@vesk/compiler 0.0.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.
- package/README.md +23 -0
- package/dist/acorn-ts-plugin/index.d.ts +482 -0
- package/dist/acorn-ts-plugin/index.d.ts.map +1 -0
- package/dist/acorn-ts-plugin/index.js +5028 -0
- package/dist/actions.d.ts +22 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +167 -0
- package/dist/api-routes.d.ts +30 -0
- package/dist/api-routes.d.ts.map +1 -0
- package/dist/api-routes.js +350 -0
- package/dist/client-codegen.d.ts +19 -0
- package/dist/client-codegen.d.ts.map +1 -0
- package/dist/client-codegen.js +1523 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +106 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +210 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/ir-generator.d.ts +10 -0
- package/dist/ir-generator.d.ts.map +1 -0
- package/dist/ir-generator.js +1062 -0
- package/dist/ir.d.ts +160 -0
- package/dist/ir.d.ts.map +1 -0
- package/dist/ir.js +219 -0
- package/dist/middleware.d.ts +15 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +183 -0
- package/dist/package.json +15 -0
- package/dist/parser.d.ts +38 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +242 -0
- package/dist/router.d.ts +31 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +451 -0
- package/dist/scan.d.ts +106 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +438 -0
- package/dist/server-codegen.d.ts +5 -0
- package/dist/server-codegen.d.ts.map +1 -0
- package/dist/server-codegen.js +4 -0
- package/dist/server-cookies.d.ts +2 -0
- package/dist/server-cookies.d.ts.map +1 -0
- package/dist/server-cookies.js +15 -0
- package/dist/server-head.d.ts +10 -0
- package/dist/server-head.d.ts.map +1 -0
- package/dist/server-head.js +289 -0
- package/dist/server-jsgen.d.ts +6 -0
- package/dist/server-jsgen.d.ts.map +1 -0
- package/dist/server-jsgen.js +446 -0
- package/dist/server-render.d.ts +16 -0
- package/dist/server-render.d.ts.map +1 -0
- package/dist/server-render.js +397 -0
- package/dist/server-utils.d.ts +93 -0
- package/dist/server-utils.d.ts.map +1 -0
- package/dist/server-utils.js +747 -0
- package/dist/ssr-store.d.ts +4 -0
- package/dist/ssr-store.d.ts.map +1 -0
- package/dist/ssr-store.js +29 -0
- package/dist/strip-ts.d.ts +25 -0
- package/dist/strip-ts.d.ts.map +1 -0
- package/dist/strip-ts.js +171 -0
- package/dist/tokens.d.ts +50 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +334 -0
- package/dist/typecheck.d.ts +19 -0
- package/dist/typecheck.d.ts.map +1 -0
- package/dist/typecheck.js +365 -0
- package/dist/types.d.ts +147 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/vesk-plugin.d.ts +53 -0
- package/dist/vesk-plugin.d.ts.map +1 -0
- package/dist/vesk-plugin.js +413 -0
- package/dist/vsk-imports.d.ts +30 -0
- package/dist/vsk-imports.d.ts.map +1 -0
- package/dist/vsk-imports.js +141 -0
- package/dist/vsk-tsx.d.ts +3 -0
- package/dist/vsk-tsx.d.ts.map +1 -0
- package/dist/vsk-tsx.js +604 -0
- package/package.json +52 -0
package/dist/scan.js
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared character-level scanners for structured text that regex is too
|
|
3
|
+
* fragile to parse: balanced delimiters, strings, comments and top-level
|
|
4
|
+
* separators. Used where the input can contain nested delimiters, `>`
|
|
5
|
+
* inside quoted attributes or braces inside strings/comments.
|
|
6
|
+
*/
|
|
7
|
+
export function isWhitespaceChar(ch) {
|
|
8
|
+
return ch === ' ' || ch === '\t' || ch === '\n' || ch === '\r' || ch === '\f' || ch === '\v' || ch === '\u00a0' || ch === '\ufeff';
|
|
9
|
+
}
|
|
10
|
+
export function isIdentStartCode(code) {
|
|
11
|
+
return ((code >= 97 && code <= 122) || (code >= 65 && code <= 90) || code === 95 || code === 36 || code >= 128);
|
|
12
|
+
}
|
|
13
|
+
export function isIdentCharCode(code) {
|
|
14
|
+
return isIdentStartCode(code) || (code >= 48 && code <= 57);
|
|
15
|
+
}
|
|
16
|
+
export function isIdentStart(ch) {
|
|
17
|
+
return ch.length > 0 && isIdentCharCode(ch.charCodeAt(0));
|
|
18
|
+
}
|
|
19
|
+
export function isIdentChar(ch) {
|
|
20
|
+
return ch.length > 0 && isIdentCharCode(ch.charCodeAt(0));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* True when `text` (ignoring leading whitespace) begins with the whole
|
|
24
|
+
* identifier `ident` — the character after it is not an identifier char,
|
|
25
|
+
* and the character before its start is not an identifier char either.
|
|
26
|
+
*/
|
|
27
|
+
export function startsWithIdentifier(text, ident) {
|
|
28
|
+
let i = 0;
|
|
29
|
+
while (i < text.length && isWhitespaceChar(text[i]))
|
|
30
|
+
i++;
|
|
31
|
+
if (text.slice(i, i + ident.length) !== ident)
|
|
32
|
+
return false;
|
|
33
|
+
if (i > 0 && isIdentChar(text[i - 1]))
|
|
34
|
+
return false;
|
|
35
|
+
const after = i + ident.length;
|
|
36
|
+
return after >= text.length || !isIdentChar(text[after]);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Strips a leading `const` / `let` / `var` keyword (plus surrounding
|
|
40
|
+
* whitespace) from a declaration prefix. Returns the remainder or the
|
|
41
|
+
* input unchanged when no keyword is present.
|
|
42
|
+
*/
|
|
43
|
+
export function stripDeclKeyword(text) {
|
|
44
|
+
for (const kw of ['const', 'let', 'var']) {
|
|
45
|
+
if (startsWithIdentifier(text, kw)) {
|
|
46
|
+
let i = 0;
|
|
47
|
+
while (i < text.length && isWhitespaceChar(text[i]))
|
|
48
|
+
i++;
|
|
49
|
+
i += kw.length;
|
|
50
|
+
while (i < text.length && isWhitespaceChar(text[i]))
|
|
51
|
+
i++;
|
|
52
|
+
return text.slice(i);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Removes trailing semicolons (and whitespace between them) from `text`.
|
|
59
|
+
*/
|
|
60
|
+
export function stripTrailingSemicolons(text) {
|
|
61
|
+
let end = text.length;
|
|
62
|
+
while (end > 0) {
|
|
63
|
+
const ch = text[end - 1];
|
|
64
|
+
if (ch === ';') {
|
|
65
|
+
end--;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (isWhitespaceChar(ch)) {
|
|
69
|
+
end--;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
return text.slice(0, end);
|
|
75
|
+
}
|
|
76
|
+
export function skipWhitespace(text, i) {
|
|
77
|
+
while (i < text.length && isWhitespaceChar(text[i]))
|
|
78
|
+
i++;
|
|
79
|
+
return i;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Collapses runs starting at a newline into a single space (JSX text
|
|
83
|
+
* normalization): every `\n` plus any following whitespace becomes `' '`.
|
|
84
|
+
*/
|
|
85
|
+
export function collapseNewlineWhitespace(text) {
|
|
86
|
+
let out = '';
|
|
87
|
+
let i = 0;
|
|
88
|
+
while (i < text.length) {
|
|
89
|
+
const c = text[i];
|
|
90
|
+
if (c === '\n') {
|
|
91
|
+
out += ' ';
|
|
92
|
+
while (i < text.length && isWhitespaceChar(text[i]))
|
|
93
|
+
i++;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
out += c;
|
|
97
|
+
i++;
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Skips a string starting at `i` (`"`, `'` or `` ` `` — backticks keep
|
|
103
|
+
* nested `${...}` template depth). Returns the index just past the closing
|
|
104
|
+
* quote, or `text.length` when unterminated.
|
|
105
|
+
*/
|
|
106
|
+
export function skipString(text, i) {
|
|
107
|
+
const quote = text[i];
|
|
108
|
+
if (quote !== '"' && quote !== "'" && quote !== '`')
|
|
109
|
+
return i;
|
|
110
|
+
let j = i + 1;
|
|
111
|
+
if (quote === '`') {
|
|
112
|
+
let depth = 0;
|
|
113
|
+
while (j < text.length) {
|
|
114
|
+
const c = text[j];
|
|
115
|
+
if (c === '\\') {
|
|
116
|
+
j += 2;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (c === '$' && text[j + 1] === '{') {
|
|
120
|
+
depth++;
|
|
121
|
+
j += 2;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (c === '}' && depth > 0) {
|
|
125
|
+
depth--;
|
|
126
|
+
j++;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (c === '`' && depth === 0)
|
|
130
|
+
return j + 1;
|
|
131
|
+
j++;
|
|
132
|
+
}
|
|
133
|
+
return text.length;
|
|
134
|
+
}
|
|
135
|
+
while (j < text.length) {
|
|
136
|
+
if (text[j] === '\\') {
|
|
137
|
+
j += 2;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (text[j] === quote)
|
|
141
|
+
return j + 1;
|
|
142
|
+
j++;
|
|
143
|
+
}
|
|
144
|
+
return text.length;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Skips a `//` or `/* ... */` comment starting at `i`. Returns the index
|
|
148
|
+
* just past the comment (past the newline for `//`), or `i` when no
|
|
149
|
+
* comment starts here.
|
|
150
|
+
*/
|
|
151
|
+
export function skipComment(text, i) {
|
|
152
|
+
if (text[i] === '/' && text[i + 1] === '/') {
|
|
153
|
+
let j = i + 2;
|
|
154
|
+
while (j < text.length && text[j] !== '\n')
|
|
155
|
+
j++;
|
|
156
|
+
return j;
|
|
157
|
+
}
|
|
158
|
+
if (text[i] === '/' && text[i + 1] === '*') {
|
|
159
|
+
let j = i + 2;
|
|
160
|
+
while (j < text.length && !(text[j] === '*' && text[j + 1] === '/'))
|
|
161
|
+
j++;
|
|
162
|
+
return Math.min(j + 2, text.length);
|
|
163
|
+
}
|
|
164
|
+
return i;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Given the index of an opening `(`, `[` or `{`, returns the index of its
|
|
168
|
+
* matching closing delimiter. Strings, `//` and `/* ... */` comments are
|
|
169
|
+
* skipped so delimiters inside them do not count. Returns `text.length`
|
|
170
|
+
* when the block is unterminated.
|
|
171
|
+
*/
|
|
172
|
+
export function findBalancedEnd(text, openIndex) {
|
|
173
|
+
const open = text[openIndex];
|
|
174
|
+
const close = open === '(' ? ')' : open === '[' ? ']' : open === '{' ? '}' : null;
|
|
175
|
+
if (close === null)
|
|
176
|
+
return openIndex;
|
|
177
|
+
let depth = 0;
|
|
178
|
+
let i = openIndex;
|
|
179
|
+
while (i < text.length) {
|
|
180
|
+
const c = text[i];
|
|
181
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
182
|
+
i = skipString(text, i);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (c === '/' && (text[i + 1] === '/' || text[i + 1] === '*')) {
|
|
186
|
+
i = skipComment(text, i);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (c === open)
|
|
190
|
+
depth++;
|
|
191
|
+
else if (c === close) {
|
|
192
|
+
depth--;
|
|
193
|
+
if (depth === 0)
|
|
194
|
+
return i;
|
|
195
|
+
}
|
|
196
|
+
i++;
|
|
197
|
+
}
|
|
198
|
+
return text.length;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Splits `text` on every whole-identifier occurrence of `sep` that sits at
|
|
202
|
+
* bracket depth 0, outside strings and comments. The identifier must be a
|
|
203
|
+
* complete word (non-identifier characters on both sides), so `of` matches
|
|
204
|
+
* `for (x of y)` but not `xoff` or `info`. The surrounding separator text
|
|
205
|
+
* is not included in the parts.
|
|
206
|
+
*/
|
|
207
|
+
export function splitTopLevel(text, sep) {
|
|
208
|
+
const parts = [];
|
|
209
|
+
let depth = 0;
|
|
210
|
+
let last = 0;
|
|
211
|
+
let i = 0;
|
|
212
|
+
while (i < text.length) {
|
|
213
|
+
const c = text[i];
|
|
214
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
215
|
+
i = skipString(text, i);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (c === '/' && (text[i + 1] === '/' || text[i + 1] === '*')) {
|
|
219
|
+
i = skipComment(text, i);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (c === '(' || c === '[' || c === '{')
|
|
223
|
+
depth++;
|
|
224
|
+
else if (c === ')' || c === ']' || c === '}') {
|
|
225
|
+
if (depth > 0)
|
|
226
|
+
depth--;
|
|
227
|
+
}
|
|
228
|
+
else if (depth === 0 && c === sep[0] && text.slice(i, i + sep.length) === sep) {
|
|
229
|
+
const before = i === 0 ? ' ' : text[i - 1];
|
|
230
|
+
const after = i + sep.length < text.length ? text[i + sep.length] : ' ';
|
|
231
|
+
if (!isIdentChar(before) && !isIdentChar(after)) {
|
|
232
|
+
parts.push(text.slice(last, i).trimEnd());
|
|
233
|
+
i += sep.length;
|
|
234
|
+
while (i < text.length && isWhitespaceChar(text[i]))
|
|
235
|
+
i++;
|
|
236
|
+
last = i;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
i++;
|
|
241
|
+
}
|
|
242
|
+
parts.push(text.slice(last));
|
|
243
|
+
return parts;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* True when `text` contains a `,` at bracket depth 0, outside strings and
|
|
247
|
+
* comments — i.e. a genuine multi-expression sequence rather than commas
|
|
248
|
+
* inside a call, object literal or parameter list.
|
|
249
|
+
*/
|
|
250
|
+
export function hasTopLevelComma(text) {
|
|
251
|
+
let depth = 0;
|
|
252
|
+
let i = 0;
|
|
253
|
+
while (i < text.length) {
|
|
254
|
+
const c = text[i];
|
|
255
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
256
|
+
i = skipString(text, i);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (c === '/' && (text[i + 1] === '/' || text[i + 1] === '*')) {
|
|
260
|
+
i = skipComment(text, i);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (c === '(' || c === '[' || c === '{')
|
|
264
|
+
depth++;
|
|
265
|
+
else if (c === ')' || c === ']' || c === '}') {
|
|
266
|
+
if (depth > 0)
|
|
267
|
+
depth--;
|
|
268
|
+
}
|
|
269
|
+
else if (depth === 0 && c === ',') {
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
i++;
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* True when `text` contains a whole-identifier `of` or `in` at bracket
|
|
278
|
+
* depth 0, outside strings and comments — used to tell `for (... of ...)`
|
|
279
|
+
* and `for (... in ...)` headers apart from classic `for` loops.
|
|
280
|
+
*/
|
|
281
|
+
export function containsForOfIn(text) {
|
|
282
|
+
let depth = 0;
|
|
283
|
+
let i = 0;
|
|
284
|
+
while (i < text.length) {
|
|
285
|
+
const c = text[i];
|
|
286
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
287
|
+
i = skipString(text, i);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (c === '/' && (text[i + 1] === '/' || text[i + 1] === '*')) {
|
|
291
|
+
i = skipComment(text, i);
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (c === '(' || c === '[' || c === '{')
|
|
295
|
+
depth++;
|
|
296
|
+
else if (c === ')' || c === ']' || c === '}') {
|
|
297
|
+
if (depth > 0)
|
|
298
|
+
depth--;
|
|
299
|
+
}
|
|
300
|
+
else if (depth === 0 && (c === 'o' || c === 'i') && (text.slice(i, i + 2) === 'of' || text.slice(i, i + 2) === 'in')) {
|
|
301
|
+
const before = i === 0 ? ' ' : text[i - 1];
|
|
302
|
+
const after = i + 2 < text.length ? text[i + 2] : ' ';
|
|
303
|
+
if (!isIdentChar(before) && !isIdentChar(after))
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
i++;
|
|
307
|
+
}
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Extracts the argument text of a `track<...>(...)` call from an init
|
|
312
|
+
* expression. Handles nested generics (`track<Map<string, number>>(...)`)
|
|
313
|
+
* and balanced parens in the argument. Returns the inner expression text,
|
|
314
|
+
* or the original input when the text is not a whole `track(...)` call.
|
|
315
|
+
*/
|
|
316
|
+
export function unwrapTrackCall(init) {
|
|
317
|
+
const text = init.trim();
|
|
318
|
+
if (!startsWithIdentifier(text, 'track'))
|
|
319
|
+
return init;
|
|
320
|
+
let i = skipWhitespace(text, 5);
|
|
321
|
+
if (text[i] === '<') {
|
|
322
|
+
i = skipTrackGeneric(text, i);
|
|
323
|
+
i = skipWhitespace(text, i);
|
|
324
|
+
}
|
|
325
|
+
if (text[i] !== '(')
|
|
326
|
+
return init;
|
|
327
|
+
const end = findBalancedEnd(text, i);
|
|
328
|
+
if (skipWhitespace(text, end + 1) !== text.length)
|
|
329
|
+
return init;
|
|
330
|
+
return text.slice(i + 1, end);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Removes a leading `track<...>` generic clause from an init expression
|
|
334
|
+
* (client-side `track` calls have no generic args). Returns the input
|
|
335
|
+
* unchanged when it does not start with a `track<` generic.
|
|
336
|
+
*/
|
|
337
|
+
export function stripTrackGeneric(init) {
|
|
338
|
+
const text = init.trim();
|
|
339
|
+
if (!startsWithIdentifier(text, 'track'))
|
|
340
|
+
return init;
|
|
341
|
+
let i = skipWhitespace(text, 5);
|
|
342
|
+
if (text[i] !== '<')
|
|
343
|
+
return init;
|
|
344
|
+
const end = skipTrackGeneric(text, i);
|
|
345
|
+
return text.slice(0, i) + text.slice(end);
|
|
346
|
+
}
|
|
347
|
+
export function skipTrackGeneric(text, open) {
|
|
348
|
+
let depth = 0;
|
|
349
|
+
let j = open;
|
|
350
|
+
while (j < text.length) {
|
|
351
|
+
const c = text[j];
|
|
352
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
353
|
+
j = skipString(text, j);
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
if (c === '<')
|
|
357
|
+
depth++;
|
|
358
|
+
else if (c === '>') {
|
|
359
|
+
depth--;
|
|
360
|
+
if (depth === 0)
|
|
361
|
+
return j + 1;
|
|
362
|
+
}
|
|
363
|
+
j++;
|
|
364
|
+
}
|
|
365
|
+
return text.length;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Scans a CSS block starting at `start` (an opening `{`) and returns the
|
|
369
|
+
* index just past its matching `}`. Quoted strings and `/* ... */`
|
|
370
|
+
* comments are skipped so braces inside them (e.g. `url("data:...{}")`)
|
|
371
|
+
* do not confuse the nesting count.
|
|
372
|
+
*/
|
|
373
|
+
export function cssBlockEnd(css, start) {
|
|
374
|
+
let depth = 0;
|
|
375
|
+
let i = start;
|
|
376
|
+
while (i < css.length) {
|
|
377
|
+
const c = css[i];
|
|
378
|
+
if (c === '"' || c === "'") {
|
|
379
|
+
i = skipString(css, i);
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (c === '/' && css[i + 1] === '*') {
|
|
383
|
+
i = skipComment(css, i);
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
if (c === '{')
|
|
387
|
+
depth++;
|
|
388
|
+
else if (c === '}') {
|
|
389
|
+
depth--;
|
|
390
|
+
if (depth === 0)
|
|
391
|
+
return i + 1;
|
|
392
|
+
}
|
|
393
|
+
i++;
|
|
394
|
+
}
|
|
395
|
+
return css.length;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Given the index of a `<` in HTML, returns the index just past the
|
|
399
|
+
* matching `>` — `>` inside quoted attribute values is not treated as a
|
|
400
|
+
* delimiter. Returns `-1` when the tag is unterminated.
|
|
401
|
+
*/
|
|
402
|
+
export function htmlTagEnd(html, lt) {
|
|
403
|
+
let i = lt + 1;
|
|
404
|
+
while (i < html.length) {
|
|
405
|
+
const c = html[i];
|
|
406
|
+
if (c === '"' || c === "'") {
|
|
407
|
+
i = skipString(html, i);
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
if (c === '>')
|
|
411
|
+
return i + 1;
|
|
412
|
+
i++;
|
|
413
|
+
}
|
|
414
|
+
return -1;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Reads the tag name of an HTML token like `<div`, `</span>` or `<my-el`.
|
|
418
|
+
* Returns `null` when the token is not a tag. The tag name itself cannot
|
|
419
|
+
* contain quotes or `>` so a simple character scan suffices.
|
|
420
|
+
*/
|
|
421
|
+
export function htmlTagName(token) {
|
|
422
|
+
let i = 0;
|
|
423
|
+
if (token[i] !== '<')
|
|
424
|
+
return null;
|
|
425
|
+
i++;
|
|
426
|
+
if (token[i] === '/')
|
|
427
|
+
i++;
|
|
428
|
+
const start = i;
|
|
429
|
+
while (i < token.length) {
|
|
430
|
+
const code = token.charCodeAt(i);
|
|
431
|
+
if ((code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code === 45) {
|
|
432
|
+
i++;
|
|
433
|
+
}
|
|
434
|
+
else
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
return i > start ? token.slice(start, i) : null;
|
|
438
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { setRuntimeModule, prettifyHtml, isStatic, escapeHtml, raw, exprJS, tryEvalExpr, childrenToHTML, extractTopLevelNames, extractRuntimeNames, buildParamInit, resolveComponentName, loadRuntimeImports, evalTopLevelCode, callStaticProps, callLoadFunction, __vskHydrate, __vskId, __vskImportedNames, resetVskState, setVskHydrate, setVskImportedNames, securityHeaders, corsHeaders, corsPreflight, csrfToken, verifyCsrfToken, csrfGuard, signCookie, unsignCookie, setSignedCookie, readSignedCookie, securityComment, redactLog, setRedactLogging, createRateLimiter, getClientIp, getClientProtocol, applyTrustProxy, } from '@vesk/compiler/src/server-utils';
|
|
2
|
+
export { renderHeadHtml, mergeHeadHtml, } from '@vesk/compiler/src/server-head';
|
|
3
|
+
export { irNodeToJS, generateFunctionBody, buildComponentMap, } from '@vesk/compiler/src/server-jsgen';
|
|
4
|
+
export { compileFile, render, renderPage, ssg, renderFullPage, renderPageStream, buildDataScripts, } from '@vesk/compiler/src/server-render';
|
|
5
|
+
//# sourceMappingURL=server-codegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-codegen.d.ts","sourceRoot":"","sources":["../src/server-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,GAAG,EACH,MAAM,EACN,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,aAAa,EACb,SAAS,EACT,eAAe,EACf,SAAS,EACT,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,cAAc,EACd,aAAa,GACd,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,WAAW,EACX,MAAM,EACN,UAAU,EACV,GAAG,EACH,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { setRuntimeModule, prettifyHtml, isStatic, escapeHtml, raw, exprJS, tryEvalExpr, childrenToHTML, extractTopLevelNames, extractRuntimeNames, buildParamInit, resolveComponentName, loadRuntimeImports, evalTopLevelCode, callStaticProps, callLoadFunction, __vskHydrate, __vskId, __vskImportedNames, resetVskState, setVskHydrate, setVskImportedNames, securityHeaders, corsHeaders, corsPreflight, csrfToken, verifyCsrfToken, csrfGuard, signCookie, unsignCookie, setSignedCookie, readSignedCookie, securityComment, redactLog, setRedactLogging, createRateLimiter, getClientIp, getClientProtocol, applyTrustProxy, } from '@vesk/compiler/src/server-utils';
|
|
2
|
+
export { renderHeadHtml, mergeHeadHtml, } from '@vesk/compiler/src/server-head';
|
|
3
|
+
export { irNodeToJS, generateFunctionBody, buildComponentMap, } from '@vesk/compiler/src/server-jsgen';
|
|
4
|
+
export { compileFile, render, renderPage, ssg, renderFullPage, renderPageStream, buildDataScripts, } from '@vesk/compiler/src/server-render';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-cookies.d.ts","sourceRoot":"","sources":["../src/server-cookies.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWhE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function parseCookies(str) {
|
|
2
|
+
const obj = {};
|
|
3
|
+
if (!str)
|
|
4
|
+
return obj;
|
|
5
|
+
for (const pair of str.split(';')) {
|
|
6
|
+
const eq = pair.indexOf('=');
|
|
7
|
+
if (eq === -1)
|
|
8
|
+
continue;
|
|
9
|
+
const k = pair.slice(0, eq).trim();
|
|
10
|
+
const v = pair.slice(eq + 1).trim();
|
|
11
|
+
if (k)
|
|
12
|
+
obj[k] = v;
|
|
13
|
+
}
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ComponentIR } from '@vesk/compiler/src/ir';
|
|
2
|
+
export declare function renderHeadHtml(comp: ComponentIR, props?: Record<string, unknown>): string;
|
|
3
|
+
export declare function mergeHeadHtml(pageHead: string, layoutHead: string): {
|
|
4
|
+
html: string;
|
|
5
|
+
conflicts: Array<{
|
|
6
|
+
key: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=server-head.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-head.d.ts","sourceRoot":"","sources":["../src/server-head.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AA+GzD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,MAAM,CAe7F;AAmFD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CA6DxI"}
|