marko 6.3.33 → 6.3.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cheatsheet.md +37 -33
- package/dist/common/constants/accessor-prefix.d.ts +1 -0
- package/dist/common/constants/accessor-prefix.debug.d.ts +1 -0
- package/dist/common/errors.d.ts +2 -0
- package/dist/common/types.d.ts +10 -0
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/{dom-BJ93mcSe.mjs → dom-B57LrRnX.mjs} +89 -46
- package/dist/debug/{dom-CiFITSPN.js → dom-Bt4OoZ-j.js} +89 -46
- package/dist/debug/dom.js +3 -1
- package/dist/debug/dom.mjs +3 -1
- package/dist/debug/html.js +205 -98
- package/dist/debug/html.mjs +205 -98
- package/dist/dom/catch.feat.js +1 -1
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/control-flow.d.ts +4 -1
- package/dist/dom/controllable-input.feat.js +1 -1
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +1 -1
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +1 -1
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +1 -1
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +1 -1
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/signals.d.ts +3 -3
- package/dist/{dom-Cj4HQ7T_.mjs → dom-BP2XSglG.mjs} +46 -33
- package/dist/{dom-CI-06TZb.js → dom-BeF9xIzO.js} +46 -33
- package/dist/dom.js +3 -1
- package/dist/dom.mjs +3 -1
- package/dist/html/compat.d.ts +4 -2
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/serializer.d.ts +9 -1
- package/dist/html/template.d.ts +1 -0
- package/dist/html/writer.d.ts +1 -0
- package/dist/html.js +88 -63
- package/dist/html.mjs +88 -63
- package/dist/translator/core/client.d.ts +1 -2
- package/dist/translator/core/server.d.ts +1 -2
- package/dist/translator/core/static.d.ts +1 -2
- package/dist/translator/index.js +514 -314
- package/dist/translator/util/constants/binding-type.d.ts +1 -0
- package/dist/translator/util/references.d.ts +8 -1
- package/dist/translator/util/serialize-reasons.d.ts +4 -4
- package/dist/translator/util/signals.d.ts +5 -0
- package/dist/translator/util/statement-tag.d.ts +2 -0
- package/dist/translator/util/translate-var.d.ts +1 -1
- package/dist/translator/visitors/export-declaration.d.ts +8 -0
- package/dist/translator/visitors/program/index.d.ts +0 -1
- package/package.json +5 -4
- package/tags/html-comment.d.marko +2 -0
- package/tags/html-script.d.marko +2 -0
- package/tags/html-style.d.marko +2 -0
- package/tags/let.d.marko +4 -5
- package/tags/show.d.marko +6 -0
- package/tags/try.d.marko +1 -1
- package/tags-html.d.ts +6 -1
- /package/dist/translator/util/{get-accessor-char.d.ts → get-accessor-enums.d.ts} +0 -0
package/dist/html.mjs
CHANGED
|
@@ -4,7 +4,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
4
4
|
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
5
|
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
6
|
return str;
|
|
7
|
-
}, unsafeXMLReg = /[
|
|
7
|
+
}, unsafeXMLReg = /[<&\r]/g, replaceUnsafeXML = (c) => c === "&" ? "&" : c === "<" ? "<" : " ", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C$1") : str, unsafeStyleReg = /<(\/style)/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str, unsafeCommentReg = />/g, escapeCommentStr = (str) => unsafeCommentReg.test(str) ? str.replace(unsafeCommentReg, ">") : str, K_SCOPE_ID = Symbol("Scope ID"), kTouchedIterator = Symbol.for("marko.touchedIterator"), { hasOwnProperty } = {}, objectProto = Object.prototype, arrayProto = Array.prototype, Generator = (function* () {})().constructor, AsyncGenerator = (async function* () {})().constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
|
|
8
8
|
let KNOWN_SYMBOLS = /* @__PURE__ */ new Map();
|
|
9
9
|
for (let name of Object.getOwnPropertyNames(Symbol)) {
|
|
10
10
|
let symbol = Symbol[name];
|
|
@@ -247,7 +247,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
247
247
|
}, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, $chunk, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
|
|
248
248
|
let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
|
|
249
249
|
return state.needsMainRuntime = !0, Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
|
|
250
|
-
}, NOOP$2 = () => {}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /'|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /"|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
|
250
|
+
}, NOOP$2 = () => {}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
|
251
251
|
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
|
|
252
252
|
if (typeof renderer == "string") {
|
|
253
253
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
@@ -278,7 +278,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
278
278
|
};
|
|
279
279
|
result = shouldResume ? withBranchId(branchId, render) : render(), rendered = _peek_scope_id() !== branchId, beforeBranch !== void 0 && (applyBranchStart(chunk, beforeBranch, rendered), _html(state.mark("]", scopeId + " " + accessor + (rendered ? " " + branchId : ""))));
|
|
280
280
|
}
|
|
281
|
-
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: renderer
|
|
281
|
+
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: rendererKey(renderer) }) : _scope_id(), result;
|
|
282
282
|
}, patchDynamicTag = ((originalDynamicTag) => (patch) => {
|
|
283
283
|
_dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
|
284
284
|
let patched = patch(tag, scopeId, accessor);
|
|
@@ -293,6 +293,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
293
293
|
peekNextScopeId: _peek_scope_id,
|
|
294
294
|
isInResumedBranch,
|
|
295
295
|
withChunk,
|
|
296
|
+
getChunk,
|
|
296
297
|
ensureState($global) {
|
|
297
298
|
let state = $global[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
|
298
299
|
return state || ($global.runtimeId ||= "M", $global.renderId ||= $global.componentIdPrefix || $global.widgetIdPrefix || "_", $global[K_TAGS_API_STATE] = state = new State($global)), state;
|
|
@@ -326,10 +327,18 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
326
327
|
return compatRegistered;
|
|
327
328
|
};
|
|
328
329
|
},
|
|
329
|
-
|
|
330
|
-
let state = this.ensureState($global)
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
createChunk($global) {
|
|
331
|
+
let state = this.ensureState($global);
|
|
332
|
+
return new Chunk(new Boundary(state), null, null, state);
|
|
333
|
+
},
|
|
334
|
+
flushScript($global, chunk) {
|
|
335
|
+
chunk ||= this.createChunk($global);
|
|
336
|
+
let { boundary } = chunk;
|
|
337
|
+
switch (boundary.flush()) {
|
|
338
|
+
case 2: throw boundary.signal.reason;
|
|
339
|
+
case 1: throw Error("Cannot serialize promise across tags/class compat layer.");
|
|
340
|
+
}
|
|
341
|
+
return chunk.flushScript().scripts;
|
|
333
342
|
},
|
|
334
343
|
render(renderer, willRerender, classAPIOut, component, input, completeChunks, registerChildScope) {
|
|
335
344
|
let state = this.ensureState(classAPIOut.global), boundary = new Boundary(state), head = new Chunk(boundary, null, getChunk()?.context ?? null, state), normalizedInput = input;
|
|
@@ -449,28 +458,28 @@ function _escape_comment(val) {
|
|
|
449
458
|
patchIteratorNext(Generator.prototype), patchIteratorNext(AsyncGenerator.prototype);
|
|
450
459
|
var State$1 = class {
|
|
451
460
|
ids = 0;
|
|
452
|
-
|
|
461
|
+
flushId = 0;
|
|
453
462
|
wroteUndefined = !1;
|
|
454
463
|
buf = [];
|
|
455
464
|
strs = /* @__PURE__ */ new Map();
|
|
456
465
|
refs = /* @__PURE__ */ new WeakMap();
|
|
457
|
-
|
|
466
|
+
pendingAssignments = /* @__PURE__ */ new Set();
|
|
458
467
|
boundary = void 0;
|
|
459
468
|
channel = void 0;
|
|
460
469
|
channelDeps = null;
|
|
461
470
|
mutated = [];
|
|
462
471
|
}, Reference = class {
|
|
463
|
-
|
|
472
|
+
assignments = null;
|
|
464
473
|
calls = null;
|
|
465
474
|
scopeId = void 0;
|
|
466
475
|
channel = void 0;
|
|
467
476
|
parent;
|
|
468
477
|
accessor;
|
|
469
|
-
|
|
478
|
+
flushId;
|
|
470
479
|
pos;
|
|
471
480
|
id;
|
|
472
|
-
constructor(parent, accessor,
|
|
473
|
-
this.parent = parent, this.accessor = accessor, this.
|
|
481
|
+
constructor(parent, accessor, flushId, pos = null, id = null) {
|
|
482
|
+
this.parent = parent, this.accessor = accessor, this.flushId = flushId, this.pos = pos, this.id = id;
|
|
474
483
|
}
|
|
475
484
|
}, Serializer = class {
|
|
476
485
|
#state = new State$1();
|
|
@@ -484,7 +493,7 @@ var State$1 = class {
|
|
|
484
493
|
try {
|
|
485
494
|
return this.#state.boundary = boundary, this.#state.channel = channel, writeScopesRoot(this.#state, flushes);
|
|
486
495
|
} finally {
|
|
487
|
-
this.#state.
|
|
496
|
+
this.#state.flushId++, this.#state.buf = [];
|
|
488
497
|
}
|
|
489
498
|
}
|
|
490
499
|
written(val) {
|
|
@@ -525,20 +534,20 @@ function writeScopesRoot(state, flushes) {
|
|
|
525
534
|
}
|
|
526
535
|
nextSlotId !== -1 && buf.push("]");
|
|
527
536
|
let extras = "";
|
|
528
|
-
(state.
|
|
537
|
+
(state.pendingAssignments.size || hasChannelMutations(state)) && (extras = ",0)", fillIndex !== -1 && (buf[fillIndex] = "_(" + buf[fillIndex], buf.push(")")), writeAssigned(state));
|
|
529
538
|
let result = extras && "(";
|
|
530
539
|
for (let chunk of buf) result += chunk;
|
|
531
540
|
return result += extras, result ? state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result : "";
|
|
532
541
|
}
|
|
533
542
|
function writeAssigned(state) {
|
|
534
543
|
let sep = state.buf.length ? "," : "";
|
|
535
|
-
if (state.
|
|
536
|
-
let
|
|
537
|
-
state.
|
|
544
|
+
if (state.pendingAssignments.size) {
|
|
545
|
+
let pending = state.pendingAssignments;
|
|
546
|
+
state.pendingAssignments = /* @__PURE__ */ new Set();
|
|
538
547
|
let buf = "", hasCalls = !1;
|
|
539
|
-
for (let ref of
|
|
548
|
+
for (let ref of pending) ref.assignments && (buf += sep + assignmentsToString(ref.assignments, ref.id), ref.assignments = null, sep = ","), hasCalls ||= ref.calls !== null;
|
|
540
549
|
if (buf && state.buf.push(buf), hasCalls) {
|
|
541
|
-
for (let ref of
|
|
550
|
+
for (let ref of pending) if (ref.calls) {
|
|
542
551
|
for (let { method, args } of ref.calls) {
|
|
543
552
|
state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
|
|
544
553
|
for (let a = 0; a < args.length; a++) a && state.buf.push(","), writeCallArg(state, args[a]);
|
|
@@ -569,10 +578,14 @@ function writeAssigned(state) {
|
|
|
569
578
|
}
|
|
570
579
|
state.mutated = remaining;
|
|
571
580
|
}
|
|
572
|
-
state.
|
|
581
|
+
state.pendingAssignments.size && writeAssigned(state);
|
|
573
582
|
}
|
|
574
583
|
function writeCallArg(state, val) {
|
|
575
|
-
val === void 0
|
|
584
|
+
if (val === void 0) state.wroteUndefined = !0, state.buf.push("$");
|
|
585
|
+
else if (writeProp(state, val, null, "")) {
|
|
586
|
+
let ref = state.refs.get(val) || state.strs.get(val);
|
|
587
|
+
ref && ref.id === null && assignId(state, ref);
|
|
588
|
+
} else state.buf.push("void 0");
|
|
576
589
|
}
|
|
577
590
|
function hasChannelMutations(state) {
|
|
578
591
|
return hasMatchingMutations(state.mutated, state.channel?.readyId);
|
|
@@ -598,22 +611,22 @@ function writeProp(state, val, parent, accessor) {
|
|
|
598
611
|
}
|
|
599
612
|
function writeReferenceOr(state, write, val, parent, accessor) {
|
|
600
613
|
let ref = state.refs.get(val);
|
|
601
|
-
if (ref) return trackChannel(state, ref) ? parent && isCircular(parent, ref) ? (ensureId(state, ref), state.
|
|
614
|
+
if (ref) return trackChannel(state, ref) ? parent && isCircular(parent, ref) ? (ensureId(state, ref), state.pendingAssignments.add(ref), addAssignment(ref, accessId(state, parent) + toAccess(accessor)), !1) : (state.buf.push(ensureId(state, ref)), !0) : !1;
|
|
602
615
|
let registered = REGISTRY.get(val);
|
|
603
|
-
return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(val, ref = new Reference(parent, accessor, state.
|
|
616
|
+
return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(val, ref = new Reference(parent, accessor, state.flushId, state.buf.length)), ref.channel = state.channel, write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
|
|
604
617
|
}
|
|
605
618
|
function trackScope(state, val, scopeId) {
|
|
606
619
|
let ref = state.refs.get(val);
|
|
607
620
|
ref ? trackChannel(state, ref) : newScopeReference(state, val, scopeId);
|
|
608
621
|
}
|
|
609
622
|
function newScopeReference(state, val, scopeId) {
|
|
610
|
-
let ref = new Reference(null, null, state.
|
|
623
|
+
let ref = new Reference(null, null, state.flushId);
|
|
611
624
|
return ref.scopeId = scopeId, ref.channel = state.channel, state.refs.set(val, ref), ref;
|
|
612
625
|
}
|
|
613
626
|
function writeRegistered(state, val, parent, accessor, registered) {
|
|
614
627
|
let { scope } = registered;
|
|
615
628
|
if (scope) {
|
|
616
|
-
let ref = new Reference(parent, accessor, state.
|
|
629
|
+
let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
617
630
|
ref.channel = state.channel, state.refs.set(val, ref);
|
|
618
631
|
let scopeId = scope[K_SCOPE_ID];
|
|
619
632
|
trackScope(state, scope, scopeId), state.buf.push("_(" + scopeId + "," + quote(registered.id, 0) + ")");
|
|
@@ -626,7 +639,7 @@ function writeString(state, val, parent, accessor) {
|
|
|
626
639
|
if (ref) {
|
|
627
640
|
if (trackChannel(state, ref)) return state.buf.push(ensureId(state, ref)), !0;
|
|
628
641
|
} else {
|
|
629
|
-
let ref = new Reference(parent, accessor, state.
|
|
642
|
+
let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
630
643
|
ref.channel = state.channel, state.strs.set(val, ref);
|
|
631
644
|
}
|
|
632
645
|
}
|
|
@@ -758,44 +771,44 @@ function writePromise(state, val, ref) {
|
|
|
758
771
|
return state.buf.push("(p=>p=new Promise((f,r)=>" + pId + "={f,r(e){p.catch(_=>0);r(e)}}))()"), val.then((v) => writeAsyncCall(state, boundary, handle, "f", v, channel, pId), (v) => writeAsyncCall(state, boundary, handle, "r", v, channel, pId)), boundary.startAsync(), !0;
|
|
759
772
|
}
|
|
760
773
|
function newAsyncHandle(state, parent, id) {
|
|
761
|
-
let handle = {}, handleRef = new Reference(parent, null, state.
|
|
774
|
+
let handle = {}, handleRef = new Reference(parent, null, state.flushId, null, id);
|
|
762
775
|
return handleRef.channel = state.channel, state.refs.set(handle, handleRef), handle;
|
|
763
776
|
}
|
|
764
777
|
function writeMap(state, val, ref) {
|
|
765
778
|
if (!val.size) return state.buf.push("new Map"), !0;
|
|
766
|
-
let items = [],
|
|
779
|
+
let items = [], assignments, needsId, deferring = !1, i = 0;
|
|
767
780
|
if (val.size < 25) {
|
|
768
781
|
for (let [itemKey, itemValue] of val) {
|
|
769
782
|
if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) && (deferring = !0), deferring) {
|
|
770
783
|
deferCall(state, ref, "set", [itemKey, itemValue]);
|
|
771
784
|
continue;
|
|
772
785
|
}
|
|
773
|
-
itemKey === val && (itemKey = void 0, (
|
|
786
|
+
itemKey === val && (itemKey = void 0, (assignments ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assignments ||= []).push("a[" + i + "][1]")), needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
|
|
774
787
|
}
|
|
775
|
-
writeArrayArg(state, ref, items,
|
|
788
|
+
writeArrayArg(state, ref, items, assignments && "((m,a)=>(" + assignmentsToString(assignments, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map,", "new Map(", needsId);
|
|
776
789
|
} else {
|
|
777
790
|
for (let [itemKey, itemValue] of val) {
|
|
778
791
|
if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) && (deferring = !0), deferring) {
|
|
779
792
|
deferCall(state, ref, "set", [itemKey, itemValue]);
|
|
780
793
|
continue;
|
|
781
794
|
}
|
|
782
|
-
itemKey === val && (itemKey = 0, (
|
|
795
|
+
itemKey === val && (itemKey = 0, (assignments ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assignments ||= []).push("a[" + (i + 1) + "]")), needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue), i = items.push(itemKey, itemValue);
|
|
783
796
|
}
|
|
784
|
-
writeArrayArg(state, ref, items,
|
|
797
|
+
writeArrayArg(state, ref, items, assignments && "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignmentsToString(assignments, "new Map") + "))(", "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(", needsId);
|
|
785
798
|
}
|
|
786
799
|
return !0;
|
|
787
800
|
}
|
|
788
801
|
function writeSet(state, val, ref) {
|
|
789
802
|
if (!val.size) return state.buf.push("new Set"), !0;
|
|
790
|
-
let items = [],
|
|
803
|
+
let items = [], assignments, needsId, deferring = !1, i = 0;
|
|
791
804
|
for (let item of val) {
|
|
792
805
|
if (!deferring && item !== val && isAncestorMember(state, ref, item) && (deferring = !0), deferring) {
|
|
793
806
|
deferCall(state, ref, "add", [item]);
|
|
794
807
|
continue;
|
|
795
808
|
}
|
|
796
|
-
item === val ? (item = 0, (
|
|
809
|
+
item === val ? (item = 0, (assignments ||= []).push("i[" + i + "]")) : needsId ||= isDedupedMember(item), i = items.push(item);
|
|
797
810
|
}
|
|
798
|
-
return writeArrayArg(state, ref, items,
|
|
811
|
+
return writeArrayArg(state, ref, items, assignments && "((s,i)=>(" + assignmentsToString(assignments, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId), !0;
|
|
799
812
|
}
|
|
800
813
|
function isAncestorMember(state, container, member) {
|
|
801
814
|
if (member === null || typeof member != "object" && typeof member != "function") return !1;
|
|
@@ -806,13 +819,13 @@ function deferCall(state, ref, method, args) {
|
|
|
806
819
|
ensureId(state, ref), (ref.calls ||= []).push({
|
|
807
820
|
method,
|
|
808
821
|
args
|
|
809
|
-
}), state.
|
|
822
|
+
}), state.pendingAssignments.add(ref);
|
|
810
823
|
}
|
|
811
824
|
function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
812
825
|
if (assignsPrefix || needsId) {
|
|
813
|
-
let arrayRef = new Reference(ref, null, state.
|
|
826
|
+
let arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
814
827
|
state.buf.push((assignsPrefix || plainPrefix) + arrayRef.id + "="), writeArray(state, items, arrayRef);
|
|
815
|
-
} else state.buf.push(plainPrefix), writeArray(state, items, new Reference(ref, null, state.
|
|
828
|
+
} else state.buf.push(plainPrefix), writeArray(state, items, new Reference(ref, null, state.flushId, state.buf.length));
|
|
816
829
|
state.buf.push(")");
|
|
817
830
|
}
|
|
818
831
|
function isDedupedMember(val) {
|
|
@@ -846,7 +859,7 @@ function writeTypedArray(state, val, ref) {
|
|
|
846
859
|
if (!canWriteBuffer(state, val.buffer, ref)) return !1;
|
|
847
860
|
let needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
|
|
848
861
|
state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
|
|
849
|
-
} else state.refs.set(val.buffer, new Reference(ref, "buffer", state.
|
|
862
|
+
} else state.refs.set(val.buffer, new Reference(ref, "buffer", state.flushId, null)), state.buf.push("new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
|
|
850
863
|
return !0;
|
|
851
864
|
}
|
|
852
865
|
function writeWeakSet(state) {
|
|
@@ -868,7 +881,7 @@ function writeAggregateError(state, val, ref) {
|
|
|
868
881
|
let inlined = writeProp(state, val.errors, ref, "errors");
|
|
869
882
|
if (inlined || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), inlined) {
|
|
870
883
|
let errorsRef = state.refs.get(val.errors);
|
|
871
|
-
errorsRef?.id && (state.
|
|
884
|
+
errorsRef?.id && (state.pendingAssignments.add(errorsRef), addAssignment(errorsRef, accessId(state, ref) + toAccess("errors")));
|
|
872
885
|
}
|
|
873
886
|
return !0;
|
|
874
887
|
}
|
|
@@ -899,7 +912,7 @@ function writeRequest(state, val, ref) {
|
|
|
899
912
|
let seenHeaders = state.refs.get(val.headers);
|
|
900
913
|
if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders), sep = ",";
|
|
901
914
|
else {
|
|
902
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.
|
|
915
|
+
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
903
916
|
let headers = stringEntriesToHeadersInit(val.headers);
|
|
904
917
|
headers && (options += sep + "headers:" + headers, sep = ",");
|
|
905
918
|
}
|
|
@@ -911,7 +924,7 @@ function writeResponse(state, val, ref) {
|
|
|
911
924
|
let seenHeaders = state.refs.get(val.headers);
|
|
912
925
|
if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
|
|
913
926
|
else {
|
|
914
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.
|
|
927
|
+
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
915
928
|
let headers = stringEntriesToHeadersInit(val.headers);
|
|
916
929
|
headers && (options += sep + "headers:" + headers);
|
|
917
930
|
}
|
|
@@ -925,7 +938,7 @@ function writeIntl(state, val, name, ref) {
|
|
|
925
938
|
}
|
|
926
939
|
state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
|
|
927
940
|
let optionsRef;
|
|
928
|
-
return needsId ? (optionsRef = new Reference(ref, null, state.
|
|
941
|
+
return needsId ? (optionsRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state)), state.buf.push(optionsRef.id + "={")) : (optionsRef = new Reference(ref, null, state.flushId, state.buf.length), state.buf.push("{")), writeObjectProps(state, options, optionsRef), state.buf.push("})"), !0;
|
|
929
942
|
}
|
|
930
943
|
function writeIntlLocale(state, val) {
|
|
931
944
|
return state.buf.push("new Intl.Locale(" + quote(val.toString(), 0) + ")"), !0;
|
|
@@ -957,11 +970,11 @@ function writeGenerator(state, iter, ref) {
|
|
|
957
970
|
if (returnValue === void 0 && !yields.length) return state.buf.push("(function*(){})()"), !0;
|
|
958
971
|
let heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
|
|
959
972
|
if (state.buf.push(returnValue === void 0 ? "(function*(a){yield*a})(" : heldReturn ? "(function*(a,r){yield*a;return r.v})(" : "(function*(a,r){yield*a;return r})("), needsId) {
|
|
960
|
-
let arrayRef = new Reference(ref, null, state.
|
|
973
|
+
let arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
961
974
|
state.buf.push(arrayRef.id + "="), writeArray(state, yields, arrayRef);
|
|
962
|
-
} else writeArray(state, yields, new Reference(ref, null, state.
|
|
975
|
+
} else writeArray(state, yields, new Reference(ref, null, state.flushId, state.buf.length));
|
|
963
976
|
if (heldReturn) {
|
|
964
|
-
let holder = new Reference(ref, null, state.
|
|
977
|
+
let holder = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
965
978
|
state.buf.push("," + holder.id + "={}"), writeProp(state, returnValue, holder, "v");
|
|
966
979
|
} else if (returnValue !== void 0) {
|
|
967
980
|
let sepIndex = state.buf.push(",") - 1;
|
|
@@ -1000,7 +1013,7 @@ function writeMaybeIterableProps(state, val, ref) {
|
|
|
1000
1013
|
let yieldSelf = "", iterArr = [];
|
|
1001
1014
|
for (let item of val) item === val && !(yieldSelf || iterArr.length) ? yieldSelf = "yield this;" : iterArr.push(item);
|
|
1002
1015
|
if (iterArr.length) {
|
|
1003
|
-
let iterRef = new Reference(ref, null, state.
|
|
1016
|
+
let iterRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
1004
1017
|
state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){" + yieldSelf + "yield*" + iterRef.id + "}");
|
|
1005
1018
|
} else state.buf.push(sep + "*[Symbol.iterator](){" + yieldSelf.slice(0, -1) + "}");
|
|
1006
1019
|
sep = ",";
|
|
@@ -1112,7 +1125,7 @@ function accessId(state, ref) {
|
|
|
1112
1125
|
}
|
|
1113
1126
|
function assignId(state, ref) {
|
|
1114
1127
|
let { pos } = ref;
|
|
1115
|
-
if (ref.id = nextRefAccess(state), pos !== null && ref.
|
|
1128
|
+
if (ref.id = nextRefAccess(state), pos !== null && ref.flushId === state.flushId) return pos === 0 ? state.buf[0] = ref.id + "=" + state.buf[0] : state.buf[pos - 1] += ref.id + "=", ref.id;
|
|
1116
1129
|
ref.channel = state.channel;
|
|
1117
1130
|
let cur = ref, accessPrevValue = "";
|
|
1118
1131
|
do {
|
|
@@ -1122,7 +1135,7 @@ function assignId(state, ref) {
|
|
|
1122
1135
|
accessPrevValue = parent.id + accessPrevValue;
|
|
1123
1136
|
break;
|
|
1124
1137
|
}
|
|
1125
|
-
if (parent.
|
|
1138
|
+
if (parent.flushId === state.flushId || parent.scopeId !== void 0) {
|
|
1126
1139
|
accessPrevValue = accessId(state, parent) + accessPrevValue;
|
|
1127
1140
|
break;
|
|
1128
1141
|
}
|
|
@@ -1130,11 +1143,11 @@ function assignId(state, ref) {
|
|
|
1130
1143
|
} while (cur);
|
|
1131
1144
|
return ref.id + "=" + accessPrevValue;
|
|
1132
1145
|
}
|
|
1133
|
-
function
|
|
1134
|
-
return
|
|
1146
|
+
function assignmentsToString(assignments, value) {
|
|
1147
|
+
return assignments.length > 100 ? "($=>(" + assignments.join("=$,") + "=$))(" + value + ")" : assignments.join("=") + "=" + value;
|
|
1135
1148
|
}
|
|
1136
1149
|
function addAssignment(ref, assign) {
|
|
1137
|
-
ref.
|
|
1150
|
+
ref.assignments ? ref.assignments.push(assign) : ref.assignments = [assign];
|
|
1138
1151
|
}
|
|
1139
1152
|
function nextRefAccess(state) {
|
|
1140
1153
|
return "_." + nextId(state);
|
|
@@ -1250,6 +1263,9 @@ function getContext(key) {
|
|
|
1250
1263
|
function getState() {
|
|
1251
1264
|
return $chunk.boundary.state;
|
|
1252
1265
|
}
|
|
1266
|
+
function rendererKey(renderer) {
|
|
1267
|
+
return renderer?.e === void 0 ? renderer?.a || renderer : renderer.a + " " + renderer.e;
|
|
1268
|
+
}
|
|
1253
1269
|
function getScopeId(scope) {
|
|
1254
1270
|
return scope[K_SCOPE_ID];
|
|
1255
1271
|
}
|
|
@@ -1328,7 +1344,7 @@ function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
|
|
|
1328
1344
|
let shouldResume = serializeReason !== 0, render = normalizeServerRender(content), branchId = _peek_scope_id();
|
|
1329
1345
|
render && (shouldResume ? withBranchId(branchId, render) : render()), _peek_scope_id() === branchId ? _scope_id() : shouldResume && writeScope(scopeId, {
|
|
1330
1346
|
["A" + nodeAccessor]: writeScope(branchId, {}),
|
|
1331
|
-
["D" + nodeAccessor]: render
|
|
1347
|
+
["D" + nodeAccessor]: rendererKey(render)
|
|
1332
1348
|
});
|
|
1333
1349
|
}
|
|
1334
1350
|
function normalizeServerRender(value) {
|
|
@@ -1815,7 +1831,13 @@ function offTick(cb) {
|
|
|
1815
1831
|
function flushTickQueue() {
|
|
1816
1832
|
let queue = tickQueue;
|
|
1817
1833
|
tickQueue = void 0;
|
|
1818
|
-
for (let cb of queue)
|
|
1834
|
+
for (let cb of queue) try {
|
|
1835
|
+
cb(!0);
|
|
1836
|
+
} catch (err) {
|
|
1837
|
+
tick(() => {
|
|
1838
|
+
throw err;
|
|
1839
|
+
});
|
|
1840
|
+
}
|
|
1819
1841
|
}
|
|
1820
1842
|
//#endregion
|
|
1821
1843
|
//#region src/html/attrs.ts
|
|
@@ -1837,7 +1859,7 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, seriali
|
|
|
1837
1859
|
}
|
|
1838
1860
|
function _textarea_value(value) {
|
|
1839
1861
|
let escaped = _escape(normalizeStrAttrValue(value));
|
|
1840
|
-
return escaped[0] === "\n"
|
|
1862
|
+
return escaped[0] === "\n" ? "\n" + escaped : escaped;
|
|
1841
1863
|
}
|
|
1842
1864
|
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1843
1865
|
return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);
|
|
@@ -1954,13 +1976,13 @@ function escapeSingleQuotedAttrValue(value) {
|
|
|
1954
1976
|
return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
|
|
1955
1977
|
}
|
|
1956
1978
|
function replaceUnsafeSingleQuoteAttrChar(match) {
|
|
1957
|
-
return match === "'" ? "'" : "&";
|
|
1979
|
+
return match === "'" ? "'" : match === "\r" ? " " : "&";
|
|
1958
1980
|
}
|
|
1959
1981
|
function escapeDoubleQuotedAttrValue(value) {
|
|
1960
1982
|
return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
|
|
1961
1983
|
}
|
|
1962
1984
|
function replaceUnsafeDoubleQuoteAttrChar(match) {
|
|
1963
|
-
return match === "\"" ? """ : "&";
|
|
1985
|
+
return match === "\"" ? """ : match === "\r" ? " " : "&";
|
|
1964
1986
|
}
|
|
1965
1987
|
function normalizedValueMatches(a, b) {
|
|
1966
1988
|
let value = normalizeStrAttrValue(b);
|
|
@@ -1974,11 +1996,11 @@ function normalizeStrAttrValue(value) {
|
|
|
1974
1996
|
}
|
|
1975
1997
|
//#endregion
|
|
1976
1998
|
//#region src/html/dynamic-tag.ts
|
|
1977
|
-
function _content(id, fn) {
|
|
1978
|
-
return fn.a = id, fn;
|
|
1999
|
+
function _content(id, fn, scopeId) {
|
|
2000
|
+
return fn.a = id, fn.e = scopeId, fn;
|
|
1979
2001
|
}
|
|
1980
2002
|
function _content_resume(id, fn, scopeId) {
|
|
1981
|
-
return _resume(_content(id, fn), id, scopeId);
|
|
2003
|
+
return _resume(_content(id, fn, scopeId), id, scopeId);
|
|
1982
2004
|
}
|
|
1983
2005
|
//#endregion
|
|
1984
2006
|
//#region src/html/template.ts
|
|
@@ -2189,14 +2211,17 @@ function writeTriggerScript(html, triggers) {
|
|
|
2189
2211
|
let htmlStr = _escape_script(JSON.stringify(html)), exprs = triggers.map((trigger) => {
|
|
2190
2212
|
let options = trigger.options && toObjectExpression(trigger.options);
|
|
2191
2213
|
switch (trigger.type) {
|
|
2192
|
-
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(
|
|
2214
|
+
case "visible": return `(e=>e&&new IntersectionObserver((e,i)=>e.some(e=>e.isIntersecting)&&i.disconnect()+l()${options ? `,${options}` : ""}).observe(e))(${querySelectorOrLoad(trigger.selector)})`;
|
|
2193
2215
|
case "idle": return `(self.requestIdleCallback||l)(l${options ? `,${options}` : ""})`;
|
|
2194
2216
|
case "media": return `(m=>m.matches?l():m.addEventListener("change",l,{once:1}))(matchMedia(${JSON.stringify(trigger.selector)}))`;
|
|
2195
|
-
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(
|
|
2217
|
+
default: return `(e=>e?.addEventListener("${trigger.type.slice(3)}",l,{once:1}))(${querySelectorOrLoad(trigger.selector)})`;
|
|
2196
2218
|
}
|
|
2197
2219
|
});
|
|
2198
2220
|
writeScript(`((p,h,d,l=$=>{d||p.after(new Range().createContextualFragment(d=h))})=>${exprs.length > 1 ? `{${exprs.join(";")}}` : exprs[0]})(document.currentScript,${htmlStr})`);
|
|
2199
2221
|
}
|
|
2222
|
+
function querySelectorOrLoad(selector) {
|
|
2223
|
+
return `document.querySelector(${JSON.stringify(selector)})||l()`;
|
|
2224
|
+
}
|
|
2200
2225
|
function toObjectExpression(options) {
|
|
2201
2226
|
let result = "{", sep = "";
|
|
2202
2227
|
for (let key in options) Object.hasOwn(options, key) && (result += sep + toObjectKey(key) + ":" + JSON.stringify(options[key]), sep = ",");
|