mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-12 04:01:20 +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.
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
/** Host registration for the browser theme preference and pre-plugin palette. */
|
|
|
|
import type { Context } from '@deepseek-ai/cordis'
|
|
import type {} from '@deepseek-ai/dsh-host-webserver'
|
|
import { settingsNamespace } from '@deepseek-ai/dsh-settings'
|
|
import { bootThemeInjection } from './boot-theme.ts'
|
|
import {
|
|
DEFAULT_PREFERENCE, THEME_SETTINGS_NAMESPACE, ThemeSettingsSchema,
|
|
type ThemePreference, type ThemeSettings,
|
|
} from './theme-settings.ts'
|
|
|
|
export {
|
|
DEFAULT_PREFERENCE, THEME_PREFERENCE_FIELD, THEME_PREFERENCES, THEME_SETTINGS_NAMESPACE,
|
|
type ThemePreference, type ThemeSettings,
|
|
} from './theme-settings.ts'
|
|
|
|
const THEME_NAMESPACE = settingsNamespace(THEME_SETTINGS_NAMESPACE)
|
|
|
|
/** Read the registered preference or use the schema default without a settings provider. */
|
|
function readPreference(ctx: Context): ThemePreference {
|
|
const settings = ctx.get('settings')
|
|
if (settings === undefined) return DEFAULT_PREFERENCE
|
|
const section = settings.get(THEME_NAMESPACE) as ThemeSettings | undefined
|
|
if (section === undefined) return DEFAULT_PREFERENCE
|
|
return section.preference
|
|
}
|
|
|
|
/**
|
|
* Register the durable theme section when the optional settings service is
|
|
* composed, and answer every index injection collection with the current
|
|
* theme bootstrap row.
|
|
* @param ctx - Host context that may acquire the settings service.
|
|
*/
|
|
export function apply(ctx: Context): void {
|
|
ctx.inject(['settings'], (settingsCtx) => {
|
|
settingsCtx.settings.register(THEME_NAMESPACE, ThemeSettingsSchema)
|
|
})
|
|
ctx.on('webserver/index-inject', (table) => {
|
|
table.push(bootThemeInjection(readPreference(ctx)))
|
|
})
|
|
}
|