@clairejs/client 3.3.1 → 3.3.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.
package/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  ## Change Log
2
2
 
3
- #### 3.3.1:
3
+ #### 3.3.3:
4
4
 
5
+ - update claire core
6
+ - export getAPI utils
5
7
  - remove webpack, change module to esm
6
8
 
7
9
  #### 3.2.33:
package/dist/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export * from "./api/AbstractTokenManager";
15
15
  export * from "./socket/IWebSocket";
16
16
  export * from "./api/DefaultTokenManager";
17
17
  export * from "./api/CrudApi";
18
+ export * from "./utils";
package/dist/index.js CHANGED
@@ -15,3 +15,4 @@ export * from "./api/AbstractTokenManager";
15
15
  export * from "./socket/IWebSocket";
16
16
  export * from "./api/DefaultTokenManager";
17
17
  export * from "./api/CrudApi";
18
+ export * from "./utils";
@@ -0,0 +1,2 @@
1
+ import { AbstractConstructor } from "@clairejs/core";
2
+ export declare const getAPI: <T>(cls: AbstractConstructor<T>) => T;
package/dist/utils.js ADDED
@@ -0,0 +1,16 @@
1
+ import { getServiceProvider } from "@clairejs/core";
2
+ const instancesCache = {};
3
+ const sp = getServiceProvider();
4
+ export const getAPI = (cls) => {
5
+ let cache = instancesCache[cls.name];
6
+ if (!cache) {
7
+ cache = [];
8
+ instancesCache[cls.name] = cache;
9
+ }
10
+ let instance = cache.find((i) => i instanceof cls);
11
+ if (!instance) {
12
+ instance = sp.getInjector().resolve(cls);
13
+ cache.push(instance);
14
+ }
15
+ return instance;
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clairejs/client",
3
- "version": "3.3.1",
3
+ "version": "3.3.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "axios": "^1.3.4"
14
14
  },
15
15
  "peerDependencies": {
16
- "@clairejs/core": "^3.5.1"
16
+ "@clairejs/core": "^3.6.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/mocha": "^10.0.1",