mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
DATA LAYERS keeps its curated core layers; regional and niche sources live in the Data Library, opened from Browse data library at the foot of the panel. Each entry is a JSON manifest in src/library/entries/ pointing at a live upstream (query API, provider-hosted file or tile endpoint), so nothing is bundled and a self-hosted instance hosts no data. Sources without CORS go through one allowlisted /api/library route. Kinds: dataset (GeoJSON, CSV, JSON records, ArcGIS, partitioned GeoParquet), tiles (XYZ, WMS/ArcGIS bbox export, terrarium relief) and pack. Selections persist and travel in share links as lib=, separate from the core layer tokens. Library rows get Zoom and Remove icon chips that work while the layer is off, rendered through RailChips. Strings are translated in every locale.
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { LayerLifecycle } from './lifecycle.js';
|
|
|
|
const layer = (id) => ({
|
|
id,
|
|
name: id,
|
|
icon: '',
|
|
source: 'test',
|
|
async init() {},
|
|
async enable() {},
|
|
async update() {},
|
|
async disable() {},
|
|
async destroy() {},
|
|
getStats: () => ({ count: 0, lastUpdate: null }),
|
|
});
|
|
|
|
test('library layers register only after sealing and only in the lib- namespace', async () => {
|
|
const manager = new LayerLifecycle({});
|
|
const activity = [];
|
|
manager.subscribeActivity((change) => activity.push(change.type));
|
|
manager.register(layer('earthquakes'));
|
|
assert.throws(
|
|
() => manager.registerLibraryLayer(layer('lib-night-lights')),
|
|
/after the catalog is sealed/,
|
|
);
|
|
manager.finalizeRegistrations([
|
|
{ id: 'earthquakes', disposition: 'enabled-only' },
|
|
]);
|
|
assert.throws(
|
|
() => manager.registerLibraryLayer(layer('radio')),
|
|
/lib- namespace/,
|
|
);
|
|
assert.throws(() => manager.register(layer('lib-x-y-z')), /finalized/);
|
|
manager.registerLibraryLayer(layer('lib-night-lights'));
|
|
assert.equal(manager.isLibraryLayer('lib-night-lights'), true);
|
|
assert.equal(manager.isLibraryLayer('earthquakes'), false);
|
|
const rows = manager.getAll();
|
|
assert.equal(
|
|
rows.find(({ id }) => id === 'earthquakes').libraryEntryId,
|
|
null,
|
|
);
|
|
assert.equal(
|
|
rows.find(({ id }) => id === 'lib-night-lights').libraryEntryId,
|
|
'night-lights',
|
|
);
|
|
assert.equal(await manager.unregisterLibraryLayer('earthquakes'), false);
|
|
assert.equal(manager.layers.has('earthquakes'), true);
|
|
await manager.setEnabled('lib-night-lights', true, { origin: 'user' });
|
|
assert.equal(await manager.unregisterLibraryLayer('lib-night-lights'), true);
|
|
assert.equal(manager.layers.has('lib-night-lights'), false);
|
|
assert.equal(manager.isLibraryLayer('lib-night-lights'), false);
|
|
assert.equal(activity.filter((type) => type === 'registrations').length, 2);
|
|
});
|