ts-ioc-container 46.9.0 → 47.0.0

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.
@@ -63,7 +63,7 @@ class Container {
63
63
  }
64
64
  resolveOneByAlias(alias, { args, child = this, lazy } = {}) {
65
65
  this.validateContainer();
66
- const [key, ..._] = this.aliases.getKeysByAlias(alias);
66
+ const key = this.aliases.getKeysByAlias(alias)[0];
67
67
  const provider = key ? this.findProviderByKeyOrFail(key) : undefined;
68
68
  return provider?.hasAccess({ invocationScope: child, providerScope: this })
69
69
  ? provider.resolve(this, { args, lazy })
@@ -6,16 +6,15 @@ class HookContext {
6
6
  instance;
7
7
  scope;
8
8
  methodName;
9
- initialArgs = [];
10
9
  constructor(instance, scope, methodName) {
11
10
  this.instance = instance;
12
11
  this.scope = scope;
13
12
  this.methodName = methodName;
14
13
  }
15
14
  resolveArgs(...args) {
16
- return (0, inject_1.resolveArgs)(this.instance.constructor, this.methodName)(this.scope, ...[...this.initialArgs, ...args]);
15
+ return (0, inject_1.resolveArgs)(this.instance.constructor, this.methodName)(this.scope, ...args);
17
16
  }
18
- invokeMethod({ args = this.resolveArgs() } = {}) {
17
+ invokeMethod({ args = this.resolveArgs() }) {
19
18
  // @ts-ignore
20
19
  return this.instance[this.methodName](...args);
21
20
  }
@@ -23,10 +22,6 @@ class HookContext {
23
22
  // @ts-ignore
24
23
  this.instance[this.methodName] = fn.resolve(this.scope);
25
24
  }
26
- setInitialArgs(...args) {
27
- this.initialArgs = args;
28
- return this;
29
- }
30
25
  }
31
26
  exports.HookContext = HookContext;
32
27
  const createHookContext = (Target, scope, methodName = 'constructor') => new HookContext(Target, scope, methodName);
@@ -60,7 +60,7 @@ export class Container {
60
60
  }
61
61
  resolveOneByAlias(alias, { args, child = this, lazy } = {}) {
62
62
  this.validateContainer();
63
- const [key, ..._] = this.aliases.getKeysByAlias(alias);
63
+ const key = this.aliases.getKeysByAlias(alias)[0];
64
64
  const provider = key ? this.findProviderByKeyOrFail(key) : undefined;
65
65
  return provider?.hasAccess({ invocationScope: child, providerScope: this })
66
66
  ? provider.resolve(this, { args, lazy })
@@ -3,16 +3,15 @@ export class HookContext {
3
3
  instance;
4
4
  scope;
5
5
  methodName;
6
- initialArgs = [];
7
6
  constructor(instance, scope, methodName) {
8
7
  this.instance = instance;
9
8
  this.scope = scope;
10
9
  this.methodName = methodName;
11
10
  }
12
11
  resolveArgs(...args) {
13
- return resolveArgs(this.instance.constructor, this.methodName)(this.scope, ...[...this.initialArgs, ...args]);
12
+ return resolveArgs(this.instance.constructor, this.methodName)(this.scope, ...args);
14
13
  }
15
- invokeMethod({ args = this.resolveArgs() } = {}) {
14
+ invokeMethod({ args = this.resolveArgs() }) {
16
15
  // @ts-ignore
17
16
  return this.instance[this.methodName](...args);
18
17
  }
@@ -20,9 +19,5 @@ export class HookContext {
20
19
  // @ts-ignore
21
20
  this.instance[this.methodName] = fn.resolve(this.scope);
22
21
  }
23
- setInitialArgs(...args) {
24
- this.initialArgs = args;
25
- return this;
26
- }
27
22
  }
28
23
  export const createHookContext = (Target, scope, methodName = 'constructor') => new HookContext(Target, scope, methodName);
package/package.json CHANGED
@@ -1,10 +1,7 @@
1
1
  {
2
2
  "name": "ts-ioc-container",
3
- "version": "46.9.0",
3
+ "version": "47.0.0",
4
4
  "description": "Typescript IoC container",
5
- "workspaces": [
6
- "docs"
7
- ],
8
5
  "publishConfig": {
9
6
  "access": "public",
10
7
  "registry": "https://registry.npmjs.org/"
@@ -38,74 +35,40 @@
38
35
  ],
39
36
  "repository": {
40
37
  "type": "git",
41
- "url": "git+https://github.com/IgorBabkin/ts-ioc-container"
38
+ "url": "git+https://github.com/IgorBabkin/ts-ioc-container",
39
+ "directory": "packages/ts-ioc-container"
42
40
  },
43
41
  "scripts": {
44
42
  "build:cjm": "rimraf cjm && tsc -p tsconfig.production.json --outDir cjm --module CommonJS",
45
43
  "build:esm": "rimraf esm && tsc -p tsconfig.production.json --outDir esm",
46
44
  "build:types": "rimraf typings && tsc -p tsconfig.production.json --outDir typings --emitDeclarationOnly --declaration",
47
- "generate:docs": "scripts/generate-readme/generate-readme.ts && git add README.md",
48
- "build": "npm run build:cjm && npm run build:esm && npm run build:types",
49
- "test": "jest",
50
- "test:coverage": "jest --coverage --coverageReporters=lcov --coverageReporters=text-summary",
45
+ "build": "pnpm run build:cjm && pnpm run build:esm && pnpm run build:types",
46
+ "test": "jest --maxWorkers=2",
47
+ "test:coverage": "jest --maxWorkers=2 --coverage --coverageReporters=lcov --coverageReporters=text-summary",
51
48
  "type-check": "tsc --noEmit",
52
49
  "type-check:watch": "tsc --noEmit --watch",
53
- "commit": "cz",
50
+ "lint": "eslint lib/**/*.ts __tests__/**/*.ts scripts/**/*.ts",
51
+ "lint:fix": "pnpm run lint -- --fix",
54
52
  "format": "prettier --write \"**/*.ts\"",
55
- "lint": "eslint lib/**/*.ts __tests__/**/*.ts scripts/**/*.ts",
56
- "lint:fix": "npm run lint --fix",
57
- "audit": "npm audit",
58
- "prepare": "husky",
59
- "release": "npm run build && npm test && npm publish",
60
- "docs:dev": "pnpm --filter ts-ioc-container-docs run dev",
61
- "docs:serve": "pnpm --filter ts-ioc-container-docs run dev",
62
- "docs:build": "pnpm --filter ts-ioc-container-docs run build",
63
- "docs:preview": "pnpm --filter ts-ioc-container-docs run preview"
53
+ "generate:docs": "scripts/generate-readme/generate-readme.ts",
54
+ "release": "pnpm run build && pnpm run test && pnpm publish"
64
55
  },
65
56
  "devDependencies": {
66
- "@commitlint/cli": "^20.2.0",
67
- "@commitlint/config-conventional": "^20.2.0",
68
- "@semantic-release/changelog": "^6.0.3",
69
- "@semantic-release/git": "^10.0.1",
70
- "@semantic-release/github": "^12.0.2",
71
- "@semantic-release/npm": "^13.1.2",
72
57
  "@types/jest": "29.5.14",
58
+ "@types/node": "^25.1.0",
73
59
  "@typescript-eslint/eslint-plugin": "8.29.1",
74
60
  "@typescript-eslint/parser": "8.29.1",
75
- "cz-conventional-changelog": "^3.3.0",
76
61
  "eslint": "9.24.0",
77
62
  "eslint-config-prettier": "10.1.1",
78
63
  "eslint-plugin-prettier": "5.2.6",
79
64
  "handlebars": "^4.7.8",
80
- "husky": "^9.1.7",
81
65
  "jest": "29.7.0",
82
- "lint-staged": "^15.5.0",
83
66
  "moq.ts": "^7.4.1",
84
67
  "prettier": "3.5.3",
85
- "prettier-plugin-astro": "^0.14.1",
86
68
  "reflect-metadata": "^0.2.2",
87
69
  "rimraf": "6.0.1",
88
- "semantic-release": "^25.0.2",
89
70
  "ts-jest": "29.3.1",
90
71
  "typescript": "5.8.3"
91
72
  },
92
- "lint-staged": {
93
- "*.{js,ts,tsx}": [
94
- "eslint --fix",
95
- "prettier --write"
96
- ],
97
- "docs/**/*.{js,ts,tsx,mjs,astro}": [
98
- "prettier --write"
99
- ],
100
- "docs/**/*.astro": [
101
- "eslint --fix"
102
- ]
103
- },
104
- "gitHead": "ae10f302c7e0f55196b42669040735112479a854",
105
- "config": {
106
- "commitizen": {
107
- "path": "./node_modules/cz-conventional-changelog"
108
- }
109
- },
110
- "packageManager": "pnpm@10.20.0+sha512.cf9998222162dd85864d0a8102e7892e7ba4ceadebbf5a31f9c2fce48dfce317a9c53b9f6464d1ef9042cba2e02ae02a9f7c143a2b438cd93c91840f0192b9dd"
73
+ "gitHead": "a69936f0186667124169b27700f2e6da7b48dc93"
111
74
  }
@@ -5,24 +5,21 @@ export interface IHookContext {
5
5
  scope: IContainer;
6
6
  methodName?: string;
7
7
  resolveArgs(...args: unknown[]): unknown[];
8
- invokeMethod(options?: {
8
+ invokeMethod({ args }: {
9
9
  args?: unknown[];
10
10
  }): unknown;
11
11
  setProperty(fn: InjectionToken): void;
12
- setInitialArgs(...args: unknown[]): this;
13
12
  }
14
13
  export declare class HookContext implements IHookContext {
15
14
  instance: object;
16
15
  scope: IContainer;
17
16
  methodName?: string | undefined;
18
- private initialArgs;
19
17
  constructor(instance: object, scope: IContainer, methodName?: string | undefined);
20
18
  resolveArgs(...args: unknown[]): unknown[];
21
- invokeMethod({ args }?: {
19
+ invokeMethod({ args }: {
22
20
  args?: unknown[];
23
21
  }): unknown;
24
22
  setProperty(fn: InjectionToken): void;
25
- setInitialArgs(...args: unknown[]): this;
26
23
  }
27
24
  export type CreateHookContext = (Target: object, scope: IContainer, methodName?: string) => IHookContext;
28
25
  export declare const createHookContext: CreateHookContext;