style: format remaining owned runtime modules

This commit is contained in:
Sameh Khamis committed 2026-09-15 07:26:32 -07:00
1 parent ae99843c14
commit 2aca7aecbb
94 files changed
+8865 -3151

No files matched your search

+67 -35
View File
@@ -143,7 +143,9 @@ export const FIRST_RUN_MISSIONS = Object.freeze({
function resolveStore(kind, injected) {
if (injected !== undefined) return injected;
try {
return kind === 'session' ? globalThis.sessionStorage : globalThis.localStorage;
return kind === 'session'
? globalThis.sessionStorage
: globalThis.localStorage;
} catch {
// Privacy-restricted storage should not make first launch silent.
return null;
@@ -211,8 +213,13 @@ export function shouldShowFirstRun({
if (params.get('welcome') === '0') return false;
// The demo/support escape hatch outranks both suppressions on purpose.
if (params.get('welcome') === '1') return true;
if (readStored('local', storage, FIRST_RUN_STORAGE_KEY) === 'suppressed') return false;
if (readStored('session', sessionStorageRef, FIRST_RUN_SESSION_KEY) === 'dismissed') return false;
if (readStored('local', storage, FIRST_RUN_STORAGE_KEY) === 'suppressed')
return false;
if (
readStored('session', sessionStorageRef, FIRST_RUN_SESSION_KEY) ===
'dismissed'
)
return false;
return true;
}
@@ -253,7 +260,10 @@ export function rememberFirstRunSessionDismissed(sessionStorageRef) {
* @param {() => Promise<any>} deps.flyToGlobe
* @returns {Promise<{ok: boolean, choice: string, result?: object, failedLayerIds?: string[]}>}
*/
export async function runFirstRunChoice(choice, { setContextMode, setLayerEnabled, flyToGlobe }) {
export async function runFirstRunChoice(
choice,
{ setContextMode, setLayerEnabled, flyToGlobe },
) {
const mission = FIRST_RUN_MISSIONS[choice];
if (!mission) return { ok: false, choice };
if (mission.kind === 'none') return { ok: true, choice };
@@ -267,15 +277,19 @@ export async function runFirstRunChoice(choice, { setContextMode, setLayerEnable
const flight = Promise.resolve()
.then(() => flyToGlobe())
.catch(() => null);
const outcomes = await Promise.all(mission.layerIds.map(async (layerId) => {
try {
return { layerId, ok: (await setLayerEnabled(layerId)) !== false };
} catch {
return { layerId, ok: false };
}
}));
const outcomes = await Promise.all(
mission.layerIds.map(async (layerId) => {
try {
return { layerId, ok: (await setLayerEnabled(layerId)) !== false };
} catch {
return { layerId, ok: false };
}
}),
);
await flight;
const failedLayerIds = outcomes.filter((entry) => !entry.ok).map((entry) => entry.layerId);
const failedLayerIds = outcomes
.filter((entry) => !entry.ok)
.map((entry) => entry.layerId);
return { ok: failedLayerIds.length === 0, choice, failedLayerIds };
}
@@ -325,20 +339,25 @@ export function initFirstRunExperience({
if (!root || root.dataset.initialized === 'true') return null;
root.dataset.initialized = 'true';
if (!shouldShowFirstRun({
hasShareState: styleManager?.hasShareState,
storage,
sessionStorageRef,
location,
})) {
if (
!shouldShowFirstRun({
hasShareState: styleManager?.hasShareState,
storage,
sessionStorageRef,
location,
})
) {
root.remove();
return null;
}
// The tile name is owner-switchable from one constant, so paint it from the
// module rather than trusting the markup to have been edited to match.
const environmentalTitle = root.querySelector('[data-first-run-environmental-title]');
if (environmentalTitle) environmentalTitle.textContent = environmentalLabel().title;
const environmentalTitle = root.querySelector(
'[data-first-run-environmental-title]',
);
if (environmentalTitle)
environmentalTitle.textContent = environmentalLabel().title;
const status = root.querySelector('[data-first-run-status]');
const suppressBox = root.querySelector('[data-first-run-suppress]');
@@ -387,10 +406,11 @@ export function initFirstRunExperience({
* is exactly how every one of those surfaces hides this card; the hit test
* then covers the overlays that leave the box intact and simply sit on top.
*/
const isTopmost = () => root.isConnected
&& root.classList.contains('visible')
&& root.getClientRects().length > 0
&& !coveredByOverlay();
const isTopmost = () =>
root.isConnected &&
root.classList.contains('visible') &&
root.getClientRects().length > 0 &&
!coveredByOverlay();
const dismiss = ({ restoreFocus = true } = {}) => {
if (closing) return;
@@ -416,10 +436,13 @@ export function initFirstRunExperience({
root.setAttribute('aria-busy', String(next));
// aria-disabled, not `disabled`: disabling the focused button drops focus to
// <body> mid-flight and strands a keyboard visitor outside the launcher.
for (const button of buttons) button.setAttribute('aria-disabled', String(next));
for (const button of buttons)
button.setAttribute('aria-disabled', String(next));
if (!status) return;
if (next) status.textContent = FIRST_RUN_MISSIONS[choice]?.busyText || 'Working…';
else if (status.dataset.sticky !== 'true') status.textContent = defaultStatus;
if (next)
status.textContent = FIRST_RUN_MISSIONS[choice]?.busyText || 'Working…';
else if (status.dataset.sticky !== 'true')
status.textContent = defaultStatus;
};
const onChoice = async (event) => {
@@ -438,13 +461,16 @@ export function initFirstRunExperience({
// does not decide panel chrome. This first-run click is an explicit
// visual choice, so reveal the result exactly as the visible
// Contacts / Space Missions tabs do.
styleManager.setPanelCollapsed?.('global-context-panel', false, { explicit: true });
styleManager.setPanelCollapsed?.('global-context-panel', false, {
explicit: true,
});
}
return result;
},
// `origin: 'user'` on purpose: a mission tile is a real person choosing
// these layers, so it persists exactly as clicking those rows would.
setLayerEnabled: (layerId) => dataManager.setEnabled(layerId, true, { origin: 'user' }),
setLayerEnabled: (layerId) =>
dataManager.setEnabled(layerId, true, { origin: 'user' }),
flyToGlobe: () => styleManager.resetToGlobeView(),
});
} catch (error) {
@@ -460,7 +486,8 @@ export function initFirstRunExperience({
const failed = outcome?.failedLayerIds?.length
? outcome.failedLayerIds
: outcome?.result?.failedLayerIds;
const detail = Array.isArray(failed) && failed.length ? ` (${failed.join(', ')})` : '';
const detail =
Array.isArray(failed) && failed.length ? ` (${failed.join(', ')})` : '';
if (status) {
status.dataset.sticky = 'true';
status.textContent = `Could not open that mission${detail}. Retry or explore manually.`;
@@ -479,7 +506,8 @@ export function initFirstRunExperience({
if (box) box.checked = !wanted;
if (!status) return;
status.dataset.sticky = 'true';
status.textContent = 'This browser is blocking storage, so that could not be saved.';
status.textContent =
'This browser is blocking storage, so that could not be saved.';
};
const keyboard = createSurfaceKeyboard({
@@ -585,13 +613,17 @@ export function initFirstRunExperience({
const onViewportResize = () => syncScrollAffordance();
globalThis.addEventListener?.('resize', onViewportResize);
const surfaceObserver = typeof globalThis.MutationObserver === 'function'
? new globalThis.MutationObserver(syncToExclusiveSurfaces)
: null;
const surfaceObserver =
typeof globalThis.MutationObserver === 'function'
? new globalThis.MutationObserver(syncToExclusiveSurfaces)
: null;
// Attributes only, no subtree: this is a class watch on one element, so it
// costs nothing per frame and never asks the render governor for a frame.
if (documentRef.body) {
surfaceObserver?.observe(documentRef.body, { attributes: true, attributeFilter: ['class'] });
surfaceObserver?.observe(documentRef.body, {
attributes: true,
attributeFilter: ['class'],
});
}
syncToExclusiveSurfaces();