@shellui/core 0.7.0-alpha.7 → 0.7.0-alpha.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shellui/core",
3
- "version": "0.7.0-alpha.7",
3
+ "version": "0.7.0-alpha.8",
4
4
  "description": "Shellui Core - Core React application runtime",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -73,7 +73,7 @@
73
73
  "workbox-routing": "^7.4.0",
74
74
  "workbox-strategies": "^7.4.0",
75
75
  "workbox-window": "^7.4.0",
76
- "@shellui/sdk": "0.7.0-alpha.7"
76
+ "@shellui/sdk": "0.7.0-alpha.8"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "react": "^18.0.0 || ^19.0.0",
@@ -73,8 +73,10 @@ export const ContentView = ({
73
73
  const iframeRef = useRef<HTMLIFrameElement>(null);
74
74
  const cancelRevealRef = useRef<(() => void) | null>(null);
75
75
  const mountTimeRef = useRef(Date.now());
76
- /** Shell path last reported by the iframe — skip driving iframe when we caused the location change. */
76
+ /** Shell path last synced with the iframe. */
77
77
  const lastShellPathFromIframeRef = useRef<string | null>(null);
78
+ /** Iframe reports not rendered back yet: their echo must not drive the iframe. */
79
+ const pendingFromIframeRef = useRef<string[]>([]);
78
80
  const skipInitialShellSyncRef = useRef(true);
79
81
  const prevNavPathRef = useRef(navItem?.path ?? '');
80
82
 
@@ -119,9 +121,16 @@ export const ContentView = ({
119
121
  return;
120
122
  }
121
123
 
124
+ const echo = pendingFromIframeRef.current.indexOf(currentShellPath);
125
+ if (echo >= 0 && !navItemChanged) {
126
+ pendingFromIframeRef.current = pendingFromIframeRef.current.slice(echo + 1);
127
+ lastShellPathFromIframeRef.current = currentShellPath;
128
+ return;
129
+ }
122
130
  if (lastShellPathFromIframeRef.current === currentShellPath && !navItemChanged) {
123
131
  return;
124
132
  }
133
+ pendingFromIframeRef.current = [];
125
134
 
126
135
  lastShellPathFromIframeRef.current = currentShellPath;
127
136
  mountTimeRef.current = Date.now();
@@ -173,7 +182,7 @@ export const ContentView = ({
173
182
  return;
174
183
  }
175
184
 
176
- const { pathname, search, hash } = data.payload as ShellUIUrlPayload;
185
+ const { pathname, search, hash, replace } = data.payload as ShellUIUrlPayload;
177
186
  // Shell URL is always path + search only (no hash) so it's transparent whether the sub-app uses hash routing or not
178
187
  let pathSegment: string;
179
188
  if (isHashRouterNavItem(navItem) && hash) {
@@ -223,17 +232,19 @@ export const ContentView = ({
223
232
  const normalizedNewPathname = newPathParts?.[1]?.replace(/\/+$/, '') || '/';
224
233
  const normalizedNewPath = normalizedNewPathname + (newPathParts?.[2] || '');
225
234
 
226
- // Mark before navigate so the shell-sync effect does not reload the iframe
227
- lastShellPathFromIframeRef.current = normalizedNewPath;
228
-
229
235
  if (currentPath !== normalizedNewPath) {
230
236
  if (!isSafeShellPath(normalizedNewPath)) {
231
237
  logger.warn('ContentView: refused unsafe shell path from iframe', normalizedNewPath);
232
238
  return;
233
239
  }
234
- // Push — iframe pushState is replace-only when embedded, so the shell
235
- // is the sole owner of back/forward entries.
236
- navigate(newShellPath);
240
+ // Mark before navigate so the shell-sync effect does not drive the iframe back.
241
+ pendingFromIframeRef.current = [
242
+ ...pendingFromIframeRef.current.slice(-19),
243
+ normalizedNewPath,
244
+ ];
245
+ // Iframe pushState is replace-only when embedded, so the shell owns back and
246
+ // forward. A child redirect replaces, so it never adds an entry.
247
+ navigate(newShellPath, { replace: replace === true });
237
248
  }
238
249
  },
239
250
  );