Skip to content

Commit 10aaa87

Browse files
committed
refactor(extensions): inject the CommandRegistry face
Registry operations go through the narrow subsystem contract; the full facade stays only for container-record operations (has, provider registration). First consumer of the per-face tokens.
1 parent 9eff3ef commit 10aaa87

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

lib/services/extensibility-service.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import {
2020
import { injector } from "../common/yok";
2121
import { IInjector } from "../common/definitions/yok";
2222
import { CommandsDelimiters } from "../common/constants";
23+
import { inject } from "../common/di/inject";
24+
import { CommandRegistry } from "../common/contracts";
2325
import { isCommandDefinition } from "../common/define-command";
2426
import { createCommandFromDefinition } from "../common/services/command-definition-adapter";
2527

@@ -57,6 +59,8 @@ export class ExtensibilityService implements IExtensibilityService {
5759
/** Command name -> name of the extension whose manifest claimed it first. */
5860
private manifestCommandOwners: IStringDictionary = {};
5961

62+
private commandRegistry = inject(CommandRegistry);
63+
6064
private get pathToPackageJson(): string {
6165
return path.join(this.pathToExtensions, constants.PACKAGE_JSON_FILE_NAME);
6266
}
@@ -364,12 +368,12 @@ export class ExtensibilityService implements IExtensibilityService {
364368
const parentName = commandName.split(
365369
CommandsDelimiters.HierarchicalCommand,
366370
)[0];
367-
const container = this.$injector.di;
368371
const parentWasAbsent =
369-
parentName !== commandName && !container.has(`commands.${parentName}`);
372+
parentName !== commandName &&
373+
!this.$injector.has(`commands.${parentName}`);
370374

371375
try {
372-
this.$injector.requireCommand(commandName, absoluteModulePath);
376+
this.commandRegistry.requireCommand(commandName, absoluteModulePath);
373377
} catch (err) {
374378
const owner = this.manifestCommandOwners[commandName];
375379
const ownerInfo = owner
@@ -391,17 +395,17 @@ export class ExtensibilityService implements IExtensibilityService {
391395
const exported = require(absoluteModulePath);
392396
const candidate = (exported && exported.default) ?? exported;
393397
if (isCommandDefinition(candidate)) {
394-
this.$injector.registerCommand(commandName, () =>
398+
this.commandRegistry.registerCommand(commandName, () =>
395399
createCommandFromDefinition(<any>candidate),
396400
);
397401
}
398402
};
399-
container.register({
403+
this.$injector.register({
400404
provide: `commands.${commandName}`,
401405
useLazyRequire: loader,
402406
});
403407
if (parentWasAbsent) {
404-
container.register({
408+
this.$injector.register({
405409
provide: `commands.${parentName}`,
406410
useLazyRequire: loader,
407411
});

0 commit comments

Comments
 (0)