@vesk/compiler 0.2.93 → 0.2.95

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/ir.d.ts CHANGED
@@ -104,6 +104,12 @@ export declare class OpaqueDynamicRegion {
104
104
  alternateNodes: IRNode[];
105
105
  constructor(condition: Expression, consequentNodes: IRNode[], alternateNodes?: IRNode[]);
106
106
  }
107
+ /**
108
+ * Stable identity for a conditional region across the SSR and client codegen
109
+ * passes. Both passes see the same source offsets, so the SSR region marker
110
+ * and the client's hydration reconciliation agree without sharing state.
111
+ */
112
+ export declare function regionMarkerId(node: OpaqueDynamicRegion): string;
107
113
  export declare class MapRegion {
108
114
  expression: Expression;
109
115
  itemVariable: string;
package/dist/ir.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../src/ir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEjD,qBAAa,UAAU;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;gBAEH,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,EAAE,GAAG,GAAE,UAAU,GAAG,IAAW,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW;CAM1G;AAED,qBAAa,MAAM;IACjB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC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AE,KAAK,GAAG,QAAgB;CAOxH;AAED,qBAAa,WAAW;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACP,QAAQ,EAAE,MAAM,EAAE;CAG/B;AAED,qBAAa,WAAW;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACP,QAAQ,EAAE,MAAM,EAAE;CAG/B;AAED,qBAAa,SAAS;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACP,QAAQ,EAAE,MAAM,EAAE;CAG/B;AAED,MAAM,MAAM,MAAM,GACd,UAAU,GACV,QAAQ,GACR,cAAc,GACd,mBAAmB,GACnB,SAAS,GACT,SAAS,GACT,WAAW,GACX,QAAQ,GACR,OAAO,GACP,SAAS,GACT,gBAAgB,GAChB,WAAW,GACX,YAAY,GACZ,aAAa,GACb,WAAW,GACX,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,cAAc,CAAC"}
package/dist/ir.js CHANGED
@@ -125,6 +125,21 @@ export class OpaqueDynamicRegion {
125
125
  this.alternateNodes = alternateNodes;
126
126
  }
127
127
  }
128
+ /**
129
+ * Stable identity for a conditional region across the SSR and client codegen
130
+ * passes. Both passes see the same source offsets, so the SSR region marker
131
+ * and the client's hydration reconciliation agree without sharing state.
132
+ */
133
+ export function regionMarkerId(node) {
134
+ const ast = node.condition.ast;
135
+ if (ast && typeof ast.start === 'number')
136
+ return `s${ast.start}`;
137
+ const raw = node.condition.raw;
138
+ let hash = 5381;
139
+ for (let i = 0; i < raw.length; i++)
140
+ hash = ((hash << 5) + hash + raw.charCodeAt(i)) | 0;
141
+ return `h${(hash >>> 0).toString(36)}`;
142
+ }
128
143
  export class MapRegion {
129
144
  expression;
130
145
  itemVariable;
@@ -106,7 +106,7 @@ export declare function resolveViaPackageExports(specifier: string, fromDir: str
106
106
  /** Rewrites an ESM program body (imports/exports removed) into CJS statements. */
107
107
  export declare function esmToCjs(body: Array<{
108
108
  type: string;
109
- } & Record<string, unknown>>): string;
109
+ } & Record<string, unknown>>, rewriteImports?: ReadonlySet<string>): string;
110
110
  export interface BundledModuleData {
111
111
  /** Synthetic loader key (e.g. `__veskMod0`), referenced by deps/bindings. */
112
112
  key: string;
@@ -142,6 +142,13 @@ export interface ModuleEntry {
142
142
  dir: string;
143
143
  /** Relative specifier (as written) -> sibling module key. */
144
144
  deps: Record<string, string>;
145
+ /**
146
+ * Absolute path the entry was registered under. Kept so a plan can be
147
+ * replayed into a fresh registry (see `precompile.ts`), where the module
148
+ * key is derived from this path. Never emitted into the deployment
149
+ * registry (which only serializes code/dir/deps).
150
+ */
151
+ absPath?: string;
145
152
  }
146
153
  /**
147
154
  * Global registry of bundled module source code, shared across every SSR
@@ -159,7 +166,7 @@ export declare class ModuleRegistry {
159
166
  has(absPath: string): boolean;
160
167
  getKey(absPath: string): string | undefined;
161
168
  get size(): number;
162
- /** Register a module's transpiled body, returning its globally-unique key. */
169
+ /** Register a module's transpiled body, returning its stable key. */
163
170
  register(absPath: string, entry: ModuleEntry): string;
164
171
  getModule(key: string): ModuleEntry | undefined;
165
172
  /** All registered modules as a plain object keyed by synthetic key, for
@@ -1 +1 @@
1
- {"version":3,"file":"module-imports.d.ts","sourceRoot":"","sources":["../src/module-imports.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAyEtD,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAM7D;AAED,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAOzD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgC1F;AAED,yEAAyE;AACzE,wBAAgB,qBAA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AAE,eAAe,GACzB,iBAAiB,EAAE,CAuBrB"}
@@ -1345,10 +1345,82 @@ function exportGetter(lines, key, valueExpr) {
1345
1345
  lines.push(`Object.defineProperty(exports, ${JSON.stringify(key)}, { get: () => ${valueExpr}, enumerable: true });`);
1346
1346
  }
1347
1347
  let exportCounter = 0;
1348
+ /**
1349
+ * `Promise.resolve().then(() => require("<spec>"))` as an AST expression.
1350
+ * Reusing the original literal node keeps its raw quoting.
1351
+ */
1352
+ function promiseOfRequire(sourceNode) {
1353
+ return {
1354
+ type: 'CallExpression',
1355
+ optional: false,
1356
+ callee: {
1357
+ type: 'MemberExpression',
1358
+ optional: false,
1359
+ computed: false,
1360
+ object: {
1361
+ type: 'CallExpression',
1362
+ optional: false,
1363
+ callee: {
1364
+ type: 'MemberExpression',
1365
+ optional: false,
1366
+ computed: false,
1367
+ object: { type: 'Identifier', name: 'Promise' },
1368
+ property: { type: 'Identifier', name: 'resolve' },
1369
+ },
1370
+ arguments: [],
1371
+ },
1372
+ property: { type: 'Identifier', name: 'then' },
1373
+ },
1374
+ arguments: [
1375
+ {
1376
+ type: 'ArrowFunctionExpression',
1377
+ id: null,
1378
+ expression: true,
1379
+ generator: false,
1380
+ async: false,
1381
+ params: [],
1382
+ body: {
1383
+ type: 'CallExpression',
1384
+ optional: false,
1385
+ callee: { type: 'Identifier', name: 'require' },
1386
+ arguments: [sourceNode],
1387
+ },
1388
+ },
1389
+ ],
1390
+ };
1391
+ }
1392
+ /**
1393
+ * Rewrites `import("<spec>")` for specifiers the SSR module bundle resolved
1394
+ * (those present in the module's `deps`) into a promise of the same
1395
+ * `require` the static-import rewrite emits.
1396
+ *
1397
+ * Registry bodies run inside `new Function`, where a native dynamic `import()`
1398
+ * has no referrer and Node resolves it against the generated function's
1399
+ * location (`/var/task` on Vercel). That directory ships no node_modules, so
1400
+ * e.g. vesk-qr's lazy `import("qrcode-generator")` fails even though the
1401
+ * encoder is already in the bundle. Routing it through the require shim makes
1402
+ * it use `entry.deps`, exactly like a static import.
1403
+ *
1404
+ * Specifiers that were not bundled (framework-owned, `.vsk`, builtins) keep
1405
+ * their original form: the shim and the host loader know how to handle them.
1406
+ */
1407
+ function rewriteDynamicImports(node, specs) {
1408
+ return walk(node, null, {
1409
+ ImportExpression(n) {
1410
+ const spec = stringLiteralValue(n.source);
1411
+ if (!spec || !specs.has(spec))
1412
+ return;
1413
+ return promiseOfRequire(n.source);
1414
+ },
1415
+ });
1416
+ }
1348
1417
  /** Rewrites an ESM program body (imports/exports removed) into CJS statements. */
1349
- export function esmToCjs(body) {
1418
+ export function esmToCjs(body, rewriteImports) {
1419
+ const statements = rewriteImports
1420
+ ? body.map((stmt) => rewriteDynamicImports(stmt, rewriteImports))
1421
+ : body;
1350
1422
  const lines = [];
1351
- for (const stmt of body) {
1423
+ for (const stmt of statements) {
1352
1424
  switch (stmt.type) {
1353
1425
  case 'ImportDeclaration': {
1354
1426
  const source = printNode(stmt.source);
@@ -1457,6 +1529,35 @@ export function esmToCjs(body) {
1457
1529
  }
1458
1530
  return lines.join('\n');
1459
1531
  }
1532
+ /**
1533
+ * Synthetic key for a module. Derived from the absolute path rather than the
1534
+ * registry's insertion order so the SAME module always gets the same key in
1535
+ * every build. Positional keys (`__veskMod${size}`) made cross-build plan
1536
+ * caching unsafe: a second in-process build (the dev server after the prod
1537
+ * build) started with an empty registry, served cached plans whose keys
1538
+ * referred to modules it never registered, and emitted `export const
1539
+ * __veskModules = {}`. Paired with the plan cache replaying each plan's
1540
+ * modules into the fresh registry, a path-derived key makes that replay
1541
+ * idempotent and collision-free.
1542
+ */
1543
+ function moduleKeyFor(absPath) {
1544
+ // Four independent FNV-1a 32-bit lanes → 128 bits of key space, which makes
1545
+ // an accidental collision between two paths (which would silently swap one
1546
+ // module for another) effectively impossible. Hand-rolled rather than
1547
+ // `node:crypto` because this file is bundled into the edge/server runtime,
1548
+ // where a `node:` import fails to resolve.
1549
+ const seeds = [0x811c9dc5, 0x9e3779b1, 0x85ebca6b, 0xc2b2ae35];
1550
+ let hex = '';
1551
+ for (const seed of seeds) {
1552
+ let h = seed >>> 0;
1553
+ for (let i = 0; i < absPath.length; i++) {
1554
+ h ^= absPath.charCodeAt(i);
1555
+ h = Math.imul(h, 0x01000193) >>> 0;
1556
+ }
1557
+ hex += h.toString(16).padStart(8, '0');
1558
+ }
1559
+ return `__veskMod${hex}`;
1560
+ }
1460
1561
  /**
1461
1562
  * Global registry of bundled module source code, shared across every SSR
1462
1563
  * function in a single build. Without it, every page plan re-embedded the
@@ -1479,14 +1580,14 @@ export class ModuleRegistry {
1479
1580
  get size() {
1480
1581
  return this.data.size;
1481
1582
  }
1482
- /** Register a module's transpiled body, returning its globally-unique key. */
1583
+ /** Register a module's transpiled body, returning its stable key. */
1483
1584
  register(absPath, entry) {
1484
1585
  const existing = this.keysByAbs.get(absPath);
1485
1586
  if (existing)
1486
1587
  return existing;
1487
- const key = `__veskMod${this.data.size}`;
1588
+ const key = moduleKeyFor(absPath);
1488
1589
  this.keysByAbs.set(absPath, key);
1489
- this.data.set(key, entry);
1590
+ this.data.set(key, { ...entry, absPath });
1490
1591
  return key;
1491
1592
  }
1492
1593
  getModule(key) {
@@ -1520,41 +1621,51 @@ function stringLiteralValue(node) {
1520
1621
  */
1521
1622
  function collectModuleSpecifiers(ast) {
1522
1623
  const specs = new Set();
1624
+ // Every type-specific visitor MUST call `next()`. zimmerframe only recurses
1625
+ // into a node's children when its visitor does — the default visitor is the
1626
+ // one that calls `next`. Without it, an `import()`/`require()` nested inside
1627
+ // an exported function (e.g. vesk-qr's lazy encoder load) was never seen, so
1628
+ // the module was neither bundled nor recorded in `deps`.
1523
1629
  walk(ast, null, {
1524
- ImportDeclaration(node) {
1525
- if (node.importKind === 'type')
1526
- return;
1527
- const v = stringLiteralValue(node.source);
1528
- if (v)
1529
- specs.add(v);
1630
+ ImportDeclaration(node, ctx) {
1631
+ if (node.importKind !== 'type') {
1632
+ const v = stringLiteralValue(node.source);
1633
+ if (v)
1634
+ specs.add(v);
1635
+ }
1636
+ ctx.next();
1530
1637
  },
1531
- ExportNamedDeclaration(node) {
1532
- if ((node.exportKind === 'type') || !node.source)
1533
- return;
1534
- const v = stringLiteralValue(node.source);
1535
- if (v)
1536
- specs.add(v);
1638
+ ExportNamedDeclaration(node, ctx) {
1639
+ if (node.exportKind !== 'type' && node.source) {
1640
+ const v = stringLiteralValue(node.source);
1641
+ if (v)
1642
+ specs.add(v);
1643
+ }
1644
+ ctx.next();
1537
1645
  },
1538
- ExportAllDeclaration(node) {
1539
- if (node.exportKind === 'type')
1540
- return;
1541
- const v = stringLiteralValue(node.source);
1542
- if (v)
1543
- specs.add(v);
1646
+ ExportAllDeclaration(node, ctx) {
1647
+ if (node.exportKind !== 'type') {
1648
+ const v = stringLiteralValue(node.source);
1649
+ if (v)
1650
+ specs.add(v);
1651
+ }
1652
+ ctx.next();
1544
1653
  },
1545
- CallExpression(node) {
1654
+ CallExpression(node, ctx) {
1546
1655
  const callee = node.callee;
1547
- if (!callee || callee.type !== 'Identifier' || callee.name !== 'require')
1548
- return;
1549
- const args = (node.arguments || []);
1550
- const v = stringLiteralValue(args[0]);
1551
- if (v)
1552
- specs.add(v);
1656
+ if (callee && callee.type === 'Identifier' && callee.name === 'require') {
1657
+ const args = (node.arguments || []);
1658
+ const v = stringLiteralValue(args[0]);
1659
+ if (v)
1660
+ specs.add(v);
1661
+ }
1662
+ ctx.next();
1553
1663
  },
1554
- ImportExpression(node) {
1664
+ ImportExpression(node, ctx) {
1555
1665
  const v = stringLiteralValue(node.source);
1556
1666
  if (v)
1557
1667
  specs.add(v);
1668
+ ctx.next();
1558
1669
  },
1559
1670
  });
1560
1671
  return specs;
@@ -1594,6 +1705,7 @@ export function collectModuleBundled(absPath, registry) {
1594
1705
  const cached = mtimeMs >= 0 ? bundledCodeCache.get(absPath) : undefined;
1595
1706
  let code;
1596
1707
  let specifiers;
1708
+ let deps = null;
1597
1709
  if (cached && cached.mtimeMs === mtimeMs) {
1598
1710
  code = cached.code;
1599
1711
  specifiers = cached.specifiers;
@@ -1614,17 +1726,30 @@ export function collectModuleBundled(absPath, registry) {
1614
1726
  stripped = stripTsTypes(src.ast);
1615
1727
  stripped.body = (stripped.body || []).filter((n) => (n ? !isTypeOnlyStatement(n) : false));
1616
1728
  specifiers = [...collectModuleSpecifiers(src.ast)];
1617
- code = esmToCjs(stripped.body);
1729
+ // Resolve the closure first: the emitter needs the set of specifiers that
1730
+ // became registry modules so it can route `import("<spec>")` through the
1731
+ // same require shim instead of leaving a bare dynamic import for the host
1732
+ // loader (see `rewriteDynamicImports`).
1733
+ deps = resolveBundledDeps(specifiers, dir, registry);
1734
+ code = esmToCjs(stripped.body, new Set(Object.keys(deps)));
1618
1735
  bundledCodeCache.set(absPath, { mtimeMs, code, specifiers });
1619
1736
  evict(bundledCodeCache);
1620
1737
  }
1738
+ if (!deps)
1739
+ deps = resolveBundledDeps(specifiers, dir, registry);
1740
+ return registry.register(absPath, { code, dir, deps });
1741
+ }
1742
+ /**
1743
+ * Resolves every specifier a module reaches for into the registry key of its
1744
+ * bundled closure. Compiler-owned (`@vesk/*`) targets are injected by the SSR
1745
+ * require shim at runtime (`precompile-runtime.ts`), never bundled: their built
1746
+ * JS may contain identifiers the `.vsk` grammar reserves (`component` in
1747
+ * ripple-runtime.js) and would fail to parse here. `.vsk`/`.css`/`.md` carry no
1748
+ * SSR value. Node builtins load natively through the shim.
1749
+ */
1750
+ function resolveBundledDeps(specifiers, dir, registry) {
1621
1751
  const deps = {};
1622
1752
  for (const spec of specifiers) {
1623
- // Compiler-owned (`@vesk/*`) targets are injected by the SSR require shim
1624
- // at runtime (`precompile-runtime.ts`), never bundled: their built JS may
1625
- // contain identifiers the `.vsk` grammar reserves (`component` in
1626
- // ripple-runtime.js) and would fail to parse here. `.vsk`/`.css`/`.md`
1627
- // carry no SSR value. Node builtins load natively through the shim.
1628
1753
  if (isCompilerOwnedTarget(spec) || isValueLessTarget(spec))
1629
1754
  continue;
1630
1755
  const depPath = resolveSsrModule(spec, dir);
@@ -1632,7 +1757,7 @@ export function collectModuleBundled(absPath, registry) {
1632
1757
  continue;
1633
1758
  deps[spec] = collectModuleBundled(depPath, registry);
1634
1759
  }
1635
- return registry.register(absPath, { code, dir, deps });
1760
+ return deps;
1636
1761
  }
1637
1762
  const bundledCodeCache = new Map();
1638
1763
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"precompile.d.ts","sourceRoot":"","sources":["../src/precompile.ts"],"names":[],"mappings":"AASA,OAAO,EAGL,cAAc,EACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,uCAAuC,CAAC;AAG/C;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,cAAc,GACxB,kBAAkB,CAapB;AAeD,iFAAiF;AACjF,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
1
+ {"version":3,"file":"precompile.d.ts","sourceRoot":"","sources":["../src/precompile.ts"],"names":[],"mappings":"AASA,OAAO,EAIL,cAAc,EACf,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,uCAAuC,CAAC;AAG/C;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,cAAc,GACxB,kBAAkB,CAsBpB;AA8CD,iFAAiF;AACjF,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
@@ -26,16 +26,54 @@ export function precompileFile(source, sourcePath, registry) {
26
26
  const hit = precompileCache.get(sourcePath);
27
27
  // Compare the source, not just the path: the dev server rebuilds in-process
28
28
  // and a stale plan would silently ship yesterday's component.
29
- if (hit !== undefined && hit.source === source)
29
+ if (hit !== undefined && hit.source === source) {
30
+ // A plan is only half of the output: it references module keys that live
31
+ // in the caller's registry. A second build in the same process (prod then
32
+ // dev under `e2e-setup`) starts with a fresh registry, so replaying the
33
+ // memoized plan without its modules left `__veskModules` empty and every
34
+ // bare-package import (`vesk-qr`, …) resolved to `undefined`. Keys are
35
+ // path-derived, so registering the same absPaths here is idempotent.
36
+ for (const { absPath, entry } of hit.modules)
37
+ reg.register(absPath, entry);
30
38
  return hit.plan;
39
+ }
31
40
  const plan = precompileFileInternal(source, sourcePath, new Set(), reg);
32
41
  // Bound it: plans are sizeable on a large app, and a watch session can
33
42
  // outlive many builds.
34
43
  if (precompileCache.size >= 512)
35
44
  precompileCache.clear();
36
- precompileCache.set(sourcePath, { source, plan });
45
+ precompileCache.set(sourcePath, { source, plan, modules: collectPlanModules(plan, reg) });
37
46
  return plan;
38
47
  }
48
+ /**
49
+ * Every module entry a plan (and its nested `.vsk` sub-plans) resolves
50
+ * against, including transitive deps. The shared `__veskModules` registry
51
+ * must contain the whole closure, not just the keys named by `plan.modules`,
52
+ * or `evaluateModule` cannot walk `deps` at hydrate time.
53
+ */
54
+ function collectPlanModules(plan, registry) {
55
+ const out = [];
56
+ const seen = new Set();
57
+ const visitKey = (key) => {
58
+ if (seen.has(key))
59
+ return;
60
+ seen.add(key);
61
+ const entry = registry.getModule(key);
62
+ if (!entry || !entry.absPath)
63
+ return;
64
+ out.push({ absPath: entry.absPath, entry });
65
+ for (const depKey of Object.values(entry.deps))
66
+ visitKey(depKey);
67
+ };
68
+ const visitPlan = (p) => {
69
+ for (const mod of p.modules)
70
+ visitKey(mod.key);
71
+ for (const sub of p.subFiles)
72
+ visitPlan(sub.plan);
73
+ };
74
+ visitPlan(plan);
75
+ return out;
76
+ }
39
77
  /**
40
78
  * Compiled plans, keyed by absolute path.
41
79
  *
package/dist/router.d.ts CHANGED
@@ -20,6 +20,7 @@ export declare function collapseSlashes(p: string): string;
20
20
  export declare function extractMiddlewareParts(src: string): {
21
21
  params: string;
22
22
  body: string;
23
+ imports: string[];
23
24
  } | null;
24
25
  export declare function extractMiddleware(sourcePath: string): string | null;
25
26
  export declare function scanRoutes(appDir: string, options?: ScanOptions): RouteNode[];
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAM1D,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAajD;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAoC3F;AAkDD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUnE;AAwED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,SAAS,EAAE,CAKjF;AAMD,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BzE;AA6HD,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBrE;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAoCnG;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CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAoCnG;AA2CD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CA0HhF"}
package/dist/router.js CHANGED
@@ -61,10 +61,25 @@ export function extractMiddlewareParts(src) {
61
61
  decls.push(src.slice(stmt.declaration.start, stmt.declaration.end).trim());
62
62
  }
63
63
  }
64
+ const imports = [];
65
+ for (const stmt of ast.body) {
66
+ if (stmt.type !== 'ImportDeclaration')
67
+ continue;
68
+ if (stmt.importKind === 'type')
69
+ continue;
70
+ const source = stmt.source?.value;
71
+ if (typeof source !== 'string')
72
+ continue;
73
+ if (source.startsWith('.') || source.startsWith('/'))
74
+ continue;
75
+ const line = src.slice(stmt.start, stmt.end).trim();
76
+ if (line && !imports.includes(line))
77
+ imports.push(line);
78
+ }
64
79
  const bodyWithDecls = decls.length > 0
65
80
  ? decls.join('\n') + '\n' + body.trim()
66
81
  : body.trim();
67
- return { params, body: bodyWithDecls };
82
+ return { params, body: bodyWithDecls, imports };
68
83
  }
69
84
  catch {
70
85
  return fallbackExtractMiddleware(src);
@@ -124,7 +139,7 @@ function fallbackExtractMiddleware(src) {
124
139
  m++;
125
140
  }
126
141
  const body = src.slice(b + 1, m - 1);
127
- return { params, body: body.trim() };
142
+ return { params, body: body.trim(), imports: [] };
128
143
  }
129
144
  return null;
130
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server-jsgen.d.ts","sourceRoot":"","sources":["../src/server-jsgen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQzE,OAAO,EAAkG,KAAK,WAAW,EAAE,MAAM,mCAAmC,CAAC;AA6DrK,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,GAAG,CAA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B;AAuFD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CA4CzE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAYhG"}
@@ -1,4 +1,4 @@
1
- import { Expression, StaticNode, TextNode, DynamicBinding, OpaqueDynamicRegion, MapRegion, WhileLoop, SwitchBlock, TryCatch, ForLoop, TrackDecl, RuntimeStatement, ComponentRef, ComponentCall, BreakSignal, ServerBlock, ClientBlock, HeadBlock, SlotNode, PropSlot, PropSlotRender, } from '@vesk/compiler/src/ir';
1
+ import { Expression, StaticNode, TextNode, DynamicBinding, OpaqueDynamicRegion, MapRegion, WhileLoop, SwitchBlock, TryCatch, ForLoop, TrackDecl, RuntimeStatement, ComponentRef, ComponentCall, BreakSignal, ServerBlock, ClientBlock, HeadBlock, SlotNode, PropSlot, PropSlotRender, regionMarkerId, } from '@vesk/compiler/src/ir';
2
2
  import { isStaticIR, collectTrackedNames, transformTracked, transformTrackedInit, semicolonizeStatement } from '@vesk/compiler/src/client-codegen';
3
3
  import { unwrapTrackCall, stripTrackGeneric, hasTopLevelComma, skipWhitespace, findBalancedEnd, startsWithIdentifier, callsIdentifier } from '@vesk/compiler/src/scan';
4
4
  import { escapeHtml, indent, exprJS, extractTopLevelNames, extractRuntimeNames, buildParamInit, VOID_ELEMENTS, __vskHydrate, __vskMarkerless, __vskImportedNames, setVskImportedNames, setVskForceClaim, takeVskForceClaim, nextVskId, } from '@vesk/compiler/src/server-utils';
@@ -295,7 +295,15 @@ function dynamicBindingToJS(node, tracked) {
295
295
  function opaqueRegionToJS(node, isAsync = false, tracked) {
296
296
  const lines = [];
297
297
  const cond = exprJSX(node.condition, tracked);
298
+ const rid = regionMarkerId(node);
299
+ // Marker-mode SSR records which branch the server actually rendered. Strict
300
+ // markerless SSR must remain ordinary HTML: no comments, no annotations. In
301
+ // markerless mode the client recovers a differing initial branch through the
302
+ // structural walker's descriptor validation instead.
303
+ const mark = __vskHydrate && !__vskMarkerless;
298
304
  lines.push(`if (${cond}) {`);
305
+ if (mark)
306
+ lines.push(indent(`__out.push('<!--vesk-r:${rid}:0-->');`));
299
307
  // Static branch content still needs server claim markers: the client
300
308
  // re-branches an if/else-if region on every tracked change (OpaqueDynamicRegion
301
309
  // claimStatic codegen), so opposed to plain component bodies it must be able
@@ -308,8 +316,10 @@ function opaqueRegionToJS(node, isAsync = false, tracked) {
308
316
  lines.push(indent(code));
309
317
  }
310
318
  setVskForceClaim(false);
319
+ lines.push(`} else {`);
320
+ if (mark)
321
+ lines.push(indent(`__out.push('<!--vesk-r:${rid}:1-->');`));
311
322
  if (node.alternateNodes.length > 0) {
312
- lines.push(`} else {`);
313
323
  setVskForceClaim(true);
314
324
  for (const n of node.alternateNodes) {
315
325
  const code = irNodeToJS(n, null, isAsync, tracked);
@@ -319,6 +329,8 @@ function opaqueRegionToJS(node, isAsync = false, tracked) {
319
329
  setVskForceClaim(false);
320
330
  }
321
331
  lines.push(`}`);
332
+ if (mark)
333
+ lines.push(`__out.push('<!--vesk-r-end:${rid}-->');`);
322
334
  return lines.join('\n');
323
335
  }
324
336
  function mapRegionToJS(node, isAsync = false, tracked) {