cradova 3.11.8 → 3.11.10
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/dist/index.js +16 -15
- package/dist/primitives/functions.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -186,7 +186,7 @@ function useState(initialValue) {
|
|
|
186
186
|
}
|
|
187
187
|
if (!Object.is(currentState, nextState)) {
|
|
188
188
|
self._state[idx] = nextState;
|
|
189
|
-
funcManager.recall(self
|
|
189
|
+
funcManager.recall(self);
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
192
|
return [self._state[idx], setState];
|
|
@@ -268,7 +268,7 @@ function useReducer(reducer, initialArg, initializer) {
|
|
|
268
268
|
}
|
|
269
269
|
if (!Object.is(currentState, nextState)) {
|
|
270
270
|
currentTracker.state = nextState;
|
|
271
|
-
funcManager.recall(self
|
|
271
|
+
funcManager.recall(self);
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
274
|
return [tracker[idx].state, dispatch];
|
|
@@ -308,7 +308,8 @@ var toComp = (comp, args) => {
|
|
|
308
308
|
comp._effect_tracker = [];
|
|
309
309
|
comp._memo_tracker = [];
|
|
310
310
|
comp._reducer_tracker = [];
|
|
311
|
-
|
|
311
|
+
comp._args = args;
|
|
312
|
+
return funcManager.render(comp);
|
|
312
313
|
};
|
|
313
314
|
var toCompNoRender = (comp) => {
|
|
314
315
|
if (typeof comp._state_index !== "number") {
|
|
@@ -324,8 +325,8 @@ var toCompNoRender = (comp) => {
|
|
|
324
325
|
return comp;
|
|
325
326
|
};
|
|
326
327
|
var funcManager = {
|
|
327
|
-
render(component
|
|
328
|
-
const html = component.apply(component,
|
|
328
|
+
render(component) {
|
|
329
|
+
const html = component.apply(component, component._args);
|
|
329
330
|
if (html instanceof HTMLElement) {
|
|
330
331
|
component.reference = html;
|
|
331
332
|
component.rendered = true;
|
|
@@ -338,16 +339,16 @@ var funcManager = {
|
|
|
338
339
|
return;
|
|
339
340
|
}
|
|
340
341
|
},
|
|
341
|
-
recall(component
|
|
342
|
+
recall(component) {
|
|
342
343
|
if (component.rendered && component.published) {
|
|
343
344
|
setTimeout(() => {
|
|
344
|
-
this.activate(component
|
|
345
|
+
this.activate(component);
|
|
345
346
|
}, 0);
|
|
346
347
|
}
|
|
347
348
|
window.CradovaEvent.dispatchEvent("after_page_is_killed");
|
|
348
349
|
window.CradovaEvent.dispatchEvent("after_comp_is_mounted");
|
|
349
350
|
},
|
|
350
|
-
activate(component
|
|
351
|
+
activate(component) {
|
|
351
352
|
component.published = false;
|
|
352
353
|
if (!component.rendered || !component.reference) {
|
|
353
354
|
return;
|
|
@@ -355,7 +356,7 @@ var funcManager = {
|
|
|
355
356
|
const node = component.reference;
|
|
356
357
|
if (document.body.contains(node)) {
|
|
357
358
|
resetComponent(component);
|
|
358
|
-
const newHtml = component.apply(component,
|
|
359
|
+
const newHtml = component.apply(component, component._args);
|
|
359
360
|
if (newHtml instanceof HTMLElement) {
|
|
360
361
|
node.replaceWith(newHtml);
|
|
361
362
|
node.insertAdjacentElement("beforebegin", newHtml);
|
|
@@ -641,11 +642,11 @@ class Signal {
|
|
|
641
642
|
const key = localStorage.getItem(props.persistName);
|
|
642
643
|
if (key && key !== "undefined") {
|
|
643
644
|
const restored = JSON.parse(key);
|
|
644
|
-
if (!Array.isArray(restored)) {
|
|
645
|
-
this.store = new Store(restored, (key2) => {
|
|
645
|
+
if (typeof restored === "object" && !Array.isArray(restored)) {
|
|
646
|
+
this.store = new Store(Object.assign(initial, restored), (key2) => {
|
|
646
647
|
this.publish(key2);
|
|
647
648
|
});
|
|
648
|
-
} else {
|
|
649
|
+
} else if (Array.isArray(restored)) {
|
|
649
650
|
this.isList = true;
|
|
650
651
|
this.store = new List2(restored, (eventType) => {
|
|
651
652
|
this.publish(eventType);
|
|
@@ -657,14 +658,14 @@ class Signal {
|
|
|
657
658
|
publish(eventName) {
|
|
658
659
|
this.subscribers[eventName]?.forEach((c) => {
|
|
659
660
|
if (c.published) {
|
|
660
|
-
funcManager.recall(c
|
|
661
|
+
funcManager.recall(c);
|
|
661
662
|
} else {
|
|
662
663
|
c();
|
|
663
664
|
}
|
|
664
665
|
});
|
|
665
666
|
this.subscribers["__ALL__"]?.forEach((c) => {
|
|
666
667
|
if (c.published) {
|
|
667
|
-
funcManager.recall(c
|
|
668
|
+
funcManager.recall(c);
|
|
668
669
|
} else {
|
|
669
670
|
c();
|
|
670
671
|
}
|
|
@@ -691,7 +692,7 @@ class Signal {
|
|
|
691
692
|
}
|
|
692
693
|
for (const c of s.values()) {
|
|
693
694
|
if (c.published) {
|
|
694
|
-
funcManager.recall(c
|
|
695
|
+
funcManager.recall(c);
|
|
695
696
|
} else {
|
|
696
697
|
c();
|
|
697
698
|
}
|
|
@@ -23,9 +23,9 @@ export declare const isArrowFunc: (fn: Function) => boolean;
|
|
|
23
23
|
export declare const toComp: (comp: Comp, args?: any[]) => HTMLElement | undefined;
|
|
24
24
|
export declare const toCompNoRender: (comp: Comp) => Comp;
|
|
25
25
|
export declare const funcManager: {
|
|
26
|
-
render(component: Comp
|
|
27
|
-
recall(component: Comp
|
|
28
|
-
activate(component: Comp
|
|
26
|
+
render(component: Comp): HTMLElement | undefined;
|
|
27
|
+
recall(component: Comp): void;
|
|
28
|
+
activate(component: Comp): void;
|
|
29
29
|
/**
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|