@researai/deepscientist 1.5.14 → 1.5.16

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 (225) hide show
  1. package/README.md +336 -90
  2. package/assets/branding/logo-raster.png +0 -0
  3. package/bin/ds.js +816 -131
  4. package/docs/en/00_QUICK_START.md +36 -15
  5. package/docs/en/01_SETTINGS_REFERENCE.md +53 -4
  6. package/docs/en/02_START_RESEARCH_GUIDE.md +7 -0
  7. package/docs/en/03_QQ_CONNECTOR_GUIDE.md +19 -0
  8. package/docs/en/05_TUI_GUIDE.md +6 -0
  9. package/docs/en/06_RUNTIME_AND_CANVAS.md +4 -3
  10. package/docs/en/09_DOCTOR.md +11 -5
  11. package/docs/en/10_WEIXIN_CONNECTOR_GUIDE.md +20 -0
  12. package/docs/en/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +65 -13
  13. package/docs/en/15_CODEX_PROVIDER_SETUP.md +25 -8
  14. package/docs/en/16_TELEGRAM_CONNECTOR_GUIDE.md +134 -0
  15. package/docs/en/17_WHATSAPP_CONNECTOR_GUIDE.md +126 -0
  16. package/docs/en/18_FEISHU_CONNECTOR_GUIDE.md +136 -0
  17. package/docs/en/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
  18. package/docs/en/19_LOCAL_BROWSER_AUTH.md +70 -0
  19. package/docs/en/20_WORKSPACE_MODES_GUIDE.md +250 -0
  20. package/docs/en/README.md +24 -0
  21. package/docs/zh/00_QUICK_START.md +36 -15
  22. package/docs/zh/01_SETTINGS_REFERENCE.md +53 -4
  23. package/docs/zh/02_START_RESEARCH_GUIDE.md +7 -0
  24. package/docs/zh/03_QQ_CONNECTOR_GUIDE.md +19 -0
  25. package/docs/zh/05_TUI_GUIDE.md +6 -0
  26. package/docs/zh/09_DOCTOR.md +11 -5
  27. package/docs/zh/10_WEIXIN_CONNECTOR_GUIDE.md +20 -0
  28. package/docs/zh/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +65 -13
  29. package/docs/zh/15_CODEX_PROVIDER_SETUP.md +25 -8
  30. package/docs/zh/16_TELEGRAM_CONNECTOR_GUIDE.md +134 -0
  31. package/docs/zh/17_WHATSAPP_CONNECTOR_GUIDE.md +126 -0
  32. package/docs/zh/18_FEISHU_CONNECTOR_GUIDE.md +136 -0
  33. package/docs/zh/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
  34. package/docs/zh/19_LOCAL_BROWSER_AUTH.md +68 -0
  35. package/docs/zh/20_WORKSPACE_MODES_GUIDE.md +251 -0
  36. package/docs/zh/README.md +24 -0
  37. package/install.sh +2 -0
  38. package/package.json +1 -1
  39. package/pyproject.toml +1 -1
  40. package/src/deepscientist/__init__.py +1 -1
  41. package/src/deepscientist/acp/envelope.py +6 -0
  42. package/src/deepscientist/artifact/charts.py +567 -0
  43. package/src/deepscientist/artifact/guidance.py +50 -10
  44. package/src/deepscientist/artifact/metrics.py +228 -5
  45. package/src/deepscientist/artifact/schemas.py +3 -0
  46. package/src/deepscientist/artifact/service.py +4276 -308
  47. package/src/deepscientist/bash_exec/models.py +23 -0
  48. package/src/deepscientist/bash_exec/monitor.py +147 -67
  49. package/src/deepscientist/bash_exec/runtime.py +218 -156
  50. package/src/deepscientist/bash_exec/service.py +309 -69
  51. package/src/deepscientist/bash_exec/shells.py +87 -0
  52. package/src/deepscientist/bridges/connectors.py +51 -2
  53. package/src/deepscientist/cli.py +115 -19
  54. package/src/deepscientist/codex_cli_compat.py +232 -0
  55. package/src/deepscientist/config/models.py +8 -4
  56. package/src/deepscientist/config/service.py +38 -11
  57. package/src/deepscientist/connector/weixin_support.py +122 -1
  58. package/src/deepscientist/daemon/api/handlers.py +199 -9
  59. package/src/deepscientist/daemon/api/router.py +5 -0
  60. package/src/deepscientist/daemon/app.py +1458 -289
  61. package/src/deepscientist/doctor.py +51 -0
  62. package/src/deepscientist/file_lock.py +48 -0
  63. package/src/deepscientist/gitops/__init__.py +10 -1
  64. package/src/deepscientist/gitops/diff.py +296 -1
  65. package/src/deepscientist/gitops/service.py +4 -1
  66. package/src/deepscientist/mcp/server.py +212 -5
  67. package/src/deepscientist/process_control.py +161 -0
  68. package/src/deepscientist/prompts/builder.py +501 -453
  69. package/src/deepscientist/quest/layout.py +15 -2
  70. package/src/deepscientist/quest/service.py +2539 -195
  71. package/src/deepscientist/quest/stage_views.py +177 -1
  72. package/src/deepscientist/runners/base.py +2 -0
  73. package/src/deepscientist/runners/codex.py +169 -31
  74. package/src/deepscientist/runners/runtime_overrides.py +17 -1
  75. package/src/deepscientist/skills/__init__.py +2 -2
  76. package/src/deepscientist/skills/installer.py +196 -5
  77. package/src/deepscientist/skills/registry.py +66 -0
  78. package/src/prompts/connectors/qq.md +18 -8
  79. package/src/prompts/connectors/weixin.md +16 -6
  80. package/src/prompts/contracts/shared_interaction.md +24 -4
  81. package/src/prompts/system.md +921 -72
  82. package/src/prompts/system_copilot.md +43 -0
  83. package/src/skills/analysis-campaign/SKILL.md +32 -2
  84. package/src/skills/analysis-campaign/references/artifact-orchestration.md +1 -1
  85. package/src/skills/analysis-campaign/references/writing-facing-slice-examples.md +65 -0
  86. package/src/skills/baseline/SKILL.md +10 -0
  87. package/src/skills/decision/SKILL.md +27 -2
  88. package/src/skills/experiment/SKILL.md +16 -2
  89. package/src/skills/figure-polish/SKILL.md +1 -0
  90. package/src/skills/finalize/SKILL.md +19 -0
  91. package/src/skills/idea/SKILL.md +79 -0
  92. package/src/skills/idea/references/idea-generation-playbook.md +100 -0
  93. package/src/skills/idea/references/outline-seeding-example.md +60 -0
  94. package/src/skills/intake-audit/SKILL.md +9 -1
  95. package/src/skills/mentor/SKILL.md +217 -0
  96. package/src/skills/mentor/references/correction-rules.md +210 -0
  97. package/src/skills/mentor/references/knowledge-profile.md +91 -0
  98. package/src/skills/mentor/references/persona-profile.md +138 -0
  99. package/src/skills/mentor/references/taste-profile.md +128 -0
  100. package/src/skills/mentor/references/thought-style-profile.md +138 -0
  101. package/src/skills/mentor/references/work-profile.md +289 -0
  102. package/src/skills/mentor/references/workflow-profile.md +240 -0
  103. package/src/skills/optimize/SKILL.md +1645 -0
  104. package/src/skills/rebuttal/SKILL.md +3 -1
  105. package/src/skills/review/SKILL.md +3 -1
  106. package/src/skills/scout/SKILL.md +8 -0
  107. package/src/skills/write/SKILL.md +81 -12
  108. package/src/skills/write/references/outline-evidence-contract-example.md +107 -0
  109. package/src/tui/dist/app/AppContainer.js +22 -11
  110. package/src/tui/dist/index.js +4 -1
  111. package/src/tui/dist/lib/api.js +33 -3
  112. package/src/tui/package.json +1 -1
  113. package/src/ui/dist/assets/AiManusChatView-COFACy7V.js +204 -0
  114. package/src/ui/dist/assets/AnalysisPlugin-DnSm0GZn.js +1 -0
  115. package/src/ui/dist/assets/CliPlugin-CvwCmDQ5.js +109 -0
  116. package/src/ui/dist/assets/CodeEditorPlugin-cOqSa0xq.js +2 -0
  117. package/src/ui/dist/assets/CodeViewerPlugin-itb0tltR.js +270 -0
  118. package/src/ui/dist/assets/DocViewerPlugin-DqKkiCI6.js +7 -0
  119. package/src/ui/dist/assets/GitCommitViewerPlugin-DVgNHBCS.js +1 -0
  120. package/src/ui/dist/assets/GitDiffViewerPlugin-DxL2ezFG.js +6 -0
  121. package/src/ui/dist/assets/GitSnapshotViewer-B_RQm1YZ.js +30 -0
  122. package/src/ui/dist/assets/ImageViewerPlugin-tHqlXY3n.js +26 -0
  123. package/src/ui/dist/assets/LabCopilotPanel-ClMbq5Yu.js +14 -0
  124. package/src/ui/dist/assets/LabPlugin-L_SuE8ow.js +22 -0
  125. package/src/ui/dist/assets/LatexPlugin-B495DTXC.js +25 -0
  126. package/src/ui/dist/assets/MarkdownViewerPlugin-DG28-61B.js +128 -0
  127. package/src/ui/dist/assets/MarketplacePlugin-BiOGT-Kj.js +13 -0
  128. package/src/ui/dist/assets/{NotebookEditor-CccQYZjX.css → NotebookEditor-BHH8rdGj.css} +1 -1
  129. package/src/ui/dist/assets/NotebookEditor-BOr3x3Ej.css +1 -0
  130. package/src/ui/dist/assets/NotebookEditor-C-4Kt1p9.js +81 -0
  131. package/src/ui/dist/assets/NotebookEditor-CVsj8h_T.js +361 -0
  132. package/src/ui/dist/assets/PdfLoader-CASDQmxJ.js +16 -0
  133. package/src/ui/dist/assets/PdfLoader-Cy5jtWrr.css +1 -0
  134. package/src/ui/dist/assets/PdfMarkdownPlugin-BFhwoKsY.js +1 -0
  135. package/src/ui/dist/assets/PdfViewerPlugin-DcOzU9vd.js +17 -0
  136. package/src/ui/dist/assets/PdfViewerPlugin-nwwE-fjJ.css +1 -0
  137. package/src/ui/dist/assets/SearchPlugin-CHj7M58O.js +16 -0
  138. package/src/ui/dist/assets/SearchPlugin-DA4en4hK.css +1 -0
  139. package/src/ui/dist/assets/TextViewerPlugin-CB4DYfWO.js +54 -0
  140. package/src/ui/dist/assets/VNCViewer-CjlbyCB3.js +11 -0
  141. package/src/ui/dist/assets/bot-CFkZY-JP.js +6 -0
  142. package/src/ui/dist/assets/browser-CTB2jwNe.js +8 -0
  143. package/src/ui/dist/assets/chevron-up-Dq5ofbht.js +6 -0
  144. package/src/ui/dist/assets/code-DLC6G24T.js +6 -0
  145. package/src/ui/dist/assets/file-content-Dv4LoZec.js +1 -0
  146. package/src/ui/dist/assets/file-diff-panel-Denq-lC3.js +1 -0
  147. package/src/ui/dist/assets/file-jump-queue-DA-SdG__.js +1 -0
  148. package/src/ui/dist/assets/file-socket-Cu4Qln7Y.js +1 -0
  149. package/src/ui/dist/assets/git-commit-horizontal-BUh6G52n.js +6 -0
  150. package/src/ui/dist/assets/image-B9HUUddG.js +6 -0
  151. package/src/ui/dist/assets/index-B2B1sg-M.js +1 -0
  152. package/src/ui/dist/assets/index-Cgla8biy.css +33 -0
  153. package/src/ui/dist/assets/index-DRyx7vAc.js +1 -0
  154. package/src/ui/dist/assets/index-Gbl53BNp.js +2496 -0
  155. package/src/ui/dist/assets/index-wQ7RIIRd.js +11 -0
  156. package/src/ui/dist/assets/monaco-CiHMMNH_.js +1 -0
  157. package/src/ui/dist/assets/pdf-effect-queue-ZtnHFCAi.js +6 -0
  158. package/src/ui/dist/assets/plugin-monaco-C8UgLomw.js +19 -0
  159. package/src/ui/dist/assets/plugin-notebook-HbW2K-1c.js +169 -0
  160. package/src/ui/dist/assets/plugin-pdf-CR8hgQBV.js +357 -0
  161. package/src/ui/dist/assets/plugin-terminal-MXFIPun8.js +227 -0
  162. package/src/ui/dist/assets/popover-DL6h35vr.js +1 -0
  163. package/src/ui/dist/assets/project-sync-CsX08Qno.js +1 -0
  164. package/src/ui/dist/assets/select-DvmXt1yY.js +11 -0
  165. package/src/ui/dist/assets/sigma-7jpXazui.js +6 -0
  166. package/src/ui/dist/assets/trash-xA7kFt8i.js +11 -0
  167. package/src/ui/dist/assets/useCliAccess-DsMwDjOp.js +1 -0
  168. package/src/ui/dist/assets/useFileDiffOverlay-FuhcnKiw.js +1 -0
  169. package/src/ui/dist/assets/wrap-text-CwMn-iqb.js +11 -0
  170. package/src/ui/dist/assets/zoom-out-R-GWEhzS.js +11 -0
  171. package/src/ui/dist/index.html +5 -2
  172. package/src/ui/dist/assets/AiManusChatView-DaF9Nge_.js +0 -26597
  173. package/src/ui/dist/assets/AnalysisPlugin-BSVx6dXE.js +0 -123
  174. package/src/ui/dist/assets/CliPlugin-C9gzJX41.js +0 -5905
  175. package/src/ui/dist/assets/CodeEditorPlugin-DU9G0Tox.js +0 -427
  176. package/src/ui/dist/assets/CodeViewerPlugin-DoX_fI9l.js +0 -905
  177. package/src/ui/dist/assets/DocViewerPlugin-C4FWIXuU.js +0 -278
  178. package/src/ui/dist/assets/GitDiffViewerPlugin-BgfFMgtf.js +0 -2661
  179. package/src/ui/dist/assets/ImageViewerPlugin-tcPkfY_x.js +0 -500
  180. package/src/ui/dist/assets/LabCopilotPanel-_dKV60Bf.js +0 -4104
  181. package/src/ui/dist/assets/LabPlugin-Bje0ayoC.js +0 -2677
  182. package/src/ui/dist/assets/LatexPlugin-CVsBzAln.js +0 -1792
  183. package/src/ui/dist/assets/MarkdownViewerPlugin-xjmrqv_8.js +0 -308
  184. package/src/ui/dist/assets/MarketplacePlugin-mMM2A8wP.js +0 -413
  185. package/src/ui/dist/assets/NotebookEditor-3kVDSOBo.js +0 -4214
  186. package/src/ui/dist/assets/NotebookEditor-C3VQ7ylN.css +0 -1405
  187. package/src/ui/dist/assets/NotebookEditor-SoJ8X-MO.js +0 -84873
  188. package/src/ui/dist/assets/PdfLoader-C-Y707R3.css +0 -49
  189. package/src/ui/dist/assets/PdfLoader-DElVuHl9.js +0 -25468
  190. package/src/ui/dist/assets/PdfMarkdownPlugin-Bq88XT4G.js +0 -409
  191. package/src/ui/dist/assets/PdfViewerPlugin-CsCXMo9S.js +0 -3095
  192. package/src/ui/dist/assets/PdfViewerPlugin-DQ11QcSf.css +0 -3627
  193. package/src/ui/dist/assets/SearchPlugin-DDMrGDkh.css +0 -379
  194. package/src/ui/dist/assets/SearchPlugin-oUPvy19k.js +0 -741
  195. package/src/ui/dist/assets/TextViewerPlugin-CRkT9yNy.js +0 -472
  196. package/src/ui/dist/assets/VNCViewer-BgbuvWhR.js +0 -18821
  197. package/src/ui/dist/assets/awareness-C0NPR2Dj.js +0 -292
  198. package/src/ui/dist/assets/bot-v_RASACv.js +0 -21
  199. package/src/ui/dist/assets/browser-BAcuE0Xj.js +0 -2895
  200. package/src/ui/dist/assets/code-5hC9d0VH.js +0 -17
  201. package/src/ui/dist/assets/file-content-D1PxfOrp.js +0 -377
  202. package/src/ui/dist/assets/file-diff-panel-DG1oT_Hj.js +0 -92
  203. package/src/ui/dist/assets/file-jump-queue-r5XKgJEV.js +0 -16
  204. package/src/ui/dist/assets/file-socket-BmdFYQlk.js +0 -58
  205. package/src/ui/dist/assets/function-B5QZkkHC.js +0 -1895
  206. package/src/ui/dist/assets/image-Dqe2X2tW.js +0 -18
  207. package/src/ui/dist/assets/index-BQG-1s2o.css +0 -12553
  208. package/src/ui/dist/assets/index-DVsMKK_y.js +0 -25
  209. package/src/ui/dist/assets/index-Duvz8Ip0.js +0 -159
  210. package/src/ui/dist/assets/index-Nt9hS4ck.js +0 -244829
  211. package/src/ui/dist/assets/index-RDlNXXx1.js +0 -120
  212. package/src/ui/dist/assets/monaco-DIXge1CP.js +0 -623
  213. package/src/ui/dist/assets/pdf-effect-queue-BBTTQaO-.js +0 -47
  214. package/src/ui/dist/assets/pdf_viewer-e0g1is2C.js +0 -8206
  215. package/src/ui/dist/assets/popover-BWlolyxo.js +0 -476
  216. package/src/ui/dist/assets/project-sync-BM5PkFH4.js +0 -297
  217. package/src/ui/dist/assets/select-D4dAtrA8.js +0 -1690
  218. package/src/ui/dist/assets/sigma-CKbE5jJT.js +0 -22
  219. package/src/ui/dist/assets/square-check-big-CZNGMgiB.js +0 -17
  220. package/src/ui/dist/assets/trash-DaB37xAz.js +0 -32
  221. package/src/ui/dist/assets/useCliAccess-C2OmAcWe.js +0 -957
  222. package/src/ui/dist/assets/useFileDiffOverlay-Dowd1Ij4.js +0 -53
  223. package/src/ui/dist/assets/wrap-text-BGjAhAUq.js +0 -35
  224. package/src/ui/dist/assets/yjs-DncrqiZ8.js +0 -11243
  225. package/src/ui/dist/assets/zoom-out-dMZQMXzc.js +0 -34
@@ -1,500 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Nt9hS4ck.js","assets/index-BQG-1s2o.css"])))=>i.map(i=>d[i]);
2
- import { w as createLucideIcon, r as reactExports, j as jsxRuntimeExports, b as cn, ah as RotateCcw, ai as Info, a3 as Download, L as LoaderCircle, _ as __vitePreload } from './index-Nt9hS4ck.js';
3
- import { I as Image } from './image-Dqe2X2tW.js';
4
- import { Z as ZoomOut, a as ZoomIn } from './zoom-out-dMZQMXzc.js';
5
-
6
- /**
7
- * @license lucide-react v0.511.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */
12
-
13
-
14
- const __iconNode$2 = [
15
- ["line", { x1: "2", x2: "22", y1: "2", y2: "22", key: "a6p6uj" }],
16
- ["path", { d: "M10.41 10.41a2 2 0 1 1-2.83-2.83", key: "1bzlo9" }],
17
- ["line", { x1: "13.5", x2: "6", y1: "13.5", y2: "21", key: "1q0aeu" }],
18
- ["line", { x1: "18", x2: "21", y1: "12", y2: "15", key: "5mozeu" }],
19
- [
20
- "path",
21
- {
22
- d: "M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",
23
- key: "mmje98"
24
- }
25
- ],
26
- ["path", { d: "M21 15V5a2 2 0 0 0-2-2H9", key: "43el77" }]
27
- ];
28
- const ImageOff = createLucideIcon("image-off", __iconNode$2);
29
-
30
- /**
31
- * @license lucide-react v0.511.0 - ISC
32
- *
33
- * This source code is licensed under the ISC license.
34
- * See the LICENSE file in the root directory of this source tree.
35
- */
36
-
37
-
38
- const __iconNode$1 = [
39
- ["path", { d: "M8 3H5a2 2 0 0 0-2 2v3", key: "1dcmit" }],
40
- ["path", { d: "M21 8V5a2 2 0 0 0-2-2h-3", key: "1e4gt3" }],
41
- ["path", { d: "M3 16v3a2 2 0 0 0 2 2h3", key: "wsl5sc" }],
42
- ["path", { d: "M16 21h3a2 2 0 0 0 2-2v-3", key: "18trek" }]
43
- ];
44
- const Maximize = createLucideIcon("maximize", __iconNode$1);
45
-
46
- /**
47
- * @license lucide-react v0.511.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */
52
-
53
-
54
- const __iconNode = [
55
- ["path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8", key: "1p45f6" }],
56
- ["path", { d: "M21 3v5h-5", key: "1q7to0" }]
57
- ];
58
- const RotateCw = createLucideIcon("rotate-cw", __iconNode);
59
-
60
- const MIN_SCALE = 0.1;
61
- const MAX_SCALE = 10;
62
- const ZOOM_STEP = 0.1;
63
- function ImageCanvas({
64
- src,
65
- alt,
66
- onLoad,
67
- onError,
68
- rotation,
69
- className
70
- }) {
71
- const [loading, setLoading] = reactExports.useState(true);
72
- const [transform, setTransform] = reactExports.useState({
73
- scale: 1,
74
- translateX: 0,
75
- translateY: 0
76
- });
77
- const [isDragging, setIsDragging] = reactExports.useState(false);
78
- const [dragStart, setDragStart] = reactExports.useState({ x: 0, y: 0 });
79
- const containerRef = reactExports.useRef(null);
80
- const imageRef = reactExports.useRef(null);
81
- reactExports.useEffect(() => {
82
- setTransform({ scale: 1, translateX: 0, translateY: 0 });
83
- setLoading(true);
84
- }, [src]);
85
- const handleLoad = reactExports.useCallback(() => {
86
- setLoading(false);
87
- if (imageRef.current && onLoad) {
88
- onLoad({
89
- width: imageRef.current.width,
90
- height: imageRef.current.height,
91
- naturalWidth: imageRef.current.naturalWidth,
92
- naturalHeight: imageRef.current.naturalHeight
93
- });
94
- }
95
- }, [onLoad]);
96
- const handleError = reactExports.useCallback(() => {
97
- setLoading(false);
98
- onError?.();
99
- }, [onError]);
100
- reactExports.useCallback(() => {
101
- setTransform((prev) => ({
102
- ...prev,
103
- scale: Math.min(prev.scale + ZOOM_STEP, MAX_SCALE)
104
- }));
105
- }, []);
106
- reactExports.useCallback(() => {
107
- setTransform((prev) => ({
108
- ...prev,
109
- scale: Math.max(prev.scale - ZOOM_STEP, MIN_SCALE)
110
- }));
111
- }, []);
112
- const resetTransform = reactExports.useCallback(() => {
113
- setTransform({ scale: 1, translateX: 0, translateY: 0 });
114
- }, []);
115
- reactExports.useCallback(() => {
116
- if (!containerRef.current || !imageRef.current) return;
117
- const container = containerRef.current.getBoundingClientRect();
118
- const img = imageRef.current;
119
- const imageWidth = img.naturalWidth;
120
- const imageHeight = img.naturalHeight;
121
- const scaleX = (container.width - 40) / imageWidth;
122
- const scaleY = (container.height - 40) / imageHeight;
123
- const scale = Math.min(scaleX, scaleY, 1);
124
- setTransform({ scale, translateX: 0, translateY: 0 });
125
- }, []);
126
- const handleWheel = reactExports.useCallback((e) => {
127
- e.preventDefault();
128
- const delta = e.deltaY > 0 ? -ZOOM_STEP : ZOOM_STEP;
129
- const newScale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, transform.scale + delta));
130
- if (containerRef.current) {
131
- const rect = containerRef.current.getBoundingClientRect();
132
- const x = e.clientX - rect.left - rect.width / 2;
133
- const y = e.clientY - rect.top - rect.height / 2;
134
- const scaleDiff = newScale / transform.scale;
135
- const newTranslateX = x - scaleDiff * (x - transform.translateX);
136
- const newTranslateY = y - scaleDiff * (y - transform.translateY);
137
- setTransform({
138
- scale: newScale,
139
- translateX: newTranslateX,
140
- translateY: newTranslateY
141
- });
142
- } else {
143
- setTransform((prev) => ({ ...prev, scale: newScale }));
144
- }
145
- }, [transform]);
146
- const handleMouseDown = reactExports.useCallback((e) => {
147
- if (e.button !== 0) return;
148
- e.preventDefault();
149
- setIsDragging(true);
150
- setDragStart({ x: e.clientX - transform.translateX, y: e.clientY - transform.translateY });
151
- }, [transform.translateX, transform.translateY]);
152
- const handleMouseMove = reactExports.useCallback((e) => {
153
- if (!isDragging) return;
154
- e.preventDefault();
155
- setTransform((prev) => ({
156
- ...prev,
157
- translateX: e.clientX - dragStart.x,
158
- translateY: e.clientY - dragStart.y
159
- }));
160
- }, [isDragging, dragStart]);
161
- const handleMouseUp = reactExports.useCallback(() => {
162
- setIsDragging(false);
163
- }, []);
164
- const handleTouchStart = reactExports.useCallback((e) => {
165
- if (e.touches.length === 1) {
166
- const touch = e.touches[0];
167
- setIsDragging(true);
168
- setDragStart({
169
- x: touch.clientX - transform.translateX,
170
- y: touch.clientY - transform.translateY
171
- });
172
- }
173
- }, [transform.translateX, transform.translateY]);
174
- const handleTouchMove = reactExports.useCallback((e) => {
175
- if (!isDragging || e.touches.length !== 1) return;
176
- const touch = e.touches[0];
177
- setTransform((prev) => ({
178
- ...prev,
179
- translateX: touch.clientX - dragStart.x,
180
- translateY: touch.clientY - dragStart.y
181
- }));
182
- }, [isDragging, dragStart]);
183
- const handleTouchEnd = reactExports.useCallback(() => {
184
- setIsDragging(false);
185
- }, []);
186
- const handleDoubleClick = reactExports.useCallback(() => {
187
- resetTransform();
188
- }, [resetTransform]);
189
- const transformStyle = `
190
- translate(${transform.translateX}px, ${transform.translateY}px)
191
- scale(${transform.scale})
192
- rotate(${rotation}deg)
193
- `;
194
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
195
- "div",
196
- {
197
- ref: containerRef,
198
- className: cn(
199
- "relative w-full h-full overflow-hidden select-none",
200
- isDragging ? "cursor-grabbing" : "cursor-grab",
201
- className
202
- ),
203
- onWheel: handleWheel,
204
- onMouseDown: handleMouseDown,
205
- onMouseMove: handleMouseMove,
206
- onMouseUp: handleMouseUp,
207
- onMouseLeave: handleMouseUp,
208
- onTouchStart: handleTouchStart,
209
- onTouchMove: handleTouchMove,
210
- onTouchEnd: handleTouchEnd,
211
- onDoubleClick: handleDoubleClick,
212
- children: [
213
- loading && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin" }) }),
214
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
215
- "img",
216
- {
217
- ref: imageRef,
218
- src,
219
- alt,
220
- className: cn(
221
- "max-w-none transition-transform duration-100",
222
- loading && "opacity-0"
223
- ),
224
- style: {
225
- transform: transformStyle,
226
- transformOrigin: "center center"
227
- },
228
- onLoad: handleLoad,
229
- onError: handleError,
230
- draggable: false
231
- }
232
- ) }),
233
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute bottom-4 left-4 px-2 py-1 bg-background/80 backdrop-blur rounded text-xs text-muted-foreground", children: [
234
- Math.round(transform.scale * 100),
235
- "%"
236
- ] })
237
- ]
238
- }
239
- );
240
- }
241
-
242
- const DEMO_IMAGE_URL = "https://via.placeholder.com/1920x1080?text=DeepScientist+Image+Viewer";
243
- function formatFileSize(bytes) {
244
- if (!bytes) return "Unknown";
245
- if (bytes < 1024) return `${bytes} B`;
246
- if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
247
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
248
- }
249
- function getImageExtension(fileName) {
250
- const ext = fileName.split(".").pop()?.toLowerCase() || "";
251
- return ext.toUpperCase();
252
- }
253
- function ImageViewerPlugin({
254
- context,
255
- tabId,
256
- setDirty,
257
- setTitle
258
- }) {
259
- const [imageUrl, setImageUrl] = reactExports.useState("");
260
- const [loading, setLoading] = reactExports.useState(true);
261
- const [error, setError] = reactExports.useState(null);
262
- const [imageInfo, setImageInfo] = reactExports.useState(null);
263
- const [rotation, setRotation] = reactExports.useState(0);
264
- const [showInfo, setShowInfo] = reactExports.useState(false);
265
- const canvasRef = reactExports.useRef(null);
266
- const fileName = context.resourceName || context.resourcePath || "Image";
267
- reactExports.useEffect(() => {
268
- setTitle(fileName);
269
- }, [fileName, setTitle]);
270
- reactExports.useEffect(() => {
271
- let cancelled = false;
272
- let objectUrl = null;
273
- setLoading(true);
274
- setError(null);
275
- if (!context.resourceId) {
276
- setImageUrl(DEMO_IMAGE_URL);
277
- return () => {
278
- cancelled = true;
279
- };
280
- }
281
- const loadImageUrl = async () => {
282
- try {
283
- const { createFileObjectUrl } = await __vitePreload(async () => { const { createFileObjectUrl } = await import('./index-Nt9hS4ck.js').then(n => n.el);return { createFileObjectUrl }},true?__vite__mapDeps([0,1]):void 0);
284
- objectUrl = await createFileObjectUrl(context.resourceId);
285
- if (cancelled) {
286
- URL.revokeObjectURL(objectUrl);
287
- return;
288
- }
289
- setImageUrl(objectUrl);
290
- } catch (err) {
291
- console.error("Failed to get image URL:", err);
292
- setError("Failed to load image");
293
- setLoading(false);
294
- }
295
- };
296
- loadImageUrl();
297
- return () => {
298
- cancelled = true;
299
- if (objectUrl) {
300
- URL.revokeObjectURL(objectUrl);
301
- }
302
- };
303
- }, [context.resourceId]);
304
- const handleImageLoad = reactExports.useCallback((info) => {
305
- setLoading(false);
306
- setImageInfo(info);
307
- }, []);
308
- const handleImageError = reactExports.useCallback(() => {
309
- setLoading(false);
310
- setError("Failed to load image");
311
- }, []);
312
- const rotateLeft = reactExports.useCallback(() => {
313
- setRotation((prev) => (prev - 90) % 360);
314
- }, []);
315
- const rotateRight = reactExports.useCallback(() => {
316
- setRotation((prev) => (prev + 90) % 360);
317
- }, []);
318
- reactExports.useCallback(() => {
319
- setRotation(0);
320
- }, []);
321
- const handleDownload = reactExports.useCallback(() => {
322
- if (!imageUrl) return;
323
- const link = document.createElement("a");
324
- link.href = imageUrl;
325
- link.download = fileName;
326
- link.click();
327
- }, [imageUrl, fileName]);
328
- const fileSize = context.customData?.size;
329
- if (error && !loading) {
330
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-full bg-background", children: [
331
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center px-4 py-2 border-b border-border bg-muted/30", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
332
- /* @__PURE__ */ jsxRuntimeExports.jsx(Image, { className: "w-4 h-4 text-muted-foreground" }),
333
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-foreground", children: fileName })
334
- ] }) }),
335
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-4 text-center", children: [
336
- /* @__PURE__ */ jsxRuntimeExports.jsx(ImageOff, { className: "w-16 h-16 text-muted-foreground" }),
337
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
338
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg font-medium text-foreground", children: "Failed to load image" }),
339
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: error })
340
- ] }),
341
- /* @__PURE__ */ jsxRuntimeExports.jsx(
342
- "button",
343
- {
344
- className: "px-4 py-2 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",
345
- onClick: () => window.location.reload(),
346
- children: "Retry"
347
- }
348
- )
349
- ] }) })
350
- ] });
351
- }
352
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-full bg-muted/30", children: [
353
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between px-4 py-2 border-b border-border bg-background", children: [
354
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [
355
- /* @__PURE__ */ jsxRuntimeExports.jsx(Image, { className: "w-4 h-4 text-muted-foreground" }),
356
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-foreground", children: fileName }),
357
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs px-2 py-0.5 rounded bg-muted text-muted-foreground", children: getImageExtension(fileName) }),
358
- imageInfo && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-xs text-muted-foreground", children: [
359
- imageInfo.naturalWidth,
360
- " x ",
361
- imageInfo.naturalHeight
362
- ] })
363
- ] }),
364
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [
365
- /* @__PURE__ */ jsxRuntimeExports.jsx(
366
- "button",
367
- {
368
- onClick: () => canvasRef.current?.zoomOut?.(),
369
- className: "p-2 rounded hover:bg-accent transition-colors text-muted-foreground hover:text-foreground",
370
- title: "Zoom out",
371
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(ZoomOut, { className: "w-4 h-4" })
372
- }
373
- ),
374
- /* @__PURE__ */ jsxRuntimeExports.jsx(
375
- "button",
376
- {
377
- onClick: () => canvasRef.current?.resetTransform?.(),
378
- className: "p-2 rounded hover:bg-accent transition-colors text-muted-foreground hover:text-foreground",
379
- title: "Reset zoom (double-click image)",
380
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Maximize, { className: "w-4 h-4" })
381
- }
382
- ),
383
- /* @__PURE__ */ jsxRuntimeExports.jsx(
384
- "button",
385
- {
386
- onClick: () => canvasRef.current?.zoomIn?.(),
387
- className: "p-2 rounded hover:bg-accent transition-colors text-muted-foreground hover:text-foreground",
388
- title: "Zoom in",
389
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(ZoomIn, { className: "w-4 h-4" })
390
- }
391
- ),
392
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-px h-6 bg-border mx-1" }),
393
- /* @__PURE__ */ jsxRuntimeExports.jsx(
394
- "button",
395
- {
396
- onClick: rotateLeft,
397
- className: "p-2 rounded hover:bg-accent transition-colors text-muted-foreground hover:text-foreground",
398
- title: "Rotate left",
399
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(RotateCcw, { className: "w-4 h-4" })
400
- }
401
- ),
402
- /* @__PURE__ */ jsxRuntimeExports.jsx(
403
- "button",
404
- {
405
- onClick: rotateRight,
406
- className: "p-2 rounded hover:bg-accent transition-colors text-muted-foreground hover:text-foreground",
407
- title: "Rotate right",
408
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(RotateCw, { className: "w-4 h-4" })
409
- }
410
- ),
411
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-px h-6 bg-border mx-1" }),
412
- /* @__PURE__ */ jsxRuntimeExports.jsx(
413
- "button",
414
- {
415
- onClick: () => setShowInfo(!showInfo),
416
- className: cn(
417
- "p-2 rounded transition-colors",
418
- showInfo ? "bg-primary text-primary-foreground" : "hover:bg-accent text-muted-foreground hover:text-foreground"
419
- ),
420
- title: "Image info",
421
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "w-4 h-4" })
422
- }
423
- ),
424
- /* @__PURE__ */ jsxRuntimeExports.jsx(
425
- "button",
426
- {
427
- onClick: handleDownload,
428
- className: "p-2 rounded hover:bg-accent transition-colors text-muted-foreground hover:text-foreground",
429
- title: "Download image",
430
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Download, { className: "w-4 h-4" })
431
- }
432
- )
433
- ] })
434
- ] }),
435
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 relative overflow-hidden bg-[#1a1a1a]", children: [
436
- /* @__PURE__ */ jsxRuntimeExports.jsx(
437
- "div",
438
- {
439
- className: "absolute inset-0 opacity-20",
440
- style: {
441
- backgroundImage: `
442
- linear-gradient(45deg, #808080 25%, transparent 25%),
443
- linear-gradient(-45deg, #808080 25%, transparent 25%),
444
- linear-gradient(45deg, transparent 75%, #808080 75%),
445
- linear-gradient(-45deg, transparent 75%, #808080 75%)
446
- `,
447
- backgroundSize: "20px 20px",
448
- backgroundPosition: "0 0, 0 10px, 10px -10px, -10px 0px"
449
- }
450
- }
451
- ),
452
- loading && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 flex items-center justify-center z-10", children: /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "w-8 h-8 animate-spin text-muted-foreground" }) }),
453
- imageUrl && /* @__PURE__ */ jsxRuntimeExports.jsx(
454
- ImageCanvas,
455
- {
456
- src: imageUrl,
457
- alt: fileName,
458
- rotation,
459
- onLoad: handleImageLoad,
460
- onError: handleImageError
461
- }
462
- ),
463
- showInfo && imageInfo && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute top-4 right-4 p-4 bg-background/90 backdrop-blur rounded-lg shadow-lg border border-border", children: [
464
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-foreground mb-3", children: "Image Information" }),
465
- /* @__PURE__ */ jsxRuntimeExports.jsxs("dl", { className: "space-y-2 text-sm", children: [
466
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between gap-8", children: [
467
- /* @__PURE__ */ jsxRuntimeExports.jsx("dt", { className: "text-muted-foreground", children: "Filename" }),
468
- /* @__PURE__ */ jsxRuntimeExports.jsx("dd", { className: "text-foreground font-mono", children: fileName })
469
- ] }),
470
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between gap-8", children: [
471
- /* @__PURE__ */ jsxRuntimeExports.jsx("dt", { className: "text-muted-foreground", children: "Dimensions" }),
472
- /* @__PURE__ */ jsxRuntimeExports.jsxs("dd", { className: "text-foreground font-mono", children: [
473
- imageInfo.naturalWidth,
474
- " x ",
475
- imageInfo.naturalHeight
476
- ] })
477
- ] }),
478
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between gap-8", children: [
479
- /* @__PURE__ */ jsxRuntimeExports.jsx("dt", { className: "text-muted-foreground", children: "Format" }),
480
- /* @__PURE__ */ jsxRuntimeExports.jsx("dd", { className: "text-foreground font-mono", children: getImageExtension(fileName) })
481
- ] }),
482
- fileSize && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between gap-8", children: [
483
- /* @__PURE__ */ jsxRuntimeExports.jsx("dt", { className: "text-muted-foreground", children: "Size" }),
484
- /* @__PURE__ */ jsxRuntimeExports.jsx("dd", { className: "text-foreground font-mono", children: formatFileSize(fileSize) })
485
- ] }),
486
- rotation !== 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between gap-8", children: [
487
- /* @__PURE__ */ jsxRuntimeExports.jsx("dt", { className: "text-muted-foreground", children: "Rotation" }),
488
- /* @__PURE__ */ jsxRuntimeExports.jsxs("dd", { className: "text-foreground font-mono", children: [
489
- rotation,
490
- "deg"
491
- ] })
492
- ] })
493
- ] })
494
- ] })
495
- ] }),
496
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center gap-2 px-4 py-2 border-t border-border bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-muted-foreground", children: "Scroll to zoom | Drag to pan | Double-click to reset" }) })
497
- ] });
498
- }
499
-
500
- export { ImageViewerPlugin as default };