diff --git a/.sizes.json b/.sizes.json index f2e731cf2b1..dada4911fab 100644 --- a/.sizes.json +++ b/.sizes.json @@ -7,8 +7,8 @@ { "name": "*", "total": { - "min": 28306, - "brotli": 10486 + "min": 28323, + "brotli": 10466 } }, { diff --git a/.sizes/dom.js b/.sizes/dom.js index d7390c94724..17cb025e06d 100644 --- a/.sizes/dom.js +++ b/.sizes/dom.js @@ -1,4 +1,4 @@ -// size: 28306 (min) 10486 (brotli) +// size: 28323 (min) 10466 (brotli) //#region packages/runtime-tags/dist/dom.mjs let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => (c === ";" ? "\\3B " : "\\\\"), @@ -97,11 +97,8 @@ let unsafeStyleAttrReg = /[\\;]/g, registeredValues = {}, patchers = {}, onPatchRecord, - failPatch = () => { - throw 0; - }, patchScope = (partial, live) => { - for (let key in partial) (patchers[key[0]] || failPatch())(live, key, partial[key]); + for (let key in partial) patchers[key[0]](live, key, partial[key]); }, curRenders, embedRenders, @@ -979,7 +976,7 @@ function walk(startNode, walkCodes, branch) { } function beginPatch(renderId) { let render = (patchRender = curRenders[renderId]); - return ((patching = 1), patchId++, render); + return (render.w(), (patching = 1), patchId++, render); } function abortPatch() { patchRender = patching = 0; @@ -2268,14 +2265,14 @@ let empty = [], insertLoaded(renderer, branch, branch.S, awaitCounter), )); }, - loadFailed(branch, awaitCounter), + loadFailed(branch, awaitCounter, "_" + id), )); }, _load_signal(() => (pending ||= load()).then((r) => ({ _: r.d }))), ); return lazyTemplate; }), - _load_setup = /*@__PURE__*/ withLazy((nodeAccessor, childScopeAccessor, load) => { + _load_setup = /*@__PURE__*/ withLazy((nodeAccessor, childScopeAccessor, load, readyId) => { ((nodeAccessor = decodeAccessor(nodeAccessor)), (childScopeAccessor = decodeAccessor(childScopeAccessor))); let pending, renderer; @@ -2289,10 +2286,10 @@ let empty = [], (mod) => { ((renderer = _content("", ...mod._)()), queueAsyncRender(child, (child) => - insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter), + insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter, readyId), )); }, - loadFailed(child, awaitCounter), + loadFailed(child, awaitCounter, readyId), )); } }; @@ -2386,11 +2383,14 @@ function mount(input = {}, reference, position) { } ); } -function insertLoaded(renderer, branch, marker, awaitCounter) { +function insertLoaded(renderer, branch, marker, awaitCounter, readyId) { let parent = marker.parentNode, values = branch.X, insert = () => { - (insertBranchBefore(branch, parent, marker), marker.remove(), awaitCounter?.c()); + (insertBranchBefore(branch, parent, marker), + marker.remove(), + awaitCounter?.c(), + readyId && queueEffect(branch, () => ready(readyId))); }, remaining; if ( @@ -2399,7 +2399,7 @@ function insertLoaded(renderer, branch, marker, awaitCounter) { (branch.X = 0), (remaining = values?.size)) ) { - let fail = loadFailed(branch, awaitCounter); + let fail = loadFailed(branch, awaitCounter, readyId); for (let [promise, entry] of values) promise.then( (signal) => { @@ -2416,7 +2416,7 @@ function insertLoaded(renderer, branch, marker, awaitCounter) { ); } else (setupBranch(renderer, branch), insert()); } -function loadFailed(scope, awaitCounter) { +function loadFailed(scope, awaitCounter, readyId) { return (error) => { (awaitCounter && (awaitCounter.m ? (awaitCounter.i = 0) : awaitCounter.c()), queueAsyncRender(scope, renderCatch, error)); diff --git a/agent-feedback/items/2026-08-12-validate-attribute-tag-bodies-generically-in-persisted-admission.md b/agent-feedback/items/2026-08-12-validate-attribute-tag-bodies-generically-in-persisted-admission.md deleted file mode 100644 index cf6e669e387..00000000000 --- a/agent-feedback/items/2026-08-12-validate-attribute-tag-bodies-generically-in-persisted-admission.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -type: cleanup -impact: low -effort: low -site: packages/runtime-tags/src/translator/util/persisted/admission.ts › assertSupportedPatch ---- - -# Validate attribute-tag bodies generically in persisted admission - -`assertSupportedPatch`'s MarkoTag visitor returns early for any `@`-named tag so `<@catch>` under an admitted `` doesn't hit the generic "unsupported tag" fallback; `` then traverses its own attr tags for server reads. Attribute tags on other owners are still rejected at the owner (template children gate `attributeTags?.length`), so nothing leaks today, but a future owner that admits attr tags would silently skip validating their contents unless it re-traverses like `` does. Validate attr-tag bodies generically (the placeholder/scriptlet visitors still visit them) or assert the parent is a core `` in the early return. - -Check: the `tagName[0] === "@"` early return in `assertSupportedPatch` and ``'s `traverseFast` over `node.attributeTags`. diff --git a/agent-feedback/items/2026-08-21-backport-lazy-load-failure-reporting-to-main.md b/agent-feedback/items/2026-08-21-backport-lazy-load-failure-reporting-to-main.md new file mode 100644 index 00000000000..e1dc5971ff2 --- /dev/null +++ b/agent-feedback/items/2026-08-21-backport-lazy-load-failure-reporting-to-main.md @@ -0,0 +1,20 @@ +--- +type: cleanup +impact: med +effort: med +site: packages/runtime-tags/src/translator/visitors/program/index.ts › isLoadEntry +--- + +Lazy load failure reporting (`readyFailed` in `src/dom/resume.ts`, the load +entry's rejection arm, and the loader-script `onerror` wiring in +`src/html/assets.ts` › `writeTriggerScript`) is gated on `isPersisted()` +because persisted patches need it to settle. The gap it closes is general: +on ANY page a failed lazy chunk currently leaves inert SSR content silently +(no `@catch`, no signal). Backporting the protocol to main — un-gating the +rejection arm and onerror wiring, and driving the ready-channel branches' +`@catch`/await-counter machinery from `readyFailed` — would give lazy SSR a +real failure story and dissolve the persisted-only gates here. + +Check: non-persisted fixture with `load: "on-click body"` + +`reject_load: ["load.mjs"]` — the child stays inert with no catch UI and no +console signal. diff --git a/agent-feedback/items/2026-08-21-decide-global-skew-policy-for-persisted-patches.md b/agent-feedback/items/2026-08-21-decide-global-skew-policy-for-persisted-patches.md deleted file mode 100644 index 71f6847f4b2..00000000000 --- a/agent-feedback/items/2026-08-21-decide-global-skew-policy-for-persisted-patches.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -type: bug -impact: med -effort: high -site: packages/runtime-tags/src/html/patch.ts › PatchState ---- - -`PatchState` sets `hasGlobals = true` ("the live page owns its serialized -globals; a frame never re-ships them"), but servers commonly vary `$global` -per request (locale, auth, feature flags). A patch re-renders with the new -globals — global-derived attr/text entries update — while anything the -client seeded from the old globals stays stale, so two related values can -silently diverge across a patch. The admission guard -(`src/translator/util/persisted/admission.ts`) blocks `$global` reads inside -client-owned structure but cannot see this cross-request skew. Decide a -policy: ship changed globals in frames, or reject/warn when a persisted -template's rendered output reads `$global`. - -Check: template rendering `$global.x` into text; renderPatch with a -different `$global.x` updates the text while a ``-seeded -value keeps the old one. diff --git a/agent-feedback/items/2026-08-23-pair-patches-into-still-streaming-boundaries.md b/agent-feedback/items/2026-08-23-pair-patches-into-still-streaming-boundaries.md new file mode 100644 index 00000000000..852abe65b92 --- /dev/null +++ b/agent-feedback/items/2026-08-23-pair-patches-into-still-streaming-boundaries.md @@ -0,0 +1,18 @@ +--- +type: feature +impact: med +effort: high +site: packages/runtime-tags/src/dom/patch-boundary.feat.ts › PatchKey.Pending +--- + +# Pair patches into still-streaming boundaries + +A patch arriving while a boundary's initial stream is still pending rejects +into navigation (safe: the construct's marker anchor has not streamed — +pinned by `persisted-await-patch-while-pending`). Supporting it needs the +frame to defer against the initial render's own reorder machinery (apply +once the anchor lands, or supersede the pending chunk outright) rather +than pairing against a node that does not exist yet. + +Check: `persisted-await-patch-while-pending` drops `expect_rejection` and +shows the second update applying once mid-stream pairing lands. diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-conditional-child-inert/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-conditional-child-inert/sizes.json index e25993f5575..f509b2b6c0b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-conditional-child-inert/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-conditional-child-inert/sizes.json @@ -5,8 +5,8 @@ "brotli": 90 }, "template.marko.page.mjs": { - "min": 1470, - "brotli": 802 + "min": 1524, + "brotli": 831 }, "child.mjs": { "min": 162, @@ -17,8 +17,8 @@ "brotli": 80 }, "shared": { - "min": 7449, - "brotli": 3339 + "min": 7456, + "brotli": 3337 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-conditional-child-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-conditional-child-state/sizes.json index 917117adbc0..fe3954a91fb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-conditional-child-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-conditional-child-state/sizes.json @@ -5,8 +5,8 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1474, - "brotli": 799 + "min": 1528, + "brotli": 814 }, "child.mjs": { "min": 297, @@ -17,8 +17,8 @@ "brotli": 81 }, "shared": { - "min": 7471, - "brotli": 3342 + "min": 7478, + "brotli": 3340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic-placeholder/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic-placeholder/sizes.json index 70373edd694..2b96a1ad069 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic-placeholder/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic-placeholder/sizes.json @@ -5,16 +5,16 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1524, - "brotli": 820 + "min": 1556, + "brotli": 848 }, "child.mjs": { "min": 212, "brotli": 143 }, "shared": { - "min": 11182, - "brotli": 4825 + "min": 11189, + "brotli": 4818 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic-unmount-before-load/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic-unmount-before-load/sizes.json index 196a2acd580..e1eb4774b4e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic-unmount-before-load/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic-unmount-before-load/sizes.json @@ -5,16 +5,16 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1464, - "brotli": 800 + "min": 1513, + "brotli": 824 }, "child.mjs": { "min": 223, "brotli": 161 }, "shared": { - "min": 11058, - "brotli": 4761 + "min": 11065, + "brotli": 4760 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic/sizes.json index 1f15d3ea8cb..83ac4d3dba2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-dynamic/sizes.json @@ -5,16 +5,16 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1405, - "brotli": 764 + "min": 1446, + "brotli": 783 }, "child.mjs": { "min": 212, "brotli": 143 }, "shared": { - "min": 10831, - "brotli": 4684 + "min": 10838, + "brotli": 4685 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-event-unmount-before-load/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-event-unmount-before-load/sizes.json index 74a73f6dbf5..4587869e7e5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-event-unmount-before-load/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-event-unmount-before-load/sizes.json @@ -5,8 +5,8 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1641, - "brotli": 874 + "min": 1695, + "brotli": 890 }, "child.mjs": { "min": 177, @@ -17,8 +17,8 @@ "brotli": 75 }, "shared": { - "min": 7413, - "brotli": 3289 + "min": 7420, + "brotli": 3287 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-idle-unmount-before-load/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-idle-unmount-before-load/sizes.json index f2d7684b55d..5ba8fe76ff2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-idle-unmount-before-load/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-idle-unmount-before-load/sizes.json @@ -5,8 +5,8 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1578, - "brotli": 864 + "min": 1632, + "brotli": 872 }, "child.mjs": { "min": 177, @@ -17,8 +17,8 @@ "brotli": 75 }, "shared": { - "min": 7413, - "brotli": 3289 + "min": 7420, + "brotli": 3287 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-input-chunk-load-error/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-input-chunk-load-error/sizes.json index d6022178fc9..81372ae1dae 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-input-chunk-load-error/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-input-chunk-load-error/sizes.json @@ -5,8 +5,8 @@ "brotli": 90 }, "template.marko.page.mjs": { - "min": 1575, - "brotli": 867 + "min": 1629, + "brotli": 883 }, "child.mjs": { "min": 124, @@ -17,8 +17,8 @@ "brotli": 69 }, "shared": { - "min": 7842, - "brotli": 3466 + "min": 7849, + "brotli": 3469 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-load-error/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-load-error/sizes.json index 1f4ce66abf0..d667ba097c7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-load-error/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-load-error/sizes.json @@ -5,8 +5,8 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1575, - "brotli": 867 + "min": 1629, + "brotli": 883 }, "child.mjs": { "min": 145, @@ -17,8 +17,8 @@ "brotli": 75 }, "shared": { - "min": 7853, - "brotli": 3467 + "min": 7860, + "brotli": 3470 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-mixed-known-and-dynamic/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-mixed-known-and-dynamic/sizes.json index 80ad5d550fa..094bb908d15 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-mixed-known-and-dynamic/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-mixed-known-and-dynamic/sizes.json @@ -5,16 +5,16 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1475, - "brotli": 792 + "min": 1516, + "brotli": 806 }, "child.mjs": { "min": 190, "brotli": 132 }, "shared": { - "min": 10889, - "brotli": 4736 + "min": 10896, + "brotli": 4737 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-unmount-before-load/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-unmount-before-load/sizes.json index d99a5649ef5..364db49320f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-unmount-before-load/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/lazy-tag-unmount-before-load/sizes.json @@ -5,8 +5,8 @@ "brotli": 69 }, "template.marko.page.mjs": { - "min": 1735, - "brotli": 921 + "min": 1779, + "brotli": 950 }, "child.mjs": { "min": 177, @@ -17,8 +17,8 @@ "brotli": 75 }, "shared": { - "min": 8958, - "brotli": 3878 + "min": 8965, + "brotli": 3885 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/__snapshots__/html.bundle.debug.js index e6b1de3cfcf..f46dc48fdea 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/__snapshots__/html.bundle.debug.js @@ -40,7 +40,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = start: 1 }); _scope($scope2_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "4:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await"); + }, 1, "__tests__/template.marko_1_#text#0/await"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4"); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/__snapshots__/html.bundle.js index 0e67eac243d..fd546590ba5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/__snapshots__/html.bundle.js @@ -38,7 +38,7 @@ var template_default = _template_persisted("a", (input) => { start: 1 }); _scope($scope2_id, { a: _existing_scope($childScope) }); - }, void 0, "a2"); + }, 1, "a2"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/sizes.json index 2a29c866f4d..4a39c989fc0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-mount/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 10967, - "brotli": 4634 + "min": 10909, + "brotli": 4615 }, "files": { "tags/counter.marko": 372, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/__snapshots__/html.bundle.debug.js index 6c5fb0a1fc3..520295b2d1c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/__snapshots__/html.bundle.debug.js @@ -40,7 +40,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = start: 2 }); _scope($scope3_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "3:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await"); + }, 1, "__tests__/template.marko_1_#text#0/await"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4"); return 0; } else { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/__snapshots__/html.bundle.js index 7e6d6f15bf9..794a07a05f6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/__snapshots__/html.bundle.js @@ -38,7 +38,7 @@ var template_default = _template_persisted("a", (input) => { start: 2 }); _scope($scope3_id, { a: _existing_scope($childScope) }); - }, void 0, "a2"); + }, 1, "a2"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } else { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/sizes.json index ee77560cc0d..c06d6836911 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-pending-scriptless/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10794, - "brotli": 4576 + "min": 10736, + "brotli": 4554 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/__snapshots__/html.bundle.debug.js index a99f69aaf14..67905964be1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/__snapshots__/html.bundle.debug.js @@ -33,7 +33,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = _patch_child($scope3_id, "#childScope/0", $childScope); pill_default({ text: value }); _scope($scope3_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "3:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await"); + }, 1, "__tests__/template.marko_1_#text#0/await"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4"); return 0; } else { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/__snapshots__/html.bundle.js index 84c8baac5a8..e0daec955a8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/__snapshots__/html.bundle.js @@ -30,7 +30,7 @@ var template_default = _template_persisted("a", (input) => { _patch_child($scope3_id, "a", $childScope); pill_default({ text: value }); _scope($scope3_id, { a: _existing_scope($childScope) }); - }, void 0, "a2"); + }, 1, "a2"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } else { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/sizes.json index b64d3d6cca5..f058869bf03 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-child-scriptless/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9175, - "brotli": 3964 + "min": 9138, + "brotli": 3950 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/__snapshots__/html.bundle.debug.js index d18e986d125..f77262f32b4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/__snapshots__/html.bundle.debug.js @@ -19,7 +19,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", value, void 0, $scope0_owned, 2)}`); _scope($scope3_id, {}, "__tests__/template.marko", "3:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await"); + }, 1, "__tests__/template.marko_1_#text#0/await"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4"); return 0; } else { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/__snapshots__/html.bundle.js index 48328cc9a4d..ceba9eb9fce 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/__snapshots__/html.bundle.js @@ -17,7 +17,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", value, void 0, $scope0_owned, 2)}`); _scope($scope3_id, {}); - }, void 0, "a2"); + }, 1, "a2"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } else { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/sizes.json index 4abec561c9b..2e4730a924e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch-scriptless/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9175, - "brotli": 3964 + "min": 9138, + "brotli": 3950 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/html.bundle.debug.js index bbcd445f8b0..bfb173fcb20 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/html.bundle.debug.js @@ -20,7 +20,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", value, void 0, $scope0_owned, 3)}`); _scope($scope3_id, {}, "__tests__/template.marko", "5:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await"); + }, 1, "__tests__/template.marko_1_#text#0/await"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "4:4"); return 0; } else { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/html.bundle.js index 2af48b2a03b..7d4486eab02 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/html.bundle.js @@ -18,7 +18,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", value, void 0, $scope0_owned, 3)}`); _scope($scope3_id, {}); - }, void 0, "a2"); + }, 1, "a2"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } else { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/render.debug.md index 33d03e7955a..c2c7b3e3164 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/render.debug.md +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/render.debug.md @@ -95,7 +95,8 @@ UPDATE: main > button::text@6 "1" => "2" ## Change ``` UPDATE: main > h1::text "Store" => "Store!" -UPDATE: main > em::text "hi" => "slow" +REMOVE: main > em +INSERT: main > h1 + em ``` # Update `{"title":"Store!","show":false,"promise":{}}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/render.md index 33d03e7955a..c2c7b3e3164 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/render.md +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/__snapshots__/render.md @@ -95,7 +95,8 @@ UPDATE: main > button::text@6 "1" => "2" ## Change ``` UPDATE: main > h1::text "Store" => "Store!" -UPDATE: main > em::text "hi" => "slow" +REMOVE: main > em +INSERT: main > h1 + em ``` # Update `{"title":"Store!","show":false,"promise":{}}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/sizes.json index 0c0c09cf9b9..84545d96a7f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10327, - "brotli": 4417 + "min": 10290, + "brotli": 4398 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/__snapshots__/html.bundle.debug.js index 9fb4d095cf6..1e90ab8ae7f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/__snapshots__/html.bundle.debug.js @@ -17,7 +17,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope2_id = _scope_id(); _html(`${_patch_text($scope2_id, "#text/0", value, void 0, $scope0_owned, 0)}`); _scope($scope2_id, {}, "__tests__/template.marko", "3:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await"); + }, 1, "__tests__/template.marko_1_#text#0/await"); $scope0_reason && _scope($scope1_id, {}, "__tests__/template.marko", "2:4"); }, "id", $scope0_id, "#text/0", 1, $sg__input_items, $sg__input_items, void 0, void 0, "__tests__/template.marko_1*shell"); _html(`${_el_resume($scope0_id, "#button/1")}`); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/__snapshots__/html.bundle.js index 6a2f2475fe9..4fc799de9af 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/__snapshots__/html.bundle.js @@ -15,7 +15,7 @@ var template_default = _template_persisted("a", (input) => { const $scope2_id = _scope_id(); _html(`${_patch_text($scope2_id, "a", value, void 0, $scope0_owned, 0)}`); _scope($scope2_id, {}); - }, void 0, "a2"); + }, 1, "a2"); $scope0_reason && _scope($scope1_id, {}); }, "id", $scope0_id, "a", 1, $sg__input_items, $sg__input_items, void 0, void 0, "a1"); _html(`${_el_resume($scope0_id, "b")}`); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/sizes.json index f7ccb56e89e..16e1de1fdc0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-in-loop/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11265, - "brotli": 4875 + "min": 11228, + "brotli": 4896 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/__snapshots__/html.bundle.debug.js index 474aa0216f7..b152783a5e1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/__snapshots__/html.bundle.debug.js @@ -34,7 +34,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "3:6")); _resume_branch($scope2_id); - }); + }, 1); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4"); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/__snapshots__/html.bundle.js index cd8d8b967d8..ddda0bada68 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/__snapshots__/html.bundle.js @@ -29,7 +29,7 @@ var template_default = _template_persisted("a", (input) => { a: _existing_scope($childScope) })); _resume_branch($scope2_id); - }); + }, 1); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/sizes.json index 9d63f700b36..02934495bc4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-inexpressible-scriptless/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9175, - "brotli": 3964 + "min": 9138, + "brotli": 3950 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/__snapshots__/html.bundle.debug.js index a71812fab35..83c5d32c96b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/__snapshots__/html.bundle.debug.js @@ -21,7 +21,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_text_resume($scope3_id, "#text/0", value)}`); _scope($scope3_id, {}, "__tests__/template.marko", "8:6"); - }, void 0, 0, 1); + }, 1, 0, 1); _subscribe($n__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "6:4")); _resume_branch($scope1_id); }, $scope0_id), { placeholder: attrTag({ content: _content_record("__tests__/template.marko_2*content", $scope0_id) }) }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/__snapshots__/html.bundle.js index b338cdb6aaa..a594e32920a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/__snapshots__/html.bundle.js @@ -19,7 +19,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_text_resume($scope3_id, "a", value)}`); _scope($scope3_id, {}); - }, void 0, 0, 1); + }, 1, 0, 1); _subscribe($n__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id), { placeholder: attrTag({ content: _content_record("a1", $scope0_id) }) }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/sizes.json index 29c3b5dadc7..08d460fea25 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy-client/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 12077, - "brotli": 5087 + "min": 12040, + "brotli": 5076 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/__snapshots__/html.bundle.debug.js index e650c0e5266..6405ee01ec0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/__snapshots__/html.bundle.debug.js @@ -24,7 +24,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", related, void 0, $scope0_owned, 0)}`); _scope($scope3_id, {}, "__tests__/template.marko", "9:8"); - }, void 0, "__tests__/template.marko_1_#text#0/await", 1); + }, 1, "__tests__/template.marko_1_#text#0/await", 1); $scope0_reason && _subscribe(_source_if($scope0_reason, 6) && $input_slow__closures, _subscribe(_source_if($scope0_reason, 5) && $input_related__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "7:6"))); _resume_branch($scope1_id); }, $scope0_id), { placeholder: attrTag({ content: _content_record("__tests__/template.marko_2*content", $scope0_id) }) }, 1); @@ -33,7 +33,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope4_id = _scope_id(); _html(`${_patch_text($scope4_id, "#text/0", note, void 0, $scope0_owned, 2)}`); _scope($scope4_id, {}, "__tests__/template.marko", "15:6"); - }, void 0, "__tests__/template.marko_0_#text#2/await", 1); + }, 1, "__tests__/template.marko_0_#text#2/await", 1); _html(`${_el_resume($scope0_id, "#button/3")}`); _script($scope0_id, "__tests__/template.marko_0"); $scope0_reason && _scope($scope0_id, { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/__snapshots__/html.bundle.js index 3f907bf2514..015f8a7df44 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/__snapshots__/html.bundle.js @@ -22,7 +22,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", related, void 0, $scope0_owned, 0)}`); _scope($scope3_id, {}); - }, void 0, "a3", 1); + }, 1, "a3", 1); $scope0_reason && _subscribe(_source_if($scope0_reason, 6) && $input_slow__closures, _subscribe(_source_if($scope0_reason, 5) && $input_related__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }))); _resume_branch($scope1_id); }, $scope0_id), { placeholder: attrTag({ content: _content_record("a2", $scope0_id) }) }, 1); @@ -31,7 +31,7 @@ var template_default = _template_persisted("a", (input) => { const $scope4_id = _scope_id(); _html(`${_patch_text($scope4_id, "a", note, void 0, $scope0_owned, 2)}`); _scope($scope4_id, {}); - }, void 0, "a5", 1); + }, 1, "a5", 1); _html(`${_el_resume($scope0_id, "d")}`); _script($scope0_id, "a6"); $scope0_reason && _scope($scope0_id, { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/sizes.json index e676f46b64a..b52185a327c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-lazy/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10069, - "brotli": 4318 + "min": 10032, + "brotli": 4312 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/__snapshots__/html.bundle.debug.js index 3f35a785a30..cde98de93fa 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/__snapshots__/html.bundle.debug.js @@ -25,14 +25,14 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = _html(`${_patch_text($scope3_id, "#text/0", outer, void 0, $scope0_owned, 4)}:${_patch_text($scope3_id, "#text/1", inner, 2, $scope0_owned, 5)}`); _subscribe($scope0_reason && $await_content__outer__closures, _scope($scope3_id, { _: _scope_with_id($scope2_id) }, "__tests__/template.marko", "4:8")); _resume_branch($scope3_id); - }, void 0, "__tests__/template.marko_2_#text#0/await"); + }, 1, "__tests__/template.marko_2_#text#0/await"); $scope0_reason && _subscribe(_source_if($scope0_reason, 5) && $input_inner__closures, _scope($scope2_id, { outer, _: _scope_with_id($scope1_id), "ClosureScopes:outer": $await_content__outer__closures }, "__tests__/template.marko", "3:6", { outer: "3:12" })); _resume_branch($scope2_id); - }, _source_guard($scope0_reason, 2), "__tests__/template.marko_1_#text#0/await"); + }, 1, "__tests__/template.marko_1_#text#0/await"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4"); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/__snapshots__/html.bundle.js index 9e70f3793a8..3521abb5a3d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/__snapshots__/html.bundle.js @@ -23,14 +23,14 @@ var template_default = _template_persisted("a", (input) => { _html(`${_patch_text($scope3_id, "a", outer, void 0, $scope0_owned, 4)}:${_patch_text($scope3_id, "b", inner, 2, $scope0_owned, 5)}`); _subscribe($scope0_reason && $await_content__outer__closures, _scope($scope3_id, { _: _scope_with_id($scope2_id) })); _resume_branch($scope3_id); - }, void 0, "a1"); + }, 1, "a1"); $scope0_reason && _subscribe(_source_if($scope0_reason, 5) && $input_inner__closures, _scope($scope2_id, { c: outer, _: _scope_with_id($scope1_id), d: $await_content__outer__closures })); _resume_branch($scope2_id); - }, _source_guard($scope0_reason, 2), "a4"); + }, 1, "a4"); $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/sizes.json index 0a4a1cfa73c..45298ffb643 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-nested-in-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9875, - "brotli": 4221 + "min": 9838, + "brotli": 4216 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..b8073a9417c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,15 @@ +// template.marko +const $template = "

"; +const $walks = "E l%l"; +const $await_content__value = ($scope, value) => _text($scope["#text/0"], value); +const $await_content__$params = ($scope, $params2) => $await_content__value($scope, $params2[0]); +const $input_title = ($scope, input_title) => _text($scope["#text/0"], input_title); +const $await_content = /*@__PURE__*/ _await_content("#text/1", " ", "D "); +const $await_promise = /*@__PURE__*/ _await_promise("#text/1", $await_content__$params); +const $setup = $await_content; +const $input_promise = $await_promise; +const $input = ($scope, input) => { + $input_title($scope, input.title); + $input_promise($scope, input.promise); +}; +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..7b1bfd44d24 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/html.bundle.debug.js @@ -0,0 +1,20 @@ +// template.marko +const $template = "

"; +const $walks = "E l%l"; +_shells({ + "__tests__/template.marko_1*content": "__tests__/template.marko_1*content;D ; ", + "__tests__/template.marko_0_#text#1/await": "__tests__/template.marko_0_#text#1/await;D ; ", + "__tests__/template.marko": "__tests__/template.marko;E l%;

" +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html(`

${_patch_text($scope0_id, "#text/0", input.title, void 0, $scope0_owned, 0)}

`); + _await($scope0_id, "#text/1", input.promise, (value) => { + const $scope1_id = _scope_id(); + _html(`${_patch_text($scope1_id, "#text/0", value, void 0, $scope0_owned, 1)}`); + _scope($scope1_id, {}, "__tests__/template.marko", "3:4"); + }, 1, "__tests__/template.marko_0_#text#1/await", 1); + _html("
"); + $scope0_reason && _scope($scope0_id, {}, "__tests__/template.marko", 0); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..6976482644b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/html.bundle.js @@ -0,0 +1,18 @@ +// template.marko +_shells({ + a0: "a0;D ; ", + a1: "a1;D ; ", + a: "a;E l%;

" +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html(`

${_patch_text($scope0_id, "a", input.title, void 0, $scope0_owned, 0)}

`); + _await($scope0_id, "b", input.promise, (value) => { + const $scope1_id = _scope_id(); + _html(`${_patch_text($scope1_id, "a", value, void 0, $scope0_owned, 1)}`); + _scope($scope1_id, {}); + }, 1, "a1", 1); + _html("
"); + $scope0_reason && _scope($scope0_id, {}); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..9fdebf649c8 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/patches.debug.js @@ -0,0 +1,21 @@ +// PATCH +{ + "PatchText:#text/0": "Store!", + "PatchPending:#text/1": 1 +} +{ + "PatchChild:BranchScopes:#text/1": { + "PatchText:#text/0": "slow" + } +} + +// PATCH +{ + "PatchText:#text/0": "Store!!", + "PatchPending:#text/1": 1 +} +{ + "PatchChild:BranchScopes:#text/1": { + "PatchText:#text/0": "slower" + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/patches.js new file mode 100644 index 00000000000..a312b852f1c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/patches.js @@ -0,0 +1,21 @@ +// PATCH +{ + ta: "Store!", + pb: 1 +} +{ + cAb: { + ta: "slow" + } +} + +// PATCH +{ + ta: "Store!!", + pb: 1 +} +{ + cAb: { + ta: "slower" + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/render.debug.md new file mode 100644 index 00000000000..ec9b5f45c1f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/render.debug.md @@ -0,0 +1,47 @@ +# Render `{"title":"Store","promise":{}}` +```html +
+

+ Store +

+ + hi + +
+``` + +# Update `{"title":"Store!","promise":{}}` +```html +
+

+ Store! +

+ + slow + +
+``` +## Change +``` +UPDATE: main > h1::text "Store" => "Store!" +REMOVE: main > em +INSERT: main > h1 + em +``` + +# Update `{"title":"Store!!","promise":{}}` +```html +
+

+ Store!! +

+ + slower + +
+``` +## Change +``` +UPDATE: main > h1::text "Store!" => "Store!!" +REMOVE: main > em +INSERT: main > h1 + em +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/render.md new file mode 100644 index 00000000000..ec9b5f45c1f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/render.md @@ -0,0 +1,47 @@ +# Render `{"title":"Store","promise":{}}` +```html +
+

+ Store +

+ + hi + +
+``` + +# Update `{"title":"Store!","promise":{}}` +```html +
+

+ Store! +

+ + slow + +
+``` +## Change +``` +UPDATE: main > h1::text "Store" => "Store!" +REMOVE: main > em +INSERT: main > h1 + em +``` + +# Update `{"title":"Store!!","promise":{}}` +```html +
+

+ Store!! +

+ + slower + +
+``` +## Change +``` +UPDATE: main > h1::text "Store!" => "Store!!" +REMOVE: main > em +INSERT: main > h1 + em +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..01e1260015c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/writes.debug.html @@ -0,0 +1,8 @@ +
+

Store

+ hi +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/writes.html new file mode 100644 index 00000000000..d2718ff77ec --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/__snapshots__/writes.html @@ -0,0 +1,7 @@ +
+

Store

hi +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/sizes.json new file mode 100644 index 00000000000..b43aeb1dff4 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 8705, + "brotli": 3767 + } + }, + "html": { + "min": 369, + "brotli": 250 + }, + "patch": { + "min": 77, + "brotli": 72 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/template.marko new file mode 100644 index 00000000000..e3770ad6076 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/template.marko @@ -0,0 +1,6 @@ +
+

${input.title}

+ + ${value} + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/test.ts new file mode 100644 index 00000000000..fa8433d1435 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending-twice/test.ts @@ -0,0 +1,21 @@ +import type { TestConfig } from "../../main.test"; + +const slow = (value: string) => ({ + // then() starts the timer so the delay begins at render, not at + // getSteps (which runs before the first document render). + then: (onFulfilled: (value: string) => unknown) => + new Promise((resolve) => setTimeout(resolve, 10, value)).then( + onFulfilled, + ), +}); + +// Two consecutive responses with a pending ``: the second must show +// its pending UI again (a settle from the first response is not sticky). +export const config: TestConfig = { + persisted: true, + steps: () => [ + { title: "Store", promise: Promise.resolve("hi") }, + { title: "Store!", promise: slow("slow") }, + { title: "Store!!", promise: slow("slower") }, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/__snapshots__/html.bundle.debug.js index ff34ac9fee2..7b1bfd44d24 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/__snapshots__/html.bundle.debug.js @@ -14,7 +14,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope1_id = _scope_id(); _html(`${_patch_text($scope1_id, "#text/0", value, void 0, $scope0_owned, 1)}`); _scope($scope1_id, {}, "__tests__/template.marko", "3:4"); - }, void 0, "__tests__/template.marko_0_#text#1/await", 1); + }, 1, "__tests__/template.marko_0_#text#1/await", 1); _html(""); $scope0_reason && _scope($scope0_id, {}, "__tests__/template.marko", 0); }, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/__snapshots__/html.bundle.js index 669fefce817..6976482644b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/__snapshots__/html.bundle.js @@ -12,7 +12,7 @@ var template_default = _template_persisted("a", (input) => { const $scope1_id = _scope_id(); _html(`${_patch_text($scope1_id, "a", value, void 0, $scope0_owned, 1)}`); _scope($scope1_id, {}); - }, void 0, "a1", 1); + }, 1, "a1", 1); _html(""); $scope0_reason && _scope($scope0_id, {}); }, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/sizes.json index c151657a7cd..7fd0a060518 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-pending/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8742, - "brotli": 3787 + "min": 8705, + "brotli": 3767 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/__snapshots__/html.bundle.debug.js index bd0441049df..c55e85cd2ae 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/__snapshots__/html.bundle.debug.js @@ -19,7 +19,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope4_id = _scope_id(); _html(`${_patch_text($scope4_id, "#text/0", value, void 0, $scope0_owned, 0)}`); _scope($scope4_id, {}, "__tests__/template.marko", "4:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await", 1); + }, 1, "__tests__/template.marko_1_#text#0/await", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4")); _resume_branch($scope1_id); }, $scope0_id), { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/__snapshots__/html.bundle.js index 45cef53bc93..a53d436ea7e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/__snapshots__/html.bundle.js @@ -17,7 +17,7 @@ var template_default = _template_persisted("a", (input) => { const $scope4_id = _scope_id(); _html(`${_patch_text($scope4_id, "a", value, void 0, $scope0_owned, 0)}`); _scope($scope4_id, {}); - }, void 0, "a2", 1); + }, 1, "a2", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id), { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/sizes.json index 9c5fdb4d8b0..10852dfc1ba 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-reject-try/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9175, - "brotli": 3976 + "min": 9138, + "brotli": 3948 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/__snapshots__/html.bundle.debug.js index 4e5ebfcea02..79a7e258ebc 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/__snapshots__/html.bundle.debug.js @@ -15,7 +15,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope1_id = _scope_id(); _html(`${_patch_text($scope1_id, "#text/0", value, void 0, $scope0_owned, 1)}`); _scope($scope1_id, {}, "__tests__/template.marko", "4:4"); - }, void 0, "__tests__/template.marko_0_#text#1/await", 1); + }, 1, "__tests__/template.marko_0_#text#1/await", 1); _html(`${_el_resume($scope0_id, "#button/2")}`); _script($scope0_id, "__tests__/template.marko_0"); $scope0_reason && _scope($scope0_id, { count }, "__tests__/template.marko", 0, { count: "1:6" }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/__snapshots__/html.bundle.js index 49d29f790c5..e62d28721c7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/__snapshots__/html.bundle.js @@ -13,7 +13,7 @@ var template_default = _template_persisted("a", (input) => { const $scope1_id = _scope_id(); _html(`${_patch_text($scope1_id, "a", value, void 0, $scope0_owned, 1)}`); _scope($scope1_id, {}); - }, void 0, "a1", 1); + }, 1, "a1", 1); _html(`${_el_resume($scope0_id, "c")}`); _script($scope0_id, "a2"); $scope0_reason && _scope($scope0_id, { i: count }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/sizes.json index d9f24e622e7..839a7011134 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-await-settled/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9889, - "brotli": 4240 + "min": 9853, + "brotli": 4229 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/__snapshots__/html.bundle.debug.js index 350d466b7f2..fba6eca4664 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/__snapshots__/html.bundle.debug.js @@ -20,7 +20,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", value, void 0, $scope0_owned, 1)}`); _scope($scope3_id, {}, "__tests__/template.marko", "4:6"); - }, void 0, "__tests__/template.marko_2_#text#0/await", 1); + }, 1, "__tests__/template.marko_2_#text#0/await", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4")); _resume_branch($scope2_id); }, $scope0_id), { catch: attrTag({ content: _content_resume("__tests__/template.marko_1*content", (err) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/__snapshots__/html.bundle.js index 45cc0afde62..5026574bb06 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/__snapshots__/html.bundle.js @@ -18,7 +18,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", value, void 0, $scope0_owned, 1)}`); _scope($scope3_id, {}); - }, void 0, "a1", 1); + }, 1, "a1", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope2_id); }, $scope0_id), { catch: attrTag({ content: _content_resume("a3", (err) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/sizes.json index 8c635638100..a7a42561c30 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-fill/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11170, - "brotli": 4729 + "min": 11112, + "brotli": 4706 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..5f8a82d8241 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,31 @@ +// template.marko +const $template = "
"; +const $walks = "D%b D m"; +const $await_content__value = ($scope, value) => _text($scope["#text/0"], value); +const $await_content__$params = ($scope, $params2) => $await_content__value($scope, $params2[0]); +const $catch_content__tag = /*@__PURE__*/ _fill_join_closure("__tests__/template.marko0", "tag", /*@__PURE__*/ _closure_get("tag", ($scope) => _text($scope["#text/0"], $scope._.tag)), 0); +const $catch_content__setup = $catch_content__tag; +const $catch_content = _content_resume("__tests__/template.marko_2*content", "

", "D ", $catch_content__setup); +const $await_content = /*@__PURE__*/ _await_content("#text/0", " ", "D "); +const $try_content__await_promise = /*@__PURE__*/ _await_promise("#text/0", $await_content__$params); +const $try_content__input_promise = /*@__PURE__*/ _closure_get("input_promise", ($scope) => $try_content__await_promise($scope, $scope._.input_promise)); +const $try_content__setup = ($scope) => { + $try_content__input_promise($scope); + $await_content($scope); +}; +const $tag__closure = /*@__PURE__*/ _closure($catch_content__tag); +const $tag = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "tag", $tag__closure); +const $n = /*@__PURE__*/ _let("n/8", ($scope) => _text($scope["#text/2"], $scope.n)); +const $try = /*@__PURE__*/ _try("#text/0", "", "b%", $try_content__setup); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { + $n($scope, +$scope.n + 1); +})); +function $setup($scope) { + $n($scope, 0); + $try($scope, { catch: attrTag({ content: $catch_content($scope) }) }); + $setup__script($scope); +} +const $input = ($scope, input) => $input_promise($scope, input.promise); +const $input_promise__closure = /*@__PURE__*/ _closure($try_content__input_promise); +const $input_promise = /*@__PURE__*/ _const("input_promise", $input_promise__closure); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..62c7295ed1e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/dom.bundle.js @@ -0,0 +1,6 @@ +// template.marko +const $catch_content = _content_resume("a3", "

", "D ", /* @__PURE__ */ _fill_join_closure("a0", 6, /*@__PURE__*/ _closure_get(10, ($scope) => _text($scope.a, $scope._.g)), 0)); +const $n = /*@__PURE__*/ _let(8, ($scope) => _text($scope.c, $scope.i)); +const $setup__script = _script("a4", ($scope) => _on($scope.b, "click", function() { + $n($scope, +$scope.i + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index 79bc469388e..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/template.marko:8:18 - 6 | ${value} - 7 |
- > 8 | <@catch>

${tag}

- | ^^^ Persisted templates cannot patch this faithfully yet: a `$global`-derived value inside `<@catch>` content would go stale. - 9 |
- 10 | - 11 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-dom.txt deleted file mode 100644 index 79bc469388e..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/template.marko:8:18 - 6 | ${value} - 7 | - > 8 | <@catch>

${tag}

- | ^^^ Persisted templates cannot patch this faithfully yet: a `$global`-derived value inside `<@catch>` content would go stale. - 9 |
- 10 | - 11 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index 79bc469388e..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/template.marko:8:18 - 6 | ${value} - 7 | - > 8 | <@catch>

${tag}

- | ^^^ Persisted templates cannot patch this faithfully yet: a `$global`-derived value inside `<@catch>` content would go stale. - 9 |
- 10 | - 11 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-html.txt deleted file mode 100644 index 79bc469388e..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/template.marko:8:18 - 6 | ${value} - 7 | - > 8 | <@catch>

${tag}

- | ^^^ Persisted templates cannot patch this faithfully yet: a `$global`-derived value inside `<@catch>` content would go stale. - 9 |
- 10 | - 11 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..d2fd568bd0d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/html.bundle.debug.js @@ -0,0 +1,47 @@ +// template.marko +const $template = "
"; +const $walks = "D%b D m"; +_shells({ + "__tests__/template.marko_3*content": "__tests__/template.marko_3*content;D ; ", + "__tests__/template.marko_1_#text#0/await": "__tests__/template.marko_1_#text#0/await;D ; ", + "__tests__/template.marko_1*content": "__tests__/template.marko_1*content;b%;" +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $tag__closures = new Set(); + const $input_promise__closures = new Set(); + const $global$1 = $global(); + const tag = `${$global$1.brand}!`; + let n = 0; + _html("
"); + _try($scope0_id, "#text/0", _content_resume("__tests__/template.marko_1*content", () => { + const $scope1_id = _scope_id(); + const $scope1_reason = _persisted_reason(); + _await($scope1_id, "#text/0", input.promise, (value) => { + const $scope3_id = _scope_id(); + _html(`${_patch_text($scope3_id, "#text/0", value, void 0, $scope0_owned, 0)}`); + _scope($scope3_id, {}, "__tests__/template.marko", "5:6"); + }, 1, "__tests__/template.marko_1_#text#0/await", 1); + $scope0_reason && _subscribe($input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "4:4")); + _resume_branch($scope1_id); + }, $scope0_id), { catch: attrTag({ content: _content_resume("__tests__/template.marko_2*content", () => { + const $scope2_reason = _persisted_reason(); + const $scope2_id = _scope_id(); + _html(`

${_text_resume($scope2_id, "#text/0", tag)}

`); + _subscribe($scope0_reason && $tag__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "8:6")); + _resume_branch($scope2_id); + }, $scope0_id) }) }, 1); + _html(`${_el_resume($scope0_id, "#button/1")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + tag, + n, + "ClosureScopes:tag": $tag__closures, + "ClosureScopes:input_promise": $input_promise__closures + }, "__tests__/template.marko", 0, { + tag: "1:8", + n: "2:6" + }) : _patch_value($scope0_id, "__tests__/template.marko0", tag); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..7c335c3913a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/html.bundle.js @@ -0,0 +1,41 @@ +// template.marko +_shells({ + a0: "a0;D ; ", + a1: "a1;D ; ", + a2: "a2;b%;" +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $tag__closures = /* @__PURE__ */ new Set(); + const $input_promise__closures = /* @__PURE__ */ new Set(); + const tag = `${$global().brand}!`; + let n = 0; + _html("
"); + _try($scope0_id, "a", _content_resume("a2", () => { + const $scope1_id = _scope_id(); + _persisted_reason(); + _await($scope1_id, "a", input.promise, (value) => { + const $scope3_id = _scope_id(); + _html(`${_patch_text($scope3_id, "a", value, void 0, $scope0_owned, 0)}`); + _scope($scope3_id, {}); + }, 1, "a1", 1); + $scope0_reason && _subscribe($input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); + _resume_branch($scope1_id); + }, $scope0_id), { catch: attrTag({ content: _content_resume("a3", () => { + _persisted_reason(); + const $scope2_id = _scope_id(); + _html(`

${_text_resume($scope2_id, "a", tag)}

`); + _subscribe($scope0_reason && $tag__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) })); + _resume_branch($scope2_id); + }, $scope0_id) }) }, 1); + _html(`${_el_resume($scope0_id, "b")}
`); + _script($scope0_id, "a4"); + $scope0_reason ? _scope($scope0_id, { + g: tag, + i: n, + k: $tag__closures, + j: $input_promise__closures + }) : _patch_value($scope0_id, "a0", tag); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..16b62d5b47d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/patches.debug.js @@ -0,0 +1,8 @@ +// PATCH +{ + "PatchChild:BranchScopes:#text/0": { + "PatchPending:#text/0": 1, + "PatchCatch:#text/0": new Error("boom") + }, + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/template.marko0": "bmce!" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/patches.js new file mode 100644 index 00000000000..745a5b2856e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/patches.js @@ -0,0 +1,8 @@ +// PATCH +{ + cAa: { + pa: 1, + ka: new Error("boom") + }, + va0: "bmce!" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/render.debug.md new file mode 100644 index 00000000000..ebec67eb4a9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/render.debug.md @@ -0,0 +1,29 @@ +# Render `{"promise":{},"$global":{"brand":"acme"}}` +```html +
+ + ok + + +
+``` + +# Update `{"promise":{},"$global":{"brand":"bmce"}}` +```html +
+

+ bmce! +

+ +
+``` +## Change +``` +INSERT: main > p +REMOVE: main > p + em +UPDATE: main > p::text " " => "bmce!" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/render.md new file mode 100644 index 00000000000..ebec67eb4a9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/render.md @@ -0,0 +1,29 @@ +# Render `{"promise":{},"$global":{"brand":"acme"}}` +```html +
+ + ok + + +
+``` + +# Update `{"promise":{},"$global":{"brand":"bmce"}}` +```html +
+

+ bmce! +

+ +
+``` +## Change +``` +INSERT: main > p +REMOVE: main > p + em +UPDATE: main > p::text " " => "bmce!" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..2368ef4b614 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/writes.debug.html @@ -0,0 +1,21 @@ +
+ ok +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/writes.html new file mode 100644 index 00000000000..62898faadfd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/__snapshots__/writes.html @@ -0,0 +1,17 @@ +
+ ok +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/sizes.json new file mode 100644 index 00000000000..6e85718c295 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 11047, + "brotli": 4675 + } + }, + "html": { + "min": 527, + "brotli": 337 + }, + "patch": { + "min": 46, + "brotli": 50 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/test.ts index dc731ec6969..5046f71fd8f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-global-derived/test.ts @@ -1,8 +1,12 @@ import type { TestConfig } from "../../main.test"; -// A `$global`-derived value never re-ships, so reading it inside `<@catch>` -// content on an interactive page stays closed. +// `@catch` content reading a `$global`-derived value: the derivation +// delivers as a fill each frame, so the catch UI renders the rejecting +// patch's brand, not the initial render's. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: () => [ + { promise: Promise.resolve("ok"), $global: { brand: "acme" } }, + { promise: Promise.reject(new Error("boom")), $global: { brand: "bmce" } }, + ], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/__snapshots__/html.bundle.debug.js index c545b807df8..ce5c2ba6166 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/__snapshots__/html.bundle.debug.js @@ -18,7 +18,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", value, void 0, $scope0_owned, 0)}`); _scope($scope3_id, {}, "__tests__/template.marko", "3:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await", 1); + }, 1, "__tests__/template.marko_1_#text#0/await", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4")); _resume_branch($scope1_id); }, $scope0_id), { catch: attrTag({ content: _content_elide("__tests__/template.marko_2*content", (err) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/__snapshots__/html.bundle.js index 16606edf828..9048b4375e7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/__snapshots__/html.bundle.js @@ -16,7 +16,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", value, void 0, $scope0_owned, 0)}`); _scope($scope3_id, {}); - }, void 0, "a1", 1); + }, 1, "a1", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id), { catch: attrTag({ content: _content_elide("a3", (err) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/sizes.json index 48f52649b02..ade6576bd81 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-scriptless/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9089, - "brotli": 3937 + "min": 9052, + "brotli": 3924 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/__snapshots__/html.bundle.debug.js index 114beac2575..b5631f29e47 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/__snapshots__/html.bundle.debug.js @@ -19,7 +19,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", value, void 0, $scope0_owned, 1)}`); _scope($scope3_id, {}, "__tests__/template.marko", "3:6"); - }, void 0, "__tests__/template.marko_2_#text#0/await", 1); + }, 1, "__tests__/template.marko_2_#text#0/await", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4")); _resume_branch($scope2_id); }, $scope0_id), { catch: attrTag({ content: _content_elide("__tests__/template.marko_1*content", (err) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/__snapshots__/html.bundle.js index ccb3f949799..4ef2402af9f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/__snapshots__/html.bundle.js @@ -17,7 +17,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", value, void 0, $scope0_owned, 1)}`); _scope($scope3_id, {}); - }, void 0, "a1", 1); + }, 1, "a1", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope2_id); }, $scope0_id), { catch: attrTag({ content: _content_elide("a3", (err) => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/sizes.json index 5c2236e69dc..9031cd42eb8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-catch-server-read/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9089, - "brotli": 3937 + "min": 9052, + "brotli": 3924 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/__snapshots__/html.bundle.debug.js index debdea38a72..403468c648d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/__snapshots__/html.bundle.debug.js @@ -20,7 +20,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", value, void 0, $scope0_owned, 1)}`); _scope($scope3_id, {}, "__tests__/template.marko", "4:6"); - }, void 0, "__tests__/template.marko_2_#text#0/await", 1); + }, 1, "__tests__/template.marko_2_#text#0/await", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4")); _resume_branch($scope2_id); }, $scope0_id), { placeholder: attrTag({ content: _content_resume("__tests__/template.marko_1*content", () => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/__snapshots__/html.bundle.js index a6300a23c36..a37eb6f5d78 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/__snapshots__/html.bundle.js @@ -18,7 +18,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", value, void 0, $scope0_owned, 1)}`); _scope($scope3_id, {}); - }, void 0, "a1", 1); + }, 1, "a1", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope2_id); }, $scope0_id), { placeholder: attrTag({ content: _content_resume("a3", () => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/sizes.json index 7806e872ab0..9434d120f70 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-placeholder-fill/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11131, - "brotli": 4708 + "min": 11073, + "brotli": 4689 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-catch-only/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-catch-only/sizes.json index 658c289878f..effb6dad055 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-catch-only/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-catch-only/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9175, - "brotli": 3976 + "min": 9138, + "brotli": 3948 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/__snapshots__/html.bundle.debug.js index 15f4fdbc410..d8ab95381a0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/__snapshots__/html.bundle.debug.js @@ -28,7 +28,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = "ClosureSignalIndex:input_value": 1 }, "__tests__/template.marko", "4:8"); _resume_branch($scope3_id); - }, void 0, "__tests__/template.marko_2_#text#0/await"); + }, 1, "__tests__/template.marko_2_#text#0/await"); $scope0_reason && _subscribe(_source_if($scope0_reason, 2) && $input_value__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "3:6")); _resume_branch($scope2_id); }, $scope1_id), { placeholder: attrTag({ content: _content_record("__tests__/template.marko_4*content", $scope1_id) }) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/__snapshots__/html.bundle.js index f8c785e48cb..9e26e21a87b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/__snapshots__/html.bundle.js @@ -26,7 +26,7 @@ var template_default = _template_persisted("a", (input) => { Cf: 1 }); _resume_branch($scope3_id); - }, void 0, "a2"); + }, 1, "a2"); $scope0_reason && _subscribe(_source_if($scope0_reason, 2) && $input_value__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) })); _resume_branch($scope2_id); }, $scope1_id), { placeholder: attrTag({ content: _content_record("a0", $scope1_id) }) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/sizes.json index c66dbfa8f97..89c129a79b7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-in-branch-scriptless/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9612, - "brotli": 4144 + "min": 9575, + "brotli": 4122 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/__snapshots__/html.bundle.debug.js index 77bacaec375..dc24e995386 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/__snapshots__/html.bundle.debug.js @@ -25,7 +25,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope5_id = _scope_id(); _html(`${_patch_text($scope5_id, "#text/0", value, void 0, $scope0_owned, 0)}`); _scope($scope5_id, {}, "__tests__/template.marko", "4:8"); - }, void 0, "__tests__/template.marko_2_#text#0/await", 1); + }, 1, "__tests__/template.marko_2_#text#0/await", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "3:6")); _resume_branch($scope2_id); }, $scope1_id), { catch: attrTag({ content: _content_record("__tests__/template.marko_4*content", $scope1_id) }) }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/__snapshots__/html.bundle.js index abe3660c839..b7f56fd62d9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/__snapshots__/html.bundle.js @@ -23,7 +23,7 @@ var template_default = _template_persisted("a", (input) => { const $scope5_id = _scope_id(); _html(`${_patch_text($scope5_id, "a", value, void 0, $scope0_owned, 0)}`); _scope($scope5_id, {}); - }, void 0, "a3", 1); + }, 1, "a3", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) })); _resume_branch($scope2_id); }, $scope1_id), { catch: attrTag({ content: _content_record("a1", $scope1_id) }) }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/sizes.json index 817b1eafbc5..1b1c03139d8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-nested-await/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9175, - "brotli": 3976 + "min": 9138, + "brotli": 3948 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/__snapshots__/html.bundle.debug.js index 3ecc8e5c1fc..32dd2d060fe 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/__snapshots__/html.bundle.debug.js @@ -20,7 +20,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", value, void 0, $scope0_owned, 1)}`); _scope($scope3_id, {}, "__tests__/template.marko", "4:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await", 1); + }, 1, "__tests__/template.marko_1_#text#0/await", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4")); _resume_branch($scope1_id); }, $scope0_id), { placeholder: attrTag({ content: _content_record("__tests__/template.marko_2*content", $scope0_id) }) }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/__snapshots__/html.bundle.js index 0406eb8ae77..dde8d5b40be 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/__snapshots__/html.bundle.js @@ -18,7 +18,7 @@ var template_default = _template_persisted("a", (input) => { const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", value, void 0, $scope0_owned, 1)}`); _scope($scope3_id, {}); - }, void 0, "a2", 1); + }, 1, "a2", 1); $scope0_reason && _subscribe($input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope1_id); }, $scope0_id), { placeholder: attrTag({ content: _content_record("a1", $scope0_id) }) }, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/sizes.json index c5ddbada1d2..683fe0490e7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-async-try-placeholder/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9181, - "brotli": 3958 + "min": 9144, + "brotli": 3948 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..cbe896b2828 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,44 @@ +// tags/wrap/index.marko +const $template$1 = "
"; +const $walks$1 = "D%l"; +const $setup$1 = () => {}; +const $input_content_direct = /*@__PURE__*/ _dynamic_tag_content("#text/0"); +const $dynamicTag = /*@__PURE__*/ _dynamic_tag("#text/0"); +const $input_content = $dynamicTag; +const $input$1 = ($scope, input) => $input_content($scope, input.content); +var wrap_default = /*@__PURE__*/ _template("__tests__/tags/wrap/index.marko", $template$1, "D%l", 0, $input$1); + +// template.marko +const $template = /*@__PURE__*/ ((_w0) => `${_w0}`)($template$1); +const $walks = /*@__PURE__*/ ((_w0) => ` D l/${_w0}&`)("D%l"); +const $placeholder_content = _content_resume("__tests__/template.marko_4*content", "loading"); +const $await_content__input_msg = /*@__PURE__*/ _closure_get("input_msg", ($scope) => _text($scope["#text/0"], $scope._._._.input_msg), ($scope) => $scope._._._, "__tests__/template.marko_3_input_msg#6/pending"); +const $await_content__setup = $await_content__input_msg; +const $await_content = /*@__PURE__*/ _await_content("#text/0", "
done
", "D%", $await_content__setup); +const $try_content__await_promise = /*@__PURE__*/ _await_promise("#text/0"); +const $try_content__input_promise = /*@__PURE__*/ _closure_get("input_promise", ($scope) => $try_content__await_promise($scope, $scope._._.input_promise), ($scope) => $scope._._); +const $try_content__setup = ($scope) => { + $try_content__input_promise($scope); + $await_content($scope); +}; +const $wrap_content__try = /*@__PURE__*/ _try("#text/0", "", "b%", $try_content__setup); +const $wrap_content__setup = ($scope) => $wrap_content__try($scope, { placeholder: attrTag({ content: $placeholder_content($scope) }) }); +const $wrap_content = /*@__PURE__*/ _content("__tests__/template.marko_1*content", "", "b%", $wrap_content__setup); +const $count = /*@__PURE__*/ _let("count/7", ($scope) => _text($scope["#text/1"], $scope.count)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $input_content_direct($scope["#childScope/2"], $wrap_content($scope)); + $count($scope, 0); + $setup__script($scope); +} +const $input = ($scope, input) => { + $input_promise($scope, input.promise); + $input_msg($scope, input.msg); +}; +const $input_promise__closure = /*@__PURE__*/ _closure($try_content__input_promise); +const $input_promise = /*@__PURE__*/ _const("input_promise", $input_promise__closure); +const $input_msg__closure = /*@__PURE__*/ _closure($await_content__input_msg); +const $input_msg = /*@__PURE__*/ _const("input_msg", $input_msg__closure); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..308d2ad32fe --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/dom.bundle.js @@ -0,0 +1,6 @@ +// template.marko +const $placeholder_content = _content_resume("a0", "loading"); +const $count = /*@__PURE__*/ _let(7, ($scope) => _text($scope.b, $scope.h)); +const $setup__script = _script("a5", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.h + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..74b5504e7b0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/html.bundle.debug.js @@ -0,0 +1,65 @@ +// tags/wrap/index.marko +const $template$1 = "
"; +const $walks$1 = "D%l"; +_shells({ "__tests__/tags/wrap/index.marko": "__tests__/tags/wrap/index.marko;D%;
" }); +var wrap_default = _template_persisted("__tests__/tags/wrap/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _patch_dynamic_tag($scope0_id, "#text/0", input.content, $scope0_owned, 0); + _dynamic_tag($scope0_id, "#text/0", input.content, {}, 0, 0, _source_guard($scope0_reason, 0), 1); + _html("
"); + $scope0_reason && _scope($scope0_id, {}, "__tests__/tags/wrap/index.marko", 0); +}, 0, 0); + +// template.marko +const $template = /*@__PURE__*/ ((_w0) => `${_w0}`)($template$1); +const $walks = /*@__PURE__*/ ((_w0) => ` D l/${_w0}&`)("D%l"); +_shells({ + "__tests__/template.marko_4*content": "__tests__/template.marko_4*content,loading", + "__tests__/template.marko_3*content": "__tests__/template.marko_3*content;D%;
done
", + "__tests__/template.marko_2_#text#0/await": "__tests__/template.marko_2_#text#0/await;D%;
done
", + "__tests__/template.marko_2*content": "__tests__/template.marko_2*content;b%;", + "__tests__/template.marko_1*content": "__tests__/template.marko_1*content;b%;", + "__tests__/template.marko": /*@__PURE__*/ ((_w0, _w1) => `__tests__/template.marko !__tests__/template.marko_0;${_w0};${_w1}`)(((_w0) => ` D l/${_w0}&`)("D%l"), ((_w0) => `${_w0}`)($template$1)) +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = new Set(); + const $input_promise__closures = new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + _set_serialize_reason(0); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "#childScope/2", $childScope); + wrap_default({ content: _content_elide("__tests__/template.marko_1*content", () => { + const $scope1_reason = _persisted_reason(); + const $scope1_id = _scope_id(); + _try($scope1_id, "#text/0", _content_resume("__tests__/template.marko_2*content", () => { + const $scope2_id = _scope_id(); + const $scope2_reason = _persisted_reason(); + _await($scope2_id, "#text/0", input.promise, () => { + const $scope3_id = _scope_id(); + _html(`
${_patch_text($scope3_id, "#text/0", input.msg, void 0, $scope0_owned, 2)} done
`); + _scope($scope3_id, { _: _scope_with_id($scope2_id) }, "__tests__/template.marko", "5:6"); + _resume_branch($scope3_id); + }, 1, "__tests__/template.marko_2_#text#0/await"); + $scope0_reason && _subscribe(_source_if($scope0_reason, 1) && $input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "4:4")); + _resume_branch($scope2_id); + }, $scope1_id), { placeholder: attrTag({ content: _content_record("__tests__/template.marko_4*content", $scope1_id) }) }); + $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:2"); + }, $scope0_id) }); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason && _scope($scope0_id, { + input_msg: input.msg, + count, + "ClosureScopes:input_msg": $input_msg__closures, + "ClosureScopes:input_promise": $input_promise__closures, + "#childScope/2": _existing_scope($childScope) + }, "__tests__/template.marko", 0, { + input_msg: ["input.msg"], + count: "1:6" + }); + _resume_branch($scope0_id); +}, 1, () => [wrap_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..ea4f9937b97 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/html.bundle.js @@ -0,0 +1,59 @@ +// tags/wrap/index.marko +const $template = "
"; +_shells({ b: "b;D%;
" }); +var wrap_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _patch_dynamic_tag($scope0_id, "a", input.content, $scope0_owned, 0); + _dynamic_tag($scope0_id, "a", input.content, {}, 0, 0, _source_guard($scope0_reason, 0), 1); + _html("
"); + $scope0_reason && _scope($scope0_id, {}); +}, 0, 0); + +// template.marko +_shells({ + a0: "a0,loading", + a1: "a1;D%;
done
", + a2: "a2;D%;
done
", + a3: "a3;b%;", + a4: "a4;b%;", + a: /*@__PURE__*/ ((_w0, _w1) => `a !a5;${_w0};${_w1}`)(((_w0) => ` D l/${_w0}&`)("D%l"), ((_w0) => `${_w0}`)($template)) +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = /* @__PURE__ */ new Set(); + const $input_promise__closures = /* @__PURE__ */ new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + _set_serialize_reason(0); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "c", $childScope); + wrap_default({ content: _content_elide("a4", () => { + _persisted_reason(); + const $scope1_id = _scope_id(); + _try($scope1_id, "a", _content_resume("a3", () => { + const $scope2_id = _scope_id(); + _persisted_reason(); + _await($scope2_id, "a", input.promise, () => { + const $scope3_id = _scope_id(); + _html(`
${_patch_text($scope3_id, "a", input.msg, void 0, $scope0_owned, 2)} done
`); + _scope($scope3_id, { _: _scope_with_id($scope2_id) }); + _resume_branch($scope3_id); + }, 1, "a2"); + $scope0_reason && _subscribe(_source_if($scope0_reason, 1) && $input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) })); + _resume_branch($scope2_id); + }, $scope1_id), { placeholder: attrTag({ content: _content_record("a0", $scope1_id) }) }); + $scope0_reason && _scope($scope1_id, { _: _scope_with_id($scope0_id) }); + }, $scope0_id) }); + _script($scope0_id, "a5"); + $scope0_reason && _scope($scope0_id, { + g: input.msg, + h: count, + j: $input_msg__closures, + i: $input_promise__closures, + c: _existing_scope($childScope) + }); + _resume_branch($scope0_id); +}, 1, () => [wrap_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..40459b1155e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/patches.debug.js @@ -0,0 +1,13 @@ +// PATCH +[`packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko_2_#text#0/await;D%;
done
`, `packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko_2*content;b%;`, `packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko_4*content,loading`, { + "PatchChild:#childScope/2": { + "PatchChild:BranchScopes:#text/0": { + "PatchChild:BranchScopes:#text/0": [{ + "PatchPending:#text/0": "packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko_2_#text#0/await", + "PatchChild:BranchScopes:#text/0": { + "PatchText:#text/0": "b" + } + }, "packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko_2*content", $, "packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko_4*content"] + } + } +}] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/patches.js new file mode 100644 index 00000000000..f44b807af5b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/patches.js @@ -0,0 +1,13 @@ +// PATCH +[`a2;D%;
done
`, `a3;b%;`, `a0,loading`, { + cc: { + cAa: { + cAa: [{ + pa: "a2", + cAa: { + ta: "b" + } + }, "a3", $, "a0"] + } + } +}] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/render.debug.md new file mode 100644 index 00000000000..3179de2e4fb --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/render.debug.md @@ -0,0 +1,50 @@ +# Render `{"msg":"a","promise":{"value":2}}` +```html + +
+ + loading + +
+``` + +# Update +```html + +
+
+ a done +
+
+``` +## Change +``` +INSERT: #done::text("a") +INSERT: #done::text@0 + ::text(" done") +REMOVE: section > em +INSERT: section > #done +``` + +# Update `{"msg":"b","promise":{"value":2}}` +```html + +
+
+ b done +
+
+``` +## Change +``` +UPDATE: #done::text@0 "a" => "b" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/render.md new file mode 100644 index 00000000000..3179de2e4fb --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/render.md @@ -0,0 +1,50 @@ +# Render `{"msg":"a","promise":{"value":2}}` +```html + +
+ + loading + +
+``` + +# Update +```html + +
+
+ a done +
+
+``` +## Change +``` +INSERT: #done::text("a") +INSERT: #done::text@0 + ::text(" done") +REMOVE: section > em +INSERT: section > #done +``` + +# Update `{"msg":"b","promise":{"value":2}}` +```html + +
+
+ b done +
+
+``` +## Change +``` +UPDATE: #done::text@0 "a" => "b" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..802bce1729d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/writes.debug.html @@ -0,0 +1,43 @@ + +
+ loading +
+ + + + + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/writes.html new file mode 100644 index 00000000000..c0cb6a9c919 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/__snapshots__/writes.html @@ -0,0 +1,39 @@ + +
+ loading +
+ + + + + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/sizes.json new file mode 100644 index 00000000000..f0a2eb0bf88 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 13131, + "brotli": 5453 + } + }, + "html": { + "min": 1223, + "brotli": 675 + }, + "patch": { + "min": 132, + "brotli": 119 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/tags/wrap/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/tags/wrap/index.marko new file mode 100644 index 00000000000..e74490cbca8 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/tags/wrap/index.marko @@ -0,0 +1 @@ +
<${input.content}/>
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko new file mode 100644 index 00000000000..3d5b594d59c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/template.marko @@ -0,0 +1,12 @@ + + + + + +
${input.msg} done
+ + <@placeholder> + loading + +
+
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/test.ts new file mode 100644 index 00000000000..d4b7eb082cf --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-in-content/test.ts @@ -0,0 +1,18 @@ +import type { TestConfig } from "../../main.test"; +import { flush, resolveAfter, wait } from "../../utils/resolve"; + +// A server value rendered inside an `` body whose chain to the owner +// crosses a non-branch content section: the boundary's marker always +// resumes on persisted pages, so a patch pairs the settled body and updates +// the text through the content chain. +export const config: TestConfig = { + persisted: true, + steps: () => [ + { msg: "a", promise: resolveAfter(2) }, + wait, + flush, + { msg: "b", promise: resolveAfter(2) }, + wait, + flush, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..b0891ea71e8 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,32 @@ +// template.marko +const $template = ""; +const $walks = " D l%c"; +const $placeholder_content = _content_resume("__tests__/template.marko_3*content", "loading"); +const $await_content__input_msg = /*@__PURE__*/ _closure_get("input_msg", ($scope) => _text($scope["#text/0"], $scope._._.input_msg), ($scope) => $scope._._, "__tests__/template.marko_2_input_msg#6/pending"); +const $await_content__setup = $await_content__input_msg; +const $await_content = /*@__PURE__*/ _await_content("#text/0", "
done
", "D%", $await_content__setup); +const $try_content__await_promise = /*@__PURE__*/ _await_promise("#text/0"); +const $try_content__input_promise = /*@__PURE__*/ _closure_get("input_promise", ($scope) => $try_content__await_promise($scope, $scope._.input_promise)); +const $try_content__setup = ($scope) => { + $try_content__input_promise($scope); + $await_content($scope); +}; +const $count = /*@__PURE__*/ _let("count/7", ($scope) => _text($scope["#text/1"], $scope.count)); +const $try = /*@__PURE__*/ _try("#text/2", "", "b%", $try_content__setup); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $count($scope, 0); + $try($scope, { placeholder: attrTag({ content: $placeholder_content($scope) }) }); + $setup__script($scope); +} +const $input = ($scope, input) => { + $input_promise($scope, input.promise); + $input_msg($scope, input.msg); +}; +const $input_promise__closure = /*@__PURE__*/ _closure($try_content__input_promise); +const $input_promise = /*@__PURE__*/ _const("input_promise", $input_promise__closure); +const $input_msg__closure = /*@__PURE__*/ _closure($await_content__input_msg); +const $input_msg = /*@__PURE__*/ _const("input_msg", $input_msg__closure); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..308d2ad32fe --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/dom.bundle.js @@ -0,0 +1,6 @@ +// template.marko +const $placeholder_content = _content_resume("a0", "loading"); +const $count = /*@__PURE__*/ _let(7, ($scope) => _text($scope.b, $scope.h)); +const $setup__script = _script("a5", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.h + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..f98200a93bc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/html.bundle.debug.js @@ -0,0 +1,42 @@ +// template.marko +const $template = ""; +const $walks = " D l%c"; +_shells({ + "__tests__/template.marko_3*content": "__tests__/template.marko_3*content,loading", + "__tests__/template.marko_2*content": "__tests__/template.marko_2*content;D%;
done
", + "__tests__/template.marko_1_#text#0/await": "__tests__/template.marko_1_#text#0/await;D%;
done
", + "__tests__/template.marko_1*content": "__tests__/template.marko_1*content;b%;", + "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0; D l%;" +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = new Set(); + const $input_promise__closures = new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + _try($scope0_id, "#text/2", _content_resume("__tests__/template.marko_1*content", () => { + const $scope1_id = _scope_id(); + const $scope1_reason = _persisted_reason(); + _await($scope1_id, "#text/0", input.promise, () => { + const $scope2_id = _scope_id(); + _script($scope2_id, "__tests__/template.marko_2_input_msg#6/pending"); + _html(`
${_patch_text($scope2_id, "#text/0", input.msg, void 0, $scope0_owned, 2)} done
`); + _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "4:4"); + _resume_branch($scope2_id); + }, 1, "__tests__/template.marko_1_#text#0/await", 1); + $scope0_reason && _subscribe(_source_if($scope0_reason, 1) && $input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:2")); + _resume_branch($scope1_id); + }, $scope0_id), { placeholder: attrTag({ content: _content_record("__tests__/template.marko_3*content", $scope0_id) }) }, 1); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason && _scope($scope0_id, { + input_msg: input.msg, + count, + "ClosureScopes:input_msg": $input_msg__closures, + "ClosureScopes:input_promise": $input_promise__closures + }, "__tests__/template.marko", 0, { + input_msg: ["input.msg"], + count: "1:6" + }); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..4f9a7d04ba9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/html.bundle.js @@ -0,0 +1,37 @@ +// template.marko +_shells({ + a0: "a0,loading", + a1: "a1;D%;
done
", + a2: "a2;D%;
done
", + a3: "a3;b%;", + a: "a !a5; D l%;" +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = /* @__PURE__ */ new Set(); + const $input_promise__closures = /* @__PURE__ */ new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + _try($scope0_id, "c", _content_resume("a3", () => { + const $scope1_id = _scope_id(); + _persisted_reason(); + _await($scope1_id, "a", input.promise, () => { + const $scope2_id = _scope_id(); + _script($scope2_id, "a4"); + _html(`
${_patch_text($scope2_id, "a", input.msg, void 0, $scope0_owned, 2)} done
`); + _scope($scope2_id, { _: _scope_with_id($scope1_id) }); + _resume_branch($scope2_id); + }, 1, "a2", 1); + $scope0_reason && _subscribe(_source_if($scope0_reason, 1) && $input_promise__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); + _resume_branch($scope1_id); + }, $scope0_id), { placeholder: attrTag({ content: _content_record("a0", $scope0_id) }) }, 1); + _script($scope0_id, "a5"); + $scope0_reason && _scope($scope0_id, { + g: input.msg, + h: count, + j: $input_msg__closures, + i: $input_promise__closures + }); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..750c5867e3b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/patches.debug.js @@ -0,0 +1,9 @@ +// PATCH +{ + "PatchChild:BranchScopes:#text/2": { + "PatchPending:#text/0": 1, + "PatchChild:BranchScopes:#text/0": { + "PatchText:#text/0": "b" + } + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/patches.js new file mode 100644 index 00000000000..3ed27b3c3dc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/patches.js @@ -0,0 +1,9 @@ +// PATCH +{ + cAc: { + pa: 1, + cAa: { + ta: "b" + } + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/render.debug.md new file mode 100644 index 00000000000..d34b7a9cc32 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/render.debug.md @@ -0,0 +1,41 @@ +# Render `{"msg":"a","promise":{"value":2}}` +```html + + + loading + +``` + +# Update `{"msg":"b","promise":{"value":2}}` +```html + + + loading + +``` +## Change +``` +INSERT: button + em +REMOVE: em + em +``` + +## Patch rejected (navigate) + +# Update +```html + + + loading + +``` +## Change +``` +INSERT: #done::text("a") +INSERT: #done::text@0 + ::text(" done") +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/render.md new file mode 100644 index 00000000000..d34b7a9cc32 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/render.md @@ -0,0 +1,41 @@ +# Render `{"msg":"a","promise":{"value":2}}` +```html + + + loading + +``` + +# Update `{"msg":"b","promise":{"value":2}}` +```html + + + loading + +``` +## Change +``` +INSERT: button + em +REMOVE: em + em +``` + +## Patch rejected (navigate) + +# Update +```html + + + loading + +``` +## Change +``` +INSERT: #done::text("a") +INSERT: #done::text@0 + ::text(" done") +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..ad59b0ad09a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/writes.debug.html @@ -0,0 +1,38 @@ +loading + + + + + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/writes.html new file mode 100644 index 00000000000..caca99e1a12 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/__snapshots__/writes.html @@ -0,0 +1,32 @@ +loading + + + + + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/sizes.json new file mode 100644 index 00000000000..e66fc6ab527 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 10015, + "brotli": 4296 + } + }, + "html": { + "min": 1171, + "brotli": 666 + }, + "patch": { + "min": 26, + "brotli": 30 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/template.marko new file mode 100644 index 00000000000..7f277977203 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/template.marko @@ -0,0 +1,10 @@ + + + + +
${input.msg} done
+
+ <@placeholder> + loading + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/test.ts new file mode 100644 index 00000000000..d653ef58b30 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-await-patch-while-pending/test.ts @@ -0,0 +1,16 @@ +import type { TestConfig } from "../../main.test"; +import { flush, resolveAfter, wait } from "../../utils/resolve"; + +// A patch arriving while the boundary's initial stream is still pending: +// the construct's marker anchor has not streamed, so the frame rejects +// (safe fallback to navigation) — pinned until mid-stream pairing lands. +export const config: TestConfig = { + persisted: true, + expect_rejection: true, + steps: () => [ + { msg: "a", promise: resolveAfter(2) }, + { msg: "b", promise: resolveAfter(2) }, + wait, + flush, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/__snapshots__/html.bundle.debug.js index b5e18c65834..7fc16a9daac 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/__snapshots__/html.bundle.debug.js @@ -14,7 +14,7 @@ var loader_default = _template_persisted("__tests__/tags/loader.marko", (input) const $scope1_id = _scope_id(); _html(_patch_text($scope1_id, "#text/0", v, void 0, $scope0_owned, 0)); _scope($scope1_id, {}, "__tests__/tags/loader.marko", "1:18"); - }, void 0, "__tests__/tags/loader.marko_0_#text#0/await", 1); + }, 1, "__tests__/tags/loader.marko_0_#text#0/await", 1); _html(""); }, 0, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/__snapshots__/html.bundle.js index c22207d98b8..553c9fec345 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/__snapshots__/html.bundle.js @@ -14,7 +14,7 @@ var loader_default = _template_persisted("b", (input) => { const $scope1_id = _scope_id(); _html(_patch_text($scope1_id, "a", v, void 0, $scope0_owned, 0)); _scope($scope1_id, {}); - }, void 0, "b1", 1); + }, 1, "b1", 1); _html(""); }, 0, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/sizes.json index 3056c8701c7..dbc6ccb8b64 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-boundary/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9178, - "brotli": 3946 + "min": 9141, + "brotli": 3936 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-paired/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-paired/sizes.json index f34c937d8ab..970bbc9ba42 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-paired/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-paired/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6761, - "brotli": 3052 + "min": 6743, + "brotli": 3046 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/__snapshots__/html.bundle.debug.js index 895fc8ef16a..942d74cae1d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/__snapshots__/html.bundle.debug.js @@ -5,7 +5,7 @@ _shells({ "__tests__/tags/card/index.marko": "__tests__/tags/card/index.marko !_ var card_default = _template_persisted("__tests__/tags/card/index.marko", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); - _html(`
${_patch_text($scope0_id, "#text/1", input.title, void 0, $scope0_owned, 1)}
${_el_resume($scope0_id, "#div/0")}`); + _html(`
${_patch_text($scope0_id, "#text/1", input.title, void 0, $scope0_owned, 1)}
${_el_resume($scope0_id, "#div/0")}`); _script($scope0_id, "__tests__/tags/card/index.marko_0_input_attrs#4"); $scope0_reason && _scope($scope0_id, {}, "__tests__/tags/card/index.marko", 0, { "EventAttributes:#div/0": ["...input.attrs", "1:9"] }); }, 0, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/__snapshots__/html.bundle.js index be07eae1c18..221bd8e055a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/__snapshots__/html.bundle.js @@ -5,7 +5,7 @@ _shells({ b: "b !b0; D ;
" }); var card_default = _template_persisted("b", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); - _html(`
${_patch_text($scope0_id, "b", input.title, void 0, $scope0_owned, 1)}
${_el_resume($scope0_id, "a")}`); + _html(`
${_patch_text($scope0_id, "b", input.title, void 0, $scope0_owned, 1)}
${_el_resume($scope0_id, "a")}`); _script($scope0_id, "b0"); $scope0_reason && _scope($scope0_id, {}); }, 0, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/sizes.json index 9924d2551df..e78422c06f2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const-spread/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9359, - "brotli": 4007 + "min": 9350, + "brotli": 4013 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const/sizes.json index 8ce348486fe..fc8b7a22dd2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-const/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6582, - "brotli": 2984 + "min": 6564, + "brotli": 2966 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-nested/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-nested/sizes.json index 0ad4a6af0c4..25bf01a6517 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-nested/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-nested/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8753, - "brotli": 3859 + "min": 8714, + "brotli": 3849 }, "files": { "tags/badge.marko": 185, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-state/sizes.json index eaa35f559c2..00ad7f24ded 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7850, - "brotli": 3486 + "min": 7811, + "brotli": 3478 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-tag/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-tag/sizes.json index fd8a0e4a779..a745e865a76 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-tag/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-tag/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7384, - "brotli": 3329 + "min": 7366, + "brotli": 3318 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-var/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-var/sizes.json index 54d3a181406..098b924c7cd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-var/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-child-var/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7678, - "brotli": 3445 + "min": 7660, + "brotli": 3442 }, "files": { "tags/box.marko": 73, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow-curried/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow-curried/sizes.json index e7919c024be..b6212982706 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow-curried/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow-curried/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7661, - "brotli": 3435 + "min": 7632, + "brotli": 3427 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow-launder/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow-launder/sizes.json index 8e806f2fb65..bc5f023f176 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow-launder/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow-launder/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7412, - "brotli": 3322 + "min": 7390, + "brotli": 3327 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow/sizes.json index 68f57b64efb..ef813578bce 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-arrow/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7387, - "brotli": 3317 + "min": 7365, + "brotli": 3309 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-both-arms/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-both-arms/sizes.json index fa91a9f9011..b00a0879700 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-both-arms/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-both-arms/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7407, - "brotli": 3323 + "min": 7385, + "brotli": 3311 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-child/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-child/sizes.json index 9907680be6a..90206920403 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-child/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-child/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7442, - "brotli": 3345 + "min": 7420, + "brotli": 3327 }, "files": { "tags/widget/index.marko": 155, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-adopt/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-adopt/sizes.json index d28ac48f491..f03e9a44eb1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-adopt/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-adopt/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8350, - "brotli": 3687 + "min": 8327, + "brotli": 3681 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-dual/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-dual/sizes.json index d8f03f486bb..d90cd290536 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-dual/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-dual/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8038, - "brotli": 3573 + "min": 8016, + "brotli": 3559 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-tree/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-tree/sizes.json index 75cf5e62767..63d9e1f38eb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-tree/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-tree/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8139, - "brotli": 3622 + "min": 8117, + "brotli": 3604 }, "files": { "tags/note/index.marko": 155, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-tri/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-tri/sizes.json index 95b821da2c2..b6d35921125 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-tri/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-closure-tri/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8350, - "brotli": 3687 + "min": 8327, + "brotli": 3681 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-else/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-else/sizes.json index 56e5923227a..efaf1728ad2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-else/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-else/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7441, - "brotli": 3335 + "min": 7419, + "brotli": 3327 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-fn-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-fn-fill/sizes.json index e3ef6f237de..5f49017374b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-fn-fill/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-fn-fill/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7635, - "brotli": 3425 + "min": 7606, + "brotli": 3414 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-for/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-for/sizes.json index e92bdc1010a..5895f296cd6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-for/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-for/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8739, - "brotli": 3922 + "min": 8717, + "brotli": 3917 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..7b010263ebb --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,15 @@ +// template.marko +const $template = "
"; +const $walks = "D%b l"; +const $if_content__$global_brand = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "$global_brand", /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => _text($scope["#text/0"], $scope._.$global_brand))); +const $if_content__setup = $if_content__$global_brand; +const $if = /*@__PURE__*/ _if("#text/0", "

", "D ", $if_content__setup); +const $count = /*@__PURE__*/ _let("count/2", ($scope) => $if($scope, $scope.count > 1 ? 0 : 1)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $count($scope, 0); + $setup__script($scope); +} +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..2ec72857d5e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/dom.bundle.js @@ -0,0 +1,7 @@ +// template.marko +const $if_content__setup = /* @__PURE__ */ _fill_join("a0", 3, /*@__PURE__*/ _if_closure(0, 0, ($scope) => _text($scope.a, $scope._.d))); +const $if = /*@__PURE__*/ _if(0, "

", "D ", $if_content__setup); +const $count = /*@__PURE__*/ _let(2, ($scope) => $if($scope, $scope.c > 1 ? 0 : 1)); +const $setup__script = _script("a0", ($scope) => _on($scope.b, "click", function() { + $count($scope, +$scope.c + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index 0e52a2bd8ad..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/template.marko:4:8 - 2 |
- 3 | 1)> - > 4 |

${$global.brand}

- | ^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `$global` cannot be read inside client-owned structure. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-dom.txt deleted file mode 100644 index 0e52a2bd8ad..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/template.marko:4:8 - 2 |
- 3 | 1)> - > 4 |

${$global.brand}

- | ^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `$global` cannot be read inside client-owned structure. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index 0e52a2bd8ad..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/template.marko:4:8 - 2 |
- 3 | 1)> - > 4 |

${$global.brand}

- | ^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `$global` cannot be read inside client-owned structure. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-html.txt deleted file mode 100644 index 0e52a2bd8ad..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/template.marko:4:8 - 2 |
- 3 | 1)> - > 4 |

${$global.brand}

- | ^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `$global` cannot be read inside client-owned structure. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..fef48618be9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/html.bundle.debug.js @@ -0,0 +1,29 @@ +// template.marko +const $template = "
"; +const $walks = "D%b l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b ;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + let count = 0; + _html("
"); + if ($scope0_reason) _if(() => { + if (count > 1) { + const $scope1_id = _scope_id(); + _html(`

${_text_resume($scope1_id, "#text/0", $global$1.brand)}

`); + _scope($scope1_id, {}, "__tests__/template.marko", "3:4"); + return 0; + } + }, $scope0_id, "#text/0", 1, 1, 1, 0, 1); + _html(`${_el_resume($scope0_id, "#button/1")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + count, + $global_brand: $global$1?.brand + }, "__tests__/template.marko", 0, { + count: "1:6", + $global_brand: ["$global.brand"] + }) : _patch_value($scope0_id, "__tests__/template.marko0", $global$1?.brand); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..8917c63de8b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/html.bundle.js @@ -0,0 +1,17 @@ +// template.marko +_shells({ a: "a !a0;D%b ;
" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + let count = 0; + _html("
"); + if ($scope0_reason) _if(() => {}, $scope0_id, "a", 1, 1, 1, 0, 1); + _html(`${_el_resume($scope0_id, "b")}
`); + _script($scope0_id, "a0"); + $scope0_reason ? _scope($scope0_id, { + c: count, + d: $global$1?.brand + }) : _patch_value($scope0_id, "a0", $global$1?.brand); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..7378221e868 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/patches.debug.js @@ -0,0 +1,4 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/template.marko0": "bmce" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/patches.js new file mode 100644 index 00000000000..5014312e4f3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/patches.js @@ -0,0 +1,4 @@ +// PATCH +{ + va0: "bmce" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/render.debug.md new file mode 100644 index 00000000000..b5c127d1ae1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/render.debug.md @@ -0,0 +1,35 @@ +# Render `{"$global":{"brand":"acme"}}` +```html +
+ +
+``` + +# Update +```js +document.querySelector("button").click(); +``` + +# Update `{"$global":{"brand":"bmce"}}` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+

+ bmce +

+ +
+``` +## Change +``` +INSERT: main > p +UPDATE: main > p::text " " => "bmce" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/render.md new file mode 100644 index 00000000000..b5c127d1ae1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/render.md @@ -0,0 +1,35 @@ +# Render `{"$global":{"brand":"acme"}}` +```html +
+ +
+``` + +# Update +```js +document.querySelector("button").click(); +``` + +# Update `{"$global":{"brand":"bmce"}}` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+

+ bmce +

+ +
+``` +## Change +``` +INSERT: main > p +UPDATE: main > p::text " " => "bmce" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..414d38f7fc9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/writes.debug.html @@ -0,0 +1,11 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/writes.html new file mode 100644 index 00000000000..ac9cdfdcc3b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/__snapshots__/writes.html @@ -0,0 +1,9 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/sizes.json new file mode 100644 index 00000000000..ba967917cdb --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 7342, + "brotli": 3306 + } + }, + "html": { + "min": 374, + "brotli": 261 + }, + "patch": { + "min": 13, + "brotli": 17 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/test.ts index 3e12946ec38..758f533cf14 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-global/test.ts @@ -1,8 +1,18 @@ import type { TestConfig } from "../../main.test"; -// A `$global` hole inside client-owned structure has no delivery channel: -// its capture would ride the branch body patch renders skip. +const inc = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// A `$global` hole inside client-owned structure: the read hoists into a +// root derivation delivered as a fill, so the client-revealed branch +// renders the latest patched brand. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: [ + { $global: { brand: "acme" } }, + inc, + { $global: { brand: "bmce" } }, + inc, + ], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..9b6731c0bc0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,18 @@ +// template.marko +const $template = "
"; +const $walks = "D%b l"; +const $if_content__setup__script = _script("__tests__/template.marko_1", ($scope) => _on($scope["#button/0"], "click", function() { + document.querySelector("main").dataset.title = $scope._.title; +})); +const $if_content__setup = $if_content__setup__script; +const $title = /*@__PURE__*/ _const("title"); +const $if = /*@__PURE__*/ _if("#text/0", "", " ", $if_content__setup); +const $show = /*@__PURE__*/ _let("show/4", ($scope) => $if($scope, $scope.show ? 0 : 1)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { + $show($scope, true); +})); +function $setup($scope) { + $show($scope, false); + $setup__script($scope); +} +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..e09fb9ed45c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/dom.bundle.js @@ -0,0 +1,9 @@ +// template.marko +const $if_content__setup = _script("a0", ($scope) => _on($scope.a, "click", function() { + document.querySelector("main").dataset.title = $scope._.c; +})); +const $if = /*@__PURE__*/ _if(0, "", " ", $if_content__setup); +const $show = /*@__PURE__*/ _let(4, ($scope) => $if($scope, $scope.e ? 0 : 1)); +const $setup__script = _script("a1", ($scope) => _on($scope.b, "click", function() { + $show($scope, true); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index 38803906353..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/template.marko:5:18 - 3 |
- 4 | - > 5 | read - 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-dom.txt deleted file mode 100644 index 38803906353..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/template.marko:5:18 - 3 |
- 4 | - > 5 | read - 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index 38803906353..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/template.marko:5:18 - 3 |
- 4 | - > 5 | read - 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-html.txt deleted file mode 100644 index 38803906353..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/template.marko:5:18 - 3 |
- 4 | - > 5 | read - 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..7cb47a9c87c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/html.bundle.debug.js @@ -0,0 +1,25 @@ +// template.marko +const $template = "
"; +const $walks = "D%b l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b ;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + const title = $global$1.title + "!"; + let show = false; + _html("
"); + if ($scope0_reason) _if(() => { + if (show) { + const $scope1_id = _scope_id(); + _html(`${_el_resume($scope1_id, "#button/0")}`); + _script($scope1_id, "__tests__/template.marko_1"); + _scope($scope1_id, {}, "__tests__/template.marko", "4:4"); + return 0; + } + }, $scope0_id, "#text/0", 1, 1, 1, 0, 1); + _html(`${_el_resume($scope0_id, "#button/1")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { title }, "__tests__/template.marko", 0, { title: "1:8" }) : _patch_write($scope0_id, "title", title); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..e8cdffd4d80 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/html.bundle.js @@ -0,0 +1,13 @@ +// template.marko +_shells({ a: "a !a1;D%b ;
" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const title = $global().title + "!"; + _html("
"); + if ($scope0_reason) _if(() => {}, $scope0_id, "a", 1, 1, 1, 0, 1); + _html(`${_el_resume($scope0_id, "b")}
`); + _script($scope0_id, "a1"); + $scope0_reason ? _scope($scope0_id, { c: title }) : _patch_write($scope0_id, "c", title); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..d6e90fa9da1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/patches.debug.js @@ -0,0 +1,4 @@ +// PATCH +{ + "PatchWrite:title": "second!" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/patches.js new file mode 100644 index 00000000000..62696c679b2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/patches.js @@ -0,0 +1,4 @@ +// PATCH +{ + wc: "second!" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/render.debug.md new file mode 100644 index 00000000000..90f197fcfdd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/render.debug.md @@ -0,0 +1,85 @@ +# Render `{"$global":{"title":"first"}}` +```html +
+ +
+``` + +# Update +```js +document.querySelector(".step").click(); +``` +```html +
+ + +
+``` +## Change +``` +INSERT: main > .read +``` + +# Update +```js +document.querySelector(".read").click(); +``` +```html +
+ + +
+``` +## Change +``` +UPDATE: main[data-title] null => "first!" +``` + +# Update `{"$global":{"title":"second"}}` + +# Update +```js +document.querySelector(".read").click(); +``` +```html +
+ + +
+``` +## Change +``` +UPDATE: main[data-title] "first!" => "second!" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/render.md new file mode 100644 index 00000000000..90f197fcfdd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/render.md @@ -0,0 +1,85 @@ +# Render `{"$global":{"title":"first"}}` +```html +
+ +
+``` + +# Update +```js +document.querySelector(".step").click(); +``` +```html +
+ + +
+``` +## Change +``` +INSERT: main > .read +``` + +# Update +```js +document.querySelector(".read").click(); +``` +```html +
+ + +
+``` +## Change +``` +UPDATE: main[data-title] null => "first!" +``` + +# Update `{"$global":{"title":"second"}}` + +# Update +```js +document.querySelector(".read").click(); +``` +```html +
+ + +
+``` +## Change +``` +UPDATE: main[data-title] "first!" => "second!" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..3f200b55e35 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/writes.debug.html @@ -0,0 +1,11 @@ +
+
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/writes.html new file mode 100644 index 00000000000..89df9e0eec4 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/__snapshots__/writes.html @@ -0,0 +1,8 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/sizes.json new file mode 100644 index 00000000000..8fd2835407a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 6963, + "brotli": 3170 + } + }, + "html": { + "min": 386, + "brotli": 265 + }, + "patch": { + "min": 15, + "brotli": 19 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/test.ts index d7dffb2da4c..21dcc8bdac4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler-global/test.ts @@ -1,8 +1,22 @@ import type { TestConfig } from "../../main.test"; -// A handler capturing a `$global`-derived value inside client-owned -// structure would go stale: frames refresh the bag, never derived slots. +const show = (document: Document) => { + document.querySelector(".step")!.click(); +}; +const read = (document: Document) => { + document.querySelector(".read")!.click(); +}; + +// A handler inside client-owned structure reading a `$global`-derived +// value: the derivation refreshes over the wire, so the handler reads the +// latest patch's title. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: [ + { $global: { title: "first" } }, + show, + read, + { $global: { title: "second" } }, + read, + ], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler/sizes.json index 37219ab7982..c29833e2c75 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-handler/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6990, - "brotli": 3198 + "min": 6971, + "brotli": 3174 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-in-client/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-in-client/sizes.json index 7bbcbd8ce47..1e62ce674f7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-in-client/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-in-client/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8055, - "brotli": 3592 + "min": 8033, + "brotli": 3582 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-inner/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-inner/sizes.json index 7d691c41830..f1f178d91b0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-inner/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-inner/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9084, - "brotli": 4002 + "min": 9045, + "brotli": 3985 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-loop-outer/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-loop-outer/sizes.json index f74c02bd1e2..6fa40618f7a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-loop-outer/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-loop-outer/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10332, - "brotli": 4574 + "min": 10293, + "brotli": 4552 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-deep/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-deep/sizes.json index 219eb68454e..091af5cbc2f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-deep/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-deep/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7889, - "brotli": 3516 + "min": 7867, + "brotli": 3502 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-derived/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-derived/sizes.json index ac45437b029..f10f433bad3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-derived/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-derived/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7957, - "brotli": 3542 + "min": 7935, + "brotli": 3538 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-else/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-else/sizes.json index 92815033812..956c6632145 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-else/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested-else/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7311, - "brotli": 3284 + "min": 7289, + "brotli": 3276 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested/sizes.json index 1e83445df0f..1c6b9a82f6b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-nested/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7297, - "brotli": 3277 + "min": 7275, + "brotli": 3274 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-only-child/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-only-child/sizes.json index 389ee005472..3ae60bfbe7e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-only-child/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-only-child/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7392, - "brotli": 3311 + "min": 7370, + "brotli": 3305 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-owned/sizes.json index c1f300c12e9..f5b688d104c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-client-owned/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7364, - "brotli": 3303 + "min": 7342, + "brotli": 3295 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-deep/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-deep/sizes.json index c5aa71bb3f0..b4d8bd53839 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-deep/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-deep/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7877, - "brotli": 3547 + "min": 7859, + "brotli": 3535 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-derived/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-derived/sizes.json index 1f3d4acf612..f6024a33b4b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-derived/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-derived/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7611, - "brotli": 3414 + "min": 7593, + "brotli": 3405 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-nested/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-nested/sizes.json index f9f8ff82165..9ff297174f1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-nested/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure-nested/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7973, - "brotli": 3543 + "min": 7934, + "brotli": 3530 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure/sizes.json index f5dc639e0d4..a1625ffc5b3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-closure/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7506, - "brotli": 3381 + "min": 7488, + "brotli": 3372 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-const-mixed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-const-mixed/sizes.json index 1e9813a7556..83306f7f74a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-const-mixed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-const-mixed/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8375, - "brotli": 3693 + "min": 8336, + "brotli": 3691 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-const/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-const/sizes.json index f6a24e2a565..7139d4ab365 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-const/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-const/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7526, - "brotli": 3394 + "min": 7508, + "brotli": 3383 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-content-direct/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-content-direct/sizes.json index 85066118bc0..1bf39d6e518 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-content-direct/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-content-direct/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10152, - "brotli": 4359 + "min": 10128, + "brotli": 4348 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-ctrl-server-handler/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-ctrl-server-handler/sizes.json index aa4a41cdfb4..11cff16048d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-ctrl-server-handler/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-ctrl-server-handler/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9199, - "brotli": 4009 + "min": 9162, + "brotli": 3999 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..2be21570a06 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,17 @@ +// template.marko +const $template = ""; +const $walks = " b%c"; +const $if = /*@__PURE__*/ _if("#text/1", "shown"); +const $input_opts_show__OR__on = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "input_opts_show", /*@__PURE__*/ _or(7, ($scope) => $if($scope, $scope.input_opts_show && $scope.on ? 0 : 1))); +const $on = /*@__PURE__*/ _let("on/6", $input_opts_show__OR__on); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $on($scope, !$scope.on); +})); +function $setup($scope) { + $on($scope, true); + $setup__script($scope); +} +const $input_opts_show = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_opts_show", $input_opts_show__OR__on); +const $input = ($scope, input) => $input_opts($scope, input.opts); +const $input_opts = ($scope, input_opts) => $input_opts_show($scope, input_opts?.show); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..7f1897b245a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/dom.bundle.js @@ -0,0 +1,7 @@ +// template.marko +const $if = /*@__PURE__*/ _if(1, "shown"); +const $input_opts_show__OR__on = /*@__PURE__*/ _fill_join("a0", 5, /*@__PURE__*/ _or(7, ($scope) => $if($scope, $scope.f && $scope.g ? 0 : 1))); +const $on = /*@__PURE__*/ _let(6, $input_opts_show__OR__on); +const $setup__script = _script("a0", ($scope) => _on($scope.a, "click", function() { + $on($scope, !$scope.g); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..655b03668f1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/html.bundle.debug.js @@ -0,0 +1,27 @@ +// template.marko +const $template = ""; +const $walks = " b%c"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0; b%;" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let on = true; + _html(`${_el_resume($scope0_id, "#button/0")}`); + if ($scope0_reason) _if(() => { + if (input.opts.show && on) { + const $scope1_id = _scope_id(); + _html("shown"); + _scope($scope1_id, {}, "__tests__/template.marko", "3:2"); + return 0; + } + }, $scope0_id, "#text/1", 1, 1, 1, 0, 1); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + input_opts_show: input.opts?.show, + on + }, "__tests__/template.marko", 0, { + input_opts_show: ["input.opts.show"], + on: "1:6" + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", input.opts?.show); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..acdf71268dd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/html.bundle.js @@ -0,0 +1,22 @@ +// template.marko +_shells({ a: "a !a0; b%;" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let on = true; + _html(`${_el_resume($scope0_id, "a")}`); + if ($scope0_reason) _if(() => { + if (input.opts.show && on) { + const $scope1_id = _scope_id(); + _html("shown"); + _scope($scope1_id, {}); + return 0; + } + }, $scope0_id, "b", 1, 1, 1, 0, 1); + _script($scope0_id, "a0"); + $scope0_reason ? _scope($scope0_id, { + f: input.opts?.show, + g: on + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", input.opts?.show); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..4a555059d41 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/patches.debug.js @@ -0,0 +1,9 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/template.marko0": !1 +} + +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/template.marko0": !0 +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/patches.js new file mode 100644 index 00000000000..f93d24e64ed --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/patches.js @@ -0,0 +1,9 @@ +// PATCH +{ + va0: !1 +} + +// PATCH +{ + va0: !0 +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/render.debug.md new file mode 100644 index 00000000000..249a966947d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/render.debug.md @@ -0,0 +1,65 @@ +# Render `{"opts":{"show":true}}` +```html + + + shown + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + span +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + shown + +``` +## Change +``` +INSERT: button + span +``` + +# Update `{"opts":{"show":false}}` +```html + +``` +## Change +``` +REMOVE: button + span +``` + +# Update `{"opts":{"show":true}}` +```html + + + shown + +``` +## Change +``` +INSERT: button + span +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/render.md new file mode 100644 index 00000000000..249a966947d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/render.md @@ -0,0 +1,65 @@ +# Render `{"opts":{"show":true}}` +```html + + + shown + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + span +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + shown + +``` +## Change +``` +INSERT: button + span +``` + +# Update `{"opts":{"show":false}}` +```html + +``` +## Change +``` +REMOVE: button + span +``` + +# Update `{"opts":{"show":true}}` +```html + + + shown + +``` +## Change +``` +INSERT: button + span +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..c74c5a1a561 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/writes.debug.html @@ -0,0 +1,11 @@ +shown + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/writes.html new file mode 100644 index 00000000000..41df5ba4bd3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/__snapshots__/writes.html @@ -0,0 +1,9 @@ +shown + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/sizes.json new file mode 100644 index 00000000000..d74f8872dab --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 7228, + "brotli": 3253 + } + }, + "html": { + "min": 378, + "brotli": 265 + }, + "patch": { + "min": 18, + "brotli": 22 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/template.marko new file mode 100644 index 00000000000..2e3e0586d03 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/template.marko @@ -0,0 +1,5 @@ + + + + shown + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/test.ts new file mode 100644 index 00000000000..c2503b3f32c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-deep-input/test.ts @@ -0,0 +1,17 @@ +import type { TestConfig } from "../../main.test"; + +const toggle = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// A deep `input` member mixing with client state to select structure. +export const config: TestConfig = { + persisted: true, + steps: [ + { opts: { show: true } }, + toggle, + toggle, + { opts: { show: false } }, + { opts: { show: true } }, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-derived-script/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-derived-script/sizes.json index 121590a636d..9b1621f412e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-derived-script/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-derived-script/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7655, - "brotli": 3445 + "min": 7637, + "brotli": 3433 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-embedded-fn-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-embedded-fn-fill/sizes.json index 2e75b37c119..bfdb081c42e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-embedded-fn-fill/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-embedded-fn-fill/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7717, - "brotli": 3456 + "min": 7688, + "brotli": 3448 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-fill-local-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-fill-local-state/sizes.json index 8bdfcf60f36..e274d38542a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-fill-local-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-fill-local-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8516, - "brotli": 3735 + "min": 8477, + "brotli": 3727 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-frozen-let/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-frozen-let/sizes.json index b9316b4a6aa..0d093c067b3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-frozen-let/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-frozen-let/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6878, - "brotli": 3116 + "min": 6860, + "brotli": 3109 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-handler-input/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-handler-input/sizes.json index f07940b918c..c7cc25d23de 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-handler-input/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-handler-input/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7286, - "brotli": 3307 + "min": 7268, + "brotli": 3288 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-inert-test/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-inert-test/sizes.json index 6f0de51d5f4..b31c4e8c3b6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-inert-test/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-inert-test/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6455, - "brotli": 2971 + "min": 6436, + "brotli": 2956 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection-chain/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection-chain/sizes.json index 11d57dc5a4c..81b20810d86 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection-chain/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection-chain/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8589, - "brotli": 3776 + "min": 8550, + "brotli": 3765 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection-deep/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection-deep/sizes.json index c3a49623e71..2d007ad1704 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection-deep/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection-deep/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8858, - "brotli": 3903 + "min": 8819, + "brotli": 3895 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection/sizes.json index dd847efbfba..38ca7577d00 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-intersection/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8358, - "brotli": 3688 + "min": 8319, + "brotli": 3684 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-iterable-fn-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-iterable-fn-fill/sizes.json index 95c6079c9a4..83078a15fb0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-iterable-fn-fill/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-iterable-fn-fill/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7770, - "brotli": 3485 + "min": 7741, + "brotli": 3478 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-late-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-late-state/sizes.json index b935a575893..b7b9affc03d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-late-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-late-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7410, - "brotli": 3334 + "min": 7388, + "brotli": 3325 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-accept/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-accept/sizes.json index 659df310599..625d4602086 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-accept/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-accept/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8001, - "brotli": 3562 + "min": 7962, + "brotli": 3548 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-cross/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-cross/sizes.json index 49985e0a66b..3539044854e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-cross/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-cross/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7991, - "brotli": 3558 + "min": 7952, + "brotli": 3543 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-ref/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-ref/sizes.json index 4b0d6e0950d..77a577c863b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-ref/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change-ref/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7993, - "brotli": 3561 + "min": 7954, + "brotli": 3553 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change/sizes.json index 262617789e2..c30f2674c17 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-change/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8020, - "brotli": 3575 + "min": 7981, + "brotli": 3554 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-mixed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-mixed/sizes.json index ec06faf61b9..61cb5a0a367 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-mixed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-mixed/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8208, - "brotli": 3613 + "min": 8169, + "brotli": 3603 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-siblings/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-siblings/sizes.json index 0ef8274016b..772a554a86c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-siblings/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-siblings/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7880, - "brotli": 3485 + "min": 7841, + "brotli": 3477 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-static/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-static/sizes.json index 180c1d97c58..b5b169b1f82 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-static/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let-static/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6525, - "brotli": 2976 + "min": 6507, + "brotli": 2964 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let/sizes.json index 5e3ed9ed89d..e13b87dbb21 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-let/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7793, - "brotli": 3488 + "min": 7754, + "brotli": 3474 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-alias/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-alias/sizes.json index 8f9c93c43d6..60be5555312 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-alias/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-alias/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7243, - "brotli": 3267 + "min": 7221, + "brotli": 3263 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-derived-param/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-derived-param/sizes.json index 8f9c93c43d6..60be5555312 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-derived-param/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-derived-param/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7243, - "brotli": 3267 + "min": 7221, + "brotli": 3263 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-derived/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-derived/sizes.json index de4dcac2afc..27776949690 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-derived/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-derived/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7259, - "brotli": 3281 + "min": 7237, + "brotli": 3263 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-destructure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-destructure/sizes.json index 2eff2188a33..14ae8c99acf 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-destructure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-destructure/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7243, - "brotli": 3268 + "min": 7221, + "brotli": 3256 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-patch-only/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-patch-only/sizes.json index 5c82ec8e8a4..fa5f3d6f68b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-patch-only/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-patch-only/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7243, - "brotli": 3268 + "min": 7221, + "brotli": 3256 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-selector/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-selector/sizes.json index 2eff2188a33..14ae8c99acf 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-selector/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-mixed-selector/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7243, - "brotli": 3268 + "min": 7221, + "brotli": 3256 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-param-const-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-param-const-state/sizes.json index 7afcef3e81b..4f23c8a8295 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-param-const-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-param-const-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8228, - "brotli": 3642 + "min": 8189, + "brotli": 3628 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..70ae4c4fb04 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,20 @@ +// template.marko +const $template = ""; +const $walks = " D l%c"; +const $if = /*@__PURE__*/ _if("#text/2", "shown"); +const $input_show__OR__on = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "input_show", /*@__PURE__*/ _or(8, ($scope) => $if($scope, $scope.input_show && $scope.on ? 0 : 1))); +const $on = /*@__PURE__*/ _let("on/7", $input_show__OR__on); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $on($scope, !$scope.on); +})); +function $setup($scope) { + $on($scope, true); + $setup__script($scope); +} +const $label = ($scope, label) => _text($scope["#text/1"], label); +const $input_show = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_show", $input_show__OR__on); +const $input = ($scope, input) => { + $label($scope, input.label); + $input_show($scope, input.show); +}; +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..0f7c9495e86 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/dom.bundle.js @@ -0,0 +1,7 @@ +// template.marko +const $if = /*@__PURE__*/ _if(2, "shown"); +const $input_show__OR__on = /*@__PURE__*/ _fill_join("a0", 6, /*@__PURE__*/ _or(8, ($scope) => $if($scope, $scope.g && $scope.h ? 0 : 1))); +const $on = /*@__PURE__*/ _let(7, $input_show__OR__on); +const $setup__script = _script("a0", ($scope) => _on($scope.a, "click", function() { + $on($scope, !$scope.h); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..449cfb85ee0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/html.bundle.debug.js @@ -0,0 +1,28 @@ +// template.marko +const $template = ""; +const $walks = " D l%c"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0; D l%;" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const { label, ...rest } = input; + let on = true; + _html(`${_el_resume($scope0_id, "#button/0")}`); + if ($scope0_reason) _if(() => { + if (rest.show && on) { + const $scope1_id = _scope_id(); + _html("shown"); + _scope($scope1_id, {}, "__tests__/template.marko", "4:2"); + return 0; + } + }, $scope0_id, "#text/2", 1, 1, 1, 0, 1); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + input_show: input.show, + on + }, "__tests__/template.marko", 0, { + input_show: ["input.show"], + on: "2:6" + }) : _owned_guard($scope0_owned, 1) && _patch_value($scope0_id, "__tests__/template.marko0", input.show); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..23d00d28afa --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/html.bundle.js @@ -0,0 +1,23 @@ +// template.marko +_shells({ a: "a !a0; D l%;" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const { label, ...rest } = input; + let on = true; + _html(`${_el_resume($scope0_id, "a")}`); + if ($scope0_reason) _if(() => { + if (rest.show && on) { + const $scope1_id = _scope_id(); + _html("shown"); + _scope($scope1_id, {}); + return 0; + } + }, $scope0_id, "c", 1, 1, 1, 0, 1); + _script($scope0_id, "a0"); + $scope0_reason ? _scope($scope0_id, { + g: input.show, + h: on + }) : _owned_guard($scope0_owned, 1) && _patch_value($scope0_id, "a0", input.show); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..49c4f572361 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/patches.debug.js @@ -0,0 +1,11 @@ +// PATCH +{ + "PatchText:#text/1": "x", + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/template.marko0": !1 +} + +// PATCH +{ + "PatchText:#text/1": "x", + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/template.marko0": !0 +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/patches.js new file mode 100644 index 00000000000..9e7f0dce3d3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/patches.js @@ -0,0 +1,11 @@ +// PATCH +{ + tb: "x", + va0: !1 +} + +// PATCH +{ + tb: "x", + va0: !0 +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/render.debug.md new file mode 100644 index 00000000000..948d77deb9b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/render.debug.md @@ -0,0 +1,67 @@ +# Render `{"label":"x","show":true}` +```html + + + shown + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + span +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + shown + +``` +## Change +``` +INSERT: button + span +``` + +# Update `{"label":"x","show":false}` +```html + +``` +## Change +``` +UPDATE: button::text "x" => "x" +REMOVE: button + span +``` + +# Update `{"label":"x","show":true}` +```html + + + shown + +``` +## Change +``` +UPDATE: button::text "x" => "x" +INSERT: button + span +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/render.md new file mode 100644 index 00000000000..948d77deb9b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/render.md @@ -0,0 +1,67 @@ +# Render `{"label":"x","show":true}` +```html + + + shown + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + span +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + shown + +``` +## Change +``` +INSERT: button + span +``` + +# Update `{"label":"x","show":false}` +```html + +``` +## Change +``` +UPDATE: button::text "x" => "x" +REMOVE: button + span +``` + +# Update `{"label":"x","show":true}` +```html + + + shown + +``` +## Change +``` +UPDATE: button::text "x" => "x" +INSERT: button + span +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..29bbc5c6938 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/writes.debug.html @@ -0,0 +1,11 @@ +shown + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/writes.html new file mode 100644 index 00000000000..0f013c8de58 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/__snapshots__/writes.html @@ -0,0 +1,9 @@ +shown + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/sizes.json new file mode 100644 index 00000000000..c733d5184fb --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 7262, + "brotli": 3265 + } + }, + "html": { + "min": 391, + "brotli": 265 + }, + "patch": { + "min": 32, + "brotli": 36 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/template.marko new file mode 100644 index 00000000000..292a7413d78 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/template.marko @@ -0,0 +1,6 @@ + + + + + shown + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/test.ts new file mode 100644 index 00000000000..831e1444d0b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-rest-input/test.ts @@ -0,0 +1,17 @@ +import type { TestConfig } from "../../main.test"; + +const toggle = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// A rest of `input` mixing with client state to select structure. +export const config: TestConfig = { + persisted: true, + steps: [ + { label: "x", show: true }, + toggle, + toggle, + { label: "x", show: false }, + { label: "x", show: true }, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-el/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-el/sizes.json index bf46ffcb6ce..b3eadf73112 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-el/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-el/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6643, - "brotli": 3026 + "min": 6625, + "brotli": 3016 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/dom.bundle.debug.js index 47050319c37..e3d0caa950b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/dom.bundle.debug.js @@ -1,17 +1,16 @@ // template.marko const $template = "

"; const $walks = "E l%l"; -const $if_content__setup__script = _script("__tests__/template.marko_1", ($scope) => { +const $setup = () => {}; +const $if_content__$global_brand__script = _script("__tests__/template.marko_1_$global_brand#5", ($scope) => { { const el = document.querySelector("main"); - el.dataset.log = (el.dataset.log || "") + "[" + $scope.$global.brand + "]"; + el.dataset.log = (el.dataset.log || "") + "[" + $scope._.$global_brand + "]"; } }); -const $if_content__setup = $if_content__setup__script; -function $setup($scope) { - _text($scope["#text/0"], $scope.$global.brand); -} +const $if_content__$global_brand = /*@__PURE__*/ _if_closure("#text/1", 0, $if_content__$global_brand__script); +const $if_content__setup = $if_content__$global_brand; const $if = /*@__PURE__*/ _if("#text/1", "

promo

", 0, $if_content__setup); const $input_show = ($scope, input_show) => $if($scope, input_show ? 0 : 1); const $input = ($scope, input) => $input_show($scope, input.show); -var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, 0, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/dom.bundle.js index f984c053e4b..14469565c18 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/dom.bundle.js @@ -1,7 +1,7 @@ // template.marko -const $if_content__setup = _script("a1", ($scope) => { +const $if_content__setup = /* @__PURE__ */ _if_closure(1, 0, _script("a1", ($scope) => { { const el = document.querySelector("main"); - el.dataset.log = (el.dataset.log || "") + "[" + $scope.$.brand + "]"; + el.dataset.log = (el.dataset.log || "") + "[" + $scope._.f + "]"; } -}); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/html.bundle.debug.js index 07d4a2b1eea..cd5d8c03afe 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/html.bundle.debug.js @@ -3,7 +3,7 @@ const $template = "

"; const $walks = "E l%l"; _shells({ "__tests__/template.marko": "__tests__/template.marko;E l%;

", - "__tests__/template.marko_1*shell": "__tests__/template.marko_1*shell !__tests__/template.marko_1,

promo

" + "__tests__/template.marko_1*shell": "__tests__/template.marko_1*shell !__tests__/template.marko_1_$global_brand#5,

promo

" }); var template_default = _template_persisted("__tests__/template.marko", (input) => { const $scope0_reason = _persisted_reason(), $sg__input_show = _source_guard($scope0_reason, 0); @@ -14,12 +14,12 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = if (input.show) { const $scope1_id = _scope_id(); _html("

promo

"); - _script($scope1_id, "__tests__/template.marko_1"); - _patch_effect($scope1_id, "__tests__/template.marko_1", "! brand", 1); - $scope0_reason && _scope($scope1_id, {}, "__tests__/template.marko", "3:4"); + _script($scope1_id, "__tests__/template.marko_1_$global_brand#5"); + _patch_effect($scope1_id, "__tests__/template.marko_1_$global_brand#5", "$global_brand 1"); + _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4"); return 0; } }, $scope0_id, "#text/1", 1, $sg__input_show, $sg__input_show, void 0, void 0, ["__tests__/template.marko_1*shell"]); _html("
"); - $scope0_reason && _scope($scope0_id, {}, "__tests__/template.marko", 0); + $scope0_reason ? _scope($scope0_id, { $global_brand: $global$1?.brand }, "__tests__/template.marko", 0, { $global_brand: ["$global.brand"] }) : _patch_write($scope0_id, "$global_brand", $global$1?.brand); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/html.bundle.js index 552944ab88d..8ba582da587 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/html.bundle.js @@ -6,17 +6,18 @@ _shells({ var template_default = _template_persisted("a", (input) => { const $scope0_reason = _persisted_reason(), $sg__input_show = _source_guard($scope0_reason, 0); const $scope0_id = _scope_id(); - _html(`

${_patch_text($scope0_id, "a", $global().brand)}

`); + const $global$1 = $global(); + _html(`

${_patch_text($scope0_id, "a", $global$1.brand)}

`); _if(() => { if (input.show) { const $scope1_id = _scope_id(); _html("

promo

"); _script($scope1_id, "a1"); - _patch_effect($scope1_id, "a1", "! brand", 1); - $scope0_reason && _scope($scope1_id, {}); + _patch_effect($scope1_id, "a1", "f 1"); + _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } }, $scope0_id, "b", 1, $sg__input_show, $sg__input_show, void 0, void 0, ["a0"]); _html("
"); - $scope0_reason && _scope($scope0_id, {}); + $scope0_reason ? _scope($scope0_id, { f: $global$1?.brand }) : _patch_write($scope0_id, "f", $global$1?.brand); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/patches.debug.js index 6ff502691c2..ce919c65c5a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/patches.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/patches.debug.js @@ -4,27 +4,30 @@ brand: "Marko" }, "PatchText:#text/0": "Marko", - "PatchBranch:#text/1": 0 + "PatchBranch:#text/1": 0, + "PatchWrite:$global_brand": "Marko" } // PATCH -[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1,

promo

`, { +[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1_$global_brand#5,

promo

`, { "$global:": { brand: "Fresh" }, "PatchText:#text/0": "Fresh", "PatchBranch:#text/1": [{ - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1": "! brand" - }, "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1*shell"] + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1_$global_brand#5": "$global_brand 1" + }, "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1*shell"], + "PatchWrite:$global_brand": "Fresh" }] // PATCH -[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1,

promo

`, { +[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1_$global_brand#5,

promo

`, { "$global:": { brand: "Patch" }, "PatchText:#text/0": "Patch", "PatchBranch:#text/1": [{ - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1": "! brand" - }, "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1*shell"] + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1_$global_brand#5": "$global_brand 1" + }, "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1*shell"], + "PatchWrite:$global_brand": "Patch" }] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/patches.js index 854b4973c2a..acfe3197141 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/patches.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/patches.js @@ -4,7 +4,8 @@ brand: "Marko" }, ta: "Marko", - bb: 0 + bb: 0, + wf: "Marko" } // PATCH @@ -14,8 +15,9 @@ }, ta: "Fresh", bb: [{ - ga1: "! brand" - }, "a0"] + ea1: "f 1" + }, "a0"], + wf: "Fresh" }] // PATCH @@ -25,6 +27,7 @@ }, ta: "Patch", bb: [{ - ga1: "! brand" - }, "a0"] + ea1: "f 1" + }, "a0"], + wf: "Patch" }] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/writes.debug.html index c542c7ae7fe..69a8445afe1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/writes.debug.html @@ -6,8 +6,12 @@

Marko

WALKER_RUNTIME("M")("_"); M._.r = [_ => [0, { brand: "Marko" + }, { + $global_brand: "Marko" + }, { + _: _(1) }], - "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1 2" + "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/template.marko_1_$global_brand#5 2" ]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/writes.html index 6d1a662e3cf..faaf10fb296 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/__snapshots__/writes.html @@ -6,6 +6,10 @@

Marko

WALKER_RUNTIME("M")("_"); M._.r = [_ => [0, { brand: "Marko" + }, { + f: "Marko" + }, { + _: _(1) }], "a1 2"]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/sizes.json index f20ec6e1a93..bc6e9ace805 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-global/sizes.json @@ -1,16 +1,16 @@ { "dom": { "template.marko.page.mjs": { - "min": 7083, - "brotli": 3220 + "min": 7061, + "brotli": 3205 } }, "html": { - "min": 395, - "brotli": 272 + "min": 416, + "brotli": 282 }, "patch": { - "min": 198, - "brotli": 109 + "min": 223, + "brotli": 118 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-input/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-input/sizes.json index 4b82e0b85ac..d4c80a86477 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-input/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-input/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7041, - "brotli": 3193 + "min": 7023, + "brotli": 3191 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/dom.bundle.debug.js index 8a04ed8891a..22aa1d8b81b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/dom.bundle.debug.js @@ -2,14 +2,19 @@ const $template = "

"; const $walks = "E l%l"; const $setup = () => {}; -const $if_content__input_value__script = _script("__tests__/template.marko_1_input_value#6", ($scope) => { +const $if_content__input_value__OR__$global_brand__script = _script("__tests__/template.marko_1_input_value#6_$global_brand#7", ($scope) => { { const el = document.querySelector("main"); - el.dataset.log = (el.dataset.log || "") + "[" + $scope._.input_value + ":" + _global_read($scope.$global, "brand") + "]"; + el.dataset.log = (el.dataset.log || "") + "[" + $scope._.input_value + ":" + $scope._.$global_brand + "]"; } }); -const $if_content__input_value = /*@__PURE__*/ _if_closure("#text/1", 0, $if_content__input_value__script); -const $if_content__setup = $if_content__input_value; +const $if_content__input_value__OR__$global_brand = /*@__PURE__*/ _or(0, $if_content__input_value__OR__$global_brand__script); +const $if_content__input_value = /*@__PURE__*/ _if_closure("#text/1", 0, $if_content__input_value__OR__$global_brand); +const $if_content__setup = ($scope) => { + $if_content__input_value._($scope); + $if_content__$global_brand._($scope); +}; +const $if_content__$global_brand = /*@__PURE__*/ _if_closure("#text/1", 0, $if_content__input_value__OR__$global_brand); const $input_title = ($scope, input_title) => _text($scope["#text/0"], input_title); const $if = /*@__PURE__*/ _if("#text/1", "

promo

", 0, $if_content__setup); const $input_show = ($scope, input_show) => $if($scope, input_show ? 0 : 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/dom.bundle.js index 4855c4ecacd..ca1975dab4c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/dom.bundle.js @@ -1,7 +1,7 @@ // template.marko -const $if_content__input_value = /*@__PURE__*/ _if_closure(1, 0, _script("a1", ($scope) => { +const $if_content__input_value__OR__$global_brand = /*@__PURE__*/ _or(0, _script("a1", ($scope) => { { const el = document.querySelector("main"); - el.dataset.log = (el.dataset.log || "") + "[" + $scope._.g + ":" + $scope.$.brand + "]"; + el.dataset.log = (el.dataset.log || "") + "[" + $scope._.g + ":" + $scope._.h + "]"; } })); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/html.bundle.debug.js index 8b2cd12fa9d..937b0d67c1b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/html.bundle.debug.js @@ -3,7 +3,7 @@ const $template = "

"; const $walks = "E l%l"; _shells({ "__tests__/template.marko": "__tests__/template.marko;E l%;

", - "__tests__/template.marko_1*shell": "__tests__/template.marko_1*shell !__tests__/template.marko_1_input_value#6,

promo

" + "__tests__/template.marko_1*shell": "__tests__/template.marko_1*shell !__tests__/template.marko_1_input_value#6_$global_brand#7,

promo

" }); var template_default = _template_persisted("__tests__/template.marko", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_show = _source_guard($scope0_reason, 2); @@ -14,12 +14,18 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = if (input.show) { const $scope1_id = _scope_id(); _html("

promo

"); - _script($scope1_id, "__tests__/template.marko_1_input_value#6"); - _patch_effect($scope1_id, "__tests__/template.marko_1_input_value#6", "input_value 1 ! brand", 1); + _script($scope1_id, "__tests__/template.marko_1_input_value#6_$global_brand#7"); + _patch_effect($scope1_id, "__tests__/template.marko_1_input_value#6_$global_brand#7", "input_value $global_brand 1"); _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4"); return 0; } }, $scope0_id, "#text/1", 1, $sg__input_show, $sg__input_show, void 0, void 0, ["__tests__/template.marko_1*shell"]); _html("
"); - $scope0_reason ? _scope($scope0_id, { input_value: input.value }, "__tests__/template.marko", 0, { input_value: ["input.value"] }) : _owned_guard($scope0_owned, 3) && _patch_write($scope0_id, "input_value", input.value); + $scope0_reason ? _scope($scope0_id, { + input_value: input.value, + $global_brand: $global$1?.brand + }, "__tests__/template.marko", 0, { + input_value: ["input.value"], + $global_brand: ["$global.brand"] + }) : (_owned_guard($scope0_owned, 3) && _patch_write($scope0_id, "input_value", input.value), _patch_write($scope0_id, "$global_brand", $global$1?.brand)); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/html.bundle.js index 5c1ebb3416c..6e29ac5b757 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/html.bundle.js @@ -6,18 +6,21 @@ _shells({ var template_default = _template_persisted("a", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_show = _source_guard($scope0_reason, 2); const $scope0_id = _scope_id(); - $global(); + const $global$1 = $global(); _html(`

${_patch_text($scope0_id, "a", input.title, void 0, $scope0_owned, 1)}

`); _if(() => { if (input.show) { const $scope1_id = _scope_id(); _html("

promo

"); _script($scope1_id, "a1"); - _patch_effect($scope1_id, "a1", "g 1 ! brand", 1); + _patch_effect($scope1_id, "a1", "g h 1"); _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; } }, $scope0_id, "b", 1, $sg__input_show, $sg__input_show, void 0, void 0, ["a0"]); _html("
"); - $scope0_reason ? _scope($scope0_id, { g: input.value }) : _owned_guard($scope0_owned, 3) && _patch_write($scope0_id, "g", input.value); + $scope0_reason ? _scope($scope0_id, { + g: input.value, + h: $global$1?.brand + }) : (_owned_guard($scope0_owned, 3) && _patch_write($scope0_id, "g", input.value), _patch_write($scope0_id, "h", $global$1?.brand)); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/patches.debug.js index 030807b24fc..60469f0d769 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/patches.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/patches.debug.js @@ -1,35 +1,38 @@ // PATCH -[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6,

promo

`, { +[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6_$global_brand#7,

promo

`, { "$global:": { brand: "Marko" }, "PatchText:#text/0": "Store", "PatchBranch:#text/1": [{ - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6": "input_value 1 ! brand" + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6_$global_brand#7": "input_value $global_brand 1" }, "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell"], - "PatchWrite:input_value": "b" + "PatchWrite:input_value": "b", + "PatchWrite:$global_brand": "Marko" }] // PATCH -[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6,

promo

`, { +[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6_$global_brand#7,

promo

`, { "$global:": { brand: "Marko" }, "PatchText:#text/0": "Store!", "PatchBranch:#text/1": [{ - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6": "input_value 1 ! brand" + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6_$global_brand#7": "input_value $global_brand 1" }, "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell"], - "PatchWrite:input_value": "b" + "PatchWrite:input_value": "b", + "PatchWrite:$global_brand": "Marko" }] // PATCH -[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6,

promo

`, { +[`packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell !packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6_$global_brand#7,

promo

`, { "$global:": { brand: "Fresh" }, "PatchText:#text/0": "Store", "PatchBranch:#text/1": [{ - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6": "input_value 1 ! brand" + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6_$global_brand#7": "input_value $global_brand 1" }, "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1*shell"], - "PatchWrite:input_value": "b" + "PatchWrite:input_value": "b", + "PatchWrite:$global_brand": "Fresh" }] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/patches.js index b75b12d0d8d..e981fa3271c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/patches.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/patches.js @@ -5,9 +5,10 @@ }, ta: "Store", bb: [{ - ga1: "g 1 ! brand" + ea1: "g h 1" }, "a0"], - wg: "b" + wg: "b", + wh: "Marko" }] // PATCH @@ -17,9 +18,10 @@ }, ta: "Store!", bb: [{ - ga1: "g 1 ! brand" + ea1: "g h 1" }, "a0"], - wg: "b" + wg: "b", + wh: "Marko" }] // PATCH @@ -29,7 +31,8 @@ }, ta: "Store", bb: [{ - ga1: "g 1 ! brand" + ea1: "g h 1" }, "a0"], - wg: "b" + wg: "b", + wh: "Fresh" }] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/writes.debug.html index ff284231933..77470a5a81b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/writes.debug.html @@ -7,11 +7,12 @@

Store

M._.r = [_ => [0, { brand: "Marko" }, { - input_value: "a" + input_value: "a", + $global_brand: "Marko" }, { _: _(1) }], - "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6 2" + "packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/template.marko_1_input_value#6_$global_brand#7 2" ]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/writes.html index cc735b195a4..7b5dc55e507 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/__snapshots__/writes.html @@ -7,7 +7,8 @@

Store

M._.r = [_ => [0, { brand: "Marko" }, { - g: "a" + g: "a", + h: "Marko" }, { _: _(1) }], "a1 2"]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/sizes.json index f109fa29cfd..289b084b2be 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-mixed/sizes.json @@ -1,16 +1,16 @@ { "dom": { "template.marko.page.mjs": { - "min": 7093, - "brotli": 3225 + "min": 7071, + "brotli": 3211 } }, "html": { - "min": 412, - "brotli": 284 + "min": 422, + "brotli": 289 }, "patch": { - "min": 277, - "brotli": 109 + "min": 292, + "brotli": 128 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-state/sizes.json index e79dd96fce1..1c99cb6d82c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7468, - "brotli": 3375 + "min": 7450, + "brotli": 3367 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script/sizes.json index 91bc242e25f..9351c66e379 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-script/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6703, - "brotli": 3046 + "min": 6685, + "brotli": 3038 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-state/sizes.json index 7ce49c5cc24..1fe21c3c05a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7531, - "brotli": 3391 + "min": 7513, + "brotli": 3394 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-static-const-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-static-const-state/sizes.json index 0507adc7ad3..f847514da4a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-static-const-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-static-const-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8223, - "brotli": 3638 + "min": 8184, + "brotli": 3637 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-unassigned-let/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-unassigned-let/sizes.json index bd85e232dd9..fddc1ea238a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-unassigned-let/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch-unassigned-let/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7495, - "brotli": 3390 + "min": 7477, + "brotli": 3385 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch/sizes.json index 5f828d7cf85..ec2a7f5191a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7327, - "brotli": 3313 + "min": 7309, + "brotli": 3304 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-capture-escapes/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-capture-escapes/sizes.json index 67b15e00f0d..4abd587fabf 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-capture-escapes/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-capture-escapes/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2285, - "brotli": 1158 + "min": 2268, + "brotli": 1147 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-alias-patch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-alias-patch/sizes.json index 45ca854c3b5..2386ea12d17 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-alias-patch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-alias-patch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2165, - "brotli": 1120 + "min": 2164, + "brotli": 1122 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-dom.debug.txt new file mode 100644 index 00000000000..1d78e326861 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-dom.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | + 7 | + 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-dom.txt new file mode 100644 index 00000000000..1d78e326861 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-dom.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | + 7 | + 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-html.debug.txt new file mode 100644 index 00000000000..1d78e326861 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-html.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | + 7 | + 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-html.txt new file mode 100644 index 00000000000..1d78e326861 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/__snapshots__/error-compile-html.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | + 7 | + 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/helper.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/helper.ts new file mode 100644 index 00000000000..5cf59f8001f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/helper.ts @@ -0,0 +1 @@ +export let thing = false; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/tags/struct/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/tags/struct/index.marko new file mode 100644 index 00000000000..f6632a65560 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/tags/struct/index.marko @@ -0,0 +1,6 @@ + +
a
+ + + b + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/template.marko new file mode 100644 index 00000000000..a12fe9a375a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/template.marko @@ -0,0 +1,8 @@ +import { thing } from "./helper"; + +
+ + + + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/test.ts new file mode 100644 index 00000000000..445628588cc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-arg-structural/test.ts @@ -0,0 +1,8 @@ +import type { TestConfig } from "../../main.test"; + +// A provenance-free ARGUMENT gating a child's structural param has no +// delivery channel, exactly like the named-attribute form. +export const config: TestConfig = { + error_compiler: true, + persisted: true, +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-dom.debug.txt new file mode 100644 index 00000000000..6b89de38524 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-dom.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/template.marko:4:12 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a spread argument for a child inside client-owned structure is not supported yet. + 5 | + 6 | + 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-dom.txt new file mode 100644 index 00000000000..6b89de38524 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-dom.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/template.marko:4:12 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a spread argument for a child inside client-owned structure is not supported yet. + 5 | + 6 | + 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-html.debug.txt new file mode 100644 index 00000000000..6b89de38524 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-html.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/template.marko:4:12 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a spread argument for a child inside client-owned structure is not supported yet. + 5 | + 6 | + 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-html.txt new file mode 100644 index 00000000000..6b89de38524 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/__snapshots__/error-compile-html.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/template.marko:4:12 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a spread argument for a child inside client-owned structure is not supported yet. + 5 | + 6 | + 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/tags/badge/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/tags/badge/index.marko new file mode 100644 index 00000000000..f21a69b36fb --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/tags/badge/index.marko @@ -0,0 +1 @@ +${input} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/template.marko new file mode 100644 index 00000000000..2a7b73019c9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/template.marko @@ -0,0 +1,7 @@ + +
+ + + + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/test.ts new file mode 100644 index 00000000000..f8a2ea1e80f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args-spread/test.ts @@ -0,0 +1,8 @@ +import type { TestConfig } from "../../main.test"; + +// A spread argument hides which child params it feeds, so per-group +// channel analysis cannot run: fail closed at the call site. +export const config: TestConfig = { + error_compiler: true, + persisted: true, +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..b5a655ea013 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,27 @@ +// tags/badge/index.marko +const $template$1 = " "; +const $walks$1 = "D l"; +const $setup$1 = () => {}; +const $input$1 = ($scope, input) => _text($scope["#text/0"], input); +var badge_default = /*@__PURE__*/ _template("__tests__/tags/badge/index.marko", $template$1, "D l", 0, $input$1); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +const $if_content__input_tag = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "input_tag", /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => $input$1($scope["#childScope/1"], $scope._.input_tag))); +const $if_content__setup = ($scope) => { + $if_content__input_tag._($scope); + $input$1($scope["#childScope/0"], "x"); +}; +const $if = /*@__PURE__*/ _if("#text/0", /*@__PURE__*/ ((_w0, _w1) => `${_w0}${_w1}`)($template$1, $template$1), /*@__PURE__*/ ((_w0, _w1) => `/${_w0}&/${_w1}&`)("D l", "D l"), $if_content__setup); +const $show = /*@__PURE__*/ _let("show/5", ($scope) => $if($scope, $scope.show ? 0 : 1)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { + $show($scope, !$scope.show); +})); +function $setup($scope) { + $show($scope, true); + $setup__script($scope); +} +const $input = ($scope, input) => $input_tag($scope, input.tag); +const $input_tag = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_tag", $if_content__input_tag); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..44cf0082097 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/dom.bundle.js @@ -0,0 +1,15 @@ +// tags/badge/index.marko +const $template = " "; +const $input = ($scope, input) => _text($scope.a, input); + +// template.marko +const $if_content__input_tag = /*@__PURE__*/ _fill_join("a0", 4, /*@__PURE__*/ _if_closure(0, 0, ($scope) => $input($scope.b, $scope._.e))); +const $if_content__setup = ($scope) => { + $if_content__input_tag._($scope); + $input($scope.a, "x"); +}; +const $if = /*@__PURE__*/ _if(0, /*@__PURE__*/ ((_w0, _w1) => `${_w0}${_w1}`)($template, $template), /*@__PURE__*/ ((_w0, _w1) => `/${_w0}&/${_w1}&`)("D l", "D l"), $if_content__setup); +const $show = /*@__PURE__*/ _let(5, ($scope) => $if($scope, $scope.f ? 0 : 1)); +const $setup__script = _script("a0", ($scope) => _on($scope.b, "click", function() { + $show($scope, !$scope.f); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index e0d061d3e95..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: arguments for a child inside client-owned structure are not supported yet. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-dom.txt deleted file mode 100644 index e0d061d3e95..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: arguments for a child inside client-owned structure are not supported yet. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index e0d061d3e95..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: arguments for a child inside client-owned structure are not supported yet. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-html.txt deleted file mode 100644 index e0d061d3e95..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: arguments for a child inside client-owned structure are not supported yet. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..7438fcb759b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/html.bundle.debug.js @@ -0,0 +1,47 @@ +// tags/badge/index.marko +const $template$1 = " "; +const $walks$1 = "D l"; +_shells({ "__tests__/tags/badge/index.marko": "__tests__/tags/badge/index.marko;D ; " }); +var badge_default = _template_persisted("__tests__/tags/badge/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html(`${_patch_text($scope0_id, "#text/0", input, void 0, $scope0_owned, 0)}`); + $scope0_reason && _scope($scope0_id, {}, "__tests__/tags/badge/index.marko", 0); +}, 0, 0); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b ;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + _html("
"); + if ($scope0_reason) _if(() => { + if (show) { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + badge_default("x"); + _set_serialize_reason(1); + const $childScope2 = _peek_scope_id(); + badge_default(input.tag); + _scope($scope1_id, { + "#childScope/0": _existing_scope($childScope), + "#childScope/1": _existing_scope($childScope2) + }, "__tests__/template.marko", "3:4"); + return 0; + } + }, $scope0_id, "#text/0"); + _html(`${_el_resume($scope0_id, "#button/1")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + input_tag: input.tag, + show + }, "__tests__/template.marko", 0, { + input_tag: ["input.tag"], + show: "1:6" + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", input.tag); + _resume_branch($scope0_id); +}, 1, () => [badge_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..6af30550bbf --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/html.bundle.js @@ -0,0 +1,40 @@ +// tags/badge/index.marko +_shells({ b: "b;D ; " }); +var badge_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html(`${_patch_text($scope0_id, "a", input, void 0, $scope0_owned, 0)}`); + $scope0_reason && _scope($scope0_id, {}); +}, 0, 0); + +// template.marko +_shells({ a: "a !a0;D%b ;
" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + _html("
"); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + badge_default("x"); + _set_serialize_reason(1); + const $childScope2 = _peek_scope_id(); + badge_default(input.tag); + _scope($scope1_id, { + a: _existing_scope($childScope), + b: _existing_scope($childScope2) + }); + return 0; + } + }, $scope0_id, "a"); + _html(`${_el_resume($scope0_id, "b")}
`); + _script($scope0_id, "a0"); + $scope0_reason ? _scope($scope0_id, { + e: input.tag, + f: show + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", input.tag); + _resume_branch($scope0_id); +}, 1, () => [badge_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..64f199d14ba --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/patches.debug.js @@ -0,0 +1,9 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko0": "t2" +} + +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko0": "t3" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/patches.js new file mode 100644 index 00000000000..d6f3494302c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/patches.js @@ -0,0 +1,9 @@ +// PATCH +{ + va0: "t2" +} + +// PATCH +{ + va0: "t3" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/render.debug.md new file mode 100644 index 00000000000..afd889128f0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/render.debug.md @@ -0,0 +1,76 @@ +# Render `{"tag":"t1"}` +```html +
+ + x + + + t1 + + +
+``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > em +REMOVE: main > em +``` + +# Update `{"tag":"t2"}` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ + x + + + t2 + + +
+``` +## Change +``` +INSERT: main > :is(em, em) +UPDATE: main > em:nth-of-type(2)::text " " => "t2" +UPDATE: main > em:nth-of-type(1)::text " " => "x" +``` + +# Update `{"tag":"t3"}` +```html +
+ + x + + + t3 + + +
+``` +## Change +``` +UPDATE: main > em:nth-of-type(2)::text "t2" => "t3" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/render.md new file mode 100644 index 00000000000..afd889128f0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/render.md @@ -0,0 +1,76 @@ +# Render `{"tag":"t1"}` +```html +
+ + x + + + t1 + + +
+``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > em +REMOVE: main > em +``` + +# Update `{"tag":"t2"}` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ + x + + + t2 + + +
+``` +## Change +``` +INSERT: main > :is(em, em) +UPDATE: main > em:nth-of-type(2)::text " " => "t2" +UPDATE: main > em:nth-of-type(1)::text " " => "x" +``` + +# Update `{"tag":"t3"}` +```html +
+ + x + + + t3 + + +
+``` +## Change +``` +UPDATE: main > em:nth-of-type(2)::text "t2" => "t3" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..ecc1aea82a6 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/writes.debug.html @@ -0,0 +1,16 @@ +
+ xt1 +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/writes.html new file mode 100644 index 00000000000..27049975659 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/__snapshots__/writes.html @@ -0,0 +1,14 @@ +
+ xt1 +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/sizes.json new file mode 100644 index 00000000000..bb4cafc43fc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/sizes.json @@ -0,0 +1,22 @@ +{ + "dom": { + "template.marko.page.mjs": { + "total": { + "min": 7486, + "brotli": 3363 + }, + "files": { + "tags/badge/index.marko": 136, + "template.marko": 665 + } + } + }, + "html": { + "min": 448, + "brotli": 297 + }, + "patch": { + "min": 22, + "brotli": 26 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko index 50849e24371..ecbdd08743a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/template.marko @@ -2,6 +2,7 @@
+
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/test.ts index 7a0ac0e9bf4..81561e60db7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-args/test.ts @@ -1,6 +1,12 @@ import type { TestConfig } from "../../main.test"; +const toggle = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// Arguments are prop-tree props: a constant arg recomputes client-side and +// a server-fed arg delivers as a fill, like named attributes. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: [{ tag: "t1" }, toggle, { tag: "t2" }, toggle, { tag: "t3" }], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-dom.debug.txt new file mode 100644 index 00000000000..cd97d900a5c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-dom.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | <@tab ...thing2/> + 7 | + 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-dom.txt new file mode 100644 index 00000000000..cd97d900a5c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-dom.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | <@tab ...thing2/> + 7 | + 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-html.debug.txt new file mode 100644 index 00000000000..cd97d900a5c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-html.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | <@tab ...thing2/> + 7 | + 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-html.txt new file mode 100644 index 00000000000..cd97d900a5c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/__snapshots__/error-compile-html.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | <@tab ...thing2/> + 7 | + 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/helper.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/helper.ts new file mode 100644 index 00000000000..20e9d2b51ef --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/helper.ts @@ -0,0 +1 @@ +export let thing2 = { on: false }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/tags/tabs/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/tags/tabs/index.marko new file mode 100644 index 00000000000..5a7f42868d9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/tags/tabs/index.marko @@ -0,0 +1,6 @@ + +
a
+ + + b + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/template.marko new file mode 100644 index 00000000000..d63e5643be6 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/template.marko @@ -0,0 +1,10 @@ +import { thing2 } from "./helper"; + +
+ + + <@tab ...thing2/> + + + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/test.ts new file mode 100644 index 00000000000..28498ae3d87 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-spread/test.ts @@ -0,0 +1,8 @@ +import type { TestConfig } from "../../main.test"; + +// A spread on an attr tag may carry any property of its group: a +// provenance-free spread value gates the structural group it feeds. +export const config: TestConfig = { + error_compiler: true, + persisted: true, +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..b613d09f0b8 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,37 @@ +// tags/tabs/index.marko +const $template$1 = ""; +const $walks$1 = "b%c"; +const $setup$1 = () => {}; +const $if_content__input_tab_on = /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => _text($scope["#text/0"], $scope._.input_tab_on)); +const $if_content__setup$1 = $if_content__input_tab_on; +const $if$1 = /*@__PURE__*/ _if("#text/0", "
a
", "Db%", $if_content__setup$1, "b"); +const $input_tab = ($scope, input_tab) => { + $input_tab_on($scope, input_tab?.on); + $if$1($scope, input_tab ? 0 : 1); +}; +const $input = ($scope, input) => $input_tab($scope, input.tab); +const $input_tab_on = /*@__PURE__*/ _const("input_tab_on", $if_content__input_tab_on); +var tabs_default = /*@__PURE__*/ _template("__tests__/tags/tabs/index.marko", $template$1, "b%c", 0, $input); + +// template.marko +const $template = "
"; +const $walks = "D%b b l"; +const $if_content__on = /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => $input_tab($scope["#childScope/0"], attrTag({ on: $scope._.on }))); +const $if_content__setup = $if_content__on; +const $if = /*@__PURE__*/ _if("#text/0", /*@__PURE__*/ ((_w0) => `${_w0}`)($template$1), /*@__PURE__*/ ((_w0) => `b/${_w0}&b`)("b%c"), $if_content__setup); +const $show = /*@__PURE__*/ _let("show/3", ($scope) => $if($scope, $scope.show ? 0 : 1)); +const $on = /*@__PURE__*/ _let("on/4", $if_content__on); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => { + _on($scope["#button/1"], "click", function() { + $on($scope, !$scope.on); + }); + _on($scope["#button/2"], "click", function() { + $show($scope, !$scope.show); + }); +}); +function $setup($scope) { + $show($scope, true); + $on($scope, false); + $setup__script($scope); +} +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..acb34815945 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/dom.bundle.js @@ -0,0 +1,23 @@ +// tags/tabs/index.marko +const $template = ""; +const $if_content__input_tab_on = /*@__PURE__*/ _if_closure(0, 0, ($scope) => _text($scope.a, $scope._.e)); +const $if$1 = /*@__PURE__*/ _if(0, "
a
", "Db%", $if_content__input_tab_on, "b"); +const $input_tab = ($scope, input_tab) => { + $input_tab_on($scope, input_tab?.on); + $if$1($scope, input_tab ? 0 : 1); +}; +const $input_tab_on = /*@__PURE__*/ _const(4, $if_content__input_tab_on); + +// template.marko +const $if_content__on = /*@__PURE__*/ _if_closure(0, 0, ($scope) => $input_tab($scope.a, attrTag({ on: $scope._.e }))); +const $if = /*@__PURE__*/ _if(0, /*@__PURE__*/ ((_w0) => `${_w0}`)($template), /*@__PURE__*/ ((_w0) => `b/${_w0}&b`)("b%c"), $if_content__on); +const $show = /*@__PURE__*/ _let(3, ($scope) => $if($scope, $scope.d ? 0 : 1)); +const $on = /*@__PURE__*/ _let(4, $if_content__on); +const $setup__script = _script("a0", ($scope) => { + _on($scope.b, "click", function() { + $on($scope, !$scope.e); + }); + _on($scope.c, "click", function() { + $show($scope, !$scope.d); + }); +}); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..d5a3011abb8 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/html.bundle.debug.js @@ -0,0 +1,58 @@ +// tags/tabs/index.marko +const $template$1 = ""; +const $walks$1 = "b%c"; +_shells({ + "__tests__/tags/tabs/index.marko": "__tests__/tags/tabs/index.marko;b%;", + "__tests__/tags/tabs/index.marko_1*shell": "__tests__/tags/tabs/index.marko_1*shell;Db%;
a
", + "__tests__/tags/tabs/index.marko_2*shell": "__tests__/tags/tabs/index.marko_2*shell,b" +}); +var tabs_default = _template_persisted("__tests__/tags/tabs/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_tab = _source_guard($scope0_reason, 0); + const $scope0_id = _scope_id(); + _if(() => { + if (input.tab) { + const $scope1_id = _scope_id(); + _html(`
a ${_patch_text($scope1_id, "#text/0", input.tab.on, 2, $scope0_owned, 1)}
`); + _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/tags/tabs/index.marko", "1:2"); + return 0; + } else { + const $scope2_id = _scope_id(); + _html("b"); + $scope0_reason && _scope($scope2_id, {}, "__tests__/tags/tabs/index.marko", "4:2"); + return 1; + } + }, $scope0_id, "#text/0", 1, $sg__input_tab, $sg__input_tab, void 0, void 0, ["__tests__/tags/tabs/index.marko_1*shell", "__tests__/tags/tabs/index.marko_2*shell"]); + $scope0_reason && _scope($scope0_id, { input_tab_on: input.tab?.on }, "__tests__/tags/tabs/index.marko", 0, { input_tab_on: ["input.tab.on"] }); +}, 0, 0); + +// template.marko +const $template = "
"; +const $walks = "D%b b l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b b ;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + let on = false; + _html("
"); + if ($scope0_reason) _if(() => { + if (show) { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + tabs_default({ tab: attrTag({ on }) }); + _scope($scope1_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "4:4"); + return 0; + } + }, $scope0_id, "#text/0"); + _html(`${_el_resume($scope0_id, "#button/1")}${_el_resume($scope0_id, "#button/2")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason && _scope($scope0_id, { + show, + on + }, "__tests__/template.marko", 0, { + show: "1:6", + on: "2:6" + }); + _resume_branch($scope0_id); +}, 1, () => [tabs_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..2f30a9ff4ca --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/html.bundle.js @@ -0,0 +1,51 @@ +// tags/tabs/index.marko +_shells({ + b: "b;b%;", + b0: "b0;Db%;
a
", + b1: "b1,b" +}); +var tabs_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_tab = _source_guard($scope0_reason, 0); + const $scope0_id = _scope_id(); + _if(() => { + if (input.tab) { + const $scope1_id = _scope_id(); + _html(`
a ${_patch_text($scope1_id, "a", input.tab.on, 2, $scope0_owned, 1)}
`); + _scope($scope1_id, { _: _scope_with_id($scope0_id) }); + return 0; + } else { + const $scope2_id = _scope_id(); + _html("b"); + $scope0_reason && _scope($scope2_id, {}); + return 1; + } + }, $scope0_id, "a", 1, $sg__input_tab, $sg__input_tab, void 0, void 0, ["b0", "b1"]); + $scope0_reason && _scope($scope0_id, { e: input.tab?.on }); +}, 0, 0); + +// template.marko +_shells({ a: "a !a0;D%b b ;
" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + let on = false; + _html("
"); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + tabs_default({ tab: attrTag({ on }) }); + _scope($scope1_id, { a: _existing_scope($childScope) }); + return 0; + } + }, $scope0_id, "a"); + _html(`${_el_resume($scope0_id, "b")}${_el_resume($scope0_id, "c")}
`); + _script($scope0_id, "a0"); + $scope0_reason && _scope($scope0_id, { + d: show, + e: on + }); + _resume_branch($scope0_id); +}, 1, () => [tabs_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..d7bdae7b7c3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/patches.debug.js @@ -0,0 +1,7 @@ +// PATCH + + +// PATCH + + +// PATCH diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/patches.js new file mode 100644 index 00000000000..d7bdae7b7c3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/patches.js @@ -0,0 +1,7 @@ +// PATCH + + +// PATCH + + +// PATCH diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/render.debug.md new file mode 100644 index 00000000000..f97638dcf61 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/render.debug.md @@ -0,0 +1,94 @@ +# Render +```html +
+
+ a +
+ + +
+``` + +# Update +```js +document.querySelector("button.flip").click(); +``` +```html +
+
+ a true +
+ + +
+``` +## Change +``` +UPDATE: main > div::text@2 "" => "true" +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ + +
+``` +## Change +``` +REMOVE: main > div +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+
+ a true +
+ + +
+``` +## Change +``` +INSERT: main > div +UPDATE: main > div::text@2 "" => "true" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/render.md new file mode 100644 index 00000000000..f97638dcf61 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/render.md @@ -0,0 +1,94 @@ +# Render +```html +
+
+ a +
+ + +
+``` + +# Update +```js +document.querySelector("button.flip").click(); +``` +```html +
+
+ a true +
+ + +
+``` +## Change +``` +UPDATE: main > div::text@2 "" => "true" +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ + +
+``` +## Change +``` +REMOVE: main > div +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+
+ a true +
+ + +
+``` +## Change +``` +INSERT: main > div +UPDATE: main > div::text@2 "" => "true" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..1c2e9faf376 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/writes.debug.html @@ -0,0 +1,22 @@ +
+
a
+ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/writes.html new file mode 100644 index 00000000000..43402a30282 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/__snapshots__/writes.html @@ -0,0 +1,19 @@ +
+
a
+
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/sizes.json new file mode 100644 index 00000000000..cccff29c5cc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/sizes.json @@ -0,0 +1,22 @@ +{ + "dom": { + "template.marko.page.mjs": { + "total": { + "min": 8343, + "brotli": 3753 + }, + "files": { + "tags/tabs/index.marko": 487, + "template.marko": 632 + } + } + }, + "html": { + "min": 514, + "brotli": 309 + }, + "patch": { + "min": 0, + "brotli": 1 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/tags/tabs/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/tags/tabs/index.marko new file mode 100644 index 00000000000..6134c3a74ec --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/tags/tabs/index.marko @@ -0,0 +1,6 @@ + +
a ${input.tab.on}
+ + + b + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/template.marko new file mode 100644 index 00000000000..01915776294 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/template.marko @@ -0,0 +1,11 @@ + + +
+ + + <@tab on=on/> + + + f + t +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/test.ts new file mode 100644 index 00000000000..5c134258d7c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-attr-tag-state/test.ts @@ -0,0 +1,15 @@ +import type { TestConfig } from "../../main.test"; + +const flip = (document: Document) => { + document.querySelector("button.flip")!.click(); +}; +const toggle = (document: Document) => { + document.querySelector("button.toggle")!.click(); +}; + +// A tracked client-state feed riding an attr-tag attribute gates nothing: +// the group is client-owned, exactly like the plain-attribute form. +export const config: TestConfig = { + persisted: true, + steps: [{}, flip, {}, toggle, {}, toggle, {}], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-body/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-body/sizes.json index 21fdedb55c3..023b1b62278 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-body/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-body/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 6623, - "brotli": 3044 + "min": 6604, + "brotli": 3033 }, "files": { "tags/widget/index.marko": 162, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-branch-const/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-branch-const/sizes.json index a7f32ebfa07..1f25f55b1dc 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-branch-const/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-branch-const/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6761, - "brotli": 3039 + "min": 6743, + "brotli": 3038 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-const/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-const/sizes.json index 0a8404bf550..c5a85fafccd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-const/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-const/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7284, - "brotli": 3271 + "min": 7262, + "brotli": 3268 }, "files": { "tags/widget/index.marko": 476, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-controllable/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-controllable/sizes.json index 607e5d8ad37..41359fb7d14 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-controllable/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-controllable/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8780, - "brotli": 3850 + "min": 8748, + "brotli": 3845 }, "files": { "tags/field/index.marko": 527, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-mix/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-mix/sizes.json index 52c051e31b0..921873707b5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-mix/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-mix/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7715, - "brotli": 3459 + "min": 7693, + "brotli": 3449 }, "files": { "tags/label/index.marko": 151, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..991283b3292 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,40 @@ +// tags/widget/index.marko +const $template$1 = " x"; +const $walks$1 = "D%c%l b"; +const $count = /*@__PURE__*/ _fill_let("__tests__/tags/widget/index.marko0", "count/6", ($scope) => { + _text($scope["#text/1"], $scope.count); + _return($scope, $scope.count); +}); +const $setup__script$1 = _script("__tests__/tags/widget/index.marko_0", ($scope) => _on($scope["#button/2"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup$1($scope) { + $count($scope, 1); + $setup__script$1($scope); +} +const $input_label$1 = ($scope, input_label) => _text($scope["#text/0"], input_label); +const $input$1 = ($scope, input) => $input_label$1($scope, input.label); +var widget_default = /*@__PURE__*/ _template("__tests__/tags/widget/index.marko", $template$1, $walks$1, $setup$1, $input$1); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +const $if_content__input_label = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "input_label", /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => $input_label$1($scope["#childScope/0"], $scope._.input_label))); +const $if_content__setup = ($scope) => { + _var($scope, "#childScope/0", $if_content__w); + $if_content__input_label._($scope); + $setup$1($scope["#childScope/0"]); +}; +const $if_content__w = _var_resume("__tests__/template.marko_1_w#3/var", ($scope, w) => _text($scope["#text/2"], w)); +const $if = /*@__PURE__*/ _if("#text/0", /*@__PURE__*/ ((_w0) => `${_w0}

`)($template$1), /*@__PURE__*/ ((_w0) => `0${_w0}&D l`)($walks$1), $if_content__setup); +const $show = /*@__PURE__*/ _let("show/5", ($scope) => $if($scope, $scope.show ? 0 : 1)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { + $show($scope, !$scope.show); +})); +function $setup($scope) { + $show($scope, true); + $setup__script($scope); +} +const $input = ($scope, input) => $input_label($scope, input.label); +const $input_label = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_label", $if_content__input_label); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..93f24e9e81a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/dom.bundle.js @@ -0,0 +1,29 @@ +// tags/widget/index.marko +const $template = " x"; +const $walks = "D%c%l b"; +const $count = /*@__PURE__*/ _fill_let("b0", 6, ($scope) => { + _text($scope.b, $scope.g); + _return($scope, $scope.g); +}); +const $setup__script$1 = _script("b0", ($scope) => _on($scope.c, "click", function() { + $count($scope, +$scope.g + 1); +})); +function $setup($scope) { + $count($scope, 1); + $setup__script$1($scope); +} +const $input_label = ($scope, input_label) => _text($scope.a, input_label); + +// template.marko +const $if_content__input_label = /*@__PURE__*/ _fill_join("a0", 4, /*@__PURE__*/ _if_closure(0, 0, ($scope) => $input_label($scope.a, $scope._.e))); +const $if_content__setup = ($scope) => { + _var($scope, 0, $if_content__w); + $if_content__input_label._($scope); + $setup($scope.a); +}; +const $if_content__w = _var_resume("a0", ($scope, w) => _text($scope.c, w)); +const $if = /*@__PURE__*/ _if(0, /*@__PURE__*/ ((_w0) => `${_w0}

`)($template), /*@__PURE__*/ ((_w0) => `0${_w0}&D l`)($walks), $if_content__setup); +const $show = /*@__PURE__*/ _let(5, ($scope) => $if($scope, $scope.f ? 0 : 1)); +const $setup__script = _script("a1", ($scope) => _on($scope.b, "click", function() { + $show($scope, !$scope.f); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index fe8da16a309..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a tag variable on a child inside client-owned structure is not supported yet. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-dom.txt deleted file mode 100644 index fe8da16a309..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a tag variable on a child inside client-owned structure is not supported yet. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index fe8da16a309..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a tag variable on a child inside client-owned structure is not supported yet. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-html.txt deleted file mode 100644 index fe8da16a309..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a tag variable on a child inside client-owned structure is not supported yet. - 5 | - 6 | - 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..228513b1746 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/html.bundle.debug.js @@ -0,0 +1,49 @@ +// tags/widget/index.marko +const $template$1 = " x"; +const $walks$1 = "D%c%l b"; +_shells({ "__tests__/tags/widget/index.marko": "__tests__/tags/widget/index.marko !__tests__/tags/widget/index.marko_0;D%c%l ; x" }); +var widget_default = _template_persisted("__tests__/tags/widget/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let count = 1; + _html(`${_patch_text($scope0_id, "#text/0", input.label, void 0, $scope0_owned, 0)} x${_text_resume($scope0_id, "#text/1", count, 2)}${_el_resume($scope0_id, "#button/2")}`); + const $return = count; + _script($scope0_id, "__tests__/tags/widget/index.marko_0"); + _patch_value($scope0_id, "__tests__/tags/widget/index.marko0", count, 1); + $scope0_reason && _scope($scope0_id, { count }, "__tests__/tags/widget/index.marko", 0, { count: "1:6" }); + _resume_branch($scope0_id); + return $return; +}, 0, 0); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b ;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + _html("
"); + if ($scope0_reason) _if(() => { + if (show) { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + let w = widget_default({ label: input.label }); + _var($scope1_id, "#scopeOffset/1", $childScope, "__tests__/template.marko_1_w#3/var"); + _html(`

${_text_resume($scope1_id, "#text/2", w)}

`); + _scope($scope1_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "3:4"); + return 0; + } + }, $scope0_id, "#text/0"); + _html(`${_el_resume($scope0_id, "#button/1")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + input_label: input.label, + show + }, "__tests__/template.marko", 0, { + input_label: ["input.label"], + show: "1:6" + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", input.label); + _resume_branch($scope0_id); +}, 1, () => [widget_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..744b5b3c40d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/html.bundle.js @@ -0,0 +1,42 @@ +// tags/widget/index.marko +_shells({ b: "b !b0;D%c%l ; x" }); +var widget_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let count = 1; + _html(`${_patch_text($scope0_id, "a", input.label, void 0, $scope0_owned, 0)} x${_text_resume($scope0_id, "b", count, 2)}${_el_resume($scope0_id, "c")}`); + const $return = count; + _script($scope0_id, "b0"); + _patch_value($scope0_id, "b0", count, 1); + $scope0_reason && _scope($scope0_id, { g: count }); + _resume_branch($scope0_id); + return $return; +}, 0, 0); + +// template.marko +_shells({ a: "a !a1;D%b ;
" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + _html("
"); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + let w = widget_default({ label: input.label }); + _var($scope1_id, "b", $childScope, "a0"); + _html(`

${_text_resume($scope1_id, "c", w)}

`); + _scope($scope1_id, { a: _existing_scope($childScope) }); + return 0; + } + }, $scope0_id, "a"); + _html(`${_el_resume($scope0_id, "b")}
`); + _script($scope0_id, "a1"); + $scope0_reason ? _scope($scope0_id, { + e: input.label, + f: show + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", input.label); + _resume_branch($scope0_id); +}, 1, () => [widget_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..920f8b4c043 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/patches.debug.js @@ -0,0 +1,14 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko0": "b" +} + +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko0": "c" +} + +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko0": "d" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/patches.js new file mode 100644 index 00000000000..b190f50ad97 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/patches.js @@ -0,0 +1,14 @@ +// PATCH +{ + va0: "b" +} + +// PATCH +{ + va0: "c" +} + +// PATCH +{ + va0: "d" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/render.debug.md new file mode 100644 index 00000000000..791ddcccf4b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/render.debug.md @@ -0,0 +1,167 @@ +# Render `{"label":"a"}` +```html +
+ + a x1 + + +

+ 1 +

+ +
+``` + +# Update +```js +document.querySelector("button.bump").click(); +``` +```html +
+ + a x2 + + +

+ 2 +

+ +
+``` +## Change +``` +UPDATE: main > em::text@3 "1" => "2" +UPDATE: .echo::text "1" => "2" +``` + +# Update `{"label":"b"}` +```html +
+ + b x2 + + +

+ 2 +

+ +
+``` +## Change +``` +UPDATE: main > em::text@0 "a" => "b" +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > em +REMOVE: main > button +REMOVE: main > p +``` + +# Update `{"label":"c"}` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ + c x1 + + +

+ 1 +

+ +
+``` +## Change +``` +INSERT: main > :is(em, .bump, .echo) +UPDATE: main > em::text@0 "" => "c" +UPDATE: main > em::text@3 "" => "1" +UPDATE: .echo::text " " => "1" +``` + +# Update `{"label":"d"}` +```html +
+ + d x1 + + +

+ 1 +

+ +
+``` +## Change +``` +UPDATE: main > em::text@0 "c" => "d" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/render.md new file mode 100644 index 00000000000..791ddcccf4b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/render.md @@ -0,0 +1,167 @@ +# Render `{"label":"a"}` +```html +
+ + a x1 + + +

+ 1 +

+ +
+``` + +# Update +```js +document.querySelector("button.bump").click(); +``` +```html +
+ + a x2 + + +

+ 2 +

+ +
+``` +## Change +``` +UPDATE: main > em::text@3 "1" => "2" +UPDATE: .echo::text "1" => "2" +``` + +# Update `{"label":"b"}` +```html +
+ + b x2 + + +

+ 2 +

+ +
+``` +## Change +``` +UPDATE: main > em::text@0 "a" => "b" +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > em +REMOVE: main > button +REMOVE: main > p +``` + +# Update `{"label":"c"}` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ + c x1 + + +

+ 1 +

+ +
+``` +## Change +``` +INSERT: main > :is(em, .bump, .echo) +UPDATE: main > em::text@0 "" => "c" +UPDATE: main > em::text@3 "" => "1" +UPDATE: .echo::text " " => "1" +``` + +# Update `{"label":"d"}` +```html +
+ + d x1 + + +

+ 1 +

+ +
+``` +## Change +``` +UPDATE: main > em::text@0 "c" => "d" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..33fff04105c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/writes.debug.html @@ -0,0 +1,24 @@ +
a x1 +

1

+
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/writes.html new file mode 100644 index 00000000000..8301a5ecf7d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/__snapshots__/writes.html @@ -0,0 +1,20 @@ +
a x1 +

1

+
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/sizes.json new file mode 100644 index 00000000000..3e90cd682ca --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/sizes.json @@ -0,0 +1,22 @@ +{ + "dom": { + "template.marko.page.mjs": { + "total": { + "min": 7860, + "brotli": 3516 + }, + "files": { + "tags/widget/index.marko": 538, + "template.marko": 762 + } + } + }, + "html": { + "min": 553, + "brotli": 348 + }, + "patch": { + "min": 30, + "brotli": 34 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/tags/price-card.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/tags/price-card.marko deleted file mode 100644 index abaa84c05b2..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/tags/price-card.marko +++ /dev/null @@ -1,5 +0,0 @@ - -
-

${input.label + " x" + qty}

- + -
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/tags/widget/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/tags/widget/index.marko index e18b824e7cd..7a03c24cdaf 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/tags/widget/index.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/tags/widget/index.marko @@ -1 +1,4 @@ -${input.label || "x"} + +${input.label} x${count} ++ + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko index 471b81558a5..4c485950236 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/template.marko @@ -1,7 +1,8 @@
- + + ${w}

- + t
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/test.ts index 7a0ac0e9bf4..20939428df7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-client-tag-var/test.ts @@ -1,6 +1,23 @@ import type { TestConfig } from "../../main.test"; +const bump = (document: Document) => { + document.querySelector("button.bump")!.click(); +}; +const toggle = (document: Document) => { + document.querySelector("button.toggle")!.click(); +}; + +// An unassigned tag variable on a child inside client-owned structure is a +// local read: the return recomputes wholly client-side each render. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: [ + { label: "a" }, + bump, + { label: "b" }, + toggle, + { label: "c" }, + toggle, + { label: "d" }, + ], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-composed-mixed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-composed-mixed/sizes.json index 624647e4360..f13f93167a0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-composed-mixed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-composed-mixed/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 4102, - "brotli": 1958 + "min": 4080, + "brotli": 1954 }, "files": { "tags/relay/tags/leaf/index.marko": 129, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-composed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-composed/sizes.json index 2638b9d95ad..8aaea5554c5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-composed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-composed/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3306, + "min": 3305, "brotli": 1642 }, "files": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-attr/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-attr/sizes.json index 833040b9d06..13121a96f8f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-attr/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-attr/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7384, - "brotli": 3328 + "min": 7366, + "brotli": 3319 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-branch/sizes.json index eb593abb262..8878818d892 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7384, - "brotli": 3328 + "min": 7366, + "brotli": 3319 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-clobber/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-clobber/sizes.json index aa783bfdef8..015a7c5fa63 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-clobber/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-const-clobber/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3467, - "brotli": 1690 + "min": 3466, + "brotli": 1694 }, "files": { "tags/card/index.marko": 118, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..651425f2759 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,30 @@ +// tags/panel/index.marko +const $template$1 = "
"; +const $walks$1 = "D%l"; +const $setup$1 = () => {}; +const $input_header_direct = /*@__PURE__*/ _dynamic_tag_content("#text/0"); +const $dynamicTag = /*@__PURE__*/ _dynamic_tag("#text/0"); +const $input_header = $dynamicTag; +const $input$1 = ($scope, input) => $input_header($scope, input.header); +var panel_default = /*@__PURE__*/ _template("__tests__/tags/panel/index.marko", $template$1, "D%l", 0, $input$1); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +const $header_content__input_title = /*@__PURE__*/ _fill_join_closure("__tests__/template.marko0", "input_title", /*@__PURE__*/ _closure_get("input_title", ($scope) => _text($scope["#text/0"], $scope._._.input_title), ($scope) => $scope._._), 0); +const $header_content__setup = $header_content__input_title; +const $header_content = /*@__PURE__*/ _content("__tests__/template.marko_2*content", "

hi

", "Db%", $header_content__setup); +const $if_content__setup = ($scope) => $input_header($scope["#childScope/0"], attrTag({ content: $header_content($scope) })); +const $if = /*@__PURE__*/ _if("#text/0", $template$1, /*@__PURE__*/ ((_w0) => `/${_w0}&`)("D%l"), $if_content__setup); +const $open = /*@__PURE__*/ _let("open/5", ($scope) => $if($scope, $scope.open ? 0 : 1)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { + $open($scope, !$scope.open); +})); +function $setup($scope) { + $open($scope, false); + $setup__script($scope); +} +const $input = ($scope, input) => $input_title($scope, input.title); +const $input_title__closure = /*@__PURE__*/ _closure($header_content__input_title); +const $input_title = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_title", $input_title__closure); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..3403ea69a51 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/dom.bundle.js @@ -0,0 +1,14 @@ +// tags/panel/index.marko +const $template = "
"; +const $dynamicTag = /*@__PURE__*/ _dynamic_tag(0); +const $input_header = $dynamicTag; + +// template.marko +const $header_content__input_title = /*@__PURE__*/ _fill_join_closure("a0", 4, /*@__PURE__*/ _closure_get(6, ($scope) => _text($scope.a, $scope._._.e), ($scope) => $scope._._), 0); +const $header_content = /*@__PURE__*/ _content$1("a0", "

hi

", "Db%", $header_content__input_title); +const $if_content__setup = ($scope) => $input_header($scope.a, attrTag({ content: $header_content($scope) })); +const $if = /*@__PURE__*/ _if(0, $template, /*@__PURE__*/ ((_w0) => `/${_w0}&`)("D%l"), $if_content__setup); +const $open = /*@__PURE__*/ _let(5, ($scope) => $if($scope, $scope.f ? 0 : 1)); +const $setup__script = _script("a1", ($scope) => _on($scope.b, "click", function() { + $open($scope, !$scope.f); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index 7cec9c07605..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^ Persisted templates cannot patch this faithfully yet: attribute tags for a child inside client-owned structure are not supported yet. - 5 | <@header> - 6 |

hi

- 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-dom.txt deleted file mode 100644 index 7cec9c07605..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^ Persisted templates cannot patch this faithfully yet: attribute tags for a child inside client-owned structure are not supported yet. - 5 | <@header> - 6 |

hi

- 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index 7cec9c07605..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^ Persisted templates cannot patch this faithfully yet: attribute tags for a child inside client-owned structure are not supported yet. - 5 | <@header> - 6 |

hi

- 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-html.txt deleted file mode 100644 index 7cec9c07605..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko:4:5 - 2 |
- 3 | - > 4 | - | ^ Persisted templates cannot patch this faithfully yet: attribute tags for a child inside client-owned structure are not supported yet. - 5 | <@header> - 6 |

hi

- 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..c4771398663 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/html.bundle.debug.js @@ -0,0 +1,55 @@ +// tags/panel/index.marko +const $template$1 = "
"; +const $walks$1 = "D%l"; +_shells({ "__tests__/tags/panel/index.marko": "__tests__/tags/panel/index.marko;D%;
" }); +var panel_default = _template_persisted("__tests__/tags/panel/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _patch_dynamic_tag($scope0_id, "#text/0", input.header, $scope0_owned, 0); + _dynamic_tag($scope0_id, "#text/0", input.header, {}, 0, 0, _source_guard($scope0_reason, 0), 1); + _html("
"); + $scope0_reason && _scope($scope0_id, {}, "__tests__/tags/panel/index.marko", 0); +}, 0, 0); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +_shells({ + "__tests__/template.marko_2*content": "__tests__/template.marko_2*content;Db%;

hi

", + "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b ;
" +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_title__closures = new Set(); + let open = false; + _html("
"); + if ($scope0_reason) _if(() => { + if (open) { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + panel_default({ header: attrTag({ content: _content_elide("__tests__/template.marko_2*content", () => { + const $scope2_reason = _persisted_reason(); + const $scope2_id = _scope_id(); + _html(`

hi ${_text_resume($scope2_id, "#text/0", input.title, 2)}

`); + _subscribe(_source_if($scope0_reason, 0) && $input_title__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "5:8")); + _resume_branch($scope2_id); + }, $scope1_id) }) }); + _scope($scope1_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "3:4"); + return 0; + } + }, $scope0_id, "#text/0", 1, 1, 1, 0, 1); + _html(`${_el_resume($scope0_id, "#button/1")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + input_title: input.title, + open, + "ClosureScopes:input_title": $input_title__closures + }, "__tests__/template.marko", 0, { + input_title: ["input.title"], + open: "1:6" + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", input.title); + _resume_branch($scope0_id); +}, 1, () => [panel_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..98ecf32b847 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/html.bundle.js @@ -0,0 +1,33 @@ +// tags/panel/index.marko +_shells({ b: "b;D%;
" }); +var panel_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _patch_dynamic_tag($scope0_id, "a", input.header, $scope0_owned, 0); + _dynamic_tag($scope0_id, "a", input.header, {}, 0, 0, _source_guard($scope0_reason, 0), 1); + _html("
"); + $scope0_reason && _scope($scope0_id, {}); +}, 0, 0); + +// template.marko +_shells({ + a0: "a0;Db%;

hi

", + a: "a !a1;D%b ;
" +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_title__closures = /* @__PURE__ */ new Set(); + let open = false; + _html("
"); + if ($scope0_reason) _if(() => {}, $scope0_id, "a", 1, 1, 1, 0, 1); + _html(`${_el_resume($scope0_id, "b")}
`); + _script($scope0_id, "a1"); + $scope0_reason ? _scope($scope0_id, { + e: input.title, + f: open, + g: $input_title__closures + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", input.title); + _resume_branch($scope0_id); +}, 1, () => [panel_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..05e3e8aed92 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/patches.debug.js @@ -0,0 +1,14 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko0": "b" +} + +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko0": "c" +} + +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko0": "d" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/patches.js new file mode 100644 index 00000000000..b190f50ad97 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/patches.js @@ -0,0 +1,14 @@ +// PATCH +{ + va0: "b" +} + +// PATCH +{ + va0: "c" +} + +// PATCH +{ + va0: "d" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/render.debug.md new file mode 100644 index 00000000000..f5e4a454848 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/render.debug.md @@ -0,0 +1,116 @@ +# Render `{"title":"a"}` +```html +
+ +
+``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+
+

+ hi a +

+
+ +
+``` +## Change +``` +INSERT: main > .panel +INSERT: .panel > h1 +UPDATE: .panel > h1::text@3 "" => "a" +``` + +# Update `{"title":"b"}` +```html +
+
+

+ hi b +

+
+ +
+``` +## Change +``` +UPDATE: .panel > h1::text@3 "a" => "b" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > div +``` + +# Update `{"title":"c"}` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+
+

+ hi c +

+
+ +
+``` +## Change +``` +INSERT: main > .panel +INSERT: .panel > h1 +UPDATE: .panel > h1::text@3 "" => "c" +``` + +# Update `{"title":"d"}` +```html +
+
+

+ hi d +

+
+ +
+``` +## Change +``` +UPDATE: .panel > h1::text@3 "c" => "d" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/render.md new file mode 100644 index 00000000000..f5e4a454848 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/render.md @@ -0,0 +1,116 @@ +# Render `{"title":"a"}` +```html +
+ +
+``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+
+

+ hi a +

+
+ +
+``` +## Change +``` +INSERT: main > .panel +INSERT: .panel > h1 +UPDATE: .panel > h1::text@3 "" => "a" +``` + +# Update `{"title":"b"}` +```html +
+
+

+ hi b +

+
+ +
+``` +## Change +``` +UPDATE: .panel > h1::text@3 "a" => "b" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > div +``` + +# Update `{"title":"c"}` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+
+

+ hi c +

+
+ +
+``` +## Change +``` +INSERT: main > .panel +INSERT: .panel > h1 +UPDATE: .panel > h1::text@3 "" => "c" +``` + +# Update `{"title":"d"}` +```html +
+
+

+ hi d +

+
+ +
+``` +## Change +``` +UPDATE: .panel > h1::text@3 "c" => "d" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..5cc935d7bf1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/writes.debug.html @@ -0,0 +1,12 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/writes.html new file mode 100644 index 00000000000..35694fce683 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/__snapshots__/writes.html @@ -0,0 +1,10 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/sizes.json new file mode 100644 index 00000000000..348ba12ff67 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/sizes.json @@ -0,0 +1,22 @@ +{ + "dom": { + "template.marko.page.mjs": { + "total": { + "min": 11512, + "brotli": 4906 + }, + "files": { + "tags/panel/index.marko": 180, + "template.marko": 748 + } + } + }, + "html": { + "min": 382, + "brotli": 269 + }, + "patch": { + "min": 30, + "brotli": 34 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko index fb86b0418ea..1bd485ef6bd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/template.marko @@ -3,7 +3,7 @@ <@header> -

hi

+

hi ${input.title}

diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/test.ts index a417c0b3d9c..f7fbce26c8f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-attr-tags/test.ts @@ -1,8 +1,20 @@ import type { TestConfig } from "../../main.test"; -// Attribute tags have per-name channels the region checks cannot see -// through yet: fail closed at the call site. +const toggle = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// An attr tag feeds a client-owned child like body content: its body +// compiles in this file and its filled reads stay fresh across patches. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: [ + { title: "a" }, + toggle, + { title: "b" }, + toggle, + { title: "c" }, + toggle, + { title: "d" }, + ], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-deep/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-deep/sizes.json index 97a001d8e18..e917e454f51 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-deep/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-deep/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 11695, - "brotli": 4952 + "min": 11630, + "brotli": 4926 }, "files": { "tags/card/index.marko": 173, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-open/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-open/sizes.json index 952db6028f0..08ce123e5d1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-open/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-open/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 11597, - "brotli": 4919 + "min": 11532, + "brotli": 4901 }, "files": { "tags/box/index.marko": 159, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-structure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-structure/sizes.json index 61fe9dcebda..02de5830441 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-structure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content-structure/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 11674, - "brotli": 4951 + "min": 11609, + "brotli": 4927 }, "files": { "tags/box/index.marko": 159, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content/sizes.json index ee84d3a4249..44c94fa82c7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-content/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 11597, - "brotli": 4919 + "min": 11532, + "brotli": 4901 }, "files": { "tags/box/index.marko": 159, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-loop/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-loop/sizes.json index 64c1da9512a..2783bfb9574 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-loop/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-loop/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 9915, - "brotli": 4415 + "min": 9876, + "brotli": 4404 }, "files": { "tags/counter/index.marko": 301, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-passthrough/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-passthrough/sizes.json index 1a0f2876107..b8d6f68edfe 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-passthrough/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-passthrough/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8056, - "brotli": 3583 + "min": 8017, + "brotli": 3572 }, "files": { "tags/counter/index.marko": 301, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-poison/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-poison/sizes.json index aba04697b29..4b3bc978b34 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-poison/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-poison/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 10162, - "brotli": 4516 + "min": 10123, + "brotli": 4509 }, "files": { "tags/counter/index.marko": 309, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-siblings/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-siblings/sizes.json index 5ad8f5711f9..a51524e079c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-siblings/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-siblings/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8113, - "brotli": 3597 + "min": 8074, + "brotli": 3584 }, "files": { "tags/counter/index.marko": 301, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-swap/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-swap/sizes.json index 4c3cec054c3..0cbf03a5654 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-swap/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable-swap/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8075, - "brotli": 3593 + "min": 8036, + "brotli": 3576 }, "files": { "tags/counter/index.marko": 301, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable/sizes.json index 363823741aa..7f39111d688 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-controllable/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8056, - "brotli": 3583 + "min": 8017, + "brotli": 3572 }, "files": { "tags/counter/index.marko": 301, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-ctrl-input/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-ctrl-input/sizes.json index cfcf1104164..90ac36bf7f8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-ctrl-input/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-ctrl-input/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 9131, - "brotli": 4010 + "min": 9099, + "brotli": 4004 }, "files": { "tags/field/index.marko": 589, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-ctrl-server-handler/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-ctrl-server-handler/sizes.json index 8b426a3c36b..41fbe10ff79 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-ctrl-server-handler/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-ctrl-server-handler/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 9393, - "brotli": 4117 + "min": 9355, + "brotli": 4101 }, "files": { "tags/field/index.marko": 501, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-fn-server/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-fn-server/sizes.json index 4e74d204bbb..5a2a9a3cec9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-fn-server/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-fn-server/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 4118, - "brotli": 1971 + "min": 4096, + "brotli": 1964 }, "files": { "tags/dump/index.marko": 123, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..f39bc9cacb5 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,24 @@ +// tags/widget/index.marko +const $template$1 = " "; +const $walks$1 = "D l"; +const $setup$1 = () => {}; +const $input_text = ($scope, input_text) => _text($scope["#text/0"], input_text); +const $input = ($scope, input) => $input_text($scope, input.text); +var widget_default = /*@__PURE__*/ _template("__tests__/tags/widget/index.marko", $template$1, "D l", 0, $input); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +const $if_content__brand = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "brand", /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => $input_text($scope["#childScope/0"], $scope._.brand))); +const $if_content__setup = $if_content__brand; +const $brand = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "brand", $if_content__brand); +const $if = /*@__PURE__*/ _if("#text/0", $template$1, /*@__PURE__*/ ((_w0) => `/${_w0}&`)("D l"), $if_content__setup); +const $show = /*@__PURE__*/ _let("show/4", ($scope) => $if($scope, $scope.show ? 0 : 1)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { + $show($scope, !$scope.show); +})); +function $setup($scope) { + $show($scope, true); + $setup__script($scope); +} +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..b7fa0b25c4b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/dom.bundle.js @@ -0,0 +1,11 @@ +// tags/widget/index.marko +const $template = " "; +const $input_text = ($scope, input_text) => _text($scope.a, input_text); + +// template.marko +const $if_content__setup = /* @__PURE__ */ _fill_join("a0", 2, /*@__PURE__*/ _if_closure(0, 0, ($scope) => $input_text($scope.a, $scope._.c))); +const $if = /*@__PURE__*/ _if(0, $template, /*@__PURE__*/ ((_w0) => `/${_w0}&`)("D l"), $if_content__setup); +const $show = /*@__PURE__*/ _let(4, ($scope) => $if($scope, $scope.e ? 0 : 1)); +const $setup__script = _script("a0", ($scope) => _on($scope.b, "click", function() { + $show($scope, !$scope.e); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index 069e1baf9c2..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/template.marko:5:13 - 3 |
- 4 | - > 5 | - | ^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `$global` cannot be read inside client-owned structure. - 6 | - 7 | - 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-dom.txt deleted file mode 100644 index 069e1baf9c2..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/template.marko:5:13 - 3 |
- 4 | - > 5 | - | ^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `$global` cannot be read inside client-owned structure. - 6 | - 7 | - 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index 069e1baf9c2..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/template.marko:5:13 - 3 |
- 4 | - > 5 | - | ^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `$global` cannot be read inside client-owned structure. - 6 | - 7 | - 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-html.txt deleted file mode 100644 index 069e1baf9c2..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,9 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/template.marko:5:13 - 3 |
- 4 | - > 5 | - | ^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `$global` cannot be read inside client-owned structure. - 6 | - 7 | - 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..db6b39ecf0c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/html.bundle.debug.js @@ -0,0 +1,43 @@ +// tags/widget/index.marko +const $template$1 = " "; +const $walks$1 = "D l"; +_shells({ "__tests__/tags/widget/index.marko": "__tests__/tags/widget/index.marko;D ; " }); +var widget_default = _template_persisted("__tests__/tags/widget/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html(`${_patch_text($scope0_id, "#text/0", input.text, void 0, $scope0_owned, 0)}`); + $scope0_reason && _scope($scope0_id, {}, "__tests__/tags/widget/index.marko", 0); +}, 0, 0); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b ;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + const brand = `${$global$1.brand}`; + let show = true; + _html("
"); + if ($scope0_reason) _if(() => { + if (show) { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + widget_default({ text: brand }); + _scope($scope1_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "4:4"); + return 0; + } + }, $scope0_id, "#text/0", 1, 1, 1, 0, 1); + _html(`${_el_resume($scope0_id, "#button/1")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + brand, + show + }, "__tests__/template.marko", 0, { + brand: "1:8", + show: "2:6" + }) : _patch_value($scope0_id, "__tests__/template.marko0", brand); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..acbbd4f9a73 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/html.bundle.js @@ -0,0 +1,35 @@ +// tags/widget/index.marko +_shells({ b: "b;D ; " }); +var widget_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html(`${_patch_text($scope0_id, "a", input.text, void 0, $scope0_owned, 0)}`); + $scope0_reason && _scope($scope0_id, {}); +}, 0, 0); + +// template.marko +_shells({ a: "a !a0;D%b ;
" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const brand = `${$global().brand}`; + let show = true; + _html("
"); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + widget_default({ text: brand }); + _scope($scope1_id, { a: _existing_scope($childScope) }); + return 0; + } + }, $scope0_id, "a", 1, 1, 1, 0, 1); + _html(`${_el_resume($scope0_id, "b")}
`); + _script($scope0_id, "a0"); + $scope0_reason ? _scope($scope0_id, { + c: brand, + e: show + }) : _patch_value($scope0_id, "a0", brand); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..06a52d082ac --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/patches.debug.js @@ -0,0 +1,4 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/template.marko0": "bmce" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/patches.js new file mode 100644 index 00000000000..5014312e4f3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/patches.js @@ -0,0 +1,4 @@ +// PATCH +{ + va0: "bmce" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/render.debug.md new file mode 100644 index 00000000000..f4314eed842 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/render.debug.md @@ -0,0 +1,63 @@ +# Render `{"$global":{"brand":"acme"}}` +```html +
+ + acme + + +
+``` + +# Update `{"$global":{"brand":"bmce"}}` +```html +
+ + bmce + + +
+``` +## Change +``` +UPDATE: main > em::text "acme" => "bmce" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > em +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ + bmce + + +
+``` +## Change +``` +INSERT: main > em +UPDATE: main > em::text " " => "bmce" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/render.md new file mode 100644 index 00000000000..f4314eed842 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/render.md @@ -0,0 +1,63 @@ +# Render `{"$global":{"brand":"acme"}}` +```html +
+ + acme + + +
+``` + +# Update `{"$global":{"brand":"bmce"}}` +```html +
+ + bmce + + +
+``` +## Change +``` +UPDATE: main > em::text "acme" => "bmce" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > em +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html +
+ + bmce + + +
+``` +## Change +``` +INSERT: main > em +UPDATE: main > em::text " " => "bmce" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..e10c0a5ea2c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/writes.debug.html @@ -0,0 +1,15 @@ +
+ acme +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/writes.html new file mode 100644 index 00000000000..7baecea664b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/__snapshots__/writes.html @@ -0,0 +1,12 @@ +
acme +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/sizes.json new file mode 100644 index 00000000000..d175d6e0443 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/sizes.json @@ -0,0 +1,22 @@ +{ + "dom": { + "template.marko.page.mjs": { + "total": { + "min": 7414, + "brotli": 3339 + }, + "files": { + "tags/widget/index.marko": 152, + "template.marko": 488 + } + } + }, + "html": { + "min": 412, + "brotli": 285 + }, + "patch": { + "min": 13, + "brotli": 17 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/test.ts index b33af38f028..182feb13242 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-derived/test.ts @@ -1,7 +1,18 @@ import type { TestConfig } from "../../main.test"; -// A `$global`-derived feed never re-ships, so it fails closed. +const toggle = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// A child inside client-owned structure fed a `$global`-derived value: the +// derivation delivers as a fill, so the re-shown child renders the latest +// patch's brand. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: [ + { $global: { brand: "acme" } }, + { $global: { brand: "bmce" } }, + toggle, + toggle, + ], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-owned/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-owned/__snapshots__/dom.bundle.debug.js index 6485612c9b5..35abb5e06c5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-owned/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-owned/__snapshots__/dom.bundle.debug.js @@ -1,12 +1,10 @@ // tags/g-badge/index.marko const $template$1 = "

"; const $walks$1 = "D%c%l"; +const $setup$1 = () => {}; const $input_value = ($scope, input_value) => _text($scope["#text/0"], input_value); -function $setup$1($scope) { - _text($scope["#text/1"], $scope.$global.flag); -} const $input = ($scope, input) => $input_value($scope, input.value); -var g_badge_default = /*@__PURE__*/ _template("__tests__/tags/g-badge/index.marko", $template$1, $walks$1, $setup$1, $input); +var g_badge_default = /*@__PURE__*/ _template("__tests__/tags/g-badge/index.marko", $template$1, $walks$1, 0, $input); // template.marko const $template = /*@__PURE__*/ ((_w0) => `
${_w0}
`)($template$1); @@ -16,7 +14,6 @@ const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($sc $count($scope, +$scope.count + 1); })); function $setup($scope) { - $setup$1($scope["#childScope/0"]); $count($scope, 0); $setup__script($scope); } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-owned/sizes.json index 5d7699efa68..aaa937a34a7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-global-owned/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3288, - "brotli": 1631 + "min": 3287, + "brotli": 1634 }, "files": { "tags/g-badge/index.marko": 124, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-dom.debug.txt index 68d529c3541..e08b864ecf1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-dom.debug.txt +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-dom.debug.txt @@ -3,7 +3,7 @@ 2 |
3 | > 4 | - | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads `$global` (it would go stale). + | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads a `$global`-derived value (it would go stale). 5 | 6 | 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-dom.txt index 68d529c3541..e08b864ecf1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-dom.txt +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-dom.txt @@ -3,7 +3,7 @@ 2 |
3 | > 4 | - | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads `$global` (it would go stale). + | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads a `$global`-derived value (it would go stale). 5 | 6 | 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-html.debug.txt index 68d529c3541..e08b864ecf1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-html.debug.txt +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-html.debug.txt @@ -3,7 +3,7 @@ 2 |
3 | > 4 | - | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads `$global` (it would go stale). + | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads a `$global`-derived value (it would go stale). 5 | 6 | 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-html.txt index 68d529c3541..e08b864ecf1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-html.txt +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-globals/__snapshots__/error-compile-html.txt @@ -3,7 +3,7 @@ 2 |
3 | > 4 | - | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads `$global` (it would go stale). + | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads a `$global`-derived value (it would go stale). 5 | 6 | 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-dom.debug.txt new file mode 100644 index 00000000000..8fa8347cfa3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-dom.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure renders a nested child with an assigned tag variable. + 5 | + 6 | t + 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-dom.txt new file mode 100644 index 00000000000..8fa8347cfa3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-dom.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure renders a nested child with an assigned tag variable. + 5 | + 6 | t + 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-html.debug.txt new file mode 100644 index 00000000000..8fa8347cfa3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-html.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure renders a nested child with an assigned tag variable. + 5 | + 6 | t + 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-html.txt new file mode 100644 index 00000000000..8fa8347cfa3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/__snapshots__/error-compile-html.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure renders a nested child with an assigned tag variable. + 5 | + 6 | t + 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/tags/widget/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/tags/widget/index.marko new file mode 100644 index 00000000000..23ff0341385 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/tags/widget/index.marko @@ -0,0 +1,3 @@ + +${v} +r diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/tags/widget/tags/inner/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/tags/widget/tags/inner/index.marko new file mode 100644 index 00000000000..f8aea48cdbd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/tags/widget/tags/inner/index.marko @@ -0,0 +1,3 @@ + ++ + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/template.marko new file mode 100644 index 00000000000..eec18b3a185 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/template.marko @@ -0,0 +1,7 @@ + +
+ + + + t +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/test.ts new file mode 100644 index 00000000000..9b6e975fede --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var-assigned/test.ts @@ -0,0 +1,8 @@ +import type { TestConfig } from "../../main.test"; + +// Assigning a grandchild's tag variable needs the `_var_change` chain the +// instance memo cannot vouch for: the call site fails closed. +export const config: TestConfig = { + error_compiler: true, + persisted: true, +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..205ffdbc820 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,39 @@ +// tags/widget/tags/inner/index.marko +const $template$2 = ""; +const $walks$2 = " b"; +const $n = /*@__PURE__*/ _fill_let("__tests__/tags/widget/tags/inner/index.marko0", "n/1", ($scope) => _return($scope, $scope.n)); +const $setup__script$1 = _script("__tests__/tags/widget/tags/inner/index.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $n($scope, +$scope.n + 1); +})); +function $setup$2($scope) { + $n($scope, 1); + $setup__script$1($scope); +} +var inner_default = /*@__PURE__*/ _template("__tests__/tags/widget/tags/inner/index.marko", $template$2, " b", $setup$2); + +// tags/widget/index.marko +const $template$1 = /*@__PURE__*/ ((_w0) => `${_w0} `)($template$2); +const $walks$1 = /*@__PURE__*/ ((_w0) => `0${_w0}&D l`)(" b"); +const $v = _var_resume("__tests__/tags/widget/index.marko_0_v#3/var", ($scope, v) => _text($scope["#text/2"], v)); +function $setup$1($scope) { + _var($scope, "#childScope/0", $v); + $setup$2($scope["#childScope/0"]); +} +var widget_default = /*@__PURE__*/ _template("__tests__/tags/widget/index.marko", $template$1, $walks$1, $setup$1); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +const $if_content__setup = ($scope) => { + $setup$1($scope["#childScope/0"]); +}; +const $if = /*@__PURE__*/ _if("#text/0", $template$1, /*@__PURE__*/ ((_w0) => `/${_w0}&`)($walks$1), $if_content__setup); +const $show = /*@__PURE__*/ _let("show/2", ($scope) => $if($scope, $scope.show ? 0 : 1)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { + $show($scope, !$scope.show); +})); +function $setup($scope) { + $show($scope, true); + $setup__script($scope); +} +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..a566ea0cff0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/dom.bundle.js @@ -0,0 +1,29 @@ +// tags/widget/tags/inner/index.marko +const $template$1 = ""; +const $n = /*@__PURE__*/ _fill_let("c0", 1, ($scope) => _return($scope, $scope.b)); +const $setup__script$1 = _script("c0", ($scope) => _on($scope.a, "click", function() { + $n($scope, +$scope.b + 1); +})); +function $setup$1($scope) { + $n($scope, 1); + $setup__script$1($scope); +} + +// tags/widget/index.marko +const $template = /*@__PURE__*/ ((_w0) => `${_w0} `)($template$1); +const $walks = /*@__PURE__*/ ((_w0) => `0${_w0}&D l`)(" b"); +const $v = _var_resume("b0", ($scope, v) => _text($scope.c, v)); +function $setup($scope) { + _var($scope, 0, $v); + $setup$1($scope.a); +} + +// template.marko +const $if_content__setup = ($scope) => { + $setup($scope.a); +}; +const $if = /*@__PURE__*/ _if(0, $template, /*@__PURE__*/ ((_w0) => `/${_w0}&`)($walks), $if_content__setup); +const $show = /*@__PURE__*/ _let(2, ($scope) => $if($scope, $scope.c ? 0 : 1)); +const $setup__script = _script("a0", ($scope) => _on($scope.b, "click", function() { + $show($scope, !$scope.c); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..53f4740aabe --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/html.bundle.debug.js @@ -0,0 +1,54 @@ +// tags/widget/tags/inner/index.marko +const $template$2 = ""; +const $walks$2 = " b"; +_shells({ "__tests__/tags/widget/tags/inner/index.marko": "__tests__/tags/widget/tags/inner/index.marko !__tests__/tags/widget/tags/inner/index.marko_0; ;" }); +var inner_default = _template_persisted("__tests__/tags/widget/tags/inner/index.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let n = 1; + _html(`${_el_resume($scope0_id, "#button/0")}`); + const $return = n; + _script($scope0_id, "__tests__/tags/widget/tags/inner/index.marko_0"); + _patch_value($scope0_id, "__tests__/tags/widget/tags/inner/index.marko0", n, 1); + $scope0_reason && _scope($scope0_id, { n }, "__tests__/tags/widget/tags/inner/index.marko", 0, { n: "1:6" }); + _resume_branch($scope0_id); + return $return; +}, 0, 0); + +// tags/widget/index.marko +const $template$1 = /*@__PURE__*/ ((_w0) => `${_w0} `)($template$2); +const $walks$1 = /*@__PURE__*/ ((_w0) => `0${_w0}&D l`)(" b"); +var widget_default = _template_persisted("__tests__/tags/widget/index.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "#childScope/0", $childScope); + let v = inner_default({}); + _var($scope0_id, "#scopeOffset/1", $childScope, "__tests__/tags/widget/index.marko_0_v#3/var"); + _html(`${_text_resume($scope0_id, "#text/2", v)}`); + $scope0_reason && _scope($scope0_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/tags/widget/index.marko", 0); +}, 0, () => [inner_default]); + +// template.marko +const $template = "
"; +const $walks = "D%b l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b ;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + _html("
"); + if ($scope0_reason) _if(() => { + if (show) { + const $scope1_id = _scope_id(); + const $childScope = _peek_scope_id(); + widget_default({}); + _scope($scope1_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "3:4"); + return 0; + } + }, $scope0_id, "#text/0"); + _html(`${_el_resume($scope0_id, "#button/1")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason && _scope($scope0_id, { show }, "__tests__/template.marko", 0, { show: "1:6" }); + _resume_branch($scope0_id); +}, 1, () => [widget_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..8816f18df98 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/html.bundle.js @@ -0,0 +1,48 @@ +// tags/widget/tags/inner/index.marko +_shells({ c: "c !c0; ;" }); +var inner_default = _template_persisted("c", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let n = 1; + _html(`${_el_resume($scope0_id, "a")}`); + const $return = n; + _script($scope0_id, "c0"); + _patch_value($scope0_id, "c0", n, 1); + $scope0_reason && _scope($scope0_id, { b: n }); + _resume_branch($scope0_id); + return $return; +}, 0, 0); + +// tags/widget/index.marko +var widget_default = _template_persisted("b", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "a", $childScope); + let v = inner_default({}); + _var($scope0_id, "b", $childScope, "b0"); + _html(`${_text_resume($scope0_id, "c", v)}`); + $scope0_reason && _scope($scope0_id, { a: _existing_scope($childScope) }); +}, 0, () => [inner_default]); + +// template.marko +_shells({ a: "a !a0;D%b ;
" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + _html("
"); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + const $childScope = _peek_scope_id(); + widget_default({}); + _scope($scope1_id, { a: _existing_scope($childScope) }); + return 0; + } + }, $scope0_id, "a"); + _html(`${_el_resume($scope0_id, "b")}
`); + _script($scope0_id, "a0"); + $scope0_reason && _scope($scope0_id, { c: show }); + _resume_branch($scope0_id); +}, 1, () => [widget_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..d7bdae7b7c3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/patches.debug.js @@ -0,0 +1,7 @@ +// PATCH + + +// PATCH + + +// PATCH diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/patches.js new file mode 100644 index 00000000000..d7bdae7b7c3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/patches.js @@ -0,0 +1,7 @@ +// PATCH + + +// PATCH + + +// PATCH diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/render.debug.md new file mode 100644 index 00000000000..2154c4c79d6 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/render.debug.md @@ -0,0 +1,90 @@ +# Render +```html +
+ + + 1 + + +
+``` + +# Update +```js +document.querySelector("button.bump").click(); +``` +```html +
+ + + 2 + + +
+``` +## Change +``` +UPDATE: main > em::text "1" => "2" +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > button +REMOVE: main > em +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ + + 1 + + +
+``` +## Change +``` +INSERT: main > :is(.bump, em) +UPDATE: main > em::text " " => "1" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/render.md new file mode 100644 index 00000000000..2154c4c79d6 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/render.md @@ -0,0 +1,90 @@ +# Render +```html +
+ + + 1 + + +
+``` + +# Update +```js +document.querySelector("button.bump").click(); +``` +```html +
+ + + 2 + + +
+``` +## Change +``` +UPDATE: main > em::text "1" => "2" +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ +
+``` +## Change +``` +REMOVE: main > button +REMOVE: main > em +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ + + 1 + + +
+``` +## Change +``` +INSERT: main > :is(.bump, em) +UPDATE: main > em::text " " => "1" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..035ee9d36be --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/writes.debug.html @@ -0,0 +1,23 @@ +
1
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/writes.html new file mode 100644 index 00000000000..4e4ec2334be --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/__snapshots__/writes.html @@ -0,0 +1,19 @@ +
1
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/sizes.json new file mode 100644 index 00000000000..5909de663e3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/sizes.json @@ -0,0 +1,23 @@ +{ + "dom": { + "template.marko.page.mjs": { + "total": { + "min": 7472, + "brotli": 3354 + }, + "files": { + "tags/widget/tags/inner/index.marko": 388, + "tags/widget/index.marko": 320, + "template.marko": 408 + } + } + }, + "html": { + "min": 505, + "brotli": 325 + }, + "patch": { + "min": 0, + "brotli": 1 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/tags/widget/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/tags/widget/index.marko new file mode 100644 index 00000000000..dd676a7587f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/tags/widget/index.marko @@ -0,0 +1,2 @@ + +${v} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/tags/widget/tags/inner/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/tags/widget/tags/inner/index.marko new file mode 100644 index 00000000000..f8aea48cdbd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/tags/widget/tags/inner/index.marko @@ -0,0 +1,3 @@ + ++ + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/template.marko new file mode 100644 index 00000000000..eec18b3a185 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/template.marko @@ -0,0 +1,7 @@ + +
+ + + + t +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/test.ts new file mode 100644 index 00000000000..e6620935fb0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild-var/test.ts @@ -0,0 +1,15 @@ +import type { TestConfig } from "../../main.test"; + +const bump = (document: Document) => { + document.querySelector("button.bump")!.click(); +}; +const toggle = (document: Document) => { + document.querySelector("button.toggle")!.click(); +}; + +// A nested child reading a grandchild's UNASSIGNED tag variable is still a +// self-contained client instance: the return recomputes on every render. +export const config: TestConfig = { + persisted: true, + steps: [{}, bump, {}, toggle, {}, toggle, {}], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild/sizes.json index fb1f4f10724..b414949a2f3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-grandchild/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 6531, + "min": 6530, "brotli": 2996 }, "files": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-handler-import/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-handler-import/sizes.json index 2848cafb80b..6df60a9ec83 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-handler-import/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-handler-import/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8009, - "brotli": 3576 + "min": 7987, + "brotli": 3561 }, "files": { "tags/widget/helper.ts": 94, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-in-loop/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-in-loop/sizes.json index d85e7bca0fe..5b97f54ab52 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-in-loop/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-in-loop/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8444, - "brotli": 3825 + "min": 8422, + "brotli": 3818 }, "files": { "tags/badge/index.marko": 151, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-intersection/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-intersection/sizes.json index 26fe73ebcc4..277edb26579 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-intersection/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-intersection/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4149, - "brotli": 1981 + "min": 4127, + "brotli": 1969 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-local-client-fed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-local-client-fed/sizes.json index 7e396759cf0..0f9de9d5759 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-local-client-fed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-local-client-fed/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8677, - "brotli": 3814 + "min": 8638, + "brotli": 3801 }, "files": { "tags/child.marko": 785, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-mixed-attr/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-mixed-attr/sizes.json index 68008507e65..8126e8aec1f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-mixed-attr/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-mixed-attr/sizes.json @@ -2,7 +2,7 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3288, + "min": 3287, "brotli": 1635 }, "files": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-dom.debug.txt new file mode 100644 index 00000000000..e73e7d11215 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-dom.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | + 7 | + 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-dom.txt new file mode 100644 index 00000000000..e73e7d11215 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-dom.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | + 7 | + 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-html.debug.txt new file mode 100644 index 00000000000..e73e7d11215 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-html.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | + 7 | + 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-html.txt new file mode 100644 index 00000000000..e73e7d11215 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/__snapshots__/error-compile-html.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | + 7 | + 8 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/helper.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/helper.ts new file mode 100644 index 00000000000..5cf59f8001f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/helper.ts @@ -0,0 +1 @@ +export let thing = false; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/tags/tabs2/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/tags/tabs2/index.marko new file mode 100644 index 00000000000..5a7f42868d9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/tags/tabs2/index.marko @@ -0,0 +1,6 @@ + +
a
+ + + b + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/template.marko new file mode 100644 index 00000000000..0bc893d017e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/template.marko @@ -0,0 +1,8 @@ +import { thing } from "./helper"; + +
+ + + + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/test.ts new file mode 100644 index 00000000000..b90fd253e2e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural-attr/test.ts @@ -0,0 +1,8 @@ +import type { TestConfig } from "../../main.test"; + +// A plain attribute feeding a NESTED structural param matches through the +// input root property, so a provenance-free feed still fails closed. +export const config: TestConfig = { + error_compiler: true, + persisted: true, +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-dom.debug.txt new file mode 100644 index 00000000000..1f071a90d8d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-dom.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | <@tab on=thing/> + 7 | + 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-dom.txt new file mode 100644 index 00000000000..1f071a90d8d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-dom.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | <@tab on=thing/> + 7 | + 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-html.debug.txt new file mode 100644 index 00000000000..1f071a90d8d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-html.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | <@tab on=thing/> + 7 | + 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-html.txt new file mode 100644 index 00000000000..1f071a90d8d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/__snapshots__/error-compile-html.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/template.marko:5:5 + 3 |
+ 4 | + > 5 | + | ^ Persisted templates cannot patch this faithfully yet: an input the child needs server-owned cannot feed from client-owned structure. + 6 | <@tab on=thing/> + 7 | + 8 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/helper.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/helper.ts new file mode 100644 index 00000000000..5cf59f8001f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/helper.ts @@ -0,0 +1 @@ +export let thing = false; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/tags/tabs/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/tags/tabs/index.marko new file mode 100644 index 00000000000..5a7f42868d9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/tags/tabs/index.marko @@ -0,0 +1,6 @@ + +
a
+ + + b + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/template.marko new file mode 100644 index 00000000000..b6f21456233 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/template.marko @@ -0,0 +1,10 @@ +import { thing } from "./helper"; + +
+ + + <@tab on=thing/> + + + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/test.ts new file mode 100644 index 00000000000..42fd0b1a648 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-nested-structural/test.ts @@ -0,0 +1,8 @@ +import type { TestConfig } from "../../main.test"; + +// Group params carry LEAF property names: matching walks up to the input +// ROOT property, so a nested structural feed still gates its group. +export const config: TestConfig = { + error_compiler: true, + persisted: true, +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-attr/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-attr/sizes.json index b7b027bd4c5..3cb2701bce4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-attr/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-attr/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3312, - "brotli": 1648 + "min": 3311, + "brotli": 1647 }, "files": { "tags/dump/index.marko": 119, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-deep/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-deep/sizes.json index 45ca854c3b5..2386ea12d17 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-deep/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-deep/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2165, - "brotli": 1120 + "min": 2164, + "brotli": 1122 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-effect/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-effect/sizes.json index d34d77ed8cc..55f840ba146 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-effect/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-effect/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 4529, - "brotli": 2168 + "min": 4507, + "brotli": 2158 }, "files": { "tags/dump/index.marko": 356, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-mixed-feed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-mixed-feed/sizes.json index 9bdfd717e10..cd0e7bde1fa 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-mixed-feed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-mixed-feed/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 4120, - "brotli": 1978 + "min": 4098, + "brotli": 1962 }, "files": { "tags/echo/index.marko": 214, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-mixed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-mixed/sizes.json index c55be33ec28..86e7da572be 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-mixed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-mixed/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 4112, - "brotli": 1965 + "min": 4090, + "brotli": 1961 }, "files": { "tags/dump/index.marko": 119, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-named/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-named/sizes.json index a840f670870..dd3e8777c3c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-named/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-named/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3312, - "brotli": 1644 + "min": 3311, + "brotli": 1646 }, "files": { "tags/card/index.marko": 116, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-patch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-patch/sizes.json index 1a8fa3bb0ff..b2e096e21e8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-patch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-rest-patch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2165, - "brotli": 1120 + "min": 2164, + "brotli": 1122 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/dom.bundle.debug.js index 0a37f9efd4a..1331be2f0d2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/dom.bundle.debug.js @@ -1,22 +1,17 @@ // tags/badge/index.marko const $template$1 = " "; const $walks$1 = "D l"; -const $setup__script = _script("__tests__/tags/badge/index.marko_0", ($scope) => { +const $setup$1 = () => {}; +const $global_brand__script = _script("__tests__/tags/badge/index.marko_0_$global_brand#1", ($scope) => { { const el = document.querySelector("main"); - el.dataset.log = (el.dataset.log || "") + "[" + $scope.$global.brand + "]"; + el.dataset.log = (el.dataset.log || "") + "[" + $scope.$global_brand + "]"; } }); -function $setup$1($scope) { - _text($scope["#text/0"], $scope.$global.brand); - $setup__script($scope); -} -var badge_default = /*@__PURE__*/ _template("__tests__/tags/badge/index.marko", $template$1, "D l", $setup$1); +var badge_default = /*@__PURE__*/ _template("__tests__/tags/badge/index.marko", $template$1, "D l"); // template.marko const $template = /*@__PURE__*/ ((_w0) => `
${_w0}
`)($template$1); const $walks = /*@__PURE__*/ ((_w0) => `D/${_w0}&l`)("D l"); -function $setup($scope) { - $setup$1($scope["#childScope/0"]); -} -var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); +const $setup = () => {}; +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/dom.bundle.js index 5bbc9704cbe..0bffa691ab1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/dom.bundle.js @@ -1,7 +1,7 @@ // tags/badge/index.marko -const $setup__script = _script("b0", ($scope) => { +_script("b0", ($scope) => { { const el = document.querySelector("main"); - el.dataset.log = (el.dataset.log || "") + "[" + $scope.$.brand + "]"; + el.dataset.log = (el.dataset.log || "") + "[" + $scope.b + "]"; } }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/html.bundle.debug.js index 3471add7ded..eafeaa108b1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/html.bundle.debug.js @@ -1,15 +1,15 @@ // tags/badge/index.marko const $template$1 = " "; const $walks$1 = "D l"; -_shells({ "__tests__/tags/badge/index.marko": "__tests__/tags/badge/index.marko !__tests__/tags/badge/index.marko_0;D ; " }); +_shells({ "__tests__/tags/badge/index.marko": "__tests__/tags/badge/index.marko !__tests__/tags/badge/index.marko_0_$global_brand#1;D ; " }); var badge_default = _template_persisted("__tests__/tags/badge/index.marko", (input) => { const $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); const $global$1 = $global(); _html(`${_patch_text($scope0_id, "#text/0", $global$1.brand)}`); - _script($scope0_id, "__tests__/tags/badge/index.marko_0"); - _patch_effect($scope0_id, "__tests__/tags/badge/index.marko_0", "! brand", 1); - $scope0_reason && _scope($scope0_id, {}, "__tests__/tags/badge/index.marko", 0); + _script($scope0_id, "__tests__/tags/badge/index.marko_0_$global_brand#1"); + _patch_effect($scope0_id, "__tests__/tags/badge/index.marko_0_$global_brand#1", "$global_brand"); + $scope0_reason ? _scope($scope0_id, { $global_brand: $global$1?.brand }, "__tests__/tags/badge/index.marko", 0, { $global_brand: ["$global.brand"] }) : _patch_write($scope0_id, "$global_brand", $global$1?.brand); }, 0, 1); // template.marko diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/html.bundle.js index 5b1a3b1883d..42e5eba9fbb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/html.bundle.js @@ -4,10 +4,11 @@ _shells({ b: "b !b0;D ; " }); var badge_default = _template_persisted("b", (input) => { const $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); - _html(`${_patch_text($scope0_id, "a", $global().brand)}`); + const $global$1 = $global(); + _html(`${_patch_text($scope0_id, "a", $global$1.brand)}`); _script($scope0_id, "b0"); - _patch_effect($scope0_id, "b0", "! brand", 1); - $scope0_reason && _scope($scope0_id, {}); + _patch_effect($scope0_id, "b0", "b"); + $scope0_reason ? _scope($scope0_id, { b: $global$1?.brand }) : _patch_write($scope0_id, "b", $global$1?.brand); }, 0, 1); // template.marko diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/patches.debug.js index 7b2cb5769fd..88a3910f3a0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/patches.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/patches.debug.js @@ -5,7 +5,8 @@ }, "PatchChild:#childScope/0": { "PatchText:#text/0": "Marko", - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/tags/badge/index.marko_0": "! brand" + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/tags/badge/index.marko_0_$global_brand#1": "$global_brand", + "PatchWrite:$global_brand": "Marko" } } @@ -16,6 +17,7 @@ }, "PatchChild:#childScope/0": { "PatchText:#text/0": "Runtime", - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/tags/badge/index.marko_0": "! brand" + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/tags/badge/index.marko_0_$global_brand#1": "$global_brand", + "PatchWrite:$global_brand": "Runtime" } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/patches.js index 522b971adec..afb3321adab 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/patches.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/patches.js @@ -5,7 +5,8 @@ }, ca: { ta: "Marko", - gb0: "! brand" + eb0: "b", + wb: "Marko" } } @@ -16,6 +17,7 @@ }, ca: { ta: "Runtime", - gb0: "! brand" + eb0: "b", + wb: "Runtime" } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/writes.debug.html index 2c207085320..500b2b5371b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/writes.debug.html @@ -5,8 +5,10 @@ brand: "Marko" }, { "#childScope/0": _(2) + }, { + $global_brand: "Marko" }], - "packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/tags/badge/index.marko_0 2" + "packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/tags/badge/index.marko_0_$global_brand#1 2" ]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/writes.html index ab7c826aa63..aebeb628fe9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/__snapshots__/writes.html @@ -5,6 +5,8 @@ brand: "Marko" }, { a: _(2) + }, { + b: "Marko" }], "b0 2"]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/sizes.json index 903e4893e47..8431ee7de6e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-script-global/sizes.json @@ -1,16 +1,16 @@ { "dom": { "template.marko.page.mjs": { - "min": 2799, - "brotli": 1400 + "min": 2792, + "brotli": 1398 } }, "html": { - "min": 371, - "brotli": 263 + "min": 383, + "brotli": 267 }, "patch": { - "min": 104, - "brotli": 68 + "min": 116, + "brotli": 88 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-server-required/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-server-required/sizes.json index 0bf27a0661c..4cbef3d7448 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-server-required/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-server-required/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8523, - "brotli": 3785 + "min": 8484, + "brotli": 3772 }, "files": { "tags/widget/index.marko": 210, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-slot-optional/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-slot-optional/sizes.json index f6b34085bc3..66ae6b5b043 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-slot-optional/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-slot-optional/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10261, - "brotli": 4394 + "min": 10216, + "brotli": 4380 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-spread-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-spread-state/sizes.json index cc2f465370b..f87f174bab0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-spread-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-spread-state/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7919, - "brotli": 3533 + "min": 7897, + "brotli": 3530 }, "files": { "tags/badge.marko": 158, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-spread/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-spread/sizes.json index 970457019b4..4f07c94a802 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-spread/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-spread/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7944, - "brotli": 3517 + "min": 7905, + "brotli": 3503 }, "files": { "tags/card.marko": 263, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-arg/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-arg/sizes.json index 2e4bca1d596..1724b3f81a7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-arg/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-arg/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3318, - "brotli": 1648 + "min": 3317, + "brotli": 1647 }, "files": { "tags/arg-badge/index.marko": 195, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-attr/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-attr/sizes.json index e765e366861..df35baea295 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-attr/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-attr/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3871, - "brotli": 1834 + "min": 3849, + "brotli": 1826 }, "files": { "tags/counter/index.marko": 336, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..200d5c298b0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,49 @@ +// tags/tabs/index.marko +const $template$1 = ""; +const $walks$1 = "b%c"; +const $setup$1 = () => {}; +const $if_content__input_tab_on = /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => _text($scope["#text/0"], $scope._.input_tab_on)); +const $if_content__setup$1 = $if_content__input_tab_on; +const $if$1 = /*@__PURE__*/ _if("#text/0", "
a
", "Db%", $if_content__setup$1, "b"); +const $input_tab = ($scope, input_tab) => { + $input_tab_on($scope, input_tab?.on); + $if$1($scope, input_tab ? 0 : 1); +}; +const $input = ($scope, input) => $input_tab($scope, input.tab); +const $input_tab_on = /*@__PURE__*/ _const("input_tab_on", $if_content__input_tab_on); +var tabs_default = /*@__PURE__*/ _template("__tests__/tags/tabs/index.marko", $template$1, "b%c", 0, $input); + +// template.marko +const $template = "
"; +const $walks = "D%b b l"; +const $if_content__on = /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => { + $input_tab($scope["#childScope/0"], attrTag({ ...{ on: $scope._.on } })); + const $tabs_input_spread = { tab: { on: $scope._.on } }; + $input_tab($scope["#childScope/2"], $tabs_input_spread.tab); +}); +const $if_content__setup = ($scope) => { + $if_content__on._($scope); + $if_content__o._($scope); +}; +const $if_content__o = /*@__PURE__*/ _if_closure("#text/0", 0, ($scope) => $input_tab($scope["#childScope/1"], attrTag({ ...$scope._.o }))); +const $if = /*@__PURE__*/ _if("#text/0", /*@__PURE__*/ ((_w0, _w1, _w2) => `${_w0}${_w1}${_w2}`)($template$1, $template$1, $template$1), /*@__PURE__*/ ((_w0, _w1, _w2) => `b/${_w0}&/${_w1}&/${_w2}&b`)("b%c", "b%c", "b%c"), $if_content__setup); +const $show = /*@__PURE__*/ _let("show/3", ($scope) => $if($scope, $scope.show ? 0 : 1)); +const $o = /*@__PURE__*/ _const("o", $if_content__o); +const $on = /*@__PURE__*/ _let("on/4", ($scope) => { + $o($scope, { on: $scope.on }); + $if_content__on($scope); +}); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => { + _on($scope["#button/1"], "click", function() { + $on($scope, !$scope.on); + }); + _on($scope["#button/2"], "click", function() { + $show($scope, !$scope.show); + }); +}); +function $setup($scope) { + $show($scope, true); + $on($scope, false); + $setup__script($scope); +} +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..a0a6c90f331 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/dom.bundle.js @@ -0,0 +1,36 @@ +// tags/tabs/index.marko +const $template = ""; +const $if_content__input_tab_on = /*@__PURE__*/ _if_closure(0, 0, ($scope) => _text($scope.a, $scope._.e)); +const $if$1 = /*@__PURE__*/ _if(0, "
a
", "Db%", $if_content__input_tab_on, "b"); +const $input_tab = ($scope, input_tab) => { + $input_tab_on($scope, input_tab?.on); + $if$1($scope, input_tab ? 0 : 1); +}; +const $input_tab_on = /*@__PURE__*/ _const(4, $if_content__input_tab_on); + +// template.marko +const $if_content__on = /*@__PURE__*/ _if_closure(0, 0, ($scope) => { + $input_tab($scope.a, attrTag({ on: $scope._.e })); + const $tabs_input_spread = { tab: { on: $scope._.e } }; + $input_tab($scope.c, $tabs_input_spread.tab); +}); +const $if_content__setup = ($scope) => { + $if_content__on._($scope); + $if_content__o._($scope); +}; +const $if_content__o = /*@__PURE__*/ _if_closure(0, 0, ($scope) => $input_tab($scope.b, attrTag({ ...$scope._.f }))); +const $if = /*@__PURE__*/ _if(0, /*@__PURE__*/ ((_w0, _w1, _w2) => `${_w0}${_w1}${_w2}`)($template, $template, $template), /*@__PURE__*/ ((_w0, _w1, _w2) => `b/${_w0}&/${_w1}&/${_w2}&b`)("b%c", "b%c", "b%c"), $if_content__setup); +const $show = /*@__PURE__*/ _let(3, ($scope) => $if($scope, $scope.d ? 0 : 1)); +const $o = /*@__PURE__*/ _const(5, $if_content__o); +const $on = /*@__PURE__*/ _let(4, ($scope) => { + $o($scope, { on: $scope.e }); + $if_content__on($scope); +}); +const $setup__script = _script("a0", ($scope) => { + _on($scope.b, "click", function() { + $on($scope, !$scope.e); + }); + _on($scope.c, "click", function() { + $show($scope, !$scope.d); + }); +}); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..b6fa161b324 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/html.bundle.debug.js @@ -0,0 +1,71 @@ +// tags/tabs/index.marko +const $template$1 = ""; +const $walks$1 = "b%c"; +_shells({ + "__tests__/tags/tabs/index.marko": "__tests__/tags/tabs/index.marko;b%;", + "__tests__/tags/tabs/index.marko_1*shell": "__tests__/tags/tabs/index.marko_1*shell;Db%;
a
", + "__tests__/tags/tabs/index.marko_2*shell": "__tests__/tags/tabs/index.marko_2*shell,b" +}); +var tabs_default = _template_persisted("__tests__/tags/tabs/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_tab = _source_guard($scope0_reason, 0); + const $scope0_id = _scope_id(); + _if(() => { + if (input.tab) { + const $scope1_id = _scope_id(); + _html(`
a ${_patch_text($scope1_id, "#text/0", input.tab.on, 2, $scope0_owned, 1)}
`); + _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/tags/tabs/index.marko", "1:2"); + return 0; + } else { + const $scope2_id = _scope_id(); + _html("b"); + $scope0_reason && _scope($scope2_id, {}, "__tests__/tags/tabs/index.marko", "4:2"); + return 1; + } + }, $scope0_id, "#text/0", 1, $sg__input_tab, $sg__input_tab, void 0, void 0, ["__tests__/tags/tabs/index.marko_1*shell", "__tests__/tags/tabs/index.marko_2*shell"]); + $scope0_reason && _scope($scope0_id, { input_tab_on: input.tab?.on }, "__tests__/tags/tabs/index.marko", 0, { input_tab_on: ["input.tab.on"] }); +}, 0, 0); + +// template.marko +const $template = "
"; +const $walks = "D%b b l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D%b b ;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + let on = false; + const o = { on }; + _html("
"); + if ($scope0_reason) _if(() => { + if (show) { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + tabs_default({ tab: attrTag({ ...{ on } }) }); + _set_serialize_reason(1); + const $childScope2 = _peek_scope_id(); + tabs_default({ tab: attrTag({ ...o }) }); + _set_serialize_reason(1); + const $childScope3 = _peek_scope_id(); + tabs_default({ tab: { on } }); + _scope($scope1_id, { + "#childScope/0": _existing_scope($childScope), + "#childScope/1": _existing_scope($childScope2), + "#childScope/2": _existing_scope($childScope3) + }, "__tests__/template.marko", "5:4"); + return 0; + } + }, $scope0_id, "#text/0"); + _html(`${_el_resume($scope0_id, "#button/1")}${_el_resume($scope0_id, "#button/2")}
`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason && _scope($scope0_id, { + show, + on, + o + }, "__tests__/template.marko", 0, { + show: "1:6", + on: "2:6", + o: "3:8" + }); + _resume_branch($scope0_id); +}, 1, () => [tabs_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..1e37a5ff8e2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/html.bundle.js @@ -0,0 +1,63 @@ +// tags/tabs/index.marko +_shells({ + b: "b;b%;", + b0: "b0;Db%;
a
", + b1: "b1,b" +}); +var tabs_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_tab = _source_guard($scope0_reason, 0); + const $scope0_id = _scope_id(); + _if(() => { + if (input.tab) { + const $scope1_id = _scope_id(); + _html(`
a ${_patch_text($scope1_id, "a", input.tab.on, 2, $scope0_owned, 1)}
`); + _scope($scope1_id, { _: _scope_with_id($scope0_id) }); + return 0; + } else { + const $scope2_id = _scope_id(); + _html("b"); + $scope0_reason && _scope($scope2_id, {}); + return 1; + } + }, $scope0_id, "a", 1, $sg__input_tab, $sg__input_tab, void 0, void 0, ["b0", "b1"]); + $scope0_reason && _scope($scope0_id, { e: input.tab?.on }); +}, 0, 0); + +// template.marko +_shells({ a: "a !a0;D%b b ;
" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let show = true; + let on = false; + const o = { on }; + _html("
"); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + tabs_default({ tab: attrTag({ on }) }); + _set_serialize_reason(1); + const $childScope2 = _peek_scope_id(); + tabs_default({ tab: attrTag({ ...o }) }); + _set_serialize_reason(1); + const $childScope3 = _peek_scope_id(); + tabs_default({ tab: { on } }); + _scope($scope1_id, { + a: _existing_scope($childScope), + b: _existing_scope($childScope2), + c: _existing_scope($childScope3) + }); + return 0; + } + }, $scope0_id, "a"); + _html(`${_el_resume($scope0_id, "b")}${_el_resume($scope0_id, "c")}
`); + _script($scope0_id, "a0"); + $scope0_reason && _scope($scope0_id, { + d: show, + e: on, + f: o + }); + _resume_branch($scope0_id); +}, 1, () => [tabs_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..d7bdae7b7c3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/patches.debug.js @@ -0,0 +1,7 @@ +// PATCH + + +// PATCH + + +// PATCH diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/patches.js new file mode 100644 index 00000000000..d7bdae7b7c3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/patches.js @@ -0,0 +1,7 @@ +// PATCH + + +// PATCH + + +// PATCH diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/render.debug.md new file mode 100644 index 00000000000..8deb361186b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/render.debug.md @@ -0,0 +1,120 @@ +# Render +```html +
+
+ a +
+
+ a +
+
+ a +
+ + +
+``` + +# Update +```js +document.querySelector("button.flip").click(); +``` +```html +
+
+ a true +
+
+ a true +
+
+ a true +
+ + +
+``` +## Change +``` +UPDATE: main > div:nth-of-type(1)::text@2 "" => "true" +UPDATE: main > div:nth-of-type(2)::text@2 "" => "true" +UPDATE: main > div:nth-of-type(3)::text@2 "" => "true" +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ + +
+``` +## Change +``` +REMOVE: main > div +REMOVE: main > div +REMOVE: main > div +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+
+ a true +
+
+ a true +
+
+ a true +
+ + +
+``` +## Change +``` +INSERT: main > div +INSERT: main > div:nth-of-type(2) + div +INSERT: main > div:nth-of-type(1) + div +UPDATE: main > div:nth-of-type(1)::text@2 "" => "true" +UPDATE: main > div:nth-of-type(3)::text@2 "" => "true" +UPDATE: main > div:nth-of-type(2)::text@2 "" => "true" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/render.md new file mode 100644 index 00000000000..8deb361186b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/render.md @@ -0,0 +1,120 @@ +# Render +```html +
+
+ a +
+
+ a +
+
+ a +
+ + +
+``` + +# Update +```js +document.querySelector("button.flip").click(); +``` +```html +
+
+ a true +
+
+ a true +
+
+ a true +
+ + +
+``` +## Change +``` +UPDATE: main > div:nth-of-type(1)::text@2 "" => "true" +UPDATE: main > div:nth-of-type(2)::text@2 "" => "true" +UPDATE: main > div:nth-of-type(3)::text@2 "" => "true" +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+ + +
+``` +## Change +``` +REMOVE: main > div +REMOVE: main > div +REMOVE: main > div +``` + +# Update +```js +document.querySelector("button.toggle").click(); +``` +```html +
+
+ a true +
+
+ a true +
+
+ a true +
+ + +
+``` +## Change +``` +INSERT: main > div +INSERT: main > div:nth-of-type(2) + div +INSERT: main > div:nth-of-type(1) + div +UPDATE: main > div:nth-of-type(1)::text@2 "" => "true" +UPDATE: main > div:nth-of-type(3)::text@2 "" => "true" +UPDATE: main > div:nth-of-type(2)::text@2 "" => "true" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..2bd74d51d56 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/writes.debug.html @@ -0,0 +1,37 @@ +
+
a
+
a
+
a
+ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/writes.html new file mode 100644 index 00000000000..af3200714fe --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/__snapshots__/writes.html @@ -0,0 +1,34 @@ +
+
a
+
a
+
a
+
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/sizes.json new file mode 100644 index 00000000000..d8cc48c236e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/sizes.json @@ -0,0 +1,22 @@ +{ + "dom": { + "template.marko.page.mjs": { + "total": { + "min": 8531, + "brotli": 3826 + }, + "files": { + "tags/tabs/index.marko": 487, + "template.marko": 1155 + } + } + }, + "html": { + "min": 672, + "brotli": 356 + }, + "patch": { + "min": 0, + "brotli": 1 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/tags/tabs/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/tags/tabs/index.marko new file mode 100644 index 00000000000..6134c3a74ec --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/tags/tabs/index.marko @@ -0,0 +1,6 @@ + +
a ${input.tab.on}
+ + + b + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/template.marko new file mode 100644 index 00000000000..42b34e21942 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/template.marko @@ -0,0 +1,16 @@ + + + +
+ + + <@tab ...{ on: on }/> + + + <@tab ...o/> + + + + f + t +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/test.ts new file mode 100644 index 00000000000..e415a13698f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-state-spread-feed/test.ts @@ -0,0 +1,15 @@ +import type { TestConfig } from "../../main.test"; + +const flip = (document: Document) => { + document.querySelector("button.flip")!.click(); +}; +const toggle = (document: Document) => { + document.querySelector("button.toggle")!.click(); +}; + +// State feeds riding spreads (attr-tag level, a `` of state, and +// tag level) resolve through the merged extra: all client-owned, admitted. +export const config: TestConfig = { + persisted: true, + steps: [{}, flip, {}, toggle, {}, toggle, {}], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-stateful/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-stateful/sizes.json index 0cb6e908846..c2e44f167c7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-stateful/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-stateful/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7207, - "brotli": 3242 + "min": 7185, + "brotli": 3231 }, "files": { "tags/counter/index.marko": 393, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-dom.debug.txt new file mode 100644 index 00000000000..24b7bd3c4a0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-dom.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: assigning a child's tag variable inside client-owned structure is not supported yet. + 5 |

${count}

+ 6 | r + 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-dom.txt new file mode 100644 index 00000000000..24b7bd3c4a0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-dom.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: assigning a child's tag variable inside client-owned structure is not supported yet. + 5 |

${count}

+ 6 | r + 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-html.debug.txt new file mode 100644 index 00000000000..24b7bd3c4a0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-html.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: assigning a child's tag variable inside client-owned structure is not supported yet. + 5 |

${count}

+ 6 | r + 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-html.txt new file mode 100644 index 00000000000..24b7bd3c4a0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/__snapshots__/error-compile-html.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: assigning a child's tag variable inside client-owned structure is not supported yet. + 5 |

${count}

+ 6 | r + 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/tags/counter-box/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/tags/counter-box/index.marko new file mode 100644 index 00000000000..6abc9dd7bcf --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/tags/counter-box/index.marko @@ -0,0 +1,3 @@ + +box ${count} + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/template.marko new file mode 100644 index 00000000000..b1d8635b647 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/template.marko @@ -0,0 +1,9 @@ + +
+ + +

${count}

+ r + + t +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/test.ts new file mode 100644 index 00000000000..af97003d4ca --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-assigned/test.ts @@ -0,0 +1,8 @@ +import type { TestConfig } from "../../main.test"; + +// The `_var_change` write-back for an assigned tag variable is not wired +// for a pure client instance yet: fail closed at the call site. +export const config: TestConfig = { + error_compiler: true, + persisted: true, +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-dom.debug.txt new file mode 100644 index 00000000000..561184cc615 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-dom.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: assigning a child's tag variable inside client-owned structure is not supported yet. + 5 |

${value}

+ 6 | r + 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-dom.txt new file mode 100644 index 00000000000..561184cc615 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-dom.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: assigning a child's tag variable inside client-owned structure is not supported yet. + 5 |

${value}

+ 6 | r + 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-html.debug.txt new file mode 100644 index 00000000000..561184cc615 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-html.debug.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: assigning a child's tag variable inside client-owned structure is not supported yet. + 5 |

${value}

+ 6 | r + 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-html.txt new file mode 100644 index 00000000000..561184cc615 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/__snapshots__/error-compile-html.txt @@ -0,0 +1,9 @@ + + at packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/template.marko:4:5 + 2 |
+ 3 | + > 4 | + | ^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: assigning a child's tag variable inside client-owned structure is not supported yet. + 5 |

${value}

+ 6 | r + 7 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/tags/counter/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/tags/counter/index.marko new file mode 100644 index 00000000000..cd8801f10db --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/tags/counter/index.marko @@ -0,0 +1,3 @@ + +box ${count} + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/template.marko new file mode 100644 index 00000000000..e819044b08a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/template.marko @@ -0,0 +1,9 @@ + +
+ + +

${value}

+ r + + t +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/test.ts new file mode 100644 index 00000000000..55c290170a3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-tag-var-destructured/test.ts @@ -0,0 +1,8 @@ +import type { TestConfig } from "../../main.test"; + +// A DESTRUCTURED tag variable hangs its bindings on the pattern's +// identifiers: an assignment to any of them still fails closed. +export const config: TestConfig = { + error_compiler: true, + persisted: true, +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-try/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-try/sizes.json index 7b9930b6731..c851239a76f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-try/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-try/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8448, - "brotli": 3793 + "min": 8429, + "brotli": 3781 }, "files": { "tags/widget/index.marko": 291, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-two-fills/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-two-fills/sizes.json index 62e694c2ff6..b1cf2f5e50e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-two-fills/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-two-fills/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7533, - "brotli": 3378 + "min": 7511, + "brotli": 3376 }, "files": { "tags/card/index.marko": 259, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-unfed-structural/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-unfed-structural/sizes.json index 079cdb8578d..f82fe5db98c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-unfed-structural/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-unfed-structural/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8794, - "brotli": 3902 + "min": 8755, + "brotli": 3886 }, "files": { "tags/badge/index.marko": 310, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-var/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-var/sizes.json index eb6f23bc865..272412a40a6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-var/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-var/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 4279, - "brotli": 2028 + "min": 4257, + "brotli": 2019 }, "files": { "tags/price-card.marko": 416, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-whole-member/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-whole-member/sizes.json index f9c2bf0de3c..219b1a7673c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-child-whole-member/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-child-whole-member/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 4147, - "brotli": 1992 + "min": 4125, + "brotli": 1979 }, "files": { "tags/duo/index.marko": 236, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-class-attribute/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-class-attribute/sizes.json index baef2e30f22..cb9c8e6006c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-class-attribute/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-class-attribute/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2251, - "brotli": 1145 + "min": 2234, + "brotli": 1135 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-class-intersection/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-class-intersection/sizes.json index e9d8a643570..161c496afa4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-class-intersection/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-class-intersection/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8468, - "brotli": 3729 + "min": 8429, + "brotli": 3710 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-client-intersections/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-client-intersections/__snapshots__/dom.bundle.debug.js index 622c51f0526..fc8e339140e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-client-intersections/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-client-intersections/__snapshots__/dom.bundle.debug.js @@ -47,8 +47,6 @@ const $template = /*@__PURE__*/ ((_w0, _w1, _w2) => `

${_ const $walks = /*@__PURE__*/ ((_w0, _w1, _w2) => `E l D l/${_w0}&/${_w1}&/${_w2}&l`)($walks$3, $walks$2, "D l"); const $input_title = ($scope, input_title) => _text($scope["#text/0"], input_title); function $setup($scope) { - _attr($scope["#p/1"], "title", $scope.$global.locale); - _text($scope["#text/2"], $scope.$global.brand); $setup$3($scope["#childScope/3"]); $setup$2($scope["#childScope/4"]); $input_text($scope["#childScope/4"], "Sale"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-client-intersections/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-client-intersections/sizes.json index 58eb44a36dd..a2005d6df32 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-client-intersections/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-client-intersections/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 4450, - "brotli": 2053 + "min": 4428, + "brotli": 2041 }, "files": { "tags/price-card.marko": 416, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-alias-render/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-alias-render/sizes.json index ef619fc473d..019439a760b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-alias-render/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-alias-render/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9695, - "brotli": 4144 + "min": 9650, + "brotli": 4125 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tag-client-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tag-client-owned/sizes.json index 2d910e6bee2..35224948873 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tag-client-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tag-client-owned/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 10805, - "brotli": 4588 + "min": 10783, + "brotli": 4584 }, "files": { "tags/card/index.marko": 602, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tags-construct/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tags-construct/sizes.json index e049f7ec017..5ab184b800a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tags-construct/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tags-construct/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4369 + "min": 10177, + "brotli": 4356 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tags/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tags/sizes.json index 1f7a2863add..763990c1c09 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tags/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-attr-tags/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9695, - "brotli": 4144 + "min": 9650, + "brotli": 4125 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/__snapshots__/html.bundle.debug.js index b4748ce0400..c0efe6cee78 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/__snapshots__/html.bundle.debug.js @@ -44,7 +44,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = "ClosureSignalIndex:input_value": 1 }, "__tests__/template.marko", "4:8")); _resume_branch($scope3_id); - }, void 0, "__tests__/template.marko_2_#text#0/await"); + }, 1, "__tests__/template.marko_2_#text#0/await"); $scope0_reason && _subscribe($si__input_value && $input_value__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "3:6")); _resume_branch($scope2_id); }, $scope1_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/__snapshots__/html.bundle.js index 687d44d07a0..fdb17c8b2f8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/__snapshots__/html.bundle.js @@ -41,7 +41,7 @@ var template_default = _template_persisted("a", (input) => { Cf: 1 })); _resume_branch($scope3_id); - }, void 0, "a1"); + }, 1, "a1"); $scope0_reason && _subscribe($si__input_value && $input_value__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) })); _resume_branch($scope2_id); }, $scope1_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/sizes.json index 975b87873b2..fa9b48a287a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-await/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 12540, - "brotli": 5206 + "min": 12477, + "brotli": 5187 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-body-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-body-branch/sizes.json index cd561f0b187..02ba7452b4f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-body-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-body-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4361 + "min": 10177, + "brotli": 4340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-branch-nested/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-branch-nested/sizes.json index a3b11976617..07372411302 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-branch-nested/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-branch-nested/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4361 + "min": 10177, + "brotli": 4340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-branch-scriptless/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-branch-scriptless/sizes.json index 83c2543f39c..5d0bdf04f15 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-branch-scriptless/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-branch-scriptless/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4361 + "min": 10177, + "brotli": 4340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-branch-static/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-branch-static/sizes.json index 5c170188267..df5e6214f67 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-branch-static/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-branch-static/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10273, - "brotli": 4388 + "min": 10229, + "brotli": 4368 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-branch/sizes.json index 0177ace4c40..5f130d8e798 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4357 + "min": 10177, + "brotli": 4340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-client-owned-const/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-client-owned-const/sizes.json index f3a7276552a..281286f17aa 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-client-owned-const/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-client-owned-const/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 10839, - "brotli": 4598 + "min": 10817, + "brotli": 4592 }, "files": { "tags/card/index.marko": 604, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-client-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-client-owned/sizes.json index fd3ba51bbc3..f64487ac0f2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-client-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-client-owned/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 10839, - "brotli": 4597 + "min": 10817, + "brotli": 4591 }, "files": { "tags/card/index.marko": 604, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-loop/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-loop/sizes.json index 1d89fbbb802..397017d8224 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-loop/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-child-loop/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11544, - "brotli": 4976 + "min": 11500, + "brotli": 4954 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-client-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-client-owned/sizes.json index c7727b04256..4c7772a11ee 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-client-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-client-owned/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 11875, - "brotli": 5022 + "min": 11810, + "brotli": 5003 }, "files": { "tags/card/index.marko": 268, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/dom.bundle.debug.js index 95eb467161b..55a90994549 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/dom.bundle.debug.js @@ -15,9 +15,10 @@ const $setup = () => {}; const $card_content__input_prefix = /*@__PURE__*/ _closure_get("input_prefix", ($scope) => _text($scope["#text/1"], $scope._._.input_prefix), ($scope) => $scope._._); const $card_content__setup = ($scope) => { $card_content__input_prefix($scope); + $card_content__$global_brand($scope); $card_content__item($scope); - _text($scope["#text/0"], $scope.$global.brand); }; +const $card_content__$global_brand = /*@__PURE__*/ _closure_get("$global_brand", ($scope) => _text($scope["#text/0"], $scope._._.$global_brand), ($scope) => $scope._._); const $card_content__item = /*@__PURE__*/ _closure_get("item", ($scope) => _text($scope["#text/2"], $scope._.item)); const $card_content = /*@__PURE__*/ _content("__tests__/template.marko_2*content", "::", "D%c%c%", $card_content__setup); const $for_content__setup = ($scope) => $input_content_direct($scope["#childScope/0"], $card_content($scope)); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/html.bundle.debug.js index 640627a74f2..062230e3af8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/html.bundle.debug.js @@ -24,6 +24,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_items = _source_guard($scope0_reason, 1); const $scope0_id = _scope_id(); const $input_prefix__closures = new Set(); + const $global_brand__closures = new Set(); const $global$1 = $global(); _html("
"); _for_of(input.items, (item) => { @@ -36,7 +37,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope2_reason = _persisted_reason(); const $scope2_id = _scope_id(); _html(`${_patch_text($scope2_id, "#text/0", $global$1.brand)}:${_patch_text($scope2_id, "#text/1", input.prefix, 2, $scope0_owned, 2)}:${_patch_text($scope2_id, "#text/2", item, 2, $scope0_owned, 1)}`); - _subscribe($scope0_reason && $for_content__item__closures, _subscribe(_source_if($scope0_reason, 2) && $input_prefix__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "3:6"))); + _subscribe($scope0_reason && $for_content__item__closures, _subscribe($scope0_reason && $global_brand__closures, _subscribe(_source_if($scope0_reason, 2) && $input_prefix__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "3:6")))); _resume_branch($scope2_id); }, $scope1_id) }); _scope($scope1_id, { @@ -48,6 +49,11 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = _html(`
${_el_resume($scope0_id, "#main/0", $sg__input_items)}`); $scope0_reason && _scope($scope0_id, { input_prefix: input.prefix, - "ClosureScopes:input_prefix": $input_prefix__closures - }, "__tests__/template.marko", 0, { input_prefix: ["input.prefix"] }); + $global_brand: $global$1?.brand, + "ClosureScopes:input_prefix": $input_prefix__closures, + "ClosureScopes:$global_brand": $global_brand__closures + }, "__tests__/template.marko", 0, { + input_prefix: ["input.prefix"], + $global_brand: ["$global.brand"] + }); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/html.bundle.js index bb6773b529d..809662cd265 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/html.bundle.js @@ -21,6 +21,7 @@ var template_default = _template_persisted("a", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_items = _source_guard($scope0_reason, 1); const $scope0_id = _scope_id(); const $input_prefix__closures = /* @__PURE__ */ new Set(); + const $global_brand__closures = /* @__PURE__ */ new Set(); const $global$1 = $global(); _html("
"); _for_of(input.items, (item) => { @@ -33,7 +34,7 @@ var template_default = _template_persisted("a", (input) => { _persisted_reason(); const $scope2_id = _scope_id(); _html(`${_patch_text($scope2_id, "a", $global$1.brand)}:${_patch_text($scope2_id, "b", input.prefix, 2, $scope0_owned, 2)}:${_patch_text($scope2_id, "c", item, 2, $scope0_owned, 1)}`); - _subscribe($scope0_reason && $for_content__item__closures, _subscribe(_source_if($scope0_reason, 2) && $input_prefix__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }))); + _subscribe($scope0_reason && $for_content__item__closures, _subscribe($scope0_reason && $global_brand__closures, _subscribe(_source_if($scope0_reason, 2) && $input_prefix__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) })))); _resume_branch($scope2_id); }, $scope1_id) }); _scope($scope1_id, { @@ -45,6 +46,8 @@ var template_default = _template_persisted("a", (input) => { _html(`
${_el_resume($scope0_id, "a", $sg__input_items)}`); $scope0_reason && _scope($scope0_id, { e: input.prefix, - f: $input_prefix__closures + f: $global$1?.brand, + g: $input_prefix__closures, + h: $global_brand__closures }); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/writes.debug.html index 4c2d461f2f9..60cf4b85f20 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/writes.debug.html @@ -11,7 +11,9 @@ brand: "Acme" }, { input_prefix: "p", - "ClosureScopes:input_prefix": new Set([_(4), _(7)]) + $global_brand: "Acme", + "ClosureScopes:input_prefix": new Set([_(4), _(7)]), + "ClosureScopes:$global_brand": new Set([_(4), _(7)]) }, { _: _(1), "ClosureScopes:item": new Set([_(4)]), diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/writes.html index 2aa096f6ca9..18327b4ac9d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/__snapshots__/writes.html @@ -10,7 +10,9 @@ brand: "Acme" }, { e: "p", - f: new Set([_(4), _(7)]) + f: "Acme", + g: new Set([_(4), _(7)]), + h: new Set([_(4), _(7)]) }, { _: _(1), d: new Set([_(4)]), diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/sizes.json index 6f09b2dabbc..268dbcf161f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-closure-mix/sizes.json @@ -1,13 +1,13 @@ { "dom": { "template.marko.page.mjs": { - "min": 11544, - "brotli": 4984 + "min": 11500, + "brotli": 4961 } }, "html": { - "min": 721, - "brotli": 367 + "min": 753, + "brotli": 373 }, "patch": { "min": 423, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-dynamic-body-construct/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-dynamic-body-construct/sizes.json index d6fd8c7a724..f4f1445732b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-dynamic-body-construct/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-dynamic-body-construct/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4361 + "min": 10177, + "brotli": 4340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-dynamic-body/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-dynamic-body/sizes.json index 57afe5c3605..6d7845fab22 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-dynamic-body/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-dynamic-body/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4361 + "min": 10177, + "brotli": 4340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-for-intersect/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-for-intersect/sizes.json index e61f7e43aea..e5092eb3401 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-for-intersect/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-for-intersect/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 13131, - "brotli": 5633 + "min": 13066, + "brotli": 5626 }, "files": { "tags/box/index.marko": 159, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/dom.bundle.debug.js index 06342904a55..a2aa3c6c78b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/dom.bundle.debug.js @@ -15,13 +15,15 @@ var card_default = /*@__PURE__*/ _template("__tests__/tags/card/index.marko", $t // template.marko const $template = /*@__PURE__*/ ((_w0) => `
${_w0}
`)($template$1); const $walks = /*@__PURE__*/ ((_w0) => `D/${_w0}&%l`)($walks$1); -const $card_content2__setup = ($scope) => _text($scope["#text/0"], $scope.$global.brand); +const $card_content2__$global_brand = /*@__PURE__*/ _closure_get("$global_brand", ($scope) => _text($scope["#text/0"], $scope._._.$global_brand), ($scope) => $scope._._); +const $card_content2__setup = $card_content2__$global_brand; const $card_content2 = /*@__PURE__*/ _content("__tests__/template.marko_3*content", " ", "D ", $card_content2__setup); const $if_content__setup = ($scope) => { $input_content_direct($scope["#childScope/0"], $card_content2($scope)); $input_title$1($scope["#childScope/0"], "x"); }; -const $card_content__setup = ($scope) => _text($scope["#text/0"], $scope.$global.brand); +const $card_content__$global_brand = /*@__PURE__*/ _closure_get("$global_brand", ($scope) => _text($scope["#text/0"], $scope._.$global_brand)); +const $card_content__setup = $card_content__$global_brand; const $card_content = /*@__PURE__*/ _content("__tests__/template.marko_1*content", " ", "D ", $card_content__setup); function $setup($scope) { $input_content_direct($scope["#childScope/0"], $card_content($scope)); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/html.bundle.debug.js index fce27f3d8f8..412195d4187 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/html.bundle.debug.js @@ -24,6 +24,7 @@ _shells({ var template_default = _template_persisted("__tests__/template.marko", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_show = _source_guard($scope0_reason, 1); const $scope0_id = _scope_id(); + const $global_brand__closures = new Set(); const $global$1 = $global(); _html("
"); _set_serialize_reason({ 0: _mask_group($scope0_owned, 0) }); @@ -35,7 +36,8 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope1_reason = _persisted_reason(); const $scope1_id = _scope_id(); _html(`${_patch_text($scope1_id, "#text/0", $global$1.brand)}`); - _scope($scope1_id, {}, "__tests__/template.marko", "2:4"); + _subscribe($scope0_reason && $global_brand__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "2:4")); + _resume_branch($scope1_id); }, $scope0_id) }); _if(() => { @@ -50,13 +52,24 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope3_reason = _persisted_reason(); const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "#text/0", $global$1.brand)}`); - _scope($scope3_id, {}, "__tests__/template.marko", "6:6"); + _subscribe($scope0_reason && $global_brand__closures, _scope($scope3_id, { + _: _scope_with_id($scope2_id), + "ClosureSignalIndex:$global_brand": 1 + }, "__tests__/template.marko", "6:6")); + _resume_branch($scope3_id); }, $scope2_id) }); - _scope($scope2_id, { "#childScope/0": _existing_scope($childScope2) }, "__tests__/template.marko", "5:4"); + _scope($scope2_id, { + _: _scope_with_id($scope0_id), + "#childScope/0": _existing_scope($childScope2) + }, "__tests__/template.marko", "5:4"); return 0; } }, $scope0_id, "#text/1", 1, $sg__input_show, $sg__input_show, void 0, void 0, ["__tests__/template.marko_2*shell"]); _html("
"); - $scope0_reason && _scope($scope0_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", 0); + $scope0_reason && _scope($scope0_id, { + $global_brand: $global$1?.brand, + "ClosureScopes:$global_brand": $global_brand__closures, + "#childScope/0": _existing_scope($childScope) + }, "__tests__/template.marko", 0, { $global_brand: ["$global.brand"] }); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/html.bundle.js index ba83f8ea086..fd717f9fb75 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/html.bundle.js @@ -22,6 +22,7 @@ _shells({ var template_default = _template_persisted("a", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_show = _source_guard($scope0_reason, 1); const $scope0_id = _scope_id(); + const $global_brand__closures = /* @__PURE__ */ new Set(); const $global$1 = $global(); _html("
"); _set_serialize_reason({ 0: _mask_group($scope0_owned, 0) }); @@ -33,7 +34,8 @@ var template_default = _template_persisted("a", (input) => { _persisted_reason(); const $scope1_id = _scope_id(); _html(`${_patch_text($scope1_id, "a", $global$1.brand)}`); - _scope($scope1_id, {}); + _subscribe($scope0_reason && $global_brand__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); + _resume_branch($scope1_id); }, $scope0_id) }); _if(() => { @@ -48,13 +50,24 @@ var template_default = _template_persisted("a", (input) => { _persisted_reason(); const $scope3_id = _scope_id(); _html(`${_patch_text($scope3_id, "a", $global$1.brand)}`); - _scope($scope3_id, {}); + _subscribe($scope0_reason && $global_brand__closures, _scope($scope3_id, { + _: _scope_with_id($scope2_id), + Ch: 1 + })); + _resume_branch($scope3_id); }, $scope2_id) }); - _scope($scope2_id, { a: _existing_scope($childScope2) }); + _scope($scope2_id, { + _: _scope_with_id($scope0_id), + a: _existing_scope($childScope2) + }); return 0; } }, $scope0_id, "b", 1, $sg__input_show, $sg__input_show, void 0, void 0, ["a2"]); _html("
"); - $scope0_reason && _scope($scope0_id, { a: _existing_scope($childScope) }); + $scope0_reason && _scope($scope0_id, { + g: $global$1?.brand, + h: $global_brand__closures, + a: _existing_scope($childScope) + }); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/writes.debug.html index de7b4f9bb6f..a36dcbab417 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/writes.debug.html @@ -9,9 +9,13 @@

a

M._.r = [_ => [0, { brand: "Acme" }, { + $global_brand: "Acme", + "ClosureScopes:$global_brand": new Set([_(3)]), "#childScope/0": _(2) }, { "ConditionalRenderer:#text/1": "packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/template.marko_1*content 1" + }, { + _: _(1) }]]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/writes.html index 7a81fa3bed2..923fad9bed3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/__snapshots__/writes.html @@ -8,9 +8,13 @@

a

Acme M._.r = [_ => [0, { brand: "Acme" }, { + g: "Acme", + h: new Set([_(3)]), a: _(2) }, { Db: "a1 1" + }, { + _: _(1) }]]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/sizes.json index 45f065ef999..d690ec2d2f1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global-scriptless/sizes.json @@ -1,13 +1,13 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4361 + "min": 10177, + "brotli": 4340 } }, "html": { - "min": 450, - "brotli": 296 + "min": 486, + "brotli": 317 }, "patch": { "min": 477, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/dom.bundle.debug.js index e014ba7eb38..87d590fd603 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/dom.bundle.debug.js @@ -15,7 +15,8 @@ var widget_default = /*@__PURE__*/ _template("__tests__/tags/widget/index.marko" // template.marko const $template = /*@__PURE__*/ ((_w0) => `
${_w0}
`)($template$1); const $walks = /*@__PURE__*/ ((_w0) => `D/${_w0}& l`)($walks$1); -const $widget_content__setup = ($scope) => _text($scope["#text/0"], $scope.$global.brand); +const $widget_content__$global_brand = /*@__PURE__*/ _closure_get("$global_brand", ($scope) => _text($scope["#text/0"], $scope._.$global_brand)); +const $widget_content__setup = $widget_content__$global_brand; const $widget_content = /*@__PURE__*/ _content("__tests__/template.marko_1*content", "
", "D ", $widget_content__setup); const $count = /*@__PURE__*/ _let("count/2", ($scope) => $input_value($scope["#childScope/0"], $scope.count)); const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/html.bundle.debug.js index 646f9f80bee..540eeea7296 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/html.bundle.debug.js @@ -22,6 +22,7 @@ _shells({ var template_default = _template_persisted("__tests__/template.marko", (input) => { const $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); + const $global_brand__closures = new Set(); const $global$1 = $global(); let count = 0; _html("
"); @@ -34,13 +35,15 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope1_reason = _persisted_reason(); const $scope1_id = _scope_id(); _html(`
${_patch_text($scope1_id, "#text/0", $global$1.brand)}
`); - _scope($scope1_id, {}, "__tests__/template.marko", "3:4"); + _subscribe($scope0_reason && $global_brand__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4")); + _resume_branch($scope1_id); }, $scope0_id) }); _html(`${_el_resume($scope0_id, "#button/1")}
`); _script($scope0_id, "__tests__/template.marko_0"); $scope0_reason && _scope($scope0_id, { count, + "ClosureScopes:$global_brand": $global_brand__closures, "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", 0, { count: "1:6" }); _resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/html.bundle.js index 58b0ed1e0ef..bbe1739af09 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/html.bundle.js @@ -20,6 +20,7 @@ _shells({ var template_default = _template_persisted("a", (input) => { const $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); + const $global_brand__closures = /* @__PURE__ */ new Set(); const $global$1 = $global(); let count = 0; _html("
"); @@ -32,13 +33,15 @@ var template_default = _template_persisted("a", (input) => { _persisted_reason(); const $scope1_id = _scope_id(); _html(`
${_patch_text($scope1_id, "a", $global$1.brand)}
`); - _scope($scope1_id, {}); + _subscribe($scope0_reason && $global_brand__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); + _resume_branch($scope1_id); }, $scope0_id) }); _html(`${_el_resume($scope0_id, "b")}
`); _script($scope0_id, "a1"); $scope0_reason && _scope($scope0_id, { c: count, + e: $global_brand__closures, a: _existing_scope($childScope) }); _resume_branch($scope0_id); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/writes.debug.html index 852037ccbfb..2ea412ffc5d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/writes.debug.html @@ -9,9 +9,12 @@ brand: "Acme" }, { count: 0, + "ClosureScopes:$global_brand": new Set([_(3)]), "#childScope/0": _(2) }, { "ConditionalRenderer:#text/1": "packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/template.marko_1*content 1" + }, { + _: _(1) }], "packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/template.marko_0 1" ]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/writes.html index bc719e5b86c..b3fc0034316 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/__snapshots__/writes.html @@ -9,9 +9,12 @@ brand: "Acme" }, { c: 0, + e: new Set([_(3)]), a: _(2) }, { Db: "a0 1" + }, { + _: _(1) }], "a1 1"]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/sizes.json index 087eb16e27f..82de4984045 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-global/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 10281, - "brotli": 4403 + "min": 10236, + "brotli": 4390 }, "files": { "tags/widget/index.marko": 123, @@ -12,8 +12,8 @@ } }, "html": { - "min": 485, - "brotli": 311 + "min": 512, + "brotli": 331 }, "patch": { "min": 38, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-hole/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-hole/sizes.json index b549b0be9ba..27a8fc599ad 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-hole/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-hole/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9695, - "brotli": 4144 + "min": 9650, + "brotli": 4125 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-inner-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-inner-branch/sizes.json index e50a725985f..c4e72b44c6c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-inner-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-inner-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4361 + "min": 10177, + "brotli": 4340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-intersect-mixed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-intersect-mixed/sizes.json index a03eccadba0..35195b36b57 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-intersect-mixed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-intersect-mixed/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 12002, - "brotli": 5090 + "min": 11937, + "brotli": 5071 }, "files": { "tags/box/index.marko": 159, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-intersect/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-intersect/sizes.json index 726e45f55a0..24fe14297d9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-intersect/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-intersect/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 11787, - "brotli": 5007 + "min": 11722, + "brotli": 4984 }, "files": { "tags/box/index.marko": 159, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-loop/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-loop/sizes.json index 285b70e6707..a521fae6837 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-loop/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-loop/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11544, - "brotli": 4984 + "min": 11500, + "brotli": 4961 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-child-client-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-child-client-owned/sizes.json index fbb8d79bc1e..3ed4d963d50 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-child-client-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-child-client-owned/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 10839, - "brotli": 4589 + "min": 10817, + "brotli": 4584 }, "files": { "tags/grand/index.marko": 605, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-client-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-client-owned/sizes.json index 8e4cb181500..08a8d865ca5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-client-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-client-owned/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 11788, - "brotli": 5001 + "min": 11723, + "brotli": 4984 }, "files": { "tags/grand/index.marko": 173, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-renderer/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-renderer/sizes.json index 8ad4f3bbe65..f22fa496b23 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-renderer/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-renderer/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10221, - "brotli": 4361 + "min": 10177, + "brotli": 4340 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-stateful-consumer/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-stateful-consumer/sizes.json index 0ff08ccef10..f7faf3a1e7f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-stateful-consumer/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-stateful-consumer/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 11762, - "brotli": 4963 + "min": 11697, + "brotli": 4942 }, "files": { "tags/grand/index.marko": 169, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-swap/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-swap/sizes.json index 90d8796f2b5..fc235f6908f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-swap/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested-swap/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10753, - "brotli": 4593 + "min": 10709, + "brotli": 4587 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested/sizes.json index ccecf5f8693..653df14566f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-nested/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9695, - "brotli": 4144 + "min": 9650, + "brotli": 4125 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/html.bundle.debug.js index 1c732e8cb94..af00ba57f3d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/html.bundle.debug.js @@ -18,7 +18,7 @@ var card_default = _template_persisted("__tests__/tags/card/index.marko", (input _await($scope2_id, "#text/0", input.promise, () => { const $scope3_id = _scope_id(); _html("done"); - }, 0, "__tests__/tags/card/index.marko_2_#text#0/await"); + }, 1, "__tests__/tags/card/index.marko_2_#text#0/await"); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) }, "__tests__/tags/card/index.marko", "2:4")); _resume_branch($scope2_id); }, $scope0_id), { placeholder: attrTag({ content: _content_elide("__tests__/tags/card/index.marko_1*content", () => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/html.bundle.js index 88dc9aef04b..48d16806a3a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/html.bundle.js @@ -17,7 +17,7 @@ var card_default = _template_persisted("b", (input) => { _await($scope2_id, "a", input.promise, () => { _scope_id(); _html("done"); - }, 0, "b1"); + }, 1, "b1"); $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) })); _resume_branch($scope2_id); }, $scope0_id), { placeholder: attrTag({ content: _content_elide("b3", () => { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/patches.debug.js index 169236898da..6ae8fc90e1e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/patches.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/patches.debug.js @@ -2,7 +2,8 @@ [`packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/tags/card/index.marko_2_#text#0/await,done`, { "PatchChild:#childScope/0": { "PatchChild:BranchScopes:#text/0": { - "PatchPending:#text/0": "packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/tags/card/index.marko_2_#text#0/await" + "PatchPending:#text/0": "packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/tags/card/index.marko_2_#text#0/await", + "PatchChild:BranchScopes:#text/0": {} } } }] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/patches.js index f41a3dba879..23a6e681b89 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/patches.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/patches.js @@ -2,7 +2,8 @@ [`b1,done`, { ca: { cAa: { - pa: "b1" + pa: "b1", + cAa: {} } } }] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/render.debug.md index c70a301b919..768944dc60b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/render.debug.md +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/render.debug.md @@ -10,5 +10,3 @@ ``` # Update `{"promise":{},"note":"y"}` - -## Patch rejected (navigate) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/render.md index c70a301b919..768944dc60b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/render.md +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/render.md @@ -10,5 +10,3 @@ ``` # Update `{"promise":{},"note":"y"}` - -## Patch rejected (navigate) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/writes.debug.html index 34209235a50..fa0a6c0c804 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-content-placeholder-scriptless/__snapshots__/writes.debug.html @@ -1,5 +1,7 @@
-
done
+
+ done +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/__snapshots__/writes.html new file mode 100644 index 00000000000..c6bfbc2a380 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/__snapshots__/writes.html @@ -0,0 +1,13 @@ +
+

+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/sizes.json new file mode 100644 index 00000000000..202e5178fe3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 5231, + "brotli": 2358 + } + }, + "html": { + "min": 496, + "brotli": 302 + }, + "patch": { + "min": 133, + "brotli": 71 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/template.marko new file mode 100644 index 00000000000..7d15934bae9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/template.marko @@ -0,0 +1,6 @@ + +
+ + +
+

${last}

diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/test.ts new file mode 100644 index 00000000000..bd20cb29a40 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value-multiple/test.ts @@ -0,0 +1,25 @@ +import type { TestConfig } from "../../main.test"; + +const toggleB = (document: Document) => { + document.querySelectorAll("input")[1]!.click(); +}; + +const probe = (document: Document) => { + const [a, b] = document.querySelectorAll("input"); + document.querySelector("p")!.textContent = `a:${a!.checked} b:${b!.checked}`; +}; + +// An array `checkedValue` (checkbox group): the entry re-ships the array by +// value each frame and each box compares its own `value` against it. +export const config: TestConfig = { + persisted: true, + steps: [ + { picked: ["a"] }, + toggleB, + probe, + { picked: ["a", "b"] }, + probe, + { picked: [] }, + probe, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..0dc7f317610 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,26 @@ +// template.marko +const $template = "

"; +const $walks = "D b lD l"; +const $note = /*@__PURE__*/ _let("note/6", ($scope) => _text($scope["#text/2"], $scope.note)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => { + _attr_input_checkedValue_script($scope, "#input/0"); + _attr_input_checkedValue_script($scope, "#input/1"); +}); +function $setup($scope) { + $note($scope, ""); + $setup__script($scope); +} +const $input_picked = /*@__PURE__*/ _const("input_picked", ($scope) => { + _attr_input_checkedValue($scope, "#input/0", $scope.input_picked, $checkedValueChange($scope), "a"); + _attr_input_checkedValue($scope, "#input/1", $scope.input_picked, $checkedValueChange2($scope), "b"); +}); +const $input = ($scope, input) => $input_picked($scope, input.picked); +const $checkedValueChange2 = ($scope) => function(next) { + $note($scope, next); +}; +const $checkedValueChange = ($scope) => function(next) { + $note($scope, next); +}; +_resume("__tests__/template.marko_0/checkedValueChange2", $checkedValueChange2); +_resume("__tests__/template.marko_0/checkedValueChange", $checkedValueChange); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..ba01f50c9da --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/dom.bundle.js @@ -0,0 +1,14 @@ +// template.marko +const $note = /*@__PURE__*/ _let(6, ($scope) => _text($scope.c, $scope.g)); +const $setup__script = _script("a2", ($scope) => { + _attr_input_checkedValue_script($scope, "a"); + _attr_input_checkedValue_script($scope, "b"); +}); +const $checkedValueChange2 = ($scope) => function(next) { + $note($scope, next); +}; +const $checkedValueChange = ($scope) => function(next) { + $note($scope, next); +}; +_resume("a1", $checkedValueChange2); +_resume("a0", $checkedValueChange); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index 5f37726fe1b..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,5 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko:1:1 - > 1 | - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `checkedValue` groups are not patchable. - 2 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-dom.txt deleted file mode 100644 index 5f37726fe1b..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,5 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko:1:1 - > 1 | - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `checkedValue` groups are not patchable. - 2 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index 5f37726fe1b..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,5 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko:1:1 - > 1 | - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `checkedValue` groups are not patchable. - 2 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-html.txt deleted file mode 100644 index 5f37726fe1b..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,5 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko:1:1 - > 1 | - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Persisted templates cannot patch this faithfully yet: `checkedValue` groups are not patchable. - 2 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..b0740fe056a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/html.bundle.debug.js @@ -0,0 +1,24 @@ +// template.marko +const $template = "

"; +const $walks = "D b lD l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;D b lD ;

" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let note = ""; + _html(`
${_el_resume($scope0_id, "#input/0")}${_el_resume($scope0_id, "#input/1")}

${_text_resume($scope0_id, "#text/2", note)}

`); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason && _scope($scope0_id, {}, "__tests__/template.marko", 0, { + "ControlledHandler:#input/0": ["checkedValueChange", "3:51"], + "ControlledHandler:#input/1": ["checkedValueChange", "4:51"] + }); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..427c836dbcd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/html.bundle.js @@ -0,0 +1,19 @@ +// template.marko +_shells({ a: "a !a2;D b lD ;

" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let note = ""; + _html(`
${_el_resume($scope0_id, "a")}${_el_resume($scope0_id, "b")}

${_text_resume($scope0_id, "c", note)}

`); + _script($scope0_id, "a2"); + $scope0_reason && _scope($scope0_id, {}); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..41244f05c28 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/patches.debug.js @@ -0,0 +1,15 @@ +// PATCH +{ + "PatchBind:1": ["packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko_0/checkedValueChange", "ControlledHandler:#input/0"], + "PatchControl:1#input/0": ["a", "a"], + "PatchBind:2": ["packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko_0/checkedValueChange2", "ControlledHandler:#input/1"], + "PatchControl:1#input/1": ["a", "b"] +} + +// PATCH +{ + "PatchBind:1": ["packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko_0/checkedValueChange", "ControlledHandler:#input/0"], + "PatchControl:1#input/0": ["b", "a"], + "PatchBind:2": ["packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko_0/checkedValueChange2", "ControlledHandler:#input/1"], + "PatchControl:1#input/1": ["b", "b"] +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/patches.js new file mode 100644 index 00000000000..87ab94b0a67 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/patches.js @@ -0,0 +1,15 @@ +// PATCH +{ + d1: ["a0", "Ea"], + n1a: ["a", "a"], + d2: ["a1", "Eb"], + n1b: ["a", "b"] +} + +// PATCH +{ + d1: ["a0", "Ea"], + n1a: ["b", "a"], + d2: ["a1", "Eb"], + n1b: ["b", "b"] +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/render.debug.md new file mode 100644 index 00000000000..7477c77be52 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/render.debug.md @@ -0,0 +1,136 @@ +# Render `{"picked":"a"}` +```html +
+ + +
+

+``` + +# Update +```js +document.querySelectorAll("input")[1].click(); +``` +```html +

+ + +
+

+ b +

+``` +## Change +``` +UPDATE: p::text "" => "b" +``` + +# Update +```js +const [a, b] = document.querySelectorAll("input"); +document.querySelector("p").textContent = `a:${a .checked} b:${b .checked}`; +``` +```html +
+ + +
+

+ a:true b:false +

+``` +## Change +``` +REMOVE: p::text("b") +INSERT: p::text("a:true b:false") +``` + +# Update `{"picked":"a"}` + +# Update +```js +const [a, b] = document.querySelectorAll("input"); +document.querySelector("p").textContent = `a:${a .checked} b:${b .checked}`; +``` +```html +
+ + +
+

+ a:true b:false +

+``` +## Change +``` +REMOVE: p::text("a:true b:false") +INSERT: p::text("a:true b:false") +``` + +# Update `{"picked":"b"}` + +# Update +```js +const [a, b] = document.querySelectorAll("input"); +document.querySelector("p").textContent = `a:${a .checked} b:${b .checked}`; +``` +```html +
+ + +
+

+ a:false b:true +

+``` +## Change +``` +REMOVE: p::text("a:true b:false") +INSERT: p::text("a:false b:true") +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/render.md new file mode 100644 index 00000000000..7477c77be52 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/render.md @@ -0,0 +1,136 @@ +# Render `{"picked":"a"}` +```html +
+ + +
+

+``` + +# Update +```js +document.querySelectorAll("input")[1].click(); +``` +```html +

+ + +
+

+ b +

+``` +## Change +``` +UPDATE: p::text "" => "b" +``` + +# Update +```js +const [a, b] = document.querySelectorAll("input"); +document.querySelector("p").textContent = `a:${a .checked} b:${b .checked}`; +``` +```html +
+ + +
+

+ a:true b:false +

+``` +## Change +``` +REMOVE: p::text("b") +INSERT: p::text("a:true b:false") +``` + +# Update `{"picked":"a"}` + +# Update +```js +const [a, b] = document.querySelectorAll("input"); +document.querySelector("p").textContent = `a:${a .checked} b:${b .checked}`; +``` +```html +
+ + +
+

+ a:true b:false +

+``` +## Change +``` +REMOVE: p::text("a:true b:false") +INSERT: p::text("a:true b:false") +``` + +# Update `{"picked":"b"}` + +# Update +```js +const [a, b] = document.querySelectorAll("input"); +document.querySelector("p").textContent = `a:${a .checked} b:${b .checked}`; +``` +```html +
+ + +
+

+ a:false b:true +

+``` +## Change +``` +REMOVE: p::text("a:true b:false") +INSERT: p::text("a:false b:true") +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..87bdc28af74 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/writes.debug.html @@ -0,0 +1,17 @@ +
+

+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/writes.html new file mode 100644 index 00000000000..30b4cc470e0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/__snapshots__/writes.html @@ -0,0 +1,11 @@ +
+

+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/sizes.json new file mode 100644 index 00000000000..c6d5d58c06f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 5211, + "brotli": 2363 + } + }, + "html": { + "min": 473, + "brotli": 291 + }, + "patch": { + "min": 120, + "brotli": 63 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko index 80ac799a8b8..c2c549dac94 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/template.marko @@ -1 +1,6 @@ - + +
+ + +
+

${note}

diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/test.ts index c12e6a0b78d..51952f96343 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked-value/test.ts @@ -1,7 +1,26 @@ import type { TestConfig } from "../../main.test"; -// Stays fail-closed: the wire cannot yet express this control faithfully. +const pickB = (document: Document) => { + document.querySelectorAll("input")[1]!.click(); +}; + +const probe = (document: Document) => { + const [a, b] = document.querySelectorAll("input"); + document.querySelector("p")!.textContent = `a:${a!.checked} b:${b!.checked}`; +}; + +// A `checkedValue` group: each input's entry carries `[checkedValue, value]` +// and applies through the same helper CSR uses, so a live selection survives +// an unchanged frame while a changed server value re-selects the group. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: [ + { picked: "a" }, + pickB, + probe, + { picked: "a" }, + probe, + { picked: "b" }, + probe, + ], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked/sizes.json index d1a12687b00..6e1dbed8ccc 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-checked/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4519, - "brotli": 2093 + "min": 4488, + "brotli": 2081 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-details/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-details/sizes.json index 8616d05e5cf..cbfbbb8d862 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-details/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-details/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 3491, - "brotli": 1695 + "min": 3460, + "brotli": 1673 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-multiple/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-multiple/sizes.json index a61b6634e0c..87dcc2fe16c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-multiple/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-multiple/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4919, - "brotli": 2191 + "min": 4888, + "brotli": 2179 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-removal/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-removal/sizes.json index b87023d73c7..538b8e9ec4d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-removal/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-removal/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4552, - "brotli": 2112 + "min": 4521, + "brotli": 2101 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-select/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-select/sizes.json index afc8cf82de3..4276304fa6c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-select/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-select/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4734, - "brotli": 2124 + "min": 4703, + "brotli": 2116 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..e6485c84606 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,25 @@ +// template.marko +const $template = "

"; +const $walks = " bD l"; +const $text = /*@__PURE__*/ _let("text/5", ($scope) => _text($scope["#text/1"], $scope.text)); +function $setup($scope) { + $text($scope, ""); +} +const $field2__script = _script("__tests__/template.marko_0_field#6", ($scope) => _attrs_script($scope, "#input/0")); +const $field2 = /*@__PURE__*/ _const("field", ($scope) => { + _attrs($scope, "#input/0", { + type: "text", + ...$scope.field + }, _controllable_input); + $field2__script($scope); +}); +const $input_field = ($scope, input_field) => $field2($scope, { + ...input_field, + valueChange: $field($scope) +}); +const $input = ($scope, input) => $input_field($scope, input.field); +const $field = ($scope) => (next) => { + $text($scope, next); +}; +_resume("__tests__/template.marko_0/field", $field); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..d049c98eebf --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/dom.bundle.js @@ -0,0 +1,7 @@ +// template.marko +const $text = /*@__PURE__*/ _let(5, ($scope) => _text($scope.b, $scope.f)); +const $field2__script = _script("a1", ($scope) => _attrs_script($scope, "a")); +const $field = ($scope) => (next) => { + $text($scope, next); +}; +_resume("a0", $field); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index 06d06f68b9a..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,5 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko:1:8 - > 1 | - | ^^^^^^^^^^^^^^ Persisted templates currently support only escaped dynamic text and dynamic attributes in native HTML. - 2 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-dom.txt deleted file mode 100644 index 06d06f68b9a..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,5 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko:1:8 - > 1 | - | ^^^^^^^^^^^^^^ Persisted templates currently support only escaped dynamic text and dynamic attributes in native HTML. - 2 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index 06d06f68b9a..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,5 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko:1:8 - > 1 | - | ^^^^^^^^^^^^^^ Persisted templates currently support only escaped dynamic text and dynamic attributes in native HTML. - 2 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-html.txt deleted file mode 100644 index 06d06f68b9a..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,5 +0,0 @@ - - at packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko:1:8 - > 1 | - | ^^^^^^^^^^^^^^ Persisted templates currently support only escaped dynamic text and dynamic attributes in native HTML. - 2 | \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..1271a986a07 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/html.bundle.debug.js @@ -0,0 +1,25 @@ +// template.marko +const $template = "

"; +const $walks = " bD l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0_field#6; bD ;

" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let text = ""; + const field = { + ...input.field, + valueChange: _resume((next) => { + text = next; + }, "__tests__/template.marko_0/field", $scope0_id) + }; + _html(`${_el_resume($scope0_id, "#input/0")}

${_text_resume($scope0_id, "#text/1", text)}

`); + _script($scope0_id, "__tests__/template.marko_0_field#6"); + $scope0_reason && _scope($scope0_id, {}, "__tests__/template.marko", 0, { + "ControlledHandler:#input/0": ["...field", "3:23"], + "EventAttributes:#input/0": ["...field", "3:23"] + }); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..d932e430197 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/html.bundle.js @@ -0,0 +1,17 @@ +// template.marko +_shells({ a: "a !a1; bD ;

" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let text = ""; + _html(` { + text = next; + }, "a0", $scope0_id) + }, "a", $scope0_id, "input", 1, $scope0_owned, 0)}>${_el_resume($scope0_id, "a")}

${_text_resume($scope0_id, "b", text)}

`); + _script($scope0_id, "a1"); + $scope0_reason && _scope($scope0_id, {}); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..dd9841b9f25 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/patches.debug.js @@ -0,0 +1,21 @@ +// PATCH +{ + "PatchBindSource:1": "packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko_0/field", + "PatchAttrs:#input/0": [{ + type: "text", + value: "a", + placeholder: "p2", + valueChange: bind(1) + }, 0, 1] +} + +// PATCH +{ + "PatchBindSource:1": "packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko_0/field", + "PatchAttrs:#input/0": [{ + type: "text", + value: "b", + placeholder: "p2", + valueChange: bind(1) + }, 0, 1] +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/patches.js new file mode 100644 index 00000000000..cd30d087da6 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/patches.js @@ -0,0 +1,21 @@ +// PATCH +{ + h1: "a0", + ja: [{ + type: "text", + value: "a", + placeholder: "p2", + valueChange: b(1) + }, 0, 1] +} + +// PATCH +{ + h1: "a0", + ja: [{ + type: "text", + value: "b", + placeholder: "p2", + valueChange: b(1) + }, 0, 1] +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/render.debug.md new file mode 100644 index 00000000000..4e4893d810f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/render.debug.md @@ -0,0 +1,112 @@ +# Render `{"field":{"value":"a","placeholder":"p1"}}` +```html + +

+``` + +# Update +```js +const el = document.querySelector("input"); +el.value = "typed"; +el.dispatchEvent(new document.defaultView.Event("input", { bubbles: true })); +``` +```html + +

+ typed +

+``` +## Change +``` +UPDATE: p::text "" => "typed" +``` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:a +

+``` +## Change +``` +REMOVE: p::text("typed") +INSERT: p::text("live:a") +``` + +# Update `{"field":{"value":"a","placeholder":"p2"}}` +```html + +

+ live:a +

+``` +## Change +``` +UPDATE: input[placeholder] "p1" => "p2" +``` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:a +

+``` +## Change +``` +REMOVE: p::text("live:a") +INSERT: p::text("live:a") +``` + +# Update `{"field":{"value":"b","placeholder":"p2"}}` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:b +

+``` +## Change +``` +REMOVE: p::text("live:a") +INSERT: p::text("live:b") +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/render.md new file mode 100644 index 00000000000..4e4893d810f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/render.md @@ -0,0 +1,112 @@ +# Render `{"field":{"value":"a","placeholder":"p1"}}` +```html + +

+``` + +# Update +```js +const el = document.querySelector("input"); +el.value = "typed"; +el.dispatchEvent(new document.defaultView.Event("input", { bubbles: true })); +``` +```html + +

+ typed +

+``` +## Change +``` +UPDATE: p::text "" => "typed" +``` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:a +

+``` +## Change +``` +REMOVE: p::text("typed") +INSERT: p::text("live:a") +``` + +# Update `{"field":{"value":"a","placeholder":"p2"}}` +```html + +

+ live:a +

+``` +## Change +``` +UPDATE: input[placeholder] "p1" => "p2" +``` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:a +

+``` +## Change +``` +REMOVE: p::text("live:a") +INSERT: p::text("live:a") +``` + +# Update `{"field":{"value":"b","placeholder":"p2"}}` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:b +

+``` +## Change +``` +REMOVE: p::text("live:a") +INSERT: p::text("live:b") +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..d3392f1a912 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/writes.debug.html @@ -0,0 +1,14 @@ + +

+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/writes.html new file mode 100644 index 00000000000..c4b591cd33e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/__snapshots__/writes.html @@ -0,0 +1,10 @@ + +

+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/sizes.json new file mode 100644 index 00000000000..fa6fe0e5f74 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 10431, + "brotli": 4006 + } + }, + "html": { + "min": 395, + "brotli": 273 + }, + "patch": { + "min": 154, + "brotli": 82 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko index ac74f2bea39..b6765aa798d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/template.marko @@ -1 +1,4 @@ - + + { text = next } }/> + +

${text}

diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/test.ts index c12e6a0b78d..333f87f431f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-spread/test.ts @@ -1,7 +1,29 @@ import type { TestConfig } from "../../main.test"; -// Stays fail-closed: the wire cannot yet express this control faithfully. +const type = (document: Document) => { + const el = document.querySelector("input")!; + el.value = "typed"; + el.dispatchEvent(new document.defaultView!.Event("input", { bubbles: true })); +}; + +const probe = (document: Document) => { + document.querySelector("p")!.textContent = + `live:${document.querySelector("input")!.value}`; +}; + +// A spread carrying a controllable: the patched set re-claims the control +// through the run-time claim table, so the change handler stays live, an +// unchanged frame preserves the controlled value, and a changed server +// value wins the input. export const config: TestConfig = { - error_compiler: true, persisted: true, + steps: [ + { field: { value: "a", placeholder: "p1" } }, + type, + probe, + { field: { value: "a", placeholder: "p2" } }, + probe, + { field: { value: "b", placeholder: "p2" } }, + probe, + ], }; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..e33cad30000 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,26 @@ +// template.marko +const $template = "

"; +const $walks = " bD l"; +const $input_rest__OR__text__script = _script("__tests__/template.marko_0_input_rest#4_text#5", ($scope) => _attrs_script($scope, "#input/0")); +const $input_rest__OR__text = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "input_rest", /*@__PURE__*/ _or(6, ($scope) => { + _attrs($scope, "#input/0", { + value: $scope.text, + valueChange: $valueChange($scope), + ...$scope.input_rest + }, _controllable_input); + $input_rest__OR__text__script($scope); +})); +const $text = /*@__PURE__*/ _let("text/5", ($scope) => { + _text($scope["#text/1"], $scope.text); + $input_rest__OR__text($scope); +}); +function $setup($scope) { + $text($scope, "init"); +} +const $input_rest = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_rest", $input_rest__OR__text); +const $input = ($scope, input) => $input_rest($scope, input.rest); +const $valueChange = ($scope) => (_new_text) => { + $text($scope, _new_text); +}; +_resume("__tests__/template.marko_0/valueChange", $valueChange); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..b7280d96990 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/dom.bundle.js @@ -0,0 +1,18 @@ +// template.marko +const $input_rest__OR__text__script = _script("a1", ($scope) => _attrs_script($scope, "a")); +const $input_rest__OR__text = /*@__PURE__*/ _fill_join("a0", 4, /*@__PURE__*/ _or(6, ($scope) => { + _attrs($scope, "a", { + value: $scope.f, + valueChange: $valueChange($scope), + ...$scope.e + }, _controllable_input); + $input_rest__OR__text__script($scope); +})); +const $text = /*@__PURE__*/ _let(5, ($scope) => { + _text($scope.b, $scope.f); + $input_rest__OR__text($scope); +}); +const $valueChange = ($scope) => (_new_text) => { + $text($scope, _new_text); +}; +_resume("a0", $valueChange); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..7ddc6f09509 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/html.bundle.debug.js @@ -0,0 +1,27 @@ +// template.marko +const $template = "

"; +const $walks = " bD l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !; bD ;

" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let text = "init"; + _html(` { + text = _new_text; + }, "__tests__/template.marko_0/valueChange", $scope0_id), + ...input.rest + }, "#input/0", $scope0_id, "input")}>${_el_resume($scope0_id, "#input/0")}

${_text_resume($scope0_id, "#text/1", text)}

`); + _script($scope0_id, "__tests__/template.marko_0_input_rest#4_text#5"); + $scope0_reason ? _scope($scope0_id, { + input_rest: input.rest, + text + }, "__tests__/template.marko", 0, { + input_rest: ["input.rest"], + text: "1:6", + "ControlledHandler:#input/0": ["...input.rest", "2:23"], + "EventAttributes:#input/0": ["...input.rest", "2:23"] + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", input.rest); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..a6f6ffacf13 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/html.bundle.js @@ -0,0 +1,20 @@ +// template.marko +_shells({ a: "a !; bD ;

" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let text = "init"; + _html(` { + text = _new_text; + }, "a0", $scope0_id), + ...input.rest + }, "a", $scope0_id, "input")}>${_el_resume($scope0_id, "a")}

${_text_resume($scope0_id, "b", text)}

`); + _script($scope0_id, "a1"); + $scope0_reason ? _scope($scope0_id, { + e: input.rest, + f: text + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", input.rest); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..a92eb8f1b15 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/patches.debug.js @@ -0,0 +1,6 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/template.marko0": { + placeholder: "p2" + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/patches.js new file mode 100644 index 00000000000..3e0fbb03003 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/patches.js @@ -0,0 +1,6 @@ +// PATCH +{ + va0: { + placeholder: "p2" + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/render.debug.md new file mode 100644 index 00000000000..8337b345759 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/render.debug.md @@ -0,0 +1,96 @@ +# Render `{"rest":{"placeholder":"p1"}}` +```html + +

+ init +

+``` + +# Update +```js +const el = document.querySelector("input"); +el.value = "typed"; +el.dispatchEvent(new document.defaultView.Event("input", { bubbles: true })); +``` +```html + +

+ typed +

+``` +## Change +``` +UPDATE: p::text "init" => "typed" +``` + +# Update `{"rest":{"placeholder":"p2"}}` +```html + +

+ typed +

+``` +## Change +``` +UPDATE: input[placeholder] "p1" => "p2" +``` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:typed +

+``` +## Change +``` +REMOVE: p::text("typed") +INSERT: p::text("live:typed") +``` + +# Update +```js +const el = document.querySelector("input"); +el.value = "typed"; +el.dispatchEvent(new document.defaultView.Event("input", { bubbles: true })); +``` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:typed +

+``` +## Change +``` +REMOVE: p::text("live:typed") +INSERT: p::text("live:typed") +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/render.md new file mode 100644 index 00000000000..8337b345759 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/render.md @@ -0,0 +1,96 @@ +# Render `{"rest":{"placeholder":"p1"}}` +```html + +

+ init +

+``` + +# Update +```js +const el = document.querySelector("input"); +el.value = "typed"; +el.dispatchEvent(new document.defaultView.Event("input", { bubbles: true })); +``` +```html + +

+ typed +

+``` +## Change +``` +UPDATE: p::text "init" => "typed" +``` + +# Update `{"rest":{"placeholder":"p2"}}` +```html + +

+ typed +

+``` +## Change +``` +UPDATE: input[placeholder] "p1" => "p2" +``` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:typed +

+``` +## Change +``` +REMOVE: p::text("typed") +INSERT: p::text("live:typed") +``` + +# Update +```js +const el = document.querySelector("input"); +el.value = "typed"; +el.dispatchEvent(new document.defaultView.Event("input", { bubbles: true })); +``` + +# Update +```js +document.querySelector("p").textContent = +`live:${document.querySelector("input") .value}`; +``` +```html + +

+ live:typed +

+``` +## Change +``` +REMOVE: p::text("live:typed") +INSERT: p::text("live:typed") +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..07fca796a8f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/writes.debug.html @@ -0,0 +1,18 @@ + +

init

+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/writes.html new file mode 100644 index 00000000000..144ddaa7c29 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/__snapshots__/writes.html @@ -0,0 +1,14 @@ + +

init

+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/sizes.json new file mode 100644 index 00000000000..d8b3c6b6cc1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 10870, + "brotli": 4192 + } + }, + "html": { + "min": 422, + "brotli": 289 + }, + "patch": { + "min": 25, + "brotli": 29 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/template.marko new file mode 100644 index 00000000000..557199ec758 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/template.marko @@ -0,0 +1,3 @@ + + +

${text}

diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/test.ts new file mode 100644 index 00000000000..9f5b3527676 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-static-with-spread/test.ts @@ -0,0 +1,27 @@ +import type { TestConfig } from "../../main.test"; + +const type = (document: Document) => { + const el = document.querySelector("input")!; + el.value = "typed"; + el.dispatchEvent(new document.defaultView!.Event("input", { bubbles: true })); +}; + +const probe = (document: Document) => { + document.querySelector("p")!.textContent = + `live:${document.querySelector("input")!.value}`; +}; + +// A control owned by a static (client-state) attr with a server spread: a +// frame carrying only the spread must leave the live control alone — the +// binding, handler, and typed value all survive the patch. +export const config: TestConfig = { + persisted: true, + steps: [ + { rest: { placeholder: "p1" } }, + type, + { rest: { placeholder: "p2" } }, + probe, + type, + probe, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-swap/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-swap/sizes.json index 1dc3fc23059..ae2ead4da11 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-swap/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-swap/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4637, - "brotli": 2137 + "min": 4606, + "brotli": 2120 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-textarea/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-textarea/sizes.json index 4ca18fb5a88..087915c2592 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-textarea/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-textarea/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4553, - "brotli": 2112 + "min": 4522, + "brotli": 2102 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-value/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-value/sizes.json index 5777ef8ba0f..25ac1abc942 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-value/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-controllable-value/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4031, - "brotli": 1859 + "min": 4000, + "brotli": 1841 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-ctrl-handler-param/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-ctrl-handler-param/sizes.json index 38393dd40a4..e31aac2f4e0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-ctrl-handler-param/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-ctrl-handler-param/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9131, - "brotli": 3982 + "min": 9094, + "brotli": 3963 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-attribute/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-attribute/sizes.json index 7f550c6561a..1081180e26f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-attribute/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-attribute/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2285, - "brotli": 1159 + "min": 2268, + "brotli": 1146 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-body/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-body/sizes.json index 50932aa54b9..ab0313d56c9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-body/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-body/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9695, - "brotli": 4144 + "min": 9650, + "brotli": 4125 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-renderer-swap/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-renderer-swap/sizes.json index 9aa5cf4c9f4..fbfd0076ba6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-renderer-swap/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-renderer-swap/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10261, - "brotli": 4396 + "min": 10216, + "brotli": 4381 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-scriptless-swap/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-scriptless-swap/sizes.json index 15b6b5df30f..416733e87b5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-scriptless-swap/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-scriptless-swap/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9689, - "brotli": 4159 + "min": 9644, + "brotli": 4142 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-swap-effects/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-swap-effects/sizes.json index 3744275428b..736f37a5a50 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-swap-effects/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-dynamic-swap-effects/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10728, - "brotli": 4553 + "min": 10663, + "brotli": 4538 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-effect-only/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-effect-only/sizes.json index e05c80b6428..e9b676f7188 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-effect-only/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-effect-only/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 3179, - "brotli": 1591 + "min": 3162, + "brotli": 1570 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-effects/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-effects/sizes.json index 3398986bce8..5d8a98b380e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-effects/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-effects/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2548, - "brotli": 1286 + "min": 2531, + "brotli": 1276 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-asymmetric-if/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-asymmetric-if/sizes.json index 7420f5ed013..aaaf37c2a49 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-asymmetric-if/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-asymmetric-if/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8857, - "brotli": 3908 + "min": 8818, + "brotli": 3893 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-bound-pair/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-bound-pair/sizes.json index d4573d5f7f7..bd88308be86 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-bound-pair/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-bound-pair/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7907, - "brotli": 3554 + "min": 7878, + "brotli": 3536 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-attr/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-attr/sizes.json index 012d42fc0f9..78c925e68fc 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-attr/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-attr/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11284, - "brotli": 4807 + "min": 11219, + "brotli": 4780 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/__snapshots__/html.bundle.debug.js index ed3afcca5bb..f3393b59831 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/__snapshots__/html.bundle.debug.js @@ -39,7 +39,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope2_id = _scope_id(); _html(`

${_text_resume($scope2_id, "#text/0", value)}

`); _scope($scope2_id, {}, "__tests__/template.marko", "4:6"); - }, void 0, "__tests__/template.marko_1_#text#0/await", 1); + }, 1, "__tests__/template.marko_1_#text#0/await"); _subscribe($showSecond__closures, _subscribe(_source_if($scope0_reason, 1) && $input_first__closures, _subscribe(_source_if($scope0_reason, 0) && $input_second__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4")))); _resume_branch($scope1_id); }, $scope0_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/__snapshots__/html.bundle.js index f229ea39cb9..144751dd80e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/__snapshots__/html.bundle.js @@ -36,7 +36,7 @@ var template_default = _template_persisted("a", (input) => { const $scope2_id = _scope_id(); _html(`

${_text_resume($scope2_id, "a", value)}

`); _scope($scope2_id, {}); - }, void 0, "a1", 1); + }, 1, "a1"); _subscribe($showSecond__closures, _subscribe(_source_if($scope0_reason, 1) && $input_first__closures, _subscribe(_source_if($scope0_reason, 0) && $input_second__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })))); _resume_branch($scope1_id); }, $scope0_id) }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/sizes.json index be88d9edb19..57cf289283a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-await/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 15662, - "brotli": 6392 + "min": 15578, + "brotli": 6376 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..b6ea1681e85 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,39 @@ +// tags/wrap/index.marko +const $template$1 = "
"; +const $walks$1 = "D%l"; +const $setup$1 = () => {}; +const $input_content_direct = /*@__PURE__*/ _dynamic_tag_content("#text/0"); +const $dynamicTag = /*@__PURE__*/ _dynamic_tag("#text/0"); +const $input_content = $dynamicTag; +const $input$1 = ($scope, input) => $input_content($scope, input.content); +var wrap_default = /*@__PURE__*/ _template("__tests__/tags/wrap/index.marko", $template$1, "D%l", 0, $input$1); + +// template.marko +const $template = ""; +const $walks = " b%c"; +const $wrap_content__input_msg__OR__count = /*@__PURE__*/ _or(1, ($scope) => _text($scope["#text/0"], $scope._._.input_msg + ":" + $scope._._.count)); +const $wrap_content__input_msg = /*@__PURE__*/ _fill_join_closure("__tests__/template.marko0", "input_msg", /*@__PURE__*/ _closure_get("input_msg", $wrap_content__input_msg__OR__count, ($scope) => $scope._._), 0); +const $wrap_content__setup = ($scope) => { + $wrap_content__input_msg($scope); + $wrap_content__count($scope); +}; +const $wrap_content__count = /*@__PURE__*/ _closure_get("count", $wrap_content__input_msg__OR__count, ($scope) => $scope._._); +const $wrap_content = /*@__PURE__*/ _content("__tests__/template.marko_2*content", " ", "D ", $wrap_content__setup); +const $if_content__setup = ($scope) => $input_content_direct($scope["#childScope/0"], $wrap_content($scope)); +const $if = /*@__PURE__*/ _if("#text/1", $template$1, /*@__PURE__*/ ((_w0) => `/${_w0}&`)("D%l"), $if_content__setup); +const $count__closure = /*@__PURE__*/ _closure($wrap_content__count); +const $count = /*@__PURE__*/ _let("count/5", ($scope) => { + $if($scope, $scope.count < 2 ? 0 : 1); + $count__closure($scope); +}); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $count($scope, 0); + $setup__script($scope); +} +const $input = ($scope, input) => $input_msg($scope, input.msg); +const $input_msg__closure = /*@__PURE__*/ _closure($wrap_content__input_msg); +const $input_msg = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_msg", $input_msg__closure); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..75bc6fbed6c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/dom.bundle.js @@ -0,0 +1,23 @@ +// tags/wrap/index.marko +const $template = "
"; +const $input_content_direct = /*@__PURE__*/ _dynamic_tag_content(0); + +// template.marko +const $wrap_content__input_msg__OR__count = /*@__PURE__*/ _or(1, ($scope) => _text($scope.a, $scope._._.e + ":" + $scope._._.f)); +const $wrap_content__input_msg = /*@__PURE__*/ _fill_join_closure("a0", 4, /*@__PURE__*/ _closure_get(6, $wrap_content__input_msg__OR__count, ($scope) => $scope._._), 0); +const $wrap_content__setup = ($scope) => { + $wrap_content__input_msg($scope); + $wrap_content__count($scope); +}; +const $wrap_content__count = /*@__PURE__*/ _closure_get(7, $wrap_content__input_msg__OR__count, ($scope) => $scope._._); +const $wrap_content = /*@__PURE__*/ _content$1("a0", " ", "D ", $wrap_content__setup); +const $if_content__setup = ($scope) => $input_content_direct($scope.a, $wrap_content($scope)); +const $if = /*@__PURE__*/ _if(1, $template, /*@__PURE__*/ ((_w0) => `/${_w0}&`)("D%l"), $if_content__setup); +const $count__closure = /*@__PURE__*/ _closure($wrap_content__count); +const $count = /*@__PURE__*/ _let(5, ($scope) => { + $if($scope, $scope.f < 2 ? 0 : 1); + $count__closure($scope); +}); +const $setup__script = _script("a1", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.f + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..b251b12b562 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/html.bundle.debug.js @@ -0,0 +1,56 @@ +// tags/wrap/index.marko +const $template$1 = "
"; +const $walks$1 = "D%l"; +_shells({ "__tests__/tags/wrap/index.marko": "__tests__/tags/wrap/index.marko;D%;
" }); +var wrap_default = _template_persisted("__tests__/tags/wrap/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _patch_dynamic_tag($scope0_id, "#text/0", input.content, $scope0_owned, 0); + _dynamic_tag($scope0_id, "#text/0", input.content, {}, 0, 0, _source_guard($scope0_reason, 0), 1); + _html("
"); + $scope0_reason && _scope($scope0_id, {}, "__tests__/tags/wrap/index.marko", 0); +}, 0, 0); + +// template.marko +const $template = ""; +const $walks = " b%c"; +_shells({ + "__tests__/template.marko_2*content": "__tests__/template.marko_2*content;D ; ", + "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0; b%;" +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = new Set(); + const $count__closures = new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + if ($scope0_reason) _if(() => { + if (count < 2) { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + wrap_default({ content: _content_elide("__tests__/template.marko_2*content", () => { + const $scope2_reason = _persisted_reason(); + const $scope2_id = _scope_id(); + _html(`${_text_resume($scope2_id, "#text/0", input.msg + ":" + count)}`); + _subscribe($count__closures, _subscribe(_source_if($scope0_reason, 0) && $input_msg__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "4:4"))); + _resume_branch($scope2_id); + }, $scope1_id) }); + _scope($scope1_id, { "#childScope/0": _existing_scope($childScope) }, "__tests__/template.marko", "3:2"); + return 0; + } + }, $scope0_id, "#text/1", 1, 1, 1, 0, 1); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + input_msg: input.msg, + count, + "ClosureScopes:input_msg": $input_msg__closures, + "ClosureScopes:count": $count__closures + }, "__tests__/template.marko", 0, { + input_msg: ["input.msg"], + count: "1:6" + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", input.msg); + _resume_branch($scope0_id); +}, 1, () => [wrap_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..e98ab9e7d07 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/html.bundle.js @@ -0,0 +1,49 @@ +// tags/wrap/index.marko +_shells({ b: "b;D%;
" }); +var wrap_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _patch_dynamic_tag($scope0_id, "a", input.content, $scope0_owned, 0); + _dynamic_tag($scope0_id, "a", input.content, {}, 0, 0, _source_guard($scope0_reason, 0), 1); + _html("
"); + $scope0_reason && _scope($scope0_id, {}); +}, 0, 0); + +// template.marko +_shells({ + a0: "a0;D ; ", + a: "a !a1; b%;" +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = /* @__PURE__ */ new Set(); + const $count__closures = /* @__PURE__ */ new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + _set_serialize_reason(1); + const $childScope = _peek_scope_id(); + wrap_default({ content: _content_elide("a0", () => { + _persisted_reason(); + const $scope2_id = _scope_id(); + _html(`${_text_resume($scope2_id, "a", input.msg + ":0")}`); + _subscribe($count__closures, _subscribe(_source_if($scope0_reason, 0) && $input_msg__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }))); + _resume_branch($scope2_id); + }, $scope1_id) }); + _scope($scope1_id, { a: _existing_scope($childScope) }); + return 0; + } + }, $scope0_id, "b", 1, 1, 1, 0, 1); + _script($scope0_id, "a1"); + $scope0_reason ? _scope($scope0_id, { + e: input.msg, + f: count, + g: $input_msg__closures, + h: $count__closures + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", input.msg); + _resume_branch($scope0_id); +}, 1, () => [wrap_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..1ae1d1f9dce --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/patches.debug.js @@ -0,0 +1,9 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/template.marko0": "b" +} + +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/template.marko0": "c" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/patches.js new file mode 100644 index 00000000000..6bd84df9cea --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/patches.js @@ -0,0 +1,9 @@ +// PATCH +{ + va0: "b" +} + +// PATCH +{ + va0: "c" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/render.debug.md new file mode 100644 index 00000000000..ef017d62877 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/render.debug.md @@ -0,0 +1,62 @@ +# Render `{"msg":"a"}` +```html + +
+ + a:0 + +
+``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +
+ + a:1 + +
+``` +## Change +``` +UPDATE: div > span::text "a:0" => "a:1" +``` + +# Update `{"msg":"b"}` +```html + +
+ + b:1 + +
+``` +## Change +``` +UPDATE: div > span::text "a:1" => "b:1" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + div +``` + +# Update `{"msg":"c"}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/render.md new file mode 100644 index 00000000000..ef017d62877 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/render.md @@ -0,0 +1,62 @@ +# Render `{"msg":"a"}` +```html + +
+ + a:0 + +
+``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +
+ + a:1 + +
+``` +## Change +``` +UPDATE: div > span::text "a:0" => "a:1" +``` + +# Update `{"msg":"b"}` +```html + +
+ + b:1 + +
+``` +## Change +``` +UPDATE: div > span::text "a:1" => "b:1" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + div +``` + +# Update `{"msg":"c"}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..55cfdc58652 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/writes.debug.html @@ -0,0 +1,21 @@ + +
a:0
+ + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/writes.html new file mode 100644 index 00000000000..021036dc2e2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/__snapshots__/writes.html @@ -0,0 +1,18 @@ + +
a:0
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/sizes.json new file mode 100644 index 00000000000..41a1b344c84 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/sizes.json @@ -0,0 +1,22 @@ +{ + "dom": { + "template.marko.page.mjs": { + "total": { + "min": 11872, + "brotli": 5046 + }, + "files": { + "tags/wrap/index.marko": 150, + "template.marko": 1185 + } + } + }, + "html": { + "min": 493, + "brotli": 327 + }, + "patch": { + "min": 20, + "brotli": 24 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/tags/wrap/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/tags/wrap/index.marko new file mode 100644 index 00000000000..a707eb13af2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/tags/wrap/index.marko @@ -0,0 +1 @@ +
<${input.content}/>
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/template.marko new file mode 100644 index 00000000000..6313ce0ab4b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/template.marko @@ -0,0 +1,7 @@ + + + + + ${input.msg + ":" + count} + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/test.ts new file mode 100644 index 00000000000..9855cff4be8 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-in-stateful/test.ts @@ -0,0 +1,13 @@ +import type { TestConfig } from "../../main.test"; + +const click = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// An intersection read (`input.msg` × `count`) inside a content section +// nested in a client-owned branch: the fill must still reach the content +// scope after a patch changes `msg`. +export const config: TestConfig = { + persisted: true, + steps: [{ msg: "a" }, click, { msg: "b" }, click, { msg: "c" }], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-section/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-section/sizes.json index c47a1e25f24..11b7d0953c9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-section/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-section/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11367, - "brotli": 4833 + "min": 11302, + "brotli": 4814 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-subscribers/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-subscribers/sizes.json index 998f69b76d6..224ab6fb179 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-subscribers/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-content-subscribers/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11505, - "brotli": 4879 + "min": 11440, + "brotli": 4851 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-depth-3/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-depth-3/sizes.json index 65ffeb736c4..3bc81786e5c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-depth-3/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-depth-3/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10801, - "brotli": 4763 + "min": 10762, + "brotli": 4764 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-embedded-fn/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-embedded-fn/sizes.json index cc7e6993dec..5cba8b9adf2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-embedded-fn/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-embedded-fn/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7641, - "brotli": 3428 + "min": 7612, + "brotli": 3417 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-fn-destructure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-fn-destructure/sizes.json index 70ad964a2f7..cd4e58f002c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-fn-destructure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-fn-destructure/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7731, - "brotli": 3473 + "min": 7702, + "brotli": 3471 }, "files": { "tags/card/index.marko": 143, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-fn-select/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-fn-select/sizes.json index c950a46b3a7..21935bb7556 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-fn-select/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-fn-select/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7665, - "brotli": 3429 + "min": 7636, + "brotli": 3427 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-loops-grow/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-loops-grow/sizes.json index 32481c46f66..d59cd599d74 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-loops-grow/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-loops-grow/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10170, - "brotli": 4522 + "min": 10131, + "brotli": 4484 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-loops-of-loops/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-loops-of-loops/sizes.json index 2000d6c9190..a206db0abac 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-loops-of-loops/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-loops-of-loops/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10170, - "brotli": 4522 + "min": 10131, + "brotli": 4484 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-multicap/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-multicap/sizes.json index 74b2a17aeea..75939c43bb9 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-multicap/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-multicap/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7645, - "brotli": 3432 + "min": 7616, + "brotli": 3422 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-offset-if/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-offset-if/sizes.json index 24088f85283..2cd214cd2a2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-offset-if/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-offset-if/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8891, - "brotli": 3915 + "min": 8852, + "brotli": 3905 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-offset-loops/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-offset-loops/sizes.json index 99aa538fe16..c535f46a0aa 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-offset-loops/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-fill-offset-loops/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10205, - "brotli": 4512 + "min": 10166, + "brotli": 4522 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..74640920236 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,28 @@ +// template.marko +const $template = ""; +const $walks = " b%c"; +const $if_content__greeting = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "greeting", /*@__PURE__*/ _if_closure("#text/1", 0, ($scope) => _text($scope["#text/0"], $scope._.greeting))); +const $if_content__setup = ($scope) => { + $if_content__greeting._($scope); + $if_content__count._($scope); +}; +const $if_content__count = /*@__PURE__*/ _if_closure("#text/1", 0, ($scope) => _text($scope["#text/1"], $scope._.count)); +const $greeting = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "greeting", $if_content__greeting); +const $input_name__OR__$global_prefix = ($scope) => { + $greeting($scope, $scope.$global_prefix + ":" + $scope.input_name); +}; +const $input_name = /*@__PURE__*/ _const("input_name", $input_name__OR__$global_prefix); +const $if = /*@__PURE__*/ _if("#text/1", " ", "D%c%", $if_content__setup); +const $count = /*@__PURE__*/ _let("count/7", ($scope) => { + $if($scope, $scope.count < 2 ? 0 : 1); + $if_content__count($scope); +}); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $count($scope, 0); + $setup__script($scope); +} +const $input = ($scope, input) => $input_name($scope, input.name); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..9e97c3bc137 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/dom.bundle.js @@ -0,0 +1,15 @@ +// template.marko +const $if_content__greeting = /*@__PURE__*/ _fill_join("a0", 5, /*@__PURE__*/ _if_closure(1, 0, ($scope) => _text($scope.a, $scope._.f))); +const $if_content__setup = ($scope) => { + $if_content__greeting._($scope); + $if_content__count._($scope); +}; +const $if_content__count = /*@__PURE__*/ _if_closure(1, 0, ($scope) => _text($scope.b, $scope._.h)); +const $if = /*@__PURE__*/ _if(1, " ", "D%c%", $if_content__setup); +const $count = /*@__PURE__*/ _let(7, ($scope) => { + $if($scope, $scope.h < 2 ? 0 : 1); + $if_content__count($scope); +}); +const $setup__script = _script("a0", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.h + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..a1b3c651c34 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/html.bundle.debug.js @@ -0,0 +1,31 @@ +// template.marko +const $template = ""; +const $walks = " b%c"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0; b%;" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + const greeting = $global$1.prefix + ":" + input.name; + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + if ($scope0_reason) _if(() => { + if (count < 2) { + const $scope1_id = _scope_id(); + _html(`${_text_resume($scope1_id, "#text/0", greeting)} ${_text_resume($scope1_id, "#text/1", count, 2)}`); + _scope($scope1_id, {}, "__tests__/template.marko", "4:2"); + return 0; + } + }, $scope0_id, "#text/1", 1, 1, 1, 0, 1); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + greeting, + $global_prefix: $global$1?.prefix, + count + }, "__tests__/template.marko", 0, { + greeting: "1:8", + $global_prefix: ["$global.prefix"], + count: "2:6" + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", greeting); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..25955f6dec4 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/html.bundle.js @@ -0,0 +1,25 @@ +// template.marko +_shells({ a: "a !a0; b%;" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + const greeting = $global$1.prefix + ":" + input.name; + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + _html(`${_text_resume($scope1_id, "a", greeting)} ${_text_resume($scope1_id, "b", count, 2)}`); + _scope($scope1_id, {}); + return 0; + } + }, $scope0_id, "b", 1, 1, 1, 0, 1); + _script($scope0_id, "a0"); + $scope0_reason ? _scope($scope0_id, { + f: greeting, + g: $global$1?.prefix, + h: count + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", greeting); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..b1700ffa7f0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/patches.debug.js @@ -0,0 +1,9 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/template.marko0": "yo:amy" +} + +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/template.marko0": "yo:bob" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/patches.js new file mode 100644 index 00000000000..ec7f13988ba --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/patches.js @@ -0,0 +1,9 @@ +// PATCH +{ + va0: "yo:amy" +} + +// PATCH +{ + va0: "yo:bob" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/render.debug.md new file mode 100644 index 00000000000..cc255ddb791 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/render.debug.md @@ -0,0 +1,56 @@ +# Render `{"name":"amy","$global":{"prefix":"hi"}}` +```html + + + hi:amy 0 + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + hi:amy 1 + +``` +## Change +``` +UPDATE: span::text@7 "0" => "1" +``` + +# Update `{"name":"amy","$global":{"prefix":"yo"}}` +```html + + + yo:amy 1 + +``` +## Change +``` +UPDATE: span::text@0 "hi:amy" => "yo:amy" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + span +``` + +# Update `{"name":"bob","$global":{"prefix":"yo"}}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/render.md new file mode 100644 index 00000000000..cc255ddb791 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/render.md @@ -0,0 +1,56 @@ +# Render `{"name":"amy","$global":{"prefix":"hi"}}` +```html + + + hi:amy 0 + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + hi:amy 1 + +``` +## Change +``` +UPDATE: span::text@7 "0" => "1" +``` + +# Update `{"name":"amy","$global":{"prefix":"yo"}}` +```html + + + yo:amy 1 + +``` +## Change +``` +UPDATE: span::text@0 "hi:amy" => "yo:amy" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + span +``` + +# Update `{"name":"bob","$global":{"prefix":"yo"}}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..7e69d144353 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/writes.debug.html @@ -0,0 +1,14 @@ +hi:amy + 0 + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/writes.html new file mode 100644 index 00000000000..f23ca4310f3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/__snapshots__/writes.html @@ -0,0 +1,12 @@ +hi:amy + 0 + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/sizes.json new file mode 100644 index 00000000000..0e50d951d76 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 7419, + "brotli": 3337 + } + }, + "html": { + "min": 424, + "brotli": 283 + }, + "patch": { + "min": 30, + "brotli": 34 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/template.marko new file mode 100644 index 00000000000..d3504ba5f3a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/template.marko @@ -0,0 +1,6 @@ + + + + + ${greeting} ${count} + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/test.ts new file mode 100644 index 00000000000..c866d488c3a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-derived-fill/test.ts @@ -0,0 +1,19 @@ +import type { TestConfig } from "../../main.test"; + +const click = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// A `$global`-derived value read inside client-owned structure delivers as +// a fill: each frame re-ships it (globals can change per response), so the +// revealed branch re-renders with the current derivation. +export const config: TestConfig = { + persisted: true, + steps: [ + { name: "amy", $global: { prefix: "hi" } }, + click, + { name: "amy", $global: { prefix: "yo" } }, + click, + { name: "bob", $global: { prefix: "yo" } }, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..3287bb34720 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,15 @@ +// template.marko +const $template = ""; +const $walks = " b%c"; +const $if_content__$global_brand = /*@__PURE__*/ _fill_join("__tests__/template.marko0", "$global_brand", /*@__PURE__*/ _if_closure("#text/1", 0, ($scope) => _text($scope["#text/0"], $scope._.$global_brand))); +const $if_content__setup = $if_content__$global_brand; +const $if = /*@__PURE__*/ _if("#text/1", " ", "D ", $if_content__setup); +const $on = /*@__PURE__*/ _let("on/2", ($scope) => $if($scope, $scope.on ? 0 : 1)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $on($scope, !$scope.on); +})); +function $setup($scope) { + $on($scope, true); + $setup__script($scope); +} +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..f65ad49ba54 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/dom.bundle.js @@ -0,0 +1,7 @@ +// template.marko +const $if_content__setup = /* @__PURE__ */ _fill_join("a0", 3, /*@__PURE__*/ _if_closure(1, 0, ($scope) => _text($scope.a, $scope._.d))); +const $if = /*@__PURE__*/ _if(1, " ", "D ", $if_content__setup); +const $on = /*@__PURE__*/ _let(2, ($scope) => $if($scope, $scope.c ? 0 : 1)); +const $setup__script = _script("a0", ($scope) => _on($scope.a, "click", function() { + $on($scope, !$scope.c); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..ca96ebcc3f6 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/html.bundle.debug.js @@ -0,0 +1,28 @@ +// template.marko +const $template = ""; +const $walks = " b%c"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0; b%;" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + let on = true; + _html(`${_el_resume($scope0_id, "#button/0")}`); + if ($scope0_reason) _if(() => { + if (on) { + const $scope1_id = _scope_id(); + _html(`${_text_resume($scope1_id, "#text/0", $global$1.brand)}`); + _scope($scope1_id, {}, "__tests__/template.marko", "3:2"); + return 0; + } + }, $scope0_id, "#text/1", 1, 1, 1, 0, 1); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + on, + $global_brand: $global$1?.brand + }, "__tests__/template.marko", 0, { + on: "1:6", + $global_brand: ["$global.brand"] + }) : _patch_value($scope0_id, "__tests__/template.marko0", $global$1?.brand); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..b579e3f1972 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/html.bundle.js @@ -0,0 +1,23 @@ +// template.marko +_shells({ a: "a !a0; b%;" }); +var template_default = _template_persisted("a", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + let on = true; + _html(`${_el_resume($scope0_id, "a")}`); + if ($scope0_reason) _if(() => { + { + const $scope1_id = _scope_id(); + _html(`${_text_resume($scope1_id, "a", $global$1.brand)}`); + _scope($scope1_id, {}); + return 0; + } + }, $scope0_id, "b", 1, 1, 1, 0, 1); + _script($scope0_id, "a0"); + $scope0_reason ? _scope($scope0_id, { + c: on, + d: $global$1?.brand + }) : _patch_value($scope0_id, "a0", $global$1?.brand); + _resume_branch($scope0_id); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..a29ef710f4f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/patches.debug.js @@ -0,0 +1,4 @@ +// PATCH +{ + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/template.marko0": "bmce" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/patches.js new file mode 100644 index 00000000000..5014312e4f3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/patches.js @@ -0,0 +1,4 @@ +// PATCH +{ + va0: "bmce" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/render.debug.md new file mode 100644 index 00000000000..e4c806dd6e0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/render.debug.md @@ -0,0 +1,55 @@ +# Render `{"$global":{"brand":"acme"}}` +```html + + + acme + +``` + +# Update `{"$global":{"brand":"bmce"}}` +```html + + + bmce + +``` +## Change +``` +UPDATE: em::text "acme" => "bmce" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + em +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + bmce + +``` +## Change +``` +INSERT: button + em +UPDATE: em::text " " => "bmce" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/render.md new file mode 100644 index 00000000000..e4c806dd6e0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/render.md @@ -0,0 +1,55 @@ +# Render `{"$global":{"brand":"acme"}}` +```html + + + acme + +``` + +# Update `{"$global":{"brand":"bmce"}}` +```html + + + bmce + +``` +## Change +``` +UPDATE: em::text "acme" => "bmce" +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + +``` +## Change +``` +REMOVE: button + em +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + bmce + +``` +## Change +``` +INSERT: button + em +UPDATE: em::text " " => "bmce" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..84f2d193645 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/writes.debug.html @@ -0,0 +1,11 @@ +acme + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/writes.html new file mode 100644 index 00000000000..cbd7afc47ac --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/__snapshots__/writes.html @@ -0,0 +1,9 @@ +acme + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/sizes.json new file mode 100644 index 00000000000..8738ddaf55f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 7338, + "brotli": 3293 + } + }, + "html": { + "min": 390, + "brotli": 270 + }, + "patch": { + "min": 13, + "brotli": 17 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/template.marko new file mode 100644 index 00000000000..984976d7a80 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/template.marko @@ -0,0 +1,5 @@ + + + + ${$global.brand} + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/test.ts new file mode 100644 index 00000000000..3de002c286b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-read-in-stateful/test.ts @@ -0,0 +1,18 @@ +import type { TestConfig } from "../../main.test"; + +const toggle = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// A direct `$global` member read inside client-owned structure hoists into +// a root derivation delivered as a fill: a patched global re-renders the +// read, and a re-shown branch renders the latest value. +export const config: TestConfig = { + persisted: true, + steps: [ + { $global: { brand: "acme" } }, + { $global: { brand: "bmce" } }, + toggle, + toggle, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-reads/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-reads/__snapshots__/dom.bundle.debug.js index 581d43b1985..93c53fa694c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-reads/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-reads/__snapshots__/dom.bundle.debug.js @@ -1,10 +1,7 @@ // template.marko const $template = "

"; const $walks = "D D lD m"; -function $setup($scope) { - _attr($scope["#h1/0"], "title", $scope.$global.locale); - _text($scope["#text/1"], $scope.$global.brand); -} +const $setup = () => {}; const $input_name = ($scope, input_name) => _text($scope["#text/2"], input_name); const $input = ($scope, input) => $input_name($scope, input.name); -var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, 0, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-reads/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-reads/sizes.json index 109fd4fd2fd..7699d512e85 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-reads/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-reads/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2285, - "brotli": 1159 + "min": 2268, + "brotli": 1146 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/dom.bundle.debug.js index 540ebbc0db1..b99c0c42ca1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/dom.bundle.debug.js @@ -2,12 +2,10 @@ const $template = "

"; const $walks = "E l bD m"; const $read = /*@__PURE__*/ _let("read/3", ($scope) => _text($scope["#text/2"], $scope.read)); -const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/1"], "click", function() { - $read($scope, $scope.$global.brand); -})); function $setup($scope) { - _text($scope["#text/0"], $scope.$global.brand); $read($scope, ""); - $setup__script($scope); } +const $global_brand__script = _script("__tests__/template.marko_0_$global_brand#4", ($scope) => _on($scope["#button/1"], "click", function() { + $read($scope, $scope.$global_brand); +})); var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/dom.bundle.js index 33dcaa78525..86abd299694 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/dom.bundle.js @@ -1,5 +1,5 @@ // template.marko const $read = /*@__PURE__*/ _let(3, ($scope) => _text($scope.c, $scope.d)); -const $setup__script = _script("a0", ($scope) => _on($scope.b, "click", function() { - $read($scope, $scope.$.brand); +_script("a0", ($scope) => _on($scope.b, "click", function() { + $read($scope, $scope.e); })); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/html.bundle.debug.js index 2d7c9d58e48..72c97b3f0bd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/html.bundle.debug.js @@ -1,14 +1,15 @@ // template.marko const $template = "

"; const $walks = "E l bD m"; -_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;E l bD ;

" }); +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0_$global_brand#4;E l bD ;

" }); var template_default = _template_persisted("__tests__/template.marko", (input) => { const $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); const $global$1 = $global(); let read = ""; _html(`

${_patch_text($scope0_id, "#text/0", $global$1.brand)}

${_el_resume($scope0_id, "#button/1")}

${_text_resume($scope0_id, "#text/2", read)}

`); - _script($scope0_id, "__tests__/template.marko_0"); - $scope0_reason && _scope($scope0_id, {}, "__tests__/template.marko", 0); + _script($scope0_id, "__tests__/template.marko_0_$global_brand#4"); + _patch_effect($scope0_id, "__tests__/template.marko_0_$global_brand#4", "$global_brand"); + $scope0_reason ? _scope($scope0_id, { $global_brand: $global$1?.brand }, "__tests__/template.marko", 0, { $global_brand: ["$global.brand"] }) : _patch_write($scope0_id, "$global_brand", $global$1?.brand); _resume_branch($scope0_id); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/html.bundle.js index eb1178b695b..2da349095d5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/html.bundle.js @@ -3,8 +3,10 @@ _shells({ a: "a !a0;E l bD ;

var template_default = _template_persisted("a", (input) => { const $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); - _html(`

${_patch_text($scope0_id, "a", $global().brand)}

${_el_resume($scope0_id, "b")}

${_text_resume($scope0_id, "c", "")}

`); + const $global$1 = $global(); + _html(`

${_patch_text($scope0_id, "a", $global$1.brand)}

${_el_resume($scope0_id, "b")}

${_text_resume($scope0_id, "c", "")}

`); _script($scope0_id, "a0"); - $scope0_reason && _scope($scope0_id, {}); + _patch_effect($scope0_id, "a0", "e"); + $scope0_reason ? _scope($scope0_id, { e: $global$1?.brand }) : _patch_write($scope0_id, "e", $global$1?.brand); _resume_branch($scope0_id); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/patches.debug.js index 9a0e805c1b5..46a66f6ade3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/patches.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/patches.debug.js @@ -3,7 +3,9 @@ "$global:": { brand: "Runtime" }, - "PatchText:#text/0": "Runtime" + "PatchText:#text/0": "Runtime", + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/template.marko_0_$global_brand#4": "$global_brand", + "PatchWrite:$global_brand": "Runtime" } // PATCH @@ -11,5 +13,7 @@ "$global:": { brand: $ }, - "PatchText:#text/0": "" + "PatchText:#text/0": "", + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/template.marko_0_$global_brand#4": "$global_brand", + "PatchWrite:$global_brand": $ } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/patches.js index 9bb365f71f3..7e1033ccbf3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/patches.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/patches.js @@ -3,7 +3,9 @@ $: { brand: "Runtime" }, - ta: "Runtime" + ta: "Runtime", + ea0: "e", + we: "Runtime" } // PATCH @@ -11,5 +13,7 @@ $: { brand: $ }, - ta: "" + ta: "", + ea0: "e", + we: $ } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/writes.debug.html index ddce9314978..7409ac04179 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/writes.debug.html @@ -6,8 +6,10 @@

Marko

WALKER_RUNTIME("M")("_"); M._.r = [_ => [0, { brand: "Marko" + }, { + $global_brand: "Marko" }], - "packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/template.marko_0 1" + "packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/template.marko_0_$global_brand#4 1" ]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/writes.html index 7c4bff00c63..2181bc826b8 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/__snapshots__/writes.html @@ -6,6 +6,8 @@

Marko

WALKER_RUNTIME("M")("_"); M._.r = [_ => [0, { brand: "Marko" + }, { + e: "Marko" }], "a0 1"]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/sizes.json index b234dfea61e..e8054322698 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-global-update/sizes.json @@ -1,16 +1,16 @@ { "dom": { "template.marko.page.mjs": { - "min": 3216, - "brotli": 1605 + "min": 3619, + "brotli": 1780 } }, "html": { - "min": 412, - "brotli": 277 + "min": 424, + "brotli": 280 }, "patch": { - "min": 55, - "brotli": 54 + "min": 89, + "brotli": 74 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-arrow-shadow/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-arrow-shadow/sizes.json index ccbe16cbfb1..397bcaa581e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-arrow-shadow/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-arrow-shadow/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7882, - "brotli": 3536 + "min": 7860, + "brotli": 3527 }, "files": { "tags/widget/index.marko": 468, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-arrow/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-arrow/sizes.json index cb3bafe309b..ab49eccaeef 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-arrow/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-arrow/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7466, - "brotli": 3357 + "min": 7444, + "brotli": 3355 }, "files": { "tags/widget/index.marko": 234, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-deep/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-deep/sizes.json index 3137665412e..31b9f5a51e4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-deep/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-deep/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7870, - "brotli": 3478 + "min": 7848, + "brotli": 3472 }, "files": { "tags/l1/tags/l2/tags/l3/index.marko": 168, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-diamond/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-diamond/sizes.json index f9a5b5c485f..d43b9d5937d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-diamond/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-diamond/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7683, - "brotli": 3412 + "min": 7661, + "brotli": 3405 }, "files": { "tags/dia-d/index.marko": 155, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-fill/sizes.json index 17f558104a9..b8d0db59a7b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-fill/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-fill/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7652, - "brotli": 3417 + "min": 7630, + "brotli": 3411 }, "files": { "tags/card/tags/badge/index.marko": 163, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-dom.debug.txt index 55c70d5820a..36881e6e9cb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-dom.debug.txt +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-dom.debug.txt @@ -3,7 +3,7 @@ 2 |
3 | > 4 | - | ^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads `$global` (it would go stale). + | ^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads a `$global`-derived value (it would go stale). 5 | 6 | 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-dom.txt index 55c70d5820a..36881e6e9cb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-dom.txt +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-dom.txt @@ -3,7 +3,7 @@ 2 |
3 | > 4 | - | ^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads `$global` (it would go stale). + | ^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads a `$global`-derived value (it would go stale). 5 | 6 | 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-html.debug.txt index 55c70d5820a..36881e6e9cb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-html.debug.txt +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-html.debug.txt @@ -3,7 +3,7 @@ 2 |
3 | > 4 | - | ^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads `$global` (it would go stale). + | ^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads a `$global`-derived value (it would go stale). 5 | 6 | 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-html.txt index 55c70d5820a..36881e6e9cb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-html.txt +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-global/__snapshots__/error-compile-html.txt @@ -3,7 +3,7 @@ 2 |
3 | > 4 | - | ^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads `$global` (it would go stale). + | ^^^^^^^^ Persisted templates cannot patch this faithfully yet: a child inside client-owned structure reads a `$global`-derived value (it would go stale). 5 | 6 | 7 |
\ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-server-fn/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-server-fn/sizes.json index 19e5b568ff7..d39c95d3e83 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-server-fn/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-server-fn/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7731, - "brotli": 3476 + "min": 7702, + "brotli": 3471 }, "files": { "tags/card/index.marko": 143, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-server-required/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-server-required/sizes.json index 5dfcefb859a..22b11b2ef0b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-server-required/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-server-required/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8645, - "brotli": 3827 + "min": 8606, + "brotli": 3809 }, "files": { "tags/outer/tags/inner/index.marko": 219, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-spread/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-spread/sizes.json index fd782c0bf5a..18d6102cc97 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-spread/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-spread/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 7534, - "brotli": 3364 + "min": 7512, + "brotli": 3360 }, "files": { "tags/mid/tags/leaf/index.marko": 163, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-unfed-structural/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-unfed-structural/sizes.json index de8952c118d..44dc4f936d2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-unfed-structural/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-grand-unfed-structural/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 8841, - "brotli": 3922 + "min": 8802, + "brotli": 3908 }, "files": { "tags/badge/index.marko": 314, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-handler-input/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-handler-input/sizes.json index f23b7eda774..96b0868fe91 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-handler-input/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-handler-input/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2935, - "brotli": 1467 + "min": 2918, + "brotli": 1454 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-input-branches/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-input-branches/sizes.json index 9f1deb44c6d..6d65c3e1c15 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-input-branches/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-input-branches/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8385, - "brotli": 3828 + "min": 8367, + "brotli": 3823 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-intersection/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-intersection/sizes.json index 19ae151c1ca..ea84d735541 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-intersection/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-intersection/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 4029, - "brotli": 1939 + "min": 4007, + "brotli": 1925 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..96b132f5ae5 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,32 @@ +// child.marko +const $template = ""; +const $walks = " D%c%l"; +const $count = /*@__PURE__*/ _fill_let("__tests__/child.marko0", "count/6", ($scope) => _text($scope["#text/2"], $scope.count)); +const $setup__script = _script("__tests__/child.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $count($scope, 0); + $setup__script($scope); +} +const $input_label = ($scope, input_label) => _text($scope["#text/1"], input_label); +const $input = ($scope, input) => $input_label($scope, input.label); +var child_default = /*@__PURE__*/ _template("__tests__/child.marko", $template, $walks, $setup, $input); + +// template.marko +const $template = "
"; +const $walks = "D%/&l"; +const $load_Child_trigger = /*@__PURE__*/ _load_event_trigger("click", "body"); +let $load_Child_setup = /*@__PURE__*/ _load_setup("#text/0", "#childScope/1", /*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.setup.mjs")), "ready:__tests__/child.marko"); +let $load_Child_tag_input_label = /*@__PURE__*/ _load_signal(/*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.input_label.mjs"))); +const $setup = $load_Child_setup; +const $input_label = ($scope, input_label) => $load_Child_tag_input_label($scope["#childScope/1"], input_label); +const $input = ($scope, input) => $input_label($scope, input.label); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); + +// v:child.marko.setup.js +const _ = [ + $template, + $walks, + $setup +]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..e999323991e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/dom.bundle.js @@ -0,0 +1,5 @@ +// child.marko +const $count = /*@__PURE__*/ _fill_let("a0", 6, ($scope) => _text($scope.c, $scope.g)); +const $setup__script = _script("a0", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.g + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..597f4002194 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/html.bundle.debug.js @@ -0,0 +1,34 @@ +// child.marko +const $template$1 = ""; +const $walks$1 = " D%c%l"; +_shells({ "__tests__/child.marko": "__tests__/child.marko !__tests__/child.marko_0; D%c%;" }); +var child_default = _template_persisted("__tests__/child.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + _script($scope0_id, "__tests__/child.marko_0"); + _patch_value($scope0_id, "__tests__/child.marko0", count, 1); + $scope0_reason && _scope($scope0_id, { count }, "__tests__/child.marko", 0, { count: "1:6" }); + _resume_branch($scope0_id); +}, 0, 0); + +// template.marko +const $Child_withLoadAssets = withLoadAssets(child_default, "ready:__tests__/child.marko", [{ + type: "on-click", + selector: "body" +}], 1); +const $template = "
"; +const $walks = "D%/&l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko __tests__/template.marko_0_#text#0/init;D%/&;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _set_serialize_reason({ 0: _mask_group($scope0_owned, 0) }); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "#childScope/1", $childScope); + $Child_withLoadAssets({ label: input.label }); + _html("
"); + $scope0_reason && _scope($scope0_id, { "#childScope/1": _existing_scope($childScope) }, "__tests__/template.marko", 0); +}, 1, () => [$Child_withLoadAssets]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..972f3a9d324 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/html.bundle.js @@ -0,0 +1,30 @@ +// child.marko +_shells({ a: "a !a0; D%c%;" }); +var child_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + _script($scope0_id, "a0"); + _patch_value($scope0_id, "a0", count, 1); + $scope0_reason && _scope($scope0_id, { g: count }); + _resume_branch($scope0_id); +}, 0, 0); + +// template.marko +const $Child_withLoadAssets = withLoadAssets(child_default, "_a", [{ + type: "on-click", + selector: "body" +}], 1); +_shells({ b: "b b1;D%/&;
" }); +var template_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _set_serialize_reason({ 0: _mask_group($scope0_owned, 0) }); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "b", $childScope); + $Child_withLoadAssets({ label: input.label }); + _html("
"); + $scope0_reason && _scope($scope0_id, { b: _existing_scope($childScope) }); +}, 1, () => [$Child_withLoadAssets]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..7426232b28c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/patches.debug.js @@ -0,0 +1,8 @@ +// PATCH +ready({ + "ready:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/child.marko": [{ + "PatchChild:#childScope/1": { + "PatchText:#text/1": "b" + } + }] +}) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/patches.js new file mode 100644 index 00000000000..7960de2f234 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/patches.js @@ -0,0 +1,8 @@ +// PATCH +y({ + _a: [{ + cb: { + tb: "b" + } + }] +}) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/render-ssr.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/render-ssr.debug.md new file mode 100644 index 00000000000..e3c3d1d234e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/render-ssr.debug.md @@ -0,0 +1,21 @@ +# Render `{"label":"a"}` +```html +
+ +
+``` + +# Update +```js +setTimeout(() => document.body.click()); +``` + +# Update `{"label":"b"}` +## Console +``` +ERROR "The lazy module for \"ready:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/child.marko\" failed to load; its server-rendered content cannot become interactive." +``` + +## Patch rejected (navigate) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/render-ssr.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/render-ssr.md new file mode 100644 index 00000000000..84c11528d88 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/render-ssr.md @@ -0,0 +1,17 @@ +# Render `{"label":"a"}` +```html +
+ +
+``` + +# Update +```js +setTimeout(() => document.body.click()); +``` + +# Update `{"label":"b"}` + +## Patch rejected (navigate) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..8904f173a0e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/writes.debug.html @@ -0,0 +1,30 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/writes.html new file mode 100644 index 00000000000..4ce0ed57eb2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/__snapshots__/writes.html @@ -0,0 +1,21 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/child.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/child.marko new file mode 100644 index 00000000000..ceb9cd77764 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/child.marko @@ -0,0 +1,2 @@ + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/sizes.json new file mode 100644 index 00000000000..10529a1d5cf --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/sizes.json @@ -0,0 +1,28 @@ +{ + "dom": { + "child.marko.load.mjs": { + "min": 98, + "brotli": 80 + }, + "template.marko.page.mjs": { + "min": 1945, + "brotli": 949 + }, + "child.mjs": { + "min": 535, + "brotli": 326 + }, + "shared": { + "min": 5686, + "brotli": 2610 + } + }, + "html": { + "min": 776, + "brotli": 468 + }, + "patch": { + "min": 24, + "brotli": 28 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/template.marko new file mode 100644 index 00000000000..878c4704051 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/template.marko @@ -0,0 +1,3 @@ +import Child from "./child.marko" with { load: "on-click body" } + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/test.ts new file mode 100644 index 00000000000..a3700ec608a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-chunk-failed/test.ts @@ -0,0 +1,19 @@ +import type { TestConfig } from "../../main.test"; + +const load = (document: Document) => { + setTimeout(() => document.body.click()); +}; + +// A patch defers on the lazy channel; the loader script evaluates but its +// inner template chunk import rejects (deploy skew): the load entry reports +// the failure so the pending `applyPatch` promise settles as rejected (the +// caller navigates) instead of hanging. +export const config: TestConfig = { + // Debug intentionally logs the load-failure diagnostic optimize cannot. + skip_parity: true, + persisted: true, + equivalent: false, + expect_rejection: true, + reject_load: ["child.mjs"], + steps: [{ label: "a" }, load, { label: "b" }], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/dom.bundle.debug.js index 35c27c1dba9..12be49e6eff 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/dom.bundle.debug.js @@ -18,9 +18,9 @@ const $template = "
"; const $walks = " b"; const $setup = () => {}; const $load_Child_trigger = /*@__PURE__*/ _load_event_trigger("click", "body"); -let $load_Child_setup = /*@__PURE__*/ _load_setup("#text/0", "#childScope/1", /*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.setup.mjs"))); +let $load_Child_setup = _resume("__tests__/template.marko_1_#text#0/init", /*@__PURE__*/ _load_setup("#text/0", "#childScope/1", /*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.setup.mjs")), "ready:__tests__/child.marko")); let $load_Child_tag_input_label = /*@__PURE__*/ _load_signal(/*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.input_label.mjs"))); -const $if_content__input_label = /*@__PURE__*/ _if_closure("#main/0", 0, ($scope) => $load_Child_tag_input_label($scope["#childScope/1"], $scope._.input_label)); +const $if_content__input_label = _resume_init_if_closure("__tests__/template.marko_1_input_label#4/init", "#main/0", 0, ($scope) => $load_Child_tag_input_label($scope["#childScope/1"], $scope._.input_label)); const $if_content__setup = ($scope) => { $if_content__input_label._($scope); $load_Child_setup($scope); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/dom.bundle.js index e999323991e..3317fa09712 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/dom.bundle.js @@ -1,5 +1,25 @@ +// template.marko +const $load_Child_trigger = /*@__PURE__*/ _load_event_trigger("click", "body"); +let $load_Child_setup = _resume("b3", /*@__PURE__*/ _load_setup(0, 1, /*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.setup.mjs")), "_a")); +let $load_Child_tag_input_label = /*@__PURE__*/ _load_signal(/*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.input_label.mjs"))); +const $if_content__input_label = _init_if_closure("b2", 0, 0, ($scope) => $load_Child_tag_input_label($scope.b, $scope._.e)); + // child.marko +const $template = ""; +const $walks = " D%c%l"; const $count = /*@__PURE__*/ _fill_let("a0", 6, ($scope) => _text($scope.c, $scope.g)); const $setup__script = _script("a0", ($scope) => _on($scope.a, "click", function() { $count($scope, +$scope.g + 1); })); +function $setup($scope) { + $count($scope, 0); + $setup__script($scope); +} +const $input_label = ($scope, input_label) => _text($scope.b, input_label); + +// v:child.marko.setup.js +const _ = [ + $template, + $walks, + $setup +]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/html.bundle.debug.js index 6b0c0ce2791..74b552203f7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/html.bundle.debug.js @@ -17,10 +17,13 @@ var child_default = _template_persisted("__tests__/child.marko", (input) => { const $Child_withLoadAssets = withLoadAssets(child_default, "ready:__tests__/child.marko", [{ type: "on-click", selector: "body" -}]); +}], 1); const $template = "
"; const $walks = " b"; -_shells({ "__tests__/template.marko": "__tests__/template.marko; ;
" }); +_shells({ + "__tests__/template.marko": "__tests__/template.marko; ;
", + "__tests__/template.marko_1*shell": "__tests__/template.marko_1*shell __tests__/template.marko_1_input_label#4/init __tests__/template.marko_1_#text#0/init;b%/&;" +}); var template_default = _template_persisted("__tests__/template.marko", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_show = _source_guard($scope0_reason, 1); const $scope0_id = _scope_id(); @@ -38,7 +41,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = }, "__tests__/template.marko", "4:4"); return 0; } - }, $scope0_id, "#main/0", 1, $sg__input_show, $sg__input_show, void 0, void 0, [0]); + }, $scope0_id, "#main/0", 1, $sg__input_show, $sg__input_show, void 0, void 0, ["__tests__/template.marko_1*shell"]); _html(`
${_el_resume($scope0_id, "#main/0", $sg__input_show)}`); $scope0_reason && _scope($scope0_id, { input_label: input.label }, "__tests__/template.marko", 0, { input_label: ["input.label"] }); }, 1, () => [$Child_withLoadAssets]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/html.bundle.js index e79988d91aa..b2bd4f35f09 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/html.bundle.js @@ -15,8 +15,11 @@ var child_default = _template_persisted("a", (input) => { const $Child_withLoadAssets = withLoadAssets(child_default, "_a", [{ type: "on-click", selector: "body" -}]); -_shells({ b: "b; ;
" }); +}], 1); +_shells({ + b: "b; ;
", + b0: "b0 b2 b3;b%/&;" +}); var template_default = _template_persisted("b", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(), $sg__input_show = _source_guard($scope0_reason, 1); const $scope0_id = _scope_id(); @@ -34,7 +37,7 @@ var template_default = _template_persisted("b", (input) => { }); return 0; } - }, $scope0_id, "a", 1, $sg__input_show, $sg__input_show, void 0, void 0, [0]); + }, $scope0_id, "a", 1, $sg__input_show, $sg__input_show, void 0, void 0, ["b0"]); _html(`
${_el_resume($scope0_id, "a", $sg__input_show)}`); $scope0_reason && _scope($scope0_id, { e: input.label }); }, 1, () => [$Child_withLoadAssets]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/patches.debug.js index e2351ca8920..bc1cd45ce26 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/patches.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/patches.debug.js @@ -1,7 +1,7 @@ // PATCH -ready({ +(ready({ "ready:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/child.marko": [{ - "PatchBranch:#main/0": [{ + "PatchChild:BranchScopes:#main/0": { "PatchChild:#childScope/1": { "PatchText:#text/1": "b", "PatchSetup:": { @@ -9,9 +9,11 @@ ready({ "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/child.marko0": 0 } } - }] + } }] -}) +}), [`packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/template.marko_1*shell packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/template.marko_1_input_label#4/init packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/template.marko_1_#text#0/init;b%/&;`, { + "PatchBranch:#main/0": "packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/template.marko_1*shell" +}]) // PATCH { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/patches.js index d7e0f1a9d67..eee3d760c69 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/patches.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/patches.js @@ -1,7 +1,7 @@ // PATCH -y({ +(y({ _a: [{ - ba: [{ + cAa: { cb: { tb: "b", s: { @@ -9,9 +9,11 @@ y({ va0: 0 } } - }] + } }] -}) +}), [`b0 b2 b3;b%/&;`, { + ba: "b0" +}]) // PATCH { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/render-ssr.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/render-ssr.debug.md index e966bd0e7bc..3d911cd029f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/render-ssr.debug.md +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/render-ssr.debug.md @@ -13,17 +13,6 @@ setTimeout(() => document.body.click()); ``` # Update `{"show":true,"label":"b"}` -```html -
- -
-``` -## Change -``` -UPDATE: main > button::text@0 "a" => "b" -``` # Update ```js @@ -32,7 +21,7 @@ document.querySelector("button").click(); ```html
``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/render-ssr.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/render-ssr.md index e966bd0e7bc..3d911cd029f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/render-ssr.md +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/render-ssr.md @@ -13,17 +13,6 @@ setTimeout(() => document.body.click()); ``` # Update `{"show":true,"label":"b"}` -```html -
- -
-``` -## Change -``` -UPDATE: main > button::text@0 "a" => "b" -``` # Update ```js @@ -32,7 +21,7 @@ document.querySelector("button").click(); ```html
``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/writes.debug.html index 82bb6a3a0c6..4d8721427c3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-conditional/__snapshots__/writes.debug.html @@ -4,9 +4,11 @@ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/__snapshots__/writes.html new file mode 100644 index 00000000000..7ad6fe0a4a1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/__snapshots__/writes.html @@ -0,0 +1,8 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/child.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/child.marko new file mode 100644 index 00000000000..ceb9cd77764 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/child.marko @@ -0,0 +1,2 @@ + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/sizes.json new file mode 100644 index 00000000000..581c1c5acb9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/sizes.json @@ -0,0 +1,32 @@ +{ + "dom": { + "child.marko.load.mjs": { + "min": 98, + "brotli": 81 + }, + "template.marko.page.mjs": { + "min": 3978, + "brotli": 1919 + }, + "child.mjs": { + "min": 692, + "brotli": 414 + }, + "v:child.marko.setup.mjs": { + "min": 95, + "brotli": 81 + }, + "shared": { + "min": 8185, + "brotli": 3564 + } + }, + "html": { + "min": 342, + "brotli": 242 + }, + "patch": { + "min": 88, + "brotli": 80 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/template.marko new file mode 100644 index 00000000000..d733dd19d5d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/template.marko @@ -0,0 +1,7 @@ +import Child from "./child.marko" with { load: "render" } + +
+ + + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/test.ts new file mode 100644 index 00000000000..6c7590b55d8 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-construct/test.ts @@ -0,0 +1,16 @@ +import type { TestConfig } from "../../main.test"; +import { wait } from "../../utils/resolve"; + +// A patch REVEALS the branch holding a not-yet-loaded lazy child: the shell +// ships the site's marker only, the construct starts the client-side load, +// and the loaded module drives the child's ready channel so the deferred +// frame data drains and the page becomes interactive. +export const config: TestConfig = { + persisted: true, + equivalent: false, + steps: [{ show: false, label: "a" }, { show: true, label: "a" }, wait, click], +}; + +function click(document: Document) { + document.querySelector("button")!.click(); +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..96b132f5ae5 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,32 @@ +// child.marko +const $template = ""; +const $walks = " D%c%l"; +const $count = /*@__PURE__*/ _fill_let("__tests__/child.marko0", "count/6", ($scope) => _text($scope["#text/2"], $scope.count)); +const $setup__script = _script("__tests__/child.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $count($scope, 0); + $setup__script($scope); +} +const $input_label = ($scope, input_label) => _text($scope["#text/1"], input_label); +const $input = ($scope, input) => $input_label($scope, input.label); +var child_default = /*@__PURE__*/ _template("__tests__/child.marko", $template, $walks, $setup, $input); + +// template.marko +const $template = "
"; +const $walks = "D%/&l"; +const $load_Child_trigger = /*@__PURE__*/ _load_event_trigger("click", "body"); +let $load_Child_setup = /*@__PURE__*/ _load_setup("#text/0", "#childScope/1", /*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.setup.mjs")), "ready:__tests__/child.marko"); +let $load_Child_tag_input_label = /*@__PURE__*/ _load_signal(/*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.input_label.mjs"))); +const $setup = $load_Child_setup; +const $input_label = ($scope, input_label) => $load_Child_tag_input_label($scope["#childScope/1"], input_label); +const $input = ($scope, input) => $input_label($scope, input.label); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); + +// v:child.marko.setup.js +const _ = [ + $template, + $walks, + $setup +]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..e999323991e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/dom.bundle.js @@ -0,0 +1,5 @@ +// child.marko +const $count = /*@__PURE__*/ _fill_let("a0", 6, ($scope) => _text($scope.c, $scope.g)); +const $setup__script = _script("a0", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.g + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..597f4002194 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/html.bundle.debug.js @@ -0,0 +1,34 @@ +// child.marko +const $template$1 = ""; +const $walks$1 = " D%c%l"; +_shells({ "__tests__/child.marko": "__tests__/child.marko !__tests__/child.marko_0; D%c%;" }); +var child_default = _template_persisted("__tests__/child.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + _script($scope0_id, "__tests__/child.marko_0"); + _patch_value($scope0_id, "__tests__/child.marko0", count, 1); + $scope0_reason && _scope($scope0_id, { count }, "__tests__/child.marko", 0, { count: "1:6" }); + _resume_branch($scope0_id); +}, 0, 0); + +// template.marko +const $Child_withLoadAssets = withLoadAssets(child_default, "ready:__tests__/child.marko", [{ + type: "on-click", + selector: "body" +}], 1); +const $template = "
"; +const $walks = "D%/&l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko __tests__/template.marko_0_#text#0/init;D%/&;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _set_serialize_reason({ 0: _mask_group($scope0_owned, 0) }); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "#childScope/1", $childScope); + $Child_withLoadAssets({ label: input.label }); + _html("
"); + $scope0_reason && _scope($scope0_id, { "#childScope/1": _existing_scope($childScope) }, "__tests__/template.marko", 0); +}, 1, () => [$Child_withLoadAssets]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..972f3a9d324 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/html.bundle.js @@ -0,0 +1,30 @@ +// child.marko +_shells({ a: "a !a0; D%c%;" }); +var child_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + _script($scope0_id, "a0"); + _patch_value($scope0_id, "a0", count, 1); + $scope0_reason && _scope($scope0_id, { g: count }); + _resume_branch($scope0_id); +}, 0, 0); + +// template.marko +const $Child_withLoadAssets = withLoadAssets(child_default, "_a", [{ + type: "on-click", + selector: "body" +}], 1); +_shells({ b: "b b1;D%/&;
" }); +var template_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _set_serialize_reason({ 0: _mask_group($scope0_owned, 0) }); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "b", $childScope); + $Child_withLoadAssets({ label: input.label }); + _html("
"); + $scope0_reason && _scope($scope0_id, { b: _existing_scope($childScope) }); +}, 1, () => [$Child_withLoadAssets]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..41a5f50cb01 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/patches.debug.js @@ -0,0 +1,8 @@ +// PATCH +ready({ + "ready:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/child.marko": [{ + "PatchChild:#childScope/1": { + "PatchText:#text/1": "b" + } + }] +}) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/patches.js new file mode 100644 index 00000000000..7960de2f234 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/patches.js @@ -0,0 +1,8 @@ +// PATCH +y({ + _a: [{ + cb: { + tb: "b" + } + }] +}) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/render-ssr.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/render-ssr.debug.md new file mode 100644 index 00000000000..82cd59d54bc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/render-ssr.debug.md @@ -0,0 +1,23 @@ +# Render `{"label":"a"}` +```html +
+ +
+``` + +# Update +```js +setTimeout(() => document.body.click()); +``` + +# Update +## Console +``` +ERROR "The lazy module for \"ready:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/child.marko\" failed to load; its server-rendered content cannot become interactive." +``` + +# Update `{"label":"b"}` + +## Patch rejected (navigate) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/render-ssr.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/render-ssr.md new file mode 100644 index 00000000000..84c11528d88 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/render-ssr.md @@ -0,0 +1,17 @@ +# Render `{"label":"a"}` +```html +
+ +
+``` + +# Update +```js +setTimeout(() => document.body.click()); +``` + +# Update `{"label":"b"}` + +## Patch rejected (navigate) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..812bb2227a6 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/writes.debug.html @@ -0,0 +1,30 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/writes.html new file mode 100644 index 00000000000..4ce0ed57eb2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/__snapshots__/writes.html @@ -0,0 +1,21 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/child.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/child.marko new file mode 100644 index 00000000000..ceb9cd77764 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/child.marko @@ -0,0 +1,2 @@ + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/sizes.json new file mode 100644 index 00000000000..10529a1d5cf --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/sizes.json @@ -0,0 +1,28 @@ +{ + "dom": { + "child.marko.load.mjs": { + "min": 98, + "brotli": 80 + }, + "template.marko.page.mjs": { + "min": 1945, + "brotli": 949 + }, + "child.mjs": { + "min": 535, + "brotli": 326 + }, + "shared": { + "min": 5686, + "brotli": 2610 + } + }, + "html": { + "min": 776, + "brotli": 468 + }, + "patch": { + "min": 24, + "brotli": 28 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/template.marko new file mode 100644 index 00000000000..878c4704051 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/template.marko @@ -0,0 +1,3 @@ +import Child from "./child.marko" with { load: "on-click body" } + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/test.ts new file mode 100644 index 00000000000..297e4f402a1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-failed-before-patch/test.ts @@ -0,0 +1,19 @@ +import type { TestConfig } from "../../main.test"; +import { wait } from "../../utils/resolve"; + +const load = (document: Document) => { + setTimeout(() => document.body.click()); +}; + +// The lazy chunk fails with NO patch pending on its channel: the page must +// stay as it is (no reload), and a later frame naming the dead channel +// rejects into navigation instead of parking forever. +export const config: TestConfig = { + // Debug intentionally logs the load-failure diagnostic optimize cannot. + skip_parity: true, + persisted: true, + equivalent: false, + expect_rejection: true, + reject_load: ["child.mjs"], + steps: [{ label: "a" }, load, wait, { label: "b" }], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..96b132f5ae5 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,32 @@ +// child.marko +const $template = ""; +const $walks = " D%c%l"; +const $count = /*@__PURE__*/ _fill_let("__tests__/child.marko0", "count/6", ($scope) => _text($scope["#text/2"], $scope.count)); +const $setup__script = _script("__tests__/child.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $count($scope, 0); + $setup__script($scope); +} +const $input_label = ($scope, input_label) => _text($scope["#text/1"], input_label); +const $input = ($scope, input) => $input_label($scope, input.label); +var child_default = /*@__PURE__*/ _template("__tests__/child.marko", $template, $walks, $setup, $input); + +// template.marko +const $template = "
"; +const $walks = "D%/&l"; +const $load_Child_trigger = /*@__PURE__*/ _load_event_trigger("click", "body"); +let $load_Child_setup = /*@__PURE__*/ _load_setup("#text/0", "#childScope/1", /*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.setup.mjs")), "ready:__tests__/child.marko"); +let $load_Child_tag_input_label = /*@__PURE__*/ _load_signal(/*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.input_label.mjs"))); +const $setup = $load_Child_setup; +const $input_label = ($scope, input_label) => $load_Child_tag_input_label($scope["#childScope/1"], input_label); +const $input = ($scope, input) => $input_label($scope, input.label); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); + +// v:child.marko.setup.js +const _ = [ + $template, + $walks, + $setup +]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..e999323991e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/dom.bundle.js @@ -0,0 +1,5 @@ +// child.marko +const $count = /*@__PURE__*/ _fill_let("a0", 6, ($scope) => _text($scope.c, $scope.g)); +const $setup__script = _script("a0", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.g + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..597f4002194 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/html.bundle.debug.js @@ -0,0 +1,34 @@ +// child.marko +const $template$1 = ""; +const $walks$1 = " D%c%l"; +_shells({ "__tests__/child.marko": "__tests__/child.marko !__tests__/child.marko_0; D%c%;" }); +var child_default = _template_persisted("__tests__/child.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + _script($scope0_id, "__tests__/child.marko_0"); + _patch_value($scope0_id, "__tests__/child.marko0", count, 1); + $scope0_reason && _scope($scope0_id, { count }, "__tests__/child.marko", 0, { count: "1:6" }); + _resume_branch($scope0_id); +}, 0, 0); + +// template.marko +const $Child_withLoadAssets = withLoadAssets(child_default, "ready:__tests__/child.marko", [{ + type: "on-click", + selector: "body" +}], 1); +const $template = "
"; +const $walks = "D%/&l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko __tests__/template.marko_0_#text#0/init;D%/&;
" }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _set_serialize_reason({ 0: _mask_group($scope0_owned, 0) }); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "#childScope/1", $childScope); + $Child_withLoadAssets({ label: input.label }); + _html("
"); + $scope0_reason && _scope($scope0_id, { "#childScope/1": _existing_scope($childScope) }, "__tests__/template.marko", 0); +}, 1, () => [$Child_withLoadAssets]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..972f3a9d324 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/html.bundle.js @@ -0,0 +1,30 @@ +// child.marko +_shells({ a: "a !a0; D%c%;" }); +var child_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + _script($scope0_id, "a0"); + _patch_value($scope0_id, "a0", count, 1); + $scope0_reason && _scope($scope0_id, { g: count }); + _resume_branch($scope0_id); +}, 0, 0); + +// template.marko +const $Child_withLoadAssets = withLoadAssets(child_default, "_a", [{ + type: "on-click", + selector: "body" +}], 1); +_shells({ b: "b b1;D%/&;
" }); +var template_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
"); + _set_serialize_reason({ 0: _mask_group($scope0_owned, 0) }); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "b", $childScope); + $Child_withLoadAssets({ label: input.label }); + _html("
"); + $scope0_reason && _scope($scope0_id, { b: _existing_scope($childScope) }); +}, 1, () => [$Child_withLoadAssets]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..afac4e46c91 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/patches.debug.js @@ -0,0 +1,8 @@ +// PATCH +ready({ + "ready:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/child.marko": [{ + "PatchChild:#childScope/1": { + "PatchText:#text/1": "b" + } + }] +}) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/patches.js new file mode 100644 index 00000000000..7960de2f234 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/patches.js @@ -0,0 +1,8 @@ +// PATCH +y({ + _a: [{ + cb: { + tb: "b" + } + }] +}) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/render-ssr.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/render-ssr.debug.md new file mode 100644 index 00000000000..372aa65f749 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/render-ssr.debug.md @@ -0,0 +1,22 @@ +# Render `{"label":"a"}` +```html +
+ +
+``` + +# Update +```js +setTimeout(() => document.body.click()); +``` + +# Update `{"label":"b"}` +## Console +``` +ERROR "The lazy module for \"ready:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/child.marko\" failed to load; its server-rendered content cannot become interactive." +ERROR "The lazy module for \"ready:packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/child.marko\" failed to load; its server-rendered content cannot become interactive." +``` + +## Patch rejected (navigate) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/render-ssr.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/render-ssr.md new file mode 100644 index 00000000000..84c11528d88 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/render-ssr.md @@ -0,0 +1,17 @@ +# Render `{"label":"a"}` +```html +
+ +
+``` + +# Update +```js +setTimeout(() => document.body.click()); +``` + +# Update `{"label":"b"}` + +## Patch rejected (navigate) diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..cbe1c181af9 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/writes.debug.html @@ -0,0 +1,30 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/writes.html new file mode 100644 index 00000000000..4ce0ed57eb2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/__snapshots__/writes.html @@ -0,0 +1,21 @@ +
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/child.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/child.marko new file mode 100644 index 00000000000..ceb9cd77764 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/child.marko @@ -0,0 +1,2 @@ + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/sizes.json new file mode 100644 index 00000000000..10529a1d5cf --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/sizes.json @@ -0,0 +1,28 @@ +{ + "dom": { + "child.marko.load.mjs": { + "min": 98, + "brotli": 80 + }, + "template.marko.page.mjs": { + "min": 1945, + "brotli": 949 + }, + "child.mjs": { + "min": 535, + "brotli": 326 + }, + "shared": { + "min": 5686, + "brotli": 2610 + } + }, + "html": { + "min": 776, + "brotli": 468 + }, + "patch": { + "min": 24, + "brotli": 28 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/template.marko new file mode 100644 index 00000000000..878c4704051 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/template.marko @@ -0,0 +1,3 @@ +import Child from "./child.marko" with { load: "on-click body" } + +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/test.ts new file mode 100644 index 00000000000..c296b5353ca --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-load-failed/test.ts @@ -0,0 +1,19 @@ +import type { TestConfig } from "../../main.test"; + +const load = (document: Document) => { + setTimeout(() => document.body.click()); +}; + +// A patch defers on the lazy channel, then the loader SCRIPT fails at the +// network level (script error, no evaluation): the +// pending `applyPatch` promise settles as rejected (the caller navigates) +// instead of hanging, and later frames naming the channel reject outright. +export const config: TestConfig = { + // Debug intentionally logs the load-failure diagnostic optimize cannot. + skip_parity: true, + persisted: true, + equivalent: false, + expect_rejection: true, + reject_load: ["load.mjs"], + steps: [{ label: "a" }, load, { label: "b" }], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/dom.bundle.debug.js index 7773ef04318..96b132f5ae5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/dom.bundle.debug.js @@ -17,7 +17,7 @@ var child_default = /*@__PURE__*/ _template("__tests__/child.marko", $template, const $template = "
"; const $walks = "D%/&l"; const $load_Child_trigger = /*@__PURE__*/ _load_event_trigger("click", "body"); -let $load_Child_setup = /*@__PURE__*/ _load_setup("#text/0", "#childScope/1", /*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.setup.mjs"))); +let $load_Child_setup = /*@__PURE__*/ _load_setup("#text/0", "#childScope/1", /*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.setup.mjs")), "ready:__tests__/child.marko"); let $load_Child_tag_input_label = /*@__PURE__*/ _load_signal(/*@__PURE__*/ $load_Child_trigger(() => import("./v:child.marko.input_label.mjs"))); const $setup = $load_Child_setup; const $input_label = ($scope, input_label) => $load_Child_tag_input_label($scope["#childScope/1"], input_label); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/html.bundle.debug.js index e3a3c2cf7de..597f4002194 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/html.bundle.debug.js @@ -17,9 +17,10 @@ var child_default = _template_persisted("__tests__/child.marko", (input) => { const $Child_withLoadAssets = withLoadAssets(child_default, "ready:__tests__/child.marko", [{ type: "on-click", selector: "body" -}]); +}], 1); const $template = "
"; const $walks = "D%/&l"; +_shells({ "__tests__/template.marko": "__tests__/template.marko __tests__/template.marko_0_#text#0/init;D%/&;
" }); var template_default = _template_persisted("__tests__/template.marko", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/html.bundle.js index 11352a39970..972f3a9d324 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/html.bundle.js @@ -15,7 +15,8 @@ var child_default = _template_persisted("a", (input) => { const $Child_withLoadAssets = withLoadAssets(child_default, "_a", [{ type: "on-click", selector: "body" -}]); +}], 1); +_shells({ b: "b b1;D%/&;
" }); var template_default = _template_persisted("b", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/render-ssr.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/render-ssr.debug.md index eac65b8c42e..f6f86e33764 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/render-ssr.debug.md +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/render-ssr.debug.md @@ -13,17 +13,6 @@ setTimeout(() => document.body.click()); ``` # Update `{"label":"b"}` -```html -
- -
-``` -## Change -``` -UPDATE: main > button::text@0 "a" => "b" -``` # Update ```js @@ -32,7 +21,7 @@ document.querySelector("button").click(); ```html
``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/render-ssr.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/render-ssr.md index eac65b8c42e..f6f86e33764 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/render-ssr.md +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/render-ssr.md @@ -13,17 +13,6 @@ setTimeout(() => document.body.click()); ``` # Update `{"label":"b"}` -```html -
- -
-``` -## Change -``` -UPDATE: main > button::text@0 "a" => "b" -``` # Update ```js @@ -32,7 +21,7 @@ document.querySelector("button").click(); ```html
``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/writes.debug.html index fa93d977425..1329d65949a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-lazy-tag-pending/__snapshots__/writes.debug.html @@ -3,9 +3,11 @@ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/__snapshots__/writes.html new file mode 100644 index 00000000000..97fa6739210 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/__snapshots__/writes.html @@ -0,0 +1,24 @@ +
+
    +
  • 1
  • +
  • 2
  • +
+
+ diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/sizes.json new file mode 100644 index 00000000000..86a3cea757a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 8310, + "brotli": 3771 + } + }, + "html": { + "min": 473, + "brotli": 311 + }, + "patch": { + "min": 0, + "brotli": 1 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/template.marko new file mode 100644 index 00000000000..a099d9d4aa1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/template.marko @@ -0,0 +1,9 @@ + +
+
    + +
  • ${item.n}
  • + +
+ +
diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/test.ts new file mode 100644 index 00000000000..aefb69b3488 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-fill/test.ts @@ -0,0 +1,12 @@ +import type { TestConfig } from "../../main.test"; + +const add = (document: Document) => { + document.querySelector("button")!.click(); +}; + +// A locally written `by` keyer inside a client-owned loop reading a server +// value: the read delivers as a fill, so client re-lists key correctly. +export const config: TestConfig = { + persisted: true, + steps: [{ keyField: "id" }, add], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-local/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-local/sizes.json index 411ea031d4e..50f81202e37 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-local/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-by-local/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7586, - "brotli": 3503 + "min": 7567, + "brotli": 3485 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-child-tag/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-child-tag/sizes.json index c544115d502..cd3099d7039 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-child-tag/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-child-tag/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8679, - "brotli": 3931 + "min": 8661, + "brotli": 3922 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-client-inner/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-client-inner/sizes.json index 0000cb2615c..29a3e5cd22d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-client-inner/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-client-inner/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8948, - "brotli": 4091 + "min": 8929, + "brotli": 4050 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-client-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-client-owned/sizes.json index da553039b58..d4ac3e34459 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-client-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-client-owned/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8350, - "brotli": 3785 + "min": 8328, + "brotli": 3778 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-closure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-closure/sizes.json index 2eb521666fa..43ea9d49f33 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-closure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-closure/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8814, - "brotli": 3983 + "min": 8795, + "brotli": 3979 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-content-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-content-branch/sizes.json index fbc7f96d128..a3af915b95a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-content-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-content-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11983, - "brotli": 5158 + "min": 11939, + "brotli": 5137 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-empty-growth/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-empty-growth/sizes.json index f2bbb351e20..ae210dad8c2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-empty-growth/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-empty-growth/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7558, - "brotli": 3483 + "min": 7539, + "brotli": 3474 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-fill-intersection/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-fill-intersection/sizes.json index 7232583e9fc..165cb2f77f1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-fill-intersection/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-fill-intersection/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8596, - "brotli": 3886 + "min": 8573, + "brotli": 3875 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-frozen-inner/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-frozen-inner/sizes.json index 5740f17d82c..d7c1612d606 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-frozen-inner/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-frozen-inner/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7895, - "brotli": 3616 + "min": 7876, + "brotli": 3602 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-grow-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-grow-state/sizes.json index abca196afa0..645b4c659da 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-grow-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-grow-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9669, - "brotli": 4314 + "min": 9630, + "brotli": 4293 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-handler/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-handler/sizes.json index edda6094531..09785d82c8f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-handler/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-handler/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7650, - "brotli": 3524 + "min": 7631, + "brotli": 3510 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-in-client-if/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-in-client-if/sizes.json index fac04c3c7ee..77dde36e542 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-in-client-if/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-in-client-if/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9330, - "brotli": 4192 + "min": 9307, + "brotli": 4169 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-in-object/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-in-object/sizes.json index 7274d987e6c..571d97ac2cd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-in-object/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-in-object/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8351, - "brotli": 3817 + "min": 8329, + "brotli": 3785 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-intersection-deep/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-intersection-deep/sizes.json index f92d15834bd..3dbde408e76 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-intersection-deep/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-intersection-deep/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10787, - "brotli": 4762 + "min": 10748, + "brotli": 4750 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-intersection/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-intersection/sizes.json index 689e02ebab1..089921bccd3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-intersection/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-intersection/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9669, - "brotli": 4314 + "min": 9630, + "brotli": 4293 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-item-content/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-item-content/sizes.json index db2d7dfe9e4..cfd37ed136c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-item-content/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-item-content/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11544, - "brotli": 4984 + "min": 11500, + "brotli": 4961 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let-index/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let-index/sizes.json index 715d158f51d..ebbd44ef6fa 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let-index/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let-index/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9039, - "brotli": 4058 + "min": 9000, + "brotli": 4070 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let-nested/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let-nested/sizes.json index 76d46a841c7..c682bfd37be 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let-nested/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let-nested/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9607, - "brotli": 4312 + "min": 9568, + "brotli": 4289 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let/sizes.json index f345bcb4c9f..71c728ea880 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-let/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9039, - "brotli": 4058 + "min": 9000, + "brotli": 4073 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-mixed/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-mixed/sizes.json index 478e25b2486..3716eb482ce 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-mixed/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-mixed/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8302, - "brotli": 3770 + "min": 8280, + "brotli": 3762 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-nested-grow-outer/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-nested-grow-outer/sizes.json index 5f136b8981a..59ca69dfe30 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-nested-grow-outer/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-nested-grow-outer/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10098, - "brotli": 4499 + "min": 10059, + "brotli": 4453 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-nested/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-nested/sizes.json index aeaf2317a88..ce43ddc1dd2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-nested/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-nested/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9054, - "brotli": 4069 + "min": 9031, + "brotli": 4061 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-pure-call/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-pure-call/sizes.json index 181fa4ae6c6..fb19ac5f64d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-pure-call/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-pure-call/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8259, - "brotli": 3785 + "min": 8237, + "brotli": 3755 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-reorder-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-reorder-fill/sizes.json index d0805961a66..01d7c67625e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-reorder-fill/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-reorder-fill/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8374, - "brotli": 3794 + "min": 8352, + "brotli": 3804 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-rest-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-rest-state/sizes.json index c2181d5119f..1aa782d8fd5 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-rest-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-rest-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9529, - "brotli": 4267 + "min": 9490, + "brotli": 4251 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-selector-fill/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-selector-fill/sizes.json index 7854996eede..392052df309 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-selector-fill/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-selector-fill/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8979, - "brotli": 4035 + "min": 8956, + "brotli": 4029 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-server-nested/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-server-nested/sizes.json index 479ce5bcd67..0b06367e1d7 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-server-nested/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-server-nested/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8443, - "brotli": 3842 + "min": 8420, + "brotli": 3810 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-shift/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-shift/sizes.json index 12b0332acdf..daea4be55fd 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-shift/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-shift/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9191, - "brotli": 4175 + "min": 9173, + "brotli": 4172 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/__snapshots__/html.bundle.debug.js index 499f9c5c30c..cf8998f4b40 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/__snapshots__/html.bundle.debug.js @@ -12,7 +12,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = _html("
    "); _for_of(input.items, (item) => { const $scope1_id = _scope_id(); - _html(`${_patch_text($scope1_id, "#text/1", item.id, void 0, $scope0_owned, 0)}${_el_resume($scope1_id, "#li/0")}`); + _html(`${_patch_text($scope1_id, "#text/1", item.id, void 0, $scope0_owned, 0)}${_el_resume($scope1_id, "#li/0")}`); _script($scope1_id, "__tests__/template.marko_1_item_attrs#4"); _scope($scope1_id, {}, "__tests__/template.marko", "3:4", { "EventAttributes:#li/0": ["...item.attrs", "4:12"] }); }, (item) => item.id, $scope0_id, "#ul/0", 1, $sg__input_items, $sg__input_items, void 0, void 0, "__tests__/template.marko_1*shell"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/__snapshots__/html.bundle.js index e42af2c0d0d..68452a97e29 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/__snapshots__/html.bundle.js @@ -10,7 +10,7 @@ var template_default = _template_persisted("a", (input) => { _html("
      "); _for_of(input.items, (item) => { const $scope1_id = _scope_id(); - _html(`${_patch_text($scope1_id, "b", item.id, void 0, $scope0_owned, 0)}${_el_resume($scope1_id, "a")}`); + _html(`${_patch_text($scope1_id, "b", item.id, void 0, $scope0_owned, 0)}${_el_resume($scope1_id, "a")}`); _script($scope1_id, "a1"); _scope($scope1_id, {}); }, (item) => item.id, $scope0_id, "a", 1, $sg__input_items, $sg__input_items, void 0, void 0, "a0"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/sizes.json index bc968d9caa1..3482f6ab9a1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-spread/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 11040, - "brotli": 4766 + "min": 11032, + "brotli": 4790 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-state/sizes.json index 49a910ebf6a..1556caffc77 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8840, - "brotli": 4013 + "min": 8821, + "brotli": 3987 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static-content/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static-content/sizes.json index 147fdc3e7c8..9369fad2c01 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static-content/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static-content/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7817, - "brotli": 3587 + "min": 7799, + "brotli": 3586 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static-holes/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static-holes/sizes.json index dab1602ddb0..9c3d7892719 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static-holes/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static-holes/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8385, - "brotli": 3841 + "min": 8367, + "brotli": 3821 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static/sizes.json index b0a27e1eaf3..d81c65dd206 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-static/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7817, - "brotli": 3587 + "min": 7799, + "brotli": 3586 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-to-range/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-to-range/sizes.json index e6f54cd63c6..059d8688337 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-to-range/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-to-range/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8247, - "brotli": 3753 + "min": 8225, + "brotli": 3744 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-until-step/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-until-step/sizes.json index 907235538b7..2111ddcdf29 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-until-step/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop-until-step/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8246, - "brotli": 3751 + "min": 8224, + "brotli": 3747 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop/sizes.json index 50ed433417b..874ebeb960e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-loop/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-loop/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8622, - "brotli": 3926 + "min": 8603, + "brotli": 3914 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-native-content-attr/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-native-content-attr/sizes.json index 8a026640977..d765ef38094 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-native-content-attr/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-native-content-attr/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9772, - "brotli": 4180 + "min": 9727, + "brotli": 4163 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-nested-flow/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-nested-flow/sizes.json index 6e1f4b8c3d3..05e7ece9bea 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-nested-flow/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-nested-flow/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9664, - "brotli": 4335 + "min": 9625, + "brotli": 4309 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-only-child-branch/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-only-child-branch/sizes.json index c144fbd179a..c0301d6f988 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-only-child-branch/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-only-child-branch/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 7327, - "brotli": 3313 + "min": 7309, + "brotli": 3299 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-option-attrs/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-option-attrs/sizes.json index 57643fd63d0..60c2c2a2093 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-option-attrs/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-option-attrs/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9929, - "brotli": 4368 + "min": 9881, + "brotli": 4346 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..648fe470079 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,44 @@ +// tags/wrap/index.marko +const $template$1 = "
      "; +const $walks$1 = "D%l"; +const $setup$1 = () => {}; +const $input_content_direct = /*@__PURE__*/ _dynamic_tag_content("#text/0"); +const $dynamicTag = /*@__PURE__*/ _dynamic_tag("#text/0"); +const $input_content = $dynamicTag; +const $input$1 = ($scope, input) => $input_content($scope, input.content); +var wrap_default = /*@__PURE__*/ _template("__tests__/tags/wrap/index.marko", $template$1, "D%l", 0, $input$1); + +// template.marko +const $template = /*@__PURE__*/ ((_w0) => `${_w0}`)($template$1); +const $walks = /*@__PURE__*/ ((_w0) => ` D l/${_w0}&`)("D%l"); +const $await_content = /*@__PURE__*/ _await_content("#text/0", "
      done
      "); +const $try_content__await_promise = /*@__PURE__*/ _await_promise("#text/0"); +const $try_content__input_promise = /*@__PURE__*/ _closure_get("input_promise", ($scope) => $try_content__await_promise($scope, $scope._._.input_promise), ($scope) => $scope._._); +const $try_content__setup = ($scope) => { + $try_content__input_promise($scope); + $await_content($scope); +}; +const $placeholder_content__input_msg = /*@__PURE__*/ _fill_join_closure("__tests__/template.marko0", "input_msg", /*@__PURE__*/ _closure_get("input_msg", ($scope) => _text($scope["#text/0"], $scope._._.input_msg), ($scope) => $scope._._), 0); +const $placeholder_content__setup = $placeholder_content__input_msg; +const $placeholder_content = _content_resume("__tests__/template.marko_2*content", "loading ", "Db%", $placeholder_content__setup); +const $wrap_content__try = /*@__PURE__*/ _try("#text/0", "", "b%", $try_content__setup); +const $wrap_content__setup = ($scope) => $wrap_content__try($scope, { placeholder: attrTag({ content: $placeholder_content($scope) }) }); +const $wrap_content = /*@__PURE__*/ _content("__tests__/template.marko_1*content", "", "b%", $wrap_content__setup); +const $count = /*@__PURE__*/ _let("count/7", ($scope) => _text($scope["#text/1"], $scope.count)); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $input_content_direct($scope["#childScope/2"], $wrap_content($scope)); + $count($scope, 0); + $setup__script($scope); +} +const $input = ($scope, input) => { + $input_msg($scope, input.msg); + $input_promise($scope, input.promise); +}; +const $input_msg__closure = /*@__PURE__*/ _closure($placeholder_content__input_msg); +const $input_msg = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_msg", $input_msg__closure); +const $input_promise__closure = /*@__PURE__*/ _closure($try_content__input_promise); +const $input_promise = /*@__PURE__*/ _const("input_promise", $input_promise__closure); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..b1da6bb6abc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/dom.bundle.js @@ -0,0 +1,7 @@ +// template.marko +const $placeholder_content__input_msg = /*@__PURE__*/ _fill_join_closure("a0", 5, /*@__PURE__*/ _closure_get(8, ($scope) => _text($scope.a, $scope._._.f), ($scope) => $scope._._), 0); +const $placeholder_content = _content_resume("a3", "loading ", "Db%", $placeholder_content__input_msg); +const $count = /*@__PURE__*/ _let(7, ($scope) => _text($scope.b, $scope.h)); +const $setup__script = _script("a5", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.h + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..35993ba7a00 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/html.bundle.debug.js @@ -0,0 +1,66 @@ +// tags/wrap/index.marko +const $template$1 = "
      "; +const $walks$1 = "D%l"; +_shells({ "__tests__/tags/wrap/index.marko": "__tests__/tags/wrap/index.marko;D%;
      " }); +var wrap_default = _template_persisted("__tests__/tags/wrap/index.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
      "); + _patch_dynamic_tag($scope0_id, "#text/0", input.content, $scope0_owned, 0); + _dynamic_tag($scope0_id, "#text/0", input.content, {}, 0, 0, _source_guard($scope0_reason, 0), 1); + _html("
      "); + $scope0_reason && _scope($scope0_id, {}, "__tests__/tags/wrap/index.marko", 0); +}, 0, 0); + +// template.marko +const $template = /*@__PURE__*/ ((_w0) => `${_w0}`)($template$1); +const $walks = /*@__PURE__*/ ((_w0) => ` D l/${_w0}&`)("D%l"); +_shells({ + "__tests__/template.marko_4*content": "__tests__/template.marko_4*content,
      done
      ", + "__tests__/template.marko_3_#text#0/await": "__tests__/template.marko_3_#text#0/await,
      done
      ", + "__tests__/template.marko_3*content": "__tests__/template.marko_3*content;b%;" +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = new Set(); + const $input_promise__closures = new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + _set_serialize_reason(0); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "#childScope/2", $childScope); + wrap_default({ content: _content("__tests__/template.marko_1*content", () => { + const $scope1_reason = _persisted_reason(); + const $scope1_id = _scope_id(); + _try($scope1_id, "#text/0", _content_resume("__tests__/template.marko_3*content", () => { + const $scope3_id = _scope_id(); + const $scope3_reason = _persisted_reason(); + _await($scope3_id, "#text/0", input.promise, () => { + const $scope4_id = _scope_id(); + _html("
      done
      "); + }, 1, "__tests__/template.marko_3_#text#0/await"); + $scope0_reason && _subscribe($input_promise__closures, _scope($scope3_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "4:4")); + _resume_branch($scope3_id); + }, $scope1_id), { placeholder: attrTag({ content: _content_resume("__tests__/template.marko_2*content", () => { + const $scope2_reason = _persisted_reason(); + const $scope2_id = _scope_id(); + _html(`loading ${_text_resume($scope2_id, "#text/0", input.msg, 2)}`); + _subscribe(_source_if($scope0_reason, 0) && $input_msg__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) }, "__tests__/template.marko", "8:6")); + _resume_branch($scope2_id); + }, $scope1_id) }) }); + _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:2"); + }, $scope0_id) }); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + input_msg: input.msg, + count, + "ClosureScopes:input_msg": $input_msg__closures, + "ClosureScopes:input_promise": $input_promise__closures, + "#childScope/2": _existing_scope($childScope) + }, "__tests__/template.marko", 0, { + input_msg: ["input.msg"], + count: "1:6" + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", input.msg); + _resume_branch($scope0_id); +}, 1, () => [wrap_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..49856013e62 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/html.bundle.js @@ -0,0 +1,59 @@ +// tags/wrap/index.marko +_shells({ b: "b;D%;
      " }); +var wrap_default = _template_persisted("b", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + _html("
      "); + _patch_dynamic_tag($scope0_id, "a", input.content, $scope0_owned, 0); + _dynamic_tag($scope0_id, "a", input.content, {}, 0, 0, _source_guard($scope0_reason, 0), 1); + _html("
      "); + $scope0_reason && _scope($scope0_id, {}); +}, 0, 0); + +// template.marko +_shells({ + a0: "a0,
      done
      ", + a1: "a1,
      done
      ", + a2: "a2;b%;" +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = /* @__PURE__ */ new Set(); + const $input_promise__closures = /* @__PURE__ */ new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + _set_serialize_reason(0); + const $childScope = _peek_scope_id(); + _patch_child($scope0_id, "c", $childScope); + wrap_default({ content: _content("a4", () => { + _persisted_reason(); + const $scope1_id = _scope_id(); + _try($scope1_id, "a", _content_resume("a2", () => { + const $scope3_id = _scope_id(); + _persisted_reason(); + _await($scope3_id, "a", input.promise, () => { + _scope_id(); + _html("
      done
      "); + }, 1, "a1"); + $scope0_reason && _subscribe($input_promise__closures, _scope($scope3_id, { _: _scope_with_id($scope1_id) })); + _resume_branch($scope3_id); + }, $scope1_id), { placeholder: attrTag({ content: _content_resume("a3", () => { + _persisted_reason(); + const $scope2_id = _scope_id(); + _html(`loading ${_text_resume($scope2_id, "a", input.msg, 2)}`); + _subscribe(_source_if($scope0_reason, 0) && $input_msg__closures, _scope($scope2_id, { _: _scope_with_id($scope1_id) })); + _resume_branch($scope2_id); + }, $scope1_id) }) }); + _scope($scope1_id, { _: _scope_with_id($scope0_id) }); + }, $scope0_id) }); + _script($scope0_id, "a5"); + $scope0_reason ? _scope($scope0_id, { + f: input.msg, + h: count, + i: $input_msg__closures, + j: $input_promise__closures, + c: _existing_scope($childScope) + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", input.msg); + _resume_branch($scope0_id); +}, 1, () => [wrap_default]); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..fa9f6c08c1f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/patches.debug.js @@ -0,0 +1,12 @@ +// PATCH +[`packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko_3_#text#0/await,
      done
      `, `packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko_3*content;b%;`, { + "PatchChild:#childScope/2": { + "PatchChild:BranchScopes:#text/0": { + "PatchChild:BranchScopes:#text/0": [{ + "PatchPending:#text/0": "packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko_3_#text#0/await", + "PatchChild:BranchScopes:#text/0": {} + }, "packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko_3*content", $, "packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko_2*content"] + } + }, + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko0": "b" +}] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/patches.js new file mode 100644 index 00000000000..f330dad221b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/patches.js @@ -0,0 +1,12 @@ +// PATCH +[`a1,
      done
      `, `a2;b%;`, { + cc: { + cAa: { + cAa: [{ + pa: "a1", + cAa: {} + }, "a2", $, "a3"] + } + }, + va0: "b" +}] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/render.debug.md new file mode 100644 index 00000000000..7133e6dd987 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/render.debug.md @@ -0,0 +1,33 @@ +# Render `{"msg":"a","promise":{"value":2}}` +```html + +
      + + loading a + +
      +``` + +# Update +```html + +
      +
      + done +
      +
      +``` +## Change +``` +INSERT: #done::text("done") +REMOVE: section > em +INSERT: section > #done +``` + +# Update `{"msg":"b","promise":{"value":2}}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/render.md new file mode 100644 index 00000000000..7133e6dd987 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/render.md @@ -0,0 +1,33 @@ +# Render `{"msg":"a","promise":{"value":2}}` +```html + +
      + + loading a + +
      +``` + +# Update +```html + +
      +
      + done +
      +
      +``` +## Change +``` +INSERT: #done::text("done") +REMOVE: section > em +INSERT: section > #done +``` + +# Update `{"msg":"b","promise":{"value":2}}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..b30be4426ef --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/writes.debug.html @@ -0,0 +1,43 @@ + +
      loading + a +
      + + + + + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/writes.html new file mode 100644 index 00000000000..e62d70234f0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/__snapshots__/writes.html @@ -0,0 +1,37 @@ + +
      loading + a
      + + + + + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/sizes.json new file mode 100644 index 00000000000..0b5754eb0dc --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 13962, + "brotli": 5772 + } + }, + "html": { + "min": 1219, + "brotli": 691 + }, + "patch": { + "min": 105, + "brotli": 101 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/tags/wrap/index.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/tags/wrap/index.marko new file mode 100644 index 00000000000..e74490cbca8 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/tags/wrap/index.marko @@ -0,0 +1 @@ +
      <${input.content}/>
      diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko new file mode 100644 index 00000000000..6388856269a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/template.marko @@ -0,0 +1,12 @@ + + + + + +
      done
      + + <@placeholder> + loading ${input.msg} + +
      +
      diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/test.ts new file mode 100644 index 00000000000..1ee7408a36c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read-in-content/test.ts @@ -0,0 +1,17 @@ +import type { TestConfig } from "../../main.test"; +import { flush, resolveAfter, wait } from "../../utils/resolve"; + +// A server value read inside `@placeholder` content under a content section +// must re-render with the patched value when a construct re-shows the +// placeholder, in optimize and debug alike. +export const config: TestConfig = { + persisted: true, + steps: () => [ + { msg: "a", promise: resolveAfter(2) }, + wait, + flush, + { msg: "b", promise: resolveAfter(2) }, + wait, + flush, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..065f5ffd0fd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,32 @@ +// template.marko +const $template = ""; +const $walks = " D l%c"; +const $await_content = /*@__PURE__*/ _await_content("#text/0", "
      done
      "); +const $try_content__await_promise = /*@__PURE__*/ _await_promise("#text/0"); +const $try_content__input_promise = /*@__PURE__*/ _closure_get("input_promise", ($scope) => $try_content__await_promise($scope, $scope._.input_promise)); +const $try_content__setup = ($scope) => { + $try_content__input_promise($scope); + $await_content($scope); +}; +const $placeholder_content__input_msg = /*@__PURE__*/ _fill_join_closure("__tests__/template.marko0", "input_msg", /*@__PURE__*/ _closure_get("input_msg", ($scope) => _text($scope["#text/0"], $scope._.input_msg)), 0); +const $placeholder_content__setup = $placeholder_content__input_msg; +const $placeholder_content = _content_resume("__tests__/template.marko_1*content", "loading ", "Db%", $placeholder_content__setup); +const $count = /*@__PURE__*/ _let("count/7", ($scope) => _text($scope["#text/1"], $scope.count)); +const $try = /*@__PURE__*/ _try("#text/2", "", "b%", $try_content__setup); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $count($scope, +$scope.count + 1); +})); +function $setup($scope) { + $count($scope, 0); + $try($scope, { placeholder: attrTag({ content: $placeholder_content($scope) }) }); + $setup__script($scope); +} +const $input = ($scope, input) => { + $input_msg($scope, input.msg); + $input_promise($scope, input.promise); +}; +const $input_msg__closure = /*@__PURE__*/ _closure($placeholder_content__input_msg); +const $input_msg = /*@__PURE__*/ _fill_const("__tests__/template.marko0", "input_msg", $input_msg__closure); +const $input_promise__closure = /*@__PURE__*/ _closure($try_content__input_promise); +const $input_promise = /*@__PURE__*/ _const("input_promise", $input_promise__closure); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..26e851eef2c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/dom.bundle.js @@ -0,0 +1,7 @@ +// template.marko +const $placeholder_content__input_msg = /*@__PURE__*/ _fill_join_closure("a0", 5, /*@__PURE__*/ _closure_get(8, ($scope) => _text($scope.a, $scope._.f)), 0); +const $placeholder_content = _content_resume("a3", "loading ", "Db%", $placeholder_content__input_msg); +const $count = /*@__PURE__*/ _let(7, ($scope) => _text($scope.b, $scope.h)); +const $setup__script = _script("a4", ($scope) => _on($scope.a, "click", function() { + $count($scope, +$scope.h + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..b0fb844e781 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/html.bundle.debug.js @@ -0,0 +1,43 @@ +// template.marko +const $template = ""; +const $walks = " D l%c"; +_shells({ + "__tests__/template.marko_3*content": "__tests__/template.marko_3*content,
      done
      ", + "__tests__/template.marko_2_#text#0/await": "__tests__/template.marko_2_#text#0/await,
      done
      ", + "__tests__/template.marko_2*content": "__tests__/template.marko_2*content;b%;" +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = new Set(); + const $input_promise__closures = new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + _try($scope0_id, "#text/2", _content_resume("__tests__/template.marko_2*content", () => { + const $scope2_id = _scope_id(); + const $scope2_reason = _persisted_reason(); + _await($scope2_id, "#text/0", input.promise, () => { + const $scope3_id = _scope_id(); + _html("
      done
      "); + }, 1, "__tests__/template.marko_2_#text#0/await"); + $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:2")); + _resume_branch($scope2_id); + }, $scope0_id), { placeholder: attrTag({ content: _content_resume("__tests__/template.marko_1*content", () => { + const $scope1_reason = _persisted_reason(); + const $scope1_id = _scope_id(); + _html(`loading ${_text_resume($scope1_id, "#text/0", input.msg, 2)}`); + _subscribe(_source_if($scope0_reason, 0) && $input_msg__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "7:4")); + _resume_branch($scope1_id); + }, $scope0_id) }) }, 1); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason ? _scope($scope0_id, { + input_msg: input.msg, + count, + "ClosureScopes:input_msg": $input_msg__closures, + "ClosureScopes:input_promise": $input_promise__closures + }, "__tests__/template.marko", 0, { + input_msg: ["input.msg"], + count: "1:6" + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "__tests__/template.marko0", input.msg); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..da4153ed45b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/html.bundle.js @@ -0,0 +1,38 @@ +// template.marko +_shells({ + a0: "a0,
      done
      ", + a1: "a1,
      done
      ", + a2: "a2;b%;" +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_msg__closures = /* @__PURE__ */ new Set(); + const $input_promise__closures = /* @__PURE__ */ new Set(); + let count = 0; + _html(`${_el_resume($scope0_id, "a")}`); + _try($scope0_id, "c", _content_resume("a2", () => { + const $scope2_id = _scope_id(); + _persisted_reason(); + _await($scope2_id, "a", input.promise, () => { + _scope_id(); + _html("
      done
      "); + }, 1, "a1"); + $scope0_reason && _subscribe($input_promise__closures, _scope($scope2_id, { _: _scope_with_id($scope0_id) })); + _resume_branch($scope2_id); + }, $scope0_id), { placeholder: attrTag({ content: _content_resume("a3", () => { + _persisted_reason(); + const $scope1_id = _scope_id(); + _html(`loading ${_text_resume($scope1_id, "a", input.msg, 2)}`); + _subscribe(_source_if($scope0_reason, 0) && $input_msg__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); + _resume_branch($scope1_id); + }, $scope0_id) }) }, 1); + _script($scope0_id, "a4"); + $scope0_reason ? _scope($scope0_id, { + f: input.msg, + h: count, + i: $input_msg__closures, + j: $input_promise__closures + }) : _owned_guard($scope0_owned, 0) && _patch_value($scope0_id, "a0", input.msg); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..b020c57ac63 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/patches.debug.js @@ -0,0 +1,8 @@ +// PATCH +[`packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/template.marko_2_#text#0/await,
      done
      `, { + "PatchChild:BranchScopes:#text/2": { + "PatchPending:#text/0": "packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/template.marko_2_#text#0/await", + "PatchChild:BranchScopes:#text/0": {} + }, + "PatchValue:packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/template.marko0": "b" +}] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/patches.js new file mode 100644 index 00000000000..112413bfb2c --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/patches.js @@ -0,0 +1,8 @@ +// PATCH +[`a1,
      done
      `, { + cAc: { + pa: "a1", + cAa: {} + }, + va0: "b" +}] diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/render.debug.md new file mode 100644 index 00000000000..3531fe2a768 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/render.debug.md @@ -0,0 +1,29 @@ +# Render `{"msg":"a","promise":{"value":2}}` +```html + + + loading a + +``` + +# Update +```html + +
      + done +
      +``` +## Change +``` +INSERT: #done::text("done") +REMOVE: em +INSERT: button + #done +``` + +# Update `{"msg":"b","promise":{"value":2}}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/render.md new file mode 100644 index 00000000000..3531fe2a768 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/render.md @@ -0,0 +1,29 @@ +# Render `{"msg":"a","promise":{"value":2}}` +```html + + + loading a + +``` + +# Update +```html + +
      + done +
      +``` +## Change +``` +INSERT: #done::text("done") +REMOVE: em +INSERT: button + #done +``` + +# Update `{"msg":"b","promise":{"value":2}}` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..a047aadc5aa --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/writes.debug.html @@ -0,0 +1,35 @@ +loading + a + + + + + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/writes.html new file mode 100644 index 00000000000..7825e259ed1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/__snapshots__/writes.html @@ -0,0 +1,30 @@ +loading + a + + + + + + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/sizes.json new file mode 100644 index 00000000000..06037c64075 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 11052, + "brotli": 4695 + } + }, + "html": { + "min": 1143, + "brotli": 663 + }, + "patch": { + "min": 62, + "brotli": 66 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/template.marko new file mode 100644 index 00000000000..21db9879c58 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/template.marko @@ -0,0 +1,10 @@ + + + + +
      done
      + + <@placeholder> + loading ${input.msg} + +
      diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/test.ts new file mode 100644 index 00000000000..f0e1e36cde3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-placeholder-server-read/test.ts @@ -0,0 +1,17 @@ +import type { TestConfig } from "../../main.test"; +import { flush, resolveAfter, wait } from "../../utils/resolve"; + +// A server value read inside `@placeholder` content must re-render with the +// patched value when a construct re-shows the placeholder, in optimize and +// debug alike (the fill registration is retained for the placeholder's read). +export const config: TestConfig = { + persisted: true, + steps: () => [ + { msg: "a", promise: resolveAfter(2) }, + wait, + flush, + { msg: "b", promise: resolveAfter(2) }, + wait, + flush, + ], +}; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..0335c884481 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,10 @@ +// template.marko +const $template = "

      "; +const $walks = "E m"; +const $setup = () => {}; +const $brand__script = _script("__tests__/template.marko_0_brand#1", ($scope) => document.querySelector("main").dataset.brand = $scope.brand); +const $brand = /*@__PURE__*/ _const("brand", ($scope) => { + _text($scope["#text/0"], $scope.brand); + $brand__script($scope); +}); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, "E m"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..13912eb312f --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/dom.bundle.js @@ -0,0 +1,2 @@ +// template.marko +_script("a0", ($scope) => document.querySelector("main").dataset.brand = $scope.b); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-dom.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-dom.debug.txt deleted file mode 100644 index 02b6930cf91..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-dom.debug.txt +++ /dev/null @@ -1,2 +0,0 @@ -Persisted templates currently support only escaped dynamic text and dynamic attributes in native HTML. - at packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/template.marko \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-dom.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-dom.txt deleted file mode 100644 index 02b6930cf91..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-dom.txt +++ /dev/null @@ -1,2 +0,0 @@ -Persisted templates currently support only escaped dynamic text and dynamic attributes in native HTML. - at packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/template.marko \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-html.debug.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-html.debug.txt deleted file mode 100644 index 02b6930cf91..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-html.debug.txt +++ /dev/null @@ -1,2 +0,0 @@ -Persisted templates currently support only escaped dynamic text and dynamic attributes in native HTML. - at packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/template.marko \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-html.txt b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-html.txt deleted file mode 100644 index 02b6930cf91..00000000000 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/error-compile-html.txt +++ /dev/null @@ -1,2 +0,0 @@ -Persisted templates currently support only escaped dynamic text and dynamic attributes in native HTML. - at packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/template.marko \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..01e03f42082 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/html.bundle.debug.js @@ -0,0 +1,14 @@ +// template.marko +const $template = "

      "; +const $walks = "E m"; +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0_brand#1;E ;

      " }); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $global$1 = $global(); + const brand = $global$1.brand; + _html(`

      ${_patch_text($scope0_id, "#text/0", brand)}

      `); + _script($scope0_id, "__tests__/template.marko_0_brand#1"); + _patch_effect($scope0_id, "__tests__/template.marko_0_brand#1", "brand"); + $scope0_reason ? _scope($scope0_id, { brand }, "__tests__/template.marko", 0, { brand: "1:8" }) : _patch_write($scope0_id, "brand", brand); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..c8222fd44a1 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/html.bundle.js @@ -0,0 +1,11 @@ +// template.marko +_shells({ a: "a !a0;E ;

      " }); +var template_default = _template_persisted("a", (input) => { + const $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const brand = $global().brand; + _html(`

      ${_patch_text($scope0_id, "a", brand)}

      `); + _script($scope0_id, "a0"); + _patch_effect($scope0_id, "a0", "b"); + $scope0_reason ? _scope($scope0_id, { b: brand }) : _patch_write($scope0_id, "b", brand); +}, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..03efb79c502 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/patches.debug.js @@ -0,0 +1,6 @@ +// PATCH +{ + "PatchText:#text/0": "bmce", + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/template.marko_0_brand#1": "brand", + "PatchWrite:brand": "bmce" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/patches.js new file mode 100644 index 00000000000..91ffe4e9e29 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/patches.js @@ -0,0 +1,6 @@ +// PATCH +{ + ta: "bmce", + ea0: "b", + wb: "bmce" +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/render.debug.md new file mode 100644 index 00000000000..7c698dbefbd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/render.debug.md @@ -0,0 +1,26 @@ +# Render `{"$global":{"brand":"acme"}}` +```html +
      +

      + acme +

      +
      +``` + +# Update `{"$global":{"brand":"bmce"}}` +```html +
      +

      + bmce +

      +
      +``` +## Change +``` +UPDATE: main > h1::text "acme" => "bmce" +UPDATE: main[data-brand] "acme" => "bmce" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/render.md new file mode 100644 index 00000000000..7c698dbefbd --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/render.md @@ -0,0 +1,26 @@ +# Render `{"$global":{"brand":"acme"}}` +```html +
      +

      + acme +

      +
      +``` + +# Update `{"$global":{"brand":"bmce"}}` +```html +
      +

      + bmce +

      +
      +``` +## Change +``` +UPDATE: main > h1::text "acme" => "bmce" +UPDATE: main[data-brand] "acme" => "bmce" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..a0d0624558e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/writes.debug.html @@ -0,0 +1,12 @@ +
      +

      acme

      +
      + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/writes.html new file mode 100644 index 00000000000..0f6530c7274 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/__snapshots__/writes.html @@ -0,0 +1,10 @@ +
      +

      acme

      +
      + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/sizes.json new file mode 100644 index 00000000000..30e0da289b4 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 2681, + "brotli": 1346 + } + }, + "html": { + "min": 352, + "brotli": 255 + }, + "patch": { + "min": 30, + "brotli": 34 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/test.ts index df62ffe6fdd..67410dca285 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/test.ts +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-alias/test.ts @@ -1,8 +1,11 @@ import type { TestConfig } from "../../main.test"; -// A ` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-keys/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-keys/__snapshots__/writes.html index 53dedea8711..1a1c1756e3e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-keys/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-keys/__snapshots__/writes.html @@ -7,6 +7,9 @@

      x

      brand: "Marko", locale: "en", other: "x" + }, { + c: "Marko", + d: "en" }], "a0 1"]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-keys/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-keys/sizes.json index e29cef7ab03..8b24a6e20ec 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-keys/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-keys/sizes.json @@ -1,16 +1,16 @@ { "dom": { "template.marko.page.mjs": { - "min": 2757, - "brotli": 1385 + "min": 2727, + "brotli": 1368 } }, "html": { - "min": 376, - "brotli": 268 + "min": 395, + "brotli": 276 }, "patch": { - "min": 210, - "brotli": 87 + "min": 234, + "brotli": 92 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-opaque/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-opaque/__snapshots__/dom.bundle.debug.js index 067b6b05829..e9723fb5e68 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-opaque/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-opaque/__snapshots__/dom.bundle.debug.js @@ -8,8 +8,5 @@ const $setup__script = _script("__tests__/template.marko_0", ($scope) => { el.dataset.log = (el.dataset.log || "") + "[" + g.brand + "]"; } }); -function $setup($scope) { - _text($scope["#text/0"], $scope.$global.other); - $setup__script($scope); -} +const $setup = $setup__script; var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, "E m", $setup); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-opaque/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-opaque/sizes.json index e1a42639214..0a333333e68 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-opaque/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global-opaque/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2746, - "brotli": 1380 + "min": 2729, + "brotli": 1371 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/dom.bundle.debug.js index 69f56a40d66..8e35c7098f6 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/dom.bundle.debug.js @@ -1,14 +1,11 @@ // template.marko const $template = "

      "; const $walks = "E m"; -const $setup__script = _script("__tests__/template.marko_0", ($scope) => { +const $setup = () => {}; +const $global_brand__script = _script("__tests__/template.marko_0_$global_brand#1", ($scope) => { { const el = document.querySelector("main"); - el.dataset.log = (el.dataset.log || "") + "[" + $scope.$global.brand + "]"; + el.dataset.log = (el.dataset.log || "") + "[" + $scope.$global_brand + "]"; } }); -function $setup($scope) { - _text($scope["#text/0"], $scope.$global.brand); - $setup__script($scope); -} -var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, "E m", $setup); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, "E m"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/dom.bundle.js index db99d9fc630..9cba7c10321 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/dom.bundle.js @@ -1,7 +1,7 @@ // template.marko -const $setup__script = _script("a0", ($scope) => { +_script("a0", ($scope) => { { const el = document.querySelector("main"); - el.dataset.log = (el.dataset.log || "") + "[" + $scope.$.brand + "]"; + el.dataset.log = (el.dataset.log || "") + "[" + $scope.b + "]"; } }); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/html.bundle.debug.js index 138de5669b7..469521ac128 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/html.bundle.debug.js @@ -1,13 +1,13 @@ // template.marko const $template = "

      "; const $walks = "E m"; -_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0;E ;

      " }); +_shells({ "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0_$global_brand#1;E ;

      " }); var template_default = _template_persisted("__tests__/template.marko", (input) => { const $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); const $global$1 = $global(); _html(`

      ${_patch_text($scope0_id, "#text/0", $global$1.brand)}

      `); - _script($scope0_id, "__tests__/template.marko_0"); - _patch_effect($scope0_id, "__tests__/template.marko_0", "! brand", 1); - $scope0_reason && _scope($scope0_id, {}, "__tests__/template.marko", 0); + _script($scope0_id, "__tests__/template.marko_0_$global_brand#1"); + _patch_effect($scope0_id, "__tests__/template.marko_0_$global_brand#1", "$global_brand"); + $scope0_reason ? _scope($scope0_id, { $global_brand: $global$1?.brand }, "__tests__/template.marko", 0, { $global_brand: ["$global.brand"] }) : _patch_write($scope0_id, "$global_brand", $global$1?.brand); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/html.bundle.js index a290639badd..2af6b4bbaba 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/html.bundle.js @@ -3,8 +3,9 @@ _shells({ a: "a !a0;E ;

      " }); var template_default = _template_persisted("a", (input) => { const $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); - _html(`

      ${_patch_text($scope0_id, "a", $global().brand)}

      `); + const $global$1 = $global(); + _html(`

      ${_patch_text($scope0_id, "a", $global$1.brand)}

      `); _script($scope0_id, "a0"); - _patch_effect($scope0_id, "a0", "! brand", 1); - $scope0_reason && _scope($scope0_id, {}); + _patch_effect($scope0_id, "a0", "b"); + $scope0_reason ? _scope($scope0_id, { b: $global$1?.brand }) : _patch_write($scope0_id, "b", $global$1?.brand); }, 1, 1); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/patches.debug.js index 163dca0e0a1..c367db0bda3 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/patches.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/patches.debug.js @@ -4,7 +4,8 @@ brand: "Marko" }, "PatchText:#text/0": "Marko", - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/template.marko_0": "! brand" + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/template.marko_0_$global_brand#1": "$global_brand", + "PatchWrite:$global_brand": "Marko" } // PATCH @@ -13,5 +14,6 @@ brand: "Runtime" }, "PatchText:#text/0": "Runtime", - "PatchGlobalEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/template.marko_0": "! brand" + "PatchEffect:packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/template.marko_0_$global_brand#1": "$global_brand", + "PatchWrite:$global_brand": "Runtime" } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/patches.js index d1d1462db7b..0091256ac52 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/patches.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/patches.js @@ -4,7 +4,8 @@ brand: "Marko" }, ta: "Marko", - ga0: "! brand" + ea0: "b", + wb: "Marko" } // PATCH @@ -13,5 +14,6 @@ brand: "Runtime" }, ta: "Runtime", - ga0: "! brand" + ea0: "b", + wb: "Runtime" } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/writes.debug.html index 3b210c4df86..0e28a9b6dca 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/writes.debug.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/writes.debug.html @@ -5,8 +5,10 @@

      Marko

      WALKER_RUNTIME("M")("_"); M._.r = [_ => [0, { brand: "Marko" + }, { + $global_brand: "Marko" }], - "packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/template.marko_0 1" + "packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/template.marko_0_$global_brand#1 1" ]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/writes.html index 8399dfe1660..d8da4be4fe4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/writes.html +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/__snapshots__/writes.html @@ -5,6 +5,8 @@

      Marko

      WALKER_RUNTIME("M")("_"); M._.r = [_ => [0, { brand: "Marko" + }, { + b: "Marko" }], "a0 1"]; M._.w() diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/sizes.json index 438b70bf458..447ebb81995 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-global/sizes.json @@ -1,16 +1,16 @@ { "dom": { "template.marko.page.mjs": { - "min": 2742, - "brotli": 1378 + "min": 2719, + "brotli": 1366 } }, "html": { - "min": 358, - "brotli": 259 + "min": 370, + "brotli": 261 }, "patch": { - "min": 94, - "brotli": 81 + "min": 106, + "brotli": 88 } } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-input/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-input/sizes.json index 4eee923cc2f..c8c61c8afff 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-input/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-input/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2759, - "brotli": 1380 + "min": 2742, + "brotli": 1368 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-inputs/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-inputs/sizes.json index 4592e9df271..f5ed7a08e1a 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-script-inputs/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-script-inputs/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2759, - "brotli": 1379 + "min": 2742, + "brotli": 1366 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-shell-holes/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-shell-holes/sizes.json index e877272edfb..641a109cb88 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-shell-holes/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-shell-holes/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 6704, - "brotli": 3022 + "min": 6686, + "brotli": 3015 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/__snapshots__/html.bundle.debug.js index 16fd121c091..318616d1067 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/__snapshots__/html.bundle.debug.js @@ -12,14 +12,14 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = _html(`
      ${_patch_text($scope0_id, "#text/1", input.label, void 0, $scope0_owned, 2)}${_el_resume($scope0_id, "#a/0")}`); + }, "#a/0", $scope0_id, "a", void 0, $scope0_owned, 1)}>${_patch_text($scope0_id, "#text/1", input.label, void 0, $scope0_owned, 2)}${_el_resume($scope0_id, "#a/0")}`); _if(() => { if (input.show) { const $scope1_id = _scope_id(); _html(`${_el_resume($scope1_id, "#img/0")}`); + }, "#img/0", $scope1_id, "img", void 0, $scope0_owned, 4)}>${_el_resume($scope1_id, "#img/0")}`); _script($scope1_id, "__tests__/template.marko_1_input_img#10"); _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "4:4", { "EventAttributes:#img/0": ["...input.img", "5:24"] }); return 0; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/__snapshots__/html.bundle.js index 6a6f914ae7a..9f436ec0241 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/__snapshots__/html.bundle.js @@ -10,14 +10,14 @@ var template_default = _template_persisted("a", (input) => { _html(`
      ${_patch_text($scope0_id, "b", input.label, void 0, $scope0_owned, 2)}${_el_resume($scope0_id, "a")}`); + }, "a", $scope0_id, "a", void 0, $scope0_owned, 1)}>${_patch_text($scope0_id, "b", input.label, void 0, $scope0_owned, 2)}${_el_resume($scope0_id, "a")}`); _if(() => { if (input.show) { const $scope1_id = _scope_id(); _html(`${_el_resume($scope1_id, "a")}`); + }, "a", $scope1_id, "img", void 0, $scope0_owned, 4)}>${_el_resume($scope1_id, "a")}`); _script($scope1_id, "a1"); _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/sizes.json index 978419587be..3b10c6bf058 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-attributes/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9815, - "brotli": 4195 + "min": 9807, + "brotli": 4212 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-client-owned/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-client-owned/sizes.json index a1209de0184..c0f33825d8d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-client-owned/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-client-owned/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9350, - "brotli": 4026 + "min": 9358, + "brotli": 4037 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/__snapshots__/html.bundle.debug.js index 47b8a52e4b7..b9e57d04741 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/__snapshots__/html.bundle.debug.js @@ -18,7 +18,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = onClick: _resume(function() { count++; }, "__tests__/template.marko_1/onClick", $scope1_id) - }, "#a/0", $scope1_id, "a", $scope0_owned, 2)}>go${_el_resume($scope1_id, "#a/0")}`); + }, "#a/0", $scope1_id, "a", void 0, $scope0_owned, 2)}>go${_el_resume($scope1_id, "#a/0")}`); _script($scope1_id, "__tests__/template.marko_1_input_attrs#5"); _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:4", { "EventAttributes:#a/0": ["...{ ...input.attrs, onClick() { count++ } }", "4:11"] }); return 0; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/__snapshots__/html.bundle.js index b8fdd601243..393b3f3bb8e 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/__snapshots__/html.bundle.js @@ -16,7 +16,7 @@ var template_default = _template_persisted("a", (input) => { onClick: _resume(function() { count++; }, "a0", $scope1_id) - }, "a", $scope1_id, "a", $scope0_owned, 2)}>go${_el_resume($scope1_id, "a")}`); + }, "a", $scope1_id, "a", void 0, $scope0_owned, 2)}>go${_el_resume($scope1_id, "a")}`); _script($scope1_id, "a2"); _scope($scope1_id, { _: _scope_with_id($scope0_id) }); return 0; diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/sizes.json index b2ab0d4b32f..541dc0996af 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-handler/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 9748, - "brotli": 4177 + "min": 9740, + "brotli": 4183 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/__snapshots__/html.bundle.debug.js index 5c0cd3ad395..634e64e825d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/__snapshots__/html.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/__snapshots__/html.bundle.debug.js @@ -6,7 +6,7 @@ var template_default = _template_persisted("__tests__/template.marko", (input) = const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); let count = 0; - _html(`
      ${_text_resume($scope0_id, "#text/1", count)}${_el_resume($scope0_id, "#button/0")}
      ${_patch_text($scope0_id, "#text/3", input.label, void 0, $scope0_owned, 2)}
      ${_el_resume($scope0_id, "#div/2")}
      `); + _html(`
      ${_text_resume($scope0_id, "#text/1", count)}${_el_resume($scope0_id, "#button/0")}
      ${_patch_text($scope0_id, "#text/3", input.label, void 0, $scope0_owned, 2)}
      ${_el_resume($scope0_id, "#div/2")}
      `); _script($scope0_id, "__tests__/template.marko_0_input_box#7"); _script($scope0_id, "__tests__/template.marko_0_input_attrs#6"); _script($scope0_id, "__tests__/template.marko_0"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/__snapshots__/html.bundle.js index a6c84514cc1..9e2e76534fe 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/__snapshots__/html.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/__snapshots__/html.bundle.js @@ -4,7 +4,7 @@ var template_default = _template_persisted("a", (input) => { const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); const $scope0_id = _scope_id(); let count = 0; - _html(`
      ${_text_resume($scope0_id, "b", count)}${_el_resume($scope0_id, "a")}
      ${_patch_text($scope0_id, "d", input.label, void 0, $scope0_owned, 2)}
      ${_el_resume($scope0_id, "c")}
      `); + _html(`
      ${_text_resume($scope0_id, "b", count)}${_el_resume($scope0_id, "a")}
      ${_patch_text($scope0_id, "d", input.label, void 0, $scope0_owned, 2)}
      ${_el_resume($scope0_id, "c")}
      `); _script($scope0_id, "a0"); _script($scope0_id, "a1"); _script($scope0_id, "a2"); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/sizes.json index 2030927c608..8ba387fea23 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-partial/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 5720, - "brotli": 2539 + "min": 5729, + "brotli": 2549 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-state/sizes.json index 2abee79bdf1..f462fdc98b2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-spread-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 10374, - "brotli": 4441 + "min": 10366, + "brotli": 4454 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-state/sizes.json index 94ad17b978a..ca00825c9af 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-state/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 3213, - "brotli": 1608 + "min": 3196, + "brotli": 1599 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-static-scriptlets/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-static-scriptlets/sizes.json index 710ac8cc8d1..e10695e362c 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-static-scriptlets/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-static-scriptlets/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8472, - "brotli": 3762 + "min": 8433, + "brotli": 3744 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-text-holes/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-text-holes/sizes.json index 4388c8a206a..0d3636ba049 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-text-holes/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-text-holes/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2108, - "brotli": 1103 + "min": 2091, + "brotli": 1087 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/dom.bundle.debug.js new file mode 100644 index 00000000000..0b503156c1d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/dom.bundle.debug.js @@ -0,0 +1,31 @@ +// template.marko +const $template = ""; +const $walks = " D l%c"; +const $await_content__v = ($scope, v) => _text($scope["#text/0"], v); +const $await_content__$params = ($scope, $params2) => $await_content__v($scope, $params2[0]); +const $catch_content = _content_resume("__tests__/template.marko_3*content", "caught-a"); +const $placeholder_content = _content_resume("__tests__/template.marko_2*content", "wait"); +const $await_content = /*@__PURE__*/ _await_content("#text/0", "

      A:

      ", "Db%"); +const $try_content__await_promise = /*@__PURE__*/ _await_promise("#text/0", $await_content__$params); +const $try_content__input_a = /*@__PURE__*/ _closure_get("input_a", ($scope) => $try_content__await_promise($scope, $scope._.input_a)); +const $try_content__setup = ($scope) => { + $try_content__input_a($scope); + $await_content($scope); +}; +const $n = /*@__PURE__*/ _let("n/6", ($scope) => _text($scope["#text/1"], $scope.n)); +const $try = /*@__PURE__*/ _try("#text/2", "", "b%", $try_content__setup); +const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($scope["#button/0"], "click", function() { + $n($scope, +$scope.n + 1); +})); +function $setup($scope) { + $n($scope, 0); + $try($scope, { + placeholder: attrTag({ content: $placeholder_content($scope) }), + catch: attrTag({ content: $catch_content($scope) }) + }); + $setup__script($scope); +} +const $input = ($scope, input) => $input_a($scope, input.a); +const $input_a__closure = /*@__PURE__*/ _closure($try_content__input_a); +const $input_a = /*@__PURE__*/ _const("input_a", $input_a__closure); +var template_default = /*@__PURE__*/ _template("__tests__/template.marko", $template, $walks, $setup, $input); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/dom.bundle.js new file mode 100644 index 00000000000..0b699d0319e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/dom.bundle.js @@ -0,0 +1,7 @@ +// template.marko +const $catch_content = _content_resume("a1", "caught-a"); +const $placeholder_content = _content_resume("a2", "wait"); +const $n = /*@__PURE__*/ _let(6, ($scope) => _text($scope.b, $scope.g)); +const $setup__script = _script("a5", ($scope) => _on($scope.a, "click", function() { + $n($scope, +$scope.g + 1); +})); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/html.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/html.bundle.debug.js new file mode 100644 index 00000000000..ea906a09583 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/html.bundle.debug.js @@ -0,0 +1,38 @@ +// template.marko +const $template = ""; +const $walks = " D l%c"; +_shells({ + "__tests__/template.marko_4*content": "__tests__/template.marko_4*content;Db%;

      A:

      ", + "__tests__/template.marko_3*content": "__tests__/template.marko_3*content,caught-a", + "__tests__/template.marko_2*content": "__tests__/template.marko_2*content,wait", + "__tests__/template.marko_1_#text#0/await": "__tests__/template.marko_1_#text#0/await;Db%;

      A:

      ", + "__tests__/template.marko_1*content": "__tests__/template.marko_1*content;b%;", + "__tests__/template.marko": "__tests__/template.marko !__tests__/template.marko_0; D l%;" +}); +var template_default = _template_persisted("__tests__/template.marko", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_a__closures = new Set(); + let n = 0; + _html(`${_el_resume($scope0_id, "#button/0")}`); + _try($scope0_id, "#text/2", _content_resume("__tests__/template.marko_1*content", () => { + const $scope1_id = _scope_id(); + const $scope1_reason = _persisted_reason(); + _await($scope1_id, "#text/0", input.a, (v) => { + const $scope4_id = _scope_id(); + _html(`

      A:${_patch_text($scope4_id, "#text/0", v, 2, $scope0_owned, 0)}

      `); + _scope($scope4_id, {}, "__tests__/template.marko", "4:4"); + }, 1, "__tests__/template.marko_1_#text#0/await", 1); + $scope0_reason && _subscribe($input_a__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) }, "__tests__/template.marko", "3:2")); + _resume_branch($scope1_id); + }, $scope0_id), { + placeholder: attrTag({ content: _content_record("__tests__/template.marko_2*content", $scope0_id) }), + catch: attrTag({ content: _content_record("__tests__/template.marko_3*content", $scope0_id) }) + }, 1); + _script($scope0_id, "__tests__/template.marko_0"); + $scope0_reason && _scope($scope0_id, { + n, + "ClosureScopes:input_a": $input_a__closures + }, "__tests__/template.marko", 0, { n: "1:6" }); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/html.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/html.bundle.js new file mode 100644 index 00000000000..80cd6fdc1f3 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/html.bundle.js @@ -0,0 +1,36 @@ +// template.marko +_shells({ + a0: "a0;Db%;

      A:

      ", + a1: "a1,caught-a", + a2: "a2,wait", + a3: "a3;Db%;

      A:

      ", + a4: "a4;b%;", + a: "a !a5; D l%;" +}); +var template_default = _template_persisted("a", (input) => { + const $scope0_owned = _persisted_ownership(), $scope0_reason = _persisted_reason(); + const $scope0_id = _scope_id(); + const $input_a__closures = /* @__PURE__ */ new Set(); + let n = 0; + _html(`${_el_resume($scope0_id, "a")}`); + _try($scope0_id, "c", _content_resume("a4", () => { + const $scope1_id = _scope_id(); + _persisted_reason(); + _await($scope1_id, "a", input.a, (v) => { + const $scope4_id = _scope_id(); + _html(`

      A:${_patch_text($scope4_id, "a", v, 2, $scope0_owned, 0)}

      `); + _scope($scope4_id, {}); + }, 1, "a3", 1); + $scope0_reason && _subscribe($input_a__closures, _scope($scope1_id, { _: _scope_with_id($scope0_id) })); + _resume_branch($scope1_id); + }, $scope0_id), { + placeholder: attrTag({ content: _content_record("a2", $scope0_id) }), + catch: attrTag({ content: _content_record("a1", $scope0_id) }) + }, 1); + _script($scope0_id, "a5"); + $scope0_reason && _scope($scope0_id, { + g: n, + h: $input_a__closures + }); + _resume_branch($scope0_id); +}, 1, 0); diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/patches.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/patches.debug.js new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/patches.debug.js @@ -0,0 +1 @@ + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/patches.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/patches.js new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/patches.js @@ -0,0 +1 @@ + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/render.debug.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/render.debug.md new file mode 100644 index 00000000000..f40b13007f0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/render.debug.md @@ -0,0 +1,26 @@ +# Render `{"a":{},"$global":{"signal":{}}}` +```html + + + wait + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + wait + +``` +## Change +``` +UPDATE: button::text "0" => "1" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/render.md b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/render.md new file mode 100644 index 00000000000..f40b13007f0 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/render.md @@ -0,0 +1,26 @@ +# Render `{"a":{},"$global":{"signal":{}}}` +```html + + + wait + +``` + +# Update +```js +document.querySelector("button").click(); +``` +```html + + + wait + +``` +## Change +``` +UPDATE: button::text "0" => "1" +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/writes.debug.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/writes.debug.html new file mode 100644 index 00000000000..20c62559c76 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/writes.debug.html @@ -0,0 +1,22 @@ +wait + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/writes.html b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/writes.html new file mode 100644 index 00000000000..e2187d53e2b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/__snapshots__/writes.html @@ -0,0 +1,16 @@ +wait + + diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/sizes.json new file mode 100644 index 00000000000..1862c7a526e --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/sizes.json @@ -0,0 +1,16 @@ +{ + "dom": { + "template.marko.page.mjs": { + "min": 10032, + "brotli": 4316 + } + }, + "html": { + "min": 1039, + "brotli": 616 + }, + "patch": { + "min": 0, + "brotli": 1 + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/template.marko b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/template.marko new file mode 100644 index 00000000000..9083ec51474 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/template.marko @@ -0,0 +1,9 @@ + + + + +

      A:${v}

      + + <@placeholder>wait + <@catch>caught-a +
      diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/test.ts b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/test.ts new file mode 100644 index 00000000000..27369db032b --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-try-abort-disconnect/test.ts @@ -0,0 +1,29 @@ +import type { TestConfig } from "../../main.test"; + +// A persisted page whose initial stream disconnects while an await pends: +// the shared abort signal strands the body (no broken pairing data flushes) +// and the resumed prefix stays interactive. +export const config: TestConfig = { + persisted: true, + abort_ssr: true, + skip_fresh_render: true, + steps: (signal) => [ + { a: afterAbort(signal, "A") }, + (document: Document) => { + document.querySelector("button")!.click(); + }, + ], +}; + +function afterAbort(signal: AbortSignal | undefined, value: string) { + return new Promise((resolve) => { + if (!signal) return resolve(value); + signal.addEventListener( + "abort", + () => setTimeout(() => resolve(value), 0), + { + once: true, + }, + ); + }); +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-effect/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-effect/sizes.json index 4943e503f7e..b93ff2c16d4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-effect/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-effect/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 3888, - "brotli": 1902 + "min": 3887, + "brotli": 1905 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/__snapshots__/dom.bundle.debug.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/__snapshots__/dom.bundle.debug.js index b3b0271cb1f..3239c4a2d99 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/__snapshots__/dom.bundle.debug.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/__snapshots__/dom.bundle.debug.js @@ -1,13 +1,11 @@ // tags/greet/index.marko const $template$1 = " "; const $walks$1 = "D l"; -function $setup$1($scope) { - _text($scope["#text/0"], $scope.$global.locale); -} +const $setup$1 = () => {}; const $double = /*@__PURE__*/ _const("double", ($scope) => _return($scope, $scope.double)); const $input_n = ($scope, input_n) => $double($scope, input_n * 2); const $input = ($scope, input) => $input_n($scope, input.n); -var greet_default = /*@__PURE__*/ _template("__tests__/tags/greet/index.marko", $template$1, "D l", $setup$1, $input); +var greet_default = /*@__PURE__*/ _template("__tests__/tags/greet/index.marko", $template$1, "D l", 0, $input); // template.marko const $template = /*@__PURE__*/ ((_w0) => `
      ${_w0}

      `)($template$1); @@ -18,7 +16,6 @@ const $setup__script = _script("__tests__/template.marko_0", ($scope) => _on($sc })); function $setup($scope) { _var($scope, "#childScope/0", $d); - $setup$1($scope["#childScope/0"]); $count($scope, 1); $setup__script($scope); } diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/__snapshots__/dom.bundle.js b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/__snapshots__/dom.bundle.js index d2ab946ccef..6f63c2b36fb 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/__snapshots__/dom.bundle.js +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/__snapshots__/dom.bundle.js @@ -1,5 +1,5 @@ // tags/greet/index.marko -const $double = /*@__PURE__*/ _const(4, ($scope) => _return($scope, $scope.e)); +const $double = /*@__PURE__*/ _const(5, ($scope) => _return($scope, $scope.f)); const $input_n = ($scope, input_n) => $double($scope, input_n * 2); // template.marko diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/sizes.json index f288945e06a..4fcc6fe9027 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-global-child/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3478, - "brotli": 1704 + "min": 3477, + "brotli": 1712 }, "files": { "tags/greet/index.marko": 194, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-pure-server/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-pure-server/sizes.json index 89bd51bfcae..7b3134804c1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-pure-server/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-pure-server/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 2131, - "brotli": 1103 + "min": 2130, + "brotli": 1116 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-server-if/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-server-if/sizes.json index 6788a47c21f..90bc6ed19c2 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-server-if/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-server-if/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 8088, - "brotli": 3628 + "min": 8070, + "brotli": 3636 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-server/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-server/sizes.json index b1cb7cb19ae..ec9974c65b4 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-server/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-server/sizes.json @@ -1,8 +1,8 @@ { "dom": { "template.marko.page.mjs": { - "min": 3337, - "brotli": 1647 + "min": 3336, + "brotli": 1653 } }, "html": { diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-state/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-state/sizes.json index aa2be596b03..c98a36f06e1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-state/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-state/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3444, - "brotli": 1702 + "min": 3443, + "brotli": 1700 }, "files": { "tags/doubler/index.marko": 212, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-structure/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-structure/sizes.json index 827d4860951..5f3f583fad1 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-structure/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-structure/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 6724, - "brotli": 3071 + "min": 6723, + "brotli": 3065 }, "files": { "tags/doubler/index.marko": 212, diff --git a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-two-hop/sizes.json b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-two-hop/sizes.json index b72f3f9afd0..6636cfdc74f 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/persisted-var-two-hop/sizes.json +++ b/packages/runtime-tags/src/__tests__/fixtures/persisted-var-two-hop/sizes.json @@ -2,8 +2,8 @@ "dom": { "template.marko.page.mjs": { "total": { - "min": 3502, - "brotli": 1731 + "min": 3501, + "brotli": 1718 }, "files": { "tags/doubler/index.marko": 214, diff --git a/packages/runtime-tags/src/dom.ts b/packages/runtime-tags/src/dom.ts index 190b93245a6..3692b9b8655 100644 --- a/packages/runtime-tags/src/dom.ts +++ b/packages/runtime-tags/src/dom.ts @@ -120,6 +120,13 @@ export { _init_for_closure, _init_for_selector, _init_if_closure, + // A `tagNameLoad` input init has no module-graph reference (a construct + // resolves it by serialized id), so the translator emits these `_resume` + // aliases — which the pure-call list excludes — to keep the registration. + _init_closure_get as _resume_init_closure_get, + _init_for_closure as _resume_init_for_closure, + _init_for_selector as _resume_init_for_selector, + _init_if_closure as _resume_init_if_closure, _let, _let_change, _or, diff --git a/packages/runtime-tags/src/dom/load.ts b/packages/runtime-tags/src/dom/load.ts index 314c3a6bf3e..3494b2ad57a 100644 --- a/packages/runtime-tags/src/dom/load.ts +++ b/packages/runtime-tags/src/dom/load.ts @@ -9,9 +9,9 @@ import { type Template, } from "../common/types"; import { addAwaitCounter, renderCatch } from "./control-flow"; -import { queueAsyncRender, runId } from "./queue"; +import { queueAsyncRender, queueEffect, runId } from "./queue"; import { _content, type Renderer, setupBranch, type SetupFn } from "./renderer"; -import { readyFailed, withLazy } from "./resume"; +import { ready, readyFailed, withLazy } from "./resume"; import { insertBranchBefore, syncGen } from "./scope"; import type { Signal } from "./signals"; import { _template } from "./template"; @@ -53,7 +53,13 @@ export const _load_template = /*@__PURE__*/ withLazy( ), ); }, - loadFailed(branch as BranchScope, awaitCounter), + // The template's ready-channel id (the client half of the + // translator's `getReadyId`; the prefix pairs with its optimize flag). + loadFailed( + branch as BranchScope, + awaitCounter, + (MARKO_DEBUG ? "ready:" : "_") + id, + ), ); }, _load_signal(() => @@ -69,6 +75,9 @@ export const _load_setup = /*@__PURE__*/ withLazy( nodeAccessor: EncodedAccessor, childScopeAccessor: EncodedAccessor, load: () => Promise, + // Only a persisted `linkAssets` build has a channel (and deferred frame + // data) for the load to drive; other builds omit it. + readyId?: string, ) => { if (!MARKO_DEBUG) { nodeAccessor = decodeAccessor(nodeAccessor as number); @@ -81,6 +90,8 @@ export const _load_setup = /*@__PURE__*/ withLazy( return (owner: Scope) => { const child = owner[childScopeAccessor] as BranchScope; if (renderer) { + // A later instance of an already-loaded module: the first load + // already counted down and drove the channel. insertLoaded(renderer, child, owner[nodeAccessor] as ChildNode); } else { const awaitCounter = addAwaitCounter(owner); @@ -94,10 +105,11 @@ export const _load_setup = /*@__PURE__*/ withLazy( child, owner[nodeAccessor] as ChildNode, awaitCounter, + readyId, ), ); }, - loadFailed(child, awaitCounter), + loadFailed(child, awaitCounter, readyId), ); } }; @@ -109,6 +121,7 @@ function insertLoaded( branch: BranchScope, marker: ChildNode, awaitCounter?: ReturnType, + readyId?: string, ) { const parent = marker.parentNode as Element, values = branch[AccessorProp.Load] as LoadValues, @@ -116,13 +129,16 @@ function insertLoaded( insertBranchBefore(branch, parent, marker); marker.remove(); awaitCounter?.c(); + // A constructed site drives its channel once the content is live, so + // deferred frame data (re-shipping this render's state) drains after. + if (readyId) queueEffect(branch, () => ready(readyId)); }; let remaining: number; syncGen(branch); renderer[RendererProp.Clone]!(branch, parent.namespaceURI!); branch[AccessorProp.Load] = 0; if ((remaining = values?.size as number)) { - const fail = loadFailed(branch, awaitCounter); + const fail = loadFailed(branch, awaitCounter, readyId); for (const [promise, entry] of values!) { promise.then( (signal) => { @@ -152,6 +168,7 @@ function insertLoaded( function loadFailed( scope: BranchScope, awaitCounter?: ReturnType, + readyId?: string, ) { return (error: unknown) => { if (awaitCounter) { @@ -160,7 +177,7 @@ function loadFailed( if (awaitCounter.m) awaitCounter.i = 0; else awaitCounter.c(); } - readyFailed(); + readyFailed(readyId); queueAsyncRender(scope, renderCatch, error); }; } diff --git a/packages/runtime-tags/src/dom/patch-attrs.feat.ts b/packages/runtime-tags/src/dom/patch-attrs.feat.ts index f3330183550..91329afee6c 100644 --- a/packages/runtime-tags/src/dom/patch-attrs.feat.ts +++ b/packages/runtime-tags/src/dom/patch-attrs.feat.ts @@ -1,18 +1,36 @@ import { type Accessor, PatchKey } from "../common/types"; +import { controllableRenders } from "./controllable"; import { _attrs, _attrs_partial, _attrs_script } from "./dom"; // The set may carry bound handlers. import "./patch-value-bind.feat"; import { queueEffect } from "./queue"; import { patchers } from "./resume"; -// A spread's set re-applies as its render would (a `[set, skip]` pair -// leaves the statics after the spread alone); its effect then re-attaches. +// A spread's set re-applies as its render would (`[set, skip]` leaves the +// statics alone; a trailing `1` re-claims the element's controllable). patchers[PatchKey.Attrs] = (scope, key, value) => { const accessor = key.slice(PatchKey.Attrs.length) as Accessor; + let skip: Record | 0 | undefined; + let controllable: (typeof controllableRenders)[string] | undefined; if (Array.isArray(value)) { - _attrs_partial(scope, accessor, value[0] || undefined, value[1]); + skip = value[1] as typeof skip; + if (value[2]) { + controllable = controllableRenders[(scope[accessor] as Element).tagName]; + } + value = value[0]; + } + // The wire's empty-set `0` flows through as-is: every consumer only + // truthiness-checks or `for..in`s the set, so it acts like `undefined`. + if (skip) { + _attrs_partial( + scope, + accessor, + value as Record, + skip, + controllable, + ); } else { - _attrs(scope, accessor, (value || undefined) as Record); + _attrs(scope, accessor, value as Record, controllable); } queueEffect(scope, () => _attrs_script(scope, accessor)); }; diff --git a/packages/runtime-tags/src/dom/patch-boundary.feat.ts b/packages/runtime-tags/src/dom/patch-boundary.feat.ts index f23fa5d85e6..800bbbb9df7 100644 --- a/packages/runtime-tags/src/dom/patch-boundary.feat.ts +++ b/packages/runtime-tags/src/dom/patch-boundary.feat.ts @@ -141,10 +141,12 @@ patchers[PatchKey.Pending] = (scope, key, value) => { // The server now owns this await frame. Invalidate a promise started while // setting up a newly constructed parent body so its stale resolution drops. scope[(AccessorPrefix.Promise + accessor) as Accessor] = 0 as never; + // A settle from an earlier response must not hide this frame's pending UI. + settled.get(scope)?.delete(accessor); // A construct has no live await branch: the entry's id delivers the body // content record its frame shipped. Mirrors `_await_content`. if (typeof value === "string" && !scope[link]) { - const renderer = getShellContent(shells[value] || failPatch()); + const renderer = getShellContent(shells[value]); const pendingScopes = collectScopes( () => (( @@ -207,10 +209,7 @@ function resolveBoundaryContent(id: string | 0, owner: Scope) { if (id === 0) return 0; const shell = shells[id]; if (shell) return getShellContent(shell, id, owner); - const registered = getRegisteredWithScope(id) as - | ((owner: Scope) => unknown) - | undefined; - return registered ? registered(owner) : failPatch(); + return (getRegisteredWithScope(id) as (owner: Scope) => unknown)(owner); } const applyChild = patchers[PatchKey.Child]; @@ -230,9 +229,8 @@ patchers[PatchKey.Child] = (scope, key, value) => { if (!scope[link]) { const shell = shells[contentId]; const renderer = ((shell && getShellContent(shell, contentId)) || - getRegisteredWithScope(contentId) || - failPatch()) as Renderer; - const marker = (scope[accessor as Accessor] || failPatch()) as ChildNode; + getRegisteredWithScope(contentId)) as Renderer; + const marker = scope[accessor as Accessor] as ChildNode; const inside = marker.nodeType === 1; const parentNode = inside ? (marker as unknown as Element) diff --git a/packages/runtime-tags/src/dom/patch-child.feat.ts b/packages/runtime-tags/src/dom/patch-child.feat.ts index 8214339a7bd..8f97bb9a7c8 100644 --- a/packages/runtime-tags/src/dom/patch-child.feat.ts +++ b/packages/runtime-tags/src/dom/patch-child.feat.ts @@ -11,6 +11,8 @@ import { failPatch, patchers, patchScope } from "./resume"; // construct's walk created it; it takes the parent as owner here). patchers[PatchKey.Child] = (scope, key, value) => { const child = scope[key.slice(PatchKey.Child.length) as Accessor] as Scope; + // Same-build reachable: a patch during the initial stream can precede + // the boundary's resumed branch (see pair-patches-into-still-streaming). if (!child) failPatch(); child[AccessorProp.Owner] ??= scope; patchScope(value as Scope, child); diff --git a/packages/runtime-tags/src/dom/patch-control-checked-value.feat.ts b/packages/runtime-tags/src/dom/patch-control-checked-value.feat.ts new file mode 100644 index 00000000000..22c0830cb35 --- /dev/null +++ b/packages/runtime-tags/src/dom/patch-control-checked-value.feat.ts @@ -0,0 +1,19 @@ +import { type Accessor, ControlledType, type Scope } from "../common/types"; +import { _attr_input_checkedValue } from "./controllable"; +import { patchControls } from "./patch-control.feat"; + +// A group entry carries `[checkedValue, value]`: each input in the group +// applies its own comparison through the same helper CSR uses. +patchControls[ControlledType.InputCheckedValue] = ( + scope: Scope, + accessor: Accessor, + value: unknown, + handler?: unknown, +) => + _attr_input_checkedValue( + scope, + accessor, + (value as unknown[])[0], + handler, + (value as unknown[])[1], + ); diff --git a/packages/runtime-tags/src/dom/patch-control.feat.ts b/packages/runtime-tags/src/dom/patch-control.feat.ts index 70245d8e4f5..bf40c8b5a16 100644 --- a/packages/runtime-tags/src/dom/patch-control.feat.ts +++ b/packages/runtime-tags/src/dom/patch-control.feat.ts @@ -7,7 +7,7 @@ import { type Scope, } from "../common/types"; import { queueRender } from "./queue"; -import { failPatch, patchers } from "./resume"; +import { patchers } from "./resume"; // Kind-keyed control applies, filled by the per-kind patch feats a page's // controls link: the wire keys `kind + accessor` (kind is a @@ -27,11 +27,10 @@ export const patchControls: { patchers[PatchKey.Control] = (scope, key, value) => { const type = +key[PatchKey.Control.length] as ControlledType; const accessor = key.slice(PatchKey.Control.length + 1) as Accessor; - const apply = patchControls[type] || failPatch(); queueRender( scope, (scope) => - apply( + patchControls[type]!( scope, accessor, value, diff --git a/packages/runtime-tags/src/dom/patch-dynamic-tag.feat.ts b/packages/runtime-tags/src/dom/patch-dynamic-tag.feat.ts index db656f19e00..e8167117e80 100644 --- a/packages/runtime-tags/src/dom/patch-dynamic-tag.feat.ts +++ b/packages/runtime-tags/src/dom/patch-dynamic-tag.feat.ts @@ -10,12 +10,7 @@ import { _dynamic_tag } from "./control-flow"; import "./patch-child.feat"; import { getShellContent, shells } from "./patch-shells"; import type { Renderer } from "./renderer"; -import { - constructPatchers, - failPatch, - getRegisteredWithScope, - patchers, -} from "./resume"; +import { constructPatchers, getRegisteredWithScope, patchers } from "./resume"; // Re-renders the tag's `input` content through its signal; an id-only // entry constructs its content record, else pairs the same one or rejects. @@ -34,10 +29,7 @@ patchers[PatchKey.DynamicTag] = constructPatchers[PatchKey.DynamicTag] = ( const shell = shells[id]; renderer = shell ? getShellContent(shell, id) - : (getRegisteredWithScope(id) as Renderer) || failPatch(); - } else if (renderer === undefined) { - // Its registration was shaken or never loaded: skew, reject (`0` is none). - failPatch(); + : (getRegisteredWithScope(id) as Renderer); } _dynamic_tag( (MARKO_DEBUG ? accessor : encodeAccessor(accessor)) as EncodedAccessor, diff --git a/packages/runtime-tags/src/dom/patch-ready.feat.ts b/packages/runtime-tags/src/dom/patch-ready.feat.ts index 0ea65fc191c..45204b79490 100644 --- a/packages/runtime-tags/src/dom/patch-ready.feat.ts +++ b/packages/runtime-tags/src/dom/patch-ready.feat.ts @@ -27,9 +27,15 @@ installReady(markReady, failReady); // Receives a frame's ready-channel record (an explicit call in the frame // text): data for a loaded channel merges into the live render's ready // record for this frame's run; the rest waits for its module. +// Live-record pushes of the frame being applied (alternating batch, +// prior length), undone if it rejects. +const framePushes: (unknown[] | number)[] = []; + function acceptReady(record: Record) { const render = patchRender as RenderData; + framePushes.length = 0; for (const readyId in record) { + if (failed.has(readyId)) throw 0; if (isReady(readyId)) { pushBatch(render, readyId, record[readyId]); } else { @@ -58,6 +64,7 @@ function acceptReady(record: Record) { // strings keep their native resume handling. function pushBatch(render: RenderData, readyId: string, batch: unknown[]) { const target = ((render.b ??= {})[readyId] ??= []); + framePushes.push(target, target.length); for (const partial of batch) { target.push( typeof partial === "object" && partial && !Array.isArray(partial) @@ -90,12 +97,28 @@ function markReady(readyId: string) { } } -function failReady() { - for (const entry of pending.values()) settle(entry, false); - pending.clear(); +// A dead channel can never make its server content whole: pending appliers +// settle rejected (their caller navigates) and later frames naming it reject. +const failed = new Set(); +function failReady(readyId: string) { + failed.add(readyId); + for (const [render, entry] of pending) { + if (entry.c.has(readyId)) { + pending.delete(render); + settle(entry, false); + } + } } function discardReady(render: RenderData) { + // A rejected frame's channel pushes must not survive to a later run; + // truncating is exact unless the batch was partially consumed mid-run — + // then the caller is navigating anyway and dropping the rest is safe. + while (framePushes.length) { + const length = framePushes.pop() as number; + const batch = framePushes.pop() as unknown[]; + if (batch.length > length) batch.length = length; + } const entry = pending.get(render); if (entry) { pending.delete(render); diff --git a/packages/runtime-tags/src/dom/patch-shells.ts b/packages/runtime-tags/src/dom/patch-shells.ts index e837cb13f34..1afd7dd5fe0 100644 --- a/packages/runtime-tags/src/dom/patch-shells.ts +++ b/packages/runtime-tags/src/dom/patch-shells.ts @@ -11,7 +11,6 @@ import { _patch_records, constructing, constructPatchers, - failPatch, getRegisteredWithScope, patchConstruct, patchers, @@ -41,15 +40,13 @@ constructPatchers[PatchKey.Init] = (scope, _key, ids) => type SetupFn = (branch: Scope) => void; type SetupIds = [inits: SetupFn[], effects?: SetupFn[]]; -// A missing registration means required client code was tree-shaken: -// constructing would silently misrender. Closure renders ride as `._`. +// Closure renders ride as `._`. export const resolveSetupIds = (ids: string) => ids.split("!").map((part) => part ? part.split(" ").map((id) => { - const fn = getRegisteredWithScope(id); - return ((fn && ((fn as { _?: unknown })._ || fn)) || - failPatch()) as SetupFn; + const fn = getRegisteredWithScope(id) as { _?: unknown }; + return (fn._ || fn) as SetupFn; }) : [], ) as SetupIds; diff --git a/packages/runtime-tags/src/dom/patch-value-bind.feat.ts b/packages/runtime-tags/src/dom/patch-value-bind.feat.ts index 98516a27a62..55ffe5bdff4 100644 --- a/packages/runtime-tags/src/dom/patch-value-bind.feat.ts +++ b/packages/runtime-tags/src/dom/patch-value-bind.feat.ts @@ -20,9 +20,7 @@ const binds = () => { }; patchers[PatchKey.BindSource] = (scope, key, id) => { binds()[key.slice(PatchKey.BindSource.length)] = ( - (getRegisteredWithScope(id as string) || failPatch()) as ( - scope: Scope, - ) => unknown + getRegisteredWithScope(id as string) as (scope: Scope) => unknown )(scope); }; // The frame's bind references: each wrapper resolves lazily (its bind diff --git a/packages/runtime-tags/src/dom/patch-value.feat.ts b/packages/runtime-tags/src/dom/patch-value.feat.ts index fd7da03fb39..8f21123065c 100644 --- a/packages/runtime-tags/src/dom/patch-value.feat.ts +++ b/packages/runtime-tags/src/dom/patch-value.feat.ts @@ -12,17 +12,16 @@ import { import { patchFills } from "./signals"; // A soft miss is a fill whose intersection was tree-shaken: nothing to -// update. A construct's seed missing means required client code is gone. +// update. A construct's seed is required, so a miss crashes to reject. patchers[PatchKey.Value] = (scope, key, value) => patchFills[key.slice(PatchKey.Value.length)]?.(scope, value); constructPatchers[PatchKey.Value] = (scope, key, value) => - (patchFills[key.slice(PatchKey.Value.length)] || failPatch())(scope, value); + patchFills[key.slice(PatchKey.Value.length)](scope, value); // A bind installs a handler the way CSR setup does: anchored at the scope // its factory was registered against, writing down the child-link path // (`[registerId, ...links, slot]`) after the apply so freshly constructed -// targets exist. Any break — poison `0`, missing link, missing -// registration — rejects the patch. +// targets exist. A poison `0` (withheld handler path) rejects the patch. patchers[PatchKey.Bind] = (scope, _key, entry) => { if (!entry) failPatch(); queueEffect(scope, (scope) => { @@ -42,12 +41,9 @@ patchers[PatchKey.Bind] = (scope, _key, entry) => { ) : target[link as Accessor] ) as Scope; - if (!target) failPatch(); } target[slot] = ( - (getRegisteredWithScope(registerId) || failPatch()) as ( - scope: Scope, - ) => unknown + getRegisteredWithScope(registerId) as (scope: Scope) => unknown )(scope); }); }; diff --git a/packages/runtime-tags/src/dom/resume.ts b/packages/runtime-tags/src/dom/resume.ts index 2ae54e1a27f..c6a5d766b26 100644 --- a/packages/runtime-tags/src/dom/resume.ts +++ b/packages/runtime-tags/src/dom/resume.ts @@ -43,6 +43,11 @@ export interface RenderData { m?(effects: unknown[]): unknown[]; // Blocking resumes keyed by ready id. b?: Record; + // Load-error sink: a lazy loader script's `onerror` reports its channel + // id here once the runtime has installed it (`init`)... + e?(readyId?: string): void; + // ...and parks it here before then (`init` drains this queue). + f?: string[] | void; /* --- Used by inline runtime --- */ // Document @@ -67,35 +72,32 @@ export let onPatchRecord: ((entry: string) => void) | undefined; export const _patch_records = (handler: NonNullable) => (onPatchRecord = handler); // Rejects the applying patch: unwinds to `applyPatch`'s catch, and the -// caller falls back to a full document navigation. +// caller falls back to a full document navigation. Only conditions +// reachable in a matched build guard explicitly (lazy load failures, +// withheld handlers, server-decided sentinels); skew rejects upstream via +// the build id, so anything else crashes naturally into the same catch. export const failPatch = () => { throw 0; }; // Construct application dispatch: everything in a setup envelope is -// REQUIRED, so misses fail (paired refresh via `patchers` stays soft — -// a shaken fill is a correct no-op). +// REQUIRED (paired refresh via `patchers` stays soft — a shaken fill is +// a correct no-op). export const constructPatchers: typeof patchers = {}; export const patchConstruct = (setup: Scope, live: Scope) => { for (const key in setup) { - ( - constructPatchers[ - MARKO_DEBUG ? key.slice(0, key.indexOf(":") + 1) : key[0] - ] || failPatch() - )(live, key, setup[key as keyof Scope]); + constructPatchers[ + MARKO_DEBUG ? key.slice(0, key.indexOf(":") + 1) : key[0] + ](live, key, setup[key as keyof Scope]); } }; // Applies a patch partial to its live counterpart; structural patchers -// recurse back through here, so no scope is ever addressed by id. An -// entry kind this bundle has no patcher for rejects: skew, never a -// silently unapplied frame. +// recurse back through here, so no scope is ever addressed by id. export const patchScope = (partial: Scope, live: Scope) => { for (const key in partial) { - ( - patchers[ - // Debug accessor prefixes are multi-character, ending ":". - MARKO_DEBUG ? key.slice(0, key.indexOf(":") + 1) : key[0] - ] || failPatch() - )(live, key, partial[key as keyof Scope]); + patchers[ + // Debug accessor prefixes are multi-character, ending ":". + MARKO_DEBUG ? key.slice(0, key.indexOf(":") + 1) : key[0] + ](live, key, partial[key as keyof Scope]); } }; let curRenders: Renders; @@ -105,9 +107,8 @@ let embedRenders: // Only assigned by `ready()`, so the lazy stream machinery guarded by // `readyIds` checks is dropped from apps without lazy tags. let readyIds: undefined | Set; -let failedIds: undefined | Set; let patchReady: undefined | ((readyId: string) => void); -let patchReadyFailed: undefined | (() => void); +let patchReadyFailed: undefined | ((readyId: string) => void); // Lazy load support latch, set as `dom/load.ts`'s runtime is evaluated, which // is before any resume; a page without lazy tags folds it and the retention away. let lazyEnabled: undefined | 1; @@ -120,6 +121,9 @@ export let patchId = 0; export function beginPatch(renderId: string) { const render = (patchRender = curRenders[renderId]); + // A page with no effects never wrote a walk call; pairing into resumed + // branches needs the walked links, so finish the resume before patching. + render.w(); patching = 1; patchId++; return render; @@ -150,26 +154,25 @@ export function ready(readyId: string) { export function installReady( onReady: (readyId: string) => void, - onFail: () => void, + onFail: (readyId: string) => void, ) { patchReady = onReady; patchReadyFailed = onFail; } -// A lazy module that will never arrive can never drain a deferred patch; -// pending patches settle as rejected so their callers navigate, and the -// debug build reports the channel instead of staying silent (repeat -// reports fold). +// A channel module that will never arrive can never drain the data waiting +// on it: the persisted feature (when installed) settles pending patches and +// rejects later frames naming the channel. Id-less runtime-managed load +// failures never gate a channel (each channel's entry reports itself). export function readyFailed(readyId?: string) { if (MARKO_DEBUG) { - if (readyId && !failedIds?.has(readyId) && !readyIds?.has(readyId)) { - (failedIds ||= new Set()).add(readyId); + if (readyId && !readyIds?.has(readyId)) { console.error( `The lazy module for "${readyId}" failed to load; its server-rendered content cannot become interactive.`, ); } } - patchReadyFailed?.(); + if (readyId) patchReadyFailed?.(readyId); } export function isReady(readyId: string) { @@ -490,6 +493,14 @@ export function init(runtimeId = DEFAULT_RUNTIME_ID) { } } + // Loader `onerror` sink (`html/assets.ts`); installed only when the + // patch-ready feature latches, which shakes it from other bundles. + // A loader that failed before this module evaluated parked its id + // on the queue; from here on failures report directly. + if (patchReadyFailed) { + render.e = readyFailed; + render.f = render.f?.forEach(readyFailed); + } render.m = (effects: unknown[]) => { processResumes(render.r, effects); diff --git a/packages/runtime-tags/src/html/assets.ts b/packages/runtime-tags/src/html/assets.ts index 4f8af71387b..b777f2c9418 100644 --- a/packages/runtime-tags/src/html/assets.ts +++ b/packages/runtime-tags/src/html/assets.ts @@ -7,6 +7,7 @@ import { _html, $global, getState, + requireMainRuntime, writeScript, writeWaitReady, } from "./writer"; @@ -43,6 +44,9 @@ type Trigger = LoadTrigger; interface Asset { id: string; triggers?: Trigger[]; + /** A persisted page's loader reports load errors to the ready-failed + * sink (`render.e`) in production, so pending patches settle. */ + reportErrors?: 1; } declare module "../common/types" { @@ -66,13 +70,14 @@ export function withLoadAssets( renderer: ServerRenderer, assetId: string, triggers?: Trigger[], + reportErrors?: 1, ): ServerRenderer { return Object.assign((input: unknown) => { if (getState().writesPatches) { return writeWaitReady(assetId, renderer, input); } const g = $global(); - addAsset(g, assetId, triggers); + addAsset(g, assetId, triggers, reportErrors); _html(flush(g, "")); return writeWaitReady(assetId, renderer, input); }, renderer); @@ -132,10 +137,12 @@ function flush(g: $Global, html: string) { } for (; di < length; di++) { - const { id, triggers } = assets[di]; + const { id, triggers, reportErrors } = assets[di]; const deferHTML = assetFlush(g, "defer", id); if (triggers) { - if (deferHTML) writeTriggerScript(id, deferHTML, triggers); + if (deferHTML) { + writeTriggerScript(g, id, deferHTML, triggers, reportErrors); + } } else { result += deferHTML; } @@ -146,13 +153,18 @@ function flush(g: $Global, html: string) { return result + html; } -function addAsset(g: $Global, id: string, triggers?: Trigger[]) { +function addAsset( + g: $Global, + id: string, + triggers?: Trigger[], + reportErrors?: 1, +) { const assets = g[kAssets]; if (!assets) { - g[kAssets] = [{ id, triggers }]; + g[kAssets] = [{ id, triggers, reportErrors }]; g[kBlockIndex] = g[kDeferIndex] = 0; } else if (!assets.find((a) => a.id === id)) { - assets.push({ id, triggers }); + assets.push({ id, triggers, reportErrors }); } else if (MARKO_DEBUG) { // Invariant: an asset streams one trigger script, so it must be requested // with a single consistent `load` trigger; only the first one applies. @@ -165,17 +177,39 @@ function addAsset(g: $Global, id: string, triggers?: Trigger[]) { } } -function writeTriggerScript(id: string, html: string, triggers: Trigger[]) { +function writeTriggerScript( + g: $Global, + id: string, + html: string, + triggers: Trigger[], + reportErrors?: 1, +) { const htmlStr = _escape_script(JSON.stringify(html)); - // A loader script that fails at the network level never evaluates, so the - // debug build reports from the script's own error event; matches the - // load-entry rejection arm's diagnostic. - const insert = MARKO_DEBUG - ? `(d=new Range().createContextualFragment(h),d.querySelectorAll("script").forEach(s=>s.onerror=()=>console.error(${_escape_script( + // The error sink hangs off the walker-created render object; make sure the + // bootstrap is emitted even if no resume content needed it yet. + if (reportErrors) requireMainRuntime(); + // A loader that fails at the network level never evaluates, so its own + // error event reports to the ready-failed sink (`render.e`). + const onError = [ + MARKO_DEBUG && + `console.error(${_escape_script( JSON.stringify( `The lazy module for "${id}" failed to load; its server-rendered content cannot become interactive.`, ), - )})),p.after(d))` + )})`, + reportErrors && + // The runtime installs the sink (`render.e`) only once its module + // evaluates; a failure before then parks its id on `render.f`, which + // `init` (dom/resume.ts) drains. Both ids are identifier-safe + // (`runtimePrefix` dot-joins them). + `((r,f)=>r.e?r.e(f):(r.f||=[]).push(f))(self.${g.runtimeId}.${ + g.renderId + },${_escape_script(JSON.stringify(id))})`, + ].filter(Boolean); + const insert = onError.length + ? `(d=new Range().createContextualFragment(h),d.querySelectorAll("script").forEach(s=>s.onerror=()=>${ + onError.length > 1 ? `(${onError.join(",")})` : onError[0] + }),p.after(d))` : `p.after(new Range().createContextualFragment(d=h))`; const exprs = triggers.map((trigger) => { const options = trigger.options && toObjectExpression(trigger.options); diff --git a/packages/runtime-tags/src/html/patch.ts b/packages/runtime-tags/src/html/patch.ts index cb11d8249a3..36d11678f45 100644 --- a/packages/runtime-tags/src/html/patch.ts +++ b/packages/runtime-tags/src/html/patch.ts @@ -38,6 +38,7 @@ import { isInResumedBranch, maskGroup, patchPartial, + peekPatchPartial, type ScopeInternals, type SerializeReasonValue, State, @@ -147,7 +148,7 @@ class PatchState extends State { contentId?: string, slotIds?: (string | 0 | undefined)[], ) { - if (!this.patchInert && !this.patchPartials?.[branchId]) { + if (!this.patchInert && !peekPatchPartial(this, branchId)) { const link = AccessorPrefix.BranchScopes + accessor; (this.patchParents ??= {})[branchId] = [scopeId, link]; (this.patchPending ??= {})[branchId] = [ @@ -179,8 +180,7 @@ class PatchState extends State { } const out = scripts ? scripts + "\n" : ""; this.patchFlushed = undefined; - this.patchPartials = undefined; - this.patchSerializeStates = undefined; + this.patchTrees = undefined; this.serializer = new Serializer(); return out; } @@ -233,27 +233,23 @@ class PatchState extends State { // Shape-typed entry, densest form first: a bare number is the // selection + 1 (`0` hides), and empty/zero members drop. const branchPartial = - branchIndex === undefined ? undefined : this.patchPartials?.[branchId]; - writePatch( - scopeId, - { - [PatchKey.Branch + accessor]: - branchIndex === undefined - ? 0 - : branchIndex - ? branchPartial || shellId - ? shellId - ? [branchIndex, branchPartial || {}, shellId] - : [branchIndex, branchPartial || {}] - : branchIndex + 1 - : branchPartial - ? shellId - ? [branchPartial, shellId] - : [branchPartial] - : shellId || 1, - }, - this.patchSerializeStates?.[branchId], - ); + branchIndex === undefined ? undefined : peekPatchPartial(this, branchId); + writePatch(scopeId, { + [PatchKey.Branch + accessor]: + branchIndex === undefined + ? 0 + : branchIndex + ? branchPartial || shellId + ? shellId + ? [branchIndex, branchPartial || {}, shellId] + : [branchIndex, branchPartial || {}] + : branchIndex + 1 + : branchPartial + ? shellId + ? [branchPartial, shellId] + : [branchPartial] + : shellId || 1, + }); // Later settle frames nest under the live branch as a Child apply. if (branchIndex !== undefined) { (this.patchPending ??= {})[branchId] = [ @@ -397,7 +393,7 @@ export function _patch_child( const state = getState(); if (state.writesPatches) { (state.patchParents ??= {})[childScopeId] = [scopeId, accessor]; - const partial = state.patchPartials?.[childScopeId]; + const partial = peekPatchPartial(state, childScopeId); if (partial) { writePatch(scopeId, { [PatchKey.Child + accessor]: partial, @@ -693,6 +689,7 @@ export function _patch_attrs( accessor: Accessor, scopeId: number, tagName: string, + controllable?: 1, owned?: SerializeReasonValue, group?: number, ) { @@ -700,7 +697,17 @@ export function _patch_attrs( if (state.writesPatches) { if (ownedWrite(owned, group)) { writeEmbeddedBinds(state as PatchState, data); - writeOwned(scopeId, PatchKey.Attrs + accessor, data ?? 0, owned, group); + // `controllable` marks a spread that owns the element's controllable + // (no static attr does), so only then does the client re-claim it. + // A bare set is the common entry; the array form (`Array.isArray` + // discriminates) carries `skip`/`controllable` without key bytes. + writeOwned( + scopeId, + PatchKey.Attrs + accessor, + controllable ? [data ?? 0, 0, 1] : (data ?? 0), + owned, + group, + ); } } else { getChunk()!.needsWalk = true; @@ -715,6 +722,7 @@ export function _patch_attrs_partial( accessor: Accessor, scopeId: number, tagName: string, + controllable?: 1, owned?: SerializeReasonValue, group?: number, ) { @@ -725,7 +733,7 @@ export function _patch_attrs_partial( writeOwned( scopeId, PatchKey.Attrs + accessor, - [data ?? 0, skip], + controllable ? [data ?? 0, skip, 1] : [data ?? 0, skip], owned, group, ); diff --git a/packages/runtime-tags/src/html/writer.ts b/packages/runtime-tags/src/html/writer.ts index 0b5340f2525..e8c1f53b6f8 100644 --- a/packages/runtime-tags/src/html/writer.ts +++ b/packages/runtime-tags/src/html/writer.ts @@ -181,6 +181,12 @@ export function writeScript(script: string) { $chunk.writeScript(script); } +// Guarantees the walker bootstrap (which creates `self[runtimeId][renderId]`) +// flushes with or before this chunk's scripts. +export function requireMainRuntime() { + $chunk.boundary.state.needsMainRuntime = true; +} + export function _script(scopeId: number, registryId: string) { if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) { _resume_branch(scopeId); @@ -339,20 +345,44 @@ export function writePatch( } } +export function peekPatchPartial(state: State, scopeId: number) { + return state.patchTrees?.get($chunk.serializeState)?.[scopeId]; +} + export function patchPartial( state: State, scopeId: number, - serializeState = $chunk.serializeState, -) { + serializeState: SerializeState = $chunk.serializeState, +): Record { if (state.patchInert) return {}; - const partials = (state.patchPartials ??= {}); + // One flush-lived merge tree per serialize state (a ready channel's + // content must not apply before its module); `flushChunk` drops the map. + const trees = (state.patchTrees ??= new Map()); + let partials = trees.get(serializeState); + if (!partials) trees.set(serializeState, (partials = {})); let partial = partials[scopeId]; if (!partial) { - partial = partials[scopeId] = {}; - if (serializeState.readyId) { - (state.patchSerializeStates ??= {})[scopeId] = serializeState; - } const pending = state.patchPending?.[scopeId]; + if (serializeState.readyId && !pending && scopeId !== state.rootScopeId) { + const link = state.patchParents?.[scopeId]; + if (link && typeof link[1] === "string") { + // Hang this scope's partial off its parent's boundary child entry + // (parent scope `link[0]`, slot `link[1]`): the live page reaches + // it by following that slot when the channel's module applies. + partial = partials[scopeId] = {}; + writePatch( + link[0], + { [PatchKey.Child + link[1]]: partial }, + serializeState, + ); + return partial; + } + // No linkable hop (keyed loop items): the write rides the main tree + // embedded in its structural entry, so it cannot defer — construct + // data naming a not-yet-registered id then rejects at apply. + return patchPartial(state, scopeId, state); + } + partial = partials[scopeId] = {}; if (pending) { // A child links into its parent's entry on its first write; boundary // construct ids ride it and a paired branch ignores them. @@ -1147,6 +1177,9 @@ export function _await( if (resumeMarker) { const branchId = _peek_scope_id(); $chunk.boundary.state.pairBranch?.(scopeId, accessor, branchId); + // The Child entry is the settle signal: force it so a body + // with no writes of its own still attaches the pending UI. + if (writesPatches) patchPartial(boundary.state, branchId); $chunk.writeHTML( $chunk.boundary.state.mark(ResumeSymbol.BranchStart, ""), ); @@ -1443,7 +1476,10 @@ export class State implements SerializeState { slotIds?: (string | 0 | undefined)[], ): void; declare rootScopeId?: number; - declare patchPartials?: Record>; + declare patchTrees?: Map< + SerializeState, + Record> + >; declare patchBinds?: number; declare patchParents?: Record< number, @@ -1458,7 +1494,6 @@ export class State implements SerializeState { slotIds?: (string | 0 | undefined)[], ] >; - declare patchSerializeStates?: Record; declare patchFlushed?: 1; declare patchInert?: 1; declare patchDeferred?: 1; diff --git a/packages/runtime-tags/src/translator/core/await.ts b/packages/runtime-tags/src/translator/core/await.ts index b377adf2972..1617558c88a 100644 --- a/packages/runtime-tags/src/translator/core/await.ts +++ b/packages/runtime-tags/src/translator/core/await.ts @@ -10,7 +10,10 @@ import { WalkCode } from "../../common/types"; import { assertNoSpreadAttrs } from "../util/assert"; import evaluate from "../util/evaluate"; import { isPersisted } from "../util/marko-config"; -import { boundaryAlwaysPairs } from "../util/persisted/structure"; +import { + boundaryAlwaysPairs, + inStatefulBranch, +} from "../util/persisted/structure"; import { type Binding, BindingType, @@ -203,7 +206,15 @@ export default { node.body.params, toFirstExpressionOrBlock(node.body.body), ), - getSerializeGuard(section, bodySection?.serializeReason, true), + // A persisted page always marks a patchable boundary: the + // frame pairs its body through the resumed branch link. + isPersisted() && !inStatefulBranch(section) + ? t.numericLiteral(1) + : getSerializeGuard( + section, + bodySection?.serializeReason, + true, + ), patchContent, // An always-pairing body's Pending entry drops its // construct id outside divergent contexts. diff --git a/packages/runtime-tags/src/translator/core/for.ts b/packages/runtime-tags/src/translator/core/for.ts index e503d3f2c03..c050d6714a6 100644 --- a/packages/runtime-tags/src/translator/core/for.ts +++ b/packages/runtime-tags/src/translator/core/for.ts @@ -446,9 +446,11 @@ export default { setClosureSignalBuilder( tag, { kind: "for", ref: nodeRef }, - (closure, render, initId) => { + (closure, render, initId, retain) => { const selectorKeyBinding = getForSelectorKey(bodySection, closure); const init = initId && t.stringLiteral(initId); + // The `_resume` aliases keep a `tagNameLoad` input's registration + // out of the pure-call list (nothing else references it). if (selectorKeyBinding) { const args = [ getScopeAccessorLiteral(nodeRef, true), @@ -457,12 +459,16 @@ export default { render, ]; return init - ? callRuntime("_init_for_selector", init, ...args) + ? callRuntime( + retain ? "_resume_init_for_selector" : "_init_for_selector", + init, + ...args, + ) : callRuntime("_for_selector", ...args); } return init ? callRuntime( - "_init_for_closure", + retain ? "_resume_init_for_closure" : "_init_for_closure", init, getScopeAccessorLiteral(nodeRef, true), render, diff --git a/packages/runtime-tags/src/translator/util/persisted/admission.ts b/packages/runtime-tags/src/translator/util/persisted/admission.ts index 5a5be3c8d55..9f8297ff0d9 100644 --- a/packages/runtime-tags/src/translator/util/persisted/admission.ts +++ b/packages/runtime-tags/src/translator/util/persisted/admission.ts @@ -6,19 +6,23 @@ import { types as t } from "@marko/compiler"; import { getProgram, getTagDef, + isAttributeTag, loadFileForTag, } from "@marko/compiler/babel-utils"; import { isEventHandler } from "../../../common/helpers"; import { getRelatedControllable, - isAttrsOnlySpread, + isAttrSetSpread, } from "../../visitors/tag/native-tag"; import * as BindingType from "../constants/binding-type"; import evaluate from "../evaluate"; +import { forEachIdentifier } from "../for-each-identifier"; +import { getTagName } from "../get-tag-name"; import { isConditionTag, isCoreTagName } from "../is-core-tag"; import { isEventOrChangeHandler } from "../is-event-or-change-handler"; import { getParamGroupFeeds, type ParamGroupFeeds } from "../known-tag"; +import { getAttrTagPaths } from "../nested-attribute-tags"; import { every, forEach, type Opt } from "../optional"; import { type Binding, getCanonicalExtra } from "../references"; import { getSection, getSectionForBody } from "../sections"; @@ -81,14 +85,11 @@ export function assertSupportedPatch(program: t.NodePath) { } forEach(extra?.referencedBindings, (binding) => { const sources = getSerializeSourcesForRef(binding); - if (sources?.global) { - unsupported( - node, - "`$global` cannot be read inside client-owned structure", - ); - } + // A `$global`-derived value delivers like any server value: its fill + // re-ships each frame, so only an unfillable read rejects. if ( - sources?.param && + sources && + (sources.param || sources.global) && !sources.state && !isPatchFillBinding(binding) && !inStatefulBranch(binding.section) @@ -153,7 +154,7 @@ export function assertSupportedPatch(program: t.NodePath) { if (!t.isStringLiteral(node.name)) { // Rendering an `input` property is the body-content channel: // what it renders is validated where it was compiled. - if (!isContentRenderTag(inner)) { + if (!isContentRenderTag(inner, file.path)) { reason = "renders a dynamic tag"; } return; @@ -177,25 +178,40 @@ export function assertSupportedPatch(program: t.NodePath) { : instanceValueUnsafety(attrPath.get("value") as t.NodePath); if (reason) return; } - if (getTagDef(inner)?.template) { - if (node.var) { - reason = "renders a nested child with a tag variable"; - } else if (node.attributeTags?.length || node.arguments?.length) { - reason = "renders a nested child with attribute tags or arguments"; - } else { - // An inputless child has no groups: anything fed must analyze. - const feeds = node.extra && getParamGroupFeeds(node.extra); - if (!feeds && node.attributes.length) { - reason = "renders a nested child without analyzable input"; + if (!isAttributeTag(inner) && getTagDef(inner)?.template) { + // The `_var_change` write-back is not wired for a pure client + // instance; an unassigned variable is just a local read. + if (node.var && varAssigned(node.var)) { + reason = "renders a nested child with an assigned tag variable"; + return; + } + if (node.arguments?.length) { + for (const argPath of inner.get("arguments") as t.NodePath[]) { + reason ||= t.isSpreadElement(argPath.node) + ? "renders a nested child with a spread argument" + : instanceValueUnsafety(argPath); } - for (const group of feeds || []) { - if (group.sources?.global) { - reason = "feeds a nested child a `$global`-derived input"; - break; - } + if (reason) return; + } + // An inputless child has no groups: anything fed must analyze + // (attr-tag attribute values validate as this traverse reaches them). + const feeds = node.extra && getParamGroupFeeds(node.extra); + if ( + !feeds && + (node.attributes.length || + node.arguments?.length || + node.attributeTags?.length || + node.body.attributeTags) + ) { + reason = "renders a nested child without analyzable input"; + } + for (const group of feeds || []) { + if (group.sources?.global) { + reason = "feeds a nested child a `$global`-derived input"; + break; } - reason ||= getInstanceUnsafety(inner); } + reason ||= getInstanceUnsafety(inner); } }, }); @@ -276,22 +292,93 @@ export function assertSupportedPatch(program: t.NodePath) { }; // Provenance-free feeds (imports, opaque reads) have no fill channel, so // only a tracked (param/state) or constant feed can gate structure. + // The child input root a group param feeds from: its program param + // index plus the property directly under it (none for a whole param). + const getGroupParamRoot = (param: Binding) => { + let prop: string | undefined; + for (let b: Binding | undefined = param; b; b = b.upstreamAlias) { + if (b.upstreamAlias === b.section.params) { + return b.property === undefined + ? undefined + : { index: b.property, prop }; + } + if (b.property !== undefined) prop = b.property; + } + }; const groupFedUnsafely = ( - attributes: (t.MarkoAttribute | t.MarkoSpreadAttribute)[], + tag: t.NodePath, group: ParamGroupFeeds, ) => { - let names: Set | undefined; + const { node } = tag; + const roots: { index: string; prop: string | undefined }[] = []; + let unresolved = false; forEach(group.params, (param) => { - (names ??= new Set()).add(param.property ?? param.name); + const root = getGroupParamRoot(param); + if (root) roots.push(root); + else unresolved = true; }); - return attributes.some( - (attr) => - attr.type === "MarkoAttribute" && - names?.has(attr.name) && - !evaluate(attr.value).confident && - !getSerializeSourcesForExpr(attr.value.extra || {}), + // A param whose feed cannot be located has no checkable channel. + if (unresolved) return true; + // Attr-tag and spread values merge their references into the group or + // tag extra: the canonical extra sees the tracked sources they carry. + const unsafeValue = (value: t.Expression) => + !evaluate(value).confident && + !getSerializeSourcesForExpr(getCanonicalExtra(value.extra || {})); + if ( + node.arguments?.some( + (arg, i) => + !t.isSpreadElement(arg) && + roots.some((root) => root.index === i + "") && + unsafeValue(arg), + ) + ) { + return true; + } + // Named attributes and attr tags feed the program param AFTER the + // positional arguments; a spread may carry any of its properties. + const attrsIndex = (node.arguments?.length || 0) + ""; + const attrRoots = roots.filter((root) => root.index === attrsIndex); + if (!attrRoots.length) return false; + const feedsRoot = (name: string) => + attrRoots.some((root) => root.prop === undefined || root.prop === name); + if ( + node.attributes.some((attr) => + attr.type === "MarkoAttribute" + ? feedsRoot(attr.name) && unsafeValue(attr.value) + : unsafeValue(attr.value), + ) + ) { + return true; + } + // An attr tag itself feeds like body content; only a provenance-free + // attribute VALUE anywhere inside one gates the group it feeds. + const attrTagFeedsUnsafely = (attrTag: t.NodePath): boolean => + attrTag.node.attributes.some((attr) => unsafeValue(attr.value)) || + getAttrTagPaths(attrTag).some( + (child) => + child.isMarkoTag() && + isAttributeTag(child) && + attrTagFeedsUnsafely(child), + ); + const lookup = node.extra?.attributeTags; + return ( + !!lookup && + getAttrTagPaths(tag).some((child) => { + if (!child.isMarkoTag() || !isAttributeTag(child)) return false; + const meta = lookup[getTagName(child)]; + return !!meta && feedsRoot(meta.name) && attrTagFeedsUnsafely(child); + }) ); }; + // Whether any binding the tag variable declares is assigned somewhere + // (destructured vars hang their bindings on the pattern's identifiers). + const varAssigned = (varNode: t.LVal) => { + let assigned = false; + forEachIdentifier(varNode, (id) => { + assigned ||= !!id.extra?.binding?.assignmentSections; + }); + return assigned; + }; program.traverse({ MarkoPlaceholder(placeholder) { const { node } = placeholder; @@ -330,14 +417,9 @@ export function assertSupportedPatch(program: t.NodePath) { forEach(ref as Opt, (binding) => { if (binding.section === localSection) return; const sources = getSerializeSourcesForRef(binding); - if (sources?.global) { - unsupported( - n, - `a \`$global\`-derived value inside \`<${attrName}>\` content would go stale`, - ); - } if ( - sources?.param && + sources && + (sources.param || sources.global) && !sources.state && !isPatchFillBinding(binding) && !inStatefulBranch(binding.section) @@ -382,10 +464,18 @@ export function assertSupportedPatch(program: t.NodePath) { if (stateful) { for (const attr of node.attributes) { if (attr.type !== "MarkoAttribute") continue; - // A local `by` invokes client-side per re-list; any server - // source anywhere in the keyer would read stale. + // A locally written keyer re-invokes client-side (reads stay + // current via fills); a server-provided keyer VALUE cannot ship. if (attr.name === "by") { - if (exprHasServerSources(attr.value)) { + if ( + t.isFunction(attr.value) + ? attr.value.extra?.globalBindings || + hasUnfillablePatchReads( + (attr.value.extra as t.FunctionExtra | undefined) + ?.referencedBindingsInFunction, + ) + : exprHasServerSources(attr.value) + ) { unsupported( attr, "a server-derived `by` key inside a client-owned loop would read stale", @@ -439,16 +529,12 @@ export function assertSupportedPatch(program: t.NodePath) { } return; } - // Fills and direct `$global` reads stay current over the wire; a - // global-DERIVED binding never re-ships, so its reads reject as stale. if (tagName === "script") { for (const attr of node.attributes) { if (attr.type === "MarkoAttribute" && attr.name === "value") { - if ( - getSerializeSourcesForRef(attr.value.extra?.referencedBindings) - ?.global || - hasUnfillablePatchReads(attr.value.extra?.referencedBindings) - ) { + // `$global`-derived reads deliver like any server value, so + // only an unfillable read rejects. + if (hasUnfillablePatchReads(attr.value.extra?.referencedBindings)) { unsupported(attr); } // A script's re-run entry rides the branch partial the frame no @@ -509,27 +595,45 @@ export function assertSupportedPatch(program: t.NodePath) { // Inside client-owned structure a child is a pure client instance // (input re-applies via tag-args signals; server values fill). if (inStatefulBranch(getSection(tag))) { - if (node.var) { - unsupported( - node, - "a tag variable on a child inside client-owned structure is not supported yet", - ); - } - // Body content compiles here, so its expressions are already - // checked in their own (client-owned) sections; attr tags are not. - if (node.attributeTags?.length) { + // The `_var_change` write-back is not wired for a pure client + // instance, so an assigned tag variable stays closed. + if (node.var && varAssigned(node.var)) { unsupported( node, - "attribute tags for a child inside client-owned structure are not supported yet", + "assigning a child's tag variable inside client-owned structure is not supported yet", ); } - // Arguments have no per-group channel: only named attrs deliver. - if (node.arguments?.length) { - unsupported( - node, - "arguments for a child inside client-owned structure are not supported yet", - ); + for (const arg of node.arguments || []) { + // A spread argument hides which params it feeds from the + // per-group analysis below. + if (t.isSpreadElement(arg)) { + unsupported( + arg, + "a spread argument for a child inside client-owned structure is not supported yet", + ); + } else { + assertDeliverableInClientOwned(arg, arg, arg.extra); + } } + // Attr-tag bodies compile in this file (this traverse visits + // them); only their attribute expressions need checking here. + const checkAttrTagAttrs = (owner: t.NodePath) => { + for (const child of getAttrTagPaths(owner)) { + if (child.isMarkoTag() && isAttributeTag(child)) { + for (const attr of child.node.attributes) { + assertDeliverableInClientOwned( + attr, + attr.value, + attr.type === "MarkoAttribute" + ? attr.value.extra + : node.extra, + ); + } + checkAttrTagAttrs(child); + } + } + }; + checkAttrTagAttrs(tag); // Transitive safety composes per-template facts with a memo: // every template below must be a self-contained client instance. const unsafety = getInstanceUnsafety(tag); @@ -553,21 +657,22 @@ export function assertSupportedPatch(program: t.NodePath) { // An inputless child has no groups to classify; anything fed // must analyze so each group's channel can be checked. const feeds = node.extra && getParamGroupFeeds(node.extra); - if (!feeds && (node.attributes.length || node.arguments?.length)) { + if ( + !feeds && + (node.attributes.length || + node.arguments?.length || + node.attributeTags?.length || + node.body.attributeTags) + ) { unsupported( node, "a child inside client-owned structure must have analyzable input", ); } for (const group of feeds || []) { - // Fills keep tracked params current and the instance - // re-selects client-side; a provenance-free structural feed - // has no channel, and `$global` never re-ships. - if ( - (group.structuralOrGlobal && - groupFedUnsafely(node.attributes, group)) || - group.sources?.global - ) { + // Fills keep tracked params current and the instance re-selects + // client-side; a provenance-free structural feed has no channel. + if (group.structuralOrGlobal && groupFedUnsafely(tag, group)) { unsupported( node, "an input the child needs server-owned cannot feed from client-owned structure", @@ -687,12 +792,8 @@ export function assertSupportedPatch(program: t.NodePath) { if (attr.type === "MarkoAttribute") seen[attr.name] = attr; } const related = getRelatedControllable(tagName as string, seen); - if (related) { - if (related.helper === "_attr_input_checkedValue") { - unsupported(node, "`checkedValue` groups are not patchable"); - } else if ("valueMode" in related && related.valueMode) { - unsupported(node, "a dynamic `type=` can change the control kind"); - } + if (related && "valueMode" in related && related.valueMode) { + unsupported(node, "a dynamic `type=` can change the control kind"); } const controlled = new Set( related ? (related.attrs.filter(Boolean) as t.Node[]) : [], @@ -710,10 +811,13 @@ export function assertSupportedPatch(program: t.NodePath) { (attr.value.extra as t.FunctionExtra | undefined) ?.referencedBindingsInFunction, (binding) => { - // Direct reads (BindingType.global) see the live bag. + // Direct reads (BindingType.global) see the live bag; a + // derived value stays current through its fill/wire write. if ( binding.type !== BindingType.global && - getSerializeSourcesForRef(binding)?.global + getSerializeSourcesForRef(binding)?.global && + !isPatchFillBinding(binding) && + !isPatchWriteBinding(binding) ) { unsupported( attr, @@ -755,7 +859,7 @@ export function assertSupportedPatch(program: t.NodePath) { attr.type === "MarkoSpreadAttribute" ? // A controllable or content-carrying spread cannot patch. !evaluate(attr.value).confident && - !isAttrsOnlySpread(tag, tagName as string) + !isAttrSetSpread(tag, tagName as string) : !evaluate(attr.value).confident && ((isEventOrChangeHandler(attr.name) && !isEventHandler(attr.name)) || diff --git a/packages/runtime-tags/src/translator/util/persisted/decisions.ts b/packages/runtime-tags/src/translator/util/persisted/decisions.ts index 63dff5b6e6b..fe3aacabf88 100644 --- a/packages/runtime-tags/src/translator/util/persisted/decisions.ts +++ b/packages/runtime-tags/src/translator/util/persisted/decisions.ts @@ -2,7 +2,11 @@ // facts (nothing is stored on the AST); they outlive the admission guard's // removal. import { types as t } from "@marko/compiler"; -import { isAttributeTag, loadFileForTag } from "@marko/compiler/babel-utils"; +import { + getProgram, + isAttributeTag, + loadFileForTag, +} from "@marko/compiler/babel-utils"; import evaluate from "../evaluate"; import isStatic from "../is-static"; @@ -42,7 +46,12 @@ export function hasInertCall(value: t.Node) { // A dynamic tag rendering `input` content (a body or attribute tag) and // nothing else: its name reads one property of the template's input, through // any alias; resolved references are required, so call at finalize or later. -export function isContentRenderTag(tag: t.NodePath) { +export function isContentRenderTag( + tag: t.NodePath, + // The admission guard walks a loaded child file's AST while `getProgram()` + // still points at the compiling parent; it passes the child program. + program: t.NodePath = getProgram(), +) { const { node } = tag; if ( t.isStringLiteral(node.name) || @@ -60,7 +69,7 @@ export function isContentRenderTag(tag: t.NodePath) { !Array.isArray(binding) && binding.property !== undefined && !!binding.upstreamAlias && - getCanonicalBinding(binding.upstreamAlias) === getInputBinding(tag) + getCanonicalBinding(binding.upstreamAlias) === getInputBinding(program) ); } // A dynamic tag whose renderer and every input the server owns (any client @@ -100,11 +109,9 @@ export function hasStateFeed(extra: t.NodeExtra | undefined) { ); } -// The template's `input` param binding (the first program param). -function getInputBinding(tag: t.NodePath) { - return ( - tag.hub.file as { ast: { program: t.Program } } - ).ast.program.extra?.binding?.propertyAliases.get("0"); +// The `input` param binding of the given template program. +function getInputBinding(program: t.NodePath) { + return program.node.extra?.binding?.propertyAliases.get("0"); } export interface ChildPatchPlan { diff --git a/packages/runtime-tags/src/translator/util/persisted/delivery.ts b/packages/runtime-tags/src/translator/util/persisted/delivery.ts index e7d72fcb3c7..a6bf1e7bd34 100644 --- a/packages/runtime-tags/src/translator/util/persisted/delivery.ts +++ b/packages/runtime-tags/src/translator/util/persisted/delivery.ts @@ -64,19 +64,21 @@ function hasWritableShape(binding: Binding) { ); } -// The shape a patch can keep current: a canonical root server value (only -// canonical bindings get ordinals and server writes — an alias never -// qualifies, so its reads reject rather than going silently stale). +// The shape a patch can keep current: a canonical root server value (an +// alias never gets ordinals or writes, so its reads reject, never go stale). function isPatchRefreshableBinding(binding: Binding) { return ( isPersisted() && getCanonicalBinding(binding) === binding && !binding.section.parent && - !!binding.sources?.param && + !!binding.sources && + !!(binding.sources.param || binding.sources.global) && !binding.sources.state && (binding.type === BindingType.input || binding.type === BindingType.param || binding.type === BindingType.derived || + // A keyed `$global` read; the bag itself never re-ships. + (binding.type === BindingType.global && !!binding.upstreamAlias) || (binding.type === BindingType.let && !binding.assignmentSections)) ); } @@ -163,20 +165,32 @@ export function isPatchWriteBinding(binding: Binding) { export function hasPatchEffectReads(binding: Binding) { for (const read of binding.reads) { // A serialized spread's set is its own delivery. - if (read.isEffect && !read.serializedSpread) return true; + if (read.isEffect && !read.attrSetSpread) return true; } return false; } // Closures whose construct INITs render a fresh scope: state closures -// through their own signal, fill closures as arrivals at the joins they feed. +// through their own signal, fill closures as arrivals at the joins they feed, +// and lazy-child input feeds (the stash must exist before the module loads). export function getConstructInitClosures(section: Section) { return filter( section.referencedClosures as Opt, - (closure) => !!closure.sources?.state || fillJoinsIn(closure, section), + (closure) => + !!closure.sources?.state || + fillJoinsIn(closure, section) || + feedsTagNameLoadIn(closure, section), ); } +// A closure read in `section` that is a `tagNameLoad` tag's input. +export function feedsTagNameLoadIn(closure: Binding, section: Section) { + for (const read of closure.reads) { + if (read.section === section && read.tagNameLoadInput) return true; + } + return false; +} + // A fill closure feeding a state intersection read in `section` (which // then rides a `_fill_join_*` wrapper registering the closure's init). function fillJoinsIn(closure: Binding, section: Section) { @@ -210,11 +224,11 @@ export function getLocalFillFeeds(section: Section) { } // A local the server computes without client state: a param property -// (or rest, a declared object), or a derivation/never-assigned let. +// (or rest, a declared object), or a derivation/never-assigned let. A +// `$global` contribution is fine — the shipped value is per-frame current. function isSeedableLocal(binding: Binding) { return ( !binding.sources?.state && - !binding.sources?.global && (isSectionParam(binding) || binding.type === BindingType.derived || (binding.type === BindingType.let && !binding.assignmentSections)) @@ -233,11 +247,12 @@ function isSectionParam(binding: Binding) { // Server-sourced reads a patch cannot keep current: param-sourced bindings // that neither fill nor refresh over the wire read stale after any patch. export function hasUnfillablePatchReads(refs: Opt) { - return some( - refs, - (binding) => - !!getSerializeSourcesForRef(binding)?.param && + return some(refs, (binding) => { + const sources = getSerializeSourcesForRef(binding); + return ( + !!(sources?.param || sources?.global) && !isPatchFillBinding(binding) && - !isPatchWriteBinding(binding), - ); + !isPatchWriteBinding(binding) + ); + }); } diff --git a/packages/runtime-tags/src/translator/util/persisted/structure.ts b/packages/runtime-tags/src/translator/util/persisted/structure.ts index f1e5aacfd4e..c70e2028b63 100644 --- a/packages/runtime-tags/src/translator/util/persisted/structure.ts +++ b/packages/runtime-tags/src/translator/util/persisted/structure.ts @@ -20,6 +20,9 @@ export function boundaryAlwaysPairs(bodySection: Section) { if (!bodySection.serializeReason) return false; for (let s: Section | undefined = bodySection; s; s = s.parent) { if (s.isBranch || s.boundaryContent) return false; + // A content section can materialize at any site (or none), so nothing + // below it is provably live and unique on every page. + if (s !== bodySection && !s.isBoundary && s.parent) return false; } return true; } diff --git a/packages/runtime-tags/src/translator/util/references.ts b/packages/runtime-tags/src/translator/util/references.ts index c44878cfbdc..6ba7c8daf6d 100644 --- a/packages/runtime-tags/src/translator/util/references.ts +++ b/packages/runtime-tags/src/translator/util/references.ts @@ -213,10 +213,13 @@ declare module "@marko/compiler/dist/types" { * (dynamic/aliased) read, a property alias names the key. */ globalBindings?: ReferencedBindings; spreadFrom?: Binding; + /** An input expression of a `tagNameLoad` tag (its value stashes until + * the child's module arrives). */ + tagNameLoadInput?: true; nativeTagSpread?: true; - /** A native tag spread whose attribute set is serialized with the - * persisted structure, so its effect read needs no other delivery. */ - serializedSpread?: true; + /** A native tag spread that is the element's whole attribute set (no + * content renderer it could carry). */ + attrSetSpread?: true; nativeTagSpreadMerged?: true; merged?: NodeExtra; } @@ -1132,10 +1135,9 @@ export function finalizeReferences() { for (const binding of bindings) { const { name, section } = binding; - // `$global` bindings resolve sources only: no collision rename (it - // would burn a UID and shift later generated names), no section - // membership, no closures — reads compile verbatim. - if (binding.type === BindingType.global) { + // Verbatim globals resolve sources only: no collision rename (it would + // burn a UID and shift later generated names), no section, no closures. + if (isVerbatimGlobal(binding)) { resolveBindingSources(binding); // LOCAL-only bit (no cross-file roll-up): the html output exports it // as the template's intrinsics, composed across templates at render. @@ -1669,6 +1671,15 @@ const [getResolvedSources] = createProgramState(() => new Set()); const [getBindingValueExprs] = createProgramState( () => new Map>(), ); +// A `$global` read compiles verbatim (no read slot, signal, or register +// id) unless persisted keys it: a keyed read delivers like any reference. +function isVerbatimGlobal(binding: Binding) { + return ( + binding.type === BindingType.global && + !(isPersisted() && binding.upstreamAlias) + ); +} + function resolveBindingSources(binding: Binding) { const resolvedSources = getResolvedSources(); if (resolvedSources.has(binding)) return; @@ -2625,16 +2636,14 @@ function resolveReferencedBindings( if (upstreamRoot) { binding = upstreamRoot; } - } else if (binding.type !== BindingType.global) { + } else if (!isVerbatimGlobal(binding)) { extra.section = expr.section; ({ binding } = extra.read ??= resolveExpressionReference( rootBindings, binding, )); } - if (binding.type === BindingType.global) { - // `$global` reads stay verbatim member chains: no read slot, - // no signal, no register-id participation. + if (isVerbatimGlobal(binding)) { globalBindings = bindingUtil.add(globalBindings, binding); } else if (isLazyRead(expr, read, binding, isChangeHandlerRead)) { lazyBindings = bindingUtil.add(lazyBindings, binding); @@ -2656,9 +2665,7 @@ function resolveReferencedBindings( binding.hoists = sectionUtil.add(binding.hoists, getter.hoisted); hoistedBindings = bindingUtil.add(hoistedBindings, binding); } - } else if (binding.type === BindingType.global) { - // `$global` reads stay verbatim member chains: no read slot, - // no signal, no register-id participation. + } else if (isVerbatimGlobal(binding)) { globalBindings = binding; } else { extra.read = createRead(binding, undefined, ownVar); diff --git a/packages/runtime-tags/src/translator/util/runtime.ts b/packages/runtime-tags/src/translator/util/runtime.ts index 751ccea1df6..bbb042bc294 100644 --- a/packages/runtime-tags/src/translator/util/runtime.ts +++ b/packages/runtime-tags/src/translator/util/runtime.ts @@ -130,6 +130,7 @@ export type DOMRuntimeFeature = | "patch-child" | "patch-content" | "patch-control" + | "patch-control-checked-value" | "patch-control-input" | "patch-control-open" | "patch-control-select" diff --git a/packages/runtime-tags/src/translator/util/sections.ts b/packages/runtime-tags/src/translator/util/sections.ts index fec2aff9ae8..c5396799b5e 100644 --- a/packages/runtime-tags/src/translator/util/sections.ts +++ b/packages/runtime-tags/src/translator/util/sections.ts @@ -171,6 +171,8 @@ export interface Section { /** Awaits a construct must deliver body content for (marker binding + * body section); `buildShells` prunes those no shipped shell reaches. */ constructSetups: { binding: Binding; body: Section }[] | undefined; + /** Lazily loaded child sites in this section, by their marker binding. */ + loadSites: Binding[] | undefined; /** Branch whose shell would construct unfaithfully: the first blocker's * reason code sticks, no shell ships, patches fail closed. */ shellBlocked: ShellBlocker.Value | undefined; @@ -262,6 +264,7 @@ export function startSection( boundaryContent: false, contentRecord: false, constructSetups: undefined, + loadSites: undefined, shellBlocked: undefined, structure: parentSection && !parentSection.structure ? null : [], }; diff --git a/packages/runtime-tags/src/translator/util/shell.ts b/packages/runtime-tags/src/translator/util/shell.ts index 4a2bb1ba3d0..7184d95214c 100644 --- a/packages/runtime-tags/src/translator/util/shell.ts +++ b/packages/runtime-tags/src/translator/util/shell.ts @@ -172,11 +172,14 @@ function isShellExpressible(section: Section) { op.kind !== StructureKind.Text && // A known child composes when its root is expressible (nested // branches/boundaries pair via their own entries) and has no tag var. + // A renderer-less child is a lazy site: only its marker expresses + // (the loaded module renders the markup client-side). !( op.kind === StructureKind.Child && !op.hasVar && - op.renderer?.kind === StructureKind.ExportRef && - isShellExpressible(op.renderer.program.section!) + (!op.renderer || + (op.renderer.kind === StructureKind.ExportRef && + isShellExpressible(op.renderer.program.section!))) ) ) { return false; diff --git a/packages/runtime-tags/src/translator/util/signals.ts b/packages/runtime-tags/src/translator/util/signals.ts index 073baa56b7e..a89cb0d3169 100644 --- a/packages/runtime-tags/src/translator/util/signals.ts +++ b/packages/runtime-tags/src/translator/util/signals.ts @@ -25,6 +25,7 @@ import { toArray, } from "./optional"; import { + feedsTagNameLoadIn, getLocalFillFeeds, getPatchFillBindings, getPatchFillKey, @@ -136,6 +137,7 @@ type closureSignalBuilder = ( closure: Binding, render: t.Expression, initId?: string, + retain?: boolean, ) => t.Expression; // Structured facts about a branch section's closure hop: what kind of // branch it is and which accessor (plus branch index) addresses it. @@ -152,8 +154,8 @@ const [getClosureSignal, _setClosureSignal] = createSectionState< export function setClosureSignalBuilder( tag: t.NodePath, hop: ClosureHop, - build: closureSignalBuilder = (_closure, render, initId) => - buildClosureHop(hop, render, initId), + build: closureSignalBuilder = (_closure, render, initId, retain) => + buildClosureHop(hop, render, initId, retain), ) { _setClosureSignal(getSectionForBody(tag.get("body"))!, { hop, build }); } @@ -162,13 +164,16 @@ function buildClosureHop( hop: ClosureHop, render: t.Expression, initId?: string, + retain?: boolean, ) { const accessor = getScopeAccessorLiteral(hop.ref, true); const init = initId && t.stringLiteral(initId); return hop.kind === "if" ? init ? callRuntime( - "_init_if_closure", + // The `_resume` alias keeps a `tagNameLoad` input's registration + // out of the pure-call list (nothing else references it). + retain ? "_resume_init_if_closure" : "_init_if_closure", init, accessor, t.numericLiteral(hop.index), @@ -181,7 +186,12 @@ function buildClosureHop( render, ) : init - ? callRuntime("_init_for_closure", init, accessor, render) + ? callRuntime( + retain ? "_resume_init_for_closure" : "_init_for_closure", + init, + accessor, + render, + ) : callRuntime("_for_closure", accessor, render); } @@ -441,13 +451,20 @@ export function getSignal( const initId = constructsWithInit(section, closure) ? getResumeRegisterId(section, closure, "init") : undefined; + const retain = !!initId && feedsTagNameLoadIn(closure, section); if (closureSignal && !isDynamicClosure(section, closure)) { - return closureSignal.build(closure, render, initId); + return closureSignal.build(closure, render, initId, retain); } return callRuntime( - initId ? "_init_closure_get" : "_closure_get", + initId + ? // The `_resume` alias keeps a `tagNameLoad` input's registration + // out of the pure-call list (nothing else references it). + retain + ? "_resume_init_closure_get" + : "_init_closure_get" + : "_closure_get", ...(initId ? [t.stringLiteral(initId)] : []), // Optimized builds pass the reserved closure accessor id. isOptimize() @@ -473,6 +490,15 @@ export function getSignal( return signal; } +// A dynamic content record elides the chain's dom renderers, and with them +// the `_closure_get` pending registration the replay script would look up. +function inRecordDeliveredChain(section: Section) { + for (let cur: Section | undefined = section; cur; cur = cur.parent) { + if (cur.contentRecord === true) return true; + } + return false; +} + function underTryPlaceholder(section: Section) { let curSection = section.parent; while (curSection) { @@ -1129,10 +1155,7 @@ export function writeSignals(section: Section) { // A chain that leaves the branch ladder delivers through the // member's own closure signal (`_fill_join_closure`) instead. if (!isBranchSectionChain(signal.section, member.section)) { - if ( - inStatefulBranch(signal.section) || - inBoundaryContent(signal.section) - ) { + if (inStatefulBranch(signal.section)) { continue; } const closureSignal = getSignal(signal.section, member); @@ -1217,7 +1240,10 @@ export function writeSignals(section: Section) { inBoundaryContent(signal.section)) && isPatchFillBinding(signal.referencedBindings) && signal.section !== signal.referencedBindings.section && - isBranchChainTo(signal.section, signal.referencedBindings.section) && + // A dynamic closure dispatches through its owner-anchored + // subscriber set, so its chain shape does not matter. + (isBranchChainTo(signal.section, signal.referencedBindings.section) || + isDynamicClosure(signal.section, signal.referencedBindings)) && hasFillDeliveredRead(signal.referencedBindings, signal.section) ) { // Inside client-owned structure a lone closure over a server @@ -1533,12 +1559,14 @@ export function sectionHasGlobalEffect(section: Section) { function constructsWithInit(section: Section, closure: Binding) { return ( sectionConstructs(section) && - (!!closure.sources?.state || includes(getLocalFillFeeds(section), closure)) + (!!closure.sources?.state || + includes(getLocalFillFeeds(section), closure) || + feedsTagNameLoadIn(closure, section)) ); } // A branch body that ships a shell, so a patch may construct it. -function sectionConstructs(section: Section) { +export function sectionConstructs(section: Section) { return ( isPersisted() && section.isBranch && @@ -1591,23 +1619,20 @@ function isSerializedSpreadEffect(signal: Signal) { !!refs && some(refs, (binding) => { for (const read of binding.reads) { - if (read.referencedBindings === refs && read.serializedSpread) - return true; + if (read.referencedBindings === refs && read.attrSetSpread) return true; } return false; }) ); } -// An effect read the wire cannot keep current (unfillable params, global- -// derived bindings) blocks constructs; direct `$global` reads re-queue. +// An effect read the wire cannot keep current blocks constructs; fill and +// wire-write deliveries (param- and `$global`-derived alike) stay current, +// and direct `$global` reads re-queue against the live bag. export function sectionHasServerEffect(section: Section) { for (const signal of getSignals(section).values()) { if (signal.hasHTMLEffect && !isSerializedSpreadEffect(signal)) { - if ( - getSerializeSourcesForRef(signal.referencedBindings)?.global || - hasUnfillablePatchReads(signal.referencedBindings) - ) { + if (hasUnfillablePatchReads(signal.referencedBindings)) { return true; } } @@ -1685,10 +1710,12 @@ export function writeHTMLResumeStatements( } if (underTryPlaceholder(section)) { - // A scriptless page never registers the pending replay (constructs - // get content via patch entries), so the envelope must not need it. + // A scriptless page or a record-delivered chain never registers + // the pending replay, so the envelope must not reference it. const reason = - isPersisted() && !getProgram().node.extra.isInteractive + isPersisted() && + (!getProgram().node.extra.isInteractive || + inRecordDeliveredChain(section)) ? undefined : getSerializeReason(section); if (reason) { diff --git a/packages/runtime-tags/src/translator/visitors/import-declaration.ts b/packages/runtime-tags/src/translator/visitors/import-declaration.ts index 0966edcc093..2bdf73ad49b 100644 --- a/packages/runtime-tags/src/translator/visitors/import-declaration.ts +++ b/packages/runtime-tags/src/translator/visitors/import-declaration.ts @@ -254,7 +254,10 @@ function getOrCreateHtmlLoadWrapped( "withLoadAssets", originalIdentifier, t.stringLiteral(readyId), - triggers ? t.valueToNode(triggers) : undefined, + triggers && t.valueToNode(triggers), + // A persisted page may hold a deferred patch on this channel, + // so its loader scripts report load errors. + isPersisted() && t.numericLiteral(1), ), ), ]), diff --git a/packages/runtime-tags/src/translator/visitors/program/html.ts b/packages/runtime-tags/src/translator/visitors/program/html.ts index 8154781dd41..974bbc38275 100644 --- a/packages/runtime-tags/src/translator/visitors/program/html.ts +++ b/packages/runtime-tags/src/translator/visitors/program/html.ts @@ -252,6 +252,11 @@ export default { marker += (marker && " ") + getResumeRegisterId(section, closure, "init"); }); + // Lazy sites wire their load (and channel) as construct inits. + for (const site of section.loadSites || []) { + marker += + (marker && " ") + getResumeRegisterId(section, site, "init"); + } // An effect the construct's own renders queue (an init, seed, // or item write cascades into it) is not replayed. const effectIds = getSectionEffectRegisterIds( diff --git a/packages/runtime-tags/src/translator/visitors/program/index.ts b/packages/runtime-tags/src/translator/visitors/program/index.ts index 30c96804a8d..431ad585e06 100644 --- a/packages/runtime-tags/src/translator/visitors/program/index.ts +++ b/packages/runtime-tags/src/translator/visitors/program/index.ts @@ -172,11 +172,9 @@ export default { const entryFile = getFile(); const { filename } = entryFile.opts; const readyId = getReadyId(entryFile)!; - // A rejected chunk blocks this ready id forever: the debug build - // reports it instead of leaving the content silently inert, while - // production keeps the arm's bytes out (the failure still surfaces - // as a network error in devtools). - const report = !markoOpts.optimize; + // A rejected chunk blocks this ready id forever: debug reports it; + // persisted also reports in production so deferred patches settle. + const report = !markoOpts.optimize || isPersisted(); program.node.body = [ t.importDeclaration( [ diff --git a/packages/runtime-tags/src/translator/visitors/referenced-identifier.ts b/packages/runtime-tags/src/translator/visitors/referenced-identifier.ts index 3f91744a851..011e300c345 100644 --- a/packages/runtime-tags/src/translator/visitors/referenced-identifier.ts +++ b/packages/runtime-tags/src/translator/visitors/referenced-identifier.ts @@ -78,6 +78,18 @@ export default { case "$global": { // An HTML read resolves to the `$global` const the program declares. if (isOutputHTML()) break; + // Only a persisted keyed read (`$global.key`) becomes a tracked + // binding — it needs an identity a fill can deliver through — so the + // standard read replacement rewrites the whole member expression. + // Every other shape (dynamic/aliased reads, whole-bag reads, and all + // non-persisted builds) has no binding and stays a bag access here. + if ( + (t.isMemberExpression(identifier.parent) || + t.isOptionalMemberExpression(identifier.parent)) && + identifier.parent.extra?.read + ) { + break; + } const globalRead = t.memberExpression( scopeIdentifier, diff --git a/packages/runtime-tags/src/translator/visitors/tag/custom-tag.ts b/packages/runtime-tags/src/translator/visitors/tag/custom-tag.ts index bb38be6261e..f45536cb0fc 100644 --- a/packages/runtime-tags/src/translator/visitors/tag/custom-tag.ts +++ b/packages/runtime-tags/src/translator/visitors/tag/custom-tag.ts @@ -29,7 +29,12 @@ import { knownTagTranslateDOM, knownTagTranslateHTML, } from "../../util/known-tag"; -import { getMarkoOpts, isOutputHTML } from "../../util/marko-config"; +import { + getMarkoOpts, + getReadyId, + isOutputHTML, + isPersisted, +} from "../../util/marko-config"; import type { Binding } from "../../util/references"; import { BindingType, @@ -40,7 +45,12 @@ import { callRuntime, importRuntimeFeature } from "../../util/runtime"; import { createScopeReadExpression } from "../../util/scope-read"; import { getOrCreateSection, StructureKind } from "../../util/sections"; import { addSetupStatement } from "../../util/setup-statements"; -import { addStatement, getSignal } from "../../util/signals"; +import { + addStatement, + getResumeRegisterId, + getSignal, + sectionConstructs, +} from "../../util/signals"; import { createProgramState } from "../../util/state"; import * as structure from "../../util/structure"; import type { TemplateVisitor } from "../../util/visitors"; @@ -92,11 +102,19 @@ export default { } if (tagExtra.tagNameLoad) { + const section = getOrCreateSection(tag); tagExtra[kLoadTagBinding] = createBinding( "#text", BindingType.dom, - getOrCreateSection(tag), + section, ); + (section.loadSites ??= []).push(tagExtra[kLoadTagBinding]!); + tagExtra.tagNameLoadInput = true; + // Reference tracking fills these same extras later, so the fact is + // recorded ahead of it on each attr value. + for (const attr of tag.node.attributes) { + (attr.value.extra ??= {}).tagNameLoadInput = true; + } } if (tagExtra.tagNameLoad || !childExtra.domExports?.setupEmpty) { @@ -252,22 +270,42 @@ function translateDOM(tag: t.NodePath) { ]), ); importRuntimeFeature("catch"); + const loadSetupCall = callRuntime( + "_load_setup", + getScopeAccessorLiteral(node.extra![kLoadTagBinding]!, true), + getScopeAccessorLiteral(childBinding, true), + triggerIdent + ? t.addComment( + t.callExpression(triggerIdent, [setupLoadExpr]), + "leading", + "@__PURE__", + ) + : setupLoadExpr, + // A construct's client-side load drives the child's ready + // channel, so its deferred frame data drains after insert. + isPersisted() && + getReadyId(childFile) !== undefined && + t.stringLiteral(getReadyId(childFile)!), + ); getProgram().node.body.push( t.variableDeclaration("let", [ t.variableDeclarator( setupIdent, - callRuntime( - "_load_setup", - getScopeAccessorLiteral(node.extra![kLoadTagBinding]!, true), - getScopeAccessorLiteral(childBinding, true), - triggerIdent - ? t.addComment( - t.callExpression(triggerIdent, [setupLoadExpr]), - "leading", - "@__PURE__", - ) - : setupLoadExpr, - ), + // A constructing branch runs the site's load wiring as a shell + // init; `_resume` (impure) survives tree-shaking to deliver it. + isPersisted() && sectionConstructs(section) + ? callRuntime( + "_resume", + t.stringLiteral( + getResumeRegisterId( + section, + node.extra![kLoadTagBinding]!, + "init", + ), + ), + loadSetupCall, + ) + : loadSetupCall, ), ]), ); diff --git a/packages/runtime-tags/src/translator/visitors/tag/native-tag.ts b/packages/runtime-tags/src/translator/visitors/tag/native-tag.ts index 3fc30f1342c..c8e706d2ed0 100644 --- a/packages/runtime-tags/src/translator/visitors/tag/native-tag.ts +++ b/packages/runtime-tags/src/translator/visitors/tag/native-tag.ts @@ -56,6 +56,7 @@ import { getPrefixedScopeAccessor, getScopeAccessorLiteral, mergeReferences, + mergeSources, trackDomVarReferences, } from "../../util/references"; import { @@ -363,10 +364,13 @@ export default { ensurePersistedWriteGroups(() => value.extra || {}); } } - if (spreadReferenceNodes && isAttrsOnlySpread(tag, tagName)) { + if (spreadReferenceNodes && isAttrSetSpread(tag, tagName)) { addRuntimeFeatureAsset("patch-attrs"); + if (controllableClaimFor(tagName)) { + addRuntimeFeatureAsset("controllable"); + } ensurePersistedWriteGroups(() => node.extra || {}); - (node.extra ??= {}).serializedSpread = true; + (node.extra ??= {}).attrSetSpread = true; } } @@ -648,11 +652,10 @@ export default { } // A patched control wires like a fill: the handler installs first - // (binds queue ahead of the control's apply), then the value entry - // makes the server's value authoritative through the registered - // controlled helper — paired refresh and construct alike. + // (binds queue ahead), then the value entry applies authoritatively. if (isPersisted() && isBranchPathSection(tagSection)) { - const [valueAttr, changeAttr] = staticControllable.attrs; + const [valueAttr, changeAttr, groupValueAttr] = + staticControllable.attrs; if (changeAttr) { // A param-fed handler binds only under server ownership, so // a client-owned control never rebinds a stale handler. @@ -672,17 +675,38 @@ export default { )}`; } // A param-fed control value writes only under server ownership. + // A group entry (`checkedValue`) also carries the input's own + // `value`: each node applies its own comparison client-side. + const groupEntry = + staticControllable.helper === "_attr_input_checkedValue"; write`${callRuntime( "_patch_control", getScopeIdIdentifier(tagSection), t.cloneNode(visitAccessor!, true), t.numericLiteral(getControlledType(staticControllable)), - valueAttr ? t.cloneNode(valueAttr.value, true) : buildUndefined(), - ...(valueAttr - ? getPatchWriteOwnership( - getSerializeSourcesForExpr(valueAttr.value.extra || {}), - ) - : []), + groupEntry + ? t.arrayExpression([ + valueAttr + ? t.cloneNode(valueAttr.value, true) + : buildUndefined(), + groupValueAttr + ? t.cloneNode(groupValueAttr.value, true) + : buildUndefined(), + ]) + : valueAttr && t.cloneNode(valueAttr.value, true), + ...getPatchWriteOwnership( + groupEntry + ? mergeSources( + valueAttr && + getSerializeSourcesForExpr(valueAttr.value.extra || {}), + groupValueAttr && + getSerializeSourcesForExpr( + groupValueAttr.value.extra || {}, + ), + ) + : valueAttr && + getSerializeSourcesForExpr(valueAttr.value.extra || {}), + ), )}`; } } @@ -879,7 +903,7 @@ export default { if (isTextOnly || isOpenOnly || hasChildren || staticContentAttr) { const patches = - isAttrsOnlySpread(tag, tagName) && + isAttrSetSpread(tag, tagName) && writesPatchAttr(tag, tagSection, "spread", tag.node.extra); if (skipExpression) { write`${callRuntime( @@ -890,9 +914,14 @@ export default { getScopeIdIdentifier(tagSection), t.stringLiteral(tagName), ...(patches - ? getPatchWriteOwnership( - getSerializeSourcesForExpr(tag.node.extra || {}), - ) + ? [ + !staticControllable && + controllableClaimFor(tagName) && + t.numericLiteral(1), + ...getPatchWriteOwnership( + getSerializeSourcesForExpr(tag.node.extra || {}), + ), + ] : []), )}`; } else if (patches) { @@ -904,6 +933,9 @@ export default { visitAccessor, getScopeIdIdentifier(tagSection), t.stringLiteral(tagName), + !staticControllable && + controllableClaimFor(tagName) && + t.numericLiteral(1), ...getPatchWriteOwnership( getSerializeSourcesForExpr(tag.node.extra || {}), ), @@ -1321,9 +1353,14 @@ export default { if ( isPersisted() && isBranchPathSection(tagSection) && - isAttrsOnlySpread(tag, staticName) + isAttrSetSpread(tag, staticName) ) { importRuntimeFeature("patch-attrs"); + // A spread that owns the element's controllable (no static attr + // does) re-claims it through the run-time claim table. + if (!staticControllable && controllableClaimFor(staticName)) { + importRuntimeFeature("controllable"); + } } if (skipExpression) { addStatement( @@ -1463,15 +1500,15 @@ function writesPatchAttr( return false; } -// A spread whose set is plain attributes: no controllable descriptor and no -// `content` renderer (the tag has its own body or admits none). -export function isAttrsOnlySpread( +// A spread that is the element's whole attribute set: no `content` renderer +// can ride it (the tag has its own body or admits none). Patches re-apply +// such a set as-is, controllable claims included. +export function isAttrSetSpread( tag: t.NodePath, tagName: string | undefined, ) { return ( !!tagName && - !controllableClaimFor(tagName) && tagName !== "option" && !!( isTextOnlyNativeTag(tag) || @@ -1581,7 +1618,9 @@ function getPatchControlFeature( ? ("patch-control-select" as const) : controllable.helper.endsWith("_open") ? ("patch-control-open" as const) - : ("patch-control-input" as const); + : controllable.helper === "_attr_input_checkedValue" + ? ("patch-control-checked-value" as const) + : ("patch-control-input" as const); } // The wire's control kind ids mirror `ControlledType`. @@ -1589,6 +1628,8 @@ function getControlledType(controllable: NonNullable) { switch (controllable.helper) { case "_attr_input_checked": return ControlledType.InputChecked; + case "_attr_input_checkedValue": + return ControlledType.InputCheckedValue; case "_attr_select_value": return ControlledType.SelectValue; case "_attr_input_value":