marko 6.3.33 → 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.
Files changed (59) hide show
  1. package/cheatsheet.md +37 -33
  2. package/dist/common/errors.d.ts +1 -0
  3. package/dist/debug/dom/catch.feat.js +1 -1
  4. package/dist/debug/dom/catch.feat.mjs +1 -1
  5. package/dist/debug/dom/controllable-input.feat.js +1 -1
  6. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  7. package/dist/debug/dom/controllable-open.feat.js +1 -1
  8. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  9. package/dist/debug/dom/controllable-select.feat.js +1 -1
  10. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  11. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  12. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  13. package/dist/debug/dom/controllable.feat.js +1 -1
  14. package/dist/debug/dom/controllable.feat.mjs +1 -1
  15. package/dist/debug/{dom-CiFITSPN.js → dom-Bj58jt8y.js} +55 -30
  16. package/dist/debug/{dom-BJ93mcSe.mjs → dom-klf8Ec_o.mjs} +55 -30
  17. package/dist/debug/dom.js +3 -1
  18. package/dist/debug/dom.mjs +3 -1
  19. package/dist/debug/html.js +119 -79
  20. package/dist/debug/html.mjs +119 -79
  21. package/dist/dom/catch.feat.js +1 -1
  22. package/dist/dom/catch.feat.mjs +1 -1
  23. package/dist/dom/control-flow.d.ts +3 -1
  24. package/dist/dom/controllable-input.feat.js +1 -1
  25. package/dist/dom/controllable-input.feat.mjs +1 -1
  26. package/dist/dom/controllable-open.feat.js +1 -1
  27. package/dist/dom/controllable-open.feat.mjs +1 -1
  28. package/dist/dom/controllable-select.feat.js +1 -1
  29. package/dist/dom/controllable-select.feat.mjs +1 -1
  30. package/dist/dom/controllable-textarea.feat.js +1 -1
  31. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  32. package/dist/dom/controllable.feat.js +1 -1
  33. package/dist/dom/controllable.feat.mjs +1 -1
  34. package/dist/{dom-Cj4HQ7T_.mjs → dom-6hBvZW7X.mjs} +27 -21
  35. package/dist/{dom-CI-06TZb.js → dom-B-XpL2_H.js} +27 -21
  36. package/dist/dom.js +3 -1
  37. package/dist/dom.mjs +3 -1
  38. package/dist/html/compat.d.ts +4 -2
  39. package/dist/html.js +73 -54
  40. package/dist/html.mjs +73 -54
  41. package/dist/translator/core/client.d.ts +1 -2
  42. package/dist/translator/core/server.d.ts +1 -2
  43. package/dist/translator/core/static.d.ts +1 -2
  44. package/dist/translator/index.js +377 -244
  45. package/dist/translator/util/constants/binding-type.d.ts +1 -0
  46. package/dist/translator/util/references.d.ts +8 -1
  47. package/dist/translator/util/serialize-reasons.d.ts +4 -4
  48. package/dist/translator/util/signals.d.ts +3 -0
  49. package/dist/translator/util/statement-tag.d.ts +2 -0
  50. package/dist/translator/visitors/program/index.d.ts +0 -1
  51. package/package.json +5 -4
  52. package/tags/html-comment.d.marko +2 -0
  53. package/tags/html-script.d.marko +2 -0
  54. package/tags/html-style.d.marko +2 -0
  55. package/tags/let.d.marko +2 -2
  56. package/tags/show.d.marko +6 -0
  57. package/tags/try.d.marko +1 -1
  58. package/tags-html.d.ts +6 -1
  59. /package/dist/translator/util/{get-accessor-char.d.ts → get-accessor-enums.d.ts} +0 -0
@@ -8,7 +8,7 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
8
8
  for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
9
9
  }), runRender = (render) => {
10
10
  (!branchesEnabled || render.b.F?.H !== 0) && render.c(render.b, render.d);
11
- }, catchEnabled, delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, !0), 1), parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
11
+ }, catchEnabled, delegate = (type, handler) => handler[1 + type] ||= (document.addEventListener(type, handler, !0), 1), parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
12
12
  scope.H = 0, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(cleanupScope);
13
13
  }, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), currentNode, walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
14
14
  let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
@@ -26,7 +26,7 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
26
26
  if (currentNode.firstChild) return currentNode = currentNode.firstChild;
27
27
  for (; !currentNode.nextSibling && currentNode.parentNode;) currentNode = currentNode.parentNode;
28
28
  walkNextSibling();
29
- }, walkNextSibling = () => currentNode = currentNode.nextSibling || currentNode, registeredValues = {}, curRenders, embedRenders, readyIds, isResuming, cloneCache = {}, R = /[^\p{L}\p{N}]/gu, inputType = "", controllableScripts = {}, controllableRenders = {}, _if = /*@__PURE__*/ withBranches((nodeAccessor, ...branchesArgs) => {
29
+ }, walkNextSibling = () => currentNode = currentNode.nextSibling || currentNode, registeredValues = {}, curRenders, embedRenders, readyIds, isResuming, cloneCache = {}, R = /[\p{L}\p{N}]/gu, inputType = "", controllableScripts = {}, controllableRenders = {}, _if = /*@__PURE__*/ withBranches((nodeAccessor, ...branchesArgs) => {
30
30
  nodeAccessor = decodeAccessor(nodeAccessor);
31
31
  let branchAccessor = "D" + nodeAccessor, branches = [], i = 0;
32
32
  for (; i < branchesArgs.length;) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
@@ -80,7 +80,7 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
80
80
  return (scope, renderer) => {
81
81
  if (scope[rendererAccessor] !== (scope[rendererAccessor] = renderer?.a || renderer) && (setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch), renderer?.f && subscribeToScopeSet(renderer.e, renderer.f, scope[childScopeAccessor])), renderer) for (let accessor in renderer.g) renderer.g[accessor](scope[childScopeAccessor], renderer.h[accessor]);
82
82
  };
83
- }), loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
83
+ }), _resume_dynamic_tag = /*@__PURE__*/ withBranches(() => _resume("d", dynamicTagScript)), loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
84
84
  nodeAccessor = decodeAccessor(nodeAccessor);
85
85
  let scopesAccessor = "A" + nodeAccessor, keyedScopesAccessor = "O" + nodeAccessor, renderer = _content("", template, walks, setup)();
86
86
  return (scope, value) => {
@@ -114,9 +114,15 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
114
114
  for (hi = tails[tail], lo = tail + 1; lo-- > 0;) tails[lo] = hi, hi = pred[hi];
115
115
  for (let i = diffLen; i--;) ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
116
116
  };
117
- }), _for_of = /*@__PURE__*/ loop(([all, by = bySecondArg], cb) => {
118
- typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
119
- }), _for_in = /*@__PURE__*/ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /*@__PURE__*/ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /*@__PURE__*/ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v])));
117
+ }), _for_of = /*@__PURE__*/ loop(([all, by], cb) => {
118
+ by ||= bySecondArg, typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
119
+ }), _for_in = /*@__PURE__*/ loop(([obj, by], cb) => {
120
+ by ||= byFirstArg, forIn(obj, (key, value) => cb(by(key, value), [key, value]));
121
+ }), _for_to = /*@__PURE__*/ loop(([to, from, step, by], cb) => {
122
+ by ||= byFirstArg, forTo(to, from, step, (v) => cb(by(v), [v]));
123
+ }), _for_until = /*@__PURE__*/ loop(([until, from, step, by], cb) => {
124
+ by ||= byFirstArg, forUntil(until, from, step, (v) => cb(by(v), [v]));
125
+ });
120
126
  //#region src/common/helpers.ts
121
127
  function _call(fn, v) {
122
128
  return fn(v), v;
@@ -277,11 +283,11 @@ function push(opt, item) {
277
283
  //#endregion
278
284
  //#region src/dom/event.ts
279
285
  function _on(element, type, handler) {
280
- element["$" + type] === void 0 && delegate(type, handleDelegated), element["$" + type] = handler || null;
286
+ element[1 + type] === void 0 && delegate(type, handleDelegated), element[1 + type] = handler || null;
281
287
  }
282
288
  function handleDelegated(ev) {
283
289
  let target = !rendering && ev.target;
284
- for (; target;) target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
290
+ for (; target;) target[1 + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
285
291
  }
286
292
  //#endregion
287
293
  //#region src/dom/parse-html.ts
@@ -454,7 +460,7 @@ function _var(scope, childAccessor, signal) {
454
460
  scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
455
461
  }
456
462
  function _return_change(scope, changeHandler) {
457
- changeHandler && (scope.U = changeHandler);
463
+ scope.U = changeHandler || void 0;
458
464
  }
459
465
  function _id({ $: $global }) {
460
466
  let id = tagIdsByGlobal.get($global) || 0;
@@ -619,7 +625,7 @@ function setupBranch(renderer, branch) {
619
625
  function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
620
626
  walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
621
627
  let clone = template ? (branch, ns) => {
622
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
628
+ ((cloneCache[ns] ||= {})[1 + template] ||= createCloneableHTML(template, ns))(branch, walks);
623
629
  } : (branch) => {
624
630
  walk(branch.S = branch.K = new Text(), walks, branch);
625
631
  };
@@ -718,7 +724,7 @@ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
718
724
  let el = scope[nodeAccessor], partial = {};
719
725
  for (let i = el.attributes.length; i--;) {
720
726
  let { name } = el.attributes.item(i);
721
- !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
727
+ !skip[name] && !(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs))) && el.removeAttribute(name);
722
728
  }
723
729
  for (let name in nextAttrs) {
724
730
  let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
@@ -801,9 +807,9 @@ function resolveCursorPosition(inputType, initialPosition, initialValue, updated
801
807
  let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
802
808
  if (updatedValue.startsWith(before)) return initialPosition;
803
809
  if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
804
- let count = before.replace(R, "").length, pos = 0;
805
- for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
806
- return pos;
810
+ let count = before.match(R)?.length;
811
+ for (; count && R.test(updatedValue);) count--;
812
+ return count ? updatedValue.length : R.lastIndex;
807
813
  }
808
814
  return -1;
809
815
  }
@@ -1027,9 +1033,9 @@ function _await_promise(nodeAccessor, params) {
1027
1033
  detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
1028
1034
  }
1029
1035
  } else dismissPlaceholder(tryBranch);
1030
- })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1036
+ })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : scheduleAwaitFrame(awaitCounter, scope, () => {
1031
1037
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
1032
- }, -1)))));
1038
+ }));
1033
1039
  let thisPromise = scope[promiseAccessor] = promise.then((data) => {
1034
1040
  if (thisPromise === scope[promiseAccessor]) {
1035
1041
  let referenceNode = scope[nodeAccessor];
@@ -1072,9 +1078,12 @@ function _await_content(nodeAccessor, template, walks, setup) {
1072
1078
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
1073
1079
  if (!tryBranch) return;
1074
1080
  let awaitCounter = tryBranch.O;
1075
- return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), placeholderShown.add(pendingEffects), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1081
+ return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), placeholderShown.add(pendingEffects), scheduleAwaitFrame(awaitCounter, tryBranch, () => {
1076
1082
  insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1077
- }, -1)))), awaitCounter;
1083
+ }), awaitCounter;
1084
+ }
1085
+ function scheduleAwaitFrame(awaitCounter, scope, render) {
1086
+ awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, render, -1))));
1078
1087
  }
1079
1088
  function createAwaitCounter(tryBranch, done) {
1080
1089
  let awaitCounter = tryBranch.O = {
@@ -1113,9 +1122,6 @@ function renderCatch(scope, error) {
1113
1122
  function patchDynamicTag(fn) {
1114
1123
  _dynamic_tag = fn(_dynamic_tag);
1115
1124
  }
1116
- function _resume_dynamic_tag() {
1117
- _resume("d", dynamicTagScript);
1118
- }
1119
1125
  function dynamicTagScript(branch) {
1120
1126
  _attrs_script(branch, "a");
1121
1127
  }
@@ -8,7 +8,7 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
8
8
  for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
9
9
  }), runRender = (render) => {
10
10
  (!branchesEnabled || render.b.F?.H !== 0) && render.c(render.b, render.d);
11
- }, catchEnabled, delegate = (type, handler) => handler[type] ||= (document.addEventListener(type, handler, !0), 1), parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
11
+ }, catchEnabled, delegate = (type, handler) => handler[1 + type] ||= (document.addEventListener(type, handler, !0), 1), parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
12
12
  scope.H = 0, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(cleanupScope);
13
13
  }, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), currentNode, walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
14
14
  let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
@@ -26,7 +26,7 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
26
26
  if (currentNode.firstChild) return currentNode = currentNode.firstChild;
27
27
  for (; !currentNode.nextSibling && currentNode.parentNode;) currentNode = currentNode.parentNode;
28
28
  walkNextSibling();
29
- }, walkNextSibling = () => currentNode = currentNode.nextSibling || currentNode, registeredValues = {}, curRenders, embedRenders, readyIds, isResuming, cloneCache = {}, R = /[^\p{L}\p{N}]/gu, inputType = "", controllableScripts = {}, controllableRenders = {}, _if = /*@__PURE__*/ withBranches((nodeAccessor, ...branchesArgs) => {
29
+ }, walkNextSibling = () => currentNode = currentNode.nextSibling || currentNode, registeredValues = {}, curRenders, embedRenders, readyIds, isResuming, cloneCache = {}, R = /[\p{L}\p{N}]/gu, inputType = "", controllableScripts = {}, controllableRenders = {}, _if = /*@__PURE__*/ withBranches((nodeAccessor, ...branchesArgs) => {
30
30
  nodeAccessor = decodeAccessor(nodeAccessor);
31
31
  let branchAccessor = "D" + nodeAccessor, branches = [], i = 0;
32
32
  for (; i < branchesArgs.length;) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
@@ -80,7 +80,7 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
80
80
  return (scope, renderer) => {
81
81
  if (scope[rendererAccessor] !== (scope[rendererAccessor] = renderer?.a || renderer) && (setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch), renderer?.f && subscribeToScopeSet(renderer.e, renderer.f, scope[childScopeAccessor])), renderer) for (let accessor in renderer.g) renderer.g[accessor](scope[childScopeAccessor], renderer.h[accessor]);
82
82
  };
83
- }), loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
83
+ }), _resume_dynamic_tag = /*@__PURE__*/ withBranches(() => _resume("d", dynamicTagScript)), loop = /*@__PURE__*/ withBranches((forEach) => (nodeAccessor, template, walks, setup, params) => {
84
84
  nodeAccessor = decodeAccessor(nodeAccessor);
85
85
  let scopesAccessor = "A" + nodeAccessor, keyedScopesAccessor = "O" + nodeAccessor, renderer = _content("", template, walks, setup)();
86
86
  return (scope, value) => {
@@ -114,9 +114,15 @@ let unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeStyleAttr = (c) => c === ";" ? "
114
114
  for (hi = tails[tail], lo = tail + 1; lo-- > 0;) tails[lo] = hi, hi = pred[hi];
115
115
  for (let i = diffLen; i--;) ~tail && i === tails[tail] ? tail-- : insertBranchBefore(newScopes[start + i], parentNode, afterReference), afterReference = newScopes[start + i].S;
116
116
  };
117
- }), _for_of = /*@__PURE__*/ loop(([all, by = bySecondArg], cb) => {
118
- typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
119
- }), _for_in = /*@__PURE__*/ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /*@__PURE__*/ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /*@__PURE__*/ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v])));
117
+ }), _for_of = /*@__PURE__*/ loop(([all, by], cb) => {
118
+ by ||= bySecondArg, typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
119
+ }), _for_in = /*@__PURE__*/ loop(([obj, by], cb) => {
120
+ by ||= byFirstArg, forIn(obj, (key, value) => cb(by(key, value), [key, value]));
121
+ }), _for_to = /*@__PURE__*/ loop(([to, from, step, by], cb) => {
122
+ by ||= byFirstArg, forTo(to, from, step, (v) => cb(by(v), [v]));
123
+ }), _for_until = /*@__PURE__*/ loop(([until, from, step, by], cb) => {
124
+ by ||= byFirstArg, forUntil(until, from, step, (v) => cb(by(v), [v]));
125
+ });
120
126
  //#region src/common/helpers.ts
121
127
  function _call(fn, v) {
122
128
  return fn(v), v;
@@ -277,11 +283,11 @@ function push(opt, item) {
277
283
  //#endregion
278
284
  //#region src/dom/event.ts
279
285
  function _on(element, type, handler) {
280
- element["$" + type] === void 0 && delegate(type, handleDelegated), element["$" + type] = handler || null;
286
+ element[1 + type] === void 0 && delegate(type, handleDelegated), element[1 + type] = handler || null;
281
287
  }
282
288
  function handleDelegated(ev) {
283
289
  let target = !rendering && ev.target;
284
- for (; target;) target["$" + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
290
+ for (; target;) target[1 + ev.type]?.(ev, target), target = ev.bubbles && !ev.cancelBubble && target.parentNode;
285
291
  }
286
292
  //#endregion
287
293
  //#region src/dom/parse-html.ts
@@ -454,7 +460,7 @@ function _var(scope, childAccessor, signal) {
454
460
  scope[decodeAccessor(childAccessor)].T = (value) => signal(scope, value);
455
461
  }
456
462
  function _return_change(scope, changeHandler) {
457
- changeHandler && (scope.U = changeHandler);
463
+ scope.U = changeHandler || void 0;
458
464
  }
459
465
  function _id({ $: $global }) {
460
466
  let id = tagIdsByGlobal.get($global) || 0;
@@ -619,7 +625,7 @@ function setupBranch(renderer, branch) {
619
625
  function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
620
626
  walks = walks ? walks.replace(/[^\0-1]+$/, "") : "", setup = setup ? setup._ || setup : void 0, params ||= void 0;
621
627
  let clone = template ? (branch, ns) => {
622
- ((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
628
+ ((cloneCache[ns] ||= {})[1 + template] ||= createCloneableHTML(template, ns))(branch, walks);
623
629
  } : (branch) => {
624
630
  walk(branch.S = branch.K = new Text(), walks, branch);
625
631
  };
@@ -718,7 +724,7 @@ function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
718
724
  let el = scope[nodeAccessor], partial = {};
719
725
  for (let i = el.attributes.length; i--;) {
720
726
  let { name } = el.attributes.item(i);
721
- !skip[name] && !(nextAttrs && name in nextAttrs) && el.removeAttribute(name);
727
+ !skip[name] && !(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs))) && el.removeAttribute(name);
722
728
  }
723
729
  for (let name in nextAttrs) {
724
730
  let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
@@ -801,9 +807,9 @@ function resolveCursorPosition(inputType, initialPosition, initialValue, updated
801
807
  let before = initialValue.slice(0, initialPosition), after = initialValue.slice(initialPosition);
802
808
  if (updatedValue.startsWith(before)) return initialPosition;
803
809
  if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
804
- let count = before.replace(R, "").length, pos = 0;
805
- for (; count && updatedValue[pos];) updatedValue[pos++].replace(R, "") && count--;
806
- return pos;
810
+ let count = before.match(R)?.length;
811
+ for (; count && R.test(updatedValue);) count--;
812
+ return count ? updatedValue.length : R.lastIndex;
807
813
  }
808
814
  return -1;
809
815
  }
@@ -1027,9 +1033,9 @@ function _await_promise(nodeAccessor, params) {
1027
1033
  detachedParent === anchor.parentNode ? anchor.remove() : anchor.replaceWith(detachedParent);
1028
1034
  }
1029
1035
  } else dismissPlaceholder(tryBranch);
1030
- })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
1036
+ })), scope[promiseAccessor] || (awaitBranch && (awaitBranch.W ||= []), tryPlaceholder ? awaitCounter = addAwaitCounter(scope, tryPlaceholder) : scheduleAwaitFrame(awaitCounter, scope, () => {
1031
1037
  awaitBranch.V || (awaitBranch.S.parentNode.insertBefore(scope[nodeAccessor], awaitBranch.S), tempDetachBranch(tryBranch));
1032
- }, -1)))));
1038
+ }));
1033
1039
  let thisPromise = scope[promiseAccessor] = promise.then((data) => {
1034
1040
  if (thisPromise === scope[promiseAccessor]) {
1035
1041
  let referenceNode = scope[nodeAccessor];
@@ -1072,9 +1078,12 @@ function _await_content(nodeAccessor, template, walks, setup) {
1072
1078
  function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
1073
1079
  if (!tryBranch) return;
1074
1080
  let awaitCounter = tryBranch.O;
1075
- return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), placeholderShown.add(pendingEffects), awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(tryBranch, () => {
1081
+ return awaitCounter?.i || (awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch))), placeholderShown.add(pendingEffects), scheduleAwaitFrame(awaitCounter, tryBranch, () => {
1076
1082
  insertBranchBefore(tryBranch.P = createAndSetupBranch(tryBranch.$, tryBranch.Q, tryBranch._, tryBranch.S.parentNode), tryBranch.S.parentNode, tryBranch.S), tempDetachBranch(tryBranch);
1077
- }, -1)))), awaitCounter;
1083
+ }), awaitCounter;
1084
+ }
1085
+ function scheduleAwaitFrame(awaitCounter, scope, render) {
1086
+ awaitCounter.i++ || requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, render, -1))));
1078
1087
  }
1079
1088
  function createAwaitCounter(tryBranch, done) {
1080
1089
  let awaitCounter = tryBranch.O = {
@@ -1113,9 +1122,6 @@ function renderCatch(scope, error) {
1113
1122
  function patchDynamicTag(fn) {
1114
1123
  _dynamic_tag = fn(_dynamic_tag);
1115
1124
  }
1116
- function _resume_dynamic_tag() {
1117
- _resume("d", dynamicTagScript);
1118
- }
1119
1125
  function dynamicTagScript(branch) {
1120
1126
  _attrs_script(branch, "a");
1121
1127
  }
package/dist/dom.js CHANGED
@@ -1,4 +1,5 @@
1
- let require_control_flow = require("./dom-CI-06TZb.js"), empty = [], rest = Symbol(), classIdToBranch = /* @__PURE__ */ new Map(), classEventResolver, scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
1
+ let require_control_flow = require("./dom-B-XpL2_H.js"), empty = [], rest = Symbol(), classIdToBranch = /* @__PURE__ */ new Map(), classEventResolver, scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
2
+ require_control_flow.vt($global.runtimeId);
2
3
  let render = self[$global.runtimeId]?.[$global.renderId], scopes = render && scopesByRender.get(render);
3
4
  return render && !scopes && scopesByRender.set(render, scopes = {}), scopes;
4
5
  }, compat = {
@@ -50,6 +51,7 @@ let require_control_flow = require("./dom-CI-06TZb.js"), empty = [], rest = Symb
50
51
  }, renderer;
51
52
  },
52
53
  render(out, component, renderer, args) {
54
+ require_control_flow.vt(out.global.runtimeId);
53
55
  let branch = component.scope, created = 0;
54
56
  if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), args[0] && typeof args[0] == "object" && "renderBody" in args[0]) {
55
57
  let input = args[0], normalizedInput = args[0] = {};
package/dist/dom.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  let empty = [], rest = Symbol(), classIdToBranch = /* @__PURE__ */ new Map(), classEventResolver, scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
2
+ init($global.runtimeId);
2
3
  let render = self[$global.runtimeId]?.[$global.renderId], scopes = render && scopesByRender.get(render);
3
4
  return render && !scopes && scopesByRender.set(render, scopes = {}), scopes;
4
5
  }, compat = {
@@ -50,6 +51,7 @@ let empty = [], rest = Symbol(), classIdToBranch = /* @__PURE__ */ new Map(), cl
50
51
  }, renderer;
51
52
  },
52
53
  render(out, component, renderer, args) {
54
+ init(out.global.runtimeId);
53
55
  let branch = component.scope, created = 0;
54
56
  if (!branch && (branch = classIdToBranch.get(component.id)) && (component.scope = branch, classIdToBranch.delete(component.id)), args[0] && typeof args[0] == "object" && "renderBody" in args[0]) {
55
57
  let input = args[0], normalizedInput = args[0] = {};
@@ -63,7 +65,7 @@ let empty = [], rest = Symbol(), classIdToBranch = /* @__PURE__ */ new Map(), cl
63
65
  let renderer = _content(id, template, walks, setup, inputSignal)();
64
66
  return renderer.mount = mount, renderer._ = renderer, _resume(id, renderer);
65
67
  };
66
- import { $ as _html, $t as queueEffect, A as _attr_select_value, At as _id, B as _attr_class, Bt as _assert_init, C as _attr_input_checked_default, Ct as _closure_get, D as _attr_input_value_default, Dt as _for_selector, E as _attr_input_value_attribute_default, Et as _for_closure, F as _controllable_select, Ft as _return, G as _attr_style, Gt as _on, H as _attr_class_items, Ht as insertBranchBefore, I as _controllable_textarea, It as _return_change, J as _attrs, K as _attr_style_item, Kt as $signal, Lt as _script, M as _attr_select_value_script, Mt as _let, N as _controllable_input, Nt as _let_change, O as _attr_input_value_dynamic_default, Ot as _hoist, P as _controllable_open, Pt as _or, Q as _attrs_script, Qt as queueAsyncRender, Rt as _var, S as _attr_input_checkedValue_script, St as _closure, T as _attr_input_value, Tt as _el_read, U as _attr_content, Ut as removeAndDestroyBranch, V as _attr_class_item, Vt as destroyBranch, W as _attr_nonce, Wt as syncGen, X as _attrs_partial, Y as _attrs_content, Z as _attrs_partial_content, Zt as prepareEffects, _ as _attr_details_or_dialog_open_default, _t as getRegisteredWithScope, a as _for_in, an as forTo, at as _to_text, b as _attr_input_checkedValue, bt as ready, c as _for_until, cn as _call, ct as _content, d as _show, dt as createAndSetupBranch, en as run, et as _lifecycle, f as _try, ft as createBranch, g as _attr_details_or_dialog_open, gt as _var_resume, h as renderCatch, ht as _resume, i as _dynamic_tag_content, in as forOf, it as _text_content, j as _attr_select_value_default, jt as _if_closure, k as _attr_input_value_script, kt as _hoist_resume, l as _if, ln as decodeAccessor, lt as _content_closures, m as patchDynamicTag, mt as _el, n as _await_promise, nn as runId, nt as _style_shell, o as _for_of, on as forUntil, ot as insertChildNodes, p as addAwaitCounter, pt as setupBranch, q as _attr_style_items, qt as $signalReset, r as _dynamic_tag, rn as forIn, rt as _text, s as _for_to, sn as _assert_hoist, st as toInsertNode, t as _await_content, tn as runEffects, tt as _style_rule_item, u as _resume_dynamic_tag, ut as _content_resume, v as _attr_details_or_dialog_open_script, vt as init, w as _attr_input_checked_script, wt as _const, x as _attr_input_checkedValue_default, xt as _child_setup, y as _attr_input_checked, yt as initEmbedded, z as _attr, zt as _var_change } from "./dom-Cj4HQ7T_.mjs";
68
+ import { $ as _html, $t as queueEffect, A as _attr_select_value, At as _id, B as _attr_class, Bt as _assert_init, C as _attr_input_checked_default, Ct as _closure_get, D as _attr_input_value_default, Dt as _for_selector, E as _attr_input_value_attribute_default, Et as _for_closure, F as _controllable_select, Ft as _return, G as _attr_style, Gt as _on, H as _attr_class_items, Ht as insertBranchBefore, I as _controllable_textarea, It as _return_change, J as _attrs, K as _attr_style_item, Kt as $signal, Lt as _script, M as _attr_select_value_script, Mt as _let, N as _controllable_input, Nt as _let_change, O as _attr_input_value_dynamic_default, Ot as _hoist, P as _controllable_open, Pt as _or, Q as _attrs_script, Qt as queueAsyncRender, Rt as _var, S as _attr_input_checkedValue_script, St as _closure, T as _attr_input_value, Tt as _el_read, U as _attr_content, Ut as removeAndDestroyBranch, V as _attr_class_item, Vt as destroyBranch, W as _attr_nonce, Wt as syncGen, X as _attrs_partial, Y as _attrs_content, Z as _attrs_partial_content, Zt as prepareEffects, _ as _attr_details_or_dialog_open_default, _t as getRegisteredWithScope, a as _for_in, an as forTo, at as _to_text, b as _attr_input_checkedValue, bt as ready, c as _for_until, cn as _call, ct as _content, d as _show, dt as createAndSetupBranch, en as run, et as _lifecycle, f as _try, ft as createBranch, g as _attr_details_or_dialog_open, gt as _var_resume, h as renderCatch, ht as _resume, i as _dynamic_tag_content, in as forOf, it as _text_content, j as _attr_select_value_default, jt as _if_closure, k as _attr_input_value_script, kt as _hoist_resume, l as _if, ln as decodeAccessor, lt as _content_closures, m as patchDynamicTag, mt as _el, n as _await_promise, nn as runId, nt as _style_shell, o as _for_of, on as forUntil, ot as insertChildNodes, p as addAwaitCounter, pt as setupBranch, q as _attr_style_items, qt as $signalReset, r as _dynamic_tag, rn as forIn, rt as _text, s as _for_to, sn as _assert_hoist, st as toInsertNode, t as _await_content, tn as runEffects, tt as _style_rule_item, u as _resume_dynamic_tag, ut as _content_resume, v as _attr_details_or_dialog_open_script, vt as init, w as _attr_input_checked_script, wt as _const, x as _attr_input_checkedValue_default, xt as _child_setup, y as _attr_input_checked, yt as initEmbedded, z as _attr, zt as _var_change } from "./dom-6hBvZW7X.mjs";
67
69
  //#region src/common/attr-tag.ts
68
70
  function attrTag(attrs) {
69
71
  return attrs[Symbol.iterator] = attrTagIterator, attrs[rest] = empty, attrs;
@@ -1,6 +1,6 @@
1
1
  import { register } from "./serializer";
2
2
  import type { ServerRenderer } from "./template";
3
- import { _await, _html, _peek_scope_id, _scope_id, $global, Chunk, isInResumedBranch, State, withChunk, writeScript } from "./writer";
3
+ import { _await, _html, _peek_scope_id, _scope_id, $global, Chunk, getChunk, isInResumedBranch, State, withChunk, writeScript } from "./writer";
4
4
  export declare const compat: {
5
5
  $global: typeof $global;
6
6
  fork: typeof _await;
@@ -10,13 +10,15 @@ export declare const compat: {
10
10
  peekNextScopeId: typeof _peek_scope_id;
11
11
  isInResumedBranch: typeof isInResumedBranch;
12
12
  withChunk: typeof withChunk;
13
+ getChunk: typeof getChunk;
13
14
  ensureState($global: any): State;
14
15
  isTagsAPI(fn: any): boolean;
15
16
  onFlush(fn: (chunk: Chunk) => void): void;
16
17
  patchDynamicTag: (patch: (tag: unknown, scopeId: number, accessor: import("../common/types").Accessor) => unknown) => void;
17
18
  writeSetScopeForComponent(branchId: number, m5c: string, m5i: unknown): void;
18
19
  toJSON(): (this: WeakKey) => [registryId: string, scopeId: unknown] | undefined;
19
- flushScript($global: any): string;
20
+ createChunk($global: any): Chunk;
21
+ flushScript($global: any, chunk?: Chunk): string;
20
22
  render(renderer: ServerRenderer, willRerender: boolean, classAPIOut: any, component: any, input: any, completeChunks: Chunk[], registerChildScope?: boolean): void;
21
23
  register: typeof register;
22
24
  registerRenderBody(fn: any): void;