@domql/element 2.27.8 → 2.27.15

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/create.js CHANGED
@@ -40,13 +40,18 @@ import {
40
40
  applyVariant,
41
41
  createValidDomqlObjectFromSugar
42
42
  } from './utils/component.js'
43
-
44
- const ENV = process.env.NODE_ENV
43
+ import { isNotProduction } from '@domql/utils/env.js'
45
44
 
46
45
  /**
47
46
  * Creating a domQL element using passed parameters
48
47
  */
49
- export const create = async (element, parent, key, options = OPTIONS.create || {}, attachOptions) => {
48
+ export const create = async (
49
+ element,
50
+ parent,
51
+ key,
52
+ options = OPTIONS.create || {},
53
+ attachOptions
54
+ ) => {
50
55
  cacheOptions(element, options)
51
56
 
52
57
  // if element is STRING
@@ -93,7 +98,8 @@ export const create = async (element, parent, key, options = OPTIONS.create || {
93
98
 
94
99
  // apply props settings
95
100
  createProps(element, parent, options)
96
- if (element.scope === 'props' || element.scope === true) element.scope = element.props
101
+ if (element.scope === 'props' || element.scope === true)
102
+ element.scope = element.props
97
103
 
98
104
  // recatch if it passess props again
99
105
  createIfConditionFlag(element, parent)
@@ -128,13 +134,17 @@ export const create = async (element, parent, key, options = OPTIONS.create || {
128
134
  const createBasedOnType = (element, parent, key, options) => {
129
135
  // if ELEMENT is not given
130
136
  if (element === undefined) {
131
- if (ENV === 'testing' || ENV === 'development') {
132
- console.warn(key, 'element is undefined in', parent && parent.__ref && parent.__ref.path)
137
+ if (isNotProduction()) {
138
+ console.warn(
139
+ key,
140
+ 'element is undefined in',
141
+ parent && parent.__ref && parent.__ref.path
142
+ )
133
143
  }
134
144
  return {}
135
145
  }
136
146
  if (isString(key) && key.slice(0, 2 === '__')) {
137
- if (ENV === 'testing' || ENV === 'development') {
147
+ if (isNotProduction()) {
138
148
  console.warn(key, 'seems like to be in __ref')
139
149
  }
140
150
  }
@@ -152,7 +162,11 @@ const createBasedOnType = (element, parent, key, options) => {
152
162
  const redefineElement = (element, parent, key, options) => {
153
163
  const elementWrapper = createBasedOnType(element, parent, key, options)
154
164
 
155
- if (options.syntaxv3 || (element.props && element.props.syntaxv3) || (parent && parent.props && parent.props.syntaxv3) /* kalduna guard */) {
165
+ if (
166
+ options.syntaxv3 ||
167
+ (element.props && element.props.syntaxv3) ||
168
+ (parent && parent.props && parent.props.syntaxv3) /* kalduna guard */
169
+ ) {
156
170
  if (element.props) element.props.syntaxv3 = true
157
171
  else element.syntaxv3 = true
158
172
  return createValidDomqlObjectFromSugar(element, parent, key, options)
@@ -187,12 +201,7 @@ const cacheOptions = (element, options) => {
187
201
  }
188
202
 
189
203
  const createKey = (element, parent, key) => {
190
- return (
191
- exec(key, element) ||
192
- key ||
193
- element.key ||
194
- generateKey()
195
- ).toString()
204
+ return (exec(key, element) || key || element.key || generateKey()).toString()
196
205
  }
197
206
 
198
207
  const addRef = (element, parent) => {
@@ -209,13 +218,15 @@ const switchDefaultOptions = (element, parent, options) => {
209
218
  }
210
219
 
211
220
  const addElementIntoParentChildren = (element, parent) => {
212
- if (parent.__ref && parent.__ref.__children) parent.__ref.__children.push(element.key)
221
+ if (parent.__ref && parent.__ref.__children)
222
+ parent.__ref.__children.push(element.key)
213
223
  }
214
224
 
215
225
  const visitedElements = new WeakMap()
216
226
  const renderElement = async (element, parent, options, attachOptions) => {
217
227
  if (visitedElements.has(element)) {
218
- if (ENV === 'testing' || ENV === 'development') console.warn('Cyclic rendering detected:', element.__ref.path)
228
+ if (isNotProduction())
229
+ console.warn('Cyclic rendering detected:', element.__ref.path)
219
230
  }
220
231
 
221
232
  visitedElements.set(element, true)
@@ -230,21 +241,34 @@ const renderElement = async (element, parent, options, attachOptions) => {
230
241
  }
231
242
 
232
243
  // CREATE a real NODE
233
- if (ENV === 'testing' || ENV === 'development') {
244
+ if (isNotProduction()) {
234
245
  await createNestedChild()
235
246
  } else {
236
247
  try {
237
248
  await createNestedChild()
238
249
  } catch (e) {
239
250
  const path = ref.path
240
- if (path.includes('ComponentsGrid')) path.splice(0, path.indexOf('ComponentsGrid') + 2)
241
- if (path.includes('demoComponent')) path.splice(0, path.indexOf('demoComponent') + 1)
251
+ if (path.includes('ComponentsGrid'))
252
+ path.splice(0, path.indexOf('ComponentsGrid') + 2)
253
+ if (path.includes('demoComponent'))
254
+ path.splice(0, path.indexOf('demoComponent') + 1)
242
255
  const isDemoComponent = element.lookup(el => el.state.key)?.state?.key
243
- element.warn('Error happened in:', isDemoComponent ? isDemoComponent + ' ' : '' + path.join('.'))
256
+ element.warn(
257
+ 'Error happened in:',
258
+ isDemoComponent ? isDemoComponent + ' ' : '' + path.join('.')
259
+ )
244
260
  element.verbose()
245
261
  element.error(e, options)
246
- if (element.on?.error) element.on.error(e, element, element.state, element.context, options)
247
- if (element.props?.onError) element.props.onError(e, element, element.state, element.context, options)
262
+ if (element.on?.error)
263
+ element.on.error(e, element, element.state, element.context, options)
264
+ if (element.props?.onError)
265
+ element.props.onError(
266
+ e,
267
+ element,
268
+ element.state,
269
+ element.context,
270
+ options
271
+ )
248
272
  }
249
273
  }
250
274
 
@@ -273,25 +297,32 @@ const renderElement = async (element, parent, options, attachOptions) => {
273
297
  await triggerEventOn('create', element, options)
274
298
  }
275
299
 
276
- const checkIfPrimitive = (element) => is(element)('string', 'number')
300
+ const checkIfPrimitive = element => is(element)('string', 'number')
277
301
 
278
302
  const applyValueAsText = (element, parent, key) => {
279
303
  const extendTag = element.extend && element.extend.tag
280
304
  const childExtendTag = parent.childExtend && parent.childExtend.tag
281
305
  const childPropsTag = parent.props.childProps && parent.props.childProps.tag
282
- const isKeyValidHTMLTag = ((HTML_TAGS.body.indexOf(key) > -1) && key)
306
+ const isKeyValidHTMLTag = HTML_TAGS.body.indexOf(key) > -1 && key
283
307
  return {
284
308
  text: element,
285
- tag: extendTag || childExtendTag || childPropsTag || isKeyValidHTMLTag || 'string'
309
+ tag:
310
+ extendTag ||
311
+ childExtendTag ||
312
+ childPropsTag ||
313
+ isKeyValidHTMLTag ||
314
+ 'string'
286
315
  }
287
316
  }
288
317
 
289
318
  const applyContext = (element, parent, options) => {
290
- const forcedOptionsContext = options.context && !ROOT.context && !element.context
319
+ const forcedOptionsContext =
320
+ options.context && !ROOT.context && !element.context
291
321
  if (forcedOptionsContext) ROOT.context = options.context
292
322
 
293
323
  // inherit from parent or root
294
- if (!element.context) element.context = parent.context || options.context || ROOT.context
324
+ if (!element.context)
325
+ element.context = parent.context || options.context || ROOT.context
295
326
  }
296
327
 
297
328
  // Create scope - shared object across the elements to the own or the nearest parent
@@ -304,7 +335,10 @@ const createScope = (element, parent) => {
304
335
  const createIfConditionFlag = (element, parent) => {
305
336
  const { __ref: ref } = element
306
337
 
307
- if (isFunction(element.if) && !element.if(element, element.state, element.context)) {
338
+ if (
339
+ isFunction(element.if) &&
340
+ !element.if(element, element.state, element.context)
341
+ ) {
308
342
  delete ref.__if
309
343
  } else ref.__if = true
310
344
  }
@@ -337,14 +371,15 @@ const addCaching = (element, parent) => {
337
371
  // enable CHANGES storing
338
372
  if (!ref.__children) ref.__children = []
339
373
 
340
- if (checkIfKeyIsComponent(key)) ref.__componentKey = key.split('_')[0].split('.')[0].split('+')[0]
374
+ if (checkIfKeyIsComponent(key))
375
+ ref.__componentKey = key.split('_')[0].split('.')[0].split('+')[0]
341
376
 
342
377
  // Add _root element property
343
378
  const hasRoot = parent && parent.key === ':root'
344
379
  if (!ref.root) ref.root = hasRoot ? element : parentRef.root
345
380
 
346
381
  // set the PATH array
347
- // if (ENV === 'testing' || ENV === 'development') {
382
+ // if (isNotProduction()) {
348
383
  if (!parentRef) parentRef = parent.ref = {}
349
384
  if (!parentRef.path) parentRef.path = []
350
385
  ref.path = parentRef.path.concat(element.key)
@@ -367,9 +402,12 @@ const onlyResolveExtends = (element, parent, key, options) => {
367
402
 
368
403
  // apply props settings
369
404
  createProps(element, parent, options)
370
- if (element.scope === 'props' || element.scope === true) element.scope = element.props
405
+ if (element.scope === 'props' || element.scope === true)
406
+ element.scope = element.props
371
407
 
372
- if (element.node && ref.__if) { parent[key || element.key] = element } // Borrowed from assignNode()
408
+ if (element.node && ref.__if) {
409
+ parent[key || element.key] = element
410
+ } // Borrowed from assignNode()
373
411
 
374
412
  if (!element.props) element.props = {}
375
413
  applyVariant(element, parent)
@@ -387,16 +425,22 @@ const onlyResolveExtends = (element, parent, key, options) => {
387
425
  isMethod(k, element) ||
388
426
  isObject((registry.default || registry)[k]) ||
389
427
  isVariant(k)
390
- ) continue
428
+ )
429
+ continue
391
430
 
392
431
  const hasDefine = element.define && element.define[k]
393
- const contextHasDefine = element.context && element.context.define &&
394
- element.context.define[k]
432
+ const contextHasDefine =
433
+ element.context && element.context.define && element.context.define[k]
395
434
  const optionsHasDefine = options.define && options.define[k]
396
435
 
397
436
  if (!ref.__skipCreate && REGISTRY[k] && !optionsHasDefine) {
398
437
  continue
399
- } else if (element[k] && !hasDefine && !optionsHasDefine && !contextHasDefine) {
438
+ } else if (
439
+ element[k] &&
440
+ !hasDefine &&
441
+ !optionsHasDefine &&
442
+ !contextHasDefine
443
+ ) {
400
444
  create(exec(element[k], element), element, k, options)
401
445
  }
402
446
  }
@@ -416,7 +460,7 @@ const onlyResolveExtends = (element, parent, key, options) => {
416
460
  return element
417
461
  }
418
462
 
419
- const checkIfMedia = (key) => key.slice(0, 1) === '@'
463
+ const checkIfMedia = key => key.slice(0, 1) === '@'
420
464
 
421
465
  const applyMediaProps = (element, parent, key) => {
422
466
  const { props } = element
@@ -37,7 +37,7 @@ var import_classList = require("./mixins/classList.js");
37
37
  var import_iterate = require("./iterate.js");
38
38
  var import_options = require("./cache/options.js");
39
39
  var import_component = require("./utils/component.js");
40
- const ENV = "development";
40
+ var import_env = require("@domql/utils/env.js");
41
41
  const create = async (element, parent, key, options = import_options.OPTIONS.create || {}, attachOptions) => {
42
42
  cacheOptions(element, options);
43
43
  if (checkIfPrimitive(element)) {
@@ -66,7 +66,8 @@ const create = async (element, parent, key, options = import_options.OPTIONS.cre
66
66
  if (element.scope === "state") element.scope = element.state;
67
67
  createIfConditionFlag(element, parent);
68
68
  (0, import_props.createProps)(element, parent, options);
69
- if (element.scope === "props" || element.scope === true) element.scope = element.props;
69
+ if (element.scope === "props" || element.scope === true)
70
+ element.scope = element.props;
70
71
  createIfConditionFlag(element, parent);
71
72
  if (element.node && ref.__if) {
72
73
  return (0, import_render.assignNode)(element, parent, key, attachOptions);
@@ -84,13 +85,17 @@ const create = async (element, parent, key, options = import_options.OPTIONS.cre
84
85
  };
85
86
  const createBasedOnType = (element, parent, key, options) => {
86
87
  if (element === void 0) {
87
- if (ENV === "testing" || ENV === "development") {
88
- console.warn(key, "element is undefined in", parent && parent.__ref && parent.__ref.path);
88
+ if ((0, import_env.isNotProduction)()) {
89
+ console.warn(
90
+ key,
91
+ "element is undefined in",
92
+ parent && parent.__ref && parent.__ref.path
93
+ );
89
94
  }
90
95
  return {};
91
96
  }
92
97
  if ((0, import_utils.isString)(key) && key.slice(0, false)) {
93
- if (ENV === "testing" || ENV === "development") {
98
+ if ((0, import_env.isNotProduction)()) {
94
99
  console.warn(key, "seems like to be in __ref");
95
100
  }
96
101
  }
@@ -145,13 +150,15 @@ const switchDefaultOptions = (element, parent, options) => {
145
150
  }
146
151
  };
147
152
  const addElementIntoParentChildren = (element, parent) => {
148
- if (parent.__ref && parent.__ref.__children) parent.__ref.__children.push(element.key);
153
+ if (parent.__ref && parent.__ref.__children)
154
+ parent.__ref.__children.push(element.key);
149
155
  };
150
156
  const visitedElements = /* @__PURE__ */ new WeakMap();
151
157
  const renderElement = async (element, parent, options, attachOptions) => {
152
158
  var _a, _b, _c, _d;
153
159
  if (visitedElements.has(element)) {
154
- if (ENV === "testing" || ENV === "development") console.warn("Cyclic rendering detected:", element.__ref.path);
160
+ if ((0, import_env.isNotProduction)())
161
+ console.warn("Cyclic rendering detected:", element.__ref.path);
155
162
  }
156
163
  visitedElements.set(element, true);
157
164
  const { __ref: ref, key } = element;
@@ -161,21 +168,34 @@ const renderElement = async (element, parent, options, attachOptions) => {
161
168
  await (0, import_node.createNode)(element, options);
162
169
  ref.__uniqId = Math.random();
163
170
  };
164
- if (ENV === "testing" || ENV === "development") {
171
+ if ((0, import_env.isNotProduction)()) {
165
172
  await createNestedChild();
166
173
  } else {
167
174
  try {
168
175
  await createNestedChild();
169
176
  } catch (e) {
170
177
  const path = ref.path;
171
- if (path.includes("ComponentsGrid")) path.splice(0, path.indexOf("ComponentsGrid") + 2);
172
- if (path.includes("demoComponent")) path.splice(0, path.indexOf("demoComponent") + 1);
178
+ if (path.includes("ComponentsGrid"))
179
+ path.splice(0, path.indexOf("ComponentsGrid") + 2);
180
+ if (path.includes("demoComponent"))
181
+ path.splice(0, path.indexOf("demoComponent") + 1);
173
182
  const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key;
174
- element.warn("Error happened in:", isDemoComponent ? isDemoComponent + " " : "" + path.join("."));
183
+ element.warn(
184
+ "Error happened in:",
185
+ isDemoComponent ? isDemoComponent + " " : "" + path.join(".")
186
+ );
175
187
  element.verbose();
176
188
  element.error(e, options);
177
- if ((_c = element.on) == null ? void 0 : _c.error) element.on.error(e, element, element.state, element.context, options);
178
- if ((_d = element.props) == null ? void 0 : _d.onError) element.props.onError(e, element, element.state, element.context, options);
189
+ if ((_c = element.on) == null ? void 0 : _c.error)
190
+ element.on.error(e, element, element.state, element.context, options);
191
+ if ((_d = element.props) == null ? void 0 : _d.onError)
192
+ element.props.onError(
193
+ e,
194
+ element,
195
+ element.state,
196
+ element.context,
197
+ options
198
+ );
179
199
  }
180
200
  }
181
201
  if (!ref.__if) {
@@ -203,7 +223,8 @@ const applyValueAsText = (element, parent, key) => {
203
223
  const applyContext = (element, parent, options) => {
204
224
  const forcedOptionsContext = options.context && !import_tree.ROOT.context && !element.context;
205
225
  if (forcedOptionsContext) import_tree.ROOT.context = options.context;
206
- if (!element.context) element.context = parent.context || options.context || import_tree.ROOT.context;
226
+ if (!element.context)
227
+ element.context = parent.context || options.context || import_tree.ROOT.context;
207
228
  };
208
229
  const createScope = (element, parent) => {
209
230
  const { __ref: ref } = element;
@@ -228,7 +249,8 @@ const addCaching = (element, parent) => {
228
249
  if (!ref.__attr) ref.__attr = {};
229
250
  if (!ref.__changes) ref.__changes = [];
230
251
  if (!ref.__children) ref.__children = [];
231
- if ((0, import_utils.checkIfKeyIsComponent)(key)) ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0];
252
+ if ((0, import_utils.checkIfKeyIsComponent)(key))
253
+ ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0];
232
254
  const hasRoot = parent && parent.key === ":root";
233
255
  if (!ref.root) ref.root = hasRoot ? element : parentRef.root;
234
256
  if (!parentRef) parentRef = parent.ref = {};
@@ -245,7 +267,8 @@ const onlyResolveExtends = (element, parent, key, options) => {
245
267
  if (element.scope === "state") element.scope = element.state;
246
268
  createIfConditionFlag(element, parent);
247
269
  (0, import_props.createProps)(element, parent, options);
248
- if (element.scope === "props" || element.scope === true) element.scope = element.props;
270
+ if (element.scope === "props" || element.scope === true)
271
+ element.scope = element.props;
249
272
  if (element.node && ref.__if) {
250
273
  parent[key || element.key] = element;
251
274
  }
@@ -257,7 +280,8 @@ const onlyResolveExtends = (element, parent, key, options) => {
257
280
  (0, import_iterate.throughInitialDefine)(element);
258
281
  (0, import_iterate.throughInitialExec)(element);
259
282
  for (const k in element) {
260
- if ((0, import_utils.isUndefined)(element[k]) || (0, import_methods.isMethod)(k, element) || (0, import_utils.isObject)((import_mixins.registry.default || import_mixins.registry)[k]) || (0, import_utils.isVariant)(k)) continue;
283
+ if ((0, import_utils.isUndefined)(element[k]) || (0, import_methods.isMethod)(k, element) || (0, import_utils.isObject)((import_mixins.registry.default || import_mixins.registry)[k]) || (0, import_utils.isVariant)(k))
284
+ continue;
261
285
  const hasDefine = element.define && element.define[k];
262
286
  const contextHasDefine = element.context && element.context.define && element.context.define[k];
263
287
  const optionsHasDefine = options.define && options.define[k];
@@ -23,7 +23,6 @@ __export(extend_exports, {
23
23
  module.exports = __toCommonJS(extend_exports);
24
24
  var import_utils = require("@domql/utils");
25
25
  var import_utils2 = require("./utils/index.js");
26
- const ENV = "development";
27
26
  let mainExtend;
28
27
  const applyExtend = (element, parent, options = {}) => {
29
28
  if ((0, import_utils.isFunction)(element)) element = (0, import_utils.exec)(element, parent);
@@ -33,7 +32,7 @@ const applyExtend = (element, parent, options = {}) => {
33
32
  const context = element.context || parent.context;
34
33
  extend = (0, import_utils2.fallbackStringExtend)(extend, context, options, variant);
35
34
  const extendStack = (0, import_utils2.getExtendStack)(extend, context);
36
- if (ENV !== "testing" || ENV !== "development") delete element.extend;
35
+ if ((0, import_utils.isProduction)()) delete element.extend;
37
36
  let childExtendStack = [];
38
37
  if (parent) {
39
38
  element.parent = parent;
@@ -43,7 +42,10 @@ const applyExtend = (element, parent, options = {}) => {
43
42
  if (parent.childExtendRecursive && !ignoreChildExtendRecursive) {
44
43
  const canExtendRecursive = element.key !== "__text";
45
44
  if (canExtendRecursive) {
46
- const childExtendRecursiveStack = (0, import_utils2.getExtendStack)(parent.childExtendRecursive, context);
45
+ const childExtendRecursiveStack = (0, import_utils2.getExtendStack)(
46
+ parent.childExtendRecursive,
47
+ context
48
+ );
47
49
  childExtendStack = childExtendStack.concat(childExtendRecursiveStack);
48
50
  element.childExtendRecursive = parent.childExtendRecursive;
49
51
  }
@@ -62,7 +64,10 @@ const applyExtend = (element, parent, options = {}) => {
62
64
  } else if (!context.defaultExtends) return element;
63
65
  if (context.defaultExtends) {
64
66
  if (!mainExtend) {
65
- const defaultOptionsExtend = (0, import_utils2.getExtendStack)(context.defaultExtends, context);
67
+ const defaultOptionsExtend = (0, import_utils2.getExtendStack)(
68
+ context.defaultExtends,
69
+ context
70
+ );
66
71
  mainExtend = (0, import_utils2.cloneAndMergeArrayExtend)(defaultOptionsExtend);
67
72
  delete mainExtend.extend;
68
73
  }
@@ -73,7 +78,9 @@ const applyExtend = (element, parent, options = {}) => {
73
78
  const COMPONENTS = context && context.components || options.components;
74
79
  const component = (0, import_utils.exec)(element.component || mergedExtend.component, element);
75
80
  if (component && COMPONENTS && COMPONENTS[component]) {
76
- const componentExtend = (0, import_utils2.cloneAndMergeArrayExtend)((0, import_utils2.getExtendStack)(COMPONENTS[component]));
81
+ const componentExtend = (0, import_utils2.cloneAndMergeArrayExtend)(
82
+ (0, import_utils2.getExtendStack)(COMPONENTS[component])
83
+ );
77
84
  mergedExtend = (0, import_utils2.deepMergeExtend)(componentExtend, mergedExtend);
78
85
  }
79
86
  const merged = (0, import_utils2.deepMergeExtend)(element, mergedExtend);
@@ -48,7 +48,6 @@ var import_event = require("@domql/event");
48
48
  var import_utils = require("@domql/utils");
49
49
  var import_tree = require("../tree.js");
50
50
  var import_mixins = require("../mixins/index.js");
51
- const ENV = "development";
52
51
  function spotByPath(path) {
53
52
  const element = this;
54
53
  const arr = [].concat(path);
@@ -207,7 +206,7 @@ function parseDeep(excl = []) {
207
206
  return obj;
208
207
  }
209
208
  function verbose(element, ...args) {
210
- if (ENV !== "testing" && ENV !== "development") return;
209
+ if ((0, import_utils.isProduction)()) return;
211
210
  const parent = this;
212
211
  const { __ref: ref } = parent;
213
212
  console.groupCollapsed(parent.key);
@@ -224,18 +223,18 @@ function verbose(element, ...args) {
224
223
  return parent;
225
224
  }
226
225
  function log(...params) {
227
- if (ENV === "testing" || ENV === "development") {
226
+ if ((0, import_utils.isNotProduction)()) {
228
227
  console.log(...params);
229
228
  }
230
229
  }
231
230
  function warn(...params) {
232
- if (ENV === "testing" || ENV === "development") {
231
+ if ((0, import_utils.isNotProduction)()) {
233
232
  console.warn(...params);
234
233
  }
235
234
  }
236
235
  function error(...params) {
237
236
  var _a, _b;
238
- if (ENV === "testing" || ENV === "development") {
237
+ if ((0, import_utils.isNotProduction)()) {
239
238
  if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) debugger;
240
239
  if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) verbose.call(this, ...params);
241
240
  console.error(...params, this);
package/dist/cjs/node.js CHANGED
@@ -31,7 +31,7 @@ var import_iterate = require("./iterate.js");
31
31
  var import_mixins = require("./mixins/index.js");
32
32
  var import_applyParam = require("./utils/applyParam.js");
33
33
  var import_propEvents = require("./utils/propEvents.js");
34
- const ENV = "development";
34
+ var import_env = require("@domql/utils/env.js");
35
35
  const createNode = async (element, options) => {
36
36
  let { node, tag, __ref: ref } = element;
37
37
  let isNewNode;
@@ -43,7 +43,7 @@ const createNode = async (element, options) => {
43
43
  } else node = element.node = (0, import_render.cacheNode)(element);
44
44
  await (0, import_event.triggerEventOn)("attachNode", element, options);
45
45
  }
46
- if (ENV === "testing" || ENV === "development" || options.alowRefReference) {
46
+ if ((0, import_env.isNotProduction)() || options.alowRefReference) {
47
47
  node.ref = element;
48
48
  if ((0, import_utils.isFunction)(node.setAttribute)) node.setAttribute("key", element.key);
49
49
  }
@@ -59,7 +59,8 @@ const createNode = async (element, options) => {
59
59
  for (const param in element) {
60
60
  const value = element[param];
61
61
  if (!Object.hasOwnProperty.call(element, param)) continue;
62
- if ((0, import_utils.isUndefined)(value) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isVariant)(param) || (0, import_utils.isObject)(import_mixins.REGISTRY[param])) continue;
62
+ if ((0, import_utils.isUndefined)(value) || (0, import_methods.isMethod)(param, element) || (0, import_utils.isVariant)(param) || (0, import_utils.isObject)(import_mixins.REGISTRY[param]))
63
+ continue;
63
64
  const isElement = await (0, import_applyParam.applyParam)(param, element, options);
64
65
  if (isElement) {
65
66
  const { hasDefine, hasContextDefine } = isElement;
@@ -36,7 +36,6 @@ __export(extendUtils_exports, {
36
36
  });
37
37
  module.exports = __toCommonJS(extendUtils_exports);
38
38
  var import_utils = require("@domql/utils");
39
- const ENV = "development";
40
39
  const generateHash = () => Math.random().toString(36).substring(2);
41
40
  const extendStackRegistry = {};
42
41
  const extendCachedRegistry = {};
@@ -110,7 +109,7 @@ const fallbackStringExtend = (extend, context, options = {}, variant) => {
110
109
  if (componentExists) return componentExists;
111
110
  else if (pageExists) return pageExists;
112
111
  else {
113
- if (options.verbose && (ENV === "testing" || ENV === "development")) {
112
+ if (options.verbose && (0, import_utils.isNotProduction)()) {
114
113
  console.warn("Extend is string but component was not found:", extend);
115
114
  }
116
115
  return {};
@@ -33,7 +33,7 @@ import {
33
33
  applyVariant,
34
34
  createValidDomqlObjectFromSugar
35
35
  } from "./utils/component.js";
36
- const ENV = "development";
36
+ import { isNotProduction } from "@domql/utils/env.js";
37
37
  const create = async (element, parent, key, options = OPTIONS.create || {}, attachOptions) => {
38
38
  cacheOptions(element, options);
39
39
  if (checkIfPrimitive(element)) {
@@ -62,7 +62,8 @@ const create = async (element, parent, key, options = OPTIONS.create || {}, atta
62
62
  if (element.scope === "state") element.scope = element.state;
63
63
  createIfConditionFlag(element, parent);
64
64
  createProps(element, parent, options);
65
- if (element.scope === "props" || element.scope === true) element.scope = element.props;
65
+ if (element.scope === "props" || element.scope === true)
66
+ element.scope = element.props;
66
67
  createIfConditionFlag(element, parent);
67
68
  if (element.node && ref.__if) {
68
69
  return assignNode(element, parent, key, attachOptions);
@@ -80,13 +81,17 @@ const create = async (element, parent, key, options = OPTIONS.create || {}, atta
80
81
  };
81
82
  const createBasedOnType = (element, parent, key, options) => {
82
83
  if (element === void 0) {
83
- if (ENV === "testing" || ENV === "development") {
84
- console.warn(key, "element is undefined in", parent && parent.__ref && parent.__ref.path);
84
+ if (isNotProduction()) {
85
+ console.warn(
86
+ key,
87
+ "element is undefined in",
88
+ parent && parent.__ref && parent.__ref.path
89
+ );
85
90
  }
86
91
  return {};
87
92
  }
88
93
  if (isString(key) && key.slice(0, false)) {
89
- if (ENV === "testing" || ENV === "development") {
94
+ if (isNotProduction()) {
90
95
  console.warn(key, "seems like to be in __ref");
91
96
  }
92
97
  }
@@ -141,13 +146,15 @@ const switchDefaultOptions = (element, parent, options) => {
141
146
  }
142
147
  };
143
148
  const addElementIntoParentChildren = (element, parent) => {
144
- if (parent.__ref && parent.__ref.__children) parent.__ref.__children.push(element.key);
149
+ if (parent.__ref && parent.__ref.__children)
150
+ parent.__ref.__children.push(element.key);
145
151
  };
146
152
  const visitedElements = /* @__PURE__ */ new WeakMap();
147
153
  const renderElement = async (element, parent, options, attachOptions) => {
148
154
  var _a, _b, _c, _d;
149
155
  if (visitedElements.has(element)) {
150
- if (ENV === "testing" || ENV === "development") console.warn("Cyclic rendering detected:", element.__ref.path);
156
+ if (isNotProduction())
157
+ console.warn("Cyclic rendering detected:", element.__ref.path);
151
158
  }
152
159
  visitedElements.set(element, true);
153
160
  const { __ref: ref, key } = element;
@@ -157,21 +164,34 @@ const renderElement = async (element, parent, options, attachOptions) => {
157
164
  await createNode(element, options);
158
165
  ref.__uniqId = Math.random();
159
166
  };
160
- if (ENV === "testing" || ENV === "development") {
167
+ if (isNotProduction()) {
161
168
  await createNestedChild();
162
169
  } else {
163
170
  try {
164
171
  await createNestedChild();
165
172
  } catch (e) {
166
173
  const path = ref.path;
167
- if (path.includes("ComponentsGrid")) path.splice(0, path.indexOf("ComponentsGrid") + 2);
168
- if (path.includes("demoComponent")) path.splice(0, path.indexOf("demoComponent") + 1);
174
+ if (path.includes("ComponentsGrid"))
175
+ path.splice(0, path.indexOf("ComponentsGrid") + 2);
176
+ if (path.includes("demoComponent"))
177
+ path.splice(0, path.indexOf("demoComponent") + 1);
169
178
  const isDemoComponent = (_b = (_a = element.lookup((el) => el.state.key)) == null ? void 0 : _a.state) == null ? void 0 : _b.key;
170
- element.warn("Error happened in:", isDemoComponent ? isDemoComponent + " " : "" + path.join("."));
179
+ element.warn(
180
+ "Error happened in:",
181
+ isDemoComponent ? isDemoComponent + " " : "" + path.join(".")
182
+ );
171
183
  element.verbose();
172
184
  element.error(e, options);
173
- if ((_c = element.on) == null ? void 0 : _c.error) element.on.error(e, element, element.state, element.context, options);
174
- if ((_d = element.props) == null ? void 0 : _d.onError) element.props.onError(e, element, element.state, element.context, options);
185
+ if ((_c = element.on) == null ? void 0 : _c.error)
186
+ element.on.error(e, element, element.state, element.context, options);
187
+ if ((_d = element.props) == null ? void 0 : _d.onError)
188
+ element.props.onError(
189
+ e,
190
+ element,
191
+ element.state,
192
+ element.context,
193
+ options
194
+ );
175
195
  }
176
196
  }
177
197
  if (!ref.__if) {
@@ -199,7 +219,8 @@ const applyValueAsText = (element, parent, key) => {
199
219
  const applyContext = (element, parent, options) => {
200
220
  const forcedOptionsContext = options.context && !ROOT.context && !element.context;
201
221
  if (forcedOptionsContext) ROOT.context = options.context;
202
- if (!element.context) element.context = parent.context || options.context || ROOT.context;
222
+ if (!element.context)
223
+ element.context = parent.context || options.context || ROOT.context;
203
224
  };
204
225
  const createScope = (element, parent) => {
205
226
  const { __ref: ref } = element;
@@ -224,7 +245,8 @@ const addCaching = (element, parent) => {
224
245
  if (!ref.__attr) ref.__attr = {};
225
246
  if (!ref.__changes) ref.__changes = [];
226
247
  if (!ref.__children) ref.__children = [];
227
- if (checkIfKeyIsComponent(key)) ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0];
248
+ if (checkIfKeyIsComponent(key))
249
+ ref.__componentKey = key.split("_")[0].split(".")[0].split("+")[0];
228
250
  const hasRoot = parent && parent.key === ":root";
229
251
  if (!ref.root) ref.root = hasRoot ? element : parentRef.root;
230
252
  if (!parentRef) parentRef = parent.ref = {};
@@ -241,7 +263,8 @@ const onlyResolveExtends = (element, parent, key, options) => {
241
263
  if (element.scope === "state") element.scope = element.state;
242
264
  createIfConditionFlag(element, parent);
243
265
  createProps(element, parent, options);
244
- if (element.scope === "props" || element.scope === true) element.scope = element.props;
266
+ if (element.scope === "props" || element.scope === true)
267
+ element.scope = element.props;
245
268
  if (element.node && ref.__if) {
246
269
  parent[key || element.key] = element;
247
270
  }
@@ -253,7 +276,8 @@ const onlyResolveExtends = (element, parent, key, options) => {
253
276
  throughInitialDefine(element);
254
277
  throughInitialExec(element);
255
278
  for (const k in element) {
256
- if (isUndefined(element[k]) || isMethod(k, element) || isObject((registry.default || registry)[k]) || isVariant(k)) continue;
279
+ if (isUndefined(element[k]) || isMethod(k, element) || isObject((registry.default || registry)[k]) || isVariant(k))
280
+ continue;
257
281
  const hasDefine = element.define && element.define[k];
258
282
  const contextHasDefine = element.context && element.context.define && element.context.define[k];
259
283
  const optionsHasDefine = options.define && options.define[k];
@@ -1,4 +1,4 @@
1
- import { isFunction, exec } from "@domql/utils";
1
+ import { isFunction, exec, isProduction } from "@domql/utils";
2
2
  import {
3
3
  getExtendStack,
4
4
  jointStacks,
@@ -6,7 +6,6 @@ import {
6
6
  deepMergeExtend,
7
7
  fallbackStringExtend
8
8
  } from "./utils/index.js";
9
- const ENV = "development";
10
9
  let mainExtend;
11
10
  const applyExtend = (element, parent, options = {}) => {
12
11
  if (isFunction(element)) element = exec(element, parent);
@@ -16,7 +15,7 @@ const applyExtend = (element, parent, options = {}) => {
16
15
  const context = element.context || parent.context;
17
16
  extend = fallbackStringExtend(extend, context, options, variant);
18
17
  const extendStack = getExtendStack(extend, context);
19
- if (ENV !== "testing" || ENV !== "development") delete element.extend;
18
+ if (isProduction()) delete element.extend;
20
19
  let childExtendStack = [];
21
20
  if (parent) {
22
21
  element.parent = parent;
@@ -26,7 +25,10 @@ const applyExtend = (element, parent, options = {}) => {
26
25
  if (parent.childExtendRecursive && !ignoreChildExtendRecursive) {
27
26
  const canExtendRecursive = element.key !== "__text";
28
27
  if (canExtendRecursive) {
29
- const childExtendRecursiveStack = getExtendStack(parent.childExtendRecursive, context);
28
+ const childExtendRecursiveStack = getExtendStack(
29
+ parent.childExtendRecursive,
30
+ context
31
+ );
30
32
  childExtendStack = childExtendStack.concat(childExtendRecursiveStack);
31
33
  element.childExtendRecursive = parent.childExtendRecursive;
32
34
  }
@@ -45,7 +47,10 @@ const applyExtend = (element, parent, options = {}) => {
45
47
  } else if (!context.defaultExtends) return element;
46
48
  if (context.defaultExtends) {
47
49
  if (!mainExtend) {
48
- const defaultOptionsExtend = getExtendStack(context.defaultExtends, context);
50
+ const defaultOptionsExtend = getExtendStack(
51
+ context.defaultExtends,
52
+ context
53
+ );
49
54
  mainExtend = cloneAndMergeArrayExtend(defaultOptionsExtend);
50
55
  delete mainExtend.extend;
51
56
  }
@@ -56,7 +61,9 @@ const applyExtend = (element, parent, options = {}) => {
56
61
  const COMPONENTS = context && context.components || options.components;
57
62
  const component = exec(element.component || mergedExtend.component, element);
58
63
  if (component && COMPONENTS && COMPONENTS[component]) {
59
- const componentExtend = cloneAndMergeArrayExtend(getExtendStack(COMPONENTS[component]));
64
+ const componentExtend = cloneAndMergeArrayExtend(
65
+ getExtendStack(COMPONENTS[component])
66
+ );
60
67
  mergedExtend = deepMergeExtend(componentExtend, mergedExtend);
61
68
  }
62
69
  const merged = deepMergeExtend(element, mergedExtend);
@@ -6,11 +6,11 @@ import {
6
6
  isObjectLike,
7
7
  isProduction,
8
8
  removeValueFromArray,
9
- deepClone
9
+ deepClone,
10
+ isNotProduction
10
11
  } from "@domql/utils";
11
12
  import { TREE } from "../tree.js";
12
13
  import { parseFilters, REGISTRY } from "../mixins/index.js";
13
- const ENV = "development";
14
14
  function spotByPath(path) {
15
15
  const element = this;
16
16
  const arr = [].concat(path);
@@ -169,7 +169,7 @@ function parseDeep(excl = []) {
169
169
  return obj;
170
170
  }
171
171
  function verbose(element, ...args) {
172
- if (ENV !== "testing" && ENV !== "development") return;
172
+ if (isProduction()) return;
173
173
  const parent = this;
174
174
  const { __ref: ref } = parent;
175
175
  console.groupCollapsed(parent.key);
@@ -186,18 +186,18 @@ function verbose(element, ...args) {
186
186
  return parent;
187
187
  }
188
188
  function log(...params) {
189
- if (ENV === "testing" || ENV === "development") {
189
+ if (isNotProduction()) {
190
190
  console.log(...params);
191
191
  }
192
192
  }
193
193
  function warn(...params) {
194
- if (ENV === "testing" || ENV === "development") {
194
+ if (isNotProduction()) {
195
195
  console.warn(...params);
196
196
  }
197
197
  }
198
198
  function error(...params) {
199
199
  var _a, _b;
200
- if (ENV === "testing" || ENV === "development") {
200
+ if (isNotProduction()) {
201
201
  if ((_a = params[params.length - 1]) == null ? void 0 : _a.debugger) debugger;
202
202
  if ((_b = params[params.length - 1]) == null ? void 0 : _b.verbose) verbose.call(this, ...params);
203
203
  console.error(...params, this);
package/dist/esm/node.js CHANGED
@@ -1,4 +1,10 @@
1
- import { exec, isFunction, isObject, isUndefined, isVariant } from "@domql/utils";
1
+ import {
2
+ exec,
3
+ isFunction,
4
+ isObject,
5
+ isUndefined,
6
+ isVariant
7
+ } from "@domql/utils";
2
8
  import { applyEventsOnNode, triggerEventOn } from "@domql/event";
3
9
  import { cacheNode } from "@domql/render";
4
10
  import { isMethod } from "./methods/index.js";
@@ -11,7 +17,7 @@ import {
11
17
  import { REGISTRY } from "./mixins/index.js";
12
18
  import { applyParam } from "./utils/applyParam.js";
13
19
  import { propagateEventsFromProps } from "./utils/propEvents.js";
14
- const ENV = "development";
20
+ import { isNotProduction } from "@domql/utils/env.js";
15
21
  const createNode = async (element, options) => {
16
22
  let { node, tag, __ref: ref } = element;
17
23
  let isNewNode;
@@ -23,7 +29,7 @@ const createNode = async (element, options) => {
23
29
  } else node = element.node = cacheNode(element);
24
30
  await triggerEventOn("attachNode", element, options);
25
31
  }
26
- if (ENV === "testing" || ENV === "development" || options.alowRefReference) {
32
+ if (isNotProduction() || options.alowRefReference) {
27
33
  node.ref = element;
28
34
  if (isFunction(node.setAttribute)) node.setAttribute("key", element.key);
29
35
  }
@@ -39,7 +45,8 @@ const createNode = async (element, options) => {
39
45
  for (const param in element) {
40
46
  const value = element[param];
41
47
  if (!Object.hasOwnProperty.call(element, param)) continue;
42
- if (isUndefined(value) || isMethod(param, element) || isVariant(param) || isObject(REGISTRY[param])) continue;
48
+ if (isUndefined(value) || isMethod(param, element) || isVariant(param) || isObject(REGISTRY[param]))
49
+ continue;
43
50
  const isElement = await applyParam(param, element, options);
44
51
  if (isElement) {
45
52
  const { hasDefine, hasContextDefine } = isElement;
@@ -1,5 +1,11 @@
1
- import { isArray, isFunction, isObject, isString, deepClone } from "@domql/utils";
2
- const ENV = "development";
1
+ import {
2
+ isArray,
3
+ isFunction,
4
+ isObject,
5
+ isString,
6
+ deepClone,
7
+ isNotProduction
8
+ } from "@domql/utils";
3
9
  const generateHash = () => Math.random().toString(36).substring(2);
4
10
  const extendStackRegistry = {};
5
11
  const extendCachedRegistry = {};
@@ -73,7 +79,7 @@ const fallbackStringExtend = (extend, context, options = {}, variant) => {
73
79
  if (componentExists) return componentExists;
74
80
  else if (pageExists) return pageExists;
75
81
  else {
76
- if (options.verbose && (ENV === "testing" || ENV === "development")) {
82
+ if (options.verbose && isNotProduction()) {
77
83
  console.warn("Extend is string but component was not found:", extend);
78
84
  }
79
85
  return {};
package/extend.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { isFunction, exec } from '@domql/utils'
3
+ import { isFunction, exec, isProduction } from '@domql/utils'
4
4
  import {
5
5
  getExtendStack,
6
6
  jointStacks,
@@ -9,8 +9,6 @@ import {
9
9
  fallbackStringExtend
10
10
  } from './utils/index.js'
11
11
 
12
- const ENV = process.env.NODE_ENV
13
-
14
12
  let mainExtend
15
13
 
16
14
  /**
@@ -29,7 +27,7 @@ export const applyExtend = (element, parent, options = {}) => {
29
27
 
30
28
  const extendStack = getExtendStack(extend, context)
31
29
 
32
- if (ENV !== 'testing' || ENV !== 'development') delete element.extend
30
+ if (isProduction()) delete element.extend
33
31
 
34
32
  let childExtendStack = []
35
33
  if (parent) {
@@ -41,11 +39,15 @@ export const applyExtend = (element, parent, options = {}) => {
41
39
  // if (!options.ignoreChildExtend && !(props && exec(props, element).ignoreChildExtend)) {
42
40
  // const ignoreChildExtendRecursive = props && exec(props, element).ignoreChildExtendRecursive
43
41
 
44
- const ignoreChildExtendRecursive = props && props.ignoreChildExtendRecursive
42
+ const ignoreChildExtendRecursive =
43
+ props && props.ignoreChildExtendRecursive
45
44
  if (parent.childExtendRecursive && !ignoreChildExtendRecursive) {
46
45
  const canExtendRecursive = element.key !== '__text'
47
46
  if (canExtendRecursive) {
48
- const childExtendRecursiveStack = getExtendStack(parent.childExtendRecursive, context)
47
+ const childExtendRecursiveStack = getExtendStack(
48
+ parent.childExtendRecursive,
49
+ context
50
+ )
49
51
  // add error if childExtendRecursive contains element which goes to infinite loop
50
52
  childExtendStack = childExtendStack.concat(childExtendRecursiveStack)
51
53
  element.childExtendRecursive = parent.childExtendRecursive
@@ -68,7 +70,10 @@ export const applyExtend = (element, parent, options = {}) => {
68
70
 
69
71
  if (context.defaultExtends) {
70
72
  if (!mainExtend) {
71
- const defaultOptionsExtend = getExtendStack(context.defaultExtends, context)
73
+ const defaultOptionsExtend = getExtendStack(
74
+ context.defaultExtends,
75
+ context
76
+ )
72
77
  mainExtend = cloneAndMergeArrayExtend(defaultOptionsExtend)
73
78
  delete mainExtend.extend
74
79
  }
@@ -81,7 +86,9 @@ export const applyExtend = (element, parent, options = {}) => {
81
86
  const COMPONENTS = (context && context.components) || options.components
82
87
  const component = exec(element.component || mergedExtend.component, element)
83
88
  if (component && COMPONENTS && COMPONENTS[component]) {
84
- const componentExtend = cloneAndMergeArrayExtend(getExtendStack(COMPONENTS[component]))
89
+ const componentExtend = cloneAndMergeArrayExtend(
90
+ getExtendStack(COMPONENTS[component])
91
+ )
85
92
  mergedExtend = deepMergeExtend(componentExtend, mergedExtend)
86
93
  }
87
94
 
package/methods/index.js CHANGED
@@ -8,11 +8,11 @@ import {
8
8
  isObjectLike,
9
9
  isProduction,
10
10
  removeValueFromArray,
11
- deepClone
11
+ deepClone,
12
+ isNotProduction
12
13
  } from '@domql/utils'
13
14
  import { TREE } from '../tree.js'
14
15
  import { parseFilters, REGISTRY } from '../mixins/index.js'
15
- const ENV = process.env.NODE_ENV
16
16
 
17
17
  // TODO: update these files
18
18
  export function spotByPath (path) {
@@ -211,7 +211,7 @@ export function parseDeep (excl = []) {
211
211
  }
212
212
 
213
213
  export function verbose (element, ...args) {
214
- if (ENV !== 'testing' && ENV !== 'development') return
214
+ if (isProduction()) return
215
215
 
216
216
  const parent = this
217
217
  const { __ref: ref } = parent
@@ -229,19 +229,19 @@ export function verbose (element, ...args) {
229
229
  }
230
230
 
231
231
  export function log (...params) {
232
- if (ENV === 'testing' || ENV === 'development') {
232
+ if (isNotProduction()) {
233
233
  console.log(...params)
234
234
  }
235
235
  }
236
236
 
237
237
  export function warn (...params) {
238
- if (ENV === 'testing' || ENV === 'development') {
238
+ if (isNotProduction()) {
239
239
  console.warn(...params)
240
240
  }
241
241
  }
242
242
 
243
243
  export function error (...params) {
244
- if (ENV === 'testing' || ENV === 'development') {
244
+ if (isNotProduction()) {
245
245
  if (params[params.length - 1]?.debugger) debugger // eslint-disable-line
246
246
  if (params[params.length - 1]?.verbose) verbose.call(this, ...params)
247
247
  console.error(...params, this)
package/node.js CHANGED
@@ -1,6 +1,12 @@
1
1
  'use strict'
2
2
 
3
- import { exec, isFunction, isObject, isUndefined, isVariant } from '@domql/utils'
3
+ import {
4
+ exec,
5
+ isFunction,
6
+ isObject,
7
+ isUndefined,
8
+ isVariant
9
+ } from '@domql/utils'
4
10
  import { applyEventsOnNode, triggerEventOn } from '@domql/event'
5
11
  import { cacheNode } from '@domql/render'
6
12
  import { isMethod } from './methods/index.js'
@@ -14,10 +20,9 @@ import {
14
20
  import { REGISTRY } from './mixins/index.js'
15
21
  import { applyParam } from './utils/applyParam.js'
16
22
  import { propagateEventsFromProps } from './utils/propEvents.js'
23
+ import { isNotProduction } from '@domql/utils/env.js'
17
24
  // import { defineSetter } from './methods'
18
25
 
19
- const ENV = process.env.NODE_ENV
20
-
21
26
  export const createNode = async (element, options) => {
22
27
  // create and assign a node
23
28
  let { node, tag, __ref: ref } = element
@@ -38,7 +43,7 @@ export const createNode = async (element, options) => {
38
43
  }
39
44
  // node.dataset // .key = element.key
40
45
 
41
- if (ENV === 'testing' || ENV === 'development' || options.alowRefReference) {
46
+ if (isNotProduction() || options.alowRefReference) {
42
47
  node.ref = element
43
48
  if (isFunction(node.setAttribute)) node.setAttribute('key', element.key)
44
49
  }
@@ -70,7 +75,8 @@ export const createNode = async (element, options) => {
70
75
  isMethod(param, element) ||
71
76
  isVariant(param) ||
72
77
  isObject(REGISTRY[param])
73
- ) continue
78
+ )
79
+ continue
74
80
 
75
81
  const isElement = await applyParam(param, element, options)
76
82
  if (isElement) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.27.8",
3
+ "version": "2.27.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -21,18 +21,18 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
24
- "build:esm": "cross-env NODE_ENV=$NODE_ENV npx esbuild *.js **/*.js --target=es2019 --format=esm --outdir=dist/esm",
25
- "build:cjs": "cross-env NODE_ENV=$NODE_ENV npx esbuild *.js **/*.js --target=node16 --format=cjs --outdir=dist/cjs",
24
+ "build:esm": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js **/*.js --target=es2019 --format=esm --outdir=dist/esm",
25
+ "build:cjs": "npx cross-env NODE_ENV=$NODE_ENV npx esbuild *.js **/*.js --target=node16 --format=cjs --outdir=dist/cjs",
26
26
  "build": "npx rimraf -I dist; npm run build:cjs; npm run build:esm",
27
27
  "prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs"
28
28
  },
29
29
  "dependencies": {
30
- "@domql/event": "^2.27.8",
31
- "@domql/render": "^2.27.8",
32
- "@domql/state": "^2.27.8",
33
- "@domql/utils": "^2.27.8"
30
+ "@domql/event": "^2.27.15",
31
+ "@domql/render": "^2.27.15",
32
+ "@domql/state": "^2.27.15",
33
+ "@domql/utils": "^2.27.15"
34
34
  },
35
- "gitHead": "e783fd54228d5c7aaab9d4b5624199a17a6c4713",
35
+ "gitHead": "aa562640d37f34a66e567c177be8f6ab6b41eccc",
36
36
  "devDependencies": {
37
37
  "@babel/core": "^7.26.0"
38
38
  }
@@ -1,7 +1,13 @@
1
1
  'use strict'
2
2
 
3
- import { isArray, isFunction, isObject, isString, deepClone } from '@domql/utils'
4
- const ENV = process.env.NODE_ENV
3
+ import {
4
+ isArray,
5
+ isFunction,
6
+ isObject,
7
+ isString,
8
+ deepClone,
9
+ isNotProduction
10
+ } from '@domql/utils'
5
11
 
6
12
  export const generateHash = () => Math.random().toString(36).substring(2)
7
13
 
@@ -15,13 +21,17 @@ export const getHashedExtend = extend => {
15
21
 
16
22
  export const setHashedExtend = (extend, stack) => {
17
23
  const hash = generateHash()
18
- if (!isString(extend)) { extend.__hash = hash }
24
+ if (!isString(extend)) {
25
+ extend.__hash = hash
26
+ }
19
27
  extendStackRegistry[hash] = stack
20
28
  return stack
21
29
  }
22
30
 
23
31
  export const getExtendStackRegistry = (extend, stack) => {
24
- if (extend.__hash) { return stack.concat(getHashedExtend(extend)) }
32
+ if (extend.__hash) {
33
+ return stack.concat(getHashedExtend(extend))
34
+ }
25
35
  return setHashedExtend(extend, stack) // stack .concat(hashedExtend)
26
36
  }
27
37
 
@@ -75,20 +85,25 @@ export const cloneAndMergeArrayExtend = stack => {
75
85
  }, {})
76
86
  }
77
87
 
78
- export const fallbackStringExtend = (extend, context, options = {}, variant) => {
88
+ export const fallbackStringExtend = (
89
+ extend,
90
+ context,
91
+ options = {},
92
+ variant
93
+ ) => {
79
94
  const COMPONENTS = (context && context.components) || options.components
80
95
  const PAGES = (context && context.pages) || options.pages
81
96
  if (isString(extend)) {
82
- const componentExists = COMPONENTS && (
83
- COMPONENTS[extend + '.' + variant] ||
84
- COMPONENTS[extend] ||
85
- COMPONENTS['smbls.' + extend]
86
- )
97
+ const componentExists =
98
+ COMPONENTS &&
99
+ (COMPONENTS[extend + '.' + variant] ||
100
+ COMPONENTS[extend] ||
101
+ COMPONENTS['smbls.' + extend])
87
102
  const pageExists = PAGES && extend.startsWith('/') && PAGES[extend]
88
103
  if (componentExists) return componentExists
89
104
  else if (pageExists) return pageExists
90
105
  else {
91
- if (options.verbose && (ENV === 'testing' || ENV === 'development')) {
106
+ if (options.verbose && isNotProduction()) {
92
107
  console.warn('Extend is string but component was not found:', extend)
93
108
  }
94
109
  return {}