@zhin.js/runtime 1.0.17 → 1.0.18

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.
@@ -23,6 +23,8 @@ export declare class ConfigValidationError extends Error {
23
23
  source?: string | undefined);
24
24
  }
25
25
  export declare class ConfigComposer {
26
+ private readonly inactivePluginInstanceKeys;
27
+ constructor(inactivePluginInstanceKeys?: readonly string[]);
26
28
  compose(graph: ProjectGraph, input?: RuntimeConfigDocument,
27
29
  /** Source config file name, annotated on ConfigValidationError. */
28
30
  source?: string): Promise<ComposedConfig>;
@@ -36,6 +36,10 @@ export class ConfigValidationError extends Error {
36
36
  }
37
37
  }
38
38
  export class ConfigComposer {
39
+ inactivePluginInstanceKeys;
40
+ constructor(inactivePluginInstanceKeys = []) {
41
+ this.inactivePluginInstanceKeys = inactivePluginInstanceKeys;
42
+ }
39
43
  async compose(graph, input = {},
40
44
  /** Source config file name, annotated on ConfigValidationError. */
41
45
  source) {
@@ -61,7 +65,10 @@ export class ConfigComposer {
61
65
  type: 'object',
62
66
  additionalProperties: false,
63
67
  default: {},
64
- properties: Object.fromEntries(childSchemas.map(([key, schema]) => [key, withDefault(schema)])),
68
+ properties: Object.fromEntries([
69
+ ...this.inactivePluginInstanceKeys.map((key) => [key, {}]),
70
+ ...childSchemas.map(([key, schema]) => [key, withDefault(schema)]),
71
+ ]),
65
72
  },
66
73
  },
67
74
  });
@@ -20,6 +20,7 @@ export interface ProjectGraph {
20
20
  }
21
21
  export interface ProjectGraphServiceOptions {
22
22
  readonly engineVersion?: string;
23
+ readonly disabledPluginInstanceKeys?: readonly string[];
23
24
  }
24
25
  export declare class ProjectGraphError extends Error {
25
26
  constructor(message: string);
@@ -11,11 +11,15 @@ export class ProjectGraphError extends Error {
11
11
  export class ProjectGraphService {
12
12
  #resolver;
13
13
  #engineVersion;
14
+ #disabledPluginInstanceKeys;
14
15
  constructor(resolver, engineVersionOrOptions = runtimeEngineVersion) {
15
16
  this.#resolver = resolver;
16
17
  this.#engineVersion = typeof engineVersionOrOptions === 'string'
17
18
  ? engineVersionOrOptions
18
19
  : (engineVersionOrOptions.engineVersion ?? runtimeEngineVersion);
20
+ this.#disabledPluginInstanceKeys = new Set(typeof engineVersionOrOptions === 'string'
21
+ ? []
22
+ : (engineVersionOrOptions.disabledPluginInstanceKeys ?? []));
19
23
  }
20
24
  async inspect(projectRoot) {
21
25
  const rootPackage = await this.#resolver.root(projectRoot);
@@ -58,6 +62,9 @@ export class ProjectGraphService {
58
62
  pluginRefs = mergeChildPluginReferences(manifest.plugins, inheritedPlugins);
59
63
  }
60
64
  }
65
+ if (isRoot && this.#disabledPluginInstanceKeys.size > 0) {
66
+ pluginRefs = pluginRefs.filter((reference) => !this.#disabledPluginInstanceKeys.has(reference.instanceKey));
67
+ }
61
68
  const featurePackages = new Set();
62
69
  const features = await Promise.all(featureRefs.map(async (reference) => {
63
70
  if (featurePackages.has(reference.package)) {
@@ -21,6 +21,7 @@ export interface RootRuntimeOptions {
21
21
  readonly installResources?: RootResourceInstaller;
22
22
  readonly isolation?: IsolatedPluginRuntimePort;
23
23
  readonly onControlError?: ControlErrorHandler;
24
+ readonly disabledPluginInstanceKeys?: readonly string[];
24
25
  }
25
26
  export type RootHmrOptions = Omit<HmrCoordinatorOptions, 'modules' | 'ownership' | 'runtime'>;
26
27
  export declare class RootRuntime {
@@ -37,6 +37,7 @@ export class RootRuntime {
37
37
  #configPatchTail = Promise.resolve();
38
38
  #stopResult;
39
39
  #controller;
40
+ #disabledPluginInstanceKeys;
40
41
  constructor(options) {
41
42
  this.#projectRoot = resolve(options.projectRoot);
42
43
  this.#modules = options.modules;
@@ -50,6 +51,7 @@ export class RootRuntime {
50
51
  this.#configDocument = structuredClone(options.config ?? {});
51
52
  this.#installResources = options.installResources;
52
53
  this.#isolation = options.isolation;
54
+ this.#disabledPluginInstanceKeys = Object.freeze([...(options.disabledPluginInstanceKeys ?? [])]);
53
55
  this.#controller = new RootController(emptyState(), options.onControlError, Object.freeze({ ownership: SourceOwnershipIndex.empty() }));
54
56
  }
55
57
  get snapshot() {
@@ -187,7 +189,9 @@ export class RootRuntime {
187
189
  }
188
190
  async #inspectProject() {
189
191
  const resolver = await NodePackageResolver.create(this.#projectRoot);
190
- const graph = await new ProjectGraphService(resolver).inspect(this.#projectRoot);
192
+ const graph = await new ProjectGraphService(resolver, {
193
+ disabledPluginInstanceKeys: this.#disabledPluginInstanceKeys,
194
+ }).inspect(this.#projectRoot);
191
195
  await this.#refreshConfigDocument();
192
196
  if (this.#configResolver) {
193
197
  return {
@@ -196,7 +200,8 @@ export class RootRuntime {
196
200
  primaryConfigDocument: Object.freeze({}),
197
201
  };
198
202
  }
199
- const composed = await new ConfigComposer().compose(graph, this.#configDocument);
203
+ const composed = await new ConfigComposer(this.#disabledPluginInstanceKeys)
204
+ .compose(graph, this.#configDocument);
200
205
  return {
201
206
  graph,
202
207
  configResolver: this.#configViewResolver(composed.views),
@@ -243,8 +248,10 @@ export class RootRuntime {
243
248
  let prepared;
244
249
  signal.throwIfAborted();
245
250
  const resolver = await NodePackageResolver.create(this.#projectRoot);
246
- const graph = await new ProjectGraphService(resolver).inspect(this.#projectRoot);
247
- const planned = await new ConfigPatchPlanner().plan(graph, currentDocument, patches);
251
+ const graph = await new ProjectGraphService(resolver, {
252
+ disabledPluginInstanceKeys: this.#disabledPluginInstanceKeys,
253
+ }).inspect(this.#projectRoot);
254
+ const planned = await new ConfigPatchPlanner(new ConfigComposer(this.#disabledPluginInstanceKeys)).plan(graph, currentDocument, patches);
248
255
  plan = planned;
249
256
  if (!planned.documentChanged)
250
257
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/runtime",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "Static Plugin graph, generation transaction and HMR Root runtime for Zhin.js",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -25,8 +25,8 @@
25
25
  "@types/node": "^26.1.2",
26
26
  "typescript": "^6.0.3",
27
27
  "@zhin.js/adapter": "1.2.1",
28
- "@zhin.js/command": "1.0.16",
29
28
  "@zhin.js/agent-feature": "1.0.13",
29
+ "@zhin.js/command": "1.0.16",
30
30
  "@zhin.js/component": "1.0.13",
31
31
  "@zhin.js/layout": "1.0.13",
32
32
  "@zhin.js/mcp-feature": "1.0.13",