dynim-react 1.0.41 → 1.0.42
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.map +1 -1
- package/dist/DynimProvider.js +33 -6
- package/package.json +1 -1
|
@@ -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;
|
|
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,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrE,kCAAkC;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,KAAK,IAAI,CAAC;IACzC,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,qBAAqB;IACrB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,yBAAyB;IACzB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,oCAAoC;IACpC,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,yDAAyD;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB,2CAA2C;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,gCAAgC;IAChC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,MAAW,GACZ,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAgalC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAM5C"}
|
package/dist/DynimProvider.js
CHANGED
|
@@ -9,7 +9,7 @@ import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-run
|
|
|
9
9
|
*/
|
|
10
10
|
import React, { createContext, useContext, useEffect, useRef, useCallback, useMemo, useState, } from 'react';
|
|
11
11
|
import ReactDOM from 'react-dom';
|
|
12
|
-
import { createBuilderClient, createBuilder, createCodeClient, createBundleLoader, BundleNotFoundError, } from 'dynim-core';
|
|
12
|
+
import { createBuilderClient, createBuilder, createCodeClient, createBundleLoader, BundleNotFoundError, BundleAuthError, } from 'dynim-core';
|
|
13
13
|
import { createSharedContext, updateSharedContext, isSharedContextReady } from './inference/sharedContext';
|
|
14
14
|
import { generateThemeCSS } from './theme';
|
|
15
15
|
const DynimContext = createContext(null);
|
|
@@ -204,6 +204,34 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
204
204
|
setIsBundleLoaded(false);
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
+
// 401 = token expired - refresh via getSession and retry
|
|
208
|
+
if (error instanceof BundleAuthError) {
|
|
209
|
+
cachedTokenRef.current = null; // Clear stale token
|
|
210
|
+
const { getSession } = configRef.current;
|
|
211
|
+
if (getSession) {
|
|
212
|
+
try {
|
|
213
|
+
const session = await getSession();
|
|
214
|
+
cachedTokenRef.current = session.token;
|
|
215
|
+
// Retry with fresh token
|
|
216
|
+
const { App, cleanup } = await loader.load(bundleUrl);
|
|
217
|
+
setTenantApp(() => App);
|
|
218
|
+
setIsBundleLoaded(true);
|
|
219
|
+
cleanup();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
catch (retryError) {
|
|
223
|
+
if (retryError instanceof BundleNotFoundError) {
|
|
224
|
+
setTenantApp(null);
|
|
225
|
+
setIsBundleLoaded(false);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
// Retry also failed - show children
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
setTenantApp(null);
|
|
232
|
+
setIsBundleLoaded(false);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
207
235
|
setBundleError(error);
|
|
208
236
|
}
|
|
209
237
|
finally {
|
|
@@ -242,15 +270,14 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
242
270
|
console.warn('[DynimProvider] Failed to fetch theme:', error);
|
|
243
271
|
}
|
|
244
272
|
}, [getAuthToken]);
|
|
245
|
-
// Auto-load saved bundle on mount if
|
|
246
|
-
// This avoids HTTP calls (getSession) while still loading saved bundles
|
|
273
|
+
// Auto-load saved bundle on mount if auth is available
|
|
247
274
|
useEffect(() => {
|
|
248
275
|
if (hasAttemptedInitialLoadRef.current)
|
|
249
276
|
return;
|
|
250
277
|
hasAttemptedInitialLoadRef.current = true;
|
|
251
|
-
const { sessionToken } = configRef.current;
|
|
252
|
-
// No
|
|
253
|
-
if (!sessionToken) {
|
|
278
|
+
const { sessionToken, getSession } = configRef.current;
|
|
279
|
+
// No auth configured = skip bundle load
|
|
280
|
+
if (!sessionToken && !getSession) {
|
|
254
281
|
setIsInitialLoadComplete(true);
|
|
255
282
|
return;
|
|
256
283
|
}
|