@mgamadeus/ddd-design-studio 0.3.1 → 0.4.0
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/canvas/index.js +534 -161
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-ICDABLFY.js → chunk-YYKTDLFF.js} +80 -2
- package/dist/chunk-YYKTDLFF.js.map +1 -0
- package/dist/index.d.ts +78 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-ICDABLFY.js.map +0 -1
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
// src/canvas/deviceViewport.ts
|
|
4
|
+
var FRAME_GAP = 48;
|
|
5
|
+
var FRAME_LABEL_HEIGHT = 40;
|
|
6
|
+
var MINIMUM_VIEWPORT_WIDTH = 240;
|
|
7
|
+
var MAXIMUM_VIEWPORT_WIDTH = 3840;
|
|
8
|
+
var MAX_PAGE_CANVAS_HEIGHT = 8e3;
|
|
9
|
+
var isResponsiveBoard = (board) => Boolean(board?.isResponsive && (board.frames?.elements?.length ?? 0) > 0);
|
|
10
|
+
var framesOf = (board) => board?.frames?.elements ?? [];
|
|
11
|
+
var viewportOfDevice = (device) => ({
|
|
12
|
+
width: device.width ?? 0,
|
|
13
|
+
height: device.height ?? 0,
|
|
14
|
+
deviceKey: device.deviceKey ?? null
|
|
15
|
+
});
|
|
16
|
+
var initialViewportForBoard = (board, current) => {
|
|
17
|
+
if (!isResponsiveBoard(board)) return null;
|
|
18
|
+
if (current) return current;
|
|
19
|
+
const firstFrame = framesOf(board)[0];
|
|
20
|
+
return { width: firstFrame.width ?? 0, height: firstFrame.height ?? 0, deviceKey: firstFrame.deviceKey ?? null };
|
|
21
|
+
};
|
|
22
|
+
var rotateViewport = (viewport, devices) => {
|
|
23
|
+
const rotated = { width: viewport.height, height: viewport.width };
|
|
24
|
+
const matchingDevice = devices.find((device) => device.width === rotated.width && device.height === rotated.height);
|
|
25
|
+
return { ...rotated, deviceKey: matchingDevice?.deviceKey ?? null };
|
|
26
|
+
};
|
|
27
|
+
var viewportWithWidth = (viewport, width) => ({
|
|
28
|
+
width: Math.round(Math.max(MINIMUM_VIEWPORT_WIDTH, Math.min(MAXIMUM_VIEWPORT_WIDTH, width))),
|
|
29
|
+
height: viewport.height,
|
|
30
|
+
deviceKey: null
|
|
31
|
+
});
|
|
32
|
+
var viewportLabel = (viewport, devices) => {
|
|
33
|
+
const device = viewport.deviceKey ? devices.find((candidate) => candidate.deviceKey === viewport.deviceKey) : void 0;
|
|
34
|
+
return `${device?.label ?? (viewport.deviceKey ?? "Free width")} \xB7 ${viewport.width} \xD7 ${viewport.height}`;
|
|
35
|
+
};
|
|
36
|
+
var pageHeightAtWidth = (board, width, viewportHeight) => {
|
|
37
|
+
const frames = framesOf(board).filter((frame) => (frame.pageHeight ?? 0) > 0 && (frame.width ?? 0) > 0);
|
|
38
|
+
const exactFrame = frames.find((frame) => frame.width === width);
|
|
39
|
+
if (exactFrame) return Math.max(viewportHeight, exactFrame.pageHeight ?? 0);
|
|
40
|
+
if (frames.length === 0) return viewportHeight * 3;
|
|
41
|
+
const nearestFrame = frames.reduce(
|
|
42
|
+
(nearest, frame) => Math.abs((frame.width ?? 0) - width) < Math.abs((nearest.width ?? 0) - width) ? frame : nearest
|
|
43
|
+
);
|
|
44
|
+
return Math.max(viewportHeight, Math.round((nearestFrame.pageHeight ?? 0) * (nearestFrame.width ?? 1) / Math.max(1, width)));
|
|
45
|
+
};
|
|
46
|
+
var frameCanvasHeight = (frame, mode) => {
|
|
47
|
+
const viewportHeight = frame.height ?? 0;
|
|
48
|
+
if (mode === "viewport") return viewportHeight;
|
|
49
|
+
return Math.min(MAX_PAGE_CANVAS_HEIGHT, Math.max(viewportHeight, frame.pageHeight ?? viewportHeight));
|
|
50
|
+
};
|
|
51
|
+
var boardCanvasSize = (board, mode) => {
|
|
52
|
+
if (!isResponsiveBoard(board)) return { width: board.width ?? 390, height: board.height ?? 844 };
|
|
53
|
+
const frames = framesOf(board);
|
|
54
|
+
const width = frames.reduce((sum, frame) => sum + (frame.width ?? 0), 0) + FRAME_GAP * (frames.length - 1);
|
|
55
|
+
const height = FRAME_LABEL_HEIGHT + Math.max(...frames.map((frame) => frameCanvasHeight(frame, mode)));
|
|
56
|
+
return { width, height };
|
|
57
|
+
};
|
|
58
|
+
var viewportOfComment = (comment) => comment.viewportWidth ? { width: comment.viewportWidth, height: comment.viewportHeight ?? comment.viewportWidth, deviceKey: comment.deviceKey ?? null } : null;
|
|
59
|
+
var isPinInViewport = (comment, viewport) => {
|
|
60
|
+
const commentViewport = viewportOfComment(comment);
|
|
61
|
+
if (!viewport) return commentViewport === null;
|
|
62
|
+
return commentViewport !== null && commentViewport.width === viewport.width;
|
|
63
|
+
};
|
|
64
|
+
var viewportReferenceText = (viewport) => `${viewport.width}x${viewport.height}${viewport.deviceKey ? ` ${viewport.deviceKey}` : ""}`;
|
|
65
|
+
|
|
3
66
|
// src/canvas/designReference.ts
|
|
4
67
|
var DESIGN_REFERENCE_PREFIX = "[design-ref]";
|
|
5
68
|
var oneLine = (text) => text.replace(/\s+/g, " ").trim();
|
|
@@ -10,7 +73,8 @@ var buildDesignReference = (input) => {
|
|
|
10
73
|
`file ${input.boardKey}`,
|
|
11
74
|
`canvas ${input.projectKey}/${input.canvasKey}`,
|
|
12
75
|
`v${input.contentHash ? input.contentHash.slice(0, 7) : "?"}`,
|
|
13
|
-
`theme ${input.themeReference || "none"}
|
|
76
|
+
`theme ${input.themeReference || "none"}`,
|
|
77
|
+
...input.viewport ? [`viewport ${viewportReferenceText(input.viewport)}`] : []
|
|
14
78
|
];
|
|
15
79
|
if (input.region) {
|
|
16
80
|
const { x, y, width, height } = input.region;
|
|
@@ -168,6 +232,20 @@ import { twMerge } from "tailwind-merge";
|
|
|
168
232
|
var cx = (...inputs) => twMerge(clsx(inputs));
|
|
169
233
|
|
|
170
234
|
export {
|
|
235
|
+
FRAME_GAP,
|
|
236
|
+
FRAME_LABEL_HEIGHT,
|
|
237
|
+
isResponsiveBoard,
|
|
238
|
+
framesOf,
|
|
239
|
+
viewportOfDevice,
|
|
240
|
+
initialViewportForBoard,
|
|
241
|
+
rotateViewport,
|
|
242
|
+
viewportWithWidth,
|
|
243
|
+
viewportLabel,
|
|
244
|
+
pageHeightAtWidth,
|
|
245
|
+
frameCanvasHeight,
|
|
246
|
+
boardCanvasSize,
|
|
247
|
+
viewportOfComment,
|
|
248
|
+
isPinInViewport,
|
|
171
249
|
DESIGN_REFERENCE_PREFIX,
|
|
172
250
|
buildDesignReference,
|
|
173
251
|
buildBoardDeepLink,
|
|
@@ -194,4 +272,4 @@ export {
|
|
|
194
272
|
useDesignStudioTexts,
|
|
195
273
|
cx
|
|
196
274
|
};
|
|
197
|
-
//# sourceMappingURL=chunk-
|
|
275
|
+
//# sourceMappingURL=chunk-YYKTDLFF.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"],"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/** 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 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"],"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,UA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KAAK,MAAM,CAAC;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,12 @@ interface DesignStudioComment {
|
|
|
33
33
|
x?: number | null;
|
|
34
34
|
/** Pin position from the board's top edge in board pixels */
|
|
35
35
|
y?: number | null;
|
|
36
|
+
/** Viewport width the pin was placed in (a responsive board: x / y are page positions at this width); null = a fixed board */
|
|
37
|
+
viewportWidth?: number | null;
|
|
38
|
+
/** Viewport height the pin was placed in */
|
|
39
|
+
viewportHeight?: number | null;
|
|
40
|
+
/** Device preset the pin was placed in; null = a free width or a fixed board */
|
|
41
|
+
deviceKey?: string | null;
|
|
36
42
|
/** The comment */
|
|
37
43
|
text: string | null;
|
|
38
44
|
/** Id of the account that wrote it; no relation, the account may be gone */
|
|
@@ -133,6 +139,49 @@ interface DesignStudioBoardView {
|
|
|
133
139
|
thumbnailUrl?: string | null;
|
|
134
140
|
/** URL of the reduced thumbnail for far zoom levels, null when there is none (yet) */
|
|
135
141
|
thumbnailSmallUrl?: string | null;
|
|
142
|
+
/** The layout adapts to the viewport width: the board is shown in device frames */
|
|
143
|
+
isResponsive?: boolean;
|
|
144
|
+
/** Device frames of a responsive board, side by side (width / height of the board = their extent); null for a fixed board */
|
|
145
|
+
frames?: DesignStudioBoardFrameViews | null;
|
|
146
|
+
/** Path of the board's page in the site view (`/`, `/pricing`), null = no page */
|
|
147
|
+
route?: string | null;
|
|
148
|
+
objectType?: string | null;
|
|
149
|
+
}
|
|
150
|
+
/** One device frame of a responsive board. */
|
|
151
|
+
interface DesignStudioBoardFrameView {
|
|
152
|
+
/** Key of the device */
|
|
153
|
+
deviceKey?: string | null;
|
|
154
|
+
/** Viewport width in CSS pixels */
|
|
155
|
+
width?: number;
|
|
156
|
+
/** Viewport height in CSS pixels (frame height in viewport mode) */
|
|
157
|
+
height?: number;
|
|
158
|
+
/** Height of the whole page at this width as rendered; null until the frame has a thumbnail */
|
|
159
|
+
pageHeight?: number | null;
|
|
160
|
+
/** Thumbnail of the whole page at this width, null until rendered */
|
|
161
|
+
thumbnailUrl?: string | null;
|
|
162
|
+
/** Reduced thumbnail, null until rendered */
|
|
163
|
+
thumbnailSmallUrl?: string | null;
|
|
164
|
+
objectType?: string | null;
|
|
165
|
+
}
|
|
166
|
+
interface DesignStudioBoardFrameViews {
|
|
167
|
+
elements?: DesignStudioBoardFrameView[];
|
|
168
|
+
objectType?: string | null;
|
|
169
|
+
}
|
|
170
|
+
/** A device preset responsive boards are shown in. */
|
|
171
|
+
interface DesignDevice {
|
|
172
|
+
/** Key of the preset, e.g. `iphone-16` */
|
|
173
|
+
deviceKey?: string | null;
|
|
174
|
+
/** Name shown in the picker */
|
|
175
|
+
label?: string | null;
|
|
176
|
+
/** Viewport width in CSS pixels */
|
|
177
|
+
width?: number;
|
|
178
|
+
/** Viewport height in CSS pixels */
|
|
179
|
+
height?: number;
|
|
180
|
+
kind?: ('DESKTOP' | 'TABLET' | 'PHONE') | null;
|
|
181
|
+
objectType?: string | null;
|
|
182
|
+
}
|
|
183
|
+
interface DesignDevices {
|
|
184
|
+
elements?: DesignDevice[];
|
|
136
185
|
objectType?: string | null;
|
|
137
186
|
}
|
|
138
187
|
interface DesignStudioBoardViews {
|
|
@@ -167,6 +216,8 @@ interface DesignStudioCanvasView {
|
|
|
167
216
|
renderRequestStatus?: string | null;
|
|
168
217
|
/** Last renderer problem of that request */
|
|
169
218
|
renderRequestError?: string | null;
|
|
219
|
+
/** Device presets responsive boards can be shown in */
|
|
220
|
+
devices?: DesignDevices;
|
|
170
221
|
objectType?: string | null;
|
|
171
222
|
}
|
|
172
223
|
interface DesignStudioCanvasSummary {
|
|
@@ -303,6 +354,12 @@ interface DesignStudioCommentCreateArg extends DesignStudioBoardArg {
|
|
|
303
354
|
x?: number | null;
|
|
304
355
|
/** Pin position from the top edge in board pixels */
|
|
305
356
|
y?: number | null;
|
|
357
|
+
/** Viewport width the pin was placed in (a responsive board); omitted = board pixels */
|
|
358
|
+
viewportWidth?: number | null;
|
|
359
|
+
/** Viewport height the pin was placed in */
|
|
360
|
+
viewportHeight?: number | null;
|
|
361
|
+
/** Device preset the pin was placed in; omitted = a free width */
|
|
362
|
+
deviceKey?: string | null;
|
|
306
363
|
/** Marks the comment as a decision */
|
|
307
364
|
isDecision?: boolean | null;
|
|
308
365
|
};
|
|
@@ -373,6 +430,19 @@ interface DesignStudioApi {
|
|
|
373
430
|
*/
|
|
374
431
|
declare const createDesignStudioApi: <ReducerPath extends string, TagTypes extends string>({ baseApi, apiPrefix, }: CreateDesignStudioApiOptions<ReducerPath, TagTypes>) => DesignStudioApi;
|
|
375
432
|
|
|
433
|
+
/**
|
|
434
|
+
* Responsive boards: the viewport a board is shown in (a device preset, rotated, or a free width), the size of a
|
|
435
|
+
* responsive board on the canvas (its device frames side by side) and which comments belong to a viewport. Pure
|
|
436
|
+
* functions, no React (tested in deviceViewport.test.ts).
|
|
437
|
+
*/
|
|
438
|
+
|
|
439
|
+
/** The viewport a responsive board is shown in. `deviceKey` null = a free width (or a rotation without a preset). */
|
|
440
|
+
interface DeviceViewport {
|
|
441
|
+
width: number;
|
|
442
|
+
height: number;
|
|
443
|
+
deviceKey: string | null;
|
|
444
|
+
}
|
|
445
|
+
|
|
376
446
|
/**
|
|
377
447
|
* Design references for agentic editing ("send to agent"): a plain-text block that names one
|
|
378
448
|
* board (and optionally a region of it, a comment, a note) with stable keys, so an agent session can resolve it.
|
|
@@ -380,15 +450,18 @@ declare const createDesignStudioApi: <ReducerPath extends string, TagTypes exten
|
|
|
380
450
|
* extra lines below):
|
|
381
451
|
*
|
|
382
452
|
* [design-ref] App › Onboarding – first run › 2 Welcome · code APP ONB-W2 · file onb-w-2-welcome.dc.html · canvas app/onboarding
|
|
383
|
-
* · v3f9c2ab · theme brand:1:dark · region 24,180,342,220
|
|
453
|
+
* · v3f9c2ab · theme brand:1:dark · viewport 393x852 iphone-16 · region 24,180,342,220
|
|
384
454
|
* · https://…/app/canvases/onboarding?board=onb-w-2-welcome.dc.html&theme=brand:1&mode=dark
|
|
385
455
|
* note: make the tab bar more compact
|
|
386
456
|
*
|
|
387
457
|
* `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
|
|
388
|
-
* content hash (git blob hash), `theme` the theme reference the board was looked at in (`none` = as authored)
|
|
458
|
+
* content hash (git blob hash), `theme` the theme reference the board was looked at in (`none` = as authored),
|
|
459
|
+
* `viewport` (responsive boards only) the viewport width × height and device preset the board was looked at in — a
|
|
460
|
+
* region or a comment position is a position in the page at that width.
|
|
389
461
|
*
|
|
390
462
|
* Pure functions, no React (tested in designReference.test.ts).
|
|
391
463
|
*/
|
|
464
|
+
|
|
392
465
|
declare const DESIGN_REFERENCE_PREFIX = "[design-ref]";
|
|
393
466
|
/** A rectangle on a board in board pixels (independent of the zoom). */
|
|
394
467
|
interface BoardRegion {
|
|
@@ -413,6 +486,8 @@ interface DesignReferenceInput {
|
|
|
413
486
|
themeReference: string | null;
|
|
414
487
|
/** Deep link to the board on the canvas (with theme and mode). */
|
|
415
488
|
url: string;
|
|
489
|
+
/** The viewport a responsive board is looked at in (region / comment positions are page positions at its width). */
|
|
490
|
+
viewport?: DeviceViewport | null;
|
|
416
491
|
region?: BoardRegion | null;
|
|
417
492
|
/** A comment thread the reference is about (id + pin position). */
|
|
418
493
|
comment?: {
|
|
@@ -863,4 +938,4 @@ declare const DesignStudioReviewsScreen: ({ description, emptyDescription, }: De
|
|
|
863
938
|
declare const cx: (...inputs: ClassValue[]) => string;
|
|
864
939
|
|
|
865
940
|
export { CODE_PARAM, DEFAULT_DESIGN_STUDIO_TEXTS, DESIGN_REFERENCE_PREFIX, DESIGN_STUDIO_TAG, DesignStudioOverviewScreen, DesignStudioProjectScreen, DesignStudioProvider, DesignStudioReviewsScreen, boardCodeMatches, boardCodeUrlValue, buildBoardCodeLink, buildBoardDeepLink, buildDesignReference, buildThemeReference, codeBelongsToCanvas, createDesignStudioApi, cx, findBoardForCode, normalizeBoardCode, resolveDesignStudioTexts, splitThemeReference, useDesignStudio, useDesignStudioApi, useDesignStudioComponents, useDesignStudioNotify, useDesignStudioPaths, useDesignStudioRouter, useDesignStudioTexts };
|
|
866
|
-
export type { BoardRegion, CreateDesignStudioApiOptions, DesignDirectorySection, DesignDirectorySections, DesignReferenceInput, DesignStudioApi, DesignStudioBadgeProps, DesignStudioBaseApi, DesignStudioBaseQuery, DesignStudioBoardArg, DesignStudioBoardStatus, DesignStudioBoardStatusPatchArg, DesignStudioBoardStatusResponse, DesignStudioBoardView, DesignStudioBoardViews, DesignStudioButtonProps, DesignStudioCanvasArg, DesignStudioCanvasCommentsArg, DesignStudioCanvasResponse, DesignStudioCanvasRevisionResponse, DesignStudioCanvasSummaries, DesignStudioCanvasSummary, DesignStudioCanvasView, DesignStudioChangeHistory, DesignStudioCheckboxProps, DesignStudioComboboxProps, DesignStudioComment, DesignStudioCommentArg, DesignStudioCommentCreateArg, DesignStudioCommentPatchArg, DesignStudioCommentReplyArg, DesignStudioCommentResolveArg, DesignStudioCommentResponse, DesignStudioComments, DesignStudioCommentsResponse, DesignStudioComponents, DesignStudioDeleteResponse, DesignStudioDialogContentProps, DesignStudioDialogProps, DesignStudioEnvironment, DesignStudioLinkProps, DesignStudioNotify, DesignStudioOption, DesignStudioOverview, DesignStudioOverviewResponse, DesignStudioOverviewScreenProps, DesignStudioPageHeaderProps, DesignStudioPaths, DesignStudioProjectScreenProps, DesignStudioProjectSummaries, DesignStudioProjectSummary, DesignStudioProviderProps, DesignStudioQuickFilterPillsProps, DesignStudioReviewsScreenProps, DesignStudioRouter, DesignStudioSearchFieldProps, DesignStudioSearchParamUpdates, DesignStudioSharedParams, DesignStudioShell, DesignStudioStatusBadgeProps, DesignStudioStatusCalloutProps, DesignStudioStatusDefinition, DesignStudioStatusTone, DesignStudioStatuses, DesignStudioStorage, DesignStudioStorageKey, DesignStudioTexts, DesignStudioThemesArg, DesignStudioThemesResponse, DesignStudioThumbnailRenderRequestArg, DesignStudioToastOptions, DesignStudioUrlState, DesignStudioUrlStateOptions, DesignTheme, DesignThemes, ThemeLook, ThemeMode };
|
|
941
|
+
export type { BoardRegion, CreateDesignStudioApiOptions, DesignDevice, DesignDevices, DesignDirectorySection, DesignDirectorySections, DesignReferenceInput, DesignStudioApi, DesignStudioBadgeProps, DesignStudioBaseApi, DesignStudioBaseQuery, DesignStudioBoardArg, DesignStudioBoardFrameView, DesignStudioBoardFrameViews, DesignStudioBoardStatus, DesignStudioBoardStatusPatchArg, DesignStudioBoardStatusResponse, DesignStudioBoardView, DesignStudioBoardViews, DesignStudioButtonProps, DesignStudioCanvasArg, DesignStudioCanvasCommentsArg, DesignStudioCanvasResponse, DesignStudioCanvasRevisionResponse, DesignStudioCanvasSummaries, DesignStudioCanvasSummary, DesignStudioCanvasView, DesignStudioChangeHistory, DesignStudioCheckboxProps, DesignStudioComboboxProps, DesignStudioComment, DesignStudioCommentArg, DesignStudioCommentCreateArg, DesignStudioCommentPatchArg, DesignStudioCommentReplyArg, DesignStudioCommentResolveArg, DesignStudioCommentResponse, DesignStudioComments, DesignStudioCommentsResponse, DesignStudioComponents, DesignStudioDeleteResponse, DesignStudioDialogContentProps, DesignStudioDialogProps, DesignStudioEnvironment, DesignStudioLinkProps, DesignStudioNotify, DesignStudioOption, DesignStudioOverview, DesignStudioOverviewResponse, DesignStudioOverviewScreenProps, DesignStudioPageHeaderProps, DesignStudioPaths, DesignStudioProjectScreenProps, DesignStudioProjectSummaries, DesignStudioProjectSummary, DesignStudioProviderProps, DesignStudioQuickFilterPillsProps, DesignStudioReviewsScreenProps, DesignStudioRouter, DesignStudioSearchFieldProps, DesignStudioSearchParamUpdates, DesignStudioSharedParams, DesignStudioShell, DesignStudioStatusBadgeProps, DesignStudioStatusCalloutProps, DesignStudioStatusDefinition, DesignStudioStatusTone, DesignStudioStatuses, DesignStudioStorage, DesignStudioStorageKey, DesignStudioTexts, DesignStudioThemesArg, DesignStudioThemesResponse, DesignStudioThumbnailRenderRequestArg, DesignStudioToastOptions, DesignStudioUrlState, DesignStudioUrlStateOptions, DesignTheme, DesignThemes, ThemeLook, ThemeMode };
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mgamadeus/ddd-design-studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "React frontend of the design review studio for backends built with mgamadeus/ddd (Composer package mgamadeus/ddd-design-studio): project overview, a canvas of HTML design boards with live sandboxed previews and thumbnails, comment threads with pins, review statuses and plain-text design references for agents.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ddd",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../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"],"sourcesContent":["/**\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 · 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 *\n * Pure functions, no React (tested in designReference.test.ts).\n */\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 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 ];\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 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"],"mappings":";;;AAiBO,IAAM,0BAA0B;AAiCvC,IAAM,UAAU,CAAC,SAAiB,KAAK,QAAQ,QAAQ,GAAG,EAAE,KAAK;AAG1D,IAAM,uBAAuB,CAAC,UAAwC;AAC3E,QAAM,SAAS;AAAA,IACb,GAAG,uBAAuB,IAAI,QAAQ,MAAM,WAAW,CAAC,WAAM,QAAQ,MAAM,UAAU,CAAC,WAAM,QAAQ,MAAM,UAAU,CAAC;AAAA,IACtH,GAAI,MAAM,YAAY,CAAC,QAAQ,QAAQ,MAAM,SAAS,CAAC,EAAE,IAAI,CAAC;AAAA,IAC9D,QAAQ,MAAM,QAAQ;AAAA,IACtB,UAAU,MAAM,UAAU,IAAI,MAAM,SAAS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