dynim-react 1.0.72 → 1.0.74
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 +17 -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,CAoelC;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,13 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
154
139
|
try {
|
|
155
140
|
const session = await getSession();
|
|
156
141
|
cachedTokenRef.current = session.token;
|
|
157
|
-
//
|
|
158
|
-
|
|
159
|
-
|
|
142
|
+
// Sync token and CSS version to code-client (bundleLoader uses this getAuthToken,
|
|
143
|
+
// not code-client's internal getValidToken, so we need to sync both here)
|
|
144
|
+
if (codeClientRef.current) {
|
|
145
|
+
codeClientRef.current.setSessionToken(session.token, session.refreshToken);
|
|
146
|
+
if (session.cssVersion !== undefined) {
|
|
147
|
+
codeClientRef.current.setCSSVersion(session.cssVersion ?? null);
|
|
148
|
+
}
|
|
160
149
|
}
|
|
161
150
|
return session.token;
|
|
162
151
|
}
|
|
@@ -255,29 +244,10 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
255
244
|
}
|
|
256
245
|
return cssLoaderRef.current;
|
|
257
246
|
}, []);
|
|
258
|
-
// Build CSS URL
|
|
259
|
-
// Returns null if no CSS exists (cssVersion is null)
|
|
247
|
+
// Build CSS URL - delegates to code-client which tracks cssVersion internally
|
|
260
248
|
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]);
|
|
249
|
+
return codeClientRef.current?.getCSSUrl(temp) ?? null;
|
|
250
|
+
}, []);
|
|
281
251
|
// Load bundle (JS + CSS)
|
|
282
252
|
const loadBundle = useCallback(async (bundleUrl, loadCSS = true) => {
|
|
283
253
|
const loader = getBundleLoader();
|
|
@@ -295,15 +265,8 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
295
265
|
const isTemp = bundleUrl.includes('temp=true');
|
|
296
266
|
const cssUrl = buildCSSUrl(isTemp);
|
|
297
267
|
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
|
-
}
|
|
268
|
+
// Load CSS (temp has cache busting in URL, saved has version param)
|
|
269
|
+
getCSSLoader().load(cssUrl);
|
|
307
270
|
}
|
|
308
271
|
else if (!isTemp) {
|
|
309
272
|
// No saved CSS exists - unload any existing CSS
|
|
@@ -389,10 +352,9 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
389
352
|
}, 3000);
|
|
390
353
|
return () => clearTimeout(themeTimeout);
|
|
391
354
|
}, [fetchTheme]);
|
|
392
|
-
// Load saved bundle
|
|
355
|
+
// Load saved bundle (JS + CSS with versioned URL)
|
|
393
356
|
const loadSavedBundle = useCallback(async () => {
|
|
394
|
-
|
|
395
|
-
await loadBundle('/api/code/bundle', false);
|
|
357
|
+
await loadBundle('/api/code/bundle', true);
|
|
396
358
|
}, [loadBundle]);
|
|
397
359
|
// Watch for bundleReady - use bundleSequence to detect new bundles
|
|
398
360
|
// (bundleReady alone stays true, so subsequent events wouldn't trigger re-render)
|
|
@@ -435,14 +397,9 @@ export function DynimProvider({ children, config = {}, }) {
|
|
|
435
397
|
await codeClientRef.current?.sendCode(query);
|
|
436
398
|
}, []);
|
|
437
399
|
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
|
|
400
|
+
// saveCode updates cssVersion internally in code-client
|
|
401
|
+
await codeClientRef.current?.saveCode();
|
|
402
|
+
// Load saved bundle - CSS will use new version from code-client
|
|
446
403
|
await loadSavedBundle();
|
|
447
404
|
}, [loadSavedBundle]);
|
|
448
405
|
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.74",
|
|
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.48"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": ">=17.0.0",
|