dynim-react 1.0.67 → 1.0.69

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.
@@ -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;AAWf,OAAO,KAAK,EAKV,WAAW,EACX,UAAU,EACV,aAAa,EAGd,MAAM,YAAY,CAAC;AAgBpB,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,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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@@ -1,4 +1,4 @@
1
- import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /**
3
3
  * DynimProvider - Single provider for all Dynim functionality
4
4
  *
@@ -7,11 +7,48 @@ import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-run
7
7
  * - Visual builder UI (when user has edit permissions)
8
8
  * - Shared context for bundles to access React, packages, etc.
9
9
  */
10
- import React, { createContext, useContext, useEffect, useRef, useCallback, useMemo, useState, } from 'react';
10
+ import React, { createContext, useContext, useEffect, useRef, useCallback, useMemo, useState, Component, } from 'react';
11
11
  import ReactDOM from 'react-dom';
12
12
  import { createBuilderClient, createBuilder, createCodeClient, createBundleLoader, createCSSLoader, BundleNotFoundError, BundleAuthError, } from 'dynim-core';
13
13
  import { createSharedContext, updateSharedContext, isSharedContextReady } from './inference/sharedContext';
14
14
  import { generateThemeCSS } from './theme';
15
+ class BundleErrorBoundary extends Component {
16
+ constructor(props) {
17
+ super(props);
18
+ this.state = { hasError: false, error: null };
19
+ this.lastResetKey = props.resetKey;
20
+ }
21
+ static getDerivedStateFromError(error) {
22
+ return { hasError: true, error };
23
+ }
24
+ componentDidCatch(error, errorInfo) {
25
+ console.warn('[DynimProvider] Bundle render error (will retry on next bundle):', error.message);
26
+ this.props.onError?.(error, errorInfo);
27
+ }
28
+ componentDidUpdate(prevProps) {
29
+ // Reset error state when resetKey changes (new bundle ready)
30
+ if (this.props.resetKey !== this.lastResetKey) {
31
+ this.lastResetKey = this.props.resetKey;
32
+ if (this.state.hasError) {
33
+ this.setState({ hasError: false, error: null });
34
+ }
35
+ }
36
+ }
37
+ render() {
38
+ if (this.state.hasError) {
39
+ return this.props.fallback ?? (_jsxs("div", { style: {
40
+ display: 'flex',
41
+ alignItems: 'center',
42
+ justifyContent: 'center',
43
+ minHeight: '200px',
44
+ color: '#6b7280',
45
+ fontSize: '14px',
46
+ gap: '8px',
47
+ }, children: [_jsx("svg", { style: { width: '16px', height: '16px', animation: 'spin 1s linear infinite' }, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: _jsx("path", { d: "M12 2v4m0 12v4m-8-10h4m12 0h4m-5.66-5.66l-2.83 2.83m-5.02 5.02l-2.83 2.83m0-11.32l2.83 2.83m5.02 5.02l2.83 2.83" }) }), _jsx("span", { children: "Updating preview..." }), _jsx("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })] }));
48
+ }
49
+ return this.props.children;
50
+ }
51
+ }
15
52
  /** Decode JWT payload to extract claims (no verification - just for reading IDs) */
16
53
  function decodeJwtPayload(token) {
17
54
  try {
@@ -335,7 +372,8 @@ export function DynimProvider({ children, config = {}, }) {
335
372
  // Note: CSS is loaded separately by saveCode/abandonCode with cache busting
336
373
  await loadBundle('/api/code/bundle', false);
337
374
  }, [loadBundle]);
338
- // Watch for bundleReady
375
+ // Watch for bundleReady - use bundleSequence to detect new bundles
376
+ // (bundleReady alone stays true, so subsequent events wouldn't trigger re-render)
339
377
  useEffect(() => {
340
378
  if (codeMessage.bundleReady && codeMessage.projectId) {
341
379
  if (isBuilderActiveRef.current && !isExitingRef.current) {
@@ -343,7 +381,7 @@ export function DynimProvider({ children, config = {}, }) {
343
381
  setBundleLoadSignal(s => s + 1);
344
382
  }
345
383
  }
346
- }, [codeMessage.bundleReady, codeMessage.projectId]);
384
+ }, [codeMessage.bundleReady, codeMessage.projectId, codeMessage.bundleSequence]);
347
385
  // Load temp bundle on signal (JS + CSS with cache busting)
348
386
  useEffect(() => {
349
387
  if (bundleLoadSignal === 0)
@@ -452,7 +490,7 @@ export function DynimProvider({ children, config = {}, }) {
452
490
  }, children: ["Bundle error: ", bundleError.message] }), children] }));
453
491
  }
454
492
  if (TenantApp) {
455
- return _jsx(TenantApp, {});
493
+ return (_jsx(BundleErrorBoundary, { resetKey: codeMessage.bundleSequence ?? 0, onError: (error) => configRef.current.onError?.(error), children: _jsx(TenantApp, {}) }));
456
494
  }
457
495
  return children;
458
496
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynim-react",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
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.41"
30
+ "dynim-core": "^1.0.43"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=17.0.0",