@yorkie-js/react 0.6.1-rc6 → 0.6.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.
@@ -2,2165 +2,8 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
5
- var react = { exports: {} };
6
- var react_production_min = {};
7
- /**
8
- * @license React
9
- * react.production.min.js
10
- *
11
- * Copyright (c) Facebook, Inc. and its affiliates.
12
- *
13
- * This source code is licensed under the MIT license found in the
14
- * LICENSE file in the root directory of this source tree.
15
- */
16
- var hasRequiredReact_production_min;
17
- function requireReact_production_min() {
18
- if (hasRequiredReact_production_min) return react_production_min;
19
- hasRequiredReact_production_min = 1;
20
- var l = Symbol.for("react.element"), n = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), q = Symbol.for("react.strict_mode"), r = Symbol.for("react.profiler"), t = Symbol.for("react.provider"), u = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), x = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), z = Symbol.iterator;
21
- function A(a) {
22
- if (null === a || "object" !== typeof a) return null;
23
- a = z && a[z] || a["@@iterator"];
24
- return "function" === typeof a ? a : null;
25
- }
26
- var B = { isMounted: function() {
27
- return false;
28
- }, enqueueForceUpdate: function() {
29
- }, enqueueReplaceState: function() {
30
- }, enqueueSetState: function() {
31
- } }, C = Object.assign, D = {};
32
- function E(a, b, e) {
33
- this.props = a;
34
- this.context = b;
35
- this.refs = D;
36
- this.updater = e || B;
37
- }
38
- E.prototype.isReactComponent = {};
39
- E.prototype.setState = function(a, b) {
40
- if ("object" !== typeof a && "function" !== typeof a && null != a) throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
41
- this.updater.enqueueSetState(this, a, b, "setState");
42
- };
43
- E.prototype.forceUpdate = function(a) {
44
- this.updater.enqueueForceUpdate(this, a, "forceUpdate");
45
- };
46
- function F() {
47
- }
48
- F.prototype = E.prototype;
49
- function G(a, b, e) {
50
- this.props = a;
51
- this.context = b;
52
- this.refs = D;
53
- this.updater = e || B;
54
- }
55
- var H = G.prototype = new F();
56
- H.constructor = G;
57
- C(H, E.prototype);
58
- H.isPureReactComponent = true;
59
- var I = Array.isArray, J = Object.prototype.hasOwnProperty, K = { current: null }, L = { key: true, ref: true, __self: true, __source: true };
60
- function M(a, b, e) {
61
- var d, c = {}, k = null, h = null;
62
- if (null != b) for (d in void 0 !== b.ref && (h = b.ref), void 0 !== b.key && (k = "" + b.key), b) J.call(b, d) && !L.hasOwnProperty(d) && (c[d] = b[d]);
63
- var g = arguments.length - 2;
64
- if (1 === g) c.children = e;
65
- else if (1 < g) {
66
- for (var f = Array(g), m = 0; m < g; m++) f[m] = arguments[m + 2];
67
- c.children = f;
68
- }
69
- if (a && a.defaultProps) for (d in g = a.defaultProps, g) void 0 === c[d] && (c[d] = g[d]);
70
- return { $$typeof: l, type: a, key: k, ref: h, props: c, _owner: K.current };
71
- }
72
- function N(a, b) {
73
- return { $$typeof: l, type: a.type, key: b, ref: a.ref, props: a.props, _owner: a._owner };
74
- }
75
- function O(a) {
76
- return "object" === typeof a && null !== a && a.$$typeof === l;
77
- }
78
- function escape(a) {
79
- var b = { "=": "=0", ":": "=2" };
80
- return "$" + a.replace(/[=:]/g, function(a2) {
81
- return b[a2];
82
- });
83
- }
84
- var P = /\/+/g;
85
- function Q(a, b) {
86
- return "object" === typeof a && null !== a && null != a.key ? escape("" + a.key) : b.toString(36);
87
- }
88
- function R(a, b, e, d, c) {
89
- var k = typeof a;
90
- if ("undefined" === k || "boolean" === k) a = null;
91
- var h = false;
92
- if (null === a) h = true;
93
- else switch (k) {
94
- case "string":
95
- case "number":
96
- h = true;
97
- break;
98
- case "object":
99
- switch (a.$$typeof) {
100
- case l:
101
- case n:
102
- h = true;
103
- }
104
- }
105
- if (h) return h = a, c = c(h), a = "" === d ? "." + Q(h, 0) : d, I(c) ? (e = "", null != a && (e = a.replace(P, "$&/") + "/"), R(c, b, e, "", function(a2) {
106
- return a2;
107
- })) : null != c && (O(c) && (c = N(c, e + (!c.key || h && h.key === c.key ? "" : ("" + c.key).replace(P, "$&/") + "/") + a)), b.push(c)), 1;
108
- h = 0;
109
- d = "" === d ? "." : d + ":";
110
- if (I(a)) for (var g = 0; g < a.length; g++) {
111
- k = a[g];
112
- var f = d + Q(k, g);
113
- h += R(k, b, e, f, c);
114
- }
115
- else if (f = A(a), "function" === typeof f) for (a = f.call(a), g = 0; !(k = a.next()).done; ) k = k.value, f = d + Q(k, g++), h += R(k, b, e, f, c);
116
- else if ("object" === k) throw b = String(a), Error("Objects are not valid as a React child (found: " + ("[object Object]" === b ? "object with keys {" + Object.keys(a).join(", ") + "}" : b) + "). If you meant to render a collection of children, use an array instead.");
117
- return h;
118
- }
119
- function S(a, b, e) {
120
- if (null == a) return a;
121
- var d = [], c = 0;
122
- R(a, d, "", "", function(a2) {
123
- return b.call(e, a2, c++);
124
- });
125
- return d;
126
- }
127
- function T(a) {
128
- if (-1 === a._status) {
129
- var b = a._result;
130
- b = b();
131
- b.then(function(b2) {
132
- if (0 === a._status || -1 === a._status) a._status = 1, a._result = b2;
133
- }, function(b2) {
134
- if (0 === a._status || -1 === a._status) a._status = 2, a._result = b2;
135
- });
136
- -1 === a._status && (a._status = 0, a._result = b);
137
- }
138
- if (1 === a._status) return a._result.default;
139
- throw a._result;
140
- }
141
- var U = { current: null }, V = { transition: null }, W = { ReactCurrentDispatcher: U, ReactCurrentBatchConfig: V, ReactCurrentOwner: K };
142
- react_production_min.Children = { map: S, forEach: function(a, b, e) {
143
- S(a, function() {
144
- b.apply(this, arguments);
145
- }, e);
146
- }, count: function(a) {
147
- var b = 0;
148
- S(a, function() {
149
- b++;
150
- });
151
- return b;
152
- }, toArray: function(a) {
153
- return S(a, function(a2) {
154
- return a2;
155
- }) || [];
156
- }, only: function(a) {
157
- if (!O(a)) throw Error("React.Children.only expected to receive a single React element child.");
158
- return a;
159
- } };
160
- react_production_min.Component = E;
161
- react_production_min.Fragment = p;
162
- react_production_min.Profiler = r;
163
- react_production_min.PureComponent = G;
164
- react_production_min.StrictMode = q;
165
- react_production_min.Suspense = w;
166
- react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = W;
167
- react_production_min.cloneElement = function(a, b, e) {
168
- if (null === a || void 0 === a) throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + a + ".");
169
- var d = C({}, a.props), c = a.key, k = a.ref, h = a._owner;
170
- if (null != b) {
171
- void 0 !== b.ref && (k = b.ref, h = K.current);
172
- void 0 !== b.key && (c = "" + b.key);
173
- if (a.type && a.type.defaultProps) var g = a.type.defaultProps;
174
- for (f in b) J.call(b, f) && !L.hasOwnProperty(f) && (d[f] = void 0 === b[f] && void 0 !== g ? g[f] : b[f]);
175
- }
176
- var f = arguments.length - 2;
177
- if (1 === f) d.children = e;
178
- else if (1 < f) {
179
- g = Array(f);
180
- for (var m = 0; m < f; m++) g[m] = arguments[m + 2];
181
- d.children = g;
182
- }
183
- return { $$typeof: l, type: a.type, key: c, ref: k, props: d, _owner: h };
184
- };
185
- react_production_min.createContext = function(a) {
186
- a = { $$typeof: u, _currentValue: a, _currentValue2: a, _threadCount: 0, Provider: null, Consumer: null, _defaultValue: null, _globalName: null };
187
- a.Provider = { $$typeof: t, _context: a };
188
- return a.Consumer = a;
189
- };
190
- react_production_min.createElement = M;
191
- react_production_min.createFactory = function(a) {
192
- var b = M.bind(null, a);
193
- b.type = a;
194
- return b;
195
- };
196
- react_production_min.createRef = function() {
197
- return { current: null };
198
- };
199
- react_production_min.forwardRef = function(a) {
200
- return { $$typeof: v, render: a };
201
- };
202
- react_production_min.isValidElement = O;
203
- react_production_min.lazy = function(a) {
204
- return { $$typeof: y, _payload: { _status: -1, _result: a }, _init: T };
205
- };
206
- react_production_min.memo = function(a, b) {
207
- return { $$typeof: x, type: a, compare: void 0 === b ? null : b };
208
- };
209
- react_production_min.startTransition = function(a) {
210
- var b = V.transition;
211
- V.transition = {};
212
- try {
213
- a();
214
- } finally {
215
- V.transition = b;
216
- }
217
- };
218
- react_production_min.unstable_act = function() {
219
- throw Error("act(...) is not supported in production builds of React.");
220
- };
221
- react_production_min.useCallback = function(a, b) {
222
- return U.current.useCallback(a, b);
223
- };
224
- react_production_min.useContext = function(a) {
225
- return U.current.useContext(a);
226
- };
227
- react_production_min.useDebugValue = function() {
228
- };
229
- react_production_min.useDeferredValue = function(a) {
230
- return U.current.useDeferredValue(a);
231
- };
232
- react_production_min.useEffect = function(a, b) {
233
- return U.current.useEffect(a, b);
234
- };
235
- react_production_min.useId = function() {
236
- return U.current.useId();
237
- };
238
- react_production_min.useImperativeHandle = function(a, b, e) {
239
- return U.current.useImperativeHandle(a, b, e);
240
- };
241
- react_production_min.useInsertionEffect = function(a, b) {
242
- return U.current.useInsertionEffect(a, b);
243
- };
244
- react_production_min.useLayoutEffect = function(a, b) {
245
- return U.current.useLayoutEffect(a, b);
246
- };
247
- react_production_min.useMemo = function(a, b) {
248
- return U.current.useMemo(a, b);
249
- };
250
- react_production_min.useReducer = function(a, b, e) {
251
- return U.current.useReducer(a, b, e);
252
- };
253
- react_production_min.useRef = function(a) {
254
- return U.current.useRef(a);
255
- };
256
- react_production_min.useState = function(a) {
257
- return U.current.useState(a);
258
- };
259
- react_production_min.useSyncExternalStore = function(a, b, e) {
260
- return U.current.useSyncExternalStore(a, b, e);
261
- };
262
- react_production_min.useTransition = function() {
263
- return U.current.useTransition();
264
- };
265
- react_production_min.version = "18.2.0";
266
- return react_production_min;
267
- }
268
- var react_development = { exports: {} };
269
- /**
270
- * @license React
271
- * react.development.js
272
- *
273
- * Copyright (c) Facebook, Inc. and its affiliates.
274
- *
275
- * This source code is licensed under the MIT license found in the
276
- * LICENSE file in the root directory of this source tree.
277
- */
278
- react_development.exports;
279
- var hasRequiredReact_development;
280
- function requireReact_development() {
281
- if (hasRequiredReact_development) return react_development.exports;
282
- hasRequiredReact_development = 1;
283
- (function(module, exports) {
284
- if (process.env.NODE_ENV !== "production") {
285
- (function() {
286
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
287
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
288
- }
289
- var ReactVersion = "18.2.0";
290
- var REACT_ELEMENT_TYPE = Symbol.for("react.element");
291
- var REACT_PORTAL_TYPE = Symbol.for("react.portal");
292
- var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
293
- var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
294
- var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
295
- var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
296
- var REACT_CONTEXT_TYPE = Symbol.for("react.context");
297
- var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
298
- var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
299
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
300
- var REACT_MEMO_TYPE = Symbol.for("react.memo");
301
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
302
- var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
303
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
304
- var FAUX_ITERATOR_SYMBOL = "@@iterator";
305
- function getIteratorFn(maybeIterable) {
306
- if (maybeIterable === null || typeof maybeIterable !== "object") {
307
- return null;
308
- }
309
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
310
- if (typeof maybeIterator === "function") {
311
- return maybeIterator;
312
- }
313
- return null;
314
- }
315
- var ReactCurrentDispatcher = {
316
- /**
317
- * @internal
318
- * @type {ReactComponent}
319
- */
320
- current: null
321
- };
322
- var ReactCurrentBatchConfig = {
323
- transition: null
324
- };
325
- var ReactCurrentActQueue = {
326
- current: null,
327
- // Used to reproduce behavior of `batchedUpdates` in legacy mode.
328
- isBatchingLegacy: false,
329
- didScheduleLegacyUpdate: false
330
- };
331
- var ReactCurrentOwner = {
332
- /**
333
- * @internal
334
- * @type {ReactComponent}
335
- */
336
- current: null
337
- };
338
- var ReactDebugCurrentFrame = {};
339
- var currentExtraStackFrame = null;
340
- function setExtraStackFrame(stack) {
341
- {
342
- currentExtraStackFrame = stack;
343
- }
344
- }
345
- {
346
- ReactDebugCurrentFrame.setExtraStackFrame = function(stack) {
347
- {
348
- currentExtraStackFrame = stack;
349
- }
350
- };
351
- ReactDebugCurrentFrame.getCurrentStack = null;
352
- ReactDebugCurrentFrame.getStackAddendum = function() {
353
- var stack = "";
354
- if (currentExtraStackFrame) {
355
- stack += currentExtraStackFrame;
356
- }
357
- var impl = ReactDebugCurrentFrame.getCurrentStack;
358
- if (impl) {
359
- stack += impl() || "";
360
- }
361
- return stack;
362
- };
363
- }
364
- var enableScopeAPI = false;
365
- var enableCacheElement = false;
366
- var enableTransitionTracing = false;
367
- var enableLegacyHidden = false;
368
- var enableDebugTracing = false;
369
- var ReactSharedInternals = {
370
- ReactCurrentDispatcher,
371
- ReactCurrentBatchConfig,
372
- ReactCurrentOwner
373
- };
374
- {
375
- ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
376
- ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;
377
- }
378
- function warn(format) {
379
- {
380
- {
381
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
382
- args[_key - 1] = arguments[_key];
383
- }
384
- printWarning("warn", format, args);
385
- }
386
- }
387
- }
388
- function error(format) {
389
- {
390
- {
391
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
392
- args[_key2 - 1] = arguments[_key2];
393
- }
394
- printWarning("error", format, args);
395
- }
396
- }
397
- }
398
- function printWarning(level2, format, args) {
399
- {
400
- var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
401
- var stack = ReactDebugCurrentFrame2.getStackAddendum();
402
- if (stack !== "") {
403
- format += "%s";
404
- args = args.concat([stack]);
405
- }
406
- var argsWithFormat = args.map(function(item) {
407
- return String(item);
408
- });
409
- argsWithFormat.unshift("Warning: " + format);
410
- Function.prototype.apply.call(console[level2], console, argsWithFormat);
411
- }
412
- }
413
- var didWarnStateUpdateForUnmountedComponent = {};
414
- function warnNoop(publicInstance, callerName) {
415
- {
416
- var _constructor = publicInstance.constructor;
417
- var componentName = _constructor && (_constructor.displayName || _constructor.name) || "ReactClass";
418
- var warningKey = componentName + "." + callerName;
419
- if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
420
- return;
421
- }
422
- error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", callerName, componentName);
423
- didWarnStateUpdateForUnmountedComponent[warningKey] = true;
424
- }
425
- }
426
- var ReactNoopUpdateQueue = {
427
- /**
428
- * Checks whether or not this composite component is mounted.
429
- * @param {ReactClass} publicInstance The instance we want to test.
430
- * @return {boolean} True if mounted, false otherwise.
431
- * @protected
432
- * @final
433
- */
434
- isMounted: function(publicInstance) {
435
- return false;
436
- },
437
- /**
438
- * Forces an update. This should only be invoked when it is known with
439
- * certainty that we are **not** in a DOM transaction.
440
- *
441
- * You may want to call this when you know that some deeper aspect of the
442
- * component's state has changed but `setState` was not called.
443
- *
444
- * This will not invoke `shouldComponentUpdate`, but it will invoke
445
- * `componentWillUpdate` and `componentDidUpdate`.
446
- *
447
- * @param {ReactClass} publicInstance The instance that should rerender.
448
- * @param {?function} callback Called after component is updated.
449
- * @param {?string} callerName name of the calling function in the public API.
450
- * @internal
451
- */
452
- enqueueForceUpdate: function(publicInstance, callback, callerName) {
453
- warnNoop(publicInstance, "forceUpdate");
454
- },
455
- /**
456
- * Replaces all of the state. Always use this or `setState` to mutate state.
457
- * You should treat `this.state` as immutable.
458
- *
459
- * There is no guarantee that `this.state` will be immediately updated, so
460
- * accessing `this.state` after calling this method may return the old value.
461
- *
462
- * @param {ReactClass} publicInstance The instance that should rerender.
463
- * @param {object} completeState Next state.
464
- * @param {?function} callback Called after component is updated.
465
- * @param {?string} callerName name of the calling function in the public API.
466
- * @internal
467
- */
468
- enqueueReplaceState: function(publicInstance, completeState, callback, callerName) {
469
- warnNoop(publicInstance, "replaceState");
470
- },
471
- /**
472
- * Sets a subset of the state. This only exists because _pendingState is
473
- * internal. This provides a merging strategy that is not available to deep
474
- * properties which is confusing. TODO: Expose pendingState or don't use it
475
- * during the merge.
476
- *
477
- * @param {ReactClass} publicInstance The instance that should rerender.
478
- * @param {object} partialState Next partial state to be merged with state.
479
- * @param {?function} callback Called after component is updated.
480
- * @param {?string} Name of the calling function in the public API.
481
- * @internal
482
- */
483
- enqueueSetState: function(publicInstance, partialState, callback, callerName) {
484
- warnNoop(publicInstance, "setState");
485
- }
486
- };
487
- var assign = Object.assign;
488
- var emptyObject = {};
489
- {
490
- Object.freeze(emptyObject);
491
- }
492
- function Component(props, context, updater) {
493
- this.props = props;
494
- this.context = context;
495
- this.refs = emptyObject;
496
- this.updater = updater || ReactNoopUpdateQueue;
497
- }
498
- Component.prototype.isReactComponent = {};
499
- Component.prototype.setState = function(partialState, callback) {
500
- if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null) {
501
- throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
502
- }
503
- this.updater.enqueueSetState(this, partialState, callback, "setState");
504
- };
505
- Component.prototype.forceUpdate = function(callback) {
506
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
507
- };
508
- {
509
- var deprecatedAPIs = {
510
- isMounted: ["isMounted", "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],
511
- replaceState: ["replaceState", "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]
512
- };
513
- var defineDeprecationWarning = function(methodName, info) {
514
- Object.defineProperty(Component.prototype, methodName, {
515
- get: function() {
516
- warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
517
- return void 0;
518
- }
519
- });
520
- };
521
- for (var fnName in deprecatedAPIs) {
522
- if (deprecatedAPIs.hasOwnProperty(fnName)) {
523
- defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
524
- }
525
- }
526
- }
527
- function ComponentDummy() {
528
- }
529
- ComponentDummy.prototype = Component.prototype;
530
- function PureComponent(props, context, updater) {
531
- this.props = props;
532
- this.context = context;
533
- this.refs = emptyObject;
534
- this.updater = updater || ReactNoopUpdateQueue;
535
- }
536
- var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
537
- pureComponentPrototype.constructor = PureComponent;
538
- assign(pureComponentPrototype, Component.prototype);
539
- pureComponentPrototype.isPureReactComponent = true;
540
- function createRef() {
541
- var refObject = {
542
- current: null
543
- };
544
- {
545
- Object.seal(refObject);
546
- }
547
- return refObject;
548
- }
549
- var isArrayImpl = Array.isArray;
550
- function isArray(a) {
551
- return isArrayImpl(a);
552
- }
553
- function typeName(value) {
554
- {
555
- var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
556
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
557
- return type;
558
- }
559
- }
560
- function willCoercionThrow(value) {
561
- {
562
- try {
563
- testStringCoercion(value);
564
- return false;
565
- } catch (e) {
566
- return true;
567
- }
568
- }
569
- }
570
- function testStringCoercion(value) {
571
- return "" + value;
572
- }
573
- function checkKeyStringCoercion(value) {
574
- {
575
- if (willCoercionThrow(value)) {
576
- error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
577
- return testStringCoercion(value);
578
- }
579
- }
580
- }
581
- function getWrappedName(outerType, innerType, wrapperName) {
582
- var displayName = outerType.displayName;
583
- if (displayName) {
584
- return displayName;
585
- }
586
- var functionName = innerType.displayName || innerType.name || "";
587
- return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
588
- }
589
- function getContextName(type) {
590
- return type.displayName || "Context";
591
- }
592
- function getComponentNameFromType(type) {
593
- if (type == null) {
594
- return null;
595
- }
596
- {
597
- if (typeof type.tag === "number") {
598
- error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
599
- }
600
- }
601
- if (typeof type === "function") {
602
- return type.displayName || type.name || null;
603
- }
604
- if (typeof type === "string") {
605
- return type;
606
- }
607
- switch (type) {
608
- case REACT_FRAGMENT_TYPE:
609
- return "Fragment";
610
- case REACT_PORTAL_TYPE:
611
- return "Portal";
612
- case REACT_PROFILER_TYPE:
613
- return "Profiler";
614
- case REACT_STRICT_MODE_TYPE:
615
- return "StrictMode";
616
- case REACT_SUSPENSE_TYPE:
617
- return "Suspense";
618
- case REACT_SUSPENSE_LIST_TYPE:
619
- return "SuspenseList";
620
- }
621
- if (typeof type === "object") {
622
- switch (type.$$typeof) {
623
- case REACT_CONTEXT_TYPE:
624
- var context = type;
625
- return getContextName(context) + ".Consumer";
626
- case REACT_PROVIDER_TYPE:
627
- var provider = type;
628
- return getContextName(provider._context) + ".Provider";
629
- case REACT_FORWARD_REF_TYPE:
630
- return getWrappedName(type, type.render, "ForwardRef");
631
- case REACT_MEMO_TYPE:
632
- var outerName = type.displayName || null;
633
- if (outerName !== null) {
634
- return outerName;
635
- }
636
- return getComponentNameFromType(type.type) || "Memo";
637
- case REACT_LAZY_TYPE: {
638
- var lazyComponent = type;
639
- var payload = lazyComponent._payload;
640
- var init = lazyComponent._init;
641
- try {
642
- return getComponentNameFromType(init(payload));
643
- } catch (x) {
644
- return null;
645
- }
646
- }
647
- }
648
- }
649
- return null;
650
- }
651
- var hasOwnProperty = Object.prototype.hasOwnProperty;
652
- var RESERVED_PROPS = {
653
- key: true,
654
- ref: true,
655
- __self: true,
656
- __source: true
657
- };
658
- var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
659
- {
660
- didWarnAboutStringRefs = {};
661
- }
662
- function hasValidRef(config) {
663
- {
664
- if (hasOwnProperty.call(config, "ref")) {
665
- var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
666
- if (getter && getter.isReactWarning) {
667
- return false;
668
- }
669
- }
670
- }
671
- return config.ref !== void 0;
672
- }
673
- function hasValidKey(config) {
674
- {
675
- if (hasOwnProperty.call(config, "key")) {
676
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
677
- if (getter && getter.isReactWarning) {
678
- return false;
679
- }
680
- }
681
- }
682
- return config.key !== void 0;
683
- }
684
- function defineKeyPropWarningGetter(props, displayName) {
685
- var warnAboutAccessingKey = function() {
686
- {
687
- if (!specialPropKeyWarningShown) {
688
- specialPropKeyWarningShown = true;
689
- error("%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)", displayName);
690
- }
691
- }
692
- };
693
- warnAboutAccessingKey.isReactWarning = true;
694
- Object.defineProperty(props, "key", {
695
- get: warnAboutAccessingKey,
696
- configurable: true
697
- });
698
- }
699
- function defineRefPropWarningGetter(props, displayName) {
700
- var warnAboutAccessingRef = function() {
701
- {
702
- if (!specialPropRefWarningShown) {
703
- specialPropRefWarningShown = true;
704
- error("%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)", displayName);
705
- }
706
- }
707
- };
708
- warnAboutAccessingRef.isReactWarning = true;
709
- Object.defineProperty(props, "ref", {
710
- get: warnAboutAccessingRef,
711
- configurable: true
712
- });
713
- }
714
- function warnIfStringRefCannotBeAutoConverted(config) {
715
- {
716
- if (typeof config.ref === "string" && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
717
- var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
718
- if (!didWarnAboutStringRefs[componentName]) {
719
- error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);
720
- didWarnAboutStringRefs[componentName] = true;
721
- }
722
- }
723
- }
724
- }
725
- var ReactElement = function(type, key, ref, self, source, owner, props) {
726
- var element = {
727
- // This tag allows us to uniquely identify this as a React Element
728
- $$typeof: REACT_ELEMENT_TYPE,
729
- // Built-in properties that belong on the element
730
- type,
731
- key,
732
- ref,
733
- props,
734
- // Record the component responsible for creating this element.
735
- _owner: owner
736
- };
737
- {
738
- element._store = {};
739
- Object.defineProperty(element._store, "validated", {
740
- configurable: false,
741
- enumerable: false,
742
- writable: true,
743
- value: false
744
- });
745
- Object.defineProperty(element, "_self", {
746
- configurable: false,
747
- enumerable: false,
748
- writable: false,
749
- value: self
750
- });
751
- Object.defineProperty(element, "_source", {
752
- configurable: false,
753
- enumerable: false,
754
- writable: false,
755
- value: source
756
- });
757
- if (Object.freeze) {
758
- Object.freeze(element.props);
759
- Object.freeze(element);
760
- }
761
- }
762
- return element;
763
- };
764
- function createElement(type, config, children) {
765
- var propName;
766
- var props = {};
767
- var key = null;
768
- var ref = null;
769
- var self = null;
770
- var source = null;
771
- if (config != null) {
772
- if (hasValidRef(config)) {
773
- ref = config.ref;
774
- {
775
- warnIfStringRefCannotBeAutoConverted(config);
776
- }
777
- }
778
- if (hasValidKey(config)) {
779
- {
780
- checkKeyStringCoercion(config.key);
781
- }
782
- key = "" + config.key;
783
- }
784
- self = config.__self === void 0 ? null : config.__self;
785
- source = config.__source === void 0 ? null : config.__source;
786
- for (propName in config) {
787
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
788
- props[propName] = config[propName];
789
- }
790
- }
791
- }
792
- var childrenLength = arguments.length - 2;
793
- if (childrenLength === 1) {
794
- props.children = children;
795
- } else if (childrenLength > 1) {
796
- var childArray = Array(childrenLength);
797
- for (var i = 0; i < childrenLength; i++) {
798
- childArray[i] = arguments[i + 2];
799
- }
800
- {
801
- if (Object.freeze) {
802
- Object.freeze(childArray);
803
- }
804
- }
805
- props.children = childArray;
806
- }
807
- if (type && type.defaultProps) {
808
- var defaultProps = type.defaultProps;
809
- for (propName in defaultProps) {
810
- if (props[propName] === void 0) {
811
- props[propName] = defaultProps[propName];
812
- }
813
- }
814
- }
815
- {
816
- if (key || ref) {
817
- var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
818
- if (key) {
819
- defineKeyPropWarningGetter(props, displayName);
820
- }
821
- if (ref) {
822
- defineRefPropWarningGetter(props, displayName);
823
- }
824
- }
825
- }
826
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
827
- }
828
- function cloneAndReplaceKey(oldElement, newKey) {
829
- var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
830
- return newElement;
831
- }
832
- function cloneElement(element, config, children) {
833
- if (element === null || element === void 0) {
834
- throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
835
- }
836
- var propName;
837
- var props = assign({}, element.props);
838
- var key = element.key;
839
- var ref = element.ref;
840
- var self = element._self;
841
- var source = element._source;
842
- var owner = element._owner;
843
- if (config != null) {
844
- if (hasValidRef(config)) {
845
- ref = config.ref;
846
- owner = ReactCurrentOwner.current;
847
- }
848
- if (hasValidKey(config)) {
849
- {
850
- checkKeyStringCoercion(config.key);
851
- }
852
- key = "" + config.key;
853
- }
854
- var defaultProps;
855
- if (element.type && element.type.defaultProps) {
856
- defaultProps = element.type.defaultProps;
857
- }
858
- for (propName in config) {
859
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
860
- if (config[propName] === void 0 && defaultProps !== void 0) {
861
- props[propName] = defaultProps[propName];
862
- } else {
863
- props[propName] = config[propName];
864
- }
865
- }
866
- }
867
- }
868
- var childrenLength = arguments.length - 2;
869
- if (childrenLength === 1) {
870
- props.children = children;
871
- } else if (childrenLength > 1) {
872
- var childArray = Array(childrenLength);
873
- for (var i = 0; i < childrenLength; i++) {
874
- childArray[i] = arguments[i + 2];
875
- }
876
- props.children = childArray;
877
- }
878
- return ReactElement(element.type, key, ref, self, source, owner, props);
879
- }
880
- function isValidElement(object) {
881
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
882
- }
883
- var SEPARATOR = ".";
884
- var SUBSEPARATOR = ":";
885
- function escape(key) {
886
- var escapeRegex = /[=:]/g;
887
- var escaperLookup = {
888
- "=": "=0",
889
- ":": "=2"
890
- };
891
- var escapedString = key.replace(escapeRegex, function(match) {
892
- return escaperLookup[match];
893
- });
894
- return "$" + escapedString;
895
- }
896
- var didWarnAboutMaps = false;
897
- var userProvidedKeyEscapeRegex = /\/+/g;
898
- function escapeUserProvidedKey(text) {
899
- return text.replace(userProvidedKeyEscapeRegex, "$&/");
900
- }
901
- function getElementKey(element, index) {
902
- if (typeof element === "object" && element !== null && element.key != null) {
903
- {
904
- checkKeyStringCoercion(element.key);
905
- }
906
- return escape("" + element.key);
907
- }
908
- return index.toString(36);
909
- }
910
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
911
- var type = typeof children;
912
- if (type === "undefined" || type === "boolean") {
913
- children = null;
914
- }
915
- var invokeCallback = false;
916
- if (children === null) {
917
- invokeCallback = true;
918
- } else {
919
- switch (type) {
920
- case "string":
921
- case "number":
922
- invokeCallback = true;
923
- break;
924
- case "object":
925
- switch (children.$$typeof) {
926
- case REACT_ELEMENT_TYPE:
927
- case REACT_PORTAL_TYPE:
928
- invokeCallback = true;
929
- }
930
- }
931
- }
932
- if (invokeCallback) {
933
- var _child = children;
934
- var mappedChild = callback(_child);
935
- var childKey = nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
936
- if (isArray(mappedChild)) {
937
- var escapedChildKey = "";
938
- if (childKey != null) {
939
- escapedChildKey = escapeUserProvidedKey(childKey) + "/";
940
- }
941
- mapIntoArray(mappedChild, array, escapedChildKey, "", function(c) {
942
- return c;
943
- });
944
- } else if (mappedChild != null) {
945
- if (isValidElement(mappedChild)) {
946
- {
947
- if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
948
- checkKeyStringCoercion(mappedChild.key);
949
- }
950
- }
951
- mappedChild = cloneAndReplaceKey(
952
- mappedChild,
953
- // Keep both the (mapped) and old keys if they differ, just as
954
- // traverseAllChildren used to do for objects as children
955
- escapedPrefix + // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
956
- (mappedChild.key && (!_child || _child.key !== mappedChild.key) ? (
957
- // $FlowFixMe Flow incorrectly thinks existing element's key can be a number
958
- // eslint-disable-next-line react-internal/safe-string-coercion
959
- escapeUserProvidedKey("" + mappedChild.key) + "/"
960
- ) : "") + childKey
961
- );
962
- }
963
- array.push(mappedChild);
964
- }
965
- return 1;
966
- }
967
- var child;
968
- var nextName;
969
- var subtreeCount = 0;
970
- var nextNamePrefix = nameSoFar === "" ? SEPARATOR : nameSoFar + SUBSEPARATOR;
971
- if (isArray(children)) {
972
- for (var i = 0; i < children.length; i++) {
973
- child = children[i];
974
- nextName = nextNamePrefix + getElementKey(child, i);
975
- subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
976
- }
977
- } else {
978
- var iteratorFn = getIteratorFn(children);
979
- if (typeof iteratorFn === "function") {
980
- var iterableChildren = children;
981
- {
982
- if (iteratorFn === iterableChildren.entries) {
983
- if (!didWarnAboutMaps) {
984
- warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead.");
985
- }
986
- didWarnAboutMaps = true;
987
- }
988
- }
989
- var iterator = iteratorFn.call(iterableChildren);
990
- var step;
991
- var ii = 0;
992
- while (!(step = iterator.next()).done) {
993
- child = step.value;
994
- nextName = nextNamePrefix + getElementKey(child, ii++);
995
- subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
996
- }
997
- } else if (type === "object") {
998
- var childrenString = String(children);
999
- throw new Error("Objects are not valid as a React child (found: " + (childrenString === "[object Object]" ? "object with keys {" + Object.keys(children).join(", ") + "}" : childrenString) + "). If you meant to render a collection of children, use an array instead.");
1000
- }
1001
- }
1002
- return subtreeCount;
1003
- }
1004
- function mapChildren(children, func, context) {
1005
- if (children == null) {
1006
- return children;
1007
- }
1008
- var result = [];
1009
- var count = 0;
1010
- mapIntoArray(children, result, "", "", function(child) {
1011
- return func.call(context, child, count++);
1012
- });
1013
- return result;
1014
- }
1015
- function countChildren(children) {
1016
- var n = 0;
1017
- mapChildren(children, function() {
1018
- n++;
1019
- });
1020
- return n;
1021
- }
1022
- function forEachChildren(children, forEachFunc, forEachContext) {
1023
- mapChildren(children, function() {
1024
- forEachFunc.apply(this, arguments);
1025
- }, forEachContext);
1026
- }
1027
- function toArray2(children) {
1028
- return mapChildren(children, function(child) {
1029
- return child;
1030
- }) || [];
1031
- }
1032
- function onlyChild(children) {
1033
- if (!isValidElement(children)) {
1034
- throw new Error("React.Children.only expected to receive a single React element child.");
1035
- }
1036
- return children;
1037
- }
1038
- function createContext(defaultValue) {
1039
- var context = {
1040
- $$typeof: REACT_CONTEXT_TYPE,
1041
- // As a workaround to support multiple concurrent renderers, we categorize
1042
- // some renderers as primary and others as secondary. We only expect
1043
- // there to be two concurrent renderers at most: React Native (primary) and
1044
- // Fabric (secondary); React DOM (primary) and React ART (secondary).
1045
- // Secondary renderers store their context values on separate fields.
1046
- _currentValue: defaultValue,
1047
- _currentValue2: defaultValue,
1048
- // Used to track how many concurrent renderers this context currently
1049
- // supports within in a single renderer. Such as parallel server rendering.
1050
- _threadCount: 0,
1051
- // These are circular
1052
- Provider: null,
1053
- Consumer: null,
1054
- // Add these to use same hidden class in VM as ServerContext
1055
- _defaultValue: null,
1056
- _globalName: null
1057
- };
1058
- context.Provider = {
1059
- $$typeof: REACT_PROVIDER_TYPE,
1060
- _context: context
1061
- };
1062
- var hasWarnedAboutUsingNestedContextConsumers = false;
1063
- var hasWarnedAboutUsingConsumerProvider = false;
1064
- var hasWarnedAboutDisplayNameOnConsumer = false;
1065
- {
1066
- var Consumer = {
1067
- $$typeof: REACT_CONTEXT_TYPE,
1068
- _context: context
1069
- };
1070
- Object.defineProperties(Consumer, {
1071
- Provider: {
1072
- get: function() {
1073
- if (!hasWarnedAboutUsingConsumerProvider) {
1074
- hasWarnedAboutUsingConsumerProvider = true;
1075
- error("Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?");
1076
- }
1077
- return context.Provider;
1078
- },
1079
- set: function(_Provider) {
1080
- context.Provider = _Provider;
1081
- }
1082
- },
1083
- _currentValue: {
1084
- get: function() {
1085
- return context._currentValue;
1086
- },
1087
- set: function(_currentValue) {
1088
- context._currentValue = _currentValue;
1089
- }
1090
- },
1091
- _currentValue2: {
1092
- get: function() {
1093
- return context._currentValue2;
1094
- },
1095
- set: function(_currentValue2) {
1096
- context._currentValue2 = _currentValue2;
1097
- }
1098
- },
1099
- _threadCount: {
1100
- get: function() {
1101
- return context._threadCount;
1102
- },
1103
- set: function(_threadCount) {
1104
- context._threadCount = _threadCount;
1105
- }
1106
- },
1107
- Consumer: {
1108
- get: function() {
1109
- if (!hasWarnedAboutUsingNestedContextConsumers) {
1110
- hasWarnedAboutUsingNestedContextConsumers = true;
1111
- error("Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
1112
- }
1113
- return context.Consumer;
1114
- }
1115
- },
1116
- displayName: {
1117
- get: function() {
1118
- return context.displayName;
1119
- },
1120
- set: function(displayName) {
1121
- if (!hasWarnedAboutDisplayNameOnConsumer) {
1122
- warn("Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.", displayName);
1123
- hasWarnedAboutDisplayNameOnConsumer = true;
1124
- }
1125
- }
1126
- }
1127
- });
1128
- context.Consumer = Consumer;
1129
- }
1130
- {
1131
- context._currentRenderer = null;
1132
- context._currentRenderer2 = null;
1133
- }
1134
- return context;
1135
- }
1136
- var Uninitialized = -1;
1137
- var Pending = 0;
1138
- var Resolved = 1;
1139
- var Rejected = 2;
1140
- function lazyInitializer(payload) {
1141
- if (payload._status === Uninitialized) {
1142
- var ctor = payload._result;
1143
- var thenable = ctor();
1144
- thenable.then(function(moduleObject2) {
1145
- if (payload._status === Pending || payload._status === Uninitialized) {
1146
- var resolved = payload;
1147
- resolved._status = Resolved;
1148
- resolved._result = moduleObject2;
1149
- }
1150
- }, function(error2) {
1151
- if (payload._status === Pending || payload._status === Uninitialized) {
1152
- var rejected = payload;
1153
- rejected._status = Rejected;
1154
- rejected._result = error2;
1155
- }
1156
- });
1157
- if (payload._status === Uninitialized) {
1158
- var pending = payload;
1159
- pending._status = Pending;
1160
- pending._result = thenable;
1161
- }
1162
- }
1163
- if (payload._status === Resolved) {
1164
- var moduleObject = payload._result;
1165
- {
1166
- if (moduleObject === void 0) {
1167
- error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?", moduleObject);
1168
- }
1169
- }
1170
- {
1171
- if (!("default" in moduleObject)) {
1172
- error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
1173
- }
1174
- }
1175
- return moduleObject.default;
1176
- } else {
1177
- throw payload._result;
1178
- }
1179
- }
1180
- function lazy(ctor) {
1181
- var payload = {
1182
- // We use these fields to store the result.
1183
- _status: Uninitialized,
1184
- _result: ctor
1185
- };
1186
- var lazyType = {
1187
- $$typeof: REACT_LAZY_TYPE,
1188
- _payload: payload,
1189
- _init: lazyInitializer
1190
- };
1191
- {
1192
- var defaultProps;
1193
- var propTypes;
1194
- Object.defineProperties(lazyType, {
1195
- defaultProps: {
1196
- configurable: true,
1197
- get: function() {
1198
- return defaultProps;
1199
- },
1200
- set: function(newDefaultProps) {
1201
- error("React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.");
1202
- defaultProps = newDefaultProps;
1203
- Object.defineProperty(lazyType, "defaultProps", {
1204
- enumerable: true
1205
- });
1206
- }
1207
- },
1208
- propTypes: {
1209
- configurable: true,
1210
- get: function() {
1211
- return propTypes;
1212
- },
1213
- set: function(newPropTypes) {
1214
- error("React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.");
1215
- propTypes = newPropTypes;
1216
- Object.defineProperty(lazyType, "propTypes", {
1217
- enumerable: true
1218
- });
1219
- }
1220
- }
1221
- });
1222
- }
1223
- return lazyType;
1224
- }
1225
- function forwardRef(render) {
1226
- {
1227
- if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
1228
- error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).");
1229
- } else if (typeof render !== "function") {
1230
- error("forwardRef requires a render function but was given %s.", render === null ? "null" : typeof render);
1231
- } else {
1232
- if (render.length !== 0 && render.length !== 2) {
1233
- error("forwardRef render functions accept exactly two parameters: props and ref. %s", render.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
1234
- }
1235
- }
1236
- if (render != null) {
1237
- if (render.defaultProps != null || render.propTypes != null) {
1238
- error("forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?");
1239
- }
1240
- }
1241
- }
1242
- var elementType = {
1243
- $$typeof: REACT_FORWARD_REF_TYPE,
1244
- render
1245
- };
1246
- {
1247
- var ownName;
1248
- Object.defineProperty(elementType, "displayName", {
1249
- enumerable: false,
1250
- configurable: true,
1251
- get: function() {
1252
- return ownName;
1253
- },
1254
- set: function(name2) {
1255
- ownName = name2;
1256
- if (!render.name && !render.displayName) {
1257
- render.displayName = name2;
1258
- }
1259
- }
1260
- });
1261
- }
1262
- return elementType;
1263
- }
1264
- var REACT_MODULE_REFERENCE;
1265
- {
1266
- REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
1267
- }
1268
- function isValidElementType(type) {
1269
- if (typeof type === "string" || typeof type === "function") {
1270
- return true;
1271
- }
1272
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
1273
- return true;
1274
- }
1275
- if (typeof type === "object" && type !== null) {
1276
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
1277
- // types supported by any Flight configuration anywhere since
1278
- // we don't know which Flight build this will end up being used
1279
- // with.
1280
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
1281
- return true;
1282
- }
1283
- }
1284
- return false;
1285
- }
1286
- function memo(type, compare2) {
1287
- {
1288
- if (!isValidElementType(type)) {
1289
- error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
1290
- }
1291
- }
1292
- var elementType = {
1293
- $$typeof: REACT_MEMO_TYPE,
1294
- type,
1295
- compare: compare2 === void 0 ? null : compare2
1296
- };
1297
- {
1298
- var ownName;
1299
- Object.defineProperty(elementType, "displayName", {
1300
- enumerable: false,
1301
- configurable: true,
1302
- get: function() {
1303
- return ownName;
1304
- },
1305
- set: function(name2) {
1306
- ownName = name2;
1307
- if (!type.name && !type.displayName) {
1308
- type.displayName = name2;
1309
- }
1310
- }
1311
- });
1312
- }
1313
- return elementType;
1314
- }
1315
- function resolveDispatcher() {
1316
- var dispatcher = ReactCurrentDispatcher.current;
1317
- {
1318
- if (dispatcher === null) {
1319
- error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
1320
- }
1321
- }
1322
- return dispatcher;
1323
- }
1324
- function useContext(Context) {
1325
- var dispatcher = resolveDispatcher();
1326
- {
1327
- if (Context._context !== void 0) {
1328
- var realContext = Context._context;
1329
- if (realContext.Consumer === Context) {
1330
- error("Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?");
1331
- } else if (realContext.Provider === Context) {
1332
- error("Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?");
1333
- }
1334
- }
1335
- }
1336
- return dispatcher.useContext(Context);
1337
- }
1338
- function useState(initialState) {
1339
- var dispatcher = resolveDispatcher();
1340
- return dispatcher.useState(initialState);
1341
- }
1342
- function useReducer(reducer, initialArg, init) {
1343
- var dispatcher = resolveDispatcher();
1344
- return dispatcher.useReducer(reducer, initialArg, init);
1345
- }
1346
- function useRef(initialValue) {
1347
- var dispatcher = resolveDispatcher();
1348
- return dispatcher.useRef(initialValue);
1349
- }
1350
- function useEffect(create, deps) {
1351
- var dispatcher = resolveDispatcher();
1352
- return dispatcher.useEffect(create, deps);
1353
- }
1354
- function useInsertionEffect(create, deps) {
1355
- var dispatcher = resolveDispatcher();
1356
- return dispatcher.useInsertionEffect(create, deps);
1357
- }
1358
- function useLayoutEffect(create, deps) {
1359
- var dispatcher = resolveDispatcher();
1360
- return dispatcher.useLayoutEffect(create, deps);
1361
- }
1362
- function useCallback(callback, deps) {
1363
- var dispatcher = resolveDispatcher();
1364
- return dispatcher.useCallback(callback, deps);
1365
- }
1366
- function useMemo(create, deps) {
1367
- var dispatcher = resolveDispatcher();
1368
- return dispatcher.useMemo(create, deps);
1369
- }
1370
- function useImperativeHandle(ref, create, deps) {
1371
- var dispatcher = resolveDispatcher();
1372
- return dispatcher.useImperativeHandle(ref, create, deps);
1373
- }
1374
- function useDebugValue(value, formatterFn) {
1375
- {
1376
- var dispatcher = resolveDispatcher();
1377
- return dispatcher.useDebugValue(value, formatterFn);
1378
- }
1379
- }
1380
- function useTransition() {
1381
- var dispatcher = resolveDispatcher();
1382
- return dispatcher.useTransition();
1383
- }
1384
- function useDeferredValue(value) {
1385
- var dispatcher = resolveDispatcher();
1386
- return dispatcher.useDeferredValue(value);
1387
- }
1388
- function useId() {
1389
- var dispatcher = resolveDispatcher();
1390
- return dispatcher.useId();
1391
- }
1392
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
1393
- var dispatcher = resolveDispatcher();
1394
- return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
1395
- }
1396
- var disabledDepth = 0;
1397
- var prevLog;
1398
- var prevInfo;
1399
- var prevWarn;
1400
- var prevError;
1401
- var prevGroup;
1402
- var prevGroupCollapsed;
1403
- var prevGroupEnd;
1404
- function disabledLog() {
1405
- }
1406
- disabledLog.__reactDisabledLog = true;
1407
- function disableLogs() {
1408
- {
1409
- if (disabledDepth === 0) {
1410
- prevLog = console.log;
1411
- prevInfo = console.info;
1412
- prevWarn = console.warn;
1413
- prevError = console.error;
1414
- prevGroup = console.group;
1415
- prevGroupCollapsed = console.groupCollapsed;
1416
- prevGroupEnd = console.groupEnd;
1417
- var props = {
1418
- configurable: true,
1419
- enumerable: true,
1420
- value: disabledLog,
1421
- writable: true
1422
- };
1423
- Object.defineProperties(console, {
1424
- info: props,
1425
- log: props,
1426
- warn: props,
1427
- error: props,
1428
- group: props,
1429
- groupCollapsed: props,
1430
- groupEnd: props
1431
- });
1432
- }
1433
- disabledDepth++;
1434
- }
1435
- }
1436
- function reenableLogs() {
1437
- {
1438
- disabledDepth--;
1439
- if (disabledDepth === 0) {
1440
- var props = {
1441
- configurable: true,
1442
- enumerable: true,
1443
- writable: true
1444
- };
1445
- Object.defineProperties(console, {
1446
- log: assign({}, props, {
1447
- value: prevLog
1448
- }),
1449
- info: assign({}, props, {
1450
- value: prevInfo
1451
- }),
1452
- warn: assign({}, props, {
1453
- value: prevWarn
1454
- }),
1455
- error: assign({}, props, {
1456
- value: prevError
1457
- }),
1458
- group: assign({}, props, {
1459
- value: prevGroup
1460
- }),
1461
- groupCollapsed: assign({}, props, {
1462
- value: prevGroupCollapsed
1463
- }),
1464
- groupEnd: assign({}, props, {
1465
- value: prevGroupEnd
1466
- })
1467
- });
1468
- }
1469
- if (disabledDepth < 0) {
1470
- error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
1471
- }
1472
- }
1473
- }
1474
- var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
1475
- var prefix;
1476
- function describeBuiltInComponentFrame(name2, source, ownerFn) {
1477
- {
1478
- if (prefix === void 0) {
1479
- try {
1480
- throw Error();
1481
- } catch (x) {
1482
- var match = x.stack.trim().match(/\n( *(at )?)/);
1483
- prefix = match && match[1] || "";
1484
- }
1485
- }
1486
- return "\n" + prefix + name2;
1487
- }
1488
- }
1489
- var reentry = false;
1490
- var componentFrameCache;
1491
- {
1492
- var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
1493
- componentFrameCache = new PossiblyWeakMap();
1494
- }
1495
- function describeNativeComponentFrame(fn, construct) {
1496
- if (!fn || reentry) {
1497
- return "";
1498
- }
1499
- {
1500
- var frame = componentFrameCache.get(fn);
1501
- if (frame !== void 0) {
1502
- return frame;
1503
- }
1504
- }
1505
- var control;
1506
- reentry = true;
1507
- var previousPrepareStackTrace = Error.prepareStackTrace;
1508
- Error.prepareStackTrace = void 0;
1509
- var previousDispatcher;
1510
- {
1511
- previousDispatcher = ReactCurrentDispatcher$1.current;
1512
- ReactCurrentDispatcher$1.current = null;
1513
- disableLogs();
1514
- }
1515
- try {
1516
- if (construct) {
1517
- var Fake = function() {
1518
- throw Error();
1519
- };
1520
- Object.defineProperty(Fake.prototype, "props", {
1521
- set: function() {
1522
- throw Error();
1523
- }
1524
- });
1525
- if (typeof Reflect === "object" && Reflect.construct) {
1526
- try {
1527
- Reflect.construct(Fake, []);
1528
- } catch (x) {
1529
- control = x;
1530
- }
1531
- Reflect.construct(fn, [], Fake);
1532
- } else {
1533
- try {
1534
- Fake.call();
1535
- } catch (x) {
1536
- control = x;
1537
- }
1538
- fn.call(Fake.prototype);
1539
- }
1540
- } else {
1541
- try {
1542
- throw Error();
1543
- } catch (x) {
1544
- control = x;
1545
- }
1546
- fn();
1547
- }
1548
- } catch (sample) {
1549
- if (sample && control && typeof sample.stack === "string") {
1550
- var sampleLines = sample.stack.split("\n");
1551
- var controlLines = control.stack.split("\n");
1552
- var s = sampleLines.length - 1;
1553
- var c = controlLines.length - 1;
1554
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
1555
- c--;
1556
- }
1557
- for (; s >= 1 && c >= 0; s--, c--) {
1558
- if (sampleLines[s] !== controlLines[c]) {
1559
- if (s !== 1 || c !== 1) {
1560
- do {
1561
- s--;
1562
- c--;
1563
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
1564
- var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
1565
- if (fn.displayName && _frame.includes("<anonymous>")) {
1566
- _frame = _frame.replace("<anonymous>", fn.displayName);
1567
- }
1568
- {
1569
- if (typeof fn === "function") {
1570
- componentFrameCache.set(fn, _frame);
1571
- }
1572
- }
1573
- return _frame;
1574
- }
1575
- } while (s >= 1 && c >= 0);
1576
- }
1577
- break;
1578
- }
1579
- }
1580
- }
1581
- } finally {
1582
- reentry = false;
1583
- {
1584
- ReactCurrentDispatcher$1.current = previousDispatcher;
1585
- reenableLogs();
1586
- }
1587
- Error.prepareStackTrace = previousPrepareStackTrace;
1588
- }
1589
- var name2 = fn ? fn.displayName || fn.name : "";
1590
- var syntheticFrame = name2 ? describeBuiltInComponentFrame(name2) : "";
1591
- {
1592
- if (typeof fn === "function") {
1593
- componentFrameCache.set(fn, syntheticFrame);
1594
- }
1595
- }
1596
- return syntheticFrame;
1597
- }
1598
- function describeFunctionComponentFrame(fn, source, ownerFn) {
1599
- {
1600
- return describeNativeComponentFrame(fn, false);
1601
- }
1602
- }
1603
- function shouldConstruct(Component2) {
1604
- var prototype = Component2.prototype;
1605
- return !!(prototype && prototype.isReactComponent);
1606
- }
1607
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
1608
- if (type == null) {
1609
- return "";
1610
- }
1611
- if (typeof type === "function") {
1612
- {
1613
- return describeNativeComponentFrame(type, shouldConstruct(type));
1614
- }
1615
- }
1616
- if (typeof type === "string") {
1617
- return describeBuiltInComponentFrame(type);
1618
- }
1619
- switch (type) {
1620
- case REACT_SUSPENSE_TYPE:
1621
- return describeBuiltInComponentFrame("Suspense");
1622
- case REACT_SUSPENSE_LIST_TYPE:
1623
- return describeBuiltInComponentFrame("SuspenseList");
1624
- }
1625
- if (typeof type === "object") {
1626
- switch (type.$$typeof) {
1627
- case REACT_FORWARD_REF_TYPE:
1628
- return describeFunctionComponentFrame(type.render);
1629
- case REACT_MEMO_TYPE:
1630
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
1631
- case REACT_LAZY_TYPE: {
1632
- var lazyComponent = type;
1633
- var payload = lazyComponent._payload;
1634
- var init = lazyComponent._init;
1635
- try {
1636
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
1637
- } catch (x) {
1638
- }
1639
- }
1640
- }
1641
- }
1642
- return "";
1643
- }
1644
- var loggedTypeFailures = {};
1645
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
1646
- function setCurrentlyValidatingElement(element) {
1647
- {
1648
- if (element) {
1649
- var owner = element._owner;
1650
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1651
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
1652
- } else {
1653
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
1654
- }
1655
- }
1656
- }
1657
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
1658
- {
1659
- var has = Function.call.bind(hasOwnProperty);
1660
- for (var typeSpecName in typeSpecs) {
1661
- if (has(typeSpecs, typeSpecName)) {
1662
- var error$1 = void 0;
1663
- try {
1664
- if (typeof typeSpecs[typeSpecName] !== "function") {
1665
- var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
1666
- err.name = "Invariant Violation";
1667
- throw err;
1668
- }
1669
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
1670
- } catch (ex) {
1671
- error$1 = ex;
1672
- }
1673
- if (error$1 && !(error$1 instanceof Error)) {
1674
- setCurrentlyValidatingElement(element);
1675
- error("%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).", componentName || "React class", location, typeSpecName, typeof error$1);
1676
- setCurrentlyValidatingElement(null);
1677
- }
1678
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
1679
- loggedTypeFailures[error$1.message] = true;
1680
- setCurrentlyValidatingElement(element);
1681
- error("Failed %s type: %s", location, error$1.message);
1682
- setCurrentlyValidatingElement(null);
1683
- }
1684
- }
1685
- }
1686
- }
1687
- }
1688
- function setCurrentlyValidatingElement$1(element) {
1689
- {
1690
- if (element) {
1691
- var owner = element._owner;
1692
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1693
- setExtraStackFrame(stack);
1694
- } else {
1695
- setExtraStackFrame(null);
1696
- }
1697
- }
1698
- }
1699
- var propTypesMisspellWarningShown;
1700
- {
1701
- propTypesMisspellWarningShown = false;
1702
- }
1703
- function getDeclarationErrorAddendum() {
1704
- if (ReactCurrentOwner.current) {
1705
- var name2 = getComponentNameFromType(ReactCurrentOwner.current.type);
1706
- if (name2) {
1707
- return "\n\nCheck the render method of `" + name2 + "`.";
1708
- }
1709
- }
1710
- return "";
1711
- }
1712
- function getSourceInfoErrorAddendum(source) {
1713
- if (source !== void 0) {
1714
- var fileName = source.fileName.replace(/^.*[\\\/]/, "");
1715
- var lineNumber = source.lineNumber;
1716
- return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
1717
- }
1718
- return "";
1719
- }
1720
- function getSourceInfoErrorAddendumForProps(elementProps) {
1721
- if (elementProps !== null && elementProps !== void 0) {
1722
- return getSourceInfoErrorAddendum(elementProps.__source);
1723
- }
1724
- return "";
1725
- }
1726
- var ownerHasKeyUseWarning = {};
1727
- function getCurrentComponentErrorInfo(parentType) {
1728
- var info = getDeclarationErrorAddendum();
1729
- if (!info) {
1730
- var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
1731
- if (parentName) {
1732
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1733
- }
1734
- }
1735
- return info;
1736
- }
1737
- function validateExplicitKey(element, parentType) {
1738
- if (!element._store || element._store.validated || element.key != null) {
1739
- return;
1740
- }
1741
- element._store.validated = true;
1742
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1743
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1744
- return;
1745
- }
1746
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
1747
- var childOwner = "";
1748
- if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
1749
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1750
- }
1751
- {
1752
- setCurrentlyValidatingElement$1(element);
1753
- error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1754
- setCurrentlyValidatingElement$1(null);
1755
- }
1756
- }
1757
- function validateChildKeys(node, parentType) {
1758
- if (typeof node !== "object") {
1759
- return;
1760
- }
1761
- if (isArray(node)) {
1762
- for (var i = 0; i < node.length; i++) {
1763
- var child = node[i];
1764
- if (isValidElement(child)) {
1765
- validateExplicitKey(child, parentType);
1766
- }
1767
- }
1768
- } else if (isValidElement(node)) {
1769
- if (node._store) {
1770
- node._store.validated = true;
1771
- }
1772
- } else if (node) {
1773
- var iteratorFn = getIteratorFn(node);
1774
- if (typeof iteratorFn === "function") {
1775
- if (iteratorFn !== node.entries) {
1776
- var iterator = iteratorFn.call(node);
1777
- var step;
1778
- while (!(step = iterator.next()).done) {
1779
- if (isValidElement(step.value)) {
1780
- validateExplicitKey(step.value, parentType);
1781
- }
1782
- }
1783
- }
1784
- }
1785
- }
1786
- }
1787
- function validatePropTypes(element) {
1788
- {
1789
- var type = element.type;
1790
- if (type === null || type === void 0 || typeof type === "string") {
1791
- return;
1792
- }
1793
- var propTypes;
1794
- if (typeof type === "function") {
1795
- propTypes = type.propTypes;
1796
- } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1797
- // Inner props are checked in the reconciler.
1798
- type.$$typeof === REACT_MEMO_TYPE)) {
1799
- propTypes = type.propTypes;
1800
- } else {
1801
- return;
1802
- }
1803
- if (propTypes) {
1804
- var name2 = getComponentNameFromType(type);
1805
- checkPropTypes(propTypes, element.props, "prop", name2, element);
1806
- } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
1807
- propTypesMisspellWarningShown = true;
1808
- var _name = getComponentNameFromType(type);
1809
- error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
1810
- }
1811
- if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
1812
- error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
1813
- }
1814
- }
1815
- }
1816
- function validateFragmentProps(fragment) {
1817
- {
1818
- var keys = Object.keys(fragment.props);
1819
- for (var i = 0; i < keys.length; i++) {
1820
- var key = keys[i];
1821
- if (key !== "children" && key !== "key") {
1822
- setCurrentlyValidatingElement$1(fragment);
1823
- error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
1824
- setCurrentlyValidatingElement$1(null);
1825
- break;
1826
- }
1827
- }
1828
- if (fragment.ref !== null) {
1829
- setCurrentlyValidatingElement$1(fragment);
1830
- error("Invalid attribute `ref` supplied to `React.Fragment`.");
1831
- setCurrentlyValidatingElement$1(null);
1832
- }
1833
- }
1834
- }
1835
- function createElementWithValidation(type, props, children) {
1836
- var validType = isValidElementType(type);
1837
- if (!validType) {
1838
- var info = "";
1839
- if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
1840
- info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
1841
- }
1842
- var sourceInfo = getSourceInfoErrorAddendumForProps(props);
1843
- if (sourceInfo) {
1844
- info += sourceInfo;
1845
- } else {
1846
- info += getDeclarationErrorAddendum();
1847
- }
1848
- var typeString;
1849
- if (type === null) {
1850
- typeString = "null";
1851
- } else if (isArray(type)) {
1852
- typeString = "array";
1853
- } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
1854
- typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
1855
- info = " Did you accidentally export a JSX literal instead of a component?";
1856
- } else {
1857
- typeString = typeof type;
1858
- }
1859
- {
1860
- error("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
1861
- }
1862
- }
1863
- var element = createElement.apply(this, arguments);
1864
- if (element == null) {
1865
- return element;
1866
- }
1867
- if (validType) {
1868
- for (var i = 2; i < arguments.length; i++) {
1869
- validateChildKeys(arguments[i], type);
1870
- }
1871
- }
1872
- if (type === REACT_FRAGMENT_TYPE) {
1873
- validateFragmentProps(element);
1874
- } else {
1875
- validatePropTypes(element);
1876
- }
1877
- return element;
1878
- }
1879
- var didWarnAboutDeprecatedCreateFactory = false;
1880
- function createFactoryWithValidation(type) {
1881
- var validatedFactory = createElementWithValidation.bind(null, type);
1882
- validatedFactory.type = type;
1883
- {
1884
- if (!didWarnAboutDeprecatedCreateFactory) {
1885
- didWarnAboutDeprecatedCreateFactory = true;
1886
- warn("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.");
1887
- }
1888
- Object.defineProperty(validatedFactory, "type", {
1889
- enumerable: false,
1890
- get: function() {
1891
- warn("Factory.type is deprecated. Access the class directly before passing it to createFactory.");
1892
- Object.defineProperty(this, "type", {
1893
- value: type
1894
- });
1895
- return type;
1896
- }
1897
- });
1898
- }
1899
- return validatedFactory;
1900
- }
1901
- function cloneElementWithValidation(element, props, children) {
1902
- var newElement = cloneElement.apply(this, arguments);
1903
- for (var i = 2; i < arguments.length; i++) {
1904
- validateChildKeys(arguments[i], newElement.type);
1905
- }
1906
- validatePropTypes(newElement);
1907
- return newElement;
1908
- }
1909
- function startTransition(scope, options) {
1910
- var prevTransition = ReactCurrentBatchConfig.transition;
1911
- ReactCurrentBatchConfig.transition = {};
1912
- var currentTransition = ReactCurrentBatchConfig.transition;
1913
- {
1914
- ReactCurrentBatchConfig.transition._updatedFibers = /* @__PURE__ */ new Set();
1915
- }
1916
- try {
1917
- scope();
1918
- } finally {
1919
- ReactCurrentBatchConfig.transition = prevTransition;
1920
- {
1921
- if (prevTransition === null && currentTransition._updatedFibers) {
1922
- var updatedFibersCount = currentTransition._updatedFibers.size;
1923
- if (updatedFibersCount > 10) {
1924
- warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.");
1925
- }
1926
- currentTransition._updatedFibers.clear();
1927
- }
1928
- }
1929
- }
1930
- }
1931
- var didWarnAboutMessageChannel = false;
1932
- var enqueueTaskImpl = null;
1933
- function enqueueTask(task) {
1934
- if (enqueueTaskImpl === null) {
1935
- try {
1936
- var requireString = ("require" + Math.random()).slice(0, 7);
1937
- var nodeRequire = module && module[requireString];
1938
- enqueueTaskImpl = nodeRequire.call(module, "timers").setImmediate;
1939
- } catch (_err) {
1940
- enqueueTaskImpl = function(callback) {
1941
- {
1942
- if (didWarnAboutMessageChannel === false) {
1943
- didWarnAboutMessageChannel = true;
1944
- if (typeof MessageChannel === "undefined") {
1945
- error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning.");
1946
- }
1947
- }
1948
- }
1949
- var channel = new MessageChannel();
1950
- channel.port1.onmessage = callback;
1951
- channel.port2.postMessage(void 0);
1952
- };
1953
- }
1954
- }
1955
- return enqueueTaskImpl(task);
1956
- }
1957
- var actScopeDepth = 0;
1958
- var didWarnNoAwaitAct = false;
1959
- function act(callback) {
1960
- {
1961
- var prevActScopeDepth = actScopeDepth;
1962
- actScopeDepth++;
1963
- if (ReactCurrentActQueue.current === null) {
1964
- ReactCurrentActQueue.current = [];
1965
- }
1966
- var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;
1967
- var result;
1968
- try {
1969
- ReactCurrentActQueue.isBatchingLegacy = true;
1970
- result = callback();
1971
- if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
1972
- var queue = ReactCurrentActQueue.current;
1973
- if (queue !== null) {
1974
- ReactCurrentActQueue.didScheduleLegacyUpdate = false;
1975
- flushActQueue(queue);
1976
- }
1977
- }
1978
- } catch (error2) {
1979
- popActScope(prevActScopeDepth);
1980
- throw error2;
1981
- } finally {
1982
- ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;
1983
- }
1984
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
1985
- var thenableResult = result;
1986
- var wasAwaited = false;
1987
- var thenable = {
1988
- then: function(resolve, reject) {
1989
- wasAwaited = true;
1990
- thenableResult.then(function(returnValue2) {
1991
- popActScope(prevActScopeDepth);
1992
- if (actScopeDepth === 0) {
1993
- recursivelyFlushAsyncActWork(returnValue2, resolve, reject);
1994
- } else {
1995
- resolve(returnValue2);
1996
- }
1997
- }, function(error2) {
1998
- popActScope(prevActScopeDepth);
1999
- reject(error2);
2000
- });
2001
- }
2002
- };
2003
- {
2004
- if (!didWarnNoAwaitAct && typeof Promise !== "undefined") {
2005
- Promise.resolve().then(function() {
2006
- }).then(function() {
2007
- if (!wasAwaited) {
2008
- didWarnNoAwaitAct = true;
2009
- error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);");
2010
- }
2011
- });
2012
- }
2013
- }
2014
- return thenable;
2015
- } else {
2016
- var returnValue = result;
2017
- popActScope(prevActScopeDepth);
2018
- if (actScopeDepth === 0) {
2019
- var _queue = ReactCurrentActQueue.current;
2020
- if (_queue !== null) {
2021
- flushActQueue(_queue);
2022
- ReactCurrentActQueue.current = null;
2023
- }
2024
- var _thenable = {
2025
- then: function(resolve, reject) {
2026
- if (ReactCurrentActQueue.current === null) {
2027
- ReactCurrentActQueue.current = [];
2028
- recursivelyFlushAsyncActWork(returnValue, resolve, reject);
2029
- } else {
2030
- resolve(returnValue);
2031
- }
2032
- }
2033
- };
2034
- return _thenable;
2035
- } else {
2036
- var _thenable2 = {
2037
- then: function(resolve, reject) {
2038
- resolve(returnValue);
2039
- }
2040
- };
2041
- return _thenable2;
2042
- }
2043
- }
2044
- }
2045
- }
2046
- function popActScope(prevActScopeDepth) {
2047
- {
2048
- if (prevActScopeDepth !== actScopeDepth - 1) {
2049
- error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
2050
- }
2051
- actScopeDepth = prevActScopeDepth;
2052
- }
2053
- }
2054
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
2055
- {
2056
- var queue = ReactCurrentActQueue.current;
2057
- if (queue !== null) {
2058
- try {
2059
- flushActQueue(queue);
2060
- enqueueTask(function() {
2061
- if (queue.length === 0) {
2062
- ReactCurrentActQueue.current = null;
2063
- resolve(returnValue);
2064
- } else {
2065
- recursivelyFlushAsyncActWork(returnValue, resolve, reject);
2066
- }
2067
- });
2068
- } catch (error2) {
2069
- reject(error2);
2070
- }
2071
- } else {
2072
- resolve(returnValue);
2073
- }
2074
- }
2075
- }
2076
- var isFlushing = false;
2077
- function flushActQueue(queue) {
2078
- {
2079
- if (!isFlushing) {
2080
- isFlushing = true;
2081
- var i = 0;
2082
- try {
2083
- for (; i < queue.length; i++) {
2084
- var callback = queue[i];
2085
- do {
2086
- callback = callback(true);
2087
- } while (callback !== null);
2088
- }
2089
- queue.length = 0;
2090
- } catch (error2) {
2091
- queue = queue.slice(i + 1);
2092
- throw error2;
2093
- } finally {
2094
- isFlushing = false;
2095
- }
2096
- }
2097
- }
2098
- }
2099
- var createElement$1 = createElementWithValidation;
2100
- var cloneElement$1 = cloneElementWithValidation;
2101
- var createFactory = createFactoryWithValidation;
2102
- var Children = {
2103
- map: mapChildren,
2104
- forEach: forEachChildren,
2105
- count: countChildren,
2106
- toArray: toArray2,
2107
- only: onlyChild
2108
- };
2109
- exports.Children = Children;
2110
- exports.Component = Component;
2111
- exports.Fragment = REACT_FRAGMENT_TYPE;
2112
- exports.Profiler = REACT_PROFILER_TYPE;
2113
- exports.PureComponent = PureComponent;
2114
- exports.StrictMode = REACT_STRICT_MODE_TYPE;
2115
- exports.Suspense = REACT_SUSPENSE_TYPE;
2116
- exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
2117
- exports.cloneElement = cloneElement$1;
2118
- exports.createContext = createContext;
2119
- exports.createElement = createElement$1;
2120
- exports.createFactory = createFactory;
2121
- exports.createRef = createRef;
2122
- exports.forwardRef = forwardRef;
2123
- exports.isValidElement = isValidElement;
2124
- exports.lazy = lazy;
2125
- exports.memo = memo;
2126
- exports.startTransition = startTransition;
2127
- exports.unstable_act = act;
2128
- exports.useCallback = useCallback;
2129
- exports.useContext = useContext;
2130
- exports.useDebugValue = useDebugValue;
2131
- exports.useDeferredValue = useDeferredValue;
2132
- exports.useEffect = useEffect;
2133
- exports.useId = useId;
2134
- exports.useImperativeHandle = useImperativeHandle;
2135
- exports.useInsertionEffect = useInsertionEffect;
2136
- exports.useLayoutEffect = useLayoutEffect;
2137
- exports.useMemo = useMemo;
2138
- exports.useReducer = useReducer;
2139
- exports.useRef = useRef;
2140
- exports.useState = useState;
2141
- exports.useSyncExternalStore = useSyncExternalStore;
2142
- exports.useTransition = useTransition;
2143
- exports.version = ReactVersion;
2144
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
2145
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
2146
- }
2147
- })();
2148
- }
2149
- })(react_development, react_development.exports);
2150
- return react_development.exports;
2151
- }
2152
- var hasRequiredReact;
2153
- function requireReact() {
2154
- if (hasRequiredReact) return react.exports;
2155
- hasRequiredReact = 1;
2156
- if (process.env.NODE_ENV === "production") {
2157
- react.exports = requireReact_production_min();
2158
- } else {
2159
- react.exports = requireReact_development();
2160
- }
2161
- return react.exports;
2162
- }
2163
- var reactExports = requireReact();
5
+ import { useState, useEffect, useCallback, createContext, useContext } from "react";
6
+ import { jsx } from "react/jsx-runtime";
2164
7
  var Code$1;
2165
8
  (function(Code2) {
2166
9
  Code2[Code2["Canceled"] = 1] = "Canceled";
@@ -22330,7 +20173,7 @@ function createAuthInterceptor(apiKey, token) {
22330
20173
  };
22331
20174
  }
22332
20175
  const name = "@yorkie-js/sdk";
22333
- const version = "0.6.0";
20176
+ const version = "0.6.1";
22334
20177
  const pkg = {
22335
20178
  name,
22336
20179
  version
@@ -22528,197 +20371,74 @@ class Client {
22528
20371
  var _a2;
22529
20372
  const { topic, payload } = event.value;
22530
20373
  const errorFn = (_a2 = event.options) == null ? void 0 : _a2.error;
22531
- const options2 = event.options;
22532
- try {
22533
- await this.broadcast(doc.getKey(), topic, payload, options2);
22534
- } catch (error) {
22535
- if (error instanceof Error) {
22536
- errorFn == null ? void 0 : errorFn(error);
22537
- }
22538
- }
22539
- }
22540
- );
22541
- const syncMode = options.syncMode ?? "realtime";
22542
- return this.enqueueTask(async () => {
22543
- return this.rpcClient.attachDocument(
22544
- {
22545
- clientId: this.id,
22546
- changePack: converter.toChangePack(doc.createChangePack())
22547
- },
22548
- { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
22549
- ).then(async (res) => {
22550
- const pack = converter.fromChangePack(res.changePack);
22551
- doc.applyChangePack(pack);
22552
- if (doc.getStatus() === DocStatus.Removed) {
22553
- return doc;
22554
- }
22555
- doc.applyStatus(DocStatus.Attached);
22556
- this.attachmentMap.set(
22557
- doc.getKey(),
22558
- new Attachment(
22559
- this.reconnectStreamDelay,
22560
- doc,
22561
- res.documentId,
22562
- syncMode,
22563
- unsubscribeBroacastEvent
22564
- )
22565
- );
22566
- if (syncMode !== "manual") {
22567
- await this.runWatchLoop(doc.getKey());
22568
- }
22569
- logger.info(`[AD] c:"${this.getKey()}" attaches d:"${doc.getKey()}"`);
22570
- const crdtObject = doc.getRootObject();
22571
- if (options.initialRoot) {
22572
- const initialRoot = options.initialRoot;
22573
- doc.update((root) => {
22574
- for (const [k, v] of Object.entries(initialRoot)) {
22575
- if (!crdtObject.has(k)) {
22576
- const key = k;
22577
- root[key] = v;
22578
- }
22579
- }
22580
- });
22581
- }
22582
- return doc;
22583
- }).catch(async (err) => {
22584
- logger.error(`[AD] c:"${this.getKey()}" err :`, err);
22585
- await this.handleConnectError(err);
22586
- throw err;
22587
- });
22588
- });
22589
- }
22590
- /**
22591
- * `detach` detaches the given document from this client. It tells the
22592
- * server that this client will no longer synchronize the given document.
22593
- *
22594
- * To collect garbage things like CRDT tombstones left on the document, all
22595
- * the changes should be applied to other replicas before GC time. For this,
22596
- * if the document is no longer used by this client, it should be detached.
22597
- */
22598
- detach(doc, options = {}) {
22599
- if (!this.isActive()) {
22600
- throw new YorkieError(
22601
- Code.ErrClientNotActivated,
22602
- `${this.key} is not active`
22603
- );
22604
- }
22605
- const attachment = this.attachmentMap.get(doc.getKey());
22606
- if (!attachment) {
22607
- throw new YorkieError(
22608
- Code.ErrDocumentNotAttached,
22609
- `${doc.getKey()} is not attached`
22610
- );
22611
- }
22612
- doc.update((_, p) => p.clear());
22613
- return this.enqueueTask(async () => {
22614
- return this.rpcClient.detachDocument(
22615
- {
22616
- clientId: this.id,
22617
- documentId: attachment.docID,
22618
- changePack: converter.toChangePack(doc.createChangePack()),
22619
- removeIfNotAttached: options.removeIfNotAttached ?? false
22620
- },
22621
- { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
22622
- ).then((res) => {
22623
- const pack = converter.fromChangePack(res.changePack);
22624
- doc.applyChangePack(pack);
22625
- if (doc.getStatus() !== DocStatus.Removed) {
22626
- doc.applyStatus(DocStatus.Detached);
22627
- }
22628
- this.detachInternal(doc.getKey());
22629
- logger.info(`[DD] c:"${this.getKey()}" detaches d:"${doc.getKey()}"`);
22630
- return doc;
22631
- }).catch(async (err) => {
22632
- logger.error(`[DD] c:"${this.getKey()}" err :`, err);
22633
- await this.handleConnectError(err);
22634
- throw err;
22635
- });
22636
- });
22637
- }
22638
- /**
22639
- * `changeRealtimeSync` changes the synchronization mode of the given document.
22640
- */
22641
- async changeSyncMode(doc, syncMode) {
22642
- if (!this.isActive()) {
22643
- throw new YorkieError(
22644
- Code.ErrClientNotActivated,
22645
- `${this.key} is not active`
22646
- );
22647
- }
22648
- const attachment = this.attachmentMap.get(doc.getKey());
22649
- if (!attachment) {
22650
- throw new YorkieError(
22651
- Code.ErrDocumentNotAttached,
22652
- `${doc.getKey()} is not attached`
22653
- );
22654
- }
22655
- const prevSyncMode = attachment.syncMode;
22656
- if (prevSyncMode === syncMode) {
22657
- return doc;
22658
- }
22659
- attachment.changeSyncMode(syncMode);
22660
- if (syncMode === "manual") {
22661
- attachment.cancelWatchStream();
22662
- return doc;
22663
- }
22664
- if (syncMode === "realtime") {
22665
- attachment.remoteChangeEventReceived = true;
22666
- }
22667
- if (prevSyncMode === "manual") {
22668
- await this.runWatchLoop(doc.getKey());
22669
- }
22670
- return doc;
22671
- }
22672
- /**
22673
- * `sync` pushes local changes of the attached documents to the server and
22674
- * receives changes of the remote replica from the server then apply them to
22675
- * local documents.
22676
- */
22677
- sync(doc) {
22678
- if (!this.isActive()) {
22679
- throw new YorkieError(
22680
- Code.ErrClientNotActivated,
22681
- `${this.key} is not active`
22682
- );
22683
- }
22684
- if (doc) {
22685
- const attachment = this.attachmentMap.get(doc.getKey());
22686
- if (!attachment) {
22687
- throw new YorkieError(
22688
- Code.ErrDocumentNotAttached,
22689
- `${doc.getKey()} is not attached`
22690
- );
22691
- }
22692
- return this.enqueueTask(async () => {
22693
- return this.syncInternal(
22694
- attachment,
22695
- "realtime"
22696
- /* Realtime */
22697
- ).catch(
22698
- async (err) => {
22699
- logger.error(`[SY] c:"${this.getKey()}" err :`, err);
22700
- await this.handleConnectError(err);
22701
- throw err;
20374
+ const options2 = event.options;
20375
+ try {
20376
+ await this.broadcast(doc.getKey(), topic, payload, options2);
20377
+ } catch (error) {
20378
+ if (error instanceof Error) {
20379
+ errorFn == null ? void 0 : errorFn(error);
22702
20380
  }
22703
- );
22704
- });
22705
- }
22706
- return this.enqueueTask(async () => {
22707
- const promises = [];
22708
- for (const [, attachment] of this.attachmentMap) {
22709
- promises.push(this.syncInternal(attachment, attachment.syncMode));
20381
+ }
22710
20382
  }
22711
- return Promise.all(promises).catch(async (err) => {
22712
- logger.error(`[SY] c:"${this.getKey()}" err :`, err);
20383
+ );
20384
+ const syncMode = options.syncMode ?? "realtime";
20385
+ return this.enqueueTask(async () => {
20386
+ return this.rpcClient.attachDocument(
20387
+ {
20388
+ clientId: this.id,
20389
+ changePack: converter.toChangePack(doc.createChangePack())
20390
+ },
20391
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
20392
+ ).then(async (res) => {
20393
+ const pack = converter.fromChangePack(res.changePack);
20394
+ doc.applyChangePack(pack);
20395
+ if (doc.getStatus() === DocStatus.Removed) {
20396
+ return doc;
20397
+ }
20398
+ doc.applyStatus(DocStatus.Attached);
20399
+ this.attachmentMap.set(
20400
+ doc.getKey(),
20401
+ new Attachment(
20402
+ this.reconnectStreamDelay,
20403
+ doc,
20404
+ res.documentId,
20405
+ syncMode,
20406
+ unsubscribeBroacastEvent
20407
+ )
20408
+ );
20409
+ if (syncMode !== "manual") {
20410
+ await this.runWatchLoop(doc.getKey());
20411
+ }
20412
+ logger.info(`[AD] c:"${this.getKey()}" attaches d:"${doc.getKey()}"`);
20413
+ const crdtObject = doc.getRootObject();
20414
+ if (options.initialRoot) {
20415
+ const initialRoot = options.initialRoot;
20416
+ doc.update((root) => {
20417
+ for (const [k, v] of Object.entries(initialRoot)) {
20418
+ if (!crdtObject.has(k)) {
20419
+ const key = k;
20420
+ root[key] = v;
20421
+ }
20422
+ }
20423
+ });
20424
+ }
20425
+ return doc;
20426
+ }).catch(async (err) => {
20427
+ logger.error(`[AD] c:"${this.getKey()}" err :`, err);
22713
20428
  await this.handleConnectError(err);
22714
20429
  throw err;
22715
20430
  });
22716
20431
  });
22717
20432
  }
22718
20433
  /**
22719
- * `remove` removes the given document.
20434
+ * `detach` detaches the given document from this client. It tells the
20435
+ * server that this client will no longer synchronize the given document.
20436
+ *
20437
+ * To collect garbage things like CRDT tombstones left on the document, all
20438
+ * the changes should be applied to other replicas before GC time. For this,
20439
+ * if the document is no longer used by this client, it should be detached.
22720
20440
  */
22721
- remove(doc) {
20441
+ detach(doc, options = { keepalive: false }) {
22722
20442
  if (!this.isActive()) {
22723
20443
  throw new YorkieError(
22724
20444
  Code.ErrClientNotActivated,
@@ -22732,1417 +20452,634 @@ class Client {
22732
20452
  `${doc.getKey()} is not attached`
22733
20453
  );
22734
20454
  }
22735
- doc.setActor(this.id);
22736
- const pbChangePack = converter.toChangePack(doc.createChangePack());
22737
- pbChangePack.isRemoved = true;
22738
- return this.enqueueTask(async () => {
22739
- return this.rpcClient.removeDocument(
20455
+ doc.update((_, p) => p.clear());
20456
+ const task = async () => {
20457
+ return await this.rpcClient.detachDocument(
22740
20458
  {
22741
20459
  clientId: this.id,
22742
20460
  documentId: attachment.docID,
22743
- changePack: pbChangePack
20461
+ changePack: converter.toChangePack(doc.createChangePack()),
20462
+ removeIfNotAttached: options.removeIfNotAttached ?? false
22744
20463
  },
22745
20464
  { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
22746
20465
  ).then((res) => {
22747
20466
  const pack = converter.fromChangePack(res.changePack);
22748
20467
  doc.applyChangePack(pack);
20468
+ if (doc.getStatus() !== DocStatus.Removed) {
20469
+ doc.applyStatus(DocStatus.Detached);
20470
+ }
22749
20471
  this.detachInternal(doc.getKey());
22750
- logger.info(`[RD] c:"${this.getKey()}" removes d:"${doc.getKey()}"`);
20472
+ logger.info(`[DD] c:"${this.getKey()}" detaches d:"${doc.getKey()}"`);
20473
+ return doc;
22751
20474
  }).catch(async (err) => {
22752
- logger.error(`[RD] c:"${this.getKey()}" err :`, err);
20475
+ logger.error(`[DD] c:"${this.getKey()}" err :`, err);
22753
20476
  await this.handleConnectError(err);
22754
20477
  throw err;
22755
20478
  });
22756
- });
22757
- }
22758
- /**
22759
- * `getID` returns a ActorID of client.
22760
- */
22761
- getID() {
22762
- return this.id;
22763
- }
22764
- /**
22765
- * `getKey` returns a key of client.
22766
- */
22767
- getKey() {
22768
- return this.key;
22769
- }
22770
- /**
22771
- * `isActive` checks if the client is active.
22772
- */
22773
- isActive() {
22774
- return this.status === "activated";
22775
- }
22776
- /**
22777
- * `getStatus` returns the status of this client.
22778
- */
22779
- getStatus() {
22780
- return this.status;
22781
- }
22782
- /**
22783
- * `getCondition` returns the condition of this client.
22784
- */
22785
- getCondition(condition) {
22786
- return this.conditions[condition];
20479
+ };
20480
+ if (options.keepalive) {
20481
+ this.keepalive = true;
20482
+ const resp = task();
20483
+ this.keepalive = false;
20484
+ return resp;
20485
+ }
20486
+ return this.enqueueTask(task);
22787
20487
  }
22788
20488
  /**
22789
- * `broadcast` broadcasts the given payload to the given topic.
20489
+ * `changeRealtimeSync` changes the synchronization mode of the given document.
22790
20490
  */
22791
- broadcast(docKey, topic, payload, options) {
20491
+ async changeSyncMode(doc, syncMode) {
22792
20492
  if (!this.isActive()) {
22793
20493
  throw new YorkieError(
22794
20494
  Code.ErrClientNotActivated,
22795
20495
  `${this.key} is not active`
22796
20496
  );
22797
20497
  }
22798
- const attachment = this.attachmentMap.get(docKey);
20498
+ const attachment = this.attachmentMap.get(doc.getKey());
22799
20499
  if (!attachment) {
22800
20500
  throw new YorkieError(
22801
20501
  Code.ErrDocumentNotAttached,
22802
- `${docKey} is not attached`
22803
- );
22804
- }
22805
- if (!validateSerializable(payload)) {
22806
- throw new YorkieError(
22807
- Code.ErrInvalidArgument,
22808
- "payload is not serializable"
20502
+ `${doc.getKey()} is not attached`
22809
20503
  );
22810
20504
  }
22811
- const maxRetries = (options == null ? void 0 : options.maxRetries) ?? DefaultBroadcastOptions.maxRetries;
22812
- const maxBackoff = DefaultBroadcastOptions.maxBackoff;
22813
- let retryCount = 0;
22814
- const exponentialBackoff = (retryCount2) => {
22815
- const retryInterval = Math.min(
22816
- DefaultBroadcastOptions.initialRetryInterval * 2 ** retryCount2,
22817
- maxBackoff
22818
- );
22819
- return retryInterval;
22820
- };
22821
- const doLoop = async () => {
22822
- return this.enqueueTask(async () => {
22823
- return this.rpcClient.broadcast(
22824
- {
22825
- clientId: this.id,
22826
- documentId: attachment.docID,
22827
- topic,
22828
- payload: new TextEncoder().encode(JSON.stringify(payload))
22829
- },
22830
- { headers: { "x-shard-key": `${this.apiKey}/${docKey}` } }
22831
- ).then(() => {
22832
- logger.info(
22833
- `[BC] c:"${this.getKey()}" broadcasts d:"${docKey}" t:"${topic}"`
22834
- );
22835
- }).catch(async (err) => {
22836
- logger.error(`[BC] c:"${this.getKey()}" err:`, err);
22837
- if (await this.handleConnectError(err)) {
22838
- if (err instanceof ConnectError && errorCodeOf(err) === Code.ErrUnauthenticated) {
22839
- attachment.doc.publish([
22840
- {
22841
- type: DocEventType.AuthError,
22842
- value: {
22843
- reason: errorMetadataOf(err).reason,
22844
- method: "Broadcast"
22845
- }
22846
- }
22847
- ]);
22848
- }
22849
- if (retryCount < maxRetries) {
22850
- retryCount++;
22851
- setTimeout(() => doLoop(), exponentialBackoff(retryCount - 1));
22852
- logger.info(
22853
- `[BC] c:"${this.getKey()}" retry attempt ${retryCount}/${maxRetries}`
22854
- );
22855
- } else {
22856
- logger.error(
22857
- `[BC] c:"${this.getKey()}" exceeded maximum retry attempts`
22858
- );
22859
- throw err;
22860
- }
22861
- } else {
22862
- throw err;
22863
- }
22864
- });
22865
- });
22866
- };
22867
- return doLoop();
22868
- }
22869
- /**
22870
- * `runSyncLoop` runs the sync loop. The sync loop pushes local changes to
22871
- * the server and pulls remote changes from the server.
22872
- */
22873
- runSyncLoop() {
22874
- const doLoop = () => {
22875
- if (!this.isActive()) {
22876
- logger.debug(`[SL] c:"${this.getKey()}" exit sync loop`);
22877
- this.conditions[
22878
- "SyncLoop"
22879
- /* SyncLoop */
22880
- ] = false;
22881
- return;
22882
- }
22883
- const syncJobs = [];
22884
- for (const [, attachment] of this.attachmentMap) {
22885
- if (attachment.needRealtimeSync()) {
22886
- attachment.remoteChangeEventReceived = false;
22887
- syncJobs.push(
22888
- this.syncInternal(attachment, attachment.syncMode).catch(
22889
- async (err) => {
22890
- if (err instanceof ConnectError && errorCodeOf(err) === Code.ErrUnauthenticated) {
22891
- attachment.doc.publish([
22892
- {
22893
- type: DocEventType.AuthError,
22894
- value: {
22895
- reason: errorMetadataOf(err).reason,
22896
- method: "PushPull"
22897
- }
22898
- }
22899
- ]);
22900
- }
22901
- throw err;
22902
- }
22903
- )
22904
- );
22905
- }
22906
- }
22907
- Promise.all(syncJobs).then(() => setTimeout(doLoop, this.syncLoopDuration)).catch(async (err) => {
22908
- logger.error(`[SL] c:"${this.getKey()}" sync failed:`, err);
22909
- if (await this.handleConnectError(err)) {
22910
- setTimeout(doLoop, this.retrySyncLoopDelay);
22911
- } else {
22912
- this.conditions[
22913
- "SyncLoop"
22914
- /* SyncLoop */
22915
- ] = false;
22916
- }
22917
- });
22918
- };
22919
- logger.debug(`[SL] c:"${this.getKey()}" run sync loop`);
22920
- this.conditions[
22921
- "SyncLoop"
22922
- /* SyncLoop */
22923
- ] = true;
22924
- doLoop();
20505
+ const prevSyncMode = attachment.syncMode;
20506
+ if (prevSyncMode === syncMode) {
20507
+ return doc;
20508
+ }
20509
+ attachment.changeSyncMode(syncMode);
20510
+ if (syncMode === "manual") {
20511
+ attachment.cancelWatchStream();
20512
+ return doc;
20513
+ }
20514
+ if (syncMode === "realtime") {
20515
+ attachment.remoteChangeEventReceived = true;
20516
+ }
20517
+ if (prevSyncMode === "manual") {
20518
+ await this.runWatchLoop(doc.getKey());
20519
+ }
20520
+ return doc;
22925
20521
  }
22926
20522
  /**
22927
- * `runWatchLoop` runs the watch loop for the given document. The watch loop
22928
- * listens to the events of the given document from the server.
20523
+ * `sync` pushes local changes of the attached documents to the server and
20524
+ * receives changes of the remote replica from the server then apply them to
20525
+ * local documents.
22929
20526
  */
22930
- async runWatchLoop(docKey) {
22931
- const attachment = this.attachmentMap.get(docKey);
22932
- if (!attachment) {
20527
+ sync(doc) {
20528
+ if (!this.isActive()) {
22933
20529
  throw new YorkieError(
22934
- Code.ErrDocumentNotAttached,
22935
- `${docKey} is not attached`
20530
+ Code.ErrClientNotActivated,
20531
+ `${this.key} is not active`
22936
20532
  );
22937
20533
  }
22938
- this.conditions[
22939
- "WatchLoop"
22940
- /* WatchLoop */
22941
- ] = true;
22942
- return attachment.runWatchLoop(
22943
- (onDisconnect) => {
22944
- if (!this.isActive()) {
22945
- this.conditions[
22946
- "WatchLoop"
22947
- /* WatchLoop */
22948
- ] = false;
22949
- return Promise.reject(
22950
- new YorkieError(
22951
- Code.ErrClientNotActivated,
22952
- `${this.key} is not active`
22953
- )
22954
- );
22955
- }
22956
- const ac = new AbortController();
22957
- const stream = this.rpcClient.watchDocument(
22958
- {
22959
- clientId: this.id,
22960
- documentId: attachment.docID
22961
- },
22962
- {
22963
- headers: { "x-shard-key": `${this.apiKey}/${docKey}` },
22964
- signal: ac.signal
22965
- }
20534
+ if (doc) {
20535
+ const attachment = this.attachmentMap.get(doc.getKey());
20536
+ if (!attachment) {
20537
+ throw new YorkieError(
20538
+ Code.ErrDocumentNotAttached,
20539
+ `${doc.getKey()} is not attached`
22966
20540
  );
22967
- attachment.doc.publish([
22968
- {
22969
- type: DocEventType.ConnectionChanged,
22970
- value: StreamConnectionStatus.Connected
22971
- }
22972
- ]);
22973
- logger.info(`[WD] c:"${this.getKey()}" watches d:"${docKey}"`);
22974
- return new Promise((resolve, reject) => {
22975
- const handleStream = async () => {
22976
- try {
22977
- for await (const resp of stream) {
22978
- this.handleWatchDocumentsResponse(attachment, resp);
22979
- if (resp.body.case === "initialization") {
22980
- resolve([stream, ac]);
22981
- }
22982
- }
22983
- } catch (err) {
22984
- attachment.doc.resetOnlineClients();
22985
- attachment.doc.publish([
22986
- {
22987
- type: DocEventType.Initialized,
22988
- source: OpSource.Local,
22989
- value: attachment.doc.getPresences()
22990
- }
22991
- ]);
22992
- attachment.doc.publish([
22993
- {
22994
- type: DocEventType.ConnectionChanged,
22995
- value: StreamConnectionStatus.Disconnected
22996
- }
22997
- ]);
22998
- logger.debug(`[WD] c:"${this.getKey()}" unwatches`);
22999
- if (await this.handleConnectError(err)) {
23000
- if (err instanceof ConnectError && errorCodeOf(err) === Code.ErrUnauthenticated) {
23001
- attachment.doc.publish([
23002
- {
23003
- type: DocEventType.AuthError,
23004
- value: {
23005
- reason: errorMetadataOf(err).reason,
23006
- method: "WatchDocuments"
23007
- }
23008
- }
23009
- ]);
23010
- }
23011
- onDisconnect();
23012
- } else {
23013
- this.conditions[
23014
- "WatchLoop"
23015
- /* WatchLoop */
23016
- ] = false;
23017
- }
23018
- reject(err);
23019
- }
23020
- };
23021
- handleStream();
23022
- });
23023
20541
  }
23024
- );
23025
- }
23026
- handleWatchDocumentsResponse(attachment, resp) {
23027
- if (resp.body.case === "event" && resp.body.value.type === DocEventType$1.DOCUMENT_CHANGED) {
23028
- attachment.remoteChangeEventReceived = true;
23029
- return;
20542
+ return this.enqueueTask(async () => {
20543
+ return this.syncInternal(
20544
+ attachment,
20545
+ "realtime"
20546
+ /* Realtime */
20547
+ ).catch(
20548
+ async (err) => {
20549
+ logger.error(`[SY] c:"${this.getKey()}" err :`, err);
20550
+ await this.handleConnectError(err);
20551
+ throw err;
20552
+ }
20553
+ );
20554
+ });
23030
20555
  }
23031
- attachment.doc.applyWatchStream(resp);
20556
+ return this.enqueueTask(async () => {
20557
+ const promises = [];
20558
+ for (const [, attachment] of this.attachmentMap) {
20559
+ promises.push(this.syncInternal(attachment, attachment.syncMode));
20560
+ }
20561
+ return Promise.all(promises).catch(async (err) => {
20562
+ logger.error(`[SY] c:"${this.getKey()}" err :`, err);
20563
+ await this.handleConnectError(err);
20564
+ throw err;
20565
+ });
20566
+ });
23032
20567
  }
23033
- deactivateInternal() {
23034
- this.status = "deactivated";
23035
- for (const [key, attachment] of this.attachmentMap) {
23036
- this.detachInternal(key);
23037
- attachment.doc.applyStatus(DocStatus.Detached);
20568
+ /**
20569
+ * `remove` removes the given document.
20570
+ */
20571
+ remove(doc) {
20572
+ if (!this.isActive()) {
20573
+ throw new YorkieError(
20574
+ Code.ErrClientNotActivated,
20575
+ `${this.key} is not active`
20576
+ );
23038
20577
  }
23039
- }
23040
- detachInternal(docKey) {
23041
- const attachment = this.attachmentMap.get(docKey);
20578
+ const attachment = this.attachmentMap.get(doc.getKey());
23042
20579
  if (!attachment) {
23043
- return;
20580
+ throw new YorkieError(
20581
+ Code.ErrDocumentNotAttached,
20582
+ `${doc.getKey()} is not attached`
20583
+ );
23044
20584
  }
23045
- attachment.cancelWatchStream();
23046
- attachment.unsubscribeBroadcastEvent();
23047
- this.attachmentMap.delete(docKey);
23048
- }
23049
- syncInternal(attachment, syncMode) {
23050
- const { doc, docID } = attachment;
23051
- const reqPack = doc.createChangePack();
23052
- return this.rpcClient.pushPullChanges(
23053
- {
23054
- clientId: this.id,
23055
- documentId: docID,
23056
- changePack: converter.toChangePack(reqPack),
23057
- pushOnly: syncMode === "realtime-pushonly"
23058
- /* RealtimePushOnly */
23059
- },
23060
- { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
23061
- ).then((res) => {
23062
- const respPack = converter.fromChangePack(res.changePack);
23063
- if (respPack.hasChanges() && (attachment.syncMode === "realtime-pushonly" || attachment.syncMode === "realtime-syncoff")) {
23064
- return doc;
23065
- }
23066
- doc.applyChangePack(respPack);
23067
- attachment.doc.publish([
20585
+ doc.setActor(this.id);
20586
+ const pbChangePack = converter.toChangePack(doc.createChangePack());
20587
+ pbChangePack.isRemoved = true;
20588
+ return this.enqueueTask(async () => {
20589
+ return this.rpcClient.removeDocument(
23068
20590
  {
23069
- type: DocEventType.SyncStatusChanged,
23070
- value: DocSyncStatus.Synced
23071
- }
23072
- ]);
23073
- if (doc.getStatus() === DocStatus.Removed) {
20591
+ clientId: this.id,
20592
+ documentId: attachment.docID,
20593
+ changePack: pbChangePack
20594
+ },
20595
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
20596
+ ).then((res) => {
20597
+ const pack = converter.fromChangePack(res.changePack);
20598
+ doc.applyChangePack(pack);
23074
20599
  this.detachInternal(doc.getKey());
23075
- }
23076
- const docKey = doc.getKey();
23077
- const remoteSize = respPack.getChangeSize();
23078
- logger.info(
23079
- `[PP] c:"${this.getKey()}" sync d:"${docKey}", push:${reqPack.getChangeSize()} pull:${remoteSize} cp:${respPack.getCheckpoint().toTestString()}`
23080
- );
23081
- return doc;
23082
- }).catch(async (err) => {
23083
- doc.publish([
23084
- {
23085
- type: DocEventType.SyncStatusChanged,
23086
- value: DocSyncStatus.SyncFailed
23087
- }
23088
- ]);
23089
- logger.error(`[PP] c:"${this.getKey()}" err :`, err);
23090
- throw err;
20600
+ logger.info(`[RD] c:"${this.getKey()}" removes d:"${doc.getKey()}"`);
20601
+ }).catch(async (err) => {
20602
+ logger.error(`[RD] c:"${this.getKey()}" err :`, err);
20603
+ await this.handleConnectError(err);
20604
+ throw err;
20605
+ });
23091
20606
  });
23092
20607
  }
23093
20608
  /**
23094
- * `handleConnectError` handles the given error. If the given error can be
23095
- * retried after handling, it returns true.
20609
+ * `getID` returns a ActorID of client.
20610
+ */
20611
+ getID() {
20612
+ return this.id;
20613
+ }
20614
+ /**
20615
+ * `getKey` returns a key of client.
20616
+ */
20617
+ getKey() {
20618
+ return this.key;
20619
+ }
20620
+ /**
20621
+ * `isActive` checks if the client is active.
20622
+ */
20623
+ isActive() {
20624
+ return this.status === "activated";
20625
+ }
20626
+ /**
20627
+ * `getStatus` returns the status of this client.
23096
20628
  */
23097
- async handleConnectError(err) {
23098
- if (!(err instanceof ConnectError)) {
23099
- return false;
23100
- }
23101
- if (err.code === Code$1.Canceled || err.code === Code$1.Unknown || err.code === Code$1.ResourceExhausted || err.code === Code$1.Unavailable) {
23102
- return true;
23103
- }
23104
- if (errorCodeOf(err) === Code.ErrUnauthenticated) {
23105
- if (this.authTokenInjector) {
23106
- const token = await this.authTokenInjector(errorMetadataOf(err).reason);
23107
- this.setAuthToken(token);
23108
- }
23109
- return true;
23110
- }
23111
- if (errorCodeOf(err) === Code.ErrClientNotActivated || errorCodeOf(err) === Code.ErrClientNotFound) {
23112
- this.deactivateInternal();
23113
- }
23114
- return false;
20629
+ getStatus() {
20630
+ return this.status;
23115
20631
  }
23116
20632
  /**
23117
- * `enqueueTask` enqueues the given task to the task queue.
20633
+ * `getCondition` returns the condition of this client.
23118
20634
  */
23119
- enqueueTask(task) {
23120
- return new Promise((resolve, reject) => {
23121
- this.taskQueue.push(() => task().then(resolve).catch(reject));
23122
- if (!this.processing) {
23123
- this.processNext();
23124
- }
23125
- });
20635
+ getCondition(condition) {
20636
+ return this.conditions[condition];
23126
20637
  }
23127
20638
  /**
23128
- * `processNext` processes the next task in the task queue. This method is
23129
- * part of enqueueTask.
20639
+ * `broadcast` broadcasts the given payload to the given topic.
23130
20640
  */
23131
- async processNext() {
23132
- if (this.taskQueue.length === 0) {
23133
- this.processing = false;
23134
- return;
20641
+ broadcast(docKey, topic, payload, options) {
20642
+ if (!this.isActive()) {
20643
+ throw new YorkieError(
20644
+ Code.ErrClientNotActivated,
20645
+ `${this.key} is not active`
20646
+ );
23135
20647
  }
23136
- try {
23137
- this.processing = true;
23138
- const task = this.taskQueue.shift();
23139
- await task();
23140
- } catch (error) {
23141
- logger.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`);
20648
+ const attachment = this.attachmentMap.get(docKey);
20649
+ if (!attachment) {
20650
+ throw new YorkieError(
20651
+ Code.ErrDocumentNotAttached,
20652
+ `${docKey} is not attached`
20653
+ );
23142
20654
  }
23143
- this.processNext();
23144
- }
23145
- }
23146
- ({
23147
- IntType: CounterType.IntegerCnt,
23148
- LongType: CounterType.LongCnt
23149
- });
23150
- if (typeof globalThis !== "undefined") {
23151
- globalThis.yorkie = {
23152
- Client,
23153
- Document,
23154
- Primitive,
23155
- Text,
23156
- Counter,
23157
- Tree,
23158
- LogLevel,
23159
- setLogLevel,
23160
- IntType: CounterType.IntegerCnt,
23161
- LongType: CounterType.LongCnt
23162
- };
23163
- }
23164
- function useYorkieDoc(apiKey, docKey, initialRoot, options) {
23165
- const [client, setClient] = reactExports.useState(void 0);
23166
- const [doc, setDoc] = reactExports.useState(void 0);
23167
- const [root, setRoot] = reactExports.useState(initialRoot);
23168
- const [loading, setLoading] = reactExports.useState(true);
23169
- const [error, setError] = reactExports.useState(void 0);
23170
- reactExports.useEffect(() => {
23171
- setLoading(true);
23172
- setError(void 0);
23173
- async function setupYorkie() {
23174
- try {
23175
- const client2 = new Client(
23176
- (options == null ? void 0 : options.rpcAddr) || "https://api.yorkie.dev",
23177
- { apiKey }
23178
- );
23179
- await client2.activate();
23180
- const doc2 = new Document(docKey);
23181
- await client2.attach(doc2, {
23182
- initialPresence: {},
23183
- initialRoot
23184
- });
23185
- doc2.subscribe((event) => {
23186
- if (event.type === "remote-change" || event.type === "local-change") {
23187
- setRoot(doc2.getRoot());
23188
- }
23189
- });
23190
- setClient(client2);
23191
- setDoc(doc2);
23192
- setRoot(doc2.getRoot());
23193
- } catch (err) {
23194
- setError(err instanceof Error ? err : new Error("Unknown error"));
23195
- } finally {
23196
- setLoading(false);
23197
- }
20655
+ if (!validateSerializable(payload)) {
20656
+ throw new YorkieError(
20657
+ Code.ErrInvalidArgument,
20658
+ "payload is not serializable"
20659
+ );
23198
20660
  }
23199
- setupYorkie();
23200
- return () => {
23201
- client == null ? void 0 : client.deactivate({ keepalive: true });
23202
- };
23203
- }, [apiKey, docKey, JSON.stringify(initialRoot), JSON.stringify(options)]);
23204
- const update = reactExports.useCallback(
23205
- (callback) => {
23206
- if (!doc) {
23207
- console.warn("Attempted to update document before it was initialized");
23208
- return;
23209
- }
23210
- doc.update((root2) => {
23211
- callback(root2);
23212
- });
23213
- },
23214
- [doc]
23215
- );
23216
- return {
23217
- root,
23218
- update,
23219
- loading,
23220
- error
23221
- };
23222
- }
23223
- var jsxRuntime = { exports: {} };
23224
- var reactJsxRuntime_production_min = {};
23225
- /**
23226
- * @license React
23227
- * react-jsx-runtime.production.min.js
23228
- *
23229
- * Copyright (c) Facebook, Inc. and its affiliates.
23230
- *
23231
- * This source code is licensed under the MIT license found in the
23232
- * LICENSE file in the root directory of this source tree.
23233
- */
23234
- var hasRequiredReactJsxRuntime_production_min;
23235
- function requireReactJsxRuntime_production_min() {
23236
- if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
23237
- hasRequiredReactJsxRuntime_production_min = 1;
23238
- var f = requireReact(), k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
23239
- function q(c, a, g) {
23240
- var b, d = {}, e = null, h = null;
23241
- void 0 !== g && (e = "" + g);
23242
- void 0 !== a.key && (e = "" + a.key);
23243
- void 0 !== a.ref && (h = a.ref);
23244
- for (b in a) m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
23245
- if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
23246
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
23247
- }
23248
- reactJsxRuntime_production_min.Fragment = l;
23249
- reactJsxRuntime_production_min.jsx = q;
23250
- reactJsxRuntime_production_min.jsxs = q;
23251
- return reactJsxRuntime_production_min;
23252
- }
23253
- var reactJsxRuntime_development = {};
23254
- /**
23255
- * @license React
23256
- * react-jsx-runtime.development.js
23257
- *
23258
- * Copyright (c) Facebook, Inc. and its affiliates.
23259
- *
23260
- * This source code is licensed under the MIT license found in the
23261
- * LICENSE file in the root directory of this source tree.
23262
- */
23263
- var hasRequiredReactJsxRuntime_development;
23264
- function requireReactJsxRuntime_development() {
23265
- if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
23266
- hasRequiredReactJsxRuntime_development = 1;
23267
- if (process.env.NODE_ENV !== "production") {
23268
- (function() {
23269
- var React = requireReact();
23270
- var REACT_ELEMENT_TYPE = Symbol.for("react.element");
23271
- var REACT_PORTAL_TYPE = Symbol.for("react.portal");
23272
- var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
23273
- var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
23274
- var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
23275
- var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
23276
- var REACT_CONTEXT_TYPE = Symbol.for("react.context");
23277
- var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
23278
- var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
23279
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
23280
- var REACT_MEMO_TYPE = Symbol.for("react.memo");
23281
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
23282
- var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
23283
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
23284
- var FAUX_ITERATOR_SYMBOL = "@@iterator";
23285
- function getIteratorFn(maybeIterable) {
23286
- if (maybeIterable === null || typeof maybeIterable !== "object") {
23287
- return null;
23288
- }
23289
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
23290
- if (typeof maybeIterator === "function") {
23291
- return maybeIterator;
23292
- }
23293
- return null;
23294
- }
23295
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
23296
- function error(format) {
23297
- {
23298
- {
23299
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
23300
- args[_key2 - 1] = arguments[_key2];
23301
- }
23302
- printWarning("error", format, args);
23303
- }
23304
- }
23305
- }
23306
- function printWarning(level2, format, args) {
23307
- {
23308
- var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
23309
- var stack = ReactDebugCurrentFrame2.getStackAddendum();
23310
- if (stack !== "") {
23311
- format += "%s";
23312
- args = args.concat([stack]);
23313
- }
23314
- var argsWithFormat = args.map(function(item) {
23315
- return String(item);
23316
- });
23317
- argsWithFormat.unshift("Warning: " + format);
23318
- Function.prototype.apply.call(console[level2], console, argsWithFormat);
23319
- }
23320
- }
23321
- var enableScopeAPI = false;
23322
- var enableCacheElement = false;
23323
- var enableTransitionTracing = false;
23324
- var enableLegacyHidden = false;
23325
- var enableDebugTracing = false;
23326
- var REACT_MODULE_REFERENCE;
23327
- {
23328
- REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
23329
- }
23330
- function isValidElementType(type) {
23331
- if (typeof type === "string" || typeof type === "function") {
23332
- return true;
23333
- }
23334
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
23335
- return true;
23336
- }
23337
- if (typeof type === "object" && type !== null) {
23338
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
23339
- // types supported by any Flight configuration anywhere since
23340
- // we don't know which Flight build this will end up being used
23341
- // with.
23342
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
23343
- return true;
23344
- }
23345
- }
23346
- return false;
23347
- }
23348
- function getWrappedName(outerType, innerType, wrapperName) {
23349
- var displayName = outerType.displayName;
23350
- if (displayName) {
23351
- return displayName;
23352
- }
23353
- var functionName = innerType.displayName || innerType.name || "";
23354
- return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
23355
- }
23356
- function getContextName(type) {
23357
- return type.displayName || "Context";
23358
- }
23359
- function getComponentNameFromType(type) {
23360
- if (type == null) {
23361
- return null;
23362
- }
23363
- {
23364
- if (typeof type.tag === "number") {
23365
- error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
23366
- }
23367
- }
23368
- if (typeof type === "function") {
23369
- return type.displayName || type.name || null;
23370
- }
23371
- if (typeof type === "string") {
23372
- return type;
23373
- }
23374
- switch (type) {
23375
- case REACT_FRAGMENT_TYPE:
23376
- return "Fragment";
23377
- case REACT_PORTAL_TYPE:
23378
- return "Portal";
23379
- case REACT_PROFILER_TYPE:
23380
- return "Profiler";
23381
- case REACT_STRICT_MODE_TYPE:
23382
- return "StrictMode";
23383
- case REACT_SUSPENSE_TYPE:
23384
- return "Suspense";
23385
- case REACT_SUSPENSE_LIST_TYPE:
23386
- return "SuspenseList";
23387
- }
23388
- if (typeof type === "object") {
23389
- switch (type.$$typeof) {
23390
- case REACT_CONTEXT_TYPE:
23391
- var context = type;
23392
- return getContextName(context) + ".Consumer";
23393
- case REACT_PROVIDER_TYPE:
23394
- var provider = type;
23395
- return getContextName(provider._context) + ".Provider";
23396
- case REACT_FORWARD_REF_TYPE:
23397
- return getWrappedName(type, type.render, "ForwardRef");
23398
- case REACT_MEMO_TYPE:
23399
- var outerName = type.displayName || null;
23400
- if (outerName !== null) {
23401
- return outerName;
23402
- }
23403
- return getComponentNameFromType(type.type) || "Memo";
23404
- case REACT_LAZY_TYPE: {
23405
- var lazyComponent = type;
23406
- var payload = lazyComponent._payload;
23407
- var init = lazyComponent._init;
23408
- try {
23409
- return getComponentNameFromType(init(payload));
23410
- } catch (x) {
23411
- return null;
23412
- }
23413
- }
23414
- }
23415
- }
23416
- return null;
23417
- }
23418
- var assign = Object.assign;
23419
- var disabledDepth = 0;
23420
- var prevLog;
23421
- var prevInfo;
23422
- var prevWarn;
23423
- var prevError;
23424
- var prevGroup;
23425
- var prevGroupCollapsed;
23426
- var prevGroupEnd;
23427
- function disabledLog() {
23428
- }
23429
- disabledLog.__reactDisabledLog = true;
23430
- function disableLogs() {
23431
- {
23432
- if (disabledDepth === 0) {
23433
- prevLog = console.log;
23434
- prevInfo = console.info;
23435
- prevWarn = console.warn;
23436
- prevError = console.error;
23437
- prevGroup = console.group;
23438
- prevGroupCollapsed = console.groupCollapsed;
23439
- prevGroupEnd = console.groupEnd;
23440
- var props = {
23441
- configurable: true,
23442
- enumerable: true,
23443
- value: disabledLog,
23444
- writable: true
23445
- };
23446
- Object.defineProperties(console, {
23447
- info: props,
23448
- log: props,
23449
- warn: props,
23450
- error: props,
23451
- group: props,
23452
- groupCollapsed: props,
23453
- groupEnd: props
23454
- });
23455
- }
23456
- disabledDepth++;
23457
- }
23458
- }
23459
- function reenableLogs() {
23460
- {
23461
- disabledDepth--;
23462
- if (disabledDepth === 0) {
23463
- var props = {
23464
- configurable: true,
23465
- enumerable: true,
23466
- writable: true
23467
- };
23468
- Object.defineProperties(console, {
23469
- log: assign({}, props, {
23470
- value: prevLog
23471
- }),
23472
- info: assign({}, props, {
23473
- value: prevInfo
23474
- }),
23475
- warn: assign({}, props, {
23476
- value: prevWarn
23477
- }),
23478
- error: assign({}, props, {
23479
- value: prevError
23480
- }),
23481
- group: assign({}, props, {
23482
- value: prevGroup
23483
- }),
23484
- groupCollapsed: assign({}, props, {
23485
- value: prevGroupCollapsed
23486
- }),
23487
- groupEnd: assign({}, props, {
23488
- value: prevGroupEnd
23489
- })
23490
- });
23491
- }
23492
- if (disabledDepth < 0) {
23493
- error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
23494
- }
23495
- }
23496
- }
23497
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
23498
- var prefix;
23499
- function describeBuiltInComponentFrame(name2, source, ownerFn) {
23500
- {
23501
- if (prefix === void 0) {
23502
- try {
23503
- throw Error();
23504
- } catch (x) {
23505
- var match = x.stack.trim().match(/\n( *(at )?)/);
23506
- prefix = match && match[1] || "";
23507
- }
23508
- }
23509
- return "\n" + prefix + name2;
23510
- }
23511
- }
23512
- var reentry = false;
23513
- var componentFrameCache;
23514
- {
23515
- var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
23516
- componentFrameCache = new PossiblyWeakMap();
23517
- }
23518
- function describeNativeComponentFrame(fn, construct) {
23519
- if (!fn || reentry) {
23520
- return "";
23521
- }
23522
- {
23523
- var frame = componentFrameCache.get(fn);
23524
- if (frame !== void 0) {
23525
- return frame;
23526
- }
23527
- }
23528
- var control;
23529
- reentry = true;
23530
- var previousPrepareStackTrace = Error.prepareStackTrace;
23531
- Error.prepareStackTrace = void 0;
23532
- var previousDispatcher;
23533
- {
23534
- previousDispatcher = ReactCurrentDispatcher.current;
23535
- ReactCurrentDispatcher.current = null;
23536
- disableLogs();
23537
- }
23538
- try {
23539
- if (construct) {
23540
- var Fake = function() {
23541
- throw Error();
23542
- };
23543
- Object.defineProperty(Fake.prototype, "props", {
23544
- set: function() {
23545
- throw Error();
23546
- }
23547
- });
23548
- if (typeof Reflect === "object" && Reflect.construct) {
23549
- try {
23550
- Reflect.construct(Fake, []);
23551
- } catch (x) {
23552
- control = x;
23553
- }
23554
- Reflect.construct(fn, [], Fake);
23555
- } else {
23556
- try {
23557
- Fake.call();
23558
- } catch (x) {
23559
- control = x;
23560
- }
23561
- fn.call(Fake.prototype);
23562
- }
23563
- } else {
23564
- try {
23565
- throw Error();
23566
- } catch (x) {
23567
- control = x;
23568
- }
23569
- fn();
23570
- }
23571
- } catch (sample) {
23572
- if (sample && control && typeof sample.stack === "string") {
23573
- var sampleLines = sample.stack.split("\n");
23574
- var controlLines = control.stack.split("\n");
23575
- var s = sampleLines.length - 1;
23576
- var c = controlLines.length - 1;
23577
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
23578
- c--;
23579
- }
23580
- for (; s >= 1 && c >= 0; s--, c--) {
23581
- if (sampleLines[s] !== controlLines[c]) {
23582
- if (s !== 1 || c !== 1) {
23583
- do {
23584
- s--;
23585
- c--;
23586
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
23587
- var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
23588
- if (fn.displayName && _frame.includes("<anonymous>")) {
23589
- _frame = _frame.replace("<anonymous>", fn.displayName);
23590
- }
23591
- {
23592
- if (typeof fn === "function") {
23593
- componentFrameCache.set(fn, _frame);
23594
- }
23595
- }
23596
- return _frame;
23597
- }
23598
- } while (s >= 1 && c >= 0);
23599
- }
23600
- break;
23601
- }
23602
- }
23603
- }
23604
- } finally {
23605
- reentry = false;
23606
- {
23607
- ReactCurrentDispatcher.current = previousDispatcher;
23608
- reenableLogs();
23609
- }
23610
- Error.prepareStackTrace = previousPrepareStackTrace;
23611
- }
23612
- var name2 = fn ? fn.displayName || fn.name : "";
23613
- var syntheticFrame = name2 ? describeBuiltInComponentFrame(name2) : "";
23614
- {
23615
- if (typeof fn === "function") {
23616
- componentFrameCache.set(fn, syntheticFrame);
23617
- }
23618
- }
23619
- return syntheticFrame;
23620
- }
23621
- function describeFunctionComponentFrame(fn, source, ownerFn) {
23622
- {
23623
- return describeNativeComponentFrame(fn, false);
23624
- }
23625
- }
23626
- function shouldConstruct(Component) {
23627
- var prototype = Component.prototype;
23628
- return !!(prototype && prototype.isReactComponent);
23629
- }
23630
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
23631
- if (type == null) {
23632
- return "";
23633
- }
23634
- if (typeof type === "function") {
23635
- {
23636
- return describeNativeComponentFrame(type, shouldConstruct(type));
23637
- }
23638
- }
23639
- if (typeof type === "string") {
23640
- return describeBuiltInComponentFrame(type);
23641
- }
23642
- switch (type) {
23643
- case REACT_SUSPENSE_TYPE:
23644
- return describeBuiltInComponentFrame("Suspense");
23645
- case REACT_SUSPENSE_LIST_TYPE:
23646
- return describeBuiltInComponentFrame("SuspenseList");
23647
- }
23648
- if (typeof type === "object") {
23649
- switch (type.$$typeof) {
23650
- case REACT_FORWARD_REF_TYPE:
23651
- return describeFunctionComponentFrame(type.render);
23652
- case REACT_MEMO_TYPE:
23653
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
23654
- case REACT_LAZY_TYPE: {
23655
- var lazyComponent = type;
23656
- var payload = lazyComponent._payload;
23657
- var init = lazyComponent._init;
23658
- try {
23659
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
23660
- } catch (x) {
23661
- }
23662
- }
23663
- }
23664
- }
23665
- return "";
23666
- }
23667
- var hasOwnProperty = Object.prototype.hasOwnProperty;
23668
- var loggedTypeFailures = {};
23669
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
23670
- function setCurrentlyValidatingElement(element) {
23671
- {
23672
- if (element) {
23673
- var owner = element._owner;
23674
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
23675
- ReactDebugCurrentFrame.setExtraStackFrame(stack);
23676
- } else {
23677
- ReactDebugCurrentFrame.setExtraStackFrame(null);
23678
- }
23679
- }
23680
- }
23681
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
23682
- {
23683
- var has = Function.call.bind(hasOwnProperty);
23684
- for (var typeSpecName in typeSpecs) {
23685
- if (has(typeSpecs, typeSpecName)) {
23686
- var error$1 = void 0;
23687
- try {
23688
- if (typeof typeSpecs[typeSpecName] !== "function") {
23689
- var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
23690
- err.name = "Invariant Violation";
23691
- throw err;
20661
+ const maxRetries = (options == null ? void 0 : options.maxRetries) ?? DefaultBroadcastOptions.maxRetries;
20662
+ const maxBackoff = DefaultBroadcastOptions.maxBackoff;
20663
+ let retryCount = 0;
20664
+ const exponentialBackoff = (retryCount2) => {
20665
+ const retryInterval = Math.min(
20666
+ DefaultBroadcastOptions.initialRetryInterval * 2 ** retryCount2,
20667
+ maxBackoff
20668
+ );
20669
+ return retryInterval;
20670
+ };
20671
+ const doLoop = async () => {
20672
+ return this.enqueueTask(async () => {
20673
+ return this.rpcClient.broadcast(
20674
+ {
20675
+ clientId: this.id,
20676
+ documentId: attachment.docID,
20677
+ topic,
20678
+ payload: new TextEncoder().encode(JSON.stringify(payload))
20679
+ },
20680
+ { headers: { "x-shard-key": `${this.apiKey}/${docKey}` } }
20681
+ ).then(() => {
20682
+ logger.info(
20683
+ `[BC] c:"${this.getKey()}" broadcasts d:"${docKey}" t:"${topic}"`
20684
+ );
20685
+ }).catch(async (err) => {
20686
+ logger.error(`[BC] c:"${this.getKey()}" err:`, err);
20687
+ if (await this.handleConnectError(err)) {
20688
+ if (err instanceof ConnectError && errorCodeOf(err) === Code.ErrUnauthenticated) {
20689
+ attachment.doc.publish([
20690
+ {
20691
+ type: DocEventType.AuthError,
20692
+ value: {
20693
+ reason: errorMetadataOf(err).reason,
20694
+ method: "Broadcast"
20695
+ }
23692
20696
  }
23693
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
23694
- } catch (ex) {
23695
- error$1 = ex;
23696
- }
23697
- if (error$1 && !(error$1 instanceof Error)) {
23698
- setCurrentlyValidatingElement(element);
23699
- error("%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).", componentName || "React class", location, typeSpecName, typeof error$1);
23700
- setCurrentlyValidatingElement(null);
23701
- }
23702
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
23703
- loggedTypeFailures[error$1.message] = true;
23704
- setCurrentlyValidatingElement(element);
23705
- error("Failed %s type: %s", location, error$1.message);
23706
- setCurrentlyValidatingElement(null);
23707
- }
23708
- }
23709
- }
23710
- }
23711
- }
23712
- var isArrayImpl = Array.isArray;
23713
- function isArray(a) {
23714
- return isArrayImpl(a);
23715
- }
23716
- function typeName(value) {
23717
- {
23718
- var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
23719
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
23720
- return type;
23721
- }
23722
- }
23723
- function willCoercionThrow(value) {
23724
- {
23725
- try {
23726
- testStringCoercion(value);
23727
- return false;
23728
- } catch (e) {
23729
- return true;
23730
- }
23731
- }
23732
- }
23733
- function testStringCoercion(value) {
23734
- return "" + value;
23735
- }
23736
- function checkKeyStringCoercion(value) {
23737
- {
23738
- if (willCoercionThrow(value)) {
23739
- error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
23740
- return testStringCoercion(value);
23741
- }
23742
- }
23743
- }
23744
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
23745
- var RESERVED_PROPS = {
23746
- key: true,
23747
- ref: true,
23748
- __self: true,
23749
- __source: true
23750
- };
23751
- var specialPropKeyWarningShown;
23752
- var specialPropRefWarningShown;
23753
- function hasValidRef(config) {
23754
- {
23755
- if (hasOwnProperty.call(config, "ref")) {
23756
- var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
23757
- if (getter && getter.isReactWarning) {
23758
- return false;
23759
- }
23760
- }
23761
- }
23762
- return config.ref !== void 0;
23763
- }
23764
- function hasValidKey(config) {
23765
- {
23766
- if (hasOwnProperty.call(config, "key")) {
23767
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
23768
- if (getter && getter.isReactWarning) {
23769
- return false;
23770
- }
23771
- }
23772
- }
23773
- return config.key !== void 0;
23774
- }
23775
- function warnIfStringRefCannotBeAutoConverted(config, self) {
23776
- {
23777
- if (typeof config.ref === "string" && ReactCurrentOwner.current && self) ;
23778
- }
23779
- }
23780
- function defineKeyPropWarningGetter(props, displayName) {
23781
- {
23782
- var warnAboutAccessingKey = function() {
23783
- if (!specialPropKeyWarningShown) {
23784
- specialPropKeyWarningShown = true;
23785
- error("%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)", displayName);
23786
- }
23787
- };
23788
- warnAboutAccessingKey.isReactWarning = true;
23789
- Object.defineProperty(props, "key", {
23790
- get: warnAboutAccessingKey,
23791
- configurable: true
23792
- });
23793
- }
23794
- }
23795
- function defineRefPropWarningGetter(props, displayName) {
23796
- {
23797
- var warnAboutAccessingRef = function() {
23798
- if (!specialPropRefWarningShown) {
23799
- specialPropRefWarningShown = true;
23800
- error("%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)", displayName);
23801
- }
23802
- };
23803
- warnAboutAccessingRef.isReactWarning = true;
23804
- Object.defineProperty(props, "ref", {
23805
- get: warnAboutAccessingRef,
23806
- configurable: true
23807
- });
23808
- }
23809
- }
23810
- var ReactElement = function(type, key, ref, self, source, owner, props) {
23811
- var element = {
23812
- // This tag allows us to uniquely identify this as a React Element
23813
- $$typeof: REACT_ELEMENT_TYPE,
23814
- // Built-in properties that belong on the element
23815
- type,
23816
- key,
23817
- ref,
23818
- props,
23819
- // Record the component responsible for creating this element.
23820
- _owner: owner
23821
- };
23822
- {
23823
- element._store = {};
23824
- Object.defineProperty(element._store, "validated", {
23825
- configurable: false,
23826
- enumerable: false,
23827
- writable: true,
23828
- value: false
23829
- });
23830
- Object.defineProperty(element, "_self", {
23831
- configurable: false,
23832
- enumerable: false,
23833
- writable: false,
23834
- value: self
23835
- });
23836
- Object.defineProperty(element, "_source", {
23837
- configurable: false,
23838
- enumerable: false,
23839
- writable: false,
23840
- value: source
23841
- });
23842
- if (Object.freeze) {
23843
- Object.freeze(element.props);
23844
- Object.freeze(element);
23845
- }
23846
- }
23847
- return element;
23848
- };
23849
- function jsxDEV(type, config, maybeKey, source, self) {
23850
- {
23851
- var propName;
23852
- var props = {};
23853
- var key = null;
23854
- var ref = null;
23855
- if (maybeKey !== void 0) {
23856
- {
23857
- checkKeyStringCoercion(maybeKey);
23858
- }
23859
- key = "" + maybeKey;
23860
- }
23861
- if (hasValidKey(config)) {
23862
- {
23863
- checkKeyStringCoercion(config.key);
23864
- }
23865
- key = "" + config.key;
23866
- }
23867
- if (hasValidRef(config)) {
23868
- ref = config.ref;
23869
- warnIfStringRefCannotBeAutoConverted(config, self);
23870
- }
23871
- for (propName in config) {
23872
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
23873
- props[propName] = config[propName];
23874
- }
23875
- }
23876
- if (type && type.defaultProps) {
23877
- var defaultProps = type.defaultProps;
23878
- for (propName in defaultProps) {
23879
- if (props[propName] === void 0) {
23880
- props[propName] = defaultProps[propName];
23881
- }
23882
- }
23883
- }
23884
- if (key || ref) {
23885
- var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
23886
- if (key) {
23887
- defineKeyPropWarningGetter(props, displayName);
20697
+ ]);
23888
20698
  }
23889
- if (ref) {
23890
- defineRefPropWarningGetter(props, displayName);
20699
+ if (retryCount < maxRetries) {
20700
+ retryCount++;
20701
+ setTimeout(() => doLoop(), exponentialBackoff(retryCount - 1));
20702
+ logger.info(
20703
+ `[BC] c:"${this.getKey()}" retry attempt ${retryCount}/${maxRetries}`
20704
+ );
20705
+ } else {
20706
+ logger.error(
20707
+ `[BC] c:"${this.getKey()}" exceeded maximum retry attempts`
20708
+ );
20709
+ throw err;
23891
20710
  }
23892
- }
23893
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
23894
- }
23895
- }
23896
- var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
23897
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
23898
- function setCurrentlyValidatingElement$1(element) {
23899
- {
23900
- if (element) {
23901
- var owner = element._owner;
23902
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
23903
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
23904
20711
  } else {
23905
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
23906
- }
23907
- }
23908
- }
23909
- var propTypesMisspellWarningShown;
23910
- {
23911
- propTypesMisspellWarningShown = false;
23912
- }
23913
- function isValidElement(object) {
23914
- {
23915
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
23916
- }
23917
- }
23918
- function getDeclarationErrorAddendum() {
23919
- {
23920
- if (ReactCurrentOwner$1.current) {
23921
- var name2 = getComponentNameFromType(ReactCurrentOwner$1.current.type);
23922
- if (name2) {
23923
- return "\n\nCheck the render method of `" + name2 + "`.";
23924
- }
23925
- }
23926
- return "";
23927
- }
23928
- }
23929
- function getSourceInfoErrorAddendum(source) {
23930
- {
23931
- return "";
23932
- }
23933
- }
23934
- var ownerHasKeyUseWarning = {};
23935
- function getCurrentComponentErrorInfo(parentType) {
23936
- {
23937
- var info = getDeclarationErrorAddendum();
23938
- if (!info) {
23939
- var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
23940
- if (parentName) {
23941
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
23942
- }
23943
- }
23944
- return info;
23945
- }
23946
- }
23947
- function validateExplicitKey(element, parentType) {
23948
- {
23949
- if (!element._store || element._store.validated || element.key != null) {
23950
- return;
23951
- }
23952
- element._store.validated = true;
23953
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
23954
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
23955
- return;
23956
- }
23957
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
23958
- var childOwner = "";
23959
- if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
23960
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
20712
+ throw err;
23961
20713
  }
23962
- setCurrentlyValidatingElement$1(element);
23963
- error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
23964
- setCurrentlyValidatingElement$1(null);
23965
- }
20714
+ });
20715
+ });
20716
+ };
20717
+ return doLoop();
20718
+ }
20719
+ /**
20720
+ * `runSyncLoop` runs the sync loop. The sync loop pushes local changes to
20721
+ * the server and pulls remote changes from the server.
20722
+ */
20723
+ runSyncLoop() {
20724
+ const doLoop = () => {
20725
+ if (!this.isActive()) {
20726
+ logger.debug(`[SL] c:"${this.getKey()}" exit sync loop`);
20727
+ this.conditions[
20728
+ "SyncLoop"
20729
+ /* SyncLoop */
20730
+ ] = false;
20731
+ return;
23966
20732
  }
23967
- function validateChildKeys(node, parentType) {
23968
- {
23969
- if (typeof node !== "object") {
23970
- return;
23971
- }
23972
- if (isArray(node)) {
23973
- for (var i = 0; i < node.length; i++) {
23974
- var child = node[i];
23975
- if (isValidElement(child)) {
23976
- validateExplicitKey(child, parentType);
23977
- }
23978
- }
23979
- } else if (isValidElement(node)) {
23980
- if (node._store) {
23981
- node._store.validated = true;
23982
- }
23983
- } else if (node) {
23984
- var iteratorFn = getIteratorFn(node);
23985
- if (typeof iteratorFn === "function") {
23986
- if (iteratorFn !== node.entries) {
23987
- var iterator = iteratorFn.call(node);
23988
- var step;
23989
- while (!(step = iterator.next()).done) {
23990
- if (isValidElement(step.value)) {
23991
- validateExplicitKey(step.value, parentType);
23992
- }
20733
+ const syncJobs = [];
20734
+ for (const [, attachment] of this.attachmentMap) {
20735
+ if (attachment.needRealtimeSync()) {
20736
+ attachment.remoteChangeEventReceived = false;
20737
+ syncJobs.push(
20738
+ this.syncInternal(attachment, attachment.syncMode).catch(
20739
+ async (err) => {
20740
+ if (err instanceof ConnectError && errorCodeOf(err) === Code.ErrUnauthenticated) {
20741
+ attachment.doc.publish([
20742
+ {
20743
+ type: DocEventType.AuthError,
20744
+ value: {
20745
+ reason: errorMetadataOf(err).reason,
20746
+ method: "PushPull"
20747
+ }
20748
+ }
20749
+ ]);
23993
20750
  }
20751
+ throw err;
23994
20752
  }
23995
- }
23996
- }
23997
- }
23998
- }
23999
- function validatePropTypes(element) {
24000
- {
24001
- var type = element.type;
24002
- if (type === null || type === void 0 || typeof type === "string") {
24003
- return;
24004
- }
24005
- var propTypes;
24006
- if (typeof type === "function") {
24007
- propTypes = type.propTypes;
24008
- } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
24009
- // Inner props are checked in the reconciler.
24010
- type.$$typeof === REACT_MEMO_TYPE)) {
24011
- propTypes = type.propTypes;
24012
- } else {
24013
- return;
24014
- }
24015
- if (propTypes) {
24016
- var name2 = getComponentNameFromType(type);
24017
- checkPropTypes(propTypes, element.props, "prop", name2, element);
24018
- } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
24019
- propTypesMisspellWarningShown = true;
24020
- var _name = getComponentNameFromType(type);
24021
- error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
24022
- }
24023
- if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
24024
- error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
24025
- }
20753
+ )
20754
+ );
24026
20755
  }
24027
20756
  }
24028
- function validateFragmentProps(fragment) {
24029
- {
24030
- var keys = Object.keys(fragment.props);
24031
- for (var i = 0; i < keys.length; i++) {
24032
- var key = keys[i];
24033
- if (key !== "children" && key !== "key") {
24034
- setCurrentlyValidatingElement$1(fragment);
24035
- error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
24036
- setCurrentlyValidatingElement$1(null);
24037
- break;
24038
- }
24039
- }
24040
- if (fragment.ref !== null) {
24041
- setCurrentlyValidatingElement$1(fragment);
24042
- error("Invalid attribute `ref` supplied to `React.Fragment`.");
24043
- setCurrentlyValidatingElement$1(null);
24044
- }
20757
+ Promise.all(syncJobs).then(() => setTimeout(doLoop, this.syncLoopDuration)).catch(async (err) => {
20758
+ logger.error(`[SL] c:"${this.getKey()}" sync failed:`, err);
20759
+ if (await this.handleConnectError(err)) {
20760
+ setTimeout(doLoop, this.retrySyncLoopDelay);
20761
+ } else {
20762
+ this.conditions[
20763
+ "SyncLoop"
20764
+ /* SyncLoop */
20765
+ ] = false;
24045
20766
  }
24046
- }
24047
- function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
24048
- {
24049
- var validType = isValidElementType(type);
24050
- if (!validType) {
24051
- var info = "";
24052
- if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
24053
- info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
24054
- }
24055
- var sourceInfo = getSourceInfoErrorAddendum();
24056
- if (sourceInfo) {
24057
- info += sourceInfo;
24058
- } else {
24059
- info += getDeclarationErrorAddendum();
24060
- }
24061
- var typeString;
24062
- if (type === null) {
24063
- typeString = "null";
24064
- } else if (isArray(type)) {
24065
- typeString = "array";
24066
- } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
24067
- typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
24068
- info = " Did you accidentally export a JSX literal instead of a component?";
24069
- } else {
24070
- typeString = typeof type;
24071
- }
24072
- error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
20767
+ });
20768
+ };
20769
+ logger.debug(`[SL] c:"${this.getKey()}" run sync loop`);
20770
+ this.conditions[
20771
+ "SyncLoop"
20772
+ /* SyncLoop */
20773
+ ] = true;
20774
+ doLoop();
20775
+ }
20776
+ /**
20777
+ * `runWatchLoop` runs the watch loop for the given document. The watch loop
20778
+ * listens to the events of the given document from the server.
20779
+ */
20780
+ async runWatchLoop(docKey) {
20781
+ const attachment = this.attachmentMap.get(docKey);
20782
+ if (!attachment) {
20783
+ throw new YorkieError(
20784
+ Code.ErrDocumentNotAttached,
20785
+ `${docKey} is not attached`
20786
+ );
20787
+ }
20788
+ this.conditions[
20789
+ "WatchLoop"
20790
+ /* WatchLoop */
20791
+ ] = true;
20792
+ return attachment.runWatchLoop(
20793
+ (onDisconnect) => {
20794
+ if (!this.isActive()) {
20795
+ this.conditions[
20796
+ "WatchLoop"
20797
+ /* WatchLoop */
20798
+ ] = false;
20799
+ return Promise.reject(
20800
+ new YorkieError(
20801
+ Code.ErrClientNotActivated,
20802
+ `${this.key} is not active`
20803
+ )
20804
+ );
20805
+ }
20806
+ const ac = new AbortController();
20807
+ const stream = this.rpcClient.watchDocument(
20808
+ {
20809
+ clientId: this.id,
20810
+ documentId: attachment.docID
20811
+ },
20812
+ {
20813
+ headers: { "x-shard-key": `${this.apiKey}/${docKey}` },
20814
+ signal: ac.signal
24073
20815
  }
24074
- var element = jsxDEV(type, props, key, source, self);
24075
- if (element == null) {
24076
- return element;
20816
+ );
20817
+ attachment.doc.publish([
20818
+ {
20819
+ type: DocEventType.ConnectionChanged,
20820
+ value: StreamConnectionStatus.Connected
24077
20821
  }
24078
- if (validType) {
24079
- var children = props.children;
24080
- if (children !== void 0) {
24081
- if (isStaticChildren) {
24082
- if (isArray(children)) {
24083
- for (var i = 0; i < children.length; i++) {
24084
- validateChildKeys(children[i], type);
24085
- }
24086
- if (Object.freeze) {
24087
- Object.freeze(children);
24088
- }
24089
- } else {
24090
- error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
20822
+ ]);
20823
+ logger.info(`[WD] c:"${this.getKey()}" watches d:"${docKey}"`);
20824
+ return new Promise((resolve, reject) => {
20825
+ const handleStream = async () => {
20826
+ try {
20827
+ for await (const resp of stream) {
20828
+ this.handleWatchDocumentsResponse(attachment, resp);
20829
+ if (resp.body.case === "initialization") {
20830
+ resolve([stream, ac]);
20831
+ }
20832
+ }
20833
+ } catch (err) {
20834
+ attachment.doc.resetOnlineClients();
20835
+ attachment.doc.publish([
20836
+ {
20837
+ type: DocEventType.Initialized,
20838
+ source: OpSource.Local,
20839
+ value: attachment.doc.getPresences()
20840
+ }
20841
+ ]);
20842
+ attachment.doc.publish([
20843
+ {
20844
+ type: DocEventType.ConnectionChanged,
20845
+ value: StreamConnectionStatus.Disconnected
20846
+ }
20847
+ ]);
20848
+ logger.debug(`[WD] c:"${this.getKey()}" unwatches`);
20849
+ if (await this.handleConnectError(err)) {
20850
+ if (err instanceof ConnectError && errorCodeOf(err) === Code.ErrUnauthenticated) {
20851
+ attachment.doc.publish([
20852
+ {
20853
+ type: DocEventType.AuthError,
20854
+ value: {
20855
+ reason: errorMetadataOf(err).reason,
20856
+ method: "WatchDocuments"
20857
+ }
20858
+ }
20859
+ ]);
24091
20860
  }
20861
+ onDisconnect();
24092
20862
  } else {
24093
- validateChildKeys(children, type);
20863
+ this.conditions[
20864
+ "WatchLoop"
20865
+ /* WatchLoop */
20866
+ ] = false;
24094
20867
  }
20868
+ reject(err);
24095
20869
  }
24096
- }
24097
- if (type === REACT_FRAGMENT_TYPE) {
24098
- validateFragmentProps(element);
24099
- } else {
24100
- validatePropTypes(element);
24101
- }
24102
- return element;
24103
- }
20870
+ };
20871
+ handleStream();
20872
+ });
20873
+ }
20874
+ );
20875
+ }
20876
+ handleWatchDocumentsResponse(attachment, resp) {
20877
+ if (resp.body.case === "event" && resp.body.value.type === DocEventType$1.DOCUMENT_CHANGED) {
20878
+ attachment.remoteChangeEventReceived = true;
20879
+ return;
20880
+ }
20881
+ attachment.doc.applyWatchStream(resp);
20882
+ }
20883
+ deactivateInternal() {
20884
+ this.status = "deactivated";
20885
+ for (const [key, attachment] of this.attachmentMap) {
20886
+ this.detachInternal(key);
20887
+ attachment.doc.applyStatus(DocStatus.Detached);
20888
+ }
20889
+ }
20890
+ detachInternal(docKey) {
20891
+ const attachment = this.attachmentMap.get(docKey);
20892
+ if (!attachment) {
20893
+ return;
20894
+ }
20895
+ attachment.cancelWatchStream();
20896
+ attachment.unsubscribeBroadcastEvent();
20897
+ this.attachmentMap.delete(docKey);
20898
+ }
20899
+ syncInternal(attachment, syncMode) {
20900
+ const { doc, docID } = attachment;
20901
+ const reqPack = doc.createChangePack();
20902
+ return this.rpcClient.pushPullChanges(
20903
+ {
20904
+ clientId: this.id,
20905
+ documentId: docID,
20906
+ changePack: converter.toChangePack(reqPack),
20907
+ pushOnly: syncMode === "realtime-pushonly"
20908
+ /* RealtimePushOnly */
20909
+ },
20910
+ { headers: { "x-shard-key": `${this.apiKey}/${doc.getKey()}` } }
20911
+ ).then((res) => {
20912
+ const respPack = converter.fromChangePack(res.changePack);
20913
+ if (respPack.hasChanges() && (attachment.syncMode === "realtime-pushonly" || attachment.syncMode === "realtime-syncoff")) {
20914
+ return doc;
24104
20915
  }
24105
- function jsxWithValidationStatic(type, props, key) {
20916
+ doc.applyChangePack(respPack);
20917
+ attachment.doc.publish([
24106
20918
  {
24107
- return jsxWithValidation(type, props, key, true);
20919
+ type: DocEventType.SyncStatusChanged,
20920
+ value: DocSyncStatus.Synced
24108
20921
  }
20922
+ ]);
20923
+ if (doc.getStatus() === DocStatus.Removed) {
20924
+ this.detachInternal(doc.getKey());
24109
20925
  }
24110
- function jsxWithValidationDynamic(type, props, key) {
20926
+ const docKey = doc.getKey();
20927
+ const remoteSize = respPack.getChangeSize();
20928
+ logger.info(
20929
+ `[PP] c:"${this.getKey()}" sync d:"${docKey}", push:${reqPack.getChangeSize()} pull:${remoteSize} cp:${respPack.getCheckpoint().toTestString()}`
20930
+ );
20931
+ return doc;
20932
+ }).catch(async (err) => {
20933
+ doc.publish([
24111
20934
  {
24112
- return jsxWithValidation(type, props, key, false);
20935
+ type: DocEventType.SyncStatusChanged,
20936
+ value: DocSyncStatus.SyncFailed
24113
20937
  }
20938
+ ]);
20939
+ logger.error(`[PP] c:"${this.getKey()}" err :`, err);
20940
+ throw err;
20941
+ });
20942
+ }
20943
+ /**
20944
+ * `handleConnectError` handles the given error. If the given error can be
20945
+ * retried after handling, it returns true.
20946
+ */
20947
+ async handleConnectError(err) {
20948
+ if (!(err instanceof ConnectError)) {
20949
+ return false;
20950
+ }
20951
+ if (err.code === Code$1.Canceled || err.code === Code$1.Unknown || err.code === Code$1.ResourceExhausted || err.code === Code$1.Unavailable) {
20952
+ return true;
20953
+ }
20954
+ if (errorCodeOf(err) === Code.ErrUnauthenticated) {
20955
+ if (this.authTokenInjector) {
20956
+ const token = await this.authTokenInjector(errorMetadataOf(err).reason);
20957
+ this.setAuthToken(token);
24114
20958
  }
24115
- var jsx = jsxWithValidationDynamic;
24116
- var jsxs = jsxWithValidationStatic;
24117
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
24118
- reactJsxRuntime_development.jsx = jsx;
24119
- reactJsxRuntime_development.jsxs = jsxs;
24120
- })();
24121
- }
24122
- return reactJsxRuntime_development;
24123
- }
24124
- var hasRequiredJsxRuntime;
24125
- function requireJsxRuntime() {
24126
- if (hasRequiredJsxRuntime) return jsxRuntime.exports;
24127
- hasRequiredJsxRuntime = 1;
24128
- if (process.env.NODE_ENV === "production") {
24129
- jsxRuntime.exports = requireReactJsxRuntime_production_min();
24130
- } else {
24131
- jsxRuntime.exports = requireReactJsxRuntime_development();
20959
+ return true;
20960
+ }
20961
+ if (errorCodeOf(err) === Code.ErrClientNotActivated || errorCodeOf(err) === Code.ErrClientNotFound) {
20962
+ this.deactivateInternal();
20963
+ }
20964
+ return false;
20965
+ }
20966
+ /**
20967
+ * `enqueueTask` enqueues the given task to the task queue.
20968
+ */
20969
+ enqueueTask(task) {
20970
+ return new Promise((resolve, reject) => {
20971
+ this.taskQueue.push(() => task().then(resolve).catch(reject));
20972
+ if (!this.processing) {
20973
+ this.processNext();
20974
+ }
20975
+ });
20976
+ }
20977
+ /**
20978
+ * `processNext` processes the next task in the task queue. This method is
20979
+ * part of enqueueTask.
20980
+ */
20981
+ async processNext() {
20982
+ if (this.taskQueue.length === 0) {
20983
+ this.processing = false;
20984
+ return;
20985
+ }
20986
+ try {
20987
+ this.processing = true;
20988
+ const task = this.taskQueue.shift();
20989
+ await task();
20990
+ } catch (error) {
20991
+ logger.error(`[TQ] c:"${this.getKey()}" process failed, id:"${this.id}"`);
20992
+ }
20993
+ this.processNext();
24132
20994
  }
24133
- return jsxRuntime.exports;
24134
20995
  }
24135
- var jsxRuntimeExports = requireJsxRuntime();
24136
- const YorkieContext = reactExports.createContext({
20996
+ ({
20997
+ IntType: CounterType.IntegerCnt,
20998
+ LongType: CounterType.LongCnt
20999
+ });
21000
+ if (typeof globalThis !== "undefined") {
21001
+ globalThis.yorkie = {
21002
+ Client,
21003
+ Document,
21004
+ Primitive,
21005
+ Text,
21006
+ Counter,
21007
+ Tree,
21008
+ LogLevel,
21009
+ setLogLevel,
21010
+ IntType: CounterType.IntegerCnt,
21011
+ LongType: CounterType.LongCnt
21012
+ };
21013
+ }
21014
+ function useYorkieDoc(apiKey, docKey, initialRoot, options) {
21015
+ const [client, setClient] = useState(void 0);
21016
+ const [doc, setDoc] = useState(void 0);
21017
+ const [root, setRoot] = useState(initialRoot);
21018
+ const [loading, setLoading] = useState(true);
21019
+ const [error, setError] = useState(void 0);
21020
+ useEffect(() => {
21021
+ setLoading(true);
21022
+ setError(void 0);
21023
+ async function setupYorkie() {
21024
+ try {
21025
+ const client2 = new Client(
21026
+ (options == null ? void 0 : options.rpcAddr) || "https://api.yorkie.dev",
21027
+ { apiKey }
21028
+ );
21029
+ await client2.activate();
21030
+ const doc2 = new Document(docKey);
21031
+ await client2.attach(doc2, {
21032
+ initialPresence: {},
21033
+ initialRoot
21034
+ });
21035
+ doc2.subscribe((event) => {
21036
+ if (event.type === "remote-change" || event.type === "local-change") {
21037
+ setRoot(doc2.getRoot());
21038
+ }
21039
+ });
21040
+ setClient(client2);
21041
+ setDoc(doc2);
21042
+ setRoot(doc2.getRoot());
21043
+ } catch (err) {
21044
+ setError(err instanceof Error ? err : new Error("Unknown error"));
21045
+ } finally {
21046
+ setLoading(false);
21047
+ }
21048
+ }
21049
+ setupYorkie();
21050
+ return () => {
21051
+ client == null ? void 0 : client.deactivate({ keepalive: true });
21052
+ };
21053
+ }, [apiKey, docKey, JSON.stringify(initialRoot), JSON.stringify(options)]);
21054
+ const update = useCallback(
21055
+ (callback) => {
21056
+ if (!doc) {
21057
+ console.warn("Attempted to update document before it was initialized");
21058
+ return;
21059
+ }
21060
+ doc.update((root2) => {
21061
+ callback(root2);
21062
+ });
21063
+ },
21064
+ [doc]
21065
+ );
21066
+ return {
21067
+ root,
21068
+ update,
21069
+ loading,
21070
+ error
21071
+ };
21072
+ }
21073
+ const YorkieContext = createContext({
24137
21074
  client: void 0,
24138
21075
  loading: true,
24139
21076
  error: void 0
24140
21077
  });
24141
21078
  const YorkieProvider = ({ apiKey, rpcAddr = "https://api.yorkie.dev", children }) => {
24142
- const [client, setClient] = reactExports.useState(void 0);
24143
- const [loading, setLoading] = reactExports.useState(true);
24144
- const [error, setError] = reactExports.useState(void 0);
24145
- reactExports.useEffect(() => {
21079
+ const [client, setClient] = useState(void 0);
21080
+ const [loading, setLoading] = useState(true);
21081
+ const [error, setError] = useState(void 0);
21082
+ useEffect(() => {
24146
21083
  setLoading(true);
24147
21084
  setError(void 0);
24148
21085
  async function activateClient() {
@@ -24167,10 +21104,10 @@ const YorkieProvider = ({ apiKey, rpcAddr = "https://api.yorkie.dev", children }
24167
21104
  }
24168
21105
  };
24169
21106
  }, [apiKey, rpcAddr]);
24170
- return /* @__PURE__ */ jsxRuntimeExports.jsx(YorkieContext.Provider, { value: { client, loading, error }, children });
21107
+ return /* @__PURE__ */ jsx(YorkieContext.Provider, { value: { client, loading, error }, children });
24171
21108
  };
24172
21109
  const useYorkie = () => {
24173
- const context = reactExports.useContext(YorkieContext);
21110
+ const context = useContext(YorkieContext);
24174
21111
  if (!context) {
24175
21112
  throw new Error("useYorkie must be used under YorkieProvider");
24176
21113
  }
@@ -24180,7 +21117,7 @@ const useYorkie = () => {
24180
21117
  error: context.error
24181
21118
  };
24182
21119
  };
24183
- const DocumentContext = reactExports.createContext(null);
21120
+ const DocumentContext = createContext(null);
24184
21121
  const DocumentProvider = ({
24185
21122
  docKey,
24186
21123
  initialRoot = {},
@@ -24188,12 +21125,12 @@ const DocumentProvider = ({
24188
21125
  children
24189
21126
  }) => {
24190
21127
  const { client, loading: clientLoading, error: clientError } = useYorkie();
24191
- const [doc, setDoc] = reactExports.useState(void 0);
24192
- const [loading, setLoading] = reactExports.useState(true);
24193
- const [error, setError] = reactExports.useState(void 0);
24194
- const [root, setRoot] = reactExports.useState(initialRoot);
24195
- const [presences, setPresences] = reactExports.useState([]);
24196
- reactExports.useEffect(() => {
21128
+ const [doc, setDoc] = useState(void 0);
21129
+ const [loading, setLoading] = useState(true);
21130
+ const [error, setError] = useState(void 0);
21131
+ const [root, setRoot] = useState(initialRoot);
21132
+ const [presences, setPresences] = useState([]);
21133
+ useEffect(() => {
24197
21134
  if (clientError) {
24198
21135
  setLoading(false);
24199
21136
  setError(clientError);
@@ -24235,7 +21172,7 @@ const DocumentProvider = ({
24235
21172
  }
24236
21173
  };
24237
21174
  }, [client, clientLoading, clientError, docKey]);
24238
- const update = reactExports.useCallback(
21175
+ const update = useCallback(
24239
21176
  (callback) => {
24240
21177
  if (!doc) {
24241
21178
  return;
@@ -24250,7 +21187,7 @@ const DocumentProvider = ({
24250
21187
  },
24251
21188
  [doc]
24252
21189
  );
24253
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
21190
+ return /* @__PURE__ */ jsx(
24254
21191
  DocumentContext.Provider,
24255
21192
  {
24256
21193
  value: { root, presences, update, loading, error },
@@ -24259,7 +21196,7 @@ const DocumentProvider = ({
24259
21196
  );
24260
21197
  };
24261
21198
  const useDocument = () => {
24262
- const context = reactExports.useContext(DocumentContext);
21199
+ const context = useContext(DocumentContext);
24263
21200
  if (!context) {
24264
21201
  throw new Error("useDocument must be used within a DocumentProvider");
24265
21202
  }
@@ -24272,14 +21209,14 @@ const useDocument = () => {
24272
21209
  };
24273
21210
  };
24274
21211
  const useRoot = () => {
24275
- const context = reactExports.useContext(DocumentContext);
21212
+ const context = useContext(DocumentContext);
24276
21213
  if (!context) {
24277
21214
  throw new Error("useRoot must be used within a DocumentProvider");
24278
21215
  }
24279
21216
  return { root: context.root };
24280
21217
  };
24281
21218
  const usePresences = () => {
24282
- const context = reactExports.useContext(DocumentContext);
21219
+ const context = useContext(DocumentContext);
24283
21220
  if (!context) {
24284
21221
  throw new Error("usePresences must be used within a DocumentProvider");
24285
21222
  }