ts-ioc-container 46.8.1 → 46.9.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)[0];
66
+ const [key, ..._] = this.aliases.getKeysByAlias(alias);
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,15 +6,16 @@ class HookContext {
6
6
  instance;
7
7
  scope;
8
8
  methodName;
9
+ initialArgs = [];
9
10
  constructor(instance, scope, methodName) {
10
11
  this.instance = instance;
11
12
  this.scope = scope;
12
13
  this.methodName = methodName;
13
14
  }
14
15
  resolveArgs(...args) {
15
- return (0, inject_1.resolveArgs)(this.instance.constructor, this.methodName)(this.scope, ...args);
16
+ return (0, inject_1.resolveArgs)(this.instance.constructor, this.methodName)(this.scope, ...[...this.initialArgs, ...args]);
16
17
  }
17
- invokeMethod({ args = this.resolveArgs() }) {
18
+ invokeMethod({ args = this.resolveArgs() } = {}) {
18
19
  // @ts-ignore
19
20
  return this.instance[this.methodName](...args);
20
21
  }
@@ -22,6 +23,10 @@ class HookContext {
22
23
  // @ts-ignore
23
24
  this.instance[this.methodName] = fn.resolve(this.scope);
24
25
  }
26
+ setInitialArgs(...args) {
27
+ this.initialArgs = args;
28
+ return this;
29
+ }
25
30
  }
26
31
  exports.HookContext = HookContext;
27
32
  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)[0];
63
+ const [key, ..._] = this.aliases.getKeysByAlias(alias);
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,15 +3,16 @@ export class HookContext {
3
3
  instance;
4
4
  scope;
5
5
  methodName;
6
+ initialArgs = [];
6
7
  constructor(instance, scope, methodName) {
7
8
  this.instance = instance;
8
9
  this.scope = scope;
9
10
  this.methodName = methodName;
10
11
  }
11
12
  resolveArgs(...args) {
12
- return resolveArgs(this.instance.constructor, this.methodName)(this.scope, ...args);
13
+ return resolveArgs(this.instance.constructor, this.methodName)(this.scope, ...[...this.initialArgs, ...args]);
13
14
  }
14
- invokeMethod({ args = this.resolveArgs() }) {
15
+ invokeMethod({ args = this.resolveArgs() } = {}) {
15
16
  // @ts-ignore
16
17
  return this.instance[this.methodName](...args);
17
18
  }
@@ -19,5 +20,9 @@ export class HookContext {
19
20
  // @ts-ignore
20
21
  this.instance[this.methodName] = fn.resolve(this.scope);
21
22
  }
23
+ setInitialArgs(...args) {
24
+ this.initialArgs = args;
25
+ return this;
26
+ }
22
27
  }
23
28
  export const createHookContext = (Target, scope, methodName = 'constructor') => new HookContext(Target, scope, methodName);
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "ts-ioc-container",
3
- "version": "46.8.1",
3
+ "version": "46.9.0",
4
4
  "description": "Typescript IoC container",
5
+ "workspaces": [
6
+ "docs"
7
+ ],
5
8
  "publishConfig": {
6
9
  "access": "public",
7
10
  "registry": "https://registry.npmjs.org/"
@@ -35,39 +38,74 @@
35
38
  ],
36
39
  "repository": {
37
40
  "type": "git",
38
- "url": "git+https://github.com/IgorBabkin/ts-ioc-container",
39
- "directory": "packages/ts-ioc-container"
41
+ "url": "git+https://github.com/IgorBabkin/ts-ioc-container"
40
42
  },
41
43
  "scripts": {
42
44
  "build:cjm": "rimraf cjm && tsc -p tsconfig.production.json --outDir cjm --module CommonJS",
43
45
  "build:esm": "rimraf esm && tsc -p tsconfig.production.json --outDir esm",
44
46
  "build:types": "rimraf typings && tsc -p tsconfig.production.json --outDir typings --emitDeclarationOnly --declaration",
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",
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",
48
51
  "type-check": "tsc --noEmit",
49
52
  "type-check:watch": "tsc --noEmit --watch",
50
- "lint": "eslint lib/**/*.ts __tests__/**/*.ts scripts/**/*.ts",
51
- "lint:fix": "pnpm run lint -- --fix",
53
+ "commit": "cz",
52
54
  "format": "prettier --write \"**/*.ts\"",
53
- "generate:docs": "scripts/generate-readme/generate-readme.ts",
54
- "release": "pnpm run build && pnpm run test && pnpm publish"
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"
55
64
  },
56
65
  "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",
57
72
  "@types/jest": "29.5.14",
58
- "@types/node": "^25.1.0",
59
73
  "@typescript-eslint/eslint-plugin": "8.29.1",
60
74
  "@typescript-eslint/parser": "8.29.1",
75
+ "cz-conventional-changelog": "^3.3.0",
61
76
  "eslint": "9.24.0",
62
77
  "eslint-config-prettier": "10.1.1",
63
78
  "eslint-plugin-prettier": "5.2.6",
64
79
  "handlebars": "^4.7.8",
80
+ "husky": "^9.1.7",
65
81
  "jest": "29.7.0",
82
+ "lint-staged": "^15.5.0",
66
83
  "moq.ts": "^7.4.1",
67
84
  "prettier": "3.5.3",
85
+ "prettier-plugin-astro": "^0.14.1",
68
86
  "reflect-metadata": "^0.2.2",
69
87
  "rimraf": "6.0.1",
88
+ "semantic-release": "^25.0.2",
70
89
  "ts-jest": "29.3.1",
71
90
  "typescript": "5.8.3"
72
- }
91
+ },
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
111
  }
@@ -5,21 +5,24 @@ export interface IHookContext {
5
5
  scope: IContainer;
6
6
  methodName?: string;
7
7
  resolveArgs(...args: unknown[]): unknown[];
8
- invokeMethod({ args }: {
8
+ invokeMethod(options?: {
9
9
  args?: unknown[];
10
10
  }): unknown;
11
11
  setProperty(fn: InjectionToken): void;
12
+ setInitialArgs(...args: unknown[]): this;
12
13
  }
13
14
  export declare class HookContext implements IHookContext {
14
15
  instance: object;
15
16
  scope: IContainer;
16
17
  methodName?: string | undefined;
18
+ private initialArgs;
17
19
  constructor(instance: object, scope: IContainer, methodName?: string | undefined);
18
20
  resolveArgs(...args: unknown[]): unknown[];
19
- invokeMethod({ args }: {
21
+ invokeMethod({ args }?: {
20
22
  args?: unknown[];
21
23
  }): unknown;
22
24
  setProperty(fn: InjectionToken): void;
25
+ setInitialArgs(...args: unknown[]): this;
23
26
  }
24
27
  export type CreateHookContext = (Target: object, scope: IContainer, methodName?: string) => IHookContext;
25
28
  export declare const createHookContext: CreateHookContext;