Skip to content

Commit f15d250

Browse files
committed
refactor(yok): re-point the facade at the token-based injector
Yok keeps its entire public surface, subclassability, and the global $injector, while storage and resolution delegate to the new container. Command routing, key commands, and the public-API builder are unchanged. Every legacy member now carries @deprecated JSDoc naming its replacement, mirrored on IInjector.
1 parent 791374f commit f15d250

2 files changed

Lines changed: 258 additions & 157 deletions

File tree

lib/common/definitions/yok.d.ts

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,154 @@ import { IDisposable, IDictionary } from "../declarations";
22
import { ICommand } from "./commands";
33
import { IKeyCommand, IValidKeyName } from "./key-commands";
44

5+
/**
6+
* The legacy injector facade surface. Every member is individually
7+
* @deprecated in favor of the token-based container in lib/common/di;
8+
* the interface itself survives until the hook/extension deprecation
9+
* completes.
10+
*/
511
interface IInjector extends IDisposable {
12+
/**
13+
* @deprecated Use provideLazy() from lib/common/di — the same deferred
14+
* loading, token-based.
15+
*/
616
require(name: string, file: string): void;
17+
/**
18+
* @deprecated Use provideLazy() from lib/common/di — the same deferred
19+
* loading, token-based.
20+
*/
721
require(names: string[], file: string): void;
22+
/**
23+
* @deprecated Legacy public-API builder.
24+
*/
825
requirePublic(names: string | string[], file: string): void;
26+
/**
27+
* @deprecated Legacy public-API builder.
28+
*/
929
requirePublicClass(names: string | string[], file: string): void;
30+
/**
31+
* @deprecated Path-based command registration; slated for replacement by
32+
* manifest-declared commands.
33+
*/
1034
requireCommand(name: string, file: string): void;
35+
/**
36+
* @deprecated Path-based command registration; slated for replacement by
37+
* manifest-declared commands.
38+
*/
1139
requireCommand(names: string[], file: string): void;
40+
/**
41+
* @deprecated Replaced together with the command registry.
42+
*/
1243
requireKeyCommand(name: IValidKeyName, file: string): void;
1344
/**
1445
* Resolves an implementation by constructor function.
1546
* The injector will create new instances for every call.
47+
* @deprecated Use Injector.createInstance from lib/common/di.
1648
*/
1749
resolve(ctor: Function, ctorArguments?: { [key: string]: any }): any;
50+
/**
51+
* @deprecated Use Injector.createInstance from lib/common/di.
52+
*/
1853
resolve<T>(ctor: Function, ctorArguments?: { [key: string]: any }): T;
1954
/**
2055
* Resolves an implementation by name.
2156
* The injector will create only one instance per name and return the same instance on subsequent calls.
57+
* @deprecated Use inject(Token) in an injection context, or Injector.get
58+
* from lib/common/di.
2259
*/
2360
resolve(name: string, ctorArguments?: IDictionary<any>): any;
61+
/**
62+
* @deprecated Use inject(Token) in an injection context, or Injector.get
63+
* from lib/common/di.
64+
*/
2465
resolve<T>(name: string, ctorArguments?: IDictionary<any>): T;
2566

67+
/**
68+
* @deprecated Legacy command-registry lookup.
69+
*/
2670
resolveCommand(name: string): ICommand;
71+
/**
72+
* @deprecated Legacy command-registry lookup.
73+
*/
2774
resolveKeyCommand(key: string): IKeyCommand;
75+
/**
76+
* @deprecated Use provide() / Injector.register from lib/common/di; a
77+
* contract's token name keeps string spellings resolvable.
78+
*/
2879
register(name: string, resolver: any, shared?: boolean): void;
80+
/**
81+
* @deprecated Slated for replacement by defineCommand and manifest-declared
82+
* commands.
83+
*/
2984
registerCommand(name: string, resolver: any): void;
85+
/**
86+
* @deprecated Slated for replacement by defineCommand and manifest-declared
87+
* commands.
88+
*/
3089
registerCommand(names: string[], resolver: any): void;
90+
/**
91+
* @deprecated Replaced together with the command registry.
92+
*/
3193
registerKeyCommand(key: IValidKeyName, resolver: any): void;
94+
/**
95+
* @deprecated Legacy command-registry enumeration; feeds shell
96+
* autocompletion and help.
97+
*/
3298
getRegisteredCommandsNames(includeDev: boolean): string[];
99+
/**
100+
* @deprecated Legacy command-registry enumeration.
101+
*/
33102
getRegisteredKeyCommandsNames(): string[];
103+
/**
104+
* @deprecated String-reflective help templating; removable only together
105+
* with the help-template pipeline.
106+
*/
34107
dynamicCallRegex: RegExp;
108+
/**
109+
* @deprecated See dynamicCallRegex.
110+
*/
35111
dynamicCall(call: string, args?: any[]): Promise<any>;
112+
/**
113+
* @deprecated Legacy command-registry routing.
114+
*/
36115
isDefaultCommand(commandName: string): boolean;
116+
/**
117+
* @deprecated Legacy command-registry routing.
118+
* Side-effecting: fails with help output on a bad subcommand.
119+
*/
37120
isValidHierarchicalCommand(
38121
commandName: string,
39-
commandArguments: string[]
122+
commandArguments: string[],
40123
): Promise<boolean>;
124+
/**
125+
* @deprecated Legacy command-registry routing.
126+
*/
41127
getChildrenCommandsNames(commandName: string): string[];
128+
/**
129+
* @deprecated Hierarchical-routing internals of the legacy command
130+
* registry.
131+
*/
42132
buildHierarchicalCommand(
43133
parentCommandName: string,
44-
commandLineArguments: string[]
134+
commandLineArguments: string[],
45135
): any;
136+
/**
137+
* @deprecated Backing store of the require('nativescript') surface.
138+
* Do not add new entries through it.
139+
*/
46140
publicApi: any;
47141

48142
/**
49143
* Defines if it's allowed to override already required module.
50144
* This can be used in order to allow redefinition of modules, for example $logger can be replaced by a plugin.
51145
* Default value is false.
146+
* @deprecated Escape hatch of the legacy require-time module map.
52147
*/
53148
overrideAlreadyRequiredModule: boolean;
54149
}
55150

151+
/**
152+
* @deprecated The process-wide legacy injector global. New code receives the
153+
* container via inject(Injector) from lib/common/di.
154+
*/
56155
declare var $injector: IInjector;

0 commit comments

Comments
 (0)