functionalscript 0.13.0 → 0.14.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/{types → fs}/asn.1/module.f.d.ts +1 -1
- package/{types → fs}/asn.1/module.f.js +3 -3
- package/{types → fs}/asn.1/test.f.js +2 -2
- package/{types → fs}/base128/module.f.d.ts +1 -1
- package/{types → fs}/base128/module.f.js +1 -1
- package/{types → fs}/base128/test.f.js +2 -2
- package/{bnf → fs/bnf}/data/module.f.d.ts +1 -1
- package/{cas → fs/cas}/module.f.d.ts +4 -4
- package/{cas → fs/cas}/module.f.js +1 -1
- package/{types → fs}/cbase32/module.f.d.ts +2 -2
- package/{types → fs}/cbase32/module.f.js +1 -1
- package/{types → fs}/cbase32/test.f.js +1 -1
- package/fs/ci/bun/module.f.d.ts +2 -0
- package/fs/ci/bun/module.f.js +20 -0
- package/fs/ci/common/module.f.d.ts +43 -0
- package/fs/ci/common/module.f.js +32 -0
- package/fs/ci/config/module.f.d.ts +25 -0
- package/fs/ci/config/module.f.js +34 -0
- package/fs/ci/deno/module.f.d.ts +2 -0
- package/fs/ci/deno/module.f.js +13 -0
- package/fs/ci/module.f.js +40 -0
- package/fs/ci/node/module.f.d.ts +6 -0
- package/fs/ci/node/module.f.js +36 -0
- package/fs/ci/playwright/module.f.d.ts +2 -0
- package/fs/ci/playwright/module.f.js +23 -0
- package/fs/ci/rust/module.f.d.ts +2 -0
- package/fs/ci/rust/module.f.js +49 -0
- package/{crypto → fs/crypto}/secp/module.f.d.ts +1 -2
- package/{dev → fs/dev}/module.f.d.ts +2 -0
- package/{dev → fs/dev}/module.f.js +5 -0
- package/{dev → fs/dev}/tf/all.test.js +7 -5
- package/{dev → fs/dev}/tf/module.f.d.ts +1 -1
- package/{dev → fs/dev}/tf/module.f.js +12 -9
- package/fs/dev/tf/test.f.d.ts +16 -0
- package/fs/dev/tf/test.f.js +22 -0
- package/fs/dev/version/module.f.d.ts +3 -0
- package/{djs → fs/djs}/tokenizer/module.f.js +3 -3
- package/{djs/parser-new → fs/djs/tokenizer-new}/test.f.d.ts +2 -1
- package/fs/djs/tokenizer-new/test.f.js +894 -0
- package/{html → fs/html}/module.f.d.ts +14 -0
- package/{html → fs/html}/module.f.js +21 -2
- package/{js → fs/js}/tokenizer/module.f.js +34 -34
- package/{json → fs/json}/tokenizer/module.f.js +1 -1
- package/{path → fs/path}/module.f.d.ts +1 -1
- package/fs/sul/id/module.f.d.ts +33 -0
- package/fs/sul/id/module.f.js +94 -0
- package/fs/sul/id/test.f.d.ts +21 -0
- package/fs/sul/id/test.f.js +75 -0
- package/fs/sul/level/hash/module.f.d.ts +38 -0
- package/fs/sul/level/hash/module.f.js +43 -0
- package/fs/sul/level/hash/test.f.d.ts +14 -0
- package/fs/sul/level/hash/test.f.js +112 -0
- package/fs/sul/level/literal/module.f.d.ts +64 -0
- package/fs/sul/level/literal/module.f.js +88 -0
- package/fs/sul/level/literal/test.f.d.ts +12 -0
- package/fs/sul/level/literal/test.f.js +722 -0
- package/fs/sul/module.f.d.ts +23 -0
- package/fs/sul/module.f.js +46 -0
- package/fs/sul/test.f.d.ts +10 -0
- package/fs/sul/test.f.js +47 -0
- package/{text → fs/text}/module.f.d.ts +1 -1
- package/{text → fs/text}/utf16/module.f.js +8 -8
- package/{text → fs/text}/utf8/module.f.js +2 -2
- package/{types → fs/types}/bit_vec/module.f.d.ts +13 -1
- package/{types → fs/types}/bit_vec/module.f.js +33 -15
- package/{types → fs/types}/effects/module.f.d.ts +1 -0
- package/{types → fs/types}/effects/node/virtual/module.f.d.ts +3 -3
- package/{types → fs/types}/function/operator/module.f.d.ts +1 -1
- package/{types → fs/types}/function/operator/module.f.js +1 -1
- package/{types → fs/types}/list/module.f.js +1 -1
- package/fs/types/patricia_trie/module.f.d.ts +25 -0
- package/fs/types/patricia_trie/module.f.js +35 -0
- package/fs/types/patricia_trie/test.f.d.ts +8 -0
- package/fs/types/patricia_trie/test.f.js +121 -0
- package/fs/types/rtti/parse/module.f.d.ts +32 -0
- package/fs/types/rtti/parse/module.f.js +113 -0
- package/fs/types/rtti/parse/test.f.d.ts +104 -0
- package/fs/types/rtti/parse/test.f.js +316 -0
- package/fs/types/rtti/validate/module.f.d.ts +74 -0
- package/{types → fs/types}/rtti/validate/module.f.js +26 -24
- package/{types → fs/types}/rtti/validate/test.f.d.ts +11 -0
- package/{types → fs/types}/rtti/validate/test.f.js +38 -0
- package/{types → fs/types}/uint8array/module.f.d.ts +2 -2
- package/fs/website/module.f.d.ts +4 -0
- package/fs/website/module.f.js +15 -0
- package/package.json +8 -8
- package/ci/module.f.js +0 -183
- package/dev/tf/test.f.d.ts +0 -4
- package/dev/tf/test.f.js +0 -5
- package/dev/version/module.f.d.ts +0 -3
- package/djs/parser-new/test.f.js +0 -202
- package/types/rtti/validate/module.f.d.ts +0 -50
- package/website/module.f.d.ts +0 -4
- package/website/module.f.js +0 -19
- /package/{types → fs}/asn.1/test.f.d.ts +0 -0
- /package/{cas → fs/base128}/test.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/data/module.f.js +0 -0
- /package/{bnf → fs/bnf}/data/test.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/data/test.f.js +0 -0
- /package/{bnf → fs/bnf}/module.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/module.f.js +0 -0
- /package/{bnf → fs/bnf}/test.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/test.f.js +0 -0
- /package/{bnf → fs/bnf}/testlib.f.d.ts +0 -0
- /package/{bnf → fs/bnf}/testlib.f.js +0 -0
- /package/{types/base128 → fs/cas}/test.f.d.ts +0 -0
- /package/{cas → fs/cas}/test.f.js +0 -0
- /package/{types → fs}/cbase32/test.f.d.ts +0 -0
- /package/{ci → fs/ci}/module.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/hmac/module.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/hmac/module.f.js +0 -0
- /package/{crypto → fs/crypto}/hmac/test.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/hmac/test.f.js +0 -0
- /package/{crypto → fs/crypto}/secp/module.f.js +0 -0
- /package/{crypto → fs/crypto}/secp/test.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/secp/test.f.js +0 -0
- /package/{crypto → fs/crypto}/sha2/module.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/sha2/module.f.js +0 -0
- /package/{crypto → fs/crypto}/sha2/test.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/sha2/test.f.js +0 -0
- /package/{crypto → fs/crypto}/sign/module.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/sign/module.f.js +0 -0
- /package/{crypto → fs/crypto}/sign/test.f.d.ts +0 -0
- /package/{crypto → fs/crypto}/sign/test.f.js +0 -0
- /package/{dev → fs/dev}/index/module.f.d.ts +0 -0
- /package/{dev → fs/dev}/index/module.f.js +0 -0
- /package/{dev → fs/dev}/test.f.d.ts +0 -0
- /package/{dev → fs/dev}/test.f.js +0 -0
- /package/{dev → fs/dev}/tf/all.test.d.ts +0 -0
- /package/{dev → fs/dev}/version/module.f.js +0 -0
- /package/{dev → fs/dev}/version/test.f.d.ts +0 -0
- /package/{dev → fs/dev}/version/test.f.js +0 -0
- /package/{djs → fs/djs}/ast/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/ast/module.f.js +0 -0
- /package/{djs → fs/djs}/ast/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/ast/test.f.js +0 -0
- /package/{djs → fs/djs}/examples/input.f.d.ts +0 -0
- /package/{djs → fs/djs}/examples/input.f.js +0 -0
- /package/{djs → fs/djs}/examples/m.f.d.ts +0 -0
- /package/{djs → fs/djs}/examples/m.f.js +0 -0
- /package/{djs → fs/djs}/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/module.f.js +0 -0
- /package/{djs → fs/djs}/parser/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/parser/module.f.js +0 -0
- /package/{djs → fs/djs}/parser/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/parser/test.f.js +0 -0
- /package/{djs → fs/djs}/serializer/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/serializer/module.f.js +0 -0
- /package/{djs → fs/djs}/serializer/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/serializer/test.f.js +0 -0
- /package/{djs → fs/djs}/tokenizer/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/tokenizer/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/tokenizer/test.f.js +0 -0
- /package/{djs/parser-new → fs/djs/tokenizer-new}/module.f.d.ts +0 -0
- /package/{djs/parser-new → fs/djs/tokenizer-new}/module.f.js +0 -0
- /package/{djs → fs/djs}/transpiler/module.f.d.ts +0 -0
- /package/{djs → fs/djs}/transpiler/module.f.js +0 -0
- /package/{djs → fs/djs}/transpiler/test.f.d.ts +0 -0
- /package/{djs → fs/djs}/transpiler/test.f.js +0 -0
- /package/{fjs → fs/fjs}/module.d.ts +0 -0
- /package/{fjs → fs/fjs}/module.f.d.ts +0 -0
- /package/{fjs → fs/fjs}/module.f.js +0 -0
- /package/{fjs → fs/fjs}/module.js +0 -0
- /package/{fsc → fs/fsc}/bnf.f.d.ts +0 -0
- /package/{fsc → fs/fsc}/bnf.f.js +0 -0
- /package/{fsc → fs/fsc}/json.f.d.ts +0 -0
- /package/{fsc → fs/fsc}/json.f.js +0 -0
- /package/{fsc → fs/fsc}/module.f.d.ts +0 -0
- /package/{fsc → fs/fsc}/module.f.js +0 -0
- /package/{fsc → fs/fsc}/test.f.d.ts +0 -0
- /package/{fsc → fs/fsc}/test.f.js +0 -0
- /package/{fsm → fs/fsm}/module.f.d.ts +0 -0
- /package/{fsm → fs/fsm}/module.f.js +0 -0
- /package/{fsm → fs/fsm}/test.f.d.ts +0 -0
- /package/{fsm → fs/fsm}/test.f.js +0 -0
- /package/{html → fs/html}/test.f.d.ts +0 -0
- /package/{html → fs/html}/test.f.js +0 -0
- /package/{io → fs/io}/module.d.ts +0 -0
- /package/{io → fs/io}/module.f.d.ts +0 -0
- /package/{io → fs/io}/module.f.js +0 -0
- /package/{io → fs/io}/module.js +0 -0
- /package/{io → fs/io}/virtual/module.f.d.ts +0 -0
- /package/{io → fs/io}/virtual/module.f.js +0 -0
- /package/{js → fs/js}/tokenizer/module.f.d.ts +0 -0
- /package/{js → fs/js}/tokenizer/test.f.d.ts +0 -0
- /package/{js → fs/js}/tokenizer/test.f.js +0 -0
- /package/{json → fs/json}/module.f.d.ts +0 -0
- /package/{json → fs/json}/module.f.js +0 -0
- /package/{json → fs/json}/parser/module.f.d.ts +0 -0
- /package/{json → fs/json}/parser/module.f.js +0 -0
- /package/{json → fs/json}/parser/test.f.d.ts +0 -0
- /package/{json → fs/json}/parser/test.f.js +0 -0
- /package/{json → fs/json}/serializer/module.f.d.ts +0 -0
- /package/{json → fs/json}/serializer/module.f.js +0 -0
- /package/{json → fs/json}/serializer/test.f.d.ts +0 -0
- /package/{json → fs/json}/serializer/test.f.js +0 -0
- /package/{json → fs/json}/test.f.d.ts +0 -0
- /package/{json → fs/json}/test.f.js +0 -0
- /package/{json → fs/json}/tokenizer/module.f.d.ts +0 -0
- /package/{json → fs/json}/tokenizer/test.f.d.ts +0 -0
- /package/{json → fs/json}/tokenizer/test.f.js +0 -0
- /package/{path → fs/path}/module.f.js +0 -0
- /package/{path → fs/path}/test.f.d.ts +0 -0
- /package/{path → fs/path}/test.f.js +0 -0
- /package/{text → fs/text}/ascii/module.f.d.ts +0 -0
- /package/{text → fs/text}/ascii/module.f.js +0 -0
- /package/{text → fs/text}/ascii/test.f.d.ts +0 -0
- /package/{text → fs/text}/ascii/test.f.js +0 -0
- /package/{text → fs/text}/module.f.js +0 -0
- /package/{text → fs/text}/sgr/module.f.d.ts +0 -0
- /package/{text → fs/text}/sgr/module.f.js +0 -0
- /package/{text → fs/text}/sgr/test.f.d.ts +0 -0
- /package/{text → fs/text}/sgr/test.f.js +0 -0
- /package/{text → fs/text}/test.f.d.ts +0 -0
- /package/{text → fs/text}/test.f.js +0 -0
- /package/{text → fs/text}/utf16/module.f.d.ts +0 -0
- /package/{text → fs/text}/utf16/test.f.d.ts +0 -0
- /package/{text → fs/text}/utf16/test.f.js +0 -0
- /package/{text → fs/text}/utf8/module.f.d.ts +0 -0
- /package/{text → fs/text}/utf8/test.f.d.ts +0 -0
- /package/{text → fs/text}/utf8/test.f.js +0 -0
- /package/{types → fs/types}/array/module.f.d.ts +0 -0
- /package/{types → fs/types}/array/module.f.js +0 -0
- /package/{types → fs/types}/array/test.f.d.ts +0 -0
- /package/{types → fs/types}/array/test.f.js +0 -0
- /package/{types → fs/types}/bigfloat/module.f.d.ts +0 -0
- /package/{types → fs/types}/bigfloat/module.f.js +0 -0
- /package/{types → fs/types}/bigfloat/test.f.d.ts +0 -0
- /package/{types → fs/types}/bigfloat/test.f.js +0 -0
- /package/{types → fs/types}/bigint/module.f.d.ts +0 -0
- /package/{types → fs/types}/bigint/module.f.js +0 -0
- /package/{types → fs/types}/bigint/test.f.d.ts +0 -0
- /package/{types → fs/types}/bigint/test.f.js +0 -0
- /package/{types → fs/types}/bit_vec/test.f.d.ts +0 -0
- /package/{types → fs/types}/bit_vec/test.f.js +0 -0
- /package/{types → fs/types}/btree/find/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/find/module.f.js +0 -0
- /package/{types → fs/types}/btree/find/test.f.d.ts +0 -0
- /package/{types → fs/types}/btree/find/test.f.js +0 -0
- /package/{types → fs/types}/btree/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/module.f.js +0 -0
- /package/{types → fs/types}/btree/remove/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/remove/module.f.js +0 -0
- /package/{types → fs/types}/btree/remove/test.f.d.ts +0 -0
- /package/{types → fs/types}/btree/remove/test.f.js +0 -0
- /package/{types → fs/types}/btree/set/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/set/module.f.js +0 -0
- /package/{types → fs/types}/btree/set/test.f.d.ts +0 -0
- /package/{types → fs/types}/btree/set/test.f.js +0 -0
- /package/{types → fs/types}/btree/test.f.d.ts +0 -0
- /package/{types → fs/types}/btree/test.f.js +0 -0
- /package/{types → fs/types}/btree/types/module.f.d.ts +0 -0
- /package/{types → fs/types}/btree/types/module.f.js +0 -0
- /package/{types → fs/types}/byte_set/module.f.d.ts +0 -0
- /package/{types → fs/types}/byte_set/module.f.js +0 -0
- /package/{types → fs/types}/byte_set/test.f.d.ts +0 -0
- /package/{types → fs/types}/byte_set/test.f.js +0 -0
- /package/{types → fs/types}/effects/mock/module.f.d.ts +0 -0
- /package/{types → fs/types}/effects/mock/module.f.js +0 -0
- /package/{types → fs/types}/effects/module.d.ts +0 -0
- /package/{types → fs/types}/effects/module.f.js +0 -0
- /package/{types → fs/types}/effects/module.js +0 -0
- /package/{types → fs/types}/effects/node/module.f.d.ts +0 -0
- /package/{types → fs/types}/effects/node/module.f.js +0 -0
- /package/{types → fs/types}/effects/node/test.f.d.ts +0 -0
- /package/{types → fs/types}/effects/node/test.f.js +0 -0
- /package/{types → fs/types}/effects/node/virtual/module.f.js +0 -0
- /package/{types → fs/types}/function/compare/module.f.d.ts +0 -0
- /package/{types → fs/types}/function/compare/module.f.js +0 -0
- /package/{types → fs/types}/function/compare/test.f.d.ts +0 -0
- /package/{types → fs/types}/function/compare/test.f.js +0 -0
- /package/{types → fs/types}/function/module.f.d.ts +0 -0
- /package/{types → fs/types}/function/module.f.js +0 -0
- /package/{types → fs/types}/function/test.f.d.ts +0 -0
- /package/{types → fs/types}/function/test.f.js +0 -0
- /package/{types → fs/types}/list/module.f.d.ts +0 -0
- /package/{types → fs/types}/list/test.f.d.ts +0 -0
- /package/{types → fs/types}/list/test.f.js +0 -0
- /package/{types → fs/types}/map/module.f.d.ts +0 -0
- /package/{types → fs/types}/map/module.f.js +0 -0
- /package/{types → fs/types}/map/test.f.d.ts +0 -0
- /package/{types → fs/types}/map/test.f.js +0 -0
- /package/{types → fs/types}/monoid/module.f.d.ts +0 -0
- /package/{types → fs/types}/monoid/module.f.js +0 -0
- /package/{types → fs/types}/monoid/test.f.d.ts +0 -0
- /package/{types → fs/types}/monoid/test.f.js +0 -0
- /package/{types → fs/types}/nibble_set/module.f.d.ts +0 -0
- /package/{types → fs/types}/nibble_set/module.f.js +0 -0
- /package/{types → fs/types}/nibble_set/test.f.d.ts +0 -0
- /package/{types → fs/types}/nibble_set/test.f.js +0 -0
- /package/{types → fs/types}/nominal/module.f.d.ts +0 -0
- /package/{types → fs/types}/nominal/module.f.js +0 -0
- /package/{types → fs/types}/nominal/test.f.d.ts +0 -0
- /package/{types → fs/types}/nominal/test.f.js +0 -0
- /package/{types → fs/types}/nullable/module.f.d.ts +0 -0
- /package/{types → fs/types}/nullable/module.f.js +0 -0
- /package/{types → fs/types}/nullable/test.f.d.ts +0 -0
- /package/{types → fs/types}/nullable/test.f.js +0 -0
- /package/{types → fs/types}/number/module.f.d.ts +0 -0
- /package/{types → fs/types}/number/module.f.js +0 -0
- /package/{types → fs/types}/number/test.f.d.ts +0 -0
- /package/{types → fs/types}/number/test.f.js +0 -0
- /package/{types → fs/types}/object/module.f.d.ts +0 -0
- /package/{types → fs/types}/object/module.f.js +0 -0
- /package/{types → fs/types}/object/test.f.d.ts +0 -0
- /package/{types → fs/types}/object/test.f.js +0 -0
- /package/{types → fs/types}/option/module.f.d.ts +0 -0
- /package/{types → fs/types}/option/module.f.js +0 -0
- /package/{types → fs/types}/ordered_map/module.f.d.ts +0 -0
- /package/{types → fs/types}/ordered_map/module.f.js +0 -0
- /package/{types → fs/types}/ordered_map/test.f.d.ts +0 -0
- /package/{types → fs/types}/ordered_map/test.f.js +0 -0
- /package/{types → fs/types}/prime_field/module.f.d.ts +0 -0
- /package/{types → fs/types}/prime_field/module.f.js +0 -0
- /package/{types → fs/types}/prime_field/test.f.d.ts +0 -0
- /package/{types → fs/types}/prime_field/test.f.js +0 -0
- /package/{types → fs/types}/range/module.f.d.ts +0 -0
- /package/{types → fs/types}/range/module.f.js +0 -0
- /package/{types → fs/types}/range/test.f.d.ts +0 -0
- /package/{types → fs/types}/range/test.f.js +0 -0
- /package/{types → fs/types}/range_map/module.f.d.ts +0 -0
- /package/{types → fs/types}/range_map/module.f.js +0 -0
- /package/{types → fs/types}/range_map/test.f.d.ts +0 -0
- /package/{types → fs/types}/range_map/test.f.js +0 -0
- /package/{types → fs/types}/result/module.d.ts +0 -0
- /package/{types → fs/types}/result/module.f.d.ts +0 -0
- /package/{types → fs/types}/result/module.f.js +0 -0
- /package/{types → fs/types}/result/module.js +0 -0
- /package/{types → fs/types}/result/test.f.d.ts +0 -0
- /package/{types → fs/types}/result/test.f.js +0 -0
- /package/{types → fs/types}/rtti/module.f.d.ts +0 -0
- /package/{types → fs/types}/rtti/module.f.js +0 -0
- /package/{types → fs/types}/rtti/test.f.d.ts +0 -0
- /package/{types → fs/types}/rtti/test.f.js +0 -0
- /package/{types → fs/types}/rtti/ts/module.f.d.ts +0 -0
- /package/{types → fs/types}/rtti/ts/module.f.js +0 -0
- /package/{types → fs/types}/rtti/ts/test.f.d.ts +0 -0
- /package/{types → fs/types}/rtti/ts/test.f.js +0 -0
- /package/{types → fs/types}/sorted_list/module.f.d.ts +0 -0
- /package/{types → fs/types}/sorted_list/module.f.js +0 -0
- /package/{types → fs/types}/sorted_list/test.f.d.ts +0 -0
- /package/{types → fs/types}/sorted_list/test.f.js +0 -0
- /package/{types → fs/types}/sorted_set/module.f.d.ts +0 -0
- /package/{types → fs/types}/sorted_set/module.f.js +0 -0
- /package/{types → fs/types}/sorted_set/test.f.d.ts +0 -0
- /package/{types → fs/types}/sorted_set/test.f.js +0 -0
- /package/{types → fs/types}/string/module.f.d.ts +0 -0
- /package/{types → fs/types}/string/module.f.js +0 -0
- /package/{types → fs/types}/string/test.f.d.ts +0 -0
- /package/{types → fs/types}/string/test.f.js +0 -0
- /package/{types → fs/types}/string_set/module.f.d.ts +0 -0
- /package/{types → fs/types}/string_set/module.f.js +0 -0
- /package/{types → fs/types}/string_set/test.f.d.ts +0 -0
- /package/{types → fs/types}/string_set/test.f.js +0 -0
- /package/{types → fs/types}/ts/module.f.d.ts +0 -0
- /package/{types → fs/types}/ts/module.f.js +0 -0
- /package/{types → fs/types}/uint8array/module.f.js +0 -0
- /package/{types → fs/types}/uint8array/test.f.d.ts +0 -0
- /package/{types → fs/types}/uint8array/test.f.js +0 -0
|
@@ -29,5 +29,19 @@ export declare const html: (_: Element) => List<string>;
|
|
|
29
29
|
* Renders an HTML element tree to a final string.
|
|
30
30
|
*/
|
|
31
31
|
export declare const htmlToString: (_: Element) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Renders a complete UTF-8 encoded HTML document as a `Vec`.
|
|
34
|
+
*
|
|
35
|
+
* Produces a full page with `<!DOCTYPE html>`, a `<head>` containing a UTF-8
|
|
36
|
+
* `<meta charset>` and a responsive-viewport `<meta>` followed by any extra
|
|
37
|
+
* `head` nodes, and a `<body>` containing the provided `body` nodes.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* htmlUtf8(['title', 'My Page'])(['h1', 'Hello'])
|
|
42
|
+
* // Vec of UTF-8 bytes for:
|
|
43
|
+
* // <!DOCTYPE html><html><head><meta charset="UTF-8">...<title>My Page</title></head><body><h1>Hello</h1></body></html>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
32
46
|
export declare const htmlUtf8: (...head: readonly Node[]) => (...body: readonly Node[]) => Vec;
|
|
33
47
|
export {};
|
|
@@ -89,5 +89,24 @@ export const html = compose(element)(listConcat(['<!DOCTYPE html>']));
|
|
|
89
89
|
* Renders an HTML element tree to a final string.
|
|
90
90
|
*/
|
|
91
91
|
export const htmlToString = compose(html)(stringConcat);
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const commonHead = [
|
|
93
|
+
['meta', { charset: 'UTF-8' }],
|
|
94
|
+
['meta', { name: 'viewport', content: 'width=device-width,initial-scale=1.0' }],
|
|
95
|
+
];
|
|
96
|
+
/**
|
|
97
|
+
* Renders a complete UTF-8 encoded HTML document as a `Vec`.
|
|
98
|
+
*
|
|
99
|
+
* Produces a full page with `<!DOCTYPE html>`, a `<head>` containing a UTF-8
|
|
100
|
+
* `<meta charset>` and a responsive-viewport `<meta>` followed by any extra
|
|
101
|
+
* `head` nodes, and a `<body>` containing the provided `body` nodes.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* htmlUtf8(['title', 'My Page'])(['h1', 'Hello'])
|
|
106
|
+
* // Vec of UTF-8 bytes for:
|
|
107
|
+
* // <!DOCTYPE html><html><head><meta charset="UTF-8">...<title>My Page</title></head><body><h1>Hello</h1></body></html>
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export const htmlUtf8 = (...head) => (...body) => utf8(htmlToString(['html',
|
|
111
|
+
['head', ...commonHead, ...head],
|
|
112
|
+
['body', ...body]]));
|
|
@@ -263,19 +263,19 @@ const initialStateOp = create((state) => () => [[{ kind: 'error', message: 'unex
|
|
|
263
263
|
rangeSetFunc(rangeOpStart)(() => input => [empty, { kind: 'op', value: fromCharCode(input) }])
|
|
264
264
|
]);
|
|
265
265
|
const invalidNumberToToken = () => input => {
|
|
266
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
266
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
267
267
|
return [{ first: { kind: 'error', message: 'invalid number' }, tail: next[0] }, next[1]];
|
|
268
268
|
};
|
|
269
269
|
const fullStopToToken = state => input => {
|
|
270
270
|
switch (state.numberKind) {
|
|
271
271
|
case '0':
|
|
272
272
|
case 'int': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: state.b, numberKind: '.' }];
|
|
273
|
-
default: return tokenizeOp({ kind: 'invalidNumber' })
|
|
273
|
+
default: return tokenizeOp(input, { kind: 'invalidNumber' });
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
276
|
const digit0ToToken = state => input => {
|
|
277
277
|
switch (state.numberKind) {
|
|
278
|
-
case '0': return tokenizeOp({ kind: 'invalidNumber' })
|
|
278
|
+
case '0': return tokenizeOp(input, { kind: 'invalidNumber' });
|
|
279
279
|
case '.':
|
|
280
280
|
case 'fractional': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: addFracDigit(input)(state.b), numberKind: 'fractional' }];
|
|
281
281
|
case 'e':
|
|
@@ -287,7 +287,7 @@ const digit0ToToken = state => input => {
|
|
|
287
287
|
};
|
|
288
288
|
const digit19ToToken = state => input => {
|
|
289
289
|
switch (state.numberKind) {
|
|
290
|
-
case '0': return tokenizeOp({ kind: 'invalidNumber' })
|
|
290
|
+
case '0': return tokenizeOp(input, { kind: 'invalidNumber' });
|
|
291
291
|
case '.':
|
|
292
292
|
case 'fractional': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: addFracDigit(input)(state.b), numberKind: 'fractional' }];
|
|
293
293
|
case 'e':
|
|
@@ -302,7 +302,7 @@ const expToToken = state => input => {
|
|
|
302
302
|
case '0':
|
|
303
303
|
case 'int':
|
|
304
304
|
case 'fractional': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: state.b, numberKind: 'e' }];
|
|
305
|
-
default: return tokenizeOp({ kind: 'invalidNumber' })
|
|
305
|
+
default: return tokenizeOp(input, { kind: 'invalidNumber' });
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
308
|
const hyphenMinusToToken = state => input => {
|
|
@@ -314,7 +314,7 @@ const hyphenMinusToToken = state => input => {
|
|
|
314
314
|
const plusSignToToken = state => input => {
|
|
315
315
|
switch (state.numberKind) {
|
|
316
316
|
case 'e': return [empty, { kind: 'number', value: appendChar(state.value)(input), b: state.b, numberKind: 'e+' }];
|
|
317
|
-
default: return tokenizeOp({ kind: 'invalidNumber' })
|
|
317
|
+
default: return tokenizeOp(input, { kind: 'invalidNumber' });
|
|
318
318
|
}
|
|
319
319
|
};
|
|
320
320
|
const terminalToToken = state => input => {
|
|
@@ -324,12 +324,12 @@ const terminalToToken = state => input => {
|
|
|
324
324
|
case 'e+':
|
|
325
325
|
case 'e-':
|
|
326
326
|
{
|
|
327
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
327
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
328
328
|
return [{ first: { kind: 'error', message: 'invalid number' }, tail: next[0] }, next[1]];
|
|
329
329
|
}
|
|
330
330
|
default:
|
|
331
331
|
{
|
|
332
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
332
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
333
333
|
return [{ first: bufferToNumberToken(state), tail: next[0] }, next[1]];
|
|
334
334
|
}
|
|
335
335
|
}
|
|
@@ -343,7 +343,7 @@ const bigintToToken = state => input => {
|
|
|
343
343
|
}
|
|
344
344
|
default:
|
|
345
345
|
{
|
|
346
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
346
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
347
347
|
return [{ first: { kind: 'error', message: 'invalid number' }, tail: next[0] }, next[1]];
|
|
348
348
|
}
|
|
349
349
|
}
|
|
@@ -360,7 +360,7 @@ const parseNumberStateOp = create(invalidNumberToToken)([
|
|
|
360
360
|
]);
|
|
361
361
|
const invalidNumberStateOp = create(() => () => [empty, { kind: 'invalidNumber' }])([
|
|
362
362
|
rangeSetFunc(rangeSetTerminalForNumber)(() => input => {
|
|
363
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
363
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
364
364
|
return [{ first: { kind: 'error', message: 'invalid number' }, tail: next[0] }, next[1]];
|
|
365
365
|
})
|
|
366
366
|
]);
|
|
@@ -370,7 +370,7 @@ const parseStringStateOp = create((state) => input => [empty, { kind: 'string',
|
|
|
370
370
|
rangeSetFunc(rangeSetNewLine)(() => () => [[{ kind: 'error', message: 'unterminated string literal' }], { kind: 'nl' }])
|
|
371
371
|
]);
|
|
372
372
|
const parseEscapeDefault = state => input => {
|
|
373
|
-
const next = tokenizeOp({ kind: 'string', value: state.value })
|
|
373
|
+
const next = tokenizeOp(input, { kind: 'string', value: state.value });
|
|
374
374
|
return [{ first: { kind: 'error', message: 'unescaped character' }, tail: next[0] }, next[1]];
|
|
375
375
|
};
|
|
376
376
|
const parseEscapeCharStateOp = create(parseEscapeDefault)([
|
|
@@ -383,7 +383,7 @@ const parseEscapeCharStateOp = create(parseEscapeDefault)([
|
|
|
383
383
|
rangeFunc(one(latinSmallLetterU))(state => () => [empty, { kind: 'unicodeChar', value: state.value, unicode: 0, hexIndex: 0 }]),
|
|
384
384
|
]);
|
|
385
385
|
const parseUnicodeCharDefault = state => input => {
|
|
386
|
-
const next = tokenizeOp({ kind: 'string', value: state.value })
|
|
386
|
+
const next = tokenizeOp(input, { kind: 'string', value: state.value });
|
|
387
387
|
return [{ first: { kind: 'error', message: 'invalid hex value' }, tail: next[0] }, next[1]];
|
|
388
388
|
};
|
|
389
389
|
const parseUnicodeCharHex = offset => state => input => {
|
|
@@ -401,7 +401,7 @@ const parseUnicodeCharStateOp = create(parseUnicodeCharDefault)([
|
|
|
401
401
|
const idToToken = s => at(s)(keywordMap) ?? { kind: 'id', value: s };
|
|
402
402
|
const parseIdDefault = state => input => {
|
|
403
403
|
const keyWordToken = idToToken(state.value);
|
|
404
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
404
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
405
405
|
return [{ first: keyWordToken, tail: next[0] }, next[1]];
|
|
406
406
|
};
|
|
407
407
|
const parseIdStateOp = create(parseIdDefault)([
|
|
@@ -415,7 +415,7 @@ const parseOperatorStateOp = state => input => {
|
|
|
415
415
|
default: {
|
|
416
416
|
if (hasOperatorToken(nextStateValue))
|
|
417
417
|
return [empty, { kind: 'op', value: nextStateValue }];
|
|
418
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
418
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
419
419
|
return [{ first: getOperatorToken(state.value), tail: next[0] }, next[1]];
|
|
420
420
|
}
|
|
421
421
|
}
|
|
@@ -436,7 +436,7 @@ const parseMultilineCommentAsteriskStateOp = create((state) => input => [empty,
|
|
|
436
436
|
})
|
|
437
437
|
]);
|
|
438
438
|
const parseWhitespaceDefault = () => input => {
|
|
439
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
439
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
440
440
|
return [{ first: { kind: 'ws' }, tail: next[0] }, next[1]];
|
|
441
441
|
};
|
|
442
442
|
const parseWhitespaceStateOp = create(parseWhitespaceDefault)([
|
|
@@ -444,7 +444,7 @@ const parseWhitespaceStateOp = create(parseWhitespaceDefault)([
|
|
|
444
444
|
rangeSetFunc(rangeSetNewLine)(() => () => [empty, { kind: 'nl' }])
|
|
445
445
|
]);
|
|
446
446
|
const parseNewLineDefault = _ => input => {
|
|
447
|
-
const next = tokenizeOp({ kind: 'initial' })
|
|
447
|
+
const next = tokenizeOp(input, { kind: 'initial' });
|
|
448
448
|
return [{ first: { kind: 'nl' }, tail: next[0] }, next[1]];
|
|
449
449
|
};
|
|
450
450
|
const parseNewLineStateOp = create(parseNewLineDefault)([
|
|
@@ -452,22 +452,22 @@ const parseNewLineStateOp = create(parseNewLineDefault)([
|
|
|
452
452
|
rangeSetFunc(rangeSetNewLine)(state => () => [empty, state])
|
|
453
453
|
]);
|
|
454
454
|
const eofStateOp = create((state) => () => [[{ kind: 'error', message: 'eof' }], state])([]);
|
|
455
|
-
const tokenizeCharCodeOp = state => {
|
|
455
|
+
const tokenizeCharCodeOp = (input, state) => {
|
|
456
456
|
switch (state.kind) {
|
|
457
|
-
case 'initial': return initialStateOp(state);
|
|
458
|
-
case 'id': return parseIdStateOp(state);
|
|
459
|
-
case 'string': return parseStringStateOp(state);
|
|
460
|
-
case 'escapeChar': return parseEscapeCharStateOp(state);
|
|
461
|
-
case 'unicodeChar': return parseUnicodeCharStateOp(state);
|
|
462
|
-
case 'invalidNumber': return invalidNumberStateOp(state);
|
|
463
|
-
case 'number': return parseNumberStateOp(state);
|
|
464
|
-
case 'op': return parseOperatorStateOp(state);
|
|
465
|
-
case '//': return parseSinglelineCommentStateOp(state);
|
|
466
|
-
case '/*': return parseMultilineCommentStateOp(state);
|
|
467
|
-
case '/**': return parseMultilineCommentAsteriskStateOp(state);
|
|
468
|
-
case 'ws': return parseWhitespaceStateOp(state);
|
|
469
|
-
case 'nl': return parseNewLineStateOp(state);
|
|
470
|
-
case 'eof': return eofStateOp(state);
|
|
457
|
+
case 'initial': return initialStateOp(state)(input);
|
|
458
|
+
case 'id': return parseIdStateOp(state)(input);
|
|
459
|
+
case 'string': return parseStringStateOp(state)(input);
|
|
460
|
+
case 'escapeChar': return parseEscapeCharStateOp(state)(input);
|
|
461
|
+
case 'unicodeChar': return parseUnicodeCharStateOp(state)(input);
|
|
462
|
+
case 'invalidNumber': return invalidNumberStateOp(state)(input);
|
|
463
|
+
case 'number': return parseNumberStateOp(state)(input);
|
|
464
|
+
case 'op': return parseOperatorStateOp(state)(input);
|
|
465
|
+
case '//': return parseSinglelineCommentStateOp(state)(input);
|
|
466
|
+
case '/*': return parseMultilineCommentStateOp(state)(input);
|
|
467
|
+
case '/**': return parseMultilineCommentAsteriskStateOp(state)(input);
|
|
468
|
+
case 'ws': return parseWhitespaceStateOp(state)(input);
|
|
469
|
+
case 'nl': return parseNewLineStateOp(state)(input);
|
|
470
|
+
case 'eof': return eofStateOp(state)(input);
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
473
|
const tokenizeEofOp = state => {
|
|
@@ -495,14 +495,14 @@ const tokenizeEofOp = state => {
|
|
|
495
495
|
case 'eof': return [[{ kind: 'error', message: 'eof' }, { kind: 'eof' }], state];
|
|
496
496
|
}
|
|
497
497
|
};
|
|
498
|
-
const tokenizeOp = state => input
|
|
498
|
+
const tokenizeOp = (input, state) => input === null ? tokenizeEofOp(state) : tokenizeCharCodeOp(input, state);
|
|
499
499
|
const mapTokenWithMetadata = metadata => token => { return { token, metadata }; };
|
|
500
|
-
const tokenizeWithPositionOp = ({ state, metadata }) =>
|
|
500
|
+
const tokenizeWithPositionOp = (input, { state, metadata }) => {
|
|
501
501
|
if (input == null) {
|
|
502
502
|
const newState = tokenizeEofOp(state);
|
|
503
503
|
return [listMap(mapTokenWithMetadata(metadata))(newState[0]), { state: newState[1], metadata }];
|
|
504
504
|
}
|
|
505
|
-
const newState = tokenizeCharCodeOp(state)
|
|
505
|
+
const newState = tokenizeCharCodeOp(input, state);
|
|
506
506
|
const isNewLine = input == lf;
|
|
507
507
|
const newMetadata = { path: metadata.path, line: isNewLine ? metadata.line + 1 : metadata.line, column: isNewLine ? 1 : metadata.column + 1 };
|
|
508
508
|
return [listMap(mapTokenWithMetadata(metadata))(newState[0]), { state: newState[1], metadata: newMetadata }];
|
|
@@ -44,7 +44,7 @@ const parseMinusState = input => {
|
|
|
44
44
|
default: return [{ first: { kind: 'error', message: 'invalid token' }, tail: mapToken(input.token) }, { kind: 'def' }];
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
const scanToken = state =>
|
|
47
|
+
const scanToken = (input, state) => {
|
|
48
48
|
switch (state.kind) {
|
|
49
49
|
case '-': return parseMinusState(input);
|
|
50
50
|
default: return parseDefaultState(input);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 256-bit content-addressed identifiers for SUL values.
|
|
3
|
+
* Every identifier is one of three variants: a level-3 literal (inline), a raw bit vector (inline),
|
|
4
|
+
* or a SHA2-based hash, selected automatically by `compress` based on size and input type.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { type Vec } from '../../types/bit_vec/module.f.ts';
|
|
9
|
+
import { type Nominal } from '../../types/nominal/module.f.ts';
|
|
10
|
+
/** A 256-bit SUL identifier. One of three variants: level-3 literal, raw bit vector, or SHA2 hash. */
|
|
11
|
+
export type Id = Nominal<'sul/id', '6f5f6da053a6ac70e9687d42b7a09e925c3be21027f55beb2cba3040bf3d5b71', bigint>;
|
|
12
|
+
/**
|
|
13
|
+
* Note: no need to add a prefix.
|
|
14
|
+
*/
|
|
15
|
+
export declare const level3Id: (v: bigint) => Id;
|
|
16
|
+
/**
|
|
17
|
+
* Note: length(symbol) <= 253n
|
|
18
|
+
*
|
|
19
|
+
* @param symbol
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare const rawId: (symbol: Vec) => Id;
|
|
23
|
+
export declare const isRaw: (v: Id) => boolean;
|
|
24
|
+
export declare const isHash: (v: Id) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Note: we don't need to remove the prefix bits from the hash because
|
|
27
|
+
* the prefix equals the prefix mask (`1n << 0xFFn`).
|
|
28
|
+
*
|
|
29
|
+
* @param symbol
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export declare const hashId: (hash: bigint) => Id;
|
|
33
|
+
export declare const compress: (a: Id, b: Id) => Id;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 256-bit content-addressed identifiers for SUL values.
|
|
3
|
+
* Every identifier is one of three variants: a level-3 literal (inline), a raw bit vector (inline),
|
|
4
|
+
* or a SHA2-based hash, selected automatically by `compress` based on size and input type.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { toArray } from "../../types/list/module.f.js";
|
|
9
|
+
import { length, listToVec, msb, uint, uintChunkList, unpack, vec } from "../../types/bit_vec/module.f.js";
|
|
10
|
+
import { assertEq } from "../../dev/module.f.js";
|
|
11
|
+
import { utf8 } from "../../text/module.f.js";
|
|
12
|
+
import { secp256r1 } from "../../crypto/secp/module.f.js";
|
|
13
|
+
import { base32 } from "../../crypto/sha2/module.f.js";
|
|
14
|
+
import { literal3ToVec } from "../level/literal/module.f.js";
|
|
15
|
+
import { log2 } from "../../types/bigint/module.f.js";
|
|
16
|
+
import { asBase, asNominal } from "../../types/nominal/module.f.js";
|
|
17
|
+
// 32 bytes = 256 bits.
|
|
18
|
+
//
|
|
19
|
+
// 0 1
|
|
20
|
+
// 0123456789ABCDEF0123456789ABCDEF
|
|
21
|
+
const ivSeed = "Synthetic Universal Language 001";
|
|
22
|
+
const utf8IvSeed = utf8(ivSeed);
|
|
23
|
+
const c = secp256r1;
|
|
24
|
+
const ivUint = c.mul(uint(utf8IvSeed))(c.g)[0];
|
|
25
|
+
// 64 hex = 256 bits = 32 bytes:
|
|
26
|
+
assertEq(ivUint,
|
|
27
|
+
// 0 1 2 3
|
|
28
|
+
// 01234567_89ABCDEF_01234567_89ABCDEF_01234567_89ABCDEF_01234567_89ABCDEF
|
|
29
|
+
0x325d5666573eb118f32191de20d17f6433392ba3291ae46c1474a5eda5383f25n);
|
|
30
|
+
const iv = toArray(uintChunkList(msb)(32n)({ length: 256n, uint: ivUint }));
|
|
31
|
+
assertEq(iv.length, 8);
|
|
32
|
+
/**
|
|
33
|
+
* Note: no need to add a prefix.
|
|
34
|
+
*/
|
|
35
|
+
export const level3Id = asNominal;
|
|
36
|
+
const rawPrefixOffset = 0xfen;
|
|
37
|
+
const rawPrefix = 1n << rawPrefixOffset;
|
|
38
|
+
assertEq(rawPrefix,
|
|
39
|
+
// 0 1 2 3
|
|
40
|
+
// 01234567_89ABCDEF_01234567_89ABCDEF_01234567_89ABCDEF_01234567_89ABCDEF
|
|
41
|
+
0x4000000000000000000000000000000000000000000000000000000000000000n);
|
|
42
|
+
/**
|
|
43
|
+
* Note: length(symbol) <= 253n
|
|
44
|
+
*
|
|
45
|
+
* @param symbol
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export const rawId = (symbol) => {
|
|
49
|
+
const { length, uint } = unpack(symbol);
|
|
50
|
+
return asNominal(rawPrefix | uint | (1n << length));
|
|
51
|
+
};
|
|
52
|
+
// 253
|
|
53
|
+
const rawLenMax = 0xfdn;
|
|
54
|
+
export const isRaw = (v) => asBase(v) >> rawPrefixOffset === 1n;
|
|
55
|
+
const toRaw = (a) => {
|
|
56
|
+
if (!isRaw(a)) {
|
|
57
|
+
return literal3ToVec(asBase(a));
|
|
58
|
+
}
|
|
59
|
+
const raw = asBase(a) ^ rawPrefix;
|
|
60
|
+
const len = log2(raw);
|
|
61
|
+
return vec(len)(raw ^ (1n << len));
|
|
62
|
+
};
|
|
63
|
+
const hashPrefixOffset = 0xffn;
|
|
64
|
+
const hashPrefix = 1n << hashPrefixOffset;
|
|
65
|
+
assertEq(hashPrefix,
|
|
66
|
+
// 0 1 2 3
|
|
67
|
+
// 01234567_89ABCDEF_01234567_89ABCDEF_01234567_89ABCDEF_01234567_89ABCDEF
|
|
68
|
+
0x8000000000000000000000000000000000000000000000000000000000000000n);
|
|
69
|
+
export const isHash = (v) => asBase(v) >> hashPrefixOffset === 1n;
|
|
70
|
+
/**
|
|
71
|
+
* Note: we don't need to remove the prefix bits from the hash because
|
|
72
|
+
* the prefix equals the prefix mask (`1n << 0xFFn`).
|
|
73
|
+
*
|
|
74
|
+
* @param symbol
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
export const hashId = (hash) => asNominal(hashPrefix | hash);
|
|
78
|
+
const hash2 = base32.compress(iv);
|
|
79
|
+
const vecX20 = vec(0x20n);
|
|
80
|
+
const ltv = listToVec(msb);
|
|
81
|
+
const hashMerge = (a, b) => hashId(uint(ltv(hash2((asBase(a) << 0x100n) | asBase(b)).map(vecX20))));
|
|
82
|
+
const { concat } = msb;
|
|
83
|
+
export const compress = (a, b) => {
|
|
84
|
+
if (isHash(a) || isHash(b)) {
|
|
85
|
+
return hashMerge(a, b);
|
|
86
|
+
}
|
|
87
|
+
const ra = toRaw(a);
|
|
88
|
+
const rb = toRaw(b);
|
|
89
|
+
const len = length(ra) + length(rb);
|
|
90
|
+
if (len > rawLenMax) {
|
|
91
|
+
return hashMerge(a, b);
|
|
92
|
+
}
|
|
93
|
+
return rawId(concat(ra)(rb));
|
|
94
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
inline_00_00: () => void;
|
|
3
|
+
inline_00_01: () => void;
|
|
4
|
+
inline_01_00: () => void;
|
|
5
|
+
inline_01_01: () => void;
|
|
6
|
+
inline_00_04: () => void;
|
|
7
|
+
inline_04_00: () => void;
|
|
8
|
+
inline_0A_80: () => void;
|
|
9
|
+
inline_is_raw: () => void;
|
|
10
|
+
non_commutative: () => void;
|
|
11
|
+
overflow_is_hash: () => void;
|
|
12
|
+
hash_left_is_hash: () => void;
|
|
13
|
+
hash_right_is_hash: () => void;
|
|
14
|
+
hash_non_commutative: () => void;
|
|
15
|
+
hash_merge_a_high_bits: () => void;
|
|
16
|
+
hash_merge_b_high_bits: () => void;
|
|
17
|
+
hash_merge_a_sensitivity: () => void;
|
|
18
|
+
hash_merge_b_sensitivity: () => void;
|
|
19
|
+
hash_merge_shift: () => void;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { assert, assertEq } from "../../dev/module.f.js";
|
|
2
|
+
import { mask } from "../../types/bigint/module.f.js";
|
|
3
|
+
import { vec } from "../../types/bit_vec/module.f.js";
|
|
4
|
+
import { compress, hashId, isHash, isRaw, level3Id, rawId } from "./module.f.js";
|
|
5
|
+
import { asBase } from "../../types/nominal/module.f.js";
|
|
6
|
+
// literal3ToVec bit patterns for symbols used below:
|
|
7
|
+
// 0 → vec(8n)(0n) 4 → vec(8n)(3n)
|
|
8
|
+
// 1 → vec(8n)(1n) 10 → vec(8n)(5n)
|
|
9
|
+
// 128 → vec(8n)(15n)
|
|
10
|
+
// Two 127-bit raw payloads overflow the 253-bit inline limit, producing a hash value.
|
|
11
|
+
const rawX7F = rawId(vec(0x7fn)(mask(0x7fn)));
|
|
12
|
+
const overflowHash = compress(rawX7F, rawX7F);
|
|
13
|
+
const hFF = hashId(mask(0xffn));
|
|
14
|
+
const hFE = hashId(mask(0xffn) - 1n);
|
|
15
|
+
assertEq(asBase(level3Id(0n)), 0n);
|
|
16
|
+
assertEq(asBase(hashId(0n)), 1n << 0xffn);
|
|
17
|
+
assertEq(asBase(hFF), mask(0x100n));
|
|
18
|
+
export default {
|
|
19
|
+
// Two level-3 literals whose combined bit vectors fit inline (≤ 253 bits)
|
|
20
|
+
inline_00_00: () => assertEq(compress(level3Id(0x00n), level3Id(0x00n)), rawId(vec(16n)(0x0000n))),
|
|
21
|
+
inline_00_01: () => assertEq(compress(level3Id(0x00n), level3Id(0x01n)), rawId(vec(16n)(0x0001n))),
|
|
22
|
+
inline_01_00: () => assertEq(compress(level3Id(0x01n), level3Id(0x00n)), rawId(vec(16n)(0x0100n))),
|
|
23
|
+
inline_01_01: () => assertEq(compress(level3Id(0x01n), level3Id(0x01n)), rawId(vec(16n)(0x0101n))),
|
|
24
|
+
inline_00_04: () => assertEq(compress(level3Id(0x00n), level3Id(0x04n)), rawId(vec(16n)(0x0003n))),
|
|
25
|
+
inline_04_00: () => assertEq(compress(level3Id(0x04n), level3Id(0x00n)), rawId(vec(16n)(0x0300n))),
|
|
26
|
+
inline_0A_80: () => assertEq(compress(level3Id(0x0an), level3Id(0x80n)), rawId(vec(16n)(0x050fn))),
|
|
27
|
+
// Inline outputs are raw-encoded (bit 254 set, bit 255 not set)
|
|
28
|
+
inline_is_raw: () => assert(isRaw(compress(level3Id(0x00n), level3Id(0x00n)))),
|
|
29
|
+
// Non-commutativity: argument order is preserved in concatenation
|
|
30
|
+
non_commutative: () => {
|
|
31
|
+
if (compress(level3Id(0n), level3Id(1n)) === compress(level3Id(1n), level3Id(0n))) {
|
|
32
|
+
throw compress(level3Id(0n), level3Id(1n));
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
// Overflow: two 127-bit raw payloads sum to 254 bits, exceeding the 253-bit inline limit
|
|
36
|
+
overflow_is_hash: () => assert(isHash(overflowHash)),
|
|
37
|
+
// Hash input: either argument being a hash always triggers SHA2-based merge
|
|
38
|
+
hash_left_is_hash: () => assert(isHash(compress(overflowHash, level3Id(0n)))),
|
|
39
|
+
hash_right_is_hash: () => assert(isHash(compress(level3Id(0n), overflowHash))),
|
|
40
|
+
hash_non_commutative: () => {
|
|
41
|
+
if (compress(overflowHash, level3Id(0n)) === compress(level3Id(0n), overflowHash)) {
|
|
42
|
+
throw compress(overflowHash, level3Id(0n));
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
// High-bit sensitivity: prefix bit of `a` is included in the SHA2 upper half
|
|
46
|
+
hash_merge_a_high_bits: () => {
|
|
47
|
+
if (compress(hashId(0n), hashId(0n)) === compress(level3Id(0n), hashId(0n))) {
|
|
48
|
+
throw compress(hashId(0n), hashId(0n));
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
// High-bit sensitivity: prefix bit of `b` is included in the SHA2 lower half
|
|
52
|
+
hash_merge_b_high_bits: () => {
|
|
53
|
+
if (compress(hashId(0n), hashId(0n)) === compress(hashId(0n), level3Id(0n))) {
|
|
54
|
+
throw compress(hashId(0n), hashId(0n));
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
// Shift correctness: changing a bit in `a` (upper 256 bits of SHA2 input) changes result
|
|
58
|
+
hash_merge_a_sensitivity: () => {
|
|
59
|
+
if (compress(hFF, hFF) === compress(hFE, hFF)) {
|
|
60
|
+
throw compress(hFF, hFF);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
// Shift correctness: changing a bit in `b` (lower 256 bits of SHA2 input) changes result
|
|
64
|
+
hash_merge_b_sensitivity: () => {
|
|
65
|
+
if (compress(hFF, hFF) === compress(hFF, hFE)) {
|
|
66
|
+
throw compress(hFF, hFF);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
// Shift correctness: same bit-flip in `a` vs `b` lands at different SHA2 input positions
|
|
70
|
+
hash_merge_shift: () => {
|
|
71
|
+
if (compress(hFE, hFF) === compress(hFF, hFE)) {
|
|
72
|
+
throw compress(hFE, hFF);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming encoder for SUL hash-level symbols using a Patricia trie and 256-bit content-addressed hashes.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type State } from '../../../types/patricia_trie/module.f.ts';
|
|
7
|
+
import { type Id } from '../../id/module.f.ts';
|
|
8
|
+
/**
|
|
9
|
+
* Called once per merge during encoding. `merged = compress(left, right)`.
|
|
10
|
+
* `isSymbol` is `true` for the terminal `compress(root, t)` that produces the
|
|
11
|
+
* word-level output symbol, and `false` for Patricia trie internal merges.
|
|
12
|
+
* Implementations record the triple in a content-addressed store.
|
|
13
|
+
*/
|
|
14
|
+
export type Add<S> = (left: Id, right: Id, merged: Id, isSymbol: boolean, storage: S) => S;
|
|
15
|
+
/**
|
|
16
|
+
* Streaming state for hash-level encoding.
|
|
17
|
+
* Wraps the Patricia trie state that accumulates the strictly-decreasing
|
|
18
|
+
* prefix of the word currently being encoded.
|
|
19
|
+
*/
|
|
20
|
+
export type EncodeState<S> = State<S, Id>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a streaming encoder for hash-level symbols.
|
|
23
|
+
*
|
|
24
|
+
* The returned step function processes one level-3 symbol at a time.
|
|
25
|
+
* It returns `undefined` while the strictly-decreasing prefix is still
|
|
26
|
+
* being accumulated. When the terminating symbol `t` arrives (`t >= last`),
|
|
27
|
+
* the word `[s0 > ... > sk, t]` is finalised:
|
|
28
|
+
*
|
|
29
|
+
* 1. The Patricia trie of `[s0, ..., sk]` is collapsed to a root hash.
|
|
30
|
+
* 2. The root is merged with `t` via `compress`, producing the output symbol.
|
|
31
|
+
* 3. State is reset to an empty stack (storage is preserved).
|
|
32
|
+
*
|
|
33
|
+
* `add` is called once for every `compress` call. `isSymbol` is `false` for
|
|
34
|
+
* Patricia trie internal merges and `true` for the terminal `compress(root, t)`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const encode: <S>(add: Add<S>) => (symbol: Id, state: EncodeState<S>) => readonly [Id | undefined, EncodeState<S>];
|
|
37
|
+
/** Returns the initial encoding state wrapping `storage`. */
|
|
38
|
+
export declare const emptyEncodeState: <S>(storage: S) => EncodeState<S>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming encoder for SUL hash-level symbols using a Patricia trie and 256-bit content-addressed hashes.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { emptyState, patriciaTrie } from "../../../types/patricia_trie/module.f.js";
|
|
7
|
+
import { compress } from "../../id/module.f.js";
|
|
8
|
+
import { asBase } from "../../../types/nominal/module.f.js";
|
|
9
|
+
/**
|
|
10
|
+
* Returns a streaming encoder for hash-level symbols.
|
|
11
|
+
*
|
|
12
|
+
* The returned step function processes one level-3 symbol at a time.
|
|
13
|
+
* It returns `undefined` while the strictly-decreasing prefix is still
|
|
14
|
+
* being accumulated. When the terminating symbol `t` arrives (`t >= last`),
|
|
15
|
+
* the word `[s0 > ... > sk, t]` is finalised:
|
|
16
|
+
*
|
|
17
|
+
* 1. The Patricia trie of `[s0, ..., sk]` is collapsed to a root hash.
|
|
18
|
+
* 2. The root is merged with `t` via `compress`, producing the output symbol.
|
|
19
|
+
* 3. State is reset to an empty stack (storage is preserved).
|
|
20
|
+
*
|
|
21
|
+
* `add` is called once for every `compress` call. `isSymbol` is `false` for
|
|
22
|
+
* Patricia trie internal merges and `true` for the terminal `compress(root, t)`.
|
|
23
|
+
*/
|
|
24
|
+
export const encode = (add) => {
|
|
25
|
+
const create = (isSymbol) => (a, b, s) => {
|
|
26
|
+
const m = compress(a, b);
|
|
27
|
+
return [m, add(a, b, m, isSymbol, s)];
|
|
28
|
+
};
|
|
29
|
+
const { push, end } = patriciaTrie(create(false));
|
|
30
|
+
const rootCreate = create(true);
|
|
31
|
+
return (symbol, state) => {
|
|
32
|
+
const [, stack] = state;
|
|
33
|
+
const last = stack.at(-1);
|
|
34
|
+
if (last === undefined || last[0] > asBase(symbol)) {
|
|
35
|
+
return [undefined, push([asBase(symbol), symbol], state)];
|
|
36
|
+
}
|
|
37
|
+
const [root1, storage1] = end(state);
|
|
38
|
+
const [root2, storage2] = rootCreate(root1, symbol, storage1);
|
|
39
|
+
return [root2, [storage2, []]];
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/** Returns the initial encoding state wrapping `storage`. */
|
|
43
|
+
export const emptyEncodeState = emptyState;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
min_equal: () => void;
|
|
3
|
+
min_greater: () => void;
|
|
4
|
+
intermediate_undefined: () => void;
|
|
5
|
+
three_symbol: () => void;
|
|
6
|
+
output_is_last_add: () => void;
|
|
7
|
+
state_reset: () => void;
|
|
8
|
+
storage_accumulates: () => void;
|
|
9
|
+
two_words: () => void;
|
|
10
|
+
non_commutative: () => void;
|
|
11
|
+
isSymbol_terminal_only: () => void;
|
|
12
|
+
isSymbol_min_word: () => void;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|