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.mjs
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
|
//#region src/common/attr-tag.ts
|
|
@@ -443,28 +458,28 @@ function _escape_comment(val) {
|
|
|
443
458
|
patchIteratorNext(Generator.prototype), patchIteratorNext(AsyncGenerator.prototype);
|
|
444
459
|
var State$1 = class {
|
|
445
460
|
ids = 0;
|
|
446
|
-
|
|
461
|
+
flushId = 0;
|
|
447
462
|
wroteUndefined = !1;
|
|
448
463
|
buf = [];
|
|
449
464
|
strs = /* @__PURE__ */ new Map();
|
|
450
465
|
refs = /* @__PURE__ */ new WeakMap();
|
|
451
|
-
|
|
466
|
+
pendingAssignments = /* @__PURE__ */ new Set();
|
|
452
467
|
boundary = void 0;
|
|
453
468
|
channel = void 0;
|
|
454
469
|
channelDeps = null;
|
|
455
470
|
mutated = [];
|
|
456
471
|
}, Reference = class {
|
|
457
|
-
|
|
472
|
+
assignments = null;
|
|
458
473
|
calls = null;
|
|
459
474
|
scopeId = void 0;
|
|
460
475
|
channel = void 0;
|
|
461
476
|
parent;
|
|
462
477
|
accessor;
|
|
463
|
-
|
|
478
|
+
flushId;
|
|
464
479
|
pos;
|
|
465
480
|
id;
|
|
466
|
-
constructor(parent, accessor,
|
|
467
|
-
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;
|
|
468
483
|
}
|
|
469
484
|
}, Serializer = class {
|
|
470
485
|
#state = new State$1();
|
|
@@ -478,7 +493,7 @@ var State$1 = class {
|
|
|
478
493
|
try {
|
|
479
494
|
return this.#state.boundary = boundary, this.#state.channel = channel, writeScopesRoot(this.#state, flushes);
|
|
480
495
|
} finally {
|
|
481
|
-
this.#state.
|
|
496
|
+
this.#state.flushId++, this.#state.buf = [];
|
|
482
497
|
}
|
|
483
498
|
}
|
|
484
499
|
written(val) {
|
|
@@ -519,20 +534,20 @@ function writeScopesRoot(state, flushes) {
|
|
|
519
534
|
}
|
|
520
535
|
nextSlotId !== -1 && buf.push("]");
|
|
521
536
|
let extras = "";
|
|
522
|
-
(state.
|
|
537
|
+
(state.pendingAssignments.size || hasChannelMutations(state)) && (extras = ",0)", fillIndex !== -1 && (buf[fillIndex] = "_(" + buf[fillIndex], buf.push(")")), writeAssigned(state));
|
|
523
538
|
let result = extras && "(";
|
|
524
539
|
for (let chunk of buf) result += chunk;
|
|
525
540
|
return result += extras, result ? state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result : "";
|
|
526
541
|
}
|
|
527
542
|
function writeAssigned(state) {
|
|
528
543
|
let sep = state.buf.length ? "," : "";
|
|
529
|
-
if (state.
|
|
530
|
-
let
|
|
531
|
-
state.
|
|
544
|
+
if (state.pendingAssignments.size) {
|
|
545
|
+
let pending = state.pendingAssignments;
|
|
546
|
+
state.pendingAssignments = /* @__PURE__ */ new Set();
|
|
532
547
|
let buf = "", hasCalls = !1;
|
|
533
|
-
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;
|
|
534
549
|
if (buf && state.buf.push(buf), hasCalls) {
|
|
535
|
-
for (let ref of
|
|
550
|
+
for (let ref of pending) if (ref.calls) {
|
|
536
551
|
for (let { method, args } of ref.calls) {
|
|
537
552
|
state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
|
|
538
553
|
for (let a = 0; a < args.length; a++) a && state.buf.push(","), writeCallArg(state, args[a]);
|
|
@@ -563,10 +578,14 @@ function writeAssigned(state) {
|
|
|
563
578
|
}
|
|
564
579
|
state.mutated = remaining;
|
|
565
580
|
}
|
|
566
|
-
state.
|
|
581
|
+
state.pendingAssignments.size && writeAssigned(state);
|
|
567
582
|
}
|
|
568
583
|
function writeCallArg(state, val) {
|
|
569
|
-
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");
|
|
570
589
|
}
|
|
571
590
|
function hasChannelMutations(state) {
|
|
572
591
|
return hasMatchingMutations(state.mutated, state.channel?.readyId);
|
|
@@ -592,22 +611,22 @@ function writeProp(state, val, parent, accessor) {
|
|
|
592
611
|
}
|
|
593
612
|
function writeReferenceOr(state, write, val, parent, accessor) {
|
|
594
613
|
let ref = state.refs.get(val);
|
|
595
|
-
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;
|
|
596
615
|
let registered = REGISTRY.get(val);
|
|
597
|
-
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));
|
|
598
617
|
}
|
|
599
618
|
function trackScope(state, val, scopeId) {
|
|
600
619
|
let ref = state.refs.get(val);
|
|
601
620
|
ref ? trackChannel(state, ref) : newScopeReference(state, val, scopeId);
|
|
602
621
|
}
|
|
603
622
|
function newScopeReference(state, val, scopeId) {
|
|
604
|
-
let ref = new Reference(null, null, state.
|
|
623
|
+
let ref = new Reference(null, null, state.flushId);
|
|
605
624
|
return ref.scopeId = scopeId, ref.channel = state.channel, state.refs.set(val, ref), ref;
|
|
606
625
|
}
|
|
607
626
|
function writeRegistered(state, val, parent, accessor, registered) {
|
|
608
627
|
let { scope } = registered;
|
|
609
628
|
if (scope) {
|
|
610
|
-
let ref = new Reference(parent, accessor, state.
|
|
629
|
+
let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
611
630
|
ref.channel = state.channel, state.refs.set(val, ref);
|
|
612
631
|
let scopeId = scope[K_SCOPE_ID];
|
|
613
632
|
trackScope(state, scope, scopeId), state.buf.push("_(" + scopeId + "," + quote(registered.id, 0) + ")");
|
|
@@ -620,7 +639,7 @@ function writeString(state, val, parent, accessor) {
|
|
|
620
639
|
if (ref) {
|
|
621
640
|
if (trackChannel(state, ref)) return state.buf.push(ensureId(state, ref)), !0;
|
|
622
641
|
} else {
|
|
623
|
-
let ref = new Reference(parent, accessor, state.
|
|
642
|
+
let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
|
|
624
643
|
ref.channel = state.channel, state.strs.set(val, ref);
|
|
625
644
|
}
|
|
626
645
|
}
|
|
@@ -752,44 +771,44 @@ function writePromise(state, val, ref) {
|
|
|
752
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;
|
|
753
772
|
}
|
|
754
773
|
function newAsyncHandle(state, parent, id) {
|
|
755
|
-
let handle = {}, handleRef = new Reference(parent, null, state.
|
|
774
|
+
let handle = {}, handleRef = new Reference(parent, null, state.flushId, null, id);
|
|
756
775
|
return handleRef.channel = state.channel, state.refs.set(handle, handleRef), handle;
|
|
757
776
|
}
|
|
758
777
|
function writeMap(state, val, ref) {
|
|
759
778
|
if (!val.size) return state.buf.push("new Map"), !0;
|
|
760
|
-
let items = [],
|
|
779
|
+
let items = [], assignments, needsId, deferring = !1, i = 0;
|
|
761
780
|
if (val.size < 25) {
|
|
762
781
|
for (let [itemKey, itemValue] of val) {
|
|
763
782
|
if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) && (deferring = !0), deferring) {
|
|
764
783
|
deferCall(state, ref, "set", [itemKey, itemValue]);
|
|
765
784
|
continue;
|
|
766
785
|
}
|
|
767
|
-
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]);
|
|
768
787
|
}
|
|
769
|
-
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);
|
|
770
789
|
} else {
|
|
771
790
|
for (let [itemKey, itemValue] of val) {
|
|
772
791
|
if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) && (deferring = !0), deferring) {
|
|
773
792
|
deferCall(state, ref, "set", [itemKey, itemValue]);
|
|
774
793
|
continue;
|
|
775
794
|
}
|
|
776
|
-
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);
|
|
777
796
|
}
|
|
778
|
-
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);
|
|
779
798
|
}
|
|
780
799
|
return !0;
|
|
781
800
|
}
|
|
782
801
|
function writeSet(state, val, ref) {
|
|
783
802
|
if (!val.size) return state.buf.push("new Set"), !0;
|
|
784
|
-
let items = [],
|
|
803
|
+
let items = [], assignments, needsId, deferring = !1, i = 0;
|
|
785
804
|
for (let item of val) {
|
|
786
805
|
if (!deferring && item !== val && isAncestorMember(state, ref, item) && (deferring = !0), deferring) {
|
|
787
806
|
deferCall(state, ref, "add", [item]);
|
|
788
807
|
continue;
|
|
789
808
|
}
|
|
790
|
-
item === val ? (item = 0, (
|
|
809
|
+
item === val ? (item = 0, (assignments ||= []).push("i[" + i + "]")) : needsId ||= isDedupedMember(item), i = items.push(item);
|
|
791
810
|
}
|
|
792
|
-
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;
|
|
793
812
|
}
|
|
794
813
|
function isAncestorMember(state, container, member) {
|
|
795
814
|
if (member === null || typeof member != "object" && typeof member != "function") return !1;
|
|
@@ -800,13 +819,13 @@ function deferCall(state, ref, method, args) {
|
|
|
800
819
|
ensureId(state, ref), (ref.calls ||= []).push({
|
|
801
820
|
method,
|
|
802
821
|
args
|
|
803
|
-
}), state.
|
|
822
|
+
}), state.pendingAssignments.add(ref);
|
|
804
823
|
}
|
|
805
824
|
function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
|
|
806
825
|
if (assignsPrefix || needsId) {
|
|
807
|
-
let arrayRef = new Reference(ref, null, state.
|
|
826
|
+
let arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
808
827
|
state.buf.push((assignsPrefix || plainPrefix) + arrayRef.id + "="), writeArray(state, items, arrayRef);
|
|
809
|
-
} 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));
|
|
810
829
|
state.buf.push(")");
|
|
811
830
|
}
|
|
812
831
|
function isDedupedMember(val) {
|
|
@@ -840,7 +859,7 @@ function writeTypedArray(state, val, ref) {
|
|
|
840
859
|
if (!canWriteBuffer(state, val.buffer, ref)) return !1;
|
|
841
860
|
let needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
|
|
842
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 : "") : "") + ")");
|
|
843
|
-
} 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)) + ")"));
|
|
844
863
|
return !0;
|
|
845
864
|
}
|
|
846
865
|
function writeWeakSet(state) {
|
|
@@ -862,7 +881,7 @@ function writeAggregateError(state, val, ref) {
|
|
|
862
881
|
let inlined = writeProp(state, val.errors, ref, "errors");
|
|
863
882
|
if (inlined || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), inlined) {
|
|
864
883
|
let errorsRef = state.refs.get(val.errors);
|
|
865
|
-
errorsRef?.id && (state.
|
|
884
|
+
errorsRef?.id && (state.pendingAssignments.add(errorsRef), addAssignment(errorsRef, accessId(state, ref) + toAccess("errors")));
|
|
866
885
|
}
|
|
867
886
|
return !0;
|
|
868
887
|
}
|
|
@@ -893,7 +912,7 @@ function writeRequest(state, val, ref) {
|
|
|
893
912
|
let seenHeaders = state.refs.get(val.headers);
|
|
894
913
|
if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders), sep = ",";
|
|
895
914
|
else {
|
|
896
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.
|
|
915
|
+
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
897
916
|
let headers = stringEntriesToHeadersInit(val.headers);
|
|
898
917
|
headers && (options += sep + "headers:" + headers, sep = ",");
|
|
899
918
|
}
|
|
@@ -905,7 +924,7 @@ function writeResponse(state, val, ref) {
|
|
|
905
924
|
let seenHeaders = state.refs.get(val.headers);
|
|
906
925
|
if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
|
|
907
926
|
else {
|
|
908
|
-
state.refs.set(val.headers, new Reference(ref, "headers", state.
|
|
927
|
+
state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
|
|
909
928
|
let headers = stringEntriesToHeadersInit(val.headers);
|
|
910
929
|
headers && (options += sep + "headers:" + headers);
|
|
911
930
|
}
|
|
@@ -919,7 +938,7 @@ function writeIntl(state, val, name, ref) {
|
|
|
919
938
|
}
|
|
920
939
|
state.buf.push("new Intl." + name + "(" + quote(locale, 0) + ",");
|
|
921
940
|
let optionsRef;
|
|
922
|
-
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;
|
|
923
942
|
}
|
|
924
943
|
function writeIntlLocale(state, val) {
|
|
925
944
|
return state.buf.push("new Intl.Locale(" + quote(val.toString(), 0) + ")"), !0;
|
|
@@ -951,11 +970,11 @@ function writeGenerator(state, iter, ref) {
|
|
|
951
970
|
if (returnValue === void 0 && !yields.length) return state.buf.push("(function*(){})()"), !0;
|
|
952
971
|
let heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
|
|
953
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) {
|
|
954
|
-
let arrayRef = new Reference(ref, null, state.
|
|
973
|
+
let arrayRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
955
974
|
state.buf.push(arrayRef.id + "="), writeArray(state, yields, arrayRef);
|
|
956
|
-
} else writeArray(state, yields, new Reference(ref, null, state.
|
|
975
|
+
} else writeArray(state, yields, new Reference(ref, null, state.flushId, state.buf.length));
|
|
957
976
|
if (heldReturn) {
|
|
958
|
-
let holder = new Reference(ref, null, state.
|
|
977
|
+
let holder = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
959
978
|
state.buf.push("," + holder.id + "={}"), writeProp(state, returnValue, holder, "v");
|
|
960
979
|
} else if (returnValue !== void 0) {
|
|
961
980
|
let sepIndex = state.buf.push(",") - 1;
|
|
@@ -994,7 +1013,7 @@ function writeMaybeIterableProps(state, val, ref) {
|
|
|
994
1013
|
let yieldSelf = "", iterArr = [];
|
|
995
1014
|
for (let item of val) item === val && !(yieldSelf || iterArr.length) ? yieldSelf = "yield this;" : iterArr.push(item);
|
|
996
1015
|
if (iterArr.length) {
|
|
997
|
-
let iterRef = new Reference(ref, null, state.
|
|
1016
|
+
let iterRef = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
|
|
998
1017
|
state.buf.push(sep + "*[(" + iterRef.id + "="), writeArray(state, iterArr, iterRef), state.buf.push(",Symbol.iterator)](){" + yieldSelf + "yield*" + iterRef.id + "}");
|
|
999
1018
|
} else state.buf.push(sep + "*[Symbol.iterator](){" + yieldSelf.slice(0, -1) + "}");
|
|
1000
1019
|
sep = ",";
|
|
@@ -1106,7 +1125,7 @@ function accessId(state, ref) {
|
|
|
1106
1125
|
}
|
|
1107
1126
|
function assignId(state, ref) {
|
|
1108
1127
|
let { pos } = ref;
|
|
1109
|
-
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;
|
|
1110
1129
|
ref.channel = state.channel;
|
|
1111
1130
|
let cur = ref, accessPrevValue = "";
|
|
1112
1131
|
do {
|
|
@@ -1116,7 +1135,7 @@ function assignId(state, ref) {
|
|
|
1116
1135
|
accessPrevValue = parent.id + accessPrevValue;
|
|
1117
1136
|
break;
|
|
1118
1137
|
}
|
|
1119
|
-
if (parent.
|
|
1138
|
+
if (parent.flushId === state.flushId || parent.scopeId !== void 0) {
|
|
1120
1139
|
accessPrevValue = accessId(state, parent) + accessPrevValue;
|
|
1121
1140
|
break;
|
|
1122
1141
|
}
|
|
@@ -1124,11 +1143,11 @@ function assignId(state, ref) {
|
|
|
1124
1143
|
} while (cur);
|
|
1125
1144
|
return ref.id + "=" + accessPrevValue;
|
|
1126
1145
|
}
|
|
1127
|
-
function
|
|
1128
|
-
return
|
|
1146
|
+
function assignmentsToString(assignments, value) {
|
|
1147
|
+
return assignments.length > 100 ? "($=>(" + assignments.join("=$,") + "=$))(" + value + ")" : assignments.join("=") + "=" + value;
|
|
1129
1148
|
}
|
|
1130
1149
|
function addAssignment(ref, assign) {
|
|
1131
|
-
ref.
|
|
1150
|
+
ref.assignments ? ref.assignments.push(assign) : ref.assignments = [assign];
|
|
1132
1151
|
}
|
|
1133
1152
|
function nextRefAccess(state) {
|
|
1134
1153
|
return "_." + nextId(state);
|
|
@@ -1229,6 +1248,15 @@ function forStepBy(by, index) {
|
|
|
1229
1248
|
function getChunk() {
|
|
1230
1249
|
return $chunk;
|
|
1231
1250
|
}
|
|
1251
|
+
function withChunk(chunk, cb) {
|
|
1252
|
+
let prev = $chunk;
|
|
1253
|
+
$chunk = chunk;
|
|
1254
|
+
try {
|
|
1255
|
+
return cb();
|
|
1256
|
+
} finally {
|
|
1257
|
+
$chunk = prev;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1232
1260
|
function getContext(key) {
|
|
1233
1261
|
return $chunk.context?.[key];
|
|
1234
1262
|
}
|
|
@@ -1381,14 +1409,19 @@ function forBranches(by, iterate, scopeId, accessor, serializeBranch, serializeM
|
|
|
1381
1409
|
}), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
|
|
1382
1410
|
}
|
|
1383
1411
|
function _if(cb, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1384
|
-
let
|
|
1385
|
-
|
|
1386
|
-
let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
|
1387
|
-
shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1412
|
+
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;
|
|
1413
|
+
beforeBranch !== void 0 && applyBranchStart(chunk, beforeBranch, shouldWriteBranch), shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
|
|
1388
1414
|
["D" + accessor]: branchIndex || void 0,
|
|
1389
1415
|
["A" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
|
|
1390
1416
|
}), writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
|
|
1391
1417
|
}
|
|
1418
|
+
function deferBranchStart(chunk) {
|
|
1419
|
+
let beforeBranch = chunk.html;
|
|
1420
|
+
return chunk.html = "", beforeBranch;
|
|
1421
|
+
}
|
|
1422
|
+
function applyBranchStart(chunk, beforeBranch, rendered) {
|
|
1423
|
+
chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
|
|
1424
|
+
}
|
|
1392
1425
|
function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, singleNode, branchIds) {
|
|
1393
1426
|
let endTag = parentEndTag || "";
|
|
1394
1427
|
if (serializeMarker !== 0) if (!parentEndTag || serializeStateful !== 0) {
|
|
@@ -1795,7 +1828,13 @@ function offTick(cb) {
|
|
|
1795
1828
|
function flushTickQueue() {
|
|
1796
1829
|
let queue = tickQueue;
|
|
1797
1830
|
tickQueue = void 0;
|
|
1798
|
-
for (let cb of queue)
|
|
1831
|
+
for (let cb of queue) try {
|
|
1832
|
+
cb(!0);
|
|
1833
|
+
} catch (err) {
|
|
1834
|
+
tick(() => {
|
|
1835
|
+
throw err;
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1799
1838
|
}
|
|
1800
1839
|
//#endregion
|
|
1801
1840
|
//#region src/html/attrs.ts
|
|
@@ -1934,13 +1973,13 @@ function escapeSingleQuotedAttrValue(value) {
|
|
|
1934
1973
|
return singleQuoteAttrReplacements.test(value) ? value.replace(singleQuoteAttrReplacements, replaceUnsafeSingleQuoteAttrChar) : value;
|
|
1935
1974
|
}
|
|
1936
1975
|
function replaceUnsafeSingleQuoteAttrChar(match) {
|
|
1937
|
-
return match === "'" ? "'" : "&";
|
|
1976
|
+
return match === "'" ? "'" : match === "\r" ? " " : "&";
|
|
1938
1977
|
}
|
|
1939
1978
|
function escapeDoubleQuotedAttrValue(value) {
|
|
1940
1979
|
return doubleQuoteAttrReplacements.test(value) ? value.replace(doubleQuoteAttrReplacements, replaceUnsafeDoubleQuoteAttrChar) : value;
|
|
1941
1980
|
}
|
|
1942
1981
|
function replaceUnsafeDoubleQuoteAttrChar(match) {
|
|
1943
|
-
return match === "\"" ? """ : "&";
|
|
1982
|
+
return match === "\"" ? """ : match === "\r" ? " " : "&";
|
|
1944
1983
|
}
|
|
1945
1984
|
function normalizedValueMatches(a, b) {
|
|
1946
1985
|
let value = normalizeStrAttrValue(b);
|
|
@@ -2049,7 +2088,7 @@ var ServerRendered = class {
|
|
|
2049
2088
|
stream.write(html), stream.flush?.();
|
|
2050
2089
|
}, (err) => {
|
|
2051
2090
|
let socket = "socket" in stream && stream.socket;
|
|
2052
|
-
if (socket && typeof socket.destroySoon == "function"
|
|
2091
|
+
if (socket && typeof socket.destroySoon == "function" ? socket.destroySoon() : stream.destroy ? stream.destroy() : stream.end(), !stream.emit?.("error", err)) throw err;
|
|
2053
2092
|
}, () => {
|
|
2054
2093
|
stream.end();
|
|
2055
2094
|
});
|
|
@@ -2188,4 +2227,4 @@ function toObjectExpression(options) {
|
|
|
2188
2227
|
//#region src/html/compat.ts
|
|
2189
2228
|
function NOOP() {}
|
|
2190
2229
|
//#endregion
|
|
2191
|
-
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _resume_locals, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _style_html, _subscribe, _template, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn,
|
|
2230
|
+
export { $global, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _id, _if, _peek_scope_id, _resume, _resume_branch, _resume_locals, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _sep, _serialize_guard, _serialize_if, _set_serialize_reason, _show_end, _show_start, _style_html, _subscribe, _template, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, withLoadAssets, withPageAssets };
|