@hazem3500/palette 0.9.114 → 0.9.116

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/README.md CHANGED
@@ -442,6 +442,8 @@ Frame opens on your browser window's own size at **Fit**, and one compact contro
442
442
 
443
443
  `frame: { mode: "iframe" }` adds a simulated viewport, like a browser's device mode. The current URL renders in a same-origin `<iframe>` sized to the chosen width × height, at Fit or 100%, so media queries, `vw`/`vh`, `matchMedia`, resize events and `window.innerWidth` are real. Palette keeps running on your page and reaches into the frame: picking, hover outlines, pins, threads, Design mode (inspector, previews, Undo, Before/After), Tokens previews and keyboard shortcuts all work there, including with focus inside the frame. The page's own Palette, booted inside the frame, sees that Palette framed it and stays inert, so there is only ever one instance. Reviewers turn it on or off with **Simulate real viewport**, a checkbox row at the end of the Frame size menu ("Reloads the page in a frame so breakpoints and popovers match this size. Runs a second copy of the app."). Unchecked, Frame shows the page itself. Palette remembers the choice per project.
444
444
 
445
+ Hosts that store normalized comment paths can supply `frame.resolveUrl(destination, current)`. It receives the comment URL and the live iframe's `Location`; return the real same-origin `URL` for that context, or `null` to cancel. This hook is used only for comment navigation inside the viewport; `navigate` continues to own outer-page SPA navigation. Preserve any query/hash the host needs. Palette consumes its own `comment`/`comment-view` parameters before assigning the resolved URL. Exceptions, cancellation and cross-origin results retain the conversation without navigating. Stored page identities and anchors are unchanged.
446
+
445
447
  - **Opt-in.** The frame runs a second live copy of your app, with its own requests, sockets, analytics and auth refreshes, so the default stays `"transform"` (the page itself). Turn it on once your app is safe to run twice. With `defaultMode: "transform"`, Frame opens on the page itself and offers the simulated viewport, and a reviewer's own choice is remembered over the default. Without `mode: "iframe"` (an `iframeUrl` alone included) Frame never creates the iframe and the row doesn't appear; a choice remembered earlier is kept, unused, and applies again if you turn the mode back on.
446
448
  - **`iframeUrl(location)`** picks the URL to frame, e.g. a preview route for an app that needs its own bootstrap. It must be same-origin. If it changes the path, pass `page(location)` too, so comments keep the page they belong to: in the simulated viewport Palette passes the frame's location to `page`.
447
449
  - **Fallback.** When the frame can't show a same-origin page, Frame falls back to the page itself and the ⓘ beside the control says why: X-Frame-Options `DENY`, a CSP `frame-ancestors` that excludes the page, a redirect to another origin, or no load within 15 seconds. Turning **Simulate real viewport** off and on again retries.
@@ -473,9 +475,9 @@ if (import.meta.env.DEV && isShell(palette.project)) {
473
475
 
474
476
  - **Free in production.** `@hazem3500/palette/shell` is side-effect free and reads nothing until `isShell()` is called, so a build-time guard such as `import.meta.env.DEV && isShell(…)` drops it, and the shell branch, from production builds. Palette's package checks verify this on a minified build.
475
477
  - **Only Palette makes a shell.** `isShell(project)` is true only when Palette set a random nonce in this tab's sessionStorage and the URL carries the same one, for the same project and origin. A link with `?komo-shell=…` alone, or a flag left by another project, returns false, so a crafted link can't blank your app. If Palette doesn't start within 4 seconds (`isShell(project, { timeout })`), the shell clears itself and loads the normal page.
476
- - **Reloads.** Turning it on asks first, because the reload drops unsaved state in the app and Design previews you haven't posted. Your app's own `beforeunload` guard can also refuse the reload. Cancel or a refused reload keeps the second copy instead. A remembered Frame reopens in the shell on load without asking. Turning it off, Floating, closing Frame or a frame that can't load all reload the normal page on the frame's route.
478
+ - **Reloads.** Turning it on asks first, because the reload drops unsaved state in the app and Design previews you haven't posted. Your app's own `beforeunload` guard can also refuse the reload. Cancel or a refused reload keeps the current app without starting another copy. Storage, startup and frame-load failures also keep the normal page, show the failure, and require an explicit retry of **Simulate real viewport**. A remembered Frame reopens in the shell on load without asking. Turning it off, Floating, closing Frame or a frame that can't load all reload the normal page on the frame's route.
477
479
  - **URL.** The shell's URL follows the frame's route, so reloading or sharing it stays on the same page. The frame's own URL never carries the nonce.
478
- - **Two copies again.** If a shell ends early (Palette didn't start, or the frame couldn't load), the tab keeps the two-copy simulated viewport until the reviewer turns it on again. Server-rendered markup the guard can't skip still paints in the shell.
480
+ - **Single-copy boundary.** `shell: true` never falls back to loading a second app. The early `isShell()` guard must run before mounting; server-rendered markup the guard cannot skip still paints in the shell. Reloads do not transfer in-memory auth or app state: the host must restore that state in the framed document.
479
481
 
480
482
  `frame: { scale: true }` explicitly opts into shrinking the original viewport instead. A CSS transform changes visual rectangles without changing local layout dimensions, so arbitrary coordinate-sensitive host handlers may select the wrong value under scaling. This option requires host controls that already account for transforms; Palette does not rewrite native events or browser prototypes. Use the default unscaled Frame or Floating for interactive pages that do not support scaling.
481
483