@hussmartinez/image-sdk 0.1.0 → 0.2.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/README.md +6 -3
- package/dist/assets/image/render.worker.js +1 -1
- package/dist/element.d.ts +25 -0
- package/dist/element.js +2 -2
- package/dist/index.d.ts +25 -0
- package/dist/index.js +1 -1
- package/dist/lazy/{inline-worker-BVCwAPZU.js → inline-worker-Cvw0Gpxf.js} +2 -2
- package/dist/lazy/{inline-worker-BVCwAPZU.js.map → inline-worker-Cvw0Gpxf.js.map} +1 -1
- package/dist/react.d.ts +78 -0
- package/dist/react.js +1 -1
- package/dist/shared/{core-cKo2m54U.js → core-CAX3GOaj.js} +27 -3
- package/dist/shared/{core-cKo2m54U.js.map → core-CAX3GOaj.js.map} +1 -1
- package/dist/shared/{editor-Dv5EU2YJ.js → editor-DziYqEP3.js} +189 -58
- package/dist/shared/editor-DziYqEP3.js.map +1 -0
- package/dist/styles.css +90 -3
- package/package.json +8 -7
- package/dist/shared/editor-Dv5EU2YJ.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editor-Dv5EU2YJ.js","names":["_Fragment","_Fragment"],"sources":["../../src/features/tool-types.ts","../../src/features/crop/crop-tools.ts","../../src/features/export/export-tool.ts","../../src/features/history/history-tools.ts","../../src/features/open/open-tool.ts","../../src/features/orientation/orientation-tools.ts","../../src/features/zoom/zoom-tools.ts","../../src/features/tools.ts","../../src/react/context.ts","../../src/react/hooks.ts","../../src/react/crop/use-crop.ts","../../src/react/crop/CropPanel.tsx","../../src/react/export/export-listener.ts","../../src/react/export/ExportDialog.tsx","../../src/features/editor-state.ts","../../src/react/view-store.ts","../../src/react/ImageEditorProvider.tsx","../../src/react/gesture.ts","../../src/react/panels/use-slider-gesture.ts","../../src/react/panels/AdjustPanel.tsx","../../src/react/panels/FilterPanel.tsx","../../src/react/panels/Inspector.tsx","../../src/react/crop/CropFrame.tsx","../../src/react/stage/ImageStage.tsx","../../src/react/toolbar/ImageToolbar.tsx","../../src/react/toolbar/icons.tsx","../../src/react/editor/ImageEditor.tsx"],"sourcesContent":["import type { Store, Tool } from \"@hussmartinez/sdk-core\";\nimport type { ImageSession, ImageSessionSnapshot } from \"../core/session/session.js\";\nimport type { ImageEditorState } from \"./editor-state.js\";\n\n/**\n * What a tool reads to decide whether it's available, enabled or active.\n *\n * @public\n */\nexport interface ImageToolState {\n readonly snapshot: ImageSessionSnapshot;\n readonly editor: ImageEditorState;\n}\n\n/**\n * What a tool runs against.\n *\n * @public\n */\nexport interface ImageToolContext {\n readonly session: ImageSession;\n readonly view: Store<{\n readonly zoom: number;\n readonly pan: { readonly x: number; readonly y: number };\n }>;\n /** The editor's own state, which tools such as crop take over. */\n readonly editor: Store<ImageEditorState>;\n /** Asks the user for an image, as the open tool does. */\n readonly chooseFile: () => void;\n}\n\n/**\n * One of the editor's tools (docs/adr/0007, sdk-core ADR 0009).\n *\n * @public\n */\nexport type ImageTool = Tool<ImageToolState, ImageToolContext, undefined>;\n\n/** Whether a document is open. */\nexport const hasDocument = ({ snapshot }: ImageToolState): boolean => snapshot.plan !== null;\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { wholeCrop } from \"../../core/model/crop.js\";\nimport type { ImageOrientation } from \"../../core/model/plan.js\";\nimport { hasDocument, type ImageTool, type ImageToolContext } from \"../tool-types.js\";\n\n/** Starts cropping: the stage shows the whole image, with the current crop as the frame. */\nfunction startCrop({ session, editor }: ImageToolContext): void {\n const { plan, source } = session.getSnapshot();\n if (!plan || !source) return;\n editor.set((state) => ({\n ...state,\n tool: \"crop\",\n crop: { pending: plan.base.crop ?? wholeCrop(source), aspect: \"free\" },\n }));\n}\n\n/** Shows the crop frame, which the editor then focuses (docs/adr/0007). */\nexport const cropTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.crop\",\n label: \"tools.crop\",\n icon: \"crop\",\n group: \"crop\",\n isEnabled: hasDocument,\n isActive: ({ editor }) => editor.tool === \"crop\",\n run: (context) => {\n if (context.editor.getSnapshot().tool === \"crop\") return;\n startCrop(context);\n },\n shortcuts: [\"C\"],\n});\n\nfunction flip({ session }: ImageToolContext, axis: \"flipX\" | \"flipY\"): void {\n const plan = session.getSnapshot().plan;\n if (!plan) return;\n const orientation: ImageOrientation = {\n ...plan.base.orientation,\n [axis]: !plan.base.orientation[axis],\n };\n session.execute({ type: \"image.setOrientation\", orientation });\n}\n\n/** Mirrors what's on screen left to right: the plan's flips come after its rotation. */\nexport const flipHorizontalTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.flip-horizontal\",\n label: \"tools.flip-horizontal\",\n icon: \"flip-horizontal\",\n group: \"orientation\",\n isEnabled: hasDocument,\n run: (context) => flip(context, \"flipX\"),\n});\n\n/** Mirrors what's on screen top to bottom. */\nexport const flipVerticalTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.flip-vertical\",\n label: \"tools.flip-vertical\",\n icon: \"flip-vertical\",\n group: \"orientation\",\n isEnabled: hasDocument,\n run: (context) => flip(context, \"flipY\"),\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport type { ImageTool } from \"../tool-types.js\";\n\n/**\n * Opens the export dialog, which shows a summary before anything is written\n * (docs/adr/0007). No shortcut: export is irreversible, so it's a click.\n * It waits while a crop is being made, which isn't an edit until applied.\n */\nexport const exportTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.export\",\n label: \"tools.export\",\n icon: \"export\",\n group: \"export\",\n isEnabled: ({ snapshot, editor }) => snapshot.plan !== null && editor.tool === null,\n run: ({ editor }) => editor.set((state) => ({ ...state, dialog: \"export\" })),\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport type { ImageTool } from \"../tool-types.js\";\n\n/** Undoes the last step (docs/adr/0007). */\nexport const undoTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.undo\",\n label: \"tools.undo\",\n icon: \"undo\",\n group: \"history\",\n isEnabled: ({ snapshot }) => snapshot.canUndo,\n run: ({ session }) => {\n session.undo();\n },\n shortcuts: \"undo\",\n});\n\n/** Redoes the last undone step. */\nexport const redoTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.redo\",\n label: \"tools.redo\",\n icon: \"redo\",\n group: \"history\",\n isEnabled: ({ snapshot }) => snapshot.canRedo,\n run: ({ session }) => {\n session.redo();\n },\n shortcuts: \"redo\",\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport type { ImageTool } from \"../tool-types.js\";\n\n/** Asks for an image and opens it. No shortcut: `Mod+O` is the browser's own. */\nexport const openTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.open\",\n label: \"tools.open\",\n icon: \"open\",\n group: \"file\",\n run: ({ chooseFile }) => chooseFile(),\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport type { ImageOrientation, ImageRotation } from \"../../core/model/plan.js\";\nimport { hasDocument, type ImageTool, type ImageToolContext } from \"../tool-types.js\";\n\n/**\n * The orientation after a quarter turn of what's on screen. The plan's flips\n * come after its rotation, so with exactly one flip, turning the result\n * left is turning the rotation right.\n */\nexport function turned(\n orientation: ImageOrientation,\n direction: \"left\" | \"right\",\n): ImageOrientation {\n const mirrored = orientation.flipX !== orientation.flipY;\n const clockwise = (direction === \"right\") !== mirrored;\n const rotate = ((orientation.rotate + (clockwise ? 90 : 270)) % 360) as ImageRotation;\n return { ...orientation, rotate };\n}\n\nfunction turn({ session }: ImageToolContext, direction: \"left\" | \"right\"): void {\n const plan = session.getSnapshot().plan;\n if (!plan) return;\n session.execute({\n type: \"image.setOrientation\",\n orientation: turned(plan.base.orientation, direction),\n });\n}\n\n/** Turns the image a quarter turn anticlockwise. */\nexport const rotateLeftTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.rotate-left\",\n label: \"tools.rotate-left\",\n icon: \"rotate-left\",\n group: \"orientation\",\n isEnabled: hasDocument,\n run: (context) => turn(context, \"left\"),\n shortcuts: [\"[\"],\n});\n\n/** Turns the image a quarter turn clockwise. */\nexport const rotateRightTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.rotate-right\",\n label: \"tools.rotate-right\",\n icon: \"rotate-right\",\n group: \"orientation\",\n isEnabled: hasDocument,\n run: (context) => turn(context, \"right\"),\n shortcuts: [\"]\"],\n});\n","import { defineTool } from \"@hussmartinez/sdk-core\";\nimport { hasDocument, type ImageTool } from \"../tool-types.js\";\n\nconst STEP = 1.25;\nconst clamp = (zoom: number) => Math.min(16, Math.max(0.1, zoom));\n\n/** Zooms the stage in, by the family's keys. */\nexport const zoomInTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.zoom-in\",\n label: \"tools.zoom-in\",\n icon: \"zoom-in\",\n group: \"zoom\",\n isEnabled: hasDocument,\n run: ({ view }) => view.set((v) => ({ ...v, zoom: clamp(v.zoom * STEP) })),\n shortcuts: \"zoom-in\",\n});\n\n/** Zooms the stage out. */\nexport const zoomOutTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.zoom-out\",\n label: \"tools.zoom-out\",\n icon: \"zoom-out\",\n group: \"zoom\",\n isEnabled: hasDocument,\n run: ({ view }) => view.set((v) => ({ ...v, zoom: clamp(v.zoom / STEP) })),\n shortcuts: \"zoom-out\",\n});\n\n/** Fits the image to the stage, with no pan, as the family's `zoom-reset` keys do. */\nexport const zoomFitTool: ImageTool = /* @__PURE__ */ defineTool({\n id: \"image.zoom-fit\",\n label: \"tools.zoom-fit\",\n icon: \"fit\",\n group: \"zoom\",\n isEnabled: hasDocument,\n run: ({ view }) => view.set({ zoom: 1, pan: { x: 0, y: 0 } }),\n shortcuts: \"zoom-reset\",\n});\n","import { cropTool, flipHorizontalTool, flipVerticalTool } from \"./crop/crop-tools.js\";\nimport { exportTool } from \"./export/export-tool.js\";\nimport { redoTool, undoTool } from \"./history/history-tools.js\";\nimport { openTool } from \"./open/open-tool.js\";\nimport { rotateLeftTool, rotateRightTool } from \"./orientation/orientation-tools.js\";\nimport type { ImageTool } from \"./tool-types.js\";\nimport { zoomFitTool, zoomInTool, zoomOutTool } from \"./zoom/zoom-tools.js\";\n\n/**\n * Every tool the editor knows, in their default order (docs/adr/0007).\n *\n * @public\n */\nexport const imageTools: readonly ImageTool[] = [\n openTool,\n undoTool,\n redoTool,\n rotateLeftTool,\n rotateRightTool,\n flipHorizontalTool,\n flipVerticalTool,\n cropTool,\n zoomInTool,\n zoomOutTool,\n zoomFitTool,\n exportTool,\n];\n\n/** The toolbar's default groups (docs/adr/0007). */\nexport const DEFAULT_TOOLBAR: readonly (readonly string[])[] = [\n [\"image.open\"],\n [\"image.undo\", \"image.redo\"],\n [\"image.rotate-left\", \"image.rotate-right\", \"image.flip-horizontal\", \"image.flip-vertical\"],\n [\"image.crop\"],\n [\"image.zoom-in\", \"image.zoom-out\", \"image.zoom-fit\"],\n [\"image.export\"],\n];\n","import type { Messages, Store } from \"@hussmartinez/sdk-core\";\nimport { createContext } from \"react\";\nimport type { ImageEngine } from \"../core/ports/image-engine.js\";\nimport type { ImageSession } from \"../core/session/session.js\";\nimport type { ImageEditorState } from \"../features/editor-state.js\";\nimport type { ImageMessageCatalogue } from \"../messages/en.js\";\nimport type { ImageViewState } from \"./view-store.js\";\n\n/** What the provider shares with every image component below it. */\nexport interface ImageContextValue {\n readonly session: ImageSession;\n /** The engine the session decodes with, which the stage's renderer shares. */\n readonly engine: ImageEngine;\n readonly messages: Messages<ImageMessageCatalogue>;\n readonly view: Store<ImageViewState>;\n readonly editor: Store<ImageEditorState>;\n readonly opener: ImageOpener;\n}\n\n/**\n * Opens images for the editor's controls, cancelling one still opening when\n * another starts, or when the user cancels. A failure is in the session's\n * snapshot, which the stage shows.\n */\nexport interface ImageOpener {\n open(file: Blob): Promise<void>;\n cancel(): void;\n}\n\n/** Creates an {@link ImageOpener} for a session. */\nexport function createOpener(session: ImageSession): ImageOpener {\n let controller: AbortController | undefined;\n return {\n async open(file) {\n controller?.abort();\n const current = new AbortController();\n controller = current;\n try {\n await session.open(file, { signal: current.signal });\n } catch {\n // In the snapshot: the stage shows it.\n } finally {\n if (controller === current) controller = undefined;\n }\n },\n cancel() {\n controller?.abort();\n controller = undefined;\n },\n };\n}\n\nexport const ImageContext = /* @__PURE__ */ createContext<ImageContextValue | undefined>(undefined);\n","import type { Messages, Store } from \"@hussmartinez/sdk-core\";\nimport { useContext, useSyncExternalStore } from \"react\";\nimport type { ImageSession, ImageSessionSnapshot } from \"../core/session/session.js\";\nimport type { ImageEditorState } from \"../features/editor-state.js\";\nimport type { ImageMessageCatalogue } from \"../messages/en.js\";\nimport { ImageContext, type ImageContextValue } from \"./context.js\";\nimport type { ImageViewState } from \"./view-store.js\";\n\nfunction useImageContext(hook: string): ImageContextValue {\n const value = useContext(ImageContext);\n if (!value) throw new Error(`${hook}() must be used inside an ImageEditorProvider.`);\n return value;\n}\n\n/**\n * The session of the nearest `ImageEditorProvider`, to open images, run\n * commands, undo and export.\n *\n * @public\n */\nexport function useImageSession(): ImageSession {\n return useImageContext(\"useImageSession\").session;\n}\n\n/**\n * The session's snapshot, re-rendering whenever it changes, through\n * `useSyncExternalStore`, so it's safe with concurrent and server rendering.\n *\n * @public\n */\nexport function useImageDocument(): ImageSessionSnapshot {\n const { session } = useImageContext(\"useImageDocument\");\n return useSyncExternalStore(session.subscribe, session.getSnapshot, session.getSnapshot);\n}\n\n/**\n * The stage's zoom and pan, and the store to change them (docs/adr/0007).\n *\n * @public\n */\nexport function useImageView(): readonly [ImageViewState, Store<ImageViewState>] {\n const { view } = useImageContext(\"useImageView\");\n const state = useSyncExternalStore(view.subscribe, view.getSnapshot, view.getSnapshot);\n return [state, view] as const;\n}\n\n/**\n * The editor's own state: the active tool, a crop in progress, and a\n * gesture's transient plan (docs/adr/0007).\n *\n * @public\n */\nexport function useImageEditorState(): readonly [ImageEditorState, Store<ImageEditorState>] {\n const { editor } = useImageContext(\"useImageEditorState\");\n const state = useSyncExternalStore(editor.subscribe, editor.getSnapshot, editor.getSnapshot);\n return [state, editor] as const;\n}\n\n/**\n * The SDK's text for the provider's locale and overrides (ADR 0019).\n *\n * @public\n */\nexport function useImageMessages(): Messages<ImageMessageCatalogue> {\n return useImageContext(\"useImageMessages\").messages;\n}\n\n/** The provider's whole context, for the SDK's own components. */\nexport function useImageInternals(): ImageContextValue {\n return useImageContext(\"useImageInternals\");\n}\n","import { useAnnounce } from \"@hussmartinez/ui/react\";\nimport { useMemo } from \"react\";\nimport { aspectRatio, fitAspect, type ImageAspect, wholeCrop } from \"../../core/model/crop.js\";\nimport type { ImageCrop } from \"../../core/model/plan.js\";\nimport { useImageInternals } from \"../hooks.js\";\n\n/** What the crop frame and panel do to a crop in progress (docs/adr/0007). */\nexport interface CropActions {\n /** Replaces the pending crop: a frame drag, a key or a field. */\n update(crop: ImageCrop): void;\n /** Chooses an aspect, and fits the pending crop to it. */\n setAspect(aspect: ImageAspect): void;\n /** Applies the pending crop as one undoable step, and ends cropping. */\n apply(): void;\n /** Ends cropping, changing nothing. */\n cancel(): void;\n}\n\nexport function useCropActions(): CropActions {\n const { session, editor, messages } = useImageInternals();\n const announce = useAnnounce();\n return useMemo(() => {\n const pendingCrop = () => editor.getSnapshot().crop;\n return {\n update(crop) {\n const current = pendingCrop();\n if (!current) return;\n editor.set((state) => ({ ...state, crop: { ...current, pending: crop } }));\n },\n setAspect(aspect) {\n const current = pendingCrop();\n const source = session.getSnapshot().source;\n if (!current || !source) return;\n const pending = fitAspect(current.pending, aspectRatio(aspect, source));\n editor.set((state) => ({ ...state, crop: { aspect, pending } }));\n },\n apply() {\n const current = pendingCrop();\n const { plan, source } = session.getSnapshot();\n editor.set((state) => ({ ...state, tool: null, crop: null }));\n if (!current || !plan || !source) return;\n const whole = wholeCrop(source);\n const isWhole =\n current.pending.x === 0 &&\n current.pending.y === 0 &&\n current.pending.width === whole.width &&\n current.pending.height === whole.height;\n const crop = isWhole ? null : current.pending;\n // One crop session is one step, and only if it changed anything.\n if (JSON.stringify(crop) !== JSON.stringify(plan.base.crop)) {\n session.execute({ type: \"image.setCrop\", crop });\n }\n announce(\n messages.t(\"crop.applied\", {\n width: current.pending.width,\n height: current.pending.height,\n }),\n );\n },\n cancel() {\n editor.set((state) => ({ ...state, tool: null, crop: null }));\n },\n };\n }, [announce, editor, messages, session]);\n}\n","import { Button, Field, NumberField, SegmentedControl } from \"@hussmartinez/ui/react\";\nimport type { ReactNode } from \"react\";\nimport { ASPECT_PRESETS, type ImageAspect, moveCrop, wholeCrop } from \"../../core/model/crop.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { useCropActions } from \"./use-crop.js\";\n\nconst aspectKey = (aspect: ImageAspect) =>\n typeof aspect === \"string\" ? aspect : `${aspect[0]}:${aspect[1]}`;\n\n/**\n * Props of {@link ImageCropPanel}.\n *\n * @public\n */\nexport interface ImageCropPanelProps {\n readonly className?: string;\n}\n\n/**\n * The crop panel (docs/adr/0007): the crop's position and size in source\n * pixels as number fields, the aspect presets, and Apply, Cancel and Whole\n * image. It's the alternative to dragging the frame (WCAG 2.5.7), shown while\n * cropping.\n *\n * @public\n */\nexport function ImageCropPanel(props: ImageCropPanelProps): ReactNode {\n const [state] = useImageEditorState();\n const { source } = useImageDocument();\n const messages = useImageMessages();\n const actions = useCropActions();\n const crop = state.crop;\n if (state.tool !== \"crop\" || !crop || !source) return null;\n const { pending } = crop;\n const field = (name: \"x\" | \"y\" | \"width\" | \"height\") => {\n const max =\n name === \"x\"\n ? source.width - pending.width\n : name === \"y\"\n ? source.height - pending.height\n : name === \"width\"\n ? source.width - pending.x\n : source.height - pending.y;\n return (\n <Field key={name} label={messages.t(`crop.${name}`)}>\n <NumberField\n value={pending[name]}\n min={name === \"width\" || name === \"height\" ? 1 : 0}\n max={max}\n step={1}\n largeStep={10}\n onValueChange={(value) => {\n const next = { ...pending, [name]: Math.round(value) };\n actions.update(name === \"x\" || name === \"y\" ? moveCrop(next, 0, 0, source) : next);\n }}\n />\n </Field>\n );\n };\n const options = ASPECT_PRESETS.map((aspect) => ({\n value: aspectKey(aspect),\n label:\n typeof aspect === \"string\"\n ? messages.t(`crop.aspects.${aspect}`)\n : messages.t(\"crop.aspects.ratio\", { width: aspect[0], height: aspect[1] }),\n }));\n return (\n <section\n className={[\"hm-image-crop-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"crop.panel\")}\n >\n <div className=\"hm-image-crop-fields\">\n {([\"x\", \"y\", \"width\", \"height\"] as const).map(field)}\n </div>\n <SegmentedControl\n label={messages.t(\"crop.aspect\")}\n value={aspectKey(crop.aspect)}\n options={options}\n size=\"small\"\n onValueChange={(value) => {\n const aspect = ASPECT_PRESETS.find((a) => aspectKey(a) === value);\n if (aspect) actions.setAspect(aspect);\n }}\n />\n <div className=\"hm-image-crop-actions\">\n <Button variant=\"secondary\" onClick={() => actions.update(wholeCrop(source))}>\n {messages.t(\"crop.reset\")}\n </Button>\n <Button variant=\"secondary\" onClick={() => actions.cancel()}>\n {messages.t(\"crop.cancel\")}\n </Button>\n <Button variant=\"primary\" onClick={() => actions.apply()}>\n {messages.t(\"crop.apply\")}\n </Button>\n </div>\n </section>\n );\n}\n","import { createContext } from \"react\";\nimport type { ImageKeepableMetadata, ImageMetadataPresence } from \"../../core/model/source.js\";\nimport type { ImageExportFormat } from \"../../core/ports/image-processor.js\";\n\n/**\n * What the export dialog reports about a finished export, for the element's\n * `export` event: no pixels and no file, which an event must never carry\n * (sdk-core ADR 0012). The element's `export()` method returns the file.\n *\n * @public\n */\nexport interface ImageExportReport {\n readonly format: ImageExportFormat[\"type\"];\n readonly width: number;\n readonly height: number;\n /** The file's size in bytes. */\n readonly size: number;\n readonly removed: readonly (keyof ImageMetadataPresence)[];\n readonly kept: readonly (keyof ImageKeepableMetadata)[];\n}\n\n/** Hears about every export the dialog finishes; the element provides it. */\nexport const ExportListenerContext = createContext<((report: ImageExportReport) => void) | null>(\n null,\n);\n","import {\n Button,\n Dialog,\n Field,\n NumberField,\n ProgressBar,\n SegmentedControl,\n Slider,\n TextField,\n useAnnounce,\n} from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useContext, useEffect, useRef, useState } from \"react\";\nimport { isImageError } from \"../../core/errors/image-error.js\";\nimport { compositionSize, outputSize } from \"../../core/model/geometry.js\";\nimport type { ImageOutput, ImagePlan } from \"../../core/model/plan.js\";\nimport {\n type ImageKeepableMetadata,\n type ImageMetadataPresence,\n longerThan,\n MAX_METADATA_LENGTH,\n} from \"../../core/model/source.js\";\nimport type { ImageCommand } from \"../../core/operations/commands.js\";\nimport type { ImageExportFormat } from \"../../core/ports/image-processor.js\";\nimport type { ImageSessionExport, ImageSessionSource } from \"../../core/session/session.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageMessages,\n useImageSession,\n} from \"../hooks.js\";\nimport { ExportListenerContext } from \"./export-listener.js\";\n\n/**\n * Props of {@link ImageExportDialog}.\n *\n * @public\n */\nexport interface ImageExportDialogProps {\n /**\n * Takes the exported file instead of the dialog's download button: the\n * dialog closes once it's called.\n */\n readonly onExport?: (blob: Blob, details: ImageSessionExport) => void;\n /** The downloaded file's name, without its extension. Defaults to `image`. */\n readonly fileName?: string;\n /** Extra classes on the dialog. */\n readonly className?: string;\n}\n\ntype FormatType = ImageExportFormat[\"type\"];\n\n/** The dialog's choices, until Export applies them to the plan. */\ninterface Draft {\n readonly format: FormatType;\n /** For JPEG and WebP, 1 to 100. */\n readonly quality: number;\n readonly output: ImageOutput;\n readonly metadata: ImageKeepableMetadata;\n}\n\ntype Phase =\n | { readonly kind: \"choose\" }\n | { readonly kind: \"exporting\"; readonly progress: number }\n | { readonly kind: \"done\"; readonly result: ImageSessionExport; readonly format: FormatType };\n\nconst FORMATS: readonly FormatType[] = [\"png\", \"jpeg\", \"webp\"];\nconst EXTENSIONS: Readonly<Record<FormatType, string>> = { png: \"png\", jpeg: \"jpg\", webp: \"webp\" };\nconst FIELDS: readonly (keyof ImageKeepableMetadata)[] = [\n \"title\",\n \"description\",\n \"artist\",\n \"copyright\",\n];\nconst KINDS: readonly (keyof ImageMetadataPresence)[] = [\n \"location\",\n \"camera\",\n \"timestamps\",\n \"thumbnail\",\n \"colourProfile\",\n \"other\",\n];\nconst DEFAULT_QUALITY = 92;\n\n/**\n * A field's text, clamped to the limit in code points, as the plan counts\n * it. An input's `maxLength` counts UTF-16 units, which would stop at half\n * as many emoji.\n */\nconst keepable = (text: string) =>\n longerThan(text, MAX_METADATA_LENGTH) ? [...text].slice(0, MAX_METADATA_LENGTH).join(\"\") : text;\n\n/** The choices a dialog opens with: the plan's size and fields, in the source's format if it can be written. */\nfunction initialDraft(plan: ImagePlan, source: ImageSessionSource): Draft {\n const format = (FORMATS as readonly string[]).includes(source.format)\n ? (source.format as FormatType)\n : \"png\";\n return { format, quality: DEFAULT_QUALITY, output: plan.output, metadata: plan.metadata };\n}\n\nconst sameOutput = (a: ImageOutput, b: ImageOutput) =>\n a.kind === \"scale\" && b.kind === \"scale\"\n ? a.scale === b.scale\n : a.kind === \"fit\" && b.kind === \"fit\" && a.width === b.width && a.height === b.height;\n\n/** The commands that bring the plan's size and fields to the dialog's choices. */\nfunction changes(plan: ImagePlan, draft: Draft): ImageCommand[] {\n const commands: ImageCommand[] = [];\n if (!sameOutput(plan.output, draft.output)) {\n commands.push({ type: \"image.setOutput\", output: draft.output });\n }\n for (const field of FIELDS) {\n if (plan.metadata[field] !== draft.metadata[field]) {\n commands.push({ type: \"image.setMetadata\", field, value: draft.metadata[field] });\n }\n }\n return commands;\n}\n\nconst formatOf = (draft: Draft): ImageExportFormat =>\n draft.format === \"png\" ? { type: \"png\" } : { type: draft.format, quality: draft.quality / 100 };\n\n/**\n * The export dialog (docs/adr/0007). Export is irreversible, so it shows a\n * summary before anything is written: the output's size and format, the\n * metadata the source carried that the file won't, and the fields the user\n * chose to keep. Then a progress bar that can stop the export, and a\n * download button, which gets focus, with the file's size.\n *\n * It opens when the editor state's `dialog` is `export`, as the export tool\n * sets it. On Export, the chosen size and fields become one undoable step\n * of the plan, so the plan records what was exported. A format the browser\n * can't encode shows the catalogue's text, and keeps the choices.\n *\n * @public\n */\nexport function ImageExportDialog(props: ImageExportDialogProps): ReactNode {\n const { onExport, fileName = \"image\" } = props;\n const session = useImageSession();\n const { plan, source } = useImageDocument();\n const [editor, editorStore] = useImageEditorState();\n const messages = useImageMessages();\n const announce = useAnnounce();\n const listener = useContext(ExportListenerContext);\n const [draft, setDraft] = useState<Draft | null>(null);\n const [phase, setPhase] = useState<Phase>({ kind: \"choose\" });\n const [error, setError] = useState<unknown>(null);\n const controller = useRef<AbortController | null>(null);\n const objectUrl = useRef<string | null>(null);\n const downloadButton = useRef<HTMLButtonElement>(null);\n\n const open = editor.dialog === \"export\" && plan !== null && source !== null;\n const current = draft ?? (plan && source ? initialDraft(plan, source) : null);\n\n const revoke = () => {\n if (objectUrl.current) URL.revokeObjectURL(objectUrl.current);\n objectUrl.current = null;\n };\n // Whatever closes the dialog, such as another image opening, ends its\n // export and drops its choices and result, so it reopens fresh. The\n // controller is cleared before the abort, so the export's own handlers\n // know it was ended for them, unlike Stop.\n useEffect(() => {\n if (open) return;\n const running = controller.current;\n controller.current = null;\n running?.abort();\n if (objectUrl.current) URL.revokeObjectURL(objectUrl.current);\n objectUrl.current = null;\n setDraft(null);\n setPhase((now) => (now.kind === \"choose\" ? now : { kind: \"choose\" }));\n setError(null);\n }, [open]);\n\n // Unmounting ends an export too, and frees a download's URL.\n useEffect(\n () => () => {\n controller.current?.abort();\n controller.current = null;\n if (objectUrl.current) URL.revokeObjectURL(objectUrl.current);\n },\n [],\n );\n\n // The download button takes focus when the file is ready.\n const done = phase.kind === \"done\";\n useEffect(() => {\n if (done) downloadButton.current?.focus();\n }, [done]);\n\n /** Asks the editor to close the dialog; the effect on `open` resets it. */\n const close = () => {\n editorStore.set((state) => (state.dialog === null ? state : { ...state, dialog: null }));\n };\n\n if (!plan || !source || !current) {\n return null;\n }\n\n const update = (patch: Partial<Draft>) => setDraft({ ...current, ...patch });\n const formatName = (format: FormatType) => messages.t(`export.formats.${format}`);\n\n const run = async () => {\n setError(null);\n try {\n const commands = changes(plan, current);\n if (commands.length > 0) session.execute(commands);\n } catch (reason) {\n setError(reason);\n return;\n }\n const running = new AbortController();\n controller.current = running;\n setPhase({ kind: \"exporting\", progress: 0 });\n try {\n const result = await session.export(formatOf(current), {\n signal: running.signal,\n onProgress: (progress) =>\n setPhase((now) => (now.kind === \"exporting\" ? { kind: \"exporting\", progress } : now)),\n });\n // Closed while it ran: the result belongs to no one.\n if (controller.current !== running) return;\n controller.current = null;\n announce(\n messages.t(\"export.done\", { format: formatName(current.format), size: result.blob.size }),\n );\n listener?.({\n format: current.format,\n width: result.width,\n height: result.height,\n size: result.blob.size,\n removed: result.removed,\n kept: result.kept,\n });\n if (onExport) {\n onExport(result.blob, result);\n close();\n return;\n }\n setPhase({ kind: \"done\", result, format: current.format });\n } catch (reason) {\n // Closed while it ran: the reset dialog shows nothing of it.\n if (controller.current !== running) return;\n controller.current = null;\n setPhase({ kind: \"choose\" });\n if (isImageError(reason) && reason.code === \"ABORTED\") {\n announce(messages.t(\"export.cancelled\"));\n return;\n }\n setError(reason);\n }\n };\n\n const stop = () => controller.current?.abort();\n\n const download = () => {\n if (phase.kind !== \"done\") return;\n revoke();\n objectUrl.current = URL.createObjectURL(phase.result.blob);\n const link = document.createElement(\"a\");\n link.href = objectUrl.current;\n link.download = `${fileName}.${EXTENSIONS[phase.format]}`;\n link.click();\n };\n\n const composition = compositionSize(plan, source);\n const size = outputSize(current.output, composition);\n const removed = KINDS.filter((kind) => source.metadata[kind]);\n const kept = FIELDS.filter((field) => current.metadata[field] !== \"\");\n const exporting = phase.kind === \"exporting\";\n\n const footer =\n phase.kind === \"done\" ? (\n <>\n <Button variant=\"secondary\" onClick={close}>\n {messages.t(\"export.close\")}\n </Button>\n <Button ref={downloadButton} variant=\"primary\" onClick={download}>\n {messages.t(\"export.download\")}\n </Button>\n </>\n ) : exporting ? (\n <Button variant=\"secondary\" onClick={stop}>\n {messages.t(\"export.stop\")}\n </Button>\n ) : (\n <>\n <Button variant=\"secondary\" onClick={close}>\n {messages.t(\"export.cancel\")}\n </Button>\n <Button variant=\"primary\" onClick={() => void run()}>\n {messages.t(\"export.confirm\")}\n </Button>\n </>\n );\n\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!next) close();\n }}\n title={messages.t(\"export.title\")}\n description={messages.t(\"export.description\")}\n footer={footer}\n className={[\"hm-image-export\", props.className].filter(Boolean).join(\" \")}\n >\n {phase.kind === \"done\" ? (\n <p className=\"hm-image-export-result\">\n {messages.t(\"export.ready\", {\n width: phase.result.width,\n height: phase.result.height,\n format: formatName(phase.format),\n size: phase.result.blob.size,\n })}\n </p>\n ) : (\n <>\n <fieldset className=\"hm-image-export-choices\" disabled={exporting}>\n <SegmentedControl\n label={messages.t(\"export.format\")}\n value={current.format}\n size=\"small\"\n options={FORMATS.map((format) => ({ value: format, label: formatName(format) }))}\n onValueChange={(format) => update({ format: format as FormatType })}\n />\n {current.format === \"png\" ? null : (\n <Field label={messages.t(\"export.quality\")} className=\"hm-image-slider-field\">\n <Slider\n min={1}\n max={100}\n step={1}\n largeStep={10}\n value={current.quality}\n onValueChange={(quality) => update({ quality: Math.round(quality) })}\n />\n </Field>\n )}\n <SegmentedControl\n label={messages.t(\"export.size\")}\n value={current.output.kind}\n size=\"small\"\n options={[\n { value: \"scale\", label: messages.t(\"export.sizes.scale\") },\n { value: \"fit\", label: messages.t(\"export.sizes.fit\") },\n ]}\n onValueChange={(kind) =>\n update({\n output:\n kind === \"fit\"\n ? { kind: \"fit\", width: composition.width, height: composition.height }\n : { kind: \"scale\", scale: 1 },\n })\n }\n />\n <div className=\"hm-image-export-fields\">\n {current.output.kind === \"scale\" ? (\n <Field label={messages.t(\"export.scale\")}>\n <NumberField\n value={Math.round(current.output.scale * 100)}\n min={1}\n max={100}\n step={1}\n largeStep={10}\n onValueChange={(percent) =>\n update({ output: { kind: \"scale\", scale: Math.round(percent) / 100 } })\n }\n />\n </Field>\n ) : (\n ([\"width\", \"height\"] as const).map((side) => {\n const output = current.output as Extract<ImageOutput, { kind: \"fit\" }>;\n return (\n <Field\n key={side}\n label={messages.t(side === \"width\" ? \"export.fitWidth\" : \"export.fitHeight\")}\n >\n <NumberField\n value={output[side]}\n min={1}\n step={1}\n largeStep={100}\n onValueChange={(value) =>\n update({ output: { ...output, [side]: Math.max(1, Math.round(value)) } })\n }\n />\n </Field>\n );\n })\n )}\n </div>\n <fieldset className=\"hm-image-export-metadata\">\n <legend>{messages.t(\"export.fields\")}</legend>\n <p className=\"hm-image-export-hint\">{messages.t(\"export.fieldsHint\")}</p>\n <div className=\"hm-image-export-fields\">\n {FIELDS.map((field) => (\n <Field key={field} label={messages.t(`export.field.${field}`)}>\n <TextField\n autoComplete=\"off\"\n value={current.metadata[field]}\n onValueChange={(value) =>\n update({ metadata: { ...current.metadata, [field]: keepable(value) } })\n }\n />\n </Field>\n ))}\n </div>\n </fieldset>\n </fieldset>\n <section className=\"hm-image-export-summary\" aria-label={messages.t(\"export.summary\")}>\n <p>\n {messages.t(\"export.output\", {\n width: size.width,\n height: size.height,\n format: formatName(current.format),\n })}\n </p>\n {removed.length > 0 ? (\n <>\n <p>{messages.t(\"export.removed\")}</p>\n <ul>\n {removed.map((kind) => (\n <li key={kind}>{messages.t(`export.kind.${kind}`)}</li>\n ))}\n </ul>\n </>\n ) : (\n <p>{messages.t(\"export.removedNone\")}</p>\n )}\n {kept.length > 0 ? (\n <>\n <p>{messages.t(\"export.kept\")}</p>\n <ul>\n {kept.map((field) => (\n <li key={field}>{messages.t(`export.field.${field}`)}</li>\n ))}\n </ul>\n </>\n ) : null}\n </section>\n {exporting ? (\n <ProgressBar\n label={messages.t(\"export.progress\")}\n value={Math.round(phase.progress * 100)}\n max={100}\n />\n ) : null}\n {error ? (\n <p className=\"hm-image-export-error\" role=\"alert\">\n {messages.error(error)}\n </p>\n ) : null}\n </>\n )}\n </Dialog>\n );\n}\n","import { createStore, type Store } from \"@hussmartinez/sdk-core\";\nimport type { ImageAspect } from \"../core/model/crop.js\";\nimport type { ImageCrop, ImagePlan } from \"../core/model/plan.js\";\n\n/**\n * The editor's own state, outside the session and its history\n * (docs/adr/0007): the active tool, a crop in progress, and a gesture's\n * transient plan, which the stage renders instead of the session's.\n *\n * @public\n */\nexport interface ImageEditorState {\n /** The tool that takes over the stage, such as `crop`, or `null`. */\n readonly tool: \"crop\" | null;\n /** The crop being made, in whole pixels of the oriented source, and its aspect. */\n readonly crop: { readonly pending: ImageCrop; readonly aspect: ImageAspect } | null;\n /**\n * A gesture's plan while it runs: the session's plan with the gesture's\n * change, which isn't an edit until the gesture ends.\n */\n readonly preview: ImagePlan | null;\n /** The dialog the editor shows over the stage, such as `export`, or `null`. */\n readonly dialog: \"export\" | null;\n}\n\nexport const IDLE: ImageEditorState = Object.freeze({\n tool: null,\n crop: null,\n preview: null,\n dialog: null,\n});\n\n/** A store of the editor's state. */\nexport function createEditorStore(): Store<ImageEditorState> {\n return createStore<ImageEditorState>(IDLE);\n}\n","import { createStore, type Store } from \"@hussmartinez/sdk-core\";\n\n/**\n * The stage's zoom and pan: view state, outside the session and its history\n * (ADR 0003, docs/adr/0007). Zoom 1 fits the image to the stage.\n *\n * @public\n */\nexport interface ImageViewState {\n readonly zoom: number;\n readonly pan: { readonly x: number; readonly y: number };\n}\n\n/** The fitted view, with no pan. */\nexport const FITTED: ImageViewState = Object.freeze({\n zoom: 1,\n pan: Object.freeze({ x: 0, y: 0 }),\n});\n\n/** The zoom range, and the step of the zoom tools. */\nexport const MIN_ZOOM = 0.1;\nexport const MAX_ZOOM = 16;\nexport const ZOOM_STEP = 1.25;\n\n/** A store of the view, which the stage reads with the session's plan. */\nexport function createViewStore(): Store<ImageViewState> {\n return createStore<ImageViewState>(FITTED);\n}\n\n/** The view zoomed by a factor, within the range. */\nexport function zoomBy(view: ImageViewState, factor: number): ImageViewState {\n const zoom = Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, view.zoom * factor));\n return { ...view, zoom };\n}\n","import { createMessages, type MessageOverrides } from \"@hussmartinez/sdk-core\";\nimport { UiMessagesProvider } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useEffect, useMemo, useState } from \"react\";\nimport { createImageEngine } from \"../adapters/image-engine.js\";\nimport { createImageProcessor } from \"../adapters/image-processor.js\";\nimport type { ImageFilePolicyOverrides } from \"../core/errors/image-limits.js\";\nimport type { ImageEngine } from \"../core/ports/image-engine.js\";\nimport type { ImageProcessor } from \"../core/ports/image-processor.js\";\nimport {\n createImageSession,\n type ImageSession,\n type ImageSessionEvent,\n} from \"../core/session/session.js\";\nimport { createEditorStore } from \"../features/editor-state.js\";\nimport { type ImageMessageCatalogue, imageMessages } from \"../messages/en.js\";\nimport { createOpener, ImageContext } from \"./context.js\";\nimport { createViewStore } from \"./view-store.js\";\n\n/**\n * Props of {@link ImageEditorProvider}.\n *\n * @public\n */\nexport interface ImageEditorProviderProps {\n /**\n * The engine that probes, decodes and holds images, and draws the stage.\n * Defaults to the SDK's own, created with `assetsUrl`. A session of your own\n * must use this engine.\n */\n readonly engine?: ImageEngine;\n /** The processor for exports. Defaults to the SDK's own, on the engine. */\n readonly processor?: ImageProcessor;\n /** A session of your own, over `engine`, instead of one the provider creates. */\n readonly session?: ImageSession;\n /**\n * Where the application serves the package's `dist/assets/` directory, for\n * the engine the provider creates (docs/adr/0002).\n */\n readonly assetsUrl?: string | URL;\n /** File limits for a session the provider creates (docs/adr/0004). */\n readonly filePolicy?: ImageFilePolicyOverrides;\n /** Anonymous usage events from a session the provider creates. */\n readonly onEvent?: (event: ImageSessionEvent) => void;\n /** Text overrides, typed against the English catalogue (ADR 0019). */\n readonly messages?: MessageOverrides<ImageMessageCatalogue>;\n /** The locale for numbers and plurals. Defaults to `\"en\"`. */\n readonly locale?: string;\n /** The components that use the session, such as `ImageStage`. */\n readonly children?: ReactNode;\n}\n\ninterface Owned {\n readonly engine: ImageEngine;\n readonly session: ImageSession;\n pending?: ReturnType<typeof setTimeout>;\n dispose(): void;\n}\n\n/** Creates what the host didn't pass. Creating an engine starts nothing until its first call. */\nfunction own(props: ImageEditorProviderProps): Owned {\n const engine =\n props.engine ??\n createImageEngine(props.assetsUrl === undefined ? {} : { assetsUrl: props.assetsUrl });\n const processor = props.processor ?? createImageProcessor(engine);\n const session =\n props.session ??\n createImageSession({\n engine,\n processor,\n ...(props.filePolicy ? { filePolicy: props.filePolicy } : {}),\n ...(props.onEvent ? { onEvent: props.onEvent } : {}),\n });\n return {\n engine,\n session,\n dispose() {\n // Only what the provider created itself is destroyed.\n if (!props.session) void session.destroy();\n if (!props.processor) void processor.destroy();\n if (!props.engine) void engine.destroy();\n },\n };\n}\n\n/**\n * Provides an image session, its engine, the stage's view and the SDK's\n * text to the components below it: `ImageStage`, `ImageToolbar` and the\n * hooks (docs/adr/0007). `ImageEditor` renders one itself.\n *\n * @example\n * ```tsx\n * <ImageEditorProvider locale=\"de\" messages={{ \"editor.empty\": \"Öffnen Sie ein Bild.\" }}>\n * <ImageToolbar />\n * <ImageStage />\n * </ImageEditorProvider>\n * ```\n *\n * @public\n */\nexport function ImageEditorProvider(props: ImageEditorProviderProps): ReactNode {\n const { messages: overrides, locale = \"en\", children } = props;\n const [owned] = useState(() => own(props));\n const [view] = useState(createViewStore);\n const [editor] = useState(createEditorStore);\n const [opener] = useState(() => createOpener(owned.session));\n\n useEffect(() => {\n // React's development mode unmounts and mounts again at once, so the\n // disposal waits a tick, and a remount cancels it.\n if (owned.pending !== undefined) clearTimeout(owned.pending);\n return () => {\n owned.pending = setTimeout(() => owned.dispose(), 0);\n };\n }, [owned]);\n\n const messages = useMemo(\n () =>\n createMessages(imageMessages, {\n locale,\n ...(overrides ? { overrides } : {}),\n }),\n [locale, overrides],\n );\n const value = useMemo(\n () => ({ session: owned.session, engine: owned.engine, messages, view, editor, opener }),\n [owned, messages, view, editor, opener],\n );\n // The same object gives ui's components their text, so a host's\n // `messages` reach the drop zone and dialogs too (sdk-core ADR 0046).\n return (\n <ImageContext.Provider value={value}>\n <UiMessagesProvider messages={messages}>{children}</UiMessagesProvider>\n </ImageContext.Provider>\n );\n}\n","import { applyCommands } from \"@hussmartinez/sdk-core\";\nimport { useEffect, useMemo } from \"react\";\nimport { createImageReducer, type ImageCommand } from \"../core/operations/commands.js\";\nimport { useImageInternals } from \"./hooks.js\";\n\n/** How long after the last key of a keyboard adjustment its gesture ends (docs/adr/0007). */\nexport const KEYBOARD_COMMIT_DELAY = 500;\n\n/**\n * One gesture of a continuous control, such as a slider (docs/adr/0007):\n * while it runs, the stage renders a transient plan, the session's plan with\n * the gesture's commands applied by the same reducer, and the session, its\n * history and the host's `onChange` don't see it. When it ends, its commands\n * execute as one undoable step.\n */\nexport interface Gesture {\n /** Shows these commands on the stage, replacing the gesture's earlier ones. */\n preview(commands: readonly ImageCommand[]): void;\n /** Ends the gesture now: its commands execute as one step, if it has any. */\n commit(): void;\n /** Ends the gesture after the keyboard delay, unless it continues before then. */\n commitSoon(): void;\n /** Ends the gesture with no step, and the stage shows the session's plan again. */\n cancel(): void;\n /** Whether a gesture is running. */\n readonly active: () => boolean;\n}\n\nexport function useGesture(): Gesture {\n const { session, editor } = useImageInternals();\n const gesture = useMemo(() => {\n let pending: readonly ImageCommand[] | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const reducer = createImageReducer((id) => {\n const source = session.getSnapshot().source;\n return source && source.id === id ? source : undefined;\n });\n const clearTimer = () => {\n if (timer !== undefined) clearTimeout(timer);\n timer = undefined;\n };\n const end = () => {\n clearTimer();\n pending = undefined;\n editor.set((state) => (state.preview === null ? state : { ...state, preview: null }));\n };\n const value: Gesture = {\n preview(commands) {\n const plan = session.getSnapshot().plan;\n if (!plan) return;\n // Checked by the reducer, as executing them will be: a value it\n // refuses never reaches the stage.\n const preview = applyCommands(reducer, plan, commands).state;\n pending = commands;\n editor.set((state) => ({ ...state, preview }));\n },\n commit() {\n const commands = pending;\n end();\n if (commands && commands.length > 0) session.execute(commands);\n },\n commitSoon() {\n clearTimer();\n timer = setTimeout(() => value.commit(), KEYBOARD_COMMIT_DELAY);\n },\n cancel: end,\n active: () => pending !== undefined,\n };\n return value;\n }, [editor, session]);\n // A control that goes away ends its gesture, so nothing is left half-done.\n useEffect(() => () => gesture.commit(), [gesture]);\n return gesture;\n}\n","import type { FocusEvent, KeyboardEvent, PointerEvent } from \"react\";\nimport type { ImageCommand } from \"../../core/operations/commands.js\";\nimport type { Gesture } from \"../gesture.js\";\n\n/**\n * The events that drive one slider's gesture (docs/adr/0007): each value\n * previews, a pointer release or leaving the slider commits, keys commit a\n * moment after the last one, and Escape cancels.\n */\nexport function sliderGesture(gesture: Gesture, command: (value: number) => ImageCommand) {\n return {\n onValueChange: (value: number) => gesture.preview([command(value)]),\n onPointerUp: (_event: PointerEvent<HTMLInputElement>) => gesture.commit(),\n onBlur: (_event: FocusEvent<HTMLInputElement>) => gesture.commit(),\n onKeyUp: (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== \"Escape\" && gesture.active()) gesture.commitSoon();\n },\n onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Escape\" && gesture.active()) {\n event.preventDefault();\n event.stopPropagation();\n gesture.cancel();\n }\n },\n };\n}\n","import { Button, Field, Slider, useAnnounce } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useRef } from \"react\";\nimport { DEVELOP_ADJUSTMENTS, type ImageDevelop } from \"../../core/model/plan.js\";\nimport { useGesture } from \"../gesture.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageMessages,\n useImageSession,\n} from \"../hooks.js\";\nimport { sliderGesture } from \"./use-slider-gesture.js\";\n\n/**\n * Props of {@link ImageAdjustPanel}.\n *\n * @public\n */\nexport interface ImageAdjustPanelProps {\n readonly className?: string;\n}\n\nconst signed = (value: number) => (value > 0 ? `+${value}` : String(value));\n\n/**\n * The Adjust panel (docs/adr/0006, docs/adr/0007): a slider per develop\n * adjustment, in the order they're applied, from −100 to 100. A slider's\n * gesture previews on the stage and is one undo step when it ends; each\n * slider resets to 0 with its button, or by double-clicking it, and \"Reset\n * all\" resets every one in one step.\n *\n * @public\n */\nexport function ImageAdjustPanel(props: ImageAdjustPanelProps): ReactNode {\n const session = useImageSession();\n const { plan } = useImageDocument();\n const [editor] = useImageEditorState();\n const messages = useImageMessages();\n const gesture = useGesture();\n const announce = useAnnounce();\n const first = useRef<HTMLInputElement>(null);\n if (!plan) return null;\n // During a gesture the sliders show its values, which the stage renders.\n const develop = (editor.preview ?? plan).base.develop;\n const reset = (values: Partial<ImageDevelop>) => {\n gesture.cancel();\n session.execute({ type: \"image.setDevelop\", values });\n };\n const changed = DEVELOP_ADJUSTMENTS.filter((name) => plan.base.develop[name] !== 0);\n return (\n <section\n className={[\"hm-image-adjust-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"develop.panel\")}\n >\n {DEVELOP_ADJUSTMENTS.map((name, index) => {\n const label = messages.t(`develop.${name}`);\n return (\n // The Field shows the slider's name, and labels it (WCAG 2.5.3).\n <Field key={name} label={label} className=\"hm-image-slider-field\">\n {(control) => (\n <div className=\"hm-image-adjust-row\">\n <Slider\n {...control}\n {...(index === 0 ? { ref: first } : {})}\n min={-100}\n max={100}\n step={1}\n largeStep={10}\n value={develop[name]}\n formatValue={signed}\n {...sliderGesture(gesture, (value) => ({\n type: \"image.setDevelop\",\n values: { [name]: Math.round(value) },\n }))}\n onDoubleClick={() => {\n if (plan.base.develop[name] !== 0) reset({ [name]: 0 });\n }}\n />\n <output className=\"hm-image-adjust-value\" aria-hidden=\"true\">\n {signed(develop[name])}\n </output>\n {plan.base.develop[name] !== 0 ? (\n <Button variant=\"quiet\" size=\"small\" onClick={() => reset({ [name]: 0 })}>\n {messages.t(\"develop.reset\", { name: label })}\n </Button>\n ) : null}\n </div>\n )}\n </Field>\n );\n })}\n <Button\n variant=\"secondary\"\n disabled={changed.length === 0}\n onClick={() => {\n reset(Object.fromEntries(changed.map((name) => [name, 0])));\n first.current?.focus();\n announce(messages.t(\"develop.wasReset\"));\n }}\n >\n {messages.t(\"develop.resetAll\")}\n </Button>\n </section>\n );\n}\n","import { Field, SegmentedControl, Slider } from \"@hussmartinez/ui/react\";\nimport type { ReactNode } from \"react\";\nimport { FILTER_PRESETS, type ImageFilterPreset } from \"../../core/model/plan.js\";\nimport { useGesture } from \"../gesture.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageMessages,\n useImageSession,\n} from \"../hooks.js\";\nimport { sliderGesture } from \"./use-slider-gesture.js\";\n\n/**\n * Props of {@link ImageFilterPanel}.\n *\n * @public\n */\nexport interface ImageFilterPanelProps {\n readonly className?: string;\n}\n\n/**\n * The Filters panel (docs/adr/0006, docs/adr/0007): the presets, \"None\"\n * first, as one choice, each one undo step; and the chosen preset's\n * strength, whose slider gesture is one undo step.\n *\n * @public\n */\nexport function ImageFilterPanel(props: ImageFilterPanelProps): ReactNode {\n const session = useImageSession();\n const { plan } = useImageDocument();\n const [editor] = useImageEditorState();\n const messages = useImageMessages();\n const gesture = useGesture();\n if (!plan) return null;\n const filter = (editor.preview ?? plan).base.filter;\n const options = [\n { value: \"none\", label: messages.t(\"filters.none\") },\n ...FILTER_PRESETS.map((preset) => ({ value: preset, label: messages.t(`filters.${preset}`) })),\n ];\n return (\n <section\n className={[\"hm-image-filter-panel\", props.className].filter(Boolean).join(\" \")}\n aria-label={messages.t(\"filters.panel\")}\n >\n <SegmentedControl\n label={messages.t(\"filters.label\")}\n value={filter?.preset ?? \"none\"}\n options={options}\n onValueChange={(value) => {\n gesture.cancel();\n session.execute({\n type: \"image.setFilter\",\n filter:\n value === \"none\"\n ? null\n : { preset: value as ImageFilterPreset, strength: filter?.strength ?? 100 },\n });\n }}\n />\n {filter ? (\n <Field label={messages.t(\"filters.strength\")} className=\"hm-image-slider-field\">\n <Slider\n min={0}\n max={100}\n step={1}\n largeStep={10}\n value={filter.strength}\n {...sliderGesture(gesture, (value) => ({\n type: \"image.setFilter\",\n filter: { preset: filter.preset, strength: Math.round(value) },\n }))}\n />\n </Field>\n ) : null}\n </section>\n );\n}\n","import { SegmentedControl } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useState } from \"react\";\nimport { ImageCropPanel } from \"../crop/CropPanel.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { ImageAdjustPanel } from \"./AdjustPanel.js\";\nimport { ImageFilterPanel } from \"./FilterPanel.js\";\n\ntype Panel = \"adjust\" | \"filters\";\n\n/**\n * The inspector (docs/adr/0007): the crop panel while cropping; otherwise\n * a choice of the Adjust and Filters panels, once an image is open.\n */\nexport function ImageInspector(): ReactNode {\n const { plan } = useImageDocument();\n const [editor] = useImageEditorState();\n const messages = useImageMessages();\n const [panel, setPanel] = useState<Panel>(\"adjust\");\n if (editor.tool === \"crop\") return <ImageCropPanel />;\n if (!plan) return null;\n return (\n <>\n <SegmentedControl\n label={messages.t(\"inspector.label\")}\n value={panel}\n size=\"small\"\n options={[\n { value: \"adjust\", label: messages.t(\"inspector.adjust\") },\n { value: \"filters\", label: messages.t(\"inspector.filters\") },\n ]}\n onValueChange={(value) => setPanel(value as Panel)}\n />\n {panel === \"adjust\" ? <ImageAdjustPanel /> : <ImageFilterPanel />}\n </>\n );\n}\n","import {\n type KeyboardEvent,\n type PointerEvent,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n} from \"react\";\nimport {\n aspectRatio,\n type CropHandle,\n compositionDeltaToSource,\n cropInComposition,\n dragHandle,\n handleInSource,\n moveCrop,\n nudgeCropOnScreen,\n} from \"../../core/model/crop.js\";\nimport { compositionSize } from \"../../core/model/geometry.js\";\nimport type { ImageCrop, ImagePlan } from \"../../core/model/plan.js\";\nimport type { ImageSize } from \"../../core/model/source.js\";\nimport { type ImageView, placement } from \"../../core/ports/image-renderer.js\";\nimport { useImageEditorState, useImageMessages } from \"../hooks.js\";\nimport { useCropActions } from \"./use-crop.js\";\n\nconst HANDLES: readonly CropHandle[] = [\"nw\", \"n\", \"ne\", \"e\", \"se\", \"s\", \"sw\", \"w\"];\nconst ARROWS = new Set([\"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\"]);\n\nexport interface CropFrameProps {\n /** The session's plan, whose crop is being changed. */\n readonly plan: ImagePlan;\n readonly source: ImageSize;\n /** The stage's view, in CSS pixels. */\n readonly view: ImageView;\n}\n\n/**\n * The crop frame (docs/adr/0007): DOM over the canvas, placed with the\n * renderer's geometry. One focusable group, named \"Crop area\" and described\n * by its size, which arrow keys move (Shift for 10 pixels, Alt to resize),\n * Enter applies and Escape cancels. Its handles are pointer targets only,\n * hidden from assistive technology: the keys and the crop panel's fields do\n * what they do.\n */\nexport function CropFrame(props: CropFrameProps): ReactNode {\n const { plan, source, view } = props;\n const [state] = useImageEditorState();\n const messages = useImageMessages();\n const actions = useCropActions();\n const frame = useRef<HTMLDivElement>(null);\n const describedBy = useId();\n const drag = useRef<\n | { pointer: number; x: number; y: number; start: ImageCrop; handle: CropHandle | \"move\" }\n | undefined\n >(undefined);\n\n // Cropping starts with focus on the frame.\n useEffect(() => {\n frame.current?.focus();\n }, []);\n\n const crop = state.crop;\n if (!crop) return null;\n const { orientation } = plan.base;\n const whole = { ...plan, base: { ...plan.base, crop: null } };\n const placed = placement(compositionSize(whole, source), view);\n // A stage with no size yet has nowhere to put the frame, and no scale for a drag.\n if (!(placed.scale > 0)) return null;\n const shown = cropInComposition(crop.pending, orientation, source);\n const ratio = aspectRatio(crop.aspect, source);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n actions.apply();\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n // Escape during a drag cancels the drag; otherwise, the crop.\n if (drag.current) {\n actions.update(drag.current.start);\n drag.current = undefined;\n } else {\n actions.cancel();\n }\n return;\n }\n if (!ARROWS.has(event.key)) return;\n event.preventDefault();\n // Handled here, so the editor's shortcuts don't also take the arrows.\n event.stopPropagation();\n actions.update(\n nudgeCropOnScreen(\n crop.pending,\n event.key as \"ArrowLeft\",\n event.shiftKey ? 10 : 1,\n event.altKey,\n orientation,\n source,\n ratio,\n ),\n );\n };\n\n const onPointerDown = (handle: CropHandle | \"move\") => (event: PointerEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n event.preventDefault();\n event.stopPropagation();\n frame.current?.focus();\n try {\n // Keeps the drag when the pointer leaves the frame; a pointer the\n // browser doesn't track can't be captured, and the drag still works.\n event.currentTarget.setPointerCapture(event.pointerId);\n } catch {}\n drag.current = {\n pointer: event.pointerId,\n x: event.clientX,\n y: event.clientY,\n start: crop.pending,\n handle,\n };\n };\n const onPointerMove = (event: PointerEvent<HTMLElement>) => {\n const current = drag.current;\n if (!current || current.pointer !== event.pointerId) return;\n // Screen pixels to composition pixels, then to the source's own axes.\n const moved = compositionDeltaToSource(\n (event.clientX - current.x) / placed.scale,\n (event.clientY - current.y) / placed.scale,\n orientation,\n source,\n );\n actions.update(\n current.handle === \"move\"\n ? moveCrop(current.start, moved.dx, moved.dy, source)\n : dragHandle(\n current.start,\n handleInSource(current.handle, orientation),\n moved.dx,\n moved.dy,\n source,\n ratio,\n ),\n );\n };\n const onPointerEnd = (event: PointerEvent<HTMLElement>) => {\n if (drag.current?.pointer !== event.pointerId) return;\n // A cancelled pointer, such as a lost capture, restores the crop the drag started from.\n if (event.type === \"pointercancel\") actions.update(drag.current.start);\n drag.current = undefined;\n };\n\n const style = {\n left: `${placed.x + shown.x * placed.scale}px`,\n top: `${placed.y + shown.y * placed.scale}px`,\n width: `${shown.width * placed.scale}px`,\n height: `${shown.height * placed.scale}px`,\n };\n const pointer = { onPointerMove, onPointerUp: onPointerEnd, onPointerCancel: onPointerEnd };\n return (\n // A positioned keyboard control over the canvas, not a form's fieldset (docs/adr/0007).\n // biome-ignore lint/a11y/useSemanticElements: a focusable group, not a fieldset\n <div\n ref={frame}\n className=\"hm-image-crop-frame\"\n role=\"group\"\n aria-label={messages.t(\"crop.frame\")}\n aria-describedby={describedBy}\n // biome-ignore lint/a11y/noNoninteractiveTabindex: the frame is a keyboard control, named and described\n tabIndex={0}\n style={style}\n onKeyDown={onKeyDown}\n onPointerDown={onPointerDown(\"move\")}\n {...pointer}\n >\n <span id={describedBy} hidden>\n {messages.t(\"crop.frameDescription\", {\n width: crop.pending.width,\n height: crop.pending.height,\n x: crop.pending.x,\n y: crop.pending.y,\n })}\n </span>\n {HANDLES.map((handle) => (\n <span\n key={handle}\n className=\"hm-image-crop-handle\"\n data-hm-handle={handle}\n aria-hidden=\"true\"\n onPointerDown={onPointerDown(handle)}\n {...pointer}\n />\n ))}\n </div>\n );\n}\n","import { Button, FileDropZone, Spinner } from \"@hussmartinez/ui/react\";\nimport { type ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { createImageRenderer } from \"../../adapters/image-renderer.js\";\nimport { compositionSize } from \"../../core/model/geometry.js\";\nimport type { ImageRenderer } from \"../../core/ports/image-renderer.js\";\nimport { CropFrame } from \"../crop/CropFrame.js\";\nimport {\n useImageDocument,\n useImageEditorState,\n useImageInternals,\n useImageView,\n} from \"../hooks.js\";\n\n/**\n * Props of {@link ImageStage}.\n *\n * @public\n */\nexport interface ImageStageProps {\n /** Extra classes on the stage. */\n readonly className?: string;\n}\n\n/**\n * The margin the image keeps inside the stage while cropping: half of the\n * largest handle target, 44 pixels on touch, so no handle is cut off where\n * the image meets the stage's edge (docs/adr/0007).\n */\nconst CROP_INSET = 24;\n\n/** The stage's size in CSS pixels, and the device pixel ratio. */\ninterface StageSize {\n readonly width: number;\n readonly height: number;\n readonly pixelRatio: number;\n}\n\n/** Follows an element's size and the device pixel ratio. */\nfunction useStageSize(element: HTMLElement | null): StageSize | undefined {\n const [size, setSize] = useState<StageSize>();\n useEffect(() => {\n if (!element) return;\n let ratioQuery: MediaQueryList | undefined;\n const measure = () => {\n const { width, height } = element.getBoundingClientRect();\n const pixelRatio = globalThis.devicePixelRatio || 1;\n setSize((current) =>\n current?.width === width && current.height === height && current.pixelRatio === pixelRatio\n ? current\n : { width, height, pixelRatio },\n );\n };\n // A change of devicePixelRatio, such as moving to another screen, ends the\n // current query's match: listen again for the new ratio.\n const watchRatio = () => {\n ratioQuery?.removeEventListener(\"change\", onRatio);\n ratioQuery = globalThis.matchMedia?.(`(resolution: ${globalThis.devicePixelRatio || 1}dppx)`);\n ratioQuery?.addEventListener(\"change\", onRatio);\n };\n const onRatio = () => {\n measure();\n watchRatio();\n };\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n measure();\n watchRatio();\n return () => {\n observer.disconnect();\n ratioQuery?.removeEventListener(\"change\", onRatio);\n };\n }, [element]);\n return size;\n}\n\n/**\n * The editor's stage (docs/adr/0007): the preview canvas, drawn by the\n * engine's render worker, with the designed states around it. With no image\n * it's a drop zone with a button to choose one; while an image opens, a\n * spinner with a cancel button over the current one; after a failure, the\n * catalogue's text for it.\n *\n * The canvas is `role=\"img\"`, named with the image's size, and isn't in the\n * tab order. It's created in an effect, never rendered by React: a canvas\n * transferred to a worker can't be transferred again, and StrictMode mounts\n * effects twice.\n *\n * @public\n */\nexport function ImageStage(props: ImageStageProps): ReactNode {\n const { engine, messages, opener } = useImageInternals();\n const snapshot = useImageDocument();\n const [view] = useImageView();\n const [frame, setFrame] = useState<HTMLDivElement | null>(null);\n const size = useStageSize(frame);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const rendererRef = useRef<{ renderer: ImageRenderer; attached: Promise<void> } | undefined>(\n undefined,\n );\n const [editorState] = useImageEditorState();\n const { source, status } = snapshot;\n const cropping = editorState.tool === \"crop\";\n const inset = cropping ? CROP_INSET : 0;\n // What the stage shows: while cropping, the whole image under the plan's\n // other edits; during a gesture, its transient plan; otherwise the plan.\n const plan = useMemo(() => {\n const committed = snapshot.plan;\n if (!committed) return null;\n if (cropping) return { ...committed, base: { ...committed.base, crop: null } };\n return editorState.preview ?? committed;\n }, [snapshot.plan, cropping, editorState.preview]);\n\n // The canvas and its renderer live and die with this effect.\n useEffect(() => {\n if (!frame) return;\n const canvas = document.createElement(\"canvas\");\n canvas.className = \"hm-image-stage-canvas\";\n canvas.setAttribute(\"role\", \"img\");\n frame.append(canvas);\n canvasRef.current = canvas;\n const renderer = createImageRenderer(engine);\n const attached = renderer.attach(canvas);\n // A failure to attach shows as an unrendered stage; renders report it.\n attached.catch(() => {});\n rendererRef.current = { renderer, attached };\n return () => {\n rendererRef.current = undefined;\n canvasRef.current = null;\n void renderer.destroy();\n canvas.remove();\n };\n }, [engine, frame]);\n\n // Its name says what it shows, and changes with the document, not each render.\n const composition = plan && source ? compositionSize(plan, source) : undefined;\n const shownWidth = composition?.width;\n const shownHeight = composition?.height;\n useEffect(() => {\n // The canvas appears in the commit after the frame does, so this runs\n // again then.\n const canvas = frame ? canvasRef.current : null;\n if (!canvas) return;\n canvas.hidden = shownWidth === undefined || shownHeight === undefined;\n if (shownWidth !== undefined && shownHeight !== undefined) {\n canvas.setAttribute(\n \"aria-label\",\n messages.t(\"editor.preview\", { width: shownWidth, height: shownHeight }),\n );\n } else {\n canvas.removeAttribute(\"aria-label\");\n }\n }, [shownWidth, shownHeight, messages, frame]);\n\n // Every change of plan, view or size renders; the renderer keeps the latest.\n useEffect(() => {\n const current = rendererRef.current;\n if (!current || !plan || !size || size.width < 1 || size.height < 1) return;\n const { renderer, attached } = current;\n void attached\n .then(() =>\n renderer.render(plan, {\n width: size.width,\n height: size.height,\n pixelRatio: size.pixelRatio,\n zoom: view.zoom,\n pan: view.pan,\n inset,\n }),\n )\n .catch(() => {\n // A render that fails leaves the previous frame; the session's state is unaffected.\n });\n }, [plan, view, size, inset]);\n\n const className = [\"hm-image-stage\", props.className].filter(Boolean).join(\" \");\n return (\n <div className={className} data-status={status}>\n <div className=\"hm-image-stage-frame\" ref={setFrame} />\n {cropping && snapshot.plan && source && size ? (\n <div className=\"hm-image-stage-overlay\">\n <CropFrame\n plan={snapshot.plan}\n source={source}\n view={{\n width: size.width,\n height: size.height,\n pixelRatio: 1,\n zoom: view.zoom,\n pan: view.pan,\n inset,\n }}\n />\n </div>\n ) : null}\n {status === \"empty\" && !snapshot.opening ? (\n <FileDropZone\n className=\"hm-image-stage-drop\"\n accept=\"image/*\"\n onFiles={(files) => {\n const [file] = files;\n if (file) void opener.open(file);\n }}\n buttonLabel={messages.t(\"editor.choose\")}\n hint={messages.t(\"editor.dropHint\")}\n >\n <p className=\"hm-image-stage-empty\">{messages.t(\"editor.empty\")}</p>\n </FileDropZone>\n ) : null}\n {snapshot.opening ? (\n <div className=\"hm-image-stage-opening\">\n <Spinner label={messages.t(\"editor.opening\")} />\n <Button variant=\"secondary\" onClick={() => opener.cancel()}>\n {messages.t(\"editor.cancel\")}\n </Button>\n </div>\n ) : null}\n {snapshot.error ? (\n <p className=\"hm-image-stage-error\" role=\"alert\">\n {messages.error(snapshot.error)}\n </p>\n ) : null}\n </div>\n );\n}\n","import type { ShortcutRegistry, ToolRegistry } from \"@hussmartinez/sdk-core\";\nimport { IconButton, type IconComponent, Toolbar, ToolbarGroup } from \"@hussmartinez/ui/react\";\nimport type { ReactNode } from \"react\";\nimport type { ImageTool, ImageToolContext } from \"../../features/tool-types.js\";\nimport { useImageDocument, useImageEditorState, useImageMessages } from \"../hooks.js\";\n\n/**\n * Props of {@link ImageToolbar}.\n *\n * @public\n */\nexport interface ImageToolbarProps {\n /** The editor's tools, from `createToolRegistry`. */\n readonly registry: ToolRegistry<ImageTool>;\n /** The editor's shortcuts, for each button's `aria-keyshortcuts`. */\n readonly shortcuts?: ShortcutRegistry;\n /** What the tools run against. */\n readonly context: ImageToolContext;\n /** Icon components by name, over the SDK's own. */\n readonly icons: Readonly<Record<string, IconComponent>>;\n readonly className?: string;\n}\n\n/**\n * The editor's toolbar (docs/adr/0007): ui's Toolbar, one group per toolbar\n * group of the registry, one button per tool, disabled when it can't run,\n * with the tool's shortcuts as `aria-keyshortcuts`.\n *\n * @public\n */\nexport function ImageToolbar(props: ImageToolbarProps): ReactNode {\n const { registry, shortcuts, context, icons } = props;\n const messages = useImageMessages();\n const snapshot = useImageDocument();\n const [editor] = useImageEditorState();\n const state = { snapshot, editor };\n const t = messages.t as (key: string) => string;\n return (\n <Toolbar label={messages.t(\"toolbar.label\")} className={props.className}>\n {registry.toolbar.map((group) => (\n <ToolbarGroup\n key={group.map((tool) => tool.id).join(\" \")}\n label={t(`toolbar.groups.${group[0]?.group ?? \"other\"}`)}\n >\n {group\n .filter((tool) => tool.isAvailable?.(state) ?? true)\n .map((tool) => {\n const Icon = icons[tool.icon];\n const keys = shortcuts?.ariaKeyShortcuts(tool.id);\n return (\n <IconButton\n key={tool.id}\n data-tool={tool.id}\n label={t(tool.label)}\n icon={Icon ? <Icon /> : null}\n disabled={!(tool.isEnabled?.(state) ?? true)}\n {...(tool.isActive ? { pressed: tool.isActive(state) } : {})}\n {...(keys ? { \"aria-keyshortcuts\": keys } : {})}\n onClick={() => void tool.run(context)}\n />\n );\n })}\n </ToolbarGroup>\n ))}\n </Toolbar>\n );\n}\n","import {\n CropIcon,\n DownloadIcon,\n FitIcon,\n FlipHorizontalIcon,\n FlipVerticalIcon,\n type IconComponent,\n OpenIcon,\n RedoIcon,\n RotateLeftIcon,\n RotateRightIcon,\n SearchIcon,\n UndoIcon,\n ZoomInIcon,\n ZoomOutIcon,\n} from \"@hussmartinez/ui/react\";\n\n/**\n * The components of the icons the editor's tools name, from ui's set\n * (sdk-core ADR 0030). A host's `icons` prop overrides any of them.\n *\n * @public\n */\nexport const imageIcons: Readonly<Record<string, IconComponent>> = {\n open: OpenIcon,\n undo: UndoIcon,\n redo: RedoIcon,\n \"rotate-left\": RotateLeftIcon,\n \"rotate-right\": RotateRightIcon,\n \"zoom-in\": ZoomInIcon,\n \"zoom-out\": ZoomOutIcon,\n fit: FitIcon,\n crop: CropIcon,\n export: DownloadIcon,\n \"flip-horizontal\": FlipHorizontalIcon,\n \"flip-vertical\": FlipVerticalIcon,\n search: SearchIcon,\n};\n","import { createShortcutRegistry, createToolRegistry } from \"@hussmartinez/sdk-core\";\nimport { AnnouncerProvider, useAnnounce, usePlatform } from \"@hussmartinez/ui/react\";\nimport {\n type ForwardedRef,\n forwardRef,\n type KeyboardEvent,\n type ReactNode,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { ImageSessionEvent } from \"../../core/session/session.js\";\nimport type { ImageToolContext } from \"../../features/tool-types.js\";\nimport { DEFAULT_TOOLBAR, imageTools } from \"../../features/tools.js\";\nimport { ImageExportDialog } from \"../export/ExportDialog.js\";\nimport { useImageDocument, useImageEditorState, useImageInternals } from \"../hooks.js\";\nimport { ImageEditorProvider } from \"../ImageEditorProvider.js\";\nimport { ImageInspector } from \"../panels/Inspector.js\";\nimport { ImageStage } from \"../stage/ImageStage.js\";\nimport { ImageToolbar } from \"../toolbar/ImageToolbar.js\";\nimport { imageIcons } from \"../toolbar/icons.js\";\nimport type { ImageEditorHandle, ImageEditorProps } from \"./types.js\";\n\nconst join = (...names: (string | undefined | false)[]) => names.filter(Boolean).join(\" \");\n\ninterface BodyProps\n extends Pick<\n ImageEditorProps,\n | \"initialFile\"\n | \"plan\"\n | \"onChange\"\n | \"tools\"\n | \"toolbar\"\n | \"icons\"\n | \"className\"\n | \"classNames\"\n | \"unstyled\"\n | \"onExport\"\n > {\n readonly handle: ForwardedRef<ImageEditorHandle>;\n readonly events: { current: ((event: ImageSessionEvent) => void) | undefined };\n}\n\nfunction ImageEditorBody(props: BodyProps): ReactNode {\n const { initialFile, onChange, classNames = {}, unstyled = false, handle, events } = props;\n const { session, messages, view, editor, opener } = useImageInternals();\n const snapshot = useImageDocument();\n const announce = useAnnounce();\n const root = useRef<HTMLElement>(null);\n const input = useRef<HTMLInputElement>(null);\n const latestOnChange = useRef(onChange);\n latestOnChange.current = onChange;\n\n const registry = useMemo(\n () =>\n createToolRegistry(imageTools, {\n ...(props.tools ? { tools: props.tools } : {}),\n toolbar:\n props.toolbar ??\n DEFAULT_TOOLBAR.map((group) =>\n group.filter((id) => !props.tools || props.tools.includes(id)),\n ),\n }),\n [props.tools, props.toolbar],\n );\n // \"other\" on the server and during hydration, then the device's own keys.\n const platform = usePlatform();\n const shortcuts = useMemo(\n () => createShortcutRegistry({ platform, tools: registry.tools }),\n [platform, registry],\n );\n const context: ImageToolContext = useMemo(\n () => ({ session, view, editor, chooseFile: () => input.current?.click() }),\n [session, view, editor],\n );\n const icons = useMemo(() => ({ ...imageIcons, ...props.icons }), [props.icons]);\n\n useImperativeHandle(\n handle,\n () => ({\n session,\n open: (file) => opener.open(file),\n execute: (commands) => session.execute(commands),\n export: (format) => session.export(format),\n undo: () => {\n session.undo();\n },\n redo: () => {\n session.redo();\n },\n }),\n [session, opener],\n );\n\n // The host's first image opens on mount; a later one replaces it.\n const initial = useRef(initialFile);\n useEffect(() => {\n if (initial.current) void opener.open(initial.current);\n }, [opener]);\n\n // Committed changes reach the host, never a gesture's transient plans.\n useEffect(() => {\n let before = session.getSnapshot().plan;\n return session.subscribe(() => {\n const after = session.getSnapshot().plan;\n if (after === before) return;\n before = after;\n if (after) latestOnChange.current?.(after);\n });\n }, [session]);\n\n // Opens, undos and redos reach screen readers, politely.\n useEffect(() => {\n events.current = (event) => {\n if (event.outcome !== \"done\") return;\n const action = event.commands[0];\n const name = action ? messages.t(`actions.${action}`) : \"\";\n if (event.type === \"undo\") announce(messages.t(\"editor.undid\", { action: name }));\n if (event.type === \"redo\") announce(messages.t(\"editor.redid\", { action: name }));\n if (event.type === \"open\") {\n const source = session.getSnapshot().source;\n if (source)\n announce(messages.t(\"editor.opened\", { width: source.width, height: source.height }));\n }\n };\n return () => {\n events.current = undefined;\n };\n }, [announce, events, messages, session]);\n\n // After an open, focus moves to the first tool it enabled, when focus was\n // in the editor or nowhere; focus elsewhere on the host's page stays.\n const previous = useRef(snapshot.source?.id);\n useEffect(() => {\n const id = snapshot.source?.id;\n if (id === previous.current) return;\n previous.current = id;\n if (!id) return;\n const active = document.activeElement;\n const ours = active === null || active === document.body || root.current?.contains(active);\n if (!ours) return;\n const buttons = root.current?.querySelectorAll<HTMLButtonElement>(\n \".hm-image-editor-toolbar button:not([disabled])\",\n );\n const next = [...(buttons ?? [])].find((button) => button.dataset[\"tool\"] !== \"image.open\");\n next?.focus();\n }, [snapshot.source?.id]);\n\n // A host's plan is applied when it changes: one undoable step of the\n // commands that reach it. A plan for another image waits for that image.\n const hostPlan = props.plan;\n const openSource = snapshot.plan?.base.source;\n useEffect(() => {\n if (!hostPlan || openSource !== hostPlan.base.source) return;\n try {\n session.applyPlan(hostPlan);\n } catch {\n // In the snapshot: the stage shows it.\n }\n }, [hostPlan, session, openSource]);\n\n // Cropping and the export dialog end when another image opens.\n const sourceId = snapshot.source?.id;\n useEffect(() => {\n if (sourceId === undefined) return;\n editor.set((state) =>\n state.tool === null && state.dialog === null\n ? state\n : { ...state, tool: null, crop: null, dialog: null },\n );\n }, [editor, sourceId]);\n\n // Focus returns to where it was when cropping started: the crop button, or\n // whatever had focus when its shortcut was pressed (docs/adr/0007).\n const [{ tool }] = useImageEditorState();\n const returnTo = useRef<HTMLElement | null>(null);\n const previousTool = useRef(tool);\n useEffect(\n () =>\n editor.subscribe(() => {\n if (editor.getSnapshot().tool === \"crop\" && previousTool.current !== \"crop\") {\n const active = document.activeElement;\n returnTo.current =\n active instanceof HTMLElement && root.current?.contains(active) ? active : null;\n }\n }),\n [editor],\n );\n useEffect(() => {\n if (previousTool.current === tool) return;\n const was = previousTool.current;\n previousTool.current = tool;\n if (was !== \"crop\") return;\n const target = returnTo.current?.isConnected\n ? returnTo.current\n : root.current?.querySelector<HTMLElement>('[data-tool=\"image.crop\"]');\n target?.focus();\n }, [tool]);\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n // The root bounds the search for a modal dialog: keys from one inside the\n // editor, such as export's, stay its own, while a host's dialog holding\n // the whole editor doesn't stop its shortcuts (sdk-core 0.4.2).\n const id = shortcuts.match(event.nativeEvent, { root: event.currentTarget });\n const tool = id ? registry.get(id) : undefined;\n if (!tool) return;\n const state = { snapshot: session.getSnapshot(), editor: editor.getSnapshot() };\n if (!(tool.isEnabled?.(state) ?? true)) return;\n event.preventDefault();\n void tool.run(context);\n };\n\n return (\n // The root takes the editor's shortcuts while focus is inside it, never\n // on window (WCAG 2.1.4, sdk-core ADR 0030). A named section is a region\n // landmark, so the editor is easy to find on a host's page.\n <section\n ref={root}\n className={join(\n \"hm-image-editor\",\n !unstyled && \"hm-image-editor--styled\",\n props.className,\n classNames.root,\n )}\n onKeyDown={onKeyDown}\n aria-label={messages.t(\"editor.label\")}\n >\n <input\n ref={input}\n type=\"file\"\n accept=\"image/*\"\n hidden\n tabIndex={-1}\n onChange={(event) => {\n const file = event.currentTarget.files?.[0];\n event.currentTarget.value = \"\";\n if (file) void opener.open(file);\n }}\n />\n <div className=\"hm-image-editor-layout\">\n <ImageToolbar\n registry={registry}\n shortcuts={shortcuts}\n context={context}\n icons={icons}\n className={join(\"hm-image-editor-toolbar\", classNames.toolbar)}\n />\n <ImageStage className={join(\"hm-image-editor-stage\", classNames.stage)} />\n <div className={join(\"hm-image-editor-inspector\", classNames.inspector)}>\n <ImageInspector />\n </div>\n </div>\n <ImageExportDialog {...(props.onExport ? { onExport: props.onExport } : {})} />\n </section>\n );\n}\n\n/**\n * The image editor (docs/adr/0007): a toolbar and a stage over an image\n * session, with the family's shortcuts while focus is inside it. It creates\n * its engine, processor and session unless you pass them, and destroys only\n * what it created. Import `@hussmartinez/ui/styles.css` once, then this\n * package's `styles.css`: ui's stylesheet carries the focus rings and target\n * sizes the editor's accessibility relies on (sdk-core ADR 0036).\n *\n * @example\n * ```tsx\n * <ImageEditor initialFile={file} onChange={(plan) => save(plan)} />\n * ```\n *\n * @public\n */\nexport const ImageEditor = forwardRef(function ImageEditor(\n props: ImageEditorProps,\n ref: ForwardedRef<ImageEditorHandle>,\n): ReactNode {\n const {\n initialFile,\n plan,\n onChange,\n tools,\n toolbar,\n icons,\n className,\n classNames,\n unstyled,\n onEvent,\n onExport,\n ...provider\n } = props;\n // The editor listens to the session's events for its announcements, and\n // passes them on to the host's handler.\n const events = useRef<((event: ImageSessionEvent) => void) | undefined>(undefined);\n const latestOnEvent = useRef(onEvent);\n latestOnEvent.current = onEvent;\n const [onSessionEvent] = useMemo(\n () => [\n (event: ImageSessionEvent) => {\n events.current?.(event);\n latestOnEvent.current?.(event);\n },\n ],\n [],\n );\n return (\n <ImageEditorProvider {...provider} onEvent={onSessionEvent}>\n <AnnouncerProvider>\n <ImageEditorBody\n handle={ref}\n events={events}\n {...(initialFile ? { initialFile } : {})}\n {...(onChange ? { onChange } : {})}\n {...(plan ? { plan } : {})}\n {...(tools ? { tools } : {})}\n {...(toolbar ? { toolbar } : {})}\n {...(icons ? { icons } : {})}\n {...(className ? { className } : {})}\n {...(classNames ? { classNames } : {})}\n {...(unstyled === undefined ? {} : { unstyled })}\n {...(onExport ? { onExport } : {})}\n />\n </AnnouncerProvider>\n </ImageEditorProvider>\n );\n});\n"],"mappings":";;;;;;AAuCA,IAAa,eAAe,EAAE,eAAwC,SAAS,SAAS;;ACjCxF,SAAS,UAAU,EAAE,SAAS,UAAkC;CAC9D,MAAM,EAAE,MAAM,WAAW,QAAQ,YAAY;CAC7C,IAAI,CAAC,QAAQ,CAAC,QAAQ;CACtB,OAAO,KAAK,WAAW;EACrB,GAAG;EACH,MAAM;EACN,MAAM;GAAE,SAAS,KAAK,KAAK,QAAQ,UAAU,MAAM;GAAG,QAAQ;EAAO;CACvE,EAAE;AACJ;AAGA,IAAa,WAAsC,2BAAW;CAC5D,IAAI;CACJ,OAAO;CACP,MAAM;CACN,OAAO;CACP,WAAW;CACX,WAAW,EAAE,aAAa,OAAO,SAAS;CAC1C,MAAM,YAAY;EAChB,IAAI,QAAQ,OAAO,YAAY,CAAC,CAAC,SAAS,QAAQ;EAClD,UAAU,OAAO;CACnB;CACA,WAAW,CAAC,GAAG;AACjB,CAAC;AAED,SAAS,KAAK,EAAE,WAA6B,MAA+B;CAC1E,MAAM,OAAO,QAAQ,YAAY,CAAC,CAAC;CACnC,IAAI,CAAC,MAAM;CACX,MAAM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