@mittwald/api-models 4.94.0 → 4.95.1
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.
|
@@ -3,8 +3,14 @@ import { hash } from "object-code";
|
|
|
3
3
|
import { reactProvisionContext } from "./reactProvisionContext.js";
|
|
4
4
|
import { joinedId } from "../lib/joinedId.js";
|
|
5
5
|
export const provideReact = (loader, dependencies = []) => {
|
|
6
|
-
const
|
|
6
|
+
const loaderHash = hash(loader);
|
|
7
|
+
let cachedProvisionId;
|
|
7
8
|
const getAsyncResource = (params) => {
|
|
9
|
+
const provisionId = cachedProvisionId ??
|
|
10
|
+
joinedId(loaderHash, ...dependencies
|
|
11
|
+
.map((d) => (typeof d === "function" ? d() : d))
|
|
12
|
+
.map((d) => hash(d)));
|
|
13
|
+
cachedProvisionId = provisionId;
|
|
8
14
|
const contextId = joinedId(provisionId, hash(params));
|
|
9
15
|
const loaderWithContext = reactProvisionContext.bind({
|
|
10
16
|
id: contextId,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { AsyncResource } from "./reactUsePromise.js";
|
|
2
2
|
import { AsyncReturnType } from "type-fest";
|
|
3
3
|
type AsyncFn = (...args: any[]) => Promise<unknown>;
|
|
4
|
-
|
|
4
|
+
type ReactProvisionDep = string | number;
|
|
5
|
+
type LazyReactProvisionDep = () => ReactProvisionDep;
|
|
6
|
+
type ReactProvisionDeps = Array<ReactProvisionDep | LazyReactProvisionDep>;
|
|
7
|
+
export declare const provideReact: <T extends AsyncFn>(loader: T, dependencies?: ReactProvisionDeps) => AsyncResourceVariant<T>;
|
|
5
8
|
export type AsyncResourceVariant<T extends AsyncFn> = T & {
|
|
6
9
|
asResource: (...params: Parameters<T>) => AsyncResource<AsyncReturnType<T>>;
|
|
7
10
|
use: (...params: Parameters<T>) => AsyncReturnType<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/api-models",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.95.1",
|
|
4
4
|
"author": "Mittwald CM Service GmbH & Co. KG <opensource@mittwald.de>",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Collection of domain models for coherent interaction with the API",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test:unit": "node --experimental-vm-modules $(yarn bin jest)"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@mittwald/api-client": "^4.
|
|
42
|
+
"@mittwald/api-client": "^4.95.0",
|
|
43
43
|
"another-deep-freeze": "^1.0.0",
|
|
44
44
|
"context": "^3.0.33",
|
|
45
45
|
"dinero.js": "^1.9.1",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"optional": true
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "367f689a5e9328582159ac2be66b482d2c618169"
|
|
88
88
|
}
|