marko 6.3.51 → 6.3.52

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.
Files changed (67) hide show
  1. package/dist/debug/dom/catch.feat.js +1 -1
  2. package/dist/debug/dom/catch.feat.mjs +1 -1
  3. package/dist/debug/dom/controllable-input.feat.js +1 -1
  4. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  5. package/dist/debug/dom/controllable-open.feat.js +1 -1
  6. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  7. package/dist/debug/dom/controllable-select.feat.js +1 -1
  8. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  9. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  10. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable.feat.js +1 -1
  12. package/dist/debug/dom/controllable.feat.mjs +1 -1
  13. package/dist/debug/dom/dynamic-tag-var.feat.js +2 -3
  14. package/dist/debug/dom/dynamic-tag-var.feat.mjs +2 -3
  15. package/dist/debug/dom/placeholder.feat.js +2 -2
  16. package/dist/debug/dom/placeholder.feat.mjs +2 -2
  17. package/dist/debug/{dom-BAGeiafn.js → dom-BJKb8-wr.js} +22 -27
  18. package/dist/debug/{dom-C55iHvof.mjs → dom-Dq_Yu7MS.mjs} +19 -18
  19. package/dist/debug/dom.js +10 -10
  20. package/dist/debug/dom.mjs +10 -10
  21. package/dist/debug/html.js +56 -40
  22. package/dist/debug/html.mjs +56 -40
  23. package/dist/dom/catch.feat.js +3 -3
  24. package/dist/dom/catch.feat.mjs +1 -1
  25. package/dist/dom/controllable-input.feat.js +1 -1
  26. package/dist/dom/controllable-input.feat.mjs +1 -1
  27. package/dist/dom/controllable-open.feat.js +1 -1
  28. package/dist/dom/controllable-open.feat.mjs +1 -1
  29. package/dist/dom/controllable-select.feat.js +1 -1
  30. package/dist/dom/controllable-select.feat.mjs +1 -1
  31. package/dist/dom/controllable-textarea.feat.js +1 -1
  32. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  33. package/dist/dom/controllable.feat.js +1 -1
  34. package/dist/dom/controllable.feat.mjs +1 -1
  35. package/dist/dom/dynamic-tag-var.feat.js +3 -2
  36. package/dist/dom/dynamic-tag-var.feat.mjs +4 -3
  37. package/dist/dom/placeholder.feat.js +3 -3
  38. package/dist/dom/placeholder.feat.mjs +2 -2
  39. package/dist/dom/resume.d.ts +1 -2
  40. package/dist/{dom-BNmfm4st.js → dom-CzGPOsST.js} +62 -71
  41. package/dist/{dom-BsAS26Ze.mjs → dom-CzfddxCE.mjs} +15 -19
  42. package/dist/dom.d.ts +1 -1
  43. package/dist/dom.js +30 -30
  44. package/dist/dom.mjs +10 -10
  45. package/dist/html/template.d.ts +3 -1
  46. package/dist/html/writer.d.ts +6 -1
  47. package/dist/html.js +40 -25
  48. package/dist/html.mjs +40 -25
  49. package/dist/translator/core/await.d.ts +0 -7
  50. package/dist/translator/core/try.d.ts +0 -7
  51. package/dist/translator/index.d.ts +1 -1
  52. package/dist/translator/index.js +1888 -1656
  53. package/dist/translator/util/binding-has-prop.d.ts +1 -1
  54. package/dist/translator/util/cyclic-memo.d.ts +4 -0
  55. package/dist/translator/util/evaluate.d.ts +2 -0
  56. package/dist/translator/util/optional.d.ts +21 -7
  57. package/dist/translator/util/references.d.ts +53 -21
  58. package/dist/translator/util/runtime.d.ts +3 -1
  59. package/dist/translator/util/sections.d.ts +10 -11
  60. package/dist/translator/util/serialize-guard.d.ts +10 -0
  61. package/dist/translator/util/serialize-reasons.d.ts +10 -11
  62. package/dist/translator/util/set-tag-sections-downstream.d.ts +3 -2
  63. package/dist/translator/util/tag-name-type.d.ts +8 -3
  64. package/dist/translator/visitors/tag/dynamic-tag.d.ts +0 -2
  65. package/index.d.ts +0 -5
  66. package/package.json +3 -3
  67. package/tags-html.d.ts +2 -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, countResumeWrite($chunk.boundary), 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 = /['\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) => {
250
+ }, CLIENT_ALL = 715827882, 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) || {};
@@ -267,7 +267,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
267
267
  } else {
268
268
  let chunk = getChunk(), beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0, render = () => {
269
269
  if (renderer) try {
270
- return _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? 1 : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
270
+ return _set_serialize_reason(shouldResume && inputOrArgs !== void 0 ? CLIENT_ALL : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
271
271
  ...inputOrArgs,
272
272
  content
273
273
  } : inputOrArgs);
@@ -357,7 +357,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
357
357
  let scopeId = _peek_scope_id();
358
358
  writeScope(scopeId, { m5c: component.id }), _script(scopeId, SET_SCOPE_REGISTER_ID);
359
359
  }
360
- _set_serialize_reason(+!!willRerender);
360
+ _set_serialize_reason(willRerender ? CLIENT_ALL : 0);
361
361
  try {
362
362
  renderer(normalizedInput);
363
363
  } finally {
@@ -495,6 +495,7 @@ var State$1 = class {
495
495
  flushId;
496
496
  pos;
497
497
  id;
498
+ path = null;
498
499
  constructor(parent, accessor, flushId, pos = null, id = null) {
499
500
  this.parent = parent, this.accessor = accessor, this.flushId = flushId, this.pos = pos, this.id = id;
500
501
  }
@@ -628,7 +629,7 @@ function writeProp(state, val, parent, accessor) {
628
629
  }
629
630
  function writeReferenceOr(state, write, val, parent, accessor) {
630
631
  let ref = state.refs.get(val);
631
- 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;
632
+ 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) : (writeRef(state, ref), !0) : !1;
632
633
  let registered = REGISTRY.get(val);
633
634
  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));
634
635
  }
@@ -654,7 +655,7 @@ function writeString(state, val, parent, accessor) {
654
655
  if (val.length > 12) {
655
656
  let ref = state.strs.get(val);
656
657
  if (ref) {
657
- if (trackChannel(state, ref)) return state.buf.push(ensureId(state, ref)), !0;
658
+ if (trackChannel(state, ref)) return writeRef(state, ref), !0;
658
659
  } else {
659
660
  let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
660
661
  ref.channel = state.channel, state.strs.set(val, ref);
@@ -1133,6 +1134,9 @@ function quote(str, startPos) {
1133
1134
  }
1134
1135
  return "\"" + (lastPos === startPos ? str : result + str.slice(lastPos)) + "\"";
1135
1136
  }
1137
+ function writeRef(state, ref) {
1138
+ ref.id === null && ref.scopeId === void 0 && ref.path === null && (ref.pos === null || ref.flushId !== state.flushId) ? (ref.path = accessPath(state, ref), ref.pos = state.buf.length, ref.flushId = state.flushId, ref.channel = state.channel, state.buf.push(ref.path)) : state.buf.push(ensureId(state, ref));
1139
+ }
1136
1140
  function ensureId(state, ref) {
1137
1141
  return ref.scopeId === void 0 ? ref.id ? (trackChannel(state, ref), ref.id) : assignId(state, ref) : (trackChannel(state, ref), "_(" + ref.scopeId + ")");
1138
1142
  }
@@ -1142,23 +1146,18 @@ function accessId(state, ref) {
1142
1146
  }
1143
1147
  function assignId(state, ref) {
1144
1148
  let { pos } = ref;
1145
- 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;
1146
- ref.channel = state.channel;
1149
+ return ref.id = nextRefAccess(state), pos !== null && ref.flushId === state.flushId ? (pos === 0 ? state.buf[0] = ref.id + "=" + state.buf[0] : state.buf[pos - 1] += ref.id + "=", ref.id) : (ref.channel = state.channel, ref.id + "=" + (ref.path || accessPath(state, ref)));
1150
+ }
1151
+ function accessPath(state, ref) {
1147
1152
  let cur = ref, accessPrevValue = "";
1148
1153
  do {
1149
1154
  accessPrevValue = toAccess(cur.accessor) + accessPrevValue;
1150
1155
  let parent = cur.parent;
1151
- if (parent.id && (trackChannel(state, parent) || !parent.parent)) {
1152
- accessPrevValue = parent.id + accessPrevValue;
1153
- break;
1154
- }
1155
- if (parent.flushId === state.flushId || parent.scopeId !== void 0) {
1156
- accessPrevValue = accessId(state, parent) + accessPrevValue;
1157
- break;
1158
- }
1156
+ if (parent.id && (trackChannel(state, parent) || !parent.parent)) return parent.id + accessPrevValue;
1157
+ if (parent.flushId === state.flushId || parent.scopeId !== void 0) return accessId(state, parent) + accessPrevValue;
1159
1158
  cur = parent;
1160
1159
  } while (cur);
1161
- return ref.id + "=" + accessPrevValue;
1160
+ return accessPrevValue;
1162
1161
  }
1163
1162
  function assignmentsToString(assignments, value) {
1164
1163
  return assignments.length > 100 ? "($=>(" + assignments.join("=$,") + "=$))(" + value + ")" : assignments.join("=") + "=" + value;
@@ -1478,6 +1477,9 @@ function _subscribe(subscribers, scope) {
1478
1477
  }
1479
1478
  return scope;
1480
1479
  }
1480
+ function maskGroup(mask, group) {
1481
+ return mask === 715827882 ? 1 : typeof mask == "number" ? mask >>> 1 + 2 * group & 3 : mask[group] ?? 0;
1482
+ }
1481
1483
  function _set_serialize_reason(reason) {
1482
1484
  $chunk.boundary.state.serializeReason = reason;
1483
1485
  }
@@ -1486,7 +1488,7 @@ function _scope_reason() {
1486
1488
  return $chunk.boundary.state.serializeReason = void 0, reason;
1487
1489
  }
1488
1490
  function _serialize_if(condition, key) {
1489
- return condition && (condition === 1 || (typeof condition == "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
1491
+ return condition && maskGroup(condition, key) ? 1 : void 0;
1490
1492
  }
1491
1493
  function _serialize_guard(condition, key) {
1492
1494
  return _serialize_if(condition, key) || 0;
@@ -1605,6 +1607,16 @@ var State = class {
1605
1607
  constructor($global) {
1606
1608
  this.$global = $global, $global.cspNonce && (this.nonceAttr = " nonce" + attrAssignment($global.cspNonce));
1607
1609
  }
1610
+ flushChunk(html, scripts, pending) {
1611
+ let { $global, nonceAttr } = this, { __flush__ } = $global;
1612
+ return scripts && (html += "<script" + nonceAttr + ">" + scripts + "<\/script>"), __flush__ && ($global.__flush__ = void 0, html = __flush__($global, html)), pending ? html : html + this.trailerHTML;
1613
+ }
1614
+ walkScript() {
1615
+ return this.runtimePrefix + ".w()";
1616
+ }
1617
+ resumeScript(resumes) {
1618
+ return this.hasWrittenResume ? this.runtimePrefix + ".r.push(" + resumes + ")" : (this.hasWrittenResume = !0, this.runtimePrefix + ".r=[" + resumes + "]");
1619
+ }
1608
1620
  get runtimePrefix() {
1609
1621
  let { $global } = this;
1610
1622
  return $global.runtimeId + "." + $global.renderId;
@@ -1684,7 +1696,7 @@ var State = class {
1684
1696
  this.scripts = concatScripts(this.scripts, script);
1685
1697
  }
1686
1698
  append(chunk) {
1687
- this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts), this.lastEffect = chunk.lastEffect || this.lastEffect, this.deferredReady = concat(this.deferredReady, chunk.takeDeferredReady());
1699
+ this.html += chunk.html, this.needsWalk ||= chunk.needsWalk, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts), this.lastEffect = chunk.lastEffect || this.lastEffect, this.deferredReady = concat(this.deferredReady, chunk.takeDeferredReady());
1688
1700
  }
1689
1701
  takeDeferredReady() {
1690
1702
  let { deferredReady } = this;
@@ -1783,13 +1795,13 @@ var State = class {
1783
1795
  }
1784
1796
  state.writeReorders = carried;
1785
1797
  }
1786
- return flushSerializer(boundary, state), state.resumes ? state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]")) : needsResumeArray && !state.hasWrittenResume && (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[]")), scripts = concatScripts(scripts, reordered), needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
1798
+ return flushSerializer(boundary, state), (state.resumes || needsResumeArray && !state.hasWrittenResume) && (scripts = concatScripts(scripts, state.resumeScript(state.resumes))), scripts = concatScripts(scripts, reordered), needsWalk && (scripts = concatScripts(scripts, state.walkScript())), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
1787
1799
  }
1788
1800
  flushHTML() {
1789
1801
  let { boundary } = this, { state } = boundary;
1790
1802
  this.needsWalk && (this.needsWalk = !1, state.walkOnNextFlush = !0), this.flushScript();
1791
- let { scripts } = this, { $global, nonceAttr } = state, { __flush__ } = $global, { html } = this;
1792
- return this.html = this.scripts = "", scripts && (html += "<script" + nonceAttr + ">" + scripts + "<\/script>"), __flush__ && ($global.__flush__ = void 0, html = __flush__($global, html)), boundary.count || (html += state.trailerHTML), html;
1803
+ let { html, scripts } = this;
1804
+ return this.html = this.scripts = "", state.flushChunk(html, scripts, boundary.count);
1793
1805
  }
1794
1806
  };
1795
1807
  function flushSerializer(boundary, serializeState) {
@@ -2043,17 +2055,20 @@ function _content_resume(id, fn, scopeId) {
2043
2055
  //#endregion
2044
2056
  //#region src/html/template.ts
2045
2057
  function render(input = {}) {
2058
+ return startRender(this, input, State);
2059
+ }
2060
+ function startRender(template, input, StateClass) {
2046
2061
  let { $global } = input;
2047
2062
  $global ? ({$global, ...input} = input, $global = {
2048
2063
  runtimeId: "M",
2049
- renderId: getDefaultRenderId(this),
2064
+ renderId: getDefaultRenderId(template),
2050
2065
  ...$global
2051
2066
  }) : $global = {
2052
2067
  runtimeId: "M",
2053
- renderId: getDefaultRenderId(this)
2068
+ renderId: getDefaultRenderId(template)
2054
2069
  };
2055
- let state = new State($global), head = new Chunk(new Boundary(state, $global.signal), null, null, state);
2056
- return this.i ? head.render(() => writeWaitReady(this.a, this, input)) : head.render(this, input), new ServerRendered(head);
2070
+ let state = new StateClass($global), head = new Chunk(new Boundary(state, $global.signal), null, null, state);
2071
+ return template.i ? head.render(() => writeWaitReady(template.a, template, input)) : head.render(template, input), new ServerRendered(head);
2057
2072
  }
2058
2073
  function getDefaultRenderId(template) {
2059
2074
  if (template.i) {
@@ -1,10 +1,3 @@
1
1
  import { type Tag } from "@marko/compiler/babel-utils";
2
- import { type Binding } from "../util/references";
3
- declare const kDOMBinding: unique symbol;
4
- declare module "@marko/compiler/dist/types" {
5
- interface MarkoTagExtra {
6
- [kDOMBinding]?: Binding;
7
- }
8
- }
9
2
  declare const _default: Tag;
10
3
  export default _default;
@@ -1,10 +1,3 @@
1
1
  import { type Tag } from "@marko/compiler/babel-utils";
2
- import { type Binding } from "../util/references";
3
- declare const kDOMBinding: unique symbol;
4
- declare module "@marko/compiler/dist/types" {
5
- interface MarkoTagExtra {
6
- [kDOMBinding]?: Binding;
7
- }
8
- }
9
2
  declare const _default: Tag;
10
3
  export default _default;
@@ -129,7 +129,7 @@ declare module "@marko/compiler/dist/types" {
129
129
  }
130
130
  interface ArrowFunctionExpressionExtra {
131
131
  }
132
- interface MarkoTagExtra {
132
+ interface MarkoTagExtra extends NodeExtra {
133
133
  }
134
134
  interface MarkoTagBodyExtra {
135
135
  }