integrate-sdk 0.5.4 → 0.5.6

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.js CHANGED
@@ -1,20 +1,4 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
1
  var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
2
  var __export = (target, all) => {
19
3
  for (var name in all)
20
4
  __defProp(target, name, {
package/dist/oauth.js CHANGED
@@ -1,20 +1,4 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
1
  var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
2
  var __export = (target, all) => {
19
3
  for (var name in all)
20
4
  __defProp(target, name, {
package/dist/react.js CHANGED
@@ -1,20 +1,4 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
1
  var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
2
  var __export = (target, all) => {
19
3
  for (var name in all)
20
4
  __defProp(target, name, {
@@ -26,853 +10,16 @@ var __export = (target, all) => {
26
10
  };
27
11
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
12
 
29
- // node_modules/react/cjs/react.development.js
30
- var require_react_development = __commonJS((exports, module) => {
31
- (function() {
32
- function defineDeprecationWarning(methodName, info) {
33
- Object.defineProperty(Component.prototype, methodName, {
34
- get: function() {
35
- console.warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
36
- }
37
- });
38
- }
39
- function getIteratorFn(maybeIterable) {
40
- if (maybeIterable === null || typeof maybeIterable !== "object")
41
- return null;
42
- maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
43
- return typeof maybeIterable === "function" ? maybeIterable : null;
44
- }
45
- function warnNoop(publicInstance, callerName) {
46
- publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
47
- var warningKey = publicInstance + "." + callerName;
48
- didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", callerName, publicInstance), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
49
- }
50
- function Component(props, context, updater) {
51
- this.props = props;
52
- this.context = context;
53
- this.refs = emptyObject;
54
- this.updater = updater || ReactNoopUpdateQueue;
55
- }
56
- function ComponentDummy() {}
57
- function PureComponent(props, context, updater) {
58
- this.props = props;
59
- this.context = context;
60
- this.refs = emptyObject;
61
- this.updater = updater || ReactNoopUpdateQueue;
62
- }
63
- function noop() {}
64
- function testStringCoercion(value) {
65
- return "" + value;
66
- }
67
- function checkKeyStringCoercion(value) {
68
- try {
69
- testStringCoercion(value);
70
- var JSCompiler_inline_result = false;
71
- } catch (e) {
72
- JSCompiler_inline_result = true;
73
- }
74
- if (JSCompiler_inline_result) {
75
- JSCompiler_inline_result = console;
76
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
77
- var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
78
- JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
79
- return testStringCoercion(value);
80
- }
81
- }
82
- function getComponentNameFromType(type) {
83
- if (type == null)
84
- return null;
85
- if (typeof type === "function")
86
- return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
87
- if (typeof type === "string")
88
- return type;
89
- switch (type) {
90
- case REACT_FRAGMENT_TYPE:
91
- return "Fragment";
92
- case REACT_PROFILER_TYPE:
93
- return "Profiler";
94
- case REACT_STRICT_MODE_TYPE:
95
- return "StrictMode";
96
- case REACT_SUSPENSE_TYPE:
97
- return "Suspense";
98
- case REACT_SUSPENSE_LIST_TYPE:
99
- return "SuspenseList";
100
- case REACT_ACTIVITY_TYPE:
101
- return "Activity";
102
- }
103
- if (typeof type === "object")
104
- switch (typeof type.tag === "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
105
- case REACT_PORTAL_TYPE:
106
- return "Portal";
107
- case REACT_CONTEXT_TYPE:
108
- return type.displayName || "Context";
109
- case REACT_CONSUMER_TYPE:
110
- return (type._context.displayName || "Context") + ".Consumer";
111
- case REACT_FORWARD_REF_TYPE:
112
- var innerType = type.render;
113
- type = type.displayName;
114
- type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
115
- return type;
116
- case REACT_MEMO_TYPE:
117
- return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
118
- case REACT_LAZY_TYPE:
119
- innerType = type._payload;
120
- type = type._init;
121
- try {
122
- return getComponentNameFromType(type(innerType));
123
- } catch (x) {}
124
- }
125
- return null;
126
- }
127
- function getTaskName(type) {
128
- if (type === REACT_FRAGMENT_TYPE)
129
- return "<>";
130
- if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
131
- return "<...>";
132
- try {
133
- var name = getComponentNameFromType(type);
134
- return name ? "<" + name + ">" : "<...>";
135
- } catch (x) {
136
- return "<...>";
137
- }
138
- }
139
- function getOwner() {
140
- var dispatcher = ReactSharedInternals.A;
141
- return dispatcher === null ? null : dispatcher.getOwner();
142
- }
143
- function UnknownOwner() {
144
- return Error("react-stack-top-frame");
145
- }
146
- function hasValidKey(config) {
147
- if (hasOwnProperty.call(config, "key")) {
148
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
149
- if (getter && getter.isReactWarning)
150
- return false;
151
- }
152
- return config.key !== undefined;
153
- }
154
- function defineKeyPropWarningGetter(props, displayName) {
155
- function warnAboutAccessingKey() {
156
- specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.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://react.dev/link/special-props)", displayName));
157
- }
158
- warnAboutAccessingKey.isReactWarning = true;
159
- Object.defineProperty(props, "key", {
160
- get: warnAboutAccessingKey,
161
- configurable: true
162
- });
163
- }
164
- function elementRefGetterWithDeprecationWarning() {
165
- var componentName = getComponentNameFromType(this.type);
166
- didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."));
167
- componentName = this.props.ref;
168
- return componentName !== undefined ? componentName : null;
169
- }
170
- function ReactElement(type, key, props, owner, debugStack, debugTask) {
171
- var refProp = props.ref;
172
- type = {
173
- $$typeof: REACT_ELEMENT_TYPE,
174
- type,
175
- key,
176
- props,
177
- _owner: owner
178
- };
179
- (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
180
- enumerable: false,
181
- get: elementRefGetterWithDeprecationWarning
182
- }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
183
- type._store = {};
184
- Object.defineProperty(type._store, "validated", {
185
- configurable: false,
186
- enumerable: false,
187
- writable: true,
188
- value: 0
189
- });
190
- Object.defineProperty(type, "_debugInfo", {
191
- configurable: false,
192
- enumerable: false,
193
- writable: true,
194
- value: null
195
- });
196
- Object.defineProperty(type, "_debugStack", {
197
- configurable: false,
198
- enumerable: false,
199
- writable: true,
200
- value: debugStack
201
- });
202
- Object.defineProperty(type, "_debugTask", {
203
- configurable: false,
204
- enumerable: false,
205
- writable: true,
206
- value: debugTask
207
- });
208
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
209
- return type;
210
- }
211
- function cloneAndReplaceKey(oldElement, newKey) {
212
- newKey = ReactElement(oldElement.type, newKey, oldElement.props, oldElement._owner, oldElement._debugStack, oldElement._debugTask);
213
- oldElement._store && (newKey._store.validated = oldElement._store.validated);
214
- return newKey;
215
- }
216
- function validateChildKeys(node) {
217
- isValidElement(node) ? node._store && (node._store.validated = 1) : typeof node === "object" && node !== null && node.$$typeof === REACT_LAZY_TYPE && (node._payload.status === "fulfilled" ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
218
- }
219
- function isValidElement(object) {
220
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
221
- }
222
- function escape(key) {
223
- var escaperLookup = { "=": "=0", ":": "=2" };
224
- return "$" + key.replace(/[=:]/g, function(match) {
225
- return escaperLookup[match];
226
- });
227
- }
228
- function getElementKey(element, index) {
229
- return typeof element === "object" && element !== null && element.key != null ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
230
- }
231
- function resolveThenable(thenable) {
232
- switch (thenable.status) {
233
- case "fulfilled":
234
- return thenable.value;
235
- case "rejected":
236
- throw thenable.reason;
237
- default:
238
- switch (typeof thenable.status === "string" ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(function(fulfilledValue) {
239
- thenable.status === "pending" && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
240
- }, function(error) {
241
- thenable.status === "pending" && (thenable.status = "rejected", thenable.reason = error);
242
- })), thenable.status) {
243
- case "fulfilled":
244
- return thenable.value;
245
- case "rejected":
246
- throw thenable.reason;
247
- }
248
- }
249
- throw thenable;
250
- }
251
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
252
- var type = typeof children;
253
- if (type === "undefined" || type === "boolean")
254
- children = null;
255
- var invokeCallback = false;
256
- if (children === null)
257
- invokeCallback = true;
258
- else
259
- switch (type) {
260
- case "bigint":
261
- case "string":
262
- case "number":
263
- invokeCallback = true;
264
- break;
265
- case "object":
266
- switch (children.$$typeof) {
267
- case REACT_ELEMENT_TYPE:
268
- case REACT_PORTAL_TYPE:
269
- invokeCallback = true;
270
- break;
271
- case REACT_LAZY_TYPE:
272
- return invokeCallback = children._init, mapIntoArray(invokeCallback(children._payload), array, escapedPrefix, nameSoFar, callback);
273
- }
274
- }
275
- if (invokeCallback) {
276
- invokeCallback = children;
277
- callback = callback(invokeCallback);
278
- var childKey = nameSoFar === "" ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
279
- isArrayImpl(callback) ? (escapedPrefix = "", childKey != null && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
280
- return c;
281
- })) : callback != null && (isValidElement(callback) && (callback.key != null && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(callback, escapedPrefix + (callback.key == null || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(userProvidedKeyEscapeRegex, "$&/") + "/") + childKey), nameSoFar !== "" && invokeCallback != null && isValidElement(invokeCallback) && invokeCallback.key == null && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
282
- return 1;
283
- }
284
- invokeCallback = 0;
285
- childKey = nameSoFar === "" ? "." : nameSoFar + ":";
286
- if (isArrayImpl(children))
287
- for (var i = 0;i < children.length; i++)
288
- nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
289
- else if (i = getIteratorFn(children), typeof i === "function")
290
- for (i === children.entries && (didWarnAboutMaps || console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."), didWarnAboutMaps = true), children = i.call(children), i = 0;!(nameSoFar = children.next()).done; )
291
- nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
292
- else if (type === "object") {
293
- if (typeof children.then === "function")
294
- return mapIntoArray(resolveThenable(children), array, escapedPrefix, nameSoFar, callback);
295
- array = String(children);
296
- throw Error("Objects are not valid as a React child (found: " + (array === "[object Object]" ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead.");
297
- }
298
- return invokeCallback;
299
- }
300
- function mapChildren(children, func, context) {
301
- if (children == null)
302
- return children;
303
- var result = [], count = 0;
304
- mapIntoArray(children, result, "", "", function(child) {
305
- return func.call(context, child, count++);
306
- });
307
- return result;
308
- }
309
- function lazyInitializer(payload) {
310
- if (payload._status === -1) {
311
- var ioInfo = payload._ioInfo;
312
- ioInfo != null && (ioInfo.start = ioInfo.end = performance.now());
313
- ioInfo = payload._result;
314
- var thenable = ioInfo();
315
- thenable.then(function(moduleObject) {
316
- if (payload._status === 0 || payload._status === -1) {
317
- payload._status = 1;
318
- payload._result = moduleObject;
319
- var _ioInfo = payload._ioInfo;
320
- _ioInfo != null && (_ioInfo.end = performance.now());
321
- thenable.status === undefined && (thenable.status = "fulfilled", thenable.value = moduleObject);
322
- }
323
- }, function(error) {
324
- if (payload._status === 0 || payload._status === -1) {
325
- payload._status = 2;
326
- payload._result = error;
327
- var _ioInfo2 = payload._ioInfo;
328
- _ioInfo2 != null && (_ioInfo2.end = performance.now());
329
- thenable.status === undefined && (thenable.status = "rejected", thenable.reason = error);
330
- }
331
- });
332
- ioInfo = payload._ioInfo;
333
- if (ioInfo != null) {
334
- ioInfo.value = thenable;
335
- var displayName = thenable.displayName;
336
- typeof displayName === "string" && (ioInfo.name = displayName);
337
- }
338
- payload._status === -1 && (payload._status = 0, payload._result = thenable);
339
- }
340
- if (payload._status === 1)
341
- return ioInfo = payload._result, ioInfo === undefined && console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
342
-
343
- Your code should look like:
344
- const MyComponent = lazy(() => import('./MyComponent'))
345
-
346
- Did you accidentally put curly braces around the import?`, ioInfo), "default" in ioInfo || console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
347
-
348
- Your code should look like:
349
- const MyComponent = lazy(() => import('./MyComponent'))`, ioInfo), ioInfo.default;
350
- throw payload._result;
351
- }
352
- function resolveDispatcher() {
353
- var dispatcher = ReactSharedInternals.H;
354
- dispatcher === null && console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
355
- 1. You might have mismatching versions of React and the renderer (such as React DOM)
356
- 2. You might be breaking the Rules of Hooks
357
- 3. You might have more than one copy of React in the same app
358
- See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`);
359
- return dispatcher;
360
- }
361
- function releaseAsyncTransition() {
362
- ReactSharedInternals.asyncTransitions--;
363
- }
364
- function enqueueTask(task) {
365
- if (enqueueTaskImpl === null)
366
- try {
367
- var requireString = ("require" + Math.random()).slice(0, 7);
368
- enqueueTaskImpl = (module && module[requireString]).call(module, "timers").setImmediate;
369
- } catch (_err) {
370
- enqueueTaskImpl = function(callback) {
371
- didWarnAboutMessageChannel === false && (didWarnAboutMessageChannel = true, typeof MessageChannel === "undefined" && console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));
372
- var channel = new MessageChannel;
373
- channel.port1.onmessage = callback;
374
- channel.port2.postMessage(undefined);
375
- };
376
- }
377
- return enqueueTaskImpl(task);
378
- }
379
- function aggregateErrors(errors) {
380
- return 1 < errors.length && typeof AggregateError === "function" ? new AggregateError(errors) : errors[0];
381
- }
382
- function popActScope(prevActQueue, prevActScopeDepth) {
383
- prevActScopeDepth !== actScopeDepth - 1 && console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
384
- actScopeDepth = prevActScopeDepth;
385
- }
386
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
387
- var queue = ReactSharedInternals.actQueue;
388
- if (queue !== null)
389
- if (queue.length !== 0)
390
- try {
391
- flushActQueue(queue);
392
- enqueueTask(function() {
393
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
394
- });
395
- return;
396
- } catch (error) {
397
- ReactSharedInternals.thrownErrors.push(error);
398
- }
399
- else
400
- ReactSharedInternals.actQueue = null;
401
- 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
402
- }
403
- function flushActQueue(queue) {
404
- if (!isFlushing) {
405
- isFlushing = true;
406
- var i = 0;
407
- try {
408
- for (;i < queue.length; i++) {
409
- var callback = queue[i];
410
- do {
411
- ReactSharedInternals.didUsePromise = false;
412
- var continuation = callback(false);
413
- if (continuation !== null) {
414
- if (ReactSharedInternals.didUsePromise) {
415
- queue[i] = callback;
416
- queue.splice(0, i);
417
- return;
418
- }
419
- callback = continuation;
420
- } else
421
- break;
422
- } while (1);
423
- }
424
- queue.length = 0;
425
- } catch (error) {
426
- queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
427
- } finally {
428
- isFlushing = false;
429
- }
430
- }
431
- }
432
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
433
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
434
- isMounted: function() {
435
- return false;
436
- },
437
- enqueueForceUpdate: function(publicInstance) {
438
- warnNoop(publicInstance, "forceUpdate");
439
- },
440
- enqueueReplaceState: function(publicInstance) {
441
- warnNoop(publicInstance, "replaceState");
442
- },
443
- enqueueSetState: function(publicInstance) {
444
- warnNoop(publicInstance, "setState");
445
- }
446
- }, assign = Object.assign, emptyObject = {};
447
- Object.freeze(emptyObject);
448
- Component.prototype.isReactComponent = {};
449
- Component.prototype.setState = function(partialState, callback) {
450
- if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null)
451
- throw Error("takes an object of state variables to update or a function which returns an object of state variables.");
452
- this.updater.enqueueSetState(this, partialState, callback, "setState");
453
- };
454
- Component.prototype.forceUpdate = function(callback) {
455
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
456
- };
457
- var deprecatedAPIs = {
458
- isMounted: [
459
- "isMounted",
460
- "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
461
- ],
462
- replaceState: [
463
- "replaceState",
464
- "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
465
- ]
466
- };
467
- for (fnName in deprecatedAPIs)
468
- deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
469
- ComponentDummy.prototype = Component.prototype;
470
- deprecatedAPIs = PureComponent.prototype = new ComponentDummy;
471
- deprecatedAPIs.constructor = PureComponent;
472
- assign(deprecatedAPIs, Component.prototype);
473
- deprecatedAPIs.isPureReactComponent = true;
474
- var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = {
475
- H: null,
476
- A: null,
477
- T: null,
478
- S: null,
479
- actQueue: null,
480
- asyncTransitions: 0,
481
- isBatchingLegacy: false,
482
- didScheduleLegacyUpdate: false,
483
- didUsePromise: false,
484
- thrownErrors: [],
485
- getCurrentStack: null,
486
- recentlyCreatedOwnerStacks: 0
487
- }, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
488
- return null;
489
- };
490
- deprecatedAPIs = {
491
- react_stack_bottom_frame: function(callStackForError) {
492
- return callStackForError();
493
- }
494
- };
495
- var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
496
- var didWarnAboutElementRef = {};
497
- var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(deprecatedAPIs, UnknownOwner)();
498
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
499
- var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = typeof reportError === "function" ? reportError : function(error) {
500
- if (typeof window === "object" && typeof window.ErrorEvent === "function") {
501
- var event = new window.ErrorEvent("error", {
502
- bubbles: true,
503
- cancelable: true,
504
- message: typeof error === "object" && error !== null && typeof error.message === "string" ? String(error.message) : String(error),
505
- error
506
- });
507
- if (!window.dispatchEvent(event))
508
- return;
509
- } else if (typeof process === "object" && typeof process.emit === "function") {
510
- process.emit("uncaughtException", error);
511
- return;
512
- }
513
- console.error(error);
514
- }, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = typeof queueMicrotask === "function" ? function(callback) {
515
- queueMicrotask(function() {
516
- return queueMicrotask(callback);
517
- });
518
- } : enqueueTask;
519
- deprecatedAPIs = Object.freeze({
520
- __proto__: null,
521
- c: function(size) {
522
- return resolveDispatcher().useMemoCache(size);
523
- }
524
- });
525
- var fnName = {
526
- map: mapChildren,
527
- forEach: function(children, forEachFunc, forEachContext) {
528
- mapChildren(children, function() {
529
- forEachFunc.apply(this, arguments);
530
- }, forEachContext);
531
- },
532
- count: function(children) {
533
- var n = 0;
534
- mapChildren(children, function() {
535
- n++;
536
- });
537
- return n;
538
- },
539
- toArray: function(children) {
540
- return mapChildren(children, function(child) {
541
- return child;
542
- }) || [];
543
- },
544
- only: function(children) {
545
- if (!isValidElement(children))
546
- throw Error("React.Children.only expected to receive a single React element child.");
547
- return children;
548
- }
549
- };
550
- exports.Activity = REACT_ACTIVITY_TYPE;
551
- exports.Children = fnName;
552
- exports.Component = Component;
553
- exports.Fragment = REACT_FRAGMENT_TYPE;
554
- exports.Profiler = REACT_PROFILER_TYPE;
555
- exports.PureComponent = PureComponent;
556
- exports.StrictMode = REACT_STRICT_MODE_TYPE;
557
- exports.Suspense = REACT_SUSPENSE_TYPE;
558
- exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
559
- exports.__COMPILER_RUNTIME = deprecatedAPIs;
560
- exports.act = function(callback) {
561
- var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
562
- actScopeDepth++;
563
- var queue = ReactSharedInternals.actQueue = prevActQueue !== null ? prevActQueue : [], didAwaitActCall = false;
564
- try {
565
- var result = callback();
566
- } catch (error) {
567
- ReactSharedInternals.thrownErrors.push(error);
568
- }
569
- if (0 < ReactSharedInternals.thrownErrors.length)
570
- throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
571
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
572
- var thenable = result;
573
- queueSeveralMicrotasks(function() {
574
- didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"));
575
- });
576
- return {
577
- then: function(resolve, reject) {
578
- didAwaitActCall = true;
579
- thenable.then(function(returnValue) {
580
- popActScope(prevActQueue, prevActScopeDepth);
581
- if (prevActScopeDepth === 0) {
582
- try {
583
- flushActQueue(queue), enqueueTask(function() {
584
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
585
- });
586
- } catch (error$0) {
587
- ReactSharedInternals.thrownErrors.push(error$0);
588
- }
589
- if (0 < ReactSharedInternals.thrownErrors.length) {
590
- var _thrownError = aggregateErrors(ReactSharedInternals.thrownErrors);
591
- ReactSharedInternals.thrownErrors.length = 0;
592
- reject(_thrownError);
593
- }
594
- } else
595
- resolve(returnValue);
596
- }, function(error) {
597
- popActScope(prevActQueue, prevActScopeDepth);
598
- 0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
599
- });
600
- }
601
- };
602
- }
603
- var returnValue$jscomp$0 = result;
604
- popActScope(prevActQueue, prevActScopeDepth);
605
- prevActScopeDepth === 0 && (flushActQueue(queue), queue.length !== 0 && queueSeveralMicrotasks(function() {
606
- didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"));
607
- }), ReactSharedInternals.actQueue = null);
608
- if (0 < ReactSharedInternals.thrownErrors.length)
609
- throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
610
- return {
611
- then: function(resolve, reject) {
612
- didAwaitActCall = true;
613
- prevActScopeDepth === 0 ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
614
- return recursivelyFlushAsyncActWork(returnValue$jscomp$0, resolve, reject);
615
- })) : resolve(returnValue$jscomp$0);
616
- }
617
- };
618
- };
619
- exports.cache = function(fn) {
620
- return function() {
621
- return fn.apply(null, arguments);
622
- };
623
- };
624
- exports.cacheSignal = function() {
625
- return null;
626
- };
627
- exports.captureOwnerStack = function() {
628
- var getCurrentStack = ReactSharedInternals.getCurrentStack;
629
- return getCurrentStack === null ? null : getCurrentStack();
630
- };
631
- exports.cloneElement = function(element, config, children) {
632
- if (element === null || element === undefined)
633
- throw Error("The argument must be a React element, but you passed " + element + ".");
634
- var props = assign({}, element.props), key = element.key, owner = element._owner;
635
- if (config != null) {
636
- var JSCompiler_inline_result;
637
- a: {
638
- if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(config, "ref").get) && JSCompiler_inline_result.isReactWarning) {
639
- JSCompiler_inline_result = false;
640
- break a;
641
- }
642
- JSCompiler_inline_result = config.ref !== undefined;
643
- }
644
- JSCompiler_inline_result && (owner = getOwner());
645
- hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
646
- for (propName in config)
647
- !hasOwnProperty.call(config, propName) || propName === "key" || propName === "__self" || propName === "__source" || propName === "ref" && config.ref === undefined || (props[propName] = config[propName]);
648
- }
649
- var propName = arguments.length - 2;
650
- if (propName === 1)
651
- props.children = children;
652
- else if (1 < propName) {
653
- JSCompiler_inline_result = Array(propName);
654
- for (var i = 0;i < propName; i++)
655
- JSCompiler_inline_result[i] = arguments[i + 2];
656
- props.children = JSCompiler_inline_result;
657
- }
658
- props = ReactElement(element.type, key, props, owner, element._debugStack, element._debugTask);
659
- for (key = 2;key < arguments.length; key++)
660
- validateChildKeys(arguments[key]);
661
- return props;
662
- };
663
- exports.createContext = function(defaultValue) {
664
- defaultValue = {
665
- $$typeof: REACT_CONTEXT_TYPE,
666
- _currentValue: defaultValue,
667
- _currentValue2: defaultValue,
668
- _threadCount: 0,
669
- Provider: null,
670
- Consumer: null
671
- };
672
- defaultValue.Provider = defaultValue;
673
- defaultValue.Consumer = {
674
- $$typeof: REACT_CONSUMER_TYPE,
675
- _context: defaultValue
676
- };
677
- defaultValue._currentRenderer = null;
678
- defaultValue._currentRenderer2 = null;
679
- return defaultValue;
680
- };
681
- exports.createElement = function(type, config, children) {
682
- for (var i = 2;i < arguments.length; i++)
683
- validateChildKeys(arguments[i]);
684
- i = {};
685
- var key = null;
686
- if (config != null)
687
- for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
688
- hasOwnProperty.call(config, propName) && propName !== "key" && propName !== "__self" && propName !== "__source" && (i[propName] = config[propName]);
689
- var childrenLength = arguments.length - 2;
690
- if (childrenLength === 1)
691
- i.children = children;
692
- else if (1 < childrenLength) {
693
- for (var childArray = Array(childrenLength), _i = 0;_i < childrenLength; _i++)
694
- childArray[_i] = arguments[_i + 2];
695
- Object.freeze && Object.freeze(childArray);
696
- i.children = childArray;
697
- }
698
- if (type && type.defaultProps)
699
- for (propName in childrenLength = type.defaultProps, childrenLength)
700
- i[propName] === undefined && (i[propName] = childrenLength[propName]);
701
- key && defineKeyPropWarningGetter(i, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
702
- var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
703
- return ReactElement(type, key, i, getOwner(), propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack, propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
704
- };
705
- exports.createRef = function() {
706
- var refObject = { current: null };
707
- Object.seal(refObject);
708
- return refObject;
709
- };
710
- exports.forwardRef = function(render) {
711
- render != null && render.$$typeof === REACT_MEMO_TYPE ? console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).") : typeof render !== "function" ? console.error("forwardRef requires a render function but was given %s.", render === null ? "null" : typeof render) : render.length !== 0 && render.length !== 2 && console.error("forwardRef render functions accept exactly two parameters: props and ref. %s", render.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
712
- render != null && render.defaultProps != null && console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");
713
- var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
714
- Object.defineProperty(elementType, "displayName", {
715
- enumerable: false,
716
- configurable: true,
717
- get: function() {
718
- return ownName;
719
- },
720
- set: function(name) {
721
- ownName = name;
722
- render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
723
- }
724
- });
725
- return elementType;
726
- };
727
- exports.isValidElement = isValidElement;
728
- exports.lazy = function(ctor) {
729
- ctor = { _status: -1, _result: ctor };
730
- var lazyType = {
731
- $$typeof: REACT_LAZY_TYPE,
732
- _payload: ctor,
733
- _init: lazyInitializer
734
- }, ioInfo = {
735
- name: "lazy",
736
- start: -1,
737
- end: -1,
738
- value: null,
739
- owner: null,
740
- debugStack: Error("react-stack-top-frame"),
741
- debugTask: console.createTask ? console.createTask("lazy()") : null
742
- };
743
- ctor._ioInfo = ioInfo;
744
- lazyType._debugInfo = [{ awaited: ioInfo }];
745
- return lazyType;
746
- };
747
- exports.memo = function(type, compare) {
748
- type == null && console.error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
749
- compare = {
750
- $$typeof: REACT_MEMO_TYPE,
751
- type,
752
- compare: compare === undefined ? null : compare
753
- };
754
- var ownName;
755
- Object.defineProperty(compare, "displayName", {
756
- enumerable: false,
757
- configurable: true,
758
- get: function() {
759
- return ownName;
760
- },
761
- set: function(name) {
762
- ownName = name;
763
- type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
764
- }
765
- });
766
- return compare;
767
- };
768
- exports.startTransition = function(scope) {
769
- var prevTransition = ReactSharedInternals.T, currentTransition = {};
770
- currentTransition._updatedFibers = new Set;
771
- ReactSharedInternals.T = currentTransition;
772
- try {
773
- var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
774
- onStartTransitionFinish !== null && onStartTransitionFinish(currentTransition, returnValue);
775
- typeof returnValue === "object" && returnValue !== null && typeof returnValue.then === "function" && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
776
- } catch (error) {
777
- reportGlobalError(error);
778
- } finally {
779
- prevTransition === null && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")), prevTransition !== null && currentTransition.types !== null && (prevTransition.types !== null && prevTransition.types !== currentTransition.types && console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
780
- }
781
- };
782
- exports.unstable_useCacheRefresh = function() {
783
- return resolveDispatcher().useCacheRefresh();
784
- };
785
- exports.use = function(usable) {
786
- return resolveDispatcher().use(usable);
787
- };
788
- exports.useActionState = function(action, initialState, permalink) {
789
- return resolveDispatcher().useActionState(action, initialState, permalink);
790
- };
791
- exports.useCallback = function(callback, deps) {
792
- return resolveDispatcher().useCallback(callback, deps);
793
- };
794
- exports.useContext = function(Context) {
795
- var dispatcher = resolveDispatcher();
796
- Context.$$typeof === REACT_CONSUMER_TYPE && console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?");
797
- return dispatcher.useContext(Context);
798
- };
799
- exports.useDebugValue = function(value, formatterFn) {
800
- return resolveDispatcher().useDebugValue(value, formatterFn);
801
- };
802
- exports.useDeferredValue = function(value, initialValue) {
803
- return resolveDispatcher().useDeferredValue(value, initialValue);
804
- };
805
- exports.useEffect = function(create, deps) {
806
- create == null && console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?");
807
- return resolveDispatcher().useEffect(create, deps);
808
- };
809
- exports.useEffectEvent = function(callback) {
810
- return resolveDispatcher().useEffectEvent(callback);
811
- };
812
- exports.useId = function() {
813
- return resolveDispatcher().useId();
814
- };
815
- exports.useImperativeHandle = function(ref, create, deps) {
816
- return resolveDispatcher().useImperativeHandle(ref, create, deps);
817
- };
818
- exports.useInsertionEffect = function(create, deps) {
819
- create == null && console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?");
820
- return resolveDispatcher().useInsertionEffect(create, deps);
821
- };
822
- exports.useLayoutEffect = function(create, deps) {
823
- create == null && console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?");
824
- return resolveDispatcher().useLayoutEffect(create, deps);
825
- };
826
- exports.useMemo = function(create, deps) {
827
- return resolveDispatcher().useMemo(create, deps);
828
- };
829
- exports.useOptimistic = function(passthrough, reducer) {
830
- return resolveDispatcher().useOptimistic(passthrough, reducer);
831
- };
832
- exports.useReducer = function(reducer, initialArg, init) {
833
- return resolveDispatcher().useReducer(reducer, initialArg, init);
834
- };
835
- exports.useRef = function(initialValue) {
836
- return resolveDispatcher().useRef(initialValue);
837
- };
838
- exports.useState = function(initialState) {
839
- return resolveDispatcher().useState(initialState);
840
- };
841
- exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
842
- return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
843
- };
844
- exports.useTransition = function() {
845
- return resolveDispatcher().useTransition();
846
- };
847
- exports.version = "19.2.0";
848
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
849
- })();
850
- });
851
-
852
- // node_modules/react/index.js
853
- var require_react = __commonJS((exports, module) => {
854
- var react_development = __toESM(require_react_development());
855
- if (false) {} else {
856
- module.exports = react_development;
857
- }
858
- });
859
-
860
13
  // src/react/hooks.ts
861
- var React = __toESM(require_react(), 1);
14
+ import { useState, useEffect } from "react";
862
15
  function getSafeFallback() {
863
16
  return {
864
17
  tokens: {},
865
- headers: {},
866
- isLoading: false,
867
- fetch: globalThis.fetch?.bind(globalThis) || (async () => new Response),
868
- mergeHeaders: (existingHeaders) => new Headers(existingHeaders)
18
+ isLoading: false
869
19
  };
870
20
  }
871
21
  function isReactHooksAvailable() {
872
- if (!React || typeof React !== "object") {
873
- return false;
874
- }
875
- if (!React.useState || !React.useEffect || !React.useMemo || !React.useCallback) {
22
+ if (!useState || !useEffect) {
876
23
  return false;
877
24
  }
878
25
  if (typeof window === "undefined") {
@@ -894,9 +41,9 @@ function useIntegrateTokens(client) {
894
41
  isLoading: true
895
42
  };
896
43
  }
897
- const [tokens, setTokens] = React.useState({});
898
- const [isLoading, setIsLoading] = React.useState(true);
899
- React.useEffect(() => {
44
+ const [tokens, setTokens] = useState({});
45
+ const [isLoading, setIsLoading] = useState(true);
46
+ useEffect(() => {
900
47
  try {
901
48
  const updateTokens = () => {
902
49
  try {
@@ -932,39 +79,83 @@ function useIntegrateTokens(client) {
932
79
  return;
933
80
  }
934
81
  }, [client]);
935
- const headers = React.useMemo(() => {
936
- if (Object.keys(tokens).length === 0) {
937
- return {};
938
- }
939
- return {
940
- "x-integrate-tokens": JSON.stringify(tokens)
941
- };
942
- }, [tokens]);
943
- const fetchWithHeaders = React.useCallback(async (input, init) => {
944
- const mergedHeaders = new Headers(init?.headers);
945
- if (headers["x-integrate-tokens"]) {
946
- mergedHeaders.set("x-integrate-tokens", headers["x-integrate-tokens"]);
947
- }
948
- return fetch(input, {
949
- ...init,
950
- headers: mergedHeaders
951
- });
952
- }, [headers]);
953
- const mergeHeaders = React.useCallback((existingHeaders) => {
954
- const merged = new Headers(existingHeaders);
955
- if (headers["x-integrate-tokens"]) {
956
- merged.set("x-integrate-tokens", headers["x-integrate-tokens"]);
957
- }
958
- return merged;
959
- }, [headers]);
960
82
  return {
961
83
  tokens,
962
- headers,
963
- isLoading,
964
- fetch: fetchWithHeaders,
965
- mergeHeaders
84
+ isLoading
966
85
  };
967
86
  }
87
+ function useIntegrateAI(client, options = {}) {
88
+ const { apiPattern = /\/api\/chat/, debug = false } = options;
89
+ useEffect(() => {
90
+ if (!client || typeof window === "undefined") {
91
+ if (debug && !client) {
92
+ console.warn("[useIntegrateAI] No client provided, skipping interceptor setup");
93
+ }
94
+ return;
95
+ }
96
+ const originalFetch = window.fetch;
97
+ let currentTokens = {};
98
+ try {
99
+ currentTokens = client.getAllProviderTokens();
100
+ if (debug) {
101
+ console.log("[useIntegrateAI] Initial tokens loaded:", Object.keys(currentTokens));
102
+ }
103
+ } catch (error) {
104
+ console.error("[useIntegrateAI] Failed to get initial tokens:", error);
105
+ }
106
+ const updateTokens = () => {
107
+ try {
108
+ currentTokens = client.getAllProviderTokens();
109
+ if (debug) {
110
+ console.log("[useIntegrateAI] Tokens updated:", Object.keys(currentTokens));
111
+ }
112
+ } catch (error) {
113
+ console.error("[useIntegrateAI] Failed to update tokens:", error);
114
+ }
115
+ };
116
+ const handleLogout = () => {
117
+ currentTokens = {};
118
+ if (debug) {
119
+ console.log("[useIntegrateAI] Tokens cleared (logout)");
120
+ }
121
+ };
122
+ client.on("auth:complete", updateTokens);
123
+ client.on("auth:disconnect", updateTokens);
124
+ client.on("auth:logout", handleLogout);
125
+ const interceptedFetch = async (input, init) => {
126
+ const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
127
+ const shouldIntercept = typeof apiPattern === "string" ? url.includes(apiPattern) : apiPattern.test(url);
128
+ if (shouldIntercept && Object.keys(currentTokens).length > 0) {
129
+ if (debug) {
130
+ console.log("[useIntegrateAI] Intercepting request to:", url);
131
+ console.log("[useIntegrateAI] Injecting tokens:", Object.keys(currentTokens));
132
+ }
133
+ const headers = new Headers(init?.headers);
134
+ headers.set("x-integrate-tokens", JSON.stringify(currentTokens));
135
+ return originalFetch(input, {
136
+ ...init,
137
+ headers
138
+ });
139
+ }
140
+ return originalFetch(input, init);
141
+ };
142
+ window.fetch = interceptedFetch;
143
+ if (debug) {
144
+ console.log("[useIntegrateAI] Global fetch interceptor installed");
145
+ console.log("[useIntegrateAI] Pattern:", apiPattern);
146
+ }
147
+ return () => {
148
+ window.fetch = originalFetch;
149
+ client.off("auth:complete", updateTokens);
150
+ client.off("auth:disconnect", updateTokens);
151
+ client.off("auth:logout", handleLogout);
152
+ if (debug) {
153
+ console.log("[useIntegrateAI] Global fetch interceptor removed");
154
+ }
155
+ };
156
+ }, [client, apiPattern, debug]);
157
+ }
968
158
  export {
969
- useIntegrateTokens
159
+ useIntegrateTokens,
160
+ useIntegrateAI
970
161
  };
package/dist/server.js CHANGED
@@ -1,20 +1,4 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
1
  var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
2
  var __export = (target, all) => {
19
3
  for (var name in all)
20
4
  __defProp(target, name, {
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * React hooks for integrate-sdk
3
3
  *
4
- * Provides React hooks for managing provider tokens and headers
5
- * in client-side applications.
4
+ * Provides React hooks for managing provider tokens in client-side applications.
6
5
  */
7
6
  import type { MCPClient } from "../client.js";
8
7
  /**
@@ -13,82 +12,117 @@ export interface UseIntegrateTokensResult {
13
12
  * Current provider tokens (e.g., { github: 'token123', gmail: 'token456' })
14
13
  */
15
14
  tokens: Record<string, string>;
16
- /**
17
- * Headers object ready to spread into fetch/useChat options
18
- * Includes 'x-integrate-tokens' header with JSON-stringified tokens
19
- */
20
- headers: Record<string, string>;
21
15
  /**
22
16
  * Whether tokens are currently being loaded
23
17
  */
24
18
  isLoading: boolean;
25
- /**
26
- * Custom fetch function with integrate tokens automatically included
27
- * Use this with libraries that accept a custom fetch function (like Vercel AI SDK's useChat)
28
- */
29
- fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
30
- /**
31
- * Helper function to merge integrate headers with existing headers
32
- * Useful for manual fetch calls where you need to combine headers
33
- */
34
- mergeHeaders: (existingHeaders?: HeadersInit) => Headers;
35
19
  }
36
20
  /**
37
- * React hook to access integrate-sdk provider tokens and headers
21
+ * React hook to access integrate-sdk provider token status
38
22
  *
39
23
  * Automatically listens for authentication events and updates when tokens change.
40
- * Returns tokens and formatted headers ready to pass to API requests.
24
+ * Use this hook to display connection status in your UI.
25
+ *
26
+ * **For automatic token injection**, use `useIntegrateAI()` instead.
41
27
  *
42
28
  * **Note:** This hook must be called inside a React component. It will return safe
43
29
  * fallback values during SSR or if the client is not ready.
44
30
  *
45
31
  * @param client - MCP client instance created with createMCPClient() (optional)
46
- * @returns Object with tokens, headers, loading state, fetch function, and mergeHeaders helper
32
+ * @returns Object with tokens and loading state
47
33
  *
48
34
  * @example
49
35
  * ```tsx
50
36
  * import { createMCPClient, githubPlugin } from 'integrate-sdk';
51
37
  * import { useIntegrateTokens } from 'integrate-sdk/react';
52
- * import { useChat } from 'ai/react';
53
38
  *
54
39
  * const client = createMCPClient({
55
40
  * plugins: [githubPlugin({ clientId: '...' })],
56
41
  * });
57
42
  *
58
- * function ChatComponent() {
59
- * const { fetch: fetchWithTokens, isLoading } = useIntegrateTokens(client);
43
+ * function ConnectionStatus() {
44
+ * const { tokens, isLoading } = useIntegrateTokens(client);
60
45
  *
61
- * const chat = useChat({
62
- * api: '/api/chat',
63
- * fetch: fetchWithTokens, // Tokens automatically included
64
- * });
46
+ * if (isLoading) return <div>Loading...</div>;
65
47
  *
66
- * return <div>Chat UI here</div>;
48
+ * return (
49
+ * <div>
50
+ * {Object.keys(tokens).length > 0 ? (
51
+ * <span>Connected: {Object.keys(tokens).join(', ')}</span>
52
+ * ) : (
53
+ * <span>Not connected</span>
54
+ * )}
55
+ * </div>
56
+ * );
67
57
  * }
68
58
  * ```
59
+ */
60
+ export declare function useIntegrateTokens(client?: MCPClient<any> | null): UseIntegrateTokensResult;
61
+ /**
62
+ * Options for useIntegrateAI hook
63
+ */
64
+ export interface UseIntegrateAIOptions {
65
+ /**
66
+ * URL pattern to intercept for token injection
67
+ * Default: /\/api\/chat/
68
+ * Can be a string (uses .includes()) or RegExp
69
+ */
70
+ apiPattern?: string | RegExp;
71
+ /**
72
+ * Enable debug logging
73
+ * Default: false
74
+ */
75
+ debug?: boolean;
76
+ }
77
+ /**
78
+ * Global fetch interceptor for Vercel AI SDK
79
+ *
80
+ * Automatically injects integrate provider tokens into all AI SDK requests.
81
+ * Call this once at your app root (layout/provider) to enable automatic token
82
+ * injection for all `useChat` calls in your application.
83
+ *
84
+ * **Note:** This installs a global `window.fetch` interceptor that only affects
85
+ * requests matching the `apiPattern`. All other requests pass through unchanged.
86
+ *
87
+ * @param client - MCP client instance created with createMCPClient() (optional)
88
+ * @param options - Configuration options for the interceptor
69
89
  *
70
90
  * @example
71
91
  * ```tsx
72
- * // With mergeHeaders helper
73
- * import { createMCPClient } from 'integrate-sdk';
92
+ * // app/layout.tsx or app/providers.tsx
93
+ * 'use client';
94
+ *
95
+ * import { createMCPClient, githubPlugin } from 'integrate-sdk';
96
+ * import { useIntegrateAI } from 'integrate-sdk/react';
74
97
  *
75
- * const client = createMCPClient({ plugins: [...] });
98
+ * const client = createMCPClient({
99
+ * plugins: [
100
+ * githubPlugin({ clientId: process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID }),
101
+ * ],
102
+ * });
76
103
  *
77
- * function MyComponent() {
78
- * const { mergeHeaders } = useIntegrateTokens(client);
104
+ * export function Providers({ children }) {
105
+ * // Install global interceptor once
106
+ * useIntegrateAI(client);
79
107
  *
80
- * const fetchData = async () => {
81
- * const response = await fetch('/api/data', {
82
- * method: 'POST',
83
- * headers: mergeHeaders({ 'Content-Type': 'application/json' }),
84
- * body: JSON.stringify({ query: 'example' }),
85
- * });
86
- * return response.json();
87
- * };
108
+ * return <>{children}</>;
109
+ * }
88
110
  *
89
- * return <button onClick={fetchData}>Fetch</button>;
111
+ * // Now any component can use useChat without manual token management
112
+ * function ChatPage() {
113
+ * const chat = useChat(); // ✅ Tokens automatically included!
114
+ * return <div>...</div>;
90
115
  * }
91
116
  * ```
117
+ *
118
+ * @example
119
+ * ```tsx
120
+ * // With custom API pattern and debug logging
121
+ * useIntegrateAI(client, {
122
+ * apiPattern: /\/(api|chat)\//, // Match /api/ or /chat/
123
+ * debug: true, // Log intercepted requests
124
+ * });
125
+ * ```
92
126
  */
93
- export declare function useIntegrateTokens(client?: MCPClient<any> | null): UseIntegrateTokensResult;
127
+ export declare function useIntegrateAI(client?: MCPClient<any> | null, options?: UseIntegrateAIOptions): void;
94
128
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3E;;;OAGG;IACH,YAAY,EAAE,CAAC,eAAe,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC;CAC1D;AA4CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAC7B,wBAAwB,CA0H1B"}
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/B;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAoCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAC7B,wBAAwB,CA4E1B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE7B;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,cAAc,CAC5B,MAAM,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,EAC9B,OAAO,GAAE,qBAA0B,GAClC,IAAI,CA6GN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integrate-sdk",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Type-safe TypeScript SDK for MCP Client with plugin-based OAuth provider configuration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -41,7 +41,7 @@
41
41
  ],
42
42
  "scripts": {
43
43
  "prep": "bun run type-check && bun run build",
44
- "build": "bun build index.ts server.ts oauth.ts react.ts --outdir dist --target node --format esm && bun run build:types",
44
+ "build": "bun build index.ts server.ts oauth.ts react.ts --outdir dist --target node --format esm --external react && bun run build:types",
45
45
  "build:types": "tsc --emitDeclarationOnly --declaration --declarationMap",
46
46
  "dev": "bun --watch src/index.ts",
47
47
  "type-check": "tsc --noEmit",
package/react.ts CHANGED
@@ -4,6 +4,6 @@
4
4
  * @packageDocumentation
5
5
  */
6
6
 
7
- export { useIntegrateTokens } from "./src/react/hooks.js";
8
- export type { UseIntegrateTokensResult } from "./src/react/hooks.js";
7
+ export { useIntegrateTokens, useIntegrateAI } from "./src/react/hooks.js";
8
+ export type { UseIntegrateTokensResult, UseIntegrateAIOptions } from "./src/react/hooks.js";
9
9