From 7e065ed9273c374457405e2b1def45d1237430db Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Mon, 24 Aug 2026 06:44:02 +0800 Subject: [PATCH 1/5] build: restore the vendored interscript-ts dependency (CI red since fbadcbc) --- package-lock.json | 1681 ++++++++++++++++++++++++++++++++++++++++++--- package.json | 10 +- 2 files changed, 1581 insertions(+), 110 deletions(-) diff --git a/package-lock.json b/package-lock.json index 863b1a0..881b34a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,17 @@ { "name": "@interscript/api-worker", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@interscript/api-worker", - "version": "0.1.0", + "version": "1.0.0", "license": "BSD-3-Clause", "dependencies": { "graphql-yoga": "^5.0.0", "hono": "^4.0.0", - "interscript-ts": "file:../interscript-ts" + "interscript-ts": "file:vendor/interscript-ts" }, "devDependencies": { "@cloudflare/workers-types": "^5.20260811.1", @@ -22,7 +22,8 @@ "typescript": "^5.6.0", "typescript-eslint": "^8.0.0", "vitest": "^2.0.0", - "wrangler": "^4.0.0" + "wrangler": "^4.0.0", + "yaml": "^2.9.0" }, "engines": { "node": ">=20" @@ -30,6 +31,7 @@ }, "../interscript-ts": { "version": "0.1.0", + "extraneous": true, "license": "BSD-2-Clause", "dependencies": { "fflate": "^0.8.3", @@ -56,6 +58,66 @@ "node": ">=20" } }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/@cloudflare/kv-asset-handler": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.5.0.tgz", @@ -729,7 +791,6 @@ "integrity": "sha512-Y3kKLvC1dvTOT+oGlqNQ1XLqK6D1HU2YXPc52NmAlJZbMMWDzGYXMiPRJ8TYD39muD/OTjlZmNJ4ib7dvSrMBA==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@eslint/object-schema": "^3.0.5", "debug": "^4.3.1", @@ -745,7 +806,6 @@ "integrity": "sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@eslint/core": "^1.2.1" }, @@ -759,7 +819,6 @@ "integrity": "sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@types/json-schema": "^7.0.15" }, @@ -786,7 +845,6 @@ "integrity": "sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": "^20.19.0 || ^22.13.0 || >=24" } @@ -797,7 +855,6 @@ "integrity": "sha512-+CNAzxglkrpNf/kKywqQfk74QjtceuOE7Qm+AF8miRvPF/wmmK5+OJOgVh3AVTT3RP2mH3+FOaxlE5v72owk0A==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@eslint/core": "^1.2.1", "levn": "^0.4.1" @@ -992,7 +1049,6 @@ "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@humanfs/types": "^0.15.0" }, @@ -1006,7 +1062,6 @@ "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "@humanfs/core": "^0.19.2", "@humanfs/types": "^0.15.0", @@ -1022,7 +1077,6 @@ "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=18.18.0" } @@ -1033,7 +1087,6 @@ "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=12.22" }, @@ -1048,7 +1101,6 @@ "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", "dev": true, "license": "Apache-2.0", - "peer": true, "engines": { "node": ">=18.18" }, @@ -1629,6 +1681,16 @@ "node": "^22.20 || ^24.12 || >=25" } }, + "node_modules/@oxc-project/types": { + "version": "0.146.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.146.0.tgz", + "integrity": "sha512-XC0QsnnhVe7sLIWmYmdPw7x5P0h4W8vUU3Nv1ySgWXtvCz8NizoAEpGXA0sOYoJQV2Rl13LgURAHQ5cI5ILCSA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, "node_modules/@poppinss/colors": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", @@ -1664,6 +1726,268 @@ "integrity": "sha512-TaoVksZRSx2KWYYpyLQtMQXXeS98VsgZImzW65xmiVgbYhXLk+aEsmzPLirqVuE4/XuUapH2iMtxUzaBNDzdSQ==", "license": "MIT" }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.5.tgz", + "integrity": "sha512-DLe/i+l8ynIBY7XEQ191TeZvCoowIGa18R+dIV30GW7DiOtp74i/xX8hs8GUjW5ARV7VZuie3d6AumSmCwbeRA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.5.tgz", + "integrity": "sha512-zXcwKlQApYAOELHd8PwKDFkagYF9Wy4e0RJ+0qnzl9Pjnpj75TEG8ufv40p2J7kCEfwZAsNiuzRIyNNMWT38ig==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.5.tgz", + "integrity": "sha512-dK4QakI42nzWgJT5sm4y4y/O//D4OxM75/cH28RLV+nzIN9AY+YsbuUVrUTjlLjXR6vpyxFbSsbmNuJ6BP9sww==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.5.tgz", + "integrity": "sha512-fqSALaUu1Wjd1nK2uW2kJDWdLCc8lx1IcY+MTY26Aurfdx19anlzhqXOgCFbBFQnlFDTn4TC1/7Nz4Bl2mLP3A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.5.tgz", + "integrity": "sha512-/vCnNxlkxs9tKxNDcyWUePpJ/PgTzxIaVhoM5SmG8UV+GR/IcPam4VYxi7GIMo7PSDuNqlJqvprqii9NqqVCMw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.5.tgz", + "integrity": "sha512-abk0NLA519LxRCszmbE0jYKuQ9YPocOXTiOXOo6Yr+YAT95VH+PtqYAjOJvGKt3viEd/x4qzabAlwd5bHOOARg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.5.tgz", + "integrity": "sha512-Y7eALiJ8lr0M2HH103Js+g7V34wf6snlpZLAsHI90uLhr3PVlNsbFVAXJC9d/V6BnPyKtpSwI+NcB/RLxsQxuA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.5.tgz", + "integrity": "sha512-xMvZgnbZg4YVnR/AX2b3oOPDTFYJvUVaJg5FedA/LuvexAtXibZQej4cnTkw3rjsJ/ggUROB64TdtETiim+FYA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.5.tgz", + "integrity": "sha512-GRjeqTUDHTo5GwntsLaAMcBahG3nlpjftXWZLN73HiYQlhwEowvarFgQnRnQZtIp4keXX7quXFbG38uPZBa2EA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.5.tgz", + "integrity": "sha512-vLNTR45F2Uwc8AufkNXPmB4VliaXs+FvcheEogIzOXzO4l+LzieXF5A/TWxLy5HtqpsRCHUfd0lPVrrdgXdLHQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.5.tgz", + "integrity": "sha512-Mgj59/HTuYeK9Gz2MA+mBWKnHsAgkBSec15ZMb1st3oIfFbX7gCjOae7GydHhzcyQi9Z/7M1QuN9bR3oFqF0jQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.5.tgz", + "integrity": "sha512-mY8AP0/ichsbhAxGnLa3d3+MwV0EfgrPND2bplI3Ym8T6R2pJ0N87bvrKVwNXmdy3jnr6eQBecdqx/HMknBmpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.5.tgz", + "integrity": "sha512-8SLssA2oweAxyRgDp789ACfRb/3P+zNRJpzZxSizxF9m8NUDQ4+3xjo8ttjhVGGw6Qxb70oZiEtIjaKikCO7Yw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.5.tgz", + "integrity": "sha512-vGbruD5zquhoc8D9SViXgN2FBJtNdTyQ4DtG+SWiEGlJiAzoKcZ2xp+xuXCffhubVdt0NJlTZqkeRuERy7g8Cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.5.tgz", + "integrity": "sha512-e/SXpgISz+IoqVcSSI0rx/d/he8zqLex+/rCWpnHpmVfmPIUjag9H6P7zotf0gJHwPUhQxZ/mF8tr6acebT9yw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT" + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.62.4", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.4.tgz", @@ -2034,13 +2358,37 @@ "dev": true, "license": "CC0-1.0" }, - "node_modules/@types/esrecurse": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", - "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/esrecurse": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", + "integrity": "sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==", + "dev": true, + "license": "MIT" }, "node_modules/@types/estree": { "version": "1.0.9", @@ -2049,13 +2397,19 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/js-yaml": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.9.tgz", + "integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@types/node": { "version": "26.2.0", @@ -2497,7 +2851,6 @@ "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2511,18 +2864,26 @@ "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, "license": "MIT", - "peer": true, "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/adm-zip": { + "version": "0.5.18", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.18.tgz", + "integrity": "sha512-ufJnssQGbxzLNS1Ho9bCtX4rQKCCvoVuDLHoJyc3F9dOGDB4BkWs2Ci0kv53lqocAEQ/Cbi+I2XCsNYGqVYqng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0" + } + }, "node_modules/ajv": { "version": "6.15.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -2534,6 +2895,12 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, "node_modules/assertion-error": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", @@ -2544,6 +2911,29 @@ "node": ">=12" } }, + "node_modules/ast-v8-to-istanbul": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.5.tgz", + "integrity": "sha512-UPAgKJFSEGMWSDr3LX4tqnAb4f7KGT8O40Tyx8wbYmmZ/yn58lNCm8h3svs3eXgiGd5AXxz8NDOvXWvicq+rJA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.31", + "estree-walker": "^3.0.3", + "js-tokens": "^10.0.0" + } + }, + "node_modules/ast-v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", @@ -2611,6 +3001,13 @@ "node": ">= 16" } }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, "node_modules/cookie": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", @@ -2643,7 +3040,6 @@ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -2686,8 +3082,43 @@ "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true, + "license": "MIT" + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, "license": "MIT", - "peer": true + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/detect-libc": { "version": "2.1.2", @@ -2709,6 +3140,26 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/es-module-lexer": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", @@ -2764,7 +3215,6 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -2778,7 +3228,6 @@ "integrity": "sha512-wqA7W2jbsC/BnV9Iv1UZpKVFkO1AdNoSmYW8NWG4HNOBbkAMvIqDZ27pI2f07dqn583NcIC44ckjAcOXDL1QbQ==", "dev": true, "license": "MIT", - "peer": true, "workspaces": [ "packages/*" ], @@ -2832,13 +3281,28 @@ } } }, + "node_modules/eslint-config-prettier": { + "version": "10.1.8", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz", + "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "funding": { + "url": "https://opencollective.com/eslint-config-prettier" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-scope": { "version": "9.1.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-9.1.2.tgz", "integrity": "sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "@types/esrecurse": "^4.3.1", "@types/estree": "^1.0.8", @@ -2871,7 +3335,6 @@ "integrity": "sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "acorn": "^8.16.0", "acorn-jsx": "^5.3.2", @@ -2890,7 +3353,6 @@ "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", "dev": true, "license": "BSD-3-Clause", - "peer": true, "dependencies": { "estraverse": "^5.1.0" }, @@ -2904,7 +3366,6 @@ "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "estraverse": "^5.2.0" }, @@ -2918,7 +3379,6 @@ "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "engines": { "node": ">=4.0" } @@ -2939,7 +3399,6 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -2959,24 +3418,21 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/fdir": { "version": "6.5.0", @@ -2996,13 +3452,18 @@ } } }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "license": "MIT" + }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "flat-cache": "^4.0.0" }, @@ -3016,7 +3477,6 @@ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "locate-path": "^6.0.0", "path-exists": "^4.0.0" @@ -3034,7 +3494,6 @@ "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "flatted": "^3.2.9", "keyv": "^4.5.4" @@ -3048,8 +3507,7 @@ "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", "dev": true, - "license": "ISC", - "peer": true + "license": "ISC" }, "node_modules/fsevents": { "version": "2.3.2", @@ -3072,7 +3530,6 @@ "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "is-glob": "^4.0.3" }, @@ -3080,6 +3537,52 @@ "node": ">=10.13.0" } }, + "node_modules/global-agent": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-4.1.3.tgz", + "integrity": "sha512-KUJEViiuFT3I97t+GYMikLPJS2Lfo/S2F+DQuBWzuzaMPnvt5yyZePzArx36fBzpGTxZjIpDbXLeySLgh+k76g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "globalthis": "^1.0.2", + "matcher": "^4.0.0", + "semver": "^7.3.5", + "serialize-error": "^8.1.0" + }, + "engines": { + "node": ">=10.0" + } + }, + "node_modules/globalthis": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", + "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-properties": "^1.2.1", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/graphql": { "version": "16.14.2", "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.14.2.tgz", @@ -3116,6 +3619,29 @@ "graphql": "^15.2.0 || ^16.0.0" } }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/hono": { "version": "4.13.2", "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.2.tgz", @@ -3125,13 +3651,19 @@ "node": ">=16.9.0" } }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">= 4" } @@ -3142,13 +3674,12 @@ "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.8.19" } }, "node_modules/interscript-ts": { - "resolved": "../interscript-ts", + "resolved": "vendor/interscript-ts", "link": true }, "node_modules/is-extglob": { @@ -3157,7 +3688,6 @@ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -3168,7 +3698,6 @@ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "is-extglob": "^2.1.1" }, @@ -3181,32 +3710,109 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true, - "license": "ISC", - "peer": true + "license": "ISC" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-reports": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", + "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/js-tokens": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz", + "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-5.3.0.tgz", + "integrity": "sha512-muutsYr+e2+d3rTgUGslq5rxbBlUy3cJ61IsHag2QNDQV+7zXWjkUpmALIajhrlLlrgRUiymj6U3zUr/TMK84Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.mjs" + } }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/keyv": { "version": "4.5.4", @@ -3214,7 +3820,6 @@ "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "json-buffer": "3.0.1" } @@ -3235,7 +3840,6 @@ "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" @@ -3244,37 +3848,297 @@ "node": ">= 0.8.0" } }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", "dev": true, - "license": "MIT", - "peer": true, + "license": "MPL-2.0", "dependencies": { - "p-locate": "^5.0.0" + "detect-libc": "^2.0.3" }, "engines": { - "node": ">=10" + "node": ">= 12.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" } }, - "node_modules/loupe": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", - "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], "dev": true, - "license": "MIT" - }, - "node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "license": "ISC" - }, - "node_modules/magic-string": { + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loupe": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", + "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "license": "ISC" + }, + "node_modules/magic-string": { "version": "0.30.21", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", @@ -3284,6 +4148,50 @@ "@jridgewell/sourcemap-codec": "^1.5.5" } }, + "node_modules/magicast": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.4.tgz", + "integrity": "sha512-llBEhWm1SacoRwgHUoQJYtwp4PBLF4faQi5TCpIGyGs9n4y5+juI0tDgyKIfpqxckRHaHzouUEph3THklWh03w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", + "source-map-js": "^1.2.1" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/matcher": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/matcher/-/matcher-4.0.0.tgz", + "integrity": "sha512-S6x5wmcDmsDRRU/c2dkccDwQPXoFczc5+HpQ2lON8pnvHlnvHAHj5WlLVvw6n6vNyHuVugYrFohYxbS+pvFpKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/miniflare": { "version": "5.20260811.1-alpha", "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-5.20260811.1-alpha.tgz", @@ -3351,13 +4259,61 @@ "dev": true, "license": "MIT" }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/obug": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.4.tgz", + "integrity": "sha512-4a+OsYv9UktOJKE+l1A4OufDgdRF9PifWj+tJnHURo/P+WOxpG4GzUFL9qCalmWauao6ogiG+QvnCovwPoyAWA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/onnxruntime-common": { + "version": "1.27.0", + "resolved": "https://registry.npmjs.org/onnxruntime-common/-/onnxruntime-common-1.27.0.tgz", + "integrity": "sha512-3KxL5wIVqa8Ex08jxSzncm9CMgw8CjOFyOQ7SxvG9o0cVLlhTNKXyIQuTbtX4tGPJEf73OER2xrjt4HJSBL4ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/onnxruntime-node": { + "version": "1.27.0", + "resolved": "https://registry.npmjs.org/onnxruntime-node/-/onnxruntime-node-1.27.0.tgz", + "integrity": "sha512-QEzGwrvNBgv4uPVdnbHsOGG4G6T96mdlcFI8aAKPjMU8wOPpVocPXb6k3QGkaZagVTv2G9Bnnbo6Z3JdXr1fQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "os": [ + "win32", + "darwin", + "linux" + ], + "dependencies": { + "adm-zip": "^0.5.16", + "global-agent": "^4.1.3", + "onnxruntime-common": "1.27.0" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", @@ -3376,7 +4332,6 @@ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "yocto-queue": "^0.1.0" }, @@ -3393,7 +4348,6 @@ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "p-limit": "^3.0.2" }, @@ -3410,7 +4364,6 @@ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -3421,7 +4374,6 @@ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -3470,6 +4422,38 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/playwright": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.62.1.tgz", + "integrity": "sha512-0M+L3LAD8/nm554LOla9Ayx0j0tmFZ0FBcoQ7F1VuVHpM/XpiC8RcDzBQB8W5+hA8L22THxELzeF+2WcUzvcLg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.62.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.62.1.tgz", + "integrity": "sha512-wPYSwEBJY9GHraISXqyqtx0na0LpO3XEX7jNDhntbex7tzUS7kLnZsOlFruFJB4Hi/rhDMjXGqHewDZ68nYZVw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/postcss": { "version": "8.5.26", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz", @@ -3505,7 +4489,6 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">= 0.8.0" } @@ -3532,25 +4515,58 @@ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6" } }, - "node_modules/rollup": { - "version": "4.62.4", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.4.tgz", - "integrity": "sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==", + "node_modules/rolldown": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.5.tgz", + "integrity": "sha512-VD2IE5PUG4Oj8zz2VGykiYd5wbnjdIiSsNQb8Qu5B+noEp+A78mu2iVvpp27g8es14Tk9rofNs5Tku9iQCS4fA==", "dev": true, "license": "MIT", "dependencies": { - "@types/estree": "1.0.9" + "@oxc-project/types": "=0.146.0", + "@rolldown/pluginutils": "^1.0.0" }, "bin": { - "rollup": "dist/bin/rollup" + "rolldown": "bin/cli.mjs" }, "engines": { - "node": ">=18.0.0", + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.5", + "@rolldown/binding-android-arm64": "1.2.5", + "@rolldown/binding-darwin-arm64": "1.2.5", + "@rolldown/binding-darwin-x64": "1.2.5", + "@rolldown/binding-freebsd-x64": "1.2.5", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.5", + "@rolldown/binding-linux-arm64-gnu": "1.2.5", + "@rolldown/binding-linux-arm64-musl": "1.2.5", + "@rolldown/binding-linux-ppc64-gnu": "1.2.5", + "@rolldown/binding-linux-s390x-gnu": "1.2.5", + "@rolldown/binding-linux-x64-gnu": "1.2.5", + "@rolldown/binding-linux-x64-musl": "1.2.5", + "@rolldown/binding-openharmony-arm64": "1.2.5", + "@rolldown/binding-win32-arm64-msvc": "1.2.5", + "@rolldown/binding-win32-x64-msvc": "1.2.5" + } + }, + "node_modules/rollup": { + "version": "4.62.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.4.tgz", + "integrity": "sha512-RXOqwaPsBGjMNMa4sQjDjHieHEZDFoj/Rdr46l2MU5DfEs16wHJPC2RPTPHWhNl+M3aI472LLqFkFKut4SblOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", "npm": ">=8.0.0" }, "optionalDependencies": { @@ -3596,6 +4612,22 @@ "node": ">=10" } }, + "node_modules/serialize-error": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-8.1.0.tgz", + "integrity": "sha512-3NnuWfM6vBYoy5gZFvHiYsVbafvI9vZv/+jlIigFn4oP4zjNPK3LhcY0xSCgeb1a5L8jO71Mit9LlNoi2UfDDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/sharp": { "version": "0.35.2", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.2.tgz", @@ -3647,7 +4679,6 @@ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "shebang-regex": "^3.0.0" }, @@ -3661,7 +4692,6 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=8" } @@ -3796,7 +4826,6 @@ "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "prelude-ls": "^1.2.1" }, @@ -3804,6 +4833,19 @@ "node": ">= 0.8.0" } }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", @@ -3882,7 +4924,6 @@ "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "punycode": "^2.1.0" } @@ -4493,7 +5534,6 @@ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "license": "ISC", - "peer": true, "dependencies": { "isexe": "^2.0.0" }, @@ -4527,7 +5567,6 @@ "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -5110,13 +6149,28 @@ } } }, + "node_modules/yaml": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz", + "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=10" }, @@ -5151,7 +6205,6 @@ }, "vendor/interscript-ts": { "version": "0.1.0", - "extraneous": true, "license": "BSD-2-Clause", "dependencies": { "fflate": "^0.8.3", @@ -5177,6 +6230,422 @@ "engines": { "node": ">=20" } + }, + "vendor/interscript-ts/node_modules/@eslint/js": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-10.0.1.tgz", + "integrity": "sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "eslint": "^10.0.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "vendor/interscript-ts/node_modules/@types/node": { + "version": "22.20.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz", + "integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "vendor/interscript-ts/node_modules/@vitest/coverage-v8": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.11.tgz", + "integrity": "sha512-8MVGEFnJIcdGjcbfKmeq8z0pZHH0JlVtoVZH9Q/qwUp6wyFnEJUBMrw9DCaj+ra3vShGmhavjalMIhPNxZAUcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^1.0.2", + "@vitest/utils": "4.1.11", + "ast-v8-to-istanbul": "^1.0.0", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-reports": "^3.2.0", + "magicast": "^0.5.2", + "obug": "^2.1.1", + "std-env": "^4.0.0-rc.1", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "4.1.11", + "vitest": "4.1.11" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, + "vendor/interscript-ts/node_modules/@vitest/expect": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.11.tgz", + "integrity": "sha512-VX2x5vNJXET47KAFzwERI+KRMtTTCSWTfSMKsW7JsUsXV4psq++e3DvZpuTDOpHcxytiDs6p2nhVb2tVDiiUYw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.1.0", + "@types/chai": "^5.2.2", + "@vitest/spy": "4.1.11", + "@vitest/utils": "4.1.11", + "chai": "^6.2.2", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "vendor/interscript-ts/node_modules/@vitest/pretty-format": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.11.tgz", + "integrity": "sha512-yiZzPbGTS9Sr/JpFl8zHrcIkAofNbFV6k21vIgQN/cY/oxZeXhJv5sc/MBJ5jFKWmWs+oJHw0UXLZjmf931+Vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "vendor/interscript-ts/node_modules/@vitest/runner": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.11.tgz", + "integrity": "sha512-LztvUgdwMNJMIkj3hQnnxiC2Xy1zNxq928W/xhjCLaNCzqTZOudjwbQf6v9IntZGPw132i2Lq2rgTRZHD3JHNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.1.11", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "vendor/interscript-ts/node_modules/@vitest/snapshot": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.11.tgz", + "integrity": "sha512-pN7ikn1ON7h8ee4gIAp4AzyK+zBtJPzVbqOgu5LCEh4VaJVbPQcgYQYJIMGQPXVeJJq1fnfazis7a5pFNPahog==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.1.11", + "@vitest/utils": "4.1.11", + "magic-string": "^0.30.21", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "vendor/interscript-ts/node_modules/@vitest/spy": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.11.tgz", + "integrity": "sha512-apNa/prQy2qCeywhnixOHPRCgGNhvg7T4Dapfl1GahLp/R+uhBm5cPyFoNVyqsNd2h1nJxL6BqqdIjiABL60YA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "vendor/interscript-ts/node_modules/@vitest/utils": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.11.tgz", + "integrity": "sha512-zTCVGpyFsGWBhllOyKlTw/vnr6D9qxsfSDyfbyZmTyjHw5N/VuvzHpHoQjm2ZJzn4RJgx5w4r7V0er69CmLgPQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.1.11", + "convert-source-map": "^2.0.0", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "vendor/interscript-ts/node_modules/chai": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", + "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "vendor/interscript-ts/node_modules/es-module-lexer": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", + "dev": true, + "license": "MIT" + }, + "vendor/interscript-ts/node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "vendor/interscript-ts/node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "vendor/interscript-ts/node_modules/std-env": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.2.0.tgz", + "integrity": "sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==", + "dev": true, + "license": "MIT" + }, + "vendor/interscript-ts/node_modules/tinyexec": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.0.tgz", + "integrity": "sha512-QKAl9m8gWWGHV8jZcPeym6j+XULi6tOf1mT83WYJ4Lk2ytW/uwAWkrP0uFsdoYMdueVJ0qs26wZ+23xeB4ibNQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "vendor/interscript-ts/node_modules/tinyrainbow": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.1.tgz", + "integrity": "sha512-yau8yJdTt989Mm0Bd/236QnzEiPf2xLLTqUZRUJOo/3CB078LSwzei343DgtJVmfJKJE3TMINY1u42SQsP6mXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "vendor/interscript-ts/node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "vendor/interscript-ts/node_modules/vite": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.2.tgz", + "integrity": "sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.5", + "postcss": "^8.5.26", + "rolldown": "~1.2.4", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.4.0 || ^0.5.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "vendor/interscript-ts/node_modules/vitest": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.11.tgz", + "integrity": "sha512-fhACrNXUidIbGSBr5FlbuBkO7VWC1ZyLl0DO4CU2DrQoAPxX84Ysxs+HeGQpii5lZWV1Q4gBZTTu49mF+A6Edw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.1.11", + "@vitest/mocker": "4.1.11", + "@vitest/pretty-format": "4.1.11", + "@vitest/runner": "4.1.11", + "@vitest/snapshot": "4.1.11", + "@vitest/spy": "4.1.11", + "@vitest/utils": "4.1.11", + "es-module-lexer": "^2.0.0", + "expect-type": "^1.3.0", + "magic-string": "^0.30.21", + "obug": "^2.1.1", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "std-env": "^4.0.0-rc.1", + "tinybench": "^2.9.0", + "tinyexec": "^1.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.1.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.1.11", + "@vitest/browser-preview": "4.1.11", + "@vitest/browser-webdriverio": "4.1.11", + "@vitest/coverage-istanbul": "4.1.11", + "@vitest/coverage-v8": "4.1.11", + "@vitest/ui": "4.1.11", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, + "vendor/interscript-ts/node_modules/vitest/node_modules/@vitest/mocker": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.11.tgz", + "integrity": "sha512-2XJVD55d1o5AZous5CCGKS74g/riOj9odEt2bQpCVZeblHyHdnMeFl4jl0XjU21stf4mbjUkew2eXQZt65g5CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "4.1.11", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.21" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } } } } diff --git a/package.json b/package.json index 07e8017..f615fb3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@interscript/api-worker", "version": "1.0.0", - "description": "Interscript API software \u2014 GraphQL API for transliteration on Cloudflare Workers (or any Workers-compatible runtime). Deploy your own endpoint: see README.", + "description": "Interscript API software — GraphQL API for transliteration on Cloudflare Workers (or any Workers-compatible runtime). Deploy your own endpoint: see README.", "type": "module", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", @@ -33,8 +33,9 @@ "e2e": "node scripts/e2e.mjs" }, "dependencies": { + "graphql-yoga": "^5.0.0", "hono": "^4.0.0", - "graphql-yoga": "^5.0.0" + "interscript-ts": "file:vendor/interscript-ts" }, "devDependencies": { "@cloudflare/workers-types": "^5.20260811.1", @@ -45,7 +46,8 @@ "typescript": "^5.6.0", "typescript-eslint": "^8.0.0", "vitest": "^2.0.0", - "wrangler": "^4.0.0" + "wrangler": "^4.0.0", + "yaml": "^2.9.0" }, "engines": { "node": ">=20" @@ -58,4 +60,4 @@ "cloudflare-workers", "interscript" ] -} \ No newline at end of file +} From 66af3554efe27f823a60bad8486463c0474698e4 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Mon, 24 Aug 2026 06:44:24 +0800 Subject: [PATCH 2/5] fix: accept legacy raw-body GraphQL and route rababa codes to ML inference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The interscript.org demo POSTs GraphQL documents as the raw body with a urlencoded content type (the old Lambda accepted this); wrap such bodies as {query} so Yoga parses them. Its Diacritize button calls transliterate with the var-ara-Arab-Arab-rababa system code — route that to the Modal inference service (ara-diac-1.0) instead of failing with map_not_found. Also: regenerate the model index (adds released heb-diac-1.1; 10 models) and rewrite gen-models in pure Node (the embedded python one-liner was committed broken). --- dist/src/generated/models.json | 62 +++++- dist/src/index.js | 4 +- dist/src/limits.d.ts | 1 + dist/src/limits.js | 1 + dist/src/models.d.ts | 25 +++ dist/src/models.js | 14 ++ dist/src/openapi.d.ts | 362 +++++++++++++++++++++++++++++++++ dist/src/openapi.js | 238 ++++++++++++++++++++++ dist/src/resolvers.d.ts | 3 + dist/src/resolvers.js | 35 +++- dist/src/rest.d.ts | 22 ++ dist/src/rest.js | 151 ++++++++++++++ dist/src/server.js | 30 ++- dist/test/rest.test.d.ts | 1 + dist/test/rest.test.js | 128 ++++++++++++ dist/test/server.test.js | 61 ++++++ scripts/e2e.mjs | 30 +++ scripts/gen-models.mjs | 45 ++-- src/generated/models.json | 64 +++++- src/limits.ts | 2 + src/resolvers.ts | 41 +++- src/rest.ts | 16 +- src/server.ts | 28 ++- test/server.test.ts | 76 +++++++ 24 files changed, 1387 insertions(+), 53 deletions(-) create mode 100644 dist/src/models.d.ts create mode 100644 dist/src/models.js create mode 100644 dist/src/openapi.d.ts create mode 100644 dist/src/openapi.js create mode 100644 dist/src/rest.d.ts create mode 100644 dist/src/rest.js create mode 100644 dist/test/rest.test.d.ts create mode 100644 dist/test/rest.test.js diff --git a/dist/src/generated/models.json b/dist/src/generated/models.json index d4e498c..3561d19 100644 --- a/dist/src/generated/models.json +++ b/dist/src/generated/models.json @@ -28,7 +28,7 @@ ], "parity": { "samples": 895, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -59,7 +59,7 @@ ], "parity": { "samples": 12699, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -85,7 +85,7 @@ ], "parity": { "samples": 11940, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -116,7 +116,7 @@ "metrics": [ { "name": "der_greedy", - "value": 29.0, + "value": 29, "source": "rababa/docs/RESULTS.md#hebrew-diacritization" }, { @@ -127,7 +127,7 @@ ], "parity": { "samples": 600, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -169,7 +169,7 @@ ], "parity": { "samples": 1219, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -202,7 +202,7 @@ "samples": 1219, "cer_delta": 0.0803 }, - "license": "BSD-3-Clause" + "license": null }, { "id": "tha-g2p-small-1.0-int4", @@ -262,9 +262,9 @@ ], "parity": { "samples": 1864, - "cer_delta": 0.0 + "cer_delta": 0 }, - "license": "BSD-3-Clause" + "license": null }, { "id": "fas-g2p-1.0", @@ -304,7 +304,49 @@ ], "parity": { "samples": 1000, - "cer_delta": 0.0 + "cer_delta": 0 + }, + "license": "BSD-3-Clause" + }, + { + "id": "heb-diac-1.1", + "task": "diacritization", + "scripts": [ + "Hebr", + "Hebr" + ], + "precision": "fp32", + "filename": "heb.zip", + "url": null, + "parts": [ + { + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-00", + "sha256": "8dac0d62e9b0ac4b137412eaf3a542953f11575f12f66f76cb93d3f5d788fc1b", + "size": 1500000000 + }, + { + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-01", + "sha256": "230c5ab731ea5f001f802d60b9e9a328c10b43bc311a19ef1974f114384313ed", + "size": 1280987905 + } + ], + "sha256": "f0022dde8d06e46e8f08cf0b2f7bbb887a05ed686b90f1d5aa82ca3ef690a0b0", + "size": 2780987905, + "metrics": [ + { + "name": "der_greedy", + "value": 16.44, + "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + }, + { + "name": "der_beam4", + "value": 16.43, + "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + } + ], + "parity": { + "samples": 500, + "cer_delta": 0 }, "license": "BSD-3-Clause" } diff --git a/dist/src/index.js b/dist/src/index.js index 75da27f..297c6d6 100644 --- a/dist/src/index.js +++ b/dist/src/index.js @@ -1,4 +1,4 @@ -var Wt=Object.defineProperty;var m=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var O=(e,t)=>{for(var n in t)Wt(e,n,{get:t[n],enumerable:!0})};var Ge={};O(Ge,{createLitertSession:()=>Zt});async function Xt(){return Q||(Q=(async()=>{try{return await import("@litertjs/core")}catch(e){throw Q=void 0,new Error("@litertjs/core is required for LiteRT inference. Install with: npm install @litertjs/core",{cause:e})}})()),Q}async function Zt(e,t={}){let n=t.accelerator??"webgpu",r=t.wasmPath??Jt,a=t.inputNames??["src","lengths"],s=t.outputNames??["output"],o=await Xt();await o.loadLiteRt(r,{jspi:n==="webnn"});let c=new Blob([new Uint8Array(e)],{type:"application/octet-stream"}),i=URL.createObjectURL(c),l;return l=await o.loadAndCompile(i,{accelerator:n}),new de(l,o,a,s,i)}function en(e){return e instanceof Float32Array?"float32":e instanceof Int32Array?"int32":e instanceof BigInt64Array?"int64":e instanceof Uint8Array?"uint8":"float32"}var Jt,Q,de,He=m(()=>{"use strict";Jt="https://cdn.jsdelivr.net/npm/@litertjs/core@2.5.2/wasm/";de=class{inputNames;outputNames;model;core;blobUrl;disposed=!1;constructor(t,n,r,a,s){this.model=t,this.core=n,this.inputNames=r,this.outputNames=a,this.blobUrl=s}async run(t){if(this.disposed)throw new Error("Session disposed");let n=[];for(let s of this.inputNames){let o=t[s];if(!o)throw new Error(`Missing LiteRT input: ${s}`);n.push(new this.core.Tensor(o.data,o.dims))}let r=await this.model.run(n.length===1?n[0]:n),a={};try{for(let s=0;snn});async function tn(){try{return await import("onnxruntime-node")}catch(e){throw new Error("onnxruntime-node is required for ML inference in Node. Install with: npm install onnxruntime-node",{cause:e})}}async function nn(e){return fe.create(e)}var fe,We=m(()=>{"use strict";fe=class e{session;ort;inputNames;outputNames;inputMetadata;constructor(t,n){this.session=t,this.ort=n,this.inputNames=t.inputNames,this.outputNames=t.outputNames;let r=t.inputMetadata;Array.isArray(r)&&(this.inputMetadata=r)}static async create(t){let n=await tn(),r=await n.InferenceSession.create(t);return new e(r,n)}async run(t){let n={};for(let[s,o]of Object.entries(t))n[s]=new this.ort.Tensor(o.type,o.data,o.dims);let r=await this.session.run(n),a={};for(let[s,o]of Object.entries(r)){let c=o;a[s]={name:s,type:c.type,data:c.data,dims:c.dims}}return a}async dispose(){await this.session.release()}}});var Ve={};O(Ve,{createWebSession:()=>an});async function rn(){return Y||(Y=(async()=>{try{let e=await import("onnxruntime-web");return e.env.wasm.simd=!0,e}catch(e){throw Y=void 0,new Error("onnxruntime-web is required for ML inference in the browser. Install with: npm install onnxruntime-web",{cause:e})}})()),Y}async function an(e,t={}){return me.create(e,t)}var Y,me,Qe=m(()=>{"use strict";me=class e{session;ort;inputNames;outputNames;constructor(t,n){this.session=t,this.ort=n,this.inputNames=t.inputNames,this.outputNames=t.outputNames}static async create(t,n={}){let r=await rn(),a=n.webgpu===!1?["wasm"]:["webgpu","wasm"],s=await r.InferenceSession.create(t,{executionProviders:a});return new e(s,r)}async run(t){let n={};for(let[s,o]of Object.entries(t))n[s]=new this.ort.Tensor(o.type,o.data,o.dims);let r=await this.session.run(n),a={};for(let[s,o]of Object.entries(r)){let c=o;a[s]={name:s,type:c.type,data:c.data,dims:c.dims}}return a}async dispose(){await this.session.release()}}});function he(){let e=globalThis;return e.process?.versions?.node?"node":e.self!==void 0?"web":"unknown"}async function T(e,t={}){if((t.runtime??"onnx")==="litert"){let s={};return t.litertAccelerator!==void 0&&(s.accelerator=t.litertAccelerator),t.inputNames!==void 0&&(s.inputNames=t.inputNames),t.outputNames!==void 0&&(s.outputNames=t.outputNames),(await Promise.resolve().then(()=>(He(),Ge))).createLitertSession(e,s)}if((t.backend??he()==="node"?"node":"web")==="node")return(await Promise.resolve().then(()=>(We(),Ke))).createNodeSession(e);let a=t.webgpu===void 0?{}:{webgpu:t.webgpu};return(await Promise.resolve().then(()=>(Qe(),Ve))).createWebSession(e,a)}var J=m(()=>{"use strict"});var sn,on,Ye,Je,dr,Xe,fr,cn,Ze,ln,ge,et,be,X,P=m(()=>{"use strict";sn=["\u0652","\u0651","\u064C","\u064D","\u0650","\u064B","\u064E","\u064F"],on="\u0649\u0639\u0638\u062D\u0631\u0633\u064A\u0634\u0636\u0642 \u062B\u0644\u0635\u0637\u0643\u0622\u0645\u0627\u0625\u0647\u0632\u0621\u0623\u0641\u0624\u063A\u062C\u0626\u062F\u0629\u062E\u0648\u0628\u0630\u062A\u0646",Ye="\u0649\u0639\u0638\u062D\u0631\u0633\u064A\u0634\u0636\u0642\u062B\u0644\u0635\u0637\u0643\u0622\u0645\u0627\u0625\u0647\u0632\u0621\u0623\u0641\u0624\u063A\u062C\u0626\u062F\u0629\u062E\u0648\u0628\u0630\u062A\u0646",Je=[...sn,...on],dr=Object.freeze({"\u064E":"Fatha","\u064B":"Fathatah","\u064F":"Damma","\u064C":"Dammatan","\u0650":"Kasra","\u064D":"Kasratan","\u0652":"Sukun","\u0651":"Shaddah"}),Xe=Object.freeze({"":"No Diacritic","\u064E":"Fatha","\u064B":"Fathatah","\u064F":"Damma","\u064C":"Dammatan","\u0650":"Kasra","\u064D":"Kasratan","\u0652":"Sukun","\u0651":"Shaddah","\u0651\u064E":"Shaddah + Fatha","\u0651\u064B":"Shaddah + Fathatah","\u0651\u064F":"Shaddah + Damma","\u0651\u064C":"Shaddah + Dammatan","\u0651\u0650":"Shaddah + Kasra","\u0651\u064D":"Shaddah + Kasratan"}),fr=Object.freeze(Object.fromEntries(Object.keys(Xe).map((e,t)=>[e,t]))),cn="P",Ze=[cn,...Object.keys(Xe),""],ln="\u0628\u0636.\u063A\u0649\u0647\u0638\u062E\u0629\u061F:\u0637\u0633\u060C\u061B\u0641\u0646\u062F\u0624\u0644\u0648\u0626\u0622\u0643-\u064A\u0630\u0627\u0635\u0634\u062D\u0632\u0621\u0645\u0623\u062C\u0625 \u062A\u0631\u0642\u0639\u062B",ge="P",et=[ge,...ln],be=Object.freeze(Object.fromEntries(et.map((e,t)=>[e,t]))),X=et});function pn(e){return e.replace(/\s+/g," ")}function ye(e){return pn(e).trim()}function tt(e){return ye(Array.from(e).filter(t=>un.has(t)).join(""))}var un,nt=m(()=>{"use strict";P();un=new Set(Je)});var Z,rt=m(()=>{"use strict";P();nt();Z=class{inputSymbolToId=be;inputIdToSymbol=X;inputPadId;startSymbolId;cleanerType;reverse;constructor(t={}){this.cleanerType=t.cleaner??"arabic",this.reverse=t.reverseInput??!1,this.inputPadId=be[ge],this.startSymbolId=t.startSymbol?0:null}clean(t){return this.cleanerType==="arabic"?tt(t):ye(t)}removeDiacritics(t){return Array.from(t).filter(n=>!(!(n in this.inputSymbolToId)&&/[ً-ْ]/.test(n))).join("")}inputToSequence(t){let n=this.reverse?Array.from(t).reverse():Array.from(t),r=[];for(let a of n){let s=this.inputSymbolToId[a];s!==void 0&&r.push(s)}return r}}});function mn(e,t){let n=[],r=0;for(let a=0;a!dn.has(i)),r=Array.from(t),a=mn(n,r),s="",o=0,c=0;for(let{idxDia:i,idxOri:l}of a){if(c{"use strict";P();dn=new Set(["\u0652","\u0651","\u064C","\u064D","\u0650","\u064B","\u064E","\u064F"]),fn=new Set(Ye)});function hn(e,t){let n=e.dims,r=n[n.length-1],a=[],s=e.data;for(let o=0;oi&&(i=d,c=p)}a.push(c)}return a}function gn(e,t,n){let r="";for(let a=0;a{"use strict";rt();st();P();E={maxLen:200,batchSize:1,textEncoder:"ArabicEncoderWithStartSymbol",textCleaner:"valid_arabic_cleaners"},Le=class{kind="rababa";session;encoder;config;constructor(t,n){this.session=t,this.config=n,this.encoder=new Z({cleaner:n.textCleaner==="valid_arabic_cleaners"?"arabic":"basic",startSymbol:n.textEncoder==="ArabicEncoderWithStartSymbol"})}async diacritize(t){let n=t;n.length>this.config.maxLen&&(n=n.slice(0,this.config.maxLen));let r=this.encoder.clean(n),a=this.stripDiacritics(r),s=this.encoder.inputToSequence(a);if(s.length===0)return n;let o=this.config.batchSize,c=this.config.maxLen,i=this.encoder.inputPadId,l=[];for(let j=0;jBigInt(j))),dims:[o,c]},d={name:"lengths",type:"int64",data:new BigInt64Array(Array(o).fill(BigInt(c))),dims:[o]},w=(await this.session.run({src:p,lengths:d}))[this.session.outputNames[0]];if(!w)throw new Error("Rababa model produced no output");let le=hn(w,s.length),$=gn(s,le,this.encoder.inputPadId);return at(r,$)}async transform(t){return this.diacritize(t)}stripDiacritics(t){return Array.from(t).filter(n=>!/[ً-ْ]/.test(n)).join("")}async dispose(){await this.session.dispose()}}});var lt={};O(lt,{rababa:()=>kn,rababaReverse:()=>xn,resetRababaConfigs:()=>Ln,setRababaConfig:()=>yn});function yn(e,t){Se.set(e,t)}function Ln(){Se=new Map(Object.entries(ct))}function wn(e){let t=Se.get(e);if(!t)throw new Error(`No rababa config registered under '${e}'. Register one via setRababaConfig() before invoking rababa.`);return t}function Sn(e){return{maxLen:Number(e.max_len??e.maxLen??200),batchSize:Number(e.batch_size??e.batchSize??32),textEncoder:e.text_encoder??"ArabicEncoderWithStartSymbol",textCleaner:e.text_cleaner??"valid_arabic_cleaners"}}async function vn(e){let t=we.get(e);if(!t){let n=wn(e);t=(async()=>{let r=await An(n.model),a=await T(r),s=Sn(n.config);return ot({session:a,artifacts:{},config:s})})(),we.set(e,t),t.catch(()=>we.delete(e))}return t}async function An(e){if(e.startsWith("file:")||e.startsWith(".")){let{readFile:n}=await import("node:fs/promises"),r=e.startsWith("file:")?e.slice(5):e;return new Uint8Array(await n(r))}let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch ${e}: ${t.status}`);return new Uint8Array(await t.arrayBuffer())}async function kn(e,t={}){let n=t.config??"200";return(await vn(n)).diacritize(e)}function xn(e){return e.replace(/[ًٌٍَُِّْ]/g,"")}var ct,Se,we,pt=m(()=>{"use strict";J();it();ct=Object.freeze({200:Object.freeze({model:"https://github.com/secryst/rababa-models/releases/download/0.1/diacritization_model_arabic.onnx",config:Object.freeze({session_name:"base",text_encoder:"ArabicEncoderWithStartSymbol",text_cleaner:"valid_arabic_cleaners",max_len:200,batch_size:32})})}),Se=new Map(Object.entries(ct));we=new Map});function dt(e){ut=e.replace(/\/$/,"")}function ee(){return ut}var ut,ve=m(()=>{"use strict";ut="https://cdn.jsdelivr.net/gh/interscript/ml-models@main/npm/models"});function mt(e){Ae=e,k=null}function ht(e){ft=e,k=null}function Mn(){return`${ee()}/npm/models/manifest.json`}async function ke(){if(k)return k;if(Ae)return k=Ae,k;let e=ft??Mn(),t=await fetch(e);if(!t.ok)throw new Error(`Failed to load model manifest from ${e}: ${t.status} ${t.statusText}`);let n=await t.json();return k=n,n}async function U(e,t){let n=await ke(),r=t.startsWith(`${e}_`)?t:`${e}_${t}`;return n.models[r]??n.models[t]??null}function F(e,t="q8",n="onnx"){let r=gt(e,t,n),a=e.cdn_base.replace("{version}",e.version),s=e.github_base.replace("{version}",e.version);return{primary:`${a}${r}`,fallback:`${s}${r}`,assetName:r}}function te(e,t="q8",n="onnx"){return[`${gt(e,t,n)}.sha256`,"vocab.json","config.json"]}function gt(e,t,n="onnx"){return`${Tn(e)}${_n[t]}${Cn[n]}`}function Tn(e){let n=e.github_base.match(/([^/]+)-v\{version\}\/$/)?.[1];if(n)return n;throw new Error(`Cannot extract task name from manifest entry. github_base=${e.github_base}`)}var _n,Cn,k,Ae,ft,xe=m(()=>{"use strict";ve();_n={fp32:"",q8:"-q8",q4:"-q4",fp16:"-fp16"},Cn={onnx:".onnx",tflite:".tflite"},k=null,Ae=null,ft=null});async function yt(e,t={}){let n=t.variant??"q8",r=t.format??"onnx",a=t.webgpu??!0,s=e.url??await En(e,n,r),o=await bt(s),c=await Nn(e,n,r),i={};await Promise.all(c.map(async({filename:d,url:v})=>{try{let w=await bt(v);d.endsWith(".json")||d.endsWith(".yaml")||d.endsWith(".yml")||d.endsWith(".sha256")?i[d]=new TextDecoder().decode(w):i[d]=w}catch{}}));let l={webgpu:a};return r==="tflite"&&(l.runtime="litert",t.litertAccelerator!==void 0&&(l.litertAccelerator=t.litertAccelerator),t.inputNames!==void 0&&(l.inputNames=t.inputNames),t.outputNames!==void 0&&(l.outputNames=t.outputNames)),{session:await T(o,l),artifacts:i}}async function En(e,t,n){let r=await U(e.kind,e.id);if(!r)throw new Error(`No manifest entry for kind=${e.kind} id=${e.id}. Pass an explicit \`url\` on the ModelRef or pin a task version in the manifest.`);let{primary:a}=F(r,t,n);return a}async function Nn(e,t,n){if(e.url)return[];let r=await U(e.kind,e.id);if(!r)return[];let{primary:a,assetName:s}=F(r,t,n),o=a.slice(0,a.lastIndexOf("/")+1);return te(r,t,n).map(c=>({filename:c,url:`${o}${c.startsWith(s),c}`}))}async function bt(e){if(e.startsWith("file:")||e.startsWith(".")&&typeof process<"u"&&process.versions?.node){let{readFile:n}=await import("node:fs/promises"),r=e.startsWith("file:")?e.slice(5):e;return new Uint8Array(await n(r))}let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch ${e}: ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())}var Lt=m(()=>{"use strict";J();xe()});function wt(e,t){if(ne.has(e))throw new Error(`Model kind "${e}" is already registered`);ne.set(e,t)}function In(e){return`${e.kind}/${e.id}/${e.url??"_default"}`}async function St(e){let t=In(e),n=q.get(t);if(n)return n;let r=ne.get(e.kind);if(!r)throw new Error(`Unknown model kind: "${e.kind}". Register a factory via registerModel("${e.kind}", factory).`);let a=(async()=>{let{session:s,artifacts:o}=await yt(e);return r({session:s,artifacts:o})})();return q.set(t,a),a.catch(()=>q.delete(t)),a}function vt(){return[...ne.keys()]}async function At(){let e=[...q.values()];q.clear(),await Promise.allSettled(e.map(async t=>{try{await(await t).dispose()}catch{}}))}var ne,q,kt=m(()=>{"use strict";Lt();ne=new Map;q=new Map});var xt={};O(xt,{artifactUrls:()=>F,createSession:()=>T,detectBackend:()=>he,getModelBase:()=>ee,loadManifest:()=>ke,loadModel:()=>St,registerModel:()=>wt,registeredKinds:()=>vt,resetModels:()=>At,resolveManifestEntry:()=>U,setInlineManifest:()=>mt,setManifestUrl:()=>ht,setModelBase:()=>dt,sidecarFilenames:()=>te});var _t=m(()=>{"use strict";kt();J();ve();xe()});import{createYoga as Kn,createSchema as Wn}from"graphql-yoga";import{Hono as Vn}from"hono";import{cors as Qn}from"hono/cors";var pe=` +var Qt=Object.defineProperty;var m=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var j=(e,t)=>{for(var n in t)Qt(e,n,{get:t[n],enumerable:!0})};var Ke={};j(Ke,{createLitertSession:()=>nn});async function tn(){return J||(J=(async()=>{try{return await import("@litertjs/core")}catch(e){throw J=void 0,new Error("@litertjs/core is required for LiteRT inference. Install with: npm install @litertjs/core",{cause:e})}})()),J}async function nn(e,t={}){let n=t.accelerator??"webgpu",r=t.wasmPath??en,a=t.inputNames??["src","lengths"],s=t.outputNames??["output"],o=await tn();await o.loadLiteRt(r,{jspi:n==="webnn"});let c=new Blob([new Uint8Array(e)],{type:"application/octet-stream"}),i=URL.createObjectURL(c),l;return l=await o.loadAndCompile(i,{accelerator:n}),new me(l,o,a,s,i)}function rn(e){return e instanceof Float32Array?"float32":e instanceof Int32Array?"int32":e instanceof BigInt64Array?"int64":e instanceof Uint8Array?"uint8":"float32"}var en,J,me,We=m(()=>{"use strict";en="https://cdn.jsdelivr.net/npm/@litertjs/core@2.5.2/wasm/";me=class{inputNames;outputNames;model;core;blobUrl;disposed=!1;constructor(t,n,r,a,s){this.model=t,this.core=n,this.inputNames=r,this.outputNames=a,this.blobUrl=s}async run(t){if(this.disposed)throw new Error("Session disposed");let n=[];for(let s of this.inputNames){let o=t[s];if(!o)throw new Error(`Missing LiteRT input: ${s}`);n.push(new this.core.Tensor(o.data,o.dims))}let r=await this.model.run(n.length===1?n[0]:n),a={};try{for(let s=0;ssn});async function an(){try{return await import("onnxruntime-node")}catch(e){throw new Error("onnxruntime-node is required for ML inference in Node. Install with: npm install onnxruntime-node",{cause:e})}}async function sn(e){return he.create(e)}var he,Je=m(()=>{"use strict";he=class e{session;ort;inputNames;outputNames;inputMetadata;constructor(t,n){this.session=t,this.ort=n,this.inputNames=t.inputNames,this.outputNames=t.outputNames;let r=t.inputMetadata;Array.isArray(r)&&(this.inputMetadata=r)}static async create(t){let n=await an(),r=await n.InferenceSession.create(t);return new e(r,n)}async run(t){let n={};for(let[s,o]of Object.entries(t))n[s]=new this.ort.Tensor(o.type,o.data,o.dims);let r=await this.session.run(n),a={};for(let[s,o]of Object.entries(r)){let c=o;a[s]={name:s,type:c.type,data:c.data,dims:c.dims}}return a}async dispose(){await this.session.release()}}});var Qe={};j(Qe,{createWebSession:()=>cn});async function on(){return Q||(Q=(async()=>{try{let e=await import("onnxruntime-web");return e.env.wasm.simd=!0,e}catch(e){throw Q=void 0,new Error("onnxruntime-web is required for ML inference in the browser. Install with: npm install onnxruntime-web",{cause:e})}})()),Q}async function cn(e,t={}){return ge.create(e,t)}var Q,ge,Ye=m(()=>{"use strict";ge=class e{session;ort;inputNames;outputNames;constructor(t,n){this.session=t,this.ort=n,this.inputNames=t.inputNames,this.outputNames=t.outputNames}static async create(t,n={}){let r=await on(),a=n.webgpu===!1?["wasm"]:["webgpu","wasm"],s=await r.InferenceSession.create(t,{executionProviders:a});return new e(s,r)}async run(t){let n={};for(let[s,o]of Object.entries(t))n[s]=new this.ort.Tensor(o.type,o.data,o.dims);let r=await this.session.run(n),a={};for(let[s,o]of Object.entries(r)){let c=o;a[s]={name:s,type:c.type,data:c.data,dims:c.dims}}return a}async dispose(){await this.session.release()}}});function be(){let e=globalThis;return e.process?.versions?.node?"node":e.self!==void 0?"web":"unknown"}async function T(e,t={}){if((t.runtime??"onnx")==="litert"){let s={};return t.litertAccelerator!==void 0&&(s.accelerator=t.litertAccelerator),t.inputNames!==void 0&&(s.inputNames=t.inputNames),t.outputNames!==void 0&&(s.outputNames=t.outputNames),(await Promise.resolve().then(()=>(We(),Ke))).createLitertSession(e,s)}if((t.backend??be()==="node"?"node":"web")==="node")return(await Promise.resolve().then(()=>(Je(),Ve))).createNodeSession(e);let a=t.webgpu===void 0?{}:{webgpu:t.webgpu};return(await Promise.resolve().then(()=>(Ye(),Qe))).createWebSession(e,a)}var Y=m(()=>{"use strict"});var ln,pn,Xe,Ze,gr,et,br,un,tt,dn,ye,nt,Le,X,P=m(()=>{"use strict";ln=["\u0652","\u0651","\u064C","\u064D","\u0650","\u064B","\u064E","\u064F"],pn="\u0649\u0639\u0638\u062D\u0631\u0633\u064A\u0634\u0636\u0642 \u062B\u0644\u0635\u0637\u0643\u0622\u0645\u0627\u0625\u0647\u0632\u0621\u0623\u0641\u0624\u063A\u062C\u0626\u062F\u0629\u062E\u0648\u0628\u0630\u062A\u0646",Xe="\u0649\u0639\u0638\u062D\u0631\u0633\u064A\u0634\u0636\u0642\u062B\u0644\u0635\u0637\u0643\u0622\u0645\u0627\u0625\u0647\u0632\u0621\u0623\u0641\u0624\u063A\u062C\u0626\u062F\u0629\u062E\u0648\u0628\u0630\u062A\u0646",Ze=[...ln,...pn],gr=Object.freeze({"\u064E":"Fatha","\u064B":"Fathatah","\u064F":"Damma","\u064C":"Dammatan","\u0650":"Kasra","\u064D":"Kasratan","\u0652":"Sukun","\u0651":"Shaddah"}),et=Object.freeze({"":"No Diacritic","\u064E":"Fatha","\u064B":"Fathatah","\u064F":"Damma","\u064C":"Dammatan","\u0650":"Kasra","\u064D":"Kasratan","\u0652":"Sukun","\u0651":"Shaddah","\u0651\u064E":"Shaddah + Fatha","\u0651\u064B":"Shaddah + Fathatah","\u0651\u064F":"Shaddah + Damma","\u0651\u064C":"Shaddah + Dammatan","\u0651\u0650":"Shaddah + Kasra","\u0651\u064D":"Shaddah + Kasratan"}),br=Object.freeze(Object.fromEntries(Object.keys(et).map((e,t)=>[e,t]))),un="P",tt=[un,...Object.keys(et),""],dn="\u0628\u0636.\u063A\u0649\u0647\u0638\u062E\u0629\u061F:\u0637\u0633\u060C\u061B\u0641\u0646\u062F\u0624\u0644\u0648\u0626\u0622\u0643-\u064A\u0630\u0627\u0635\u0634\u062D\u0632\u0621\u0645\u0623\u062C\u0625 \u062A\u0631\u0642\u0639\u062B",ye="P",nt=[ye,...dn],Le=Object.freeze(Object.fromEntries(nt.map((e,t)=>[e,t]))),X=nt});function fn(e){return e.replace(/\s+/g," ")}function we(e){return fn(e).trim()}function rt(e){return we(Array.from(e).filter(t=>mn.has(t)).join(""))}var mn,at=m(()=>{"use strict";P();mn=new Set(Ze)});var Z,st=m(()=>{"use strict";P();at();Z=class{inputSymbolToId=Le;inputIdToSymbol=X;inputPadId;startSymbolId;cleanerType;reverse;constructor(t={}){this.cleanerType=t.cleaner??"arabic",this.reverse=t.reverseInput??!1,this.inputPadId=Le[ye],this.startSymbolId=t.startSymbol?0:null}clean(t){return this.cleanerType==="arabic"?rt(t):we(t)}removeDiacritics(t){return Array.from(t).filter(n=>!(!(n in this.inputSymbolToId)&&/[ً-ْ]/.test(n))).join("")}inputToSequence(t){let n=this.reverse?Array.from(t).reverse():Array.from(t),r=[];for(let a of n){let s=this.inputSymbolToId[a];s!==void 0&&r.push(s)}return r}}});function bn(e,t){let n=[],r=0;for(let a=0;a!hn.has(i)),r=Array.from(t),a=bn(n,r),s="",o=0,c=0;for(let{idxDia:i,idxOri:l}of a){if(c{"use strict";P();hn=new Set(["\u0652","\u0651","\u064C","\u064D","\u0650","\u064B","\u064E","\u064F"]),gn=new Set(Xe)});function yn(e,t){let n=e.dims,r=n[n.length-1],a=[],s=e.data;for(let o=0;oi&&(i=d,c=p)}a.push(c)}return a}function Ln(e,t,n){let r="";for(let a=0;a{"use strict";st();it();P();E={maxLen:200,batchSize:1,textEncoder:"ArabicEncoderWithStartSymbol",textCleaner:"valid_arabic_cleaners"},Se=class{kind="rababa";session;encoder;config;constructor(t,n){this.session=t,this.config=n,this.encoder=new Z({cleaner:n.textCleaner==="valid_arabic_cleaners"?"arabic":"basic",startSymbol:n.textEncoder==="ArabicEncoderWithStartSymbol"})}async diacritize(t){let n=t;n.length>this.config.maxLen&&(n=n.slice(0,this.config.maxLen));let r=this.encoder.clean(n),a=this.stripDiacritics(r),s=this.encoder.inputToSequence(a);if(s.length===0)return n;let o=this.config.batchSize,c=this.config.maxLen,i=this.encoder.inputPadId,l=[];for(let $=0;$BigInt($))),dims:[o,c]},d={name:"lengths",type:"int64",data:new BigInt64Array(Array(o).fill(BigInt(c))),dims:[o]},w=(await this.session.run({src:p,lengths:d}))[this.session.outputNames[0]];if(!w)throw new Error("Rababa model produced no output");let ue=yn(w,s.length),O=Ln(s,ue,this.encoder.inputPadId);return ot(r,O)}async transform(t){return this.diacritize(t)}stripDiacritics(t){return Array.from(t).filter(n=>!/[ً-ْ]/.test(n)).join("")}async dispose(){await this.session.dispose()}}});var ut={};j(ut,{rababa:()=>Mn,rababaReverse:()=>Cn,resetRababaConfigs:()=>vn,setRababaConfig:()=>Sn});function Sn(e,t){Ae.set(e,t)}function vn(){Ae=new Map(Object.entries(pt))}function An(e){let t=Ae.get(e);if(!t)throw new Error(`No rababa config registered under '${e}'. Register one via setRababaConfig() before invoking rababa.`);return t}function kn(e){return{maxLen:Number(e.max_len??e.maxLen??200),batchSize:Number(e.batch_size??e.batchSize??32),textEncoder:e.text_encoder??"ArabicEncoderWithStartSymbol",textCleaner:e.text_cleaner??"valid_arabic_cleaners"}}async function xn(e){let t=ve.get(e);if(!t){let n=An(e);t=(async()=>{let r=await _n(n.model),a=await T(r),s=kn(n.config);return ct({session:a,artifacts:{},config:s})})(),ve.set(e,t),t.catch(()=>ve.delete(e))}return t}async function _n(e){if(e.startsWith("file:")||e.startsWith(".")){let{readFile:n}=await import("node:fs/promises"),r=e.startsWith("file:")?e.slice(5):e;return new Uint8Array(await n(r))}let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch ${e}: ${t.status}`);return new Uint8Array(await t.arrayBuffer())}async function Mn(e,t={}){let n=t.config??"200";return(await xn(n)).diacritize(e)}function Cn(e){return e.replace(/[ًٌٍَُِّْ]/g,"")}var pt,Ae,ve,dt=m(()=>{"use strict";Y();lt();pt=Object.freeze({200:Object.freeze({model:"https://github.com/secryst/rababa-models/releases/download/0.1/diacritization_model_arabic.onnx",config:Object.freeze({session_name:"base",text_encoder:"ArabicEncoderWithStartSymbol",text_cleaner:"valid_arabic_cleaners",max_len:200,batch_size:32})})}),Ae=new Map(Object.entries(pt));ve=new Map});function mt(e){ft=e.replace(/\/$/,"")}function ee(){return ft}var ft,ke=m(()=>{"use strict";ft="https://cdn.jsdelivr.net/gh/interscript/ml-models@main/npm/models"});function gt(e){xe=e,k=null}function bt(e){ht=e,k=null}function Nn(){return`${ee()}/npm/models/manifest.json`}async function _e(){if(k)return k;if(xe)return k=xe,k;let e=ht??Nn(),t=await fetch(e);if(!t.ok)throw new Error(`Failed to load model manifest from ${e}: ${t.status} ${t.statusText}`);let n=await t.json();return k=n,n}async function U(e,t){let n=await _e(),r=t.startsWith(`${e}_`)?t:`${e}_${t}`;return n.models[r]??n.models[t]??null}function q(e,t="q8",n="onnx"){let r=yt(e,t,n),a=e.cdn_base.replace("{version}",e.version),s=e.github_base.replace("{version}",e.version);return{primary:`${a}${r}`,fallback:`${s}${r}`,assetName:r}}function te(e,t="q8",n="onnx"){return[`${yt(e,t,n)}.sha256`,"vocab.json","config.json"]}function yt(e,t,n="onnx"){return`${In(e)}${Tn[t]}${En[n]}`}function In(e){let n=e.github_base.match(/([^/]+)-v\{version\}\/$/)?.[1];if(n)return n;throw new Error(`Cannot extract task name from manifest entry. github_base=${e.github_base}`)}var Tn,En,k,xe,ht,Me=m(()=>{"use strict";ke();Tn={fp32:"",q8:"-q8",q4:"-q4",fp16:"-fp16"},En={onnx:".onnx",tflite:".tflite"},k=null,xe=null,ht=null});async function wt(e,t={}){let n=t.variant??"q8",r=t.format??"onnx",a=t.webgpu??!0,s=e.url??await Rn(e,n,r),o=await Lt(s),c=await On(e,n,r),i={};await Promise.all(c.map(async({filename:d,url:v})=>{try{let w=await Lt(v);d.endsWith(".json")||d.endsWith(".yaml")||d.endsWith(".yml")||d.endsWith(".sha256")?i[d]=new TextDecoder().decode(w):i[d]=w}catch{}}));let l={webgpu:a};return r==="tflite"&&(l.runtime="litert",t.litertAccelerator!==void 0&&(l.litertAccelerator=t.litertAccelerator),t.inputNames!==void 0&&(l.inputNames=t.inputNames),t.outputNames!==void 0&&(l.outputNames=t.outputNames)),{session:await T(o,l),artifacts:i}}async function Rn(e,t,n){let r=await U(e.kind,e.id);if(!r)throw new Error(`No manifest entry for kind=${e.kind} id=${e.id}. Pass an explicit \`url\` on the ModelRef or pin a task version in the manifest.`);let{primary:a}=q(r,t,n);return a}async function On(e,t,n){if(e.url)return[];let r=await U(e.kind,e.id);if(!r)return[];let{primary:a,assetName:s}=q(r,t,n),o=a.slice(0,a.lastIndexOf("/")+1);return te(r,t,n).map(c=>({filename:c,url:`${o}${c.startsWith(s),c}`}))}async function Lt(e){if(e.startsWith("file:")||e.startsWith(".")&&typeof process<"u"&&process.versions?.node){let{readFile:n}=await import("node:fs/promises"),r=e.startsWith("file:")?e.slice(5):e;return new Uint8Array(await n(r))}let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch ${e}: ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())}var St=m(()=>{"use strict";Y();Me()});function vt(e,t){if(ne.has(e))throw new Error(`Model kind "${e}" is already registered`);ne.set(e,t)}function $n(e){return`${e.kind}/${e.id}/${e.url??"_default"}`}async function At(e){let t=$n(e),n=F.get(t);if(n)return n;let r=ne.get(e.kind);if(!r)throw new Error(`Unknown model kind: "${e.kind}". Register a factory via registerModel("${e.kind}", factory).`);let a=(async()=>{let{session:s,artifacts:o}=await wt(e);return r({session:s,artifacts:o})})();return F.set(t,a),a.catch(()=>F.delete(t)),a}function kt(){return[...ne.keys()]}async function xt(){let e=[...F.values()];F.clear(),await Promise.allSettled(e.map(async t=>{try{await(await t).dispose()}catch{}}))}var ne,F,_t=m(()=>{"use strict";St();ne=new Map;F=new Map});var Mt={};j(Mt,{artifactUrls:()=>q,createSession:()=>T,detectBackend:()=>be,getModelBase:()=>ee,loadManifest:()=>_e,loadModel:()=>At,registerModel:()=>vt,registeredKinds:()=>kt,resetModels:()=>xt,resolveManifestEntry:()=>U,setInlineManifest:()=>gt,setManifestUrl:()=>bt,setModelBase:()=>mt,sidecarFilenames:()=>te});var Ct=m(()=>{"use strict";_t();Y();ke();Me()});import{createYoga as Qn,createSchema as Yn}from"graphql-yoga";import{Hono as Xn}from"hono";import{cors as Zn}from"hono/cors";var de=` type DetectionResult { mapName: String distance: Float @@ -10,4 +10,4 @@ var Wt=Object.defineProperty;var m=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&( transliterate(systemCode: String!, input: String!): String detect(input: String!, output: String!): [DetectionResult] } -`;import{Hono as Gn}from"hono";var g=class extends Error{cause;constructor(t,n){super(t,n),this.name=new.target.name,this.cause=n?.cause}},h=class extends g{systemCode;constructor(t){super(`Map not found: ${t}`),this.systemCode=t}},_=class extends g{},L=class extends g{},C=class extends g{dependency;constructor(t){super(`Map dependency missing: ${t}`),this.dependency=t}};var W=class{strategies;cache=new Map;known=new Map;options;constructor(t,n={}){this.strategies=t,this.options=n}load(t){let n=this.cache.get(t);if(n)return n;let r=this.known.get(t);if(r)return this.cache.set(t,r),r;for(let a of this.strategies){let s=a(t);if(s&&typeof s.then!="function"){let o=s;return this.cache.set(t,o),this.known.set(t,o),this.options.onLoaded?.(t,o),o}}throw new h(t)}async loadAsync(t){let n=this.cache.get(t);if(n)return n;let r=this.known.get(t);if(r)return this.cache.set(t,r),r;for(let a of this.strategies){let s=await a(t);if(s)return this.cache.set(t,s),this.known.set(t,s),this.options.onLoaded?.(t,s),s}throw new h(t)}clear(){this.cache.clear()}loadedMaps(){return Array.from(this.known.keys())}register(t,n){this.known.set(t,n),this.cache.set(t,n)}};var z=class e{current;map;loader;aliasCache=new Map;functions;constructor(t,n,r){this.map=t,this.current=n,this.functions=t.functions,this.loader=r}resolveAlias(t){if(this.aliasCache.has(t))return this.aliasCache.get(t);let n=this.map.aliases.get(t);if(!n&&this.loader)for(let r of this.map.dependencies)try{let s=this.loader.load(r).aliases.get(t);if(s){n=s;break}}catch{}return n&&this.aliasCache.set(t,n),n}withMap(t){return new e(t,this.current,this.loader)}loadDependency(t){if(!this.loader)throw new Error(`Cannot resolve dependency ${t}: no loader configured`);return this.loader.load(t)}};function ue(){return{children:new Map,match:null}}function Ie(e){let t=ue();for(let[n,r]of e){if(n.length===0)continue;let a=t;for(let c=0;c0?(n+=c,a+=o):(n+=e[a],a+=1)}return n}function D(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $e(e){return e.toLowerCase()}function je(e){return e.toUpperCase()}function Oe(e,t={}){let n=t.wordSeparator??" ";return n===""?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e.split(n).map(r=>r.length===0?r:r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(n)}function ze(e,t={}){let n=t.separator??" ";return e.split("").join(n)}function De(e){return e.normalize("NFC")}function Be(e){return e.normalize("NFD")}function Pe(e,t){if(t.length===0)return e;let n=t.map((a,s)=>`(?<__r${s}>${a.pattern})`),r=new RegExp(n.join("|"),"gmu");return e.replace(r,(...a)=>{let s=a[a.length-1];for(let o=0;ou(a,t).re),r=e.of.length>0?u(e.of[0],t).literal:"";return{re:`(?:${n.join("|")})`,literal:r}}case"any_char_class":{if(e.range){let[n,r]=e.range;return{re:`[${D(n)}-${D(r)}]`,literal:n??""}}return e.chars&&e.chars.length>0?{re:`[${e.chars.map(r=>D(r)).join("")}]`,literal:e.chars[0]}:{re:"[^]",literal:""}}case"group":{let n=e.items.map(s=>u(s,t)),r=n.map(s=>s.re).join(""),a=n.map(s=>s.literal).join("");return{re:`(?:${r})`,literal:a}}case"repeat":{let n=u(e.item,t).re,{min:r,max:a}=e,s=a===null?1/0:a,o=s===1/0?r===0?"*":"+":`{${r},${s}}`;return{re:`(?:${n})${o}`,literal:""}}case"stage_ref":return{re:"",literal:""}}}function B(e,t){switch(e.kind){case"string":return e.value;case"alias":{let n=V[e.name];if(n)return n.literal===""?null:n.literal;let r=t.resolveAlias(e.name);return r?B(r,t):null}case"capture_group":case"capture_ref":case"repeat":case"stage_ref":return null;case"any_char_class":return e.chars&&e.chars.length>0?e.chars[0]:e.range?e.range[0]:null;case"any":return e.of.length===0?null:B(e.of[0],t);case"group":{let n="";for(let r of e.items){let a=B(r,t);if(a===null)return null;n+=a}return n}}}function M(e,t){switch(e.kind){case"string":return[e.value];case"alias":{if(V[e.name])return null;let r=t.resolveAlias(e.name);return r?M(r,t):null}case"any_char_class":{if(e.chars)return[...e.chars];if(e.range){let[n,r]=e.range,a=n.codePointAt(0),s=r.codePointAt(0),o=[];for(let c=a;c<=s;c++)o.push(String.fromCodePoint(c));return o}return null}case"any":{let n=[];for(let r of e.of){let a=M(r,t);if(a===null)return null;n.push(...a)}return n}case"group":{let n=[""];for(let r of e.items){let a=M(r,t);if(a===null)return null;let s=[];for(let o of n)for(let c of a)s.push(o+c);n=s}return n}default:return null}}function y(e,t){switch(e.kind){case"string":return e.value.length;case"capture_group":return y(e.data,t);case"capture_ref":return 1;case"alias":{if(e.name==="none")return 0;if(V[e.name])return 1;let n=t.resolveAlias(e.name);return n?y(n,t):1}case"any":return e.of.reduce((n,r)=>Math.max(n,y(r,t)),0);case"any_char_class":return 1;case"group":return e.items.reduce((n,r)=>n+y(r,t),0);case"repeat":return y(e.item,t);case"stage_ref":return 1}}var V=Object.freeze({any_character:{re:".",literal:""},none:{re:"",literal:""},space:{re:" ",literal:" "},whitespace:{re:"\\s+",literal:" "},boundary:{re:"(?:(?Oe(e,t??{}),separate:(e,t)=>ze(e,t??{}),compose:De,decompose:Be};function Ue(e,t){let n=e.functions.get(t)?.impl;if(n)return n;let r=Vt[t];if(r)return r}var Qt={sub:(e,t)=>Yt(e,t),run:(e,t)=>{let n=e.docName?t.loadDependency(e.docName):t.map,r=n.stages.find(s=>s.name===e.stage);if(!r)throw new L(`Stage not found: ${e.stage}`);let a=t.withMap(n);for(let s of r.rules)A(s,a);t.current=a.current},funcall:(e,t)=>{let n=Ue(t,e.name);if(!n)throw new L(`Unknown function: ${e.name}`);t.current=n(t.current,e.kwargs??{})},parallel:(e,t)=>{let n=[],r=[];for(let o of e.rules)o.kind==="sub"&&o.from?n.push(o):r.push(o);let a=o=>!o.before&&!o.after&&!o.notBefore&&!o.notAfter&&M(o.from,t)!==null;if(n.some(o=>!a(o))){let c=n.map((i,l)=>({rule:i,idx:l,len:y(i.from,t)+(i.before?y(i.before,t):0)+(i.after?y(i.after,t):0)+(i.notBefore?y(i.notBefore,t):0)+(i.notAfter?y(i.notAfter,t):0)+(i.priority??0)})).sort((i,l)=>l.len-i.len||i.idx-l.idx).map(({rule:i})=>{let l=u(i.from,t),p=i.before?u(i.before,t).re:"",d=i.after?u(i.after,t).re:"",v=i.notBefore?u(i.notBefore,t).re:"",w=i.notAfter?u(i.notAfter,t).re:"",le=[p?`(?<=${p})`:"",v?`(?Fe($,x,Kt):$}});t.current=Pe(t.current,c)}else{let o=[];for(let c of n){if(c.to&&c.to.kind==="funcall_inline")continue;let i=c.to?B(c.to,t):"";if(i===null)continue;let l=M(c.from,t);if(l!==null)for(let p of l)o.push([p,i])}o.length>0&&(t.current=Re(t.current,Ie(o)))}for(let o of r)A(o,t)},sequential:(e,t)=>{for(let n of e.rules)A(n,t)}};function Yt(e,t){if(!e.from)throw new L("Sub rule missing 'from'");let n=u(e.from,t),r=e.before?u(e.before,t).re:"",a=e.after?u(e.after,t).re:"",s=e.notBefore?u(e.notBefore,t).re:"",o=e.notAfter?u(e.notAfter,t).re:"",c=[];r&&c.push(`(?<=${r})`),s&&c.push(`(?{let p=l;return(d,...v)=>Fe(p,d,v)})():l)}function Fe(e,t,n){return e.replace(/\$(\d+)/g,(r,a)=>{let s=parseInt(a,10);return n[s-1]??t})}function qe(e,t){if(!e)return"";if(e.kind==="funcall_inline"){let r=Ue(t,e.name);if(!r)throw new L(`Unknown inline function: ${e.name}`);return a=>r(a)}return u(e,t).literal}function A(e,t){let n=Qt[e.kind];n(e,t)}var _e=new Set(["rababa","secryst"]);function Ct(e){for(let t of e){if(t.kind==="funcall"&&_e.has(t.name))return!0;if(t.kind==="parallel"||t.kind==="sequential"){for(let n of t.rules)if(n.kind==="funcall"&&_e.has(n.name))return!0}}return!1}function G(e,t,n,r){let a=e.stages.find(o=>o.name===t);if(!a)return n;if(Ct(a.rules))throw new Error(`Stage "${t}" contains ML function calls (rababa/secryst). Use transliterateAsync() instead of transliterate().`);let s=new z(e,n,r);for(let o of a.rules)A(o,s);return s.current}async function Mt(e,t,n,r){let a=e.stages.find(o=>o.name===t);if(!a)return n;if(!Ct(a.rules))return G(e,t,n,r);let s=new z(e,n,r);for(let o of a.rules)await Rn(o,s);return s.current}async function Rn(e,t){if(e.kind==="funcall"){await $n(e,t);return}A(e,t)}async function $n(e,t){if(e.name==="rababa"){let{rababa:n}=await Promise.resolve().then(()=>(pt(),lt));t.current=await n(t.current,e.kwargs);return}if(_e.has(e.name)){let{loadModel:n}=await Promise.resolve().then(()=>(_t(),xt)),r=e.kwargs?.config??e.kwargs?.model??"default",a=await n({kind:e.name,id:r});t.current=await a.transform(t.current);return}A({kind:"funcall",name:e.name,kwargs:e.kwargs},t)}function jn(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=new Array(t.length+1),r=new Array(t.length+1);for(let a=0;a<=t.length;a++)n[a]=a;for(let a=1;a<=e.length;a++){r[0]=a;for(let s=1;s<=t.length;s++){let o=e[a-1]===t[s-1]?0:1;r[s]=Math.min(n[s]+1,r[s-1]+1,n[s-1]+o)}[n,r]=[r,n]}return n[t.length]}function On(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${t}$`)}function Tt(e,t,n,r={},a){let s=[],o=r.mapPattern?On(r.mapPattern):null,c=a??n.loadedMaps();for(let i of c){if(o&&!o.test(i))continue;let l;try{let p=n.load(i);l=G(p,"main",e,n)}catch(p){if(p instanceof g)continue;throw p}s.push({mapName:i,distance:jn(l,t)})}return s.sort((i,l)=>i.distance-l.distance)}function Ce(e){let t={schemaVersion:e.schemaVersion,systemCode:e.systemCode,dependencies:e.dependencies,stages:e.stages,aliases:new Map(Object.entries(e.aliases)),functions:new Map};return e.metadata&&(t.metadata=e.metadata),t}var zn="main",ae=class{loader;defaultStage;constructor(t={}){this.loader=new W(t.strategies??[]),this.defaultStage=t.defaultStage??zn}loadMap(t){let n=this.loader.load(t);for(let r of n.dependencies)try{this.loader.load(r)}catch(a){throw a instanceof h?new C(r):a}return n}async loadMapAsync(t){let n=await this.loader.loadAsync(t),r=new Set,a=[...n.dependencies];for(;a.length>0;){let s=a.shift();if(!r.has(s)){r.add(s);try{let o=await this.loader.loadAsync(s);for(let c of o.dependencies)r.has(c)||a.push(c)}catch(o){throw o instanceof h?new C(s):o}}}return n}transliterate(t,n,r){try{let a=this.loadMap(t),s=r??this.defaultStage;return G(a,s,n,this.loader)}catch(a){throw a instanceof g?a:new _(`Transliteration failed for ${t}: ${a.message}`,{cause:a})}}async transliterateAsync(t,n,r){try{let a=await this.loadMapAsync(t),s=r??this.defaultStage;return await Mt(a,s,n,this.loader)}catch(a){throw a instanceof g?a:new _(`Transliteration failed for ${t}: ${a.message}`,{cause:a})}}loadedMaps(){return this.loader.loadedMaps()}getLoader(){return this.loader}detect(t,n,r={},a){return Tt(t,n,this.loader,r,a)}},re;function Et(e){re=new ae(e)}function Dn(){return re||(re=new ae),re}function Me(e,t,n){return Dn().transliterateAsync(e,t,n)}var Nt=["acadsin-zho-Hani-Latn-2002","alalc-amh-Ethi-Latn-1997","alalc-amh-Ethi-Latn-2011","alalc-ara-Arab-Latn-1997","alalc-asm-Deva-Latn-1997","alalc-asm-Deva-Latn-2012","alalc-aze-Arab-Latn-1997","alalc-aze-Cyrl-Latn-1997","alalc-bel-Cyrl-Latn-1997","alalc-ben-Beng-Latn-1997","alalc-ben-Beng-Latn-2017","alalc-bul-Cyrl-Latn-1997","alalc-div-Thaa-Latn-1997","alalc-div-Thaa-Latn-2012","alalc-ell-Grek-Latn-1997","alalc-ell-Grek-Latn-2010","alalc-fas-Arab-Latn-1997","alalc-guj-Gujr-Latn-1997","alalc-guj-Gujr-Latn-2011","alalc-hin-Deva-Latn-1997","alalc-hin-Deva-Latn-2011","alalc-kan-Kana-Latn-1997","alalc-kan-Kana-Latn-2011","alalc-kat-Geok-Latn-1997","alalc-kat-Geok-Latn-2011","alalc-kat-Geor-Latn-1997","alalc-kat-Geor-Latn-2011","alalc-kor-Hang-Latn-1997","alalc-mal-Mlym-Latn-1997","alalc-mal-Mlym-Latn-2012","alalc-mar-Deva-Latn-1997","alalc-mar-Deva-Latn-2011","alalc-mkd-Cyrl-Latn-1997","alalc-mkd-Cyrl-Latn-2013","alalc-mon-Cyrl-Latn-1997","alalc-ori-Orya-Latn-1997","alalc-ori-Orya-Latn-2011","alalc-pan-Guru-Latn-1997","alalc-pan-Guru-Latn-2011","alalc-pli-Deva-Latn-2012","alalc-pra-Deva-Latn-2012","alalc-rus-Cyrl-Latn-1997","alalc-rus-Cyrl-Latn-2012","alalc-san-Deva-Latn-2012","alalc-sin-Sinh-Latn-1997","alalc-sin-Sinh-Latn-2011","alalc-srp-Cyrl-Latn-1997","alalc-srp-Cyrl-Latn-2013","alalc-tam-Taml-Latn-1997","alalc-tam-Taml-Latn-2011","alalc-tel-Telu-Latn-1997","alalc-tel-Telu-Latn-2011","alalc-tir-Ethi-Latn-1997","alalc-tir-Ethi-Latn-2011","alalc-ukr-Cyrl-Latn-1997","alalc-ukr-Cyrl-Latn-2011","apcbg-bul-Cyrl-Latn-1995","az-aze-Cyrl-Latn-1939","az-aze-Cyrl-Latn-1958","bas-rus-Cyrl-Latn-2017-bss","bas-rus-Cyrl-Latn-2017-oss","bgn-jpn-Hrkt-Latn-1962","bgn-kor-Hang-Latn-1943","bgn-kor-Kore-Latn-1943","bgna-bul-Cyrl-Latn-2006","bgna-bul-Cyrl-Latn-2009","bgnpcgn-amh-Ethi-Latn-1967","bgnpcgn-ara-Arab-Latn-1956","bgnpcgn-arm-Armn-Latn-1981","bgnpcgn-aze-Cyrl-Latn-1993","bgnpcgn-bak-Cyrl-Latn-2007","bgnpcgn-bal-Arab-Latn-2008","bgnpcgn-bel-Cyrl-Latn-1979","bgnpcgn-bul-Cyrl-Latn-1952","bgnpcgn-bul-Cyrl-Latn-2013","bgnpcgn-che-Cyrl-Latn-2008","bgnpcgn-deu-Latn-Latn-2000","bgnpcgn-div-Thaa-Latn-1972","bgnpcgn-div-Thaa-Latn-1988","bgnpcgn-ell-Grek-Latn-1962","bgnpcgn-ell-Grek-Latn-1996","bgnpcgn-fao-Latn-Latn-1964","bgnpcgn-fao-Latn-Latn-1968","bgnpcgn-fas-Arab-Latn-1956","bgnpcgn-isl-Latn-Latn-1964","bgnpcgn-isl-Latn-Latn-1968","bgnpcgn-jpn-Hrkt-Latn-1976","bgnpcgn-kat-Geor-Latn-1981","bgnpcgn-kat-Geor-Latn-2009","bgnpcgn-kaz-Cyrl-Latn-1979","bgnpcgn-kir-Cyrl-Latn-1979","bgnpcgn-kor-Hang-Latn-kn-1945","bgnpcgn-kor-Hang-Latn-rok-2011","bgnpcgn-kor-Kore-Latn-rok-2011","bgnpcgn-kur-Arab-Latn-2007","bgnpcgn-mkd-Cyrl-Latn-1981","bgnpcgn-mkd-Cyrl-Latn-2013","bgnpcgn-mon-Cyrl-Latn-1964","bgnpcgn-nep-Deva-Latn-2011","bgnpcgn-per-Arab-Latn-1958","bgnpcgn-prs-Arab-Latn-2007","bgnpcgn-prs-Arab-Latn-yaghoubi","bgnpcgn-pus-Arab-Latn-1968","bgnpcgn-ron-Cyrl-Latn-2002","bgnpcgn-rue-Cyrl-Latn-2016","bgnpcgn-rus-Cyrl-Latn-1947","bgnpcgn-sme-Latn-Latn-1984","bgnpcgn-srp-Cyrl-Latn-1962","bgnpcgn-srp-Cyrl-Latn-2005","bgnpcgn-tat-Cyrl-Latn-2007","bgnpcgn-tgk-Cyrl-Latn-1994","bgnpcgn-tir-Ethi-Latn-2007","bgnpcgn-ukr-Cyrl-Latn-1965","bgnpcgn-ukr-Cyrl-Latn-2019","bgnpcgn-urd-Arab-Latn-2007","bgnpcgn-uzb-Cyrl-Latn-1979","bgnpcgn-uzb-Cyrl-Latn-2000","bgnpcgn-zho-Hans-Latn-1979","bis-asm-Beng-Latn-13194-1991","bis-ben-Beng-Latn-13194-1991","bis-dev-Deva-Latn-13194-1991","bis-guj-Gujr-Latn-13194-1991","bis-kan-Kana-Latn-13194-1991","bis-mlm-Mlym-Latn-13194-1991","bis-ori-Orya-Latn-13194-1991","bis-pnj-Guru-Latn-13194-1991","bis-tel-Telu-Latn-13194-1991","bis-tml-Taml-Latn-13194-1991","by-bel-Cyrl-Latn-1998","by-bel-Cyrl-Latn-2007","din-grc-Grek-Latn-31634-2011-t1","din-hin-Deva-Latn-33904-2018","din-kat-Geor-Latn-32707-2010","din-mar-Deva-Latn-33904-2018","din-nep-Deva-Latn-33904-2018","din-pli-Deva-Latn-33904-2018","din-pra-Deva-Latn-33904-2018","din-san-Deva-Latn-33904-2018","din-tam-Taml-Latn-33903-2016","dos-nep-Deva-Latn-1997","elot-ell-Grek-Latn-743-1982-tl","elot-ell-Grek-Latn-743-1982-ts","elot-ell-Grek-Latn-743-2001-tl","elot-ell-Grek-Latn-743-2001-ts","ggg-kat-Geor-Latn-2002","gki-bel-Cyrl-Latn-1992","gki-bel-Cyrl-Latn-2000","gost-rus-Cyrl-Latn-16876-71-1983","gost-rus-Cyrl-Latn-7.79-2000-2002","hk-yue-Hani-Latn-1888","icao-bel-Cyrl-Latn-9303","icao-bul-Cyrl-Latn-9303","icao-fas-Arab-Latn-9303","icao-heb-Hebr-Latn-9303","icao-mkd-Cyrl-Latn-9303","icao-rus-Cyrl-Latn-9303","icao-srp-Cyrl-Latn-9303","icao-ukr-Cyrl-Latn-9303","iso-ara-Arab-Latn-233-1984","iso-ara-Arab-Latn-233-2-1993","iso-asm-Beng-Latn-15919-2001","iso-ben-Beng-Latn-15919-2001","iso-ell-Grek-Latn-843-1997-t1","iso-ell-Grek-Latn-843-1997-t2","iso-guj-Gujr-Latn-15919-2001","iso-hin-Deva-Latn-15919-2001","iso-inc-Deva-Latn-15919-2001","iso-jpn-Hrkt-Latn-3602-1989","iso-kan-Kana-Latn-15919-2001","iso-kat-Geor-Latn-9984-1996","iso-kor-Hang-Latn-1996-method1","iso-kor-Hang-Latn-1996-method2","iso-mal-Mlym-Latn-15919-2001","iso-mar-Deva-Latn-15919-2001","iso-nep-Deva-Latn-15919-2001","iso-ori-Orya-Latn-15919-2001","iso-pan-Guru-Latn-15919-2001","iso-pli-Beng-Latn-15919-2001","iso-pli-Deva-Latn-15919-2001","iso-pli-Sinh-Latn-15919-2001","iso-pli-Thai-Latn-15919-2001","iso-pra-Deva-Latn-15919-2001","iso-prs-Arab-Latn-233-3-1999","iso-rus-Cyrl-Latn-9-1995","iso-san-Deva-Latn-15919-2001","iso-tam-Taml-Latn-15919-2001","iso-tel-Telu-Latn-15919-2001","iso-tha-Thai-Latn-11940-1998","kp-kor-Hang-Latn-2002","lshk-yue-Hani-Latn-jyutping-1993","masm-mon-Cyrl-Latn-5217-2012","masm-mon-Latn-Cyrl-5217-2012","mext-jpn-Hrkt-Latn-1954","moct-kor-Hang-Latn-2000","mofa-jpn-Hrkt-Latn-1989","mv-div-Thaa-Latn-1987","mvd-bel-Cyrl-Latn-2008","mvd-bel-Cyrl-Latn-2010","mvd-rus-Cyrl-Latn-2008","mvd-rus-Cyrl-Latn-2010","odni-ara-Arab-Latn-2004","odni-ara-Arab-Latn-2015","odni-aze-Cyrl-Latn-2015","odni-bel-Cyrl-Latn-2015","odni-bul-Cyrl-Latn-2005","odni-bul-Cyrl-Latn-2015","odni-che-Cyrl-Latn-2015","odni-fas-Arab-Latn-2004","odni-fas-Arab-Latn-2015","odni-hin-Deva-Latn-2004","odni-hin-Deva-Latn-2015","odni-kat-Geor-Latn-2015","odni-kaz-Cyrl-Latn-2015","odni-kir-Cyrl-Latn-2015","odni-kor-Hang-Latn-2015","odni-mkd-Cyrl-Latn-2005","odni-mkd-Cyrl-Latn-2015","odni-prs-Arab-Latn-2004","odni-prs-Arab-Latn-2015","odni-pus-Arab-Latn-2011","odni-rus-Cyrl-Latn-2015","odni-srp-Cyrl-Latn-2005","odni-srp-Cyrl-Latn-2015","odni-tat-Cyrl-Latn-2015","odni-tgk-Cyrl-Latn-2015","odni-tuk-Cyrl-Latn-2015","odni-uig-Cyrl-Latn-2015","odni-ukr-Cyrl-Latn-2015","odni-urd-Arab-Latn-2015","odni-uzb-Cyrl-Latn-2015","posix","sac-zho-Hans-Latn-1979","sasm-mon-Mong-Latn-general-1978","sasm-mon-Mong-Latn-phonetic-1978","ses-ara-Arab-Latn-1930","stategeocadastre-ukr-Cyrl-Latn-1993","ua-ukr-Cyrl-Latn-1996","ua-ukr-Cyrl-Latn-2007","ua-ukr-Cyrl-Latn-2010","un-amh-Ethi-Latn-2016","un-ara-Arab-Latn-1971","un-ara-Arab-Latn-1972","un-ara-Arab-Latn-2017","un-asm-Beng-Latn-1972","un-bel-Cyrl-Latn-2007","un-ben-Beng-Latn-2016","un-bul-Cyrl-Latn-1977","un-ell-Grek-Latn-1987-phonetic","un-ell-Grek-Latn-1987-tl","un-ell-Grek-Latn-1987-ts","un-guj-Gujr-Latn-1972","un-hin-Deva-Latn-2016","un-kan-Kana-Latn-2016","un-mal-Mlym-Latn-1972","un-mar-Deva-Latn-2016","un-mkd-Cyrl-Latn-1977","un-mon-Mong-Latn-general-2013","un-mon-Mong-Latn-phonetic-2013","un-nep-Deva-Latn-1972","un-nep-Deva-Latn-2013","un-ori-Orya-Latn-1972","un-pan-Guru-Latn-1972","un-prs-Arab-Latn-1967","un-rus-Cyrl-Latn-1987","un-sin-Sinh-Latn-1972","un-srp-Cyrl-Latn-1997","un-tam-Taml-Latn-1972","un-tel-Telu-Latn-1972","un-ukr-Cyrl-Latn-1998","un-ukr-Cyrl-Latn-2012","un-urd-Arab-Latn-1972","unicode","var-Cyrl","var-amh-Ethi-Latn-eae-2003","var-ara-Arab-Arab-rababa","var-gez-Ethi-Latn-eae-2003","var-hin-Deva-Latn-hunterian-1872","var-jpn-Hrkt-Latn-hepburn-1886","var-jpn-Hrkt-Latn-hepburn-1954","var-kor","var-kor-Hang-Hang-jamo","var-kor-Hang-Latn-mr-1939","var-kor-Kore-Hang-2013","var-kor-Kore-Latn-mr-1939","var-mar-Deva-Latn-hunterian-1872","var-mon-Mong-Latn-1930","var-mon-Mong-Latn-lessing","var-mon-Mong-Latn-vpmc","var-pra-Deva-Latn-iast-1912","var-san-Deva-Latn-iast-1912","var-zho-Hani-Latn-wd-1979"];var Bn=new Set(["unicode","posix","var-Cyrl","var-kor"]),Pn=new Set(["var-ara-Arab-Arab-rababa"]),Rt=Nt.filter(e=>!Bn.has(e)),Un=Rt.filter(e=>!Pn.has(e)),It=new Map;function S(){return Rt}function $t(){return Un}async function jt(e,t){let n=It.get(t);if(n)return n;let r=await e.fetch(new Request(`https://assets.internal/${t}.json`));if(!r.ok)throw new h(t);let a=await r.json(),s=Ce(a);return It.set(t,s),s}var Ot;function zt(e){if(Ot===e)return;Et({strategies:[n=>jt(e,n)]}),Ot=e}async function Dt(e,t,n){return zt(e),Me(t,n)}function Fn(e,t){if(e===t)return 0;if(!e.length)return t.length;if(!t.length)return e.length;let n=Array.from({length:t.length+1},(r,a)=>a);for(let r=1;r<=e.length;r++){let a=[r];for(let s=1;s<=t.length;s++)a[s]=Math.min(n[s]+1,a[s-1]+1,n[s-1]+(e[r-1]===t[s-1]?0:1));n=a}return n[t.length]}async function Bt(e,t,n){zt(e);let r=[];for(let a of $t())try{let s=await Me(a,t);r.push({mapName:a,distance:Fn(s,n)})}catch{continue}return r.sort((a,s)=>a.distance-s.distance)}var N=class extends Error{constructor(n){super(`Input is too long (max ${n} characters)`);this.max=n;this.name="InputTooLongError"}max},I=class extends Error{constructor(n){super(`Couldn't locate ${n}`);this.systemCode=n;this.name="MapNotFoundError"}systemCode};var R={input_max_size:1e6};var se="3.0.0-cloudflare.1",Te;function H(e){Te=e}function Pt(){if(!Te)throw new Error("ASSETS binding missing \u2014 see README deployment notes");return Te}async function Ut(){return JSON.stringify({version:se,engine:"interscript-ts@native-interpreter"})}function Ft(){return[...S()]}async function oe(e,t){if(t.length>R.input_max_size)throw new N(R.input_max_size);try{return await Dt(Pt(),e,t)}catch(n){throw n instanceof h?new I(e):n}}async function ie(e,t){return Bt(Pt(),e,t)}var qt={version:1,models:[{id:"khm-latn-1.0",task:"translit",scripts:["Khmr","Latn"],precision:"fp32",filename:"khm-latn-1.0-fp32.zip",url:"https://github.com/interscript/interscript-ml/releases/download/khm-latn-1.0/khm-latn-1.0-fp32.zip",parts:null,sha256:"55993d473a2ed9489058779cad7e115db05e4020085b71616468cfae4f2f65cb",size:1418009977,metrics:[{name:"cer",value:27.42,source:"secryst/docs/RESULTS.md#khmer-transliteration-2026-08-14"},{name:"em",value:59.66,source:"secryst/docs/RESULTS.md#khmer-transliteration-2026-08-14"}],parity:{samples:895,cer_delta:0},license:"BSD-3-Clause"},{id:"urd-g2p-1.0",task:"g2p",scripts:["Arab","IPA"],precision:"fp32",filename:"urd-g2p-1.0-fp32.zip",url:"https://github.com/interscript/interscript-ml/releases/download/urd-g2p-1.0/urd-g2p-1.0-fp32.zip",parts:null,sha256:"9f0a248c7116aa7f6b9ac125fb9684a3556f3b8ce8b64567c05a5e7e7a018ebf",size:1418039605,metrics:[{name:"cer",value:14.77,source:"rababa-urdu/docs/RESULTS.md#g2p-urdu-text--ipa"},{name:"em",value:33.6,source:"rababa-urdu/docs/RESULTS.md#g2p-urdu-text--ipa"}],parity:{samples:12699,cer_delta:0},license:"BSD-3-Clause"},{id:"urd-diac-1.0",task:"diacritization",scripts:["Arab","Arab"],precision:"fp32",filename:"urd-diac-1.0-fp32.zip",url:"https://github.com/interscript/interscript-ml/releases/download/urd-diac-1.0/urd-diac-1.0-fp32.zip",parts:null,sha256:"c299ea44a4da4851a52283f8e42d2fb6f8c7a9c443ba7eb0270f97372e10b8ea",size:1417851421,metrics:[{name:"cer",value:3.74,source:"rababa-urdu/docs/RESULTS.md#diacritization-urdu-text--text--haraqat"}],parity:{samples:11940,cer_delta:0},license:"BSD-3-Clause"},{id:"heb-diac-1.0",task:"diacritization",scripts:["Hebr","Hebr"],precision:"fp32",filename:"heb-diac-1.0-fp32.zip",url:null,parts:[{url:"https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.0/heb-diac-1.0-fp32.zip.part-00",sha256:"5497f70cc3c96829e65f1eb0cc401c2d1ffeb4fa909acd4def824c2e019cbc37",size:15e8},{url:"https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.0/heb-diac-1.0-fp32.zip.part-01",sha256:"a7d2011ab4f9326a86e234cc49cb50daf82949e51efbf03a21d5796c46465e9d",size:1281139753}],sha256:"b32fa239e0c56708b6004942de4b9e6e9f265e7cc3828f41d560e96386e20dd8",size:2781139753,metrics:[{name:"der_greedy",value:29,source:"rababa/docs/RESULTS.md#hebrew-diacritization"},{name:"der_beam4",value:17.46,source:"rababa/docs/RESULTS.md#hebrew-diacritization"}],parity:{samples:600,cer_delta:0},license:"BSD-3-Clause"},{id:"tha-g2p-base-1.0",task:"g2p",scripts:["Thai","IPA"],precision:"fp32",filename:"tha-g2p-base-1.0-fp32.zip",url:null,parts:[{url:"https://github.com/interscript/interscript-ml/releases/download/tha-g2p-base-1.0/tha-g2p-base-1.0-fp32.zip.part-00",sha256:"c4525414e5dec91a54d055ca9f1acd51c198f81fbfc55977aa82c1fb038d58d7",size:15e8},{url:"https://github.com/interscript/interscript-ml/releases/download/tha-g2p-base-1.0/tha-g2p-base-1.0-fp32.zip.part-01",sha256:"f5d11fbd75f92e8b5471add867418e2dd4f49a5e258b9ded2f3b5ffa630abe24",size:1281174343}],sha256:"f341a5868867a9847d3f897d1fcc4d1d63b9a59b8913871bcf4ecab48f4fa895",size:2781174343,metrics:[{name:"per_teacher",value:4.43,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-base-1.0"},{name:"per_student",value:9.19,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-base-1.0"}],parity:{samples:1219,cer_delta:0},license:"BSD-3-Clause"},{id:"tha-g2p-small-1.0",task:"g2p",scripts:["Thai","IPA"],precision:"int8",filename:"tha-g2p-small-1.0-int8.zip",url:"https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int8.zip",parts:null,sha256:"f2cfa93a42d98aabf08fdc82dfc6bd1574e21993f36558aa581fbe29e0588a94",size:257468517,metrics:[{name:"per_teacher",value:4.43,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0"},{name:"per_student",value:12.06,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0"}],parity:{samples:1219,cer_delta:.0803},license:"BSD-3-Clause"},{id:"tha-g2p-small-1.0-int4",task:"g2p",scripts:["Thai","IPA"],precision:"int4",filename:"tha-g2p-small-1.0-int4.zip",url:"https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int4.zip",parts:null,sha256:"e5d12a3d65c6ac39fa08f52c975c99ff7a51c3e7b7aca7fbb461d2de2345e4cb",size:201958073,metrics:[{name:"per_teacher",value:4.43,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0"},{name:"per_student",value:12.06,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0"}],parity:{samples:600,cer_delta:.0734},license:"BSD-3-Clause"},{id:"heb-diac-small-1.0",task:"diacritization",scripts:["Hebr","Hebr"],precision:"fp32",filename:"heb-diac-small-1.0-fp32.zip",url:"https://github.com/interscript/interscript-ml/releases/download/heb-diac-small-1.0/heb-diac-small-1.0-fp32.zip",parts:null,sha256:"905c53873d5a62bbe6252c6ec0ecef5f37e96e78cb01e8cd99b6b24c4d4d74ad",size:1418663344,metrics:[{name:"der_teacher_greedy",value:24.79,source:"interscript/interscript-ml docs/RESULTS.md#heb-diac-small-1.0"},{name:"der_student_greedy",value:30.37,source:"interscript/interscript-ml docs/RESULTS.md#heb-diac-small-1.0"}],parity:{samples:1864,cer_delta:0},license:"BSD-3-Clause"},{id:"fas-g2p-1.0",task:"g2p",scripts:["Arab","Latn"],precision:"fp32",filename:"fas-g2p-1.0-fp32.zip",url:null,parts:[{url:"https://github.com/interscript/interscript-ml/releases/download/fas-g2p-1.0/fas-g2p-1.0-fp32.zip.part-00",sha256:"6c475e53f3c7ef3edcef5a24d2d81f51d13ddf4c417de98440943c9a32b03e55",size:15e8},{url:"https://github.com/interscript/interscript-ml/releases/download/fas-g2p-1.0/fas-g2p-1.0-fp32.zip.part-01",sha256:"c5656c649412f41e201c567e002514d31390b636d4650d9dcb6dfed1973fb3d5",size:1280254270}],sha256:"b53fd69196127efcc596935d24e135b3c897006872c1646c674e70f3c0d9a0e3",size:2780254270,metrics:[{name:"cer",value:1.6,source:"interscript/interscript-ml docs/RESULTS.md#fas-g2p-1.0"},{name:"sb_homograph_ezafe_norm",value:77.34,source:"interscript/interscript-ml docs/RESULTS.md#fas-g2p-1.0"}],parity:{samples:1e3,cer_delta:0},license:"BSD-3-Clause"}]};var Ee=qt;function ce(){return Ee.models}function Ne(e){return Ee.models.find(t=>t.id===e)}var Gt=Ee.version;var Ht={openapi:"3.1.0",info:{title:"Interscript API",version:"1.0.0",description:"Transliteration and neural text processing. Maps run in-edge on the interscript-ts native interpreter (289 systems); neural models (diacritization, grapheme-to-phoneme) run on Interscript's inference service. GraphQL remains available at POST /graphql.",license:{name:"BSD-3-Clause"}},servers:[{url:"https://api.interscript.org"}],tags:[{name:"service"},{name:"maps"},{name:"transliteration"},{name:"models"},{name:"inference"}],paths:{"/":{get:{tags:["service"],summary:"Service index",responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/info":{get:{tags:["service"],summary:"Version and capability summary",responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/maps":{get:{tags:["maps"],summary:"Every bundled transliteration system code",responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/maps/{code}":{get:{tags:["maps"],summary:"One system's compiled map (JSON IR)",parameters:[{name:"code",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{$ref:"#/components/responses/Ok"},404:{$ref:"#/components/responses/NotFound"}}}},"/v1/transliterate":{post:{tags:["transliteration"],summary:"Transliterate text with a system",requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/TransliterateRequest"},examples:{gek:{value:{system:"ungegn-kor-Kore-Latn-1939",input:"\uD3C9\uC591"}}}}}},responses:{200:{description:"Transliterated output",content:{"application/json":{schema:{$ref:"#/components/schemas/TransliterateResponse"}}}},404:{$ref:"#/components/responses/NotFound"},413:{$ref:"#/components/responses/Error"}}}},"/v1/detect":{post:{tags:["transliteration"],summary:"Rank systems by how well they map input to output",requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/DetectRequest"}}}},responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/models":{get:{tags:["models"],summary:"The neural model index (IMF v1)",responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/models/{id}":{get:{tags:["models"],summary:"One model's full entry (metrics, parity, download)",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{$ref:"#/components/responses/Ok"},404:{$ref:"#/components/responses/NotFound"}}}},"/v1/infer":{post:{tags:["inference"],summary:"Run a neural model (diacritization or G2P)",description:"Proxy to Interscript's inference service. Only models whose task is diacritization or g2p are served; see GET /v1/models for the catalog.",requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/InferRequest"},examples:{hebrew:{value:{model:"heb-diac-1.0",input:"\u05E9\u05DC\u05D5\u05DD \u05E2\u05DC\u05D9\u05DB\u05DD"},summary:"Hebrew nikud restoration"},urdu:{value:{model:"urd-g2p-1.0",input:"\u0627\u0631\u062F\u0648"},summary:"Urdu grapheme-to-phoneme"}}}}},responses:{200:{description:"Model output",content:{"application/json":{schema:{$ref:"#/components/schemas/InferResponse"}}}},404:{$ref:"#/components/responses/NotFound"},502:{$ref:"#/components/responses/Error"},503:{$ref:"#/components/responses/Error"}}}}},components:{schemas:{Error:{type:"object",properties:{error:{type:"object",properties:{code:{type:"string"},message:{type:"string"}}}}},TransliterateRequest:{type:"object",required:["system","input"],properties:{system:{type:"string",description:"A system code from GET /v1/maps",examples:["ungegn-kor-Kore-Latn-1939"]},input:{type:"string",maxLength:1e6}}},TransliterateResponse:{type:"object",properties:{system:{type:"string"},input:{type:"string"},output:{type:"string"}}},DetectRequest:{type:"object",required:["input","output"],properties:{input:{type:"string"},output:{type:"string"}}},InferRequest:{type:"object",required:["model","input"],properties:{model:{type:"string",description:"A model id from GET /v1/models",examples:["heb-diac-1.0"]},input:{type:"string",maxLength:4e3}}},InferResponse:{type:"object",properties:{model:{type:"string"},task:{type:"string",enum:["diacritization","g2p"]},input:{type:"string"},output:{type:"string"}}}},responses:{Ok:{description:"Success",content:{"application/json":{schema:{type:"object"}}}},NotFound:{description:"Unknown system or model",content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}}},Error:{description:"Error",content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}}}}}};var Hn=12e4;function f(e,t,n){return Response.json({error:{code:t,message:n}},{status:e})}var b=new Gn;b.get("/",e=>e.json({name:"Interscript API",version:"v1",openapi:"/openapi.json",endpoints:["GET /v1/info","GET /v1/maps","GET /v1/maps/{code}","POST /v1/transliterate","POST /v1/detect","GET /v1/models","GET /v1/models/{id}","POST /v1/infer","POST /graphql"]}));b.get("/openapi.json",e=>e.json(Ht));b.get("/v1/info",e=>e.json({api_version:"1.0.0",engine_version:se,engine:"interscript-ts@native-interpreter",maps:S().length,models:ce().length,models_index_version:Gt,limits:R}));b.get("/v1/maps",e=>e.json({count:S().length,maps:S()}));b.get("/v1/maps/:code",async e=>{let t=e.env?.ASSETS;if(!t)return f(503,"assets_missing","ASSETS binding not configured");let n=e.req.param("code");if(!S().includes(n))return f(404,"map_not_found",`Couldn't locate ${n}`);let r=await t.fetch(`https://assets.internal/${n}.json`);return r.ok?new Response(r.body,{headers:{"content-type":"application/json; charset=utf-8"}}):f(404,"map_not_found",`Couldn't locate ${n}`)});b.post("/v1/transliterate",async e=>{let t=e.env?.ASSETS;if(!t)return f(503,"assets_missing","ASSETS binding not configured");H(t);let n=await e.req.json().catch(()=>null);if(!n||typeof n!="object")return f(400,"bad_request","body must be JSON {system, input}");let{system:r,input:a}=n;if(typeof r!="string"||typeof a!="string")return f(400,"bad_request","system and input must be strings");try{let s=await oe(r,a);return e.json({system:r,input:a,output:s})}catch(s){return s instanceof N?f(413,"input_too_long",s.message):s instanceof I?f(404,"map_not_found",s.message):f(500,"engine_error",String(s))}});b.post("/v1/detect",async e=>{let t=e.env?.ASSETS;if(!t)return f(503,"assets_missing","ASSETS binding not configured");H(t);let n=await e.req.json().catch(()=>null),{input:r,output:a}=n??{};if(typeof r!="string"||typeof a!="string")return f(400,"bad_request","input and output must be strings");let s=await ie(r,a);return e.json({count:s.length,results:s})});b.get("/v1/models",e=>e.json({count:ce().length,models:ce()}));b.get("/v1/models/:id",e=>{let t=Ne(e.req.param("id"));return t?e.json(t):f(404,"model_not_found",`Couldn't locate ${e.req.param("id")}`)});b.post("/v1/infer",async e=>{let t=await e.req.json().catch(()=>null),{model:n,input:r}=t??{};if(typeof n!="string"||typeof r!="string")return f(400,"bad_request","body must be JSON {model, input}");if(!Ne(n))return f(404,"model_not_found",`Couldn't locate ${n}`);let{ML_ENDPOINT:a,ML_TOKEN:s}=e.env??{};if(!a||!s)return f(503,"inference_unconfigured","ML_ENDPOINT/ML_TOKEN are not set on this deployment");let o=await fetch(`${a}/infer`,{method:"POST",headers:{"content-type":"application/json","x-api-key":s},body:JSON.stringify({model:n,input:r}),signal:AbortSignal.timeout(Hn)}).catch(()=>null);if(!o||!o.ok){let i=o?await o.text().catch(()=>""):"upstream unreachable";return f(502,"inference_upstream",i.slice(0,500))}let c=await o.json();return e.json({model:n,task:c.task,input:r,output:c.output})});var Yn=Kn({schema:Wn({typeDefs:pe,resolvers:{Query:{info:()=>Ut(),systemCodes:()=>Ft(),transliterate:(e,t)=>oe(t.systemCode,t.input),detect:(e,t)=>ie(t.input,t.output)}}}),graphqlEndpoint:"*",landingPage:!1,maskedErrors:!1}),K=new Vn;K.use("*",Qn({origin:"*",allowMethods:["GET","POST","OPTIONS"]}));K.route("/",b);K.all("*",e=>{let t=e.env;t?.ASSETS&&H(t.ASSETS);let n;try{n=e.executionCtx}catch{n=void 0}return Yn.fetch(e.req.raw,e.env,n)});var Jn=K;export{se as API_VERSION,R as LIMITS,K as app,Jn as default,pe as typeDefs}; +`;import{Hono as Jn}from"hono";var g=class extends Error{cause;constructor(t,n){super(t,n),this.name=new.target.name,this.cause=n?.cause}},h=class extends g{systemCode;constructor(t){super(`Map not found: ${t}`),this.systemCode=t}},_=class extends g{},L=class extends g{},M=class extends g{dependency;constructor(t){super(`Map dependency missing: ${t}`),this.dependency=t}};var W=class{strategies;cache=new Map;known=new Map;options;constructor(t,n={}){this.strategies=t,this.options=n}load(t){let n=this.cache.get(t);if(n)return n;let r=this.known.get(t);if(r)return this.cache.set(t,r),r;for(let a of this.strategies){let s=a(t);if(s&&typeof s.then!="function"){let o=s;return this.cache.set(t,o),this.known.set(t,o),this.options.onLoaded?.(t,o),o}}throw new h(t)}async loadAsync(t){let n=this.cache.get(t);if(n)return n;let r=this.known.get(t);if(r)return this.cache.set(t,r),r;for(let a of this.strategies){let s=await a(t);if(s)return this.cache.set(t,s),this.known.set(t,s),this.options.onLoaded?.(t,s),s}throw new h(t)}clear(){this.cache.clear()}loadedMaps(){return Array.from(this.known.keys())}register(t,n){this.known.set(t,n),this.cache.set(t,n)}};var z=class e{current;map;loader;aliasCache=new Map;functions;constructor(t,n,r){this.map=t,this.current=n,this.functions=t.functions,this.loader=r}resolveAlias(t){if(this.aliasCache.has(t))return this.aliasCache.get(t);let n=this.map.aliases.get(t);if(!n&&this.loader)for(let r of this.map.dependencies)try{let s=this.loader.load(r).aliases.get(t);if(s){n=s;break}}catch{}return n&&this.aliasCache.set(t,n),n}withMap(t){return new e(t,this.current,this.loader)}loadDependency(t){if(!this.loader)throw new Error(`Cannot resolve dependency ${t}: no loader configured`);return this.loader.load(t)}};function fe(){return{children:new Map,match:null}}function Oe(e){let t=fe();for(let[n,r]of e){if(n.length===0)continue;let a=t;for(let c=0;c0?(n+=c,a+=o):(n+=e[a],a+=1)}return n}function D(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function je(e){return e.toLowerCase()}function ze(e){return e.toUpperCase()}function De(e,t={}){let n=t.wordSeparator??" ";return n===""?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e.split(n).map(r=>r.length===0?r:r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(n)}function Be(e,t={}){let n=t.separator??" ";return e.split("").join(n)}function Pe(e){return e.normalize("NFC")}function Ue(e){return e.normalize("NFD")}function qe(e,t){if(t.length===0)return e;let n=t.map((a,s)=>`(?<__r${s}>${a.pattern})`),r=new RegExp(n.join("|"),"gmu");return e.replace(r,(...a)=>{let s=a[a.length-1];for(let o=0;ou(a,t).re),r=e.of.length>0?u(e.of[0],t).literal:"";return{re:`(?:${n.join("|")})`,literal:r}}case"any_char_class":{if(e.range){let[n,r]=e.range;return{re:`[${D(n)}-${D(r)}]`,literal:n??""}}return e.chars&&e.chars.length>0?{re:`[${e.chars.map(r=>D(r)).join("")}]`,literal:e.chars[0]}:{re:"[^]",literal:""}}case"group":{let n=e.items.map(s=>u(s,t)),r=n.map(s=>s.re).join(""),a=n.map(s=>s.literal).join("");return{re:`(?:${r})`,literal:a}}case"repeat":{let n=u(e.item,t).re,{min:r,max:a}=e,s=a===null?1/0:a,o=s===1/0?r===0?"*":"+":`{${r},${s}}`;return{re:`(?:${n})${o}`,literal:""}}case"stage_ref":return{re:"",literal:""}}}function B(e,t){switch(e.kind){case"string":return e.value;case"alias":{let n=V[e.name];if(n)return n.literal===""?null:n.literal;let r=t.resolveAlias(e.name);return r?B(r,t):null}case"capture_group":case"capture_ref":case"repeat":case"stage_ref":return null;case"any_char_class":return e.chars&&e.chars.length>0?e.chars[0]:e.range?e.range[0]:null;case"any":return e.of.length===0?null:B(e.of[0],t);case"group":{let n="";for(let r of e.items){let a=B(r,t);if(a===null)return null;n+=a}return n}}}function C(e,t){switch(e.kind){case"string":return[e.value];case"alias":{if(V[e.name])return null;let r=t.resolveAlias(e.name);return r?C(r,t):null}case"any_char_class":{if(e.chars)return[...e.chars];if(e.range){let[n,r]=e.range,a=n.codePointAt(0),s=r.codePointAt(0),o=[];for(let c=a;c<=s;c++)o.push(String.fromCodePoint(c));return o}return null}case"any":{let n=[];for(let r of e.of){let a=C(r,t);if(a===null)return null;n.push(...a)}return n}case"group":{let n=[""];for(let r of e.items){let a=C(r,t);if(a===null)return null;let s=[];for(let o of n)for(let c of a)s.push(o+c);n=s}return n}default:return null}}function y(e,t){switch(e.kind){case"string":return e.value.length;case"capture_group":return y(e.data,t);case"capture_ref":return 1;case"alias":{if(e.name==="none")return 0;if(V[e.name])return 1;let n=t.resolveAlias(e.name);return n?y(n,t):1}case"any":return e.of.reduce((n,r)=>Math.max(n,y(r,t)),0);case"any_char_class":return 1;case"group":return e.items.reduce((n,r)=>n+y(r,t),0);case"repeat":return y(e.item,t);case"stage_ref":return 1}}var V=Object.freeze({any_character:{re:".",literal:""},none:{re:"",literal:""},space:{re:" ",literal:" "},whitespace:{re:"\\s+",literal:" "},boundary:{re:"(?:(?De(e,t??{}),separate:(e,t)=>Be(e,t??{}),compose:Pe,decompose:Ue};function Fe(e,t){let n=e.functions.get(t)?.impl;if(n)return n;let r=Yt[t];if(r)return r}var Xt={sub:(e,t)=>Zt(e,t),run:(e,t)=>{let n=e.docName?t.loadDependency(e.docName):t.map,r=n.stages.find(s=>s.name===e.stage);if(!r)throw new L(`Stage not found: ${e.stage}`);let a=t.withMap(n);for(let s of r.rules)A(s,a);t.current=a.current},funcall:(e,t)=>{let n=Fe(t,e.name);if(!n)throw new L(`Unknown function: ${e.name}`);t.current=n(t.current,e.kwargs??{})},parallel:(e,t)=>{let n=[],r=[];for(let o of e.rules)o.kind==="sub"&&o.from?n.push(o):r.push(o);let a=o=>!o.before&&!o.after&&!o.notBefore&&!o.notAfter&&C(o.from,t)!==null;if(n.some(o=>!a(o))){let c=n.map((i,l)=>({rule:i,idx:l,len:y(i.from,t)+(i.before?y(i.before,t):0)+(i.after?y(i.after,t):0)+(i.notBefore?y(i.notBefore,t):0)+(i.notAfter?y(i.notAfter,t):0)+(i.priority??0)})).sort((i,l)=>l.len-i.len||i.idx-l.idx).map(({rule:i})=>{let l=u(i.from,t),p=i.before?u(i.before,t).re:"",d=i.after?u(i.after,t).re:"",v=i.notBefore?u(i.notBefore,t).re:"",w=i.notAfter?u(i.notAfter,t).re:"",ue=[p?`(?<=${p})`:"",v?`(?He(O,x,Jt):O}});t.current=qe(t.current,c)}else{let o=[];for(let c of n){if(c.to&&c.to.kind==="funcall_inline")continue;let i=c.to?B(c.to,t):"";if(i===null)continue;let l=C(c.from,t);if(l!==null)for(let p of l)o.push([p,i])}o.length>0&&(t.current=$e(t.current,Oe(o)))}for(let o of r)A(o,t)},sequential:(e,t)=>{for(let n of e.rules)A(n,t)}};function Zt(e,t){if(!e.from)throw new L("Sub rule missing 'from'");let n=u(e.from,t),r=e.before?u(e.before,t).re:"",a=e.after?u(e.after,t).re:"",s=e.notBefore?u(e.notBefore,t).re:"",o=e.notAfter?u(e.notAfter,t).re:"",c=[];r&&c.push(`(?<=${r})`),s&&c.push(`(?{let p=l;return(d,...v)=>He(p,d,v)})():l)}function He(e,t,n){return e.replace(/\$(\d+)/g,(r,a)=>{let s=parseInt(a,10);return n[s-1]??t})}function Ge(e,t){if(!e)return"";if(e.kind==="funcall_inline"){let r=Fe(t,e.name);if(!r)throw new L(`Unknown inline function: ${e.name}`);return a=>r(a)}return u(e,t).literal}function A(e,t){let n=Xt[e.kind];n(e,t)}var Ce=new Set(["rababa","secryst"]);function Tt(e){for(let t of e){if(t.kind==="funcall"&&Ce.has(t.name))return!0;if(t.kind==="parallel"||t.kind==="sequential"){for(let n of t.rules)if(n.kind==="funcall"&&Ce.has(n.name))return!0}}return!1}function H(e,t,n,r){let a=e.stages.find(o=>o.name===t);if(!a)return n;if(Tt(a.rules))throw new Error(`Stage "${t}" contains ML function calls (rababa/secryst). Use transliterateAsync() instead of transliterate().`);let s=new z(e,n,r);for(let o of a.rules)A(o,s);return s.current}async function Et(e,t,n,r){let a=e.stages.find(o=>o.name===t);if(!a)return n;if(!Tt(a.rules))return H(e,t,n,r);let s=new z(e,n,r);for(let o of a.rules)await jn(o,s);return s.current}async function jn(e,t){if(e.kind==="funcall"){await zn(e,t);return}A(e,t)}async function zn(e,t){if(e.name==="rababa"){let{rababa:n}=await Promise.resolve().then(()=>(dt(),ut));t.current=await n(t.current,e.kwargs);return}if(Ce.has(e.name)){let{loadModel:n}=await Promise.resolve().then(()=>(Ct(),Mt)),r=e.kwargs?.config??e.kwargs?.model??"default",a=await n({kind:e.name,id:r});t.current=await a.transform(t.current);return}A({kind:"funcall",name:e.name,kwargs:e.kwargs},t)}function Dn(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=new Array(t.length+1),r=new Array(t.length+1);for(let a=0;a<=t.length;a++)n[a]=a;for(let a=1;a<=e.length;a++){r[0]=a;for(let s=1;s<=t.length;s++){let o=e[a-1]===t[s-1]?0:1;r[s]=Math.min(n[s]+1,r[s-1]+1,n[s-1]+o)}[n,r]=[r,n]}return n[t.length]}function Bn(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${t}$`)}function Nt(e,t,n,r={},a){let s=[],o=r.mapPattern?Bn(r.mapPattern):null,c=a??n.loadedMaps();for(let i of c){if(o&&!o.test(i))continue;let l;try{let p=n.load(i);l=H(p,"main",e,n)}catch(p){if(p instanceof g)continue;throw p}s.push({mapName:i,distance:Dn(l,t)})}return s.sort((i,l)=>i.distance-l.distance)}function Te(e){let t={schemaVersion:e.schemaVersion,systemCode:e.systemCode,dependencies:e.dependencies,stages:e.stages,aliases:new Map(Object.entries(e.aliases)),functions:new Map};return e.metadata&&(t.metadata=e.metadata),t}var Pn="main",ae=class{loader;defaultStage;constructor(t={}){this.loader=new W(t.strategies??[]),this.defaultStage=t.defaultStage??Pn}loadMap(t){let n=this.loader.load(t);for(let r of n.dependencies)try{this.loader.load(r)}catch(a){throw a instanceof h?new M(r):a}return n}async loadMapAsync(t){let n=await this.loader.loadAsync(t),r=new Set,a=[...n.dependencies];for(;a.length>0;){let s=a.shift();if(!r.has(s)){r.add(s);try{let o=await this.loader.loadAsync(s);for(let c of o.dependencies)r.has(c)||a.push(c)}catch(o){throw o instanceof h?new M(s):o}}}return n}transliterate(t,n,r){try{let a=this.loadMap(t),s=r??this.defaultStage;return H(a,s,n,this.loader)}catch(a){throw a instanceof g?a:new _(`Transliteration failed for ${t}: ${a.message}`,{cause:a})}}async transliterateAsync(t,n,r){try{let a=await this.loadMapAsync(t),s=r??this.defaultStage;return await Et(a,s,n,this.loader)}catch(a){throw a instanceof g?a:new _(`Transliteration failed for ${t}: ${a.message}`,{cause:a})}}loadedMaps(){return this.loader.loadedMaps()}getLoader(){return this.loader}detect(t,n,r={},a){return Nt(t,n,this.loader,r,a)}},re;function It(e){re=new ae(e)}function Un(){return re||(re=new ae),re}function Ee(e,t,n){return Un().transliterateAsync(e,t,n)}var Rt=["acadsin-zho-Hani-Latn-2002","alalc-amh-Ethi-Latn-1997","alalc-amh-Ethi-Latn-2011","alalc-ara-Arab-Latn-1997","alalc-asm-Deva-Latn-1997","alalc-asm-Deva-Latn-2012","alalc-aze-Arab-Latn-1997","alalc-aze-Cyrl-Latn-1997","alalc-bel-Cyrl-Latn-1997","alalc-ben-Beng-Latn-1997","alalc-ben-Beng-Latn-2017","alalc-bul-Cyrl-Latn-1997","alalc-div-Thaa-Latn-1997","alalc-div-Thaa-Latn-2012","alalc-ell-Grek-Latn-1997","alalc-ell-Grek-Latn-2010","alalc-fas-Arab-Latn-1997","alalc-guj-Gujr-Latn-1997","alalc-guj-Gujr-Latn-2011","alalc-hin-Deva-Latn-1997","alalc-hin-Deva-Latn-2011","alalc-kan-Kana-Latn-1997","alalc-kan-Kana-Latn-2011","alalc-kat-Geok-Latn-1997","alalc-kat-Geok-Latn-2011","alalc-kat-Geor-Latn-1997","alalc-kat-Geor-Latn-2011","alalc-kor-Hang-Latn-1997","alalc-mal-Mlym-Latn-1997","alalc-mal-Mlym-Latn-2012","alalc-mar-Deva-Latn-1997","alalc-mar-Deva-Latn-2011","alalc-mkd-Cyrl-Latn-1997","alalc-mkd-Cyrl-Latn-2013","alalc-mon-Cyrl-Latn-1997","alalc-ori-Orya-Latn-1997","alalc-ori-Orya-Latn-2011","alalc-pan-Guru-Latn-1997","alalc-pan-Guru-Latn-2011","alalc-pli-Deva-Latn-2012","alalc-pra-Deva-Latn-2012","alalc-rus-Cyrl-Latn-1997","alalc-rus-Cyrl-Latn-2012","alalc-san-Deva-Latn-2012","alalc-sin-Sinh-Latn-1997","alalc-sin-Sinh-Latn-2011","alalc-srp-Cyrl-Latn-1997","alalc-srp-Cyrl-Latn-2013","alalc-tam-Taml-Latn-1997","alalc-tam-Taml-Latn-2011","alalc-tel-Telu-Latn-1997","alalc-tel-Telu-Latn-2011","alalc-tir-Ethi-Latn-1997","alalc-tir-Ethi-Latn-2011","alalc-ukr-Cyrl-Latn-1997","alalc-ukr-Cyrl-Latn-2011","apcbg-bul-Cyrl-Latn-1995","az-aze-Cyrl-Latn-1939","az-aze-Cyrl-Latn-1958","bas-rus-Cyrl-Latn-2017-bss","bas-rus-Cyrl-Latn-2017-oss","bgn-jpn-Hrkt-Latn-1962","bgn-kor-Hang-Latn-1943","bgn-kor-Kore-Latn-1943","bgna-bul-Cyrl-Latn-2006","bgna-bul-Cyrl-Latn-2009","bgnpcgn-amh-Ethi-Latn-1967","bgnpcgn-ara-Arab-Latn-1956","bgnpcgn-arm-Armn-Latn-1981","bgnpcgn-aze-Cyrl-Latn-1993","bgnpcgn-bak-Cyrl-Latn-2007","bgnpcgn-bal-Arab-Latn-2008","bgnpcgn-bel-Cyrl-Latn-1979","bgnpcgn-bul-Cyrl-Latn-1952","bgnpcgn-bul-Cyrl-Latn-2013","bgnpcgn-che-Cyrl-Latn-2008","bgnpcgn-deu-Latn-Latn-2000","bgnpcgn-div-Thaa-Latn-1972","bgnpcgn-div-Thaa-Latn-1988","bgnpcgn-ell-Grek-Latn-1962","bgnpcgn-ell-Grek-Latn-1996","bgnpcgn-fao-Latn-Latn-1964","bgnpcgn-fao-Latn-Latn-1968","bgnpcgn-fas-Arab-Latn-1956","bgnpcgn-isl-Latn-Latn-1964","bgnpcgn-isl-Latn-Latn-1968","bgnpcgn-jpn-Hrkt-Latn-1976","bgnpcgn-kat-Geor-Latn-1981","bgnpcgn-kat-Geor-Latn-2009","bgnpcgn-kaz-Cyrl-Latn-1979","bgnpcgn-kir-Cyrl-Latn-1979","bgnpcgn-kor-Hang-Latn-kn-1945","bgnpcgn-kor-Hang-Latn-rok-2011","bgnpcgn-kor-Kore-Latn-rok-2011","bgnpcgn-kur-Arab-Latn-2007","bgnpcgn-mkd-Cyrl-Latn-1981","bgnpcgn-mkd-Cyrl-Latn-2013","bgnpcgn-mon-Cyrl-Latn-1964","bgnpcgn-nep-Deva-Latn-2011","bgnpcgn-per-Arab-Latn-1958","bgnpcgn-prs-Arab-Latn-2007","bgnpcgn-prs-Arab-Latn-yaghoubi","bgnpcgn-pus-Arab-Latn-1968","bgnpcgn-ron-Cyrl-Latn-2002","bgnpcgn-rue-Cyrl-Latn-2016","bgnpcgn-rus-Cyrl-Latn-1947","bgnpcgn-sme-Latn-Latn-1984","bgnpcgn-srp-Cyrl-Latn-1962","bgnpcgn-srp-Cyrl-Latn-2005","bgnpcgn-tat-Cyrl-Latn-2007","bgnpcgn-tgk-Cyrl-Latn-1994","bgnpcgn-tir-Ethi-Latn-2007","bgnpcgn-ukr-Cyrl-Latn-1965","bgnpcgn-ukr-Cyrl-Latn-2019","bgnpcgn-urd-Arab-Latn-2007","bgnpcgn-uzb-Cyrl-Latn-1979","bgnpcgn-uzb-Cyrl-Latn-2000","bgnpcgn-zho-Hans-Latn-1979","bis-asm-Beng-Latn-13194-1991","bis-ben-Beng-Latn-13194-1991","bis-dev-Deva-Latn-13194-1991","bis-guj-Gujr-Latn-13194-1991","bis-kan-Kana-Latn-13194-1991","bis-mlm-Mlym-Latn-13194-1991","bis-ori-Orya-Latn-13194-1991","bis-pnj-Guru-Latn-13194-1991","bis-tel-Telu-Latn-13194-1991","bis-tml-Taml-Latn-13194-1991","by-bel-Cyrl-Latn-1998","by-bel-Cyrl-Latn-2007","din-grc-Grek-Latn-31634-2011-t1","din-hin-Deva-Latn-33904-2018","din-kat-Geor-Latn-32707-2010","din-mar-Deva-Latn-33904-2018","din-nep-Deva-Latn-33904-2018","din-pli-Deva-Latn-33904-2018","din-pra-Deva-Latn-33904-2018","din-san-Deva-Latn-33904-2018","din-tam-Taml-Latn-33903-2016","dos-nep-Deva-Latn-1997","elot-ell-Grek-Latn-743-1982-tl","elot-ell-Grek-Latn-743-1982-ts","elot-ell-Grek-Latn-743-2001-tl","elot-ell-Grek-Latn-743-2001-ts","ggg-kat-Geor-Latn-2002","gki-bel-Cyrl-Latn-1992","gki-bel-Cyrl-Latn-2000","gost-rus-Cyrl-Latn-16876-71-1983","gost-rus-Cyrl-Latn-7.79-2000-2002","hk-yue-Hani-Latn-1888","icao-bel-Cyrl-Latn-9303","icao-bul-Cyrl-Latn-9303","icao-fas-Arab-Latn-9303","icao-heb-Hebr-Latn-9303","icao-mkd-Cyrl-Latn-9303","icao-rus-Cyrl-Latn-9303","icao-srp-Cyrl-Latn-9303","icao-ukr-Cyrl-Latn-9303","iso-ara-Arab-Latn-233-1984","iso-ara-Arab-Latn-233-2-1993","iso-asm-Beng-Latn-15919-2001","iso-ben-Beng-Latn-15919-2001","iso-ell-Grek-Latn-843-1997-t1","iso-ell-Grek-Latn-843-1997-t2","iso-guj-Gujr-Latn-15919-2001","iso-hin-Deva-Latn-15919-2001","iso-inc-Deva-Latn-15919-2001","iso-jpn-Hrkt-Latn-3602-1989","iso-kan-Kana-Latn-15919-2001","iso-kat-Geor-Latn-9984-1996","iso-kor-Hang-Latn-1996-method1","iso-kor-Hang-Latn-1996-method2","iso-mal-Mlym-Latn-15919-2001","iso-mar-Deva-Latn-15919-2001","iso-nep-Deva-Latn-15919-2001","iso-ori-Orya-Latn-15919-2001","iso-pan-Guru-Latn-15919-2001","iso-pli-Beng-Latn-15919-2001","iso-pli-Deva-Latn-15919-2001","iso-pli-Sinh-Latn-15919-2001","iso-pli-Thai-Latn-15919-2001","iso-pra-Deva-Latn-15919-2001","iso-prs-Arab-Latn-233-3-1999","iso-rus-Cyrl-Latn-9-1995","iso-san-Deva-Latn-15919-2001","iso-tam-Taml-Latn-15919-2001","iso-tel-Telu-Latn-15919-2001","iso-tha-Thai-Latn-11940-1998","kp-kor-Hang-Latn-2002","lshk-yue-Hani-Latn-jyutping-1993","masm-mon-Cyrl-Latn-5217-2012","masm-mon-Latn-Cyrl-5217-2012","mext-jpn-Hrkt-Latn-1954","moct-kor-Hang-Latn-2000","mofa-jpn-Hrkt-Latn-1989","mv-div-Thaa-Latn-1987","mvd-bel-Cyrl-Latn-2008","mvd-bel-Cyrl-Latn-2010","mvd-rus-Cyrl-Latn-2008","mvd-rus-Cyrl-Latn-2010","odni-ara-Arab-Latn-2004","odni-ara-Arab-Latn-2015","odni-aze-Cyrl-Latn-2015","odni-bel-Cyrl-Latn-2015","odni-bul-Cyrl-Latn-2005","odni-bul-Cyrl-Latn-2015","odni-che-Cyrl-Latn-2015","odni-fas-Arab-Latn-2004","odni-fas-Arab-Latn-2015","odni-hin-Deva-Latn-2004","odni-hin-Deva-Latn-2015","odni-kat-Geor-Latn-2015","odni-kaz-Cyrl-Latn-2015","odni-kir-Cyrl-Latn-2015","odni-kor-Hang-Latn-2015","odni-mkd-Cyrl-Latn-2005","odni-mkd-Cyrl-Latn-2015","odni-prs-Arab-Latn-2004","odni-prs-Arab-Latn-2015","odni-pus-Arab-Latn-2011","odni-rus-Cyrl-Latn-2015","odni-srp-Cyrl-Latn-2005","odni-srp-Cyrl-Latn-2015","odni-tat-Cyrl-Latn-2015","odni-tgk-Cyrl-Latn-2015","odni-tuk-Cyrl-Latn-2015","odni-uig-Cyrl-Latn-2015","odni-ukr-Cyrl-Latn-2015","odni-urd-Arab-Latn-2015","odni-uzb-Cyrl-Latn-2015","posix","sac-zho-Hans-Latn-1979","sasm-mon-Mong-Latn-general-1978","sasm-mon-Mong-Latn-phonetic-1978","ses-ara-Arab-Latn-1930","stategeocadastre-ukr-Cyrl-Latn-1993","ua-ukr-Cyrl-Latn-1996","ua-ukr-Cyrl-Latn-2007","ua-ukr-Cyrl-Latn-2010","un-amh-Ethi-Latn-2016","un-ara-Arab-Latn-1971","un-ara-Arab-Latn-1972","un-ara-Arab-Latn-2017","un-asm-Beng-Latn-1972","un-bel-Cyrl-Latn-2007","un-ben-Beng-Latn-2016","un-bul-Cyrl-Latn-1977","un-ell-Grek-Latn-1987-phonetic","un-ell-Grek-Latn-1987-tl","un-ell-Grek-Latn-1987-ts","un-guj-Gujr-Latn-1972","un-hin-Deva-Latn-2016","un-kan-Kana-Latn-2016","un-mal-Mlym-Latn-1972","un-mar-Deva-Latn-2016","un-mkd-Cyrl-Latn-1977","un-mon-Mong-Latn-general-2013","un-mon-Mong-Latn-phonetic-2013","un-nep-Deva-Latn-1972","un-nep-Deva-Latn-2013","un-ori-Orya-Latn-1972","un-pan-Guru-Latn-1972","un-prs-Arab-Latn-1967","un-rus-Cyrl-Latn-1987","un-sin-Sinh-Latn-1972","un-srp-Cyrl-Latn-1997","un-tam-Taml-Latn-1972","un-tel-Telu-Latn-1972","un-ukr-Cyrl-Latn-1998","un-ukr-Cyrl-Latn-2012","un-urd-Arab-Latn-1972","unicode","var-Cyrl","var-amh-Ethi-Latn-eae-2003","var-ara-Arab-Arab-rababa","var-gez-Ethi-Latn-eae-2003","var-hin-Deva-Latn-hunterian-1872","var-jpn-Hrkt-Latn-hepburn-1886","var-jpn-Hrkt-Latn-hepburn-1954","var-kor","var-kor-Hang-Hang-jamo","var-kor-Hang-Latn-mr-1939","var-kor-Kore-Hang-2013","var-kor-Kore-Latn-mr-1939","var-mar-Deva-Latn-hunterian-1872","var-mon-Mong-Latn-1930","var-mon-Mong-Latn-lessing","var-mon-Mong-Latn-vpmc","var-pra-Deva-Latn-iast-1912","var-san-Deva-Latn-iast-1912","var-zho-Hani-Latn-wd-1979"];var qn=new Set(["unicode","posix","var-Cyrl","var-kor"]),Fn=new Set(["var-ara-Arab-Arab-rababa"]),$t=Rt.filter(e=>!qn.has(e)),Hn=$t.filter(e=>!Fn.has(e)),Ot=new Map;function S(){return $t}function jt(){return Hn}async function zt(e,t){let n=Ot.get(t);if(n)return n;let r=await e.fetch(new Request(`https://assets.internal/${t}.json`));if(!r.ok)throw new h(t);let a=await r.json(),s=Te(a);return Ot.set(t,s),s}var Dt;function Bt(e){if(Dt===e)return;It({strategies:[n=>zt(e,n)]}),Dt=e}async function Pt(e,t,n){return Bt(e),Ee(t,n)}function Gn(e,t){if(e===t)return 0;if(!e.length)return t.length;if(!t.length)return e.length;let n=Array.from({length:t.length+1},(r,a)=>a);for(let r=1;r<=e.length;r++){let a=[r];for(let s=1;s<=t.length;s++)a[s]=Math.min(n[s]+1,a[s-1]+1,n[s-1]+(e[r-1]===t[s-1]?0:1));n=a}return n[t.length]}async function Ut(e,t,n){Bt(e);let r=[];for(let a of jt())try{let s=await Ee(a,t);r.push({mapName:a,distance:Gn(s,n)})}catch{continue}return r.sort((a,s)=>a.distance-s.distance)}var N=class extends Error{constructor(n){super(`Input is too long (max ${n} characters)`);this.max=n;this.name="InputTooLongError"}max},I=class extends Error{constructor(n){super(`Couldn't locate ${n}`);this.systemCode=n;this.name="MapNotFoundError"}systemCode};var R={input_max_size:1e6},se=12e4;var ie="3.0.0-cloudflare.1",Ne;function G(e){Ne=e}var oe;function qt(e,t){oe=e&&t?{endpoint:e,token:t}:void 0}var Kn={"var-ara-Arab-Arab-rababa":"ara-diac-1.0"};async function Wn(e,t){if(!oe)throw new Error("ML inference unavailable \u2014 ML_ENDPOINT/ML_TOKEN not set");let n=await fetch(`${oe.endpoint}/infer`,{method:"POST",headers:{"content-type":"application/json","x-api-key":oe.token},body:JSON.stringify({model:e,input:t}),signal:AbortSignal.timeout(se)}).catch(()=>null);if(!n||!n.ok)throw new Error("ML inference upstream failed");let r=await n.json().catch(()=>null);if(!r||typeof r.output!="string")throw new Error("ML inference returned no output");return r.output}function Ft(){if(!Ne)throw new Error("ASSETS binding missing \u2014 see README deployment notes");return Ne}async function Ht(){return JSON.stringify({version:ie,engine:"interscript-ts@native-interpreter"})}function Gt(){return[...S()]}async function ce(e,t){if(t.length>R.input_max_size)throw new N(R.input_max_size);let n=Kn[e];if(n)return Wn(n,t);try{return await Pt(Ft(),e,t)}catch(r){throw r instanceof h?new I(e):r}}async function le(e,t){return Ut(Ft(),e,t)}var Kt={version:1,models:[{id:"khm-latn-1.0",task:"translit",scripts:["Khmr","Latn"],precision:"fp32",filename:"khm-latn-1.0-fp32.zip",url:"https://github.com/interscript/interscript-ml/releases/download/khm-latn-1.0/khm-latn-1.0-fp32.zip",parts:null,sha256:"55993d473a2ed9489058779cad7e115db05e4020085b71616468cfae4f2f65cb",size:1418009977,metrics:[{name:"cer",value:27.42,source:"secryst/docs/RESULTS.md#khmer-transliteration-2026-08-14"},{name:"em",value:59.66,source:"secryst/docs/RESULTS.md#khmer-transliteration-2026-08-14"}],parity:{samples:895,cer_delta:0},license:"BSD-3-Clause"},{id:"urd-g2p-1.0",task:"g2p",scripts:["Arab","IPA"],precision:"fp32",filename:"urd-g2p-1.0-fp32.zip",url:"https://github.com/interscript/interscript-ml/releases/download/urd-g2p-1.0/urd-g2p-1.0-fp32.zip",parts:null,sha256:"9f0a248c7116aa7f6b9ac125fb9684a3556f3b8ce8b64567c05a5e7e7a018ebf",size:1418039605,metrics:[{name:"cer",value:14.77,source:"rababa-urdu/docs/RESULTS.md#g2p-urdu-text--ipa"},{name:"em",value:33.6,source:"rababa-urdu/docs/RESULTS.md#g2p-urdu-text--ipa"}],parity:{samples:12699,cer_delta:0},license:"BSD-3-Clause"},{id:"urd-diac-1.0",task:"diacritization",scripts:["Arab","Arab"],precision:"fp32",filename:"urd-diac-1.0-fp32.zip",url:"https://github.com/interscript/interscript-ml/releases/download/urd-diac-1.0/urd-diac-1.0-fp32.zip",parts:null,sha256:"c299ea44a4da4851a52283f8e42d2fb6f8c7a9c443ba7eb0270f97372e10b8ea",size:1417851421,metrics:[{name:"cer",value:3.74,source:"rababa-urdu/docs/RESULTS.md#diacritization-urdu-text--text--haraqat"}],parity:{samples:11940,cer_delta:0},license:"BSD-3-Clause"},{id:"heb-diac-1.0",task:"diacritization",scripts:["Hebr","Hebr"],precision:"fp32",filename:"heb-diac-1.0-fp32.zip",url:null,parts:[{url:"https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.0/heb-diac-1.0-fp32.zip.part-00",sha256:"5497f70cc3c96829e65f1eb0cc401c2d1ffeb4fa909acd4def824c2e019cbc37",size:15e8},{url:"https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.0/heb-diac-1.0-fp32.zip.part-01",sha256:"a7d2011ab4f9326a86e234cc49cb50daf82949e51efbf03a21d5796c46465e9d",size:1281139753}],sha256:"b32fa239e0c56708b6004942de4b9e6e9f265e7cc3828f41d560e96386e20dd8",size:2781139753,metrics:[{name:"der_greedy",value:29,source:"rababa/docs/RESULTS.md#hebrew-diacritization"},{name:"der_beam4",value:17.46,source:"rababa/docs/RESULTS.md#hebrew-diacritization"}],parity:{samples:600,cer_delta:0},license:"BSD-3-Clause"},{id:"tha-g2p-base-1.0",task:"g2p",scripts:["Thai","IPA"],precision:"fp32",filename:"tha-g2p-base-1.0-fp32.zip",url:null,parts:[{url:"https://github.com/interscript/interscript-ml/releases/download/tha-g2p-base-1.0/tha-g2p-base-1.0-fp32.zip.part-00",sha256:"c4525414e5dec91a54d055ca9f1acd51c198f81fbfc55977aa82c1fb038d58d7",size:15e8},{url:"https://github.com/interscript/interscript-ml/releases/download/tha-g2p-base-1.0/tha-g2p-base-1.0-fp32.zip.part-01",sha256:"f5d11fbd75f92e8b5471add867418e2dd4f49a5e258b9ded2f3b5ffa630abe24",size:1281174343}],sha256:"f341a5868867a9847d3f897d1fcc4d1d63b9a59b8913871bcf4ecab48f4fa895",size:2781174343,metrics:[{name:"per_teacher",value:4.43,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-base-1.0"},{name:"per_student",value:9.19,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-base-1.0"}],parity:{samples:1219,cer_delta:0},license:"BSD-3-Clause"},{id:"tha-g2p-small-1.0",task:"g2p",scripts:["Thai","IPA"],precision:"int8",filename:"tha-g2p-small-1.0-int8.zip",url:"https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int8.zip",parts:null,sha256:"f2cfa93a42d98aabf08fdc82dfc6bd1574e21993f36558aa581fbe29e0588a94",size:257468517,metrics:[{name:"per_teacher",value:4.43,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0"},{name:"per_student",value:12.06,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0"}],parity:{samples:1219,cer_delta:.0803},license:null},{id:"tha-g2p-small-1.0-int4",task:"g2p",scripts:["Thai","IPA"],precision:"int4",filename:"tha-g2p-small-1.0-int4.zip",url:"https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int4.zip",parts:null,sha256:"e5d12a3d65c6ac39fa08f52c975c99ff7a51c3e7b7aca7fbb461d2de2345e4cb",size:201958073,metrics:[{name:"per_teacher",value:4.43,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0"},{name:"per_student",value:12.06,source:"interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0"}],parity:{samples:600,cer_delta:.0734},license:"BSD-3-Clause"},{id:"heb-diac-small-1.0",task:"diacritization",scripts:["Hebr","Hebr"],precision:"fp32",filename:"heb-diac-small-1.0-fp32.zip",url:"https://github.com/interscript/interscript-ml/releases/download/heb-diac-small-1.0/heb-diac-small-1.0-fp32.zip",parts:null,sha256:"905c53873d5a62bbe6252c6ec0ecef5f37e96e78cb01e8cd99b6b24c4d4d74ad",size:1418663344,metrics:[{name:"der_teacher_greedy",value:24.79,source:"interscript/interscript-ml docs/RESULTS.md#heb-diac-small-1.0"},{name:"der_student_greedy",value:30.37,source:"interscript/interscript-ml docs/RESULTS.md#heb-diac-small-1.0"}],parity:{samples:1864,cer_delta:0},license:null},{id:"fas-g2p-1.0",task:"g2p",scripts:["Arab","Latn"],precision:"fp32",filename:"fas-g2p-1.0-fp32.zip",url:null,parts:[{url:"https://github.com/interscript/interscript-ml/releases/download/fas-g2p-1.0/fas-g2p-1.0-fp32.zip.part-00",sha256:"6c475e53f3c7ef3edcef5a24d2d81f51d13ddf4c417de98440943c9a32b03e55",size:15e8},{url:"https://github.com/interscript/interscript-ml/releases/download/fas-g2p-1.0/fas-g2p-1.0-fp32.zip.part-01",sha256:"c5656c649412f41e201c567e002514d31390b636d4650d9dcb6dfed1973fb3d5",size:1280254270}],sha256:"b53fd69196127efcc596935d24e135b3c897006872c1646c674e70f3c0d9a0e3",size:2780254270,metrics:[{name:"cer",value:1.6,source:"interscript/interscript-ml docs/RESULTS.md#fas-g2p-1.0"},{name:"sb_homograph_ezafe_norm",value:77.34,source:"interscript/interscript-ml docs/RESULTS.md#fas-g2p-1.0"}],parity:{samples:1e3,cer_delta:0},license:"BSD-3-Clause"},{id:"heb-diac-1.1",task:"diacritization",scripts:["Hebr","Hebr"],precision:"fp32",filename:"heb.zip",url:null,parts:[{url:"https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-00",sha256:"8dac0d62e9b0ac4b137412eaf3a542953f11575f12f66f76cb93d3f5d788fc1b",size:15e8},{url:"https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-01",sha256:"230c5ab731ea5f001f802d60b9e9a328c10b43bc311a19ef1974f114384313ed",size:1280987905}],sha256:"f0022dde8d06e46e8f08cf0b2f7bbb887a05ed686b90f1d5aa82ca3ef690a0b0",size:2780987905,metrics:[{name:"der_greedy",value:16.44,source:"rababa/docs/RESULTS.md#hebrew-diacritization"},{name:"der_beam4",value:16.43,source:"rababa/docs/RESULTS.md#hebrew-diacritization"}],parity:{samples:500,cer_delta:0},license:"BSD-3-Clause"}]};var Ie=Kt;function pe(){return Ie.models}function Re(e){return Ie.models.find(t=>t.id===e)}var Wt=Ie.version;var Vt={openapi:"3.1.0",info:{title:"Interscript API",version:"1.0.0",description:"Transliteration and neural text processing. Maps run in-edge on the interscript-ts native interpreter (289 systems); neural models (diacritization, grapheme-to-phoneme) run on Interscript's inference service. GraphQL remains available at POST /graphql.",license:{name:"BSD-3-Clause"}},servers:[{url:"https://api.interscript.org"}],tags:[{name:"service"},{name:"maps"},{name:"transliteration"},{name:"models"},{name:"inference"}],paths:{"/":{get:{tags:["service"],summary:"Service index",responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/info":{get:{tags:["service"],summary:"Version and capability summary",responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/maps":{get:{tags:["maps"],summary:"Every bundled transliteration system code",responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/maps/{code}":{get:{tags:["maps"],summary:"One system's compiled map (JSON IR)",parameters:[{name:"code",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{$ref:"#/components/responses/Ok"},404:{$ref:"#/components/responses/NotFound"}}}},"/v1/transliterate":{post:{tags:["transliteration"],summary:"Transliterate text with a system",requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/TransliterateRequest"},examples:{gek:{value:{system:"ungegn-kor-Kore-Latn-1939",input:"\uD3C9\uC591"}}}}}},responses:{200:{description:"Transliterated output",content:{"application/json":{schema:{$ref:"#/components/schemas/TransliterateResponse"}}}},404:{$ref:"#/components/responses/NotFound"},413:{$ref:"#/components/responses/Error"}}}},"/v1/detect":{post:{tags:["transliteration"],summary:"Rank systems by how well they map input to output",requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/DetectRequest"}}}},responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/models":{get:{tags:["models"],summary:"The neural model index (IMF v1)",responses:{200:{$ref:"#/components/responses/Ok"}}}},"/v1/models/{id}":{get:{tags:["models"],summary:"One model's full entry (metrics, parity, download)",parameters:[{name:"id",in:"path",required:!0,schema:{type:"string"}}],responses:{200:{$ref:"#/components/responses/Ok"},404:{$ref:"#/components/responses/NotFound"}}}},"/v1/infer":{post:{tags:["inference"],summary:"Run a neural model (diacritization or G2P)",description:"Proxy to Interscript's inference service. Only models whose task is diacritization or g2p are served; see GET /v1/models for the catalog.",requestBody:{required:!0,content:{"application/json":{schema:{$ref:"#/components/schemas/InferRequest"},examples:{hebrew:{value:{model:"heb-diac-1.0",input:"\u05E9\u05DC\u05D5\u05DD \u05E2\u05DC\u05D9\u05DB\u05DD"},summary:"Hebrew nikud restoration"},urdu:{value:{model:"urd-g2p-1.0",input:"\u0627\u0631\u062F\u0648"},summary:"Urdu grapheme-to-phoneme"}}}}},responses:{200:{description:"Model output",content:{"application/json":{schema:{$ref:"#/components/schemas/InferResponse"}}}},404:{$ref:"#/components/responses/NotFound"},502:{$ref:"#/components/responses/Error"},503:{$ref:"#/components/responses/Error"}}}}},components:{schemas:{Error:{type:"object",properties:{error:{type:"object",properties:{code:{type:"string"},message:{type:"string"}}}}},TransliterateRequest:{type:"object",required:["system","input"],properties:{system:{type:"string",description:"A system code from GET /v1/maps",examples:["ungegn-kor-Kore-Latn-1939"]},input:{type:"string",maxLength:1e6}}},TransliterateResponse:{type:"object",properties:{system:{type:"string"},input:{type:"string"},output:{type:"string"}}},DetectRequest:{type:"object",required:["input","output"],properties:{input:{type:"string"},output:{type:"string"}}},InferRequest:{type:"object",required:["model","input"],properties:{model:{type:"string",description:"A model id from GET /v1/models",examples:["heb-diac-1.0"]},input:{type:"string",maxLength:4e3}}},InferResponse:{type:"object",properties:{model:{type:"string"},task:{type:"string",enum:["diacritization","g2p"]},input:{type:"string"},output:{type:"string"}}}},responses:{Ok:{description:"Success",content:{"application/json":{schema:{type:"object"}}}},NotFound:{description:"Unknown system or model",content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}}},Error:{description:"Error",content:{"application/json":{schema:{$ref:"#/components/schemas/Error"}}}}}}};function f(e,t,n){return Response.json({error:{code:t,message:n}},{status:e})}var b=new Jn;b.get("/",e=>e.json({name:"Interscript API",version:"v1",openapi:"/openapi.json",endpoints:["GET /v1/info","GET /v1/maps","GET /v1/maps/{code}","POST /v1/transliterate","POST /v1/detect","GET /v1/models","GET /v1/models/{id}","POST /v1/infer","POST /graphql"]}));b.get("/openapi.json",e=>e.json(Vt));b.get("/v1/info",e=>e.json({api_version:"1.0.0",engine_version:ie,engine:"interscript-ts@native-interpreter",maps:S().length,models:pe().length,models_index_version:Wt,limits:R}));b.get("/v1/maps",e=>e.json({count:S().length,maps:S()}));b.get("/v1/maps/:code",async e=>{let t=e.env?.ASSETS;if(!t)return f(503,"assets_missing","ASSETS binding not configured");let n=e.req.param("code");if(!S().includes(n))return f(404,"map_not_found",`Couldn't locate ${n}`);let r=await t.fetch(`https://assets.internal/${n}.json`);return r.ok?new Response(r.body,{headers:{"content-type":"application/json; charset=utf-8"}}):f(404,"map_not_found",`Couldn't locate ${n}`)});b.post("/v1/transliterate",async e=>{let t=e.env?.ASSETS;if(!t)return f(503,"assets_missing","ASSETS binding not configured");G(t);let n=await e.req.json().catch(()=>null);if(!n||typeof n!="object")return f(400,"bad_request","body must be JSON {system, input}");let{system:r,input:a}=n;if(typeof r!="string"||typeof a!="string")return f(400,"bad_request","system and input must be strings");try{let s=await ce(r,a);return e.json({system:r,input:a,output:s})}catch(s){return s instanceof N?f(413,"input_too_long",s.message):s instanceof I?f(404,"map_not_found",s.message):f(500,"engine_error",String(s))}});b.post("/v1/detect",async e=>{let t=e.env?.ASSETS;if(!t)return f(503,"assets_missing","ASSETS binding not configured");G(t);let n=await e.req.json().catch(()=>null),{input:r,output:a}=n??{};if(typeof r!="string"||typeof a!="string")return f(400,"bad_request","input and output must be strings");let s=await le(r,a);return e.json({count:s.length,results:s})});b.get("/v1/models",e=>e.json({count:pe().length,models:pe()}));b.get("/v1/models/:id",e=>{let t=Re(e.req.param("id"));return t?e.json(t):f(404,"model_not_found",`Couldn't locate ${e.req.param("id")}`)});b.post("/v1/infer",async e=>{let t=await e.req.json().catch(()=>null),{model:n,input:r}=t??{};if(typeof n!="string"||typeof r!="string")return f(400,"bad_request","body must be JSON {model, input}");if(!Re(n))return f(404,"model_not_found",`Couldn't locate ${n}`);let{ML_ENDPOINT:a,ML_TOKEN:s}=e.env??{};if(!a||!s)return f(503,"inference_unconfigured","ML_ENDPOINT/ML_TOKEN are not set on this deployment");let o=await fetch(`${a}/infer`,{method:"POST",headers:{"content-type":"application/json","x-api-key":s},body:JSON.stringify({model:n,input:r}),signal:AbortSignal.timeout(se)}).catch(()=>null);if(!o||!o.ok){let i=o?await o.text().catch(()=>""):"upstream unreachable";return f(502,"inference_upstream",i.slice(0,500))}let c=await o.json();return e.json({model:n,task:c.task,input:r,output:c.output})});var er=Qn({schema:Yn({typeDefs:de,resolvers:{Query:{info:()=>Ht(),systemCodes:()=>Gt(),transliterate:(e,t)=>ce(t.systemCode,t.input),detect:(e,t)=>le(t.input,t.output)}}}),graphqlEndpoint:"*",landingPage:!1,maskedErrors:!1}),K=new Xn;K.use("*",Zn({origin:"*",allowMethods:["GET","POST","OPTIONS"]}));K.route("/",b);K.all("*",async e=>{let t=e.env;t?.ASSETS&&G(t.ASSETS),qt(t?.ML_ENDPOINT,t?.ML_TOKEN);let n;try{n=e.executionCtx}catch{n=void 0}let r=e.req.raw,a=(r.headers.get("content-type")??"").toLowerCase();if(r.method==="POST"&&!a.includes("application/json")){let s=await r.text(),o=!1;try{JSON.parse(s),o=!0}catch{}s.trim()&&!o&&(r=new Request(r.url,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:s})}))}return er.fetch(r,e.env,n)});var tr=K;export{ie as API_VERSION,R as LIMITS,K as app,tr as default,de as typeDefs}; diff --git a/dist/src/limits.d.ts b/dist/src/limits.d.ts index 456de47..cf9b57e 100644 --- a/dist/src/limits.d.ts +++ b/dist/src/limits.d.ts @@ -2,3 +2,4 @@ export declare const LIMITS: { readonly input_max_size: 1000000; }; +export declare const INFER_TIMEOUT_MS = 120000; diff --git a/dist/src/limits.js b/dist/src/limits.js index ba2869d..0cc4eab 100644 --- a/dist/src/limits.js +++ b/dist/src/limits.js @@ -2,3 +2,4 @@ export const LIMITS = { input_max_size: 1_000_000, }; +export const INFER_TIMEOUT_MS = 120_000; diff --git a/dist/src/models.d.ts b/dist/src/models.d.ts new file mode 100644 index 0000000..e837f86 --- /dev/null +++ b/dist/src/models.d.ts @@ -0,0 +1,25 @@ +export interface ModelMetric { + name: string; + value: number; + source: string; +} +export interface ModelEntry { + id: string; + task: "g2p" | "diacritization" | "translit"; + scripts: string[]; + precision: string; + filename: string | null; + url: string | null; + parts: unknown; + sha256: string | null; + size: number | null; + metrics: ModelMetric[]; + parity: { + samples: number; + cer_delta: number; + } | null; + license: string; +} +export declare function listModels(): ModelEntry[]; +export declare function getModel(id: string): ModelEntry | undefined; +export declare const MODELS_INDEX_VERSION: number; diff --git a/dist/src/models.js b/dist/src/models.js new file mode 100644 index 0000000..a4c1791 --- /dev/null +++ b/dist/src/models.js @@ -0,0 +1,14 @@ +/** + * The neural model index: a generated projection of interscript-ml's + * models.yaml (the IMF v1 contract). Regenerate with + * `npm run gen:models` from a checkout of interscript/interscript-ml. + */ +import index from "./generated/models.json"; +const data = index; +export function listModels() { + return data.models; +} +export function getModel(id) { + return data.models.find((m) => m.id === id); +} +export const MODELS_INDEX_VERSION = data.version; diff --git a/dist/src/openapi.d.ts b/dist/src/openapi.d.ts new file mode 100644 index 0000000..fce5512 --- /dev/null +++ b/dist/src/openapi.d.ts @@ -0,0 +1,362 @@ +/** + * The OpenAPI 3.1 document for REST v1 — served at /openapi.json. + * Hand-maintained to mirror src/rest.ts exactly. + */ +export declare const OPENAPI: { + readonly openapi: "3.1.0"; + readonly info: { + readonly title: "Interscript API"; + readonly version: "1.0.0"; + readonly description: "Transliteration and neural text processing. Maps run in-edge on the interscript-ts native interpreter (289 systems); neural models (diacritization, grapheme-to-phoneme) run on Interscript's inference service. GraphQL remains available at POST /graphql."; + readonly license: { + readonly name: "BSD-3-Clause"; + }; + }; + readonly servers: readonly [{ + readonly url: "https://api.interscript.org"; + }]; + readonly tags: readonly [{ + readonly name: "service"; + }, { + readonly name: "maps"; + }, { + readonly name: "transliteration"; + }, { + readonly name: "models"; + }, { + readonly name: "inference"; + }]; + readonly paths: { + readonly "/": { + readonly get: { + readonly tags: readonly ["service"]; + readonly summary: "Service index"; + readonly responses: { + readonly "200": { + readonly $ref: "#/components/responses/Ok"; + }; + }; + }; + }; + readonly "/v1/info": { + readonly get: { + readonly tags: readonly ["service"]; + readonly summary: "Version and capability summary"; + readonly responses: { + readonly "200": { + readonly $ref: "#/components/responses/Ok"; + }; + }; + }; + }; + readonly "/v1/maps": { + readonly get: { + readonly tags: readonly ["maps"]; + readonly summary: "Every bundled transliteration system code"; + readonly responses: { + readonly "200": { + readonly $ref: "#/components/responses/Ok"; + }; + }; + }; + }; + readonly "/v1/maps/{code}": { + readonly get: { + readonly tags: readonly ["maps"]; + readonly summary: "One system's compiled map (JSON IR)"; + readonly parameters: readonly [{ + readonly name: "code"; + readonly in: "path"; + readonly required: true; + readonly schema: { + readonly type: "string"; + }; + }]; + readonly responses: { + readonly "200": { + readonly $ref: "#/components/responses/Ok"; + }; + readonly "404": { + readonly $ref: "#/components/responses/NotFound"; + }; + }; + }; + }; + readonly "/v1/transliterate": { + readonly post: { + readonly tags: readonly ["transliteration"]; + readonly summary: "Transliterate text with a system"; + readonly requestBody: { + readonly required: true; + readonly content: { + readonly "application/json": { + readonly schema: { + readonly $ref: "#/components/schemas/TransliterateRequest"; + }; + readonly examples: { + readonly gek: { + readonly value: { + readonly system: "ungegn-kor-Kore-Latn-1939"; + readonly input: "평양"; + }; + }; + }; + }; + }; + }; + readonly responses: { + readonly "200": { + readonly description: "Transliterated output"; + readonly content: { + readonly "application/json": { + readonly schema: { + readonly $ref: "#/components/schemas/TransliterateResponse"; + }; + }; + }; + }; + readonly "404": { + readonly $ref: "#/components/responses/NotFound"; + }; + readonly "413": { + readonly $ref: "#/components/responses/Error"; + }; + }; + }; + }; + readonly "/v1/detect": { + readonly post: { + readonly tags: readonly ["transliteration"]; + readonly summary: "Rank systems by how well they map input to output"; + readonly requestBody: { + readonly required: true; + readonly content: { + readonly "application/json": { + readonly schema: { + readonly $ref: "#/components/schemas/DetectRequest"; + }; + }; + }; + }; + readonly responses: { + readonly "200": { + readonly $ref: "#/components/responses/Ok"; + }; + }; + }; + }; + readonly "/v1/models": { + readonly get: { + readonly tags: readonly ["models"]; + readonly summary: "The neural model index (IMF v1)"; + readonly responses: { + readonly "200": { + readonly $ref: "#/components/responses/Ok"; + }; + }; + }; + }; + readonly "/v1/models/{id}": { + readonly get: { + readonly tags: readonly ["models"]; + readonly summary: "One model's full entry (metrics, parity, download)"; + readonly parameters: readonly [{ + readonly name: "id"; + readonly in: "path"; + readonly required: true; + readonly schema: { + readonly type: "string"; + }; + }]; + readonly responses: { + readonly "200": { + readonly $ref: "#/components/responses/Ok"; + }; + readonly "404": { + readonly $ref: "#/components/responses/NotFound"; + }; + }; + }; + }; + readonly "/v1/infer": { + readonly post: { + readonly tags: readonly ["inference"]; + readonly summary: "Run a neural model (diacritization or G2P)"; + readonly description: "Proxy to Interscript's inference service. Only models whose task is diacritization or g2p are served; see GET /v1/models for the catalog."; + readonly requestBody: { + readonly required: true; + readonly content: { + readonly "application/json": { + readonly schema: { + readonly $ref: "#/components/schemas/InferRequest"; + }; + readonly examples: { + readonly hebrew: { + readonly value: { + readonly model: "heb-diac-1.0"; + readonly input: "שלום עליכם"; + }; + readonly summary: "Hebrew nikud restoration"; + }; + readonly urdu: { + readonly value: { + readonly model: "urd-g2p-1.0"; + readonly input: "اردو"; + }; + readonly summary: "Urdu grapheme-to-phoneme"; + }; + }; + }; + }; + }; + readonly responses: { + readonly "200": { + readonly description: "Model output"; + readonly content: { + readonly "application/json": { + readonly schema: { + readonly $ref: "#/components/schemas/InferResponse"; + }; + }; + }; + }; + readonly "404": { + readonly $ref: "#/components/responses/NotFound"; + }; + readonly "502": { + readonly $ref: "#/components/responses/Error"; + }; + readonly "503": { + readonly $ref: "#/components/responses/Error"; + }; + }; + }; + }; + }; + readonly components: { + readonly schemas: { + readonly Error: { + readonly type: "object"; + readonly properties: { + readonly error: { + readonly type: "object"; + readonly properties: { + readonly code: { + readonly type: "string"; + }; + readonly message: { + readonly type: "string"; + }; + }; + }; + }; + }; + readonly TransliterateRequest: { + readonly type: "object"; + readonly required: readonly ["system", "input"]; + readonly properties: { + readonly system: { + readonly type: "string"; + readonly description: "A system code from GET /v1/maps"; + readonly examples: readonly ["ungegn-kor-Kore-Latn-1939"]; + }; + readonly input: { + readonly type: "string"; + readonly maxLength: 1000000; + }; + }; + }; + readonly TransliterateResponse: { + readonly type: "object"; + readonly properties: { + readonly system: { + readonly type: "string"; + }; + readonly input: { + readonly type: "string"; + }; + readonly output: { + readonly type: "string"; + }; + }; + }; + readonly DetectRequest: { + readonly type: "object"; + readonly required: readonly ["input", "output"]; + readonly properties: { + readonly input: { + readonly type: "string"; + }; + readonly output: { + readonly type: "string"; + }; + }; + }; + readonly InferRequest: { + readonly type: "object"; + readonly required: readonly ["model", "input"]; + readonly properties: { + readonly model: { + readonly type: "string"; + readonly description: "A model id from GET /v1/models"; + readonly examples: readonly ["heb-diac-1.0"]; + }; + readonly input: { + readonly type: "string"; + readonly maxLength: 4000; + }; + }; + }; + readonly InferResponse: { + readonly type: "object"; + readonly properties: { + readonly model: { + readonly type: "string"; + }; + readonly task: { + readonly type: "string"; + readonly enum: readonly ["diacritization", "g2p"]; + }; + readonly input: { + readonly type: "string"; + }; + readonly output: { + readonly type: "string"; + }; + }; + }; + }; + readonly responses: { + readonly Ok: { + readonly description: "Success"; + readonly content: { + readonly "application/json": { + readonly schema: { + readonly type: "object"; + }; + }; + }; + }; + readonly NotFound: { + readonly description: "Unknown system or model"; + readonly content: { + readonly "application/json": { + readonly schema: { + readonly $ref: "#/components/schemas/Error"; + }; + }; + }; + }; + readonly Error: { + readonly description: "Error"; + readonly content: { + readonly "application/json": { + readonly schema: { + readonly $ref: "#/components/schemas/Error"; + }; + }; + }; + }; + }; + }; +}; diff --git a/dist/src/openapi.js b/dist/src/openapi.js new file mode 100644 index 0000000..3b157b9 --- /dev/null +++ b/dist/src/openapi.js @@ -0,0 +1,238 @@ +/** + * The OpenAPI 3.1 document for REST v1 — served at /openapi.json. + * Hand-maintained to mirror src/rest.ts exactly. + */ +export const OPENAPI = { + openapi: "3.1.0", + info: { + title: "Interscript API", + version: "1.0.0", + description: "Transliteration and neural text processing. Maps run in-edge on the interscript-ts native interpreter (289 systems); neural models (diacritization, grapheme-to-phoneme) run on Interscript's inference service. GraphQL remains available at POST /graphql.", + license: { name: "BSD-3-Clause" }, + }, + servers: [{ url: "https://api.interscript.org" }], + tags: [ + { name: "service" }, + { name: "maps" }, + { name: "transliteration" }, + { name: "models" }, + { name: "inference" }, + ], + paths: { + "/": { + get: { + tags: ["service"], + summary: "Service index", + responses: { "200": { $ref: "#/components/responses/Ok" } }, + }, + }, + "/v1/info": { + get: { + tags: ["service"], + summary: "Version and capability summary", + responses: { "200": { $ref: "#/components/responses/Ok" } }, + }, + }, + "/v1/maps": { + get: { + tags: ["maps"], + summary: "Every bundled transliteration system code", + responses: { "200": { $ref: "#/components/responses/Ok" } }, + }, + }, + "/v1/maps/{code}": { + get: { + tags: ["maps"], + summary: "One system's compiled map (JSON IR)", + parameters: [ + { name: "code", in: "path", required: true, schema: { type: "string" } }, + ], + responses: { + "200": { $ref: "#/components/responses/Ok" }, + "404": { $ref: "#/components/responses/NotFound" }, + }, + }, + }, + "/v1/transliterate": { + post: { + tags: ["transliteration"], + summary: "Transliterate text with a system", + requestBody: { + required: true, + content: { + "application/json": { + schema: { $ref: "#/components/schemas/TransliterateRequest" }, + examples: { + gek: { + value: { system: "ungegn-kor-Kore-Latn-1939", input: "평양" }, + }, + }, + }, + }, + }, + responses: { + "200": { + description: "Transliterated output", + content: { + "application/json": { + schema: { $ref: "#/components/schemas/TransliterateResponse" }, + }, + }, + }, + "404": { $ref: "#/components/responses/NotFound" }, + "413": { $ref: "#/components/responses/Error" }, + }, + }, + }, + "/v1/detect": { + post: { + tags: ["transliteration"], + summary: "Rank systems by how well they map input to output", + requestBody: { + required: true, + content: { + "application/json": { + schema: { $ref: "#/components/schemas/DetectRequest" }, + }, + }, + }, + responses: { "200": { $ref: "#/components/responses/Ok" } }, + }, + }, + "/v1/models": { + get: { + tags: ["models"], + summary: "The neural model index (IMF v1)", + responses: { "200": { $ref: "#/components/responses/Ok" } }, + }, + }, + "/v1/models/{id}": { + get: { + tags: ["models"], + summary: "One model's full entry (metrics, parity, download)", + parameters: [{ name: "id", in: "path", required: true, schema: { type: "string" } }], + responses: { + "200": { $ref: "#/components/responses/Ok" }, + "404": { $ref: "#/components/responses/NotFound" }, + }, + }, + }, + "/v1/infer": { + post: { + tags: ["inference"], + summary: "Run a neural model (diacritization or G2P)", + description: "Proxy to Interscript's inference service. Only models whose task is diacritization or g2p are served; see GET /v1/models for the catalog.", + requestBody: { + required: true, + content: { + "application/json": { + schema: { $ref: "#/components/schemas/InferRequest" }, + examples: { + hebrew: { + value: { model: "heb-diac-1.0", input: "שלום עליכם" }, + summary: "Hebrew nikud restoration", + }, + urdu: { + value: { model: "urd-g2p-1.0", input: "اردو" }, + summary: "Urdu grapheme-to-phoneme", + }, + }, + }, + }, + }, + responses: { + "200": { + description: "Model output", + content: { + "application/json": { + schema: { $ref: "#/components/schemas/InferResponse" }, + }, + }, + }, + "404": { $ref: "#/components/responses/NotFound" }, + "502": { $ref: "#/components/responses/Error" }, + "503": { $ref: "#/components/responses/Error" }, + }, + }, + }, + }, + components: { + schemas: { + Error: { + type: "object", + properties: { + error: { + type: "object", + properties: { + code: { type: "string" }, + message: { type: "string" }, + }, + }, + }, + }, + TransliterateRequest: { + type: "object", + required: ["system", "input"], + properties: { + system: { + type: "string", + description: "A system code from GET /v1/maps", + examples: ["ungegn-kor-Kore-Latn-1939"], + }, + input: { type: "string", maxLength: 1000000 }, + }, + }, + TransliterateResponse: { + type: "object", + properties: { + system: { type: "string" }, + input: { type: "string" }, + output: { type: "string" }, + }, + }, + DetectRequest: { + type: "object", + required: ["input", "output"], + properties: { + input: { type: "string" }, + output: { type: "string" }, + }, + }, + InferRequest: { + type: "object", + required: ["model", "input"], + properties: { + model: { + type: "string", + description: "A model id from GET /v1/models", + examples: ["heb-diac-1.0"], + }, + input: { type: "string", maxLength: 4000 }, + }, + }, + InferResponse: { + type: "object", + properties: { + model: { type: "string" }, + task: { type: "string", enum: ["diacritization", "g2p"] }, + input: { type: "string" }, + output: { type: "string" }, + }, + }, + }, + responses: { + Ok: { + description: "Success", + content: { "application/json": { schema: { type: "object" } } }, + }, + NotFound: { + description: "Unknown system or model", + content: { "application/json": { schema: { $ref: "#/components/schemas/Error" } } }, + }, + Error: { + description: "Error", + content: { "application/json": { schema: { $ref: "#/components/schemas/Error" } } }, + }, + }, + }, +}; diff --git a/dist/src/resolvers.d.ts b/dist/src/resolvers.d.ts index 55bfba7..acfb1e4 100644 --- a/dist/src/resolvers.d.ts +++ b/dist/src/resolvers.d.ts @@ -4,8 +4,11 @@ export interface AssetsBinding { } export interface Env { ASSETS?: AssetsBinding; + ML_ENDPOINT?: string; + ML_TOKEN?: string; } export declare function setAssets(binding: AssetsBinding): void; +export declare function setMl(endpoint: string | undefined, token: string | undefined): void; export declare function requireAssets(): AssetsBinding; export declare function info(): Promise; export declare function systemCodesResolver(): string[]; diff --git a/dist/src/resolvers.js b/dist/src/resolvers.js index 6fea0ae..0aa4171 100644 --- a/dist/src/resolvers.js +++ b/dist/src/resolvers.js @@ -5,7 +5,7 @@ import { MapNotFoundError as EngineMapNotFoundError } from "interscript-ts"; import { detect, transliterate } from "./engine.js"; import { InputTooLongError, MapNotFoundError } from "./errors.js"; -import { LIMITS } from "./limits.js"; +import { INFER_TIMEOUT_MS, LIMITS } from "./limits.js"; import { bundledSystemCodes } from "./engine.js"; export const API_VERSION = "3.0.0-cloudflare.1"; // The ASSETS binding is constant for an isolate's lifetime; the Hono @@ -15,6 +15,35 @@ let assets; export function setAssets(binding) { assets = binding; } +let ml; +export function setMl(endpoint, token) { + ml = endpoint && token ? { endpoint, token } : undefined; +} +// Legacy wire compatibility: the old Ruby API proxied rababa system +// codes to the ML service; the interscript.org demo still calls this +// through GraphQL and REST transliterate. +const RABABA_MODELS = { + "var-ara-Arab-Arab-rababa": "ara-diac-1.0", +}; +async function infer(model, input) { + if (!ml) { + throw new Error("ML inference unavailable — ML_ENDPOINT/ML_TOKEN not set"); + } + const res = await fetch(`${ml.endpoint}/infer`, { + method: "POST", + headers: { "content-type": "application/json", "x-api-key": ml.token }, + body: JSON.stringify({ model, input }), + signal: AbortSignal.timeout(INFER_TIMEOUT_MS), + }).catch(() => null); + if (!res || !res.ok) { + throw new Error("ML inference upstream failed"); + } + const out = (await res.json().catch(() => null)); + if (!out || typeof out.output !== "string") { + throw new Error("ML inference returned no output"); + } + return out.output; +} export function requireAssets() { if (!assets) { throw new Error("ASSETS binding missing — see README deployment notes"); @@ -34,6 +63,10 @@ export async function transliterateResolver(systemCode, input) { if (input.length > LIMITS.input_max_size) { throw new InputTooLongError(LIMITS.input_max_size); } + const rababaModel = RABABA_MODELS[systemCode]; + if (rababaModel) { + return infer(rababaModel, input); + } try { return await transliterate(requireAssets(), systemCode, input); } diff --git a/dist/src/rest.d.ts b/dist/src/rest.d.ts new file mode 100644 index 0000000..9c0b7e2 --- /dev/null +++ b/dist/src/rest.d.ts @@ -0,0 +1,22 @@ +/** + * REST v1 — the OpenAPI-first interface to Interscript. + * + * GET /openapi.json the OpenAPI 3.1 document + * GET / service index (JSON) + * GET /v1/info version + capability summary + * GET /v1/maps every bundled transliteration system code + * GET /v1/maps/:code one system's compiled map (JSON IR) + * POST /v1/transliterate {system, input} -> {output} + * POST /v1/detect {input, output} -> ranked systems + * GET /v1/models the neural model index (IMF v1) + * GET /v1/models/:id one model's full entry + * POST /v1/infer {model, input} -> {output} (Modal proxy) + * + * GraphQL remains at POST /graphql (and any other path, for + * compatibility with the Ruby API's {proxy+} behavior). + */ +import { Hono } from "hono"; +import { type Env } from "./resolvers.js"; +export declare const rest: Hono<{ + Bindings: Env; +}, import("hono/types").BlankSchema, "/">; diff --git a/dist/src/rest.js b/dist/src/rest.js new file mode 100644 index 0000000..98c32e6 --- /dev/null +++ b/dist/src/rest.js @@ -0,0 +1,151 @@ +/** + * REST v1 — the OpenAPI-first interface to Interscript. + * + * GET /openapi.json the OpenAPI 3.1 document + * GET / service index (JSON) + * GET /v1/info version + capability summary + * GET /v1/maps every bundled transliteration system code + * GET /v1/maps/:code one system's compiled map (JSON IR) + * POST /v1/transliterate {system, input} -> {output} + * POST /v1/detect {input, output} -> ranked systems + * GET /v1/models the neural model index (IMF v1) + * GET /v1/models/:id one model's full entry + * POST /v1/infer {model, input} -> {output} (Modal proxy) + * + * GraphQL remains at POST /graphql (and any other path, for + * compatibility with the Ruby API's {proxy+} behavior). + */ +import { Hono } from "hono"; +import { API_VERSION, detectResolver, setAssets, transliterateResolver, } from "./resolvers.js"; +import { InputTooLongError, MapNotFoundError } from "./errors.js"; +import { INFER_TIMEOUT_MS, LIMITS } from "./limits.js"; +import { bundledSystemCodes } from "./engine.js"; +import { getModel, listModels, MODELS_INDEX_VERSION } from "./models.js"; +import { OPENAPI } from "./openapi.js"; +function errorResponse(status, code, message) { + return Response.json({ error: { code, message } }, { status }); +} +export const rest = new Hono(); +rest.get("/", (c) => c.json({ + name: "Interscript API", + version: "v1", + openapi: "/openapi.json", + endpoints: [ + "GET /v1/info", + "GET /v1/maps", + "GET /v1/maps/{code}", + "POST /v1/transliterate", + "POST /v1/detect", + "GET /v1/models", + "GET /v1/models/{id}", + "POST /v1/infer", + "POST /graphql", + ], +})); +rest.get("/openapi.json", (c) => c.json(OPENAPI)); +rest.get("/v1/info", (c) => c.json({ + api_version: "1.0.0", + engine_version: API_VERSION, + engine: "interscript-ts@native-interpreter", + maps: bundledSystemCodes().length, + models: listModels().length, + models_index_version: MODELS_INDEX_VERSION, + limits: LIMITS, +})); +rest.get("/v1/maps", (c) => c.json({ count: bundledSystemCodes().length, maps: bundledSystemCodes() })); +rest.get("/v1/maps/:code", async (c) => { + const assets = c.env?.ASSETS; + if (!assets) + return errorResponse(503, "assets_missing", "ASSETS binding not configured"); + const code = c.req.param("code"); + if (!bundledSystemCodes().includes(code)) { + return errorResponse(404, "map_not_found", `Couldn't locate ${code}`); + } + // The assets directory IS the maps directory (no /maps/ prefix) and + // requires absolute URLs. + const response = await assets.fetch(`https://assets.internal/${code}.json`); + if (!response.ok) { + return errorResponse(404, "map_not_found", `Couldn't locate ${code}`); + } + return new Response(response.body, { + headers: { "content-type": "application/json; charset=utf-8" }, + }); +}); +rest.post("/v1/transliterate", async (c) => { + const assets = c.env?.ASSETS; + if (!assets) + return errorResponse(503, "assets_missing", "ASSETS binding not configured"); + setAssets(assets); + const body = await c.req.json().catch(() => null); + if (!body || typeof body !== "object") { + return errorResponse(400, "bad_request", "body must be JSON {system, input}"); + } + const { system, input } = body; + if (typeof system !== "string" || typeof input !== "string") { + return errorResponse(400, "bad_request", "system and input must be strings"); + } + try { + const output = await transliterateResolver(system, input); + return c.json({ system, input, output }); + } + catch (e) { + if (e instanceof InputTooLongError) { + return errorResponse(413, "input_too_long", e.message); + } + if (e instanceof MapNotFoundError) { + return errorResponse(404, "map_not_found", e.message); + } + return errorResponse(500, "engine_error", String(e)); + } +}); +rest.post("/v1/detect", async (c) => { + const assets = c.env?.ASSETS; + if (!assets) + return errorResponse(503, "assets_missing", "ASSETS binding not configured"); + setAssets(assets); + const body = await c.req.json().catch(() => null); + const { input, output } = (body ?? {}); + if (typeof input !== "string" || typeof output !== "string") { + return errorResponse(400, "bad_request", "input and output must be strings"); + } + const results = await detectResolver(input, output); + return c.json({ count: results.length, results }); +}); +rest.get("/v1/models", (c) => c.json({ count: listModels().length, models: listModels() })); +rest.get("/v1/models/:id", (c) => { + const model = getModel(c.req.param("id")); + if (!model) + return errorResponse(404, "model_not_found", `Couldn't locate ${c.req.param("id")}`); + return c.json(model); +}); +rest.post("/v1/infer", async (c) => { + const body = await c.req.json().catch(() => null); + const { model, input } = (body ?? {}); + if (typeof model !== "string" || typeof input !== "string") { + return errorResponse(400, "bad_request", "body must be JSON {model, input}"); + } + if (!getModel(model)) { + return errorResponse(404, "model_not_found", `Couldn't locate ${model}`); + } + const { ML_ENDPOINT, ML_TOKEN } = (c.env ?? {}); + if (!ML_ENDPOINT || !ML_TOKEN) { + return errorResponse(503, "inference_unconfigured", "ML_ENDPOINT/ML_TOKEN are not set on this deployment"); + } + const upstream = await fetch(`${ML_ENDPOINT}/infer`, { + method: "POST", + headers: { "content-type": "application/json", "x-api-key": ML_TOKEN }, + body: JSON.stringify({ model, input }), + signal: AbortSignal.timeout(INFER_TIMEOUT_MS), + }).catch(() => null); + if (!upstream || !upstream.ok) { + const detail = upstream ? await upstream.text().catch(() => "") : "upstream unreachable"; + return errorResponse(502, "inference_upstream", detail.slice(0, 500)); + } + const result = (await upstream.json()); + return c.json({ + model, + task: result["task"], + input, + output: result["output"], + }); +}); diff --git a/dist/src/server.js b/dist/src/server.js index c7d4099..68f150a 100644 --- a/dist/src/server.js +++ b/dist/src/server.js @@ -9,7 +9,7 @@ import { Hono } from "hono"; import { cors } from "hono/cors"; import { typeDefs } from "./schema.js"; import { rest } from "./rest.js"; -import { detectResolver, info, setAssets, systemCodesResolver, transliterateResolver, } from "./resolvers.js"; +import { detectResolver, info, setAssets, setMl, systemCodesResolver, transliterateResolver, } from "./resolvers.js"; const yoga = createYoga({ schema: createSchema({ typeDefs, @@ -33,10 +33,11 @@ app.use("*", cors({ origin: "*", allowMethods: ["GET", "POST", "OPTIONS"] })); // REST v1 (OpenAPI: GET /openapi.json) — mounted before the GraphQL // catch-all so /v1/* and / serve REST; everything else stays GraphQL. app.route("/", rest); -app.all("*", (c) => { +app.all("*", async (c) => { const env = c.env; if (env?.ASSETS) setAssets(env.ASSETS); + setMl(env?.ML_ENDPOINT, env?.ML_TOKEN); // executionCtx exists only in a real Workers runtime; without it // (tests, edge runtimes) yoga runs unbatched, which is fine here. let executionCtx; @@ -46,6 +47,29 @@ app.all("*", (c) => { catch { executionCtx = undefined; } - return yoga.fetch(c.req.raw, c.env, executionCtx); + let request = c.req.raw; + // Legacy clients (the interscript.org demo) POST the GraphQL + // document as the raw body with a non-JSON content type; the old + // Lambda accepted that, so wrap it as {query} for Yoga. + const contentType = (request.headers.get("content-type") ?? "").toLowerCase(); + if (request.method === "POST" && !contentType.includes("application/json")) { + const body = await request.text(); + let isJson = false; + try { + JSON.parse(body); + isJson = true; + } + catch { + // not JSON — a raw GraphQL document + } + if (body.trim() && !isJson) { + request = new Request(request.url, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ query: body }), + }); + } + } + return yoga.fetch(request, c.env, executionCtx); }); export default app; diff --git a/dist/test/rest.test.d.ts b/dist/test/rest.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/test/rest.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/test/rest.test.js b/dist/test/rest.test.js new file mode 100644 index 0000000..08d8754 --- /dev/null +++ b/dist/test/rest.test.js @@ -0,0 +1,128 @@ +/** + * REST v1 behavior tests — same fetch-interface harness as the GraphQL + * suite (maps served from the local maps/ directory). + */ +import { readFileSync } from "node:fs"; +import { describe, expect, it } from "vitest"; +import { app } from "../src/server.js"; +const assets = { + fetch: async (url) => { + const path = typeof url === "string" ? url : url.url; + const name = path.substring(path.lastIndexOf("/") + 1); + const code = name.replace(".json", ""); + try { + const body = readFileSync(`maps/${code}.json`); + return new Response(body, { status: 200 }); + } + catch { + return new Response(null, { status: 404 }); + } + }, +}; +const env = { ASSETS: assets }; +const JSON_HEADERS = { "content-type": "application/json" }; +async function get(path, extra = {}) { + return await app.request(`https://example.org${path}`, { headers: { ...JSON_HEADERS, ...extra } }, env); +} +async function post(path, body, extra = {}) { + return await app.request(`https://example.org${path}`, { method: "POST", headers: { ...JSON_HEADERS, ...extra }, body: JSON.stringify(body) }, env); +} +describe("REST index + docs", () => { + it("GET / lists endpoints", async () => { + const res = await get("/"); + expect(res.status).toBe(200); + const body = (await res.json()); + expect(body.endpoints).toContain("POST /v1/infer"); + }); + it("GET /openapi.json serves a 3.1 document covering all routes", async () => { + const res = await get("/openapi.json"); + expect(res.status).toBe(200); + const spec = (await res.json()); + expect(spec.openapi).toBe("3.1.0"); + for (const p of [ + "/v1/info", + "/v1/maps", + "/v1/maps/{code}", + "/v1/transliterate", + "/v1/detect", + "/v1/models", + "/v1/models/{id}", + "/v1/infer", + ]) { + expect(spec.paths[p], p).toBeDefined(); + } + }); + it("GET /v1/info reports map and model counts", async () => { + const res = await get("/v1/info"); + const body = (await res.json()); + expect(body.maps).toBeGreaterThan(200); + expect(body.models).toBeGreaterThanOrEqual(9); + }); +}); +describe("REST maps", () => { + it("GET /v1/maps lists systems", async () => { + const res = await get("/v1/maps"); + const body = (await res.json()); + expect(body.count).toBe(body.maps.length); + expect(body.maps).toContain("alalc-kat-Geor-Latn-1997"); + }); + it("GET /v1/maps/:code returns the compiled map; unknown codes 404", async () => { + const ok = await get("/v1/maps/alalc-kat-Geor-Latn-1997"); + expect(ok.status).toBe(200); + expect(await ok.json()).toBeTruthy(); + const missing = await get("/v1/maps/does-not-exist"); + expect(missing.status).toBe(404); + expect((await missing.json()).error.code).toBe("map_not_found"); + }); +}); +describe("REST transliteration", () => { + it("POST /v1/transliterate mirrors the GraphQL engine", async () => { + const res = await post("/v1/transliterate", { + system: "alalc-kat-Geor-Latn-1997", + input: "ქართული", + }); + expect(res.status).toBe(200); + const body = (await res.json()); + expect(body.output).toBe("k\u02bbart\u02bbuli"); + }); + it("rejects unknown systems and over-long input", async () => { + const missing = await post("/v1/transliterate", { system: "nope", input: "x" }); + expect(missing.status).toBe(404); + const tooLong = await post("/v1/transliterate", { + system: "alalc-kat-Geor-Latn-1997", + input: "a".repeat(1_000_001), + }); + expect(tooLong.status).toBe(413); + }); +}); +describe("REST detect", () => { + it("ranks systems", async () => { + const res = await post("/v1/detect", { input: "ქართული", output: "k\u02bbart\u02bbuli" }); + expect(res.status).toBe(200); + const body = (await res.json()); + expect(body.count).toBeGreaterThan(0); + expect(body.results[0]?.mapName).toContain("kat"); + }); +}); +describe("REST models + inference", () => { + it("GET /v1/models lists the IMF index", async () => { + const res = await get("/v1/models"); + const body = (await res.json()); + expect(body.count).toBeGreaterThanOrEqual(9); + expect(body.models.map((m) => m.id)).toContain("heb-diac-1.0"); + }); + it("GET /v1/models/:id returns the entry; unknown 404", async () => { + const ok = await get("/v1/models/heb-diac-1.0"); + expect(ok.status).toBe(200); + const missing = await get("/v1/models/nope-9.9"); + expect(missing.status).toBe(404); + }); + it("POST /v1/infer validates without an upstream configured", async () => { + const unconfigured = await post("/v1/infer", { model: "heb-diac-1.0", input: "x" }); + expect(unconfigured.status).toBe(503); + const unknownModel = await post("/v1/infer", { model: "nope-9.9", input: "x" }); + expect(unknownModel.status).toBe(404); + const badBody = await post("/v1/infer", { model: 1, input: "x" }); + expect(badBody.status).toBe(400); + }); +}); diff --git a/dist/test/server.test.js b/dist/test/server.test.js index ca3a3fe..39f00c8 100644 --- a/dist/test/server.test.js +++ b/dist/test/server.test.js @@ -73,6 +73,67 @@ describe("detect", () => { expect(ranked.map((r) => r.mapName)).toContain("alalc-kat-Geor-Latn-1997"); }); }); +describe("legacy wire format", () => { + // The interscript.org demo POSTs the GraphQL document as the raw + // body with a urlencoded content type; the old Lambda accepted it. + it("accepts a raw query body with urlencoded content type", async () => { + const response = await app.request("https://example.org/prod", { + method: "POST", + headers: { "content-type": "application/x-www-form-urlencoded" }, + body: `{ transliterate(systemCode: "alalc-kat-Geor-Latn-1997", input: "ქართული") }`, + }, env); + expect(response.status).toBe(200); + const parsed = (await response.json()); + expect(parsed.data?.transliterate).toBe("kʻartʻuli"); + }); + it("accepts a raw query body with the application/graphql content type", async () => { + const response = await app.request("https://example.org/graphql", { + method: "POST", + headers: { "content-type": "application/graphql" }, + body: `{ detect(input: "ქართული", output: "kʻartʻuli") { mapName } }`, + }, env); + expect(response.status).toBe(200); + const parsed = (await response.json()); + expect(parsed.data?.detect?.[0]?.mapName).toContain("kat"); + }); + it("still accepts JSON bodies", async () => { + const response = await query(JSON.stringify({ query: "{ info }" })); + expect(response.status).toBe(200); + const parsed = (await response.json()); + expect(JSON.parse(parsed.data?.info ?? "{}")["version"]).toMatch(/^3\./); + }); +}); +describe("rababa routing", () => { + it("proxies the legacy rababa system code to the ML service", async () => { + const originalFetch = globalThis.fetch; + let called; + globalThis.fetch = (async (url, init) => { + called = { + url: String(url), + body: JSON.parse(String(init?.body)), + key: (init?.headers)["x-api-key"] ?? null, + }; + return new Response(JSON.stringify({ output: "مَدْرَسَة" }), { status: 200 }); + }); + try { + const response = await app.request("https://example.org/graphql", { + method: "POST", + headers: GRAPHQL, + body: JSON.stringify({ + query: `{ transliterate(systemCode: "var-ara-Arab-Arab-rababa", input: "مدرسة") }`, + }), + }, { ASSETS: assets, ML_ENDPOINT: "https://ml.example", ML_TOKEN: "secret-token" }); + const parsed = (await response.json()); + expect(parsed.data?.transliterate).toBe("مَدْرَسَة"); + expect(called?.url).toBe("https://ml.example/infer"); + expect(called?.body).toEqual({ model: "ara-diac-1.0", input: "مدرسة" }); + expect(called?.key).toBe("secret-token"); + } + finally { + globalThis.fetch = originalFetch; + } + }); +}); describe("CORS", () => { it("answers preflight", async () => { const response = await app.request("https://example.org/graphql", { method: "OPTIONS", headers: { origin: "https://interscript.org" } }, env); diff --git a/scripts/e2e.mjs b/scripts/e2e.mjs index 4f13dc3..ae57b4a 100644 --- a/scripts/e2e.mjs +++ b/scripts/e2e.mjs @@ -163,6 +163,36 @@ console.log(`E2E against ${BASE}\n`) check("graphql transliterate parity", tr.data.transliterate === "kʻartʻuli") } +// --- legacy wire format (the interscript.org demo client) --- +{ + const res = await fetch(`${BASE}/prod`, { + method: "POST", + headers: { "content-type": "application/x-www-form-urlencoded" }, + body: `{ transliterate(systemCode: "alalc-kat-Geor-Latn-1997", input: "ქართული") }`, + }) + check("legacy raw-body graphql 200", res.status === 200, `status ${res.status}`) + const body = await res.json() + check( + "legacy raw-body transliterate", + body.data?.transliterate === "kʻartʻuli", + JSON.stringify(body).slice(0, 120), + ) +} +{ + // The demo's Diacritize button: rababa system code routes to ML inference. + const res = await fetch(`${BASE}/prod`, { + method: "POST", + headers: { "content-type": "application/x-www-form-urlencoded" }, + body: `{ transliterate(systemCode: "var-ara-Arab-Arab-rababa", input: "مدرسة جميلة") }`, + }) + const body = await res.json() + check( + "rababa route diacritizes", + /[ً-ْ]/.test(String(body.data?.transliterate ?? "")), + JSON.stringify(body).slice(0, 120), + ) +} + // --- CORS --- { const res = await fetch(`${BASE}/v1/info`, { method: "OPTIONS" }) diff --git a/scripts/gen-models.mjs b/scripts/gen-models.mjs index f81e470..c517b26 100644 --- a/scripts/gen-models.mjs +++ b/scripts/gen-models.mjs @@ -1,21 +1,34 @@ // Regenerate src/generated/models.json from a checkout of // interscript/interscript-ml (default path ../ml-models is the -// historical local name; override with INTSCRIPT_ML_DIR). -import { execSync } from "node:child_process" -import { mkdirSync, writeFileSync } from "node:fs" +// historical local name; override with INTERSCRIPT_ML_DIR). +import { readFileSync, mkdirSync, writeFileSync } from "node:fs" +import { parse } from "yaml" const dir = process.env.INTERSCRIPT_ML_DIR ?? "../ml-models" -const yaml = `${dir}/models.yaml` +const data = parse(readFileSync(`${dir}/models.yaml`, "utf8")) +const fields = [ + "id", + "task", + "scripts", + "precision", + "filename", + "url", + "parts", + "sha256", + "size", + "metrics", + "parity", + "license", +] +const projection = { + version: data.version ?? 1, + models: Object.entries(data.models).map(([id, m]) => + Object.fromEntries([ + ["id", id], + ...fields.filter((k) => k !== "id").map((k) => [k, m[k] ?? null]), + ]), + ), +} mkdirSync("src/generated", { recursive: true }) -const out = execSync( - `python3 -c '${[ - "import json,yaml", - "d=yaml.safe_load(open(" + JSON.stringify(yaml) + "))", - "print(json.dumps({'version':d.get('version',1),'models':[{k:m.get(k) for k in", - "('id','task','scripts','precision','filename','url','parts','sha256','size','metrics','parity','license')}", - "for m in d['models'].values()]}))", - ].join(" ")}'`, -).toString() -const parsed = JSON.parse(out) -writeFileSync("src/generated/models.json", JSON.stringify(parsed, null, 1) + "\n") -console.log(`wrote ${parsed.models.length} models`) +writeFileSync("src/generated/models.json", JSON.stringify(projection, null, 1) + "\n") +console.log(`wrote ${projection.models.length} models`) diff --git a/src/generated/models.json b/src/generated/models.json index 04553af..003b6af 100644 --- a/src/generated/models.json +++ b/src/generated/models.json @@ -28,7 +28,7 @@ ], "parity": { "samples": 895, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -59,7 +59,7 @@ ], "parity": { "samples": 12699, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -85,7 +85,7 @@ ], "parity": { "samples": 11940, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -116,7 +116,7 @@ "metrics": [ { "name": "der_greedy", - "value": 29.0, + "value": 29, "source": "rababa/docs/RESULTS.md#hebrew-diacritization" }, { @@ -127,7 +127,7 @@ ], "parity": { "samples": 600, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -169,7 +169,7 @@ ], "parity": { "samples": 1219, - "cer_delta": 0.0 + "cer_delta": 0 }, "license": "BSD-3-Clause" }, @@ -202,7 +202,7 @@ "samples": 1219, "cer_delta": 0.0803 }, - "license": "BSD-3-Clause" + "license": null }, { "id": "tha-g2p-small-1.0-int4", @@ -262,9 +262,9 @@ ], "parity": { "samples": 1864, - "cer_delta": 0.0 + "cer_delta": 0 }, - "license": "BSD-3-Clause" + "license": null }, { "id": "fas-g2p-1.0", @@ -304,9 +304,51 @@ ], "parity": { "samples": 1000, - "cer_delta": 0.0 + "cer_delta": 0 + }, + "license": "BSD-3-Clause" + }, + { + "id": "heb-diac-1.1", + "task": "diacritization", + "scripts": [ + "Hebr", + "Hebr" + ], + "precision": "fp32", + "filename": "heb.zip", + "url": null, + "parts": [ + { + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-00", + "sha256": "8dac0d62e9b0ac4b137412eaf3a542953f11575f12f66f76cb93d3f5d788fc1b", + "size": 1500000000 + }, + { + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-01", + "sha256": "230c5ab731ea5f001f802d60b9e9a328c10b43bc311a19ef1974f114384313ed", + "size": 1280987905 + } + ], + "sha256": "f0022dde8d06e46e8f08cf0b2f7bbb887a05ed686b90f1d5aa82ca3ef690a0b0", + "size": 2780987905, + "metrics": [ + { + "name": "der_greedy", + "value": 16.44, + "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + }, + { + "name": "der_beam4", + "value": 16.43, + "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + } + ], + "parity": { + "samples": 500, + "cer_delta": 0 }, "license": "BSD-3-Clause" } ] -} \ No newline at end of file +} diff --git a/src/limits.ts b/src/limits.ts index ab93073..86a5c07 100644 --- a/src/limits.ts +++ b/src/limits.ts @@ -2,3 +2,5 @@ export const LIMITS = { input_max_size: 1_000_000, } as const + +export const INFER_TIMEOUT_MS = 120_000 diff --git a/src/resolvers.ts b/src/resolvers.ts index 8ff090a..453c0bd 100644 --- a/src/resolvers.ts +++ b/src/resolvers.ts @@ -5,7 +5,7 @@ import { MapNotFoundError as EngineMapNotFoundError } from "interscript-ts" import { detect, transliterate } from "./engine.js" import { InputTooLongError, MapNotFoundError } from "./errors.js" -import { LIMITS } from "./limits.js" +import { INFER_TIMEOUT_MS, LIMITS } from "./limits.js" import { bundledSystemCodes } from "./engine.js" export const API_VERSION = "3.0.0-cloudflare.1" @@ -16,6 +16,8 @@ export interface AssetsBinding { export interface Env { ASSETS?: AssetsBinding + ML_ENDPOINT?: string + ML_TOKEN?: string } // The ASSETS binding is constant for an isolate's lifetime; the Hono @@ -27,6 +29,39 @@ export function setAssets(binding: AssetsBinding): void { assets = binding } +let ml: { endpoint: string; token: string } | undefined + +export function setMl(endpoint: string | undefined, token: string | undefined): void { + ml = endpoint && token ? { endpoint, token } : undefined +} + +// Legacy wire compatibility: the old Ruby API proxied rababa system +// codes to the ML service; the interscript.org demo still calls this +// through GraphQL and REST transliterate. +const RABABA_MODELS: Record = { + "var-ara-Arab-Arab-rababa": "ara-diac-1.0", +} + +async function infer(model: string, input: string): Promise { + if (!ml) { + throw new Error("ML inference unavailable — ML_ENDPOINT/ML_TOKEN not set") + } + const res = await fetch(`${ml.endpoint}/infer`, { + method: "POST", + headers: { "content-type": "application/json", "x-api-key": ml.token }, + body: JSON.stringify({ model, input }), + signal: AbortSignal.timeout(INFER_TIMEOUT_MS), + }).catch(() => null) + if (!res || !res.ok) { + throw new Error("ML inference upstream failed") + } + const out = (await res.json().catch(() => null)) as { output?: unknown } | null + if (!out || typeof out.output !== "string") { + throw new Error("ML inference returned no output") + } + return out.output +} + export function requireAssets(): AssetsBinding { if (!assets) { throw new Error("ASSETS binding missing — see README deployment notes") @@ -49,6 +84,10 @@ export async function transliterateResolver(systemCode: string, input: string): if (input.length > LIMITS.input_max_size) { throw new InputTooLongError(LIMITS.input_max_size) } + const rababaModel = RABABA_MODELS[systemCode] + if (rababaModel) { + return infer(rababaModel, input) + } try { return await transliterate(requireAssets(), systemCode, input) } catch (e) { diff --git a/src/rest.ts b/src/rest.ts index 4bbaec1..5d3f308 100644 --- a/src/rest.ts +++ b/src/rest.ts @@ -16,15 +16,19 @@ * compatibility with the Ruby API's {proxy+} behavior). */ import { Hono } from "hono" -import { API_VERSION, detectResolver, setAssets, transliterateResolver, type Env } from "./resolvers.js" +import { + API_VERSION, + detectResolver, + setAssets, + transliterateResolver, + type Env, +} from "./resolvers.js" import { InputTooLongError, MapNotFoundError } from "./errors.js" -import { LIMITS } from "./limits.js" +import { INFER_TIMEOUT_MS, LIMITS } from "./limits.js" import { bundledSystemCodes } from "./engine.js" import { getModel, listModels, MODELS_INDEX_VERSION } from "./models.js" import { OPENAPI } from "./openapi.js" -const INFER_TIMEOUT_MS = 120_000 - function errorResponse(status: number, code: string, message: string) { return Response.json({ error: { code, message } }, { status }) } @@ -125,9 +129,7 @@ rest.post("/v1/detect", async (c) => { return c.json({ count: results.length, results }) }) -rest.get("/v1/models", (c) => - c.json({ count: listModels().length, models: listModels() }), -) +rest.get("/v1/models", (c) => c.json({ count: listModels().length, models: listModels() })) rest.get("/v1/models/:id", (c) => { const model = getModel(c.req.param("id")) diff --git a/src/server.ts b/src/server.ts index 676cac8..2b591d4 100644 --- a/src/server.ts +++ b/src/server.ts @@ -13,6 +13,7 @@ import { detectResolver, info, setAssets, + setMl, systemCodesResolver, transliterateResolver, type Env, @@ -45,9 +46,10 @@ app.use("*", cors({ origin: "*", allowMethods: ["GET", "POST", "OPTIONS"] })) // catch-all so /v1/* and / serve REST; everything else stays GraphQL. app.route("/", rest) -app.all("*", (c) => { +app.all("*", async (c) => { const env = c.env as Env | undefined if (env?.ASSETS) setAssets(env.ASSETS) + setMl(env?.ML_ENDPOINT, env?.ML_TOKEN) // executionCtx exists only in a real Workers runtime; without it // (tests, edge runtimes) yoga runs unbatched, which is fine here. let executionCtx: unknown @@ -56,8 +58,30 @@ app.all("*", (c) => { } catch { executionCtx = undefined } + let request = c.req.raw + // Legacy clients (the interscript.org demo) POST the GraphQL + // document as the raw body with a non-JSON content type; the old + // Lambda accepted that, so wrap it as {query} for Yoga. + const contentType = (request.headers.get("content-type") ?? "").toLowerCase() + if (request.method === "POST" && !contentType.includes("application/json")) { + const body = await request.text() + let isJson = false + try { + JSON.parse(body) + isJson = true + } catch { + // not JSON — a raw GraphQL document + } + if (body.trim() && !isJson) { + request = new Request(request.url, { + method: "POST", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ query: body }), + }) + } + } return yoga.fetch( - c.req.raw as unknown as Parameters[0], + request as unknown as Parameters[0], c.env as never, executionCtx as never, ) diff --git a/test/server.test.ts b/test/server.test.ts index 31a0436..3accf85 100644 --- a/test/server.test.ts +++ b/test/server.test.ts @@ -90,6 +90,82 @@ describe("detect", () => { }) }) +describe("legacy wire format", () => { + // The interscript.org demo POSTs the GraphQL document as the raw + // body with a urlencoded content type; the old Lambda accepted it. + it("accepts a raw query body with urlencoded content type", async () => { + const response = await app.request( + "https://example.org/prod", + { + method: "POST", + headers: { "content-type": "application/x-www-form-urlencoded" }, + body: `{ transliterate(systemCode: "alalc-kat-Geor-Latn-1997", input: "ქართული") }`, + }, + env, + ) + expect(response.status).toBe(200) + const parsed = (await response.json()) as { data?: { transliterate?: string } } + expect(parsed.data?.transliterate).toBe("kʻartʻuli") + }) + + it("accepts a raw query body with the application/graphql content type", async () => { + const response = await app.request( + "https://example.org/graphql", + { + method: "POST", + headers: { "content-type": "application/graphql" }, + body: `{ detect(input: "ქართული", output: "kʻartʻuli") { mapName } }`, + }, + env, + ) + expect(response.status).toBe(200) + const parsed = (await response.json()) as { data?: { detect?: { mapName: string }[] } } + expect(parsed.data?.detect?.[0]?.mapName).toContain("kat") + }) + + it("still accepts JSON bodies", async () => { + const response = await query(JSON.stringify({ query: "{ info }" })) + expect(response.status).toBe(200) + const parsed = (await response.json()) as { data?: { info?: string } } + expect(JSON.parse(parsed.data?.info ?? "{}")["version"]).toMatch(/^3\./) + }) +}) + +describe("rababa routing", () => { + it("proxies the legacy rababa system code to the ML service", async () => { + const originalFetch = globalThis.fetch + let called: { url: string; body: unknown; key: string | null } | undefined + globalThis.fetch = (async (url: unknown, init?: RequestInit) => { + called = { + url: String(url), + body: JSON.parse(String(init?.body)), + key: (init?.headers as Record)["x-api-key"] ?? null, + } + return new Response(JSON.stringify({ output: "مَدْرَسَة" }), { status: 200 }) + }) as typeof fetch + try { + const response = await app.request( + "https://example.org/graphql", + { + method: "POST", + headers: GRAPHQL, + body: JSON.stringify({ + query: `{ transliterate(systemCode: "var-ara-Arab-Arab-rababa", input: "مدرسة") }`, + }), + }, + { ASSETS: assets, ML_ENDPOINT: "https://ml.example", ML_TOKEN: "secret-token" }, + ) + const parsed = (await response.json()) as { data?: { transliterate?: string } } + expect(parsed.data?.transliterate).toBe("مَدْرَسَة") + expect(called?.url).toBe("https://ml.example/infer") + expect(called?.body).toEqual({ model: "ara-diac-1.0", input: "مدرسة" }) + expect(called?.key).toBe("secret-token") + } finally { + globalThis.fetch = originalFetch + } + }) +}) + describe("CORS", () => { it("answers preflight", async () => { const response = await app.request( From 9dc928ce3d9425fcc06be765b141e916af2f2b5e Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Mon, 24 Aug 2026 06:57:50 +0800 Subject: [PATCH 3/5] build: commit the vendored engine dist (its nested gitignore hid it from checkouts) --- vendor/interscript-ts/dist/cli.d.ts | 25 + vendor/interscript-ts/dist/cli.d.ts.map | 1 + vendor/interscript-ts/dist/cli.js | 323 ++++++++ vendor/interscript-ts/dist/cli.js.map | 1 + vendor/interscript-ts/dist/detector.d.ts | 22 + vendor/interscript-ts/dist/detector.d.ts.map | 1 + vendor/interscript-ts/dist/detector.js | 73 ++ vendor/interscript-ts/dist/detector.js.map | 1 + vendor/interscript-ts/dist/errors.d.ts | 26 + vendor/interscript-ts/dist/errors.d.ts.map | 1 + vendor/interscript-ts/dist/errors.js | 34 + vendor/interscript-ts/dist/errors.js.map | 1 + vendor/interscript-ts/dist/http-loader.d.ts | 42 + .../interscript-ts/dist/http-loader.d.ts.map | 1 + vendor/interscript-ts/dist/http-loader.js | 95 +++ vendor/interscript-ts/dist/http-loader.js.map | 1 + vendor/interscript-ts/dist/index.d.ts | 49 ++ vendor/interscript-ts/dist/index.d.ts.map | 1 + vendor/interscript-ts/dist/index.js | 182 +++++ vendor/interscript-ts/dist/index.js.map | 1 + vendor/interscript-ts/dist/isc/converter.d.ts | 11 + .../dist/isc/converter.d.ts.map | 1 + vendor/interscript-ts/dist/isc/converter.js | 175 +++++ .../interscript-ts/dist/isc/converter.js.map | 1 + vendor/interscript-ts/dist/isc/index.d.ts | 16 + vendor/interscript-ts/dist/isc/index.d.ts.map | 1 + vendor/interscript-ts/dist/isc/index.js | 15 + vendor/interscript-ts/dist/isc/index.js.map | 1 + vendor/interscript-ts/dist/isc/loader.d.ts | 22 + .../interscript-ts/dist/isc/loader.d.ts.map | 1 + vendor/interscript-ts/dist/isc/loader.js | 47 ++ vendor/interscript-ts/dist/isc/loader.js.map | 1 + vendor/interscript-ts/dist/isc/parser.d.ts | 14 + .../interscript-ts/dist/isc/parser.d.ts.map | 1 + vendor/interscript-ts/dist/isc/parser.js | 732 ++++++++++++++++++ vendor/interscript-ts/dist/isc/parser.js.map | 1 + vendor/interscript-ts/dist/isc/types.d.ts | 110 +++ vendor/interscript-ts/dist/isc/types.d.ts.map | 1 + vendor/interscript-ts/dist/isc/types.js | 19 + vendor/interscript-ts/dist/isc/types.js.map | 1 + vendor/interscript-ts/dist/loader.d.ts | 49 ++ vendor/interscript-ts/dist/loader.d.ts.map | 1 + vendor/interscript-ts/dist/loader.js | 93 +++ vendor/interscript-ts/dist/loader.js.map | 1 + vendor/interscript-ts/dist/loaders.d.ts | 23 + vendor/interscript-ts/dist/loaders.d.ts.map | 1 + vendor/interscript-ts/dist/loaders.js | 40 + vendor/interscript-ts/dist/loaders.js.map | 1 + vendor/interscript-ts/dist/loaders.node.d.ts | 25 + .../interscript-ts/dist/loaders.node.d.ts.map | 1 + vendor/interscript-ts/dist/loaders.node.js | 42 + .../interscript-ts/dist/loaders.node.js.map | 1 + vendor/interscript-ts/dist/ml/imf/index.d.ts | 6 + .../interscript-ts/dist/ml/imf/index.d.ts.map | 1 + vendor/interscript-ts/dist/ml/imf/index.js | 6 + .../interscript-ts/dist/ml/imf/index.js.map | 1 + vendor/interscript-ts/dist/ml/imf/loader.d.ts | 19 + .../dist/ml/imf/loader.d.ts.map | 1 + vendor/interscript-ts/dist/ml/imf/loader.js | 59 ++ .../interscript-ts/dist/ml/imf/loader.js.map | 1 + vendor/interscript-ts/dist/ml/imf/model.d.ts | 28 + .../interscript-ts/dist/ml/imf/model.d.ts.map | 1 + vendor/interscript-ts/dist/ml/imf/model.js | 179 +++++ .../interscript-ts/dist/ml/imf/model.js.map | 1 + .../interscript-ts/dist/ml/imf/registry.d.ts | 24 + .../dist/ml/imf/registry.d.ts.map | 1 + vendor/interscript-ts/dist/ml/imf/registry.js | 73 ++ .../dist/ml/imf/registry.js.map | 1 + vendor/interscript-ts/dist/ml/imf/tokens.d.ts | 13 + .../dist/ml/imf/tokens.d.ts.map | 1 + vendor/interscript-ts/dist/ml/imf/tokens.js | 32 + .../interscript-ts/dist/ml/imf/tokens.js.map | 1 + vendor/interscript-ts/dist/ml/index.d.ts | 24 + vendor/interscript-ts/dist/ml/index.d.ts.map | 1 + vendor/interscript-ts/dist/ml/index.js | 25 + vendor/interscript-ts/dist/ml/index.js.map | 1 + .../dist/ml/models/rababa/cleaner.d.ts | 11 + .../dist/ml/models/rababa/cleaner.d.ts.map | 1 + .../dist/ml/models/rababa/cleaner.js | 21 + .../dist/ml/models/rababa/cleaner.js.map | 1 + .../dist/ml/models/rababa/diacritizer.d.ts | 37 + .../ml/models/rababa/diacritizer.d.ts.map | 1 + .../dist/ml/models/rababa/diacritizer.js | 174 +++++ .../dist/ml/models/rababa/diacritizer.js.map | 1 + .../dist/ml/models/rababa/encoder.d.ts | 40 + .../dist/ml/models/rababa/encoder.d.ts.map | 1 + .../dist/ml/models/rababa/encoder.js | 57 ++ .../dist/ml/models/rababa/encoder.js.map | 1 + .../dist/ml/models/rababa/haraqat.d.ts | 49 ++ .../dist/ml/models/rababa/haraqat.d.ts.map | 1 + .../dist/ml/models/rababa/haraqat.js | 93 +++ .../dist/ml/models/rababa/haraqat.js.map | 1 + .../dist/ml/models/rababa/index.d.ts | 12 + .../dist/ml/models/rababa/index.d.ts.map | 1 + .../dist/ml/models/rababa/index.js | 14 + .../dist/ml/models/rababa/index.js.map | 1 + .../dist/ml/models/rababa/reconciler.d.ts | 29 + .../dist/ml/models/rababa/reconciler.d.ts.map | 1 + .../dist/ml/models/rababa/reconciler.js | 81 ++ .../dist/ml/models/rababa/reconciler.js.map | 1 + .../dist/ml/models/secryst/index.d.ts | 10 + .../dist/ml/models/secryst/index.d.ts.map | 1 + .../dist/ml/models/secryst/index.js | 12 + .../dist/ml/models/secryst/index.js.map | 1 + .../dist/ml/models/secryst/masks.d.ts | 33 + .../dist/ml/models/secryst/masks.d.ts.map | 1 + .../dist/ml/models/secryst/masks.js | 73 ++ .../dist/ml/models/secryst/masks.js.map | 1 + .../dist/ml/models/secryst/translator.d.ts | 31 + .../ml/models/secryst/translator.d.ts.map | 1 + .../dist/ml/models/secryst/translator.js | 114 +++ .../dist/ml/models/secryst/translator.js.map | 1 + .../dist/ml/models/secryst/vocab.d.ts | 39 + .../dist/ml/models/secryst/vocab.d.ts.map | 1 + .../dist/ml/models/secryst/vocab.js | 85 ++ .../dist/ml/models/secryst/vocab.js.map | 1 + .../dist/ml/provision/base.d.ts | 14 + .../dist/ml/provision/base.d.ts.map | 1 + .../interscript-ts/dist/ml/provision/base.js | 19 + .../dist/ml/provision/base.js.map | 1 + .../dist/ml/provision/index.d.ts | 62 ++ .../dist/ml/provision/index.d.ts.map | 1 + .../interscript-ts/dist/ml/provision/index.js | 107 +++ .../dist/ml/provision/index.js.map | 1 + .../dist/ml/provision/manifest.d.ts | 79 ++ .../dist/ml/provision/manifest.d.ts.map | 1 + .../dist/ml/provision/manifest.js | 126 +++ .../dist/ml/provision/manifest.js.map | 1 + vendor/interscript-ts/dist/ml/registry.d.ts | 35 + .../interscript-ts/dist/ml/registry.d.ts.map | 1 + vendor/interscript-ts/dist/ml/registry.js | 76 ++ vendor/interscript-ts/dist/ml/registry.js.map | 1 + .../interscript-ts/dist/ml/session/index.d.ts | 55 ++ .../dist/ml/session/index.d.ts.map | 1 + .../interscript-ts/dist/ml/session/index.js | 57 ++ .../dist/ml/session/index.js.map | 1 + .../dist/ml/session/litert-web.d.ts | 50 ++ .../dist/ml/session/litert-web.d.ts.map | 1 + .../dist/ml/session/litert-web.js | 146 ++++ .../dist/ml/session/litert-web.js.map | 1 + .../dist/ml/session/onnx-node.d.ts | 10 + .../dist/ml/session/onnx-node.d.ts.map | 1 + .../dist/ml/session/onnx-node.js | 62 ++ .../dist/ml/session/onnx-node.js.map | 1 + .../dist/ml/session/onnx-web.d.ts | 23 + .../dist/ml/session/onnx-web.d.ts.map | 1 + .../dist/ml/session/onnx-web.js | 74 ++ .../dist/ml/session/onnx-web.js.map | 1 + vendor/interscript-ts/dist/ml/types.d.ts | 113 +++ vendor/interscript-ts/dist/ml/types.d.ts.map | 1 + vendor/interscript-ts/dist/ml/types.js | 7 + vendor/interscript-ts/dist/ml/types.js.map | 1 + .../dist/runtime/compile-item.d.ts | 53 ++ .../dist/runtime/compile-item.d.ts.map | 1 + .../dist/runtime/compile-item.js | 272 +++++++ .../dist/runtime/compile-item.js.map | 1 + .../interscript-ts/dist/runtime/context.d.ts | 33 + .../dist/runtime/context.d.ts.map | 1 + vendor/interscript-ts/dist/runtime/context.js | 67 ++ .../dist/runtime/context.js.map | 1 + .../interscript-ts/dist/runtime/executor.d.ts | 18 + .../dist/runtime/executor.d.ts.map | 1 + .../interscript-ts/dist/runtime/executor.js | 224 ++++++ .../dist/runtime/executor.js.map | 1 + .../dist/runtime/interpreter.d.ts | 30 + .../dist/runtime/interpreter.d.ts.map | 1 + .../dist/runtime/interpreter.js | 130 ++++ .../dist/runtime/interpreter.js.map | 1 + vendor/interscript-ts/dist/stdlib.d.ts | 96 +++ vendor/interscript-ts/dist/stdlib.d.ts.map | 1 + vendor/interscript-ts/dist/stdlib.js | 160 ++++ vendor/interscript-ts/dist/stdlib.js.map | 1 + vendor/interscript-ts/dist/stdlib/ml.d.ts | 55 ++ vendor/interscript-ts/dist/stdlib/ml.d.ts.map | 1 + vendor/interscript-ts/dist/stdlib/ml.js | 113 +++ vendor/interscript-ts/dist/stdlib/ml.js.map | 1 + vendor/interscript-ts/dist/types.d.ts | 167 ++++ vendor/interscript-ts/dist/types.d.ts.map | 1 + vendor/interscript-ts/dist/types.js | 13 + vendor/interscript-ts/dist/types.js.map | 1 + 180 files changed, 6443 insertions(+) create mode 100644 vendor/interscript-ts/dist/cli.d.ts create mode 100644 vendor/interscript-ts/dist/cli.d.ts.map create mode 100755 vendor/interscript-ts/dist/cli.js create mode 100644 vendor/interscript-ts/dist/cli.js.map create mode 100644 vendor/interscript-ts/dist/detector.d.ts create mode 100644 vendor/interscript-ts/dist/detector.d.ts.map create mode 100644 vendor/interscript-ts/dist/detector.js create mode 100644 vendor/interscript-ts/dist/detector.js.map create mode 100644 vendor/interscript-ts/dist/errors.d.ts create mode 100644 vendor/interscript-ts/dist/errors.d.ts.map create mode 100644 vendor/interscript-ts/dist/errors.js create mode 100644 vendor/interscript-ts/dist/errors.js.map create mode 100644 vendor/interscript-ts/dist/http-loader.d.ts create mode 100644 vendor/interscript-ts/dist/http-loader.d.ts.map create mode 100644 vendor/interscript-ts/dist/http-loader.js create mode 100644 vendor/interscript-ts/dist/http-loader.js.map create mode 100644 vendor/interscript-ts/dist/index.d.ts create mode 100644 vendor/interscript-ts/dist/index.d.ts.map create mode 100644 vendor/interscript-ts/dist/index.js create mode 100644 vendor/interscript-ts/dist/index.js.map create mode 100644 vendor/interscript-ts/dist/isc/converter.d.ts create mode 100644 vendor/interscript-ts/dist/isc/converter.d.ts.map create mode 100644 vendor/interscript-ts/dist/isc/converter.js create mode 100644 vendor/interscript-ts/dist/isc/converter.js.map create mode 100644 vendor/interscript-ts/dist/isc/index.d.ts create mode 100644 vendor/interscript-ts/dist/isc/index.d.ts.map create mode 100644 vendor/interscript-ts/dist/isc/index.js create mode 100644 vendor/interscript-ts/dist/isc/index.js.map create mode 100644 vendor/interscript-ts/dist/isc/loader.d.ts create mode 100644 vendor/interscript-ts/dist/isc/loader.d.ts.map create mode 100644 vendor/interscript-ts/dist/isc/loader.js create mode 100644 vendor/interscript-ts/dist/isc/loader.js.map create mode 100644 vendor/interscript-ts/dist/isc/parser.d.ts create mode 100644 vendor/interscript-ts/dist/isc/parser.d.ts.map create mode 100644 vendor/interscript-ts/dist/isc/parser.js create mode 100644 vendor/interscript-ts/dist/isc/parser.js.map create mode 100644 vendor/interscript-ts/dist/isc/types.d.ts create mode 100644 vendor/interscript-ts/dist/isc/types.d.ts.map create mode 100644 vendor/interscript-ts/dist/isc/types.js create mode 100644 vendor/interscript-ts/dist/isc/types.js.map create mode 100644 vendor/interscript-ts/dist/loader.d.ts create mode 100644 vendor/interscript-ts/dist/loader.d.ts.map create mode 100644 vendor/interscript-ts/dist/loader.js create mode 100644 vendor/interscript-ts/dist/loader.js.map create mode 100644 vendor/interscript-ts/dist/loaders.d.ts create mode 100644 vendor/interscript-ts/dist/loaders.d.ts.map create mode 100644 vendor/interscript-ts/dist/loaders.js create mode 100644 vendor/interscript-ts/dist/loaders.js.map create mode 100644 vendor/interscript-ts/dist/loaders.node.d.ts create mode 100644 vendor/interscript-ts/dist/loaders.node.d.ts.map create mode 100644 vendor/interscript-ts/dist/loaders.node.js create mode 100644 vendor/interscript-ts/dist/loaders.node.js.map create mode 100644 vendor/interscript-ts/dist/ml/imf/index.d.ts create mode 100644 vendor/interscript-ts/dist/ml/imf/index.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/imf/index.js create mode 100644 vendor/interscript-ts/dist/ml/imf/index.js.map create mode 100644 vendor/interscript-ts/dist/ml/imf/loader.d.ts create mode 100644 vendor/interscript-ts/dist/ml/imf/loader.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/imf/loader.js create mode 100644 vendor/interscript-ts/dist/ml/imf/loader.js.map create mode 100644 vendor/interscript-ts/dist/ml/imf/model.d.ts create mode 100644 vendor/interscript-ts/dist/ml/imf/model.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/imf/model.js create mode 100644 vendor/interscript-ts/dist/ml/imf/model.js.map create mode 100644 vendor/interscript-ts/dist/ml/imf/registry.d.ts create mode 100644 vendor/interscript-ts/dist/ml/imf/registry.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/imf/registry.js create mode 100644 vendor/interscript-ts/dist/ml/imf/registry.js.map create mode 100644 vendor/interscript-ts/dist/ml/imf/tokens.d.ts create mode 100644 vendor/interscript-ts/dist/ml/imf/tokens.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/imf/tokens.js create mode 100644 vendor/interscript-ts/dist/ml/imf/tokens.js.map create mode 100644 vendor/interscript-ts/dist/ml/index.d.ts create mode 100644 vendor/interscript-ts/dist/ml/index.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/index.js create mode 100644 vendor/interscript-ts/dist/ml/index.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/cleaner.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/cleaner.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/cleaner.js create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/cleaner.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/diacritizer.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/diacritizer.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/diacritizer.js create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/diacritizer.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/encoder.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/encoder.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/encoder.js create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/encoder.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/haraqat.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/haraqat.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/haraqat.js create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/haraqat.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/index.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/index.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/index.js create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/index.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/reconciler.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/reconciler.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/reconciler.js create mode 100644 vendor/interscript-ts/dist/ml/models/rababa/reconciler.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/index.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/index.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/index.js create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/index.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/masks.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/masks.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/masks.js create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/masks.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/translator.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/translator.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/translator.js create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/translator.js.map create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/vocab.d.ts create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/vocab.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/vocab.js create mode 100644 vendor/interscript-ts/dist/ml/models/secryst/vocab.js.map create mode 100644 vendor/interscript-ts/dist/ml/provision/base.d.ts create mode 100644 vendor/interscript-ts/dist/ml/provision/base.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/provision/base.js create mode 100644 vendor/interscript-ts/dist/ml/provision/base.js.map create mode 100644 vendor/interscript-ts/dist/ml/provision/index.d.ts create mode 100644 vendor/interscript-ts/dist/ml/provision/index.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/provision/index.js create mode 100644 vendor/interscript-ts/dist/ml/provision/index.js.map create mode 100644 vendor/interscript-ts/dist/ml/provision/manifest.d.ts create mode 100644 vendor/interscript-ts/dist/ml/provision/manifest.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/provision/manifest.js create mode 100644 vendor/interscript-ts/dist/ml/provision/manifest.js.map create mode 100644 vendor/interscript-ts/dist/ml/registry.d.ts create mode 100644 vendor/interscript-ts/dist/ml/registry.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/registry.js create mode 100644 vendor/interscript-ts/dist/ml/registry.js.map create mode 100644 vendor/interscript-ts/dist/ml/session/index.d.ts create mode 100644 vendor/interscript-ts/dist/ml/session/index.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/session/index.js create mode 100644 vendor/interscript-ts/dist/ml/session/index.js.map create mode 100644 vendor/interscript-ts/dist/ml/session/litert-web.d.ts create mode 100644 vendor/interscript-ts/dist/ml/session/litert-web.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/session/litert-web.js create mode 100644 vendor/interscript-ts/dist/ml/session/litert-web.js.map create mode 100644 vendor/interscript-ts/dist/ml/session/onnx-node.d.ts create mode 100644 vendor/interscript-ts/dist/ml/session/onnx-node.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/session/onnx-node.js create mode 100644 vendor/interscript-ts/dist/ml/session/onnx-node.js.map create mode 100644 vendor/interscript-ts/dist/ml/session/onnx-web.d.ts create mode 100644 vendor/interscript-ts/dist/ml/session/onnx-web.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/session/onnx-web.js create mode 100644 vendor/interscript-ts/dist/ml/session/onnx-web.js.map create mode 100644 vendor/interscript-ts/dist/ml/types.d.ts create mode 100644 vendor/interscript-ts/dist/ml/types.d.ts.map create mode 100644 vendor/interscript-ts/dist/ml/types.js create mode 100644 vendor/interscript-ts/dist/ml/types.js.map create mode 100644 vendor/interscript-ts/dist/runtime/compile-item.d.ts create mode 100644 vendor/interscript-ts/dist/runtime/compile-item.d.ts.map create mode 100644 vendor/interscript-ts/dist/runtime/compile-item.js create mode 100644 vendor/interscript-ts/dist/runtime/compile-item.js.map create mode 100644 vendor/interscript-ts/dist/runtime/context.d.ts create mode 100644 vendor/interscript-ts/dist/runtime/context.d.ts.map create mode 100644 vendor/interscript-ts/dist/runtime/context.js create mode 100644 vendor/interscript-ts/dist/runtime/context.js.map create mode 100644 vendor/interscript-ts/dist/runtime/executor.d.ts create mode 100644 vendor/interscript-ts/dist/runtime/executor.d.ts.map create mode 100644 vendor/interscript-ts/dist/runtime/executor.js create mode 100644 vendor/interscript-ts/dist/runtime/executor.js.map create mode 100644 vendor/interscript-ts/dist/runtime/interpreter.d.ts create mode 100644 vendor/interscript-ts/dist/runtime/interpreter.d.ts.map create mode 100644 vendor/interscript-ts/dist/runtime/interpreter.js create mode 100644 vendor/interscript-ts/dist/runtime/interpreter.js.map create mode 100644 vendor/interscript-ts/dist/stdlib.d.ts create mode 100644 vendor/interscript-ts/dist/stdlib.d.ts.map create mode 100644 vendor/interscript-ts/dist/stdlib.js create mode 100644 vendor/interscript-ts/dist/stdlib.js.map create mode 100644 vendor/interscript-ts/dist/stdlib/ml.d.ts create mode 100644 vendor/interscript-ts/dist/stdlib/ml.d.ts.map create mode 100644 vendor/interscript-ts/dist/stdlib/ml.js create mode 100644 vendor/interscript-ts/dist/stdlib/ml.js.map create mode 100644 vendor/interscript-ts/dist/types.d.ts create mode 100644 vendor/interscript-ts/dist/types.d.ts.map create mode 100644 vendor/interscript-ts/dist/types.js create mode 100644 vendor/interscript-ts/dist/types.js.map diff --git a/vendor/interscript-ts/dist/cli.d.ts b/vendor/interscript-ts/dist/cli.d.ts new file mode 100644 index 0000000..707038a --- /dev/null +++ b/vendor/interscript-ts/dist/cli.d.ts @@ -0,0 +1,25 @@ +#!/usr/bin/env node +/** + * interscript-ts CLI — transliteration power tool. + * + * Subcommands: + * interscript-ts transliterate [options] (alias: t) + * interscript-ts batch (alias: b) + * interscript-ts list (alias: l) + * interscript-ts detect (alias: d) + * + * Global options: + * --maps-dir Directory containing .json IR files + * --http Load maps from HTTP base URL (default /maps) + * --no-cache Skip persistent cache (HTTP loader) + * -h, --help Show this help + * + * Examples: + * echo "Антон" | interscript-ts t bgnpcgn-ukr-Cyrl-Latn-2019 + * interscript-ts t bgnpcgn-ukr-Cyrl-Latn-2019 -i input.txt -o output.txt + * interscript-ts batch bgnpcgn-ukr-Cyrl-Latn-2019 names.txt --csv + * interscript-ts list --authority bgnpcgn --source-script Cyrl + * interscript-ts detect "Антон" "Anton" --maps-dir ./ir + */ +export {}; +//# sourceMappingURL=cli.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/cli.d.ts.map b/vendor/interscript-ts/dist/cli.d.ts.map new file mode 100644 index 0000000..ff3d6b9 --- /dev/null +++ b/vendor/interscript-ts/dist/cli.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/cli.js b/vendor/interscript-ts/dist/cli.js new file mode 100755 index 0000000..929f207 --- /dev/null +++ b/vendor/interscript-ts/dist/cli.js @@ -0,0 +1,323 @@ +#!/usr/bin/env node +/** + * interscript-ts CLI — transliteration power tool. + * + * Subcommands: + * interscript-ts transliterate [options] (alias: t) + * interscript-ts batch (alias: b) + * interscript-ts list (alias: l) + * interscript-ts detect (alias: d) + * + * Global options: + * --maps-dir Directory containing .json IR files + * --http Load maps from HTTP base URL (default /maps) + * --no-cache Skip persistent cache (HTTP loader) + * -h, --help Show this help + * + * Examples: + * echo "Антон" | interscript-ts t bgnpcgn-ukr-Cyrl-Latn-2019 + * interscript-ts t bgnpcgn-ukr-Cyrl-Latn-2019 -i input.txt -o output.txt + * interscript-ts batch bgnpcgn-ukr-Cyrl-Latn-2019 names.txt --csv + * interscript-ts list --authority bgnpcgn --source-script Cyrl + * interscript-ts detect "Антон" "Anton" --maps-dir ./ir + */ +import { parseArgs } from "node:util"; +import { readFileSync, writeFileSync, existsSync, readdirSync } from "node:fs"; +import { resolve } from "node:path"; +import { configure, reset, transliterate, transliterateAsync, detect, httpStrategy, } from "./index.js"; +import { filesystemStrategy } from "./loaders.node.js"; +function buildStrategies(opts) { + if (opts.http) { + const httpOpts = { baseUrl: opts.http }; + if (!opts.noCache) + httpOpts.cacheKeyPrefix = "isx-cli:"; + return [httpStrategy(httpOpts)]; + } + if (opts.mapsDir) { + return [filesystemStrategy(opts.mapsDir)]; + } + // Default: try filesystem in CWD, fall back to HTTP from interscript.org. + const httpOpts = { + baseUrl: "https://interscript.org/maps", + }; + if (!opts.noCache) + httpOpts.cacheKeyPrefix = "isx-cli:"; + return [ + filesystemStrategy(resolve(process.cwd(), "maps")), + filesystemStrategy(resolve(process.cwd(), "public/maps")), + httpStrategy(httpOpts), + ]; +} +function readStdin() { + try { + return readFileSync(0, "utf8"); + } + catch { + return ""; + } +} +function parseGlobalOpts(args) { + const opts = { noCache: false }; + const rest = []; + for (let i = 0; i < args.length; i++) { + const a = args[i]; + if (a === "--maps-dir") { + opts.mapsDir = args[++i]; + } + else if (a === "--http") { + opts.http = args[++i]; + } + else if (a === "--no-cache") { + opts.noCache = true; + } + else { + rest.push(a); + } + } + return { opts, rest }; +} +function loadCatalogue(mapsDir) { + const out = []; + for (const f of readdirSync(mapsDir)) { + if (!f.endsWith(".json")) + continue; + const code = f.replace(/\.json$/, ""); + try { + const json = JSON.parse(readFileSync(resolve(mapsDir, f), "utf8")); + out.push({ code, metadata: json.metadata }); + } + catch { + out.push({ code }); + } + } + return out; +} +async function cmdTransliterate(args, opts) { + const { values, positionals } = parseArgs({ + args, + options: { + input: { type: "string", short: "i" }, + output: { type: "string", short: "o" }, + }, + allowPositionals: true, + strict: true, + }); + const systemCode = positionals[0]; + if (!systemCode) { + process.stderr.write("Error: systemCode is required as the first positional arg\n"); + return 1; + } + reset(); + configure({ strategies: buildStrategies(opts) }); + const inputText = values.input + ? readFileSync(resolve(process.cwd(), values.input), "utf8") + : readStdin(); + try { + const useAsync = !!opts.http || (!opts.mapsDir && !existsSync(resolve(process.cwd(), "maps")) && !existsSync(resolve(process.cwd(), "public/maps"))); + const result = useAsync + ? await transliterateAsync(systemCode, inputText) + : transliterate(systemCode, inputText); + if (values.output) { + writeFileSync(resolve(process.cwd(), values.output), result + "\n"); + } + else { + process.stdout.write(result + "\n"); + } + return 0; + } + catch (e) { + process.stderr.write(`Error: ${e.message}\n`); + return 1; + } +} +async function cmdBatch(args, opts) { + const { values, positionals } = parseArgs({ + args, + options: { + output: { type: "string", short: "o" }, + csv: { type: "boolean", default: false }, + }, + allowPositionals: true, + strict: true, + }); + const [systemCode, inputFile] = positionals; + if (!systemCode || !inputFile) { + process.stderr.write("Usage: interscript-ts batch [--csv]\n"); + return 1; + } + if (!existsSync(resolve(process.cwd(), inputFile))) { + process.stderr.write(`Error: input file not found: ${inputFile}\n`); + return 2; + } + reset(); + configure({ strategies: buildStrategies(opts) }); + const lines = readFileSync(resolve(process.cwd(), inputFile), "utf8") + .split(/\r?\n/) + .map((l) => l.trim()) + .filter(Boolean); + const rows = []; + for (const input of lines) { + try { + const output = await transliterateAsync(systemCode, input); + rows.push({ input, output }); + } + catch (e) { + rows.push({ input, output: "", error: e.message }); + } + } + const fmtRow = (r) => values.csv + ? `"${r.input}","${r.output}","${r.error ?? ""}"` + : `${r.input}\t${r.output}${r.error ? `\t⚠ ${r.error}` : ""}`; + const text = rows.map(fmtRow).join("\n") + "\n"; + if (values.output) { + writeFileSync(resolve(process.cwd(), values.output), text); + } + else { + process.stdout.write(text); + } + process.stderr.write(`Processed ${rows.length} lines\n`); + return 0; +} +function cmdList(args, opts) { + const { values } = parseArgs({ + args, + options: { + authority: { type: "string" }, + "source-script": { type: "string" }, + "destination-script": { type: "string" }, + }, + allowPositionals: true, + strict: true, + }); + // List requires a local maps dir — HTTP can't enumerate. + const mapsDir = opts.mapsDir ?? resolve(process.cwd(), "maps"); + if (!existsSync(mapsDir)) { + process.stderr.write(`Error: --maps-dir required (or run from a directory containing ./maps).\n`); + return 2; + } + const entries = loadCatalogue(mapsDir); + const filtered = entries.filter((e) => { + if (!e.metadata) + return true; + if (values.authority && e.metadata.authority_id !== values.authority) + return false; + if (values["source-script"] && e.metadata.source_script !== values["source-script"]) + return false; + if (values["destination-script"] && e.metadata.destination_script !== values["destination-script"]) + return false; + return true; + }); + for (const e of filtered) { + const meta = e.metadata; + const auth = meta?.authority_id ?? "?"; + const pair = meta ? `${meta.source_script}→${meta.destination_script}` : ""; + const name = meta?.name ?? ""; + process.stdout.write(`${e.code}\t${auth}\t${pair}\t${name}\n`); + } + process.stderr.write(`${filtered.length} systems\n`); + return 0; +} +async function cmdDetect(args, opts) { + const { values, positionals } = parseArgs({ + args, + options: { + "max-results": { type: "string", default: "10" }, + }, + allowPositionals: true, + strict: true, + }); + const [input, output] = positionals; + if (!input || !output) { + process.stderr.write("Usage: interscript-ts detect \n"); + return 1; + } + reset(); + configure({ strategies: buildStrategies(opts) }); + const mapsDir = opts.mapsDir ?? resolve(process.cwd(), "maps"); + if (!existsSync(mapsDir)) { + process.stderr.write(`Error: detect needs a local maps directory (--maps-dir).\n`); + return 2; + } + // Detect only works against pre-loaded maps; load them all. + const codes = readdirSync(mapsDir) + .filter((f) => f.endsWith(".json")) + .map((f) => f.replace(/\.json$/, "")); + process.stderr.write(`Loading ${codes.length} maps…\n`); + const results = detect(input, output, {}); + const max = parseInt(values["max-results"], 10); + for (const r of results.slice(0, max)) { + process.stdout.write(`${r.distance}\t${r.mapName}\n`); + } + return 0; +} +function showHelp() { + process.stdout.write(`interscript-ts — transliteration CLI + +Usage: + interscript-ts [options] + +Commands: + transliterate [-i FILE] [-o FILE] Transliterate text (alias: t) + batch [--csv] [-o FILE] Bulk process many lines (alias: b) + list [--authority X] [--source-script X] List available systems (alias: l) + detect Find best-matching system (alias: d) + +Global options: + --maps-dir Directory of .json IR files + --http Load maps from HTTP base URL + --no-cache Skip persistent cache (HTTP loader) + -h, --help Show this help + +Map source resolution (first match wins): + 1. --maps-dir + 2. --http + 3. ./maps/ in the current directory + 4. ./public/maps/ in the current directory + 5. https://interscript.org/maps/ (with cache) + +Examples: + echo "Антон" | interscript-ts t bgnpcgn-ukr-Cyrl-Latn-2019 + interscript-ts t bgnpcgn-ukr-Cyrl-Latn-2019 -i in.txt -o out.txt + interscript-ts b bgnpcgn-ukr-Cyrl-Latn-2019 names.txt --csv > out.csv + interscript-ts l --authority bgnpcgn --source-script Cyrl + interscript-ts d "Антон" "Anton" --maps-dir ./ir +`); +} +async function main() { + const argv = process.argv.slice(2); + if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help") { + showHelp(); + process.exit(argv.length === 0 ? 1 : 0); + } + const command = argv[0]; + const { opts, rest } = parseGlobalOpts(argv.slice(1)); + const aliasMap = { + t: "transliterate", + b: "batch", + l: "list", + d: "detect", + }; + const cmd = aliasMap[command] ?? command; + let exit = 0; + switch (cmd) { + case "transliterate": + exit = await cmdTransliterate(rest, opts); + break; + case "batch": + exit = await cmdBatch(rest, opts); + break; + case "list": + exit = cmdList(rest, opts); + break; + case "detect": + exit = await cmdDetect(rest, opts); + break; + default: + process.stderr.write(`Unknown command: ${command}\n\n`); + showHelp(); + exit = 1; + } + process.exit(exit); +} +await main(); +//# sourceMappingURL=cli.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/cli.js.map b/vendor/interscript-ts/dist/cli.js.map new file mode 100644 index 0000000..6c088dc --- /dev/null +++ b/vendor/interscript-ts/dist/cli.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EACL,SAAS,EACT,KAAK,EACL,aAAa,EACb,kBAAkB,EAClB,MAA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AAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACzC,MAAK;QACP,KAAK,OAAO;YACV,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACjC,MAAK;QACP,KAAK,MAAM;YACT,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAC1B,MAAK;QACP,KAAK,QAAQ;YACX,IAAI,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAClC,MAAK;QACP;YACE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,OAAO,MAAM,CAAC,CAAA;YACvD,QAAQ,EAAE,CAAA;YACV,IAAI,GAAG,CAAC,CAAA;IACZ,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACpB,CAAC;AAED,MAAM,IAAI,EAAE,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/detector.d.ts b/vendor/interscript-ts/dist/detector.d.ts new file mode 100644 index 0000000..b9742ec --- /dev/null +++ b/vendor/interscript-ts/dist/detector.d.ts @@ -0,0 +1,22 @@ +/** + * Detector — finds which transliteration system best explains how + * `input` became `output`. + * + * Mirrors `interscript-ruby/lib/interscript/detector.rb` semantics: + * iterate every known map, transliterate `input` through it, compute + * Levenshtein distance to `output`, return ranked candidates. + */ +import type { DetectionResult, DetectOptions, SystemCode } from "./types.js"; +import type { MapLoader } from "./loader.js"; +/** + * Compute Levenshtein edit distance between two strings. + * Classic dynamic programming, O(m·n) time and O(min(m,n)) space. + */ +export declare function levenshtein(a: string, b: string): number; +/** + * Run detect against every map the loader knows. Caller may pass an + * explicit `knownMaps` iterable to restrict the scan (e.g. a curated + * shortlist for performance). + */ +export declare function detectInMaps(input: string, output: string, loader: MapLoader, opts?: DetectOptions, knownMaps?: Iterable): DetectionResult[]; +//# sourceMappingURL=detector.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/detector.d.ts.map b/vendor/interscript-ts/dist/detector.d.ts.map new file mode 100644 index 0000000..3d3433a --- /dev/null +++ b/vendor/interscript-ts/dist/detector.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAI5C;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAsBxD;AAQD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,GAAE,aAAkB,EACxB,SAAS,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,GAC/B,eAAe,EAAE,CAuBnB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/detector.js b/vendor/interscript-ts/dist/detector.js new file mode 100644 index 0000000..50d6a88 --- /dev/null +++ b/vendor/interscript-ts/dist/detector.js @@ -0,0 +1,73 @@ +/** + * Detector — finds which transliteration system best explains how + * `input` became `output`. + * + * Mirrors `interscript-ruby/lib/interscript/detector.rb` semantics: + * iterate every known map, transliterate `input` through it, compute + * Levenshtein distance to `output`, return ranked candidates. + */ +import { executeStage } from "./runtime/interpreter.js"; +import { InterscriptError } from "./errors.js"; +/** + * Compute Levenshtein edit distance between two strings. + * Classic dynamic programming, O(m·n) time and O(min(m,n)) space. + */ +export function levenshtein(a, b) { + if (a === b) + return 0; + if (a.length === 0) + return b.length; + if (b.length === 0) + return a.length; + let prev = new Array(b.length + 1); + let curr = new Array(b.length + 1); + for (let j = 0; j <= b.length; j++) + prev[j] = j; + for (let i = 1; i <= a.length; i++) { + curr[0] = i; + for (let j = 1; j <= b.length; j++) { + const cost = a[i - 1] === b[j - 1] ? 0 : 1; + curr[j] = Math.min(prev[j] + 1, // deletion + curr[j - 1] + 1, // insertion + prev[j - 1] + cost); + } + ; + [prev, curr] = [curr, prev]; + } + return prev[b.length]; +} +/** Convert a glob (`*` wildcard) into a RegExp. */ +function globToRegExp(pattern) { + const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*"); + return new RegExp(`^${escaped}$`); +} +/** + * Run detect against every map the loader knows. Caller may pass an + * explicit `knownMaps` iterable to restrict the scan (e.g. a curated + * shortlist for performance). + */ +export function detectInMaps(input, output, loader, opts = {}, knownMaps) { + const candidates = []; + const filter = opts.mapPattern ? globToRegExp(opts.mapPattern) : null; + const systems = knownMaps ?? loader.loadedMaps(); + for (const systemCode of systems) { + if (filter && !filter.test(systemCode)) + continue; + let transliterated; + try { + const map = loader.load(systemCode); + transliterated = executeStage(map, "main", input, loader); + } + catch (e) { + if (e instanceof InterscriptError) + continue; + throw e; + } + candidates.push({ + mapName: systemCode, + distance: levenshtein(transliterated, output), + }); + } + return candidates.sort((a, b) => a.distance - b.distance); +} +//# sourceMappingURL=detector.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/detector.js.map b/vendor/interscript-ts/dist/detector.js.map new file mode 100644 index 0000000..e292fed --- /dev/null +++ b/vendor/interscript-ts/dist/detector.js.map @@ -0,0 +1 @@ +{"version":3,"file":"detector.js","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,CAAS,EAAE,CAAS;IAC9C,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAA;IACrB,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAA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E,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAA;AAC3D,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/errors.d.ts b/vendor/interscript-ts/dist/errors.d.ts new file mode 100644 index 0000000..642d519 --- /dev/null +++ b/vendor/interscript-ts/dist/errors.d.ts @@ -0,0 +1,26 @@ +/** + * Typed error hierarchy for Interscript-TS. + * + * Hierarchy is intentionally shallow so callers can rescue a single base + * class or a specific subclass without traversing a deep inheritance tree + * (MECE: each error class has exactly one responsibility). + */ +export declare class InterscriptError extends Error { + readonly cause?: unknown; + constructor(message: string, options?: { + cause?: unknown; + }); +} +export declare class MapNotFoundError extends InterscriptError { + readonly systemCode: string; + constructor(systemCode: string); +} +export declare class SystemConversionError extends InterscriptError { +} +export declare class MapLogicError extends InterscriptError { +} +export declare class DependencyMissingError extends InterscriptError { + readonly dependency: string; + constructor(dependency: string); +} +//# sourceMappingURL=errors.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/errors.d.ts.map b/vendor/interscript-ts/dist/errors.d.ts.map new file mode 100644 index 0000000..070b1dc --- /dev/null +++ b/vendor/interscript-ts/dist/errors.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAkB,KAAK,CAAC,EAAE,OAAO,CAAA;gBAErB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAK3D;AAED,qBAAa,gBAAiB,SAAQ,gBAAgB;IACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;gBACf,UAAU,EAAE,MAAM;CAI/B;AAED,qBAAa,qBAAsB,SAAQ,gBAAgB;CAAG;AAE9D,qBAAa,aAAc,SAAQ,gBAAgB;CAAG;AAEtD,qBAAa,sBAAuB,SAAQ,gBAAgB;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;gBACf,UAAU,EAAE,MAAM;CAI/B"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/errors.js b/vendor/interscript-ts/dist/errors.js new file mode 100644 index 0000000..5419eb0 --- /dev/null +++ b/vendor/interscript-ts/dist/errors.js @@ -0,0 +1,34 @@ +/** + * Typed error hierarchy for Interscript-TS. + * + * Hierarchy is intentionally shallow so callers can rescue a single base + * class or a specific subclass without traversing a deep inheritance tree + * (MECE: each error class has exactly one responsibility). + */ +export class InterscriptError extends Error { + cause; + constructor(message, options) { + super(message, options); + this.name = new.target.name; + this.cause = options?.cause; + } +} +export class MapNotFoundError extends InterscriptError { + systemCode; + constructor(systemCode) { + super(`Map not found: ${systemCode}`); + this.systemCode = systemCode; + } +} +export class SystemConversionError extends InterscriptError { +} +export class MapLogicError extends InterscriptError { +} +export class DependencyMissingError extends InterscriptError { + dependency; + constructor(dependency) { + super(`Map dependency missing: ${dependency}`); + this.dependency = dependency; + } +} +//# sourceMappingURL=errors.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/errors.js.map b/vendor/interscript-ts/dist/errors.js.map new file mode 100644 index 0000000..82a5300 --- /dev/null +++ b/vendor/interscript-ts/dist/errors.js.map @@ -0,0 +1 @@ +{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACvB,KAAK,CAAU;IAEjC,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,CAAA;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,gBAAgB;IAC3C,UAAU,CAAQ;IAC3B,YAAY,UAAkB;QAC5B,KAAK,CAAC,kBAAkB,UAAU,EAAE,CAAC,CAAA;QACrC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,gBAAgB;CAAG;AAE9D,MAAM,OAAO,aAAc,SAAQ,gBAAgB;CAAG;AAEtD,MAAM,OAAO,sBAAuB,SAAQ,gBAAgB;IACjD,UAAU,CAAQ;IAC3B,YAAY,UAAkB;QAC5B,KAAK,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAA;QAC9C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/http-loader.d.ts b/vendor/interscript-ts/dist/http-loader.d.ts new file mode 100644 index 0000000..8562af1 --- /dev/null +++ b/vendor/interscript-ts/dist/http-loader.d.ts @@ -0,0 +1,42 @@ +/** + * HTTP map loading strategy — fetches map IR from a base URL on demand. + * + * Browser-safe: uses the global `fetch()`. Suitable for browser bundles, + * Cloudflare Workers, Deno, Bun. Node 18+ also has global fetch. + * + * Two-tier caching: in-memory (instant) + optional persistent via + * localStorage (survives reloads). Set `cacheKeyPrefix` to enable. + */ +import type { LoadStrategy, SystemCode } from "./index.js"; +export interface HttpStrategyOptions { + /** + * Base URL or function returning a URL for a given system code. + * Defaults to `/maps/${code}.json` (works with the interscript.org + * deployment). + */ + readonly baseUrl?: string | ((code: SystemCode) => string); + /** + * Optional request init passed to fetch() (headers, mode, etc.). + */ + readonly fetchInit?: RequestInit; + /** + * Persistent cache prefix. When set, fetched maps are stored in + * localStorage so they survive page reloads. Disabled by default. + */ + readonly cacheKeyPrefix?: string; +} +/** + * Strategy that fetches map IR over HTTP on demand. + * + * Async: returns a Promise. Use `MapLoader.loadAsync()` or + * `InterscriptRuntime.transliterate()` (which auto-awaits async + * strategies when present). + * + * Caching: + * - In-memory: every fetched map stays in the loader's cache for + * the lifetime of the page/process. + * - Persistent: optional localStorage cache (set `cacheKeyPrefix`) + * so maps don't re-fetch on subsequent visits. + */ +export declare function httpStrategy(options?: HttpStrategyOptions): LoadStrategy; +//# sourceMappingURL=http-loader.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/http-loader.d.ts.map b/vendor/interscript-ts/dist/http-loader.d.ts.map new file mode 100644 index 0000000..397c83c --- /dev/null +++ b/vendor/interscript-ts/dist/http-loader.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"http-loader.d.ts","sourceRoot":"","sources":["../src/http-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAgC,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGxF,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC,CAAA;IAC1D;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAA;IAChC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CACjC;AA2CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CA6B5E"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/http-loader.js b/vendor/interscript-ts/dist/http-loader.js new file mode 100644 index 0000000..088749b --- /dev/null +++ b/vendor/interscript-ts/dist/http-loader.js @@ -0,0 +1,95 @@ +/** + * HTTP map loading strategy — fetches map IR from a base URL on demand. + * + * Browser-safe: uses the global `fetch()`. Suitable for browser bundles, + * Cloudflare Workers, Deno, Bun. Node 18+ also has global fetch. + * + * Two-tier caching: in-memory (instant) + optional persistent via + * localStorage (survives reloads). Set `cacheKeyPrefix` to enable. + */ +import { normaliseMap } from "./loaders.js"; +const MAX_CACHE_AGE_MS = 30 * 24 * 60 * 60 * 1000; // 30 days +function resolveUrl(code, baseUrl) { + if (typeof baseUrl === "function") + return baseUrl(code); + if (baseUrl) + return baseUrl.replace(/\/$/, "") + "/" + code + ".json"; + return `/maps/${code}.json`; +} +function readPersistent(prefix, code) { + if (typeof localStorage === "undefined") + return undefined; + try { + const raw = localStorage.getItem(prefix + code); + if (!raw) + return undefined; + const entry = JSON.parse(raw); + if (Date.now() - entry.fetchedAt > MAX_CACHE_AGE_MS) + return undefined; + return entry; + } + catch { + return undefined; + } +} +function writePersistent(prefix, code, json) { + if (typeof localStorage === "undefined") + return; + try { + const entry = { + schemaVersion: 1, + fetchedAt: Date.now(), + json, + }; + localStorage.setItem(prefix + code, JSON.stringify(entry)); + } + catch { + // Quota exceeded or serialization failure — silently drop. + } +} +/** + * Strategy that fetches map IR over HTTP on demand. + * + * Async: returns a Promise. Use `MapLoader.loadAsync()` or + * `InterscriptRuntime.transliterate()` (which auto-awaits async + * strategies when present). + * + * Caching: + * - In-memory: every fetched map stays in the loader's cache for + * the lifetime of the page/process. + * - Persistent: optional localStorage cache (set `cacheKeyPrefix`) + * so maps don't re-fetch on subsequent visits. + */ +export function httpStrategy(options = {}) { + const inMemory = new Map(); + return async (systemCode) => { + const cached = inMemory.get(systemCode); + if (cached) + return cached; + if (options.cacheKeyPrefix) { + const entry = readPersistent(options.cacheKeyPrefix, systemCode); + if (entry) { + const map = normaliseMap(entry.json); + inMemory.set(systemCode, map); + return map; + } + } + const url = resolveUrl(systemCode, options.baseUrl); + let res; + try { + res = await fetch(url, options.fetchInit); + } + catch { + return undefined; + } + if (!res.ok) + return undefined; + const json = (await res.json()); + if (options.cacheKeyPrefix) + writePersistent(options.cacheKeyPrefix, systemCode, json); + const map = normaliseMap(json); + inMemory.set(systemCode, map); + return map; + }; +} +//# sourceMappingURL=http-loader.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/http-loader.js.map b/vendor/interscript-ts/dist/http-loader.js.map new file mode 100644 index 0000000..5a1fea9 --- /dev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G,CAAC,IAAI,EAAE,CAAoB,CAAA;QAClD,IAAI,OAAO,CAAC,cAAc;YAAE,eAAe,CAAC,OAAO,CAAC,cAAc,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;QACrF,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QAC9B,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;QAC7B,OAAO,GAAG,CAAA;IACZ,CAAC,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/index.d.ts b/vendor/interscript-ts/dist/index.d.ts new file mode 100644 index 0000000..3bbe525 --- /dev/null +++ b/vendor/interscript-ts/dist/index.d.ts @@ -0,0 +1,49 @@ +/** + * Public API surface of Interscript-TS. + * + * Mirrors `interscript-ruby/lib/interscript.rb`: + * - transliterate(systemCode, input) + * - loadMap(systemCode) + * - detect(input, output) + * + * The runtime is configured with a MapLoader. Callers can supply their + * own (e.g. for browser fetch, for fs reads) without modifying the + * interpreter (OCP). + */ +import type { CompiledMap, DetectionResult, DetectOptions, SystemCode } from "./types.js"; +import { type LoadStrategy } from "./loader.js"; +export { InterscriptError, MapNotFoundError, SystemConversionError, DependencyMissingError, MapLogicError, } from "./errors.js"; +export type { CompiledMap, CompiledMapJson, DetectionResult, DetectOptions, FunctionDef, MapInfo, SystemCode, Stage, Rule, Item, SubRule, RunRule, FuncallRule, ParallelRule, SequentialRule, StringItem, CaptureGroupItem, CaptureRefItem, AliasItem, AnyItem, GroupItem, RepeatItem, StageItem, } from "./types.js"; +export type { LoadStrategy, MapLoader } from "./loader.js"; +export { normaliseMap, bundledStrategy } from "./loaders.js"; +export { httpStrategy, type HttpStrategyOptions } from "./http-loader.js"; +export { iscStrategy, iscBundledStrategy, type IscStrategyOptions } from "./isc/loader.js"; +export type { IscDocument, IscItem, IscRule, IscStage, IscStageItem, IscTest, IscConstraint } from "./isc/types.js"; +export { parseIsc } from "./isc/parser.js"; +export { IscParseError } from "./isc/types.js"; +export { iscToCompiledMap } from "./isc/converter.js"; +export { setRababaConfig, resetRababaConfigs, type RababaConfigEntry, } from "./stdlib/ml.js"; +export interface InterscriptConfig { + /** Strategies consulted in order when loading a map. */ + readonly strategies?: LoadStrategy[]; + /** Default stage to execute if not specified. Default: "main". */ + readonly defaultStage?: string; +} +/** Configure the default runtime with custom strategies. */ +export declare function configure(config: InterscriptConfig): void; +/** Public API — mirrors Interscript.transliterate from Ruby. */ +export declare function transliterate(systemCode: SystemCode, input: string, stage?: string): string; +/** + * Async transliterate. Use when async strategies (httpStrategy) are + * configured and the map may not be in the cache yet. + */ +export declare function transliterateAsync(systemCode: SystemCode, input: string, stage?: string): Promise; +/** Public API — mirrors Interscript.load. */ +export declare function loadMap(systemCode: SystemCode): CompiledMap; +/** Async version — needed when async strategies may be used. */ +export declare function loadMapAsync(systemCode: SystemCode): Promise; +/** Public API — mirrors Interscript.detect. */ +export declare function detect(input: string, output: string, opts?: DetectOptions): DetectionResult[]; +/** Reset the default runtime (mainly for tests). */ +export declare function reset(): void; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/index.d.ts.map b/vendor/interscript-ts/dist/index.d.ts.map new file mode 100644 index 0000000..a261bed --- /dev/null +++ b/vendor/interscript-ts/dist/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACX,MAAM,YAAY,CAAA;AACnB,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAU1D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,GACd,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,WAAW,EACX,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,OAA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AM,CAE3F;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,CAE3D;AAED,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAEzE;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,aAAa,GACnB,eAAe,EAAE,CAEnB;AAED,oDAAoD;AACpD,wBAAgB,KAAK,IAAI,IAAI,CAE5B"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/index.js b/vendor/interscript-ts/dist/index.js new file mode 100644 index 0000000..7fb67f8 --- /dev/null +++ b/vendor/interscript-ts/dist/index.js @@ -0,0 +1,182 @@ +/** + * Public API surface of Interscript-TS. + * + * Mirrors `interscript-ruby/lib/interscript.rb`: + * - transliterate(systemCode, input) + * - loadMap(systemCode) + * - detect(input, output) + * + * The runtime is configured with a MapLoader. Callers can supply their + * own (e.g. for browser fetch, for fs reads) without modifying the + * interpreter (OCP). + */ +import { MapLoader } from "./loader.js"; +import { executeStage, executeStageAsync } from "./runtime/interpreter.js"; +import { DependencyMissingError, InterscriptError, MapNotFoundError, SystemConversionError, } from "./errors.js"; +import { detectInMaps } from "./detector.js"; +export { InterscriptError, MapNotFoundError, SystemConversionError, DependencyMissingError, MapLogicError, } from "./errors.js"; +// Only re-export browser-safe loaders from the main entry. Filesystem +// strategies live in `./loaders.node.ts` and pull in `node:fs`; importing +// them via the main entry would break browser bundles. Node callers +// (CLI, server tests) should import directly from `./loaders.node.js`. +export { normaliseMap, bundledStrategy } from "./loaders.js"; +export { httpStrategy } from "./http-loader.js"; +export { iscStrategy, iscBundledStrategy } from "./isc/loader.js"; +export { parseIsc } from "./isc/parser.js"; +export { IscParseError } from "./isc/types.js"; +export { iscToCompiledMap } from "./isc/converter.js"; +export { setRababaConfig, resetRababaConfigs, } from "./stdlib/ml.js"; +const DEFAULT_STAGE = "main"; +class InterscriptRuntime { + loader; + defaultStage; + constructor(config = {}) { + this.loader = new MapLoader(config.strategies ?? []); + this.defaultStage = config.defaultStage ?? DEFAULT_STAGE; + } + /** + * Pre-load a map so subsequent transliterate() calls are fast. + * Throws MapNotFoundError if the map can't be located. + */ + loadMap(systemCode) { + const map = this.loader.load(systemCode); + for (const dep of map.dependencies) { + try { + this.loader.load(dep); + } + catch (e) { + if (e instanceof MapNotFoundError) { + throw new DependencyMissingError(dep); + } + throw e; + } + } + return map; + } + /** + * Async pre-load. Required when async strategies (HTTP) are configured + * and the map isn't already cached. + * + * Recursively loads all transitive dependencies so the synchronous + * execution path can resolve deps without awaiting. + */ + async loadMapAsync(systemCode) { + const map = await this.loader.loadAsync(systemCode); + // Recursively load every transitive dep. The synchronous executor + // calls loader.load() during execution and can't await async + // strategies — so we preload the entire closure upfront. + const seen = new Set(); + const queue = [...map.dependencies]; + while (queue.length > 0) { + const dep = queue.shift(); + if (seen.has(dep)) + continue; + seen.add(dep); + try { + const depMap = await this.loader.loadAsync(dep); + for (const d of depMap.dependencies) { + if (!seen.has(d)) + queue.push(d); + } + } + catch (e) { + if (e instanceof MapNotFoundError) { + throw new DependencyMissingError(dep); + } + throw e; + } + } + return map; + } + /** + * Transliterate `input` using `systemCode`. Loads the map on first use, + * caches it. + */ + transliterate(systemCode, input, stage) { + try { + const map = this.loadMap(systemCode); + const stageName = stage ?? this.defaultStage; + return executeStage(map, stageName, input, this.loader); + } + catch (e) { + if (e instanceof InterscriptError) + throw e; + throw new SystemConversionError(`Transliteration failed for ${systemCode}: ${e.message}`, { cause: e }); + } + } + /** + * Async transliterate. Required when the configured strategies include + * async loaders (e.g. httpStrategy) and the map may not be cached. + * Also handles ML-powered maps (rababa, secryst) — use this instead + * of transliterate() for any map that might contain ML funcalls. + */ + async transliterateAsync(systemCode, input, stage) { + try { + const map = await this.loadMapAsync(systemCode); + const stageName = stage ?? this.defaultStage; + return await executeStageAsync(map, stageName, input, this.loader); + } + catch (e) { + if (e instanceof InterscriptError) + throw e; + throw new SystemConversionError(`Transliteration failed for ${systemCode}: ${e.message}`, { cause: e }); + } + } + /** List all maps currently loaded in the cache. */ + loadedMaps() { + return this.loader.loadedMaps(); + } + /** Direct loader access (for detector + advanced use). */ + getLoader() { + return this.loader; + } + /** + * Detect which transliteration system best explains how `input` became + * `output`. Returns candidates ranked by edit distance. + * + * Iterates every loaded map; for large map sets, supply `mapPattern` + * to pre-filter. + */ + detect(input, output, opts = {}, knownMaps) { + return detectInMaps(input, output, this.loader, opts, knownMaps); + } +} +let defaultRuntime; +/** Configure the default runtime with custom strategies. */ +export function configure(config) { + defaultRuntime = new InterscriptRuntime(config); +} +function runtime() { + if (!defaultRuntime) { + defaultRuntime = new InterscriptRuntime(); + } + return defaultRuntime; +} +/** Public API — mirrors Interscript.transliterate from Ruby. */ +export function transliterate(systemCode, input, stage) { + return runtime().transliterate(systemCode, input, stage); +} +/** + * Async transliterate. Use when async strategies (httpStrategy) are + * configured and the map may not be in the cache yet. + */ +export function transliterateAsync(systemCode, input, stage) { + return runtime().transliterateAsync(systemCode, input, stage); +} +/** Public API — mirrors Interscript.load. */ +export function loadMap(systemCode) { + return runtime().loadMap(systemCode); +} +/** Async version — needed when async strategies may be used. */ +export function loadMapAsync(systemCode) { + return runtime().loadMapAsync(systemCode); +} +/** Public API — mirrors Interscript.detect. */ +export function detect(input, output, opts) { + return runtime().detect(input, output, opts); +} +/** Reset the default runtime (mainly for tests). */ +export function reset() { + defaultRuntime = undefined; +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/index.js.map b/vendor/interscript-ts/dist/index.js.map new file mode 100644 index 0000000..a03620e --- /dev/null +++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AC5C,OAAO,OAAO,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;AACtC,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,YAAY,CAAC,UAAsB;IACjD,OAAO,OAAO,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;AAC3C,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,MAAM,CACpB,KAAa,EACb,MAAc,EACd,IAAoB;IAEpB,OAAO,OAAO,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;AAC9C,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,KAAK;IACnB,cAAc,GAAG,SAAS,CAAA;AAC5B,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/converter.d.ts b/vendor/interscript-ts/dist/isc/converter.d.ts new file mode 100644 index 0000000..2d2385e --- /dev/null +++ b/vendor/interscript-ts/dist/isc/converter.d.ts @@ -0,0 +1,11 @@ +/** + * Converts an IscDocument (parsed from .isc source) to a CompiledMapJson + * (the runtime representation consumed by the existing TS runtime). + * + * This bridges the ISC parser output to the existing runtime without + * modifying any runtime code (OCP). + */ +import type { IscDocument } from "./types.js"; +import type { CompiledMapJson } from "../types.js"; +export declare function iscToCompiledMap(doc: IscDocument): CompiledMapJson; +//# sourceMappingURL=converter.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/converter.d.ts.map b/vendor/interscript-ts/dist/isc/converter.d.ts.map new file mode 100644 index 0000000..9b0d604 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/converter.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"converter.d.ts","sourceRoot":"","sources":["../../src/isc/converter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,YAAY,CAAA;AAC7E,OAAO,KAAK,EAMV,eAAe,EAahB,MAAM,aAAa,CAAA;AAEpB,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,GAAG,eAAe,CAgClE"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/converter.js b/vendor/interscript-ts/dist/isc/converter.js new file mode 100644 index 0000000..c27cc54 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/converter.js @@ -0,0 +1,175 @@ +/** + * Converts an IscDocument (parsed from .isc source) to a CompiledMapJson + * (the runtime representation consumed by the existing TS runtime). + * + * This bridges the ISC parser output to the existing runtime without + * modifying any runtime code (OCP). + */ +export function iscToCompiledMap(doc) { + const aliases = {}; + for (const a of doc.aliases) { + aliases[a.name] = convertItem(a.value); + } + // Build alias → target system code map for run-rule resolution. + const depAliases = new Map(); + for (const d of doc.dependencies) { + if (d.aliasName) + depAliases.set(d.aliasName, d.target); + } + const resolveDep = (name) => depAliases.get(name) ?? name; + const stages = doc.stages.map((s) => convertStage(s, resolveDep)); + if (Object.keys(doc.metadata).length === 0) { + return { + schemaVersion: 1, + systemCode: doc.systemCode, + dependencies: doc.dependencies.map((d) => d.target), + stages, + aliases, + functions: {}, + }; + } + return { + schemaVersion: 1, + systemCode: doc.systemCode, + dependencies: doc.dependencies.map((d) => d.target), + metadata: doc.metadata, + stages, + aliases, + functions: {}, + }; +} +function convertStage(stage, resolveDep) { + return { + kind: "stage", + name: stage.name, + rules: stage.body.map((item) => convertStageItem(item, resolveDep)), + }; +} +function convertStageItem(item, resolveDep) { + switch (item.kind) { + case "parallel": { + const r = { kind: "parallel", rules: item.rules.map(convertRule) }; + return r; + } + case "sequence": { + const r = { kind: "sequential", rules: item.rules.map(convertRule) }; + return r; + } + case "bare_rule": + return convertRule(item.rule); + case "run": { + const r = item.dependency + ? { kind: "run", stage: item.stage, docName: resolveDep(item.dependency) } + : { kind: "run", stage: item.stage }; + return r; + } + case "separate": { + if (item.separator && item.separator.type === "string") { + const r = { kind: "funcall", name: "separate", kwargs: { separator: item.separator.value } }; + return r; + } + const r = { kind: "funcall", name: "separate" }; + return r; + } + case "compose": { + const r = { kind: "funcall", name: "compose" }; + return r; + } + case "decompose": { + const r = { kind: "funcall", name: "decompose" }; + return r; + } + case "string_case": { + const r = { kind: "funcall", name: item.op }; + return r; + } + case "funcall": { + const r = { kind: "funcall", name: item.name, kwargs: item.kwargs }; + return r; + } + } +} +function convertRule(rule) { + const before = findConstraint(rule, "before"); + const after = findConstraint(rule, "after"); + const notBefore = findConstraint(rule, "not_before"); + const notAfter = findConstraint(rule, "not_after"); + // `to` may be a function (upcase/downcase/title_case/etc.) — represented + // as FuncallInline rather than an Item. + const toItem = rule.to; + const to = toItem.type === "function" + ? { kind: "funcall_inline", name: toItem.name } + : convertItem(toItem); + const r = { + kind: "sub", + from: convertItem(rule.from), + to, + ...(before !== undefined ? { before } : {}), + ...(after !== undefined ? { after } : {}), + ...(notBefore !== undefined ? { notBefore } : {}), + ...(notAfter !== undefined ? { notAfter } : {}), + }; + return r; +} +function findConstraint(rule, kind) { + const c = rule.constraints.find((x) => x.kind === kind); + return c ? convertItem(c.item) : undefined; +} +function convertItem(item) { + switch (item.type) { + case "string": { + const r = { kind: "string", value: item.value }; + return r; + } + case "none": { + const r = { kind: "string", value: "" }; + return r; + } + case "primitive": { + const r = { kind: "alias", name: item.name }; + return r; + } + case "function": { + // Functions in non-`to` positions are unexpected — fall back to alias + // lookup so a clear error surfaces at runtime. + const r = { kind: "alias", name: item.name }; + return r; + } + case "alias_ref": { + const r = { kind: "alias", name: item.name }; + return r; + } + case "capture": { + const r = { kind: "capture_ref", id: item.index }; + return r; + } + case "capture_group": { + const r = { kind: "capture_group", data: convertItem(item.inner) }; + return r; + } + case "concat": { + const parts = item.parts.map(convertItem); + if (parts.length === 1) + return parts[0]; + const r = { kind: "group", items: parts }; + return r; + } + case "set": { + const r = { kind: "any", of: item.items.map(convertItem) }; + return r; + } + case "range": { + const r = { kind: "any_char_class", range: [item.lo, item.hi] }; + return r; + } + case "maybe": { + const r = { kind: "repeat", item: convertItem(item.inner), min: 0, max: 1 }; + return r; + } + case "some": { + const r = { kind: "repeat", item: convertItem(item.inner), min: 1, max: null }; + return r; + } + } +} +//# sourceMappingURL=converter.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/converter.js.map b/vendor/interscript-ts/dist/isc/converter.js.map new file mode 100644 index 0000000..24d4dc0 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/converter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"converter.js","sourceRoot":"","sources":["../../src/isc/converter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwBH,MAAM,UAAU,gBAAgB,CAAC,GAAgB;IAC/C,MAAM,OAAO,GAAyB,EAAE,CAAA;IACxC,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAC5B,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACxC,CAAC;IACD,gEAAgE;IAChE,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAA;IAC5C,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;QACjC,IAAI,CAAC,CAAC,SAAS;YAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC;IACD,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;IACzE,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAA;IAEjE,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO;YACL,aAAa,EAAE,CAAC;YAChB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1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AAO,CAAC,CAAA;QACV,CAAC;QACD,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,CAAC,GAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAA;YACvF,OAAO,CAAC,CAAA;QACV,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,CAAC,GAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAA;YAC1F,OAAO,CAAC,CAAA;QACV,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/index.d.ts b/vendor/interscript-ts/dist/isc/index.d.ts new file mode 100644 index 0000000..3f6dc8a --- /dev/null +++ b/vendor/interscript-ts/dist/isc/index.d.ts @@ -0,0 +1,16 @@ +/** + * ISC module — parse .isc source files directly, no JSON IR needed. + * + * Public API: + * import { parseIsc } from "interscript-ts/isc" + * const doc = parseIsc(source, "map.isc") + * + * import { iscStrategy } from "interscript-ts/isc" + * configure({ strategies: [iscStrategy({ baseUrl: "/maps" })] }) + */ +export { parseIsc } from "./parser.js"; +export { iscToCompiledMap } from "./converter.js"; +export { iscStrategy, iscBundledStrategy } from "./loader.js"; +export type { IscDocument, IscItem, IscRule, IscStage, IscStageItem, IscTest, IscConstraint, } from "./types.js"; +export { IscParseError } from "./types.js"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/index.d.ts.map b/vendor/interscript-ts/dist/isc/index.d.ts.map new file mode 100644 index 0000000..4ac1bdf --- /dev/null +++ b/vendor/interscript-ts/dist/isc/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/isc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC7D,YAAY,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,aAAa,GACd,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/index.js b/vendor/interscript-ts/dist/isc/index.js new file mode 100644 index 0000000..2d4c04a --- /dev/null +++ b/vendor/interscript-ts/dist/isc/index.js @@ -0,0 +1,15 @@ +/** + * ISC module — parse .isc source files directly, no JSON IR needed. + * + * Public API: + * import { parseIsc } from "interscript-ts/isc" + * const doc = parseIsc(source, "map.isc") + * + * import { iscStrategy } from "interscript-ts/isc" + * configure({ strategies: [iscStrategy({ baseUrl: "/maps" })] }) + */ +export { parseIsc } from "./parser.js"; +export { iscToCompiledMap } from "./converter.js"; +export { iscStrategy, iscBundledStrategy } from "./loader.js"; +export { IscParseError } from "./types.js"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/index.js.map b/vendor/interscript-ts/dist/isc/index.js.map new file mode 100644 index 0000000..4032a7c --- /dev/null +++ b/vendor/interscript-ts/dist/isc/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/isc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAU7D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/loader.d.ts b/vendor/interscript-ts/dist/isc/loader.d.ts new file mode 100644 index 0000000..c415705 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/loader.d.ts @@ -0,0 +1,22 @@ +/** + * ISC loader strategy — fetches .isc source files and feeds them to the + * ISC parser + converter, producing CompiledMap objects for the runtime. + * + * configure({ strategies: [iscStrategy({ baseUrl: "/maps" })] }) + */ +import type { LoadStrategy } from "../loader.js"; +export interface IscStrategyOptions { + /** Base URL for fetching .isc files, e.g. "/maps" */ + baseUrl: string; + /** Fetch function (defaults to global fetch) */ + readonly fetchFn?: typeof fetch; + /** Pre-loaded ISC sources: { "system-code": "isc source text" } */ + readonly bundled?: Record; +} +export declare function iscStrategy(opts: IscStrategyOptions): LoadStrategy; +/** + * Synchronous strategy for pre-loaded ISC sources. + * Use in Node.js (read files from disk) or with bundled sources. + */ +export declare function iscBundledStrategy(sources: Record): LoadStrategy; +//# sourceMappingURL=loader.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/loader.d.ts.map b/vendor/interscript-ts/dist/isc/loader.d.ts.map new file mode 100644 index 0000000..4a716b6 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/loader.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/isc/loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAKhD,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAA;IACf,gDAAgD;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,CAAA;IAC/B,mEAAmE;IACnE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,YAAY,CAwBlE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAQhF"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/loader.js b/vendor/interscript-ts/dist/isc/loader.js new file mode 100644 index 0000000..ffe23a0 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/loader.js @@ -0,0 +1,47 @@ +/** + * ISC loader strategy — fetches .isc source files and feeds them to the + * ISC parser + converter, producing CompiledMap objects for the runtime. + * + * configure({ strategies: [iscStrategy({ baseUrl: "/maps" })] }) + */ +import { parseIsc } from "./parser.js"; +import { iscToCompiledMap } from "./converter.js"; +import { normaliseMap } from "../loaders.js"; +export function iscStrategy(opts) { + const fetchFn = opts.fetchFn ?? fetch.bind(globalThis); + return async (code) => { + let source; + if (opts.bundled && opts.bundled[code]) { + source = opts.bundled[code]; + } + if (!source) { + try { + const res = await fetchFn(`${opts.baseUrl}/${code}.isc`); + if (!res.ok) + return undefined; + source = await res.text(); + } + catch { + return undefined; + } + } + const doc = parseIsc(source, `${code}.isc`); + const json = iscToCompiledMap(doc); + return normaliseMap(json); + }; +} +/** + * Synchronous strategy for pre-loaded ISC sources. + * Use in Node.js (read files from disk) or with bundled sources. + */ +export function iscBundledStrategy(sources) { + return (code) => { + const source = sources[code]; + if (!source) + return undefined; + const doc = parseIsc(source, `${code}.isc`); + const json = iscToCompiledMap(doc); + return normaliseMap(json); + }; +} +//# sourceMappingURL=loader.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/loader.js.map b/vendor/interscript-ts/dist/isc/loader.js.map new file mode 100644 index 0000000..137b867 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/loader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/isc/loader.ts"],"names":[],"mappings":"AAAA;;;;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C,MAAM;YAAE,OAAO,SAAS,CAAA;QAC7B,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,CAAA;QAC3C,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAClC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/parser.d.ts b/vendor/interscript-ts/dist/isc/parser.d.ts new file mode 100644 index 0000000..8f86182 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/parser.d.ts @@ -0,0 +1,14 @@ +/** + * ISC parser — recursive descent parser for ISC format. + * + * Parses .isc source text into an IscDocument. No external dependencies. + * Each construct has its own parse method (OCP: new construct = new method). + * + * The grammar mirrors the Ruby Parslet grammar in interscript-ruby. + * + * const doc = parseIsc(source, "map.isc") + * // doc.systemCode, doc.metadata, doc.tests, doc.stages, ... + */ +import type { IscDocument } from "./types.js"; +export declare function parseIsc(source: string, filename?: string): IscDocument; +//# sourceMappingURL=parser.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/parser.d.ts.map b/vendor/interscript-ts/dist/isc/parser.d.ts.map new file mode 100644 index 0000000..c35317d --- /dev/null +++ b/vendor/interscript-ts/dist/isc/parser.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/isc/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,WAAW,EAOZ,MAAM,YAAY,CAAA;AAcnB,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,CAEvE"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/parser.js b/vendor/interscript-ts/dist/isc/parser.js new file mode 100644 index 0000000..9fd16f7 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/parser.js @@ -0,0 +1,732 @@ +/** + * ISC parser — recursive descent parser for ISC format. + * + * Parses .isc source text into an IscDocument. No external dependencies. + * Each construct has its own parse method (OCP: new construct = new method). + * + * The grammar mirrors the Ruby Parslet grammar in interscript-ruby. + * + * const doc = parseIsc(source, "map.isc") + * // doc.systemCode, doc.metadata, doc.tests, doc.stages, ... + */ +import { IscParseError } from "./types.js"; +const PRIMITIVES = new Set([ + "boundary", "line_start", "line_end", "word_boundary", + "space", "non_boundary", +]); +const FUNCTIONS = new Set([ + "upcase", "downcase", "title_case", "reverse", "strip", "swapcase", +]); +const CONSTRAINTS = new Set(["before", "after", "not_before", "not_after"]); +export function parseIsc(source, filename) { + return new Parser(source, filename).parse(); +} +class Parser { + src; + pos = 0; + filename; + constructor(src, filename) { + this.src = src; + this.filename = filename; + } + parse() { + this.skipWs(); + this.expect("system"); + this.skipWs(); + const systemCode = this.parseQuotedString(); + this.skipWs(); + this.expect("{"); + const body = this.parseBlockItems(); + this.skipWs(); + this.expect("}"); + this.skipWs(); + let metadata = {}; + let tests = []; + let aliases = []; + let stages = []; + let dependencies = []; + for (const item of body) { + if (item.metadata) + metadata = { ...metadata, ...item.metadata }; + else if (item.tests) + tests = item.tests; + else if (item.aliases) + aliases = item.aliases; + else if (item.stage) + stages.push(item.stage); + else if (item.dependency) + dependencies.push(item.dependency); + } + return { systemCode, metadata, tests, aliases, stages, dependencies }; + } + // -- Block items -- + parseBlockItems() { + const items = []; + for (;;) { + this.skipWs(); + if (this.peek() === "}" || this.pos >= this.src.length) + break; + const keyword = this.peekWord(); + if (keyword === "metadata") + items.push(this.parseMetadata()); + else if (keyword === "tests") + items.push(this.parseTests()); + else if (keyword === "aliases") + items.push(this.parseAliases()); + else if (keyword === "stage") + items.push(this.parseStage()); + else if (keyword === "dependency") + items.push(this.parseDependency()); + else + this.error(`Unexpected keyword: ${keyword}`); + } + return items; + } + // -- Metadata -- + parseMetadata() { + this.expect("metadata"); + this.skipWs(); + this.expect("{"); + const metadata = {}; + for (;;) { + this.skipWs(); + if (this.peek() === "}") + break; + // Check for description block + if (this.peekWord() === "description") { + this.consume("description"); + this.skipInlineWs(); + if (this.peek() === "{") { + this.expect("{"); + const text = this.parseRawText(); + this.expect("}"); + metadata.description = text; + } + else if (this.peek() === '"') { + metadata.description = this.parseQuotedString(); + } + else { + metadata.description = this.parseToNewline().trim(); + } + continue; + } + // Check for notes block + if (this.peekWord() === "notes") { + this.consume("notes"); + this.skipInlineWs(); + if (this.peek() === "{") { + this.expect("{"); + // Detect form: if first non-ws token is `note`, use note-list form. + // Otherwise, treat block body as raw free-text. + const saved = this.pos; + this.skipWs(); + const isNoteList = this.peekWord() === "note"; + this.pos = saved; + if (isNoteList) { + const notes = []; + for (;;) { + this.skipWs(); + if (this.peek() === "}") + break; + this.expect("note"); + this.skipWs(); + notes.push(this.parseQuotedString()); + } + this.expect("}"); + metadata.notes = notes; + } + else { + const text = this.parseRawText(); + this.expect("}"); + metadata.notes = text; + } + } + continue; + } + // Generic field: key value + const key = this.parseIdentifier(); + this.skipInlineWs(); + if (this.peek() === "\n" || this.peek() === "}") { + metadata[key] = ""; + continue; + } + if (this.peek() === "{") { + this.expect("{"); + const blockText = this.parseRawText(); + this.expect("}"); + metadata[key] = blockText; + } + else if (this.peek() === '"') { + metadata[key] = this.parseQuotedString(); + } + else { + metadata[key] = this.parseToNewline().trim(); + } + } + this.expect("}"); + return { metadata }; + } + // -- Tests -- + parseTests() { + this.expect("tests"); + this.skipWs(); + this.expect("{"); + const tests = []; + for (;;) { + this.skipWs(); + if (this.peek() === "}") + break; + if (this.peek() === "#") { + this.skipLine(); + continue; + } + const input = this.parseStringLiteral(); + this.skipWs(); + this.expect("->"); + this.skipWs(); + const expected = this.parseStringLiteral(); + this.skipWs(); + if (this.peekWord() === "note") { + this.consume("note"); + this.skipWs(); + const note = this.parseStringLiteral(); + tests.push({ input, expected, note }); + } + else { + tests.push({ input, expected }); + } + } + this.expect("}"); + return { tests }; + } + // -- Aliases -- + parseAliases() { + this.expect("aliases"); + this.skipWs(); + this.expect("{"); + const aliases = []; + for (;;) { + this.skipWs(); + if (this.peek() === "}") + break; + if (this.peek() === "#") { + this.skipLine(); + continue; + } + const name = this.parseIdentifier(); + this.skipWs(); + this.expect("="); + this.skipWs(); + const value = this.parseItem(); + aliases.push({ name, value }); + } + this.expect("}"); + return { aliases }; + } + // -- Stage -- + parseStage() { + this.expect("stage"); + this.skipWs(); + const name = this.parseIdentifier(); + this.skipWs(); + this.expect("{"); + const body = []; + for (;;) { + this.skipWs(); + if (this.peek() === "}") + break; + if (this.peek() === "#") { + this.skipLine(); + continue; + } + const keyword = this.peekWord(); + if (keyword === "parallel" || keyword === "sequence") { + this.consume(keyword); + this.skipWs(); + this.expect("{"); + const rules = []; + for (;;) { + this.skipWs(); + if (this.peek() === "}") + break; + if (this.peek() === "#") { + this.skipLine(); + continue; + } + if (this.peekWord() === "sub") { + rules.push(this.parseRule()); + } + else { + // Ruby Parslet silently drops unrecognized tokens in rule blocks. + this.skipLine(); + } + } + this.expect("}"); + body.push({ kind: keyword, rules }); + } + else if (keyword === "run") { + this.consume("run"); + this.skipWs(); + let dep; + let stageName; + if (this.peekWord() === "map") { + this.consume("map"); + this.expect("."); + dep = this.parseIdentifier(); + this.expect("."); + this.expect("stage"); + this.expect("."); + stageName = this.parseIdentifier(); + } + else if (this.peekWord() === "stage") { + this.consume("stage"); + this.expect("."); + stageName = this.parseIdentifier(); + } + else { + this.error("Expected map. or stage. after run"); + } + body.push(dep + ? { kind: "run", dependency: dep, stage: stageName } + : { kind: "run", stage: stageName }); + } + else if (keyword === "separate") { + this.consume("separate"); + this.skipWs(); + if (this.peekWord() === "separator") { + this.consume("separator"); + this.skipWs(); + const separator = this.parseItemAtom(); + body.push({ kind: "separate", separator }); + } + else { + body.push({ kind: "separate" }); + } + } + else if (keyword === "compose") { + this.consume(keyword); + body.push({ kind: "compose" }); + } + else if (keyword === "decompose") { + this.consume(keyword); + body.push({ kind: "decompose" }); + } + else if (keyword === "rababa") { + this.consume("rababa"); + this.skipInlineWs(); + const kwargs = {}; + // Parse `name: "value"` pairs separated by commas/whitespace. + while (this.peek() !== "}" && this.peek() !== "" && this.peek() !== "\n") { + const argName = this.parseIdentifier(); + if (!argName) + break; + this.skipInlineWs(); + this.expect(":"); + this.skipInlineWs(); + const argVal = this.parseStringLiteral(); + kwargs[argName] = argVal; + this.skipInlineWs(); + if (this.peek() === ",") + this.pos++; + this.skipInlineWs(); + } + body.push({ kind: "funcall", name: "rababa", kwargs }); + } + else if (FUNCTIONS.has(keyword)) { + this.consume(keyword); + body.push({ kind: "string_case", op: keyword }); + } + else if (keyword === "sub") { + const rule = this.parseRule(); + body.push({ kind: "bare_rule", rule }); + } + else { + // Ruby Parslet silently drops unrecognized tokens in stage body. + // Skip to end of line for parity. + this.skipLine(); + } + } + this.expect("}"); + return { stage: { name, body } }; + } + // -- Rules -- + parseRule() { + this.expect("sub"); + this.skipWs(); + // Block form: sub { from ... to ... } + if (this.peek() === "{") { + this.expect("{"); + let from = { type: "none" }; + let to = { type: "none" }; + const constraints = []; + for (;;) { + this.skipWs(); + if (this.peek() === "}") + break; + const word = this.peekWord(); + if (word === "from") { + this.consume("from"); + this.skipWs(); + from = this.parseItem(); + } + else if (word === "to") { + this.consume("to"); + this.skipWs(); + to = this.parseItem(); + } + else if (CONSTRAINTS.has(word)) { + this.consume(word); + this.skipWs(); + constraints.push({ kind: word, item: this.parseItem() }); + } + else { + this.error(`Unexpected keyword in sub block: ${word}`); + } + } + this.expect("}"); + return { from, to, constraints }; + } + // Compact form: sub + const from = this.parseItemAtom(); + this.skipWs(); + const to = this.parseItemAtom(); + const constraints = []; + for (;;) { + this.skipWs(); + const word = this.peekWord(); + if (!CONSTRAINTS.has(word)) + break; + this.consume(word); + this.skipWs(); + constraints.push({ kind: word, item: this.parseItemAtom() }); + } + return { from, to, constraints }; + } + // -- Items -- + parseItem() { + const first = this.parseItemAtom(); + const parts = [first]; + for (;;) { + this.skipInlineWs(); + if (this.peek() === "+") { + this.pos++; + this.skipInlineWs(); + parts.push(this.parseItemAtom()); + } + else if (this.isItemAtomStart() && !this.isKeyword()) { + parts.push(this.parseItemAtom()); + } + else { + break; + } + } + if (parts.length === 1) + return parts[0]; + return { type: "concat", parts }; + } + parseItemAtom() { + const c = this.peek(); + if (c === '"' || c === "'") + return { type: "string", value: this.parseStringLiteral() }; + const word = this.peekWord(); + if (!word) + this.error("Expected item atom"); + if (word === "none") { + this.consume("none"); + return { type: "none" }; + } + if (word === "any_character") { + this.consume("any_character"); + return { type: "function", name: "any_character" }; + } + if (word === "any") { + this.consume("any"); + this.expect("("); + this.skipWs(); + const inner = this.peek(); + // any("...".."...") or any('...'..'...') — range from string literals + if (inner === '"' || inner === "'") { + const lo = this.parseStringLiteral(); + this.skipWs(); + // Check for range: "lo".."hi" + if (this.src.startsWith("..", this.pos)) { + this.pos += 2; + this.skipWs(); + const hi = this.parseStringLiteral(); + this.skipWs(); + this.expect(")"); + return { type: "range", lo, hi }; + } + this.expect(")"); + // any("abc") — split into per-char string items + return { type: "set", items: [...lo].map((c) => ({ type: "string", value: c })) }; + } + if (inner === "[") { + this.expect("["); + const items = []; + for (;;) { + this.skipWs(); + if (this.peek() === "]") + break; + items.push(this.parseItem()); + this.skipWs(); + if (this.peek() === ",") + this.pos++; + } + this.expect("]"); + this.skipWs(); + this.expect(")"); + return { type: "set", items }; + } + // any(item), any(item + item), any(alias_name), any(range_start..range_end) + const item = this.parseItem(); + this.skipWs(); + this.expect(")"); + return { type: "set", items: [item] }; + } + if (word === "capture") { + this.consume("capture"); + this.expect("("); + this.skipWs(); + const inner = this.parseItem(); + this.skipWs(); + this.expect(")"); + return { type: "capture_group", inner }; + } + if (word === "maybe") { + this.consume("maybe"); + this.expect("("); + this.skipWs(); + const inner = this.parseItem(); + this.skipWs(); + this.expect(")"); + return { type: "maybe", inner }; + } + if (word === "some") { + this.consume("some"); + this.expect("("); + this.skipWs(); + const inner = this.parseItem(); + this.skipWs(); + this.expect(")"); + return { type: "some", inner }; + } + if (word === "ref") { + this.consume("ref"); + this.expect("("); + this.skipWs(); + const num = this.parseNumber(); + this.skipWs(); + this.expect(")"); + return { type: "capture", index: num }; + } + if (PRIMITIVES.has(word)) { + this.consume(word); + return { type: "primitive", name: word }; + } + if (FUNCTIONS.has(word)) { + this.consume(word); + return { type: "function", name: word }; + } + // Alias reference + this.consume(word); + return { type: "alias_ref", name: word }; + } + // -- Dependency -- + parseDependency() { + this.expect("dependency"); + this.skipWs(); + const target = this.parseQuotedString(); + this.skipInlineWs(); + if (this.peekWord() === "as") { + this.consume("as"); + this.skipWs(); + const aliasName = this.parseIdentifier(); + return { dependency: { target, aliasName } }; + } + return { dependency: { target } }; + } + // -- Primitives -- + parseStringLiteral() { + const c = this.peek(); + if (c === '"') + return this.parseQuotedString(); + if (c === "'") + return this.parseSingleQuotedString(); + this.error(`Expected string but got "${this.src.slice(this.pos, this.pos + 20)}"`); + } + parseQuotedString() { + this.expect('"'); + let result = ""; + while (this.pos < this.src.length) { + const c = this.charAt(this.pos++); + if (c === '"') + return result; + if (c === "\\") { + const next = this.charAt(this.pos++); + if (next === "n") + result += "\n"; + else if (next === "t") + result += "\t"; + else if (next === "r") + result += "\r"; + else if (next === '"') + result += '"'; + else if (next === "\\") + result += "\\"; + else if (next === "u") { + const hex = this.src.slice(this.pos, this.pos + 4); + this.pos += 4; + result += String.fromCharCode(parseInt(hex, 16)); + } + else if (next === "{") + result += "{"; + else if (next === "}") + result += "}"; + else + result += next; + } + else { + result += c; + } + } + this.error("Unterminated string"); + } + parseSingleQuotedString() { + this.expect("'"); + let result = ""; + while (this.pos < this.src.length && this.charAt(this.pos) !== "'") { + result += this.charAt(this.pos++); + } + this.expect("'"); + return result; + } + parseRawText() { + let result = ""; + let depth = 0; + while (this.pos < this.src.length) { + const c = this.charAt(this.pos); + if (c === "\\") { + const next = this.charAt(this.pos + 1); + if (next === "{") { + result += "{"; + this.pos += 2; + continue; + } + if (next === "}") { + result += "}"; + this.pos += 2; + continue; + } + } + if (c === "}" && depth === 0) + break; + if (c === "{") + depth++; + if (c === "}") + depth--; + result += c; + this.pos++; + } + return result.trim(); + } + parseIdentifier() { + this.skipWs(); + const start = this.pos; + while (this.pos < this.src.length && /[\w-]/.test(this.charAt(this.pos))) { + this.pos++; + } + if (this.pos === start) + this.error("Expected identifier"); + return this.src.slice(start, this.pos); + } + parseNumber() { + const start = this.pos; + while (this.pos < this.src.length && /\d/.test(this.charAt(this.pos))) { + this.pos++; + } + return parseInt(this.src.slice(start, this.pos), 10); + } + parseToNewline() { + const start = this.pos; + while (this.pos < this.src.length && this.charAt(this.pos) !== "\n") { + this.pos++; + } + return this.src.slice(start, this.pos); + } + // -- Helpers -- + charAt(i) { + return this.src[i] ?? ""; + } + peek() { + return this.charAt(this.pos); + } + peekWord() { + const start = this.pos; + while (this.pos < this.src.length && /[\w_]/.test(this.charAt(this.pos))) { + this.pos++; + } + const word = this.src.slice(start, this.pos); + this.pos = start; + return word; + } + expect(s) { + this.skipWs(); + if (!this.src.startsWith(s, this.pos)) { + this.error(`Expected "${s}" but got "${this.src.slice(this.pos, this.pos + 20)}"`); + } + this.pos += s.length; + } + consume(word) { + if (!this.src.startsWith(word, this.pos)) { + this.error(`Expected "${word}"`); + } + this.pos += word.length; + } + skipWs() { + while (this.pos < this.src.length) { + const c = this.charAt(this.pos); + if (/\s/.test(c)) { + this.pos++; + continue; + } + if (c === "#") { + this.skipLine(); + continue; + } + break; + } + } + skipInlineWs() { + while (this.pos < this.src.length && /[ \t]/.test(this.charAt(this.pos))) { + this.pos++; + } + } + skipLine() { + while (this.pos < this.src.length && this.charAt(this.pos) !== "\n") { + this.pos++; + } + if (this.pos < this.src.length) + this.pos++; + } + skipToNewline() { + while (this.pos < this.src.length && this.charAt(this.pos) !== "\n") { + this.pos++; + } + } + isItemAtomStart() { + const c = this.peek(); + return c === '"' || c === "'" || /[\w]/.test(c); + } + isKeyword() { + const word = this.peekWord(); + return ["to", "from", "before", "after", "not_before", "not_after", "}", "note"].includes(word); + } + error(msg) { + const line = this.src.slice(0, this.pos).split("\n").length; + const col = this.pos - this.src.lastIndexOf("\n", this.pos); + const fullMsg = this.filename ? `${this.filename}: ${msg}` : msg; + throw new IscParseError(fullMsg, this.pos, line, col); + } +} +//# sourceMappingURL=parser.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/parser.js.map b/vendor/interscript-ts/dist/isc/parser.js.map new file mode 100644 index 0000000..52c2305 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/parser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/isc/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe;IACrD,OAAO,EAAE,cAAc;CACxB,CAAC,CAAA;AAEF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU;CACnE,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAA;AAE3E,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,QAAiB;IACxD,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAA;AAC7C,CAAC;AAED,MAAM,MAAM;IACF,GAAG,CAAQ;IACX,GAAG,GAAG,CAAC,CAAA;IACP,QAAQ,CAAoB;IAEpC,YAAY,GAAW,EAAE,QAAiB;QACxC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED,KA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AE,CAAC,CAAC,CAAC,GAAG,CAAA;QAChE,MAAM,IAAI,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IACvD,CAAC;CACF"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/types.d.ts b/vendor/interscript-ts/dist/isc/types.d.ts new file mode 100644 index 0000000..4c4bba4 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/types.d.ts @@ -0,0 +1,110 @@ +/** + * ISC document types — mirror the Ruby document hash shape. + * + * These types represent the PARSED ISC document, not the runtime + * CompiledMap. A converter (iscToCompiledMap) bridges the two. + */ +export interface IscDocument { + readonly systemCode: string; + readonly metadata: Readonly>; + readonly tests: readonly IscTest[]; + readonly aliases: ReadonlyArray<{ + name: string; + value: IscItem; + }>; + readonly stages: readonly IscStage[]; + readonly dependencies: ReadonlyArray<{ + target: string; + aliasName?: string; + }>; +} +export interface IscTest { + readonly input: string; + readonly expected: string; + readonly note?: string; +} +export interface IscStage { + readonly name: string; + readonly body: readonly IscStageItem[]; +} +export type IscStageItem = { + kind: "parallel"; + rules: readonly IscRule[]; +} | { + kind: "sequence"; + rules: readonly IscRule[]; +} | { + kind: "bare_rule"; + rule: IscRule; +} | { + kind: "run"; + dependency?: string; + stage: string; +} | { + kind: "separate"; + separator?: IscItem; +} | { + kind: "compose"; +} | { + kind: "decompose"; +} | { + kind: "string_case"; + op: string; +} | { + kind: "funcall"; + name: string; + kwargs: Readonly>; +}; +export interface IscRule { + readonly from: IscItem; + readonly to: IscItem; + readonly constraints: readonly IscConstraint[]; +} +export interface IscConstraint { + readonly kind: string; + readonly item: IscItem; +} +export type IscItem = { + type: "string"; + value: string; +} | { + type: "none"; +} | { + type: "primitive"; + name: string; +} | { + type: "function"; + name: string; +} | { + type: "alias_ref"; + name: string; +} | { + type: "capture"; + index: number; +} | { + type: "capture_group"; + inner: IscItem; +} | { + type: "concat"; + parts: readonly IscItem[]; +} | { + type: "set"; + items: readonly IscItem[]; +} | { + type: "range"; + lo: string; + hi: string; +} | { + type: "maybe"; + inner: IscItem; +} | { + type: "some"; + inner: IscItem; +}; +export declare class IscParseError extends Error { + readonly position: number; + readonly line: number; + readonly col: number; + constructor(message: string, position: number, line: number, col: number); +} +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/types.d.ts.map b/vendor/interscript-ts/dist/isc/types.d.ts.map new file mode 100644 index 0000000..0177ddd --- /dev/null +++ b/vendor/interscript-ts/dist/isc/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/isc/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAA;IAClC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IACjE,QAAQ,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAA;IACpC,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7E;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI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GAChB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAEpC,qBAAa,aAAc,SAAQ,KAAK;IAGpC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM;gBAHpB,OAAO,EAAE,MAAM,EACN,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM;CAKvB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/types.js b/vendor/interscript-ts/dist/isc/types.js new file mode 100644 index 0000000..3c40e14 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/types.js @@ -0,0 +1,19 @@ +/** + * ISC document types — mirror the Ruby document hash shape. + * + * These types represent the PARSED ISC document, not the runtime + * CompiledMap. A converter (iscToCompiledMap) bridges the two. + */ +export class IscParseError extends Error { + position; + line; + col; + constructor(message, position, line, col) { + super(`ISC parse error at line ${line}:${col}: ${message}`); + this.position = position; + this.line = line; + this.col = col; + this.name = "IscParseError"; + } +} +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/isc/types.js.map b/vendor/interscript-ts/dist/isc/types.js.map new file mode 100644 index 0000000..67cdae1 --- /dev/null +++ b/vendor/interscript-ts/dist/isc/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/isc/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0DH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAG3B;IACA;IACA;IAJX,YACE,OAAe,EACN,QAAgB,EAChB,IAAY,EACZ,GAAW;QAEpB,KAAK,CAAC,2BAA2B,IAAI,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC,CAAA;QAJlD,aAAQ,GAAR,QAAQ,CAAQ;QAChB,SAAI,GAAJ,IAAI,CAAQ;QACZ,QAAG,GAAH,GAAG,CAAQ;QAGpB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,CAAC;CACF"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loader.d.ts b/vendor/interscript-ts/dist/loader.d.ts new file mode 100644 index 0000000..3d17bb9 --- /dev/null +++ b/vendor/interscript-ts/dist/loader.d.ts @@ -0,0 +1,49 @@ +/** + * Map loader — resolves a system code to a compiled map. + * + * Strategy pattern: maps can be loaded from different sources. Each + * strategy is a function `(systemCode) => CompiledMap | undefined` + * (sync) or `Promise` (async). Loader + * composes strategies in priority order. + * + * Async strategies (e.g. HTTP fetch) are tried after sync ones. If an + * async strategy is needed, callers must use `loadAsync()` / + * `transliterate()` will throw a `MapNotInCacheError` so the caller + * can preload and retry. + * + * Adding a new source: add a function to the strategies list. + * Existing strategies don't change (OCP). + */ +import type { CompiledMap, SystemCode } from "./types.js"; +export type LoadStrategy = ((systemCode: SystemCode) => CompiledMap | undefined | Promise); +interface MapLoaderOptions { + /** Called when a map is first loaded so the loader can track it. */ + readonly onLoaded?: (systemCode: SystemCode, map: CompiledMap) => void; +} +export declare class MapLoader { + private readonly strategies; + private readonly cache; + /** Tracks everything we've EVER loaded (even after cache clear). */ + private readonly known; + private readonly options; + constructor(strategies: LoadStrategy[], options?: MapLoaderOptions); + /** + * Synchronous load. Returns the cached map or attempts sync + * strategies. Throws MapNotFoundError if no sync strategy resolves + * the code (use loadAsync for async strategies like HTTP). + */ + load(systemCode: SystemCode): CompiledMap; + /** + * Async load. Tries every strategy in order, awaiting async ones. + * Use this when the strategy set includes HTTP or other async loaders. + */ + loadAsync(systemCode: SystemCode): Promise; + /** Force-clear the in-memory cache (keeps `known` registry). */ + clear(): void; + /** All system codes ever loaded. */ + loadedMaps(): readonly SystemCode[]; + /** Register a map directly (bypasses strategies). */ + register(systemCode: SystemCode, map: CompiledMap): void; +} +export {}; +//# sourceMappingURL=loader.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loader.d.ts.map b/vendor/interscript-ts/dist/loader.d.ts.map new file mode 100644 index 0000000..5d63a74 --- /dev/null +++ b/vendor/interscript-ts/dist/loader.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGzD,MAAM,MAAM,YAAY,GAAG,CAAC,CAC1B,UAAU,EAAE,UAAU,KACnB,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC,CAAA;AAEhE,UAAU,gBAAgB;IACxB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,CAAA;CACvE;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAC3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAC3D,oEAAoE;IACpE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAC3D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;gBAE9B,UAAU,EAAE,YAAY,EAAE,EAAE,OAAO,GAAE,gBAAqB;IAKtE;;;;OAIG;IACH,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW;IAuBzC;;;OAGG;IACG,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IAqB7D,gEAAgE;IAChE,KAAK,IAAI,IAAI;IAIb,oCAAoC;IACpC,UAAU,IAAI,SAAS,UAAU,EAAE;IAInC,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI;CAIzD"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loader.js b/vendor/interscript-ts/dist/loader.js new file mode 100644 index 0000000..c8c5dd5 --- /dev/null +++ b/vendor/interscript-ts/dist/loader.js @@ -0,0 +1,93 @@ +/** + * Map loader — resolves a system code to a compiled map. + * + * Strategy pattern: maps can be loaded from different sources. Each + * strategy is a function `(systemCode) => CompiledMap | undefined` + * (sync) or `Promise` (async). Loader + * composes strategies in priority order. + * + * Async strategies (e.g. HTTP fetch) are tried after sync ones. If an + * async strategy is needed, callers must use `loadAsync()` / + * `transliterate()` will throw a `MapNotInCacheError` so the caller + * can preload and retry. + * + * Adding a new source: add a function to the strategies list. + * Existing strategies don't change (OCP). + */ +import { MapNotFoundError } from "./errors.js"; +export class MapLoader { + strategies; + cache = new Map(); + /** Tracks everything we've EVER loaded (even after cache clear). */ + known = new Map(); + options; + constructor(strategies, options = {}) { + this.strategies = strategies; + this.options = options; + } + /** + * Synchronous load. Returns the cached map or attempts sync + * strategies. Throws MapNotFoundError if no sync strategy resolves + * the code (use loadAsync for async strategies like HTTP). + */ + load(systemCode) { + const cached = this.cache.get(systemCode); + if (cached) + return cached; + const known = this.known.get(systemCode); + if (known) { + this.cache.set(systemCode, known); + return known; + } + for (const strategy of this.strategies) { + const result = strategy(systemCode); + // Promise results can't be handled synchronously — skip. + if (result && typeof result.then !== "function") { + const map = result; + this.cache.set(systemCode, map); + this.known.set(systemCode, map); + this.options.onLoaded?.(systemCode, map); + return map; + } + } + throw new MapNotFoundError(systemCode); + } + /** + * Async load. Tries every strategy in order, awaiting async ones. + * Use this when the strategy set includes HTTP or other async loaders. + */ + async loadAsync(systemCode) { + const cached = this.cache.get(systemCode); + if (cached) + return cached; + const known = this.known.get(systemCode); + if (known) { + this.cache.set(systemCode, known); + return known; + } + for (const strategy of this.strategies) { + const result = await strategy(systemCode); + if (result) { + this.cache.set(systemCode, result); + this.known.set(systemCode, result); + this.options.onLoaded?.(systemCode, result); + return result; + } + } + throw new MapNotFoundError(systemCode); + } + /** Force-clear the in-memory cache (keeps `known` registry). */ + clear() { + this.cache.clear(); + } + /** All system codes ever loaded. */ + loadedMaps() { + return Array.from(this.known.keys()); + } + /** Register a map directly (bypasses strategies). */ + register(systemCode, map) { + this.known.set(systemCode, map); + this.cache.set(systemCode, map); + } +} +//# sourceMappingURL=loader.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loader.js.map b/vendor/interscript-ts/dist/loader.js.map new file mode 100644 index 0000000..21bfc92 --- /dev/null +++ b/vendor/interscript-ts/dist/loader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAW9C,MAAM,OAAO,SAAS;IACH,UAAU,CAAgB;IAC1B,KAAK,GAAG,IAAI,GAAG,EAA2B,CAAA;IAC3D,oEAAoE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ff --git a/vendor/interscript-ts/dist/loaders.d.ts b/vendor/interscript-ts/dist/loaders.d.ts new file mode 100644 index 0000000..a9f018d --- /dev/null +++ b/vendor/interscript-ts/dist/loaders.d.ts @@ -0,0 +1,23 @@ +/** + * Map loading strategies — pluggable sources for compiled maps. + * + * Browser-safe: this module is safe to bundle into browsers. It only + * exports `normaliseMap` (pure data) and `bundledStrategy` (works on + * in-memory dictionaries). Filesystem strategies live in + * `./loaders.node.ts` and pull in `node:fs` — that module is server-only. + */ +import type { CompiledMap, CompiledMapJson, LoadStrategy } from "./index.js"; +/** + * Convert raw JSON IR (as emitted by the Ruby compiler) into the runtime + * CompiledMap shape. Reconstructs Map objects for aliases and functions. + * + * Single responsibility: shape normalisation. No I/O. + */ +export declare function normaliseMap(json: CompiledMapJson): CompiledMap; +/** + * Load maps from a JSON dictionary bundled at build time. Useful for + * browser bundles, tests, and any context where the maps are already + * in memory. + */ +export declare function bundledStrategy(maps: Record): LoadStrategy; +//# sourceMappingURL=loaders.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loaders.d.ts.map b/vendor/interscript-ts/dist/loaders.d.ts.map new file mode 100644 index 0000000..994efa4 --- /dev/null +++ b/vendor/interscript-ts/dist/loaders.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../src/loaders.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAc,MAAM,YAAY,CAAA;AAGxF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAW/D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,YAAY,CAMnF"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loaders.js b/vendor/interscript-ts/dist/loaders.js new file mode 100644 index 0000000..63da95f --- /dev/null +++ b/vendor/interscript-ts/dist/loaders.js @@ -0,0 +1,40 @@ +/** + * Map loading strategies — pluggable sources for compiled maps. + * + * Browser-safe: this module is safe to bundle into browsers. It only + * exports `normaliseMap` (pure data) and `bundledStrategy` (works on + * in-memory dictionaries). Filesystem strategies live in + * `./loaders.node.ts` and pull in `node:fs` — that module is server-only. + */ +/** + * Convert raw JSON IR (as emitted by the Ruby compiler) into the runtime + * CompiledMap shape. Reconstructs Map objects for aliases and functions. + * + * Single responsibility: shape normalisation. No I/O. + */ +export function normaliseMap(json) { + const out = { + schemaVersion: json.schemaVersion, + systemCode: json.systemCode, + dependencies: json.dependencies, + stages: json.stages, + aliases: new Map(Object.entries(json.aliases)), + functions: new Map(), + }; + if (json.metadata) + out.metadata = json.metadata; + return out; +} +/** + * Load maps from a JSON dictionary bundled at build time. Useful for + * browser bundles, tests, and any context where the maps are already + * in memory. + */ +export function bundledStrategy(maps) { + const normalised = new Map(); + for (const [code, json] of Object.entries(maps)) { + normalised.set(code, normaliseMap(json)); + } + return (systemCode) => normalised.get(systemCode); +} +//# sourceMappingURL=loaders.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loaders.js.map b/vendor/interscript-ts/dist/loaders.js.map new file mode 100644 index 0000000..be811bd --- /dev/null +++ b/vendor/interscript-ts/dist/loaders.js.map @@ -0,0 +1 @@ +{"version":3,"file":"loaders.js","sourceRoot":"","sources":["../src/loaders.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAqB;IAChD,MAAM,GAAG,GAAG;QACV,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9C,SAAS,EAAE,IAAI,GAAG,EAAE;KACC,CAAA;IACvB,IAAI,IAAI,CAAC,QAAQ;QAAE,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAC/C,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAqC;IACnE,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAA;IACjD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1C,CAAC;IACD,OAAO,CAAC,UAAsB,EAA2B,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AACxF,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loaders.node.d.ts b/vendor/interscript-ts/dist/loaders.node.d.ts new file mode 100644 index 0000000..0a31a66 --- /dev/null +++ b/vendor/interscript-ts/dist/loaders.node.d.ts @@ -0,0 +1,25 @@ +/** + * Filesystem-based map loading strategies. + * + * SERVER-ONLY: requires `node:fs`, `node:url`, `node:path`. Don't import + * this from browser bundles — use `bundledStrategy` from `./loaders.js` + * instead, or pre-bundle the maps with Vite's `import.meta.glob`. + * + * The CLI and Node-side test helpers import from here. Browser-safe + * helpers (`normaliseMap`, `bundledStrategy`) are re-exported so server + * callers have a single import surface. + */ +import type { LoadStrategy } from "./index.js"; +import { normaliseMap, bundledStrategy } from "./loaders.js"; +export { normaliseMap, bundledStrategy }; +/** + * Load maps from a filesystem directory. Each map is `.json`. + * Throws on filesystem errors but returns `undefined` if the specific + * file doesn't exist (so other strategies can be tried). + */ +export declare function filesystemStrategy(mapsDir: string): LoadStrategy; +/** + * Loader relative to a module URL — handy for test fixtures. + */ +export declare function relativeFilesystemStrategy(relativeTo: string, relativePath: string): LoadStrategy; +//# sourceMappingURL=loaders.node.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loaders.node.d.ts.map b/vendor/interscript-ts/dist/loaders.node.d.ts.map new file mode 100644 index 0000000..dcaad59 --- /dev/null +++ b/vendor/interscript-ts/dist/loaders.node.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"loaders.node.d.ts","sourceRoot":"","sources":["../src/loaders.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAgC,YAAY,EAAc,MAAM,YAAY,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG5D,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA;AAExC;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAUhE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,YAAY,CAGd"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loaders.node.js b/vendor/interscript-ts/dist/loaders.node.js new file mode 100644 index 0000000..c40146c --- /dev/null +++ b/vendor/interscript-ts/dist/loaders.node.js @@ -0,0 +1,42 @@ +/** + * Filesystem-based map loading strategies. + * + * SERVER-ONLY: requires `node:fs`, `node:url`, `node:path`. Don't import + * this from browser bundles — use `bundledStrategy` from `./loaders.js` + * instead, or pre-bundle the maps with Vite's `import.meta.glob`. + * + * The CLI and Node-side test helpers import from here. Browser-safe + * helpers (`normaliseMap`, `bundledStrategy`) are re-exported so server + * callers have a single import surface. + */ +import { readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; +import { dirname, resolve } from "node:path"; +import { normaliseMap, bundledStrategy } from "./loaders.js"; +// Re-export browser-safe helpers for server callers' convenience. +export { normaliseMap, bundledStrategy }; +/** + * Load maps from a filesystem directory. Each map is `.json`. + * Throws on filesystem errors but returns `undefined` if the specific + * file doesn't exist (so other strategies can be tried). + */ +export function filesystemStrategy(mapsDir) { + return (systemCode) => { + const path = resolve(mapsDir, `${systemCode}.json`); + try { + const raw = readFileSync(path, "utf8"); + return normaliseMap(JSON.parse(raw)); + } + catch { + return undefined; + } + }; +} +/** + * Loader relative to a module URL — handy for test fixtures. + */ +export function relativeFilesystemStrategy(relativeTo, relativePath) { + const base = relativeTo.startsWith("file://") ? dirname(fileURLToPath(relativeTo)) : relativeTo; + return filesystemStrategy(resolve(base, relativePath)); +} +//# sourceMappingURL=loaders.node.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/loaders.node.js.map b/vendor/interscript-ts/dist/loaders.node.js.map new file mode 100644 index 0000000..ea3583c --- /dev/null +++ b/vendor/interscript-ts/dist/loaders.node.js.map @@ -0,0 +1 @@ +{"version":3,"file":"loaders.node.js","sourceRoot":"","sources":["../src/loaders.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE5D,kEAAkE;AAClE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA;AAExC;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,OAAO,CAAC,UAAsB,EAA2B,EAAE;QACzD,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,UAAU,OAAO,CAAC,CAAA;QACnD,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YACtC,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAoB,CAAC,CAAA;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAAkB,EAClB,YAAoB;IAEpB,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAC/F,OAAO,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAA;AACxD,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/index.d.ts b/vendor/interscript-ts/dist/ml/imf/index.d.ts new file mode 100644 index 0000000..ee79149 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/index.d.ts @@ -0,0 +1,6 @@ +/** @interscript/ml — the IMF v1 runtime for TypeScript. */ +export { IMFModel } from "./model.js"; +export { IMFError, parseManifest, verifyAndRead, type IMFManifest } from "./loader.js"; +export { resolve, DEFAULT_INDEX_URL, RegistryError, type IndexEntry } from "./registry.js"; +export { encode, decode, BYTE_OFFSET, EOS_ID, PAD_ID, UNK_ID } from "./tokens.js"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/index.d.ts.map b/vendor/interscript-ts/dist/ml/imf/index.d.ts.map new file mode 100644 index 0000000..75ee815 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ml/imf/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AACtF,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/index.js b/vendor/interscript-ts/dist/ml/imf/index.js new file mode 100644 index 0000000..7f00796 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/index.js @@ -0,0 +1,6 @@ +/** @interscript/ml — the IMF v1 runtime for TypeScript. */ +export { IMFModel } from "./model.js"; +export { IMFError, parseManifest, verifyAndRead } from "./loader.js"; +export { resolve, DEFAULT_INDEX_URL, RegistryError } from "./registry.js"; +export { encode, decode, BYTE_OFFSET, EOS_ID, PAD_ID, UNK_ID } from "./tokens.js"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/index.js.map b/vendor/interscript-ts/dist/ml/imf/index.js.map new file mode 100644 index 0000000..4f17ec8 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ml/imf/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAA;AACtF,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/loader.d.ts b/vendor/interscript-ts/dist/ml/imf/loader.d.ts new file mode 100644 index 0000000..6630b50 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/loader.d.ts @@ -0,0 +1,19 @@ +/** + * IMF v1 zip loading: manifest parse, per-graph sha256 verification. + * Corrupt downloads fail loudly, before any session is created. + */ +export interface IMFManifest { + format: string; + id: string; + task: string; + decoder: string; + precision: string; + opset: number; + sha256: Record; +} +export declare class IMFError extends Error { +} +export declare function parseManifest(zipBytes: Uint8Array): IMFManifest; +/** Unzip + sha256-verify every .onnx member; returns name -> bytes. */ +export declare function verifyAndRead(zipBytes: Uint8Array): Promise>; +//# sourceMappingURL=loader.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/loader.d.ts.map b/vendor/interscript-ts/dist/ml/imf/loader.d.ts.map new file mode 100644 index 0000000..17eeee0 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/loader.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/ml/imf/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B;AAED,qBAAa,QAAS,SAAQ,KAAK;CAAG;AAEtC,wBAAgB,aAAa,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW,CAqB/D;AAUD,uEAAuE;AACvE,wBAAsB,aAAa,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAe1F"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/loader.js b/vendor/interscript-ts/dist/ml/imf/loader.js new file mode 100644 index 0000000..59d0ec4 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/loader.js @@ -0,0 +1,59 @@ +/** + * IMF v1 zip loading: manifest parse, per-graph sha256 verification. + * Corrupt downloads fail loudly, before any session is created. + */ +import { unzipSync } from "fflate"; +import { load as loadYaml } from "js-yaml"; +export class IMFError extends Error { +} +export function parseManifest(zipBytes) { + const files = unzipSync(zipBytes); + const metaBytes = files["metadata.yaml"]; + if (!metaBytes) + throw new IMFError("missing metadata.yaml"); + const raw = loadYaml(new TextDecoder().decode(metaBytes)); + if (raw["format"] !== "imf-v1") + throw new IMFError(`unsupported format: ${String(raw["format"])}`); + if (raw["tokenizer"] !== "bytes") { + throw new IMFError(`tokenizer ${String(raw["tokenizer"])}: this runtime is byte-level only`); + } + if (!files["encoder.onnx"] || !files["decoder.onnx"]) { + throw new IMFError("missing encoder.onnx / decoder.onnx"); + } + return { + format: "imf-v1", + id: String(raw["id"]), + task: String(raw["task"]), + decoder: raw["decoder"] === undefined ? "plain" : String(raw["decoder"]), + precision: raw["precision"] === undefined ? "fp32" : String(raw["precision"]), + opset: raw["opset"] === undefined ? 14 : Number(raw["opset"]), + sha256: raw["sha256"] ?? {}, + }; +} +async function sha256(data) { + const buffer = new Uint8Array(data).buffer; + const digest = await crypto.subtle.digest("SHA-256", buffer); + return Array.from(new Uint8Array(digest)) + .map((b) => b.toString(16).padStart(2, "0")) + .join(""); +} +/** Unzip + sha256-verify every .onnx member; returns name -> bytes. */ +export async function verifyAndRead(zipBytes) { + const manifest = parseManifest(zipBytes); + const files = unzipSync(zipBytes); + const graphs = new Map(); + for (const [name, bytes] of Object.entries(files)) { + if (!name.endsWith(".onnx")) + continue; + const recorded = manifest.sha256[name]; + if (!recorded) + throw new IMFError(`${name} is not covered by metadata sha256`); + const actual = await sha256(bytes); + if (actual !== recorded) { + throw new IMFError(`${name} sha256 mismatch: zip has ${actual}, metadata says ${recorded}`); + } + graphs.set(name, bytes); + } + return graphs; +} +//# sourceMappingURL=loader.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/loader.js.map b/vendor/interscript-ts/dist/ml/imf/loader.js.map new file mode 100644 index 0000000..490f3e5 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/loader.js.map @@ -0,0 +1 @@ +{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/ml/imf/loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAA;AAY1C,MAAM,OAAO,QAAS,SAAQ,KAAK;CAAG;AAEtC,MAAM,UAAU,aAAa,CAAC,QAAoB;IAChD,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;IACjC,MAAM,SAAS,GAAG,KAAK,CAAC,eAAe,CAAC,CAAA;IACxC,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,QAAQ,CAAC,uBAAuB,CAAC,CAAA;IAC3D,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAA4B,CAAA;IACpF,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ;QAAE,MAAM,IAAI,QAAQ,CAAC,uBAAuB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAA;IAClG,IAAI,GAAG,CAAC,WAAW,CAAC,KAAK,OAAO,EAAE,CAAC;QACjC,MAAM,IAAI,QAAQ,CAAC,aAAa,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,mCAAmC,CAAC,CAAA;IAC9F,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,QAAQ,CAAC,qCAAqC,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO;QACL,MAAM,EAAE,QAAQ;QAChB,EAAE,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AC,CAAA;IACjC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsB,CAAA;IAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,SAAQ;QACrC,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACtC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,QAAQ,CAAC,GAAG,IAAI,oCAAoC,CAAC,CAAA;QAC9E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAA;QAClC,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YACxB,MAAM,IAAI,QAAQ,CAAC,GAAG,IAAI,6BAA6B,MAAM,mBAAmB,QAAQ,EAAE,CAAC,CAAA;QAC7F,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/model.d.ts b/vendor/interscript-ts/dist/ml/imf/model.d.ts new file mode 100644 index 0000000..cad8374 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/model.d.ts @@ -0,0 +1,28 @@ +/** + * IMFModel — a loaded, checksum-verified IMF v1 model. Greedy KV-cache + * decode when the zip ships decoder-kv.onnx (default), plain + * full-recompute fallback otherwise. The decode loop is the shared + * cross-runtime contract; outputs are byte-identical with the Python + * reference on the golden sets. + */ +export declare class IMFModel { + readonly id: string; + private readonly manifest; + private readonly encoder; + private readonly decoder; + private readonly kv; + private readonly pasts; + private constructor(); + static fromZipBytes(zipBytes: Uint8Array): Promise; + /** Accepts a zip path (Node), raw zip bytes, or a models.yaml model id. */ + static load(source: string | Uint8Array, indexUrl?: string): Promise; + translate(text: string, maxLen?: number): Promise; + dispose(): Promise; + private runEncoder; + private zeroPastSpecs; + private pastTensors; + private argmaxLastStep; + private greedyKv; + private greedyPlain; +} +//# sourceMappingURL=model.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/model.d.ts.map b/vendor/interscript-ts/dist/ml/imf/model.d.ts.map new file mode 100644 index 0000000..bbaa458 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/model.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/ml/imf/model.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH,qBAAa,QAAQ;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkB;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA0D;IAEhF,OAAO;WAaM,YAAY,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC;IAWlE,2EAA2E;WAC9D,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU9E,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAKhB,UAAU;IAYxB,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,cAAc;YAiBR,QAAQ;YA+BR,WAAW;CAyB1B"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/model.js b/vendor/interscript-ts/dist/ml/imf/model.js new file mode 100644 index 0000000..4b3a310 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/model.js @@ -0,0 +1,179 @@ +/** + * IMFModel — a loaded, checksum-verified IMF v1 model. Greedy KV-cache + * decode when the zip ships decoder-kv.onnx (default), plain + * full-recompute fallback otherwise. The decode loop is the shared + * cross-runtime contract; outputs are byte-identical with the Python + * reference on the golden sets. + */ +import { createSession } from "../session/index.js"; +import { verifyAndRead, parseManifest } from "./loader.js"; +import { resolve } from "./registry.js"; +import { EOS_ID, PAD_ID, decode, encode } from "./tokens.js"; +export class IMFModel { + id; + manifest; + encoder; + decoder; + kv; + pasts; + constructor(manifest, encoder, decoder) { + this.manifest = manifest; + this.id = manifest.id; + this.encoder = encoder; + this.decoder = decoder; + this.kv = manifest.decoder === "kv" && decoder.inputNames.some((n) => n.startsWith("past_")); + this.pasts = this.kv ? this.zeroPastSpecs() : []; + } + static async fromZipBytes(zipBytes) { + const manifest = parseManifest(zipBytes); + const graphs = await verifyAndRead(zipBytes); + const encoder = await createSession(graphs.get("encoder.onnx")); + const decoderName = manifest.decoder === "kv" && graphs.has("decoder-kv.onnx") + ? "decoder-kv.onnx" + : "decoder.onnx"; + const decoder = (await createSession(graphs.get(decoderName))); + return new IMFModel(manifest, encoder, decoder); + } + /** Accepts a zip path (Node), raw zip bytes, or a models.yaml model id. */ + static async load(source, indexUrl) { + if (source instanceof Uint8Array) + return IMFModel.fromZipBytes(source); + if (source.endsWith(".zip")) { + const fs = (await import("node:fs")); + return IMFModel.fromZipBytes(fs.readFileSync(source)); + } + const resolved = await resolve(source, indexUrl); + return IMFModel.fromZipBytes(resolved.bytes); + } + async translate(text, maxLen = 256) { + const ids = encode(text); + if (ids.length === 1) + return ""; + const hidden = await this.runEncoder(ids); + const tokens = this.kv ? await this.greedyKv(hidden, maxLen) : await this.greedyPlain(hidden, maxLen); + return decode(tokens); + } + async dispose() { + await this.encoder.dispose(); + await this.decoder.dispose(); + } + async runEncoder(ids) { + const outputs = await this.encoder.run({ + input_ids: { + name: "input_ids", + type: "int64", + data: new BigInt64Array(ids.map((n) => BigInt(n))), + dims: [1, ids.length], + }, + }); + return outputs["last_hidden_state"]; + } + zeroPastSpecs() { + const specs = []; + const metadata = this.decoder.inputMetadata; + for (const name of this.decoder.inputNames) { + if (!name.startsWith("past_")) + continue; + // [batch, heads, past_seq, d_kv]: heads and d_kv are static + let heads = 6; + let dKv = 64; + const meta = metadata?.find((m) => m.name === name); + if (meta && typeof meta.shape[1] === "number") + heads = meta.shape[1]; + if (meta && typeof meta.shape[3] === "number") + dKv = meta.shape[3]; + specs.push({ name, dims: [1, heads, 0, dKv] }); + } + return specs; + } + pastTensors(present) { + const feeds = {}; + for (const spec of this.pasts) { + const value = present?.get(spec.name); + if (value) { + feeds[spec.name] = { name: spec.name, type: value.type, data: value.data, dims: value.dims }; + } + else { + feeds[spec.name] = { + name: spec.name, + type: "float32", + data: new Float32Array(0), + dims: [...spec.dims], + }; + } + } + return feeds; + } + argmaxLastStep(logits) { + const dims = logits.dims; + const classes = dims[dims.length - 1]; + const data = logits.data; + const base = (dims[dims.length - 2] - 1) * classes; + let best = 0; + let bestVal = -Infinity; + for (let c = 0; c < classes; c++) { + const v = typeof data[base + c] === "bigint" ? Number(data[base + c]) : data[base + c]; + if (v > bestVal) { + bestVal = v; + best = c; + } + } + return best; + } + async greedyKv(hidden, maxLen) { + const generated = []; + let current = [PAD_ID]; + let present; + for (let step = 0; step < maxLen; step++) { + const outputs = await this.decoder.run({ + input_ids: { + name: "input_ids", + type: "int64", + data: new BigInt64Array(current.map((n) => BigInt(n))), + dims: [1, current.length], + }, + encoder_hidden_states: { + name: "encoder_hidden_states", + type: hidden.type, + data: hidden.data, + dims: hidden.dims, + }, + ...this.pastTensors(present), + }); + const token = this.argmaxLastStep(outputs["logits"]); + if (token === EOS_ID) + break; + generated.push(token); + present = new Map(this.pasts.map((spec) => [spec.name, outputs[spec.name.replace("past_", "present_")]])); + current = [token]; + } + return generated; + } + async greedyPlain(hidden, maxLen) { + const generated = []; + const decoderIds = [PAD_ID]; + for (let step = 0; step < maxLen; step++) { + const outputs = await this.decoder.run({ + input_ids: { + name: "input_ids", + type: "int64", + data: new BigInt64Array(decoderIds.map((n) => BigInt(n))), + dims: [1, decoderIds.length], + }, + encoder_hidden_states: { + name: "encoder_hidden_states", + type: hidden.type, + data: hidden.data, + dims: hidden.dims, + }, + }); + const token = this.argmaxLastStep(outputs["logits"]); + if (token === EOS_ID) + break; + generated.push(token); + decoderIds.push(token); + } + return generated; + } +} +//# sourceMappingURL=model.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/model.js.map b/vendor/interscript-ts/dist/ml/imf/model.js.map new file mode 100644 index 0000000..fa83663 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/model.js.map @@ -0,0 +1 @@ +{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/ml/imf/model.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAyB,MAAM,qBAAqB,CAAA;AAE1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAY5D,MAAM,OAAO,QAAQ;IACV,EAAE,CAAQ;IACF,QAAQ,CAAa;IACrB,OAAO,CAAkB;IACzB,OAAO,CAAiB;IACxB,EAAE,CAAS;IACX,KAAK,CAA0D;IAEhF,YACE,QAAqB,EACrB,OAAyB,EACzB,OAAwB;QAExB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAA;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,EAAE,GAAG,QAAQ,CA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vendor/interscript-ts/dist/ml/imf/registry.d.ts b/vendor/interscript-ts/dist/ml/imf/registry.d.ts new file mode 100644 index 0000000..64753c2 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/registry.d.ts @@ -0,0 +1,24 @@ +/** + * models.yaml resolution (the dynamic-fetch contract shared with the + * Python and Ruby runtimes): resolve id -> channel URL, verify a cached + * copy against the index sha256, or download -> verify -> install. + * + * Node persists to ~/.cache/interscript/models// (fs, atomic + * rename); browsers keep the verified bytes in memory (the Cache API + * integration is future work). Overrides: INTERSCRIPT_ML_INDEX, + * INTERSCRIPT_ML_CACHE. + */ +export declare const DEFAULT_INDEX_URL = "https://raw.githubusercontent.com/interscript/ml-models/main/models.yaml"; +export interface IndexEntry { + filename: string; + url: string; + sha256: string; +} +export declare class RegistryError extends Error { +} +export interface ResolvedZip { + bytes: Uint8Array; + path?: string; +} +export declare function resolve(modelId: string, indexUrl?: string): Promise; +//# sourceMappingURL=registry.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/registry.d.ts.map b/vendor/interscript-ts/dist/ml/imf/registry.d.ts.map new file mode 100644 index 0000000..a3ead9a --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/registry.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/ml/imf/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,eAAO,MAAM,iBAAiB,6EAC8C,CAAA;AAE5E,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,aAAc,SAAQ,KAAK;CAAG;AAuC3C,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,UAAU,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,OAAO,CAC3B,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC,CAiCtB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/registry.js b/vendor/interscript-ts/dist/ml/imf/registry.js new file mode 100644 index 0000000..d22e316 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/registry.js @@ -0,0 +1,73 @@ +/** + * models.yaml resolution (the dynamic-fetch contract shared with the + * Python and Ruby runtimes): resolve id -> channel URL, verify a cached + * copy against the index sha256, or download -> verify -> install. + * + * Node persists to ~/.cache/interscript/models// (fs, atomic + * rename); browsers keep the verified bytes in memory (the Cache API + * integration is future work). Overrides: INTERSCRIPT_ML_INDEX, + * INTERSCRIPT_ML_CACHE. + */ +import { load as loadYaml } from "js-yaml"; +export const DEFAULT_INDEX_URL = "https://raw.githubusercontent.com/interscript/ml-models/main/models.yaml"; +export class RegistryError extends Error { +} +async function nodeFs() { + const g = globalThis; + if (!g.process?.versions?.node) + return undefined; + return (await import("node:fs")); +} +function cacheDir() { + const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "."; + return process.env["INTERSCRIPT_ML_CACHE"] ?? `${home}/.cache/interscript`; +} +async function fetchIndex(source) { + const text = source.startsWith("http://") || source.startsWith("https://") + ? await (await fetch(source)).text() + : new TextDecoder().decode((await nodeFs()).readFileSync(source)); + const raw = loadYaml(text); + if (raw.version !== 1) + throw new RegistryError("index must have version: 1"); + const entries = {}; + for (const [id, spec] of Object.entries(raw.models ?? {})) { + entries[id] = { filename: spec["filename"], url: spec["url"], sha256: spec["sha256"] }; + } + return entries; +} +async function sha256Hex(data) { + const digest = await crypto.subtle.digest("SHA-256", new Uint8Array(data).buffer); + return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join(""); +} +export async function resolve(modelId, indexUrl) { + const source = indexUrl ?? process.env["INTERSCRIPT_ML_INDEX"] ?? DEFAULT_INDEX_URL; + const entries = await fetchIndex(source); + const entry = entries[modelId]; + if (!entry) { + throw new RegistryError(`unknown model id '${modelId}' (known: ${Object.keys(entries).sort().join(", ")})`); + } + const fs = await nodeFs(); + const target = `${cacheDir()}/models/${modelId}/${entry.filename}`; + if (fs?.existsSync(target)) { + const cached = fs.readFileSync(target); + if ((await sha256Hex(cached)) === entry.sha256) + return { bytes: cached, path: target }; + } + const bytes = entry.url.startsWith("file://") + ? fs.readFileSync(entry.url.replace(/^file:\/\//, "")) + : new Uint8Array(await (await fetch(entry.url)).arrayBuffer()); + const actual = await sha256Hex(bytes); + if (actual !== entry.sha256) { + throw new RegistryError(`downloaded ${entry.filename} sha256 mismatch: got ${actual}, index says ${entry.sha256}`); + } + if (fs) { + const dir = target.substring(0, target.lastIndexOf("/")); + fs.mkdirSync(dir, { recursive: true }); + const tmp = `${target}.part.${process.pid}`; + fs.writeFileSync(tmp, bytes); + fs.renameSync(tmp, target); + return { bytes, path: target }; + } + return { bytes }; +} +//# sourceMappingURL=registry.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/registry.js.map b/vendor/interscript-ts/dist/ml/imf/registry.js.map new file mode 100644 index 0000000..c8f5dc1 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/registry.js.map @@ -0,0 +1 @@ +{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/ml/imf/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAC5B,0EAA0E,CAAA;AAQ5E,MAAM,OAAO,aAAc,SAAQ,KAAK;CAAG;AAU3C,KAAK,UAAU,MAAM;IACnB,MAAM,CAAC,GAAG,UAA4D,CAAA;IACtE,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI;QAAE,OAAO,SAAS,CAAA;IAChD,OAAO,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAsB,CAAA;AACvD,CAAC;AAED,SAAS,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KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;QAC3C,CAAC,CAAC,EAAG,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QACvD,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;IAChE,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAA;IACrC,IAAI,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QAC5B,MAAM,IAAI,aAAa,CACrB,cAAc,KAAK,CAAC,QAAQ,yBAAyB,MAAM,gBAAgB,KAAK,CAAC,MAAM,EAAE,CAC1F,CAAA;IACH,CAAC;IACD,IAAI,EAAE,EAAE,CAAC;QACP,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;QACxD,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACtC,MAAM,GAAG,GAAG,GAAG,MAAM,SAAS,OAAO,CAAC,GAAG,EAAE,CAAA;QAC3C,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC5B,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC1B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IAChC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/tokens.d.ts b/vendor/interscript-ts/dist/ml/imf/tokens.d.ts new file mode 100644 index 0000000..1a4a983 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/tokens.d.ts @@ -0,0 +1,13 @@ +/** + * The canonical ByT5 byte table (shared contract with the Python and + * Ruby runtimes): byte b -> token id b+3, trailing EOS; pad=0, unk=2. + * Token ids are NOT raw byte values — feeding TextEncoder output + * directly as ids silently produces garbage on real checkpoints. + */ +export declare const BYTE_OFFSET = 3; +export declare const PAD_ID = 0; +export declare const EOS_ID = 1; +export declare const UNK_ID = 2; +export declare function encode(text: string): number[]; +export declare function decode(tokenIds: readonly number[]): string; +//# sourceMappingURL=tokens.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/tokens.d.ts.map b/vendor/interscript-ts/dist/ml/imf/tokens.d.ts.map new file mode 100644 index 0000000..7db9650 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/tokens.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/ml/imf/tokens.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,WAAW,IAAI,CAAA;AAC5B,eAAO,MAAM,MAAM,IAAI,CAAA;AACvB,eAAO,MAAM,MAAM,IAAI,CAAA;AACvB,eAAO,MAAM,MAAM,IAAI,CAAA;AAKvB,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAM7C;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAQ1D"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/tokens.js b/vendor/interscript-ts/dist/ml/imf/tokens.js new file mode 100644 index 0000000..08fc6e3 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/tokens.js @@ -0,0 +1,32 @@ +/** + * The canonical ByT5 byte table (shared contract with the Python and + * Ruby runtimes): byte b -> token id b+3, trailing EOS; pad=0, unk=2. + * Token ids are NOT raw byte values — feeding TextEncoder output + * directly as ids silently produces garbage on real checkpoints. + */ +export const BYTE_OFFSET = 3; +export const PAD_ID = 0; +export const EOS_ID = 1; +export const UNK_ID = 2; +const encoder = new TextEncoder(); +const decoder = new TextDecoder("utf-8", { fatal: false }); +export function encode(text) { + const bytes = encoder.encode(text); + const ids = new Array(bytes.length + 1); + for (let i = 0; i < bytes.length; i++) + ids[i] = bytes[i] + BYTE_OFFSET; + ids[bytes.length] = EOS_ID; + return ids; +} +export function decode(tokenIds) { + const out = []; + for (const token of tokenIds) { + if (token === EOS_ID) + break; + if (token === PAD_ID || token === UNK_ID) + continue; + out.push((token - BYTE_OFFSET) % 256); + } + return decoder.decode(new Uint8Array(out)); +} +//# sourceMappingURL=tokens.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/imf/tokens.js.map b/vendor/interscript-ts/dist/ml/imf/tokens.js.map new file mode 100644 index 0000000..ef4faab --- /dev/null +++ b/vendor/interscript-ts/dist/ml/imf/tokens.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/ml/imf/tokens.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAA;AAC5B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAA;AACvB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAA;AACvB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAA;AAEvB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AACjC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;AAE1D,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAClC,MAAM,GAAG,GAAa,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,GAAG,WAAW,CAAA;IACvE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IAC1B,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,QAA2B;IAChD,MAAM,GAAG,GAAa,EAAE,CAAA;IACxB,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,IAAI,KAAK,KAAK,MAAM;YAAE,MAAK;QAC3B,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,MAAM;YAAE,SAAQ;QAClD,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,CAAA;IACvC,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5C,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/index.d.ts b/vendor/interscript-ts/dist/ml/index.d.ts new file mode 100644 index 0000000..81133e8 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/index.d.ts @@ -0,0 +1,24 @@ +/** + * Public API for ML inference in interscript-ts. + * + * End users don't import this directly — they call `transliterateAsync` + * and the runtime transparently loads ML models when a map requires + * one. This module is for: + * - Internal stdlib integration (rababa/secryst functions) + * - Power users who want to load models directly + * + * Usage: + * import { loadModel } from "interscript-ts/ml" + * const rababa = await loadModel({ kind: "rababa", id: "200" }) + * + * Models register themselves on first import of this module's + * `models/` submodules. + */ +export type { Model, ModelArtifacts, ModelFactory, ModelKind, ModelLoadParams, ModelRef, InferenceInputs, InferenceOutputs, InferenceSession, Tensor, } from "./types.js"; +export { registerModel, loadModel, registeredKinds, resetModels, } from "./registry.js"; +export { createSession, detectBackend } from "./session/index.js"; +export { setModelBase, getModelBase } from "./provision/base.js"; +export { loadManifest, resolveManifestEntry, artifactUrls, sidecarFilenames, setInlineManifest, setManifestUrl, type AssetVariant, type Manifest, type ManifestModelEntry, } from "./provision/manifest.js"; +import "./models/rababa/index.js"; +import "./models/secryst/index.js"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/index.d.ts.map b/vendor/interscript-ts/dist/ml/index.d.ts.map new file mode 100644 index 0000000..0b5eaf6 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ml/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,YAAY,EACV,KAAK,EACL,cAAc,EACd,YAAY,EACZ,SAAS,EACT,eAAe,EACf,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,GACP,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,GACZ,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEhE,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,kBAAkB,GACxB,MAAM,yBAAyB,CAAA;AAIhC,OAAO,0BAA0B,CAAA;AACjC,OAAO,2BAA2B,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/index.js b/vendor/interscript-ts/dist/ml/index.js new file mode 100644 index 0000000..01d87f2 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/index.js @@ -0,0 +1,25 @@ +/** + * Public API for ML inference in interscript-ts. + * + * End users don't import this directly — they call `transliterateAsync` + * and the runtime transparently loads ML models when a map requires + * one. This module is for: + * - Internal stdlib integration (rababa/secryst functions) + * - Power users who want to load models directly + * + * Usage: + * import { loadModel } from "interscript-ts/ml" + * const rababa = await loadModel({ kind: "rababa", id: "200" }) + * + * Models register themselves on first import of this module's + * `models/` submodules. + */ +export { registerModel, loadModel, registeredKinds, resetModels, } from "./registry.js"; +export { createSession, detectBackend } from "./session/index.js"; +export { setModelBase, getModelBase } from "./provision/base.js"; +export { loadManifest, resolveManifestEntry, artifactUrls, sidecarFilenames, setInlineManifest, setManifestUrl, } from "./provision/manifest.js"; +// Side-effect: register built-in model kinds. Adding a new model kind +// = adding a new import here. Order doesn't matter. +import "./models/rababa/index.js"; +import "./models/secryst/index.js"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/index.js.map b/vendor/interscript-ts/dist/ml/index.js.map new file mode 100644 index 0000000..d83e7dc --- /dev/null +++ b/vendor/interscript-ts/dist/ml/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ml/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAeH,OAAO,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,WAAW,GACZ,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEhE,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GAIf,MAAM,yBAAyB,CAAA;AAEhC,sEAAsE;AACtE,oDAAoD;AACpD,OAAO,0BAA0B,CAAA;AACjC,OAAO,2BAA2B,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/cleaner.d.ts b/vendor/interscript-ts/dist/ml/models/rababa/cleaner.d.ts new file mode 100644 index 0000000..a967ff7 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/cleaner.d.ts @@ -0,0 +1,11 @@ +/** + * Text cleaner — mirrors `rababa/lib/rababa/{cleaner,arabic/cleaner}.rb`. + * + * Two cleaners, both pure functions: + * - cleanBasic: collapse whitespace, strip + * - cleanArabic: keep only VALID_ARABIC chars, then cleanBasic + */ +export declare function collapseWhitespace(text: string): string; +export declare function cleanBasic(text: string): string; +export declare function cleanArabic(text: string): string; +//# sourceMappingURL=cleaner.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/cleaner.d.ts.map b/vendor/interscript-ts/dist/ml/models/rababa/cleaner.d.ts.map new file mode 100644 index 0000000..9028750 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/cleaner.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cleaner.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/rababa/cleaner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMhD"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/cleaner.js b/vendor/interscript-ts/dist/ml/models/rababa/cleaner.js new file mode 100644 index 0000000..75a5bb7 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/cleaner.js @@ -0,0 +1,21 @@ +/** + * Text cleaner — mirrors `rababa/lib/rababa/{cleaner,arabic/cleaner}.rb`. + * + * Two cleaners, both pure functions: + * - cleanBasic: collapse whitespace, strip + * - cleanArabic: keep only VALID_ARABIC chars, then cleanBasic + */ +import { VALID_ARABIC } from "./haraqat.js"; +export function collapseWhitespace(text) { + return text.replace(/\s+/g, " "); +} +export function cleanBasic(text) { + return collapseWhitespace(text).trim(); +} +const validArabicSet = new Set(VALID_ARABIC); +export function cleanArabic(text) { + return cleanBasic(Array.from(text) + .filter((c) => validArabicSet.has(c)) + .join("")); +} +//# sourceMappingURL=cleaner.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/cleaner.js.map b/vendor/interscript-ts/dist/ml/models/rababa/cleaner.js.map new file mode 100644 index 0000000..ade1873 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/cleaner.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cleaner.js","sourceRoot":"","sources":["../../../../src/ml/models/rababa/cleaner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;AACxC,CAAC;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAA;AAC5C,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,UAAU,CACf,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;SACb,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACpC,IAAI,CAAC,EAAE,CAAC,CACZ,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.d.ts b/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.d.ts new file mode 100644 index 0000000..50da870 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.d.ts @@ -0,0 +1,37 @@ +/** + * Rababa diacritizer — port of `rababa/lib/rababa/arabic/diacritizer.rb`. + * + * Pipeline: + * text → clean → strip diacritics → encode to IDs + * → ONNX inference ({src, lengths}) → logits + * → argmax over classes → haraqat IDs + * → combine: original letters + predicted haraqat + * → reconcile with original input (preserves non-Arabic chars) + * + * The model file is loaded by the provisioner; we receive an + * InferenceSession + config artifacts. + */ +import type { InferenceSession, MLModel, ModelArtifacts, ModelKind } from "../../types.js"; +export interface RababaConfig { + readonly maxLen: number; + readonly batchSize: number; + readonly textEncoder: "BasicArabicEncoder" | "ArabicEncoderWithStartSymbol"; + readonly textCleaner: "basic_cleaners" | "valid_arabic_cleaners"; +} +export interface RababaModel extends MLModel { + readonly kind: ModelKind; + diacritize(text: string): Promise; + transform(input: string): Promise; + dispose(): Promise; +} +/** + * Factory: builds a RababaModel from a session + artifacts. + * + * Registered as the factory for kind "rababa" in src/ml/index.ts. + */ +export declare function createRababaModel(params: { + readonly session: InferenceSession; + readonly artifacts: ModelArtifacts; + readonly config?: RababaConfig; +}): Promise; +//# sourceMappingURL=diacritizer.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.d.ts.map b/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.d.ts.map new file mode 100644 index 0000000..b831f9f --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"diacritizer.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/rababa/diacritizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAEhB,OAAO,EACP,cAAc,EACd,SAAS,EAEV,MAAM,gBAAgB,CAAA;AAKvB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,oBAAoB,GAAG,8BAA8B,CAAA;IAC3E,QAAQ,CAAC,WAAW,EAAE,gBAAgB,GAAG,uBAAuB,CAAA;CACjE;AASD,MAAM,WAAW,WAAY,SAAQ,OAAO;IAC1C,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACzC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AAyID;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAC9C,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAA;CAC/B,GAAG,OAAO,CAAC,WAAW,CAAC,CAGvB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.js b/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.js new file mode 100644 index 0000000..0e1db71 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.js @@ -0,0 +1,174 @@ +/** + * Rababa diacritizer — port of `rababa/lib/rababa/arabic/diacritizer.rb`. + * + * Pipeline: + * text → clean → strip diacritics → encode to IDs + * → ONNX inference ({src, lengths}) → logits + * → argmax over classes → haraqat IDs + * → combine: original letters + predicted haraqat + * → reconcile with original input (preserves non-Arabic chars) + * + * The model file is loaded by the provisioner; we receive an + * InferenceSession + config artifacts. + */ +import { ArabicEncoder } from "./encoder.js"; +import { reconcileStrings } from "./reconciler.js"; +import { ID_TO_HARAAQAT, INPUT_ID_TO_SYMBOL } from "./haraqat.js"; +const DEFAULT_CONFIG = { + maxLen: 200, + batchSize: 1, + textEncoder: "ArabicEncoderWithStartSymbol", + textCleaner: "valid_arabic_cleaners", +}; +class RababaModelImpl { + kind = "rababa"; + session; + encoder; + config; + constructor(session, config) { + this.session = session; + this.config = config; + this.encoder = new ArabicEncoder({ + cleaner: config.textCleaner === "valid_arabic_cleaners" ? "arabic" : "basic", + startSymbol: config.textEncoder === "ArabicEncoderWithStartSymbol", + }); + } + async diacritize(text) { + // Truncate if too long + let truncated = text; + if (truncated.length > this.config.maxLen) { + truncated = truncated.slice(0, this.config.maxLen); + } + // Clean → strip existing diacritics → encode + const cleaned = this.encoder.clean(truncated); + const stripped = this.stripDiacritics(cleaned); + const sequence = this.encoder.inputToSequence(stripped); + if (sequence.length === 0) + return truncated; + // Replicate the sequence batch_size times, padded to maxLen. + // The trained rababa model is fixed-shape [batch_size, max_len]. + // We replicate the input row batch_size times (matching Ruby's + // diacritize_text) and pad each row to maxLen with the pad token. + const batchSize = this.config.batchSize; + const maxLen = this.config.maxLen; + const padToken = this.encoder.inputPadId; + const flat = []; + for (let b = 0; b < batchSize; b++) { + for (let i = 0; i < maxLen; i++) { + flat.push(i < sequence.length ? sequence[i] : padToken); + } + } + // Inference: {src, lengths} + const src = { + name: "src", + type: "int64", + data: new BigInt64Array(flat.map((n) => BigInt(n))), + dims: [batchSize, maxLen], + }; + const lengths = { + name: "lengths", + type: "int64", + data: new BigInt64Array(Array(batchSize).fill(BigInt(maxLen))), + dims: [batchSize], + }; + const outputs = await this.session.run({ src, lengths }); + // Outputs[0] is the predictions tensor: [batch, seq, classes]. + const out = outputs[this.session.outputNames[0]]; + if (!out) + throw new Error("Rababa model produced no output"); + const preds = argmaxBatch(out, sequence.length); + const combined = combineTextAndHaraqat(sequence, preds, this.encoder.inputPadId); + return reconcileStrings(cleaned, combined); + } + /** Unified MLModel interface — delegates to diacritize. */ + async transform(input) { + return this.diacritize(input); + } + /** + * Strip haraqat from text — direct port of the Ruby + * remove_diacritics. We reuse the encoder's vocab check. + */ + stripDiacritics(text) { + return Array.from(text) + .filter((c) => !/[ً-ْ]/.test(c)) + .join(""); + } + async dispose() { + await this.session.dispose(); + } +} +/** + * Argmax over the last axis of a [batch, seq, classes] tensor. + * Returns one class index per (batch, seq) position. + */ +function argmaxBatch(tensor, seqLen) { + const dims = tensor.dims; + // Last dim is classes + const classCount = dims[dims.length - 1]; + const out = []; + // Treat data as flat floats or ints + const data = tensor.data; + for (let i = 0; i < seqLen; i++) { + let best = 0; + let bestVal = -Infinity; + const base = i * classCount; + for (let c = 0; c < classCount; c++) { + const v = typeof data[base + c] === "bigint" + ? Number(data[base + c]) + : data[base + c]; + if (v > bestVal) { + bestVal = v; + best = c; + } + } + out.push(best); + } + return out; +} +/** + * Combine input token IDs + haraqat IDs into a diacritized string. + * Direct port of `combine_text_and_haraqat`. + */ +function combineTextAndHaraqat(vecTxt, vecHaraqat, padId) { + let text = ""; + for (let i = 0; i < vecTxt.length; i++) { + const txt = vecTxt[i]; + if (txt === padId) + break; + const haraq = vecHaraqat[i] ?? 0; + const symbol = INPUT_ID_TO_SYMBOL[txt] ?? ""; + const haraqStr = ID_TO_HARAAQAT[haraq] ?? ""; + // Skip the pad and unused start tokens in the target vocab — + // they decode to "P" or "" and shouldn't appear in output. + if (haraqStr === "P") + continue; + text += symbol + haraqStr; + } + return text; +} +/** + * Factory: builds a RababaModel from a session + artifacts. + * + * Registered as the factory for kind "rababa" in src/ml/index.ts. + */ +export async function createRababaModel(params) { + const config = params.config ?? parseConfig(params.artifacts["config.json"]); + return new RababaModelImpl(params.session, config); +} +function parseConfig(raw) { + if (!raw) + return DEFAULT_CONFIG; + try { + const json = typeof raw === "string" ? JSON.parse(raw) : JSON.parse(new TextDecoder().decode(raw)); + return { + maxLen: Number(json.max_len ?? json.maxLen ?? DEFAULT_CONFIG.maxLen), + batchSize: Number(json.batch_size ?? json.batchSize ?? DEFAULT_CONFIG.batchSize), + textEncoder: (json.text_encoder ?? DEFAULT_CONFIG.textEncoder), + textCleaner: (json.text_cleaner ?? DEFAULT_CONFIG.textCleaner), + }; + } + catch { + return DEFAULT_CONFIG; + } +} +//# sourceMappingURL=diacritizer.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.js.map b/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.js.map new file mode 100644 index 0000000..247d2f8 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/diacritizer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"diacritizer.js","sourceRoot":"","sources":["../../../../src/ml/models/rababa/diacritizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAUH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AASjE,MAAM,cAAc,GAAiB;IACnC,MAAM,EAAE,GAAG;IACX,SAAS,EAAE,CAAC;IACZ,WAAW,EAAE,8BAA8B;IAC3C,WAAW,EAAE,uBAAuB;CACrC,CAAA;AASD,MAAM,eAAe;IACV,IAAI,GAAc,QAAQ,CAAA;IAClB,OAAO,CAAkB;IACzB,OAAO,CAAe;IACtB,MAAM,CAAc;IAErC,YAAY,OAAyB,EAAE,MAAoB;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC;YAC/B,OAAO,EAAE,MAAM,CAAC,WAAW,KAAK,uBAAuB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO;YAC5E,WAAW,EAAE,MAAM,CAAC,WAAW,KAAK,8BAA8B;SACnE,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAY;QAC3B,uBAAuB;QACvB,IAAI,SAAS,GAAG,IAAI,CAAA;QACpB,IAAI,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YAC1C,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CA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I,CAAC,SAAS,IAAI,cAAc,CAAC,SAAS,CAAC;YAChF,WAAW,EAAE,CAAC,IAAI,CAAC,YAAY,IAAI,cAAc,CAAC,WAAW,CAAgC;YAC7F,WAAW,EAAE,CAAC,IAAI,CAAC,YAAY,IAAI,cAAc,CAAC,WAAW,CAAgC;SAC9F,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,cAAc,CAAA;IACvB,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/encoder.d.ts b/vendor/interscript-ts/dist/ml/models/rababa/encoder.d.ts new file mode 100644 index 0000000..acf601d --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/encoder.d.ts @@ -0,0 +1,40 @@ +/** + * Text encoder — port of `rababa/lib/rababa/arabic/encoders.rb`. + * + * Converts input text into integer sequences the model can consume. + * Two methods: + * - inputToSequence(text): string → number[] (token IDs) + * - reverse: optional, defaults to false (matches Ruby default) + * + * The Ruby BasicArabicEncoder + ArabicEncoderWithStartSymbol collapse + * to a single class with options — they share the same vocab. + */ +export interface ArabicEncoderOptions { + readonly cleaner?: "basic" | "arabic"; + readonly reverseInput?: boolean; + readonly startSymbol?: boolean; +} +export declare class ArabicEncoder { + readonly inputSymbolToId: Readonly>; + readonly inputIdToSymbol: readonly string[]; + readonly inputPadId: number; + readonly startSymbolId: number | null; + private readonly cleanerType; + private readonly reverse; + constructor(opts?: ArabicEncoderOptions); + clean(text: string): string; + /** + * Strip existing haraqat from `text`. Used before encoding so the + * model doesn't see its own output as input. + */ + removeDiacritics(text: string): string; + /** + * Convert a cleaned, diacritics-stripped string into a sequence + * of token IDs. + * + * Skips characters not in the vocab (the Ruby version's + * `.map.reject { |i| i.nil? }`). + */ + inputToSequence(text: string): number[]; +} +//# sourceMappingURL=encoder.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/encoder.d.ts.map b/vendor/interscript-ts/dist/ml/models/rababa/encoder.d.ts.map new file mode 100644 index 0000000..1d77466 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/encoder.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"encoder.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/rababa/encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IACrC,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAC/B;AAED,qBAAa,aAAa;IACxB,QAAQ,CAAC,eAAe,mCAAqB;IAC7C,QAAQ,CAAC,eAAe,oBAAqB;IAC7C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,IAAI,GAAE,oBAAyB;IAO3C,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI3B;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAMtC;;;;;;OAMG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;CASxC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/encoder.js b/vendor/interscript-ts/dist/ml/models/rababa/encoder.js new file mode 100644 index 0000000..ecd0fb2 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/encoder.js @@ -0,0 +1,57 @@ +/** + * Text encoder — port of `rababa/lib/rababa/arabic/encoders.rb`. + * + * Converts input text into integer sequences the model can consume. + * Two methods: + * - inputToSequence(text): string → number[] (token IDs) + * - reverse: optional, defaults to false (matches Ruby default) + * + * The Ruby BasicArabicEncoder + ArabicEncoderWithStartSymbol collapse + * to a single class with options — they share the same vocab. + */ +import { INPUT_ID_TO_SYMBOL, INPUT_SYMBOL_TO_ID, PAD_SYMBOL, } from "./haraqat.js"; +import { cleanArabic, cleanBasic } from "./cleaner.js"; +export class ArabicEncoder { + inputSymbolToId = INPUT_SYMBOL_TO_ID; + inputIdToSymbol = INPUT_ID_TO_SYMBOL; + inputPadId; + startSymbolId; + cleanerType; + reverse; + constructor(opts = {}) { + this.cleanerType = opts.cleaner ?? "arabic"; + this.reverse = opts.reverseInput ?? false; + this.inputPadId = INPUT_SYMBOL_TO_ID[PAD_SYMBOL]; + this.startSymbolId = opts.startSymbol ? 0 : null; + } + clean(text) { + return this.cleanerType === "arabic" ? cleanArabic(text) : cleanBasic(text); + } + /** + * Strip existing haraqat from `text`. Used before encoding so the + * model doesn't see its own output as input. + */ + removeDiacritics(text) { + return Array.from(text) + .filter((c) => !(c in this.inputSymbolToId === false && /[ً-ْ]/.test(c))) + .join(""); + } + /** + * Convert a cleaned, diacritics-stripped string into a sequence + * of token IDs. + * + * Skips characters not in the vocab (the Ruby version's + * `.map.reject { |i| i.nil? }`). + */ + inputToSequence(text) { + const chars = this.reverse ? Array.from(text).reverse() : Array.from(text); + const out = []; + for (const c of chars) { + const id = this.inputSymbolToId[c]; + if (id !== undefined) + out.push(id); + } + return out; + } +} +//# sourceMappingURL=encoder.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/encoder.js.map b/vendor/interscript-ts/dist/ml/models/rababa/encoder.js.map new file mode 100644 index 0000000..32dadd6 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/encoder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../../../src/ml/models/rababa/encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,GACX,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE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AM,GAAG,GAAa,EAAE,CAAA;QACxB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;YAClC,IAAI,EAAE,KAAK,SAAS;gBAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACpC,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/haraqat.d.ts b/vendor/interscript-ts/dist/ml/models/rababa/haraqat.d.ts new file mode 100644 index 0000000..9d80550 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/haraqat.d.ts @@ -0,0 +1,49 @@ +/** + * Arabic haraqat (diacritic marks) + character classes. + * + * Direct port of `rababa/lib/rababa/arabic.rb` constants. These are + * Unicode code-point references — kept exactly as the Ruby source + * defines them so the encoder vocab matches the trained model. + */ +/** Single haraqat (basic diacritics). */ +export declare const HARAQAT: readonly ["ْ", "ّ", "ٌ", "ٍ", "ِ", "ً", "َ", "ُ"]; +/** Unicode escapes of HARAQAT for clarity. */ +export declare const UHARAQAT: readonly ["ْ", "ّ", "ٌ", "ٍ", "ِ", "ً", "َ", "ُ"]; +/** Punctuations allowed by the Arabic cleaner. */ +export declare const PUNCTUATIONS: readonly [".", "،", ":", "؛", "-", "؟"]; +/** Arabic characters the model accepts (including space). */ +export declare const ARAB_CHARS = "\u0649\u0639\u0638\u062D\u0631\u0633\u064A\u0634\u0636\u0642 \u062B\u0644\u0635\u0637\u0643\u0622\u0645\u0627\u0625\u0647\u0632\u0621\u0623\u0641\u0624\u063A\u062C\u0626\u062F\u0629\u062E\u0648\u0628\u0630\u062A\u0646"; +/** Arabic characters without the space. */ +export declare const ARAB_CHARS_NO_SPACE = "\u0649\u0639\u0638\u062D\u0631\u0633\u064A\u0634\u0636\u0642\u062B\u0644\u0635\u0637\u0643\u0622\u0645\u0627\u0625\u0647\u0632\u0621\u0623\u0641\u0624\u063A\u062C\u0626\u062F\u0629\u062E\u0648\u0628\u0630\u062A\u0646"; +/** Valid Arabic characters for the cleaner's whitelist. */ +export declare const VALID_ARABIC: string[]; +/** + * Map of basic haraqat → display name. Used for human-readable + * diagnostics; the model uses indices into ALL_POSSIBLE_HARAQAT. + */ +export declare const BASIC_HARAQAT: Readonly>; +/** + * Complete output vocabulary: every haraqat combination the model + * can predict. Index into this dict = target token ID. + * + * Order matters — must match the model's training-time vocab order. + */ +export declare const ALL_POSSIBLE_HARAQAT: Readonly>; +/** + * Reverse lookup: haraqat string → index. Matches the encoder's + * `@target_symbol_to_id`. + */ +export declare const HARAAQAT_TO_ID: Readonly>; +export declare const ID_TO_HARAAQAT: readonly string[]; +/** + * Input vocab used by BasicArabicEncoder. Index 0 = pad ("P"); + * remaining indices match the source's input_chars string. + * + * Direct port of `rababa/lib/rababa/arabic/encoders.rb:84`. + */ +export declare const INPUT_CHARS = "\u0628\u0636.\u063A\u0649\u0647\u0638\u062E\u0629\u061F:\u0637\u0633\u060C\u061B\u0641\u0646\u062F\u0624\u0644\u0648\u0626\u0622\u0643-\u064A\u0630\u0627\u0635\u0634\u062D\u0632\u0621\u0645\u0623\u062C\u0625 \u062A\u0631\u0642\u0639\u062B"; +export declare const PAD_SYMBOL = "P"; +export declare const INPUT_VOCAB: readonly string[]; +export declare const INPUT_SYMBOL_TO_ID: Readonly>; +export declare const INPUT_ID_TO_SYMBOL: readonly string[]; +//# sourceMappingURL=haraqat.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/haraqat.d.ts.map b/vendor/interscript-ts/dist/ml/models/rababa/haraqat.d.ts.map new file mode 100644 index 0000000..1a35596 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/haraqat.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"haraqat.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/rababa/haraqat.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yCAAyC;AACzC,eAAO,MAAM,OAAO,mDAEV,CAAA;AAEV,8CAA8C;AAC9C,eAAO,MAAM,QAAQ,mDAEX,CAAA;AAEV,kDAAkD;AAClD,eAAO,MAAM,YAAY,yCAA0C,CAAA;AAEnE,6DAA6D;AAC7D,eAAO,MAAM,UAAU,8NAA0C,CAAA;AAEjE,2CAA2C;AAC3C,eAAO,MAAM,mBAAmB,6NACQ,CAAA;AAExC,2DAA2D;AAC3D,eAAO,MAAM,YAAY,UAA8B,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASzD,CAAA;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBhE,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3D,CAAA;AAaD,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAI3C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,mPAAgD,CAAA;AAExE,eAAO,MAAM,UAAU,MAAM,CAAA;AAC7B,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAAiC,CAAA;AAC1E,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE/D,CAAA;AACD,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAgB,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/haraqat.js b/vendor/interscript-ts/dist/ml/models/rababa/haraqat.js new file mode 100644 index 0000000..f91823a --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/haraqat.js @@ -0,0 +1,93 @@ +/** + * Arabic haraqat (diacritic marks) + character classes. + * + * Direct port of `rababa/lib/rababa/arabic.rb` constants. These are + * Unicode code-point references — kept exactly as the Ruby source + * defines them so the encoder vocab matches the trained model. + */ +/** Single haraqat (basic diacritics). */ +export const HARAQAT = [ + "ْ", "ّ", "ٌ", "ٍ", "ِ", "ً", "َ", "ُ", +]; +/** Unicode escapes of HARAQAT for clarity. */ +export const UHARAQAT = [ + "ْ", "ّ", "ٌ", "ٍ", "ِ", "ً", "َ", "ُ", +]; +/** Punctuations allowed by the Arabic cleaner. */ +export const PUNCTUATIONS = [".", "،", ":", "؛", "-", "؟"]; +/** Arabic characters the model accepts (including space). */ +export const ARAB_CHARS = "ىعظحرسيشضق ثلصطكآماإهزءأفؤغجئدةخوبذتن"; +/** Arabic characters without the space. */ +export const ARAB_CHARS_NO_SPACE = "ىعظحرسيشضقثلصطكآماإهزءأفؤغجئدةخوبذتن"; +/** Valid Arabic characters for the cleaner's whitelist. */ +export const VALID_ARABIC = [...HARAQAT, ...ARAB_CHARS]; +/** + * Map of basic haraqat → display name. Used for human-readable + * diagnostics; the model uses indices into ALL_POSSIBLE_HARAQAT. + */ +export const BASIC_HARAQAT = Object.freeze({ + "َ": "Fatha", + "ً": "Fathatah", + "ُ": "Damma", + "ٌ": "Dammatan", + "ِ": "Kasra", + "ٍ": "Kasratan", + "ْ": "Sukun", + "ّ": "Shaddah", +}); +/** + * Complete output vocabulary: every haraqat combination the model + * can predict. Index into this dict = target token ID. + * + * Order matters — must match the model's training-time vocab order. + */ +export const ALL_POSSIBLE_HARAQAT = Object.freeze({ + "": "No Diacritic", + "َ": "Fatha", + "ً": "Fathatah", + "ُ": "Damma", + "ٌ": "Dammatan", + "ِ": "Kasra", + "ٍ": "Kasratan", + "ْ": "Sukun", + "ّ": "Shaddah", + "َّ": "Shaddah + Fatha", + "ًّ": "Shaddah + Fathatah", + "ُّ": "Shaddah + Damma", + "ٌّ": "Shaddah + Dammatan", + "ِّ": "Shaddah + Kasra", + "ٍّ": "Shaddah + Kasratan", +}); +/** + * Reverse lookup: haraqat string → index. Matches the encoder's + * `@target_symbol_to_id`. + */ +export const HARAAQAT_TO_ID = Object.freeze(Object.fromEntries(Object.keys(ALL_POSSIBLE_HARAQAT).map((k, i) => [k, i]))); +/** + * Reverse lookup: index → haraqat string. Matches the encoder's + * `@target_id_to_symbol`. + * + * The model's target vocab is `[@pad] + ALL_POSSIBLE_HARAQAT.keys`, + * so index 0 = pad ("P", treated as no-op) and indices 1..15 are + * the haraqat combinations. The model output has 17 classes (extra + * slot for start token "s" used during training); the last index + * is unused at inference time and decodes to "". + */ +const TARGET_PAD_SYMBOL = "P"; +export const ID_TO_HARAAQAT = [ + TARGET_PAD_SYMBOL, + ...Object.keys(ALL_POSSIBLE_HARAQAT), + "", +]; +/** + * Input vocab used by BasicArabicEncoder. Index 0 = pad ("P"); + * remaining indices match the source's input_chars string. + * + * Direct port of `rababa/lib/rababa/arabic/encoders.rb:84`. + */ +export const INPUT_CHARS = "بض.غىهظخة؟:طس،؛فندؤلوئآك-يذاصشحزءمأجإ ترقعث"; +export const PAD_SYMBOL = "P"; +export const INPUT_VOCAB = [PAD_SYMBOL, ...INPUT_CHARS]; +export const INPUT_SYMBOL_TO_ID = Object.freeze(Object.fromEntries(INPUT_VOCAB.map((s, i) => [s, i]))); +export const INPUT_ID_TO_SYMBOL = INPUT_VOCAB; +//# sourceMappingURL=haraqat.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/haraqat.js.map b/vendor/interscript-ts/dist/ml/models/rababa/haraqat.js.map new file mode 100644 index 0000000..1081a65 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/haraqat.js.map @@ -0,0 +1 @@ +{"version":3,"file":"haraqat.js","sourceRoot":"","sources":["../../../../src/ml/models/rababa/haraqat.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yCAAyC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,E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AAiB;IACvB,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,oBAAoB;CAC3B,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAqC,MAAM,CAAC,MAAM,CAC3E,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAC5E,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAC7B,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC/C,iBAAiB;IACjB,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;IACpC,EAAE;CACH,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,6CAA6C,CAAA;AAExE,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;AAC7B,MAAM,CAAC,MAAM,WAAW,GAAsB,CAAC,UAAU,EAAE,GAAG,WAAW,CAAC,CAAA;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAqC,MAAM,CAAC,MAAM,CAC/E,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CACtD,CAAA;AACD,MAAM,CAAC,MAAM,kBAAkB,GAAsB,WAAW,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/index.d.ts b/vendor/interscript-ts/dist/ml/models/rababa/index.d.ts new file mode 100644 index 0000000..df1d1e7 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/index.d.ts @@ -0,0 +1,12 @@ +/** + * Rababa model registration — side-effect import. + * + * Importing this module registers the "rababa" factory with the ML + * registry. Done in `src/ml/index.ts` so end users don't need to. + */ +export type { RababaModel, RababaConfig } from "./diacritizer.js"; +export { ArabicEncoder } from "./encoder.js"; +export { reconcileStrings } from "./reconciler.js"; +export { cleanArabic, cleanBasic, collapseWhitespace } from "./cleaner.js"; +export * from "./haraqat.js"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/index.d.ts.map b/vendor/interscript-ts/dist/ml/models/rababa/index.d.ts.map new file mode 100644 index 0000000..ce9a26a --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/rababa/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAC1E,cAAc,cAAc,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/index.js b/vendor/interscript-ts/dist/ml/models/rababa/index.js new file mode 100644 index 0000000..079b783 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/index.js @@ -0,0 +1,14 @@ +/** + * Rababa model registration — side-effect import. + * + * Importing this module registers the "rababa" factory with the ML + * registry. Done in `src/ml/index.ts` so end users don't need to. + */ +import { registerModel } from "../../registry.js"; +import { createRababaModel } from "./diacritizer.js"; +registerModel("rababa", async (params) => createRababaModel(params)); +export { ArabicEncoder } from "./encoder.js"; +export { reconcileStrings } from "./reconciler.js"; +export { cleanArabic, cleanBasic, collapseWhitespace } from "./cleaner.js"; +export * from "./haraqat.js"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/index.js.map b/vendor/interscript-ts/dist/ml/models/rababa/index.js.map new file mode 100644 index 0000000..520e298 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ml/models/rababa/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGpD,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAA;AAGpE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAC1E,cAAc,cAAc,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/reconciler.d.ts b/vendor/interscript-ts/dist/ml/models/rababa/reconciler.d.ts new file mode 100644 index 0000000..2507dcc --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/reconciler.d.ts @@ -0,0 +1,29 @@ +/** + * Reconciler — port of `rababa/lib/rababa/arabic/reconciler.rb`. + * + * Given: + * - strOriginal: original text including digits, punctuation, etc. + * - strDiacritized: model output (Arabic letters + haraqat only; + * non-Arabic chars dropped by the encoder) + * + * Produce a merged string where: + * - Arabic letters from `strOriginal` get the haraqat from the + * matching position in `strDiacritized` + * - Non-Arabic chars from `strOriginal` are preserved at their + * original positions + * + * The Ruby algorithm: + * 1. Build pivot map: pairs of (idx_dia, idx_ori) where the chars match + * 2. Walk both strings, emitting chars from original until next pivot, + * then chars from diacritized until next pivot, then the matched + * char itself + * 3. Finalize: remaining diacritized chars, then remaining original chars + * + * Direct port — same shape, same edge cases. + */ +/** + * Merge original + diacritized into the final output. Direct port of + * `reconcile_strings`. + */ +export declare function reconcileStrings(strOriginal: string, strDiacritized: string): string; +//# sourceMappingURL=reconciler.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/reconciler.d.ts.map b/vendor/interscript-ts/dist/ml/models/rababa/reconciler.d.ts.map new file mode 100644 index 0000000..018240d --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/reconciler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/rababa/reconciler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAqCH;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CA2BpF"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/reconciler.js b/vendor/interscript-ts/dist/ml/models/rababa/reconciler.js new file mode 100644 index 0000000..c0556ae --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/reconciler.js @@ -0,0 +1,81 @@ +/** + * Reconciler — port of `rababa/lib/rababa/arabic/reconciler.rb`. + * + * Given: + * - strOriginal: original text including digits, punctuation, etc. + * - strDiacritized: model output (Arabic letters + haraqat only; + * non-Arabic chars dropped by the encoder) + * + * Produce a merged string where: + * - Arabic letters from `strOriginal` get the haraqat from the + * matching position in `strDiacritized` + * - Non-Arabic chars from `strOriginal` are preserved at their + * original positions + * + * The Ruby algorithm: + * 1. Build pivot map: pairs of (idx_dia, idx_ori) where the chars match + * 2. Walk both strings, emitting chars from original until next pivot, + * then chars from diacritized until next pivot, then the matched + * char itself + * 3. Finalize: remaining diacritized chars, then remaining original chars + * + * Direct port — same shape, same edge cases. + */ +import { ARAB_CHARS_NO_SPACE } from "./haraqat.js"; +const HARAQAT_SET = new Set(["ْ", "ّ", "ٌ", "ٍ", "ِ", "ً", "َ", "ُ"]); +const ARAB_CHARS_SET = new Set(ARAB_CHARS_NO_SPACE); +/** + * Find indices where `dOriginal` and `dDiacritized` agree. Two-pointer + * scan: for each char in diacritized, find next matching char in original. + */ +function buildPivotMap(dOriginal, dDiacritized) { + const out = []; + let idxOri = 0; + for (let idxDia = 0; idxDia < dDiacritized.length; idxDia++) { + const cDia = dDiacritized[idxDia]; + for (let i = idxOri; i <= dOriginal.length; i++) { + if (cDia === dOriginal[i]) { + idxOri = i; + out.push({ idxDia, idxOri }); + // Skip past arabic letters to avoid double-counting + if (ARAB_CHARS_SET.has(cDia)) + idxOri++; + break; + } + } + } + return out; +} +/** + * Merge original + diacritized into the final output. Direct port of + * `reconcile_strings`. + */ +export function reconcileStrings(strOriginal, strDiacritized) { + const dOriginal = Array.from(strOriginal).filter((c) => !HARAQAT_SET.has(c)); + const dDiacritized = Array.from(strDiacritized); + const pivots = buildPivotMap(dOriginal, dDiacritized); + let out = ""; + let ptDia = 0; + let ptOri = 0; + for (const { idxDia, idxOri } of pivots) { + if (ptOri < idxOri) { + for (let i = ptOri; i < idxOri; i++) + out += dOriginal[i]; + } + if (ptDia < idxDia) { + for (let i = ptDia; i < idxDia; i++) + out += dDiacritized[i]; + } + out += dOriginal[idxOri] ?? ""; + ptDia = idxDia + 1; + ptOri = idxOri + 1; + } + // Trailing diacritized chars + for (let i = ptDia; i < dDiacritized.length; i++) + out += dDiacritized[i]; + // Trailing original chars + for (let i = ptOri; i < dOriginal.length; i++) + out += dOriginal[i]; + return out; +} +//# sourceMappingURL=reconciler.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/rababa/reconciler.js.map b/vendor/interscript-ts/dist/ml/models/rababa/reconciler.js.map new file mode 100644 index 0000000..fd06089 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/rababa/reconciler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"reconciler.js","sourceRoot":"","sources":["../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G,CAAA;AACZ,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/index.d.ts b/vendor/interscript-ts/dist/ml/models/secryst/index.d.ts new file mode 100644 index 0000000..8d2fe80 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/index.d.ts @@ -0,0 +1,10 @@ +/** + * Secryst model registration — side-effect import. + * + * Importing this module registers the "secryst" factory with the ML + * registry. Done in `src/ml/index.ts` so end users don't need to. + */ +export type { SecrystModel } from "./translator.js"; +export { Vocab, parseVocabYaml, buildVocabs } from "./vocab.js"; +export { causalMask, paddingMask, buildMasks } from "./masks.js"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/index.d.ts.map b/vendor/interscript-ts/dist/ml/models/secryst/index.d.ts.map new file mode 100644 index 0000000..2976df0 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/secryst/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/index.js b/vendor/interscript-ts/dist/ml/models/secryst/index.js new file mode 100644 index 0000000..9d4e655 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/index.js @@ -0,0 +1,12 @@ +/** + * Secryst model registration — side-effect import. + * + * Importing this module registers the "secryst" factory with the ML + * registry. Done in `src/ml/index.ts` so end users don't need to. + */ +import { registerModel } from "../../registry.js"; +import { createSecrystModel } from "./translator.js"; +registerModel("secryst", async (params) => createSecrystModel(params)); +export { Vocab, parseVocabYaml, buildVocabs } from "./vocab.js"; +export { causalMask, paddingMask, buildMasks } from "./masks.js"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/index.js.map b/vendor/interscript-ts/dist/ml/models/secryst/index.js.map new file mode 100644 index 0000000..b110d42 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ml/models/secryst/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGpD,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAA;AAGtE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/masks.d.ts b/vendor/interscript-ts/dist/ml/models/secryst/masks.d.ts new file mode 100644 index 0000000..de30621 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/masks.d.ts @@ -0,0 +1,33 @@ +/** + * Attention masks for the Secryst transformer. + * + * Port of the mask construction logic from + * `secryst/lib/secryst/translator.rb`. + * + * The transformer needs three mask types: + * - tgt_mask: causal mask (lower-triangular) prevents attending to future positions + * - src_key_padding_mask: marks padding tokens in the source + * - tgt_key_padding_mask: marks padding tokens in the target + * - memory_key_padding_mask: same as src_key_padding_mask + */ +import type { Tensor } from "../../types.js"; +/** + * Build a causal (lower-triangular) attention mask. + * Shape: [seq_len, seq_len]. 1 = allowed, 0 = masked. + * + * Port of: Numo::DFloat.ones(n,n).triu.transpose.eq(0) + * → upper triangular of ones → transpose → lower triangular → negate + */ +export declare function causalMask(seqLen: number): Uint8Array; +/** + * Build a padding mask from a token ID sequence. + * Pad ID = 1 in secryst (matching the Ruby code). + * Shape: [batch, seq_len]. 1 = real token, 0 = padding. + */ +export declare function paddingMask(tokens: readonly number[], padId?: number): Uint8Array; +/** + * Construct all masks needed for one inference step. + * Returns tensors in the format the ONNX model expects. + */ +export declare function buildMasks(srcLen: number, tgtLen: number, srcIds: readonly number[], tgtIds: readonly number[]): Record; +//# sourceMappingURL=masks.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/masks.d.ts.map b/vendor/interscript-ts/dist/ml/models/secryst/masks.d.ts.map new file mode 100644 index 0000000..c9335b7 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/masks.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"masks.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/secryst/masks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CASrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,KAAK,GAAE,MAAU,GAChB,UAAU,CAEZ;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,SAAS,MAAM,EAAE,GACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+BxB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/masks.js b/vendor/interscript-ts/dist/ml/models/secryst/masks.js new file mode 100644 index 0000000..61ff5da --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/masks.js @@ -0,0 +1,73 @@ +/** + * Attention masks for the Secryst transformer. + * + * Port of the mask construction logic from + * `secryst/lib/secryst/translator.rb`. + * + * The transformer needs three mask types: + * - tgt_mask: causal mask (lower-triangular) prevents attending to future positions + * - src_key_padding_mask: marks padding tokens in the source + * - tgt_key_padding_mask: marks padding tokens in the target + * - memory_key_padding_mask: same as src_key_padding_mask + */ +/** + * Build a causal (lower-triangular) attention mask. + * Shape: [seq_len, seq_len]. 1 = allowed, 0 = masked. + * + * Port of: Numo::DFloat.ones(n,n).triu.transpose.eq(0) + * → upper triangular of ones → transpose → lower triangular → negate + */ +export function causalMask(seqLen) { + const mask = new Uint8Array(seqLen * seqLen); + for (let i = 0; i < seqLen; i++) { + for (let j = 0; j < seqLen; j++) { + // Allow attention to positions ≤ current position (causal) + mask[i * seqLen + j] = j <= i ? 1 : 0; + } + } + return mask; +} +/** + * Build a padding mask from a token ID sequence. + * Pad ID = 1 in secryst (matching the Ruby code). + * Shape: [batch, seq_len]. 1 = real token, 0 = padding. + */ +export function paddingMask(tokens, padId = 1) { + return new Uint8Array(tokens.map((t) => (t === padId ? 0 : 1))); +} +/** + * Construct all masks needed for one inference step. + * Returns tensors in the format the ONNX model expects. + */ +export function buildMasks(srcLen, tgtLen, srcIds, tgtIds) { + const tgt = causalMask(tgtLen); + const srcPad = paddingMask(srcIds); + const tgtPad = paddingMask(tgtIds); + return { + tgt_mask: { + name: "tgt_mask", + type: "int8", + data: tgt, + dims: [tgtLen, tgtLen], + }, + src_key_padding_mask: { + name: "src_key_padding_mask", + type: "int8", + data: srcPad, + dims: [1, srcLen], + }, + tgt_key_padding_mask: { + name: "tgt_key_padding_mask", + type: "int8", + data: tgtPad, + dims: [1, tgtLen], + }, + memory_key_padding_mask: { + name: "memory_key_padding_mask", + type: "int8", + data: srcPad, + dims: [1, srcLen], + }, + }; +} +//# sourceMappingURL=masks.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/masks.js.map b/vendor/interscript-ts/dist/ml/models/secryst/masks.js.map new file mode 100644 index 0000000..23294d8 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/masks.js.map @@ -0,0 +1 @@ +{"version":3,"file":"masks.js","sourceRoot":"","sources":["../../../../src/ml/models/secryst/masks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;IAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,2DAA2D;YAC3D,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,MAAyB,EACzB,QAAgB,CAAC;IAEjB,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,MAAc,EACd,MAAc,EACd,MAAyB,EACzB,MAAyB;IAEzB,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IAC9B,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAClC,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IAElC,OAAO;QACL,QAAQ,EAAE;YACR,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,GAAG;YACT,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;SACvB;QACD,oBAAoB,EAAE;YACpB,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;SAClB;QACD,oBAAoB,EAAE;YACpB,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;SAClB;QACD,uBAAuB,EAAE;YACvB,IAAI,EAAE,yBAAyB;YAC/B,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;SAClB;KACF,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/translator.d.ts b/vendor/interscript-ts/dist/ml/models/secryst/translator.d.ts new file mode 100644 index 0000000..a2074c4 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/translator.d.ts @@ -0,0 +1,31 @@ +/** + * Secryst translator — autoregressive seq2seq decode loop. + * + * Port of `secryst/lib/secryst/translator.rb:translate`. + * + * The transformer generates output one token at a time: + * 1. Encode input: chars → vocab IDs, wrap with / + * 2. Initialize output: [] + * 3. Loop (max_seq_length times): + * a. Build masks for current src + tgt lengths + * b. Run ONNX inference + * c. Argmax → next token ID + * d. If : break + * e. Append to output + * 4. Decode output IDs → string + */ +import type { InferenceSession, MLModel, ModelArtifacts, ModelKind } from "../../types.js"; +export interface SecrystModel extends MLModel { + readonly kind: ModelKind; + translate(text: string, maxSeqLength?: number): Promise; + transform(input: string): Promise; + dispose(): Promise; +} +/** + * Factory: builds a SecrystModel from a session + artifacts. + */ +export declare function createSecrystModel(params: { + readonly session: InferenceSession; + readonly artifacts: ModelArtifacts; +}): Promise; +//# sourceMappingURL=translator.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/translator.d.ts.map b/vendor/interscript-ts/dist/ml/models/secryst/translator.d.ts.map new file mode 100644 index 0000000..0367f13 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/translator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"translator.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/secryst/translator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,gBAAgB,CAAA;AAKlG,MAAM,WAAW,YAAa,SAAQ,OAAO;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/D,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AA8FD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;CACnC,GAAG,OAAO,CAAC,YAAY,CAAC,CAWxB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/translator.js b/vendor/interscript-ts/dist/ml/models/secryst/translator.js new file mode 100644 index 0000000..ca1ed9b --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/translator.js @@ -0,0 +1,114 @@ +/** + * Secryst translator — autoregressive seq2seq decode loop. + * + * Port of `secryst/lib/secryst/translator.rb:translate`. + * + * The transformer generates output one token at a time: + * 1. Encode input: chars → vocab IDs, wrap with / + * 2. Initialize output: [] + * 3. Loop (max_seq_length times): + * a. Build masks for current src + tgt lengths + * b. Run ONNX inference + * c. Argmax → next token ID + * d. If : break + * e. Append to output + * 4. Decode output IDs → string + */ +import { buildVocabs, parseVocabYaml } from "./vocab.js"; +import { buildMasks } from "./masks.js"; +const DEFAULT_MAX_SEQ = 100; +const SOS_TOKEN = ""; +const EOS_TOKEN = ""; +class SecrystModelImpl { + kind = "secryst"; + session; + inputVocab; + targetVocab; + constructor(session, inputVocab, targetVocab) { + this.session = session; + this.inputVocab = inputVocab; + this.targetVocab = targetVocab; + } + async translate(text, maxSeqLength = DEFAULT_MAX_SEQ) { + // Encode input: + chars + + const srcIds = [ + this.inputVocab.encode(SOS_TOKEN), + ...this.inputVocab.encodeSequence(text), + this.inputVocab.encode(EOS_TOKEN), + ].filter((id) => id >= 0); + // Initialize output with + const tgtIds = [this.targetVocab.encode(SOS_TOKEN)]; + const eosId = this.targetVocab.encode(EOS_TOKEN); + for (let step = 0; step < maxSeqLength; step++) { + const masks = buildMasks(srcIds.length, tgtIds.length, srcIds, tgtIds); + const feeds = { + src: { + name: "src", + type: "int64", + data: new BigInt64Array(srcIds.map((n) => BigInt(n))), + dims: [1, srcIds.length], + }, + tgt: { + name: "tgt", + type: "int64", + data: new BigInt64Array(tgtIds.map((n) => BigInt(n))), + dims: [1, tgtIds.length], + }, + ...masks, + }; + const outputs = await this.session.run(feeds); + const out = outputs[this.session.outputNames[0]]; + if (!out) + throw new Error("Secryst model produced no output"); + // Argmax over the last position's class dimension + const dims = out.dims; + const classCount = dims[dims.length - 1]; + const data = out.data; + const lastPosBase = step * classCount; + let bestId = 0; + let bestVal = -Infinity; + for (let c = 0; c < classCount; c++) { + const v = typeof data[lastPosBase + c] === "bigint" + ? Number(data[lastPosBase + c]) + : data[lastPosBase + c]; + if (v > bestVal) { + bestVal = v; + bestId = c; + } + } + if (bestId === eosId) + break; + tgtIds.push(bestId); + } + // Drop the and return decoded text + return this.targetVocab.decodeSequence(tgtIds.slice(1)); + } + /** Unified MLModel interface — processes line by line (matching Ruby). */ + async transform(input) { + const lines = input.split("\n"); + const results = []; + for (const line of lines) { + results.push(await this.translate(line)); + } + return results.join("\n"); + } + async dispose() { + await this.session.dispose(); + } +} +/** + * Factory: builds a SecrystModel from a session + artifacts. + */ +export async function createSecrystModel(params) { + const vocabsRaw = params.artifacts["vocabs.yaml"]; + if (!vocabsRaw) { + throw new Error("Secryst model missing vocabs.yaml"); + } + const yamlStr = typeof vocabsRaw === "string" + ? vocabsRaw + : new TextDecoder().decode(vocabsRaw); + const data = parseVocabYaml(yamlStr); + const { input, target } = buildVocabs(data); + return new SecrystModelImpl(params.session, input, target); +} +//# sourceMappingURL=translator.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/translator.js.map b/vendor/interscript-ts/dist/ml/models/secryst/translator.js.map new file mode 100644 index 0000000..bd954bf --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/translator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"translator.js","sourceRoot":"","sources":["../../../../src/ml/models/secryst/translator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AASvC,MAAM,eAAe,GAAG,GAAG,CAAA;AAC3B,MAAM,SAAS,GAAG,OAAO,CAAA;AACzB,MAAM,SAAS,GAAG,OAAO,CAAA;AAEzB,MAAM,gBAAgB;IACX,IAAI,GAAc,SAAS,CAAA;IACnB,OAAO,CAAkB;IACzB,UAAU,CAAO;IACjB,WAAW,CAAO;IAEnC,YAAY,OAAyB,EAAE,UAAiB,EAAE,WAAkB;QAC1E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU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line at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/vocab.d.ts b/vendor/interscript-ts/dist/ml/models/secryst/vocab.d.ts new file mode 100644 index 0000000..00bef77 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/vocab.d.ts @@ -0,0 +1,39 @@ +/** + * Secryst vocabulary — port of `secryst/lib/secryst/vocab.rb`. + * + * Maps tokens to integer IDs (stoi) and back (itos). Supports + * special tokens (, , ) alongside character-level + * vocab. + */ +export interface VocabData { + readonly input: readonly string[]; + readonly target: readonly string[]; +} +export declare class Vocab { + readonly stoi: Readonly>; + readonly itos: readonly string[]; + readonly length: number; + constructor(tokens: readonly string[], specials?: readonly string[]); + /** String to ID. Returns -1 for unknown tokens. */ + encode(token: string): number; + /** ID to string. Returns "" for unknown IDs. */ + decode(id: number): string; + /** Encode a string into a sequence of token IDs. */ + encodeSequence(text: string): number[]; + /** Decode a sequence of token IDs back into a string. */ + decodeSequence(ids: readonly number[]): string; +} +/** + * Parse vocab data from YAML format (as stored in the model zip). + * Uses js-yaml if available, otherwise a minimal YAML parser for + * the simple list format secryst uses. + */ +export declare function parseVocabYaml(yaml: string): VocabData; +/** + * Build Vocab instances from parsed data. + */ +export declare function buildVocabs(data: VocabData): { + input: Vocab; + target: Vocab; +}; +//# sourceMappingURL=vocab.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/vocab.d.ts.map b/vendor/interscript-ts/dist/ml/models/secryst/vocab.d.ts.map new file mode 100644 index 0000000..5fd5219 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/vocab.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"vocab.d.ts","sourceRoot":"","sources":["../../../../src/ml/models/secryst/vocab.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CACnC;AAED,qBAAa,KAAK;IAChB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC/C,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBAEX,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,QAAQ,GAAE,SAAS,MAAM,EAAO;IASvE,mDAAmD;IACnD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI7B,gDAAgD;IAChD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI1B,oDAAoD;IACpD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAItC,yDAAyD;IACzD,cAAc,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM;CAG/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAmCtD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,KAAK,CAAA;CAAE,CAK5E"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/vocab.js b/vendor/interscript-ts/dist/ml/models/secryst/vocab.js new file mode 100644 index 0000000..3a53fe6 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/vocab.js @@ -0,0 +1,85 @@ +/** + * Secryst vocabulary — port of `secryst/lib/secryst/vocab.rb`. + * + * Maps tokens to integer IDs (stoi) and back (itos). Supports + * special tokens (, , ) alongside character-level + * vocab. + */ +export class Vocab { + stoi; + itos; + length; + constructor(tokens, specials = []) { + const all = [...specials, ...tokens]; + this.itos = all; + this.stoi = Object.freeze(Object.fromEntries(all.map((t, i) => [t, i]))); + this.length = all.length; + } + /** String to ID. Returns -1 for unknown tokens. */ + encode(token) { + return this.stoi[token] ?? -1; + } + /** ID to string. Returns "" for unknown IDs. */ + decode(id) { + return this.itos[id] ?? ""; + } + /** Encode a string into a sequence of token IDs. */ + encodeSequence(text) { + return Array.from(text).map((c) => this.encode(c)); + } + /** Decode a sequence of token IDs back into a string. */ + decodeSequence(ids) { + return ids.map((id) => this.decode(id)).join(""); + } +} +/** + * Parse vocab data from YAML format (as stored in the model zip). + * Uses js-yaml if available, otherwise a minimal YAML parser for + * the simple list format secryst uses. + */ +export function parseVocabYaml(yaml) { + // Secryst vocabs are simple YAML: + // input: + // - "" + // - "" + // - "a" + // target: + // - "" + // - ... + // + // We use a minimal parser instead of requiring js-yaml as a dep. + const lines = yaml.split("\n"); + let section = null; + const input = []; + const target = []; + for (const line of lines) { + const trimmed = line.trimEnd(); + if (trimmed === "input:") { + section = "input"; + continue; + } + if (trimmed === "target:") { + section = "target"; + continue; + } + const match = trimmed.match(/^\s+-\s+"?(.+?)"?\s*$/); + if (match && section) { + const token = match[1]; + if (section === "input") + input.push(token); + else + target.push(token); + } + } + return { input, target }; +} +/** + * Build Vocab instances from parsed data. + */ +export function buildVocabs(data) { + return { + input: new Vocab(data.input), + target: new Vocab(data.target), + }; +} +//# sourceMappingURL=vocab.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/models/secryst/vocab.js.map b/vendor/interscript-ts/dist/ml/models/secryst/vocab.js.map new file mode 100644 index 0000000..6d8a72e --- /dev/null +++ b/vendor/interscript-ts/dist/ml/models/secryst/vocab.js.map @@ -0,0 +1 @@ +{"version":3,"file":"vocab.js","sourceRoot":"","sources":["../../../../src/ml/models/secryst/vocab.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,MAAM,OAAO,KAAK;IACP,IAAI,CAAkC;IACtC,IAAI,CAAmB;IACvB,MAAM,CAAQ;IAEvB,YAAY,MAAyB,EAAE,WAA8B,EAAE;QACrE,MAAM,GAAG,GAAG,CAAC,GAAG,QAA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AAO,GAA8B,IAAI,CAAA;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,MAAM,MAAM,GAAa,EAAE,CAAA;IAE3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAC9B,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzB,OAAO,GAAG,OAAO,CAAA;YACjB,SAAQ;QACV,CAAC;QACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,QAAQ,CAAA;YAClB,SAAQ;QACV,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;QACpD,IAAI,KAAK,IAAI,OAAO,EAAE,CAAC;YACrB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;YACvB,IAAI,OAAO,KAAK,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;;gBACrC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,IAAe;IACzC,OAAO;QACL,KAAK,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5B,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;KAC/B,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/base.d.ts b/vendor/interscript-ts/dist/ml/provision/base.d.ts new file mode 100644 index 0000000..dba5c5e --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/base.d.ts @@ -0,0 +1,14 @@ +/** + * Base URL for model artifacts. Owned here so every provisioner + * (HTTP fetcher, manifest loader, future IPFS/Bittorrent) reads + * from the same source. No circular deps. + * + * Default points at the jsDelivr mirror of `interscript/ml-models` + * — works without npm install, edge-cached globally. + * + * Override at runtime with `setModelBase()` for self-hosted mirrors, + * air-gapped envs, or staging deployments. + */ +export declare function setModelBase(url: string): void; +export declare function getModelBase(): string; +//# sourceMappingURL=base.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/base.d.ts.map b/vendor/interscript-ts/dist/ml/provision/base.d.ts.map new file mode 100644 index 0000000..e0e0885 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/base.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ml/provision/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/base.js b/vendor/interscript-ts/dist/ml/provision/base.js new file mode 100644 index 0000000..6a3ed51 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/base.js @@ -0,0 +1,19 @@ +/** + * Base URL for model artifacts. Owned here so every provisioner + * (HTTP fetcher, manifest loader, future IPFS/Bittorrent) reads + * from the same source. No circular deps. + * + * Default points at the jsDelivr mirror of `interscript/ml-models` + * — works without npm install, edge-cached globally. + * + * Override at runtime with `setModelBase()` for self-hosted mirrors, + * air-gapped envs, or staging deployments. + */ +let modelBase = "https://cdn.jsdelivr.net/gh/interscript/ml-models@main/npm/models"; +export function setModelBase(url) { + modelBase = url.replace(/\/$/, ""); +} +export function getModelBase() { + return modelBase; +} +//# sourceMappingURL=base.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/base.js.map b/vendor/interscript-ts/dist/ml/provision/base.js.map new file mode 100644 index 0000000..b072b38 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/base.js.map @@ -0,0 +1 @@ +{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/ml/provision/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,IAAI,SAAS,GACX,mEAAmE,CAAA;AAErE,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAS,CAAA;AAClB,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/index.d.ts b/vendor/interscript-ts/dist/ml/provision/index.d.ts new file mode 100644 index 0000000..95bcdf0 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/index.d.ts @@ -0,0 +1,62 @@ +/** + * Model provisioner — fetch + cache model files. + * + * Used by the registry to materialize a ModelRef into a session + + * auxiliary artifacts. Reuses fetch (works in Node 18+ and modern + * browsers); falls back to filesystem reads in Node when given a + * `file:` or relative URL. + * + * The manifest (version → URL mapping) lives in `./manifest.ts`. + * The base URL (CDN mirror override) lives in `./base.ts`. + * + * Adding a new provision source (e.g. IPFS, BitTorrent) = adding a + * new provisioner file. Existing code never changes (OCP). + */ +import type { ModelArtifacts, ModelRef } from "../types.js"; +import type { InferenceSession } from "../session/index.js"; +import { type AssetFormat, type AssetVariant } from "./manifest.js"; +export interface ProvisionedModel { + readonly session: InferenceSession; + readonly artifacts: ModelArtifacts; +} +/** + * Which ONNX variant to download. `q8` is the browser default — + * 8-bit quantized, ~25% the size of fp32 with negligible accuracy + * loss for character-level transformers. Override per-call via + * `provisionModel(ref, { variant: "fp32" })`. + */ +export interface ProvisionOptions { + readonly variant?: AssetVariant; + /** + * Model serialization format. `onnx` (default) selects the + * Microsoft runtime path; `tflite` selects Google's LiteRT.js. + * Both formats can be shipped for the same model — provisioner + * picks based on this option. + */ + readonly format?: AssetFormat; + /** Browser only: enable WebGPU with WASM fallback. Default: true. */ + readonly webgpu?: boolean; + /** + * LiteRT only: accelerator preference. Default: "webgpu". + * No-op for ONNX runtime. + */ + readonly litertAccelerator?: "webgpu" | "webnn" | "wasm"; + /** + * LiteRT only: input/output tensor names. ONNX reads these from + * the model graph; LiteRT needs them supplied by the caller. + * Defaults are correct for rababa models. + */ + readonly inputNames?: readonly string[]; + readonly outputNames?: readonly string[]; +} +/** + * Provision a model from the manifest. Resolves the task version, + * downloads the model file from the CDN (falls back to GitHub + * Releases), opens an inference session, and fetches sidecar + * artifacts (vocab, config, checksum) in parallel. + * + * In Node, can read from the filesystem if `url` starts with `file:` + * or is a relative path. + */ +export declare function provisionModel(ref: ModelRef, opts?: ProvisionOptions): Promise; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/index.d.ts.map b/vendor/interscript-ts/dist/ml/provision/index.d.ts.map new file mode 100644 index 0000000..3776096 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ml/provision/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAA;AAEtB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAA;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IACxD;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACzC;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,QAAQ,EACb,IAAI,GAAE,gBAAqB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAwC3B"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/index.js b/vendor/interscript-ts/dist/ml/provision/index.js new file mode 100644 index 0000000..3389a8e --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/index.js @@ -0,0 +1,107 @@ +/** + * Model provisioner — fetch + cache model files. + * + * Used by the registry to materialize a ModelRef into a session + + * auxiliary artifacts. Reuses fetch (works in Node 18+ and modern + * browsers); falls back to filesystem reads in Node when given a + * `file:` or relative URL. + * + * The manifest (version → URL mapping) lives in `./manifest.ts`. + * The base URL (CDN mirror override) lives in `./base.ts`. + * + * Adding a new provision source (e.g. IPFS, BitTorrent) = adding a + * new provisioner file. Existing code never changes (OCP). + */ +import { createSession } from "../session/index.js"; +import { artifactUrls, resolveManifestEntry, sidecarFilenames, } from "./manifest.js"; +/** + * Provision a model from the manifest. Resolves the task version, + * downloads the model file from the CDN (falls back to GitHub + * Releases), opens an inference session, and fetches sidecar + * artifacts (vocab, config, checksum) in parallel. + * + * In Node, can read from the filesystem if `url` starts with `file:` + * or is a relative path. + */ +export async function provisionModel(ref, opts = {}) { + const variant = opts.variant ?? "q8"; + const format = opts.format ?? "onnx"; + const webgpu = opts.webgpu ?? true; + const modelUrl = ref.url ?? (await resolveModelUrl(ref, variant, format)); + const modelBuffer = await fetchBytesWithFallback(modelUrl); + const sidecars = await resolveSidecarUrls(ref, variant, format); + const artifacts = {}; + await Promise.all(sidecars.map(async ({ filename, url }) => { + try { + const bytes = await fetchBytesWithFallback(url); + if (filename.endsWith(".json") || + filename.endsWith(".yaml") || + filename.endsWith(".yml") || + filename.endsWith(".sha256")) { + artifacts[filename] = new TextDecoder().decode(bytes); + } + else { + artifacts[filename] = bytes; + } + } + catch { + // Sidecars are optional; missing ones are skipped. + } + })); + const sessionOpts = { webgpu }; + if (format === "tflite") { + sessionOpts.runtime = "litert"; + if (opts.litertAccelerator !== undefined) + sessionOpts.litertAccelerator = opts.litertAccelerator; + if (opts.inputNames !== undefined) + sessionOpts.inputNames = opts.inputNames; + if (opts.outputNames !== undefined) + sessionOpts.outputNames = opts.outputNames; + } + const session = await createSession(modelBuffer, sessionOpts); + return { session, artifacts }; +} +async function resolveModelUrl(ref, variant, format) { + const entry = await resolveManifestEntry(ref.kind, ref.id); + if (!entry) { + throw new Error(`No manifest entry for kind=${ref.kind} id=${ref.id}. ` + + `Pass an explicit \`url\` on the ModelRef or pin a task version in the manifest.`); + } + const { primary } = artifactUrls(entry, variant, format); + return primary; +} +async function resolveSidecarUrls(ref, variant, format) { + // If the caller provided an explicit URL, skip manifest-based sidecar + // resolution — they've taken control of provisioning. + if (ref.url) + return []; + const entry = await resolveManifestEntry(ref.kind, ref.id); + if (!entry) + return []; + const { primary, assetName } = artifactUrls(entry, variant, format); + const base = primary.slice(0, primary.lastIndexOf("/") + 1); + return sidecarFilenames(entry, variant, format).map((filename) => ({ + filename, + url: `${base}${filename.startsWith(assetName) ? filename : filename}`, + })); +} +/** + * Fetch bytes from a URL. Tries the URL as-given; if it's the CDN + * primary and fails, the caller can supply a fallback URL via the + * `url` field on the ModelRef. + */ +async function fetchBytesWithFallback(url) { + // Node filesystem path + if (url.startsWith("file:") || + (url.startsWith(".") && typeof process !== "undefined" && process.versions?.node)) { + const { readFile } = await import("node:fs/promises"); + const path = url.startsWith("file:") ? url.slice(5) : url; + return new Uint8Array(await readFile(path)); + } + const res = await fetch(url); + if (!res.ok) { + throw new Error(`Failed to fetch ${url}: ${res.status} ${res.statusText}`); + } + return new Uint8Array(await res.arrayBuffer()); +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/index.js.map b/vendor/interscript-ts/dist/ml/provision/index.js.map new file mode 100644 index 0000000..f8ed5c0 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ml/provision/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GAGjB,MAAM,eAAe,CAAA;AAsCtB;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAa,EACb,OAAyB,EAAE;IAE3B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAA;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAA;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAA;IAElC,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;IAEzE,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC,QAAQ,CAAC,CAAA;IAE1D,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAC/D,MAAM,SAAS,GAAwC,EAAE,CAAA;IACzD,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,EAAE;QACvC,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAA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GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EACjF,CAAC;QACD,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAA;QACrD,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;QACzD,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;IAC7C,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,KAAK,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA;AAChD,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/manifest.d.ts b/vendor/interscript-ts/dist/ml/provision/manifest.d.ts new file mode 100644 index 0000000..9fd706d --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/manifest.d.ts @@ -0,0 +1,79 @@ +/** + * Manifest-driven model resolution. + * + * The source of truth for "what model version is current" lives in + * the `@interscript/models` npm package (a tiny JSON manifest kept + * in lockstep with GH Releases in `interscript/ml-models`). + * + * Resolution order for the manifest itself: + * 1. Programmatically injected via `setManifestUrl()` or + * `setInlineManifest()` (tests, air-gapped envs). + * 2. The `@interscript/models` package, when installed. + * 3. A remote JSON URL on the CDN (`manifest.json` next to the + * release assets). + * + * See `ml-models/TODO.distribution/04-npm-packages.md` for the + * full MECE breakdown of who owns what. + */ +/** + * Per-task manifest entry. Matches `npm/models/manifest.json` shape. + */ +export interface ManifestModelEntry { + readonly status: "preview" | "stable" | "deprecated"; + readonly version: string; + readonly note?: string; + readonly cdn_base: string; + readonly github_base: string; +} +export interface Manifest { + readonly schema_version: number; + readonly models: Readonly>; +} +/** + * Asset variants a release may ship. `fp32` (no suffix) is the + * default; q8 is the browser-optimized default. + */ +export type AssetVariant = "fp32" | "q8" | "q4" | "fp16"; +/** + * Serialization format. ONNX is the historical default; LiteRT (.tflite) + * is the 2026 alternative backed by Google's LiteRT.js runtime. + * + * The two formats are orthogonal to `AssetVariant` — both can be + * quantized to q8, both can be fp32. The runtime that loads the file + * is what differs. + */ +export type AssetFormat = "onnx" | "tflite"; +export declare function setInlineManifest(m: Manifest | null): void; +export declare function setManifestUrl(url: string | null): void; +/** + * Load the manifest. Cached after first call; bust the cache with + * `setInlineManifest()` or `setManifestUrl()`. + */ +export declare function loadManifest(): Promise; +/** + * Resolve a `(kind, id)` ref to a manifest entry. The `id` field on + * a ModelRef carries the task name (e.g. "rababa_arabic"); the kind + * is redundant but kept for backwards compatibility. + * + * Returns `null` if the task isn't in the manifest. Callers decide + * whether that's an error or a "use bundled fallback" signal. + */ +export declare function resolveManifestEntry(kind: string, id: string): Promise; +/** + * Build concrete artifact URLs for a model. Prefers the CDN base; + * GitHub Releases base is the fallback (slower, but no CDN cache). + * + * Both URLs use the same asset naming convention so a downloader + * can verify checksums identically against either source. + */ +export declare function artifactUrls(entry: ManifestModelEntry, variant?: AssetVariant, format?: AssetFormat): { + primary: string; + fallback: string; + assetName: string; +}; +/** + * Sidecar artifacts that ship with every release. These names match + * the release pipeline in `ml-models/.github/workflows/release.yml`. + */ +export declare function sidecarFilenames(entry: ManifestModelEntry, variant?: AssetVariant, format?: AssetFormat): readonly string[]; +//# sourceMappingURL=manifest.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/manifest.d.ts.map b/vendor/interscript-ts/dist/ml/provision/manifest.d.ts.map new file mode 100644 index 0000000..75b4f93 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/manifest.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/ml/provision/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAA;IACpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAA;CAC9D;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAA;AAExD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAA;AAkB3C,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAG1D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAGvD;AAWD;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,QAAQ,CAAC,CAetD;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAIpC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,kBAAkB,EACzB,OAAO,GAAE,YAAmB,EAC5B,MAAM,GAAE,WAAoB,GAC3B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAS1D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,kBAAkB,EACzB,OAAO,GAAE,YAAmB,EAC5B,MAAM,GAAE,WAAoB,GAC3B,SAAS,MAAM,EAAE,CAOnB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/manifest.js b/vendor/interscript-ts/dist/ml/provision/manifest.js new file mode 100644 index 0000000..816643b --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/manifest.js @@ -0,0 +1,126 @@ +/** + * Manifest-driven model resolution. + * + * The source of truth for "what model version is current" lives in + * the `@interscript/models` npm package (a tiny JSON manifest kept + * in lockstep with GH Releases in `interscript/ml-models`). + * + * Resolution order for the manifest itself: + * 1. Programmatically injected via `setManifestUrl()` or + * `setInlineManifest()` (tests, air-gapped envs). + * 2. The `@interscript/models` package, when installed. + * 3. A remote JSON URL on the CDN (`manifest.json` next to the + * release assets). + * + * See `ml-models/TODO.distribution/04-npm-packages.md` for the + * full MECE breakdown of who owns what. + */ +import { getModelBase } from "./base.js"; +const VARIANT_SUFFIX = { + fp32: "", + q8: "-q8", + q4: "-q4", + fp16: "-fp16", +}; +const FORMAT_EXTENSION = { + onnx: ".onnx", + tflite: ".tflite", +}; +let cachedManifest = null; +let inlineManifest = null; +let manifestUrlOverride = null; +export function setInlineManifest(m) { + inlineManifest = m; + cachedManifest = null; +} +export function setManifestUrl(url) { + manifestUrlOverride = url; + cachedManifest = null; +} +/** + * Default manifest URL — sits next to release assets on the CDN. + * Points at the jsDelivr mirror of the ml-models repo so it works + * with zero npm install. + */ +function defaultManifestUrl() { + return `${getModelBase()}/npm/models/manifest.json`; +} +/** + * Load the manifest. Cached after first call; bust the cache with + * `setInlineManifest()` or `setManifestUrl()`. + */ +export async function loadManifest() { + if (cachedManifest) + return cachedManifest; + if (inlineManifest) { + cachedManifest = inlineManifest; + return cachedManifest; + } + const url = manifestUrlOverride ?? defaultManifestUrl(); + const res = await fetch(url); + if (!res.ok) { + throw new Error(`Failed to load model manifest from ${url}: ${res.status} ${res.statusText}`); + } + const json = (await res.json()); + cachedManifest = json; + return json; +} +/** + * Resolve a `(kind, id)` ref to a manifest entry. The `id` field on + * a ModelRef carries the task name (e.g. "rababa_arabic"); the kind + * is redundant but kept for backwards compatibility. + * + * Returns `null` if the task isn't in the manifest. Callers decide + * whether that's an error or a "use bundled fallback" signal. + */ +export async function resolveManifestEntry(kind, id) { + const manifest = await loadManifest(); + const taskKey = id.startsWith(`${kind}_`) ? id : `${kind}_${id}`; + return manifest.models[taskKey] ?? manifest.models[id] ?? null; +} +/** + * Build concrete artifact URLs for a model. Prefers the CDN base; + * GitHub Releases base is the fallback (slower, but no CDN cache). + * + * Both URLs use the same asset naming convention so a downloader + * can verify checksums identically against either source. + */ +export function artifactUrls(entry, variant = "q8", format = "onnx") { + const assetName = assetNameFor(entry, variant, format); + const versionedCdn = entry.cdn_base.replace("{version}", entry.version); + const versionedGithub = entry.github_base.replace("{version}", entry.version); + return { + primary: `${versionedCdn}${assetName}`, + fallback: `${versionedGithub}${assetName}`, + assetName, + }; +} +/** + * Sidecar artifacts that ship with every release. These names match + * the release pipeline in `ml-models/.github/workflows/release.yml`. + */ +export function sidecarFilenames(entry, variant = "q8", format = "onnx") { + const asset = assetNameFor(entry, variant, format); + return [ + `${asset}.sha256`, + "vocab.json", + "config.json", + ]; +} +function assetNameFor(entry, variant, format = "onnx") { + const task = taskNameFromBases(entry); + return `${task}${VARIANT_SUFFIX[variant]}${FORMAT_EXTENSION[format]}`; +} +/** + * Best-effort task name extraction from `cdn_base`/`github_base`. + * Both bases end with `-v{version}/`, so we slice off the + * trailing version segment. + */ +function taskNameFromBases(entry) { + const match = entry.github_base.match(/([^/]+)-v\{version\}\/$/); + const task = match?.[1]; + if (task) + return task; + throw new Error(`Cannot extract task name from manifest entry. github_base=${entry.github_base}`); +} +//# sourceMappingURL=manifest.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/provision/manifest.js.map b/vendor/interscript-ts/dist/ml/provision/manifest.js.map new file mode 100644 index 0000000..99927e5 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/provision/manifest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/ml/provision/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAkCxC,MAAM,cAAc,GAAiC;IACnD,IAAI,EAAE,EAAE;IACR,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,OAAO;CACd,CAAA;AAED,MAAM,gBAAgB,GAAgC;IACpD,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,SAAS;CAClB,CAAA;AAED,IAAI,cAAc,GAAoB,IAAI,CAAA;AAC1C,IAAI,cAAc,GAAoB,IAAI,CAAA;AAC1C,IAAI,mBAAmB,GAAkB,IAAI,CAAA;AAE7C,MAAM,UAAU,iBAAiB,CAAC,CAAkB;IAClD,cAAc,GAAG,CAAC,CAAA;IAClB,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAkB;IAC/C,mBAAmB,GAAG,GAAG,CAAA;IACzB,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB;IACzB,OAAO,GAAG,YAAY,EAAE,2BAA2B,CAAA;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,IAAI,cAAc;QAAE,OAAO,cAAc,CAAA;IACzC,IAAI,cAAc,EAAE,CAAC;QACnB,cAAc,GAAG,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K,CAAC,OAAO,CAAC,CAAA;IAC7E,OAAO;QACL,OAAO,EAAE,GAAG,YAAY,GAAG,SAAS,EAAE;QACtC,QAAQ,EAAE,GAAG,eAAe,GAAG,SAAS,EAAE;QAC1C,SAAS;KACV,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAyB,EACzB,UAAwB,IAAI,EAC5B,SAAsB,MAAM;IAE5B,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAClD,OAAO;QACL,GAAG,KAAK,SAAS;QACjB,YAAY;QACZ,aAAa;KACd,CAAA;AACH,CAAC;AAED,SAAS,YAAY,CACnB,KAAyB,EACzB,OAAqB,EACrB,SAAsB,MAAM;IAE5B,MAAM,IAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,GAAG,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAA;AACvE,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,KAAyB;IAClD,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAChE,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACvB,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,MAAM,IAAI,KAAK,CACb,6DAA6D,KAAK,CAAC,WAAW,EAAE,CACjF,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/registry.d.ts b/vendor/interscript-ts/dist/ml/registry.d.ts new file mode 100644 index 0000000..04cfc87 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/registry.d.ts @@ -0,0 +1,35 @@ +/** + * Model registry — adding a new ML model kind is purely additive. + * + * Adding ByT5 / Mamba / etc. later = new file in `src/ml/models//` + * that calls `registerModel`. Existing code never changes. + * + * MECE: every model kind lives in exactly one factory function. + * OCP: registry is open for extension, closed for modification. + * DRY: shared infrastructure (session creation, provisioning) is + * reused by every model. + */ +import type { MLModel, ModelFactory, ModelKind, ModelRef } from "./types.js"; +/** + * Register a factory for a model kind. Call once per kind at module + * load time. + */ +export declare function registerModel(kind: ModelKind, factory: ModelFactory): void; +/** + * Load (or return cached) model for a given ref. The factory is + * dispatched by `kind`; the session and artifacts are provisioned + * by the provisioner. + * + * Lazy: models load only when first requested. Subsequent calls + * return the cached instance. + */ +export declare function loadModel(ref: ModelRef): Promise; +/** + * List registered model kinds (useful for diagnostics). + */ +export declare function registeredKinds(): readonly ModelKind[]; +/** + * Free all cached models. Used in tests. + */ +export declare function resetModels(): Promise; +//# sourceMappingURL=registry.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/registry.d.ts.map b/vendor/interscript-ts/dist/ml/registry.d.ts.map new file mode 100644 index 0000000..9c4b6a7 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/registry.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/ml/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAK5E;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAK1E;AAQD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAqB/D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,SAAS,EAAE,CAEtD;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAajD"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/registry.js b/vendor/interscript-ts/dist/ml/registry.js new file mode 100644 index 0000000..d19fee7 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/registry.js @@ -0,0 +1,76 @@ +/** + * Model registry — adding a new ML model kind is purely additive. + * + * Adding ByT5 / Mamba / etc. later = new file in `src/ml/models//` + * that calls `registerModel`. Existing code never changes. + * + * MECE: every model kind lives in exactly one factory function. + * OCP: registry is open for extension, closed for modification. + * DRY: shared infrastructure (session creation, provisioning) is + * reused by every model. + */ +import { provisionModel } from "./provision/index.js"; +const factories = new Map(); +/** + * Register a factory for a model kind. Call once per kind at module + * load time. + */ +export function registerModel(kind, factory) { + if (factories.has(kind)) { + throw new Error(`Model kind "${kind}" is already registered`); + } + factories.set(kind, factory); +} +const cache = new Map(); +function cacheKey(ref) { + return `${ref.kind}/${ref.id}/${ref.url ?? "_default"}`; +} +/** + * Load (or return cached) model for a given ref. The factory is + * dispatched by `kind`; the session and artifacts are provisioned + * by the provisioner. + * + * Lazy: models load only when first requested. Subsequent calls + * return the cached instance. + */ +export async function loadModel(ref) { + const key = cacheKey(ref); + const cached = cache.get(key); + if (cached) + return cached; + const factory = factories.get(ref.kind); + if (!factory) { + throw new Error(`Unknown model kind: "${ref.kind}". Register a factory via registerModel("${ref.kind}", factory).`); + } + const promise = (async () => { + const { session, artifacts } = await provisionModel(ref); + return factory({ session, artifacts }); + })(); + cache.set(key, promise); + // On failure, drop the cached rejection so callers can retry. + promise.catch(() => cache.delete(key)); + return promise; +} +/** + * List registered model kinds (useful for diagnostics). + */ +export function registeredKinds() { + return [...factories.keys()]; +} +/** + * Free all cached models. Used in tests. + */ +export async function resetModels() { + const pending = [...cache.values()]; + cache.clear(); + await Promise.allSettled(pending.map(async (p) => { + try { + const m = await p; + await m.dispose(); + } + catch { + // already rejected; ignore + } + })); +} +//# sourceMappingURL=registry.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/registry.js.map b/vendor/interscript-ts/dist/ml/registry.js.map new file mode 100644 index 0000000..5703b2e --- /dev/null +++ b/v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,EAAE,SAAS,EAAE,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,CAAA;QACxD,OAAO,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;IACxC,CAAC,CAAC,EAAE,CAAA;IAEJ,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACvB,8DAA8D;IAC9D,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IACtC,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACnC,KAAK,CAAC,KAAK,EAAE,CAAA;IACb,MAAM,OAAO,CAAC,UAAU,CACtB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;QACtB,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,MAAM,CAAC,CAAA;YACjB,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,2BAA2B;QAC7B,CAAC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/index.d.ts b/vendor/interscript-ts/dist/ml/session/index.d.ts new file mode 100644 index 0000000..c48bbd3 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/index.d.ts @@ -0,0 +1,55 @@ +/** + * InferenceSession — abstract interface for running ML models. + * + * Three backends implement this: + * - onnx-node: native ONNX Runtime via onnxruntime-node (Node.js only) + * - onnx-web: WASM/WebGPU ONNX Runtime via onnxruntime-web (browser) + * - litert-web: LiteRT.js for .tflite models (browser) + * + * Adding a new backend = adding a new file here + exporting a factory. + * Existing code never changes (OCP). + * + * Backends are loaded lazily — only the one needed is imported, keeping + * the bundle size minimal. + */ +import type { InferenceSession, InferenceInputs, InferenceOutputs } from "../types.js"; +export type { InferenceSession, InferenceInputs, InferenceOutputs }; +export type { WebSessionOptions } from "./onnx-web.js"; +export type { LitertSessionOptions } from "./litert-web.js"; +/** + * Detect environment. Browser backends work in `window`, Node backends + * work in `process.versions.node`. Some environments (Cloudflare + * Workers, Deno) might prefer Web. + */ +export declare function detectBackend(): "node" | "web" | "unknown"; +/** + * Options for `createSession`. + */ +export interface SessionOptions { + /** Force a specific backend. Auto-detected by default. */ + backend?: "node" | "web"; + /** + * Which runtime to use. ONNX is the default; "litert" selects + * Google's LiteRT.js for .tflite models. The runtime choice must + * match the model artifact being loaded (.onnx vs .tflite). + */ + runtime?: "onnx" | "litert"; + /** ONNX-web only: enable WebGPU with WASM fallback. Default: true. */ + webgpu?: boolean; + /** LiteRT-web only: accelerator preference. Default: "webgpu". */ + litertAccelerator?: "webgpu" | "webnn" | "wasm"; + /** + * LiteRT-web only: input/output tensor names. ONNX reads these from + * the model graph; LiteRT's auto-generated names are not user-facing, + * so the caller must supply them. + */ + inputNames?: readonly string[]; + outputNames?: readonly string[]; +} +/** + * Create an InferenceSession from a model file. Auto-picks the backend. + * Backend choice can be overridden via opts.backend; runtime choice + * via opts.runtime. + */ +export declare function createSession(modelData: ArrayBuffer | Uint8Array, opts?: SessionOptions): Promise; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/index.d.ts.map b/vendor/interscript-ts/dist/ml/session/index.d.ts.map new file mode 100644 index 0000000..62a7e3f --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ml/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEtF,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA;AACnE,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACtD,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE3D;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,KAAK,GAAG,SAAS,CAS1D;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;IACxB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,sEAAsE;IACtE,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IAC/C;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAChC;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,WAAW,GAAG,UAAU,EACnC,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAoB3B"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/index.js b/vendor/interscript-ts/dist/ml/session/index.js new file mode 100644 index 0000000..04f5cc8 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/index.js @@ -0,0 +1,57 @@ +/** + * InferenceSession — abstract interface for running ML models. + * + * Three backends implement this: + * - onnx-node: native ONNX Runtime via onnxruntime-node (Node.js only) + * - onnx-web: WASM/WebGPU ONNX Runtime via onnxruntime-web (browser) + * - litert-web: LiteRT.js for .tflite models (browser) + * + * Adding a new backend = adding a new file here + exporting a factory. + * Existing code never changes (OCP). + * + * Backends are loaded lazily — only the one needed is imported, keeping + * the bundle size minimal. + */ +/** + * Detect environment. Browser backends work in `window`, Node backends + * work in `process.versions.node`. Some environments (Cloudflare + * Workers, Deno) might prefer Web. + */ +export function detectBackend() { + const g = globalThis; + if (g.process?.versions?.node) { + return "node"; + } + if (g.self !== undefined) { + return "web"; + } + return "unknown"; +} +/** + * Create an InferenceSession from a model file. Auto-picks the backend. + * Backend choice can be overridden via opts.backend; runtime choice + * via opts.runtime. + */ +export async function createSession(modelData, opts = {}) { + const runtime = opts.runtime ?? "onnx"; + // LiteRT runs in the browser only (for now — no Node.js build). + if (runtime === "litert") { + const litertOpts = {}; + if (opts.litertAccelerator !== undefined) + litertOpts.accelerator = opts.litertAccelerator; + if (opts.inputNames !== undefined) + litertOpts.inputNames = opts.inputNames; + if (opts.outputNames !== undefined) + litertOpts.outputNames = opts.outputNames; + return (await import("./litert-web.js")).createLitertSession(modelData, litertOpts); + } + const backend = opts.backend ?? detectBackend() === "node" ? "node" : "web"; + if (backend === "node") { + return (await import("./onnx-node.js")).createNodeSession(modelData); + } + // Pass through webgpu only when explicitly set — exactOptionalPropertyTypes + // distinguishes missing vs undefined, and we want missing = use default. + const webOpts = opts.webgpu === undefined ? {} : { webgpu: opts.webgpu }; + return (await import("./onnx-web.js")).createWebSession(modelData, webOpts); +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/index.js.map b/vendor/interscript-ts/dist/ml/session/index.js.map new file mode 100644 index 0000000..07bbceb --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ml/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,CAAC,GAAG,UAA4E,CAAA;IACtF,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ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AAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAA;IACxE,OAAO,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC7E,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/litert-web.d.ts b/vendor/interscript-ts/dist/ml/session/litert-web.d.ts new file mode 100644 index 0000000..1d40c45 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/litert-web.d.ts @@ -0,0 +1,50 @@ +/** + * LiteRT.js backend — runs .tflite models via Google's runtime. + * + * Parallel to onnx-web.ts. Same InferenceSession interface. Lazy-loaded + * so bundlers exclude it from builds that don't use LiteRT. + * + * `@litertjs/core` is a peer dep — users install it if they want the + * LiteRT runtime. Without it, calling with `runtime: 'litert'` throws + * a clear error. + * + * Note: as of v2.5.2 (released July 9, 2026), the LiteRT.js API is + * still settling. This wrapper isolates users from API churn — when + * Google ships breaking changes, we absorb them here. + * + * Known API gaps to verify with real models (deferred until v0.1.0 + * produces a real .tflite artifact): + * - Multi-input: example shows `model.run(singleTensor)`. We pass an + * array when inputNames.length > 1; will adjust if API differs. + * - Multi-output: result object shape unknown until we have a real + * multi-head .tflite. + * - Int64 inputs: our model has int64 src/lengths. Tensor constructor + * accepts TypedArray; BigInt64Array should work but untested. + */ +import type { InferenceSession } from "../types.js"; +export interface LitertSessionOptions { + /** + * Accelerator preference. Default: 'webgpu' (falls back to 'wasm' + * automatically inside LiteRT.js if WebGPU is unavailable). + */ + accelerator?: "webgpu" | "webnn" | "wasm"; + /** + * URL prefix serving the LiteRT.js WASM files. Default: jsdelivr CDN. + * Override for self-hosted deployments or offline use. + */ + wasmPath?: string; +} +/** + * Create a LiteRT.js session from a .tflite model blob. + * + * Caller supplies input/output names because the .tflite default + * signature names are auto-generated (e.g. "args_0"). For our rababa + * models, use: + * - single-head: inputNames=["src","lengths"], outputNames=["output"] + * - multi-head: inputNames=["src","lengths"], outputNames=["niqqud","dagesh","sin"] + */ +export declare function createLitertSession(modelData: ArrayBuffer | Uint8Array, opts?: LitertSessionOptions & { + inputNames?: readonly string[]; + outputNames?: readonly string[]; +}): Promise; +//# sourceMappingURL=litert-web.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/litert-web.d.ts.map b/vendor/interscript-ts/dist/ml/session/litert-web.d.ts.map new file mode 100644 index 0000000..15775b3 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/litert-web.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"litert-web.d.ts","sourceRoot":"","sources":["../../../src/ml/session/litert-web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAKjB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IACzC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAkDD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,WAAW,GAAG,UAAU,EACnC,IAAI,GAAE,oBAAoB,GAAG;IAC3B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC3B,GACL,OAAO,CAAC,gBAAgB,CAAC,CAuB3B"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/litert-web.js b/vendor/interscript-ts/dist/ml/session/litert-web.js new file mode 100644 index 0000000..126209d --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/litert-web.js @@ -0,0 +1,146 @@ +/** + * LiteRT.js backend — runs .tflite models via Google's runtime. + * + * Parallel to onnx-web.ts. Same InferenceSession interface. Lazy-loaded + * so bundlers exclude it from builds that don't use LiteRT. + * + * `@litertjs/core` is a peer dep — users install it if they want the + * LiteRT runtime. Without it, calling with `runtime: 'litert'` throws + * a clear error. + * + * Note: as of v2.5.2 (released July 9, 2026), the LiteRT.js API is + * still settling. This wrapper isolates users from API churn — when + * Google ships breaking changes, we absorb them here. + * + * Known API gaps to verify with real models (deferred until v0.1.0 + * produces a real .tflite artifact): + * - Multi-input: example shows `model.run(singleTensor)`. We pass an + * array when inputNames.length > 1; will adjust if API differs. + * - Multi-output: result object shape unknown until we have a real + * multi-head .tflite. + * - Int64 inputs: our model has int64 src/lengths. Tensor constructor + * accepts TypedArray; BigInt64Array should work but untested. + */ +const DEFAULT_WASM_PATH = "https://cdn.jsdelivr.net/npm/@litertjs/core@2.5.2/wasm/"; +let cached; +async function loadLitertCore() { + if (!cached) { + cached = (async () => { + try { + return (await import("@litertjs/core")); + } + catch (e) { + cached = undefined; + throw new Error("@litertjs/core is required for LiteRT inference. Install with: npm install @litertjs/core", { cause: e }); + } + })(); + } + return cached; +} +/** + * Create a LiteRT.js session from a .tflite model blob. + * + * Caller supplies input/output names because the .tflite default + * signature names are auto-generated (e.g. "args_0"). For our rababa + * models, use: + * - single-head: inputNames=["src","lengths"], outputNames=["output"] + * - multi-head: inputNames=["src","lengths"], outputNames=["niqqud","dagesh","sin"] + */ +export async function createLitertSession(modelData, opts = {}) { + const accelerator = opts.accelerator ?? "webgpu"; + const wasmPath = opts.wasmPath ?? DEFAULT_WASM_PATH; + const inputNames = opts.inputNames ?? ["src", "lengths"]; + const outputNames = opts.outputNames ?? ["output"]; + const core = await loadLitertCore(); + await core.loadLiteRt(wasmPath, { jspi: accelerator === "webnn" }); + // LiteRT.js takes a URL; create a blob URL from the bytes. + // (In Node 18+, Blob + URL.createObjectURL are available globally.) + const blob = new Blob([new Uint8Array(modelData)], { type: "application/octet-stream" }); + const url = URL.createObjectURL(blob); + let model; + try { + model = await core.loadAndCompile(url, { accelerator }); + } + finally { + // Model is compiled; the URL can be revoked. If LiteRT keeps lazy + // references to the URL, we'd need to defer this to dispose(). Be + // conservative and revoke on dispose instead. + } + return new LitertInferenceSession(model, core, inputNames, outputNames, url); +} +class LitertInferenceSession { + inputNames; + outputNames; + model; + core; + blobUrl; + disposed = false; + constructor(model, core, inputNames, outputNames, blobUrl) { + this.model = model; + this.core = core; + this.inputNames = inputNames; + this.outputNames = outputNames; + this.blobUrl = blobUrl; + } + async run(inputs) { + if (this.disposed) + throw new Error("Session disposed"); + // Convert named inputs to LiteRT Tensors, in inputNames order. + const tensors = []; + for (const name of this.inputNames) { + const t = inputs[name]; + if (!t) + throw new Error(`Missing LiteRT input: ${name}`); + tensors.push(new this.core.Tensor(t.data, t.dims)); + } + // Pass single tensor directly; pass array for multi-input. The + // LiteRT.js v2.5.2 example shows single-tensor `run()`, but the + // underlying signature accepts either form. Empirical verification + // pending a real multi-input model. + const results = await this.model.run(tensors.length === 1 ? tensors[0] : tensors); + const out = {}; + try { + for (let i = 0; i < this.outputNames.length; i++) { + const name = this.outputNames[i]; + const resultTensor = results[i]; + if (!resultTensor) { + throw new Error(`LiteRT produced no output at index ${i} (expected ${name})`); + } + // Move to wasm-backed readable buffer; safe regardless of where + // the tensor currently lives (webgpu or wasm). + const moved = await resultTensor.moveTo("wasm"); + const data = await moved.toTypedArray(); + out[name] = { + name, + type: dtypeFromTypedArray(data), + data, + dims: [...resultTensor.dims], + }; + await moved.delete(); + } + } + finally { + await results.delete(); + } + return out; + } + async dispose() { + if (this.disposed) + return; + this.disposed = true; + await this.model.delete(); + URL.revokeObjectURL(this.blobUrl); + } +} +function dtypeFromTypedArray(arr) { + if (arr instanceof Float32Array) + return "float32"; + if (arr instanceof Int32Array) + return "int32"; + if (arr instanceof BigInt64Array) + return "int64"; + if (arr instanceof Uint8Array) + return "uint8"; + return "float32"; +} +//# sourceMappingURL=litert-web.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/litert-web.js.map b/vendor/interscript-ts/dist/ml/session/litert-web.js.map new file mode 100644 index 0000000..5ea595a --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/litert-web.js.map @@ -0,0 +1 @@ +{"version":3,"file":"litert-web.js","sourceRoot":"","sources":["../../../src/ml/session/litert-web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAkDH,MAAM,iBAAiB,GAAG,yDAAyD,CAAA;AAEnF,IAAI,MAA6C,CAAA;AAEjD,KAAK,UAAU,cAAc;IAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;YACnB,IAAI,CAAC;gBACH,OAAO,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAgC,CAAA;YACxE,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,GAAG,SAAS,CAAA;gBAClB,MAAM,IAAI,KAAK,CACb,2FAA2F,EAC3F,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAA;YACH,CAAC;QACH,CAAC,CAAC,EAAE,CAAA;IACN,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAAmC,EACnC,OAGI,EAAE;IAEN,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,QAAQ,CAAA;IAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,iBAAiB,CAAA;IACnD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACxD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,CAAC,QAAQ,CAAC,CAAA;IAElD,MAAM,IAAI,GAAG,MAAM,cAAc,EAAE,CAAA;IACnC,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,EAAE,CAAC,CAAA;IAElE,2DAA2D;IAC3D,oEAAoE;IACpE,MAAM,IAAI,GAA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gBACD,MAAM,KAAK,CAAC,MAAM,EAAE,CAAA;YACtB,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,OAAO,CAAC,MAAM,EAAE,CAAA;QACxB,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAM;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAA;QACzB,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;CACF;AAED,SAAS,mBAAmB,CAAC,GAAe;IAC1C,IAAI,GAAG,YAAY,YAAY;QAAE,OAAO,SAAS,CAAA;IACjD,IAAI,GAAG,YAAY,UAAU;QAAE,OAAO,OAAO,CAAA;IAC7C,IAAI,GAAG,YAAY,aAAa;QAAE,OAAO,OAAO,CAAA;IAChD,IAAI,GAAG,YAAY,UAAU;QAAE,OAAO,OAAO,CAAA;IAC7C,OAAO,SAAS,CAAA;AAClB,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/onnx-node.d.ts b/vendor/interscript-ts/dist/ml/session/onnx-node.d.ts new file mode 100644 index 0000000..668fb76 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/onnx-node.d.ts @@ -0,0 +1,10 @@ +/** + * Node.js backend — wraps onnxruntime-node. + * + * Server-only: requires Node native modules. Imported lazily by the + * session factory only when the runtime detects a Node environment. + * Don't import this from browser bundles. + */ +import type { InferenceSession } from "../types.js"; +export declare function createNodeSession(modelData: ArrayBuffer | Uint8Array): Promise; +//# sourceMappingURL=onnx-node.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/onnx-node.d.ts.map b/vendor/interscript-ts/dist/ml/session/onnx-node.d.ts.map new file mode 100644 index 0000000..0d6dec1 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/onnx-node.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"onnx-node.d.ts","sourceRoot":"","sources":["../../../src/ml/session/onnx-node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAKjB,MAAM,aAAa,CAAA;AA6EpB,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEtG"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/onnx-node.js b/vendor/interscript-ts/dist/ml/session/onnx-node.js new file mode 100644 index 0000000..3cf5007 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/onnx-node.js @@ -0,0 +1,62 @@ +/** + * Node.js backend — wraps onnxruntime-node. + * + * Server-only: requires Node native modules. Imported lazily by the + * session factory only when the runtime detects a Node environment. + * Don't import this from browser bundles. + */ +async function loadOrt() { + try { + return (await import("onnxruntime-node")); + } + catch (e) { + throw new Error("onnxruntime-node is required for ML inference in Node. Install with: npm install onnxruntime-node", { cause: e }); + } +} +class NodeInferenceSession { + session; + ort; + inputNames; + outputNames; + inputMetadata; + constructor(session, ort) { + this.session = session; + this.ort = ort; + this.inputNames = session.inputNames; + this.outputNames = session.outputNames; + const raw = session.inputMetadata; + if (Array.isArray(raw)) { + this.inputMetadata = raw; + } + } + static async create(modelData) { + const ort = await loadOrt(); + const session = await ort.InferenceSession.create(modelData); + return new NodeInferenceSession(session, ort); + } + async run(inputs) { + const feeds = {}; + for (const [name, tensor] of Object.entries(inputs)) { + feeds[name] = new this.ort.Tensor(tensor.type, tensor.data, tensor.dims); + } + const outputs = await this.session.run(feeds); + const out = {}; + for (const [name, value] of Object.entries(outputs)) { + const v = value; + out[name] = { + name, + type: v.type, + data: v.data, + dims: v.dims, + }; + } + return out; + } + async dispose() { + await this.session.release(); + } +} +export async function createNodeSession(modelData) { + return NodeInferenceSession.create(modelData); +} +//# sourceMappingURL=onnx-node.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/onnx-node.js.map b/vendor/interscript-ts/dist/ml/session/onnx-node.js.map new file mode 100644 index 0000000..d57b354 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/onnx-node.js.map @@ -0,0 +1 @@ +{"version":3,"file":"onnx-node.js","sourceRoot":"","sources":["../../../src/ml/session/onnx-node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0BH,KAAK,UAAU,OAAO;IACpB,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAA8B,CAAA;IACxE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,mGAAmG,EACnG,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAA;IACH,CAAC;AACH,CAAC;AAED,MAAM,oBAAoB;IACP,OAAO,CAAiB;IACxB,GAAG,CAAgB;IAC3B,UAAU,CAAmB;IAC7B,WAAW,CAAmB;IAC9B,aAAa,CAAmG;IAEzH,YAAoB,OAAwB,EAAE,GAAmB;QAC/D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;QACpC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;QACtC,MAAM,GAAG,GAAI,OAAuC,CAAC,aAAa,CAAA;QAClE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,GAAG,GAA4C,CAAA;QACnE,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,SAAmC;QACrD,MAAM,GAAG,GAAG,MAAM,OAAO,EAAE,CAAA;QAC3B,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAC5D,OAAO,IAAI,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAC/C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAuB;QAC/B,MAAM,KAAK,GAA4B,EAAE,CAAA;QACzC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACpD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC1E,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC7C,MAAM,GAAG,GAA2B,EAAE,CAAA;QACtC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,MAAM,CAAC,GAAG,KAA2D,CAAA;YACrE,GAAG,CAAC,IAAI,CAAC,GAAG;gBACV,IAAI;gBACJ,IAAI,EAAE,CAAC,CAAC,IAAsB;gBAC9B,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;aACb,CAAA;QACH,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,SAAmC;IACzE,OAAO,oBAAoB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AAC/C,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/onnx-web.d.ts b/vendor/interscript-ts/dist/ml/session/onnx-web.d.ts new file mode 100644 index 0000000..7bd83c9 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/onnx-web.d.ts @@ -0,0 +1,23 @@ +/** + * Browser backend — wraps onnxruntime-web with WebGPU + WASM fallback. + * + * Imported lazily by the session factory. Bundlers will only include + * this in browser builds. + * + * onnxruntime-web is a peer dep; users install it if they need ML. + * Without it, calling rababa() from the browser throws a clear error. + */ +import type { InferenceSession } from "../types.js"; +export interface WebSessionOptions { + /** + * Try WebGPU first, fall back to WASM if WebGPU is unavailable or + * fails to initialize. Default: `true` — most browsers shipped WebGPU + * by default as of Nov 2025 (Chrome 113+, Safari 17+, Firefox 141+). + * + * Set to `false` to force WASM only — useful for debugging WebGPU + * quirks or in environments where the GPU driver is known to be bad. + */ + webgpu?: boolean; +} +export declare function createWebSession(modelData: ArrayBuffer | Uint8Array, opts?: WebSessionOptions): Promise; +//# sourceMappingURL=onnx-web.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/onnx-web.d.ts.map b/vendor/interscript-ts/dist/ml/session/onnx-web.d.ts.map new file mode 100644 index 0000000..c1958c3 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/onnx-web.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"onnx-web.d.ts","sourceRoot":"","sources":["../../../src/ml/session/onnx-web.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAKjB,MAAM,aAAa,CAAA;AAEpB,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAqGD,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,WAAW,GAAG,UAAU,EACnC,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAE3B"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/onnx-web.js b/vendor/interscript-ts/dist/ml/session/onnx-web.js new file mode 100644 index 0000000..48fd4c4 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/onnx-web.js @@ -0,0 +1,74 @@ +/** + * Browser backend — wraps onnxruntime-web with WebGPU + WASM fallback. + * + * Imported lazily by the session factory. Bundlers will only include + * this in browser builds. + * + * onnxruntime-web is a peer dep; users install it if they need ML. + * Without it, calling rababa() from the browser throws a clear error. + */ +let cached; +async function loadOrt() { + if (!cached) { + cached = (async () => { + try { + const mod = (await import("onnxruntime-web")); + // Use SIMD when available (~2x faster for WASM fallback path). + mod.env.wasm.simd = true; + return mod; + } + catch (e) { + cached = undefined; + throw new Error("onnxruntime-web is required for ML inference in the browser. Install with: npm install onnxruntime-web", { cause: e }); + } + })(); + } + return cached; +} +class WebInferenceSession { + session; + ort; + inputNames; + outputNames; + constructor(session, ort) { + this.session = session; + this.ort = ort; + this.inputNames = session.inputNames; + this.outputNames = session.outputNames; + } + static async create(modelData, opts = {}) { + const ort = await loadOrt(); + // Execution provider preference — onnxruntime-web picks the first + // available; WebGPU silently falls back to WASM when unavailable. + const executionProviders = opts.webgpu === false ? ["wasm"] : ["webgpu", "wasm"]; + const session = await ort.InferenceSession.create(modelData, { + executionProviders, + }); + return new WebInferenceSession(session, ort); + } + async run(inputs) { + const feeds = {}; + for (const [name, tensor] of Object.entries(inputs)) { + feeds[name] = new this.ort.Tensor(tensor.type, tensor.data, tensor.dims); + } + const outputs = await this.session.run(feeds); + const out = {}; + for (const [name, value] of Object.entries(outputs)) { + const v = value; + out[name] = { + name, + type: v.type, + data: v.data, + dims: v.dims, + }; + } + return out; + } + async dispose() { + await this.session.release(); + } +} +export async function createWebSession(modelData, opts = {}) { + return WebInferenceSession.create(modelData, opts); +} +//# sourceMappingURL=onnx-web.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/session/onnx-web.js.map b/vendor/interscript-ts/dist/ml/session/onnx-web.js.map new file mode 100644 index 0000000..304da44 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/session/onnx-web.js.map @@ -0,0 +1 @@ +{"version":3,"file":"onnx-web.js","sourceRoot":"","sources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CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AACpD,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/types.d.ts b/vendor/interscript-ts/dist/ml/types.d.ts new file mode 100644 index 0000000..dd0b35a --- /dev/null +++ b/vendor/interscript-ts/dist/ml/types.d.ts @@ -0,0 +1,113 @@ +/** + * ML types — used by the model registry, sessions, and individual model + * implementations. Discriminated unions throughout so adding a new + * model kind or backend is purely additive (OCP). + */ +/** + * Discriminated union of every supported model kind. Add a new variant + * here + register a factory; nothing else changes. + */ +export type ModelKind = "rababa" | "secryst"; +/** + * Reference to a model the runtime can provision. Discriminated by + * `kind` so the registry can dispatch to the right factory. + */ +export interface ModelRef { + readonly kind: ModelKind; + /** Model-specific identifier (e.g. "200" for rababa max-len-200). */ + readonly id: string; + /** Optional override URL for the model file (otherwise from manifest). */ + readonly url?: string; +} +/** + * Input to an ONNX inference call. The runtime hands the model a + * Record of named tensors. + */ +export type TensorData = Int8Array | Uint8Array | Int16Array | Int32Array | Float32Array | Float64Array | BigInt64Array; +export interface Tensor { + readonly name: string; + readonly data: TensorData; + readonly dims: readonly number[]; + readonly type: "int8" | "uint8" | "int16" | "int32" | "int64" | "float32" | "float64"; +} +export interface InferenceInputs { + readonly [name: string]: Tensor; +} +export interface InferenceOutputs { + readonly [name: string]: Tensor; +} +/** + * An inference session wraps an ONNX model. Both Node and browser + * backends implement this interface; callers don't know which. + */ +export interface SessionInputMetadata { + readonly name: string; + readonly type: string; + readonly shape: ReadonlyArray; +} +export interface InferenceSession { + /** Run inference with named inputs. Returns named outputs. */ + run(inputs: InferenceInputs): Promise; + /** Input names the model accepts. */ + inputNames: readonly string[]; + /** Input shapes/types when the backend exposes them (used for + * zero-length KV pasts whose static dims must match the graph). */ + readonly inputMetadata?: readonly SessionInputMetadata[] | undefined; + /** Output names the model produces. */ + outputNames: readonly string[]; + /** Free native resources held by the session. */ + dispose(): Promise; +} +/** + * A loaded model — has a session plus any auxiliary artifacts + * (vocabularies, configs). Each ModelKind has its own subclass + * extending this; the registry returns Model implementations + * generically. + */ +export interface Model { + readonly kind: ModelKind; + /** Free native resources. */ + dispose(): Promise; +} +/** + * Universal text-transform interface. Every ML model — rababa, + * secryst, ByT5, or future kinds — implements this single method. + * + * The interpreter calls `transform(input)` for ANY async funcall, + * regardless of model kind. No per-model branching in the interpreter + * (OCP: adding a new model kind doesn't change the interpreter). + * + * MECE: the interface knows about text transformation. It does NOT + * know about Arabic diacritization, Thai transliteration, or any + * domain-specific concept. + */ +export interface MLModel extends Model { + /** + * Transform input text into output text. + * + * Rababa: undiacritized Arabic → diacritized Arabic + * Secryst: source script → target script + * Future models: any text-to-text transformation + */ + transform(input: string): Promise; +} +/** + * Factory for a model. Given a provisioned bundle (session + auxiliary + * data), return a Model implementation. + * + * Each kind registers exactly one factory (MECE). + */ +export type ModelFactory = (params: ModelLoadParams) => Promise; +export interface ModelLoadParams { + readonly session: InferenceSession; + readonly artifacts: ModelArtifacts; +} +/** + * Auxiliary files that ship alongside the model ONNX file: + * vocabularies, configs, metadata. Loaded by the provisioner before + * the factory is called. + */ +export interface ModelArtifacts { + readonly [filename: string]: Uint8Array | string; +} +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/types.d.ts.map b/vendor/interscript-ts/dist/ml/types.d.ts.map new file mode 100644 index 0000000..cc7d810 --- /dev/null +++ b/vendor/interscript-ts/dist/ml/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ml/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE5C;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,0EAA0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AAA;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,6BAA6B;IAC7B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAQ,SAAQ,KAAK;IACpC;;;;;;OAMG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAC1C;AAED;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAExE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;IAClC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;CACjD"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/types.js b/vendor/interscript-ts/dist/ml/types.js new file mode 100644 index 0000000..64eb52a --- /dev/null +++ b/vendor/interscript-ts/dist/ml/types.js @@ -0,0 +1,7 @@ +/** + * ML types — used by the model registry, sessions, and individual model + * implementations. Discriminated unions throughout so adding a new + * model kind or backend is purely additive (OCP). + */ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/ml/types.js.map b/vendor/interscript-ts/dist/ml/types.js.map new file mode 100644 index 0000000..c27c6db --- /dev/null +++ b/vendor/interscript-ts/dist/ml/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ml/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/compile-item.d.ts b/vendor/interscript-ts/dist/runtime/compile-item.d.ts new file mode 100644 index 0000000..20b98f1 --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/compile-item.d.ts @@ -0,0 +1,53 @@ +/** + * Item compilation — convert AST Items into RegExp source or literal string. + * + * Items are decomposed into their compiled form ONCE per stage, then + * reused across many string inputs. This avoids redundant work and + * keeps the interpreter's inner loop tight (DRY + performance). + */ +import type { Item } from "../types.js"; +import type { ExecutionContext } from "./context.js"; +/** Compiled form of a pattern Item. */ +export interface CompiledItem { + /** RegExp source. */ + readonly re: string; + /** Literal value (for replacement strings). */ + readonly literal: string; +} +/** + * Compile an Item into a RegExp source string + literal value. + * Visitor-free dispatch — adding a new Item kind = adding a case here. + * + * Note: this is intentionally a single switch with exhaustive type + * coverage. New Item kinds force this switch to be updated, which is + * good — it surfaces the change rather than hiding it. + */ +export declare function compileItem(item: Item, ctx: ExecutionContext): CompiledItem; +/** + * Compile an Item to a literal string only (no regex semantics). + * Used by the parallel-replace executor which needs exact strings. + * + * Returns `null` if the Item cannot be represented as a literal + * (captures, regex-only constructs). The caller decides whether to + * fall back to sequential execution. + */ +export declare function compileToLiteral(item: Item, ctx: ExecutionContext): string | null; +/** + * Expand a `from` item into ALL possible literal strings for parallel + * replace. `any` items produce one entry per alternative. Other items + * produce a single entry (or null if not literal). + * + * This is the multi-valued counterpart of `compileToLiteral`. + */ +export declare function expandFromLiterals(item: Item, ctx: ExecutionContext): string[] | null; +/** + * Compute the max-length estimate for an Item. Mirrors Ruby's + * `Node::Item#max_length`, which is used to sort parallel rules + * (longest first) before building the megaregexp fallback. + * + * The estimate need not be exact — it only governs sort order within + * a parallel block. Stdlib aliases count as length 1 (matching Ruby), + * `none` is 0. + */ +export declare function maxLengthOfItem(item: Item, ctx: ExecutionContext): number; +//# sourceMappingURL=compile-item.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/compile-item.d.ts.map b/vendor/interscript-ts/dist/runtime/compile-item.d.ts.map new file mode 100644 index 0000000..94c2976 --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/compile-item.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"compile-item.d.ts","sourceRoot":"","sources":["../../src/runtime/compile-item.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAGpD,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC3B,qBAAqB;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,gBAAgB,GAAG,YAAY,CAqE3E;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,GAAG,IAAI,CA4CjF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,EAAE,GAAG,IAAI,CA2DrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,gBAAgB,GAAG,MAAM,CAyBzE"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/compile-item.js b/vendor/interscript-ts/dist/runtime/compile-item.js new file mode 100644 index 0000000..26ba289 --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/compile-item.js @@ -0,0 +1,272 @@ +/** + * Item compilation — convert AST Items into RegExp source or literal string. + * + * Items are decomposed into their compiled form ONCE per stage, then + * reused across many string inputs. This avoids redundant work and + * keeps the interpreter's inner loop tight (DRY + performance). + */ +import { regexpEscape } from "../stdlib.js"; +/** + * Compile an Item into a RegExp source string + literal value. + * Visitor-free dispatch — adding a new Item kind = adding a case here. + * + * Note: this is intentionally a single switch with exhaustive type + * coverage. New Item kinds force this switch to be updated, which is + * good — it surfaces the change rather than hiding it. + */ +export function compileItem(item, ctx) { + switch (item.kind) { + case "string": + return { re: regexpEscape(item.value), literal: item.value }; + case "capture_group": { + const inner = compileItem(item.data, ctx); + return { re: `(${inner.re})`, literal: inner.literal }; + } + case "capture_ref": { + const id = item.id; + return { re: `\\${id}`, literal: `$${id}` }; + } + case "alias": { + // Stdlib aliases (single characters like \w, \b, etc.) + const stdlib = STDLIB_ALIASES[item.name]; + if (stdlib) + return stdlib; + const resolved = ctx.resolveAlias(item.name); + if (!resolved) + return { re: "", literal: "" }; + return compileItem(resolved, ctx); + } + case "any": { + const parts = item.of.map((i) => compileItem(i, ctx).re); + // Mirror Ruby's Any#nth_string: the literal form picks the first + // alternative. Sub rules with `to: any("ie")` use this for the + // canonical replacement. + const firstLit = item.of.length > 0 ? compileItem(item.of[0], ctx).literal : ""; + return { re: `(?:${parts.join("|")})`, literal: firstLit }; + } + case "any_char_class": { + // Build a JS char class. Range → [first-last], chars → [abc]. + // Both forms are escaped so a literal `]` or `-` survives. + if (item.range) { + const [first, last] = item.range; + return { + re: `[${regexpEscape(first)}-${regexpEscape(last)}]`, + literal: first ?? "", + }; + } + if (item.chars && item.chars.length > 0) { + const escaped = item.chars.map((c) => regexpEscape(c)).join(""); + return { re: `[${escaped}]`, literal: item.chars[0] }; + } + return { re: "[^]", literal: "" }; + } + case "group": { + const compiled = item.items.map((i) => compileItem(i, ctx)); + const re = compiled.map((c) => c.re).join(""); + const literal = compiled.map((c) => c.literal).join(""); + return { re: `(?:${re})`, literal }; + } + case "repeat": { + const inner = compileItem(item.item, ctx).re; + const { min, max } = item; + const maxVal = max === null ? Infinity : max; + const quant = maxVal === Infinity ? (min === 0 ? "*" : "+") : `{${min},${maxVal}}`; + return { re: `(?:${inner})${quant}`, literal: "" }; + } + case "stage_ref": + // Stage references are handled by the executor, not by item compilation. + return { re: "", literal: "" }; + } +} +/** + * Compile an Item to a literal string only (no regex semantics). + * Used by the parallel-replace executor which needs exact strings. + * + * Returns `null` if the Item cannot be represented as a literal + * (captures, regex-only constructs). The caller decides whether to + * fall back to sequential execution. + */ +export function compileToLiteral(item, ctx) { + switch (item.kind) { + case "string": + return item.value; + case "alias": { + const stdlib = STDLIB_ALIASES[item.name]; + if (stdlib) + return stdlib.literal === "" ? null : stdlib.literal; + const resolved = ctx.resolveAlias(item.name); + if (!resolved) + return null; + return compileToLiteral(resolved, ctx); + } + case "capture_group": + case "capture_ref": + case "repeat": + case "stage_ref": + return null; + case "any_char_class": { + // Mirror Ruby's Any#nth_string: first char of the class. + if (item.chars && item.chars.length > 0) + return item.chars[0]; + if (item.range) + return item.range[0]; + return null; + } + case "any": { + // `any` represents alternative spellings (e.g. "te" vs "t" for the + // same source char). Ruby picks the first option in non-iterating + // mode; we match that. + if (item.of.length === 0) + return null; + return compileToLiteral(item.of[0], ctx); + } + case "group": { + let out = ""; + for (const child of item.items) { + const lit = compileToLiteral(child, ctx); + if (lit === null) + return null; + out += lit; + } + return out; + } + } +} +/** + * Expand a `from` item into ALL possible literal strings for parallel + * replace. `any` items produce one entry per alternative. Other items + * produce a single entry (or null if not literal). + * + * This is the multi-valued counterpart of `compileToLiteral`. + */ +export function expandFromLiterals(item, ctx) { + switch (item.kind) { + case "string": + return [item.value]; + case "alias": { + const stdlib = STDLIB_ALIASES[item.name]; + if (stdlib) + return null; + const resolved = ctx.resolveAlias(item.name); + if (!resolved) + return null; + return expandFromLiterals(resolved, ctx); + } + case "any_char_class": { + // Mirror Ruby's parallel-tree expansion: one entry per char. + // For ranges, expand every code point — same as Ruby's Any#data + // when value is a Range. + if (item.chars) + return [...item.chars]; + if (item.range) { + const [first, last] = item.range; + const start = first.codePointAt(0); + const end = last.codePointAt(0); + const out = []; + for (let cp = start; cp <= end; cp++) + out.push(String.fromCodePoint(cp)); + return out; + } + return null; + } + case "any": { + const out = []; + for (const child of item.of) { + const lit = expandFromLiterals(child, ctx); + if (lit === null) + return null; + out.push(...lit); + } + return out; + } + case "group": { + // Cartesian product of all children's alternatives. + let combos = [""]; + for (const child of item.items) { + const childAlts = expandFromLiterals(child, ctx); + if (childAlts === null) + return null; + const next = []; + for (const prefix of combos) { + for (const suffix of childAlts) { + next.push(prefix + suffix); + } + } + combos = next; + } + return combos; + } + default: + return null; + } +} +/** + * Compute the max-length estimate for an Item. Mirrors Ruby's + * `Node::Item#max_length`, which is used to sort parallel rules + * (longest first) before building the megaregexp fallback. + * + * The estimate need not be exact — it only governs sort order within + * a parallel block. Stdlib aliases count as length 1 (matching Ruby), + * `none` is 0. + */ +export function maxLengthOfItem(item, ctx) { + switch (item.kind) { + case "string": + return item.value.length; + case "capture_group": + return maxLengthOfItem(item.data, ctx); + case "capture_ref": + return 1; + case "alias": { + if (item.name === "none") + return 0; + if (STDLIB_ALIASES[item.name]) + return 1; + const resolved = ctx.resolveAlias(item.name); + return resolved ? maxLengthOfItem(resolved, ctx) : 1; + } + case "any": + return item.of.reduce((m, i) => Math.max(m, maxLengthOfItem(i, ctx)), 0); + case "any_char_class": + return 1; + case "group": + return item.items.reduce((sum, i) => sum + maxLengthOfItem(i, ctx), 0); + case "repeat": + return maxLengthOfItem(item.item, ctx); + case "stage_ref": + return 1; + } +} +/** + * Stdlib alias table — single-character aliases like `:word`, `:boundary`. + * Mirrors Interscript::Stdlib::ALIASES in Ruby. + */ +const STDLIB_ALIASES = Object.freeze({ + any_character: { re: ".", literal: "" }, + none: { re: "", literal: "" }, + space: { re: " ", literal: " " }, + whitespace: { re: "\\s+", literal: " " }, + // Boundary is implemented as Unicode-aware lookarounds so that + // Cyrillic, Arabic, Devanagari etc. get correct word boundaries + // (66 maps rely on this). Ruby's \b is ASCII-only by default, but + // most maps work because their boundary usage is at start-of-string + // or after whitespace — cases where ASCII \b happens to coincide + // with the Unicode form. + boundary: { re: "(?:(?(rule: Extract, ctx: ExecutionContext): void; +export type { Item }; +//# sourceMappingURL=executor.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/executor.d.ts.map b/vendor/interscript-ts/dist/runtime/executor.d.ts.map new file mode 100644 index 0000000..864aa97 --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/executor.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/runtime/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAW,MAAM,aAAa,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAiBpD,KAAK,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;AAmO5B,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAC5C,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,EAChC,GAAG,EAAE,gBAAgB,GACpB,IAAI,CAGN;AAGD,YAAY,EAAE,IAAI,EAAE,CAAA"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/executor.js b/vendor/interscript-ts/dist/runtime/executor.js new file mode 100644 index 0000000..482dead --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/executor.js @@ -0,0 +1,224 @@ +/** + * Rule executors — one pure function per Rule kind. + * + * Adding a new Rule kind: + * 1. Add a variant to `Rule` in `types.ts` + * 2. Register an executor here via the `executors` map + * + * Existing executors never need to change (OCP). + */ +import { compileItem, compileToLiteral, expandFromLiterals, maxLengthOfItem } from "./compile-item.js"; +import { MapLogicError } from "../errors.js"; +import { compileParallelTree, parallelReplaceTree, parallelMegaregexp, downcase, upcase, titleCase, separate, compose, decompose, } from "../stdlib.js"; +/** Built-in function registry. Mirrors Interscript.functions.* in Ruby. */ +const BUILTIN_FUNCTIONS = { + downcase, + upcase, + title_case: (i, o) => titleCase(i, o ?? {}), + separate: (i, o) => separate(i, o ?? {}), + compose, + decompose, +}; +function resolveFunction(ctx, name) { + const fromMap = ctx.functions.get(name)?.impl; + if (fromMap) + return fromMap; + const builtin = BUILTIN_FUNCTIONS[name]; + if (builtin) + return builtin; + return undefined; +} +const executors = { + sub: (rule, ctx) => executeSubRule(rule, ctx), + run: (rule, ctx) => { + // If docName is set, resolve via the loader (dependency map). + // Otherwise look up the stage in the current map. + const targetMap = rule.docName ? ctx.loadDependency(rule.docName) : ctx.map; + const target = targetMap.stages.find((s) => s.name === rule.stage); + if (!target) + throw new MapLogicError(`Stage not found: ${rule.stage}`); + const inner = ctx.withMap(targetMap); + for (const r of target.rules) { + executeRule(r, inner); + } + // Propagate the transformed string back to the outer context. + ctx.current = inner.current; + }, + funcall: (rule, ctx) => { + const fn = resolveFunction(ctx, rule.name); + if (!fn) + throw new MapLogicError(`Unknown function: ${rule.name}`); + ctx.current = fn(ctx.current, rule.kwargs ?? {}); + }, + parallel: (rule, ctx) => { + // Ruby's parallel executor tries tree mode first; if ANY rule has + // before/after/not_before/not_after constraints OR contains a + // re-only stdlib alias (boundary, line_start, word, etc.) inside + // `from`, the whole block falls back to a single megaregexp gsub + // (alternation of every rule's compiled pattern, first-match-wins + // at each position). + // + // Splitting at the rule level (trie for unconstrained, sequential + // for constrained) produces different output because the trie pass + // mutates the string before constrained rules can compete. We must + // take the WHOLE block down one path or the other. + const subRules = []; + const trailingRules = []; + for (const inner of rule.rules) { + if (inner.kind === "sub" && inner.from) { + subRules.push(inner); + } + else { + trailingRules.push(inner); + } + } + // A rule is tree-compatible if it has no before/after clauses AND + // its `from` can be expanded to literal strings (no re-only aliases + // like boundary, no captures). If any rule fails this check, the + // whole block goes through megaregexp. + const treeCompatible = (r) => !r.before && !r.after && !r.notBefore && !r.notAfter && expandFromLiterals(r.from, ctx) !== null; + const anyConstrained = subRules.some((r) => !treeCompatible(r)); + if (!anyConstrained) { + // Tree mode: every from must compile to literal(s) + const triePairs = []; + for (const r of subRules) { + if (r.to && r.to.kind === "funcall_inline") + continue; + const toLit = r.to ? compileToLiteral(r.to, ctx) : ""; + if (toLit === null) + continue; + const fromAlts = expandFromLiterals(r.from, ctx); + if (fromAlts === null) + continue; + for (const fromLit of fromAlts) + triePairs.push([fromLit, toLit]); + } + if (triePairs.length > 0) { + ctx.current = parallelReplaceTree(ctx.current, compileParallelTree(triePairs)); + } + } + else { + // Megaregexp mode: sort by max_length desc (declaration as + // tiebreaker), then build one alternation regex. + const sorted = subRules + .map((r, idx) => ({ + rule: r, + idx, + len: maxLengthOfItem(r.from, ctx) + + (r.before ? maxLengthOfItem(r.before, ctx) : 0) + + (r.after ? maxLengthOfItem(r.after, ctx) : 0) + + (r.notBefore ? maxLengthOfItem(r.notBefore, ctx) : 0) + + (r.notAfter ? maxLengthOfItem(r.notAfter, ctx) : 0) + + (r.priority ?? 0), + })) + .sort((a, b) => b.len - a.len || a.idx - b.idx); + const megaRules = sorted.map(({ rule: r }) => { + const from = compileItem(r.from, ctx); + const before = r.before ? compileItem(r.before, ctx).re : ""; + const after = r.after ? compileItem(r.after, ctx).re : ""; + const notBefore = r.notBefore ? compileItem(r.notBefore, ctx).re : ""; + const notAfter = r.notAfter ? compileItem(r.notAfter, ctx).re : ""; + const pattern = [ + before ? `(?<=${before})` : "", + notBefore ? `(? resolveTemplate(replacement, match, _groups) + : replacement; + return { pattern, replace: replaceFn }; + }); + ctx.current = parallelMegaregexp(ctx.current, megaRules); + } + // Non-sub rules (run/funcall/etc.) execute after the parallel pass, + // in declaration order. + for (const r of trailingRules) + executeRule(r, ctx); + }, + sequential: (rule, ctx) => { + for (const inner of rule.rules) { + executeRule(inner, ctx); + } + }, +}; +function executeSubRule(rule, ctx) { + if (!rule.from) + throw new MapLogicError("Sub rule missing 'from'"); + const from = compileItem(rule.from, ctx); + // `before` and `after` are lookarounds — they assert without consuming. + // Ruby's interpreter uses Ruby gsub with capture groups, which DOES + // consume the surrounding context and re-inserts it via backreferences. + // We use lookarounds for correctness with multi-byte scripts. + const before = rule.before ? compileItem(rule.before, ctx).re : ""; + const after = rule.after ? compileItem(rule.after, ctx).re : ""; + const notBefore = rule.notBefore ? compileItem(rule.notBefore, ctx).re : ""; + const notAfter = rule.notAfter ? compileItem(rule.notAfter, ctx).re : ""; + const patternParts = []; + if (before) + patternParts.push(`(?<=${before})`); + if (notBefore) + patternParts.push(`(? { + // Use function to avoid $' $` $$ special-meaning bugs in + // String.replace replacement strings. + const tmpl = replacement; + return (match, ...args) => resolveTemplate(tmpl, match, args); + })() + : replacement); +} +/** + * Resolve a replacement template against a regex match. + * + * Handles `$1`, `$2` capture-group references. Does NOT interpret + * `$'`, `` $` ``, `$$` — those are literal characters in our templates. + */ +function resolveTemplate(template, match, groups) { + return template.replace(/\$(\d+)/g, (_, n) => { + const idx = parseInt(n, 10); + return groups[idx - 1] ?? match; + }); +} +/** + * Build the replacement string for a sub rule. + * Handles plain Items (use their literal form) and inline funcalls. + * + * With lookaround-based patterns (no surrounding capture groups), the + * replacement is simply the compiled literal of the `to` item. + */ +function buildReplacement(to, ctx) { + if (!to) + return ""; + if (to.kind === "funcall_inline") { + const fn = resolveFunction(ctx, to.name); + if (!fn) + throw new MapLogicError(`Unknown inline function: ${to.name}`); + return (match) => fn(match); + } + const compiled = compileItem(to, ctx); + return compiled.literal; +} +/** Dispatch a Rule to its registered executor. O(1) lookup. */ +export function executeRule(rule, ctx) { + const executor = executors[rule.kind]; + executor(rule, ctx); +} +//# sourceMappingURL=executor.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/executor.js.map b/vendor/interscript-ts/dist/runtime/executor.js.map new file mode 100644 index 0000000..9564d0d --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/executor.js.map @@ -0,0 +1 @@ +{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/runtime/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAA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,UAAU,WAAW,CACzB,IAAgC,EAChC,GAAqB;IAErB,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAuB,CAAA;IAC3D,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AACrB,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/interpreter.d.ts b/vendor/interscript-ts/dist/runtime/interpreter.d.ts new file mode 100644 index 0000000..80a2021 --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/interpreter.d.ts @@ -0,0 +1,30 @@ +/** + * Stage execution — apply a stage's rules in sequence to the context. + * + * Pure orchestrator: builds context, dispatches to rule executors, + * returns the final string. Holds no state itself. + * + * Two paths: + * - executeStage (sync): fast path for rule-only maps. Throws if + * the stage contains ML funcalls (rababa/secryst). + * - executeStageAsync (async): handles everything including ML. + * Falls through to the sync path for non-ML stages (zero overhead). + */ +import type { CompiledMap } from "../types.js"; +import type { MapLoader } from "../loader.js"; +/** Register an additional async function name (used by ML modules). */ +export declare function registerAsyncFunction(name: string): void; +/** + * Run a single stage by name (SYNC path). Returns the transformed string. + * + * Throws if the stage contains ML funcalls — use `executeStageAsync` + * for those. + */ +export declare function executeStage(map: CompiledMap, stageName: string, input: string, loader?: MapLoader): string; +/** + * Run a single stage by name (ASYNC path). Handles ML funcalls. + * + * For non-ML stages, delegates to the sync path (zero overhead). + */ +export declare function executeStageAsync(map: CompiledMap, stageName: string, input: string, loader?: MapLoader): Promise; +//# sourceMappingURL=interpreter.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/interpreter.d.ts.map b/vendor/interscript-ts/dist/runtime/interpreter.d.ts.map new file mode 100644 index 0000000..e8b1029 --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/interpreter.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"interpreter.d.ts","sourceRoot":"","sources":["../../src/runtime/interpreter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAU7C,uEAAuE;AACvE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAExD;AAmBD;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,SAAS,GACjB,MAAM,CAkBR;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,SAAS,GACjB,OAAO,CAAC,MAAM,CAAC,CAiBjB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/interpreter.js b/vendor/interscript-ts/dist/runtime/interpreter.js new file mode 100644 index 0000000..0fc61c4 --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/interpreter.js @@ -0,0 +1,130 @@ +/** + * Stage execution — apply a stage's rules in sequence to the context. + * + * Pure orchestrator: builds context, dispatches to rule executors, + * returns the final string. Holds no state itself. + * + * Two paths: + * - executeStage (sync): fast path for rule-only maps. Throws if + * the stage contains ML funcalls (rababa/secryst). + * - executeStageAsync (async): handles everything including ML. + * Falls through to the sync path for non-ML stages (zero overhead). + */ +import { ExecutionContext } from "./context.js"; +import { executeRule } from "./executor.js"; +/** + * Set of function names that require async execution (ML inference). + * Populated from the ML module registration. + */ +const ASYNC_FUNCTIONS = new Set(["rababa", "secryst"]); +/** Register an additional async function name (used by ML modules). */ +export function registerAsyncFunction(name) { + ASYNC_FUNCTIONS.add(name); +} +/** + * Check if a rule list contains any async funcalls. + * Shallow scan — doesn't recurse into parallel/sequential groups + * deeper than one level (sufficient for real maps). + */ +function containsAsyncFuncalls(rules) { + for (const r of rules) { + if (r.kind === "funcall" && ASYNC_FUNCTIONS.has(r.name)) + return true; + if (r.kind === "parallel" || r.kind === "sequential") { + for (const inner of r.rules) { + if (inner.kind === "funcall" && ASYNC_FUNCTIONS.has(inner.name)) + return true; + } + } + } + return false; +} +/** + * Run a single stage by name (SYNC path). Returns the transformed string. + * + * Throws if the stage contains ML funcalls — use `executeStageAsync` + * for those. + */ +export function executeStage(map, stageName, input, loader) { + const stage = map.stages.find((s) => s.name === stageName); + if (!stage) { + return input; + } + if (containsAsyncFuncalls(stage.rules)) { + throw new Error(`Stage "${stageName}" contains ML function calls (rababa/secryst). ` + + `Use transliterateAsync() instead of transliterate().`); + } + const ctx = new ExecutionContext(map, input, loader); + for (const rule of stage.rules) { + executeRule(rule, ctx); + } + return ctx.current; +} +/** + * Run a single stage by name (ASYNC path). Handles ML funcalls. + * + * For non-ML stages, delegates to the sync path (zero overhead). + */ +export async function executeStageAsync(map, stageName, input, loader) { + const stage = map.stages.find((s) => s.name === stageName); + if (!stage) { + return input; + } + // Fast path: no async functions → use the sync executor directly. + if (!containsAsyncFuncalls(stage.rules)) { + return executeStage(map, stageName, input, loader); + } + // Async path: same executors, but funcall results are awaited. + const ctx = new ExecutionContext(map, input, loader); + for (const rule of stage.rules) { + await executeRuleAsync(rule, ctx); + } + return ctx.current; +} +/** + * Async rule dispatcher. Same as `executeRule` but awaits funcall + * results. Only used for stages that contain async functions. + * + * All non-funcall rule kinds delegate to the sync executor (they're + * already synchronous). Only funcall needs special handling. + */ +async function executeRuleAsync(rule, ctx) { + if (rule.kind === "funcall") { + await executeFuncallAsync(rule, ctx); + return; + } + // All other rule kinds are sync — delegate to the existing executor. + // This avoids duplicating the parallel/sub/run logic (DRY). + executeRule(rule, ctx); +} +/** + * Async funcall handler. Looks up the function, calls it, and awaits + * the result. Handles both sync functions (transparent — Promise.resolve) + * and async functions (rababa, secryst). + * + * OCP: doesn't hardcode which functions are async. Just awaits + * whatever the function returns, sync or not. + */ +async function executeFuncallAsync(rule, ctx) { + // Rababa has its own config-keyed model registry (see stdlib/ml.ts). + // The config "200" maps to a specific model URL and rababa-specific + // config — bypass the generic ML registry, which is keyed by task + // version and doesn't know about rababa configs. + if (rule.name === "rababa") { + const { rababa } = await import("../stdlib/ml.js"); + ctx.current = await rababa(ctx.current, rule.kwargs); + return; + } + // Other ASYNC_FUNCTIONS (secryst, etc.) still go through the generic + // ML registry. + if (ASYNC_FUNCTIONS.has(rule.name)) { + const { loadModel } = await import("../ml/index.js"); + const modelId = (rule.kwargs?.config ?? rule.kwargs?.model ?? "default"); + const model = await loadModel({ kind: rule.name, id: modelId }); + ctx.current = await model.transform(ctx.current); + return; + } + // Fall back to the sync funcall executor for all other functions. + executeRule({ kind: "funcall", name: rule.name, kwargs: rule.kwargs }, ctx); +} +//# sourceMappingURL=interpreter.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/runtime/interpreter.js.map b/vendor/interscript-ts/dist/runtime/interpreter.js.map new file mode 100644 index 0000000..b346b8f --- /dev/null +++ b/vendor/interscript-ts/dist/runtime/interpreter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"interpreter.js","sourceRoot":"","sources":["../../src/runtime/interpreter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;GAGG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAA;AAE9D,uEAAuE;AACvE,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC3B,CAAC;AAED;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,KAAsB;IACnD,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC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AI,CAAC,MAA6B,CAAC,CAAA;QAC3E,OAAM;IACR,CAAC;IACD,qEAAqE;IACrE,eAAe;IACf,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAA;QACpD,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,SAAS,CAAW,CAAA;QAClF,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAiB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;QAC5E,GAAG,CAAC,OAAO,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAChD,OAAM;IACR,CAAC;IACD,kEAAkE;IAClE,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAU,EAAE,GAAG,CAAC,CAAA;AACrF,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/stdlib.d.ts b/vendor/interscript-ts/dist/stdlib.d.ts new file mode 100644 index 0000000..6e91e21 --- /dev/null +++ b/vendor/interscript-ts/dist/stdlib.d.ts @@ -0,0 +1,96 @@ +/** + * Standard library helpers — direct port of + * `interscript-ruby/lib/interscript/stdlib.rb`. + * + * Pure functions: no global state, no side effects. Easy to test in + * isolation. Each function has exactly one responsibility (MECE). + */ +/** + * Apply parallel string replacements in a single pass. + * + * Replaces all (from, to) pairs simultaneously, longest-from-first to + * avoid ambiguity. Tree-based for O(n log n) on input length. + * + * Port of `Interscript::Stdlib.parallel_replace`. + */ +export declare function parallelReplace(input: string, pairs: readonly (readonly [string, string])[]): string; +/** + * Trie node for parallel replacement. Maps char code → child node. + * `match` holds the replacement string when this node is the end of a + * complete "from" pattern. + * + * Port of Ruby's nested-hash tree with `nil` sentinel for matches. + */ +export interface ParallelTrieNode { + readonly children: Map; + match: string | null; +} +export declare function emptyTrieNode(): ParallelTrieNode; +/** + * Build a trie from (from, to) pairs. Each "from" string becomes a path + * from root through character codes; the final node holds `match = to`. + * + * Multiple "from"s can share prefixes naturally. Longest match wins at + * runtime (handled by `parallelReplaceTree`). + * + * Port of `Interscript::Stdlib.parallel_replace_compile_tree`. + */ +export declare function compileParallelTree(pairs: readonly (readonly [string, string])[]): ParallelTrieNode; +/** + * Walk `input` against the trie, emitting the longest match at each + * position. Falls back to passing through the character unchanged. + * + * Port of `Interscript::Stdlib.parallel_replace_tree`. + */ +export declare function parallelReplaceTree(input: string, tree: ParallelTrieNode): string; +/** + * Escape a string so it matches literally inside a RegExp. + * Port of Ruby's `Regexp.escape`. + */ +export declare function regexpEscape(input: string): string; +/** + * Lowercase a string. Maps to `Interscript.functions.downcase`. + */ +export declare function downcase(input: string): string; +/** + * Uppercase a string. Maps to `Interscript.functions.upcase`. + */ +export declare function upcase(input: string): string; +/** + * Capitalise each word; honours custom word separator. + * Maps to `Interscript.functions.title_case`. + */ +export declare function titleCase(input: string, opts?: { + wordSeparator?: string; +}): string; +/** + * Insert a separator between every character. + * Maps to `Interscript.functions.separate`. + */ +export declare function separate(input: string, opts?: { + separator?: string; +}): string; +/** + * Unicode NFC normalisation via String.prototype.normalize. + */ +export declare function compose(input: string): string; +export declare function decompose(input: string): string; +/** + * Megaregexp parallel replace — Ruby's fallback for parallel blocks + * where any rule has `before`/`after`/`not_before`/`not_after` constraints. + * + * Mirrors `Interscript::Stdlib.parallel_regexp_compile` + `parallel_regexp_gsub`: + * all rules join into one alternation `(?p0)|(?p1)|...` and a single + * gsub decides which alternative matched via the named group. Rule order is + * pre-sorted by the caller (longest `max_length` first, declaration order + * as tiebreaker — matching Ruby's `deterministic_sort_by_max_length`). + * + * Onigmo and V8 share alternation semantics: at each scan position, + * alternatives are tried in declaration order and the first match wins. + */ +export interface MegaregexpRule { + readonly pattern: string; + readonly replace: (match: string, groups: (string | undefined)[]) => string; +} +export declare function parallelMegaregexp(input: string, rules: readonly MegaregexpRule[]): string; +//# sourceMappingURL=stdlib.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/stdlib.d.ts.map b/vendor/interscript-ts/dist/stdlib.d.ts.map new file mode 100644 index 0000000..6130072 --- /dev/null +++ b/vendor/interscript-ts/dist/stdlib.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"stdlib.d.ts","sourceRoot":"","sources":["../src/stdlib.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GAC5C,MAAM,CAGR;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAChD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GAC5C,gBAAgB,CAuBlB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,MAAM,CA8BjF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAOtF;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAGjF;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,KAAK,MAAM,CAAA;CAC5E;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAe1F"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/stdlib.js b/vendor/interscript-ts/dist/stdlib.js new file mode 100644 index 0000000..c70644d --- /dev/null +++ b/vendor/interscript-ts/dist/stdlib.js @@ -0,0 +1,160 @@ +/** + * Standard library helpers — direct port of + * `interscript-ruby/lib/interscript/stdlib.rb`. + * + * Pure functions: no global state, no side effects. Easy to test in + * isolation. Each function has exactly one responsibility (MECE). + */ +/** + * Apply parallel string replacements in a single pass. + * + * Replaces all (from, to) pairs simultaneously, longest-from-first to + * avoid ambiguity. Tree-based for O(n log n) on input length. + * + * Port of `Interscript::Stdlib.parallel_replace`. + */ +export function parallelReplace(input, pairs) { + if (pairs.length === 0) + return input; + return parallelReplaceTree(input, compileParallelTree(pairs)); +} +export function emptyTrieNode() { + return { children: new Map(), match: null }; +} +/** + * Build a trie from (from, to) pairs. Each "from" string becomes a path + * from root through character codes; the final node holds `match = to`. + * + * Multiple "from"s can share prefixes naturally. Longest match wins at + * runtime (handled by `parallelReplaceTree`). + * + * Port of `Interscript::Stdlib.parallel_replace_compile_tree`. + */ +export function compileParallelTree(pairs) { + const root = emptyTrieNode(); + for (const [from, to] of pairs) { + if (from.length === 0) + continue; + let branch = root; + for (let i = 0; i < from.length - 1; i++) { + const code = from.charCodeAt(i); + let next = branch.children.get(code); + if (!next) { + next = emptyTrieNode(); + branch.children.set(code, next); + } + branch = next; + } + const last = from.charCodeAt(from.length - 1); + let leaf = branch.children.get(last); + if (!leaf) { + leaf = emptyTrieNode(); + branch.children.set(last, leaf); + } + leaf.match = to; + } + return root; +} +/** + * Walk `input` against the trie, emitting the longest match at each + * position. Falls back to passing through the character unchanged. + * + * Port of `Interscript::Stdlib.parallel_replace_tree`. + */ +export function parallelReplaceTree(input, tree) { + let out = ""; + const len = input.length; + let i = 0; + while (i < len) { + let branch = tree; + let matchEnd = 0; + let matchReplacement = null; + for (let j = 0; i + j < len; j++) { + const code = input.charCodeAt(i + j); + const next = branch.children.get(code); + if (!next) + break; + branch = next; + if (branch.match !== null) { + matchEnd = j + 1; + matchReplacement = branch.match; + } + } + if (matchReplacement !== null && matchEnd > 0) { + out += matchReplacement; + i += matchEnd; + } + else { + out += input[i]; + i += 1; + } + } + return out; +} +/** + * Escape a string so it matches literally inside a RegExp. + * Port of Ruby's `Regexp.escape`. + */ +export function regexpEscape(input) { + return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} +/** + * Lowercase a string. Maps to `Interscript.functions.downcase`. + */ +export function downcase(input) { + return input.toLowerCase(); +} +/** + * Uppercase a string. Maps to `Interscript.functions.upcase`. + */ +export function upcase(input) { + return input.toUpperCase(); +} +/** + * Capitalise each word; honours custom word separator. + * Maps to `Interscript.functions.title_case`. + */ +export function titleCase(input, opts = {}) { + const sep = opts.wordSeparator ?? " "; + if (sep === "") + return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); + return input + .split(sep) + .map((w) => (w.length === 0 ? w : w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())) + .join(sep); +} +/** + * Insert a separator between every character. + * Maps to `Interscript.functions.separate`. + */ +export function separate(input, opts = {}) { + const sep = opts.separator ?? " "; + return input.split("").join(sep); +} +/** + * Unicode NFC normalisation via String.prototype.normalize. + */ +export function compose(input) { + return input.normalize("NFC"); +} +export function decompose(input) { + return input.normalize("NFD"); +} +export function parallelMegaregexp(input, rules) { + if (rules.length === 0) + return input; + const parts = rules.map((r, i) => `(?<__r${i}>${r.pattern})`); + const re = new RegExp(parts.join("|"), "gmu"); + return input.replace(re, (...args) => { + const groups = args[args.length - 1]; + for (let i = 0; i < rules.length; i++) { + if (groups[`__r${i}`] !== undefined) { + const match = args[0]; + const captures = args.slice(1, -2); + return rules[i].replace(match, captures); + } + } + return args[0]; + }); +} +//# sourceMappingURL=stdlib.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/stdlib.js.map b/vendor/interscript-ts/dist/stdlib.js.map new file mode 100644 index 0000000..10aedb2 --- /dev/null +++ b/vendor/interscript-ts/dist/stdlib.js.map @@ -0,0 +1 @@ +{"version":3,"file":"stdlib.js","sourceRoot":"","sources":["../src/stdlib.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAa,EACb,KAA6C;IAE7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACpC,OAAO,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAA;AAC/D,CAAC;AAcD,MAAM,UAAU,aAAa;IAC3B,OAAO,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AAC7C,CAAC;AAED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AkB,CAAC,KAAa,EAAE,KAAgC;IAChF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,GAAG,CAAC,CAAA;IAC7D,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;IAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAuC,CAAA;QAC1E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;gBACpC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAW,CAAA;gBAC/B,MAAM,QAAQ,GAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAA4B,CAAA;gBAC9D,OAAO,KAAK,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YAC3C,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC,CAAC,CAAW,CAAA;IAC1B,CAAC,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/stdlib/ml.d.ts b/vendor/interscript-ts/dist/stdlib/ml.d.ts new file mode 100644 index 0000000..946ba7b --- /dev/null +++ b/vendor/interscript-ts/dist/stdlib/ml.d.ts @@ -0,0 +1,55 @@ +/** + * Rababa function — wired into the stdlib function registry. + * + * Called from rule executors when a map invokes `rababa config: "200"`. + * Loads the model on first use via the ML registry. + * + * Config keys (e.g. "200") map to a (model URL, rababa-specific config) + * pair via a registry. The registry is populated from + * `interscript-maps.yaml`'s `rababa-configs` section, the same source + * the Ruby runtime uses. Callers can override at runtime via + * `setRababaConfig(key, ...)`. + */ +/** + * Rababa config — mirrors the YAML structure of `rababa-configs:` in + * `interscript-maps.yaml`. The `model` is a URL to the ONNX file; the + * `config` is passed to the diacritizer. + */ +export interface RababaConfigEntry { + readonly model: string; + readonly config: Readonly>; +} +/** + * Register or replace a rababa config entry. Useful for tests and for + * air-gapped environments that need to point at a local model file. + * + * setRababaConfig("200", { + * model: "file:///path/to/model.onnx", + * config: { max_len: 200, batch_size: 32, ... }, + * }) + */ +export declare function setRababaConfig(key: string, entry: RababaConfigEntry): void; +/** + * Reset the rababa config registry to the defaults shipped with the + * library. Tests use this to undo `setRababaConfig` between cases. + */ +export declare function resetRababaConfigs(): void; +/** + * Run rababa diacritization on the input. + * + * Maps call this as `rababa config: "200"` (the Interscript DSL). + * The function registry in `executor.ts` dispatches funcalls with + * `name: "rababa"` to this function. + * + * Async — the function executor must use `transliterateAsync` when + * a map's stage contains a rababa call (see #67). + */ +export declare function rababa(input: string, opts?: { + config?: string; +}): Promise; +/** + * Strip haraqat from text. Pure — no model required. + * Used by `rababa_reverse` in maps. + */ +export declare function rababaReverse(input: string): string; +//# sourceMappingURL=ml.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/stdlib/ml.d.ts.map b/vendor/interscript-ts/dist/stdlib/ml.d.ts.map new file mode 100644 index 0000000..999fd00 --- /dev/null +++ b/vendor/interscript-ts/dist/stdlib/ml.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ml.d.ts","sourceRoot":"","sources":["../../src/stdlib/ml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACnD;AAiBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAE3E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAoDD;;;;;;;;;GASG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAI3F;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/stdlib/ml.js b/vendor/interscript-ts/dist/stdlib/ml.js new file mode 100644 index 0000000..3001100 --- /dev/null +++ b/vendor/interscript-ts/dist/stdlib/ml.js @@ -0,0 +1,113 @@ +/** + * Rababa function — wired into the stdlib function registry. + * + * Called from rule executors when a map invokes `rababa config: "200"`. + * Loads the model on first use via the ML registry. + * + * Config keys (e.g. "200") map to a (model URL, rababa-specific config) + * pair via a registry. The registry is populated from + * `interscript-maps.yaml`'s `rababa-configs` section, the same source + * the Ruby runtime uses. Callers can override at runtime via + * `setRababaConfig(key, ...)`. + */ +import { createSession } from "../ml/session/index.js"; +import { createRababaModel } from "../ml/models/rababa/diacritizer.js"; +const DEFAULT_RABABA_CONFIGS = Object.freeze({ + "200": Object.freeze({ + model: "https://github.com/secryst/rababa-models/releases/download/0.1/diacritization_model_arabic.onnx", + config: Object.freeze({ + session_name: "base", + text_encoder: "ArabicEncoderWithStartSymbol", + text_cleaner: "valid_arabic_cleaners", + max_len: 200, + batch_size: 32, + }), + }), +}); +let rababaConfigs = new Map(Object.entries(DEFAULT_RABABA_CONFIGS)); +/** + * Register or replace a rababa config entry. Useful for tests and for + * air-gapped environments that need to point at a local model file. + * + * setRababaConfig("200", { + * model: "file:///path/to/model.onnx", + * config: { max_len: 200, batch_size: 32, ... }, + * }) + */ +export function setRababaConfig(key, entry) { + rababaConfigs.set(key, entry); +} +/** + * Reset the rababa config registry to the defaults shipped with the + * library. Tests use this to undo `setRababaConfig` between cases. + */ +export function resetRababaConfigs() { + rababaConfigs = new Map(Object.entries(DEFAULT_RABABA_CONFIGS)); +} +function resolveConfig(key) { + const entry = rababaConfigs.get(key); + if (!entry) { + throw new Error(`No rababa config registered under '${key}'. ` + + `Register one via setRababaConfig() before invoking rababa.`); + } + return entry; +} +function buildRababaConfig(raw) { + return { + maxLen: Number(raw.max_len ?? raw.maxLen ?? 200), + batchSize: Number(raw.batch_size ?? raw.batchSize ?? 32), + textEncoder: (raw.text_encoder ?? "ArabicEncoderWithStartSymbol"), + textCleaner: (raw.text_cleaner ?? "valid_arabic_cleaners"), + }; +} +const rababaCache = new Map(); +async function getRababa(configKey) { + let cached = rababaCache.get(configKey); + if (!cached) { + const entry = resolveConfig(configKey); + cached = (async () => { + const bytes = await fetchBytesLocal(entry.model); + const session = await createSession(bytes); + const config = buildRababaConfig(entry.config); + return createRababaModel({ session, artifacts: {}, config }); + })(); + rababaCache.set(configKey, cached); + cached.catch(() => rababaCache.delete(configKey)); + } + return cached; +} +// Local fetch helper that handles file:// and https:// URLs. +async function fetchBytesLocal(url) { + if (url.startsWith("file:") || url.startsWith(".")) { + const { readFile } = await import("node:fs/promises"); + const path = url.startsWith("file:") ? url.slice(5) : url; + return new Uint8Array(await readFile(path)); + } + const res = await fetch(url); + if (!res.ok) + throw new Error(`Failed to fetch ${url}: ${res.status}`); + return new Uint8Array(await res.arrayBuffer()); +} +/** + * Run rababa diacritization on the input. + * + * Maps call this as `rababa config: "200"` (the Interscript DSL). + * The function registry in `executor.ts` dispatches funcalls with + * `name: "rababa"` to this function. + * + * Async — the function executor must use `transliterateAsync` when + * a map's stage contains a rababa call (see #67). + */ +export async function rababa(input, opts = {}) { + const configKey = opts.config ?? "200"; + const model = await getRababa(configKey); + return model.diacritize(input); +} +/** + * Strip haraqat from text. Pure — no model required. + * Used by `rababa_reverse` in maps. + */ +export function rababaReverse(input) { + return input.replace(/[ًٌٍَُِّْ]/g, ""); +} +//# sourceMappingURL=ml.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/stdlib/ml.js.map b/vendor/interscript-ts/dist/stdlib/ml.js.map new file mode 100644 index 0000000..620990b --- /dev/null +++ b/vendor/interscript-ts/dist/stdlib/ml.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ml.js","sourceRoot":"","sources":["../../src/stdlib/ml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAatE,MAAM,sBAAsB,GAAgD,MAAM,CAAC,MAAM,CAAC;IACxF,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,iGAAiG;QACxG,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;YACpB,YAAY,EAAE,MAAM;YACpB,YAAY,EAAE,8BAA8B;YAC5C,YAAY,EAAE,uBAAuB;YACrC,OAAO,EAAE,GAAG;YACZ,UAAU,EAAE,EAAE;SACf,CAAC;KACH,CAAC;CACH,CAAC,CAAA;AAEF,IAAI,aAAa,GAAmC,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAA;AAEnG;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,KAAwB;IACnE,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,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C;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAA;AACzC,CAAC"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/types.d.ts b/vendor/interscript-ts/dist/types.d.ts new file mode 100644 index 0000000..532cafa --- /dev/null +++ b/vendor/interscript-ts/dist/types.d.ts @@ -0,0 +1,167 @@ +/** + * Domain model for Interscript — TypeScript-native port of the Ruby AST. + * + * Design principles (per OCP): + * - AST nodes are discriminated unions, not class hierarchies. Adding a + * new node kind = adding a new variant + a new executor registration. + * Existing executors never need to change. + * - Each type maps to exactly one Ruby AST concept (MECE). + * - Public types live here so consumers can pattern-match without + * depending on internal file layout. + */ +/** Identifier of a transliteration system, e.g. "bgnpcgn-ukr-Cyrl-Latn-2019". */ +export type SystemCode = string; +/** Metadata about a transliteration map. */ +export interface MapInfo { + systemCode: SystemCode; + displayName?: string; + authority?: string; + sourceScript?: string; + destinationScript?: string; +} +/** Result of a detect() call — one candidate system with its distance. */ +export interface DetectionResult { + mapName: SystemCode; + distance: number; +} +/** Options for detect(). */ +export interface DetectOptions { + mapPattern?: string; +} +/** + * JSON IR shape emitted by `Interscript::Compiler::JsonIR` (Ruby). + * + * `aliases` and `functions` are serialised as plain JSON objects (not + * Maps) because JSON has no Map type. The runtime reconstructs them + * into Maps at load time via `normaliseMap()`. + */ +export interface CompiledMapJson { + readonly schemaVersion: 1; + readonly systemCode: SystemCode; + readonly dependencies: readonly SystemCode[]; + readonly metadata?: Readonly>; + readonly stages: readonly Stage[]; + readonly aliases: Readonly>; + readonly functions: Readonly>; +} +/** + * Runtime form of a compiled map. + * + * Public consumers should treat this as opaque; the loader produces it + * from `CompiledMapJson` via `normaliseMap()`. + */ +export interface CompiledMap { + readonly schemaVersion: 1; + readonly systemCode: SystemCode; + readonly dependencies: readonly SystemCode[]; + readonly metadata?: Readonly>; + readonly stages: readonly Stage[]; + readonly aliases: ReadonlyMap; + readonly functions: ReadonlyMap; +} +/** Mutable builder form — produced by `normaliseMap`, frozen before use. */ +export type CompiledMapBuilder = { + -readonly [K in keyof CompiledMap]: CompiledMap[K]; +}; +export interface FunctionDef { + readonly name: string; + /** Native function reference. JSON IR serialises names; runtime resolves. */ + readonly impl?: (input: string, opts?: Record) => string; +} +/** A stage is a sequence of rules applied in order to a string. */ +export interface Stage { + readonly kind: "stage"; + readonly name: string; + readonly rules: readonly Rule[]; +} +/** + * Discriminated union of all rule kinds. + * Adding a new rule kind = adding a variant here + an executor. + */ +export type Rule = SubRule | RunRule | FuncallRule | ParallelRule | SequentialRule; +export interface SubRule { + readonly kind: "sub"; + readonly from?: Item; + readonly to?: Item | FuncallInline; + readonly before?: Item; + readonly after?: Item; + readonly notBefore?: Item; + readonly notAfter?: Item; + readonly priority?: number; +} +export interface RunRule { + readonly kind: "run"; + readonly stage: string; + readonly docName?: string; +} +export interface FuncallRule { + readonly kind: "funcall"; + readonly name: string; + readonly kwargs?: Readonly>; +} +/** Parallel rule group — all subs inside apply in a single pass. */ +export interface ParallelRule { + readonly kind: "parallel"; + readonly rules: readonly Rule[]; +} +/** Sequential rule group — applies rules in order, like a sub-stage. */ +export interface SequentialRule { + readonly kind: "sequential"; + readonly rules: readonly Rule[]; +} +/** Inline function call used as a SubRule's `to` (e.g. `:upcase`). */ +export interface FuncallInline { + readonly kind: "funcall_inline"; + readonly name: string; +} +/** Items are the building blocks of pattern/replace expressions. */ +export type Item = StringItem | CaptureGroupItem | CaptureRefItem | AliasItem | AnyItem | AnyCharClassItem | GroupItem | RepeatItem | StageItem; +export interface StringItem { + readonly kind: "string"; + readonly value: string; +} +/** A capture group `(...)` — defines a new capture. */ +export interface CaptureGroupItem { + readonly kind: "capture_group"; + readonly data: Item; +} +/** A back-reference to a previously-defined capture group (`\1`). */ +export interface CaptureRefItem { + readonly kind: "capture_ref"; + readonly id: number; +} +export interface AliasItem { + readonly kind: "alias"; + readonly name: string; + readonly map?: string; +} +export interface AnyItem { + readonly kind: "any"; + readonly of: readonly Item[]; +} +/** + * Character class — `[a-z]`, `[abc]`, etc. Mirrors Ruby's Any node when + * constructed from a String or Range payload. Kept distinct from + * `AnyItem` because Ruby's interpreter compiles them differently: + * `Any(["a","b"])` → `(?:a|b)`, `Any("ab")` → `[ab]`, `Any("a".."z")` → `[a-z]`. + */ +export interface AnyCharClassItem { + readonly kind: "any_char_class"; + readonly range?: readonly [string, string]; + readonly chars?: readonly string[]; +} +export interface GroupItem { + readonly kind: "group"; + readonly items: readonly Item[]; +} +export interface RepeatItem { + readonly kind: "repeat"; + readonly item: Item; + readonly min: number; + readonly max: number | null; +} +export interface StageItem { + readonly kind: "stage_ref"; + readonly name: string; +} +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/types.d.ts.map b/vendor/interscript-ts/dist/types.d.ts.map new file mode 100644 index 0000000..bf86989 --- /dev/null +++ b/vendor/interscript-ts/dist/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAE/B,4CAA4C;AAC5C,MAAM,WAAW,OAAO;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,UAAU,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,4BAA4B;AAC5B,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,Q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;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACnC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAA;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB"} \ No newline at end of file diff --git a/vendor/interscript-ts/dist/types.js b/vendor/interscript-ts/dist/types.js new file mode 100644 index 0000000..cbac6dd --- /dev/null +++ b/vendor/interscript-ts/dist/types.js @@ -0,0 +1,13 @@ +/** + * Domain model for Interscript — TypeScript-native port of the Ruby AST. + * + * Design principles (per OCP): + * - AST nodes are discriminated unions, not class hierarchies. Adding a + * new node kind = adding a new variant + a new executor registration. + * Existing executors never need to change. + * - Each type maps to exactly one Ruby AST concept (MECE). + * - Public types live here so consumers can pattern-match without + * depending on internal file layout. + */ +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/vendor/interscript-ts/dist/types.js.map b/vendor/interscript-ts/dist/types.js.map new file mode 100644 index 0000000..8bfa003 --- /dev/null +++ b/vendor/interscript-ts/dist/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"} \ No newline at end of file From fd207b8434f2235fbd68808c3f3373f6d41b3889 Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Mon, 24 Aug 2026 06:59:30 +0800 Subject: [PATCH 4/5] =?UTF-8?q?ci:=20drop=20sparse-checkout:false=20?= =?UTF-8?q?=E2=80=94=20it=20sparse-checks=20out=20only=20top-level=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b21e8d..c9ebae8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - with: { sparse-checkout: false } - uses: actions/setup-node@v4 with: { node-version: "22" } - run: npm install From cfd7c5acbee0c1cfb0b6752ca3a238220986d77a Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Mon, 24 Aug 2026 07:01:28 +0800 Subject: [PATCH 5/5] style: prettier across the repo (format:check was failing since the REST PR) --- scripts/e2e.mjs | 58 +++- src/generated/models.json | 634 ++++++++++++++++++-------------------- src/maps.ts | 4 +- src/openapi.ts | 4 +- test/rest.test.ts | 16 +- 5 files changed, 364 insertions(+), 352 deletions(-) diff --git a/scripts/e2e.mjs b/scripts/e2e.mjs index ae57b4a..fe1caef 100644 --- a/scripts/e2e.mjs +++ b/scripts/e2e.mjs @@ -57,14 +57,26 @@ console.log(`E2E against ${BASE}\n`) { const res = await get("/") check("GET / 200", res.status === 200) - check("GET / lists endpoints", Array.isArray(res.body.endpoints) && res.body.endpoints.includes("POST /v1/infer")) + check( + "GET / lists endpoints", + Array.isArray(res.body.endpoints) && res.body.endpoints.includes("POST /v1/infer"), + ) } { const res = await get("/openapi.json") check("GET /openapi.json 200", res.status === 200) check("openapi 3.1", res.body.openapi === "3.1.0") const paths = Object.keys(res.body.paths ?? {}) - for (const p of ["/v1/info", "/v1/maps", "/v1/maps/{code}", "/v1/transliterate", "/v1/detect", "/v1/models", "/v1/models/{id}", "/v1/infer"]) { + for (const p of [ + "/v1/info", + "/v1/maps", + "/v1/maps/{code}", + "/v1/transliterate", + "/v1/detect", + "/v1/models", + "/v1/models/{id}", + "/v1/infer", + ]) { check(`openapi has ${p}`, paths.includes(p)) } } @@ -92,12 +104,22 @@ console.log(`E2E against ${BASE}\n`) // --- transliteration (byte-parity with the Ruby API fixture) --- { - const res = await post("/v1/transliterate", { system: "alalc-kat-Geor-Latn-1997", input: "ქართული" }) + const res = await post("/v1/transliterate", { + system: "alalc-kat-Geor-Latn-1997", + input: "ქართული", + }) check("transliterate 200", res.status === 200) - check("transliterate Ruby parity", res.body.output === "kʻartʻuli", `got ${JSON.stringify(res.body.output)}`) + check( + "transliterate Ruby parity", + res.body.output === "kʻartʻuli", + `got ${JSON.stringify(res.body.output)}`, + ) const missing = await post("/v1/transliterate", { system: "nope-xxx-Xxx-Xxx-0000", input: "x" }) check("transliterate unknown 404", missing.status === 404) - const tooLong = await post("/v1/transliterate", { system: "alalc-kat-Geor-Latn-1997", input: "a".repeat(1_000_001) }) + const tooLong = await post("/v1/transliterate", { + system: "alalc-kat-Geor-Latn-1997", + input: "a".repeat(1_000_001), + }) check("transliterate 1MB limit 413", tooLong.status === 413) const bad = await post("/v1/transliterate", { system: 42 }) check("transliterate bad body 400", bad.status === 400) @@ -107,7 +129,11 @@ console.log(`E2E against ${BASE}\n`) { const res = await post("/v1/detect", { input: "ქართული", output: "kʻartʻuli" }) check("detect 200", res.status === 200) - check("detect ranks a Georgian system first", (res.body.results ?? [])[0]?.mapName?.includes("kat"), JSON.stringify((res.body.results ?? []).slice(0, 2))) + check( + "detect ranks a Georgian system first", + (res.body.results ?? [])[0]?.mapName?.includes("kat"), + JSON.stringify((res.body.results ?? []).slice(0, 2)), + ) } // --- models --- @@ -131,12 +157,22 @@ console.log(`E2E against ${BASE}\n`) { const res = await post("/v1/infer", { model: "heb-diac-small-1.0", input: "שלום עליכם" }) check("infer hebrew 200", res.status === 200, JSON.stringify(res.body).slice(0, 120)) - check("infer hebrew adds nikud", typeof res.body.output === "string" && res.body.output.includes("ָ"), `got ${JSON.stringify(res.body.output)}`) + check( + "infer hebrew adds nikud", + typeof res.body.output === "string" && res.body.output.includes("ָ"), + `got ${JSON.stringify(res.body.output)}`, + ) } { const res = await post("/v1/infer", { model: "urd-g2p-1.0", input: "اردو" }) check("infer urdu 200", res.status === 200) - check("infer urdu IPA output", typeof res.body.output === "string" && res.body.output.length > 0 && /[ɑɐəɪʊuː]/.test(res.body.output), `got ${JSON.stringify(res.body.output)}`) + check( + "infer urdu IPA output", + typeof res.body.output === "string" && + res.body.output.length > 0 && + /[ɑɐəɪʊuː]/.test(res.body.output), + `got ${JSON.stringify(res.body.output)}`, + ) } { const missing = await post("/v1/infer", { model: "nope-9.9", input: "x" }) @@ -158,7 +194,11 @@ console.log(`E2E against ${BASE}\n`) const info = await q("{ info }") check("graphql info", JSON.parse(info.data.info).version.startsWith("3.")) const codes = await q("{ systemCodes }") - check("graphql systemCodes 287", codes.data.systemCodes.length === 287, `got ${codes.data.systemCodes.length}`) + check( + "graphql systemCodes 287", + codes.data.systemCodes.length === 287, + `got ${codes.data.systemCodes.length}`, + ) const tr = await q('{ transliterate(systemCode: "alalc-kat-Geor-Latn-1997", input: "ქართული") }') check("graphql transliterate parity", tr.data.transliterate === "kʻartʻuli") } diff --git a/src/generated/models.json b/src/generated/models.json index 003b6af..fbf8c3e 100644 --- a/src/generated/models.json +++ b/src/generated/models.json @@ -1,354 +1,324 @@ { - "version": 1, - "models": [ - { - "id": "khm-latn-1.0", - "task": "translit", - "scripts": [ - "Khmr", - "Latn" - ], - "precision": "fp32", - "filename": "khm-latn-1.0-fp32.zip", - "url": "https://github.com/interscript/interscript-ml/releases/download/khm-latn-1.0/khm-latn-1.0-fp32.zip", - "parts": null, - "sha256": "55993d473a2ed9489058779cad7e115db05e4020085b71616468cfae4f2f65cb", - "size": 1418009977, - "metrics": [ + "version": 1, + "models": [ { - "name": "cer", - "value": 27.42, - "source": "secryst/docs/RESULTS.md#khmer-transliteration-2026-08-14" + "id": "khm-latn-1.0", + "task": "translit", + "scripts": ["Khmr", "Latn"], + "precision": "fp32", + "filename": "khm-latn-1.0-fp32.zip", + "url": "https://github.com/interscript/interscript-ml/releases/download/khm-latn-1.0/khm-latn-1.0-fp32.zip", + "parts": null, + "sha256": "55993d473a2ed9489058779cad7e115db05e4020085b71616468cfae4f2f65cb", + "size": 1418009977, + "metrics": [ + { + "name": "cer", + "value": 27.42, + "source": "secryst/docs/RESULTS.md#khmer-transliteration-2026-08-14" + }, + { + "name": "em", + "value": 59.66, + "source": "secryst/docs/RESULTS.md#khmer-transliteration-2026-08-14" + } + ], + "parity": { + "samples": 895, + "cer_delta": 0 + }, + "license": "BSD-3-Clause" }, { - "name": "em", - "value": 59.66, - "source": "secryst/docs/RESULTS.md#khmer-transliteration-2026-08-14" - } - ], - "parity": { - "samples": 895, - "cer_delta": 0 - }, - "license": "BSD-3-Clause" - }, - { - "id": "urd-g2p-1.0", - "task": "g2p", - "scripts": [ - "Arab", - "IPA" - ], - "precision": "fp32", - "filename": "urd-g2p-1.0-fp32.zip", - "url": "https://github.com/interscript/interscript-ml/releases/download/urd-g2p-1.0/urd-g2p-1.0-fp32.zip", - "parts": null, - "sha256": "9f0a248c7116aa7f6b9ac125fb9684a3556f3b8ce8b64567c05a5e7e7a018ebf", - "size": 1418039605, - "metrics": [ - { - "name": "cer", - "value": 14.77, - "source": "rababa-urdu/docs/RESULTS.md#g2p-urdu-text--ipa" - }, - { - "name": "em", - "value": 33.6, - "source": "rababa-urdu/docs/RESULTS.md#g2p-urdu-text--ipa" - } - ], - "parity": { - "samples": 12699, - "cer_delta": 0 - }, - "license": "BSD-3-Clause" - }, - { - "id": "urd-diac-1.0", - "task": "diacritization", - "scripts": [ - "Arab", - "Arab" - ], - "precision": "fp32", - "filename": "urd-diac-1.0-fp32.zip", - "url": "https://github.com/interscript/interscript-ml/releases/download/urd-diac-1.0/urd-diac-1.0-fp32.zip", - "parts": null, - "sha256": "c299ea44a4da4851a52283f8e42d2fb6f8c7a9c443ba7eb0270f97372e10b8ea", - "size": 1417851421, - "metrics": [ - { - "name": "cer", - "value": 3.74, - "source": "rababa-urdu/docs/RESULTS.md#diacritization-urdu-text--text--haraqat" - } - ], - "parity": { - "samples": 11940, - "cer_delta": 0 - }, - "license": "BSD-3-Clause" - }, - { - "id": "heb-diac-1.0", - "task": "diacritization", - "scripts": [ - "Hebr", - "Hebr" - ], - "precision": "fp32", - "filename": "heb-diac-1.0-fp32.zip", - "url": null, - "parts": [ - { - "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.0/heb-diac-1.0-fp32.zip.part-00", - "sha256": "5497f70cc3c96829e65f1eb0cc401c2d1ffeb4fa909acd4def824c2e019cbc37", - "size": 1500000000 - }, - { - "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.0/heb-diac-1.0-fp32.zip.part-01", - "sha256": "a7d2011ab4f9326a86e234cc49cb50daf82949e51efbf03a21d5796c46465e9d", - "size": 1281139753 - } - ], - "sha256": "b32fa239e0c56708b6004942de4b9e6e9f265e7cc3828f41d560e96386e20dd8", - "size": 2781139753, - "metrics": [ - { - "name": "der_greedy", - "value": 29, - "source": "rababa/docs/RESULTS.md#hebrew-diacritization" - }, - { - "name": "der_beam4", - "value": 17.46, - "source": "rababa/docs/RESULTS.md#hebrew-diacritization" - } - ], - "parity": { - "samples": 600, - "cer_delta": 0 - }, - "license": "BSD-3-Clause" - }, - { - "id": "tha-g2p-base-1.0", - "task": "g2p", - "scripts": [ - "Thai", - "IPA" - ], - "precision": "fp32", - "filename": "tha-g2p-base-1.0-fp32.zip", - "url": null, - "parts": [ - { - "url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-base-1.0/tha-g2p-base-1.0-fp32.zip.part-00", - "sha256": "c4525414e5dec91a54d055ca9f1acd51c198f81fbfc55977aa82c1fb038d58d7", - "size": 1500000000 - }, - { - "url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-base-1.0/tha-g2p-base-1.0-fp32.zip.part-01", - "sha256": "f5d11fbd75f92e8b5471add867418e2dd4f49a5e258b9ded2f3b5ffa630abe24", - "size": 1281174343 - } - ], - "sha256": "f341a5868867a9847d3f897d1fcc4d1d63b9a59b8913871bcf4ecab48f4fa895", - "size": 2781174343, - "metrics": [ - { - "name": "per_teacher", - "value": 4.43, - "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-base-1.0" + "id": "urd-g2p-1.0", + "task": "g2p", + "scripts": ["Arab", "IPA"], + "precision": "fp32", + "filename": "urd-g2p-1.0-fp32.zip", + "url": "https://github.com/interscript/interscript-ml/releases/download/urd-g2p-1.0/urd-g2p-1.0-fp32.zip", + "parts": null, + "sha256": "9f0a248c7116aa7f6b9ac125fb9684a3556f3b8ce8b64567c05a5e7e7a018ebf", + "size": 1418039605, + "metrics": [ + { + "name": "cer", + "value": 14.77, + "source": "rababa-urdu/docs/RESULTS.md#g2p-urdu-text--ipa" + }, + { + "name": "em", + "value": 33.6, + "source": "rababa-urdu/docs/RESULTS.md#g2p-urdu-text--ipa" + } + ], + "parity": { + "samples": 12699, + "cer_delta": 0 + }, + "license": "BSD-3-Clause" }, { - "name": "per_student", - "value": 9.19, - "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-base-1.0" - } - ], - "parity": { - "samples": 1219, - "cer_delta": 0 - }, - "license": "BSD-3-Clause" - }, - { - "id": "tha-g2p-small-1.0", - "task": "g2p", - "scripts": [ - "Thai", - "IPA" - ], - "precision": "int8", - "filename": "tha-g2p-small-1.0-int8.zip", - "url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int8.zip", - "parts": null, - "sha256": "f2cfa93a42d98aabf08fdc82dfc6bd1574e21993f36558aa581fbe29e0588a94", - "size": 257468517, - "metrics": [ - { - "name": "per_teacher", - "value": 4.43, - "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0" + "id": "urd-diac-1.0", + "task": "diacritization", + "scripts": ["Arab", "Arab"], + "precision": "fp32", + "filename": "urd-diac-1.0-fp32.zip", + "url": "https://github.com/interscript/interscript-ml/releases/download/urd-diac-1.0/urd-diac-1.0-fp32.zip", + "parts": null, + "sha256": "c299ea44a4da4851a52283f8e42d2fb6f8c7a9c443ba7eb0270f97372e10b8ea", + "size": 1417851421, + "metrics": [ + { + "name": "cer", + "value": 3.74, + "source": "rababa-urdu/docs/RESULTS.md#diacritization-urdu-text--text--haraqat" + } + ], + "parity": { + "samples": 11940, + "cer_delta": 0 + }, + "license": "BSD-3-Clause" }, { - "name": "per_student", - "value": 12.06, - "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0" - } - ], - "parity": { - "samples": 1219, - "cer_delta": 0.0803 - }, - "license": null - }, - { - "id": "tha-g2p-small-1.0-int4", - "task": "g2p", - "scripts": [ - "Thai", - "IPA" - ], - "precision": "int4", - "filename": "tha-g2p-small-1.0-int4.zip", - "url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int4.zip", - "parts": null, - "sha256": "e5d12a3d65c6ac39fa08f52c975c99ff7a51c3e7b7aca7fbb461d2de2345e4cb", - "size": 201958073, - "metrics": [ - { - "name": "per_teacher", - "value": 4.43, - "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0" + "id": "heb-diac-1.0", + "task": "diacritization", + "scripts": ["Hebr", "Hebr"], + "precision": "fp32", + "filename": "heb-diac-1.0-fp32.zip", + "url": null, + "parts": [ + { + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.0/heb-diac-1.0-fp32.zip.part-00", + "sha256": "5497f70cc3c96829e65f1eb0cc401c2d1ffeb4fa909acd4def824c2e019cbc37", + "size": 1500000000 + }, + { + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.0/heb-diac-1.0-fp32.zip.part-01", + "sha256": "a7d2011ab4f9326a86e234cc49cb50daf82949e51efbf03a21d5796c46465e9d", + "size": 1281139753 + } + ], + "sha256": "b32fa239e0c56708b6004942de4b9e6e9f265e7cc3828f41d560e96386e20dd8", + "size": 2781139753, + "metrics": [ + { + "name": "der_greedy", + "value": 29, + "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + }, + { + "name": "der_beam4", + "value": 17.46, + "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + } + ], + "parity": { + "samples": 600, + "cer_delta": 0 + }, + "license": "BSD-3-Clause" }, { - "name": "per_student", - "value": 12.06, - "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0" - } - ], - "parity": { - "samples": 600, - "cer_delta": 0.0734 - }, - "license": "BSD-3-Clause" - }, - { - "id": "heb-diac-small-1.0", - "task": "diacritization", - "scripts": [ - "Hebr", - "Hebr" - ], - "precision": "fp32", - "filename": "heb-diac-small-1.0-fp32.zip", - "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-small-1.0/heb-diac-small-1.0-fp32.zip", - "parts": null, - "sha256": "905c53873d5a62bbe6252c6ec0ecef5f37e96e78cb01e8cd99b6b24c4d4d74ad", - "size": 1418663344, - "metrics": [ - { - "name": "der_teacher_greedy", - "value": 24.79, - "source": "interscript/interscript-ml docs/RESULTS.md#heb-diac-small-1.0" + "id": "tha-g2p-base-1.0", + "task": "g2p", + "scripts": ["Thai", "IPA"], + "precision": "fp32", + "filename": "tha-g2p-base-1.0-fp32.zip", + "url": null, + "parts": [ + { + "url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-base-1.0/tha-g2p-base-1.0-fp32.zip.part-00", + "sha256": "c4525414e5dec91a54d055ca9f1acd51c198f81fbfc55977aa82c1fb038d58d7", + "size": 1500000000 + }, + { + "url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-base-1.0/tha-g2p-base-1.0-fp32.zip.part-01", + "sha256": "f5d11fbd75f92e8b5471add867418e2dd4f49a5e258b9ded2f3b5ffa630abe24", + "size": 1281174343 + } + ], + "sha256": "f341a5868867a9847d3f897d1fcc4d1d63b9a59b8913871bcf4ecab48f4fa895", + "size": 2781174343, + "metrics": [ + { + "name": "per_teacher", + "value": 4.43, + "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-base-1.0" + }, + { + "name": "per_student", + "value": 9.19, + "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-base-1.0" + } + ], + "parity": { + "samples": 1219, + "cer_delta": 0 + }, + "license": "BSD-3-Clause" }, { - "name": "der_student_greedy", - "value": 30.37, - "source": "interscript/interscript-ml docs/RESULTS.md#heb-diac-small-1.0" - } - ], - "parity": { - "samples": 1864, - "cer_delta": 0 - }, - "license": null - }, - { - "id": "fas-g2p-1.0", - "task": "g2p", - "scripts": [ - "Arab", - "Latn" - ], - "precision": "fp32", - "filename": "fas-g2p-1.0-fp32.zip", - "url": null, - "parts": [ - { - "url": "https://github.com/interscript/interscript-ml/releases/download/fas-g2p-1.0/fas-g2p-1.0-fp32.zip.part-00", - "sha256": "6c475e53f3c7ef3edcef5a24d2d81f51d13ddf4c417de98440943c9a32b03e55", - "size": 1500000000 + "id": "tha-g2p-small-1.0", + "task": "g2p", + "scripts": ["Thai", "IPA"], + "precision": "int8", + "filename": "tha-g2p-small-1.0-int8.zip", + "url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int8.zip", + "parts": null, + "sha256": "f2cfa93a42d98aabf08fdc82dfc6bd1574e21993f36558aa581fbe29e0588a94", + "size": 257468517, + "metrics": [ + { + "name": "per_teacher", + "value": 4.43, + "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0" + }, + { + "name": "per_student", + "value": 12.06, + "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0" + } + ], + "parity": { + "samples": 1219, + "cer_delta": 0.0803 + }, + "license": null }, { - "url": "https://github.com/interscript/interscript-ml/releases/download/fas-g2p-1.0/fas-g2p-1.0-fp32.zip.part-01", - "sha256": "c5656c649412f41e201c567e002514d31390b636d4650d9dcb6dfed1973fb3d5", - "size": 1280254270 - } - ], - "sha256": "b53fd69196127efcc596935d24e135b3c897006872c1646c674e70f3c0d9a0e3", - "size": 2780254270, - "metrics": [ - { - "name": "cer", - "value": 1.6, - "source": "interscript/interscript-ml docs/RESULTS.md#fas-g2p-1.0" + "id": "tha-g2p-small-1.0-int4", + "task": "g2p", + "scripts": ["Thai", "IPA"], + "precision": "int4", + "filename": "tha-g2p-small-1.0-int4.zip", + "url": "https://github.com/interscript/interscript-ml/releases/download/tha-g2p-small-1.0/tha-g2p-small-1.0-int4.zip", + "parts": null, + "sha256": "e5d12a3d65c6ac39fa08f52c975c99ff7a51c3e7b7aca7fbb461d2de2345e4cb", + "size": 201958073, + "metrics": [ + { + "name": "per_teacher", + "value": 4.43, + "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0" + }, + { + "name": "per_student", + "value": 12.06, + "source": "interscript/interscript-ml docs/RESULTS.md#tha-g2p-small-1.0" + } + ], + "parity": { + "samples": 600, + "cer_delta": 0.0734 + }, + "license": "BSD-3-Clause" }, { - "name": "sb_homograph_ezafe_norm", - "value": 77.34, - "source": "interscript/interscript-ml docs/RESULTS.md#fas-g2p-1.0" - } - ], - "parity": { - "samples": 1000, - "cer_delta": 0 - }, - "license": "BSD-3-Clause" - }, - { - "id": "heb-diac-1.1", - "task": "diacritization", - "scripts": [ - "Hebr", - "Hebr" - ], - "precision": "fp32", - "filename": "heb.zip", - "url": null, - "parts": [ - { - "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-00", - "sha256": "8dac0d62e9b0ac4b137412eaf3a542953f11575f12f66f76cb93d3f5d788fc1b", - "size": 1500000000 + "id": "heb-diac-small-1.0", + "task": "diacritization", + "scripts": ["Hebr", "Hebr"], + "precision": "fp32", + "filename": "heb-diac-small-1.0-fp32.zip", + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-small-1.0/heb-diac-small-1.0-fp32.zip", + "parts": null, + "sha256": "905c53873d5a62bbe6252c6ec0ecef5f37e96e78cb01e8cd99b6b24c4d4d74ad", + "size": 1418663344, + "metrics": [ + { + "name": "der_teacher_greedy", + "value": 24.79, + "source": "interscript/interscript-ml docs/RESULTS.md#heb-diac-small-1.0" + }, + { + "name": "der_student_greedy", + "value": 30.37, + "source": "interscript/interscript-ml docs/RESULTS.md#heb-diac-small-1.0" + } + ], + "parity": { + "samples": 1864, + "cer_delta": 0 + }, + "license": null }, { - "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-01", - "sha256": "230c5ab731ea5f001f802d60b9e9a328c10b43bc311a19ef1974f114384313ed", - "size": 1280987905 - } - ], - "sha256": "f0022dde8d06e46e8f08cf0b2f7bbb887a05ed686b90f1d5aa82ca3ef690a0b0", - "size": 2780987905, - "metrics": [ - { - "name": "der_greedy", - "value": 16.44, - "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + "id": "fas-g2p-1.0", + "task": "g2p", + "scripts": ["Arab", "Latn"], + "precision": "fp32", + "filename": "fas-g2p-1.0-fp32.zip", + "url": null, + "parts": [ + { + "url": "https://github.com/interscript/interscript-ml/releases/download/fas-g2p-1.0/fas-g2p-1.0-fp32.zip.part-00", + "sha256": "6c475e53f3c7ef3edcef5a24d2d81f51d13ddf4c417de98440943c9a32b03e55", + "size": 1500000000 + }, + { + "url": "https://github.com/interscript/interscript-ml/releases/download/fas-g2p-1.0/fas-g2p-1.0-fp32.zip.part-01", + "sha256": "c5656c649412f41e201c567e002514d31390b636d4650d9dcb6dfed1973fb3d5", + "size": 1280254270 + } + ], + "sha256": "b53fd69196127efcc596935d24e135b3c897006872c1646c674e70f3c0d9a0e3", + "size": 2780254270, + "metrics": [ + { + "name": "cer", + "value": 1.6, + "source": "interscript/interscript-ml docs/RESULTS.md#fas-g2p-1.0" + }, + { + "name": "sb_homograph_ezafe_norm", + "value": 77.34, + "source": "interscript/interscript-ml docs/RESULTS.md#fas-g2p-1.0" + } + ], + "parity": { + "samples": 1000, + "cer_delta": 0 + }, + "license": "BSD-3-Clause" }, { - "name": "der_beam4", - "value": 16.43, - "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + "id": "heb-diac-1.1", + "task": "diacritization", + "scripts": ["Hebr", "Hebr"], + "precision": "fp32", + "filename": "heb.zip", + "url": null, + "parts": [ + { + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-00", + "sha256": "8dac0d62e9b0ac4b137412eaf3a542953f11575f12f66f76cb93d3f5d788fc1b", + "size": 1500000000 + }, + { + "url": "https://github.com/interscript/interscript-ml/releases/download/heb-diac-1.1/heb.zip.part-01", + "sha256": "230c5ab731ea5f001f802d60b9e9a328c10b43bc311a19ef1974f114384313ed", + "size": 1280987905 + } + ], + "sha256": "f0022dde8d06e46e8f08cf0b2f7bbb887a05ed686b90f1d5aa82ca3ef690a0b0", + "size": 2780987905, + "metrics": [ + { + "name": "der_greedy", + "value": 16.44, + "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + }, + { + "name": "der_beam4", + "value": 16.43, + "source": "rababa/docs/RESULTS.md#hebrew-diacritization" + } + ], + "parity": { + "samples": 500, + "cer_delta": 0 + }, + "license": "BSD-3-Clause" } - ], - "parity": { - "samples": 500, - "cer_delta": 0 - }, - "license": "BSD-3-Clause" - } - ] + ] } diff --git a/src/maps.ts b/src/maps.ts index 3c86cc5..e298e6c 100644 --- a/src/maps.ts +++ b/src/maps.ts @@ -48,9 +48,7 @@ export async function loadMap(assets: MapAssets, code: SystemCode): Promise = {}): Promise { - return await app.request(`https://example.org${path}`, { headers: { ...JSON_HEADERS, ...extra } }, env) + return await app.request( + `https://example.org${path}`, + { headers: { ...JSON_HEADERS, ...extra } }, + env, + ) } -async function post(path: string, body: unknown, extra: Record = {}): Promise { +async function post( + path: string, + body: unknown, + extra: Record = {}, +): Promise { return await app.request( `https://example.org${path}`, { method: "POST", headers: { ...JSON_HEADERS, ...extra }, body: JSON.stringify(body) }, @@ -83,9 +91,7 @@ describe("REST maps", () => { expect(await ok.json()).toBeTruthy() const missing = await get("/v1/maps/does-not-exist") expect(missing.status).toBe(404) - expect(((await missing.json()) as { error: { code: string } }).error.code).toBe( - "map_not_found", - ) + expect(((await missing.json()) as { error: { code: string } }).error.code).toBe("map_not_found") }) })