style: format standalone configuration and build boundaries

This commit is contained in:
Sameh Khamis committed 2026-09-11 18:08:26 -07:00
1 parent 8de1018c21
commit fb67024f43
9 files changed
+111 -61

No files matched your search

+8 -2
View File
@@ -20,11 +20,17 @@ export function createStandaloneApplication({
const loaderStatus = loadingScreen.querySelector('.loader-status');
return createApplication({
createScene: (context) =>
createStandaloneScene({ ...context, googleApiKey, cesiumToken, loaderStatus }),
createStandaloneScene({
...context,
googleApiKey,
cesiumToken,
loaderStatus,
}),
createControls: (context) =>
createStandaloneControls({ ...context, loaderStatus }),
createData: (context) =>
createStandaloneData({ ...context, allowQaRegistration }),
createTools: (context) => createStandaloneTools({ ...context, loadingScreen }),
createTools: (context) =>
createStandaloneTools({ ...context, loadingScreen }),
});
}
+3 -1
View File
@@ -30,7 +30,9 @@ export function createStandaloneTools({
if (window.__gevAnnotations === annotations) delete window.__gevAnnotations;
annotations.destroy();
});
defer(startStandaloneChrome({ loadingScreen, styleManager, dataManager, signal }));
defer(
startStandaloneChrome({ loadingScreen, styleManager, dataManager, signal }),
);
// Idle render governor: flips the scene into requestRenderMode whenever
// nothing animates per frame. Installed AFTER every module above has had
// its chance to register pre-install holds. (perf wave 2)
+26 -8
View File
@@ -78,14 +78,32 @@ test('dynamic imports obey the same component ownership rule', async (t) => {
test('a Node build export must be explicitly classified and scoped', async (t) => {
const root = await fixture(t);
await writeFile(path.join(root, 'package.json'), JSON.stringify({
name: 'boundary-fixture', type: 'module', exports: { './feature': { node: './entry.js' } },
}));
await writeFile(path.join(root, 'scripts/package-boundaries.json'), JSON.stringify({
feature: { runtime: 'node', exports: ['./feature'], modules: ['entry.js'], external: [] },
}));
assert.deepEqual(await checkPackageBoundaries(root), [{ name: 'feature', exports: 1, modules: 1 }]);
await writeFile(path.join(root, 'entry.js'), "import './startup.js'; export const value = 1;");
await writeFile(
path.join(root, 'package.json'),
JSON.stringify({
name: 'boundary-fixture',
type: 'module',
exports: { './feature': { node: './entry.js' } },
}),
);
await writeFile(
path.join(root, 'scripts/package-boundaries.json'),
JSON.stringify({
feature: {
runtime: 'node',
exports: ['./feature'],
modules: ['entry.js'],
external: [],
},
}),
);
assert.deepEqual(await checkPackageBoundaries(root), [
{ name: 'feature', exports: 1, modules: 1 },
]);
await writeFile(
path.join(root, 'entry.js'),
"import './startup.js'; export const value = 1;",
);
await writeFile(path.join(root, 'startup.js'), 'export const app = 2;');
await assert.rejects(checkPackageBoundaries(root), /unowned module.*startup/);
});
+36 -9
View File
@@ -7,21 +7,39 @@ import * as providers from '../../server/providers/local.js';
test('explicit build inputs preserve browser-only defines, plugin order and loopback protections', () => {
const plugin = { name: 'fixture-provider' };
const config = createBrowserViteConfig({ plugins: [plugin], googleApiKey: 'browser-fixture', cesiumToken: 'ion-fixture' });
const config = createBrowserViteConfig({
plugins: [plugin],
googleApiKey: 'browser-fixture',
cesiumToken: 'ion-fixture',
});
assert.equal(config.plugins[1], plugin);
assert.equal(config.server.host, 'localhost');
assert.equal(config.server.port, 4173);
assert.deepEqual(config.server.allowedHosts, ['localhost', '127.0.0.1', '.local']);
assert.deepEqual(config.server.allowedHosts, [
'localhost',
'127.0.0.1',
'.local',
]);
assert.ok(config.server.fs.deny.includes('**/ENVIRONMENT'));
assert.ok(config.server.fs.deny.includes('.env.*'));
assert.equal(config.server.headers['X-Frame-Options'], 'DENY');
assert.equal(config.server.headers['Content-Security-Policy'], "frame-ancestors 'none'");
assert.equal(
config.server.headers['Content-Security-Policy'],
"frame-ancestors 'none'",
);
assert.deepEqual(config.define, {
'import.meta.env.GOOGLE_MAPS_API_KEY': '"browser-fixture"',
'import.meta.env.CESIUM_ION_TOKEN': '"ion-fixture"',
});
assert.equal(createBrowserViteConfig({ host: '0.0.0.0', port: '4800' }).server.allowedHosts, true);
assert.equal(createBrowserViteConfig({ host: '::', port: '4800' }).server.port, 4800);
assert.equal(
createBrowserViteConfig({ host: '0.0.0.0', port: '4800' }).server
.allowedHosts,
true,
);
assert.equal(
createBrowserViteConfig({ host: '::', port: '4800' }).server.port,
4800,
);
});
test('build helper does not discover environment values or construct local providers', () => {
@@ -29,7 +47,10 @@ test('build helper does not discover environment values or construct local provi
process.env.GOOGLE_MAPS_API_KEY = 'environment-fixture';
try {
const config = createBrowserViteConfig();
assert.equal(config.define['import.meta.env.GOOGLE_MAPS_API_KEY'], undefined);
assert.equal(
config.define['import.meta.env.GOOGLE_MAPS_API_KEY'],
undefined,
);
assert.equal(config.plugins.length, 1);
} finally {
if (before === undefined) delete process.env.GOOGLE_MAPS_API_KEY;
@@ -38,15 +59,21 @@ test('build helper does not discover environment values or construct local provi
});
test('root config retains existing named exports and standalone provider order', () => {
for (const [name, value] of Object.entries(providers)) assert.equal(compatibility[name], value, name);
for (const [name, value] of Object.entries(providers))
assert.equal(compatibility[name], value, name);
const config = standaloneConfig({ mode: 'test' });
assert.deepEqual(config.plugins.slice(1).map((plugin) => plugin.name), providers.localProviderPlugins().map((plugin) => plugin.name));
assert.deepEqual(
config.plugins.slice(1).map((plugin) => plugin.name),
providers.localProviderPlugins().map((plugin) => plugin.name),
);
assert.equal(config.plugins.at(-1).name, 'gev-key-setup');
});
test('build export resolves in Node and has no browser fallback', async () => {
const exported = await import('gods-eye-view/build/vite');
assert.equal(exported.createBrowserViteConfig, createBrowserViteConfig);
const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url)));
const pkg = JSON.parse(
readFileSync(new URL('../../package.json', import.meta.url)),
);
assert.deepEqual(pkg.exports['./build/vite'], { node: './build/vite.js' });
});