marko 6.3.32 → 6.3.34
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 +38 -31
- package/dist/common/errors.d.ts +1 -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-CiFITSPN.js → dom-Bj58jt8y.js} +55 -30
- package/dist/debug/{dom-BJ93mcSe.mjs → dom-klf8Ec_o.mjs} +55 -30
- package/dist/debug/dom.js +3 -1
- package/dist/debug/dom.mjs +3 -1
- package/dist/debug/html.js +154 -86
- package/dist/debug/html.mjs +155 -84
- package/dist/dom/catch.feat.js +1 -1
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/control-flow.d.ts +3 -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-Cj4HQ7T_.mjs → dom-6hBvZW7X.mjs} +27 -21
- package/dist/{dom-CI-06TZb.js → dom-B-XpL2_H.js} +27 -21
- package/dist/dom.js +3 -1
- package/dist/dom.mjs +3 -1
- package/dist/html/compat.d.ts +6 -2
- package/dist/html/writer.d.ts +3 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +104 -65
- package/dist/html.mjs +104 -65
- 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 +430 -294
- package/dist/translator/util/branch-tag.d.ts +5 -0
- 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 +4 -3
- package/dist/translator/util/statement-tag.d.ts +2 -0
- package/dist/translator/visitors/program/index.d.ts +0 -1
- package/index.d.ts +19 -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 +2 -2
- 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.js
CHANGED
|
@@ -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) || {};
|
|
@@ -265,8 +265,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
265
265
|
needsScript && _script(branchId, "d"), (shouldResume || needsScript) && _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
266
266
|
})();
|
|
267
267
|
} else {
|
|
268
|
-
shouldResume
|
|
269
|
-
let render = () => {
|
|
268
|
+
let chunk = getChunk(), beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0, render = () => {
|
|
270
269
|
if (renderer) try {
|
|
271
270
|
return _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
|
|
272
271
|
...inputOrArgs,
|
|
@@ -277,7 +276,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
277
276
|
}
|
|
278
277
|
else if (content) return content();
|
|
279
278
|
};
|
|
280
|
-
result = shouldResume ? withBranchId(branchId, render) : render(), rendered = _peek_scope_id() !== branchId,
|
|
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 : ""))));
|
|
281
280
|
}
|
|
282
281
|
return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: renderer?.a || renderer }) : _scope_id(), result;
|
|
283
282
|
}, patchDynamicTag = ((originalDynamicTag) => (patch) => {
|
|
@@ -285,7 +284,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
285
284
|
let patched = patch(tag, scopeId, accessor);
|
|
286
285
|
return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume);
|
|
287
286
|
};
|
|
288
|
-
})(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kBlockIndex = Symbol(), kDeferIndex = Symbol(), assetFlush, SET_SCOPE_REGISTER_ID = "$C_s", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
|
287
|
+
})(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kBlockIndex = Symbol(), kDeferIndex = Symbol(), assetFlush, SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
|
289
288
|
$global,
|
|
290
289
|
fork: _await,
|
|
291
290
|
write: _html,
|
|
@@ -293,6 +292,8 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
293
292
|
nextScopeId: _scope_id,
|
|
294
293
|
peekNextScopeId: _peek_scope_id,
|
|
295
294
|
isInResumedBranch,
|
|
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;
|
|
@@ -361,7 +370,13 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
|
|
|
361
370
|
},
|
|
362
371
|
register,
|
|
363
372
|
registerRenderBody(fn) {
|
|
364
|
-
register(
|
|
373
|
+
register(RENDER_BODY_ID, fn);
|
|
374
|
+
},
|
|
375
|
+
registerClassFunctions(input) {
|
|
376
|
+
for (let key in input) {
|
|
377
|
+
let value = input[key];
|
|
378
|
+
typeof value == "function" && !getRegistered(value) && register(RENDER_BODY_ID, value);
|
|
379
|
+
}
|
|
365
380
|
}
|
|
366
381
|
};
|
|
367
382
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -444,28 +459,28 @@ function _escape_comment(val) {
|
|
|
444
459
|
patchIteratorNext(Generator.prototype), patchIteratorNext(AsyncGenerator.prototype);
|
|
445
460
|
var State$1 = class {
|
|
446
461
|
ids = 0;
|
|
447
|
-
|
|
462
|
+
flushId = 0;
|
|
448
463
|
wroteUndefined = !1;
|
|
449
464
|
buf = [];
|
|
450
465
|
strs = /* @__PURE__ */ new Map();
|
|
451
466
|
refs = /* @__PURE__ */ new WeakMap();
|
|
452
|
-
|
|
467
|
+
pendingAssignments = /* @__PURE__ */ new Set();
|
|
453
468
|
boundary = void 0;
|
|
454
469
|
channel = void 0;
|
|
455
470
|
channelDeps = null;
|
|
456
471
|
mutated = [];
|
|
457
472
|
}, Reference = class {
|
|
458
|
-
|
|
473
|
+
assignments = null;
|
|
459
474
|
calls = null;
|
|
460
475
|
scopeId = void 0;
|
|
461
476
|
channel = void 0;
|
|
462
477
|
parent;
|
|
463
478
|
accessor;
|
|
464
|
-
|
|
479
|
+
flushId;
|
|
465
480
|
pos;
|
|
466
481
|
id;
|
|
467
|
-
constructor(parent, accessor,
|
|
468
|
-
this.parent = parent, this.accessor = accessor, this.
|
|
482
|
+
constructor(parent, accessor, flushId, pos = null, id = null) {
|
|
483
|
+
this.parent = parent, this.accessor = accessor, this.flushId = flushId, this.pos = pos, this.id = id;
|
|
469
484
|
}
|
|
470
485
|
}, Serializer = class {
|
|
471
486
|
#state = new State$1();
|
|
@@ -479,7 +494,7 @@ var State$1 = class {
|
|
|
479
494
|
try {
|
|
480
495
|
return this.#state.boundary = boundary, this.#state.channel = channel, writeScopesRoot(this.#state, flushes);
|
|
481
496
|
} finally {
|
|
482
|
-
this.#state.
|
|
497
|
+
this.#state.flushId++, this.#state.buf = [];
|
|
483
498
|
}
|
|
484
499
|
}
|
|
485
500
|
written(val) {
|
|
@@ -520,20 +535,20 @@ function writeScopesRoot(state, flushes) {
|
|
|
520
535
|
}
|
|
521
536
|
nextSlotId !== -1 && buf.push("]");
|
|
522
537
|
let extras = "";
|
|
523
|
-
(state.
|
|
538
|
+
(state.pendingAssignments.size || hasChannelMutations(state)) && (extras = ",0)", fillIndex !== -1 && (buf[fillIndex] = "_(" + buf[fillIndex], buf.push(")")), writeAssigned(state));
|
|
524
539
|
let result = extras && "(";
|
|
525
540
|
for (let chunk of buf) result += chunk;
|
|
526
541
|
return result += extras, result ? state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result : "";
|
|
527
542
|
}
|
|
528
543
|
function writeAssigned(state) {
|
|
529
544
|
let sep = state.buf.length ? "," : "";
|
|
530
|
-
if (state.
|
|
531
|
-
let
|
|
532
|
-
state.
|
|
545
|
+
if (state.pendingAssignments.size) {
|
|
546
|
+
let pending = state.pendingAssignments;
|
|
547
|
+
state.pendingAssignments = /* @__PURE__ */ new Set();
|
|
533
548
|
let buf = "", hasCalls = !1;
|
|
534
|
-
for (let ref of
|
|
549
|
+
for (let ref of pending) ref.assignments && (buf += sep + assignmentsToString(ref.assignments, ref.id), ref.assignments = null, sep = ","), hasCalls ||= ref.calls !== null;
|
|
535
550
|
if (buf && state.buf.push(buf), hasCalls) {
|
|
536
|
-
for (let ref of
|
|
551
|
+
for (let ref of pending) if (ref.calls) {
|
|
537
552
|
for (let { method, args } of ref.calls) {
|
|
538
553
|
state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
|
|
539
554
|
for (let a = 0; a < args.length; a++) a && state.buf.push(","), writeCallArg(state, args[a]);
|
|
@@ -564,10 +579,14 @@ function writeAssigned(state) {
|
|
|
564
579
|
}
|
|
565
580
|
state.mutated = remaining;
|
|
566
581
|
}
|
|
567
|
-
state.
|
|
582
|
+
state.pendingAssignments.size && writeAssigned(state);
|
|
568
583
|
}
|
|
569
584
|
function writeCallArg(state, val) {
|
|
570
|
-
val === void 0
|
|
585
|
+
if (val === void 0) state.wroteUndefined = !0, state.buf.push("$");
|
|
586
|
+
else if (writeProp(state, val, null, "")) {
|
|
587
|
+
let ref = state.refs.get(val) || state.strs.get(val);
|
|
588
|
+
ref && ref.id === null && assignId(state, ref);
|
|
589
|
+
} else state.buf.push("void 0");
|
|
571
590
|
}
|
|
572
591
|
function hasChannelMutations(state) {
|
|
573
592
|
return hasMatchingMutations(state.mutated, state.channel?.readyId);
|
|
@@ -593,22 +612,22 @@ function writeProp(state, val, parent, accessor) {
|
|
|
593
612
|
}
|
|
594
613
|
function writeReferenceOr(state, write, val, parent, accessor) {
|
|
595
614
|
let ref = state.refs.get(val);
|
|
596
|
-
if (ref) return trackChannel(state, ref) ? parent && isCircular(parent, ref) ? (ensureId(state, ref), state.
|
|
615
|
+
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;
|
|
597
616
|
let registered = REGISTRY.get(val);
|
|
598
|
-
return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(val, ref = new Reference(parent, accessor, state.
|
|
617
|
+
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));
|
|
599
618
|
}
|
|
600
619
|
function trackScope(state, val, scopeId) {
|
|
601
620
|
let ref = state.refs.get(val);
|
|
602
621
|
ref ? trackChannel(state, ref) : newScopeReference(state, val, scopeId);
|
|
603
622
|
}
|
|
604
623
|
function newScopeReference(state, val, scopeId) {
|
|
605
|
-
let ref = new Reference(null, null, state.
|
|
624
|
+
let ref = new Reference(null, null, state.flushId);
|
|
606
625
|
return ref.scopeId = scopeId, ref.channel = state.channel, state.refs.set(val, ref), ref;
|
|
607
626
|
}
|
|
608
627
|
function writeRegistered(state, val, parent, accessor, registered) {
|
|
609
628
|
let { scope } = registered;
|
|
610
629
|
if (scope) {
|
|
611
|
-
let ref = new Reference(parent, accessor, state.
|
|
630
|
+
let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
612
631
|
ref.channel = state.channel, state.refs.set(val, ref);
|
|
613
632
|
let scopeId = scope[K_SCOPE_ID];
|
|
614
633
|
trackScope(state, scope, scopeId), state.buf.push("_(" + scopeId + "," + quote(registered.id, 0) + ")");
|
|
@@ -621,7 +640,7 @@ function writeString(state, val, parent, accessor) {
|
|
|
621
640
|
if (ref) {
|
|
622
641
|
if (trackChannel(state, ref)) return state.buf.push(ensureId(state, ref)), !0;
|
|
623
642
|
} else {
|
|
624
|
-
let ref = new Reference(parent, accessor, state.
|
|
643
|
+
let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
625
644
|
ref.channel = state.channel, state.strs.set(val, ref);
|
|
626
645
|
}
|
|
627
646
|
}
|
|
@@ -753,44 +772,44 @@ function writePromise(state, val, ref) {
|
|
|
753
772
|
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;
|
|
754
773
|
}
|
|
755
774
|
function newAsyncHandle(state, parent, id) {
|
|
756
|
-
let handle = {}, handleRef = new Reference(parent, null, state.
|
|
775
|
+
let handle = {}, handleRef = new Reference(parent, null, state.flushId, null, id);
|
|
757
776
|
return handleRef.channel = state.channel, state.refs.set(handle, handleRef), handle;
|
|
758
777
|
}
|
|
759
778
|
function writeMap(state, val, ref) {
|
|
760
779
|
if (!val.size) return state.buf.push("new Map"), !0;
|
|
761
|
-
let items = [],
|
|
780
|
+
let items = [], assignments, needsId, deferring = !1, i = 0;
|
|
762
781
|
if (val.size < 25) {
|
|
763
782
|
for (let [itemKey, itemValue] of val) {
|
|
764
783
|
if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) && (deferring = !0), deferring) {
|
|
765
784
|
deferCall(state, ref, "set", [itemKey, itemValue]);
|
|
766
785
|
continue;
|
|
767
786
|
}
|
|
768
|
-
itemKey === val && (itemKey = void 0, (
|
|
787
|
+
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]);
|
|
769
788
|
}
|
|
770
|
-
writeArrayArg(state, ref, items,
|
|
789
|
+
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);
|
|
771
790
|
} else {
|
|
772
791
|
for (let [itemKey, itemValue] of val) {
|
|
773
792
|
if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) && (deferring = !0), deferring) {
|
|
774
793
|
deferCall(state, ref, "set", [itemKey, itemValue]);
|
|
775
794
|
continue;
|
|
776
795
|
}
|
|
777
|
-
itemKey === val && (itemKey = 0, (
|
|
796
|
+
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);
|
|
778
797
|
}
|
|
779
|
-
writeArrayArg(state, ref, items,
|
|
798
|
+
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);
|
|
780
799
|
}
|
|
781
800
|
return !0;
|
|
782
801
|
}
|
|
783
802
|
function writeSet(state, val, ref) {
|
|
784
803
|
if (!val.size) return state.buf.push("new Set"), !0;
|
|
785
|
-
let items = [],
|
|
804
|
+
let items = [], assignments, needsId, deferring = !1, i = 0;
|
|
786
805
|
for (let item of val) {
|
|
787
806
|
if (!deferring && item !== val && isAncestorMember(state, ref, item) && (deferring = !0), deferring) {
|
|
788
807
|
deferCall(state, ref, "add", [item]);
|
|
789
808
|
continue;
|
|
790
809
|
}
|
|
791
|
-
item === val ? (item = 0, (
|
|
810
|
+
item === val ? (item = 0, (assignments ||= []).push("i[" + i + "]")) : needsId ||= isDedupedMember(item), i = items.push(item);
|
|
792
811
|
}
|
|
793
|
-
return writeArrayArg(state, ref, items,
|
|
812
|
+
return writeArrayArg(state, ref, items, assignments && "((s,i)=>(" + assignmentsToString(assignments, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId), !0;
|
|
794
813
|
}
|
|
795
814
|
function isAncestorMember(state, container, member) {
|
|
796
815
|
if (member === null || typeof member != "object" && typeof member != "function") return !1;
|
|
@@ -801,13 +820,13 @@ function deferCall(state, ref, method, args) {
|
|
|
801
820
|
ensureId(state, ref), (ref.calls ||= []).push({
|
|
802
821
|
method,
|
|
803
822
|
args
|
|
804
|
-
}), state.
|
|
823
|
+
}), state.pendingAssignments.add(ref);
|
|
805
824
|
}
|
|
806
825
|
function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
807
826
|
if (assignsPrefix || needsId) {
|
|
808
|
-
let arrayRef = new Reference(ref, null, state.
|
|
827
|
+
let arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
809
828
|
state.buf.push((assignsPrefix || plainPrefix) + arrayRef.id + "="), writeArray(state, items, arrayRef);
|
|
810
|
-
} else state.buf.push(plainPrefix), writeArray(state, items, new Reference(ref, null, state.
|
|
829
|
+
} else state.buf.push(plainPrefix), writeArray(state, items, new Reference(ref, null, state.flushId, state.buf.length));
|
|
811
830
|
state.buf.push(")");
|
|
812
831
|
}
|
|
813
832
|
function isDedupedMember(val) {
|
|
@@ -841,7 +860,7 @@ function writeTypedArray(state, val, ref) {
|
|
|
841
860
|
if (!canWriteBuffer(state, val.buffer, ref)) return !1;
|
|
842
861
|
let needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
|
|
843
862
|
state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
|
|
844
|
-
} else state.refs.set(val.buffer, new Reference(ref, "buffer", state.
|
|
863
|
+
} 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)) + ")"));
|
|
845
864
|
return !0;
|
|
846
865
|
}
|
|
847
866
|
function writeWeakSet(state) {
|
|
@@ -863,7 +882,7 @@ function writeAggregateError(state, val, ref) {
|
|
|
863
882
|
let inlined = writeProp(state, val.errors, ref, "errors");
|
|
864
883
|
if (inlined || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), inlined) {
|
|
865
884
|
let errorsRef = state.refs.get(val.errors);
|
|
866
|
-
errorsRef?.id && (state.
|
|
885
|
+
errorsRef?.id && (state.pendingAssignments.add(errorsRef), addAssignment(errorsRef, accessId(state, ref) + toAccess("errors")));
|
|
867
886
|
}
|
|
868
887
|
return !0;
|
|
869
888
|
}
|
|
@@ -894,7 +913,7 @@ function writeRequest(state, val, ref) {
|
|
|
894
913
|
let seenHeaders = state.refs.get(val.headers);
|
|
895
914
|
if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders), sep = ",";
|
|
896
915
|
else {
|
|
897
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.
|
|
916
|
+
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
898
917
|
let headers = stringEntriesToHeadersInit(val.headers);
|
|
899
918
|
headers && (options += sep + "headers:" + headers, sep = ",");
|
|
900
919
|
}
|
|
@@ -906,7 +925,7 @@ function writeResponse(state, val, ref) {
|
|
|
906
925
|
let seenHeaders = state.refs.get(val.headers);
|
|
907
926
|
if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
|
|
908
927
|
else {
|
|
909
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.
|
|
928
|
+
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
910
929
|
let headers = stringEntriesToHeadersInit(val.headers);
|
|
911
930
|
headers && (options += sep + "headers:" + headers);
|
|
912
931
|
}
|
|
@@ -920,7 +939,7 @@ function writeIntl(state, val, name, ref) {
|
|
|
920
939
|
}
|
|
921
940
|
state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
|
|
922
941
|
let optionsRef;
|
|
923
|
-
return needsId ? (optionsRef = new Reference(ref, null, state.
|
|
942
|
+
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;
|
|
924
943
|
}
|
|
925
944
|
function writeIntlLocale(state, val) {
|
|
926
945
|
return state.buf.push("new Intl.Locale(" + quote(val.toString(), 0) + ")"), !0;
|
|
@@ -952,11 +971,11 @@ function writeGenerator(state, iter, ref) {
|
|
|
952
971
|
if (returnValue === void 0 && !yields.length) return state.buf.push("(function*(){})()"), !0;
|
|
953
972
|
let heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
|
|
954
973
|
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) {
|
|
955
|
-
let arrayRef = new Reference(ref, null, state.
|
|
974
|
+
let arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
956
975
|
state.buf.push(arrayRef.id + "="), writeArray(state, yields, arrayRef);
|
|
957
|
-
} else writeArray(state, yields, new Reference(ref, null, state.
|
|
976
|
+
} else writeArray(state, yields, new Reference(ref, null, state.flushId, state.buf.length));
|
|
958
977
|
if (heldReturn) {
|
|
959
|
-
let holder = new Reference(ref, null, state.
|
|
978
|
+
let holder = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
960
979
|
state.buf.push("," + holder.id + "={}"), writeProp(state, returnValue, holder, "v");
|
|
961
980
|
} else if (returnValue !== void 0) {
|
|
962
981
|
let sepIndex = state.buf.push(",") - 1;
|
|
@@ -995,7 +1014,7 @@ function writeMaybeIterableProps(state, val, ref) {
|
|
|
995
1014
|
let yieldSelf = "", iterArr = [];
|
|
996
1015
|
for (let item of val) item === val && !(yieldSelf || iterArr.length) ? yieldSelf = "yield this;" : iterArr.push(item);
|
|
997
1016
|
if (iterArr.length) {
|
|
998
|
-
let iterRef = new Reference(ref, null, state.
|
|
1017
|
+
let iterRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
999
1018
|
state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){" + yieldSelf + "yield*" + iterRef.id + "}");
|
|
1000
1019
|
} else state.buf.push(sep + "*[Symbol.iterator](){" + yieldSelf.slice(0, -1) + "}");
|
|
1001
1020
|
sep = ",";
|
|
@@ -1107,7 +1126,7 @@ function accessId(state, ref) {
|
|
|
1107
1126
|
}
|
|
1108
1127
|
function assignId(state, ref) {
|
|
1109
1128
|
let { pos } = ref;
|
|
1110
|
-
if (ref.id = nextRefAccess(state), pos !== null && ref.
|
|
1129
|
+
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;
|
|
1111
1130
|
ref.channel = state.channel;
|
|
1112
1131
|
let cur = ref, accessPrevValue = "";
|
|
1113
1132
|
do {
|
|
@@ -1117,7 +1136,7 @@ function assignId(state, ref) {
|
|
|
1117
1136
|
accessPrevValue = parent.id + accessPrevValue;
|
|
1118
1137
|
break;
|
|
1119
1138
|
}
|
|
1120
|
-
if (parent.
|
|
1139
|
+
if (parent.flushId === state.flushId || parent.scopeId !== void 0) {
|
|
1121
1140
|
accessPrevValue = accessId(state, parent) + accessPrevValue;
|
|
1122
1141
|
break;
|
|
1123
1142
|
}
|
|
@@ -1125,11 +1144,11 @@ function assignId(state, ref) {
|
|
|
1125
1144
|
} while (cur);
|
|
1126
1145
|
return ref.id + "=" + accessPrevValue;
|
|
1127
1146
|
}
|
|
1128
|
-
function
|
|
1129
|
-
return
|
|
1147
|
+
function assignmentsToString(assignments, value) {
|
|
1148
|
+
return assignments.length > 100 ? "($=>(" + assignments.join("=$,") + "=$))(" + value + ")" : assignments.join("=") + "=" + value;
|
|
1130
1149
|
}
|
|
1131
1150
|
function addAssignment(ref, assign) {
|
|
1132
|
-
ref.
|
|
1151
|
+
ref.assignments ? ref.assignments.push(assign) : ref.assignments = [assign];
|
|
1133
1152
|
}
|
|
1134
1153
|
function nextRefAccess(state) {
|
|
1135
1154
|
return "_." + nextId(state);
|
|
@@ -1230,6 +1249,15 @@ function forStepBy(by, index) {
|
|
|
1230
1249
|
function getChunk() {
|
|
1231
1250
|
return $chunk;
|
|
1232
1251
|
}
|
|
1252
|
+
function withChunk(chunk, cb) {
|
|
1253
|
+
let prev = $chunk;
|
|
1254
|
+
$chunk = chunk;
|
|
1255
|
+
try {
|
|
1256
|
+
return cb();
|
|
1257
|
+
} finally {
|
|
1258
|
+
$chunk = prev;
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1233
1261
|
function getContext(key) {
|
|
1234
1262
|
return $chunk.context?.[key];
|
|
1235
1263
|
}
|
|
@@ -1382,14 +1410,19 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
1382
1410
|
}), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
1383
1411
|
}
|
|
1384
1412
|
function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1385
|
-
let
|
|
1386
|
-
|
|
1387
|
-
let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
1388
|
-
shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1413
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0 && (!parentEndTag || serializeStateful !== 0), branchId = _peek_scope_id(), chunk = $chunk, beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0, branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
1414
|
+
beforeBranch !== void 0 && applyBranchStart(chunk, beforeBranch, shouldWriteBranch), shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1389
1415
|
["D" + accessor]: branchIndex || void 0,
|
|
1390
1416
|
["A" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
1391
1417
|
}), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
1392
1418
|
}
|
|
1419
|
+
function deferBranchStart(chunk) {
|
|
1420
|
+
let beforeBranch = chunk.html;
|
|
1421
|
+
return chunk.html = "", beforeBranch;
|
|
1422
|
+
}
|
|
1423
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
1424
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
1425
|
+
}
|
|
1393
1426
|
function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
|
|
1394
1427
|
let endTag = parentEndTag || "";
|
|
1395
1428
|
if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
|
|
@@ -1796,7 +1829,13 @@ function offTick(cb) {
|
|
|
1796
1829
|
function flushTickQueue() {
|
|
1797
1830
|
let queue = tickQueue;
|
|
1798
1831
|
tickQueue = void 0;
|
|
1799
|
-
for (let cb of queue)
|
|
1832
|
+
for (let cb of queue) try {
|
|
1833
|
+
cb(!0);
|
|
1834
|
+
} catch (err) {
|
|
1835
|
+
tick(() => {
|
|
1836
|
+
throw err;
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1800
1839
|
}
|
|
1801
1840
|
//#endregion
|
|
1802
1841
|
//#region src/html/attrs.ts
|
|
@@ -1935,13 +1974,13 @@ function escapeSingleQuotedAttrValue(value) {
|
|
|
1935
1974
|
return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
|
|
1936
1975
|
}
|
|
1937
1976
|
function replaceUnsafeSingleQuoteAttrChar(match) {
|
|
1938
|
-
return match === "'" ? "'" : "&";
|
|
1977
|
+
return match === "'" ? "'" : match === "\r" ? " " : "&";
|
|
1939
1978
|
}
|
|
1940
1979
|
function escapeDoubleQuotedAttrValue(value) {
|
|
1941
1980
|
return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
|
|
1942
1981
|
}
|
|
1943
1982
|
function replaceUnsafeDoubleQuoteAttrChar(match) {
|
|
1944
|
-
return match === "\"" ? """ : "&";
|
|
1983
|
+
return match === "\"" ? """ : match === "\r" ? " " : "&";
|
|
1945
1984
|
}
|
|
1946
1985
|
function normalizedValueMatches(a, b) {
|
|
1947
1986
|
let value = normalizeStrAttrValue(b);
|
|
@@ -2050,7 +2089,7 @@ var ServerRendered = class {
|
|
|
2050
2089
|
stream.write(html), stream.flush?.();
|
|
2051
2090
|
}, (err) => {
|
|
2052
2091
|
let socket = "socket" in stream && stream.socket;
|
|
2053
|
-
if (socket && typeof socket.destroySoon == "function"
|
|
2092
|
+
if (socket && typeof socket.destroySoon == "function" ? socket.destroySoon() : stream.destroy ? stream.destroy() : stream.end(), !stream.emit?.("error", err)) throw err;
|
|
2054
2093
|
}, () => {
|
|
2055
2094
|
stream.end();
|
|
2056
2095
|
});
|
|
@@ -2193,4 +2232,4 @@ exports.$global = $global, exports._assert_hoist = _assert_hoist, exports._attr
|
|
|
2193
2232
|
get: function() {
|
|
2194
2233
|
return _dynamic_tag;
|
|
2195
2234
|
}
|
|
2196
|
-
}), exports._el = _el, exports._el_read_error = _el_read_error, exports._el_resume = _el_resume, exports._escape = _escape, exports._escape_comment = _escape_comment, exports._escape_script = _escape_script, exports._escape_style = _escape_style, exports._escape_style_value = _escape_style_value, exports._existing_scope = _existing_scope, exports._flush_head = _flush_head, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_read_error = _hoist_read_error, exports._html = _html, exports._id = _id, exports._if = _if, exports._peek_scope_id = _peek_scope_id, exports._resume = _resume, exports._resume_branch = _resume_branch, exports._resume_locals = _resume_locals, exports._scope = writeScope, exports._scope_id = _scope_id, exports._scope_reason = _scope_reason, exports._scope_with_id = _scope_with_id, exports._script = _script, exports._sep = _sep, exports._serialize_guard = _serialize_guard, exports._serialize_if = _serialize_if, exports._set_serialize_reason = _set_serialize_reason, exports._show_end = _show_end, exports._show_start = _show_start, exports._style_html = _style_html, exports._subscribe = _subscribe, exports._template = _template, exports._textarea_value = _textarea_value, exports._to_text = _to_text, exports._trailers = _trailers, exports._try = _try, exports._unescaped = _unescaped, exports._var = _var, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = forIn, exports.
|
|
2235
|
+
}), exports._el = _el, exports._el_read_error = _el_read_error, exports._el_resume = _el_resume, exports._escape = _escape, exports._escape_comment = _escape_comment, exports._escape_script = _escape_script, exports._escape_style = _escape_style, exports._escape_style_value = _escape_style_value, exports._existing_scope = _existing_scope, exports._flush_head = _flush_head, exports._for_in = _for_in, exports._for_of = _for_of, exports._for_to = _for_to, exports._for_until = _for_until, exports._hoist = _hoist, exports._hoist_read_error = _hoist_read_error, exports._html = _html, exports._id = _id, exports._if = _if, exports._peek_scope_id = _peek_scope_id, exports._resume = _resume, exports._resume_branch = _resume_branch, exports._resume_locals = _resume_locals, exports._scope = writeScope, exports._scope_id = _scope_id, exports._scope_reason = _scope_reason, exports._scope_with_id = _scope_with_id, exports._script = _script, exports._sep = _sep, exports._serialize_guard = _serialize_guard, exports._serialize_if = _serialize_if, exports._set_serialize_reason = _set_serialize_reason, exports._show_end = _show_end, exports._show_start = _show_start, exports._style_html = _style_html, exports._subscribe = _subscribe, exports._template = _template, exports._textarea_value = _textarea_value, exports._to_text = _to_text, exports._trailers = _trailers, exports._try = _try, exports._unescaped = _unescaped, exports._var = _var, exports.attrTag = attrTag, exports.attrTags = attrTags, exports.compat = compat, exports.forIn = forIn, exports.forOf = forOf, exports.forTo = forTo, exports.forUntil = forUntil, exports.withLoadAssets = withLoadAssets, exports.withPageAssets = withPageAssets;
|