pawajs 1.4.39 → 1.4.41

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 (2) hide show
  1. package/index.js +24 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -324,31 +324,37 @@ export const createIntersectionObserver = (element, observeBy) => {
324
324
  observer.observe(observeBy || element);
325
325
  return observer;
326
326
  }
327
- RegisterComponent.lazy=async(...args)=>{
328
- if (typeof args[0] === 'string') {
327
+ RegisterComponent.lazy=(...args)=>{
329
328
  for (let i = 0; i < args.length; i += 2) {
330
329
  const name = args[i];
331
- const component = args[i + 1];
332
- if (components.has(name.toUpperCase())) return
333
- if (typeof name === 'string' && typeof component === 'function') {
334
- if (isServer()) {
335
- lazyComponents.set(name.toUpperCase(), {name,component});
336
- const compo=await component()
337
- if (compo[name]) {
338
- components.set(name.toUpperCase(),compo[name])
339
- }else{
340
- console.log(`component name doesn't matched the export ${name}`);
341
- }
342
- }else{
343
- lazyComponents.set(name.toUpperCase(), {name,component});
330
+ const componentFunc = args[i + 1];
331
+
332
+ if (typeof componentFunc !== 'function') {
333
+ console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string|string[], function).');
334
+ break;
335
+ }
336
+
337
+ const processName =(compName) => {
338
+ if (components.has(compName.toUpperCase()) || lazyComponents.has(compName.toUpperCase()) && !__pawaDev.tool) return;
339
+
340
+ if (typeof compName === 'string') {
341
+ lazyComponents.set(compName.toUpperCase(), { name: compName, component: componentFunc });
342
+ }
343
+ };
344
+
345
+ if (Array.isArray(name)) {
346
+ for (const compName of name) {
347
+ processName(compName);
344
348
  }
349
+ } else if (typeof name === 'string') {
350
+ processName(name);
345
351
  } else {
346
- console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string, function).');
352
+ console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string|string[], function).');
347
353
  break;
348
354
  }
349
355
  }
350
- return;
351
- }
356
+
357
+
352
358
  }
353
359
 
354
360
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "1.4.39",
3
+ "version": "1.4.41",
4
4
  "type":"module",
5
5
  "description": "pawajs library (reactive web runtime) for easily building web ui, enhancing html element, micro frontend etc ",
6
6
  "main": "index.js",