marko 6.3.25 → 6.3.26
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/dist/debug/dom.js +305 -297
- package/dist/debug/dom.mjs +305 -297
- package/dist/debug/html.js +9 -3
- package/dist/debug/html.mjs +9 -3
- package/dist/dom.js +211 -212
- package/dist/dom.mjs +211 -212
- package/dist/html.js +8 -3
- package/dist/html.mjs +8 -3
- package/dist/translator/index.js +90 -32
- package/dist/translator/util/translate-attrs.d.ts +2 -0
- package/dist/translator/visitors/tag/native-tag.d.ts +3 -2
- package/package.json +4 -4
package/dist/debug/dom.mjs
CHANGED
|
@@ -345,22 +345,6 @@ function handleDelegated(ev) {
|
|
|
345
345
|
delete ev.currentTarget;
|
|
346
346
|
}
|
|
347
347
|
//#endregion
|
|
348
|
-
//#region src/dom/resolve-cursor-position.ts
|
|
349
|
-
const R = /[^\p{L}\p{N}]/gu;
|
|
350
|
-
function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
|
|
351
|
-
if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
|
|
352
|
-
const before = initialValue.slice(0, initialPosition);
|
|
353
|
-
const after = initialValue.slice(initialPosition);
|
|
354
|
-
if (updatedValue.startsWith(before)) return initialPosition;
|
|
355
|
-
if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
|
|
356
|
-
let count = before.replace(R, "").length;
|
|
357
|
-
let pos = 0;
|
|
358
|
-
while (count && updatedValue[pos]) if (updatedValue[pos++].replace(R, "")) count--;
|
|
359
|
-
return pos;
|
|
360
|
-
}
|
|
361
|
-
return -1;
|
|
362
|
-
}
|
|
363
|
-
//#endregion
|
|
364
348
|
//#region src/dom/parse-html.ts
|
|
365
349
|
const parsers = {};
|
|
366
350
|
function parseHTML(html, ns) {
|
|
@@ -709,77 +693,6 @@ function getDebugKey(index, node) {
|
|
|
709
693
|
return index;
|
|
710
694
|
}
|
|
711
695
|
//#endregion
|
|
712
|
-
//#region src/dom/renderer.ts
|
|
713
|
-
function createBranch($global, renderer, parentScope, parentNode) {
|
|
714
|
-
const branch = createScope($global);
|
|
715
|
-
branch["_"] = renderer["owner"] || parentScope;
|
|
716
|
-
setParentBranch(branch, parentScope?.[ClosestBranch]);
|
|
717
|
-
branch[Renderer] = renderer;
|
|
718
|
-
renderer[Clone]?.(branch, parentNode.namespaceURI);
|
|
719
|
-
return branch;
|
|
720
|
-
}
|
|
721
|
-
function setParentBranch(branch, parentBranch) {
|
|
722
|
-
if (parentBranch) {
|
|
723
|
-
branch[ParentBranch] = parentBranch;
|
|
724
|
-
(parentBranch[BranchScopes] ||= /* @__PURE__ */ new Set()).add(branch);
|
|
725
|
-
}
|
|
726
|
-
branch[ClosestBranch] = branch;
|
|
727
|
-
}
|
|
728
|
-
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
729
|
-
return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
|
|
730
|
-
}
|
|
731
|
-
function setupBranch(renderer, branch) {
|
|
732
|
-
if (renderer["setup"]) queueRender(branch, renderer[Setup], -1);
|
|
733
|
-
return branch;
|
|
734
|
-
}
|
|
735
|
-
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
736
|
-
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
|
737
|
-
setup = setup ? setup._ || setup : void 0;
|
|
738
|
-
params ||= void 0;
|
|
739
|
-
const clone = template ? (branch, ns) => {
|
|
740
|
-
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
|
|
741
|
-
} : (branch) => {
|
|
742
|
-
walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
743
|
-
};
|
|
744
|
-
return (owner) => {
|
|
745
|
-
return {
|
|
746
|
-
["id"]: id,
|
|
747
|
-
[Clone]: clone,
|
|
748
|
-
[Owner]: owner,
|
|
749
|
-
[Setup]: setup,
|
|
750
|
-
[Params]: params,
|
|
751
|
-
[Accessor]: dynamicScopesAccessor
|
|
752
|
-
};
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
756
|
-
return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
|
|
757
|
-
}
|
|
758
|
-
function _content_closures(renderer, closureFns) {
|
|
759
|
-
const closureSignals = {};
|
|
760
|
-
for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
|
|
761
|
-
return (owner, closureValues) => {
|
|
762
|
-
const instance = renderer(owner);
|
|
763
|
-
instance[LocalClosures] = closureSignals;
|
|
764
|
-
instance[LocalClosureValues] = closureValues;
|
|
765
|
-
return instance;
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
const cloneCache = {};
|
|
769
|
-
function createCloneableHTML(html, ns) {
|
|
770
|
-
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
771
|
-
const parent = document.createElementNS(ns, "t");
|
|
772
|
-
insertChildNodes(parent, null, firstChild, lastChild);
|
|
773
|
-
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
774
|
-
walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
|
|
775
|
-
} : (branch, walks) => {
|
|
776
|
-
const clone = parent.cloneNode(true);
|
|
777
|
-
walk(clone.firstChild, walks, branch);
|
|
778
|
-
branch[StartNode] = clone.firstChild;
|
|
779
|
-
branch[EndNode] = clone.lastChild;
|
|
780
|
-
};
|
|
781
|
-
}
|
|
782
|
-
//#endregion
|
|
783
696
|
//#region src/dom/resume.ts
|
|
784
697
|
const registeredValues = {};
|
|
785
698
|
let curRenders;
|
|
@@ -975,28 +888,304 @@ function init(runtimeId = "M") {
|
|
|
975
888
|
set: initRuntime
|
|
976
889
|
});
|
|
977
890
|
}
|
|
978
|
-
let isResuming;
|
|
979
|
-
function runResumeEffects(render) {
|
|
980
|
-
try {
|
|
981
|
-
isResuming = 1;
|
|
982
|
-
runEffects(render.m([]), 1);
|
|
983
|
-
} finally {
|
|
984
|
-
isResuming = 0;
|
|
891
|
+
let isResuming;
|
|
892
|
+
function runResumeEffects(render) {
|
|
893
|
+
try {
|
|
894
|
+
isResuming = 1;
|
|
895
|
+
runEffects(render.m([]), 1);
|
|
896
|
+
} finally {
|
|
897
|
+
isResuming = 0;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function getRegisteredWithScope(id, scope) {
|
|
901
|
+
const val = registeredValues[id];
|
|
902
|
+
return scope ? val(scope) : val;
|
|
903
|
+
}
|
|
904
|
+
function _resume(id, obj) {
|
|
905
|
+
return registeredValues[id] = obj;
|
|
906
|
+
}
|
|
907
|
+
function _var_resume(id, signal) {
|
|
908
|
+
_resume(id, (scope) => (value) => signal(scope, value));
|
|
909
|
+
return signal;
|
|
910
|
+
}
|
|
911
|
+
function _el(id, accessor) {
|
|
912
|
+
return _resume(id, (scope) => () => _el_read(scope[accessor]));
|
|
913
|
+
}
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/dom/renderer.ts
|
|
916
|
+
function createBranch($global, renderer, parentScope, parentNode) {
|
|
917
|
+
const branch = createScope($global);
|
|
918
|
+
branch["_"] = renderer["owner"] || parentScope;
|
|
919
|
+
setParentBranch(branch, parentScope?.[ClosestBranch]);
|
|
920
|
+
branch[Renderer] = renderer;
|
|
921
|
+
renderer[Clone]?.(branch, parentNode.namespaceURI);
|
|
922
|
+
return branch;
|
|
923
|
+
}
|
|
924
|
+
function setParentBranch(branch, parentBranch) {
|
|
925
|
+
if (parentBranch) {
|
|
926
|
+
branch[ParentBranch] = parentBranch;
|
|
927
|
+
(parentBranch[BranchScopes] ||= /* @__PURE__ */ new Set()).add(branch);
|
|
928
|
+
}
|
|
929
|
+
branch[ClosestBranch] = branch;
|
|
930
|
+
}
|
|
931
|
+
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
932
|
+
return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
|
|
933
|
+
}
|
|
934
|
+
function setupBranch(renderer, branch) {
|
|
935
|
+
if (renderer["setup"]) queueRender(branch, renderer[Setup], -1);
|
|
936
|
+
return branch;
|
|
937
|
+
}
|
|
938
|
+
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
939
|
+
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
|
940
|
+
setup = setup ? setup._ || setup : void 0;
|
|
941
|
+
params ||= void 0;
|
|
942
|
+
const clone = template ? (branch, ns) => {
|
|
943
|
+
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
|
|
944
|
+
} : (branch) => {
|
|
945
|
+
walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
946
|
+
};
|
|
947
|
+
return (owner) => {
|
|
948
|
+
return {
|
|
949
|
+
["id"]: id,
|
|
950
|
+
[Clone]: clone,
|
|
951
|
+
[Owner]: owner,
|
|
952
|
+
[Setup]: setup,
|
|
953
|
+
[Params]: params,
|
|
954
|
+
[Accessor]: dynamicScopesAccessor
|
|
955
|
+
};
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function _content_resume(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
959
|
+
return _resume(id, _content(id, template, walks, setup, params, dynamicScopesAccessor));
|
|
960
|
+
}
|
|
961
|
+
function _content_closures(renderer, closureFns) {
|
|
962
|
+
const closureSignals = {};
|
|
963
|
+
for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
|
|
964
|
+
return (owner, closureValues) => {
|
|
965
|
+
const instance = renderer(owner);
|
|
966
|
+
instance[LocalClosures] = closureSignals;
|
|
967
|
+
instance[LocalClosureValues] = closureValues;
|
|
968
|
+
return instance;
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
const cloneCache = {};
|
|
972
|
+
function createCloneableHTML(html, ns) {
|
|
973
|
+
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
974
|
+
const parent = document.createElementNS(ns, "t");
|
|
975
|
+
insertChildNodes(parent, null, firstChild, lastChild);
|
|
976
|
+
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
977
|
+
walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
|
|
978
|
+
} : (branch, walks) => {
|
|
979
|
+
const clone = parent.cloneNode(true);
|
|
980
|
+
walk(clone.firstChild, walks, branch);
|
|
981
|
+
branch[StartNode] = clone.firstChild;
|
|
982
|
+
branch[EndNode] = clone.lastChild;
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/dom/dom.ts
|
|
987
|
+
function _to_text(value) {
|
|
988
|
+
assertValidTextValue(value);
|
|
989
|
+
return value || value === 0 ? value + "" : "";
|
|
990
|
+
}
|
|
991
|
+
function _attr(element, name, value) {
|
|
992
|
+
assertValidAttrValue(name, value);
|
|
993
|
+
setAttribute(element, name, normalizeAttrValue(value));
|
|
994
|
+
}
|
|
995
|
+
function setAttribute(element, name, value) {
|
|
996
|
+
if (element.getAttribute(name) != value) if (value === void 0) element.removeAttribute(name);
|
|
997
|
+
else element.setAttribute(name, value);
|
|
998
|
+
}
|
|
999
|
+
function _attr_class(element, value) {
|
|
1000
|
+
setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
|
|
1001
|
+
}
|
|
1002
|
+
function _attr_class_items(element, items) {
|
|
1003
|
+
for (const key in items) _attr_class_item(element, key, items[key]);
|
|
1004
|
+
}
|
|
1005
|
+
function _attr_class_item(element, name, value) {
|
|
1006
|
+
element.classList.toggle(name, !!value);
|
|
1007
|
+
}
|
|
1008
|
+
function _attr_style(element, value) {
|
|
1009
|
+
setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
|
|
1010
|
+
}
|
|
1011
|
+
function _attr_style_items(element, items) {
|
|
1012
|
+
for (const key in items) _attr_style_item(element, key, items[key]);
|
|
1013
|
+
}
|
|
1014
|
+
function _attr_style_item(element, name, value) {
|
|
1015
|
+
element.style.setProperty(name, _to_text(value));
|
|
1016
|
+
}
|
|
1017
|
+
function _style_shell(scope, nodeAccessor) {
|
|
1018
|
+
const element = scope[nodeAccessor];
|
|
1019
|
+
const id = _id(scope);
|
|
1020
|
+
_attr_nonce(scope, nodeAccessor);
|
|
1021
|
+
element.className = id;
|
|
1022
|
+
_text_content(element, "." + id + "~*{}");
|
|
1023
|
+
}
|
|
1024
|
+
function _style_rule_item(element, name, value) {
|
|
1025
|
+
const text = element.textContent;
|
|
1026
|
+
const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
|
|
1027
|
+
let start = text.indexOf("{" + name + ":");
|
|
1028
|
+
if (!~start) start = text.indexOf(";" + name + ":");
|
|
1029
|
+
_text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
1030
|
+
}
|
|
1031
|
+
function _attr_nonce(scope, nodeAccessor) {
|
|
1032
|
+
_attr(scope[nodeAccessor], "nonce", scope[Global].cspNonce);
|
|
1033
|
+
}
|
|
1034
|
+
function _text(node, value) {
|
|
1035
|
+
const normalizedValue = _to_text(value);
|
|
1036
|
+
if (node.data !== normalizedValue) node.data = normalizedValue;
|
|
1037
|
+
}
|
|
1038
|
+
function _text_content(node, value) {
|
|
1039
|
+
const normalizedValue = _to_text(value);
|
|
1040
|
+
if (node.textContent !== normalizedValue) node.textContent = normalizedValue;
|
|
1041
|
+
}
|
|
1042
|
+
function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1043
|
+
const el = scope[nodeAccessor];
|
|
1044
|
+
for (let i = el.attributes.length; i--;) {
|
|
1045
|
+
const { name } = el.attributes.item(i);
|
|
1046
|
+
if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) el.removeAttribute(name);
|
|
1047
|
+
}
|
|
1048
|
+
assertExclusiveAttrs(nextAttrs);
|
|
1049
|
+
attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
|
|
1050
|
+
}
|
|
1051
|
+
function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1052
|
+
_attrs(scope, nodeAccessor, nextAttrs, controllable);
|
|
1053
|
+
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1054
|
+
}
|
|
1055
|
+
function hasAttrAlias(element, attr, nextAttrs) {
|
|
1056
|
+
return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
|
|
1057
|
+
}
|
|
1058
|
+
function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
|
|
1059
|
+
const el = scope[nodeAccessor];
|
|
1060
|
+
const partial = {};
|
|
1061
|
+
for (let i = el.attributes.length; i--;) {
|
|
1062
|
+
const { name } = el.attributes.item(i);
|
|
1063
|
+
if (!skip[name] && !(nextAttrs && name in nextAttrs)) el.removeAttribute(name);
|
|
1064
|
+
}
|
|
1065
|
+
for (const name in nextAttrs) {
|
|
1066
|
+
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1067
|
+
if (!skip[key]) partial[key] = nextAttrs[name];
|
|
1068
|
+
}
|
|
1069
|
+
assertExclusiveAttrs({
|
|
1070
|
+
...nextAttrs,
|
|
1071
|
+
...skip
|
|
1072
|
+
});
|
|
1073
|
+
attrsInternal(scope, nodeAccessor, partial, controllable);
|
|
1074
|
+
}
|
|
1075
|
+
function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
|
|
1076
|
+
_attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable);
|
|
1077
|
+
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1078
|
+
}
|
|
1079
|
+
function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1080
|
+
const el = scope[nodeAccessor];
|
|
1081
|
+
let events = scope[EventAttributes + nodeAccessor];
|
|
1082
|
+
let skip = void 0;
|
|
1083
|
+
for (const name in events) events[name] = 0;
|
|
1084
|
+
if (controllable) {
|
|
1085
|
+
scope[ControlledType + nodeAccessor] = 5;
|
|
1086
|
+
scope[ControlledHandler + nodeAccessor] = 0;
|
|
1087
|
+
if (nextAttrs) skip = controllable(scope, nodeAccessor, nextAttrs);
|
|
1088
|
+
}
|
|
1089
|
+
for (const name in nextAttrs) {
|
|
1090
|
+
const value = nextAttrs[name];
|
|
1091
|
+
switch (name) {
|
|
1092
|
+
case "class":
|
|
1093
|
+
_attr_class(el, value);
|
|
1094
|
+
break;
|
|
1095
|
+
case "style":
|
|
1096
|
+
_attr_style(el, value);
|
|
1097
|
+
break;
|
|
1098
|
+
default:
|
|
1099
|
+
assertValidAttrName(name);
|
|
1100
|
+
if (isEventHandler(name)) (events ||= scope[EventAttributes + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1101
|
+
else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
|
|
1102
|
+
break;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function _attr_content(scope, nodeAccessor, value) {
|
|
1107
|
+
const content = normalizeClientRender(value);
|
|
1108
|
+
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
|
|
1109
|
+
setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1110
|
+
if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
|
|
1111
|
+
}
|
|
1112
|
+
for (const accessor in content?.[LocalClosures]) content[LocalClosures][accessor](scope[BranchScopes$1 + nodeAccessor], content[LocalClosureValues][accessor]);
|
|
1113
|
+
}
|
|
1114
|
+
function _attrs_script(scope, nodeAccessor) {
|
|
1115
|
+
const el = scope[nodeAccessor];
|
|
1116
|
+
const events = scope[EventAttributes + nodeAccessor];
|
|
1117
|
+
controllableScripts[scope[ControlledType + nodeAccessor]]?.(scope, nodeAccessor);
|
|
1118
|
+
for (const name in events) _on(el, name, events[name]);
|
|
1119
|
+
}
|
|
1120
|
+
function _html(scope, value, accessor) {
|
|
1121
|
+
const firstChild = scope[accessor];
|
|
1122
|
+
const parentNode = firstChild.parentNode;
|
|
1123
|
+
const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
|
|
1124
|
+
const newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
|
|
1125
|
+
insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope[DynamicHTMLLastChild + accessor] = newContent.lastChild);
|
|
1126
|
+
removeChildNodes(firstChild, lastChild);
|
|
1127
|
+
}
|
|
1128
|
+
function normalizeClientRender(value) {
|
|
1129
|
+
const renderer = normalizeDynamicRenderer(value);
|
|
1130
|
+
if (renderer) if (renderer["id"]) return renderer;
|
|
1131
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1132
|
+
}
|
|
1133
|
+
function normalizeAttrValue(value) {
|
|
1134
|
+
if (isNotVoid(value)) return value === true ? "" : value + "";
|
|
1135
|
+
}
|
|
1136
|
+
function _lifecycle(scope, thisObj, index = 0) {
|
|
1137
|
+
const accessor = Lifecycle + index;
|
|
1138
|
+
const instance = scope[accessor];
|
|
1139
|
+
if (instance) {
|
|
1140
|
+
Object.assign(instance, thisObj);
|
|
1141
|
+
instance.onUpdate?.();
|
|
1142
|
+
} else {
|
|
1143
|
+
scope[accessor] = thisObj;
|
|
1144
|
+
{
|
|
1145
|
+
const snapshot = { ...thisObj };
|
|
1146
|
+
Object.assign(thisObj, thisObj.onMount?.());
|
|
1147
|
+
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1148
|
+
}
|
|
1149
|
+
$signal(scope, accessor).onabort = () => thisObj.onDestroy?.();
|
|
985
1150
|
}
|
|
986
1151
|
}
|
|
987
|
-
function
|
|
988
|
-
const
|
|
989
|
-
|
|
1152
|
+
function removeChildNodes(startNode, endNode) {
|
|
1153
|
+
const stop = endNode.nextSibling;
|
|
1154
|
+
while (startNode !== stop) {
|
|
1155
|
+
const next = startNode.nextSibling;
|
|
1156
|
+
startNode.remove();
|
|
1157
|
+
startNode = next;
|
|
1158
|
+
}
|
|
990
1159
|
}
|
|
991
|
-
function
|
|
992
|
-
|
|
1160
|
+
function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
|
|
1161
|
+
parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
|
|
993
1162
|
}
|
|
994
|
-
function
|
|
995
|
-
|
|
996
|
-
|
|
1163
|
+
function toInsertNode(startNode, endNode) {
|
|
1164
|
+
if (startNode === endNode) return startNode;
|
|
1165
|
+
const parent = new DocumentFragment();
|
|
1166
|
+
const stop = endNode.nextSibling;
|
|
1167
|
+
while (startNode !== stop) {
|
|
1168
|
+
const next = startNode.nextSibling;
|
|
1169
|
+
parent.appendChild(startNode);
|
|
1170
|
+
startNode = next;
|
|
1171
|
+
}
|
|
1172
|
+
return parent;
|
|
997
1173
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1174
|
+
//#endregion
|
|
1175
|
+
//#region src/dom/resolve-cursor-position.ts
|
|
1176
|
+
const R = /[^\p{L}\p{N}]/gu;
|
|
1177
|
+
function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
|
|
1178
|
+
if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
|
|
1179
|
+
const before = initialValue.slice(0, initialPosition);
|
|
1180
|
+
const after = initialValue.slice(initialPosition);
|
|
1181
|
+
if (updatedValue.startsWith(before)) return initialPosition;
|
|
1182
|
+
if (updatedValue.endsWith(after)) return updatedValue.length - after.length;
|
|
1183
|
+
let count = before.replace(R, "").length;
|
|
1184
|
+
let pos = 0;
|
|
1185
|
+
while (count && updatedValue[pos]) if (updatedValue[pos++].replace(R, "")) count--;
|
|
1186
|
+
return pos;
|
|
1187
|
+
}
|
|
1188
|
+
return -1;
|
|
1000
1189
|
}
|
|
1001
1190
|
//#endregion
|
|
1002
1191
|
//#region src/dom/controllable.ts
|
|
@@ -1317,192 +1506,6 @@ function _controllable_open(scope, nodeAccessor, nextAttrs) {
|
|
|
1317
1506
|
}
|
|
1318
1507
|
}
|
|
1319
1508
|
//#endregion
|
|
1320
|
-
//#region src/dom/dom.ts
|
|
1321
|
-
function _to_text(value) {
|
|
1322
|
-
assertValidTextValue(value);
|
|
1323
|
-
return value || value === 0 ? value + "" : "";
|
|
1324
|
-
}
|
|
1325
|
-
function _attr(element, name, value) {
|
|
1326
|
-
assertValidAttrValue(name, value);
|
|
1327
|
-
setAttribute(element, name, normalizeAttrValue(value));
|
|
1328
|
-
}
|
|
1329
|
-
function setAttribute(element, name, value) {
|
|
1330
|
-
if (element.getAttribute(name) != value) if (value === void 0) element.removeAttribute(name);
|
|
1331
|
-
else element.setAttribute(name, value);
|
|
1332
|
-
}
|
|
1333
|
-
function _attr_class(element, value) {
|
|
1334
|
-
setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
|
|
1335
|
-
}
|
|
1336
|
-
function _attr_class_items(element, items) {
|
|
1337
|
-
for (const key in items) _attr_class_item(element, key, items[key]);
|
|
1338
|
-
}
|
|
1339
|
-
function _attr_class_item(element, name, value) {
|
|
1340
|
-
element.classList.toggle(name, !!value);
|
|
1341
|
-
}
|
|
1342
|
-
function _attr_style(element, value) {
|
|
1343
|
-
setAttribute(element, "style", toDelimitedString(value, ";", stringifyStyleObject) || void 0);
|
|
1344
|
-
}
|
|
1345
|
-
function _attr_style_items(element, items) {
|
|
1346
|
-
for (const key in items) _attr_style_item(element, key, items[key]);
|
|
1347
|
-
}
|
|
1348
|
-
function _attr_style_item(element, name, value) {
|
|
1349
|
-
element.style.setProperty(name, _to_text(value));
|
|
1350
|
-
}
|
|
1351
|
-
function _style_shell(scope, nodeAccessor) {
|
|
1352
|
-
const element = scope[nodeAccessor];
|
|
1353
|
-
const id = _id(scope);
|
|
1354
|
-
_attr_nonce(scope, nodeAccessor);
|
|
1355
|
-
element.className = id;
|
|
1356
|
-
_text_content(element, "." + id + "~*{}");
|
|
1357
|
-
}
|
|
1358
|
-
function _style_rule_item(element, name, value) {
|
|
1359
|
-
const text = element.textContent;
|
|
1360
|
-
const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
|
|
1361
|
-
let start = text.indexOf("{" + name + ":");
|
|
1362
|
-
if (!~start) start = text.indexOf(";" + name + ":");
|
|
1363
|
-
_text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
1364
|
-
}
|
|
1365
|
-
function _attr_nonce(scope, nodeAccessor) {
|
|
1366
|
-
_attr(scope[nodeAccessor], "nonce", scope[Global].cspNonce);
|
|
1367
|
-
}
|
|
1368
|
-
function _text(node, value) {
|
|
1369
|
-
const normalizedValue = _to_text(value);
|
|
1370
|
-
if (node.data !== normalizedValue) node.data = normalizedValue;
|
|
1371
|
-
}
|
|
1372
|
-
function _text_content(node, value) {
|
|
1373
|
-
const normalizedValue = _to_text(value);
|
|
1374
|
-
if (node.textContent !== normalizedValue) node.textContent = normalizedValue;
|
|
1375
|
-
}
|
|
1376
|
-
function _attrs(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1377
|
-
const el = scope[nodeAccessor];
|
|
1378
|
-
for (let i = el.attributes.length; i--;) {
|
|
1379
|
-
const { name } = el.attributes.item(i);
|
|
1380
|
-
if (!(nextAttrs && (name in nextAttrs || hasAttrAlias(el, name, nextAttrs)))) el.removeAttribute(name);
|
|
1381
|
-
}
|
|
1382
|
-
assertExclusiveAttrs(nextAttrs);
|
|
1383
|
-
attrsInternal(scope, nodeAccessor, nextAttrs, controllable);
|
|
1384
|
-
}
|
|
1385
|
-
function _attrs_content(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1386
|
-
_attrs(scope, nodeAccessor, nextAttrs, controllable);
|
|
1387
|
-
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1388
|
-
}
|
|
1389
|
-
function hasAttrAlias(element, attr, nextAttrs) {
|
|
1390
|
-
return attr === "checked" && element.tagName === "INPUT" && "checkedValue" in nextAttrs;
|
|
1391
|
-
}
|
|
1392
|
-
function _attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable) {
|
|
1393
|
-
const el = scope[nodeAccessor];
|
|
1394
|
-
const partial = {};
|
|
1395
|
-
for (let i = el.attributes.length; i--;) {
|
|
1396
|
-
const { name } = el.attributes.item(i);
|
|
1397
|
-
if (!skip[name] && !(nextAttrs && name in nextAttrs)) el.removeAttribute(name);
|
|
1398
|
-
}
|
|
1399
|
-
for (const name in nextAttrs) {
|
|
1400
|
-
const key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
|
|
1401
|
-
if (!skip[key]) partial[key] = nextAttrs[name];
|
|
1402
|
-
}
|
|
1403
|
-
assertExclusiveAttrs({
|
|
1404
|
-
...nextAttrs,
|
|
1405
|
-
...skip
|
|
1406
|
-
});
|
|
1407
|
-
attrsInternal(scope, nodeAccessor, partial, controllable);
|
|
1408
|
-
}
|
|
1409
|
-
function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip, controllable) {
|
|
1410
|
-
_attrs_partial(scope, nodeAccessor, nextAttrs, skip, controllable);
|
|
1411
|
-
_attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
1412
|
-
}
|
|
1413
|
-
function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
1414
|
-
const el = scope[nodeAccessor];
|
|
1415
|
-
let events = scope[EventAttributes + nodeAccessor];
|
|
1416
|
-
for (const name in events) events[name] = 0;
|
|
1417
|
-
scope[ControlledType + nodeAccessor] = 5;
|
|
1418
|
-
scope[ControlledHandler + nodeAccessor] = 0;
|
|
1419
|
-
const skip = nextAttrs && (controllable || controllableRenders[el.tagName])?.(scope, nodeAccessor, nextAttrs);
|
|
1420
|
-
for (const name in nextAttrs) {
|
|
1421
|
-
const value = nextAttrs[name];
|
|
1422
|
-
switch (name) {
|
|
1423
|
-
case "class":
|
|
1424
|
-
_attr_class(el, value);
|
|
1425
|
-
break;
|
|
1426
|
-
case "style":
|
|
1427
|
-
_attr_style(el, value);
|
|
1428
|
-
break;
|
|
1429
|
-
default:
|
|
1430
|
-
assertValidAttrName(name);
|
|
1431
|
-
if (isEventHandler(name)) (events ||= scope[EventAttributes + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1432
|
-
else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
|
|
1433
|
-
break;
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
function _attr_content(scope, nodeAccessor, value) {
|
|
1438
|
-
const content = normalizeClientRender(value);
|
|
1439
|
-
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
|
|
1440
|
-
setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1441
|
-
if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
|
|
1442
|
-
}
|
|
1443
|
-
for (const accessor in content?.[LocalClosures]) content[LocalClosures][accessor](scope[BranchScopes$1 + nodeAccessor], content[LocalClosureValues][accessor]);
|
|
1444
|
-
}
|
|
1445
|
-
function _attrs_script(scope, nodeAccessor) {
|
|
1446
|
-
const el = scope[nodeAccessor];
|
|
1447
|
-
const events = scope[EventAttributes + nodeAccessor];
|
|
1448
|
-
controllableScripts[scope[ControlledType + nodeAccessor]]?.(scope, nodeAccessor);
|
|
1449
|
-
for (const name in events) _on(el, name, events[name]);
|
|
1450
|
-
}
|
|
1451
|
-
function _html(scope, value, accessor) {
|
|
1452
|
-
const firstChild = scope[accessor];
|
|
1453
|
-
const parentNode = firstChild.parentNode;
|
|
1454
|
-
const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
|
|
1455
|
-
const newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
|
|
1456
|
-
insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope[DynamicHTMLLastChild + accessor] = newContent.lastChild);
|
|
1457
|
-
removeChildNodes(firstChild, lastChild);
|
|
1458
|
-
}
|
|
1459
|
-
function normalizeClientRender(value) {
|
|
1460
|
-
const renderer = normalizeDynamicRenderer(value);
|
|
1461
|
-
if (renderer) if (renderer["id"]) return renderer;
|
|
1462
|
-
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1463
|
-
}
|
|
1464
|
-
function normalizeAttrValue(value) {
|
|
1465
|
-
if (isNotVoid(value)) return value === true ? "" : value + "";
|
|
1466
|
-
}
|
|
1467
|
-
function _lifecycle(scope, thisObj, index = 0) {
|
|
1468
|
-
const accessor = Lifecycle + index;
|
|
1469
|
-
const instance = scope[accessor];
|
|
1470
|
-
if (instance) {
|
|
1471
|
-
Object.assign(instance, thisObj);
|
|
1472
|
-
instance.onUpdate?.();
|
|
1473
|
-
} else {
|
|
1474
|
-
scope[accessor] = thisObj;
|
|
1475
|
-
{
|
|
1476
|
-
const snapshot = { ...thisObj };
|
|
1477
|
-
Object.assign(thisObj, thisObj.onMount?.());
|
|
1478
|
-
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1479
|
-
}
|
|
1480
|
-
$signal(scope, accessor).onabort = () => thisObj.onDestroy?.();
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
function removeChildNodes(startNode, endNode) {
|
|
1484
|
-
const stop = endNode.nextSibling;
|
|
1485
|
-
while (startNode !== stop) {
|
|
1486
|
-
const next = startNode.nextSibling;
|
|
1487
|
-
startNode.remove();
|
|
1488
|
-
startNode = next;
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
|
|
1492
|
-
parentNode.insertBefore(toInsertNode(startNode, endNode), referenceNode);
|
|
1493
|
-
}
|
|
1494
|
-
function toInsertNode(startNode, endNode) {
|
|
1495
|
-
if (startNode === endNode) return startNode;
|
|
1496
|
-
const parent = new DocumentFragment();
|
|
1497
|
-
const stop = endNode.nextSibling;
|
|
1498
|
-
while (startNode !== stop) {
|
|
1499
|
-
const next = startNode.nextSibling;
|
|
1500
|
-
parent.appendChild(startNode);
|
|
1501
|
-
startNode = next;
|
|
1502
|
-
}
|
|
1503
|
-
return parent;
|
|
1504
|
-
}
|
|
1505
|
-
//#endregion
|
|
1506
1509
|
//#region src/dom/control-flow.ts
|
|
1507
1510
|
function _await_promise(nodeAccessor, params) {
|
|
1508
1511
|
const promiseAccessor = Promise$1 + nodeAccessor;
|
|
@@ -1741,8 +1744,9 @@ let _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inpu
|
|
|
1741
1744
|
const childScope = scope[childScopeAccessor];
|
|
1742
1745
|
const args = getInput?.();
|
|
1743
1746
|
if (typeof normalizedRenderer === "string") {
|
|
1744
|
-
|
|
1745
|
-
|
|
1747
|
+
const nodeAccessor = `#${normalizedRenderer}/0`;
|
|
1748
|
+
(getContent ? _attrs : _attrs_content)(childScope, nodeAccessor, (inputIsArgs ? args[0] : args) || {}, controllableRenders[childScope[nodeAccessor].tagName]);
|
|
1749
|
+
if (childScope["EventAttributes:" + nodeAccessor] || childScope["ControlledHandler:" + nodeAccessor]) queueEffect(childScope, dynamicTagScript);
|
|
1746
1750
|
} else {
|
|
1747
1751
|
for (const accessor in normalizedRenderer[LocalClosures]) normalizedRenderer[LocalClosures][accessor](childScope, normalizedRenderer[LocalClosureValues][accessor]);
|
|
1748
1752
|
if (normalizedRenderer["params"]) if (inputIsArgs) normalizedRenderer[Params](childScope, normalizedRenderer._ ? args[0] : args);
|
|
@@ -2072,8 +2076,9 @@ function _enable_catch() {
|
|
|
2072
2076
|
function $signalReset(scope, id) {
|
|
2073
2077
|
const ctrl = scope[AbortControllers]?.[id];
|
|
2074
2078
|
if (ctrl) {
|
|
2075
|
-
queueEffect(ctrl, abort);
|
|
2076
2079
|
scope[AbortControllers][id] = void 0;
|
|
2080
|
+
if (rendering) queueEffect(ctrl, abort);
|
|
2081
|
+
else abort(ctrl);
|
|
2077
2082
|
}
|
|
2078
2083
|
}
|
|
2079
2084
|
function $signal(scope, id) {
|
|
@@ -2236,10 +2241,13 @@ function mount(input = {}, reference, position) {
|
|
|
2236
2241
|
set value(newValue) {
|
|
2237
2242
|
_var_change(branch, newValue);
|
|
2238
2243
|
},
|
|
2239
|
-
update(newInput) {
|
|
2240
|
-
if (args)
|
|
2241
|
-
|
|
2242
|
-
|
|
2244
|
+
update(newInput = {}) {
|
|
2245
|
+
if (args) {
|
|
2246
|
+
if (newInput.$global) ({$global, ...newInput} = newInput);
|
|
2247
|
+
runEffects(prepareEffects(() => {
|
|
2248
|
+
args(branch, newInput);
|
|
2249
|
+
}));
|
|
2250
|
+
}
|
|
2243
2251
|
},
|
|
2244
2252
|
destroy() {
|
|
2245
2253
|
removeAndDestroyBranch(branch);
|
package/dist/debug/html.js
CHANGED
|
@@ -1366,13 +1366,18 @@ function writeGenerator(state, iter, ref) {
|
|
|
1366
1366
|
state.buf.push("(function*(){})()");
|
|
1367
1367
|
return true;
|
|
1368
1368
|
}
|
|
1369
|
-
|
|
1369
|
+
const heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
|
|
1370
|
+
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})(");
|
|
1370
1371
|
if (needsId) {
|
|
1371
1372
|
const arrayRef = new Reference(ref, null, state.flush, null, nextRefAccess(state));
|
|
1372
1373
|
state.buf.push(arrayRef.id + "=");
|
|
1373
1374
|
writeArray(state, yields, arrayRef);
|
|
1374
1375
|
} else writeArray(state, yields, new Reference(ref, null, state.flush, state.buf.length));
|
|
1375
|
-
if (
|
|
1376
|
+
if (heldReturn) {
|
|
1377
|
+
const holder = new Reference(ref, null, state.flush, null, nextRefAccess(state));
|
|
1378
|
+
state.buf.push("," + holder.id + "={}");
|
|
1379
|
+
writeProp(state, returnValue, holder, "v");
|
|
1380
|
+
} else if (returnValue !== void 0) {
|
|
1376
1381
|
const sepIndex = state.buf.push(",") - 1;
|
|
1377
1382
|
if (writeProp(state, returnValue, ref, "") && isDedupedMember(returnValue)) {
|
|
1378
1383
|
const retRef = typeof returnValue === "string" ? state.strs.get(returnValue) : state.refs.get(returnValue);
|
|
@@ -2763,7 +2768,8 @@ function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, seriali
|
|
|
2763
2768
|
return _textarea_value(value);
|
|
2764
2769
|
}
|
|
2765
2770
|
function _textarea_value(value) {
|
|
2766
|
-
|
|
2771
|
+
const escaped = _escape(normalizeStrAttrValue(value));
|
|
2772
|
+
return escaped[0] === "\n" || escaped[0] === "\r" ? "\n" + escaped : escaped;
|
|
2767
2773
|
}
|
|
2768
2774
|
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
2769
2775
|
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|