@vesk/compiler 0.2.34 → 0.2.36
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-codegen.d.ts","sourceRoot":"","sources":["../src/client-codegen.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAGL,cAAc,EAQd,gBAAgB,EASjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAyCxD,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;CAC1B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1D;AAiDD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,CAwGlI;AAID,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAU5E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,CAY5F;AAoBD,qDAAqD;AACrD,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,SAAS,CAQtE;
|
|
1
|
+
{"version":3,"file":"client-codegen.d.ts","sourceRoot":"","sources":["../src/client-codegen.ts"],"names":[],"mappings":"A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O,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,aAAa,CAAC,EAAE,SAAS,CAAA;CAAO,GAAG,MAAM,CAO9O;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,UAAU,CAAC,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CA0BpD;AAED,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/client-codegen.js
CHANGED
|
@@ -914,7 +914,9 @@ function emitComponentCall(ctx, node, tracked, effectsVar, parentVar, compPrefix
|
|
|
914
914
|
ctx.push(`return $f; })();`);
|
|
915
915
|
propsEntries.push(`children: ${frag}`);
|
|
916
916
|
}
|
|
917
|
-
ctx.push(`
|
|
917
|
+
ctx.push(`let ${v} = undefined;`);
|
|
918
|
+
ctx.push(`if (__hydrate) __hydrate.childFrame = (__hydrate.childFrame || 0) + 1;`);
|
|
919
|
+
ctx.push(`try { ${v} = ${awaitKw}${access}(${callArgs()}, __registry, ${walkerArg}); } finally { if (__hydrate) __hydrate.childFrame--; }`);
|
|
918
920
|
maybeReplace(v);
|
|
919
921
|
maybeRetire();
|
|
920
922
|
return v;
|
|
@@ -971,6 +973,14 @@ function emitComponentCall(ctx, node, tracked, effectsVar, parentVar, compPrefix
|
|
|
971
973
|
function emitHydrateFenceAnchoring(ctx, anchor, endAnchor, rootLevel) {
|
|
972
974
|
if (!ctx.hydrate || !rootLevel)
|
|
973
975
|
return;
|
|
976
|
+
// `rootLevel` (fallback parent is `$root`) already implies the region is a
|
|
977
|
+
// top-level sibling of its enclosing claims — a region nested inside a
|
|
978
|
+
// claimed element gets that element as its `__place` fallback and never
|
|
979
|
+
// reaches here, so its fences stay local. Anchoring therefore works even
|
|
980
|
+
// inside a child `hydration frame`: the shared walker's cursor sits exactly
|
|
981
|
+
// at the region's SSR slot (e.g. a polish-mobile menu panel that follows a
|
|
982
|
+
// `<header>` in a `<>` fragment), so a no-content nested region must anchor
|
|
983
|
+
// there instead of drifting to the page root's end via `__place`'s fallback.
|
|
974
984
|
ctx.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
|
|
975
985
|
ctx.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
|
|
976
986
|
ctx.push(indent(`__hydrate.insertBeforeNextClaim(${anchor});`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../src/ir-generator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAsBP,MAAM,uBAAuB,CAAC;AA0S/B,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkCnL;
|
|
1
|
+
{"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../src/ir-generator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAsBP,MAAM,uBAAuB,CAAC;AA0S/B,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkCnL;AA48BD,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAwN9E"}
|
package/dist/ir-generator.js
CHANGED
|
@@ -1036,6 +1036,22 @@ function getReturnArgument(node) {
|
|
|
1036
1036
|
}
|
|
1037
1037
|
return null;
|
|
1038
1038
|
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Returns the `return` statement of an early-return statement — either a bare
|
|
1041
|
+
* `ReturnStatement` or a `BlockStatement` wrapping a single `ReturnStatement` —
|
|
1042
|
+
* regardless of whether it has an argument. Returns `null` when the statement
|
|
1043
|
+
* is not such a return. Unlike `getReturnArgument`, a *bare* `return` (no
|
|
1044
|
+
* argument) is recognized: `if (c) return` must still short-circuit the rest
|
|
1045
|
+
* of the body with an empty consequent.
|
|
1046
|
+
*/
|
|
1047
|
+
function getReturnStatement(node) {
|
|
1048
|
+
if (node.type === 'ReturnStatement')
|
|
1049
|
+
return node;
|
|
1050
|
+
if (node.type === 'BlockStatement' && node.body.length === 1 && node.body[0].type === 'ReturnStatement') {
|
|
1051
|
+
return node.body[0];
|
|
1052
|
+
}
|
|
1053
|
+
return null;
|
|
1054
|
+
}
|
|
1039
1055
|
function isStatementMode(bodyStmts) {
|
|
1040
1056
|
if (bodyStmts.some((s) => s.type === 'JSXElement' || s.type === 'JSXExpressionContainer' || s.type === 'JSXFragment'))
|
|
1041
1057
|
return true;
|
|
@@ -1197,9 +1213,11 @@ function processStatementModeBody(source, bodyStmts, filename) {
|
|
|
1197
1213
|
// expression-mode `buildGuardChain`. Without this the `return` is
|
|
1198
1214
|
// silently swallowed and execution falls through into code that
|
|
1199
1215
|
// assumes the guard held.
|
|
1200
|
-
const
|
|
1201
|
-
if (
|
|
1202
|
-
|
|
1216
|
+
const guardReturn = !stmt.alternate ? getReturnStatement(stmt.consequent) : null;
|
|
1217
|
+
if (guardReturn) {
|
|
1218
|
+
// A bare `return` (no argument) is a guard that renders nothing, like
|
|
1219
|
+
// expression-mode's empty consequent for argument-less returns.
|
|
1220
|
+
const consequent = guardReturn.argument ? exprToIR(source, guardReturn.argument) : [];
|
|
1203
1221
|
const alternate = processStatementModeBody(source, bodyStmts.slice(i + 1), filename);
|
|
1204
1222
|
nodes.push(new OpaqueDynamicRegion(toExpression(source, stmt.test), consequent, alternate));
|
|
1205
1223
|
break;
|
package/dist/vsk-imports.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resolve `import ... from './path.vsk'` statements so helper components can
|
|
3
3
|
* live in arbitrary `.vsk` files and be imported into any page, layout,
|
|
4
|
-
* component or route file.
|
|
4
|
+
* component or route file. Bare-alias specifiers (`@/components/Button.vsk`,
|
|
5
|
+
* `@app/...` and anything else mapped by tsconfig `paths`) also resolve, so a
|
|
6
|
+
* shared component in `components/` can be imported with the root `@/` alias
|
|
7
|
+
* exactly like in Next.js.
|
|
5
8
|
*/
|
|
6
9
|
export declare function vskImportTarget(importText: string): string | null;
|
|
7
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vsk-imports.d.ts","sourceRoot":"","sources":["../src/vsk-imports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vsk-imports.d.ts","sourceRoot":"","sources":["../src/vsk-imports.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AAEH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQjE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAahE;AA0BD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAerF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAKnD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsBhE"}
|
package/dist/vsk-imports.js
CHANGED
|
@@ -3,11 +3,15 @@ import { existsSync } from 'node:fs';
|
|
|
3
3
|
import { print } from 'esrap';
|
|
4
4
|
import ts from 'esrap/languages/ts';
|
|
5
5
|
import { parse } from '@vesk/compiler/src/parser';
|
|
6
|
+
import { resolveImportPath } from '@vesk/compiler/src/module-imports';
|
|
6
7
|
import { importModuleTarget, tokenizeCode } from '@vesk/compiler/src/tokens';
|
|
7
8
|
/**
|
|
8
9
|
* Resolve `import ... from './path.vsk'` statements so helper components can
|
|
9
10
|
* live in arbitrary `.vsk` files and be imported into any page, layout,
|
|
10
|
-
* component or route file.
|
|
11
|
+
* component or route file. Bare-alias specifiers (`@/components/Button.vsk`,
|
|
12
|
+
* `@app/...` and anything else mapped by tsconfig `paths`) also resolve, so a
|
|
13
|
+
* shared component in `components/` can be imported with the root `@/` alias
|
|
14
|
+
* exactly like in Next.js.
|
|
11
15
|
*/
|
|
12
16
|
export function vskImportTarget(importText) {
|
|
13
17
|
const spec = importModuleTarget(importText);
|
|
@@ -82,11 +86,17 @@ export function collectVskImportPaths(imports, sourcePath) {
|
|
|
82
86
|
if (stripTypeImport(imp) === null)
|
|
83
87
|
continue;
|
|
84
88
|
const target = vskImportTarget(imp);
|
|
85
|
-
if (!target
|
|
89
|
+
if (!target)
|
|
86
90
|
continue;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
if (target.startsWith('.')) {
|
|
92
|
+
const full = resolve(dirname(sourcePath), target);
|
|
93
|
+
if (existsSync(full))
|
|
94
|
+
out.push(full);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const aliased = resolveImportPath(target, dirname(sourcePath));
|
|
98
|
+
if (aliased !== target && existsSync(aliased))
|
|
99
|
+
out.push(aliased);
|
|
90
100
|
}
|
|
91
101
|
return out;
|
|
92
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.36",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk compiler — lexer, parser, semantic analysis, IR, codegen",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@sveltejs/acorn-typescript": "^1.0.0",
|
|
23
|
-
"@vesk/types": "^0.2.
|
|
23
|
+
"@vesk/types": "^0.2.36",
|
|
24
24
|
"acorn": "^8.15.0",
|
|
25
25
|
"esrap": "^2.3.0",
|
|
26
26
|
"is-reference": "^3.0.0",
|