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