Ver Fonte

fix(client): align lazy chunk metadata

imccyu há 1 semana atrás
pai
commit
ee9f43bc5d

+ 2 - 2
docs/subsystems/client-modules.i18n.yaml

@@ -2,5 +2,5 @@
 # side as of the last confirmed-consistent state. Both languages carry equal authority;
 # after editing either side, bring the other along and re-record with:
 #   pnpm run verify-translation-pairing --write docs/subsystems/client-modules.md
-client-modules.md: 7855cecd8e2802e9ad25f3ee05f01f286bc21c1b
-client-modules.zh.md: 19f3fb4dfb3b112700df879325525b4ff9e23850
+client-modules.md: c6248eb02b989aed7bc34cc1d3fdfc3d3fbd0e5c
+client-modules.zh.md: ee5a90d9cd100dfabe3612757888a7d94401161a

+ 3 - 3
docs/subsystems/client-modules.md

@@ -89,7 +89,7 @@ Package metadata — including the negative "not a client package" verdict — i
 ```ts type-equiv
 /** Filesystem baseline captured before a client artifact snapshot is read. */
 interface ClientArtifactBaseline {
-  /** Absolute path of the client bundle. */
+  /** Absolute path of the client entry bundle watched for package rebuilds. */
   readonly path: string
   /** Bundle modification time in milliseconds. */
   readonly mtimeMs: number
@@ -151,8 +151,8 @@ async fetchBundle(request: Request): Promise<Response>
 artifactBaseline(id: string): ClientArtifactBaseline | undefined
 
 /**
- * Re-hash one bundle (the HMR watch's registration hook — the only entry
- * point through which bundle content changes reach the graph).
+ * Re-snapshot one package's entry and chunks (the HMR watch's registration
+ * hook — the only entry point through which executable changes reach the graph).
  * @param id - entry id (package name).
  * @returns the new rev, or undefined for an unknown id.
  */

+ 3 - 3
docs/subsystems/client-modules.zh.md

@@ -89,7 +89,7 @@ interface WebBootGraph {
 ```ts type-equiv
 /** Filesystem baseline captured before a client artifact snapshot is read. */
 interface ClientArtifactBaseline {
-  /** Absolute path of the client bundle. */
+  /** Absolute path of the client entry bundle watched for package rebuilds. */
   readonly path: string
   /** Bundle modification time in milliseconds. */
   readonly mtimeMs: number
@@ -151,8 +151,8 @@ async fetchBundle(request: Request): Promise<Response>
 artifactBaseline(id: string): ClientArtifactBaseline | undefined
 
 /**
- * Re-hash one bundle (the HMR watch's registration hook — the only entry
- * point through which bundle content changes reach the graph).
+ * Re-snapshot one package's entry and chunks (the HMR watch's registration
+ * hook — the only entry point through which executable changes reach the graph).
  * @param id - entry id (package name).
  * @returns the new rev, or undefined for an unknown id.
  */

+ 5 - 3
packages/client/modules/src/index.ts

@@ -23,6 +23,7 @@
  * @module @deepseek-ai/dsh-client-modules
  */
 
+import assert from 'node:assert/strict'
 import { createHash, randomBytes } from 'node:crypto'
 import { existsSync, readFileSync, statSync } from 'node:fs'
 import type { IncomingMessage, ServerResponse } from 'node:http'
@@ -939,10 +940,11 @@ export class ClientModuleRegistry extends Service {
       const bundle = readFileSync(clientPath)
       const chunks = new Map<string, Buffer>()
       const pending = [bundle]
-      for (let index = 0; index < pending.length; index += 1) {
-        const source = pending[index]!.toString('utf8')
+      for (const artifact of pending) {
+        const source = artifact.toString('utf8')
         for (const match of source.matchAll(CLIENT_CHUNK_REQUIRE)) {
-          const fileName = match[2]!
+          const fileName = match[2]
+          assert(fileName !== undefined)
           if (chunks.has(fileName)) continue
           const chunk = readFileSync(join(dirname(clientPath), fileName))
           chunks.set(fileName, chunk)

+ 2 - 2
packages/extensions/cordis-client-runner/src/client/slot-catalog.ts

@@ -2343,7 +2343,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
       'client-ui-sidebar-documentpreview TextPreview',
       'client-ui-sidebar-files FilesBody',
       'client-ui-sidebar-right GuideBody',
-      'client-ui-sidebar-terminal TerminalBody',
+      'client-ui-sidebar-terminal LazyTerminalBody',
     ],
     replaceRisk: 'none',
     example: 'return {\n  inject: [\'slots\'],\n  apply(ctx) {\n    ctx.slots.inject(\'sidebar.right.pane.tab\', () => ctx.slots.register(\n      { name: \'sidebar.right.pane.tab\', key: \'<one key the owner dispatches>\' },\n      () => React.createElement(\'div\', null, \'hello\'),\n    ))\n  },\n}',
@@ -2440,7 +2440,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
       'client-ui-sidebar-documentpreview HtmlBody',
       'client-ui-sidebar-documentpreview ImageBody',
       'client-ui-sidebar-documentpreview MarkdownBody',
-      'client-ui-sidebar-documentpreview PdfBody',
+      'client-ui-sidebar-documentpreview LazyPdfBody',
       'client-ui-sidebar-documentpreview TextBody',
     ],
     replaceRisk: 'none',

+ 1 - 1
packages/extensions/tool-cordis/src/api-catalog.ts

@@ -638,7 +638,7 @@ export const SERVICE_API: readonly ServiceApiEntry[] = [
       },
       {
         signature: 'rebuilt(id: string): string | undefined',
-        description: 'Re-hash one bundle (the HMR watch\'s registration hook — the only entry point through which bundle content changes reach the graph).',
+        description: 'Re-snapshot one package\'s entry and chunks (the HMR watch\'s registration hook — the only entry point through which executable changes reach the graph).',
         parameters: [{ name: 'id', description: 'entry id (package name).' }],
         returns: 'the new rev, or undefined for an unknown id.',
       },