@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.
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/dist/agents/definition.d.ts +15 -0
- package/dist/agents/definition.d.ts.map +1 -0
- package/dist/agents/definition.js +41 -0
- package/dist/agents/definition.js.map +1 -0
- package/dist/agents/index.d.ts +12 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +11 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/registry.d.ts +17 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +23 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/agents/specialized.d.ts +31 -0
- package/dist/agents/specialized.d.ts.map +1 -0
- package/dist/agents/specialized.js +75 -0
- package/dist/agents/specialized.js.map +1 -0
- package/dist/awareness/index.d.ts +14 -0
- package/dist/awareness/index.d.ts.map +1 -0
- package/dist/awareness/index.js +22 -0
- package/dist/awareness/index.js.map +1 -0
- package/dist/awareness/service.d.ts +180 -0
- package/dist/awareness/service.d.ts.map +1 -0
- package/dist/awareness/service.js +789 -0
- package/dist/awareness/service.js.map +1 -0
- package/dist/cli/entry.d.ts +13 -0
- package/dist/cli/entry.d.ts.map +1 -0
- package/dist/cli/entry.js +35 -0
- package/dist/cli/entry.js.map +1 -0
- package/dist/comms/telegram.d.ts +41 -0
- package/dist/comms/telegram.d.ts.map +1 -0
- package/dist/comms/telegram.js +332 -0
- package/dist/comms/telegram.js.map +1 -0
- package/dist/core/agent.d.ts +252 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +1399 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/auth.d.ts +23 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +113 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/authority.d.ts +118 -0
- package/dist/core/authority.d.ts.map +1 -0
- package/dist/core/authority.js +402 -0
- package/dist/core/authority.js.map +1 -0
- package/dist/core/backend/async_queue.d.ts +17 -0
- package/dist/core/backend/async_queue.d.ts.map +1 -0
- package/dist/core/backend/async_queue.js +66 -0
- package/dist/core/backend/async_queue.js.map +1 -0
- package/dist/core/backend/index.d.ts +24 -0
- package/dist/core/backend/index.d.ts.map +1 -0
- package/dist/core/backend/index.js +128 -0
- package/dist/core/backend/index.js.map +1 -0
- package/dist/core/backend/llama_server.d.ts +39 -0
- package/dist/core/backend/llama_server.d.ts.map +1 -0
- package/dist/core/backend/llama_server.js +182 -0
- package/dist/core/backend/llama_server.js.map +1 -0
- package/dist/core/backend/llamacpp.d.ts +40 -0
- package/dist/core/backend/llamacpp.d.ts.map +1 -0
- package/dist/core/backend/llamacpp.js +200 -0
- package/dist/core/backend/llamacpp.js.map +1 -0
- package/dist/core/backend/lmstudio.d.ts +53 -0
- package/dist/core/backend/lmstudio.d.ts.map +1 -0
- package/dist/core/backend/lmstudio.js +274 -0
- package/dist/core/backend/lmstudio.js.map +1 -0
- package/dist/core/backend/ollama.d.ts +25 -0
- package/dist/core/backend/ollama.d.ts.map +1 -0
- package/dist/core/backend/ollama.js +86 -0
- package/dist/core/backend/ollama.js.map +1 -0
- package/dist/core/backend/openai.d.ts +27 -0
- package/dist/core/backend/openai.d.ts.map +1 -0
- package/dist/core/backend/openai.js +84 -0
- package/dist/core/backend/openai.js.map +1 -0
- package/dist/core/backend/types.d.ts +73 -0
- package/dist/core/backend/types.d.ts.map +1 -0
- package/dist/core/backend/types.js +137 -0
- package/dist/core/backend/types.js.map +1 -0
- package/dist/core/chat_store.d.ts +77 -0
- package/dist/core/chat_store.d.ts.map +1 -0
- package/dist/core/chat_store.js +332 -0
- package/dist/core/chat_store.js.map +1 -0
- package/dist/core/cli.d.ts +82 -0
- package/dist/core/cli.d.ts.map +1 -0
- package/dist/core/cli.js +602 -0
- package/dist/core/cli.js.map +1 -0
- package/dist/core/config.d.ts +127 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +295 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/debug.d.ts +8 -0
- package/dist/core/debug.d.ts.map +1 -0
- package/dist/core/debug.js +8 -0
- package/dist/core/debug.js.map +1 -0
- package/dist/core/downloader.d.ts +31 -0
- package/dist/core/downloader.d.ts.map +1 -0
- package/dist/core/downloader.js +180 -0
- package/dist/core/downloader.js.map +1 -0
- package/dist/core/errors.d.ts +80 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +134 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/extras.d.ts +160 -0
- package/dist/core/extras.d.ts.map +1 -0
- package/dist/core/extras.js +553 -0
- package/dist/core/extras.js.map +1 -0
- package/dist/core/health.d.ts +27 -0
- package/dist/core/health.d.ts.map +1 -0
- package/dist/core/health.js +96 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/history.d.ts +50 -0
- package/dist/core/history.d.ts.map +1 -0
- package/dist/core/history.js +276 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/intelligence/ast_index.d.ts +255 -0
- package/dist/core/intelligence/ast_index.d.ts.map +1 -0
- package/dist/core/intelligence/ast_index.js +1369 -0
- package/dist/core/intelligence/ast_index.js.map +1 -0
- package/dist/core/intelligence/confidence.d.ts +113 -0
- package/dist/core/intelligence/confidence.d.ts.map +1 -0
- package/dist/core/intelligence/confidence.js +298 -0
- package/dist/core/intelligence/confidence.js.map +1 -0
- package/dist/core/intelligence/context_compressor.d.ts +80 -0
- package/dist/core/intelligence/context_compressor.d.ts.map +1 -0
- package/dist/core/intelligence/context_compressor.js +245 -0
- package/dist/core/intelligence/context_compressor.js.map +1 -0
- package/dist/core/intelligence/daemon.d.ts +247 -0
- package/dist/core/intelligence/daemon.d.ts.map +1 -0
- package/dist/core/intelligence/daemon.js +842 -0
- package/dist/core/intelligence/daemon.js.map +1 -0
- package/dist/core/intelligence/index.d.ts +60 -0
- package/dist/core/intelligence/index.d.ts.map +1 -0
- package/dist/core/intelligence/index.js +101 -0
- package/dist/core/intelligence/index.js.map +1 -0
- package/dist/core/intelligence/predictor.d.ts +246 -0
- package/dist/core/intelligence/predictor.d.ts.map +1 -0
- package/dist/core/intelligence/predictor.js +590 -0
- package/dist/core/intelligence/predictor.js.map +1 -0
- package/dist/core/intelligence/reflex.d.ts +84 -0
- package/dist/core/intelligence/reflex.d.ts.map +1 -0
- package/dist/core/intelligence/reflex.js +344 -0
- package/dist/core/intelligence/reflex.js.map +1 -0
- package/dist/core/intelligence/self_correction.d.ts +121 -0
- package/dist/core/intelligence/self_correction.d.ts.map +1 -0
- package/dist/core/intelligence/self_correction.js +327 -0
- package/dist/core/intelligence/self_correction.js.map +1 -0
- package/dist/core/intelligence/skill_distiller.d.ts +100 -0
- package/dist/core/intelligence/skill_distiller.d.ts.map +1 -0
- package/dist/core/intelligence/skill_distiller.js +246 -0
- package/dist/core/intelligence/skill_distiller.js.map +1 -0
- package/dist/core/intelligence/swarm.d.ts +330 -0
- package/dist/core/intelligence/swarm.d.ts.map +1 -0
- package/dist/core/intelligence/swarm.js +1064 -0
- package/dist/core/intelligence/swarm.js.map +1 -0
- package/dist/core/intelligence/trajectory.d.ts +107 -0
- package/dist/core/intelligence/trajectory.d.ts.map +1 -0
- package/dist/core/intelligence/trajectory.js +330 -0
- package/dist/core/intelligence/trajectory.js.map +1 -0
- package/dist/core/logger.d.ts +111 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +640 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/loop.d.ts +123 -0
- package/dist/core/loop.d.ts.map +1 -0
- package/dist/core/loop.js +423 -0
- package/dist/core/loop.js.map +1 -0
- package/dist/core/memory.d.ts +81 -0
- package/dist/core/memory.d.ts.map +1 -0
- package/dist/core/memory.js +328 -0
- package/dist/core/memory.js.map +1 -0
- package/dist/core/metrics.d.ts +29 -0
- package/dist/core/metrics.d.ts.map +1 -0
- package/dist/core/metrics.js +109 -0
- package/dist/core/metrics.js.map +1 -0
- package/dist/core/models.d.ts +51 -0
- package/dist/core/models.d.ts.map +1 -0
- package/dist/core/models.js +146 -0
- package/dist/core/models.js.map +1 -0
- package/dist/core/optimizer.d.ts +34 -0
- package/dist/core/optimizer.d.ts.map +1 -0
- package/dist/core/optimizer.js +131 -0
- package/dist/core/optimizer.js.map +1 -0
- package/dist/core/persona.d.ts +35 -0
- package/dist/core/persona.d.ts.map +1 -0
- package/dist/core/persona.js +126 -0
- package/dist/core/persona.js.map +1 -0
- package/dist/core/rate_limit.d.ts +23 -0
- package/dist/core/rate_limit.d.ts.map +1 -0
- package/dist/core/rate_limit.js +62 -0
- package/dist/core/rate_limit.js.map +1 -0
- package/dist/core/runner.d.ts +63 -0
- package/dist/core/runner.d.ts.map +1 -0
- package/dist/core/runner.js +671 -0
- package/dist/core/runner.js.map +1 -0
- package/dist/core/stream_parser.d.ts +43 -0
- package/dist/core/stream_parser.d.ts.map +1 -0
- package/dist/core/stream_parser.js +140 -0
- package/dist/core/stream_parser.js.map +1 -0
- package/dist/core/tool_schemas.d.ts +26 -0
- package/dist/core/tool_schemas.d.ts.map +1 -0
- package/dist/core/tool_schemas.js +124 -0
- package/dist/core/tool_schemas.js.map +1 -0
- package/dist/core/which.d.ts +2 -0
- package/dist/core/which.d.ts.map +1 -0
- package/dist/core/which.js +35 -0
- package/dist/core/which.js.map +1 -0
- package/dist/goals/index.d.ts +9 -0
- package/dist/goals/index.d.ts.map +1 -0
- package/dist/goals/index.js +17 -0
- package/dist/goals/index.js.map +1 -0
- package/dist/goals/service.d.ts +115 -0
- package/dist/goals/service.d.ts.map +1 -0
- package/dist/goals/service.js +415 -0
- package/dist/goals/service.js.map +1 -0
- package/dist/goals/types.d.ts +47 -0
- package/dist/goals/types.d.ts.map +1 -0
- package/dist/goals/types.js +66 -0
- package/dist/goals/types.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/autonomous_startup.d.ts +51 -0
- package/dist/integrations/autonomous_startup.d.ts.map +1 -0
- package/dist/integrations/autonomous_startup.js +419 -0
- package/dist/integrations/autonomous_startup.js.map +1 -0
- package/dist/integrations/goose.d.ts +105 -0
- package/dist/integrations/goose.d.ts.map +1 -0
- package/dist/integrations/goose.js +408 -0
- package/dist/integrations/goose.js.map +1 -0
- package/dist/integrations/index.d.ts +21 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +17 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/mcp.d.ts +73 -0
- package/dist/integrations/mcp.d.ts.map +1 -0
- package/dist/integrations/mcp.js +307 -0
- package/dist/integrations/mcp.js.map +1 -0
- package/dist/integrations/mempalace.d.ts +18 -0
- package/dist/integrations/mempalace.d.ts.map +1 -0
- package/dist/integrations/mempalace.js +25 -0
- package/dist/integrations/mempalace.js.map +1 -0
- package/dist/integrations/multi_agent.d.ts +82 -0
- package/dist/integrations/multi_agent.d.ts.map +1 -0
- package/dist/integrations/multi_agent.js +280 -0
- package/dist/integrations/multi_agent.js.map +1 -0
- package/dist/integrations/unified_memory.d.ts +415 -0
- package/dist/integrations/unified_memory.d.ts.map +1 -0
- package/dist/integrations/unified_memory.js +1489 -0
- package/dist/integrations/unified_memory.js.map +1 -0
- package/dist/roles/beru.yaml +48 -0
- package/dist/sidecar/client.d.ts +63 -0
- package/dist/sidecar/client.d.ts.map +1 -0
- package/dist/sidecar/client.js +222 -0
- package/dist/sidecar/client.js.map +1 -0
- package/dist/sidecar/index.d.ts +7 -0
- package/dist/sidecar/index.d.ts.map +1 -0
- package/dist/sidecar/index.js +6 -0
- package/dist/sidecar/index.js.map +1 -0
- package/dist/startup.d.ts +22 -0
- package/dist/startup.d.ts.map +1 -0
- package/dist/startup.js +194 -0
- package/dist/startup.js.map +1 -0
- package/dist/tools/_internal.d.ts +90 -0
- package/dist/tools/_internal.d.ts.map +1 -0
- package/dist/tools/_internal.js +375 -0
- package/dist/tools/_internal.js.map +1 -0
- package/dist/tools/_smoke.d.ts +2 -0
- package/dist/tools/_smoke.d.ts.map +1 -0
- package/dist/tools/_smoke.js +203 -0
- package/dist/tools/_smoke.js.map +1 -0
- package/dist/tools/axodex_tools.d.ts +51 -0
- package/dist/tools/axodex_tools.d.ts.map +1 -0
- package/dist/tools/axodex_tools.js +181 -0
- package/dist/tools/axodex_tools.js.map +1 -0
- package/dist/tools/code_tools.d.ts +33 -0
- package/dist/tools/code_tools.d.ts.map +1 -0
- package/dist/tools/code_tools.js +191 -0
- package/dist/tools/code_tools.js.map +1 -0
- package/dist/tools/computer_tools.d.ts +59 -0
- package/dist/tools/computer_tools.d.ts.map +1 -0
- package/dist/tools/computer_tools.js +348 -0
- package/dist/tools/computer_tools.js.map +1 -0
- package/dist/tools/file_tools.d.ts +51 -0
- package/dist/tools/file_tools.d.ts.map +1 -0
- package/dist/tools/file_tools.js +424 -0
- package/dist/tools/file_tools.js.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +13 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/shell_tools.d.ts +39 -0
- package/dist/tools/shell_tools.d.ts.map +1 -0
- package/dist/tools/shell_tools.js +163 -0
- package/dist/tools/shell_tools.js.map +1 -0
- package/dist/tools/web_tools.d.ts +31 -0
- package/dist/tools/web_tools.d.ts.map +1 -0
- package/dist/tools/web_tools.js +117 -0
- package/dist/tools/web_tools.js.map +1 -0
- package/dist/voice/index.d.ts +41 -0
- package/dist/voice/index.d.ts.map +1 -0
- package/dist/voice/index.js +58 -0
- package/dist/voice/index.js.map +1 -0
- package/dist/voice/light_daemon.d.ts +197 -0
- package/dist/voice/light_daemon.d.ts.map +1 -0
- package/dist/voice/light_daemon.js +746 -0
- package/dist/voice/light_daemon.js.map +1 -0
- package/dist/voice/setup.d.ts +63 -0
- package/dist/voice/setup.d.ts.map +1 -0
- package/dist/voice/setup.js +443 -0
- package/dist/voice/setup.js.map +1 -0
- package/dist/voice/stt.d.ts +148 -0
- package/dist/voice/stt.d.ts.map +1 -0
- package/dist/voice/stt.js +361 -0
- package/dist/voice/stt.js.map +1 -0
- package/dist/voice/tts.d.ts +168 -0
- package/dist/voice/tts.d.ts.map +1 -0
- package/dist/voice/tts.js +698 -0
- package/dist/voice/tts.js.map +1 -0
- package/dist/voice/voice_loop.d.ts +101 -0
- package/dist/voice/voice_loop.d.ts.map +1 -0
- package/dist/voice/voice_loop.js +463 -0
- package/dist/voice/voice_loop.js.map +1 -0
- package/dist/voice/wake_word.d.ts +153 -0
- package/dist/voice/wake_word.d.ts.map +1 -0
- package/dist/voice/wake_word.js +458 -0
- package/dist/voice/wake_word.js.map +1 -0
- package/dist/voice/wav.d.ts +99 -0
- package/dist/voice/wav.d.ts.map +1 -0
- package/dist/voice/wav.js +306 -0
- package/dist/voice/wav.js.map +1 -0
- package/dist/web/broker.d.ts +33 -0
- package/dist/web/broker.d.ts.map +1 -0
- package/dist/web/broker.js +58 -0
- package/dist/web/broker.js.map +1 -0
- package/dist/web/open_browser.d.ts +2 -0
- package/dist/web/open_browser.d.ts.map +1 -0
- package/dist/web/open_browser.js +42 -0
- package/dist/web/open_browser.js.map +1 -0
- package/dist/web/server.d.ts +54 -0
- package/dist/web/server.d.ts.map +1 -0
- package/dist/web/server.js +831 -0
- package/dist/web/server.js.map +1 -0
- package/dist/web/static/app.js +4121 -0
- package/dist/web/static/index.html +2281 -0
- package/dist/web/static/js/MODULE_SUMMARY.md +124 -0
- package/dist/web/static/js/a11y.js +165 -0
- package/dist/web/static/js/admin.js +2145 -0
- package/dist/web/static/js/assistant.js +475 -0
- package/dist/web/static/js/calendar/reminders.js +114 -0
- package/dist/web/static/js/calendar/utils.js +166 -0
- package/dist/web/static/js/calendar.js +3348 -0
- package/dist/web/static/js/censor.js +356 -0
- package/dist/web/static/js/chat.js +4546 -0
- package/dist/web/static/js/chatRenderer.js +2294 -0
- package/dist/web/static/js/chatStream.js +276 -0
- package/dist/web/static/js/codeRunner.js +398 -0
- package/dist/web/static/js/color/hex.js +14 -0
- package/dist/web/static/js/colorPicker.js +453 -0
- package/dist/web/static/js/compare/icons.js +77 -0
- package/dist/web/static/js/compare/index.js +1482 -0
- package/dist/web/static/js/compare/models.js +104 -0
- package/dist/web/static/js/compare/panes.js +817 -0
- package/dist/web/static/js/compare/probe.js +78 -0
- package/dist/web/static/js/compare/scoreboard.js +223 -0
- package/dist/web/static/js/compare/selector.js +1335 -0
- package/dist/web/static/js/compare/state.js +58 -0
- package/dist/web/static/js/compare/stream.js +695 -0
- package/dist/web/static/js/compare/vote.js +254 -0
- package/dist/web/static/js/cookbook-diagnosis.js +694 -0
- package/dist/web/static/js/cookbook-hwfit.js +1888 -0
- package/dist/web/static/js/cookbook.js +2093 -0
- package/dist/web/static/js/cookbookDownload.js +633 -0
- package/dist/web/static/js/cookbookProgressSignal.js +29 -0
- package/dist/web/static/js/cookbookRunning.js +3506 -0
- package/dist/web/static/js/cookbookServe.js +2128 -0
- package/dist/web/static/js/document.js +9731 -0
- package/dist/web/static/js/documentLibrary.js +3376 -0
- package/dist/web/static/js/dragSort.js +265 -0
- package/dist/web/static/js/editor/ai-inpaint.js +374 -0
- package/dist/web/static/js/editor/ai-models.js +273 -0
- package/dist/web/static/js/editor/ai-rembg.js +230 -0
- package/dist/web/static/js/editor/ai-tool-runner.js +147 -0
- package/dist/web/static/js/editor/ai-tools-misc.js +216 -0
- package/dist/web/static/js/editor/build/controls.js +366 -0
- package/dist/web/static/js/editor/build/popups.js +112 -0
- package/dist/web/static/js/editor/build/right-panel.js +200 -0
- package/dist/web/static/js/editor/build/toolbar.js +73 -0
- package/dist/web/static/js/editor/build/topbar.js +131 -0
- package/dist/web/static/js/editor/build/transform-popup.js +109 -0
- package/dist/web/static/js/editor/canvas-coords.js +21 -0
- package/dist/web/static/js/editor/canvas-events.js +197 -0
- package/dist/web/static/js/editor/canvas-transforms.js +132 -0
- package/dist/web/static/js/editor/checkerboard.js +24 -0
- package/dist/web/static/js/editor/clipboard-and-drop.js +133 -0
- package/dist/web/static/js/editor/composite-helpers.js +83 -0
- package/dist/web/static/js/editor/filters/blur.js +118 -0
- package/dist/web/static/js/editor/filters/edge-feather.js +70 -0
- package/dist/web/static/js/editor/fx/adj-popup.js +677 -0
- package/dist/web/static/js/editor/fx/filter-string.js +38 -0
- package/dist/web/static/js/editor/fx/histogram.js +67 -0
- package/dist/web/static/js/editor/fx/pixel-pass.js +249 -0
- package/dist/web/static/js/editor/harmonize-masks.js +116 -0
- package/dist/web/static/js/editor/history-panel.js +176 -0
- package/dist/web/static/js/editor/keyboard-shortcuts.js +271 -0
- package/dist/web/static/js/editor/layer-helpers.js +131 -0
- package/dist/web/static/js/editor/layer-panel.js +600 -0
- package/dist/web/static/js/editor/mask-utils.js +91 -0
- package/dist/web/static/js/editor/shortcuts-popover.js +149 -0
- package/dist/web/static/js/editor/slider-ux.js +191 -0
- package/dist/web/static/js/editor/snap.js +107 -0
- package/dist/web/static/js/editor/state.js +257 -0
- package/dist/web/static/js/editor/stroke-pipeline.js +162 -0
- package/dist/web/static/js/editor/stroke-tool-sliders.js +64 -0
- package/dist/web/static/js/editor/tools/clone.js +81 -0
- package/dist/web/static/js/editor/tools/crop.js +137 -0
- package/dist/web/static/js/editor/tools/flood-fill.js +72 -0
- package/dist/web/static/js/editor/tools/lasso-mask.js +171 -0
- package/dist/web/static/js/editor/tools/lasso.js +65 -0
- package/dist/web/static/js/editor/tools/move.js +79 -0
- package/dist/web/static/js/editor/tools/stroke.js +123 -0
- package/dist/web/static/js/editor/tools/transform-drag.js +174 -0
- package/dist/web/static/js/editor/tools/transform-handles.js +271 -0
- package/dist/web/static/js/editor/tools/transform-session.js +381 -0
- package/dist/web/static/js/editor/tools/wand.js +46 -0
- package/dist/web/static/js/editor/wire-import.js +148 -0
- package/dist/web/static/js/editor/wire-inpaint-controls.js +164 -0
- package/dist/web/static/js/editor/wire-merge-buttons.js +103 -0
- package/dist/web/static/js/editor/wire-selection-controls.js +170 -0
- package/dist/web/static/js/editor/wire-topbar-menus.js +174 -0
- package/dist/web/static/js/editor/wire-topbar-overflow.js +49 -0
- package/dist/web/static/js/editor/wire-topbar.js +188 -0
- package/dist/web/static/js/emailInbox.js +1245 -0
- package/dist/web/static/js/emailLibrary/replyRecipients.js +27 -0
- package/dist/web/static/js/emailLibrary/signatureFold.js +339 -0
- package/dist/web/static/js/emailLibrary/state.js +34 -0
- package/dist/web/static/js/emailLibrary/utils.js +202 -0
- package/dist/web/static/js/emailLibrary.js +5217 -0
- package/dist/web/static/js/emojiPicker.js +311 -0
- package/dist/web/static/js/escMenuStack.js +102 -0
- package/dist/web/static/js/fileHandler.js +295 -0
- package/dist/web/static/js/gallery.js +2835 -0
- package/dist/web/static/js/galleryEditor.js +3798 -0
- package/dist/web/static/js/group.js +955 -0
- package/dist/web/static/js/init.js +405 -0
- package/dist/web/static/js/keyboard-shortcuts.js +292 -0
- package/dist/web/static/js/langIcons.js +187 -0
- package/dist/web/static/js/markdown/tableRow.js +19 -0
- package/dist/web/static/js/markdown.js +806 -0
- package/dist/web/static/js/memory.js +1418 -0
- package/dist/web/static/js/modalManager.js +1552 -0
- package/dist/web/static/js/modalSnap.js +782 -0
- package/dist/web/static/js/model/matchKey.js +19 -0
- package/dist/web/static/js/modelPicker.js +695 -0
- package/dist/web/static/js/modelSort.js +33 -0
- package/dist/web/static/js/models.js +642 -0
- package/dist/web/static/js/notes.js +5054 -0
- package/dist/web/static/js/package.json +1 -0
- package/dist/web/static/js/platform.js +47 -0
- package/dist/web/static/js/presets.js +1110 -0
- package/dist/web/static/js/providers.js +93 -0
- package/dist/web/static/js/rag.js +177 -0
- package/dist/web/static/js/research/jobs.js +335 -0
- package/dist/web/static/js/research/panel.js +1233 -0
- package/dist/web/static/js/researchSynapse.js +225 -0
- package/dist/web/static/js/search-chat.js +201 -0
- package/dist/web/static/js/search.js +52 -0
- package/dist/web/static/js/section-management.js +260 -0
- package/dist/web/static/js/sessions.js +3108 -0
- package/dist/web/static/js/settings.js +4991 -0
- package/dist/web/static/js/sidebar-layout.js +573 -0
- package/dist/web/static/js/signature.js +504 -0
- package/dist/web/static/js/skills.js +1908 -0
- package/dist/web/static/js/slashAutocomplete.js +267 -0
- package/dist/web/static/js/slashCommands.js +6099 -0
- package/dist/web/static/js/spinner.js +406 -0
- package/dist/web/static/js/storage.js +123 -0
- package/dist/web/static/js/tasks.js +2699 -0
- package/dist/web/static/js/theme.js +2086 -0
- package/dist/web/static/js/tileManager.js +386 -0
- package/dist/web/static/js/tourAutoplay.js +133 -0
- package/dist/web/static/js/tourHints.js +179 -0
- package/dist/web/static/js/tts-ai.js +521 -0
- package/dist/web/static/js/ui.js +1288 -0
- package/dist/web/static/js/util/ordinal.js +13 -0
- package/dist/web/static/js/voiceRecorder.js +283 -0
- package/dist/web/static/js/windowDrag.js +326 -0
- package/dist/web/static/js/windowResize.js +233 -0
- package/dist/web/static/landing.html +824 -0
- package/dist/web/static/lib/docx.umd.min.js +20116 -0
- package/dist/web/static/lib/highlight.min.js +1213 -0
- package/dist/web/static/lib/html2pdf.bundle.min.js +3 -0
- package/dist/web/static/lib/mammoth.browser.min.js +21 -0
- package/dist/web/static/lib/qrcode.min.js +8 -0
- package/dist/web/static/lib/xlsx.full.min.js +24 -0
- package/dist/web/static/login.html +582 -0
- package/dist/web/static/manifest.json +15 -0
- package/dist/web/static/style.css +35733 -0
- package/dist/web/static/sw.js +144 -0
- package/dist/workflows/engine.d.ts +162 -0
- package/dist/workflows/engine.d.ts.map +1 -0
- package/dist/workflows/engine.js +625 -0
- package/dist/workflows/engine.js.map +1 -0
- package/dist/workflows/index.d.ts +8 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +14 -0
- package/dist/workflows/index.js.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
// static/js/signature.js
|
|
2
|
+
//
|
|
3
|
+
// Reusable signature module. Two entry points:
|
|
4
|
+
// capture(opts) — open a drawing modal, return Promise<Signature|null>
|
|
5
|
+
// pick(opts) — show saved signatures + a "new" tile, return Promise<Signature|null>
|
|
6
|
+
//
|
|
7
|
+
// Signature shape: { id, dataUrl, width, height, name }
|
|
8
|
+
//
|
|
9
|
+
// Drawing uses a per-stroke smoother: each quadratic-bezier segment is anchored
|
|
10
|
+
// at the previous point with control points at midpoints, which yields a
|
|
11
|
+
// Catmull-Rom-like curve without external deps. Variable stroke width is
|
|
12
|
+
// derived from pointer velocity (slower → thicker), which gives signatures
|
|
13
|
+
// their characteristic ink-bleed feel.
|
|
14
|
+
|
|
15
|
+
const API_BASE = window.location.origin;
|
|
16
|
+
|
|
17
|
+
// Last signature the user picked or created in this session. Lets the export
|
|
18
|
+
// modal pre-fill subsequent signature fields with the same one — sign once,
|
|
19
|
+
// applies everywhere.
|
|
20
|
+
let _lastUsed = null;
|
|
21
|
+
export function getLastUsed() { return _lastUsed; }
|
|
22
|
+
export function setLastUsed(sig) { _lastUsed = sig || null; }
|
|
23
|
+
|
|
24
|
+
class SmoothPad {
|
|
25
|
+
constructor(canvas, opts = {}) {
|
|
26
|
+
this.canvas = canvas;
|
|
27
|
+
this.ctx = canvas.getContext('2d');
|
|
28
|
+
this.minWidth = opts.minWidth ?? 1.0;
|
|
29
|
+
this.maxWidth = opts.maxWidth ?? 3.0;
|
|
30
|
+
this.color = opts.color ?? '#111';
|
|
31
|
+
this.bgColor = opts.bgColor ?? '#fff';
|
|
32
|
+
// Heavy-smoothing knobs (much smoother than v1):
|
|
33
|
+
// - minDistance: jitter floor (px) — bigger = more aggressive thinning
|
|
34
|
+
// - emaAlpha: live EMA on incoming points (lower = smoother, laggier)
|
|
35
|
+
// - chaikinIters: Chaikin corner-cutting passes on stroke-end redraw
|
|
36
|
+
// (each pass roughly doubles segment count and rounds every corner;
|
|
37
|
+
// 3 passes is silky, 4 is glass)
|
|
38
|
+
// - tension: secondary Catmull-Rom tightness for the final cubic curve
|
|
39
|
+
this.minDistance = opts.minDistance ?? 5.0;
|
|
40
|
+
this.emaAlpha = opts.emaAlpha ?? 0.15;
|
|
41
|
+
this.chaikinIters = opts.chaikinIters ?? 4;
|
|
42
|
+
this.tension = opts.tension ?? 0.35;
|
|
43
|
+
this._strokes = []; // array of { points: [{x,y,t,p}] }
|
|
44
|
+
this._current = null;
|
|
45
|
+
this._currentSmoothed = null; // EMA point used for live drawing
|
|
46
|
+
this._isEmpty = true;
|
|
47
|
+
this._wirePointer();
|
|
48
|
+
this.clear();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_wirePointer() {
|
|
52
|
+
const c = this.canvas;
|
|
53
|
+
c.style.touchAction = 'none';
|
|
54
|
+
c.addEventListener('pointerdown', (e) => this._onDown(e));
|
|
55
|
+
c.addEventListener('pointermove', (e) => this._onMove(e));
|
|
56
|
+
c.addEventListener('pointerup', (e) => this._onUp(e));
|
|
57
|
+
c.addEventListener('pointercancel', (e) => this._onUp(e));
|
|
58
|
+
c.addEventListener('pointerleave', (e) => this._onUp(e));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_toLocal(e) {
|
|
62
|
+
const r = this.canvas.getBoundingClientRect();
|
|
63
|
+
const sx = this.canvas.width / r.width;
|
|
64
|
+
const sy = this.canvas.height / r.height;
|
|
65
|
+
return {
|
|
66
|
+
x: (e.clientX - r.left) * sx,
|
|
67
|
+
y: (e.clientY - r.top) * sy,
|
|
68
|
+
t: performance.now(),
|
|
69
|
+
p: e.pressure && e.pressure > 0 ? e.pressure : 0.5,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_onDown(e) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
this.canvas.setPointerCapture(e.pointerId);
|
|
76
|
+
const raw = this._toLocal(e);
|
|
77
|
+
this._current = { points: [raw] };
|
|
78
|
+
this._currentSmoothed = { ...raw };
|
|
79
|
+
this._strokes.push(this._current);
|
|
80
|
+
this._isEmpty = false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_onMove(e) {
|
|
84
|
+
if (!this._current) return;
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
const raw = this._toLocal(e);
|
|
87
|
+
const pts = this._current.points;
|
|
88
|
+
const last = pts[pts.length - 1];
|
|
89
|
+
if (Math.hypot(raw.x - last.x, raw.y - last.y) < this.minDistance) return;
|
|
90
|
+
// EMA the incoming point against the running smoothed point so the live
|
|
91
|
+
// preview already reads as smooth (the final stroke-end pass will smooth
|
|
92
|
+
// further via Catmull-Rom).
|
|
93
|
+
const a = this.emaAlpha;
|
|
94
|
+
const sm = this._currentSmoothed;
|
|
95
|
+
const smoothed = {
|
|
96
|
+
x: sm.x + a * (raw.x - sm.x),
|
|
97
|
+
y: sm.y + a * (raw.y - sm.y),
|
|
98
|
+
t: raw.t,
|
|
99
|
+
p: sm.p + a * (raw.p - sm.p),
|
|
100
|
+
};
|
|
101
|
+
this._currentSmoothed = smoothed;
|
|
102
|
+
pts.push(smoothed);
|
|
103
|
+
if (pts.length >= 3) {
|
|
104
|
+
this._drawSegment(pts[pts.length - 3], pts[pts.length - 2], pts[pts.length - 1]);
|
|
105
|
+
} else if (pts.length === 2) {
|
|
106
|
+
const [a0, b0] = pts;
|
|
107
|
+
this._strokeLine(a0, b0, this._widthBetween(a0, b0));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_onUp(e) {
|
|
112
|
+
if (!this._current) return;
|
|
113
|
+
try { this.canvas.releasePointerCapture(e.pointerId); } catch (_) {}
|
|
114
|
+
// Heavy-smoothing finalize: redraw the just-finished stroke as a
|
|
115
|
+
// Catmull-Rom-fit cubic (much smoother than incremental quadratics).
|
|
116
|
+
const stroke = this._current;
|
|
117
|
+
this._current = null;
|
|
118
|
+
this._currentSmoothed = null;
|
|
119
|
+
if (stroke && stroke.points.length >= 2) {
|
|
120
|
+
this._repaintAll();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
_repaintAll() {
|
|
125
|
+
const ctx = this.ctx;
|
|
126
|
+
ctx.fillStyle = this.bgColor;
|
|
127
|
+
ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
128
|
+
for (const stroke of this._strokes) {
|
|
129
|
+
this._drawStrokeSmooth(stroke.points);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
_chaikinPass(pts) {
|
|
134
|
+
// Each interior pair (a,b) becomes two new points at 1/4 and 3/4 along
|
|
135
|
+
// the segment. Endpoints preserved.
|
|
136
|
+
if (pts.length < 3) return pts;
|
|
137
|
+
const out = [pts[0]];
|
|
138
|
+
for (let i = 0; i < pts.length - 1; i++) {
|
|
139
|
+
const a = pts[i], b = pts[i + 1];
|
|
140
|
+
out.push({
|
|
141
|
+
x: a.x * 0.75 + b.x * 0.25,
|
|
142
|
+
y: a.y * 0.75 + b.y * 0.25,
|
|
143
|
+
t: a.t, p: (a.p + b.p) / 2,
|
|
144
|
+
});
|
|
145
|
+
out.push({
|
|
146
|
+
x: a.x * 0.25 + b.x * 0.75,
|
|
147
|
+
y: a.y * 0.25 + b.y * 0.75,
|
|
148
|
+
t: b.t, p: (a.p + b.p) / 2,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
out.push(pts[pts.length - 1]);
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
_drawStrokeSmooth(pts) {
|
|
156
|
+
if (!pts || pts.length < 2) return;
|
|
157
|
+
if (pts.length === 2) {
|
|
158
|
+
this._strokeLine(pts[0], pts[1], this._widthBetween(pts[0], pts[1]));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
// Aggressive smoothing: N passes of Chaikin's corner-cutting, then a
|
|
162
|
+
// Catmull-Rom cubic through the densified points.
|
|
163
|
+
let smoothed = pts;
|
|
164
|
+
for (let i = 0; i < this.chaikinIters; i++) {
|
|
165
|
+
smoothed = this._chaikinPass(smoothed);
|
|
166
|
+
}
|
|
167
|
+
const ctx = this.ctx;
|
|
168
|
+
ctx.lineCap = 'round';
|
|
169
|
+
ctx.lineJoin = 'round';
|
|
170
|
+
ctx.strokeStyle = this.color;
|
|
171
|
+
const t = Math.max(0.05, Math.min(1, this.tension));
|
|
172
|
+
const padded = [smoothed[0], ...smoothed, smoothed[smoothed.length - 1]];
|
|
173
|
+
for (let i = 1; i < padded.length - 2; i++) {
|
|
174
|
+
const p0 = padded[i - 1];
|
|
175
|
+
const p1 = padded[i];
|
|
176
|
+
const p2 = padded[i + 1];
|
|
177
|
+
const p3 = padded[i + 2];
|
|
178
|
+
const c1 = {
|
|
179
|
+
x: p1.x + ((p2.x - p0.x) / 6) * t * 3,
|
|
180
|
+
y: p1.y + ((p2.y - p0.y) / 6) * t * 3,
|
|
181
|
+
};
|
|
182
|
+
const c2 = {
|
|
183
|
+
x: p2.x - ((p3.x - p1.x) / 6) * t * 3,
|
|
184
|
+
y: p2.y - ((p3.y - p1.y) / 6) * t * 3,
|
|
185
|
+
};
|
|
186
|
+
const w = this._widthBetween(p1, p2);
|
|
187
|
+
ctx.lineWidth = w;
|
|
188
|
+
ctx.beginPath();
|
|
189
|
+
ctx.moveTo(p1.x, p1.y);
|
|
190
|
+
ctx.bezierCurveTo(c1.x, c1.y, c2.x, c2.y, p2.x, p2.y);
|
|
191
|
+
ctx.stroke();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
_widthBetween(a, b) {
|
|
196
|
+
const dt = Math.max(1, b.t - a.t);
|
|
197
|
+
const dist = Math.hypot(b.x - a.x, b.y - a.y);
|
|
198
|
+
const v = dist / dt; // px/ms
|
|
199
|
+
// Slower strokes → thicker line. Tunable mapping.
|
|
200
|
+
const k = 1 / (1 + v * 4);
|
|
201
|
+
let w = this.minWidth + (this.maxWidth - this.minWidth) * k;
|
|
202
|
+
// Stylus pressure further modulates
|
|
203
|
+
const pAvg = (a.p + b.p) / 2;
|
|
204
|
+
w *= 0.6 + 0.8 * pAvg;
|
|
205
|
+
return Math.max(this.minWidth * 0.8, Math.min(this.maxWidth * 1.2, w));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
_strokeLine(a, b, width) {
|
|
209
|
+
const ctx = this.ctx;
|
|
210
|
+
ctx.lineCap = 'round';
|
|
211
|
+
ctx.lineJoin = 'round';
|
|
212
|
+
ctx.strokeStyle = this.color;
|
|
213
|
+
ctx.lineWidth = width;
|
|
214
|
+
ctx.beginPath();
|
|
215
|
+
ctx.moveTo(a.x, a.y);
|
|
216
|
+
ctx.lineTo(b.x, b.y);
|
|
217
|
+
ctx.stroke();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
_drawSegment(p0, p1, p2) {
|
|
221
|
+
// Quadratic bezier from mid(p0,p1) to mid(p1,p2) with control p1.
|
|
222
|
+
const m1 = { x: (p0.x + p1.x) / 2, y: (p0.y + p1.y) / 2 };
|
|
223
|
+
const m2 = { x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 };
|
|
224
|
+
const w = this._widthBetween(p1, p2);
|
|
225
|
+
const ctx = this.ctx;
|
|
226
|
+
ctx.lineCap = 'round';
|
|
227
|
+
ctx.lineJoin = 'round';
|
|
228
|
+
ctx.strokeStyle = this.color;
|
|
229
|
+
ctx.lineWidth = w;
|
|
230
|
+
ctx.beginPath();
|
|
231
|
+
ctx.moveTo(m1.x, m1.y);
|
|
232
|
+
ctx.quadraticCurveTo(p1.x, p1.y, m2.x, m2.y);
|
|
233
|
+
ctx.stroke();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
clear() {
|
|
237
|
+
const ctx = this.ctx;
|
|
238
|
+
ctx.save();
|
|
239
|
+
ctx.fillStyle = this.bgColor;
|
|
240
|
+
ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
241
|
+
ctx.restore();
|
|
242
|
+
this._strokes = [];
|
|
243
|
+
this._current = null;
|
|
244
|
+
this._isEmpty = true;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
undo() {
|
|
248
|
+
if (!this._strokes.length) return;
|
|
249
|
+
this._strokes.pop();
|
|
250
|
+
this._repaintAll();
|
|
251
|
+
this._isEmpty = this._strokes.length === 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
isEmpty() { return this._isEmpty; }
|
|
255
|
+
|
|
256
|
+
// Trim transparent border so the saved signature isn't surrounded by
|
|
257
|
+
// empty space when stamped into a PDF rect.
|
|
258
|
+
toTrimmedDataUrl(padding = 4) {
|
|
259
|
+
const cw = this.canvas.width;
|
|
260
|
+
const ch = this.canvas.height;
|
|
261
|
+
const ctx = this.ctx;
|
|
262
|
+
const data = ctx.getImageData(0, 0, cw, ch).data;
|
|
263
|
+
let minX = cw, minY = ch, maxX = -1, maxY = -1;
|
|
264
|
+
// bgColor is opaque white — detect non-white pixels
|
|
265
|
+
for (let y = 0; y < ch; y++) {
|
|
266
|
+
for (let x = 0; x < cw; x++) {
|
|
267
|
+
const i = (y * cw + x) * 4;
|
|
268
|
+
if (data[i] < 250 || data[i + 1] < 250 || data[i + 2] < 250) {
|
|
269
|
+
if (x < minX) minX = x;
|
|
270
|
+
if (x > maxX) maxX = x;
|
|
271
|
+
if (y < minY) minY = y;
|
|
272
|
+
if (y > maxY) maxY = y;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (maxX < 0) {
|
|
277
|
+
// empty
|
|
278
|
+
return { dataUrl: this.canvas.toDataURL('image/png'), width: cw, height: ch };
|
|
279
|
+
}
|
|
280
|
+
minX = Math.max(0, minX - padding);
|
|
281
|
+
minY = Math.max(0, minY - padding);
|
|
282
|
+
maxX = Math.min(cw - 1, maxX + padding);
|
|
283
|
+
maxY = Math.min(ch - 1, maxY + padding);
|
|
284
|
+
const w = maxX - minX + 1;
|
|
285
|
+
const h = maxY - minY + 1;
|
|
286
|
+
const off = document.createElement('canvas');
|
|
287
|
+
off.width = w; off.height = h;
|
|
288
|
+
const octx = off.getContext('2d');
|
|
289
|
+
// Transparent background so the signature blends with the PDF
|
|
290
|
+
octx.drawImage(this.canvas, minX, minY, w, h, 0, 0, w, h);
|
|
291
|
+
// Replace white with transparent
|
|
292
|
+
const id = octx.getImageData(0, 0, w, h);
|
|
293
|
+
const px = id.data;
|
|
294
|
+
for (let i = 0; i < px.length; i += 4) {
|
|
295
|
+
if (px[i] > 245 && px[i + 1] > 245 && px[i + 2] > 245) {
|
|
296
|
+
px[i + 3] = 0;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
octx.putImageData(id, 0, 0);
|
|
300
|
+
return { dataUrl: off.toDataURL('image/png'), width: w, height: h };
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function _modal(innerHtml) {
|
|
305
|
+
// Match the app's standard .modal pattern (defined in static/style.css).
|
|
306
|
+
const overlay = document.createElement('div');
|
|
307
|
+
overlay.className = 'modal sig-modal-overlay';
|
|
308
|
+
overlay.style.cssText = 'pointer-events:auto;background:rgba(0,0,0,0.45);z-index:10100;';
|
|
309
|
+
overlay.innerHTML = innerHtml;
|
|
310
|
+
document.body.appendChild(overlay);
|
|
311
|
+
return overlay;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
async function _listSignatures() {
|
|
315
|
+
const r = await fetch(`${API_BASE}/api/signatures`);
|
|
316
|
+
if (!r.ok) return [];
|
|
317
|
+
const data = await r.json();
|
|
318
|
+
return data.signatures || [];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
async function _saveSignature({ dataUrl, width, height, name }) {
|
|
322
|
+
const r = await fetch(`${API_BASE}/api/signatures`, {
|
|
323
|
+
method: 'POST',
|
|
324
|
+
headers: { 'Content-Type': 'application/json' },
|
|
325
|
+
body: JSON.stringify({ data: dataUrl, width, height, name }),
|
|
326
|
+
});
|
|
327
|
+
if (!r.ok) {
|
|
328
|
+
const t = await r.text();
|
|
329
|
+
throw new Error(t || r.statusText);
|
|
330
|
+
}
|
|
331
|
+
return await r.json();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async function _deleteSignature(id) {
|
|
335
|
+
await fetch(`${API_BASE}/api/signatures/${id}`, { method: 'DELETE' });
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Smoothness slider maps a single 0–10 value to the two main knobs.
|
|
339
|
+
// Persisted in localStorage so the user's preference sticks.
|
|
340
|
+
const SMOOTH_KEY = 'zero.signature.smoothness';
|
|
341
|
+
function _loadSmoothness() {
|
|
342
|
+
const v = parseInt(localStorage.getItem(SMOOTH_KEY) || '', 10);
|
|
343
|
+
return Number.isFinite(v) && v >= 0 && v <= 10 ? v : 7;
|
|
344
|
+
}
|
|
345
|
+
function _saveSmoothness(v) {
|
|
346
|
+
try { localStorage.setItem(SMOOTH_KEY, String(v)); } catch (_) {}
|
|
347
|
+
}
|
|
348
|
+
function _smoothnessToParams(v) {
|
|
349
|
+
// 0 = raw, 10 = extreme glass
|
|
350
|
+
return {
|
|
351
|
+
minDistance: 1.0 + v * 0.6, // 1.0 → 7.0
|
|
352
|
+
emaAlpha: Math.max(0.05, 0.6 - v * 0.055), // 0.6 → 0.05
|
|
353
|
+
chaikinIters: Math.round(v * 0.6), // 0 → 6
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
function _applySmoothness(pad, v) {
|
|
357
|
+
const p = _smoothnessToParams(v);
|
|
358
|
+
pad.minDistance = p.minDistance;
|
|
359
|
+
pad.emaAlpha = p.emaAlpha;
|
|
360
|
+
pad.chaikinIters = p.chaikinIters;
|
|
361
|
+
pad._repaintAll();
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// ── capture: open the drawing modal, save on confirm ─────────────────────
|
|
365
|
+
export function capture(opts = {}) {
|
|
366
|
+
return new Promise((resolve) => {
|
|
367
|
+
const initialSmooth = _loadSmoothness();
|
|
368
|
+
const overlay = _modal(`
|
|
369
|
+
<div class="modal-content" style="width:min(560px,94vw);">
|
|
370
|
+
<div class="modal-header">
|
|
371
|
+
<h4>Draw your signature</h4>
|
|
372
|
+
<button class="sig-close modal-close" title="Close">×</button>
|
|
373
|
+
</div>
|
|
374
|
+
<div class="modal-body">
|
|
375
|
+
<canvas class="sig-canvas" width="900" height="280" data-no-swipe-dismiss></canvas>
|
|
376
|
+
<div style="margin-top:10px;display:flex;align-items:center;gap:10px;font-size:0.78rem;">
|
|
377
|
+
<label for="sig-smoothness" style="white-space:nowrap;opacity:0.8;">Smoothness</label>
|
|
378
|
+
<input id="sig-smoothness" class="sig-smoothness" type="range" min="0" max="10" step="1" value="${initialSmooth}" style="flex:1;">
|
|
379
|
+
<span class="sig-smoothness-val" style="width:18px;text-align:right;font-variant-numeric:tabular-nums;opacity:0.7;">${initialSmooth}</span>
|
|
380
|
+
</div>
|
|
381
|
+
<input class="sig-name" type="text" placeholder="Name (optional, e.g. 'Full' or 'Initials')" style="margin-top:10px;">
|
|
382
|
+
</div>
|
|
383
|
+
<div class="modal-footer" style="display:flex;gap:8px;justify-content:flex-end;padding-top:8px;border-top:1px solid var(--border);margin-top:6px;">
|
|
384
|
+
<button class="sig-clear confirm-btn confirm-btn-secondary">Clear</button>
|
|
385
|
+
<button class="sig-undo confirm-btn confirm-btn-secondary">Undo</button>
|
|
386
|
+
<span style="flex:1;"></span>
|
|
387
|
+
<button class="sig-cancel confirm-btn confirm-btn-secondary">Cancel</button>
|
|
388
|
+
<button class="sig-save confirm-btn confirm-btn-primary" disabled>Save</button>
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
`);
|
|
392
|
+
|
|
393
|
+
const canvas = overlay.querySelector('.sig-canvas');
|
|
394
|
+
const pad = new SmoothPad(canvas, _smoothnessToParams(initialSmooth));
|
|
395
|
+
const slider = overlay.querySelector('.sig-smoothness');
|
|
396
|
+
const sliderVal = overlay.querySelector('.sig-smoothness-val');
|
|
397
|
+
slider.addEventListener('input', () => {
|
|
398
|
+
const v = parseInt(slider.value, 10);
|
|
399
|
+
sliderVal.textContent = String(v);
|
|
400
|
+
_saveSmoothness(v);
|
|
401
|
+
_applySmoothness(pad, v);
|
|
402
|
+
});
|
|
403
|
+
const saveBtn = overlay.querySelector('.sig-save');
|
|
404
|
+
const nameInput = overlay.querySelector('.sig-name');
|
|
405
|
+
|
|
406
|
+
const refreshSaveBtn = () => { saveBtn.disabled = pad.isEmpty(); };
|
|
407
|
+
canvas.addEventListener('pointerup', refreshSaveBtn);
|
|
408
|
+
canvas.addEventListener('pointerleave', refreshSaveBtn);
|
|
409
|
+
canvas.addEventListener('pointercancel', refreshSaveBtn);
|
|
410
|
+
|
|
411
|
+
const close = (val) => { overlay.remove(); resolve(val); };
|
|
412
|
+
overlay.querySelector('.sig-close').onclick = () => close(null);
|
|
413
|
+
overlay.querySelector('.sig-cancel').onclick = () => close(null);
|
|
414
|
+
overlay.querySelector('.sig-clear').onclick = () => { pad.clear(); refreshSaveBtn(); };
|
|
415
|
+
overlay.querySelector('.sig-undo').onclick = () => { pad.undo(); refreshSaveBtn(); };
|
|
416
|
+
overlay.addEventListener('click', (e) => { if (e.target === overlay) close(null); });
|
|
417
|
+
|
|
418
|
+
saveBtn.onclick = async () => {
|
|
419
|
+
saveBtn.disabled = true;
|
|
420
|
+
try {
|
|
421
|
+
const trimmed = pad.toTrimmedDataUrl();
|
|
422
|
+
const sig = await _saveSignature({
|
|
423
|
+
dataUrl: trimmed.dataUrl,
|
|
424
|
+
width: trimmed.width,
|
|
425
|
+
height: trimmed.height,
|
|
426
|
+
name: (nameInput.value || '').trim() || 'Signature',
|
|
427
|
+
});
|
|
428
|
+
const out = {
|
|
429
|
+
id: sig.id,
|
|
430
|
+
dataUrl: sig.data_url,
|
|
431
|
+
width: sig.width,
|
|
432
|
+
height: sig.height,
|
|
433
|
+
name: sig.name,
|
|
434
|
+
};
|
|
435
|
+
setLastUsed(out);
|
|
436
|
+
close(out);
|
|
437
|
+
} catch (e) {
|
|
438
|
+
alert('Failed to save signature: ' + e.message);
|
|
439
|
+
saveBtn.disabled = false;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// ── pick: show saved signatures + new tile ───────────────────────────────
|
|
446
|
+
export function pick(opts = {}) {
|
|
447
|
+
return new Promise(async (resolve) => {
|
|
448
|
+
const sigs = await _listSignatures();
|
|
449
|
+
const tiles = sigs.map((s) => `
|
|
450
|
+
<div class="sig-tile" data-id="${s.id}">
|
|
451
|
+
<img src="${s.data_url}"/>
|
|
452
|
+
<div style="margin-top:4px;font-size:0.72rem;color:var(--fg);opacity:0.85;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">${(s.name || '').replace(/[<>&]/g, '')}</div>
|
|
453
|
+
<button class="sig-tile-del" data-id="${s.id}" title="Delete">×</button>
|
|
454
|
+
</div>
|
|
455
|
+
`).join('');
|
|
456
|
+
|
|
457
|
+
const overlay = _modal(`
|
|
458
|
+
<div class="modal-content" style="width:min(560px,94vw);">
|
|
459
|
+
<div class="modal-header">
|
|
460
|
+
<h4>Choose a signature</h4>
|
|
461
|
+
<button class="sig-close modal-close" title="Close">×</button>
|
|
462
|
+
</div>
|
|
463
|
+
<div class="modal-body">
|
|
464
|
+
<button class="sig-new-tile confirm-btn confirm-btn-primary" style="width:100%;margin-bottom:12px;padding:8px;">+ Draw new signature</button>
|
|
465
|
+
${tiles ? `<div style="display:grid;grid-template-columns:repeat(3, 1fr);gap:10px;">${tiles}</div>` : '<div style="opacity:0.6;font-size:0.8rem;text-align:center;padding:8px 0;">No saved signatures yet — draw one above.</div>'}
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
`);
|
|
469
|
+
|
|
470
|
+
const close = (val) => { overlay.remove(); resolve(val); };
|
|
471
|
+
overlay.querySelector('.sig-close').onclick = () => close(null);
|
|
472
|
+
overlay.addEventListener('click', (e) => { if (e.target === overlay) close(null); });
|
|
473
|
+
|
|
474
|
+
overlay.querySelectorAll('.sig-tile').forEach((tile) => {
|
|
475
|
+
tile.addEventListener('click', (e) => {
|
|
476
|
+
if (e.target.classList.contains('sig-tile-del')) return;
|
|
477
|
+
const id = tile.dataset.id;
|
|
478
|
+
const s = sigs.find((x) => x.id === id);
|
|
479
|
+
if (s) {
|
|
480
|
+
const out = { id: s.id, dataUrl: s.data_url, width: s.width, height: s.height, name: s.name };
|
|
481
|
+
setLastUsed(out);
|
|
482
|
+
close(out);
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
});
|
|
486
|
+
overlay.querySelectorAll('.sig-tile-del').forEach((btn) => {
|
|
487
|
+
btn.addEventListener('click', async (e) => {
|
|
488
|
+
e.stopPropagation();
|
|
489
|
+
const id = btn.dataset.id;
|
|
490
|
+
if (!await window.styledConfirm('Delete this signature?', { confirmText: 'Delete', danger: true })) return;
|
|
491
|
+
await _deleteSignature(id);
|
|
492
|
+
btn.closest('.sig-tile')?.remove();
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
overlay.querySelector('.sig-new-tile').onclick = async () => {
|
|
496
|
+
overlay.remove();
|
|
497
|
+
const created = await capture(opts);
|
|
498
|
+
if (created) setLastUsed(created);
|
|
499
|
+
resolve(created);
|
|
500
|
+
};
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export default { capture, pick, getLastUsed, setLastUsed };
|