@domql/utils 2.5.200 → 3.0.0

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.
Files changed (58) hide show
  1. package/array.js +26 -13
  2. package/cache.js +4 -0
  3. package/component.js +10 -227
  4. package/cookie.js +27 -24
  5. package/dist/cjs/array.js +27 -10
  6. package/dist/cjs/cache.js +26 -0
  7. package/dist/cjs/component.js +15 -206
  8. package/dist/cjs/cookie.js +14 -14
  9. package/dist/cjs/element.js +137 -0
  10. package/dist/cjs/events.js +37 -0
  11. package/dist/cjs/extends.js +351 -0
  12. package/dist/cjs/if.js +30 -0
  13. package/dist/cjs/index.js +10 -0
  14. package/dist/cjs/key.js +5 -0
  15. package/dist/cjs/keys.js +178 -0
  16. package/dist/cjs/methods.js +305 -0
  17. package/dist/cjs/object.js +78 -191
  18. package/dist/cjs/props.js +220 -0
  19. package/dist/cjs/scope.js +28 -0
  20. package/dist/cjs/state.js +175 -0
  21. package/dist/cjs/string.js +27 -15
  22. package/dist/cjs/update.js +42 -0
  23. package/dist/esm/array.js +27 -10
  24. package/dist/esm/cache.js +6 -0
  25. package/dist/esm/component.js +16 -225
  26. package/dist/esm/cookie.js +14 -14
  27. package/dist/esm/element.js +135 -0
  28. package/dist/esm/events.js +17 -0
  29. package/dist/esm/extends.js +349 -0
  30. package/dist/esm/if.js +10 -0
  31. package/dist/esm/index.js +10 -0
  32. package/dist/esm/key.js +5 -0
  33. package/dist/esm/keys.js +158 -0
  34. package/dist/esm/methods.js +285 -0
  35. package/dist/esm/object.js +79 -193
  36. package/dist/esm/props.js +216 -0
  37. package/dist/esm/scope.js +8 -0
  38. package/dist/esm/state.js +185 -0
  39. package/dist/esm/string.js +27 -15
  40. package/dist/esm/update.js +22 -0
  41. package/element.js +149 -0
  42. package/env.js +5 -2
  43. package/events.js +17 -0
  44. package/extends.js +425 -0
  45. package/if.js +14 -0
  46. package/index.js +10 -0
  47. package/key.js +6 -0
  48. package/keys.js +157 -0
  49. package/log.js +4 -1
  50. package/methods.js +315 -0
  51. package/node.js +21 -13
  52. package/object.js +122 -236
  53. package/package.json +3 -3
  54. package/props.js +249 -0
  55. package/scope.js +8 -0
  56. package/state.js +208 -0
  57. package/string.js +66 -30
  58. package/update.js +27 -0
@@ -0,0 +1,135 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { createExtends } from "./extends.js";
21
+ import { createKey } from "./key.js";
22
+ import { isNode } from "./node.js";
23
+ import { createProps } from "./props.js";
24
+ import { HTML_TAGS } from "./tags.js";
25
+ import { is, isFunction } from "./types.js";
26
+ const ENV = "development";
27
+ const returnValueAsText = (element, parent, key) => {
28
+ const childExtendsTag = parent.childExtends && parent.childExtends.tag;
29
+ const childPropsTag = parent.props.childProps && parent.props.childProps.tag;
30
+ const isKeyValidHTMLTag = HTML_TAGS.body.indexOf(key) > -1 && key;
31
+ return {
32
+ text: element,
33
+ tag: childExtendsTag || childPropsTag || isKeyValidHTMLTag || "string"
34
+ };
35
+ };
36
+ const createBasedOnType = (element, parent, key) => {
37
+ if (element === void 0) {
38
+ if (ENV === "test" || ENV === "development") {
39
+ console.warn(
40
+ key,
41
+ "element is undefined in",
42
+ parent && parent.__ref && parent.__ref.path
43
+ );
44
+ }
45
+ return {};
46
+ }
47
+ if (element === null) return;
48
+ if (element === true) return {};
49
+ if (is(element)("string", "number")) {
50
+ return returnValueAsText(element, parent, key);
51
+ }
52
+ if (isFunction(element)) {
53
+ return { props: element };
54
+ }
55
+ return element;
56
+ };
57
+ const addRef = (element, parent) => {
58
+ const ref = {};
59
+ ref.origin = element;
60
+ ref.parent = parent;
61
+ return ref;
62
+ };
63
+ const createParent = (element, parent, key, options, root) => {
64
+ if (!parent) return root;
65
+ if (isNode(parent)) {
66
+ const parentNodeWrapper = { key: ":root", node: parent };
67
+ root[`${key}_parent`] = parentNodeWrapper;
68
+ return parentNodeWrapper;
69
+ }
70
+ return parent;
71
+ };
72
+ const createRoot = (element, parent) => {
73
+ const { __ref: ref } = element;
74
+ const { __ref: parentRef } = parent;
75
+ const hasRoot = parent && parent.key === ":root";
76
+ if (!(ref == null ? void 0 : ref.root)) {
77
+ return hasRoot ? element : parentRef == null ? void 0 : parentRef.root;
78
+ }
79
+ };
80
+ const createPath = (element, parent, key) => {
81
+ let { __ref: parentRef } = parent;
82
+ if (!parentRef) parentRef = parent.ref = {};
83
+ if (!parentRef.path) parentRef.path = [];
84
+ return parentRef.path.concat(key);
85
+ };
86
+ const addContext = (element, parent, key, options, root) => {
87
+ const forcedOptionsContext = options.context && !root.context && !element.context;
88
+ if (forcedOptionsContext) root.context = options.context;
89
+ return options.context || parent.context || root.context || element.context;
90
+ };
91
+ const addCaching = (element, parent, key) => {
92
+ const ref = addRef(element, parent);
93
+ element.__ref = ref;
94
+ if (!ref.__defineCache) ref.__defineCache = {};
95
+ if (!ref.__exec) ref.__exec = {};
96
+ if (!ref.__execProps) ref.__execProps = {};
97
+ if (!ref.__class) ref.__class = {};
98
+ if (!ref.__classNames) ref.__classNames = {};
99
+ if (!ref.__attr) ref.__attr = {};
100
+ if (!ref.__changes) ref.__changes = [];
101
+ if (!ref.__children) ref.__children = [];
102
+ ref.__extends = createExtends(element, parent, key);
103
+ ref.path = createPath(element, parent, key);
104
+ ref.root = createRoot(element, parent);
105
+ return ref;
106
+ };
107
+ const createElement = (passedProps, parentEl, passedKey, opts, root) => {
108
+ const hashed = passedProps == null ? void 0 : passedProps.__hash;
109
+ const element = hashed ? { extends: [passedProps] } : createBasedOnType(passedProps, parentEl, passedKey);
110
+ if (!element) return;
111
+ const parent = createParent(element, parentEl, passedKey, opts, root);
112
+ const key = createKey(element, parent, passedKey);
113
+ addCaching(element, parent, key);
114
+ const props = createProps(element, parent, key);
115
+ const context = addContext(element, parent, key, opts, root);
116
+ const on = element.on || {};
117
+ return __spreadProps(__spreadValues({}, element), {
118
+ key,
119
+ props,
120
+ parent,
121
+ context,
122
+ on
123
+ });
124
+ };
125
+ export {
126
+ addCaching,
127
+ addContext,
128
+ addRef,
129
+ createBasedOnType,
130
+ createElement,
131
+ createParent,
132
+ createPath,
133
+ createRoot,
134
+ returnValueAsText
135
+ };
@@ -0,0 +1,17 @@
1
+ import { lowercaseFirstLetter } from "./string.js";
2
+ import { isFunction } from "./types.js";
3
+ const addEventFromProps = (key, element) => {
4
+ const { props, on } = element;
5
+ const eventName = lowercaseFirstLetter(key.split("on")[1]);
6
+ const origEvent = on[eventName];
7
+ const funcFromProps = props[key];
8
+ if (isFunction(origEvent)) {
9
+ on[eventName] = (...args) => {
10
+ const originalEventRetunrs = origEvent(...args);
11
+ if (originalEventRetunrs !== false) funcFromProps(...args);
12
+ };
13
+ } else on[eventName] = funcFromProps;
14
+ };
15
+ export {
16
+ addEventFromProps
17
+ };
@@ -0,0 +1,349 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { joinArrays, removeDuplicatesInArray } from "./array.js";
21
+ import { matchesComponentNaming } from "./component.js";
22
+ import { deepClone, exec } from "./object.js";
23
+ import { isArray, isFunction, isObject, isString } from "./types.js";
24
+ const ENV = "development";
25
+ const createExtendsFromKeys = (key) => {
26
+ if (key.includes("+")) {
27
+ return key.split("+").filter(matchesComponentNaming);
28
+ }
29
+ if (key.includes("_")) {
30
+ const [first] = key.split("_");
31
+ return [first];
32
+ }
33
+ if (key.includes(".") && !matchesComponentNaming(key.split(".")[1])) {
34
+ const [first] = key.split(".");
35
+ return [first];
36
+ }
37
+ return [key];
38
+ };
39
+ const createExtends = (element, parent, key) => {
40
+ let __extends = [];
41
+ const keyExtends = createExtendsFromKeys(key);
42
+ if (keyExtends) __extends = [...keyExtends];
43
+ const elementExtends = element.extends;
44
+ if (elementExtends) {
45
+ __extends = isArray(elementExtends) ? [...__extends, ...elementExtends] : [...__extends, elementExtends];
46
+ }
47
+ return __extends;
48
+ };
49
+ const addExtends = (newExtends, element) => {
50
+ var _a;
51
+ const { __ref: ref } = element;
52
+ let { __extends } = ref;
53
+ if (!newExtends) return __extends;
54
+ const variant = (_a = element.props) == null ? void 0 : _a.variant;
55
+ const context = element.context;
56
+ if (variant && (context == null ? void 0 : context.components) && !Array.isArray(newExtends) && typeof newExtends === "string") {
57
+ const variantKey = `${newExtends}.${variant}`;
58
+ if (context.components[variantKey]) {
59
+ newExtends = variantKey;
60
+ }
61
+ }
62
+ if (!__extends.includes(newExtends)) {
63
+ __extends = Array.isArray(newExtends) ? [...__extends, ...newExtends] : [...__extends, newExtends];
64
+ ref.__extends = __extends;
65
+ }
66
+ return __extends;
67
+ };
68
+ const concatAddExtends = (newExtend, element) => {
69
+ if (!newExtend) return element;
70
+ const { extend: elementExtend } = element;
71
+ const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend];
72
+ const receivedArray = isArray(newExtend) ? newExtend : [newExtend];
73
+ return __spreadProps(__spreadValues({}, element), {
74
+ extends: joinArrays(receivedArray, originalArray)
75
+ });
76
+ };
77
+ const generateHash = () => Math.random().toString(36).substring(2);
78
+ const extendStackRegistry = {};
79
+ const extendCachedRegistry = {};
80
+ const getHashedExtend = (extend) => {
81
+ return extendStackRegistry[extend.__hash];
82
+ };
83
+ const setHashedExtend = (extend, stack) => {
84
+ const hash = generateHash();
85
+ if (!isString(extend)) {
86
+ extend.__hash = hash;
87
+ }
88
+ if (!["__proto__", "constructor", "prototype"].includes(hash)) {
89
+ extendStackRegistry[hash] = stack;
90
+ }
91
+ return stack;
92
+ };
93
+ const getExtendsStackRegistry = (extend, stack) => {
94
+ if (extend.__hash) {
95
+ return stack.concat(getHashedExtend(extend));
96
+ }
97
+ return setHashedExtend(extend, stack);
98
+ };
99
+ const extractArrayExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
100
+ for (const each of extend) {
101
+ if (isArray(each)) {
102
+ extractArrayExtend(each, stack, context, processed);
103
+ } else {
104
+ flattenExtend(each, stack, context, processed);
105
+ }
106
+ }
107
+ return stack;
108
+ };
109
+ const deepExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
110
+ const extendOflattenExtend = extend.extends;
111
+ const cleanExtend = __spreadValues({}, extend);
112
+ delete cleanExtend.extends;
113
+ if (Object.keys(cleanExtend).length > 0) {
114
+ stack.push(cleanExtend);
115
+ }
116
+ if (extendOflattenExtend) {
117
+ flattenExtend(extendOflattenExtend, stack, context, processed);
118
+ }
119
+ return stack;
120
+ };
121
+ const flattenExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
122
+ if (!extend) return stack;
123
+ if (processed.has(extend)) return stack;
124
+ if (isArray(extend)) {
125
+ return extractArrayExtend(extend, stack, context, processed);
126
+ }
127
+ if (isString(extend)) {
128
+ extend = mapStringsWithContextComponents(extend, context);
129
+ }
130
+ processed.add(extend);
131
+ if (extend == null ? void 0 : extend.extends) {
132
+ deepExtend(extend, stack, context, processed);
133
+ } else {
134
+ stack.push(extend);
135
+ }
136
+ return stack;
137
+ };
138
+ const deepMergeExtends = (element, extend) => {
139
+ extend = deepClone(extend);
140
+ for (const e in extend) {
141
+ if (["parent", "node", "__ref"].indexOf(e) > -1) continue;
142
+ if (e === "__proto__") continue;
143
+ const elementProp = element[e];
144
+ const extendProp = extend[e];
145
+ if (extendProp === void 0) continue;
146
+ if (Object.prototype.hasOwnProperty.call(extend, e) && !["__proto__", "constructor", "prototype"].includes(e)) {
147
+ if (elementProp === void 0) {
148
+ element[e] = isObject(extendProp) ? deepClone(extendProp) : extendProp;
149
+ } else if (isObject(elementProp) && isObject(extendProp)) {
150
+ if (matchesComponentNaming(e)) {
151
+ element[e] = deepMergeExtends(elementProp, deepClone(extendProp));
152
+ } else {
153
+ deepMergeExtends(elementProp, extendProp);
154
+ }
155
+ }
156
+ }
157
+ }
158
+ return element;
159
+ };
160
+ const cloneAndMergeArrayExtend = (stack) => {
161
+ return stack.reduce((acc, current) => {
162
+ const cloned = deepClone(current);
163
+ return deepMergeExtends(acc, cloned);
164
+ }, {});
165
+ };
166
+ const mapStringsWithContextComponents = (extend, context, options = {}, variant) => {
167
+ const COMPONENTS = context && context.components || options.components;
168
+ const PAGES = context && context.pages || options.pages;
169
+ if (isString(extend)) {
170
+ const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
171
+ const pageExists = PAGES && extend.startsWith("/") && PAGES[extend];
172
+ if (componentExists) return componentExists;
173
+ else if (pageExists) return pageExists;
174
+ else {
175
+ if (options.verbose && (ENV === "test" || ENV === "development")) {
176
+ console.warn("Extend is string but component was not found:", extend);
177
+ }
178
+ return;
179
+ }
180
+ }
181
+ return extend;
182
+ };
183
+ const jointStacks = (extendStack, childExtendsStack) => {
184
+ return [].concat(extendStack.slice(0, 1)).concat(childExtendsStack.slice(0, 1)).concat(extendStack.slice(1)).concat(childExtendsStack.slice(1));
185
+ };
186
+ const getExtendsStack = (extend, context) => {
187
+ if (!extend) return [];
188
+ if (extend.__hash) return getHashedExtend(extend) || [];
189
+ const processed = /* @__PURE__ */ new Set();
190
+ const stack = flattenExtend(extend, [], context, processed);
191
+ return getExtendsStackRegistry(extend, stack);
192
+ };
193
+ const addExtend = (newExtends, elementExtends) => {
194
+ if (!newExtends) return elementExtends;
195
+ const receivedArray = isArray(newExtends) ? newExtends : [newExtends];
196
+ return joinArrays(receivedArray, elementExtends);
197
+ };
198
+ const getExtendsInElement = (obj) => {
199
+ let result = [];
200
+ function traverse(o) {
201
+ for (const key in o) {
202
+ if (Object.hasOwnProperty.call(o, key)) {
203
+ if (matchesComponentNaming(key)) {
204
+ result.push(key);
205
+ }
206
+ if (key === "extends") {
207
+ if (typeof o[key] === "string") {
208
+ result.push(o[key]);
209
+ } else if (Array.isArray(o[key])) {
210
+ result = result.concat(o[key]);
211
+ }
212
+ }
213
+ if (typeof o[key] === "object" && o[key] !== null) {
214
+ traverse(o[key]);
215
+ }
216
+ }
217
+ }
218
+ }
219
+ traverse(obj);
220
+ return result;
221
+ };
222
+ const createElementExtends = (element, parent, options = {}) => {
223
+ var _a;
224
+ const { __ref: ref } = element;
225
+ const context = element.context || parent.context;
226
+ const variant = (_a = element.props) == null ? void 0 : _a.variant;
227
+ if (element.extends) {
228
+ if (Array.isArray(element.extends) && element.extends.length > 0) {
229
+ const [firstExtend, ...restExtends] = element.extends;
230
+ if (typeof firstExtend === "string" && variant && (context == null ? void 0 : context.components)) {
231
+ const variantKey = `${firstExtend}.${variant}`;
232
+ if (context.components[variantKey]) {
233
+ addExtends([variantKey, ...restExtends], element);
234
+ } else {
235
+ addExtends(element.extends, element);
236
+ }
237
+ } else {
238
+ addExtends(element.extends, element);
239
+ }
240
+ } else if (typeof element.extends === "string" && variant && (context == null ? void 0 : context.components)) {
241
+ const variantKey = `${element.extends}.${variant}`;
242
+ if (context.components[variantKey]) {
243
+ addExtends(variantKey, element);
244
+ } else {
245
+ addExtends(element.extends, element);
246
+ }
247
+ } else {
248
+ addExtends(element.extends, element);
249
+ }
250
+ }
251
+ inheritChildPropsExtends(element, parent, options);
252
+ inheritChildExtends(element, parent, options);
253
+ inheritRecursiveChildExtends(element, parent, options);
254
+ if (element.component) {
255
+ addExtends(exec(element.component, element), element);
256
+ }
257
+ if (context.defaultExtends) {
258
+ addExtends(context.defaultExtends, element);
259
+ }
260
+ return removeDuplicatesInArray(ref.__extends);
261
+ };
262
+ const inheritChildPropsExtends = (element, parent, options = {}) => {
263
+ var _a, _b, _c;
264
+ const { props, __ref: ref } = element;
265
+ const ignoreChildExtends = options.ignoreChildExtends || (props == null ? void 0 : props.ignoreChildExtends);
266
+ if (!ignoreChildExtends) {
267
+ if ((_b = (_a = parent.props) == null ? void 0 : _a.childProps) == null ? void 0 : _b.extends) {
268
+ addExtends((_c = parent.props) == null ? void 0 : _c.childProps.extends, element);
269
+ }
270
+ }
271
+ return ref.__extends;
272
+ };
273
+ const inheritChildExtends = (element, parent, options = {}) => {
274
+ const { props, __ref: ref } = element;
275
+ const ignoreChildExtends = options.ignoreChildExtends || (props == null ? void 0 : props.ignoreChildExtends);
276
+ if (!ignoreChildExtends && parent.childExtends) {
277
+ addExtends(parent.childExtends, element);
278
+ }
279
+ return ref.__extends;
280
+ };
281
+ const inheritRecursiveChildExtends = (element, parent, options = {}) => {
282
+ const { props, __ref: ref } = element;
283
+ const childExtendsRecursive = parent.childExtendsRecursive;
284
+ const ignoreChildExtendsRecursive = options.ignoreChildExtendsRecursive || (props == null ? void 0 : props.ignoreChildExtendsRecursive);
285
+ const isText = element.key === "__text";
286
+ if (childExtendsRecursive && !isText && !ignoreChildExtendsRecursive) {
287
+ addExtends(childExtendsRecursive, element);
288
+ }
289
+ return ref.__extends;
290
+ };
291
+ const createExtendsStack = (element, parent, options = {}) => {
292
+ const { props, __ref: ref } = element;
293
+ const context = element.context || parent.context;
294
+ const variant = element.variant || (props == null ? void 0 : props.variant);
295
+ const __extends = removeDuplicatesInArray(
296
+ ref.__extends.map((val, i) => {
297
+ return mapStringsWithContextComponents(
298
+ val,
299
+ context,
300
+ options,
301
+ i === 0 && variant
302
+ );
303
+ })
304
+ );
305
+ const stack = getExtendsStack(__extends, context);
306
+ ref.__extendsStack = stack;
307
+ return ref.__extendsStack;
308
+ };
309
+ const finalizeExtends = (element, parent, options = {}) => {
310
+ const { __ref: ref } = element;
311
+ const { __extendsStack } = ref;
312
+ const flattenExtends = cloneAndMergeArrayExtend(__extendsStack);
313
+ return deepMergeExtends(element, flattenExtends);
314
+ };
315
+ const applyExtends = (element, parent, options = {}) => {
316
+ createElementExtends(element, parent, options);
317
+ createExtendsStack(element, parent, options);
318
+ finalizeExtends(element, parent, options);
319
+ return element;
320
+ };
321
+ export {
322
+ addExtend,
323
+ addExtends,
324
+ applyExtends,
325
+ cloneAndMergeArrayExtend,
326
+ concatAddExtends,
327
+ createElementExtends,
328
+ createExtends,
329
+ createExtendsFromKeys,
330
+ createExtendsStack,
331
+ deepExtend,
332
+ deepMergeExtends,
333
+ extendCachedRegistry,
334
+ extendStackRegistry,
335
+ extractArrayExtend,
336
+ finalizeExtends,
337
+ flattenExtend,
338
+ generateHash,
339
+ getExtendsInElement,
340
+ getExtendsStack,
341
+ getExtendsStackRegistry,
342
+ getHashedExtend,
343
+ inheritChildExtends,
344
+ inheritChildPropsExtends,
345
+ inheritRecursiveChildExtends,
346
+ jointStacks,
347
+ mapStringsWithContextComponents,
348
+ setHashedExtend
349
+ };
package/dist/esm/if.js ADDED
@@ -0,0 +1,10 @@
1
+ import { isFunction } from "./types.js";
2
+ const createIfConditionFlag = (element, parent) => {
3
+ const { __ref: ref } = element;
4
+ if (isFunction(element.if) && !element.if(element, element.state, element.context)) {
5
+ delete ref.__if;
6
+ } else ref.__if = true;
7
+ };
8
+ export {
9
+ createIfConditionFlag
10
+ };
package/dist/esm/index.js CHANGED
@@ -5,9 +5,19 @@ export * from "./object.js";
5
5
  export * from "./function.js";
6
6
  export * from "./array.js";
7
7
  export * from "./node.js";
8
+ export * from "./if.js";
8
9
  export * from "./log.js";
9
10
  export * from "./string.js";
10
11
  export * from "./globals.js";
11
12
  export * from "./cookie.js";
12
13
  export * from "./tags.js";
13
14
  export * from "./component.js";
15
+ export * from "./props.js";
16
+ export * from "./extends.js";
17
+ export * from "./element.js";
18
+ export * from "./state.js";
19
+ export * from "./keys.js";
20
+ export * from "./scope.js";
21
+ export * from "./methods.js";
22
+ export * from "./cache.js";
23
+ export * from "./update.js";
package/dist/esm/key.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { exec } from "./object.js";
1
2
  const generateKey = /* @__PURE__ */ function() {
2
3
  let index = 0;
3
4
  function newId() {
@@ -7,7 +8,11 @@ const generateKey = /* @__PURE__ */ function() {
7
8
  return newId;
8
9
  }();
9
10
  const createSnapshotId = generateKey;
11
+ const createKey = (element, parent, key) => {
12
+ return (exec(key, element) || key || element.key || generateKey()).toString();
13
+ };
10
14
  export {
15
+ createKey,
11
16
  createSnapshotId,
12
17
  generateKey
13
18
  };
@@ -0,0 +1,158 @@
1
+ const DOMQ_PROPERTIES = [
2
+ "attr",
3
+ "style",
4
+ "text",
5
+ "html",
6
+ "content",
7
+ "data",
8
+ "class",
9
+ "state",
10
+ "scope",
11
+ "deps",
12
+ "extends",
13
+ "$router",
14
+ "routes",
15
+ "children",
16
+ "childExtends",
17
+ "childExtendsRecursive",
18
+ "props",
19
+ "if",
20
+ "define",
21
+ "__name",
22
+ "__ref",
23
+ "__hash",
24
+ "__text",
25
+ "key",
26
+ "tag",
27
+ "query",
28
+ "parent",
29
+ "node",
30
+ "variables",
31
+ "on",
32
+ "component",
33
+ "context"
34
+ ];
35
+ const PARSED_DOMQ_PROPERTIES = [
36
+ "attr",
37
+ "style",
38
+ "text",
39
+ "html",
40
+ "content",
41
+ "data",
42
+ "class",
43
+ "state",
44
+ "scope",
45
+ "children",
46
+ "props",
47
+ "if",
48
+ "key",
49
+ "tag",
50
+ "query",
51
+ "on",
52
+ "context"
53
+ ];
54
+ const STATE_PROPERTIES = [
55
+ "ref",
56
+ "parent",
57
+ "__element",
58
+ "__depends",
59
+ "__ref",
60
+ "__children",
61
+ "root"
62
+ ];
63
+ const STATE_METHODS = [
64
+ "update",
65
+ "parse",
66
+ "clean",
67
+ "create",
68
+ "destroy",
69
+ "add",
70
+ "toggle",
71
+ "remove",
72
+ "apply",
73
+ "set",
74
+ "reset",
75
+ "replace",
76
+ "quietReplace",
77
+ "quietUpdate",
78
+ "applyReplace",
79
+ "applyFunction",
80
+ "keys",
81
+ "values",
82
+ "ref",
83
+ "rootUpdate",
84
+ "parentUpdate",
85
+ "parent",
86
+ "__element",
87
+ "__depends",
88
+ "__ref",
89
+ "__children",
90
+ "root",
91
+ "setByPath",
92
+ "setPathCollection",
93
+ "removeByPath",
94
+ "removePathCollection",
95
+ "getByPath"
96
+ ];
97
+ const PROPS_METHODS = ["update", "__element"];
98
+ const METHODS = [
99
+ "set",
100
+ "reset",
101
+ "update",
102
+ "remove",
103
+ "updateContent",
104
+ "removeContent",
105
+ "lookup",
106
+ "lookdown",
107
+ "lookdownAll",
108
+ "getRef",
109
+ "getPath",
110
+ "setNodeStyles",
111
+ "spotByPath",
112
+ "keys",
113
+ "parse",
114
+ "setProps",
115
+ "parseDeep",
116
+ "variables",
117
+ "if",
118
+ "log",
119
+ "verbose",
120
+ "warn",
121
+ "error",
122
+ "call",
123
+ "nextElement",
124
+ "previousElement"
125
+ ];
126
+ const METHODS_EXL = [
127
+ ...["node", "context", "extends", "__element", "__ref"],
128
+ ...METHODS,
129
+ ...STATE_METHODS,
130
+ ...PROPS_METHODS
131
+ ];
132
+ const DOMQL_EVENTS = [
133
+ "init",
134
+ "beforeClassAssign",
135
+ "render",
136
+ "renderRouter",
137
+ "attachNode",
138
+ "stateInit",
139
+ "stateCreated",
140
+ "beforeStateUpdate",
141
+ "stateUpdate",
142
+ "beforeUpdate",
143
+ "done",
144
+ "create",
145
+ "complete",
146
+ "frame",
147
+ "update"
148
+ ];
149
+ export {
150
+ DOMQL_EVENTS,
151
+ DOMQ_PROPERTIES,
152
+ METHODS,
153
+ METHODS_EXL,
154
+ PARSED_DOMQ_PROPERTIES,
155
+ PROPS_METHODS,
156
+ STATE_METHODS,
157
+ STATE_PROPERTIES
158
+ };