@inditextech/weave-react 0.14.2 → 0.15.0
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/react.cjs +16 -19
- package/dist/react.d.cts +0 -16
- package/dist/react.d.ts +0 -16
- package/dist/react.js +16 -19
- package/package.json +2 -2
package/dist/react.cjs
CHANGED
|
@@ -214,7 +214,7 @@ const useWeave = create()((set) => ({
|
|
|
214
214
|
|
|
215
215
|
//#endregion
|
|
216
216
|
//#region src/components/provider.tsx
|
|
217
|
-
const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [], plugins = [], customPlugins = [], fonts = [],
|
|
217
|
+
const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [], plugins = [], customPlugins = [], fonts = [], children }) => {
|
|
218
218
|
const weaveInstanceRef = react.default.useRef(null);
|
|
219
219
|
const selectedNodes = useWeave((state) => state.selection.nodes);
|
|
220
220
|
const setInstance = useWeave((state) => state.setInstance);
|
|
@@ -224,19 +224,16 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
224
224
|
const setCanUndo = useWeave((state) => state.setCanUndo);
|
|
225
225
|
const setCanRedo = useWeave((state) => state.setCanRedo);
|
|
226
226
|
const setActualAction = useWeave((state) => state.setActualAction);
|
|
227
|
-
const { onInstanceStatus, onRoomLoaded, onStateChange, onUndoManagerStatusChange, onActiveActionChange,...restCallbacks } = callbacks;
|
|
228
227
|
const onInstanceStatusHandler = react.default.useCallback(
|
|
229
|
-
(status
|
|
230
|
-
setStatus(status
|
|
231
|
-
onInstanceStatus?.(status$1);
|
|
228
|
+
(status) => {
|
|
229
|
+
setStatus(status);
|
|
232
230
|
},
|
|
233
231
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
234
232
|
[]
|
|
235
233
|
);
|
|
236
234
|
const onRoomLoadedHandler = react.default.useCallback(
|
|
237
|
-
(status
|
|
238
|
-
setRoomLoaded(status
|
|
239
|
-
onRoomLoaded?.(status$1);
|
|
235
|
+
(status) => {
|
|
236
|
+
setRoomLoaded(status);
|
|
240
237
|
},
|
|
241
238
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
242
239
|
[]
|
|
@@ -244,7 +241,6 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
244
241
|
const onStateChangeHandler = react.default.useCallback(
|
|
245
242
|
(state) => {
|
|
246
243
|
setAppState(state);
|
|
247
|
-
onStateChange?.(state);
|
|
248
244
|
},
|
|
249
245
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
250
246
|
[selectedNodes]
|
|
@@ -254,7 +250,6 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
254
250
|
const { canUndo, canRedo } = undoManagerStatus;
|
|
255
251
|
setCanUndo(canUndo);
|
|
256
252
|
setCanRedo(canRedo);
|
|
257
|
-
onUndoManagerStatusChange?.(undoManagerStatus);
|
|
258
253
|
},
|
|
259
254
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
260
255
|
[]
|
|
@@ -262,7 +257,6 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
262
257
|
const onActiveActionChangeHandler = react.default.useCallback(
|
|
263
258
|
(actionName) => {
|
|
264
259
|
setActualAction(actionName);
|
|
265
|
-
onActiveActionChange?.(status);
|
|
266
260
|
},
|
|
267
261
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
268
262
|
[selectedNodes]
|
|
@@ -300,25 +294,28 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
300
294
|
actions,
|
|
301
295
|
plugins: [...instancePlugins, ...customPlugins],
|
|
302
296
|
fonts,
|
|
303
|
-
callbacks: {
|
|
304
|
-
...restCallbacks,
|
|
305
|
-
onInstanceStatus: onInstanceStatusHandler,
|
|
306
|
-
onRoomLoaded: onRoomLoadedHandler,
|
|
307
|
-
onStateChange: onStateChangeHandler,
|
|
308
|
-
onUndoManagerStatusChange: onUndoManagerStatusChangeHandler,
|
|
309
|
-
onActiveActionChange: onActiveActionChangeHandler
|
|
310
|
-
},
|
|
311
297
|
logger: { level: "info" }
|
|
312
298
|
}, {
|
|
313
299
|
container: containerId,
|
|
314
300
|
width: weaveEleClientRect?.width ?? 1920,
|
|
315
301
|
height: weaveEleClientRect?.height ?? 1080
|
|
316
302
|
});
|
|
303
|
+
weaveInstanceRef.current.addEventListener("onInstanceStatus", onInstanceStatusHandler);
|
|
304
|
+
weaveInstanceRef.current.addEventListener("onRoomLoaded", onRoomLoadedHandler);
|
|
305
|
+
weaveInstanceRef.current.addEventListener("onStateChange", onStateChangeHandler);
|
|
306
|
+
weaveInstanceRef.current.addEventListener("onUndoManagerStatusChange", onUndoManagerStatusChangeHandler);
|
|
307
|
+
weaveInstanceRef.current.addEventListener("onActiveActionChange", onActiveActionChangeHandler);
|
|
317
308
|
setInstance(weaveInstanceRef.current);
|
|
318
309
|
weaveInstanceRef.current.start();
|
|
319
310
|
}
|
|
320
311
|
}
|
|
312
|
+
setStatus(WEAVE_INSTANCE_STATUS.IDLE);
|
|
313
|
+
setRoomLoaded(false);
|
|
321
314
|
initWeave();
|
|
315
|
+
return () => {
|
|
316
|
+
weaveInstanceRef.current?.destroy();
|
|
317
|
+
weaveInstanceRef.current = null;
|
|
318
|
+
};
|
|
322
319
|
}, []);
|
|
323
320
|
return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, children);
|
|
324
321
|
};
|
package/dist/react.d.cts
CHANGED
|
@@ -48,20 +48,6 @@ type WeaveUser = {
|
|
|
48
48
|
type WeaveFont = {
|
|
49
49
|
id: string;
|
|
50
50
|
name: string;
|
|
51
|
-
};
|
|
52
|
-
type WeaveUndoRedoChange = {
|
|
53
|
-
canRedo: boolean;
|
|
54
|
-
canUndo: boolean;
|
|
55
|
-
redoStackLength: number;
|
|
56
|
-
undoStackLength: number;
|
|
57
|
-
};
|
|
58
|
-
type WeaveCallbacks = {
|
|
59
|
-
onRender?: () => void;
|
|
60
|
-
onRoomLoaded?: (loaded: boolean) => void;
|
|
61
|
-
onInstanceStatus?: (status: WeaveStatus) => void;
|
|
62
|
-
onActiveActionChange?: (actionName: string | undefined) => void;
|
|
63
|
-
onStateChange?: (state: WeaveState) => void;
|
|
64
|
-
onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
|
|
65
51
|
}; //#endregion
|
|
66
52
|
//#region src/components/provider.d.ts
|
|
67
53
|
type WeaveProviderType = {
|
|
@@ -75,7 +61,6 @@ type WeaveProviderType = {
|
|
|
75
61
|
customNodes?: WeaveNode[];
|
|
76
62
|
customActions?: WeaveAction[];
|
|
77
63
|
customPlugins?: WeavePlugin[];
|
|
78
|
-
callbacks?: WeaveCallbacks;
|
|
79
64
|
children: React.ReactNode;
|
|
80
65
|
};
|
|
81
66
|
declare const WeaveProvider: ({
|
|
@@ -87,7 +72,6 @@ declare const WeaveProvider: ({
|
|
|
87
72
|
plugins,
|
|
88
73
|
customPlugins,
|
|
89
74
|
fonts,
|
|
90
|
-
callbacks,
|
|
91
75
|
children
|
|
92
76
|
}: Readonly<WeaveProviderType>) => React.JSX.Element;
|
|
93
77
|
|
package/dist/react.d.ts
CHANGED
|
@@ -48,20 +48,6 @@ type WeaveUser = {
|
|
|
48
48
|
type WeaveFont = {
|
|
49
49
|
id: string;
|
|
50
50
|
name: string;
|
|
51
|
-
};
|
|
52
|
-
type WeaveUndoRedoChange = {
|
|
53
|
-
canRedo: boolean;
|
|
54
|
-
canUndo: boolean;
|
|
55
|
-
redoStackLength: number;
|
|
56
|
-
undoStackLength: number;
|
|
57
|
-
};
|
|
58
|
-
type WeaveCallbacks = {
|
|
59
|
-
onRender?: () => void;
|
|
60
|
-
onRoomLoaded?: (loaded: boolean) => void;
|
|
61
|
-
onInstanceStatus?: (status: WeaveStatus) => void;
|
|
62
|
-
onActiveActionChange?: (actionName: string | undefined) => void;
|
|
63
|
-
onStateChange?: (state: WeaveState) => void;
|
|
64
|
-
onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
|
|
65
51
|
}; //#endregion
|
|
66
52
|
//#region src/components/provider.d.ts
|
|
67
53
|
type WeaveProviderType = {
|
|
@@ -75,7 +61,6 @@ type WeaveProviderType = {
|
|
|
75
61
|
customNodes?: WeaveNode[];
|
|
76
62
|
customActions?: WeaveAction[];
|
|
77
63
|
customPlugins?: WeavePlugin[];
|
|
78
|
-
callbacks?: WeaveCallbacks;
|
|
79
64
|
children: React.ReactNode;
|
|
80
65
|
};
|
|
81
66
|
declare const WeaveProvider: ({
|
|
@@ -87,7 +72,6 @@ declare const WeaveProvider: ({
|
|
|
87
72
|
plugins,
|
|
88
73
|
customPlugins,
|
|
89
74
|
fonts,
|
|
90
|
-
callbacks,
|
|
91
75
|
children
|
|
92
76
|
}: Readonly<WeaveProviderType>) => React.JSX.Element;
|
|
93
77
|
|
package/dist/react.js
CHANGED
|
@@ -190,7 +190,7 @@ const useWeave = create()((set) => ({
|
|
|
190
190
|
|
|
191
191
|
//#endregion
|
|
192
192
|
//#region src/components/provider.tsx
|
|
193
|
-
const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [], plugins = [], customPlugins = [], fonts = [],
|
|
193
|
+
const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [], plugins = [], customPlugins = [], fonts = [], children }) => {
|
|
194
194
|
const weaveInstanceRef = React.useRef(null);
|
|
195
195
|
const selectedNodes = useWeave((state) => state.selection.nodes);
|
|
196
196
|
const setInstance = useWeave((state) => state.setInstance);
|
|
@@ -200,19 +200,16 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
200
200
|
const setCanUndo = useWeave((state) => state.setCanUndo);
|
|
201
201
|
const setCanRedo = useWeave((state) => state.setCanRedo);
|
|
202
202
|
const setActualAction = useWeave((state) => state.setActualAction);
|
|
203
|
-
const { onInstanceStatus, onRoomLoaded, onStateChange, onUndoManagerStatusChange, onActiveActionChange,...restCallbacks } = callbacks;
|
|
204
203
|
const onInstanceStatusHandler = React.useCallback(
|
|
205
|
-
(status
|
|
206
|
-
setStatus(status
|
|
207
|
-
onInstanceStatus?.(status$1);
|
|
204
|
+
(status) => {
|
|
205
|
+
setStatus(status);
|
|
208
206
|
},
|
|
209
207
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
210
208
|
[]
|
|
211
209
|
);
|
|
212
210
|
const onRoomLoadedHandler = React.useCallback(
|
|
213
|
-
(status
|
|
214
|
-
setRoomLoaded(status
|
|
215
|
-
onRoomLoaded?.(status$1);
|
|
211
|
+
(status) => {
|
|
212
|
+
setRoomLoaded(status);
|
|
216
213
|
},
|
|
217
214
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
218
215
|
[]
|
|
@@ -220,7 +217,6 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
220
217
|
const onStateChangeHandler = React.useCallback(
|
|
221
218
|
(state) => {
|
|
222
219
|
setAppState(state);
|
|
223
|
-
onStateChange?.(state);
|
|
224
220
|
},
|
|
225
221
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
226
222
|
[selectedNodes]
|
|
@@ -230,7 +226,6 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
230
226
|
const { canUndo, canRedo } = undoManagerStatus;
|
|
231
227
|
setCanUndo(canUndo);
|
|
232
228
|
setCanRedo(canRedo);
|
|
233
|
-
onUndoManagerStatusChange?.(undoManagerStatus);
|
|
234
229
|
},
|
|
235
230
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
236
231
|
[]
|
|
@@ -238,7 +233,6 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
238
233
|
const onActiveActionChangeHandler = React.useCallback(
|
|
239
234
|
(actionName) => {
|
|
240
235
|
setActualAction(actionName);
|
|
241
|
-
onActiveActionChange?.(status);
|
|
242
236
|
},
|
|
243
237
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
244
238
|
[selectedNodes]
|
|
@@ -276,25 +270,28 @@ const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [],
|
|
|
276
270
|
actions,
|
|
277
271
|
plugins: [...instancePlugins, ...customPlugins],
|
|
278
272
|
fonts,
|
|
279
|
-
callbacks: {
|
|
280
|
-
...restCallbacks,
|
|
281
|
-
onInstanceStatus: onInstanceStatusHandler,
|
|
282
|
-
onRoomLoaded: onRoomLoadedHandler,
|
|
283
|
-
onStateChange: onStateChangeHandler,
|
|
284
|
-
onUndoManagerStatusChange: onUndoManagerStatusChangeHandler,
|
|
285
|
-
onActiveActionChange: onActiveActionChangeHandler
|
|
286
|
-
},
|
|
287
273
|
logger: { level: "info" }
|
|
288
274
|
}, {
|
|
289
275
|
container: containerId,
|
|
290
276
|
width: weaveEleClientRect?.width ?? 1920,
|
|
291
277
|
height: weaveEleClientRect?.height ?? 1080
|
|
292
278
|
});
|
|
279
|
+
weaveInstanceRef.current.addEventListener("onInstanceStatus", onInstanceStatusHandler);
|
|
280
|
+
weaveInstanceRef.current.addEventListener("onRoomLoaded", onRoomLoadedHandler);
|
|
281
|
+
weaveInstanceRef.current.addEventListener("onStateChange", onStateChangeHandler);
|
|
282
|
+
weaveInstanceRef.current.addEventListener("onUndoManagerStatusChange", onUndoManagerStatusChangeHandler);
|
|
283
|
+
weaveInstanceRef.current.addEventListener("onActiveActionChange", onActiveActionChangeHandler);
|
|
293
284
|
setInstance(weaveInstanceRef.current);
|
|
294
285
|
weaveInstanceRef.current.start();
|
|
295
286
|
}
|
|
296
287
|
}
|
|
288
|
+
setStatus(WEAVE_INSTANCE_STATUS.IDLE);
|
|
289
|
+
setRoomLoaded(false);
|
|
297
290
|
initWeave();
|
|
291
|
+
return () => {
|
|
292
|
+
weaveInstanceRef.current?.destroy();
|
|
293
|
+
weaveInstanceRef.current = null;
|
|
294
|
+
};
|
|
298
295
|
}, []);
|
|
299
296
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
300
297
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/weave-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"yjs": "13.6.26"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@inditextech/weave-sdk": "0.
|
|
51
|
+
"@inditextech/weave-sdk": "0.15.0",
|
|
52
52
|
"@types/node": "^22.15.3",
|
|
53
53
|
"@typescript-eslint/eslint-plugin": "8.26.0",
|
|
54
54
|
"@typescript-eslint/parser": "8.26.0",
|