bantou 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +13 -0
- package/.output/public/_nuxt/BmGsA4i2.js +1 -0
- package/.output/public/_nuxt/D_G6gzEa.js +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -0
- package/.output/public/_nuxt/builds/meta/1a8fc623-6671-445b-bdd3-c3d073520a3a.json +1 -0
- package/.output/public/_nuxt/entry.CZSvzYhH.css +1 -0
- package/.output/public/_nuxt/error-404.C3wqHTJz.css +1 -0
- package/.output/public/_nuxt/error-500.D6rBzoDj.css +1 -0
- package/.output/public/_nuxt/pdFQkwM_.js +4 -0
- package/.output/server/chunks/_/error-500.mjs +20 -0
- package/.output/server/chunks/_/error-500.mjs.map +1 -0
- package/.output/server/chunks/nitro/nitro.mjs +5870 -0
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -0
- package/.output/server/chunks/routes/mcp.mjs +22 -0
- package/.output/server/chunks/routes/mcp.mjs.map +1 -0
- package/.output/server/chunks/routes/renderer.mjs +462 -0
- package/.output/server/chunks/routes/renderer.mjs.map +1 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
- package/.output/server/chunks/virtual/precomputed.mjs +4 -0
- package/.output/server/chunks/virtual/precomputed.mjs.map +1 -0
- package/.output/server/index.mjs +18 -0
- package/.output/server/index.mjs.map +1 -0
- package/.output/server/node_modules/@babel/parser/lib/index.js +14657 -0
- package/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js +64 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js +16 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js +32 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js +246 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/package.json +1 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +41 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +429 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +971 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js +58 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +961 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +228 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +51 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +1137 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +92 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js +239 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +2065 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +87 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/package.json +165 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/index.mjs +349 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/package.json +44 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/watcher.wasm +0 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/wrapper.js +88 -0
- package/.output/server/node_modules/@unagents/messenger-broker/dist/index.mjs +12 -0
- package/.output/server/node_modules/@unagents/messenger-broker/dist/shared/messenger-broker.B8W77sqB.mjs +1177 -0
- package/.output/server/node_modules/@unagents/messenger-broker/package.json +37 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/index.mjs +9 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CfQVmH_Z.mjs +975 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CoDKzubj.mjs +1000 -0
- package/.output/server/node_modules/@unagents/messenger-client/package.json +37 -0
- package/.output/server/node_modules/@unagents/messenger-protocol/dist/index.mjs +103 -0
- package/.output/server/node_modules/@unagents/messenger-protocol/package.json +29 -0
- package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6802 -0
- package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +729 -0
- package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
- package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1933 -0
- package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +7085 -0
- package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1917 -0
- package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +951 -0
- package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
- package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +655 -0
- package/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/.output/server/node_modules/ajv/dist/ajv.js +50 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/code.js +156 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/index.js +697 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
- package/.output/server/node_modules/ajv/dist/compile/errors.js +123 -0
- package/.output/server/node_modules/ajv/dist/compile/index.js +242 -0
- package/.output/server/node_modules/ajv/dist/compile/names.js +28 -0
- package/.output/server/node_modules/ajv/dist/compile/ref_error.js +12 -0
- package/.output/server/node_modules/ajv/dist/compile/resolve.js +155 -0
- package/.output/server/node_modules/ajv/dist/compile/rules.js +26 -0
- package/.output/server/node_modules/ajv/dist/compile/util.js +178 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/index.js +520 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
- package/.output/server/node_modules/ajv/dist/core.js +618 -0
- package/.output/server/node_modules/ajv/dist/refs/data.json +13 -0
- package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
- package/.output/server/node_modules/ajv/dist/runtime/equal.js +7 -0
- package/.output/server/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
- package/.output/server/node_modules/ajv/dist/runtime/uri.js +6 -0
- package/.output/server/node_modules/ajv/dist/runtime/validation_error.js +11 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/code.js +131 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/pattern.js +33 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
- package/.output/server/node_modules/ajv/package.json +126 -0
- package/.output/server/node_modules/ajv-formats/dist/formats.js +208 -0
- package/.output/server/node_modules/ajv-formats/dist/index.js +37 -0
- package/.output/server/node_modules/ajv-formats/dist/limit.js +69 -0
- package/.output/server/node_modules/ajv-formats/package.json +74 -0
- package/.output/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/.output/server/node_modules/consola/dist/core.mjs +512 -0
- package/.output/server/node_modules/consola/dist/index.mjs +651 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/.output/server/node_modules/consola/dist/utils.mjs +54 -0
- package/.output/server/node_modules/consola/package.json +136 -0
- package/.output/server/node_modules/content-type/index.js +225 -0
- package/.output/server/node_modules/content-type/package.json +42 -0
- package/.output/server/node_modules/cookie-es/dist/index.mjs +268 -0
- package/.output/server/node_modules/cookie-es/package.json +46 -0
- package/.output/server/node_modules/crossws/dist/_chunks/_request.mjs +83 -0
- package/.output/server/node_modules/crossws/dist/_chunks/adapter.mjs +234 -0
- package/.output/server/node_modules/crossws/dist/_chunks/error.mjs +7 -0
- package/.output/server/node_modules/crossws/dist/_chunks/libs/ws.mjs +6 -0
- package/.output/server/node_modules/crossws/dist/_chunks/node.mjs +220 -0
- package/.output/server/node_modules/crossws/dist/_chunks/peer.mjs +208 -0
- package/.output/server/node_modules/crossws/dist/adapters/node.mjs +1 -0
- package/.output/server/node_modules/crossws/package.json +115 -0
- package/.output/server/node_modules/defu/dist/defu.mjs +69 -0
- package/.output/server/node_modules/defu/package.json +48 -0
- package/.output/server/node_modules/destr/dist/index.mjs +72 -0
- package/.output/server/node_modules/destr/package.json +47 -0
- package/.output/server/node_modules/devalue/index.js +17 -0
- package/.output/server/node_modules/devalue/package.json +39 -0
- package/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/.output/server/node_modules/devalue/src/operations.js +221 -0
- package/.output/server/node_modules/devalue/src/parse.js +279 -0
- package/.output/server/node_modules/devalue/src/stringify.js +433 -0
- package/.output/server/node_modules/devalue/src/uneval.js +698 -0
- package/.output/server/node_modules/devalue/src/utils.js +190 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/.output/server/node_modules/entities/package.json +120 -0
- package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/.output/server/node_modules/estree-walker/package.json +37 -0
- package/.output/server/node_modules/fast-deep-equal/index.js +46 -0
- package/.output/server/node_modules/fast-deep-equal/package.json +61 -0
- package/.output/server/node_modules/fast-uri/index.js +711 -0
- package/.output/server/node_modules/fast-uri/lib/schemes.js +272 -0
- package/.output/server/node_modules/fast-uri/lib/utils.js +799 -0
- package/.output/server/node_modules/fast-uri/package.json +68 -0
- package/.output/server/node_modules/get-port-please/dist/index.mjs +430 -0
- package/.output/server/node_modules/get-port-please/package.json +39 -0
- package/.output/server/node_modules/h3/dist/index.mjs +2498 -0
- package/.output/server/node_modules/h3/package.json +75 -0
- package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/.output/server/node_modules/hookable/package.json +54 -0
- package/.output/server/node_modules/http-shutdown/index.js +85 -0
- package/.output/server/node_modules/http-shutdown/package.json +32 -0
- package/.output/server/node_modules/iron-webcrypto/dist/index.js +298 -0
- package/.output/server/node_modules/iron-webcrypto/package.json +72 -0
- package/.output/server/node_modules/is-extglob/index.js +20 -0
- package/.output/server/node_modules/is-extglob/package.json +69 -0
- package/.output/server/node_modules/is-glob/index.js +150 -0
- package/.output/server/node_modules/is-glob/package.json +81 -0
- package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
- package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
- package/.output/server/node_modules/jiti/package.json +146 -0
- package/.output/server/node_modules/json-schema-traverse/index.js +93 -0
- package/.output/server/node_modules/json-schema-traverse/package.json +43 -0
- package/.output/server/node_modules/listhen/dist/chunks/xdg-open.mjs +1069 -0
- package/.output/server/node_modules/listhen/dist/index.mjs +19 -0
- package/.output/server/node_modules/listhen/dist/shared/listhen.tqe5I1Rl.mjs +1040 -0
- package/.output/server/node_modules/listhen/package.json +84 -0
- package/.output/server/node_modules/napi-wasm/index.mjs +1371 -0
- package/.output/server/node_modules/napi-wasm/package.json +33 -0
- package/.output/server/node_modules/node-forge/lib/aes.js +1091 -0
- package/.output/server/node_modules/node-forge/lib/aesCipherSuites.js +282 -0
- package/.output/server/node_modules/node-forge/lib/asn1-validator.js +91 -0
- package/.output/server/node_modules/node-forge/lib/asn1.js +1522 -0
- package/.output/server/node_modules/node-forge/lib/baseN.js +186 -0
- package/.output/server/node_modules/node-forge/lib/cipher.js +230 -0
- package/.output/server/node_modules/node-forge/lib/cipherModes.js +1027 -0
- package/.output/server/node_modules/node-forge/lib/des.js +496 -0
- package/.output/server/node_modules/node-forge/lib/ed25519.js +1091 -0
- package/.output/server/node_modules/node-forge/lib/forge.js +13 -0
- package/.output/server/node_modules/node-forge/lib/hmac.js +146 -0
- package/.output/server/node_modules/node-forge/lib/index.js +33 -0
- package/.output/server/node_modules/node-forge/lib/jsbn.js +1294 -0
- package/.output/server/node_modules/node-forge/lib/kem.js +168 -0
- package/.output/server/node_modules/node-forge/lib/log.js +319 -0
- package/.output/server/node_modules/node-forge/lib/md.all.js +13 -0
- package/.output/server/node_modules/node-forge/lib/md.js +11 -0
- package/.output/server/node_modules/node-forge/lib/md5.js +289 -0
- package/.output/server/node_modules/node-forge/lib/mgf.js +12 -0
- package/.output/server/node_modules/node-forge/lib/mgf1.js +57 -0
- package/.output/server/node_modules/node-forge/lib/oids.js +180 -0
- package/.output/server/node_modules/node-forge/lib/pbe.js +1029 -0
- package/.output/server/node_modules/node-forge/lib/pbkdf2.js +211 -0
- package/.output/server/node_modules/node-forge/lib/pem.js +413 -0
- package/.output/server/node_modules/node-forge/lib/pkcs1.js +276 -0
- package/.output/server/node_modules/node-forge/lib/pkcs12.js +1081 -0
- package/.output/server/node_modules/node-forge/lib/pkcs7.js +1260 -0
- package/.output/server/node_modules/node-forge/lib/pkcs7asn1.js +410 -0
- package/.output/server/node_modules/node-forge/lib/pki.js +102 -0
- package/.output/server/node_modules/node-forge/lib/prime.js +297 -0
- package/.output/server/node_modules/node-forge/lib/prng.js +419 -0
- package/.output/server/node_modules/node-forge/lib/pss.js +241 -0
- package/.output/server/node_modules/node-forge/lib/random.js +191 -0
- package/.output/server/node_modules/node-forge/lib/rc2.js +410 -0
- package/.output/server/node_modules/node-forge/lib/rsa.js +2014 -0
- package/.output/server/node_modules/node-forge/lib/sha1.js +319 -0
- package/.output/server/node_modules/node-forge/lib/sha256.js +327 -0
- package/.output/server/node_modules/node-forge/lib/sha512.js +561 -0
- package/.output/server/node_modules/node-forge/lib/ssh.js +236 -0
- package/.output/server/node_modules/node-forge/lib/tls.js +4334 -0
- package/.output/server/node_modules/node-forge/lib/util.js +2652 -0
- package/.output/server/node_modules/node-forge/lib/x509.js +3257 -0
- package/.output/server/node_modules/node-forge/package.json +123 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/index.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/package.json +63 -0
- package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
- package/.output/server/node_modules/nostics/dist/index.mjs +194 -0
- package/.output/server/node_modules/nostics/package.json +126 -0
- package/.output/server/node_modules/pathe/dist/index.mjs +19 -0
- package/.output/server/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/.output/server/node_modules/pathe/package.json +61 -0
- package/.output/server/node_modules/picomatch/index.js +17 -0
- package/.output/server/node_modules/picomatch/lib/constants.js +184 -0
- package/.output/server/node_modules/picomatch/lib/parse.js +1425 -0
- package/.output/server/node_modules/picomatch/lib/picomatch.js +361 -0
- package/.output/server/node_modules/picomatch/lib/scan.js +403 -0
- package/.output/server/node_modules/picomatch/lib/utils.js +72 -0
- package/.output/server/node_modules/picomatch/package.json +83 -0
- package/.output/server/node_modules/radix3/dist/index.mjs +262 -0
- package/.output/server/node_modules/radix3/package.json +52 -0
- package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/.output/server/node_modules/source-map-js/lib/quick-sort.js +141 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1236 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +446 -0
- package/.output/server/node_modules/source-map-js/lib/source-node.js +420 -0
- package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/.output/server/node_modules/source-map-js/package.json +71 -0
- package/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/.output/server/node_modules/std-env/dist/index.mjs +1 -0
- package/.output/server/node_modules/std-env/package.json +43 -0
- package/.output/server/node_modules/tinyclip/dist/index.js +143 -0
- package/.output/server/node_modules/tinyclip/package.json +48 -0
- package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/.output/server/node_modules/ufo/package.json +48 -0
- package/.output/server/node_modules/uncrypto/dist/crypto.node.mjs +16 -0
- package/.output/server/node_modules/uncrypto/package.json +60 -0
- package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
- package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
- package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
- package/.output/server/node_modules/unhead/dist/plugins.mjs +782 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C_7zwq8E.mjs +11 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CaeaMM5q.mjs +19 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D9VfQWNo.mjs +240 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DD4N5B4k.mjs +224 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DGl9jcjg.mjs +196 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DJuZwX9c.mjs +400 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DkxnqlHC.mjs +264 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DspMpm6y.mjs +48 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.o8j9utSy.mjs +208 -0
- package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
- package/.output/server/node_modules/unhead/dist/stream/server.mjs +446 -0
- package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
- package/.output/server/node_modules/unhead/package.json +179 -0
- package/.output/server/node_modules/untun/dist/_chunks/cloudflared.mjs +179 -0
- package/.output/server/node_modules/untun/dist/_chunks/log.mjs +27 -0
- package/.output/server/node_modules/untun/dist/index.mjs +47 -0
- package/.output/server/node_modules/untun/package.json +44 -0
- package/.output/server/node_modules/uqr/dist/index.mjs +739 -0
- package/.output/server/node_modules/uqr/package.json +69 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/.output/server/node_modules/vue/index.js +7 -0
- package/.output/server/node_modules/vue/index.mjs +1 -0
- package/.output/server/node_modules/vue/package.json +112 -0
- package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +687 -0
- package/.output/server/node_modules/vue-bundle-renderer/package.json +66 -0
- package/.output/server/node_modules/zod/index.js +7 -0
- package/.output/server/node_modules/zod/package.json +147 -0
- package/.output/server/node_modules/zod/v3/ZodError.js +143 -0
- package/.output/server/node_modules/zod/v3/errors.js +9 -0
- package/.output/server/node_modules/zod/v3/external.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/.output/server/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/.output/server/node_modules/zod/v3/helpers/util.js +133 -0
- package/.output/server/node_modules/zod/v3/index.js +4 -0
- package/.output/server/node_modules/zod/v3/locales/en.js +109 -0
- package/.output/server/node_modules/zod/v3/package.json +7 -0
- package/.output/server/node_modules/zod/v3/types.js +3697 -0
- package/.output/server/node_modules/zod/v4/classic/checks.js +1 -0
- package/.output/server/node_modules/zod/v4/classic/coerce.js +17 -0
- package/.output/server/node_modules/zod/v4/classic/compat.js +31 -0
- package/.output/server/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/classic/errors.js +57 -0
- package/.output/server/node_modules/zod/v4/classic/external.js +17 -0
- package/.output/server/node_modules/zod/v4/classic/from-json-schema.js +881 -0
- package/.output/server/node_modules/zod/v4/classic/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/classic/index.js +4 -0
- package/.output/server/node_modules/zod/v4/classic/iso.js +15 -0
- package/.output/server/node_modules/zod/v4/classic/package.json +7 -0
- package/.output/server/node_modules/zod/v4/classic/parse.js +16 -0
- package/.output/server/node_modules/zod/v4/classic/schemas.js +1535 -0
- package/.output/server/node_modules/zod/v4/core/api.js +1107 -0
- package/.output/server/node_modules/zod/v4/core/checks.js +516 -0
- package/.output/server/node_modules/zod/v4/core/compile.js +1866 -0
- package/.output/server/node_modules/zod/v4/core/core.js +141 -0
- package/.output/server/node_modules/zod/v4/core/doc.js +38 -0
- package/.output/server/node_modules/zod/v4/core/errors.js +267 -0
- package/.output/server/node_modules/zod/v4/core/index.js +19 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-generator.js +99 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-processors.js +843 -0
- package/.output/server/node_modules/zod/v4/core/json-schema.js +1 -0
- package/.output/server/node_modules/zod/v4/core/memoizer.js +311 -0
- package/.output/server/node_modules/zod/v4/core/package.json +7 -0
- package/.output/server/node_modules/zod/v4/core/parse.js +175 -0
- package/.output/server/node_modules/zod/v4/core/regexes.js +156 -0
- package/.output/server/node_modules/zod/v4/core/registries.js +51 -0
- package/.output/server/node_modules/zod/v4/core/schemas.js +2636 -0
- package/.output/server/node_modules/zod/v4/core/to-json-schema.js +651 -0
- package/.output/server/node_modules/zod/v4/core/util.js +873 -0
- package/.output/server/node_modules/zod/v4/core/versions.js +5 -0
- package/.output/server/node_modules/zod/v4/core/visit.js +169 -0
- package/.output/server/node_modules/zod/v4/index.js +4 -0
- package/.output/server/node_modules/zod/v4/locales/ar.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/az.js +110 -0
- package/.output/server/node_modules/zod/v4/locales/be.js +168 -0
- package/.output/server/node_modules/zod/v4/locales/bg.js +125 -0
- package/.output/server/node_modules/zod/v4/locales/bn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ca.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ckb.js +133 -0
- package/.output/server/node_modules/zod/v4/locales/cs.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/da.js +120 -0
- package/.output/server/node_modules/zod/v4/locales/de.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/el.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/en.js +125 -0
- package/.output/server/node_modules/zod/v4/locales/eo.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/es.js +136 -0
- package/.output/server/node_modules/zod/v4/locales/fa.js +119 -0
- package/.output/server/node_modules/zod/v4/locales/fi.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/fr-CA.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/fr.js +129 -0
- package/.output/server/node_modules/zod/v4/locales/gu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/he.js +221 -0
- package/.output/server/node_modules/zod/v4/locales/hi.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/hr.js +126 -0
- package/.output/server/node_modules/zod/v4/locales/hu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/hy.js +158 -0
- package/.output/server/node_modules/zod/v4/locales/id.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/index.js +63 -0
- package/.output/server/node_modules/zod/v4/locales/is.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/it.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ja.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ka.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/kh.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/km.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/kn.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/ko.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/lt.js +207 -0
- package/.output/server/node_modules/zod/v4/locales/mk.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/ms.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ne.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/nl.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/nn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/no.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ota.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/package.json +7 -0
- package/.output/server/node_modules/zod/v4/locales/pl.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/ps.js +119 -0
- package/.output/server/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/.output/server/node_modules/zod/v4/locales/pt.js +142 -0
- package/.output/server/node_modules/zod/v4/locales/ro.js +122 -0
- package/.output/server/node_modules/zod/v4/locales/ru.js +168 -0
- package/.output/server/node_modules/zod/v4/locales/sk.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/sl.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/sv.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/ta.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/tg.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/th.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/tk.js +107 -0
- package/.output/server/node_modules/zod/v4/locales/tr.js +110 -0
- package/.output/server/node_modules/zod/v4/locales/ua.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/uk.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ur.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/uz.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/vi.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/yo.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/zh-CN.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/zh-TW.js +112 -0
- package/.output/server/node_modules/zod/v4/mini/checks.js +1 -0
- package/.output/server/node_modules/zod/v4/mini/coerce.js +22 -0
- package/.output/server/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/mini/external.js +16 -0
- package/.output/server/node_modules/zod/v4/mini/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/mini/iso.js +34 -0
- package/.output/server/node_modules/zod/v4/mini/package.json +7 -0
- package/.output/server/node_modules/zod/v4/mini/parse.js +1 -0
- package/.output/server/node_modules/zod/v4/mini/schemas.js +1002 -0
- package/.output/server/node_modules/zod/v4/package.json +7 -0
- package/.output/server/node_modules/zod/v4-mini/index.js +3 -0
- package/.output/server/node_modules/zod/v4-mini/package.json +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/Options.js +46 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/Refs.js +22 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +14 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +8 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/index.js +40 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/package.json +1 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseDef.js +62 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseTypes.js +1 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +17 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +26 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +49 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +5 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +46 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +6 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +52 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +21 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +26 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +16 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +11 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +10 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +33 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +52 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +72 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +21 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +20 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +61 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +20 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +352 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +32 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +6 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +80 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/selectParser.js +105 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +87 -0
- package/.output/server/node_modules/zod-to-json-schema/package.json +85 -0
- package/.output/server/package.json +64 -0
- package/README.md +226 -23
- package/bin/bantou.mjs +33 -0
- package/package.json +18 -8
- package/protocol/PROTOCOL.md +26 -0
- package/protocol/protocol.json +92 -0
- package/dist/cap.js +0 -7
- package/dist/cli.js +0 -27
- package/dist/config.js +0 -23
- package/dist/daemon.js +0 -23
- package/dist/session.js +0 -7
- package/dist/workspace.js +0 -8
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
var QrCodeDataType = /* @__PURE__ */ ((QrCodeDataType2) => {
|
|
2
|
+
QrCodeDataType2[QrCodeDataType2["Border"] = -1] = "Border";
|
|
3
|
+
QrCodeDataType2[QrCodeDataType2["Data"] = 0] = "Data";
|
|
4
|
+
QrCodeDataType2[QrCodeDataType2["Function"] = 1] = "Function";
|
|
5
|
+
QrCodeDataType2[QrCodeDataType2["Position"] = 2] = "Position";
|
|
6
|
+
QrCodeDataType2[QrCodeDataType2["Timing"] = 3] = "Timing";
|
|
7
|
+
QrCodeDataType2[QrCodeDataType2["Alignment"] = 4] = "Alignment";
|
|
8
|
+
return QrCodeDataType2;
|
|
9
|
+
})(QrCodeDataType || {});
|
|
10
|
+
|
|
11
|
+
const LOW = [0, 1];
|
|
12
|
+
const MEDIUM = [1, 0];
|
|
13
|
+
const QUARTILE = [2, 3];
|
|
14
|
+
const HIGH = [3, 2];
|
|
15
|
+
const EccMap = {
|
|
16
|
+
L: LOW,
|
|
17
|
+
M: MEDIUM,
|
|
18
|
+
Q: QUARTILE,
|
|
19
|
+
H: HIGH
|
|
20
|
+
};
|
|
21
|
+
const NUMERIC_REGEX = /^\d*$/;
|
|
22
|
+
const ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+./:-]*$/;
|
|
23
|
+
const ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
24
|
+
const MIN_VERSION = 1;
|
|
25
|
+
const MAX_VERSION = 40;
|
|
26
|
+
const PENALTY_N1 = 3;
|
|
27
|
+
const PENALTY_N2 = 3;
|
|
28
|
+
const PENALTY_N3 = 40;
|
|
29
|
+
const PENALTY_N4 = 10;
|
|
30
|
+
const ECC_CODEWORDS_PER_BLOCK = [
|
|
31
|
+
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
32
|
+
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
33
|
+
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
34
|
+
// Low
|
|
35
|
+
[-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
|
|
36
|
+
// Medium
|
|
37
|
+
[-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
38
|
+
// Quartile
|
|
39
|
+
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
|
40
|
+
// High
|
|
41
|
+
];
|
|
42
|
+
const NUM_ERROR_CORRECTION_BLOCKS = [
|
|
43
|
+
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
44
|
+
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
45
|
+
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
46
|
+
// Low
|
|
47
|
+
[-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
|
48
|
+
// Medium
|
|
49
|
+
[-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
|
|
50
|
+
// Quartile
|
|
51
|
+
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
|
|
52
|
+
// High
|
|
53
|
+
];
|
|
54
|
+
class QrCode {
|
|
55
|
+
/* -- Constructor (low level) and fields -- */
|
|
56
|
+
// Creates a new QR Code with the given version number,
|
|
57
|
+
// error correction level, data codeword bytes, and mask number.
|
|
58
|
+
// This is a low-level API that most users should not use directly.
|
|
59
|
+
// A mid-level API is the encodeSegments() function.
|
|
60
|
+
constructor(version, ecc, dataCodewords, msk) {
|
|
61
|
+
this.version = version;
|
|
62
|
+
this.ecc = ecc;
|
|
63
|
+
if (version < MIN_VERSION || version > MAX_VERSION)
|
|
64
|
+
throw new RangeError("Version value out of range");
|
|
65
|
+
if (msk < -1 || msk > 7)
|
|
66
|
+
throw new RangeError("Mask value out of range");
|
|
67
|
+
this.size = version * 4 + 17;
|
|
68
|
+
const row = Array.from({ length: this.size }).fill(false);
|
|
69
|
+
for (let i = 0; i < this.size; i++) {
|
|
70
|
+
this.modules.push(row.slice());
|
|
71
|
+
this.types.push(row.map(() => 0));
|
|
72
|
+
}
|
|
73
|
+
this.drawFunctionPatterns();
|
|
74
|
+
const allCodewords = this.addEccAndInterleave(dataCodewords);
|
|
75
|
+
this.drawCodewords(allCodewords);
|
|
76
|
+
if (msk === -1) {
|
|
77
|
+
let minPenalty = 1e9;
|
|
78
|
+
for (let i = 0; i < 8; i++) {
|
|
79
|
+
this.applyMask(i);
|
|
80
|
+
this.drawFormatBits(i);
|
|
81
|
+
const penalty = this.getPenaltyScore();
|
|
82
|
+
if (penalty < minPenalty) {
|
|
83
|
+
msk = i;
|
|
84
|
+
minPenalty = penalty;
|
|
85
|
+
}
|
|
86
|
+
this.applyMask(i);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
this.mask = msk;
|
|
90
|
+
this.applyMask(msk);
|
|
91
|
+
this.drawFormatBits(msk);
|
|
92
|
+
}
|
|
93
|
+
/* -- Fields -- */
|
|
94
|
+
// The width and height of this QR Code, measured in modules, between
|
|
95
|
+
// 21 and 177 (inclusive). This is equal to version * 4 + 17.
|
|
96
|
+
size;
|
|
97
|
+
// The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive).
|
|
98
|
+
// Even if a QR Code is created with automatic masking requested (mask = -1),
|
|
99
|
+
// the resulting object still has a mask value between 0 and 7.
|
|
100
|
+
mask;
|
|
101
|
+
// The modules of this QR Code (false = light, true = dark).
|
|
102
|
+
// Immutable after constructor finishes. Accessed through getModule().
|
|
103
|
+
modules = [];
|
|
104
|
+
types = [];
|
|
105
|
+
/* -- Accessor methods -- */
|
|
106
|
+
// Returns the color of the module (pixel) at the given coordinates, which is false
|
|
107
|
+
// for light or true for dark. The top left corner has the coordinates (x=0, y=0).
|
|
108
|
+
// If the given coordinates are out of bounds, then false (light) is returned.
|
|
109
|
+
getModule(x, y) {
|
|
110
|
+
return x >= 0 && x < this.size && y >= 0 && y < this.size && this.modules[y][x];
|
|
111
|
+
}
|
|
112
|
+
/* -- Private helper methods for constructor: Drawing function modules -- */
|
|
113
|
+
// Reads this object's version field, and draws and marks all function modules.
|
|
114
|
+
drawFunctionPatterns() {
|
|
115
|
+
for (let i = 0; i < this.size; i++) {
|
|
116
|
+
this.setFunctionModule(6, i, i % 2 === 0, QrCodeDataType.Timing);
|
|
117
|
+
this.setFunctionModule(i, 6, i % 2 === 0, QrCodeDataType.Timing);
|
|
118
|
+
}
|
|
119
|
+
this.drawFinderPattern(3, 3);
|
|
120
|
+
this.drawFinderPattern(this.size - 4, 3);
|
|
121
|
+
this.drawFinderPattern(3, this.size - 4);
|
|
122
|
+
const alignPatPos = this.getAlignmentPatternPositions();
|
|
123
|
+
const numAlign = alignPatPos.length;
|
|
124
|
+
for (let i = 0; i < numAlign; i++) {
|
|
125
|
+
for (let j = 0; j < numAlign; j++) {
|
|
126
|
+
if (!(i === 0 && j === 0 || i === 0 && j === numAlign - 1 || i === numAlign - 1 && j === 0))
|
|
127
|
+
this.drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
this.drawFormatBits(0);
|
|
131
|
+
this.drawVersion();
|
|
132
|
+
}
|
|
133
|
+
// Draws two copies of the format bits (with its own error correction code)
|
|
134
|
+
// based on the given mask and this object's error correction level field.
|
|
135
|
+
drawFormatBits(mask) {
|
|
136
|
+
const data = this.ecc[1] << 3 | mask;
|
|
137
|
+
let rem = data;
|
|
138
|
+
for (let i = 0; i < 10; i++)
|
|
139
|
+
rem = rem << 1 ^ (rem >>> 9) * 1335;
|
|
140
|
+
const bits = (data << 10 | rem) ^ 21522;
|
|
141
|
+
for (let i = 0; i <= 5; i++)
|
|
142
|
+
this.setFunctionModule(8, i, getBit(bits, i));
|
|
143
|
+
this.setFunctionModule(8, 7, getBit(bits, 6));
|
|
144
|
+
this.setFunctionModule(8, 8, getBit(bits, 7));
|
|
145
|
+
this.setFunctionModule(7, 8, getBit(bits, 8));
|
|
146
|
+
for (let i = 9; i < 15; i++)
|
|
147
|
+
this.setFunctionModule(14 - i, 8, getBit(bits, i));
|
|
148
|
+
for (let i = 0; i < 8; i++)
|
|
149
|
+
this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i));
|
|
150
|
+
for (let i = 8; i < 15; i++)
|
|
151
|
+
this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i));
|
|
152
|
+
this.setFunctionModule(8, this.size - 8, true);
|
|
153
|
+
}
|
|
154
|
+
// Draws two copies of the version bits (with its own error correction code),
|
|
155
|
+
// based on this object's version field, iff 7 <= version <= 40.
|
|
156
|
+
drawVersion() {
|
|
157
|
+
if (this.version < 7)
|
|
158
|
+
return;
|
|
159
|
+
let rem = this.version;
|
|
160
|
+
for (let i = 0; i < 12; i++)
|
|
161
|
+
rem = rem << 1 ^ (rem >>> 11) * 7973;
|
|
162
|
+
const bits = this.version << 12 | rem;
|
|
163
|
+
for (let i = 0; i < 18; i++) {
|
|
164
|
+
const color = getBit(bits, i);
|
|
165
|
+
const a = this.size - 11 + i % 3;
|
|
166
|
+
const b = Math.floor(i / 3);
|
|
167
|
+
this.setFunctionModule(a, b, color);
|
|
168
|
+
this.setFunctionModule(b, a, color);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Draws a 9*9 finder pattern including the border separator,
|
|
172
|
+
// with the center module at (x, y). Modules can be out of bounds.
|
|
173
|
+
drawFinderPattern(x, y) {
|
|
174
|
+
for (let dy = -4; dy <= 4; dy++) {
|
|
175
|
+
for (let dx = -4; dx <= 4; dx++) {
|
|
176
|
+
const dist = Math.max(Math.abs(dx), Math.abs(dy));
|
|
177
|
+
const xx = x + dx;
|
|
178
|
+
const yy = y + dy;
|
|
179
|
+
if (xx >= 0 && xx < this.size && yy >= 0 && yy < this.size)
|
|
180
|
+
this.setFunctionModule(xx, yy, dist !== 2 && dist !== 4, QrCodeDataType.Position);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Draws a 5*5 alignment pattern, with the center module
|
|
185
|
+
// at (x, y). All modules must be in bounds.
|
|
186
|
+
drawAlignmentPattern(x, y) {
|
|
187
|
+
for (let dy = -2; dy <= 2; dy++) {
|
|
188
|
+
for (let dx = -2; dx <= 2; dx++) {
|
|
189
|
+
this.setFunctionModule(
|
|
190
|
+
x + dx,
|
|
191
|
+
y + dy,
|
|
192
|
+
Math.max(Math.abs(dx), Math.abs(dy)) !== 1,
|
|
193
|
+
QrCodeDataType.Alignment
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Sets the color of a module and marks it as a function module.
|
|
199
|
+
// Only used by the constructor. Coordinates must be in bounds.
|
|
200
|
+
setFunctionModule(x, y, isDark, type = QrCodeDataType.Function) {
|
|
201
|
+
this.modules[y][x] = isDark;
|
|
202
|
+
this.types[y][x] = type;
|
|
203
|
+
}
|
|
204
|
+
/* -- Private helper methods for constructor: Codewords and masking -- */
|
|
205
|
+
// Returns a new byte string representing the given data with the appropriate error correction
|
|
206
|
+
// codewords appended to it, based on this object's version and error correction level.
|
|
207
|
+
addEccAndInterleave(data) {
|
|
208
|
+
const ver = this.version;
|
|
209
|
+
const ecl = this.ecc;
|
|
210
|
+
if (data.length !== getNumDataCodewords(ver, ecl))
|
|
211
|
+
throw new RangeError("Invalid argument");
|
|
212
|
+
const numBlocks = NUM_ERROR_CORRECTION_BLOCKS[ecl[0]][ver];
|
|
213
|
+
const blockEccLen = ECC_CODEWORDS_PER_BLOCK[ecl[0]][ver];
|
|
214
|
+
const rawCodewords = Math.floor(getNumRawDataModules(ver) / 8);
|
|
215
|
+
const numShortBlocks = numBlocks - rawCodewords % numBlocks;
|
|
216
|
+
const shortBlockLen = Math.floor(rawCodewords / numBlocks);
|
|
217
|
+
const blocks = [];
|
|
218
|
+
const rsDiv = reedSolomonComputeDivisor(blockEccLen);
|
|
219
|
+
for (let i = 0, k = 0; i < numBlocks; i++) {
|
|
220
|
+
const dat = data.slice(k, k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1));
|
|
221
|
+
k += dat.length;
|
|
222
|
+
const ecc = reedSolomonComputeRemainder(dat, rsDiv);
|
|
223
|
+
if (i < numShortBlocks)
|
|
224
|
+
dat.push(0);
|
|
225
|
+
blocks.push(dat.concat(ecc));
|
|
226
|
+
}
|
|
227
|
+
const result = [];
|
|
228
|
+
for (let i = 0; i < blocks[0].length; i++) {
|
|
229
|
+
blocks.forEach((block, j) => {
|
|
230
|
+
if (i !== shortBlockLen - blockEccLen || j >= numShortBlocks)
|
|
231
|
+
result.push(block[i]);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
|
237
|
+
// data area of this QR Code. Function modules need to be marked off before this is called.
|
|
238
|
+
drawCodewords(data) {
|
|
239
|
+
if (data.length !== Math.floor(getNumRawDataModules(this.version) / 8))
|
|
240
|
+
throw new RangeError("Invalid argument");
|
|
241
|
+
let i = 0;
|
|
242
|
+
for (let right = this.size - 1; right >= 1; right -= 2) {
|
|
243
|
+
if (right === 6)
|
|
244
|
+
right = 5;
|
|
245
|
+
for (let vert = 0; vert < this.size; vert++) {
|
|
246
|
+
for (let j = 0; j < 2; j++) {
|
|
247
|
+
const x = right - j;
|
|
248
|
+
const upward = (right + 1 & 2) === 0;
|
|
249
|
+
const y = upward ? this.size - 1 - vert : vert;
|
|
250
|
+
if (!this.types[y][x] && i < data.length * 8) {
|
|
251
|
+
this.modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
|
|
252
|
+
i++;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// XORs the codeword modules in this QR Code with the given mask pattern.
|
|
259
|
+
// The function modules must be marked and the codeword bits must be drawn
|
|
260
|
+
// before masking. Due to the arithmetic of XOR, calling applyMask() with
|
|
261
|
+
// the same mask value a second time will undo the mask. A final well-formed
|
|
262
|
+
// QR Code needs exactly one (not zero, two, etc.) mask applied.
|
|
263
|
+
applyMask(mask) {
|
|
264
|
+
if (mask < 0 || mask > 7)
|
|
265
|
+
throw new RangeError("Mask value out of range");
|
|
266
|
+
for (let y = 0; y < this.size; y++) {
|
|
267
|
+
for (let x = 0; x < this.size; x++) {
|
|
268
|
+
let invert;
|
|
269
|
+
switch (mask) {
|
|
270
|
+
case 0:
|
|
271
|
+
invert = (x + y) % 2 === 0;
|
|
272
|
+
break;
|
|
273
|
+
case 1:
|
|
274
|
+
invert = y % 2 === 0;
|
|
275
|
+
break;
|
|
276
|
+
case 2:
|
|
277
|
+
invert = x % 3 === 0;
|
|
278
|
+
break;
|
|
279
|
+
case 3:
|
|
280
|
+
invert = (x + y) % 3 === 0;
|
|
281
|
+
break;
|
|
282
|
+
case 4:
|
|
283
|
+
invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;
|
|
284
|
+
break;
|
|
285
|
+
case 5:
|
|
286
|
+
invert = x * y % 2 + x * y % 3 === 0;
|
|
287
|
+
break;
|
|
288
|
+
case 6:
|
|
289
|
+
invert = (x * y % 2 + x * y % 3) % 2 === 0;
|
|
290
|
+
break;
|
|
291
|
+
case 7:
|
|
292
|
+
invert = ((x + y) % 2 + x * y % 3) % 2 === 0;
|
|
293
|
+
break;
|
|
294
|
+
default:
|
|
295
|
+
throw new Error("Unreachable");
|
|
296
|
+
}
|
|
297
|
+
if (!this.types[y][x] && invert)
|
|
298
|
+
this.modules[y][x] = !this.modules[y][x];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
|
303
|
+
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
|
|
304
|
+
getPenaltyScore() {
|
|
305
|
+
let result = 0;
|
|
306
|
+
for (let y = 0; y < this.size; y++) {
|
|
307
|
+
let runColor = false;
|
|
308
|
+
let runX = 0;
|
|
309
|
+
const runHistory = [0, 0, 0, 0, 0, 0, 0];
|
|
310
|
+
for (let x = 0; x < this.size; x++) {
|
|
311
|
+
if (this.modules[y][x] === runColor) {
|
|
312
|
+
runX++;
|
|
313
|
+
if (runX === 5)
|
|
314
|
+
result += PENALTY_N1;
|
|
315
|
+
else if (runX > 5)
|
|
316
|
+
result++;
|
|
317
|
+
} else {
|
|
318
|
+
this.finderPenaltyAddHistory(runX, runHistory);
|
|
319
|
+
if (!runColor)
|
|
320
|
+
result += this.finderPenaltyCountPatterns(runHistory) * PENALTY_N3;
|
|
321
|
+
runColor = this.modules[y][x];
|
|
322
|
+
runX = 1;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
result += this.finderPenaltyTerminateAndCount(runColor, runX, runHistory) * PENALTY_N3;
|
|
326
|
+
}
|
|
327
|
+
for (let x = 0; x < this.size; x++) {
|
|
328
|
+
let runColor = false;
|
|
329
|
+
let runY = 0;
|
|
330
|
+
const runHistory = [0, 0, 0, 0, 0, 0, 0];
|
|
331
|
+
for (let y = 0; y < this.size; y++) {
|
|
332
|
+
if (this.modules[y][x] === runColor) {
|
|
333
|
+
runY++;
|
|
334
|
+
if (runY === 5)
|
|
335
|
+
result += PENALTY_N1;
|
|
336
|
+
else if (runY > 5)
|
|
337
|
+
result++;
|
|
338
|
+
} else {
|
|
339
|
+
this.finderPenaltyAddHistory(runY, runHistory);
|
|
340
|
+
if (!runColor)
|
|
341
|
+
result += this.finderPenaltyCountPatterns(runHistory) * PENALTY_N3;
|
|
342
|
+
runColor = this.modules[y][x];
|
|
343
|
+
runY = 1;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
result += this.finderPenaltyTerminateAndCount(runColor, runY, runHistory) * PENALTY_N3;
|
|
347
|
+
}
|
|
348
|
+
for (let y = 0; y < this.size - 1; y++) {
|
|
349
|
+
for (let x = 0; x < this.size - 1; x++) {
|
|
350
|
+
const color = this.modules[y][x];
|
|
351
|
+
if (color === this.modules[y][x + 1] && color === this.modules[y + 1][x] && color === this.modules[y + 1][x + 1]) {
|
|
352
|
+
result += PENALTY_N2;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
let dark = 0;
|
|
357
|
+
for (const row of this.modules)
|
|
358
|
+
dark = row.reduce((sum, color) => sum + (color ? 1 : 0), dark);
|
|
359
|
+
const total = this.size * this.size;
|
|
360
|
+
const k = Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1;
|
|
361
|
+
result += k * PENALTY_N4;
|
|
362
|
+
return result;
|
|
363
|
+
}
|
|
364
|
+
/* -- Private helper functions -- */
|
|
365
|
+
// Returns an ascending list of positions of alignment patterns for this version number.
|
|
366
|
+
// Each position is in the range [0,177), and are used on both the x and y axes.
|
|
367
|
+
// This could be implemented as lookup table of 40 variable-length lists of integers.
|
|
368
|
+
getAlignmentPatternPositions() {
|
|
369
|
+
if (this.version === 1) {
|
|
370
|
+
return [];
|
|
371
|
+
} else {
|
|
372
|
+
const numAlign = Math.floor(this.version / 7) + 2;
|
|
373
|
+
const step = this.version === 32 ? 26 : Math.ceil((this.version * 4 + 4) / (numAlign * 2 - 2)) * 2;
|
|
374
|
+
const result = [6];
|
|
375
|
+
for (let pos = this.size - 7; result.length < numAlign; pos -= step)
|
|
376
|
+
result.splice(1, 0, pos);
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// Can only be called immediately after a light run is added, and
|
|
381
|
+
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
|
382
|
+
finderPenaltyCountPatterns(runHistory) {
|
|
383
|
+
const n = runHistory[1];
|
|
384
|
+
const core = n > 0 && runHistory[2] === n && runHistory[3] === n * 3 && runHistory[4] === n && runHistory[5] === n;
|
|
385
|
+
return (core && runHistory[0] >= n * 4 && runHistory[6] >= n ? 1 : 0) + (core && runHistory[6] >= n * 4 && runHistory[0] >= n ? 1 : 0);
|
|
386
|
+
}
|
|
387
|
+
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
|
|
388
|
+
finderPenaltyTerminateAndCount(currentRunColor, currentRunLength, runHistory) {
|
|
389
|
+
if (currentRunColor) {
|
|
390
|
+
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
|
391
|
+
currentRunLength = 0;
|
|
392
|
+
}
|
|
393
|
+
currentRunLength += this.size;
|
|
394
|
+
this.finderPenaltyAddHistory(currentRunLength, runHistory);
|
|
395
|
+
return this.finderPenaltyCountPatterns(runHistory);
|
|
396
|
+
}
|
|
397
|
+
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
|
398
|
+
finderPenaltyAddHistory(currentRunLength, runHistory) {
|
|
399
|
+
if (runHistory[0] === 0)
|
|
400
|
+
currentRunLength += this.size;
|
|
401
|
+
runHistory.pop();
|
|
402
|
+
runHistory.unshift(currentRunLength);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function appendBits(val, len, bb) {
|
|
406
|
+
if (len < 0 || len > 31 || val >>> len !== 0)
|
|
407
|
+
throw new RangeError("Value out of range");
|
|
408
|
+
for (let i = len - 1; i >= 0; i--)
|
|
409
|
+
bb.push(val >>> i & 1);
|
|
410
|
+
}
|
|
411
|
+
function getBit(x, i) {
|
|
412
|
+
return (x >>> i & 1) !== 0;
|
|
413
|
+
}
|
|
414
|
+
class QrSegment {
|
|
415
|
+
// Creates a new QR Code segment with the given attributes and data.
|
|
416
|
+
// The character count (numChars) must agree with the mode and the bit buffer length,
|
|
417
|
+
// but the constraint isn't checked. The given bit buffer is cloned and stored.
|
|
418
|
+
constructor(mode, numChars, bitData) {
|
|
419
|
+
this.mode = mode;
|
|
420
|
+
this.numChars = numChars;
|
|
421
|
+
this.bitData = bitData;
|
|
422
|
+
if (numChars < 0)
|
|
423
|
+
throw new RangeError("Invalid argument");
|
|
424
|
+
this.bitData = bitData.slice();
|
|
425
|
+
}
|
|
426
|
+
/* -- Methods -- */
|
|
427
|
+
// Returns a new copy of the data bits of this segment.
|
|
428
|
+
getData() {
|
|
429
|
+
return this.bitData.slice();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const MODE_NUMERIC = [1, 10, 12, 14];
|
|
433
|
+
const MODE_ALPHANUMERIC = [2, 9, 11, 13];
|
|
434
|
+
const MODE_BYTE = [4, 8, 16, 16];
|
|
435
|
+
function numCharCountBits(mode, ver) {
|
|
436
|
+
return mode[Math.floor((ver + 7) / 17) + 1];
|
|
437
|
+
}
|
|
438
|
+
function makeBytes(data) {
|
|
439
|
+
const bb = [];
|
|
440
|
+
for (const b of data)
|
|
441
|
+
appendBits(b, 8, bb);
|
|
442
|
+
return new QrSegment(MODE_BYTE, data.length, bb);
|
|
443
|
+
}
|
|
444
|
+
function makeNumeric(digits) {
|
|
445
|
+
if (!isNumeric(digits))
|
|
446
|
+
throw new RangeError("String contains non-numeric characters");
|
|
447
|
+
const bb = [];
|
|
448
|
+
for (let i = 0; i < digits.length; ) {
|
|
449
|
+
const n = Math.min(digits.length - i, 3);
|
|
450
|
+
appendBits(Number.parseInt(digits.substring(i, i + n), 10), n * 3 + 1, bb);
|
|
451
|
+
i += n;
|
|
452
|
+
}
|
|
453
|
+
return new QrSegment(MODE_NUMERIC, digits.length, bb);
|
|
454
|
+
}
|
|
455
|
+
function makeAlphanumeric(text) {
|
|
456
|
+
if (!isAlphanumeric(text))
|
|
457
|
+
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
458
|
+
const bb = [];
|
|
459
|
+
let i;
|
|
460
|
+
for (i = 0; i + 2 <= text.length; i += 2) {
|
|
461
|
+
let temp = ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)) * 45;
|
|
462
|
+
temp += ALPHANUMERIC_CHARSET.indexOf(text.charAt(i + 1));
|
|
463
|
+
appendBits(temp, 11, bb);
|
|
464
|
+
}
|
|
465
|
+
if (i < text.length)
|
|
466
|
+
appendBits(ALPHANUMERIC_CHARSET.indexOf(text.charAt(i)), 6, bb);
|
|
467
|
+
return new QrSegment(MODE_ALPHANUMERIC, text.length, bb);
|
|
468
|
+
}
|
|
469
|
+
function makeSegments(text) {
|
|
470
|
+
if (text === "")
|
|
471
|
+
return [];
|
|
472
|
+
else if (isNumeric(text))
|
|
473
|
+
return [makeNumeric(text)];
|
|
474
|
+
else if (isAlphanumeric(text))
|
|
475
|
+
return [makeAlphanumeric(text)];
|
|
476
|
+
else
|
|
477
|
+
return [makeBytes(toUtf8ByteArray(text))];
|
|
478
|
+
}
|
|
479
|
+
function isNumeric(text) {
|
|
480
|
+
return NUMERIC_REGEX.test(text);
|
|
481
|
+
}
|
|
482
|
+
function isAlphanumeric(text) {
|
|
483
|
+
return ALPHANUMERIC_REGEX.test(text);
|
|
484
|
+
}
|
|
485
|
+
function getTotalBits(segs, version) {
|
|
486
|
+
let result = 0;
|
|
487
|
+
for (const seg of segs) {
|
|
488
|
+
const ccbits = numCharCountBits(seg.mode, version);
|
|
489
|
+
if (seg.numChars >= 1 << ccbits)
|
|
490
|
+
return Number.POSITIVE_INFINITY;
|
|
491
|
+
result += 4 + ccbits + seg.bitData.length;
|
|
492
|
+
}
|
|
493
|
+
return result;
|
|
494
|
+
}
|
|
495
|
+
function toUtf8ByteArray(str) {
|
|
496
|
+
str = encodeURI(str);
|
|
497
|
+
const result = [];
|
|
498
|
+
for (let i = 0; i < str.length; i++) {
|
|
499
|
+
if (str.charAt(i) !== "%") {
|
|
500
|
+
result.push(str.charCodeAt(i));
|
|
501
|
+
} else {
|
|
502
|
+
result.push(Number.parseInt(str.substring(i + 1, i + 3), 16));
|
|
503
|
+
i += 2;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
function getNumRawDataModules(ver) {
|
|
509
|
+
if (ver < MIN_VERSION || ver > MAX_VERSION)
|
|
510
|
+
throw new RangeError("Version number out of range");
|
|
511
|
+
let result = (16 * ver + 128) * ver + 64;
|
|
512
|
+
if (ver >= 2) {
|
|
513
|
+
const numAlign = Math.floor(ver / 7) + 2;
|
|
514
|
+
result -= (25 * numAlign - 10) * numAlign - 55;
|
|
515
|
+
if (ver >= 7)
|
|
516
|
+
result -= 36;
|
|
517
|
+
}
|
|
518
|
+
return result;
|
|
519
|
+
}
|
|
520
|
+
function getNumDataCodewords(ver, ecl) {
|
|
521
|
+
return Math.floor(getNumRawDataModules(ver) / 8) - ECC_CODEWORDS_PER_BLOCK[ecl[0]][ver] * NUM_ERROR_CORRECTION_BLOCKS[ecl[0]][ver];
|
|
522
|
+
}
|
|
523
|
+
function reedSolomonComputeDivisor(degree) {
|
|
524
|
+
if (degree < 1 || degree > 255)
|
|
525
|
+
throw new RangeError("Degree out of range");
|
|
526
|
+
const result = [];
|
|
527
|
+
for (let i = 0; i < degree - 1; i++)
|
|
528
|
+
result.push(0);
|
|
529
|
+
result.push(1);
|
|
530
|
+
let root = 1;
|
|
531
|
+
for (let i = 0; i < degree; i++) {
|
|
532
|
+
for (let j = 0; j < result.length; j++) {
|
|
533
|
+
result[j] = reedSolomonMultiply(result[j], root);
|
|
534
|
+
if (j + 1 < result.length)
|
|
535
|
+
result[j] ^= result[j + 1];
|
|
536
|
+
}
|
|
537
|
+
root = reedSolomonMultiply(root, 2);
|
|
538
|
+
}
|
|
539
|
+
return result;
|
|
540
|
+
}
|
|
541
|
+
function reedSolomonComputeRemainder(data, divisor) {
|
|
542
|
+
const result = divisor.map((_) => 0);
|
|
543
|
+
for (const b of data) {
|
|
544
|
+
const factor = b ^ result.shift();
|
|
545
|
+
result.push(0);
|
|
546
|
+
divisor.forEach((coef, i) => result[i] ^= reedSolomonMultiply(coef, factor));
|
|
547
|
+
}
|
|
548
|
+
return result;
|
|
549
|
+
}
|
|
550
|
+
function reedSolomonMultiply(x, y) {
|
|
551
|
+
if (x >>> 8 !== 0 || y >>> 8 !== 0)
|
|
552
|
+
throw new RangeError("Byte out of range");
|
|
553
|
+
let z = 0;
|
|
554
|
+
for (let i = 7; i >= 0; i--) {
|
|
555
|
+
z = z << 1 ^ (z >>> 7) * 285;
|
|
556
|
+
z ^= (y >>> i & 1) * x;
|
|
557
|
+
}
|
|
558
|
+
return z;
|
|
559
|
+
}
|
|
560
|
+
function encodeSegments(segs, ecl, minVersion = 1, maxVersion = 40, mask = -1, boostEcl = true) {
|
|
561
|
+
if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7) {
|
|
562
|
+
throw new RangeError("Invalid value");
|
|
563
|
+
}
|
|
564
|
+
let version;
|
|
565
|
+
let dataUsedBits;
|
|
566
|
+
for (version = minVersion; ; version++) {
|
|
567
|
+
const dataCapacityBits2 = getNumDataCodewords(version, ecl) * 8;
|
|
568
|
+
const usedBits = getTotalBits(segs, version);
|
|
569
|
+
if (usedBits <= dataCapacityBits2) {
|
|
570
|
+
dataUsedBits = usedBits;
|
|
571
|
+
break;
|
|
572
|
+
}
|
|
573
|
+
if (version >= maxVersion)
|
|
574
|
+
throw new RangeError("Data too long");
|
|
575
|
+
}
|
|
576
|
+
for (const newEcl of [MEDIUM, QUARTILE, HIGH]) {
|
|
577
|
+
if (boostEcl && dataUsedBits <= getNumDataCodewords(version, newEcl) * 8)
|
|
578
|
+
ecl = newEcl;
|
|
579
|
+
}
|
|
580
|
+
const bb = [];
|
|
581
|
+
for (const seg of segs) {
|
|
582
|
+
appendBits(seg.mode[0], 4, bb);
|
|
583
|
+
appendBits(seg.numChars, numCharCountBits(seg.mode, version), bb);
|
|
584
|
+
for (const b of seg.getData())
|
|
585
|
+
bb.push(b);
|
|
586
|
+
}
|
|
587
|
+
const dataCapacityBits = getNumDataCodewords(version, ecl) * 8;
|
|
588
|
+
appendBits(0, Math.min(4, dataCapacityBits - bb.length), bb);
|
|
589
|
+
appendBits(0, (8 - bb.length % 8) % 8, bb);
|
|
590
|
+
for (let padByte = 236; bb.length < dataCapacityBits; padByte ^= 236 ^ 17)
|
|
591
|
+
appendBits(padByte, 8, bb);
|
|
592
|
+
const dataCodewords = Array.from({ length: Math.ceil(bb.length / 8) }, () => 0);
|
|
593
|
+
bb.forEach((b, i) => dataCodewords[i >>> 3] |= b << 7 - (i & 7));
|
|
594
|
+
return new QrCode(version, ecl, dataCodewords, mask);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function encode(data, options) {
|
|
598
|
+
const {
|
|
599
|
+
ecc = "L",
|
|
600
|
+
boostEcc = false,
|
|
601
|
+
minVersion = 1,
|
|
602
|
+
maxVersion = 40,
|
|
603
|
+
maskPattern = -1,
|
|
604
|
+
border = 1
|
|
605
|
+
} = options || {};
|
|
606
|
+
const segment = typeof data === "string" ? makeSegments(data) : Array.isArray(data) ? [makeBytes(data)] : void 0;
|
|
607
|
+
if (!segment)
|
|
608
|
+
throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof data}`);
|
|
609
|
+
const qr = encodeSegments(
|
|
610
|
+
segment,
|
|
611
|
+
EccMap[ecc],
|
|
612
|
+
minVersion,
|
|
613
|
+
maxVersion,
|
|
614
|
+
maskPattern,
|
|
615
|
+
boostEcc
|
|
616
|
+
);
|
|
617
|
+
const result = addBorder({
|
|
618
|
+
version: qr.version,
|
|
619
|
+
maskPattern: qr.mask,
|
|
620
|
+
size: qr.size,
|
|
621
|
+
data: qr.modules,
|
|
622
|
+
types: qr.types
|
|
623
|
+
}, border);
|
|
624
|
+
if (options?.invert)
|
|
625
|
+
result.data = result.data.map((row) => row.map((mod) => !mod));
|
|
626
|
+
options?.onEncoded?.(result);
|
|
627
|
+
return result;
|
|
628
|
+
}
|
|
629
|
+
function addBorder(input, border = 1) {
|
|
630
|
+
if (!border)
|
|
631
|
+
return input;
|
|
632
|
+
const { size } = input;
|
|
633
|
+
const newSize = size + border * 2;
|
|
634
|
+
input.size = newSize;
|
|
635
|
+
input.data.forEach((row) => {
|
|
636
|
+
for (let i = 0; i < border; i++) {
|
|
637
|
+
row.unshift(false);
|
|
638
|
+
row.push(false);
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
for (let i = 0; i < border; i++) {
|
|
642
|
+
input.data.unshift(Array.from({ length: newSize }, (_) => false));
|
|
643
|
+
input.data.push(Array.from({ length: newSize }, (_) => false));
|
|
644
|
+
}
|
|
645
|
+
const b = QrCodeDataType.Border;
|
|
646
|
+
input.types.forEach((row) => {
|
|
647
|
+
for (let i = 0; i < border; i++) {
|
|
648
|
+
row.unshift(b);
|
|
649
|
+
row.push(b);
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
for (let i = 0; i < border; i++) {
|
|
653
|
+
input.types.unshift(Array.from({ length: newSize }, (_) => b));
|
|
654
|
+
input.types.push(Array.from({ length: newSize }, (_) => b));
|
|
655
|
+
}
|
|
656
|
+
return input;
|
|
657
|
+
}
|
|
658
|
+
function getDataAt(data, x, y, defaults = false) {
|
|
659
|
+
if (x < 0 || y < 0 || x >= data.length || y >= data.length)
|
|
660
|
+
return defaults;
|
|
661
|
+
return data[y][x];
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function renderUnicode(data, options = {}) {
|
|
665
|
+
const {
|
|
666
|
+
whiteChar = "\u2588",
|
|
667
|
+
blackChar = "\u2591"
|
|
668
|
+
} = options;
|
|
669
|
+
const result = encode(data, options);
|
|
670
|
+
return result.data.map((row) => {
|
|
671
|
+
return row.map((mod) => mod ? blackChar : whiteChar).join("");
|
|
672
|
+
}).join("\n");
|
|
673
|
+
}
|
|
674
|
+
function renderANSI(data, options = {}) {
|
|
675
|
+
return renderUnicode(data, {
|
|
676
|
+
...options,
|
|
677
|
+
blackChar: "\x1B[40m\u3000\x1B[0m",
|
|
678
|
+
whiteChar: "\x1B[47m\u3000\x1B[0m"
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
function renderUnicodeCompact(data, options = {}) {
|
|
682
|
+
const palette = {
|
|
683
|
+
WHITE_ALL: "\u2588",
|
|
684
|
+
WHITE_BLACK: "\u2580",
|
|
685
|
+
BLACK_WHITE: "\u2584",
|
|
686
|
+
BLACK_ALL: " "
|
|
687
|
+
};
|
|
688
|
+
const result = encode(data, options);
|
|
689
|
+
const WHITE = false;
|
|
690
|
+
const BLACK = true;
|
|
691
|
+
const at = (x, y) => getDataAt(result.data, x, y, true);
|
|
692
|
+
const lines = [];
|
|
693
|
+
let line = "";
|
|
694
|
+
for (let row = 0; row < result.size; row += 2) {
|
|
695
|
+
for (let col = 0; col < result.size; col++) {
|
|
696
|
+
if (at(col, row) === WHITE && at(col, row + 1) === WHITE)
|
|
697
|
+
line += palette.WHITE_ALL;
|
|
698
|
+
else if (at(col, row) === WHITE && at(col, row + 1) === BLACK)
|
|
699
|
+
line += palette.WHITE_BLACK;
|
|
700
|
+
else if (at(col, row) === BLACK && at(col, row + 1) === WHITE)
|
|
701
|
+
line += palette.BLACK_WHITE;
|
|
702
|
+
else
|
|
703
|
+
line += palette.BLACK_ALL;
|
|
704
|
+
}
|
|
705
|
+
lines.push(line);
|
|
706
|
+
line = "";
|
|
707
|
+
}
|
|
708
|
+
return lines.join("\n");
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function escapeAttr(value) {
|
|
712
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
713
|
+
}
|
|
714
|
+
function renderSVG(data, options = {}) {
|
|
715
|
+
const result = encode(data, options);
|
|
716
|
+
const {
|
|
717
|
+
pixelSize = 10,
|
|
718
|
+
whiteColor = "white",
|
|
719
|
+
blackColor = "black"
|
|
720
|
+
} = options;
|
|
721
|
+
const height = result.size * pixelSize;
|
|
722
|
+
const width = result.size * pixelSize;
|
|
723
|
+
let svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}">`;
|
|
724
|
+
const paths = [];
|
|
725
|
+
for (let row = 0; row < result.size; row++) {
|
|
726
|
+
for (let col = 0; col < result.size; col++) {
|
|
727
|
+
const x = col * pixelSize;
|
|
728
|
+
const y = row * pixelSize;
|
|
729
|
+
if (result.data[row][col])
|
|
730
|
+
paths.push(`M${x},${y}h${pixelSize}v${pixelSize}h-${pixelSize}z`);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
svg += `<rect fill="${escapeAttr(whiteColor)}" width="${width}" height="${height}"/>`;
|
|
734
|
+
svg += `<path fill="${escapeAttr(blackColor)}" d="${paths.join("")}"/>`;
|
|
735
|
+
svg += "</svg>";
|
|
736
|
+
return svg;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export { QrCodeDataType, encode, renderANSI, renderSVG, renderUnicode, renderUnicodeCompact };
|