dynim-react 1.0.72 → 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.map +1 -1
- package/dist/DynimProvider.js +14 -60
- package/package.json +2 -2
|
@@ -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
|
|
@@ -103,8 +90,6 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
103
90
|
// Cached auth token
|
|
104
91
|
const cachedTokenRef = useRef(null);
|
|
105
92
|
const tokenPromiseRef = useRef(null);
|
|
106
|
-
// CSS version for cache invalidation (null = no CSS exists)
|
|
107
|
-
const [cssVersion, setCSSVersion] = useState(null);
|
|
108
93
|
// Bundle load signal
|
|
109
94
|
const [bundleLoadSignal, setBundleLoadSignal] = useState(0);
|
|
110
95
|
const pendingBundleProjectIdRef = useRef(null);
|
|
@@ -154,9 +139,10 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
154
139
|
try {
|
|
155
140
|
const session = await getSession();
|
|
156
141
|
cachedTokenRef.current = session.token;
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
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);
|
|
160
146
|
}
|
|
161
147
|
return session.token;
|
|
162
148
|
}
|
|
@@ -255,29 +241,10 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
255
241
|
}
|
|
256
242
|
return cssLoaderRef.current;
|
|
257
243
|
}, []);
|
|
258
|
-
// Build CSS URL
|
|
259
|
-
// Returns null if no CSS exists (cssVersion is null)
|
|
244
|
+
// Build CSS URL - delegates to code-client which tracks cssVersion internally
|
|
260
245
|
const buildCSSUrl = useCallback((temp = false) => {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return null;
|
|
264
|
-
const claims = decodeJwtPayload(token);
|
|
265
|
-
if (!claims?.sub || !claims?.project)
|
|
266
|
-
return null;
|
|
267
|
-
const base = `/api/code/css?project_id=${claims.project}&customer_id=${claims.sub}`;
|
|
268
|
-
if (temp) {
|
|
269
|
-
// Temp/preview CSS - use cache busting
|
|
270
|
-
return `${base}&temp=true&_t=${Date.now()}`;
|
|
271
|
-
}
|
|
272
|
-
else if (cssVersion) {
|
|
273
|
-
// Versioned URL for saved CSS - enables immutable caching
|
|
274
|
-
return `${base}&v=${cssVersion}`;
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
// No CSS exists for this customer
|
|
278
|
-
return null;
|
|
279
|
-
}
|
|
280
|
-
}, [cssVersion]);
|
|
246
|
+
return codeClientRef.current?.getCSSUrl(temp) ?? null;
|
|
247
|
+
}, []);
|
|
281
248
|
// Load bundle (JS + CSS)
|
|
282
249
|
const loadBundle = useCallback(async (bundleUrl, loadCSS = true) => {
|
|
283
250
|
const loader = getBundleLoader();
|
|
@@ -295,15 +262,8 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
295
262
|
const isTemp = bundleUrl.includes('temp=true');
|
|
296
263
|
const cssUrl = buildCSSUrl(isTemp);
|
|
297
264
|
if (cssUrl) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
// Temp/preview CSS - cache busting already in URL
|
|
301
|
-
cssLoader.load(cssUrl);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
// Saved CSS with version - browser can cache immutably
|
|
305
|
-
cssLoader.load(cssUrl);
|
|
306
|
-
}
|
|
265
|
+
// Load CSS (temp has cache busting in URL, saved has version param)
|
|
266
|
+
getCSSLoader().load(cssUrl);
|
|
307
267
|
}
|
|
308
268
|
else if (!isTemp) {
|
|
309
269
|
// No saved CSS exists - unload any existing CSS
|
|
@@ -389,10 +349,9 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
389
349
|
}, 3000);
|
|
390
350
|
return () => clearTimeout(themeTimeout);
|
|
391
351
|
}, [fetchTheme]);
|
|
392
|
-
// Load saved bundle
|
|
352
|
+
// Load saved bundle (JS + CSS with versioned URL)
|
|
393
353
|
const loadSavedBundle = useCallback(async () => {
|
|
394
|
-
|
|
395
|
-
await loadBundle('/api/code/bundle', false);
|
|
354
|
+
await loadBundle('/api/code/bundle', true);
|
|
396
355
|
}, [loadBundle]);
|
|
397
356
|
// Watch for bundleReady - use bundleSequence to detect new bundles
|
|
398
357
|
// (bundleReady alone stays true, so subsequent events wouldn't trigger re-render)
|
|
@@ -435,14 +394,9 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
435
394
|
await codeClientRef.current?.sendCode(query);
|
|
436
395
|
}, []);
|
|
437
396
|
const saveCode = useCallback(async () => {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (result && result.css_version) {
|
|
442
|
-
setCSSVersion(result.css_version);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
// Load saved bundle - CSS will use new version in URL
|
|
397
|
+
// saveCode updates cssVersion internally in code-client
|
|
398
|
+
await codeClientRef.current?.saveCode();
|
|
399
|
+
// Load saved bundle - CSS will use new version from code-client
|
|
446
400
|
await loadSavedBundle();
|
|
447
401
|
}, [loadSavedBundle]);
|
|
448
402
|
const abandonCode = useCallback(async () => {
|
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",
|