@inditextech/weave-react 0.1.0 → 0.2.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 +332 -20
- package/dist/react.d.cts +596 -0
- package/dist/react.d.ts +596 -81
- package/dist/react.js +304 -861
- package/package.json +10 -5
- package/dist/react.cjs.gz +0 -0
- package/dist/react.js.gz +0 -0
package/dist/react.js
CHANGED
|
@@ -1,866 +1,309 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @license React
|
|
6
|
-
* react-jsx-runtime.development.js
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the MIT license found in the
|
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/
|
|
13
|
-
(function() {
|
|
14
|
-
var c = w, o = Symbol.for("react.element"), n = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), U = Symbol.for("react.profiler"), M = Symbol.for("react.provider"), I = Symbol.for("react.context"), x = Symbol.for("react.forward_ref"), E = Symbol.for("react.suspense"), _ = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), D = Symbol.for("react.lazy"), N = Symbol.for("react.offscreen"), H = Symbol.iterator, oe = "@@iterator";
|
|
15
|
-
function ie(e) {
|
|
16
|
-
if (e === null || typeof e != "object")
|
|
17
|
-
return null;
|
|
18
|
-
var r = H && e[H] || e[oe];
|
|
19
|
-
return typeof r == "function" ? r : null;
|
|
20
|
-
}
|
|
21
|
-
var A = c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
22
|
-
function g(e) {
|
|
23
|
-
{
|
|
24
|
-
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), i = 1; i < r; i++)
|
|
25
|
-
t[i - 1] = arguments[i];
|
|
26
|
-
se("error", e, t);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function se(e, r, t) {
|
|
30
|
-
{
|
|
31
|
-
var i = A.ReactDebugCurrentFrame, l = i.getStackAddendum();
|
|
32
|
-
l !== "" && (r += "%s", t = t.concat([l]));
|
|
33
|
-
var f = t.map(function(u) {
|
|
34
|
-
return String(u);
|
|
35
|
-
});
|
|
36
|
-
f.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, f);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
var ue = !1, ce = !1, le = !1, K = !1, fe = !1, Y;
|
|
40
|
-
Y = Symbol.for("react.module.reference");
|
|
41
|
-
function V(e) {
|
|
42
|
-
return !!(typeof e == "string" || typeof e == "function" || e === m || e === U || fe || e === O || e === E || e === _ || K || e === N || ue || ce || le || typeof e == "object" && e !== null && (e.$$typeof === D || e.$$typeof === R || e.$$typeof === M || e.$$typeof === I || e.$$typeof === x || // This needs to include all possible module reference object
|
|
43
|
-
// types supported by any Flight configuration anywhere since
|
|
44
|
-
// we don't know which Flight build this will end up being used
|
|
45
|
-
// with.
|
|
46
|
-
e.$$typeof === Y || e.getModuleId !== void 0));
|
|
47
|
-
}
|
|
48
|
-
function z(e, r, t) {
|
|
49
|
-
var i = e.displayName;
|
|
50
|
-
if (i)
|
|
51
|
-
return i;
|
|
52
|
-
var l = r.displayName || r.name || "";
|
|
53
|
-
return l !== "" ? t + "(" + l + ")" : t;
|
|
54
|
-
}
|
|
55
|
-
function $(e) {
|
|
56
|
-
return e.displayName || "Context";
|
|
57
|
-
}
|
|
58
|
-
function S(e) {
|
|
59
|
-
if (e == null)
|
|
60
|
-
return null;
|
|
61
|
-
if (typeof e.tag == "number" && g("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
62
|
-
return e.displayName || e.name || null;
|
|
63
|
-
if (typeof e == "string")
|
|
64
|
-
return e;
|
|
65
|
-
switch (e) {
|
|
66
|
-
case m:
|
|
67
|
-
return "Fragment";
|
|
68
|
-
case n:
|
|
69
|
-
return "Portal";
|
|
70
|
-
case U:
|
|
71
|
-
return "Profiler";
|
|
72
|
-
case O:
|
|
73
|
-
return "StrictMode";
|
|
74
|
-
case E:
|
|
75
|
-
return "Suspense";
|
|
76
|
-
case _:
|
|
77
|
-
return "SuspenseList";
|
|
78
|
-
}
|
|
79
|
-
if (typeof e == "object")
|
|
80
|
-
switch (e.$$typeof) {
|
|
81
|
-
case I:
|
|
82
|
-
var r = e;
|
|
83
|
-
return $(r) + ".Consumer";
|
|
84
|
-
case M:
|
|
85
|
-
var t = e;
|
|
86
|
-
return $(t._context) + ".Provider";
|
|
87
|
-
case x:
|
|
88
|
-
return z(e, e.render, "ForwardRef");
|
|
89
|
-
case R:
|
|
90
|
-
var i = e.displayName || null;
|
|
91
|
-
return i !== null ? i : S(e.type) || "Memo";
|
|
92
|
-
case D: {
|
|
93
|
-
var l = e, f = l._payload, u = l._init;
|
|
94
|
-
try {
|
|
95
|
-
return S(u(f));
|
|
96
|
-
} catch {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
var j = Object.assign, F = 0, G, X, J, q, Q, a, k;
|
|
104
|
-
function P() {
|
|
105
|
-
}
|
|
106
|
-
P.__reactDisabledLog = !0;
|
|
107
|
-
function y() {
|
|
108
|
-
{
|
|
109
|
-
if (F === 0) {
|
|
110
|
-
G = console.log, X = console.info, J = console.warn, q = console.error, Q = console.group, a = console.groupCollapsed, k = console.groupEnd;
|
|
111
|
-
var e = {
|
|
112
|
-
configurable: !0,
|
|
113
|
-
enumerable: !0,
|
|
114
|
-
value: P,
|
|
115
|
-
writable: !0
|
|
116
|
-
};
|
|
117
|
-
Object.defineProperties(console, {
|
|
118
|
-
info: e,
|
|
119
|
-
log: e,
|
|
120
|
-
warn: e,
|
|
121
|
-
error: e,
|
|
122
|
-
group: e,
|
|
123
|
-
groupCollapsed: e,
|
|
124
|
-
groupEnd: e
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
F++;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function T() {
|
|
131
|
-
{
|
|
132
|
-
if (F--, F === 0) {
|
|
133
|
-
var e = {
|
|
134
|
-
configurable: !0,
|
|
135
|
-
enumerable: !0,
|
|
136
|
-
writable: !0
|
|
137
|
-
};
|
|
138
|
-
Object.defineProperties(console, {
|
|
139
|
-
log: j({}, e, {
|
|
140
|
-
value: G
|
|
141
|
-
}),
|
|
142
|
-
info: j({}, e, {
|
|
143
|
-
value: X
|
|
144
|
-
}),
|
|
145
|
-
warn: j({}, e, {
|
|
146
|
-
value: J
|
|
147
|
-
}),
|
|
148
|
-
error: j({}, e, {
|
|
149
|
-
value: q
|
|
150
|
-
}),
|
|
151
|
-
group: j({}, e, {
|
|
152
|
-
value: Q
|
|
153
|
-
}),
|
|
154
|
-
groupCollapsed: j({}, e, {
|
|
155
|
-
value: a
|
|
156
|
-
}),
|
|
157
|
-
groupEnd: j({}, e, {
|
|
158
|
-
value: k
|
|
159
|
-
})
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
F < 0 && g("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
var de = A.ReactCurrentDispatcher, ve;
|
|
166
|
-
function ee(e, r, t) {
|
|
167
|
-
{
|
|
168
|
-
if (ve === void 0)
|
|
169
|
-
try {
|
|
170
|
-
throw Error();
|
|
171
|
-
} catch (l) {
|
|
172
|
-
var i = l.stack.trim().match(/\n( *(at )?)/);
|
|
173
|
-
ve = i && i[1] || "";
|
|
174
|
-
}
|
|
175
|
-
return `
|
|
176
|
-
` + ve + e;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
var ge = !1, re;
|
|
180
|
-
{
|
|
181
|
-
var Ye = typeof WeakMap == "function" ? WeakMap : Map;
|
|
182
|
-
re = new Ye();
|
|
183
|
-
}
|
|
184
|
-
function ye(e, r) {
|
|
185
|
-
if (!e || ge)
|
|
186
|
-
return "";
|
|
187
|
-
{
|
|
188
|
-
var t = re.get(e);
|
|
189
|
-
if (t !== void 0)
|
|
190
|
-
return t;
|
|
191
|
-
}
|
|
192
|
-
var i;
|
|
193
|
-
ge = !0;
|
|
194
|
-
var l = Error.prepareStackTrace;
|
|
195
|
-
Error.prepareStackTrace = void 0;
|
|
196
|
-
var f;
|
|
197
|
-
f = de.current, de.current = null, y();
|
|
198
|
-
try {
|
|
199
|
-
if (r) {
|
|
200
|
-
var u = function() {
|
|
201
|
-
throw Error();
|
|
202
|
-
};
|
|
203
|
-
if (Object.defineProperty(u.prototype, "props", {
|
|
204
|
-
set: function() {
|
|
205
|
-
throw Error();
|
|
206
|
-
}
|
|
207
|
-
}), typeof Reflect == "object" && Reflect.construct) {
|
|
208
|
-
try {
|
|
209
|
-
Reflect.construct(u, []);
|
|
210
|
-
} catch (h) {
|
|
211
|
-
i = h;
|
|
212
|
-
}
|
|
213
|
-
Reflect.construct(e, [], u);
|
|
214
|
-
} else {
|
|
215
|
-
try {
|
|
216
|
-
u.call();
|
|
217
|
-
} catch (h) {
|
|
218
|
-
i = h;
|
|
219
|
-
}
|
|
220
|
-
e.call(u.prototype);
|
|
221
|
-
}
|
|
222
|
-
} else {
|
|
223
|
-
try {
|
|
224
|
-
throw Error();
|
|
225
|
-
} catch (h) {
|
|
226
|
-
i = h;
|
|
227
|
-
}
|
|
228
|
-
e();
|
|
229
|
-
}
|
|
230
|
-
} catch (h) {
|
|
231
|
-
if (h && i && typeof h.stack == "string") {
|
|
232
|
-
for (var s = h.stack.split(`
|
|
233
|
-
`), p = i.stack.split(`
|
|
234
|
-
`), d = s.length - 1, v = p.length - 1; d >= 1 && v >= 0 && s[d] !== p[v]; )
|
|
235
|
-
v--;
|
|
236
|
-
for (; d >= 1 && v >= 0; d--, v--)
|
|
237
|
-
if (s[d] !== p[v]) {
|
|
238
|
-
if (d !== 1 || v !== 1)
|
|
239
|
-
do
|
|
240
|
-
if (d--, v--, v < 0 || s[d] !== p[v]) {
|
|
241
|
-
var C = `
|
|
242
|
-
` + s[d].replace(" at new ", " at ");
|
|
243
|
-
return e.displayName && C.includes("<anonymous>") && (C = C.replace("<anonymous>", e.displayName)), typeof e == "function" && re.set(e, C), C;
|
|
244
|
-
}
|
|
245
|
-
while (d >= 1 && v >= 0);
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
} finally {
|
|
250
|
-
ge = !1, de.current = f, T(), Error.prepareStackTrace = l;
|
|
251
|
-
}
|
|
252
|
-
var Z = e ? e.displayName || e.name : "", W = Z ? ee(Z) : "";
|
|
253
|
-
return typeof e == "function" && re.set(e, W), W;
|
|
254
|
-
}
|
|
255
|
-
function $e(e, r, t) {
|
|
256
|
-
return ye(e, !1);
|
|
257
|
-
}
|
|
258
|
-
function Le(e) {
|
|
259
|
-
var r = e.prototype;
|
|
260
|
-
return !!(r && r.isReactComponent);
|
|
261
|
-
}
|
|
262
|
-
function te(e, r, t) {
|
|
263
|
-
if (e == null)
|
|
264
|
-
return "";
|
|
265
|
-
if (typeof e == "function")
|
|
266
|
-
return ye(e, Le(e));
|
|
267
|
-
if (typeof e == "string")
|
|
268
|
-
return ee(e);
|
|
269
|
-
switch (e) {
|
|
270
|
-
case E:
|
|
271
|
-
return ee("Suspense");
|
|
272
|
-
case _:
|
|
273
|
-
return ee("SuspenseList");
|
|
274
|
-
}
|
|
275
|
-
if (typeof e == "object")
|
|
276
|
-
switch (e.$$typeof) {
|
|
277
|
-
case x:
|
|
278
|
-
return $e(e.render);
|
|
279
|
-
case R:
|
|
280
|
-
return te(e.type, r, t);
|
|
281
|
-
case D: {
|
|
282
|
-
var i = e, l = i._payload, f = i._init;
|
|
283
|
-
try {
|
|
284
|
-
return te(f(l), r, t);
|
|
285
|
-
} catch {
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return "";
|
|
290
|
-
}
|
|
291
|
-
var B = Object.prototype.hasOwnProperty, Ee = {}, Se = A.ReactDebugCurrentFrame;
|
|
292
|
-
function ne(e) {
|
|
293
|
-
if (e) {
|
|
294
|
-
var r = e._owner, t = te(e.type, e._source, r ? r.type : null);
|
|
295
|
-
Se.setExtraStackFrame(t);
|
|
296
|
-
} else
|
|
297
|
-
Se.setExtraStackFrame(null);
|
|
298
|
-
}
|
|
299
|
-
function Ze(e, r, t, i, l) {
|
|
300
|
-
{
|
|
301
|
-
var f = Function.call.bind(B);
|
|
302
|
-
for (var u in e)
|
|
303
|
-
if (f(e, u)) {
|
|
304
|
-
var s = void 0;
|
|
305
|
-
try {
|
|
306
|
-
if (typeof e[u] != "function") {
|
|
307
|
-
var p = Error((i || "React class") + ": " + t + " type `" + u + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[u] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
308
|
-
throw p.name = "Invariant Violation", p;
|
|
309
|
-
}
|
|
310
|
-
s = e[u](r, u, i, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
311
|
-
} catch (d) {
|
|
312
|
-
s = d;
|
|
313
|
-
}
|
|
314
|
-
s && !(s instanceof Error) && (ne(l), g("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", i || "React class", t, u, typeof s), ne(null)), s instanceof Error && !(s.message in Ee) && (Ee[s.message] = !0, ne(l), g("Failed %s type: %s", t, s.message), ne(null));
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
var Me = Array.isArray;
|
|
319
|
-
function pe(e) {
|
|
320
|
-
return Me(e);
|
|
321
|
-
}
|
|
322
|
-
function Ne(e) {
|
|
323
|
-
{
|
|
324
|
-
var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
325
|
-
return t;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function Ve(e) {
|
|
329
|
-
try {
|
|
330
|
-
return Ce(e), !1;
|
|
331
|
-
} catch {
|
|
332
|
-
return !0;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function Ce(e) {
|
|
336
|
-
return "" + e;
|
|
337
|
-
}
|
|
338
|
-
function _e(e) {
|
|
339
|
-
if (Ve(e))
|
|
340
|
-
return g("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ne(e)), Ce(e);
|
|
341
|
-
}
|
|
342
|
-
var Pe = A.ReactCurrentOwner, ze = {
|
|
343
|
-
key: !0,
|
|
344
|
-
ref: !0,
|
|
345
|
-
__self: !0,
|
|
346
|
-
__source: !0
|
|
347
|
-
}, Te, we;
|
|
348
|
-
function Be(e) {
|
|
349
|
-
if (B.call(e, "ref")) {
|
|
350
|
-
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
351
|
-
if (r && r.isReactWarning)
|
|
352
|
-
return !1;
|
|
353
|
-
}
|
|
354
|
-
return e.ref !== void 0;
|
|
355
|
-
}
|
|
356
|
-
function He(e) {
|
|
357
|
-
if (B.call(e, "key")) {
|
|
358
|
-
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
359
|
-
if (r && r.isReactWarning)
|
|
360
|
-
return !1;
|
|
361
|
-
}
|
|
362
|
-
return e.key !== void 0;
|
|
363
|
-
}
|
|
364
|
-
function Ke(e, r) {
|
|
365
|
-
typeof e.ref == "string" && Pe.current;
|
|
366
|
-
}
|
|
367
|
-
function Ge(e, r) {
|
|
368
|
-
{
|
|
369
|
-
var t = function() {
|
|
370
|
-
Te || (Te = !0, g("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
371
|
-
};
|
|
372
|
-
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
373
|
-
get: t,
|
|
374
|
-
configurable: !0
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
function Xe(e, r) {
|
|
379
|
-
{
|
|
380
|
-
var t = function() {
|
|
381
|
-
we || (we = !0, g("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
382
|
-
};
|
|
383
|
-
t.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
384
|
-
get: t,
|
|
385
|
-
configurable: !0
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
var Je = function(e, r, t, i, l, f, u) {
|
|
390
|
-
var s = {
|
|
391
|
-
// This tag allows us to uniquely identify this as a React Element
|
|
392
|
-
$$typeof: o,
|
|
393
|
-
// Built-in properties that belong on the element
|
|
394
|
-
type: e,
|
|
395
|
-
key: r,
|
|
396
|
-
ref: t,
|
|
397
|
-
props: u,
|
|
398
|
-
// Record the component responsible for creating this element.
|
|
399
|
-
_owner: f
|
|
400
|
-
};
|
|
401
|
-
return s._store = {}, Object.defineProperty(s._store, "validated", {
|
|
402
|
-
configurable: !1,
|
|
403
|
-
enumerable: !1,
|
|
404
|
-
writable: !0,
|
|
405
|
-
value: !1
|
|
406
|
-
}), Object.defineProperty(s, "_self", {
|
|
407
|
-
configurable: !1,
|
|
408
|
-
enumerable: !1,
|
|
409
|
-
writable: !1,
|
|
410
|
-
value: i
|
|
411
|
-
}), Object.defineProperty(s, "_source", {
|
|
412
|
-
configurable: !1,
|
|
413
|
-
enumerable: !1,
|
|
414
|
-
writable: !1,
|
|
415
|
-
value: l
|
|
416
|
-
}), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
|
|
417
|
-
};
|
|
418
|
-
function qe(e, r, t, i, l) {
|
|
419
|
-
{
|
|
420
|
-
var f, u = {}, s = null, p = null;
|
|
421
|
-
t !== void 0 && (_e(t), s = "" + t), He(r) && (_e(r.key), s = "" + r.key), Be(r) && (p = r.ref, Ke(r, l));
|
|
422
|
-
for (f in r)
|
|
423
|
-
B.call(r, f) && !ze.hasOwnProperty(f) && (u[f] = r[f]);
|
|
424
|
-
if (e && e.defaultProps) {
|
|
425
|
-
var d = e.defaultProps;
|
|
426
|
-
for (f in d)
|
|
427
|
-
u[f] === void 0 && (u[f] = d[f]);
|
|
428
|
-
}
|
|
429
|
-
if (s || p) {
|
|
430
|
-
var v = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
431
|
-
s && Ge(u, v), p && Xe(u, v);
|
|
432
|
-
}
|
|
433
|
-
return Je(e, s, p, l, i, Pe.current, u);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
var he = A.ReactCurrentOwner, Oe = A.ReactDebugCurrentFrame;
|
|
437
|
-
function L(e) {
|
|
438
|
-
if (e) {
|
|
439
|
-
var r = e._owner, t = te(e.type, e._source, r ? r.type : null);
|
|
440
|
-
Oe.setExtraStackFrame(t);
|
|
441
|
-
} else
|
|
442
|
-
Oe.setExtraStackFrame(null);
|
|
443
|
-
}
|
|
444
|
-
var be;
|
|
445
|
-
be = !1;
|
|
446
|
-
function me(e) {
|
|
447
|
-
return typeof e == "object" && e !== null && e.$$typeof === o;
|
|
448
|
-
}
|
|
449
|
-
function je() {
|
|
450
|
-
{
|
|
451
|
-
if (he.current) {
|
|
452
|
-
var e = S(he.current.type);
|
|
453
|
-
if (e)
|
|
454
|
-
return `
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Weave, WeaveConnectedUsersPlugin, WeaveCopyPasteNodesPlugin, WeaveNodesSelectionPlugin, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveUsersPointersPlugin } from "@inditextech/weave-sdk";
|
|
3
|
+
import Konva from "konva";
|
|
455
4
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
5
|
+
//#region ../types/dist/types.js
|
|
6
|
+
const WEAVE_INSTANCE_STATUS = {
|
|
7
|
+
["IDLE"]: "idle",
|
|
8
|
+
["STARTING"]: "starting",
|
|
9
|
+
["LOADING_FONTS"]: "loadingFonts",
|
|
10
|
+
["RUNNING"]: "running"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ../../node_modules/zustand/esm/vanilla.mjs
|
|
15
|
+
const createStoreImpl = (createState) => {
|
|
16
|
+
let state;
|
|
17
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
18
|
+
const setState = (partial, replace) => {
|
|
19
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
20
|
+
if (!Object.is(nextState, state)) {
|
|
21
|
+
const previousState = state;
|
|
22
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
23
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const getState = () => state;
|
|
27
|
+
const getInitialState = () => initialState;
|
|
28
|
+
const subscribe = (listener) => {
|
|
29
|
+
listeners.add(listener);
|
|
30
|
+
return () => listeners.delete(listener);
|
|
31
|
+
};
|
|
32
|
+
const api = {
|
|
33
|
+
setState,
|
|
34
|
+
getState,
|
|
35
|
+
getInitialState,
|
|
36
|
+
subscribe
|
|
37
|
+
};
|
|
38
|
+
const initialState = state = createState(setState, getState, api);
|
|
39
|
+
return api;
|
|
40
|
+
};
|
|
41
|
+
const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
471
42
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if (!e._store || e._store.validated || e.key != null)
|
|
480
|
-
return;
|
|
481
|
-
e._store.validated = !0;
|
|
482
|
-
var t = er(r);
|
|
483
|
-
if (ke[t])
|
|
484
|
-
return;
|
|
485
|
-
ke[t] = !0;
|
|
486
|
-
var i = "";
|
|
487
|
-
e && e._owner && e._owner !== he.current && (i = " It was passed a child from " + S(e._owner.type) + "."), L(e), g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, i), L(null);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
function Ae(e, r) {
|
|
491
|
-
{
|
|
492
|
-
if (typeof e != "object")
|
|
493
|
-
return;
|
|
494
|
-
if (pe(e))
|
|
495
|
-
for (var t = 0; t < e.length; t++) {
|
|
496
|
-
var i = e[t];
|
|
497
|
-
me(i) && xe(i, r);
|
|
498
|
-
}
|
|
499
|
-
else if (me(e))
|
|
500
|
-
e._store && (e._store.validated = !0);
|
|
501
|
-
else if (e) {
|
|
502
|
-
var l = ie(e);
|
|
503
|
-
if (typeof l == "function" && l !== e.entries)
|
|
504
|
-
for (var f = l.call(e), u; !(u = f.next()).done; )
|
|
505
|
-
me(u.value) && xe(u.value, r);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
function rr(e) {
|
|
510
|
-
{
|
|
511
|
-
var r = e.type;
|
|
512
|
-
if (r == null || typeof r == "string")
|
|
513
|
-
return;
|
|
514
|
-
var t;
|
|
515
|
-
if (typeof r == "function")
|
|
516
|
-
t = r.propTypes;
|
|
517
|
-
else if (typeof r == "object" && (r.$$typeof === x || // Note: Memo only checks outer props here.
|
|
518
|
-
// Inner props are checked in the reconciler.
|
|
519
|
-
r.$$typeof === R))
|
|
520
|
-
t = r.propTypes;
|
|
521
|
-
else
|
|
522
|
-
return;
|
|
523
|
-
if (t) {
|
|
524
|
-
var i = S(r);
|
|
525
|
-
Ze(t, e.props, "prop", i, e);
|
|
526
|
-
} else if (r.PropTypes !== void 0 && !be) {
|
|
527
|
-
be = !0;
|
|
528
|
-
var l = S(r);
|
|
529
|
-
g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", l || "Unknown");
|
|
530
|
-
}
|
|
531
|
-
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
function tr(e) {
|
|
535
|
-
{
|
|
536
|
-
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
|
|
537
|
-
var i = r[t];
|
|
538
|
-
if (i !== "children" && i !== "key") {
|
|
539
|
-
L(e), g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", i), L(null);
|
|
540
|
-
break;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
e.ref !== null && (L(e), g("Invalid attribute `ref` supplied to `React.Fragment`."), L(null));
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
var Ie = {};
|
|
547
|
-
function De(e, r, t, i, l, f) {
|
|
548
|
-
{
|
|
549
|
-
var u = V(e);
|
|
550
|
-
if (!u) {
|
|
551
|
-
var s = "";
|
|
552
|
-
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (s += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
553
|
-
var p = Qe();
|
|
554
|
-
p ? s += p : s += je();
|
|
555
|
-
var d;
|
|
556
|
-
e === null ? d = "null" : pe(e) ? d = "array" : e !== void 0 && e.$$typeof === o ? (d = "<" + (S(e.type) || "Unknown") + " />", s = " Did you accidentally export a JSX literal instead of a component?") : d = typeof e, g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", d, s);
|
|
557
|
-
}
|
|
558
|
-
var v = qe(e, r, t, l, f);
|
|
559
|
-
if (v == null)
|
|
560
|
-
return v;
|
|
561
|
-
if (u) {
|
|
562
|
-
var C = r.children;
|
|
563
|
-
if (C !== void 0)
|
|
564
|
-
if (i)
|
|
565
|
-
if (pe(C)) {
|
|
566
|
-
for (var Z = 0; Z < C.length; Z++)
|
|
567
|
-
Ae(C[Z], e);
|
|
568
|
-
Object.freeze && Object.freeze(C);
|
|
569
|
-
} else
|
|
570
|
-
g("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
571
|
-
else
|
|
572
|
-
Ae(C, e);
|
|
573
|
-
}
|
|
574
|
-
if (B.call(r, "key")) {
|
|
575
|
-
var W = S(e), h = Object.keys(r).filter(function(ur) {
|
|
576
|
-
return ur !== "key";
|
|
577
|
-
}), Re = h.length > 0 ? "{key: someKey, " + h.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
578
|
-
if (!Ie[W + Re]) {
|
|
579
|
-
var sr = h.length > 0 ? "{" + h.join(": ..., ") + ": ...}" : "{}";
|
|
580
|
-
g(`A props object containing a "key" prop is being spread into JSX:
|
|
581
|
-
let props = %s;
|
|
582
|
-
<%s {...props} />
|
|
583
|
-
React keys must be passed directly to JSX without using spread:
|
|
584
|
-
let props = %s;
|
|
585
|
-
<%s key={someKey} {...props} />`, Re, W, sr, W), Ie[W + Re] = !0;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
return e === m ? tr(v) : rr(v), v;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
function nr(e, r, t) {
|
|
592
|
-
return De(e, r, t, !0);
|
|
593
|
-
}
|
|
594
|
-
function ar(e, r, t) {
|
|
595
|
-
return De(e, r, t, !1);
|
|
596
|
-
}
|
|
597
|
-
var or = ar, ir = nr;
|
|
598
|
-
ae.Fragment = m, ae.jsx = or, ae.jsxs = ir;
|
|
599
|
-
})();
|
|
600
|
-
Ue.exports = ae;
|
|
601
|
-
var Fe = Ue.exports;
|
|
602
|
-
const Rr = {
|
|
603
|
-
IDLE: "idle"
|
|
604
|
-
}, We = (c) => {
|
|
605
|
-
let o;
|
|
606
|
-
const n = /* @__PURE__ */ new Set(), m = (E, _) => {
|
|
607
|
-
const R = typeof E == "function" ? E(o) : E;
|
|
608
|
-
if (!Object.is(R, o)) {
|
|
609
|
-
const D = o;
|
|
610
|
-
o = _ ?? (typeof R != "object" || R === null) ? R : Object.assign({}, o, R), n.forEach((N) => N(o, D));
|
|
611
|
-
}
|
|
612
|
-
}, O = () => o, I = { setState: m, getState: O, getInitialState: () => x, subscribe: (E) => (n.add(E), () => n.delete(E)) }, x = o = c(m, O, I);
|
|
613
|
-
return I;
|
|
614
|
-
}, yr = (c) => c ? We(c) : We, Er = (c) => c;
|
|
615
|
-
function Sr(c, o = Er) {
|
|
616
|
-
const n = w.useSyncExternalStore(
|
|
617
|
-
c.subscribe,
|
|
618
|
-
() => o(c.getState()),
|
|
619
|
-
() => o(c.getInitialState())
|
|
620
|
-
);
|
|
621
|
-
return w.useDebugValue(n), n;
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region ../../node_modules/zustand/esm/react.mjs
|
|
45
|
+
const identity = (arg) => arg;
|
|
46
|
+
function useStore(api, selector = identity) {
|
|
47
|
+
const slice = React.useSyncExternalStore(api.subscribe, () => selector(api.getState()), () => selector(api.getInitialState()));
|
|
48
|
+
React.useDebugValue(slice);
|
|
49
|
+
return slice;
|
|
622
50
|
}
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
appState: {
|
|
629
|
-
weave: {}
|
|
630
|
-
},
|
|
631
|
-
status: Rr.IDLE,
|
|
632
|
-
room: {
|
|
633
|
-
loaded: !1
|
|
634
|
-
},
|
|
635
|
-
connection: {
|
|
636
|
-
status: "disconnected"
|
|
637
|
-
},
|
|
638
|
-
users: {},
|
|
639
|
-
undoRedo: {
|
|
640
|
-
canUndo: !1,
|
|
641
|
-
canRedo: !1
|
|
642
|
-
},
|
|
643
|
-
zoom: {
|
|
644
|
-
value: 1,
|
|
645
|
-
canZoomIn: !1,
|
|
646
|
-
canZoomOut: !1
|
|
647
|
-
},
|
|
648
|
-
contextMenu: {
|
|
649
|
-
show: !1,
|
|
650
|
-
position: {
|
|
651
|
-
x: 0,
|
|
652
|
-
y: 0
|
|
653
|
-
},
|
|
654
|
-
options: []
|
|
655
|
-
},
|
|
656
|
-
selection: {
|
|
657
|
-
nodes: [],
|
|
658
|
-
node: void 0
|
|
659
|
-
},
|
|
660
|
-
actions: {
|
|
661
|
-
active: !1,
|
|
662
|
-
actual: void 0
|
|
663
|
-
},
|
|
664
|
-
setInstance: (o) => c((n) => ({
|
|
665
|
-
...n,
|
|
666
|
-
instance: o
|
|
667
|
-
})),
|
|
668
|
-
setStatus: (o) => c((n) => ({
|
|
669
|
-
...n,
|
|
670
|
-
status: o
|
|
671
|
-
})),
|
|
672
|
-
setAppState: (o) => c((n) => ({
|
|
673
|
-
...n,
|
|
674
|
-
appState: o
|
|
675
|
-
})),
|
|
676
|
-
setConnectionStatus: (o) => c((n) => ({
|
|
677
|
-
...n,
|
|
678
|
-
connection: {
|
|
679
|
-
...n.connection,
|
|
680
|
-
status: o
|
|
681
|
-
}
|
|
682
|
-
})),
|
|
683
|
-
setRoomLoaded: (o) => c((n) => ({
|
|
684
|
-
...n,
|
|
685
|
-
room: {
|
|
686
|
-
...n.room,
|
|
687
|
-
loaded: o
|
|
688
|
-
}
|
|
689
|
-
})),
|
|
690
|
-
setUsers: (o) => c((n) => ({
|
|
691
|
-
...n,
|
|
692
|
-
users: o
|
|
693
|
-
})),
|
|
694
|
-
setCanUndo: (o) => c((n) => ({
|
|
695
|
-
...n,
|
|
696
|
-
undoRedo: {
|
|
697
|
-
...n.undoRedo,
|
|
698
|
-
canUndo: o
|
|
699
|
-
}
|
|
700
|
-
})),
|
|
701
|
-
setCanRedo: (o) => c((n) => ({
|
|
702
|
-
...n,
|
|
703
|
-
undoRedo: {
|
|
704
|
-
...n.undoRedo,
|
|
705
|
-
canRedo: o
|
|
706
|
-
}
|
|
707
|
-
})),
|
|
708
|
-
setZoom: (o) => c((n) => ({
|
|
709
|
-
...n,
|
|
710
|
-
zoom: {
|
|
711
|
-
...n.zoom,
|
|
712
|
-
value: o
|
|
713
|
-
}
|
|
714
|
-
})),
|
|
715
|
-
setCanZoomIn: (o) => c((n) => ({
|
|
716
|
-
...n,
|
|
717
|
-
zoom: {
|
|
718
|
-
...n.zoom,
|
|
719
|
-
canZoomIn: o
|
|
720
|
-
}
|
|
721
|
-
})),
|
|
722
|
-
setCanZoomOut: (o) => c((n) => ({
|
|
723
|
-
...n,
|
|
724
|
-
zoom: {
|
|
725
|
-
...n.zoom,
|
|
726
|
-
canZoomOut: o
|
|
727
|
-
}
|
|
728
|
-
})),
|
|
729
|
-
setSelectedNodes: (o) => c((n) => ({
|
|
730
|
-
...n,
|
|
731
|
-
selection: {
|
|
732
|
-
...n.selection,
|
|
733
|
-
nodes: o
|
|
734
|
-
}
|
|
735
|
-
})),
|
|
736
|
-
setNode: (o) => c((n) => ({
|
|
737
|
-
...n,
|
|
738
|
-
selection: {
|
|
739
|
-
...n.selection,
|
|
740
|
-
node: o
|
|
741
|
-
}
|
|
742
|
-
})),
|
|
743
|
-
setActualAction: (o) => c((n) => ({
|
|
744
|
-
...n,
|
|
745
|
-
actions: {
|
|
746
|
-
...n.actions,
|
|
747
|
-
active: typeof o < "u",
|
|
748
|
-
actual: o
|
|
749
|
-
}
|
|
750
|
-
}))
|
|
751
|
-
})), wr = ({
|
|
752
|
-
containerId: c,
|
|
753
|
-
getUser: o,
|
|
754
|
-
store: n,
|
|
755
|
-
nodes: m = [],
|
|
756
|
-
actions: O = [],
|
|
757
|
-
plugins: U = [],
|
|
758
|
-
customPlugins: M = [],
|
|
759
|
-
fonts: I = [],
|
|
760
|
-
callbacks: x = {},
|
|
761
|
-
children: E
|
|
762
|
-
}) => {
|
|
763
|
-
const _ = w.useRef(null), R = b((a) => a.selection.nodes), D = b((a) => a.setInstance), N = b((a) => a.setAppState), H = b((a) => a.setStatus), oe = b((a) => a.setRoomLoaded), ie = b((a) => a.setUsers), A = b((a) => a.setCanUndo), g = b((a) => a.setCanRedo), se = b((a) => a.setZoom), ue = b((a) => a.setCanZoomIn), ce = b((a) => a.setCanZoomOut), le = b((a) => a.setSelectedNodes), K = b((a) => a.setNode), fe = b((a) => a.setActualAction), {
|
|
764
|
-
onInstanceStatus: Y,
|
|
765
|
-
onRoomLoaded: V,
|
|
766
|
-
onStateChange: z,
|
|
767
|
-
onUndoManagerStatusChange: $,
|
|
768
|
-
onActiveActionChange: S,
|
|
769
|
-
...j
|
|
770
|
-
} = x, F = w.useCallback(
|
|
771
|
-
(a) => {
|
|
772
|
-
H(a), Y == null || Y(a);
|
|
773
|
-
},
|
|
774
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
775
|
-
[]
|
|
776
|
-
), G = w.useCallback(
|
|
777
|
-
(a) => {
|
|
778
|
-
oe(a), V == null || V(a);
|
|
779
|
-
},
|
|
780
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
781
|
-
[]
|
|
782
|
-
), X = w.useCallback(
|
|
783
|
-
(a) => {
|
|
784
|
-
N(a), z == null || z(a);
|
|
785
|
-
},
|
|
786
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
787
|
-
[R]
|
|
788
|
-
), J = w.useCallback(
|
|
789
|
-
(a) => {
|
|
790
|
-
const {
|
|
791
|
-
canUndo: k,
|
|
792
|
-
canRedo: P
|
|
793
|
-
} = a;
|
|
794
|
-
A(k), g(P), $ == null || $(a);
|
|
795
|
-
},
|
|
796
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
797
|
-
[]
|
|
798
|
-
), q = w.useCallback(
|
|
799
|
-
(a) => {
|
|
800
|
-
fe(a), S == null || S(status);
|
|
801
|
-
},
|
|
802
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
803
|
-
[R]
|
|
804
|
-
), Q = w.useCallback((a) => {
|
|
805
|
-
a.length === 1 && K(a[0].node), a.length !== 1 && K(void 0), le(a);
|
|
806
|
-
}, []);
|
|
807
|
-
return w.useEffect(() => {
|
|
808
|
-
async function a() {
|
|
809
|
-
const k = document.getElementById(c), P = k == null ? void 0 : k.getBoundingClientRect();
|
|
810
|
-
if (k && !_.current) {
|
|
811
|
-
if (m.length > 0)
|
|
812
|
-
for (const T of m)
|
|
813
|
-
;
|
|
814
|
-
if (O.length > 0)
|
|
815
|
-
for (const T of O)
|
|
816
|
-
;
|
|
817
|
-
const y = [];
|
|
818
|
-
if (U.length > 0)
|
|
819
|
-
for (const T of U)
|
|
820
|
-
y.push(T);
|
|
821
|
-
else
|
|
822
|
-
y.push(new cr({})), y.push(new lr()), y.push(new fr()), y.push(new dr({
|
|
823
|
-
onZoomChange: (T) => {
|
|
824
|
-
se(T.scale), ue(T.canZoomIn), ce(T.canZoomOut);
|
|
825
|
-
}
|
|
826
|
-
})), y.push(new vr({
|
|
827
|
-
onNodesChange: Q
|
|
828
|
-
})), y.push(new gr({})), y.push(new pr({
|
|
829
|
-
onConnectedUsersChanged: (T) => {
|
|
830
|
-
ie(T);
|
|
831
|
-
},
|
|
832
|
-
getUser: o
|
|
833
|
-
})), y.push(new hr({
|
|
834
|
-
getUser: o
|
|
835
|
-
})), y.push(new br({}));
|
|
836
|
-
_.current = new mr({
|
|
837
|
-
store: n,
|
|
838
|
-
nodes: m,
|
|
839
|
-
actions: O,
|
|
840
|
-
plugins: [...y, ...M],
|
|
841
|
-
fonts: I,
|
|
842
|
-
callbacks: {
|
|
843
|
-
...j,
|
|
844
|
-
onInstanceStatus: F,
|
|
845
|
-
onRoomLoaded: G,
|
|
846
|
-
onStateChange: X,
|
|
847
|
-
onUndoManagerStatusChange: J,
|
|
848
|
-
onActiveActionChange: q
|
|
849
|
-
},
|
|
850
|
-
logger: {
|
|
851
|
-
level: "info"
|
|
852
|
-
}
|
|
853
|
-
}, {
|
|
854
|
-
container: c,
|
|
855
|
-
width: (P == null ? void 0 : P.width) ?? 1920,
|
|
856
|
-
height: (P == null ? void 0 : P.height) ?? 1080
|
|
857
|
-
}), D(_.current), _.current.start();
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
a();
|
|
861
|
-
}, []), /* @__PURE__ */ Fe.jsx(Fe.Fragment, { children: E });
|
|
51
|
+
const createImpl = (createState) => {
|
|
52
|
+
const api = createStore(createState);
|
|
53
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
|
54
|
+
Object.assign(useBoundStore, api);
|
|
55
|
+
return useBoundStore;
|
|
862
56
|
};
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
57
|
+
const create = (createState) => createState ? createImpl(createState) : createImpl;
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/components/store.tsx
|
|
61
|
+
const useWeave = create()((set) => ({
|
|
62
|
+
instance: null,
|
|
63
|
+
appState: { weave: {} },
|
|
64
|
+
status: WEAVE_INSTANCE_STATUS.IDLE,
|
|
65
|
+
room: { loaded: false },
|
|
66
|
+
connection: { status: "disconnected" },
|
|
67
|
+
users: {},
|
|
68
|
+
undoRedo: {
|
|
69
|
+
canUndo: false,
|
|
70
|
+
canRedo: false
|
|
71
|
+
},
|
|
72
|
+
zoom: {
|
|
73
|
+
value: 1,
|
|
74
|
+
canZoomIn: false,
|
|
75
|
+
canZoomOut: false
|
|
76
|
+
},
|
|
77
|
+
contextMenu: {
|
|
78
|
+
show: false,
|
|
79
|
+
position: {
|
|
80
|
+
x: 0,
|
|
81
|
+
y: 0
|
|
82
|
+
},
|
|
83
|
+
options: []
|
|
84
|
+
},
|
|
85
|
+
selection: {
|
|
86
|
+
nodes: [],
|
|
87
|
+
node: void 0
|
|
88
|
+
},
|
|
89
|
+
actions: {
|
|
90
|
+
active: false,
|
|
91
|
+
actual: void 0
|
|
92
|
+
},
|
|
93
|
+
setInstance: (newInstance) => set((state) => ({
|
|
94
|
+
...state,
|
|
95
|
+
instance: newInstance
|
|
96
|
+
})),
|
|
97
|
+
setStatus: (newStatus) => set((state) => ({
|
|
98
|
+
...state,
|
|
99
|
+
status: newStatus
|
|
100
|
+
})),
|
|
101
|
+
setAppState: (newAppState) => set((state) => ({
|
|
102
|
+
...state,
|
|
103
|
+
appState: newAppState
|
|
104
|
+
})),
|
|
105
|
+
setConnectionStatus: (newConnectionStatus) => set((state) => ({
|
|
106
|
+
...state,
|
|
107
|
+
connection: {
|
|
108
|
+
...state.connection,
|
|
109
|
+
status: newConnectionStatus
|
|
110
|
+
}
|
|
111
|
+
})),
|
|
112
|
+
setRoomLoaded: (newStatus) => set((state) => ({
|
|
113
|
+
...state,
|
|
114
|
+
room: {
|
|
115
|
+
...state.room,
|
|
116
|
+
loaded: newStatus
|
|
117
|
+
}
|
|
118
|
+
})),
|
|
119
|
+
setUsers: (newUsers) => set((state) => ({
|
|
120
|
+
...state,
|
|
121
|
+
users: newUsers
|
|
122
|
+
})),
|
|
123
|
+
setCanUndo: (newCanUndo) => set((state) => ({
|
|
124
|
+
...state,
|
|
125
|
+
undoRedo: {
|
|
126
|
+
...state.undoRedo,
|
|
127
|
+
canUndo: newCanUndo
|
|
128
|
+
}
|
|
129
|
+
})),
|
|
130
|
+
setCanRedo: (newCanRedo) => set((state) => ({
|
|
131
|
+
...state,
|
|
132
|
+
undoRedo: {
|
|
133
|
+
...state.undoRedo,
|
|
134
|
+
canRedo: newCanRedo
|
|
135
|
+
}
|
|
136
|
+
})),
|
|
137
|
+
setZoom: (newZoom) => set((state) => ({
|
|
138
|
+
...state,
|
|
139
|
+
zoom: {
|
|
140
|
+
...state.zoom,
|
|
141
|
+
value: newZoom
|
|
142
|
+
}
|
|
143
|
+
})),
|
|
144
|
+
setCanZoomIn: (newCanZoomIn) => set((state) => ({
|
|
145
|
+
...state,
|
|
146
|
+
zoom: {
|
|
147
|
+
...state.zoom,
|
|
148
|
+
canZoomIn: newCanZoomIn
|
|
149
|
+
}
|
|
150
|
+
})),
|
|
151
|
+
setCanZoomOut: (newCanZoomOut) => set((state) => ({
|
|
152
|
+
...state,
|
|
153
|
+
zoom: {
|
|
154
|
+
...state.zoom,
|
|
155
|
+
canZoomOut: newCanZoomOut
|
|
156
|
+
}
|
|
157
|
+
})),
|
|
158
|
+
setSelectedNodes: (newSelectedNodes) => set((state) => ({
|
|
159
|
+
...state,
|
|
160
|
+
selection: {
|
|
161
|
+
...state.selection,
|
|
162
|
+
nodes: newSelectedNodes
|
|
163
|
+
}
|
|
164
|
+
})),
|
|
165
|
+
setNode: (newNode) => set((state) => ({
|
|
166
|
+
...state,
|
|
167
|
+
selection: {
|
|
168
|
+
...state.selection,
|
|
169
|
+
node: newNode
|
|
170
|
+
}
|
|
171
|
+
})),
|
|
172
|
+
setActualAction: (newActualAction) => set((state) => ({
|
|
173
|
+
...state,
|
|
174
|
+
actions: {
|
|
175
|
+
...state.actions,
|
|
176
|
+
active: typeof newActualAction !== "undefined",
|
|
177
|
+
actual: newActualAction
|
|
178
|
+
}
|
|
179
|
+
}))
|
|
180
|
+
}));
|
|
181
|
+
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/components/provider.tsx
|
|
184
|
+
const WeaveProvider = ({ containerId, getUser, store, nodes = [], actions = [], plugins = [], customPlugins = [], fonts = [], callbacks = {}, children }) => {
|
|
185
|
+
const weaveInstanceRef = React.useRef(null);
|
|
186
|
+
const selectedNodes = useWeave((state) => state.selection.nodes);
|
|
187
|
+
const setInstance = useWeave((state) => state.setInstance);
|
|
188
|
+
const setAppState = useWeave((state) => state.setAppState);
|
|
189
|
+
const setStatus = useWeave((state) => state.setStatus);
|
|
190
|
+
const setRoomLoaded = useWeave((state) => state.setRoomLoaded);
|
|
191
|
+
const setUsers = useWeave((state) => state.setUsers);
|
|
192
|
+
const setCanUndo = useWeave((state) => state.setCanUndo);
|
|
193
|
+
const setCanRedo = useWeave((state) => state.setCanRedo);
|
|
194
|
+
const setZoom = useWeave((state) => state.setZoom);
|
|
195
|
+
const setCanZoomIn = useWeave((state) => state.setCanZoomIn);
|
|
196
|
+
const setCanZoomOut = useWeave((state) => state.setCanZoomOut);
|
|
197
|
+
const setSelectedNodes = useWeave((state) => state.setSelectedNodes);
|
|
198
|
+
const setNode = useWeave((state) => state.setNode);
|
|
199
|
+
const setActualAction = useWeave((state) => state.setActualAction);
|
|
200
|
+
const { onInstanceStatus, onRoomLoaded, onStateChange, onUndoManagerStatusChange, onActiveActionChange,...restCallbacks } = callbacks;
|
|
201
|
+
const onInstanceStatusHandler = React.useCallback(
|
|
202
|
+
(status$1) => {
|
|
203
|
+
setStatus(status$1);
|
|
204
|
+
onInstanceStatus?.(status$1);
|
|
205
|
+
},
|
|
206
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
207
|
+
[]
|
|
208
|
+
);
|
|
209
|
+
const onRoomLoadedHandler = React.useCallback(
|
|
210
|
+
(status$1) => {
|
|
211
|
+
setRoomLoaded(status$1);
|
|
212
|
+
onRoomLoaded?.(status$1);
|
|
213
|
+
},
|
|
214
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
215
|
+
[]
|
|
216
|
+
);
|
|
217
|
+
const onStateChangeHandler = React.useCallback(
|
|
218
|
+
(state) => {
|
|
219
|
+
setAppState(state);
|
|
220
|
+
onStateChange?.(state);
|
|
221
|
+
},
|
|
222
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
223
|
+
[selectedNodes]
|
|
224
|
+
);
|
|
225
|
+
const onUndoManagerStatusChangeHandler = React.useCallback(
|
|
226
|
+
(undoManagerStatus) => {
|
|
227
|
+
const { canUndo, canRedo } = undoManagerStatus;
|
|
228
|
+
setCanUndo(canUndo);
|
|
229
|
+
setCanRedo(canRedo);
|
|
230
|
+
onUndoManagerStatusChange?.(undoManagerStatus);
|
|
231
|
+
},
|
|
232
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
233
|
+
[]
|
|
234
|
+
);
|
|
235
|
+
const onActiveActionChangeHandler = React.useCallback(
|
|
236
|
+
(actionName) => {
|
|
237
|
+
setActualAction(actionName);
|
|
238
|
+
onActiveActionChange?.(status);
|
|
239
|
+
},
|
|
240
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
241
|
+
[selectedNodes]
|
|
242
|
+
);
|
|
243
|
+
const onNodesChange = React.useCallback((nodes$1) => {
|
|
244
|
+
if (nodes$1.length === 1) setNode(nodes$1[0].node);
|
|
245
|
+
if (nodes$1.length !== 1) setNode(void 0);
|
|
246
|
+
setSelectedNodes(nodes$1);
|
|
247
|
+
}, []);
|
|
248
|
+
React.useEffect(() => {
|
|
249
|
+
async function initWeave() {
|
|
250
|
+
const weaveEle = document.getElementById(containerId);
|
|
251
|
+
const weaveEleClientRect = weaveEle?.getBoundingClientRect();
|
|
252
|
+
if (weaveEle && !weaveInstanceRef.current) {
|
|
253
|
+
const instanceNodes = [];
|
|
254
|
+
if (nodes.length > 0) for (const node of nodes) instanceNodes.push(node);
|
|
255
|
+
const instanceActions = [];
|
|
256
|
+
if (actions.length > 0) for (const action of actions) instanceActions.push(action);
|
|
257
|
+
const instancePlugins = [];
|
|
258
|
+
if (plugins.length > 0) for (const plugin of plugins) instancePlugins.push(plugin);
|
|
259
|
+
else {
|
|
260
|
+
instancePlugins.push(new WeaveStageGridPlugin({}));
|
|
261
|
+
instancePlugins.push(new WeaveStagePanningPlugin());
|
|
262
|
+
instancePlugins.push(new WeaveStageResizePlugin());
|
|
263
|
+
instancePlugins.push(new WeaveStageZoomPlugin({ onZoomChange: (zoomInfo) => {
|
|
264
|
+
setZoom(zoomInfo.scale);
|
|
265
|
+
setCanZoomIn(zoomInfo.canZoomIn);
|
|
266
|
+
setCanZoomOut(zoomInfo.canZoomOut);
|
|
267
|
+
} }));
|
|
268
|
+
instancePlugins.push(new WeaveNodesSelectionPlugin({ onNodesChange }));
|
|
269
|
+
instancePlugins.push(new WeaveStageDropAreaPlugin({}));
|
|
270
|
+
instancePlugins.push(new WeaveConnectedUsersPlugin({
|
|
271
|
+
onConnectedUsersChanged: (users) => {
|
|
272
|
+
setUsers(users);
|
|
273
|
+
},
|
|
274
|
+
getUser
|
|
275
|
+
}));
|
|
276
|
+
instancePlugins.push(new WeaveUsersPointersPlugin({ getUser }));
|
|
277
|
+
instancePlugins.push(new WeaveCopyPasteNodesPlugin({}));
|
|
278
|
+
}
|
|
279
|
+
weaveInstanceRef.current = new Weave({
|
|
280
|
+
store,
|
|
281
|
+
nodes,
|
|
282
|
+
actions,
|
|
283
|
+
plugins: [...instancePlugins, ...customPlugins],
|
|
284
|
+
fonts,
|
|
285
|
+
callbacks: {
|
|
286
|
+
...restCallbacks,
|
|
287
|
+
onInstanceStatus: onInstanceStatusHandler,
|
|
288
|
+
onRoomLoaded: onRoomLoadedHandler,
|
|
289
|
+
onStateChange: onStateChangeHandler,
|
|
290
|
+
onUndoManagerStatusChange: onUndoManagerStatusChangeHandler,
|
|
291
|
+
onActiveActionChange: onActiveActionChangeHandler
|
|
292
|
+
},
|
|
293
|
+
logger: { level: "info" }
|
|
294
|
+
}, {
|
|
295
|
+
container: containerId,
|
|
296
|
+
width: weaveEleClientRect?.width ?? 1920,
|
|
297
|
+
height: weaveEleClientRect?.height ?? 1080
|
|
298
|
+
});
|
|
299
|
+
setInstance(weaveInstanceRef.current);
|
|
300
|
+
weaveInstanceRef.current.start();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
initWeave();
|
|
304
|
+
}, []);
|
|
305
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
866
306
|
};
|
|
307
|
+
|
|
308
|
+
//#endregion
|
|
309
|
+
export { WeaveProvider, useWeave };
|