diff --git a/.changeset/many-lies-dream.md b/.changeset/many-lies-dream.md new file mode 100644 index 000000000..9ab579a2b --- /dev/null +++ b/.changeset/many-lies-dream.md @@ -0,0 +1,5 @@ +--- +"@marko/runtime-tags": patch +--- + +Unify inline placeholder and await placeholders diff --git a/.sizes.json b/.sizes.json index 029360580..9bf4da9b0 100644 --- a/.sizes.json +++ b/.sizes.json @@ -7,8 +7,8 @@ { "name": "*", "total": { - "min": 19659, - "brotli": 7540 + "min": 20005, + "brotli": 7670 } }, { @@ -19,11 +19,11 @@ }, "runtime": { "min": 4043, - "brotli": 1822 + "brotli": 1820 }, "total": { "min": 4217, - "brotli": 1962 + "brotli": 1960 } }, { @@ -33,12 +33,12 @@ "brotli": 89 }, "runtime": { - "min": 2154, - "brotli": 1137 + "min": 2186, + "brotli": 1145 }, "total": { - "min": 2250, - "brotli": 1226 + "min": 2282, + "brotli": 1234 } }, { @@ -49,11 +49,11 @@ }, "runtime": { "min": 7099, - "brotli": 3103 + "brotli": 3111 }, "total": { "min": 7842, - "brotli": 3507 + "brotli": 3515 } }, { @@ -63,12 +63,12 @@ "brotli": 116 }, "runtime": { - "min": 2306, - "brotli": 1171 + "min": 2338, + "brotli": 1183 }, "total": { - "min": 2436, - "brotli": 1287 + "min": 2468, + "brotli": 1299 } } ] diff --git a/.sizes/dom.js b/.sizes/dom.js index a37e0b5d7..2e9f45e15 100644 --- a/.sizes/dom.js +++ b/.sizes/dom.js @@ -1,4 +1,4 @@ -// size: 19659 (min) 7540 (brotli) +// size: 20005 (min) 7670 (brotli) var empty = [], rest = Symbol(); function attrTag(attrs) { @@ -76,7 +76,7 @@ function normalizeDynamicRenderer(value) { if (value) { if ("string" == typeof value) return value; let normalized = value.content || value.default || value; - if ("e" in normalized) return normalized; + if ("g" in normalized) return normalized; } } var decodeAccessor = (num) => @@ -201,7 +201,6 @@ function walkInternal(currentWalkIndex, walkCodes, scope) { } } var branchesEnabled, - isInit, isResuming, registeredValues = {}; function enableBranches() { @@ -324,43 +323,41 @@ function init(runtimeId = "M") { : visitText.length, )); return ( - (render.w = (effects = []) => { - try { - (isInit || walk2(), (isResuming = 1)); - for (let serialized of (resumes = render.r || [])) - if ("string" == typeof serialized) lastEffect = serialized; - else if ("number" == typeof serialized) - effects.push( - registeredValues[lastEffect], - (scopeLookup[serialized] ||= { L: serialized }), - ); - else - for (let scope of serialized(serializeContext)) - $global - ? "number" == typeof scope - ? (lastScopeId += scope) - : ((scopeLookup[(scope.L = ++lastScopeId)] = scope), - (scope.$ = $global), - branchesEnabled && (scope.F = scopeLookup[scope.G])) - : (($global = scope || {}), - ($global.runtimeId = runtimeId), - ($global.renderId = renderId)); - for (visit of (visits = render.v)) - ((lastTokenIndex = render.i.length), - (visitText = visit.data), - (visitType = visitText[lastTokenIndex++]), - (visitScope = scopeLookup[+nextToken()] ||= - { L: +lastToken }), - "*" === visitType - ? (visitScope["J" + nextToken()] = ( - (node) => () => - node - )((visitScope[lastToken] = visit.previousSibling))) - : branchesEnabled && visitBranches()); - runEffects(effects); - } finally { - isInit = isResuming = visits.length = resumes.length = 0; - } + (render.m = (effects = []) => { + for (let serialized of (resumes = render.r || [])) + if ("string" == typeof serialized) lastEffect = serialized; + else if ("number" == typeof serialized) + effects.push( + registeredValues[lastEffect], + (scopeLookup[serialized] ||= { L: serialized }), + ); + else + for (let scope of serialized(serializeContext)) + $global + ? "number" == typeof scope + ? (lastScopeId += scope) + : ((scopeLookup[(scope.L = ++lastScopeId)] = scope), + (scope.$ = $global), + branchesEnabled && (scope.F = scopeLookup[scope.G])) + : (($global = scope || {}), + ($global.runtimeId = runtimeId), + ($global.renderId = renderId)); + for (visit of (visits = render.v)) + ((lastTokenIndex = render.i.length), + (visitText = visit.data), + (visitType = visitText[lastTokenIndex++]), + (visitScope = scopeLookup[+nextToken()] ||= + { L: +lastToken }), + "*" === visitType + ? (visitScope["J" + nextToken()] = ( + (node) => () => + node + )((visitScope[lastToken] = visit.previousSibling))) + : branchesEnabled && visitBranches()); + return ((visits.length = resumes.length = 0), effects); + }), + (render.w = () => { + (walk2(), runResumeEffects(render)); }), render ); @@ -369,9 +366,16 @@ function init(runtimeId = "M") { }; if (renders) { initRuntime(renders); - for (let renderId in renders) ((isInit = 1), resumeRender(renderId).w()); + for (let renderId in renders) runResumeEffects(resumeRender(renderId)); } else defineRuntime({ configurable: !0, set: initRuntime }); } +function runResumeEffects(render) { + try { + ((isResuming = 1), runEffects(render.m(), 1)); + } finally { + isResuming = 0; + } +} function _resume(id, obj) { return (registeredValues[id] = obj); } @@ -735,9 +739,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) { )); } function _closure(...closureSignals) { - let [{ j: ___scopeInstancesAccessor, k: ___signalIndexAccessor }] = + let [{ l: ___scopeInstancesAccessor, n: ___signalIndexAccessor }] = closureSignals; - for (let i = closureSignals.length; i--; ) closureSignals[i].n = i; + for (let i = closureSignals.length; i--; ) closureSignals[i].t = i; return (scope) => { if (scope[___scopeInstancesAccessor]) for (let childScope of scope[___scopeInstancesAccessor]) @@ -752,17 +756,17 @@ function _closure(...closureSignals) { function _closure_get(valueAccessor, fn, getOwnerScope) { valueAccessor = decodeAccessor(valueAccessor); let closureSignal = (scope) => { - ((scope[closureSignal.k] = closureSignal.n), + ((scope[closureSignal.n] = closureSignal.t), fn(scope), subscribeToScopeSet( getOwnerScope ? getOwnerScope(scope) : scope._, - closureSignal.j, + closureSignal.l, scope, )); }; return ( - (closureSignal.j = "B" + valueAccessor), - (closureSignal.k = "C" + valueAccessor), + (closureSignal.l = "B" + valueAccessor), + (closureSignal.n = "C" + valueAccessor), closureSignal ); } @@ -829,11 +833,11 @@ function createBranch($global, renderer, parentScope, parentNode) { let branch = createScope($global), parentBranch = parentScope?.F; return ( - (branch._ = renderer.c || parentScope), + (branch._ = renderer.e || parentScope), (branch.F = branch), parentBranch && ((branch.N = parentBranch), (parentBranch.D ||= new Set()).add(branch)), - renderer.f?.(branch, parentNode.namespaceURI), + renderer.h?.(branch, parentNode.namespaceURI), branch ); } @@ -844,7 +848,7 @@ function createAndSetupBranch($global, renderer, parentScope, parentNode) { ); } function setupBranch(renderer, branch) { - return (renderer.g && queueRender(branch, renderer.g, -1), branch); + return (renderer.j && queueRender(branch, renderer.j, -1), branch); } function _content(id, template, walks, setup, params, dynamicScopesAccessor) { ((walks = walks ? walks.replace(/[^\0-1]+$/, "") : ""), @@ -881,10 +885,10 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) { walk((branch.S = branch.K = new Text()), walks, branch); }; return (owner) => ({ - e: id, - f: clone, - c: owner, - g: setup, + g: id, + h: clone, + e: owner, + j: setup, a: params, b: dynamicScopesAccessor, }); @@ -909,8 +913,8 @@ function _content_closures(renderer, closureFns) { return (owner, closureValues) => { let instance = renderer(owner); return ( - (instance.l = closureSignals), - (instance.o = closureValues), + (instance.o = closureSignals), + (instance.u = closureValues), instance ); }; @@ -1081,13 +1085,13 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) { function _attr_content(scope, nodeAccessor, value) { let content = (function (value) { let renderer = normalizeDynamicRenderer(value); - if (renderer && renderer.e) return renderer; + if (renderer && renderer.g) return renderer; })(value), rendererAccessor = "D" + nodeAccessor; - scope[rendererAccessor] !== (scope[rendererAccessor] = content?.e) && + scope[rendererAccessor] !== (scope[rendererAccessor] = content?.g) && (setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch), content?.b && - subscribeToScopeSet(content.c, content.b, scope["A" + nodeAccessor])); + subscribeToScopeSet(content.e, content.b, scope["A" + nodeAccessor])); } function _attrs_script(scope, nodeAccessor) { let el = scope[nodeAccessor], @@ -1168,18 +1172,47 @@ function _await(nodeAccessor, template, walks, setup, params) { branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)(); return ( - enableBranches(), + _enable_catch(), (scope, promise) => { - let referenceNode = scope[nodeAccessor], - tryWithPlaceholder = findBranchWithKey(scope, "Q"), - awaitBranch = scope[branchAccessor]; + let awaitCounter, + renderData, + tryWithPlaceholder = findBranchWithKey(scope, "Q"); tryWithPlaceholder - ? (placeholderShown.add(pendingEffects), + ? ((renderData = + self[tryWithPlaceholder.$.runtimeId]?.[ + tryWithPlaceholder.$.renderId + ]), + (awaitCounter = tryWithPlaceholder.O ||= + renderData?.p?.[tryWithPlaceholder.L]), + awaitCounter?.i || + (awaitCounter = tryWithPlaceholder.O = + { + d: 1, + i: 0, + c() { + if (!--awaitCounter.i) { + let placeholderBranch = tryWithPlaceholder.P; + ((tryWithPlaceholder.P = 0), + placeholderBranch && + (placeholderBranch.S.parentNode.insertBefore( + tryWithPlaceholder.S.parentNode, + placeholderBranch.S, + ), + removeAndDestroyBranch(placeholderBranch)), + queueEffect(tryWithPlaceholder, (scope2) => { + let pendingEffects2 = scope2.J; + pendingEffects2 && + ((scope2.J = []), runEffects(pendingEffects2, !0)); + })); + } + }, + }), + placeholderShown.add(pendingEffects), !scope[promiseAccessor] && - 1 === (tryWithPlaceholder.O = (tryWithPlaceholder.O || 0) + 1) && + !awaitCounter.i++ && requestAnimationFrame( () => - tryWithPlaceholder.O && + awaitCounter.i && runEffects( prepareEffects(() => queueRender( @@ -1202,10 +1235,13 @@ function _await(nodeAccessor, template, walks, setup, params) { ), ), )) - : awaitBranch && + : scope[branchAccessor] && !scope[promiseAccessor] && - (awaitBranch.S.parentNode.insertBefore(referenceNode, awaitBranch.S), - tempDetachBranch(awaitBranch)); + (scope[branchAccessor].S.parentNode.insertBefore( + scope[nodeAccessor], + scope[branchAccessor].S, + ), + tempDetachBranch(scope[branchAccessor])); let thisPromise = (scope[promiseAccessor] = promise.then( (data) => { thisPromise === scope[promiseAccessor] && @@ -1215,39 +1251,41 @@ function _await(nodeAccessor, template, walks, setup, params) { scope, () => { if ( - (awaitBranch + (scope[branchAccessor] ? tryWithPlaceholder || - referenceNode.replaceWith(awaitBranch.S.parentNode) + scope[nodeAccessor].replaceWith( + scope[branchAccessor].S.parentNode, + ) : (insertBranchBefore( - (awaitBranch = scope[branchAccessor] = - createAndSetupBranch( - scope.$, - renderer, - scope, - referenceNode.parentNode, - )), - referenceNode.parentNode, - referenceNode, + (scope[branchAccessor] = createAndSetupBranch( + scope.$, + renderer, + scope, + scope[nodeAccessor].parentNode, + )), + scope[nodeAccessor].parentNode, + scope[nodeAccessor], ), - referenceNode.remove()), - params?.(awaitBranch, [data]), - tryWithPlaceholder && + scope[nodeAccessor].remove()), + params?.(scope[branchAccessor], [data]), + awaitCounter && (placeholderShown.add(pendingEffects), - !--tryWithPlaceholder.O)) + awaitCounter.c(), + !awaitCounter.d)) ) { - let placeholderBranch = tryWithPlaceholder.P; - ((tryWithPlaceholder.P = 0), - placeholderBranch && - (placeholderBranch.S.parentNode.insertBefore( - tryWithPlaceholder.S.parentNode, - placeholderBranch.S, - ), - removeAndDestroyBranch(placeholderBranch)), - queueEffect(tryWithPlaceholder, (scope2) => { - let pendingEffects2 = scope2.J; - pendingEffects2 && - ((scope2.J = []), runEffects(pendingEffects2, !0)); - })); + let fnScopes = new Map(), + effects = renderData.m(); + for (let i = 0; i < pendingEffects.length; ) { + let fn = pendingEffects[i++], + scopes = fnScopes.get(fn); + (scopes || fnScopes.set(fn, (scopes = new Set())), + scopes.add(pendingEffects[i++])); + } + for (let i = 0; i < effects.length; ) { + let fn = effects[i++], + scope2 = effects[i++]; + fnScopes.get(fn)?.has(scope2) || queueEffect(scope2, fn); + } } }, -1, @@ -1255,7 +1293,7 @@ function _await(nodeAccessor, template, walks, setup, params) { }, (error) => { thisPromise === scope[promiseAccessor] && - (tryWithPlaceholder && (tryWithPlaceholder.O = 0), + (awaitCounter && (awaitCounter.i = 0), (scope[promiseAccessor] = 0), schedule(), queueRender(scope, renderCatch, -1, error)); @@ -1289,7 +1327,7 @@ function renderCatch(scope, error) { let owner = tryWithCatch._, placeholderBranch = tryWithCatch.P; (placeholderBranch && - ((tryWithCatch.O = 0), + (tryWithCatch.O && (tryWithCatch.O.i = 0), (owner["A" + tryWithCatch.C] = placeholderBranch), destroyBranch(tryWithCatch)), caughtError.add(pendingEffects), @@ -1333,7 +1371,7 @@ var _dynamic_tag = function (nodeAccessor, getContent, getTagVar, inputIsArgs) { if ( scope[rendererAccessor] !== (scope[rendererAccessor] = - normalizedRenderer?.e || normalizedRenderer) || + normalizedRenderer?.g || normalizedRenderer) || (getContent && !normalizedRenderer && !scope[childScopeAccessor]) ) if ( @@ -1358,7 +1396,7 @@ var _dynamic_tag = function (nodeAccessor, getContent, getTagVar, inputIsArgs) { ), content.b && subscribeToScopeSet( - content.c, + content.e, content.b, scope[childScopeAccessor].Aa, )); @@ -1366,7 +1404,7 @@ var _dynamic_tag = function (nodeAccessor, getContent, getTagVar, inputIsArgs) { } else normalizedRenderer?.b && subscribeToScopeSet( - normalizedRenderer.c, + normalizedRenderer.e, normalizedRenderer.b, scope[childScopeAccessor], ); @@ -1382,10 +1420,10 @@ var _dynamic_tag = function (nodeAccessor, getContent, getTagVar, inputIsArgs) { (childScope.Ia || childScope.Ea) && queueEffect(childScope, dynamicTagScript)); else { - for (let accessor in normalizedRenderer.l) - normalizedRenderer.l[accessor]( + for (let accessor in normalizedRenderer.o) + normalizedRenderer.o[accessor]( childScope, - normalizedRenderer.o[accessor], + normalizedRenderer.u[accessor], ); if (normalizedRenderer.a) if (inputIsArgs) @@ -1682,14 +1720,14 @@ var rendering, function queueRender(scope, signal, signalKey, value, scopeKey = scope.L) { let key = scopeKey * scopeKeyOffset + signalKey, existingRender = signalKey >= 0 && pendingRendersLookup.get(key); - if (existingRender) existingRender.m = value; + if (existingRender) existingRender.q = value; else { - let render = { d: key, h: scope, p: signal, m: value }, + let render = { f: key, k: scope, x: signal, q: value }, i = pendingRenders.push(render) - 1; for (; i; ) { let parentIndex = (i - 1) >> 1, parent = pendingRenders[parentIndex]; - if (key - parent.d >= 0) break; + if (key - parent.f >= 0) break; ((pendingRenders[i] = parent), (i = parentIndex)); } (signalKey >= 0 && pendingRendersLookup.set(key, render), @@ -1737,32 +1775,32 @@ function runRenders() { if (render !== item) { let i = 0, mid = pendingRenders.length >> 1, - key = (pendingRenders[0] = item).d; + key = (pendingRenders[0] = item).f; for (; i < mid; ) { let bestChild = 1 + (i << 1), right = bestChild + 1; if ( (right < pendingRenders.length && - pendingRenders[right].d - pendingRenders[bestChild].d < 0 && + pendingRenders[right].f - pendingRenders[bestChild].f < 0 && (bestChild = right), - pendingRenders[bestChild].d - key >= 0) + pendingRenders[bestChild].f - key >= 0) ) break; ((pendingRenders[i] = pendingRenders[bestChild]), (i = bestChild)); } pendingRenders[i] = item; } - render.h.F?.I || runRender(render); + render.k.F?.I || runRender(render); } for (let scope of pendingScopes) scope.H = 0; pendingScopes = []; } -var runRender = (render) => render.p(render.h, render.m), +var runRender = (render) => render.x(render.k, render.q), _enable_catch = () => { ((_enable_catch = () => {}), enableBranches()); let handlePendingTry = (fn, scope, branch) => { for (; branch; ) { - if (branch.O) return (branch.J ||= []).push(fn, scope); + if (branch.O?.i) return (branch.J ||= []).push(fn, scope); branch = branch.N; } }; @@ -1788,7 +1826,7 @@ var runRender = (render) => render.p(render.h, render.m), try { runRender2(render); } catch (error) { - renderCatch(render.h, error); + renderCatch(render.k, error); } })(runRender))); }; @@ -1820,7 +1858,7 @@ var classIdToBranch = new Map(), registerRenderer(fn) { _resume("$C_r", fn); }, - isRenderer: (renderer) => renderer.f, + isRenderer: (renderer) => renderer.h, getStartNode: (branch) => branch.S, setScopeNodes(branch, startNode, endNode) { ((branch.S = startNode), (branch.K = endNode)); @@ -1845,7 +1883,7 @@ var classIdToBranch = new Map(), createRenderer(params, clone) { let renderer = _content("", 0, 0, 0, params)(); return ( - (renderer.f = (branch) => { + (renderer.h = (branch) => { let cloned = clone(); ((branch.S = cloned.startNode), (branch.K = cloned.endNode)); }), @@ -1874,7 +1912,7 @@ var classIdToBranch = new Map(), createAndSetupBranch( out.global, renderer, - renderer.c, + renderer.e, document.body, ))), renderer.a?.(branch, renderer._ ? args[0] : args)); @@ -1921,7 +1959,7 @@ function mount(input = {}, reference, position) { (branch.T = (newValue) => { curValue = newValue; }), - this.g?.(branch), + this.j?.(branch), args?.(branch, input)); }); return ( diff --git a/.sizes/name-cache.json b/.sizes/name-cache.json index 8a667e8e3..325287808 100644 --- a/.sizes/name-cache.json +++ b/.sizes/name-cache.json @@ -1 +1 @@ -{"vars":{"props":{"$empty":"e","$rest":"t","$attrTag":"n","$attrTags":"r","$attrTagIterator":"o","$_assert_hoist":"i","$forIn":"l","$forOf":"u","$forTo":"f","$forUntil":"a","$_call":"c","$stringifyClassObject":"s","$stringifyStyleObject":"d","$toDelimitedString":"h","$isEventHandler":"p","$getEventHandlerName":"g","$normalizeDynamicRenderer":"v","$decodeAccessor":"b","$toArray":"m","$push":"S","$defaultDelegator":"y","$_on":"A","$createDelegator":"k","$handleDelegated":"C","$stripSpacesAndPunctuation":"N","$nextScopeId":"_","$createScope":"w","$skipScope":"E","$findBranchWithKey":"I","$destroyBranch":"M","$destroyNestedBranches":"x","$removeAndDestroyBranch":"F","$insertBranchBefore":"L","$tempDetachBranch":"T","$walker":"$","$walk":"O","$walkInternal":"D","$branchesEnabled":"K","$isResuming":"G","$registeredValues":"R","$enableBranches":"B","$init":"H","$_resume":"U","$_var_resume":"V","$_el":"P","$_attr_input_checked":"W","$_attr_input_checked_script":"j","$_attr_input_checkedValue":"q","$_attr_input_checkedValue_script":"J","$_attr_input_value":"Q","$_attr_input_value_script":"X","$_attr_select_value":"Z","$_attr_select_value_script":"z","$setSelectOptions":"Y","$_attr_details_or_dialog_open":"ee","$_attr_details_or_dialog_open_script":"te","$inputType":"ne","$setValueAndUpdateSelection":"re","$setCheckboxValue":"oe","$controllableDelegate":"ie","$syncControllable":"le","$handleChange":"ue","$handleFormReset":"fe","$hasValueChanged":"ae","$hasCheckboxChanged":"ce","$hasSelectChanged":"se","$hasFormElementChanged":"de","$normalizeStrProp":"he","$normalizeBoolProp":"pe","$toValueProp":"ge","$isScheduled":"ve","$channel":"be","$parsers":"me","$parseHTML":"Se","$schedule":"ye","$flushAndWaitFrame":"Ae","$triggerMacroTask":"ke","$_let":"Ce","$_const":"Ne","$_or":"_e","$_for_closure":"we","$_if_closure":"Ee","$subscribeToScopeSet":"Ie","$_closure":"Me","$_closure_get":"xe","$_child_setup":"Fe","$_var":"Le","$_return":"Te","$_return_change":"$e","$_var_change":"Oe","$tagIdsByGlobal":"De","$_id":"Ke","$_script":"Ge","$_el_read":"Re","$traverseAllHoisted":"Be","$_hoist":"He","$createBranch":"Ue","$createAndSetupBranch":"Ve","$setupBranch":"Pe","$_content":"We","$_content_resume":"je","$_content_closures":"qe","$cloneCache":"Je","$_attr":"Qe","$setAttribute":"Xe","$_attr_class":"Ze","$_attr_class_items":"ze","$_attr_class_item":"Ye","$_attr_style":"et","$_attr_style_items":"tt","$_attr_style_item":"nt","$_text":"rt","$_text_content":"ot","$_attrs":"it","$_attrs_content":"lt","$hasAttrAlias":"ut","$_attrs_partial":"ft","$_attrs_partial_content":"at","$attrsInternal":"ct","$_attr_content":"st","$_attrs_script":"dt","$_html":"ht","$normalizeAttrValue":"pt","$normalizeString":"gt","$_lifecycle":"vt","$removeChildNodes":"bt","$insertChildNodes":"mt","$toInsertNode":"St","$_await":"yt","$_try":"At","$renderCatch":"kt","$_if":"Ct","$_dynamic_tag":"Nt","$_resume_dynamic_tag":"_t","$dynamicTagScript":"wt","$setConditionalRenderer":"Et","$_for_of":"It","$_for_in":"Mt","$_for_to":"xt","$_for_until":"Ft","$loop":"Lt","$createBranchWithTagNameOrRenderer":"Tt","$bySecondArg":"$t","$byFirstArg":"Ot","$rendering":"Dt","$pendingRenders":"Kt","$pendingRendersLookup":"Gt","$caughtError":"Rt","$placeholderShown":"Bt","$pendingEffects":"Ht","$pendingScopes":"Ut","$scopeKeyOffset":"Vt","$queueRender":"Pt","$queueEffect":"Wt","$run":"jt","$prepareEffects":"qt","$runEffects":"Jt","$runRenders":"Qt","$runRender":"Xt","$_enable_catch":"Zt","$$signalReset":"zt","$$signal":"Yt","$abort":"en","$classIdToBranch":"tn","$compat":"nn","$_template":"rn","$mount":"on","$$clickCount__script":"ta","$$clickCount":"aa","$$setup":"na","$forEach":"ln","$$if_content__setup":"sa","$$if_content__comment_comments":"ca","$$if_content__id":"ia","$$for_content__id":"la","$$for_content__input_path__OR__i":"ma","$$for_content__input_path":"oa","$$for_content__i":"ua","$$for_content__open__script":"ba","$$for_content__open":"ea","$$for_content__setup":"_a","$$for_content__comment_text":"da","$$for_content__if":"fa","$$for_content__comment_comments":"ha","$$for_content__$params":"ja","$$for_content__comment":"pa","$$for":"ga","$$input_comments":"ka","$$input_path":"ra","$isInit":"un"}}} \ No newline at end of file +{"vars":{"props":{"$empty":"e","$rest":"t","$attrTag":"n","$attrTags":"r","$attrTagIterator":"o","$_assert_hoist":"i","$forIn":"l","$forOf":"u","$forTo":"f","$forUntil":"a","$_call":"c","$stringifyClassObject":"s","$stringifyStyleObject":"d","$toDelimitedString":"h","$isEventHandler":"p","$getEventHandlerName":"g","$normalizeDynamicRenderer":"v","$decodeAccessor":"b","$toArray":"m","$push":"S","$defaultDelegator":"y","$_on":"A","$createDelegator":"k","$handleDelegated":"C","$stripSpacesAndPunctuation":"N","$nextScopeId":"_","$createScope":"w","$skipScope":"E","$findBranchWithKey":"I","$destroyBranch":"M","$destroyNestedBranches":"x","$removeAndDestroyBranch":"F","$insertBranchBefore":"L","$tempDetachBranch":"T","$walker":"$","$walk":"O","$walkInternal":"D","$branchesEnabled":"K","$isResuming":"G","$registeredValues":"R","$enableBranches":"B","$init":"H","$_resume":"U","$_var_resume":"V","$_el":"P","$_attr_input_checked":"W","$_attr_input_checked_script":"j","$_attr_input_checkedValue":"q","$_attr_input_checkedValue_script":"J","$_attr_input_value":"Q","$_attr_input_value_script":"X","$_attr_select_value":"Z","$_attr_select_value_script":"z","$setSelectOptions":"Y","$_attr_details_or_dialog_open":"ee","$_attr_details_or_dialog_open_script":"te","$inputType":"ne","$setValueAndUpdateSelection":"re","$setCheckboxValue":"oe","$controllableDelegate":"ie","$syncControllable":"le","$handleChange":"ue","$handleFormReset":"fe","$hasValueChanged":"ae","$hasCheckboxChanged":"ce","$hasSelectChanged":"se","$hasFormElementChanged":"de","$normalizeStrProp":"he","$normalizeBoolProp":"pe","$toValueProp":"ge","$isScheduled":"ve","$channel":"be","$parsers":"me","$parseHTML":"Se","$schedule":"ye","$flushAndWaitFrame":"Ae","$triggerMacroTask":"ke","$_let":"Ce","$_const":"Ne","$_or":"_e","$_for_closure":"we","$_if_closure":"Ee","$subscribeToScopeSet":"Ie","$_closure":"Me","$_closure_get":"xe","$_child_setup":"Fe","$_var":"Le","$_return":"Te","$_return_change":"$e","$_var_change":"Oe","$tagIdsByGlobal":"De","$_id":"Ke","$_script":"Ge","$_el_read":"Re","$traverseAllHoisted":"Be","$_hoist":"He","$createBranch":"Ue","$createAndSetupBranch":"Ve","$setupBranch":"Pe","$_content":"We","$_content_resume":"je","$_content_closures":"qe","$cloneCache":"Je","$_attr":"Qe","$setAttribute":"Xe","$_attr_class":"Ze","$_attr_class_items":"ze","$_attr_class_item":"Ye","$_attr_style":"et","$_attr_style_items":"tt","$_attr_style_item":"nt","$_text":"rt","$_text_content":"ot","$_attrs":"it","$_attrs_content":"lt","$hasAttrAlias":"ut","$_attrs_partial":"ft","$_attrs_partial_content":"at","$attrsInternal":"ct","$_attr_content":"st","$_attrs_script":"dt","$_html":"ht","$normalizeAttrValue":"pt","$normalizeString":"gt","$_lifecycle":"vt","$removeChildNodes":"bt","$insertChildNodes":"mt","$toInsertNode":"St","$_await":"yt","$_try":"At","$renderCatch":"kt","$_if":"Ct","$_dynamic_tag":"Nt","$_resume_dynamic_tag":"_t","$dynamicTagScript":"wt","$setConditionalRenderer":"Et","$_for_of":"It","$_for_in":"Mt","$_for_to":"xt","$_for_until":"Ft","$loop":"Lt","$createBranchWithTagNameOrRenderer":"Tt","$bySecondArg":"$t","$byFirstArg":"Ot","$rendering":"Dt","$pendingRenders":"Kt","$pendingRendersLookup":"Gt","$caughtError":"Rt","$placeholderShown":"Bt","$pendingEffects":"Ht","$pendingScopes":"Ut","$scopeKeyOffset":"Vt","$queueRender":"Pt","$queueEffect":"Wt","$run":"jt","$prepareEffects":"qt","$runEffects":"Jt","$runRenders":"Qt","$runRender":"Xt","$_enable_catch":"Zt","$$signalReset":"zt","$$signal":"Yt","$abort":"en","$classIdToBranch":"tn","$compat":"nn","$_template":"rn","$mount":"on","$$clickCount__script":"ta","$$clickCount":"aa","$$setup":"na","$forEach":"ln","$$if_content__setup":"sa","$$if_content__comment_comments":"ca","$$if_content__id":"ia","$$for_content__id":"la","$$for_content__input_path__OR__i":"ma","$$for_content__input_path":"oa","$$for_content__i":"ua","$$for_content__open__script":"ba","$$for_content__open":"ea","$$for_content__setup":"_a","$$for_content__comment_text":"da","$$for_content__if":"fa","$$for_content__comment_comments":"ha","$$for_content__$params":"ja","$$for_content__comment":"pa","$$for":"ga","$$input_comments":"ka","$$input_path":"ra","$isInit":"un","$runResumeEffects":"fn"}}} \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr.expected.md index 81a48b49b..cfffe3e3d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-deep-recursive/__snapshots__/ssr.expected.md @@ -1,16 +1,16 @@ # Write ```html -
LOADING...
+
LOADING...
``` # Write ```html -
LOADING...
+
LOADING...
``` # Write ```html - + ``` # Render ASYNC @@ -32,9 +32,9 @@ data-level="3" > - + LOADING... - + @@ -110,9 +110,9 @@ INSERT html/body/script data-level="1" > - + LOADING... - + diff --git a/packages/runtime-tags/src/__tests__/fixtures/async-reorder-nested-batched-resolve/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/async-reorder-nested-batched-resolve/__snapshots__/ssr.expected.md index b2559dc01..2dd041b0d 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/async-reorder-nested-batched-resolve/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/async-reorder-nested-batched-resolve/__snapshots__/ssr.expected.md @@ -1,16 +1,16 @@ # Write ```html - LOADING A1 + LOADING A1 ``` # Write ```html -
LOADING B1
+
LOADING B1
``` # Write ```html -
+
``` # Render ASYNC @@ -25,9 +25,9 @@ - + LOADING A1 - + + LOADING... ``` # Write ```html - 0 + 0 ``` # Render ASYNC @@ -24,9 +24,9 @@ - + LOADING... - + + + + +``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/__snapshots__/ssr-sanitized.expected.md new file mode 100644 index 000000000..c07f567df --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/__snapshots__/ssr-sanitized.expected.md @@ -0,0 +1,19 @@ +# Render ASYNC +```html +
+ Pass +
+loading... +``` + + +# Render ASYNC +```html +
+ Pass +
+``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/__snapshots__/ssr.expected.md new file mode 100644 index 000000000..625d0d32a --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/__snapshots__/ssr.expected.md @@ -0,0 +1,135 @@ +# Write +```html +
Pass
loading... +``` + +# Write +```html + +``` + +# Render ASYNC +```html + + + + + +
+ Pass +
+ + + + loading... + + + + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/div +INSERT html/body/div/#text +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/#comment2 +INSERT html/body/#text +INSERT html/body/#comment3 +INSERT html/body/#comment4 +INSERT html/body/#comment5 +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#comment +REMOVE html/head/style after html/body/#comment5 +INSERT html/head/style +REMOVE t after html/body/#comment5 +INSERT html/body/script +``` + +# Render ASYNC +```html + + + + + +
+ Pass +
+ + + + + + + + +``` + +# Mutations +``` +INSERT t +REMOVE t after html/body/script0 +REMOVE #text after #comment +REMOVE #comment after html/body/#comment1 +REMOVE #comment after html/body/#comment1 +INSERT html/body/script1 +``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/template.marko b/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/template.marko new file mode 100644 index 000000000..fd25e58b2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/template.marko @@ -0,0 +1,9 @@ +import { resolveAfter } from "../../utils/resolve"; +let/show=1 +script -- show = 0 +div#outside -- Pass +if=show + try + @placeholder -- loading... + await=resolveAfter(0, 1) + script -- document.querySelector('#outside')!.textContent = "Fail" \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/test.ts b/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/test.ts new file mode 100644 index 000000000..99f6f09ad --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-remove-parent/test.ts @@ -0,0 +1,3 @@ +import { wait } from "../../utils/resolve"; + +export const steps = [{}, wait(2)]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/.name-cache.json b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/.name-cache.json new file mode 100644 index 000000000..99e85dde2 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/.name-cache.json @@ -0,0 +1,17 @@ +{ + "vars": { + "props": { + "$_": "t", + "$init": "o", + "$resolveAfter": "e", + "$$await_content__value": "r", + "$$await_content__setup": "c", + "$$await_content__$params": "i", + "$$try_content__await": "s", + "$$try_content__value": "n", + "$$value__closure": "_", + "$$value": "a", + "$$await_content__value__script": "m" + } + } +} diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/csr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/csr-sanitized.expected.md new file mode 100644 index 000000000..e5f3c6c92 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/csr-sanitized.expected.md @@ -0,0 +1,44 @@ +# Render +```html +
+ 0 +
+``` + + +# Render ASYNC +```html +
+ 1 +
+``` + + +# Render ASYNC +```html +
+ 1 +
+loading... +``` + + +# Render ASYNC +```html +
+ 1 effect ran +
+
+ 1 effect ran 1 +
+``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/csr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/csr.expected.md new file mode 100644 index 000000000..64aad3d11 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/csr.expected.md @@ -0,0 +1,79 @@ +# Render +```html +
+ 0 +
+ + + +``` + +# Mutations +``` +INSERT div, #comment0, #text, #comment1, #comment2 +``` + +# Render ASYNC +```html +
+ 1 +
+ + + +``` + +# Mutations +``` +UPDATE div/#text "0" => "1" +``` + +# Render ASYNC +```html +
+ 1 +
+loading... + +``` + +# Mutations +``` +INSERT #text +REMOVE #document-fragment/#comment0 after #text +REMOVE #document-fragment/#text after #text +REMOVE #document-fragment/#comment1 after #text +``` + +# Render ASYNC +```html +
+ 1 effect ran +
+ +
+ 1 effect ran 1 +
+ + +``` + +# Mutations +``` +INSERT #comment0, div1, #comment1 +REMOVE #text after #comment1 +REMOVE #text in div1 +INSERT div1/#text +REMOVE #text in div0 +INSERT div0/#text +``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/dom.expected/template.hydrate.js new file mode 100644 index 000000000..e8e1b2b79 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/dom.expected/template.hydrate.js @@ -0,0 +1,35 @@ +// size: 487 (min) 245 (brotli) +_._enable_catch(); +const $await_content__value__script = _._script( + "a0", + ($scope) => + (document.querySelector("#inside").textContent += + ` effect ran ${$scope.c}`), + ), + $await_content__value = _._const(2, ($scope) => { + (_._text($scope.a, $scope.c), $await_content__value__script($scope)); + }), + $await_content__setup = _._script( + "a1", + ($scope) => + (document.querySelector("#outside").textContent += " effect ran"), + ), + $await_content__$params = _._const(1, ($scope) => + $await_content__value($scope, $scope.b[0]), + ); +_._content_resume("a2", "loading...", "b"); +const $try_content__await = _._await( + 0, + "
", + "D l", + $await_content__setup, + $await_content__$params, + ), + $try_content__value = _._closure_get(2, ($scope) => + $try_content__await($scope, resolveAfter($scope._.c, 10)), + ), + $value__closure = _._closure($try_content__value), + $value = _._let(2, ($scope) => { + (_._text($scope.a, $scope.c), $value__closure($scope)); + }); +(_._script("a3", ($scope) => $value($scope, 1)), init()); diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/dom.expected/template.js new file mode 100644 index 000000000..81ca329ed --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/dom.expected/template.js @@ -0,0 +1,34 @@ +export const $template = "
"; +export const $walks = /* next(1), get, out(1), replace, over(2) */"D l%c"; +import { resolveAfter } from "../../utils/resolve"; +import * as _ from "@marko/runtime-tags/debug/dom"; +_._enable_catch(); +const $await_content__value__script = _._script("__tests__/template.marko_3_value", $scope => (document.querySelector('#inside').textContent += ` effect ran ${$scope.value}`)); +const $await_content__value = /* @__PURE__ */_._const("value", $scope => { + _._text($scope["#text/0"], $scope.value); + $await_content__value__script($scope); +}); +const $await_content__setup__script = _._script("__tests__/template.marko_3", $scope => (document.querySelector('#outside').textContent += ` effect ran`)); +const $await_content__setup = $await_content__setup__script; +const $await_content__$params = /* @__PURE__ */_._const("$params2", $scope => $await_content__value($scope, $scope.$params2[0])); +const $placeholder_content = _._content_resume("__tests__/template.marko_2_content", "loading...", /* over(1) */"b"); +const $try_content__await = /* @__PURE__ */_._await("#text/0", "
", /* next(1), get, out(1) */"D l", $await_content__setup, $await_content__$params); +const $try_content__value = /* @__PURE__ */_._closure_get("value", $scope => $try_content__await($scope, resolveAfter($scope._.value, 10))); +const $try_content__setup = $try_content__value; +const $value__closure = /* @__PURE__ */_._closure($try_content__value); +const $value = /* @__PURE__ */_._let("value/2", $scope => { + _._text($scope["#text/0"], $scope.value); + $value__closure($scope); +}); +const $try = /* @__PURE__ */_._try("#text/1", "", /* over(1), replace, over(2) */"b%c", $try_content__setup); +const $setup__script = _._script("__tests__/template.marko_0", $scope => $value($scope, 1)); +export function $setup($scope) { + $value($scope, 0); + $try($scope, { + placeholder: _.attrTag({ + content: $placeholder_content($scope) + }) + }); + $setup__script($scope); +} +export default /* @__PURE__ */_._template("__tests__/template.marko", $template, $walks, $setup); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/html.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/html.expected/template.js new file mode 100644 index 000000000..a62877726 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/html.expected/template.js @@ -0,0 +1,39 @@ +import { resolveAfter } from "../../utils/resolve"; +import * as _ from "@marko/runtime-tags/debug/html"; +export default _._template("__tests__/template.marko", input => { + const $scope0_id = _._scope_id(); + const $value__closures = new Set(); + let value = 0; + _._html(`
${_._escape(value)}${_._el_resume($scope0_id, "#text/0")}
`); + _._try($scope0_id, "#text/1", _._content_resume("__tests__/template.marko_1_content", () => { + const $scope1_id = _._scope_id(); + _._await($scope1_id, "#text/0", resolveAfter(value, 10), value => { + const $scope3_id = _._scope_id(); + _._html(`
${_._escape(value)}${_._el_resume($scope3_id, "#text/0")}
`); + _._script($scope3_id, "__tests__/template.marko_3"); + _._script($scope3_id, "__tests__/template.marko_3_value"); + _._scope($scope3_id, { + value + }, "__tests__/template.marko", "7:3", { + value: "7:9" + }); + }); + _._subscribe($value__closures, _._scope($scope1_id, { + _: _._scope_with_id($scope0_id), + "ClosureSignalIndex:value": 0 + }, "__tests__/template.marko", "5:1")); + _._resume_branch($scope1_id); + }, $scope0_id), { + placeholder: _.attrTag({ + content: _._content_resume("__tests__/template.marko_2_content", () => { + const $scope2_id = _._scope_id(); + _._html("loading..."); + }, $scope0_id) + }) + }); + _._script($scope0_id, "__tests__/template.marko_0"); + _._scope($scope0_id, { + "ClosureScopes:value": $value__closures + }, "__tests__/template.marko", 0); + _._resume_branch($scope0_id); +}); \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/resume-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/resume-sanitized.expected.md new file mode 100644 index 000000000..e992e22df --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/resume-sanitized.expected.md @@ -0,0 +1,24 @@ +# Render +```html +
+ 1 +
+loading... +``` + + +# Render ASYNC +```html +
+ 1 effect ran +
+
+ 1 effect ran 1 +
+``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/resume.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/resume.expected.md new file mode 100644 index 000000000..a2708bc64 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/resume.expected.md @@ -0,0 +1,131 @@ +# Render +```html + + + + + +
+ 1 + +
+ + + loading... + + + + + + +``` + + +# Render ASYNC +```html + + + + + +
+ 1 effect ran +
+ + +
+ 1 effect ran 1 +
+ + + + + + +``` + +# Mutations +``` +REMOVE #text after #comment +REMOVE #comment after html/body/#comment0 +REMOVE #comment after html/body/#comment0 +INSERT html/body/#comment1, html/body/div1, html/body/#text0, html/body/#comment2 +REMOVE #text, #comment in html/body/div1 +INSERT html/body/div1/#text +REMOVE #text, #comment in html/body/div0 +INSERT html/body/div0/#text +``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/ssr-sanitized.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/ssr-sanitized.expected.md new file mode 100644 index 000000000..9e3e8f8b4 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/ssr-sanitized.expected.md @@ -0,0 +1,24 @@ +# Render ASYNC +```html +
+ 0 +
+loading... +``` + + +# Render ASYNC +```html +
+ 0 +
+
+ 0 +
+``` diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/ssr.expected.md new file mode 100644 index 000000000..f94493b1d --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/__snapshots__/ssr.expected.md @@ -0,0 +1,154 @@ +# Write +```html +
0
loading... +``` + +# Write +```html +
0
+``` + +# Render ASYNC +```html + + + + + +
+ 0 + +
+ + + loading... + + + + + +``` + +# Mutations +``` +INSERT html +INSERT html/head +INSERT html/body +INSERT html/body/div +INSERT html/body/div/#text +INSERT html/body/div/#comment +INSERT html/body/#comment0 +INSERT html/body/#comment1 +INSERT html/body/#text +INSERT html/body/#comment2 +INSERT html/body/#comment3 +INSERT html/head/style +INSERT html/head/style/#text +INSERT t +INSERT t/#comment +REMOVE html/head/style after html/body/#comment3 +INSERT html/head/style +REMOVE t after html/body/#comment3 +INSERT html/body/script +``` + +# Render ASYNC +```html + + + + + +
+ 0 + +
+ + +
+ 0 + +
+ + + + + + +``` + +# Mutations +``` +INSERT t +INSERT html/body/#comment1 +INSERT html/body/div1 +INSERT html/body/div1/#text +INSERT html/body/div1/#comment +INSERT html/body/#comment2 +REMOVE t after html/body/script0 +REMOVE #text after #comment +REMOVE #comment after html/body/#comment0 +REMOVE #comment after html/body/#comment0 +INSERT html/body/#comment1, html/body/div1, html/body/#comment2 +INSERT html/body/script1 +``` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/template.marko b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/template.marko new file mode 100644 index 000000000..a02662d97 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/template.marko @@ -0,0 +1,10 @@ +import { resolveAfter } from "../../utils/resolve"; +let/value=0 +script -- value = 1 +div#outside -- ${value} +try + @placeholder -- loading... + await|value|=resolveAfter(value, 10) + div#inside -- ${value} + script -- document.querySelector('#inside')!.textContent += ` effect ran ${value}` + script -- document.querySelector('#outside')!.textContent += ` effect ran` \ No newline at end of file diff --git a/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/test.ts b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/test.ts new file mode 100644 index 000000000..8bf09c5f7 --- /dev/null +++ b/packages/runtime-tags/src/__tests__/fixtures/await-update-before-resume/test.ts @@ -0,0 +1,3 @@ +import { wait } from "../../utils/resolve"; + +export const steps = [{}, wait(11)]; diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.hydrate.js b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.hydrate.js index 098d6f9f5..b801b096b 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.hydrate.js +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.hydrate.js @@ -1,6 +1,3 @@ -// size: 86 (min) 79 (brotli) +// size: 84 (min) 76 (brotli) const $output = _._let(2, ($scope) => _._text($scope.a, $scope.c)); -(_._script("a0", ($scope) => { - $output($scope, JSON.stringify(testLog)); -}), - init()); +(_._script("a0", ($scope) => $output($scope, JSON.stringify(testLog))), init()); diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.js b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.js index c64b1bd77..752506c13 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.js +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/__snapshots__/dom.expected/template.js @@ -5,10 +5,7 @@ const staticVar = "static var"; import * as _ from "@marko/runtime-tags/debug/dom"; const $tagVar = /* @__PURE__ */_._const("tagVar", $scope => console.log($scope.tagVar)); const $output = /* @__PURE__ */_._let("output/2", $scope => _._text($scope["#text/0"], $scope.output)); -const $setup__script = _._script("__tests__/template.marko_0", $scope => { - debugger; - $output($scope, JSON.stringify(testLog)); -}); +const $setup__script = _._script("__tests__/template.marko_0", $scope => $output($scope, JSON.stringify(testLog))); export function $setup($scope) { console.log("identifier"); console.log(staticVar); diff --git a/packages/runtime-tags/src/__tests__/fixtures/log-tag/template.marko b/packages/runtime-tags/src/__tests__/fixtures/log-tag/template.marko index 909a03aed..f14ed8f85 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/log-tag/template.marko +++ b/packages/runtime-tags/src/__tests__/fixtures/log-tag/template.marko @@ -6,5 +6,5 @@ static const staticVar = "static var"; - + -- ${output} diff --git a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr.expected.md b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr.expected.md index c35fdcb14..7db5c9de0 100644 --- a/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr.expected.md +++ b/packages/runtime-tags/src/__tests__/fixtures/placeholder-single/__snapshots__/ssr.expected.md @@ -1,6 +1,6 @@ # Write ```html - a_A_ebd + a_A_ebd ``` # Write @@ -10,7 +10,7 @@ # Write ```html - c + c ``` # Render ASYNC @@ -26,9 +26,9 @@ a - + _A_ - + e + a_B_hbd_A_eg ``` # Write @@ -10,12 +10,12 @@ # Write ```html - c + c ``` # Write ```html - f + f ``` # Render ASYNC @@ -31,9 +31,9 @@ a - + _B_ - + h +
LOADING... ``` # Write ```html - Async: 0 + Async: 0 ``` # Render ASYNC @@ -27,9 +27,9 @@ - + LOADING... - +