functionalscript 0.18.0 → 0.20.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/fs/asn.1/module.f.js +7 -8
- package/fs/asn.1/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/asn.1/{test.f.js → proof.f.js} +12 -13
- package/fs/base128/proof.f.d.ts +1 -0
- package/fs/base128/{test.f.js → proof.f.js} +1 -1
- package/fs/bnf/data/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/bnf/data/{test.f.js → proof.f.js} +1 -1
- package/fs/bnf/proof.f.d.ts +3 -0
- package/fs/bnf/{test.f.js → proof.f.js} +1 -1
- package/fs/cas/module.f.js +2 -12
- package/fs/cas/proof.f.d.ts +1 -0
- package/fs/cas/proof.f.js +1 -0
- package/fs/cbase32/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/cbase32/{test.f.js → proof.f.js} +1 -1
- package/fs/ci/config/module.f.d.ts +4 -4
- package/fs/ci/config/module.f.js +4 -4
- package/fs/ci/node/module.f.js +12 -7
- package/fs/ci/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/ci/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/hmac/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/hmac/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/secp/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/secp/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/sha2/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/sha2/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/sign/module.f.js +3 -3
- package/fs/crypto/sign/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/sign/{test.f.js → proof.f.js} +1 -1
- package/fs/dev/module.f.d.ts +28 -2
- package/fs/dev/module.f.js +38 -22
- package/fs/dev/{test.f.d.ts → proof.f.d.ts} +5 -2
- package/fs/dev/{test.f.js → proof.f.js} +25 -2
- package/fs/dev/tf/module.d.ts +1 -2
- package/fs/dev/tf/module.f.d.ts +70 -7
- package/fs/dev/tf/module.f.js +115 -27
- package/fs/dev/tf/module.js +4 -103
- package/fs/dev/tf/{test.f.d.ts → proof.f.d.ts} +26 -0
- package/fs/dev/tf/{test.f.js → proof.f.js} +85 -38
- package/fs/dev/tf/scenarios/all.d.ts +1 -0
- package/fs/dev/tf/scenarios/all.js +3 -0
- package/fs/dev/tf/scenarios/async-subtests.fail.d.ts +4 -0
- package/fs/dev/tf/scenarios/async-subtests.fail.js +7 -0
- package/fs/dev/tf/scenarios/async-subtests.pass.d.ts +4 -0
- package/fs/dev/tf/scenarios/async-subtests.pass.js +7 -0
- package/fs/dev/tf/scenarios/async.fail.d.ts +1 -0
- package/fs/dev/tf/scenarios/async.fail.js +4 -0
- package/fs/dev/tf/scenarios/async.pass.d.ts +1 -0
- package/fs/dev/tf/scenarios/async.pass.js +3 -0
- package/fs/dev/tf/scenarios/fail.fail.f.d.ts +1 -0
- package/fs/dev/tf/scenarios/fail.fail.f.js +1 -0
- package/fs/dev/tf/scenarios/return-value.pass.f.d.ts +1 -0
- package/fs/dev/tf/scenarios/return-value.pass.f.js +2 -0
- package/fs/dev/tf/scenarios/thenable.pass.d.ts +3 -0
- package/fs/dev/tf/scenarios/thenable.pass.js +9 -0
- package/fs/dev/tf/scenarios/thenable2.pass.f.d.ts +3 -0
- package/fs/dev/tf/scenarios/thenable2.pass.f.js +3 -0
- package/fs/{bnf/test.f.d.ts → dev/tf/scenarios/throw.pass.f.d.ts} +3 -1
- package/fs/dev/tf/scenarios/throw.pass.f.js +3 -0
- package/fs/dev/version/proof.f.d.ts +3 -0
- package/fs/dev/version/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/ast/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/ast/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/parser/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/serializer/module.f.d.ts +2 -2
- package/fs/djs/serializer/module.f.js +47 -79
- package/fs/djs/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/serializer/{test.f.js → proof.f.js} +8 -8
- package/fs/djs/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/tokenizer-new/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/tokenizer-new/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/transpiler/module.f.d.ts +15 -0
- package/fs/djs/transpiler/module.f.js +10 -2
- package/fs/djs/transpiler/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/transpiler/{test.f.js → proof.f.js} +1 -1
- package/fs/fsc/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/fsc/{test.f.js → proof.f.js} +1 -1
- package/fs/fsm/proof.f.d.ts +4 -0
- package/fs/fsm/{test.f.js → proof.f.js} +1 -1
- package/fs/html/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/html/{test.f.js → proof.f.js} +1 -1
- package/fs/io/module.d.ts +1 -1
- package/fs/io/module.f.d.ts +8 -3
- package/fs/io/module.f.js +12 -12
- package/fs/io/module.js +43 -5
- package/fs/js/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/js/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/json/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/parser/{test.f.js → proof.f.js} +1 -1
- package/fs/json/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/{test.f.js → proof.f.js} +1 -1
- package/fs/json/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/serializer/{test.f.js → proof.f.js} +1 -1
- package/fs/json/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/path/proof.f.d.ts +5 -0
- package/fs/path/{test.f.js → proof.f.js} +4 -3
- package/fs/sul/id/module.f.js +3 -4
- package/fs/sul/id/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/id/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/level/hash/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/level/hash/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/level/literal/module.f.js +3 -3
- package/fs/sul/level/literal/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/level/literal/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/{test.f.js → proof.f.js} +1 -1
- package/fs/text/ascii/proof.f.d.ts +3 -0
- package/fs/text/ascii/{test.f.js → proof.f.js} +1 -1
- package/fs/text/code_point/module.f.d.ts +28 -0
- package/fs/text/code_point/module.f.js +31 -0
- package/fs/text/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/{test.f.js → proof.f.js} +1 -1
- package/fs/text/sgr/proof.f.d.ts +1 -0
- package/fs/text/sgr/proof.f.js +23 -0
- package/fs/text/utf16/module.f.js +3 -53
- package/fs/text/utf16/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/utf16/{test.f.js → proof.f.js} +1 -1
- package/fs/text/utf8/module.f.js +3 -25
- package/fs/text/utf8/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/utf8/{test.f.js → proof.f.js} +1 -1
- package/fs/types/array/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/array/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bigfloat/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bigfloat/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bigint/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bigint/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bit_vec/module.f.d.ts +9 -4
- package/fs/types/bit_vec/module.f.js +7 -9
- package/fs/types/bit_vec/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bit_vec/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/find/proof.f.d.ts +1 -0
- package/fs/types/btree/find/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/btree/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/remove/module.f.d.ts +1 -1
- package/fs/types/btree/remove/module.f.js +7 -2
- package/fs/types/btree/remove/proof.f.d.ts +4 -0
- package/fs/types/btree/remove/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/set/module.f.d.ts +1 -1
- package/fs/types/btree/set/module.f.js +7 -2
- package/fs/types/btree/set/proof.f.d.ts +1 -0
- package/fs/types/btree/set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/types/module.f.d.ts +9 -0
- package/fs/types/btree/types/module.f.js +9 -1
- package/fs/types/byte_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/byte_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/effects/module.f.d.ts +17 -0
- package/fs/types/effects/module.f.js +17 -0
- package/fs/types/effects/node/module.f.d.ts +66 -4
- package/fs/types/effects/node/module.f.js +5 -1
- package/fs/types/effects/node/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/effects/node/{test.f.js → proof.f.js} +1 -1
- package/fs/types/effects/node/virtual/module.f.d.ts +2 -1
- package/fs/types/effects/node/virtual/module.f.js +2 -0
- package/fs/types/effects/proof.f.d.ts +11 -0
- package/fs/types/effects/proof.f.js +57 -0
- package/fs/types/function/compare/proof.f.d.ts +1 -0
- package/fs/types/function/compare/{test.f.js → proof.f.js} +1 -1
- package/fs/types/function/operator/proof.f.d.ts +12 -0
- package/fs/types/function/operator/{test.f.js → proof.f.js} +11 -10
- package/fs/types/function/proof.f.d.ts +1 -0
- package/fs/types/function/{test.f.js → proof.f.js} +1 -1
- package/fs/types/list/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/list/{test.f.js → proof.f.js} +1 -1
- package/fs/types/map/proof.f.d.ts +4 -0
- package/fs/types/map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/monoid/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/monoid/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nibble_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/nibble_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nominal/proof.f.d.ts +4 -0
- package/fs/types/nominal/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nullable/proof.f.d.ts +1 -0
- package/fs/types/nullable/{test.f.js → proof.f.js} +11 -2
- package/fs/types/number/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/number/{test.f.js → proof.f.js} +1 -1
- package/fs/types/object/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/object/{test.f.js → proof.f.js} +1 -1
- package/fs/types/ordered_map/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/ordered_map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/patricia_trie/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/patricia_trie/{test.f.js → proof.f.js} +1 -1
- package/fs/types/prime_field/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/prime_field/{test.f.js → proof.f.js} +1 -1
- package/fs/types/range/proof.f.d.ts +1 -0
- package/fs/types/range/{test.f.js → proof.f.js} +1 -1
- package/fs/types/range_map/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/range_map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/result/proof.f.d.ts +5 -0
- package/fs/types/result/{test.f.js → proof.f.js} +18 -2
- package/fs/types/rtti/parse/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/parse/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/ts/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/ts/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/validate/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/validate/{test.f.js → proof.f.js} +1 -1
- package/fs/types/sorted_list/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/sorted_list/{test.f.js → proof.f.js} +1 -1
- package/fs/types/sorted_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/sorted_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/string/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/string/{test.f.js → proof.f.js} +1 -1
- package/fs/types/string_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/string_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/ts/{test.f.d.ts → proof.f.d.ts} +20 -0
- package/fs/types/ts/{test.f.js → proof.f.js} +1 -0
- package/fs/types/uint8array/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/uint8array/{test.f.js → proof.f.js} +1 -1
- package/issues/demo/sample/{test.f.js → proof.f.js} +1 -1
- package/issues/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/issues/{test.f.js → proof.f.js} +1 -1
- package/nanvm-lib/tests/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/nanvm-lib/tests/{test.f.js → proof.f.js} +1 -1
- package/nanvm-lib/tests/vm/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/nanvm-lib/tests/vm/{test.f.js → proof.f.js} +1 -1
- package/package.json +5 -5
- package/fs/base128/test.f.d.ts +0 -2
- package/fs/cas/test.f.d.ts +0 -2
- package/fs/cas/test.f.js +0 -1
- package/fs/dev/version/test.f.d.ts +0 -4
- package/fs/fsm/test.f.d.ts +0 -5
- package/fs/path/test.f.d.ts +0 -3
- package/fs/text/ascii/test.f.d.ts +0 -4
- package/fs/text/sgr/test.f.d.ts +0 -2
- package/fs/text/sgr/test.f.js +0 -8
- package/fs/types/btree/find/test.f.d.ts +0 -2
- package/fs/types/btree/remove/test.f.d.ts +0 -5
- package/fs/types/btree/set/test.f.d.ts +0 -2
- package/fs/types/function/compare/test.f.d.ts +0 -2
- package/fs/types/function/operator/test.f.d.ts +0 -10
- package/fs/types/function/test.f.d.ts +0 -2
- package/fs/types/map/test.f.d.ts +0 -5
- package/fs/types/nominal/test.f.d.ts +0 -5
- package/fs/types/nullable/test.f.d.ts +0 -2
- package/fs/types/range/test.f.d.ts +0 -2
- package/fs/types/result/test.f.d.ts +0 -2
package/fs/asn.1/module.f.js
CHANGED
|
@@ -5,19 +5,18 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import { bitLength, max } from "../types/bigint/module.f.js";
|
|
8
|
-
import { empty, isVec, length,
|
|
8
|
+
import { empty, isVec, length, msb, uint, unpack, vec, vec8 } from "../types/bit_vec/module.f.js";
|
|
9
9
|
import { identity } from "../types/function/module.f.js";
|
|
10
10
|
import { encode as b128encode, decode as b128decode } from "../base128/module.f.js";
|
|
11
|
-
const pop = msb
|
|
11
|
+
const { popFront: pop, listToVec } = msb;
|
|
12
12
|
const pop8 = pop(8n);
|
|
13
|
-
const concat = listToVec(msb);
|
|
14
13
|
const classPcMask = 224n;
|
|
15
14
|
const tagNumberMask = 31n;
|
|
16
15
|
const parsedTagEncode = ([classPc, number]) => {
|
|
17
16
|
const [firstByteNumber, rest] = number < tagNumberMask
|
|
18
17
|
? [number, empty]
|
|
19
18
|
: [tagNumberMask, b128encode(number)];
|
|
20
|
-
return
|
|
19
|
+
return listToVec([vec8(classPc | firstByteNumber), rest]);
|
|
21
20
|
};
|
|
22
21
|
const parsedTagDecode = (v) => {
|
|
23
22
|
const [firstByte, rest] = pop8(v);
|
|
@@ -86,7 +85,7 @@ const lenEncode = (uint) => {
|
|
|
86
85
|
return vec8(uint);
|
|
87
86
|
}
|
|
88
87
|
const { byteLen, v } = round8({ length: bitLength(uint), uint });
|
|
89
|
-
return
|
|
88
|
+
return listToVec([vec8(0x80n | byteLen), v]);
|
|
90
89
|
};
|
|
91
90
|
/**
|
|
92
91
|
* Decodes the length field of an ASN.1 TLV and returns the length in bits and the remaining input.
|
|
@@ -104,7 +103,7 @@ const lenDecode = (v) => {
|
|
|
104
103
|
export const encodeRaw = ([tag, value]) => {
|
|
105
104
|
const tagVec = tagEncode(tag);
|
|
106
105
|
const { byteLen, v } = round8(unpack(value));
|
|
107
|
-
return
|
|
106
|
+
return listToVec([tagVec, lenEncode(byteLen), v]);
|
|
108
107
|
};
|
|
109
108
|
/** Decodes a raw ASN.1 TLV tuple and returns the remaining input. */
|
|
110
109
|
export const decodeRaw = (v) => {
|
|
@@ -139,7 +138,7 @@ export const decodeOctetString = (v) => v;
|
|
|
139
138
|
export const encodeObjectIdentifier = (oid) => {
|
|
140
139
|
const [first, second, ...rest] = oid;
|
|
141
140
|
const firstByte = first * 40n + second;
|
|
142
|
-
return
|
|
141
|
+
return listToVec([vec8(firstByte), ...rest.map(b128encode)]);
|
|
143
142
|
};
|
|
144
143
|
/** Decodes an OBJECT IDENTIFIER value. */
|
|
145
144
|
export const decodeObjectIdentifier = (v) => {
|
|
@@ -155,7 +154,7 @@ export const decodeObjectIdentifier = (v) => {
|
|
|
155
154
|
}
|
|
156
155
|
return result;
|
|
157
156
|
};
|
|
158
|
-
const genericEncodeSequence = (map) => (...records) =>
|
|
157
|
+
const genericEncodeSequence = (map) => (...records) => listToVec(map(records.map(encode)));
|
|
159
158
|
/** Encodes a SEQUENCE payload from ordered records. */
|
|
160
159
|
export const encodeSequence = genericEncodeSequence(identity);
|
|
161
160
|
/** Decodes a SEQUENCE payload into records. */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { empty, length,
|
|
1
|
+
import { empty, length, msb, uint, unpack, vec, vec8 } from "../types/bit_vec/module.f.js";
|
|
2
2
|
import { asBase } from "../types/nominal/module.f.js";
|
|
3
3
|
import { decodeRaw, decodeInteger, encodeRaw, encodeInteger, integer, encode, decode, constructedSequence, octetString, boolean, constructedSet } from "./module.f.js";
|
|
4
|
-
const { concat, popFront: pop } = msb;
|
|
5
|
-
const cat = listToVec(msb);
|
|
4
|
+
const { concat, popFront: pop, listToVec } = msb;
|
|
6
5
|
const pop8 = pop(8n);
|
|
7
6
|
const check = (tag, v, rest) => {
|
|
8
7
|
const s = encodeRaw([tag, v]);
|
|
@@ -46,7 +45,7 @@ const ch = (r, v) => {
|
|
|
46
45
|
ch0(r, v, vec8(0x23n));
|
|
47
46
|
ch0(r, v, vec(16n)(0x2345n));
|
|
48
47
|
};
|
|
49
|
-
export
|
|
48
|
+
export const proof = {
|
|
50
49
|
encodeSmall: () => {
|
|
51
50
|
const v = vec8(0x13n);
|
|
52
51
|
const x = encodeRaw([integer, v]);
|
|
@@ -244,19 +243,19 @@ export default {
|
|
|
244
243
|
},
|
|
245
244
|
encodeDecode: {
|
|
246
245
|
integer: () => {
|
|
247
|
-
ch([integer, 0n],
|
|
248
|
-
ch([integer, 1n],
|
|
246
|
+
ch([integer, 0n], listToVec([vec8(BigInt(integer)), vec8(1n), vec8(0n)]));
|
|
247
|
+
ch([integer, 1n], listToVec([vec8(BigInt(integer)), vec8(1n), vec8(1n)]));
|
|
249
248
|
},
|
|
250
249
|
sequence: () => {
|
|
251
|
-
ch([constructedSequence, []],
|
|
252
|
-
ch([constructedSequence, [[integer, 0n]]],
|
|
253
|
-
ch([constructedSequence, [[integer, 1n], [integer, 2n]]],
|
|
250
|
+
ch([constructedSequence, []], listToVec([vec8(BigInt(constructedSequence)), vec8(0n)]));
|
|
251
|
+
ch([constructedSequence, [[integer, 0n]]], listToVec([vec8(BigInt(constructedSequence)), vec8(3n), encode([integer, 0n])]));
|
|
252
|
+
ch([constructedSequence, [[integer, 1n], [integer, 2n]]], listToVec([
|
|
254
253
|
vec8(BigInt(constructedSequence)),
|
|
255
254
|
vec8(6n),
|
|
256
255
|
encode([integer, 1n]),
|
|
257
256
|
encode([integer, 2n])
|
|
258
257
|
]));
|
|
259
|
-
ch([constructedSequence, [[octetString, vec8(0x23n)], [boolean, true], [boolean, false]]],
|
|
258
|
+
ch([constructedSequence, [[octetString, vec8(0x23n)], [boolean, true], [boolean, false]]], listToVec([
|
|
260
259
|
vec8(BigInt(constructedSequence)),
|
|
261
260
|
vec8(9n),
|
|
262
261
|
encode([octetString, vec8(0x23n)]),
|
|
@@ -265,7 +264,7 @@ export default {
|
|
|
265
264
|
]));
|
|
266
265
|
},
|
|
267
266
|
set: () => {
|
|
268
|
-
ch([constructedSet, [[integer, 2n], [integer, 1n]]],
|
|
267
|
+
ch([constructedSet, [[integer, 2n], [integer, 1n]]], listToVec([
|
|
269
268
|
vec8(BigInt(constructedSet)),
|
|
270
269
|
vec8(6n),
|
|
271
270
|
encode([integer, 1n]),
|
|
@@ -276,7 +275,7 @@ export default {
|
|
|
276
275
|
raw: [
|
|
277
276
|
() => {
|
|
278
277
|
const e = encodeRaw([0x00n, vec8(0x23n)]);
|
|
279
|
-
if (e !==
|
|
278
|
+
if (e !== listToVec([vec8(0x00n), vec8(1n), vec8(0x23n)])) {
|
|
280
279
|
throw `encode: ${length(e)}: ${uint(e).toString(2)}`;
|
|
281
280
|
}
|
|
282
281
|
const [[tag, value], rest] = decodeRaw(e);
|
|
@@ -292,7 +291,7 @@ export default {
|
|
|
292
291
|
},
|
|
293
292
|
() => {
|
|
294
293
|
const e = encodeRaw([0x1f20n, vec(16n)(0x1234n)]);
|
|
295
|
-
if (e !==
|
|
294
|
+
if (e !== listToVec([vec8(0x1fn), vec8(0x20n), vec8(2n), vec(16n)(0x1234n)])) {
|
|
296
295
|
const l = length(e);
|
|
297
296
|
const u = uint(e);
|
|
298
297
|
throw `encode: ${l}: ${u.toString(16)}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const proof: {
|
|
2
2
|
rangeDecode: () => void;
|
|
3
3
|
rangeEncode: () => void;
|
|
4
4
|
toData: (() => void)[];
|
|
@@ -12,4 +12,3 @@ declare const _default: {
|
|
|
12
12
|
repeatParser: (() => void)[];
|
|
13
13
|
example: () => void;
|
|
14
14
|
};
|
|
15
|
-
export default _default;
|
|
@@ -11,7 +11,7 @@ const descentParserCpOnly = (m, name, cp) => {
|
|
|
11
11
|
const cpm = toArray(map(mapCodePoint)(cp));
|
|
12
12
|
return m(name, cpm);
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export const proof = {
|
|
15
15
|
rangeDecode: () => {
|
|
16
16
|
const decoded1 = stringify(sort)(rangeDecode(0x000079_000087));
|
|
17
17
|
if (decoded1 !== '[121,135]') {
|
package/fs/cas/module.f.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { computeSync, sha256 } from "../crypto/sha2/module.f.js";
|
|
7
7
|
import { parse } from "../path/module.f.js";
|
|
8
8
|
import { cBase32ToVec, vecToCBase32 } from "../cbase32/module.f.js";
|
|
9
|
-
import { begin, pure } from "../types/effects/module.f.js";
|
|
9
|
+
import { begin, forEachStep, pure } from "../types/effects/module.f.js";
|
|
10
10
|
import { error, log, mkdir, readdir, readFile, writeFile } from "../types/effects/node/module.f.js";
|
|
11
11
|
import { toOption } from "../types/nullable/module.f.js";
|
|
12
12
|
import { unwrap } from "../types/result/module.f.js";
|
|
@@ -111,17 +111,7 @@ export const main = (args) => {
|
|
|
111
111
|
case 'list': {
|
|
112
112
|
return begin
|
|
113
113
|
.step(() => c.list())
|
|
114
|
-
.step(
|
|
115
|
-
// TODO: make it lazy.
|
|
116
|
-
let i = begin;
|
|
117
|
-
for (const j of v) {
|
|
118
|
-
const prev = i;
|
|
119
|
-
i = begin
|
|
120
|
-
.step(() => prev)
|
|
121
|
-
.step(() => log(vecToCBase32(j)));
|
|
122
|
-
}
|
|
123
|
-
return i;
|
|
124
|
-
})
|
|
114
|
+
.step(forEachStep(j => log(vecToCBase32(j))))
|
|
125
115
|
.step(() => pure(0));
|
|
126
116
|
}
|
|
127
117
|
case undefined: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const proof = () => { };
|
|
@@ -20,13 +20,13 @@ export declare const images: {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
export declare const bun = "1.3.14";
|
|
23
|
-
export declare const deno = "2.8.
|
|
23
|
+
export declare const deno = "2.8.1";
|
|
24
24
|
export declare const playwright = "1.60.0";
|
|
25
25
|
export declare const rust = "1.95.0";
|
|
26
26
|
export declare const node: {
|
|
27
27
|
readonly default: "26.2.0";
|
|
28
|
-
readonly others: readonly ["
|
|
28
|
+
readonly others: readonly ["24.16.0"];
|
|
29
29
|
};
|
|
30
|
-
export declare const wasmtime = "
|
|
30
|
+
export declare const wasmtime = "45.0.0";
|
|
31
31
|
export declare const wasmer = "7.1.0";
|
|
32
|
-
export declare const tsgo = "7.0.0-dev.
|
|
32
|
+
export declare const tsgo = "7.0.0-dev.20260527.1";
|
package/fs/ci/config/module.f.js
CHANGED
|
@@ -23,7 +23,7 @@ export const images = {
|
|
|
23
23
|
// https://bun.sh/
|
|
24
24
|
export const bun = '1.3.14';
|
|
25
25
|
// https://deno.com/
|
|
26
|
-
export const deno = '2.8.
|
|
26
|
+
export const deno = '2.8.1';
|
|
27
27
|
// https://www.npmjs.com/package/playwright
|
|
28
28
|
export const playwright = '1.60.0';
|
|
29
29
|
// https://rust-lang.org/
|
|
@@ -31,11 +31,11 @@ export const rust = '1.95.0';
|
|
|
31
31
|
// https://nodejs.org/en/download
|
|
32
32
|
export const node = {
|
|
33
33
|
default: '26.2.0',
|
|
34
|
-
others: ['
|
|
34
|
+
others: ['24.16.0'],
|
|
35
35
|
};
|
|
36
36
|
// https://github.com/bytecodealliance/wasmtime/releases
|
|
37
|
-
export const wasmtime = '
|
|
37
|
+
export const wasmtime = '45.0.0';
|
|
38
38
|
// https://github.com/wasmerio/wasmer/releases
|
|
39
39
|
export const wasmer = '7.1.0';
|
|
40
40
|
// https://www.npmjs.com/package/@typescript/native-preview?activeTab=versions
|
|
41
|
-
export const tsgo = '7.0.0-dev.
|
|
41
|
+
export const tsgo = '7.0.0-dev.20260527.1';
|
package/fs/ci/node/module.f.js
CHANGED
|
@@ -8,20 +8,25 @@ import { node, tsgo } from "../config/module.f.js";
|
|
|
8
8
|
import { clean, findTgz, install, test, ubuntu } from "../common/module.f.js";
|
|
9
9
|
export const major = (v) => v.split('.')[0];
|
|
10
10
|
const installNode = (version) => ({ uses: 'actions/setup-node@v6', with: { 'node-version': version } });
|
|
11
|
-
|
|
12
|
-
install(installNode(
|
|
11
|
+
const nodeInstall = (v) => [
|
|
12
|
+
install(installNode(v)),
|
|
13
13
|
test({ run: 'npm ci' }),
|
|
14
|
+
];
|
|
15
|
+
export const basicNode = (version) => (extra) => clean([
|
|
16
|
+
...nodeInstall(version),
|
|
14
17
|
...extra,
|
|
15
18
|
]);
|
|
16
|
-
|
|
17
|
-
test({ run: 'npm
|
|
19
|
+
const basicTests = [
|
|
20
|
+
test({ run: 'npm t' }),
|
|
18
21
|
test({ run: 'npm run fst' }),
|
|
22
|
+
];
|
|
23
|
+
export const nodeTests = (version) => (extra) => basicNode(version)([
|
|
24
|
+
...basicTests,
|
|
19
25
|
...extra,
|
|
20
26
|
]);
|
|
21
27
|
const nodeSteps = (v) => [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
test({ run: 'npm t' }),
|
|
28
|
+
...nodeInstall(v),
|
|
29
|
+
...basicTests,
|
|
25
30
|
];
|
|
26
31
|
export const nodeVersions = Object.fromEntries(node.others.map(v => [
|
|
27
32
|
`node${major(v)}`,
|
|
@@ -23,7 +23,7 @@ const run = (rust, nodeExtra = () => []) => {
|
|
|
23
23
|
assert(isVec(file), file);
|
|
24
24
|
return unwrap(parseGitHubAction(jsonParse(utf8ToString(file))));
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export const proof = {
|
|
27
27
|
rust: () => {
|
|
28
28
|
assert(hasRun('cargo')(run(true)), 'expected Rust steps');
|
|
29
29
|
},
|
|
@@ -2,7 +2,7 @@ import { utf8 } from "../../text/module.f.js";
|
|
|
2
2
|
import { uint, vec } from "../../types/bit_vec/module.f.js";
|
|
3
3
|
import { sha256, sha384, sha512 } from "../sha2/module.f.js";
|
|
4
4
|
import { hmac } from "./module.f.js";
|
|
5
|
-
export
|
|
5
|
+
export const proof = {
|
|
6
6
|
example: () => {
|
|
7
7
|
const r = hmac(sha256)(utf8('key'))(utf8('The quick brown fox jumps over the lazy dog'));
|
|
8
8
|
if (r !== vec(256n)(0xf7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8n)) {
|
|
@@ -12,7 +12,7 @@ const checkEmpty = ({ init, end, hashLength }) => (x) => {
|
|
|
12
12
|
// https://en.wikipedia.org/wiki/SHA-2#Test_vectors
|
|
13
13
|
//
|
|
14
14
|
// https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/Secure-Hashing
|
|
15
|
-
export
|
|
15
|
+
export const proof = {
|
|
16
16
|
base: {
|
|
17
17
|
b32: () => {
|
|
18
18
|
const { fromV8, compress, chunkLength } = base32;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bitLength, divUp, roundUp } from "../../types/bigint/module.f.js";
|
|
2
|
-
import { empty, length,
|
|
2
|
+
import { empty, length, msb, repeat, unpack, vec, vec8 } from "../../types/bit_vec/module.f.js";
|
|
3
3
|
import { hmac } from "../hmac/module.f.js";
|
|
4
4
|
import { computeSync } from "../sha2/module.f.js";
|
|
5
5
|
// qlen to rlen
|
|
@@ -34,8 +34,8 @@ export const all = (q) => {
|
|
|
34
34
|
export const fromCurve = (c) => all(c.nf.p);
|
|
35
35
|
const x01 = vec8(0x01n);
|
|
36
36
|
const x00 = vec8(0x00n);
|
|
37
|
-
const
|
|
38
|
-
export const concat = (...x) =>
|
|
37
|
+
const { listToVec } = msb;
|
|
38
|
+
export const concat = (...x) => listToVec(x);
|
|
39
39
|
/**
|
|
40
40
|
* Computes deterministic ECDSA nonce `k` as described by RFC6979.
|
|
41
41
|
*/
|
package/fs/dev/module.f.d.ts
CHANGED
|
@@ -10,14 +10,40 @@ export declare const todo: () => never;
|
|
|
10
10
|
export declare const assert: (v: boolean, msg?: unknown) => asserts v;
|
|
11
11
|
export declare const assertEq: <T>(a: T, b: T) => void;
|
|
12
12
|
export type Module = {
|
|
13
|
-
readonly
|
|
13
|
+
readonly proof?: unknown;
|
|
14
14
|
readonly [k: string]: unknown;
|
|
15
15
|
};
|
|
16
16
|
export type ModuleMap = {
|
|
17
17
|
readonly [k in string]: Module;
|
|
18
18
|
};
|
|
19
19
|
export declare const env: (io: Io) => (v: string) => string | undefined;
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Returns `true` if the file should be loaded for proof discovery.
|
|
22
|
+
*
|
|
23
|
+
* All FunctionalScript modules (`.f.ts` / `.f.js`) are safe to bulk-load by
|
|
24
|
+
* construction — they have no import side effects. For vanilla TS/JS the
|
|
25
|
+
* load gate stays opt-in by filename: any file ending in `proof.ts`,
|
|
26
|
+
* `proof.js`, `proof.mts`, or `proof.mjs` is included.
|
|
27
|
+
*
|
|
28
|
+
* Whether a loaded module actually _contains_ a proof is determined at
|
|
29
|
+
* runtime by checking for an exported `proof` property.
|
|
30
|
+
*/
|
|
31
|
+
export declare const shouldLoad: (s: string) => boolean;
|
|
32
|
+
/** The effect operations required to discover and load a module map. */
|
|
21
33
|
export type LoadModuleOperations = Access | Import | All | Readdir;
|
|
34
|
+
/**
|
|
35
|
+
* Discovers all source files under `INIT_CWD` (or `.` if unset) that match
|
|
36
|
+
* `predicate`, imports them, and returns a map from relative path to module
|
|
37
|
+
* exports.
|
|
38
|
+
*
|
|
39
|
+
* The `predicate` is propagated into `allFiles` so that non-matching files
|
|
40
|
+
* are excluded before any `import()` is attempted — no wasted I/O.
|
|
41
|
+
* The default matches all JS/TS source files (`.js`, `.ts`, `.mts`, `.mjs`).
|
|
42
|
+
* `loadFile`'s own guards (`.f.js`, `.f.ts`, `shouldLoad`) still apply on
|
|
43
|
+
* top; the predicate only controls which files are discovered.
|
|
44
|
+
*
|
|
45
|
+
* The result is sorted by path key using `string.cmp` so the order is
|
|
46
|
+
* deterministic regardless of filesystem traversal order.
|
|
47
|
+
*/
|
|
22
48
|
export declare const loadModuleMap: (env: Env) => Effect<LoadModuleOperations, ModuleMap>;
|
|
23
49
|
export declare const index4: NodeProgram;
|
package/fs/dev/module.f.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { updateVersion } from "./version/module.f.js";
|
|
2
2
|
import { access, all, both, import_, readdir, readFile, writeFile } from "../types/effects/node/module.f.js";
|
|
3
|
+
import { cmp as strCmp } from "../types/string/module.f.js";
|
|
3
4
|
import { utf8, utf8ToString } from "../text/module.f.js";
|
|
4
5
|
import { unwrap } from "../types/result/module.f.js";
|
|
5
6
|
import { begin, pure } from "../types/effects/module.f.js";
|
|
@@ -13,14 +14,28 @@ export const assert = (v, msg = 'assertion failed') => {
|
|
|
13
14
|
throw msg;
|
|
14
15
|
};
|
|
15
16
|
export const assertEq = (a, b) => assert(a === b, [a, b]);
|
|
16
|
-
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
17
17
|
export const env = ({ process: { env } }) => a => {
|
|
18
18
|
const r = Object.getOwnPropertyDescriptor(env, a);
|
|
19
19
|
return r === undefined ? undefined :
|
|
20
20
|
typeof r.get === 'function' ? r.get() :
|
|
21
21
|
r.value;
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Returns `true` if the file should be loaded for proof discovery.
|
|
25
|
+
*
|
|
26
|
+
* All FunctionalScript modules (`.f.ts` / `.f.js`) are safe to bulk-load by
|
|
27
|
+
* construction — they have no import side effects. For vanilla TS/JS the
|
|
28
|
+
* load gate stays opt-in by filename: any file ending in `proof.ts`,
|
|
29
|
+
* `proof.js`, `proof.mts`, or `proof.mjs` is included.
|
|
30
|
+
*
|
|
31
|
+
* Whether a loaded module actually _contains_ a proof is determined at
|
|
32
|
+
* runtime by checking for an exported `proof` property.
|
|
33
|
+
*/
|
|
34
|
+
export const shouldLoad = (s) => s.endsWith('.f.ts') || s.endsWith('.f.js') ||
|
|
35
|
+
s.endsWith('proof.ts') || s.endsWith('proof.js') ||
|
|
36
|
+
s.endsWith('proof.mts') || s.endsWith('proof.mjs');
|
|
37
|
+
const isSourceFile = (path) => path.endsWith('.js') || path.endsWith('.ts') || path.endsWith('.mts') || path.endsWith('.mjs');
|
|
38
|
+
const allFiles = (s, predicate) => {
|
|
24
39
|
const load = (p) => begin
|
|
25
40
|
.step(() => readdir(p, {}))
|
|
26
41
|
.step(d => {
|
|
@@ -38,7 +53,7 @@ export const allFiles = (s) => {
|
|
|
38
53
|
result = [...result, load(file)];
|
|
39
54
|
continue;
|
|
40
55
|
}
|
|
41
|
-
if (
|
|
56
|
+
if (predicate(file)) {
|
|
42
57
|
result = [...result, pure([file])];
|
|
43
58
|
}
|
|
44
59
|
}
|
|
@@ -47,18 +62,22 @@ export const allFiles = (s) => {
|
|
|
47
62
|
.step(v => pure(v.flat()));
|
|
48
63
|
return load(s);
|
|
49
64
|
};
|
|
50
|
-
const loadFile = (f) =>
|
|
51
|
-
const doImport = import_(f).step(r => pure([[f, unwrap(r)]]));
|
|
52
|
-
if (f.endsWith('.f.js')) {
|
|
53
|
-
return doImport;
|
|
54
|
-
}
|
|
55
|
-
if (f.endsWith('.f.ts')) {
|
|
56
|
-
return access(f.substring(0, f.length - 3) + '.js')
|
|
57
|
-
.step(r => r[0] === 'ok' ? pure([]) : doImport);
|
|
58
|
-
}
|
|
59
|
-
return pure([]);
|
|
60
|
-
};
|
|
65
|
+
const loadFile = (f) => import_(f).step(r => pure([[f, unwrap(r)]]));
|
|
61
66
|
const { fromEntries } = Object;
|
|
67
|
+
/**
|
|
68
|
+
* Discovers all source files under `INIT_CWD` (or `.` if unset) that match
|
|
69
|
+
* `predicate`, imports them, and returns a map from relative path to module
|
|
70
|
+
* exports.
|
|
71
|
+
*
|
|
72
|
+
* The `predicate` is propagated into `allFiles` so that non-matching files
|
|
73
|
+
* are excluded before any `import()` is attempted — no wasted I/O.
|
|
74
|
+
* The default matches all JS/TS source files (`.js`, `.ts`, `.mts`, `.mjs`).
|
|
75
|
+
* `loadFile`'s own guards (`.f.js`, `.f.ts`, `shouldLoad`) still apply on
|
|
76
|
+
* top; the predicate only controls which files are discovered.
|
|
77
|
+
*
|
|
78
|
+
* The result is sorted by path key using `string.cmp` so the order is
|
|
79
|
+
* deterministic regardless of filesystem traversal order.
|
|
80
|
+
*/
|
|
62
81
|
export const loadModuleMap = (env) => {
|
|
63
82
|
const initCwd = env['INIT_CWD'];
|
|
64
83
|
const s = initCwd === undefined ? '.' : `${initCwd.replaceAll('\\', '/')}`;
|
|
@@ -67,24 +86,21 @@ export const loadModuleMap = (env) => {
|
|
|
67
86
|
// we should consider optimize them by ALIQ technique or something similar.
|
|
68
87
|
// For example, we should be able to write it like `allFiles(s).flatMap(loadFile)`,
|
|
69
88
|
// then an effect runner can batch all file loading operations together.
|
|
70
|
-
return allFiles(s)
|
|
89
|
+
return allFiles(s, shouldLoad)
|
|
71
90
|
.step(files => all(...files.map(loadFile)))
|
|
72
91
|
.step(entries => pure(fromEntries(entries
|
|
73
92
|
.flat()
|
|
74
93
|
.map(([k, v]) => [relativize(prefix, k), v])
|
|
75
|
-
.toSorted(
|
|
94
|
+
.toSorted(([a], [b]) => strCmp(a)(b)))));
|
|
76
95
|
};
|
|
77
96
|
const denoJson = './deno.json';
|
|
78
97
|
const parseDenoJson = rttiParse(record(rttiUnknown));
|
|
79
|
-
const index2 =
|
|
80
|
-
.step(() => updateVersion)
|
|
98
|
+
const index2 = updateVersion
|
|
81
99
|
.step(() => readFile(denoJson))
|
|
82
100
|
.step(v => pure(unwrap(parseDenoJson(jsonParse(utf8ToString(unwrap(v)))))));
|
|
83
|
-
const allFiles2aa =
|
|
84
|
-
.step(() => allFiles('.'))
|
|
101
|
+
const allFiles2aa = allFiles('.', v => v.endsWith('/module.f.ts') || v.endsWith('/module.ts'))
|
|
85
102
|
.step(files => {
|
|
86
|
-
const
|
|
87
|
-
const exportsA = list.map(v => [v, `./${v.substring(2)}`]);
|
|
103
|
+
const exportsA = files.map(v => [v, `./${v.substring(2)}`]);
|
|
88
104
|
return pure(Object.fromEntries(exportsA));
|
|
89
105
|
});
|
|
90
106
|
const index3 = both(index2)(allFiles2aa)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const proof: {
|
|
2
|
+
shouldPass: () => {
|
|
3
|
+
then: () => undefined;
|
|
4
|
+
};
|
|
2
5
|
ctor: () => void;
|
|
3
6
|
ctorEmpty: () => void;
|
|
4
7
|
ctorUndefined: () => void;
|
|
@@ -6,5 +9,5 @@ declare const _default: {
|
|
|
6
9
|
properties: () => void;
|
|
7
10
|
getOwnPropertyDescriptor: () => void;
|
|
8
11
|
throw: () => void;
|
|
12
|
+
env: () => void;
|
|
9
13
|
};
|
|
10
|
-
export default _default;
|