@domql/element 2.33.14 → 2.33.20

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.
@@ -335,7 +335,8 @@ function call(fnKey, ...args) {
335
335
  }
336
336
  return result;
337
337
  } catch (error2) {
338
- console.error(`Error calling function: '${fnKey}'`);
338
+ console.error(`Error calling function: '${fnKey}'
339
+ `, error2);
339
340
  throw new Error(error2);
340
341
  }
341
342
  }
@@ -22,10 +22,23 @@ __export(html_exports, {
22
22
  html: () => html
23
23
  });
24
24
  module.exports = __toCommonJS(html_exports);
25
- var import_utils = require("@domql/utils");
26
25
  function html(param, element, node, opts) {
27
26
  var _a;
28
- const prop = (0, import_utils.exec)(param, element, element.state, element.context, opts) || (0, import_utils.exec)((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html, element, element.state, element.context, opts);
27
+ const prop = element.call(
28
+ "exec",
29
+ param,
30
+ element,
31
+ element.state,
32
+ element.context,
33
+ opts
34
+ ) || element.call(
35
+ "exec",
36
+ (_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html,
37
+ element,
38
+ element.state,
39
+ element.context,
40
+ opts
41
+ );
29
42
  const { __ref } = element;
30
43
  if (prop !== __ref.__html) {
31
44
  if (node.nodeName === "SVG") node.textContent = prop;
@@ -101,19 +101,36 @@ const cloneAndMergeArrayExtend = (stack) => {
101
101
  }, {});
102
102
  };
103
103
  const fallbackStringExtend = (extend, context, options = {}, variant) => {
104
- const COMPONENTS = context && context.components || options.components;
105
- const PAGES = context && context.pages || options.pages;
104
+ const checkIfExists = (key, variant2, onlyVariant) => {
105
+ const COMPONENTS = context && context.components || options.components;
106
+ if (COMPONENTS) {
107
+ const hasVariant = variant2 && COMPONENTS[key + "." + variant2];
108
+ if (onlyVariant) return hasVariant;
109
+ const componentExists = hasVariant || COMPONENTS[key] || COMPONENTS["smbls." + key];
110
+ if (componentExists) return componentExists;
111
+ }
112
+ const PAGES = context && context.pages || options.pages;
113
+ if (PAGES) {
114
+ const pageExists = (key == null ? void 0 : key.startsWith("/")) && PAGES[key];
115
+ if (pageExists) return pageExists;
116
+ }
117
+ };
118
+ if (variant) {
119
+ console.log(extend, variant);
120
+ }
106
121
  if ((0, import_utils.isString)(extend)) {
107
- const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
108
- const pageExists = PAGES && extend.startsWith("/") && PAGES[extend];
109
- if (componentExists) return componentExists;
110
- else if (pageExists) return pageExists;
111
- else {
112
- if (options.verbose && (0, import_utils.isNotProduction)()) {
113
- console.warn("Extend is string but component was not found:", extend);
114
- }
115
- return {};
122
+ const variantExists = checkIfExists(extend, variant);
123
+ if (variantExists) return variantExists;
124
+ if (options.verbose && (0, import_utils.isNotProduction)()) {
125
+ console.warn("Extend is string but component was not found:", extend);
116
126
  }
127
+ return {};
128
+ } else if ((0, import_utils.isArray)(extend)) {
129
+ const extendKey = extend.find((element) => {
130
+ return typeof element === "string";
131
+ });
132
+ const variantExists = checkIfExists(extendKey, variant, true);
133
+ if (variantExists) return variantExists;
117
134
  }
118
135
  return extend;
119
136
  };
@@ -294,7 +294,8 @@ function call(fnKey, ...args) {
294
294
  }
295
295
  return result;
296
296
  } catch (error2) {
297
- console.error(`Error calling function: '${fnKey}'`);
297
+ console.error(`Error calling function: '${fnKey}'
298
+ `, error2);
298
299
  throw new Error(error2);
299
300
  }
300
301
  }
@@ -1,7 +1,20 @@
1
- import { exec } from "@domql/utils";
2
1
  function html(param, element, node, opts) {
3
2
  var _a;
4
- const prop = exec(param, element, element.state, element.context, opts) || exec((_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html, element, element.state, element.context, opts);
3
+ const prop = element.call(
4
+ "exec",
5
+ param,
6
+ element,
7
+ element.state,
8
+ element.context,
9
+ opts
10
+ ) || element.call(
11
+ "exec",
12
+ (_a = element == null ? void 0 : element.props) == null ? void 0 : _a.html,
13
+ element,
14
+ element.state,
15
+ element.context,
16
+ opts
17
+ );
5
18
  const { __ref } = element;
6
19
  if (prop !== __ref.__html) {
7
20
  if (node.nodeName === "SVG") node.textContent = prop;
@@ -71,19 +71,36 @@ const cloneAndMergeArrayExtend = (stack) => {
71
71
  }, {});
72
72
  };
73
73
  const fallbackStringExtend = (extend, context, options = {}, variant) => {
74
- const COMPONENTS = context && context.components || options.components;
75
- const PAGES = context && context.pages || options.pages;
74
+ const checkIfExists = (key, variant2, onlyVariant) => {
75
+ const COMPONENTS = context && context.components || options.components;
76
+ if (COMPONENTS) {
77
+ const hasVariant = variant2 && COMPONENTS[key + "." + variant2];
78
+ if (onlyVariant) return hasVariant;
79
+ const componentExists = hasVariant || COMPONENTS[key] || COMPONENTS["smbls." + key];
80
+ if (componentExists) return componentExists;
81
+ }
82
+ const PAGES = context && context.pages || options.pages;
83
+ if (PAGES) {
84
+ const pageExists = (key == null ? void 0 : key.startsWith("/")) && PAGES[key];
85
+ if (pageExists) return pageExists;
86
+ }
87
+ };
88
+ if (variant) {
89
+ console.log(extend, variant);
90
+ }
76
91
  if (isString(extend)) {
77
- const componentExists = COMPONENTS && (COMPONENTS[extend + "." + variant] || COMPONENTS[extend] || COMPONENTS["smbls." + extend]);
78
- const pageExists = PAGES && extend.startsWith("/") && PAGES[extend];
79
- if (componentExists) return componentExists;
80
- else if (pageExists) return pageExists;
81
- else {
82
- if (options.verbose && isNotProduction()) {
83
- console.warn("Extend is string but component was not found:", extend);
84
- }
85
- return {};
92
+ const variantExists = checkIfExists(extend, variant);
93
+ if (variantExists) return variantExists;
94
+ if (options.verbose && isNotProduction()) {
95
+ console.warn("Extend is string but component was not found:", extend);
86
96
  }
97
+ return {};
98
+ } else if (isArray(extend)) {
99
+ const extendKey = extend.find((element) => {
100
+ return typeof element === "string";
101
+ });
102
+ const variantExists = checkIfExists(extendKey, variant, true);
103
+ if (variantExists) return variantExists;
87
104
  }
88
105
  return extend;
89
106
  };
package/methods/index.js CHANGED
@@ -379,7 +379,7 @@ export function call(fnKey, ...args) {
379
379
  // Return synchronous results directly
380
380
  return result
381
381
  } catch (error) {
382
- console.error(`Error calling function: '${fnKey}'`)
382
+ console.error(`Error calling function: '${fnKey}'\n`, error)
383
383
  throw new Error(error)
384
384
  }
385
385
  }
package/mixins/html.js CHANGED
@@ -1,15 +1,27 @@
1
1
  'use strict'
2
2
 
3
- import { exec } from '@domql/utils'
4
-
5
3
  /**
6
4
  * Appends raw HTML as content
7
5
  * an original one as a child
8
6
  */
9
7
  export function html(param, element, node, opts) {
10
8
  const prop =
11
- exec(param, element, element.state, element.context, opts) ||
12
- exec(element?.props?.html, element, element.state, element.context, opts)
9
+ element.call(
10
+ 'exec',
11
+ param,
12
+ element,
13
+ element.state,
14
+ element.context,
15
+ opts
16
+ ) ||
17
+ element.call(
18
+ 'exec',
19
+ element?.props?.html,
20
+ element,
21
+ element.state,
22
+ element.context,
23
+ opts
24
+ )
13
25
  const { __ref } = element
14
26
  if (prop !== __ref.__html) {
15
27
  // const parser = new window.DOMParser()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.33.14",
3
+ "version": "2.33.20",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -27,12 +27,12 @@
27
27
  "prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs"
28
28
  },
29
29
  "dependencies": {
30
- "@domql/event": "^2.33.14",
31
- "@domql/render": "^2.33.14",
32
- "@domql/state": "^2.33.14",
33
- "@domql/utils": "^2.33.14"
30
+ "@domql/event": "^2.33.20",
31
+ "@domql/render": "^2.33.20",
32
+ "@domql/state": "^2.33.20",
33
+ "@domql/utils": "^2.33.20"
34
34
  },
35
- "gitHead": "6794a2267003c3ffcbf972d382e850c1fee0dbe5",
35
+ "gitHead": "717ab2ed8690b295c7d6c79e31831048f20f4e86",
36
36
  "devDependencies": {
37
37
  "@babel/core": "^7.27.1"
38
38
  }
@@ -15,7 +15,7 @@ export const generateHash = () => Math.random().toString(36).substring(2)
15
15
  export const extendStackRegistry = {}
16
16
  export const extendCachedRegistry = {}
17
17
 
18
- export const getHashedExtend = extend => {
18
+ export const getHashedExtend = (extend) => {
19
19
  return extendStackRegistry[extend.__hash]
20
20
  }
21
21
 
@@ -37,7 +37,7 @@ export const getExtendStackRegistry = (extend, stack) => {
37
37
 
38
38
  // stacking
39
39
  export const extractArrayExtend = (extend, stack, context) => {
40
- extend.forEach(each => flattenExtend(each, stack, context))
40
+ extend.forEach((each) => flattenExtend(each, stack, context))
41
41
  return stack
42
42
  }
43
43
 
@@ -79,7 +79,7 @@ export const deepMergeExtend = (element, extend) => {
79
79
  return element
80
80
  }
81
81
 
82
- export const cloneAndMergeArrayExtend = stack => {
82
+ export const cloneAndMergeArrayExtend = (stack) => {
83
83
  return stack.reduce((a, c) => {
84
84
  return deepMergeExtend(a, deepClone(c))
85
85
  }, {})
@@ -91,23 +91,39 @@ export const fallbackStringExtend = (
91
91
  options = {},
92
92
  variant
93
93
  ) => {
94
- const COMPONENTS = (context && context.components) || options.components
95
- const PAGES = (context && context.pages) || options.pages
94
+ const checkIfExists = (key, variant, onlyVariant) => {
95
+ const COMPONENTS = (context && context.components) || options.components
96
+ if (COMPONENTS) {
97
+ const hasVariant = variant && COMPONENTS[key + '.' + variant]
98
+ if (onlyVariant) return hasVariant
99
+ const componentExists =
100
+ hasVariant || COMPONENTS[key] || COMPONENTS['smbls.' + key] // add shared libraries
101
+ if (componentExists) return componentExists
102
+ }
103
+ const PAGES = (context && context.pages) || options.pages
104
+ if (PAGES) {
105
+ const pageExists = key?.startsWith('/') && PAGES[key]
106
+ if (pageExists) return pageExists
107
+ }
108
+ }
109
+
110
+ if (variant) {
111
+ console.log(extend, variant)
112
+ }
113
+
96
114
  if (isString(extend)) {
97
- const componentExists =
98
- COMPONENTS &&
99
- (COMPONENTS[extend + '.' + variant] ||
100
- COMPONENTS[extend] ||
101
- COMPONENTS['smbls.' + extend])
102
- const pageExists = PAGES && extend.startsWith('/') && PAGES[extend]
103
- if (componentExists) return componentExists
104
- else if (pageExists) return pageExists
105
- else {
106
- if (options.verbose && isNotProduction()) {
107
- console.warn('Extend is string but component was not found:', extend)
108
- }
109
- return {}
115
+ const variantExists = checkIfExists(extend, variant)
116
+ if (variantExists) return variantExists
117
+ if (options.verbose && isNotProduction()) {
118
+ console.warn('Extend is string but component was not found:', extend)
110
119
  }
120
+ return {}
121
+ } else if (isArray(extend)) {
122
+ const extendKey = extend.find((element) => {
123
+ return typeof element === 'string'
124
+ })
125
+ const variantExists = checkIfExists(extendKey, variant, true)
126
+ if (variantExists) return variantExists
111
127
  }
112
128
  return extend
113
129
  }
@@ -129,7 +145,7 @@ export const getExtendStack = (extend, context) => {
129
145
  return getExtendStackRegistry(extend, stack)
130
146
  }
131
147
 
132
- export const getExtendMerged = extend => {
148
+ export const getExtendMerged = (extend) => {
133
149
  const stack = getExtendStack(extend)
134
150
  return cloneAndMergeArrayExtend(stack)
135
151
  }