@velarscript/compiler 0.10.1

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 (159) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +70 -0
  3. package/dist/analyzer.d.ts +1175 -0
  4. package/dist/analyzer.d.ts.map +1 -0
  5. package/dist/analyzer.js +12130 -0
  6. package/dist/analyzer.js.map +1 -0
  7. package/dist/application-package-host.d.ts +28 -0
  8. package/dist/application-package-host.d.ts.map +1 -0
  9. package/dist/application-package-host.js +2 -0
  10. package/dist/application-package-host.js.map +1 -0
  11. package/dist/ast.d.ts +853 -0
  12. package/dist/ast.d.ts.map +1 -0
  13. package/dist/ast.js +245 -0
  14. package/dist/ast.js.map +1 -0
  15. package/dist/class-runtime.d.ts +6 -0
  16. package/dist/class-runtime.d.ts.map +1 -0
  17. package/dist/class-runtime.js +45 -0
  18. package/dist/class-runtime.js.map +1 -0
  19. package/dist/collection-lowering-runtime.d.ts +7 -0
  20. package/dist/collection-lowering-runtime.d.ts.map +1 -0
  21. package/dist/collection-lowering-runtime.js +952 -0
  22. package/dist/collection-lowering-runtime.js.map +1 -0
  23. package/dist/collection-runtime.d.ts +16 -0
  24. package/dist/collection-runtime.d.ts.map +1 -0
  25. package/dist/collection-runtime.js +231 -0
  26. package/dist/collection-runtime.js.map +1 -0
  27. package/dist/core-vocabulary.d.ts +141 -0
  28. package/dist/core-vocabulary.d.ts.map +1 -0
  29. package/dist/core-vocabulary.js +88 -0
  30. package/dist/core-vocabulary.js.map +1 -0
  31. package/dist/diagnostic.d.ts +42 -0
  32. package/dist/diagnostic.d.ts.map +1 -0
  33. package/dist/diagnostic.js +66 -0
  34. package/dist/diagnostic.js.map +1 -0
  35. package/dist/embedded-javascript.d.ts +74 -0
  36. package/dist/embedded-javascript.d.ts.map +1 -0
  37. package/dist/embedded-javascript.js +341 -0
  38. package/dist/embedded-javascript.js.map +1 -0
  39. package/dist/embedded-module.d.ts +11 -0
  40. package/dist/embedded-module.d.ts.map +1 -0
  41. package/dist/embedded-module.js +67 -0
  42. package/dist/embedded-module.js.map +1 -0
  43. package/dist/embedded-source.d.ts +19 -0
  44. package/dist/embedded-source.d.ts.map +1 -0
  45. package/dist/embedded-source.js +61 -0
  46. package/dist/embedded-source.js.map +1 -0
  47. package/dist/emitter.d.ts +188 -0
  48. package/dist/emitter.d.ts.map +1 -0
  49. package/dist/emitter.js +3254 -0
  50. package/dist/emitter.js.map +1 -0
  51. package/dist/error-runtime.d.ts +17 -0
  52. package/dist/error-runtime.d.ts.map +1 -0
  53. package/dist/error-runtime.js +109 -0
  54. package/dist/error-runtime.js.map +1 -0
  55. package/dist/extension.d.ts +373 -0
  56. package/dist/extension.d.ts.map +1 -0
  57. package/dist/extension.js +25 -0
  58. package/dist/extension.js.map +1 -0
  59. package/dist/formatter.d.ts +13 -0
  60. package/dist/formatter.d.ts.map +1 -0
  61. package/dist/formatter.js +1440 -0
  62. package/dist/formatter.js.map +1 -0
  63. package/dist/framework-host.d.ts +87 -0
  64. package/dist/framework-host.d.ts.map +1 -0
  65. package/dist/framework-host.js +2 -0
  66. package/dist/framework-host.js.map +1 -0
  67. package/dist/index.d.ts +75 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +932 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/interpolated-string.d.ts +47 -0
  72. package/dist/interpolated-string.d.ts.map +1 -0
  73. package/dist/interpolated-string.js +344 -0
  74. package/dist/interpolated-string.js.map +1 -0
  75. package/dist/json-runtime.d.ts +2 -0
  76. package/dist/json-runtime.d.ts.map +1 -0
  77. package/dist/json-runtime.js +193 -0
  78. package/dist/json-runtime.js.map +1 -0
  79. package/dist/language-guidance.d.ts +31 -0
  80. package/dist/language-guidance.d.ts.map +1 -0
  81. package/dist/language-guidance.js +187 -0
  82. package/dist/language-guidance.js.map +1 -0
  83. package/dist/lexer.d.ts +85 -0
  84. package/dist/lexer.d.ts.map +1 -0
  85. package/dist/lexer.js +1004 -0
  86. package/dist/lexer.js.map +1 -0
  87. package/dist/limits.d.ts +2 -0
  88. package/dist/limits.d.ts.map +1 -0
  89. package/dist/limits.js +2 -0
  90. package/dist/limits.js.map +1 -0
  91. package/dist/mechanical-fix.d.ts +26 -0
  92. package/dist/mechanical-fix.d.ts.map +1 -0
  93. package/dist/mechanical-fix.js +61 -0
  94. package/dist/mechanical-fix.js.map +1 -0
  95. package/dist/narrowing-runtime.d.ts +5 -0
  96. package/dist/narrowing-runtime.d.ts.map +1 -0
  97. package/dist/narrowing-runtime.js +27 -0
  98. package/dist/narrowing-runtime.js.map +1 -0
  99. package/dist/number-runtime.d.ts +3 -0
  100. package/dist/number-runtime.d.ts.map +1 -0
  101. package/dist/number-runtime.js +37 -0
  102. package/dist/number-runtime.js.map +1 -0
  103. package/dist/parser.d.ts +245 -0
  104. package/dist/parser.d.ts.map +1 -0
  105. package/dist/parser.js +3582 -0
  106. package/dist/parser.js.map +1 -0
  107. package/dist/primitive-runtime.d.ts +4 -0
  108. package/dist/primitive-runtime.d.ts.map +1 -0
  109. package/dist/primitive-runtime.js +39 -0
  110. package/dist/primitive-runtime.js.map +1 -0
  111. package/dist/promise-runtime.d.ts +6 -0
  112. package/dist/promise-runtime.d.ts.map +1 -0
  113. package/dist/promise-runtime.js +86 -0
  114. package/dist/promise-runtime.js.map +1 -0
  115. package/dist/reactive-bridge-runtime.d.ts +7 -0
  116. package/dist/reactive-bridge-runtime.d.ts.map +1 -0
  117. package/dist/reactive-bridge-runtime.js +112 -0
  118. package/dist/reactive-bridge-runtime.js.map +1 -0
  119. package/dist/runtime-abi.d.ts +24 -0
  120. package/dist/runtime-abi.d.ts.map +1 -0
  121. package/dist/runtime-abi.js +24 -0
  122. package/dist/runtime-abi.js.map +1 -0
  123. package/dist/semantic.d.ts +142 -0
  124. package/dist/semantic.d.ts.map +1 -0
  125. package/dist/semantic.js +845 -0
  126. package/dist/semantic.js.map +1 -0
  127. package/dist/source-names.d.ts +32 -0
  128. package/dist/source-names.d.ts.map +1 -0
  129. package/dist/source-names.js +101 -0
  130. package/dist/source-names.js.map +1 -0
  131. package/dist/source.d.ts +19 -0
  132. package/dist/source.d.ts.map +1 -0
  133. package/dist/source.js +64 -0
  134. package/dist/source.js.map +1 -0
  135. package/dist/text-runtime.d.ts +2 -0
  136. package/dist/text-runtime.d.ts.map +1 -0
  137. package/dist/text-runtime.js +285 -0
  138. package/dist/text-runtime.js.map +1 -0
  139. package/dist/token.d.ts +19 -0
  140. package/dist/token.d.ts.map +1 -0
  141. package/dist/token.js +51 -0
  142. package/dist/token.js.map +1 -0
  143. package/dist/type-registry-runtime.d.ts +7 -0
  144. package/dist/type-registry-runtime.d.ts.map +1 -0
  145. package/dist/type-registry-runtime.js +51 -0
  146. package/dist/type-registry-runtime.js.map +1 -0
  147. package/dist/type-validation-runtime.d.ts +17 -0
  148. package/dist/type-validation-runtime.d.ts.map +1 -0
  149. package/dist/type-validation-runtime.js +150 -0
  150. package/dist/type-validation-runtime.js.map +1 -0
  151. package/dist/types.d.ts +356 -0
  152. package/dist/types.d.ts.map +1 -0
  153. package/dist/types.js +1170 -0
  154. package/dist/types.js.map +1 -0
  155. package/dist/utf8-runtime.d.ts +7 -0
  156. package/dist/utf8-runtime.d.ts.map +1 -0
  157. package/dist/utf8-runtime.js +43 -0
  158. package/dist/utf8-runtime.js.map +1 -0
  159. package/package.json +48 -0
@@ -0,0 +1,193 @@
1
+ import { VELAR_RUNTIME_REGISTRY_KEY, VELAR_RUNTIME_SCHEMA_VERSION } from "./runtime-abi.js";
2
+ export const VELAR_STRICT_JSON_RUNTIME = String.raw `
3
+ const __velarMaxJsonCodeUnits = 16 * 1024 * 1024;
4
+ const __velarMaxJsonNodes = 1000000;
5
+ const __velarMaxJsonDepth = 128;
6
+ const __velarJsonNativeArray = globalThis.Array;
7
+ const __velarJsonNativeSet = globalThis.Set;
8
+ const __velarJsonNativeObject = globalThis.Object;
9
+ const __velarJsonNativeNumber = globalThis.Number;
10
+ const __velarJsonNativeString = globalThis.String;
11
+ const __velarJsonNativeMath = globalThis.Math;
12
+ const __velarJsonNativeTypeError = globalThis.TypeError;
13
+ const __velarJsonNativeRangeError = globalThis.RangeError;
14
+ const __velarJsonGetOwnPropertyDescriptor = __velarJsonNativeObject.getOwnPropertyDescriptor;
15
+ const __velarJsonGetOwnPropertyNames = __velarJsonNativeObject.getOwnPropertyNames;
16
+ const __velarJsonGetOwnPropertySymbols = __velarJsonNativeObject.getOwnPropertySymbols;
17
+ const __velarJsonGetPrototypeOf = __velarJsonNativeObject.getPrototypeOf;
18
+ const __velarJsonObjectPrototype = __velarJsonGetOwnPropertyDescriptor(__velarJsonNativeObject, "prototype")?.value;
19
+ const __velarJsonCreate = __velarJsonNativeObject.create;
20
+ const __velarJsonDefineProperty = __velarJsonNativeObject.defineProperty;
21
+ const __velarJsonArrayIsArray = __velarJsonNativeArray.isArray;
22
+ const __velarJsonArrayPrototype = __velarJsonGetOwnPropertyDescriptor(__velarJsonNativeArray, "prototype")?.value;
23
+ const __velarJsonArraySort = __velarJsonGetOwnPropertyDescriptor(__velarJsonArrayPrototype, "sort")?.value;
24
+ const __velarJsonNumberIsFinite = __velarJsonNativeNumber.isFinite;
25
+ const __velarJsonNumberIsInteger = __velarJsonNativeNumber.isInteger;
26
+ const __velarJsonMathMax = __velarJsonNativeMath.max;
27
+ const __velarJsonSymbolFor = globalThis.Symbol.for;
28
+ const __velarJsonReflectOwnKeys = globalThis.Reflect.ownKeys;
29
+ const __velarNativeReflectApply = __velarJsonGetOwnPropertyDescriptor(globalThis.Reflect, "apply")?.value;
30
+ const __velarJsonSetPrototype = __velarJsonGetOwnPropertyDescriptor(__velarJsonNativeSet, "prototype")?.value;
31
+ const __velarJsonSetHas = __velarJsonGetOwnPropertyDescriptor(__velarJsonSetPrototype, "has")?.value;
32
+ const __velarJsonSetAdd = __velarJsonGetOwnPropertyDescriptor(__velarJsonSetPrototype, "add")?.value;
33
+ const __velarJsonSetDelete = __velarJsonGetOwnPropertyDescriptor(__velarJsonSetPrototype, "delete")?.value;
34
+ const __velarJsonStringPrototype = __velarJsonGetOwnPropertyDescriptor(__velarJsonNativeString, "prototype")?.value;
35
+ const __velarJsonCharCodeAt = __velarJsonGetOwnPropertyDescriptor(__velarJsonStringPrototype, "charCodeAt")?.value;
36
+ const __velarJsonPathPattern = /^[A-Za-z_][A-Za-z0-9_]*$/u;
37
+ const __velarJsonRegExpPrototype = __velarJsonGetPrototypeOf(__velarJsonPathPattern);
38
+ const __velarJsonRegExpTest = __velarJsonGetOwnPropertyDescriptor(__velarJsonRegExpPrototype, "test")?.value;
39
+ function __velarJsonApply(operation, receiver, arguments_, label) {
40
+ if (typeof operation !== "function" || typeof __velarNativeReflectApply !== "function") throw new __velarJsonNativeTypeError("The JavaScript " + label + " JSON API is unavailable");
41
+ return __velarNativeReflectApply(operation, receiver, arguments_);
42
+ }
43
+ const __velarJsonHostDescriptor = __velarJsonGetOwnPropertyDescriptor(globalThis, "JSON");
44
+ const __velarJsonHost = __velarJsonHostDescriptor && "value" in __velarJsonHostDescriptor ? __velarJsonHostDescriptor.value : null;
45
+ const __velarNativeJsonParse = __velarJsonHost && __velarJsonGetOwnPropertyDescriptor(__velarJsonHost, "parse")?.value;
46
+ const __velarNativeJsonStringify = __velarJsonHost && __velarJsonGetOwnPropertyDescriptor(__velarJsonHost, "stringify")?.value;
47
+ function __velarJsonRaw(value) {
48
+ const descriptor = __velarJsonGetOwnPropertyDescriptor(globalThis, __velarJsonApply(__velarJsonSymbolFor, undefined, [${JSON.stringify(VELAR_RUNTIME_REGISTRY_KEY)}], "Symbol.for"));
49
+ const runtime = descriptor && "value" in descriptor ? descriptor.value : null;
50
+ if (!runtime || runtime.version !== ${JSON.stringify(VELAR_RUNTIME_SCHEMA_VERSION)} || typeof runtime.toRaw !== "function") return value;
51
+ if (typeof runtime.trackDeep === "function") runtime.trackDeep(value);
52
+ return runtime.toRaw(value);
53
+ }
54
+ function __velarJsonFailure(path, message) {
55
+ throw new __velarJsonNativeTypeError("Invalid JSON value at " + path + ": " + message);
56
+ }
57
+ function __velarJsonPath(parent, key) {
58
+ return __velarJsonApply(__velarJsonRegExpTest, __velarJsonPathPattern, [key], "RegExp.test") ? parent + "." + key : parent + "[field]";
59
+ }
60
+ function __velarJsonStringUnits(value) {
61
+ let units = 2;
62
+ for (let index = 0; index < value.length; index += 1) {
63
+ const code = __velarJsonApply(__velarJsonCharCodeAt, value, [index], "String.charCodeAt");
64
+ if (code === 34 || code === 92 || code === 8 || code === 9 || code === 10 || code === 12 || code === 13) units += 2;
65
+ else if (code <= 31 || (code >= 0xD800 && code <= 0xDFFF && !(code <= 0xDBFF && index + 1 < value.length && __velarJsonApply(__velarJsonCharCodeAt, value, [index + 1], "String.charCodeAt") >= 0xDC00 && __velarJsonApply(__velarJsonCharCodeAt, value, [index + 1], "String.charCodeAt") <= 0xDFFF))) units += 6;
66
+ else { units += 1; if (code >= 0xD800 && code <= 0xDBFF) { units += 1; index += 1; } }
67
+ if (units > __velarMaxJsonCodeUnits) return units;
68
+ }
69
+ return units;
70
+ }
71
+ function __velarJsonBudget(state, path) {
72
+ if (state.nodes > __velarMaxJsonNodes) __velarJsonFailure(path, "data cannot exceed " + __velarMaxJsonNodes + " values");
73
+ if (state.compactUnits > __velarMaxJsonCodeUnits) __velarJsonFailure(path, "encoded JSON cannot exceed 16 MiB");
74
+ }
75
+ function __velarJsonState() { return { active: new __velarJsonNativeSet(), nodes: 0, depth: 0, compactUnits: 0, prettyLines: 0, prettyIndentWeight: 0, prettyColonSpaces: 0 }; }
76
+ function __velarInspectJson(value, path, state, copy) {
77
+ value = __velarJsonRaw(value);
78
+ state.nodes += 1;
79
+ if (value === null) { state.compactUnits += 4; __velarJsonBudget(state, path); return value; }
80
+ if (typeof value === "string") { state.compactUnits += __velarJsonStringUnits(value); __velarJsonBudget(state, path); return value; }
81
+ if (typeof value === "boolean") { state.compactUnits += value ? 4 : 5; __velarJsonBudget(state, path); return value; }
82
+ if (typeof value === "number") {
83
+ if (!__velarJsonApply(__velarJsonNumberIsFinite, __velarJsonNativeNumber, [value], "Number.isFinite")) __velarJsonFailure(path, "numbers must be finite");
84
+ state.compactUnits += __velarJsonApply(__velarJsonNativeString, undefined, [value], "String").length;
85
+ __velarJsonBudget(state, path);
86
+ return value;
87
+ }
88
+ if (typeof value !== "object") __velarJsonFailure(path, typeof value + " is not supported");
89
+ if (state.depth >= __velarMaxJsonDepth) __velarJsonFailure(path, "data cannot exceed " + __velarMaxJsonDepth + " nested collections");
90
+ if (__velarJsonApply(__velarJsonSetHas, state.active, [value], "Set.has")) __velarJsonFailure(path, "cyclic data is not supported");
91
+ __velarJsonApply(__velarJsonSetAdd, state.active, [value], "Set.add");
92
+ try {
93
+ if (__velarJsonApply(__velarJsonArrayIsArray, __velarJsonNativeArray, [value], "Array.isArray")) {
94
+ if (value.length > 1000000) __velarJsonFailure(path, "Lists cannot exceed 1000000 items");
95
+ if (__velarJsonGetOwnPropertySymbols(value).length > 0) __velarJsonFailure(path, "List symbol fields are not supported");
96
+ const names = __velarJsonGetOwnPropertyNames(value);
97
+ if (names.length !== value.length + 1 || names[names.length - 1] !== "length") {
98
+ __velarJsonFailure(path, "Lists must be dense and cannot have extra fields");
99
+ }
100
+ state.compactUnits += 2 + __velarJsonApply(__velarJsonMathMax, __velarJsonNativeMath, [0, value.length - 1], "Math.max");
101
+ if (value.length > 0) {
102
+ state.prettyLines += value.length + 1;
103
+ state.prettyIndentWeight += value.length * (state.depth + 1) + state.depth;
104
+ }
105
+ __velarJsonBudget(state, path);
106
+ const output = copy ? new __velarJsonNativeArray(value.length) : value;
107
+ state.depth += 1;
108
+ for (let index = 0; index < value.length; index += 1) {
109
+ const descriptor = __velarJsonGetOwnPropertyDescriptor(value, index);
110
+ if (!descriptor?.enumerable || !("value" in descriptor)) __velarJsonFailure(path + "[" + index + "]", "List entries must be enumerable data values");
111
+ const child = __velarInspectJson(descriptor.value, path + "[" + index + "]", state, copy);
112
+ if (copy) output[index] = child;
113
+ }
114
+ state.depth -= 1;
115
+ return output;
116
+ }
117
+ const prototype = __velarJsonGetPrototypeOf(value);
118
+ if (prototype !== __velarJsonObjectPrototype && prototype !== null) {
119
+ __velarJsonFailure(path, "only records and Lists are supported");
120
+ }
121
+ const keys = __velarJsonApply(__velarJsonReflectOwnKeys, globalThis.Reflect, [value], "Reflect.ownKeys");
122
+ if (keys.length > 1000000) __velarJsonFailure(path, "records cannot exceed 1000000 fields");
123
+ state.compactUnits += 2 + __velarJsonApply(__velarJsonMathMax, __velarJsonNativeMath, [0, keys.length - 1], "Math.max");
124
+ if (keys.length > 0) {
125
+ state.prettyLines += keys.length + 1;
126
+ state.prettyIndentWeight += keys.length * (state.depth + 1) + state.depth;
127
+ state.prettyColonSpaces += keys.length;
128
+ }
129
+ __velarJsonBudget(state, path);
130
+ const output = copy ? __velarJsonApply(__velarJsonCreate, __velarJsonNativeObject, [null], "Object.create") : value;
131
+ state.depth += 1;
132
+ for (let index = 0; index < keys.length; index += 1) {
133
+ const key = keys[index];
134
+ if (typeof key !== "string") __velarJsonFailure(path, "record symbol fields are not supported");
135
+ state.compactUnits += __velarJsonStringUnits(key) + 1;
136
+ __velarJsonBudget(state, path);
137
+ const childPath = __velarJsonPath(path, key);
138
+ const descriptor = __velarJsonGetOwnPropertyDescriptor(value, key);
139
+ if (!descriptor?.enumerable || !("value" in descriptor)) {
140
+ __velarJsonFailure(childPath, "record fields must be enumerable data values");
141
+ }
142
+ const child = __velarInspectJson(descriptor.value, childPath, state, copy);
143
+ if (copy) __velarJsonApply(__velarJsonDefineProperty, __velarJsonNativeObject, [output, key, { value: child, enumerable: true, configurable: true, writable: true }], "Object.defineProperty");
144
+ }
145
+ state.depth -= 1;
146
+ return output;
147
+ } finally {
148
+ __velarJsonApply(__velarJsonSetDelete, state.active, [value], "Set.delete");
149
+ }
150
+ }
151
+ function __velarAssertJson(value, path = "$", state = null) {
152
+ state ??= __velarJsonState();
153
+ __velarInspectJson(value, path, state, false);
154
+ return state;
155
+ }
156
+ function __velarJsonSnapshot(value) {
157
+ const state = __velarJsonState();
158
+ return { value: __velarInspectJson(value, "$", state, true), state };
159
+ }
160
+ function __velarJsonIndent(pretty) {
161
+ if (pretty === false) return 0;
162
+ if (pretty === true) return 2;
163
+ if (!__velarJsonApply(__velarJsonNumberIsInteger, __velarJsonNativeNumber, [pretty], "Number.isInteger") || pretty < 0 || pretty > 10) {
164
+ throw new __velarJsonNativeRangeError("JSON indentation must be false, true, or an integer from 0 to 10");
165
+ }
166
+ return pretty;
167
+ }
168
+ function __velarJsonParse(text, name = "JSON text") {
169
+ if (typeof text !== "string") throw new __velarJsonNativeTypeError(name + " must be a string");
170
+ if (text.length > __velarMaxJsonCodeUnits) throw new __velarJsonNativeRangeError(name + " cannot exceed 16 MiB");
171
+ if (typeof __velarNativeJsonParse !== "function" || typeof __velarNativeReflectApply !== "function") {
172
+ throw new __velarJsonNativeTypeError("The host JSON parser is unavailable");
173
+ }
174
+ const value = __velarNativeReflectApply(__velarNativeJsonParse, __velarJsonHost, [text]);
175
+ return __velarJsonSnapshot(value).value;
176
+ }
177
+ function __velarJsonStringify(value, pretty = false) {
178
+ const snapshot = __velarJsonSnapshot(value);
179
+ const state = snapshot.state;
180
+ const indentation = __velarJsonIndent(pretty);
181
+ const estimated = state.compactUnits + (indentation ? state.prettyLines + state.prettyColonSpaces + state.prettyIndentWeight * indentation : 0);
182
+ if (estimated > __velarMaxJsonCodeUnits) throw new __velarJsonNativeRangeError("Encoded JSON cannot exceed 16 MiB");
183
+ if (typeof __velarNativeJsonStringify !== "function" || typeof __velarNativeReflectApply !== "function") {
184
+ throw new __velarJsonNativeTypeError("The host JSON serializer is unavailable");
185
+ }
186
+ const output = __velarNativeReflectApply(__velarNativeJsonStringify, __velarJsonHost, [snapshot.value, null, indentation]);
187
+ if (typeof output !== "string") throw new __velarJsonNativeTypeError("The host JSON serializer must return a string");
188
+ if (output.length > __velarMaxJsonCodeUnits) throw new __velarJsonNativeRangeError("Encoded JSON cannot exceed 16 MiB");
189
+ return output;
190
+ }
191
+ function __velarJsonClone(value) { return __velarJsonParse(__velarJsonStringify(value)); }
192
+ `.trimStart();
193
+ //# sourceMappingURL=json-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-runtime.js","sourceRoot":"","sources":["../src/json-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAE5F,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0HA8CuE,IAAI,CAAC,SAAS,CAAC,0BAA0B,CAAC;;wCAE5H,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8InF,CAAC,SAAS,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ export interface SourceTypeGuidance {
2
+ readonly message: string;
3
+ readonly replacement: string | null;
4
+ readonly title: string | null;
5
+ }
6
+ export type CollectionKind = "List" | "Set" | "Map";
7
+ export interface CollectionMemberGuidance {
8
+ readonly message: string;
9
+ readonly replacement: string | null;
10
+ readonly title: string | null;
11
+ }
12
+ export interface DeclarationKeywordGuidance {
13
+ readonly message: string;
14
+ readonly keyword: "def" | "type";
15
+ }
16
+ export declare function webNumericUnitOwner(suffix: string): string | null;
17
+ export declare function declarationKeywordGuidance(name: string): DeclarationKeywordGuidance | null;
18
+ export declare function stringMemberGuidance(name: string): string | null;
19
+ export declare function removedStandardFunctionGuidance(source: string, name: string): string | null;
20
+ export declare function removedGlobalFunctionGuidance(name: string): string | null;
21
+ /**
22
+ * D65 rule 170: one sentence, two stages. A rest parameter without an element
23
+ * type is refused by the parser in every declaration, and by the analyzer in
24
+ * an arrow, where the contextual function type gets its chance to supply one
25
+ * first — exactly as a fixed parameter's type already arrives. Both stages say
26
+ * the same thing because it is the same refusal.
27
+ */
28
+ export declare const REST_PARAMETER_ELEMENT_TYPE_MESSAGE = "A rest parameter requires an element type";
29
+ export declare function sourceTypeNameGuidance(name: string): SourceTypeGuidance | null;
30
+ export declare function collectionMemberGuidance(kind: CollectionKind, member: string): CollectionMemberGuidance | null;
31
+ //# sourceMappingURL=language-guidance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language-guidance.d.ts","sourceRoot":"","sources":["../src/language-guidance.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEpD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAiED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC;CAClC;AAsFD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEjE;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,0BAA0B,GAAG,IAAI,CAE1F;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE3F;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMzE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mCAAmC,8CAA8C,CAAC;AAE/F,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAE9E;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,wBAAwB,GAAG,IAAI,CAE9G"}
@@ -0,0 +1,187 @@
1
+ const sourceTypeGuidance = new Map([
2
+ ["Array", typeReplacement("Use 'List<T>' for ordered collections; VelarScript exposes one source-level List type", "List", "Use the VelarScript List type")],
3
+ ["array", typeReplacement("Use 'List<T>' for ordered collections; VelarScript exposes one source-level List type", "List", "Use the VelarScript List type")],
4
+ ["list", typeReplacement("Use 'List<T>' for ordered collections", "List", "Use the VelarScript List type")],
5
+ ["dict", typeReplacement("Use 'Map<K, V>' for keyed collections", "Map", "Use the VelarScript Map type")],
6
+ ["set", typeReplacement("Use 'Set<T>' for unique collections", "Set", "Use the VelarScript Set type")],
7
+ ["str", typeReplacement("Use 'string' for text values; str(value) is only the explicit text conversion function", "string", "Use the VelarScript string type")],
8
+ ["String", typeReplacement("Use 'string' for text values; JavaScript wrapper-object types are not exposed", "string", "Use the VelarScript string type")],
9
+ ["Number", typeReplacement("Use 'number'; JavaScript wrapper-object types are not exposed", "number", "Use the VelarScript number type")],
10
+ ["boolean", typeReplacement("Use 'bool' for boolean values", "bool", "Use the VelarScript bool type")],
11
+ ["Boolean", typeReplacement("Use 'bool'; JavaScript wrapper-object types are not exposed", "bool", "Use the VelarScript bool type")],
12
+ ["void", typeReplacement("Use 'null' for an explicit no-result type; omitted body-backed results are inferred", "null", "Use the VelarScript null type")],
13
+ ["object", typeGuidance("Declare a named 'type' for an object shape, or use 'unknown' at an unchecked boundary")],
14
+ ["Object", typeGuidance("Declare a named 'type' for an object shape, or use 'unknown' at an unchecked boundary")],
15
+ ["Callable", typeGuidance("Write an explicit function type such as '(value: string) -> bool'")],
16
+ ]);
17
+ const collectionGuidance = new Map([
18
+ ["List", new Map([
19
+ ["length", memberReplacement("Use 'size'", "size", "Use List size")],
20
+ ["at", memberReplacement("Use 'get(index)'", "get", "Use List.get")],
21
+ ["includes", memberReplacement("Use 'has(value)'", "has", "Use List.has")],
22
+ ["contains", memberReplacement("Use 'has(value)'", "has", "Use List.has")],
23
+ ["add", memberReplacement("Use 'append(value)'", "append", "Use List.append")],
24
+ ["addAll", memberReplacement("Use 'extend(values)'", "extend", "Use List.extend")],
25
+ ["push", memberReplacement("Use 'append(value)'", "append", "Use List.append")],
26
+ ["unshift", memberGuidance("Use 'insert(0, value)'")],
27
+ ["shift", memberGuidance("Use 'pop(0)'")],
28
+ ["set", memberGuidance("Use indexed assignment such as 'values[index] = value'")],
29
+ ["delete", memberGuidance("Use 'remove(value)' to remove by value, or 'pop(index)' to remove by index")],
30
+ ["deleteAt", memberReplacement("Use 'pop(index)'", "pop", "Use List.pop")],
31
+ ["first", memberGuidance("Use 'get(0)'")],
32
+ ["last", memberGuidance("Use 'get(-1)'")],
33
+ ["findIndex", memberGuidance("Use 'find(test)' when you need the matching value, or 'index(value)' when locating a known value")],
34
+ ["forEach", memberGuidance("Use a structured loop for side effects — 'for value in values:' followed by the effect in its indented body")],
35
+ ["indexOf", memberReplacement("Use 'index(value)'", "index", "Use List.index")],
36
+ ["any", memberReplacement("Use 'some(test)'", "some", "Use List.some")],
37
+ ["all", memberReplacement("Use 'every(test)'", "every", "Use List.every")],
38
+ ["sort", memberGuidance("Use non-mutating 'sorted(compare)' and keep its returned List")],
39
+ ["reverse", memberGuidance("Use non-mutating 'reversed()' and keep its returned List")],
40
+ ["splice", memberGuidance("Use 'insert', 'remove', 'pop', or 'slice' for one explicit operation")],
41
+ ])],
42
+ ["Set", new Map([
43
+ ["length", memberReplacement("Use 'size'", "size", "Use Set size")],
44
+ ["addAll", memberReplacement("Use 'update(values)'", "update", "Use Set.update")],
45
+ ["append", memberReplacement("Use 'add(value)'", "add", "Use Set.add")],
46
+ ["push", memberReplacement("Use 'add(value)'", "add", "Use Set.add")],
47
+ ["includes", memberReplacement("Use 'has(value)'", "has", "Use Set.has")],
48
+ ["contains", memberReplacement("Use 'has(value)'", "has", "Use Set.has")],
49
+ ["delete", memberReplacement("Use 'remove(value)'", "remove", "Use Set.remove")],
50
+ ])],
51
+ ["Map", new Map([
52
+ ["length", memberReplacement("Use 'size'", "size", "Use Map size")],
53
+ ["setAll", memberReplacement("Use 'update(other)'", "update", "Use Map.update")],
54
+ ["put", memberReplacement("Use 'set(key, value)'", "set", "Use Map.set")],
55
+ ["includes", memberReplacement("Use 'has(key)'", "has", "Use Map.has")],
56
+ ["includesKey", memberReplacement("Use 'has(key)'", "has", "Use Map.has")],
57
+ ["contains", memberReplacement("Use 'has(key)'", "has", "Use Map.has")],
58
+ ["containsKey", memberReplacement("Use 'has(key)'", "has", "Use Map.has")],
59
+ ["delete", memberReplacement("Use 'remove(key)'", "remove", "Use Map.remove")],
60
+ ])],
61
+ ]);
62
+ const functionKeywordGuidance = { message: "Use 'def'; VelarScript declares functions with 'def name(...)'", keyword: "def" };
63
+ const typeKeywordGuidance = { message: "Use 'type'; VelarScript declares record shapes with 'type Name:'", keyword: "type" };
64
+ const declarationKeywordGuidanceEntries = new Map([
65
+ ["fn", functionKeywordGuidance],
66
+ ["func", functionKeywordGuidance],
67
+ ["function", functionKeywordGuidance],
68
+ ["record", typeKeywordGuidance],
69
+ ["struct", typeKeywordGuidance],
70
+ ["interface", typeKeywordGuidance],
71
+ ["schema", typeKeywordGuidance],
72
+ ]);
73
+ const stringMemberGuidanceEntries = new Map([
74
+ ["length", "Use '.size'; strings count Unicode code points like List.size"],
75
+ ["substring", "Use '.slice(start, end)'; VelarScript has one string slicing method"],
76
+ ["substr", "Use '.slice(start, end)'; VelarScript has one string slicing method"],
77
+ ["charAt", "Use '.char(index)'; string positions count Unicode code points"],
78
+ ["at", "Use '.char(index)'; string positions count Unicode code points"],
79
+ ["indexOf", "Use '.index(text, start)'; missing text returns null and string positions count Unicode code points"],
80
+ ["lastIndexOf", "Use '.index(text, start)' to search forward; VelarScript has no reverse string search member"],
81
+ // D51 item "two-round retirement": the destination is the spelling that
82
+ // survives. Naming 'velar/text' here sent the author to an import the
83
+ // project driver retires on the next run, so the guidance taught a loop.
84
+ ["trimStart", "Use Text.trimStart(value); string operations beyond the core members live in the Text namespace, which needs no import"],
85
+ ["trimEnd", "Use Text.trimEnd(value); string operations beyond the core members live in the Text namespace, which needs no import"],
86
+ ["toUpperCase", "Use '.upper()'; VelarScript exposes one string uppercase spelling"],
87
+ ["toLowerCase", "Use '.lower()'; VelarScript exposes one string lowercase spelling"],
88
+ ["includes", "Use '.has(text)'; strings and collections share one membership method"],
89
+ ["toString", "Use 'str(value)' or an f-string; VelarScript has one explicit text conversion spelling"],
90
+ // TXT-I1: the Python spellings, each pointed at the member or the `Text.`
91
+ // namespace function that exists.
92
+ ["strip", "Use '.trim()'; VelarScript trims whitespace with the trim member"],
93
+ ["lstrip", "Use Text.trimStart(value); string operations beyond the core members live in the Text namespace, which needs no import"],
94
+ ["rstrip", "Use Text.trimEnd(value); string operations beyond the core members live in the Text namespace, which needs no import"],
95
+ ["startswith", "Use '.startsWith(text)'; VelarScript member names are camelCase"],
96
+ ["endswith", "Use '.endsWith(text)'; VelarScript member names are camelCase"],
97
+ ["find", "Use '.index(text, start)'; missing text returns null instead of -1"],
98
+ ["splitlines", "Use Text.lines(value); it splits on line boundaries, and the Text namespace needs no import"],
99
+ ["casefold", "Use '.lower()'; VelarScript exposes simple case mapping, not locale case folding"],
100
+ ["format", "Use an f-string — f\"Hello {name}\" — VelarScript interpolates values instead of format()"],
101
+ ["title", "Use Text.title(value); string operations beyond the core members live in the Text namespace, which needs no import"],
102
+ ["capitalize", "Use Text.capitalize(value); string operations beyond the core members live in the Text namespace, which needs no import"],
103
+ ]);
104
+ const removedStandardFunctionGuidanceEntries = new Map([
105
+ ["velar/text", new Map([
106
+ ["length", "Use 'value.size'; string measurement is a checked member"],
107
+ ["char", "Use 'value.char(index)'; string access is a checked member"],
108
+ ["slice", "Use 'value.slice(start, end)'; string slicing is a checked member"],
109
+ ["trim", "Use 'value.trim()'; string trimming is a checked member"],
110
+ ["lower", "Use 'value.lower()'; string lowercasing is a checked member"],
111
+ ["upper", "Use 'value.upper()'; string uppercasing is a checked member"],
112
+ ["startsWith", "Use 'value.startsWith(text)'; string prefix checks are checked members"],
113
+ ["endsWith", "Use 'value.endsWith(text)'; string suffix checks are checked members"],
114
+ ["includes", "Use 'value.has(text)'; strings and collections share one membership method"],
115
+ ["indexOf", "Use 'value.index(text, start)'; missing text returns null and string positions count Unicode code points"],
116
+ ["split", "Use 'value.split(separator)'; string splitting is a checked member"],
117
+ ["replace", "Use 'value.replace(from, to)'; string replacement is a checked member"],
118
+ ["replaceAll", "Use 'value.replaceAll(from, to)'; string replacement is a checked member"],
119
+ ["repeat", "Use 'value.repeat(count)'; string repetition is a checked member"],
120
+ ["padStart", "Use 'value.padStart(size, fill)'; string padding is a checked member"],
121
+ ["padEnd", "Use 'value.padEnd(size, fill)'; string padding is a checked member"],
122
+ ])],
123
+ ["velar/math", new Map([
124
+ ["abs", "Use 'value.abs()'; absolute value is a checked number member"],
125
+ ["round", "Use 'value.round()'; number rounding is a checked member"],
126
+ ["floor", "Use 'value.floor()'; number flooring is a checked member"],
127
+ ["ceil", "Use 'value.ceil()'; number ceiling is a checked member"],
128
+ ["isFinite", "Use 'value.isFinite()'; finite-number checks are checked members"],
129
+ ["isInteger", "Use 'value.isInteger()'; integer checks are checked members"],
130
+ ])],
131
+ ]);
132
+ /**
133
+ * LOK-I5: the visual unit vocabulary belongs to `@velarscript/web`, which adds
134
+ * these suffixes to the lexer. Core keeps the list only to recognize the
135
+ * spelling and name the extension that owns it — the same cross-extension
136
+ * guidance D37 rule 45 established for Web statement shapes — instead of
137
+ * reporting a unit the author spelled perfectly well as unknown. Core's own
138
+ * duration suffixes (`ms`, `s`) are not in this list; they are Core's.
139
+ */
140
+ const webNumericUnits = new Set(["px", "rem", "em", "vw", "vh", "vmin", "vmax", "%", "fr", "deg", "turn"]);
141
+ export function webNumericUnitOwner(suffix) {
142
+ return webNumericUnits.has(suffix) ? "@velarscript/web" : null;
143
+ }
144
+ export function declarationKeywordGuidance(name) {
145
+ return declarationKeywordGuidanceEntries.get(name) ?? null;
146
+ }
147
+ export function stringMemberGuidance(name) {
148
+ return stringMemberGuidanceEntries.get(name) ?? null;
149
+ }
150
+ export function removedStandardFunctionGuidance(source, name) {
151
+ return removedStandardFunctionGuidanceEntries.get(source)?.get(name) ?? null;
152
+ }
153
+ export function removedGlobalFunctionGuidance(name) {
154
+ for (const entries of removedStandardFunctionGuidanceEntries.values()) {
155
+ const guidance = entries.get(name);
156
+ if (guidance)
157
+ return guidance;
158
+ }
159
+ return null;
160
+ }
161
+ /**
162
+ * D65 rule 170: one sentence, two stages. A rest parameter without an element
163
+ * type is refused by the parser in every declaration, and by the analyzer in
164
+ * an arrow, where the contextual function type gets its chance to supply one
165
+ * first — exactly as a fixed parameter's type already arrives. Both stages say
166
+ * the same thing because it is the same refusal.
167
+ */
168
+ export const REST_PARAMETER_ELEMENT_TYPE_MESSAGE = "A rest parameter requires an element type";
169
+ export function sourceTypeNameGuidance(name) {
170
+ return sourceTypeGuidance.get(name) ?? null;
171
+ }
172
+ export function collectionMemberGuidance(kind, member) {
173
+ return collectionGuidance.get(kind)?.get(member) ?? null;
174
+ }
175
+ function typeGuidance(message) {
176
+ return { message, replacement: null, title: null };
177
+ }
178
+ function typeReplacement(message, value, title) {
179
+ return { message, replacement: value, title };
180
+ }
181
+ function memberGuidance(message) {
182
+ return { message, replacement: null, title: null };
183
+ }
184
+ function memberReplacement(message, value, title) {
185
+ return { message, replacement: value, title };
186
+ }
187
+ //# sourceMappingURL=language-guidance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language-guidance.js","sourceRoot":"","sources":["../src/language-guidance.ts"],"names":[],"mappings":"AAcA,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAA6B;IAC7D,CAAC,OAAO,EAAE,eAAe,CAAC,uFAAuF,EAAE,MAAM,EAAE,+BAA+B,CAAC,CAAC;IAC5J,CAAC,OAAO,EAAE,eAAe,CAAC,uFAAuF,EAAE,MAAM,EAAE,+BAA+B,CAAC,CAAC;IAC5J,CAAC,MAAM,EAAE,eAAe,CAAC,uCAAuC,EAAE,MAAM,EAAE,+BAA+B,CAAC,CAAC;IAC3G,CAAC,MAAM,EAAE,eAAe,CAAC,uCAAuC,EAAE,KAAK,EAAE,8BAA8B,CAAC,CAAC;IACzG,CAAC,KAAK,EAAE,eAAe,CAAC,qCAAqC,EAAE,KAAK,EAAE,8BAA8B,CAAC,CAAC;IACtG,CAAC,KAAK,EAAE,eAAe,CAAC,wFAAwF,EAAE,QAAQ,EAAE,iCAAiC,CAAC,CAAC;IAC/J,CAAC,QAAQ,EAAE,eAAe,CAAC,+EAA+E,EAAE,QAAQ,EAAE,iCAAiC,CAAC,CAAC;IACzJ,CAAC,QAAQ,EAAE,eAAe,CAAC,+DAA+D,EAAE,QAAQ,EAAE,iCAAiC,CAAC,CAAC;IACzI,CAAC,SAAS,EAAE,eAAe,CAAC,+BAA+B,EAAE,MAAM,EAAE,+BAA+B,CAAC,CAAC;IACtG,CAAC,SAAS,EAAE,eAAe,CAAC,6DAA6D,EAAE,MAAM,EAAE,+BAA+B,CAAC,CAAC;IACpI,CAAC,MAAM,EAAE,eAAe,CAAC,qFAAqF,EAAE,MAAM,EAAE,+BAA+B,CAAC,CAAC;IACzJ,CAAC,QAAQ,EAAE,YAAY,CAAC,uFAAuF,CAAC,CAAC;IACjH,CAAC,QAAQ,EAAE,YAAY,CAAC,uFAAuF,CAAC,CAA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AK,EAAE,KAAK,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACrD,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe,EAAE,KAAa,EAAE,KAAa;IACtE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { type Diagnostic } from "./diagnostic.ts";
2
+ import type { CompilerLexicalExtension } from "./extension.ts";
3
+ import { type Token } from "./token.ts";
4
+ export interface LexResult {
5
+ readonly tokens: readonly Token[];
6
+ readonly diagnostics: readonly Diagnostic[];
7
+ }
8
+ export declare class Lexer {
9
+ private readonly text;
10
+ private readonly extensionForbiddenIdentifiers;
11
+ private readonly extensionScanners;
12
+ private readonly numericSuffixes;
13
+ private readonly tokens;
14
+ private readonly diagnostics;
15
+ private readonly diagnosedBidirectionalOffsets;
16
+ private readonly indentStack;
17
+ private index;
18
+ private atLineStart;
19
+ private nesting;
20
+ private readonly bracketFragment;
21
+ private readonly scanSourceHygiene;
22
+ constructor(text: string, extensions?: readonly CompilerLexicalExtension[], options?: {
23
+ readonly bracketFragment?: boolean;
24
+ readonly scanSourceHygiene?: boolean;
25
+ });
26
+ lex(): LexResult;
27
+ private readIndentation;
28
+ private isChainContinuation;
29
+ private readNewline;
30
+ private readComment;
31
+ private readBlockComment;
32
+ private blockCommentOwnsLine;
33
+ private readIdentifier;
34
+ private readNumber;
35
+ private readRadixNumber;
36
+ private isRadixDigit;
37
+ /**
38
+ * LOK-I5: `%` right after a number is the percentage unit only where a
39
+ * remainder operator could not stand — the operator always takes a right
40
+ * operand, so a `%` followed by a line end, a closing bracket, or a
41
+ * separator is a unit spelling and nothing else.
42
+ */
43
+ private isPercentUnitPosition;
44
+ private readLeadingDotNumber;
45
+ private readDigitsWithSeparators;
46
+ private readString;
47
+ private readEmbeddedJavaScript;
48
+ private diagnoseStringContents;
49
+ private decodeStringText;
50
+ private legacyTripleQuotePrefix;
51
+ private readLegacyTripleQuote;
52
+ private readExtensionToken;
53
+ private operator;
54
+ /**
55
+ * The rewrite of a symbol operator to its word spelling. A word needs air on
56
+ * either side that a symbol did not: 'a&&b' becomes 'a and b', while
57
+ * 'a && b' keeps the spacing it already had.
58
+ */
59
+ private wordOperatorFix;
60
+ private skipHorizontalWhitespace;
61
+ /**
62
+ * The deletion of a line-ending semicolon, including the blank space it would
63
+ * leave behind. A semicolon followed by anything except further semicolons,
64
+ * spaces, or a comment separates two statements: putting those on their own
65
+ * lines is a change of layout rather than of spelling, so it carries no fix.
66
+ */
67
+ private trailingSemicolonFix;
68
+ private simple;
69
+ private readHexColor;
70
+ private readJavaScriptPrivateIdentifier;
71
+ private readHashComment;
72
+ private diagnoseForbiddenSourceCharacters;
73
+ private isBidirectionalControl;
74
+ private isForbiddenLiteralControl;
75
+ private lineStart;
76
+ private lineEnd;
77
+ private invalidCharacter;
78
+ private isAtEnd;
79
+ private peek;
80
+ private advance;
81
+ private isIdentifierStart;
82
+ private isIdentifierPart;
83
+ private isDigit;
84
+ }
85
+ //# sourceMappingURL=lexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../src/lexer.ts"],"names":[],"mappings":"AACA,OAAO,EAAkD,KAAK,UAAU,EAAsB,MAAM,iBAAiB,CAAC;AAEtH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAK/D,OAAO,EAAgB,KAAK,KAAK,EAAkB,MAAM,YAAY,CAAC;AA0BtE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;CAC7C;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,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