Skip to content
Merged
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
46 changes: 46 additions & 0 deletions bundle_index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import fs from 'fs'
import ts from 'typescript'
import { rollup } from 'rollup'

const bundleLayers = await rollup({
external: [/lib\/model\/nns\/layer\/base.js/, /lib\/model\/[^/]+.js/, /lib\/util/, /node_modules/],
input: 'lib/model/nns/layer/index.js',
})
await bundleLayers.write({ format: 'esm', file: './lib/model/nns/layer/index.js' })
const layerDir = './lib/model/nns/layer'
const files = await fs.promises.readdir(layerDir)
for (const file of files) {
if (file === 'base.js' || file === 'index.js') {
continue
}
const text = (await fs.promises.readFile(`${layerDir}/${file}`)).toString()
const source = ts.createSourceFile(`${layerDir}/${file}`, text, ts.ScriptTarget.Latest)
let className = null
source.forEachChild(node => {
if (ts.isClassDeclaration(node) && !className) {
className = node.name.escapedText
}
})
await fs.promises.writeFile(
`${layerDir}/${file}`,
`import { ${className} } from './index.js'\nexport default ${className}`
)
}

const bundleOptimizer = await rollup({
external: [/lib\/util/, /node_modules/],
input: 'lib/model/nns/optimizer.js',
})
await bundleOptimizer.write({ format: 'esm', file: './lib/model/nns/optimizer.js' })

const bundleONNXLayer = await rollup({
external: [/lib\/model\/nns\/onnx\/[^/]+.js/, /lib\/util/, /node_modules/],
input: 'lib/model/nns/onnx/layer/index.js',
})
await bundleONNXLayer.write({ format: 'esm', file: './lib/model/nns/onnx/layer/index.js' })

const bundleONNXOperator = await rollup({
external: [/lib\/model\/nns\/onnx\/[^/]+.js/, /lib\/util/, /node_modules/],
input: 'lib/model/nns/onnx/operators/index.js',
})
await bundleONNXOperator.write({ format: 'esm', file: './lib/model/nns/onnx/operators/index.js' })
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"test:gui": "NODE_OPTIONS=--experimental-vm-modules npx jest --testMatch '**/gui/**/?(*.)+(spec|test).[jt]s?(x)' --coveragePathIgnorePatterns '/node_modules/' 'onnx/onnx_pb.js' --reporters default ./tests/retry-test.js ./tests/slow-test.js ./tests/gui-coverage-reporter.js --testTimeout=20000 --maxWorkers=100% --workerIdleMemoryLimit=100MB",
"types": "npm run create-entry && find lib -name \\*.d.ts -delete && tsc ./lib/**.js ./lib/**/*.js --declaration --allowJs --emitDeclarationOnly",
"document": "npm run types && typedoc --skipErrorChecking ./lib/**.d.ts",
"bundle": "node ./bundle_index.js",
"minify": "npx esbuild `find . -name \\*.js | grep -E '^./(lib|js)'` ./css/*.css --minify --allow-overwrite --keep-names --outdir=. && html-minifier --collapse-whitespace --minify-css true --minify-js true -o ./index.html ./index.html",
"build:gh-pages": "npm run document && find lib -name \\*.d.ts -delete && sed -i -e /^doc/d .gitignore && npm run minify",
"build:gh-pages": "npm run document && find lib -name \\*.d.ts -delete && sed -i -e /^doc/d .gitignore && npm run bundle && npm run minify",
"build:npm": "npm run types && npm run format"
},
"repository": {
Expand Down Expand Up @@ -67,6 +68,7 @@
"onnxruntime-web": "^1.21.0",
"playwright": "^1.44.0",
"prettier": "^3.2.5",
"rollup": "^4.37.0",
"typedoc": "^0.27.6",
"typescript": "^5.4.5",
"v8-to-istanbul": "^9.2.0"
Expand Down
136 changes: 135 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,106 @@
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==

"@rollup/rollup-android-arm-eabi@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.37.0.tgz#9bedc746a97fe707154086365f269ced92ff4aa9"
integrity sha512-l7StVw6WAa8l3vA1ov80jyetOAEo1FtHvZDbzXDO/02Sq/QVvqlHkYoFwDJPIMj0GKiistsBudfx5tGFnwYWDQ==

"@rollup/rollup-android-arm64@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.37.0.tgz#6edc6ffc8af8773e4bc28c72894dd5e846b8ee6c"
integrity sha512-6U3SlVyMxezt8Y+/iEBcbp945uZjJwjZimu76xoG7tO1av9VO691z8PkhzQ85ith2I8R2RddEPeSfcbyPfD4hA==

"@rollup/rollup-darwin-arm64@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.37.0.tgz#737a7b8be9ff79bd24a7efaae0903e8c66ac0676"
integrity sha512-+iTQ5YHuGmPt10NTzEyMPbayiNTcOZDWsbxZYR1ZnmLnZxG17ivrPSWFO9j6GalY0+gV3Jtwrrs12DBscxnlYA==

"@rollup/rollup-darwin-x64@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.37.0.tgz#a6a697bb685ca9462a7caeea5f22f6a686acff1f"
integrity sha512-m8W2UbxLDcmRKVjgl5J/k4B8d7qX2EcJve3Sut7YGrQoPtCIQGPH5AMzuFvYRWZi0FVS0zEY4c8uttPfX6bwYQ==

"@rollup/rollup-freebsd-arm64@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.37.0.tgz#18113e8e133ccb6de4b9dc9d3e09f7acff344cb7"
integrity sha512-FOMXGmH15OmtQWEt174v9P1JqqhlgYge/bUjIbiVD1nI1NeJ30HYT9SJlZMqdo1uQFyt9cz748F1BHghWaDnVA==

"@rollup/rollup-freebsd-x64@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.37.0.tgz#5e56ffd4a0d7ccfcbc86867c40b8f0e6a2c0c81e"
integrity sha512-SZMxNttjPKvV14Hjck5t70xS3l63sbVwl98g3FlVVx2YIDmfUIy29jQrsw06ewEYQ8lQSuY9mpAPlmgRD2iSsA==

"@rollup/rollup-linux-arm-gnueabihf@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.37.0.tgz#5addf1a51e1495ae7ff28d26442a88adf629c980"
integrity sha512-hhAALKJPidCwZcj+g+iN+38SIOkhK2a9bqtJR+EtyxrKKSt1ynCBeqrQy31z0oWU6thRZzdx53hVgEbRkuI19w==

"@rollup/rollup-linux-arm-musleabihf@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.37.0.tgz#00cddb9ab51086c5f2cd33cd4738259e24be4e73"
integrity sha512-jUb/kmn/Gd8epbHKEqkRAxq5c2EwRt0DqhSGWjPFxLeFvldFdHQs/n8lQ9x85oAeVb6bHcS8irhTJX2FCOd8Ag==

"@rollup/rollup-linux-arm64-gnu@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.37.0.tgz#c3b4324496236b6fd9f31fda5701c6d6060b1512"
integrity sha512-oNrJxcQT9IcbcmKlkF+Yz2tmOxZgG9D9GRq+1OE6XCQwCVwxixYAa38Z8qqPzQvzt1FCfmrHX03E0pWoXm1DqA==

"@rollup/rollup-linux-arm64-musl@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.37.0.tgz#b5222180bb1a50e6e9bc8263efd771c1ce770b6f"
integrity sha512-pfxLBMls+28Ey2enpX3JvjEjaJMBX5XlPCZNGxj4kdJyHduPBXtxYeb8alo0a7bqOoWZW2uKynhHxF/MWoHaGQ==

"@rollup/rollup-linux-loongarch64-gnu@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.37.0.tgz#5660181c1c1efb7b19c7a531d496e685236c5ce7"
integrity sha512-yCE0NnutTC/7IGUq/PUHmoeZbIwq3KRh02e9SfFh7Vmc1Z7atuJRYWhRME5fKgT8aS20mwi1RyChA23qSyRGpA==

"@rollup/rollup-linux-powerpc64le-gnu@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.37.0.tgz#8273166495d2f5d3fbc556cf42a5a6e24b78bdab"
integrity sha512-NxcICptHk06E2Lh3a4Pu+2PEdZ6ahNHuK7o6Np9zcWkrBMuv21j10SQDJW3C9Yf/A/P7cutWoC/DptNLVsZ0VQ==

"@rollup/rollup-linux-riscv64-gnu@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.37.0.tgz#9677e39288ccc91ebcd707cdd794732d701cd174"
integrity sha512-PpWwHMPCVpFZLTfLq7EWJWvrmEuLdGn1GMYcm5MV7PaRgwCEYJAwiN94uBuZev0/J/hFIIJCsYw4nLmXA9J7Pw==

"@rollup/rollup-linux-riscv64-musl@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.37.0.tgz#71cc5ca7be1ed263357618bfe4f8f50c09725a7e"
integrity sha512-DTNwl6a3CfhGTAOYZ4KtYbdS8b+275LSLqJVJIrPa5/JuIufWWZ/QFvkxp52gpmguN95eujrM68ZG+zVxa8zHA==

"@rollup/rollup-linux-s390x-gnu@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.37.0.tgz#6b0b7df33eb32b0ee7423898b183acc1b5fee33e"
integrity sha512-hZDDU5fgWvDdHFuExN1gBOhCuzo/8TMpidfOR+1cPZJflcEzXdCy1LjnklQdW8/Et9sryOPJAKAQRw8Jq7Tg+A==

"@rollup/rollup-linux-x64-gnu@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.37.0.tgz#52c27717d3c4819d13b5ebc2373ddea099d2e71b"
integrity sha512-pKivGpgJM5g8dwj0ywBwe/HeVAUSuVVJhUTa/URXjxvoyTT/AxsLTAbkHkDHG7qQxLoW2s3apEIl26uUe08LVQ==

"@rollup/rollup-linux-x64-musl@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.37.0.tgz#c134a22d30642345de8b799c816345674bf68019"
integrity sha512-E2lPrLKE8sQbY/2bEkVTGDEk4/49UYRVWgj90MY8yPjpnGBQ+Xi1Qnr7b7UIWw1NOggdFQFOLZ8+5CzCiz143w==

"@rollup/rollup-win32-arm64-msvc@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.37.0.tgz#8063d5f8195dd1845e056d069366fbe06a424d09"
integrity sha512-Jm7biMazjNzTU4PrQtr7VS8ibeys9Pn29/1bm4ph7CP2kf21950LgN+BaE2mJ1QujnvOc6p54eWWiVvn05SOBg==

"@rollup/rollup-win32-ia32-msvc@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.37.0.tgz#891d90e3b5517f9d290bb416afdfe2ebfb12139e"
integrity sha512-e3/1SFm1OjefWICB2Ucstg2dxYDkDTZGDYgwufcbsxTHyqQps1UQf33dFEChBNmeSsTOyrjw2JJq0zbG5GF6RA==

"@rollup/rollup-win32-x64-msvc@4.37.0":
version "4.37.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.37.0.tgz#a54d7304c3bd45573d8bcd1270de89771f8195fe"
integrity sha512-LWbXUBwn/bcLx2sSsqy7pK5o+Nr+VCoRoAohfJ5C/aBio9nfJmGQqHAhU6pwxV/RmyTk5AqdySma7uwWGlmeuA==

"@shikijs/engine-oniguruma@^1.27.2":
version "1.29.2"
resolved "https://registry.yarnpkg.com/@shikijs/engine-oniguruma/-/engine-oniguruma-1.29.2.tgz#d879717ced61d44e78feab16f701f6edd75434f1"
Expand Down Expand Up @@ -890,6 +990,11 @@
resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz"
integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==

"@types/estree@1.0.6":
version "1.0.6"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==

"@types/graceful-fs@^4.1.3":
version "4.1.9"
resolved "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz"
Expand Down Expand Up @@ -1731,7 +1836,7 @@ fsevents@2.3.2:
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

fsevents@^2.3.2:
fsevents@^2.3.2, fsevents@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==
Expand Down Expand Up @@ -2909,6 +3014,35 @@ reusify@^1.0.4:
resolved "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz"
integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==

rollup@^4.37.0:
version "4.37.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.37.0.tgz#e4172f8bdb6ea7df08a1b0acf99abeccb2250378"
integrity sha512-iAtQy/L4QFU+rTJ1YUjXqJOJzuwEghqWzCEYD2FEghT7Gsy1VdABntrO4CLopA5IkflTyqNiLNwPcOJ3S7UKLg==
dependencies:
"@types/estree" "1.0.6"
optionalDependencies:
"@rollup/rollup-android-arm-eabi" "4.37.0"
"@rollup/rollup-android-arm64" "4.37.0"
"@rollup/rollup-darwin-arm64" "4.37.0"
"@rollup/rollup-darwin-x64" "4.37.0"
"@rollup/rollup-freebsd-arm64" "4.37.0"
"@rollup/rollup-freebsd-x64" "4.37.0"
"@rollup/rollup-linux-arm-gnueabihf" "4.37.0"
"@rollup/rollup-linux-arm-musleabihf" "4.37.0"
"@rollup/rollup-linux-arm64-gnu" "4.37.0"
"@rollup/rollup-linux-arm64-musl" "4.37.0"
"@rollup/rollup-linux-loongarch64-gnu" "4.37.0"
"@rollup/rollup-linux-powerpc64le-gnu" "4.37.0"
"@rollup/rollup-linux-riscv64-gnu" "4.37.0"
"@rollup/rollup-linux-riscv64-musl" "4.37.0"
"@rollup/rollup-linux-s390x-gnu" "4.37.0"
"@rollup/rollup-linux-x64-gnu" "4.37.0"
"@rollup/rollup-linux-x64-musl" "4.37.0"
"@rollup/rollup-win32-arm64-msvc" "4.37.0"
"@rollup/rollup-win32-ia32-msvc" "4.37.0"
"@rollup/rollup-win32-x64-msvc" "4.37.0"
fsevents "~2.3.2"

run-parallel@^1.1.9:
version "1.2.0"
resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz"
Expand Down