@servicetitan/react-ioc 30.2.1 → 30.3.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,"file":"use-dependencies.d.ts","sourceRoot":"","sources":["../src/use-dependencies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,EAAE,MAAM,UAAU,CAAC;AAEnD,KAAK,MAAM,CAAC,CAAC,IAAI;KACZ,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AA0BF,wBAAgB,eAAe,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAEpE;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,cAE5E"}
1
+ {"version":3,"file":"use-dependencies.d.ts","sourceRoot":"","sources":["../src/use-dependencies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,EAAE,MAAM,UAAU,CAAC;AAEnD,KAAK,MAAM,CAAC,CAAC,IAAI;KACZ,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AAwBF,wBAAgB,eAAe,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAEpE;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,cAE5E"}
@@ -1,19 +1,18 @@
1
1
  import { useRef, useContext } from 'react';
2
2
  import { ContainerContext } from './common';
3
3
  function useDependenciesInternal(tokens, optional) {
4
+ var _a;
4
5
  const ref = useRef(null);
5
6
  const container = useContext(ContainerContext);
6
- if (!ref.current) {
7
- ref.current = tokens.map(s => {
8
- if (optional) {
9
- if (s && container.isBound(s)) {
10
- return container.get(s);
11
- }
12
- return undefined;
7
+ (_a = ref.current) !== null && _a !== void 0 ? _a : (ref.current = tokens.map(s => {
8
+ if (optional) {
9
+ if (s && container.isBound(s)) {
10
+ return container.get(s);
13
11
  }
14
- return container.get(s);
15
- });
16
- }
12
+ return undefined;
13
+ }
14
+ return container.get(s);
15
+ }));
17
16
  return ref.current;
18
17
  }
19
18
  export function useDependencies(...tokens) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-dependencies.js","sourceRoot":"","sources":["../src/use-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAS,MAAM,UAAU,CAAC;AAMnD,SAAS,uBAAuB,CAC5B,MAAiB,EACjB,QAAW;IAEX,MAAM,GAAG,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAE/C,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACf,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACzB,IAAI,QAAQ,EAAE,CAAC;gBACX,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC5B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBAC5B,CAAC;gBAED,OAAO,SAAS,CAAC;YACrB,CAAC;YAED,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC,CAAM,CAAC;IACZ,CAAC;IAED,OAAO,GAAG,CAAC,OAA0C,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,eAAe,CAAkB,GAAG,MAAiB;IACjE,OAAO,uBAAuB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAkB,GAAG,MAAiB;IACzE,OAAO,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC"}
1
+ {"version":3,"file":"use-dependencies.js","sourceRoot":"","sources":["../src/use-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAS,MAAM,UAAU,CAAC;AAMnD,SAAS,uBAAuB,CAC5B,MAAiB,EACjB,QAAW;;IAEX,MAAM,GAAG,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAE/C,MAAA,GAAG,CAAC,OAAO,oCAAX,GAAG,CAAC,OAAO,GAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QAC3B,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC5B,CAAC;YAED,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC,CAAM,EAAC;IAER,OAAO,GAAG,CAAC,OAA0C,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,eAAe,CAAkB,GAAG,MAAiB;IACjE,OAAO,uBAAuB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAkB,GAAG,MAAiB;IACzE,OAAO,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/react-ioc",
3
- "version": "30.2.1",
3
+ "version": "30.3.0",
4
4
  "description": "",
5
5
  "homepage": "https://docs.st.dev/docs/frontend/react-ioc",
6
6
  "repository": {
@@ -34,5 +34,5 @@
34
34
  "cli": {
35
35
  "webpack": false
36
36
  },
37
- "gitHead": "297a0bb448afa86cf35e80c5d9a7613d8f86b0a3"
37
+ "gitHead": "7521e8d9534299652c39fb5e71348c68120aee70"
38
38
  }
@@ -13,19 +13,17 @@ function useDependenciesInternal<T extends any[], P extends boolean>(
13
13
  const ref = useRef<T | Partial<T> | null>(null);
14
14
  const container = useContext(ContainerContext);
15
15
 
16
- if (!ref.current) {
17
- ref.current = tokens.map(s => {
18
- if (optional) {
19
- if (s && container.isBound(s)) {
20
- return container.get(s);
21
- }
22
-
23
- return undefined;
16
+ ref.current ??= tokens.map(s => {
17
+ if (optional) {
18
+ if (s && container.isBound(s)) {
19
+ return container.get(s);
24
20
  }
25
21
 
26
- return container.get(s);
27
- }) as T;
28
- }
22
+ return undefined;
23
+ }
24
+
25
+ return container.get(s);
26
+ }) as T;
29
27
 
30
28
  return ref.current as P extends true ? Partial<T> : T;
31
29
  }