@servicetitan/react-ioc 31.3.2 → 31.5.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/inject-dependency.ts"],"sourcesContent":["import { interfaces, METADATA_KEY } from 'inversify';\n\nimport { ContainerContext } from './common';\n\nconst INJECTION = Symbol.for('INJECTION');\n\nfunction proxyGetter(\n proto: any,\n key: string,\n resolve: (componentInstance: any) => any,\n doCache: boolean\n) {\n function getter(this: any) {\n if (doCache && !Reflect.hasMetadata(INJECTION, this, key)) {\n Reflect.defineMetadata(INJECTION, resolve(this), this, key);\n }\n if (Reflect.hasMetadata(INJECTION, this, key)) {\n return Reflect.getMetadata(INJECTION, this, key);\n }\n return resolve(this);\n }\n function setter(this: any, newVal: any) {\n Reflect.defineMetadata(INJECTION, newVal, this, key);\n }\n Object.defineProperty(proto, key, {\n configurable: true,\n enumerable: true,\n get: getter,\n set: setter,\n });\n}\n\nexport function injectDependency(serviceIdentifier: interfaces.ServiceIdentifier<any>) {\n return function (proto: any, key: string): void {\n const resolve = (componentInstance: any) => {\n if (!componentInstance.context) {\n throw new Error(\n \"Context doesn't exist on a target class. \" +\n 'Please make sure to pass context object to super method if you access injectable stores in constructor.'\n );\n }\n\n const metadata: Partial<interfaces.MetadataMap> =\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, proto.constructor) || {};\n\n if (\n metadata[key]?.some(({ key, value }) => key === METADATA_KEY.OPTIONAL_TAG && value)\n ) {\n if (componentInstance.context.isBound(serviceIdentifier)) {\n return componentInstance.context.get(serviceIdentifier);\n }\n } else {\n return componentInstance.context.get(serviceIdentifier);\n }\n };\n\n if (proto.constructor.contextType && proto.constructor.contextType !== ContainerContext) {\n throw new Error(\n \"injectDependency can't be used together with contextType static property\"\n );\n }\n\n proto.constructor.contextType = ContainerContext;\n proxyGetter(proto, key, resolve, true);\n };\n}\n"],"names":["METADATA_KEY","ContainerContext","INJECTION","Symbol","for","proxyGetter","proto","key","resolve","doCache","getter","Reflect","hasMetadata","defineMetadata","getMetadata","setter","newVal","Object","defineProperty","configurable","enumerable","get","set","injectDependency","serviceIdentifier","componentInstance","metadata","context","Error","TAGGED_PROP","constructor","some","value","OPTIONAL_TAG","isBound","contextType"],"mappings":"AAAA,SAAqBA,YAAY,QAAQ,YAAY;AAErD,SAASC,gBAAgB,QAAQ,WAAW;AAE5C,MAAMC,YAAYC,OAAOC,GAAG,CAAC;AAE7B,SAASC,YACLC,KAAU,EACVC,GAAW,EACXC,OAAwC,EACxCC,OAAgB;IAEhB,SAASC;QACL,IAAID,WAAW,CAACE,QAAQC,WAAW,CAACV,WAAW,IAAI,EAAEK,MAAM;YACvDI,QAAQE,cAAc,CAACX,WAAWM,QAAQ,IAAI,GAAG,IAAI,EAAED;QAC3D;QACA,IAAII,QAAQC,WAAW,CAACV,WAAW,IAAI,EAAEK,MAAM;YAC3C,OAAOI,QAAQG,WAAW,CAACZ,WAAW,IAAI,EAAEK;QAChD;QACA,OAAOC,QAAQ,IAAI;IACvB;IACA,SAASO,OAAkBC,MAAW;QAClCL,QAAQE,cAAc,CAACX,WAAWc,QAAQ,IAAI,EAAET;IACpD;IACAU,OAAOC,cAAc,CAACZ,OAAOC,KAAK;QAC9BY,cAAc;QACdC,YAAY;QACZC,KAAKX;QACLY,KAAKP;IACT;AACJ;AAEA,OAAO,SAASQ,iBAAiBC,iBAAoD;IACjF,OAAO,SAAUlB,KAAU,EAAEC,GAAW;QACpC,MAAMC,UAAU,CAACiB;gBAaTC;YAZJ,IAAI,CAACD,kBAAkBE,OAAO,EAAE;gBAC5B,MAAM,IAAIC,MACN,8CACI;YAEZ;YAEA,MAAMF,WACF,wEAAwE;YACxEf,QAAQG,WAAW,CAACd,aAAa6B,WAAW,EAAEvB,MAAMwB,WAAW,KAAK,CAAC;YAEzE,KACIJ,gBAAAA,QAAQ,CAACnB,IAAI,cAAbmB,oCAAAA,cAAeK,IAAI,CAAC,CAAC,EAAExB,GAAG,EAAEyB,KAAK,EAAE,GAAKzB,QAAQP,aAAaiC,YAAY,IAAID,QAC/E;gBACE,IAAIP,kBAAkBE,OAAO,CAACO,OAAO,CAACV,oBAAoB;oBACtD,OAAOC,kBAAkBE,OAAO,CAACN,GAAG,CAACG;gBACzC;YACJ,OAAO;gBACH,OAAOC,kBAAkBE,OAAO,CAACN,GAAG,CAACG;YACzC;QACJ;QAEA,IAAIlB,MAAMwB,WAAW,CAACK,WAAW,IAAI7B,MAAMwB,WAAW,CAACK,WAAW,KAAKlC,kBAAkB;YACrF,MAAM,IAAI2B,MACN;QAER;QAEAtB,MAAMwB,WAAW,CAACK,WAAW,GAAGlC;QAChCI,YAAYC,OAAOC,KAAKC,SAAS;IACrC;AACJ"}
1
+ {"version":3,"sources":["../src/inject-dependency.ts"],"sourcesContent":["import { interfaces, METADATA_KEY } from 'inversify';\n\nimport { ContainerContext } from './common';\n\nconst INJECTION = Symbol.for('INJECTION');\n\nfunction proxyGetter(\n proto: any,\n key: string,\n resolve: (componentInstance: any) => any,\n doCache: boolean\n) {\n function getter(this: any) {\n if (doCache && !Reflect.hasMetadata(INJECTION, this, key)) {\n Reflect.defineMetadata(INJECTION, resolve(this), this, key);\n }\n if (Reflect.hasMetadata(INJECTION, this, key)) {\n return Reflect.getMetadata(INJECTION, this, key);\n }\n return resolve(this);\n }\n function setter(this: any, newVal: any) {\n Reflect.defineMetadata(INJECTION, newVal, this, key);\n }\n Object.defineProperty(proto, key, {\n configurable: true,\n enumerable: true,\n get: getter,\n set: setter,\n });\n}\n\nexport function injectDependency(serviceIdentifier: interfaces.ServiceIdentifier<any>) {\n return function (proto: any, key: string): void {\n const resolve = (componentInstance: any) => {\n if (!componentInstance.context) {\n throw new Error(\n \"Context doesn't exist on a target class. \" +\n 'Please make sure to pass context object to super method if you access injectable stores in constructor.'\n );\n }\n\n const metadata: Partial<interfaces.MetadataMap> =\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, proto.constructor) || {};\n\n if (\n metadata[key]?.some(({ key, value }) => key === METADATA_KEY.OPTIONAL_TAG && value)\n ) {\n if (componentInstance.context.isBound(serviceIdentifier)) {\n return componentInstance.context.get(serviceIdentifier);\n }\n } else {\n return componentInstance.context.get(serviceIdentifier);\n }\n };\n\n if (proto.constructor.contextType && proto.constructor.contextType !== ContainerContext) {\n throw new Error(\n \"injectDependency can't be used together with contextType static property\"\n );\n }\n\n proto.constructor.contextType = ContainerContext;\n proxyGetter(proto, key, resolve, true);\n };\n}\n"],"names":["METADATA_KEY","ContainerContext","INJECTION","Symbol","for","proxyGetter","proto","key","resolve","doCache","getter","Reflect","hasMetadata","defineMetadata","getMetadata","setter","newVal","Object","defineProperty","configurable","enumerable","get","set","injectDependency","serviceIdentifier","componentInstance","metadata","context","Error","TAGGED_PROP","some","value","OPTIONAL_TAG","isBound","contextType"],"mappings":"AAAA,SAAqBA,YAAY,QAAQ,YAAY;AAErD,SAASC,gBAAgB,QAAQ,WAAW;AAE5C,MAAMC,YAAYC,OAAOC,GAAG,CAAC;AAE7B,SAASC,YACLC,KAAU,EACVC,GAAW,EACXC,OAAwC,EACxCC,OAAgB;IAEhB,SAASC;QACL,IAAID,WAAW,CAACE,QAAQC,WAAW,CAACV,WAAW,IAAI,EAAEK,MAAM;YACvDI,QAAQE,cAAc,CAACX,WAAWM,QAAQ,IAAI,GAAG,IAAI,EAAED;QAC3D;QACA,IAAII,QAAQC,WAAW,CAACV,WAAW,IAAI,EAAEK,MAAM;YAC3C,OAAOI,QAAQG,WAAW,CAACZ,WAAW,IAAI,EAAEK;QAChD;QACA,OAAOC,QAAQ,IAAI;IACvB;IACA,SAASO,OAAkBC,MAAW;QAClCL,QAAQE,cAAc,CAACX,WAAWc,QAAQ,IAAI,EAAET;IACpD;IACAU,OAAOC,cAAc,CAACZ,OAAOC,KAAK;QAC9BY,cAAc;QACdC,YAAY;QACZC,KAAKX;QACLY,KAAKP;IACT;AACJ;AAEA,OAAO,SAASQ,iBAAiBC,iBAAoD;IACjF,OAAO,SAAUlB,KAAU,EAAEC,GAAW;QACpC,MAAMC,UAAU,CAACiB;gBAaTC;YAZJ,IAAI,CAACD,kBAAkBE,OAAO,EAAE;gBAC5B,MAAM,IAAIC,MACN,8CACI;YAEZ;YAEA,MAAMF,WACF,wEAAwE;YACxEf,QAAQG,WAAW,CAACd,aAAa6B,WAAW,EAAEvB,MAAM,WAAW,KAAK,CAAC;YAEzE,KACIoB,gBAAAA,QAAQ,CAACnB,IAAI,cAAbmB,oCAAAA,cAAeI,IAAI,CAAC,CAAC,EAAEvB,GAAG,EAAEwB,KAAK,EAAE,GAAKxB,QAAQP,aAAagC,YAAY,IAAID,QAC/E;gBACE,IAAIN,kBAAkBE,OAAO,CAACM,OAAO,CAACT,oBAAoB;oBACtD,OAAOC,kBAAkBE,OAAO,CAACN,GAAG,CAACG;gBACzC;YACJ,OAAO;gBACH,OAAOC,kBAAkBE,OAAO,CAACN,GAAG,CAACG;YACzC;QACJ;QAEA,IAAIlB,MAAM,WAAW,CAAC4B,WAAW,IAAI5B,MAAM,WAAW,CAAC4B,WAAW,KAAKjC,kBAAkB;YACrF,MAAM,IAAI2B,MACN;QAER;QAEAtB,MAAM,WAAW,CAAC4B,WAAW,GAAGjC;QAChCI,YAAYC,OAAOC,KAAKC,SAAS;IACrC;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/react-ioc",
3
- "version": "31.3.2",
3
+ "version": "31.5.0",
4
4
  "description": "",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/react-ioc",
6
6
  "repository": {
@@ -20,8 +20,8 @@
20
20
  "reflect-metadata": "~0.2.2"
21
21
  },
22
22
  "devDependencies": {
23
- "@testing-library/dom": "^10.4.0",
24
- "@testing-library/jest-dom": "^6.6.3",
23
+ "@testing-library/dom": "^10.4.1",
24
+ "@testing-library/jest-dom": "^6.6.4",
25
25
  "@testing-library/react": "^16.3.0",
26
26
  "@types/react": "~18.3.3",
27
27
  "react": "~18.3.1"
@@ -35,5 +35,5 @@
35
35
  "cli": {
36
36
  "webpack": false
37
37
  },
38
- "gitHead": "c9909c13f221700fe9d3adb043d2faa26472e921"
38
+ "gitHead": "6fce124ae36f2a36705247f6300ca8354aba6fb2"
39
39
  }