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