@deepseek-ai/cordis-plugin-loader 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,9 +11,9 @@ export declare class EntryGroup {
11
11
  get context(): Context;
12
12
  create(options: Omit<EntryOptions, 'id'>): Promise<string>;
13
13
  unlink(options: EntryOptions): void;
14
- remove(id: string, isDispose?: boolean): Promise<void>;
14
+ remove(id: string, isDispose?: boolean): void;
15
15
  update(config: EntryOptions[]): Promise<void>;
16
- stop(): Promise<void>;
16
+ stop(): void;
17
17
  }
18
18
  /** Plugin that mounts a nested loader entry group. */
19
19
  export declare class Group extends EntryGroup {
@@ -22,6 +22,6 @@ export declare class Group extends EntryGroup {
22
22
  static initial: Omit<EntryOptions, 'id'>[];
23
23
  static readonly [EntryGroup.key] = true;
24
24
  constructor(ctx: Context, config: EntryOptions[]);
25
- [Service.init](): AsyncGenerator<() => Promise<void>, void, unknown>;
25
+ [Service.init](): AsyncGenerator<() => void, void, unknown>;
26
26
  }
27
27
  //# sourceMappingURL=group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/config/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,wDAAwD;AACxD,qBAAa,UAAU;IAKF,GAAG,EAAE,OAAO;IAAS,IAAI,EAAE,SAAS;IAJvD,MAAM,CAAC,QAAQ,CAAC,GAAG,gBAA6B;IAEzC,IAAI,EAAE,YAAY,EAAE,CAAK;gBAEb,GAAG,EAAE,OAAO,EAAS,IAAI,EAAE,SAAS;IAKvD,IAAI,OAAO,IAAI,OAAO,CAErB;IAEK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,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;CAKL;AAED,sDAAsD;AACtD,qBAAa,KAAM,SAAQ,UAAU;IAIhB,GAAG,EAAE,OAAO;IAAS,MAAM,EAAE,YAAY,EAAE;IAH9D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAK;IAC/C,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,QAAO;gBAEpB,GAAG,EAAE,OAAO,EAAS,MAAM,EAAE,YAAY,EAAE;IAOvD,CAAC,OAAO,CAAC,IAAI,CAAC;CAItB"}
@@ -15,10 +15,7 @@ export declare abstract class EntryTree {
15
15
  entries(): Generator<Entry, void, void>;
16
16
  /** Return pending import and lifecycle tasks owned by this tree. */
17
17
  getTasks(): Promise<void>[];
18
- /**
19
- * Wait until this tree has no active import or lifecycle tasks.
20
- * @throws a settled fiber failure, or an aggregate when several fibers failed.
21
- */
18
+ /** Wait until this tree has no pending import or lifecycle tasks. */
22
19
  await(): Promise<void>;
23
20
  ensureId(options: Partial<EntryOptions>): string;
24
21
  /** Resolve an entry by id, including nested ids separated by `EntryTree.sep`. */
@@ -27,7 +24,7 @@ export declare abstract class EntryTree {
27
24
  /** Create an entry in the root group or a nested group. */
28
25
  create(options: Omit<EntryOptions, 'id'>, parent?: string | null, position?: number): Promise<string>;
29
26
  /** Stop and remove an entry from its parent group. */
30
- remove(id: string): Promise<void>;
27
+ remove(id: string): void;
31
28
  /** Update an entry and optionally move it to another group. */
32
29
  update(id: string, options: Omit<EntryOptions, 'id' | 'name'>, parent?: string | null, position?: number): Promise<void>;
33
30
  /** Import a plugin module from a specifier or `cordis:` builtin. */
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/config/tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAiB,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EA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,EAAE,MAAM;IAc9G,oEAAoE;IACpE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,MAAM,EAAE;IAmBnD,iFAAiF;IACjF,QAAQ,CAAC,KAAK,IAAI,IAAI;CACvB"}
@@ -1,6 +1,6 @@
1
1
  /** Evaluate a JavaScript expression against a loader context scope. */
2
2
  export declare const evaluate: ((ctx: object, expr: string) => any);
3
- /** Recursively replace YAML `!js` expression nodes with evaluated values. */
3
+ /** Recursively replace YAML `!!js` expression nodes with evaluated values. */
4
4
  export declare function interpolate(ctx: object, value: any): any;
5
5
  /** Return true when a value is a serialized loader JavaScript expression. */
6
6
  export declare function isJsExpr(value: any): value is JsExpr;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/config/utils.ts"],"names":[],"mappings":"AAGA,uEAAuE;AACvE,eAAO,MAAM,QAAQ,EAIf,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC,CAAA;AAE1C,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAUlD;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAEpD;AAED,yEAAyE;AACzE,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/config/utils.ts"],"names":[],"mappings":"AAGA,uEAAuE;AACvE,eAAO,MAAM,QAAQ,EAIf,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC,CAAA;AAE1C,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAUlD;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAEpD;AAED,yEAAyE;AACzE,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB"}
@@ -21,7 +21,19 @@ declare module '@deepseek-ai/cordis' {
21
21
  'loader/config-update'(): void;
22
22
  'loader/entry-init'(entry: Entry): void;
23
23
  'loader/partial-dispose'(entry: Entry, legacy: Partial<EntryOptions>, active: boolean): void;
24
- 'loader/patch-context'(entry: Entry, next: () => void | Promise<void>): void | Promise<void>;
24
+ /**
25
+ * Volatile config values were committed into the running fiber without a remount; dispatched to the owning fiber only.
26
+ * @param paths - changed config paths as key arrays; every value is committed before dispatch.
27
+ * @mode emit
28
+ */
29
+ 'loader/volatile-update'(paths: readonly (readonly string[])[]): void;
30
+ /**
31
+ * Refresh entry context before applying config.
32
+ * @param entry - entry containing the new raw config and optional current fiber.
33
+ * @param next - continue context refresh and Loader's config update.
34
+ * @mode waterfall
35
+ */
36
+ 'loader/patch-context'(entry: Entry, next: () => void): void;
25
37
  }
26
38
  interface Context {
27
39
  loader: Loader;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,qBAAqB,CAAA;AACtF,OAAO,EAA8B,KAAK,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAG5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAG5C,iCAAiC;AACjC,cAAc,mBAAmB,CAAA;AACjC,yCAAyC;AACzC,cAAc,mBAAmB,CAAA;AACjC,2CAA2C;AAC3C,cAAc,qBAAqB,CAAA;AACnC,6CAA6C;AAC7C,c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J,wEAAwE;IACxE,aAAa,CAAC,OAAO,EAAE,GAAG;CAQ3B;AAED,eAAe,MAAM,CAAA"}
@@ -91,6 +91,17 @@ export interface ModuleLoaderV2 {
91
91
  export type ModuleLoader = ModuleLoaderV1 | ModuleLoaderV2;
92
92
  /** Helpers for locating the current Node internal module loader. */
93
93
  export declare namespace ModuleLoader {
94
+ /**
95
+ * Locate and classify the running Node internal module loader.
96
+ *
97
+ * The shape is decided by which module-job API the loader owns, never by the
98
+ * Node version: v2 landed in 24.12.0, so a major-version test mistags every
99
+ * 24.0–24.11.1 loader as v2 and makes consumers call `resolveSync` with
100
+ * reversed parameters. Arity is not usable either — `resolveSync` reports 2
101
+ * under both shapes. A loader owning neither API is left unclassified rather
102
+ * than guessed, so consumers take their documented no-internals path.
103
+ * @returns the classified loader, or `undefined` when none is reachable or its shape is unknown.
104
+ */
94
105
  function fromInternal(): ModuleLoader | undefined;
95
106
  }
96
107
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAEjD,iEAAiE;AACjE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAA;AAC9E,kEAAkE;AAClE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,WAAW,CAAA;AAE/C,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,CAAC,EAAE,YAAY,CAAA;CACtB;AAED,KAAK,aAAa,GAAG,SAAS,CAAA;AAE9B,2FAA2F;AAC3F,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AAG,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACzH,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IACpH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CAAA;IACrE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,kBAAkB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACtG;AAED,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,cAAc,CAAA;AAE1D,oEAAoE;AACpE,yBAAiB,YAAY,CAAC;IAe5B;;;;;;;;;;OAUG;IACH,SAAgB,YAAY,IAAI,YAAY,GAAG,SAAS,CAYvD;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/cordis-plugin-loader",
3
3
  "description": "Plugin loader for cordis",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -30,8 +30,8 @@
30
30
  "author": "Shigma <shigma10826@gmail.com>",
31
31
  "license": "MIT",
32
32
  "peerDependencies": {
33
- "node-addon-require-builtin": "^0.1.4",
34
- "@deepseek-ai/cordis": "^4.0.1"
33
+ "node-addon-require-builtin": "^0.1.6",
34
+ "@deepseek-ai/cordis": "^4.0.3"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "node-addon-require-builtin": {
@@ -39,6 +39,7 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@deepseek-ai/cosmokit": "^1.8.2"
42
+ "@deepseek-ai/schemastery": "^3.18.3",
43
+ "@deepseek-ai/cosmokit": "^1.8.4"
43
44
  }
44
45
  }
@@ -0,0 +1,45 @@
1
+ /** Compare raw plugin configs using schema metadata without executing config hooks or validators. */
2
+ import type { Plugin } from '@deepseek-ai/cordis'
3
+ import { deepEqual } from '@deepseek-ai/cosmokit'
4
+ import type Schema from '@deepseek-ai/schemastery'
5
+ import { isJsExpr } from './utils.ts'
6
+
7
+ function isSchemastery(schema: Plugin.Runtime['Config']): schema is Schema {
8
+ return schema?.['~standard'].vendor === 'schemastery'
9
+ }
10
+
11
+ function isRecord(value: unknown): value is Record<string, unknown> {
12
+ if (!value || typeof value !== 'object' || isJsExpr(value)) return false
13
+ const prototype = Object.getPrototypeOf(value)
14
+ return prototype === Object.prototype || prototype === null
15
+ }
16
+
17
+ function equal(a: unknown, b: unknown, schema: Schema | undefined, ancestors: Set<Schema>): boolean {
18
+ if (schema?.meta?.volatile) return true
19
+ if (schema?.type !== 'object' || !schema.dict || ancestors.has(schema)) return deepEqual(a, b, true)
20
+ const left = a ?? schema.meta?.default
21
+ const right = b ?? schema.meta?.default
22
+ if (!isRecord(left) || !isRecord(right)) return deepEqual(left, right, true)
23
+ const { dict } = schema
24
+ ancestors.add(schema)
25
+ try {
26
+ return Object.keys({ ...left, ...right }).every(key =>
27
+ equal(left[key], right[key], Object.hasOwn(dict, key) ? dict[key] : undefined, ancestors),
28
+ )
29
+ } finally {
30
+ ancestors.delete(schema)
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Compare two raw configs, treating schema-declared volatile fields at fixed object paths as equal and absent objects as their schema default.
36
+ * Schema backedges, expressions, unknown fields and opaque values keep strict raw equality; an absent or non-Schemastery schema compares everything raw.
37
+ * @param previous - previous raw config.
38
+ * @param next - next raw config.
39
+ * @param schema - the plugin's config schema.
40
+ * @returns Whether the configs differ at most in volatile fields, without evaluating expressions, validating config or modifying inputs.
41
+ * @internal
42
+ */
43
+ export function equalExceptVolatile(previous: unknown, next: unknown, schema: Plugin.Runtime['Config']): boolean {
44
+ return isSchemastery(schema) ? equal(previous, next, schema, new Set()) : deepEqual(previous, next, true)
45
+ }
@@ -1,9 +1,10 @@
1
- import { Context, Fiber, Inject } from '@deepseek-ai/cordis'
2
- import { deepEqual, isNullable } from '@deepseek-ai/cosmokit'
1
+ import { Context, Fiber, FiberState, Inject, resolveConfig } from '@deepseek-ai/cordis'
2
+ import { deepEqual, isNullable, updateVolatile, volatileEntries, type Volatile } from '@deepseek-ai/cosmokit'
3
3
  import { Loader } from '../index.ts'
4
4
  import { EntryGroup } from './group.ts'
5
5
  import { EntryTree } from './tree.ts'
6
6
  import { evaluate, isJsExpr } from './utils.ts'
7
+ import { equalExceptVolatile } from './diff.ts'
7
8
 
8
9
  /** Serialized plugin entry options stored in loader config files. */
9
10
  export interface EntryOptions {
@@ -21,11 +22,6 @@ export interface EntryOptions {
21
22
  inject?: Inject | null
22
23
  }
23
24
 
24
- function updateError(stage: 'import' | 'dispose' | 'apply' | 'rollback', options: EntryOptions, cause: unknown) {
25
- const detail = cause instanceof Error ? cause.message : String(cause)
26
- return new Error(`failed to ${stage} loader entry ${options.id} (${options.name}): ${detail}`, { cause })
27
- }
28
-
29
25
  function takeEntries(object: {}, keys: string[]) {
30
26
  const result: [string, any][] = []
31
27
  for (const key of keys) {
@@ -43,11 +39,6 @@ function sortKeys<T extends {}>(object: T, prepend = ['id', 'name'], append = ['
43
39
  return Object.assign(object, Object.fromEntries([...part1, ...rest, ...part2]))
44
40
  }
45
41
 
46
- function replaceKeys<T extends {}>(target: T, source: T): T {
47
- for (const key of Object.keys(target)) Reflect.deleteProperty(target, key)
48
- return Object.assign(target, source)
49
- }
50
-
51
42
  /** One configured plugin node inside an `EntryTree`. */
52
43
  export class Entry {
53
44
  static readonly key = Symbol.for('cordis.entry')
@@ -61,7 +52,6 @@ export class Entry {
61
52
  public subtree?: EntryTree
62
53
 
63
54
  _initTask?: Promise<void>
64
- _disposing = 0
65
55
 
66
56
  constructor(public loader: Loader) {
67
57
  this.ctx = loader.ctx.extend({ [Entry.key]: this })
@@ -82,18 +72,13 @@ export class Entry {
82
72
 
83
73
  /** True when this entry or any owning parent entry is disabled. */
84
74
  get disabled() {
85
- return this._disabled(this.options)
86
- }
87
-
88
- private _disabled(options: EntryOptions) {
89
75
  // group is always enabled
90
- if (options.group) return false
91
- if (this.disabledOf(options)) return true
92
- let entry = this.parent.ctx.fiber.entry
93
- while (entry) {
76
+ if (this.options.group) return false
77
+ let entry: Entry | undefined = this
78
+ do {
94
79
  if (this.disabledOf(entry.options)) return true
95
80
  entry = entry.parent.ctx.fiber.entry
96
- }
81
+ } while (entry)
97
82
  return false
98
83
  }
99
84
 
@@ -111,12 +96,12 @@ export class Entry {
111
96
  return evaluate(this.ctx, expr)
112
97
  }
113
98
 
114
- private async _patchContext(diff: string[]) {
115
- await this.context.waterfall('loader/patch-context', this, async () => {
99
+ private _patchContext(diff: string[]) {
100
+ this.context.waterfall('loader/patch-context', this, () => {
116
101
  Object.setPrototypeOf(this.ctx, this.parent.ctx)
117
102
 
118
103
  if (this.fiber?.uid && (diff.includes('config') || this.options.group)) {
119
- await this.fiber.update(this.options.config, true)
104
+ this.fiber.update(this.options.config, true)
120
105
  }
121
106
  })
122
107
  }
@@ -127,122 +112,86 @@ export class Entry {
127
112
  await this.init()
128
113
  }
129
114
 
130
- async _dispose(fiber = this.fiber) {
131
- if (!fiber) return
132
- if (this.fiber === fiber) this.fiber = undefined
133
- this._disposing += 1
134
- try {
135
- await fiber.dispose()
136
- } finally {
137
- this._disposing -= 1
138
- }
139
- }
140
-
141
115
  /** Merge new options, restart as needed, and persist through the parent tree. */
142
116
  async update(options: Partial<EntryOptions>, create = false, force = false) {
143
- const previousOptions = this.options
144
- const legacy = { ...previousOptions }
145
- const candidate = create ? options as EntryOptions : { ...previousOptions }
146
- if (!create) {
117
+ const legacy = { ...this.options }
118
+
119
+ // step 1: update options
120
+ if (create) {
121
+ this.options = options as EntryOptions
122
+ } else {
147
123
  for (const [key, value] of Object.entries(options)) {
148
124
  if (isNullable(value)) {
149
- delete candidate[key as keyof EntryOptions]
125
+ delete this.options[key]
150
126
  } else {
151
- candidate[key as keyof EntryOptions] = value as never
127
+ this.options[key] = value
152
128
  }
153
129
  }
154
130
  }
155
- sortKeys(candidate)
131
+ sortKeys(this.options)
156
132
 
157
- const diff = Object
158
- .keys({ ...candidate, ...legacy })
159
- .filter(key => !deepEqual(candidate[key as keyof EntryOptions], legacy[key as keyof EntryOptions]))
160
- if (!diff.length && !force) return
161
-
162
- const commit = () => {
163
- if (create) return
164
- this.options = replaceKeys(previousOptions, candidate)
165
- }
166
-
167
- const previous = this.fiber
168
- if (!previous?.uid) {
169
- this.fiber = undefined
170
- this.options = candidate
171
- try {
172
- if (!this._disabled(candidate)) await this.init()
173
- } catch (error) {
174
- this.options = previousOptions
175
- throw error
176
- }
177
- commit()
133
+ // step 2: execute
134
+ if (this.disabled) {
135
+ this.fiber?.dispose()
178
136
  return
179
137
  }
180
138
 
181
- if (this._disabled(candidate)) {
182
- this.options = candidate
183
- try {
184
- await this._dispose(previous)
185
- } catch (error) {
186
- this.options = previousOptions
187
- throw updateError('dispose', candidate, error)
188
- }
189
- commit()
190
- this.context.emit('loader/partial-dispose', this, legacy, true)
191
- return
192
- }
193
-
194
- const replace = diff.some(key => key === 'name' || key === 'inject' || key === 'group')
195
- if (!replace) {
196
- this.options = candidate
197
- try {
198
- await this._patchContext(diff)
199
- } catch (error) {
200
- this.options = previousOptions
201
- try {
202
- await this._patchContext(diff)
203
- } catch (rollbackError) {
204
- throw updateError('rollback', legacy, new AggregateError([error, rollbackError]))
205
- }
206
- this.context.emit('loader/partial-dispose', this, candidate, true)
207
- throw updateError('apply', candidate, error)
208
- }
209
- commit()
139
+ // step 3: check if options are changed
140
+ if (this.fiber?.uid) {
141
+ const changes = Object.keys({ ...this.options, ...legacy })
142
+ .filter(key => !deepEqual(this.options[key], legacy[key], key === 'config'))
143
+ // Only an active fiber in an unchanged context takes volatile-only config changes without a remount.
144
+ const volatileOnly = changes.length === 1 && changes[0] === 'config'
145
+ && this.fiber.state === FiberState.ACTIVE && Object.getPrototypeOf(this.ctx) === this.parent.ctx
146
+ && equalExceptVolatile(legacy.config, this.options.config, this.fiber.runtime?.Config)
147
+ if (volatileOnly) this.fiber._config = this.options.config
148
+ const pending = volatileOnly && this._commitVolatile() ? [] : changes
149
+ if (!pending.length && !force) return
210
150
  this.context.emit('loader/partial-dispose', this, legacy, true)
211
- return
212
- }
213
-
214
- let plugin: any
215
- try {
216
- plugin = diff.includes('name')
217
- ? this.loader.unwrapExports(await this.parent.tree.import(candidate.name, this.getOuterStack))
218
- : previous.runtime!.callback
219
- } catch (error) {
220
- throw updateError('import', candidate, error)
151
+ this._patchContext(pending)
152
+ } else {
153
+ await this.init()
221
154
  }
155
+ }
222
156
 
223
- const previousPlugin = previous.runtime!.callback
224
- this.options = candidate
157
+ /**
158
+ * Parse a volatile-only raw config change and commit its values into the running fiber's references.
159
+ * An invalid candidate is logged and leaves the running references unchanged; the raw config stays retained for the next activation.
160
+ * @returns `false` when an ordinary effective value changed, so the caller applies the ordinary update lifecycle.
161
+ */
162
+ private _commitVolatile(): boolean {
163
+ const fiber = this.fiber!
164
+ const refs = volatileEntries(fiber.config)
165
+ if (!refs.length) return true
166
+ const raw = this.options.config
167
+ let candidate: unknown
225
168
  try {
226
- await this._dispose(previous)
169
+ candidate = resolveConfig(fiber.runtime!, fiber.ctx.waterfall(fiber, 'internal/config', raw, () => raw))
227
170
  } catch (error) {
228
- this.options = previousOptions
229
- throw updateError('dispose', candidate, error)
230
- }
231
-
171
+ this.ctx.logger.warn('volatile config update failed for %C', this.options.id)
172
+ this.ctx.logger.warn(error)
173
+ return true
174
+ }
175
+ if (!deepEqual(fiber.config, candidate, true)) {
176
+ this.ctx.logger.debug('ordinary config values of %C changed with its volatile values; applying the ordinary update', this.options.id)
177
+ return false
178
+ }
179
+ const paths = refs.flatMap(({ path, ref }) => {
180
+ const source = path.reduce<unknown>((value, key) => Reflect.get(value as object, key), candidate) as Volatile<unknown>
181
+ if (deepEqual(ref.get(), source.get(), true)) return []
182
+ updateVolatile(ref, source)
183
+ return [path]
184
+ })
185
+ if (!paths.length) return true
186
+ const self: Context = Object.create(fiber.ctx)
187
+ self[Context.filter] = (owner: Context) => owner.fiber === fiber
232
188
  try {
233
- await this._start(plugin)
189
+ fiber.ctx.emit(self, 'loader/volatile-update', paths)
234
190
  } catch (error) {
235
- this.options = previousOptions
236
- try {
237
- await this._start(previousPlugin)
238
- } catch (rollbackError) {
239
- throw updateError('rollback', legacy, new AggregateError([error, rollbackError]))
240
- }
241
- this.context.emit('loader/partial-dispose', this, candidate, true)
242
- throw updateError('apply', candidate, error)
191
+ // A listener failure must not fail the entry update; every value is already committed.
192
+ this.ctx.logger.warn(error)
243
193
  }
244
- commit()
245
- this.context.emit('loader/partial-dispose', this, legacy, true)
194
+ return true
246
195
  }
247
196
 
248
197
  getOuterStack = () => {
@@ -261,43 +210,27 @@ export class Entry {
261
210
  await (this._initTask ??= this._init())
262
211
  } finally {
263
212
  this._initTask = undefined
264
- if (!this.loader.getTasks().length) this.ctx.reflect.notify(['loader'])
265
213
  }
266
- await this._await()
267
- }
268
-
269
- async _await() {
270
- try {
271
- await this.fiber?.await()
272
- } catch (error) {
273
- throw updateError('apply', this.options, error)
214
+ const notify = () => {
215
+ if (this.loader.getTasks().length) return
216
+ this.ctx.reflect.notify(['loader'])
274
217
  }
218
+ this.fiber?.await().then(notify, notify)
275
219
  }
276
220
 
277
221
  private async _init() {
278
- let plugin: any
222
+ let exports: any
279
223
  try {
280
- plugin = this.loader.unwrapExports(await this.parent.tree.import(this.options.name, this.getOuterStack))
224
+ exports = await this.parent.tree.import(this.options.name, this.getOuterStack)
281
225
  } catch (error) {
282
- throw updateError('import', this.options, error)
283
- }
284
- try {
285
- await this._start(plugin)
286
- } catch (error) {
287
- throw updateError('apply', this.options, error)
288
- }
289
- }
290
-
291
- private async _start(plugin: any) {
292
- let fiber: Fiber | undefined
293
- try {
294
- await this._patchContext([])
295
- this.loader.showLog(this, 'apply')
296
- fiber = this.fiber = this.ctx.registry.plugin(plugin, this.options.config, this.getOuterStack)
297
- await fiber.await()
298
- } catch (error) {
299
- await this._dispose(fiber)
300
- throw error
226
+ this.ctx.logger.error(error)
227
+ return
228
+ } finally {
229
+ this._initTask = undefined
301
230
  }
231
+ const plugin = this.loader.unwrapExports(exports)
232
+ this._patchContext([])
233
+ this.loader.showLog(this, 'apply')
234
+ this.fiber = this.ctx.registry.plugin(plugin, this.options.config, this.getOuterStack).ctx.fiber
302
235
  }
303
236
  }