Run the worker prelude ahead of Cesium's own workers script

Cesium's script sets CESIUM_WORKERS itself when it loads, so the panel's
combined workers script was never used, and neither was the embedded
terrain-heights file: the worker still requested it from the panel
page's site. The panel build now writes only the prelude, and the panel
puts it ahead of whatever Cesium assigns to CESIUM_WORKERS. The separate
esbuild bundle of Cesium's workers is gone.
This commit is contained in:
Sameh Khamis committed 2026-10-02 18:29:42 -07:00
1 parent 9e5ef78f91
commit e82ab7440d
6 files changed
+38 -65

No files matched your search

+15 -4
View File
@@ -489,14 +489,25 @@ export function panelRuntime(config) {
'text/html',
);
window.CESIUM_BASE_URL = `${config.panelBase}cesium/`;
const [workers] = await Promise.all([
appFetch(config.panelBase + config.workersPath).then((r) => r.text()),
const [prelude] = await Promise.all([
appFetch(config.panelBase + config.workerPreludePath).then((r) =>
r.text(),
),
...[...built.head.querySelectorAll('link[rel="stylesheet"]')].map(
(link) => addStylesheet(link.getAttribute('href')),
),
]);
// Cesium starts its workers from this script instead of from files.
window.CESIUM_WORKERS = workers;
// Cesium's script sets CESIUM_WORKERS, its workers as one script it
// starts from memory. Workers request files themselves, which this page
// cannot answer, so the prelude, holding those files, runs ahead of it.
let workers;
Object.defineProperty(window, 'CESIUM_WORKERS', {
configurable: true,
get: () => workers,
set: (script) => {
workers = prelude + script;
},
});
// Images in the markup load their files once added; give them the
// files instead of letting them request this page's site.
const images = [];