@vesk/compiler 0.2.42 → 0.2.44
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/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +17 -1
- package/dist/client-codegen.d.ts +25 -0
- package/dist/client-codegen.d.ts.map +1 -1
- package/dist/client-codegen.js +225 -15
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +36 -0
- package/dist/ir-generator.d.ts.map +1 -1
- package/dist/ir-generator.js +466 -199
- package/dist/ir.d.ts +22 -1
- package/dist/ir.d.ts.map +1 -1
- package/dist/ir.js +18 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +25 -1
- package/dist/precompile-runtime.d.ts.map +1 -1
- package/dist/precompile-runtime.js +4 -0
- package/dist/precompile.js +6 -2
- package/dist/server-jsgen.d.ts.map +1 -1
- package/dist/server-jsgen.js +8 -1
- package/dist/server-render.d.ts.map +1 -1
- package/dist/server-render.js +138 -56
- package/dist/server-utils.d.ts.map +1 -1
- package/dist/server-utils.js +33 -5
- package/dist/ssr-store.d.ts +60 -0
- package/dist/ssr-store.d.ts.map +1 -1
- package/dist/ssr-store.js +157 -6
- package/dist/tokens.d.ts +28 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +200 -19
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vesk-plugin.d.ts +2 -0
- package/dist/vesk-plugin.d.ts.map +1 -1
- package/dist/vesk-plugin.js +28 -1
- package/dist/vsk-collision.d.ts +44 -0
- package/dist/vsk-collision.d.ts.map +1 -0
- package/dist/vsk-collision.js +73 -0
- package/dist/vsk-imports.d.ts +51 -0
- package/dist/vsk-imports.d.ts.map +1 -1
- package/dist/vsk-imports.js +106 -9
- package/package.json +2 -2
package/dist/server-utils.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as __defaultRuntimeModule from '@vesk/runtime/src/index-server';
|
|
|
3
3
|
import { parse } from '@vesk/compiler/src/parser';
|
|
4
4
|
import { generateIR } from '@vesk/compiler/src/ir-generator';
|
|
5
5
|
import { htmlTagName, htmlTagEnd } from '@vesk/compiler/src/scan';
|
|
6
|
-
import { importModuleTarget, extractImportNames } from '@vesk/compiler/src/tokens';
|
|
6
|
+
import { importModuleTarget, extractImportNames, stripTrackDeclMarkers } from '@vesk/compiler/src/tokens';
|
|
7
7
|
const VOID_ELEMENTS = new Set([
|
|
8
8
|
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr',
|
|
9
9
|
]);
|
|
@@ -1124,6 +1124,18 @@ export function loadRuntimeImports(importStrs) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
return {};
|
|
1126
1126
|
}
|
|
1127
|
+
/** Binding name of one TrackDecl pattern element, or null for a hole. */
|
|
1128
|
+
function patternElementName(element) {
|
|
1129
|
+
if (!element)
|
|
1130
|
+
return null;
|
|
1131
|
+
if (element.type === 'Identifier')
|
|
1132
|
+
return element.name;
|
|
1133
|
+
if (element.type === 'AssignmentPattern' && element.left)
|
|
1134
|
+
return patternElementName(element.left);
|
|
1135
|
+
if (element.type === 'RestElement' && element.argument)
|
|
1136
|
+
return patternElementName(element.argument);
|
|
1137
|
+
return null;
|
|
1138
|
+
}
|
|
1127
1139
|
export function evalTopLevelCode(topLevelCode, __vesk) {
|
|
1128
1140
|
for (const code of topLevelCode) {
|
|
1129
1141
|
const ast = tryParseTopLevel(code);
|
|
@@ -1135,9 +1147,19 @@ export function evalTopLevelCode(topLevelCode, __vesk) {
|
|
|
1135
1147
|
continue;
|
|
1136
1148
|
if (target.type === 'VariableDeclaration') {
|
|
1137
1149
|
for (const d of target.declarations) {
|
|
1138
|
-
if (!d.id
|
|
1150
|
+
if (!d.id)
|
|
1151
|
+
continue;
|
|
1152
|
+
// A TrackDecl declarator's `id` is the parser's `lazy` ArrayPattern
|
|
1153
|
+
// (`const &[count, rawCell] = track(0)`), not an Identifier. Its
|
|
1154
|
+
// initializer yields a TUPLE, so each name takes its own index —
|
|
1155
|
+
// the whole value is not bound to every name.
|
|
1156
|
+
const isTrack = d.id.type === 'ArrayPattern' && d.id.lazy === true;
|
|
1157
|
+
const names = isTrack
|
|
1158
|
+
? (d.id.elements || []).map(patternElementName)
|
|
1159
|
+
: d.id.type === 'Identifier' ? [d.id.name] : [];
|
|
1160
|
+
if (names.every((n) => n === null))
|
|
1139
1161
|
continue;
|
|
1140
|
-
const initSrc = d.init ? code.slice(d.init.start, d.init.end) : 'undefined';
|
|
1162
|
+
const initSrc = d.init ? stripTrackDeclMarkers(code.slice(d.init.start, d.init.end), d.init.start, d.init) : 'undefined';
|
|
1141
1163
|
try {
|
|
1142
1164
|
const keys = Object.keys(__vesk);
|
|
1143
1165
|
const params = [...keys, '__vesk', 'result'];
|
|
@@ -1145,7 +1167,13 @@ export function evalTopLevelCode(topLevelCode, __vesk) {
|
|
|
1145
1167
|
const fn = new Function(...params, body);
|
|
1146
1168
|
const result = { value: undefined };
|
|
1147
1169
|
fn(...keys.map(k => __vesk[k]), __vesk, result);
|
|
1148
|
-
|
|
1170
|
+
names.forEach((name, i) => {
|
|
1171
|
+
if (name === null)
|
|
1172
|
+
return;
|
|
1173
|
+
__vesk[name] = isTrack
|
|
1174
|
+
? (Array.isArray(result.value) ? result.value[i] : undefined)
|
|
1175
|
+
: result.value;
|
|
1176
|
+
});
|
|
1149
1177
|
}
|
|
1150
1178
|
catch {
|
|
1151
1179
|
// skip evaluation errors
|
|
@@ -1160,7 +1188,7 @@ export function evalTopLevelCode(topLevelCode, __vesk) {
|
|
|
1160
1188
|
const paramSrc = target.params.length
|
|
1161
1189
|
? code.slice(target.params[0].start, target.params[target.params.length - 1].end)
|
|
1162
1190
|
: '';
|
|
1163
|
-
const bodySrc = code.slice(target.body.start, target.body.end);
|
|
1191
|
+
const bodySrc = stripTrackDeclMarkers(code.slice(target.body.start, target.body.end), target.body.start, target.body);
|
|
1164
1192
|
const asyncKw = target.async ? 'async ' : '';
|
|
1165
1193
|
const fn = new Function(...params, `__vesk['${target.id.name}'] = ${asyncKw}function ${target.id.name}(${paramSrc}) ${bodySrc};`);
|
|
1166
1194
|
fn(...keys.map(k => __vesk[k]), __vesk);
|
package/dist/ssr-store.d.ts
CHANGED
|
@@ -1,4 +1,64 @@
|
|
|
1
1
|
import type { SsrDataSink } from '@vesk/runtime/src/resource';
|
|
2
|
+
export interface SsrStore {
|
|
3
|
+
/** Per-request token. Keyed data slots hang off this, so it must be unique
|
|
4
|
+
* per concurrent render — a shared token lets a finishing render delete a
|
|
5
|
+
* stranger's data slot. */
|
|
6
|
+
token?: string;
|
|
7
|
+
/** Handoff data for the current request. */
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A store that is not yet attached to a scope. Callers that drive several
|
|
12
|
+
* scopes (streaming renders) own it and hand it to `withSsrStoreOf` so the
|
|
13
|
+
* token and sink survive across the boundary.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSsrStore(): SsrStore;
|
|
16
|
+
/**
|
|
17
|
+
* The store for the current request: the ambient one when a scope is already
|
|
18
|
+
* open, otherwise a fresh caller-owned one. Callers that outlive a single
|
|
19
|
+
* `withSsrStore` (streaming renders drive chunks from the consumer, long after
|
|
20
|
+
* the scope's promise resolved) use this so their work still lands on the
|
|
21
|
+
* request's token instead of minting a second one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function adoptSsrStore(): SsrStore;
|
|
24
|
+
/**
|
|
25
|
+
* Run `fn` in a request scope, reusing the ambient store when one is open.
|
|
26
|
+
*
|
|
27
|
+
* The scope owns a claim on its token for its whole lifetime, which is what
|
|
28
|
+
* keeps a request's data slot reap-exempt between its stages. A request runs
|
|
29
|
+
* `renderPage` (page) -> `renderPage` (each nested layout) -> `renderFullPage`
|
|
30
|
+
* (document), and each of those claims and releases the slot on entry/exit.
|
|
31
|
+
* Without the scope-level claim the token is briefly unowned between stages, so
|
|
32
|
+
* with more than ~40 renders in flight a concurrent reaper sees the slot as
|
|
33
|
+
* abandoned and deletes the data the document render still has to serialize.
|
|
34
|
+
*/
|
|
2
35
|
export declare function withSsrStore<T>(fn: () => T): T;
|
|
36
|
+
/**
|
|
37
|
+
* Run `fn` in a scope backed by a caller-owned store, so the token and the sink
|
|
38
|
+
* survive across `yield`s. Streaming renders need this: each `next()` is driven
|
|
39
|
+
* by the consumer, not by the generator, so a per-`next()` `withSsrStore` would
|
|
40
|
+
* mint a new token every chunk and every data slot written by an earlier chunk
|
|
41
|
+
* would be orphaned.
|
|
42
|
+
*/
|
|
43
|
+
export declare function withSsrStoreOf<T>(store: SsrStore, fn: () => T): T;
|
|
44
|
+
/** The current request's token, or undefined outside a render scope. */
|
|
45
|
+
export declare function currentSsrToken(): string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Mint a fresh token for the current scope. Used by the dev servers' data-nav
|
|
48
|
+
* path, which renders several routes within one request and must not let an
|
|
49
|
+
* earlier route's slot settle into a later one.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resetSsrToken(): string;
|
|
52
|
+
/** Claim a token's data slot so the reaper never deletes it mid-render. */
|
|
53
|
+
export declare function keepSsrSlot(token: string | undefined): void;
|
|
54
|
+
/** Release one claim on a token's data slot. */
|
|
55
|
+
export declare function dropSsrSlot(token: string | undefined): void;
|
|
56
|
+
/**
|
|
57
|
+
* True while a render still owns this token's slot. Slots are keyed by
|
|
58
|
+
* per-request tokens, so a cap-based reaper that ignores ownership deletes a
|
|
59
|
+
* *concurrent* request's handoff and the second page ships with no ssr-data
|
|
60
|
+
* script — the original bug, just triggered by load instead of interleaving.
|
|
61
|
+
*/
|
|
62
|
+
export declare function isSsrSlotLive(token: string): boolean;
|
|
3
63
|
export declare const ssrSink: SsrDataSink;
|
|
4
64
|
//# sourceMappingURL=ssr-store.d.ts.map
|
package/dist/ssr-store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-store.d.ts","sourceRoot":"","sources":["../src/ssr-store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI9D,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"ssr-store.d.ts","sourceRoot":"","sources":["../src/ssr-store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAI9D,MAAM,WAAW,QAAQ;IACvB;;gCAE4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAkBD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,QAAQ,CAExC;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAuB9C;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAEjE;AAED,wEAAwE;AACxE,wBAAgB,eAAe,IAAI,MAAM,GAAG,SAAS,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAYtC;AAED,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAG3D;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAM3D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,eAAO,MAAM,OAAO,EAAE,WAgBrB,CAAC"}
|
package/dist/ssr-store.js
CHANGED
|
@@ -3,30 +3,181 @@ import { AsyncLocalStorage } from 'node:async_hooks';
|
|
|
3
3
|
// checkout the compiler typechecks BEFORE @vesk/runtime's dist exists, and
|
|
4
4
|
// resolving types through the barrel then fails.
|
|
5
5
|
import { setSsrSink } from '@vesk/runtime/src/index-server';
|
|
6
|
+
const TOKEN_KEY = '__vsk_ssr_token';
|
|
6
7
|
const storage = new AsyncLocalStorage();
|
|
8
|
+
/**
|
|
9
|
+
* Tokens whose `__vsk_ssr_data_<token>` slot a live render still owns, with a
|
|
10
|
+
* refcount. A request runs `renderPage` (page) -> `renderPage` (each nested
|
|
11
|
+
* layout) -> `renderFullPage` (document) inside ONE store, and each of those
|
|
12
|
+
* claims the slot on entry and releases it on exit. A plain Set would let the
|
|
13
|
+
* first inner release revoke the claim the document render still depends on,
|
|
14
|
+
* so the reaper could reap a live request's handoff. Counts balance instead.
|
|
15
|
+
*/
|
|
16
|
+
const liveSlots = new Map();
|
|
17
|
+
function newSsrToken() {
|
|
18
|
+
return Math.random().toString(36).slice(2);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A store that is not yet attached to a scope. Callers that drive several
|
|
22
|
+
* scopes (streaming renders) own it and hand it to `withSsrStoreOf` so the
|
|
23
|
+
* token and sink survive across the boundary.
|
|
24
|
+
*/
|
|
25
|
+
export function createSsrStore() {
|
|
26
|
+
return { token: newSsrToken(), data: {} };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The store for the current request: the ambient one when a scope is already
|
|
30
|
+
* open, otherwise a fresh caller-owned one. Callers that outlive a single
|
|
31
|
+
* `withSsrStore` (streaming renders drive chunks from the consumer, long after
|
|
32
|
+
* the scope's promise resolved) use this so their work still lands on the
|
|
33
|
+
* request's token instead of minting a second one.
|
|
34
|
+
*/
|
|
35
|
+
export function adoptSsrStore() {
|
|
36
|
+
return storage.getStore() ?? createSsrStore();
|
|
37
|
+
}
|
|
38
|
+
function isThenable(value) {
|
|
39
|
+
return typeof value?.then === 'function';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Run `fn` in a request scope, reusing the ambient store when one is open.
|
|
43
|
+
*
|
|
44
|
+
* The scope owns a claim on its token for its whole lifetime, which is what
|
|
45
|
+
* keeps a request's data slot reap-exempt between its stages. A request runs
|
|
46
|
+
* `renderPage` (page) -> `renderPage` (each nested layout) -> `renderFullPage`
|
|
47
|
+
* (document), and each of those claims and releases the slot on entry/exit.
|
|
48
|
+
* Without the scope-level claim the token is briefly unowned between stages, so
|
|
49
|
+
* with more than ~40 renders in flight a concurrent reaper sees the slot as
|
|
50
|
+
* abandoned and deletes the data the document render still has to serialize.
|
|
51
|
+
*/
|
|
7
52
|
export function withSsrStore(fn) {
|
|
8
53
|
const existing = storage.getStore();
|
|
9
54
|
if (existing)
|
|
10
55
|
return fn();
|
|
11
|
-
|
|
56
|
+
const store = createSsrStore();
|
|
57
|
+
keepSsrSlot(store.token);
|
|
58
|
+
let result;
|
|
59
|
+
try {
|
|
60
|
+
result = storage.run(store, fn);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
dropSsrSlot(store.token);
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
// A streaming render hands back a Response while its body is still pending;
|
|
67
|
+
// releasing on promise settlement is exactly right for both cases, because a
|
|
68
|
+
// render that outlives the scope claims the token itself (renderPageStream).
|
|
69
|
+
if (isThenable(result)) {
|
|
70
|
+
return result.then((value) => { dropSsrSlot(store.token); return value; }, (err) => { dropSsrSlot(store.token); throw err; });
|
|
71
|
+
}
|
|
72
|
+
dropSsrSlot(store.token);
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Run `fn` in a scope backed by a caller-owned store, so the token and the sink
|
|
77
|
+
* survive across `yield`s. Streaming renders need this: each `next()` is driven
|
|
78
|
+
* by the consumer, not by the generator, so a per-`next()` `withSsrStore` would
|
|
79
|
+
* mint a new token every chunk and every data slot written by an earlier chunk
|
|
80
|
+
* would be orphaned.
|
|
81
|
+
*/
|
|
82
|
+
export function withSsrStoreOf(store, fn) {
|
|
83
|
+
return storage.run(store, fn);
|
|
84
|
+
}
|
|
85
|
+
/** The current request's token, or undefined outside a render scope. */
|
|
86
|
+
export function currentSsrToken() {
|
|
87
|
+
return storage.getStore()?.token;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Mint a fresh token for the current scope. Used by the dev servers' data-nav
|
|
91
|
+
* path, which renders several routes within one request and must not let an
|
|
92
|
+
* earlier route's slot settle into a later one.
|
|
93
|
+
*/
|
|
94
|
+
export function resetSsrToken() {
|
|
95
|
+
const store = storage.getStore();
|
|
96
|
+
const token = newSsrToken();
|
|
97
|
+
if (store) {
|
|
98
|
+
if (store.token)
|
|
99
|
+
liveSlots.delete(store.token);
|
|
100
|
+
store.token = token;
|
|
101
|
+
}
|
|
102
|
+
// The caller owns the request from here, so hold the claim for the whole
|
|
103
|
+
// scope: nested page/layout renders each add and remove their own count, and
|
|
104
|
+
// this one keeps the slot reap-exempt until the caller is done with it.
|
|
105
|
+
liveSlots.set(token, 1);
|
|
106
|
+
return token;
|
|
107
|
+
}
|
|
108
|
+
/** Claim a token's data slot so the reaper never deletes it mid-render. */
|
|
109
|
+
export function keepSsrSlot(token) {
|
|
110
|
+
if (!token)
|
|
111
|
+
return;
|
|
112
|
+
liveSlots.set(token, (liveSlots.get(token) ?? 0) + 1);
|
|
113
|
+
}
|
|
114
|
+
/** Release one claim on a token's data slot. */
|
|
115
|
+
export function dropSsrSlot(token) {
|
|
116
|
+
if (!token)
|
|
117
|
+
return;
|
|
118
|
+
const count = liveSlots.get(token);
|
|
119
|
+
if (count === undefined)
|
|
120
|
+
return;
|
|
121
|
+
if (count <= 1)
|
|
122
|
+
liveSlots.delete(token);
|
|
123
|
+
else
|
|
124
|
+
liveSlots.set(token, count - 1);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* True while a render still owns this token's slot. Slots are keyed by
|
|
128
|
+
* per-request tokens, so a cap-based reaper that ignores ownership deletes a
|
|
129
|
+
* *concurrent* request's handoff and the second page ships with no ssr-data
|
|
130
|
+
* script — the original bug, just triggered by load instead of interleaving.
|
|
131
|
+
*/
|
|
132
|
+
export function isSsrSlotLive(token) {
|
|
133
|
+
return liveSlots.has(token);
|
|
12
134
|
}
|
|
13
135
|
export const ssrSink = {
|
|
14
136
|
set: (key, value) => {
|
|
15
137
|
const store = storage.getStore();
|
|
16
138
|
if (store)
|
|
17
|
-
store[key] = value;
|
|
139
|
+
store.data[key] = value;
|
|
18
140
|
},
|
|
19
141
|
get: (key) => {
|
|
20
142
|
const store = storage.getStore();
|
|
21
|
-
return store ? store[key] : undefined;
|
|
143
|
+
return store ? store.data[key] : undefined;
|
|
22
144
|
},
|
|
23
|
-
snapshot: () => ({ ...(storage.getStore() ?? {}) }),
|
|
145
|
+
snapshot: () => ({ ...(storage.getStore()?.data ?? {}) }),
|
|
24
146
|
clear: () => {
|
|
25
147
|
const store = storage.getStore();
|
|
26
148
|
if (store) {
|
|
27
|
-
for (const key of Object.keys(store))
|
|
28
|
-
delete store[key];
|
|
149
|
+
for (const key of Object.keys(store.data))
|
|
150
|
+
delete store.data[key];
|
|
29
151
|
}
|
|
30
152
|
},
|
|
31
153
|
};
|
|
32
154
|
setSsrSink(ssrSink);
|
|
155
|
+
// The generated server code reads `globalThis.__vsk_ssr_token` synchronously
|
|
156
|
+
// at the top of every component render, and the runtime's promise tracker and
|
|
157
|
+
// data writers read it the same way. Back that global with the ALS store so
|
|
158
|
+
// those readers become request-scoped instead of process-global. Before this,
|
|
159
|
+
// two concurrent renders adopted the same token and whichever finished first
|
|
160
|
+
// deleted the other's data slot, so the second page shipped with an empty
|
|
161
|
+
// handoff and the client refetched what SSR already had.
|
|
162
|
+
//
|
|
163
|
+
// Outside a render scope the accessor reads/writes nothing, which is what
|
|
164
|
+
// keeps a stray write from leaking into the next request. Bundles that never
|
|
165
|
+
// load this module keep the plain global and the previous behaviour.
|
|
166
|
+
//
|
|
167
|
+
// NEVER `delete globalThis.__vsk_ssr_token`. This is a configurable accessor,
|
|
168
|
+
// so `delete` removes the property definition outright — it does not route
|
|
169
|
+
// through the setter — and the process silently falls back to a
|
|
170
|
+
// process-global token, reintroducing the race for every later request. Clear
|
|
171
|
+
// a token by assigning through `globalThis` inside a scope, or with
|
|
172
|
+
// `resetSsrToken`.
|
|
173
|
+
Object.defineProperty(globalThis, TOKEN_KEY, {
|
|
174
|
+
configurable: true,
|
|
175
|
+
get() {
|
|
176
|
+
return storage.getStore()?.token;
|
|
177
|
+
},
|
|
178
|
+
set(value) {
|
|
179
|
+
const store = storage.getStore();
|
|
180
|
+
if (store)
|
|
181
|
+
store.token = value;
|
|
182
|
+
},
|
|
183
|
+
});
|
package/dist/tokens.d.ts
CHANGED
|
@@ -47,4 +47,32 @@ export declare function extractImportNames(importText: string): string[];
|
|
|
47
47
|
* after `from` (or the bare side-effect string). `null` when none found.
|
|
48
48
|
*/
|
|
49
49
|
export declare function importModuleTarget(importText: string): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* True when `code` declares `name` as a real top-level value (`const`/`let`/
|
|
52
|
+
* `var`/`function`/`class`). Used to tell a `.vsk` component — a registry entry
|
|
53
|
+
* with no binding — apart from an ordinary JS/TS declaration, whose
|
|
54
|
+
* `export { name }` must keep native module semantics.
|
|
55
|
+
*/
|
|
56
|
+
export declare function hasTopLevelValueDeclaration(code: string, name: string): boolean;
|
|
57
|
+
/** One entry of a same-file `export { A, B as C }` specifier list. */
|
|
58
|
+
export interface VskSpecifierExport {
|
|
59
|
+
local: string;
|
|
60
|
+
exported: string;
|
|
61
|
+
/** Byte span of the whole `export { … }` statement, including any `;`. */
|
|
62
|
+
start: number;
|
|
63
|
+
end: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Finds same-file export *specifier lists* — `export { A }`, `export { A as B }`
|
|
67
|
+
* — and returns them with their source spans so the caller can remove them.
|
|
68
|
+
*
|
|
69
|
+
* A `.vsk` component is a registry entry keyed by its declared name, not a
|
|
70
|
+
* top-level binding, so acorn's module validator rejects `export { A }` with
|
|
71
|
+
* `Export 'A' is not defined`. Export *declarations* (`export component A`,
|
|
72
|
+
* `export const A = 1`) and re-exports (`export … from '…'`) are left alone:
|
|
73
|
+
* those parse fine and are handled in the IR generator.
|
|
74
|
+
*/
|
|
75
|
+
export declare function findSpecifierExports(code: string): VskSpecifierExport[];
|
|
76
|
+
/** `text` must be `source.slice(base, …)`; `node` is AST parsed from `source`. */
|
|
77
|
+
export declare function stripTrackDeclMarkers(text: string, base: number, node: any): string;
|
|
50
78
|
//# sourceMappingURL=tokens.d.ts.map
|
package/dist/tokens.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,IAAI,CA0B7D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CA2BlE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAStE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAqBxE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAuC/D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOpE;AAwID;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAkB/E;AAED,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAkCvE;AA6DD,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,MAAM,CAcnF"}
|
package/dist/tokens.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* unparsable text.
|
|
9
9
|
*/
|
|
10
10
|
import { createBaseParser } from '@vesk/compiler/src/parser';
|
|
11
|
+
import { withStandaloneTokens } from '@vesk/compiler/src/vesk-plugin';
|
|
11
12
|
import { skipString, skipComment, skipWhitespace, skipTrackGeneric, isIdentStart, isIdentChar, } from '@vesk/compiler/src/scan';
|
|
12
13
|
/**
|
|
13
14
|
* Tokenizes `code` with the Vesk parser's tokenizer. Returns an array of
|
|
@@ -16,27 +17,32 @@ import { skipString, skipComment, skipWhitespace, skipTrackGeneric, isIdentStart
|
|
|
16
17
|
* their span so callers can read the actual character via `code[start]`.
|
|
17
18
|
*/
|
|
18
19
|
export function tokenizeCode(code) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
out.push({
|
|
29
|
-
label: t.type.label,
|
|
30
|
-
value: typeof t.value === 'string' ? t.value : '',
|
|
31
|
-
start: t.start,
|
|
32
|
-
end: t.end,
|
|
20
|
+
// No parser runs here, so the plugin cannot infer component bodies from its
|
|
21
|
+
// own component-depth counter and every JSX tag would be read as relational
|
|
22
|
+
// operators. `withStandaloneTokens` asks it to read JSX tags directly.
|
|
23
|
+
return withStandaloneTokens(() => {
|
|
24
|
+
try {
|
|
25
|
+
const ParserClass = createBaseParser();
|
|
26
|
+
const tok = ParserClass.tokenizer(code, {
|
|
27
|
+
ecmaVersion: 'latest',
|
|
28
|
+
sourceType: 'module',
|
|
33
29
|
});
|
|
30
|
+
const out = [];
|
|
31
|
+
let t;
|
|
32
|
+
while ((t = tok.getToken()) && t.type && t.type.label !== 'eof') {
|
|
33
|
+
out.push({
|
|
34
|
+
label: t.type.label,
|
|
35
|
+
value: typeof t.value === 'string' ? t.value : '',
|
|
36
|
+
start: t.start,
|
|
37
|
+
end: t.end,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
34
41
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
40
46
|
}
|
|
41
47
|
/**
|
|
42
48
|
* Returns the set of identifiers in `code` that are called — an identifier
|
|
@@ -355,3 +361,178 @@ function manualExtractImportNames(importText) {
|
|
|
355
361
|
}
|
|
356
362
|
return names;
|
|
357
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* True when `code` declares `name` as a real top-level value (`const`/`let`/
|
|
366
|
+
* `var`/`function`/`class`). Used to tell a `.vsk` component — a registry entry
|
|
367
|
+
* with no binding — apart from an ordinary JS/TS declaration, whose
|
|
368
|
+
* `export { name }` must keep native module semantics.
|
|
369
|
+
*/
|
|
370
|
+
export function hasTopLevelValueDeclaration(code, name) {
|
|
371
|
+
const tokens = tokenizeCode(code);
|
|
372
|
+
if (tokens === null)
|
|
373
|
+
return false;
|
|
374
|
+
const declWords = ['const', 'let', 'var', 'function', 'class'];
|
|
375
|
+
for (let i = 1; i < tokens.length; i++) {
|
|
376
|
+
if (tokens[i].label !== 'name' || tokens[i].value !== name)
|
|
377
|
+
continue;
|
|
378
|
+
const prev = tokens[i - 1];
|
|
379
|
+
// Declaration keywords carry their own token label (`const`, `var`,
|
|
380
|
+
// `function`, `class`); `let` arrives as a plain name. Match on value.
|
|
381
|
+
if (!prev || !declWords.includes(prev.value))
|
|
382
|
+
continue;
|
|
383
|
+
// `export const X` / `export function X` are preceded by `export`.
|
|
384
|
+
if (i >= 2) {
|
|
385
|
+
const pp = tokens[i - 2];
|
|
386
|
+
if (pp && pp.label === 'name' && pp.value === 'export')
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Finds same-file export *specifier lists* — `export { A }`, `export { A as B }`
|
|
395
|
+
* — and returns them with their source spans so the caller can remove them.
|
|
396
|
+
*
|
|
397
|
+
* A `.vsk` component is a registry entry keyed by its declared name, not a
|
|
398
|
+
* top-level binding, so acorn's module validator rejects `export { A }` with
|
|
399
|
+
* `Export 'A' is not defined`. Export *declarations* (`export component A`,
|
|
400
|
+
* `export const A = 1`) and re-exports (`export … from '…'`) are left alone:
|
|
401
|
+
* those parse fine and are handled in the IR generator.
|
|
402
|
+
*/
|
|
403
|
+
export function findSpecifierExports(code) {
|
|
404
|
+
const tokens = tokenizeCode(code);
|
|
405
|
+
if (tokens === null)
|
|
406
|
+
return [];
|
|
407
|
+
const out = [];
|
|
408
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
409
|
+
if (tokens[i].label !== 'export')
|
|
410
|
+
continue;
|
|
411
|
+
// A specifier list starts with `{`. `export default`, `export const` and
|
|
412
|
+
// `export *` take another route and are left for the IR generator.
|
|
413
|
+
if (!tokens[i + 1] || tokens[i + 1].label !== '{')
|
|
414
|
+
continue;
|
|
415
|
+
// Find this statement's `}` and note any module source, which makes it a
|
|
416
|
+
// re-export (`export { A } from './x.vsk'`) rather than a specifier list.
|
|
417
|
+
let k = i + 2;
|
|
418
|
+
let depth = 1;
|
|
419
|
+
for (; k < tokens.length; k++) {
|
|
420
|
+
const lbl = tokens[k].label;
|
|
421
|
+
if (lbl === 'string') {
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
if (lbl === '{')
|
|
425
|
+
depth++;
|
|
426
|
+
else if (lbl === '}') {
|
|
427
|
+
depth--;
|
|
428
|
+
if (depth === 0)
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
// A re-export puts `from '…'` AFTER the closing brace, so check past it.
|
|
433
|
+
let isReexport = false;
|
|
434
|
+
for (let j = k + 1; j < tokens.length; j++) {
|
|
435
|
+
const lbl = tokens[j].label;
|
|
436
|
+
if (lbl === 'string') {
|
|
437
|
+
isReexport = true;
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
if (lbl === ';' || lbl === 'export' || lbl === 'import' || lbl === '}')
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
if (depth !== 0 || isReexport)
|
|
444
|
+
continue;
|
|
445
|
+
const pairs = readSpecifierPairs(code, tokens[i + 1].end, tokens[k].end);
|
|
446
|
+
if (pairs === null)
|
|
447
|
+
continue;
|
|
448
|
+
const stmtEnd = tokens[k].end;
|
|
449
|
+
for (const [local, exported] of pairs)
|
|
450
|
+
out.push({ local, exported, start: tokens[i].start, end: stmtEnd });
|
|
451
|
+
i = k;
|
|
452
|
+
}
|
|
453
|
+
return out;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Reads `A, B as C` pairs from the text between a `{` and its matching `}`.
|
|
457
|
+
* Returns `null` for anything that is not a plain (optionally `as`-aliased)
|
|
458
|
+
* identifier list, so unusual forms are left to the normal parser.
|
|
459
|
+
*/
|
|
460
|
+
function readSpecifierPairs(code, from, to) {
|
|
461
|
+
// Wrapped in parens so a leading `{` is a block, not the start of an object.
|
|
462
|
+
const tokens = tokenizeCode(`(${code.slice(from, to)})`);
|
|
463
|
+
if (tokens === null || tokens.length < 2)
|
|
464
|
+
return null;
|
|
465
|
+
const pairs = [];
|
|
466
|
+
let i = 1; // skip the '('
|
|
467
|
+
while (i < tokens.length) {
|
|
468
|
+
const local = tokens[i];
|
|
469
|
+
if (!local || local.label === ')' || local.label === ';')
|
|
470
|
+
break;
|
|
471
|
+
if (local.label !== 'name')
|
|
472
|
+
return null;
|
|
473
|
+
const asTok = tokens[i + 1];
|
|
474
|
+
if (asTok && asTok.label === 'name' && asTok.value === 'as') {
|
|
475
|
+
const exported = tokens[i + 2];
|
|
476
|
+
if (!exported || exported.label !== 'name')
|
|
477
|
+
return null;
|
|
478
|
+
pairs.push([local.value, exported.value]);
|
|
479
|
+
i += 3;
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
482
|
+
pairs.push([local.value, local.value]);
|
|
483
|
+
i += 1;
|
|
484
|
+
}
|
|
485
|
+
const sep = tokens[i];
|
|
486
|
+
if (!sep || sep.label !== ',')
|
|
487
|
+
break;
|
|
488
|
+
i += 1;
|
|
489
|
+
}
|
|
490
|
+
return pairs.length > 0 ? pairs : null;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* The Vesk TrackDecl form `const &[count] = track(0)` exists only for the
|
|
494
|
+
* parser: `VeskParserPlugin` consumes the `&` and returns an `ArrayPattern`
|
|
495
|
+
* tagged `lazy: true` whose `start` points at the `[`. The marker character
|
|
496
|
+
* itself survives in the source text, so every raw slice of that text is
|
|
497
|
+
* invalid JavaScript — `new Function` rejects it, and a browser rejects the
|
|
498
|
+
* whole module.
|
|
499
|
+
*
|
|
500
|
+
* Blank exactly those marker characters. Offsets come from the already parsed
|
|
501
|
+
* AST (each `lazy` pattern's `start - 1`), never from a text scan.
|
|
502
|
+
*/
|
|
503
|
+
function collectTrackDeclMarkers(node, out) {
|
|
504
|
+
if (!node || typeof node !== 'object')
|
|
505
|
+
return;
|
|
506
|
+
if (Array.isArray(node)) {
|
|
507
|
+
for (const child of node)
|
|
508
|
+
collectTrackDeclMarkers(child, out);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (node.type === 'ArrayPattern' && node.lazy === true && typeof node.start === 'number') {
|
|
512
|
+
out.add(node.start - 1);
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
for (const key of Object.keys(node)) {
|
|
516
|
+
const value = node[key];
|
|
517
|
+
if (value && typeof value === 'object')
|
|
518
|
+
collectTrackDeclMarkers(value, out);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
/** `text` must be `source.slice(base, …)`; `node` is AST parsed from `source`. */
|
|
522
|
+
export function stripTrackDeclMarkers(text, base, node) {
|
|
523
|
+
const offsets = new Set();
|
|
524
|
+
collectTrackDeclMarkers(node, offsets);
|
|
525
|
+
if (offsets.size === 0)
|
|
526
|
+
return text;
|
|
527
|
+
const sorted = [...offsets].sort((a, b) => a - b);
|
|
528
|
+
let out = '';
|
|
529
|
+
let prev = 0;
|
|
530
|
+
for (const offset of sorted) {
|
|
531
|
+
const i = offset - base;
|
|
532
|
+
if (i < prev || i >= text.length)
|
|
533
|
+
continue;
|
|
534
|
+
out += text.slice(prev, i) + ' ';
|
|
535
|
+
prev = i + 1;
|
|
536
|
+
}
|
|
537
|
+
return out + text.slice(prev);
|
|
538
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IRRoot } from '@vesk/compiler/src/ir';
|
|
2
|
-
export type { RouteNode, ApiRouteNode, MiddlewareContext, ServerEventContext, VeskEventHandlers, VeskPlugin, VeskCors, VeskRateLimit, VeskSecurityPreset, VeskSecurity, VeskConfig, MdConfig, MdHtmlMode, MdProps, MarkdownOptions, MdHtmlWarning, MiddlewareEntry, MiddlewareChainOptions, RenderPageResult, SSGResult, DataScriptPayload, ExternalDataScript, Tracked, Resource, UseFetchOptions, UseFetchStreamOptions, SsrDataSink, VeskResponse, SetCookieOptions, } from '@vesk/types';
|
|
2
|
+
export type { RouteNode, ApiRouteNode, MiddlewareContext, ServerEventContext, VeskEventHandlers, VeskPlugin, VeskCors, VeskRateLimit, VeskSecurityPreset, VeskSecurity, VeskConfig, MdConfig, MdHtmlMode, MdProps, MarkdownOptions, MdHtmlWarning, VeskLeafComponent, VeskPrimitiveComponent, VeskTaggedLeafComponent, VeskComponentRegistry, VeskScope, MiddlewareEntry, MiddlewareChainOptions, RenderPageResult, SSGResult, DataScriptPayload, ExternalDataScript, Tracked, Resource, UseFetchOptions, UseFetchStreamOptions, SsrDataSink, VeskResponse, SetCookieOptions, } from '@vesk/types';
|
|
3
3
|
export interface CompileFileResult {
|
|
4
4
|
ir: IRRoot;
|
|
5
5
|
componentMap: Map<string, Function>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,YAAY,EACV,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,UAAU,EACV,OAAO,EACP,eAAe,EACf,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,OAAO,EACP,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,MAAM,a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AC,MAAM,CAAC,CAAC"}
|
package/dist/vesk-plugin.d.ts
CHANGED
|
@@ -52,5 +52,7 @@ declare module 'acorn' {
|
|
|
52
52
|
export interface VeskPluginConfig {
|
|
53
53
|
[key: string]: unknown;
|
|
54
54
|
}
|
|
55
|
+
/** Runs `fn` with JSX tag recognition enabled without a parser driving it. */
|
|
56
|
+
export declare function withStandaloneTokens<T>(fn: () => T): T;
|
|
55
57
|
export declare function VeskParserPlugin(config?: VeskPluginConfig): (Parser: typeof acorn.Parser) => typeof acorn.Parser;
|
|
56
58
|
//# sourceMappingURL=vesk-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vesk-plugin.d.ts","sourceRoot":"","sources":["../src/vesk-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,QAAQ,OAAO,CAAC;IACrB,UAAU,MAAM;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,GAAG,CAAC;QACV,KAAK,EAAE,GAAG,CAAC;QACX,WAAW,EAAE,OAAO,CAAC;QACrB,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,IAAI,GAAG,CAAC;QAClB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QAC7B,KAAK,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC;QAC7B,gBAAgB,IAAI,GAAG,CAAC;QACxB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,GAAG,GAAG,GAAG,CAAC;QACjE,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;QAClD,UAAU,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,OAAO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