@domql/element 3.1.2 → 3.2.7
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/README.md +4 -6
- package/children.js +45 -18
- package/create.js +58 -46
- package/define.js +1 -1
- package/dist/cjs/children.js +43 -13
- package/dist/cjs/create.js +57 -27
- package/dist/cjs/define.js +1 -1
- package/dist/cjs/event/animationFrame.js +96 -0
- package/dist/cjs/event/can.js +28 -0
- package/dist/cjs/event/index.js +20 -0
- package/dist/cjs/event/on.js +84 -0
- package/dist/cjs/event/store.js +27 -0
- package/dist/cjs/extend.js +88 -0
- package/dist/cjs/index.js +9 -6
- package/dist/cjs/iterate.js +89 -33
- package/dist/cjs/methods/set.js +5 -0
- package/dist/cjs/methods/v2.js +1 -1
- package/dist/cjs/mixins/attr.js +3 -2
- package/dist/cjs/mixins/classList.js +11 -1
- package/dist/cjs/mixins/content.js +72 -0
- package/dist/cjs/mixins/html.js +1 -2
- package/dist/cjs/mixins/registry.js +2 -2
- package/dist/cjs/mixins/scope.js +1 -1
- package/dist/cjs/mixins/state.js +4 -4
- package/dist/cjs/mixins/style.js +11 -2
- package/dist/cjs/mixins/text.js +9 -5
- package/dist/cjs/node.js +22 -19
- package/dist/cjs/render/append.js +72 -0
- package/dist/cjs/render/cache.js +80 -0
- package/dist/cjs/render/create.js +25 -0
- package/dist/cjs/render/index.js +20 -0
- package/dist/cjs/set.js +33 -40
- package/dist/cjs/update.js +100 -69
- package/dist/cjs/utils/applyParam.js +7 -7
- package/dist/cjs/utils/extendUtils.js +132 -0
- package/dist/cjs/utils/index.js +2 -0
- package/dist/cjs/utils/propEvents.js +56 -0
- package/dist/esm/children.js +44 -14
- package/dist/esm/create.js +58 -27
- package/dist/esm/define.js +1 -1
- package/dist/esm/event/animationFrame.js +76 -0
- package/dist/esm/event/can.js +8 -0
- package/dist/esm/event/index.js +3 -0
- package/dist/esm/event/on.js +64 -0
- package/dist/esm/event/store.js +7 -0
- package/dist/esm/extend.js +74 -0
- package/dist/esm/index.js +8 -6
- package/dist/esm/iterate.js +90 -35
- package/dist/esm/methods/set.js +10 -0
- package/dist/esm/methods/v2.js +1 -1
- package/dist/esm/mixins/attr.js +4 -3
- package/dist/esm/mixins/classList.js +11 -1
- package/dist/esm/mixins/content.js +52 -0
- package/dist/esm/mixins/html.js +1 -2
- package/dist/esm/mixins/registry.js +1 -1
- package/dist/esm/mixins/scope.js +1 -1
- package/dist/esm/mixins/state.js +5 -5
- package/dist/esm/mixins/style.js +12 -3
- package/dist/esm/mixins/text.js +10 -6
- package/dist/esm/node.js +22 -19
- package/dist/esm/render/append.js +52 -0
- package/dist/esm/render/cache.js +60 -0
- package/dist/esm/render/create.js +5 -0
- package/dist/esm/render/index.js +3 -0
- package/dist/esm/set.js +34 -41
- package/dist/esm/update.js +100 -71
- package/dist/esm/utils/applyParam.js +8 -8
- package/dist/esm/utils/extendUtils.js +119 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/propEvents.js +36 -0
- package/dist/iife/index.js +4718 -0
- package/extend.js +95 -0
- package/index.js +9 -6
- package/iterate.js +100 -38
- package/node.js +25 -23
- package/package.json +44 -20
- package/set.js +28 -32
- package/update.js +111 -82
- package/__tests__/checkIfOnUpdate.test.js +0 -103
- package/__tests__/children.test.js +0 -213
- package/__tests__/define.test.js +0 -75
- package/__tests__/inheritStateUpdates.test.js +0 -79
- package/__tests__/renderElement.test.js +0 -131
- package/__tests__/resetElement.test.js +0 -44
- package/__tests__/set.test.js +0 -316
- package/__tests__/throughExecProps.test.js +0 -86
- package/__tests__/throughInitialDefine.test.js +0 -104
- package/__tests__/throughInitialExec.test.js +0 -92
- package/__tests__/throughUpdatedDefine.test.js +0 -92
- package/__tests__/throughUpdatedExec.test.js +0 -110
- package/__tests__/tree.test.js +0 -15
- package/__tests__/update.test.js +0 -256
- package/dist/cjs/__tests__/checkIfOnUpdate.test.js +0 -73
- package/dist/cjs/__tests__/children.test.js +0 -177
- package/dist/cjs/__tests__/define.test.js +0 -75
- package/dist/cjs/__tests__/inheritStateUpdates.test.js +0 -62
- package/dist/cjs/__tests__/renderElement.test.js +0 -138
- package/dist/cjs/__tests__/resetElement.test.js +0 -35
- package/dist/cjs/__tests__/set.test.js +0 -256
- package/dist/cjs/__tests__/throughExecProps.test.js +0 -62
- package/dist/cjs/__tests__/throughInitialDefine.test.js +0 -79
- package/dist/cjs/__tests__/throughInitialExec.test.js +0 -73
- package/dist/cjs/__tests__/throughUpdatedDefine.test.js +0 -69
- package/dist/cjs/__tests__/throughUpdatedExec.test.js +0 -84
- package/dist/cjs/__tests__/tree.test.js +0 -11
- package/dist/cjs/__tests__/update.test.js +0 -222
- package/dist/cjs/package.json +0 -4
- package/dist/esm/__tests__/checkIfOnUpdate.test.js +0 -73
- package/dist/esm/__tests__/children.test.js +0 -177
- package/dist/esm/__tests__/define.test.js +0 -53
- package/dist/esm/__tests__/inheritStateUpdates.test.js +0 -62
- package/dist/esm/__tests__/renderElement.test.js +0 -116
- package/dist/esm/__tests__/resetElement.test.js +0 -35
- package/dist/esm/__tests__/set.test.js +0 -256
- package/dist/esm/__tests__/throughExecProps.test.js +0 -62
- package/dist/esm/__tests__/throughInitialDefine.test.js +0 -79
- package/dist/esm/__tests__/throughInitialExec.test.js +0 -73
- package/dist/esm/__tests__/throughUpdatedDefine.test.js +0 -69
- package/dist/esm/__tests__/throughUpdatedExec.test.js +0 -84
- package/dist/esm/__tests__/tree.test.js +0 -11
- package/dist/esm/__tests__/update.test.js +0 -222
- package/methods/set.js +0 -63
- package/methods/v2.js +0 -83
- package/mixins/attr.js +0 -32
- package/mixins/classList.js +0 -54
- package/mixins/data.js +0 -26
- package/mixins/html.js +0 -21
- package/mixins/index.js +0 -23
- package/mixins/registry.js +0 -46
- package/mixins/scope.js +0 -23
- package/mixins/state.js +0 -19
- package/mixins/style.js +0 -16
- package/mixins/text.js +0 -26
- package/utils/applyParam.js +0 -34
- package/utils/index.js +0 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var animationFrame_exports = {};
|
|
20
|
+
__export(animationFrame_exports, {
|
|
21
|
+
applyAnimationFrame: () => applyAnimationFrame,
|
|
22
|
+
initAnimationFrame: () => initAnimationFrame,
|
|
23
|
+
registerFrameListener: () => registerFrameListener
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(animationFrame_exports);
|
|
26
|
+
const registerFrameListener = (el) => {
|
|
27
|
+
if (!el || !el.__ref) {
|
|
28
|
+
throw new Error("Element reference is invalid");
|
|
29
|
+
}
|
|
30
|
+
const { __ref: ref } = el;
|
|
31
|
+
if (!ref.root) {
|
|
32
|
+
throw new Error("Root reference is invalid");
|
|
33
|
+
}
|
|
34
|
+
if (!ref.root.data) {
|
|
35
|
+
throw new Error("Data are undefined");
|
|
36
|
+
}
|
|
37
|
+
const { frameListeners } = ref.root.data;
|
|
38
|
+
if (frameListeners && !frameListeners.has(el)) {
|
|
39
|
+
frameListeners.add(el);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const processFrameListeners = (frameListeners) => {
|
|
43
|
+
for (const element of frameListeners) {
|
|
44
|
+
if (!element.__ref.__frameHandler) {
|
|
45
|
+
const handler = element.on?.frame || element.onFrame || element.props?.onFrame;
|
|
46
|
+
if (handler) element.__ref.__frameHandler = handler;
|
|
47
|
+
else {
|
|
48
|
+
frameListeners.delete(element);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!element.node?.parentNode) {
|
|
53
|
+
frameListeners.delete(element);
|
|
54
|
+
delete element.__ref.__frameHandler;
|
|
55
|
+
} else {
|
|
56
|
+
try {
|
|
57
|
+
element.__ref.__frameHandler(element, element.state, element.context);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
console.warn(e);
|
|
60
|
+
frameListeners.delete(element);
|
|
61
|
+
delete element.__ref.__frameHandler;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const startFrameLoop = (frameListeners) => {
|
|
67
|
+
if (_frameRunning) return;
|
|
68
|
+
_frameRunning = true;
|
|
69
|
+
function requestFrame() {
|
|
70
|
+
if (frameListeners.size === 0) {
|
|
71
|
+
_frameRunning = false;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
processFrameListeners(frameListeners);
|
|
75
|
+
window.requestAnimationFrame(requestFrame);
|
|
76
|
+
}
|
|
77
|
+
window.requestAnimationFrame(requestFrame);
|
|
78
|
+
};
|
|
79
|
+
const applyAnimationFrame = (element) => {
|
|
80
|
+
if (!element) {
|
|
81
|
+
throw new Error("Element is invalid");
|
|
82
|
+
}
|
|
83
|
+
const { on, props, __ref: ref } = element;
|
|
84
|
+
if (!ref.root || !ref.root.data) return;
|
|
85
|
+
const { frameListeners } = ref.root.data;
|
|
86
|
+
if (frameListeners && (on?.frame || element.onFrame || props?.onFrame)) {
|
|
87
|
+
registerFrameListener(element);
|
|
88
|
+
startFrameLoop(frameListeners);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
let _frameRunning = false;
|
|
92
|
+
const initAnimationFrame = () => {
|
|
93
|
+
const frameListeners = /* @__PURE__ */ new Set();
|
|
94
|
+
startFrameLoop(frameListeners);
|
|
95
|
+
return frameListeners;
|
|
96
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var can_exports = {};
|
|
20
|
+
__export(can_exports, {
|
|
21
|
+
canRenderTag: () => canRenderTag
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(can_exports);
|
|
24
|
+
var import_report = require("@domql/report");
|
|
25
|
+
var import_utils = require("@domql/utils");
|
|
26
|
+
const canRenderTag = (tag) => {
|
|
27
|
+
return (0, import_utils.isValidHtmlTag)(tag || "div") || (0, import_report.report)("HTMLInvalidTag");
|
|
28
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var event_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(event_exports);
|
|
18
|
+
__reExport(event_exports, require("./on.js"), module.exports);
|
|
19
|
+
__reExport(event_exports, require("./can.js"), module.exports);
|
|
20
|
+
__reExport(event_exports, require("./animationFrame.js"), module.exports);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var on_exports = {};
|
|
20
|
+
__export(on_exports, {
|
|
21
|
+
applyEvent: () => import_utils2.applyEvent,
|
|
22
|
+
applyEventUpdate: () => import_utils2.applyEventUpdate,
|
|
23
|
+
applyEventsOnNode: () => applyEventsOnNode,
|
|
24
|
+
triggerEventOn: () => import_utils2.triggerEventOn,
|
|
25
|
+
triggerEventOnUpdate: () => import_utils2.triggerEventOnUpdate
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(on_exports);
|
|
28
|
+
var import_utils = require("@domql/utils");
|
|
29
|
+
var import_utils2 = require("@domql/utils");
|
|
30
|
+
const getOnOrPropsEvent = (param, element) => {
|
|
31
|
+
const onEvent = element.on?.[param];
|
|
32
|
+
if (onEvent) return onEvent;
|
|
33
|
+
const props = element.props;
|
|
34
|
+
if (!props) return;
|
|
35
|
+
const propKey = "on" + param.charAt(0).toUpperCase() + param.slice(1);
|
|
36
|
+
return props[propKey];
|
|
37
|
+
};
|
|
38
|
+
const registerNodeEvent = (param, element, node, options) => {
|
|
39
|
+
const appliedFunction = getOnOrPropsEvent(param, element);
|
|
40
|
+
if ((0, import_utils.isFunction)(appliedFunction)) {
|
|
41
|
+
const { __ref: ref } = element;
|
|
42
|
+
if (!ref.__eventListeners) ref.__eventListeners = {};
|
|
43
|
+
if (ref.__eventListeners[param]) {
|
|
44
|
+
node.removeEventListener(param, ref.__eventListeners[param]);
|
|
45
|
+
}
|
|
46
|
+
const handler = (event) => {
|
|
47
|
+
const { state, context } = element;
|
|
48
|
+
const result = appliedFunction.call(
|
|
49
|
+
element,
|
|
50
|
+
event,
|
|
51
|
+
element,
|
|
52
|
+
state,
|
|
53
|
+
context,
|
|
54
|
+
options
|
|
55
|
+
);
|
|
56
|
+
if (result && typeof result.then === "function") {
|
|
57
|
+
result.catch(() => {
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
ref.__eventListeners[param] = handler;
|
|
62
|
+
node.addEventListener(param, handler);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const applyEventsOnNode = (element, options) => {
|
|
66
|
+
const { node, on, props } = element;
|
|
67
|
+
const handled = /* @__PURE__ */ new Set();
|
|
68
|
+
for (const param in on) {
|
|
69
|
+
if (import_utils.DOMQL_EVENTS.has(param)) continue;
|
|
70
|
+
handled.add(param);
|
|
71
|
+
registerNodeEvent(param, element, node, options);
|
|
72
|
+
}
|
|
73
|
+
if (props) {
|
|
74
|
+
for (const key in props) {
|
|
75
|
+
if (key.length > 2 && key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && (0, import_utils.isFunction)(props[key])) {
|
|
76
|
+
const thirdChar = key[2];
|
|
77
|
+
if (thirdChar !== thirdChar.toUpperCase()) continue;
|
|
78
|
+
const eventName = thirdChar.toLowerCase() + key.slice(3);
|
|
79
|
+
if (handled.has(eventName) || import_utils.DOMQL_EVENTS.has(eventName)) continue;
|
|
80
|
+
registerNodeEvent(eventName, element, node, options);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var store_exports = {};
|
|
20
|
+
__export(store_exports, {
|
|
21
|
+
default: () => store_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(store_exports);
|
|
24
|
+
var store_default = {
|
|
25
|
+
click: [],
|
|
26
|
+
render: []
|
|
27
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var extend_exports = {};
|
|
20
|
+
__export(extend_exports, {
|
|
21
|
+
applyExtend: () => applyExtend
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(extend_exports);
|
|
24
|
+
var import_utils = require("@domql/utils");
|
|
25
|
+
var import_utils2 = require("./utils/index.js");
|
|
26
|
+
let mainExtend;
|
|
27
|
+
const applyExtend = (element, parent, options = {}) => {
|
|
28
|
+
if ((0, import_utils.isFunction)(element)) element = (0, import_utils.exec)(element, parent);
|
|
29
|
+
const { props, __ref } = element;
|
|
30
|
+
let extend = props?.extends || element.extends || element.extend;
|
|
31
|
+
const variant = props?.variant;
|
|
32
|
+
const context = element.context || parent.context;
|
|
33
|
+
extend = (0, import_utils2.fallbackStringExtend)(extend, context, options, variant);
|
|
34
|
+
const extendStack = (0, import_utils2.getExtendStack)(extend, context);
|
|
35
|
+
delete element.extend;
|
|
36
|
+
let childExtendStack = [];
|
|
37
|
+
if (parent) {
|
|
38
|
+
element.parent = parent;
|
|
39
|
+
if (!options.ignoreChildExtend && !props?.ignoreChildExtend) {
|
|
40
|
+
childExtendStack = (0, import_utils2.getExtendStack)(parent.childExtend, context);
|
|
41
|
+
const ignoreChildExtendRecursive = props?.ignoreChildExtendRecursive;
|
|
42
|
+
if (parent.childExtendRecursive && !ignoreChildExtendRecursive) {
|
|
43
|
+
const canExtendRecursive = element.key !== "__text";
|
|
44
|
+
if (canExtendRecursive) {
|
|
45
|
+
const childExtendRecursiveStack = (0, import_utils2.getExtendStack)(
|
|
46
|
+
parent.childExtendRecursive,
|
|
47
|
+
context
|
|
48
|
+
);
|
|
49
|
+
childExtendStack = childExtendStack.concat(childExtendRecursiveStack);
|
|
50
|
+
element.childExtendRecursive = parent.childExtendRecursive;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const extendLength = extendStack.length;
|
|
56
|
+
const childExtendLength = childExtendStack.length;
|
|
57
|
+
let stack = [];
|
|
58
|
+
if (extendLength && childExtendLength) {
|
|
59
|
+
stack = (0, import_utils2.jointStacks)(extendStack, childExtendStack);
|
|
60
|
+
} else if (extendLength) {
|
|
61
|
+
stack = extendStack;
|
|
62
|
+
} else if (childExtendLength) {
|
|
63
|
+
stack = childExtendStack;
|
|
64
|
+
} else if (!context.defaultExtends) return element;
|
|
65
|
+
if (context.defaultExtends) {
|
|
66
|
+
if (!mainExtend) {
|
|
67
|
+
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(
|
|
68
|
+
context.defaultExtends,
|
|
69
|
+
context
|
|
70
|
+
);
|
|
71
|
+
mainExtend = (0, import_utils2.cloneAndMergeArrayExtend)(defaultOptionsExtend);
|
|
72
|
+
delete mainExtend.extend;
|
|
73
|
+
}
|
|
74
|
+
stack = [].concat(stack, mainExtend);
|
|
75
|
+
}
|
|
76
|
+
if (__ref) __ref.__extend = stack;
|
|
77
|
+
let mergedExtend = (0, import_utils2.cloneAndMergeArrayExtend)(stack);
|
|
78
|
+
const COMPONENTS = context?.components || options.components;
|
|
79
|
+
const component = (0, import_utils.exec)(element.component || mergedExtend.component, element);
|
|
80
|
+
if (component && COMPONENTS?.[component]) {
|
|
81
|
+
const componentExtend = (0, import_utils2.cloneAndMergeArrayExtend)(
|
|
82
|
+
(0, import_utils2.getExtendStack)(COMPONENTS[component])
|
|
83
|
+
);
|
|
84
|
+
mergedExtend = (0, import_utils2.deepMergeExtend)(componentExtend, mergedExtend);
|
|
85
|
+
}
|
|
86
|
+
const merged = (0, import_utils2.deepMergeExtend)(element, mergedExtend);
|
|
87
|
+
return merged;
|
|
88
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
21
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
22
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
23
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -36,9 +37,11 @@ __export(index_exports, {
|
|
|
36
37
|
update: () => import_update.default
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(index_exports);
|
|
39
|
-
var import_tree = require("./tree");
|
|
40
|
-
var import_create = __toESM(require("./create"), 1);
|
|
41
|
-
var import_node = __toESM(require("./node"), 1);
|
|
42
|
-
var import_define = __toESM(require("./define"), 1);
|
|
43
|
-
var import_update = __toESM(require("./update"), 1);
|
|
44
|
-
var import_set = __toESM(require("./set"), 1);
|
|
40
|
+
var import_tree = require("./tree.js");
|
|
41
|
+
var import_create = __toESM(require("./create.js"), 1);
|
|
42
|
+
var import_node = __toESM(require("./node.js"), 1);
|
|
43
|
+
var import_define = __toESM(require("./define.js"), 1);
|
|
44
|
+
var import_update = __toESM(require("./update.js"), 1);
|
|
45
|
+
var import_set = __toESM(require("./set.js"), 1);
|
|
46
|
+
__reExport(index_exports, require("./event/index.js"), module.exports);
|
|
47
|
+
__reExport(index_exports, require("./render/index.js"), module.exports);
|
package/dist/cjs/iterate.js
CHANGED
|
@@ -18,7 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var iterate_exports = {};
|
|
20
20
|
__export(iterate_exports, {
|
|
21
|
-
isPropertyInDefines: () => isPropertyInDefines,
|
|
22
21
|
throughExecProps: () => throughExecProps,
|
|
23
22
|
throughInitialDefine: () => throughInitialDefine,
|
|
24
23
|
throughInitialExec: () => throughInitialExec,
|
|
@@ -27,14 +26,21 @@ __export(iterate_exports, {
|
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(iterate_exports);
|
|
29
28
|
var import_utils = require("@domql/utils");
|
|
30
|
-
const throughInitialExec =
|
|
29
|
+
const throughInitialExec = (element, exclude = {}) => {
|
|
31
30
|
const { __ref: ref } = element;
|
|
32
31
|
for (const param in element) {
|
|
33
32
|
if (exclude[param]) continue;
|
|
34
33
|
const prop = element[param];
|
|
35
34
|
if ((0, import_utils.isFunction)(prop) && !(0, import_utils.isMethod)(param, element)) {
|
|
36
35
|
ref.__exec[param] = prop;
|
|
37
|
-
|
|
36
|
+
const result = prop(element, element.state, element.context);
|
|
37
|
+
if (result && typeof result.then === "function") {
|
|
38
|
+
result.then((resolved) => {
|
|
39
|
+
element[param] = resolved;
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
element[param] = result;
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
};
|
|
@@ -46,8 +52,14 @@ const throughUpdatedExec = (element, options = {}) => {
|
|
|
46
52
|
const isDefinedParam = ref.__defineCache[param];
|
|
47
53
|
if (isDefinedParam) continue;
|
|
48
54
|
const newExec = ref.__exec[param](element, element.state, element.context);
|
|
55
|
+
if (newExec && typeof newExec.then === "function") {
|
|
56
|
+
newExec.then((resolved) => {
|
|
57
|
+
element[param] = resolved;
|
|
58
|
+
});
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
49
61
|
const execReturnsString = (0, import_utils.isString)(newExec) || (0, import_utils.isNumber)(newExec);
|
|
50
|
-
if (prop
|
|
62
|
+
if (prop?.node && execReturnsString) {
|
|
51
63
|
(0, import_utils.overwrite)(prop, { text: newExec });
|
|
52
64
|
} else if (newExec !== prop) {
|
|
53
65
|
if ((0, import_utils.matchesComponentNaming)(param)) {
|
|
@@ -65,66 +77,110 @@ const throughUpdatedExec = (element, options = {}) => {
|
|
|
65
77
|
}
|
|
66
78
|
return changes;
|
|
67
79
|
};
|
|
68
|
-
const throughExecProps =
|
|
80
|
+
const throughExecProps = (element) => {
|
|
69
81
|
const { __ref: ref } = element;
|
|
70
82
|
const { props } = element;
|
|
71
83
|
for (const k in props) {
|
|
72
|
-
const
|
|
84
|
+
const c0 = k.charCodeAt(0);
|
|
85
|
+
const c1 = k.charCodeAt(1);
|
|
86
|
+
const isDefine = c0 === 105 && c1 === 115 || // 'is'
|
|
87
|
+
c0 === 104 && c1 === 97 && k.charCodeAt(2) === 115 || // 'has'
|
|
88
|
+
c0 === 117 && c1 === 115 && k.charCodeAt(2) === 101;
|
|
73
89
|
const cachedExecProp = ref.__execProps[k];
|
|
74
90
|
if ((0, import_utils.isFunction)(cachedExecProp)) {
|
|
75
|
-
|
|
91
|
+
const result = (0, import_utils.exec)(cachedExecProp, element);
|
|
92
|
+
if (result && typeof result.then === "function") {
|
|
93
|
+
result.then((resolved) => {
|
|
94
|
+
props[k] = resolved;
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
props[k] = result;
|
|
98
|
+
}
|
|
76
99
|
} else if (isDefine && (0, import_utils.isFunction)(props[k])) {
|
|
77
100
|
ref.__execProps[k] = props[k];
|
|
78
|
-
|
|
101
|
+
const result = (0, import_utils.exec)(props[k], element);
|
|
102
|
+
if (result && typeof result.then === "function") {
|
|
103
|
+
result.then((resolved) => {
|
|
104
|
+
props[k] = resolved;
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
props[k] = result;
|
|
108
|
+
}
|
|
79
109
|
}
|
|
80
110
|
}
|
|
81
111
|
};
|
|
82
|
-
const
|
|
83
|
-
};
|
|
84
|
-
const throughInitialDefine = async (element) => {
|
|
112
|
+
const throughInitialDefine = (element) => {
|
|
85
113
|
const { define, context, __ref: ref } = element;
|
|
86
|
-
|
|
114
|
+
const hasLocalDefine = (0, import_utils.isObject)(define);
|
|
87
115
|
const hasGlobalDefine = context && (0, import_utils.isObject)(context.define);
|
|
88
|
-
if (
|
|
89
|
-
|
|
116
|
+
if (!hasLocalDefine && !hasGlobalDefine) return element;
|
|
117
|
+
const defineObj = hasLocalDefine && hasGlobalDefine ? { ...define, ...context.define } : hasLocalDefine ? define : context.define;
|
|
90
118
|
for (const param in defineObj) {
|
|
91
119
|
let elementProp = element[param];
|
|
92
120
|
if ((0, import_utils.isFunction)(elementProp) && !(0, import_utils.isMethod)(param, element)) {
|
|
93
121
|
ref.__exec[param] = elementProp;
|
|
94
|
-
|
|
95
|
-
if (execParam2) {
|
|
96
|
-
|
|
97
|
-
|
|
122
|
+
let execParam2 = (0, import_utils.exec)(elementProp, element);
|
|
123
|
+
if (execParam2 && typeof execParam2.then === "function") {
|
|
124
|
+
execParam2.then((resolved) => {
|
|
125
|
+
elementProp = element[param] = resolved && resolved.parse ? resolved.parse() : resolved;
|
|
126
|
+
if (resolved) {
|
|
127
|
+
ref.__defineCache[param] = elementProp;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
} else {
|
|
131
|
+
elementProp = element[param] = execParam2 && execParam2.parse ? execParam2.parse() : execParam2;
|
|
132
|
+
if (execParam2) {
|
|
133
|
+
ref.__defineCache[param] = elementProp;
|
|
134
|
+
}
|
|
98
135
|
}
|
|
99
136
|
}
|
|
100
|
-
const execParam =
|
|
137
|
+
const execParam = defineObj[param](
|
|
101
138
|
elementProp,
|
|
102
139
|
element,
|
|
103
140
|
element.state,
|
|
104
141
|
element.context
|
|
105
142
|
);
|
|
106
|
-
if (execParam
|
|
143
|
+
if (execParam && typeof execParam.then === "function") {
|
|
144
|
+
execParam.then((resolved) => {
|
|
145
|
+
if (resolved) element[param] = resolved;
|
|
146
|
+
});
|
|
147
|
+
} else if (execParam) {
|
|
148
|
+
element[param] = execParam;
|
|
149
|
+
}
|
|
107
150
|
}
|
|
108
151
|
return element;
|
|
109
152
|
};
|
|
110
|
-
const throughUpdatedDefine =
|
|
153
|
+
const throughUpdatedDefine = (element) => {
|
|
111
154
|
const { context, define, __ref: ref } = element;
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
|
|
155
|
+
const hasLocalDefine = (0, import_utils.isObject)(define);
|
|
156
|
+
const hasGlobalDefine = (0, import_utils.isObject)(context?.define);
|
|
157
|
+
if (!hasLocalDefine && !hasGlobalDefine) return;
|
|
158
|
+
const obj = hasLocalDefine && hasGlobalDefine ? { ...define, ...context.define } : hasLocalDefine ? define : context.define;
|
|
116
159
|
for (const param in obj) {
|
|
117
160
|
const execParam = ref.__exec[param];
|
|
118
161
|
if (execParam) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
162
|
+
const result = execParam(element, element.state, element.context);
|
|
163
|
+
if (result && typeof result.then === "function") {
|
|
164
|
+
result.then((resolved) => {
|
|
165
|
+
ref.__defineCache[param] = resolved;
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
ref.__defineCache[param] = result;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const cached = (0, import_utils.exec)(ref.__defineCache[param], element);
|
|
172
|
+
if (cached && typeof cached.then === "function") {
|
|
173
|
+
cached.then((resolved) => {
|
|
174
|
+
});
|
|
175
|
+
continue;
|
|
124
176
|
}
|
|
125
|
-
const cached = await (0, import_utils.execPromise)(ref.__defineCache[param], element);
|
|
126
177
|
const newExecParam = typeof obj[param] === "function" ? obj[param](cached, element, element.state, element.context) : void 0;
|
|
127
|
-
if (newExecParam
|
|
178
|
+
if (newExecParam && typeof newExecParam.then === "function") {
|
|
179
|
+
newExecParam.then((resolved) => {
|
|
180
|
+
element[param] = resolved;
|
|
181
|
+
});
|
|
182
|
+
} else if (newExecParam) {
|
|
183
|
+
element[param] = newExecParam;
|
|
184
|
+
}
|
|
128
185
|
}
|
|
129
|
-
return changes;
|
|
130
186
|
};
|
package/dist/cjs/methods/set.js
CHANGED
|
@@ -40,6 +40,11 @@ const addMethods = (element, parent, options = {}) => {
|
|
|
40
40
|
lookdownAll: import_methods.lookdownAll,
|
|
41
41
|
getRef: import_methods.getRef,
|
|
42
42
|
getPath: import_methods.getPath,
|
|
43
|
+
getRootState: import_methods.getRootState,
|
|
44
|
+
getRoot: import_methods.getRoot,
|
|
45
|
+
getRootData: import_methods.getRootData,
|
|
46
|
+
getRootContext: import_methods.getRootContext,
|
|
47
|
+
getContext: import_methods.getContext,
|
|
43
48
|
setNodeStyles: import_methods.setNodeStyles,
|
|
44
49
|
spotByPath: import_methods.spotByPath,
|
|
45
50
|
parse: import_methods.parse,
|
package/dist/cjs/methods/v2.js
CHANGED
|
@@ -73,7 +73,7 @@ const log = function(...args) {
|
|
|
73
73
|
args.forEach((v) => console.log(`%c${v}:
|
|
74
74
|
`, "font-weight: bold", element[v]));
|
|
75
75
|
} else {
|
|
76
|
-
console.log(__ref
|
|
76
|
+
console.log(__ref?.path);
|
|
77
77
|
const keys2 = element.keys();
|
|
78
78
|
keys2.forEach((v) => console.log(`%c${v}:
|
|
79
79
|
`, "font-weight: bold", element[v]));
|
package/dist/cjs/mixins/attr.js
CHANGED
|
@@ -27,13 +27,14 @@ var import_report = require("@domql/report");
|
|
|
27
27
|
function attr(params, element, node) {
|
|
28
28
|
const { __ref: ref, props } = element;
|
|
29
29
|
const { __attr } = ref;
|
|
30
|
-
if ((0, import_utils.isNot)("object")) (0, import_report.report)("HTMLInvalidAttr", params);
|
|
30
|
+
if ((0, import_utils.isNot)(params)("object")) (0, import_report.report)("HTMLInvalidAttr", params);
|
|
31
31
|
if (params) {
|
|
32
32
|
const attrs = (0, import_utils.exec)(params, element);
|
|
33
33
|
if (props.attr) (0, import_utils.deepMerge)(attrs, props.attr);
|
|
34
34
|
for (const attr2 in attrs) {
|
|
35
35
|
const val = (0, import_utils.exec)(attrs[attr2], element);
|
|
36
|
-
if (val
|
|
36
|
+
if (val === __attr[attr2]) continue;
|
|
37
|
+
if (val !== false && val !== void 0 && val !== null && node.setAttribute) {
|
|
37
38
|
node.setAttribute(attr2, val);
|
|
38
39
|
} else if (node.removeAttribute) node.removeAttribute(attr2);
|
|
39
40
|
__attr[attr2] = val;
|
|
@@ -57,7 +57,17 @@ const classList = (params, element) => {
|
|
|
57
57
|
};
|
|
58
58
|
const applyClassListOnNode = (params, element, node) => {
|
|
59
59
|
const className = classList(params, element);
|
|
60
|
-
|
|
60
|
+
const { __ref } = element;
|
|
61
|
+
if (className === __ref.__className) return className;
|
|
62
|
+
__ref.__className = className;
|
|
63
|
+
if (node && typeof node.setAttribute === "function") {
|
|
64
|
+
node.setAttribute("class", className);
|
|
65
|
+
} else if (node) {
|
|
66
|
+
try {
|
|
67
|
+
node.className = className;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
61
71
|
return className;
|
|
62
72
|
};
|
|
63
73
|
function applyClasslist(params, element, node) {
|