domql 3.5.1 → 3.6.1
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/iife/index.js +145 -38
- package/package.json +9 -8
package/dist/iife/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var Domql = (() => {
|
|
|
36
36
|
return (typeof HTMLElement === "object" ? obj instanceof window2.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string") || false;
|
|
37
37
|
};
|
|
38
38
|
var isDOMNode = (obj) => {
|
|
39
|
-
return typeof window2 !== "undefined" && (obj instanceof window2.Node || obj instanceof window2.Window || obj === window2 || obj === document);
|
|
39
|
+
return typeof window2 !== "undefined" && (window2.Node && obj instanceof window2.Node || window2.Window && obj instanceof window2.Window || obj === window2 || obj === document);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
// ../utils/dist/esm/types.js
|
|
@@ -780,6 +780,7 @@ var Domql = (() => {
|
|
|
780
780
|
|
|
781
781
|
// ../utils/dist/esm/extends.js
|
|
782
782
|
var ENV2 = process.env.NODE_ENV;
|
|
783
|
+
var isSourcemapEnabled = (options) => options.sourcemap !== false && ENV2 !== "production";
|
|
783
784
|
var createExtendsFromKeys = (key) => {
|
|
784
785
|
if (key.includes("+")) {
|
|
785
786
|
return key.split("+").filter(matchesComponentNaming);
|
|
@@ -853,17 +854,17 @@ var Domql = (() => {
|
|
|
853
854
|
}
|
|
854
855
|
return setHashedExtend(extend, stack);
|
|
855
856
|
};
|
|
856
|
-
var extractArrayExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
|
|
857
|
+
var extractArrayExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set(), nameStack, componentNameMap) => {
|
|
857
858
|
for (const each of extend) {
|
|
858
859
|
if (isArray(each)) {
|
|
859
|
-
extractArrayExtend(each, stack, context, processed);
|
|
860
|
+
extractArrayExtend(each, stack, context, processed, nameStack, componentNameMap);
|
|
860
861
|
} else {
|
|
861
|
-
flattenExtend(each, stack, context, processed);
|
|
862
|
+
flattenExtend(each, stack, context, processed, nameStack, void 0, componentNameMap);
|
|
862
863
|
}
|
|
863
864
|
}
|
|
864
865
|
return stack;
|
|
865
866
|
};
|
|
866
|
-
var deepExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
|
|
867
|
+
var deepExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set(), nameStack, currentName, componentNameMap) => {
|
|
867
868
|
const extendOflattenExtend = extend.extends || extend.extend;
|
|
868
869
|
const cleanExtend = { ...extend };
|
|
869
870
|
delete cleanExtend.extends;
|
|
@@ -875,26 +876,32 @@ var Domql = (() => {
|
|
|
875
876
|
}
|
|
876
877
|
if (hasKeys) {
|
|
877
878
|
stack.push(cleanExtend);
|
|
879
|
+
if (nameStack) nameStack.push(currentName);
|
|
878
880
|
}
|
|
879
881
|
if (extendOflattenExtend) {
|
|
880
|
-
flattenExtend(extendOflattenExtend, stack, context, processed);
|
|
882
|
+
flattenExtend(extendOflattenExtend, stack, context, processed, nameStack, currentName, componentNameMap);
|
|
881
883
|
}
|
|
882
884
|
return stack;
|
|
883
885
|
};
|
|
884
|
-
var flattenExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
|
|
886
|
+
var flattenExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set(), nameStack, parentName, componentNameMap) => {
|
|
885
887
|
if (!extend) return stack;
|
|
886
888
|
if (processed.has(extend)) return stack;
|
|
887
889
|
if (isArray(extend)) {
|
|
888
|
-
return extractArrayExtend(extend, stack, context, processed);
|
|
890
|
+
return extractArrayExtend(extend, stack, context, processed, nameStack, componentNameMap);
|
|
889
891
|
}
|
|
892
|
+
let currentName = parentName;
|
|
890
893
|
if (isString(extend)) {
|
|
894
|
+
currentName = extend;
|
|
891
895
|
extend = mapStringsWithContextComponents(extend, context);
|
|
896
|
+
} else if (componentNameMap && isObject(extend) && componentNameMap.has(extend)) {
|
|
897
|
+
currentName = componentNameMap.get(extend);
|
|
892
898
|
}
|
|
893
899
|
processed.add(extend);
|
|
894
900
|
if (extend?.extends || extend?.extend) {
|
|
895
|
-
deepExtend(extend, stack, context, processed);
|
|
901
|
+
deepExtend(extend, stack, context, processed, nameStack, currentName, componentNameMap);
|
|
896
902
|
} else if (extend) {
|
|
897
903
|
stack.push(extend);
|
|
904
|
+
if (nameStack) nameStack.push(currentName);
|
|
898
905
|
}
|
|
899
906
|
return stack;
|
|
900
907
|
};
|
|
@@ -907,7 +914,7 @@ var Domql = (() => {
|
|
|
907
914
|
"childExtend",
|
|
908
915
|
"childExtendRecursive"
|
|
909
916
|
]);
|
|
910
|
-
var deepMergeExtends = (element, extend) => {
|
|
917
|
+
var deepMergeExtends = (element, extend, sourcemap, sourceName, preBuiltSourcemap) => {
|
|
911
918
|
extend = deepClone(extend);
|
|
912
919
|
for (const e in extend) {
|
|
913
920
|
if (MERGE_EXTENDS_SKIP.has(e)) continue;
|
|
@@ -917,11 +924,23 @@ var Domql = (() => {
|
|
|
917
924
|
if (Object.prototype.hasOwnProperty.call(extend, e) && e !== "__proto__" && e !== "constructor" && e !== "prototype") {
|
|
918
925
|
if (elementProp === void 0) {
|
|
919
926
|
element[e] = extendProp;
|
|
927
|
+
if (sourcemap && sourceName) {
|
|
928
|
+
if (isObject(extendProp) && !isArray(extendProp)) {
|
|
929
|
+
sourcemap[e] = sourcemap[e] || {};
|
|
930
|
+
trackSourcemapDeep(sourcemap[e], extendProp, sourceName);
|
|
931
|
+
} else {
|
|
932
|
+
sourcemap[e] = sourceName;
|
|
933
|
+
}
|
|
934
|
+
} else if (sourcemap && preBuiltSourcemap?.[e]) {
|
|
935
|
+
sourcemap[e] = preBuiltSourcemap[e];
|
|
936
|
+
}
|
|
920
937
|
} else if (isObject(elementProp) && isObject(extendProp)) {
|
|
938
|
+
const nestedSourcemap = sourcemap ? sourcemap[e] = sourcemap[e] || {} : void 0;
|
|
939
|
+
const nestedPreBuilt = preBuiltSourcemap?.[e];
|
|
921
940
|
if (matchesComponentNaming(e)) {
|
|
922
|
-
element[e] = deepMergeExtends(elementProp, extendProp);
|
|
941
|
+
element[e] = deepMergeExtends(elementProp, extendProp, nestedSourcemap, sourceName, nestedPreBuilt);
|
|
923
942
|
} else {
|
|
924
|
-
deepMergeExtends(elementProp, extendProp);
|
|
943
|
+
deepMergeExtends(elementProp, extendProp, nestedSourcemap, sourceName, nestedPreBuilt);
|
|
925
944
|
}
|
|
926
945
|
}
|
|
927
946
|
if (e === "extends" || e === "childExtends" || e === "childExtendsRecursive") {
|
|
@@ -936,10 +955,24 @@ var Domql = (() => {
|
|
|
936
955
|
}
|
|
937
956
|
return element;
|
|
938
957
|
};
|
|
939
|
-
var
|
|
940
|
-
|
|
958
|
+
var trackSourcemapDeep = (sourcemap, obj, sourceName) => {
|
|
959
|
+
for (const key in obj) {
|
|
960
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
961
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
962
|
+
const val = obj[key];
|
|
963
|
+
if (isObject(val) && !isArray(val)) {
|
|
964
|
+
sourcemap[key] = sourcemap[key] || {};
|
|
965
|
+
trackSourcemapDeep(sourcemap[key], val, sourceName);
|
|
966
|
+
} else {
|
|
967
|
+
sourcemap[key] = sourceName;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
var cloneAndMergeArrayExtend = (stack, sourcemap, extendNames) => {
|
|
972
|
+
return stack.reduce((acc, current, i) => {
|
|
941
973
|
const cloned = deepClone(current);
|
|
942
|
-
|
|
974
|
+
const sourceName = extendNames ? extendNames[i] : void 0;
|
|
975
|
+
return deepMergeExtends(acc, cloned, sourcemap, sourceName);
|
|
943
976
|
}, {});
|
|
944
977
|
};
|
|
945
978
|
var mapStringsWithContextComponents = (extend, context, options = {}, variant) => {
|
|
@@ -959,11 +992,12 @@ var Domql = (() => {
|
|
|
959
992
|
}
|
|
960
993
|
return extend;
|
|
961
994
|
};
|
|
962
|
-
var getExtendsStack = (extend, context) => {
|
|
995
|
+
var getExtendsStack = (extend, context, nameStack, componentNameMap) => {
|
|
963
996
|
if (!extend) return [];
|
|
964
997
|
if (extend.__hash) return getHashedExtend(extend) || [];
|
|
965
998
|
const processed = /* @__PURE__ */ new Set();
|
|
966
|
-
const stack = flattenExtend(extend, [], context, processed);
|
|
999
|
+
const stack = flattenExtend(extend, [], context, processed, nameStack, void 0, componentNameMap);
|
|
1000
|
+
if (nameStack) return stack;
|
|
967
1001
|
return getExtendsStackRegistry(extend, stack);
|
|
968
1002
|
};
|
|
969
1003
|
var createElementExtends = (element, parent, options = {}) => {
|
|
@@ -1041,6 +1075,8 @@ var Domql = (() => {
|
|
|
1041
1075
|
const { props, __ref: ref } = element;
|
|
1042
1076
|
const context = element.context || parent.context;
|
|
1043
1077
|
const variant = element.variant || props?.variant;
|
|
1078
|
+
const sourcemap = isSourcemapEnabled(options);
|
|
1079
|
+
const originalExtendNames = sourcemap ? [...ref.__extends] : null;
|
|
1044
1080
|
const __extends = removeDuplicatesInArray(
|
|
1045
1081
|
ref.__extends.map((val, i) => {
|
|
1046
1082
|
return mapStringsWithContextComponents(
|
|
@@ -1051,15 +1087,40 @@ var Domql = (() => {
|
|
|
1051
1087
|
);
|
|
1052
1088
|
})
|
|
1053
1089
|
);
|
|
1054
|
-
|
|
1055
|
-
|
|
1090
|
+
if (sourcemap) {
|
|
1091
|
+
const componentNameMap = /* @__PURE__ */ new WeakMap();
|
|
1092
|
+
for (let i = 0; i < __extends.length; i++) {
|
|
1093
|
+
const resolved = __extends[i];
|
|
1094
|
+
const originalName = originalExtendNames[i];
|
|
1095
|
+
if (resolved && isObject(resolved) && isString(originalName)) {
|
|
1096
|
+
componentNameMap.set(resolved, originalName);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
const nameStack = [];
|
|
1100
|
+
const stack = getExtendsStack(__extends, context, nameStack, componentNameMap);
|
|
1101
|
+
ref.__extendsStack = stack;
|
|
1102
|
+
ref.__extendsNames = nameStack;
|
|
1103
|
+
} else {
|
|
1104
|
+
const stack = getExtendsStack(__extends, context);
|
|
1105
|
+
ref.__extendsStack = stack;
|
|
1106
|
+
}
|
|
1056
1107
|
return ref.__extendsStack;
|
|
1057
1108
|
};
|
|
1058
1109
|
var finalizeExtends = (element, parent, options = {}) => {
|
|
1059
1110
|
const { __ref: ref } = element;
|
|
1060
1111
|
const { __extendsStack } = ref;
|
|
1061
|
-
|
|
1062
|
-
|
|
1112
|
+
if (isSourcemapEnabled(options)) {
|
|
1113
|
+
const sourcemapAcc = {};
|
|
1114
|
+
const extendNames = ref.__extendsNames || [];
|
|
1115
|
+
const flattenExtends = cloneAndMergeArrayExtend(__extendsStack, sourcemapAcc, extendNames);
|
|
1116
|
+
const appliedSourcemap = {};
|
|
1117
|
+
deepMergeExtends(element, flattenExtends, appliedSourcemap, void 0, sourcemapAcc);
|
|
1118
|
+
ref.__sourcemap = appliedSourcemap;
|
|
1119
|
+
} else {
|
|
1120
|
+
const flattenExtends = cloneAndMergeArrayExtend(__extendsStack);
|
|
1121
|
+
deepMergeExtends(element, flattenExtends);
|
|
1122
|
+
}
|
|
1123
|
+
return element;
|
|
1063
1124
|
};
|
|
1064
1125
|
var applyExtends = (element, parent, options = {}) => {
|
|
1065
1126
|
createElementExtends(element, parent, options);
|
|
@@ -1098,6 +1159,30 @@ var Domql = (() => {
|
|
|
1098
1159
|
// ../utils/dist/esm/props.js
|
|
1099
1160
|
var RE_UPPER = /^[A-Z]/;
|
|
1100
1161
|
var RE_DIGITS = /^\d+$/;
|
|
1162
|
+
var ELEMENT_INDICATOR_KEYS = /* @__PURE__ */ new Set([
|
|
1163
|
+
"extend",
|
|
1164
|
+
"props",
|
|
1165
|
+
"text",
|
|
1166
|
+
"tag",
|
|
1167
|
+
"on",
|
|
1168
|
+
"if",
|
|
1169
|
+
"childExtend",
|
|
1170
|
+
"children",
|
|
1171
|
+
"childrenAs",
|
|
1172
|
+
"state",
|
|
1173
|
+
"html",
|
|
1174
|
+
"attr",
|
|
1175
|
+
"define",
|
|
1176
|
+
"content"
|
|
1177
|
+
]);
|
|
1178
|
+
var looksLikeElement = (value) => {
|
|
1179
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
1180
|
+
for (const k in value) {
|
|
1181
|
+
if (ELEMENT_INDICATOR_KEYS.has(k)) return true;
|
|
1182
|
+
if (RE_UPPER.test(k)) return true;
|
|
1183
|
+
}
|
|
1184
|
+
return false;
|
|
1185
|
+
};
|
|
1101
1186
|
var createProps = (element, parent, key) => {
|
|
1102
1187
|
const { props, __ref: ref } = element;
|
|
1103
1188
|
ref.__propsStack = [];
|
|
@@ -1122,7 +1207,7 @@ var Domql = (() => {
|
|
|
1122
1207
|
}
|
|
1123
1208
|
const hasDefine = isObject(this.define?.[key]);
|
|
1124
1209
|
const hasGlobalDefine = isObject(this.context?.define?.[key]);
|
|
1125
|
-
const isElement = RE_UPPER.test(key) || RE_DIGITS.test(key);
|
|
1210
|
+
const isElement = RE_UPPER.test(key) || RE_DIGITS.test(key) || looksLikeElement(value);
|
|
1126
1211
|
const isBuiltin = DOMQ_PROPERTIES.has(key);
|
|
1127
1212
|
if (!isElement && !isBuiltin && !hasDefine && !hasGlobalDefine) {
|
|
1128
1213
|
obj.props[key] = value;
|
|
@@ -2130,7 +2215,8 @@ ${element}` : "";
|
|
|
2130
2215
|
}
|
|
2131
2216
|
};
|
|
2132
2217
|
var startFrameLoop = (frameListeners) => {
|
|
2133
|
-
|
|
2218
|
+
const raf = typeof window !== "undefined" && window.requestAnimationFrame;
|
|
2219
|
+
if (_frameRunning || !raf) return;
|
|
2134
2220
|
_frameRunning = true;
|
|
2135
2221
|
function requestFrame() {
|
|
2136
2222
|
if (frameListeners.size === 0) {
|
|
@@ -2138,9 +2224,9 @@ ${element}` : "";
|
|
|
2138
2224
|
return;
|
|
2139
2225
|
}
|
|
2140
2226
|
processFrameListeners(frameListeners);
|
|
2141
|
-
|
|
2227
|
+
raf(requestFrame);
|
|
2142
2228
|
}
|
|
2143
|
-
|
|
2229
|
+
raf(requestFrame);
|
|
2144
2230
|
};
|
|
2145
2231
|
var applyAnimationFrame = (element) => {
|
|
2146
2232
|
if (!element) {
|
|
@@ -2518,7 +2604,7 @@ ${element}` : "";
|
|
|
2518
2604
|
|
|
2519
2605
|
// ../element/dist/esm/mixins/html.js
|
|
2520
2606
|
function html(param, element, node) {
|
|
2521
|
-
const prop = exec(element?.props?.html
|
|
2607
|
+
const prop = exec(param ?? element?.props?.html, element);
|
|
2522
2608
|
const { __ref } = element;
|
|
2523
2609
|
if (prop !== __ref.__html) {
|
|
2524
2610
|
if (node.nodeName === "SVG") node.textContent = prop;
|
|
@@ -2848,7 +2934,7 @@ ${element}` : "";
|
|
|
2848
2934
|
}
|
|
2849
2935
|
return;
|
|
2850
2936
|
}
|
|
2851
|
-
if (!params) return element;
|
|
2937
|
+
if (!params || typeof params !== "object") return element;
|
|
2852
2938
|
let { childExtends, props, tag } = params;
|
|
2853
2939
|
if (!props) props = params.props = {};
|
|
2854
2940
|
if (tag === "fragment") {
|
|
@@ -3467,6 +3553,34 @@ ${element}` : "";
|
|
|
3467
3553
|
triggerEventOn("update", element, options);
|
|
3468
3554
|
}
|
|
3469
3555
|
};
|
|
3556
|
+
var findSiblingAttachOptions = (element, parent) => {
|
|
3557
|
+
const { __children } = parent.__ref || {};
|
|
3558
|
+
if (!__children) return false;
|
|
3559
|
+
const currentIndex = __children.indexOf(element.key);
|
|
3560
|
+
let previousNode;
|
|
3561
|
+
for (let i = currentIndex - 1; i >= 0; i--) {
|
|
3562
|
+
const sibling = parent[__children[i]];
|
|
3563
|
+
if (sibling?.node?.parentNode) {
|
|
3564
|
+
previousNode = sibling.node;
|
|
3565
|
+
break;
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
if (previousNode) {
|
|
3569
|
+
return { position: "after", node: previousNode };
|
|
3570
|
+
}
|
|
3571
|
+
let nextNode;
|
|
3572
|
+
for (let i = currentIndex + 1; i < __children.length; i++) {
|
|
3573
|
+
const sibling = parent[__children[i]];
|
|
3574
|
+
if (sibling?.node?.parentNode) {
|
|
3575
|
+
nextNode = sibling.node;
|
|
3576
|
+
break;
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
if (nextNode) {
|
|
3580
|
+
return { position: "before", node: nextNode };
|
|
3581
|
+
}
|
|
3582
|
+
return false;
|
|
3583
|
+
};
|
|
3470
3584
|
var checkIfOnUpdate = (element, parent, options) => {
|
|
3471
3585
|
if (!isFunction(element.if) && !isFunction(element.props?.if) || !parent) {
|
|
3472
3586
|
return;
|
|
@@ -3503,16 +3617,7 @@ ${element}` : "";
|
|
|
3503
3617
|
} else if (element[contentKey]?.parseDeep) {
|
|
3504
3618
|
element[contentKey] = element[contentKey].parseDeep();
|
|
3505
3619
|
}
|
|
3506
|
-
const
|
|
3507
|
-
const previousNode = previousElement2?.node;
|
|
3508
|
-
const hasPrevious = previousNode?.parentNode;
|
|
3509
|
-
const nextElement2 = element.nextElement();
|
|
3510
|
-
const nextNode = nextElement2?.node;
|
|
3511
|
-
const hasNext = nextNode?.parentNode;
|
|
3512
|
-
const attachOptions = (hasPrevious || hasNext) && {
|
|
3513
|
-
position: hasPrevious ? "after" : hasNext ? "before" : null,
|
|
3514
|
-
node: hasPrevious && previousNode || hasNext && nextNode
|
|
3515
|
-
};
|
|
3620
|
+
const attachOptions = findSiblingAttachOptions(element, parent);
|
|
3516
3621
|
delete element.__ref;
|
|
3517
3622
|
delete element.parent;
|
|
3518
3623
|
const createdElement = create(
|
|
@@ -4620,7 +4725,9 @@ ${element}` : "";
|
|
|
4620
4725
|
};
|
|
4621
4726
|
var addElementIntoParentChildren = (element, parent) => {
|
|
4622
4727
|
if (parent.__ref && parent.__ref.__children) {
|
|
4623
|
-
parent.__ref.__children.
|
|
4728
|
+
if (!parent.__ref.__children.includes(element.key)) {
|
|
4729
|
+
parent.__ref.__children.push(element.key);
|
|
4730
|
+
}
|
|
4624
4731
|
}
|
|
4625
4732
|
};
|
|
4626
4733
|
var _uniqIdCounter = 1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "domql",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/esm/index.js",
|
|
11
|
-
"require": "./dist/cjs/index.js"
|
|
12
|
-
"browser": "./dist/esm/index.js",
|
|
13
|
-
"default": "./dist/esm/index.js"
|
|
11
|
+
"require": "./dist/cjs/index.js"
|
|
14
12
|
}
|
|
15
13
|
},
|
|
16
14
|
"source": "index.js",
|
|
@@ -27,13 +25,16 @@
|
|
|
27
25
|
"build:iife": "cross-env NODE_ENV=$NODE_ENV esbuild index.js --bundle --target=es2020 --format=iife --global-name=Domql --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV"
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"@domql/element": "^3.
|
|
31
|
-
"@domql/state": "^3.
|
|
32
|
-
"@domql/utils": "^3.
|
|
28
|
+
"@domql/element": "^3.6.1",
|
|
29
|
+
"@domql/state": "^3.6.1",
|
|
30
|
+
"@domql/utils": "^3.6.1"
|
|
33
31
|
},
|
|
34
32
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
35
33
|
"browser": "./dist/esm/index.js",
|
|
36
34
|
"unpkg": "./dist/iife/index.js",
|
|
37
35
|
"jsdelivr": "./dist/iife/index.js",
|
|
38
|
-
"sideEffects": false
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
39
40
|
}
|