@domql/element 2.4.2 → 2.4.4
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/cjs/applyParam.js +41 -0
- package/dist/cjs/create.js +262 -0
- package/dist/cjs/define.js +34 -0
- package/dist/cjs/extend.js +87 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/iterate.js +108 -0
- package/dist/cjs/mixins/state.js +1 -1
- package/dist/cjs/node.js +85 -0
- package/dist/cjs/set.js +58 -0
- package/dist/cjs/tree.js +31 -0
- package/dist/cjs/update.js +223 -0
- package/mixins/state.js +2 -2
- package/node.js +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,41 @@
|
|
|
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 applyParam_exports = {};
|
|
20
|
+
__export(applyParam_exports, {
|
|
21
|
+
applyParam: () => applyParam
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(applyParam_exports);
|
|
24
|
+
var import_utils = require("@domql/utils");
|
|
25
|
+
var import_mixins = require("./mixins");
|
|
26
|
+
const applyParam = (param, element, options) => {
|
|
27
|
+
const { node, context } = element;
|
|
28
|
+
const prop = element[param];
|
|
29
|
+
const DOMQLProperty = import_mixins.registry[param];
|
|
30
|
+
const DOMQLPropertyFromContext = context && context.registry && context.registry[param];
|
|
31
|
+
const isGlobalTransformer = DOMQLPropertyFromContext || DOMQLProperty;
|
|
32
|
+
const hasDefine = element.define && element.define[param];
|
|
33
|
+
const hasContextDefine = context && context.define && context.define[param];
|
|
34
|
+
if (isGlobalTransformer && !hasContextDefine) {
|
|
35
|
+
if ((0, import_utils.isFunction)(isGlobalTransformer)) {
|
|
36
|
+
isGlobalTransformer(prop, element, node, options);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { hasDefine, hasContextDefine };
|
|
41
|
+
};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var create_exports = {};
|
|
30
|
+
__export(create_exports, {
|
|
31
|
+
default: () => create_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(create_exports);
|
|
34
|
+
var import_utils = require("@domql/utils");
|
|
35
|
+
var import_tree = require("./tree");
|
|
36
|
+
var import_registry = require("@domql/registry");
|
|
37
|
+
var import_event = require("@domql/event");
|
|
38
|
+
var import_render = require("@domql/render");
|
|
39
|
+
var import_classlist = require("@domql/classlist");
|
|
40
|
+
var import_node = require("@domql/node");
|
|
41
|
+
var import_state = require("@domql/state");
|
|
42
|
+
var import_methods = require("./methods");
|
|
43
|
+
var import_props = require("./props");
|
|
44
|
+
var import_node2 = __toESM(require("./node"), 1);
|
|
45
|
+
var import_extend = require("./extend");
|
|
46
|
+
var import_mixins = require("./mixins");
|
|
47
|
+
var import_iterate = require("./iterate");
|
|
48
|
+
var import_options = __toESM(require("./cache/options"), 1);
|
|
49
|
+
var import_component = require("./utils/component");
|
|
50
|
+
var import_set = require("./methods/set");
|
|
51
|
+
const ENV = "development";
|
|
52
|
+
const create = (element, parent, key, options = import_options.default.create || {}) => {
|
|
53
|
+
if (options && !import_options.default.create) {
|
|
54
|
+
import_options.default.create = options;
|
|
55
|
+
import_options.default.create.context = element.context || options.context;
|
|
56
|
+
}
|
|
57
|
+
if (element === void 0) {
|
|
58
|
+
if (ENV === "test" || ENV === "development") {
|
|
59
|
+
console.warn(key, "element is undefined in", parent && parent.__ref && parent.__ref.path);
|
|
60
|
+
}
|
|
61
|
+
element = {};
|
|
62
|
+
}
|
|
63
|
+
if ((0, import_utils.isString)(key) && key.slice(0, 2 === "__")) {
|
|
64
|
+
if (ENV === "test" || ENV === "development") {
|
|
65
|
+
console.warn(key, "seems like to be in __ref");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (element === null)
|
|
69
|
+
return;
|
|
70
|
+
if (element === true)
|
|
71
|
+
element = { text: true };
|
|
72
|
+
if (element.__hash) {
|
|
73
|
+
element = { extend: element };
|
|
74
|
+
}
|
|
75
|
+
if (!parent)
|
|
76
|
+
parent = import_tree.ROOT;
|
|
77
|
+
if ((0, import_utils.isNode)(parent)) {
|
|
78
|
+
parent = import_tree.ROOT[`${key}_parent`] = { key: ":root", node: parent };
|
|
79
|
+
}
|
|
80
|
+
if (checkIfPrimitive(element)) {
|
|
81
|
+
element = applyValueAsText(element, parent, key);
|
|
82
|
+
}
|
|
83
|
+
const assignedKey = (element.key || key || (0, import_utils.createKey)()).toString();
|
|
84
|
+
if ((0, import_component.checkIfKeyIsComponent)(assignedKey)) {
|
|
85
|
+
element = (0, import_component.applyKeyComponentAsExtend)(element, parent, assignedKey);
|
|
86
|
+
}
|
|
87
|
+
if (checkIfMedia(assignedKey)) {
|
|
88
|
+
element = applyMediaProps(element, parent, assignedKey);
|
|
89
|
+
}
|
|
90
|
+
if (element.__ref)
|
|
91
|
+
element.__ref.origin = element;
|
|
92
|
+
else
|
|
93
|
+
element.__ref = { origin: element };
|
|
94
|
+
const __ref = element.__ref;
|
|
95
|
+
applyContext(element, parent, options);
|
|
96
|
+
const { context } = element;
|
|
97
|
+
if (context && context.components) {
|
|
98
|
+
(0, import_component.applyComponentFromContext)(element, parent, options);
|
|
99
|
+
}
|
|
100
|
+
(0, import_extend.applyExtend)(element, parent, options);
|
|
101
|
+
element.key = assignedKey;
|
|
102
|
+
if (options.onlyResolveExtends) {
|
|
103
|
+
return resolveExtends(element, parent, options);
|
|
104
|
+
}
|
|
105
|
+
if (Object.keys(options).length) {
|
|
106
|
+
import_mixins.registry.defaultOptions = options;
|
|
107
|
+
if (options.ignoreChildExtend)
|
|
108
|
+
delete options.ignoreChildExtend;
|
|
109
|
+
}
|
|
110
|
+
addCaching(element, parent);
|
|
111
|
+
(0, import_set.addMethods)(element, parent);
|
|
112
|
+
element.state = (0, import_state.createState)(element, parent);
|
|
113
|
+
checkIf(element, parent);
|
|
114
|
+
if (element.node && __ref.__if) {
|
|
115
|
+
return (0, import_render.assignNode)(element, parent, assignedKey);
|
|
116
|
+
}
|
|
117
|
+
if (__ref.__if)
|
|
118
|
+
(0, import_props.createProps)(element, parent);
|
|
119
|
+
(0, import_component.applyVariant)(element, parent);
|
|
120
|
+
const initReturns = (0, import_event.triggerEventOn)("init", element, options);
|
|
121
|
+
if (initReturns === false)
|
|
122
|
+
return element;
|
|
123
|
+
(0, import_event.triggerEventOn)("beforeClassAssign", element, options);
|
|
124
|
+
(0, import_classlist.assignClass)(element);
|
|
125
|
+
renderElement(element, parent, options);
|
|
126
|
+
if (parent.__ref && parent.__ref.__children)
|
|
127
|
+
parent.__ref.__children.push(element.key);
|
|
128
|
+
(0, import_event.triggerEventOn)("complete", element, options);
|
|
129
|
+
return element;
|
|
130
|
+
};
|
|
131
|
+
const renderElement = (element, parent, options) => {
|
|
132
|
+
const { __ref: ref, key } = element;
|
|
133
|
+
(0, import_node2.default)(element, options);
|
|
134
|
+
if (!ref.__if)
|
|
135
|
+
return element;
|
|
136
|
+
(0, import_render.assignNode)(element, parent, key);
|
|
137
|
+
(0, import_event.triggerEventOn)("renderRouter", element, options);
|
|
138
|
+
(0, import_event.triggerEventOn)("render", element, options);
|
|
139
|
+
};
|
|
140
|
+
const checkIfPrimitive = (element) => {
|
|
141
|
+
return (0, import_utils.is)(element)("string", "number");
|
|
142
|
+
};
|
|
143
|
+
const applyValueAsText = (element, parent, key) => {
|
|
144
|
+
const extendTag = element.extend && element.extend.tag;
|
|
145
|
+
const childExtendTag = parent.childExtend && parent.childExtend.tag;
|
|
146
|
+
const isKeyValidHTMLTag = import_registry.TAGS.body.indexOf(key) > -1 && key;
|
|
147
|
+
return {
|
|
148
|
+
text: element,
|
|
149
|
+
tag: extendTag || childExtendTag || isKeyValidHTMLTag || "string"
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
const applyContext = (element, parent, options) => {
|
|
153
|
+
if (options.context && !import_tree.ROOT.context && !element.context)
|
|
154
|
+
import_tree.ROOT.context = options.context;
|
|
155
|
+
if (!element.context)
|
|
156
|
+
element.context = parent.context || options.context || import_tree.ROOT.context;
|
|
157
|
+
};
|
|
158
|
+
const checkIf = (element, parent) => {
|
|
159
|
+
const { __ref: ref } = element;
|
|
160
|
+
if ((0, import_utils.isFunction)(element.if)) {
|
|
161
|
+
const ifPassed = element.if(element, element.state);
|
|
162
|
+
if (!ifPassed) {
|
|
163
|
+
const ifFragment = (0, import_node.cacheNode)({ tag: "fragment" });
|
|
164
|
+
ref.__ifFragment = (0, import_render.appendNode)(ifFragment, parent.node);
|
|
165
|
+
delete ref.__if;
|
|
166
|
+
} else
|
|
167
|
+
ref.__if = true;
|
|
168
|
+
} else
|
|
169
|
+
ref.__if = true;
|
|
170
|
+
};
|
|
171
|
+
const addCaching = (element, parent) => {
|
|
172
|
+
const { __ref: ref } = element;
|
|
173
|
+
let { __ref: parentRef } = parent;
|
|
174
|
+
if (!element.transform)
|
|
175
|
+
element.transform = {};
|
|
176
|
+
if (!ref.__cached)
|
|
177
|
+
ref.__cached = {};
|
|
178
|
+
if (!ref.__defineCache)
|
|
179
|
+
ref.__defineCache = {};
|
|
180
|
+
if (!ref.__exec)
|
|
181
|
+
ref.__exec = {};
|
|
182
|
+
if (!ref.__class)
|
|
183
|
+
ref.__class = {};
|
|
184
|
+
if (!ref.__classNames)
|
|
185
|
+
ref.__classNames = {};
|
|
186
|
+
if (!ref.__attr)
|
|
187
|
+
ref.__attr = {};
|
|
188
|
+
if (!ref.__changes)
|
|
189
|
+
ref.__changes = [];
|
|
190
|
+
if (!ref.__children)
|
|
191
|
+
ref.__children = [];
|
|
192
|
+
const hasRoot = parent && parent.key === ":root";
|
|
193
|
+
if (!ref.__root)
|
|
194
|
+
ref.__root = hasRoot ? element : parentRef.__root;
|
|
195
|
+
if (ENV === "test" || ENV === "development") {
|
|
196
|
+
if (!parentRef)
|
|
197
|
+
parentRef = parent.ref = {};
|
|
198
|
+
if (!parentRef.__path)
|
|
199
|
+
parentRef.__path = [];
|
|
200
|
+
ref.__path = parentRef.__path.concat(element.key);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const resolveExtends = (element, parent, options) => {
|
|
204
|
+
const { __ref } = element;
|
|
205
|
+
element.tag = (0, import_node.detectTag)(element);
|
|
206
|
+
if (!__ref.__exec)
|
|
207
|
+
__ref.__exec = {};
|
|
208
|
+
if (!__ref.__attr)
|
|
209
|
+
__ref.__attr = {};
|
|
210
|
+
if (!element.props)
|
|
211
|
+
element.props = {};
|
|
212
|
+
if (!element.state)
|
|
213
|
+
element.state = {};
|
|
214
|
+
(0, import_state.createState)(element, parent, { skipApplyMethods: true });
|
|
215
|
+
(0, import_props.createProps)(element, parent);
|
|
216
|
+
(0, import_component.applyVariant)(element, parent);
|
|
217
|
+
(0, import_iterate.throughInitialExec)(element, options.propsExcludedFromExec);
|
|
218
|
+
for (const param in element) {
|
|
219
|
+
const prop = element[param];
|
|
220
|
+
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import_component.isVariant)(param))
|
|
221
|
+
continue;
|
|
222
|
+
const hasDefined = element.define && element.define[param];
|
|
223
|
+
const ourParam = import_mixins.registry[param];
|
|
224
|
+
const hasOptionsDefine = options.define && options.define[param];
|
|
225
|
+
if (ourParam && !hasOptionsDefine)
|
|
226
|
+
continue;
|
|
227
|
+
else if (element[param] && !hasDefined && !hasOptionsDefine) {
|
|
228
|
+
create((0, import_utils.exec)(prop, element), element, param, options);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
delete element.parent;
|
|
232
|
+
delete element.update;
|
|
233
|
+
delete element.__element;
|
|
234
|
+
delete element.props.update;
|
|
235
|
+
delete element.props.__element;
|
|
236
|
+
delete element.state.__element;
|
|
237
|
+
delete element.state.__element;
|
|
238
|
+
if (!options.keepRef)
|
|
239
|
+
delete element.__ref;
|
|
240
|
+
return element;
|
|
241
|
+
};
|
|
242
|
+
const checkIfMedia = (key) => key.slice(0, 1) === "@";
|
|
243
|
+
const applyMediaProps = (element, parent, key) => {
|
|
244
|
+
const { props } = element;
|
|
245
|
+
if (props) {
|
|
246
|
+
props.display = "none";
|
|
247
|
+
if (props[key])
|
|
248
|
+
props[key].display = props.display;
|
|
249
|
+
else
|
|
250
|
+
props[key] = { display: props.display || "block" };
|
|
251
|
+
return element;
|
|
252
|
+
} else {
|
|
253
|
+
return {
|
|
254
|
+
...element,
|
|
255
|
+
props: {
|
|
256
|
+
display: "none",
|
|
257
|
+
[key]: { display: "block" }
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
var create_default = create;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 define_exports = {};
|
|
20
|
+
__export(define_exports, {
|
|
21
|
+
default: () => define_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(define_exports);
|
|
24
|
+
var import_report = require("@domql/report");
|
|
25
|
+
var import_mixins = require("./mixins");
|
|
26
|
+
var define_default = (params, options = {}) => {
|
|
27
|
+
const { overwrite } = options;
|
|
28
|
+
for (const param in params) {
|
|
29
|
+
if (import_mixins.registry[param] && !overwrite) {
|
|
30
|
+
(0, import_report.report)("OverwriteToBuiltin", param);
|
|
31
|
+
} else
|
|
32
|
+
import_mixins.registry[param] = params[param];
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
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");
|
|
26
|
+
const ENV = "development";
|
|
27
|
+
const applyExtend = (element, parent, options = {}) => {
|
|
28
|
+
if ((0, import_utils.isFunction)(element))
|
|
29
|
+
element = (0, import_utils.exec)(element, parent);
|
|
30
|
+
let { extend, props, context, __ref } = element;
|
|
31
|
+
const COMPONENTS = context && context.components || options.components;
|
|
32
|
+
if ((0, import_utils.isString)(extend)) {
|
|
33
|
+
if (COMPONENTS && COMPONENTS[extend])
|
|
34
|
+
extend = COMPONENTS[extend];
|
|
35
|
+
else {
|
|
36
|
+
if (ENV !== "test" || ENV !== "development") {
|
|
37
|
+
console.warn("Extend is string but component was not found:", extend);
|
|
38
|
+
}
|
|
39
|
+
extend = {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const extendStack = (0, import_utils2.getExtendStack)(extend);
|
|
43
|
+
if (ENV !== "test" || ENV !== "development")
|
|
44
|
+
delete element.extend;
|
|
45
|
+
let childExtendStack = [];
|
|
46
|
+
if (parent) {
|
|
47
|
+
element.parent = parent;
|
|
48
|
+
if (!options.ignoreChildExtend) {
|
|
49
|
+
if (props && props.ignoreChildExtend)
|
|
50
|
+
return;
|
|
51
|
+
childExtendStack = (0, import_utils2.getExtendStack)(parent.childExtend);
|
|
52
|
+
if (parent.childExtendRecursive) {
|
|
53
|
+
const canExtendRecursive = !(props == null ? void 0 : props.ignoreChildExtendRecursive) && element.key !== "__text";
|
|
54
|
+
if (canExtendRecursive) {
|
|
55
|
+
const childExtendRecursiveStack = (0, import_utils2.getExtendStack)(parent.childExtendRecursive);
|
|
56
|
+
childExtendStack = childExtendStack.concat(childExtendRecursiveStack);
|
|
57
|
+
element.childExtendRecursive = parent.childExtendRecursive;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const extendLength = extendStack.length;
|
|
63
|
+
const childExtendLength = childExtendStack.length;
|
|
64
|
+
let stack = [];
|
|
65
|
+
if (extendLength && childExtendLength) {
|
|
66
|
+
stack = (0, import_utils2.jointStacks)(extendStack, childExtendStack);
|
|
67
|
+
} else if (extendLength) {
|
|
68
|
+
stack = extendStack;
|
|
69
|
+
} else if (childExtendLength) {
|
|
70
|
+
stack = childExtendStack;
|
|
71
|
+
} else if (!options.extend)
|
|
72
|
+
return element;
|
|
73
|
+
if (options.extend) {
|
|
74
|
+
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(options.extend);
|
|
75
|
+
stack = [].concat(stack, defaultOptionsExtend);
|
|
76
|
+
}
|
|
77
|
+
if (__ref)
|
|
78
|
+
__ref.__extend = stack;
|
|
79
|
+
const findAndReplaceStrings = (0, import_utils2.replaceStringsWithComponents)(stack, COMPONENTS);
|
|
80
|
+
let mergedExtend = (0, import_utils2.cloneAndMergeArrayExtend)(findAndReplaceStrings);
|
|
81
|
+
const component = (0, import_utils.exec)(element.component || mergedExtend.component, element);
|
|
82
|
+
if (component && COMPONENTS && COMPONENTS[component]) {
|
|
83
|
+
const componentExtend = (0, import_utils2.cloneAndMergeArrayExtend)((0, import_utils2.getExtendStack)(COMPONENTS[component]));
|
|
84
|
+
mergedExtend = (0, import_utils2.deepMergeExtend)(componentExtend, mergedExtend);
|
|
85
|
+
}
|
|
86
|
+
return (0, import_utils2.deepMergeExtend)(element, mergedExtend);
|
|
87
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var element_exports = {};
|
|
30
|
+
__export(element_exports, {
|
|
31
|
+
TREE: () => import_tree.TREE,
|
|
32
|
+
create: () => import_create.default,
|
|
33
|
+
createNode: () => import_node.default,
|
|
34
|
+
define: () => import_define.default,
|
|
35
|
+
set: () => import_set.default,
|
|
36
|
+
update: () => import_update.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(element_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);
|
|
@@ -0,0 +1,108 @@
|
|
|
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 iterate_exports = {};
|
|
20
|
+
__export(iterate_exports, {
|
|
21
|
+
throughInitialDefine: () => throughInitialDefine,
|
|
22
|
+
throughInitialExec: () => throughInitialExec,
|
|
23
|
+
throughUpdatedDefine: () => throughUpdatedDefine,
|
|
24
|
+
throughUpdatedExec: () => throughUpdatedExec
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(iterate_exports);
|
|
27
|
+
var import_utils = require("@domql/utils");
|
|
28
|
+
var import_utils2 = require("./utils");
|
|
29
|
+
var import_methods = require("./methods");
|
|
30
|
+
const throughInitialExec = (element, exclude = {}) => {
|
|
31
|
+
const { __ref: ref } = element;
|
|
32
|
+
for (const param in element) {
|
|
33
|
+
if (exclude[param])
|
|
34
|
+
continue;
|
|
35
|
+
const prop = element[param];
|
|
36
|
+
if ((0, import_utils.isFunction)(prop) && !(0, import_methods.isMethod)(param) && !(0, import_utils2.isVariant)(param)) {
|
|
37
|
+
ref.__exec[param] = prop;
|
|
38
|
+
element[param] = prop(element, element.state);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const throughUpdatedExec = (element, options = { excludes: import_utils2.METHODS_EXL }) => {
|
|
43
|
+
const { __ref: ref } = element;
|
|
44
|
+
const changes = {};
|
|
45
|
+
for (const param in ref.__exec) {
|
|
46
|
+
const prop = element[param];
|
|
47
|
+
const isDefinedParam = ref.__defineCache[param];
|
|
48
|
+
if (isDefinedParam)
|
|
49
|
+
continue;
|
|
50
|
+
const newExec = ref.__exec[param](element, element.state, element.context);
|
|
51
|
+
const execReturnsString = (0, import_utils.isString)(newExec) || (0, import_utils.isNumber)(newExec);
|
|
52
|
+
if (prop && prop.node && execReturnsString) {
|
|
53
|
+
(0, import_utils2.overwrite)(prop, { text: newExec }, options);
|
|
54
|
+
} else if (newExec !== prop) {
|
|
55
|
+
if ((0, import_utils2.checkIfKeyIsComponent)(param)) {
|
|
56
|
+
const { extend, ...newElem } = (0, import_utils2.extendizeByKey)(newExec, element, param);
|
|
57
|
+
(0, import_utils2.overwrite)(prop, newElem, options);
|
|
58
|
+
} else {
|
|
59
|
+
ref.__cached[param] = changes[param] = prop;
|
|
60
|
+
element[param] = newExec;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return changes;
|
|
65
|
+
};
|
|
66
|
+
const throughInitialDefine = (element) => {
|
|
67
|
+
const { define, context, __ref: ref } = element;
|
|
68
|
+
let defineObj = {};
|
|
69
|
+
const hasGlobalDefine = context && (0, import_utils.isObject)(context.define);
|
|
70
|
+
if ((0, import_utils.isObject)(define))
|
|
71
|
+
defineObj = { ...define };
|
|
72
|
+
if (hasGlobalDefine)
|
|
73
|
+
defineObj = { ...defineObj, ...context.define };
|
|
74
|
+
for (const param in defineObj) {
|
|
75
|
+
let elementProp = element[param];
|
|
76
|
+
if ((0, import_utils.isFunction)(elementProp) && !(0, import_methods.isMethod)(param) && !(0, import_utils2.isVariant)(param)) {
|
|
77
|
+
ref.__exec[param] = elementProp;
|
|
78
|
+
const execParam2 = elementProp = (0, import_utils.exec)(elementProp, element);
|
|
79
|
+
if (execParam2) {
|
|
80
|
+
elementProp = element[param] = execParam2.parse ? execParam2.parse() : execParam2;
|
|
81
|
+
ref.__defineCache[param] = elementProp;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const execParam = defineObj[param](elementProp, element, element.state, element.context);
|
|
85
|
+
if (execParam)
|
|
86
|
+
element[param] = execParam;
|
|
87
|
+
}
|
|
88
|
+
return element;
|
|
89
|
+
};
|
|
90
|
+
const throughUpdatedDefine = (element) => {
|
|
91
|
+
const { context, define, __ref: ref } = element;
|
|
92
|
+
const changes = {};
|
|
93
|
+
let obj = {};
|
|
94
|
+
if ((0, import_utils.isObject)(define))
|
|
95
|
+
obj = { ...define };
|
|
96
|
+
if ((0, import_utils.isObject)(context && context.define))
|
|
97
|
+
obj = { ...obj, ...context.define };
|
|
98
|
+
for (const param in obj) {
|
|
99
|
+
const execParam = ref.__exec[param];
|
|
100
|
+
if (execParam)
|
|
101
|
+
ref.__defineCache[param] = execParam(element, element.state, element.context);
|
|
102
|
+
const cached = (0, import_utils.exec)(ref.__defineCache[param], element);
|
|
103
|
+
const newExecParam = obj[param](cached, element, element.state, element.context);
|
|
104
|
+
if (newExecParam)
|
|
105
|
+
element[param] = newExecParam;
|
|
106
|
+
}
|
|
107
|
+
return changes;
|
|
108
|
+
};
|
package/dist/cjs/mixins/state.js
CHANGED
|
@@ -30,7 +30,7 @@ const state = (params, element, node) => {
|
|
|
30
30
|
for (const param in state2) {
|
|
31
31
|
if (import_state.IGNORE_STATE_PARAMS.includes(param))
|
|
32
32
|
continue;
|
|
33
|
-
if (!
|
|
33
|
+
if (!Object.hasOwnProperty.call(state2, param))
|
|
34
34
|
continue;
|
|
35
35
|
element.state[param] = (0, import_utils.exec)(state2[param], element);
|
|
36
36
|
}
|
package/dist/cjs/node.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var node_exports = {};
|
|
30
|
+
__export(node_exports, {
|
|
31
|
+
createNode: () => createNode,
|
|
32
|
+
default: () => node_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(node_exports);
|
|
35
|
+
var import_utils = require("@domql/utils");
|
|
36
|
+
var import_event = require("@domql/event");
|
|
37
|
+
var import_methods = require("./methods");
|
|
38
|
+
var import_node = require("@domql/node");
|
|
39
|
+
var import_create = __toESM(require("./create"), 1);
|
|
40
|
+
var import_iterate = require("./iterate");
|
|
41
|
+
var import_mixins = require("./mixins");
|
|
42
|
+
var import_applyParam = require("./applyParam");
|
|
43
|
+
var import_utils2 = require("./utils");
|
|
44
|
+
const ENV = "development";
|
|
45
|
+
const createNode = (element, options) => {
|
|
46
|
+
let { node, tag, __ref: ref } = element;
|
|
47
|
+
let isNewNode;
|
|
48
|
+
if (!node) {
|
|
49
|
+
isNewNode = true;
|
|
50
|
+
if (!ref.__if)
|
|
51
|
+
return element;
|
|
52
|
+
if (tag === "shadow") {
|
|
53
|
+
node = element.node = element.parent.node.attachShadow({ mode: "open" });
|
|
54
|
+
} else
|
|
55
|
+
node = element.node = (0, import_node.cacheNode)(element);
|
|
56
|
+
(0, import_event.triggerEventOn)("attachNode", element, options);
|
|
57
|
+
}
|
|
58
|
+
if (ENV === "test" || ENV === "development" || options.alowRefReference) {
|
|
59
|
+
node.ref = element;
|
|
60
|
+
if ((0, import_utils.isFunction)(node.setAttribute))
|
|
61
|
+
node.setAttribute("key", element.key);
|
|
62
|
+
}
|
|
63
|
+
if (!ref.__if)
|
|
64
|
+
return element;
|
|
65
|
+
if (element.tag !== "string" || element.tag !== "fragment") {
|
|
66
|
+
(0, import_iterate.throughInitialDefine)(element);
|
|
67
|
+
(0, import_iterate.throughInitialExec)(element);
|
|
68
|
+
if (isNewNode && (0, import_utils.isObject)(element.on))
|
|
69
|
+
(0, import_event.applyEventsOnNode)(element);
|
|
70
|
+
for (const param in element) {
|
|
71
|
+
const prop = element[param];
|
|
72
|
+
if ((0, import_utils.isUndefined)(prop) || (0, import_methods.isMethod)(param) || (0, import_utils2.isVariant)(param) || (0, import_utils.isObject)(import_mixins.registry[param]))
|
|
73
|
+
continue;
|
|
74
|
+
const isElement = (0, import_applyParam.applyParam)(param, element, options);
|
|
75
|
+
if (isElement) {
|
|
76
|
+
const { hasDefine, hasContextDefine } = isElement;
|
|
77
|
+
if (element[param] && !hasDefine && !hasContextDefine) {
|
|
78
|
+
(0, import_create.default)((0, import_utils.exec)(prop, element), element, param, options);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return element;
|
|
84
|
+
};
|
|
85
|
+
var node_default = createNode;
|
package/dist/cjs/set.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var set_exports = {};
|
|
30
|
+
__export(set_exports, {
|
|
31
|
+
default: () => set_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(set_exports);
|
|
34
|
+
var import_utils = require("@domql/utils");
|
|
35
|
+
var import_create = __toESM(require("./create"), 1);
|
|
36
|
+
var import_options = __toESM(require("./cache/options"), 1);
|
|
37
|
+
var import_mixins = require("./mixins");
|
|
38
|
+
var import_content = require("./mixins/content");
|
|
39
|
+
const set = function(params, options = {}, el) {
|
|
40
|
+
const element = el || this;
|
|
41
|
+
const __contentRef = element.content && element.content.__ref;
|
|
42
|
+
if (__contentRef && __contentRef.__cached && (0, import_utils.isEqualDeep)(params, element.content))
|
|
43
|
+
return element;
|
|
44
|
+
(0, import_content.removeContent)(element);
|
|
45
|
+
if (params) {
|
|
46
|
+
const { childExtend } = params;
|
|
47
|
+
if (!childExtend && element.childExtend)
|
|
48
|
+
params.childExtend = element.childExtend;
|
|
49
|
+
(0, import_create.default)(params, element, "content", {
|
|
50
|
+
ignoreChildExtend: true,
|
|
51
|
+
...import_mixins.registry.defaultOptions,
|
|
52
|
+
...import_options.default.create,
|
|
53
|
+
...options
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return element;
|
|
57
|
+
};
|
|
58
|
+
var set_default = set;
|
package/dist/cjs/tree.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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 tree_exports = {};
|
|
20
|
+
__export(tree_exports, {
|
|
21
|
+
ROOT: () => ROOT,
|
|
22
|
+
TREE: () => TREE
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tree_exports);
|
|
25
|
+
var import_utils = require("@domql/utils");
|
|
26
|
+
var import_report = require("@domql/report");
|
|
27
|
+
const ROOT = {
|
|
28
|
+
key: ":root",
|
|
29
|
+
node: import_utils.document ? import_utils.document.body : (0, import_report.report)("DocumentNotDefined", import_utils.document)
|
|
30
|
+
};
|
|
31
|
+
const TREE = ROOT;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var update_exports = {};
|
|
30
|
+
__export(update_exports, {
|
|
31
|
+
default: () => update_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(update_exports);
|
|
34
|
+
var import_utils = require("@domql/utils");
|
|
35
|
+
var import_event = require("@domql/event");
|
|
36
|
+
var import_methods = require("./methods");
|
|
37
|
+
var import_props = require("./props");
|
|
38
|
+
var import_state = require("@domql/state");
|
|
39
|
+
var import_utils2 = require("./utils");
|
|
40
|
+
var import_create = __toESM(require("./create"), 1);
|
|
41
|
+
var import_iterate = require("./iterate");
|
|
42
|
+
var import_mixins = require("./mixins");
|
|
43
|
+
var import_applyParam = require("./applyParam");
|
|
44
|
+
var import_options = __toESM(require("./cache/options"), 1);
|
|
45
|
+
const snapshot = {
|
|
46
|
+
snapshotId: import_utils.createSnapshotId
|
|
47
|
+
};
|
|
48
|
+
const UPDATE_DEFAULT_OPTIONS = {
|
|
49
|
+
stackChanges: false,
|
|
50
|
+
cleanExec: true,
|
|
51
|
+
preventRecursive: false,
|
|
52
|
+
currentSnapshot: false,
|
|
53
|
+
calleeElement: false,
|
|
54
|
+
excludes: import_utils2.METHODS_EXL
|
|
55
|
+
};
|
|
56
|
+
const update = function(params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
57
|
+
const element = this;
|
|
58
|
+
const { parent, node, key } = element;
|
|
59
|
+
const { excludes, preventInheritAtCurrentState } = options;
|
|
60
|
+
if (preventInheritAtCurrentState && preventInheritAtCurrentState.__element === element)
|
|
61
|
+
return;
|
|
62
|
+
if (!excludes)
|
|
63
|
+
(0, import_utils.merge)(options, UPDATE_DEFAULT_OPTIONS);
|
|
64
|
+
let ref = element.__ref;
|
|
65
|
+
if (!ref)
|
|
66
|
+
ref = element.__ref = {};
|
|
67
|
+
const [snapshotOnCallee, calleeElement, snapshotHasUpdated] = captureSnapshot(element, options);
|
|
68
|
+
if (snapshotHasUpdated)
|
|
69
|
+
return;
|
|
70
|
+
if ((0, import_utils.isString)(params) || (0, import_utils.isNumber)(params)) {
|
|
71
|
+
params = { text: params };
|
|
72
|
+
}
|
|
73
|
+
const ifFails = checkIfOnUpdate(element, parent, options);
|
|
74
|
+
if (ifFails)
|
|
75
|
+
return;
|
|
76
|
+
const inheritState = inheritStateUpdates(element, options);
|
|
77
|
+
if (inheritState === false)
|
|
78
|
+
return;
|
|
79
|
+
if (ref.__if && !options.preventPropsUpdate) {
|
|
80
|
+
const hasParentProps = parent.props && (parent.props[key] || parent.props.childProps);
|
|
81
|
+
const hasFunctionInProps = ref.__props.filter((v) => (0, import_utils.isFunction)(v));
|
|
82
|
+
const props = params.props || hasParentProps || hasFunctionInProps.length;
|
|
83
|
+
if (props)
|
|
84
|
+
(0, import_props.updateProps)(props, element, parent);
|
|
85
|
+
}
|
|
86
|
+
if (!options.isForced) {
|
|
87
|
+
(0, import_event.triggerEventOn)("beforeClassAssign", element, options);
|
|
88
|
+
}
|
|
89
|
+
if (!options.preventInitUpdateListener) {
|
|
90
|
+
const initUpdateReturns = (0, import_event.triggerEventOnUpdate)("initUpdate", params, element, options);
|
|
91
|
+
if (initUpdateReturns === false)
|
|
92
|
+
return element;
|
|
93
|
+
}
|
|
94
|
+
const overwriteChanges = (0, import_utils.overwriteDeep)(element, params, import_utils2.METHODS_EXL);
|
|
95
|
+
const execChanges = (0, import_iterate.throughUpdatedExec)(element, { ignore: UPDATE_DEFAULT_OPTIONS });
|
|
96
|
+
const definedChanges = (0, import_iterate.throughUpdatedDefine)(element);
|
|
97
|
+
if (options.stackChanges && element.__stackChanges) {
|
|
98
|
+
const stackChanges = (0, import_utils.merge)(definedChanges, (0, import_utils.merge)(execChanges, overwriteChanges));
|
|
99
|
+
element.__stackChanges.push(stackChanges);
|
|
100
|
+
}
|
|
101
|
+
if (!ref.__if)
|
|
102
|
+
return false;
|
|
103
|
+
if (!node) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
for (const param in element) {
|
|
107
|
+
const prop = element[param];
|
|
108
|
+
const hasOnlyUpdateFalsy = options.onlyUpdate && (options.onlyUpdate !== param || !element.lookup(options.onlyUpdate));
|
|
109
|
+
const isInPreventUpdate = (0, import_utils.isArray)(options.preventUpdate) && options.preventUpdate.includes(param);
|
|
110
|
+
const isInPreventDefineUpdate = (0, import_utils.isArray)(options.preventDefineUpdate) && options.preventDefineUpdate.includes(param);
|
|
111
|
+
if ((0, import_utils.isUndefined)(prop) || hasOnlyUpdateFalsy || isInPreventUpdate || isInPreventDefineUpdate || options.preventDefineUpdate === true || options.preventDefineUpdate === param || options.preventContentUpdate && param === "content" || (options.preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import_utils2.isVariant)(param))
|
|
112
|
+
continue;
|
|
113
|
+
if (options.preventStateUpdate === "once")
|
|
114
|
+
options.preventStateUpdate = false;
|
|
115
|
+
const isElement = (0, import_applyParam.applyParam)(param, element, options);
|
|
116
|
+
if (isElement) {
|
|
117
|
+
const { hasDefine, hasContextDefine } = isElement;
|
|
118
|
+
const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !options.preventRecursive;
|
|
119
|
+
if (!canUpdate)
|
|
120
|
+
continue;
|
|
121
|
+
const childUpdateCall = () => update.call(prop, params[prop], {
|
|
122
|
+
...options,
|
|
123
|
+
currentSnapshot: snapshotOnCallee,
|
|
124
|
+
calleeElement
|
|
125
|
+
});
|
|
126
|
+
if (element.props && element.props.lazyLoad || options.lazyLoad) {
|
|
127
|
+
import_utils.window.requestAnimationFrame(() => childUpdateCall());
|
|
128
|
+
} else
|
|
129
|
+
childUpdateCall();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (!options.preventUpdateListener)
|
|
133
|
+
(0, import_event.triggerEventOn)("update", element, options);
|
|
134
|
+
};
|
|
135
|
+
const captureSnapshot = (element, options) => {
|
|
136
|
+
const ref = element.__ref;
|
|
137
|
+
const { currentSnapshot, calleeElement } = options;
|
|
138
|
+
const isCallee = calleeElement === element;
|
|
139
|
+
if (!calleeElement || isCallee) {
|
|
140
|
+
const createdStanpshot = snapshot.snapshotId();
|
|
141
|
+
ref.__currentSnapshot = createdStanpshot;
|
|
142
|
+
return [createdStanpshot, element];
|
|
143
|
+
}
|
|
144
|
+
const snapshotOnCallee = ref.__currentSnapshot;
|
|
145
|
+
if (currentSnapshot < snapshotOnCallee) {
|
|
146
|
+
return [snapshotOnCallee, calleeElement, true];
|
|
147
|
+
}
|
|
148
|
+
return [snapshotOnCallee, calleeElement];
|
|
149
|
+
};
|
|
150
|
+
const checkIfOnUpdate = (element, parent, options) => {
|
|
151
|
+
if (!(0, import_utils.isFunction)(element.if) || !element.state || !parent)
|
|
152
|
+
return;
|
|
153
|
+
const ref = element.__ref;
|
|
154
|
+
const ifPassed = element.if(element, element.state, element.context, options);
|
|
155
|
+
const itWasFalse = ref.__if !== true;
|
|
156
|
+
if (ifPassed) {
|
|
157
|
+
ref.__if = true;
|
|
158
|
+
if (itWasFalse) {
|
|
159
|
+
delete element.__hash;
|
|
160
|
+
delete element.extend;
|
|
161
|
+
if (!ref.__hasRootState) {
|
|
162
|
+
delete element.state;
|
|
163
|
+
}
|
|
164
|
+
if (ref.__state) {
|
|
165
|
+
element.state = ref.__state;
|
|
166
|
+
}
|
|
167
|
+
const created = (0, import_create.default)(element, parent, element.key, import_options.default.create);
|
|
168
|
+
if (options.preventUpdate !== true && element.on && (0, import_utils.isFunction)(element.on.update)) {
|
|
169
|
+
(0, import_event.applyEvent)(element.on.update, created, created.state);
|
|
170
|
+
}
|
|
171
|
+
return created;
|
|
172
|
+
}
|
|
173
|
+
} else if (element.node && !ifPassed) {
|
|
174
|
+
element.node.remove();
|
|
175
|
+
delete ref.__if;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const inheritStateUpdates = (element, options) => {
|
|
179
|
+
const { __ref: ref } = element;
|
|
180
|
+
const stateKey = ref.__state;
|
|
181
|
+
const { parent, state } = element;
|
|
182
|
+
if (options.preventpdateTriggerStateUpdate)
|
|
183
|
+
return;
|
|
184
|
+
if (!stateKey && !ref.__hasRootState) {
|
|
185
|
+
element.state = parent && parent.state || {};
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const { isHoisted, execStateFunction, stateFunctionOverwrite } = options;
|
|
189
|
+
const shouldForceStateUpdate = (0, import_utils.isFunction)(stateKey) && (!isHoisted && execStateFunction && stateFunctionOverwrite);
|
|
190
|
+
if (shouldForceStateUpdate) {
|
|
191
|
+
const execState = (0, import_utils.exec)(stateKey, element);
|
|
192
|
+
state.set(execState, {
|
|
193
|
+
...options,
|
|
194
|
+
preventUpdate: true
|
|
195
|
+
});
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const parentState = parent && parent.state || {};
|
|
199
|
+
const keyInParentState = parentState[stateKey];
|
|
200
|
+
if (!keyInParentState || options.preventInheritedStateUpdate)
|
|
201
|
+
return;
|
|
202
|
+
if (!options.preventInitStateUpdateListener) {
|
|
203
|
+
const initStateReturns = (0, import_event.triggerEventOnUpdate)("initStateUpdated", keyInParentState, element, options);
|
|
204
|
+
if (initStateReturns === false)
|
|
205
|
+
return element;
|
|
206
|
+
}
|
|
207
|
+
const newState = createStateUpdate(element, parent, options);
|
|
208
|
+
if (!options.preventStateUpdateListener) {
|
|
209
|
+
(0, import_event.triggerEventOnUpdate)("stateUpdated", newState.parse(), element, options);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const createStateUpdate = (element, parent, options) => {
|
|
213
|
+
const __stateChildren = element.state.__children;
|
|
214
|
+
const newState = (0, import_state.createState)(element, parent);
|
|
215
|
+
element.state = newState;
|
|
216
|
+
for (const child in __stateChildren) {
|
|
217
|
+
if (newState[child])
|
|
218
|
+
newState.__children[child] = __stateChildren[child];
|
|
219
|
+
__stateChildren[child].parent = newState;
|
|
220
|
+
}
|
|
221
|
+
return newState;
|
|
222
|
+
};
|
|
223
|
+
var update_default = update;
|
package/mixins/state.js
CHANGED
|
@@ -9,7 +9,7 @@ export const state = (params, element, node) => {
|
|
|
9
9
|
if (isObject(state)) {
|
|
10
10
|
for (const param in state) {
|
|
11
11
|
if (IGNORE_STATE_PARAMS.includes(param)) continue
|
|
12
|
-
if (!
|
|
12
|
+
if (!Object.hasOwnProperty.call(state, param)) continue
|
|
13
13
|
element.state[param] = exec(state[param], element)
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -17,4 +17,4 @@ export const state = (params, element, node) => {
|
|
|
17
17
|
return element
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export default state
|
|
20
|
+
export default state
|
package/node.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
22
|
-
"build:esm": "npx esbuild **/*.js --target=es2019 --format=esm --outdir=dist/esm",
|
|
23
|
-
"build:cjs": "npx esbuild **/*.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
22
|
+
"build:esm": "npx esbuild *.js **/*.js --target=es2019 --format=esm --outdir=dist/esm",
|
|
23
|
+
"build:cjs": "npx esbuild *.js **/*.js --target=node16 --format=cjs --outdir=dist/cjs",
|
|
24
24
|
"build": "yarn build:cjs",
|
|
25
25
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
26
26
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@domql/state": "latest",
|
|
32
32
|
"@domql/utils": "latest"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "7cd7195bfa99a253070a8db387483bb28720bf39",
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@babel/core": "^7.12.0"
|
|
37
37
|
}
|