pawajs 1.4.39 → 1.4.40

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 +25 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -324,26 +324,36 @@ export const createIntersectionObserver = (element, observeBy) => {
324
324
  observer.observe(observeBy || element);
325
325
  return observer;
326
326
  }
327
- RegisterComponent.lazy=async(...args)=>{
327
+ RegisterComponent.lazy=(...args)=>{
328
328
  if (typeof args[0] === 'string') {
329
329
  for (let i = 0; i < args.length; i += 2) {
330
330
  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});
331
+ const componentFunc = args[i + 1];
332
+
333
+ if (typeof componentFunc !== 'function') {
334
+ console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string|string[], function).');
335
+ break;
336
+ }
337
+
338
+ const processName =(compName) => {
339
+ if (components.has(compName.toUpperCase())) return;
340
+ if (typeof compName === 'string') {
341
+ if (isServer()) {
342
+ componentFunc();
343
+ }
344
+ lazyComponents.set(compName.toUpperCase(), { name: compName, component: componentFunc });
345
+
344
346
  }
347
+ };
348
+
349
+ if (Array.isArray(name)) {
350
+ for (const compName of name) {
351
+ processName(compName);
352
+ }
353
+ } else if (typeof name === 'string') {
354
+ processName(name);
345
355
  } else {
346
- console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string, function).');
356
+ console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string|string[], function).');
347
357
  break;
348
358
  }
349
359
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "1.4.39",
3
+ "version": "1.4.40",
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",