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
|
@@ -2,7 +2,7 @@ import { countRefs, stringify, stringifyAsTree } from "./module.f.js";
|
|
|
2
2
|
import { sort } from "../../types/object/module.f.js";
|
|
3
3
|
import { identity } from "../../types/function/module.f.js";
|
|
4
4
|
import { setProperty } from "../../json/module.f.js";
|
|
5
|
-
export
|
|
5
|
+
export const proof = {
|
|
6
6
|
stringify: [
|
|
7
7
|
{
|
|
8
8
|
testPrimitives: () => {
|
|
@@ -12,15 +12,15 @@ export default {
|
|
|
12
12
|
throw refs.size;
|
|
13
13
|
}
|
|
14
14
|
const refsBigInt = stringifyAsTree(sort)(refs.get(3n));
|
|
15
|
-
if (refsBigInt !== '[0,1
|
|
15
|
+
if (refsBigInt !== '[0,1]') {
|
|
16
16
|
throw refsBigInt;
|
|
17
17
|
}
|
|
18
18
|
const refsString = stringifyAsTree(sort)(refs.get("str"));
|
|
19
|
-
if (refsString !== '[1,1
|
|
19
|
+
if (refsString !== '[1,1]') {
|
|
20
20
|
throw refsString;
|
|
21
21
|
}
|
|
22
22
|
const refsRoot = stringifyAsTree(sort)(refs.get(djs));
|
|
23
|
-
if (refsRoot !== '[2,1
|
|
23
|
+
if (refsRoot !== '[2,1]') {
|
|
24
24
|
throw refsRoot;
|
|
25
25
|
}
|
|
26
26
|
if (refs.get(null) !== undefined) {
|
|
@@ -35,11 +35,11 @@ export default {
|
|
|
35
35
|
throw refs.size;
|
|
36
36
|
}
|
|
37
37
|
const refsArray = stringifyAsTree(sort)(refs.get(array));
|
|
38
|
-
if (refsArray !== '[0,3
|
|
38
|
+
if (refsArray !== '[0,3]') {
|
|
39
39
|
throw refsArray;
|
|
40
40
|
}
|
|
41
41
|
const refsRoot = stringifyAsTree(sort)(refs.get(djs));
|
|
42
|
-
if (refsRoot !== '[1,1
|
|
42
|
+
if (refsRoot !== '[1,1]') {
|
|
43
43
|
throw refsRoot;
|
|
44
44
|
}
|
|
45
45
|
},
|
|
@@ -51,11 +51,11 @@ export default {
|
|
|
51
51
|
throw refs.size;
|
|
52
52
|
}
|
|
53
53
|
const refsObj = stringifyAsTree(sort)(refs.get(obj));
|
|
54
|
-
if (refsObj !== '[0,2
|
|
54
|
+
if (refsObj !== '[0,2]') {
|
|
55
55
|
throw refsObj;
|
|
56
56
|
}
|
|
57
57
|
const refsRoot = stringifyAsTree(sort)(refs.get(djs));
|
|
58
|
-
if (refsRoot !== '[1,1
|
|
58
|
+
if (refsRoot !== '[1,1]') {
|
|
59
59
|
throw refsRoot;
|
|
60
60
|
}
|
|
61
61
|
},
|
|
@@ -7,7 +7,7 @@ const tokenizeString = s => toArray(map(withoutMetada)(tokenize(stringToList(s))
|
|
|
7
7
|
const tokenizeStringWithMetadata = s => toArray(tokenize(stringToList(s))(''));
|
|
8
8
|
const stringify = stringifyAsTree(sort);
|
|
9
9
|
const withoutMetada = tokenWithMetada => { return tokenWithMetada.token; };
|
|
10
|
-
export
|
|
10
|
+
export const proof = {
|
|
11
11
|
djs: [
|
|
12
12
|
() => {
|
|
13
13
|
const result = stringify(tokenizeString(''));
|
|
@@ -108,7 +108,7 @@ const getTokensFromAstRule = ast => {
|
|
|
108
108
|
return [token];
|
|
109
109
|
return { first: token, tail: getTokensFromAstSequence(ast.sequence) };
|
|
110
110
|
};
|
|
111
|
-
export
|
|
111
|
+
export const proof = {
|
|
112
112
|
isValid: [() => {
|
|
113
113
|
const m = descentParser(jsGrammar());
|
|
114
114
|
const expect = (s, expected) => {
|
|
@@ -10,12 +10,27 @@ import { type OrderedMap } from '../../types/ordered_map/module.f.ts';
|
|
|
10
10
|
import { type ParseError } from '../parser/module.f.ts';
|
|
11
11
|
import { type Effect } from '../../types/effects/module.f.ts';
|
|
12
12
|
import { type ReadFile } from '../../types/effects/node/module.f.ts';
|
|
13
|
+
/**
|
|
14
|
+
* State threaded through the recursive transpilation of a DJS module graph.
|
|
15
|
+
*
|
|
16
|
+
* - `complete`: modules that have been fully parsed and evaluated, keyed by path.
|
|
17
|
+
* - `stack`: import chain currently being resolved (used to detect circular dependencies).
|
|
18
|
+
* - `error`: the first parse error encountered, or `null` while everything is clean.
|
|
19
|
+
*/
|
|
13
20
|
export type ParseContext = {
|
|
14
21
|
readonly complete: OrderedMap<djsResult>;
|
|
15
22
|
readonly stack: List<string>;
|
|
16
23
|
readonly error: ParseError | null;
|
|
17
24
|
};
|
|
25
|
+
/** The evaluated DJS value produced for one successfully transpiled module. */
|
|
18
26
|
export type djsResult = {
|
|
19
27
|
djs: Unknown;
|
|
20
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Transpiles a DJS module graph rooted at `path` into a single `Unknown` value.
|
|
31
|
+
*
|
|
32
|
+
* Reads each file via the `ReadFile` effect, resolves imports recursively, and
|
|
33
|
+
* evaluates the AST. Returns `['ok', value]` on success, or `['error', ParseError]`
|
|
34
|
+
* on a parse failure or circular dependency.
|
|
35
|
+
*/
|
|
21
36
|
export declare const transpile: (path: string) => Effect<ReadFile, Result<Unknown, ParseError>>;
|
|
@@ -12,7 +12,7 @@ import { stringToList } from "../../text/utf16/module.f.js";
|
|
|
12
12
|
import { concat as pathConcat } from "../../path/module.f.js";
|
|
13
13
|
import { parseFromTokens } from "../parser/module.f.js";
|
|
14
14
|
import { run } from "../ast/module.f.js";
|
|
15
|
-
import { pure } from "../../types/effects/module.f.js";
|
|
15
|
+
import { foldStep, pure } from "../../types/effects/module.f.js";
|
|
16
16
|
import { readFile } from "../../types/effects/node/module.f.js";
|
|
17
17
|
import { utf8ToString } from "../../text/module.f.js";
|
|
18
18
|
const mapDjs = context => path => {
|
|
@@ -35,7 +35,8 @@ const transpileWithImports = path => parseModuleResult => context => {
|
|
|
35
35
|
const pathsCombine = listMap(pathConcat(dir))(parseModuleResult[1][0]);
|
|
36
36
|
const pathsArray = toArray(pathsCombine);
|
|
37
37
|
const contextWithStack = { ...context, stack: { first: path, tail: context.stack } };
|
|
38
|
-
return
|
|
38
|
+
return foldStep(foldNextModuleOp)(contextWithStack)(pathsArray)
|
|
39
|
+
.step(contextWithImports => {
|
|
39
40
|
if (contextWithImports.error !== null) {
|
|
40
41
|
return pure(contextWithImports);
|
|
41
42
|
}
|
|
@@ -62,6 +63,13 @@ const foldNextModuleOp = path => context => {
|
|
|
62
63
|
}
|
|
63
64
|
return parseModule(path).step(parseModuleResult => transpileWithImports(path)(parseModuleResult)(context));
|
|
64
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Transpiles a DJS module graph rooted at `path` into a single `Unknown` value.
|
|
68
|
+
*
|
|
69
|
+
* Reads each file via the `ReadFile` effect, resolves imports recursively, and
|
|
70
|
+
* evaluates the AST. Returns `['ok', value]` on success, or `['error', ParseError]`
|
|
71
|
+
* on a parse failure or circular dependency.
|
|
72
|
+
*/
|
|
65
73
|
export const transpile = path => foldNextModuleOp(path)({ stack: null, complete: null, error: null }).step((context) => {
|
|
66
74
|
if (context.error !== null) {
|
|
67
75
|
return pure(error(context.error));
|
|
@@ -7,7 +7,7 @@ const run = (root) => (path) => {
|
|
|
7
7
|
const [_, result] = virtual({ ...emptyState, root })(transpile(path));
|
|
8
8
|
return result;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export const proof = {
|
|
11
11
|
parse: () => {
|
|
12
12
|
const result = run({ a: utf8('export default 1') })('a');
|
|
13
13
|
if (result[0] === 'error') {
|
|
@@ -11,7 +11,7 @@ const fn = (f, name) => ({ [name]: f }[name]);
|
|
|
11
11
|
const withName = (name) =>
|
|
12
12
|
// translated into one command: define a `function [name]() { return undefined }`
|
|
13
13
|
Object.getOwnPropertyDescriptor({ [name]: () => undefined }, name).value;
|
|
14
|
-
export
|
|
14
|
+
export const proof = {
|
|
15
15
|
a: () => {
|
|
16
16
|
const x = f('1');
|
|
17
17
|
if (x !== '["1"]') {
|
package/fs/io/module.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import { type Result } from '../types/result/module.f.ts';
|
|
|
4
4
|
export declare const asyncImport: (v: string) => Promise<Module>;
|
|
5
5
|
export declare const tryCatch: <T>(f: () => T) => Result<T, unknown>;
|
|
6
6
|
export declare const io: Io;
|
|
7
|
-
export type NodeRun = (p: NodeProgram) => Promise<
|
|
7
|
+
export type NodeRun = (p: NodeProgram) => Promise<never>;
|
|
8
8
|
declare const effectRun: NodeRun;
|
|
9
9
|
export default effectRun;
|
package/fs/io/module.f.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Effect } from '../types/effects/module.f.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type Headers, type Module, type NodeOp, type Env, type SandboxResult, type NodeProgram, type WriteConsoles, type TestContext, type Engine } from '../types/effects/node/module.f.ts';
|
|
3
3
|
import type { Vec } from '../types/bit_vec/module.f.ts';
|
|
4
4
|
import { type Result } from '../types/result/module.f.ts';
|
|
5
5
|
/**
|
|
@@ -74,7 +74,7 @@ export type Process = {
|
|
|
74
74
|
readonly stderr: Writable;
|
|
75
75
|
};
|
|
76
76
|
export type TryCatch = <T>(f: () => T) => Result<T, unknown>;
|
|
77
|
-
export type Sandbox = <T>(f: () => T) => SandboxResult<T
|
|
77
|
+
export type Sandbox = <T>(f: () => T) => Promise<SandboxResult<T>>;
|
|
78
78
|
export type Server = {
|
|
79
79
|
readonly listen: (port: number) => void;
|
|
80
80
|
};
|
|
@@ -116,6 +116,11 @@ export type Io = {
|
|
|
116
116
|
readonly now: () => number;
|
|
117
117
|
readonly sandbox: Sandbox;
|
|
118
118
|
readonly write: (stream: WriteConsoles, data: Vec) => Promise<void>;
|
|
119
|
+
readonly testContext: TestContext;
|
|
120
|
+
readonly bunTestContext: TestContext;
|
|
121
|
+
readonly playwrightTestContext: TestContext;
|
|
122
|
+
readonly engine: Engine;
|
|
123
|
+
readonly await: (p: unknown) => Promise<readonly [unknown]>;
|
|
119
124
|
};
|
|
120
125
|
export type App = (io: Io) => Promise<number>;
|
|
121
126
|
export type Run = (f: App) => Promise<never>;
|
|
@@ -125,5 +130,5 @@ export type Run = (f: App) => Promise<never>;
|
|
|
125
130
|
*/
|
|
126
131
|
export declare const run: (io: Io) => Run;
|
|
127
132
|
export type EffectToPromise = <T>(effect: Effect<NodeOp, T>) => Promise<T>;
|
|
128
|
-
export declare const fromIo: ({ fs: { promises: { mkdir, readFile, readdir, writeFile, rm, access } }, fetch, http: { createServer }, childProcess, asyncImport, now: ioNow, sandbox
|
|
133
|
+
export declare const fromIo: ({ fs: { promises: { mkdir, readFile, readdir, writeFile, rm, access } }, fetch, http: { createServer }, childProcess, asyncImport, now: ioNow, sandbox, write, await: awaitPromise, }: Io) => EffectToPromise;
|
|
129
134
|
export declare const runProgram: (io: Io) => (args: readonly string[]) => (program: NodeProgram) => Promise<number>;
|
package/fs/io/module.f.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { normalize } from "../path/module.f.js";
|
|
11
11
|
import {} from "../types/effects/module.f.js";
|
|
12
12
|
import { asyncRun } from "../types/effects/module.js";
|
|
13
|
+
import {} from "../types/effects/node/module.f.js";
|
|
13
14
|
import { asBase, asNominal } from "../types/nominal/module.f.js";
|
|
14
15
|
import { error, ok } from "../types/result/module.f.js";
|
|
15
16
|
import { fromVec, listToVec, toVec } from "../types/uint8array/module.f.js";
|
|
@@ -44,7 +45,7 @@ const collect = async (v) => {
|
|
|
44
45
|
}
|
|
45
46
|
return result;
|
|
46
47
|
};
|
|
47
|
-
export const fromIo = ({ fs: { promises: { mkdir, readFile, readdir, writeFile, rm, access } }, fetch, http: { createServer }, childProcess, asyncImport, now: ioNow, sandbox
|
|
48
|
+
export const fromIo = ({ fs: { promises: { mkdir, readFile, readdir, writeFile, rm, access } }, fetch, http: { createServer }, childProcess, asyncImport, now: ioNow, sandbox, write, await: awaitPromise, }) => {
|
|
48
49
|
const result = asyncRun({
|
|
49
50
|
all: async (...effects) => await Promise.all(effects.map(result)),
|
|
50
51
|
fetch: async (url) => tc(async () => {
|
|
@@ -94,20 +95,19 @@ export const fromIo = ({ fs: { promises: { mkdir, readFile, readdir, writeFile,
|
|
|
94
95
|
},
|
|
95
96
|
forever: () => new Promise(() => { }),
|
|
96
97
|
now: async () => ioNow(),
|
|
97
|
-
sandbox
|
|
98
|
-
|
|
98
|
+
sandbox,
|
|
99
|
+
await: awaitPromise,
|
|
100
|
+
write,
|
|
101
|
+
test: async (ctx, name, expectFailure, test) => ctx.test(name, { expectFailure }, async (t) => result(test(t))),
|
|
99
102
|
});
|
|
100
103
|
return result;
|
|
101
104
|
};
|
|
102
105
|
export const runProgram = (io) => {
|
|
103
|
-
const { process: { env, stdout, stderr } } = io;
|
|
106
|
+
const { process: { env, stdout, stderr }, testContext, bunTestContext, playwrightTestContext, engine } = io;
|
|
107
|
+
const std = { stdout, stderr };
|
|
104
108
|
const f = fromIo(io);
|
|
105
|
-
return
|
|
106
|
-
args,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
stdout: { isTTY: stdout.isTTY },
|
|
110
|
-
stderr: { isTTY: stderr.isTTY },
|
|
111
|
-
},
|
|
112
|
-
}));
|
|
109
|
+
return args => {
|
|
110
|
+
const options = { args, env, std, testContext, bunTestContext, playwrightTestContext, engine };
|
|
111
|
+
return program => f(program(options));
|
|
112
|
+
};
|
|
113
113
|
};
|
package/fs/io/module.js
CHANGED
|
@@ -12,9 +12,34 @@ import fs from 'node:fs';
|
|
|
12
12
|
import process from 'node:process';
|
|
13
13
|
import { concat } from "../path/module.f.js";
|
|
14
14
|
import { once } from 'node:events';
|
|
15
|
-
import {
|
|
15
|
+
import { runProgram } from "./module.f.js";
|
|
16
16
|
import { error, ok } from "../types/result/module.f.js";
|
|
17
17
|
import { fromVec } from "../types/uint8array/module.f.js";
|
|
18
|
+
import * as testContext from 'node:test';
|
|
19
|
+
const isPlaywright = 'PLAYWRIGHT_TEST' in (process?.env ?? {});
|
|
20
|
+
const pwTest = isPlaywright
|
|
21
|
+
? (await import('@playwright/test')).test
|
|
22
|
+
: undefined;
|
|
23
|
+
const inlineTest = async (name, { expectFailure }, fn) => {
|
|
24
|
+
if (expectFailure) {
|
|
25
|
+
try {
|
|
26
|
+
await fn(inlineContext);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`expected to throw: ${name}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
await fn(inlineContext);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const inlineContext = { test: inlineTest };
|
|
38
|
+
const wrapInlineTest = (register) => ({
|
|
39
|
+
test: (name, opts, fn) => register(name, () => inlineTest(name, opts, fn))
|
|
40
|
+
});
|
|
41
|
+
const bunTestContext = wrapInlineTest(testContext.test);
|
|
42
|
+
const playwrightTestContext = wrapInlineTest(pwTest);
|
|
18
43
|
const prefix = 'file:///';
|
|
19
44
|
const { now } = Date;
|
|
20
45
|
/** Maps `WriteConsoles` names to the corresponding Node.js writable streams. */
|
|
@@ -50,6 +75,7 @@ export const tryCatch = f => {
|
|
|
50
75
|
return error(e);
|
|
51
76
|
}
|
|
52
77
|
};
|
|
78
|
+
const awaitPromise = async (p) => [p instanceof Promise ? await p : p];
|
|
53
79
|
export const io = {
|
|
54
80
|
console,
|
|
55
81
|
fs,
|
|
@@ -73,14 +99,18 @@ export const io = {
|
|
|
73
99
|
http,
|
|
74
100
|
childProcess,
|
|
75
101
|
now,
|
|
76
|
-
sandbox: (f) => {
|
|
102
|
+
sandbox: async (f) => {
|
|
77
103
|
let result;
|
|
78
104
|
let after;
|
|
79
105
|
const before = performance.now();
|
|
80
106
|
try {
|
|
81
|
-
|
|
107
|
+
let p = f();
|
|
82
108
|
after = performance.now();
|
|
83
|
-
|
|
109
|
+
if (p instanceof Promise) {
|
|
110
|
+
p = await p;
|
|
111
|
+
after = performance.now();
|
|
112
|
+
}
|
|
113
|
+
result = ok(p);
|
|
84
114
|
}
|
|
85
115
|
catch (e) {
|
|
86
116
|
after = performance.now();
|
|
@@ -89,6 +119,14 @@ export const io = {
|
|
|
89
119
|
return { result, duration: after - before };
|
|
90
120
|
},
|
|
91
121
|
write: (stream, data) => writeAll(streams[stream], fromVec(data)),
|
|
122
|
+
await: awaitPromise,
|
|
123
|
+
testContext,
|
|
124
|
+
bunTestContext,
|
|
125
|
+
playwrightTestContext,
|
|
126
|
+
engine: isPlaywright ? 'playwright' : 'Bun' in globalThis ? 'bun' : 'node',
|
|
127
|
+
};
|
|
128
|
+
const effectRun = async (p) => {
|
|
129
|
+
const code = await runProgram(io)(io.process.argv.slice(2))(p);
|
|
130
|
+
return process.exit(code);
|
|
92
131
|
};
|
|
93
|
-
const effectRun = runProgram(io)(io.process.argv.slice(2));
|
|
94
132
|
export default effectRun;
|
|
@@ -7,7 +7,7 @@ const tokenizeString = s => toArray(map(withoutMetada)(tokenize(stringToList(s))
|
|
|
7
7
|
const tokenizeStringWithMetadata = s => toArray(tokenize(stringToList(s))(''));
|
|
8
8
|
const stringify = stringifyAsTree(sort);
|
|
9
9
|
const withoutMetada = tokenWithMetada => tokenWithMetada.token;
|
|
10
|
-
export
|
|
10
|
+
export const proof = {
|
|
11
11
|
djs: [
|
|
12
12
|
() => {
|
|
13
13
|
const result = stringify(tokenizeString(''));
|
|
@@ -6,7 +6,7 @@ import { sort } from "../../types/object/module.f.js";
|
|
|
6
6
|
import { stringToList } from "../../text/utf16/module.f.js";
|
|
7
7
|
const tokenizeString = s => toArray(tokenize(stringToList(s)));
|
|
8
8
|
const stringify = jsonStringify(sort);
|
|
9
|
-
export
|
|
9
|
+
export const proof = {
|
|
10
10
|
valid: [
|
|
11
11
|
() => {
|
|
12
12
|
const tokenList = tokenizeString('null');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setProperty, stringify } from "./module.f.js";
|
|
2
2
|
import { sort } from "../types/object/module.f.js";
|
|
3
3
|
import { identity } from "../types/function/module.f.js";
|
|
4
|
-
export
|
|
4
|
+
export const proof = {
|
|
5
5
|
setProperty: () => {
|
|
6
6
|
if (setProperty("Hello")([])({}) !== "Hello") {
|
|
7
7
|
throw 'error';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { arrayWrap, boolSerialize, numberSerialize, objectWrap, stringSerialize } from "./module.f.js";
|
|
2
2
|
import * as list from "../../types/list/module.f.js";
|
|
3
3
|
const { toArray } = list;
|
|
4
|
-
export
|
|
4
|
+
export const proof = {
|
|
5
5
|
arrayWrap: [
|
|
6
6
|
() => {
|
|
7
7
|
const result = JSON.stringify(toArray(arrayWrap(null)));
|
|
@@ -5,7 +5,7 @@ import { sort } from "../../types/object/module.f.js";
|
|
|
5
5
|
import { stringToList } from "../../text/utf16/module.f.js";
|
|
6
6
|
const tokenizeString = s => toArray(tokenize(stringToList(s)));
|
|
7
7
|
const stringify = stringifyAsTree(sort);
|
|
8
|
-
export
|
|
8
|
+
export const proof = {
|
|
9
9
|
json: [
|
|
10
10
|
() => {
|
|
11
11
|
const result = stringify(tokenizeString(''));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { concat, normalize, relativize } from "./module.f.js";
|
|
2
|
-
|
|
2
|
+
const normalizeTest = [
|
|
3
3
|
() => {
|
|
4
4
|
const norm = normalize("dir/file.json");
|
|
5
5
|
if (norm !== "dir/file.json") {
|
|
@@ -25,7 +25,7 @@ export const normalizeTest = [
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
];
|
|
28
|
-
|
|
28
|
+
const concatTest = [
|
|
29
29
|
() => {
|
|
30
30
|
const c = concat("a")("b");
|
|
31
31
|
if (c !== "a/b") {
|
|
@@ -45,7 +45,7 @@ export const concatTest = [
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
];
|
|
48
|
-
|
|
48
|
+
const relativizeTest = [
|
|
49
49
|
() => {
|
|
50
50
|
const r = relativize('/repo', '/repo/fs/a.ts');
|
|
51
51
|
if (r !== './fs/a.ts') {
|
|
@@ -65,3 +65,4 @@ export const relativizeTest = [
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
];
|
|
68
|
+
export const proof = { normalizeTest, concatTest, relativizeTest };
|
package/fs/sul/id/module.f.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module
|
|
7
7
|
*/
|
|
8
8
|
import { toArray } from "../../types/list/module.f.js";
|
|
9
|
-
import { length,
|
|
9
|
+
import { length, msb, uint, uintChunkList, unpack, vec } from "../../types/bit_vec/module.f.js";
|
|
10
10
|
import { assertEq } from "../../dev/module.f.js";
|
|
11
11
|
import { utf8 } from "../../text/module.f.js";
|
|
12
12
|
import { secp256r1 } from "../../crypto/secp/module.f.js";
|
|
@@ -77,9 +77,8 @@ export const isHash = (v) => asBase(v) >> hashPrefixOffset === 1n;
|
|
|
77
77
|
export const hashId = (hash) => asNominal(hashPrefix | hash);
|
|
78
78
|
const hash2 = base32.compress(iv);
|
|
79
79
|
const vecX20 = vec(0x20n);
|
|
80
|
-
const
|
|
81
|
-
const hashMerge = (a, b) => hashId(uint(
|
|
82
|
-
const { concat } = msb;
|
|
80
|
+
const { concat, listToVec } = msb;
|
|
81
|
+
const hashMerge = (a, b) => hashId(uint(listToVec(hash2((asBase(a) << 0x100n) | asBase(b)).map(vecX20))));
|
|
83
82
|
export const compress = (a, b) => {
|
|
84
83
|
if (isHash(a) || isHash(b)) {
|
|
85
84
|
return hashMerge(a, b);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const proof: {
|
|
2
2
|
inline_00_00: () => void;
|
|
3
3
|
inline_00_01: () => void;
|
|
4
4
|
inline_01_00: () => void;
|
|
@@ -18,4 +18,3 @@ declare const _default: {
|
|
|
18
18
|
hash_merge_b_sensitivity: () => void;
|
|
19
19
|
hash_merge_shift: () => void;
|
|
20
20
|
};
|
|
21
|
-
export default _default;
|
|
@@ -15,7 +15,7 @@ const hFE = hashId(mask(0xffn) - 1n);
|
|
|
15
15
|
assertEq(asBase(level3Id(0n)), 0n);
|
|
16
16
|
assertEq(asBase(hashId(0n)), 1n << 0xffn);
|
|
17
17
|
assertEq(asBase(hFF), mask(0x100n));
|
|
18
|
-
export
|
|
18
|
+
export const proof = {
|
|
19
19
|
// Two level-3 literals whose combined bit vectors fit inline (≤ 253 bits)
|
|
20
20
|
inline_00_00: () => assertEq(compress(level3Id(0x00n), level3Id(0x00n)), rawId(vec(16n)(0x0000n))),
|
|
21
21
|
inline_00_01: () => assertEq(compress(level3Id(0x00n), level3Id(0x01n)), rawId(vec(16n)(0x0001n))),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
export declare const proof: {
|
|
2
2
|
min_equal: () => void;
|
|
3
3
|
min_greater: () => void;
|
|
4
4
|
intermediate_undefined: () => void;
|
|
@@ -11,4 +11,3 @@ declare const _default: {
|
|
|
11
11
|
isSymbol_terminal_only: () => void;
|
|
12
12
|
isSymbol_min_word: () => void;
|
|
13
13
|
};
|
|
14
|
-
export default _default;
|