@aphrody/koharu-ui 0.0.0-stage → 0.1.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.
Files changed (123) hide show
  1. package/README.md +37 -2
  2. package/package.json +70 -4
  3. package/src/assets/NotoSansCJK-VF.otf +0 -0
  4. package/src/assets/OFL.txt +92 -0
  5. package/src/components/ClientOnly.tsx +21 -0
  6. package/src/components/ShenronExportPanel.tsx +213 -0
  7. package/src/components/app/AboutDialog.tsx +64 -0
  8. package/src/components/app/KoharuApp.tsx +58 -0
  9. package/src/components/app/StartupView.tsx +67 -0
  10. package/src/components/app/TitleBar.tsx +322 -0
  11. package/src/components/app/Updater.tsx +143 -0
  12. package/src/components/app/WindowChrome.tsx +137 -0
  13. package/src/components/controls/ColorSampling.tsx +70 -0
  14. package/src/components/controls/ColorWell.tsx +139 -0
  15. package/src/components/controls/CommitTextarea.tsx +63 -0
  16. package/src/components/controls/FontPicker.tsx +543 -0
  17. package/src/components/controls/ModelPicker.tsx +178 -0
  18. package/src/components/controls/OutputPicker.tsx +170 -0
  19. package/src/components/editor/ActivityCenter.tsx +234 -0
  20. package/src/components/editor/AgentPanel.tsx +352 -0
  21. package/src/components/editor/CanvasCommandBar.tsx +38 -0
  22. package/src/components/editor/CanvasOverlay.tsx +194 -0
  23. package/src/components/editor/CanvasWorkspace.tsx +947 -0
  24. package/src/components/editor/Editor.tsx +56 -0
  25. package/src/components/editor/InferenceControl.tsx +457 -0
  26. package/src/components/editor/Inspector.tsx +1073 -0
  27. package/src/components/editor/PageRail.tsx +581 -0
  28. package/src/components/editor/ResourceMonitor.tsx +151 -0
  29. package/src/components/editor/RightSidebar.tsx +50 -0
  30. package/src/components/editor/SelectionControls.tsx +184 -0
  31. package/src/components/editor/StatusBar.tsx +41 -0
  32. package/src/components/editor/ToolBar.tsx +182 -0
  33. package/src/components/editor/useCanvas.ts +194 -0
  34. package/src/components/preferences/GenerationPreferences.tsx +118 -0
  35. package/src/components/preferences/KoharuSettings.tsx +229 -0
  36. package/src/components/preferences/PipelinePreferences.tsx +173 -0
  37. package/src/components/preferences/PreferenceFields.tsx +149 -0
  38. package/src/components/preferences/ProviderPreferences.tsx +173 -0
  39. package/src/components/preferences/SettingsPage.tsx +336 -0
  40. package/src/components/preferences/TranslationPreferences.tsx +187 -0
  41. package/src/components/preferences/TypesettingPreferences.tsx +142 -0
  42. package/src/components/preferences/models.ts +103 -0
  43. package/src/components/start/StartView.tsx +277 -0
  44. package/src/index.ts +59 -0
  45. package/src/internal/components/accordion.tsx +72 -0
  46. package/src/internal/components/alert-dialog.tsx +189 -0
  47. package/src/internal/components/alert.tsx +76 -0
  48. package/src/internal/components/aspect-ratio.tsx +22 -0
  49. package/src/internal/components/attachment.tsx +207 -0
  50. package/src/internal/components/avatar.tsx +109 -0
  51. package/src/internal/components/badge.tsx +52 -0
  52. package/src/internal/components/breadcrumb.tsx +125 -0
  53. package/src/internal/components/bubble.tsx +128 -0
  54. package/src/internal/components/button-group.tsx +87 -0
  55. package/src/internal/components/button.tsx +58 -0
  56. package/src/internal/components/card.tsx +103 -0
  57. package/src/internal/components/checkbox.tsx +29 -0
  58. package/src/internal/components/collapsible.tsx +21 -0
  59. package/src/internal/components/combobox.tsx +298 -0
  60. package/src/internal/components/context-menu.tsx +272 -0
  61. package/src/internal/components/dialog.tsx +162 -0
  62. package/src/internal/components/direction.tsx +6 -0
  63. package/src/internal/components/drawer.tsx +230 -0
  64. package/src/internal/components/dropdown-menu.tsx +278 -0
  65. package/src/internal/components/empty.tsx +104 -0
  66. package/src/internal/components/field.tsx +238 -0
  67. package/src/internal/components/hover-card.tsx +52 -0
  68. package/src/internal/components/input-group.tsx +158 -0
  69. package/src/internal/components/input.tsx +20 -0
  70. package/src/internal/components/item.tsx +201 -0
  71. package/src/internal/components/kbd.tsx +26 -0
  72. package/src/internal/components/label.tsx +20 -0
  73. package/src/internal/components/marker.tsx +71 -0
  74. package/src/internal/components/menubar.tsx +280 -0
  75. package/src/internal/components/message.tsx +92 -0
  76. package/src/internal/components/native-select.tsx +61 -0
  77. package/src/internal/components/navigation-menu.tsx +168 -0
  78. package/src/internal/components/number-field.tsx +68 -0
  79. package/src/internal/components/pagination.tsx +130 -0
  80. package/src/internal/components/popover.tsx +91 -0
  81. package/src/internal/components/progress.tsx +83 -0
  82. package/src/internal/components/radio-group.tsx +38 -0
  83. package/src/internal/components/resizable.tsx +50 -0
  84. package/src/internal/components/scroll-area.tsx +88 -0
  85. package/src/internal/components/select.tsx +191 -0
  86. package/src/internal/components/separator.tsx +25 -0
  87. package/src/internal/components/sheet.tsx +140 -0
  88. package/src/internal/components/sidebar.tsx +723 -0
  89. package/src/internal/components/skeleton.tsx +13 -0
  90. package/src/internal/components/slider.tsx +56 -0
  91. package/src/internal/components/spinner.tsx +10 -0
  92. package/src/internal/components/switch.tsx +32 -0
  93. package/src/internal/components/table.tsx +116 -0
  94. package/src/internal/components/tabs.tsx +82 -0
  95. package/src/internal/components/textarea.tsx +18 -0
  96. package/src/internal/components/toast.tsx +235 -0
  97. package/src/internal/components/toggle-group.tsx +89 -0
  98. package/src/internal/components/toggle.tsx +45 -0
  99. package/src/internal/components/tooltip.tsx +67 -0
  100. package/src/internal/hooks/use-mobile.ts +19 -0
  101. package/src/internal/lib/utils.ts +6 -0
  102. package/src/internal/styles/globals.css +73 -0
  103. package/src/lib/backend.ts +85 -0
  104. package/src/lib/document.ts +46 -0
  105. package/src/lib/geometry.ts +272 -0
  106. package/src/lib/i18n.ts +54 -0
  107. package/src/lib/queries.ts +110 -0
  108. package/src/lib/store.ts +191 -0
  109. package/src/lib/translation.ts +35 -0
  110. package/src/locales/en-US/translation.json +536 -0
  111. package/src/locales/es-ES/translation.json +536 -0
  112. package/src/locales/ja-JP/translation.json +536 -0
  113. package/src/locales/ko-KR/translation.json +536 -0
  114. package/src/locales/pt-BR/translation.json +536 -0
  115. package/src/locales/ru-RU/translation.json +536 -0
  116. package/src/locales/tr-TR/translation.json +536 -0
  117. package/src/locales/zh-CN/translation.json +536 -0
  118. package/src/locales/zh-TW/translation.json +536 -0
  119. package/src/navigation.ts +28 -0
  120. package/src/providers.tsx +132 -0
  121. package/src/shenron-pipeline-env.d.ts +14 -0
  122. package/src/styles.css +246 -0
  123. package/tsconfig.json +21 -0
package/README.md CHANGED
@@ -1,3 +1,38 @@
1
- # Temporary Holding Version
1
+ # @aphrody/koharu-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Koharu's React editor, project browser, settings, controls, localization, and
4
+ browser interaction helpers are owned here. The application host supplies the
5
+ Koharu command transport and canvas WASM through `@aphrody/koharu-bridge`.
6
+
7
+ The package exports product components under `components/*`, editor state and
8
+ hooks under `lib/*`, nine locale dictionaries under `locales/*`, and its M3 theme
9
+ sheet as `styles.css`. The editor uses canonical `@aphrody/m3-primitives`
10
+ where the component contract fits. Remaining Koharu-specific controls are
11
+ internal until they can be ported without changing editor behavior.
12
+
13
+ The shell in `apps/koharu/editor` consumes this package. The host imports
14
+ its own Tailwind and M3 tokens before opting into `@aphrody/koharu-ui/styles.css`.
15
+ That stylesheet scopes its UI rules to `[data-koharu-ui]` and portal rules to
16
+ `[data-koharu-ui-layer]`. The package includes the full Noto Sans CJK variable
17
+ font for Japanese, Korean and Chinese text. The font is under SIL OFL 1.1; see
18
+ `src/assets/OFL.txt`.
19
+
20
+ `./navigation` exports the settings tabs, editor side panels, and title menu
21
+ sections used by the components. `./providers` exports the React state and
22
+ query providers. Preferences, shortcuts, project navigation and editor controls
23
+ are available from the corresponding component and `lib/*` subpaths.
24
+
25
+ The extracted editor still depends on `@aphrody/koharu-bridge` and its original
26
+ generated Koharu command contract. Its JavaScript API and opener/process
27
+ plugins now use Tauri v2, matching the Aphrody desktop dependency family.
28
+ It can be packed independently of the original
29
+ Koharu checkout, but the unpublished bridge package must be supplied to a
30
+ consumer from a local archive or a registry. Aphrody `app-ui` uses Tauri v2
31
+ and does not mount the editor. Its Settings > Koharu section instead uses
32
+ `@aphrody/koharu-sdk/settings` with the native `koharu_rpc` broker to read/save
33
+ pipeline, translation, provider credentials and typography settings. The
34
+ native broker does not implement every command used by the extracted editor.
35
+ The standalone Koharu Rust host still has its own Tauri v3 alpha dependency;
36
+ this frontend dependency alignment does not prove that host runs with the v2
37
+ JavaScript packages.
38
+ Generic Aphrody navigation and shell components remain owned by `@aphrody/app-ui`.
package/package.json CHANGED
@@ -1,6 +1,72 @@
1
1
  {
2
2
  "name": "@aphrody/koharu-ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Koharu editor, controls, preferences, resources and canvas UI for Aphrody hosts",
5
+ "license": "MIT OR Apache-2.0",
6
+ "type": "module",
7
+ "main": "./src/index.ts",
8
+ "types": "./src/index.ts",
9
+ "exports": {
10
+ ".": {
11
+ "bun": "./src/index.ts",
12
+ "import": "./src/index.ts",
13
+ "types": "./src/index.ts",
14
+ "default": "./src/index.ts"
15
+ },
16
+ "./providers": "./src/providers.tsx",
17
+ "./navigation": "./src/navigation.ts",
18
+ "./components/editor/useCanvas": "./src/components/editor/useCanvas.ts",
19
+ "./components/preferences/models": "./src/components/preferences/models.ts",
20
+ "./components/*": "./src/components/*.tsx",
21
+ "./lib/*": "./src/lib/*.ts",
22
+ "./locales/*": "./src/locales/*",
23
+ "./assets/NotoSansCJK-VF.otf": "./src/assets/NotoSansCJK-VF.otf",
24
+ "./assets/OFL.txt": "./src/assets/OFL.txt",
25
+ "./styles.css": "./src/styles.css",
26
+ "./components/preferences/KoharuSettings": "./src/components/preferences/KoharuSettings.tsx"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "typecheck": "tsc --noEmit"
33
+ },
34
+ "dependencies": {
35
+ "@aphrody/api": "3.0.0-alpha.2",
36
+ "@aphrody/koharu-bridge": "0.1.0",
37
+ "@aphrody/koharu-sdk": "0.1.0",
38
+ "@aphrody/m3-primitives": "3.3.4",
39
+ "@aphrody/plugin-opener": "3.0.0-alpha.2",
40
+ "@base-ui/react": "^1.8.0",
41
+ "@shenron/pipeline": "0.1.0",
42
+ "@tanstack/react-query": "^5.104.0",
43
+ "@tanstack/react-virtual": "^3.14.13",
44
+ "class-variance-authority": "^0.7.1",
45
+ "clsx": "^2.1.1",
46
+ "i18next": "^26.4.2",
47
+ "i18next-browser-languagedetector": "^8.2.1",
48
+ "i18next-localstorage-backend": "^4.3.2",
49
+ "lucide-react": "^1.48.0",
50
+ "next-themes": "^0.4.6",
51
+ "react-colorful": "^5.8.1",
52
+ "react-i18next": "^17.0.15",
53
+ "react-markdown": "^10.1.0",
54
+ "react-resizable-panels": "^4.14.1",
55
+ "remark-gfm": "^4.0.1",
56
+ "tailwind-merge": "^3.7.0",
57
+ "zustand": "^5.0.15"
58
+ },
59
+ "devDependencies": {
60
+ "@types/react": "^19.3.0",
61
+ "@types/react-dom": "^19.3.0",
62
+ "react": "^19.3.0",
63
+ "react-dom": "^19.3.0"
64
+ },
65
+ "peerDependencies": {
66
+ "react": "^19.3.0",
67
+ "react-dom": "^19.3.0"
68
+ },
69
+ "engines": {
70
+ "bun": ">=1.4.2"
71
+ }
72
+ }
Binary file
@@ -0,0 +1,92 @@
1
+ This Font Software is licensed under the SIL Open Font License,
2
+ Version 1.1.
3
+
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+ -----------------------------------------------------------
8
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9
+ -----------------------------------------------------------
10
+
11
+ PREAMBLE
12
+ The goals of the Open Font License (OFL) are to stimulate worldwide
13
+ development of collaborative font projects, to support the font
14
+ creation efforts of academic and linguistic communities, and to
15
+ provide a free and open framework in which fonts may be shared and
16
+ improved in partnership with others.
17
+
18
+ The OFL allows the licensed fonts to be used, studied, modified and
19
+ redistributed freely as long as they are not sold by themselves. The
20
+ fonts, including any derivative works, can be bundled, embedded,
21
+ redistributed and/or sold with any software provided that any reserved
22
+ names are not used by derivative works. The fonts and derivatives,
23
+ however, cannot be released under any other type of license. The
24
+ requirement for fonts to remain under this license does not apply to
25
+ any document created using the fonts or their derivatives.
26
+
27
+ DEFINITIONS
28
+ "Font Software" refers to the set of files released by the Copyright
29
+ Holder(s) under this license and clearly marked as such. This may
30
+ include source files, build scripts and documentation.
31
+
32
+ "Reserved Font Name" refers to any names specified as such after the
33
+ copyright statement(s).
34
+
35
+ "Original Version" refers to the collection of Font Software
36
+ components as distributed by the Copyright Holder(s).
37
+
38
+ "Modified Version" refers to any derivative made by adding to,
39
+ deleting, or substituting -- in part or in whole -- any of the
40
+ components of the Original Version, by changing formats or by porting
41
+ the Font Software to a new environment.
42
+
43
+ "Author" refers to any designer, engineer, programmer, technical
44
+ writer or other person who contributed to the Font Software.
45
+
46
+ PERMISSION & CONDITIONS
47
+ Permission is hereby granted, free of charge, to any person obtaining
48
+ a copy of the Font Software, to use, study, copy, merge, embed,
49
+ modify, redistribute, and sell modified and unmodified copies of the
50
+ Font Software, subject to the following conditions:
51
+
52
+ 1) Neither the Font Software nor any of its individual components, in
53
+ Original or Modified Versions, may be sold by itself.
54
+
55
+ 2) Original or Modified Versions of the Font Software may be bundled,
56
+ redistributed and/or sold with any software, provided that each copy
57
+ contains the above copyright notice and this license. These can be
58
+ included either as stand-alone text files, human-readable headers or
59
+ in the appropriate machine-readable metadata fields within text or
60
+ binary files as long as those fields can be easily viewed by the user.
61
+
62
+ 3) No Modified Version of the Font Software may use the Reserved Font
63
+ Name(s) unless explicit written permission is granted by the
64
+ corresponding Copyright Holder. This restriction only applies to the
65
+ primary font name as presented to the users.
66
+
67
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68
+ Software shall not be used to promote, endorse or advertise any
69
+ Modified Version, except to acknowledge the contribution(s) of the
70
+ Copyright Holder(s) and the Author(s) or with their explicit written
71
+ permission.
72
+
73
+ 5) The Font Software, modified or unmodified, in part or in whole,
74
+ must be distributed entirely under this license, and must not be
75
+ distributed under any other license. The requirement for fonts to
76
+ remain under this license does not apply to any document created using
77
+ the Font Software.
78
+
79
+ TERMINATION
80
+ This license becomes null and void if any of the above conditions are
81
+ not met.
82
+
83
+ DISCLAIMER
84
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,21 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useState, type ReactNode } from 'react'
4
+
5
+ export function ClientOnly({
6
+ children,
7
+ fallback = null,
8
+ }: {
9
+ children: ReactNode
10
+ fallback?: ReactNode
11
+ }) {
12
+ const [mounted, setMounted] = useState(false)
13
+
14
+ useEffect(() => {
15
+ setMounted(true)
16
+ }, [])
17
+
18
+ return mounted ? <>{children}</> : <>{fallback}</>
19
+ }
20
+
21
+ export default ClientOnly
@@ -0,0 +1,213 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Export native Koharu page results to Shenron as unreviewed manga candidates.
3
+ import { useEffect, useState } from "react";
4
+ import {
5
+ mapNativeKoharuPageResult,
6
+ toMangaReviewCandidateInput,
7
+ type KoharuMangaPageSource,
8
+ type MangaCandidateBinding,
9
+ } from "@shenron/pipeline/koharu";
10
+
11
+ export interface ShenronExportHost {
12
+ isTauri(): boolean;
13
+ invoke<T>(command: string, args: Record<string, unknown>): Promise<T | null>;
14
+ }
15
+
16
+ interface PageSummary {
17
+ id: string;
18
+ label: string;
19
+ size: { width: number; height: number };
20
+ }
21
+
22
+ interface Binding {
23
+ mangaPageId: string;
24
+ sourceSha256: string;
25
+ image: string;
26
+ }
27
+
28
+ type Status =
29
+ | { state: "idle" }
30
+ | { state: "busy" }
31
+ | { state: "done"; detail: string }
32
+ | { state: "error"; detail: string };
33
+
34
+ const STORAGE_KEY = "aphrody.koharu.shenron-export";
35
+ const fieldClass = "h-7 w-full rounded border border-border bg-transparent px-2 text-[11px]";
36
+
37
+ function loadSettings(): { apiUrl: string; token: string } {
38
+ try {
39
+ const raw = globalThis.localStorage?.getItem(STORAGE_KEY);
40
+ if (raw) {
41
+ const parsed = JSON.parse(raw) as { apiUrl?: unknown; token?: unknown };
42
+ return {
43
+ apiUrl: typeof parsed.apiUrl === "string" ? parsed.apiUrl : "",
44
+ token: typeof parsed.token === "string" ? parsed.token : "",
45
+ };
46
+ }
47
+ } catch {
48
+ // ignore unreadable storage
49
+ }
50
+ return { apiUrl: "", token: "" };
51
+ }
52
+
53
+ function mimeFor(image: string): KoharuMangaPageSource["mime"] {
54
+ if (/\.jpe?g$/i.test(image)) return "image/jpeg";
55
+ if (/\.png$/i.test(image)) return "image/png";
56
+ if (/\.webp$/i.test(image)) return "image/webp";
57
+ throw new Error("image path needs a .jpg, .png or .webp extension");
58
+ }
59
+
60
+ async function sha256Hex(bytes: Uint8Array): Promise<string> {
61
+ const digest = await crypto.subtle.digest("SHA-256", bytes as BufferSource);
62
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
63
+ }
64
+
65
+ export function ShenronExportPanel({ host }: { host: ShenronExportHost }) {
66
+ const [settings, setSettings] = useState(loadSettings);
67
+ const [pages, setPages] = useState<PageSummary[]>([]);
68
+ const [bindings, setBindings] = useState<Record<string, Binding>>({});
69
+ const [statuses, setStatuses] = useState<Record<string, Status>>({});
70
+ const [error, setError] = useState<string | null>(null);
71
+ const [running, setRunning] = useState(false);
72
+
73
+ const rpc = async <T,>(method: string, params: Record<string, unknown>): Promise<T> => {
74
+ if (!host.isTauri()) throw new Error("L’export Shenron nécessite l’application Aphrody.");
75
+ const result = await host.invoke<T>("koharu_rpc", { method, params });
76
+ if (result === null) throw new Error("Le service natif Koharu est indisponible.");
77
+ return result;
78
+ };
79
+
80
+ const refresh = async () => {
81
+ setError(null);
82
+ try {
83
+ setPages(await rpc<PageSummary[]>("project.pages", {}));
84
+ } catch (cause) {
85
+ setError(cause instanceof Error ? cause.message : String(cause));
86
+ }
87
+ };
88
+
89
+ useEffect(() => { void refresh(); }, []);
90
+
91
+ useEffect(() => {
92
+ try {
93
+ globalThis.localStorage?.setItem(STORAGE_KEY, JSON.stringify(settings));
94
+ } catch {
95
+ // ignore unwritable storage
96
+ }
97
+ }, [settings]);
98
+
99
+ const setBinding = (page: string, patch: Partial<Binding>) =>
100
+ setBindings((current) => ({
101
+ ...current,
102
+ [page]: { ...(current[page] ?? { mangaPageId: "", sourceSha256: "", image: "" }), ...patch },
103
+ }));
104
+
105
+ const exportPage = async (page: PageSummary, binding: Binding) => {
106
+ const result = await rpc<Record<string, unknown>>("page.result", { page: page.id });
107
+ const { sha256 } = await rpc<{ sha256: string }>("page.sourceSha256", { page: page.id });
108
+ const manifest: MangaCandidateBinding = {
109
+ id: binding.mangaPageId.trim(),
110
+ sourceSha256: binding.sourceSha256.trim().toLowerCase(),
111
+ imageSha256: sha256,
112
+ image: binding.image.trim(),
113
+ };
114
+ const source: KoharuMangaPageSource = {
115
+ kind: "manga",
116
+ pageId: manifest.id,
117
+ sourceSha256: manifest.sourceSha256,
118
+ imageSha256: manifest.imageSha256,
119
+ mime: mimeFor(manifest.image),
120
+ width: page.size.width,
121
+ height: page.size.height,
122
+ };
123
+ // The shared mapper hashes the cleanup layer with Bun.CryptoHasher, which the
124
+ // webview lacks; hash it here with WebCrypto and map the rest unchanged.
125
+ const cleanup = result.cleanup_layer_png;
126
+ const mapped = mapNativeKoharuPageResult({ result: { ...result, cleanup_layer_png: null }, sourceSha256: sha256 }, source);
127
+ if (Array.isArray(cleanup)) {
128
+ mapped.artifacts = { cleanupOverlaySha256: await sha256Hex(Uint8Array.from(cleanup as number[])) };
129
+ }
130
+ const candidate = toMangaReviewCandidateInput(mapped, manifest);
131
+ const base = settings.apiUrl.trim().replace(/\/+$/, "");
132
+ const response = await fetch(`${base}/api/manga/candidates`, {
133
+ method: "POST",
134
+ headers: {
135
+ "content-type": "application/json",
136
+ ...(settings.token ? { authorization: `Bearer ${settings.token}` } : {}),
137
+ },
138
+ body: JSON.stringify(candidate),
139
+ });
140
+ const text = await response.text();
141
+ if (!response.ok) throw new Error(`HTTP ${response.status}: ${text.slice(0, 200)}`);
142
+ return `HTTP ${response.status}`;
143
+ };
144
+
145
+ const exportAll = async () => {
146
+ if (!settings.apiUrl.trim()) {
147
+ setError("SHENRON_API_URL manquant.");
148
+ return;
149
+ }
150
+ setRunning(true);
151
+ setError(null);
152
+ for (const page of pages) {
153
+ const binding = bindings[page.id];
154
+ if (!binding?.mangaPageId.trim()) continue;
155
+ setStatuses((s) => ({ ...s, [page.id]: { state: "busy" } }));
156
+ try {
157
+ const detail = await exportPage(page, binding);
158
+ setStatuses((s) => ({ ...s, [page.id]: { state: "done", detail } }));
159
+ } catch (cause) {
160
+ const detail = cause instanceof Error ? cause.message : String(cause);
161
+ setStatuses((s) => ({ ...s, [page.id]: { state: "error", detail } }));
162
+ }
163
+ }
164
+ setRunning(false);
165
+ };
166
+
167
+ return (
168
+ <div className="flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-2.5 text-[11px]">
169
+ <label className="grid gap-1">
170
+ <span>SHENRON_API_URL</span>
171
+ <input className={fieldClass} type="url" value={settings.apiUrl}
172
+ onChange={(e) => setSettings({ ...settings, apiUrl: e.currentTarget.value })} />
173
+ </label>
174
+ <label className="grid gap-1">
175
+ <span>Jeton</span>
176
+ <input className={fieldClass} type="password" value={settings.token}
177
+ onChange={(e) => setSettings({ ...settings, token: e.currentTarget.value })} />
178
+ </label>
179
+ <div className="flex gap-1">
180
+ <button type="button" className="h-7 flex-1 rounded border border-border" onClick={() => void refresh()} disabled={running}>
181
+ Actualiser
182
+ </button>
183
+ <button type="button" className="h-7 flex-1 rounded bg-primary text-primary-foreground" onClick={() => void exportAll()} disabled={running || pages.length === 0}>
184
+ Exporter
185
+ </button>
186
+ </div>
187
+ {error && <p role="alert" className="text-destructive">{error}</p>}
188
+ <ul className="grid gap-2">
189
+ {pages.map((page) => {
190
+ const binding = bindings[page.id];
191
+ const status = statuses[page.id] ?? { state: "idle" };
192
+ return (
193
+ <li key={page.id} className="grid gap-1 rounded border border-border/80 p-2">
194
+ <div className="flex justify-between gap-2">
195
+ <span className="truncate font-medium">{page.label}</span>
196
+ <span data-state={status.state}>
197
+ {status.state === "idle" ? "—" : status.state === "busy" ? "…" : status.state === "done" ? `OK ${status.detail}` : "Erreur"}
198
+ </span>
199
+ </div>
200
+ <input className={fieldClass} placeholder="ID page manga" value={binding?.mangaPageId ?? ""}
201
+ onChange={(e) => setBinding(page.id, { mangaPageId: e.currentTarget.value })} />
202
+ <input className={fieldClass} placeholder="sourceSha256 (manifeste)" value={binding?.sourceSha256 ?? ""}
203
+ onChange={(e) => setBinding(page.id, { sourceSha256: e.currentTarget.value })} />
204
+ <input className={fieldClass} placeholder="image (manifeste)" value={binding?.image ?? ""}
205
+ onChange={(e) => setBinding(page.id, { image: e.currentTarget.value })} />
206
+ {status.state === "error" && <p className="break-words text-destructive">{status.detail}</p>}
207
+ </li>
208
+ );
209
+ })}
210
+ </ul>
211
+ </div>
212
+ );
213
+ }
@@ -0,0 +1,64 @@
1
+ 'use client'
2
+
3
+ import { getVersion } from '@aphrody/api/app'
4
+ import { useEffect, useState } from 'react'
5
+ import { useTranslation } from 'react-i18next'
6
+
7
+ import {
8
+ Dialog,
9
+ DialogContent,
10
+ DialogDescription,
11
+ DialogHeader,
12
+ DialogTitle,
13
+ } from '../../internal/components/dialog'
14
+
15
+ const author = 'Mayo Takanashi'
16
+
17
+ export function AboutDialog({
18
+ open,
19
+ onOpenChange,
20
+ }: {
21
+ open: boolean
22
+ onOpenChange: (open: boolean) => void
23
+ }) {
24
+ const { t } = useTranslation()
25
+ const [version, setVersion] = useState<string | null>(null)
26
+
27
+ useEffect(() => {
28
+ if (!open || version) return
29
+ let active = true
30
+ void getVersion()
31
+ .then((current) => {
32
+ if (active) setVersion(current)
33
+ })
34
+ .catch(() => {
35
+ if (active) setVersion(t('about.unavailable'))
36
+ })
37
+ return () => {
38
+ active = false
39
+ }
40
+ }, [open, t, version])
41
+
42
+ return (
43
+ <Dialog open={open} onOpenChange={onOpenChange}>
44
+ <DialogContent className='max-w-xs gap-4 p-5'>
45
+ <div className='flex items-center gap-3'>
46
+ <div className='grid size-12 shrink-0 place-items-center rounded-xl bg-primary/10'>
47
+ <img src='/icon.png' alt='' width={30} height={30} />
48
+ </div>
49
+ <DialogHeader className='min-w-0 gap-1'>
50
+ <DialogTitle className='text-[15px]'>Koharu</DialogTitle>
51
+ <DialogDescription className='text-[11px]'>{t('about.description')}</DialogDescription>
52
+ </DialogHeader>
53
+ </div>
54
+
55
+ <dl className='grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 border-t border-border/70 pt-3 text-[11px]'>
56
+ <dt className='text-muted-foreground'>{t('about.version')}</dt>
57
+ <dd className='text-right font-medium'>{version ?? t('common.loading')}</dd>
58
+ <dt className='text-muted-foreground'>{t('about.author')}</dt>
59
+ <dd className='text-right font-medium'>{author}</dd>
60
+ </dl>
61
+ </DialogContent>
62
+ </Dialog>
63
+ )
64
+ }
@@ -0,0 +1,58 @@
1
+ 'use client'
2
+
3
+ import { useEffect } from 'react'
4
+ import { useTranslation } from 'react-i18next'
5
+
6
+ import { TitleBar } from '@aphrody/koharu-ui/components/app/TitleBar'
7
+ import { Editor } from '@aphrody/koharu-ui/components/editor/Editor'
8
+ import { SettingsPage } from '@aphrody/koharu-ui/components/preferences/SettingsPage'
9
+ import { StartView } from '@aphrody/koharu-ui/components/start/StartView'
10
+ import { useProject } from '@aphrody/koharu-ui/lib/queries'
11
+ import { useKoharuStore } from '@aphrody/koharu-ui/lib/store'
12
+ import { cn } from '../../internal/lib/utils'
13
+
14
+ /** `embedded`: hosted inside another app (Aphrody Studio) — fills its container, no window controls. */
15
+ export function KoharuApp({ embedded = false }: { embedded?: boolean } = {}) {
16
+ const { t } = useTranslation()
17
+ const project = useProject().data
18
+ const selectedPages = useKoharuStore((state) => state.selectedPages)
19
+ const selectPages = useKoharuStore((state) => state.selectPages)
20
+ const selectLayers = useKoharuStore((state) => state.selectLayers)
21
+ const projectLoaded = project !== undefined
22
+ const settingsOpen = useKoharuStore((state) => state.settingsOpen)
23
+ const activePage = project?.active_page
24
+ const editorOpen = project !== undefined && project !== null && !settingsOpen
25
+
26
+ useEffect(() => {
27
+ if (!projectLoaded || selectedPages.length > 0) return
28
+ selectPages(activePage ? [activePage] : [])
29
+ selectLayers([])
30
+ }, [activePage, projectLoaded, selectLayers, selectPages, selectedPages.length])
31
+
32
+ return (
33
+ <div
34
+ data-koharu-ui
35
+ className={cn(
36
+ 'relative flex flex-col overflow-hidden text-foreground',
37
+ embedded ? 'h-full w-full' : 'h-screen w-screen',
38
+ editorOpen ? 'bg-transparent' : 'bg-[var(--surface-titlebar)]',
39
+ )}
40
+ >
41
+ <TitleBar windowControls={!embedded} />
42
+ {settingsOpen ? (
43
+ <SettingsPage />
44
+ ) : project === undefined ? (
45
+ <main className='grid min-h-0 flex-1 place-items-center bg-[var(--surface-canvas)]'>
46
+ <div className='flex items-center gap-3 text-[12px] text-muted-foreground'>
47
+ <span className='size-2 rounded-full bg-primary' />
48
+ {t('startup.opening')}
49
+ </div>
50
+ </main>
51
+ ) : project === null ? (
52
+ <StartView />
53
+ ) : (
54
+ <Editor />
55
+ )}
56
+ </div>
57
+ )
58
+ }
@@ -0,0 +1,67 @@
1
+ 'use client'
2
+
3
+ import { LoaderCircle } from 'lucide-react'
4
+ import { useTranslation } from 'react-i18next'
5
+
6
+ import { useMacOS, WindowControls } from '@aphrody/koharu-ui/components/app/WindowChrome'
7
+
8
+ export function StartupView() {
9
+ const { t } = useTranslation()
10
+ const macOS = useMacOS()
11
+
12
+ return (
13
+ <div className='relative flex h-screen w-screen flex-col overflow-hidden bg-[var(--surface-titlebar)] text-foreground'>
14
+ <header
15
+ data-tauri-drag-region='deep'
16
+ className='grid h-10 shrink-0 grid-cols-[132px_1fr_132px] items-center border-b border-border/80 bg-[var(--surface-titlebar)] shadow-[var(--shadow-titlebar)]'
17
+ >
18
+ <div className='flex h-full items-center'>
19
+ {!macOS && (
20
+ <div className='grid h-full w-10 place-items-center rounded-br-lg'>
21
+ <img
22
+ className='pointer-events-none'
23
+ src='/icon.png'
24
+ alt=''
25
+ width={17}
26
+ height={17}
27
+ draggable={false}
28
+ />
29
+ </div>
30
+ )}
31
+ </div>
32
+ <div className='grid h-full place-items-center text-[11px] text-muted-foreground select-none'>
33
+ Koharu
34
+ </div>
35
+ {!macOS && <WindowControls />}
36
+ </header>
37
+
38
+ <main className='relative grid min-h-0 flex-1 place-items-center overflow-hidden bg-[var(--surface-canvas)]'>
39
+ <section
40
+ className='w-full max-w-[620px] px-10 text-center'
41
+ role='status'
42
+ aria-live='polite'
43
+ aria-labelledby='startup-title'
44
+ >
45
+ <LoaderCircle
46
+ className='startup-spinner mx-auto size-11 text-primary'
47
+ aria-hidden='true'
48
+ />
49
+ <h1
50
+ id='startup-title'
51
+ className='mt-5 text-[24px] font-semibold tracking-[-0.025em] text-balance'
52
+ >
53
+ {t('startup.title')}
54
+ </h1>
55
+ <p className='mx-auto mt-2 max-w-[48ch] text-[13px] leading-5 text-muted-foreground'>
56
+ {t('startup.description')}
57
+ </p>
58
+
59
+ <div className='mx-auto mt-7 flex max-w-[480px] items-center justify-center gap-2.5 border-t border-border/80 pt-4 text-[12px] font-medium text-muted-foreground'>
60
+ <span className='size-2 rounded-full bg-primary' aria-hidden='true' />
61
+ {t('startup.status')}
62
+ </div>
63
+ </section>
64
+ </main>
65
+ </div>
66
+ )
67
+ }