evomeme 0.1.9 → 0.1.10-beta.13

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 (477) hide show
  1. package/README.md +2 -0
  2. package/dist/canvas-public/app.js +509 -5999
  3. package/dist/canvas-public/assets/presets/catalog.json +47 -0
  4. package/dist/canvas-public/assets/presets/tiles/A_01_CaoDi.png +0 -0
  5. package/dist/canvas-public/assets/presets/tiles/A_02_ShaMo.png +0 -0
  6. package/dist/canvas-public/assets/presets/tiles/A_03_TianKong.png +0 -0
  7. package/dist/canvas-public/assets/presets/tiles/A_04_ShuiBo.png +0 -0
  8. package/dist/canvas-public/assets/presets/tiles/A_05_HaiMian.png +0 -0
  9. package/dist/canvas-public/assets/presets/tiles/A_06_MuDiBan.png +0 -0
  10. package/dist/canvas-public/assets/presets/tiles/A_07_ShiZhuan.png +0 -0
  11. package/dist/canvas-public/assets/presets/tiles/A_08_AnRongYan.png +0 -0
  12. package/dist/canvas-public/assets/presets/tiles/A_09_QingTaiShi.png +0 -0
  13. package/dist/canvas-public/assets/presets/tiles/A_10_ShenHai.png +0 -0
  14. package/dist/canvas-public/assets/presets/tiles/A_11_HuiYanShi.png +0 -0
  15. package/dist/canvas-public/assets/presets/tiles/A_12_HongTu.png +0 -0
  16. package/dist/canvas-public/assets/presets/tiles/A_13_GengDi.png +0 -0
  17. package/dist/canvas-public/assets/presets/tiles/A_14_HuoShanYan.png +0 -0
  18. package/dist/canvas-public/assets/presets/tiles/A_15_NiTu.png +0 -0
  19. package/dist/canvas-public/assets/presets/tiles/A_16_HuangSha.png +0 -0
  20. package/dist/canvas-public/assets/presets/tiles/A_17_CongLin.png +0 -0
  21. package/dist/canvas-public/assets/presets/tiles/A_18_ZiYanShi.png +0 -0
  22. package/dist/canvas-public/assets/presets/tiles/A_19_MoGuTu.png +0 -0
  23. package/dist/canvas-public/assets/presets/tiles/A_20_HuaDian.png +0 -0
  24. package/dist/canvas-public/assets/presets/tiles/A_21_HaiLang.png +0 -0
  25. package/dist/canvas-public/assets/presets/tiles/A_22_GanTu.png +0 -0
  26. package/dist/canvas-public/assets/presets/tiles/A_23_QingTaiShiBan.png +0 -0
  27. package/dist/canvas-public/assets/presets/tiles/A_24_XingKong.png +0 -0
  28. package/dist/canvas-public/assets/presets/tiles/A_25_MoFaFuWen.png +0 -0
  29. package/dist/canvas-public/assets/presets/tiles/A_26_ShiTuYeDi.png +0 -0
  30. package/dist/canvas-public/assets/presets/tiles/A_27_LanZhuan.png +0 -0
  31. package/dist/canvas-public/assets/presets/tiles/A_28_HongZhuan.png +0 -0
  32. package/dist/canvas-public/assets/presets/tiles/A_29_YueQiu.png +0 -0
  33. package/dist/canvas-public/assets/presets/tiles/A_30_JinShuGe.png +0 -0
  34. package/dist/canvas-public/assets/presets/tiles/A_31_JinShuJingGai.png +0 -0
  35. package/dist/canvas-public/assets/presets/tiles/A_32_ShuZiChuang.png +0 -0
  36. package/dist/canvas-public/canvas/actions.js +144 -0
  37. package/dist/canvas-public/canvas/camera.js +28 -0
  38. package/dist/canvas-public/canvas/chrome.js +14 -0
  39. package/dist/canvas-public/canvas/data.js +123 -0
  40. package/dist/canvas-public/canvas/dependencies.js +19 -0
  41. package/dist/canvas-public/canvas/interactions.js +544 -0
  42. package/dist/canvas-public/canvas/panel-resize.js +5 -0
  43. package/dist/canvas-public/canvas/renderer.js +297 -0
  44. package/dist/canvas-public/canvas/selection.js +62 -0
  45. package/dist/canvas-public/canvas/serialization.js +118 -0
  46. package/dist/canvas-public/canvas/sync.js +202 -0
  47. package/dist/canvas-public/core/api.js +32 -0
  48. package/dist/canvas-public/core/feature-registry.js +29 -0
  49. package/dist/canvas-public/core/feature-state.js +228 -0
  50. package/dist/canvas-public/core/layout.js +133 -0
  51. package/dist/canvas-public/core/operations.js +38 -0
  52. package/dist/canvas-public/core/project.js +203 -0
  53. package/dist/canvas-public/core/state.js +27 -0
  54. package/dist/canvas-public/dialogs/context-menu.js +118 -0
  55. package/dist/canvas-public/elements/base.js +100 -0
  56. package/dist/canvas-public/elements/connections.js +105 -0
  57. package/dist/canvas-public/elements/drag.js +53 -0
  58. package/dist/canvas-public/elements/image.js +259 -0
  59. package/dist/canvas-public/elements/loading-recovery.js +5 -0
  60. package/dist/canvas-public/elements/loading.js +21 -0
  61. package/dist/canvas-public/elements/map.js +64 -0
  62. package/dist/canvas-public/elements/registry.js +58 -0
  63. package/dist/canvas-public/elements/replacement.js +78 -0
  64. package/dist/canvas-public/elements/resize.js +210 -0
  65. package/dist/canvas-public/elements/task-pipeline.js +235 -0
  66. package/dist/canvas-public/elements/types.js +21 -0
  67. package/dist/canvas-public/elements/ui.js +14 -0
  68. package/dist/canvas-public/elements/video.js +64 -0
  69. package/dist/canvas-public/features/assets/local-assets.js +72 -0
  70. package/dist/canvas-public/features/assets/official-assets.js +539 -0
  71. package/dist/canvas-public/features/editing/canvas-size.js +532 -0
  72. package/dist/canvas-public/features/editing/color-key.js +471 -0
  73. package/dist/canvas-public/features/editing/cutout.js +20 -0
  74. package/dist/canvas-public/features/editing/interactive-image-editing.js +982 -0
  75. package/dist/canvas-public/features/editing/layer-decomposition.js +45 -0
  76. package/dist/canvas-public/features/editing/manual-split.js +115 -0
  77. package/dist/canvas-public/features/editing/perfect-pixel.js +299 -0
  78. package/dist/canvas-public/features/editing/scroll-preview.js +130 -0
  79. package/dist/canvas-public/features/editing/scroll-seam-elimination.js +71 -0
  80. package/dist/canvas-public/features/editing/seam-elimination.js +46 -0
  81. package/dist/canvas-public/features/editing/smart-split.js +49 -0
  82. package/dist/canvas-public/features/editing/source-preview.js +43 -0
  83. package/dist/canvas-public/features/editing/video-cycle.js +49 -0
  84. package/dist/canvas-public/features/editing/video-frames.js +35 -0
  85. package/dist/canvas-public/features/frame-editor/frame-editing.js +755 -0
  86. package/dist/canvas-public/features/frame-editor/frame-model.js +63 -0
  87. package/dist/canvas-public/features/frame-editor/playback.js +83 -0
  88. package/dist/canvas-public/features/frame-editor/preview.js +151 -0
  89. package/dist/canvas-public/features/generation/animation.js +272 -0
  90. package/dist/canvas-public/features/generation/asset-batch.js +102 -0
  91. package/dist/canvas-public/features/generation/direction.js +163 -0
  92. package/dist/canvas-public/features/generation/fields.js +73 -0
  93. package/dist/canvas-public/features/generation/game-ui.js +64 -0
  94. package/dist/canvas-public/features/generation/image.js +96 -0
  95. package/dist/canvas-public/features/generation/scroll-image.js +157 -0
  96. package/dist/canvas-public/features/generation/seamless-tile.js +52 -0
  97. package/dist/canvas-public/features/generation/tile-transition-atlas.js +79 -0
  98. package/dist/canvas-public/features/generation/video.js +105 -0
  99. package/dist/canvas-public/features/map/creation.js +73 -0
  100. package/dist/canvas-public/features/map/tile-map-editor.js +2520 -0
  101. package/dist/canvas-public/features/registry.js +59 -0
  102. package/dist/canvas-public/index.html +84 -259
  103. package/dist/canvas-public/inspector/controls.js +49 -0
  104. package/dist/canvas-public/inspector/frame-preview.js +11 -0
  105. package/dist/canvas-public/inspector/inspector.js +190 -0
  106. package/dist/canvas-public/inspector/media-inspector.js +517 -0
  107. package/dist/canvas-public/inspector/media-preview.js +56 -0
  108. package/dist/canvas-public/inspector/number-stepper.js +96 -0
  109. package/dist/canvas-public/inspector/resize.js +88 -0
  110. package/dist/canvas-public/inspector/scroll-preview.js +11 -0
  111. package/dist/canvas-public/inspector/ui-inspector.js +14 -0
  112. package/dist/canvas-public/language/en-US.js +1059 -0
  113. package/dist/canvas-public/language/index.js +91 -0
  114. package/dist/canvas-public/language/zh-CN.js +1059 -0
  115. package/dist/canvas-public/map/export.js +10 -0
  116. package/dist/canvas-public/map/inspector.js +8 -0
  117. package/dist/canvas-public/map/model.js +409 -0
  118. package/dist/canvas-public/map/tile-map-editor.js +2 -0
  119. package/dist/canvas-public/media/metadata.js +183 -0
  120. package/dist/canvas-public/media/support.js +183 -0
  121. package/dist/canvas-public/styles/base.css +49 -0
  122. package/dist/canvas-public/styles/canvas.css +127 -0
  123. package/dist/canvas-public/styles/controls.css +203 -0
  124. package/dist/canvas-public/styles/dialogs.css +521 -0
  125. package/dist/canvas-public/styles/feature-form.css +409 -0
  126. package/dist/canvas-public/styles/inspector.css +441 -0
  127. package/dist/canvas-public/styles/layout.css +344 -0
  128. package/dist/canvas-public/styles/map.css +11 -0
  129. package/dist/canvas-public/styles/nodes.css +636 -0
  130. package/dist/canvas-public/styles.css +9 -2247
  131. package/dist/canvas-public/ui/controls.js +222 -0
  132. package/dist/canvas-public/ui/elements.js +9 -0
  133. package/dist/canvas-public/ui/feature-controller.js +296 -0
  134. package/dist/canvas-public/ui/feature-form.js +402 -0
  135. package/dist/canvas-public/ui/settings.js +84 -0
  136. package/dist/canvas-public/ui/toolbar.js +55 -0
  137. package/dist/canvas-public/vendor/pixi-tilemap.js +126 -0
  138. package/dist/canvas-public/vendor/pixi.min.js +2340 -0
  139. package/dist/canvas-public/workers/color-key-worker.js +289 -0
  140. package/dist/image-workers/perfect-pixel/perfect-pixel-core.js +441 -0
  141. package/dist/image-workers/perfect-pixel/perfect-pixel-worker.cjs +10 -0
  142. package/dist/index.js +46710 -12400
  143. package/dist/skills/en-US/evomeme-canvas/SKILL.md +52 -0
  144. package/dist/skills/en-US/evomeme-canvas/agents/openai.yaml +7 -0
  145. package/dist/skills/en-US/evomeme-cloud-fs/SKILL.md +203 -0
  146. package/dist/skills/en-US/evomeme-cloud-fs/agents/openai.yaml +7 -0
  147. package/dist/skills/en-US/evomeme-cover/SKILL.md +131 -0
  148. package/dist/skills/en-US/evomeme-cover/agents/openai.yaml +7 -0
  149. package/dist/skills/en-US/evomeme-game-maker/SKILL.md +288 -0
  150. package/dist/skills/en-US/evomeme-game-maker/agents/openai.yaml +4 -0
  151. package/dist/skills/en-US/evomeme-login/SKILL.md +97 -0
  152. package/dist/skills/en-US/evomeme-login/agents/openai.yaml +7 -0
  153. package/dist/skills/en-US/evomeme-mcp/SKILL.md +71 -0
  154. package/dist/skills/en-US/evomeme-mcp/agents/openai.yaml +7 -0
  155. package/dist/skills/en-US/evomeme-mcp/references/troubleshooting.md +55 -0
  156. package/dist/skills/en-US/evomeme-native-bridge-sdk/SKILL.md +286 -0
  157. package/dist/skills/en-US/evomeme-native-bridge-sdk/agents/openai.yaml +8 -0
  158. package/dist/skills/en-US/evomeme-tos-upload/SKILL.md +47 -0
  159. package/dist/skills/en-US/evomeme-tos-upload/agents/openai.yaml +5 -0
  160. package/dist/skills/en-US/evomeme-ui/SKILL.md +123 -0
  161. package/dist/skills/en-US/evomeme-ui/agents/openai.yaml +4 -0
  162. package/dist/skills/en-US/evomeme-ui/references/host-layout.md +69 -0
  163. package/dist/skills/en-US/game-art/SKILL.md +121 -0
  164. package/dist/skills/en-US/game-art/agents/openai.yaml +8 -0
  165. package/dist/skills/en-US/game-asset-align/SKILL.md +47 -0
  166. package/dist/skills/en-US/game-asset-align/agents/openai.yaml +8 -0
  167. package/dist/skills/en-US/game-asset-align/references/alignment-contract.md +61 -0
  168. package/dist/skills/en-US/game-asset-align/references/blender-scene-pipeline.md +35 -0
  169. package/dist/skills/en-US/game-asset-align/references/canonical-package.md +26 -0
  170. package/dist/skills/en-US/game-asset-align/references/engine-capabilities.md +14 -0
  171. package/dist/skills/en-US/game-asset-align/references/lightweight-review.md +34 -0
  172. package/dist/skills/en-US/game-asset-align/references/repair-policy.md +30 -0
  173. package/dist/skills/en-US/game-asset-align/references/tool-contract.md +69 -0
  174. package/dist/skills/en-US/game-asset-align/references/visual-review.md +26 -0
  175. package/dist/skills/en-US/game-asset-batch-generator/SKILL.md +117 -0
  176. package/dist/skills/en-US/game-asset-batch-generator/agents/openai.yaml +7 -0
  177. package/dist/skills/en-US/game-asset-image-generator/SKILL.md +86 -0
  178. package/dist/skills/en-US/game-asset-image-generator/agents/openai.yaml +7 -0
  179. package/dist/skills/en-US/game-asset-image-generator/references/background.md +34 -0
  180. package/dist/skills/en-US/game-asset-image-generator/references/static-game-assets.md +38 -0
  181. package/dist/skills/en-US/game-asset-mesh-generator/SKILL.md +35 -0
  182. package/dist/skills/en-US/game-asset-mesh-generator/agents/openai.yaml +7 -0
  183. package/dist/skills/en-US/game-asset-mesh-generator/references/animation-presets.md +313 -0
  184. package/dist/skills/en-US/game-asset-mesh-generator/references/generation-contracts.md +131 -0
  185. package/dist/skills/en-US/game-asset-mesh-generator/references/image-generator-workflows.md +65 -0
  186. package/dist/skills/en-US/game-asset-mesh-generator/references/postprocess-contracts.md +187 -0
  187. package/dist/skills/en-US/game-asset-mesh-generator/references/threejs-integration.md +113 -0
  188. package/dist/skills/en-US/game-asset-mesh-generator/references/tool-reference.md +67 -0
  189. package/dist/skills/en-US/game-audio/SKILL.md +121 -0
  190. package/dist/skills/en-US/game-audio/agents/openai.yaml +4 -0
  191. package/{skills → dist/skills/en-US}/game-audio/references/bgm-cdn.md +7 -11
  192. package/{skills → dist/skills/en-US}/game-audio/references/sfx-cdn.md +6 -4
  193. package/dist/skills/en-US/game-character-view-generator/SKILL.md +110 -0
  194. package/dist/skills/en-US/game-character-view-generator/agents/openai.yaml +7 -0
  195. package/dist/skills/en-US/game-demo/SKILL.md +103 -0
  196. package/dist/skills/en-US/game-demo/agents/openai.yaml +7 -0
  197. package/dist/skills/en-US/game-image-layer-decomposer/SKILL.md +99 -0
  198. package/dist/skills/en-US/game-image-layer-decomposer/agents/openai.yaml +7 -0
  199. package/dist/skills/en-US/game-image-splitter/SKILL.md +114 -0
  200. package/dist/skills/en-US/game-image-splitter/agents/openai.yaml +7 -0
  201. package/dist/skills/en-US/game-maker/SKILL.md +111 -0
  202. package/dist/skills/en-US/game-maker/agents/openai.yaml +4 -0
  203. package/dist/skills/en-US/game-perfect-pixel/SKILL.md +123 -0
  204. package/dist/skills/en-US/game-perfect-pixel/agents/openai.yaml +7 -0
  205. package/dist/skills/en-US/game-scroll-generator/SKILL.md +110 -0
  206. package/dist/skills/en-US/game-scroll-generator/agents/openai.yaml +7 -0
  207. package/dist/skills/en-US/game-test/SKILL.md +58 -0
  208. package/dist/skills/en-US/game-test/agents/openai.yaml +7 -0
  209. package/dist/skills/en-US/game-tile-generator/SKILL.md +152 -0
  210. package/dist/skills/en-US/game-tile-generator/agents/openai.yaml +7 -0
  211. package/dist/skills/en-US/game-ui/SKILL.md +177 -0
  212. package/dist/skills/en-US/game-ui/agents/openai.yaml +4 -0
  213. package/dist/skills/en-US/game-ui-generator/SKILL.md +82 -0
  214. package/dist/skills/en-US/game-ui-generator/agents/openai.yaml +7 -0
  215. package/dist/skills/en-US/game-ui-generator/references/component-patterns.md +65 -0
  216. package/dist/skills/en-US/game-ui-generator/references/runtime-integration.md +45 -0
  217. package/dist/skills/en-US/game-video-cycle/SKILL.md +98 -0
  218. package/dist/skills/en-US/game-video-cycle/agents/openai.yaml +7 -0
  219. package/dist/skills/en-US/game-video-generator/SKILL.md +78 -0
  220. package/dist/skills/en-US/game-video-generator/agents/openai.yaml +7 -0
  221. package/dist/skills/en-US/godot-3d-game/SKILL.md +41 -0
  222. package/dist/skills/en-US/godot-3d-game/agents/openai.yaml +8 -0
  223. package/dist/skills/en-US/godot-3d-game/references/alignment-gates.md +26 -0
  224. package/dist/skills/en-US/godot-3d-game/references/appearance-alignment.md +54 -0
  225. package/dist/skills/en-US/godot-3d-game/references/build-and-qa.md +22 -0
  226. package/dist/skills/en-US/godot-3d-game/references/canonical-asset-runtime.md +27 -0
  227. package/dist/skills/en-US/godot-3d-game/references/import-and-wrapper-scenes.md +20 -0
  228. package/dist/skills/en-US/godot-3d-game/references/physics-colliders.md +13 -0
  229. package/dist/skills/en-US/godot-3d-game/references/project-structure.md +22 -0
  230. package/dist/skills/en-US/godot-3d-game/references/skeleton-animation.md +16 -0
  231. package/dist/skills/en-US/phaser-2d-game/SKILL.md +127 -0
  232. package/dist/skills/en-US/phaser-2d-game/agents/openai.yaml +8 -0
  233. package/dist/skills/en-US/phaser-2d-game/references/engine-performance.md +64 -0
  234. package/dist/skills/en-US/phaser-2d-game/references/engine-physics.md +139 -0
  235. package/dist/skills/en-US/phaser-2d-game/references/engine-runtime.md +129 -0
  236. package/dist/skills/en-US/phaser-2d-game/references/engine-spritesheets.md +99 -0
  237. package/dist/skills/en-US/phaser-2d-game/references/engine-tilemaps.md +80 -0
  238. package/dist/skills/en-US/phaser-2d-game/references/file-structure.md +94 -0
  239. package/dist/skills/en-US/phaser-2d-graphics-builder/SKILL.md +68 -0
  240. package/dist/skills/en-US/phaser-2d-graphics-builder/agents/openai.yaml +7 -0
  241. package/dist/skills/en-US/threejs-3d-game/SKILL.md +117 -0
  242. package/dist/skills/en-US/threejs-3d-game/agents/openai.yaml +7 -0
  243. package/dist/skills/en-US/threejs-3d-game/references/engine-asset-pipeline.md +155 -0
  244. package/dist/skills/en-US/threejs-3d-game/references/engine-audio.md +70 -0
  245. package/dist/skills/en-US/threejs-3d-game/references/engine-input-camera.md +84 -0
  246. package/dist/skills/en-US/threejs-3d-game/references/engine-performance.md +96 -0
  247. package/dist/skills/en-US/threejs-3d-game/references/engine-physics.md +142 -0
  248. package/dist/skills/en-US/threejs-3d-game/references/engine-runtime.md +199 -0
  249. package/dist/skills/en-US/threejs-3d-game/references/file-structure.md +353 -0
  250. package/dist/skills/en-US/threejs-aaa-graphics-builder/SKILL.md +62 -0
  251. package/dist/skills/en-US/threejs-aaa-graphics-builder/agents/openai.yaml +7 -0
  252. package/{skills → dist/skills/zh-CN}/evomeme-cloud-fs/SKILL.md +33 -6
  253. package/{skills → dist/skills/zh-CN}/evomeme-cover/SKILL.md +7 -8
  254. package/{skills → dist/skills/zh-CN}/evomeme-game-maker/SKILL.md +91 -88
  255. package/{skills → dist/skills/zh-CN}/evomeme-login/SKILL.md +5 -0
  256. package/dist/skills/zh-CN/evomeme-mcp/SKILL.md +71 -0
  257. package/dist/skills/zh-CN/evomeme-mcp/agents/openai.yaml +7 -0
  258. package/dist/skills/zh-CN/evomeme-mcp/references/troubleshooting.md +55 -0
  259. package/{skills → dist/skills/zh-CN}/evomeme-tos-upload/SKILL.md +6 -5
  260. package/dist/skills/zh-CN/evomeme-ui/SKILL.md +123 -0
  261. package/dist/skills/zh-CN/evomeme-ui/agents/openai.yaml +4 -0
  262. package/dist/skills/zh-CN/evomeme-ui/references/host-layout.md +69 -0
  263. package/dist/skills/zh-CN/game-asset-align/SKILL.md +47 -0
  264. package/dist/skills/zh-CN/game-asset-align/agents/openai.yaml +8 -0
  265. package/dist/skills/zh-CN/game-asset-align/references/alignment-contract.md +61 -0
  266. package/dist/skills/zh-CN/game-asset-align/references/blender-scene-pipeline.md +35 -0
  267. package/dist/skills/zh-CN/game-asset-align/references/canonical-package.md +26 -0
  268. package/dist/skills/zh-CN/game-asset-align/references/engine-capabilities.md +14 -0
  269. package/dist/skills/zh-CN/game-asset-align/references/lightweight-review.md +34 -0
  270. package/dist/skills/zh-CN/game-asset-align/references/repair-policy.md +30 -0
  271. package/dist/skills/zh-CN/game-asset-align/references/tool-contract.md +69 -0
  272. package/dist/skills/zh-CN/game-asset-align/references/visual-review.md +26 -0
  273. package/dist/skills/zh-CN/game-asset-batch-generator/SKILL.md +117 -0
  274. package/dist/skills/zh-CN/game-asset-batch-generator/agents/openai.yaml +7 -0
  275. package/dist/skills/zh-CN/game-asset-image-generator/SKILL.md +86 -0
  276. package/{skills → dist/skills/zh-CN}/game-asset-image-generator/references/background.md +3 -1
  277. package/{skills → dist/skills/zh-CN}/game-asset-image-generator/references/static-game-assets.md +2 -2
  278. package/dist/skills/zh-CN/game-asset-mesh-generator/SKILL.md +35 -0
  279. package/dist/skills/zh-CN/game-asset-mesh-generator/agents/openai.yaml +7 -0
  280. package/dist/skills/zh-CN/game-asset-mesh-generator/references/animation-presets.md +313 -0
  281. package/dist/skills/zh-CN/game-asset-mesh-generator/references/generation-contracts.md +131 -0
  282. package/dist/skills/zh-CN/game-asset-mesh-generator/references/image-generator-workflows.md +65 -0
  283. package/dist/skills/zh-CN/game-asset-mesh-generator/references/postprocess-contracts.md +187 -0
  284. package/dist/skills/zh-CN/game-asset-mesh-generator/references/threejs-integration.md +113 -0
  285. package/dist/skills/zh-CN/game-asset-mesh-generator/references/tool-reference.md +67 -0
  286. package/dist/skills/zh-CN/game-audio/SKILL.md +121 -0
  287. package/dist/skills/zh-CN/game-audio/agents/openai.yaml +4 -0
  288. package/dist/skills/zh-CN/game-audio/references/bgm-cdn.md +123 -0
  289. package/dist/skills/zh-CN/game-audio/references/sfx-cdn.md +79 -0
  290. package/dist/skills/zh-CN/game-character-view-generator/SKILL.md +110 -0
  291. package/dist/skills/zh-CN/game-character-view-generator/agents/openai.yaml +7 -0
  292. package/dist/skills/zh-CN/game-image-layer-decomposer/SKILL.md +99 -0
  293. package/dist/skills/zh-CN/game-image-layer-decomposer/agents/openai.yaml +7 -0
  294. package/dist/skills/zh-CN/game-image-splitter/SKILL.md +114 -0
  295. package/dist/skills/zh-CN/game-image-splitter/agents/openai.yaml +7 -0
  296. package/dist/skills/zh-CN/game-perfect-pixel/SKILL.md +123 -0
  297. package/dist/skills/zh-CN/game-perfect-pixel/agents/openai.yaml +7 -0
  298. package/dist/skills/zh-CN/game-scroll-generator/SKILL.md +110 -0
  299. package/dist/skills/zh-CN/game-scroll-generator/agents/openai.yaml +7 -0
  300. package/dist/skills/zh-CN/game-test/references/checklists/playtest-qa.md +12 -0
  301. package/dist/skills/zh-CN/game-tile-generator/SKILL.md +151 -0
  302. package/dist/skills/zh-CN/game-tile-generator/agents/openai.yaml +7 -0
  303. package/{skills → dist/skills/zh-CN}/game-ui/SKILL.md +9 -1
  304. package/dist/skills/zh-CN/game-ui/references/checklists/game-ui-quality.md +14 -0
  305. package/dist/skills/zh-CN/game-ui/references/checklists/hud-readability.md +12 -0
  306. package/dist/skills/zh-CN/game-ui/references/checklists/mobile-input.md +12 -0
  307. package/dist/skills/zh-CN/game-ui/references/checklists/responsive-ui-fit.md +12 -0
  308. package/dist/skills/zh-CN/game-ui/references/ui-patterns.md +140 -0
  309. package/dist/skills/zh-CN/game-ui/references/ui-prompt-templates.md +63 -0
  310. package/dist/skills/zh-CN/game-ui-generator/SKILL.md +82 -0
  311. package/dist/skills/zh-CN/game-ui-generator/agents/openai.yaml +7 -0
  312. package/dist/skills/zh-CN/game-ui-generator/references/component-patterns.md +65 -0
  313. package/dist/skills/zh-CN/game-ui-generator/references/runtime-integration.md +45 -0
  314. package/dist/skills/zh-CN/game-video-cycle/SKILL.md +98 -0
  315. package/dist/skills/zh-CN/game-video-cycle/agents/openai.yaml +7 -0
  316. package/dist/skills/zh-CN/game-video-generator/SKILL.md +78 -0
  317. package/dist/skills/zh-CN/game-video-generator/agents/openai.yaml +7 -0
  318. package/dist/skills/zh-CN/godot-3d-game/SKILL.md +41 -0
  319. package/dist/skills/zh-CN/godot-3d-game/agents/openai.yaml +8 -0
  320. package/dist/skills/zh-CN/godot-3d-game/references/alignment-gates.md +26 -0
  321. package/dist/skills/zh-CN/godot-3d-game/references/appearance-alignment.md +54 -0
  322. package/dist/skills/zh-CN/godot-3d-game/references/build-and-qa.md +22 -0
  323. package/dist/skills/zh-CN/godot-3d-game/references/canonical-asset-runtime.md +27 -0
  324. package/dist/skills/zh-CN/godot-3d-game/references/import-and-wrapper-scenes.md +20 -0
  325. package/dist/skills/zh-CN/godot-3d-game/references/physics-colliders.md +13 -0
  326. package/dist/skills/zh-CN/godot-3d-game/references/project-structure.md +22 -0
  327. package/dist/skills/zh-CN/godot-3d-game/references/skeleton-animation.md +16 -0
  328. package/dist/skills/zh-CN/phaser-2d-graphics-builder/assets/scorecard-anchors/scene-1.jpeg +0 -0
  329. package/dist/skills/zh-CN/phaser-2d-graphics-builder/assets/scorecard-anchors/scene-2.jpeg +0 -0
  330. package/dist/skills/zh-CN/phaser-2d-graphics-builder/assets/scorecard-anchors/scene-3.jpg +0 -0
  331. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/checklists/compose-quality.md +10 -0
  332. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/checklists/performance-safe-visual-detail.md +9 -0
  333. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/checklists/premium-game-quality-gate.md +15 -0
  334. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/checklists/sprite-quality.md +10 -0
  335. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/checklists/technical-art-quality.md +9 -0
  336. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/checklists/visual-scorecard.md +9 -0
  337. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/compose-recipes.md +71 -0
  338. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/graphics-prompt-templates.md +33 -0
  339. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/implementation-blueprint.md +82 -0
  340. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/sprite-recipes.md +90 -0
  341. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/technical-art.md +67 -0
  342. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/vfx-recipes.md +67 -0
  343. package/dist/skills/zh-CN/phaser-2d-graphics-builder/references/visual-scorecard.md +129 -0
  344. package/{skills → dist/skills/zh-CN}/threejs-3d-game/SKILL.md +6 -2
  345. package/dist/skills/zh-CN/threejs-3d-game/references/engine-asset-pipeline.md +155 -0
  346. package/{skills → dist/skills/zh-CN}/threejs-aaa-graphics-builder/SKILL.md +6 -6
  347. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/assets/scorecard-anchors/scene-1.jpg +0 -0
  348. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/assets/scorecard-anchors/scene-2.jpg +0 -0
  349. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/assets/scorecard-anchors/scene-3.jpg +0 -0
  350. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/checklists/aaa-game-quality-gate.md +23 -0
  351. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/checklists/aaa-visual-scorecard.md +19 -0
  352. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/checklists/material-lighting-quality.md +14 -0
  353. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/checklists/performance-safe-visual-detail.md +14 -0
  354. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/checklists/procedural-model-quality.md +15 -0
  355. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/checklists/technical-art-quality.md +17 -0
  356. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/graphics-prompt-templates.md +236 -0
  357. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/implementation-blueprint.md +161 -0
  358. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/model-recipes.md +146 -0
  359. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/render-recipes.md +90 -0
  360. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/shader-cookbook.md +292 -0
  361. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/technical-art.md +167 -0
  362. package/dist/skills/zh-CN/threejs-aaa-graphics-builder/references/visual-scorecard.md +147 -0
  363. package/dist/stage-blender/bake_materials.py +102 -0
  364. package/dist/stage-blender/export_scene.py +275 -0
  365. package/dist/stage-blender/preview_camera.py +90 -0
  366. package/dist/stage-blender/repair_mesh.py +112 -0
  367. package/dist/stage-public/app.js +759 -0
  368. package/dist/stage-public/baked/bakePilot.js +44 -0
  369. package/dist/stage-public/baked/bakedScene.js +129 -0
  370. package/dist/stage-public/baked/sceneAppearance.js +225 -0
  371. package/dist/stage-public/baked/sceneCamera.js +45 -0
  372. package/dist/stage-public/comparison-contract.js +28 -0
  373. package/dist/stage-public/delivery.html +4 -0
  374. package/dist/stage-public/delivery.js +17 -0
  375. package/dist/stage-public/godot/appearance.gd +170 -0
  376. package/dist/stage-public/godot/preview.gd +79 -0
  377. package/dist/stage-public/index.html +141 -0
  378. package/dist/stage-public/review-app.js +289 -0
  379. package/dist/stage-public/review-runtime.js +63 -0
  380. package/dist/stage-public/review.css +24 -0
  381. package/dist/stage-public/review.html +47 -0
  382. package/dist/stage-public/scene-runtime.js +212 -0
  383. package/dist/stage-public/sceneContractRuntime.js +235 -0
  384. package/dist/stage-public/styles.css +328 -0
  385. package/dist/stage-public/three-appearance.js +104 -0
  386. package/dist/stage-public/vendor/three170/LICENSE +21 -0
  387. package/dist/stage-public/vendor/three170/build/three.module.js +54571 -0
  388. package/dist/stage-public/vendor/three170/examples/jsm/controls/OrbitControls.js +1523 -0
  389. package/dist/stage-public/vendor/three170/examples/jsm/environments/RoomEnvironment.js +144 -0
  390. package/dist/stage-public/vendor/three170/examples/jsm/libs/fflate.module.js +2672 -0
  391. package/dist/stage-public/vendor/three170/examples/jsm/loaders/EXRLoader.js +2563 -0
  392. package/dist/stage-public/vendor/three170/examples/jsm/loaders/GLTFLoader.js +4727 -0
  393. package/dist/stage-public/vendor/three170/examples/jsm/utils/BufferGeometryUtils.js +1373 -0
  394. package/dist/tile-transition-mask.svg +40 -0
  395. package/package.json +24 -8
  396. package/dist/canvas-public/cycle-detect.js +0 -166
  397. package/dist/canvas-public/smart-split.js +0 -185
  398. package/skills/game-asset-image-generator/SKILL.md +0 -104
  399. package/skills/game-audio/SKILL.md +0 -82
  400. package/skills/game-audio/agents/openai.yaml +0 -4
  401. package/skills/threejs-3d-game/references/engine-asset-pipeline.md +0 -116
  402. /package/{skills → dist/skills/en-US}/game-test/references/checklists/playtest-qa.md +0 -0
  403. /package/{skills → dist/skills/en-US}/game-ui/references/checklists/game-ui-quality.md +0 -0
  404. /package/{skills → dist/skills/en-US}/game-ui/references/checklists/hud-readability.md +0 -0
  405. /package/{skills → dist/skills/en-US}/game-ui/references/checklists/mobile-input.md +0 -0
  406. /package/{skills → dist/skills/en-US}/game-ui/references/checklists/responsive-ui-fit.md +0 -0
  407. /package/{skills → dist/skills/en-US}/game-ui/references/ui-patterns.md +0 -0
  408. /package/{skills → dist/skills/en-US}/game-ui/references/ui-prompt-templates.md +0 -0
  409. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/assets/scorecard-anchors/scene-1.jpeg +0 -0
  410. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/assets/scorecard-anchors/scene-2.jpeg +0 -0
  411. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/assets/scorecard-anchors/scene-3.jpg +0 -0
  412. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/checklists/compose-quality.md +0 -0
  413. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/checklists/performance-safe-visual-detail.md +0 -0
  414. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/checklists/premium-game-quality-gate.md +0 -0
  415. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/checklists/sprite-quality.md +0 -0
  416. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/checklists/technical-art-quality.md +0 -0
  417. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/checklists/visual-scorecard.md +0 -0
  418. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/compose-recipes.md +0 -0
  419. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/graphics-prompt-templates.md +0 -0
  420. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/implementation-blueprint.md +0 -0
  421. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/sprite-recipes.md +0 -0
  422. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/technical-art.md +0 -0
  423. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/vfx-recipes.md +0 -0
  424. /package/{skills → dist/skills/en-US}/phaser-2d-graphics-builder/references/visual-scorecard.md +0 -0
  425. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/assets/scorecard-anchors/scene-1.jpg +0 -0
  426. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/assets/scorecard-anchors/scene-2.jpg +0 -0
  427. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/assets/scorecard-anchors/scene-3.jpg +0 -0
  428. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/checklists/aaa-game-quality-gate.md +0 -0
  429. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/checklists/aaa-visual-scorecard.md +0 -0
  430. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/checklists/material-lighting-quality.md +0 -0
  431. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/checklists/performance-safe-visual-detail.md +0 -0
  432. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/checklists/procedural-model-quality.md +0 -0
  433. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/checklists/technical-art-quality.md +0 -0
  434. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/graphics-prompt-templates.md +0 -0
  435. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/implementation-blueprint.md +0 -0
  436. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/model-recipes.md +0 -0
  437. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/render-recipes.md +0 -0
  438. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/shader-cookbook.md +0 -0
  439. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/technical-art.md +0 -0
  440. /package/{skills → dist/skills/en-US}/threejs-aaa-graphics-builder/references/visual-scorecard.md +0 -0
  441. /package/{skills → dist/skills/zh-CN}/evomeme-canvas/SKILL.md +0 -0
  442. /package/{skills → dist/skills/zh-CN}/evomeme-canvas/agents/openai.yaml +0 -0
  443. /package/{skills → dist/skills/zh-CN}/evomeme-cloud-fs/agents/openai.yaml +0 -0
  444. /package/{skills → dist/skills/zh-CN}/evomeme-cover/agents/openai.yaml +0 -0
  445. /package/{skills → dist/skills/zh-CN}/evomeme-game-maker/agents/openai.yaml +0 -0
  446. /package/{skills → dist/skills/zh-CN}/evomeme-login/agents/openai.yaml +0 -0
  447. /package/{skills → dist/skills/zh-CN}/evomeme-native-bridge-sdk/SKILL.md +0 -0
  448. /package/{skills → dist/skills/zh-CN}/evomeme-native-bridge-sdk/agents/openai.yaml +0 -0
  449. /package/{skills → dist/skills/zh-CN}/evomeme-tos-upload/agents/openai.yaml +0 -0
  450. /package/{skills → dist/skills/zh-CN}/game-art/SKILL.md +0 -0
  451. /package/{skills → dist/skills/zh-CN}/game-art/agents/openai.yaml +0 -0
  452. /package/{skills → dist/skills/zh-CN}/game-asset-image-generator/agents/openai.yaml +0 -0
  453. /package/{skills → dist/skills/zh-CN}/game-demo/SKILL.md +0 -0
  454. /package/{skills → dist/skills/zh-CN}/game-demo/agents/openai.yaml +0 -0
  455. /package/{skills → dist/skills/zh-CN}/game-maker/SKILL.md +0 -0
  456. /package/{skills → dist/skills/zh-CN}/game-maker/agents/openai.yaml +0 -0
  457. /package/{skills → dist/skills/zh-CN}/game-test/SKILL.md +0 -0
  458. /package/{skills → dist/skills/zh-CN}/game-test/agents/openai.yaml +0 -0
  459. /package/{skills → dist/skills/zh-CN}/game-ui/agents/openai.yaml +0 -0
  460. /package/{skills → dist/skills/zh-CN}/phaser-2d-game/SKILL.md +0 -0
  461. /package/{skills → dist/skills/zh-CN}/phaser-2d-game/agents/openai.yaml +0 -0
  462. /package/{skills → dist/skills/zh-CN}/phaser-2d-game/references/engine-performance.md +0 -0
  463. /package/{skills → dist/skills/zh-CN}/phaser-2d-game/references/engine-physics.md +0 -0
  464. /package/{skills → dist/skills/zh-CN}/phaser-2d-game/references/engine-runtime.md +0 -0
  465. /package/{skills → dist/skills/zh-CN}/phaser-2d-game/references/engine-spritesheets.md +0 -0
  466. /package/{skills → dist/skills/zh-CN}/phaser-2d-game/references/engine-tilemaps.md +0 -0
  467. /package/{skills → dist/skills/zh-CN}/phaser-2d-game/references/file-structure.md +0 -0
  468. /package/{skills → dist/skills/zh-CN}/phaser-2d-graphics-builder/SKILL.md +0 -0
  469. /package/{skills → dist/skills/zh-CN}/phaser-2d-graphics-builder/agents/openai.yaml +0 -0
  470. /package/{skills → dist/skills/zh-CN}/threejs-3d-game/agents/openai.yaml +0 -0
  471. /package/{skills → dist/skills/zh-CN}/threejs-3d-game/references/engine-audio.md +0 -0
  472. /package/{skills → dist/skills/zh-CN}/threejs-3d-game/references/engine-input-camera.md +0 -0
  473. /package/{skills → dist/skills/zh-CN}/threejs-3d-game/references/engine-performance.md +0 -0
  474. /package/{skills → dist/skills/zh-CN}/threejs-3d-game/references/engine-physics.md +0 -0
  475. /package/{skills → dist/skills/zh-CN}/threejs-3d-game/references/engine-runtime.md +0 -0
  476. /package/{skills → dist/skills/zh-CN}/threejs-3d-game/references/file-structure.md +0 -0
  477. /package/{skills → dist/skills/zh-CN}/threejs-aaa-graphics-builder/agents/openai.yaml +0 -0
@@ -0,0 +1,982 @@
1
+ import { errorT, errorText } from '../../language/index.js'
2
+ import { t } from '../../language/index.js'
3
+ import { api } from '../../core/api.js'
4
+ import { state } from '../../core/state.js'
5
+ import {
6
+ ensureFeatureState,
7
+ notifyFeatureState,
8
+ subscribeFeatureState,
9
+ } from '../../core/feature-state.js'
10
+ import { el } from '../../ui/controls.js'
11
+
12
+ // Painterro owns only drawing interactions. Parameters and remote submission use the feature controller.
13
+ export default {
14
+ styles: `
15
+ .interactive-editor-stage {
16
+ position: relative;
17
+ flex: 1 1 auto;
18
+ min-height: 440px;
19
+ min-width: 0;
20
+ }
21
+
22
+ .interactive-editor-host {
23
+ position: absolute;
24
+ inset: 0;
25
+ overflow: hidden;
26
+ border: 1px solid var(--line);
27
+ border-radius: 14px;
28
+ background:
29
+ radial-gradient(circle at 50% 15%, rgba(61, 214, 198, 0.06), transparent 38%),
30
+ var(--bg-0);
31
+ }
32
+
33
+ .interactive-editor-host .ptro-wrapper {
34
+ bottom: 0 !important;
35
+ color: var(--text);
36
+ background:
37
+ radial-gradient(circle at 50% 12%, rgba(61, 214, 198, 0.06), transparent 40%),
38
+ var(--bg-0) !important;
39
+ font-family: 'DM Sans', sans-serif !important;
40
+ }
41
+
42
+ .interactive-editor-host .ptro-wrapper .ptro-substrate {
43
+ opacity: 1 !important;
44
+ background: var(--bg-1) !important;
45
+ }
46
+
47
+ .interactive-editor-host .ptro-scroller {
48
+ padding: 20px 20px 20px 72px;
49
+ }
50
+
51
+ .interactive-editor-host.is-panning .ptro-scroller,
52
+ .interactive-editor-host.is-panning .ptro-crp-el {
53
+ cursor: grabbing !important;
54
+ }
55
+
56
+ .interactive-editor-host .ptro-bar {
57
+ top: 50% !important;
58
+ right: auto !important;
59
+ bottom: auto !important;
60
+ left: 14px !important;
61
+ width: auto !important;
62
+ height: auto !important;
63
+ display: flex;
64
+ justify-content: flex-start;
65
+ transform: translateY(-50%);
66
+ pointer-events: none;
67
+ background: transparent !important;
68
+ color: var(--text) !important;
69
+ font-family: 'DM Sans', sans-serif !important;
70
+ z-index: 30;
71
+ }
72
+
73
+ .interactive-editor-host .ptro-bar > div {
74
+ position: relative;
75
+ width: max-content;
76
+ max-width: none;
77
+ height: auto !important;
78
+ min-width: 46px;
79
+ min-height: 0;
80
+ margin: 0 auto;
81
+ padding: 6px;
82
+ display: flex;
83
+ flex-direction: column;
84
+ align-items: center;
85
+ justify-content: center;
86
+ gap: 4px;
87
+ overflow: visible !important;
88
+ pointer-events: auto;
89
+ border: 1px solid var(--line);
90
+ border-radius: 15px;
91
+ background: rgba(26, 31, 39, 0.92);
92
+ box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
93
+ backdrop-filter: blur(18px);
94
+ }
95
+
96
+ .interactive-editor-host .ptro-bar .ptro-icon-btn {
97
+ width: 34px !important;
98
+ height: 34px !important;
99
+ margin: 0 !important;
100
+ padding: 0;
101
+ flex: 0 0 34px;
102
+ border: 1px solid transparent !important;
103
+ border-radius: 50%;
104
+ color: var(--muted) !important;
105
+ background: transparent !important;
106
+ box-shadow: none !important;
107
+ transition:
108
+ color 120ms ease,
109
+ border-color 120ms ease,
110
+ background 120ms ease,
111
+ transform 120ms ease;
112
+ }
113
+
114
+ .interactive-editor-host .ptro-bar .ptro-icon-btn:hover:not(:disabled) {
115
+ color: var(--text) !important;
116
+ border-color: var(--line) !important;
117
+ background: var(--bg-2) !important;
118
+ transform: translateY(-1px);
119
+ }
120
+
121
+ .interactive-editor-host .ptro-bar .ptro-icon-btn.ptro-color-active-control {
122
+ color: #071311 !important;
123
+ border-color: rgba(61, 214, 198, 0.72) !important;
124
+ background: var(--accent) !important;
125
+ box-shadow: 0 6px 18px rgba(61, 214, 198, 0.2) !important;
126
+ }
127
+
128
+ .interactive-editor-host .ptro-bar .ptro-icon-btn:disabled {
129
+ opacity: 0.3;
130
+ cursor: not-allowed;
131
+ }
132
+
133
+ .interactive-editor-host .ptro-bar .ptro-icon-btn svg {
134
+ width: 18px;
135
+ height: 18px;
136
+ fill: none;
137
+ stroke: currentColor;
138
+ stroke-width: 1.8;
139
+ stroke-linecap: round;
140
+ stroke-linejoin: round;
141
+ pointer-events: none;
142
+ }
143
+
144
+ .interactive-editor-host .ptro-tool-controls {
145
+ position: absolute;
146
+ top: 0;
147
+ bottom: auto;
148
+ left: calc(100% + 10px);
149
+ width: max-content;
150
+ min-height: 42px;
151
+ max-width: none;
152
+ padding: 5px 8px;
153
+ display: flex;
154
+ align-items: center;
155
+ justify-content: center;
156
+ gap: 7px;
157
+ flex-wrap: nowrap;
158
+ overflow: visible;
159
+ transform: translateY(-50%);
160
+ border: 1px solid var(--line);
161
+ border-radius: 12px;
162
+ background: rgba(26, 31, 39, 0.94);
163
+ box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
164
+ backdrop-filter: blur(16px);
165
+ }
166
+
167
+ .interactive-editor-host .ptro-bar:not(.has-tool-options) .ptro-tool-controls,
168
+ .interactive-editor-host .ptro-tool-controls:empty {
169
+ display: none;
170
+ }
171
+
172
+ .interactive-editor-host .ptro-tool-controls .ptro-tool-ctl-name {
173
+ margin: 0 0 0 4px !important;
174
+ padding: 0 !important;
175
+ flex: 0 0 auto;
176
+ border-radius: 0 !important;
177
+ color: var(--muted);
178
+ background: transparent !important;
179
+ font-family: 'DM Sans', sans-serif !important;
180
+ font-size: 12px;
181
+ line-height: 32px;
182
+ }
183
+
184
+ .interactive-editor-host .ptro-tool-controls .ptro-input,
185
+ .interactive-editor-host .ptro-tool-controls select.ptro-input {
186
+ width: 64px !important;
187
+ height: 32px !important;
188
+ padding: 0 8px !important;
189
+ border: 1px solid var(--line) !important;
190
+ border-radius: 9px;
191
+ color: var(--text) !important;
192
+ background: var(--bg-0) !important;
193
+ box-shadow: none !important;
194
+ font-family: 'DM Sans', sans-serif !important;
195
+ font-size: 13px !important;
196
+ }
197
+
198
+ .interactive-editor-host .ptro-tool-controls .ptro-color-btn {
199
+ position: relative;
200
+ z-index: 2;
201
+ width: 28px !important;
202
+ height: 28px !important;
203
+ flex: 0 0 28px;
204
+ border: 2px solid rgba(255, 255, 255, 0.82) !important;
205
+ border-radius: 50%;
206
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45) !important;
207
+ }
208
+
209
+ .interactive-editor-host .ptro-tool-controls .ptro-btn-color-checkers-bar {
210
+ display: none;
211
+ }
212
+
213
+ .interactive-editor-host .interactive-crop-hint {
214
+ color: var(--muted);
215
+ font-size: 12px;
216
+ white-space: nowrap;
217
+ }
218
+
219
+ .interactive-editor-host .interactive-crop-apply {
220
+ height: 30px;
221
+ padding: 0 11px;
222
+ border: 1px solid rgba(61, 214, 198, 0.42);
223
+ border-radius: 8px;
224
+ color: #071311;
225
+ background: var(--accent);
226
+ font-size: 12px;
227
+ font-weight: 700;
228
+ cursor: pointer;
229
+ }
230
+
231
+ .interactive-editor-host .interactive-crop-apply:hover {
232
+ filter: brightness(1.06);
233
+ }
234
+
235
+ .interactive-editor-host .ptro-tool-controls [data-id='shadowOn'],
236
+ .interactive-editor-host .ptro-tool-controls [data-id='fontName'],
237
+ .interactive-editor-host .ptro-tool-controls [data-id='fontIsBold'],
238
+ .interactive-editor-host .ptro-tool-controls [data-id='fontIsItalic'],
239
+ .interactive-editor-host .ptro-tool-controls [data-id='fontStrokeAndShadow'],
240
+ .interactive-editor-host .ptro-tool-controls .ptro-tool-ctl-name:has(+ [data-id='shadowOn']),
241
+ .interactive-editor-host .ptro-tool-controls .ptro-tool-ctl-name:has(+ [data-id='fontName']),
242
+ .interactive-editor-host .ptro-tool-controls .ptro-tool-ctl-name:has(+ [data-id='fontIsBold']),
243
+ .interactive-editor-host .ptro-tool-controls .ptro-tool-ctl-name:has(+ [data-id='fontIsItalic']),
244
+ .interactive-editor-host .ptro-tool-controls .ptro-tool-ctl-name:has(+ [data-id='fontStrokeAndShadow']) {
245
+ display: none !important;
246
+ }
247
+
248
+ .interactive-editor-host .ptro-info,
249
+ .interactive-editor-host .ptro-bar-right {
250
+ display: none !important;
251
+ }
252
+
253
+ .interactive-editor-host .ptro-common-widget-wrapper {
254
+ color: var(--text);
255
+ background: rgba(7, 10, 14, 0.62) !important;
256
+ backdrop-filter: blur(4px);
257
+ }
258
+
259
+ .interactive-editor-host .ptro-pallet,
260
+ .interactive-editor-host .ptro-color-widget-wrapper .ptro-v-middle-in {
261
+ border: 1px solid var(--line);
262
+ border-radius: 14px;
263
+ background: var(--bg-1);
264
+ box-shadow: var(--shadow);
265
+ }
266
+
267
+ .interactive-edit-compose {
268
+ flex: 0 0 auto;
269
+ display: flex;
270
+ flex-direction: column;
271
+ gap: 8px;
272
+ }
273
+
274
+ .interactive-edit-compose .layer-decomposition-prompt {
275
+ width: 100%;
276
+ }
277
+
278
+ .interactive-edit-model {
279
+ display: flex;
280
+ align-items: center;
281
+ gap: 8px;
282
+ color: var(--muted);
283
+ font-size: 12px;
284
+ }
285
+
286
+ .interactive-edit-model select {
287
+ min-width: 112px;
288
+ border: 1px solid var(--line);
289
+ border-radius: 8px;
290
+ padding: 6px 9px;
291
+ background: var(--bg-1);
292
+ color: var(--text);
293
+ }
294
+
295
+ .interactive-edit-zoom {
296
+ position: absolute;
297
+ top: 12px;
298
+ right: 12px;
299
+ z-index: 35;
300
+ display: grid;
301
+ grid-template-columns: auto 96px 36px;
302
+ align-items: center;
303
+ gap: 7px;
304
+ min-height: 32px;
305
+ padding: 5px 8px;
306
+ border: 1px solid var(--line);
307
+ border-radius: 10px;
308
+ color: var(--muted);
309
+ background: rgba(26, 31, 39, 0.86);
310
+ box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
311
+ backdrop-filter: blur(16px);
312
+ font-size: 11px;
313
+ line-height: 1;
314
+ }
315
+
316
+ .interactive-edit-zoom input {
317
+ width: 96px;
318
+ height: 16px;
319
+ margin: 0;
320
+ }
321
+
322
+ .interactive-edit-zoom output {
323
+ color: var(--text);
324
+ font-family: 'JetBrains Mono', monospace;
325
+ font-size: 10px;
326
+ text-align: right;
327
+ }
328
+
329
+ .interactive-edit-compose > .modal-actions {
330
+ padding-top: 0;
331
+ }
332
+
333
+ @media (max-width: 760px) {
334
+ .modal-dialog-interactive-edit {
335
+ width: calc(100vw - 16px);
336
+ height: calc(100vh - 16px);
337
+ }
338
+
339
+ .interactive-editor-stage {
340
+ min-height: 360px;
341
+ }
342
+
343
+ }
344
+ `,
345
+ render(ui) {
346
+ const view = ui.view()
347
+ if (view) view.classList.add('interactive-edit-view')
348
+ return ui.stack(view, ui.prompt('prompt'), ui.field('model'), ui.field('html.text075'))
349
+ },
350
+ id: 'interactive-edit',
351
+ title: 'html.text049',
352
+ storage: 'parameters',
353
+ menu: [{ accepts: ['image'] }],
354
+ node: {
355
+ type: 'feature_dialog',
356
+ width: 900,
357
+ minWidth: 520,
358
+ minHeight: 520,
359
+ generationInput: true,
360
+ classNames: ['is-interactive-ui', 'is-interactive-edit'],
361
+ },
362
+ fields: [
363
+ {
364
+ path: 'prompt',
365
+ type: 'textarea',
366
+ default: '',
367
+ required: true,
368
+ label: 'html.text105',
369
+ placeholder: 'html.text019',
370
+ },
371
+ {
372
+ path: 'model',
373
+ type: 'enum',
374
+ default: 'asset-pro',
375
+ label: 'html.text074',
376
+ options: [
377
+ { value: 'asset-pro', labelKey: 'models.assetPro' },
378
+ { value: 'asset-max', labelKey: 'models.assetMax' },
379
+ ],
380
+ },
381
+ { path: 'referenceImageData', type: 'hidden', default: '' },
382
+ { type: 'note', label: 'html.text075' },
383
+ ],
384
+ runtimeDefaults: () => ({ ready: false }),
385
+ ready: (p) => p.ready,
386
+ submitLabel: 'html.text077',
387
+ setup: createInteractiveImageEditing,
388
+ }
389
+
390
+ function createInteractiveImageEditing(services) {
391
+ const views = new Map()
392
+ return {
393
+ mountView(host, item) {
394
+ const view = mountDrawingView(host, item, services)
395
+ views.set(item.id, view)
396
+ return () => {
397
+ view.dispose()
398
+ if (views.get(item.id) === view) views.delete(item.id)
399
+ }
400
+ },
401
+ async task(item, params) {
402
+ const referenceImageData = await views.get(item.id)?.exportImage()
403
+ if (!referenceImageData?.startsWith('data:image/'))
404
+ throw new Error(errorT('features.editing.interactiveImageEditing.text036'))
405
+ params.referenceImageData = referenceImageData
406
+ return {
407
+ endpoint: '/api/generate',
408
+ body: {
409
+ prompt: params.prompt.trim(),
410
+ model: params.model,
411
+ reference_ids: [item.sourceId],
412
+ reference_image_data: referenceImageData,
413
+ },
414
+ wait: {
415
+ name: t('features.editing.interactiveImageEditing.text041'),
416
+ references: [item.sourceId],
417
+ },
418
+ }
419
+ },
420
+ dispose(id) {
421
+ views.get(id)?.dispose()
422
+ views.delete(id)
423
+ },
424
+ }
425
+ }
426
+
427
+ function mountDrawingView(host, item, services) {
428
+ const params = ensureFeatureState(item)
429
+ const { imageUrl } = services
430
+ let interactiveEditor = null,
431
+ interactiveEditorExportRequest = null,
432
+ interactiveEditorInteractionCleanup = null,
433
+ disposed = false
434
+ const stage = el('div', 'interactive-editor-stage')
435
+ stage.style.height = '500px'
436
+ stage.style.flexShrink = '0'
437
+ const drawingHost = el('div', 'interactive-editor-host')
438
+ drawingHost.id = 'drawing-' + item.id
439
+ const zoomLabel = el('label', 'interactive-edit-zoom', t('html.text073'))
440
+ const zoom = el('input'),
441
+ output = el('output')
442
+ zoom.type = 'range'
443
+ zoom.min = '1'
444
+ zoom.max = '400'
445
+ zoom.value = '100'
446
+ zoom.step = '1'
447
+ zoomLabel.append(zoom, output)
448
+ stage.append(drawingHost, zoomLabel)
449
+ const status = el('p', 'modal-hint', t('features.editing.interactiveImageEditing.text026'))
450
+ const save = el('button', 'ghost-btn', t('html.text076'))
451
+ save.type = 'button'
452
+ host.append(stage, status, save)
453
+ const elements = {
454
+ world: host.closest('.canvas-world') || document.getElementById('world'),
455
+ interactiveEditorHost: drawingHost,
456
+ interactiveEditZoom: zoom,
457
+ interactiveEditZoomValue: output,
458
+ interactiveEditStatus: status,
459
+ }
460
+ const reportError = (error) => {
461
+ if (!disposed) {
462
+ params.messages.push({ error: String(error?.message || error) })
463
+ notifyFeatureState(item.id)
464
+ }
465
+ }
466
+ const INTERACTIVE_EDITOR_TRANSLATION = {
467
+ name: 'zh-CN-canvas',
468
+ strings: {
469
+ lineColor: t('features.editing.interactiveImageEditing.text001'),
470
+ lineColorFull: t('features.editing.interactiveImageEditing.text002'),
471
+ fillColor: t('features.editing.interactiveImageEditing.text003'),
472
+ fillColorFull: t('features.editing.interactiveImageEditing.text004'),
473
+ alpha: t('features.editing.interactiveImageEditing.text005'),
474
+ alphaFull: t('features.editing.interactiveImageEditing.text005'),
475
+ lineWidth: t('features.editing.interactiveImageEditing.text006'),
476
+ lineWidthFull: t('features.editing.interactiveImageEditing.text007'),
477
+ arrowLength: t('features.editing.interactiveImageEditing.text008'),
478
+ arrowLengthFull: t('features.editing.interactiveImageEditing.text009'),
479
+ textColor: t('features.editing.interactiveImageEditing.text001'),
480
+ textColorFull: t('features.editing.interactiveImageEditing.text010'),
481
+ fontSize: t('features.editing.interactiveImageEditing.text011'),
482
+ fontSizeFull: t('features.editing.interactiveImageEditing.text012'),
483
+ apply: t('features.editing.interactiveImageEditing.text013'),
484
+ cancel: t('features.editing.interactiveImageEditing.text014'),
485
+ tools: {
486
+ select: t('features.editing.interactiveImageEditing.text015'),
487
+ rect: t('features.editing.interactiveImageEditing.text016'),
488
+ ellipse: t('features.editing.interactiveImageEditing.text017'),
489
+ arrow: t('features.editing.interactiveImageEditing.text018'),
490
+ brush: t('features.editing.interactiveImageEditing.text019'),
491
+ text: t('features.editing.interactiveImageEditing.text020'),
492
+ rotate: t('features.editing.interactiveImageEditing.text021'),
493
+ undo: t('features.editing.interactiveImageEditing.text022'),
494
+ redo: t('features.editing.interactiveImageEditing.text023'),
495
+ },
496
+ },
497
+ }
498
+
499
+ const INTERACTIVE_EDITOR_HIDDEN_TOOLS = [
500
+ 'crop',
501
+ 'pixelize',
502
+ 'line',
503
+ 'filters',
504
+ 'eraser',
505
+ 'resize',
506
+ 'settings',
507
+ 'zoomout',
508
+ 'zoomin',
509
+ 'bucket',
510
+ 'clear',
511
+ 'save',
512
+ 'open',
513
+ 'close',
514
+ ]
515
+
516
+ const INTERACTIVE_EDITOR_TOOL_ORDER = [
517
+ 'arrow',
518
+ 'brush',
519
+ 'rect',
520
+ 'ellipse',
521
+ 'text',
522
+ 'select',
523
+ 'rotate',
524
+ 'undo',
525
+ 'redo',
526
+ ]
527
+
528
+ const INTERACTIVE_EDITOR_TOOL_ICONS = {
529
+ arrow: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 19 19 5M10 5h9v9"/></svg>',
530
+ brush:
531
+ '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3.5 16.5c3-9 6.4 8.2 9.4-.5 2.2-6.4 4.8-5.7 7.6-2.2"/></svg>',
532
+ rect: '<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="4.5" y="5.5" width="15" height="13" rx="1.5"/></svg>',
533
+ ellipse:
534
+ '<svg viewBox="0 0 24 24" aria-hidden="true"><ellipse cx="12" cy="12" rx="8" ry="6.5"/></svg>',
535
+ text: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5 6h14M12 6v13M8.5 19h7"/></svg>',
536
+ select:
537
+ '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M8 4H4v4M16 4h4v4M20 16v4h-4M8 20H4v-4"/></svg>',
538
+ rotate:
539
+ '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20 7v5h-5M19 12a7 7 0 1 1-2-5"/></svg>',
540
+ undo: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 7-4 4 4 4M5 11h8a6 6 0 0 1 6 6"/></svg>',
541
+ redo: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 7 4 4-4 4M19 11h-8a6 6 0 0 0-6 6"/></svg>',
542
+ }
543
+
544
+ function syncInteractiveEditZoomControl(editor) {
545
+ const percentage = Math.max(1, Math.min(400, Math.round((editor?.zoomFactor || 1) * 100)))
546
+ elements.interactiveEditZoom.value = String(percentage)
547
+ elements.interactiveEditZoomValue.value = `${percentage}%`
548
+ elements.interactiveEditZoomValue.textContent = `${percentage}%`
549
+ }
550
+
551
+ function destroyInteractiveEditor() {
552
+ const editor = interactiveEditor
553
+ interactiveEditor = null
554
+ interactiveEditorInteractionCleanup?.()
555
+ interactiveEditorInteractionCleanup = null
556
+ const exportRequest = interactiveEditorExportRequest
557
+ interactiveEditorExportRequest = null
558
+ if (exportRequest) {
559
+ clearTimeout(exportRequest.timeout)
560
+ exportRequest.reject(new Error(errorT('features.editing.interactiveImageEditing.text024')))
561
+ }
562
+ if (editor) {
563
+ try {
564
+ editor.hide()
565
+ } catch {
566
+ /* editor may still be initializing */
567
+ }
568
+ }
569
+ elements.interactiveEditorHost.innerHTML = ''
570
+ }
571
+
572
+ async function initializeInteractiveEditor(imageId) {
573
+ try {
574
+ const PainterroEditor = window.Painterro
575
+ if (typeof PainterroEditor !== 'function')
576
+ throw new Error(errorT('features.editing.interactiveImageEditing.text027'))
577
+ if (disposed) return
578
+ let editor = null
579
+ let loadTimeout = null
580
+ await new Promise((resolve, reject) => {
581
+ const finish = (callback, value) => {
582
+ if (loadTimeout) clearTimeout(loadTimeout)
583
+ callback(value)
584
+ }
585
+ editor = PainterroEditor({
586
+ id: elements.interactiveEditorHost.id,
587
+ defaultTool: 'brush',
588
+ hiddenTools: INTERACTIVE_EDITOR_HIDDEN_TOOLS,
589
+ backgroundFillColorAlpha: 0,
590
+ defaultPrimitiveShadowOn: false,
591
+ defaultTextStrokeAndShadow: false,
592
+ disableWheelZoom: true,
593
+ fixMobilePageReloader: false,
594
+ toolbarHeightPx: 64,
595
+ buttonSizePx: 44,
596
+ colorScheme: {
597
+ main: '#1a1f27',
598
+ control: '#232a34',
599
+ controlShadow: '0 0 0 1px rgba(255,255,255,0.08)',
600
+ controlContent: '#e8edf4',
601
+ hoverControl: '#2d3744',
602
+ hoverControlContent: '#ffffff',
603
+ activeControl: '#3dd6c6',
604
+ activeControlContent: '#0b1214',
605
+ inputBorderColor: 'rgba(255,255,255,0.1)',
606
+ inputBackground: '#12151a',
607
+ inputText: '#e8edf4',
608
+ backgroundColor: '#12151a',
609
+ toolControlNameColor: 'transparent',
610
+ dragOverBarColor: 'rgba(61,214,198,0.18)',
611
+ },
612
+ translation: INTERACTIVE_EDITOR_TRANSLATION,
613
+ onChange: ({ image, operationsDone }) => {
614
+ if (disposed || !params.ready || !operationsDone) return
615
+ params.referenceImageData = image.asDataURL('image/png')
616
+ services.saveLayout().catch(reportError)
617
+ },
618
+ onImageLoaded: () => finish(resolve),
619
+ onImageFailedOpen: () =>
620
+ finish(reject, new Error(errorT('features.editing.interactiveImageEditing.text028'))),
621
+ saveHandler: (image, done) => {
622
+ const request = interactiveEditorExportRequest
623
+ if (!request || request.editor !== editor) {
624
+ done(false)
625
+ return
626
+ }
627
+ interactiveEditorExportRequest = null
628
+ clearTimeout(request.timeout)
629
+ try {
630
+ request.resolve(image.asDataURL('image/png'))
631
+ } catch (error) {
632
+ request.reject(error)
633
+ } finally {
634
+ done(false)
635
+ }
636
+ },
637
+ })
638
+ interactiveEditor = editor
639
+ interactiveEditorInteractionCleanup = installInteractiveEditorInteractions(editor)
640
+ editor.show(params.referenceImageData || imageUrl(imageId))
641
+ loadTimeout = setTimeout(
642
+ () => reject(new Error(errorT('features.editing.interactiveImageEditing.text029'))),
643
+ 10_000,
644
+ )
645
+ })
646
+ if (disposed || interactiveEditor !== editor) return
647
+ decorateInteractiveEditorToolbar(editor)
648
+ syncInteractiveEditZoomControl(editor)
649
+ params.ready = true
650
+ notifyFeatureState(item.id)
651
+ elements.interactiveEditStatus.hidden = true
652
+ } catch (error) {
653
+ if (disposed) return
654
+ destroyInteractiveEditor()
655
+ params.ready = false
656
+ notifyFeatureState(item.id)
657
+ elements.interactiveEditStatus.hidden = false
658
+ elements.interactiveEditStatus.textContent = errorText(error)
659
+ }
660
+ }
661
+
662
+ function decorateInteractiveEditorToolbar(editor) {
663
+ const bar = elements.interactiveEditorHost.querySelector('.ptro-bar > div')
664
+ const controls = bar?.querySelector('.ptro-tool-controls')
665
+ if (!bar || !controls) return
666
+ for (const tool of INTERACTIVE_EDITOR_TOOL_ORDER) {
667
+ const button = bar.querySelector(`button[aria-label="${tool}"]`)
668
+ if (!button) continue
669
+ button.dataset.tool = tool === 'select' ? 'crop' : tool
670
+ button.innerHTML = INTERACTIVE_EDITOR_TOOL_ICONS[tool]
671
+ button.addEventListener('click', () => {
672
+ const toolbar = button.closest('.ptro-bar')
673
+ const isSelectedTool = editor.activeTool?.name === tool
674
+ if (tool === 'select' && isSelectedTool) {
675
+ mountInteractiveCropControls(editor, controls, toolbar)
676
+ }
677
+ const hasOptions = isSelectedTool && !['undo', 'redo', 'rotate'].includes(tool)
678
+ if (hasOptions) {
679
+ controls.style.top = `${button.offsetTop + button.offsetHeight / 2}px`
680
+ }
681
+ toolbar?.classList.toggle('has-tool-options', hasOptions)
682
+ })
683
+ bar.insertBefore(button, controls)
684
+ }
685
+ }
686
+
687
+ function mountInteractiveCropControls(editor, controls, toolbar) {
688
+ controls.innerHTML = ''
689
+ const hint = document.createElement('span')
690
+ hint.className = 'interactive-crop-hint'
691
+ hint.textContent = t('features.editing.interactiveImageEditing.text030')
692
+ const apply = document.createElement('button')
693
+ apply.type = 'button'
694
+ apply.className = 'interactive-crop-apply'
695
+ apply.textContent = t('features.editing.interactiveImageEditing.text031')
696
+ apply.addEventListener('click', (event) => {
697
+ event.preventDefault()
698
+ event.stopPropagation()
699
+ const area = editor.select?.area
700
+ const width = area?.bottoml?.[0] - area?.topl?.[0]
701
+ const height = area?.bottoml?.[1] - area?.topl?.[1]
702
+ if (!editor.select?.shown || !(width > 0 && height > 0)) {
703
+ hint.textContent = t('features.editing.interactiveImageEditing.text032')
704
+ return
705
+ }
706
+ editor.select.doCrop()
707
+ editor.closeActiveTool(true)
708
+ editor.setActiveTool(editor.defaultTool)
709
+ toolbar?.classList.remove('has-tool-options')
710
+ })
711
+ controls.append(hint, apply)
712
+ }
713
+
714
+ function installInteractiveEditorCoordinateFix(host) {
715
+ const nativeGetBoundingClientRect = Element.prototype.getBoundingClientRect
716
+ const patchedElements = new Map()
717
+ let mouseGestureActive = false
718
+
719
+ const coordinateSpace = () => {
720
+ const worldRect = nativeGetBoundingClientRect.call(elements.world)
721
+ return {
722
+ scale: Math.max(0.01, Number(state.camera.scale) || 1),
723
+ originX: worldRect.left,
724
+ originY: worldRect.top,
725
+ }
726
+ }
727
+
728
+ const normalizeX = (value, space) =>
729
+ space.originX + (Number(value) - space.originX) / space.scale
730
+ const normalizeY = (value, space) =>
731
+ space.originY + (Number(value) - space.originY) / space.scale
732
+
733
+ const normalizeRect = (rect) => {
734
+ const space = coordinateSpace()
735
+ const left = normalizeX(rect.left, space)
736
+ const top = normalizeY(rect.top, space)
737
+ const width = rect.width / space.scale
738
+ const height = rect.height / space.scale
739
+ return {
740
+ x: left,
741
+ y: top,
742
+ left,
743
+ top,
744
+ right: left + width,
745
+ bottom: top + height,
746
+ width,
747
+ height,
748
+ toJSON() {
749
+ return {
750
+ x: left,
751
+ y: top,
752
+ left,
753
+ top,
754
+ right: left + width,
755
+ bottom: top + height,
756
+ width,
757
+ height,
758
+ }
759
+ },
760
+ }
761
+ }
762
+
763
+ const patchElement = (element) => {
764
+ if (!(element instanceof Element) || patchedElements.has(element)) return
765
+ const ownDescriptor = Object.getOwnPropertyDescriptor(element, 'getBoundingClientRect')
766
+ const readNativeRect = element.getBoundingClientRect.bind(element)
767
+ try {
768
+ Object.defineProperty(element, 'getBoundingClientRect', {
769
+ configurable: true,
770
+ value: () => normalizeRect(readNativeRect()),
771
+ })
772
+ patchedElements.set(element, ownDescriptor || null)
773
+ } catch {
774
+ /* keep native geometry when a browser does not allow an instance override */
775
+ }
776
+ }
777
+
778
+ patchElement(host)
779
+ for (const element of host.querySelectorAll('*')) patchElement(element)
780
+ const observer = new MutationObserver((records) => {
781
+ for (const record of records) {
782
+ for (const node of record.addedNodes) {
783
+ if (!(node instanceof Element)) continue
784
+ patchElement(node)
785
+ for (const element of node.querySelectorAll('*')) patchElement(element)
786
+ }
787
+ }
788
+ })
789
+ observer.observe(host, { childList: true, subtree: true })
790
+
791
+ const eventBelongsToEditor = (event) =>
792
+ event.target instanceof Node && host.contains(event.target)
793
+ const normalizeMouseEvent = (event) => {
794
+ const space = coordinateSpace()
795
+ try {
796
+ Object.defineProperties(event, {
797
+ clientX: { configurable: true, value: normalizeX(event.clientX, space) },
798
+ clientY: { configurable: true, value: normalizeY(event.clientY, space) },
799
+ })
800
+ } catch {
801
+ /* Chromium permits shadowing these accessors; leave the event intact elsewhere */
802
+ }
803
+ }
804
+ const onMouseDown = (event) => {
805
+ if (!eventBelongsToEditor(event)) return
806
+ mouseGestureActive = true
807
+ normalizeMouseEvent(event)
808
+ }
809
+ const onMouseMove = (event) => {
810
+ if (!mouseGestureActive && !eventBelongsToEditor(event)) return
811
+ normalizeMouseEvent(event)
812
+ }
813
+ const onMouseUp = (event) => {
814
+ if (!mouseGestureActive) return
815
+ normalizeMouseEvent(event)
816
+ mouseGestureActive = false
817
+ }
818
+
819
+ document.addEventListener('mousedown', onMouseDown, true)
820
+ document.addEventListener('mousemove', onMouseMove, true)
821
+ document.addEventListener('mouseup', onMouseUp, true)
822
+
823
+ return () => {
824
+ document.removeEventListener('mousedown', onMouseDown, true)
825
+ document.removeEventListener('mousemove', onMouseMove, true)
826
+ document.removeEventListener('mouseup', onMouseUp, true)
827
+ observer.disconnect()
828
+ for (const [element, descriptor] of patchedElements) {
829
+ if (descriptor) Object.defineProperty(element, 'getBoundingClientRect', descriptor)
830
+ else delete element.getBoundingClientRect
831
+ }
832
+ }
833
+ }
834
+
835
+ function installInteractiveEditorInteractions(editor) {
836
+ const scroller = editor?.scroller
837
+ if (!scroller) return () => undefined
838
+ const removeCoordinateFix = installInteractiveEditorCoordinateFix(
839
+ elements.interactiveEditorHost,
840
+ )
841
+ let pan = null
842
+
843
+ const onMouseDown = (event) => {
844
+ if (event.button !== 1) return
845
+ event.preventDefault()
846
+ event.stopPropagation()
847
+ pan = {
848
+ x: event.clientX,
849
+ y: event.clientY,
850
+ left: scroller.scrollLeft,
851
+ top: scroller.scrollTop,
852
+ }
853
+ elements.interactiveEditorHost.classList.add('is-panning')
854
+ }
855
+
856
+ const onMouseMove = (event) => {
857
+ if (!pan) return
858
+ event.preventDefault()
859
+ event.stopPropagation()
860
+ scroller.scrollLeft = pan.left - (event.clientX - pan.x)
861
+ scroller.scrollTop = pan.top - (event.clientY - pan.y)
862
+ }
863
+
864
+ const stopPanning = (event) => {
865
+ if (!pan) return
866
+ if (event) {
867
+ event.preventDefault()
868
+ event.stopPropagation()
869
+ }
870
+ pan = null
871
+ elements.interactiveEditorHost.classList.remove('is-panning')
872
+ }
873
+
874
+ const onAuxClick = (event) => {
875
+ if (event.button === 1) event.preventDefault()
876
+ }
877
+
878
+ scroller.addEventListener('mousedown', onMouseDown, true)
879
+ scroller.addEventListener('auxclick', onAuxClick)
880
+ window.addEventListener('mousemove', onMouseMove, true)
881
+ window.addEventListener('mouseup', stopPanning, true)
882
+ window.addEventListener('blur', stopPanning)
883
+
884
+ return () => {
885
+ removeCoordinateFix()
886
+ scroller.removeEventListener('mousedown', onMouseDown, true)
887
+ scroller.removeEventListener('auxclick', onAuxClick)
888
+ window.removeEventListener('mousemove', onMouseMove, true)
889
+ window.removeEventListener('mouseup', stopPanning, true)
890
+ window.removeEventListener('blur', stopPanning)
891
+ elements.interactiveEditorHost.classList.remove('is-panning')
892
+ }
893
+ }
894
+
895
+ function exportInteractiveEditor(editor) {
896
+ if (interactiveEditorExportRequest) {
897
+ return Promise.reject(new Error(errorT('features.editing.interactiveImageEditing.text033')))
898
+ }
899
+ return new Promise((resolve, reject) => {
900
+ const timeout = setTimeout(() => {
901
+ if (interactiveEditorExportRequest?.editor !== editor) return
902
+ interactiveEditorExportRequest = null
903
+ reject(new Error(errorT('features.editing.interactiveImageEditing.text034')))
904
+ }, 10_000)
905
+ interactiveEditorExportRequest = { editor, resolve, reject, timeout }
906
+ try {
907
+ editor.save()
908
+ } catch (error) {
909
+ interactiveEditorExportRequest = null
910
+ clearTimeout(timeout)
911
+ reject(error)
912
+ }
913
+ })
914
+ }
915
+
916
+ zoom.addEventListener('input', () => {
917
+ interactiveEditor?.setZoom(Number(zoom.value))
918
+ syncInteractiveEditZoomControl(interactiveEditor)
919
+ })
920
+ const unsubscribe = subscribeFeatureState(item.id, () => {
921
+ save.disabled = params.busy || !params.ready
922
+ zoom.disabled = params.busy || !params.ready
923
+ drawingHost.style.pointerEvents = params.busy ? 'none' : ''
924
+ })
925
+ save.addEventListener('click', async () => {
926
+ if (params.busy || !params.ready) return
927
+ params.busy = true
928
+ notifyFeatureState(item.id)
929
+ const operation = services.beginActiveOperation('interactive-edit-save')
930
+ try {
931
+ const data = await exportInteractiveEditor(interactiveEditor)
932
+ const sourceName = String(services.imageName(item.sourceId) || 'image').replace(
933
+ /\.[^.]+$/,
934
+ '',
935
+ )
936
+ const saved = await api('/api/upload', {
937
+ method: 'POST',
938
+ headers: { 'Content-Type': 'application/json' },
939
+ body: JSON.stringify({
940
+ name: sourceName + '_edited.png',
941
+ data,
942
+ place: false,
943
+ operation: 'interactive_edit',
944
+ source_id: item.sourceId,
945
+ }),
946
+ })
947
+ await services.replaceLocal(item, [
948
+ {
949
+ id: saved.id,
950
+ name: saved.name,
951
+ x: item.x,
952
+ y: item.y,
953
+ width: 220,
954
+ height: null,
955
+ references: [{ id: item.sourceId, role: 'source' }],
956
+ },
957
+ ])
958
+ await services.reload()
959
+ services.setSelection([saved.id])
960
+ services.renderChrome()
961
+ } catch (error) {
962
+ reportError(error)
963
+ } finally {
964
+ params.busy = false
965
+ services.endActiveOperation(operation)
966
+ notifyFeatureState(item.id)
967
+ }
968
+ })
969
+ requestAnimationFrame(() => {
970
+ if (!disposed) initializeInteractiveEditor(item.sourceId)
971
+ })
972
+ return {
973
+ exportImage: () => exportInteractiveEditor(interactiveEditor),
974
+ dispose() {
975
+ if (disposed) return
976
+ disposed = true
977
+ params.ready = false
978
+ unsubscribe()
979
+ destroyInteractiveEditor()
980
+ },
981
+ }
982
+ }