cx 24.6.4 → 24.7.2
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/manifest.js +706 -706
- package/dist/ui.js +11 -6
- package/package.json +1 -1
- package/src/charts/helpers/MinMaxFinder.d.ts +5 -5
- package/src/charts/helpers/SnapPointFinder.d.ts +2 -2
- package/src/ui/Cx.js +313 -313
- package/src/ui/VDOM.d.ts +9 -1
- package/src/ui/app/startAppLoop.js +37 -37
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { Widget, VDOM } from
|
|
2
|
-
import { Store } from
|
|
3
|
-
import { Cx } from
|
|
1
|
+
import { Widget, VDOM } from "../Widget";
|
|
2
|
+
import { Store } from "../../data/Store";
|
|
3
|
+
import { Cx } from "../Cx";
|
|
4
4
|
|
|
5
5
|
export function startAppLoop(parentDOMElement, storeOrInstance, widget, options = {}) {
|
|
6
|
-
|
|
7
6
|
if (!parentDOMElement || parentDOMElement.nodeType !== 1)
|
|
8
|
-
throw new Error(
|
|
7
|
+
throw new Error("First argument to startAppLoop should be a valid DOM element.");
|
|
9
8
|
|
|
10
9
|
let store, instance, parentInstance;
|
|
11
10
|
|
|
12
|
-
if (!storeOrInstance)
|
|
13
|
-
storeOrInstance = new Store();
|
|
11
|
+
if (!storeOrInstance) storeOrInstance = new Store();
|
|
14
12
|
|
|
15
|
-
if (storeOrInstance.notify)
|
|
16
|
-
store = storeOrInstance;
|
|
13
|
+
if (storeOrInstance.notify) store = storeOrInstance;
|
|
17
14
|
else if (storeOrInstance.getChild) {
|
|
18
|
-
if (storeOrInstance.widget === widget)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
15
|
+
if (storeOrInstance.widget === widget) instance = storeOrInstance;
|
|
16
|
+
else parentInstance = storeOrInstance;
|
|
17
|
+
} else throw new Error("Second argument to startAppLoop should be either of type Store or Instance");
|
|
18
|
+
|
|
19
|
+
let content = (
|
|
20
|
+
<Cx
|
|
21
|
+
store={store}
|
|
22
|
+
widget={widget}
|
|
23
|
+
instance={instance}
|
|
24
|
+
parentInstance={parentInstance}
|
|
25
|
+
options={options}
|
|
26
|
+
subscribe
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
let root = null;
|
|
31
|
+
if (VDOM.DOM.createRoot) {
|
|
32
|
+
root = VDOM.DOM.createRoot(parentDOMElement);
|
|
33
|
+
root.render(content);
|
|
34
|
+
} else VDOM.DOM.render(content, parentDOMElement);
|
|
35
|
+
|
|
36
36
|
let stopped = false;
|
|
37
37
|
|
|
38
38
|
return function () {
|
|
39
|
-
if (stopped)
|
|
40
|
-
return;
|
|
39
|
+
if (stopped) return;
|
|
41
40
|
|
|
42
41
|
stopped = true;
|
|
43
42
|
|
|
44
|
-
if (!options.destroyDelay)
|
|
45
|
-
destroy(parentDOMElement, options);
|
|
43
|
+
if (!options.destroyDelay) destroy(parentDOMElement, options, root);
|
|
46
44
|
else {
|
|
47
45
|
setTimeout(() => {
|
|
48
|
-
destroy(parentDOMElement, options);
|
|
49
|
-
}, options.destroyDelay)
|
|
46
|
+
destroy(parentDOMElement, options, root);
|
|
47
|
+
}, options.destroyDelay);
|
|
50
48
|
}
|
|
51
|
-
}
|
|
49
|
+
};
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
function destroy(parentDOMElement, options) {
|
|
55
|
-
|
|
52
|
+
function destroy(parentDOMElement, options, root) {
|
|
53
|
+
if (root) root.unmount();
|
|
54
|
+
else VDOM.DOM.unmountComponentAtNode(parentDOMElement);
|
|
55
|
+
|
|
56
56
|
if (options.removeParentDOMElement && parentDOMElement.parentNode)
|
|
57
57
|
parentDOMElement.parentNode.removeChild(parentDOMElement);
|
|
58
|
-
}
|
|
58
|
+
}
|