pawajs 1.5.5 → 1.5.6

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/index.js CHANGED
@@ -286,40 +286,49 @@ export const RegisterComponent = (...args) => {
286
286
  }
287
287
  });
288
288
  }
289
+ /**
290
+ * Shared helper to trigger the dynamic import and hydration of a lazy component.
291
+ * @param {string} tagName
292
+ */
293
+ export const triggerLazyLoad = (tagName) => {
294
+ const lazyData = lazyComponents.get(tagName);
295
+ if (!lazyData) return;
296
+
297
+ lazyData.component().then(res => {
298
+ const compoFunc = res[lazyData.name];
299
+ if (!compoFunc) return;
300
+
301
+ components.set(tagName, compoFunc);
302
+ lazyComponents.delete(tagName);
303
+
304
+ const instances = lazyComponentElement.get(tagName) || [];
305
+ while (instances.length > 0) {
306
+ const { element: el, func } = instances.shift();
307
+ if (el) {
308
+ queueMicrotask(() => {
309
+ el.style.opacity = "";
310
+ if (el._component) {
311
+ el._component.component = compoFunc;
312
+ el._component.validPropRule = compoFunc?.validateProps || {}
313
+ }
314
+
315
+ keepContext(el._stateContext);
316
+ el._stateContext._hasRun = false;
317
+ func();
318
+ el._stateContext._hasRun = true;
319
+ });
320
+ }
321
+ }
322
+ lazyComponentElement.delete(tagName);
323
+ }).catch(err => console.error(`Lazy load failed for ${tagName}:`, err));
324
+ };
325
+
289
326
  export const createIntersectionObserver = (element, observeBy) => {
290
327
  const observer = new IntersectionObserver(entries => {
291
328
  entries.forEach(entry => {
292
329
  if (entry.isIntersecting) {
293
- const tagName = splitAndAdd(element.tagName);
294
- const lazyData = lazyComponents.get(tagName);
295
-
296
- if (!lazyData) return;
297
-
298
- lazyData.component().then(res => {
299
- const compoFunc = res[lazyData.name];
300
- if (!compoFunc) return;
301
-
302
- components.set(tagName, compoFunc);
303
- lazyComponents.delete(tagName);
304
-
305
- const instances = lazyComponentElement.get(tagName) || [];
306
- while (instances.length > 0) {
307
- const { element: el, func } = instances.shift();
308
- if (el) {
309
- if (el._component){
310
- el._component.component = compoFunc;
311
- el._component.validPropRule=compoFunc?.validateProps || {}
312
- }
313
-
314
- keepContext(el._stateContext);
315
- el._stateContext._hasRun = false;
316
- func();
317
- el._stateContext._hasRun = true;
318
- }
319
- }
320
- lazyComponentElement.delete(tagName)
321
- observer.disconnect();
322
- }).catch(err => console.error(`Lazy load failed for ${tagName}:`, err));
330
+ triggerLazyLoad(splitAndAdd(element.tagName));
331
+ observer.disconnect();
323
332
  }
324
333
  });
325
334
  }, { rootMargin: '100px' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
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",
package/pawaElement.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {components,lazyComponents ,escapePawaAttribute,getPawaAttributes,getDependentAttribute,getPrimaryDirectives, pluginsMap } from './index.js';
2
2
  import {splitAndAdd,replaceTemplateOperators,setPawaDevError,getEvalValues, checkKeywordsExistence} from './utils.js';
3
3
  import PawaComponent from './pawaComponent.js';
4
- import { createIntersectionObserver } from './index.js';
4
+ import { triggerLazyLoad } from './index.js';
5
5
  import { addLazyComponentElement } from './index.js';
6
6
  import { lazyComponentElement } from './index.js';
7
7
 
@@ -55,7 +55,7 @@ export class PawaElement {
55
55
  if(components.has(splitAndAdd(this._el.tagName))) return
56
56
  this._lazy=true
57
57
  if (!lazyComponentElement.has(splitAndAdd(this._el.tagName))) {
58
- createIntersectionObserver(this._el)
58
+ triggerLazyLoad(splitAndAdd(this._el.tagName))
59
59
  }
60
60
  }
61
61
  }
package/reactive.js CHANGED
@@ -30,8 +30,8 @@ function scheduleRenderWithTimeBudget() {
30
30
 
31
31
  rafScheduled = true;
32
32
  scheduleInProgress=true
33
- requestAnimationFrame(() => {
34
- const start = performance.now();
33
+ requestAnimationFrame((timestamp) => {
34
+ const start = timestamp;
35
35
  const processed = [];
36
36
 
37
37
  for (const fn of scheduled) {