domql 1.6.4 → 1.6.6
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/element/applyParam.js +41 -0
- package/dist/cjs/element/create.js +266 -0
- package/dist/cjs/element/define.js +34 -0
- package/dist/cjs/element/extend.js +75 -0
- package/dist/cjs/element/index.js +49 -0
- package/dist/cjs/element/iterate.js +99 -0
- package/dist/cjs/element/methods.js +116 -0
- package/dist/cjs/element/node.js +80 -0
- package/dist/cjs/element/options.js +24 -0
- package/dist/cjs/element/parse.js +42 -0
- package/dist/cjs/element/props.js +116 -0
- package/dist/cjs/element/remove.js +44 -0
- package/dist/cjs/element/set.js +55 -0
- package/dist/cjs/element/state.js +279 -0
- package/dist/cjs/element/update.js +182 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/utils/component.js +76 -0
- package/dist/cjs/utils/extendUtils.js +142 -0
- package/dist/cjs/utils/index.js +20 -0
- package/dist/cjs/utils/object.js +152 -0
- package/dist/esm/element/applyParam.js +4644 -0
- package/dist/esm/element/create.js +4644 -0
- package/dist/esm/element/define.js +4653 -0
- package/dist/esm/element/extend.js +3395 -0
- package/dist/esm/element/index.js +4675 -0
- package/dist/esm/element/iterate.js +3338 -0
- package/dist/esm/element/methods.js +4657 -0
- package/dist/esm/element/node.js +4645 -0
- package/dist/esm/element/options.js +5 -0
- package/dist/esm/element/parse.js +4657 -0
- package/dist/esm/element/props.js +3370 -0
- package/dist/esm/element/remove.js +991 -0
- package/dist/esm/element/set.js +4644 -0
- package/dist/esm/element/state.js +4656 -0
- package/dist/esm/element/update.js +4642 -0
- package/dist/esm/index.js +4676 -0
- package/dist/esm/utils/component.js +1023 -0
- package/dist/esm/utils/extendUtils.js +1089 -0
- package/dist/esm/utils/index.js +3536 -0
- package/dist/esm/utils/object.js +3364 -0
- package/dist/iife/index.js +4676 -0
- package/package.json +1 -1
- package/src/element/methods.js +1 -1
|
@@ -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,266 @@
|
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var create_exports = {};
|
|
26
|
+
__export(create_exports, {
|
|
27
|
+
default: () => create_default
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(create_exports);
|
|
30
|
+
var import_utils = require("@domql/utils");
|
|
31
|
+
var import_tree = require("@domql/tree");
|
|
32
|
+
var import_key = require("@domql/key");
|
|
33
|
+
var import_registry = require("@domql/registry");
|
|
34
|
+
var import_event = require("@domql/event");
|
|
35
|
+
var import_render = require("@domql/render");
|
|
36
|
+
var import_methods = require("@domql/methods");
|
|
37
|
+
var import_classlist = require("@domql/classlist");
|
|
38
|
+
var import_node = require("@domql/node");
|
|
39
|
+
var import_node2 = __toESM(require("./node"));
|
|
40
|
+
var import_extend = require("./extend");
|
|
41
|
+
var import_set = __toESM(require("./set"));
|
|
42
|
+
var import_state = __toESM(require("./state"));
|
|
43
|
+
var import_props = __toESM(require("./props"));
|
|
44
|
+
var import_update = __toESM(require("./update"));
|
|
45
|
+
var import_methods2 = require("./methods");
|
|
46
|
+
var import_mixins = require("./mixins");
|
|
47
|
+
var import_iterate = require("./iterate");
|
|
48
|
+
var import_options = __toESM(require("./options"));
|
|
49
|
+
var import_component = require("../utils/component");
|
|
50
|
+
var import_remove = require("./remove");
|
|
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
|
+
if (element === void 0) {
|
|
56
|
+
if (ENV === "test" || ENV === "development") {
|
|
57
|
+
console.warn(key, "element is undefined in", parent && parent.__ref && parent.__ref.path);
|
|
58
|
+
}
|
|
59
|
+
element = {};
|
|
60
|
+
}
|
|
61
|
+
if ((0, import_utils.isString)(key) && key.slice(0, 2 === "__")) {
|
|
62
|
+
if (ENV === "test" || ENV === "development") {
|
|
63
|
+
console.warn(key, "seems like to be in __ref");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (element === null)
|
|
67
|
+
return;
|
|
68
|
+
if (element === true)
|
|
69
|
+
element = { text: true };
|
|
70
|
+
if (element.__hash) {
|
|
71
|
+
element = { extend: element };
|
|
72
|
+
}
|
|
73
|
+
if (!parent)
|
|
74
|
+
parent = import_tree.ROOT;
|
|
75
|
+
if ((0, import_utils.isNode)(parent)) {
|
|
76
|
+
parent = import_tree.ROOT[`${key}_parent`] = { key: ":root", node: parent };
|
|
77
|
+
}
|
|
78
|
+
if (checkIfPrimitive(element)) {
|
|
79
|
+
element = applyValueAsText(element, parent, key);
|
|
80
|
+
}
|
|
81
|
+
const assignedKey = (element.key || key || (0, import_key.createKey)()).toString();
|
|
82
|
+
if ((0, import_component.checkIfKeyIsComponent)(assignedKey)) {
|
|
83
|
+
element = (0, import_component.applyKeyComponentAsExtend)(element, parent, assignedKey);
|
|
84
|
+
}
|
|
85
|
+
if (checkIfMedia(assignedKey)) {
|
|
86
|
+
element = applyMediaProps(element, parent, assignedKey);
|
|
87
|
+
}
|
|
88
|
+
if (element.__ref)
|
|
89
|
+
element.__ref.origin = element;
|
|
90
|
+
else
|
|
91
|
+
element.__ref = { origin: element };
|
|
92
|
+
const __ref = element.__ref;
|
|
93
|
+
applyContext(element, parent, options);
|
|
94
|
+
const { context } = element;
|
|
95
|
+
if (context && context.components)
|
|
96
|
+
(0, import_component.applyComponentFromContext)(element, parent, options);
|
|
97
|
+
(0, import_extend.applyExtend)(element, parent, options);
|
|
98
|
+
element.key = assignedKey;
|
|
99
|
+
if (options.onlyResolveExtends)
|
|
100
|
+
return resolveExtends(element, parent, options);
|
|
101
|
+
if (Object.keys(options).length) {
|
|
102
|
+
import_mixins.registry.defaultOptions = options;
|
|
103
|
+
if (options.ignoreChildExtend)
|
|
104
|
+
delete options.ignoreChildExtend;
|
|
105
|
+
}
|
|
106
|
+
addCaching(element, parent);
|
|
107
|
+
addMethods(element, parent);
|
|
108
|
+
element.state = (0, import_state.default)(element, parent);
|
|
109
|
+
checkIf(element, parent);
|
|
110
|
+
if (element.node && __ref.__if) {
|
|
111
|
+
return (0, import_render.assignNode)(element, parent, assignedKey);
|
|
112
|
+
}
|
|
113
|
+
if (__ref.__if)
|
|
114
|
+
(0, import_props.default)(element, parent);
|
|
115
|
+
const initReturns = (0, import_event.triggerEventOn)("init", element);
|
|
116
|
+
if (initReturns === false)
|
|
117
|
+
return element;
|
|
118
|
+
(0, import_event.triggerEventOn)("beforeClassAssign", element);
|
|
119
|
+
(0, import_classlist.assignClass)(element);
|
|
120
|
+
(0, import_node2.default)(element, options);
|
|
121
|
+
if (!__ref.__if)
|
|
122
|
+
return element;
|
|
123
|
+
(0, import_render.assignNode)(element, parent, key);
|
|
124
|
+
(0, import_event.triggerEventOn)("renderRouter", element);
|
|
125
|
+
(0, import_event.triggerEventOn)("render", element);
|
|
126
|
+
if (parent.__ref && parent.__ref.__children)
|
|
127
|
+
parent.__ref.__children.push(element.key);
|
|
128
|
+
return element;
|
|
129
|
+
};
|
|
130
|
+
const checkIfPrimitive = (element) => {
|
|
131
|
+
return (0, import_utils.is)(element)("string", "number");
|
|
132
|
+
};
|
|
133
|
+
const applyValueAsText = (element, parent, key) => {
|
|
134
|
+
const extendTag = element.extend && element.extend.tag;
|
|
135
|
+
const childExtendTag = parent.childExtend && parent.childExtend.tag;
|
|
136
|
+
const isKeyValidHTMLTag = import_registry.TAGS.body.indexOf(key) > -1 && key;
|
|
137
|
+
return {
|
|
138
|
+
text: element,
|
|
139
|
+
tag: extendTag || childExtendTag || isKeyValidHTMLTag || "string"
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
const addMethods = (element, parent) => {
|
|
143
|
+
element.set = import_set.default;
|
|
144
|
+
element.update = import_update.default;
|
|
145
|
+
element.remove = import_methods.remove;
|
|
146
|
+
element.removeContent = import_remove.removeContentElement;
|
|
147
|
+
element.setProps = import_methods.setProps;
|
|
148
|
+
element.lookup = import_methods.lookup;
|
|
149
|
+
element.spotByPath = import_methods.spotByPath;
|
|
150
|
+
element.parse = import_methods2.parse;
|
|
151
|
+
element.parseDeep = import_methods2.parseDeep;
|
|
152
|
+
element.keys = import_methods2.keys;
|
|
153
|
+
element.nextElement = import_methods2.nextElement;
|
|
154
|
+
element.previousElement = import_methods2.previousElement;
|
|
155
|
+
if (ENV === "test" || ENV === "development") {
|
|
156
|
+
element.log = import_methods2.log;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const applyContext = (element, parent, options) => {
|
|
160
|
+
if (options.context && !import_tree.ROOT.context && !element.context)
|
|
161
|
+
import_tree.ROOT.context = options.context;
|
|
162
|
+
if (!element.context)
|
|
163
|
+
element.context = parent.context || options.context || import_tree.ROOT.context;
|
|
164
|
+
};
|
|
165
|
+
const checkIf = (element, parent) => {
|
|
166
|
+
const { __ref } = element;
|
|
167
|
+
if ((0, import_utils.isFunction)(element.if)) {
|
|
168
|
+
const ifPassed = element.if(element, element.state);
|
|
169
|
+
if (!ifPassed) {
|
|
170
|
+
const ifFragment = (0, import_node.cacheNode)({ tag: "fragment" });
|
|
171
|
+
__ref.__ifFragment = (0, import_render.appendNode)(ifFragment, parent.node);
|
|
172
|
+
delete __ref.__if;
|
|
173
|
+
} else
|
|
174
|
+
__ref.__if = true;
|
|
175
|
+
} else
|
|
176
|
+
__ref.__if = true;
|
|
177
|
+
};
|
|
178
|
+
const addCaching = (element, parent) => {
|
|
179
|
+
const { __ref } = element;
|
|
180
|
+
let { __ref: __parentRef } = parent;
|
|
181
|
+
if (!element.transform)
|
|
182
|
+
element.transform = {};
|
|
183
|
+
if (!__ref.__cached)
|
|
184
|
+
__ref.__cached = {};
|
|
185
|
+
if (!__ref.__exec)
|
|
186
|
+
__ref.__exec = {};
|
|
187
|
+
if (!__ref.__class)
|
|
188
|
+
__ref.__class = {};
|
|
189
|
+
if (!__ref.__classNames)
|
|
190
|
+
__ref.__classNames = {};
|
|
191
|
+
if (!__ref.__attr)
|
|
192
|
+
__ref.__attr = {};
|
|
193
|
+
if (!__ref.__changes)
|
|
194
|
+
__ref.__changes = [];
|
|
195
|
+
if (!__ref.__children)
|
|
196
|
+
__ref.__children = [];
|
|
197
|
+
const hasRoot = parent && parent.key === ":root";
|
|
198
|
+
if (!__ref.__root)
|
|
199
|
+
__ref.__root = hasRoot ? element : __parentRef.__root;
|
|
200
|
+
if (ENV === "test" || ENV === "development") {
|
|
201
|
+
if (!__parentRef)
|
|
202
|
+
__parentRef = parent.__ref = {};
|
|
203
|
+
if (!__parentRef.__path)
|
|
204
|
+
__parentRef.__path = [];
|
|
205
|
+
__ref.__path = __parentRef.__path.concat(element.key);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const resolveExtends = (element, parent, options) => {
|
|
209
|
+
const { __ref } = element;
|
|
210
|
+
element.tag = (0, import_node.detectTag)(element);
|
|
211
|
+
if (!__ref.__exec)
|
|
212
|
+
__ref.__exec = {};
|
|
213
|
+
if (!__ref.__attr)
|
|
214
|
+
__ref.__attr = {};
|
|
215
|
+
if (!element.props)
|
|
216
|
+
element.props = {};
|
|
217
|
+
if (!element.state)
|
|
218
|
+
element.state = {};
|
|
219
|
+
element = (0, import_props.default)(element, parent);
|
|
220
|
+
(0, import_state.default)(element, parent, { skip: true });
|
|
221
|
+
(0, import_iterate.throughInitialExec)(element);
|
|
222
|
+
for (const param in element) {
|
|
223
|
+
const prop = element[param];
|
|
224
|
+
if ((0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || prop === void 0)
|
|
225
|
+
continue;
|
|
226
|
+
const hasDefined = element.define && element.define[param];
|
|
227
|
+
const ourParam = import_mixins.registry[param];
|
|
228
|
+
const hasOptionsDefine = options.define && options.define[param];
|
|
229
|
+
if (ourParam && !hasOptionsDefine)
|
|
230
|
+
continue;
|
|
231
|
+
else if (element[param] && !hasDefined && !hasOptionsDefine) {
|
|
232
|
+
create((0, import_utils.exec)(prop, element), element, param, options);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
delete element.parent;
|
|
236
|
+
delete element.update;
|
|
237
|
+
delete element.__element;
|
|
238
|
+
delete element.props.update;
|
|
239
|
+
delete element.props.__element;
|
|
240
|
+
delete element.state.__element;
|
|
241
|
+
delete element.state.__element;
|
|
242
|
+
delete element.__hasRootState;
|
|
243
|
+
delete element.__ref;
|
|
244
|
+
return element;
|
|
245
|
+
};
|
|
246
|
+
const checkIfMedia = (key) => key.slice(0, 1) === "@";
|
|
247
|
+
const applyMediaProps = (element, parent, key) => {
|
|
248
|
+
const { props } = element;
|
|
249
|
+
if (props) {
|
|
250
|
+
props.display = "none";
|
|
251
|
+
if (props[key])
|
|
252
|
+
props[key].display = props.display;
|
|
253
|
+
else
|
|
254
|
+
props[key] = { display: props.display || "block" };
|
|
255
|
+
return element;
|
|
256
|
+
} else {
|
|
257
|
+
return {
|
|
258
|
+
...element,
|
|
259
|
+
props: {
|
|
260
|
+
display: "none",
|
|
261
|
+
[key]: { display: "block" }
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
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,75 @@
|
|
|
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
|
+
extend = COMPONENTS[extend];
|
|
34
|
+
const extendStack = (0, import_utils2.getExtendStack)(extend);
|
|
35
|
+
if (ENV !== "test" || ENV !== "development")
|
|
36
|
+
delete element.extend;
|
|
37
|
+
let childExtendStack = [];
|
|
38
|
+
if (parent) {
|
|
39
|
+
element.parent = parent;
|
|
40
|
+
if (!options.ignoreChildExtend) {
|
|
41
|
+
if (props && props.ignoreChildExtend)
|
|
42
|
+
return;
|
|
43
|
+
childExtendStack = (0, import_utils2.getExtendStack)(parent.childExtend);
|
|
44
|
+
if (parent.childExtendRecursive) {
|
|
45
|
+
const childExtendRecursiveStack = (0, import_utils2.getExtendStack)(parent.childExtendRecursive);
|
|
46
|
+
childExtendStack = childExtendStack.concat(childExtendRecursiveStack);
|
|
47
|
+
element.childExtendRecursive = parent.childExtendRecursive;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const extendLength = extendStack.length;
|
|
52
|
+
const childExtendLength = childExtendStack.length;
|
|
53
|
+
let stack = [];
|
|
54
|
+
if (extendLength && childExtendLength) {
|
|
55
|
+
stack = (0, import_utils2.jointStacks)(extendStack, childExtendStack);
|
|
56
|
+
} else if (extendLength) {
|
|
57
|
+
stack = extendStack;
|
|
58
|
+
} else if (childExtendLength) {
|
|
59
|
+
stack = childExtendStack;
|
|
60
|
+
} else if (!options.extend)
|
|
61
|
+
return element;
|
|
62
|
+
if (options.extend) {
|
|
63
|
+
const defaultOptionsExtend = (0, import_utils2.getExtendStack)(options.extend);
|
|
64
|
+
stack = [].concat(stack, defaultOptionsExtend);
|
|
65
|
+
}
|
|
66
|
+
__ref.__extend = stack;
|
|
67
|
+
const findAndReplaceStrings = (0, import_utils2.replaceStringsWithComponents)(stack, COMPONENTS);
|
|
68
|
+
let mergedExtend = (0, import_utils2.cloneAndMergeArrayExtend)(findAndReplaceStrings);
|
|
69
|
+
const component = (0, import_utils.exec)(element.component || mergedExtend.component, element);
|
|
70
|
+
if (component && COMPONENTS && COMPONENTS[component]) {
|
|
71
|
+
const componentExtend = (0, import_utils2.cloneAndMergeArrayExtend)((0, import_utils2.getExtendStack)(COMPONENTS[component]));
|
|
72
|
+
mergedExtend = (0, import_utils2.deepMergeExtend)(componentExtend, mergedExtend);
|
|
73
|
+
}
|
|
74
|
+
return (0, import_utils2.deepMergeExtend)(element, mergedExtend);
|
|
75
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var element_exports = {};
|
|
26
|
+
__export(element_exports, {
|
|
27
|
+
TREE: () => import_tree.TREE,
|
|
28
|
+
create: () => import_create.default,
|
|
29
|
+
createNode: () => import_node.default,
|
|
30
|
+
define: () => import_define.default,
|
|
31
|
+
get: () => import_methods2.get,
|
|
32
|
+
keys: () => import_methods.keys,
|
|
33
|
+
log: () => import_methods.log,
|
|
34
|
+
lookup: () => import_methods2.lookup,
|
|
35
|
+
parse: () => import_parse.default,
|
|
36
|
+
remove: () => import_methods2.remove,
|
|
37
|
+
set: () => import_set.default,
|
|
38
|
+
update: () => import_update.default
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(element_exports);
|
|
41
|
+
var import_tree = require("@domql/tree");
|
|
42
|
+
var import_create = __toESM(require("./create"));
|
|
43
|
+
var import_node = __toESM(require("./node"));
|
|
44
|
+
var import_define = __toESM(require("./define"));
|
|
45
|
+
var import_update = __toESM(require("./update"));
|
|
46
|
+
var import_parse = __toESM(require("./parse"));
|
|
47
|
+
var import_set = __toESM(require("./set"));
|
|
48
|
+
var import_methods = require("./methods");
|
|
49
|
+
var import_methods2 = require("@domql/methods");
|
|
@@ -0,0 +1,99 @@
|
|
|
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("@domql/methods");
|
|
30
|
+
const throughInitialExec = (element) => {
|
|
31
|
+
const { __ref } = element;
|
|
32
|
+
const { __exec } = __ref;
|
|
33
|
+
for (const param in element) {
|
|
34
|
+
const prop = element[param];
|
|
35
|
+
if ((0, import_utils.isFunction)(prop) && !(0, import_methods.isMethod)(param)) {
|
|
36
|
+
__exec[param] = prop;
|
|
37
|
+
element[param] = prop(element, element.state);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const throughUpdatedExec = (element, options) => {
|
|
42
|
+
const { __ref } = element;
|
|
43
|
+
const { __exec, __cached } = __ref;
|
|
44
|
+
const changes = {};
|
|
45
|
+
for (const param in __exec) {
|
|
46
|
+
const prop = element[param];
|
|
47
|
+
const newExec = __exec[param](element, element.state);
|
|
48
|
+
if (prop && prop.node && ((0, import_utils.isString)(newExec) || (0, import_utils.isNumber)(newExec))) {
|
|
49
|
+
(0, import_utils2.overwrite)(prop, { text: newExec }, options);
|
|
50
|
+
} else if (newExec !== prop) {
|
|
51
|
+
__cached[param] = changes[param] = prop;
|
|
52
|
+
element[param] = newExec;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return changes;
|
|
56
|
+
};
|
|
57
|
+
const throughInitialDefine = (element) => {
|
|
58
|
+
const { define, context, __ref } = element;
|
|
59
|
+
const { __exec, __cached } = __ref;
|
|
60
|
+
let obj = {};
|
|
61
|
+
if ((0, import_utils.isObject)(define))
|
|
62
|
+
obj = { ...define };
|
|
63
|
+
if (context && (0, import_utils.isObject)(context.define))
|
|
64
|
+
obj = { ...obj, ...context.define };
|
|
65
|
+
for (const param in obj) {
|
|
66
|
+
let prop = element[param];
|
|
67
|
+
if ((0, import_utils.isFunction)(prop) && !(0, import_methods.isMethod)(param)) {
|
|
68
|
+
__exec[param] = prop;
|
|
69
|
+
const execParam2 = prop = (0, import_utils.exec)(prop, element);
|
|
70
|
+
if (execParam2)
|
|
71
|
+
element[param] = execParam2;
|
|
72
|
+
}
|
|
73
|
+
__cached[param] = prop;
|
|
74
|
+
const execParam = obj[param](prop, element, element.state);
|
|
75
|
+
if (execParam)
|
|
76
|
+
element[param] = execParam;
|
|
77
|
+
}
|
|
78
|
+
return element;
|
|
79
|
+
};
|
|
80
|
+
const throughUpdatedDefine = (element) => {
|
|
81
|
+
const { context, define, __ref } = element;
|
|
82
|
+
const { __exec, __cached } = __ref;
|
|
83
|
+
const changes = {};
|
|
84
|
+
let obj = {};
|
|
85
|
+
if ((0, import_utils.isObject)(define))
|
|
86
|
+
obj = { ...define };
|
|
87
|
+
if ((0, import_utils.isObject)(context && context.define))
|
|
88
|
+
obj = { ...obj, ...context.define };
|
|
89
|
+
for (const param in obj) {
|
|
90
|
+
const execParam = __exec[param];
|
|
91
|
+
if (execParam)
|
|
92
|
+
__cached[param] = execParam(element, element.state);
|
|
93
|
+
const cached = (0, import_utils.exec)(__cached[param], element);
|
|
94
|
+
const newExecParam = obj[param](cached, element, element.state);
|
|
95
|
+
if (newExecParam)
|
|
96
|
+
element[param] = newExecParam;
|
|
97
|
+
}
|
|
98
|
+
return changes;
|
|
99
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
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 methods_exports = {};
|
|
20
|
+
__export(methods_exports, {
|
|
21
|
+
defineSetter: () => defineSetter,
|
|
22
|
+
keys: () => keys,
|
|
23
|
+
log: () => log,
|
|
24
|
+
nextElement: () => nextElement,
|
|
25
|
+
parse: () => parse,
|
|
26
|
+
parseDeep: () => parseDeep,
|
|
27
|
+
previousElement: () => previousElement,
|
|
28
|
+
set: () => set,
|
|
29
|
+
update: () => update
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(methods_exports);
|
|
32
|
+
var import_utils = require("@domql/utils");
|
|
33
|
+
var import_mixins = require("./mixins");
|
|
34
|
+
const set = function() {
|
|
35
|
+
};
|
|
36
|
+
const update = function() {
|
|
37
|
+
};
|
|
38
|
+
const defineSetter = (element, key, get, set2) => Object.defineProperty(element, key, { get, set: set2 });
|
|
39
|
+
const keys = function() {
|
|
40
|
+
const element = this;
|
|
41
|
+
const keys2 = [];
|
|
42
|
+
for (const param in element) {
|
|
43
|
+
if (import_mixins.registry[param] && !import_mixins.parseFilters.elementKeys.includes(param)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
keys2.push(param);
|
|
47
|
+
}
|
|
48
|
+
return keys2;
|
|
49
|
+
};
|
|
50
|
+
const parse = function(excl = []) {
|
|
51
|
+
const element = this;
|
|
52
|
+
const obj = {};
|
|
53
|
+
const keyList = keys.call(element);
|
|
54
|
+
keyList.forEach((v) => {
|
|
55
|
+
if (excl.includes(v))
|
|
56
|
+
return;
|
|
57
|
+
let val = element[v];
|
|
58
|
+
if (v === "state") {
|
|
59
|
+
if (element.__ref && element.__ref.__hasRootState)
|
|
60
|
+
return;
|
|
61
|
+
if ((0, import_utils.isFunction)(val == null ? void 0 : val.parse))
|
|
62
|
+
val = val.parse();
|
|
63
|
+
} else if (v === "props") {
|
|
64
|
+
const { __element, update: update2, ...props } = element[v];
|
|
65
|
+
obj[v] = props;
|
|
66
|
+
} else if ((0, import_utils.isDefined)(val))
|
|
67
|
+
obj[v] = val;
|
|
68
|
+
});
|
|
69
|
+
return obj;
|
|
70
|
+
};
|
|
71
|
+
const parseDeep = function(excl = []) {
|
|
72
|
+
const element = this;
|
|
73
|
+
const obj = parse.call(element, excl);
|
|
74
|
+
for (const v in obj) {
|
|
75
|
+
if (excl.includes(v))
|
|
76
|
+
return;
|
|
77
|
+
if ((0, import_utils.isObjectLike)(obj[v])) {
|
|
78
|
+
obj[v] = parseDeep.call(obj[v], excl);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return obj;
|
|
82
|
+
};
|
|
83
|
+
const log = function(...args) {
|
|
84
|
+
const element = this;
|
|
85
|
+
const { __ref } = element;
|
|
86
|
+
console.group(element.key);
|
|
87
|
+
if (args.length) {
|
|
88
|
+
args.forEach((v) => console.log(`%c${v}:
|
|
89
|
+
`, "font-weight: bold", element[v]));
|
|
90
|
+
} else {
|
|
91
|
+
console.log(__ref.path);
|
|
92
|
+
const keys2 = element.keys();
|
|
93
|
+
keys2.forEach((v) => console.log(`%c${v}:
|
|
94
|
+
`, "font-weight: bold", element[v]));
|
|
95
|
+
}
|
|
96
|
+
console.groupEnd(element.key);
|
|
97
|
+
return element;
|
|
98
|
+
};
|
|
99
|
+
const nextElement = function() {
|
|
100
|
+
const element = this;
|
|
101
|
+
const { key, parent } = element;
|
|
102
|
+
const { __children } = parent.__ref;
|
|
103
|
+
const currentIndex = __children.indexOf(key);
|
|
104
|
+
const nextChild = __children[currentIndex + 1];
|
|
105
|
+
console.log(nextChild);
|
|
106
|
+
return parent[nextChild];
|
|
107
|
+
};
|
|
108
|
+
const previousElement = function(el) {
|
|
109
|
+
const element = el || this;
|
|
110
|
+
const { key, parent } = element;
|
|
111
|
+
const { __children } = parent.__ref;
|
|
112
|
+
if (!__children)
|
|
113
|
+
return;
|
|
114
|
+
const currentIndex = __children.indexOf(key);
|
|
115
|
+
return parent[__children[currentIndex - 1]];
|
|
116
|
+
};
|