@mindexec/cli 0.2.483 → 0.2.494
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/codex-runtime.js +6 -2
- package/electron/main.cjs +56 -32
- package/electron/preload.cjs +178 -0
- package/electron/source-smoke.mjs +14 -1
- package/electron/windows-package-smoke.mjs +16 -0
- package/package.json +11 -10
- package/remote-fast/osx-arm64/mindexec-remote-fast.dll +0 -0
- package/remote-fast/osx-x64/mindexec-remote-fast.dll +0 -0
- package/remote-fast/win-x64/mindexec-remote-fast.dll +0 -0
- package/wwwroot/_content/MindExecution.Shared/css/app.css +1 -1
- package/wwwroot/_content/MindExecution.Shared/js/canvas-chat-task-switch.js +122 -0
- package/wwwroot/_content/MindExecution.Shared/js/mind-map-css3d-manager.js +161 -16
- package/wwwroot/_content/MindExecution.Shared/js/mind-map-interactions.js +68 -2
- package/wwwroot/_content/MindExecution.Shared/js/mind-map-lod-plan-worker.js +44 -8
- package/wwwroot/_content/MindExecution.Shared/js/mind-map-logic-workers.js +823 -111
- package/wwwroot/_content/MindExecution.Shared/js/mind-map-native-core-bridge.js +399 -0
- package/wwwroot/_content/MindExecution.Shared/js/mind-map-node-search-worker.js +53 -10
- package/wwwroot/_content/MindExecution.Shared/js/mind-map-visibility-worker.js +71 -11
- package/wwwroot/_content/MindExecution.Shared/native-core/mindexec-core-simd.js +18 -0
- package/wwwroot/_content/MindExecution.Shared/native-core/mindexec-core-simd.wasm +0 -0
- package/wwwroot/_content/MindExecution.Shared/native-core/mindexec-core.js +18 -0
- package/wwwroot/_content/MindExecution.Shared/native-core/mindexec-core.wasm +0 -0
- package/wwwroot/_content/MindExecution.Shared/native-core/mindexec-native-core-adapter.js +566 -0
- package/wwwroot/_content/MindExecution.Shared/native-core/mindexec-native-core-worker.js +89 -0
- package/wwwroot/_content/MindExecution.Shared/native-core/native-core-manifest.json +59 -0
- package/wwwroot/_framework/BenchmarkUtils.ytz7pn9azy.dll +0 -0
- package/wwwroot/_framework/Edgar.9yqq548b45.dll +0 -0
- package/wwwroot/_framework/GraphPlanarityTesting.lgk3vd0bh9.dll +0 -0
- package/wwwroot/_framework/Microsoft.Win32.SystemEvents.f8qhom7uq5.dll +0 -0
- package/wwwroot/_framework/{MindExecution.Core.zs4n1f9hjc.dll → MindExecution.Core.tre9kny2uo.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Kernel.l9idvg7mp7.dll → MindExecution.Kernel.lvfnhwdksf.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Plugins.Admin.l37qx5d8zi.dll → MindExecution.Plugins.Admin.k2vbe4lt64.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Plugins.Business.d7b282yazn.dll → MindExecution.Plugins.Business.u7i3r45xp5.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Plugins.Concept.iw98n0qz5k.dll → MindExecution.Plugins.Concept.7eoasvev17.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Plugins.Directory.cqgn6pa8di.dll → MindExecution.Plugins.Directory.rhh13u0z6c.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Plugins.PlanMaster.j8xoa8nl57.dll → MindExecution.Plugins.PlanMaster.xzl2x2cqk4.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Plugins.YouTube.zvpzk7om4z.dll → MindExecution.Plugins.YouTube.945tf0zc9m.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Shared.ovot7q606x.dll → MindExecution.Shared.e0w408b0ti.dll} +0 -0
- package/wwwroot/_framework/{MindExecution.Web.bzuaz35jv0.dll → MindExecution.Web.vc6ux7xjcw.dll} +0 -0
- package/wwwroot/_framework/RangeTree.iw8h1x5u2y.dll +0 -0
- package/wwwroot/_framework/System.Collections.Concurrent.jzwteolu29.dll +0 -0
- package/wwwroot/_framework/System.Collections.NonGeneric.uqtvwssxuq.dll +0 -0
- package/wwwroot/_framework/System.Collections.Specialized.85qtrfslgb.dll +0 -0
- package/wwwroot/_framework/System.Collections.xmhu72xgrp.dll +0 -0
- package/wwwroot/_framework/System.ComponentModel.Primitives.excbd02v5j.dll +0 -0
- package/wwwroot/_framework/System.ComponentModel.TypeConverter.ek2jcwibb9.dll +0 -0
- package/wwwroot/_framework/System.ComponentModel.wfe9zz2icv.dll +0 -0
- package/wwwroot/_framework/System.Console.5j283so6ps.dll +0 -0
- package/wwwroot/_framework/System.Drawing.Common.xzizafq144.dll +0 -0
- package/wwwroot/_framework/System.Private.CoreLib.7ouudb2fbl.dll +0 -0
- package/wwwroot/_framework/{System.Text.RegularExpressions.cvkox11l6l.dll → System.Text.RegularExpressions.b0vqxbob08.dll} +0 -0
- package/wwwroot/_framework/System.Threading.Tasks.Parallel.9tqazg1b0u.dll +0 -0
- package/wwwroot/_framework/System.Threading.Tasks.zl4yo3otxa.dll +0 -0
- package/wwwroot/_framework/YamlDotNet.dtey92juka.dll +0 -0
- package/wwwroot/_framework/blazor.boot.json +63 -45
- package/wwwroot/_framework/{dotnet.native.60hhmnxyoo.wasm → dotnet.native.58bvs6q392.wasm} +0 -0
- package/wwwroot/_framework/netstandard.he3m3p1s9q.dll +0 -0
- package/wwwroot/index.html +2 -1
- package/wwwroot/service-worker-assets.js +128 -56
- package/wwwroot/service-worker.js +1 -1
- package/wwwroot/_framework/System.Collections.3iuoxbe8my.dll +0 -0
- package/wwwroot/_framework/System.Collections.Concurrent.vow3rm1dku.dll +0 -0
- package/wwwroot/_framework/System.Collections.NonGeneric.npjkaz40oc.dll +0 -0
- package/wwwroot/_framework/System.Collections.Specialized.ugkjbs6p02.dll +0 -0
- package/wwwroot/_framework/System.ComponentModel.Primitives.end4v0xe2c.dll +0 -0
- package/wwwroot/_framework/System.ComponentModel.TypeConverter.tgtp5sm4iv.dll +0 -0
- package/wwwroot/_framework/System.ComponentModel.wupoltkk1t.dll +0 -0
- package/wwwroot/_framework/System.Console.9dik0wogo2.dll +0 -0
- package/wwwroot/_framework/System.Private.CoreLib.7s8wte759y.dll +0 -0
- package/wwwroot/_framework/netstandard.b50t77veor.dll +0 -0
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
(function (global) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const API_VERSION = 1;
|
|
5
|
+
const GEOMETRY_STRIDE = 9;
|
|
6
|
+
const STATUS_STALE = 0;
|
|
7
|
+
const STATUS_OK = 1;
|
|
8
|
+
const NODE_TEXT_LIKE = 1 << 0;
|
|
9
|
+
const NODE_IMAGE = 1 << 1;
|
|
10
|
+
const VISIBILITY_PANNING = 1 << 0;
|
|
11
|
+
const VISIBILITY_ZOOMING = 1 << 1;
|
|
12
|
+
const VISIBILITY_WINDOW_RESIZING = 1 << 2;
|
|
13
|
+
const VISIBILITY_NODE_RESIZING = 1 << 3;
|
|
14
|
+
const VISIBILITY_FULL_RES = 1 << 4;
|
|
15
|
+
const VISIBILITY_CTRL_WHEEL_SCROLLING = 1 << 5;
|
|
16
|
+
|
|
17
|
+
const ARRAY = Object.freeze({
|
|
18
|
+
visible: 1,
|
|
19
|
+
entered: 2,
|
|
20
|
+
exited: 3,
|
|
21
|
+
priority: 4,
|
|
22
|
+
hit: 5,
|
|
23
|
+
selection: 6
|
|
24
|
+
});
|
|
25
|
+
const INTEGER = Object.freeze({
|
|
26
|
+
visibleCount: 1,
|
|
27
|
+
visibilityChanged: 2,
|
|
28
|
+
nodeCount: 3,
|
|
29
|
+
reconcilePending: 4,
|
|
30
|
+
omitVisibleIds: 5,
|
|
31
|
+
priorityChanged: 6,
|
|
32
|
+
useCoarseVisibility: 7,
|
|
33
|
+
gridSpanX: 8,
|
|
34
|
+
gridSpanY: 9,
|
|
35
|
+
directGridLookups: 10,
|
|
36
|
+
usedPopulatedCellScan: 11,
|
|
37
|
+
incrementalPanMode: 12,
|
|
38
|
+
incrementalPanBandCount: 13,
|
|
39
|
+
incrementalPanCellLookups: 14,
|
|
40
|
+
candidateCount: 15,
|
|
41
|
+
previousVisibleCount: 16,
|
|
42
|
+
cellLookups: 17,
|
|
43
|
+
cellRadius: 18,
|
|
44
|
+
spatialGridCellCount: 19
|
|
45
|
+
});
|
|
46
|
+
const NUMBER = Object.freeze({
|
|
47
|
+
durationMs: 1,
|
|
48
|
+
cameraZ: 2,
|
|
49
|
+
marginWorld: 3,
|
|
50
|
+
viewLeft: 4,
|
|
51
|
+
viewRight: 5,
|
|
52
|
+
viewBottom: 6,
|
|
53
|
+
viewTop: 7
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function normalizeBoardId(value) {
|
|
57
|
+
return String(value ?? '').trim();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function normalizeToken(value) {
|
|
61
|
+
const number = Number(value || 0);
|
|
62
|
+
return Number.isFinite(number) && number > 0
|
|
63
|
+
? Math.floor(number) >>> 0
|
|
64
|
+
: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function normalizeRevision(value) {
|
|
68
|
+
const number = Number(value || 0);
|
|
69
|
+
return Number.isFinite(number) && number >= 0
|
|
70
|
+
? Math.floor(number) >>> 0
|
|
71
|
+
: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function normalizeNode(node) {
|
|
75
|
+
if (!node || typeof node !== 'object') return null;
|
|
76
|
+
const id = String(node.id || '').trim();
|
|
77
|
+
if (!id) return null;
|
|
78
|
+
const minX = Number(node.minX ?? 0);
|
|
79
|
+
const maxX = Number(node.maxX ?? minX);
|
|
80
|
+
const minY = Number(node.minY ?? 0);
|
|
81
|
+
const maxY = Number(node.maxY ?? minY);
|
|
82
|
+
const contentType = String(node.contentType || '').trim().toLowerCase();
|
|
83
|
+
let flags = 0;
|
|
84
|
+
if (node.textLike === true) flags |= NODE_TEXT_LIKE;
|
|
85
|
+
if (contentType === 'image') flags |= NODE_IMAGE;
|
|
86
|
+
const geometry = [
|
|
87
|
+
Number(node.x ?? minX),
|
|
88
|
+
Number(node.y ?? maxY),
|
|
89
|
+
Number(node.z ?? 0),
|
|
90
|
+
Math.max(1, Number(node.width ?? (maxX - minX) ?? 1)),
|
|
91
|
+
Math.max(1, Number(node.height ?? (maxY - minY) ?? 1)),
|
|
92
|
+
minX,
|
|
93
|
+
maxX,
|
|
94
|
+
minY,
|
|
95
|
+
maxY
|
|
96
|
+
];
|
|
97
|
+
if (geometry.some((value) => !Number.isFinite(value)) ||
|
|
98
|
+
geometry[3] <= 0 || geometry[4] <= 0 ||
|
|
99
|
+
geometry[6] < geometry[5] || geometry[8] < geometry[7]) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
id,
|
|
104
|
+
flags,
|
|
105
|
+
geometry
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function roundProfile(value) {
|
|
110
|
+
const number = Number(value || 0);
|
|
111
|
+
return Number(Math.max(0, number).toFixed(2));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function requireFiniteNumber(value, fallback, label) {
|
|
115
|
+
const number = Number(value ?? fallback);
|
|
116
|
+
if (!Number.isFinite(number)) {
|
|
117
|
+
throw new Error(`Invalid native ${label}.`);
|
|
118
|
+
}
|
|
119
|
+
return number;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function create(module, options = {}) {
|
|
123
|
+
if (!module || typeof module._me_context_create !== 'function') {
|
|
124
|
+
throw new Error('MindExecution C++ core exports are unavailable.');
|
|
125
|
+
}
|
|
126
|
+
if (Number(module._me_core_api_version()) !== API_VERSION) {
|
|
127
|
+
throw new Error(`MindExecution C++ core ABI mismatch (expected ${API_VERSION}).`);
|
|
128
|
+
}
|
|
129
|
+
if (Number(module._me_node_geometry_stride()) !== GEOMETRY_STRIDE) {
|
|
130
|
+
throw new Error(`MindExecution C++ geometry stride mismatch (expected ${GEOMETRY_STRIDE}).`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const emit = typeof options.postMessage === 'function'
|
|
134
|
+
? options.postMessage
|
|
135
|
+
: (payload) => global.postMessage(payload);
|
|
136
|
+
const context = module._me_context_create(500);
|
|
137
|
+
if (!context) throw new Error('MindExecution C++ core context creation failed.');
|
|
138
|
+
|
|
139
|
+
let disposed = false;
|
|
140
|
+
let boardId = '';
|
|
141
|
+
let boardEpoch = 0;
|
|
142
|
+
let engineGeneration = 0;
|
|
143
|
+
let boardRevision = 0;
|
|
144
|
+
let nextHandle = 1;
|
|
145
|
+
const handleById = new Map();
|
|
146
|
+
const idByHandle = [''];
|
|
147
|
+
|
|
148
|
+
function intResult(kind) {
|
|
149
|
+
return Number(module._me_result_integer(context, kind) || 0);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function numberResult(kind) {
|
|
153
|
+
return Number(module._me_result_number(context, kind) || 0);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function handleResult(kind) {
|
|
157
|
+
const count = Number(module._me_result_count(context, kind) || 0);
|
|
158
|
+
const pointer = Number(module._me_result_data(context, kind) || 0);
|
|
159
|
+
if (!Number.isInteger(count) || count < 0) {
|
|
160
|
+
throw new Error(`Invalid C++ result count for kind ${kind}.`);
|
|
161
|
+
}
|
|
162
|
+
if (count === 0) return [];
|
|
163
|
+
if (pointer <= 0) {
|
|
164
|
+
throw new Error(`Missing C++ result data for kind ${kind}.`);
|
|
165
|
+
}
|
|
166
|
+
const handles = module.HEAPU32.subarray(pointer >>> 2, (pointer >>> 2) + count);
|
|
167
|
+
const ids = [];
|
|
168
|
+
const seenHandles = new Set();
|
|
169
|
+
for (let index = 0; index < handles.length; index++) {
|
|
170
|
+
const handle = Number(handles[index] || 0);
|
|
171
|
+
const id = String(idByHandle[handle] || '').trim();
|
|
172
|
+
if (handle <= 0 || !id || seenHandles.has(handle)) {
|
|
173
|
+
throw new Error(`Invalid C++ result handle for kind ${kind}.`);
|
|
174
|
+
}
|
|
175
|
+
seenHandles.add(handle);
|
|
176
|
+
ids.push(id);
|
|
177
|
+
}
|
|
178
|
+
return ids;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function ensureHandle(id) {
|
|
182
|
+
let handle = Number(handleById.get(id) || 0);
|
|
183
|
+
if (handle > 0) return handle;
|
|
184
|
+
handle = nextHandle++;
|
|
185
|
+
handleById.set(id, handle);
|
|
186
|
+
idByHandle[handle] = id;
|
|
187
|
+
return handle;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function resetHandles() {
|
|
191
|
+
nextHandle = 1;
|
|
192
|
+
handleById.clear();
|
|
193
|
+
idByHandle.length = 1;
|
|
194
|
+
idByHandle[0] = '';
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function captureOwner(message) {
|
|
198
|
+
boardId = normalizeBoardId(message.boardId);
|
|
199
|
+
boardEpoch = normalizeToken(message.boardEpoch);
|
|
200
|
+
engineGeneration = normalizeToken(message.engineGeneration);
|
|
201
|
+
boardRevision = normalizeRevision(message.boardRevision);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function ownerMatches(message) {
|
|
205
|
+
return normalizeBoardId(message.boardId) === boardId &&
|
|
206
|
+
normalizeToken(message.boardEpoch) === boardEpoch &&
|
|
207
|
+
normalizeToken(message.engineGeneration) === engineGeneration;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function postStale(type, message) {
|
|
211
|
+
emit({
|
|
212
|
+
type,
|
|
213
|
+
boardId: normalizeBoardId(message.boardId),
|
|
214
|
+
boardEpoch: normalizeToken(message.boardEpoch),
|
|
215
|
+
engineGeneration: normalizeToken(message.engineGeneration),
|
|
216
|
+
boardRevision: normalizeRevision(message.boardRevision),
|
|
217
|
+
seq: normalizeToken(message.seq),
|
|
218
|
+
stale: true,
|
|
219
|
+
coreBackend: options.backend || 'wasm'
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function withBoardArrays(nodes, callback) {
|
|
224
|
+
const normalized = [];
|
|
225
|
+
const source = Array.isArray(nodes) ? nodes : [];
|
|
226
|
+
for (let index = 0; index < source.length; index++) {
|
|
227
|
+
const node = normalizeNode(source[index]);
|
|
228
|
+
if (!node) throw new Error(`Invalid native node snapshot at index ${index}.`);
|
|
229
|
+
normalized.push(node);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const handles = new Uint32Array(normalized.length);
|
|
233
|
+
const flags = new Uint32Array(normalized.length);
|
|
234
|
+
const geometry = new Float64Array(normalized.length * GEOMETRY_STRIDE);
|
|
235
|
+
for (let index = 0; index < normalized.length; index++) {
|
|
236
|
+
handles[index] = ensureHandle(normalized[index].id);
|
|
237
|
+
flags[index] = normalized[index].flags;
|
|
238
|
+
geometry.set(normalized[index].geometry, index * GEOMETRY_STRIDE);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const handlesPointer = handles.byteLength > 0 ? module._malloc(handles.byteLength) : 0;
|
|
242
|
+
const flagsPointer = flags.byteLength > 0 ? module._malloc(flags.byteLength) : 0;
|
|
243
|
+
const geometryPointer = geometry.byteLength > 0 ? module._malloc(geometry.byteLength) : 0;
|
|
244
|
+
try {
|
|
245
|
+
if (handlesPointer) module.HEAPU32.set(handles, handlesPointer >>> 2);
|
|
246
|
+
if (flagsPointer) module.HEAPU32.set(flags, flagsPointer >>> 2);
|
|
247
|
+
if (geometryPointer) module.HEAPF64.set(geometry, geometryPointer >>> 3);
|
|
248
|
+
return callback(normalized.length, handlesPointer, flagsPointer, geometryPointer);
|
|
249
|
+
} finally {
|
|
250
|
+
if (geometryPointer) module._free(geometryPointer);
|
|
251
|
+
if (flagsPointer) module._free(flagsPointer);
|
|
252
|
+
if (handlesPointer) module._free(handlesPointer);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function handleReset(message) {
|
|
257
|
+
captureOwner(message);
|
|
258
|
+
resetHandles();
|
|
259
|
+
const status = module._me_board_reset(
|
|
260
|
+
context,
|
|
261
|
+
boardEpoch,
|
|
262
|
+
engineGeneration,
|
|
263
|
+
boardRevision,
|
|
264
|
+
Math.max(1, Number(message.cellSize || 500))
|
|
265
|
+
);
|
|
266
|
+
if (status !== STATUS_OK) throw new Error(`C++ board reset failed with status ${status}.`);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function handleRebuild(message) {
|
|
270
|
+
captureOwner(message);
|
|
271
|
+
resetHandles();
|
|
272
|
+
withBoardArrays(message.nodes, (count, handles, flags, geometry) => {
|
|
273
|
+
const status = module._me_board_load(
|
|
274
|
+
context,
|
|
275
|
+
boardEpoch,
|
|
276
|
+
engineGeneration,
|
|
277
|
+
boardRevision,
|
|
278
|
+
Math.max(1, Number(message.cellSize || 500)),
|
|
279
|
+
count,
|
|
280
|
+
handles,
|
|
281
|
+
flags,
|
|
282
|
+
geometry
|
|
283
|
+
);
|
|
284
|
+
if (status !== STATUS_OK) throw new Error(`C++ board load failed with status ${status}.`);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function handleUpsert(message) {
|
|
289
|
+
if (!ownerMatches(message)) return;
|
|
290
|
+
const node = normalizeNode(message.node);
|
|
291
|
+
if (!node) throw new Error('Invalid native node upsert snapshot.');
|
|
292
|
+
const revision = normalizeRevision(message.boardRevision);
|
|
293
|
+
const handle = ensureHandle(node.id);
|
|
294
|
+
const g = node.geometry;
|
|
295
|
+
const status = module._me_node_upsert(
|
|
296
|
+
context, boardEpoch, engineGeneration, revision, handle, node.flags,
|
|
297
|
+
g[0], g[1], g[2], g[3], g[4], g[5], g[6], g[7], g[8]
|
|
298
|
+
);
|
|
299
|
+
if (status === STATUS_OK) boardRevision = revision;
|
|
300
|
+
else if (status !== STATUS_STALE) throw new Error(`C++ node upsert failed with status ${status}.`);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function handleRemove(message) {
|
|
304
|
+
if (!ownerMatches(message)) return;
|
|
305
|
+
const id = String(message.nodeId || '').trim();
|
|
306
|
+
if (!id) return;
|
|
307
|
+
const mappedHandle = Number(handleById.get(id) || 0);
|
|
308
|
+
// A valid board mutation must advance the mirrored revision even
|
|
309
|
+
// when this node never entered the native mirror (for example,
|
|
310
|
+
// because its geometry snapshot was invalid). The C++ remove API
|
|
311
|
+
// deliberately accepts an unused non-zero handle as a no-op.
|
|
312
|
+
const handle = mappedHandle > 0 ? mappedHandle : nextHandle;
|
|
313
|
+
const revision = normalizeRevision(message.boardRevision);
|
|
314
|
+
const status = module._me_node_remove(context, boardEpoch, engineGeneration, revision, handle);
|
|
315
|
+
if (status === STATUS_OK) {
|
|
316
|
+
boardRevision = revision;
|
|
317
|
+
if (mappedHandle > 0) {
|
|
318
|
+
handleById.delete(id);
|
|
319
|
+
idByHandle[mappedHandle] = '';
|
|
320
|
+
}
|
|
321
|
+
} else if (status !== STATUS_STALE) throw new Error(`C++ node removal failed with status ${status}.`);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function handleVisibility(message) {
|
|
325
|
+
const camera = message.camera || {};
|
|
326
|
+
const state = message.state || {};
|
|
327
|
+
let stateFlags = 0;
|
|
328
|
+
if (state.isPanning === true) stateFlags |= VISIBILITY_PANNING;
|
|
329
|
+
if (state.isZooming === true) stateFlags |= VISIBILITY_ZOOMING;
|
|
330
|
+
if (state.isWindowResizing === true) stateFlags |= VISIBILITY_WINDOW_RESIZING;
|
|
331
|
+
if (state.isResizing === true) stateFlags |= VISIBILITY_NODE_RESIZING;
|
|
332
|
+
if (state.isFullResMode === true) stateFlags |= VISIBILITY_FULL_RES;
|
|
333
|
+
if (state.isCtrlWheelVerticalScrolling === true) stateFlags |= VISIBILITY_CTRL_WHEEL_SCROLLING;
|
|
334
|
+
const cameraX = requireFiniteNumber(camera.x, 0, 'camera.x');
|
|
335
|
+
const cameraY = requireFiniteNumber(camera.y, 0, 'camera.y');
|
|
336
|
+
const cameraZ = requireFiniteNumber(camera.z, 0, 'camera.z');
|
|
337
|
+
const cameraNear = requireFiniteNumber(camera.near, 0, 'camera.near');
|
|
338
|
+
const cameraFar = requireFiniteNumber(camera.far, Number.MAX_SAFE_INTEGER, 'camera.far');
|
|
339
|
+
const cameraFov = requireFiniteNumber(camera.fov, 45, 'camera.fov');
|
|
340
|
+
const cameraAspect = Math.max(0.1, requireFiniteNumber(camera.aspect, 1, 'camera.aspect'));
|
|
341
|
+
const viewportWidth = Math.max(1, requireFiniteNumber(camera.viewportW, 1, 'camera.viewportW'));
|
|
342
|
+
const viewportHeight = Math.max(1, requireFiniteNumber(camera.viewportH, 1, 'camera.viewportH'));
|
|
343
|
+
const ctrlWheelDeltaY = requireFiniteNumber(state.lastCtrlWheelDeltaY, 0, 'lastCtrlWheelDeltaY');
|
|
344
|
+
const panWorldDeltaX = requireFiniteNumber(state.lastPanWorldDeltaX, 0, 'lastPanWorldDeltaX');
|
|
345
|
+
const panWorldDeltaY = requireFiniteNumber(state.lastPanWorldDeltaY, 0, 'lastPanWorldDeltaY');
|
|
346
|
+
const status = module._me_visibility_query(
|
|
347
|
+
context,
|
|
348
|
+
normalizeToken(message.boardEpoch),
|
|
349
|
+
normalizeToken(message.engineGeneration),
|
|
350
|
+
normalizeRevision(message.boardRevision),
|
|
351
|
+
normalizeToken(message.seq),
|
|
352
|
+
normalizeToken(message.mainLastAppliedSeq),
|
|
353
|
+
cameraX,
|
|
354
|
+
cameraY,
|
|
355
|
+
cameraZ,
|
|
356
|
+
cameraNear,
|
|
357
|
+
cameraFar,
|
|
358
|
+
cameraFov,
|
|
359
|
+
cameraAspect,
|
|
360
|
+
viewportWidth,
|
|
361
|
+
viewportHeight,
|
|
362
|
+
stateFlags,
|
|
363
|
+
ctrlWheelDeltaY,
|
|
364
|
+
panWorldDeltaX,
|
|
365
|
+
panWorldDeltaY
|
|
366
|
+
);
|
|
367
|
+
if (status !== STATUS_OK) {
|
|
368
|
+
if (status !== STATUS_STALE) throw new Error(`C++ visibility query failed with status ${status}.`);
|
|
369
|
+
postStale('VISIBILITY_RESULT', message);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const omitVisibleIds = intResult(INTEGER.omitVisibleIds) === 1;
|
|
374
|
+
const priorityChanged = intResult(INTEGER.priorityChanged) === 1;
|
|
375
|
+
const visibleCount = intResult(INTEGER.visibleCount);
|
|
376
|
+
emit({
|
|
377
|
+
type: 'VISIBILITY_RESULT',
|
|
378
|
+
boardId,
|
|
379
|
+
boardEpoch,
|
|
380
|
+
engineGeneration,
|
|
381
|
+
boardRevision,
|
|
382
|
+
seq: normalizeToken(message.seq),
|
|
383
|
+
visibleIds: omitVisibleIds ? undefined : handleResult(ARRAY.visible),
|
|
384
|
+
visibleCount,
|
|
385
|
+
enteredIds: handleResult(ARRAY.entered),
|
|
386
|
+
exitedIds: handleResult(ARRAY.exited),
|
|
387
|
+
priorityIds: priorityChanged ? handleResult(ARRAY.priority) : undefined,
|
|
388
|
+
visibilityChanged: intResult(INTEGER.visibilityChanged) === 1,
|
|
389
|
+
viewportRect: {
|
|
390
|
+
left: numberResult(NUMBER.viewLeft),
|
|
391
|
+
right: numberResult(NUMBER.viewRight),
|
|
392
|
+
bottom: numberResult(NUMBER.viewBottom),
|
|
393
|
+
top: numberResult(NUMBER.viewTop),
|
|
394
|
+
mode: state.isFullResMode === true ? 'full-res' : 'lod',
|
|
395
|
+
cameraZ
|
|
396
|
+
},
|
|
397
|
+
lastVisibilityNodeCount: intResult(INTEGER.nodeCount),
|
|
398
|
+
fullResVisibilityReconcilePending: intResult(INTEGER.reconcilePending) === 1,
|
|
399
|
+
coreBackend: options.backend || 'wasm',
|
|
400
|
+
profile: {
|
|
401
|
+
durationMs: roundProfile(numberResult(NUMBER.durationMs)),
|
|
402
|
+
cameraZ: Number(numberResult(NUMBER.cameraZ).toFixed(2)),
|
|
403
|
+
useCoarseVisibility: intResult(INTEGER.useCoarseVisibility) === 1,
|
|
404
|
+
marginWorld: Number(numberResult(NUMBER.marginWorld).toFixed(2)),
|
|
405
|
+
gridSpanX: intResult(INTEGER.gridSpanX),
|
|
406
|
+
gridSpanY: intResult(INTEGER.gridSpanY),
|
|
407
|
+
directGridLookups: intResult(INTEGER.directGridLookups),
|
|
408
|
+
usedPopulatedCellScan: intResult(INTEGER.usedPopulatedCellScan) === 1,
|
|
409
|
+
incrementalPanMode: intResult(INTEGER.incrementalPanMode) === 1,
|
|
410
|
+
incrementalPanBandCount: intResult(INTEGER.incrementalPanBandCount),
|
|
411
|
+
incrementalPanCellLookups: intResult(INTEGER.incrementalPanCellLookups),
|
|
412
|
+
omittedFullVisibleIds: omitVisibleIds,
|
|
413
|
+
candidateCount: intResult(INTEGER.candidateCount),
|
|
414
|
+
processedCount: intResult(INTEGER.candidateCount),
|
|
415
|
+
prevVisibleCount: intResult(INTEGER.previousVisibleCount),
|
|
416
|
+
nextVisibleCount: visibleCount,
|
|
417
|
+
visibilityChanged: intResult(INTEGER.visibilityChanged) === 1,
|
|
418
|
+
backend: options.backend || 'wasm'
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function handleHitTest(message) {
|
|
424
|
+
const cellRadius = Math.max(0, Math.min(3, Math.round(
|
|
425
|
+
requireFiniteNumber(message.cellRadius, 1, 'hit cellRadius')
|
|
426
|
+
)));
|
|
427
|
+
const cellX = Math.floor(requireFiniteNumber(message.cellX, 0, 'hit cellX'));
|
|
428
|
+
const cellY = Math.floor(requireFiniteNumber(message.cellY, 0, 'hit cellY'));
|
|
429
|
+
const status = module._me_hit_test_query(
|
|
430
|
+
context,
|
|
431
|
+
normalizeToken(message.boardEpoch),
|
|
432
|
+
normalizeToken(message.engineGeneration),
|
|
433
|
+
normalizeRevision(message.boardRevision),
|
|
434
|
+
cellX,
|
|
435
|
+
cellY,
|
|
436
|
+
cellRadius
|
|
437
|
+
);
|
|
438
|
+
if (status !== STATUS_OK) {
|
|
439
|
+
if (status !== STATUS_STALE) throw new Error(`C++ hit-test query failed with status ${status}.`);
|
|
440
|
+
postStale('HIT_TEST_RESULT', message);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
emit({
|
|
444
|
+
type: 'HIT_TEST_RESULT',
|
|
445
|
+
boardId,
|
|
446
|
+
boardEpoch,
|
|
447
|
+
engineGeneration,
|
|
448
|
+
boardRevision,
|
|
449
|
+
seq: normalizeToken(message.seq),
|
|
450
|
+
cellX,
|
|
451
|
+
cellY,
|
|
452
|
+
cellRadius,
|
|
453
|
+
rangeKey: `${cellX}:${cellY}:${cellRadius}`,
|
|
454
|
+
candidateIds: handleResult(ARRAY.hit),
|
|
455
|
+
coreBackend: options.backend || 'wasm',
|
|
456
|
+
profile: {
|
|
457
|
+
durationMs: roundProfile(numberResult(NUMBER.durationMs)),
|
|
458
|
+
cellLookups: intResult(INTEGER.cellLookups),
|
|
459
|
+
candidateCount: intResult(INTEGER.candidateCount),
|
|
460
|
+
spatialGridCellCount: intResult(INTEGER.spatialGridCellCount),
|
|
461
|
+
backend: options.backend || 'wasm'
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function handleSelection(message) {
|
|
467
|
+
const rect = message.selectionRect || null;
|
|
468
|
+
if (!rect) {
|
|
469
|
+
postStale('SELECTION_QUERY_RESULT', message);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const rectLeft = requireFiniteNumber(rect.left, 0, 'selection left');
|
|
473
|
+
const rectRight = requireFiniteNumber(rect.right, 0, 'selection right');
|
|
474
|
+
const rectBottom = requireFiniteNumber(rect.bottom, 0, 'selection bottom');
|
|
475
|
+
const rectTop = requireFiniteNumber(rect.top, 0, 'selection top');
|
|
476
|
+
const status = module._me_selection_query(
|
|
477
|
+
context,
|
|
478
|
+
normalizeToken(message.boardEpoch),
|
|
479
|
+
normalizeToken(message.engineGeneration),
|
|
480
|
+
normalizeRevision(message.boardRevision),
|
|
481
|
+
rectLeft, rectRight, rectBottom, rectTop
|
|
482
|
+
);
|
|
483
|
+
if (status !== STATUS_OK) {
|
|
484
|
+
if (status !== STATUS_STALE) throw new Error(`C++ selection query failed with status ${status}.`);
|
|
485
|
+
postStale('SELECTION_QUERY_RESULT', message);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const normalizedRect = {
|
|
489
|
+
left: Math.min(rectLeft, rectRight),
|
|
490
|
+
right: Math.max(rectLeft, rectRight),
|
|
491
|
+
bottom: Math.min(rectBottom, rectTop),
|
|
492
|
+
top: Math.max(rectBottom, rectTop)
|
|
493
|
+
};
|
|
494
|
+
const selectedIds = handleResult(ARRAY.selection);
|
|
495
|
+
emit({
|
|
496
|
+
type: 'SELECTION_QUERY_RESULT',
|
|
497
|
+
boardId,
|
|
498
|
+
boardEpoch,
|
|
499
|
+
engineGeneration,
|
|
500
|
+
boardRevision,
|
|
501
|
+
seq: normalizeToken(message.seq),
|
|
502
|
+
selectedIds,
|
|
503
|
+
selectionRect: normalizedRect,
|
|
504
|
+
coreBackend: options.backend || 'wasm',
|
|
505
|
+
profile: {
|
|
506
|
+
durationMs: roundProfile(numberResult(NUMBER.durationMs)),
|
|
507
|
+
candidateCount: intResult(INTEGER.candidateCount),
|
|
508
|
+
selectedCount: selectedIds.length,
|
|
509
|
+
gridSpanX: intResult(INTEGER.gridSpanX),
|
|
510
|
+
gridSpanY: intResult(INTEGER.gridSpanY),
|
|
511
|
+
directGridLookups: intResult(INTEGER.directGridLookups),
|
|
512
|
+
usedPopulatedCellScan: intResult(INTEGER.usedPopulatedCellScan) === 1,
|
|
513
|
+
backend: options.backend || 'wasm'
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function handleMessage(message) {
|
|
519
|
+
if (disposed || !message || typeof message !== 'object') return false;
|
|
520
|
+
switch (String(message.type || '')) {
|
|
521
|
+
case 'RESET_BOARD':
|
|
522
|
+
handleReset(message);
|
|
523
|
+
return true;
|
|
524
|
+
case 'REBUILD_BOARD':
|
|
525
|
+
handleRebuild(message);
|
|
526
|
+
return true;
|
|
527
|
+
case 'UPSERT_NODE':
|
|
528
|
+
handleUpsert(message);
|
|
529
|
+
return true;
|
|
530
|
+
case 'REMOVE_NODE':
|
|
531
|
+
handleRemove(message);
|
|
532
|
+
return true;
|
|
533
|
+
case 'VISIBILITY_QUERY':
|
|
534
|
+
handleVisibility(message);
|
|
535
|
+
return true;
|
|
536
|
+
case 'HIT_TEST_QUERY':
|
|
537
|
+
handleHitTest(message);
|
|
538
|
+
return true;
|
|
539
|
+
case 'SELECTION_QUERY':
|
|
540
|
+
handleSelection(message);
|
|
541
|
+
return true;
|
|
542
|
+
default:
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function dispose() {
|
|
548
|
+
if (disposed) return;
|
|
549
|
+
disposed = true;
|
|
550
|
+
module._me_context_destroy(context);
|
|
551
|
+
resetHandles();
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return {
|
|
555
|
+
handleMessage,
|
|
556
|
+
dispose,
|
|
557
|
+
apiVersion: API_VERSION,
|
|
558
|
+
backend: options.backend || 'wasm'
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
global.MindExecutionNativeCoreAdapter = Object.freeze({
|
|
563
|
+
API_VERSION,
|
|
564
|
+
create
|
|
565
|
+
});
|
|
566
|
+
})(typeof self !== 'undefined' ? self : globalThis);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const NATIVE_CORE_WORKER_BUILD_ID = '20260830-native-core-v004';
|
|
4
|
+
const pendingMessages = [];
|
|
5
|
+
let runtime = null;
|
|
6
|
+
let initializationFailed = false;
|
|
7
|
+
|
|
8
|
+
self.onmessage = function (event) {
|
|
9
|
+
const message = event?.data || null;
|
|
10
|
+
if (!message || typeof message !== 'object' || initializationFailed) return;
|
|
11
|
+
if (!runtime) {
|
|
12
|
+
pendingMessages.push(message);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
runtime.handleMessage(message);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
self.postMessage({
|
|
19
|
+
type: 'NATIVE_CORE_RUNTIME_ERROR',
|
|
20
|
+
message: String(error?.message || error || 'unknown native core error')
|
|
21
|
+
});
|
|
22
|
+
setTimeout(() => { throw error; }, 0);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function runtimeUrl(fileName) {
|
|
27
|
+
return new URL(`./${fileName}?v=${NATIVE_CORE_WORKER_BUILD_ID}`, self.location.href).href;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function locateRuntimeFile(path) {
|
|
31
|
+
return runtimeUrl(path);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function initialize() {
|
|
35
|
+
importScripts(runtimeUrl('mindexec-native-core-adapter.js'));
|
|
36
|
+
importScripts(runtimeUrl('mindexec-core.js'));
|
|
37
|
+
|
|
38
|
+
let simdFactory = null;
|
|
39
|
+
try {
|
|
40
|
+
importScripts(runtimeUrl('mindexec-core-simd.js'));
|
|
41
|
+
simdFactory = typeof self.createMindExecutionCoreSimd === 'function'
|
|
42
|
+
? self.createMindExecutionCoreSimd
|
|
43
|
+
: null;
|
|
44
|
+
} catch {
|
|
45
|
+
simdFactory = null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let module = null;
|
|
49
|
+
let backend = 'wasm-scalar';
|
|
50
|
+
if (simdFactory) {
|
|
51
|
+
try {
|
|
52
|
+
module = await simdFactory({ locateFile: locateRuntimeFile });
|
|
53
|
+
backend = 'wasm-simd';
|
|
54
|
+
} catch {
|
|
55
|
+
module = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!module) {
|
|
59
|
+
if (typeof self.createMindExecutionCore !== 'function') {
|
|
60
|
+
throw new Error('Scalar MindExecution C++ core factory is unavailable.');
|
|
61
|
+
}
|
|
62
|
+
module = await self.createMindExecutionCore({ locateFile: locateRuntimeFile });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
runtime = self.MindExecutionNativeCoreAdapter.create(module, {
|
|
66
|
+
backend,
|
|
67
|
+
postMessage: (payload) => self.postMessage(payload)
|
|
68
|
+
});
|
|
69
|
+
while (pendingMessages.length > 0) {
|
|
70
|
+
runtime.handleMessage(pendingMessages.shift());
|
|
71
|
+
}
|
|
72
|
+
self.postMessage({
|
|
73
|
+
type: 'READY',
|
|
74
|
+
worker: 'native-core',
|
|
75
|
+
backend,
|
|
76
|
+
apiVersion: runtime.apiVersion,
|
|
77
|
+
buildId: NATIVE_CORE_WORKER_BUILD_ID
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
initialize().catch((error) => {
|
|
82
|
+
initializationFailed = true;
|
|
83
|
+
self.postMessage({
|
|
84
|
+
type: 'NATIVE_CORE_INIT_ERROR',
|
|
85
|
+
message: String(error?.message || error || 'native core initialization failed'),
|
|
86
|
+
buildId: NATIVE_CORE_WORKER_BUILD_ID
|
|
87
|
+
});
|
|
88
|
+
setTimeout(() => { throw error; }, 0);
|
|
89
|
+
});
|