@vesk/compiler 0.2.31 → 0.2.32
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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,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
|
@@ -548,7 +548,7 @@ function emitStatic(ctx, node, tracked, effectsVar) {
|
|
|
548
548
|
const useProp = PROPERTY_ATTRS[node.tag]?.has(target);
|
|
549
549
|
const eff = useProp
|
|
550
550
|
? `effect(() => { ${ssrEl}.${target} = ${expr}; })`
|
|
551
|
-
: `effect(() => { const __v = ${expr}; if (__v
|
|
551
|
+
: `effect(() => { const __v = ${expr}; if (__v == null || __v === false) ${ssrEl}.removeAttribute(${JSON.stringify(target)}); else ${ssrEl}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
|
|
552
552
|
if (effectsVar) {
|
|
553
553
|
ctx.push(`${effectsVar}.push(${eff});`);
|
|
554
554
|
}
|
|
@@ -631,7 +631,7 @@ function emitStatic(ctx, node, tracked, effectsVar) {
|
|
|
631
631
|
const useProp = PROPERTY_ATTRS[node.tag]?.has(target);
|
|
632
632
|
const eff = useProp
|
|
633
633
|
? `effect(() => { ${el}.${target} = ${expr}; })`
|
|
634
|
-
: `effect(() => { const __v = ${expr}; if (__v
|
|
634
|
+
: `effect(() => { const __v = ${expr}; if (__v == null || __v === false) ${el}.removeAttribute(${JSON.stringify(target)}); else ${el}.setAttribute(${JSON.stringify(target)}, __v === true ? 'true' : String(__v)); })`;
|
|
635
635
|
if (effectsVar) {
|
|
636
636
|
ctx.push(`${effectsVar}.push(${eff});`);
|
|
637
637
|
}
|
|
@@ -952,6 +952,31 @@ function emitComponentCall(ctx, node, tracked, effectsVar, parentVar, compPrefix
|
|
|
952
952
|
}
|
|
953
953
|
return v;
|
|
954
954
|
}
|
|
955
|
+
// Hydrate-mode dynamic regions create `anchor`/`endAnchor` comment fences that
|
|
956
|
+
// `__place` attaches when a branch claims SSR content — but a branch with NO SSR
|
|
957
|
+
// content (e.g. a root-level `if (open)` that was falsy at SSR time) falls into
|
|
958
|
+
// `__place`'s tail and appends fences + content to `$root`'s end, drifting the
|
|
959
|
+
// region to the bottom of the whole layout. Anchor the fences at the walker's
|
|
960
|
+
// current SSR slot at build time instead, so later content lands exactly where
|
|
961
|
+
// the region would have been if SSR had rendered it. Only used in hydrate mode;
|
|
962
|
+
// fresh (SPA) renders append fences to `parent` inline.
|
|
963
|
+
//
|
|
964
|
+
// Anchoring is only safe when the region's fallback parent is `$root` itself.
|
|
965
|
+
// Regions nested inside a claimed element (e.g. the `{open ? X : Menu}` ternary
|
|
966
|
+
// inside DocsHeader's `<button>`, or a copy-button icon swap) must keep their
|
|
967
|
+
// fences INSIDE that element so `__place` swaps in place — anchoring them at the
|
|
968
|
+
// walker slot moves their content to the element's following sibling slot, which
|
|
969
|
+
// makes the icon vanish from the button on re-render. `rootLevel` should be
|
|
970
|
+
// `parent === '$root'`.
|
|
971
|
+
function emitHydrateFenceAnchoring(ctx, anchor, endAnchor, rootLevel) {
|
|
972
|
+
if (!ctx.hydrate || !rootLevel)
|
|
973
|
+
return;
|
|
974
|
+
ctx.push(`// Anchor region fences to the SSR slot so no-content regions do not fall back to $root's end.`);
|
|
975
|
+
ctx.push(`if (__hydrate && __hydrate.insertBeforeNextClaim) {`);
|
|
976
|
+
ctx.push(indent(`__hydrate.insertBeforeNextClaim(${anchor});`));
|
|
977
|
+
ctx.push(indent(`__hydrate.insertBeforeNextClaim(${endAnchor});`));
|
|
978
|
+
ctx.push(`}`);
|
|
979
|
+
}
|
|
955
980
|
function emitTryCatch(ctx, node, tracked, effectsVar, parentVar) {
|
|
956
981
|
const anchor = ctx.n();
|
|
957
982
|
const endAnchor = ctx.n();
|
|
@@ -963,6 +988,7 @@ function emitTryCatch(ctx, node, tracked, effectsVar, parentVar) {
|
|
|
963
988
|
ctx.push(`${parent}.appendChild(${anchor});`);
|
|
964
989
|
ctx.push(`let ${effArr} = [];`);
|
|
965
990
|
ctx.push(`const ${endAnchor} = document.createComment('try-end');`);
|
|
991
|
+
emitHydrateFenceAnchoring(ctx, anchor, endAnchor, parent === '$root');
|
|
966
992
|
const asyncKw = ctx.isAsyncScope ? 'await ' : '';
|
|
967
993
|
function emitRenderFunc(name, isCatch, hydMode, compPrefix = '__components') {
|
|
968
994
|
const savedHydrate = ctx.hydrate;
|
|
@@ -1055,6 +1081,7 @@ function emitOpaque(ctx, node, tracked, effTarget, parentVar) {
|
|
|
1055
1081
|
ctx.push(`const ${anchor} = document.createComment('if');`);
|
|
1056
1082
|
ctx.push(`let ${effectsVar} = [];`);
|
|
1057
1083
|
ctx.push(`const ${endAnchor} = document.createComment('if-end');`);
|
|
1084
|
+
emitHydrateFenceAnchoring(ctx, anchor, endAnchor, parent === '$root');
|
|
1058
1085
|
const asyncKw = ctx.isAsyncScope ? 'await ' : '';
|
|
1059
1086
|
const fnOpen = ctx.isAsyncScope ? 'async () => {' : '() => {';
|
|
1060
1087
|
const renderNames = [];
|
|
@@ -1151,6 +1178,7 @@ function emitOpaque(ctx, node, tracked, effTarget, parentVar) {
|
|
|
1151
1178
|
ctx.push(`${parent}.appendChild(${anchor});`);
|
|
1152
1179
|
ctx.push(`let ${effectsVar} = [];`);
|
|
1153
1180
|
ctx.push(`const ${endAnchor} = document.createComment('if-end');`);
|
|
1181
|
+
emitHydrateFenceAnchoring(ctx, anchor, endAnchor, parent === '$root');
|
|
1154
1182
|
const asyncKw = ctx.isAsyncScope ? 'await ' : '';
|
|
1155
1183
|
const fnOpen = ctx.isAsyncScope ? 'async () => {' : '() => {';
|
|
1156
1184
|
const conRenderName = ctx.n();
|
|
@@ -1258,6 +1286,7 @@ function emitWhileLoop(ctx, node, tracked, parentVar) {
|
|
|
1258
1286
|
ctx.push(`${parent}.appendChild(${anchor});`);
|
|
1259
1287
|
ctx.push(`let ${effectsVar} = [];`);
|
|
1260
1288
|
ctx.push(`const ${endAnchor} = document.createComment('while-end');`);
|
|
1289
|
+
emitHydrateFenceAnchoring(ctx, anchor, endAnchor, parent === '$root');
|
|
1261
1290
|
const renderLoop = ctx.n();
|
|
1262
1291
|
ctx.push(`const ${renderLoop} = ${ctx.isAsyncScope ? 'async () => {' : '() => {'}`);
|
|
1263
1292
|
if (!hyd)
|
|
@@ -1332,6 +1361,7 @@ function emitForLoop(ctx, node, tracked, parentVar) {
|
|
|
1332
1361
|
ctx.push(`${parent}.appendChild(${anchor});`);
|
|
1333
1362
|
ctx.push(`let ${effectsVar} = [];`);
|
|
1334
1363
|
ctx.push(`const ${endAnchor} = document.createComment('for-end');`);
|
|
1364
|
+
emitHydrateFenceAnchoring(ctx, anchor, endAnchor, parent === '$root');
|
|
1335
1365
|
const renderLoop = ctx.n();
|
|
1336
1366
|
ctx.push(`const ${renderLoop} = ${ctx.isAsyncScope ? 'async () => {' : '() => {'}`);
|
|
1337
1367
|
if (!hyd)
|
|
@@ -1505,6 +1535,7 @@ function emitSwitchBlock(ctx, node, tracked, parentVar) {
|
|
|
1505
1535
|
ctx.push(`${parent}.appendChild(${anchor});`);
|
|
1506
1536
|
ctx.push(`let ${effectsVar} = [];`);
|
|
1507
1537
|
ctx.push(`const ${endAnchor} = document.createComment('switch-end');`);
|
|
1538
|
+
emitHydrateFenceAnchoring(ctx, anchor, endAnchor, parent === '$root');
|
|
1508
1539
|
const renderSwitch = ctx.n();
|
|
1509
1540
|
ctx.push(`const ${renderSwitch} = ${ctx.isAsyncScope ? 'async () => {' : '() => {'}`);
|
|
1510
1541
|
if (hyd) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.32",
|
|
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.32",
|
|
24
24
|
"acorn": "^8.15.0",
|
|
25
25
|
"esrap": "^2.3.0",
|
|
26
26
|
"is-reference": "^3.0.0",
|