functionalscript 0.46.1 → 0.47.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.
Files changed (178) hide show
  1. package/fjs/basen/cbase32/module.f.mjs +18 -10
  2. package/fjs/basen/cbase32/proof.f.d.mts +3 -0
  3. package/fjs/basen/cbase32/proof.f.mjs +24 -2
  4. package/fjs/basen/proof.f.mjs +8 -16
  5. package/fjs/bnf/ll1/proof.f.d.mts +2 -0
  6. package/fjs/bnf/ll1/proof.f.mjs +33 -18
  7. package/fjs/bnf/module.f.d.mts +2 -2
  8. package/fjs/bnf/module.f.mjs +2 -2
  9. package/fjs/cas/proof.f.mjs +4 -26
  10. package/fjs/ci/common/module.f.mjs +6 -0
  11. package/fjs/ci/config/module.f.d.mts +7 -7
  12. package/fjs/ci/config/module.f.mjs +7 -7
  13. package/fjs/cli/module.f.mjs +14 -10
  14. package/fjs/crypto/vdf/module.f.d.mts +0 -1
  15. package/fjs/crypto/vdf/module.f.mjs +3 -14
  16. package/fjs/dev/module.f.mjs +10 -20
  17. package/fjs/djs/parser/module.f.d.mts +101 -53
  18. package/fjs/djs/parser/module.f.mjs +732 -525
  19. package/fjs/djs/parser/proof.f.d.mts +6 -0
  20. package/fjs/djs/parser/proof.f.mjs +315 -11
  21. package/fjs/djs/parser/types.d.ts +29 -2
  22. package/fjs/djs/tokenizer/module.f.mjs +122 -105
  23. package/fjs/djs/tokenizer/proof.f.mjs +17 -0
  24. package/fjs/djs/transpiler/module.f.mjs +4 -5
  25. package/fjs/djs/transpiler/proof.f.d.mts +2 -0
  26. package/fjs/djs/transpiler/proof.f.mjs +25 -0
  27. package/fjs/edag/amnesia/module.f.d.mts +20 -0
  28. package/fjs/edag/amnesia/module.f.mjs +303 -0
  29. package/fjs/edag/amnesia/proof.f.d.mts +79 -0
  30. package/fjs/edag/amnesia/proof.f.mjs +573 -0
  31. package/fjs/edag/amnesia/types.d.ts +15 -0
  32. package/fjs/edag/module.f.d.mts +410 -0
  33. package/fjs/edag/module.f.mjs +559 -0
  34. package/fjs/edag/proof.f.d.mts +116 -0
  35. package/fjs/edag/proof.f.mjs +686 -0
  36. package/fjs/edag/types.d.ts +55 -0
  37. package/fjs/effects/node/memory/module.d.mts +37 -3
  38. package/fjs/effects/node/memory/module.mjs +38 -4
  39. package/fjs/effects/node/memory/proof.d.mts +5 -2
  40. package/fjs/effects/node/memory/proof.mjs +36 -6
  41. package/fjs/effects/node/module.d.mts +9 -1
  42. package/fjs/effects/node/module.f.d.mts +39 -0
  43. package/fjs/effects/node/module.f.mjs +46 -0
  44. package/fjs/effects/node/module.mjs +234 -32
  45. package/fjs/effects/node/types.d.ts +28 -2
  46. package/fjs/effects/node/virtual/module.f.d.mts +19 -10
  47. package/fjs/effects/node/virtual/module.f.mjs +246 -32
  48. package/fjs/effects/node/virtual/proof.f.d.mts +17 -2
  49. package/fjs/effects/node/virtual/proof.f.mjs +232 -8
  50. package/fjs/effects/node/virtual/types.d.ts +57 -1
  51. package/fjs/emergent_testing/browser/proof.d.mts +55 -0
  52. package/fjs/emergent_testing/browser/proof.mjs +352 -0
  53. package/fjs/emergent_testing/browser/species.proof.d.mts +4 -0
  54. package/fjs/emergent_testing/browser/species.proof.mjs +45 -0
  55. package/fjs/emergent_testing/browser.d.mts +79 -0
  56. package/fjs/emergent_testing/browser.mjs +432 -0
  57. package/fjs/emergent_testing/proof.f.d.mts +1 -1
  58. package/fjs/emergent_testing/proof.f.mjs +2 -2
  59. package/fjs/js/string_escape/module.f.d.mts +47 -0
  60. package/fjs/js/string_escape/module.f.mjs +95 -0
  61. package/fjs/js/string_escape/proof.f.d.mts +8 -0
  62. package/fjs/js/string_escape/proof.f.mjs +68 -0
  63. package/fjs/js/tokenizer/module.f.mjs +14 -12
  64. package/fjs/mcp/cas/module.f.d.mts +1 -7
  65. package/fjs/mcp/cas/module.f.mjs +24 -15
  66. package/fjs/mcp/evo/module.f.mjs +9 -24
  67. package/fjs/mcp/module.f.d.mts +3 -1
  68. package/fjs/mcp/module.f.mjs +4 -2
  69. package/fjs/media/json/rtti/module.f.d.mts +2 -2
  70. package/fjs/media/json/rtti/module.f.mjs +1 -1
  71. package/fjs/media/json/schema/module.f.d.mts +15 -5
  72. package/fjs/media/json/schema/module.f.mjs +42 -15
  73. package/fjs/media/json/schema/proof.f.d.mts +10 -1
  74. package/fjs/media/json/schema/proof.f.mjs +88 -16
  75. package/fjs/media/json/serializer/module.f.mjs +14 -26
  76. package/fjs/media/json/types.d.ts +1 -1
  77. package/fjs/media/lock/module.f.d.mts +8 -3
  78. package/fjs/media/lock/module.f.mjs +9 -3
  79. package/fjs/media/lock/proof.f.d.mts +1 -1
  80. package/fjs/media/lock/proof.f.mjs +2 -2
  81. package/fjs/media/lock/types.d.ts +1 -3
  82. package/fjs/media/module.f.d.mts +20 -13
  83. package/fjs/media/module.f.mjs +29 -16
  84. package/fjs/media/note/module.f.d.mts +14 -7
  85. package/fjs/media/note/module.f.mjs +14 -7
  86. package/fjs/media/note/proof.f.mjs +1 -1
  87. package/fjs/media/proof.f.mjs +5 -5
  88. package/fjs/media/revision/module.f.d.mts +8 -2
  89. package/fjs/media/revision/module.f.mjs +9 -3
  90. package/fjs/media/revision/proof.f.mjs +1 -1
  91. package/fjs/media/revision/types.d.ts +1 -1
  92. package/fjs/media/type/module.f.d.mts +20 -0
  93. package/fjs/media/type/module.f.mjs +74 -0
  94. package/fjs/media/type/proof.f.d.mts +5 -0
  95. package/fjs/media/type/proof.f.mjs +24 -1
  96. package/fjs/module.f.mjs +6 -0
  97. package/fjs/path/module.f.d.mts +60 -3
  98. package/fjs/path/module.f.mjs +138 -14
  99. package/fjs/path/proof.f.d.mts +3 -0
  100. package/fjs/path/proof.f.mjs +298 -2
  101. package/fjs/protocol/json_rpc/module.f.d.mts +65 -28
  102. package/fjs/protocol/json_rpc/module.f.mjs +49 -13
  103. package/fjs/protocol/json_rpc/proof.f.d.mts +4 -0
  104. package/fjs/protocol/json_rpc/proof.f.mjs +29 -0
  105. package/fjs/protocol/json_rpc/types.d.ts +12 -2
  106. package/fjs/protocol/mcp/module.f.d.mts +89 -54
  107. package/fjs/protocol/mcp/module.f.mjs +110 -56
  108. package/fjs/protocol/mcp/proof.f.d.mts +13 -0
  109. package/fjs/protocol/mcp/proof.f.mjs +107 -7
  110. package/fjs/protocol/mcp/stdio/module.f.mjs +3 -4
  111. package/fjs/protocol/mcp/stdio/proof.f.mjs +2 -2
  112. package/fjs/protocol/mcp/types.d.ts +14 -2
  113. package/fjs/text/utf8/module.f.mjs +27 -1
  114. package/fjs/text/utf8/proof.f.mjs +37 -0
  115. package/fjs/types/array/module.f.mjs +18 -11
  116. package/fjs/types/array/proof.f.mjs +27 -1
  117. package/fjs/types/bigfloat/module.f.d.mts +48 -9
  118. package/fjs/types/bigfloat/module.f.mjs +147 -59
  119. package/fjs/types/bigfloat/proof.f.d.mts +2 -0
  120. package/fjs/types/bigfloat/proof.f.mjs +136 -4
  121. package/fjs/types/bigfloat/types.d.ts +17 -0
  122. package/fjs/types/function/module.f.d.mts +11 -2
  123. package/fjs/types/function/module.f.mjs +20 -2
  124. package/fjs/types/function/proof.f.mjs +5 -1
  125. package/fjs/types/phantom/types.d.ts +21 -0
  126. package/fjs/types/result/module.f.d.mts +4 -4
  127. package/fjs/types/result/module.f.mjs +2 -2
  128. package/fjs/types/result/proof.f.d.mts +6 -2
  129. package/fjs/types/result/proof.f.mjs +17 -1
  130. package/fjs/types/rtti/common/module.f.d.mts +78 -5
  131. package/fjs/types/rtti/common/module.f.mjs +168 -3
  132. package/fjs/types/rtti/common/proof.f.d.mts +14 -0
  133. package/fjs/types/rtti/common/proof.f.mjs +61 -2
  134. package/fjs/types/rtti/common/types.d.ts +23 -1
  135. package/fjs/types/rtti/data/module.f.d.mts +57 -1
  136. package/fjs/types/rtti/data/module.f.mjs +241 -47
  137. package/fjs/types/rtti/data/proof.f.d.mts +10 -0
  138. package/fjs/types/rtti/data/proof.f.mjs +272 -39
  139. package/fjs/types/rtti/data/types.d.ts +14 -7
  140. package/fjs/types/rtti/host.proof.d.mts +33 -0
  141. package/fjs/types/rtti/host.proof.mjs +170 -0
  142. package/fjs/types/rtti/module.f.d.mts +51 -6
  143. package/fjs/types/rtti/module.f.mjs +50 -3
  144. package/fjs/types/rtti/parse/module.f.d.mts +31 -24
  145. package/fjs/types/rtti/parse/module.f.mjs +197 -59
  146. package/fjs/types/rtti/parse/proof.f.d.mts +37 -2
  147. package/fjs/types/rtti/parse/proof.f.mjs +171 -47
  148. package/fjs/types/rtti/proof.f.d.mts +6 -0
  149. package/fjs/types/rtti/proof.f.mjs +42 -1
  150. package/fjs/types/rtti/ts/module.f.d.mts +9 -3
  151. package/fjs/types/rtti/ts/module.f.mjs +68 -15
  152. package/fjs/types/rtti/ts/proof.f.d.mts +42 -2
  153. package/fjs/types/rtti/ts/proof.f.mjs +139 -6
  154. package/fjs/types/rtti/ts/types.d.ts +164 -16
  155. package/fjs/types/rtti/types.d.ts +31 -3
  156. package/fjs/types/rtti/validate/module.f.d.mts +42 -25
  157. package/fjs/types/rtti/validate/module.f.mjs +187 -53
  158. package/fjs/types/rtti/validate/proof.f.d.mts +28 -2
  159. package/fjs/types/rtti/validate/proof.f.mjs +430 -75
  160. package/fjs/types/ts/types.d.ts +4 -0
  161. package/fjs/web/module.f.d.mts +115 -0
  162. package/fjs/web/module.f.mjs +581 -0
  163. package/fjs/web/proof.f.d.mts +39 -0
  164. package/fjs/web/proof.f.mjs +413 -0
  165. package/fjs/web/types.d.ts +39 -0
  166. package/fjs/website/browser-prepare.d.mts +5 -0
  167. package/fjs/website/browser-prepare.mjs +115 -0
  168. package/fjs/website/browser-source.d.mts +37 -0
  169. package/fjs/website/browser-source.mjs +202 -0
  170. package/fjs/website/browser-source.proof.d.mts +31 -0
  171. package/fjs/website/browser-source.proof.mjs +162 -0
  172. package/fjs/website/browser.d.mts +5 -0
  173. package/fjs/website/browser.mjs +8 -0
  174. package/fjs/website/module.f.d.mts +3 -3
  175. package/fjs/website/module.f.mjs +62 -9
  176. package/fjs/website/proof.f.d.mts +4 -0
  177. package/fjs/website/proof.f.mjs +18 -3
  178. package/package.json +2 -3
@@ -8,61 +8,94 @@
8
8
  * @import { Fold } from '../../types/function/operator/types.ts'
9
9
  * @import { DjsToken, DjsTokenWithMetadata } from '../tokenizer/types.ts'
10
10
  * @import { OrderedMap } from '../../types/ordered_map/types.ts'
11
- * @import { AstArray, AstConst, AstModule, AstModuleRef } from '../ast/types.ts'
11
+ * @import { AstArray, AstConst, AstModule, AstModuleRef, AstObject } from '../ast/types.ts'
12
12
  * @import { TokenMetadata } from '../../js/tokenizer/types.ts'
13
- * @import { ParseError, _ValueToken } from './types.ts'
13
+ * @import { ParseError, _FramingKeyword, _OrdinaryTokenName, _ValueToken } from './types.ts'
14
+ * @import { Assert } from '../../asserts/types.ts'
15
+ * @import { Equal } from '../../types/ts/types.ts'
16
+ * @import { CodePointMeta } from '../../bnf/descent/types.ts'
17
+ * @import { Ast, AstSequence } from '../../bnf/matcher/types.ts'
18
+ * @import { Rule, TerminalRange } from '../../bnf/types.ts'
19
+ * @import { DescentMatch } from '../../bnf/descent/types.ts'
14
20
  */
15
21
  import type { Result } from '../../types/result/types.ts';
16
22
  import type { List } from '../../types/list/types.ts';
17
- import type { DjsTokenWithMetadata } from '../tokenizer/types.ts';
23
+ import type { DjsToken, DjsTokenWithMetadata } from '../tokenizer/types.ts';
18
24
  import type { OrderedMap } from '../../types/ordered_map/types.ts';
19
25
  import type { AstConst, AstModule, AstModuleRef } from '../ast/types.ts';
20
- import type { ParseError } from './types.ts';
21
- export type _DjsStackArray = ['array', List<AstConst>];
22
- export type _DjsStackObject = ['object', OrderedMap<AstConst>, string];
23
- export type _DjsStackElement = _DjsStackArray | _DjsStackObject;
24
- export type _DjsStack = List<_DjsStackElement>;
25
- export type _ParserState = _InitialState | _NewLineRequiredState | _ImportState | _ConstState | _ExportState | _ParseValueState | _ResultState | _ErrorState;
26
- export type _ModuleState = {
27
- readonly refs: OrderedMap<AstModuleRef>;
28
- readonly modules: List<string>;
29
- readonly consts: List<AstConst>;
30
- };
31
- export type _InitialState = {
32
- readonly state: '';
33
- readonly module: _ModuleState;
34
- };
35
- export type _NewLineRequiredState = {
36
- readonly state: 'nl';
37
- readonly module: _ModuleState;
38
- };
39
- export type _ImportState = {
40
- readonly state: 'import' | 'import+name' | 'import+from';
41
- readonly module: _ModuleState;
42
- };
43
- export type _ConstState = {
44
- readonly state: 'const' | 'const+name';
45
- readonly module: _ModuleState;
46
- };
47
- export type _ExportState = {
48
- readonly state: 'export';
49
- readonly module: _ModuleState;
26
+ import type { TokenMetadata } from '../../js/tokenizer/types.ts';
27
+ import type { ParseError, _FramingKeyword, _OrdinaryTokenName } from './types.ts';
28
+ import type { Assert } from '../../asserts/types.ts';
29
+ import type { Equal } from '../../types/ts/types.ts';
30
+ import type { CodePointMeta } from '../../bnf/descent/types.ts';
31
+ import type { Ast } from '../../bnf/matcher/types.ts';
32
+ export type _TokenStream = {
33
+ readonly tokens: readonly DjsTokenWithMetadata[];
34
+ readonly eofMetadata: TokenMetadata;
50
35
  };
51
- export type _ValueState = '' | '[' | '[v' | '[,' | '{' | '{[' | '{[k' | '{k' | '{:' | '{v' | '{,';
52
- export type _ParseValueState = {
53
- readonly state: 'constValue' | 'exportValue';
54
- readonly module: _ModuleState;
55
- readonly valueState: _ValueState;
56
- readonly top: _DjsStackElement | null;
57
- readonly stack: _DjsStack;
58
- };
59
- export type _ResultState = {
60
- readonly state: 'result';
61
- readonly module: _ModuleState;
36
+ /**
37
+ * The parser layer's complete finite alphabet: every token name its grammar may
38
+ * name as a terminal, and the exact set a token-name-to-symbol mapping has to be
39
+ * validated over before parsing.
40
+ *
41
+ * `eof` is not a member — {@link splitEof} removes the tokenizer's physical
42
+ * end-of-input token before any name is mapped, and the backend synthesizes its
43
+ * own logical one.
44
+ *
45
+ * The names are the *token* vocabulary, not the tokenizer grammar's tag
46
+ * vocabulary: only eight punctuators survive into `DjsToken`, so the JS operator
47
+ * set the tokenizer recognizes is far larger than what reaches this layer.
48
+ *
49
+ * A name is not always a kind. The framing keywords arrive as `id` tokens and
50
+ * need terminals of their own, or the grammar could not tell `export default`
51
+ * from two arbitrary identifiers — see {@link framingKeywords}.
52
+ *
53
+ * The `_…AreComplete` assertions below check both halves against `DjsToken` and
54
+ * `_FramingKeyword` at compile time, so a kind or keyword added there breaks the
55
+ * build rather than going unrepresented.
56
+ */
57
+ declare const tokenKindNames: readonly ['true', 'false', 'null', 'undefined', '{', '}', ':', ',', '[', ']', '.', '=', 'string', 'number', 'error', 'id', 'bigint', 'ws', 'nl', '//', '/*'];
58
+ /**
59
+ * The framing keywords, which the tokenizer emits as `id` tokens carrying the
60
+ * word in `value`. Kept as its own list because the mapping has to recognize
61
+ * exactly these values, not merely encode them.
62
+ *
63
+ * **A grammar over this alphabet owes them an identifier rule.** None of the
64
+ * five is reserved: outside the framing positions the parser accepts them as
65
+ * ordinary identifiers, so `const export = 1`, `export default export`, and
66
+ * `{ from: 2, default: 3 }` all parse today. Once each carries its own symbol, a
67
+ * rule whose identifier terminal is the bare `id` symbol rejects every one of
68
+ * them. Wherever an identifier is accepted — binding names, references, object
69
+ * keys, import names — the terminal has to be the union of `id` and these five.
70
+ *
71
+ * Giving a word its own symbol narrows where it is *required*, never where it is
72
+ * *allowed*.
73
+ */
74
+ declare const framingKeywords: readonly ['import', 'const', 'export', 'default', 'from'];
75
+ /**
76
+ * The complete alphabet: one name per `DjsToken` kind except `eof`, plus one per
77
+ * framing keyword. No keyword collides with a kind, so the two lists concatenate
78
+ * without a name being registered twice — which `encoding` would reject anyway.
79
+ */
80
+ declare const ordinaryTokenNames: ("," | "." | "/*" | "//" | ":" | "=" | "[" | "]" | "bigint" | "const" | "default" | "error" | "export" | "false" | "from" | "id" | "import" | "nl" | "null" | "number" | "string" | "true" | "undefined" | "ws" | "{" | "}")[];
81
+ export type _KindsAreComplete = Assert<Equal<(typeof tokenKindNames)[number], Exclude<DjsToken['kind'], 'eof'>>>;
82
+ export type _KeywordsAreComplete = Assert<Equal<(typeof framingKeywords)[number], _FramingKeyword>>;
83
+ export type _AlphabetIsComplete = Assert<Equal<(typeof ordinaryTokenNames)[number], _OrdinaryTokenName>>;
84
+ export type _EofIsNotAName = Assert<Equal<Extract<_OrdinaryTokenName, 'eof'>, never>>;
85
+ export type _Node = Ast<CodePointMeta<DjsTokenWithMetadata>>;
86
+ export type _FoldState = {
87
+ readonly refs: OrderedMap<AstModuleRef>;
88
+ readonly modules: readonly string[];
89
+ readonly consts: readonly AstConst[];
90
+ readonly error: ParseError | null;
62
91
  };
63
- export type _ErrorState = {
64
- readonly state: 'error';
65
- readonly error: ParseError;
92
+ export type _FoldFrame = {
93
+ readonly items: readonly _Node[];
94
+ readonly index: number;
95
+ readonly array: List<AstConst>;
96
+ readonly object: OrderedMap<AstConst>;
97
+ readonly keys: readonly (readonly [string, boolean])[];
98
+ readonly isArray: boolean;
66
99
  };
67
100
  /**
68
101
  * Reads the token list as a FunctionalScript module: `import` statements, then
@@ -72,17 +105,32 @@ export type _ErrorState = {
72
105
  * module, and `fjs/media/json` is its reader
73
106
  * ([spec: JSON input](../../../spec/README.md#json-input)).
74
107
  *
108
+ * The grammar it accepts is written down, in the rules above, rather than
109
+ * implied by the control flow of a state machine — which is what this replaced.
110
+ *
75
111
  * @type {(tokenList: List<DjsTokenWithMetadata>) => Result<AstModule, ParseError>}
76
112
  */
77
113
  export declare const parseFromTokens: (tokenList: List<DjsTokenWithMetadata>) => Result<AstModule, ParseError>;
78
114
  export declare const proof: {
79
- pushKey: {
80
- nonObjectTop: () => void;
115
+ ordinaryTokenNames: {
116
+ noDuplicates: () => void;
81
117
  };
82
- endArray: {
83
- nonArrayTop: () => void;
118
+ tokenToSymbol: {
119
+ distinctAndAboveUnicode: () => void;
120
+ framingKeywordsAreNotIdentifiers: () => void;
121
+ carriesTheToken: () => void;
122
+ throw: {
123
+ eofRejected: () => CodePointMeta<DjsTokenWithMetadata>;
124
+ };
84
125
  };
85
- endObject: {
86
- nonObjectTop: () => void;
126
+ splitEof: {
127
+ final: () => void;
128
+ onlyEof: () => void;
129
+ missing: () => void;
130
+ empty: () => void;
131
+ lexicalError: () => void;
132
+ notFinal: () => void;
133
+ duplicate: () => void;
87
134
  };
88
135
  };
136
+ export {};