@mindexec/cli 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +275 -0
  2. package/codex-runtime.js +960 -0
  3. package/launch-bridge.cjs +162 -0
  4. package/package.json +61 -0
  5. package/port-guard.cjs +232 -0
  6. package/scripts/setup-tree-sitter-grammars.mjs +59 -0
  7. package/server.js +8422 -0
  8. package/start-bridge.bat +32 -0
  9. package/start-bridge.sh +81 -0
  10. package/tree-sitter-grammars/README.md +18 -0
  11. package/tree-sitter-grammars/tree-sitter-c_sharp.wasm +0 -0
  12. package/tree-sitter-grammars/tree-sitter-go.wasm +0 -0
  13. package/tree-sitter-grammars/tree-sitter-java.wasm +0 -0
  14. package/tree-sitter-grammars/tree-sitter-javascript.wasm +0 -0
  15. package/tree-sitter-grammars/tree-sitter-python.wasm +0 -0
  16. package/tree-sitter-grammars/tree-sitter-rust.wasm +0 -0
  17. package/tree-sitter-grammars/tree-sitter-tsx.wasm +0 -0
  18. package/tree-sitter-grammars/tree-sitter-typescript.wasm +0 -0
  19. package/wwwroot/MindExecution.Web.styles.css +3 -0
  20. package/wwwroot/_content/MindExecution.Plugins.Admin/css/admin-dashboard.css +546 -0
  21. package/wwwroot/_content/MindExecution.Plugins.Directory/MindExecution.Plugins.Directory.u7utcng611.bundle.scp.css +7 -0
  22. package/wwwroot/_content/MindExecution.Plugins.Directory/background.png +0 -0
  23. package/wwwroot/_content/MindExecution.Plugins.Directory/directory-manager.js +202 -0
  24. package/wwwroot/_content/MindExecution.Plugins.Directory/exampleJsInterop.js +6 -0
  25. package/wwwroot/_content/MindExecution.Plugins.YouTube/css/youtube-search.css +251 -0
  26. package/wwwroot/_content/MindExecution.Shared/MindExecution.Shared.wsano1j4wp.bundle.scp.css +4 -0
  27. package/wwwroot/_content/MindExecution.Shared/css/admin-dashboard.css +559 -0
  28. package/wwwroot/_content/MindExecution.Shared/css/app.css +1 -0
  29. package/wwwroot/_content/MindExecution.Shared/css/mind-map-overrides.css +2936 -0
  30. package/wwwroot/_content/MindExecution.Shared/fonts/NotoSansKR-Bold.ttf +0 -0
  31. package/wwwroot/_content/MindExecution.Shared/fonts/NotoSansKR-Regular.ttf +0 -0
  32. package/wwwroot/_content/MindExecution.Shared/js/agent-visualization.js +359 -0
  33. package/wwwroot/_content/MindExecution.Shared/js/background-themes.js +1721 -0
  34. package/wwwroot/_content/MindExecution.Shared/js/code-master.js +8316 -0
  35. package/wwwroot/_content/MindExecution.Shared/js/file-system-helper.js +639 -0
  36. package/wwwroot/_content/MindExecution.Shared/js/helpers/InfiniteGridHelper.js +109 -0
  37. package/wwwroot/_content/MindExecution.Shared/js/marked.min.js +69 -0
  38. package/wwwroot/_content/MindExecution.Shared/js/mind-map-core.js +7982 -0
  39. package/wwwroot/_content/MindExecution.Shared/js/mind-map-core.js.backup +1059 -0
  40. package/wwwroot/_content/MindExecution.Shared/js/mind-map-css3d-manager.js +15803 -0
  41. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dev-guards.js +325 -0
  42. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dnd.js +1430 -0
  43. package/wwwroot/_content/MindExecution.Shared/js/mind-map-dnd.js.bak +434 -0
  44. package/wwwroot/_content/MindExecution.Shared/js/mind-map-glow-shader.js +260 -0
  45. package/wwwroot/_content/MindExecution.Shared/js/mind-map-interactions.js +7640 -0
  46. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-plan-worker.js +160 -0
  47. package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-renderer.js +9923 -0
  48. package/wwwroot/_content/MindExecution.Shared/js/mind-map-logic-workers.js +977 -0
  49. package/wwwroot/_content/MindExecution.Shared/js/mind-map-menu-manager.js +1431 -0
  50. package/wwwroot/_content/MindExecution.Shared/js/mind-map-multi-select.js +1716 -0
  51. package/wwwroot/_content/MindExecution.Shared/js/mind-map-node-search-worker.js +553 -0
  52. package/wwwroot/_content/MindExecution.Shared/js/mind-map-nodes.js +4541 -0
  53. package/wwwroot/_content/MindExecution.Shared/js/mind-map-object-manager.js +489 -0
  54. package/wwwroot/_content/MindExecution.Shared/js/mind-map-object-manager.js.backup +372 -0
  55. package/wwwroot/_content/MindExecution.Shared/js/mind-map-pipeline.js +2075 -0
  56. package/wwwroot/_content/MindExecution.Shared/js/mind-map-text-lod-system.js +646 -0
  57. package/wwwroot/_content/MindExecution.Shared/js/mind-map-text-overlay-v2.js +4323 -0
  58. package/wwwroot/_content/MindExecution.Shared/js/mind-map-texture-factory.js +2260 -0
  59. package/wwwroot/_content/MindExecution.Shared/js/mind-map-texture-factory.js.backup +1258 -0
  60. package/wwwroot/_content/MindExecution.Shared/js/mind-map-visibility-worker.js +890 -0
  61. package/wwwroot/_content/MindExecution.Shared/js/mindmap-toolbar.js +594 -0
  62. package/wwwroot/_content/MindExecution.Shared/js/native-drop-handler.js +170 -0
  63. package/wwwroot/_content/MindExecution.Shared/js/plan-master.js +788 -0
  64. package/wwwroot/_content/MindExecution.Shared/js/renderers/CSS3DRenderer.js +50 -0
  65. package/wwwroot/_content/MindExecution.Shared/js/texture-worker-manager.js +188 -0
  66. package/wwwroot/_content/MindExecution.Shared/js/texture-worker.js +208 -0
  67. package/wwwroot/_content/MindExecution.Shared/js/three.min.js +6 -0
  68. package/wwwroot/_content/MindExecution.Shared/js/titlebar-handler.js +191 -0
  69. package/wwwroot/_content/MindExecution.Shared/js/token-manager.js +37 -0
  70. package/wwwroot/_content/MindExecution.Shared/js/token-worker.js +28 -0
  71. package/wwwroot/_content/MindExecution.Shared/js/troika-bundle.js +5626 -0
  72. package/wwwroot/_content/MindExecution.Shared/js/troika-bundle.js.map +7 -0
  73. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/css/all.min.css +9 -0
  74. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-brands-400.ttf +0 -0
  75. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-brands-400.woff2 +0 -0
  76. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-regular-400.ttf +0 -0
  77. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-regular-400.woff2 +0 -0
  78. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-solid-900.ttf +0 -0
  79. package/wwwroot/_content/MindExecution.Shared/lib/font-awesome/webfonts/fa-solid-900.woff2 +0 -0
  80. package/wwwroot/_content/MindExecution.Shared/models/all-MiniLM-L6-v2-quantized.onnx +0 -0
  81. package/wwwroot/_content/MindExecution.Shared/models/vocab.txt +30522 -0
  82. package/wwwroot/_framework/Google.Protobuf.9h59ukbel7.dll +0 -0
  83. package/wwwroot/_framework/Markdig.d1j7v41cl1.dll +0 -0
  84. package/wwwroot/_framework/MessagePack.Annotations.l6qv48kgpt.dll +0 -0
  85. package/wwwroot/_framework/MessagePack.eqoptzx9d5.dll +0 -0
  86. package/wwwroot/_framework/Microsoft.AspNetCore.Authorization.k7dsih5y5g.dll +0 -0
  87. package/wwwroot/_framework/Microsoft.AspNetCore.Components.6nyje9sa0g.dll +0 -0
  88. package/wwwroot/_framework/Microsoft.AspNetCore.Components.Authorization.iycd6unprw.dll +0 -0
  89. package/wwwroot/_framework/Microsoft.AspNetCore.Components.Web.487u3twia4.dll +0 -0
  90. package/wwwroot/_framework/Microsoft.AspNetCore.Components.WebAssembly.d0gcnmlxxz.dll +0 -0
  91. package/wwwroot/_framework/Microsoft.AspNetCore.Metadata.h4yevl9adi.dll +0 -0
  92. package/wwwroot/_framework/Microsoft.CSharp.qrvp77qmhs.dll +0 -0
  93. package/wwwroot/_framework/Microsoft.Data.Sqlite.jdlxgv2jtg.dll +0 -0
  94. package/wwwroot/_framework/Microsoft.EntityFrameworkCore.4gjazp7kjf.dll +0 -0
  95. package/wwwroot/_framework/Microsoft.EntityFrameworkCore.Abstractions.gocudnvz7b.dll +0 -0
  96. package/wwwroot/_framework/Microsoft.EntityFrameworkCore.Relational.lt4rsvinuo.dll +0 -0
  97. package/wwwroot/_framework/Microsoft.EntityFrameworkCore.Sqlite.69luj0fa9r.dll +0 -0
  98. package/wwwroot/_framework/Microsoft.Extensions.Caching.Abstractions.364t4jh3zz.dll +0 -0
  99. package/wwwroot/_framework/Microsoft.Extensions.Caching.Memory.izlxhpzosu.dll +0 -0
  100. package/wwwroot/_framework/Microsoft.Extensions.Configuration.8zq7hh41o7.dll +0 -0
  101. package/wwwroot/_framework/Microsoft.Extensions.Configuration.Abstractions.8if74zs6ea.dll +0 -0
  102. package/wwwroot/_framework/Microsoft.Extensions.Configuration.Json.duvlngw8i0.dll +0 -0
  103. package/wwwroot/_framework/Microsoft.Extensions.DependencyInjection.Abstractions.t2hh9kvx0o.dll +0 -0
  104. package/wwwroot/_framework/Microsoft.Extensions.DependencyInjection.n4tg99oy8l.dll +0 -0
  105. package/wwwroot/_framework/Microsoft.Extensions.DependencyModel.h0d06ixk3e.dll +0 -0
  106. package/wwwroot/_framework/Microsoft.Extensions.Logging.Abstractions.rl32bkx2sd.dll +0 -0
  107. package/wwwroot/_framework/Microsoft.Extensions.Logging.dlht1xei0t.dll +0 -0
  108. package/wwwroot/_framework/Microsoft.Extensions.Options.qeunebioml.dll +0 -0
  109. package/wwwroot/_framework/Microsoft.Extensions.Primitives.18cr6vnuuz.dll +0 -0
  110. package/wwwroot/_framework/Microsoft.IO.RecyclableMemoryStream.r915vovvw4.dll +0 -0
  111. package/wwwroot/_framework/Microsoft.IdentityModel.Abstractions.1ejljk3erv.dll +0 -0
  112. package/wwwroot/_framework/Microsoft.IdentityModel.JsonWebTokens.1596zr8gne.dll +0 -0
  113. package/wwwroot/_framework/Microsoft.IdentityModel.Logging.229uyvpgio.dll +0 -0
  114. package/wwwroot/_framework/Microsoft.IdentityModel.Tokens.9sibtajc9f.dll +0 -0
  115. package/wwwroot/_framework/Microsoft.JSInterop.17lq4j1j7g.dll +0 -0
  116. package/wwwroot/_framework/Microsoft.JSInterop.WebAssembly.ryia5gxiad.dll +0 -0
  117. package/wwwroot/_framework/Microsoft.ML.OnnxRuntime.w9deo1m5ss.dll +0 -0
  118. package/wwwroot/_framework/Microsoft.ML.Tokenizers.cm2vuv2z61.dll +0 -0
  119. package/wwwroot/_framework/Microsoft.NET.StringTools.3qbrf4v2ki.dll +0 -0
  120. package/wwwroot/_framework/MimeMapping.og9ys58ylm.dll +0 -0
  121. package/wwwroot/_framework/MindExecution.Core.1q1trifbuu.dll +0 -0
  122. package/wwwroot/_framework/MindExecution.Kernel.gwwc40sc45.dll +0 -0
  123. package/wwwroot/_framework/MindExecution.Plugins.Admin.0jgrn1sckv.dll +0 -0
  124. package/wwwroot/_framework/MindExecution.Plugins.Business.13mme2qcag.dll +0 -0
  125. package/wwwroot/_framework/MindExecution.Plugins.Concept.dfp2mdt45q.dll +0 -0
  126. package/wwwroot/_framework/MindExecution.Plugins.Directory.3w4t6n3se0.dll +0 -0
  127. package/wwwroot/_framework/MindExecution.Plugins.PlanMaster.s0qpntz420.dll +0 -0
  128. package/wwwroot/_framework/MindExecution.Plugins.YouTube.iu11fq8d16.dll +0 -0
  129. package/wwwroot/_framework/MindExecution.Shared.7j27dcqnrc.dll +0 -0
  130. package/wwwroot/_framework/MindExecution.Web.pq1ty8ov2v.dll +0 -0
  131. package/wwwroot/_framework/Newtonsoft.Json.a56zs13vug.dll +0 -0
  132. package/wwwroot/_framework/SQLitePCLRaw.batteries_v2.rrd1nzawpp.dll +0 -0
  133. package/wwwroot/_framework/SQLitePCLRaw.core.1dxloztpfz.dll +0 -0
  134. package/wwwroot/_framework/SQLitePCLRaw.provider.e_sqlite3.oekyzl53i1.dll +0 -0
  135. package/wwwroot/_framework/Supabase.Core.s1pkj4aj0l.dll +0 -0
  136. package/wwwroot/_framework/Supabase.Functions.qz4nu782sg.dll +0 -0
  137. package/wwwroot/_framework/Supabase.Gotrue.twah27pkik.dll +0 -0
  138. package/wwwroot/_framework/Supabase.Postgrest.gmuuv369ih.dll +0 -0
  139. package/wwwroot/_framework/Supabase.Realtime.ox3kchdy3w.dll +0 -0
  140. package/wwwroot/_framework/Supabase.Storage.fnjnepaowr.dll +0 -0
  141. package/wwwroot/_framework/Supabase.azmaw5pgcz.dll +0 -0
  142. package/wwwroot/_framework/System.Collections.Concurrent.y1zmvuyipi.dll +0 -0
  143. package/wwwroot/_framework/System.Collections.Immutable.ug3j698qms.dll +0 -0
  144. package/wwwroot/_framework/System.Collections.NonGeneric.h66hj3863h.dll +0 -0
  145. package/wwwroot/_framework/System.Collections.Specialized.umr3y27ntj.dll +0 -0
  146. package/wwwroot/_framework/System.Collections.x53e19vfsj.dll +0 -0
  147. package/wwwroot/_framework/System.ComponentModel.Annotations.tz6gnt4ebt.dll +0 -0
  148. package/wwwroot/_framework/System.ComponentModel.Primitives.j7tiphu4rg.dll +0 -0
  149. package/wwwroot/_framework/System.ComponentModel.TypeConverter.ujlztox1gx.dll +0 -0
  150. package/wwwroot/_framework/System.ComponentModel.x9xz0ojfb6.dll +0 -0
  151. package/wwwroot/_framework/System.Console.ijzpqmj7ne.dll +0 -0
  152. package/wwwroot/_framework/System.Data.Common.1r0sqffq1p.dll +0 -0
  153. package/wwwroot/_framework/System.Diagnostics.DiagnosticSource.9upoqwq09o.dll +0 -0
  154. package/wwwroot/_framework/System.Diagnostics.Process.m99azzntjm.dll +0 -0
  155. package/wwwroot/_framework/System.Diagnostics.TraceSource.pl7wv26myr.dll +0 -0
  156. package/wwwroot/_framework/System.Diagnostics.Tracing.crlhfx6tut.dll +0 -0
  157. package/wwwroot/_framework/System.Drawing.Primitives.22e4y9ikq9.dll +0 -0
  158. package/wwwroot/_framework/System.Drawing.mi7d8hwowb.dll +0 -0
  159. package/wwwroot/_framework/System.Formats.Asn1.jx23sjiqnn.dll +0 -0
  160. package/wwwroot/_framework/System.IO.Compression.6fyoii3uej.dll +0 -0
  161. package/wwwroot/_framework/System.IO.Pipelines.vg77t4cd4d.dll +0 -0
  162. package/wwwroot/_framework/System.IdentityModel.Tokens.Jwt.t67es60z5b.dll +0 -0
  163. package/wwwroot/_framework/System.Linq.1bkoxlqgmq.dll +0 -0
  164. package/wwwroot/_framework/System.Linq.Expressions.24xqiypwdt.dll +0 -0
  165. package/wwwroot/_framework/System.Linq.Queryable.hvd01d6rsa.dll +0 -0
  166. package/wwwroot/_framework/System.Memory.8dx3lwgym4.dll +0 -0
  167. package/wwwroot/_framework/System.Net.Http.Json.3mhdm9l1rf.dll +0 -0
  168. package/wwwroot/_framework/System.Net.Http.eitrz660my.dll +0 -0
  169. package/wwwroot/_framework/System.Net.NetworkInformation.3pkuofcv9r.dll +0 -0
  170. package/wwwroot/_framework/System.Net.Ping.8clj5pklrp.dll +0 -0
  171. package/wwwroot/_framework/System.Net.Primitives.qrp4wcjz1p.dll +0 -0
  172. package/wwwroot/_framework/System.Net.WebSockets.Client.2u6pv01g69.dll +0 -0
  173. package/wwwroot/_framework/System.Net.WebSockets.qp6u31zvm5.dll +0 -0
  174. package/wwwroot/_framework/System.Numerics.Tensors.0c7z4mt3on.dll +0 -0
  175. package/wwwroot/_framework/System.Numerics.Vectors.kc7ufp2j4l.dll +0 -0
  176. package/wwwroot/_framework/System.ObjectModel.qv82fot1ib.dll +0 -0
  177. package/wwwroot/_framework/System.Private.CoreLib.rkafq04oma.dll +0 -0
  178. package/wwwroot/_framework/System.Private.Uri.t9542hmr6j.dll +0 -0
  179. package/wwwroot/_framework/System.Private.Xml.Linq.n8n3ptrbwu.dll +0 -0
  180. package/wwwroot/_framework/System.Private.Xml.rxd3tytisn.dll +0 -0
  181. package/wwwroot/_framework/System.Reactive.t3fuon548l.dll +0 -0
  182. package/wwwroot/_framework/System.Reflection.Emit.9tjhp6y0j3.dll +0 -0
  183. package/wwwroot/_framework/System.Reflection.Emit.ILGeneration.stxyk8zoo1.dll +0 -0
  184. package/wwwroot/_framework/System.Reflection.Emit.Lightweight.6xrd5v8vg0.dll +0 -0
  185. package/wwwroot/_framework/System.Reflection.Primitives.wgn8fpwwvv.dll +0 -0
  186. package/wwwroot/_framework/System.Runtime.InteropServices.JavaScript.sliym526xh.dll +0 -0
  187. package/wwwroot/_framework/System.Runtime.InteropServices.RuntimeInformation.oji7zut14z.dll +0 -0
  188. package/wwwroot/_framework/System.Runtime.InteropServices.te07xr2we9.dll +0 -0
  189. package/wwwroot/_framework/System.Runtime.Intrinsics.507y4h8nzq.dll +0 -0
  190. package/wwwroot/_framework/System.Runtime.Loader.v7gk4bse0k.dll +0 -0
  191. package/wwwroot/_framework/System.Runtime.Numerics.eqy5xjv3nd.dll +0 -0
  192. package/wwwroot/_framework/System.Runtime.Serialization.Formatters.zpkrub8lab.dll +0 -0
  193. package/wwwroot/_framework/System.Runtime.Serialization.Primitives.vhkpnbxjip.dll +0 -0
  194. package/wwwroot/_framework/System.Runtime.jn319d5nyg.dll +0 -0
  195. package/wwwroot/_framework/System.Security.Claims.0ztig1q9vo.dll +0 -0
  196. package/wwwroot/_framework/System.Security.Cryptography.vttizqc9ho.dll +0 -0
  197. package/wwwroot/_framework/System.Text.Encoding.Extensions.utdd47ny8f.dll +0 -0
  198. package/wwwroot/_framework/System.Text.Encodings.Web.wah8r1zoe0.dll +0 -0
  199. package/wwwroot/_framework/System.Text.Json.kxlfxj0wrs.dll +0 -0
  200. package/wwwroot/_framework/System.Text.RegularExpressions.dbqn58klox.dll +0 -0
  201. package/wwwroot/_framework/System.Threading.42ao9vi047.dll +0 -0
  202. package/wwwroot/_framework/System.Threading.Channels.hfa7j0uv2w.dll +0 -0
  203. package/wwwroot/_framework/System.Threading.Thread.caul0pdqul.dll +0 -0
  204. package/wwwroot/_framework/System.Transactions.Local.fimi2hamzo.dll +0 -0
  205. package/wwwroot/_framework/System.Web.HttpUtility.gq8yz50p2e.dll +0 -0
  206. package/wwwroot/_framework/System.Xml.Linq.kitin4zjoj.dll +0 -0
  207. package/wwwroot/_framework/System.Xml.ReaderWriter.kzvw3qgxb0.dll +0 -0
  208. package/wwwroot/_framework/System.Xml.XDocument.c539ki6cuq.dll +0 -0
  209. package/wwwroot/_framework/System.m05i39uvk9.dll +0 -0
  210. package/wwwroot/_framework/Websocket.Client.vapounvmnl.dll +0 -0
  211. package/wwwroot/_framework/blazor.boot.json +305 -0
  212. package/wwwroot/_framework/blazor.webassembly.js +1 -0
  213. package/wwwroot/_framework/dotnet.js +4 -0
  214. package/wwwroot/_framework/dotnet.native.vz0adxojrz.wasm +0 -0
  215. package/wwwroot/_framework/dotnet.native.xsn1d6x2kd.js +16 -0
  216. package/wwwroot/_framework/dotnet.runtime.dstopyvqzi.js +4 -0
  217. package/wwwroot/_framework/icudt_CJK.tjcz0u77k5.dat +0 -0
  218. package/wwwroot/_framework/icudt_EFIGS.tptq2av103.dat +0 -0
  219. package/wwwroot/_framework/icudt_no_CJK.lfu7j35m59.dat +0 -0
  220. package/wwwroot/_framework/netstandard.0xet7jg7ky.dll +0 -0
  221. package/wwwroot/_headers +40 -0
  222. package/wwwroot/_redirects +1 -0
  223. package/wwwroot/appsettings.json +71 -0
  224. package/wwwroot/icon-192.png +0 -0
  225. package/wwwroot/icon-512.png +0 -0
  226. package/wwwroot/index.html +710 -0
  227. package/wwwroot/js/marketing-tool.js +180 -0
  228. package/wwwroot/manifest.webmanifest +22 -0
  229. package/wwwroot/robots.txt +4 -0
  230. package/wwwroot/service-worker-assets.js +857 -0
  231. package/wwwroot/service-worker.js +33 -0
  232. package/wwwroot/sitemap.xml +27 -0
@@ -0,0 +1,977 @@
1
+ (function () {
2
+ 'use strict';
3
+
4
+ const LOGIC_WORKER_BRIDGE_BUILD_ID = '20260606-worker-pan-enter-only-v006';
5
+ const VISIBILITY_WORKER_URL = `_content/MindExecution.Shared/js/mind-map-visibility-worker.js?v=${LOGIC_WORKER_BRIDGE_BUILD_ID}`;
6
+ const LOD_PLAN_WORKER_URL = `_content/MindExecution.Shared/js/mind-map-lod-plan-worker.js?v=${LOGIC_WORKER_BRIDGE_BUILD_ID}`;
7
+ const NODE_SEARCH_WORKER_URL = `_content/MindExecution.Shared/js/mind-map-node-search-worker.js?v=${LOGIC_WORKER_BRIDGE_BUILD_ID}`;
8
+ const CTRL_WHEEL_SCROLL_ACTIVE_WINDOW_MS = 140;
9
+ const SEARCH_METADATA_TEXT_LIMIT = 8192;
10
+
11
+ function getNodeContentType(model) {
12
+ return String(model?.contentType ?? model?.ContentType ?? '').trim().toLowerCase();
13
+ }
14
+
15
+ function isTextLikeContentType(contentType) {
16
+ return contentType === 'text' ||
17
+ contentType === 'note' ||
18
+ contentType === 'memo' ||
19
+ contentType === 'markdown' ||
20
+ contentType === 'code';
21
+ }
22
+
23
+ function getNodeSpatialGridKeys(entry) {
24
+ if (entry?._spatialGridKeys instanceof Set) {
25
+ return entry._spatialGridKeys;
26
+ }
27
+ if (entry?.glObject?.userData?.spatialGridKeys instanceof Set) {
28
+ return entry.glObject.userData.spatialGridKeys;
29
+ }
30
+ if (entry?.cssObject?.userData?.spatialGridKeys instanceof Set) {
31
+ return entry.cssObject.userData.spatialGridKeys;
32
+ }
33
+
34
+ return new Set();
35
+ }
36
+
37
+ function normalizeBoardId(boardId) {
38
+ return String(boardId ?? '').trim();
39
+ }
40
+
41
+ function cloneCellKeys(cellKeys) {
42
+ if (Array.isArray(cellKeys)) {
43
+ return cellKeys
44
+ .map((key) => String(key || '').trim())
45
+ .filter(Boolean);
46
+ }
47
+ if (cellKeys instanceof Set) {
48
+ return Array.from(cellKeys)
49
+ .map((key) => String(key || '').trim())
50
+ .filter(Boolean);
51
+ }
52
+
53
+ return [];
54
+ }
55
+
56
+ function limitSearchText(value, maxLength) {
57
+ const text = String(value ?? '');
58
+ if (!text) {
59
+ return '';
60
+ }
61
+
62
+ return text.length <= maxLength
63
+ ? text
64
+ : text.slice(0, maxLength);
65
+ }
66
+
67
+ function buildSearchMetadataText(metadata) {
68
+ if (!metadata) {
69
+ return '';
70
+ }
71
+
72
+ if (typeof metadata === 'string') {
73
+ return limitSearchText(metadata, SEARCH_METADATA_TEXT_LIMIT);
74
+ }
75
+
76
+ const values = [];
77
+ const entries = Array.isArray(metadata)
78
+ ? metadata
79
+ : Object.entries(metadata);
80
+ for (let i = 0; i < entries.length; i++) {
81
+ const entry = entries[i];
82
+ if (Array.isArray(entry)) {
83
+ const key = limitSearchText(entry[0], 128).trim();
84
+ const value = limitSearchText(entry[1], 1024).trim();
85
+ if (key) values.push(key);
86
+ if (value) values.push(value);
87
+ } else if (entry) {
88
+ const value = limitSearchText(entry, 1024).trim();
89
+ if (value) values.push(value);
90
+ }
91
+
92
+ if (values.join(' ').length >= SEARCH_METADATA_TEXT_LIMIT) {
93
+ break;
94
+ }
95
+ }
96
+
97
+ return limitSearchText(values.join(' '), SEARCH_METADATA_TEXT_LIMIT);
98
+ }
99
+
100
+ function buildWorkerNodeSnapshot(entry, fallbackNodeId = null, boundsOverride = null, cellKeysOverride = null) {
101
+ const model = entry?.model || null;
102
+ const nodeId = String(
103
+ model?.id ??
104
+ entry?.glObject?.userData?.nodeId ??
105
+ entry?.cssObject?.userData?.nodeId ??
106
+ fallbackNodeId ??
107
+ ''
108
+ ).trim();
109
+ if (!nodeId) {
110
+ return null;
111
+ }
112
+
113
+ const bounds = boundsOverride || window.MindMapNodeBounds?.getNodeWorldBounds?.(entry);
114
+ if (!bounds) {
115
+ return null;
116
+ }
117
+
118
+ const contentType = getNodeContentType(model);
119
+ const cellKeys = cloneCellKeys(cellKeysOverride || getNodeSpatialGridKeys(entry));
120
+
121
+ return {
122
+ id: nodeId,
123
+ contentType,
124
+ textLike: isTextLikeContentType(contentType),
125
+ x: Number(bounds.x || 0),
126
+ y: Number(bounds.y || 0),
127
+ z: Number(bounds.z || 0),
128
+ width: Math.max(1, Number(bounds.width || 1)),
129
+ height: Math.max(1, Number(bounds.height || 1)),
130
+ minX: Number(bounds.minX || 0),
131
+ maxX: Number(bounds.maxX || 0),
132
+ minY: Number(bounds.minY || 0),
133
+ maxY: Number(bounds.maxY || 0),
134
+ cellKeys
135
+ };
136
+ }
137
+
138
+ function buildWorkerSearchSnapshot(source, fallbackNodeId = null, boundsOverride = null) {
139
+ const model = source?.model || source || null;
140
+ const nodeId = String(
141
+ model?.id ??
142
+ model?.Id ??
143
+ source?.glObject?.userData?.nodeId ??
144
+ source?.cssObject?.userData?.nodeId ??
145
+ fallbackNodeId ??
146
+ ''
147
+ ).trim();
148
+ if (!nodeId) {
149
+ return null;
150
+ }
151
+
152
+ const bounds = boundsOverride || window.MindMapNodeBounds?.getNodeWorldBounds?.(source) || null;
153
+ const contentType = String(model?.contentType ?? model?.ContentType ?? source?.contentType ?? source?.ContentType ?? '').trim().toLowerCase();
154
+
155
+ return {
156
+ id: nodeId,
157
+ contentType,
158
+ prompt: limitSearchText(model?.prompt ?? model?.Prompt ?? source?.prompt ?? source?.Prompt, 2048),
159
+ response: limitSearchText(model?.response ?? model?.Response ?? source?.response ?? source?.Response, 16000),
160
+ metadataText: buildSearchMetadataText(model?.metadata ?? model?.Metadata ?? source?.metadataText ?? source?.MetadataText ?? source?.metadata ?? source?.Metadata),
161
+ sourcePath: limitSearchText(model?.sourceFilePath ?? model?.SourceFilePath ?? source?.sourcePath ?? source?.SourcePath, 2048),
162
+ positionX: Number(model?.positionX ?? model?.PositionX ?? model?.x ?? bounds?.x ?? source?.positionX ?? source?.PositionX ?? 0),
163
+ positionY: Number(model?.positionY ?? model?.PositionY ?? model?.y ?? bounds?.y ?? source?.positionY ?? source?.PositionY ?? 0),
164
+ width: Math.max(1, Number(model?.width ?? model?.Width ?? bounds?.width ?? source?.width ?? source?.Width ?? 1)),
165
+ height: Math.max(1, Number(model?.height ?? model?.Height ?? bounds?.height ?? source?.height ?? source?.Height ?? 1))
166
+ };
167
+ }
168
+
169
+ class MindMapLogicWorkerBridge {
170
+ constructor(module) {
171
+ this.module = module || null;
172
+ this.boardId = normalizeBoardId(module?.activeBoardId || window.mindMap?.activeBoardId || '');
173
+
174
+ this._visibilityWorker = null;
175
+ this._lodPlanWorker = null;
176
+ this._searchWorker = null;
177
+ this._visibilityReady = false;
178
+ this._lodPlanReady = false;
179
+ this._searchReady = false;
180
+ this._visibilityDisabled = false;
181
+ this._lodPlanDisabled = false;
182
+ this._searchDisabled = false;
183
+ this._latestVisibilityRequestSeq = 0;
184
+ this._latestHitTestRequestSeq = 0;
185
+ this._latestSelectionRequestSeq = 0;
186
+ this._latestLodPlanRequestSeq = 0;
187
+ this._latestSearchRequestSeq = 0;
188
+ this._pendingLodPlanKey = '';
189
+ this._visibilityQueryPending = false;
190
+ this._deferredVisibilityPayload = null;
191
+ this._hitTestQueryPending = false;
192
+ this._deferredHitTestPayload = null;
193
+ this._pendingSelectionResolvers = new Map();
194
+ this._pendingSearchResolvers = new Map();
195
+
196
+ this._createWorkers();
197
+ }
198
+
199
+ _createWorkers() {
200
+ this._visibilityWorker = this._createWorker(
201
+ 'visibility',
202
+ VISIBILITY_WORKER_URL,
203
+ (data) => this._handleVisibilityMessage(data)
204
+ );
205
+ this._lodPlanWorker = this._createWorker(
206
+ 'lod-plan',
207
+ LOD_PLAN_WORKER_URL,
208
+ (data) => this._handleLodPlanMessage(data)
209
+ );
210
+ this._searchWorker = this._createWorker(
211
+ 'node-search',
212
+ NODE_SEARCH_WORKER_URL,
213
+ (data) => this._handleSearchMessage(data)
214
+ );
215
+ }
216
+
217
+ _createWorker(kind, url, onMessage) {
218
+ try {
219
+ const worker = new Worker(url);
220
+ worker.onmessage = (event) => {
221
+ const data = event?.data || null;
222
+ if (!data || typeof data !== 'object') {
223
+ return;
224
+ }
225
+
226
+ if (data.type === 'READY') {
227
+ if (kind === 'visibility') {
228
+ this._visibilityReady = true;
229
+ } else if (kind === 'lod-plan') {
230
+ this._lodPlanReady = true;
231
+ } else if (kind === 'node-search') {
232
+ this._searchReady = true;
233
+ }
234
+ return;
235
+ }
236
+
237
+ onMessage(data);
238
+ };
239
+ worker.onerror = (error) => {
240
+ console.warn(`[MindMapLogicWorkerBridge] ${kind} worker disabled after error.`, error);
241
+ if (kind === 'visibility') {
242
+ this._visibilityDisabled = true;
243
+ this._visibilityReady = false;
244
+ this._clearHitTestCache(this.module);
245
+ this._hitTestQueryPending = false;
246
+ this._deferredHitTestPayload = null;
247
+ this._resolvePendingSelectionQueries(null);
248
+ } else if (kind === 'lod-plan') {
249
+ this._lodPlanDisabled = true;
250
+ this._lodPlanReady = false;
251
+ } else {
252
+ this._searchDisabled = true;
253
+ this._searchReady = false;
254
+ this._resolvePendingSearches(null);
255
+ }
256
+ try {
257
+ worker.terminate();
258
+ } catch { }
259
+ };
260
+ return worker;
261
+ } catch (error) {
262
+ console.warn(`[MindMapLogicWorkerBridge] Failed to create ${kind} worker.`, error);
263
+ if (kind === 'visibility') {
264
+ this._visibilityDisabled = true;
265
+ } else if (kind === 'lod-plan') {
266
+ this._lodPlanDisabled = true;
267
+ } else {
268
+ this._searchDisabled = true;
269
+ }
270
+ return null;
271
+ }
272
+ }
273
+
274
+ _post(worker, payload) {
275
+ if (!worker || !payload) {
276
+ return false;
277
+ }
278
+
279
+ try {
280
+ worker.postMessage(payload);
281
+ return true;
282
+ } catch (error) {
283
+ console.warn('[MindMapLogicWorkerBridge] Failed to post worker message.', payload?.type, error);
284
+ return false;
285
+ }
286
+ }
287
+
288
+ _stampVisibilityPayloadForPost(payload) {
289
+ if (!payload || String(payload.type || '') !== 'VISIBILITY_QUERY') {
290
+ return payload;
291
+ }
292
+
293
+ payload.mainLastAppliedSeq = Math.max(
294
+ 0,
295
+ Math.floor(Number(this.module?._workerVisibilitySeq || 0))
296
+ );
297
+ return payload;
298
+ }
299
+
300
+ _resolveBoardId(module = this.module, fallbackBoardId = null) {
301
+ const candidate = normalizeBoardId(
302
+ fallbackBoardId ??
303
+ module?.activeBoardId ??
304
+ window.mindMap?.activeBoardId ??
305
+ this.boardId
306
+ );
307
+ if (candidate) {
308
+ this.boardId = candidate;
309
+ }
310
+ return candidate;
311
+ }
312
+
313
+ _clearHitTestCache(module = this.module) {
314
+ if (!module) {
315
+ return;
316
+ }
317
+
318
+ module._workerHitTestRangeKey = '';
319
+ module._workerHitTestBoardId = '';
320
+ module._workerHitTestCandidateIds = [];
321
+ module._workerHitTestSeq = 0;
322
+ module._workerHitTestCellX = 0;
323
+ module._workerHitTestCellY = 0;
324
+ module._workerHitTestCellRadius = 0;
325
+ module._workerHitTestUpdatedAt = 0;
326
+ module._workerHitTestProfile = null;
327
+ }
328
+
329
+ _handleVisibilityMessage(data) {
330
+ if (String(data?.type || '') === 'HIT_TEST_RESULT') {
331
+ this._handleHitTestMessage(data);
332
+ return;
333
+ }
334
+ if (String(data?.type || '') === 'SELECTION_QUERY_RESULT') {
335
+ this._handleSelectionQueryMessage(data);
336
+ return;
337
+ }
338
+
339
+ const module = this.module;
340
+ const boardId = this._resolveBoardId(module);
341
+ if (!module || !boardId) {
342
+ return;
343
+ }
344
+
345
+ if (normalizeBoardId(data.boardId) !== boardId) {
346
+ return;
347
+ }
348
+
349
+ if (Number(data.seq || 0) < Number(this._latestVisibilityRequestSeq || 0)) {
350
+ this._visibilityQueryPending = false;
351
+ this._flushDeferredVisibilityRequest();
352
+ return;
353
+ }
354
+
355
+ module._applyWorkerVisibilityResult?.(data);
356
+ this._visibilityQueryPending = false;
357
+ this._flushDeferredVisibilityRequest();
358
+ }
359
+
360
+ _handleHitTestMessage(data) {
361
+ const module = this.module;
362
+ const boardId = this._resolveBoardId(module);
363
+ this._hitTestQueryPending = false;
364
+
365
+ if (!module || !boardId) {
366
+ this._flushDeferredHitTestRequest();
367
+ return;
368
+ }
369
+
370
+ if (normalizeBoardId(data.boardId) !== boardId) {
371
+ this._flushDeferredHitTestRequest();
372
+ return;
373
+ }
374
+
375
+ if (Number(data.seq || 0) < Number(this._latestHitTestRequestSeq || 0)) {
376
+ this._flushDeferredHitTestRequest();
377
+ return;
378
+ }
379
+
380
+ module._workerHitTestRangeKey = String(data.rangeKey || '').trim();
381
+ module._workerHitTestBoardId = boardId;
382
+ module._workerHitTestCandidateIds = Array.isArray(data.candidateIds)
383
+ ? data.candidateIds.map((nodeId) => String(nodeId || '').trim()).filter(Boolean)
384
+ : [];
385
+ module._workerHitTestSeq = Number(data.seq || 0);
386
+ module._workerHitTestCellX = Number(data.cellX || 0);
387
+ module._workerHitTestCellY = Number(data.cellY || 0);
388
+ module._workerHitTestCellRadius = Number(data.cellRadius || 0);
389
+ module._workerHitTestUpdatedAt = (typeof performance !== 'undefined' && typeof performance.now === 'function')
390
+ ? performance.now()
391
+ : Date.now();
392
+ module._workerHitTestProfile = data.profile || null;
393
+
394
+ this._flushDeferredHitTestRequest();
395
+ }
396
+
397
+ _handleSelectionQueryMessage(data) {
398
+ const boardId = this._resolveBoardId(this.module);
399
+ const seq = Number(data.seq || 0);
400
+ const resolver = this._pendingSelectionResolvers.get(seq) || null;
401
+ if (resolver) {
402
+ this._pendingSelectionResolvers.delete(seq);
403
+ }
404
+
405
+ if (!resolver) {
406
+ return;
407
+ }
408
+
409
+ if (seq < Number(this._latestSelectionRequestSeq || 0)) {
410
+ resolver(null);
411
+ return;
412
+ }
413
+
414
+ if (!boardId || normalizeBoardId(data.boardId) !== boardId) {
415
+ resolver(null);
416
+ return;
417
+ }
418
+
419
+ const selectedIds = Array.isArray(data.selectedIds)
420
+ ? data.selectedIds.map((nodeId) => String(nodeId || '').trim()).filter(Boolean)
421
+ : [];
422
+ resolver(selectedIds);
423
+ }
424
+
425
+ _handleLodPlanMessage(data) {
426
+ const module = this.module;
427
+ const boardId = this._resolveBoardId(module);
428
+ if (!module || !module.lodRenderer || !boardId) {
429
+ return;
430
+ }
431
+
432
+ if (normalizeBoardId(data.boardId) !== boardId) {
433
+ return;
434
+ }
435
+
436
+ if (Number(data.seq || 0) < Number(this._latestLodPlanRequestSeq || 0)) {
437
+ return;
438
+ }
439
+
440
+ if (String(data.key || '') === this._pendingLodPlanKey) {
441
+ this._pendingLodPlanKey = '';
442
+ }
443
+
444
+ module.lodRenderer._applyWorkerLodPlanResult?.(data);
445
+ }
446
+
447
+ _handleSearchMessage(data) {
448
+ const boardId = this._resolveBoardId(this.module);
449
+ const normalizedBoardId = normalizeBoardId(data.boardId);
450
+ const seq = Number(data.seq || 0);
451
+ const resolver = this._pendingSearchResolvers.get(seq) || null;
452
+ if (resolver) {
453
+ this._pendingSearchResolvers.delete(seq);
454
+ }
455
+
456
+ if (!resolver) {
457
+ return;
458
+ }
459
+
460
+ if (!boardId || normalizedBoardId !== boardId) {
461
+ resolver([]);
462
+ return;
463
+ }
464
+
465
+ const hits = Array.isArray(data.hits)
466
+ ? data.hits.map((hit) => ({
467
+ nodeId: String(hit?.nodeId ?? hit?.id ?? '').trim(),
468
+ score: Number(hit?.score || 0)
469
+ })).filter((hit) => hit.nodeId)
470
+ : [];
471
+ resolver(hits);
472
+ }
473
+
474
+ _resolvePendingSearches(hits) {
475
+ const resolvers = Array.from(this._pendingSearchResolvers.values());
476
+ this._pendingSearchResolvers.clear();
477
+ for (let i = 0; i < resolvers.length; i++) {
478
+ try {
479
+ resolvers[i](hits);
480
+ } catch {
481
+ }
482
+ }
483
+ }
484
+
485
+ _resolvePendingSelectionQueries(nodeIds) {
486
+ const resolvers = Array.from(this._pendingSelectionResolvers.values());
487
+ this._pendingSelectionResolvers.clear();
488
+ for (let i = 0; i < resolvers.length; i++) {
489
+ try {
490
+ resolvers[i](nodeIds);
491
+ } catch {
492
+ }
493
+ }
494
+ }
495
+
496
+ dispose() {
497
+ try {
498
+ this._visibilityWorker?.terminate?.();
499
+ } catch { }
500
+ try {
501
+ this._lodPlanWorker?.terminate?.();
502
+ } catch { }
503
+ try {
504
+ this._searchWorker?.terminate?.();
505
+ } catch { }
506
+
507
+ this._visibilityWorker = null;
508
+ this._lodPlanWorker = null;
509
+ this._searchWorker = null;
510
+ this._visibilityReady = false;
511
+ this._lodPlanReady = false;
512
+ this._searchReady = false;
513
+ this._hitTestQueryPending = false;
514
+ this._deferredHitTestPayload = null;
515
+ this._resolvePendingSelectionQueries(null);
516
+ this._clearHitTestCache(this.module);
517
+ this._resolvePendingSearches(null);
518
+ }
519
+
520
+ resetBoard(boardId, reason = 'reset-board') {
521
+ const normalizedBoardId = this._resolveBoardId(this.module, boardId);
522
+ this._latestVisibilityRequestSeq = 0;
523
+ this._latestHitTestRequestSeq = 0;
524
+ this._latestSelectionRequestSeq = 0;
525
+ this._latestLodPlanRequestSeq = 0;
526
+ this._latestSearchRequestSeq = 0;
527
+ this._pendingLodPlanKey = '';
528
+ this._visibilityQueryPending = false;
529
+ this._deferredVisibilityPayload = null;
530
+ this._hitTestQueryPending = false;
531
+ this._deferredHitTestPayload = null;
532
+ this._resolvePendingSelectionQueries(null);
533
+ this._resolvePendingSearches(null);
534
+ this._clearHitTestCache(this.module);
535
+
536
+ if (this.module) {
537
+ this.module._visibilityWorkerPrimed = false;
538
+ }
539
+
540
+ const payload = {
541
+ type: 'RESET_BOARD',
542
+ boardId: normalizedBoardId,
543
+ reason,
544
+ cellSize: Math.max(1, Number(this.module?.GRID_CELL_SIZE || 500))
545
+ };
546
+ this._post(this._visibilityWorker, payload);
547
+ this._post(this._lodPlanWorker, payload);
548
+ this._post(this._searchWorker, payload);
549
+ }
550
+
551
+ rebuildNodeTables(module = this.module, options = {}) {
552
+ const activeModule = module || this.module;
553
+ const boardId = this._resolveBoardId(activeModule, options.boardId);
554
+ if (!activeModule || !boardId) {
555
+ return false;
556
+ }
557
+
558
+ const nodes = [];
559
+ const searchNodes = [];
560
+ activeModule.nodeObjectsById?.forEach?.((entry, nodeId) => {
561
+ const snapshot = buildWorkerNodeSnapshot(entry, nodeId);
562
+ if (snapshot) {
563
+ nodes.push(snapshot);
564
+ }
565
+
566
+ const searchSnapshot = buildWorkerSearchSnapshot(entry, nodeId);
567
+ if (searchSnapshot) {
568
+ searchNodes.push(searchSnapshot);
569
+ }
570
+ });
571
+
572
+ const payload = {
573
+ type: 'REBUILD_BOARD',
574
+ boardId,
575
+ reason: String(options.reason || 'rebuild-node-tables'),
576
+ cellSize: Math.max(1, Number(activeModule.GRID_CELL_SIZE || 500)),
577
+ nodes
578
+ };
579
+
580
+ const postedVisibility = this._post(this._visibilityWorker, payload);
581
+ const postedLodPlan = this._post(this._lodPlanWorker, payload);
582
+ const postedSearch = this._post(this._searchWorker, {
583
+ type: 'REBUILD_BOARD',
584
+ boardId,
585
+ reason: String(options.reason || 'rebuild-search-index'),
586
+ nodes: searchNodes
587
+ });
588
+ if (postedVisibility || postedLodPlan || postedSearch) {
589
+ activeModule._visibilityWorkerPrimed = false;
590
+ this._clearHitTestCache(activeModule);
591
+ }
592
+ return postedVisibility || postedLodPlan || postedSearch;
593
+ }
594
+
595
+ upsertNodeEntry(entry, module = this.module, options = {}) {
596
+ const activeModule = module || this.module;
597
+ const boardId = this._resolveBoardId(activeModule, options.boardId);
598
+ if (!activeModule || !boardId) {
599
+ return false;
600
+ }
601
+
602
+ const snapshot = buildWorkerNodeSnapshot(
603
+ entry,
604
+ options.nodeId,
605
+ options.bounds || null,
606
+ options.cellKeys || null
607
+ );
608
+ const searchSnapshot = buildWorkerSearchSnapshot(
609
+ entry,
610
+ options.nodeId,
611
+ options.bounds || null
612
+ );
613
+ if (!snapshot && !searchSnapshot) {
614
+ return false;
615
+ }
616
+
617
+ let postedVisibility = false;
618
+ let postedLodPlan = false;
619
+ let postedSearch = false;
620
+ if (snapshot) {
621
+ const payload = {
622
+ type: 'UPSERT_NODE',
623
+ boardId,
624
+ node: snapshot
625
+ };
626
+ postedVisibility = this._post(this._visibilityWorker, payload);
627
+ postedLodPlan = this._post(this._lodPlanWorker, payload);
628
+ }
629
+ if (searchSnapshot) {
630
+ postedSearch = this._post(this._searchWorker, {
631
+ type: 'UPSERT_NODE',
632
+ boardId,
633
+ node: searchSnapshot
634
+ });
635
+ }
636
+ if (postedVisibility || postedLodPlan) {
637
+ this._clearHitTestCache(activeModule);
638
+ }
639
+ return postedVisibility || postedLodPlan || postedSearch;
640
+ }
641
+
642
+ removeNode(nodeId, module = this.module, options = {}) {
643
+ const boardId = this._resolveBoardId(module, options.boardId);
644
+ const normalizedNodeId = String(nodeId || '').trim();
645
+ if (!boardId || !normalizedNodeId) {
646
+ return false;
647
+ }
648
+
649
+ const payload = {
650
+ type: 'REMOVE_NODE',
651
+ boardId,
652
+ nodeId: normalizedNodeId
653
+ };
654
+
655
+ const postedVisibility = this._post(this._visibilityWorker, payload);
656
+ const postedLodPlan = this._post(this._lodPlanWorker, payload);
657
+ const postedSearch = this._post(this._searchWorker, payload);
658
+ if (postedVisibility || postedLodPlan) {
659
+ this._clearHitTestCache(module || this.module);
660
+ }
661
+ return postedVisibility || postedLodPlan || postedSearch;
662
+ }
663
+
664
+ batchSyncSearchNodes(boardId, nodes = null, removedIds = null) {
665
+ if (this._searchDisabled || !this._searchWorker) {
666
+ return false;
667
+ }
668
+
669
+ const normalizedBoardId = this._resolveBoardId(this.module, boardId);
670
+ if (!normalizedBoardId) {
671
+ return false;
672
+ }
673
+
674
+ const normalizedNodes = Array.isArray(nodes)
675
+ ? nodes.map((node) => buildWorkerSearchSnapshot(node)).filter(Boolean)
676
+ : [];
677
+ const normalizedRemovedIds = Array.isArray(removedIds)
678
+ ? removedIds.map((nodeId) => String(nodeId || '').trim()).filter(Boolean)
679
+ : [];
680
+ if (normalizedNodes.length === 0 && normalizedRemovedIds.length === 0) {
681
+ return false;
682
+ }
683
+
684
+ return this._post(this._searchWorker, {
685
+ type: 'BATCH_SYNC',
686
+ boardId: normalizedBoardId,
687
+ nodes: normalizedNodes,
688
+ removedIds: normalizedRemovedIds
689
+ });
690
+ }
691
+
692
+ requestVisibility(module = this.module, camera) {
693
+ if (this._visibilityDisabled || !this._visibilityReady) {
694
+ return false;
695
+ }
696
+
697
+ const activeModule = module || this.module;
698
+ const boardId = this._resolveBoardId(activeModule);
699
+ if (!activeModule || !camera || !boardId) {
700
+ return false;
701
+ }
702
+
703
+ const viewportWidth = Math.max(1, Number(activeModule.container?.clientWidth || activeModule._lastViewportWidth || 1));
704
+ const viewportHeight = Math.max(1, Number(activeModule.container?.clientHeight || activeModule._lastViewportHeight || 1));
705
+ const now = (typeof performance !== 'undefined' && typeof performance.now === 'function')
706
+ ? performance.now()
707
+ : Date.now();
708
+ const isCtrlWheelVerticalScrolling =
709
+ (now - Number(activeModule._ctrlWheelScrollInputTime || 0)) <= CTRL_WHEEL_SCROLL_ACTIVE_WINDOW_MS;
710
+ const seq = ++this._latestVisibilityRequestSeq;
711
+
712
+ const payload = {
713
+ type: 'VISIBILITY_QUERY',
714
+ boardId,
715
+ seq,
716
+ cellSize: Math.max(1, Number(activeModule.GRID_CELL_SIZE || 500)),
717
+ camera: {
718
+ x: Number(camera.position?.x || 0),
719
+ y: Number(camera.position?.y || 0),
720
+ z: Number(camera.position?.z || 0),
721
+ near: Number(camera.near || 0),
722
+ far: Number(camera.far || Number.MAX_SAFE_INTEGER),
723
+ fov: Number(camera.fov || 45),
724
+ aspect: Math.max(0.1, Number(camera.aspect || 1)),
725
+ viewportW: viewportWidth,
726
+ viewportH: viewportHeight
727
+ },
728
+ state: {
729
+ isPanning: activeModule.isPanning === true,
730
+ isZooming: activeModule.isZooming === true,
731
+ isWindowResizing: activeModule.isWindowResizing === true,
732
+ isResizing: activeModule.isResizing === true,
733
+ isFullResMode: activeModule.lodRenderer?.isInLODMode !== true,
734
+ isCtrlWheelVerticalScrolling,
735
+ lastCtrlWheelDeltaY: Number(activeModule._ctrlWheelScrollLastDeltaY || 0),
736
+ lastPanWorldDeltaX: Number(activeModule._lastPanWorldDeltaX || 0),
737
+ lastPanWorldDeltaY: Number(activeModule._lastPanWorldDeltaY || 0)
738
+ }
739
+ };
740
+
741
+ if (this._visibilityQueryPending === true) {
742
+ this._deferredVisibilityPayload = payload;
743
+ return true;
744
+ }
745
+
746
+ const posted = this._post(this._visibilityWorker, this._stampVisibilityPayloadForPost(payload));
747
+ this._visibilityQueryPending = posted;
748
+ return posted;
749
+ }
750
+
751
+ _flushDeferredVisibilityRequest() {
752
+ if (!this._deferredVisibilityPayload || !this._visibilityWorker || this._visibilityDisabled || !this._visibilityReady) {
753
+ return;
754
+ }
755
+
756
+ const payload = this._deferredVisibilityPayload;
757
+ this._deferredVisibilityPayload = null;
758
+ const posted = this._post(this._visibilityWorker, this._stampVisibilityPayloadForPost(payload));
759
+ this._visibilityQueryPending = posted;
760
+ }
761
+
762
+ _describeHitTestQuery(module = this.module, options = {}) {
763
+ const activeModule = module || this.module;
764
+ const boardId = this._resolveBoardId(activeModule);
765
+ const point = options.point || null;
766
+ const pointX = Number(point?.x);
767
+ const pointY = Number(point?.y);
768
+ if (!activeModule || !boardId || !Number.isFinite(pointX) || !Number.isFinite(pointY)) {
769
+ return null;
770
+ }
771
+
772
+ const cellSize = Math.max(1, Number(activeModule.GRID_CELL_SIZE || 500));
773
+ const cellRadius = Math.max(0, Math.min(3, Math.round(Number(options.cellRadius || 1))));
774
+ const cellX = Math.floor(pointX / cellSize);
775
+ const cellY = Math.floor(pointY / cellSize);
776
+
777
+ return {
778
+ boardId,
779
+ cellRadius,
780
+ cellSize,
781
+ cellX,
782
+ cellY,
783
+ rangeKey: `${cellX}:${cellY}:${cellRadius}`
784
+ };
785
+ }
786
+
787
+ primeHitTestCandidates(module = this.module, options = {}) {
788
+ if (this._visibilityDisabled || !this._visibilityReady) {
789
+ return false;
790
+ }
791
+
792
+ const activeModule = module || this.module;
793
+ const query = this._describeHitTestQuery(activeModule, options);
794
+ if (!activeModule || !query) {
795
+ return false;
796
+ }
797
+
798
+ if (String(activeModule._workerHitTestBoardId || '') === query.boardId &&
799
+ String(activeModule._workerHitTestRangeKey || '') === query.rangeKey) {
800
+ return true;
801
+ }
802
+
803
+ const payload = {
804
+ type: 'HIT_TEST_QUERY',
805
+ boardId: query.boardId,
806
+ seq: ++this._latestHitTestRequestSeq,
807
+ cellX: query.cellX,
808
+ cellY: query.cellY,
809
+ cellRadius: query.cellRadius
810
+ };
811
+
812
+ if (this._hitTestQueryPending === true) {
813
+ this._deferredHitTestPayload = payload;
814
+ return true;
815
+ }
816
+
817
+ const posted = this._post(this._visibilityWorker, payload);
818
+ this._hitTestQueryPending = posted;
819
+ return posted;
820
+ }
821
+
822
+ _flushDeferredHitTestRequest() {
823
+ if (!this._deferredHitTestPayload || !this._visibilityWorker || this._visibilityDisabled || !this._visibilityReady) {
824
+ return;
825
+ }
826
+
827
+ const payload = this._deferredHitTestPayload;
828
+ this._deferredHitTestPayload = null;
829
+ const posted = this._post(this._visibilityWorker, payload);
830
+ this._hitTestQueryPending = posted;
831
+ }
832
+
833
+ getCachedHitTestCandidateIds(module = this.module, options = {}) {
834
+ const activeModule = module || this.module;
835
+ const query = this._describeHitTestQuery(activeModule, options);
836
+ if (!activeModule || !query) {
837
+ return null;
838
+ }
839
+
840
+ if (String(activeModule._workerHitTestBoardId || '') !== query.boardId) {
841
+ return null;
842
+ }
843
+
844
+ if (String(activeModule._workerHitTestRangeKey || '') !== query.rangeKey) {
845
+ return null;
846
+ }
847
+
848
+ return Array.isArray(activeModule._workerHitTestCandidateIds)
849
+ ? activeModule._workerHitTestCandidateIds.slice()
850
+ : [];
851
+ }
852
+
853
+ requestSelectionQuery(module = this.module, options = {}) {
854
+ if (this._visibilityDisabled || !this._visibilityReady) {
855
+ return Promise.resolve(null);
856
+ }
857
+
858
+ const activeModule = module || this.module;
859
+ const boardId = this._resolveBoardId(activeModule);
860
+ const selectionRect = options.selectionRect || null;
861
+ if (!activeModule || !boardId || !selectionRect) {
862
+ return Promise.resolve(null);
863
+ }
864
+
865
+ const payload = {
866
+ type: 'SELECTION_QUERY',
867
+ boardId,
868
+ seq: ++this._latestSelectionRequestSeq,
869
+ cellSize: Math.max(1, Number(activeModule.GRID_CELL_SIZE || 500)),
870
+ selectionRect: {
871
+ left: Number(selectionRect.left || 0),
872
+ right: Number(selectionRect.right || 0),
873
+ bottom: Number(selectionRect.bottom || 0),
874
+ top: Number(selectionRect.top || 0)
875
+ }
876
+ };
877
+
878
+ return new Promise((resolve) => {
879
+ this._pendingSelectionResolvers.set(payload.seq, resolve);
880
+ const posted = this._post(this._visibilityWorker, payload);
881
+ if (!posted) {
882
+ this._pendingSelectionResolvers.delete(payload.seq);
883
+ resolve(null);
884
+ }
885
+ });
886
+ }
887
+
888
+ requestLodPlan(module = this.module, options = {}) {
889
+ if (this._lodPlanDisabled || !this._lodPlanReady) {
890
+ return false;
891
+ }
892
+
893
+ const activeModule = module || this.module;
894
+ const boardId = this._resolveBoardId(activeModule);
895
+ const visibleIds = options.visibleIds instanceof Set
896
+ ? Array.from(options.visibleIds)
897
+ : Array.isArray(options.visibleIds)
898
+ ? options.visibleIds
899
+ : [];
900
+ const key = String(options.key || '').trim();
901
+
902
+ if (!activeModule || !boardId || !key || visibleIds.length === 0 && Number(options.totalNodeCount || 0) === 0) {
903
+ return false;
904
+ }
905
+
906
+ if (this._pendingLodPlanKey === key) {
907
+ return true;
908
+ }
909
+
910
+ this._pendingLodPlanKey = key;
911
+ const seq = ++this._latestLodPlanRequestSeq;
912
+ return this._post(this._lodPlanWorker, {
913
+ type: 'LOD_PLAN_QUERY',
914
+ boardId,
915
+ seq,
916
+ key,
917
+ visibilityVersion: Number(options.visibilityVersion || 0),
918
+ lodBand: String(options.lodBand || '').trim(),
919
+ selectionKey: String(options.selectionKey || '').trim(),
920
+ totalNodeCount: Number(options.totalNodeCount || 0),
921
+ visibleIds: visibleIds.map((id) => String(id || '').trim()).filter(Boolean)
922
+ });
923
+ }
924
+
925
+ requestNodeSearch(module = this.module, options = {}) {
926
+ if (this._searchDisabled || !this._searchReady) {
927
+ return Promise.resolve(null);
928
+ }
929
+
930
+ const activeModule = module || this.module;
931
+ const boardId = this._resolveBoardId(activeModule);
932
+ const query = String(options.query || '').trim();
933
+ if (!activeModule || !boardId || !query) {
934
+ return Promise.resolve(null);
935
+ }
936
+
937
+ const seq = ++this._latestSearchRequestSeq;
938
+ const limit = Math.max(1, Number(options.limit || 12));
939
+ const contentTypes = Array.isArray(options.contentTypes)
940
+ ? options.contentTypes.map((value) => String(value || '').trim().toLowerCase()).filter(Boolean)
941
+ : [];
942
+ const payload = {
943
+ type: 'SEARCH_QUERY',
944
+ boardId,
945
+ seq,
946
+ query,
947
+ limit,
948
+ contentTypes,
949
+ camera: {
950
+ x: Number(activeModule.camera?.position?.x || 0),
951
+ y: Number(activeModule.camera?.position?.y || 0),
952
+ z: Number(activeModule.camera?.position?.z || 0),
953
+ aspect: Math.max(0.1, Number(activeModule.camera?.aspect || 1))
954
+ }
955
+ };
956
+
957
+ return new Promise((resolve) => {
958
+ this._pendingSearchResolvers.set(seq, resolve);
959
+ const posted = this._post(this._searchWorker, payload);
960
+ if (!posted) {
961
+ this._pendingSearchResolvers.delete(seq);
962
+ resolve(null);
963
+ }
964
+ });
965
+ }
966
+ }
967
+
968
+ window.MindMapLogicWorkers = Object.assign(window.MindMapLogicWorkers || {}, {
969
+ BUILD_ID: LOGIC_WORKER_BRIDGE_BUILD_ID,
970
+ createBridge(module) {
971
+ return new MindMapLogicWorkerBridge(module);
972
+ },
973
+ buildWorkerNodeSnapshot,
974
+ buildWorkerSearchSnapshot,
975
+ isTextLikeContentType
976
+ });
977
+ })();