@awacloud/fw 0.1.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 +79 -0
- package/LICENSE +176 -0
- package/NOTICE +12 -0
- package/README.md +355 -0
- package/dist/build/fw.core.pure.meta.json +29 -0
- package/dist/build/fw.core.pure.min.js +26 -0
- package/dist/build/fw.full.pure.meta.json +224 -0
- package/dist/build/fw.full.pure.min.js +60 -0
- package/dist/build/fw.minimal.pure.meta.json +21 -0
- package/dist/build/fw.minimal.pure.min.js +26 -0
- package/dist/build/fw.pack.compress-heavy.pure.meta.json +29 -0
- package/dist/build/fw.pack.compress-heavy.pure.min.js +8 -0
- package/dist/build/fw.pack.crypto-advanced.pure.meta.json +38 -0
- package/dist/build/fw.pack.crypto-advanced.pure.min.js +6 -0
- package/dist/build/fw.pack.crypto-basic.pure.meta.json +29 -0
- package/dist/build/fw.pack.crypto-basic.pure.min.js +6 -0
- package/dist/build/fw.pack.crypto-identity.pure.meta.json +29 -0
- package/dist/build/fw.pack.crypto-identity.pure.min.js +9 -0
- package/dist/build/fw.pack.realtime.pure.meta.json +21 -0
- package/dist/build/fw.pack.realtime.pure.min.js +6 -0
- package/dist/build/fw.pack.sensors.pure.meta.json +21 -0
- package/dist/build/fw.pack.sensors.pure.min.js +6 -0
- package/dist/build/fw.pack.structures-advanced.pure.meta.json +20 -0
- package/dist/build/fw.pack.structures-advanced.pure.min.js +6 -0
- package/dist/build/fw.pack.text-advanced.pure.meta.json +20 -0
- package/dist/build/fw.pack.text-advanced.pure.min.js +6 -0
- package/dist/build/fw.pwa.pure.meta.json +127 -0
- package/dist/build/fw.pwa.pure.min.js +55 -0
- package/dist/build/fw.site-interactive.pure.meta.json +81 -0
- package/dist/build/fw.site-interactive.pure.min.js +52 -0
- package/dist/build/fw.site.pure.meta.json +51 -0
- package/dist/build/fw.site.pure.min.js +35 -0
- package/dist/build/fw.spa.pure.meta.json +108 -0
- package/dist/build/fw.spa.pure.min.js +55 -0
- package/dist/build/io/compress/brotli_dict.bin +432 -0
- package/dist/build/sanity-base-classic.min.js +6 -0
- package/dist/build/sanity-community-classic.min.js +6 -0
- package/dist/build/sanity.min.js +6 -0
- package/dist/types/core/logger.d.ts +71 -0
- package/dist/types/core/logger.d.ts.map +1 -0
- package/dist/types/core/modules.d.ts +3962 -0
- package/dist/types/core/modules.d.ts.map +1 -0
- package/dist/types/core/readyState.d.ts +14 -0
- package/dist/types/core/readyState.d.ts.map +1 -0
- package/dist/types/core/runtime.d.ts +625 -0
- package/dist/types/core/runtime.d.ts.map +1 -0
- package/dist/types/core/worker-helper.d.ts +153 -0
- package/dist/types/core/worker-helper.d.ts.map +1 -0
- package/dist/types/crypto/cipher/aes.d.ts +55 -0
- package/dist/types/crypto/cipher/aes.d.ts.map +1 -0
- package/dist/types/crypto/cipher/chacha20.d.ts +33 -0
- package/dist/types/crypto/cipher/chacha20.d.ts.map +1 -0
- package/dist/types/crypto/hash/adf.d.ts +65 -0
- package/dist/types/crypto/hash/adf.d.ts.map +1 -0
- package/dist/types/crypto/hash/argon2.d.ts +79 -0
- package/dist/types/crypto/hash/argon2.d.ts.map +1 -0
- package/dist/types/crypto/hash/blake2b.d.ts +40 -0
- package/dist/types/crypto/hash/blake2b.d.ts.map +1 -0
- package/dist/types/crypto/hash/hkdf.d.ts +88 -0
- package/dist/types/crypto/hash/hkdf.d.ts.map +1 -0
- package/dist/types/crypto/hash/hmac.d.ts +85 -0
- package/dist/types/crypto/hash/hmac.d.ts.map +1 -0
- package/dist/types/crypto/hash/pbkdf2.d.ts +80 -0
- package/dist/types/crypto/hash/pbkdf2.d.ts.map +1 -0
- package/dist/types/crypto/hash/poly1305.d.ts +31 -0
- package/dist/types/crypto/hash/poly1305.d.ts.map +1 -0
- package/dist/types/crypto/hash/sha224.d.ts +80 -0
- package/dist/types/crypto/hash/sha224.d.ts.map +1 -0
- package/dist/types/crypto/hash/sha256.d.ts +82 -0
- package/dist/types/crypto/hash/sha256.d.ts.map +1 -0
- package/dist/types/crypto/hash/sha3.d.ts +111 -0
- package/dist/types/crypto/hash/sha3.d.ts.map +1 -0
- package/dist/types/crypto/hash/sha384.d.ts +84 -0
- package/dist/types/crypto/hash/sha384.d.ts.map +1 -0
- package/dist/types/crypto/hash/sha512.d.ts +87 -0
- package/dist/types/crypto/hash/sha512.d.ts.map +1 -0
- package/dist/types/crypto/hash/sha512_224.d.ts +84 -0
- package/dist/types/crypto/hash/sha512_224.d.ts.map +1 -0
- package/dist/types/crypto/hash/sha512_256.d.ts +84 -0
- package/dist/types/crypto/hash/sha512_256.d.ts.map +1 -0
- package/dist/types/crypto/mode/cbc.d.ts +38 -0
- package/dist/types/crypto/mode/cbc.d.ts.map +1 -0
- package/dist/types/crypto/mode/chacha20poly1305.d.ts +71 -0
- package/dist/types/crypto/mode/chacha20poly1305.d.ts.map +1 -0
- package/dist/types/crypto/mode/cmac.d.ts +56 -0
- package/dist/types/crypto/mode/cmac.d.ts.map +1 -0
- package/dist/types/crypto/mode/ctr.d.ts +52 -0
- package/dist/types/crypto/mode/ctr.d.ts.map +1 -0
- package/dist/types/crypto/mode/gcm.d.ts +88 -0
- package/dist/types/crypto/mode/gcm.d.ts.map +1 -0
- package/dist/types/crypto/mode/kw.d.ts +60 -0
- package/dist/types/crypto/mode/kw.d.ts.map +1 -0
- package/dist/types/crypto/pkc/ecc.d.ts +284 -0
- package/dist/types/crypto/pkc/ecc.d.ts.map +1 -0
- package/dist/types/crypto/pkc/ed25519.d.ts +107 -0
- package/dist/types/crypto/pkc/ed25519.d.ts.map +1 -0
- package/dist/types/crypto/pkc/hybridKem.d.ts +154 -0
- package/dist/types/crypto/pkc/hybridKem.d.ts.map +1 -0
- package/dist/types/crypto/pkc/hybridSign.d.ts +383 -0
- package/dist/types/crypto/pkc/hybridSign.d.ts.map +1 -0
- package/dist/types/crypto/pkc/ml_dsa.d.ts +174 -0
- package/dist/types/crypto/pkc/ml_dsa.d.ts.map +1 -0
- package/dist/types/crypto/pkc/ml_kem.d.ts +194 -0
- package/dist/types/crypto/pkc/ml_kem.d.ts.map +1 -0
- package/dist/types/crypto/pkc/rsa.d.ts +175 -0
- package/dist/types/crypto/pkc/rsa.d.ts.map +1 -0
- package/dist/types/crypto/pkc/slh_dsa.d.ts +232 -0
- package/dist/types/crypto/pkc/slh_dsa.d.ts.map +1 -0
- package/dist/types/crypto/pkc/x25519.d.ts +37 -0
- package/dist/types/crypto/pkc/x25519.d.ts.map +1 -0
- package/dist/types/crypto/utils/aes_ctr.d.ts +84 -0
- package/dist/types/crypto/utils/aes_ctr.d.ts.map +1 -0
- package/dist/types/crypto/utils/aes_modes.d.ts +128 -0
- package/dist/types/crypto/utils/aes_modes.d.ts.map +1 -0
- package/dist/types/crypto/utils/asn1-oid.d.ts +45 -0
- package/dist/types/crypto/utils/asn1-oid.d.ts.map +1 -0
- package/dist/types/crypto/utils/asn1.d.ts +115 -0
- package/dist/types/crypto/utils/asn1.d.ts.map +1 -0
- package/dist/types/crypto/utils/bitArray.d.ts +75 -0
- package/dist/types/crypto/utils/bitArray.d.ts.map +1 -0
- package/dist/types/crypto/utils/bn.d.ts +214 -0
- package/dist/types/crypto/utils/bn.d.ts.map +1 -0
- package/dist/types/crypto/utils/jws.d.ts +159 -0
- package/dist/types/crypto/utils/jws.d.ts.map +1 -0
- package/dist/types/crypto/utils/keyformat.d.ts +100 -0
- package/dist/types/crypto/utils/keyformat.d.ts.map +1 -0
- package/dist/types/crypto/utils/pad.d.ts +44 -0
- package/dist/types/crypto/utils/pad.d.ts.map +1 -0
- package/dist/types/crypto/utils/pem.d.ts +41 -0
- package/dist/types/crypto/utils/pem.d.ts.map +1 -0
- package/dist/types/crypto/utils/random.d.ts +203 -0
- package/dist/types/crypto/utils/random.d.ts.map +1 -0
- package/dist/types/crypto/utils/rsaKeygen.d.ts +162 -0
- package/dist/types/crypto/utils/rsaKeygen.d.ts.map +1 -0
- package/dist/types/crypto/utils/totp.d.ts +183 -0
- package/dist/types/crypto/utils/totp.d.ts.map +1 -0
- package/dist/types/crypto/utils/uuid.d.ts +29 -0
- package/dist/types/crypto/utils/uuid.d.ts.map +1 -0
- package/dist/types/crypto/wasm/aes.d.ts +59 -0
- package/dist/types/crypto/wasm/aes.d.ts.map +1 -0
- package/dist/types/crypto/wasm/argon2.d.ts +70 -0
- package/dist/types/crypto/wasm/argon2.d.ts.map +1 -0
- package/dist/types/crypto/wasm/blake2b.d.ts +59 -0
- package/dist/types/crypto/wasm/blake2b.d.ts.map +1 -0
- package/dist/types/crypto/wasm/chacha20poly1305.d.ts +43 -0
- package/dist/types/crypto/wasm/chacha20poly1305.d.ts.map +1 -0
- package/dist/types/crypto/wasm/cmac.d.ts +42 -0
- package/dist/types/crypto/wasm/cmac.d.ts.map +1 -0
- package/dist/types/crypto/wasm/ecc.d.ts +56 -0
- package/dist/types/crypto/wasm/ecc.d.ts.map +1 -0
- package/dist/types/crypto/wasm/ed25519.d.ts +52 -0
- package/dist/types/crypto/wasm/ed25519.d.ts.map +1 -0
- package/dist/types/crypto/wasm/hkdf.d.ts +40 -0
- package/dist/types/crypto/wasm/hkdf.d.ts.map +1 -0
- package/dist/types/crypto/wasm/hmac.d.ts +42 -0
- package/dist/types/crypto/wasm/hmac.d.ts.map +1 -0
- package/dist/types/crypto/wasm/ml_dsa.d.ts +48 -0
- package/dist/types/crypto/wasm/ml_dsa.d.ts.map +1 -0
- package/dist/types/crypto/wasm/ml_kem.d.ts +58 -0
- package/dist/types/crypto/wasm/ml_kem.d.ts.map +1 -0
- package/dist/types/crypto/wasm/pbkdf2.d.ts +38 -0
- package/dist/types/crypto/wasm/pbkdf2.d.ts.map +1 -0
- package/dist/types/crypto/wasm/rsa.d.ts +56 -0
- package/dist/types/crypto/wasm/rsa.d.ts.map +1 -0
- package/dist/types/crypto/wasm/runtime.d.ts +99 -0
- package/dist/types/crypto/wasm/runtime.d.ts.map +1 -0
- package/dist/types/crypto/wasm/sha2.d.ts +45 -0
- package/dist/types/crypto/wasm/sha2.d.ts.map +1 -0
- package/dist/types/crypto/wasm/sha3.d.ts +57 -0
- package/dist/types/crypto/wasm/sha3.d.ts.map +1 -0
- package/dist/types/crypto/wasm/slh_dsa.d.ts +62 -0
- package/dist/types/crypto/wasm/slh_dsa.d.ts.map +1 -0
- package/dist/types/crypto/wasm/x25519.d.ts +53 -0
- package/dist/types/crypto/wasm/x25519.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/aes.d.ts +59 -0
- package/dist/types/crypto/webcrypto/aes.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/aeskw.d.ts +40 -0
- package/dist/types/crypto/webcrypto/aeskw.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/digest.d.ts +43 -0
- package/dist/types/crypto/webcrypto/digest.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/ecc.d.ts +51 -0
- package/dist/types/crypto/webcrypto/ecc.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/ed25519.d.ts +43 -0
- package/dist/types/crypto/webcrypto/ed25519.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/hkdf.d.ts +18 -0
- package/dist/types/crypto/webcrypto/hkdf.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/hmac.d.ts +43 -0
- package/dist/types/crypto/webcrypto/hmac.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/pbkdf2.d.ts +18 -0
- package/dist/types/crypto/webcrypto/pbkdf2.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/rsa.d.ts +51 -0
- package/dist/types/crypto/webcrypto/rsa.d.ts.map +1 -0
- package/dist/types/crypto/webcrypto/x25519.d.ts +43 -0
- package/dist/types/crypto/webcrypto/x25519.d.ts.map +1 -0
- package/dist/types/dom/display/animate.d.ts +35 -0
- package/dist/types/dom/display/animate.d.ts.map +1 -0
- package/dist/types/dom/display/fullscreen.d.ts +59 -0
- package/dist/types/dom/display/fullscreen.d.ts.map +1 -0
- package/dist/types/dom/fs/download.d.ts +36 -0
- package/dist/types/dom/fs/download.d.ts.map +1 -0
- package/dist/types/dom/fs/fsAccess.d.ts +107 -0
- package/dist/types/dom/fs/fsAccess.d.ts.map +1 -0
- package/dist/types/dom/fs/indexedDB.d.ts +62 -0
- package/dist/types/dom/fs/indexedDB.d.ts.map +1 -0
- package/dist/types/dom/fs/remoteStore.d.ts +64 -0
- package/dist/types/dom/fs/remoteStore.d.ts.map +1 -0
- package/dist/types/dom/fs/storage.d.ts +56 -0
- package/dist/types/dom/fs/storage.d.ts.map +1 -0
- package/dist/types/dom/lifecycle/idle.d.ts +91 -0
- package/dist/types/dom/lifecycle/idle.d.ts.map +1 -0
- package/dist/types/dom/lifecycle/visibility.d.ts +49 -0
- package/dist/types/dom/lifecycle/visibility.d.ts.map +1 -0
- package/dist/types/dom/lifecycle/wakeLock.d.ts +69 -0
- package/dist/types/dom/lifecycle/wakeLock.d.ts.map +1 -0
- package/dist/types/dom/net/ajax.d.ts +27 -0
- package/dist/types/dom/net/ajax.d.ts.map +1 -0
- package/dist/types/dom/net/broadcastChannel.d.ts +51 -0
- package/dist/types/dom/net/broadcastChannel.d.ts.map +1 -0
- package/dist/types/dom/net/network.d.ts +80 -0
- package/dist/types/dom/net/network.d.ts.map +1 -0
- package/dist/types/dom/net/sse.d.ts +72 -0
- package/dist/types/dom/net/sse.d.ts.map +1 -0
- package/dist/types/dom/net/webrtc.d.ts +149 -0
- package/dist/types/dom/net/webrtc.d.ts.map +1 -0
- package/dist/types/dom/net/ws.d.ts +70 -0
- package/dist/types/dom/net/ws.d.ts.map +1 -0
- package/dist/types/dom/query/dnd.d.ts +86 -0
- package/dist/types/dom/query/dnd.d.ts.map +1 -0
- package/dist/types/dom/query/dom.d.ts +194 -0
- package/dist/types/dom/query/dom.d.ts.map +1 -0
- package/dist/types/dom/query/events.d.ts +135 -0
- package/dist/types/dom/query/events.d.ts.map +1 -0
- package/dist/types/dom/query/gesture.d.ts +59 -0
- package/dist/types/dom/query/gesture.d.ts.map +1 -0
- package/dist/types/dom/query/media.d.ts +156 -0
- package/dist/types/dom/query/media.d.ts.map +1 -0
- package/dist/types/dom/rendering/chart.d.ts +143 -0
- package/dist/types/dom/rendering/chart.d.ts.map +1 -0
- package/dist/types/dom/rendering/component.d.ts +92 -0
- package/dist/types/dom/rendering/component.d.ts.map +1 -0
- package/dist/types/dom/rendering/devtools-ui.d.ts +83 -0
- package/dist/types/dom/rendering/devtools-ui.d.ts.map +1 -0
- package/dist/types/dom/rendering/devtools.d.ts +68 -0
- package/dist/types/dom/rendering/devtools.d.ts.map +1 -0
- package/dist/types/dom/rendering/parser.d.ts +216 -0
- package/dist/types/dom/rendering/parser.d.ts.map +1 -0
- package/dist/types/dom/rendering/reactiveBind.d.ts +101 -0
- package/dist/types/dom/rendering/reactiveBind.d.ts.map +1 -0
- package/dist/types/dom/rendering/render.d.ts +121 -0
- package/dist/types/dom/rendering/render.d.ts.map +1 -0
- package/dist/types/dom/rendering/sanitize.d.ts +48 -0
- package/dist/types/dom/rendering/sanitize.d.ts.map +1 -0
- package/dist/types/dom/rendering/secPolicy.d.ts +89 -0
- package/dist/types/dom/rendering/secPolicy.d.ts.map +1 -0
- package/dist/types/dom/rendering/template.d.ts +251 -0
- package/dist/types/dom/rendering/template.d.ts.map +1 -0
- package/dist/types/dom/rendering/themeTokens.d.ts +61 -0
- package/dist/types/dom/rendering/themeTokens.d.ts.map +1 -0
- package/dist/types/dom/rendering/uiSession-core.d.ts +192 -0
- package/dist/types/dom/rendering/uiSession-core.d.ts.map +1 -0
- package/dist/types/dom/rendering/uiSession-direct.d.ts +63 -0
- package/dist/types/dom/rendering/uiSession-direct.d.ts.map +1 -0
- package/dist/types/dom/rendering/uiSession-list.d.ts +205 -0
- package/dist/types/dom/rendering/uiSession-list.d.ts.map +1 -0
- package/dist/types/dom/rendering/uiSession.d.ts +285 -0
- package/dist/types/dom/rendering/uiSession.d.ts.map +1 -0
- package/dist/types/dom/rendering/virtualScroll.d.ts +80 -0
- package/dist/types/dom/rendering/virtualScroll.d.ts.map +1 -0
- package/dist/types/dom/sensors/battery.d.ts +71 -0
- package/dist/types/dom/sensors/battery.d.ts.map +1 -0
- package/dist/types/dom/sensors/geolocation.d.ts +83 -0
- package/dist/types/dom/sensors/geolocation.d.ts.map +1 -0
- package/dist/types/dom/sensors/networkInfo.d.ts +82 -0
- package/dist/types/dom/sensors/networkInfo.d.ts.map +1 -0
- package/dist/types/dom/sensors/sensors.d.ts +191 -0
- package/dist/types/dom/sensors/sensors.d.ts.map +1 -0
- package/dist/types/dom/sw/backgroundSync.d.ts +48 -0
- package/dist/types/dom/sw/backgroundSync.d.ts.map +1 -0
- package/dist/types/dom/sw/cache.d.ts +71 -0
- package/dist/types/dom/sw/cache.d.ts.map +1 -0
- package/dist/types/dom/sw/push.d.ts +77 -0
- package/dist/types/dom/sw/push.d.ts.map +1 -0
- package/dist/types/dom/sw/serviceWorker.d.ts +57 -0
- package/dist/types/dom/sw/serviceWorker.d.ts.map +1 -0
- package/dist/types/dom/sw/sharedWorker.d.ts +81 -0
- package/dist/types/dom/sw/sharedWorker.d.ts.map +1 -0
- package/dist/types/dom/utils/a11y.d.ts +53 -0
- package/dist/types/dom/utils/a11y.d.ts.map +1 -0
- package/dist/types/dom/utils/clipboard.d.ts +44 -0
- package/dist/types/dom/utils/clipboard.d.ts.map +1 -0
- package/dist/types/dom/utils/entropyCollector.d.ts +58 -0
- package/dist/types/dom/utils/entropyCollector.d.ts.map +1 -0
- package/dist/types/dom/utils/focus.d.ts +123 -0
- package/dist/types/dom/utils/focus.d.ts.map +1 -0
- package/dist/types/dom/utils/form.d.ts +227 -0
- package/dist/types/dom/utils/form.d.ts.map +1 -0
- package/dist/types/dom/utils/formKit.d.ts +206 -0
- package/dist/types/dom/utils/formKit.d.ts.map +1 -0
- package/dist/types/dom/utils/keybindings.d.ts +53 -0
- package/dist/types/dom/utils/keybindings.d.ts.map +1 -0
- package/dist/types/dom/utils/leaderElection.d.ts +70 -0
- package/dist/types/dom/utils/leaderElection.d.ts.map +1 -0
- package/dist/types/dom/utils/notifications.d.ts +164 -0
- package/dist/types/dom/utils/notifications.d.ts.map +1 -0
- package/dist/types/dom/utils/permissions.d.ts +35 -0
- package/dist/types/dom/utils/permissions.d.ts.map +1 -0
- package/dist/types/dom/utils/route.d.ts +117 -0
- package/dist/types/dom/utils/route.d.ts.map +1 -0
- package/dist/types/dom/utils/ua.d.ts +35 -0
- package/dist/types/dom/utils/ua.d.ts.map +1 -0
- package/dist/types/dom/utils/webauthn.d.ts +98 -0
- package/dist/types/dom/utils/webauthn.d.ts.map +1 -0
- package/dist/types/io/binary/reader.d.ts +59 -0
- package/dist/types/io/binary/reader.d.ts.map +1 -0
- package/dist/types/io/binary/writer.d.ts +56 -0
- package/dist/types/io/binary/writer.d.ts.map +1 -0
- package/dist/types/io/calc/adler32.d.ts +31 -0
- package/dist/types/io/calc/adler32.d.ts.map +1 -0
- package/dist/types/io/calc/bigint.d.ts +74 -0
- package/dist/types/io/calc/bigint.d.ts.map +1 -0
- package/dist/types/io/calc/crc32.d.ts +36 -0
- package/dist/types/io/calc/crc32.d.ts.map +1 -0
- package/dist/types/io/calc/easing.d.ts +60 -0
- package/dist/types/io/calc/easing.d.ts.map +1 -0
- package/dist/types/io/codec/b64.d.ts +28 -0
- package/dist/types/io/codec/b64.d.ts.map +1 -0
- package/dist/types/io/codec/base32.d.ts +28 -0
- package/dist/types/io/codec/base32.d.ts.map +1 -0
- package/dist/types/io/codec/base58.d.ts +28 -0
- package/dist/types/io/codec/base58.d.ts.map +1 -0
- package/dist/types/io/codec/buffer.d.ts +66 -0
- package/dist/types/io/codec/buffer.d.ts.map +1 -0
- package/dist/types/io/codec/cbor.d.ts +43 -0
- package/dist/types/io/codec/cbor.d.ts.map +1 -0
- package/dist/types/io/codec/csv.d.ts +35 -0
- package/dist/types/io/codec/csv.d.ts.map +1 -0
- package/dist/types/io/codec/hex.d.ts +28 -0
- package/dist/types/io/codec/hex.d.ts.map +1 -0
- package/dist/types/io/codec/mime.d.ts +100 -0
- package/dist/types/io/codec/mime.d.ts.map +1 -0
- package/dist/types/io/codec/msgpack.d.ts +36 -0
- package/dist/types/io/codec/msgpack.d.ts.map +1 -0
- package/dist/types/io/codec/url.d.ts +52 -0
- package/dist/types/io/codec/url.d.ts.map +1 -0
- package/dist/types/io/codec/utf8.d.ts +22 -0
- package/dist/types/io/codec/utf8.d.ts.map +1 -0
- package/dist/types/io/codec/xml.d.ts +91 -0
- package/dist/types/io/codec/xml.d.ts.map +1 -0
- package/dist/types/io/compress/bitstream.d.ts +51 -0
- package/dist/types/io/compress/bitstream.d.ts.map +1 -0
- package/dist/types/io/compress/brotli.d.ts +86 -0
- package/dist/types/io/compress/brotli.d.ts.map +1 -0
- package/dist/types/io/compress/brotli_dict.d.ts +76 -0
- package/dist/types/io/compress/brotli_dict.d.ts.map +1 -0
- package/dist/types/io/compress/brotli_dict_words.d.ts +43 -0
- package/dist/types/io/compress/brotli_dict_words.d.ts.map +1 -0
- package/dist/types/io/compress/brotli_frame.d.ts +166 -0
- package/dist/types/io/compress/brotli_frame.d.ts.map +1 -0
- package/dist/types/io/compress/brotli_shared.d.ts +165 -0
- package/dist/types/io/compress/brotli_shared.d.ts.map +1 -0
- package/dist/types/io/compress/deflate.d.ts +89 -0
- package/dist/types/io/compress/deflate.d.ts.map +1 -0
- package/dist/types/io/compress/gzip.d.ts +100 -0
- package/dist/types/io/compress/gzip.d.ts.map +1 -0
- package/dist/types/io/compress/huffman.d.ts +37 -0
- package/dist/types/io/compress/huffman.d.ts.map +1 -0
- package/dist/types/io/compress/lz4.d.ts +45 -0
- package/dist/types/io/compress/lz4.d.ts.map +1 -0
- package/dist/types/io/compress/lz77.d.ts +66 -0
- package/dist/types/io/compress/lz77.d.ts.map +1 -0
- package/dist/types/io/compress/lzw.d.ts +37 -0
- package/dist/types/io/compress/lzw.d.ts.map +1 -0
- package/dist/types/io/compress/zip.d.ts +112 -0
- package/dist/types/io/compress/zip.d.ts.map +1 -0
- package/dist/types/io/compress/zlib.d.ts +97 -0
- package/dist/types/io/compress/zlib.d.ts.map +1 -0
- package/dist/types/io/i18n/i18n.d.ts +64 -0
- package/dist/types/io/i18n/i18n.d.ts.map +1 -0
- package/dist/types/io/math/fixed-point.d.ts +30 -0
- package/dist/types/io/math/fixed-point.d.ts.map +1 -0
- package/dist/types/io/math/geom.d.ts +125 -0
- package/dist/types/io/math/geom.d.ts.map +1 -0
- package/dist/types/io/math/interp.d.ts +48 -0
- package/dist/types/io/math/interp.d.ts.map +1 -0
- package/dist/types/io/math/linalg.d.ts +117 -0
- package/dist/types/io/math/linalg.d.ts.map +1 -0
- package/dist/types/io/math/stats.d.ts +45 -0
- package/dist/types/io/math/stats.d.ts.map +1 -0
- package/dist/types/io/structures/btree.d.ts +84 -0
- package/dist/types/io/structures/btree.d.ts.map +1 -0
- package/dist/types/io/structures/heap.d.ts +75 -0
- package/dist/types/io/structures/heap.d.ts.map +1 -0
- package/dist/types/io/structures/lruCache.d.ts +88 -0
- package/dist/types/io/structures/lruCache.d.ts.map +1 -0
- package/dist/types/io/structures/ringBuffer.d.ts +82 -0
- package/dist/types/io/structures/ringBuffer.d.ts.map +1 -0
- package/dist/types/io/structures/tree-walker.d.ts +95 -0
- package/dist/types/io/structures/tree-walker.d.ts.map +1 -0
- package/dist/types/io/structures/trie.d.ts +71 -0
- package/dist/types/io/structures/trie.d.ts.map +1 -0
- package/dist/types/io/sync/abort.d.ts +59 -0
- package/dist/types/io/sync/abort.d.ts.map +1 -0
- package/dist/types/io/sync/atomics.d.ts +107 -0
- package/dist/types/io/sync/atomics.d.ts.map +1 -0
- package/dist/types/io/sync/cancellable.d.ts +69 -0
- package/dist/types/io/sync/cancellable.d.ts.map +1 -0
- package/dist/types/io/sync/channel.d.ts +70 -0
- package/dist/types/io/sync/channel.d.ts.map +1 -0
- package/dist/types/io/sync/mutex.d.ts +39 -0
- package/dist/types/io/sync/mutex.d.ts.map +1 -0
- package/dist/types/io/sync/semaphore.d.ts +40 -0
- package/dist/types/io/sync/semaphore.d.ts.map +1 -0
- package/dist/types/io/sync/tokenBucket.d.ts +53 -0
- package/dist/types/io/sync/tokenBucket.d.ts.map +1 -0
- package/dist/types/io/text/ansi.d.ts +125 -0
- package/dist/types/io/text/ansi.d.ts.map +1 -0
- package/dist/types/io/text/html-entities.d.ts +35 -0
- package/dist/types/io/text/html-entities.d.ts.map +1 -0
- package/dist/types/io/text/semver.d.ts +75 -0
- package/dist/types/io/text/semver.d.ts.map +1 -0
- package/dist/types/io/text/str.d.ts +88 -0
- package/dist/types/io/text/str.d.ts.map +1 -0
- package/dist/types/io/text/unicode.d.ts +70 -0
- package/dist/types/io/text/unicode.d.ts.map +1 -0
- package/dist/types/io/time/date.d.ts +73 -0
- package/dist/types/io/time/date.d.ts.map +1 -0
- package/dist/types/io/timing/clock.d.ts +39 -0
- package/dist/types/io/timing/clock.d.ts.map +1 -0
- package/dist/types/io/timing/rateLimit.d.ts +40 -0
- package/dist/types/io/timing/rateLimit.d.ts.map +1 -0
- package/dist/types/io/timing/scheduler.d.ts +122 -0
- package/dist/types/io/timing/scheduler.d.ts.map +1 -0
- package/dist/types/io/utils/bitmap.d.ts +34 -0
- package/dist/types/io/utils/bitmap.d.ts.map +1 -0
- package/dist/types/io/utils/errors.d.ts +94 -0
- package/dist/types/io/utils/errors.d.ts.map +1 -0
- package/dist/types/io/utils/eventBus.d.ts +68 -0
- package/dist/types/io/utils/eventBus.d.ts.map +1 -0
- package/dist/types/io/utils/queue.d.ts +69 -0
- package/dist/types/io/utils/queue.d.ts.map +1 -0
- package/dist/types/io/utils/signal.d.ts +362 -0
- package/dist/types/io/utils/signal.d.ts.map +1 -0
- package/dist/types/io/utils/ui8.d.ts +34 -0
- package/dist/types/io/utils/ui8.d.ts.map +1 -0
- package/dist/types/io/utils/valid.d.ts +130 -0
- package/dist/types/io/utils/valid.d.ts.map +1 -0
- package/dist/types/main.d.ts +25 -0
- package/dist/types/main.d.ts.map +1 -0
- package/dist/types/process/message.d.ts +64 -0
- package/dist/types/process/message.d.ts.map +1 -0
- package/dist/types/process/rpc.d.ts +35 -0
- package/dist/types/process/rpc.d.ts.map +1 -0
- package/dist/types/process/workerPool.d.ts +62 -0
- package/dist/types/process/workerPool.d.ts.map +1 -0
- package/dist/types/sanity/base.d.ts +28 -0
- package/dist/types/sanity/base.d.ts.map +1 -0
- package/dist/types/sanity/community.d.ts +20 -0
- package/dist/types/sanity/community.d.ts.map +1 -0
- package/dist/types/sanity/lockdown-apply.d.ts +7 -0
- package/dist/types/sanity/lockdown-apply.d.ts.map +1 -0
- package/dist/types/sanity/lockdown.d.ts +43 -0
- package/dist/types/sanity/lockdown.d.ts.map +1 -0
- package/dist/types/sanity/wasm-gate.d.ts +128 -0
- package/dist/types/sanity/wasm-gate.d.ts.map +1 -0
- package/docs/README.md +301 -0
- package/docs/api/README.md +33 -0
- package/docs/api/core/README.md +14 -0
- package/docs/api/core/logger.md +151 -0
- package/docs/api/core/main.md +105 -0
- package/docs/api/core/modules.md +123 -0
- package/docs/api/core/readyState.md +94 -0
- package/docs/api/core/runtime.md +499 -0
- package/docs/api/core/worker-helper.md +180 -0
- package/docs/api/crypto/README.md +39 -0
- package/docs/api/crypto/cipher/README.md +24 -0
- package/docs/api/crypto/cipher/aes.md +101 -0
- package/docs/api/crypto/cipher/chacha20.md +85 -0
- package/docs/api/crypto/hash/README.md +49 -0
- package/docs/api/crypto/hash/adf.md +61 -0
- package/docs/api/crypto/hash/argon2.md +92 -0
- package/docs/api/crypto/hash/blake2b.md +88 -0
- package/docs/api/crypto/hash/hkdf.md +82 -0
- package/docs/api/crypto/hash/hmac.md +90 -0
- package/docs/api/crypto/hash/pbkdf2.md +93 -0
- package/docs/api/crypto/hash/poly1305.md +71 -0
- package/docs/api/crypto/hash/sha224.md +61 -0
- package/docs/api/crypto/hash/sha256.md +84 -0
- package/docs/api/crypto/hash/sha3.md +89 -0
- package/docs/api/crypto/hash/sha384.md +58 -0
- package/docs/api/crypto/hash/sha512.md +73 -0
- package/docs/api/crypto/hash/sha512_224.md +59 -0
- package/docs/api/crypto/hash/sha512_256.md +58 -0
- package/docs/api/crypto/mode/README.md +33 -0
- package/docs/api/crypto/mode/cbc.md +69 -0
- package/docs/api/crypto/mode/chacha20poly1305.md +77 -0
- package/docs/api/crypto/mode/cmac.md +79 -0
- package/docs/api/crypto/mode/ctr.md +66 -0
- package/docs/api/crypto/mode/gcm.md +93 -0
- package/docs/api/crypto/mode/kw.md +84 -0
- package/docs/api/crypto/pkc/README.md +48 -0
- package/docs/api/crypto/pkc/ecc.md +91 -0
- package/docs/api/crypto/pkc/ed25519.md +99 -0
- package/docs/api/crypto/pkc/hybridKem.md +178 -0
- package/docs/api/crypto/pkc/hybridSign.md +192 -0
- package/docs/api/crypto/pkc/ml_dsa.md +99 -0
- package/docs/api/crypto/pkc/ml_kem.md +90 -0
- package/docs/api/crypto/pkc/rsa.md +87 -0
- package/docs/api/crypto/pkc/slh_dsa.md +86 -0
- package/docs/api/crypto/pkc/x25519.md +84 -0
- package/docs/api/crypto/utils/README.md +39 -0
- package/docs/api/crypto/utils/aes_ctr.md +71 -0
- package/docs/api/crypto/utils/aes_modes.md +81 -0
- package/docs/api/crypto/utils/asn1-oid.md +130 -0
- package/docs/api/crypto/utils/asn1.md +69 -0
- package/docs/api/crypto/utils/bitArray.md +77 -0
- package/docs/api/crypto/utils/bn.md +67 -0
- package/docs/api/crypto/utils/jws.md +94 -0
- package/docs/api/crypto/utils/keyformat.md +78 -0
- package/docs/api/crypto/utils/pad.md +66 -0
- package/docs/api/crypto/utils/pem.md +63 -0
- package/docs/api/crypto/utils/random.md +103 -0
- package/docs/api/crypto/utils/rsaKeygen.md +118 -0
- package/docs/api/crypto/utils/totp.md +159 -0
- package/docs/api/crypto/utils/uuid.md +98 -0
- package/docs/api/crypto/wasm/README.md +76 -0
- package/docs/api/crypto/wasm/aes.md +128 -0
- package/docs/api/crypto/wasm/argon2.md +110 -0
- package/docs/api/crypto/wasm/blake2b.md +103 -0
- package/docs/api/crypto/wasm/chacha20poly1305.md +120 -0
- package/docs/api/crypto/wasm/cmac.md +119 -0
- package/docs/api/crypto/wasm/ecc.md +114 -0
- package/docs/api/crypto/wasm/ed25519.md +117 -0
- package/docs/api/crypto/wasm/hkdf.md +163 -0
- package/docs/api/crypto/wasm/hmac.md +129 -0
- package/docs/api/crypto/wasm/ml_dsa.md +99 -0
- package/docs/api/crypto/wasm/ml_kem.md +91 -0
- package/docs/api/crypto/wasm/pbkdf2.md +111 -0
- package/docs/api/crypto/wasm/rsa.md +113 -0
- package/docs/api/crypto/wasm/runtime.md +172 -0
- package/docs/api/crypto/wasm/sha2.md +95 -0
- package/docs/api/crypto/wasm/sha3.md +127 -0
- package/docs/api/crypto/wasm/slh_dsa.md +89 -0
- package/docs/api/crypto/wasm/x25519.md +116 -0
- package/docs/api/crypto/webcrypto/README.md +56 -0
- package/docs/api/crypto/webcrypto/aes.md +140 -0
- package/docs/api/crypto/webcrypto/aeskw.md +120 -0
- package/docs/api/crypto/webcrypto/digest.md +103 -0
- package/docs/api/crypto/webcrypto/ecc.md +122 -0
- package/docs/api/crypto/webcrypto/ed25519.md +121 -0
- package/docs/api/crypto/webcrypto/hkdf.md +141 -0
- package/docs/api/crypto/webcrypto/hmac.md +112 -0
- package/docs/api/crypto/webcrypto/pbkdf2.md +140 -0
- package/docs/api/crypto/webcrypto/rsa.md +149 -0
- package/docs/api/crypto/webcrypto/x25519.md +96 -0
- package/docs/api/dom/README.md +117 -0
- package/docs/api/dom/display/README.md +27 -0
- package/docs/api/dom/display/animate.md +113 -0
- package/docs/api/dom/display/fullscreen.md +121 -0
- package/docs/api/dom/fs/README.md +36 -0
- package/docs/api/dom/fs/download.md +108 -0
- package/docs/api/dom/fs/fsAccess.md +200 -0
- package/docs/api/dom/fs/indexedDB.md +219 -0
- package/docs/api/dom/fs/remoteStore.md +158 -0
- package/docs/api/dom/fs/storage.md +197 -0
- package/docs/api/dom/lifecycle/README.md +11 -0
- package/docs/api/dom/lifecycle/idle.md +89 -0
- package/docs/api/dom/lifecycle/visibility.md +73 -0
- package/docs/api/dom/lifecycle/wakeLock.md +94 -0
- package/docs/api/dom/net/README.md +31 -0
- package/docs/api/dom/net/ajax.md +176 -0
- package/docs/api/dom/net/broadcastChannel.md +110 -0
- package/docs/api/dom/net/network.md +137 -0
- package/docs/api/dom/net/sse.md +141 -0
- package/docs/api/dom/net/webrtc.md +158 -0
- package/docs/api/dom/net/ws.md +168 -0
- package/docs/api/dom/query/README.md +30 -0
- package/docs/api/dom/query/dnd.md +137 -0
- package/docs/api/dom/query/dom.md +275 -0
- package/docs/api/dom/query/events.md +211 -0
- package/docs/api/dom/query/gesture.md +137 -0
- package/docs/api/dom/query/media.md +188 -0
- package/docs/api/dom/rendering/README.md +41 -0
- package/docs/api/dom/rendering/chart.md +149 -0
- package/docs/api/dom/rendering/component.md +287 -0
- package/docs/api/dom/rendering/devtools-ui.md +129 -0
- package/docs/api/dom/rendering/devtools.md +157 -0
- package/docs/api/dom/rendering/parser.md +200 -0
- package/docs/api/dom/rendering/reactiveBind.md +234 -0
- package/docs/api/dom/rendering/render.md +219 -0
- package/docs/api/dom/rendering/sanitize.md +97 -0
- package/docs/api/dom/rendering/secPolicy.md +155 -0
- package/docs/api/dom/rendering/template.md +301 -0
- package/docs/api/dom/rendering/themeTokens.md +175 -0
- package/docs/api/dom/rendering/uiSession.md +546 -0
- package/docs/api/dom/rendering/virtualScroll.md +126 -0
- package/docs/api/dom/sensors/README.md +12 -0
- package/docs/api/dom/sensors/battery.md +70 -0
- package/docs/api/dom/sensors/geolocation.md +115 -0
- package/docs/api/dom/sensors/networkInfo.md +73 -0
- package/docs/api/dom/sensors/sensors.md +123 -0
- package/docs/api/dom/sw/README.md +31 -0
- package/docs/api/dom/sw/backgroundSync.md +145 -0
- package/docs/api/dom/sw/cache.md +116 -0
- package/docs/api/dom/sw/push.md +114 -0
- package/docs/api/dom/sw/serviceWorker.md +90 -0
- package/docs/api/dom/sw/sharedWorker.md +131 -0
- package/docs/api/dom/utils/README.md +25 -0
- package/docs/api/dom/utils/a11y.md +143 -0
- package/docs/api/dom/utils/clipboard.md +146 -0
- package/docs/api/dom/utils/entropyCollector.md +175 -0
- package/docs/api/dom/utils/focus.md +140 -0
- package/docs/api/dom/utils/form.md +196 -0
- package/docs/api/dom/utils/formKit.md +181 -0
- package/docs/api/dom/utils/keybindings.md +138 -0
- package/docs/api/dom/utils/leaderElection.md +130 -0
- package/docs/api/dom/utils/notifications.md +106 -0
- package/docs/api/dom/utils/permissions.md +82 -0
- package/docs/api/dom/utils/route.md +112 -0
- package/docs/api/dom/utils/ua.md +119 -0
- package/docs/api/dom/utils/webauthn.md +190 -0
- package/docs/api/io/README.md +20 -0
- package/docs/api/io/binary/README.md +29 -0
- package/docs/api/io/binary/reader.md +126 -0
- package/docs/api/io/binary/writer.md +127 -0
- package/docs/api/io/calc/README.md +22 -0
- package/docs/api/io/calc/adler32.md +75 -0
- package/docs/api/io/calc/bigint.md +105 -0
- package/docs/api/io/calc/crc32.md +74 -0
- package/docs/api/io/calc/easing.md +118 -0
- package/docs/api/io/codec/README.md +35 -0
- package/docs/api/io/codec/b64.md +92 -0
- package/docs/api/io/codec/base32.md +98 -0
- package/docs/api/io/codec/base58.md +104 -0
- package/docs/api/io/codec/buffer.md +144 -0
- package/docs/api/io/codec/cbor.md +179 -0
- package/docs/api/io/codec/csv.md +178 -0
- package/docs/api/io/codec/hex.md +75 -0
- package/docs/api/io/codec/mime.md +156 -0
- package/docs/api/io/codec/msgpack.md +142 -0
- package/docs/api/io/codec/url.md +265 -0
- package/docs/api/io/codec/utf8.md +84 -0
- package/docs/api/io/codec/xml.md +87 -0
- package/docs/api/io/compress/README.md +62 -0
- package/docs/api/io/compress/bitstream.md +131 -0
- package/docs/api/io/compress/brotli.md +232 -0
- package/docs/api/io/compress/brotli_dict.md +119 -0
- package/docs/api/io/compress/brotli_dict_words.md +142 -0
- package/docs/api/io/compress/brotli_frame.md +214 -0
- package/docs/api/io/compress/brotli_shared.md +144 -0
- package/docs/api/io/compress/deflate.md +474 -0
- package/docs/api/io/compress/gzip.md +130 -0
- package/docs/api/io/compress/huffman.md +210 -0
- package/docs/api/io/compress/lz4.md +278 -0
- package/docs/api/io/compress/lz77.md +180 -0
- package/docs/api/io/compress/lzw.md +121 -0
- package/docs/api/io/compress/zip.md +209 -0
- package/docs/api/io/compress/zlib.md +125 -0
- package/docs/api/io/i18n/README.md +23 -0
- package/docs/api/io/i18n/i18n.md +128 -0
- package/docs/api/io/math/README.md +24 -0
- package/docs/api/io/math/fixed-point.md +115 -0
- package/docs/api/io/math/geom.md +144 -0
- package/docs/api/io/math/interp.md +115 -0
- package/docs/api/io/math/linalg.md +138 -0
- package/docs/api/io/math/stats.md +109 -0
- package/docs/api/io/structures/README.md +31 -0
- package/docs/api/io/structures/btree.md +155 -0
- package/docs/api/io/structures/heap.md +166 -0
- package/docs/api/io/structures/lruCache.md +156 -0
- package/docs/api/io/structures/ringBuffer.md +188 -0
- package/docs/api/io/structures/tree-walker.md +132 -0
- package/docs/api/io/structures/trie.md +138 -0
- package/docs/api/io/sync/README.md +29 -0
- package/docs/api/io/sync/abort.md +129 -0
- package/docs/api/io/sync/atomics.md +159 -0
- package/docs/api/io/sync/cancellable.md +176 -0
- package/docs/api/io/sync/channel.md +125 -0
- package/docs/api/io/sync/mutex.md +93 -0
- package/docs/api/io/sync/semaphore.md +106 -0
- package/docs/api/io/sync/tokenBucket.md +139 -0
- package/docs/api/io/text/README.md +23 -0
- package/docs/api/io/text/ansi.md +182 -0
- package/docs/api/io/text/html-entities.md +79 -0
- package/docs/api/io/text/semver.md +158 -0
- package/docs/api/io/text/str.md +129 -0
- package/docs/api/io/text/unicode.md +89 -0
- package/docs/api/io/time/README.md +22 -0
- package/docs/api/io/time/date.md +128 -0
- package/docs/api/io/timing/README.md +32 -0
- package/docs/api/io/timing/clock.md +102 -0
- package/docs/api/io/timing/rateLimit.md +137 -0
- package/docs/api/io/timing/scheduler.md +163 -0
- package/docs/api/io/utils/README.md +30 -0
- package/docs/api/io/utils/bitmap.md +96 -0
- package/docs/api/io/utils/errors.md +165 -0
- package/docs/api/io/utils/eventBus.md +162 -0
- package/docs/api/io/utils/queue.md +141 -0
- package/docs/api/io/utils/signal.md +388 -0
- package/docs/api/io/utils/ui8.md +111 -0
- package/docs/api/io/utils/valid.md +272 -0
- package/docs/api/process/README.md +18 -0
- package/docs/api/process/message.md +166 -0
- package/docs/api/process/rpc.md +161 -0
- package/docs/api/process/workerPool.md +130 -0
- package/docs/api/sanity/base.md +132 -0
- package/docs/api/sanity/community.md +96 -0
- package/docs/api/sanity/lockdown.md +128 -0
- package/docs/api/typed.md +85 -0
- package/docs/dev/README.md +25 -0
- package/docs/dev/provenance.md +80 -0
- package/docs/dev/publishing.md +31 -0
- package/docs/dev/runtime.md +64 -0
- package/docs/dev/testing.md +61 -0
- package/docs/dev/types.md +35 -0
- package/docs/evidence/pqc-hybrid-evidence.md +438 -0
- package/docs/guide/README.md +38 -0
- package/docs/guide/_QUICK_REF.md +341 -0
- package/docs/guide/by-use-case.md +160 -0
- package/docs/guide/doc-format.md +306 -0
- package/docs/guide/gesture-dnd-side-channel.md +119 -0
- package/docs/guide/getting-started.md +134 -0
- package/docs/guide/hmr.md +187 -0
- package/docs/guide/integration-bundlers.md +193 -0
- package/docs/guide/integrations-hmr.md +103 -0
- package/docs/guide/module-creation-workflow.md +342 -0
- package/docs/guide/module-pattern.md +244 -0
- package/docs/guide/rendering-pipeline.md +422 -0
- package/docs/guide/security.md +346 -0
- package/docs/guide/test-format.md +190 -0
- package/docs/guide/tutorial-todo.md +298 -0
- package/docs/guide/typescript.md +215 -0
- package/docs/guide/worker-confinement.md +301 -0
- package/docs/guide/workers.md +168 -0
- package/docs/notes/lz77-deflate-factorization.md +96 -0
- package/docs/notes/worker-confinement-spike.md +302 -0
- package/docs/tools/README.md +56 -0
- package/docs/tools/aot.md +108 -0
- package/docs/tools/audit.md +61 -0
- package/docs/tools/bundler.md +215 -0
- package/docs/tools/codegen.md +64 -0
- package/docs/tools/jsx.md +236 -0
- package/docs/tools/precompilation.md +88 -0
- package/docs/tools/standalone.md +107 -0
- package/fw.config.json +129 -0
- package/integrations/README.md +52 -0
- package/integrations/_shared/catalog.generated.json +207 -0
- package/integrations/_shared/config-resolve.js +201 -0
- package/integrations/_shared/core.js +362 -0
- package/integrations/astro/README.md +96 -0
- package/integrations/astro/index.d.ts +42 -0
- package/integrations/astro/index.js +94 -0
- package/integrations/bun/README.md +62 -0
- package/integrations/bun/index.d.ts +30 -0
- package/integrations/bun/index.js +134 -0
- package/integrations/deno/README.md +55 -0
- package/integrations/deno/deno.json +10 -0
- package/integrations/esbuild/README.md +75 -0
- package/integrations/esbuild/backend.js +147 -0
- package/integrations/esbuild/index.d.ts +32 -0
- package/integrations/esbuild/index.js +147 -0
- package/integrations/eslint/README.md +27 -0
- package/integrations/eslint/no-factory-capture.js +99 -0
- package/integrations/jest/README.md +45 -0
- package/integrations/jest/bun-test-shim.js +43 -0
- package/integrations/nestjs/README.md +68 -0
- package/integrations/nestjs/index.d.ts +38 -0
- package/integrations/nestjs/index.js +99 -0
- package/integrations/nextjs/README.md +149 -0
- package/integrations/nextjs/index.d.ts +30 -0
- package/integrations/nextjs/index.js +98 -0
- package/integrations/nodejs/README.md +46 -0
- package/integrations/nodejs/package.node.example.json +31 -0
- package/integrations/rollup/README.md +65 -0
- package/integrations/rollup/backend.js +132 -0
- package/integrations/rollup/index.d.ts +32 -0
- package/integrations/rollup/index.js +84 -0
- package/integrations/turbopack/README.md +56 -0
- package/integrations/turbopack/index.d.ts +47 -0
- package/integrations/turbopack/index.js +164 -0
- package/integrations/typedoc/README.md +57 -0
- package/integrations/typedoc/categorize.js +121 -0
- package/integrations/typedoc/tsconfig.typedoc.json +14 -0
- package/integrations/typedoc/typedoc.json +19 -0
- package/integrations/vite/README.md +115 -0
- package/integrations/vite/index.d.ts +29 -0
- package/integrations/vite/index.js +182 -0
- package/integrations/vite/package.json +8 -0
- package/integrations/vite/vite-env.d.ts +36 -0
- package/integrations/vitest/README.md +77 -0
- package/integrations/vitest/bun-test-shim.js +92 -0
- package/integrations/vitest/vitest.config.js +41 -0
- package/integrations/webpack/README.md +53 -0
- package/integrations/webpack/index.d.ts +29 -0
- package/integrations/webpack/index.js +182 -0
- package/package.json +303 -0
- package/src/core/logger.js +373 -0
- package/src/core/modules.js +289 -0
- package/src/core/readyState.js +119 -0
- package/src/core/runtime.js +929 -0
- package/src/core/worker-helper.js +261 -0
- package/src/crypto/NIST_CONFORMANCE.md +249 -0
- package/src/crypto/cipher/aes.acvp.md +74 -0
- package/src/crypto/cipher/aes.js +512 -0
- package/src/crypto/cipher/chacha20.acvp.md +117 -0
- package/src/crypto/cipher/chacha20.js +147 -0
- package/src/crypto/hash/adf.acvp.md +144 -0
- package/src/crypto/hash/adf.js +127 -0
- package/src/crypto/hash/argon2.acvp.md +144 -0
- package/src/crypto/hash/argon2.js +517 -0
- package/src/crypto/hash/blake2b.acvp.md +122 -0
- package/src/crypto/hash/blake2b.js +367 -0
- package/src/crypto/hash/hkdf.acvp.md +128 -0
- package/src/crypto/hash/hkdf.js +145 -0
- package/src/crypto/hash/hmac.acvp.md +110 -0
- package/src/crypto/hash/hmac.js +177 -0
- package/src/crypto/hash/pbkdf2.acvp.md +122 -0
- package/src/crypto/hash/pbkdf2.js +120 -0
- package/src/crypto/hash/poly1305.acvp.md +111 -0
- package/src/crypto/hash/poly1305.js +126 -0
- package/src/crypto/hash/sha224.acvp.md +81 -0
- package/src/crypto/hash/sha224.js +60 -0
- package/src/crypto/hash/sha256.acvp.md +75 -0
- package/src/crypto/hash/sha256.js +217 -0
- package/src/crypto/hash/sha3.acvp.md +133 -0
- package/src/crypto/hash/sha3.js +391 -0
- package/src/crypto/hash/sha384.acvp.md +82 -0
- package/src/crypto/hash/sha384.js +61 -0
- package/src/crypto/hash/sha512.acvp.md +84 -0
- package/src/crypto/hash/sha512.js +314 -0
- package/src/crypto/hash/sha512_224.acvp.md +90 -0
- package/src/crypto/hash/sha512_224.js +66 -0
- package/src/crypto/hash/sha512_256.acvp.md +96 -0
- package/src/crypto/hash/sha512_256.js +75 -0
- package/src/crypto/mode/cbc.acvp.md +105 -0
- package/src/crypto/mode/cbc.js +136 -0
- package/src/crypto/mode/chacha20poly1305.acvp.md +116 -0
- package/src/crypto/mode/chacha20poly1305.js +190 -0
- package/src/crypto/mode/cmac.acvp.md +106 -0
- package/src/crypto/mode/cmac.js +172 -0
- package/src/crypto/mode/ctr.acvp.md +110 -0
- package/src/crypto/mode/ctr.js +174 -0
- package/src/crypto/mode/gcm.acvp.md +129 -0
- package/src/crypto/mode/gcm.js +333 -0
- package/src/crypto/mode/kw.acvp.md +145 -0
- package/src/crypto/mode/kw.js +323 -0
- package/src/crypto/pkc/ecc.acvp.md +181 -0
- package/src/crypto/pkc/ecc.js +941 -0
- package/src/crypto/pkc/ed25519.acvp.md +172 -0
- package/src/crypto/pkc/ed25519.js +582 -0
- package/src/crypto/pkc/hybrid-kat.provenance.md +89 -0
- package/src/crypto/pkc/hybridKem.js +255 -0
- package/src/crypto/pkc/hybridSign.js +437 -0
- package/src/crypto/pkc/ml_dsa.acvp.md +146 -0
- package/src/crypto/pkc/ml_dsa.js +984 -0
- package/src/crypto/pkc/ml_kem.acvp.md +117 -0
- package/src/crypto/pkc/ml_kem.js +596 -0
- package/src/crypto/pkc/rsa.acvp.md +187 -0
- package/src/crypto/pkc/rsa.js +470 -0
- package/src/crypto/pkc/slh_dsa.acvp.md +155 -0
- package/src/crypto/pkc/slh_dsa.js +820 -0
- package/src/crypto/pkc/x25519.acvp.md +113 -0
- package/src/crypto/pkc/x25519.js +290 -0
- package/src/crypto/utils/aes_ctr.acvp.md +67 -0
- package/src/crypto/utils/aes_ctr.js +134 -0
- package/src/crypto/utils/aes_modes.acvp.md +66 -0
- package/src/crypto/utils/aes_modes.js +241 -0
- package/src/crypto/utils/asn1-oid.js +369 -0
- package/src/crypto/utils/asn1.js +343 -0
- package/src/crypto/utils/bitArray.js +312 -0
- package/src/crypto/utils/bn.js +825 -0
- package/src/crypto/utils/jws.js +222 -0
- package/src/crypto/utils/keyformat.js +303 -0
- package/src/crypto/utils/pad.js +198 -0
- package/src/crypto/utils/pem.js +90 -0
- package/src/crypto/utils/random.acvp.md +167 -0
- package/src/crypto/utils/random.js +846 -0
- package/src/crypto/utils/rsaKeygen.acvp.md +158 -0
- package/src/crypto/utils/rsaKeygen.js +448 -0
- package/src/crypto/utils/totp.js +409 -0
- package/src/crypto/utils/uuid.acvp.md +137 -0
- package/src/crypto/utils/uuid.js +176 -0
- package/src/crypto/wasm/aes.js +494 -0
- package/src/crypto/wasm/argon2.js +236 -0
- package/src/crypto/wasm/blake2b.js +213 -0
- package/src/crypto/wasm/chacha20poly1305.js +238 -0
- package/src/crypto/wasm/cmac.js +207 -0
- package/src/crypto/wasm/ecc.js +437 -0
- package/src/crypto/wasm/ed25519.js +307 -0
- package/src/crypto/wasm/hkdf.js +183 -0
- package/src/crypto/wasm/hmac.js +215 -0
- package/src/crypto/wasm/ml_dsa.js +375 -0
- package/src/crypto/wasm/ml_kem.js +313 -0
- package/src/crypto/wasm/pbkdf2.js +205 -0
- package/src/crypto/wasm/rsa.js +674 -0
- package/src/crypto/wasm/runtime.js +400 -0
- package/src/crypto/wasm/sha2.js +183 -0
- package/src/crypto/wasm/sha3.js +221 -0
- package/src/crypto/wasm/slh_dsa.js +397 -0
- package/src/crypto/wasm/x25519.js +241 -0
- package/src/crypto/webcrypto/aes.js +370 -0
- package/src/crypto/webcrypto/aeskw.js +185 -0
- package/src/crypto/webcrypto/digest.js +136 -0
- package/src/crypto/webcrypto/ecc.js +371 -0
- package/src/crypto/webcrypto/ed25519.js +248 -0
- package/src/crypto/webcrypto/hkdf.js +132 -0
- package/src/crypto/webcrypto/hmac.js +213 -0
- package/src/crypto/webcrypto/pbkdf2.js +146 -0
- package/src/crypto/webcrypto/rsa.js +415 -0
- package/src/crypto/webcrypto/x25519.js +250 -0
- package/src/dom/display/animate.js +154 -0
- package/src/dom/display/fullscreen.js +305 -0
- package/src/dom/fs/download.js +118 -0
- package/src/dom/fs/fsAccess.js +307 -0
- package/src/dom/fs/indexedDB.js +465 -0
- package/src/dom/fs/remoteStore.js +484 -0
- package/src/dom/fs/storage.js +440 -0
- package/src/dom/lifecycle/idle.js +133 -0
- package/src/dom/lifecycle/visibility.js +140 -0
- package/src/dom/lifecycle/wakeLock.js +187 -0
- package/src/dom/net/ajax.js +303 -0
- package/src/dom/net/broadcastChannel.js +89 -0
- package/src/dom/net/network.js +260 -0
- package/src/dom/net/sse.js +295 -0
- package/src/dom/net/webrtc.js +381 -0
- package/src/dom/net/ws.js +290 -0
- package/src/dom/query/dnd.js +409 -0
- package/src/dom/query/dom.js +831 -0
- package/src/dom/query/events.js +425 -0
- package/src/dom/query/gesture.js +396 -0
- package/src/dom/query/media.js +616 -0
- package/src/dom/rendering/chart.js +663 -0
- package/src/dom/rendering/component.js +469 -0
- package/src/dom/rendering/devtools-ui.js +399 -0
- package/src/dom/rendering/devtools.js +352 -0
- package/src/dom/rendering/parser.js +1055 -0
- package/src/dom/rendering/reactiveBind.js +341 -0
- package/src/dom/rendering/render.js +601 -0
- package/src/dom/rendering/sanitize.js +364 -0
- package/src/dom/rendering/secPolicy.js +281 -0
- package/src/dom/rendering/template.js +1031 -0
- package/src/dom/rendering/themeTokens.js +522 -0
- package/src/dom/rendering/uiSession-core.js +597 -0
- package/src/dom/rendering/uiSession-direct.js +251 -0
- package/src/dom/rendering/uiSession-list.js +751 -0
- package/src/dom/rendering/uiSession.js +145 -0
- package/src/dom/rendering/virtualScroll.js +341 -0
- package/src/dom/sensors/battery.js +153 -0
- package/src/dom/sensors/geolocation.js +156 -0
- package/src/dom/sensors/networkInfo.js +136 -0
- package/src/dom/sensors/sensors.js +340 -0
- package/src/dom/sw/backgroundSync.js +113 -0
- package/src/dom/sw/cache.js +139 -0
- package/src/dom/sw/push.js +181 -0
- package/src/dom/sw/serviceWorker.js +193 -0
- package/src/dom/sw/sharedWorker.js +192 -0
- package/src/dom/utils/a11y.js +244 -0
- package/src/dom/utils/clipboard.js +113 -0
- package/src/dom/utils/entropyCollector.js +344 -0
- package/src/dom/utils/focus.js +421 -0
- package/src/dom/utils/form.js +535 -0
- package/src/dom/utils/formKit.js +427 -0
- package/src/dom/utils/keybindings.js +574 -0
- package/src/dom/utils/leaderElection.js +280 -0
- package/src/dom/utils/notifications.js +218 -0
- package/src/dom/utils/permissions.js +107 -0
- package/src/dom/utils/route.js +482 -0
- package/src/dom/utils/ua.js +109 -0
- package/src/dom/utils/webauthn.js +369 -0
- package/src/external/README.md +15 -0
- package/src/io/binary/reader.js +374 -0
- package/src/io/binary/writer.js +351 -0
- package/src/io/calc/adler32.js +94 -0
- package/src/io/calc/bigint.js +276 -0
- package/src/io/calc/crc32.js +111 -0
- package/src/io/calc/easing.js +514 -0
- package/src/io/codec/b64.js +235 -0
- package/src/io/codec/base32.js +147 -0
- package/src/io/codec/base58.js +167 -0
- package/src/io/codec/buffer.js +630 -0
- package/src/io/codec/cbor.js +550 -0
- package/src/io/codec/csv.js +299 -0
- package/src/io/codec/hex.js +129 -0
- package/src/io/codec/mime.js +398 -0
- package/src/io/codec/msgpack.js +491 -0
- package/src/io/codec/url.js +530 -0
- package/src/io/codec/utf8.js +181 -0
- package/src/io/codec/xml.js +428 -0
- package/src/io/compress/bitstream.js +199 -0
- package/src/io/compress/brotli.js +3073 -0
- package/src/io/compress/brotli_dict.bin +432 -0
- package/src/io/compress/brotli_dict.js +356 -0
- package/src/io/compress/brotli_dict_words.js +157 -0
- package/src/io/compress/brotli_frame.js +420 -0
- package/src/io/compress/brotli_shared.js +715 -0
- package/src/io/compress/deflate.js +1432 -0
- package/src/io/compress/gzip.js +406 -0
- package/src/io/compress/huffman.js +322 -0
- package/src/io/compress/lz4.js +451 -0
- package/src/io/compress/lz77.js +408 -0
- package/src/io/compress/lzw.js +332 -0
- package/src/io/compress/zip.js +815 -0
- package/src/io/compress/zlib.js +340 -0
- package/src/io/i18n/i18n.js +236 -0
- package/src/io/math/fixed-point.js +269 -0
- package/src/io/math/geom.js +350 -0
- package/src/io/math/interp.js +263 -0
- package/src/io/math/linalg.js +472 -0
- package/src/io/math/stats.js +339 -0
- package/src/io/structures/btree.js +357 -0
- package/src/io/structures/heap.js +249 -0
- package/src/io/structures/lruCache.js +219 -0
- package/src/io/structures/ringBuffer.js +208 -0
- package/src/io/structures/tree-walker.js +413 -0
- package/src/io/structures/trie.js +219 -0
- package/src/io/sync/abort.js +196 -0
- package/src/io/sync/atomics.js +342 -0
- package/src/io/sync/cancellable.js +279 -0
- package/src/io/sync/channel.js +301 -0
- package/src/io/sync/mutex.js +148 -0
- package/src/io/sync/semaphore.js +156 -0
- package/src/io/sync/tokenBucket.js +208 -0
- package/src/io/text/ansi.js +536 -0
- package/src/io/text/html-entities.js +143 -0
- package/src/io/text/semver.js +375 -0
- package/src/io/text/str.js +243 -0
- package/src/io/text/unicode.js +188 -0
- package/src/io/time/date.js +355 -0
- package/src/io/timing/clock.js +79 -0
- package/src/io/timing/rateLimit.js +264 -0
- package/src/io/timing/scheduler.js +351 -0
- package/src/io/utils/bitmap.js +94 -0
- package/src/io/utils/errors.js +269 -0
- package/src/io/utils/eventBus.js +315 -0
- package/src/io/utils/queue.js +223 -0
- package/src/io/utils/signal.js +858 -0
- package/src/io/utils/ui8.js +99 -0
- package/src/io/utils/valid.js +556 -0
- package/src/main.js +41 -0
- package/src/polyfill/README.md +9 -0
- package/src/process/message.js +257 -0
- package/src/process/rpc.js +286 -0
- package/src/process/workerPool.js +392 -0
- package/src/sanity/base.js +374 -0
- package/src/sanity/community.js +254 -0
- package/src/sanity/lockdown-apply.js +58 -0
- package/src/sanity/lockdown.js +408 -0
- package/src/sanity/wasm-gate.js +316 -0
- package/src/typed.js +53 -0
- package/third-party/NOTICE-penner-easing +88 -0
- package/third-party/NOTICE-sjcl +50 -0
- package/tools/_lib/cli-help.js +55 -0
- package/tools/rendering/aot/index.js +148 -0
- package/tools/rendering/aot/lib/dom-codegen.js +295 -0
- package/tools/rendering/jsx/index.js +654 -0
- package/tools/rendering/precompilation/index.js +368 -0
- package/types/registry.generated.d.ts +217 -0
- package/types/typed.d.ts +106 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: huffman
|
|
3
|
+
category: io/compress
|
|
4
|
+
dependencies: [bitstream]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# huffman
|
|
11
|
+
|
|
12
|
+
> Canonical Huffman code construction (encode + decode) with length cap.
|
|
13
|
+
|
|
14
|
+
**Module** `huffman` | **Source** `packages/front/fw/src/io/compress/huffman.js` | **Deps** `bitstream` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Primitives shared by the DEFLATE/Brotli codecs:
|
|
17
|
+
|
|
18
|
+
- `buildMap` — from an array of canonical code lengths, produces the
|
|
19
|
+
encoding table (symbol → code) **or** the decoding table indexed by
|
|
20
|
+
the `maxBits` LSBs of the stream.
|
|
21
|
+
- `buildTree` — from symbol frequencies, computes the code lengths of an
|
|
22
|
+
optimal prefix code whose lengths never exceed `maxBits` (package-merge,
|
|
23
|
+
no post-hoc length adjustment).
|
|
24
|
+
|
|
25
|
+
The assignment follows the canonical convention: symbols with shorter code
|
|
26
|
+
first, ties broken by symbol order. See RFC 1951 §3.2.2.
|
|
27
|
+
|
|
28
|
+
## Resolve
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
const hf = runtime.resolve('huffman');
|
|
32
|
+
// { buildMap, buildTree }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
| Method | Signature | Returns |
|
|
38
|
+
|--------|-----------|---------|
|
|
39
|
+
| `buildMap` | `(codeLengths: Uint8Array, maxBits: number, reversed: 0\|1) => Uint16Array` | encode table (`reversed=0`) or decode table (`reversed=1`) |
|
|
40
|
+
| `buildTree` | `(freqs: Uint16Array \| number[], maxBits: number) => { t: Uint8Array, l: number }` | `t` = code lengths, `l` = max bits used |
|
|
41
|
+
|
|
42
|
+
### `buildMap(cd, mb, reversed)`
|
|
43
|
+
|
|
44
|
+
**Encoder mode** (`reversed = 0`): returns `Uint16Array[cd.length]` where
|
|
45
|
+
`out[s]` is the canonical code of symbol `s` bit-reversed over `cd[s]` bits
|
|
46
|
+
(0 for unused symbols), so that `bitstream.writeBits(buf, p, out[s])` followed
|
|
47
|
+
by `p += cd[s]` puts the code on the wire most-significant bit first, as RFC
|
|
48
|
+
1951 §3.1.1 requires.
|
|
49
|
+
|
|
50
|
+
**Decoder mode** (`reversed = 1`): returns `Uint16Array[1 << maxBits]`
|
|
51
|
+
indexed by the `maxBits` low-order bits of the stream. Each entry is
|
|
52
|
+
packed as `(symbol << 4) | codeLength`. To decode:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const entry = decTable[bs.readBits(buf, p, (1 << mb) - 1)];
|
|
56
|
+
const symbol = entry >> 4;
|
|
57
|
+
const len = entry & 0x0F;
|
|
58
|
+
p += len;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### `buildTree(freqs, mb)`
|
|
62
|
+
|
|
63
|
+
Runs the package-merge algorithm (Larmore & Hirschberg, 1990) over the
|
|
64
|
+
used symbols sorted by frequency (ties by symbol index): the result
|
|
65
|
+
minimises `Σ freq[s] · t[s]` among all prefix codes whose lengths stay within
|
|
66
|
+
`mb`, so the cap is part of the optimisation rather than a repair applied to
|
|
67
|
+
an unlimited Huffman tree. Cost is `O(n log n)` for `n` used symbols when an
|
|
68
|
+
unlimited Huffman code already fits in `mb` (the usual case, see
|
|
69
|
+
[Design](#design)), and `O(n · mb)` when the cap binds.
|
|
70
|
+
Frequencies are plain non-negative integers of any size (`Uint16Array`,
|
|
71
|
+
`Uint32Array` or `number[]`; sums below `2^32` are exact). Special cases:
|
|
72
|
+
|
|
73
|
+
| Input | Output |
|
|
74
|
+
|-------|--------|
|
|
75
|
+
| All frequencies 0 | `{ t: Uint8Array(0), l: 0 }` |
|
|
76
|
+
| Single symbol `s` with freq > 0 | `{ t: [0,…,1 @ s], l: 1 }` |
|
|
77
|
+
| ≥ 2 symbols | Complete canonical code (Kraft sum = 1), `l = max(t) ≤ mb`; a more frequent symbol never gets a longer code |
|
|
78
|
+
|
|
79
|
+
The returned `t` array is sized to `maxSymbol + 1` (not the next power of 2).
|
|
80
|
+
|
|
81
|
+
## Examples
|
|
82
|
+
|
|
83
|
+
### Build a code from frequencies
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
const hf = runtime.resolve('huffman');
|
|
87
|
+
|
|
88
|
+
const freqs = new Uint16Array([5, 9, 12, 13, 16, 45]);
|
|
89
|
+
const { t, l } = hf.buildTree(freqs, 15);
|
|
90
|
+
// t = [4, 4, 3, 3, 3, 1] — canonical code lengths
|
|
91
|
+
// l = 4
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Round-trip encode → decode
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
const enc = hf.buildMap(t, l, 0); // {symbol → code}
|
|
98
|
+
const dec = hf.buildMap(t, l, 1); // table indexed by LSB bits
|
|
99
|
+
|
|
100
|
+
// Verification
|
|
101
|
+
for (let s = 0; s < t.length; ++s) {
|
|
102
|
+
if (!t[s]) continue;
|
|
103
|
+
const entry = dec[enc[s]];
|
|
104
|
+
console.assert((entry >> 4) === s);
|
|
105
|
+
console.assert((entry & 0x0F) === t[s]);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Worker Usage
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
const worker = fw.createWorker(
|
|
113
|
+
function ({ libs, args }) {
|
|
114
|
+
const hf = libs.huffman;
|
|
115
|
+
const { t, l } = hf.buildTree(args[0], 15);
|
|
116
|
+
self.postMessage({ lengths: Array.from(t), maxBits: l });
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
dependencies: ['huffman'],
|
|
120
|
+
args: [new Uint16Array([1, 2, 3, 4])],
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Notes
|
|
126
|
+
|
|
127
|
+
- `buildMap` in decoder mode allocates `1 << maxBits` entries: keep `maxBits` as tight as possible (15 for DEFLATE literal/length, 5 for DEFLATE distance, up to 15 for Brotli).
|
|
128
|
+
- Decode packing `(sym << 4) | len`: limits `len` to 4 bits (≤ 15). Consistent with the constraints of both supported RFCs.
|
|
129
|
+
- Every call returns fresh arrays, including the empty `{ t: Uint8Array(0), l: 0 }` result; the output is deterministic for a given input.
|
|
130
|
+
- Zero-frequency symbols are **excluded**: a symbol with frequency 0 gets `t[s] = 0` and must not be emitted by the encoder.
|
|
131
|
+
|
|
132
|
+
## Design
|
|
133
|
+
|
|
134
|
+
**Two paths, one answer.** `buildTree` sorts the used symbols once, by
|
|
135
|
+
frequency then symbol, and first runs a plain Huffman construction over them
|
|
136
|
+
with two queues instead of a heap: the sorted leaves, and the merged nodes,
|
|
137
|
+
which are created in non-decreasing weight order, so each step only compares
|
|
138
|
+
the two queue heads. On equal weights the leaf is taken first. Each item
|
|
139
|
+
records the step that absorbed it, and one reverse pass over the steps turns
|
|
140
|
+
those links into depths. If the deepest code fits in `mb`, that code is
|
|
141
|
+
returned: an unlimited Huffman code that respects the cap is optimal under the
|
|
142
|
+
cap too. Only when it does not fit does package-merge run, on the same sorted
|
|
143
|
+
leaves.
|
|
144
|
+
|
|
145
|
+
The two paths are not merely equal in cost: package-merge with the same tie
|
|
146
|
+
rule (leaf before package on equal weight) returns the **same lengths**
|
|
147
|
+
whenever the Huffman code fits, so the fast path never changes a codec's
|
|
148
|
+
output. `huffman.test.js` holds `buildTree` equal to an independent
|
|
149
|
+
package-merge (explicit coin counts) on every alphabet of 2 to 5 symbols with
|
|
150
|
+
frequencies 1 to 5, at the Huffman depth, one above and one below it, and on
|
|
151
|
+
400 seeded random vectors with tie-heavy and wide frequencies. Swapping the
|
|
152
|
+
tie rule of the fast path (`<=` to `<`) turns both tests red.
|
|
153
|
+
|
|
154
|
+
Measured on the codec bench histograms (200 calls, Bun 1.3.13), `buildTree`
|
|
155
|
+
spends about 70 % of its package-merge time in the level merges; the fast path
|
|
156
|
+
cuts a call by 60 to 78 % (text: 3.26 to 0.71 ms per 200 calls) and leaves
|
|
157
|
+
the sort as the dominant cost. The DEFLATE code-length code (`mb = 7`) and
|
|
158
|
+
skewed Brotli alphabets still reach package-merge when the cap binds.
|
|
159
|
+
|
|
160
|
+
**Decode-table fill.** A code of length `len` owns every slot of the
|
|
161
|
+
`1 << mb` table whose low `len` bits spell it in stream order, so each symbol
|
|
162
|
+
writes its entry at `rev(code)` and then every `1 << len` slots: one pass per
|
|
163
|
+
symbol, no sorting, and no second pass for the long codes.
|
|
164
|
+
|
|
165
|
+
## Benchmark
|
|
166
|
+
|
|
167
|
+
Micro-cells, `tools/bench/codec-levels.js` (`<corpus>:buildTree` = 200×
|
|
168
|
+
`buildTree(hist, 15)`; `<corpus>` = 200× `buildMap(lengths, 15, 0)` then
|
|
169
|
+
200× `buildMap(lengths, 15, 1)`, on this engine's own `buildTree` output),
|
|
170
|
+
`--reps 7 --warmup 3`, baseline sha
|
|
171
|
+
`d47f8fc7a68809f519fe7d36ff2b0ba88bcacdbd`. Host `win32` / `13th Gen
|
|
172
|
+
Intel(R) Core(TM) i7-13700KF` / Bun `1.3.13`. Generated
|
|
173
|
+
`2026-09-24T20:50:02.210Z` (gitignored bench artifact). Rule: `Δenc < +5 %`,
|
|
174
|
+
`Δdec < +5 %`; gated on time only (no bytes cell).
|
|
175
|
+
|
|
176
|
+
| Corpus | Old enc ms | New enc ms | Δenc % | Old dec ms | New dec ms | Δdec % | Verdict |
|
|
177
|
+
|---|---|---|---|---|---|---|---|
|
|
178
|
+
| text:buildTree | 2.09 | 0.68 | -67.4 | 0.00 | 0.00 | 0.0 | PASS |
|
|
179
|
+
| text | 0.10 | 0.10 | 4.1 | 13.79 | 6.76 | -51.0 | PASS |
|
|
180
|
+
| source:buildTree | 1.28 | 0.43 | -66.3 | 0.00 | 0.00 | 0.0 | PASS |
|
|
181
|
+
| source | 0.08 | 0.09 | 14.6 | 14.13 | 5.42 | -61.6 | FAIL (enc) |
|
|
182
|
+
| json:buildTree | 0.31 | 0.16 | -46.7 | 0.00 | 0.00 | 0.0 | PASS |
|
|
183
|
+
| json | 0.04 | 0.06 | 37.0 | 13.95 | 5.24 | -62.4 | FAIL (enc) |
|
|
184
|
+
| random:buildTree | 3.26 | 1.02 | -68.7 | 0.00 | 0.00 | 0.0 | PASS |
|
|
185
|
+
| random | 0.15 | 0.15 | -2.0 | 14.00 | 8.63 | -38.4 | PASS |
|
|
186
|
+
| repeat:buildTree | 0.83 | 0.32 | -61.7 | 0.00 | 0.00 | 0.0 | PASS |
|
|
187
|
+
| repeat | 0.07 | 0.10 | 32.5 | 14.24 | 6.91 | -51.5 | FAIL (enc) |
|
|
188
|
+
| small:buildTree | 1.16 | 0.41 | -64.5 | 0.00 | 0.00 | 0.0 | PASS |
|
|
189
|
+
| small | 0.08 | 0.09 | 11.5 | 14.03 | 5.57 | -60.3 | FAIL (enc) |
|
|
190
|
+
|
|
191
|
+
**8/13 PASS, 5/13 FAIL** (of the 13 huffman + bitstream micro-cells; 8/12
|
|
192
|
+
PASS, 4/12 FAIL restricted to this module's own 12 rows above —
|
|
193
|
+
`bitstream.rw` is [bitstream](./bitstream.md)'s cell). Every `buildTree`
|
|
194
|
+
row PASSES, by a wide margin (−47 to −69 %): the two-queue fast path (see
|
|
195
|
+
Design) is the dominant win. The `buildMap`-encode red cells
|
|
196
|
+
(source/json/repeat/small, +12 to +37 %) sit inside the harness's own
|
|
197
|
+
noise floor: a later measurement ruling recorded that an A/A run of two
|
|
198
|
+
byte-identical copies of the new module measures +4 to +14 % on the same
|
|
199
|
+
cell, and no variant tried moved it monomorphically. The paired
|
|
200
|
+
`buildMap`-decode timing (same cell, `reversed = 1`) is faster everywhere
|
|
201
|
+
(−38 to −62 %) and never fails.
|
|
202
|
+
|
|
203
|
+
## Provenance
|
|
204
|
+
|
|
205
|
+
In-house implementation from RFC 1951 §3.2.2 (canonical assignment) and a length-limited optimal code construction (package-merge, Larmore & Hirschberg 1990); the earlier fflate-derived implementation was replaced by a clean-room rewrite (2026-09).
|
|
206
|
+
|
|
207
|
+
## See also
|
|
208
|
+
|
|
209
|
+
- [bitstream](./bitstream.md) — provides `rev` (bit-reversal) and TypedArray helpers
|
|
210
|
+
- [deflate](./deflate.md) — RFC 1951 §3.2.2 (canonical assignment)
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: lz4
|
|
3
|
+
category: io/compress
|
|
4
|
+
dependencies: []
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# lz4
|
|
11
|
+
|
|
12
|
+
> LZ4 compression — ultra-fast algorithm, block and streaming compression/decompression.
|
|
13
|
+
|
|
14
|
+
**Module** `lz4` | **Source** `packages/front/fw/src/io/compress/lz4.js` | **Deps** none | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
## Resolve
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
const lz4 = runtime.resolve('lz4');
|
|
20
|
+
// Returns: { compress, decompress, Lz4CompressStream, Lz4DecompressStream }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
### `lz4.compress(src, len, opts?) → [size, data]`
|
|
26
|
+
|
|
27
|
+
Compresses a `Uint8Array` block.
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const [size, data] = lz4.compress(uint8Array, uint8Array.length); // mode 'speed'
|
|
31
|
+
const [rSize, rData] = lz4.compress(uint8Array, uint8Array.length, { mode: 'ratio' }); // smaller, slower
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
| Option | Values | Default |
|
|
35
|
+
|--------|--------|---------|
|
|
36
|
+
| `opts.mode` | `'speed'` (fast search) or `'ratio'` (deeper search, smaller block) — see [Modes](#modes) | `'speed'` |
|
|
37
|
+
|
|
38
|
+
| Return | Meaning |
|
|
39
|
+
|--------|---------|
|
|
40
|
+
| `size > 0` | Success — `size` = compressed size |
|
|
41
|
+
| `size === 0` | Incompressible data — return original |
|
|
42
|
+
| `size === -1` | Error — input exceeds ~1 GB |
|
|
43
|
+
|
|
44
|
+
Throws a `RangeError` naming the value when `opts.mode` is neither `'speed'`
|
|
45
|
+
nor `'ratio'`. Both modes produce standard LZ4 blocks: `decompress` reads either.
|
|
46
|
+
|
|
47
|
+
### `lz4.decompress(src) → [size, data]`
|
|
48
|
+
|
|
49
|
+
Decompresses an LZ4 block.
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
const [origSize, original] = lz4.decompress(compressed);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
| Return | Meaning |
|
|
56
|
+
|--------|---------|
|
|
57
|
+
| `size > 0` | Success — `size` = decompressed size |
|
|
58
|
+
| `size === -1` | Decompression error |
|
|
59
|
+
|
|
60
|
+
### `new lz4.Lz4CompressStream(ondata?, opts?)`
|
|
61
|
+
|
|
62
|
+
Streaming compression. Each chunk is processed as an independent LZ4 block.
|
|
63
|
+
`opts.mode` is the same as for `compress` (default `'speed'`); an unknown mode
|
|
64
|
+
throws a `RangeError` at construction.
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
const chunks = [];
|
|
68
|
+
const stream = new lz4.Lz4CompressStream((chunk) => chunks.push(chunk));
|
|
69
|
+
|
|
70
|
+
stream.push(data1);
|
|
71
|
+
stream.push(data2);
|
|
72
|
+
stream.push(lastChunk, true); // true = dernier chunk
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `new lz4.Lz4DecompressStream(ondata?)`
|
|
76
|
+
|
|
77
|
+
Streaming decompression.
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
const output = [];
|
|
81
|
+
const stream = new lz4.Lz4DecompressStream((chunk) => output.push(chunk));
|
|
82
|
+
|
|
83
|
+
stream.push(compressedChunk);
|
|
84
|
+
stream.push(lastCompressedChunk, true);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Characteristics
|
|
88
|
+
|
|
89
|
+
| Aspect | Value |
|
|
90
|
+
|--------|-------|
|
|
91
|
+
| Maximum input size | ~1 GB (0x3F000000 bytes) |
|
|
92
|
+
| Minimum match length | 4 bytes |
|
|
93
|
+
| Compression modes | `'speed'` (default, 1 candidate per position) / `'ratio'` (chain of 4) — same block format |
|
|
94
|
+
| Decompression buffer allocation | One exact-size allocation — a validation pass sums the decoded size first |
|
|
95
|
+
| Streaming | Each chunk = independent LZ4 block |
|
|
96
|
+
|
|
97
|
+
## Modes
|
|
98
|
+
|
|
99
|
+
Both modes run the same encoder and emit the same block format; they differ
|
|
100
|
+
only in how hard the match search works.
|
|
101
|
+
|
|
102
|
+
| | `'speed'` (default) | `'ratio'` |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| Candidates per position | 1 (newest bucket entry, no chains) | up to 4 (hash chains) |
|
|
105
|
+
| Positions indexed inside an emitted match | none | the last 3 |
|
|
106
|
+
| Miss run before the stride grows | 32 | 64 |
|
|
107
|
+
|
|
108
|
+
Measured with the codec bench (`tools/bench/codec-levels.js --lz4-mode`,
|
|
109
|
+
Bun 1.3.13, 256 KiB corpora, `small` = 200 × 2 KiB slices; encode time in ms,
|
|
110
|
+
median of 7), next to the single-mode encoder this module replaced
|
|
111
|
+
(pre-rewrite baseline):
|
|
112
|
+
|
|
113
|
+
| Corpus | previous encoder: B / ms | `'speed'`: B / ms | `'ratio'`: B / ms |
|
|
114
|
+
|---|---|---|---|
|
|
115
|
+
| text | 84076 / 0.83 | 83621 / 0.85 | 77053 / 1.32 |
|
|
116
|
+
| source | 57987 / 0.51 | 57188 / 0.57 | 50538 / 0.71 |
|
|
117
|
+
| json | 90883 / 0.52 | 90742 / 0.63 | 75186 / 0.94 |
|
|
118
|
+
| random | 262144 / 0.09 | 262144 / 0.07 | 262144 / 0.09 |
|
|
119
|
+
| repeat | 1142 / 0.21 | 1135 / 0.21 | 1135 / 0.16 |
|
|
120
|
+
| small | 218866 / 12.9 | 217745 / 1.96 | 209947 / 2.58 |
|
|
121
|
+
|
|
122
|
+
`'speed'` is never larger than the previous encoder on these corpora and
|
|
123
|
+
encodes at about its speed (from −85 % on many small inputs to +20 % on
|
|
124
|
+
short-match text such as json); `'ratio'` trades 1.5 to 1.8 times the encode
|
|
125
|
+
time on large text for blocks 8 to 17 % smaller. Both decode with the same
|
|
126
|
+
`decompress`, within about 10 % of each other (a `'speed'` block carries more
|
|
127
|
+
literals, a `'ratio'` block more matches).
|
|
128
|
+
|
|
129
|
+
## Full example
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
const lz4 = runtime.resolve('lz4');
|
|
133
|
+
const utf8 = runtime.resolve('utf8');
|
|
134
|
+
|
|
135
|
+
const data = utf8.toBytes('Hello World '.repeat(1000));
|
|
136
|
+
|
|
137
|
+
// Block
|
|
138
|
+
const [size, compressed] = lz4.compress(data, data.length);
|
|
139
|
+
console.log(`${data.length} → ${size} bytes`);
|
|
140
|
+
|
|
141
|
+
const [origSize, restored] = lz4.decompress(compressed);
|
|
142
|
+
console.log(utf8.fromBytes(restored)); // 'Hello World Hello World ...'
|
|
143
|
+
|
|
144
|
+
// Streaming compression
|
|
145
|
+
const parts = [];
|
|
146
|
+
const comp = new lz4.Lz4CompressStream((chunk) => parts.push(chunk));
|
|
147
|
+
comp.push(data.slice(0, 500));
|
|
148
|
+
comp.push(data.slice(500), true);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Worker Usage
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
const worker = fw.createWorker(
|
|
155
|
+
function ({ libs, args }) {
|
|
156
|
+
const lz4 = libs.lz4;
|
|
157
|
+
const [size, compressed] = lz4.compress(args.data, args.data.length);
|
|
158
|
+
self.postMessage({ size, compressed }, [compressed.buffer]);
|
|
159
|
+
},
|
|
160
|
+
{ dependencies: ['lz4'], args: { data: new Uint8Array(rawData) } }
|
|
161
|
+
);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Notes
|
|
165
|
+
|
|
166
|
+
- LZ4 favours **speed** (hundreds of MB/s) over ratio — for maximum ratio, use `brotli` (quality 11) or `deflate` (level 9).
|
|
167
|
+
- Block format: each `compress` call produces an independent LZ4 block — no multi-block LZ4 frame header.
|
|
168
|
+
- `Lz4CompressStream` / `Lz4DecompressStream`: each `push` produces one or more complete blocks (no inter-push buffering).
|
|
169
|
+
|
|
170
|
+
## Design
|
|
171
|
+
|
|
172
|
+
**Match search (hash, chain, skip).** Every visited position hashes its
|
|
173
|
+
4-byte little-endian word multiplicatively (`Math.imul` by 2654435761, top
|
|
174
|
+
`hashBits` bits, with `hashBits` between 8 and 16 sized to the input) into a
|
|
175
|
+
bucket table. In `'ratio'` mode each bucket heads a chain linked through a
|
|
176
|
+
64 KiB ring indexed by position, so a lookup walks older candidates newest
|
|
177
|
+
first: at most 4 inside the 64 KiB window, keeping the longest and stopping
|
|
178
|
+
early on a match of 32 bytes or one that reaches the end limit. In `'speed'`
|
|
179
|
+
mode only the newest entry of the bucket is tried, and no chain is kept at
|
|
180
|
+
all (no ring is allocated or written). A cheap test comes first: the byte at
|
|
181
|
+
the current best length must match before the whole 4-byte word is compared.
|
|
182
|
+
The kept match is then widened backwards over the pending literals (both
|
|
183
|
+
modes: without it, `'speed'` would exceed the previous encoder's size on the
|
|
184
|
+
text corpora). After a match, `'ratio'` indexes its last 3 covered positions,
|
|
185
|
+
`'speed'` none. After a run of misses the stride grows by one every 64
|
|
186
|
+
(`'ratio'`) or 32 (`'speed'`) misses, so incompressible stretches are sampled
|
|
187
|
+
instead of scanned. The two modes are one function with three parameters
|
|
188
|
+
(probes, covered positions, skip shift); `'ratio'` is byte-identical to the
|
|
189
|
+
single-mode encoder it replaced, and the parameterisation costs it nothing
|
|
190
|
+
measurable.
|
|
191
|
+
|
|
192
|
+
**Match extension.** Past the first 4 bytes, a candidate is compared byte by
|
|
193
|
+
byte up to 16 bytes, because most matches end there. A candidate that gets
|
|
194
|
+
that far is compared in 4-byte words, and a final byte loop finishes whatever
|
|
195
|
+
the word loop leaves before the end limit. The length found is always the
|
|
196
|
+
exact common prefix; `lz4.test.js` checks it for every run length from 7 to
|
|
197
|
+
96 and at the end-of-block cut.
|
|
198
|
+
|
|
199
|
+
**Literal copies.** Literals are copied byte by byte in both the encoder and
|
|
200
|
+
the decoder. Literal runs between matches are short, and a
|
|
201
|
+
`set(subarray(...))` would allocate a view object for every sequence (a
|
|
202
|
+
`Buffer` when the input is one), which costs more than the copy it saves.
|
|
203
|
+
|
|
204
|
+
**What the chain costs.** The 4-probe chain and the 3-position indexing are
|
|
205
|
+
what buy `'ratio'`'s smaller blocks; `'speed'` drops both and keeps only a
|
|
206
|
+
fraction of the size gain (see [Modes](#modes)). Among the configurations
|
|
207
|
+
measured for `'speed'` (1 or 2 probes, 0 to 3 indexed positions, with and
|
|
208
|
+
without backward widening, skip after 16, 32 or 64 misses, 14 to 16 hash
|
|
209
|
+
bits), the one shipped is the fastest overall that stays at or below the previous
|
|
210
|
+
encoder's size on every bench corpus.
|
|
211
|
+
|
|
212
|
+
**Decoder.** Two passes: the first validates every sequence and sums the
|
|
213
|
+
output size (so the size limit is checked before any allocation), the second
|
|
214
|
+
copies into one exact-size buffer. A non-overlapping match longer than 32
|
|
215
|
+
bytes uses `copyWithin`. Overlapping matches are copied byte by byte, because
|
|
216
|
+
they re-read bytes they have just written.
|
|
217
|
+
|
|
218
|
+
## Benchmark
|
|
219
|
+
|
|
220
|
+
`tools/bench/codec-levels.js --lz4-mode {speed,ratio}`, `--reps 7 --warmup
|
|
221
|
+
3`, baseline sha `d47f8fc7a68809f519fe7d36ff2b0ba88bcacdbd` (the single-mode
|
|
222
|
+
encoder this module replaced). Host `win32` / `13th Gen Intel(R) Core(TM)
|
|
223
|
+
i7-13700KF` / Bun `1.3.13`. Generated `2026-09-24T21:14:48.449Z` (`speed`)
|
|
224
|
+
and `2026-09-24T21:14:48.950Z` (`ratio`), both gitignored bench artifacts.
|
|
225
|
+
|
|
226
|
+
**Gate reading (a later measurement ruling).** The rule for lz4 is
|
|
227
|
+
`Δbytes ≤ 0` per corpus — the only gated figure; the mode's own encode
|
|
228
|
+
time is recorded, not gated: `'speed'`'s delta is the accepted
|
|
229
|
+
measurement floor (the fastest configuration found that still keeps bytes
|
|
230
|
+
≤ 0 on every corpus), and `'ratio'`'s delta is a recorded compression
|
|
231
|
+
trade-off. Both decode with the unchanged `decompress`.
|
|
232
|
+
|
|
233
|
+
### `'speed'` (default)
|
|
234
|
+
|
|
235
|
+
| Corpus | Old B | New B | Δbytes % | Δenc % (reps 7) | Δenc % (reps 21) | Δdec % | Bytes gate |
|
|
236
|
+
|---|---|---|---|---|---|---|---|
|
|
237
|
+
| text | 84076 | 83621 | -0.54 | +3.1 | +27.8 | -28.9 | PASS |
|
|
238
|
+
| source | 57987 | 57188 | -1.38 | +22.1 | +10.7 | -12.1 | PASS |
|
|
239
|
+
| json | 90883 | 90742 | -0.16 | +16.9 | +14.3 | -25.9 | PASS |
|
|
240
|
+
| random | 262144 | 262144 | 0.00 | -17.6 | -22.8 | -100.0 | PASS |
|
|
241
|
+
| repeat | 1142 | 1135 | -0.61 | -0.7 | -16.3 | -63.0 | PASS |
|
|
242
|
+
| small | 218866 | 217745 | -0.51 | -82.9 | -83.5 | -73.2 | PASS |
|
|
243
|
+
|
|
244
|
+
Bytes ≤ 0 on all 6 corpora. The reps-7/reps-21 spread on text/source/json
|
|
245
|
+
(companion artifact `05-supp-lz4-speed-reps21-20260924T2114Z.json`,
|
|
246
|
+
gitignored) is the harness's own noise floor — the baseline side alone
|
|
247
|
+
moved from 0.82 to 0.65 ms on `text` between the two runs — not a
|
|
248
|
+
regression; it is accepted as the measured floor by the ruling.
|
|
249
|
+
|
|
250
|
+
### `'ratio'`
|
|
251
|
+
|
|
252
|
+
| Corpus | Old B | New B | Δbytes % | Δenc % (reps 7) | Δenc % (reps 21) | Δdec % | Bytes gate |
|
|
253
|
+
|---|---|---|---|---|---|---|---|
|
|
254
|
+
| text | 84076 | 77053 | -8.35 | +55.2 | +54.3 | -29.5 | PASS |
|
|
255
|
+
| source | 57987 | 50538 | -12.85 | +44.4 | +56.6 | +11.7 | PASS |
|
|
256
|
+
| json | 90883 | 75186 | -17.27 | +76.5 | +83.0 | -28.0 | PASS |
|
|
257
|
+
| random | 262144 | 262144 | 0.00 | +8.8 | +3.6 | +0.0 | PASS |
|
|
258
|
+
| repeat | 1142 | 1135 | -0.61 | -27.6 | -9.9 | -64.7 | PASS |
|
|
259
|
+
| small | 218866 | 209947 | -4.08 | -79.3 | -78.4 | -56.3 | PASS |
|
|
260
|
+
|
|
261
|
+
Bytes ≤ 0 on all 6 corpora. Encode time (+44 to +83 % on text/source/json)
|
|
262
|
+
is recorded as the ratio trade-off, not gated — this is the same encoder
|
|
263
|
+
the module shipped before the speed/ratio split, byte-identical
|
|
264
|
+
by hash (gitignored companion artifact, reps 21).
|
|
265
|
+
|
|
266
|
+
**Totals: 12/12 PASS on the gated figure (bytes ≤ 0, both modes, all 6
|
|
267
|
+
corpora); 0 cells fail on bytes.** No byte was traded for time in the
|
|
268
|
+
default: `'speed'` stays at or below the previous encoder's size on every
|
|
269
|
+
corpus (see [Modes](#modes) for the configuration search).
|
|
270
|
+
|
|
271
|
+
## Provenance
|
|
272
|
+
|
|
273
|
+
In-house implementation written from the LZ4 Block Format specification; the earlier node-lz4-derived implementation was replaced by a clean-room rewrite (2026-09).
|
|
274
|
+
|
|
275
|
+
## See also
|
|
276
|
+
|
|
277
|
+
- [gzip](./gzip.md), [zlib](./zlib.md) — standard HTTP compression
|
|
278
|
+
- [deflate](./deflate.md) — DEFLATE engine
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: lz77
|
|
3
|
+
category: io/compress
|
|
4
|
+
dependencies: []
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# lz77
|
|
11
|
+
|
|
12
|
+
> Lempel-Ziv 77 string-match encoder (hash-chain) — shared primitive for codecs.
|
|
13
|
+
|
|
14
|
+
**Module** `lz77` | **Source** `packages/front/fw/src/io/compress/lz77.js` | **Deps** none | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Generic LZ77 matching primitive usable by any codec that emits a
|
|
17
|
+
token stream `(literal | <length, distance>)`: DEFLATE (RFC 1951),
|
|
18
|
+
Brotli (RFC 7932), Snappy, etc. Classic hash-chain implementation with:
|
|
19
|
+
|
|
20
|
+
- Configurable sliding window (`windowBits`, max 22).
|
|
21
|
+
- Parameterizable min/max match length.
|
|
22
|
+
- Chain depth (`chainDepth`) — speed/ratio trade-off; `niceLength` ends
|
|
23
|
+
the search at a position early.
|
|
24
|
+
- Optional lazy matching (`lazy`) — probes the next position before
|
|
25
|
+
emitting the current match, throttled by `goodLength` / `maxLazy`
|
|
26
|
+
(zlib semantics).
|
|
27
|
+
- Optional chain-skip walk (`chainSkip`) — the fflate heuristic that
|
|
28
|
+
continues the walk on the sparsest chain inside the current best match.
|
|
29
|
+
|
|
30
|
+
The scan runs once, in `encodeTokens`, and packs the token stream as
|
|
31
|
+
`(len|0, dist|byte)` pairs into an `Int32Array` (8 bytes per input byte
|
|
32
|
+
past `start`); `encode` replays that buffer through two callbacks
|
|
33
|
+
(`literal(pos)`, `match(pos, len, dist)`). Both accept `opts.tokens` to
|
|
34
|
+
reuse a caller-owned buffer across calls.
|
|
35
|
+
|
|
36
|
+
## Resolve
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
const lz77 = runtime.resolve('lz77');
|
|
40
|
+
// { encode, encodeTokens, findMatch, decodeStream, DEFAULT }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
| Method | Signature | Returns |
|
|
46
|
+
|--------|-----------|---------|
|
|
47
|
+
| `encode` | `(data: Uint8Array, opts, callbacks) => void` | Scans with `encodeTokens`, replays the pairs via callbacks |
|
|
48
|
+
| `encodeTokens` | `(data: Uint8Array, opts?) => { tokens: Int32Array, count: number }` | The scan: token stream packed as `(len\|0, dist\|byte)` pairs |
|
|
49
|
+
| `findMatch` | `(data, pos, head, prev, opts) => {len, dist} \| null` | Probes a position |
|
|
50
|
+
| `decodeStream` | `(dst: Uint8Array, ops: array) => number` | Test helper: reconstructs from a stream |
|
|
51
|
+
| `DEFAULT` | `object` | Default options |
|
|
52
|
+
|
|
53
|
+
### Options
|
|
54
|
+
|
|
55
|
+
| Option | Type | Default | Description |
|
|
56
|
+
|--------|------|---------|-------------|
|
|
57
|
+
| `windowBits` | `number` (10–24) | `16` | log2 of the sliding window (max backward distance) |
|
|
58
|
+
| `minMatch` | `number` (≥ 3) | `4` | Minimum match length (3 for DEFLATE, 4 for Brotli) |
|
|
59
|
+
| `maxMatch` | `number` | `258` | Maximum match length emitted |
|
|
60
|
+
| `chainDepth` | `number` (≥ 1) | `16` | Max probe depth in the hash chain |
|
|
61
|
+
| `lazy` | `boolean` | `false` | Lazy matching: prefers the next position if it yields a strictly longer match |
|
|
62
|
+
| `hashBits` | `number` (≤ 22) | `17` | log2 of the hash table (allocates `Int32Array`) |
|
|
63
|
+
| `niceLength` | `number` (`minMatch`–`maxMatch`) | `258` | A match this long ends the search at a position (lower = faster, weaker); it is never re-probed lazily either |
|
|
64
|
+
| `goodLength` | `number` (≤ `maxMatch`) | `258` | Lazy only: once the current match is this long, the probe of the next position gets a quarter of `chainDepth` (at least one probe) |
|
|
65
|
+
| `maxLazy` | `number` (≤ `niceLength`) | `258` | Lazy only: once the current match is this long, the next position is not probed at all. Capped at `niceLength` |
|
|
66
|
+
| `chainSkip` | `boolean` | `false` | After a new best match, continue the walk on the chain of the position inside it whose first step back is the widest, instead of the scanned position's own chain — fewer full comparisons on repetitive data, possibly a different (in practice slightly better) match choice under a bounded `chainDepth`. Positions absent from every chain are never followed |
|
|
67
|
+
| `start` | `number` (≥ 0) | `0` | Positions `[0, start)` prime the hash chains but are never emitted; matches may still reach into them |
|
|
68
|
+
| `hashFn` | `((data: Uint8Array, pos: number) => number) \| null` | `null` | Replaces the built-in hasher when given; the result is masked to `hashBits` internally |
|
|
69
|
+
| `tokens` | `Int32Array` | — | Buffer reused by `encodeTokens` / `encode` when it holds `2 × (data.length - start)` entries (throws when too small) |
|
|
70
|
+
|
|
71
|
+
With the defaults, `goodLength` / `maxLazy` never trigger and `chainSkip`
|
|
72
|
+
is off: an option set that predates them scans exactly as before.
|
|
73
|
+
|
|
74
|
+
### Callbacks
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
{
|
|
78
|
+
literal(pos: number): void,
|
|
79
|
+
// data[pos] is emitted as-is as a literal byte.
|
|
80
|
+
|
|
81
|
+
match(pos: number, len: number, dist: number): void,
|
|
82
|
+
// Match of `len` bytes at `pos`, copying from `pos - dist`.
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Examples
|
|
87
|
+
|
|
88
|
+
### Simple round-trip
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
const lz77 = runtime.resolve('lz77');
|
|
92
|
+
const data = new TextEncoder().encode('ABCDABCDABCD');
|
|
93
|
+
|
|
94
|
+
const ops = [];
|
|
95
|
+
lz77.encode(data, { minMatch: 4 }, {
|
|
96
|
+
literal: pos => ops.push({ lit: data[pos] }),
|
|
97
|
+
match: (pos, len, dist) => ops.push({ len, dist }),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Reconstruction
|
|
101
|
+
const out = new Uint8Array(data.length);
|
|
102
|
+
lz77.decodeStream(out, ops);
|
|
103
|
+
new TextDecoder().decode(out); // 'ABCDABCDABCD'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### For a DEFLATE-like codec (minMatch=3)
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
lz77.encode(data, { minMatch: 3, windowBits: 15, chainDepth: 32, lazy: true }, {
|
|
110
|
+
literal: pos => emitLiteral(data[pos]),
|
|
111
|
+
match: (pos, len, dist) => emitMatch(len, dist),
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### For a Brotli-like codec (minMatch=4)
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
lz77.encode(data, { minMatch: 4, windowBits: 22, chainDepth: 16, lazy: true }, {
|
|
119
|
+
literal: pos => insertBuffer.push(data[pos]),
|
|
120
|
+
match: (pos, len, dist) => emitIacCommand(insertBuffer, len, dist),
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Packed tokens (the scan itself)
|
|
125
|
+
|
|
126
|
+
`encodeTokens` is the scan: it packs the `(literal | match)` sequence
|
|
127
|
+
directly into an `Int32Array` as `(len|0, dist|byte)` pairs, optionally
|
|
128
|
+
reusing a caller-supplied buffer. `encode` is a replay of that buffer, so
|
|
129
|
+
a consumer that can read pairs saves one call per token.
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
const lz77 = runtime.resolve('lz77');
|
|
133
|
+
const data = new TextEncoder().encode('ABCDABCDABCD');
|
|
134
|
+
|
|
135
|
+
const { tokens, count } = lz77.encodeTokens(data, { minMatch: 4 });
|
|
136
|
+
for (let k = 0; k < count; ++k) {
|
|
137
|
+
const a = tokens[2 * k], b = tokens[2 * k + 1];
|
|
138
|
+
if (a === 0) consumeLiteral(b); // b = the literal byte
|
|
139
|
+
else consumeMatch(a, b); // a = len, b = dist
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Reuse a preallocated buffer across calls (throws if too small):
|
|
143
|
+
const buf = new Int32Array(2 * data.length);
|
|
144
|
+
lz77.encodeTokens(data, { minMatch: 4, tokens: buf });
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Worker Usage
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const worker = fw.createWorker(
|
|
151
|
+
function ({ libs, args }) {
|
|
152
|
+
const lz77 = libs.lz77;
|
|
153
|
+
let matches = 0, lits = 0;
|
|
154
|
+
lz77.encode(args[0], { minMatch: 4 }, {
|
|
155
|
+
literal: () => ++lits,
|
|
156
|
+
match: () => ++matches,
|
|
157
|
+
});
|
|
158
|
+
self.postMessage({ matches, lits });
|
|
159
|
+
},
|
|
160
|
+
{ dependencies: ['lz77'], args: [new TextEncoder().encode('ABCDABCD')] }
|
|
161
|
+
);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Notes
|
|
165
|
+
|
|
166
|
+
- The implementation uses a Knuth-style multiplicative hash over 3 or 4 bytes (depending on `minMatch`). No optimal distribution guarantees — tune `hashBits` to the typical input size.
|
|
167
|
+
- The tail (the last `minMatch-1` bytes) is always emitted as literals — no match is possible when there are not enough bytes to form a hash key.
|
|
168
|
+
- `chainDepth=1` produces a "fast" encoder (single probe per position); high values (32-256) approach an optimal match at the cost of throughput.
|
|
169
|
+
- After a lazy win the start of the winning match is inserted into the chains like any other match start: earlier versions never inserted it, which left those positions unreachable by later probes — on a 256 KiB JSON corpus that alone cost +2.8 % of output.
|
|
170
|
+
- The probe reports its distance through a factory-scope side channel rather than a `{ len, dist }` object, so the hot loop allocates nothing per match; `findMatch` wraps it into the documented object for callers.
|
|
171
|
+
- No Huffman optimisation or entropy encoding — that is the consumer codec's responsibility.
|
|
172
|
+
- Worker-safe: pure factory, no `window`/`document` access.
|
|
173
|
+
- `hashFn` MUST be pure and read only `data[pos .. pos + minMatch - 1]` — its return value is masked internally (`& ((1 << hashBits) - 1)`), so it may return any integer without risking an out-of-range hash-table index.
|
|
174
|
+
|
|
175
|
+
## See also
|
|
176
|
+
|
|
177
|
+
- [bitstream](./bitstream.md) — bit-level primitive used by consumer codecs
|
|
178
|
+
- [huffman](./huffman.md) — entropy coding that naturally follows LZ77
|
|
179
|
+
- [deflate](./deflate.md) — example codec (RFC 1951) using LZ77 + Huffman
|
|
180
|
+
- [brotli](./brotli.md) — consumer codec (RFC 7932)
|