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