@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,285 @@
1
+ export const VELAR_TEXT_METHOD_RUNTIME = String.raw `
2
+ const __velarMaxTextCodeUnits = 16 * 1024 * 1024;
3
+ const __velarMaxTextItems = 1000000;
4
+ const __velarTextNativeArray = globalThis.Array;
5
+ const __velarTextNativeString = globalThis.String;
6
+ const __velarTextNativeNumber = globalThis.Number;
7
+ const __velarTextNativeMath = globalThis.Math;
8
+ const __velarTextNativeObject = globalThis.Object;
9
+ const __velarTextNativeTypeError = globalThis.TypeError;
10
+ const __velarTextNativeRangeError = globalThis.RangeError;
11
+ const __velarTextGetOwnPropertyDescriptor = __velarTextNativeObject.getOwnPropertyDescriptor;
12
+ const __velarTextRuntimeGetPrototypeOf = __velarTextGetOwnPropertyDescriptor(__velarTextNativeObject, "getPrototypeOf")?.value;
13
+ const __velarTextReflectApply = __velarTextGetOwnPropertyDescriptor(globalThis.Reflect, "apply")?.value;
14
+ const __velarTextStringPrototype = __velarTextGetOwnPropertyDescriptor(__velarTextNativeString, "prototype")?.value;
15
+ const __velarTextArrayIsArray = __velarTextGetOwnPropertyDescriptor(__velarTextNativeArray, "isArray")?.value;
16
+ const __velarTextNumberIsSafeInteger = __velarTextGetOwnPropertyDescriptor(__velarTextNativeNumber, "isSafeInteger")?.value;
17
+ const __velarTextNumberIsInteger = __velarTextGetOwnPropertyDescriptor(__velarTextNativeNumber, "isInteger")?.value;
18
+ const __velarTextMathFloor = __velarTextGetOwnPropertyDescriptor(__velarTextNativeMath, "floor")?.value;
19
+ const __velarTextMathMax = __velarTextGetOwnPropertyDescriptor(__velarTextNativeMath, "max")?.value;
20
+ const __velarTextMathMin = __velarTextGetOwnPropertyDescriptor(__velarTextNativeMath, "min")?.value;
21
+ const __velarNativeStringIndexOf = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "indexOf")?.value;
22
+ const __velarNativeStringSlice = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "slice")?.value;
23
+ const __velarNativeStringCharCodeAt = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "charCodeAt")?.value;
24
+ const __velarNativeStringTrim = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "trim")?.value;
25
+ const __velarNativeStringUpper = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "toUpperCase")?.value;
26
+ const __velarNativeStringLower = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "toLowerCase")?.value;
27
+ const __velarNativeStringSplit = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "split")?.value;
28
+ const __velarNativeStringReplace = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "replace")?.value;
29
+ const __velarNativeStringReplaceAll = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "replaceAll")?.value;
30
+ const __velarNativeStringRepeat = __velarTextGetOwnPropertyDescriptor(__velarTextStringPrototype, "repeat")?.value;
31
+ const __velarTextSurrogatePattern = /[\u{10000}-\u{10FFFF}\uD800-\uDFFF]/u;
32
+ const __velarTextRegExpPrototype = typeof __velarTextRuntimeGetPrototypeOf === "function" ? __velarTextRuntimeGetPrototypeOf(__velarTextSurrogatePattern) : null;
33
+ const __velarTextSurrogateExec = __velarTextRegExpPrototype ? __velarTextGetOwnPropertyDescriptor(__velarTextRegExpPrototype, "exec")?.value : null;
34
+ function __velarTextCall(operation, receiver, arguments_) {
35
+ if (typeof operation !== "function" || typeof __velarTextReflectApply !== "function") throw new __velarTextNativeTypeError("The JavaScript text runtime is unavailable");
36
+ return __velarTextReflectApply(operation, receiver, arguments_);
37
+ }
38
+
39
+ function __velarTextValue(value) {
40
+ if (typeof value !== "string") throw new __velarTextNativeTypeError("String methods require a string receiver");
41
+ if (value.length > __velarMaxTextCodeUnits) throw new __velarTextNativeRangeError("Strings cannot exceed 16 MiB");
42
+ return value;
43
+ }
44
+ function __velarTextArgument(value, name) {
45
+ if (typeof value !== "string") throw new __velarTextNativeTypeError(name + " must be a string");
46
+ if (value.length > __velarMaxTextCodeUnits) throw new __velarTextNativeRangeError(name + " cannot exceed 16 MiB");
47
+ return value;
48
+ }
49
+ function __velarTextOutput(value, name) {
50
+ if (value.length > __velarMaxTextCodeUnits) throw new __velarTextNativeRangeError(name + " output cannot exceed 16 MiB");
51
+ return value;
52
+ }
53
+ function __velarTextCount(value, name) {
54
+ if (!__velarTextCall(__velarTextNumberIsSafeInteger, __velarTextNativeNumber, [value]) || value < 0 || value > __velarMaxTextCodeUnits) {
55
+ throw new __velarTextNativeRangeError(name + " must be an integer from 0 through " + __velarMaxTextCodeUnits);
56
+ }
57
+ return value;
58
+ }
59
+ function __velarTextList(values, name) {
60
+ if (values.length > __velarMaxTextItems) throw new __velarTextNativeRangeError(name + " cannot produce more than " + __velarMaxTextItems + " items");
61
+ return values;
62
+ }
63
+ function __velarTextNextCodePointOffset(value, offset) {
64
+ const first = __velarTextCall(__velarNativeStringCharCodeAt, value, [offset]);
65
+ if (first < 0xD800 || first > 0xDBFF || offset + 1 >= value.length) return offset + 1;
66
+ const second = __velarTextCall(__velarNativeStringCharCodeAt, value, [offset + 1]);
67
+ return second >= 0xDC00 && second <= 0xDFFF ? offset + 2 : offset + 1;
68
+ }
69
+ function __velarTextCodePointLength(value) {
70
+ if (__velarTextCall(__velarTextSurrogateExec, __velarTextSurrogatePattern, [value]) === null) return value.length;
71
+ let length = 0, offset = 0;
72
+ while (offset < value.length) { offset = __velarTextNextCodePointOffset(value, offset); length += 1; }
73
+ return length;
74
+ }
75
+ function __velarTextCodePointPrefix(value, count) { return __velarTextCall(__velarNativeStringSlice, value, [0, __velarTextCodeUnitOffset(value, count)]); }
76
+ // A string whose code-point count equals its code-unit count carries no
77
+ // surrogate pair, so a code-point position is already a code-unit offset.
78
+ // The codePointLength argument lets a caller that has already measured the string reuse
79
+ // that measurement; without it the surrogate probe answers the same question
80
+ // in one native scan. Walking code points from zero instead made every offset
81
+ // conversion O(corpus + position), which is what turned slice-based document
82
+ // scanning quadratic.
83
+ function __velarTextOneUnitPerCodePoint(value, codePointLength) {
84
+ if (codePointLength >= 0) return codePointLength === value.length;
85
+ return __velarTextCall(__velarTextSurrogateExec, __velarTextSurrogatePattern, [value]) === null;
86
+ }
87
+ function __velarTextCodeUnitOffset(value, position, codePointLength = -1) {
88
+ if (__velarTextOneUnitPerCodePoint(value, codePointLength)) return position < value.length ? position : value.length;
89
+ let offset = 0, current = 0;
90
+ while (offset < value.length && current < position) { offset = __velarTextNextCodePointOffset(value, offset); current += 1; }
91
+ return offset;
92
+ }
93
+ function __velarTextCodePointIndex(value, unitOffset, codePointLength = -1) {
94
+ if (__velarTextOneUnitPerCodePoint(value, codePointLength)) return unitOffset <= value.length ? unitOffset : null;
95
+ let offset = 0, position = 0;
96
+ while (offset < unitOffset && offset < value.length) { offset = __velarTextNextCodePointOffset(value, offset); position += 1; }
97
+ return offset === unitOffset ? position : null;
98
+ }
99
+ function __velarTextCodePointDistance(value, start, end) {
100
+ let offset = start, distance = 0;
101
+ while (offset < end) { offset = __velarTextNextCodePointOffset(value, offset); distance += 1; }
102
+ return offset === end ? distance : null;
103
+ }
104
+ function __velarTextReplacementOutputUnits(value, search, replacement, all) {
105
+ let matches = 0;
106
+ if (search === "") matches = all ? __velarTextCodePointLength(value) + 1 : 1;
107
+ else {
108
+ let cursor = 0;
109
+ while (true) {
110
+ const index = __velarTextCall(__velarNativeStringIndexOf, value, [search, cursor]);
111
+ if (index < 0) break;
112
+ matches += 1;
113
+ if (!all) break;
114
+ cursor = index + search.length;
115
+ }
116
+ }
117
+ if (replacement.length <= search.length || matches === 0) return value.length;
118
+ const growth = replacement.length - search.length;
119
+ if (matches > __velarTextCall(__velarTextMathFloor, __velarTextNativeMath, [(__velarMaxTextCodeUnits - value.length) / growth])) return __velarMaxTextCodeUnits + 1;
120
+ return value.length + matches * growth;
121
+ }
122
+
123
+ // TXT-D1: ordered string comparison uses code-point order (= UTF-8 binary
124
+ // order). UTF-16 code-unit order already agrees when neither operand
125
+ // contains a surrogate, so the native probe keeps the decoded walk on
126
+ // surrogate-bearing strings only.
127
+ function __velarStringCompare(left, right) {
128
+ left = __velarTextValue(left);
129
+ right = __velarTextValue(right);
130
+ if (left === right) return 0;
131
+ if (__velarTextCall(__velarTextSurrogateExec, __velarTextSurrogatePattern, [left]) === null
132
+ && __velarTextCall(__velarTextSurrogateExec, __velarTextSurrogatePattern, [right]) === null) {
133
+ return left < right ? -1 : 1;
134
+ }
135
+ let leftOffset = 0;
136
+ let rightOffset = 0;
137
+ while (leftOffset < left.length && rightOffset < right.length) {
138
+ let first = __velarTextCall(__velarNativeStringCharCodeAt, left, [leftOffset]);
139
+ let firstUnits = 1;
140
+ if (first >= 0xD800 && first <= 0xDBFF && leftOffset + 1 < left.length) {
141
+ const trail = __velarTextCall(__velarNativeStringCharCodeAt, left, [leftOffset + 1]);
142
+ if (trail >= 0xDC00 && trail <= 0xDFFF) { first = (first - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; firstUnits = 2; }
143
+ }
144
+ let second = __velarTextCall(__velarNativeStringCharCodeAt, right, [rightOffset]);
145
+ let secondUnits = 1;
146
+ if (second >= 0xD800 && second <= 0xDBFF && rightOffset + 1 < right.length) {
147
+ const trail = __velarTextCall(__velarNativeStringCharCodeAt, right, [rightOffset + 1]);
148
+ if (trail >= 0xDC00 && trail <= 0xDFFF) { second = (second - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; secondUnits = 2; }
149
+ }
150
+ if (first !== second) return first < second ? -1 : 1;
151
+ leftOffset += firstUnits;
152
+ rightOffset += secondUnits;
153
+ }
154
+ return leftOffset < left.length ? 1 : rightOffset < right.length ? -1 : 0;
155
+ }
156
+ // D41 item 61: two 'Comparable'-bounded values hold numbers or strings, and
157
+ // which one is known only at runtime. A string pair keeps code-point order
158
+ // (TXT-D1); everything else uses the plain relational order, exactly as a
159
+ // monomorphic comparison of that category would.
160
+ function __velarOrderCompare(left, right) {
161
+ if (typeof left === "string" && typeof right === "string") return __velarStringCompare(left, right);
162
+ return left < right ? -1 : left > right ? 1 : 0;
163
+ }
164
+ function __velarStringSize(value) { return __velarTextCodePointLength(__velarTextValue(value)); }
165
+ function __velarStringTrim(value) { return __velarTextCall(__velarNativeStringTrim, __velarTextValue(value), []); }
166
+ function __velarStringIsBlank(value) { return __velarTextCall(__velarNativeStringTrim, __velarTextValue(value), []) === ""; }
167
+ function __velarStringUpper(value) { return __velarTextOutput(__velarTextCall(__velarNativeStringUpper, __velarTextValue(value), []), "String.upper"); }
168
+ function __velarStringLower(value) { return __velarTextOutput(__velarTextCall(__velarNativeStringLower, __velarTextValue(value), []), "String.lower"); }
169
+ function __velarStringSlice(value, start = 0, end = null) {
170
+ value = __velarTextValue(value);
171
+ const total = __velarTextCodePointLength(value);
172
+ if (end === null) end = total;
173
+ if (!__velarTextCall(__velarTextNumberIsInteger, __velarTextNativeNumber, [start]) || !__velarTextCall(__velarTextNumberIsInteger, __velarTextNativeNumber, [end])) throw new __velarTextNativeTypeError("String.slice positions must be integers");
174
+ const first = start < 0 ? __velarTextCall(__velarTextMathMax, __velarTextNativeMath, [total + start, 0]) : __velarTextCall(__velarTextMathMin, __velarTextNativeMath, [start, total]);
175
+ const last = end < 0 ? __velarTextCall(__velarTextMathMax, __velarTextNativeMath, [total + end, 0]) : __velarTextCall(__velarTextMathMin, __velarTextNativeMath, [end, total]);
176
+ return __velarTextCall(__velarNativeStringSlice, value, [__velarTextCodeUnitOffset(value, first, total), __velarTextCodeUnitOffset(value, last, total)]);
177
+ }
178
+ function __velarStringChar(value, index) {
179
+ value = __velarTextValue(value);
180
+ if (!__velarTextCall(__velarTextNumberIsInteger, __velarTextNativeNumber, [index])) throw new __velarTextNativeTypeError("String.char index must be an integer");
181
+ const total = __velarTextCodePointLength(value);
182
+ if (index < 0) index += total;
183
+ if (index < 0) return null;
184
+ if (index >= total) return null;
185
+ const start = __velarTextCodeUnitOffset(value, index, total);
186
+ return __velarTextCall(__velarNativeStringSlice, value, [start, __velarTextNextCodePointOffset(value, start)]);
187
+ }
188
+ function __velarStringHas(value, text) { return __velarTextCall(__velarNativeStringIndexOf, __velarTextValue(value), [__velarTextArgument(text, "String.has text")]) >= 0; }
189
+ function __velarStringIndex(value, text, start = 0) {
190
+ value = __velarTextValue(value); text = __velarTextArgument(text, "String.index text");
191
+ if (!__velarTextCall(__velarTextNumberIsInteger, __velarTextNativeNumber, [start])) throw new __velarTextNativeTypeError("String.index start must be an integer");
192
+ const total = __velarTextCodePointLength(value);
193
+ const first = start < 0 ? __velarTextCall(__velarTextMathMax, __velarTextNativeMath, [total + start, 0]) : __velarTextCall(__velarTextMathMin, __velarTextNativeMath, [start, total]);
194
+ let cursor = __velarTextCodeUnitOffset(value, first, total);
195
+ if (text === "") return first;
196
+ while (cursor <= value.length) {
197
+ const found = __velarTextCall(__velarNativeStringIndexOf, value, [text, cursor]);
198
+ if (found < 0) return null;
199
+ const position = __velarTextCodePointIndex(value, found, total);
200
+ if (position !== null && __velarTextCodePointIndex(value, found + text.length, total) !== null) return position;
201
+ cursor = found + 1;
202
+ }
203
+ return null;
204
+ }
205
+ function __velarStringCount(value, text) {
206
+ value = __velarTextValue(value); text = __velarTextArgument(text, "String.count text");
207
+ if (text === "") return __velarTextCodePointLength(value) + 1;
208
+ let count = 0;
209
+ let cursor = 0;
210
+ while (true) {
211
+ const index = __velarTextCall(__velarNativeStringIndexOf, value, [text, cursor]);
212
+ if (index < 0) return count;
213
+ count += 1;
214
+ cursor = index + text.length;
215
+ }
216
+ }
217
+ function __velarStringStartsWith(value, text) {
218
+ value = __velarTextValue(value); text = __velarTextArgument(text, "String.startsWith text");
219
+ return __velarTextCall(__velarNativeStringIndexOf, value, [text, 0]) === 0;
220
+ }
221
+ function __velarStringEndsWith(value, text) {
222
+ value = __velarTextValue(value); text = __velarTextArgument(text, "String.endsWith text");
223
+ const start = value.length - text.length;
224
+ return start >= 0 && __velarTextCall(__velarNativeStringIndexOf, value, [text, start]) === start;
225
+ }
226
+ function __velarStringSplit(value, separator) {
227
+ value = __velarTextValue(value); separator = __velarTextArgument(separator, "String.split separator");
228
+ if (separator === "") {
229
+ const count = __velarTextCodePointLength(value);
230
+ if (count > __velarMaxTextItems) throw new __velarTextNativeRangeError("String.split cannot produce more than " + __velarMaxTextItems + " items");
231
+ const output = new __velarTextNativeArray(count);
232
+ let offset = 0;
233
+ for (let index = 0; index < count; index += 1) {
234
+ const next = __velarTextNextCodePointOffset(value, offset);
235
+ output[index] = __velarTextCall(__velarNativeStringSlice, value, [offset, next]);
236
+ offset = next;
237
+ }
238
+ return output;
239
+ }
240
+ return __velarTextList(__velarTextCall(__velarNativeStringSplit, value, [separator, __velarMaxTextItems + 1]), "String.split");
241
+ }
242
+ function __velarStringReplace(value, from, to) {
243
+ value = __velarTextValue(value); from = __velarTextArgument(from, "String.replace from"); to = __velarTextArgument(to, "String.replace to");
244
+ if (__velarTextReplacementOutputUnits(value, from, to, false) > __velarMaxTextCodeUnits) throw new __velarTextNativeRangeError("String.replace output cannot exceed 16 MiB");
245
+ return __velarTextCall(__velarNativeStringReplace, value, [from, () => to]);
246
+ }
247
+ function __velarStringReplaceAll(value, from, to) {
248
+ value = __velarTextValue(value); from = __velarTextArgument(from, "String.replaceAll from"); to = __velarTextArgument(to, "String.replaceAll to");
249
+ if (__velarTextReplacementOutputUnits(value, from, to, true) > __velarMaxTextCodeUnits) throw new __velarTextNativeRangeError("String.replaceAll output cannot exceed 16 MiB");
250
+ if (from === "") {
251
+ let output = to;
252
+ let offset = 0;
253
+ while (offset < value.length) { const next = __velarTextNextCodePointOffset(value, offset); output += __velarTextCall(__velarNativeStringSlice, value, [offset, next]) + to; offset = next; }
254
+ return output;
255
+ }
256
+ return __velarTextCall(__velarNativeStringReplaceAll, value, [from, () => to]);
257
+ }
258
+ function __velarStringPad(value, size, fill, start) {
259
+ const name = start ? "String.padStart" : "String.padEnd";
260
+ value = __velarTextValue(value); size = __velarTextCount(size, name + " size"); fill = __velarTextArgument(fill, name + " fill");
261
+ const needed = size - __velarTextCodePointLength(value);
262
+ if (needed <= 0 || fill.length === 0) return value;
263
+ let outputUnits = value.length;
264
+ let padding = "";
265
+ let counted = 0, fillOffset = 0;
266
+ while (counted < needed) {
267
+ const next = __velarTextNextCodePointOffset(fill, fillOffset);
268
+ const character = __velarTextCall(__velarNativeStringSlice, fill, [fillOffset, next]);
269
+ outputUnits += character.length;
270
+ if (outputUnits > __velarMaxTextCodeUnits) throw new __velarTextNativeRangeError(name + " output cannot exceed 16 MiB");
271
+ padding += character;
272
+ counted += 1;
273
+ fillOffset = next === fill.length ? 0 : next;
274
+ }
275
+ return start ? padding + value : value + padding;
276
+ }
277
+ function __velarStringPadStart(value, size, fill = " ") { return __velarStringPad(value, size, fill, true); }
278
+ function __velarStringPadEnd(value, size, fill = " ") { return __velarStringPad(value, size, fill, false); }
279
+ function __velarStringRepeat(value, count) {
280
+ value = __velarTextValue(value); count = __velarTextCount(count, "String.repeat count");
281
+ if (value.length > 0 && count > __velarTextCall(__velarTextMathFloor, __velarTextNativeMath, [__velarMaxTextCodeUnits / value.length])) throw new __velarTextNativeRangeError("String.repeat output cannot exceed 16 MiB");
282
+ return __velarTextCall(__velarNativeStringRepeat, value, [count]);
283
+ }
284
+ `.trimStart();
285
+ //# sourceMappingURL=text-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-runtime.js","sourceRoot":"","sources":["../src/text-runtime.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2RlD,CAAC,SAAS,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { Span } from "./source.ts";
2
+ export type TokenKind = "identifier" | "number" | "string" | "fstring" | "extensionToken" | "unitNumber" | "const" | "let" | "def" | "async" | "await" | "export" | "import" | "js" | "unsafe" | "extern" | "module" | "enum" | "abstract" | "class" | "extends" | "override" | "private" | "static" | "super" | "return" | "throw" | "assert" | "if" | "else" | "for" | "in" | "while" | "break" | "continue" | "try" | "catch" | "finally" | "pass" | "is" | "true" | "false" | "null" | "and" | "or" | "not" | "newline" | "indent" | "dedent" | "leftParen" | "rightParen" | "leftBracket" | "rightBracket" | "leftBrace" | "rightBrace" | "colon" | "comma"
3
+ /** D43 item 67: `@name` marks a name the language owns, not the author. */ | "at" | "dot" | "ellipsis" | "question" | "optionalDot" | "nullish" | "arrow" | "fatArrow" | "pipe" | "amp" | "caret" | "tilde" | "leftShift" | "rightShift" | "unsignedRightShift" | "assign" | "plusAssign" | "minusAssign" | "starAssign" | "slashAssign" | "percentAssign" | "bitOrAssign" | "bitAndAssign" | "bitXorAssign" | "leftShiftAssign" | "rightShiftAssign" | "unsignedRightShiftAssign" | "equal" | "notEqual" | "less" | "lessEqual" | "greater" | "greaterEqual" | "plus" | "minus" | "star" | "starStar" | "slash" | "percent" | "eof";
4
+ export interface Token {
5
+ readonly kind: TokenKind;
6
+ readonly value: string;
7
+ readonly span: Span;
8
+ readonly payload?: unknown;
9
+ }
10
+ /**
11
+ * Hard reserved words: spellings the lexer always turns into a keyword token,
12
+ * so they can never name a binding. D30 item 16 softened the statement-head
13
+ * words that JavaScript does not reserve — `type`, `match`, `case`, `from`,
14
+ * `as` — into contextual keywords, which the lexer emits as ordinary
15
+ * identifiers and the parser recognizes by declaration shape. `enum` stays
16
+ * here because JavaScript reserves it, and generated JavaScript must be legal.
17
+ */
18
+ export declare const keywordKinds: Readonly<Record<string, TokenKind>>;
19
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,gBAAgB,GAChB,YAAY,GACZ,OAAO,GACP,KAAK,GACL,KAAK,GACL,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,IAAI,GACJ,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,UAAU,GACV,OAAO,GACP,SAAS,GACT,UAAU,GACV,SAAS,GACT,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,IAAI,GACJ,MAAM,GACN,KAAK,GACL,IAAI,GACJ,OAAO,GACP,OAAO,GACP,UAAU,GACV,KAAK,GACL,OAAO,GACP,SAAS,GACT,MAAM,GACN,IAAI,GACJ,MAAM,GACN,OAAO,GACP,MAAM,GACN,KAAK,GACL,IAAI,GACJ,KAAK,GACL,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,cAAc,GACd,WAAW,GACX,YAAY,GACZ,OAAO,GACP,OAAO;AACT,2EAA2E,IAAI,IAAI,GACjF,KAAK,GACL,UAAU,GACV,UAAU,GACV,aAAa,GACb,SAAS,GACT,OAAO,GACP,UAAU,GACV,MAAM,GACN,KAAK,GACL,OAAO,GACP,OAAO,GACP,WAAW,GACX,YAAY,GACZ,oBAAoB,GACpB,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,aAAa,GACb,eAAe,GACf,aAAa,GACb,cAAc,GACd,cAAc,GACd,iBAAiB,GACjB,kBAAkB,GAClB,0BAA0B,GAC1B,OAAO,GACP,UAAU,GACV,MAAM,GACN,WAAW,GACX,SAAS,GACT,cAAc,GACd,MAAM,GACN,OAAO,GACP,MAAM,GACN,UAAU,GACV,OAAO,GACP,SAAS,GACT,KAAK,CAAC;AAEV,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAyC5D,CAAC"}
package/dist/token.js ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Hard reserved words: spellings the lexer always turns into a keyword token,
3
+ * so they can never name a binding. D30 item 16 softened the statement-head
4
+ * words that JavaScript does not reserve — `type`, `match`, `case`, `from`,
5
+ * `as` — into contextual keywords, which the lexer emits as ordinary
6
+ * identifiers and the parser recognizes by declaration shape. `enum` stays
7
+ * here because JavaScript reserves it, and generated JavaScript must be legal.
8
+ */
9
+ export const keywordKinds = {
10
+ const: "const",
11
+ let: "let",
12
+ def: "def",
13
+ async: "async",
14
+ await: "await",
15
+ export: "export",
16
+ import: "import",
17
+ js: "js",
18
+ unsafe: "unsafe",
19
+ extern: "extern",
20
+ module: "module",
21
+ enum: "enum",
22
+ abstract: "abstract",
23
+ class: "class",
24
+ extends: "extends",
25
+ override: "override",
26
+ private: "private",
27
+ static: "static",
28
+ super: "super",
29
+ return: "return",
30
+ throw: "throw",
31
+ assert: "assert",
32
+ if: "if",
33
+ else: "else",
34
+ for: "for",
35
+ in: "in",
36
+ while: "while",
37
+ break: "break",
38
+ continue: "continue",
39
+ try: "try",
40
+ catch: "catch",
41
+ finally: "finally",
42
+ pass: "pass",
43
+ is: "is",
44
+ true: "true",
45
+ false: "false",
46
+ null: "null",
47
+ and: "and",
48
+ or: "or",
49
+ not: "not",
50
+ };
51
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AA4GA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAwC;IAC/D,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,EAAE,EAAE,IAAI;IACR,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,KAAK;CACX,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Canonical generated runtime for compiler-known Type identities. Core and
3
+ * extensions embed this source into separate modules, then converge through
4
+ * one immutable global WeakSet descriptor.
5
+ */
6
+ export declare const VELAR_TYPE_REGISTRY_RUNTIME: string;
7
+ //# sourceMappingURL=type-registry-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-registry-runtime.d.ts","sourceRoot":"","sources":["../src/type-registry-runtime.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QA2C3B,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { VELAR_TYPE_REGISTRY_KEY } from "./runtime-abi.js";
2
+ /**
3
+ * Canonical generated runtime for compiler-known Type identities. Core and
4
+ * extensions embed this source into separate modules, then converge through
5
+ * one immutable global WeakSet descriptor.
6
+ */
7
+ export const VELAR_TYPE_REGISTRY_RUNTIME = String.raw `
8
+ const __velarTypeNativeWeakSet = globalThis.WeakSet;
9
+ const __velarTypeNativeObject = globalThis.Object;
10
+ const __velarTypeNativeTypeError = globalThis.TypeError;
11
+ const __velarTypeGetOwnPropertyDescriptor = __velarTypeNativeObject.getOwnPropertyDescriptor;
12
+ const __velarTypeDefineProperty = __velarTypeNativeObject.defineProperty;
13
+ const __velarTypeReflectApply = __velarTypeGetOwnPropertyDescriptor(globalThis.Reflect, "apply")?.value;
14
+ const __velarTypeSymbolFor = globalThis.Symbol.for;
15
+ const __velarTypeWeakSetPrototype = __velarTypeGetOwnPropertyDescriptor(__velarTypeNativeWeakSet, "prototype")?.value;
16
+ const __velarTypeWeakSetHas = __velarTypeGetOwnPropertyDescriptor(__velarTypeWeakSetPrototype, "has")?.value;
17
+ const __velarTypeWeakSetAdd = __velarTypeGetOwnPropertyDescriptor(__velarTypeWeakSetPrototype, "add")?.value;
18
+ function __velarTypeCall(operation, receiver, arguments_) { if (typeof operation !== "function" || typeof __velarTypeReflectApply !== "function") throw new __velarTypeNativeTypeError("The JavaScript runtime Type registry API is unavailable"); return __velarTypeReflectApply(operation, receiver, arguments_); }
19
+ const __velarRuntimeTypeRegistryKey = __velarTypeCall(__velarTypeSymbolFor, globalThis.Symbol, [${JSON.stringify(VELAR_TYPE_REGISTRY_KEY)}]);
20
+ const __velarRuntimeTypeRegistry = (() => {
21
+ const descriptor = __velarTypeGetOwnPropertyDescriptor(globalThis, __velarRuntimeTypeRegistryKey);
22
+ if (descriptor) {
23
+ if (!("value" in descriptor) || descriptor.enumerable || descriptor.configurable || descriptor.writable) {
24
+ throw new __velarTypeNativeTypeError("VelarScript runtime type registry descriptor is invalid");
25
+ }
26
+ try { __velarTypeCall(__velarTypeWeakSetHas, descriptor.value, [descriptor.value]); }
27
+ catch { throw new __velarTypeNativeTypeError("VelarScript runtime type registry is invalid"); }
28
+ return descriptor.value;
29
+ }
30
+ const registry = new __velarTypeNativeWeakSet();
31
+ __velarTypeCall(__velarTypeDefineProperty, __velarTypeNativeObject, [globalThis, __velarRuntimeTypeRegistryKey, {
32
+ value: registry,
33
+ enumerable: false,
34
+ configurable: false,
35
+ writable: false,
36
+ }]);
37
+ return registry;
38
+ })();
39
+ function __velarRegisterRuntimeType(value) {
40
+ __velarTypeCall(__velarTypeWeakSetAdd, __velarRuntimeTypeRegistry, [value]);
41
+ return value;
42
+ }
43
+ function __velarRequireRuntimeType(value, name, optional = false) {
44
+ if (optional && value == null) return null;
45
+ if (!value || typeof value !== "object" || !__velarTypeCall(__velarTypeWeakSetHas, __velarRuntimeTypeRegistry, [value])) {
46
+ throw new __velarTypeNativeTypeError(name + " requires a compiler-known VelarScript runtime type");
47
+ }
48
+ return value;
49
+ }
50
+ `.trimStart();
51
+ //# sourceMappingURL=type-registry-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-registry-runtime.js","sourceRoot":"","sources":["../src/type-registry-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;kGAY6C,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BxI,CAAC,SAAS,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Canonical generated runtime for data Type traversal. Runtime Type identity
3
+ * remains owned by type-registry-runtime.ts; this fragment owns only the
4
+ * per-validation graph state and host operations used by generated validators.
5
+ */
6
+ export declare const VELAR_TYPE_VALIDATION_RUNTIME: string;
7
+ /** Stateless traversal for collection-shaped runtime Types. */
8
+ export declare const VELAR_RUNTIME_TYPE_COLLECTION_RUNTIME: string;
9
+ export declare const VELAR_VALIDATION_ERROR_RUNTIME: string;
10
+ export declare const VELAR_TYPE_VALIDATION_MODULE = "velar/compiler-runtime-types-v1";
11
+ /**
12
+ * Project-shared runtime-Type host ABI. Generated predicates and Type values
13
+ * remain in their source modules; only immutable host operations and fresh
14
+ * per-call traversal state cross the project boundary.
15
+ */
16
+ export declare const VELAR_TYPE_VALIDATION_MODULE_SOURCE: string;
17
+ //# sourceMappingURL=type-validation-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-validation-runtime.d.ts","sourceRoot":"","sources":["../src/type-validation-runtime.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,QAgD7B,CAAC;AAEd,+DAA+D;AAC/D,eAAO,MAAM,qCAAqC,QAsCrC,CAAC;AAEd,eAAO,MAAM,8BAA8B,QAc9B,CAAC;AAEd,eAAO,MAAM,4BAA4B,oCAAoC,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,QA+BnC,CAAC"}
@@ -0,0 +1,150 @@
1
+ import { VELAR_COLLECTION_IDENTITY_RUNTIME, VELAR_COLLECTION_TYPE_RUNTIME } from "./collection-runtime.js";
2
+ import { VELAR_TYPE_REGISTRY_RUNTIME } from "./type-registry-runtime.js";
3
+ /**
4
+ * Canonical generated runtime for data Type traversal. Runtime Type identity
5
+ * remains owned by type-registry-runtime.ts; this fragment owns only the
6
+ * per-validation graph state and host operations used by generated validators.
7
+ */
8
+ export const VELAR_TYPE_VALIDATION_RUNTIME = String.raw `
9
+ const __velarValidationNativeWeakMap = globalThis.WeakMap;
10
+ const __velarValidationNativeSet = globalThis.Set;
11
+ const __velarValidationNativePromise = globalThis.Promise;
12
+ const __velarValidationNativeFunction = globalThis.Function;
13
+ const __velarValidationNativeSymbol = globalThis.Symbol;
14
+ const __velarValidationWeakMapPrototype = __velarCollectionGetOwnPropertyDescriptor(__velarValidationNativeWeakMap, "prototype")?.value;
15
+ const __velarValidationSetPrototype = __velarCollectionGetOwnPropertyDescriptor(__velarValidationNativeSet, "prototype")?.value;
16
+ const __velarValidationFunctionPrototype = __velarCollectionGetOwnPropertyDescriptor(__velarValidationNativeFunction, "prototype")?.value;
17
+ const __velarValidationHasInstanceSymbol = __velarCollectionGetOwnPropertyDescriptor(__velarValidationNativeSymbol, "hasInstance")?.value;
18
+ const __velarValidationWeakMapGetOperation = __velarCollectionGetOwnPropertyDescriptor(__velarValidationWeakMapPrototype, "get")?.value;
19
+ const __velarValidationWeakMapSetOperation = __velarCollectionGetOwnPropertyDescriptor(__velarValidationWeakMapPrototype, "set")?.value;
20
+ const __velarValidationWeakMapDeleteOperation = __velarCollectionGetOwnPropertyDescriptor(__velarValidationWeakMapPrototype, "delete")?.value;
21
+ const __velarValidationSetHasOperation = __velarCollectionGetOwnPropertyDescriptor(__velarValidationSetPrototype, "has")?.value;
22
+ const __velarValidationSetAddOperation = __velarCollectionGetOwnPropertyDescriptor(__velarValidationSetPrototype, "add")?.value;
23
+ const __velarValidationSetDeleteOperation = __velarCollectionGetOwnPropertyDescriptor(__velarValidationSetPrototype, "delete")?.value;
24
+ const __velarValidationSetSizeOperation = __velarCollectionGetOwnPropertyDescriptor(__velarValidationSetPrototype, "size")?.get;
25
+ const __velarValidationFunctionHasInstanceOperation = __velarCollectionGetOwnPropertyDescriptor(__velarValidationFunctionPrototype, __velarValidationHasInstanceSymbol)?.value;
26
+ const __velarValidationFreezeOperation = __velarCollectionGetOwnPropertyDescriptor(__velarCollectionNativeObject, "freeze")?.value;
27
+ function __velarValidationState() { return { active: new __velarValidationNativeWeakMap(), depth: 0 }; }
28
+ function __velarValidationSet() { return new __velarValidationNativeSet(); }
29
+ function __velarValidationWeakMapGet(value, key) { return __velarCollectionHostCall(__velarValidationWeakMapGetOperation, value, [key]); }
30
+ function __velarValidationWeakMapSet(value, key, item) { return __velarCollectionHostCall(__velarValidationWeakMapSetOperation, value, [key, item]); }
31
+ function __velarValidationWeakMapDelete(value, key) { return __velarCollectionHostCall(__velarValidationWeakMapDeleteOperation, value, [key]); }
32
+ function __velarValidationSetHas(value, item) { return __velarCollectionHostCall(__velarValidationSetHasOperation, value, [item]); }
33
+ function __velarValidationSetAdd(value, item) { return __velarCollectionHostCall(__velarValidationSetAddOperation, value, [item]); }
34
+ function __velarValidationSetDelete(value, item) { return __velarCollectionHostCall(__velarValidationSetDeleteOperation, value, [item]); }
35
+ function __velarValidationSetSize(value) { return __velarCollectionHostCall(__velarValidationSetSizeOperation, value, []); }
36
+ function __velarValidationIsArray(value) { return __velarCollectionHostCall(__velarCollectionArrayIsArray, __velarCollectionNativeArray, [value]); }
37
+ function __velarValidationOwnDescriptor(value, key) { return __velarCollectionHostCall(__velarCollectionGetOwnPropertyDescriptor, __velarCollectionNativeObject, [value, key]); }
38
+ function __velarValidationIsInstance(value, constructor) { return __velarCollectionHostCall(__velarValidationFunctionHasInstanceOperation, constructor, [value]); }
39
+ function __velarValidationIsPromise(value) { return __velarValidationIsInstance(value, __velarValidationNativePromise); }
40
+ function __velarValidationFreeze(value) { return __velarCollectionHostCall(__velarValidationFreezeOperation, __velarCollectionNativeObject, [value]); }
41
+ // A record contract accepts only plain data objects: prototype null, or a
42
+ // prototype that itself has none (some realm's Object.prototype). The check
43
+ // is structural rather than an identity comparison so plain values from other
44
+ // realms validate, while class instances, Error values, and host objects are
45
+ // rejected — their prototypes always chain through another object.
46
+ function __velarValidationIsPlainObject(value) {
47
+ const prototype = __velarCollectionHostCall(__velarCollectionGetPrototypeOf, __velarCollectionNativeObject, [value]);
48
+ if (prototype === null) return true;
49
+ return __velarCollectionHostCall(__velarCollectionGetPrototypeOf, __velarCollectionNativeObject, [prototype]) === null;
50
+ }
51
+ // Teaching suffix for record parse failures caused by the plain-object rule.
52
+ function __velarValidationRejectionHint(value) {
53
+ if (value === null || typeof value !== "object" || __velarValidationIsArray(value) || __velarValidationIsPlainObject(value)) return "";
54
+ return "; a record accepts only plain data objects — project the fields into a record first, for example {x: instance.x}";
55
+ }
56
+ `.trimStart();
57
+ /** Stateless traversal for collection-shaped runtime Types. */
58
+ export const VELAR_RUNTIME_TYPE_COLLECTION_RUNTIME = String.raw `
59
+ function __velarListTypeIs(value, check) {
60
+ if (!__velarCollectionHostCall(__velarCollectionArrayIsArray, __velarCollectionNativeArray, [value]) || value.length > 1000000 || __velarCollectionHostCall(__velarCollectionOwnSymbols, __velarCollectionNativeObject, [value]).length > 0 || __velarCollectionHostCall(__velarCollectionOwnNames, __velarCollectionNativeObject, [value]).length !== value.length + 1) return false;
61
+ const lengthDescriptor = __velarCollectionHostCall(__velarCollectionGetOwnPropertyDescriptor, __velarCollectionNativeObject, [value, "length"]);
62
+ if (!lengthDescriptor || !lengthDescriptor.writable || lengthDescriptor.enumerable || lengthDescriptor.configurable || !("value" in lengthDescriptor)) return false;
63
+ for (let index = 0; index < value.length; index += 1) {
64
+ const descriptor = __velarCollectionHostCall(__velarCollectionGetOwnPropertyDescriptor, __velarCollectionNativeObject, [value, index]);
65
+ if (!descriptor?.enumerable || !descriptor.configurable || !descriptor.writable || !("value" in descriptor) || !check(descriptor.value)) return false;
66
+ }
67
+ return true;
68
+ }
69
+
70
+ function __velarSetTypeIs(value, check) {
71
+ if (!__velarIsSet(value) || __velarCollectionHostCall(__velarCollectionSetSize, value, []) > 1000000) return false;
72
+ const iterator = __velarCollectionSetTypeIterator(value);
73
+ while (true) { const step = __velarCollectionSetTypeNext(iterator); if (step.done) break; if (!check(step.value)) return false; }
74
+ return true;
75
+ }
76
+
77
+ function __velarMapTypeIs(value, check) {
78
+ if (!__velarIsMap(value) || __velarCollectionHostCall(__velarCollectionMapSize, value, []) > 1000000) return false;
79
+ const iterator = __velarCollectionMapTypeIterator(value);
80
+ while (true) { const step = __velarCollectionMapTypeNext(iterator); if (step.done) break; const entry = step.value; if (!check(entry[0], entry[1])) return false; }
81
+ return true;
82
+ }
83
+
84
+ function __velarRecordTypeIs(value, check) {
85
+ if (!__velarIsRecord(value)) return false;
86
+ const keys = __velarCollectionHostCall(__velarCollectionOwnKeys, __velarCollectionNativeReflect, [value]);
87
+ if (keys.length > 1000000) return false;
88
+ for (let index = 0; index < keys.length; index += 1) {
89
+ const key = keys[index];
90
+ if (typeof key !== "string") return false;
91
+ const descriptor = __velarCollectionHostCall(__velarCollectionGetOwnPropertyDescriptor, __velarCollectionNativeObject, [value, key]);
92
+ if (!descriptor?.enumerable || !descriptor.configurable || !descriptor.writable || !("value" in descriptor) || !check(descriptor.value)) return false;
93
+ }
94
+ return true;
95
+ }
96
+ `.trimStart();
97
+ export const VELAR_VALIDATION_ERROR_RUNTIME = String.raw `
98
+ const __velarValidationErrorDefineProperty = globalThis.Object.defineProperty;
99
+ class __VelarValidationError extends __velarCollectionNativeTypeError {
100
+ constructor(message, detail) {
101
+ super(message);
102
+ this.name = "ValidationError";
103
+ this.path = detail?.path ?? null;
104
+ this.field = detail?.field ?? null;
105
+ this.reason = detail?.reason ?? null;
106
+ }
107
+ }
108
+ // D51 rule 107: 'code' answers with the class a value was constructed from, so
109
+ // the compiler-owned class carries the source-level name it reports.
110
+ __velarValidationErrorDefineProperty(__VelarValidationError, "name", { value: "ValidationError", writable: false, enumerable: false, configurable: true });
111
+ `.trimStart();
112
+ export const VELAR_TYPE_VALIDATION_MODULE = "velar/compiler-runtime-types-v1";
113
+ /**
114
+ * Project-shared runtime-Type host ABI. Generated predicates and Type values
115
+ * remain in their source modules; only immutable host operations and fresh
116
+ * per-call traversal state cross the project boundary.
117
+ */
118
+ export const VELAR_TYPE_VALIDATION_MODULE_SOURCE = String.raw `
119
+ ${VELAR_COLLECTION_IDENTITY_RUNTIME}
120
+ ${VELAR_COLLECTION_TYPE_RUNTIME}
121
+ ${VELAR_TYPE_REGISTRY_RUNTIME}
122
+ ${VELAR_TYPE_VALIDATION_RUNTIME}
123
+ ${VELAR_RUNTIME_TYPE_COLLECTION_RUNTIME}
124
+ ${VELAR_VALIDATION_ERROR_RUNTIME}
125
+ export {
126
+ __velarRegisterRuntimeType as registerRuntimeType,
127
+ __velarValidationState as validationState,
128
+ __velarValidationSet as validationSet,
129
+ __velarValidationWeakMapGet as validationWeakMapGet,
130
+ __velarValidationWeakMapSet as validationWeakMapSet,
131
+ __velarValidationWeakMapDelete as validationWeakMapDelete,
132
+ __velarValidationSetHas as validationSetHas,
133
+ __velarValidationSetAdd as validationSetAdd,
134
+ __velarValidationSetDelete as validationSetDelete,
135
+ __velarValidationSetSize as validationSetSize,
136
+ __velarValidationIsArray as validationIsArray,
137
+ __velarValidationOwnDescriptor as validationOwnDescriptor,
138
+ __velarValidationIsInstance as validationIsInstance,
139
+ __velarValidationIsPromise as validationIsPromise,
140
+ __velarValidationIsPlainObject as validationIsPlainObject,
141
+ __velarValidationRejectionHint as validationRejectionHint,
142
+ __velarValidationFreeze as validationFreeze,
143
+ __velarListTypeIs as listTypeIs,
144
+ __velarSetTypeIs as setTypeIs,
145
+ __velarMapTypeIs as mapTypeIs,
146
+ __velarRecordTypeIs as recordTypeIs,
147
+ __VelarValidationError as ValidationError,
148
+ };
149
+ `.trimStart();
150
+ //# sourceMappingURL=type-validation-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-validation-runtime.js","sourceRoot":"","sources":["../src/type-validation-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAC3G,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEzE;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDtD,CAAC,SAAS,EAAE,CAAC;AAEd,+DAA+D;AAC/D,MAAM,CAAC,MAAM,qCAAqC,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsC9D,CAAC,SAAS,EAAE,CAAC;AAEd,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;CAcvD,CAAC,SAAS,EAAE,CAAC;AAEd,MAAM,CAAC,MAAM,4BAA4B,GAAG,iCAAiC,CAAC;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,MAAM,CAAC,GAAG,CAAA;EAC3D,iCAAiC;EACjC,6BAA6B;EAC7B,2BAA2B;EAC3B,6BAA6B;EAC7B,qCAAqC;EACrC,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;CAyB/B,CAAC,SAAS,EAAE,CAAC"}