Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

add bundle #133

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ dist/
pkg/
bound/typescript/src/wasm/generated.js
bound/typescript/src/wasm/generated.d.ts
bound/typescript/tests/compiled
bound/typescript/tests/compiled
bound/typescript/generate-mappings/node_modules/
bound/typescript/node_modules/
examples/hosted-wallet-ts/node_modules/
14 changes: 7 additions & 7 deletions bound/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
"private": false,
"type": "module",
"description": "",
"types": "./dist/tbdex.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/tbdex.d.ts"
"types": "./dist/index.d.ts"
}
},
"files": [
"./dist/index.js",
"./dist/bundle.js",
"./dist/tbdex.d.ts"
"dist"
],
"devDependencies": {
"@types/chai": "4.3.0",
Expand All @@ -33,8 +32,9 @@
},
"scripts": {
"clean": "rimraf pkg tests/compiled dist",
"build:wasm": "./scripts/build.sh && node ./scripts/bundle.js && cp dist/bundle.js src/wasm/generated.js && cp dist/tbdex_wasm.d.ts src/wasm/generated.d.ts && (cd ./generate-mappings && npm run generate)",
"build": "tsc && cp -r src/wasm dist/bound/typescript/src",
"build:wasm": "./scripts/build.sh && node ./scripts/bundle_wasm.js && (cd ./generate-mappings && npm run generate)",
"build": "tsc",

"test:node": "npm run build && node tests/bundle-node.js && mocha",
"test:browser": "npm run build && node tests/bundle-browser.js && web-test-runner",
"test": "npm run test:node && npm run test:browser"
Expand Down
18 changes: 18 additions & 0 deletions bound/typescript/scripts/bundle_tbdex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// import { fileURLToPath } from 'node:url';
// import esbuild from 'esbuild';
// import path from 'node:path';

// const __filename = fileURLToPath(import.meta.url);
// const __dirname = path.dirname(__filename);

// esbuild.buildSync({
// entryPoints: [`${__dirname}/../src/index.ts`],
// format: 'esm',
// bundle: true,
// minify: true,
// sourcemap: true,
// outfile: `${__dirname}/../dist/index.js`,
// target: 'esnext',
// platform: 'node',
// external: ['node_modules/*']
// });
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ esbuild.buildSync({
bundle: true,
minify: true,
entryPoints: [`${__dirname}/../pkg/tbdex_wasm.js`],
outfile: `${__dirname}/../dist/bundle.js`,
outfile: `${__dirname}/../src/wasm/generated.js`,
allowOverwrite: true,
})

fs.copyFileSync(`${__dirname}/../pkg/tbdex_wasm.d.ts`, `${__dirname}/../dist/tbdex_wasm.d.ts`)
fs.copyFileSync(`${__dirname}/../pkg/tbdex_wasm.d.ts`, `${__dirname}/../src/wasm/generated.d.ts`)
44 changes: 44 additions & 0 deletions bound/typescript/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// TODO: Generate this file automatically

// messages
export * from './messages';
export * from './messages/cancel';
export * from './messages/cancel';
export * from './messages/close';
export * from './messages/order';
export * from './messages/order-instructions';
export * from './messages/order-status';
export * from './messages/quote';
export * from './messages/rfq';

// resources
export * from './resources';
export * from './resources/balance'
export * from './resources/offering'

// wasm
export * from './wasm';

// http
export * from './http/exchanges'
export * from './http/exchanges/create-exchange';
export {GetExchangesResponseBody} from './http/exchanges/get-exchange-ids';
export * from './http/exchanges/get-exchange';
export * from './http/exchanges/reply-to';
export * from './http/exchanges/update-exchange';


export * from './http/balances'
export * from './http/offerings'

// http-client
export * from './http-client/balances'
export * from './http-client/exchanges'
export * from './http-client/offerings'

// web5
export * from './bearer-did';
export * from './errors';
export * from './key-managers';
export * from './portable-did';
export * from './signers';
2 changes: 1 addition & 1 deletion bound/typescript/tests/bundle-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

esbuild.buildSync({
entryPoints : [`${__dirname}/../dist/bound/typescript/tests/**/*.test.js`],
entryPoints: [`${__dirname}/*.test.ts`],
format : 'esm',
bundle : true,
sourcemap : true,
Expand Down
2 changes: 1 addition & 1 deletion bound/typescript/tests/bundle-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

esbuild.buildSync({
entryPoints: [`${__dirname}/../dist/bound/typescript/tests/**/*.test.js`],
entryPoints: [`${__dirname}/*.test.ts`],
format: 'esm',
bundle: true,
sourcemap: true,
Expand Down
12 changes: 7 additions & 5 deletions bound/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
"resolveJsonModule": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
"skipLibCheck": true,
"declaration": true,
"declarationMap": true
},
"include": [
"src/**/*",
"tests/**/*"
"src/**/*"
],
"exclude": [
"node_modules"
"node_modules",
"tests"
]
}
}
4 changes: 4 additions & 0 deletions examples/hosted-wallet-ts/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PFI_DID_URI=did:example:pfi12345
HOSTED_WALLET_VERIFIABLE_CREDENTIAL=your_verifiable_credential_here
HOSTED_WALLET_PORTABLE_DID_JSON={"uri":"did:example:wallet12345","document":{},"privateKeys":[]}
REPLY_TO_URL=http://localhost:8081/pfi-reply-to
11 changes: 11 additions & 0 deletions examples/hosted-wallet-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# hosted-wallet-ts

This is a TypeScript implementation of the hosted wallet example, showcasing a simple end-to-end tbDEX exchange.

## How-To

### 1. Install Dependencies

```bash
npm install
```
Loading