@mgamadeus/ddd-design-studio 0.5.1 → 0.5.2

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.
@@ -818,6 +818,58 @@ var useImageRetry = (url) => {
818
818
  return { imageKey: `${url ?? ""}#${attempt}`, isFailed, onError: () => setIsFailed(true) };
819
819
  };
820
820
 
821
+ // src/site/siteNavigation.ts
822
+ var normalizeSitePath = (path) => {
823
+ const trimmed = path.trim();
824
+ if (/[?#]/.test(trimmed) || trimmed.includes("..") || trimmed.includes("//")) return null;
825
+ const segments = trimmed.split("/").filter((segment) => segment !== "" && segment !== ".");
826
+ return `/${segments.join("/")}`;
827
+ };
828
+ var sitePagesOf = (boards) => {
829
+ const pages = /* @__PURE__ */ new Map();
830
+ for (const board of boards) {
831
+ if (board.route && !pages.has(board.route)) pages.set(board.route, board);
832
+ }
833
+ return pages;
834
+ };
835
+ var startRouteOf = (pages, route) => {
836
+ const normalized = route !== null ? normalizeSitePath(route) : null;
837
+ if (normalized !== null && pages.has(normalized)) return normalized;
838
+ if (pages.has("/")) return "/";
839
+ return pages.keys().next().value ?? null;
840
+ };
841
+ var resolveSiteHref = (href, currentRoute, boards) => {
842
+ const trimmed = href.trim();
843
+ if (trimmed === "" || trimmed.startsWith("#")) return { kind: "anchor", hash: trimmed };
844
+ if (trimmed.startsWith("board:")) {
845
+ const boardKey = trimmed.slice("board:".length).split("#")[0];
846
+ const board2 = boards.find((candidate) => candidate.boardKey === boardKey);
847
+ return board2?.route ? { kind: "page", board: board2, route: board2.route, hash: null } : { kind: "missing", path: trimmed };
848
+ }
849
+ if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed) || trimmed.startsWith("//")) return { kind: "external", href: trimmed };
850
+ const hashIndex = trimmed.indexOf("#");
851
+ const hash = hashIndex >= 0 ? trimmed.slice(hashIndex) : null;
852
+ const pathWithQuery = hashIndex >= 0 ? trimmed.slice(0, hashIndex) : trimmed;
853
+ const path = pathWithQuery.split("?")[0];
854
+ const absolutePath = path.startsWith("/") ? path : `${currentRoute.endsWith("/") ? currentRoute : currentRoute.slice(0, currentRoute.lastIndexOf("/") + 1)}${path}`;
855
+ const route = normalizeSitePath(absolutePath);
856
+ const board = route !== null ? sitePagesOf(boards).get(route) : void 0;
857
+ return board && route !== null ? { kind: "page", board, route, hash } : { kind: "missing", path: route ?? path };
858
+ };
859
+ var parseSiteFrameMessage = (data) => {
860
+ if (typeof data !== "object" || data === null) return null;
861
+ const message = data;
862
+ if (message.source !== "design-studio-site") return null;
863
+ if (message.type === "navigate" && typeof message.href === "string") return { type: "navigate", href: message.href };
864
+ if (message.type === "scroll" && typeof message.top === "number" && Number.isFinite(message.top)) {
865
+ return { type: "scroll", top: Math.max(0, Math.round(message.top)) };
866
+ }
867
+ if (message.type === "height" && typeof message.height === "number" && Number.isFinite(message.height)) {
868
+ return { type: "height", height: Math.max(1, Math.min(1e5, Math.round(message.height))) };
869
+ }
870
+ return null;
871
+ };
872
+
821
873
  export {
822
874
  FRAME_GAP,
823
875
  FRAME_LABEL_HEIGHT,
@@ -862,6 +914,10 @@ export {
862
914
  WidthDragHandle,
863
915
  wasContentUrlLoaded,
864
916
  useCheckedContentUrl,
865
- useImageRetry
917
+ useImageRetry,
918
+ sitePagesOf,
919
+ startRouteOf,
920
+ resolveSiteHref,
921
+ parseSiteFrameMessage
866
922
  };
867
- //# sourceMappingURL=chunk-FXDTHFHX.js.map
923
+ //# sourceMappingURL=chunk-GPHJ2WQ3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/canvas/deviceViewport.ts","../src/canvas/designReference.ts","../src/canvas/boardKey.ts","../src/canvas/boardCode.ts","../src/canvas/designTheme.ts","../src/provider/texts.ts","../src/provider/DesignStudioProvider.tsx","../src/utils/cx.ts","../src/canvas/BoardComments.tsx","../src/canvas/ViewportControls.tsx","../src/canvas/useCheckedContentUrl.ts","../src/site/siteNavigation.ts"],"sourcesContent":["/**\n * Responsive boards: the viewport a board is shown in (a device preset, rotated, or a free width), the size of a\n * responsive board on the canvas (its device frames side by side) and which comments belong to a viewport. Pure\n * functions, no React (tested in deviceViewport.test.ts).\n */\n\nimport type { DesignDevice, DesignStudioBoardFrameView, DesignStudioBoardView, DesignStudioComment } from '../api/types';\n\n/** Gap between the device frames of a responsive board on the canvas (the backend's FRAME_GAP). */\nexport const FRAME_GAP = 48;\n\n/** Height of the label line above each device frame on the canvas. */\nexport const FRAME_LABEL_HEIGHT = 40;\n\n/** Narrowest and widest free width of the focus view's drag handle (the backend's device width bounds). */\nexport const MINIMUM_VIEWPORT_WIDTH = 240;\nexport const MAXIMUM_VIEWPORT_WIDTH = 3840;\n\n/** Highest a responsive board is drawn on the canvas in page mode (longer pages are cut, whole in the focus view). */\nexport const MAX_PAGE_CANVAS_HEIGHT = 8000;\n\n/** How high the device frames of responsive boards are drawn on the canvas. */\nexport type FrameHeightMode = 'viewport' | 'page';\n\n/** The viewport a responsive board is shown in. `deviceKey` null = a free width (or a rotation without a preset). */\nexport interface DeviceViewport {\n width: number;\n height: number;\n deviceKey: string | null;\n}\n\nexport const isResponsiveBoard = (board: DesignStudioBoardView | null | undefined): boolean =>\n Boolean(board?.isResponsive && (board.frames?.elements?.length ?? 0) > 0);\n\nexport const framesOf = (board: DesignStudioBoardView | null | undefined): DesignStudioBoardFrameView[] =>\n board?.frames?.elements ?? [];\n\nexport const viewportOfDevice = (device: DesignDevice): DeviceViewport => ({\n width: device.width ?? 0,\n height: device.height ?? 0,\n deviceKey: device.deviceKey ?? null,\n});\n\n/**\n * The viewport a responsive board opens in: the current one when there is one (a device picked in the focus view or\n * for present mode stays while stepping through boards), else the board's first frame.\n */\nexport const initialViewportForBoard = (\n board: DesignStudioBoardView | null | undefined,\n current: DeviceViewport | null\n): DeviceViewport | null => {\n if (!isResponsiveBoard(board)) return null;\n if (current) return current;\n const firstFrame = framesOf(board)[0];\n return { width: firstFrame.width ?? 0, height: firstFrame.height ?? 0, deviceKey: firstFrame.deviceKey ?? null };\n};\n\n/**\n * The viewport the site view opens a page in: its widest frame (a website is first looked at on a desktop), the\n * current one when one was picked.\n */\nexport const siteViewportForBoard = (\n board: DesignStudioBoardView | null | undefined,\n current: DeviceViewport | null\n): DeviceViewport | null => {\n if (!isResponsiveBoard(board)) return null;\n if (current) return current;\n const widestFrame = framesOf(board).reduce((widest, frame) => ((frame.width ?? 0) > (widest.width ?? 0) ? frame : widest));\n return { width: widestFrame.width ?? 0, height: widestFrame.height ?? 0, deviceKey: widestFrame.deviceKey ?? null };\n};\n\n/** Landscape ↔ portrait: width and height swapped; the preset with exactly that size when there is one. */\nexport const rotateViewport = (viewport: DeviceViewport, devices: readonly DesignDevice[]): DeviceViewport => {\n const rotated = { width: viewport.height, height: viewport.width };\n const matchingDevice = devices.find(device => device.width === rotated.width && device.height === rotated.height);\n return { ...rotated, deviceKey: matchingDevice?.deviceKey ?? null };\n};\n\n/** A free width from the drag handle (bounded); the height stays, the preset is left. */\nexport const viewportWithWidth = (viewport: DeviceViewport, width: number): DeviceViewport => ({\n width: Math.round(Math.max(MINIMUM_VIEWPORT_WIDTH, Math.min(MAXIMUM_VIEWPORT_WIDTH, width))),\n height: viewport.height,\n deviceKey: null,\n});\n\n/** `iPhone 16 / 15 · 393 × 852`, `Free width · 900 × 852`. */\nexport const viewportLabel = (viewport: DeviceViewport, devices: readonly DesignDevice[]): string => {\n const device = viewport.deviceKey ? devices.find(candidate => candidate.deviceKey === viewport.deviceKey) : undefined;\n return `${device?.label ?? (viewport.deviceKey ?? 'Free width')} · ${viewport.width} × ${viewport.height}`;\n};\n\n/**\n * The page height of a responsive board at a width: the rendered height of the frame of that width; else the frame of\n * the nearest width (a narrower page is taller: scaled by the width ratio); else three screens.\n */\nexport const pageHeightAtWidth = (board: DesignStudioBoardView, width: number, viewportHeight: number): number => {\n const frames = framesOf(board).filter(frame => (frame.pageHeight ?? 0) > 0 && (frame.width ?? 0) > 0);\n const exactFrame = frames.find(frame => frame.width === width);\n if (exactFrame) return Math.max(viewportHeight, exactFrame.pageHeight ?? 0);\n if (frames.length === 0) return viewportHeight * 3;\n const nearestFrame = frames.reduce((nearest, frame) =>\n Math.abs((frame.width ?? 0) - width) < Math.abs((nearest.width ?? 0) - width) ? frame : nearest\n );\n return Math.max(viewportHeight, Math.round(((nearestFrame.pageHeight ?? 0) * (nearestFrame.width ?? 1)) / Math.max(1, width)));\n};\n\n/** Height of one device frame on the canvas in a mode (page mode: the rendered page, once there is one). */\nexport const frameCanvasHeight = (frame: DesignStudioBoardFrameView, mode: FrameHeightMode): number => {\n const viewportHeight = frame.height ?? 0;\n if (mode === 'viewport') return viewportHeight;\n return Math.min(MAX_PAGE_CANVAS_HEIGHT, Math.max(viewportHeight, frame.pageHeight ?? viewportHeight));\n};\n\n/** Size of a board on the canvas below its header: a responsive board = its frames side by side with their labels. */\nexport const boardCanvasSize = (\n board: DesignStudioBoardView,\n mode: FrameHeightMode\n): { width: number; height: number } => {\n if (!isResponsiveBoard(board)) return { width: board.width ?? 390, height: board.height ?? 844 };\n const frames = framesOf(board);\n const width = frames.reduce((sum, frame) => sum + (frame.width ?? 0), 0) + FRAME_GAP * (frames.length - 1);\n const height = FRAME_LABEL_HEIGHT + Math.max(...frames.map(frame => frameCanvasHeight(frame, mode)));\n return { width, height };\n};\n\n/** The viewport a comment's pin was placed in, null for a comment on a fixed board (or without a pin). */\nexport const viewportOfComment = (comment: DesignStudioComment): DeviceViewport | null =>\n comment.viewportWidth\n ? { width: comment.viewportWidth, height: comment.viewportHeight ?? comment.viewportWidth, deviceKey: comment.deviceKey ?? null }\n : null;\n\n/**\n * Whether a comment's pin is shown in a viewport: a pin placed in a viewport shows at that width only (its position\n * is a position in the page at that width); a pin without a viewport (a fixed board) shows when no viewport is set.\n */\nexport const isPinInViewport = (comment: DesignStudioComment, viewport: DeviceViewport | null): boolean => {\n const commentViewport = viewportOfComment(comment);\n if (!viewport) return commentViewport === null;\n return commentViewport !== null && commentViewport.width === viewport.width;\n};\n\n/** `393x852 iphone-16` / `900x852`: the viewport as a design reference and the console print it. */\nexport const viewportReferenceText = (viewport: DeviceViewport): string =>\n `${viewport.width}x${viewport.height}${viewport.deviceKey ? ` ${viewport.deviceKey}` : ''}`;\n","/**\n * Design references for agentic editing (\"send to agent\"): a plain-text block that names one\n * board (and optionally a region of it, a comment, a note) with stable keys, so an agent session can resolve it.\n * Format (one line per board, fields joined by \" · \", the deep link always last; optional\n * extra lines below):\n *\n * [design-ref] App › Onboarding – first run › 2 Welcome · code APP ONB-W2 · file onb-w-2-welcome.dc.html · canvas app/onboarding\n * · v3f9c2ab · theme brand:1:dark · viewport 393x852 iphone-16 · region 24,180,342,220\n * · https://…/app/canvases/onboarding?board=onb-w-2-welcome.dc.html&theme=brand:1&mode=dark\n * note: make the tab bar more compact\n *\n * `code` is the board code (left out when the board has none), `file` the board key (the file name in the canvas folder), `v…` the first 7 characters of the board file's\n * content hash (git blob hash), `theme` the theme reference the board was looked at in (`none` = as authored),\n * `viewport` (responsive boards only) the viewport width × height and device preset the board was looked at in — a\n * region or a comment position is a position in the page at that width.\n *\n * Pure functions, no React (tested in designReference.test.ts).\n */\n\nimport { type DeviceViewport, viewportReferenceText } from './deviceViewport.ts';\n\nexport const DESIGN_REFERENCE_PREFIX = '[design-ref]';\n\n/** A rectangle on a board in board pixels (independent of the zoom). */\nexport interface BoardRegion {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface DesignReferenceInput {\n projectName: string;\n canvasName: string;\n projectKey: string;\n canvasKey: string;\n boardTitle: string;\n /** File name of the board in the canvas folder. */\n boardKey: string;\n /** Board code (`APP ONB-W2`), null / absent = the board has none. */\n boardCode?: string | null;\n /** Content hash of the board file (git blob hash); the reference carries its first 7 characters. */\n contentHash: string | null;\n /** Theme reference the board is shown in (`<themeId>` or `<themeId>:dark`), null = as authored. */\n themeReference: string | null;\n /** Deep link to the board on the canvas (with theme and mode). */\n url: string;\n /** The viewport a responsive board is looked at in (region / comment positions are page positions at its width). */\n viewport?: DeviceViewport | null;\n region?: BoardRegion | null;\n /** A comment thread the reference is about (id + pin position). */\n comment?: { id: number | string; x: number | null; y: number | null; lines: string[] } | null;\n /** What should change (free text). */\n note?: string | null;\n}\n\nconst oneLine = (text: string) => text.replace(/\\s+/g, ' ').trim();\n\n/** One reference block (first line + optional `comment:` / `note:` lines). */\nexport const buildDesignReference = (input: DesignReferenceInput): string => {\n const fields = [\n `${DESIGN_REFERENCE_PREFIX} ${oneLine(input.projectName)} › ${oneLine(input.canvasName)} › ${oneLine(input.boardTitle)}`,\n ...(input.boardCode ? [`code ${oneLine(input.boardCode)}`] : []),\n `file ${input.boardKey}`,\n `canvas ${input.projectKey}/${input.canvasKey}`,\n `v${input.contentHash ? input.contentHash.slice(0, 7) : '?'}`,\n `theme ${input.themeReference || 'none'}`,\n ...(input.viewport ? [`viewport ${viewportReferenceText(input.viewport)}`] : []),\n ];\n if (input.region) {\n const { x, y, width, height } = input.region;\n fields.push(`region ${Math.round(x)},${Math.round(y)},${Math.round(width)},${Math.round(height)}`);\n }\n if (input.comment) {\n const position =\n input.comment.x != null && input.comment.y != null\n ? ` at ${Math.round(input.comment.x)},${Math.round(input.comment.y)}`\n : '';\n fields.push(`comment ${input.comment.id}${position}`);\n }\n fields.push(input.url);\n const lines = [fields.join(' · ')];\n for (const commentLine of input.comment?.lines ?? []) {\n if (commentLine.trim()) lines.push(`comment: ${oneLine(commentLine)}`);\n }\n if (input.note?.trim()) lines.push(`note: ${oneLine(input.note)}`);\n return lines.join('\\n');\n};\n\n/**\n * Deep link to a board: the current page URL with `board` (the board key), the look (`theme`, `mode`; left out when\n * the board is shown as authored) and, when given, the canvas viewport `vp` (other canvas parameters dropped) — the\n * link reopens the focus view over the same part of the canvas.\n */\nexport const buildBoardDeepLink = (\n pageUrl: string,\n boardKey: string,\n themeId: string | null,\n mode: 'light' | 'dark',\n viewport?: string | null\n): string => {\n const url = new URL(pageUrl);\n url.search = '';\n url.hash = '';\n url.searchParams.set('board', boardKey);\n if (themeId) {\n url.searchParams.set('theme', themeId);\n url.searchParams.set('mode', mode);\n }\n if (viewport) url.searchParams.set('vp', viewport);\n // commas and colons are valid in a query; unescaped, the viewport and the theme stay readable in a pasted reference\n return url.toString().replace(/%2C/gi, ',').replace(/%3A/gi, ':');\n};\n\n/**\n * Copies text: the async Clipboard API, else a hidden textarea + `execCommand('copy')` (older browsers, insecure\n * origins).\n * @returns whether the text reached the clipboard\n */\nexport const copyTextToClipboard = async (text: string): Promise<boolean> => {\n if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n // fall through to the textarea fallback (permission denied, document not focused)\n }\n }\n if (typeof document === 'undefined') return false;\n const textarea = document.createElement('textarea');\n textarea.value = text;\n textarea.setAttribute('readonly', '');\n textarea.style.position = 'fixed';\n textarea.style.opacity = '0';\n document.body.appendChild(textarea);\n textarea.select();\n const isCopied = document.execCommand('copy');\n textarea.remove();\n return isCopied;\n};\n","/**\n * A board's code: its key (the file name in the canvas folder) without the `.html` extension and without an optional\n * `.dc` before it (`welcome.html` and `welcome.dc.html` both give `welcome`). Shown under the title and used as the\n * base name of downloads. A key without `.html` is returned as it is.\n */\nexport const boardCodeOf = (boardKey: string): string => boardKey.replace(/(?:\\.dc)?\\.html$/, '');\n","/**\n * Board codes (`APP ONB-W2`): the short name of a board that people say in a chat or paste into the studio. The\n * backend sets them (project code + canvas code + a board part from the file name or canvas.json); here they are\n * matched and turned into links. A code link opens the canvas on that board: the view moves to it, the board is\n * selected and its side panel shows.\n *\n * Pure functions, no React (tested in boardCode.test.ts).\n */\n\nimport { boardCodeOf } from './boardKey.ts';\n\n/** URL parameter of a code link (`?code=APP-ONB-W2`). */\nexport const CODE_PARAM = 'code';\n\n/** A code for comparisons: upper case, letters and digits only (`app onb-w2` → `APPONBW2`). */\nexport const normalizeBoardCode = (code: string): string => code.toUpperCase().replace(/[^A-Z0-9]/g, '');\n\n/** The parts of a code: `APP ONB-W2` → `['APP', 'ONB', 'W2']`. */\nconst codeParts = (code: string): string[] => code.trim().toUpperCase().split(/[\\s-]+/).filter(Boolean);\n\n/**\n * Whether a typed code names a board on its canvas: the full code, the code without the project part, or the board\n * part alone (`APP ONB-W2`, `ONB-W2`, `w2`) — case, spaces and dashes do not matter, a fragment (`2`, `NBW2`) does not\n * match.\n */\nexport const boardCodeMatches = (typedCode: string, boardCode: string | null | undefined): boolean => {\n const typed = normalizeBoardCode(typedCode);\n if (!typed || !boardCode) return false;\n const parts = codeParts(boardCode);\n return parts.some((_, index) => parts.slice(index).join('') === typed);\n};\n\n/**\n * Whether a typed code belongs to a canvas: it starts with the canvas' code prefix, with or without the project part\n * (`APP ONB-W2` and `ONB-W2` belong to `APP ONB`). Used by the overview to send a pasted code to its canvas.\n */\nexport const codeBelongsToCanvas = (typedCode: string, canvasCode: string | null | undefined): boolean => {\n const typed = normalizeBoardCode(typedCode);\n if (!typed || !canvasCode) return false;\n const parts = codeParts(canvasCode);\n return parts.some((_, index) => {\n const prefix = parts.slice(index).join('');\n return typed.length > prefix.length && typed.startsWith(prefix);\n });\n};\n\n/** A code as a URL value: parts joined by dashes (`APP ONB-W2` → `APP-ONB-W2`), readable in a pasted link. */\nexport const boardCodeUrlValue = (code: string): string => codeParts(code).join('-');\n\n/**\n * Link that opens a canvas on one board by its code: the canvas page URL (other parameters dropped) with `code`,\n * plus the look (`theme`, `mode`) when the board is shown in one.\n */\nexport const buildBoardCodeLink = (\n canvasPageUrl: string,\n code: string,\n themeId: string | null,\n mode: 'light' | 'dark'\n): string => {\n const url = new URL(canvasPageUrl);\n url.search = '';\n url.hash = '';\n url.searchParams.set(CODE_PARAM, boardCodeUrlValue(code));\n if (themeId) {\n url.searchParams.set('theme', themeId);\n url.searchParams.set('mode', mode);\n }\n return url.toString().replace(/%3A/gi, ':');\n};\n\n/**\n * The board a typed code names on a canvas: by its code (`boardCodeMatches`), else by its file name without extension\n * (`onb-w-2-welcome`, for boards without a code). Null when none or more than one board matches.\n */\nexport const findBoardForCode = <Board extends { code?: string | null; boardKey?: string | null }>(\n boards: readonly Board[],\n typedCode: string\n): Board | null => {\n const byCode = boards.filter(board => boardCodeMatches(typedCode, board.code));\n if (byCode.length > 0) return byCode.length === 1 ? byCode[0] : null;\n const typed = typedCode.trim().toLowerCase();\n const byName = boards.filter(board => board.boardKey && boardCodeOf(board.boardKey).toLowerCase() === typed);\n return byName.length === 1 ? byName[0] : null;\n};\n","/**\n * Theme references of the design studio: `<themeId>` or `<themeId>:<mode>` (mode `light` or `dark`), e.g.\n * `brand:1:dark` — the theme id itself may contain colons, only a trailing `:light` / `:dark` is the mode (same rule\n * as `DesignThemeReference::fromString`). Pure functions, no React (tested in designTheme.test.ts).\n */\n\nexport type ThemeMode = 'light' | 'dark';\n\nexport interface ThemeLook {\n themeId: string;\n mode: ThemeMode;\n}\n\n/** Splits a theme reference; null without one (the boards are shown as authored). */\nexport const splitThemeReference = (themeReference: string | null | undefined): ThemeLook | null => {\n const reference = (themeReference ?? '').trim();\n if (!reference) return null;\n for (const mode of ['light', 'dark'] as const) {\n if (reference.endsWith(`:${mode}`)) return { themeId: reference.slice(0, -(mode.length + 1)), mode };\n }\n return { themeId: reference, mode: 'light' };\n};\n\n/** `<themeId>` for light, `<themeId>:dark` for dark. */\nexport const buildThemeReference = (themeId: string, mode: ThemeMode): string =>\n mode === 'dark' ? `${themeId}:dark` : themeId;\n","import type { DesignStudioTexts } from './types';\n\n/** The English defaults of the texts an application can replace through `environment.texts`. */\nexport const DEFAULT_DESIGN_STUDIO_TEXTS: DesignStudioTexts = {\n referencesCopied: count => (count > 1 ? `References copied (${count})` : 'Reference copied'),\n boardsUpdated: count => (count === 1 ? '1 board updated' : `${count} boards updated`),\n showUpdatedBoard: 'Show',\n canvasUpToDate: 'Canvas is up to date',\n reload: 'Reload (R)',\n thumbnailsFailed: 'Thumbnails failed · try again',\n thumbnailsWaitingForRenderer: themeLabel => `Thumbnails for ${themeLabel} are waiting for the renderer`,\n thumbnailsRendering: themeLabel => `Thumbnails for ${themeLabel} are being rendered`,\n thumbnailsFallbackThemeLabel: 'this look',\n thumbnailsMissing: count =>\n count === 1\n ? '1 board has no thumbnail in this look yet; it appears as soon as it is rendered.'\n : `${count} boards have no thumbnail in this look yet; they appear as soon as they are rendered.`,\n thumbnailsLastError: error => `Last error: ${error}`,\n themeWithoutDarkMode: 'This theme has no dark mode',\n thumbnailMissing: 'No thumbnail yet',\n thumbnailLoading: 'Loading…',\n sitePageMissing: path => `No page for ${path}`,\n siteExternalLink: href => `External link, not followed: ${href}`,\n openAsWebsite: 'Open as website',\n referenceNotePlaceholder: 'What should change? (optional, goes into the reference)',\n boardCodeNotFound: code => `No board has the code ${code}`,\n boardLinkCopied: code => `Link to ${code} copied`,\n copyBoardLink: 'Copy link',\n};\n\n/** The defaults with the application's replacements on top; an entry that is missing or `undefined` keeps its default. */\nexport const resolveDesignStudioTexts = (texts: Partial<DesignStudioTexts> | undefined): DesignStudioTexts => {\n if (!texts) return DEFAULT_DESIGN_STUDIO_TEXTS;\n const defined = Object.fromEntries(Object.entries(texts).filter(([, value]) => value !== undefined));\n return { ...DEFAULT_DESIGN_STUDIO_TEXTS, ...defined };\n};\n","'use client';\n\nimport { createContext, type ReactNode, useContext, useMemo } from 'react';\n\nimport type { DesignStudioApi } from '../api/createDesignStudioApi';\nimport { resolveDesignStudioTexts } from './texts';\nimport type {\n DesignStudioComponents,\n DesignStudioEnvironment,\n DesignStudioNotify,\n DesignStudioPaths,\n DesignStudioRouter,\n DesignStudioTexts,\n} from './types';\n\nconst DesignStudioContext = createContext<DesignStudioEnvironment | null>(null);\n\nexport interface DesignStudioProviderProps {\n /** Keep it referentially stable (a module constant): every studio component reads it. */\n environment: DesignStudioEnvironment;\n children: ReactNode;\n}\n\n/** Hands the application's environment (API, router, UI primitives, …) to the studio's screens below it. */\nexport const DesignStudioProvider = ({ environment, children }: DesignStudioProviderProps) => (\n <DesignStudioContext.Provider value={environment}>{children}</DesignStudioContext.Provider>\n);\n\n/** The whole environment. */\nexport const useDesignStudio = (): DesignStudioEnvironment => {\n const environment = useContext(DesignStudioContext);\n if (!environment) {\n throw new Error('The design studio needs a DesignStudioProvider above it');\n }\n return environment;\n};\n\nexport const useDesignStudioApi = (): DesignStudioApi => useDesignStudio().api;\n\nexport const useDesignStudioComponents = (): DesignStudioComponents => useDesignStudio().components;\n\nexport const useDesignStudioRouter = (): DesignStudioRouter => useDesignStudio().router;\n\nexport const useDesignStudioPaths = (): DesignStudioPaths => useDesignStudio().paths;\n\nexport const useDesignStudioNotify = (): DesignStudioNotify => useDesignStudio().notify;\n\n/** The UI texts: the application's replacements (`environment.texts`) on top of the English defaults. Stable per environment. */\nexport const useDesignStudioTexts = (): DesignStudioTexts => {\n const { texts } = useDesignStudio();\n return useMemo(() => resolveDesignStudioTexts(texts), [texts]);\n};\n","import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\n/** Conditional class names, later Tailwind classes winning over earlier ones (`clsx` + `tailwind-merge`). */\nexport const cx = (...inputs: ClassValue[]): string => twMerge(clsx(inputs));\n","'use client';\n\nimport { normalizeDddError } from '@mgamadeus/ddd-web/api';\nimport { Bot, CheckCircle2, ClipboardCopy, Flag, History, Hourglass, MapPin, RotateCcw, Trash2 } from 'lucide-react';\nimport { useState } from 'react';\n\nimport type { DesignStudioBoardView, DesignStudioComment } from '../api/types';\nimport { useDesignStudio } from '../provider/DesignStudioProvider';\nimport { cx } from '../utils/cx';\nimport { type DeviceViewport, viewportOfComment } from './deviceViewport';\n\n/**\n * A pin position on a board: board pixels on a fixed board, page pixels at the viewport's width on a responsive one.\n */\nexport interface BoardPin {\n x: number;\n y: number;\n /** The viewport the pin was placed in (a responsive board), null on a fixed board. */\n viewport?: DeviceViewport | null;\n}\n\n/** Thread roots of a board with their replies, oldest first. */\nexport interface CommentThread {\n root: DesignStudioComment;\n replies: DesignStudioComment[];\n /** 1-based number of a pinned root (shown on the board), null for a board-level comment. */\n pinNumber: number | null;\n}\n\n/** Groups a board's comments into threads by `parentDesignStudioCommentId` (null = a thread root). */\nexport const buildCommentThreads = (comments: DesignStudioComment[]): CommentThread[] => {\n const repliesByRootId = new Map<number, DesignStudioComment[]>();\n for (const comment of comments) {\n if (comment.parentDesignStudioCommentId != null) {\n const replies = repliesByRootId.get(comment.parentDesignStudioCommentId) ?? [];\n replies.push(comment);\n repliesByRootId.set(comment.parentDesignStudioCommentId, replies);\n }\n }\n let pinNumber = 0;\n return comments\n .filter(comment => comment.parentDesignStudioCommentId == null)\n .map(root => ({\n root,\n replies: repliesByRootId.get(Number(root.id)) ?? [],\n pinNumber: root.x != null && root.y != null ? ++pinNumber : null,\n }));\n};\n\nconst errorMessage = (error: unknown) => normalizeDddError(error, 'Request failed').message;\n\ninterface CommentLineProps {\n comment: DesignStudioComment;\n isOwn: boolean;\n writesAllowed: boolean;\n}\n\nconst CommentLine = ({ comment, isOwn, writesAllowed }: CommentLineProps) => {\n const { api, components, formatDateTime, notify } = useDesignStudio();\n const { Button } = components;\n const [deleteComment, { isLoading: isDeleting }] = api.useDeleteCommentMutation();\n return (\n <div className=\"space-y-1\">\n <p className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n {comment.authorKind === 'AGENT' && <Bot className=\"size-3.5 text-brand-emphasis\" aria-label=\"Agent\" />}\n <span className=\"font-semibold text-foreground\">{comment.authorName ?? 'Unknown'}</span>\n <span>· {formatDateTime(comment.changeHistory?.createdTime)}</span>\n {isOwn && (\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"ml-auto size-6\"\n aria-label=\"Delete comment\"\n disabled={!writesAllowed || isDeleting}\n onClick={() =>\n deleteComment({ designStudioCommentId: Number(comment.id) })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <Trash2 className=\"size-3.5\" />\n </Button>\n )}\n </p>\n <p className=\"text-sm whitespace-pre-wrap break-words\">{comment.text}</p>\n </div>\n );\n};\n\ninterface ThreadCardProps {\n thread: CommentThread;\n /** \"Copy for agent\": the board reference with this thread (pin + texts). */\n onCopyReference: (thread: CommentThread) => void;\n isHighlighted: boolean;\n onHighlight: () => void;\n authAccountId: number | null;\n writesAllowed: boolean;\n /** The board file is another version than the one the thread was written on. */\n hasBoardChangedSince: boolean;\n /** The thread is deleted soon unless something happens in it (\"Keep\" postpones that). */\n isExpiring: boolean;\n /** A thread pinned in a viewport (responsive board): shows the board in that viewport. */\n onSelectViewport?: (viewport: DeviceViewport) => void;\n}\n\nconst ThreadCard = ({\n thread,\n onCopyReference,\n isHighlighted,\n onHighlight,\n authAccountId,\n writesAllowed,\n hasBoardChangedSince,\n isExpiring,\n onSelectViewport,\n}: ThreadCardProps) => {\n const { root, replies, pinNumber } = thread;\n const rootViewport = viewportOfComment(root);\n const [replyText, setReplyText] = useState('');\n const { api, components, notify } = useDesignStudio();\n const { Badge, Button, Textarea } = components;\n const [createReply, { isLoading: isReplying }] = api.useReplyToCommentMutation();\n const [resolveThread, { isLoading: isResolving }] = api.useResolveCommentMutation();\n const [reopenThread, { isLoading: isReopening }] = api.useReopenCommentMutation();\n const [patchComment, { isLoading: isPatching }] = api.usePatchCommentMutation();\n const [keepThread, { isLoading: isKeeping }] = api.useKeepCommentMutation();\n const designStudioCommentId = Number(root.id);\n\n const sendReply = async () => {\n try {\n await createReply({\n designStudioCommentId,\n body: { text: replyText },\n }).unwrap();\n setReplyText('');\n } catch (error) {\n notify.error(errorMessage(error));\n }\n };\n\n return (\n // biome-ignore lint/a11y/useSemanticElements: an article that highlights its pin on hover / focus, not a control\n <article\n className={cx(\n 'space-y-3 rounded-2xl bg-card p-4 shadow-surface-raised ring-1 ring-foreground/5',\n root.isResolved && 'opacity-70',\n isHighlighted && 'ring-2 ring-brand'\n )}\n onMouseEnter={onHighlight}\n onFocus={onHighlight}\n role=\"group\"\n aria-label={`Comment thread${pinNumber ? ` ${pinNumber}` : ''}`}\n >\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {pinNumber !== null ? (\n <Badge className=\"bg-primary text-primary-foreground\">\n <MapPin aria-hidden /> {pinNumber}\n </Badge>\n ) : (\n <Badge variant=\"outline\">Board</Badge>\n )}\n {rootViewport && (\n <button\n type=\"button\"\n className=\"rounded-full bg-tint px-2 py-0.5 text-xs font-medium text-muted-foreground tabular-nums hover:bg-tint-strong hover:text-foreground disabled:cursor-default\"\n title=\"Pinned in this viewport: show the board in it\"\n disabled={!onSelectViewport}\n onClick={() => onSelectViewport?.(rootViewport)}\n >\n {rootViewport.width} × {rootViewport.height}\n {rootViewport.deviceKey ? ` · ${rootViewport.deviceKey}` : ''}\n </button>\n )}\n {root.isDecision && (\n <Badge variant=\"outline\" className=\"border-transparent bg-success/15 text-success\">\n <Flag aria-hidden /> Decision\n </Badge>\n )}\n {root.isResolved && (\n <Badge variant=\"outline\" className=\"border-transparent bg-tint text-muted-foreground\">\n Resolved{root.resolvedByName ? ` by ${root.resolvedByName}` : ''}\n </Badge>\n )}\n {hasBoardChangedSince && (\n <Badge\n variant=\"outline\"\n className=\"border-transparent bg-warning/15 text-warning\"\n title=\"The board file is another version than the one this thread was written on\"\n >\n <History aria-hidden /> Board changed since\n </Badge>\n )}\n {isExpiring && (\n <Badge\n variant=\"outline\"\n className=\"border-transparent bg-tint text-muted-foreground\"\n title=\"Idle threads are deleted; “Keep” or any reply postpones that\"\n >\n <Hourglass aria-hidden /> Expires soon\n </Badge>\n )}\n </div>\n <CommentLine comment={root} isOwn={authAccountId !== null && root.authorAccountId === authAccountId} writesAllowed={writesAllowed} />\n {replies.map(reply => (\n <div key={String(reply.id)} className=\"border-l-2 border-border pl-3\">\n <CommentLine\n comment={reply}\n isOwn={authAccountId !== null && reply.authorAccountId === authAccountId}\n writesAllowed={writesAllowed}\n />\n </div>\n ))}\n <Textarea\n value={replyText}\n onChange={event => setReplyText(event.target.value)}\n placeholder=\"Reply…\"\n rows={2}\n aria-label=\"Reply\"\n disabled={!writesAllowed}\n />\n <div className=\"flex flex-wrap items-center gap-2\">\n <Button size=\"sm\" variant=\"outline\" disabled={!writesAllowed || !replyText.trim() || isReplying} onClick={sendReply}>\n Reply\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={!writesAllowed || isPatching}\n aria-pressed={Boolean(root.isDecision)}\n onClick={() =>\n patchComment({\n designStudioCommentId,\n body: { isDecision: !root.isDecision },\n })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <Flag /> {root.isDecision ? 'Not a decision' : 'Decision'}\n </Button>\n <Button size=\"sm\" variant=\"outline\" onClick={() => onCopyReference(thread)} aria-label=\"Copy for agent\">\n <ClipboardCopy /> Copy for agent\n </Button>\n {isExpiring && (\n <Button\n size=\"sm\"\n variant=\"outline\"\n disabled={!writesAllowed || isKeeping}\n onClick={() =>\n keepThread({ designStudioCommentId })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n Keep\n </Button>\n )}\n {root.isResolved ? (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"ml-auto\"\n disabled={!writesAllowed || isReopening}\n onClick={() =>\n reopenThread({ designStudioCommentId })\n .unwrap()\n .catch(error => notify.error(errorMessage(error)))\n }\n >\n <RotateCcw /> Reopen\n </Button>\n ) : (\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"ml-auto\"\n disabled={!writesAllowed || isResolving}\n onClick={async () => {\n try {\n await resolveThread({\n designStudioCommentId,\n body: { replyText: replyText.trim() ? replyText : null },\n }).unwrap();\n setReplyText('');\n } catch (error) {\n notify.error(errorMessage(error));\n }\n }}\n >\n <CheckCircle2 /> Resolve\n </Button>\n )}\n </div>\n </article>\n );\n};\n\nexport interface BoardCommentsProps {\n projectKey: string;\n canvasKey: string;\n board: DesignStudioBoardView;\n threads: CommentThread[];\n /** A pin placed on the board in focus view, waiting for its comment. */\n pendingPin: BoardPin | null;\n onClearPendingPin: () => void;\n highlightedCommentId: number | null;\n onHighlightComment: (designStudioCommentId: number | null) => void;\n writesAllowed: boolean;\n /** Show resolved threads too. */\n showResolved: boolean;\n onShowResolvedChange: (showResolved: boolean) => void;\n /** How to pin a comment from where the panel is shown (placeholder of the new-comment field). */\n pinHint: string;\n /** \"Copy for agent\" on a thread. */\n onCopyThreadReference: (thread: CommentThread) => void;\n /** A thread pinned in a viewport (responsive board): shows the board in that viewport. */\n onSelectViewport?: (viewport: DeviceViewport) => void;\n}\n\n/** Comments of one board: new thread (on the board or at a placed pin), threads with replies, resolve, decision. */\nexport const BoardComments = ({\n projectKey,\n canvasKey,\n board,\n threads,\n pendingPin,\n onClearPendingPin,\n highlightedCommentId,\n onHighlightComment,\n writesAllowed,\n showResolved,\n onShowResolvedChange,\n pinHint,\n onCopyThreadReference,\n onSelectViewport,\n}: BoardCommentsProps) => {\n const [text, setText] = useState('');\n const [isDecision, setIsDecision] = useState(false);\n const { api, components, notify, useCurrentAccountId } = useDesignStudio();\n const { Button, Checkbox, Label, Textarea } = components;\n const [createComment, { isLoading }] = api.useCreateCommentMutation();\n const authAccountId = useCurrentAccountId();\n // threads that are deleted soon unless something happens in them (all canvases; one cached request)\n const { data: expiringData } = api.useExpiringCommentsQuery();\n const expiringCommentIds = new Set(\n (expiringData?.designStudioComments.elements ?? []).map(comment => Number(comment.id))\n );\n const visibleThreads = showResolved ? threads : threads.filter(thread => !thread.root.isResolved);\n const resolvedCount = threads.length - threads.filter(thread => !thread.root.isResolved).length;\n\n const addComment = async () => {\n try {\n await createComment({\n projectKey,\n canvasKey,\n boardKey: board.boardKey ?? '',\n body: {\n text,\n x: pendingPin?.x ?? null,\n y: pendingPin?.y ?? null,\n viewportWidth: pendingPin?.viewport?.width ?? null,\n viewportHeight: pendingPin?.viewport?.height ?? null,\n deviceKey: pendingPin?.viewport?.deviceKey ?? null,\n isDecision,\n },\n }).unwrap();\n setText('');\n setIsDecision(false);\n onClearPendingPin();\n } catch (error) {\n notify.error(errorMessage(error));\n }\n };\n\n return (\n <div className=\"space-y-4\">\n <div className=\"space-y-2\">\n <Label htmlFor=\"design-comment-text\" className=\"flex items-center gap-1.5\">\n {pendingPin ? (\n <>\n <MapPin className=\"size-4 text-brand-emphasis\" aria-hidden /> Comment at the placed pin\n </>\n ) : (\n 'New comment on the board'\n )}\n </Label>\n <Textarea\n id=\"design-comment-text\"\n value={text}\n onChange={event => setText(event.target.value)}\n placeholder={pendingPin ? 'What should change here?' : `Comment… (${pinHint})`}\n rows={3}\n disabled={!writesAllowed}\n />\n <div className=\"flex flex-wrap items-center gap-3\">\n <div className=\"flex items-center gap-2\">\n <Checkbox\n id=\"design-comment-decision\"\n checked={isDecision}\n onCheckedChange={checked => setIsDecision(checked === true)}\n disabled={!writesAllowed}\n />\n <Label htmlFor=\"design-comment-decision\" className=\"font-normal\">\n Decision\n </Label>\n </div>\n {pendingPin && (\n <Button size=\"sm\" variant=\"ghost\" onClick={onClearPendingPin}>\n Remove pin\n </Button>\n )}\n <Button size=\"sm\" className=\"ml-auto\" disabled={!writesAllowed || !text.trim() || isLoading || !board.boardKey} onClick={addComment}>\n Comment\n </Button>\n </div>\n </div>\n {resolvedCount > 0 && (\n <div className=\"flex items-center gap-2\">\n <Checkbox\n id=\"design-comment-show-resolved\"\n checked={showResolved}\n onCheckedChange={checked => onShowResolvedChange(checked === true)}\n />\n <Label htmlFor=\"design-comment-show-resolved\" className=\"font-normal text-muted-foreground\">\n Show {resolvedCount} resolved\n </Label>\n </div>\n )}\n {visibleThreads.length === 0 && <p className=\"text-sm text-muted-foreground\">No open comments on this board.</p>}\n {visibleThreads.map(thread => (\n <ThreadCard\n key={String(thread.root.id)}\n thread={thread}\n onCopyReference={onCopyThreadReference}\n onSelectViewport={onSelectViewport}\n isHighlighted={highlightedCommentId === Number(thread.root.id)}\n onHighlight={() => onHighlightComment(Number(thread.root.id))}\n authAccountId={authAccountId}\n writesAllowed={writesAllowed}\n hasBoardChangedSince={\n Boolean(thread.root.contentHash && board.contentHash) && thread.root.contentHash !== board.contentHash\n }\n isExpiring={expiringCommentIds.has(Number(thread.root.id))}\n />\n ))}\n </div>\n );\n};\n","'use client';\n\nimport { RotateCw, Smartphone } from 'lucide-react';\nimport { useRef } from 'react';\n\nimport type { DesignDevice } from '../api/types';\nimport { useDesignStudio } from '../provider/DesignStudioProvider';\nimport { type DeviceViewport, rotateViewport, viewportLabel, viewportOfDevice } from './deviceViewport';\n\n/** Viewport controls of a responsive board (focus view, site view): device picker, rotation, width handle. */\nexport interface ViewportToolbarProps {\n devices: readonly DesignDevice[];\n viewport: DeviceViewport;\n /** Open pins placed in other viewport widths (not shown in this one). */\n hiddenPinCount: number;\n showsDeviceFrame: boolean;\n onShowsDeviceFrameChange: (showsDeviceFrame: boolean) => void;\n onViewportChange: (viewport: DeviceViewport) => void;\n}\n\n/** Device picker (presets), landscape / portrait, the current size and the device frame switch of a responsive board. */\nexport const ViewportToolbar = ({\n devices,\n viewport,\n hiddenPinCount,\n showsDeviceFrame,\n onShowsDeviceFrameChange,\n onViewportChange,\n}: ViewportToolbarProps) => {\n const { components } = useDesignStudio();\n const { Button } = components;\n return (\n <div className=\"flex flex-wrap items-center gap-2 border-b border-border px-5 py-2 text-sm\">\n <label className=\"flex items-center gap-2\">\n <span className=\"sr-only\">Device</span>\n <select\n className=\"h-8 rounded-lg border border-border bg-card px-2 text-sm\"\n value={viewport.deviceKey ?? ''}\n onChange={event => {\n const device = devices.find(candidate => candidate.deviceKey === event.target.value);\n if (device) onViewportChange(viewportOfDevice(device));\n }}\n >\n {viewport.deviceKey === null && <option value=\"\">Free width</option>}\n {devices.map(device => (\n <option key={device.deviceKey ?? ''} value={device.deviceKey ?? ''}>\n {device.label} · {device.width} × {device.height}\n </option>\n ))}\n </select>\n </label>\n <Button\n variant=\"outline\"\n size=\"sm\"\n aria-label=\"Rotate (landscape / portrait)\"\n onClick={() => onViewportChange(rotateViewport(viewport, devices))}\n >\n <RotateCw /> Rotate\n </Button>\n <span className=\"text-muted-foreground tabular-nums\">{viewportLabel(viewport, devices)}</span>\n <Button\n variant={showsDeviceFrame ? 'default' : 'outline'}\n size=\"sm\"\n aria-pressed={showsDeviceFrame}\n onClick={() => onShowsDeviceFrameChange(!showsDeviceFrame)}\n >\n <Smartphone /> Device frame\n </Button>\n {hiddenPinCount > 0 && (\n <span className=\"ml-auto text-xs text-muted-foreground\">\n {hiddenPinCount} open pin(s) in other widths — pick their size in the comment list\n </span>\n )}\n </div>\n );\n};\n\nexport interface WidthDragHandleProps {\n /** Scale the viewport is drawn at (screen pixels per page pixel). */\n scale: number;\n width: number;\n onWidthChange: (width: number) => void;\n}\n\n/** The handle at the right edge of the viewport: dragging it sets a free width (page pixels). */\nexport const WidthDragHandle = ({ scale, width, onWidthChange }: WidthDragHandleProps) => {\n const dragStartRef = useRef<{ clientX: number; width: number } | null>(null);\n return (\n <button\n type=\"button\"\n aria-label={`Viewport width ${width} px: drag to change`}\n className=\"absolute top-1/2 -right-6 z-30 h-24 w-3 -translate-y-1/2 cursor-ew-resize touch-none rounded-full bg-foreground/40 hover:bg-foreground/70\"\n onPointerDown={event => {\n event.currentTarget.setPointerCapture(event.pointerId);\n dragStartRef.current = { clientX: event.clientX, width };\n }}\n onPointerMove={event => {\n const dragStart = dragStartRef.current;\n if (!dragStart) return;\n onWidthChange(dragStart.width + (event.clientX - dragStart.clientX) / Math.max(0.05, scale));\n }}\n onPointerUp={() => {\n dragStartRef.current = null;\n }}\n onKeyDown={event => {\n if (event.key === 'ArrowLeft') onWidthChange(width - 10);\n if (event.key === 'ArrowRight') onWidthChange(width + 10);\n }}\n />\n );\n};\n","'use client';\n\nimport { useEffect, useState } from 'react';\n\n/**\n * Loads a board's delivery URL (HTML) before an iframe shows it. An `<iframe src>` renders whatever the server answers —\n * on a storage error that was the raw error JSON on top of the thumbnail. The URL is fetched first (at most\n * MAX_CONCURRENT_LOADS at once across the canvas, so a zoom does not fire every board at the object storage); only a 2xx\n * answer is handed to the iframe, which then reads it from the browser cache (the endpoint answers `private,\n * immutable`). A failed load leaves the thumbnail in place and is retried with growing delays while the board stays\n * live.\n */\nconst MAX_CONCURRENT_LOADS = 2;\n\n/** Delays (ms) before the next attempt after a failure; the last one repeats. */\nconst RETRY_DELAYS_MS = [2000, 5000, 15000, 30000];\n\n/**\n * URLs already loaded successfully in this page, least recently used first (a remount shows them at once; the browser\n * cache holds the bytes). Bounded: it also decides which boards remount their live HTML outside the live set.\n */\nconst MAX_REMEMBERED_URLS = 24;\nconst loadedUrls = new Set<string>();\n\nconst rememberLoadedUrl = (url: string) => {\n loadedUrls.delete(url);\n loadedUrls.add(url);\n while (loadedUrls.size > MAX_REMEMBERED_URLS) {\n const oldestUrl = loadedUrls.values().next().value;\n if (oldestUrl === undefined) break;\n loadedUrls.delete(oldestUrl);\n }\n};\n\n/** Whether this board HTML URL (content hash + theme in its query) was shown live before in this page. */\nexport const wasContentUrlLoaded = (url: string | undefined): boolean => Boolean(url && loadedUrls.has(url));\n\nlet activeLoads = 0;\nconst waitingLoads: Array<() => void> = [];\n\nconst acquireLoadSlot = (): Promise<void> =>\n new Promise(resolve => {\n if (activeLoads < MAX_CONCURRENT_LOADS) {\n activeLoads += 1;\n resolve();\n return;\n }\n waitingLoads.push(() => {\n activeLoads += 1;\n resolve();\n });\n });\n\nconst releaseLoadSlot = () => {\n activeLoads -= 1;\n waitingLoads.shift()?.();\n};\n\nconst loadUrl = async (url: string, signal: AbortSignal): Promise<boolean> => {\n await acquireLoadSlot();\n try {\n if (signal.aborted) return false;\n const response = await fetch(url, { signal, credentials: 'omit', referrerPolicy: 'no-referrer' });\n if (!response.ok) return false;\n // read the whole body so the browser cache holds the complete answer for the iframe\n await response.blob();\n return true;\n } catch {\n // network error or abort: the caller retries while the board is still live\n return false;\n } finally {\n releaseLoadSlot();\n }\n};\n\n/**\n * @param url the delivery URL, undefined when nothing should load (board not live)\n * @returns the URL once it answered 2xx, else undefined (show the thumbnail)\n */\nexport const useCheckedContentUrl = (url: string | undefined): string | undefined => {\n const [checkedUrl, setCheckedUrl] = useState<string | undefined>(() =>\n url && loadedUrls.has(url) ? url : undefined\n );\n\n useEffect(() => {\n if (!url) {\n setCheckedUrl(undefined);\n return;\n }\n if (loadedUrls.has(url)) {\n rememberLoadedUrl(url);\n setCheckedUrl(url);\n return;\n }\n setCheckedUrl(undefined);\n const abortController = new AbortController();\n let retryTimer: ReturnType<typeof setTimeout> | undefined;\n let attempt = 0;\n const tryLoad = async () => {\n const isLoaded = await loadUrl(url, abortController.signal);\n if (abortController.signal.aborted) return;\n if (isLoaded) {\n rememberLoadedUrl(url);\n setCheckedUrl(url);\n return;\n }\n const delay = RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)];\n attempt += 1;\n retryTimer = setTimeout(tryLoad, delay);\n };\n void tryLoad();\n return () => {\n abortController.abort();\n if (retryTimer) clearTimeout(retryTimer);\n };\n }, [url]);\n\n return checkedUrl;\n};\n\n/**\n * Retries a failed `<img>` (a thumbnail answered with an error): the image is hidden, and after a growing delay it is\n * mounted again under a new key, which requests the URL once more (error answers are not cached).\n * @returns the key for the `<img>`, whether it failed (hide it until the retry) and its `onError` handler\n */\nexport const useImageRetry = (url: string | undefined) => {\n const [attempt, setAttempt] = useState(0);\n const [isFailed, setIsFailed] = useState(false);\n const [previousUrl, setPreviousUrl] = useState(url);\n // a new URL (another theme, a new token window) starts over (state reset during render, no effect needed)\n if (url !== previousUrl) {\n setPreviousUrl(url);\n setAttempt(0);\n setIsFailed(false);\n }\n\n useEffect(() => {\n if (!isFailed) return;\n const retryTimer = setTimeout(\n () => {\n setIsFailed(false);\n setAttempt(previousAttempt => previousAttempt + 1);\n },\n RETRY_DELAYS_MS[Math.min(attempt, RETRY_DELAYS_MS.length - 1)]\n );\n return () => clearTimeout(retryTimer);\n }, [isFailed, attempt]);\n\n return { imageKey: `${url ?? ''}#${attempt}`, isFailed, onError: () => setIsFailed(true) };\n};\n","/**\n * The site view: a canvas as a clickable website. Boards with a `route` are its pages; a link clicked inside a board\n * (reported by the board's navigation script, see the backend's DesignBoardContentService::addSiteNavigationScript;\n * `#anchors` the page scrolls to itself) is resolved here to a page, an external link (not followed) or a missing\n * page. Pure functions, no React\n * (tested in siteNavigation.test.ts).\n */\n\nimport type { DesignStudioBoardView } from '../api/types';\n\n/** Where a clicked link leads. */\nexport type SiteLinkTarget =\n | { kind: 'page'; board: DesignStudioBoardView; route: string; hash: string | null }\n | { kind: 'anchor'; hash: string }\n | { kind: 'external'; href: string }\n | { kind: 'missing'; path: string };\n\n/** A message of the board's navigation script. */\nexport type SiteFrameMessage =\n | { type: 'navigate'; href: string }\n | { type: 'scroll'; top: number }\n | { type: 'height'; height: number };\n\n/** `/pricing/` → `/pricing`, `pricing` → `/pricing`, `` → `/`; null when it is no plain path. */\nexport const normalizeSitePath = (path: string): string | null => {\n const trimmed = path.trim();\n if (/[?#]/.test(trimmed) || trimmed.includes('..') || trimmed.includes('//')) return null;\n const segments = trimmed.split('/').filter(segment => segment !== '' && segment !== '.');\n return `/${segments.join('/')}`;\n};\n\n/** The pages of a canvas: route → board (boards without a route are no page). */\nexport const sitePagesOf = (boards: readonly DesignStudioBoardView[]): Map<string, DesignStudioBoardView> => {\n const pages = new Map<string, DesignStudioBoardView>();\n for (const board of boards) {\n if (board.route && !pages.has(board.route)) pages.set(board.route, board);\n }\n return pages;\n};\n\n/** The route a site view opens at: the given one when it is a page, else `/`, else the first page. */\nexport const startRouteOf = (pages: ReadonlyMap<string, DesignStudioBoardView>, route: string | null): string | null => {\n const normalized = route !== null ? normalizeSitePath(route) : null;\n if (normalized !== null && pages.has(normalized)) return normalized;\n if (pages.has('/')) return '/';\n return pages.keys().next().value ?? null;\n};\n\n/**\n * Resolves the `href` of a clicked link: `#x` an anchor on the page, `board:<file>` the board with that file name\n * (its route, else no page), `/path` or a relative `path` (relative to the current page's folder) a page by its route,\n * anything with a scheme or `//` external.\n */\nexport const resolveSiteHref = (\n href: string,\n currentRoute: string,\n boards: readonly DesignStudioBoardView[]\n): SiteLinkTarget => {\n const trimmed = href.trim();\n if (trimmed === '' || trimmed.startsWith('#')) return { kind: 'anchor', hash: trimmed };\n if (trimmed.startsWith('board:')) {\n const boardKey = trimmed.slice('board:'.length).split('#')[0];\n const board = boards.find(candidate => candidate.boardKey === boardKey);\n return board?.route\n ? { kind: 'page', board, route: board.route, hash: null }\n : { kind: 'missing', path: trimmed };\n }\n if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed) || trimmed.startsWith('//')) return { kind: 'external', href: trimmed };\n const hashIndex = trimmed.indexOf('#');\n const hash = hashIndex >= 0 ? trimmed.slice(hashIndex) : null;\n const pathWithQuery = hashIndex >= 0 ? trimmed.slice(0, hashIndex) : trimmed;\n const path = pathWithQuery.split('?')[0];\n const absolutePath = path.startsWith('/')\n ? path\n : `${currentRoute.endsWith('/') ? currentRoute : currentRoute.slice(0, currentRoute.lastIndexOf('/') + 1)}${path}`;\n const route = normalizeSitePath(absolutePath);\n const board = route !== null ? sitePagesOf(boards).get(route) : undefined;\n return board && route !== null ? { kind: 'page', board, route, hash } : { kind: 'missing', path: route ?? path };\n};\n\n/** The message of the board's navigation script, null for anything else. */\nexport const parseSiteFrameMessage = (data: unknown): SiteFrameMessage | null => {\n if (typeof data !== 'object' || data === null) return null;\n const message = data as Record<string, unknown>;\n if (message.source !== 'design-studio-site') return null;\n if (message.type === 'navigate' && typeof message.href === 'string') return { type: 'navigate', href: message.href };\n if (message.type === 'scroll' && typeof message.top === 'number' && Number.isFinite(message.top)) {\n return { type: 'scroll', top: Math.max(0, Math.round(message.top)) };\n }\n if (message.type === 'height' && typeof message.height === 'number' && Number.isFinite(message.height)) {\n return { type: 'height', height: Math.max(1, Math.min(100_000, Math.round(message.height))) };\n }\n return null;\n};\n"],"mappings":";;;AASO,IAAM,YAAY;AAGlB,IAAM,qBAAqB;AAG3B,IAAM,yBAAyB;AAC/B,IAAM,yBAAyB;AAG/B,IAAM,yBAAyB;AAY/B,IAAM,oBAAoB,CAAC,UAChC,QAAQ,OAAO,iBAAiB,MAAM,QAAQ,UAAU,UAAU,KAAK,CAAC;AAEnE,IAAM,WAAW,CAAC,UACvB,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K,IAAI,GAAG,KAAK,IAAI,KAAS,KAAK,MAAM,QAAQ,MAAM,CAAC,CAAC,EAAE;AAAA,EAC9F;AACA,SAAO;AACT;","names":["jsx","jsx","jsxs","useState","board"]}
package/dist/index.js CHANGED
@@ -20,9 +20,13 @@ import {
20
20
  isPinInViewport,
21
21
  isResponsiveBoard,
22
22
  normalizeBoardCode,
23
+ parseSiteFrameMessage,
23
24
  resolveDesignStudioTexts,
25
+ resolveSiteHref,
26
+ sitePagesOf,
24
27
  siteViewportForBoard,
25
28
  splitThemeReference,
29
+ startRouteOf,
26
30
  useCheckedContentUrl,
27
31
  useDesignStudio,
28
32
  useDesignStudioApi,
@@ -32,7 +36,7 @@ import {
32
36
  useDesignStudioRouter,
33
37
  useDesignStudioTexts,
34
38
  viewportWithWidth
35
- } from "./chunk-FXDTHFHX.js";
39
+ } from "./chunk-GPHJ2WQ3.js";
36
40
 
37
41
  // src/api/createDesignStudioApi.ts
38
42
  var DESIGN_STUDIO_TAG = "DesignStudio";
@@ -449,60 +453,6 @@ var DesignStudioReviewsScreen = ({
449
453
  import { normalizeDddError as normalizeDddError3 } from "@mgamadeus/ddd-web/api";
450
454
  import { ArrowLeft, MapPin, MapPinPlus, MessageSquare as MessageSquare2, X } from "lucide-react";
451
455
  import { useCallback, useEffect as useEffect2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
452
-
453
- // src/site/siteNavigation.ts
454
- var normalizeSitePath = (path) => {
455
- const trimmed = path.trim();
456
- if (/[?#]/.test(trimmed) || trimmed.includes("..") || trimmed.includes("//")) return null;
457
- const segments = trimmed.split("/").filter((segment) => segment !== "" && segment !== ".");
458
- return `/${segments.join("/")}`;
459
- };
460
- var sitePagesOf = (boards) => {
461
- const pages = /* @__PURE__ */ new Map();
462
- for (const board of boards) {
463
- if (board.route && !pages.has(board.route)) pages.set(board.route, board);
464
- }
465
- return pages;
466
- };
467
- var startRouteOf = (pages, route) => {
468
- const normalized = route !== null ? normalizeSitePath(route) : null;
469
- if (normalized !== null && pages.has(normalized)) return normalized;
470
- if (pages.has("/")) return "/";
471
- return pages.keys().next().value ?? null;
472
- };
473
- var resolveSiteHref = (href, currentRoute, boards) => {
474
- const trimmed = href.trim();
475
- if (trimmed === "" || trimmed.startsWith("#")) return { kind: "anchor", hash: trimmed };
476
- if (trimmed.startsWith("board:")) {
477
- const boardKey = trimmed.slice("board:".length).split("#")[0];
478
- const board2 = boards.find((candidate) => candidate.boardKey === boardKey);
479
- return board2?.route ? { kind: "page", board: board2, route: board2.route, hash: null } : { kind: "missing", path: trimmed };
480
- }
481
- if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed) || trimmed.startsWith("//")) return { kind: "external", href: trimmed };
482
- const hashIndex = trimmed.indexOf("#");
483
- const hash = hashIndex >= 0 ? trimmed.slice(hashIndex) : null;
484
- const pathWithQuery = hashIndex >= 0 ? trimmed.slice(0, hashIndex) : trimmed;
485
- const path = pathWithQuery.split("?")[0];
486
- const absolutePath = path.startsWith("/") ? path : `${currentRoute.endsWith("/") ? currentRoute : currentRoute.slice(0, currentRoute.lastIndexOf("/") + 1)}${path}`;
487
- const route = normalizeSitePath(absolutePath);
488
- const board = route !== null ? sitePagesOf(boards).get(route) : void 0;
489
- return board && route !== null ? { kind: "page", board, route, hash } : { kind: "missing", path: route ?? path };
490
- };
491
- var parseSiteFrameMessage = (data) => {
492
- if (typeof data !== "object" || data === null) return null;
493
- const message = data;
494
- if (message.source !== "design-studio-site") return null;
495
- if (message.type === "navigate" && typeof message.href === "string") return { type: "navigate", href: message.href };
496
- if (message.type === "scroll" && typeof message.top === "number" && Number.isFinite(message.top)) {
497
- return { type: "scroll", top: Math.max(0, Math.round(message.top)) };
498
- }
499
- if (message.type === "height" && typeof message.height === "number" && Number.isFinite(message.height)) {
500
- return { type: "height", height: Math.max(1, Math.min(1e5, Math.round(message.height))) };
501
- }
502
- return null;
503
- };
504
-
505
- // src/screens/DesignStudioSiteScreen.tsx
506
456
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
507
457
  var DesignStudioSiteScreen = ({ projectKey, canvasKey, route }) => {
508
458
  const { api, apiBaseUrl, components, notify, paths, router, useCanWrite } = useDesignStudio();