@inditextech/weave-react 3.3.1 → 3.4.0-SNAPSHOT.85.1
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.d.ts +6 -2
- package/dist/react.js +63 -7
- package/package.json +3 -3
package/dist/react.d.ts
CHANGED
|
@@ -41,12 +41,14 @@ interface WeaveRuntimeState {
|
|
|
41
41
|
status: string;
|
|
42
42
|
};
|
|
43
43
|
room: {
|
|
44
|
+
id: string | null;
|
|
45
|
+
switching: boolean;
|
|
44
46
|
loaded: boolean;
|
|
45
47
|
};
|
|
46
48
|
asyncElements: {
|
|
49
|
+
state: "idle" | "loading" | "loaded";
|
|
47
50
|
loaded: number;
|
|
48
51
|
total: number;
|
|
49
|
-
allLoaded: boolean;
|
|
50
52
|
};
|
|
51
53
|
users: WeaveConnectedUsers;
|
|
52
54
|
undoRedo: {
|
|
@@ -72,9 +74,11 @@ interface WeaveRuntimeState {
|
|
|
72
74
|
setStatus: (newStatus: WeaveStatus) => void;
|
|
73
75
|
setAppState: (newAppState: WeaveState) => void;
|
|
74
76
|
setConnectionStatus: (newConnectionStatus: string) => void;
|
|
77
|
+
setRoomId: (newRoomId: string | null) => void;
|
|
78
|
+
setRoomSwitching: (newRoomSwitching: boolean) => void;
|
|
75
79
|
setRoomLoaded: (newStatus: boolean) => void;
|
|
76
80
|
setAsyncElements: (loaded: number, total: number) => void;
|
|
77
|
-
|
|
81
|
+
setAsyncElementsState: (newState: "idle" | "loading" | "loaded") => void;
|
|
78
82
|
setUsers: (newUsers: WeaveConnectedUsers) => void;
|
|
79
83
|
setCanUndo: (newCanUndo: boolean) => void;
|
|
80
84
|
setCanRedo: (newCanRedo: boolean) => void;
|
package/dist/react.js
CHANGED
|
@@ -53,11 +53,15 @@ const useWeave = create()((set) => ({
|
|
|
53
53
|
instance: null,
|
|
54
54
|
appState: { weave: {} },
|
|
55
55
|
status: WEAVE_INSTANCE_STATUS.IDLE,
|
|
56
|
-
room: {
|
|
56
|
+
room: {
|
|
57
|
+
id: null,
|
|
58
|
+
switching: false,
|
|
59
|
+
loaded: false
|
|
60
|
+
},
|
|
57
61
|
asyncElements: {
|
|
62
|
+
state: "idle",
|
|
58
63
|
loaded: 0,
|
|
59
|
-
total: 0
|
|
60
|
-
allLoaded: false
|
|
64
|
+
total: 0
|
|
61
65
|
},
|
|
62
66
|
connection: { status: "disconnected" },
|
|
63
67
|
users: {},
|
|
@@ -107,6 +111,20 @@ const useWeave = create()((set) => ({
|
|
|
107
111
|
status: newConnectionStatus
|
|
108
112
|
}
|
|
109
113
|
})),
|
|
114
|
+
setRoomId: (newRoomId) => set((state) => ({
|
|
115
|
+
...state,
|
|
116
|
+
room: {
|
|
117
|
+
...state.room,
|
|
118
|
+
id: newRoomId
|
|
119
|
+
}
|
|
120
|
+
})),
|
|
121
|
+
setRoomSwitching: (newRoomSwitching) => set((state) => ({
|
|
122
|
+
...state,
|
|
123
|
+
room: {
|
|
124
|
+
...state.room,
|
|
125
|
+
switching: newRoomSwitching
|
|
126
|
+
}
|
|
127
|
+
})),
|
|
110
128
|
setRoomLoaded: (newStatus) => set((state) => ({
|
|
111
129
|
...state,
|
|
112
130
|
room: {
|
|
@@ -122,11 +140,11 @@ const useWeave = create()((set) => ({
|
|
|
122
140
|
total
|
|
123
141
|
}
|
|
124
142
|
})),
|
|
125
|
-
|
|
143
|
+
setAsyncElementsState: (newState) => set((state) => ({
|
|
126
144
|
...state,
|
|
127
145
|
asyncElements: {
|
|
128
146
|
...state.asyncElements,
|
|
129
|
-
|
|
147
|
+
state: newState
|
|
130
148
|
}
|
|
131
149
|
})),
|
|
132
150
|
setUsers: (newUsers) => set((state) => ({
|
|
@@ -217,7 +235,7 @@ const WeaveProvider = ({ getContainer, store, renderer, nodes = [], actions = []
|
|
|
217
235
|
const setActualAction = useWeave((state) => state.setActualAction);
|
|
218
236
|
const setConnectionStatus = useWeave((state) => state.setConnectionStatus);
|
|
219
237
|
const setAsyncElements = useWeave((state) => state.setAsyncElements);
|
|
220
|
-
const
|
|
238
|
+
const setAsyncElementsState = useWeave((state) => state.setAsyncElementsState);
|
|
221
239
|
const onInstanceStatusHandler = React.useCallback(
|
|
222
240
|
(status) => {
|
|
223
241
|
setStatus(status);
|
|
@@ -261,9 +279,17 @@ const WeaveProvider = ({ getContainer, store, renderer, nodes = [], actions = []
|
|
|
261
279
|
},
|
|
262
280
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
263
281
|
[selectedNodes]
|
|
282
|
+
);
|
|
283
|
+
const onAsyncElementsIdleHandler = React.useCallback(
|
|
284
|
+
() => {
|
|
285
|
+
setAsyncElementsState("idle");
|
|
286
|
+
},
|
|
287
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
288
|
+
[selectedNodes]
|
|
264
289
|
);
|
|
265
290
|
const onAsyncElementsLoadingHandler = React.useCallback(
|
|
266
291
|
({ loaded, total }) => {
|
|
292
|
+
setAsyncElementsState("loading");
|
|
267
293
|
setAsyncElements(loaded, total);
|
|
268
294
|
},
|
|
269
295
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -271,7 +297,7 @@ const WeaveProvider = ({ getContainer, store, renderer, nodes = [], actions = []
|
|
|
271
297
|
);
|
|
272
298
|
const onAsyncElementsLoadedHandler = React.useCallback(
|
|
273
299
|
() => {
|
|
274
|
-
|
|
300
|
+
setAsyncElementsState("loaded");
|
|
275
301
|
},
|
|
276
302
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
277
303
|
[selectedNodes]
|
|
@@ -305,6 +331,7 @@ const WeaveProvider = ({ getContainer, store, renderer, nodes = [], actions = []
|
|
|
305
331
|
weaveInstanceRef.current.addEventListener("onStateChange", onStateChangeHandler);
|
|
306
332
|
weaveInstanceRef.current.addEventListener("onUndoManagerStatusChange", onUndoManagerStatusChangeHandler);
|
|
307
333
|
weaveInstanceRef.current.addEventListener("onActiveActionChange", onActiveActionChangeHandler);
|
|
334
|
+
weaveInstanceRef.current.addEventListener("onAsyncElementsIdle", onAsyncElementsIdleHandler);
|
|
308
335
|
weaveInstanceRef.current.addEventListener("onAsyncElementsLoading", onAsyncElementsLoadingHandler);
|
|
309
336
|
weaveInstanceRef.current.addEventListener("onAsyncElementsLoaded", onAsyncElementsLoadedHandler);
|
|
310
337
|
setInstance(weaveInstanceRef.current);
|
|
@@ -337,6 +364,8 @@ const WeaveProvider = ({ getContainer, store, renderer, nodes = [], actions = []
|
|
|
337
364
|
const useWeaveEvents = () => {
|
|
338
365
|
const instance = useWeave((state) => state.instance);
|
|
339
366
|
const node = useWeave((state) => state.selection.node);
|
|
367
|
+
const setRoomId = useWeave((state) => state.setRoomId);
|
|
368
|
+
const setRoomSwitching = useWeave((state) => state.setRoomSwitching);
|
|
340
369
|
const setZoom = useWeave((state) => state.setZoom);
|
|
341
370
|
const setCanZoomIn = useWeave((state) => state.setCanZoomIn);
|
|
342
371
|
const setCanZoomOut = useWeave((state) => state.setCanZoomOut);
|
|
@@ -345,6 +374,27 @@ const useWeaveEvents = () => {
|
|
|
345
374
|
const setNode = useWeave((state) => state.setNode);
|
|
346
375
|
const setUsers = useWeave((state) => state.setUsers);
|
|
347
376
|
const setUsersLocks = useWeave((state) => state.setUsersLocks);
|
|
377
|
+
const onStoreRoomChangedHandler = React.useCallback(
|
|
378
|
+
({ room }) => {
|
|
379
|
+
setRoomId(room);
|
|
380
|
+
},
|
|
381
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
382
|
+
[]
|
|
383
|
+
);
|
|
384
|
+
const onRoomSwitchingStartHandler = React.useCallback(
|
|
385
|
+
() => {
|
|
386
|
+
setRoomSwitching(true);
|
|
387
|
+
},
|
|
388
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
389
|
+
[]
|
|
390
|
+
);
|
|
391
|
+
const onRoomSwitchingEndHandler = React.useCallback(
|
|
392
|
+
() => {
|
|
393
|
+
setRoomSwitching(false);
|
|
394
|
+
},
|
|
395
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
396
|
+
[]
|
|
397
|
+
);
|
|
348
398
|
const onSelectionStateHandler = React.useCallback((active) => {
|
|
349
399
|
setSelectionActive(active);
|
|
350
400
|
}, []);
|
|
@@ -389,12 +439,18 @@ const useWeaveEvents = () => {
|
|
|
389
439
|
);
|
|
390
440
|
React.useEffect(() => {
|
|
391
441
|
if (!instance) return;
|
|
442
|
+
instance.addEventListener("onStoreRoomChanged", onStoreRoomChangedHandler);
|
|
443
|
+
instance.addEventListener("onRoomSwitchingStart", onRoomSwitchingStartHandler);
|
|
444
|
+
instance.addEventListener("onRoomSwitchingEnd", onRoomSwitchingEndHandler);
|
|
392
445
|
instance.addEventListener("onSelectionState", onSelectionStateHandler);
|
|
393
446
|
instance.addEventListener("onZoomChange", onZoomChangeHandler);
|
|
394
447
|
instance.addEventListener("onNodesChange", onNodesChangeHandler);
|
|
395
448
|
instance.addEventListener("onConnectedUsersChange", onConnectedUsersChangedHandler);
|
|
396
449
|
instance.addEventListener("onMutexLockChange", onMutexLockChangeHandler);
|
|
397
450
|
return () => {
|
|
451
|
+
instance.removeEventListener("onStoreRoomChanged", onStoreRoomChangedHandler);
|
|
452
|
+
instance.removeEventListener("onRoomSwitchingStart", onRoomSwitchingStartHandler);
|
|
453
|
+
instance.removeEventListener("onRoomSwitchingEnd", onRoomSwitchingEndHandler);
|
|
398
454
|
instance.removeEventListener("onSelectionState", onSelectionStateHandler);
|
|
399
455
|
instance.removeEventListener("onZoomChange", onZoomChangeHandler);
|
|
400
456
|
instance.removeEventListener("onNodesChange", onNodesChangeHandler);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/weave-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-SNAPSHOT.85.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"version:release": "npm version $RELEASE_VERSION -m \"[npm-scripts] prepare release $RELEASE_VERSION\" --tag-version-prefix \"\""
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@inditextech/weave-sdk": "3.
|
|
51
|
-
"@inditextech/weave-types": "3.
|
|
50
|
+
"@inditextech/weave-sdk": "3.4.0-SNAPSHOT.85.1",
|
|
51
|
+
"@inditextech/weave-types": "3.4.0-SNAPSHOT.85.1",
|
|
52
52
|
"@syncedstore/core": "0.6.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|