@trustgraph/react-state 0.3.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,1368 +1,11 @@
1
1
  import { useSocket, useConnectionState } from '@trustgraph/react-provider';
2
2
  export { ConnectionStateContext, SocketContext, SocketProvider } from '@trustgraph/react-provider';
3
- import require$$0, { createContext, useContext, useEffect, useState, useMemo } from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { createContext, useContext, useEffect, useState, useMemo } from 'react';
4
5
  import { create } from 'zustand';
5
6
  import { useQueryClient, useQuery, useMutation } from '@tanstack/react-query';
6
7
  import { v4 } from 'uuid';
7
-
8
- function getDefaultExportFromCjs (x) {
9
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
10
- }
11
-
12
- var jsxRuntime = {exports: {}};
13
-
14
- var reactJsxRuntime_production_min = {};
15
-
16
- /**
17
- * @license React
18
- * react-jsx-runtime.production.min.js
19
- *
20
- * Copyright (c) Facebook, Inc. and its affiliates.
21
- *
22
- * This source code is licensed under the MIT license found in the
23
- * LICENSE file in the root directory of this source tree.
24
- */
25
-
26
- var hasRequiredReactJsxRuntime_production_min;
27
-
28
- function requireReactJsxRuntime_production_min () {
29
- if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
30
- hasRequiredReactJsxRuntime_production_min = 1;
31
- var f=require$$0,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};
32
- function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a) void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
33
- return reactJsxRuntime_production_min;
34
- }
35
-
36
- var reactJsxRuntime_development = {};
37
-
38
- /**
39
- * @license React
40
- * react-jsx-runtime.development.js
41
- *
42
- * Copyright (c) Facebook, Inc. and its affiliates.
43
- *
44
- * This source code is licensed under the MIT license found in the
45
- * LICENSE file in the root directory of this source tree.
46
- */
47
-
48
- var hasRequiredReactJsxRuntime_development;
49
-
50
- function requireReactJsxRuntime_development () {
51
- if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
52
- hasRequiredReactJsxRuntime_development = 1;
53
-
54
- if (process.env.NODE_ENV !== "production") {
55
- (function() {
56
-
57
- var React = require$$0;
58
-
59
- // ATTENTION
60
- // When adding new symbols to this file,
61
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
62
- // The Symbol used to tag the ReactElement-like types.
63
- var REACT_ELEMENT_TYPE = Symbol.for('react.element');
64
- var REACT_PORTAL_TYPE = Symbol.for('react.portal');
65
- var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
66
- var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
67
- var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
68
- var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
69
- var REACT_CONTEXT_TYPE = Symbol.for('react.context');
70
- var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
71
- var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
72
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
73
- var REACT_MEMO_TYPE = Symbol.for('react.memo');
74
- var REACT_LAZY_TYPE = Symbol.for('react.lazy');
75
- var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
76
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
77
- var FAUX_ITERATOR_SYMBOL = '@@iterator';
78
- function getIteratorFn(maybeIterable) {
79
- if (maybeIterable === null || typeof maybeIterable !== 'object') {
80
- return null;
81
- }
82
-
83
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
84
-
85
- if (typeof maybeIterator === 'function') {
86
- return maybeIterator;
87
- }
88
-
89
- return null;
90
- }
91
-
92
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
93
-
94
- function error(format) {
95
- {
96
- {
97
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
98
- args[_key2 - 1] = arguments[_key2];
99
- }
100
-
101
- printWarning('error', format, args);
102
- }
103
- }
104
- }
105
-
106
- function printWarning(level, format, args) {
107
- // When changing this logic, you might want to also
108
- // update consoleWithStackDev.www.js as well.
109
- {
110
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
111
- var stack = ReactDebugCurrentFrame.getStackAddendum();
112
-
113
- if (stack !== '') {
114
- format += '%s';
115
- args = args.concat([stack]);
116
- } // eslint-disable-next-line react-internal/safe-string-coercion
117
-
118
-
119
- var argsWithFormat = args.map(function (item) {
120
- return String(item);
121
- }); // Careful: RN currently depends on this prefix
122
-
123
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
124
- // breaks IE9: https://github.com/facebook/react/issues/13610
125
- // eslint-disable-next-line react-internal/no-production-logging
126
-
127
- Function.prototype.apply.call(console[level], console, argsWithFormat);
128
- }
129
- }
130
-
131
- // -----------------------------------------------------------------------------
132
-
133
- var enableScopeAPI = false; // Experimental Create Event Handle API.
134
- var enableCacheElement = false;
135
- var enableTransitionTracing = false; // No known bugs, but needs performance testing
136
-
137
- var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
138
- // stuff. Intended to enable React core members to more easily debug scheduling
139
- // issues in DEV builds.
140
-
141
- var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
142
-
143
- var REACT_MODULE_REFERENCE;
144
-
145
- {
146
- REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
147
- }
148
-
149
- function isValidElementType(type) {
150
- if (typeof type === 'string' || typeof type === 'function') {
151
- return true;
152
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
153
-
154
-
155
- 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 ) {
156
- return true;
157
- }
158
-
159
- if (typeof type === 'object' && type !== null) {
160
- 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
161
- // types supported by any Flight configuration anywhere since
162
- // we don't know which Flight build this will end up being used
163
- // with.
164
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
165
- return true;
166
- }
167
- }
168
-
169
- return false;
170
- }
171
-
172
- function getWrappedName(outerType, innerType, wrapperName) {
173
- var displayName = outerType.displayName;
174
-
175
- if (displayName) {
176
- return displayName;
177
- }
178
-
179
- var functionName = innerType.displayName || innerType.name || '';
180
- return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
181
- } // Keep in sync with react-reconciler/getComponentNameFromFiber
182
-
183
-
184
- function getContextName(type) {
185
- return type.displayName || 'Context';
186
- } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
187
-
188
-
189
- function getComponentNameFromType(type) {
190
- if (type == null) {
191
- // Host root, text node or just invalid type.
192
- return null;
193
- }
194
-
195
- {
196
- if (typeof type.tag === 'number') {
197
- error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
198
- }
199
- }
200
-
201
- if (typeof type === 'function') {
202
- return type.displayName || type.name || null;
203
- }
204
-
205
- if (typeof type === 'string') {
206
- return type;
207
- }
208
-
209
- switch (type) {
210
- case REACT_FRAGMENT_TYPE:
211
- return 'Fragment';
212
-
213
- case REACT_PORTAL_TYPE:
214
- return 'Portal';
215
-
216
- case REACT_PROFILER_TYPE:
217
- return 'Profiler';
218
-
219
- case REACT_STRICT_MODE_TYPE:
220
- return 'StrictMode';
221
-
222
- case REACT_SUSPENSE_TYPE:
223
- return 'Suspense';
224
-
225
- case REACT_SUSPENSE_LIST_TYPE:
226
- return 'SuspenseList';
227
-
228
- }
229
-
230
- if (typeof type === 'object') {
231
- switch (type.$$typeof) {
232
- case REACT_CONTEXT_TYPE:
233
- var context = type;
234
- return getContextName(context) + '.Consumer';
235
-
236
- case REACT_PROVIDER_TYPE:
237
- var provider = type;
238
- return getContextName(provider._context) + '.Provider';
239
-
240
- case REACT_FORWARD_REF_TYPE:
241
- return getWrappedName(type, type.render, 'ForwardRef');
242
-
243
- case REACT_MEMO_TYPE:
244
- var outerName = type.displayName || null;
245
-
246
- if (outerName !== null) {
247
- return outerName;
248
- }
249
-
250
- return getComponentNameFromType(type.type) || 'Memo';
251
-
252
- case REACT_LAZY_TYPE:
253
- {
254
- var lazyComponent = type;
255
- var payload = lazyComponent._payload;
256
- var init = lazyComponent._init;
257
-
258
- try {
259
- return getComponentNameFromType(init(payload));
260
- } catch (x) {
261
- return null;
262
- }
263
- }
264
-
265
- // eslint-disable-next-line no-fallthrough
266
- }
267
- }
268
-
269
- return null;
270
- }
271
-
272
- var assign = Object.assign;
273
-
274
- // Helpers to patch console.logs to avoid logging during side-effect free
275
- // replaying on render function. This currently only patches the object
276
- // lazily which won't cover if the log function was extracted eagerly.
277
- // We could also eagerly patch the method.
278
- var disabledDepth = 0;
279
- var prevLog;
280
- var prevInfo;
281
- var prevWarn;
282
- var prevError;
283
- var prevGroup;
284
- var prevGroupCollapsed;
285
- var prevGroupEnd;
286
-
287
- function disabledLog() {}
288
-
289
- disabledLog.__reactDisabledLog = true;
290
- function disableLogs() {
291
- {
292
- if (disabledDepth === 0) {
293
- /* eslint-disable react-internal/no-production-logging */
294
- prevLog = console.log;
295
- prevInfo = console.info;
296
- prevWarn = console.warn;
297
- prevError = console.error;
298
- prevGroup = console.group;
299
- prevGroupCollapsed = console.groupCollapsed;
300
- prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
301
-
302
- var props = {
303
- configurable: true,
304
- enumerable: true,
305
- value: disabledLog,
306
- writable: true
307
- }; // $FlowFixMe Flow thinks console is immutable.
308
-
309
- Object.defineProperties(console, {
310
- info: props,
311
- log: props,
312
- warn: props,
313
- error: props,
314
- group: props,
315
- groupCollapsed: props,
316
- groupEnd: props
317
- });
318
- /* eslint-enable react-internal/no-production-logging */
319
- }
320
-
321
- disabledDepth++;
322
- }
323
- }
324
- function reenableLogs() {
325
- {
326
- disabledDepth--;
327
-
328
- if (disabledDepth === 0) {
329
- /* eslint-disable react-internal/no-production-logging */
330
- var props = {
331
- configurable: true,
332
- enumerable: true,
333
- writable: true
334
- }; // $FlowFixMe Flow thinks console is immutable.
335
-
336
- Object.defineProperties(console, {
337
- log: assign({}, props, {
338
- value: prevLog
339
- }),
340
- info: assign({}, props, {
341
- value: prevInfo
342
- }),
343
- warn: assign({}, props, {
344
- value: prevWarn
345
- }),
346
- error: assign({}, props, {
347
- value: prevError
348
- }),
349
- group: assign({}, props, {
350
- value: prevGroup
351
- }),
352
- groupCollapsed: assign({}, props, {
353
- value: prevGroupCollapsed
354
- }),
355
- groupEnd: assign({}, props, {
356
- value: prevGroupEnd
357
- })
358
- });
359
- /* eslint-enable react-internal/no-production-logging */
360
- }
361
-
362
- if (disabledDepth < 0) {
363
- error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
364
- }
365
- }
366
- }
367
-
368
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
369
- var prefix;
370
- function describeBuiltInComponentFrame(name, source, ownerFn) {
371
- {
372
- if (prefix === undefined) {
373
- // Extract the VM specific prefix used by each line.
374
- try {
375
- throw Error();
376
- } catch (x) {
377
- var match = x.stack.trim().match(/\n( *(at )?)/);
378
- prefix = match && match[1] || '';
379
- }
380
- } // We use the prefix to ensure our stacks line up with native stack frames.
381
-
382
-
383
- return '\n' + prefix + name;
384
- }
385
- }
386
- var reentry = false;
387
- var componentFrameCache;
388
-
389
- {
390
- var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
391
- componentFrameCache = new PossiblyWeakMap();
392
- }
393
-
394
- function describeNativeComponentFrame(fn, construct) {
395
- // If something asked for a stack inside a fake render, it should get ignored.
396
- if ( !fn || reentry) {
397
- return '';
398
- }
399
-
400
- {
401
- var frame = componentFrameCache.get(fn);
402
-
403
- if (frame !== undefined) {
404
- return frame;
405
- }
406
- }
407
-
408
- var control;
409
- reentry = true;
410
- var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
411
-
412
- Error.prepareStackTrace = undefined;
413
- var previousDispatcher;
414
-
415
- {
416
- previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
417
- // for warnings.
418
-
419
- ReactCurrentDispatcher.current = null;
420
- disableLogs();
421
- }
422
-
423
- try {
424
- // This should throw.
425
- if (construct) {
426
- // Something should be setting the props in the constructor.
427
- var Fake = function () {
428
- throw Error();
429
- }; // $FlowFixMe
430
-
431
-
432
- Object.defineProperty(Fake.prototype, 'props', {
433
- set: function () {
434
- // We use a throwing setter instead of frozen or non-writable props
435
- // because that won't throw in a non-strict mode function.
436
- throw Error();
437
- }
438
- });
439
-
440
- if (typeof Reflect === 'object' && Reflect.construct) {
441
- // We construct a different control for this case to include any extra
442
- // frames added by the construct call.
443
- try {
444
- Reflect.construct(Fake, []);
445
- } catch (x) {
446
- control = x;
447
- }
448
-
449
- Reflect.construct(fn, [], Fake);
450
- } else {
451
- try {
452
- Fake.call();
453
- } catch (x) {
454
- control = x;
455
- }
456
-
457
- fn.call(Fake.prototype);
458
- }
459
- } else {
460
- try {
461
- throw Error();
462
- } catch (x) {
463
- control = x;
464
- }
465
-
466
- fn();
467
- }
468
- } catch (sample) {
469
- // This is inlined manually because closure doesn't do it for us.
470
- if (sample && control && typeof sample.stack === 'string') {
471
- // This extracts the first frame from the sample that isn't also in the control.
472
- // Skipping one frame that we assume is the frame that calls the two.
473
- var sampleLines = sample.stack.split('\n');
474
- var controlLines = control.stack.split('\n');
475
- var s = sampleLines.length - 1;
476
- var c = controlLines.length - 1;
477
-
478
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
479
- // We expect at least one stack frame to be shared.
480
- // Typically this will be the root most one. However, stack frames may be
481
- // cut off due to maximum stack limits. In this case, one maybe cut off
482
- // earlier than the other. We assume that the sample is longer or the same
483
- // and there for cut off earlier. So we should find the root most frame in
484
- // the sample somewhere in the control.
485
- c--;
486
- }
487
-
488
- for (; s >= 1 && c >= 0; s--, c--) {
489
- // Next we find the first one that isn't the same which should be the
490
- // frame that called our sample function and the control.
491
- if (sampleLines[s] !== controlLines[c]) {
492
- // In V8, the first line is describing the message but other VMs don't.
493
- // If we're about to return the first line, and the control is also on the same
494
- // line, that's a pretty good indicator that our sample threw at same line as
495
- // the control. I.e. before we entered the sample frame. So we ignore this result.
496
- // This can happen if you passed a class to function component, or non-function.
497
- if (s !== 1 || c !== 1) {
498
- do {
499
- s--;
500
- c--; // We may still have similar intermediate frames from the construct call.
501
- // The next one that isn't the same should be our match though.
502
-
503
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
504
- // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
505
- var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
506
- // but we have a user-provided "displayName"
507
- // splice it in to make the stack more readable.
508
-
509
-
510
- if (fn.displayName && _frame.includes('<anonymous>')) {
511
- _frame = _frame.replace('<anonymous>', fn.displayName);
512
- }
513
-
514
- {
515
- if (typeof fn === 'function') {
516
- componentFrameCache.set(fn, _frame);
517
- }
518
- } // Return the line we found.
519
-
520
-
521
- return _frame;
522
- }
523
- } while (s >= 1 && c >= 0);
524
- }
525
-
526
- break;
527
- }
528
- }
529
- }
530
- } finally {
531
- reentry = false;
532
-
533
- {
534
- ReactCurrentDispatcher.current = previousDispatcher;
535
- reenableLogs();
536
- }
537
-
538
- Error.prepareStackTrace = previousPrepareStackTrace;
539
- } // Fallback to just using the name if we couldn't make it throw.
540
-
541
-
542
- var name = fn ? fn.displayName || fn.name : '';
543
- var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
544
-
545
- {
546
- if (typeof fn === 'function') {
547
- componentFrameCache.set(fn, syntheticFrame);
548
- }
549
- }
550
-
551
- return syntheticFrame;
552
- }
553
- function describeFunctionComponentFrame(fn, source, ownerFn) {
554
- {
555
- return describeNativeComponentFrame(fn, false);
556
- }
557
- }
558
-
559
- function shouldConstruct(Component) {
560
- var prototype = Component.prototype;
561
- return !!(prototype && prototype.isReactComponent);
562
- }
563
-
564
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
565
-
566
- if (type == null) {
567
- return '';
568
- }
569
-
570
- if (typeof type === 'function') {
571
- {
572
- return describeNativeComponentFrame(type, shouldConstruct(type));
573
- }
574
- }
575
-
576
- if (typeof type === 'string') {
577
- return describeBuiltInComponentFrame(type);
578
- }
579
-
580
- switch (type) {
581
- case REACT_SUSPENSE_TYPE:
582
- return describeBuiltInComponentFrame('Suspense');
583
-
584
- case REACT_SUSPENSE_LIST_TYPE:
585
- return describeBuiltInComponentFrame('SuspenseList');
586
- }
587
-
588
- if (typeof type === 'object') {
589
- switch (type.$$typeof) {
590
- case REACT_FORWARD_REF_TYPE:
591
- return describeFunctionComponentFrame(type.render);
592
-
593
- case REACT_MEMO_TYPE:
594
- // Memo may contain any component type so we recursively resolve it.
595
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
596
-
597
- case REACT_LAZY_TYPE:
598
- {
599
- var lazyComponent = type;
600
- var payload = lazyComponent._payload;
601
- var init = lazyComponent._init;
602
-
603
- try {
604
- // Lazy may contain any component type so we recursively resolve it.
605
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
606
- } catch (x) {}
607
- }
608
- }
609
- }
610
-
611
- return '';
612
- }
613
-
614
- var hasOwnProperty = Object.prototype.hasOwnProperty;
615
-
616
- var loggedTypeFailures = {};
617
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
618
-
619
- function setCurrentlyValidatingElement(element) {
620
- {
621
- if (element) {
622
- var owner = element._owner;
623
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
624
- ReactDebugCurrentFrame.setExtraStackFrame(stack);
625
- } else {
626
- ReactDebugCurrentFrame.setExtraStackFrame(null);
627
- }
628
- }
629
- }
630
-
631
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
632
- {
633
- // $FlowFixMe This is okay but Flow doesn't know it.
634
- var has = Function.call.bind(hasOwnProperty);
635
-
636
- for (var typeSpecName in typeSpecs) {
637
- if (has(typeSpecs, typeSpecName)) {
638
- var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
639
- // fail the render phase where it didn't fail before. So we log it.
640
- // After these have been cleaned up, we'll let them throw.
641
-
642
- try {
643
- // This is intentionally an invariant that gets caught. It's the same
644
- // behavior as without this statement except with a better message.
645
- if (typeof typeSpecs[typeSpecName] !== 'function') {
646
- // eslint-disable-next-line react-internal/prod-error-codes
647
- 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`.');
648
- err.name = 'Invariant Violation';
649
- throw err;
650
- }
651
-
652
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
653
- } catch (ex) {
654
- error$1 = ex;
655
- }
656
-
657
- if (error$1 && !(error$1 instanceof Error)) {
658
- setCurrentlyValidatingElement(element);
659
-
660
- 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);
661
-
662
- setCurrentlyValidatingElement(null);
663
- }
664
-
665
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
666
- // Only monitor this failure once because there tends to be a lot of the
667
- // same error.
668
- loggedTypeFailures[error$1.message] = true;
669
- setCurrentlyValidatingElement(element);
670
-
671
- error('Failed %s type: %s', location, error$1.message);
672
-
673
- setCurrentlyValidatingElement(null);
674
- }
675
- }
676
- }
677
- }
678
- }
679
-
680
- var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
681
-
682
- function isArray(a) {
683
- return isArrayImpl(a);
684
- }
685
-
686
- /*
687
- * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
688
- * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
689
- *
690
- * The functions in this module will throw an easier-to-understand,
691
- * easier-to-debug exception with a clear errors message message explaining the
692
- * problem. (Instead of a confusing exception thrown inside the implementation
693
- * of the `value` object).
694
- */
695
- // $FlowFixMe only called in DEV, so void return is not possible.
696
- function typeName(value) {
697
- {
698
- // toStringTag is needed for namespaced types like Temporal.Instant
699
- var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
700
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
701
- return type;
702
- }
703
- } // $FlowFixMe only called in DEV, so void return is not possible.
704
-
705
-
706
- function willCoercionThrow(value) {
707
- {
708
- try {
709
- testStringCoercion(value);
710
- return false;
711
- } catch (e) {
712
- return true;
713
- }
714
- }
715
- }
716
-
717
- function testStringCoercion(value) {
718
- // If you ended up here by following an exception call stack, here's what's
719
- // happened: you supplied an object or symbol value to React (as a prop, key,
720
- // DOM attribute, CSS property, string ref, etc.) and when React tried to
721
- // coerce it to a string using `'' + value`, an exception was thrown.
722
- //
723
- // The most common types that will cause this exception are `Symbol` instances
724
- // and Temporal objects like `Temporal.Instant`. But any object that has a
725
- // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
726
- // exception. (Library authors do this to prevent users from using built-in
727
- // numeric operators like `+` or comparison operators like `>=` because custom
728
- // methods are needed to perform accurate arithmetic or comparison.)
729
- //
730
- // To fix the problem, coerce this object or symbol value to a string before
731
- // passing it to React. The most reliable way is usually `String(value)`.
732
- //
733
- // To find which value is throwing, check the browser or debugger console.
734
- // Before this exception was thrown, there should be `console.error` output
735
- // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
736
- // problem and how that type was used: key, atrribute, input value prop, etc.
737
- // In most cases, this console output also shows the component and its
738
- // ancestor components where the exception happened.
739
- //
740
- // eslint-disable-next-line react-internal/safe-string-coercion
741
- return '' + value;
742
- }
743
- function checkKeyStringCoercion(value) {
744
- {
745
- if (willCoercionThrow(value)) {
746
- error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
747
-
748
- return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
749
- }
750
- }
751
- }
752
-
753
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
754
- var RESERVED_PROPS = {
755
- key: true,
756
- ref: true,
757
- __self: true,
758
- __source: true
759
- };
760
- var specialPropKeyWarningShown;
761
- var specialPropRefWarningShown;
762
-
763
- function hasValidRef(config) {
764
- {
765
- if (hasOwnProperty.call(config, 'ref')) {
766
- var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
767
-
768
- if (getter && getter.isReactWarning) {
769
- return false;
770
- }
771
- }
772
- }
773
-
774
- return config.ref !== undefined;
775
- }
776
-
777
- function hasValidKey(config) {
778
- {
779
- if (hasOwnProperty.call(config, 'key')) {
780
- var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
781
-
782
- if (getter && getter.isReactWarning) {
783
- return false;
784
- }
785
- }
786
- }
787
-
788
- return config.key !== undefined;
789
- }
790
-
791
- function warnIfStringRefCannotBeAutoConverted(config, self) {
792
- {
793
- if (typeof config.ref === 'string' && ReactCurrentOwner.current && self) ;
794
- }
795
- }
796
-
797
- function defineKeyPropWarningGetter(props, displayName) {
798
- {
799
- var warnAboutAccessingKey = function () {
800
- if (!specialPropKeyWarningShown) {
801
- specialPropKeyWarningShown = true;
802
-
803
- 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);
804
- }
805
- };
806
-
807
- warnAboutAccessingKey.isReactWarning = true;
808
- Object.defineProperty(props, 'key', {
809
- get: warnAboutAccessingKey,
810
- configurable: true
811
- });
812
- }
813
- }
814
-
815
- function defineRefPropWarningGetter(props, displayName) {
816
- {
817
- var warnAboutAccessingRef = function () {
818
- if (!specialPropRefWarningShown) {
819
- specialPropRefWarningShown = true;
820
-
821
- 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);
822
- }
823
- };
824
-
825
- warnAboutAccessingRef.isReactWarning = true;
826
- Object.defineProperty(props, 'ref', {
827
- get: warnAboutAccessingRef,
828
- configurable: true
829
- });
830
- }
831
- }
832
- /**
833
- * Factory method to create a new React element. This no longer adheres to
834
- * the class pattern, so do not use new to call it. Also, instanceof check
835
- * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
836
- * if something is a React Element.
837
- *
838
- * @param {*} type
839
- * @param {*} props
840
- * @param {*} key
841
- * @param {string|object} ref
842
- * @param {*} owner
843
- * @param {*} self A *temporary* helper to detect places where `this` is
844
- * different from the `owner` when React.createElement is called, so that we
845
- * can warn. We want to get rid of owner and replace string `ref`s with arrow
846
- * functions, and as long as `this` and owner are the same, there will be no
847
- * change in behavior.
848
- * @param {*} source An annotation object (added by a transpiler or otherwise)
849
- * indicating filename, line number, and/or other information.
850
- * @internal
851
- */
852
-
853
-
854
- var ReactElement = function (type, key, ref, self, source, owner, props) {
855
- var element = {
856
- // This tag allows us to uniquely identify this as a React Element
857
- $$typeof: REACT_ELEMENT_TYPE,
858
- // Built-in properties that belong on the element
859
- type: type,
860
- key: key,
861
- ref: ref,
862
- props: props,
863
- // Record the component responsible for creating this element.
864
- _owner: owner
865
- };
866
-
867
- {
868
- // The validation flag is currently mutative. We put it on
869
- // an external backing store so that we can freeze the whole object.
870
- // This can be replaced with a WeakMap once they are implemented in
871
- // commonly used development environments.
872
- element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
873
- // the validation flag non-enumerable (where possible, which should
874
- // include every environment we run tests in), so the test framework
875
- // ignores it.
876
-
877
- Object.defineProperty(element._store, 'validated', {
878
- configurable: false,
879
- enumerable: false,
880
- writable: true,
881
- value: false
882
- }); // self and source are DEV only properties.
883
-
884
- Object.defineProperty(element, '_self', {
885
- configurable: false,
886
- enumerable: false,
887
- writable: false,
888
- value: self
889
- }); // Two elements created in two different places should be considered
890
- // equal for testing purposes and therefore we hide it from enumeration.
891
-
892
- Object.defineProperty(element, '_source', {
893
- configurable: false,
894
- enumerable: false,
895
- writable: false,
896
- value: source
897
- });
898
-
899
- if (Object.freeze) {
900
- Object.freeze(element.props);
901
- Object.freeze(element);
902
- }
903
- }
904
-
905
- return element;
906
- };
907
- /**
908
- * https://github.com/reactjs/rfcs/pull/107
909
- * @param {*} type
910
- * @param {object} props
911
- * @param {string} key
912
- */
913
-
914
- function jsxDEV(type, config, maybeKey, source, self) {
915
- {
916
- var propName; // Reserved names are extracted
917
-
918
- var props = {};
919
- var key = null;
920
- var ref = null; // Currently, key can be spread in as a prop. This causes a potential
921
- // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
922
- // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
923
- // but as an intermediary step, we will use jsxDEV for everything except
924
- // <div {...props} key="Hi" />, because we aren't currently able to tell if
925
- // key is explicitly declared to be undefined or not.
926
-
927
- if (maybeKey !== undefined) {
928
- {
929
- checkKeyStringCoercion(maybeKey);
930
- }
931
-
932
- key = '' + maybeKey;
933
- }
934
-
935
- if (hasValidKey(config)) {
936
- {
937
- checkKeyStringCoercion(config.key);
938
- }
939
-
940
- key = '' + config.key;
941
- }
942
-
943
- if (hasValidRef(config)) {
944
- ref = config.ref;
945
- warnIfStringRefCannotBeAutoConverted(config, self);
946
- } // Remaining properties are added to a new props object
947
-
948
-
949
- for (propName in config) {
950
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
951
- props[propName] = config[propName];
952
- }
953
- } // Resolve default props
954
-
955
-
956
- if (type && type.defaultProps) {
957
- var defaultProps = type.defaultProps;
958
-
959
- for (propName in defaultProps) {
960
- if (props[propName] === undefined) {
961
- props[propName] = defaultProps[propName];
962
- }
963
- }
964
- }
965
-
966
- if (key || ref) {
967
- var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
968
-
969
- if (key) {
970
- defineKeyPropWarningGetter(props, displayName);
971
- }
972
-
973
- if (ref) {
974
- defineRefPropWarningGetter(props, displayName);
975
- }
976
- }
977
-
978
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
979
- }
980
- }
981
-
982
- var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
983
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
984
-
985
- function setCurrentlyValidatingElement$1(element) {
986
- {
987
- if (element) {
988
- var owner = element._owner;
989
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
990
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
991
- } else {
992
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
993
- }
994
- }
995
- }
996
-
997
- var propTypesMisspellWarningShown;
998
-
999
- {
1000
- propTypesMisspellWarningShown = false;
1001
- }
1002
- /**
1003
- * Verifies the object is a ReactElement.
1004
- * See https://reactjs.org/docs/react-api.html#isvalidelement
1005
- * @param {?object} object
1006
- * @return {boolean} True if `object` is a ReactElement.
1007
- * @final
1008
- */
1009
-
1010
-
1011
- function isValidElement(object) {
1012
- {
1013
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1014
- }
1015
- }
1016
-
1017
- function getDeclarationErrorAddendum() {
1018
- {
1019
- if (ReactCurrentOwner$1.current) {
1020
- var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
1021
-
1022
- if (name) {
1023
- return '\n\nCheck the render method of `' + name + '`.';
1024
- }
1025
- }
1026
-
1027
- return '';
1028
- }
1029
- }
1030
-
1031
- function getSourceInfoErrorAddendum(source) {
1032
- {
1033
-
1034
- return '';
1035
- }
1036
- }
1037
- /**
1038
- * Warn if there's no key explicitly set on dynamic arrays of children or
1039
- * object keys are not valid. This allows us to keep track of children between
1040
- * updates.
1041
- */
1042
-
1043
-
1044
- var ownerHasKeyUseWarning = {};
1045
-
1046
- function getCurrentComponentErrorInfo(parentType) {
1047
- {
1048
- var info = getDeclarationErrorAddendum();
1049
-
1050
- if (!info) {
1051
- var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1052
-
1053
- if (parentName) {
1054
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1055
- }
1056
- }
1057
-
1058
- return info;
1059
- }
1060
- }
1061
- /**
1062
- * Warn if the element doesn't have an explicit key assigned to it.
1063
- * This element is in an array. The array could grow and shrink or be
1064
- * reordered. All children that haven't already been validated are required to
1065
- * have a "key" property assigned to it. Error statuses are cached so a warning
1066
- * will only be shown once.
1067
- *
1068
- * @internal
1069
- * @param {ReactElement} element Element that requires a key.
1070
- * @param {*} parentType element's parent's type.
1071
- */
1072
-
1073
-
1074
- function validateExplicitKey(element, parentType) {
1075
- {
1076
- if (!element._store || element._store.validated || element.key != null) {
1077
- return;
1078
- }
1079
-
1080
- element._store.validated = true;
1081
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1082
-
1083
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1084
- return;
1085
- }
1086
-
1087
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
1088
- // property, it may be the creator of the child that's responsible for
1089
- // assigning it a key.
1090
-
1091
- var childOwner = '';
1092
-
1093
- if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
1094
- // Give the component that originally created this child.
1095
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1096
- }
1097
-
1098
- setCurrentlyValidatingElement$1(element);
1099
-
1100
- 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);
1101
-
1102
- setCurrentlyValidatingElement$1(null);
1103
- }
1104
- }
1105
- /**
1106
- * Ensure that every element either is passed in a static location, in an
1107
- * array with an explicit keys property defined, or in an object literal
1108
- * with valid key property.
1109
- *
1110
- * @internal
1111
- * @param {ReactNode} node Statically passed child of any type.
1112
- * @param {*} parentType node's parent's type.
1113
- */
1114
-
1115
-
1116
- function validateChildKeys(node, parentType) {
1117
- {
1118
- if (typeof node !== 'object') {
1119
- return;
1120
- }
1121
-
1122
- if (isArray(node)) {
1123
- for (var i = 0; i < node.length; i++) {
1124
- var child = node[i];
1125
-
1126
- if (isValidElement(child)) {
1127
- validateExplicitKey(child, parentType);
1128
- }
1129
- }
1130
- } else if (isValidElement(node)) {
1131
- // This element was passed in a valid location.
1132
- if (node._store) {
1133
- node._store.validated = true;
1134
- }
1135
- } else if (node) {
1136
- var iteratorFn = getIteratorFn(node);
1137
-
1138
- if (typeof iteratorFn === 'function') {
1139
- // Entry iterators used to provide implicit keys,
1140
- // but now we print a separate warning for them later.
1141
- if (iteratorFn !== node.entries) {
1142
- var iterator = iteratorFn.call(node);
1143
- var step;
1144
-
1145
- while (!(step = iterator.next()).done) {
1146
- if (isValidElement(step.value)) {
1147
- validateExplicitKey(step.value, parentType);
1148
- }
1149
- }
1150
- }
1151
- }
1152
- }
1153
- }
1154
- }
1155
- /**
1156
- * Given an element, validate that its props follow the propTypes definition,
1157
- * provided by the type.
1158
- *
1159
- * @param {ReactElement} element
1160
- */
1161
-
1162
-
1163
- function validatePropTypes(element) {
1164
- {
1165
- var type = element.type;
1166
-
1167
- if (type === null || type === undefined || typeof type === 'string') {
1168
- return;
1169
- }
1170
-
1171
- var propTypes;
1172
-
1173
- if (typeof type === 'function') {
1174
- propTypes = type.propTypes;
1175
- } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1176
- // Inner props are checked in the reconciler.
1177
- type.$$typeof === REACT_MEMO_TYPE)) {
1178
- propTypes = type.propTypes;
1179
- } else {
1180
- return;
1181
- }
1182
-
1183
- if (propTypes) {
1184
- // Intentionally inside to avoid triggering lazy initializers:
1185
- var name = getComponentNameFromType(type);
1186
- checkPropTypes(propTypes, element.props, 'prop', name, element);
1187
- } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1188
- propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
1189
-
1190
- var _name = getComponentNameFromType(type);
1191
-
1192
- error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
1193
- }
1194
-
1195
- if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
1196
- error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1197
- }
1198
- }
1199
- }
1200
- /**
1201
- * Given a fragment, validate that it can only be provided with fragment props
1202
- * @param {ReactElement} fragment
1203
- */
1204
-
1205
-
1206
- function validateFragmentProps(fragment) {
1207
- {
1208
- var keys = Object.keys(fragment.props);
1209
-
1210
- for (var i = 0; i < keys.length; i++) {
1211
- var key = keys[i];
1212
-
1213
- if (key !== 'children' && key !== 'key') {
1214
- setCurrentlyValidatingElement$1(fragment);
1215
-
1216
- error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1217
-
1218
- setCurrentlyValidatingElement$1(null);
1219
- break;
1220
- }
1221
- }
1222
-
1223
- if (fragment.ref !== null) {
1224
- setCurrentlyValidatingElement$1(fragment);
1225
-
1226
- error('Invalid attribute `ref` supplied to `React.Fragment`.');
1227
-
1228
- setCurrentlyValidatingElement$1(null);
1229
- }
1230
- }
1231
- }
1232
-
1233
- var didWarnAboutKeySpread = {};
1234
- function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1235
- {
1236
- var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
1237
- // succeed and there will likely be errors in render.
1238
-
1239
- if (!validType) {
1240
- var info = '';
1241
-
1242
- if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1243
- 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.";
1244
- }
1245
-
1246
- var sourceInfo = getSourceInfoErrorAddendum();
1247
-
1248
- if (sourceInfo) {
1249
- info += sourceInfo;
1250
- } else {
1251
- info += getDeclarationErrorAddendum();
1252
- }
1253
-
1254
- var typeString;
1255
-
1256
- if (type === null) {
1257
- typeString = 'null';
1258
- } else if (isArray(type)) {
1259
- typeString = 'array';
1260
- } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1261
- typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
1262
- info = ' Did you accidentally export a JSX literal instead of a component?';
1263
- } else {
1264
- typeString = typeof type;
1265
- }
1266
-
1267
- 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);
1268
- }
1269
-
1270
- var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
1271
- // TODO: Drop this when these are no longer allowed as the type argument.
1272
-
1273
- if (element == null) {
1274
- return element;
1275
- } // Skip key warning if the type isn't valid since our key validation logic
1276
- // doesn't expect a non-string/function type and can throw confusing errors.
1277
- // We don't want exception behavior to differ between dev and prod.
1278
- // (Rendering will throw with a helpful message and as soon as the type is
1279
- // fixed, the key warnings will appear.)
1280
-
1281
-
1282
- if (validType) {
1283
- var children = props.children;
1284
-
1285
- if (children !== undefined) {
1286
- if (isStaticChildren) {
1287
- if (isArray(children)) {
1288
- for (var i = 0; i < children.length; i++) {
1289
- validateChildKeys(children[i], type);
1290
- }
1291
-
1292
- if (Object.freeze) {
1293
- Object.freeze(children);
1294
- }
1295
- } else {
1296
- 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.');
1297
- }
1298
- } else {
1299
- validateChildKeys(children, type);
1300
- }
1301
- }
1302
- }
1303
-
1304
- {
1305
- if (hasOwnProperty.call(props, 'key')) {
1306
- var componentName = getComponentNameFromType(type);
1307
- var keys = Object.keys(props).filter(function (k) {
1308
- return k !== 'key';
1309
- });
1310
- var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
1311
-
1312
- if (!didWarnAboutKeySpread[componentName + beforeExample]) {
1313
- var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
1314
-
1315
- error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
1316
-
1317
- didWarnAboutKeySpread[componentName + beforeExample] = true;
1318
- }
1319
- }
1320
- }
1321
-
1322
- if (type === REACT_FRAGMENT_TYPE) {
1323
- validateFragmentProps(element);
1324
- } else {
1325
- validatePropTypes(element);
1326
- }
1327
-
1328
- return element;
1329
- }
1330
- } // These two functions exist to still get child warnings in dev
1331
- // even with the prod transform. This means that jsxDEV is purely
1332
- // opt-in behavior for better messages but that we won't stop
1333
- // giving you warnings if you use production apis.
1334
-
1335
- function jsxWithValidationStatic(type, props, key) {
1336
- {
1337
- return jsxWithValidation(type, props, key, true);
1338
- }
1339
- }
1340
- function jsxWithValidationDynamic(type, props, key) {
1341
- {
1342
- return jsxWithValidation(type, props, key, false);
1343
- }
1344
- }
1345
-
1346
- var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
1347
- // for now we can ship identical prod functions
1348
-
1349
- var jsxs = jsxWithValidationStatic ;
1350
-
1351
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
1352
- reactJsxRuntime_development.jsx = jsx;
1353
- reactJsxRuntime_development.jsxs = jsxs;
1354
- })();
1355
- }
1356
- return reactJsxRuntime_development;
1357
- }
1358
-
1359
- if (process.env.NODE_ENV === 'production') {
1360
- jsxRuntime.exports = requireReactJsxRuntime_production_min();
1361
- } else {
1362
- jsxRuntime.exports = requireReactJsxRuntime_development();
1363
- }
1364
-
1365
- var jsxRuntimeExports = jsxRuntime.exports;
8
+ import similarity from 'compute-cosine-similarity';
1366
9
 
1367
10
  // Create context for notification handler
1368
11
  const NotificationContext = createContext(null);
@@ -1386,7 +29,7 @@ const NotificationContext = createContext(null);
1386
29
  * ```
1387
30
  */
1388
31
  const NotificationProvider = ({ children, handler, }) => {
1389
- return (jsxRuntimeExports.jsx(NotificationContext.Provider, { value: handler, children: children }));
32
+ return (jsx(NotificationContext.Provider, { value: handler, children: children }));
1390
33
  };
1391
34
 
1392
35
  /**
@@ -1527,6 +170,16 @@ const useConversation = create()((set) => ({
1527
170
  },
1528
171
  ],
1529
172
  })),
173
+ updateLastMessage: (text) => set((state) => {
174
+ if (state.messages.length === 0)
175
+ return state;
176
+ const messages = [...state.messages];
177
+ messages[messages.length - 1] = {
178
+ ...messages[messages.length - 1],
179
+ text: text,
180
+ };
181
+ return { messages };
182
+ }),
1530
183
  setInput: (v) => set(() => ({
1531
184
  input: v,
1532
185
  })),
@@ -2766,269 +1419,6 @@ const useGraphEmbeddings = ({ flow, vecs, limit, collection }) => {
2766
1419
  };
2767
1420
  };
2768
1421
 
2769
- /**
2770
- * FUNCTION: isArray( value )
2771
- * Validates if a value is an array.
2772
- *
2773
- * @param {*} value - value to be validated
2774
- * @returns {Boolean} boolean indicating whether value is an array
2775
- */
2776
- function isArray$3( value ) {
2777
- return Object.prototype.toString.call( value ) === '[object Array]';
2778
- } // end FUNCTION isArray()
2779
-
2780
- // EXPORTS //
2781
-
2782
- var lib$4 = Array.isArray || isArray$3;
2783
-
2784
- /**
2785
- *
2786
- * VALIDATE: function
2787
- *
2788
- *
2789
- * DESCRIPTION:
2790
- * - Validates if a value is a function.
2791
- *
2792
- *
2793
- * NOTES:
2794
- * [1]
2795
- *
2796
- *
2797
- * TODO:
2798
- * [1]
2799
- *
2800
- *
2801
- * LICENSE:
2802
- * MIT
2803
- *
2804
- * Copyright (c) 2014. Athan Reines.
2805
- *
2806
- *
2807
- * AUTHOR:
2808
- * Athan Reines. kgryte@gmail.com. 2014.
2809
- *
2810
- */
2811
-
2812
- /**
2813
- * FUNCTION: isFunction( value )
2814
- * Validates if a value is a function.
2815
- *
2816
- * @param {*} value - value to be validated
2817
- * @returns {Boolean} boolean indicating whether value is a function
2818
- */
2819
- function isFunction$3( value ) {
2820
- return ( typeof value === 'function' );
2821
- } // end FUNCTION isFunction()
2822
-
2823
-
2824
- // EXPORTS //
2825
-
2826
- var lib$3 = isFunction$3;
2827
-
2828
- // MODULES //
2829
-
2830
- var isArray$2 = lib$4,
2831
- isFunction$2 = lib$3;
2832
-
2833
-
2834
- // DOT PRODUCT //
2835
-
2836
- /**
2837
- * FUNCTION: dot( x, y[, accessor] )
2838
- * Computes the dot product between two arrays.
2839
- *
2840
- * @param {Array} x - input array
2841
- * @param {Array} y - input array
2842
- * @param {Function} [accessor] - accessor function for accessing array values
2843
- * @returns {Number|Null} dot product
2844
- */
2845
- function dot$1( x, y, clbk ) {
2846
- if ( !isArray$2( x ) ) {
2847
- throw new TypeError( 'dot()::invalid input argument. First argument must be an array. Value: `' + x + '`.' );
2848
- }
2849
- if ( !isArray$2( y ) ) {
2850
- throw new TypeError( 'dot()::invalid input argument. Second argument must be an array. Value: `' + y + '`.' );
2851
- }
2852
- if ( arguments.length > 2 ) {
2853
- if ( !isFunction$2( clbk ) ) {
2854
- throw new TypeError( 'dot()::invalid input argument. Accessor must be a function. Value: `' + clbk + '`.' );
2855
- }
2856
- }
2857
- var len = x.length,
2858
- sum = 0,
2859
- i;
2860
-
2861
- if ( len !== y.length ) {
2862
- throw new Error( 'dot()::invalid input argument. Arrays must be of equal length.' );
2863
- }
2864
- if ( !len ) {
2865
- return null;
2866
- }
2867
- if ( clbk ) {
2868
- for ( i = 0; i < len; i++ ) {
2869
- sum += clbk( x[ i ], i, 0 ) * clbk( y[ i ], i, 1 );
2870
- }
2871
- } else {
2872
- for ( i = 0; i < len; i++ ) {
2873
- sum += x[ i ] * y[ i ];
2874
- }
2875
- }
2876
- return sum;
2877
- } // end FUNCTION dot()
2878
-
2879
-
2880
- // EXPORTS //
2881
-
2882
- var lib$2 = dot$1;
2883
-
2884
- // MODULES //
2885
-
2886
- var isArray$1 = lib$4,
2887
- isFunction$1 = lib$3;
2888
-
2889
-
2890
- // L2NORM //
2891
-
2892
- /**
2893
- * FUNCTION: l2norm( arr[, accessor] )
2894
- * Calculates the L2 norm (Euclidean norm) of an array.
2895
- *
2896
- * @param {Array} arr - input array
2897
- * @param {Function} [accessor] - accessor function for accessing array values
2898
- * @returns {Number|Null} L2 norm or null
2899
- */
2900
- function l2norm$1( arr, clbk ) {
2901
- if ( !isArray$1( arr ) ) {
2902
- throw new TypeError( 'l2norm()::invalid input argument. Must provide an array. Value: `' + arr + '`.' );
2903
- }
2904
- if ( arguments.length > 1 ) {
2905
- if ( !isFunction$1( clbk ) ) {
2906
- throw new TypeError( 'l2norm()::invalid input argument. Accessor must be a function. Value: `' + clbk + '`.' );
2907
- }
2908
- }
2909
- var len = arr.length,
2910
- t = 0,
2911
- s = 1,
2912
- r,
2913
- val,
2914
- abs,
2915
- i;
2916
-
2917
- if ( !len ) {
2918
- return null;
2919
- }
2920
- if ( clbk ) {
2921
- for ( i = 0; i < len; i++ ) {
2922
- val = clbk( arr[ i ], i );
2923
- abs = ( val < 0 ) ? -val : val;
2924
- if ( abs > 0 ) {
2925
- if ( abs > t ) {
2926
- r = t / val;
2927
- s = 1 + s*r*r;
2928
- t = abs;
2929
- } else {
2930
- r = val / t;
2931
- s = s + r*r;
2932
- }
2933
- }
2934
- }
2935
- } else {
2936
- for ( i = 0; i < len; i++ ) {
2937
- val = arr[ i ];
2938
- abs = ( val < 0 ) ? -val : val;
2939
- if ( abs > 0 ) {
2940
- if ( abs > t ) {
2941
- r = t / val;
2942
- s = 1 + s*r*r;
2943
- t = abs;
2944
- } else {
2945
- r = val / t;
2946
- s = s + r*r;
2947
- }
2948
- }
2949
- }
2950
- }
2951
- return t * Math.sqrt( s );
2952
- } // end FUNCTION l2norm()
2953
-
2954
-
2955
- // EXPORTS //
2956
-
2957
- var lib$1 = l2norm$1;
2958
-
2959
- // MODULES //
2960
-
2961
- var dot = lib$2,
2962
- l2norm = lib$1,
2963
- isArray = lib$4,
2964
- isFunction = lib$3;
2965
-
2966
-
2967
- // FUNCTIONS //
2968
-
2969
- /**
2970
- * Partially applied function from the right.
2971
- *
2972
- * @private
2973
- * @param {Function} fn - input function
2974
- * @param {number} j - array index
2975
- * @returns {Function} partially applied function
2976
- */
2977
- function partial( fn, j ) {
2978
- return function accessor( d, i ) {
2979
- return fn( d, i, j );
2980
- };
2981
- }
2982
-
2983
-
2984
- // MAIN //
2985
-
2986
- /**
2987
- * Computes the cosine similarity between two arrays.
2988
- *
2989
- * @param {number[]|Array} x - input array
2990
- * @param {number[]|Array} y - input array
2991
- * @param {Function} [accessor] - accessor function for accessing array values
2992
- * @returns {number|null} cosine similarity or null
2993
- */
2994
- function similarity( x, y, clbk ) {
2995
- var a, b, c;
2996
- if ( !isArray( x ) ) {
2997
- throw new TypeError( 'cosine-similarity()::invalid input argument. First argument must be an array. Value: `' + x + '`.' );
2998
- }
2999
- if ( !isArray( y ) ) {
3000
- throw new TypeError( 'cosine-similarity()::invalid input argument. Second argument must be an array. Value: `' + y + '`.' );
3001
- }
3002
- if ( arguments.length > 2 ) {
3003
- if ( !isFunction( clbk ) ) {
3004
- throw new TypeError( 'cosine-similarity()::invalid input argument. Accessor must be a function. Value: `' + clbk + '`.' );
3005
- }
3006
- }
3007
- if ( x.length !== y.length ) {
3008
- throw new Error( 'cosine-similarity()::invalid input argument. Input arrays must have the same length.' );
3009
- }
3010
- if ( !x.length ) {
3011
- return null;
3012
- }
3013
- if ( clbk ) {
3014
- a = dot( x, y, clbk );
3015
- b = l2norm( x, partial( clbk, 0 ) );
3016
- c = l2norm( y, partial( clbk, 1 ) );
3017
- } else {
3018
- a = dot( x, y );
3019
- b = l2norm( x );
3020
- c = l2norm( y );
3021
- }
3022
- return a / ( b*c );
3023
- }
3024
-
3025
-
3026
- // EXPORTS //
3027
-
3028
- var lib = similarity;
3029
-
3030
- var similarity$1 = /*@__PURE__*/getDefaultExportFromCjs(lib);
3031
-
3032
1422
  // Take the embeddings, and lookup entities using graph
3033
1423
  // embeddings, add embedding to each entity row, just an easy
3034
1424
  // place to put it
@@ -3148,7 +1538,7 @@ const addRowEmbeddings = (socket, add, remove) => (entities) => {
3148
1538
  };
3149
1539
  // Rest of the procecess is not async, so not adding progress
3150
1540
  const computeCosineSimilarity = () => (entities) => entities.map((ent) => {
3151
- const sim = similarity$1(ent.target, ent.embeddings);
1541
+ const sim = similarity(ent.target, ent.embeddings);
3152
1542
  return {
3153
1543
  uri: ent.uri,
3154
1544
  label: ent.label,
@@ -3318,11 +1708,27 @@ const useInference = () => {
3318
1708
  * Graph RAG inference with entity discovery
3319
1709
  */
3320
1710
  const graphRagMutation = useMutation({
3321
- mutationFn: async ({ input, options, collection, }) => {
3322
- // Execute Graph RAG request
3323
- const response = await socket
3324
- .flow(flowId)
3325
- .graphRag(input, options || {}, collection);
1711
+ mutationFn: async ({ input, options, collection, callbacks, }) => {
1712
+ // If callbacks provided, use streaming API
1713
+ const response = callbacks
1714
+ ? await new Promise((resolve, reject) => {
1715
+ let accumulated = "";
1716
+ const onChunk = (chunk, complete) => {
1717
+ accumulated += chunk;
1718
+ callbacks?.onChunk?.(chunk, complete);
1719
+ if (complete) {
1720
+ resolve(accumulated);
1721
+ }
1722
+ };
1723
+ const onError = (error) => {
1724
+ callbacks?.onError?.(error);
1725
+ reject(new Error(error));
1726
+ };
1727
+ socket
1728
+ .flow(flowId)
1729
+ .graphRagStreaming(input, onChunk, onError, options, collection);
1730
+ })
1731
+ : await socket.flow(flowId).graphRag(input, options || {}, collection);
3326
1732
  // Get embeddings for entity discovery
3327
1733
  const embeddings = await socket.flow(flowId).embeddings(input);
3328
1734
  // Query graph embeddings to find entities
@@ -3336,8 +1742,27 @@ const useInference = () => {
3336
1742
  * Basic LLM text completion
3337
1743
  */
3338
1744
  const textCompletionMutation = useMutation({
3339
- mutationFn: async ({ systemPrompt, input, }) => {
3340
- return await socket.flow(flowId).textCompletion(systemPrompt, input);
1745
+ mutationFn: async ({ systemPrompt, input, callbacks, }) => {
1746
+ // If callbacks provided, use streaming API
1747
+ return callbacks
1748
+ ? await new Promise((resolve, reject) => {
1749
+ let accumulated = "";
1750
+ const onChunk = (chunk, complete) => {
1751
+ accumulated += chunk;
1752
+ callbacks?.onChunk?.(chunk, complete);
1753
+ if (complete) {
1754
+ resolve(accumulated);
1755
+ }
1756
+ };
1757
+ const onError = (error) => {
1758
+ callbacks?.onError?.(error);
1759
+ reject(new Error(error));
1760
+ };
1761
+ socket
1762
+ .flow(flowId)
1763
+ .textCompletionStreaming(systemPrompt, input, onChunk, onError);
1764
+ })
1765
+ : await socket.flow(flowId).textCompletion(systemPrompt, input);
3341
1766
  },
3342
1767
  });
3343
1768
  /**
@@ -3346,15 +1771,19 @@ const useInference = () => {
3346
1771
  const agentMutation = useMutation({
3347
1772
  mutationFn: async ({ input, callbacks, }) => {
3348
1773
  return new Promise((resolve, reject) => {
3349
- const onThink = (thought) => {
3350
- callbacks?.onThink?.(thought);
1774
+ let fullAnswer = "";
1775
+ const onThink = (thought, complete) => {
1776
+ callbacks?.onThink?.(thought, complete);
3351
1777
  };
3352
- const onObserve = (observation) => {
3353
- callbacks?.onObserve?.(observation);
1778
+ const onObserve = (observation, complete) => {
1779
+ callbacks?.onObserve?.(observation, complete);
3354
1780
  };
3355
- const onAnswer = (answer) => {
3356
- callbacks?.onAnswer?.(answer);
3357
- resolve(answer);
1781
+ const onAnswer = (answer, complete) => {
1782
+ fullAnswer += answer;
1783
+ callbacks?.onAnswer?.(answer, complete);
1784
+ if (complete) {
1785
+ resolve(fullAnswer);
1786
+ }
3358
1787
  };
3359
1788
  const onError = (error) => {
3360
1789
  callbacks?.onError?.(error);
@@ -3386,6 +1815,7 @@ const useChatSession = () => {
3386
1815
  const notify = useNotification();
3387
1816
  // Conversation state
3388
1817
  const addMessage = useConversation((state) => state.addMessage);
1818
+ const updateLastMessage = useConversation((state) => state.updateLastMessage);
3389
1819
  const setInput = useConversation((state) => state.setInput);
3390
1820
  const chatMode = useConversation((state) => state.chatMode);
3391
1821
  // Progress and activity management
@@ -3405,8 +1835,10 @@ const useChatSession = () => {
3405
1835
  const ragActivity = "Graph RAG: " + input;
3406
1836
  const embActivity = "Find entities: " + input;
3407
1837
  addActivity(ragActivity);
1838
+ let accumulated = "";
1839
+ let messageAdded = false;
3408
1840
  try {
3409
- // Execute Graph RAG with entity discovery
1841
+ // Execute Graph RAG with streaming and entity discovery
3410
1842
  const result = await inference.graphRag({
3411
1843
  input,
3412
1844
  options: {
@@ -3416,8 +1848,21 @@ const useChatSession = () => {
3416
1848
  pathLength: settings.graphrag.pathLength,
3417
1849
  },
3418
1850
  collection: settings.collection,
1851
+ callbacks: {
1852
+ onChunk: (chunk, complete) => {
1853
+ accumulated += chunk;
1854
+ if (!messageAdded) {
1855
+ // Add empty message on first chunk
1856
+ addMessage("ai", accumulated);
1857
+ messageAdded = true;
1858
+ }
1859
+ else {
1860
+ // Update existing message with accumulated text
1861
+ updateLastMessage(accumulated);
1862
+ }
1863
+ },
1864
+ },
3419
1865
  });
3420
- addMessage("ai", result.response);
3421
1866
  removeActivity(ragActivity);
3422
1867
  // Start embeddings activity
3423
1868
  addActivity(embActivity);
@@ -3461,12 +1906,27 @@ const useChatSession = () => {
3461
1906
  const handleBasicLlm = async (input) => {
3462
1907
  const activity = "Text completion: " + input;
3463
1908
  addActivity(activity);
1909
+ let accumulated = "";
1910
+ let messageAdded = false;
3464
1911
  try {
3465
1912
  const response = await inference.textCompletion({
3466
1913
  systemPrompt: "You are a helpful assistant. Provide clear and concise responses.",
3467
1914
  input,
1915
+ callbacks: {
1916
+ onChunk: (chunk, complete) => {
1917
+ accumulated += chunk;
1918
+ if (!messageAdded) {
1919
+ // Add empty message on first chunk
1920
+ addMessage("ai", accumulated);
1921
+ messageAdded = true;
1922
+ }
1923
+ else {
1924
+ // Update existing message with accumulated text
1925
+ updateLastMessage(accumulated);
1926
+ }
1927
+ },
1928
+ },
3468
1929
  });
3469
- addMessage("ai", response);
3470
1930
  removeActivity(activity);
3471
1931
  setEntities([]);
3472
1932
  return response;
@@ -3482,13 +1942,54 @@ const useChatSession = () => {
3482
1942
  const handleAgent = async (input) => {
3483
1943
  const activity = "Agent: " + input;
3484
1944
  addActivity(activity);
1945
+ let thinkingAccumulated = "";
1946
+ let thinkingMessageAdded = false;
1947
+ let observationAccumulated = "";
1948
+ let observationMessageAdded = false;
1949
+ let answerAccumulated = "";
1950
+ let answerMessageAdded = false;
3485
1951
  try {
3486
1952
  const response = await inference.agent({
3487
1953
  input,
3488
1954
  callbacks: {
3489
- onThink: (thought) => addMessage("ai", thought, "thinking"),
3490
- onObserve: (observation) => addMessage("ai", observation, "observation"),
3491
- onAnswer: (answer) => addMessage("ai", answer, "answer"),
1955
+ onThink: (thought, complete) => {
1956
+ thinkingAccumulated += thought;
1957
+ if (!thinkingMessageAdded) {
1958
+ addMessage("ai", thinkingAccumulated, "thinking");
1959
+ thinkingMessageAdded = true;
1960
+ }
1961
+ else {
1962
+ updateLastMessage(thinkingAccumulated);
1963
+ }
1964
+ if (complete) {
1965
+ thinkingAccumulated = "";
1966
+ thinkingMessageAdded = false;
1967
+ }
1968
+ },
1969
+ onObserve: (observation, complete) => {
1970
+ observationAccumulated += observation;
1971
+ if (!observationMessageAdded) {
1972
+ addMessage("ai", observationAccumulated, "observation");
1973
+ observationMessageAdded = true;
1974
+ }
1975
+ else {
1976
+ updateLastMessage(observationAccumulated);
1977
+ }
1978
+ if (complete) {
1979
+ observationAccumulated = "";
1980
+ observationMessageAdded = false;
1981
+ }
1982
+ },
1983
+ onAnswer: (answer, complete) => {
1984
+ answerAccumulated += answer;
1985
+ if (!answerMessageAdded) {
1986
+ addMessage("ai", answerAccumulated, "answer");
1987
+ answerMessageAdded = true;
1988
+ }
1989
+ else {
1990
+ updateLastMessage(answerAccumulated);
1991
+ }
1992
+ },
3492
1993
  },
3493
1994
  });
3494
1995
  removeActivity(activity);