synabun 1.3.0 → 2.0.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/CHANGELOG.md +205 -662
- package/LICENSE-COMMERCIAL.md +33 -0
- package/NOTICE +17 -0
- package/README.md +175 -853
- package/THIRD-PARTY-LICENSES.md +136 -0
- package/benchmarks/browser-live-results.json +79 -0
- package/benchmarks/browser-v2-results.json +258 -0
- package/benchmarks/fixtures/browser/README.md +57 -0
- package/benchmarks/fixtures/browser/page-state.json +132 -0
- package/benchmarks/fixtures/browser/social.json +92 -0
- package/benchmarks/fixtures/browser/target.json +319 -0
- package/benchmarks/fixtures/desktop/README.md +58 -0
- package/benchmarks/fixtures/desktop/abstention.json +59 -0
- package/benchmarks/fixtures/desktop/adversarial.json +22 -0
- package/benchmarks/fixtures/desktop/forbidden.json +93 -0
- package/benchmarks/fixtures/desktop/generate.mjs +1023 -0
- package/benchmarks/fixtures/desktop/target.json +136 -0
- package/bin/synabun.js +30 -0
- package/docs/whatsapp.md +325 -0
- package/hooks/claude-code/post-plan.mjs +613 -391
- package/hooks/claude-code/post-remember.mjs +246 -122
- package/hooks/claude-code/pre-compact.mjs +171 -110
- package/hooks/claude-code/pre-task.mjs +133 -0
- package/hooks/claude-code/pre-websearch.mjs +15 -4
- package/hooks/claude-code/prompt-origin.mjs +94 -0
- package/hooks/claude-code/prompt-submit.mjs +1244 -861
- package/hooks/claude-code/session-start.mjs +114 -156
- package/hooks/claude-code/shared.mjs +1228 -368
- package/hooks/claude-code/state.mjs +167 -0
- package/hooks/claude-code/stop.mjs +515 -140
- package/hooks/claude-code/subagent-start.mjs +154 -0
- package/hooks/claude-code/subagent-stop.mjs +102 -0
- package/hooks/claude-code/task-gate.mjs +150 -0
- package/launcher.mjs +40 -0
- package/lib/claude-hooks.js +137 -0
- package/lib/claude-usage-audit.js +141 -0
- package/lib/client-config-repair.js +145 -0
- package/lib/data-home-migration.js +502 -0
- package/lib/desktop-pwa.js +206 -0
- package/lib/external-tools.js +221 -0
- package/lib/first-launch-protection.js +245 -0
- package/lib/packaged-runtime.js +110 -0
- package/lib/paths.d.ts +21 -0
- package/lib/paths.js +103 -0
- package/lib/start-launcher.js +1309 -0
- package/mcp-server/dist/config.d.ts +22 -0
- package/mcp-server/dist/config.d.ts.map +1 -0
- package/mcp-server/dist/config.js +109 -0
- package/mcp-server/dist/config.js.map +1 -0
- package/mcp-server/dist/http.d.ts +30 -0
- package/mcp-server/dist/http.d.ts.map +1 -0
- package/mcp-server/dist/http.js +276 -0
- package/mcp-server/dist/http.js.map +1 -0
- package/mcp-server/dist/index.d.ts +48 -0
- package/mcp-server/dist/index.d.ts.map +1 -0
- package/mcp-server/dist/index.js +538 -0
- package/mcp-server/dist/index.js.map +1 -0
- package/mcp-server/dist/preload-http.d.ts +3 -0
- package/mcp-server/dist/preload-http.d.ts.map +1 -0
- package/mcp-server/dist/preload-http.js +28 -0
- package/mcp-server/dist/preload-http.js.map +1 -0
- package/mcp-server/dist/preload.d.ts +3 -0
- package/mcp-server/dist/preload.d.ts.map +1 -0
- package/mcp-server/dist/preload.js +32 -0
- package/mcp-server/dist/preload.js.map +1 -0
- package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.d.ts +19 -0
- package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.d.ts.map +1 -0
- package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.js +403 -0
- package/mcp-server/dist/scripts/migrate-qdrant-to-sqlite.js.map +1 -0
- package/mcp-server/dist/scripts/setup-embeddings.d.ts +3 -0
- package/mcp-server/dist/scripts/setup-embeddings.d.ts.map +1 -0
- package/mcp-server/dist/scripts/setup-embeddings.js +15 -0
- package/mcp-server/dist/scripts/setup-embeddings.js.map +1 -0
- package/mcp-server/dist/services/assistant-judgments.d.ts +79 -0
- package/mcp-server/dist/services/assistant-judgments.d.ts.map +1 -0
- package/mcp-server/dist/services/assistant-judgments.js +128 -0
- package/mcp-server/dist/services/assistant-judgments.js.map +1 -0
- package/mcp-server/dist/services/browser-assist-gate.d.ts +314 -0
- package/mcp-server/dist/services/browser-assist-gate.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-assist-gate.js +344 -0
- package/mcp-server/dist/services/browser-assist-gate.js.map +1 -0
- package/mcp-server/dist/services/browser-assist.d.ts +104 -0
- package/mcp-server/dist/services/browser-assist.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-assist.js +282 -0
- package/mcp-server/dist/services/browser-assist.js.map +1 -0
- package/mcp-server/dist/services/browser-bench.d.ts +772 -0
- package/mcp-server/dist/services/browser-bench.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-bench.js +424 -0
- package/mcp-server/dist/services/browser-bench.js.map +1 -0
- package/mcp-server/dist/services/browser-judgments.d.ts +196 -0
- package/mcp-server/dist/services/browser-judgments.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-judgments.js +363 -0
- package/mcp-server/dist/services/browser-judgments.js.map +1 -0
- package/mcp-server/dist/services/browser-risk.d.ts +166 -0
- package/mcp-server/dist/services/browser-risk.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-risk.js +458 -0
- package/mcp-server/dist/services/browser-risk.js.map +1 -0
- package/mcp-server/dist/services/categories.d.ts +61 -0
- package/mcp-server/dist/services/categories.d.ts.map +1 -0
- package/mcp-server/dist/services/categories.js +377 -0
- package/mcp-server/dist/services/categories.js.map +1 -0
- package/mcp-server/dist/services/codex-config-heal.d.ts +49 -0
- package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -0
- package/mcp-server/dist/services/codex-config-heal.js +346 -0
- package/mcp-server/dist/services/codex-config-heal.js.map +1 -0
- package/mcp-server/dist/services/desktop-assist-gate.d.ts +198 -0
- package/mcp-server/dist/services/desktop-assist-gate.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-assist-gate.js +202 -0
- package/mcp-server/dist/services/desktop-assist-gate.js.map +1 -0
- package/mcp-server/dist/services/desktop-assist.d.ts +104 -0
- package/mcp-server/dist/services/desktop-assist.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-assist.js +266 -0
- package/mcp-server/dist/services/desktop-assist.js.map +1 -0
- package/mcp-server/dist/services/desktop-bench.d.ts +553 -0
- package/mcp-server/dist/services/desktop-bench.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-bench.js +311 -0
- package/mcp-server/dist/services/desktop-bench.js.map +1 -0
- package/mcp-server/dist/services/desktop-client.d.ts +23 -0
- package/mcp-server/dist/services/desktop-client.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-client.js +79 -0
- package/mcp-server/dist/services/desktop-client.js.map +1 -0
- package/mcp-server/dist/services/desktop-judgments.d.ts +125 -0
- package/mcp-server/dist/services/desktop-judgments.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-judgments.js +177 -0
- package/mcp-server/dist/services/desktop-judgments.js.map +1 -0
- package/mcp-server/dist/services/desktop-risk.d.ts +283 -0
- package/mcp-server/dist/services/desktop-risk.d.ts.map +1 -0
- package/mcp-server/dist/services/desktop-risk.js +605 -0
- package/mcp-server/dist/services/desktop-risk.js.map +1 -0
- package/mcp-server/dist/services/discord.d.ts +112 -0
- package/mcp-server/dist/services/discord.d.ts.map +1 -0
- package/mcp-server/dist/services/discord.js +477 -0
- package/mcp-server/dist/services/discord.js.map +1 -0
- package/mcp-server/dist/services/edit-stale.d.ts +81 -0
- package/mcp-server/dist/services/edit-stale.d.ts.map +1 -0
- package/mcp-server/dist/services/edit-stale.js +358 -0
- package/mcp-server/dist/services/edit-stale.js.map +1 -0
- package/mcp-server/dist/services/embedding-service.d.ts +16 -0
- package/mcp-server/dist/services/embedding-service.d.ts.map +1 -0
- package/mcp-server/dist/services/embedding-service.js +126 -0
- package/mcp-server/dist/services/embedding-service.js.map +1 -0
- package/mcp-server/dist/services/embedding-worker.d.ts +2 -0
- package/mcp-server/dist/services/embedding-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/embedding-worker.js +52 -0
- package/mcp-server/dist/services/embedding-worker.js.map +1 -0
- package/mcp-server/dist/services/fb-regions.d.ts +71 -0
- package/mcp-server/dist/services/fb-regions.d.ts.map +1 -0
- package/mcp-server/dist/services/fb-regions.js +211 -0
- package/mcp-server/dist/services/fb-regions.js.map +1 -0
- package/mcp-server/dist/services/file-checksums.d.ts +22 -0
- package/mcp-server/dist/services/file-checksums.d.ts.map +1 -0
- package/mcp-server/dist/services/file-checksums.js +55 -0
- package/mcp-server/dist/services/file-checksums.js.map +1 -0
- package/mcp-server/dist/services/file-excerpt.d.ts +24 -0
- package/mcp-server/dist/services/file-excerpt.d.ts.map +1 -0
- package/mcp-server/dist/services/file-excerpt.js +65 -0
- package/mcp-server/dist/services/file-excerpt.js.map +1 -0
- package/mcp-server/dist/services/identity.d.ts +124 -0
- package/mcp-server/dist/services/identity.d.ts.map +1 -0
- package/mcp-server/dist/services/identity.js +241 -0
- package/mcp-server/dist/services/identity.js.map +1 -0
- package/mcp-server/dist/services/local-embeddings.d.ts +2 -0
- package/mcp-server/dist/services/local-embeddings.d.ts.map +1 -0
- package/mcp-server/dist/services/local-embeddings.js +3 -0
- package/mcp-server/dist/services/local-embeddings.js.map +1 -0
- package/mcp-server/dist/services/memory-client.d.ts +4 -0
- package/mcp-server/dist/services/memory-client.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-client.js +27 -0
- package/mcp-server/dist/services/memory-client.js.map +1 -0
- package/mcp-server/dist/services/memory-judge-backfill.d.ts +135 -0
- package/mcp-server/dist/services/memory-judge-backfill.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-judge-backfill.js +510 -0
- package/mcp-server/dist/services/memory-judge-backfill.js.map +1 -0
- package/mcp-server/dist/services/memory-judgments.d.ts +362 -0
- package/mcp-server/dist/services/memory-judgments.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-judgments.js +674 -0
- package/mcp-server/dist/services/memory-judgments.js.map +1 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts +108 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-maintenance.js +403 -0
- package/mcp-server/dist/services/memory-maintenance.js.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts +66 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.js +412 -0
- package/mcp-server/dist/services/memory-retrieval.js.map +1 -0
- package/mcp-server/dist/services/memory-schema.d.ts +16 -0
- package/mcp-server/dist/services/memory-schema.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-schema.js +282 -0
- package/mcp-server/dist/services/memory-schema.js.map +1 -0
- package/mcp-server/dist/services/memory-sessions.d.ts +24 -0
- package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-sessions.js +110 -0
- package/mcp-server/dist/services/memory-sessions.js.map +1 -0
- package/mcp-server/dist/services/memory-triage.d.ts +60 -0
- package/mcp-server/dist/services/memory-triage.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-triage.js +189 -0
- package/mcp-server/dist/services/memory-triage.js.map +1 -0
- package/mcp-server/dist/services/memory-verification.d.ts +24 -0
- package/mcp-server/dist/services/memory-verification.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-verification.js +92 -0
- package/mcp-server/dist/services/memory-verification.js.map +1 -0
- package/mcp-server/dist/services/memory-writer.d.ts +26 -0
- package/mcp-server/dist/services/memory-writer.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-writer.js +126 -0
- package/mcp-server/dist/services/memory-writer.js.map +1 -0
- package/mcp-server/dist/services/neural-interface.d.ts +439 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -0
- package/mcp-server/dist/services/neural-interface.js +1135 -0
- package/mcp-server/dist/services/neural-interface.js.map +1 -0
- package/mcp-server/dist/services/profiles.d.ts +120 -0
- package/mcp-server/dist/services/profiles.d.ts.map +1 -0
- package/mcp-server/dist/services/profiles.js +387 -0
- package/mcp-server/dist/services/profiles.js.map +1 -0
- package/mcp-server/dist/services/secret-gate.d.ts +29 -0
- package/mcp-server/dist/services/secret-gate.d.ts.map +1 -0
- package/mcp-server/dist/services/secret-gate.js +43 -0
- package/mcp-server/dist/services/secret-gate.js.map +1 -0
- package/mcp-server/dist/services/server-instructions.d.ts +10 -0
- package/mcp-server/dist/services/server-instructions.d.ts.map +1 -0
- package/mcp-server/dist/services/server-instructions.js +101 -0
- package/mcp-server/dist/services/server-instructions.js.map +1 -0
- package/mcp-server/dist/services/sqlite.d.ts +235 -0
- package/mcp-server/dist/services/sqlite.d.ts.map +1 -0
- package/mcp-server/dist/services/sqlite.js +1185 -0
- package/mcp-server/dist/services/sqlite.js.map +1 -0
- package/mcp-server/dist/services/typesafe-bench.d.ts +99 -0
- package/mcp-server/dist/services/typesafe-bench.d.ts.map +1 -0
- package/mcp-server/dist/services/typesafe-bench.js +218 -0
- package/mcp-server/dist/services/typesafe-bench.js.map +1 -0
- package/mcp-server/dist/services/typesafe-config.d.ts +342 -0
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -0
- package/mcp-server/dist/services/typesafe-config.js +746 -0
- package/mcp-server/dist/services/typesafe-config.js.map +1 -0
- package/mcp-server/dist/services/typesafe.d.ts +213 -0
- package/mcp-server/dist/services/typesafe.d.ts.map +1 -0
- package/mcp-server/dist/services/typesafe.js +330 -0
- package/mcp-server/dist/services/typesafe.js.map +1 -0
- package/mcp-server/dist/services/vector-cache.d.ts +68 -0
- package/mcp-server/dist/services/vector-cache.d.ts.map +1 -0
- package/mcp-server/dist/services/vector-cache.js +271 -0
- package/mcp-server/dist/services/vector-cache.js.map +1 -0
- package/mcp-server/dist/services/whiteboard-geometry.d.ts +305 -0
- package/mcp-server/dist/services/whiteboard-geometry.d.ts.map +1 -0
- package/mcp-server/dist/services/whiteboard-geometry.js +666 -0
- package/mcp-server/dist/services/whiteboard-geometry.js.map +1 -0
- package/mcp-server/dist/tools/agents.d.ts +212 -0
- package/mcp-server/dist/tools/agents.d.ts.map +1 -0
- package/mcp-server/dist/tools/agents.js +407 -0
- package/mcp-server/dist/tools/agents.js.map +1 -0
- package/mcp-server/dist/tools/bluesky.d.ts +39 -0
- package/mcp-server/dist/tools/bluesky.d.ts.map +1 -0
- package/mcp-server/dist/tools/bluesky.js +1144 -0
- package/mcp-server/dist/tools/bluesky.js.map +1 -0
- package/mcp-server/dist/tools/browser-advanced.d.ts +58 -0
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-advanced.js +106 -0
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -0
- package/mcp-server/dist/tools/browser-batch.d.ts +99 -0
- package/mcp-server/dist/tools/browser-batch.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-batch.js +187 -0
- package/mcp-server/dist/tools/browser-batch.js.map +1 -0
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts +21 -0
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-cheatsheet.js +144 -0
- package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -0
- package/mcp-server/dist/tools/browser-interact.d.ts +239 -0
- package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-interact.js +300 -0
- package/mcp-server/dist/tools/browser-interact.js.map +1 -0
- package/mcp-server/dist/tools/browser-navigate.d.ts +90 -0
- package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-navigate.js +142 -0
- package/mcp-server/dist/tools/browser-navigate.js.map +1 -0
- package/mcp-server/dist/tools/browser-observe.d.ts +561 -0
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-observe.js +2009 -0
- package/mcp-server/dist/tools/browser-observe.js.map +1 -0
- package/mcp-server/dist/tools/browser.d.ts +34 -0
- package/mcp-server/dist/tools/browser.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser.js +112 -0
- package/mcp-server/dist/tools/browser.js.map +1 -0
- package/mcp-server/dist/tools/card-tools.d.ts +82 -0
- package/mcp-server/dist/tools/card-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/card-tools.js +137 -0
- package/mcp-server/dist/tools/card-tools.js.map +1 -0
- package/mcp-server/dist/tools/card.d.ts +8 -0
- package/mcp-server/dist/tools/card.d.ts.map +1 -0
- package/mcp-server/dist/tools/card.js +16 -0
- package/mcp-server/dist/tools/card.js.map +1 -0
- package/mcp-server/dist/tools/category.d.ts +32 -0
- package/mcp-server/dist/tools/category.d.ts.map +1 -0
- package/mcp-server/dist/tools/category.js +290 -0
- package/mcp-server/dist/tools/category.js.map +1 -0
- package/mcp-server/dist/tools/choice.d.ts +160 -0
- package/mcp-server/dist/tools/choice.d.ts.map +1 -0
- package/mcp-server/dist/tools/choice.js +80 -0
- package/mcp-server/dist/tools/choice.js.map +1 -0
- package/mcp-server/dist/tools/computer.d.ts +71 -0
- package/mcp-server/dist/tools/computer.d.ts.map +1 -0
- package/mcp-server/dist/tools/computer.js +174 -0
- package/mcp-server/dist/tools/computer.js.map +1 -0
- package/mcp-server/dist/tools/discord-channel.d.ts +44 -0
- package/mcp-server/dist/tools/discord-channel.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-channel.js +236 -0
- package/mcp-server/dist/tools/discord-channel.js.map +1 -0
- package/mcp-server/dist/tools/discord-guild.d.ts +20 -0
- package/mcp-server/dist/tools/discord-guild.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-guild.js +138 -0
- package/mcp-server/dist/tools/discord-guild.js.map +1 -0
- package/mcp-server/dist/tools/discord-member.d.ts +26 -0
- package/mcp-server/dist/tools/discord-member.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-member.js +122 -0
- package/mcp-server/dist/tools/discord-member.js.map +1 -0
- package/mcp-server/dist/tools/discord-message.d.ts +36 -0
- package/mcp-server/dist/tools/discord-message.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-message.js +184 -0
- package/mcp-server/dist/tools/discord-message.js.map +1 -0
- package/mcp-server/dist/tools/discord-onboarding.d.ts +32 -0
- package/mcp-server/dist/tools/discord-onboarding.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-onboarding.js +179 -0
- package/mcp-server/dist/tools/discord-onboarding.js.map +1 -0
- package/mcp-server/dist/tools/discord-role.d.ts +34 -0
- package/mcp-server/dist/tools/discord-role.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-role.js +178 -0
- package/mcp-server/dist/tools/discord-role.js.map +1 -0
- package/mcp-server/dist/tools/discord-thread.d.ts +28 -0
- package/mcp-server/dist/tools/discord-thread.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-thread.js +88 -0
- package/mcp-server/dist/tools/discord-thread.js.map +1 -0
- package/mcp-server/dist/tools/discord-webhook.d.ts +32 -0
- package/mcp-server/dist/tools/discord-webhook.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord-webhook.js +154 -0
- package/mcp-server/dist/tools/discord-webhook.js.map +1 -0
- package/mcp-server/dist/tools/discord.d.ts +7 -0
- package/mcp-server/dist/tools/discord.d.ts.map +1 -0
- package/mcp-server/dist/tools/discord.js +25 -0
- package/mcp-server/dist/tools/discord.js.map +1 -0
- package/mcp-server/dist/tools/fb-groups.d.ts +98 -0
- package/mcp-server/dist/tools/fb-groups.d.ts.map +1 -0
- package/mcp-server/dist/tools/fb-groups.js +369 -0
- package/mcp-server/dist/tools/fb-groups.js.map +1 -0
- package/mcp-server/dist/tools/forget.d.ts +14 -0
- package/mcp-server/dist/tools/forget.d.ts.map +1 -0
- package/mcp-server/dist/tools/forget.js +26 -0
- package/mcp-server/dist/tools/forget.js.map +1 -0
- package/mcp-server/dist/tools/git-tools.d.ts +24 -0
- package/mcp-server/dist/tools/git-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/git-tools.js +107 -0
- package/mcp-server/dist/tools/git-tools.js.map +1 -0
- package/mcp-server/dist/tools/git.d.ts +7 -0
- package/mcp-server/dist/tools/git.d.ts.map +1 -0
- package/mcp-server/dist/tools/git.js +11 -0
- package/mcp-server/dist/tools/git.js.map +1 -0
- package/mcp-server/dist/tools/gsc/experience.d.ts +135 -0
- package/mcp-server/dist/tools/gsc/experience.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/experience.js +351 -0
- package/mcp-server/dist/tools/gsc/experience.js.map +1 -0
- package/mcp-server/dist/tools/gsc/helpers.d.ts +78 -0
- package/mcp-server/dist/tools/gsc/helpers.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/helpers.js +258 -0
- package/mcp-server/dist/tools/gsc/helpers.js.map +1 -0
- package/mcp-server/dist/tools/gsc/indexing.d.ts +121 -0
- package/mcp-server/dist/tools/gsc/indexing.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/indexing.js +357 -0
- package/mcp-server/dist/tools/gsc/indexing.js.map +1 -0
- package/mcp-server/dist/tools/gsc/inspect.d.ts +78 -0
- package/mcp-server/dist/tools/gsc/inspect.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/inspect.js +321 -0
- package/mcp-server/dist/tools/gsc/inspect.js.map +1 -0
- package/mcp-server/dist/tools/gsc/navigate.d.ts +44 -0
- package/mcp-server/dist/tools/gsc/navigate.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/navigate.js +197 -0
- package/mcp-server/dist/tools/gsc/navigate.js.map +1 -0
- package/mcp-server/dist/tools/gsc/performance.d.ts +84 -0
- package/mcp-server/dist/tools/gsc/performance.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/performance.js +274 -0
- package/mcp-server/dist/tools/gsc/performance.js.map +1 -0
- package/mcp-server/dist/tools/gsc/settings.d.ts +153 -0
- package/mcp-server/dist/tools/gsc/settings.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc/settings.js +425 -0
- package/mcp-server/dist/tools/gsc/settings.js.map +1 -0
- package/mcp-server/dist/tools/gsc.d.ts +7 -0
- package/mcp-server/dist/tools/gsc.d.ts.map +1 -0
- package/mcp-server/dist/tools/gsc.js +51 -0
- package/mcp-server/dist/tools/gsc.js.map +1 -0
- package/mcp-server/dist/tools/image-tools.d.ts +24 -0
- package/mcp-server/dist/tools/image-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/image-tools.js +80 -0
- package/mcp-server/dist/tools/image-tools.js.map +1 -0
- package/mcp-server/dist/tools/image.d.ts +10 -0
- package/mcp-server/dist/tools/image.d.ts.map +1 -0
- package/mcp-server/dist/tools/image.js +14 -0
- package/mcp-server/dist/tools/image.js.map +1 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.d.ts +97 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.js +228 -0
- package/mcp-server/dist/tools/leonardo-browser-tools.js.map +1 -0
- package/mcp-server/dist/tools/leonardo.d.ts +13 -0
- package/mcp-server/dist/tools/leonardo.d.ts.map +1 -0
- package/mcp-server/dist/tools/leonardo.js +21 -0
- package/mcp-server/dist/tools/leonardo.js.map +1 -0
- package/mcp-server/dist/tools/loop.d.ts +30 -0
- package/mcp-server/dist/tools/loop.d.ts.map +1 -0
- package/mcp-server/dist/tools/loop.js +401 -0
- package/mcp-server/dist/tools/loop.js.map +1 -0
- package/mcp-server/dist/tools/memories.d.ts +56 -0
- package/mcp-server/dist/tools/memories.d.ts.map +1 -0
- package/mcp-server/dist/tools/memories.js +171 -0
- package/mcp-server/dist/tools/memories.js.map +1 -0
- package/mcp-server/dist/tools/morelogin.d.ts +24 -0
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -0
- package/mcp-server/dist/tools/morelogin.js +79 -0
- package/mcp-server/dist/tools/morelogin.js.map +1 -0
- package/mcp-server/dist/tools/profile.d.ts +17 -0
- package/mcp-server/dist/tools/profile.d.ts.map +1 -0
- package/mcp-server/dist/tools/profile.js +114 -0
- package/mcp-server/dist/tools/profile.js.map +1 -0
- package/mcp-server/dist/tools/recall.d.ts +71 -0
- package/mcp-server/dist/tools/recall.d.ts.map +1 -0
- package/mcp-server/dist/tools/recall.js +147 -0
- package/mcp-server/dist/tools/recall.js.map +1 -0
- package/mcp-server/dist/tools/reflect.d.ts +56 -0
- package/mcp-server/dist/tools/reflect.d.ts.map +1 -0
- package/mcp-server/dist/tools/reflect.js +157 -0
- package/mcp-server/dist/tools/reflect.js.map +1 -0
- package/mcp-server/dist/tools/remember.d.ts +62 -0
- package/mcp-server/dist/tools/remember.d.ts.map +1 -0
- package/mcp-server/dist/tools/remember.js +201 -0
- package/mcp-server/dist/tools/remember.js.map +1 -0
- package/mcp-server/dist/tools/response.d.ts +23 -0
- package/mcp-server/dist/tools/response.d.ts.map +1 -0
- package/mcp-server/dist/tools/response.js +24 -0
- package/mcp-server/dist/tools/response.js.map +1 -0
- package/mcp-server/dist/tools/restore.d.ts +14 -0
- package/mcp-server/dist/tools/restore.d.ts.map +1 -0
- package/mcp-server/dist/tools/restore.js +23 -0
- package/mcp-server/dist/tools/restore.js.map +1 -0
- package/mcp-server/dist/tools/style-guide-tools.d.ts +51 -0
- package/mcp-server/dist/tools/style-guide-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/style-guide-tools.js +231 -0
- package/mcp-server/dist/tools/style-guide-tools.js.map +1 -0
- package/mcp-server/dist/tools/style-guide.d.ts +8 -0
- package/mcp-server/dist/tools/style-guide.d.ts.map +1 -0
- package/mcp-server/dist/tools/style-guide.js +12 -0
- package/mcp-server/dist/tools/style-guide.js.map +1 -0
- package/mcp-server/dist/tools/sync.d.ts +20 -0
- package/mcp-server/dist/tools/sync.d.ts.map +1 -0
- package/mcp-server/dist/tools/sync.js +156 -0
- package/mcp-server/dist/tools/sync.js.map +1 -0
- package/mcp-server/dist/tools/tictactoe-tools.d.ts +18 -0
- package/mcp-server/dist/tools/tictactoe-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/tictactoe-tools.js +78 -0
- package/mcp-server/dist/tools/tictactoe-tools.js.map +1 -0
- package/mcp-server/dist/tools/tictactoe.d.ts +7 -0
- package/mcp-server/dist/tools/tictactoe.d.ts.map +1 -0
- package/mcp-server/dist/tools/tictactoe.js +11 -0
- package/mcp-server/dist/tools/tictactoe.js.map +1 -0
- package/mcp-server/dist/tools/utils.d.ts +19 -0
- package/mcp-server/dist/tools/utils.d.ts.map +1 -0
- package/mcp-server/dist/tools/utils.js +54 -0
- package/mcp-server/dist/tools/utils.js.map +1 -0
- package/mcp-server/dist/tools/whiteboard-format.d.ts +88 -0
- package/mcp-server/dist/tools/whiteboard-format.d.ts.map +1 -0
- package/mcp-server/dist/tools/whiteboard-format.js +337 -0
- package/mcp-server/dist/tools/whiteboard-format.js.map +1 -0
- package/mcp-server/dist/tools/whiteboard-tools.d.ts +326 -0
- package/mcp-server/dist/tools/whiteboard-tools.d.ts.map +1 -0
- package/mcp-server/dist/tools/whiteboard-tools.js +222 -0
- package/mcp-server/dist/tools/whiteboard-tools.js.map +1 -0
- package/mcp-server/dist/tools/whiteboard.d.ts +8 -0
- package/mcp-server/dist/tools/whiteboard.d.ts.map +1 -0
- package/mcp-server/dist/tools/whiteboard.js +16 -0
- package/mcp-server/dist/tools/whiteboard.js.map +1 -0
- package/mcp-server/dist/tools/youtube/analytics.d.ts +46 -0
- package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/analytics.js +83 -0
- package/mcp-server/dist/tools/youtube/analytics.js.map +1 -0
- package/mcp-server/dist/tools/youtube/dedup.d.ts +35 -0
- package/mcp-server/dist/tools/youtube/dedup.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/dedup.js +56 -0
- package/mcp-server/dist/tools/youtube/dedup.js.map +1 -0
- package/mcp-server/dist/tools/youtube/download.d.ts +31 -0
- package/mcp-server/dist/tools/youtube/download.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/download.js +30 -0
- package/mcp-server/dist/tools/youtube/download.js.map +1 -0
- package/mcp-server/dist/tools/youtube/helpers.d.ts +66 -0
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/helpers.js +143 -0
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -0
- package/mcp-server/dist/tools/youtube/media.d.ts +43 -0
- package/mcp-server/dist/tools/youtube/media.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/media.js +97 -0
- package/mcp-server/dist/tools/youtube/media.js.map +1 -0
- package/mcp-server/dist/tools/youtube/metadata.d.ts +33 -0
- package/mcp-server/dist/tools/youtube/metadata.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/metadata.js +106 -0
- package/mcp-server/dist/tools/youtube/metadata.js.map +1 -0
- package/mcp-server/dist/tools/youtube/navigate.d.ts +30 -0
- package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/navigate.js +71 -0
- package/mcp-server/dist/tools/youtube/navigate.js.map +1 -0
- package/mcp-server/dist/tools/youtube/playlist.d.ts +29 -0
- package/mcp-server/dist/tools/youtube/playlist.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/playlist.js +128 -0
- package/mcp-server/dist/tools/youtube/playlist.js.map +1 -0
- package/mcp-server/dist/tools/youtube/schedule.d.ts +31 -0
- package/mcp-server/dist/tools/youtube/schedule.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/schedule.js +147 -0
- package/mcp-server/dist/tools/youtube/schedule.js.map +1 -0
- package/mcp-server/dist/tools/youtube/source.d.ts +36 -0
- package/mcp-server/dist/tools/youtube/source.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/source.js +85 -0
- package/mcp-server/dist/tools/youtube/source.js.map +1 -0
- package/mcp-server/dist/tools/youtube/upload.d.ts +53 -0
- package/mcp-server/dist/tools/youtube/upload.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube/upload.js +255 -0
- package/mcp-server/dist/tools/youtube/upload.js.map +1 -0
- package/mcp-server/dist/tools/youtube.d.ts +12 -0
- package/mcp-server/dist/tools/youtube.d.ts.map +1 -0
- package/mcp-server/dist/tools/youtube.js +38 -0
- package/mcp-server/dist/tools/youtube.js.map +1 -0
- package/mcp-server/dist/tui.d.ts +3 -0
- package/mcp-server/dist/tui.d.ts.map +1 -0
- package/mcp-server/dist/tui.js +806 -0
- package/mcp-server/dist/tui.js.map +1 -0
- package/mcp-server/dist/types.d.ts +77 -0
- package/mcp-server/dist/types.d.ts.map +1 -0
- package/mcp-server/dist/types.js +2 -0
- package/mcp-server/dist/types.js.map +1 -0
- package/mcp-server/package-lock.json +4798 -0
- package/mcp-server/package.json +55 -38
- package/mcp-server/run.mjs +12 -2
- package/mcp-server/src/config.ts +48 -3
- package/mcp-server/src/http.ts +296 -93
- package/mcp-server/src/index.ts +546 -203
- package/mcp-server/src/preload-http.ts +19 -18
- package/mcp-server/src/preload.ts +19 -18
- package/mcp-server/src/scripts/setup-embeddings.ts +9 -0
- package/mcp-server/src/services/assistant-judgments.ts +157 -0
- package/mcp-server/src/services/browser-assist-gate.ts +383 -0
- package/mcp-server/src/services/browser-assist.ts +267 -0
- package/mcp-server/src/services/browser-bench.ts +477 -0
- package/mcp-server/src/services/browser-judgments.ts +414 -0
- package/mcp-server/src/services/browser-risk.ts +484 -0
- package/mcp-server/src/services/categories.ts +36 -19
- package/mcp-server/src/services/codex-config-heal.ts +403 -0
- package/mcp-server/src/services/desktop-assist-gate.ts +251 -0
- package/mcp-server/src/services/desktop-assist.ts +308 -0
- package/mcp-server/src/services/desktop-bench.ts +372 -0
- package/mcp-server/src/services/desktop-client.ts +76 -0
- package/mcp-server/src/services/desktop-judgments.ts +218 -0
- package/mcp-server/src/services/desktop-risk.ts +743 -0
- package/mcp-server/src/services/edit-stale.ts +299 -0
- package/mcp-server/src/services/embedding-service.ts +108 -0
- package/mcp-server/src/services/embedding-worker.ts +46 -0
- package/mcp-server/src/services/fb-regions.ts +221 -0
- package/mcp-server/src/services/file-checksums.ts +26 -9
- package/mcp-server/src/services/file-excerpt.ts +59 -0
- package/mcp-server/src/services/identity.ts +291 -0
- package/mcp-server/src/services/local-embeddings.ts +2 -77
- package/mcp-server/src/services/memory-client.ts +23 -0
- package/mcp-server/src/services/memory-judge-backfill.ts +462 -0
- package/mcp-server/src/services/memory-judgments.ts +901 -0
- package/mcp-server/src/services/memory-maintenance.ts +360 -0
- package/mcp-server/src/services/memory-retrieval.ts +349 -0
- package/mcp-server/src/services/memory-schema.ts +280 -0
- package/mcp-server/src/services/memory-sessions.ts +87 -0
- package/mcp-server/src/services/memory-triage.ts +182 -0
- package/mcp-server/src/services/memory-verification.ts +68 -0
- package/mcp-server/src/services/memory-writer.ts +125 -0
- package/mcp-server/src/services/neural-interface.ts +1217 -73
- package/mcp-server/src/services/profiles.ts +428 -0
- package/mcp-server/src/services/secret-gate.ts +52 -0
- package/mcp-server/src/services/server-instructions.ts +122 -0
- package/mcp-server/src/services/sqlite.ts +1456 -823
- package/mcp-server/src/services/typesafe-bench.ts +247 -0
- package/mcp-server/src/services/typesafe-config.ts +790 -0
- package/mcp-server/src/services/typesafe.ts +390 -0
- package/mcp-server/src/services/vector-cache.ts +255 -0
- package/mcp-server/src/services/whiteboard-geometry.ts +711 -0
- package/mcp-server/src/tools/agents.ts +539 -0
- package/mcp-server/src/tools/bluesky.ts +1186 -0
- package/mcp-server/src/tools/browser-advanced.ts +15 -6
- package/mcp-server/src/tools/browser-batch.ts +178 -0
- package/mcp-server/src/tools/browser-cheatsheet.ts +155 -0
- package/mcp-server/src/tools/browser-interact.ts +362 -255
- package/mcp-server/src/tools/browser-navigate.ts +164 -77
- package/mcp-server/src/tools/browser-observe.ts +2222 -1330
- package/mcp-server/src/tools/browser.ts +181 -107
- package/mcp-server/src/tools/card.ts +7 -5
- package/mcp-server/src/tools/choice.ts +103 -0
- package/mcp-server/src/tools/computer.ts +190 -0
- package/mcp-server/src/tools/discord.ts +10 -23
- package/mcp-server/src/tools/fb-groups.ts +387 -0
- package/mcp-server/src/tools/forget.ts +1 -1
- package/mcp-server/src/tools/git.ts +3 -1
- package/mcp-server/src/tools/gsc/experience.ts +440 -0
- package/mcp-server/src/tools/gsc/helpers.ts +288 -0
- package/mcp-server/src/tools/gsc/indexing.ts +495 -0
- package/mcp-server/src/tools/gsc/inspect.ts +391 -0
- package/mcp-server/src/tools/gsc/navigate.ts +236 -0
- package/mcp-server/src/tools/gsc/performance.ts +352 -0
- package/mcp-server/src/tools/gsc/settings.ts +564 -0
- package/mcp-server/src/tools/gsc.ts +95 -0
- package/mcp-server/src/tools/image.ts +3 -1
- package/mcp-server/src/tools/leonardo-browser-tools.ts +47 -37
- package/mcp-server/src/tools/leonardo.ts +7 -5
- package/mcp-server/src/tools/loop.ts +118 -25
- package/mcp-server/src/tools/memories.ts +65 -5
- package/mcp-server/src/tools/morelogin.ts +81 -0
- package/mcp-server/src/tools/profile.ts +122 -0
- package/mcp-server/src/tools/recall.ts +105 -261
- package/mcp-server/src/tools/reflect.ts +171 -145
- package/mcp-server/src/tools/remember.ts +223 -115
- package/mcp-server/src/tools/style-guide-tools.ts +250 -0
- package/mcp-server/src/tools/style-guide.ts +16 -0
- package/mcp-server/src/tools/sync.ts +66 -9
- package/mcp-server/src/tools/tictactoe.ts +3 -1
- package/mcp-server/src/tools/utils.ts +22 -0
- package/mcp-server/src/tools/whiteboard-format.ts +394 -0
- package/mcp-server/src/tools/whiteboard-tools.ts +191 -183
- package/mcp-server/src/tools/whiteboard.ts +7 -5
- package/mcp-server/src/tools/youtube/analytics.ts +106 -0
- package/mcp-server/src/tools/youtube/dedup.ts +57 -0
- package/mcp-server/src/tools/youtube/download.ts +41 -0
- package/mcp-server/src/tools/youtube/helpers.ts +183 -0
- package/mcp-server/src/tools/youtube/media.ts +109 -0
- package/mcp-server/src/tools/youtube/metadata.ts +112 -0
- package/mcp-server/src/tools/youtube/navigate.ts +81 -0
- package/mcp-server/src/tools/youtube/playlist.ts +134 -0
- package/mcp-server/src/tools/youtube/schedule.ts +158 -0
- package/mcp-server/src/tools/youtube/source.ts +101 -0
- package/mcp-server/src/tools/youtube/upload.ts +296 -0
- package/mcp-server/src/tools/youtube.ts +47 -0
- package/mcp-server/src/tui.ts +8 -9
- package/neural-interface/games/TicTacToe/1.svg +1 -0
- package/neural-interface/games/TicTacToe/2.svg +1 -0
- package/neural-interface/games/TicTacToe/3.svg +1 -0
- package/neural-interface/games/TicTacToe/4.svg +1 -0
- package/neural-interface/games/TicTacToe/5.svg +1 -0
- package/neural-interface/games/TicTacToe/6.svg +1 -0
- package/neural-interface/games/TicTacToe/7.svg +1 -0
- package/neural-interface/games/TicTacToe/8.svg +1 -0
- package/neural-interface/games/TicTacToe/9.svg +1 -0
- package/neural-interface/games/TicTacToe/Board.svg +1 -0
- package/neural-interface/games/TicTacToe/Circle.svg +1 -0
- package/neural-interface/games/TicTacToe/Cross.svg +1 -0
- package/neural-interface/i18n/en.json +7022 -0
- package/neural-interface/i18n/pt-BR.json +7026 -0
- package/neural-interface/lib/assistant-api.js +1005 -0
- package/neural-interface/lib/assistant-attachments.js +121 -0
- package/neural-interface/lib/assistant-brains/claude.js +207 -0
- package/neural-interface/lib/assistant-brains/codex-browser-policy-hook.mjs +43 -0
- package/neural-interface/lib/assistant-brains/codex-route-gate-hook.mjs +56 -0
- package/neural-interface/lib/assistant-brains/codex.js +213 -0
- package/neural-interface/lib/assistant-brains/opencode-browser-policy.js +47 -0
- package/neural-interface/lib/assistant-brains/opencode-route-gate.js +62 -0
- package/neural-interface/lib/assistant-brains/opencode.js +320 -0
- package/neural-interface/lib/assistant-budget.js +318 -0
- package/neural-interface/lib/assistant-catalog.js +731 -0
- package/neural-interface/lib/assistant-clarify.js +664 -0
- package/neural-interface/lib/assistant-config.js +232 -0
- package/neural-interface/lib/assistant-dispatch.js +2744 -0
- package/neural-interface/lib/assistant-envelope.js +582 -0
- package/neural-interface/lib/assistant-evidence.js +236 -0
- package/neural-interface/lib/assistant-hidden-models.js +272 -0
- package/neural-interface/lib/assistant-jev.js +117 -0
- package/neural-interface/lib/assistant-judgments.js +111 -0
- package/neural-interface/lib/assistant-media.js +335 -0
- package/neural-interface/lib/assistant-memory.js +398 -0
- package/neural-interface/lib/assistant-persona.js +444 -0
- package/neural-interface/lib/assistant-plan-permissions.js +448 -0
- package/neural-interface/lib/assistant-playbooks/design.md +87 -0
- package/neural-interface/lib/assistant-playbooks.js +72 -0
- package/neural-interface/lib/assistant-pricing.js +159 -0
- package/neural-interface/lib/assistant-route-gate-codex.js +163 -0
- package/neural-interface/lib/assistant-route-gate.js +212 -0
- package/neural-interface/lib/assistant-router.js +1324 -0
- package/neural-interface/lib/assistant-runtime.js +3337 -0
- package/neural-interface/lib/assistant-task-prompt.js +472 -0
- package/neural-interface/lib/assistant-usage.js +1688 -0
- package/neural-interface/lib/augmented-path.js +70 -0
- package/neural-interface/lib/automation-storage-migration.js +54 -0
- package/neural-interface/lib/backup-service.js +851 -0
- package/neural-interface/lib/backup-zip-reader.js +262 -0
- package/neural-interface/lib/browser-assist-api.js +41 -0
- package/neural-interface/lib/browser-console.js +176 -0
- package/neural-interface/lib/browser-execution.js +241 -0
- package/neural-interface/lib/browser-extraction.js +191 -0
- package/neural-interface/lib/browser-language.js +83 -0
- package/neural-interface/lib/browser-screenshot.js +399 -0
- package/neural-interface/lib/browser-semantic-context.js +639 -0
- package/neural-interface/lib/browser-snapshots.js +192 -0
- package/neural-interface/lib/browser-tab-recovery.js +119 -0
- package/neural-interface/lib/browser-targets.js +70 -0
- package/neural-interface/lib/browser-tool-policy.js +926 -0
- package/neural-interface/lib/claude-accounts.js +230 -0
- package/neural-interface/lib/claude-agent-bridge.js +3203 -0
- package/neural-interface/lib/claude-bypass-policy.js +99 -0
- package/neural-interface/lib/claude-executable.js +241 -0
- package/neural-interface/lib/claude-history.js +429 -0
- package/neural-interface/lib/claude-model-catalog.js +444 -0
- package/neural-interface/lib/claude-panel-requests.js +165 -0
- package/neural-interface/lib/claude-panel-session.js +272 -0
- package/neural-interface/lib/claude-permission-rules.js +153 -0
- package/neural-interface/lib/claude-session-cleanup.js +71 -0
- package/neural-interface/lib/claude-session-list.js +82 -0
- package/neural-interface/lib/claude-session-ops.js +140 -0
- package/neural-interface/lib/claude-settings-view.js +51 -0
- package/neural-interface/lib/claude-skin-connect.js +79 -0
- package/neural-interface/lib/claude-stall-policy.js +7 -0
- package/neural-interface/lib/claude-temporary.js +435 -0
- package/neural-interface/lib/cli-update-planner.js +312 -0
- package/neural-interface/lib/codex-capabilities.d.ts +41 -0
- package/neural-interface/lib/codex-capabilities.js +148 -0
- package/neural-interface/lib/codex-collaboration-mode.js +17 -0
- package/neural-interface/lib/codex-compat-rpc.js +241 -0
- package/neural-interface/lib/codex-mcp-approvals.js +56 -0
- package/neural-interface/lib/codex-mcp-apps.js +47 -0
- package/neural-interface/lib/codex-model-context.js +202 -0
- package/neural-interface/lib/codex-plan-store.js +71 -0
- package/neural-interface/lib/codex-request-journal.js +242 -0
- package/neural-interface/lib/codex-runtime-path.js +213 -0
- package/neural-interface/lib/codex-session-catalog.js +231 -0
- package/neural-interface/lib/codex-session-settings.js +46 -0
- package/neural-interface/lib/codex-sidepanel-permissions.js +110 -0
- package/neural-interface/lib/codex-thread-history.js +165 -0
- package/neural-interface/lib/codex-user-verification.js +34 -0
- package/neural-interface/lib/codex-writer-lifecycle.js +152 -0
- package/neural-interface/lib/confined-fs.js +256 -0
- package/neural-interface/lib/db.js +922 -0
- package/neural-interface/lib/design-md.js +9 -0
- package/neural-interface/lib/desktop/api.js +92 -0
- package/neural-interface/lib/desktop/audit.js +62 -0
- package/neural-interface/lib/desktop/build.js +423 -0
- package/neural-interface/lib/desktop/config.js +606 -0
- package/neural-interface/lib/desktop/coords.js +76 -0
- package/neural-interface/lib/desktop/fake-helper.js +1192 -0
- package/neural-interface/lib/desktop/frames.js +77 -0
- package/neural-interface/lib/desktop/grants.js +84 -0
- package/neural-interface/lib/desktop/guards.js +170 -0
- package/neural-interface/lib/desktop/helper/SynabunDesktop.swift +3056 -0
- package/neural-interface/lib/desktop/lease.js +51 -0
- package/neural-interface/lib/desktop/manager.js +545 -0
- package/neural-interface/lib/desktop/press-contexts.js +103 -0
- package/neural-interface/lib/desktop/protocol.js +495 -0
- package/neural-interface/lib/desktop/service.js +1202 -0
- package/neural-interface/lib/effort-levels.js +148 -0
- package/neural-interface/lib/event-loop-monitor.js +67 -0
- package/neural-interface/lib/exec-loop-command.js +209 -0
- package/neural-interface/lib/folder-picker.ps1 +77 -0
- package/neural-interface/lib/http-guards.js +287 -0
- package/neural-interface/lib/jsonl-lines.js +94 -0
- package/neural-interface/lib/loop-logger.js +127 -0
- package/neural-interface/lib/mcp-client-config.js +133 -0
- package/neural-interface/lib/mcp-installer.js +487 -0
- package/neural-interface/lib/mcp-profile-refresh-coordinator.js +78 -0
- package/neural-interface/lib/mcp-profile-servers.js +120 -0
- package/neural-interface/lib/memo-cache.js +84 -0
- package/neural-interface/lib/memory-api.js +758 -0
- package/neural-interface/lib/memory-map-api.js +1150 -0
- package/neural-interface/lib/memory-map-layout.js +872 -0
- package/neural-interface/lib/memory-map-worker.js +165 -0
- package/neural-interface/lib/memory-session-capture.js +81 -0
- package/neural-interface/lib/memory-timers.js +62 -0
- package/neural-interface/lib/morelogin.js +301 -0
- package/neural-interface/lib/native-binary-runtime.js +382 -0
- package/neural-interface/lib/native-loop-goal.js +33 -0
- package/neural-interface/lib/native-loop-providers.js +1002 -0
- package/neural-interface/lib/native-loop-runtime.js +747 -0
- package/neural-interface/lib/offline-page.js +54 -0
- package/neural-interface/lib/opencode-hidden-models.js +113 -0
- package/neural-interface/lib/opencode-history.js +253 -0
- package/neural-interface/lib/opencode-runtime-config.js +58 -0
- package/neural-interface/lib/opencode-v2-client.js +486 -0
- package/neural-interface/lib/opencode-v2-ws-requests.js +955 -0
- package/neural-interface/lib/path-confine.js +213 -0
- package/neural-interface/lib/plugin-installer.js +264 -0
- package/neural-interface/lib/project-storage.js +766 -0
- package/neural-interface/lib/pty-host/core.js +603 -0
- package/neural-interface/lib/pty-host/flow.js +43 -0
- package/neural-interface/lib/pty-host/host.js +47 -0
- package/neural-interface/lib/pty-host/manager.js +360 -0
- package/neural-interface/lib/pty-host/protocol.js +81 -0
- package/neural-interface/lib/pty-host/snapshot.js +133 -0
- package/neural-interface/lib/remote-policy.js +582 -0
- package/neural-interface/lib/rulesets/api.js +175 -0
- package/neural-interface/lib/rulesets/fs-safe.js +245 -0
- package/neural-interface/lib/rulesets/installer.js +1453 -0
- package/neural-interface/lib/rulesets/json-edit.js +186 -0
- package/neural-interface/lib/rulesets/lock.js +170 -0
- package/neural-interface/lib/rulesets/managed-text.js +314 -0
- package/neural-interface/lib/rulesets/normalise.js +24 -0
- package/neural-interface/lib/rulesets/render.js +84 -0
- package/neural-interface/lib/schedule-launch-intent.js +40 -0
- package/neural-interface/lib/session-cache-builder.js +524 -0
- package/neural-interface/lib/session-chunker.js +344 -0
- package/neural-interface/lib/session-indexer.js +327 -0
- package/neural-interface/lib/session-title-generator.js +232 -0
- package/neural-interface/lib/skill-prompt-bridge.js +11 -0
- package/neural-interface/lib/style-guide/api.js +375 -0
- package/neural-interface/lib/style-guide/color.js +352 -0
- package/neural-interface/lib/style-guide/export-css.js +99 -0
- package/neural-interface/lib/style-guide/export-dtcg.js +209 -0
- package/neural-interface/lib/style-guide/export-tailwind.js +102 -0
- package/neural-interface/lib/style-guide/fonts.json +227 -0
- package/neural-interface/lib/style-guide/import.js +1268 -0
- package/neural-interface/lib/style-guide/pointers.js +103 -0
- package/neural-interface/lib/style-guide/presets.js +232 -0
- package/neural-interface/lib/style-guide/render-design-md.js +319 -0
- package/neural-interface/lib/style-guide/schema.js +848 -0
- package/neural-interface/lib/style-guide/security.js +43 -0
- package/neural-interface/lib/style-guide/store.js +491 -0
- package/neural-interface/lib/style-guide/summary.js +106 -0
- package/neural-interface/lib/style-guide/tokens.js +170 -0
- package/neural-interface/lib/synabun-update-plan.js +324 -0
- package/neural-interface/lib/synabun-version.js +179 -0
- package/neural-interface/lib/system-restore.js +99 -0
- package/neural-interface/lib/terminal-env.js +86 -0
- package/neural-interface/lib/ui-blob-store.js +106 -0
- package/neural-interface/lib/vector-cache.js +2 -0
- package/neural-interface/lib/virtual-socket.js +60 -0
- package/neural-interface/lib/whatsapp/api.js +146 -0
- package/neural-interface/lib/whatsapp/auth-store.js +389 -0
- package/neural-interface/lib/whatsapp/baileys-adapter.js +457 -0
- package/neural-interface/lib/whatsapp/brain.js +128 -0
- package/neural-interface/lib/whatsapp/bridge.js +1499 -0
- package/neural-interface/lib/whatsapp/cards.js +519 -0
- package/neural-interface/lib/whatsapp/commands.js +92 -0
- package/neural-interface/lib/whatsapp/config.js +291 -0
- package/neural-interface/lib/whatsapp/connector/entry.mjs +25 -0
- package/neural-interface/lib/whatsapp/connector/manifest.json +6 -0
- package/neural-interface/lib/whatsapp/connector/npm-shrinkwrap.json +717 -0
- package/neural-interface/lib/whatsapp/connector/package.json +8 -0
- package/neural-interface/lib/whatsapp/fake-baileys.js +444 -0
- package/neural-interface/lib/whatsapp/format.js +552 -0
- package/neural-interface/lib/whatsapp/host-core.js +1225 -0
- package/neural-interface/lib/whatsapp/host.js +119 -0
- package/neural-interface/lib/whatsapp/identity.js +288 -0
- package/neural-interface/lib/whatsapp/inbound.js +149 -0
- package/neural-interface/lib/whatsapp/installer.js +562 -0
- package/neural-interface/lib/whatsapp/manager.js +638 -0
- package/neural-interface/lib/whatsapp/paths.js +81 -0
- package/neural-interface/lib/whatsapp/protocol.js +327 -0
- package/neural-interface/lib/whatsapp/qr-svg.js +57 -0
- package/neural-interface/lib/whatsapp/redact.js +130 -0
- package/neural-interface/lib/whatsapp/service.js +1305 -0
- package/neural-interface/lib/whatsapp/vendor/qrcodegen.js +848 -0
- package/neural-interface/package-lock.json +4431 -0
- package/neural-interface/package.json +58 -27
- package/neural-interface/public/apple-touch-icon.png +0 -0
- package/neural-interface/public/category-logos/synabun.png +0 -0
- package/neural-interface/public/claude.svg +1 -0
- package/neural-interface/public/favicon-16x16.png +0 -0
- package/neural-interface/public/favicon-32x32.png +0 -0
- package/neural-interface/public/icon-192.png +0 -0
- package/neural-interface/public/icon-512.png +0 -0
- package/neural-interface/public/index.html +32 -182
- package/neural-interface/public/index2d.html +2 -2
- package/neural-interface/public/install-app.html +31 -0
- package/neural-interface/public/logo-synabun.png +0 -0
- package/neural-interface/public/logoHD.png +0 -0
- package/neural-interface/public/manifest.json +2 -0
- package/neural-interface/public/mcp.svg +4 -0
- package/neural-interface/public/offline.html +670 -299
- package/neural-interface/public/onboarding.html +804 -161
- package/neural-interface/public/opencode-logo-dark-square.svg +1 -0
- package/neural-interface/public/shared/agent-runtime-options.js +596 -0
- package/neural-interface/public/shared/api.js +339 -28
- package/neural-interface/public/shared/assistant/asst-accounts.js +318 -0
- package/neural-interface/public/shared/assistant/asst-agents-dock.js +296 -0
- package/neural-interface/public/shared/assistant/asst-api.js +270 -0
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +744 -0
- package/neural-interface/public/shared/assistant/asst-budget.js +333 -0
- package/neural-interface/public/shared/assistant/asst-composer.js +656 -0
- package/neural-interface/public/shared/assistant/asst-computer.js +803 -0
- package/neural-interface/public/shared/assistant/asst-control.js +1018 -0
- package/neural-interface/public/shared/assistant/asst-hosts.js +262 -0
- package/neural-interface/public/shared/assistant/asst-mascot.js +313 -0
- package/neural-interface/public/shared/assistant/asst-menu.js +375 -0
- package/neural-interface/public/shared/assistant/asst-panel.js +1845 -0
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +586 -0
- package/neural-interface/public/shared/assistant/asst-render.js +3305 -0
- package/neural-interface/public/shared/assistant/asst-route.js +1653 -0
- package/neural-interface/public/shared/assistant/asst-roving.js +75 -0
- package/neural-interface/public/shared/assistant/asst-sanitize.js +117 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel-styles.js +488 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +675 -0
- package/neural-interface/public/shared/assistant/asst-slash.js +258 -0
- package/neural-interface/public/shared/assistant/asst-state.js +727 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +1686 -0
- package/neural-interface/public/shared/assistant/asst-tool-kinds.js +1017 -0
- package/neural-interface/public/shared/assistant/asst-usage.js +444 -0
- package/neural-interface/public/shared/assistant/asst-ws.js +175 -0
- package/neural-interface/public/shared/automation-context.js +75 -0
- package/neural-interface/public/shared/blob-store.js +99 -0
- package/neural-interface/public/shared/cdx/cdx-capabilities.js +118 -0
- package/neural-interface/public/shared/cdx/cdx-cards.js +37 -0
- package/neural-interface/public/shared/cdx/cdx-commands.js +171 -0
- package/neural-interface/public/shared/cdx/cdx-context-menu.js +402 -0
- package/neural-interface/public/shared/cdx/cdx-context-model.js +220 -0
- package/neural-interface/public/shared/cdx/cdx-features.js +408 -0
- package/neural-interface/public/shared/cdx/cdx-icons.js +89 -0
- package/neural-interface/public/shared/cdx/cdx-mcp-app-host.js +414 -0
- package/neural-interface/public/shared/cdx/cdx-mcp-app-proxy.html +6 -0
- package/neural-interface/public/shared/cdx/cdx-mcp-app-proxy.js +56 -0
- package/neural-interface/public/shared/cdx/cdx-mcp-app.js +178 -0
- package/neural-interface/public/shared/cdx/cdx-model-catalog.js +120 -0
- package/neural-interface/public/shared/cdx/cdx-output-model.js +261 -0
- package/neural-interface/public/shared/cdx/cdx-output.js +382 -0
- package/neural-interface/public/shared/cdx/cdx-panel.js +1372 -0
- package/neural-interface/public/shared/cdx/cdx-plan.js +266 -0
- package/neural-interface/public/shared/cdx/cdx-protocol.js +682 -0
- package/neural-interface/public/shared/cdx/cdx-render.js +3381 -0
- package/neural-interface/public/shared/cdx/cdx-requests.js +1136 -0
- package/neural-interface/public/shared/cdx/cdx-styles.js +3251 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +7992 -0
- package/neural-interface/public/shared/cdx/cdx-ws.js +363 -0
- package/neural-interface/public/shared/cli-status.js +169 -0
- package/neural-interface/public/shared/command-runner-model.js +30 -0
- package/neural-interface/public/shared/constants.js +22 -5
- package/neural-interface/public/shared/cp/cp-agents.js +186 -0
- package/neural-interface/public/shared/cp/cp-bash.js +252 -0
- package/neural-interface/public/shared/cp/cp-compose.js +159 -0
- package/neural-interface/public/shared/cp/cp-context-menu.js +309 -0
- package/neural-interface/public/shared/cp/cp-context-model.js +157 -0
- package/neural-interface/public/shared/cp/cp-context-window.js +80 -0
- package/neural-interface/public/shared/cp/cp-ctx.js +11 -0
- package/neural-interface/public/shared/cp/cp-diff.js +255 -0
- package/neural-interface/public/shared/cp/cp-event-rows.js +637 -0
- package/neural-interface/public/shared/cp/cp-events.js +846 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +104 -0
- package/neural-interface/public/shared/cp/cp-permission-model.js +905 -0
- package/neural-interface/public/shared/cp/cp-permissions.js +626 -0
- package/neural-interface/public/shared/cp/cp-rehydrate.js +113 -0
- package/neural-interface/public/shared/cp/cp-restore.js +224 -0
- package/neural-interface/public/shared/cp/cp-session-model.js +338 -0
- package/neural-interface/public/shared/cp/cp-session-settings.js +254 -0
- package/neural-interface/public/shared/cp/cp-sessions.js +227 -0
- package/neural-interface/public/shared/cp/cp-statusline.js +153 -0
- package/neural-interface/public/shared/cp/cp-styles.js +349 -0
- package/neural-interface/public/shared/cp/cp-tasks-model.js +282 -0
- package/neural-interface/public/shared/cp/cp-tasks.js +107 -0
- package/neural-interface/public/shared/cp/cp-temporary-view.js +56 -0
- package/neural-interface/public/shared/cp/cp-temporary.js +231 -0
- package/neural-interface/public/shared/cp/cp-tool-cards.js +326 -0
- package/neural-interface/public/shared/cp/cp-tool-results.js +618 -0
- package/neural-interface/public/shared/cp/cp-usage-model.js +124 -0
- package/neural-interface/public/shared/graph-activity.js +68 -0
- package/neural-interface/public/shared/html-shell.js +116 -17
- package/neural-interface/public/shared/i18n.js +132 -34
- package/neural-interface/public/shared/node-positions-store.js +44 -0
- package/neural-interface/public/shared/ocp-hidden-models.js +116 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-approvals.js +355 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-autoaccept-button.js +35 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +72 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-binding.js +280 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-caps.js +67 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-changes-logic.js +179 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-changes.js +164 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +725 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-compact-button.js +75 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-composer-logic.js +1204 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-confirm-logic.js +117 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-confirm.js +59 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-context-gauge.js +252 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-context-menu.js +478 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-context-model.js +179 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +233 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +30 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1065 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-mention-hints.js +182 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +655 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +2636 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-plan.js +601 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-profile-inheritance.js +78 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +649 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-providers.js +35 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +357 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render-logic.js +189 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +1869 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-select.js +42 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +117 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +1714 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +468 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-widgets.js +63 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +366 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-settings-link.js +19 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-slash-hints.js +343 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +746 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-status-logic.js +347 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-status.js +338 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +3543 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-subagents-logic.js +482 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +351 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +168 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +315 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +545 -0
- package/neural-interface/public/shared/provider-icons.js +30 -0
- package/neural-interface/public/shared/pwa-install-page.js +34 -0
- package/neural-interface/public/shared/pwa-install.css +12 -0
- package/neural-interface/public/shared/pwa-install.js +28 -0
- package/neural-interface/public/shared/session-title.js +100 -0
- package/neural-interface/public/shared/settings/settings-ia.js +389 -0
- package/neural-interface/public/shared/settings/settings-kit.js +234 -0
- package/neural-interface/public/shared/settings/settings-rules.js +160 -0
- package/neural-interface/public/shared/settings/settings-search.js +463 -0
- package/neural-interface/public/shared/settings/settings-shell.js +570 -0
- package/neural-interface/public/shared/start-bridge.js +583 -0
- package/neural-interface/public/shared/state.js +5 -0
- package/neural-interface/public/shared/storage.js +50 -7
- package/neural-interface/public/shared/styleguide/sg-agents.js +42 -0
- package/neural-interface/public/shared/styleguide/sg-brand.js +4 -0
- package/neural-interface/public/shared/styleguide/sg-color-client.js +388 -0
- package/neural-interface/public/shared/styleguide/sg-colors.js +151 -0
- package/neural-interface/public/shared/styleguide/sg-components.js +35 -0
- package/neural-interface/public/shared/styleguide/sg-history.js +41 -0
- package/neural-interface/public/shared/styleguide/sg-icons-logo.js +38 -0
- package/neural-interface/public/shared/styleguide/sg-imagery.js +4 -0
- package/neural-interface/public/shared/styleguide/sg-import-export.js +48 -0
- package/neural-interface/public/shared/styleguide/sg-kit.js +284 -0
- package/neural-interface/public/shared/styleguide/sg-labels.js +318 -0
- package/neural-interface/public/shared/styleguide/sg-layout.js +4 -0
- package/neural-interface/public/shared/styleguide/sg-motion.js +5 -0
- package/neural-interface/public/shared/styleguide/sg-panel.js +237 -0
- package/neural-interface/public/shared/styleguide/sg-preview.js +138 -0
- package/neural-interface/public/shared/styleguide/sg-rules.js +9 -0
- package/neural-interface/public/shared/styleguide/sg-shape.js +24 -0
- package/neural-interface/public/shared/styleguide/sg-state.js +132 -0
- package/neural-interface/public/shared/styleguide/sg-typography.js +125 -0
- package/neural-interface/public/shared/styles.css +8614 -1477
- package/neural-interface/public/shared/synabun-mascot.js +1625 -0
- package/neural-interface/public/shared/synabun-ticker.js +376 -0
- package/neural-interface/public/shared/term-ready.js +307 -0
- package/neural-interface/public/shared/term-renderer.js +343 -0
- package/neural-interface/public/shared/ui-assistant-panel.js +10 -0
- package/neural-interface/public/shared/ui-assistant.js +77 -0
- package/neural-interface/public/shared/ui-automation-studio.js +5105 -3573
- package/neural-interface/public/shared/ui-claude-panel.js +11685 -6333
- package/neural-interface/public/shared/ui-codex-panel.js +12 -0
- package/neural-interface/public/shared/ui-command-runner.js +251 -468
- package/neural-interface/public/shared/ui-cost-widget.js +55 -34
- package/neural-interface/public/shared/ui-detail.js +77 -14
- package/neural-interface/public/shared/ui-explorer.js +360 -181
- package/neural-interface/public/shared/ui-file-explorer.js +485 -107
- package/neural-interface/public/shared/ui-help.js +2 -2
- package/neural-interface/public/shared/ui-image-gallery.js +45 -21
- package/neural-interface/public/shared/ui-judgments.js +1346 -0
- package/neural-interface/public/shared/ui-keybinds.js +3 -2
- package/neural-interface/public/shared/ui-link.js +105 -51
- package/neural-interface/public/shared/ui-loading.js +222 -11
- package/neural-interface/public/shared/ui-memory-maintenance.js +111 -0
- package/neural-interface/public/shared/ui-menubar.js +100 -31
- package/neural-interface/public/shared/ui-native-loop-router-state.js +94 -0
- package/neural-interface/public/shared/ui-native-loop-router.js +493 -0
- package/neural-interface/public/shared/ui-native-window-id.js +7 -0
- package/neural-interface/public/shared/ui-navbar.js +357 -222
- package/neural-interface/public/shared/ui-notifications.js +58 -12
- package/neural-interface/public/shared/ui-opencode-panel-v2.js +17 -0
- package/neural-interface/public/shared/ui-panels.js +15 -7
- package/neural-interface/public/shared/ui-resume.js +823 -653
- package/neural-interface/public/shared/ui-schedule-queue.js +172 -0
- package/neural-interface/public/shared/ui-schedules-studio.js +1882 -0
- package/neural-interface/public/shared/ui-scroll-follow.js +194 -0
- package/neural-interface/public/shared/ui-sessions.js +789 -34
- package/neural-interface/public/shared/ui-settings.js +5774 -2194
- package/neural-interface/public/shared/ui-sidepanel-layout.js +109 -0
- package/neural-interface/public/shared/ui-sidepanel-runtime.js +19 -0
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +40 -0
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +221 -0
- package/neural-interface/public/shared/ui-sidepanel-state.js +131 -0
- package/neural-interface/public/shared/ui-sidepanel-tray.js +547 -0
- package/neural-interface/public/shared/ui-sidepanel-windows.js +387 -0
- package/neural-interface/public/shared/ui-skills.js +18 -32
- package/neural-interface/public/shared/ui-styleguide.js +35 -0
- package/neural-interface/public/shared/ui-sync.js +87 -0
- package/neural-interface/public/shared/ui-terminal.js +7863 -6385
- package/neural-interface/public/shared/ui-tool-updates.js +292 -0
- package/neural-interface/public/shared/ui-tooltip.js +156 -15
- package/neural-interface/public/shared/ui-tutorial-draw.js +119 -683
- package/neural-interface/public/shared/ui-tutorial-layout.js +135 -0
- package/neural-interface/public/shared/ui-tutorial-steps.js +59 -2209
- package/neural-interface/public/shared/ui-tutorial.css +102 -0
- package/neural-interface/public/shared/ui-tutorial.js +557 -1076
- package/neural-interface/public/shared/ui-update.js +420 -68
- package/neural-interface/public/shared/ui-whatsapp.js +941 -0
- package/neural-interface/public/shared/ui-whiteboard.js +1076 -233
- package/neural-interface/public/shared/ui-workspaces.js +2 -1
- package/neural-interface/public/shared/utils.js +58 -0
- package/neural-interface/public/shared/vterm-buffer.js +15 -5
- package/neural-interface/public/shared/whatsapp/wa-phone.js +65 -0
- package/neural-interface/public/shared/whatsapp/wa-view.js +411 -0
- package/neural-interface/public/sidepanel-session.html +18 -0
- package/neural-interface/public/sw.js +10 -2
- package/neural-interface/public/synabun.png +0 -0
- package/neural-interface/public/variant/2d/graph.js +1707 -1635
- package/neural-interface/public/variant/2d/lasso.js +2 -1
- package/neural-interface/public/variant/2d/layout.js +595 -594
- package/neural-interface/public/variant/2d/main.js +557 -521
- package/neural-interface/public/variant/2d/settings-gfx.js +18 -24
- package/neural-interface/public/variant/3d/main.js +517 -500
- package/neural-interface/public/variant/3d/map-controls.js +144 -0
- package/neural-interface/public/variant/3d/map-data.js +251 -0
- package/neural-interface/public/variant/3d/map-labels.js +241 -0
- package/neural-interface/public/variant/3d/map-pick.js +90 -0
- package/neural-interface/public/variant/3d/map-renderer.js +521 -0
- package/neural-interface/public/variant/3d/map-shaders.js +158 -0
- package/neural-interface/public/variant/3d/map-view.js +618 -0
- package/neural-interface/public/vendor/three/manifest.json +3 -0
- package/neural-interface/public/vendor/three/three-0.169.0.min.js +3844 -0
- package/neural-interface/public/vendor/xterm/manifest.json +3 -0
- package/neural-interface/public/vendor/xterm/xterm-6.0.0.css +285 -0
- package/neural-interface/public/vendor/xterm/xterm-6.0.0.min.js +192 -0
- package/neural-interface/scripts/build-vendor.mjs +64 -0
- package/neural-interface/scripts/codex-protocol-fixture.mjs +83 -0
- package/neural-interface/scripts/rebuild-pty.js +39 -22
- package/neural-interface/scripts/vendor-three-entry.js +24 -0
- package/neural-interface/scripts/vendor-xterm-entry.js +8 -0
- package/neural-interface/server.js +33983 -15000
- package/neural-interface/skins/default/skin.css +90 -0
- package/neural-interface/skins/default/skin.json +8 -0
- package/neural-interface/templates/rulesets/README.md +9 -0
- package/neural-interface/templates/rulesets/claude.md +3 -0
- package/neural-interface/templates/rulesets/codex.md +2 -0
- package/neural-interface/templates/rulesets/coexistence.md +6 -0
- package/neural-interface/templates/rulesets/core.md +26 -0
- package/neural-interface/templates/rulesets/cursor.md +2 -0
- package/neural-interface/templates/rulesets/gemini.md +2 -0
- package/neural-interface/templates/rulesets/legacy-hashes.json +227 -0
- package/neural-interface/templates/rulesets/manifest.json +12 -0
- package/neural-interface/templates/rulesets/opencode.md +2 -0
- package/package.json +131 -53
- package/postinstall.js +55 -26
- package/preuninstall.js +187 -0
- package/scripts/restore-data-home-from-backup.mjs +239 -0
- package/setup.js +872 -260
- package/skills/leonardo/SKILL.md +19 -10
- package/skills/leonardo/modules/image-prompter.md +18 -12
- package/skills/leonardo/modules/video-prompter.md +19 -13
- package/skills/synabun/SKILL.md +209 -185
- package/skills/synabun/icon.png +0 -0
- package/skills/synabun/modules/audit.md +380 -374
- package/skills/synabun/modules/changelog.md +15 -6
- package/skills/synabun/modules/idea.md +148 -144
- package/skills/synabun/modules/memorize.md +13 -4
- package/skills/synabun/modules/schedule.md +198 -0
- package/skills/synabun/synabunicon.png +0 -0
- package/updater.cmd +31 -0
- package/updater.mjs +382 -0
- package/updater.sh +29 -0
- package/hooks/claude-code/test-user-learning.mjs +0 -531
- package/neural-interface/public/claude-chat.css +0 -878
- package/neural-interface/public/claude-chat.html +0 -92
- package/neural-interface/public/claude-chat.js +0 -1168
- package/neural-interface/public/index-legacy.html +0 -14677
- package/neural-interface/public/index2d-legacy.html +0 -8193
- package/neural-interface/public/shared/html-term-renderer.js +0 -1022
- package/neural-interface/public/variant/3d/background.js +0 -884
- package/neural-interface/public/variant/3d/camera.js +0 -661
- package/neural-interface/public/variant/3d/gfx.js +0 -116
- package/neural-interface/public/variant/3d/graph.js +0 -2399
- package/neural-interface/public/variant/3d/settings-gfx.js +0 -228
- package/neural-interface/templates/CLAUDE-template.md +0 -211
|
@@ -1,1635 +1,1707 @@
|
|
|
1
|
-
// ═══════════════════════════════════════════
|
|
2
|
-
// SynaBun Neural Interface — 2D Canvas Renderer
|
|
3
|
-
// Pure canvas rendering with orbital layout,
|
|
4
|
-
// viewport pan/zoom, hit detection, drag system
|
|
5
|
-
// ═══════════════════════════════════════════
|
|
6
|
-
|
|
7
|
-
import { gfx } from './gfx.js';
|
|
8
|
-
import { computeLayout, resetLayout, flattenRegions, CARD_W, CARD_H } from './layout.js';
|
|
9
|
-
import { drawBackground, initBackground } from './background.js';
|
|
10
|
-
import { state, emit, on } from '../../shared/state.js';
|
|
11
|
-
import { catColor, hexAlpha } from '../../shared/colors.js';
|
|
12
|
-
import { KEYS } from '../../shared/constants.js';
|
|
13
|
-
import { storage } from '../../shared/storage.js';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
let
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_openclawLogo
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
// ═══════════════════════════════════════════
|
|
163
|
-
//
|
|
164
|
-
// ═══════════════════════════════════════════
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
//
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
_canvas.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
*
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
//
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
//
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
//
|
|
632
|
-
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
ctx.
|
|
641
|
-
ctx.
|
|
642
|
-
ctx.
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
ctx.
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
//
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
ctx.
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
//
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
//
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
ctx.
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
ctx.
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
//
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
ctx.
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
function
|
|
893
|
-
const
|
|
894
|
-
const
|
|
895
|
-
const
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
//
|
|
950
|
-
if (
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
// ──
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
ctx.
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
ctx
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
if (
|
|
998
|
-
ctx
|
|
999
|
-
ctx.
|
|
1000
|
-
ctx.
|
|
1001
|
-
ctx.
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
ctx.
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
//
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
ctx.
|
|
1074
|
-
ctx.
|
|
1075
|
-
|
|
1076
|
-
ctx.
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
if (
|
|
1128
|
-
|
|
1129
|
-
if (
|
|
1130
|
-
|
|
1131
|
-
return
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
if (x >= region.cx -
|
|
1172
|
-
y >= region.cy -
|
|
1173
|
-
return { type: 'region', item: region };
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
if (
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
//
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
if (
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
_pointer.
|
|
1335
|
-
|
|
1336
|
-
} else {
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
)
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun Neural Interface — 2D Canvas Renderer
|
|
3
|
+
// Pure canvas rendering with orbital layout,
|
|
4
|
+
// viewport pan/zoom, hit detection, drag system
|
|
5
|
+
// ═══════════════════════════════════════════
|
|
6
|
+
|
|
7
|
+
import { gfx } from './gfx.js';
|
|
8
|
+
import { computeLayout, resetLayout, flattenRegions, CARD_W, CARD_H } from './layout.js';
|
|
9
|
+
import { drawBackground, initBackground } from './background.js';
|
|
10
|
+
import { state, emit, on } from '../../shared/state.js';
|
|
11
|
+
import { catColor, hexAlpha } from '../../shared/colors.js';
|
|
12
|
+
import { KEYS } from '../../shared/constants.js';
|
|
13
|
+
import { storage } from '../../shared/storage.js';
|
|
14
|
+
import { posStore } from '../../shared/node-positions-store.js';
|
|
15
|
+
import { truncate, normalizeNodes, rafThrottle } from '../../shared/utils.js';
|
|
16
|
+
|
|
17
|
+
// ═══════════════════════════════════════════
|
|
18
|
+
// PRIVATE STATE
|
|
19
|
+
// ═══════════════════════════════════════════
|
|
20
|
+
|
|
21
|
+
let _canvas = null;
|
|
22
|
+
let _ctx = null;
|
|
23
|
+
let _container = null;
|
|
24
|
+
let _animFrameId = null;
|
|
25
|
+
let _callbacks = {};
|
|
26
|
+
|
|
27
|
+
// Layout data
|
|
28
|
+
let _regions = []; // CategoryRegion[] from computeLayout
|
|
29
|
+
let _cards = []; // CardPosition[] from computeLayout
|
|
30
|
+
let _cardById = new Map(); // id → CardPosition
|
|
31
|
+
|
|
32
|
+
// Category logo preload cache
|
|
33
|
+
const _categoryLogos = new Map();
|
|
34
|
+
|
|
35
|
+
// Fallback logo for OpenClaw (hardcoded like 3D variant)
|
|
36
|
+
const _openclawLogo = new Image();
|
|
37
|
+
_openclawLogo.src = '/openclaw-logo-text.png';
|
|
38
|
+
let _openclawLogoReady = false;
|
|
39
|
+
_openclawLogo.onload = () => { _openclawLogoReady = true; };
|
|
40
|
+
|
|
41
|
+
// Graph removal scheduling
|
|
42
|
+
let _graphRemovalTimer = null;
|
|
43
|
+
|
|
44
|
+
// ═══════════════════════════════════════════
|
|
45
|
+
// PERFORMANCE CACHES
|
|
46
|
+
// ═══════════════════════════════════════════
|
|
47
|
+
|
|
48
|
+
// Neighbor adjacency map: id → Set<id> — built once in applyGraphData
|
|
49
|
+
let _neighborMap = new Map();
|
|
50
|
+
|
|
51
|
+
// Resolved links cache — built once in applyGraphData, avoids per-frame ID lookups
|
|
52
|
+
// Each entry: { sourceCard, targetCard, strength, crossCat }
|
|
53
|
+
let _resolvedLinks = [];
|
|
54
|
+
let _resolvedLinksStrong = []; // strength >= 0.4 (shown at LOD 1)
|
|
55
|
+
|
|
56
|
+
// Card text cache: nodeId → { content, lines }
|
|
57
|
+
const _textCache = new Map();
|
|
58
|
+
|
|
59
|
+
// DPR for high-DPI rendering (capped to limit fill rate on high-DPI displays)
|
|
60
|
+
const MAX_DPR = 1.5;
|
|
61
|
+
let _dpr = 1;
|
|
62
|
+
|
|
63
|
+
// Idle throttling — full rate while panning/zooming/animating, reduced when
|
|
64
|
+
// still (background breathing is a 4s sine; 15fps keeps it smooth enough)
|
|
65
|
+
const IDLE_AFTER_MS = 2000;
|
|
66
|
+
const IDLE_FPS = 15;
|
|
67
|
+
let _externallyStopped = false; // stopAnimation() called (focus mode / viz toggle)
|
|
68
|
+
let _lastActivityTime = 0;
|
|
69
|
+
let _lastIdleRenderTime = 0;
|
|
70
|
+
|
|
71
|
+
// ═══════════════════════════════════════════
|
|
72
|
+
// VIEWPORT (pan/zoom state)
|
|
73
|
+
// ═══════════════════════════════════════════
|
|
74
|
+
|
|
75
|
+
const _viewport = {
|
|
76
|
+
offsetX: 0,
|
|
77
|
+
offsetY: 0,
|
|
78
|
+
scale: 0.4,
|
|
79
|
+
minScale: 0.02,
|
|
80
|
+
maxScale: 3.0,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Animation state
|
|
84
|
+
let _animating = false;
|
|
85
|
+
let _animStart = 0;
|
|
86
|
+
let _animDuration = 0;
|
|
87
|
+
let _animFrom = {};
|
|
88
|
+
let _animTo = {};
|
|
89
|
+
|
|
90
|
+
// Smooth zoom state — lerps toward target for fluid feel
|
|
91
|
+
const _smoothZoom = {
|
|
92
|
+
targetScale: 0.4,
|
|
93
|
+
anchorX: 0, // cursor position in buffer coords (zoom pivot)
|
|
94
|
+
anchorY: 0,
|
|
95
|
+
active: false,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// ═══════════════════════════════════════════
|
|
99
|
+
// INTERACTION STATE
|
|
100
|
+
// ═══════════════════════════════════════════
|
|
101
|
+
|
|
102
|
+
const _pointer = {
|
|
103
|
+
isPanning: false,
|
|
104
|
+
isDragging: false,
|
|
105
|
+
dragTarget: null, // { type: 'card'|'region', item: CardPosition|Region }
|
|
106
|
+
dragSet: [], // items moving together (rigid-body)
|
|
107
|
+
dragStartWorld: null, // world coords at drag start
|
|
108
|
+
lastScreenX: 0,
|
|
109
|
+
lastScreenY: 0,
|
|
110
|
+
downScreenX: 0,
|
|
111
|
+
downScreenY: 0,
|
|
112
|
+
lastMoveTime: 0, // for velocity tracking
|
|
113
|
+
downTime: 0,
|
|
114
|
+
hasMoved: false,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Position save timer
|
|
118
|
+
let _posSaveTimer = null;
|
|
119
|
+
|
|
120
|
+
// Focus mode — true when visualization is paused (zero-resource mode)
|
|
121
|
+
let _focusPaused = false;
|
|
122
|
+
|
|
123
|
+
// Pan inertia — coasting after mouse release
|
|
124
|
+
const _panInertia = {
|
|
125
|
+
vx: 0,
|
|
126
|
+
vy: 0,
|
|
127
|
+
active: false,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// ═══════════════════════════════════════════
|
|
131
|
+
// COORDINATE TRANSFORMS
|
|
132
|
+
// ═══════════════════════════════════════════
|
|
133
|
+
|
|
134
|
+
export function screenToWorld(sx, sy) {
|
|
135
|
+
return {
|
|
136
|
+
x: (sx * _dpr - _viewport.offsetX) / _viewport.scale,
|
|
137
|
+
y: (sy * _dpr - _viewport.offsetY) / _viewport.scale,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function worldToScreen(wx, wy) {
|
|
142
|
+
return {
|
|
143
|
+
x: (wx * _viewport.scale + _viewport.offsetX) / _dpr,
|
|
144
|
+
y: (wy * _viewport.scale + _viewport.offsetY) / _dpr,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Get the visible world-space bounding box (with margin for partially visible items).
|
|
150
|
+
* @param {number} margin Extra world-space pixels around the viewport edges
|
|
151
|
+
* @returns {{ left: number, right: number, top: number, bottom: number }}
|
|
152
|
+
*/
|
|
153
|
+
function _getVisibleBounds(margin = 0) {
|
|
154
|
+
const invScale = 1 / _viewport.scale;
|
|
155
|
+
const left = -_viewport.offsetX * invScale - margin;
|
|
156
|
+
const top = -_viewport.offsetY * invScale - margin;
|
|
157
|
+
const right = (_canvas.width - _viewport.offsetX) * invScale + margin;
|
|
158
|
+
const bottom = (_canvas.height - _viewport.offsetY) * invScale + margin;
|
|
159
|
+
return { left, right, top, bottom };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ═══════════════════════════════════════════
|
|
163
|
+
// PUBLIC API: Viewport accessors
|
|
164
|
+
// ═══════════════════════════════════════════
|
|
165
|
+
|
|
166
|
+
export function getViewport() { return { ..._viewport, dpr: _dpr }; }
|
|
167
|
+
export function getAllCards() { return _cards; }
|
|
168
|
+
export function getRegions() { return _regions; }
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
// ═══════════════════════════════════════════
|
|
172
|
+
// INIT
|
|
173
|
+
// ═══════════════════════════════════════════
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Initialize the 2D canvas renderer.
|
|
177
|
+
* @param {HTMLElement} container The #graph-container element
|
|
178
|
+
* @param {Object} callbacks { onRenderFramePost }
|
|
179
|
+
* @returns {Object} Public API shim (centerAt, zoom, etc.)
|
|
180
|
+
*/
|
|
181
|
+
export function initGraph(container, callbacks = {}) {
|
|
182
|
+
_container = container;
|
|
183
|
+
_callbacks = callbacks;
|
|
184
|
+
|
|
185
|
+
// Create or find the main canvas
|
|
186
|
+
_canvas = document.getElementById('canvas-main');
|
|
187
|
+
if (!_canvas) {
|
|
188
|
+
_canvas = document.createElement('canvas');
|
|
189
|
+
_canvas.id = 'canvas-main';
|
|
190
|
+
_canvas.style.cssText = 'position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:1;';
|
|
191
|
+
container.appendChild(_canvas);
|
|
192
|
+
}
|
|
193
|
+
_ctx = _canvas.getContext('2d');
|
|
194
|
+
|
|
195
|
+
// Size canvas (DPR-aware, capped for perf)
|
|
196
|
+
_dpr = Math.min(window.devicePixelRatio || 1, MAX_DPR);
|
|
197
|
+
_resizeCanvas();
|
|
198
|
+
|
|
199
|
+
// Center viewport
|
|
200
|
+
_viewport.offsetX = _canvas.width / 2;
|
|
201
|
+
_viewport.offsetY = _canvas.height / 2;
|
|
202
|
+
_smoothZoom.targetScale = _viewport.scale;
|
|
203
|
+
|
|
204
|
+
// Attach event listeners
|
|
205
|
+
_canvas.addEventListener('pointerdown', _onPointerDown);
|
|
206
|
+
_canvas.addEventListener('pointermove', _onPointerMove);
|
|
207
|
+
_canvas.addEventListener('pointerup', _onPointerUp);
|
|
208
|
+
_canvas.addEventListener('pointerleave', _onPointerLeave);
|
|
209
|
+
_canvas.addEventListener('wheel', _onWheel, { passive: false });
|
|
210
|
+
_canvas.addEventListener('dblclick', _onDblClick);
|
|
211
|
+
_canvas.addEventListener('contextmenu', _onContextMenu);
|
|
212
|
+
window.addEventListener('resize', _scheduleCanvasResize);
|
|
213
|
+
|
|
214
|
+
// Hidden tab → stop the loop entirely; resume on return unless externally stopped
|
|
215
|
+
document.addEventListener('visibilitychange', () => {
|
|
216
|
+
if (document.hidden) {
|
|
217
|
+
if (_animFrameId) { cancelAnimationFrame(_animFrameId); _animFrameId = null; }
|
|
218
|
+
} else if (!_externallyStopped && !_animFrameId && _canvas) {
|
|
219
|
+
_lastActivityTime = performance.now(); // render immediately on return
|
|
220
|
+
_animFrameId = requestAnimationFrame(_renderLoop);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// Start render loop
|
|
225
|
+
_animFrameId = requestAnimationFrame(_renderLoop);
|
|
226
|
+
|
|
227
|
+
// Init background (logo preload)
|
|
228
|
+
initBackground();
|
|
229
|
+
|
|
230
|
+
return _getPublicAPI();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Get the public API object (force-graph compatible shim).
|
|
235
|
+
* @returns {Object|null}
|
|
236
|
+
*/
|
|
237
|
+
export function getGraph() {
|
|
238
|
+
if (!_canvas) return null;
|
|
239
|
+
return _getPublicAPI();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
// ═══════════════════════════════════════════
|
|
244
|
+
// PUBLIC API: Data & Layout
|
|
245
|
+
// ═══════════════════════════════════════════
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Apply graph data: filters by activeCategories, runs layout, updates render state.
|
|
249
|
+
* Call after data load, category change, or search change.
|
|
250
|
+
*/
|
|
251
|
+
export function applyGraphData() {
|
|
252
|
+
if (!_canvas) return;
|
|
253
|
+
_lastActivityTime = performance.now(); // new data → render at full rate
|
|
254
|
+
|
|
255
|
+
// Filter nodes by active categories
|
|
256
|
+
const visibleNodes = state.allNodes.filter(n => {
|
|
257
|
+
const cat = n.payload?.category;
|
|
258
|
+
return cat && state.activeCategories.has(cat);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// Compute orbital layout
|
|
262
|
+
const result = computeLayout(visibleNodes, state.categoryMetadata, state.activeCategories);
|
|
263
|
+
_regions = result.regions;
|
|
264
|
+
_cards = result.cards;
|
|
265
|
+
|
|
266
|
+
// Build card lookup
|
|
267
|
+
_cardById.clear();
|
|
268
|
+
for (const card of _cards) {
|
|
269
|
+
_cardById.set(card.node.id, card);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Build neighbor adjacency map + resolved links (O(links) once, not per frame)
|
|
273
|
+
_neighborMap.clear();
|
|
274
|
+
_resolvedLinks = [];
|
|
275
|
+
_resolvedLinksStrong = [];
|
|
276
|
+
for (const link of state.allLinks) {
|
|
277
|
+
const s = typeof link.source === 'object' ? link.source.id : link.source;
|
|
278
|
+
const t = typeof link.target === 'object' ? link.target.id : link.target;
|
|
279
|
+
if (!_neighborMap.has(s)) _neighborMap.set(s, new Set());
|
|
280
|
+
if (!_neighborMap.has(t)) _neighborMap.set(t, new Set());
|
|
281
|
+
_neighborMap.get(s).add(t);
|
|
282
|
+
_neighborMap.get(t).add(s);
|
|
283
|
+
|
|
284
|
+
const sc = _cardById.get(s);
|
|
285
|
+
const tc = _cardById.get(t);
|
|
286
|
+
if (!sc || !tc) continue;
|
|
287
|
+
const crossCat = (sc.node.payload?.category !== tc.node.payload?.category);
|
|
288
|
+
const entry = { sourceCard: sc, targetCard: tc, strength: link.strength || 0.5, crossCat };
|
|
289
|
+
_resolvedLinks.push(entry);
|
|
290
|
+
if (entry.strength >= 0.4) _resolvedLinksStrong.push(entry);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Clear text cache (content may have changed)
|
|
294
|
+
_textCache.clear();
|
|
295
|
+
|
|
296
|
+
// Preload category logos
|
|
297
|
+
const cats = [];
|
|
298
|
+
for (const [name, meta] of Object.entries(state.categoryMetadata)) {
|
|
299
|
+
if (meta.logo) cats.push({ name, logo: meta.logo });
|
|
300
|
+
}
|
|
301
|
+
preloadCategoryLogos(cats);
|
|
302
|
+
|
|
303
|
+
emit('stats-changed');
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Preload category logo images from metadata.
|
|
308
|
+
* @param {Array<{name:string, logo:string}>} categories
|
|
309
|
+
*/
|
|
310
|
+
export function preloadCategoryLogos(categories) {
|
|
311
|
+
const names = new Set(categories.map(c => c.name));
|
|
312
|
+
for (const [k] of _categoryLogos) { if (!names.has(k)) _categoryLogos.delete(k); }
|
|
313
|
+
for (const cat of categories) {
|
|
314
|
+
if (!cat.logo) continue;
|
|
315
|
+
const existing = _categoryLogos.get(cat.name);
|
|
316
|
+
if (existing && existing.src === cat.logo) continue;
|
|
317
|
+
const img = new Image();
|
|
318
|
+
const entry = { img, ready: false, src: cat.logo };
|
|
319
|
+
img.onload = () => { entry.ready = true; };
|
|
320
|
+
img.onerror = () => { _categoryLogos.delete(cat.name); };
|
|
321
|
+
img.src = cat.logo;
|
|
322
|
+
_categoryLogos.set(cat.name, entry);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Re-fetch data from API and re-apply layout.
|
|
328
|
+
*/
|
|
329
|
+
export async function refreshGraph() {
|
|
330
|
+
const res = await fetch('/api/memories?fields=graph');
|
|
331
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
332
|
+
const data = await res.json();
|
|
333
|
+
state.allNodes = normalizeNodes(data.nodes);
|
|
334
|
+
state.allLinks = data.links;
|
|
335
|
+
applyGraphData();
|
|
336
|
+
emit('data-loaded', data);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Re-compute layout from scratch (replaces reheatSimulation).
|
|
341
|
+
*/
|
|
342
|
+
export function reheatSimulation() {
|
|
343
|
+
resetLayout();
|
|
344
|
+
applyGraphData();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Schedule a deferred graph data reapply (after deletion animation).
|
|
349
|
+
*/
|
|
350
|
+
export function scheduleGraphRemoval(delay = 500) {
|
|
351
|
+
cancelScheduledRemoval();
|
|
352
|
+
_graphRemovalTimer = setTimeout(() => {
|
|
353
|
+
applyGraphData();
|
|
354
|
+
_graphRemovalTimer = null;
|
|
355
|
+
}, delay);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export function cancelScheduledRemoval() {
|
|
359
|
+
if (_graphRemovalTimer) {
|
|
360
|
+
clearTimeout(_graphRemovalTimer);
|
|
361
|
+
_graphRemovalTimer = null;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
/** Stop the render loop (focus mode). */
|
|
367
|
+
export function stopAnimation() {
|
|
368
|
+
_externallyStopped = true;
|
|
369
|
+
if (_animFrameId) {
|
|
370
|
+
cancelAnimationFrame(_animFrameId);
|
|
371
|
+
_animFrameId = null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** Restart the render loop after stopping. */
|
|
376
|
+
export function startAnimation() {
|
|
377
|
+
_externallyStopped = false;
|
|
378
|
+
_lastActivityTime = performance.now();
|
|
379
|
+
if (!_animFrameId && _canvas) {
|
|
380
|
+
_animFrameId = requestAnimationFrame(_renderLoop);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** Pause all interaction (focus mode — zero resource consumption). */
|
|
385
|
+
export function pauseInteraction() {
|
|
386
|
+
_focusPaused = true;
|
|
387
|
+
_panInertia.active = false;
|
|
388
|
+
// Reset any in-flight drag/pan so state doesn't stick across focus toggles
|
|
389
|
+
_pointer.isPanning = false;
|
|
390
|
+
_pointer.isDragging = false;
|
|
391
|
+
// Ensure canvas doesn't block pointer events to layers below (whiteboard).
|
|
392
|
+
// This also covers the boot race where viz:toggle fires before _bootComplete.
|
|
393
|
+
if (_canvas) _canvas.classList.add('viz-hidden-2d');
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** Resume interaction after focus mode exit. */
|
|
397
|
+
export function resumeInteraction() {
|
|
398
|
+
_focusPaused = false;
|
|
399
|
+
if (_canvas) _canvas.classList.remove('viz-hidden-2d');
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// ═══════════════════════════════════════════
|
|
403
|
+
// RENDER LOOP
|
|
404
|
+
// ═══════════════════════════════════════════
|
|
405
|
+
|
|
406
|
+
function _renderLoop(time) {
|
|
407
|
+
if (!_canvas || !_ctx) return;
|
|
408
|
+
|
|
409
|
+
// Pending window resize: apply it now (once this frame) and draw this frame
|
|
410
|
+
// even when idle — resizing cleared the canvas.
|
|
411
|
+
const resized = _resizePending;
|
|
412
|
+
if (resized) _resizeCanvas();
|
|
413
|
+
|
|
414
|
+
// Idle gate: while any viewport motion is in flight stay at full rate;
|
|
415
|
+
// after 2s of stillness drop to IDLE_FPS (skip the frame, keep the loop)
|
|
416
|
+
if (_animating || _smoothZoom.active || _panInertia.active) {
|
|
417
|
+
_lastActivityTime = time;
|
|
418
|
+
}
|
|
419
|
+
if (!resized &&
|
|
420
|
+
time - _lastActivityTime > IDLE_AFTER_MS &&
|
|
421
|
+
time - _lastIdleRenderTime < 1000 / IDLE_FPS) {
|
|
422
|
+
_animFrameId = requestAnimationFrame(_renderLoop);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
_lastIdleRenderTime = time;
|
|
426
|
+
|
|
427
|
+
const w = _canvas.width;
|
|
428
|
+
const h = _canvas.height;
|
|
429
|
+
const ctx = _ctx;
|
|
430
|
+
|
|
431
|
+
// Process viewport animation
|
|
432
|
+
if (_animating) {
|
|
433
|
+
const elapsed = time - _animStart;
|
|
434
|
+
const t = Math.min(elapsed / _animDuration, 1);
|
|
435
|
+
const ease = t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2; // easeInOutQuad
|
|
436
|
+
|
|
437
|
+
_viewport.offsetX = _animFrom.offsetX + (_animTo.offsetX - _animFrom.offsetX) * ease;
|
|
438
|
+
_viewport.offsetY = _animFrom.offsetY + (_animTo.offsetY - _animFrom.offsetY) * ease;
|
|
439
|
+
_viewport.scale = _animFrom.scale + (_animTo.scale - _animFrom.scale) * ease;
|
|
440
|
+
|
|
441
|
+
if (t >= 1) {
|
|
442
|
+
_animating = false;
|
|
443
|
+
_smoothZoom.targetScale = _viewport.scale;
|
|
444
|
+
_smoothZoom.active = false;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// Process smooth zoom (lerp toward target scale with cursor as pivot)
|
|
449
|
+
if (_smoothZoom.active) {
|
|
450
|
+
const LERP = 0.18;
|
|
451
|
+
const diff = _smoothZoom.targetScale - _viewport.scale;
|
|
452
|
+
if (Math.abs(diff) < 0.0001) {
|
|
453
|
+
_viewport.scale = _smoothZoom.targetScale;
|
|
454
|
+
_smoothZoom.active = false;
|
|
455
|
+
} else {
|
|
456
|
+
const newScale = _viewport.scale + diff * LERP;
|
|
457
|
+
const mx = _smoothZoom.anchorX;
|
|
458
|
+
const my = _smoothZoom.anchorY;
|
|
459
|
+
_viewport.offsetX = mx - (mx - _viewport.offsetX) * (newScale / _viewport.scale);
|
|
460
|
+
_viewport.offsetY = my - (my - _viewport.offsetY) * (newScale / _viewport.scale);
|
|
461
|
+
_viewport.scale = newScale;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Process pan inertia (coasting after mouse release)
|
|
466
|
+
if (_panInertia.active) {
|
|
467
|
+
const FRICTION = 0.92;
|
|
468
|
+
_viewport.offsetX += _panInertia.vx;
|
|
469
|
+
_viewport.offsetY += _panInertia.vy;
|
|
470
|
+
_panInertia.vx *= FRICTION;
|
|
471
|
+
_panInertia.vy *= FRICTION;
|
|
472
|
+
if (Math.abs(_panInertia.vx) < 0.1 && Math.abs(_panInertia.vy) < 0.1) {
|
|
473
|
+
_panInertia.active = false;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// ── Compute visible world bounds (with margin for partially visible items) ──
|
|
478
|
+
const cardMargin = Math.max(CARD_W, CARD_H);
|
|
479
|
+
const vb = _getVisibleBounds(cardMargin);
|
|
480
|
+
|
|
481
|
+
// ── LOD thresholds (card screen-space size in CSS pixels) ──
|
|
482
|
+
const cardScreenW = CARD_W * _viewport.scale / _dpr;
|
|
483
|
+
// LOD 0: full card (cardScreenW >= 25px)
|
|
484
|
+
// LOD 1: simple colored rect (12-25px)
|
|
485
|
+
// LOD 2: tiny dot (< 12px)
|
|
486
|
+
const lod = cardScreenW >= 25 ? 0 : cardScreenW >= 12 ? 1 : 2;
|
|
487
|
+
|
|
488
|
+
// ── 1. Background (screen-space) ──
|
|
489
|
+
drawBackground(ctx, time, w, h);
|
|
490
|
+
|
|
491
|
+
// ── 2. Apply pan/zoom transform ──
|
|
492
|
+
ctx.save();
|
|
493
|
+
ctx.translate(_viewport.offsetX, _viewport.offsetY);
|
|
494
|
+
ctx.scale(_viewport.scale, _viewport.scale);
|
|
495
|
+
|
|
496
|
+
// ── 3. Category region glows (culled, skip at LOD 2) ──
|
|
497
|
+
if (gfx.regionGlowOpacity > 0 && lod < 2) {
|
|
498
|
+
for (const region of _regions) {
|
|
499
|
+
if (_isRegionVisible(region, vb)) _drawRegionGlow(ctx, region);
|
|
500
|
+
for (const child of (region.children || [])) {
|
|
501
|
+
if (_isRegionVisible(child, vb)) _drawRegionGlow(ctx, child);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// ── 4. Connection lines (batched + culled, LOD-aware, skip at LOD 2) ──
|
|
507
|
+
if (state.linkMode !== 'off' && _resolvedLinks.length > 0 && lod < 2) {
|
|
508
|
+
_drawLinks(ctx, vb, lod);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// ── 5. Memory cards (LOD-aware + culled) ──
|
|
512
|
+
if (lod === 2) {
|
|
513
|
+
// LOD 2: tiny dots — batch into single path per color for speed
|
|
514
|
+
_drawCardDots(ctx, vb);
|
|
515
|
+
} else if (lod === 1) {
|
|
516
|
+
// LOD 1: simple colored rectangles, no text/shadows
|
|
517
|
+
_drawCardSimple(ctx, vb);
|
|
518
|
+
} else {
|
|
519
|
+
// LOD 0: full detail
|
|
520
|
+
for (const card of _cards) {
|
|
521
|
+
if (card.x + CARD_W / 2 < vb.left || card.x - CARD_W / 2 > vb.right ||
|
|
522
|
+
card.y + CARD_H / 2 < vb.top || card.y - CARD_H / 2 > vb.bottom) continue;
|
|
523
|
+
_drawCard(ctx, card);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// ── 6. Category labels (LOD-aware + culled) ──
|
|
528
|
+
// Child labels hidden at LOD >= 1 (zoomed out too far to be useful)
|
|
529
|
+
// Child labels fade near the LOD boundary for smooth transition
|
|
530
|
+
const childLabelOpacity = lod >= 1 ? 0 : Math.min(1, (cardScreenW - 25) / 15); // fade 25→40px
|
|
531
|
+
for (const region of _regions) {
|
|
532
|
+
if (_isRegionVisible(region, vb)) _drawCategoryLabel(ctx, region, true, 1);
|
|
533
|
+
if (childLabelOpacity > 0) {
|
|
534
|
+
for (const child of (region.children || [])) {
|
|
535
|
+
if (_isRegionVisible(child, vb)) _drawCategoryLabel(ctx, child, false, childLabelOpacity);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
ctx.restore();
|
|
541
|
+
|
|
542
|
+
// ── 7. Post-render callback (minimap, etc.) ──
|
|
543
|
+
if (_callbacks.onRenderFramePost) {
|
|
544
|
+
_callbacks.onRenderFramePost();
|
|
545
|
+
}
|
|
546
|
+
emit('render-frame-post');
|
|
547
|
+
|
|
548
|
+
_animFrameId = requestAnimationFrame(_renderLoop);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** Check if a region's bounding circle is within the visible bounds */
|
|
552
|
+
function _isRegionVisible(region, vb) {
|
|
553
|
+
const r = (region.radius || 200) + 100; // extra margin for glow/labels
|
|
554
|
+
return region.cx + r > vb.left && region.cx - r < vb.right &&
|
|
555
|
+
region.cy + r > vb.top && region.cy - r < vb.bottom;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
// ═══════════════════════════════════════════
|
|
560
|
+
// DRAWING: Region Glow
|
|
561
|
+
// ═══════════════════════════════════════════
|
|
562
|
+
|
|
563
|
+
function _drawRegionGlow(ctx, region) {
|
|
564
|
+
if (!region.radius || region.radius <= 0) return;
|
|
565
|
+
const r = region.radius + 40;
|
|
566
|
+
const grad = ctx.createRadialGradient(region.cx, region.cy, 0, region.cx, region.cy, r);
|
|
567
|
+
grad.addColorStop(0, hexAlpha(region.color, gfx.regionGlowOpacity));
|
|
568
|
+
grad.addColorStop(1, hexAlpha(region.color, 0));
|
|
569
|
+
ctx.fillStyle = grad;
|
|
570
|
+
ctx.beginPath();
|
|
571
|
+
ctx.arc(region.cx, region.cy, r, 0, Math.PI * 2);
|
|
572
|
+
ctx.fill();
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
// ═══════════════════════════════════════════
|
|
577
|
+
// DRAWING: Category Labels
|
|
578
|
+
// ═══════════════════════════════════════════
|
|
579
|
+
|
|
580
|
+
function _drawCategoryLabel(ctx, region, isParent, labelOpacity = 1) {
|
|
581
|
+
// Respect label visibility toggle
|
|
582
|
+
if (!state.labelsVisible) return;
|
|
583
|
+
|
|
584
|
+
const mul = state.labelSizeMultiplier || 1;
|
|
585
|
+
const logoEntry = _categoryLogos.get(region.name);
|
|
586
|
+
// Fall back to hardcoded OpenClaw logo if no uploaded logo
|
|
587
|
+
const hasLogo = (logoEntry && logoEntry.ready) || (region.name === 'openclaw' && _openclawLogoReady);
|
|
588
|
+
const logoImg = (logoEntry && logoEntry.ready) ? logoEntry.img : _openclawLogo;
|
|
589
|
+
|
|
590
|
+
// ── Zoom compensation: ensure labels stay readable at any zoom ──
|
|
591
|
+
// Capped at 2.5x to prevent labels from growing larger than the gaps between categories
|
|
592
|
+
const MAX_ZOOM_BOOST = isParent ? 2.5 : 2.0;
|
|
593
|
+
const MIN_SCREEN_PX = isParent ? 18 : 13;
|
|
594
|
+
const baseFontSize = isParent ? 38 : 22;
|
|
595
|
+
const rawFontSize = baseFontSize * mul;
|
|
596
|
+
const screenPx = rawFontSize * _viewport.scale / _dpr;
|
|
597
|
+
const zoomBoost = screenPx < MIN_SCREEN_PX
|
|
598
|
+
? Math.min(MIN_SCREEN_PX / screenPx, MAX_ZOOM_BOOST)
|
|
599
|
+
: 1;
|
|
600
|
+
|
|
601
|
+
// Apply label opacity (for child label fade-out at zoom boundaries)
|
|
602
|
+
const needsOpacity = labelOpacity < 1;
|
|
603
|
+
if (needsOpacity) {
|
|
604
|
+
ctx.save();
|
|
605
|
+
ctx.globalAlpha = labelOpacity;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (isParent) {
|
|
609
|
+
// ── PARENT: logo-first if available, clean text otherwise ──
|
|
610
|
+
const fontSize = Math.round(38 * mul * zoomBoost);
|
|
611
|
+
const nameText = region.name.toUpperCase();
|
|
612
|
+
|
|
613
|
+
// Subtle glow ring
|
|
614
|
+
ctx.save();
|
|
615
|
+
const glowR = 70 * mul * zoomBoost;
|
|
616
|
+
const grad = ctx.createRadialGradient(region.cx, region.cy, glowR * 0.3, region.cx, region.cy, glowR);
|
|
617
|
+
grad.addColorStop(0, hexAlpha(region.color, 0.12));
|
|
618
|
+
grad.addColorStop(1, hexAlpha(region.color, 0));
|
|
619
|
+
ctx.fillStyle = grad;
|
|
620
|
+
ctx.beginPath();
|
|
621
|
+
ctx.arc(region.cx, region.cy, glowR, 0, Math.PI * 2);
|
|
622
|
+
ctx.fill();
|
|
623
|
+
ctx.restore();
|
|
624
|
+
|
|
625
|
+
let cursorY = region.cy; // tracks vertical stacking position
|
|
626
|
+
|
|
627
|
+
if (hasLogo) {
|
|
628
|
+
// Logo with its own zoom compensation (independent of text zoomBoost)
|
|
629
|
+
// Logos are the primary identifier so they need a higher cap and their own min screen size
|
|
630
|
+
const BASE_LOGO_H = 64 * mul;
|
|
631
|
+
const MIN_LOGO_SCREEN = 32; // minimum screen pixels for parent logo
|
|
632
|
+
const logoScreenH = BASE_LOGO_H * _viewport.scale / _dpr;
|
|
633
|
+
const logoBoost = logoScreenH < MIN_LOGO_SCREEN
|
|
634
|
+
? Math.min(MIN_LOGO_SCREEN / logoScreenH, 5.0)
|
|
635
|
+
: 1;
|
|
636
|
+
const logoH = Math.round(BASE_LOGO_H * logoBoost);
|
|
637
|
+
const aspect = (logoImg.naturalWidth || 1) / (logoImg.naturalHeight || 1);
|
|
638
|
+
const logoW = Math.round(logoH * aspect);
|
|
639
|
+
const logoY = region.cy - logoH / 2;
|
|
640
|
+
ctx.save();
|
|
641
|
+
ctx.globalAlpha = 0.92;
|
|
642
|
+
ctx.drawImage(logoImg,
|
|
643
|
+
region.cx - logoW / 2, logoY,
|
|
644
|
+
logoW, logoH
|
|
645
|
+
);
|
|
646
|
+
ctx.restore();
|
|
647
|
+
cursorY = logoY + logoH + 6;
|
|
648
|
+
} else {
|
|
649
|
+
// No logo — glass pill behind text
|
|
650
|
+
ctx.font = `bold ${fontSize}px 'Space Grotesk', 'Inter', sans-serif`;
|
|
651
|
+
ctx.textAlign = 'center';
|
|
652
|
+
ctx.textBaseline = 'middle';
|
|
653
|
+
|
|
654
|
+
// Measure text to size the glass pill
|
|
655
|
+
const textW = ctx.measureText(nameText).width;
|
|
656
|
+
const padX = fontSize * 0.6;
|
|
657
|
+
const padY = fontSize * 0.4;
|
|
658
|
+
|
|
659
|
+
// Memory count text (compute now so pill can encompass both)
|
|
660
|
+
const count = region.memories ? region.memories.length : 0;
|
|
661
|
+
const childCount = (region.children || []).reduce((sum, c) => sum + (c.memories ? c.memories.length : 0), 0);
|
|
662
|
+
const total = count + childCount;
|
|
663
|
+
const subSize = Math.round(fontSize * 0.45);
|
|
664
|
+
const countText = total > 0 ? `${total} ${total === 1 ? 'memory' : 'memories'}` : '';
|
|
665
|
+
const countH = total > 0 ? subSize + padY * 0.5 : 0;
|
|
666
|
+
|
|
667
|
+
const pillW = textW + padX * 2;
|
|
668
|
+
const pillH = fontSize + padY * 2 + countH;
|
|
669
|
+
const pillX = region.cx - pillW / 2;
|
|
670
|
+
const pillY = cursorY - fontSize / 2 - padY;
|
|
671
|
+
const pillR = Math.min(14, pillH / 2);
|
|
672
|
+
|
|
673
|
+
// Glass pill — diffuse color-tinted glassmorphic
|
|
674
|
+
ctx.save();
|
|
675
|
+
const col = region.color;
|
|
676
|
+
|
|
677
|
+
// Colored diffuse glow behind pill
|
|
678
|
+
ctx.shadowColor = hexAlpha(col, 0.3);
|
|
679
|
+
ctx.shadowBlur = 44;
|
|
680
|
+
_roundRect(ctx, pillX, pillY, pillW, pillH, pillR);
|
|
681
|
+
ctx.fillStyle = 'rgba(4, 5, 8, 0.92)';
|
|
682
|
+
ctx.fill();
|
|
683
|
+
ctx.shadowColor = 'transparent';
|
|
684
|
+
ctx.shadowBlur = 0;
|
|
685
|
+
|
|
686
|
+
// Color-tinted inner wash
|
|
687
|
+
_roundRect(ctx, pillX, pillY, pillW, pillH, pillR);
|
|
688
|
+
ctx.fillStyle = hexAlpha(col, 0.1);
|
|
689
|
+
ctx.fill();
|
|
690
|
+
|
|
691
|
+
// Top highlight edge
|
|
692
|
+
const hlGrad = ctx.createLinearGradient(pillX, pillY, pillX, pillY + pillH * 0.35);
|
|
693
|
+
hlGrad.addColorStop(0, 'rgba(255, 255, 255, 0.06)');
|
|
694
|
+
hlGrad.addColorStop(1, 'rgba(255, 255, 255, 0)');
|
|
695
|
+
_roundRect(ctx, pillX, pillY, pillW, pillH * 0.35, pillR);
|
|
696
|
+
ctx.fillStyle = hlGrad;
|
|
697
|
+
ctx.fill();
|
|
698
|
+
|
|
699
|
+
// Color-tinted border
|
|
700
|
+
_roundRect(ctx, pillX, pillY, pillW, pillH, pillR);
|
|
701
|
+
ctx.strokeStyle = hexAlpha(col, 0.2);
|
|
702
|
+
ctx.lineWidth = 1;
|
|
703
|
+
ctx.stroke();
|
|
704
|
+
|
|
705
|
+
ctx.restore();
|
|
706
|
+
|
|
707
|
+
// Draw name text
|
|
708
|
+
ctx.font = `bold ${fontSize}px 'Space Grotesk', 'Inter', sans-serif`;
|
|
709
|
+
ctx.textAlign = 'center';
|
|
710
|
+
ctx.textBaseline = 'middle';
|
|
711
|
+
ctx.fillStyle = region.color;
|
|
712
|
+
ctx.fillText(nameText, region.cx, cursorY);
|
|
713
|
+
cursorY += fontSize * 0.5 + 4;
|
|
714
|
+
|
|
715
|
+
// Memory count inside the pill
|
|
716
|
+
if (total > 0) {
|
|
717
|
+
ctx.font = `500 ${subSize}px 'Inter', sans-serif`;
|
|
718
|
+
ctx.fillStyle = hexAlpha(region.color, 0.5);
|
|
719
|
+
ctx.fillText(countText, region.cx, cursorY + subSize * 0.7);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// Memory count below (only for logo path — text path handles it inside the pill)
|
|
724
|
+
if (hasLogo) {
|
|
725
|
+
const count = region.memories ? region.memories.length : 0;
|
|
726
|
+
const childCount = (region.children || []).reduce((sum, c) => sum + (c.memories ? c.memories.length : 0), 0);
|
|
727
|
+
const total = count + childCount;
|
|
728
|
+
if (total > 0) {
|
|
729
|
+
const fontSize2 = Math.round(38 * mul * zoomBoost);
|
|
730
|
+
const subSize = Math.round(fontSize2 * 0.45);
|
|
731
|
+
ctx.font = `500 ${subSize}px 'Inter', sans-serif`;
|
|
732
|
+
ctx.fillStyle = hexAlpha(region.color, 0.5);
|
|
733
|
+
ctx.fillText(`${total} ${total === 1 ? 'memory' : 'memories'}`, region.cx, cursorY + subSize * 0.7);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
} else {
|
|
738
|
+
// ── CHILD: smaller, simpler ──
|
|
739
|
+
const fontSize = Math.round(22 * mul * zoomBoost);
|
|
740
|
+
const nameText = region.name.toUpperCase();
|
|
741
|
+
|
|
742
|
+
let cursorY = region.cy;
|
|
743
|
+
|
|
744
|
+
if (hasLogo) {
|
|
745
|
+
// Logo with its own zoom compensation (independent of text zoomBoost)
|
|
746
|
+
const BASE_LOGO_H = 32 * mul;
|
|
747
|
+
const MIN_LOGO_SCREEN = 20; // minimum screen pixels for child logo
|
|
748
|
+
const logoScreenH = BASE_LOGO_H * _viewport.scale / _dpr;
|
|
749
|
+
const logoBoost = logoScreenH < MIN_LOGO_SCREEN
|
|
750
|
+
? Math.min(MIN_LOGO_SCREEN / logoScreenH, 4.0)
|
|
751
|
+
: 1;
|
|
752
|
+
const logoH = Math.round(BASE_LOGO_H * logoBoost);
|
|
753
|
+
const aspect = (logoImg.naturalWidth || 1) / (logoImg.naturalHeight || 1);
|
|
754
|
+
const logoW = Math.round(logoH * aspect);
|
|
755
|
+
const logoY = region.cy - logoH / 2;
|
|
756
|
+
ctx.save();
|
|
757
|
+
ctx.globalAlpha = 0.75;
|
|
758
|
+
ctx.drawImage(logoImg,
|
|
759
|
+
region.cx - logoW / 2, logoY,
|
|
760
|
+
logoW, logoH
|
|
761
|
+
);
|
|
762
|
+
ctx.restore();
|
|
763
|
+
cursorY = logoY + logoH + 4;
|
|
764
|
+
} else {
|
|
765
|
+
// No logo — glass pill behind text
|
|
766
|
+
ctx.font = `600 ${fontSize}px 'Space Grotesk', 'Inter', sans-serif`;
|
|
767
|
+
ctx.textAlign = 'center';
|
|
768
|
+
ctx.textBaseline = 'middle';
|
|
769
|
+
|
|
770
|
+
const textW = ctx.measureText(nameText).width;
|
|
771
|
+
const padX = fontSize * 0.5;
|
|
772
|
+
const padY = fontSize * 0.35;
|
|
773
|
+
|
|
774
|
+
// Count text
|
|
775
|
+
const count = region.memories ? region.memories.length : 0;
|
|
776
|
+
const subSize = Math.round(fontSize * 0.5);
|
|
777
|
+
const countH = count > 0 ? subSize + padY * 0.4 : 0;
|
|
778
|
+
|
|
779
|
+
const pillW = textW + padX * 2;
|
|
780
|
+
const pillH = fontSize + padY * 2 + countH;
|
|
781
|
+
const pillX = region.cx - pillW / 2;
|
|
782
|
+
const pillY = cursorY - fontSize / 2 - padY;
|
|
783
|
+
const pillR = Math.min(10, pillH / 2);
|
|
784
|
+
|
|
785
|
+
// Glass pill — diffuse color-tinted glassmorphic
|
|
786
|
+
ctx.save();
|
|
787
|
+
const col = region.color;
|
|
788
|
+
|
|
789
|
+
// Colored diffuse glow
|
|
790
|
+
ctx.shadowColor = hexAlpha(col, 0.25);
|
|
791
|
+
ctx.shadowBlur = 30;
|
|
792
|
+
_roundRect(ctx, pillX, pillY, pillW, pillH, pillR);
|
|
793
|
+
ctx.fillStyle = 'rgba(4, 5, 8, 0.88)';
|
|
794
|
+
ctx.fill();
|
|
795
|
+
ctx.shadowColor = 'transparent';
|
|
796
|
+
ctx.shadowBlur = 0;
|
|
797
|
+
|
|
798
|
+
// Color-tinted inner wash
|
|
799
|
+
_roundRect(ctx, pillX, pillY, pillW, pillH, pillR);
|
|
800
|
+
ctx.fillStyle = hexAlpha(col, 0.08);
|
|
801
|
+
ctx.fill();
|
|
802
|
+
|
|
803
|
+
// Color-tinted border
|
|
804
|
+
_roundRect(ctx, pillX, pillY, pillW, pillH, pillR);
|
|
805
|
+
ctx.strokeStyle = hexAlpha(col, 0.18);
|
|
806
|
+
ctx.lineWidth = 1;
|
|
807
|
+
ctx.stroke();
|
|
808
|
+
ctx.restore();
|
|
809
|
+
|
|
810
|
+
// Name text
|
|
811
|
+
ctx.font = `600 ${fontSize}px 'Space Grotesk', 'Inter', sans-serif`;
|
|
812
|
+
ctx.textAlign = 'center';
|
|
813
|
+
ctx.textBaseline = 'middle';
|
|
814
|
+
ctx.fillStyle = hexAlpha(region.color, 0.8);
|
|
815
|
+
ctx.fillText(nameText, region.cx, cursorY);
|
|
816
|
+
cursorY += fontSize * 0.5 + 4;
|
|
817
|
+
|
|
818
|
+
// Count inside pill
|
|
819
|
+
if (count > 0) {
|
|
820
|
+
ctx.font = `500 ${subSize}px 'Inter', sans-serif`;
|
|
821
|
+
ctx.fillStyle = hexAlpha(region.color, 0.4);
|
|
822
|
+
ctx.fillText(`${count}`, region.cx, cursorY + subSize * 0.6);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// Memory count (only for logo path)
|
|
827
|
+
if (hasLogo) {
|
|
828
|
+
const count = region.memories ? region.memories.length : 0;
|
|
829
|
+
if (count > 0) {
|
|
830
|
+
const subSize = Math.round(fontSize * 0.5);
|
|
831
|
+
ctx.font = `500 ${subSize}px 'Inter', sans-serif`;
|
|
832
|
+
ctx.fillStyle = hexAlpha(region.color, 0.4);
|
|
833
|
+
ctx.fillText(`${count}`, region.cx, cursorY + subSize * 0.6);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
if (needsOpacity) ctx.restore();
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
// Pre-computed card background fill style (used by LOD 0, 1, and 2 drawing functions)
|
|
843
|
+
const _cardBgFill = `rgba(15, 18, 25, ${gfx.cardOpacity})`;
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
// ═══════════════════════════════════════════
|
|
847
|
+
// DRAWING: LOD 2 — Dots (zoomed far out)
|
|
848
|
+
// ═══════════════════════════════════════════
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Draw all visible cards as tiny colored dots, batched by color.
|
|
852
|
+
* At LOD 2, cards are ~2px circles — no text, no shadows, no borders.
|
|
853
|
+
* Groups by category color for minimal state changes (one fillStyle + fill per color).
|
|
854
|
+
*/
|
|
855
|
+
function _drawCardDots(ctx, vb) {
|
|
856
|
+
const hasSearch = state.searchResults !== null;
|
|
857
|
+
// Group visible cards by color
|
|
858
|
+
const byColor = new Map();
|
|
859
|
+
for (const card of _cards) {
|
|
860
|
+
if (card.x < vb.left || card.x > vb.right ||
|
|
861
|
+
card.y < vb.top || card.y > vb.bottom) continue;
|
|
862
|
+
// Skip non-matching cards during search
|
|
863
|
+
if (hasSearch && !state.searchResults.has(card.node.id)) continue;
|
|
864
|
+
const color = catColor(card.node.payload?.category || '');
|
|
865
|
+
let list = byColor.get(color);
|
|
866
|
+
if (!list) { list = []; byColor.set(color, list); }
|
|
867
|
+
list.push(card);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
const TWO_PI = Math.PI * 2;
|
|
871
|
+
for (const [color, cards] of byColor) {
|
|
872
|
+
ctx.fillStyle = color;
|
|
873
|
+
ctx.beginPath();
|
|
874
|
+
for (const card of cards) {
|
|
875
|
+
const dotR = hasSearch && state.searchResults.has(card.node.id) ? 5 : 3;
|
|
876
|
+
ctx.moveTo(card.x + dotR, card.y);
|
|
877
|
+
ctx.arc(card.x, card.y, dotR, 0, TWO_PI);
|
|
878
|
+
}
|
|
879
|
+
ctx.fill();
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
// ═══════════════════════════════════════════
|
|
885
|
+
// DRAWING: LOD 1 — Simple Rects (medium zoom)
|
|
886
|
+
// ═══════════════════════════════════════════
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Draw visible cards as simple colored rectangles — no text, no shadows, no font rendering.
|
|
890
|
+
* Much faster than full cards but still shows shape and color coding.
|
|
891
|
+
*/
|
|
892
|
+
function _drawCardSimple(ctx, vb) {
|
|
893
|
+
const halfW = CARD_W / 2;
|
|
894
|
+
const halfH = CARD_H / 2;
|
|
895
|
+
const selectedId = state.selectedNodeId;
|
|
896
|
+
const hasSearch = state.searchResults !== null;
|
|
897
|
+
|
|
898
|
+
for (const card of _cards) {
|
|
899
|
+
if (card.x + halfW < vb.left || card.x - halfW > vb.right ||
|
|
900
|
+
card.y + halfH < vb.top || card.y - halfH > vb.bottom) continue;
|
|
901
|
+
// Skip non-matching cards during search
|
|
902
|
+
if (hasSearch && !state.searchResults.has(card.node.id)) continue;
|
|
903
|
+
|
|
904
|
+
const isMatch = hasSearch && state.searchResults.has(card.node.id);
|
|
905
|
+
const scale = isMatch ? 1.3 : 1;
|
|
906
|
+
const w = CARD_W * scale;
|
|
907
|
+
const h = CARD_H * scale;
|
|
908
|
+
const x = card.x - w / 2;
|
|
909
|
+
const y = card.y - h / 2;
|
|
910
|
+
const color = catColor(card.node.payload?.category || '');
|
|
911
|
+
|
|
912
|
+
// Card background
|
|
913
|
+
ctx.fillStyle = _cardBgFill;
|
|
914
|
+
ctx.fillRect(x, y, w, h);
|
|
915
|
+
|
|
916
|
+
// Left color bar (thicker at this LOD for visibility)
|
|
917
|
+
ctx.fillStyle = color;
|
|
918
|
+
ctx.fillRect(x, y, 4, h);
|
|
919
|
+
|
|
920
|
+
// Selection or search highlight
|
|
921
|
+
if (card.node.id === selectedId || isMatch) {
|
|
922
|
+
ctx.strokeStyle = color;
|
|
923
|
+
ctx.lineWidth = isMatch ? 1.5 : 2;
|
|
924
|
+
ctx.strokeRect(x, y, w, h);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
// ═══════════════════════════════════════════
|
|
931
|
+
// DRAWING: LOD 0 — Full Detail Cards
|
|
932
|
+
// ═══════════════════════════════════════════
|
|
933
|
+
|
|
934
|
+
function _drawCard(ctx, card) {
|
|
935
|
+
const node = card.node;
|
|
936
|
+
const cat = node.payload?.category || '';
|
|
937
|
+
const color = catColor(cat);
|
|
938
|
+
const importance = node.payload?.importance || 5;
|
|
939
|
+
const content = node.payload?.content || '';
|
|
940
|
+
const isSelected = node.id === state.selectedNodeId;
|
|
941
|
+
const isHovered = node.id === state.hoveredNodeId;
|
|
942
|
+
const isMultiSelected = state.multiSelected.has(node.id);
|
|
943
|
+
|
|
944
|
+
// Opacity for search/focus dimming — use pre-built neighbor map (O(1) lookup)
|
|
945
|
+
let opacity = 1;
|
|
946
|
+
const isSearchMatch = state.searchResults && state.searchResults.has(node.id);
|
|
947
|
+
const isSearchMiss = state.searchResults && !isSearchMatch;
|
|
948
|
+
if (isSearchMiss) return; // Vanish non-matching memories during search
|
|
949
|
+
if (isSearchMatch) opacity = 1; // Full brightness for matches
|
|
950
|
+
if (state.focusedNodeId && state.focusedNodeId !== node.id) {
|
|
951
|
+
const neighbors = _neighborMap.get(state.focusedNodeId);
|
|
952
|
+
if (neighbors && neighbors.has(node.id)) opacity = 0.7;
|
|
953
|
+
else opacity = 0.15;
|
|
954
|
+
}
|
|
955
|
+
if (opacity < 0.05) return;
|
|
956
|
+
|
|
957
|
+
// Search matches get scaled up
|
|
958
|
+
const searchScale = isSearchMatch ? 1.3 : 1;
|
|
959
|
+
const scaledW = CARD_W * searchScale;
|
|
960
|
+
const scaledH = CARD_H * searchScale;
|
|
961
|
+
const x = card.x - scaledW / 2;
|
|
962
|
+
const y = card.y - scaledH / 2;
|
|
963
|
+
const needsShadow = isHovered || isSelected || isMultiSelected || isSearchMatch;
|
|
964
|
+
|
|
965
|
+
// Only save/restore when we actually change global state
|
|
966
|
+
if (opacity < 1 || needsShadow) {
|
|
967
|
+
ctx.save();
|
|
968
|
+
ctx.globalAlpha = opacity;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// ── Hover glow (shadow) ──
|
|
972
|
+
if (isSearchMatch && !isHovered && !isSelected) {
|
|
973
|
+
ctx.shadowColor = hexAlpha(color, 0.7);
|
|
974
|
+
ctx.shadowBlur = 14;
|
|
975
|
+
} else if (needsShadow) {
|
|
976
|
+
ctx.shadowColor = isSelected ? color : hexAlpha(color, 0.6);
|
|
977
|
+
ctx.shadowBlur = isSelected ? 16 : 10;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// ── Card background ──
|
|
981
|
+
_roundRect(ctx, x, y, scaledW, scaledH, 8);
|
|
982
|
+
ctx.fillStyle = _cardBgFill;
|
|
983
|
+
ctx.fill();
|
|
984
|
+
|
|
985
|
+
// Reset shadow after fill (only if set)
|
|
986
|
+
if (needsShadow) {
|
|
987
|
+
ctx.shadowColor = 'transparent';
|
|
988
|
+
ctx.shadowBlur = 0;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
// ── Selection/hover border ──
|
|
992
|
+
if (isSelected || isMultiSelected) {
|
|
993
|
+
_roundRect(ctx, x, y, scaledW, scaledH, 8);
|
|
994
|
+
ctx.strokeStyle = color;
|
|
995
|
+
ctx.lineWidth = 1.5;
|
|
996
|
+
ctx.stroke();
|
|
997
|
+
} else if (isHovered) {
|
|
998
|
+
_roundRect(ctx, x, y, scaledW, scaledH, 8);
|
|
999
|
+
ctx.strokeStyle = hexAlpha(color, 0.4);
|
|
1000
|
+
ctx.lineWidth = 1;
|
|
1001
|
+
ctx.stroke();
|
|
1002
|
+
} else if (isSearchMatch) {
|
|
1003
|
+
_roundRect(ctx, x, y, scaledW, scaledH, 8);
|
|
1004
|
+
ctx.strokeStyle = hexAlpha(color, 0.5);
|
|
1005
|
+
ctx.lineWidth = 1;
|
|
1006
|
+
ctx.stroke();
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// ── Left color bar (simplified — no clip needed for 3px bar) ──
|
|
1010
|
+
ctx.fillStyle = color;
|
|
1011
|
+
ctx.fillRect(x, y + 8, 3, scaledH - 16);
|
|
1012
|
+
|
|
1013
|
+
// ── Category label ──
|
|
1014
|
+
ctx.font = "bold 8px 'Inter', sans-serif";
|
|
1015
|
+
ctx.fillStyle = color;
|
|
1016
|
+
ctx.textAlign = 'left';
|
|
1017
|
+
ctx.textBaseline = 'top';
|
|
1018
|
+
ctx.fillText(cat.toUpperCase(), x + 8, y + 6);
|
|
1019
|
+
|
|
1020
|
+
// ── Content preview (cached text wrapping) ──
|
|
1021
|
+
ctx.font = "10px 'Inter', sans-serif";
|
|
1022
|
+
ctx.fillStyle = 'rgba(200, 206, 220, 0.85)';
|
|
1023
|
+
const lines = _getWrappedText(ctx, node.id, content, scaledW - 16, 3);
|
|
1024
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1025
|
+
ctx.fillText(lines[i], x + 8, y + 20 + i * 13);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// ── Importance stars ──
|
|
1029
|
+
if (importance > 0) {
|
|
1030
|
+
ctx.font = "8px 'Inter', sans-serif";
|
|
1031
|
+
ctx.fillStyle = 'rgba(255, 200, 50, 0.6)';
|
|
1032
|
+
ctx.textAlign = 'right';
|
|
1033
|
+
ctx.textBaseline = 'bottom';
|
|
1034
|
+
const stars = importance <= 5 ? '\u2606'.repeat(importance) : '\u2605'.repeat(Math.min(importance, 10));
|
|
1035
|
+
ctx.fillText(stars, x + scaledW - 6, y + scaledH - 4);
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// ── Pin indicator ──
|
|
1039
|
+
if (card.pinned) {
|
|
1040
|
+
ctx.font = "9px sans-serif";
|
|
1041
|
+
ctx.fillStyle = 'rgba(255,255,255,0.3)';
|
|
1042
|
+
ctx.textAlign = 'right';
|
|
1043
|
+
ctx.textBaseline = 'top';
|
|
1044
|
+
ctx.fillText('\uD83D\uDCCC', x + scaledW - 4, y + 4);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
if (opacity < 1 || needsShadow) {
|
|
1048
|
+
ctx.restore();
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* Get cached wrapped text lines for a card.
|
|
1054
|
+
* Only re-wraps when content changes.
|
|
1055
|
+
*/
|
|
1056
|
+
function _getWrappedText(ctx, nodeId, content, maxWidth, maxLines) {
|
|
1057
|
+
const cached = _textCache.get(nodeId);
|
|
1058
|
+
if (cached && cached.content === content) return cached.lines;
|
|
1059
|
+
const lines = _wrapText(ctx, content, maxWidth, maxLines);
|
|
1060
|
+
_textCache.set(nodeId, { content, lines });
|
|
1061
|
+
return lines;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
// ═══════════════════════════════════════════
|
|
1066
|
+
// DRAWING: Links
|
|
1067
|
+
// ═══════════════════════════════════════════
|
|
1068
|
+
|
|
1069
|
+
function _drawLinks(ctx, vb, lod) {
|
|
1070
|
+
// LOD 1: only draw strong links (strength >= 0.4), reduced opacity
|
|
1071
|
+
const links = lod >= 1 ? _resolvedLinksStrong : _resolvedLinks;
|
|
1072
|
+
const opacity = lod >= 1 ? gfx.linkOpacity * 0.5 : gfx.linkOpacity;
|
|
1073
|
+
ctx.strokeStyle = `rgba(100, 140, 200, ${opacity})`;
|
|
1074
|
+
ctx.lineWidth = 0.5;
|
|
1075
|
+
|
|
1076
|
+
ctx.beginPath();
|
|
1077
|
+
const isIntra = state.linkMode === 'intra';
|
|
1078
|
+
const hasSearch = state.searchResults !== null;
|
|
1079
|
+
|
|
1080
|
+
for (let i = 0, len = links.length; i < len; i++) {
|
|
1081
|
+
const link = links[i];
|
|
1082
|
+
const sc = link.sourceCard;
|
|
1083
|
+
const tc = link.targetCard;
|
|
1084
|
+
|
|
1085
|
+
// Viewport cull: skip if both endpoints are off-screen
|
|
1086
|
+
const sx = sc.x, sy = sc.y, tx = tc.x, ty = tc.y;
|
|
1087
|
+
if ((sx < vb.left && tx < vb.left) || (sx > vb.right && tx > vb.right) ||
|
|
1088
|
+
(sy < vb.top && ty < vb.top) || (sy > vb.bottom && ty > vb.bottom)) continue;
|
|
1089
|
+
|
|
1090
|
+
// Filter by link mode
|
|
1091
|
+
if (isIntra && link.crossCat) continue;
|
|
1092
|
+
|
|
1093
|
+
// Hide links where both endpoints are not search matches
|
|
1094
|
+
if (hasSearch && !state.searchResults.has(sc.node.id) && !state.searchResults.has(tc.node.id)) continue;
|
|
1095
|
+
|
|
1096
|
+
ctx.moveTo(sx, sy);
|
|
1097
|
+
ctx.lineTo(tx, ty);
|
|
1098
|
+
}
|
|
1099
|
+
ctx.stroke();
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
// ═══════════════════════════════════════════
|
|
1104
|
+
// DRAWING HELPERS
|
|
1105
|
+
// ═══════════════════════════════════════════
|
|
1106
|
+
|
|
1107
|
+
function _roundRect(ctx, x, y, w, h, r) {
|
|
1108
|
+
ctx.beginPath();
|
|
1109
|
+
ctx.moveTo(x + r, y);
|
|
1110
|
+
ctx.lineTo(x + w - r, y);
|
|
1111
|
+
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
|
|
1112
|
+
ctx.lineTo(x + w, y + h - r);
|
|
1113
|
+
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
|
|
1114
|
+
ctx.lineTo(x + r, y + h);
|
|
1115
|
+
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
|
|
1116
|
+
ctx.lineTo(x, y + r);
|
|
1117
|
+
ctx.quadraticCurveTo(x, y, x + r, y);
|
|
1118
|
+
ctx.closePath();
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
function _wrapText(ctx, text, maxWidth, maxLines) {
|
|
1122
|
+
const words = (text || '').replace(/\n/g, ' ').split(' ');
|
|
1123
|
+
const lines = [];
|
|
1124
|
+
let line = '';
|
|
1125
|
+
for (const word of words) {
|
|
1126
|
+
const test = line + (line ? ' ' : '') + word;
|
|
1127
|
+
if (ctx.measureText(test).width > maxWidth && line) {
|
|
1128
|
+
lines.push(line);
|
|
1129
|
+
if (lines.length >= maxLines) {
|
|
1130
|
+
lines[lines.length - 1] = lines[lines.length - 1].replace(/...$/, '') + '\u2026';
|
|
1131
|
+
return lines;
|
|
1132
|
+
}
|
|
1133
|
+
line = word;
|
|
1134
|
+
} else {
|
|
1135
|
+
line = test;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
if (line) {
|
|
1139
|
+
if (lines.length >= maxLines) {
|
|
1140
|
+
lines[lines.length - 1] += '\u2026';
|
|
1141
|
+
} else {
|
|
1142
|
+
lines.push(line);
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
return lines;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
|
|
1149
|
+
// ═══════════════════════════════════════════
|
|
1150
|
+
// HIT DETECTION
|
|
1151
|
+
// ═══════════════════════════════════════════
|
|
1152
|
+
|
|
1153
|
+
function _hitTest(screenX, screenY) {
|
|
1154
|
+
const { x, y } = screenToWorld(screenX, screenY);
|
|
1155
|
+
|
|
1156
|
+
// Check cards (reverse order = topmost first)
|
|
1157
|
+
for (let i = _cards.length - 1; i >= 0; i--) {
|
|
1158
|
+
const card = _cards[i];
|
|
1159
|
+
if (x >= card.x - CARD_W / 2 && x <= card.x + CARD_W / 2 &&
|
|
1160
|
+
y >= card.y - CARD_H / 2 && y <= card.y + CARD_H / 2) {
|
|
1161
|
+
return { type: 'card', item: card, node: card.node };
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
// Check category labels — hit zone scales with label size + zoom compensation
|
|
1166
|
+
const allRegions = flattenRegions(_regions);
|
|
1167
|
+
const mul = state.labelSizeMultiplier || 1;
|
|
1168
|
+
for (const region of allRegions) {
|
|
1169
|
+
if (!state.labelsVisible) {
|
|
1170
|
+
// Labels hidden — small dot hit zone so categories are still clickable
|
|
1171
|
+
if (x >= region.cx - 30 && x <= region.cx + 30 &&
|
|
1172
|
+
y >= region.cy - 30 && y <= region.cy + 30) {
|
|
1173
|
+
return { type: 'region', item: region };
|
|
1174
|
+
}
|
|
1175
|
+
} else {
|
|
1176
|
+
// Compute zoom compensation to match rendered size (capped, same as _drawCategoryLabel)
|
|
1177
|
+
const MAX_ZOOM_BOOST = region.isParent ? 2.5 : 2.0;
|
|
1178
|
+
const baseFontSize = region.isParent ? 38 : 22;
|
|
1179
|
+
const MIN_SCREEN_PX = region.isParent ? 18 : 13;
|
|
1180
|
+
const rawFontSize = baseFontSize * mul;
|
|
1181
|
+
const screenPx = rawFontSize * _viewport.scale / _dpr;
|
|
1182
|
+
const zoomBoost = screenPx < MIN_SCREEN_PX
|
|
1183
|
+
? Math.min(MIN_SCREEN_PX / screenPx, MAX_ZOOM_BOOST)
|
|
1184
|
+
: 1;
|
|
1185
|
+
|
|
1186
|
+
const fontSize = Math.round(baseFontSize * mul * zoomBoost);
|
|
1187
|
+
const hasLogo = _categoryLogos.get(region.name)?.ready || (region.name === 'openclaw' && _openclawLogoReady);
|
|
1188
|
+
|
|
1189
|
+
// Hit zone: logo width or text width + padding
|
|
1190
|
+
let labelW, labelH;
|
|
1191
|
+
if (hasLogo) {
|
|
1192
|
+
// Logo has its own zoom compensation (same as _drawCategoryLabel)
|
|
1193
|
+
const baseLogo = (region.isParent ? 64 : 32) * mul;
|
|
1194
|
+
const minLogoScreen = region.isParent ? 32 : 20;
|
|
1195
|
+
const logoScreen = baseLogo * _viewport.scale / _dpr;
|
|
1196
|
+
const logoBoost = logoScreen < minLogoScreen
|
|
1197
|
+
? Math.min(minLogoScreen / logoScreen, region.isParent ? 5.0 : 4.0)
|
|
1198
|
+
: 1;
|
|
1199
|
+
const logoH = baseLogo * logoBoost;
|
|
1200
|
+
const logoW = logoH * 3; // conservative aspect estimate
|
|
1201
|
+
labelW = Math.max(logoW, 160) + 20;
|
|
1202
|
+
labelH = logoH + fontSize * 0.5 + 30;
|
|
1203
|
+
} else {
|
|
1204
|
+
// Match glass pill sizing: text width + padX on each side, fontSize + padY*2 + count height
|
|
1205
|
+
const nameText = region.name.toUpperCase();
|
|
1206
|
+
const approxTextW = fontSize * 0.65 * nameText.length;
|
|
1207
|
+
const padX = fontSize * (region.isParent ? 0.6 : 0.5);
|
|
1208
|
+
const padY = fontSize * (region.isParent ? 0.4 : 0.35);
|
|
1209
|
+
const countH = fontSize * 0.5; // always include count space for hit zone
|
|
1210
|
+
labelW = approxTextW + padX * 2 + 20; // extra margin for easier clicking
|
|
1211
|
+
labelH = fontSize + padY * 2 + countH + 20;
|
|
1212
|
+
}
|
|
1213
|
+
if (x >= region.cx - labelW / 2 && x <= region.cx + labelW / 2 &&
|
|
1214
|
+
y >= region.cy - labelH / 2 && y <= region.cy + labelH / 2) {
|
|
1215
|
+
return { type: 'region', item: region };
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
return null;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
// ═══════════════════════════════════════════
|
|
1225
|
+
// DRAG SYSTEM
|
|
1226
|
+
// ═══════════════════════════════════════════
|
|
1227
|
+
|
|
1228
|
+
function _buildDragSet(hit) {
|
|
1229
|
+
const set = [];
|
|
1230
|
+
|
|
1231
|
+
if (hit.type === 'card') {
|
|
1232
|
+
// If this card is part of a multi-selection, drag ALL selected cards
|
|
1233
|
+
if (state.multiSelected.size > 0 && state.multiSelected.has(hit.node.id)) {
|
|
1234
|
+
for (const card of _cards) {
|
|
1235
|
+
if (state.multiSelected.has(card.node.id)) {
|
|
1236
|
+
set.push({ type: 'card', ref: card });
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
} else {
|
|
1240
|
+
// Just this card
|
|
1241
|
+
set.push({ type: 'card', ref: hit.item });
|
|
1242
|
+
}
|
|
1243
|
+
} else if (hit.type === 'region') {
|
|
1244
|
+
const region = hit.item;
|
|
1245
|
+
// The region label itself
|
|
1246
|
+
set.push({ type: 'region', ref: region });
|
|
1247
|
+
|
|
1248
|
+
// All cards directly on this region
|
|
1249
|
+
for (const card of _cards) {
|
|
1250
|
+
const cat = card.node.payload?.category;
|
|
1251
|
+
if (cat === region.name) {
|
|
1252
|
+
set.push({ type: 'card', ref: card });
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
// If parent, also include children + their cards
|
|
1257
|
+
if (region.isParent && region.children) {
|
|
1258
|
+
for (const child of region.children) {
|
|
1259
|
+
set.push({ type: 'region', ref: child });
|
|
1260
|
+
for (const card of _cards) {
|
|
1261
|
+
const cat = card.node.payload?.category;
|
|
1262
|
+
if (cat === child.name) {
|
|
1263
|
+
set.push({ type: 'card', ref: card });
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
return set;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
function _applyDragDelta(dx, dy) {
|
|
1274
|
+
for (const item of _pointer.dragSet) {
|
|
1275
|
+
if (item.type === 'card') {
|
|
1276
|
+
item.ref.x += dx;
|
|
1277
|
+
item.ref.y += dy;
|
|
1278
|
+
item.ref.pinned = true;
|
|
1279
|
+
} else if (item.type === 'region') {
|
|
1280
|
+
item.ref.cx += dx;
|
|
1281
|
+
item.ref.cy += dy;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
// ═══════════════════════════════════════════
|
|
1288
|
+
// POSITION PERSISTENCE
|
|
1289
|
+
// ═══════════════════════════════════════════
|
|
1290
|
+
|
|
1291
|
+
function _savePositions() {
|
|
1292
|
+
const positions = {};
|
|
1293
|
+
for (const card of _cards) {
|
|
1294
|
+
positions[card.node.id] = { x: card.x, y: card.y, pinned: card.pinned };
|
|
1295
|
+
}
|
|
1296
|
+
for (const region of flattenRegions(_regions)) {
|
|
1297
|
+
positions[`_cat_${region.name}`] = { x: region.cx, y: region.cy };
|
|
1298
|
+
}
|
|
1299
|
+
try { posStore.setItem(KEYS.NODE_POS_2D, JSON.stringify(positions)); } catch (_) {}
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
function _schedulePositionSave() {
|
|
1303
|
+
if (_posSaveTimer) clearTimeout(_posSaveTimer);
|
|
1304
|
+
_posSaveTimer = setTimeout(_savePositions, 2000);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
|
|
1308
|
+
// ═══════════════════════════════════════════
|
|
1309
|
+
// EVENT HANDLERS
|
|
1310
|
+
// ═══════════════════════════════════════════
|
|
1311
|
+
|
|
1312
|
+
function _onPointerDown(e) {
|
|
1313
|
+
if (_focusPaused || e.button !== 0) return;
|
|
1314
|
+
_lastActivityTime = performance.now();
|
|
1315
|
+
// Skip if Shift (lasso mode handled by lasso.js)
|
|
1316
|
+
if (e.shiftKey) return;
|
|
1317
|
+
|
|
1318
|
+
const hit = _hitTest(e.clientX, e.clientY);
|
|
1319
|
+
|
|
1320
|
+
_pointer.downScreenX = e.clientX;
|
|
1321
|
+
_pointer.downScreenY = e.clientY;
|
|
1322
|
+
_pointer.lastScreenX = e.clientX;
|
|
1323
|
+
_pointer.lastScreenY = e.clientY;
|
|
1324
|
+
_pointer.downTime = performance.now();
|
|
1325
|
+
_pointer.lastMoveTime = performance.now();
|
|
1326
|
+
_pointer.hasMoved = false;
|
|
1327
|
+
_panInertia.active = false; // stop coasting on new interaction
|
|
1328
|
+
|
|
1329
|
+
if (hit) {
|
|
1330
|
+
_pointer.isDragging = true;
|
|
1331
|
+
_pointer.isPanning = false;
|
|
1332
|
+
_pointer.dragTarget = hit;
|
|
1333
|
+
_pointer.dragSet = _buildDragSet(hit);
|
|
1334
|
+
_pointer.dragStartWorld = screenToWorld(e.clientX, e.clientY);
|
|
1335
|
+
_canvas.setPointerCapture(e.pointerId);
|
|
1336
|
+
} else {
|
|
1337
|
+
_pointer.isPanning = true;
|
|
1338
|
+
_pointer.isDragging = false;
|
|
1339
|
+
_pointer.dragTarget = null;
|
|
1340
|
+
_canvas.setPointerCapture(e.pointerId);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
const DRAG_THRESHOLD = 5; // pixels before drag/pan starts
|
|
1345
|
+
|
|
1346
|
+
function _onPointerMove(e) {
|
|
1347
|
+
if (_focusPaused) return;
|
|
1348
|
+
// A window/panel/terminal drag that passes over the canvas is not graph
|
|
1349
|
+
// activity — don't wake the render loop or hover-pick under it.
|
|
1350
|
+
if (document.body.classList.contains('ui-interacting')) return;
|
|
1351
|
+
_lastActivityTime = performance.now();
|
|
1352
|
+
// Check if we've exceeded the drag threshold before actually moving
|
|
1353
|
+
if ((_pointer.isPanning || _pointer.isDragging) && !_pointer.hasMoved) {
|
|
1354
|
+
const tdx = e.clientX - _pointer.downScreenX;
|
|
1355
|
+
const tdy = e.clientY - _pointer.downScreenY;
|
|
1356
|
+
if (Math.abs(tdx) < DRAG_THRESHOLD && Math.abs(tdy) < DRAG_THRESHOLD) return;
|
|
1357
|
+
_pointer.hasMoved = true;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
if (_pointer.isPanning) {
|
|
1361
|
+
const dx = (e.clientX - _pointer.lastScreenX) * _dpr;
|
|
1362
|
+
const dy = (e.clientY - _pointer.lastScreenY) * _dpr;
|
|
1363
|
+
_viewport.offsetX += dx;
|
|
1364
|
+
_viewport.offsetY += dy;
|
|
1365
|
+
// Track velocity for inertia
|
|
1366
|
+
const now = performance.now();
|
|
1367
|
+
const dt = now - _pointer.lastMoveTime || 16;
|
|
1368
|
+
_panInertia.vx = dx / dt * 16; // normalize to ~60fps frame
|
|
1369
|
+
_panInertia.vy = dy / dt * 16;
|
|
1370
|
+
_pointer.lastMoveTime = now;
|
|
1371
|
+
_pointer.lastScreenX = e.clientX;
|
|
1372
|
+
_pointer.lastScreenY = e.clientY;
|
|
1373
|
+
// Kill any active inertia while dragging
|
|
1374
|
+
_panInertia.active = false;
|
|
1375
|
+
} else if (_pointer.isDragging) {
|
|
1376
|
+
const worldNow = screenToWorld(e.clientX, e.clientY);
|
|
1377
|
+
const worldPrev = screenToWorld(_pointer.lastScreenX, _pointer.lastScreenY);
|
|
1378
|
+
const dx = worldNow.x - worldPrev.x;
|
|
1379
|
+
const dy = worldNow.y - worldPrev.y;
|
|
1380
|
+
_applyDragDelta(dx, dy);
|
|
1381
|
+
_pointer.lastScreenX = e.clientX;
|
|
1382
|
+
_pointer.lastScreenY = e.clientY;
|
|
1383
|
+
} else {
|
|
1384
|
+
// Hover detection — _hitTest allocates flattenRegions() + per-region zoom
|
|
1385
|
+
// math, so coalesce to one test per frame (cursor at frame rate is fine).
|
|
1386
|
+
_lastHoverClientX = e.clientX;
|
|
1387
|
+
_lastHoverClientY = e.clientY;
|
|
1388
|
+
_scheduleHover2D();
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
let _lastHoverClientX = 0, _lastHoverClientY = 0;
|
|
1393
|
+
const _scheduleHover2D = rafThrottle(() => {
|
|
1394
|
+
if (_focusPaused || _pointer.isPanning || _pointer.isDragging) return;
|
|
1395
|
+
const hit = _hitTest(_lastHoverClientX, _lastHoverClientY);
|
|
1396
|
+
const newHoverId = (hit && hit.type === 'card') ? hit.node.id : null;
|
|
1397
|
+
if (newHoverId !== state.hoveredNodeId) {
|
|
1398
|
+
state.hoveredNodeId = newHoverId;
|
|
1399
|
+
}
|
|
1400
|
+
_canvas.style.cursor = hit ? 'pointer' : 'grab';
|
|
1401
|
+
if (newHoverId) emit('node-hover', hit.node);
|
|
1402
|
+
else if (!hit) emit('node-hover', null);
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
function _onPointerUp(e) {
|
|
1406
|
+
if (_focusPaused) return;
|
|
1407
|
+
const wasDragging = _pointer.isDragging;
|
|
1408
|
+
const wasPanning = _pointer.isPanning;
|
|
1409
|
+
const moved = _pointer.hasMoved;
|
|
1410
|
+
const elapsed = performance.now() - _pointer.downTime;
|
|
1411
|
+
|
|
1412
|
+
_pointer.isPanning = false;
|
|
1413
|
+
_pointer.isDragging = false;
|
|
1414
|
+
_canvas.releasePointerCapture(e.pointerId);
|
|
1415
|
+
|
|
1416
|
+
// Start pan inertia if we were panning and had velocity
|
|
1417
|
+
if (wasPanning && moved) {
|
|
1418
|
+
const speed = Math.sqrt(_panInertia.vx ** 2 + _panInertia.vy ** 2);
|
|
1419
|
+
if (speed > 0.5) {
|
|
1420
|
+
_panInertia.active = true;
|
|
1421
|
+
}
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
if (wasDragging && moved) {
|
|
1426
|
+
_schedulePositionSave();
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
// Click (no significant movement)
|
|
1431
|
+
if (!moved || elapsed < 200) {
|
|
1432
|
+
const hit = _hitTest(e.clientX, e.clientY);
|
|
1433
|
+
|
|
1434
|
+
if (hit && hit.type === 'card') {
|
|
1435
|
+
// Ctrl/Cmd+Click: toggle multi-select (same as 3D variant)
|
|
1436
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1437
|
+
if (state.multiSelected.has(hit.node.id)) {
|
|
1438
|
+
state.multiSelected.delete(hit.node.id);
|
|
1439
|
+
} else {
|
|
1440
|
+
state.multiSelected.add(hit.node.id);
|
|
1441
|
+
}
|
|
1442
|
+
emit('multiselect:update');
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
// Regular click: clear multi-select, select node
|
|
1446
|
+
if (state.multiSelected.size > 0) {
|
|
1447
|
+
state.multiSelected.clear();
|
|
1448
|
+
emit('multiselect:update');
|
|
1449
|
+
}
|
|
1450
|
+
state.selectedNodeId = hit.node.id;
|
|
1451
|
+
emit('node-selected', hit.node);
|
|
1452
|
+
} else if (hit && hit.type === 'region') {
|
|
1453
|
+
// Zoom to fit this category region
|
|
1454
|
+
_zoomToRegion(hit.item);
|
|
1455
|
+
} else {
|
|
1456
|
+
// Click background — deselect everything
|
|
1457
|
+
if (state.multiSelected.size > 0) {
|
|
1458
|
+
state.multiSelected.clear();
|
|
1459
|
+
emit('multiselect:update');
|
|
1460
|
+
}
|
|
1461
|
+
state.selectedNodeId = null;
|
|
1462
|
+
emit('background-click');
|
|
1463
|
+
emit('node-selected', null);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
function _onPointerLeave() {
|
|
1469
|
+
if (_focusPaused) return;
|
|
1470
|
+
if (state.hoveredNodeId) {
|
|
1471
|
+
state.hoveredNodeId = null;
|
|
1472
|
+
_canvas.style.cursor = 'grab';
|
|
1473
|
+
emit('node-hover', null);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
function _onWheel(e) {
|
|
1478
|
+
if (_focusPaused) return;
|
|
1479
|
+
e.preventDefault();
|
|
1480
|
+
// Accumulate zoom target — each tick multiplies by factor
|
|
1481
|
+
const zoomFactor = e.deltaY > 0 ? 0.88 : 1.12;
|
|
1482
|
+
_smoothZoom.targetScale = Math.max(
|
|
1483
|
+
_viewport.minScale,
|
|
1484
|
+
Math.min(_viewport.maxScale, (_smoothZoom.active ? _smoothZoom.targetScale : _viewport.scale) * zoomFactor)
|
|
1485
|
+
);
|
|
1486
|
+
// Update anchor to cursor position (buffer coords)
|
|
1487
|
+
_smoothZoom.anchorX = e.clientX * _dpr;
|
|
1488
|
+
_smoothZoom.anchorY = e.clientY * _dpr;
|
|
1489
|
+
_smoothZoom.active = true;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
function _onDblClick(e) {
|
|
1493
|
+
if (_focusPaused) return;
|
|
1494
|
+
const hit = _hitTest(e.clientX, e.clientY);
|
|
1495
|
+
if (hit && hit.type === 'card') {
|
|
1496
|
+
// Unpin card
|
|
1497
|
+
hit.item.pinned = false;
|
|
1498
|
+
_schedulePositionSave();
|
|
1499
|
+
} else {
|
|
1500
|
+
// Zoom to fit all
|
|
1501
|
+
_zoomToFit(400, 60);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
function _onContextMenu(e) {
|
|
1506
|
+
if (_focusPaused) { e.preventDefault(); return; }
|
|
1507
|
+
e.preventDefault();
|
|
1508
|
+
const hit = _hitTest(e.clientX, e.clientY);
|
|
1509
|
+
if (hit && hit.type === 'card') {
|
|
1510
|
+
emit('node-context-menu', { node: hit.node, event: e });
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
|
|
1515
|
+
// ═══════════════════════════════════════════
|
|
1516
|
+
// VIEWPORT NAVIGATION
|
|
1517
|
+
// ═══════════════════════════════════════════
|
|
1518
|
+
|
|
1519
|
+
function _centerAt(worldX, worldY, duration = 0) {
|
|
1520
|
+
_lastActivityTime = performance.now();
|
|
1521
|
+
const targetOffsetX = _canvas.width / 2 - worldX * _viewport.scale;
|
|
1522
|
+
const targetOffsetY = _canvas.height / 2 - worldY * _viewport.scale;
|
|
1523
|
+
|
|
1524
|
+
if (duration <= 0) {
|
|
1525
|
+
_viewport.offsetX = targetOffsetX;
|
|
1526
|
+
_viewport.offsetY = targetOffsetY;
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
_animFrom = {
|
|
1531
|
+
offsetX: _viewport.offsetX,
|
|
1532
|
+
offsetY: _viewport.offsetY,
|
|
1533
|
+
scale: _viewport.scale,
|
|
1534
|
+
};
|
|
1535
|
+
_animTo = {
|
|
1536
|
+
offsetX: targetOffsetX,
|
|
1537
|
+
offsetY: targetOffsetY,
|
|
1538
|
+
scale: _viewport.scale,
|
|
1539
|
+
};
|
|
1540
|
+
_animStart = performance.now();
|
|
1541
|
+
_animDuration = duration;
|
|
1542
|
+
_animating = true;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
function _zoomToFit(duration = 400, padding = 60) {
|
|
1546
|
+
if (_cards.length === 0) return;
|
|
1547
|
+
|
|
1548
|
+
let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
|
|
1549
|
+
for (const card of _cards) {
|
|
1550
|
+
if (card.x - CARD_W / 2 < minX) minX = card.x - CARD_W / 2;
|
|
1551
|
+
if (card.x + CARD_W / 2 > maxX) maxX = card.x + CARD_W / 2;
|
|
1552
|
+
if (card.y - CARD_H / 2 < minY) minY = card.y - CARD_H / 2;
|
|
1553
|
+
if (card.y + CARD_H / 2 > maxY) maxY = card.y + CARD_H / 2;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
const rangeX = (maxX - minX) || 1;
|
|
1557
|
+
const rangeY = (maxY - minY) || 1;
|
|
1558
|
+
const centerX = (minX + maxX) / 2;
|
|
1559
|
+
const centerY = (minY + maxY) / 2;
|
|
1560
|
+
|
|
1561
|
+
const scaledPadding = padding * _dpr;
|
|
1562
|
+
const availW = _canvas.width - scaledPadding * 2;
|
|
1563
|
+
const availH = _canvas.height - scaledPadding * 2;
|
|
1564
|
+
const newScale = Math.min(availW / rangeX, availH / rangeY);
|
|
1565
|
+
const clampedScale = Math.max(_viewport.minScale, Math.min(_viewport.maxScale, newScale));
|
|
1566
|
+
|
|
1567
|
+
if (duration <= 0) {
|
|
1568
|
+
_viewport.scale = clampedScale;
|
|
1569
|
+
_viewport.offsetX = _canvas.width / 2 - centerX * clampedScale;
|
|
1570
|
+
_viewport.offsetY = _canvas.height / 2 - centerY * clampedScale;
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
_animFrom = {
|
|
1575
|
+
offsetX: _viewport.offsetX,
|
|
1576
|
+
offsetY: _viewport.offsetY,
|
|
1577
|
+
scale: _viewport.scale,
|
|
1578
|
+
};
|
|
1579
|
+
_animTo = {
|
|
1580
|
+
offsetX: _canvas.width / 2 - centerX * clampedScale,
|
|
1581
|
+
offsetY: _canvas.height / 2 - centerY * clampedScale,
|
|
1582
|
+
scale: clampedScale,
|
|
1583
|
+
};
|
|
1584
|
+
_animStart = performance.now();
|
|
1585
|
+
_animDuration = duration;
|
|
1586
|
+
_animating = true;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
function _zoomToRegion(region, duration = 400) {
|
|
1590
|
+
const padding = 80 * _dpr;
|
|
1591
|
+
const regionR = region.radius || 200;
|
|
1592
|
+
|
|
1593
|
+
const rangeX = regionR * 2;
|
|
1594
|
+
const rangeY = regionR * 2;
|
|
1595
|
+
|
|
1596
|
+
const availW = _canvas.width - padding * 2;
|
|
1597
|
+
const availH = _canvas.height - padding * 2;
|
|
1598
|
+
const newScale = Math.min(availW / rangeX, availH / rangeY);
|
|
1599
|
+
const clampedScale = Math.max(_viewport.minScale, Math.min(_viewport.maxScale, newScale));
|
|
1600
|
+
|
|
1601
|
+
_animFrom = {
|
|
1602
|
+
offsetX: _viewport.offsetX,
|
|
1603
|
+
offsetY: _viewport.offsetY,
|
|
1604
|
+
scale: _viewport.scale,
|
|
1605
|
+
};
|
|
1606
|
+
_animTo = {
|
|
1607
|
+
offsetX: _canvas.width / 2 - region.cx * clampedScale,
|
|
1608
|
+
offsetY: _canvas.height / 2 - region.cy * clampedScale,
|
|
1609
|
+
scale: clampedScale,
|
|
1610
|
+
};
|
|
1611
|
+
_animStart = performance.now();
|
|
1612
|
+
_animDuration = duration;
|
|
1613
|
+
_animating = true;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
// ═══════════════════════════════════════════
|
|
1618
|
+
// RESIZE
|
|
1619
|
+
// ═══════════════════════════════════════════
|
|
1620
|
+
|
|
1621
|
+
function _resizeCanvas() {
|
|
1622
|
+
if (!_canvas) return;
|
|
1623
|
+
_resizePending = false;
|
|
1624
|
+
_dpr = Math.min(window.devicePixelRatio || 1, MAX_DPR);
|
|
1625
|
+
const w = window.innerWidth;
|
|
1626
|
+
const h = window.innerHeight;
|
|
1627
|
+
// Set canvas buffer size to DPR-scaled resolution for crisp rendering
|
|
1628
|
+
_canvas.width = Math.round(w * _dpr);
|
|
1629
|
+
_canvas.height = Math.round(h * _dpr);
|
|
1630
|
+
// CSS display size stays at viewport dimensions
|
|
1631
|
+
_canvas.style.width = w + 'px';
|
|
1632
|
+
_canvas.style.height = h + 'px';
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
// Window resizes arrive many times per frame while a window or sidepanel is
|
|
1636
|
+
// dragged; each buffer resize clears and reallocates the canvas. Apply at most
|
|
1637
|
+
// once per frame: the render loop applies it right before it draws (so the
|
|
1638
|
+
// cleared canvas is redrawn in the same frame); a stopped loop gets a one-off
|
|
1639
|
+
// frame to apply it.
|
|
1640
|
+
let _resizePending = false;
|
|
1641
|
+
function _scheduleCanvasResize() {
|
|
1642
|
+
if (_resizePending) return;
|
|
1643
|
+
_resizePending = true;
|
|
1644
|
+
if (!_animFrameId) {
|
|
1645
|
+
requestAnimationFrame(() => { if (_resizePending) _resizeCanvas(); });
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
|
|
1650
|
+
// ═══════════════════════════════════════════
|
|
1651
|
+
// PUBLIC API SHIM (force-graph compatible)
|
|
1652
|
+
// ═══════════════════════════════════════════
|
|
1653
|
+
|
|
1654
|
+
function _getPublicAPI() {
|
|
1655
|
+
return {
|
|
1656
|
+
centerAt: (x, y, duration) => {
|
|
1657
|
+
if (x == null && y == null) {
|
|
1658
|
+
// getter mode (used by minimap)
|
|
1659
|
+
return {
|
|
1660
|
+
x: (_canvas.width / 2 - _viewport.offsetX) / _viewport.scale,
|
|
1661
|
+
y: (_canvas.height / 2 - _viewport.offsetY) / _viewport.scale,
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
_centerAt(x, y, duration);
|
|
1665
|
+
},
|
|
1666
|
+
zoom: (level, duration) => {
|
|
1667
|
+
if (level == null) return _viewport.scale; // getter
|
|
1668
|
+
_lastActivityTime = performance.now();
|
|
1669
|
+
const newScale = Math.max(_viewport.minScale, Math.min(_viewport.maxScale, level));
|
|
1670
|
+
if (duration > 0) {
|
|
1671
|
+
_animFrom = { offsetX: _viewport.offsetX, offsetY: _viewport.offsetY, scale: _viewport.scale };
|
|
1672
|
+
_animTo = { offsetX: _viewport.offsetX, offsetY: _viewport.offsetY, scale: newScale };
|
|
1673
|
+
// Zoom from center
|
|
1674
|
+
const cx = _canvas.width / 2;
|
|
1675
|
+
const cy = _canvas.height / 2;
|
|
1676
|
+
_animTo.offsetX = cx - (cx - _viewport.offsetX) * (newScale / _viewport.scale);
|
|
1677
|
+
_animTo.offsetY = cy - (cy - _viewport.offsetY) * (newScale / _viewport.scale);
|
|
1678
|
+
_animStart = performance.now();
|
|
1679
|
+
_animDuration = duration;
|
|
1680
|
+
_animating = true;
|
|
1681
|
+
} else {
|
|
1682
|
+
_viewport.scale = newScale;
|
|
1683
|
+
}
|
|
1684
|
+
},
|
|
1685
|
+
zoomToFit: (duration, padding) => _zoomToFit(duration, padding),
|
|
1686
|
+
graphData: () => ({
|
|
1687
|
+
nodes: _cards.map(c => ({
|
|
1688
|
+
id: c.node.id,
|
|
1689
|
+
x: c.x,
|
|
1690
|
+
y: c.y,
|
|
1691
|
+
payload: c.node.payload,
|
|
1692
|
+
})),
|
|
1693
|
+
links: state.allLinks,
|
|
1694
|
+
}),
|
|
1695
|
+
width: (w) => {
|
|
1696
|
+
if (w != null) { _canvas.style.width = w + 'px'; _resizeCanvas(); }
|
|
1697
|
+
return _canvas ? Math.round(_canvas.width / _dpr) : 0;
|
|
1698
|
+
},
|
|
1699
|
+
height: (h) => {
|
|
1700
|
+
if (h != null) { _canvas.style.height = h + 'px'; _resizeCanvas(); }
|
|
1701
|
+
return _canvas ? Math.round(_canvas.height / _dpr) : 0;
|
|
1702
|
+
},
|
|
1703
|
+
// No-ops for compatibility
|
|
1704
|
+
linkVisibility: (fn) => fn,
|
|
1705
|
+
d3ReheatSimulation: () => reheatSimulation(),
|
|
1706
|
+
};
|
|
1707
|
+
}
|