refactor: projection-key home moves to src/types.ts with /types + /client/types dual outlets

This commit is contained in:
imccyu
2026-07-27 22:22:33 +08:00
parent 75ea589976
commit 38ffb78e1c
9 changed files with 58 additions and 31 deletions
@@ -15,9 +15,13 @@
"types": "./lib/types/invariant.d.ts", "types": "./lib/types/invariant.d.ts",
"default": "./lib/invariant.js" "default": "./lib/invariant.js"
}, },
"./types": {
"types": "./lib/types/types.d.ts",
"default": "./lib/types/types.js"
},
"./client/types": { "./client/types": {
"types": "./lib/types/client/types.d.ts", "types": "./lib/types/client/index.d.ts",
"default": "./lib/types/client/types.js" "default": "./lib/types/client/index.js"
}, },
"./src/*": "./src/*", "./src/*": "./src/*",
"./package.json": "./package.json" "./package.json": "./package.json"
@@ -0,0 +1,10 @@
/**
* Browser half-entry of the title domain: a pure re-export of the package's
* types outlet. Client code imports ONLY the client namespace (repo
* discipline), so `./client/types` projects the same single-source content
* `./types` serves to host consumers — zero duplication.
*
* @module @deepseek-ai/dsh-session-title/client/types
*/
export type * from '../types.ts'
@@ -17,12 +17,11 @@ import type {
} from '@deepseek-ai/dsh-session' } from '@deepseek-ai/dsh-session'
// Type-only: resolves ctx.sessionProjections for the optional unit child. // Type-only: resolves ctx.sessionProjections for the optional unit child.
import type {} from '@deepseek-ai/dsh-session-projection' import type {} from '@deepseek-ai/dsh-session-projection'
// The `title` projection-key declaration lives in the client outlet (its one // The `title` projection-key declaration lives in src/types.ts (its one home);
// home). A PLAIN side-effect import, not `import type`: declaration emit // this re-export projects the type face onto the package root AND keeps the
// elides type-only imports, and the aggregate programs resolve this package // module edge in the emitted index.d.ts, so aggregate programs consuming the
// through its emitted declarations — the merge must survive in index.d.ts. // declarations still receive the SessionProjectionMap merge.
// The imported module is types-only, so the runtime edge is an empty module. export type * from './types.ts'
import './client/types.ts'
import { fallbackSessionTitle, normalizeSessionTitle } from './normalize.ts' import { fallbackSessionTitle, normalizeSessionTitle } from './normalize.ts'
export { fallbackSessionTitle, normalizeSessionTitle, truncateTitleUtf8 } from './normalize.ts' export { fallbackSessionTitle, normalizeSessionTitle, truncateTitleUtf8 } from './normalize.ts'
@@ -1,12 +1,11 @@
/** /**
* Pure-type client outlet of the title domain: the ONE home of the `title` * Pure types of the title domain: the ONE home of the `title` projection-key
* projection-key declaration, importable from client aggregates without * declaration, free of this package's host-side value imports (cordis
* dragging this package's host-side value imports (cordis service, * service, schemastery, the llm seam). Two namespace projections serve it —
* schemastery, the llm seam). The host entry (`index.ts`) imports this module * `./types` for host consumers, `./client/types` (the browser half-entry's
* type-only to reuse the same merge — one declaration serves both program * re-export) for client aggregates — with zero content duplication.
* sides.
* *
* @module @deepseek-ai/dsh-session-title/client/types * @module @deepseek-ai/dsh-session-title/types
*/ */
// Marks this file a module so the declaration below AUGMENTS the projection // Marks this file a module so the declaration below AUGMENTS the projection
+6 -2
View File
@@ -15,9 +15,13 @@
"types": "./lib/types/invariant.d.ts", "types": "./lib/types/invariant.d.ts",
"default": "./lib/invariant.js" "default": "./lib/invariant.js"
}, },
"./types": {
"types": "./lib/types/types.d.ts",
"default": "./lib/types/types.js"
},
"./client/types": { "./client/types": {
"types": "./lib/types/client/types.d.ts", "types": "./lib/types/client/index.d.ts",
"default": "./lib/types/client/types.js" "default": "./lib/types/client/index.js"
}, },
"./src/*": "./src/*", "./src/*": "./src/*",
"./package.json": "./package.json" "./package.json": "./package.json"
@@ -0,0 +1,10 @@
/**
* Browser half-entry of the todo domain: a pure re-export of the package's
* types outlet. Client code imports ONLY the client namespace (repo
* discipline), so `./client/types` projects the same single-source content
* `./types` serves to host consumers — zero duplication.
*
* @module @deepseek-ai/dsh-tool-todo/client/types
*/
export type * from '../types.ts'
+5 -6
View File
@@ -12,12 +12,11 @@ import { defineTool } from '@deepseek-ai/dsh-tools'
import type { TodoItem } from '@deepseek-ai/dsh-session' import type { TodoItem } from '@deepseek-ai/dsh-session'
// Type-only: resolves ctx.sessionProjections for the optional unit child. // Type-only: resolves ctx.sessionProjections for the optional unit child.
import type {} from '@deepseek-ai/dsh-session-projection' import type {} from '@deepseek-ai/dsh-session-projection'
// The `todos` projection-key declaration lives in the client outlet (its one // The `todos` projection-key declaration lives in src/types.ts (its one home);
// home). A PLAIN side-effect import, not `import type`: declaration emit // this re-export projects the type face onto the package root AND keeps the
// elides type-only imports, and the aggregate programs resolve this package // module edge in the emitted index.d.ts, so aggregate programs consuming the
// through its emitted declarations — the merge must survive in index.d.ts. // declarations still receive the SessionProjectionMap merge.
// The imported module is types-only, so the runtime edge is an empty module. export type * from './types.ts'
import './client/types.ts'
export const name = 'tool-todo' export const name = 'tool-todo'
export const inject = ['tools'] export const inject = ['tools']
@@ -1,11 +1,11 @@
/** /**
* Pure-type client outlet of the todo domain: the ONE home of the `todos` * Pure types of the todo domain: the ONE home of the `todos` projection-key
* projection-key declaration, importable from client aggregates without * declaration plus its payload types, free of this package's host-side value
* dragging this package's host-side value imports (dsh-tools, zod). The host * imports (dsh-tools, zod). Two namespace projections serve it — `./types`
* entry (`index.ts`) imports this module type-only to reuse the same merge — * for host consumers, `./client/types` (the browser half-entry's re-export)
* one declaration serves both program sides. * for client aggregates — with zero content duplication.
* *
* @module @deepseek-ai/dsh-tool-todo/client/types * @module @deepseek-ai/dsh-tool-todo/types
*/ */
import type { TodoItem } from '@deepseek-ai/dsh-session/types' import type { TodoItem } from '@deepseek-ai/dsh-session/types'
+4 -2
View File
@@ -42,8 +42,10 @@
"@deepseek-ai/dsh-session/types": ["./packages/core/session/src/types.ts"], "@deepseek-ai/dsh-session/types": ["./packages/core/session/src/types.ts"],
"@deepseek-ai/dsh-session/surface": ["./packages/core/session/src/surface.ts"], "@deepseek-ai/dsh-session/surface": ["./packages/core/session/src/surface.ts"],
"@deepseek-ai/dsh-session-projection/types": ["./packages/session-projection/session-projection/src/types.ts"], "@deepseek-ai/dsh-session-projection/types": ["./packages/session-projection/session-projection/src/types.ts"],
"@deepseek-ai/dsh-tool-todo/client/types": ["./packages/todo/tool-todo/src/client/types.ts"], "@deepseek-ai/dsh-tool-todo/types": ["./packages/todo/tool-todo/src/types.ts"],
"@deepseek-ai/dsh-session-title/client/types": ["./packages/session-title/session-title/src/client/types.ts"], "@deepseek-ai/dsh-tool-todo/client/types": ["./packages/todo/tool-todo/src/client/index.ts"],
"@deepseek-ai/dsh-session-title/types": ["./packages/session-title/session-title/src/types.ts"],
"@deepseek-ai/dsh-session-title/client/types": ["./packages/session-title/session-title/src/client/index.ts"],
"@deepseek-ai/dsh-llm/types": ["./packages/llm/llm/src/types.ts"], "@deepseek-ai/dsh-llm/types": ["./packages/llm/llm/src/types.ts"],
"@deepseek-ai/dsh-llm/brand": ["./packages/llm/llm/src/brand.ts"], "@deepseek-ai/dsh-llm/brand": ["./packages/llm/llm/src/brand.ts"],
"@deepseek-ai/dsh-tools/presentation": ["./packages/core/tools/src/presentation.ts"], "@deepseek-ai/dsh-tools/presentation": ["./packages/core/tools/src/presentation.ts"],