Files
deepseek-harness/packages/client/web/src/seed.ts
T
imccyu b58f0989f9 refactor(gui): rebuild the client loading kernel as dsh-client-modules with a two-phase boot
The module system moves out of dsh-client-runtime (./loader retired) into
its own package: a lazy CJS table where executing a bundle only registers
its factory and materialization happens at first require, memoized, with
recursive requires self-ordering. ClientModuleSystem is a class; index.ts
keeps the types and a thin factory. Boot is two-phase: phase one prefetches
the immediately tier in parallel (registration only, failures deferred to
phase two's loud import); phase two mounts the vendored Loader with the
module system as internal, creates one entry per graph row plus the
app-shell pseudo-row the kernel appends itself, and settles on an
all-ACTIVE sweep. The shell kernel is self-sufficient: hand-rolled
loader-status stores, no plugin value imports, platform seed list single-
sourced in platform.ts.
2026-07-24 02:09:42 +08:00

38 lines
1.6 KiB
TypeScript

/**
* Platform-singleton module-table. These are the ONLY entities the shell
* shares into the frozen module table — fetch bundles resolve their externals
* against exactly this set through the loader's require. Keys come from the
* platform constant module ({@link ./platform.ts}, contract C1: single source
* of truth with the tsdown client externals); values stay shell-static
* imports so every bundle sees the same instance.
*/
import * as React from 'react'
import * as ReactJsxRuntime from 'react/jsx-runtime'
import * as ReactDom from 'react-dom'
import * as ReactDomClient from 'react-dom/client'
import * as Cordis from 'cordis'
import * as UiSlots from '@deepseek-ai/dsh-client-ui-slots'
import * as WebReact from '@deepseek-ai/dsh-client-web-react'
import * as UiPrimitives from '@deepseek-ai/dsh-client-ui-primitives'
import type { PlatformModule } from './platform.ts'
/**
* Build the static table handed to the module loader at boot.
* @returns module specifier → export-surface entity (one entry per platform word).
*/
export function getStaticModules(): Record<string, unknown> {
// The satisfies pin is the projection contract: a word added to
// PLATFORM_MODULES without a static import here (or vice versa) fails to
// compile instead of drifting into a runtime require miss.
return {
'react': React,
'react/jsx-runtime': ReactJsxRuntime,
'react-dom': ReactDom,
'react-dom/client': ReactDomClient,
'cordis': Cordis,
'@deepseek-ai/dsh-client-ui-slots': UiSlots,
'@deepseek-ai/dsh-client-web-react': WebReact,
'@deepseek-ai/dsh-client-ui-primitives': UiPrimitives,
} satisfies Record<PlatformModule, unknown>
}