refactor(cctv): separate camera source and scene components

This commit is contained in:
Sameh Khamis committed 2026-09-13 15:02:32 -07:00
1 parent ca5f5fff93
commit 519bc6c362
32 files changed
+6873 -4835

No files matched your search

+87 -4823
View File
File diff suppressed because it is too large. Load diff
+14 -9
View File
@@ -14,6 +14,11 @@
// computeFrustumGeometry is PURE (no viewer, no scene queries) so it runs under
// plain node:test.
import { test } from 'node:test';
// Preserve structural pins across component qualification and formatter wrapping.
function componentFunctionSource(fn) {
return fn.toString().replace(/\blayerState\./g, '').replace(/\bparts\.\w+\./g, '')
.replace(/,\s*(?=\))/g, '').replace(/\s+/g, ' ').replace(/\(\s+/g, '(');
}
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
@@ -208,7 +213,7 @@ test('lazy coverage inserts nothing at catalog init, then materializes only elig
});
assert.equal(insertCount, 0, 'building a 100-camera catalog must insert zero coverage entities');
assert.doesNotMatch(cctvLayer.init.toString(), /buildCoverageEntities|ensure(?:Active|Visible)CoverageEntities/);
assert.doesNotMatch(componentFunctionSource(cctvLayer.init), /buildCoverageEntities|ensure(?:Active|Visible)CoverageEntities/);
const activated = materializeCctvActiveCoverageEntities(records[42], build);
assert.equal(activated.length, 5);
@@ -224,7 +229,7 @@ test('lazy coverage inserts nothing at catalog init, then materializes only elig
assert.equal(coverageOn.length, 14 * 5);
assert.equal(insertCount, 15 * 5, 'COVERAGE ON builds only remaining visible/eligible sets');
assert.equal(records.filter((record) => record.coverageEntities.length > 0).length, 15);
assert.match(refreshCoverageStyles.toString(), /ensureVisibleCoverageEntities\(_records, coverageVisible\)/);
assert.match(componentFunctionSource(refreshCoverageStyles), /ensureVisibleCoverageEntities\(_records, coverageVisible\)/);
assert.equal(
materializeCctvVisibleCoverageEntities(records, visibleIds, build).length,
0,
@@ -614,7 +619,7 @@ test('CCTV disable→enable defers the active-camera re-probe until its next act
assert.equal(record.activationDone, false);
assert.equal(cctvRecordNeedsActivation('active', 'active', record), true);
assert.doesNotMatch(
cctvLayer.enable.toString(),
componentFunctionSource(cctvLayer.enable),
/setActiveCamera|runActivationObstructionProbe|pickFromRay/,
'enable must restore nominal visuals without entering the activation probe path',
);
@@ -724,11 +729,11 @@ test('CCTV repeated in-world clicks dispatch focus only for the one real activat
assert.deepEqual(activated, ['atx-cam-3', 'atx-cam-3', 'atx-cam-3']);
assert.deepEqual(requests, [{ cameraId: 'atx-cam-3' }]);
assert.match(cctvLayer.init.toString(), /bindCctvWorldClickGesture\(_clickHandler/);
assert.match(cctvLayer.init.toString(), /_cctvOverlayHost\.hitTest/);
assert.match(cctvLayer.init.toString(), /sourceId: CCTV_OVERLAY_SOURCE_ID/);
assert.match(cctvLayer.init.toString(), /activateCctvCameraFromWorldClick\(cameraId, setActiveCamera\)/);
assert.match(cctvLayer.init.toString(), /activateCctvCameraFromWorldClick\(cardId, setActiveCamera\)/);
assert.match(componentFunctionSource(cctvLayer.init), /bindCctvWorldClickGesture\(_clickHandler/);
assert.match(componentFunctionSource(cctvLayer.init), /_cctvOverlayHost\.hitTest/);
assert.match(componentFunctionSource(cctvLayer.init), /sourceId: CCTV_OVERLAY_SOURCE_ID/);
assert.match(componentFunctionSource(cctvLayer.init), /activateCctvCameraFromWorldClick\(cameraId, setActiveCamera\)/);
assert.match(componentFunctionSource(cctvLayer.init), /activateCctvCameraFromWorldClick\(cardId, setActiveCamera\)/);
});
// ─── Empty-space deselection and stable null-active state ──────────────────
@@ -795,7 +800,7 @@ test('CCTV empty-click gate excludes every identified scene object, ADJUST, and
activeCameraId: 'cam-1',
}), true, 'an ID-less surface pick remains true empty space');
const initSource = cctvLayer.init.toString();
const initSource = componentFunctionSource(cctvLayer.init);
assert.ok(
initSource.indexOf('if (pickedId !== null) return')
< initSource.indexOf('_cctvOverlayHost.hitTest'),