functionalscript 0.9.2 → 0.10.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/bnf/data/test.f.d.ts +2 -0
- package/bnf/data/test.f.js +39 -2
- package/bnf/module.f.d.ts +3 -2
- package/bnf/module.f.js +5 -4
- package/cas/module.f.d.ts +5 -0
- package/cas/module.f.js +5 -0
- package/ci/module.f.js +45 -35
- package/ci/module.js +3 -3
- package/crypto/hmac/test.f.js +1 -1
- package/crypto/sign/module.f.d.ts +5 -0
- package/crypto/sign/test.f.js +1 -1
- package/dev/index/module.js +2 -2
- package/dev/module.f.d.ts +5 -0
- package/dev/module.f.js +5 -0
- package/dev/tf/all.test.js +2 -2
- package/dev/tf/module.f.js +7 -2
- package/dev/version/module.f.js +5 -0
- package/djs/ast/module.f.d.ts +5 -0
- package/djs/module.f.d.ts +5 -0
- package/djs/parser/module.f.d.ts +5 -0
- package/djs/parser/module.f.js +5 -0
- package/djs/parser-new/module.f.js +6 -2
- package/djs/parser-new/test.f.js +2 -1
- package/djs/serializer/module.f.d.ts +5 -0
- package/djs/transpiler/module.f.d.ts +5 -0
- package/djs/transpiler/module.f.js +5 -0
- package/fjs/module.f.d.ts +5 -0
- package/fjs/module.f.js +5 -0
- package/fjs/module.js +2 -2
- package/fsc/module.f.js +5 -0
- package/fsm/module.f.d.ts +5 -0
- package/fsm/module.f.js +5 -0
- package/io/module.d.ts +3 -3
- package/io/module.f.d.ts +1 -1
- package/io/module.f.js +8 -1
- package/io/module.js +8 -7
- package/io/virtual/module.f.d.ts +5 -0
- package/json/parser/module.f.d.ts +5 -0
- package/json/parser/module.f.js +5 -0
- package/json/serializer/module.f.d.ts +5 -0
- package/json/serializer/module.f.js +5 -0
- package/json/tokenizer/module.f.js +5 -0
- package/package.json +1 -1
- package/path/module.f.d.ts +5 -0
- package/text/utf8/module.f.d.ts +1 -1
- package/types/asn.1/module.f.d.ts +62 -0
- package/types/asn.1/module.f.js +276 -0
- package/types/asn.1/test.f.d.ts +44 -0
- package/types/asn.1/test.f.js +312 -0
- package/types/base128/module.f.d.ts +20 -0
- package/types/base128/module.f.js +43 -0
- package/types/base128/test.f.d.ts +2 -0
- package/types/base128/test.f.js +26 -0
- package/types/bigfloat/module.f.js +5 -0
- package/types/bit_vec/module.f.d.ts +14 -3
- package/types/bit_vec/module.f.js +21 -2
- package/types/bit_vec/test.f.d.ts +1 -0
- package/types/bit_vec/test.f.js +28 -6
- package/types/btree/find/module.f.d.ts +5 -0
- package/types/btree/module.f.d.ts +5 -0
- package/types/btree/module.f.js +5 -0
- package/types/btree/remove/module.f.d.ts +5 -0
- package/types/btree/set/module.f.d.ts +5 -0
- package/types/btree/types/module.f.d.ts +5 -0
- package/types/byte_set/module.f.js +5 -0
- package/types/cbase32/module.f.d.ts +5 -0
- package/types/cbase32/module.f.js +5 -0
- package/types/effect/mock/module.f.d.ts +5 -0
- package/types/effect/module.f.d.ts +5 -0
- package/types/effect/node/module.f.d.ts +5 -1
- package/types/effect/node/module.f.js +1 -0
- package/types/effect/node/test.f.d.ts +1 -0
- package/types/effect/node/test.f.js +19 -1
- package/types/effect/node/virtual/module.f.d.ts +3 -0
- package/types/effect/node/virtual/module.f.js +10 -0
- package/types/function/compare/module.f.d.ts +5 -0
- package/types/function/operator/module.f.d.ts +5 -0
- package/types/list/module.f.js +5 -0
- package/types/map/module.f.js +5 -0
- package/types/nibble_set/module.f.d.ts +5 -0
- package/types/nominal/module.f.d.ts +5 -0
- package/types/nullable/module.f.d.ts +5 -0
- package/types/ordered_map/module.f.d.ts +5 -0
- package/types/range/module.f.d.ts +5 -0
- package/types/sorted_list/module.f.d.ts +5 -0
- package/website/module.f.js +5 -0
- package/website/module.js +3 -3
package/bnf/data/test.f.d.ts
CHANGED
package/bnf/data/test.f.js
CHANGED
|
@@ -3,7 +3,7 @@ import { stringToCodePointList } from "../../text/utf16/module.f.js";
|
|
|
3
3
|
import { identity } from "../../types/function/module.f.js";
|
|
4
4
|
import { map, toArray } from "../../types/list/module.f.js";
|
|
5
5
|
import { sort } from "../../types/object/module.f.js";
|
|
6
|
-
import { join0Plus, option, range, repeat0Plus, set } from "../module.f.js";
|
|
6
|
+
import { join0Plus, oneEncode, option, range, rangeDecode, repeat0Plus, set } from "../module.f.js";
|
|
7
7
|
import { classic, deterministic } from "../testlib.f.js";
|
|
8
8
|
import { dispatchMap, parser, parserRuleSet, toData, createEmptyTagMap, descentParser } from "./module.f.js";
|
|
9
9
|
const mapCodePoint = (cp) => [cp, undefined];
|
|
@@ -12,6 +12,34 @@ const descentParserCpOnly = (m, name, cp) => {
|
|
|
12
12
|
return m(name, cpm);
|
|
13
13
|
};
|
|
14
14
|
export default {
|
|
15
|
+
rangeDecode: () => {
|
|
16
|
+
const decoded1 = stringify(sort)(rangeDecode(0x000079_000087));
|
|
17
|
+
if (decoded1 !== '[121,135]') {
|
|
18
|
+
throw decoded1;
|
|
19
|
+
}
|
|
20
|
+
const decoded2 = stringify(sort)(rangeDecode(0x000080_000087));
|
|
21
|
+
if (decoded2 !== '[128,135]') {
|
|
22
|
+
throw decoded2;
|
|
23
|
+
}
|
|
24
|
+
const decoded3 = stringify(sort)(rangeDecode(0x10FFFF_10FFFF));
|
|
25
|
+
if (decoded3 !== '[1114111,1114111]') {
|
|
26
|
+
throw decoded3;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
rangeEncode: () => {
|
|
30
|
+
const encoded1 = oneEncode(0x79);
|
|
31
|
+
if (encoded1 !== 0x000079_000079) {
|
|
32
|
+
throw encoded1;
|
|
33
|
+
}
|
|
34
|
+
const encoded2 = oneEncode(0x80);
|
|
35
|
+
if (encoded2 !== 0x000080_000080) {
|
|
36
|
+
throw encoded2;
|
|
37
|
+
}
|
|
38
|
+
const encoded3 = oneEncode(0x10FFFF);
|
|
39
|
+
if (encoded3 !== 0x10FFFF_10FFFF) {
|
|
40
|
+
throw encoded3;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
15
43
|
toData: [
|
|
16
44
|
() => {
|
|
17
45
|
const c = toData(classic());
|
|
@@ -281,7 +309,16 @@ export default {
|
|
|
281
309
|
}
|
|
282
310
|
},
|
|
283
311
|
() => {
|
|
284
|
-
const terminalRangeRule =
|
|
312
|
+
const terminalRangeRule = 0x000079_000087;
|
|
313
|
+
const m = parser(terminalRangeRule);
|
|
314
|
+
const mr = m("", [64]);
|
|
315
|
+
const result = JSON.stringify(mr);
|
|
316
|
+
if (result !== '[{"sequence":[]},false,[64]]') {
|
|
317
|
+
throw result;
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
() => {
|
|
321
|
+
const terminalRangeRule = 0x000080_000087; //broken range
|
|
285
322
|
const m = parser(terminalRangeRule);
|
|
286
323
|
const mr = m("", [64]);
|
|
287
324
|
const result = JSON.stringify(mr);
|
package/bnf/module.f.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import { type Array2 } from '../types/array/module.f.ts';
|
|
|
9
9
|
export type TerminalRange = number;
|
|
10
10
|
export declare const fullRange: TerminalRange;
|
|
11
11
|
export declare const unicodeRange: TerminalRange;
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const max: string;
|
|
13
|
+
export declare const unicodeMax: string;
|
|
13
14
|
/** A sequence of rules. */
|
|
14
15
|
export type Sequence = readonly Rule[];
|
|
15
16
|
/** A variant */
|
|
@@ -19,9 +20,9 @@ export type Variant = {
|
|
|
19
20
|
export type DataRule = Variant | Sequence | TerminalRange | string;
|
|
20
21
|
export type LazyRule = () => DataRule;
|
|
21
22
|
export type Rule = DataRule | LazyRule;
|
|
22
|
-
export declare const max: string;
|
|
23
23
|
export declare const rangeEncode: (a: number, b: number) => TerminalRange;
|
|
24
24
|
export declare const oneEncode: (a: number) => TerminalRange;
|
|
25
|
+
export declare const eof: TerminalRange;
|
|
25
26
|
export declare const rangeDecode: (r: number) => Array2<number>;
|
|
26
27
|
export declare const toSequence: (s: string) => readonly TerminalRange[];
|
|
27
28
|
export declare const str: (s: string) => readonly TerminalRange[] | TerminalRange;
|
package/bnf/module.f.js
CHANGED
|
@@ -3,7 +3,8 @@ import { isArray2 } from "../types/array/module.f.js";
|
|
|
3
3
|
import { map, toArray, repeat as listRepeat } from "../types/list/module.f.js";
|
|
4
4
|
export const fullRange = 0x000000_FFFFFF;
|
|
5
5
|
export const unicodeRange = 0x000000_10FFFF;
|
|
6
|
-
export const
|
|
6
|
+
export const max = codePointListToString([0xFFFFFF]);
|
|
7
|
+
export const unicodeMax = codePointListToString([0x10FFFF]);
|
|
7
8
|
// Internals:
|
|
8
9
|
const { fromEntries, values } = Object;
|
|
9
10
|
const { fromCodePoint } = String;
|
|
@@ -13,15 +14,15 @@ const { fromCodePoint } = String;
|
|
|
13
14
|
const offset = 24;
|
|
14
15
|
const mask = (1 << offset) - 1;
|
|
15
16
|
const isValid = (r) => r >= 0 && r <= mask;
|
|
16
|
-
export const max = codePointListToString([0x10FFFF]);
|
|
17
17
|
export const rangeEncode = (a, b) => {
|
|
18
18
|
if (!isValid(a) || !isValid(b) || a > b) {
|
|
19
19
|
throw `Invalid range ${a} ${b}.`;
|
|
20
20
|
}
|
|
21
|
-
return (a << offset) | b;
|
|
21
|
+
return Number((BigInt(a) << BigInt(offset)) | BigInt(b));
|
|
22
22
|
};
|
|
23
23
|
export const oneEncode = (a) => rangeEncode(a, a);
|
|
24
|
-
export const
|
|
24
|
+
export const eof = oneEncode(0x110000);
|
|
25
|
+
export const rangeDecode = (r) => [Number(BigInt(r) >> BigInt(offset)), Number(BigInt(r) & BigInt(mask))];
|
|
25
26
|
const mapOneEncode = map(oneEncode);
|
|
26
27
|
export const toSequence = (s) => toArray(mapOneEncode(stringToCodePointList(s)));
|
|
27
28
|
export const str = (s) => {
|
package/cas/module.f.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-addressable storage utilities for hashing, addressing, and path parsing.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { type Sha2 } from "../crypto/sha2/module.f.ts";
|
|
2
7
|
import type { Vec } from "../types/bit_vec/module.f.ts";
|
|
3
8
|
import { type Effect, type Operations } from "../types/effect/module.f.ts";
|
package/cas/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-addressable storage utilities for hashing, addressing, and path parsing.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { computeSync, sha256 } from "../crypto/sha2/module.f.js";
|
|
2
7
|
import { parse } from "../path/module.f.js";
|
|
3
8
|
import { cBase32ToVec, vecToCBase32 } from "../types/cbase32/module.f.js";
|
package/ci/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Continuous integration helper commands for repository automation tasks.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { utf8 } from "../text/module.f.js";
|
|
2
7
|
import { writeFile } from "../types/effect/node/module.f.js";
|
|
3
8
|
const os = ['ubuntu', 'macos', 'windows'];
|
|
@@ -5,15 +10,15 @@ const architecture = ['intel', 'arm'];
|
|
|
5
10
|
// https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for-public-repositories
|
|
6
11
|
const images = {
|
|
7
12
|
ubuntu: {
|
|
8
|
-
intel: 'ubuntu-
|
|
13
|
+
intel: 'ubuntu-24.04',
|
|
9
14
|
arm: 'ubuntu-24.04-arm'
|
|
10
15
|
},
|
|
11
16
|
macos: {
|
|
12
|
-
intel: 'macos-
|
|
13
|
-
arm: 'macos-
|
|
17
|
+
intel: 'macos-26-intel',
|
|
18
|
+
arm: 'macos-26'
|
|
14
19
|
},
|
|
15
20
|
windows: {
|
|
16
|
-
intel: 'windows-
|
|
21
|
+
intel: 'windows-2025',
|
|
17
22
|
arm: 'windows-11-arm',
|
|
18
23
|
}
|
|
19
24
|
};
|
|
@@ -27,11 +32,7 @@ const installBun = installOnWindowsArm({
|
|
|
27
32
|
name: 'bun',
|
|
28
33
|
path: 'bun.sh'
|
|
29
34
|
});
|
|
30
|
-
const installDeno =
|
|
31
|
-
def: { uses: 'denoland/setup-deno@v2', with: { 'deno-version': '2' } },
|
|
32
|
-
name: 'deno',
|
|
33
|
-
path: 'deno.land'
|
|
34
|
-
});
|
|
35
|
+
const installDeno = install({ uses: 'denoland/setup-deno@v2', with: { 'deno-version': '2' } });
|
|
35
36
|
const cargoTest = (target, config) => {
|
|
36
37
|
const to = target ? ` --target ${target}` : '';
|
|
37
38
|
const co = config ? ` --config ${config}` : '';
|
|
@@ -65,6 +66,9 @@ const node = (version) => (extra) => basicNode(version)([
|
|
|
65
66
|
...extra,
|
|
66
67
|
]);
|
|
67
68
|
const findTgz = (v) => v === 'windows' ? '(Get-ChildItem *.tgz).FullName' : './*.tgz';
|
|
69
|
+
const playwrightVersion = '1.58.2';
|
|
70
|
+
const playwrightAndVersion = `playwright@${playwrightVersion}`;
|
|
71
|
+
const rustToolchain = '1.93.1';
|
|
68
72
|
const toSteps = (m) => {
|
|
69
73
|
const filter = (st) => m.flatMap((mt) => mt.type === st ? [mt.step] : []);
|
|
70
74
|
const aptGet = m.flatMap(v => v.type === 'apt-get' ? [v.package] : []).join(' ');
|
|
@@ -73,9 +77,7 @@ const toSteps = (m) => {
|
|
|
73
77
|
return [
|
|
74
78
|
...(aptGet !== '' ? [{ run: `sudo apt-get update && sudo apt-get install -y ${aptGet}` }] : []),
|
|
75
79
|
...(rust ? [{
|
|
76
|
-
|
|
77
|
-
// See https://github.com/sergey-shandar/wasmtime-crash
|
|
78
|
-
uses: 'dtolnay/rust-toolchain@1.93.0',
|
|
80
|
+
uses: `dtolnay/rust-toolchain@${rustToolchain}`,
|
|
79
81
|
with: {
|
|
80
82
|
components: 'rustfmt,clippy',
|
|
81
83
|
targets
|
|
@@ -94,11 +96,34 @@ const nodeSteps = (v) => [
|
|
|
94
96
|
test({ run: `npm ${nodeTest(v)}` }),
|
|
95
97
|
];
|
|
96
98
|
const ubuntu = (ms) => ({
|
|
97
|
-
'runs-on': 'ubuntu-
|
|
99
|
+
'runs-on': 'ubuntu-24.04',
|
|
98
100
|
steps: toSteps(ms)
|
|
99
101
|
});
|
|
100
102
|
const nodeVersions = Object.fromEntries(nodes.map(v => [`node${v}`, ubuntu(nodeSteps(v))]));
|
|
101
|
-
const
|
|
103
|
+
const defaultNodeVersion = '24';
|
|
104
|
+
const playwright = ubuntu(basicNode(defaultNodeVersion)([
|
|
105
|
+
//install({ uses: 'actions/cache@v4', with: { path: '~/.cache/ms-playwright', key: `${images.ubuntu.intel}-${playwrightAndVersion}` } }),
|
|
106
|
+
install({ run: `npm install -g ${playwrightAndVersion}` }),
|
|
107
|
+
install({ run: 'playwright install --with-deps' }),
|
|
108
|
+
// we have to use `npx` to make sure that we respect `@playwright/test` version from
|
|
109
|
+
// the `package.json`.
|
|
110
|
+
...['chromium', 'firefox', 'webkit'].map(browser => test({ run: `npx playwright test --browser=${browser}` })),
|
|
111
|
+
]));
|
|
112
|
+
const i686 = (a, v) => {
|
|
113
|
+
if (a === 'intel') {
|
|
114
|
+
switch (v) {
|
|
115
|
+
case 'windows': return customTarget('i686-pc-windows-msvc');
|
|
116
|
+
case 'ubuntu': return [
|
|
117
|
+
{ type: 'apt-get', package: 'libc6-dev-i386' },
|
|
118
|
+
...customTarget('i686-unknown-linux-gnu'),
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return [];
|
|
123
|
+
};
|
|
124
|
+
const job = (v) => (a) => {
|
|
125
|
+
const id = `${v}-${a}`;
|
|
126
|
+
const image = images[v][a];
|
|
102
127
|
const result = [
|
|
103
128
|
// Rust
|
|
104
129
|
test({ run: 'cargo fmt -- --check' }),
|
|
@@ -110,23 +135,12 @@ const steps = (v) => (a) => {
|
|
|
110
135
|
...wasmTarget('wasm32-wasip2'),
|
|
111
136
|
...wasmTarget('wasm32-unknown-unknown'),
|
|
112
137
|
...wasmTarget('wasm32-wasip1-threads'),
|
|
113
|
-
...(a
|
|
114
|
-
v === 'windows' ?
|
|
115
|
-
customTarget('i686-pc-windows-msvc') :
|
|
116
|
-
v === 'ubuntu' ? [
|
|
117
|
-
{ type: 'apt-get', package: 'libc6-dev-i386' },
|
|
118
|
-
...customTarget('i686-unknown-linux-gnu'),
|
|
119
|
-
] :
|
|
120
|
-
[]),
|
|
138
|
+
...i686(a, v),
|
|
121
139
|
// Node.js
|
|
122
|
-
...node(
|
|
140
|
+
...node(defaultNodeVersion)([
|
|
123
141
|
// TypeScript Preview
|
|
124
142
|
install({ run: 'npm install -g @typescript/native-preview' }),
|
|
125
143
|
test({ run: 'tsgo' }),
|
|
126
|
-
// Playwright
|
|
127
|
-
install({ run: 'npm install -g playwright' }),
|
|
128
|
-
install({ run: 'playwright install --with-deps' }),
|
|
129
|
-
...['chromium', 'firefox', 'webkit'].map(browser => (test({ run: `npx playwright test --browser=${browser}` }))),
|
|
130
144
|
// publishing
|
|
131
145
|
test({ run: 'npm pack' }),
|
|
132
146
|
test({ run: `npm install -g ${findTgz(v)}` }),
|
|
@@ -136,7 +150,7 @@ const steps = (v) => (a) => {
|
|
|
136
150
|
]),
|
|
137
151
|
// Deno
|
|
138
152
|
...clean([
|
|
139
|
-
installDeno
|
|
153
|
+
installDeno,
|
|
140
154
|
test({ run: 'deno install' }),
|
|
141
155
|
test({ run: 'deno task test' }),
|
|
142
156
|
test({ run: 'deno task fjs compile issues/demo/data/tree.json _tree.f.js' }),
|
|
@@ -150,16 +164,12 @@ const steps = (v) => (a) => {
|
|
|
150
164
|
test({ run: 'bun ./fjs/module.ts t' }),
|
|
151
165
|
]),
|
|
152
166
|
];
|
|
153
|
-
return toSteps(result);
|
|
167
|
+
return [id, { 'runs-on': image, steps: toSteps(result) }];
|
|
154
168
|
};
|
|
155
169
|
const jobs = {
|
|
156
|
-
...Object.fromEntries(
|
|
157
|
-
...os.flatMap(v => architecture.map(a => [`${v}-${a}`, {
|
|
158
|
-
'runs-on': images[v][a],
|
|
159
|
-
steps: steps(v)(a),
|
|
160
|
-
}]))
|
|
161
|
-
]),
|
|
170
|
+
...Object.fromEntries(os.flatMap(v => architecture.map(job(v)))),
|
|
162
171
|
...nodeVersions,
|
|
172
|
+
playwright,
|
|
163
173
|
};
|
|
164
174
|
const gha = {
|
|
165
175
|
name: 'CI',
|
package/ci/module.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import run from "../io/module.js";
|
|
2
|
+
import app from "./module.f.js";
|
|
3
|
+
run(app);
|
package/crypto/hmac/test.f.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { utf8 } from "../../text/module.f.js";
|
|
2
|
-
import {
|
|
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
5
|
export default {
|
package/crypto/sign/test.f.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { utf8 } from "../../text/module.f.js";
|
|
2
2
|
import { empty, msb, repeat, vec, vec8 } from "../../types/bit_vec/module.f.js";
|
|
3
3
|
import { hmac } from "../hmac/module.f.js";
|
|
4
|
-
import {
|
|
4
|
+
import { secp192r1, secp256r1, secp384r1, secp521r1 } from "../secp/module.f.js";
|
|
5
5
|
import { computeSync, sha224, sha256, sha384, sha512 } from "../sha2/module.f.js";
|
|
6
6
|
import { all, concat, computeK, fromCurve, sign } from "./module.f.js";
|
|
7
7
|
const sample = utf8("sample");
|
package/dev/index/module.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { index } from "../module.f.js";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import { legacyRun } from "../../io/module.js";
|
|
3
|
+
legacyRun(index);
|
package/dev/module.f.d.ts
CHANGED
package/dev/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development utilities for indexing modules and loading FunctionalScript files.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { fromIo } from "../io/module.f.js";
|
|
2
7
|
import { updateVersion } from "./version/module.f.js";
|
|
3
8
|
import { decodeUtf8, encodeUtf8 } from "../types/uint8array/module.f.js";
|
package/dev/tf/all.test.js
CHANGED
|
@@ -7,11 +7,11 @@ const isPlaywright = typeof process !== 'undefined' && process?.env?.PLAYWRIGHT_
|
|
|
7
7
|
const createFramework = (fw) => (prefix, f) => fw.test(prefix, t => f((name, v) => t.test(name, v)));
|
|
8
8
|
// Bun doesn't support nested tests yet.
|
|
9
9
|
const createBunFramework = (fw) => (prefix, f) => f((name, v) => fw.test(`${prefix}: ${name}`, v));
|
|
10
|
-
const
|
|
10
|
+
const createPlaywrightFramework = async () => {
|
|
11
11
|
const pwTest = (await import('@playwright/test')).test;
|
|
12
12
|
return (prefix, f) => f((name, v) => pwTest(`${prefix}: ${name}`, v));
|
|
13
13
|
};
|
|
14
|
-
const framework = isPlaywright ? await
|
|
14
|
+
const framework = isPlaywright ? await createPlaywrightFramework() :
|
|
15
15
|
isBun ? createBunFramework(nodeTest) :
|
|
16
16
|
createFramework(nodeTest);
|
|
17
17
|
const parse = parseTestSet(io.tryCatch);
|
package/dev/tf/module.f.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Test-framework helpers for running and reporting FunctionalScript tests.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { fold } from "../../types/list/module.f.js";
|
|
2
7
|
import { reset, fgGreen, fgRed, bold, stdio, stderr } from "../../text/sgr/module.f.js";
|
|
3
8
|
import { env, loadModuleMap } from "../module.f.js";
|
|
4
9
|
export const isTest = (s) => s.endsWith('test.f.js') || s.endsWith('test.f.ts');
|
|
@@ -58,7 +63,7 @@ export const test = (input) => {
|
|
|
58
63
|
if (isGitHub) {
|
|
59
64
|
// https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
|
|
60
65
|
// https://github.com/OndraM/ci-detector/blob/main/src/Ci/GitHubActions.php
|
|
61
|
-
error(`::error file=${k},line=1,title
|
|
66
|
+
error(`::error file=${k},line=1,title=${i}()::${r}`);
|
|
62
67
|
}
|
|
63
68
|
else {
|
|
64
69
|
error(`${i}() ${fgRed}error${reset}, ${timeFormat(delta)}`);
|
package/dev/version/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version management helpers for updating project package versions.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { utf8, utf8ToString } from "../../text/module.f.js";
|
|
2
7
|
import { all } from "../../types/effect/module.f.js";
|
|
3
8
|
import { readFile, writeFile } from "../../types/effect/node/module.f.js";
|
package/djs/ast/module.f.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST types and helpers for the DJS representation.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import type { Primitive, Array, Unknown } from '../module.f.ts';
|
|
2
7
|
export type AstModule = [readonly string[], AstBody];
|
|
3
8
|
export type AstConst = Primitive | AstModuleRef | AstArray | AstObject;
|
package/djs/module.f.d.ts
CHANGED
package/djs/parser/module.f.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DJS parser that builds structured trees from DJS tokens.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { type Result } from '../../types/result/module.f.ts';
|
|
2
7
|
import { type List } from '../../types/list/module.f.ts';
|
|
3
8
|
import type { DjsTokenWithMetadata } from '../tokenizer/module.f.ts';
|
package/djs/parser/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DJS parser that builds structured trees from DJS tokens.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { error, ok } from "../../types/result/module.f.js";
|
|
2
7
|
import { fold, first, drop, toArray, length, concat } from "../../types/list/module.f.js";
|
|
3
8
|
import { setReplace, at } from "../../types/ordered_map/module.f.js";
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experimental DJS parser implementation.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { descentParser } from "../../bnf/data/module.f.js";
|
|
2
7
|
import { eof, join0Plus, max, none, not, notSet, oneEncode, option, range, remove, repeat, repeat0Plus, repeat1Plus, set, unicodeRange } from "../../bnf/module.f.js";
|
|
3
8
|
import { todo } from "../../dev/module.f.js";
|
|
@@ -134,7 +139,6 @@ export const jsGrammar = () => {
|
|
|
134
139
|
]
|
|
135
140
|
}
|
|
136
141
|
];
|
|
137
|
-
const endOfFile = oneEncode(eof);
|
|
138
142
|
const token = {
|
|
139
143
|
number,
|
|
140
144
|
string,
|
|
@@ -143,7 +147,7 @@ export const jsGrammar = () => {
|
|
|
143
147
|
operator,
|
|
144
148
|
ws,
|
|
145
149
|
newLine,
|
|
146
|
-
|
|
150
|
+
eof
|
|
147
151
|
};
|
|
148
152
|
const tokens = repeat0Plus(token);
|
|
149
153
|
return tokens;
|
package/djs/parser-new/test.f.js
CHANGED
|
@@ -15,9 +15,10 @@ export default {
|
|
|
15
15
|
const mr = descentParserCpOnly(m, '', cp);
|
|
16
16
|
const success = mr[1] && mr[2] === cp.length;
|
|
17
17
|
if (success !== expected) {
|
|
18
|
-
throw mr;
|
|
18
|
+
throw JSON.stringify([s, mr]);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
+
expect('"', false);
|
|
21
22
|
expect(' true ', true);
|
|
22
23
|
expect(' tr2ue ', true);
|
|
23
24
|
expect(' 2true ', true);
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DJS serializer for formatting AST values back to source text.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import type { Unknown } from '../module.f.ts';
|
|
2
7
|
import type { Entry as ObjectEntry } from '../../types/object/module.f.ts';
|
|
3
8
|
import { type List } from '../../types/list/module.f.ts';
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DJS transpiler for transforming parsed trees into JavaScript output.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { type Unknown } from '../module.f.ts';
|
|
2
7
|
import { type Result } from '../../types/result/module.f.ts';
|
|
3
8
|
import { type List } from '../../types/list/module.f.ts';
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DJS transpiler for transforming parsed trees into JavaScript output.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import {} from "../module.f.js";
|
|
2
7
|
import { error, ok } from "../../types/result/module.f.js";
|
|
3
8
|
import { fold, drop, map as listMap, toArray, includes } from "../../types/list/module.f.js";
|
package/fjs/module.f.d.ts
CHANGED
package/fjs/module.f.js
CHANGED
package/fjs/module.js
CHANGED
package/fsc/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FunctionalScript command utilities for compile workflows.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { strictEqual } from "../types/function/operator/module.f.js";
|
|
2
7
|
import { merge as rangeMapMerge, fromRange, get, } from "../types/range_map/module.f.js";
|
|
3
8
|
import { reduce as listReduce, toArray, map } from "../types/list/module.f.js";
|
package/fsm/module.f.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finite state machine helpers used by parser and tokenizer logic.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { type List } from '../types/list/module.f.ts';
|
|
2
7
|
import { type ByteSet } from '../types/byte_set/module.f.ts';
|
|
3
8
|
import { type RangeMapArray } from '../types/range_map/module.f.ts';
|
package/fsm/module.f.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finite state machine helpers used by parser and tokenizer logic.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { equal, isEmpty, fold, toArray, scan, foldScan, empty as emptyList } from "../types/list/module.f.js";
|
|
2
7
|
import { toRangeMap, union as byteSetUnion, one, empty, range } from "../types/byte_set/module.f.js";
|
|
3
8
|
import { intersect, union as sortedSetUnion } from "../types/sorted_set/module.f.js";
|
package/io/module.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Io, type Run } from './module.f.ts';
|
|
2
2
|
import type { NodeProgram } from '../types/effect/node/module.f.ts';
|
|
3
3
|
export declare const io: Io;
|
|
4
|
-
declare const
|
|
5
|
-
export default runDefault;
|
|
4
|
+
export declare const legacyRun: Run;
|
|
6
5
|
export type NodeRun = (p: NodeProgram) => Promise<number>;
|
|
7
6
|
export declare const ioRun: (io: Io) => NodeRun;
|
|
8
|
-
|
|
7
|
+
declare const effectRun: NodeRun;
|
|
8
|
+
export default effectRun;
|
package/io/module.f.d.ts
CHANGED
|
@@ -104,4 +104,4 @@ export type Run = (f: App) => Promise<never>;
|
|
|
104
104
|
* Handles errors by exiting with code 1
|
|
105
105
|
*/
|
|
106
106
|
export declare const run: (io: Io) => Run;
|
|
107
|
-
export declare const fromIo: ({ console: { error, log }, fs: { promises: { mkdir, readFile, readdir, writeFile } }, }: Io) => <T>(effect: NodeEffect<T>) => Promise<T>;
|
|
107
|
+
export declare const fromIo: ({ console: { error, log }, fs: { promises: { mkdir, readFile, readdir, writeFile } }, fetch, }: Io) => <T>(effect: NodeEffect<T>) => Promise<T>;
|
package/io/module.f.js
CHANGED
|
@@ -26,9 +26,16 @@ const tc = async (f) => {
|
|
|
26
26
|
return error(e);
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
export const fromIo = ({ console: { error, log }, fs: { promises: { mkdir, readFile, readdir, writeFile } }, }) => asyncRun({
|
|
29
|
+
export const fromIo = ({ console: { error, log }, fs: { promises: { mkdir, readFile, readdir, writeFile } }, fetch, }) => asyncRun({
|
|
30
30
|
error: async (message) => error(message),
|
|
31
31
|
log: async (message) => log(message),
|
|
32
|
+
fetch: async (url) => tc(async () => {
|
|
33
|
+
const response = await fetch(url);
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error(`Fetch error: ${response.status} ${response.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
return toVec(new Uint8Array(await response.arrayBuffer()));
|
|
38
|
+
}),
|
|
32
39
|
mkdir: param => tc(async () => { await mkdir(...param); }),
|
|
33
40
|
readFile: path => tc(async () => toVec(await readFile(path))),
|
|
34
41
|
readdir: ([path, r]) => tc(async () => (await readdir(path, { ...r, withFileTypes: true }))
|
package/io/module.js
CHANGED
|
@@ -10,6 +10,7 @@ import { fromIo, run } from "./module.f.js";
|
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import process from "node:process";
|
|
12
12
|
import { concat } from "../path/module.f.js";
|
|
13
|
+
import { error, ok } from "../types/result/module.f.js";
|
|
13
14
|
const prefix = 'file:///';
|
|
14
15
|
export const io = {
|
|
15
16
|
console,
|
|
@@ -24,26 +25,26 @@ export const io = {
|
|
|
24
25
|
fetch,
|
|
25
26
|
tryCatch: f => {
|
|
26
27
|
try {
|
|
27
|
-
return
|
|
28
|
+
return ok(f());
|
|
28
29
|
}
|
|
29
30
|
catch (e) {
|
|
30
|
-
return
|
|
31
|
+
return error(e);
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
asyncTryCatch: async (f) => {
|
|
34
35
|
try {
|
|
35
|
-
return
|
|
36
|
+
return ok(await f());
|
|
36
37
|
}
|
|
37
38
|
catch (e) {
|
|
38
|
-
return
|
|
39
|
+
return error(e);
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
42
|
};
|
|
42
|
-
const
|
|
43
|
-
export default runDefault;
|
|
43
|
+
export const legacyRun = run(io);
|
|
44
44
|
export const ioRun = (io) => {
|
|
45
45
|
const r = fromIo(io);
|
|
46
46
|
const { argv } = io.process;
|
|
47
47
|
return p => r(p(argv));
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
const effectRun = ioRun(io);
|
|
50
|
+
export default effectRun;
|