dynim-react 1.0.71 → 1.0.73
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 -0
- package/dist/DynimProvider.d.ts.map +1 -1
- package/dist/DynimProvider.js +20 -44
- package/package.json +2 -2
package/dist/DynimProvider.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EASZ,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EAKV,WAAW,EACX,UAAU,EACV,aAAa,EAGd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"DynimProvider.d.ts","sourceRoot":"","sources":["../src/DynimProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAc,EASZ,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAWf,OAAO,KAAK,EAKV,WAAW,EACX,UAAU,EACV,aAAa,EAGd,MAAM,YAAY,CAAC;AA+EpB,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC;QACzB,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B,CAAC,CAAC;IACH,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,6CAA6C;IAC7C,cAAc,EAAE,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5C,mEAAmE;IACnE,iBAAiB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpE,kDAAkD;IAClD,WAAW,EAAE,OAAO,CAAC;IACrB,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,CAielC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,iBAAiB,CAM5C"}
|
package/dist/DynimProvider.js
CHANGED
|
@@ -49,19 +49,6 @@ class BundleErrorBoundary extends Component {
|
|
|
49
49
|
return this.props.children;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
/** Decode JWT payload to extract claims (no verification - just for reading IDs) */
|
|
53
|
-
function decodeJwtPayload(token) {
|
|
54
|
-
try {
|
|
55
|
-
const parts = token.split('.');
|
|
56
|
-
if (parts.length !== 3)
|
|
57
|
-
return null;
|
|
58
|
-
const payload = JSON.parse(atob(parts[1]));
|
|
59
|
-
return payload;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
52
|
const DynimContext = createContext(null);
|
|
66
53
|
/**
|
|
67
54
|
* DynimProvider - Wrap your app with this to enable Dynim functionality
|
|
@@ -152,6 +139,11 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
152
139
|
try {
|
|
153
140
|
const session = await getSession();
|
|
154
141
|
cachedTokenRef.current = session.token;
|
|
142
|
+
// Pass CSS version to code-client (bundleLoader uses this getAuthToken,
|
|
143
|
+
// not code-client's internal getValidToken, so we need to sync it here)
|
|
144
|
+
if (session.cssVersion !== undefined && codeClientRef.current) {
|
|
145
|
+
codeClientRef.current.setCSSVersion(session.cssVersion ?? null);
|
|
146
|
+
}
|
|
155
147
|
return session.token;
|
|
156
148
|
}
|
|
157
149
|
catch {
|
|
@@ -249,16 +241,9 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
249
241
|
}
|
|
250
242
|
return cssLoaderRef.current;
|
|
251
243
|
}, []);
|
|
252
|
-
// Build CSS URL
|
|
244
|
+
// Build CSS URL - delegates to code-client which tracks cssVersion internally
|
|
253
245
|
const buildCSSUrl = useCallback((temp = false) => {
|
|
254
|
-
|
|
255
|
-
if (!token)
|
|
256
|
-
return null;
|
|
257
|
-
const claims = decodeJwtPayload(token);
|
|
258
|
-
if (!claims?.sub || !claims?.project)
|
|
259
|
-
return null;
|
|
260
|
-
const params = `project_id=${claims.project}&customer_id=${claims.sub}`;
|
|
261
|
-
return temp ? `/api/code/css?${params}&temp=true` : `/api/code/css?${params}`;
|
|
246
|
+
return codeClientRef.current?.getCSSUrl(temp) ?? null;
|
|
262
247
|
}, []);
|
|
263
248
|
// Load bundle (JS + CSS)
|
|
264
249
|
const loadBundle = useCallback(async (bundleUrl, loadCSS = true) => {
|
|
@@ -277,15 +262,12 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
277
262
|
const isTemp = bundleUrl.includes('temp=true');
|
|
278
263
|
const cssUrl = buildCSSUrl(isTemp);
|
|
279
264
|
if (cssUrl) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
// Saved CSS - let browser cache
|
|
287
|
-
cssLoader.load(cssUrl);
|
|
288
|
-
}
|
|
265
|
+
// Load CSS (temp has cache busting in URL, saved has version param)
|
|
266
|
+
getCSSLoader().load(cssUrl);
|
|
267
|
+
}
|
|
268
|
+
else if (!isTemp) {
|
|
269
|
+
// No saved CSS exists - unload any existing CSS
|
|
270
|
+
getCSSLoader().unload();
|
|
289
271
|
}
|
|
290
272
|
}
|
|
291
273
|
}
|
|
@@ -367,10 +349,9 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
367
349
|
}, 3000);
|
|
368
350
|
return () => clearTimeout(themeTimeout);
|
|
369
351
|
}, [fetchTheme]);
|
|
370
|
-
// Load saved bundle
|
|
352
|
+
// Load saved bundle (JS + CSS with versioned URL)
|
|
371
353
|
const loadSavedBundle = useCallback(async () => {
|
|
372
|
-
|
|
373
|
-
await loadBundle('/api/code/bundle', false);
|
|
354
|
+
await loadBundle('/api/code/bundle', true);
|
|
374
355
|
}, [loadBundle]);
|
|
375
356
|
// Watch for bundleReady - use bundleSequence to detect new bundles
|
|
376
357
|
// (bundleReady alone stays true, so subsequent events wouldn't trigger re-render)
|
|
@@ -413,21 +394,16 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
413
394
|
await codeClientRef.current?.sendCode(query);
|
|
414
395
|
}, []);
|
|
415
396
|
const saveCode = useCallback(async () => {
|
|
397
|
+
// saveCode updates cssVersion internally in code-client
|
|
416
398
|
await codeClientRef.current?.saveCode();
|
|
399
|
+
// Load saved bundle - CSS will use new version from code-client
|
|
417
400
|
await loadSavedBundle();
|
|
418
|
-
|
|
419
|
-
const cssUrl = buildCSSUrl(false);
|
|
420
|
-
if (cssUrl)
|
|
421
|
-
await getCSSLoader().invalidateAndReload(cssUrl);
|
|
422
|
-
}, [loadSavedBundle, getCSSLoader, buildCSSUrl]);
|
|
401
|
+
}, [loadSavedBundle]);
|
|
423
402
|
const abandonCode = useCallback(async () => {
|
|
424
403
|
await codeClientRef.current?.abandonCode();
|
|
404
|
+
// Load saved bundle - cssVersion state unchanged, will use existing version
|
|
425
405
|
await loadSavedBundle();
|
|
426
|
-
|
|
427
|
-
const cssUrl = buildCSSUrl(false);
|
|
428
|
-
if (cssUrl)
|
|
429
|
-
await getCSSLoader().invalidateAndReload(cssUrl);
|
|
430
|
-
}, [loadSavedBundle, getCSSLoader, buildCSSUrl]);
|
|
406
|
+
}, [loadSavedBundle]);
|
|
431
407
|
const getCheckpoints = useCallback(async () => {
|
|
432
408
|
return codeClientRef.current?.getCheckpoints() ?? [];
|
|
433
409
|
}, []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dynim-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dev": "tsc --watch"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"dynim-core": "^1.0.
|
|
30
|
+
"dynim-core": "^1.0.47"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=17.0.0",
|