fix(web): include the HMR receiver in the initial client graph

This commit is contained in:
Turtle
2026-08-10 23:45:04 +08:00
parent 37ee7b0f24
commit a4d8c0da9b
19 changed files with 125 additions and 48 deletions
+1
View File
@@ -46,6 +46,7 @@ Keep this log exhaustive — every divergence from upstream must be listed.
14. **`include/src/index.ts` durable debounced writes**: serialized and tracked config-file writes, retried transient `EACCES`/`EBUSY`/`EPERM` rename failures with a bounded backoff, observed asynchronous timer rejections, and drained the latest write during Include teardown. Windows can briefly retain a destination handle after a Loader child disposes; the upstream fire-and-forget rename escaped as an unhandled rejection and could lose the persisted `disabled` state. A terminal failure is logged by the asynchronous writer and remains on the queue so `Include.stop()` rethrows it instead of silently declaring persistence complete; Cordis's ordinary fiber teardown retains its separate error-containment contract. Covered by `packages/host/directory-picker-auto/tests/loader-composition.spec.ts` with injected transient and terminal rename failures.
15. **`@deepseek-ai` rescope**: every vendored manifest `name`, every internal dependency entry among the vendored set, and every module specifier that reaches them use the scoped names in the manifest table's `npm name` column. Directory names, version numbers, and dependency ranges are unchanged, and no upstream runtime identifier is renamed — `Symbol.for('schemastery')` and Schemastery's `vendor:` metadata field keep their upstream values. Re-apply with `pnpm run rescope-vendor --apply` after a sync; the table's two name columns are the mapping, restated for consumers in [docs/rescope.md](../docs/rescope.md).
16. **Lazy Loader config resolution across `cordis/src/{events,fiber}.ts`, `loader/src/{index,config/entry}.ts`, `include/src/index.ts`, and `hmr/src/index.ts`**: ports [cordiverse/cordis#41](https://github.com/cordiverse/cordis/pull/41), retaining raw fiber config and resolving it through `internal/config` only after declared injections are active. Provider replacement re-resolves the raw expression, pending updates retain it, and HMR transfers it. Resolution applies only to the entry root, so child plugins mounted by a row keep caller-owned config identity. Include adds a static entry-config resolver so its own options interpolate while nested row `!!js` nodes remain deferred. Deferred failures retain the owning row diagnostic, and tree teardown does not persist failure-driven self-disposal. Covered by `packages/boot/app-boot/tests/{app-boot,user-patches}.spec.ts`, `packages/boot/cmdline/tests/cmdline.spec.ts`, `apps/cli/tests/web-agent-presets.e2e.ts`, and the built custom-profile cases in `apps/cli/tests/built-bin.e2e.ts`.
17. **In-memory Loader entry activation in `loader/src/config/entry.ts`**: an invocation can activate a row shipped with `disabled: true` without mutating its serialized options. The override belongs to the mounted entry object, survives Include config reapplication, respects disabled ancestors, and disappears with the entry. Covered by `packages/boot/cmdline/tests/cmdline.spec.ts` and `apps/web/tests/hmr-live.e2e.ts`.
## Sync procedure
+20 -2
View File
@@ -73,6 +73,8 @@ export class Entry {
_initTask?: Promise<void>
_disposing = 0
private runtimeEnabled = false
private runtimeEnableTask?: Promise<void>
constructor(public loader: Loader) {
this.ctx = loader.ctx.extend({ [Entry.key]: this })
@@ -99,15 +101,31 @@ export class Entry {
private _disabled(options: EntryOptions) {
// group is always enabled
if (options.group) return false
if (options.disabled) return true
if (options.disabled && !this.runtimeEnabled) return true
let entry = this.parent.ctx.fiber.entry
while (entry) {
if (entry.options.disabled) return true
if (entry.options.disabled && !entry.runtimeEnabled) return true
entry = entry.parent.ctx.fiber.entry
}
return false
}
/**
* Enable this in-memory entry without rewriting its configured `disabled`
* value; the override survives config reapplication for this entry object.
* @returns a promise settling after its initial activation attempt.
*/
enableRuntime(): Promise<void> {
if (this.runtimeEnableTask !== undefined) return this.runtimeEnableTask
this.runtimeEnabled = true
this.runtimeEnableTask = this.refresh().catch((error: unknown) => {
this.runtimeEnabled = false
this.runtimeEnableTask = undefined
throw error
})
return this.runtimeEnableTask
}
evaluate(expr: string) {
return evaluate(this.ctx, expr)
}