marko
Version:
Optimized runtime for Marko templates.
37 lines (36 loc) • 1.5 kB
JavaScript
;
const require_control_flow = require("../dom-CNgQ6lj9.js");
//#region src/dom/catch.feat.ts
const deferToPendingTry = (fn, scope, branch) => {
while (branch) {
if (branch["#AwaitCounter"]?.i) return (scope[require_control_flow.PendingEffects] ||= ((branch[require_control_flow.PendingEffectScopes] ||= (branch["#AwaitCounter"].m && ((complete) => branch["#AwaitCounter"].c = () => complete() || require_control_flow.queueAsyncRender(branch, require_control_flow.queueEffect, require_control_flow.runPendingEffects))(branch["#AwaitCounter"].c), [])).push(scope), /* @__PURE__ */ new Set())).add(fn);
branch = branch[require_control_flow.ParentBranch];
}
};
require_control_flow.installCatch((effects) => {
let i = 0;
let fn;
let scope;
let branch;
for (; i < effects.length;) {
fn = effects[i++];
scope = effects[i++];
if ((branch = scope["#ClosestBranch"])?.["#Gen"] !== 0 && !deferToPendingTry(fn, scope, branch)) fn(scope);
}
}, (runRender) => (render) => {
try {
let branch = render[require_control_flow.Scope][require_control_flow.ClosestBranch];
while (branch) {
if (branch["#PendingRenders"]) {
render[require_control_flow.Pending] = 1;
return branch[require_control_flow.PendingRenders].push(render);
}
branch = branch[require_control_flow.ParentBranch];
}
render[require_control_flow.Pending] = 0;
runRender(render);
} catch (error) {
require_control_flow.renderCatch(render[require_control_flow.Scope], error);
}
});
//#endregion