@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,1031 @@
|
|
|
1
|
+
// Copyright (c) 2026 AwaCloud SAS
|
|
2
|
+
// Author: Matthieu Bouilloux
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @fileoverview DOM-level rendering engine that materialises elm-array data into
|
|
7
|
+
* real DOM nodes using a pre-built catalogue of `<template>` elements as cloning
|
|
8
|
+
* sources.
|
|
9
|
+
*
|
|
10
|
+
* Each named **context** owns:
|
|
11
|
+
* - A container element (`ctx`) where nodes are inserted.
|
|
12
|
+
* - A `map` of live element entries indexed by element ID.
|
|
13
|
+
* - A reference to a shared template catalogue (`tpl`).
|
|
14
|
+
* - Optional `head`, `styles`, and `scripts` registries for page-level contexts.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An entry in the live element map maintained per context.
|
|
20
|
+
*
|
|
21
|
+
* @typedef {Object} MapEntry
|
|
22
|
+
* @property {Element} node - The live DOM node.
|
|
23
|
+
* @property {Element} target - The direct DOM parent of `node`.
|
|
24
|
+
* @property {string} tag - Internal tag name (e.g. `'div'`, `'text'`).
|
|
25
|
+
* @property {string[]} children - Ordered list of child element IDs.
|
|
26
|
+
* @property {string[]} [childCtxs] - Names of nested contexts whose root node is
|
|
27
|
+
* a child of this element; cleared together with
|
|
28
|
+
* this entry.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Descriptor for a single entry in the template catalogue.
|
|
33
|
+
* Entries may be a plain tag-name string or a configuration object.
|
|
34
|
+
*
|
|
35
|
+
* @typedef {string | {
|
|
36
|
+
* name : string,
|
|
37
|
+
* tag ?: string,
|
|
38
|
+
* svg ?: boolean,
|
|
39
|
+
* child ?: string,
|
|
40
|
+
* attrs ?: Object.<string, string>
|
|
41
|
+
* }} TagSpec
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Options accepted by `cmd.init`.
|
|
46
|
+
*
|
|
47
|
+
* @typedef {Object} InitOptions
|
|
48
|
+
* @property {string | Element} to - CSS selector string or a DOM element
|
|
49
|
+
* used as the render container.
|
|
50
|
+
* @property {boolean} [main] - When `true`, the template catalogue
|
|
51
|
+
* is stored under the shared `'main'` key so all non-main contexts can share it.
|
|
52
|
+
* @property {boolean} [page] - When `true`, the container is treated
|
|
53
|
+
* as a full page document: `ctx` → `body`, `head` → `head`, plus `styles` / `scripts`
|
|
54
|
+
* registries are created.
|
|
55
|
+
* @property {string | HTMLElement[] | NodeListOf<HTMLTemplateElement>} [tpl] - Custom
|
|
56
|
+
* template source. A string is treated as a CSS selector whose children are
|
|
57
|
+
* `<template>` elements. An array/NodeList is used directly. When omitted,
|
|
58
|
+
* `DEFAULT_TAGS` are used to auto-generate templates.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A render context entry stored in the internal `contexts` map.
|
|
63
|
+
*
|
|
64
|
+
* @typedef {Object} ContextEntry
|
|
65
|
+
* @property {Element} ctx - Root container element.
|
|
66
|
+
* @property {Object.<string, MapEntry>} map - Live element map (id → entry).
|
|
67
|
+
* @property {string} tpl - Key into the template catalogue.
|
|
68
|
+
* @property {Document} [page] - Owning document (page contexts only).
|
|
69
|
+
* @property {Element} [head] - `<head>` element (page contexts only).
|
|
70
|
+
* @property {Object.<string, Element>} [styles] - `<style>` nodes keyed by id.
|
|
71
|
+
* @property {Object.<string, Element>} [scripts] - `<script>` nodes keyed by id.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
import { secPolicy } from './secPolicy.js';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Public API object returned by `template.factory()` (the internal `cmd`).
|
|
78
|
+
* DOM materialiser : clones `<template>` sources into live nodes and tracks
|
|
79
|
+
* them per named context.
|
|
80
|
+
*
|
|
81
|
+
* @typedef {object} TemplateAPI
|
|
82
|
+
* @property {(name: string, options?: InitOptions) => ContextEntry} init Initialise a named render context bound to a container; throws if the name already exists.
|
|
83
|
+
* @property {TagSpec[]} DEFAULT_TAGS Default tag catalogue used when no custom template source is supplied.
|
|
84
|
+
* @property {(tags?: TagSpec[]) => HTMLTemplateElement[]} generateTemplateTags Build detached `<template>` elements from tag specs.
|
|
85
|
+
* @property {(tags: TagSpec[], ctxName?: string) => string[]} registerTags Extend a catalogue; returns the names registered.
|
|
86
|
+
* @property {(tags: TagSpec[], ctxName?: string) => { added: string[], removed: string[] }} reloadTags Replace-set a catalogue; returns added/removed names.
|
|
87
|
+
* @property {(name: string, ctxName?: string) => boolean} unregisterTag Remove one tag entry; returns whether one was removed.
|
|
88
|
+
* @property {(name: string) => (Element|Document|null)} container Container element for a context, or `null`.
|
|
89
|
+
* @property {(ctxName: string, id: string, node: Element, parentId?: string) => void} adoptNode Register an existing DOM node (SSR hydration); throws on duplicate id.
|
|
90
|
+
* @property {(value: (string|null)) => void} setNonce Set/clear the CSP nonce applied to inserted `<style>`/`<script>`.
|
|
91
|
+
* @property {() => string} getNonce Current CSP nonce, or `''`.
|
|
92
|
+
* @property {(name: string) => (object|null)} getCtx Raw internal context entry, or `null`.
|
|
93
|
+
* @property {(name: string, attrs: Object.<string,string>) => void} pageAttr Set whitelisted attributes on a page context's `<body>`.
|
|
94
|
+
* @property {(name: string, data: (import('./parser').ElmNode|import('./parser').ElmNode[]), parent?: string, index?: number) => void} elm Materialise a single elm node (or array) into the DOM.
|
|
95
|
+
* @property {(anchor: string, elm_array: import('./parser').ElmNode[], parent?: string) => void} elms Materialise an ordered elm array into the DOM.
|
|
96
|
+
* @property {(name: string, id: string) => (Element|null)} get Live DOM node for an element id, or `null`.
|
|
97
|
+
* @property {(name: string, id: string) => boolean} has Whether an element id exists in a context.
|
|
98
|
+
* @property {(name: string, node: Element, newParent: Element) => void} move Move a node under a new parent within a context.
|
|
99
|
+
* @property {(name: string, id: string, css: string) => void} style Insert/update a `<style>` in a page context's `<head>`.
|
|
100
|
+
* @property {(name: string, id: string) => void} removeStyle Remove a named `<style>`.
|
|
101
|
+
* @property {(name: string, id: string, options?: { content?: string, type?: string }) => void} script Insert/replace a `<script>` in a page context's `<head>`.
|
|
102
|
+
* @property {(name: string, id: string) => void} removeScript Remove a named `<script>`.
|
|
103
|
+
* @property {(parseResult: { template: import('./parser').ElmNode[], iterates?: Object.<string, import('./parser').ElmNode[]> }) => object} fromParseResult Validate a precompiled ParseResult; returns it unchanged.
|
|
104
|
+
* @property {(name: string) => void} clearContext Tear down a context: remove its container and delete the entry.
|
|
105
|
+
* @property {(name: string) => string[]} clearAll Remove all rendered elements from a context; returns removed ids.
|
|
106
|
+
* @property {(name: string, id: string) => string[]} clearElm Remove an element and its subtree; returns removed ids.
|
|
107
|
+
* @property {(name: string, id: string) => string[]} clearIn Clear an element's children; returns removed descendant ids.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
export const template = {
|
|
111
|
+
name: 'template',
|
|
112
|
+
type: 'fw.dom.rendering',
|
|
113
|
+
dependencies: ['secPolicy'],
|
|
114
|
+
deps: [secPolicy],
|
|
115
|
+
|
|
116
|
+
/** @returns {TemplateAPI} */
|
|
117
|
+
factory(secPolicy) {
|
|
118
|
+
|
|
119
|
+
const contexts = {};
|
|
120
|
+
const tpl = {};
|
|
121
|
+
const nodeIndex = new WeakMap();
|
|
122
|
+
// CSP nonce applied to all `<style>` / `<script>` elements created via
|
|
123
|
+
// `cmd.style` / `cmd.script`. Auto-detected from a `<meta name="csp-nonce">`
|
|
124
|
+
// tag at factory init ; can be overridden at runtime via `cmd.setNonce`.
|
|
125
|
+
let cspNonce = (typeof document !== 'undefined')
|
|
126
|
+
? (document.querySelector('meta[name="csp-nonce"]')?.getAttribute('content') ?? '')
|
|
127
|
+
: '';
|
|
128
|
+
|
|
129
|
+
// --- Internal utilities ---
|
|
130
|
+
// All security primitives below are sourced from `secPolicy` - single
|
|
131
|
+
// source of truth, shared with `render.toHTML` (SSR path), `sanitize`
|
|
132
|
+
// (HTML user-input path), `dom.styleApply` (CSS path) and `parser`
|
|
133
|
+
// (parse-time tag/attr rejection). See `secPolicy.js` for the full
|
|
134
|
+
// policy.
|
|
135
|
+
const ATTR_RE = secPolicy.SAFE_ATTR_NAME_RE;
|
|
136
|
+
const ATTR_EVT = secPolicy.EVENT_ATTR_RE;
|
|
137
|
+
const URL_ATTRS = secPolicy.URL_ATTRS;
|
|
138
|
+
const CLOBBER_ATTRS = secPolicy.CLOBBER_ATTRS;
|
|
139
|
+
const CLOBBER_NAMES = secPolicy.CLOBBER_NAMES;
|
|
140
|
+
const _isSafeUrl = (url) => secPolicy.isSafeUrl(url);
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Unwrap the actual element from an SVG `<template>`'s content.
|
|
144
|
+
*
|
|
145
|
+
* When a template's first child is an `<svg>` element that wraps a single
|
|
146
|
+
* child (e.g. a `<use>` inside `<svg>`), return that inner child instead
|
|
147
|
+
* so the clone target is the SVG child element directly.
|
|
148
|
+
*
|
|
149
|
+
* @param {Element} first - First child of a `<template>`'s content fragment.
|
|
150
|
+
* @returns {Element} The element to use as the clone source.
|
|
151
|
+
*/
|
|
152
|
+
function resolveTemplateNode(first) {
|
|
153
|
+
return (first instanceof SVGSVGElement && first.children.length === 1)
|
|
154
|
+
? first.children[0]
|
|
155
|
+
: first;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Apply elm-node data (attributes and text content) to a DOM node.
|
|
160
|
+
* Event handler attributes (`on*`) and attributes not starting with a letter
|
|
161
|
+
* are silently skipped for security.
|
|
162
|
+
*
|
|
163
|
+
* @param {Element} node - Target DOM node to mutate.
|
|
164
|
+
* @param {import('./parser').ElmNode} data - Elm node carrying `attrs`, `data`,
|
|
165
|
+
* `text`, and `id`.
|
|
166
|
+
* @returns {Element} The mutated `node` (same reference).
|
|
167
|
+
*/
|
|
168
|
+
function applyAttributes(node, data) {
|
|
169
|
+
if (data.attrs) {
|
|
170
|
+
for (const attr of data.attrs) {
|
|
171
|
+
if (ATTR_EVT.test(attr) || !ATTR_RE.test(attr)) continue;
|
|
172
|
+
const v = data.data?.[attr];
|
|
173
|
+
// Conditional attribute: omit when null / false / undefined,
|
|
174
|
+
// set otherwise - including empty string and 0. This lets a
|
|
175
|
+
// single template handle both presence/absence of boolean
|
|
176
|
+
// attributes via data bindings (e.g. `<details open="#{o}">`
|
|
177
|
+
// with `o:''` → open, `o:null` → closed).
|
|
178
|
+
if (v === null || v === false || v === undefined) continue;
|
|
179
|
+
// Defence in depth : URL-bearing attributes are filtered
|
|
180
|
+
// through `_isSafeUrl` to block `javascript:`, `vbscript:`,
|
|
181
|
+
// and dangerous `data:` schemes that could be injected
|
|
182
|
+
// via the `#{var}` bindings. Aligns with `sanity/base.js`
|
|
183
|
+
// intent - sanity blocks HTML mutation but cannot inspect
|
|
184
|
+
// attribute values set via setAttribute.
|
|
185
|
+
// Some default-tag templates pre-set `href`/`src` to `''`
|
|
186
|
+
// (DEFAULT_TAGS spec) - we must REMOVE the attribute when
|
|
187
|
+
// the value is unsafe rather than just skip setAttribute,
|
|
188
|
+
// otherwise the pre-set empty value would leak through.
|
|
189
|
+
if (URL_ATTRS.has(attr) && !_isSafeUrl(String(v))) {
|
|
190
|
+
node.removeAttribute(attr);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
// DOM clobbering defence : reject `id`/`name` values that
|
|
194
|
+
// collide with built-in document.* properties. Such values
|
|
195
|
+
// would make `document.cookie` etc. resolve to the element
|
|
196
|
+
// instead of the native API.
|
|
197
|
+
if (CLOBBER_ATTRS.has(attr) && CLOBBER_NAMES.has(String(v))) {
|
|
198
|
+
node.removeAttribute(attr);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
node.setAttribute(attr, v);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (data.text != null) {
|
|
205
|
+
node.textContent = data.text;
|
|
206
|
+
}
|
|
207
|
+
node.setAttribute('id', data.id);
|
|
208
|
+
return node;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Clone the template node matching `data.tag` from the context's catalogue
|
|
213
|
+
* and apply elm-node data to the clone.
|
|
214
|
+
*
|
|
215
|
+
* The synthetic `'text'` tag is mapped to `'span'` for DOM creation.
|
|
216
|
+
*
|
|
217
|
+
* @param {string} ctxName - Name of the render context.
|
|
218
|
+
* @param {import('./parser').ElmNode} data - Elm node to materialise.
|
|
219
|
+
* @returns {Element|null} The cloned and populated node, or `null` when no
|
|
220
|
+
* matching template entry exists for the tag.
|
|
221
|
+
*/
|
|
222
|
+
function cloneAndApply(ctxName, data) {
|
|
223
|
+
const tplKey = contexts[ctxName].tpl;
|
|
224
|
+
const tag = data.tag === 'text' ? 'span' : data.tag;
|
|
225
|
+
|
|
226
|
+
if(!Object.prototype.hasOwnProperty.call(tpl[tplKey], tag)){
|
|
227
|
+
return null;
|
|
228
|
+
} else {
|
|
229
|
+
return applyAttributes(tpl[tplKey][tag].cloneNode(), data);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Insert `node` into `target`, either prepending or appending.
|
|
235
|
+
*
|
|
236
|
+
* @param {Element} target - Parent element to insert into.
|
|
237
|
+
* @param {Element} node - Node to insert.
|
|
238
|
+
* @param {boolean} prepend - `true` to insert before the first child;
|
|
239
|
+
* `false` to append.
|
|
240
|
+
*/
|
|
241
|
+
function insertNode(target, node, prepend) {
|
|
242
|
+
if (prepend) {
|
|
243
|
+
target.insertBefore(node, target.firstChild);
|
|
244
|
+
} else {
|
|
245
|
+
target.appendChild(node);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Recursively collect all descendant IDs of the given `ids` from a context
|
|
251
|
+
* map, removing each visited entry from `map` in the process.
|
|
252
|
+
* Nested child contexts encountered during traversal are cleared via
|
|
253
|
+
* {@link cmd.clearContext}.
|
|
254
|
+
*
|
|
255
|
+
* @param {string} ctxName - Name of the render context.
|
|
256
|
+
* @param {string[]} ids - Root IDs whose subtrees should be collected.
|
|
257
|
+
* @returns {string[]} All collected descendant IDs (excluding the roots
|
|
258
|
+
* themselves - callers are responsible for those).
|
|
259
|
+
*/
|
|
260
|
+
function collectChildren(ctxName, ids) {
|
|
261
|
+
const map = contexts[ctxName].map;
|
|
262
|
+
const collected = [];
|
|
263
|
+
const stack = [...ids];
|
|
264
|
+
|
|
265
|
+
while (stack.length > 0) {
|
|
266
|
+
const id = stack.pop();
|
|
267
|
+
if (map[id]) {
|
|
268
|
+
stack.push(...map[id].children);
|
|
269
|
+
if (map[id].childCtxs) {
|
|
270
|
+
for (const childCtxName of map[id].childCtxs) {
|
|
271
|
+
cmd.clearContext(childCtxName);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
collected.push(id);
|
|
275
|
+
delete map[id];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return collected;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// --- Template generation ---
|
|
283
|
+
|
|
284
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Default tag catalogue used when no custom template source is provided.
|
|
288
|
+
* Each entry is either a plain tag-name string or a {@link TagSpec} object.
|
|
289
|
+
*
|
|
290
|
+
* @type {TagSpec[]}
|
|
291
|
+
*/
|
|
292
|
+
const DEFAULT_TAGS = [
|
|
293
|
+
'div', 'span',
|
|
294
|
+
'nav', 'header', 'footer', 'section', 'article', 'aside', 'main',
|
|
295
|
+
{ name: 'a', attrs: { href: '' } },
|
|
296
|
+
'button',
|
|
297
|
+
'input', 'form', 'label', 'select', 'option', 'textarea', 'fieldset', 'legend',
|
|
298
|
+
'table', 'tr', 'td', 'th', 'thead', 'tbody', 'tfoot', 'caption',
|
|
299
|
+
'ul', 'li', 'ol',
|
|
300
|
+
'dl', 'dt', 'dd',
|
|
301
|
+
'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
|
|
302
|
+
'br', 'hr',
|
|
303
|
+
'p', 'i', 'b', 'em', 'strong', 'small', 'pre', 'code', 'kbd', 'samp', 'var', 'mark',
|
|
304
|
+
'abbr', 'cite', 'q', 'blockquote', 's', 'u', 'sub', 'sup', 'time',
|
|
305
|
+
'details', 'summary',
|
|
306
|
+
'figure', 'figcaption',
|
|
307
|
+
'dialog', 'progress', 'meter',
|
|
308
|
+
'video', 'audio',
|
|
309
|
+
'picture',
|
|
310
|
+
{ name: 'img', attrs: { src: '', alt: '' } },
|
|
311
|
+
{ name: 'cvs', tag: 'canvas' },
|
|
312
|
+
{ name: 'svg', svg: true },
|
|
313
|
+
{ name: 'svg_use', svg: true, child: 'use' }
|
|
314
|
+
];
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Build an array of detached `<template>` elements from a {@link TagSpec}
|
|
318
|
+
* array, ready to be used as a clone-source catalogue.
|
|
319
|
+
*
|
|
320
|
+
* Each `<template>` element's `className` matches the entry name so it can
|
|
321
|
+
* be looked up by tag name at render time.
|
|
322
|
+
*
|
|
323
|
+
* @param {TagSpec[]} [tags=DEFAULT_TAGS] - Tag specifications to generate
|
|
324
|
+
* templates for.
|
|
325
|
+
* @returns {HTMLTemplateElement[]} Array of fully configured `<template>`
|
|
326
|
+
* elements (detached from any document).
|
|
327
|
+
*/
|
|
328
|
+
function generateTemplateTags(tags = DEFAULT_TAGS) {
|
|
329
|
+
return tags.map(entry => {
|
|
330
|
+
const t = document.createElement('template');
|
|
331
|
+
const isObj = typeof entry === 'object';
|
|
332
|
+
const name = isObj ? entry.name : entry;
|
|
333
|
+
const tag = isObj && entry.tag ? entry.tag : (isObj && entry.svg) ? 'svg' : name;
|
|
334
|
+
|
|
335
|
+
t.className = name;
|
|
336
|
+
|
|
337
|
+
const el = (isObj && entry.svg)
|
|
338
|
+
? document.createElementNS(SVG_NS, tag)
|
|
339
|
+
: document.createElement(tag);
|
|
340
|
+
|
|
341
|
+
if (isObj && entry.attrs) {
|
|
342
|
+
for (const [k, v] of Object.entries(entry.attrs)) {
|
|
343
|
+
el.setAttribute(k, v);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (isObj && entry.child) {
|
|
348
|
+
el.appendChild(document.createElementNS(SVG_NS, entry.child));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
t.content.appendChild(el);
|
|
352
|
+
return t;
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// --- Public API ---
|
|
357
|
+
|
|
358
|
+
const cmd = {};
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Initialise a named render context bound to a container element.
|
|
362
|
+
*
|
|
363
|
+
* - If the container is already tracked by the `nodeIndex` (i.e. it is itself
|
|
364
|
+
* a rendered element in an existing context), the new context is registered
|
|
365
|
+
* as a child context of that element so that it is torn down automatically
|
|
366
|
+
* when the parent element is cleared.
|
|
367
|
+
* - When `options.main` is `true`, the template catalogue is shared under the
|
|
368
|
+
* `'main'` key; subsequent non-main contexts with no custom `tpl` will
|
|
369
|
+
* reuse it.
|
|
370
|
+
* - Requires at least one valid template source; no runtime guard is applied.
|
|
371
|
+
*
|
|
372
|
+
* Throws when a context with the same `name` already exists. This is a
|
|
373
|
+
* strict contract - callers who genuinely want hot-reload semantics
|
|
374
|
+
* must call `clearContext(name)` first. Silently overwriting was a
|
|
375
|
+
* latent bug : already-rendered DOM became orphaned (still in the
|
|
376
|
+
* page but no longer in the map).
|
|
377
|
+
*
|
|
378
|
+
* @param {string} name - Unique context name.
|
|
379
|
+
* @param {InitOptions} [options={}] - Configuration options.
|
|
380
|
+
* @returns {ContextEntry} The newly created context entry.
|
|
381
|
+
* @throws {Error} When `name` is already registered.
|
|
382
|
+
*/
|
|
383
|
+
// ── Container fn
|
|
384
|
+
cmd.init = function (name, /** @type {InitOptions} */ options = /** @type {InitOptions} */ ({})) {
|
|
385
|
+
// if templates empty --> will fail (no catch or check in this factory)
|
|
386
|
+
|
|
387
|
+
if (contexts[name]) {
|
|
388
|
+
throw new Error(
|
|
389
|
+
`template.init: context '${name}' already exists. ` +
|
|
390
|
+
`Call clearContext('${name}') first if you want to re-init.`
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const { main, page } = options;
|
|
395
|
+
const tplSrc = options.tpl;
|
|
396
|
+
|
|
397
|
+
const container = typeof options.to === 'string'
|
|
398
|
+
? document.querySelector(options.to)
|
|
399
|
+
: options.to;
|
|
400
|
+
|
|
401
|
+
const ref = nodeIndex.get(container);
|
|
402
|
+
if (ref) {
|
|
403
|
+
const entry = contexts[ref.ctxName].map[ref.id];
|
|
404
|
+
if (!entry.childCtxs) entry.childCtxs = [];
|
|
405
|
+
entry.childCtxs.push(name);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
if (page) {
|
|
409
|
+
const pageDoc = /** @type {Document} */ (/** @type {*} */ (container));
|
|
410
|
+
contexts[name] = {
|
|
411
|
+
page: container,
|
|
412
|
+
head: pageDoc.head,
|
|
413
|
+
ctx: pageDoc.body,
|
|
414
|
+
map: {},
|
|
415
|
+
styles: {},
|
|
416
|
+
scripts: {}
|
|
417
|
+
};
|
|
418
|
+
} else {
|
|
419
|
+
contexts[name] = {
|
|
420
|
+
ctx: container,
|
|
421
|
+
map: {}
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (main || tplSrc) {
|
|
426
|
+
const tplKey = main ? 'main' : name;
|
|
427
|
+
const templates = typeof tplSrc === 'string'
|
|
428
|
+
? document.querySelectorAll(tplSrc + ' > template')
|
|
429
|
+
: (tplSrc ?? generateTemplateTags());
|
|
430
|
+
|
|
431
|
+
tpl[tplKey] = {};
|
|
432
|
+
/** @type {HTMLTemplateElement[]} */
|
|
433
|
+
const templateArr = /** @type {HTMLTemplateElement[]} */ (Array.from(/** @type {*} */ (templates)));
|
|
434
|
+
for (const t of templateArr) {
|
|
435
|
+
tpl[tplKey][t.className] = resolveTemplateNode(/** @type {Element} */ (t.content.firstChild));
|
|
436
|
+
}
|
|
437
|
+
contexts[name].tpl = tplKey;
|
|
438
|
+
|
|
439
|
+
} else {
|
|
440
|
+
contexts[name].tpl = 'main';
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return contexts[name];
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
/** @type {TagSpec[]} */
|
|
447
|
+
cmd.DEFAULT_TAGS = DEFAULT_TAGS;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Expose the template-generation utility for callers that need to extend or
|
|
451
|
+
* pre-build a catalogue outside of `init`.
|
|
452
|
+
*
|
|
453
|
+
* @type {typeof generateTemplateTags}
|
|
454
|
+
*/
|
|
455
|
+
cmd.generateTemplateTags = generateTemplateTags;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Extend an existing template catalogue with additional tag entries.
|
|
459
|
+
*
|
|
460
|
+
* Useful when the caller cannot enumerate every tag at `init` time, or when
|
|
461
|
+
* different parts of the app share a single `'main'` catalogue but need to
|
|
462
|
+
* register their own custom tags after bootstrap.
|
|
463
|
+
*
|
|
464
|
+
* @param {TagSpec[]} tags - Tag specs to add (same shape as `DEFAULT_TAGS`
|
|
465
|
+
* entries: plain string, or `{ name, tag?, attrs?, svg?, child? }`).
|
|
466
|
+
* @param {string} [ctxName] - Target context whose catalogue to extend.
|
|
467
|
+
* Defaults to `'main'` (the shared catalogue created by any `init` with
|
|
468
|
+
* `{ main: true }`).
|
|
469
|
+
* @returns {string[]} Names of the tags actually registered (after the
|
|
470
|
+
* add). Already-present names are overwritten silently.
|
|
471
|
+
*/
|
|
472
|
+
cmd.registerTags = function (tags, ctxName) {
|
|
473
|
+
const tplKey = ctxName ? (contexts[ctxName]?.tpl ?? ctxName) : 'main';
|
|
474
|
+
if (!tpl[tplKey]) tpl[tplKey] = {};
|
|
475
|
+
const generated = generateTemplateTags(tags);
|
|
476
|
+
const added = [];
|
|
477
|
+
for (const t of generated) {
|
|
478
|
+
tpl[tplKey][t.className] = resolveTemplateNode(/** @type {Element} */ (t.content.firstChild));
|
|
479
|
+
added.push(t.className);
|
|
480
|
+
}
|
|
481
|
+
return added;
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Hot-reload the tag catalogue of a context. Like {@link cmd.registerTags}
|
|
486
|
+
* but with **replace-set semantics** : after the call, the context's
|
|
487
|
+
* catalogue contains **exactly** `tags`, no more. Useful for HMR-style
|
|
488
|
+
* scenarios where the template file is re-parsed at dev-time and the
|
|
489
|
+
* old tags must be purged.
|
|
490
|
+
*
|
|
491
|
+
* Already-mounted DOM nodes are **NOT** re-rendered - only the
|
|
492
|
+
* future clone source (the `<template>` registry) is swapped.
|
|
493
|
+
* Consumers wanting full re-render must call `cmd.clearAll(ctxName)`
|
|
494
|
+
* + `ui.add(...)` afterwards. The narrower scope here is intentional
|
|
495
|
+
* (re-rendering on hot-reload is a host-level concern, not fw).
|
|
496
|
+
*
|
|
497
|
+
* Recipe :
|
|
498
|
+
*
|
|
499
|
+
* // 1. Swap the catalogue.
|
|
500
|
+
* tpl.reloadTags(newTags, 'main');
|
|
501
|
+
* // 2. Tear down the old DOM.
|
|
502
|
+
* tpl.clearAll('main');
|
|
503
|
+
* // 3. Re-add the items (UI session, app shell, …).
|
|
504
|
+
* ui.add(items);
|
|
505
|
+
*
|
|
506
|
+
* @param {TagSpec[]} tags
|
|
507
|
+
* @param {string} [ctxName]
|
|
508
|
+
* @returns {{ added: string[], removed: string[] }}
|
|
509
|
+
*/
|
|
510
|
+
cmd.reloadTags = function (tags, ctxName) {
|
|
511
|
+
const tplKey = ctxName ? (contexts[ctxName]?.tpl ?? ctxName) : 'main';
|
|
512
|
+
const before = tpl[tplKey] ? Object.keys(tpl[tplKey]) : [];
|
|
513
|
+
tpl[tplKey] = {}; // wipe
|
|
514
|
+
const added = cmd.registerTags(tags, ctxName);
|
|
515
|
+
const removed = before.filter(n => !added.includes(n));
|
|
516
|
+
return { added, removed };
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Remove one tag entry from a context's catalogue. No-op when absent.
|
|
521
|
+
*
|
|
522
|
+
* @param {string} name - Internal tag name (`'a'`, `'svg_use'`, …).
|
|
523
|
+
* @param {string} [ctxName] - Default `'main'`.
|
|
524
|
+
* @returns {boolean} `true` when an entry was actually removed.
|
|
525
|
+
*/
|
|
526
|
+
cmd.unregisterTag = function (name, ctxName) {
|
|
527
|
+
const tplKey = ctxName ? (contexts[ctxName]?.tpl ?? ctxName) : 'main';
|
|
528
|
+
if (tpl[tplKey] && Object.prototype.hasOwnProperty.call(tpl[tplKey], name)) {
|
|
529
|
+
delete tpl[tplKey][name];
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
return false;
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Return the container element associated with a context.
|
|
537
|
+
*
|
|
538
|
+
* Useful when callers need a stable reference to the DOM root for event
|
|
539
|
+
* delegation, intersection observers, etc., without re-querying via
|
|
540
|
+
* `document.getElementById` or a CSS selector.
|
|
541
|
+
*
|
|
542
|
+
* @param {string} name - Context name (created via `cmd.init`).
|
|
543
|
+
* @returns {Element | Document | null} Container element, or `null` if the
|
|
544
|
+
* context does not exist.
|
|
545
|
+
*/
|
|
546
|
+
cmd.container = function (name) {
|
|
547
|
+
return contexts[name]?.ctx ?? null;
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Register an **existing** DOM node into a context's live element map
|
|
552
|
+
* without creating a new clone. Used by `uiSession.hydrate(...)` to
|
|
553
|
+
* adopt server-rendered HTML : the nodes are already in the DOM with
|
|
554
|
+
* `data-fw-id` markers ; this method threads them through the same
|
|
555
|
+
* bookkeeping that `cmd.elm` would have done if the node had been
|
|
556
|
+
* created client-side.
|
|
557
|
+
*
|
|
558
|
+
* Strict on duplicate id : throws when `id` is already mapped. This
|
|
559
|
+
* surfaces SSR hydration mismatches immediately rather than silently
|
|
560
|
+
* dropping the second registration (which previously discarded any
|
|
561
|
+
* differing `parentId`, leaving the tree inconsistent).
|
|
562
|
+
*
|
|
563
|
+
* @param {string} ctxName - Name of the render context.
|
|
564
|
+
* @param {string} id - Logical id under which to register.
|
|
565
|
+
* Will become the entry's key in `contexts[name].map`.
|
|
566
|
+
* @param {Element} node - The existing DOM element.
|
|
567
|
+
* @param {string} [parentId] - Optional parent id (already registered)
|
|
568
|
+
* to maintain the parent-children tree.
|
|
569
|
+
* @throws {Error} When `ctxName` does not exist or `id` is already adopted.
|
|
570
|
+
*/
|
|
571
|
+
cmd.adoptNode = function (ctxName, id, node, parentId) {
|
|
572
|
+
const ctx = contexts[ctxName];
|
|
573
|
+
if (!ctx) throw new Error(`template.adoptNode: unknown context '${ctxName}'`);
|
|
574
|
+
if (ctx.map[id]) {
|
|
575
|
+
throw new Error(
|
|
576
|
+
`template.adoptNode: id '${id}' is already registered in context '${ctxName}'. ` +
|
|
577
|
+
`Re-adoption with a different parentId would silently corrupt the tree.`
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const entry = {
|
|
582
|
+
node,
|
|
583
|
+
target: node?.parentNode ?? null,
|
|
584
|
+
tag: typeof node?.tagName === 'string' ? node.tagName.toLowerCase() : 'div',
|
|
585
|
+
children: [],
|
|
586
|
+
};
|
|
587
|
+
ctx.map[id] = entry;
|
|
588
|
+
if (node) nodeIndex.set(node, { ctxName, id });
|
|
589
|
+
|
|
590
|
+
if (parentId && ctx.map[parentId]) {
|
|
591
|
+
ctx.map[parentId].children.push(id);
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Set or update the CSP nonce applied to all `<style>` and `<script>`
|
|
597
|
+
* elements created via {@link cmd.style} / {@link cmd.script}. Pass `''`
|
|
598
|
+
* or `null` to disable.
|
|
599
|
+
*
|
|
600
|
+
* At factory init, the nonce is auto-read from a
|
|
601
|
+
* `<meta name="csp-nonce" content="…">` tag if present. Call this
|
|
602
|
+
* setter to override (e.g. when the nonce is rotated, or fetched async).
|
|
603
|
+
*
|
|
604
|
+
* Existing `<style>`/`<script>` nodes are NOT retro-actively updated -
|
|
605
|
+
* the nonce only applies to subsequent insertions.
|
|
606
|
+
*
|
|
607
|
+
* @param {string|null} value - Nonce value, or empty/null to disable.
|
|
608
|
+
*/
|
|
609
|
+
cmd.setNonce = function (value) {
|
|
610
|
+
cspNonce = value ? String(value) : '';
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Read the current CSP nonce applied to inserted `<style>`/`<script>`.
|
|
615
|
+
* @returns {string} Current nonce, or `''` when none is configured.
|
|
616
|
+
*/
|
|
617
|
+
cmd.getNonce = function () {
|
|
618
|
+
return cspNonce;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Return the full context entry (raw internal record) for inspection.
|
|
623
|
+
*
|
|
624
|
+
* Intended for debugging or for advanced callers that need the live map of
|
|
625
|
+
* IDs. The returned object is the framework's internal state - do not
|
|
626
|
+
* mutate it directly.
|
|
627
|
+
*
|
|
628
|
+
* @param {string} name - Context name.
|
|
629
|
+
* @returns {Object | null} Internal context entry, or `null` if absent.
|
|
630
|
+
*/
|
|
631
|
+
cmd.getCtx = function (name) {
|
|
632
|
+
return contexts[name] ?? null;
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* Set whitelisted attributes on the `<body>` element of a page context.
|
|
637
|
+
* Only `class`, `style`, and `data-*` attributes are accepted; all others
|
|
638
|
+
* are silently ignored.
|
|
639
|
+
*
|
|
640
|
+
* @param {string} name - Page context name.
|
|
641
|
+
* @param {Object.<string,string>} attrs - Attribute key/value pairs.
|
|
642
|
+
*/
|
|
643
|
+
cmd.pageAttr = function (name, attrs) {
|
|
644
|
+
const body = contexts[name].ctx;
|
|
645
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
646
|
+
if (ATTR_RE.test(key) && (key === 'class' || key === 'style' || key.startsWith('data-'))) {
|
|
647
|
+
body.setAttribute(key, value);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Materialise a single elm node (or a full elm array) into the DOM under
|
|
654
|
+
* the named context.
|
|
655
|
+
*
|
|
656
|
+
* - When `data` is an **array**, delegates to {@link cmd.elms}.
|
|
657
|
+
* - When the element ID already exists in the context map, the existing DOM
|
|
658
|
+
* node is replaced in-place (children first cleared via {@link cmd.clearIn}).
|
|
659
|
+
* - When the element is new, it is cloned from the catalogue and inserted
|
|
660
|
+
* into the correct parent (or the context root).
|
|
661
|
+
* - Returns without action if `data.id` or `data.tag` are missing or not
|
|
662
|
+
* strings.
|
|
663
|
+
*
|
|
664
|
+
* @param {string} name - Context name.
|
|
665
|
+
* @param {import('./parser').ElmNode | import('./parser').ElmNode[]} data -
|
|
666
|
+
* Single elm node or an array of elm nodes to render.
|
|
667
|
+
*/
|
|
668
|
+
// ── Elements fn
|
|
669
|
+
cmd.elm = function (name, data, parent, index = 0) {
|
|
670
|
+
if(Array.isArray(data)){
|
|
671
|
+
cmd.elms(name, data);
|
|
672
|
+
} else {
|
|
673
|
+
|
|
674
|
+
if(data.tag && typeof data.tag === 'string') {
|
|
675
|
+
if(!data.id || typeof data.id !== 'string'){
|
|
676
|
+
data.id = (Date.now().toString(36) + index.toString() + crypto.getRandomValues(new Uint32Array(1))[0].toString(36))
|
|
677
|
+
}
|
|
678
|
+
const ctx = contexts[name];
|
|
679
|
+
|
|
680
|
+
if (ctx.map[data.id]) {
|
|
681
|
+
// Update existing element
|
|
682
|
+
cmd.clearIn(name, data.id);
|
|
683
|
+
const entry = ctx.map[data.id];
|
|
684
|
+
const newNode = cloneAndApply(name, data);
|
|
685
|
+
if(newNode !== null) {
|
|
686
|
+
entry.node.parentNode.replaceChild(newNode, entry.node);
|
|
687
|
+
entry.node = newNode;
|
|
688
|
+
nodeIndex.set(newNode, {ctxName: name, id: data.id});
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if(data.child && Array.isArray(data.child)){
|
|
692
|
+
cmd.elms(name, data.child, data.id);
|
|
693
|
+
}
|
|
694
|
+
} else {
|
|
695
|
+
// Create new element
|
|
696
|
+
const entry = {
|
|
697
|
+
node: null,
|
|
698
|
+
target: null,
|
|
699
|
+
tag: data.tag === 'text' ? 'text' : data.tag,
|
|
700
|
+
children: []
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
// Resolve target
|
|
704
|
+
if (data.parent && ctx.map[data.parent]) {
|
|
705
|
+
entry.target = ctx.map[data.parent].node;
|
|
706
|
+
if (data.prepend) {
|
|
707
|
+
ctx.map[data.parent].children.unshift(data.id);
|
|
708
|
+
} else {
|
|
709
|
+
ctx.map[data.parent].children.push(data.id);
|
|
710
|
+
}
|
|
711
|
+
} else if (typeof parent === 'string' && ctx.map[parent]) {
|
|
712
|
+
entry.target = ctx.map[parent].node;
|
|
713
|
+
if (data.prepend) {
|
|
714
|
+
ctx.map[parent].children.unshift(data.id);
|
|
715
|
+
} else {
|
|
716
|
+
ctx.map[parent].children.push(data.id);
|
|
717
|
+
}
|
|
718
|
+
} else {
|
|
719
|
+
entry.target = ctx.ctx;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// Clone, apply, insert
|
|
723
|
+
const node = cloneAndApply(name, data);
|
|
724
|
+
if(node !== null) {
|
|
725
|
+
insertNode(entry.target, node, data.prepend);
|
|
726
|
+
entry.node = node;
|
|
727
|
+
|
|
728
|
+
ctx.map[data.id] = entry;
|
|
729
|
+
nodeIndex.set(node, {ctxName: name, id: data.id});
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
if(data.child && Array.isArray(data.child)){
|
|
733
|
+
cmd.elms(name, data.child, data.id);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Materialise an ordered array of elm nodes into the DOM, calling
|
|
742
|
+
* {@link cmd.elm} for each entry.
|
|
743
|
+
*
|
|
744
|
+
* Because each elm node carries its own `parent` reference and the array is
|
|
745
|
+
* parent-before-child ordered, nodes are automatically inserted into the
|
|
746
|
+
* correct DOM positions.
|
|
747
|
+
*
|
|
748
|
+
* @param {string} anchor - Context name.
|
|
749
|
+
* @param {import('./parser').ElmNode[]} elm_array - Ordered elm array to render.
|
|
750
|
+
*/
|
|
751
|
+
cmd.elms = function(anchor, elm_array, parent){
|
|
752
|
+
elm_array.forEach(function(elm, index){
|
|
753
|
+
cmd.elm(anchor, elm, parent, index);
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Retrieve the live DOM node for a given element ID from a context.
|
|
759
|
+
*
|
|
760
|
+
* @param {string} name - Context name.
|
|
761
|
+
* @param {string} id - Element ID to look up.
|
|
762
|
+
* @returns {Element|null} The live DOM node, or `null` when not found.
|
|
763
|
+
*/
|
|
764
|
+
cmd.get = function (name, id) {
|
|
765
|
+
return contexts[name].map[id]?.node || null;
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Check whether an element ID exists in a context's live map.
|
|
770
|
+
*
|
|
771
|
+
* @param {string} name - Context name.
|
|
772
|
+
* @param {string} id - Element ID to check.
|
|
773
|
+
* @returns {boolean} `true` when the element is present.
|
|
774
|
+
*/
|
|
775
|
+
cmd.has = function (name, id) {
|
|
776
|
+
return !!(contexts[name]?.map[id]);
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Move a DOM node to a new parent within the same context, updating the
|
|
781
|
+
* internal `children` lists and `target` references accordingly.
|
|
782
|
+
*
|
|
783
|
+
* Both `node` and `newParent` must be `Element` instances with an `id`
|
|
784
|
+
* attribute already tracked in the context map; the call is a no-op
|
|
785
|
+
* otherwise.
|
|
786
|
+
*
|
|
787
|
+
* @param {string} name - Context name.
|
|
788
|
+
* @param {Element} node - Element to move (must be in the context map).
|
|
789
|
+
* @param {Element} newParent - Destination parent element (must be in the
|
|
790
|
+
* context map).
|
|
791
|
+
*/
|
|
792
|
+
cmd.move = function (name, node, newParent) {
|
|
793
|
+
const id = (node instanceof Element) ? node.getAttribute('id') : null;
|
|
794
|
+
const newParentId = (newParent instanceof Element) ? newParent.getAttribute('id') : null;
|
|
795
|
+
if (id === null || newParentId === null) return;
|
|
796
|
+
|
|
797
|
+
const ctx = contexts[name];
|
|
798
|
+
const entry = ctx.map[id];
|
|
799
|
+
const newParentEntry = ctx.map[newParentId];
|
|
800
|
+
if (!entry || !newParentEntry) return;
|
|
801
|
+
|
|
802
|
+
// Remove id from old parent's children list
|
|
803
|
+
const oldParentId = (entry.target instanceof Element) ? entry.target.getAttribute('id') : null;
|
|
804
|
+
if (oldParentId !== null && ctx.map[oldParentId]) {
|
|
805
|
+
const siblings = ctx.map[oldParentId].children;
|
|
806
|
+
const idx = siblings.indexOf(id);
|
|
807
|
+
if (idx !== -1) siblings.splice(idx, 1);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// Move in DOM, then update the map entry
|
|
811
|
+
newParent.appendChild(node);
|
|
812
|
+
entry.target = newParent;
|
|
813
|
+
newParentEntry.children.push(id);
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
// ── Style
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Insert or update a `<style>` element in the page context's `<head>`.
|
|
820
|
+
* If a `<style>` with `id` already exists it is updated in place
|
|
821
|
+
* (no new node created).
|
|
822
|
+
*
|
|
823
|
+
* Only available on page contexts (those initialised with `options.page`).
|
|
824
|
+
*
|
|
825
|
+
* @param {string} name - Page context name.
|
|
826
|
+
* @param {string} id - Identifier for the style block (becomes the element id).
|
|
827
|
+
* @param {string} css - CSS text content.
|
|
828
|
+
*/
|
|
829
|
+
cmd.style = function (name, id, css) {
|
|
830
|
+
const ctx = contexts[name];
|
|
831
|
+
if (ctx.styles[id]) {
|
|
832
|
+
ctx.styles[id].textContent = css;
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
const node = document.createElement('style');
|
|
836
|
+
node.id = id;
|
|
837
|
+
node.textContent = css;
|
|
838
|
+
if (cspNonce) node.setAttribute('nonce', cspNonce);
|
|
839
|
+
ctx.head.appendChild(node);
|
|
840
|
+
ctx.styles[id] = node;
|
|
841
|
+
};
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Remove a named `<style>` element from the page context's `<head>`.
|
|
845
|
+
* No-op when the id is not found.
|
|
846
|
+
*
|
|
847
|
+
* @param {string} name - Page context name.
|
|
848
|
+
* @param {string} id - Identifier of the style block to remove.
|
|
849
|
+
*/
|
|
850
|
+
cmd.removeStyle = function (name, id) {
|
|
851
|
+
const ctx = contexts[name];
|
|
852
|
+
if (ctx.styles[id]) {
|
|
853
|
+
ctx.styles[id].remove();
|
|
854
|
+
delete ctx.styles[id];
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
|
|
858
|
+
// ── Scripts
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Insert or replace a `<script>` element in the page context's `<head>`.
|
|
862
|
+
* If a `<script>` with `id` already exists it is removed before the new one
|
|
863
|
+
* is appended.
|
|
864
|
+
*
|
|
865
|
+
* Only inline script content is supported (`options.content`).
|
|
866
|
+
* The `src` attribute path is reserved for future use and intentionally
|
|
867
|
+
* disabled; content must be validated externally before calling this method.
|
|
868
|
+
*
|
|
869
|
+
* @param {string} name - Page context name.
|
|
870
|
+
* @param {string} id - Identifier for the script element.
|
|
871
|
+
* @param {Object} [options={}] - Script options.
|
|
872
|
+
* @param {string} [options.content] - Inline script text.
|
|
873
|
+
* @param {string} [options.type] - MIME type (e.g. `'module'`).
|
|
874
|
+
*/
|
|
875
|
+
// ── Scripts
|
|
876
|
+
cmd.script = function (name, id, options = {}) {
|
|
877
|
+
const ctx = contexts[name];
|
|
878
|
+
if (ctx.scripts[id]) {
|
|
879
|
+
ctx.scripts[id].remove();
|
|
880
|
+
}
|
|
881
|
+
const node = document.createElement('script');
|
|
882
|
+
node.id = id;
|
|
883
|
+
// inline script only with validation before (not part of this factory).
|
|
884
|
+
if (options.content) node.textContent = options.content;
|
|
885
|
+
if (options.type) node.type = options.type;
|
|
886
|
+
if (cspNonce) node.setAttribute('nonce', cspNonce);
|
|
887
|
+
ctx.head.appendChild(node);
|
|
888
|
+
ctx.scripts[id] = node;
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Remove a named `<script>` element from the page context's `<head>`.
|
|
893
|
+
* No-op when the id is not found.
|
|
894
|
+
*
|
|
895
|
+
* @param {string} name - Page context name.
|
|
896
|
+
* @param {string} id - Identifier of the script to remove.
|
|
897
|
+
*/
|
|
898
|
+
cmd.removeScript = function (name, id) {
|
|
899
|
+
const ctx = contexts[name];
|
|
900
|
+
if (ctx.scripts[id]) {
|
|
901
|
+
ctx.scripts[id].remove();
|
|
902
|
+
delete ctx.scripts[id];
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
// ── Clearing fn
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Completely tear down a named context: remove its container element from
|
|
910
|
+
* the DOM and delete the context entry.
|
|
911
|
+
*
|
|
912
|
+
* @param {string} name - Context name to destroy.
|
|
913
|
+
*/
|
|
914
|
+
cmd.clearContext = function (name) {
|
|
915
|
+
if (contexts[name]) {
|
|
916
|
+
contexts[name].ctx.remove();
|
|
917
|
+
delete contexts[name];
|
|
918
|
+
}
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Remove all rendered elements from a context, reset its live map, and
|
|
923
|
+
* recursively clear any child contexts.
|
|
924
|
+
*
|
|
925
|
+
* The container element itself is kept; only its children are removed via
|
|
926
|
+
* `replaceChildren()`.
|
|
927
|
+
*
|
|
928
|
+
* @param {string} name - Context name.
|
|
929
|
+
* @returns {string[]} Array of all element IDs that were removed.
|
|
930
|
+
*/
|
|
931
|
+
cmd.clearAll = function (name) {
|
|
932
|
+
const ctx = contexts[name];
|
|
933
|
+
const ret = [];
|
|
934
|
+
for (const id in ctx.map) {
|
|
935
|
+
if (!ctx.map[id]) continue; // guard against already-collected children
|
|
936
|
+
if (ctx.map[id].childCtxs) {
|
|
937
|
+
for (const childCtxName of ctx.map[id].childCtxs) {
|
|
938
|
+
cmd.clearContext(childCtxName);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
ret.push(...collectChildren(name, ctx.map[id].children));
|
|
942
|
+
ret.push(id);
|
|
943
|
+
}
|
|
944
|
+
ctx.ctx.replaceChildren();
|
|
945
|
+
ctx.map = {};
|
|
946
|
+
return ret;
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Remove a single element and its entire descendant subtree from the DOM
|
|
951
|
+
* and the context map.
|
|
952
|
+
*
|
|
953
|
+
* @param {string} name - Context name.
|
|
954
|
+
* @param {string} id - ID of the element to remove.
|
|
955
|
+
* @returns {string[]} IDs of all removed elements (the element itself plus
|
|
956
|
+
* all descendants).
|
|
957
|
+
*/
|
|
958
|
+
cmd.clearElm = function (name, id) {
|
|
959
|
+
const ctx = contexts[name];
|
|
960
|
+
if (!ctx.map[id]) return [];
|
|
961
|
+
|
|
962
|
+
const entry = ctx.map[id];
|
|
963
|
+
entry.node.remove();
|
|
964
|
+
const ret = collectChildren(name, entry.children);
|
|
965
|
+
ret.push(id);
|
|
966
|
+
delete ctx.map[id];
|
|
967
|
+
return ret;
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Clear the children of an element without removing the element itself.
|
|
972
|
+
*
|
|
973
|
+
* The element's DOM children are removed via `replaceChildren()` and its
|
|
974
|
+
* descendant entries are purged from the context map. The element entry
|
|
975
|
+
* remains in `ctx.map` with an empty `children` array.
|
|
976
|
+
*
|
|
977
|
+
* @param {string} name - Context name.
|
|
978
|
+
* @param {string} id - ID of the element whose children should be cleared.
|
|
979
|
+
* @returns {string[]} IDs of all removed descendant elements.
|
|
980
|
+
*/
|
|
981
|
+
/**
|
|
982
|
+
* Adopt a precompiled `ParseResult` JSON (produced by
|
|
983
|
+
* `build/tools/parseresult.js`) directly, bypassing
|
|
984
|
+
* `parser.fromHTML()`. The input shape is identical to what
|
|
985
|
+
* `parser.fromHTML()` returns at runtime.
|
|
986
|
+
*
|
|
987
|
+
* The function performs a shallow shape check and returns the same
|
|
988
|
+
* object unchanged — callers can then feed it to `cmd.elms`,
|
|
989
|
+
* `cmd.elm`, `render.toHTML`, etc. as they would with a freshly
|
|
990
|
+
* parsed result.
|
|
991
|
+
*
|
|
992
|
+
* @param {{ template: import('./parser').ElmNode[],
|
|
993
|
+
* iterates?: Object.<string, import('./parser').ElmNode[]> }} parseResult
|
|
994
|
+
* JSON payload from parser precompilation.
|
|
995
|
+
* @returns {object} The same `parseResult` reference, unchanged.
|
|
996
|
+
* @throws {TypeError} When `parseResult` is missing or malformed.
|
|
997
|
+
*/
|
|
998
|
+
cmd.fromParseResult = function (parseResult) {
|
|
999
|
+
if (!parseResult || typeof parseResult !== 'object' || Array.isArray(parseResult)) {
|
|
1000
|
+
throw new TypeError(
|
|
1001
|
+
'template.fromParseResult: parseResult must be an object with a `template` array'
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
if (!Array.isArray(parseResult.template)) {
|
|
1005
|
+
throw new TypeError(
|
|
1006
|
+
'template.fromParseResult: parseResult.template must be an array'
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
1009
|
+
if (parseResult.iterates !== undefined &&
|
|
1010
|
+
(typeof parseResult.iterates !== 'object' || parseResult.iterates === null)) {
|
|
1011
|
+
throw new TypeError(
|
|
1012
|
+
'template.fromParseResult: parseResult.iterates must be an object when present'
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
return parseResult;
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
cmd.clearIn = function (name, id) {
|
|
1019
|
+
const ctx = contexts[name];
|
|
1020
|
+
if (!ctx.map[id]) return [];
|
|
1021
|
+
|
|
1022
|
+
const entry = ctx.map[id];
|
|
1023
|
+
entry.node.replaceChildren();
|
|
1024
|
+
const ret = collectChildren(name, entry.children);
|
|
1025
|
+
entry.children = [];
|
|
1026
|
+
return ret;
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
return cmd;
|
|
1030
|
+
}
|
|
1031
|
+
};
|