dynim-react 1.0.43 → 1.0.45
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/DynimProvider.d.ts +1 -3
- package/dist/DynimProvider.d.ts.map +1 -1
- package/dist/DynimProvider.js +7 -41
- package/dist/inference/sharedContext.d.ts +0 -7
- package/dist/inference/sharedContext.d.ts.map +1 -1
- package/dist/inference/sharedContext.js +1 -10
- package/dist/inference/types.d.ts +0 -1
- package/dist/inference/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/DynimProvider.d.ts
CHANGED
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
import { type ReactNode } from 'react';
|
|
10
10
|
import type { CodeMessage } from 'dynim-core';
|
|
11
11
|
export interface DynimConfig {
|
|
12
|
-
/**
|
|
13
|
-
sessionToken?: string;
|
|
14
|
-
/** Function to fetch a new session when current one expires */
|
|
12
|
+
/** Function to fetch a session token for authentication */
|
|
15
13
|
getSession?: () => Promise<{
|
|
16
14
|
token: string;
|
|
17
15
|
refreshToken?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EAQZ,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAKV,WAAW,EAEZ,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,WAAW;IAC1B,
|
|
1
|
+
{"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EAQZ,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAKV,WAAW,EAEZ,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,OAAO,CAA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AQ,IAAI,iBAAiB,CAM5C"}
|
package/dist/DynimProvider.js
CHANGED
|
@@ -51,8 +51,6 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
51
51
|
// Cached auth token
|
|
52
52
|
const cachedTokenRef = useRef(null);
|
|
53
53
|
const tokenPromiseRef = useRef(null);
|
|
54
|
-
// Flag to skip stale sessionToken from config after 401
|
|
55
|
-
const sessionTokenInvalidRef = useRef(false);
|
|
56
54
|
// Bundle load signal
|
|
57
55
|
const [bundleLoadSignal, setBundleLoadSignal] = useState(0);
|
|
58
56
|
const pendingBundleProjectIdRef = useRef(null);
|
|
@@ -88,16 +86,12 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
88
|
}, []);
|
|
91
|
-
// Get auth token
|
|
89
|
+
// Get auth token (cached after first call)
|
|
92
90
|
const getAuthToken = useCallback(async () => {
|
|
93
|
-
const {
|
|
94
|
-
//
|
|
91
|
+
const { getSession } = configRef.current;
|
|
92
|
+
// Return cached token if available
|
|
95
93
|
if (cachedTokenRef.current)
|
|
96
94
|
return cachedTokenRef.current;
|
|
97
|
-
// Fast path: static token from config (skip if known invalid)
|
|
98
|
-
if (sessionToken && !sessionTokenInvalidRef.current) {
|
|
99
|
-
return sessionToken;
|
|
100
|
-
}
|
|
101
95
|
// Reuse in-flight promise if one exists
|
|
102
96
|
if (tokenPromiseRef.current)
|
|
103
97
|
return tokenPromiseRef.current;
|
|
@@ -201,36 +195,8 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
201
195
|
cleanup();
|
|
202
196
|
}
|
|
203
197
|
catch (error) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
setIsBundleLoaded(false);
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
// 401 = token expired - refresh via getSession and retry
|
|
210
|
-
if (error instanceof BundleAuthError) {
|
|
211
|
-
cachedTokenRef.current = null; // Clear stale token
|
|
212
|
-
sessionTokenInvalidRef.current = true; // Skip config sessionToken on retry
|
|
213
|
-
const { getSession } = configRef.current;
|
|
214
|
-
if (getSession) {
|
|
215
|
-
try {
|
|
216
|
-
const session = await getSession();
|
|
217
|
-
cachedTokenRef.current = session.token;
|
|
218
|
-
// Retry with fresh token
|
|
219
|
-
const { App, cleanup } = await loader.load(bundleUrl);
|
|
220
|
-
setTenantApp(() => App);
|
|
221
|
-
setIsBundleLoaded(true);
|
|
222
|
-
cleanup();
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
catch (retryError) {
|
|
226
|
-
if (retryError instanceof BundleNotFoundError) {
|
|
227
|
-
setTenantApp(null);
|
|
228
|
-
setIsBundleLoaded(false);
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
// Retry also failed - show children
|
|
232
|
-
}
|
|
233
|
-
}
|
|
198
|
+
// 404 = no bundle, 401 = not authenticated - show children
|
|
199
|
+
if (error instanceof BundleNotFoundError || error instanceof BundleAuthError) {
|
|
234
200
|
setTenantApp(null);
|
|
235
201
|
setIsBundleLoaded(false);
|
|
236
202
|
return;
|
|
@@ -278,9 +244,9 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
278
244
|
if (hasAttemptedInitialLoadRef.current)
|
|
279
245
|
return;
|
|
280
246
|
hasAttemptedInitialLoadRef.current = true;
|
|
281
|
-
const {
|
|
247
|
+
const { getSession } = configRef.current;
|
|
282
248
|
// No auth configured = skip bundle load
|
|
283
|
-
if (!
|
|
249
|
+
if (!getSession) {
|
|
284
250
|
setIsInitialLoadComplete(true);
|
|
285
251
|
return;
|
|
286
252
|
}
|
|
@@ -33,13 +33,6 @@ export declare function createSharedContext(config: DynimSDKConfig): DynimGlobal
|
|
|
33
33
|
* @param config - Partial configuration to merge into existing context
|
|
34
34
|
*/
|
|
35
35
|
export declare function updateSharedContext(config: Partial<DynimSDKConfig>): void;
|
|
36
|
-
/**
|
|
37
|
-
* Gets the current shared context instance from the window object.
|
|
38
|
-
* Useful for tenant bundles to access the SDK.
|
|
39
|
-
*
|
|
40
|
-
* @returns The shared context instance or undefined if not initialized
|
|
41
|
-
*/
|
|
42
|
-
export declare function getSharedContext(): DynimGlobal | undefined;
|
|
43
36
|
/**
|
|
44
37
|
* Checks if the shared context has been initialized.
|
|
45
38
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedContext.d.ts","sourceRoot":"","sources":["../../src/inference/sharedContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sharedContext.d.ts","sourceRoot":"","sources":["../../src/inference/sharedContext.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,CA8BvE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAYzE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createSharedRegistry,
|
|
1
|
+
import { createSharedRegistry, isSharedRegistryReady, } from 'dynim-core';
|
|
2
2
|
// Keep a reference to the current registry for updates
|
|
3
3
|
let currentRegistry = null;
|
|
4
4
|
/**
|
|
@@ -72,15 +72,6 @@ export function updateSharedContext(config) {
|
|
|
72
72
|
globals: config.globals,
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Gets the current shared context instance from the window object.
|
|
77
|
-
* Useful for tenant bundles to access the SDK.
|
|
78
|
-
*
|
|
79
|
-
* @returns The shared context instance or undefined if not initialized
|
|
80
|
-
*/
|
|
81
|
-
export function getSharedContext() {
|
|
82
|
-
return getSharedRegistry();
|
|
83
|
-
}
|
|
84
75
|
/**
|
|
85
76
|
* Checks if the shared context has been initialized.
|
|
86
77
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/inference/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,KAAK,EAAE,cAAc,OAAO,CAAC,CAAC;IAC9B,mDAAmD;IACnD,QAAQ,EAAE,cAAc,WAAW,CAAC,CAAC;IACrC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/inference/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,KAAK,EAAE,cAAc,OAAO,CAAC,CAAC;IAC9B,mDAAmD;IACnD,QAAQ,EAAE,cAAc,WAAW,CAAC,CAAC;IACrC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC"}
|