functionalscript 0.17.0 → 0.19.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.js +11 -12
- package/fs/ci/common/module.f.d.ts +4 -5
- package/fs/ci/common/module.f.js +4 -4
- package/fs/ci/config/module.f.d.ts +5 -5
- package/fs/ci/config/module.f.js +5 -5
- package/fs/ci/test.f.js +2 -4
- package/fs/crypto/sign/module.f.js +3 -3
- package/fs/dev/module.f.d.ts +3 -3
- package/fs/dev/module.f.js +12 -9
- package/fs/dev/tf/module.d.ts +1 -1
- package/fs/dev/tf/module.f.d.ts +76 -7
- package/fs/dev/tf/module.f.js +166 -87
- package/fs/dev/tf/module.js +3 -53
- package/fs/dev/tf/scenarios/all.d.ts +1 -0
- package/fs/dev/tf/scenarios/all.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/throw.pass.f.d.ts +6 -0
- package/fs/dev/tf/scenarios/throw.pass.f.js +3 -0
- package/fs/dev/tf/test.f.d.ts +21 -20
- package/fs/dev/tf/test.f.js +254 -31
- package/fs/djs/module.f.d.ts +2 -2
- package/fs/djs/module.f.js +8 -5
- package/fs/djs/test.f.js +5 -6
- package/fs/djs/tokenizer-new/test.f.js +126 -78
- package/fs/djs/transpiler/module.f.js +2 -2
- package/fs/djs/transpiler/test.f.js +11 -12
- package/fs/fjs/module.f.d.ts +2 -7
- package/fs/fjs/module.f.js +16 -22
- package/fs/fjs/module.js +2 -2
- package/fs/io/module.d.ts +3 -3
- package/fs/io/module.f.d.ts +9 -2
- package/fs/io/module.f.js +13 -3
- package/fs/io/module.js +68 -17
- package/fs/path/module.f.d.ts +6 -0
- package/fs/path/module.f.js +6 -0
- package/fs/path/test.f.d.ts +3 -5
- package/fs/path/test.f.js +67 -49
- package/fs/sul/id/module.f.js +3 -4
- package/fs/sul/level/literal/module.f.js +3 -3
- package/fs/text/sgr/module.f.d.ts +9 -1
- package/fs/text/sgr/module.f.js +16 -5
- package/fs/text/sgr/test.f.js +16 -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/btree/remove/module.f.d.ts +1 -1
- package/fs/types/btree/remove/module.f.js +7 -2
- 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/types/module.f.d.ts +1 -0
- package/fs/types/btree/types/module.f.js +1 -1
- package/fs/types/effects/node/module.f.d.ts +30 -17
- package/fs/types/effects/node/module.f.js +21 -2
- package/fs/types/effects/node/test.f.js +8 -5
- package/fs/types/effects/node/virtual/module.f.d.ts +12 -2
- package/fs/types/effects/node/virtual/module.f.js +31 -17
- package/fs/types/function/compare/module.f.d.ts +12 -0
- package/fs/types/function/compare/module.f.js +33 -0
- package/fs/types/function/operator/test.f.d.ts +10 -0
- package/fs/types/function/operator/test.f.js +81 -0
- package/fs/types/nullable/test.f.js +10 -1
- package/fs/types/range_map/module.f.js +3 -18
- package/fs/types/result/module.f.d.ts +4 -0
- package/fs/types/result/module.f.js +4 -0
- package/fs/types/result/test.f.d.ts +2 -4
- package/fs/types/result/test.f.js +24 -16
- package/fs/types/rtti/common/module.f.d.ts +10 -1
- package/fs/types/rtti/common/module.f.js +7 -2
- package/fs/types/rtti/parse/module.f.js +35 -46
- package/fs/types/rtti/validate/module.f.js +9 -12
- package/fs/types/sorted_list/module.f.d.ts +1 -2
- package/fs/types/sorted_list/module.f.js +8 -21
- package/fs/types/sorted_set/module.f.d.ts +1 -3
- package/fs/types/ts/test.f.d.ts +18 -0
- package/fs/types/ts/test.f.js +111 -0
- package/fs/types/uint8array/module.f.js +7 -1
- package/fs/types/uint8array/test.f.d.ts +1 -0
- package/fs/types/uint8array/test.f.js +5 -1
- package/package.json +4 -4
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. */
|
package/fs/asn.1/test.f.js
CHANGED
|
@@ -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]);
|
|
@@ -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)}`;
|
|
@@ -12,12 +12,12 @@ export type Os = typeof os[number];
|
|
|
12
12
|
export declare const architecture: readonly ["intel", "arm"];
|
|
13
13
|
export type Architecture = typeof architecture[number];
|
|
14
14
|
export type Image = typeof images[Os][Architecture];
|
|
15
|
-
declare const stepSchema: {
|
|
15
|
+
export declare const stepSchema: {
|
|
16
16
|
readonly run: import("../../types/rtti/module.f.ts").Or<readonly [import("../../types/rtti/module.f.ts").String, undefined]>;
|
|
17
17
|
readonly uses: import("../../types/rtti/module.f.ts").Or<readonly [import("../../types/rtti/module.f.ts").String, undefined]>;
|
|
18
18
|
readonly with: import("../../types/rtti/module.f.ts").Or<readonly [import("../../types/rtti/module.f.ts").Type1<"record", import("../../types/rtti/module.f.ts").String>, undefined]>;
|
|
19
19
|
};
|
|
20
|
-
declare const jobSchema: {
|
|
20
|
+
export declare const jobSchema: {
|
|
21
21
|
readonly 'runs-on': import("../../types/rtti/module.f.ts").String;
|
|
22
22
|
readonly steps: import("../../types/rtti/module.f.ts").Type1<"array", {
|
|
23
23
|
readonly run: import("../../types/rtti/module.f.ts").Or<readonly [import("../../types/rtti/module.f.ts").String, undefined]>;
|
|
@@ -25,7 +25,7 @@ declare const jobSchema: {
|
|
|
25
25
|
readonly with: import("../../types/rtti/module.f.ts").Or<readonly [import("../../types/rtti/module.f.ts").Type1<"record", import("../../types/rtti/module.f.ts").String>, undefined]>;
|
|
26
26
|
}>;
|
|
27
27
|
};
|
|
28
|
-
declare const jobsSchema: import("../../types/rtti/module.f.ts").Type1<"record", {
|
|
28
|
+
export declare const jobsSchema: import("../../types/rtti/module.f.ts").Type1<"record", {
|
|
29
29
|
readonly 'runs-on': import("../../types/rtti/module.f.ts").String;
|
|
30
30
|
readonly steps: import("../../types/rtti/module.f.ts").Type1<"array", {
|
|
31
31
|
readonly run: import("../../types/rtti/module.f.ts").Or<readonly [import("../../types/rtti/module.f.ts").String, undefined]>;
|
|
@@ -33,7 +33,7 @@ declare const jobsSchema: import("../../types/rtti/module.f.ts").Type1<"record",
|
|
|
33
33
|
readonly with: import("../../types/rtti/module.f.ts").Or<readonly [import("../../types/rtti/module.f.ts").Type1<"record", import("../../types/rtti/module.f.ts").String>, undefined]>;
|
|
34
34
|
}>;
|
|
35
35
|
}>;
|
|
36
|
-
declare const gitHubActionSchema: {
|
|
36
|
+
export declare const gitHubActionSchema: {
|
|
37
37
|
readonly name: import("../../types/rtti/module.f.ts").String;
|
|
38
38
|
readonly on: {
|
|
39
39
|
readonly pull_request: import("../../types/rtti/module.f.ts").Or<readonly [{}, undefined]>;
|
|
@@ -82,4 +82,3 @@ export declare const clean: (steps: readonly MetaStep[]) => readonly MetaStep[];
|
|
|
82
82
|
export declare const toSteps: (m: readonly MetaStep[]) => readonly Step[];
|
|
83
83
|
export declare const ubuntu: (ms: readonly MetaStep[]) => Job;
|
|
84
84
|
export declare const findTgz: (v: Os) => "(Get-ChildItem *.tgz).FullName" | "./*.tgz";
|
|
85
|
-
export {};
|
package/fs/ci/common/module.f.js
CHANGED
|
@@ -11,17 +11,17 @@ import {} from "../../types/rtti/ts/module.f.js";
|
|
|
11
11
|
import { parse as rttiParse } from "../../types/rtti/parse/module.f.js";
|
|
12
12
|
export const os = ['ubuntu', 'macos', 'windows'];
|
|
13
13
|
export const architecture = ['intel', 'arm'];
|
|
14
|
-
const stepSchema = {
|
|
14
|
+
export const stepSchema = {
|
|
15
15
|
run: option(string),
|
|
16
16
|
uses: option(string),
|
|
17
17
|
with: option(record(string))
|
|
18
18
|
};
|
|
19
|
-
const jobSchema = {
|
|
19
|
+
export const jobSchema = {
|
|
20
20
|
'runs-on': string,
|
|
21
21
|
steps: array(stepSchema)
|
|
22
22
|
};
|
|
23
|
-
const jobsSchema = record(jobSchema);
|
|
24
|
-
const gitHubActionSchema = {
|
|
23
|
+
export const jobsSchema = record(jobSchema);
|
|
24
|
+
export const gitHubActionSchema = {
|
|
25
25
|
name: string,
|
|
26
26
|
on: { pull_request: option({}) },
|
|
27
27
|
jobs: jobsSchema
|
|
@@ -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.
|
|
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
|
-
readonly default: "26.
|
|
28
|
-
readonly others: readonly ["
|
|
27
|
+
readonly default: "26.2.0";
|
|
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,19 +23,19 @@ 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.
|
|
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/
|
|
30
30
|
export const rust = '1.95.0';
|
|
31
31
|
// https://nodejs.org/en/download
|
|
32
32
|
export const node = {
|
|
33
|
-
default: '26.
|
|
34
|
-
others: ['
|
|
33
|
+
default: '26.2.0',
|
|
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/test.f.js
CHANGED
|
@@ -4,10 +4,8 @@ import { isVec } from "../types/bit_vec/module.f.js";
|
|
|
4
4
|
import { test, parseGitHubAction } from "./common/module.f.js";
|
|
5
5
|
import { assert } from "../dev/module.f.js";
|
|
6
6
|
import { emptyState, virtual } from "../types/effects/node/virtual/module.f.js";
|
|
7
|
-
import {} from "../types/rtti/ts/module.f.js";
|
|
8
7
|
import { parse as jsonParse } from "../json/module.f.js";
|
|
9
8
|
import { unwrap } from "../types/result/module.f.js";
|
|
10
|
-
// type Gha = Ts<typeof gitHubActionSchema>
|
|
11
9
|
const hasRun = (cmd) => (gha) => Object.values(gha.jobs).some(job => job.steps.some(step => step.run?.includes(cmd)));
|
|
12
10
|
const hasRunInJob = (jobId, cmd) => (gha) => gha.jobs[jobId]?.steps.some(step => step.run?.includes(cmd)) ?? false;
|
|
13
11
|
const githubState = {
|
|
@@ -18,9 +16,9 @@ const run = (rust, nodeExtra = () => []) => {
|
|
|
18
16
|
const [state, result] = virtual(githubState)(ci({ rust, nodeExtra, denoExtra: [], bunExtra: [] }));
|
|
19
17
|
assert(result === 0, result);
|
|
20
18
|
const dotGithub = state.root['.github'];
|
|
21
|
-
assert(dotGithub
|
|
19
|
+
assert(typeof dotGithub === 'object', dotGithub);
|
|
22
20
|
const workflows = dotGithub['workflows'];
|
|
23
|
-
assert(workflows
|
|
21
|
+
assert(typeof workflows === 'object', workflows);
|
|
24
22
|
const file = workflows['ci.yml'];
|
|
25
23
|
assert(isVec(file), file);
|
|
26
24
|
return unwrap(parseGitHubAction(jsonParse(utf8ToString(file))));
|
|
@@ -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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import type { Io } from '../io/module.f.ts';
|
|
7
7
|
import { type Access, type All, type Env, type Import, type NodeProgram, type Readdir } from '../types/effects/node/module.f.ts';
|
|
8
8
|
import { type Effect } from '../types/effects/module.f.ts';
|
|
9
9
|
export declare const todo: () => never;
|
|
@@ -18,6 +18,6 @@ export type ModuleMap = {
|
|
|
18
18
|
};
|
|
19
19
|
export declare const env: (io: Io) => (v: string) => string | undefined;
|
|
20
20
|
export declare const allFiles: (s: string) => Effect<Readdir | All, readonly string[]>;
|
|
21
|
-
export
|
|
22
|
-
export declare const loadModuleMap: (
|
|
21
|
+
export type LoadModuleOperations = Access | Import | All | Readdir;
|
|
22
|
+
export declare const loadModuleMap: (env: Env) => Effect<LoadModuleOperations, ModuleMap>;
|
|
23
23
|
export declare const index4: NodeProgram;
|
package/fs/dev/module.f.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Development utilities for indexing modules and loading FunctionalScript files.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { fromIo } from "../io/module.f.js";
|
|
7
1
|
import { updateVersion } from "./version/module.f.js";
|
|
8
2
|
import { access, all, both, import_, readdir, readFile, writeFile } from "../types/effects/node/module.f.js";
|
|
9
3
|
import { utf8, utf8ToString } from "../text/module.f.js";
|
|
@@ -12,6 +6,7 @@ import { begin, pure } from "../types/effects/module.f.js";
|
|
|
12
6
|
import { parse as jsonParse } from "../json/module.f.js";
|
|
13
7
|
import { record, unknown as rttiUnknown } from "../types/rtti/module.f.js";
|
|
14
8
|
import { parse as rttiParse } from "../types/rtti/parse/module.f.js";
|
|
9
|
+
import { relativize } from "../path/module.f.js";
|
|
15
10
|
export const todo = () => { throw 'not implemented'; };
|
|
16
11
|
export const assert = (v, msg = 'assertion failed') => {
|
|
17
12
|
if (!v)
|
|
@@ -63,14 +58,22 @@ const loadFile = (f) => {
|
|
|
63
58
|
}
|
|
64
59
|
return pure([]);
|
|
65
60
|
};
|
|
66
|
-
|
|
61
|
+
const { fromEntries } = Object;
|
|
62
|
+
export const loadModuleMap = (env) => {
|
|
67
63
|
const initCwd = env['INIT_CWD'];
|
|
68
64
|
const s = initCwd === undefined ? '.' : `${initCwd.replaceAll('\\', '/')}`;
|
|
65
|
+
const prefix = s === '.' ? '' : s;
|
|
66
|
+
// TODO: there are multiple `all` effects here,
|
|
67
|
+
// we should consider optimize them by ALIQ technique or something similar.
|
|
68
|
+
// For example, we should be able to write it like `allFiles(s).flatMap(loadFile)`,
|
|
69
|
+
// then an effect runner can batch all file loading operations together.
|
|
69
70
|
return allFiles(s)
|
|
70
71
|
.step(files => all(...files.map(loadFile)))
|
|
71
|
-
.step(entries => pure(
|
|
72
|
+
.step(entries => pure(fromEntries(entries
|
|
73
|
+
.flat()
|
|
74
|
+
.map(([k, v]) => [relativize(prefix, k), v])
|
|
75
|
+
.toSorted(cmp))));
|
|
72
76
|
};
|
|
73
|
-
export const loadModuleMap = async (io) => fromIo(io)(loadModuleMap2(io.process.env));
|
|
74
77
|
const denoJson = './deno.json';
|
|
75
78
|
const parseDenoJson = rttiParse(record(rttiUnknown));
|
|
76
79
|
const index2 = begin
|
package/fs/dev/tf/module.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const run: () => Promise<
|
|
1
|
+
export declare const run: () => Promise<number>;
|
package/fs/dev/tf/module.f.d.ts
CHANGED
|
@@ -1,8 +1,77 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type All, type NodeProgram, type NodeProgramOptions, type Program, type Sandbox, type SandboxResult, type Test, type TestContext, type Write } from '../../types/effects/node/module.f.ts';
|
|
2
|
+
import { type Effect, type Operation } from '../../types/effects/module.f.ts';
|
|
3
|
+
import { type LoadModuleOperations, type ModuleMap } from '../module.f.ts';
|
|
3
4
|
export declare const isTest: (s: string) => boolean;
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export type TestFn = () => unknown;
|
|
6
|
+
export type TestEntry = {
|
|
7
|
+
readonly fn: TestFn;
|
|
8
|
+
readonly throws: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type TestSet = TestEntry | readonly (readonly [string, unknown])[];
|
|
11
|
+
export declare const parseTestSet: (throws: boolean, x: unknown) => TestSet;
|
|
12
|
+
type TestAndPath = readonly [Path, TestEntry];
|
|
13
|
+
/**
|
|
14
|
+
* Recursively collects all leaf tests reachable from `v` as `[path, entry]`
|
|
15
|
+
* pairs, without running anything. Return-value sub-trees are not walked
|
|
16
|
+
* (that requires execution); only the static object/array/function structure
|
|
17
|
+
* is traversed.
|
|
18
|
+
*/
|
|
19
|
+
export declare const collectTests: (path: Path, throws: boolean, v: unknown) => readonly TestAndPath[];
|
|
20
|
+
/**
|
|
21
|
+
* Receives semantic test-run events. Each method is the runner's notification
|
|
22
|
+
* of an event; the reporter decides how to render it (terminal, GitHub
|
|
23
|
+
* annotations, JSON, node `--test`, etc.). `path` is the chain of object keys
|
|
24
|
+
* leading to the current location; `null` marks a function-call boundary, e.g.
|
|
25
|
+
* `['outer', null, 'inner']` means `outer` was invoked and its return value
|
|
26
|
+
* contained `inner`.
|
|
27
|
+
*/
|
|
28
|
+
export type Reporter<O extends Operation> = {
|
|
29
|
+
readonly result: (file: string, path: Path, r: SandboxResult<unknown>) => Effect<O, void>;
|
|
30
|
+
readonly summary: (pass: number, fail: number, time: number) => Effect<O, void>;
|
|
31
|
+
readonly test: (file: string, path: Path, set: TestEntry) => Effect<O, SandboxResult<unknown>>;
|
|
32
|
+
};
|
|
33
|
+
export declare const registerModule: (ctx: TestContext, k: string, v: unknown) => Effect<Test | All, void>;
|
|
34
|
+
export declare const runModuleMap: <O extends Operation>(reporter: Reporter<O>) => (moduleMap: ModuleMap) => Effect<O | All, number>;
|
|
35
|
+
export declare const testAll: <O extends Operation>(reporter: Reporter<O>) => Program<O | All | LoadModuleOperations>;
|
|
36
|
+
export declare const registerModuleMap: (ctx: TestContext, moduleMap: ModuleMap) => Effect<Test | All, void>;
|
|
37
|
+
export type Path = readonly (string | null)[];
|
|
38
|
+
export declare const isInteger: (s: string) => boolean;
|
|
39
|
+
export declare const isIdentifier: (s: string) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Renders a key chain as a JS property-access expression: identifier keys use
|
|
42
|
+
* dot notation, integer keys use `[N]`, other strings use `["key"]`, and `null`
|
|
43
|
+
* emits `()` to mark a function-call boundary.
|
|
44
|
+
* E.g. `['math', 'add']` → `.math.add`, `['outer', null, 'inner']` → `.outer().inner`.
|
|
45
|
+
*/
|
|
46
|
+
export declare const fmtPath: (path: Path) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Formats a fully-qualified test identifier as a JS-like expression, e.g.
|
|
49
|
+
* `import("./math.test.f.ts").add()` or `import("./a.test.f.ts").users[3].name()`.
|
|
50
|
+
* Self-contained per line — suitable for parallel output and as a CLI filter argument.
|
|
51
|
+
*/
|
|
52
|
+
export declare const fmtImport: (file: string, path: Path) => string;
|
|
53
|
+
/**
|
|
54
|
+
* Renders a key chain for terminal output: `| ` per level of depth, followed
|
|
55
|
+
* by the last segment formatted as a bare integer, a bare identifier, or a
|
|
56
|
+
* JSON-quoted string. E.g. `['math', 'add']` → `| | add`,
|
|
57
|
+
* `['a', '0']` → `| | 0`, `['x', 'hello world']` → `| | "hello world"`.
|
|
58
|
+
*/
|
|
59
|
+
export declare const fmtTerm: (path: Path) => string;
|
|
60
|
+
/**
|
|
61
|
+
* Percent-encodes characters that GitHub workflow-command property values
|
|
62
|
+
* treat as separators (`%`, `:`, `,`) plus newlines.
|
|
63
|
+
* https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
|
|
64
|
+
*/
|
|
65
|
+
export declare const ghEscape: (s: string) => string;
|
|
66
|
+
export declare const defaultTest: (file: string, path: Path, { fn, throws }: TestEntry) => Effect<Sandbox, SandboxResult<unknown>>;
|
|
67
|
+
/**
|
|
68
|
+
* The terminal/GitHub reporter used by `fjs t`. Output goes through
|
|
69
|
+
* `csiWrite`, so ANSI styles are stripped on non-TTY streams. When
|
|
70
|
+
* `GITHUB_ACTION` is set, failures are emitted as `::error` workflow
|
|
71
|
+
* annotations instead of colored lines. Exported as a factory so the
|
|
72
|
+
* GitHub format path can be exercised directly from tests.
|
|
73
|
+
*/
|
|
74
|
+
export declare const defaultReporter: (options: NodeProgramOptions) => Reporter<Write | Sandbox>;
|
|
75
|
+
export declare const main: NodeProgram;
|
|
76
|
+
export declare const register: NodeProgram;
|
|
77
|
+
export {};
|