di-sacala 0.1.2 → 0.1.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"di-sacala.d.ts","sourceRoot":"","sources":["../src/di-sacala.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,IAAI,SAAS,MAAM;IAC1C;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACpC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,GAAG,MAAM,IAAI,CAAC,GACjD,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GACjB,CAAC,SAAS,EAAE,GACV,OAAO,GACP,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,GAC7B;KAAG,GAAG,IAAI,IAAI,GAAG,CAAC;CAAE,GACpB,KAAK,CAAC;AAIhB,KAAK,kBAAkB,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,SAAS,MAAM,WAAW,GAC3D,wBAAwB,IAAI,EAAE,GAC9B,CAAC,CAAC;AAER,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,SAAS,SAAS,CAAC,MAAM,CAAC,IACpD,OAAO,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,GAC/B,kBAAkB,CACd,IAAI,EACJ,SAAS,SAAS;KAAG,GAAG,IAAI,IAAI,GAAG,OAAO;CAAE,GACtC,2BAA2B,IAAI,EAAE,GACjC,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,CAChC,GACD,KAAK,CAAC;AAEhB,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE,QAAQ,GAAG,iBAAiB,CAAC,GACnE,OAAO,CAAC,MAAM,GAAG,EAAE,QAAQ,G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;AAER,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,SAAS,SAAS,CAAC,MAAM,CAAC,IACpD,OAAO,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,GAC/B,kBAAkB,CACd,IAAI,EACJ,SAAS,SAAS;KAAG,GAAG,IAAI,IAAI,GAAG,OAAO;CAAE,GACtC,2BAA2B,IAAI,EAAE,GACjC,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,CAChC,GACD,KAAK,CAAC;AAEhB,KAAK,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,OAAO,CAAC,MAAM,GAAG,EAAE,QAAQ,GAAG,iBAAiB,CAAC,GACnE,OAAO,CAAC,MAAM,GAAG,EAAE,QAAQ,GAAG,iBAAiB,CAAC,SAAS,KAAK,GAC5D,GAAG,GAAG,GAAG,GACT,oCAAoC,CAAC,OAAO,CACxC,MAAM,GAAG,EACT,QAAQ,GAAG,iBAAiB,CAC/B,GACG,OAAO,CAAC,MAAM,GAAG,EAAE,QAAQ,GAAG,iBAAiB,CAAC,CAAC,GACjD,MAAM,EAAE,CAAC;AAiBnB;;;;GAIG;AACH,qBAAa,WAAW;;IAGpB;;;;;;;;OAQG;IACH,MAAM,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,EAC9B,UAAU,EAAE,KAAK,YAAY,EAAE,IAAI,KAAK,CAAC,GAC1C,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAwBlB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;CAetE"}
package/dist/index.js CHANGED
@@ -1,51 +1,27 @@
1
- const s = /* @__PURE__ */ new Set(["inject", "injectContainer"]), r = (n, t) => Object.prototype.hasOwnProperty.call(n, t);
2
- class o {
1
+ const s = new Set(["inject", "injectContainer"]), i = (n, t) => Object.prototype.hasOwnProperty.call(n, t);
2
+ function c(n, t) {
3
+ for (const e in n) i(n, e) && t(e);
4
+ }
5
+ const r = (n) => {
6
+ throw new Error(n);
7
+ };
8
+ class a {
3
9
  constructor() {
4
10
  }
5
- /**
6
- * Registers a new service by instantiating it with the current container instance.
7
- * The service is then attached to the container using its `name` property.
8
- *
9
- * @template S - The type of service being injected.
10
- * @param dependency - A constructor for the service, which receives the container as its only argument.
11
- * @returns The container instance, typed with the newly added service.
12
- * @throws {Error} If a service with the same name is already registered.
13
- */
14
11
  inject(t) {
15
- const e = t.prototype.getServiceName();
16
- if (s.has(e))
17
- throw new Error(`Reserved field name: ${e}`);
18
- if (r(this, e))
19
- throw new Error(`Duplicate service name: ${e}`);
20
- let i;
21
- return Object.defineProperty(this, e, {
22
- enumerable: !0,
23
- configurable: !1,
24
- get: () => i ?? (i = new t(this))
25
- }), this;
12
+ const e = t.prototype.getServiceName.call(null);
13
+ s.has(e) && r(`Reserved field name: ${e}`), i(this, e) && r(`Duplicate service name: ${e}`);
14
+ let o;
15
+ return Object.defineProperty(this, e, { enumerable: !0, get: () => o ?? (o = new t(this)) }), this;
26
16
  }
27
- /**
28
- * Copies all service properties from another container into this one.
29
- * Useful for composing containers or providing shared dependencies.
30
- *
31
- * @template DC - The type of the other DiContainer.
32
- * @param other - The source container to copy services from.
33
- * @returns The current container instance, typed with the merged services.
34
- * @throws {Error} If any service name from the other container already exists in this container.
35
- */
36
17
  injectContainer(t) {
37
- for (const e in t)
38
- if (r(t, e) && r(this, e))
39
- throw new Error(`Containers have duplicated keys: ${e}`);
40
- for (const e in t)
41
- r(t, e) && Object.defineProperty(this, e, {
42
- enumerable: !0,
43
- configurable: !1,
44
- get: () => t[e]
45
- });
46
- return this;
18
+ return c(t, (e) => {
19
+ i(this, e) && r(`Containers have duplicated keys: ${String(e)}`);
20
+ }), c(t, (e) => {
21
+ Object.defineProperty(this, e, { enumerable: !0, get: () => t[e] });
22
+ }), this;
47
23
  }
48
24
  }
49
25
  export {
50
- o as DiContainer
26
+ a as DiContainer
51
27
  };
@@ -1 +1 @@
1
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.DiSacala={}))})(this,(function(n){"use strict";const i=new Set(["inject","injectContainer"]),r=(o,t)=>Object.prototype.hasOwnProperty.call(o,t);class a{constructor(){}inject(t){const e=t.prototype.getServiceName();if(i.has(e))throw new Error(`Reserved field name: ${e}`);if(r(this,e))throw new Error(`Duplicate service name: ${e}`);let s;return Object.defineProperty(this,e,{enumerable:!0,configurable:!1,get:()=>s??(s=new t(this))}),this}injectContainer(t){for(const e in t)if(r(t,e)&&r(this,e))throw new Error(`Containers have duplicated keys: ${e}`);for(const e in t)r(t,e)&&Object.defineProperty(this,e,{enumerable:!0,configurable:!1,get:()=>t[e]});return this}}n.DiContainer=a,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(o,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(o=typeof globalThis<"u"?globalThis:o||self,i(o.DiSacala={}))})(this,(function(o){"use strict";const i=new Set(["inject","injectContainer"]),r=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);function c(n,t){for(const e in n)r(n,e)&&t(e)}const s=n=>{throw new Error(n)};class l{constructor(){}inject(t){const e=t.prototype.getServiceName.call(null);i.has(e)&&s(`Reserved field name: ${e}`),r(this,e)&&s(`Duplicate service name: ${e}`);let a;return Object.defineProperty(this,e,{enumerable:!0,get:()=>a??(a=new t(this))}),this}injectContainer(t){return c(t,e=>{r(this,e)&&s(`Containers have duplicated keys: ${String(e)}`)}),c(t,e=>{Object.defineProperty(this,e,{enumerable:!0,get:()=>t[e]})}),this}}o.DiContainer=l,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "di-sacala",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Small type-safe dependency injection lib",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
7
+ "types": "./dist/di-sacala.d.ts",
8
8
  "files": [
9
9
  "dist"
10
10
  ],