@knotx/react 0.4.7 → 0.4.9
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.cjs +12 -8
- package/dist/index.js +12 -8
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -116,7 +116,10 @@ function useContainerRef(onResize) {
|
|
|
116
116
|
function useDataUpdate(engineRef, { nodes, edges, initRef }) {
|
|
117
117
|
react.useEffect(() => {
|
|
118
118
|
const engine = engineRef.current;
|
|
119
|
-
if (
|
|
119
|
+
if (
|
|
120
|
+
// 未初始化完成
|
|
121
|
+
!initRef.current || !(engine == null ? void 0 : engine.nodesManager.version)
|
|
122
|
+
) {
|
|
120
123
|
return;
|
|
121
124
|
}
|
|
122
125
|
const previousNodes = engine.nodesManager.dataMap$.value;
|
|
@@ -126,7 +129,10 @@ function useDataUpdate(engineRef, { nodes, edges, initRef }) {
|
|
|
126
129
|
}, [nodes, nodes == null ? void 0 : nodes.length]);
|
|
127
130
|
react.useEffect(() => {
|
|
128
131
|
const engine = engineRef.current;
|
|
129
|
-
if (
|
|
132
|
+
if (
|
|
133
|
+
// 未初始化完成
|
|
134
|
+
!initRef.current || !(engine == null ? void 0 : engine.edgesManager.version)
|
|
135
|
+
) {
|
|
130
136
|
return;
|
|
131
137
|
}
|
|
132
138
|
const previousEdges = engine.edgesManager.dataMap$.value;
|
|
@@ -221,17 +227,15 @@ const Knotx = react.memo(react.forwardRef(({
|
|
|
221
227
|
return;
|
|
222
228
|
}
|
|
223
229
|
engineRef.current.container = containerSize;
|
|
224
|
-
initRef.current
|
|
230
|
+
if (!initRef.current) {
|
|
231
|
+
initRef.current = true;
|
|
232
|
+
onInit == null ? void 0 : onInit(engineRef.current);
|
|
233
|
+
}
|
|
225
234
|
rerender();
|
|
226
235
|
});
|
|
227
236
|
react.useImperativeHandle(ref, () => ({ engineRef, rerender }));
|
|
228
237
|
useDataUpdate(engineRef, { nodes, edges, initRef });
|
|
229
238
|
usePluginConfigUpdate(engineRef, { pluginConfig, initRef });
|
|
230
|
-
react.useEffect(() => {
|
|
231
|
-
if (initRef.current) {
|
|
232
|
-
onInit == null ? void 0 : onInit(engineRef.current);
|
|
233
|
-
}
|
|
234
|
-
}, [initRef.current]);
|
|
235
239
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
236
240
|
"div",
|
|
237
241
|
{
|
package/dist/index.js
CHANGED
|
@@ -114,7 +114,10 @@ function useContainerRef(onResize) {
|
|
|
114
114
|
function useDataUpdate(engineRef, { nodes, edges, initRef }) {
|
|
115
115
|
useEffect(() => {
|
|
116
116
|
const engine = engineRef.current;
|
|
117
|
-
if (
|
|
117
|
+
if (
|
|
118
|
+
// 未初始化完成
|
|
119
|
+
!initRef.current || !(engine == null ? void 0 : engine.nodesManager.version)
|
|
120
|
+
) {
|
|
118
121
|
return;
|
|
119
122
|
}
|
|
120
123
|
const previousNodes = engine.nodesManager.dataMap$.value;
|
|
@@ -124,7 +127,10 @@ function useDataUpdate(engineRef, { nodes, edges, initRef }) {
|
|
|
124
127
|
}, [nodes, nodes == null ? void 0 : nodes.length]);
|
|
125
128
|
useEffect(() => {
|
|
126
129
|
const engine = engineRef.current;
|
|
127
|
-
if (
|
|
130
|
+
if (
|
|
131
|
+
// 未初始化完成
|
|
132
|
+
!initRef.current || !(engine == null ? void 0 : engine.edgesManager.version)
|
|
133
|
+
) {
|
|
128
134
|
return;
|
|
129
135
|
}
|
|
130
136
|
const previousEdges = engine.edgesManager.dataMap$.value;
|
|
@@ -219,17 +225,15 @@ const Knotx = memo(forwardRef(({
|
|
|
219
225
|
return;
|
|
220
226
|
}
|
|
221
227
|
engineRef.current.container = containerSize;
|
|
222
|
-
initRef.current
|
|
228
|
+
if (!initRef.current) {
|
|
229
|
+
initRef.current = true;
|
|
230
|
+
onInit == null ? void 0 : onInit(engineRef.current);
|
|
231
|
+
}
|
|
223
232
|
rerender();
|
|
224
233
|
});
|
|
225
234
|
useImperativeHandle(ref, () => ({ engineRef, rerender }));
|
|
226
235
|
useDataUpdate(engineRef, { nodes, edges, initRef });
|
|
227
236
|
usePluginConfigUpdate(engineRef, { pluginConfig, initRef });
|
|
228
|
-
useEffect(() => {
|
|
229
|
-
if (initRef.current) {
|
|
230
|
-
onInit == null ? void 0 : onInit(engineRef.current);
|
|
231
|
-
}
|
|
232
|
-
}, [initRef.current]);
|
|
233
237
|
return /* @__PURE__ */ jsx(
|
|
234
238
|
"div",
|
|
235
239
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/react",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "React for Knotx",
|
|
5
5
|
"author": "boenfu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"rxjs": "^7.8.1",
|
|
36
|
-
"@knotx/core": "0.4.
|
|
37
|
-
"@knotx/jsx": "0.4.
|
|
38
|
-
"@knotx/plugins-base-render": "0.4.
|
|
36
|
+
"@knotx/core": "0.4.9",
|
|
37
|
+
"@knotx/jsx": "0.4.9",
|
|
38
|
+
"@knotx/plugins-base-render": "0.4.9"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/react": "^17.0.0",
|
|
42
42
|
"@types/react-dom": "^17.0.0",
|
|
43
43
|
"react": "^17.0.0",
|
|
44
44
|
"react-dom": "^17.0.0",
|
|
45
|
-
"@knotx/build-config": "0.4.
|
|
46
|
-
"@knotx/eslint-config": "0.4.
|
|
47
|
-
"@knotx/jsx": "0.4.
|
|
48
|
-
"@knotx/typescript-config": "0.4.
|
|
45
|
+
"@knotx/build-config": "0.4.9",
|
|
46
|
+
"@knotx/eslint-config": "0.4.9",
|
|
47
|
+
"@knotx/jsx": "0.4.9",
|
|
48
|
+
"@knotx/typescript-config": "0.4.9"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "unbuild",
|