@domql/utils 3.2.3 → 3.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/array.js +11 -5
  2. package/cache.js +3 -0
  3. package/component.js +3 -4
  4. package/dist/cjs/array.js +11 -5
  5. package/dist/cjs/component.js +4 -6
  6. package/dist/cjs/element.js +5 -5
  7. package/dist/cjs/extends.js +43 -27
  8. package/dist/cjs/function.js +3 -3
  9. package/dist/cjs/index.js +1 -0
  10. package/dist/cjs/key.js +2 -2
  11. package/dist/cjs/keys.js +30 -16
  12. package/dist/cjs/methods.js +64 -28
  13. package/dist/cjs/object.js +141 -125
  14. package/dist/cjs/props.js +41 -32
  15. package/dist/cjs/scope.js +1 -2
  16. package/dist/cjs/state.js +9 -8
  17. package/dist/cjs/string.js +15 -20
  18. package/dist/cjs/tags.js +69 -4
  19. package/dist/cjs/triggerEvent.js +90 -0
  20. package/dist/cjs/types.js +4 -12
  21. package/dist/esm/array.js +11 -5
  22. package/dist/esm/component.js +4 -6
  23. package/dist/esm/element.js +8 -26
  24. package/dist/esm/extends.js +47 -49
  25. package/dist/esm/function.js +3 -3
  26. package/dist/esm/index.js +1 -0
  27. package/dist/esm/key.js +2 -2
  28. package/dist/esm/keys.js +30 -16
  29. package/dist/esm/methods.js +63 -42
  30. package/dist/esm/object.js +145 -149
  31. package/dist/esm/props.js +41 -48
  32. package/dist/esm/scope.js +1 -2
  33. package/dist/esm/state.js +17 -34
  34. package/dist/esm/string.js +15 -20
  35. package/dist/esm/tags.js +69 -4
  36. package/dist/esm/triggerEvent.js +70 -0
  37. package/dist/esm/types.js +4 -12
  38. package/dist/iife/index.js +2779 -0
  39. package/element.js +2 -2
  40. package/extends.js +28 -17
  41. package/function.js +4 -6
  42. package/index.js +1 -0
  43. package/keys.js +26 -16
  44. package/methods.js +63 -18
  45. package/object.js +142 -200
  46. package/package.json +33 -12
  47. package/props.js +42 -25
  48. package/state.js +7 -7
  49. package/string.js +20 -38
  50. package/tags.js +43 -4
  51. package/triggerEvent.js +76 -0
  52. package/types.js +4 -23
  53. package/dist/cjs/package.json +0 -4
@@ -1,22 +1,3 @@
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
1
  import { joinArrays, removeDuplicatesInArray } from "./array.js";
21
2
  import { matchesComponentNaming } from "./component.js";
22
3
  import { deepClone, exec } from "./object.js";
@@ -47,13 +28,12 @@ const createExtends = (element, parent, key) => {
47
28
  return __extends;
48
29
  };
49
30
  const addExtends = (newExtends, element) => {
50
- var _a;
51
31
  const { __ref: ref } = element;
52
32
  let { __extends } = ref;
53
33
  if (!newExtends) return __extends;
54
- const variant = (_a = element.props) == null ? void 0 : _a.variant;
34
+ const variant = element.props?.variant;
55
35
  const context = element.context;
56
- if (variant && (context == null ? void 0 : context.components) && !Array.isArray(newExtends) && typeof newExtends === "string") {
36
+ if (variant && context?.components && !Array.isArray(newExtends) && typeof newExtends === "string") {
57
37
  const variantKey = `${newExtends}.${variant}`;
58
38
  if (context.components[variantKey]) {
59
39
  newExtends = variantKey;
@@ -70,9 +50,10 @@ const concatAddExtends = (newExtend, element) => {
70
50
  const { extends: elementExtend } = element;
71
51
  const originalArray = isArray(elementExtend) ? elementExtend : [elementExtend];
72
52
  const receivedArray = isArray(newExtend) ? newExtend : [newExtend];
73
- return __spreadProps(__spreadValues({}, element), {
53
+ return {
54
+ ...element,
74
55
  extends: joinArrays(receivedArray, originalArray)
75
- });
56
+ };
76
57
  };
77
58
  const generateHash = () => Math.random().toString(36).substring(2);
78
59
  const extendStackRegistry = {};
@@ -85,7 +66,7 @@ const setHashedExtend = (extend, stack) => {
85
66
  if (!isString(extend)) {
86
67
  extend.__hash = hash;
87
68
  }
88
- if (!["__proto__", "constructor", "prototype"].includes(hash)) {
69
+ if (hash !== "__proto__" && hash !== "constructor" && hash !== "prototype") {
89
70
  extendStackRegistry[hash] = stack;
90
71
  }
91
72
  return stack;
@@ -107,10 +88,16 @@ const extractArrayExtend = (extend, stack, context, processed = /* @__PURE__ */
107
88
  return stack;
108
89
  };
109
90
  const deepExtend = (extend, stack, context, processed = /* @__PURE__ */ new Set()) => {
110
- const extendOflattenExtend = extend.extends;
111
- const cleanExtend = __spreadValues({}, extend);
91
+ const extendOflattenExtend = extend.extends || extend.extend;
92
+ const cleanExtend = { ...extend };
112
93
  delete cleanExtend.extends;
113
- if (Object.keys(cleanExtend).length > 0) {
94
+ delete cleanExtend.extend;
95
+ let hasKeys = false;
96
+ for (const _k in cleanExtend) {
97
+ hasKeys = true;
98
+ break;
99
+ }
100
+ if (hasKeys) {
114
101
  stack.push(cleanExtend);
115
102
  }
116
103
  if (extendOflattenExtend) {
@@ -128,21 +115,30 @@ const flattenExtend = (extend, stack, context, processed = /* @__PURE__ */ new S
128
115
  extend = mapStringsWithContextComponents(extend, context);
129
116
  }
130
117
  processed.add(extend);
131
- if (extend == null ? void 0 : extend.extends) {
118
+ if (extend?.extends || extend?.extend) {
132
119
  deepExtend(extend, stack, context, processed);
133
120
  } else if (extend) {
134
121
  stack.push(extend);
135
122
  }
136
123
  return stack;
137
124
  };
125
+ const MERGE_EXTENDS_SKIP = /* @__PURE__ */ new Set([
126
+ "parent",
127
+ "node",
128
+ "__ref",
129
+ "__proto__",
130
+ "extend",
131
+ "childExtend",
132
+ "childExtendRecursive"
133
+ ]);
138
134
  const deepMergeExtends = (element, extend) => {
139
135
  extend = deepClone(extend);
140
136
  for (const e in extend) {
141
- if (["parent", "node", "__ref", "__proto__"].indexOf(e) > -1) continue;
137
+ if (MERGE_EXTENDS_SKIP.has(e)) continue;
142
138
  const elementProp = element[e];
143
139
  const extendProp = extend[e];
144
140
  if (extendProp === void 0) continue;
145
- if (Object.prototype.hasOwnProperty.call(extend, e) && !["__proto__", "constructor", "prototype"].includes(e)) {
141
+ if (Object.prototype.hasOwnProperty.call(extend, e) && e !== "__proto__" && e !== "constructor" && e !== "prototype") {
146
142
  if (elementProp === void 0) {
147
143
  element[e] = extendProp;
148
144
  } else if (isObject(elementProp) && isObject(extendProp)) {
@@ -171,11 +167,11 @@ const cloneAndMergeArrayExtend = (stack) => {
171
167
  }, {});
172
168
  };
173
169
  const mapStringsWithContextComponents = (extend, context, options = {}, variant) => {
174
- const COMPONENTS = context && context.components || options.components;
175
- const PAGES = context && context.pages || options.pages;
170
+ const COMPONENTS = context?.components || options.components;
171
+ const PAGES = context?.pages || options.pages;
176
172
  if (isString(extend)) {
177
173
  const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
178
- const pageExists = PAGES && extend.startsWith("/") && PAGES[extend];
174
+ const pageExists = PAGES && extend.charCodeAt(0) === 47 && PAGES[extend];
179
175
  if (componentExists) return componentExists;
180
176
  else if (pageExists) return pageExists;
181
177
  else {
@@ -206,7 +202,7 @@ const getExtendsInElement = (obj) => {
206
202
  let result = [];
207
203
  function traverse(o) {
208
204
  for (const key in o) {
209
- if (Object.hasOwnProperty.call(o, key)) {
205
+ if (Object.prototype.hasOwnProperty.call(o, key)) {
210
206
  if (matchesComponentNaming(key)) {
211
207
  result.push(key);
212
208
  }
@@ -227,14 +223,16 @@ const getExtendsInElement = (obj) => {
227
223
  return result;
228
224
  };
229
225
  const createElementExtends = (element, parent, options = {}) => {
230
- var _a;
231
226
  const { __ref: ref } = element;
232
227
  const context = element.context || parent.context;
233
- const variant = (_a = element.props) == null ? void 0 : _a.variant;
228
+ const variant = element.props?.variant;
229
+ if (element.extend && !element.extends) element.extends = element.extend;
230
+ delete element.extend;
231
+ if (!element.extends && element.props?.extends) element.extends = element.props.extends;
234
232
  if (element.extends) {
235
233
  if (Array.isArray(element.extends) && element.extends.length > 0) {
236
234
  const [firstExtend, ...restExtends] = element.extends;
237
- if (typeof firstExtend === "string" && variant && (context == null ? void 0 : context.components)) {
235
+ if (typeof firstExtend === "string" && variant && context?.components) {
238
236
  const variantKey = `${firstExtend}.${variant}`;
239
237
  if (context.components[variantKey]) {
240
238
  addExtends([variantKey, ...restExtends], element);
@@ -244,7 +242,7 @@ const createElementExtends = (element, parent, options = {}) => {
244
242
  } else {
245
243
  addExtends(element.extends, element);
246
244
  }
247
- } else if (typeof element.extends === "string" && variant && (context == null ? void 0 : context.components)) {
245
+ } else if (typeof element.extends === "string" && variant && context?.components) {
248
246
  const variantKey = `${element.extends}.${variant}`;
249
247
  if (context.components[variantKey]) {
250
248
  addExtends(variantKey, element);
@@ -267,28 +265,28 @@ const createElementExtends = (element, parent, options = {}) => {
267
265
  return removeDuplicatesInArray(ref.__extends);
268
266
  };
269
267
  const inheritChildPropsExtends = (element, parent, options = {}) => {
270
- var _a, _b, _c;
271
268
  const { props, __ref: ref } = element;
272
- const ignoreChildExtends = options.ignoreChildExtends || (props == null ? void 0 : props.ignoreChildExtends);
269
+ const ignoreChildExtends = options.ignoreChildExtends || props?.ignoreChildExtends;
273
270
  if (!ignoreChildExtends) {
274
- if ((_b = (_a = parent.props) == null ? void 0 : _a.childProps) == null ? void 0 : _b.extends) {
275
- addExtends((_c = parent.props) == null ? void 0 : _c.childProps.extends, element);
271
+ if (parent.props?.childProps?.extends) {
272
+ addExtends(parent.props?.childProps.extends, element);
276
273
  }
277
274
  }
278
275
  return ref.__extends;
279
276
  };
280
277
  const inheritChildExtends = (element, parent, options = {}) => {
281
278
  const { props, __ref: ref } = element;
282
- const ignoreChildExtends = options.ignoreChildExtends || (props == null ? void 0 : props.ignoreChildExtends);
283
- if (!ignoreChildExtends && parent.childExtends) {
284
- addExtends(parent.childExtends, element);
279
+ const ignoreChildExtends = options.ignoreChildExtends || props?.ignoreChildExtends;
280
+ const childExtends = parent.childExtends || parent.childExtend;
281
+ if (!ignoreChildExtends && childExtends) {
282
+ addExtends(childExtends, element);
285
283
  }
286
284
  return ref.__extends;
287
285
  };
288
286
  const inheritRecursiveChildExtends = (element, parent, options = {}) => {
289
287
  const { props, __ref: ref } = element;
290
- const childExtendsRecursive = parent.childExtendsRecursive;
291
- const ignoreChildExtendsRecursive = options.ignoreChildExtendsRecursive || (props == null ? void 0 : props.ignoreChildExtendsRecursive);
288
+ const childExtendsRecursive = parent.childExtendsRecursive || parent.childExtendRecursive;
289
+ const ignoreChildExtendsRecursive = options.ignoreChildExtendsRecursive || props?.ignoreChildExtendsRecursive;
292
290
  const isText = element.key === "__text";
293
291
  if (childExtendsRecursive && !isText && !ignoreChildExtendsRecursive) {
294
292
  addExtends(childExtendsRecursive, element);
@@ -298,7 +296,7 @@ const inheritRecursiveChildExtends = (element, parent, options = {}) => {
298
296
  const createExtendsStack = (element, parent, options = {}) => {
299
297
  const { props, __ref: ref } = element;
300
298
  const context = element.context || parent.context;
301
- const variant = element.variant || (props == null ? void 0 : props.variant);
299
+ const variant = element.variant || props?.variant;
302
300
  const __extends = removeDuplicatesInArray(
303
301
  ref.__extends.map((val, i) => {
304
302
  return mapStringsWithContextComponents(
@@ -35,16 +35,16 @@ const memoize = (fn) => {
35
35
  }
36
36
  };
37
37
  };
38
+ const RE_STRING_FUNCTION = /^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/;
38
39
  const isStringFunction = (inputString) => {
39
- const functionRegex = /^((function\s*\([^)]*\)\s*\{[^}]*\})|(\([^)]*\)\s*=>))/;
40
- return functionRegex.test(inputString);
40
+ return RE_STRING_FUNCTION.test(inputString);
41
41
  };
42
42
  function cloneFunction(fn, win = window) {
43
43
  const temp = function() {
44
44
  return fn.apply(win, arguments);
45
45
  };
46
46
  for (const key in fn) {
47
- if (Object.hasOwnProperty.call(fn, key)) {
47
+ if (Object.prototype.hasOwnProperty.call(fn, key)) {
48
48
  temp[key] = fn[key];
49
49
  }
50
50
  }
package/dist/esm/index.js CHANGED
@@ -21,3 +21,4 @@ export * from "./scope.js";
21
21
  export * from "./methods.js";
22
22
  export * from "./cache.js";
23
23
  export * from "./update.js";
24
+ export * from "./triggerEvent.js";
package/dist/esm/key.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { exec } from "./object.js";
2
- const generateKey = /* @__PURE__ */ function() {
2
+ const generateKey = /* @__PURE__ */ (function() {
3
3
  let index = 0;
4
4
  function newId() {
5
5
  index++;
6
6
  return index;
7
7
  }
8
8
  return newId;
9
- }();
9
+ })();
10
10
  const createSnapshotId = generateKey;
11
11
  const createKey = (element, parent, key) => {
12
12
  return (exec(key, element) || key || element.key || generateKey()).toString();
package/dist/esm/keys.js CHANGED
@@ -1,4 +1,4 @@
1
- const DOMQ_PROPERTIES = [
1
+ const DOMQ_PROPERTIES = /* @__PURE__ */ new Set([
2
2
  "attr",
3
3
  "style",
4
4
  "text",
@@ -10,11 +10,14 @@ const DOMQ_PROPERTIES = [
10
10
  "scope",
11
11
  "root",
12
12
  "deps",
13
+ "extend",
13
14
  "extends",
14
15
  "$router",
15
16
  "routes",
16
17
  "children",
18
+ "childExtend",
17
19
  "childExtends",
20
+ "childExtendRecursive",
18
21
  "childExtendsRecursive",
19
22
  "props",
20
23
  "if",
@@ -32,8 +35,8 @@ const DOMQ_PROPERTIES = [
32
35
  "on",
33
36
  "component",
34
37
  "context"
35
- ];
36
- const PARSED_DOMQ_PROPERTIES = [
38
+ ]);
39
+ const PARSED_DOMQ_PROPERTIES = /* @__PURE__ */ new Set([
37
40
  "attr",
38
41
  "style",
39
42
  "text",
@@ -49,8 +52,9 @@ const PARSED_DOMQ_PROPERTIES = [
49
52
  "key",
50
53
  "tag",
51
54
  "query",
52
- "on"
53
- ];
55
+ "on",
56
+ "context"
57
+ ]);
54
58
  const STATE_PROPERTIES = [
55
59
  "ref",
56
60
  "parent",
@@ -60,7 +64,7 @@ const STATE_PROPERTIES = [
60
64
  "__children",
61
65
  "root"
62
66
  ];
63
- const STATE_METHODS = [
67
+ const STATE_METHODS = /* @__PURE__ */ new Set([
64
68
  "update",
65
69
  "parse",
66
70
  "clean",
@@ -93,9 +97,9 @@ const STATE_METHODS = [
93
97
  "removeByPath",
94
98
  "removePathCollection",
95
99
  "getByPath"
96
- ];
97
- const PROPS_METHODS = ["update", "__element"];
98
- const METHODS = [
100
+ ]);
101
+ const PROPS_METHODS = /* @__PURE__ */ new Set(["update", "__element"]);
102
+ const METHODS = /* @__PURE__ */ new Set([
99
103
  "set",
100
104
  "reset",
101
105
  "update",
@@ -121,15 +125,25 @@ const METHODS = [
121
125
  "error",
122
126
  "call",
123
127
  "nextElement",
124
- "previousElement"
125
- ];
126
- const METHODS_EXL = [
127
- ...["node", "context", "extends", "__element", "__ref"],
128
+ "previousElement",
129
+ "getRootState",
130
+ "getRoot",
131
+ "getRootData",
132
+ "getRootContext",
133
+ "getContext",
134
+ "getChildren"
135
+ ]);
136
+ const METHODS_EXL = /* @__PURE__ */ new Set([
137
+ "node",
138
+ "context",
139
+ "extends",
140
+ "__element",
141
+ "__ref",
128
142
  ...METHODS,
129
143
  ...STATE_METHODS,
130
144
  ...PROPS_METHODS
131
- ];
132
- const DOMQL_EVENTS = [
145
+ ]);
146
+ const DOMQL_EVENTS = /* @__PURE__ */ new Set([
133
147
  "init",
134
148
  "beforeClassAssign",
135
149
  "render",
@@ -145,7 +159,7 @@ const DOMQL_EVENTS = [
145
159
  "complete",
146
160
  "frame",
147
161
  "update"
148
- ];
162
+ ]);
149
163
  export {
150
164
  DOMQL_EVENTS,
151
165
  DOMQ_PROPERTIES,
@@ -1,19 +1,4 @@
1
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
2
- var __hasOwnProp = Object.prototype.hasOwnProperty;
3
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
4
- var __objRest = (source, exclude) => {
5
- var target = {};
6
- for (var prop in source)
7
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
8
- target[prop] = source[prop];
9
- if (source != null && __getOwnPropSymbols)
10
- for (var prop of __getOwnPropSymbols(source)) {
11
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
12
- target[prop] = source[prop];
13
- }
14
- return target;
15
- };
16
- import { triggerEventOn } from "@domql/event";
1
+ import { triggerEventOn } from "./triggerEvent.js";
17
2
  import { DOMQ_PROPERTIES, METHODS, PARSED_DOMQ_PROPERTIES } from "./keys.js";
18
3
  import { isDefined, isFunction, isObject, isObjectLike } from "./types.js";
19
4
  import { deepClone } from "./object.js";
@@ -54,10 +39,9 @@ function lookup(param) {
54
39
  return parent;
55
40
  }
56
41
  function lookdown(param) {
57
- var _a;
58
42
  const el = this;
59
43
  const { __ref: ref } = el;
60
- const children = ref == null ? void 0 : ref.__children;
44
+ const children = ref?.__children;
61
45
  if (!children) return;
62
46
  for (let i = 0; i < children.length; i++) {
63
47
  const v = children[i];
@@ -69,15 +53,14 @@ function lookdown(param) {
69
53
  return childElem;
70
54
  }
71
55
  }
72
- const lookdown2 = (_a = childElem == null ? void 0 : childElem.lookdown) == null ? void 0 : _a.call(childElem, param);
56
+ const lookdown2 = childElem?.lookdown?.(param);
73
57
  if (lookdown2) return lookdown2;
74
58
  }
75
59
  }
76
60
  function lookdownAll(param, results = []) {
77
- var _a;
78
61
  const el = this;
79
62
  const { __ref: ref } = el;
80
- const children = ref == null ? void 0 : ref.__children;
63
+ const children = ref?.__children;
81
64
  if (!children) return;
82
65
  for (let i = 0; i < children.length; i++) {
83
66
  const v = children[i];
@@ -87,14 +70,13 @@ function lookdownAll(param, results = []) {
87
70
  const exec = param(childElem, childElem.state, childElem.context);
88
71
  if (childElem.state && exec) results.push(childElem);
89
72
  }
90
- (_a = childElem == null ? void 0 : childElem.lookdownAll) == null ? void 0 : _a.call(childElem, param, results);
73
+ childElem?.lookdownAll?.(param, results);
91
74
  }
92
75
  return results.length ? results : void 0;
93
76
  }
94
77
  function setNodeStyles(params = {}) {
95
- var _a;
96
78
  const el = this;
97
- if (!((_a = el.node) == null ? void 0 : _a.style)) return;
79
+ if (!el.node?.style) return;
98
80
  for (const param in params) {
99
81
  const value = params[param];
100
82
  const childElem = el[param];
@@ -142,14 +124,48 @@ function getChildren() {
142
124
  function getPath() {
143
125
  return this.getRef().path;
144
126
  }
127
+ function getRootState(param) {
128
+ let state = null;
129
+ const hasRootState = (obj) => obj.__element && obj.root?.isRootState;
130
+ if (!this) {
131
+ state = window.platformState || window.smblsApp?.state;
132
+ } else if (hasRootState(this)) {
133
+ state = this.root;
134
+ } else if (this.__ref && this.__ref.path) {
135
+ const hasPlatformState = this.state && hasRootState(this.state);
136
+ const hasPlatformStateOnParent = isFunction(this.state) && this.parent.state && hasRootState(this.parent.state);
137
+ if (hasPlatformState || hasPlatformStateOnParent) {
138
+ state = this.state.root || this.parent.state.root;
139
+ }
140
+ }
141
+ if (!state) {
142
+ state = window.platformState || window.smblsApp?.state;
143
+ }
144
+ return param ? state?.[param] : state;
145
+ }
146
+ function getRoot(key) {
147
+ const rootElem = this.getRootState()?.__element;
148
+ return rootElem && Object.keys(rootElem).length > 0 && key ? rootElem[key] : rootElem;
149
+ }
150
+ function getRootData(key) {
151
+ return this.getRoot("data") && Object.keys(this.getRoot("data")).length > 0 && key ? this.getRoot("data")[key] : this.getRoot("data");
152
+ }
153
+ function getRootContext(key) {
154
+ const ctx = this.getRoot()?.context;
155
+ return key ? ctx[key] : ctx;
156
+ }
157
+ function getContext(key) {
158
+ const ctx = this.context;
159
+ return key ? ctx[key] : ctx;
160
+ }
145
161
  const defineSetter = (element, key, get2, set) => Object.defineProperty(element, key, { get: get2, set });
146
162
  function keys() {
147
163
  const element = this;
148
164
  const keys2 = [];
149
165
  for (const param in element) {
150
166
  if (
151
- // (REGISTRY[param] && !DOMQ_PROPERTIES.includes(param)) ||
152
- !Object.hasOwnProperty.call(element, param) || DOMQ_PROPERTIES.includes(param) && !PARSED_DOMQ_PROPERTIES.includes(param)
167
+ // (REGISTRY[param] && !DOMQ_PROPERTIES.has(param)) ||
168
+ !Object.prototype.hasOwnProperty.call(element, param) || DOMQ_PROPERTIES.has(param) && !PARSED_DOMQ_PROPERTIES.has(param)
153
169
  ) {
154
170
  continue;
155
171
  }
@@ -162,24 +178,26 @@ function parse(excl = []) {
162
178
  const obj = {};
163
179
  const keyList = keys.call(element);
164
180
  const hasChildren = keyList.includes("children");
165
- keyList.forEach((v) => {
166
- if (excl.includes(v) || !Object.hasOwnProperty.call(element, v)) return;
167
- if (hasChildren && v === "content") return;
181
+ const exclSet = excl.length ? new Set(excl) : null;
182
+ for (let i = 0; i < keyList.length; i++) {
183
+ const v = keyList[i];
184
+ if (exclSet && exclSet.has(v) || !Object.prototype.hasOwnProperty.call(element, v)) continue;
185
+ if (hasChildren && v === "content") continue;
168
186
  const val = element[v];
169
187
  if (v === "state") {
170
- if (element.__ref && !element.__ref.__hasRootState) return;
188
+ if (element.__ref && !element.__ref.__hasRootState) continue;
171
189
  const parsedVal = isFunction(val && val.parse) ? val.parse() : val;
172
190
  obj[v] = isFunction(parsedVal) ? parsedVal : JSON.parse(JSON.stringify(parsedVal || {}));
173
191
  } else if (v === "scope") {
174
- if (element.__ref && !element.__ref.__hasRootScope) return;
192
+ if (element.__ref && !element.__ref.__hasRootScope) continue;
175
193
  obj[v] = JSON.parse(JSON.stringify(val || {}));
176
194
  } else if (v === "props") {
177
- const _a = element[v], { __element, update } = _a, props = __objRest(_a, ["__element", "update"]);
195
+ const { __element, update, ...props } = element[v];
178
196
  obj[v] = props;
179
- } else if (isDefined(val) && Object.hasOwnProperty.call(element, v)) {
197
+ } else if (isDefined(val) && Object.prototype.hasOwnProperty.call(element, v)) {
180
198
  obj[v] = val;
181
199
  }
182
- });
200
+ }
183
201
  return obj;
184
202
  }
185
203
  function parseDeep(excl = [], visited = /* @__PURE__ */ new WeakSet()) {
@@ -187,8 +205,9 @@ function parseDeep(excl = [], visited = /* @__PURE__ */ new WeakSet()) {
187
205
  if (visited.has(element)) return void 0;
188
206
  visited.add(element);
189
207
  const obj = parse.call(element, excl);
208
+ const exclSet = excl.length ? new Set(excl) : null;
190
209
  for (const v in obj) {
191
- if (excl.includes(v) || !Object.hasOwnProperty.call(element, v)) continue;
210
+ if (exclSet && exclSet.has(v) || !Object.prototype.hasOwnProperty.call(element, v)) continue;
192
211
  const val = obj[v];
193
212
  if (Array.isArray(val)) {
194
213
  obj[v] = val.map(
@@ -228,10 +247,9 @@ function warn(...params) {
228
247
  }
229
248
  }
230
249
  function error(...params) {
231
- var _a, _b;
232
250
  if (ENV === "test" || ENV === "development") {
233
- if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) debugger;
234
- if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) verbose.call(this);
251
+ if (params[params.length - 1]?.debugger) debugger;
252
+ if (params[params.length - 1]?.verbose) verbose.call(this);
235
253
  throw new Error(...params);
236
254
  }
237
255
  }
@@ -283,13 +301,11 @@ function variables(obj = {}) {
283
301
  };
284
302
  }
285
303
  function call(fnKey, ...args) {
286
- var _a, _b, _c, _d, _e;
287
304
  const context = this.context;
288
- return (_e = ((_a = context.utils) == null ? void 0 : _a[fnKey]) || ((_b = context.functions) == null ? void 0 : _b[fnKey]) || ((_c = context.methods) == null ? void 0 : _c[fnKey]) || ((_d = context.snippets) == null ? void 0 : _d[fnKey])) == null ? void 0 : _e.call(this, ...args);
305
+ return (context.utils?.[fnKey] || context.functions?.[fnKey] || context.methods?.[fnKey] || context.snippets?.[fnKey])?.call(this, ...args);
289
306
  }
290
307
  function isMethod(param, element) {
291
- var _a, _b;
292
- return Boolean(METHODS.includes(param) || ((_b = (_a = element == null ? void 0 : element.context) == null ? void 0 : _a.methods) == null ? void 0 : _b[param]));
308
+ return Boolean(METHODS.has(param) || element?.context?.methods?.[param]);
293
309
  }
294
310
  export {
295
311
  call,
@@ -297,8 +313,13 @@ export {
297
313
  error,
298
314
  get,
299
315
  getChildren,
316
+ getContext,
300
317
  getPath,
301
318
  getRef,
319
+ getRoot,
320
+ getRootContext,
321
+ getRootData,
322
+ getRootState,
302
323
  isMethod,
303
324
  keys,
304
325
  log,