mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-13 04:03:30 +00:00
Replace per-plugin tapIndex regex edits with pure-data IndexInjection rows collected fresh per render over one webserver/index-inject event. One table, two renderers: the served form renders rows into index.html; a static worker form ships the same rows over its boot payload. tapIndex survives as the raw-HTML escape hatch, applied after row rendering; client-modules and ui-theme move to the event, and the manifest global renders as globalThis["__DSH_BOOT__"]. The client boot chain gains the seams a pre-injected transport needs: the module loader takes loadBundle from the transport global by default, HTTP prefetch stands down when a transport owns bundle bytes, the web-app bundle can decline frontend serving, the gateway client installs a namespace's whole method group inside its fiber apply so a parked dependent never observes the service without its methods, and the dynamic-code precheck gates through new Function so hosts without a real node:vm keep the define-time parse gate.
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
/**
|
|
* Theme bootstrap row for the browser's pre-plugin interval. Each index
|
|
* render embeds the current durable built-in preference; the browser resolves
|
|
* only `system`, then writes the same DOM fields ui-layout's ThemePresenter
|
|
* owns after the client plugin tree activates.
|
|
*/
|
|
|
|
import type { IndexInjection } from '@deepseek-ai/dsh-host-webserver'
|
|
import { DEFAULT_PREFERENCE, type ThemePreference } from './theme-settings.ts'
|
|
|
|
/** Build the inline script body for one schema-validated built-in preference. */
|
|
function bootThemeScript(preference: ThemePreference): string {
|
|
return `(() => {
|
|
const preference = ${JSON.stringify(preference)}
|
|
const systemDark = preference === 'system'
|
|
&& typeof matchMedia !== 'undefined'
|
|
&& matchMedia('(prefers-color-scheme: dark)').matches
|
|
const dark = preference === 'dark' || systemDark
|
|
document.documentElement.style.colorScheme = dark ? 'dark' : 'light'
|
|
document.body.toggleAttribute('data-ds-dark-theme', dark)
|
|
})()`
|
|
}
|
|
|
|
/**
|
|
* The theme bootstrap as an injection row: an inline script immediately after
|
|
* the opening body tag, before the shell mount and module script.
|
|
* @param preference - Current Host-backed built-in preference.
|
|
* @returns the body script row.
|
|
*/
|
|
export function bootThemeInjection(
|
|
preference: ThemePreference = DEFAULT_PREFERENCE,
|
|
): IndexInjection {
|
|
return { kind: 'script', placement: 'body', text: bootThemeScript(preference) }
|
|
}
|