@knotx/react 0.2.12 → 0.2.13
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 +7 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -116,8 +116,10 @@ const Knotx = react.memo(react.forwardRef(({
|
|
|
116
116
|
edges,
|
|
117
117
|
plugins: _plugins,
|
|
118
118
|
pluginConfig,
|
|
119
|
-
disablePresetPlugins = false
|
|
119
|
+
disablePresetPlugins = false,
|
|
120
|
+
onInit
|
|
120
121
|
}, ref) => {
|
|
122
|
+
const initRef = react.useRef(false);
|
|
121
123
|
const engineRef = useEngineRef();
|
|
122
124
|
const plugins = useMergedPlugins(_plugins, disablePresetPlugins);
|
|
123
125
|
const setContainer = useContainerRef((containerSize) => {
|
|
@@ -130,6 +132,10 @@ const Knotx = react.memo(react.forwardRef(({
|
|
|
130
132
|
react.useImperativeHandle(ref, () => ({ engineRef }));
|
|
131
133
|
usePluginConfigUpdate(engineRef, pluginConfig);
|
|
132
134
|
const content = useLayerContent(engineRef);
|
|
135
|
+
if (!initRef.current && engineRef.current && content) {
|
|
136
|
+
initRef.current = true;
|
|
137
|
+
onInit == null ? void 0 : onInit(engineRef.current);
|
|
138
|
+
}
|
|
133
139
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
134
140
|
"div",
|
|
135
141
|
{
|
package/dist/index.d.cts
CHANGED
|
@@ -20,6 +20,7 @@ type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
disablePresetPlugins?: boolean;
|
|
23
|
+
onInit?: (engine: ReactEngine) => void;
|
|
23
24
|
} & ((TPlugins[number] extends Plugin<infer T> ? {
|
|
24
25
|
[TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
|
|
25
26
|
} : {}) extends infer PluginConfig ? {} extends PluginConfig ? {
|
package/dist/index.d.mts
CHANGED
|
@@ -20,6 +20,7 @@ type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
disablePresetPlugins?: boolean;
|
|
23
|
+
onInit?: (engine: ReactEngine) => void;
|
|
23
24
|
} & ((TPlugins[number] extends Plugin<infer T> ? {
|
|
24
25
|
[TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
|
|
25
26
|
} : {}) extends infer PluginConfig ? {} extends PluginConfig ? {
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ type KnotxProps<TPlugins extends Plugin[] = Plugin[]> = {
|
|
|
20
20
|
* @default false
|
|
21
21
|
*/
|
|
22
22
|
disablePresetPlugins?: boolean;
|
|
23
|
+
onInit?: (engine: ReactEngine) => void;
|
|
23
24
|
} & ((TPlugins[number] extends Plugin<infer T> ? {
|
|
24
25
|
[TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
|
|
25
26
|
} : {}) extends infer PluginConfig ? {} extends PluginConfig ? {
|
package/dist/index.js
CHANGED
|
@@ -114,8 +114,10 @@ const Knotx = memo(forwardRef(({
|
|
|
114
114
|
edges,
|
|
115
115
|
plugins: _plugins,
|
|
116
116
|
pluginConfig,
|
|
117
|
-
disablePresetPlugins = false
|
|
117
|
+
disablePresetPlugins = false,
|
|
118
|
+
onInit
|
|
118
119
|
}, ref) => {
|
|
120
|
+
const initRef = useRef(false);
|
|
119
121
|
const engineRef = useEngineRef();
|
|
120
122
|
const plugins = useMergedPlugins(_plugins, disablePresetPlugins);
|
|
121
123
|
const setContainer = useContainerRef((containerSize) => {
|
|
@@ -128,6 +130,10 @@ const Knotx = memo(forwardRef(({
|
|
|
128
130
|
useImperativeHandle(ref, () => ({ engineRef }));
|
|
129
131
|
usePluginConfigUpdate(engineRef, pluginConfig);
|
|
130
132
|
const content = useLayerContent(engineRef);
|
|
133
|
+
if (!initRef.current && engineRef.current && content) {
|
|
134
|
+
initRef.current = true;
|
|
135
|
+
onInit == null ? void 0 : onInit(engineRef.current);
|
|
136
|
+
}
|
|
131
137
|
return /* @__PURE__ */ jsx(
|
|
132
138
|
"div",
|
|
133
139
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knotx/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
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.2.
|
|
37
|
-
"@knotx/jsx": "0.2.
|
|
38
|
-
"@knotx/plugins-base-render": "0.2.
|
|
36
|
+
"@knotx/core": "0.2.10",
|
|
37
|
+
"@knotx/jsx": "0.2.10",
|
|
38
|
+
"@knotx/plugins-base-render": "0.2.12"
|
|
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.2.
|
|
46
|
-
"@knotx/eslint-config": "0.2.
|
|
47
|
-
"@knotx/jsx": "0.2.
|
|
48
|
-
"@knotx/typescript-config": "0.2.
|
|
45
|
+
"@knotx/build-config": "0.2.10",
|
|
46
|
+
"@knotx/eslint-config": "0.2.10",
|
|
47
|
+
"@knotx/jsx": "0.2.10",
|
|
48
|
+
"@knotx/typescript-config": "0.2.10"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "unbuild",
|