@awacloud/fw 0.1.0 → 1.0.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/CHANGELOG.md +125 -0
- package/NOTICE +8 -0
- package/README.md +163 -31
- package/dist/build/fw.core.pure.meta.json +6 -6
- package/dist/build/fw.core.pure.min.js +15 -12
- package/dist/build/fw.full.pure.meta.json +13 -7
- package/dist/build/fw.full.pure.min.js +45 -42
- package/dist/build/fw.minimal.pure.meta.json +6 -6
- package/dist/build/fw.minimal.pure.min.js +16 -13
- package/dist/build/fw.pack.compress-heavy.pure.meta.json +6 -6
- package/dist/build/fw.pack.compress-heavy.pure.min.js +3 -3
- package/dist/build/fw.pack.crypto-advanced.pure.meta.json +6 -6
- package/dist/build/fw.pack.crypto-advanced.pure.min.js +1 -1
- package/dist/build/fw.pack.crypto-basic.pure.meta.json +6 -6
- package/dist/build/fw.pack.crypto-basic.pure.min.js +1 -1
- package/dist/build/fw.pack.crypto-identity.pure.meta.json +7 -6
- package/dist/build/fw.pack.crypto-identity.pure.min.js +4 -4
- package/dist/build/fw.pwa.pure.meta.json +7 -6
- package/dist/build/fw.pwa.pure.min.js +38 -35
- package/dist/build/fw.site-interactive.pure.meta.json +6 -6
- package/dist/build/fw.site-interactive.pure.min.js +37 -34
- package/dist/build/fw.site.pure.meta.json +6 -6
- package/dist/build/fw.site.pure.min.js +24 -21
- package/dist/build/fw.spa.pure.meta.json +8 -7
- package/dist/build/fw.spa.pure.min.js +41 -38
- package/dist/build/sanity-base-classic.min.js +1 -1
- package/dist/build/sanity.min.js +1 -1
- package/dist/types/core/internal.d.ts +29 -0
- package/dist/types/core/internal.d.ts.map +1 -0
- package/dist/types/core/logger.d.ts +23 -4
- package/dist/types/core/logger.d.ts.map +1 -1
- package/dist/types/core/modules.d.ts +374 -61
- package/dist/types/core/modules.d.ts.map +1 -1
- package/dist/types/core/runtime.d.ts +10 -6
- package/dist/types/core/runtime.d.ts.map +1 -1
- package/dist/types/core/worker-helper.d.ts +35 -0
- package/dist/types/core/worker-helper.d.ts.map +1 -1
- package/dist/types/crypto/cipher/aes.d.ts +1 -7
- package/dist/types/crypto/cipher/aes.d.ts.map +1 -1
- package/dist/types/crypto/cipher/chacha20.d.ts +0 -10
- package/dist/types/crypto/cipher/chacha20.d.ts.map +1 -1
- package/dist/types/crypto/hash/argon2.d.ts +0 -15
- package/dist/types/crypto/hash/argon2.d.ts.map +1 -1
- package/dist/types/crypto/hash/blake2b.d.ts.map +1 -1
- package/dist/types/crypto/hash/hmac.d.ts.map +1 -1
- package/dist/types/crypto/hash/pbkdf2.d.ts.map +1 -1
- package/dist/types/crypto/hash/poly1305.d.ts.map +1 -1
- package/dist/types/crypto/hash/sha224.d.ts +1 -1
- package/dist/types/crypto/hash/sha256.d.ts +4 -13
- package/dist/types/crypto/hash/sha256.d.ts.map +1 -1
- package/dist/types/crypto/hash/sha3.d.ts.map +1 -1
- package/dist/types/crypto/hash/sha384.d.ts +1 -1
- package/dist/types/crypto/hash/sha512.d.ts +4 -13
- package/dist/types/crypto/hash/sha512.d.ts.map +1 -1
- package/dist/types/crypto/mode/cmac.d.ts +0 -6
- package/dist/types/crypto/mode/cmac.d.ts.map +1 -1
- package/dist/types/crypto/mode/ctr.d.ts +0 -6
- package/dist/types/crypto/mode/ctr.d.ts.map +1 -1
- package/dist/types/crypto/mode/gcm.d.ts +0 -9
- package/dist/types/crypto/mode/gcm.d.ts.map +1 -1
- package/dist/types/crypto/pkc/ecc.d.ts +0 -1
- package/dist/types/crypto/pkc/ecc.d.ts.map +1 -1
- package/dist/types/crypto/pkc/ed25519.d.ts +4 -25
- package/dist/types/crypto/pkc/ed25519.d.ts.map +1 -1
- package/dist/types/crypto/pkc/hybridSign.d.ts +25 -5
- package/dist/types/crypto/pkc/hybridSign.d.ts.map +1 -1
- package/dist/types/crypto/pkc/ml_dsa.d.ts +6 -26
- package/dist/types/crypto/pkc/ml_dsa.d.ts.map +1 -1
- package/dist/types/crypto/pkc/ml_kem.d.ts +0 -43
- package/dist/types/crypto/pkc/ml_kem.d.ts.map +1 -1
- package/dist/types/crypto/pkc/rsa.d.ts +0 -24
- package/dist/types/crypto/pkc/rsa.d.ts.map +1 -1
- package/dist/types/crypto/pkc/slh_dsa.d.ts +6 -16
- package/dist/types/crypto/pkc/slh_dsa.d.ts.map +1 -1
- package/dist/types/crypto/pkc/x25519.d.ts +0 -6
- package/dist/types/crypto/pkc/x25519.d.ts.map +1 -1
- package/dist/types/crypto/utils/bitArray.d.ts +0 -8
- package/dist/types/crypto/utils/bitArray.d.ts.map +1 -1
- package/dist/types/crypto/utils/jws.d.ts +6 -14
- package/dist/types/crypto/utils/jws.d.ts.map +1 -1
- package/dist/types/crypto/utils/keyformat.d.ts +52 -0
- package/dist/types/crypto/utils/keyformat.d.ts.map +1 -1
- package/dist/types/crypto/utils/random.d.ts +1 -10
- package/dist/types/crypto/utils/random.d.ts.map +1 -1
- package/dist/types/crypto/utils/rsaKeygen.d.ts +0 -10
- package/dist/types/crypto/utils/rsaKeygen.d.ts.map +1 -1
- package/dist/types/crypto/utils/uuid.d.ts.map +1 -1
- package/dist/types/crypto/utils/x509.d.ts +397 -0
- package/dist/types/crypto/utils/x509.d.ts.map +1 -0
- package/dist/types/crypto/wasm/argon2.d.ts +2 -1
- package/dist/types/crypto/wasm/argon2.d.ts.map +1 -1
- package/dist/types/crypto/wasm/pbkdf2.d.ts +2 -2
- package/dist/types/crypto/wasm/pbkdf2.d.ts.map +1 -1
- package/dist/types/crypto/wasm/rsa.d.ts.map +1 -1
- package/dist/types/crypto/wasm/runtime.d.ts +13 -0
- package/dist/types/crypto/wasm/runtime.d.ts.map +1 -1
- package/dist/types/crypto/webcrypto/aes.d.ts.map +1 -1
- package/dist/types/crypto/webcrypto/aeskw.d.ts.map +1 -1
- package/dist/types/crypto/webcrypto/digest.d.ts +0 -4
- package/dist/types/crypto/webcrypto/digest.d.ts.map +1 -1
- package/dist/types/crypto/webcrypto/rsa.d.ts.map +1 -1
- package/dist/types/dom/fs/fileIntake.d.ts +59 -0
- package/dist/types/dom/fs/fileIntake.d.ts.map +1 -0
- package/dist/types/dom/fs/fsAccess.d.ts.map +1 -1
- package/dist/types/dom/query/dnd.d.ts.map +1 -1
- package/dist/types/dom/query/sound.d.ts +89 -0
- package/dist/types/dom/query/sound.d.ts.map +1 -0
- package/dist/types/dom/rendering/chart.d.ts.map +1 -1
- package/dist/types/dom/rendering/component.d.ts +9 -3
- package/dist/types/dom/rendering/component.d.ts.map +1 -1
- package/dist/types/dom/rendering/parser.d.ts +39 -0
- package/dist/types/dom/rendering/parser.d.ts.map +1 -1
- package/dist/types/dom/rendering/render.d.ts.map +1 -1
- package/dist/types/dom/rendering/sanitize.d.ts +4 -0
- package/dist/types/dom/rendering/sanitize.d.ts.map +1 -1
- package/dist/types/dom/rendering/secPolicy.d.ts.map +1 -1
- package/dist/types/dom/rendering/styleSheet.d.ts +74 -0
- package/dist/types/dom/rendering/styleSheet.d.ts.map +1 -0
- package/dist/types/dom/rendering/template.d.ts +9 -3
- package/dist/types/dom/rendering/template.d.ts.map +1 -1
- package/dist/types/dom/rendering/themeTokens.d.ts +9 -3
- package/dist/types/dom/rendering/themeTokens.d.ts.map +1 -1
- package/dist/types/dom/rendering/uiSession-core.d.ts +9 -3
- package/dist/types/dom/rendering/uiSession-core.d.ts.map +1 -1
- package/dist/types/dom/rendering/uiSession-list.d.ts +9 -3
- package/dist/types/dom/rendering/uiSession-list.d.ts.map +1 -1
- package/dist/types/dom/rendering/uiSession.d.ts +18 -6
- package/dist/types/dom/rendering/uiSession.d.ts.map +1 -1
- package/dist/types/dom/sw/installPrompt.d.ts +89 -0
- package/dist/types/dom/sw/installPrompt.d.ts.map +1 -0
- package/dist/types/dom/sw/precache.d.ts +149 -0
- package/dist/types/dom/sw/precache.d.ts.map +1 -0
- package/dist/types/dom/sw/swUpdate.d.ts +129 -0
- package/dist/types/dom/sw/swUpdate.d.ts.map +1 -0
- package/dist/types/dom/utils/clipboard.d.ts +8 -0
- package/dist/types/dom/utils/clipboard.d.ts.map +1 -1
- package/dist/types/dom/utils/keybindings.d.ts.map +1 -1
- package/dist/types/dom/utils/route.d.ts.map +1 -1
- package/dist/types/dom/utils/ua.d.ts +2 -2
- package/dist/types/dom/utils/ua.d.ts.map +1 -1
- package/dist/types/io/calc/crc32.d.ts.map +1 -1
- package/dist/types/io/codec/b64.d.ts +24 -0
- package/dist/types/io/codec/b64.d.ts.map +1 -1
- package/dist/types/io/codec/cbor.d.ts +1 -0
- package/dist/types/io/codec/cbor.d.ts.map +1 -1
- package/dist/types/io/codec/hex.d.ts.map +1 -1
- package/dist/types/io/codec/msgpack.d.ts +1 -0
- package/dist/types/io/codec/msgpack.d.ts.map +1 -1
- package/dist/types/io/codec/url.d.ts +3 -1
- package/dist/types/io/codec/url.d.ts.map +1 -1
- package/dist/types/io/codec/utf8.d.ts.map +1 -1
- package/dist/types/io/compress/bitstream.d.ts +1 -1
- package/dist/types/io/compress/brotli.d.ts +0 -1
- package/dist/types/io/compress/brotli.d.ts.map +1 -1
- package/dist/types/io/compress/brotli_shared.d.ts +0 -4
- package/dist/types/io/compress/brotli_shared.d.ts.map +1 -1
- package/dist/types/io/compress/deflate.d.ts +14 -1
- package/dist/types/io/compress/deflate.d.ts.map +1 -1
- package/dist/types/io/compress/gzip.d.ts +4 -0
- package/dist/types/io/compress/gzip.d.ts.map +1 -1
- package/dist/types/io/compress/huffman.d.ts +7 -0
- package/dist/types/io/compress/huffman.d.ts.map +1 -1
- package/dist/types/io/compress/lz4.d.ts +4 -2
- package/dist/types/io/compress/lz4.d.ts.map +1 -1
- package/dist/types/io/compress/lz77.d.ts +17 -0
- package/dist/types/io/compress/lz77.d.ts.map +1 -1
- package/dist/types/io/compress/lzw.d.ts +2 -0
- package/dist/types/io/compress/lzw.d.ts.map +1 -1
- package/dist/types/io/compress/zip.d.ts.map +1 -1
- package/dist/types/io/compress/zlib.d.ts +9 -2
- package/dist/types/io/compress/zlib.d.ts.map +1 -1
- package/dist/types/io/math/linalg.d.ts.map +1 -1
- package/dist/types/process/rpc.d.ts.map +1 -1
- package/dist/types/process/workerPool.d.ts.map +1 -1
- package/dist/types/sanity/base.d.ts +12 -2
- package/dist/types/sanity/base.d.ts.map +1 -1
- package/dist/types/sanity/lockdown.d.ts +6 -5
- package/dist/types/sanity/lockdown.d.ts.map +1 -1
- package/dist/types/sanity/wasm-gate.d.ts +1 -1
- package/docs/README.md +17 -10
- package/docs/api/README.md +5 -5
- package/docs/api/core/logger.md +2 -1
- package/docs/api/core/modules.md +3 -3
- package/docs/api/core/runtime.md +9 -9
- package/docs/api/core/worker-helper.md +12 -2
- package/docs/api/crypto/README.md +1 -1
- package/docs/api/crypto/cipher/README.md +2 -2
- package/docs/api/crypto/cipher/aes.md +5 -10
- package/docs/api/crypto/cipher/chacha20.md +3 -8
- package/docs/api/crypto/hash/README.md +5 -5
- package/docs/api/crypto/hash/adf.md +21 -11
- package/docs/api/crypto/hash/argon2.md +3 -12
- package/docs/api/crypto/hash/blake2b.md +12 -14
- package/docs/api/crypto/hash/pbkdf2.md +1 -1
- package/docs/api/crypto/hash/sha224.md +2 -2
- package/docs/api/crypto/hash/sha256.md +4 -4
- package/docs/api/crypto/hash/sha3.md +2 -2
- package/docs/api/crypto/hash/sha384.md +1 -1
- package/docs/api/crypto/hash/sha512.md +5 -5
- package/docs/api/crypto/hash/sha512_224.md +1 -1
- package/docs/api/crypto/hash/sha512_256.md +1 -1
- package/docs/api/crypto/mode/README.md +3 -3
- package/docs/api/crypto/mode/cbc.md +2 -2
- package/docs/api/crypto/mode/chacha20poly1305.md +1 -1
- package/docs/api/crypto/mode/cmac.md +4 -4
- package/docs/api/crypto/mode/ctr.md +2 -3
- package/docs/api/crypto/mode/gcm.md +5 -5
- package/docs/api/crypto/mode/kw.md +4 -4
- package/docs/api/crypto/pkc/README.md +8 -8
- package/docs/api/crypto/pkc/ecc.md +19 -17
- package/docs/api/crypto/pkc/ed25519.md +10 -15
- package/docs/api/crypto/pkc/hybridKem.md +8 -2
- package/docs/api/crypto/pkc/hybridSign.md +34 -7
- package/docs/api/crypto/pkc/ml_dsa.md +20 -19
- package/docs/api/crypto/pkc/ml_kem.md +3 -3
- package/docs/api/crypto/pkc/rsa.md +7 -9
- package/docs/api/crypto/pkc/slh_dsa.md +12 -12
- package/docs/api/crypto/pkc/x25519.md +5 -4
- package/docs/api/crypto/utils/README.md +7 -7
- package/docs/api/crypto/utils/aes_modes.md +2 -5
- package/docs/api/crypto/utils/asn1.md +25 -16
- package/docs/api/crypto/utils/jws.md +6 -4
- package/docs/api/crypto/utils/keyformat.md +24 -15
- package/docs/api/crypto/utils/pad.md +1 -1
- package/docs/api/crypto/utils/pem.md +3 -3
- package/docs/api/crypto/utils/random.md +3 -4
- package/docs/api/crypto/utils/rsaKeygen.md +2 -2
- package/docs/api/crypto/utils/totp.md +2 -2
- package/docs/api/crypto/utils/uuid.md +5 -5
- package/docs/api/crypto/utils/x509.md +124 -0
- package/docs/api/crypto/wasm/aes.md +1 -1
- package/docs/api/crypto/wasm/argon2.md +6 -4
- package/docs/api/crypto/wasm/ml_kem.md +1 -0
- package/docs/api/crypto/wasm/pbkdf2.md +8 -8
- package/docs/api/crypto/wasm/rsa.md +1 -1
- package/docs/api/crypto/wasm/runtime.md +27 -10
- package/docs/api/crypto/webcrypto/aes.md +1 -1
- package/docs/api/crypto/webcrypto/aeskw.md +2 -2
- package/docs/api/crypto/webcrypto/digest.md +3 -5
- package/docs/api/crypto/webcrypto/ecc.md +1 -1
- package/docs/api/crypto/webcrypto/ed25519.md +1 -1
- package/docs/api/crypto/webcrypto/rsa.md +3 -2
- package/docs/api/crypto/webcrypto/x25519.md +1 -1
- package/docs/api/dom/README.md +6 -1
- package/docs/api/dom/fs/README.md +1 -0
- package/docs/api/dom/fs/fileIntake.md +120 -0
- package/docs/api/dom/fs/fsAccess.md +1 -0
- package/docs/api/dom/fs/indexedDB.md +1 -1
- package/docs/api/dom/fs/storage.md +1 -1
- package/docs/api/dom/query/README.md +2 -1
- package/docs/api/dom/query/dnd.md +4 -1
- package/docs/api/dom/query/dom.md +5 -0
- package/docs/api/dom/query/sound.md +103 -0
- package/docs/api/dom/rendering/README.md +4 -3
- package/docs/api/dom/rendering/chart.md +5 -4
- package/docs/api/dom/rendering/component.md +25 -3
- package/docs/api/dom/rendering/parser.md +5 -2
- package/docs/api/dom/rendering/reactiveBind.md +1 -1
- package/docs/api/dom/rendering/render.md +2 -2
- package/docs/api/dom/rendering/sanitize.md +10 -2
- package/docs/api/dom/rendering/secPolicy.md +4 -4
- package/docs/api/dom/rendering/styleSheet.md +85 -0
- package/docs/api/dom/rendering/template.md +20 -5
- package/docs/api/dom/rendering/themeTokens.md +6 -3
- package/docs/api/dom/rendering/uiSession.md +18 -5
- package/docs/api/dom/rendering/virtualScroll.md +2 -2
- package/docs/api/dom/sensors/geolocation.md +1 -1
- package/docs/api/dom/sw/README.md +7 -1
- package/docs/api/dom/sw/cache.md +2 -1
- package/docs/api/dom/sw/installPrompt.md +111 -0
- package/docs/api/dom/sw/precache.md +124 -0
- package/docs/api/dom/sw/serviceWorker.md +4 -2
- package/docs/api/dom/sw/swUpdate.md +112 -0
- package/docs/api/dom/utils/clipboard.md +56 -5
- package/docs/api/dom/utils/entropyCollector.md +1 -1
- package/docs/api/dom/utils/keybindings.md +17 -2
- package/docs/api/dom/utils/leaderElection.md +2 -2
- package/docs/api/dom/utils/route.md +1 -0
- package/docs/api/dom/utils/ua.md +15 -10
- package/docs/api/io/calc/crc32.md +4 -1
- package/docs/api/io/codec/README.md +2 -2
- package/docs/api/io/codec/b64.md +31 -2
- package/docs/api/io/codec/buffer.md +1 -1
- package/docs/api/io/codec/cbor.md +6 -4
- package/docs/api/io/codec/csv.md +178 -178
- package/docs/api/io/codec/hex.md +10 -2
- package/docs/api/io/codec/msgpack.md +4 -3
- package/docs/api/io/codec/url.md +4 -3
- package/docs/api/io/codec/utf8.md +3 -3
- package/docs/api/io/compress/bitstream.md +6 -3
- package/docs/api/io/compress/brotli.md +36 -4
- package/docs/api/io/compress/brotli_shared.md +1 -1
- package/docs/api/io/compress/deflate.md +42 -34
- package/docs/api/io/compress/gzip.md +26 -6
- package/docs/api/io/compress/huffman.md +2 -1
- package/docs/api/io/compress/lz4.md +5 -3
- package/docs/api/io/compress/lz77.md +26 -3
- package/docs/api/io/compress/lzw.md +13 -8
- package/docs/api/io/compress/zip.md +36 -10
- package/docs/api/io/compress/zlib.md +21 -5
- package/docs/api/io/math/linalg.md +1 -1
- package/docs/api/io/utils/valid.md +1 -1
- package/docs/api/process/rpc.md +3 -2
- package/docs/api/process/workerPool.md +1 -1
- package/docs/api/sanity/base.md +9 -5
- package/docs/api/sanity/lockdown.md +7 -6
- package/docs/api/surface.json +12311 -0
- package/docs/api/typed.md +5 -3
- package/docs/dev/README.md +2 -0
- package/docs/dev/bench.md +76 -0
- package/docs/dev/crypto-references.md +54 -0
- package/docs/dev/provenance.md +30 -7
- package/docs/dev/publishing.md +7 -7
- package/docs/dev/runtime.md +1 -1
- package/docs/dev/testing.md +13 -0
- package/docs/evidence/l4-evidence.md +86 -0
- package/docs/evidence/pqc-hybrid-evidence.md +7 -6
- package/docs/guide/README.md +1 -0
- package/docs/guide/_QUICK_REF.md +5 -5
- package/docs/guide/doc-format.md +4 -3
- package/docs/guide/integrations-hmr.md +1 -1
- package/docs/guide/module-creation-workflow.md +8 -8
- package/docs/guide/rendering-pipeline.md +11 -4
- package/docs/guide/security.md +7 -5
- package/docs/guide/stability.md +123 -0
- package/docs/guide/tutorial-todo.md +20 -8
- package/docs/guide/typescript.md +9 -0
- package/docs/guide/worker-confinement.md +30 -17
- package/docs/notes/lz77-deflate-factorization.md +3 -3
- package/docs/tools/README.md +1 -1
- package/docs/tools/bundler.md +3 -3
- package/docs/tools/codegen.md +1 -1
- package/docs/tools/standalone.md +0 -1
- package/fw.config.json +2 -2
- package/integrations/_shared/catalog.generated.json +7 -1
- package/integrations/_shared/core.js +1 -1
- package/integrations/astro/index.js +1 -1
- package/integrations/eslint/README.md +7 -1
- package/integrations/nextjs/index.js +1 -1
- package/integrations/nodejs/README.md +3 -3
- package/integrations/turbopack/index.js +2 -2
- package/integrations/typedoc/categorize.js +1 -1
- package/integrations/typedoc/typedoc.json +2 -1
- package/integrations/vite/index.js +2 -2
- package/integrations/vite/vite-env.d.ts +7 -4
- package/integrations/webpack/index.js +3 -3
- package/package.json +76 -10
- package/src/core/internal.js +31 -0
- package/src/core/logger.js +95 -23
- package/src/core/modules.js +17 -8
- package/src/core/readyState.js +1 -1
- package/src/core/runtime.js +74 -27
- package/src/core/worker-helper.js +83 -4
- package/src/crypto/NIST_CONFORMANCE.md +47 -34
- package/src/crypto/cipher/aes.acvp.md +7 -8
- package/src/crypto/cipher/aes.js +280 -229
- package/src/crypto/cipher/chacha20.acvp.md +6 -7
- package/src/crypto/cipher/chacha20.js +91 -61
- package/src/crypto/hash/adf.js +1 -1
- package/src/crypto/hash/argon2.acvp.md +11 -15
- package/src/crypto/hash/argon2.js +9 -24
- package/src/crypto/hash/blake2b.js +157 -125
- package/src/crypto/hash/hkdf.acvp.md +15 -15
- package/src/crypto/hash/hkdf.js +1 -1
- package/src/crypto/hash/hmac.acvp.md +10 -12
- package/src/crypto/hash/hmac.js +5 -1
- package/src/crypto/hash/pbkdf2.acvp.md +13 -13
- package/src/crypto/hash/pbkdf2.js +36 -8
- package/src/crypto/hash/poly1305.acvp.md +10 -6
- package/src/crypto/hash/poly1305.js +171 -50
- package/src/crypto/hash/sha224.acvp.md +3 -3
- package/src/crypto/hash/sha224.js +4 -4
- package/src/crypto/hash/sha256.acvp.md +2 -2
- package/src/crypto/hash/sha256.js +514 -50
- package/src/crypto/hash/sha3.acvp.md +9 -9
- package/src/crypto/hash/sha3.js +127 -71
- package/src/crypto/hash/sha384.acvp.md +3 -3
- package/src/crypto/hash/sha384.js +4 -4
- package/src/crypto/hash/sha512.acvp.md +7 -8
- package/src/crypto/hash/sha512.js +107 -108
- package/src/crypto/hash/sha512_224.acvp.md +6 -6
- package/src/crypto/hash/sha512_224.js +2 -2
- package/src/crypto/hash/sha512_256.acvp.md +6 -6
- package/src/crypto/hash/sha512_256.js +2 -2
- package/src/crypto/mode/cbc.acvp.md +2 -2
- package/src/crypto/mode/cbc.js +1 -1
- package/src/crypto/mode/chacha20poly1305.acvp.md +6 -6
- package/src/crypto/mode/chacha20poly1305.js +3 -3
- package/src/crypto/mode/cmac.acvp.md +5 -5
- package/src/crypto/mode/cmac.js +8 -8
- package/src/crypto/mode/ctr.acvp.md +2 -2
- package/src/crypto/mode/ctr.js +1 -3
- package/src/crypto/mode/gcm.acvp.md +6 -6
- package/src/crypto/mode/gcm.js +7 -7
- package/src/crypto/mode/kw.acvp.md +4 -4
- package/src/crypto/mode/kw.js +5 -5
- package/src/crypto/pkc/ecc.acvp.md +13 -13
- package/src/crypto/pkc/ecc.js +9 -11
- package/src/crypto/pkc/ed25519.acvp.md +30 -34
- package/src/crypto/pkc/ed25519.js +453 -94
- package/src/crypto/pkc/hybrid-kat.provenance.md +4 -4
- package/src/crypto/pkc/hybridSign.js +103 -24
- package/src/crypto/pkc/ml_dsa.acvp.md +18 -18
- package/src/crypto/pkc/ml_dsa.js +29 -32
- package/src/crypto/pkc/ml_kem.acvp.md +7 -7
- package/src/crypto/pkc/ml_kem.js +15 -21
- package/src/crypto/pkc/rsa.acvp.md +11 -15
- package/src/crypto/pkc/rsa.js +7 -44
- package/src/crypto/pkc/slh_dsa.acvp.md +16 -16
- package/src/crypto/pkc/slh_dsa.js +16 -18
- package/src/crypto/pkc/x25519.acvp.md +13 -10
- package/src/crypto/pkc/x25519.js +273 -29
- package/src/crypto/utils/aes_modes.acvp.md +1 -2
- package/src/crypto/utils/aes_modes.js +2 -2
- package/src/crypto/utils/asn1-oid.js +1 -1
- package/src/crypto/utils/asn1.js +1 -1
- package/src/crypto/utils/bitArray.js +33 -48
- package/src/crypto/utils/bn.js +1 -1
- package/src/crypto/utils/jws.js +37 -41
- package/src/crypto/utils/keyformat.js +181 -2
- package/src/crypto/utils/pem.js +1 -1
- package/src/crypto/utils/random.acvp.md +5 -5
- package/src/crypto/utils/random.js +845 -846
- package/src/crypto/utils/rsaKeygen.acvp.md +3 -2
- package/src/crypto/utils/rsaKeygen.js +6 -6
- package/src/crypto/utils/totp.js +1 -1
- package/src/crypto/utils/uuid.acvp.md +5 -5
- package/src/crypto/utils/uuid.js +11 -10
- package/src/crypto/utils/x509.js +591 -0
- package/src/crypto/wasm/aes.js +1 -1
- package/src/crypto/wasm/aes.scalar.wasm +0 -0
- package/src/crypto/wasm/argon2.js +17 -1
- package/src/crypto/wasm/argon2.scalar.wasm +0 -0
- package/src/crypto/wasm/blake2b.scalar.wasm +0 -0
- package/src/crypto/wasm/blake2b.simd.wasm +0 -0
- package/src/crypto/wasm/chacha20poly1305.scalar.wasm +0 -0
- package/src/crypto/wasm/chacha20poly1305.simd.wasm +0 -0
- package/src/crypto/wasm/cmac.scalar.wasm +0 -0
- package/src/crypto/wasm/ecc.js +3 -3
- package/src/crypto/wasm/ecc.scalar.wasm +0 -0
- package/src/crypto/wasm/ed25519.js +1 -1
- package/src/crypto/wasm/ed25519.scalar.wasm +0 -0
- package/src/crypto/wasm/hkdf.scalar.wasm +0 -0
- package/src/crypto/wasm/hmac.scalar.wasm +0 -0
- package/src/crypto/wasm/ml_dsa.js +2 -2
- package/src/crypto/wasm/ml_dsa.scalar.wasm +0 -0
- package/src/crypto/wasm/ml_dsa.simd.wasm +0 -0
- package/src/crypto/wasm/ml_kem.js +2 -2
- package/src/crypto/wasm/ml_kem.scalar.wasm +0 -0
- package/src/crypto/wasm/ml_kem.simd.wasm +0 -0
- package/src/crypto/wasm/pbkdf2.js +8 -6
- package/src/crypto/wasm/pbkdf2.scalar.wasm +0 -0
- package/src/crypto/wasm/rsa.js +6 -5
- package/src/crypto/wasm/rsa.scalar.wasm +0 -0
- package/src/crypto/wasm/runtime.js +84 -17
- package/src/crypto/wasm/sha2.scalar.wasm +0 -0
- package/src/crypto/wasm/sha3.scalar.wasm +0 -0
- package/src/crypto/wasm/sha3.simd.wasm +0 -0
- package/src/crypto/wasm/slh_dsa.js +1 -1
- package/src/crypto/wasm/slh_dsa.scalar.wasm +0 -0
- package/src/crypto/wasm/x25519.js +1 -1
- package/src/crypto/wasm/x25519.scalar.wasm +0 -0
- package/src/crypto/webcrypto/aes.js +8 -2
- package/src/crypto/webcrypto/aeskw.js +7 -2
- package/src/crypto/webcrypto/digest.js +1 -15
- package/src/crypto/webcrypto/ecc.js +2 -2
- package/src/crypto/webcrypto/ed25519.js +2 -2
- package/src/crypto/webcrypto/hmac.js +2 -2
- package/src/crypto/webcrypto/rsa.js +7 -2
- package/src/crypto/webcrypto/x25519.js +2 -2
- package/src/dom/display/animate.js +1 -1
- package/src/dom/display/fullscreen.js +1 -1
- package/src/dom/fs/download.js +1 -1
- package/src/dom/fs/fileIntake.js +192 -0
- package/src/dom/fs/fsAccess.js +2 -3
- package/src/dom/fs/indexedDB.js +1 -1
- package/src/dom/fs/remoteStore.js +1 -1
- package/src/dom/fs/storage.js +1 -1
- package/src/dom/lifecycle/idle.js +1 -1
- package/src/dom/lifecycle/visibility.js +1 -1
- package/src/dom/lifecycle/wakeLock.js +1 -1
- package/src/dom/net/ajax.js +1 -1
- package/src/dom/net/network.js +1 -1
- package/src/dom/net/sse.js +1 -1
- package/src/dom/net/webrtc.js +1 -1
- package/src/dom/net/ws.js +1 -1
- package/src/dom/query/dnd.js +56 -4
- package/src/dom/query/dom.js +1 -1
- package/src/dom/query/events.js +1 -1
- package/src/dom/query/gesture.js +1 -1
- package/src/dom/query/media.js +1 -1
- package/src/dom/query/sound.js +333 -0
- package/src/dom/rendering/chart.js +736 -663
- package/src/dom/rendering/component.js +25 -14
- package/src/dom/rendering/devtools.js +2 -2
- package/src/dom/rendering/parser.js +155 -12
- package/src/dom/rendering/render.js +14 -4
- package/src/dom/rendering/sanitize.js +11 -4
- package/src/dom/rendering/secPolicy.js +6 -4
- package/src/dom/rendering/styleSheet.js +217 -0
- package/src/dom/rendering/template.js +72 -13
- package/src/dom/rendering/themeTokens.js +542 -522
- package/src/dom/rendering/uiSession-core.js +51 -6
- package/src/dom/rendering/uiSession-direct.js +1 -1
- package/src/dom/rendering/uiSession-list.js +4 -4
- package/src/dom/rendering/uiSession.js +1 -1
- package/src/dom/rendering/virtualScroll.js +341 -341
- package/src/dom/sensors/battery.js +1 -1
- package/src/dom/sensors/geolocation.js +1 -1
- package/src/dom/sensors/networkInfo.js +1 -1
- package/src/dom/sensors/sensors.js +1 -1
- package/src/dom/sw/backgroundSync.js +1 -1
- package/src/dom/sw/cache.js +1 -1
- package/src/dom/sw/installPrompt.js +151 -0
- package/src/dom/sw/precache.js +257 -0
- package/src/dom/sw/push.js +1 -1
- package/src/dom/sw/sharedWorker.js +1 -1
- package/src/dom/sw/swUpdate.js +239 -0
- package/src/dom/utils/a11y.js +1 -1
- package/src/dom/utils/clipboard.js +56 -6
- package/src/dom/utils/entropyCollector.js +1 -1
- package/src/dom/utils/focus.js +1 -1
- package/src/dom/utils/form.js +1 -1
- package/src/dom/utils/keybindings.js +600 -574
- package/src/dom/utils/leaderElection.js +1 -1
- package/src/dom/utils/notifications.js +1 -1
- package/src/dom/utils/permissions.js +107 -107
- package/src/dom/utils/route.js +14 -2
- package/src/dom/utils/ua.js +42 -28
- package/src/dom/utils/webauthn.js +1 -1
- package/src/io/binary/reader.js +1 -1
- package/src/io/binary/writer.js +1 -1
- package/src/io/calc/bigint.js +1 -1
- package/src/io/calc/crc32.js +28 -2
- package/src/io/calc/easing.js +514 -514
- package/src/io/codec/b64.js +189 -52
- package/src/io/codec/base32.js +1 -1
- package/src/io/codec/base58.js +1 -1
- package/src/io/codec/buffer.js +1 -1
- package/src/io/codec/cbor.js +111 -18
- package/src/io/codec/csv.js +1 -1
- package/src/io/codec/hex.js +51 -6
- package/src/io/codec/mime.js +1 -1
- package/src/io/codec/msgpack.js +47 -6
- package/src/io/codec/url.js +24 -7
- package/src/io/codec/utf8.js +5 -3
- package/src/io/codec/xml.js +1 -1
- package/src/io/compress/bitstream.js +2 -2
- package/src/io/compress/brotli.js +663 -163
- package/src/io/compress/brotli_dict.js +1 -1
- package/src/io/compress/brotli_dict_words.js +1 -1
- package/src/io/compress/brotli_frame.js +1 -1
- package/src/io/compress/brotli_shared.js +7 -7
- package/src/io/compress/deflate.js +87 -53
- package/src/io/compress/gzip.js +187 -74
- package/src/io/compress/huffman.js +24 -1
- package/src/io/compress/lz4.js +45 -7
- package/src/io/compress/lz77.js +148 -63
- package/src/io/compress/lzw.js +35 -19
- package/src/io/compress/zip.js +862 -815
- package/src/io/compress/zlib.js +87 -7
- package/src/io/i18n/i18n.js +1 -1
- package/src/io/math/fixed-point.js +1 -1
- package/src/io/math/geom.js +1 -1
- package/src/io/math/interp.js +1 -1
- package/src/io/math/linalg.js +10 -4
- package/src/io/math/stats.js +1 -1
- package/src/io/structures/btree.js +1 -1
- package/src/io/structures/heap.js +1 -1
- package/src/io/structures/lruCache.js +1 -1
- package/src/io/structures/ringBuffer.js +1 -1
- package/src/io/structures/tree-walker.js +1 -1
- package/src/io/structures/trie.js +1 -1
- package/src/io/sync/abort.js +1 -1
- package/src/io/sync/atomics.js +1 -1
- package/src/io/sync/cancellable.js +1 -1
- package/src/io/sync/channel.js +1 -1
- package/src/io/sync/mutex.js +1 -1
- package/src/io/sync/semaphore.js +1 -1
- package/src/io/sync/tokenBucket.js +1 -1
- package/src/io/text/ansi.js +1 -1
- package/src/io/text/html-entities.js +1 -1
- package/src/io/time/date.js +1 -1
- package/src/io/timing/clock.js +1 -1
- package/src/io/timing/rateLimit.js +1 -1
- package/src/io/timing/scheduler.js +1 -1
- package/src/io/utils/errors.js +1 -1
- package/src/io/utils/eventBus.js +1 -1
- package/src/io/utils/signal.js +1 -1
- package/src/io/utils/valid.js +1 -1
- package/src/main.js +1 -1
- package/src/process/message.js +1 -1
- package/src/process/rpc.js +7 -3
- package/src/process/workerPool.js +11 -4
- package/src/sanity/base.js +85 -39
- package/src/sanity/lockdown-apply.js +3 -3
- package/src/sanity/lockdown.js +58 -32
- package/src/sanity/wasm-gate.js +2 -2
- package/src/typed.js +7 -3
- package/third-party/NOTICE-brotli-dictionary.txt +69 -0
- package/third-party/NOTICE-fw-wasm-crypto.txt +576 -0
- package/third-party/NOTICE-whatwg-entities.txt +44 -0
- package/types/registry.generated.d.ts +7 -1
- package/types/typed.d.ts +7 -3
- package/dist/types/crypto/utils/aes_ctr.d.ts +0 -84
- package/dist/types/crypto/utils/aes_ctr.d.ts.map +0 -1
- package/docs/api/crypto/utils/aes_ctr.md +0 -71
- package/src/crypto/utils/aes_ctr.acvp.md +0 -67
- package/src/crypto/utils/aes_ctr.js +0 -134
package/src/io/compress/lz77.js
CHANGED
|
@@ -22,10 +22,13 @@
|
|
|
22
22
|
* - **chainSkip** - walk heuristic that follows the sparsest chain inside
|
|
23
23
|
* the current best match instead of the position's own chain.
|
|
24
24
|
*
|
|
25
|
-
* The scan
|
|
26
|
-
* `
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* The scan packs the token stream as `(len|0, dist|byte)` pairs into an
|
|
26
|
+
* `Int32Array`. `createScanner` runs it in steps: each `fill(tokens, max)`
|
|
27
|
+
* writes the next `max` tokens at most and resumes where it stopped, so a
|
|
28
|
+
* block-wise consumer holds one block of tokens. `encodeTokens` is one fill
|
|
29
|
+
* over the whole input; `encode` replays that stream through two callbacks
|
|
30
|
+
* (`literal(pos)`, `match(pos, len, dist)`). Both accept `opts.tokens` to
|
|
31
|
+
* reuse a caller-owned buffer.
|
|
29
32
|
*
|
|
30
33
|
* ## API
|
|
31
34
|
*
|
|
@@ -33,6 +36,7 @@
|
|
|
33
36
|
* |---|---|
|
|
34
37
|
* | `encode(data, opts, callbacks)` | `void` - drives the scan, reports via callbacks |
|
|
35
38
|
* | `encodeTokens(data, opts)` | `{ tokens, count }` - packed token pairs |
|
|
39
|
+
* | `createScanner(data, opts)` | `{ fill(tokens, max), done }` - the same scan, resumable |
|
|
36
40
|
* | `findMatch(data, pos, head, prev, opts)` | `{ len, dist } \| null` - single-position probe |
|
|
37
41
|
*
|
|
38
42
|
* ## Hash function
|
|
@@ -47,11 +51,19 @@
|
|
|
47
51
|
* @typedef {object} Lz77API
|
|
48
52
|
* @property {(data: Uint8Array, opts: object, callbacks: { literal: (pos: number) => void, match: (pos: number, len: number, dist: number) => void }) => void} encode Run the hash-chain encoder, reporting tokens via callbacks.
|
|
49
53
|
* @property {(data: Uint8Array, opts?: object) => { tokens: Int32Array, count: number }} encodeTokens Callback-free fast path: same token sequence as `encode`, packed as `(len|0, dist|byte)` pairs into an `Int32Array`.
|
|
54
|
+
* @property {(data: Uint8Array, opts?: object) => Lz77Scanner} createScanner Resumable scan: successive `fill` calls give the `encodeTokens` token sequence, `max` tokens at a time.
|
|
50
55
|
* @property {(data: Uint8Array, pos: number, head: Int32Array, prev: Int32Array, opts: object) => ({ len: number, dist: number } | null)} findMatch Single-position match probe.
|
|
51
56
|
* @property {(dst: Uint8Array, ops: Array<{ lit?: number, pos?: number, len?: number, dist?: number }>) => number} decodeStream Replay a token stream into `dst`; returns bytes written.
|
|
52
57
|
* @property {{ windowBits: number, minMatch: number, maxMatch: number, chainDepth: number, lazy: boolean, hashBits: number, niceLength: number, goodLength: number, maxLazy: number, chainSkip: boolean, start: number, hashFn: (((data: Uint8Array, pos: number) => number) | null) }} DEFAULT Frozen default option set.
|
|
53
58
|
*/
|
|
54
59
|
|
|
60
|
+
/**
|
|
61
|
+
* A resumable scan from `lz77.createScanner`.
|
|
62
|
+
* @typedef {object} Lz77Scanner
|
|
63
|
+
* @property {(tokens: Int32Array, max: number) => number} fill Write at most `max` tokens (`2 × max` entries) from index 0; returns how many. Fewer than `max` only at the end of the input.
|
|
64
|
+
* @property {boolean} done `true` once every token has been written.
|
|
65
|
+
*/
|
|
66
|
+
|
|
55
67
|
export const lz77 = {
|
|
56
68
|
name: 'lz77',
|
|
57
69
|
version: '1.0.0',
|
|
@@ -264,63 +276,38 @@ export const lz77 = {
|
|
|
264
276
|
}
|
|
265
277
|
|
|
266
278
|
/**
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
279
|
+
* Write the next tokens of the scan `st` (see `createScanner`) into
|
|
280
|
+
* `tokens` from index 0, at most `max` of them, and record where the
|
|
281
|
+
* scan stopped. Every field the loop reads is copied to a local first:
|
|
282
|
+
* the loop runs once per input position.
|
|
271
283
|
*
|
|
272
|
-
* @param {
|
|
273
|
-
* @param {
|
|
274
|
-
*
|
|
275
|
-
* @returns {
|
|
276
|
-
* pairs are valid at `tokens[0 .. 2*count)`.
|
|
277
|
-
* @throws {Error} When `data` is not a `Uint8Array` or `opts.tokens` is too small.
|
|
284
|
+
* @param {object} st Scan state built by `createScanner`.
|
|
285
|
+
* @param {Int32Array} tokens At least `2 × max` entries.
|
|
286
|
+
* @param {number} max Most tokens to write (≥ 1).
|
|
287
|
+
* @returns {number} Tokens written; fewer than `max` only at the end.
|
|
278
288
|
*/
|
|
279
|
-
function
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
const provided = opts && opts.tokens;
|
|
286
|
-
let tokens;
|
|
287
|
-
if (provided) {
|
|
288
|
-
if (provided.length < cap) throw new Error('lz77.encodeTokens: tokens buffer too small');
|
|
289
|
-
tokens = provided;
|
|
290
|
-
} else {
|
|
291
|
-
tokens = new i32(cap);
|
|
292
|
-
}
|
|
293
|
-
|
|
289
|
+
function _fill(st, tokens, max) {
|
|
290
|
+
const data = st.data, len = st.len, head = st.head, prev = st.prev, hash = st.hash;
|
|
291
|
+
const maxMatch = st.maxMatch, niceLength = st.niceLength, chainDepth = st.chainDepth;
|
|
292
|
+
const lazy = st.lazy, goodLength = st.goodLength, maxLazy = st.maxLazy, chainSkip = st.chainSkip;
|
|
293
|
+
const wndSize = st.wndSize, wndMask = wndSize - 1, lastKey = st.lastKey, atLeast = st.atLeast;
|
|
294
|
+
const cap = 2 * max;
|
|
294
295
|
let p = 0;
|
|
295
|
-
if (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const lazy = o.lazy, goodLength = o.goodLength, maxLazy = o.maxLazy, chainSkip = o.chainSkip;
|
|
300
|
-
const wndSize = 1 << o.windowBits;
|
|
301
|
-
const wndMask = wndSize - 1;
|
|
302
|
-
const head = new i32(1 << o.hashBits).fill(-1);
|
|
303
|
-
// One chain link per input position, capped at the window: a
|
|
304
|
-
// short input never touches the higher slots.
|
|
305
|
-
const prev = new i32(Math.min(wndSize, len)).fill(-1);
|
|
306
|
-
const hash = _hasherFor(o);
|
|
307
|
-
/** Last position with a complete hash key (inclusive). */
|
|
308
|
-
const lastKey = len - o.minMatch;
|
|
309
|
-
/** Floor of the first probe at a position: a match must exceed it. */
|
|
310
|
-
const atLeast = o.minMatch - 1;
|
|
311
|
-
|
|
312
|
-
// Prime the chains with [0, start): never emitted, still matchable.
|
|
313
|
-
for (let k = 0; k < o.start && k <= lastKey; ++k) {
|
|
314
|
-
const h = hash(data, k);
|
|
315
|
-
prev[k & wndMask] = head[h];
|
|
316
|
-
head[h] = k;
|
|
296
|
+
if (st.heldLen) {
|
|
297
|
+
tokens[p++] = st.heldLen;
|
|
298
|
+
tokens[p++] = st.heldDist;
|
|
299
|
+
st.heldLen = 0;
|
|
317
300
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
while (i <= lastKey) {
|
|
301
|
+
let i = st.at;
|
|
302
|
+
while (p < cap && i <= lastKey) {
|
|
321
303
|
const h = hash(data, i);
|
|
322
|
-
|
|
323
|
-
|
|
304
|
+
// The probe's own first test, inline: on incompressible data
|
|
305
|
+
// the bucket's newest entry is nearly always empty or out of
|
|
306
|
+
// the window, and the call is most of the cost.
|
|
307
|
+
const newest = head[h];
|
|
308
|
+
let matchLen = newest === -1 || i - newest >= wndSize ? 0
|
|
309
|
+
: _longestMatch(data, i, h, head, prev, wndSize, wndMask,
|
|
310
|
+
Math.min(maxMatch, len - i), niceLength, chainDepth, chainSkip, atLeast);
|
|
324
311
|
let dist = matchDist;
|
|
325
312
|
// Insert `i` now: every path below needs it in the chain before
|
|
326
313
|
// moving on, and the lazy probe at `i + 1` must be able to reach it.
|
|
@@ -339,9 +326,11 @@ export const lz77 = {
|
|
|
339
326
|
// match that is already "good" only gets a quarter of
|
|
340
327
|
// the chain (at least one probe).
|
|
341
328
|
const h1 = hash(data, i + 1);
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
329
|
+
const newest1 = head[h1];
|
|
330
|
+
const nextLen = newest1 === -1 || i + 1 - newest1 >= wndSize ? 0
|
|
331
|
+
: _longestMatch(data, i + 1, h1, head, prev, wndSize, wndMask,
|
|
332
|
+
Math.min(maxMatch, len - i - 1), niceLength,
|
|
333
|
+
matchLen >= goodLength ? (chainDepth >> 2) || 1 : chainDepth, chainSkip, matchLen);
|
|
345
334
|
if (nextLen) {
|
|
346
335
|
tokens[p++] = 0;
|
|
347
336
|
tokens[p++] = data[i];
|
|
@@ -355,8 +344,13 @@ export const lz77 = {
|
|
|
355
344
|
}
|
|
356
345
|
}
|
|
357
346
|
|
|
358
|
-
|
|
359
|
-
|
|
347
|
+
if (p < cap) {
|
|
348
|
+
tokens[p++] = matchLen;
|
|
349
|
+
tokens[p++] = dist;
|
|
350
|
+
} else {
|
|
351
|
+
st.heldLen = matchLen; // the cut fell between the lazy literal and its match
|
|
352
|
+
st.heldDist = dist;
|
|
353
|
+
}
|
|
360
354
|
const end = i + matchLen;
|
|
361
355
|
for (let k = i + 1; k < end && k <= lastKey; ++k) {
|
|
362
356
|
const hk = hash(data, k);
|
|
@@ -366,12 +360,102 @@ export const lz77 = {
|
|
|
366
360
|
i = end;
|
|
367
361
|
}
|
|
368
362
|
// Tail: the last `minMatch - 1` bytes cannot form a hash key.
|
|
369
|
-
while (i < len) {
|
|
363
|
+
while (p < cap && i < len) {
|
|
370
364
|
tokens[p++] = 0;
|
|
371
365
|
tokens[p++] = data[i];
|
|
372
366
|
i++;
|
|
373
367
|
}
|
|
374
|
-
|
|
368
|
+
st.at = i;
|
|
369
|
+
return p >> 1;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* A resumable scan of `data`: the scan's state (the position and the
|
|
374
|
+
* hash chains) lives in the returned object, and each `fill` call
|
|
375
|
+
* writes the next tokens of the stream as `(len|0, dist|byte)` pairs
|
|
376
|
+
* — the format of `encodeTokens` — then stops. Successive fills give
|
|
377
|
+
* exactly the token sequence of one `encodeTokens` call, whatever
|
|
378
|
+
* `max` each one is given: a lazy step that emits a literal and a
|
|
379
|
+
* match across the cut keeps the match for the next fill.
|
|
380
|
+
*
|
|
381
|
+
* A consumer that handles the stream in blocks (DEFLATE) holds one
|
|
382
|
+
* block of tokens instead of the whole input's.
|
|
383
|
+
*
|
|
384
|
+
* @param {Uint8Array} data
|
|
385
|
+
* @param {object} [opts] See `DEFAULT` (`opts.tokens` is ignored).
|
|
386
|
+
* @returns {Lz77Scanner}
|
|
387
|
+
* @throws {Error} When `data` is not a `Uint8Array`.
|
|
388
|
+
*/
|
|
389
|
+
function createScanner(data, opts) {
|
|
390
|
+
if (!(data instanceof u8)) throw new Error('lz77.createScanner: data must be Uint8Array');
|
|
391
|
+
const o = _resolveOpts(opts);
|
|
392
|
+
const len = data.length;
|
|
393
|
+
const wndSize = 1 << o.windowBits;
|
|
394
|
+
const wndMask = wndSize - 1;
|
|
395
|
+
const empty = o.start >= len;
|
|
396
|
+
const hash = _hasherFor(o);
|
|
397
|
+
/** Last position with a complete hash key (inclusive). */
|
|
398
|
+
const lastKey = len - o.minMatch;
|
|
399
|
+
const head = empty ? null : new i32(1 << o.hashBits).fill(-1);
|
|
400
|
+
// One chain link per input position, capped at the window: a
|
|
401
|
+
// short input never touches the higher slots.
|
|
402
|
+
const prev = empty ? null : new i32(Math.min(wndSize, len)).fill(-1);
|
|
403
|
+
|
|
404
|
+
// Prime the chains with [0, start): never emitted, still matchable.
|
|
405
|
+
if (!empty) {
|
|
406
|
+
for (let k = 0; k < o.start && k <= lastKey; ++k) {
|
|
407
|
+
const h = hash(data, k);
|
|
408
|
+
prev[k & wndMask] = head[h];
|
|
409
|
+
head[h] = k;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
const st = {
|
|
414
|
+
data, len, hash, lastKey, wndSize, head, prev,
|
|
415
|
+
maxMatch: o.maxMatch, niceLength: o.niceLength, chainDepth: o.chainDepth,
|
|
416
|
+
lazy: o.lazy, goodLength: o.goodLength, maxLazy: o.maxLazy, chainSkip: o.chainSkip,
|
|
417
|
+
/** Floor of the first probe at a position: a match must exceed it. */
|
|
418
|
+
atLeast: o.minMatch - 1,
|
|
419
|
+
/** Next input position to scan. */
|
|
420
|
+
at: empty ? len : o.start,
|
|
421
|
+
/** A match token held across a cut (length, 0 when none) and its distance. */
|
|
422
|
+
heldLen: 0, heldDist: 0,
|
|
423
|
+
};
|
|
424
|
+
return {
|
|
425
|
+
fill(tokens, max) { return _fill(st, tokens, max); },
|
|
426
|
+
get done() { return st.at >= st.len && st.heldLen === 0; },
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Scan `data` and pack its token stream as `(len|0, dist|byte)` pairs
|
|
432
|
+
* into an `Int32Array`: `tokens[2k] === 0` marks a literal whose byte
|
|
433
|
+
* is `tokens[2k + 1]`, otherwise the pair is a match length and its
|
|
434
|
+
* distance. One `createScanner(data, opts).fill` over the whole input.
|
|
435
|
+
*
|
|
436
|
+
* @param {Uint8Array} data
|
|
437
|
+
* @param {object} [opts] See `DEFAULT`; `opts.tokens` (Int32Array)
|
|
438
|
+
* is reused when it holds `2 × (data.length - start)` entries.
|
|
439
|
+
* @returns {{ tokens: Int32Array, count: number }} `count` token
|
|
440
|
+
* pairs are valid at `tokens[0 .. 2*count)`.
|
|
441
|
+
* @throws {Error} When `data` is not a `Uint8Array` or `opts.tokens` is too small.
|
|
442
|
+
*/
|
|
443
|
+
function encodeTokens(data, opts) {
|
|
444
|
+
if (!(data instanceof u8)) throw new Error('lz77.encodeTokens: data must be Uint8Array');
|
|
445
|
+
const n = Math.max(0, data.length - Math.max(0, (opts && opts.start) | 0));
|
|
446
|
+
const cap = 2 * n;
|
|
447
|
+
|
|
448
|
+
const provided = opts && opts.tokens;
|
|
449
|
+
let tokens;
|
|
450
|
+
if (provided) {
|
|
451
|
+
if (provided.length < cap) throw new Error('lz77.encodeTokens: tokens buffer too small');
|
|
452
|
+
tokens = provided;
|
|
453
|
+
} else {
|
|
454
|
+
tokens = new i32(cap);
|
|
455
|
+
}
|
|
456
|
+
if (n === 0) return { tokens, count: 0 };
|
|
457
|
+
// At most one token per input byte: one fill holds the whole stream.
|
|
458
|
+
return { tokens, count: createScanner(data, opts).fill(tokens, n) };
|
|
375
459
|
}
|
|
376
460
|
|
|
377
461
|
/**
|
|
@@ -400,6 +484,7 @@ export const lz77 = {
|
|
|
400
484
|
return {
|
|
401
485
|
encode,
|
|
402
486
|
encodeTokens,
|
|
487
|
+
createScanner,
|
|
403
488
|
findMatch,
|
|
404
489
|
decodeStream,
|
|
405
490
|
DEFAULT,
|
package/src/io/compress/lzw.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright (c) 2026 AwaCloud SAS
|
|
2
2
|
// Author: Matthieu Bouilloux
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
@@ -15,14 +15,16 @@
|
|
|
15
15
|
*
|
|
16
16
|
* ## Wire-format families
|
|
17
17
|
*
|
|
18
|
-
* | Family | `bigEndian` | `useClearEnd` | `minCodeBits` | Used by |
|
|
19
|
-
*
|
|
20
|
-
* | GIF | `false` (LSB-first) | `true` (CLEAR + END markers) | 8 (
|
|
21
|
-
* | TIFF | `true` (MSB-first) | `true` | 8 | image/tiff |
|
|
22
|
-
* | `compress`/.Z | `false` | `false` (no markers, just dict reset on full) | 8 | unix |
|
|
18
|
+
* | Family | `bigEndian` | `earlyChange` | `useClearEnd` | `minCodeBits` | Used by |
|
|
19
|
+
* |---|---|---|---|---|---|
|
|
20
|
+
* | GIF | `false` (LSB-first) | `false` | `true` (CLEAR + END markers) | 2..8 (the image's) | image/gif |
|
|
21
|
+
* | TIFF, PDF `LZWDecode` | `true` (MSB-first) | `true` | `true` | 8 | image/tiff, application/pdf |
|
|
22
|
+
* | `compress`/.Z | `false` | `false` | `false` (no markers, just dict reset on full) | 8 | unix |
|
|
23
23
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* `earlyChange` is when the code width grows: GIF (and .Z) widen once the
|
|
25
|
+
* table holds `2^n` entries; TIFF and PDF (`/EarlyChange 1`, its default)
|
|
26
|
+
* one code earlier. It defaults to `bigEndian`, so the defaults are the GIF
|
|
27
|
+
* profile and `bigEndian: true` alone is the TIFF / PDF one.
|
|
26
28
|
*
|
|
27
29
|
* ## API
|
|
28
30
|
*
|
|
@@ -39,6 +41,7 @@
|
|
|
39
41
|
* | `minCodeBits` | `number` (2..12) | `8` | log2 of the initial alphabet (`1 << minCodeBits` initial codes) |
|
|
40
42
|
* | `maxBits` | `number` (9..16) | `12` | Max code width before the dictionary stops growing (or resets) |
|
|
41
43
|
* | `bigEndian` | `boolean` | `false` | `false` = LSB-first packing (GIF/Z), `true` = MSB-first (TIFF) |
|
|
44
|
+
* | `earlyChange` | `boolean` | `bigEndian` | `true` = widen the code one code early (TIFF, PDF `/EarlyChange 1`), `false` = at `2^n` entries (GIF, .Z) |
|
|
42
45
|
* | `useClearEnd` | `boolean` | `true` | Emit `CLEAR = 1 << minCodeBits` and `END = CLEAR + 1` markers |
|
|
43
46
|
*
|
|
44
47
|
*/
|
|
@@ -46,8 +49,8 @@
|
|
|
46
49
|
/**
|
|
47
50
|
* Public surface of `lzw.factory()`.
|
|
48
51
|
* @typedef {object} LzwAPI
|
|
49
|
-
* @property {(data: Uint8Array, opts?: { minCodeBits?: number, maxBits?: number, bigEndian?: boolean, useClearEnd?: boolean }) => Uint8Array} encode Compress `data` to LZW codes.
|
|
50
|
-
* @property {(data: Uint8Array, opts?: { minCodeBits?: number, maxBits?: number, bigEndian?: boolean, useClearEnd?: boolean }) => Uint8Array} decode Decompress LZW codes back to the original bytes.
|
|
52
|
+
* @property {(data: Uint8Array, opts?: { minCodeBits?: number, maxBits?: number, bigEndian?: boolean, useClearEnd?: boolean, earlyChange?: boolean }) => Uint8Array} encode Compress `data` to LZW codes.
|
|
53
|
+
* @property {(data: Uint8Array, opts?: { minCodeBits?: number, maxBits?: number, bigEndian?: boolean, useClearEnd?: boolean, earlyChange?: boolean }) => Uint8Array} decode Decompress LZW codes back to the original bytes.
|
|
51
54
|
*/
|
|
52
55
|
|
|
53
56
|
export const lzw = {
|
|
@@ -58,6 +61,14 @@ export const lzw = {
|
|
|
58
61
|
|
|
59
62
|
/** @returns {LzwAPI} */
|
|
60
63
|
factory() {
|
|
64
|
+
/** An `Error` with the compressor family's string `code` (D9 G6). */
|
|
65
|
+
function _codedError(code, message) {
|
|
66
|
+
const e = new Error(message);
|
|
67
|
+
// @ts-ignore - Error.code is a non-standard but widely-used extension
|
|
68
|
+
e.code = code;
|
|
69
|
+
return e;
|
|
70
|
+
}
|
|
71
|
+
|
|
61
72
|
|
|
62
73
|
const u8 = Uint8Array;
|
|
63
74
|
|
|
@@ -67,13 +78,14 @@ export const lzw = {
|
|
|
67
78
|
const maxBits = opts.maxBits ?? 12;
|
|
68
79
|
const bigEndian = !!opts.bigEndian;
|
|
69
80
|
const useClearEnd = opts.useClearEnd ?? true;
|
|
81
|
+
const earlyChange = opts.earlyChange ?? bigEndian;
|
|
70
82
|
if (minCodeBits < 2 || minCodeBits > 12) {
|
|
71
|
-
throw
|
|
83
|
+
throw _codedError('EBADARG', 'lzw: minCodeBits must be in [2, 12]');
|
|
72
84
|
}
|
|
73
85
|
if (maxBits < minCodeBits + 1 || maxBits > 16) {
|
|
74
|
-
throw
|
|
86
|
+
throw _codedError('EBADARG', 'lzw: maxBits must be in [minCodeBits+1, 16]');
|
|
75
87
|
}
|
|
76
|
-
return { minCodeBits, maxBits, bigEndian, useClearEnd };
|
|
88
|
+
return { minCodeBits, maxBits, bigEndian, useClearEnd, earlyChange: !!earlyChange };
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
// --- Bit writer ---
|
|
@@ -177,7 +189,7 @@ export const lzw = {
|
|
|
177
189
|
// --- Encoder ---
|
|
178
190
|
|
|
179
191
|
function encode(data, opts) {
|
|
180
|
-
if (!(data instanceof u8)) throw
|
|
192
|
+
if (!(data instanceof u8)) throw _codedError('EBADARG', 'lzw.encode: data must be Uint8Array');
|
|
181
193
|
const o = _resolveOpts(opts);
|
|
182
194
|
|
|
183
195
|
const initialSize = 1 << o.minCodeBits;
|
|
@@ -222,7 +234,9 @@ export const lzw = {
|
|
|
222
234
|
// The decoder side widens its code BEFORE reading
|
|
223
235
|
// a code that would require the wider width - to
|
|
224
236
|
// match, widen here when `nextCode === (1<<codeBits)`.
|
|
225
|
-
|
|
237
|
+
// With early change (TIFF, PDF) the width grows one
|
|
238
|
+
// code sooner than GIF's rule.
|
|
239
|
+
if (nextCode === (1 << codeBits) + (o.earlyChange ? 0 : 1) && codeBits < o.maxBits) {
|
|
226
240
|
codeBits++;
|
|
227
241
|
}
|
|
228
242
|
}
|
|
@@ -238,7 +252,7 @@ export const lzw = {
|
|
|
238
252
|
// --- Decoder ---
|
|
239
253
|
|
|
240
254
|
function decode(data, opts) {
|
|
241
|
-
if (!(data instanceof u8)) throw
|
|
255
|
+
if (!(data instanceof u8)) throw _codedError('EBADARG', 'lzw.decode: data must be Uint8Array');
|
|
242
256
|
const o = _resolveOpts(opts);
|
|
243
257
|
|
|
244
258
|
const initialSize = 1 << o.minCodeBits;
|
|
@@ -291,7 +305,7 @@ export const lzw = {
|
|
|
291
305
|
if (code < nextCode) {
|
|
292
306
|
seq = dict[code];
|
|
293
307
|
if (!seq) {
|
|
294
|
-
throw
|
|
308
|
+
throw _codedError('EBADSTREAM', 'lzw.decode: invalid code ' + code + ' (unassigned)');
|
|
295
309
|
}
|
|
296
310
|
} else if (code === nextCode && prevSeq) {
|
|
297
311
|
// "KwKwK" case - code refers to the entry currently
|
|
@@ -300,7 +314,7 @@ export const lzw = {
|
|
|
300
314
|
seq.set(prevSeq, 0);
|
|
301
315
|
seq[prevSeq.length] = prevSeq[0];
|
|
302
316
|
} else {
|
|
303
|
-
throw
|
|
317
|
+
throw _codedError('EBADSTREAM', 'lzw.decode: code ' + code + ' out of range (nextCode=' + nextCode + ')');
|
|
304
318
|
}
|
|
305
319
|
|
|
306
320
|
append(seq);
|
|
@@ -314,7 +328,9 @@ export const lzw = {
|
|
|
314
328
|
// the encoder by one entry (it skipped adding on the
|
|
315
329
|
// very first read). Widen one iteration EARLIER than
|
|
316
330
|
// the encoder so we're aligned at the next read.
|
|
317
|
-
|
|
331
|
+
// GIF: widen once the table holds 2^n entries; early
|
|
332
|
+
// change (TIFF, PDF): one entry sooner.
|
|
333
|
+
if (nextCode === (1 << codeBits) - (o.earlyChange ? 1 : 0) && codeBits < o.maxBits) {
|
|
318
334
|
codeBits++;
|
|
319
335
|
}
|
|
320
336
|
}
|