@fraziym/axoniz 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (512) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -0
  3. package/dist/agents/definition.d.ts +15 -0
  4. package/dist/agents/definition.d.ts.map +1 -0
  5. package/dist/agents/definition.js +41 -0
  6. package/dist/agents/definition.js.map +1 -0
  7. package/dist/agents/index.d.ts +12 -0
  8. package/dist/agents/index.d.ts.map +1 -0
  9. package/dist/agents/index.js +11 -0
  10. package/dist/agents/index.js.map +1 -0
  11. package/dist/agents/registry.d.ts +17 -0
  12. package/dist/agents/registry.d.ts.map +1 -0
  13. package/dist/agents/registry.js +23 -0
  14. package/dist/agents/registry.js.map +1 -0
  15. package/dist/agents/specialized.d.ts +31 -0
  16. package/dist/agents/specialized.d.ts.map +1 -0
  17. package/dist/agents/specialized.js +75 -0
  18. package/dist/agents/specialized.js.map +1 -0
  19. package/dist/awareness/index.d.ts +14 -0
  20. package/dist/awareness/index.d.ts.map +1 -0
  21. package/dist/awareness/index.js +22 -0
  22. package/dist/awareness/index.js.map +1 -0
  23. package/dist/awareness/service.d.ts +180 -0
  24. package/dist/awareness/service.d.ts.map +1 -0
  25. package/dist/awareness/service.js +789 -0
  26. package/dist/awareness/service.js.map +1 -0
  27. package/dist/cli/entry.d.ts +13 -0
  28. package/dist/cli/entry.d.ts.map +1 -0
  29. package/dist/cli/entry.js +35 -0
  30. package/dist/cli/entry.js.map +1 -0
  31. package/dist/comms/telegram.d.ts +41 -0
  32. package/dist/comms/telegram.d.ts.map +1 -0
  33. package/dist/comms/telegram.js +332 -0
  34. package/dist/comms/telegram.js.map +1 -0
  35. package/dist/core/agent.d.ts +252 -0
  36. package/dist/core/agent.d.ts.map +1 -0
  37. package/dist/core/agent.js +1399 -0
  38. package/dist/core/agent.js.map +1 -0
  39. package/dist/core/auth.d.ts +23 -0
  40. package/dist/core/auth.d.ts.map +1 -0
  41. package/dist/core/auth.js +113 -0
  42. package/dist/core/auth.js.map +1 -0
  43. package/dist/core/authority.d.ts +118 -0
  44. package/dist/core/authority.d.ts.map +1 -0
  45. package/dist/core/authority.js +402 -0
  46. package/dist/core/authority.js.map +1 -0
  47. package/dist/core/backend/async_queue.d.ts +17 -0
  48. package/dist/core/backend/async_queue.d.ts.map +1 -0
  49. package/dist/core/backend/async_queue.js +66 -0
  50. package/dist/core/backend/async_queue.js.map +1 -0
  51. package/dist/core/backend/index.d.ts +24 -0
  52. package/dist/core/backend/index.d.ts.map +1 -0
  53. package/dist/core/backend/index.js +128 -0
  54. package/dist/core/backend/index.js.map +1 -0
  55. package/dist/core/backend/llama_server.d.ts +39 -0
  56. package/dist/core/backend/llama_server.d.ts.map +1 -0
  57. package/dist/core/backend/llama_server.js +182 -0
  58. package/dist/core/backend/llama_server.js.map +1 -0
  59. package/dist/core/backend/llamacpp.d.ts +40 -0
  60. package/dist/core/backend/llamacpp.d.ts.map +1 -0
  61. package/dist/core/backend/llamacpp.js +200 -0
  62. package/dist/core/backend/llamacpp.js.map +1 -0
  63. package/dist/core/backend/lmstudio.d.ts +53 -0
  64. package/dist/core/backend/lmstudio.d.ts.map +1 -0
  65. package/dist/core/backend/lmstudio.js +274 -0
  66. package/dist/core/backend/lmstudio.js.map +1 -0
  67. package/dist/core/backend/ollama.d.ts +25 -0
  68. package/dist/core/backend/ollama.d.ts.map +1 -0
  69. package/dist/core/backend/ollama.js +86 -0
  70. package/dist/core/backend/ollama.js.map +1 -0
  71. package/dist/core/backend/openai.d.ts +27 -0
  72. package/dist/core/backend/openai.d.ts.map +1 -0
  73. package/dist/core/backend/openai.js +84 -0
  74. package/dist/core/backend/openai.js.map +1 -0
  75. package/dist/core/backend/types.d.ts +73 -0
  76. package/dist/core/backend/types.d.ts.map +1 -0
  77. package/dist/core/backend/types.js +137 -0
  78. package/dist/core/backend/types.js.map +1 -0
  79. package/dist/core/chat_store.d.ts +77 -0
  80. package/dist/core/chat_store.d.ts.map +1 -0
  81. package/dist/core/chat_store.js +332 -0
  82. package/dist/core/chat_store.js.map +1 -0
  83. package/dist/core/cli.d.ts +82 -0
  84. package/dist/core/cli.d.ts.map +1 -0
  85. package/dist/core/cli.js +602 -0
  86. package/dist/core/cli.js.map +1 -0
  87. package/dist/core/config.d.ts +127 -0
  88. package/dist/core/config.d.ts.map +1 -0
  89. package/dist/core/config.js +295 -0
  90. package/dist/core/config.js.map +1 -0
  91. package/dist/core/debug.d.ts +8 -0
  92. package/dist/core/debug.d.ts.map +1 -0
  93. package/dist/core/debug.js +8 -0
  94. package/dist/core/debug.js.map +1 -0
  95. package/dist/core/downloader.d.ts +31 -0
  96. package/dist/core/downloader.d.ts.map +1 -0
  97. package/dist/core/downloader.js +180 -0
  98. package/dist/core/downloader.js.map +1 -0
  99. package/dist/core/errors.d.ts +80 -0
  100. package/dist/core/errors.d.ts.map +1 -0
  101. package/dist/core/errors.js +134 -0
  102. package/dist/core/errors.js.map +1 -0
  103. package/dist/core/extras.d.ts +160 -0
  104. package/dist/core/extras.d.ts.map +1 -0
  105. package/dist/core/extras.js +553 -0
  106. package/dist/core/extras.js.map +1 -0
  107. package/dist/core/health.d.ts +27 -0
  108. package/dist/core/health.d.ts.map +1 -0
  109. package/dist/core/health.js +96 -0
  110. package/dist/core/health.js.map +1 -0
  111. package/dist/core/history.d.ts +50 -0
  112. package/dist/core/history.d.ts.map +1 -0
  113. package/dist/core/history.js +276 -0
  114. package/dist/core/history.js.map +1 -0
  115. package/dist/core/index.d.ts +6 -0
  116. package/dist/core/index.d.ts.map +1 -0
  117. package/dist/core/index.js +6 -0
  118. package/dist/core/index.js.map +1 -0
  119. package/dist/core/intelligence/ast_index.d.ts +255 -0
  120. package/dist/core/intelligence/ast_index.d.ts.map +1 -0
  121. package/dist/core/intelligence/ast_index.js +1369 -0
  122. package/dist/core/intelligence/ast_index.js.map +1 -0
  123. package/dist/core/intelligence/confidence.d.ts +113 -0
  124. package/dist/core/intelligence/confidence.d.ts.map +1 -0
  125. package/dist/core/intelligence/confidence.js +298 -0
  126. package/dist/core/intelligence/confidence.js.map +1 -0
  127. package/dist/core/intelligence/context_compressor.d.ts +80 -0
  128. package/dist/core/intelligence/context_compressor.d.ts.map +1 -0
  129. package/dist/core/intelligence/context_compressor.js +245 -0
  130. package/dist/core/intelligence/context_compressor.js.map +1 -0
  131. package/dist/core/intelligence/daemon.d.ts +247 -0
  132. package/dist/core/intelligence/daemon.d.ts.map +1 -0
  133. package/dist/core/intelligence/daemon.js +842 -0
  134. package/dist/core/intelligence/daemon.js.map +1 -0
  135. package/dist/core/intelligence/index.d.ts +60 -0
  136. package/dist/core/intelligence/index.d.ts.map +1 -0
  137. package/dist/core/intelligence/index.js +101 -0
  138. package/dist/core/intelligence/index.js.map +1 -0
  139. package/dist/core/intelligence/predictor.d.ts +246 -0
  140. package/dist/core/intelligence/predictor.d.ts.map +1 -0
  141. package/dist/core/intelligence/predictor.js +590 -0
  142. package/dist/core/intelligence/predictor.js.map +1 -0
  143. package/dist/core/intelligence/reflex.d.ts +84 -0
  144. package/dist/core/intelligence/reflex.d.ts.map +1 -0
  145. package/dist/core/intelligence/reflex.js +344 -0
  146. package/dist/core/intelligence/reflex.js.map +1 -0
  147. package/dist/core/intelligence/self_correction.d.ts +121 -0
  148. package/dist/core/intelligence/self_correction.d.ts.map +1 -0
  149. package/dist/core/intelligence/self_correction.js +327 -0
  150. package/dist/core/intelligence/self_correction.js.map +1 -0
  151. package/dist/core/intelligence/skill_distiller.d.ts +100 -0
  152. package/dist/core/intelligence/skill_distiller.d.ts.map +1 -0
  153. package/dist/core/intelligence/skill_distiller.js +246 -0
  154. package/dist/core/intelligence/skill_distiller.js.map +1 -0
  155. package/dist/core/intelligence/swarm.d.ts +330 -0
  156. package/dist/core/intelligence/swarm.d.ts.map +1 -0
  157. package/dist/core/intelligence/swarm.js +1064 -0
  158. package/dist/core/intelligence/swarm.js.map +1 -0
  159. package/dist/core/intelligence/trajectory.d.ts +107 -0
  160. package/dist/core/intelligence/trajectory.d.ts.map +1 -0
  161. package/dist/core/intelligence/trajectory.js +330 -0
  162. package/dist/core/intelligence/trajectory.js.map +1 -0
  163. package/dist/core/logger.d.ts +111 -0
  164. package/dist/core/logger.d.ts.map +1 -0
  165. package/dist/core/logger.js +640 -0
  166. package/dist/core/logger.js.map +1 -0
  167. package/dist/core/loop.d.ts +123 -0
  168. package/dist/core/loop.d.ts.map +1 -0
  169. package/dist/core/loop.js +423 -0
  170. package/dist/core/loop.js.map +1 -0
  171. package/dist/core/memory.d.ts +81 -0
  172. package/dist/core/memory.d.ts.map +1 -0
  173. package/dist/core/memory.js +328 -0
  174. package/dist/core/memory.js.map +1 -0
  175. package/dist/core/metrics.d.ts +29 -0
  176. package/dist/core/metrics.d.ts.map +1 -0
  177. package/dist/core/metrics.js +109 -0
  178. package/dist/core/metrics.js.map +1 -0
  179. package/dist/core/models.d.ts +51 -0
  180. package/dist/core/models.d.ts.map +1 -0
  181. package/dist/core/models.js +146 -0
  182. package/dist/core/models.js.map +1 -0
  183. package/dist/core/optimizer.d.ts +34 -0
  184. package/dist/core/optimizer.d.ts.map +1 -0
  185. package/dist/core/optimizer.js +131 -0
  186. package/dist/core/optimizer.js.map +1 -0
  187. package/dist/core/persona.d.ts +35 -0
  188. package/dist/core/persona.d.ts.map +1 -0
  189. package/dist/core/persona.js +126 -0
  190. package/dist/core/persona.js.map +1 -0
  191. package/dist/core/rate_limit.d.ts +23 -0
  192. package/dist/core/rate_limit.d.ts.map +1 -0
  193. package/dist/core/rate_limit.js +62 -0
  194. package/dist/core/rate_limit.js.map +1 -0
  195. package/dist/core/runner.d.ts +63 -0
  196. package/dist/core/runner.d.ts.map +1 -0
  197. package/dist/core/runner.js +671 -0
  198. package/dist/core/runner.js.map +1 -0
  199. package/dist/core/stream_parser.d.ts +43 -0
  200. package/dist/core/stream_parser.d.ts.map +1 -0
  201. package/dist/core/stream_parser.js +140 -0
  202. package/dist/core/stream_parser.js.map +1 -0
  203. package/dist/core/tool_schemas.d.ts +26 -0
  204. package/dist/core/tool_schemas.d.ts.map +1 -0
  205. package/dist/core/tool_schemas.js +124 -0
  206. package/dist/core/tool_schemas.js.map +1 -0
  207. package/dist/core/which.d.ts +2 -0
  208. package/dist/core/which.d.ts.map +1 -0
  209. package/dist/core/which.js +35 -0
  210. package/dist/core/which.js.map +1 -0
  211. package/dist/goals/index.d.ts +9 -0
  212. package/dist/goals/index.d.ts.map +1 -0
  213. package/dist/goals/index.js +17 -0
  214. package/dist/goals/index.js.map +1 -0
  215. package/dist/goals/service.d.ts +115 -0
  216. package/dist/goals/service.d.ts.map +1 -0
  217. package/dist/goals/service.js +415 -0
  218. package/dist/goals/service.js.map +1 -0
  219. package/dist/goals/types.d.ts +47 -0
  220. package/dist/goals/types.d.ts.map +1 -0
  221. package/dist/goals/types.js +66 -0
  222. package/dist/goals/types.js.map +1 -0
  223. package/dist/index.d.ts +22 -0
  224. package/dist/index.d.ts.map +1 -0
  225. package/dist/index.js +22 -0
  226. package/dist/index.js.map +1 -0
  227. package/dist/integrations/autonomous_startup.d.ts +51 -0
  228. package/dist/integrations/autonomous_startup.d.ts.map +1 -0
  229. package/dist/integrations/autonomous_startup.js +419 -0
  230. package/dist/integrations/autonomous_startup.js.map +1 -0
  231. package/dist/integrations/goose.d.ts +105 -0
  232. package/dist/integrations/goose.d.ts.map +1 -0
  233. package/dist/integrations/goose.js +408 -0
  234. package/dist/integrations/goose.js.map +1 -0
  235. package/dist/integrations/index.d.ts +21 -0
  236. package/dist/integrations/index.d.ts.map +1 -0
  237. package/dist/integrations/index.js +17 -0
  238. package/dist/integrations/index.js.map +1 -0
  239. package/dist/integrations/mcp.d.ts +73 -0
  240. package/dist/integrations/mcp.d.ts.map +1 -0
  241. package/dist/integrations/mcp.js +307 -0
  242. package/dist/integrations/mcp.js.map +1 -0
  243. package/dist/integrations/mempalace.d.ts +18 -0
  244. package/dist/integrations/mempalace.d.ts.map +1 -0
  245. package/dist/integrations/mempalace.js +25 -0
  246. package/dist/integrations/mempalace.js.map +1 -0
  247. package/dist/integrations/multi_agent.d.ts +82 -0
  248. package/dist/integrations/multi_agent.d.ts.map +1 -0
  249. package/dist/integrations/multi_agent.js +280 -0
  250. package/dist/integrations/multi_agent.js.map +1 -0
  251. package/dist/integrations/unified_memory.d.ts +415 -0
  252. package/dist/integrations/unified_memory.d.ts.map +1 -0
  253. package/dist/integrations/unified_memory.js +1489 -0
  254. package/dist/integrations/unified_memory.js.map +1 -0
  255. package/dist/roles/beru.yaml +48 -0
  256. package/dist/sidecar/client.d.ts +63 -0
  257. package/dist/sidecar/client.d.ts.map +1 -0
  258. package/dist/sidecar/client.js +222 -0
  259. package/dist/sidecar/client.js.map +1 -0
  260. package/dist/sidecar/index.d.ts +7 -0
  261. package/dist/sidecar/index.d.ts.map +1 -0
  262. package/dist/sidecar/index.js +6 -0
  263. package/dist/sidecar/index.js.map +1 -0
  264. package/dist/startup.d.ts +22 -0
  265. package/dist/startup.d.ts.map +1 -0
  266. package/dist/startup.js +194 -0
  267. package/dist/startup.js.map +1 -0
  268. package/dist/tools/_internal.d.ts +90 -0
  269. package/dist/tools/_internal.d.ts.map +1 -0
  270. package/dist/tools/_internal.js +375 -0
  271. package/dist/tools/_internal.js.map +1 -0
  272. package/dist/tools/_smoke.d.ts +2 -0
  273. package/dist/tools/_smoke.d.ts.map +1 -0
  274. package/dist/tools/_smoke.js +203 -0
  275. package/dist/tools/_smoke.js.map +1 -0
  276. package/dist/tools/axodex_tools.d.ts +51 -0
  277. package/dist/tools/axodex_tools.d.ts.map +1 -0
  278. package/dist/tools/axodex_tools.js +181 -0
  279. package/dist/tools/axodex_tools.js.map +1 -0
  280. package/dist/tools/code_tools.d.ts +33 -0
  281. package/dist/tools/code_tools.d.ts.map +1 -0
  282. package/dist/tools/code_tools.js +191 -0
  283. package/dist/tools/code_tools.js.map +1 -0
  284. package/dist/tools/computer_tools.d.ts +59 -0
  285. package/dist/tools/computer_tools.d.ts.map +1 -0
  286. package/dist/tools/computer_tools.js +348 -0
  287. package/dist/tools/computer_tools.js.map +1 -0
  288. package/dist/tools/file_tools.d.ts +51 -0
  289. package/dist/tools/file_tools.d.ts.map +1 -0
  290. package/dist/tools/file_tools.js +424 -0
  291. package/dist/tools/file_tools.js.map +1 -0
  292. package/dist/tools/index.d.ts +13 -0
  293. package/dist/tools/index.d.ts.map +1 -0
  294. package/dist/tools/index.js +13 -0
  295. package/dist/tools/index.js.map +1 -0
  296. package/dist/tools/shell_tools.d.ts +39 -0
  297. package/dist/tools/shell_tools.d.ts.map +1 -0
  298. package/dist/tools/shell_tools.js +163 -0
  299. package/dist/tools/shell_tools.js.map +1 -0
  300. package/dist/tools/web_tools.d.ts +31 -0
  301. package/dist/tools/web_tools.d.ts.map +1 -0
  302. package/dist/tools/web_tools.js +117 -0
  303. package/dist/tools/web_tools.js.map +1 -0
  304. package/dist/voice/index.d.ts +41 -0
  305. package/dist/voice/index.d.ts.map +1 -0
  306. package/dist/voice/index.js +58 -0
  307. package/dist/voice/index.js.map +1 -0
  308. package/dist/voice/light_daemon.d.ts +197 -0
  309. package/dist/voice/light_daemon.d.ts.map +1 -0
  310. package/dist/voice/light_daemon.js +746 -0
  311. package/dist/voice/light_daemon.js.map +1 -0
  312. package/dist/voice/setup.d.ts +63 -0
  313. package/dist/voice/setup.d.ts.map +1 -0
  314. package/dist/voice/setup.js +443 -0
  315. package/dist/voice/setup.js.map +1 -0
  316. package/dist/voice/stt.d.ts +148 -0
  317. package/dist/voice/stt.d.ts.map +1 -0
  318. package/dist/voice/stt.js +361 -0
  319. package/dist/voice/stt.js.map +1 -0
  320. package/dist/voice/tts.d.ts +168 -0
  321. package/dist/voice/tts.d.ts.map +1 -0
  322. package/dist/voice/tts.js +698 -0
  323. package/dist/voice/tts.js.map +1 -0
  324. package/dist/voice/voice_loop.d.ts +101 -0
  325. package/dist/voice/voice_loop.d.ts.map +1 -0
  326. package/dist/voice/voice_loop.js +463 -0
  327. package/dist/voice/voice_loop.js.map +1 -0
  328. package/dist/voice/wake_word.d.ts +153 -0
  329. package/dist/voice/wake_word.d.ts.map +1 -0
  330. package/dist/voice/wake_word.js +458 -0
  331. package/dist/voice/wake_word.js.map +1 -0
  332. package/dist/voice/wav.d.ts +99 -0
  333. package/dist/voice/wav.d.ts.map +1 -0
  334. package/dist/voice/wav.js +306 -0
  335. package/dist/voice/wav.js.map +1 -0
  336. package/dist/web/broker.d.ts +33 -0
  337. package/dist/web/broker.d.ts.map +1 -0
  338. package/dist/web/broker.js +58 -0
  339. package/dist/web/broker.js.map +1 -0
  340. package/dist/web/open_browser.d.ts +2 -0
  341. package/dist/web/open_browser.d.ts.map +1 -0
  342. package/dist/web/open_browser.js +42 -0
  343. package/dist/web/open_browser.js.map +1 -0
  344. package/dist/web/server.d.ts +54 -0
  345. package/dist/web/server.d.ts.map +1 -0
  346. package/dist/web/server.js +831 -0
  347. package/dist/web/server.js.map +1 -0
  348. package/dist/web/static/app.js +4121 -0
  349. package/dist/web/static/index.html +2281 -0
  350. package/dist/web/static/js/MODULE_SUMMARY.md +124 -0
  351. package/dist/web/static/js/a11y.js +165 -0
  352. package/dist/web/static/js/admin.js +2145 -0
  353. package/dist/web/static/js/assistant.js +475 -0
  354. package/dist/web/static/js/calendar/reminders.js +114 -0
  355. package/dist/web/static/js/calendar/utils.js +166 -0
  356. package/dist/web/static/js/calendar.js +3348 -0
  357. package/dist/web/static/js/censor.js +356 -0
  358. package/dist/web/static/js/chat.js +4546 -0
  359. package/dist/web/static/js/chatRenderer.js +2294 -0
  360. package/dist/web/static/js/chatStream.js +276 -0
  361. package/dist/web/static/js/codeRunner.js +398 -0
  362. package/dist/web/static/js/color/hex.js +14 -0
  363. package/dist/web/static/js/colorPicker.js +453 -0
  364. package/dist/web/static/js/compare/icons.js +77 -0
  365. package/dist/web/static/js/compare/index.js +1482 -0
  366. package/dist/web/static/js/compare/models.js +104 -0
  367. package/dist/web/static/js/compare/panes.js +817 -0
  368. package/dist/web/static/js/compare/probe.js +78 -0
  369. package/dist/web/static/js/compare/scoreboard.js +223 -0
  370. package/dist/web/static/js/compare/selector.js +1335 -0
  371. package/dist/web/static/js/compare/state.js +58 -0
  372. package/dist/web/static/js/compare/stream.js +695 -0
  373. package/dist/web/static/js/compare/vote.js +254 -0
  374. package/dist/web/static/js/cookbook-diagnosis.js +694 -0
  375. package/dist/web/static/js/cookbook-hwfit.js +1888 -0
  376. package/dist/web/static/js/cookbook.js +2093 -0
  377. package/dist/web/static/js/cookbookDownload.js +633 -0
  378. package/dist/web/static/js/cookbookProgressSignal.js +29 -0
  379. package/dist/web/static/js/cookbookRunning.js +3506 -0
  380. package/dist/web/static/js/cookbookServe.js +2128 -0
  381. package/dist/web/static/js/document.js +9731 -0
  382. package/dist/web/static/js/documentLibrary.js +3376 -0
  383. package/dist/web/static/js/dragSort.js +265 -0
  384. package/dist/web/static/js/editor/ai-inpaint.js +374 -0
  385. package/dist/web/static/js/editor/ai-models.js +273 -0
  386. package/dist/web/static/js/editor/ai-rembg.js +230 -0
  387. package/dist/web/static/js/editor/ai-tool-runner.js +147 -0
  388. package/dist/web/static/js/editor/ai-tools-misc.js +216 -0
  389. package/dist/web/static/js/editor/build/controls.js +366 -0
  390. package/dist/web/static/js/editor/build/popups.js +112 -0
  391. package/dist/web/static/js/editor/build/right-panel.js +200 -0
  392. package/dist/web/static/js/editor/build/toolbar.js +73 -0
  393. package/dist/web/static/js/editor/build/topbar.js +131 -0
  394. package/dist/web/static/js/editor/build/transform-popup.js +109 -0
  395. package/dist/web/static/js/editor/canvas-coords.js +21 -0
  396. package/dist/web/static/js/editor/canvas-events.js +197 -0
  397. package/dist/web/static/js/editor/canvas-transforms.js +132 -0
  398. package/dist/web/static/js/editor/checkerboard.js +24 -0
  399. package/dist/web/static/js/editor/clipboard-and-drop.js +133 -0
  400. package/dist/web/static/js/editor/composite-helpers.js +83 -0
  401. package/dist/web/static/js/editor/filters/blur.js +118 -0
  402. package/dist/web/static/js/editor/filters/edge-feather.js +70 -0
  403. package/dist/web/static/js/editor/fx/adj-popup.js +677 -0
  404. package/dist/web/static/js/editor/fx/filter-string.js +38 -0
  405. package/dist/web/static/js/editor/fx/histogram.js +67 -0
  406. package/dist/web/static/js/editor/fx/pixel-pass.js +249 -0
  407. package/dist/web/static/js/editor/harmonize-masks.js +116 -0
  408. package/dist/web/static/js/editor/history-panel.js +176 -0
  409. package/dist/web/static/js/editor/keyboard-shortcuts.js +271 -0
  410. package/dist/web/static/js/editor/layer-helpers.js +131 -0
  411. package/dist/web/static/js/editor/layer-panel.js +600 -0
  412. package/dist/web/static/js/editor/mask-utils.js +91 -0
  413. package/dist/web/static/js/editor/shortcuts-popover.js +149 -0
  414. package/dist/web/static/js/editor/slider-ux.js +191 -0
  415. package/dist/web/static/js/editor/snap.js +107 -0
  416. package/dist/web/static/js/editor/state.js +257 -0
  417. package/dist/web/static/js/editor/stroke-pipeline.js +162 -0
  418. package/dist/web/static/js/editor/stroke-tool-sliders.js +64 -0
  419. package/dist/web/static/js/editor/tools/clone.js +81 -0
  420. package/dist/web/static/js/editor/tools/crop.js +137 -0
  421. package/dist/web/static/js/editor/tools/flood-fill.js +72 -0
  422. package/dist/web/static/js/editor/tools/lasso-mask.js +171 -0
  423. package/dist/web/static/js/editor/tools/lasso.js +65 -0
  424. package/dist/web/static/js/editor/tools/move.js +79 -0
  425. package/dist/web/static/js/editor/tools/stroke.js +123 -0
  426. package/dist/web/static/js/editor/tools/transform-drag.js +174 -0
  427. package/dist/web/static/js/editor/tools/transform-handles.js +271 -0
  428. package/dist/web/static/js/editor/tools/transform-session.js +381 -0
  429. package/dist/web/static/js/editor/tools/wand.js +46 -0
  430. package/dist/web/static/js/editor/wire-import.js +148 -0
  431. package/dist/web/static/js/editor/wire-inpaint-controls.js +164 -0
  432. package/dist/web/static/js/editor/wire-merge-buttons.js +103 -0
  433. package/dist/web/static/js/editor/wire-selection-controls.js +170 -0
  434. package/dist/web/static/js/editor/wire-topbar-menus.js +174 -0
  435. package/dist/web/static/js/editor/wire-topbar-overflow.js +49 -0
  436. package/dist/web/static/js/editor/wire-topbar.js +188 -0
  437. package/dist/web/static/js/emailInbox.js +1245 -0
  438. package/dist/web/static/js/emailLibrary/replyRecipients.js +27 -0
  439. package/dist/web/static/js/emailLibrary/signatureFold.js +339 -0
  440. package/dist/web/static/js/emailLibrary/state.js +34 -0
  441. package/dist/web/static/js/emailLibrary/utils.js +202 -0
  442. package/dist/web/static/js/emailLibrary.js +5217 -0
  443. package/dist/web/static/js/emojiPicker.js +311 -0
  444. package/dist/web/static/js/escMenuStack.js +102 -0
  445. package/dist/web/static/js/fileHandler.js +295 -0
  446. package/dist/web/static/js/gallery.js +2835 -0
  447. package/dist/web/static/js/galleryEditor.js +3798 -0
  448. package/dist/web/static/js/group.js +955 -0
  449. package/dist/web/static/js/init.js +405 -0
  450. package/dist/web/static/js/keyboard-shortcuts.js +292 -0
  451. package/dist/web/static/js/langIcons.js +187 -0
  452. package/dist/web/static/js/markdown/tableRow.js +19 -0
  453. package/dist/web/static/js/markdown.js +806 -0
  454. package/dist/web/static/js/memory.js +1418 -0
  455. package/dist/web/static/js/modalManager.js +1552 -0
  456. package/dist/web/static/js/modalSnap.js +782 -0
  457. package/dist/web/static/js/model/matchKey.js +19 -0
  458. package/dist/web/static/js/modelPicker.js +695 -0
  459. package/dist/web/static/js/modelSort.js +33 -0
  460. package/dist/web/static/js/models.js +642 -0
  461. package/dist/web/static/js/notes.js +5054 -0
  462. package/dist/web/static/js/package.json +1 -0
  463. package/dist/web/static/js/platform.js +47 -0
  464. package/dist/web/static/js/presets.js +1110 -0
  465. package/dist/web/static/js/providers.js +93 -0
  466. package/dist/web/static/js/rag.js +177 -0
  467. package/dist/web/static/js/research/jobs.js +335 -0
  468. package/dist/web/static/js/research/panel.js +1233 -0
  469. package/dist/web/static/js/researchSynapse.js +225 -0
  470. package/dist/web/static/js/search-chat.js +201 -0
  471. package/dist/web/static/js/search.js +52 -0
  472. package/dist/web/static/js/section-management.js +260 -0
  473. package/dist/web/static/js/sessions.js +3108 -0
  474. package/dist/web/static/js/settings.js +4991 -0
  475. package/dist/web/static/js/sidebar-layout.js +573 -0
  476. package/dist/web/static/js/signature.js +504 -0
  477. package/dist/web/static/js/skills.js +1908 -0
  478. package/dist/web/static/js/slashAutocomplete.js +267 -0
  479. package/dist/web/static/js/slashCommands.js +6099 -0
  480. package/dist/web/static/js/spinner.js +406 -0
  481. package/dist/web/static/js/storage.js +123 -0
  482. package/dist/web/static/js/tasks.js +2699 -0
  483. package/dist/web/static/js/theme.js +2086 -0
  484. package/dist/web/static/js/tileManager.js +386 -0
  485. package/dist/web/static/js/tourAutoplay.js +133 -0
  486. package/dist/web/static/js/tourHints.js +179 -0
  487. package/dist/web/static/js/tts-ai.js +521 -0
  488. package/dist/web/static/js/ui.js +1288 -0
  489. package/dist/web/static/js/util/ordinal.js +13 -0
  490. package/dist/web/static/js/voiceRecorder.js +283 -0
  491. package/dist/web/static/js/windowDrag.js +326 -0
  492. package/dist/web/static/js/windowResize.js +233 -0
  493. package/dist/web/static/landing.html +824 -0
  494. package/dist/web/static/lib/docx.umd.min.js +20116 -0
  495. package/dist/web/static/lib/highlight.min.js +1213 -0
  496. package/dist/web/static/lib/html2pdf.bundle.min.js +3 -0
  497. package/dist/web/static/lib/mammoth.browser.min.js +21 -0
  498. package/dist/web/static/lib/qrcode.min.js +8 -0
  499. package/dist/web/static/lib/xlsx.full.min.js +24 -0
  500. package/dist/web/static/login.html +582 -0
  501. package/dist/web/static/manifest.json +15 -0
  502. package/dist/web/static/style.css +35733 -0
  503. package/dist/web/static/sw.js +144 -0
  504. package/dist/workflows/engine.d.ts +162 -0
  505. package/dist/workflows/engine.d.ts.map +1 -0
  506. package/dist/workflows/engine.js +625 -0
  507. package/dist/workflows/engine.js.map +1 -0
  508. package/dist/workflows/index.d.ts +8 -0
  509. package/dist/workflows/index.d.ts.map +1 -0
  510. package/dist/workflows/index.js +14 -0
  511. package/dist/workflows/index.js.map +1 -0
  512. package/package.json +112 -0
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Crop tool — drag-rect selection that lets the user cut down the
3
+ * canvas to a smaller region. Supports Shift-lock aspect ratio and
4
+ * click-inside-rect to reposition an existing crop without redrawing.
5
+ *
6
+ * Owns its own begin/drag/end handlers and reads/writes shared state.
7
+ * The factory takes a small dependency bag for things still living in
8
+ * galleryEditor.js — `composite` redraws the canvas, `showCropApply`
9
+ * mounts the floating W×H + Apply panel after the user finishes
10
+ * dragging.
11
+ *
12
+ * @param {{
13
+ * composite: () => void,
14
+ * showCropApply: () => void,
15
+ * }} deps
16
+ */
17
+ import { state } from '../state.js';
18
+ import { canvasCoords } from '../canvas-coords.js';
19
+ import { drawCheckerboard } from '../checkerboard.js';
20
+
21
+ export function createCropTool({ composite, showCropApply }) {
22
+ return {
23
+ begin(e) {
24
+ const coords = canvasCoords(e, state.mainCanvas);
25
+ // Click inside an existing crop rect → switch to move-mode so
26
+ // the user can reposition without redrawing.
27
+ if (state.cropRect &&
28
+ coords.x >= state.cropRect.x && coords.x <= state.cropRect.x + state.cropRect.w &&
29
+ coords.y >= state.cropRect.y && coords.y <= state.cropRect.y + state.cropRect.h) {
30
+ state.cropMoving = true;
31
+ state.cropMoveStart = { x: coords.x, y: coords.y, rx: state.cropRect.x, ry: state.cropRect.y };
32
+ return;
33
+ }
34
+ state.cropping = true;
35
+ state.cropStart = coords;
36
+ state.cropEnd = { ...state.cropStart };
37
+ state.cropRect = null;
38
+ state.cropAspectLock = null;
39
+ // Tear down the size panel while the user is drawing a new rect.
40
+ const old = state.container?.querySelector('.ge-crop-apply');
41
+ if (old) old.remove();
42
+ },
43
+
44
+ drag(e) {
45
+ // Move-mode: drag the existing rect around the canvas.
46
+ if (state.cropMoving && state.cropRect && state.cropMoveStart) {
47
+ e.preventDefault();
48
+ const c = canvasCoords(e, state.mainCanvas);
49
+ const dx = c.x - state.cropMoveStart.x;
50
+ const dy = c.y - state.cropMoveStart.y;
51
+ let nx = state.cropMoveStart.rx + dx;
52
+ let ny = state.cropMoveStart.ry + dy;
53
+ // Clamp to canvas bounds so the rect stays fully visible.
54
+ nx = Math.max(0, Math.min(nx, state.mainCanvas.width - state.cropRect.w));
55
+ ny = Math.max(0, Math.min(ny, state.mainCanvas.height - state.cropRect.h));
56
+ state.cropRect = { ...state.cropRect, x: nx, y: ny };
57
+ composite();
58
+ return;
59
+ }
60
+ if (!state.cropping) return;
61
+ e.preventDefault();
62
+ state.cropEnd = canvasCoords(e, state.mainCanvas);
63
+ // Shift-held = lock aspect ratio. First Shift press during the
64
+ // drag snapshots the current aspect; subsequent moves stay locked.
65
+ // Releasing Shift resets so the user can re-lock at a new ratio.
66
+ if (e.shiftKey) {
67
+ const rawDx = state.cropEnd.x - state.cropStart.x;
68
+ const rawDy = state.cropEnd.y - state.cropStart.y;
69
+ if (state.cropAspectLock == null) {
70
+ const rawW = Math.abs(rawDx) || 1;
71
+ const rawH = Math.abs(rawDy) || 1;
72
+ state.cropAspectLock = rawW / rawH;
73
+ }
74
+ const absDx = Math.abs(rawDx);
75
+ const absDy = Math.abs(rawDy);
76
+ // Whichever axis the user moved more (relative to the lock) is
77
+ // the driver; scale the other to preserve aspect.
78
+ let dx, dy;
79
+ if (absDx >= absDy * state.cropAspectLock) {
80
+ dx = rawDx;
81
+ dy = Math.sign(rawDy || 1) * (absDx / state.cropAspectLock);
82
+ } else {
83
+ dy = rawDy;
84
+ dx = Math.sign(rawDx || 1) * (absDy * state.cropAspectLock);
85
+ }
86
+ state.cropEnd = { x: state.cropStart.x + dx, y: state.cropStart.y + dy };
87
+ } else {
88
+ state.cropAspectLock = null;
89
+ }
90
+ composite();
91
+ // Draw crop overlay.
92
+ const x = Math.min(state.cropStart.x, state.cropEnd.x);
93
+ const y = Math.min(state.cropStart.y, state.cropEnd.y);
94
+ const w = Math.abs(state.cropEnd.x - state.cropStart.x);
95
+ const h = Math.abs(state.cropEnd.y - state.cropStart.y);
96
+ state.mainCtx.fillStyle = 'rgba(0,0,0,0.4)';
97
+ state.mainCtx.fillRect(0, 0, state.mainCanvas.width, state.mainCanvas.height);
98
+ state.mainCtx.clearRect(x, y, w, h);
99
+ // Redraw layers inside the crop rect (dim everything outside).
100
+ state.mainCtx.save();
101
+ state.mainCtx.beginPath();
102
+ state.mainCtx.rect(x, y, w, h);
103
+ state.mainCtx.clip();
104
+ drawCheckerboard(state.mainCtx, state.mainCanvas.width, state.mainCanvas.height);
105
+ for (const layer of state.layers) {
106
+ if (!layer.visible) continue;
107
+ state.mainCtx.globalAlpha = layer.opacity;
108
+ const off = state.layerOffsets.get(layer.id) || { x: 0, y: 0 };
109
+ state.mainCtx.drawImage(layer.canvas, off.x, off.y);
110
+ }
111
+ state.mainCtx.globalAlpha = 1;
112
+ state.mainCtx.restore();
113
+ // Dashed border around the kept region.
114
+ state.mainCtx.strokeStyle = '#fff';
115
+ state.mainCtx.lineWidth = 1;
116
+ state.mainCtx.setLineDash([4, 4]);
117
+ state.mainCtx.strokeRect(x, y, w, h);
118
+ state.mainCtx.setLineDash([]);
119
+ state.cropRect = { x, y, w, h };
120
+ },
121
+
122
+ end() {
123
+ // Move-mode wrap-up: refresh the floating panel so Apply follows
124
+ // the rect to its new spot.
125
+ if (state.cropMoving) {
126
+ state.cropMoving = false;
127
+ state.cropMoveStart = null;
128
+ if (state.cropRect) showCropApply();
129
+ return;
130
+ }
131
+ state.cropping = false;
132
+ if (state.cropRect && state.cropRect.w > 5 && state.cropRect.h > 5) {
133
+ showCropApply();
134
+ }
135
+ },
136
+ };
137
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Iterative 4-connected flood fill on RGBA pixel data.
3
+ *
4
+ * Pure function — takes the source pixel array + seed + tolerance and
5
+ * returns a mask canvas with white where the fill landed. The legacy
6
+ * gallery editor's magic-wand tool delegates to this.
7
+ *
8
+ * @param {Uint8ClampedArray|Uint8Array} src RGBA bytes (length = w*h*4).
9
+ * @param {number} w Pixel width.
10
+ * @param {number} h Pixel height.
11
+ * @param {number} seedX Floored seed X.
12
+ * @param {number} seedY Floored seed Y.
13
+ * @param {number} tolerance Tolerance 0..100. Internally
14
+ * squared and scaled to RGB+A
15
+ * space (max ≈ 195k at 100).
16
+ * @returns {HTMLCanvasElement|null} A `w × h` mask canvas with
17
+ * white-opaque pixels for
18
+ * visited cells, or null if
19
+ * the seed is out of bounds.
20
+ */
21
+ export function floodFillMask(src, w, h, seedX, seedY, tolerance) {
22
+ if (seedX < 0 || seedY < 0 || seedX >= w || seedY >= h) return null;
23
+
24
+ const seedIdx = (seedY * w + seedX) * 4;
25
+ const sr = src[seedIdx], sg = src[seedIdx + 1];
26
+ const sb = src[seedIdx + 2], sa = src[seedIdx + 3];
27
+
28
+ // 0..100 → squared RGB+A distance threshold. Max single-channel diff
29
+ // is 255, so sqrt(4 * 255²) ≈ 510; squared cap ≈ 195k at tol = 100.
30
+ const tol = Math.pow(tolerance * 4.42, 2);
31
+
32
+ const visited = new Uint8Array(w * h);
33
+ const stack = [seedX, seedY];
34
+ visited[seedY * w + seedX] = 1;
35
+ while (stack.length) {
36
+ const y = stack.pop();
37
+ const x = stack.pop();
38
+ const nbrs = [
39
+ [x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1],
40
+ ];
41
+ for (const [nx, ny] of nbrs) {
42
+ if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
43
+ const idx = ny * w + nx;
44
+ if (visited[idx]) continue;
45
+ const o = idx * 4;
46
+ const dr = src[o] - sr, dg = src[o + 1] - sg;
47
+ const db = src[o + 2] - sb, da = src[o + 3] - sa;
48
+ // RGB + alpha-aware so a click on a transparent pixel selects
49
+ // the transparent region cleanly.
50
+ if (dr * dr + dg * dg + db * db + da * da <= tol) {
51
+ visited[idx] = 1;
52
+ stack.push(nx, ny);
53
+ }
54
+ }
55
+ }
56
+
57
+ const mask = document.createElement('canvas');
58
+ mask.width = w;
59
+ mask.height = h;
60
+ const mCtx = mask.getContext('2d');
61
+ const mData = mCtx.createImageData(w, h);
62
+ for (let i = 0; i < w * h; i++) {
63
+ if (visited[i]) {
64
+ mData.data[i * 4] = 255;
65
+ mData.data[i * 4 + 1] = 255;
66
+ mData.data[i * 4 + 2] = 255;
67
+ mData.data[i * 4 + 3] = 255;
68
+ }
69
+ }
70
+ mCtx.putImageData(mData, 0, 0);
71
+ return mask;
72
+ }
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Lasso-tool pixel & path helpers.
3
+ *
4
+ * All functions take the lasso polygon `points` as an explicit
5
+ * argument so they can be tested in isolation. The legacy gallery
6
+ * editor calls them with its module-level `_lassoPoints` array.
7
+ */
8
+
9
+ /**
10
+ * Shift each polygon vertex along the outward normal by `grow` pixels.
11
+ * Used by the lasso overlay (to draw the "feather" halo) and by
12
+ * `buildLassoMask` (to bake the grown polygon into the mask).
13
+ *
14
+ * @param {{x: number, y: number}[]} points Polygon vertices in draw order.
15
+ * @param {number} grow Positive = expand outward, negative = contract.
16
+ * @returns {{x: number, y: number}[]} New array (same length, original is not mutated).
17
+ */
18
+ export function lassoOffsetPoints(points, grow) {
19
+ const n = points.length;
20
+ if (n < 3 || !grow) return points;
21
+ // Polygon winding (positive = CCW) — flip the normal so it points
22
+ // away from the interior regardless of draw direction.
23
+ let area = 0;
24
+ for (let i = 0; i < n; i++) {
25
+ const p = points[i], q = points[(i + 1) % n];
26
+ area += (q.x - p.x) * (q.y + p.y);
27
+ }
28
+ const sign = area > 0 ? 1 : -1;
29
+ const out = new Array(n);
30
+ for (let i = 0; i < n; i++) {
31
+ const a = points[(i - 1 + n) % n], b = points[i], c = points[(i + 1) % n];
32
+ const e1x = b.x - a.x, e1y = b.y - a.y;
33
+ const e2x = c.x - b.x, e2y = c.y - b.y;
34
+ const l1 = Math.hypot(e1x, e1y) || 1;
35
+ const l2 = Math.hypot(e2x, e2y) || 1;
36
+ // Perpendicular (dy, -dx); flip via `sign` for outward direction.
37
+ const n1x = (e1y / l1) * sign, n1y = (-e1x / l1) * sign;
38
+ const n2x = (e2y / l2) * sign, n2y = (-e2x / l2) * sign;
39
+ const nx = (n1x + n2x) / 2;
40
+ const ny = (n1y + n2y) / 2;
41
+ const nl = Math.hypot(nx, ny) || 1;
42
+ out[i] = { x: b.x + (nx / nl) * grow, y: b.y + (ny / nl) * grow };
43
+ }
44
+ return out;
45
+ }
46
+
47
+
48
+ /**
49
+ * Trace the lasso polygon on the given context (move-to + line-to,
50
+ * closed). Caller is responsible for `stroke()` / `fill()` choice.
51
+ */
52
+ export function getLassoPath(ctx, points) {
53
+ if (!points || points.length < 1) return;
54
+ ctx.beginPath();
55
+ ctx.moveTo(points[0].x, points[0].y);
56
+ for (let i = 1; i < points.length; i++) {
57
+ ctx.lineTo(points[i].x, points[i].y);
58
+ }
59
+ ctx.closePath();
60
+ }
61
+
62
+
63
+ /**
64
+ * Build a (optionally feathered, optionally grown) selection mask
65
+ * from a lasso polygon.
66
+ *
67
+ * @param {{x: number, y: number}[]} points Polygon vertices.
68
+ * @param {number} w / h Output canvas dimensions.
69
+ * @param {number} offX / offY Translate the polygon by (offX, offY) before rasterising.
70
+ * @param {number} feather Feather width in pixels. 0 = hard edge.
71
+ * @param {number} grow Positive = dilate the polygon, negative = erode.
72
+ * @returns {HTMLCanvasElement} A `w × h` canvas with alpha = selection strength.
73
+ */
74
+ export function buildLassoMask(points, w, h, offX, offY, feather, grow) {
75
+ // Step 1: draw hard mask
76
+ const hard = document.createElement('canvas');
77
+ hard.width = w; hard.height = h;
78
+ const hCtx = hard.getContext('2d');
79
+ hCtx.beginPath();
80
+ hCtx.moveTo(points[0].x - offX, points[0].y - offY);
81
+ for (let i = 1; i < points.length; i++) {
82
+ hCtx.lineTo(points[i].x - offX, points[i].y - offY);
83
+ }
84
+ hCtx.closePath();
85
+ hCtx.fillStyle = '#fff';
86
+ hCtx.fill();
87
+
88
+ // Step 1b: grow / shrink — blur the hard mask, threshold low for
89
+ // grow and high for shrink. Same technique as the bg-remove edge
90
+ // tuner. RGB is left alone, alpha is replaced.
91
+ if (grow && grow !== 0) {
92
+ const blurC = document.createElement('canvas');
93
+ blurC.width = w; blurC.height = h;
94
+ const bctx = blurC.getContext('2d');
95
+ bctx.filter = `blur(${Math.abs(grow)}px)`;
96
+ bctx.drawImage(hard, 0, 0);
97
+ bctx.filter = 'none';
98
+ const blurred = bctx.getImageData(0, 0, w, h).data;
99
+ const hd = hCtx.getImageData(0, 0, w, h);
100
+ const out = hd.data;
101
+ const thr = grow > 0 ? 32 : 200;
102
+ for (let i = 0; i < out.length; i += 4) {
103
+ const a = blurred[i + 3] >= thr ? 255 : 0;
104
+ out[i] = a; out[i + 1] = a; out[i + 2] = a; out[i + 3] = a;
105
+ }
106
+ hCtx.putImageData(hd, 0, 0);
107
+ }
108
+
109
+ if (feather <= 0) return hard;
110
+
111
+ // Step 2: pixel data and distance-based feather.
112
+ const hardData = hCtx.getImageData(0, 0, w, h);
113
+ const d = hardData.data;
114
+
115
+ // Build inside/outside map.
116
+ const inside = new Uint8Array(w * h);
117
+ for (let i = 0; i < w * h; i++) {
118
+ inside[i] = d[i * 4] > 128 ? 1 : 0;
119
+ }
120
+
121
+ // Distance from edge (for pixels inside the selection, distance to nearest outside pixel).
122
+ const dist = new Float32Array(w * h);
123
+ dist.fill(feather + 1);
124
+
125
+ // Seed: edge pixels (inside pixels adjacent to outside pixels).
126
+ for (let y = 0; y < h; y++) {
127
+ for (let x = 0; x < w; x++) {
128
+ const i = y * w + x;
129
+ if (!inside[i]) { dist[i] = 0; continue; }
130
+ const hasOutside = (x > 0 && !inside[i-1]) || (x < w-1 && !inside[i+1]) ||
131
+ (y > 0 && !inside[(y-1)*w+x]) || (y < h-1 && !inside[(y+1)*w+x]);
132
+ if (hasOutside) dist[i] = 1;
133
+ }
134
+ }
135
+
136
+ // Two-pass chamfer distance transform.
137
+ for (let y = 0; y < h; y++) {
138
+ for (let x = 0; x < w; x++) {
139
+ const i = y * w + x;
140
+ if (dist[i] === 0) continue;
141
+ if (x > 0) dist[i] = Math.min(dist[i], dist[i-1] + 1);
142
+ if (y > 0) dist[i] = Math.min(dist[i], dist[(y-1)*w+x] + 1);
143
+ }
144
+ }
145
+ for (let y = h-1; y >= 0; y--) {
146
+ for (let x = w-1; x >= 0; x--) {
147
+ const i = y * w + x;
148
+ if (dist[i] === 0) continue;
149
+ if (x < w-1) dist[i] = Math.min(dist[i], dist[i+1] + 1);
150
+ if (y < h-1) dist[i] = Math.min(dist[i], dist[(y+1)*w+x] + 1);
151
+ }
152
+ }
153
+
154
+ // Pixels near the edge get reduced alpha.
155
+ const result = document.createElement('canvas');
156
+ result.width = w; result.height = h;
157
+ const rCtx = result.getContext('2d');
158
+ const rData = rCtx.createImageData(w, h);
159
+
160
+ for (let i = 0; i < w * h; i++) {
161
+ if (!inside[i]) continue;
162
+ const edgeDist = dist[i];
163
+ const alpha = edgeDist >= feather ? 255 : Math.round((edgeDist / feather) * 255);
164
+ rData.data[i*4] = alpha;
165
+ rData.data[i*4+1] = alpha;
166
+ rData.data[i*4+2] = alpha;
167
+ rData.data[i*4+3] = 255;
168
+ }
169
+ rCtx.putImageData(rData, 0, 0);
170
+ return result;
171
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Lasso tool — freehand polygon selection. Mouse-down starts a fresh
3
+ * polygon; every move appends a point and redraws the dashed outline;
4
+ * mouse-up keeps the selection visible (the panel's action buttons
5
+ * read `state.lassoPoints` to act on it).
6
+ *
7
+ * Owns its own begin/drag/end handlers and reads/writes shared state.
8
+ *
9
+ * @param {{
10
+ * composite: () => void,
11
+ * drawLassoOverlay: () => void,
12
+ * syncToolClearIndicators: () => void,
13
+ * }} deps
14
+ */
15
+ import { state } from '../state.js';
16
+ import { canvasCoords } from '../canvas-coords.js';
17
+
18
+ export function createLassoTool({ composite, drawLassoOverlay, syncToolClearIndicators }) {
19
+ return {
20
+ begin(e) {
21
+ state.lassoPoints = [];
22
+ state.lassoActive = true;
23
+ const coords = canvasCoords(e, state.mainCanvas);
24
+ state.lassoPoints.push(coords);
25
+ },
26
+
27
+ drag(e) {
28
+ if (!state.lassoActive) return;
29
+ e.preventDefault();
30
+ const coords = canvasCoords(e, state.mainCanvas);
31
+ state.lassoPoints.push(coords);
32
+ // Live overlay: dashed white outline + translucent red fill.
33
+ composite();
34
+ if (state.lassoPoints.length > 1) {
35
+ state.mainCtx.beginPath();
36
+ state.mainCtx.moveTo(state.lassoPoints[0].x, state.lassoPoints[0].y);
37
+ for (let i = 1; i < state.lassoPoints.length; i++) {
38
+ state.mainCtx.lineTo(state.lassoPoints[i].x, state.lassoPoints[i].y);
39
+ }
40
+ state.mainCtx.closePath();
41
+ state.mainCtx.strokeStyle = '#fff';
42
+ state.mainCtx.lineWidth = 1 / state.zoom;
43
+ state.mainCtx.setLineDash([4 / state.zoom, 4 / state.zoom]);
44
+ state.mainCtx.stroke();
45
+ state.mainCtx.setLineDash([]);
46
+ state.mainCtx.fillStyle = 'rgba(255, 80, 80, 0.15)';
47
+ state.mainCtx.fill();
48
+ }
49
+ },
50
+
51
+ end() {
52
+ state.lassoActive = false;
53
+ if (state.lassoPoints.length < 3) {
54
+ state.lassoPoints = [];
55
+ composite();
56
+ syncToolClearIndicators();
57
+ return;
58
+ }
59
+ // Keep the selection drawn — the panel's action buttons use it.
60
+ composite();
61
+ drawLassoOverlay();
62
+ syncToolClearIndicators();
63
+ },
64
+ };
65
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Move tool — drag a layer around the canvas, with optional snap-on-Ctrl
3
+ * to other layers' edges/centers and to canvas edges/center.
4
+ *
5
+ * Owns its own input handlers (begin/drag/end) and reads/writes the
6
+ * shared `state` store directly. The factory takes a small dependency
7
+ * bag for things that still live in galleryEditor.js — `activeLayer`,
8
+ * `saveState`, `composite` — so this module doesn't have to know about
9
+ * the orchestrator.
10
+ *
11
+ * @param {{
12
+ * activeLayer: () => {id: string, canvas: HTMLCanvasElement, locked?: boolean} | null,
13
+ * saveState: (label?: string) => void,
14
+ * composite: () => void,
15
+ * }} deps
16
+ * @returns {{ begin: (e: Event) => void, drag: (e: Event) => void, end: () => void }}
17
+ */
18
+ import { state } from '../state.js';
19
+ import { canvasCoords } from '../canvas-coords.js';
20
+ import { computeSnap as computeSnapImpl } from '../snap.js';
21
+
22
+ export function createMoveTool({ activeLayer, saveState, composite }) {
23
+ function computeSnap(layer, nx, ny) {
24
+ return computeSnapImpl(layer, nx, ny, {
25
+ zoom: state.zoom,
26
+ canvasW: state.imgWidth,
27
+ canvasH: state.imgHeight,
28
+ otherLayers: state.layers.map(l => ({
29
+ visible: l.visible,
30
+ id: l.id,
31
+ canvas: l.canvas,
32
+ offset: state.layerOffsets.get(l.id) || { x: 0, y: 0 },
33
+ })),
34
+ });
35
+ }
36
+
37
+ return {
38
+ begin(e) {
39
+ const layer = activeLayer();
40
+ if (!layer || layer.locked) return;
41
+ saveState();
42
+ state.moving = true;
43
+ const coords = canvasCoords(e, state.mainCanvas);
44
+ const off = state.layerOffsets.get(layer.id) || { x: 0, y: 0 };
45
+ state.moveStartX = coords.x;
46
+ state.moveStartY = coords.y;
47
+ state.moveLayerOffsetX = off.x;
48
+ state.moveLayerOffsetY = off.y;
49
+ },
50
+ drag(e) {
51
+ if (!state.moving) return;
52
+ e.preventDefault();
53
+ const layer = activeLayer();
54
+ if (!layer) return;
55
+ const coords = canvasCoords(e, state.mainCanvas);
56
+ const dx = coords.x - state.moveStartX;
57
+ const dy = coords.y - state.moveStartY;
58
+ let nx = state.moveLayerOffsetX + dx;
59
+ let ny = state.moveLayerOffsetY + dy;
60
+ // Ctrl held = snap to canvas edges/center and to every other
61
+ // visible layer's edges/center. Opt-in to avoid a "sticky" feel
62
+ // during normal drags.
63
+ if (e.ctrlKey || e.metaKey) {
64
+ const snapped = computeSnap(layer, nx, ny);
65
+ nx = snapped.x;
66
+ ny = snapped.y;
67
+ state.activeSnapGuides = snapped.guides;
68
+ } else {
69
+ state.activeSnapGuides = null;
70
+ }
71
+ state.layerOffsets.set(layer.id, { x: nx, y: ny });
72
+ composite();
73
+ },
74
+ end() {
75
+ state.moving = false;
76
+ state.activeSnapGuides = null;
77
+ },
78
+ };
79
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Shared stroke pipeline for brush / eraser / inpaint.
3
+ *
4
+ * Per-sample stamping happens in `_strokeTo` (still in galleryEditor.js
5
+ * because it touches a lot of pixel-pass internals). This module owns
6
+ * the begin / continue / end orchestration around it:
7
+ *
8
+ * - begin: capture the inpaint-erase flag for the stroke, ensure a
9
+ * mask sub-layer exists when inpaint runs against an empty
10
+ * layer, push an undo entry with a tool-specific label, then
11
+ * kick off the first stamp.
12
+ * - continue: forward the new cursor position to `_strokeTo`.
13
+ * - end: clear the drawing flag, composite, sync any tool indicators
14
+ * that reflect mask state.
15
+ *
16
+ * Clone has its own begin (see tools/clone.js) but reuses `continue`
17
+ * and `end` because once a clone stroke is in progress, the pipeline
18
+ * is identical.
19
+ *
20
+ * @param {{
21
+ * saveState: (label: string) => void,
22
+ * strokeTo: (x: number, y: number) => void,
23
+ * composite: () => void,
24
+ * getActiveMaskLayer: () => object | null,
25
+ * activeParentLayer: () => object | null,
26
+ * ensureActiveMaskLayer: () => object | null,
27
+ * createLayer: (name: string, w: number, h: number) => object,
28
+ * renderLayerPanel: () => void,
29
+ * syncToolClearIndicators: () => void,
30
+ * }} deps
31
+ */
32
+ import { state } from '../state.js';
33
+ import { canvasCoords } from '../canvas-coords.js';
34
+
35
+ const STROKE_TOOLS = new Set(['brush', 'eraser', 'inpaint']);
36
+
37
+ function strokeLabel(tool) {
38
+ if (tool === 'brush') return 'Brush stroke';
39
+ if (tool === 'eraser') return 'Eraser stroke';
40
+ if (tool === 'inpaint') return state.inpaintEraseStroke ? 'Erase mask' : 'Paint mask';
41
+ return 'Stroke';
42
+ }
43
+
44
+ export function createStrokeTool({
45
+ saveState, strokeTo, composite,
46
+ getActiveMaskLayer, activeParentLayer, ensureActiveMaskLayer, createLayer,
47
+ renderLayerPanel, syncToolClearIndicators,
48
+ }) {
49
+ return {
50
+ /**
51
+ * Begin a stroke. Returns true if the dispatcher should consider
52
+ * the event handled (i.e. tool is one of brush/eraser/inpaint).
53
+ */
54
+ tryBegin(e) {
55
+ if (!STROKE_TOOLS.has(state.tool)) return false;
56
+ // Capture the inpaint-erase flag for this stroke. Ctrl+Alt
57
+ // pressed at pointerdown flips the persistent toggle for one
58
+ // stroke only.
59
+ if (state.tool === 'inpaint') {
60
+ const flip = e && e.ctrlKey && e.altKey;
61
+ state.inpaintEraseStroke = flip ? !state.inpaintEraseMode : state.inpaintEraseMode;
62
+ // Make sure we're painting onto an existing mask sub-layer. If
63
+ // there's no parent layer at all, create one first so a totally
64
+ // empty canvas can accept an inpaint stroke.
65
+ if (!getActiveMaskLayer()) {
66
+ let parent = activeParentLayer();
67
+ if (!parent) {
68
+ parent = createLayer('Layer 1', state.imgWidth, state.imgHeight);
69
+ state.layers.push(parent);
70
+ state.activeLayerId = parent.id;
71
+ }
72
+ if (parent.masks && parent.masks.length) {
73
+ parent.activeMaskId = parent.masks[parent.masks.length - 1].id;
74
+ const m = getActiveMaskLayer();
75
+ if (m) {
76
+ state.maskCanvas = m.canvas;
77
+ state.maskCtx = m.ctx;
78
+ renderLayerPanel();
79
+ }
80
+ } else {
81
+ const mk = ensureActiveMaskLayer();
82
+ if (mk) {
83
+ state.maskCanvas = mk.canvas;
84
+ state.maskCtx = mk.ctx;
85
+ renderLayerPanel();
86
+ }
87
+ }
88
+ }
89
+ }
90
+ saveState(strokeLabel(state.tool));
91
+ state.drawing = true;
92
+ const coords = canvasCoords(e, state.mainCanvas);
93
+ state.lastX = coords.x;
94
+ state.lastY = coords.y;
95
+ strokeTo(coords.x, coords.y);
96
+ return true;
97
+ },
98
+
99
+ /**
100
+ * Forward an in-progress stroke. Returns true if a stroke is
101
+ * actually in progress (dispatcher should short-circuit).
102
+ */
103
+ tryContinue(e) {
104
+ if (!state.drawing) return false;
105
+ e.preventDefault();
106
+ const coords = canvasCoords(e, state.mainCanvas);
107
+ strokeTo(coords.x, coords.y);
108
+ return true;
109
+ },
110
+
111
+ /**
112
+ * Wrap up an in-progress stroke. Returns true if there was one.
113
+ */
114
+ tryEnd() {
115
+ if (!state.drawing) return false;
116
+ const wasDrawingInpaint = state.tool === 'inpaint';
117
+ state.drawing = false;
118
+ composite();
119
+ if (wasDrawingInpaint) syncToolClearIndicators();
120
+ return true;
121
+ },
122
+ };
123
+ }