@faasjs/react 0.0.2-beta.341 → 0.0.2-beta.342
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/dist/index.d.ts +8 -6
- package/dist/index.js +14 -3
- package/dist/index.mjs +12 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -20,14 +20,16 @@ declare type FaasDataProps<PathOrData extends FaasAction> = {
|
|
|
20
20
|
params?: FaasParams<PathOrData>;
|
|
21
21
|
onDataChange?(args: FaasDataInjection<FaasData<PathOrData>>): void;
|
|
22
22
|
};
|
|
23
|
-
declare
|
|
24
|
-
domain: string;
|
|
25
|
-
options?: Options;
|
|
26
|
-
onError?: (action: string, params: Record<string, any>) => (res: ResponseError) => Promise<void>;
|
|
27
|
-
}): {
|
|
23
|
+
declare type FaasReactClientInstance = {
|
|
28
24
|
faas: <PathOrData extends FaasAction>(action: string | PathOrData, params: FaasParams<PathOrData>) => Promise<Response<FaasData<PathOrData>>>;
|
|
29
25
|
useFaas: <PathOrData extends FaasAction>(action: string | PathOrData, defaultParams: FaasParams<PathOrData>) => FaasDataInjection<FaasData<PathOrData>>;
|
|
30
26
|
FaasData<PathOrData extends FaasAction>(props: FaasDataProps<PathOrData>): JSX.Element;
|
|
31
27
|
};
|
|
28
|
+
declare function FaasReactClient({ domain, options, onError }: {
|
|
29
|
+
domain: string;
|
|
30
|
+
options?: Options;
|
|
31
|
+
onError?: (action: string, params: Record<string, any>) => (res: ResponseError) => Promise<void>;
|
|
32
|
+
}): FaasReactClientInstance;
|
|
33
|
+
declare function getClient(domain?: string): FaasReactClientInstance;
|
|
32
34
|
|
|
33
|
-
export { FaasReactClient };
|
|
35
|
+
export { FaasReactClient, getClient };
|
package/dist/index.js
CHANGED
|
@@ -24,10 +24,12 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
|
24
24
|
// src/index.ts
|
|
25
25
|
var src_exports = {};
|
|
26
26
|
__export(src_exports, {
|
|
27
|
-
FaasReactClient: () => FaasReactClient
|
|
27
|
+
FaasReactClient: () => FaasReactClient,
|
|
28
|
+
getClient: () => getClient
|
|
28
29
|
});
|
|
29
30
|
var import_browser = require("@faasjs/browser");
|
|
30
31
|
var import_react = require("react");
|
|
32
|
+
var clients = {};
|
|
31
33
|
function FaasReactClient({
|
|
32
34
|
domain,
|
|
33
35
|
options,
|
|
@@ -92,7 +94,7 @@ function FaasReactClient({
|
|
|
92
94
|
setError
|
|
93
95
|
};
|
|
94
96
|
}
|
|
95
|
-
|
|
97
|
+
const reactClient = {
|
|
96
98
|
faas,
|
|
97
99
|
useFaas,
|
|
98
100
|
FaasData({
|
|
@@ -117,9 +119,18 @@ function FaasReactClient({
|
|
|
117
119
|
return fallback || null;
|
|
118
120
|
}
|
|
119
121
|
};
|
|
122
|
+
clients[domain] = reactClient;
|
|
123
|
+
return reactClient;
|
|
124
|
+
}
|
|
125
|
+
function getClient(domain) {
|
|
126
|
+
const client = clients[domain || Object.keys(clients)[0]];
|
|
127
|
+
if (!client)
|
|
128
|
+
throw Error("FaasReactClient is not initialized");
|
|
129
|
+
return client;
|
|
120
130
|
}
|
|
121
131
|
module.exports = __toCommonJS(src_exports);
|
|
122
132
|
// Annotate the CommonJS export names for ESM import in node:
|
|
123
133
|
0 && (module.exports = {
|
|
124
|
-
FaasReactClient
|
|
134
|
+
FaasReactClient,
|
|
135
|
+
getClient
|
|
125
136
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
FaasBrowserClient
|
|
4
4
|
} from "@faasjs/browser";
|
|
5
5
|
import { useState, useEffect } from "react";
|
|
6
|
+
var clients = {};
|
|
6
7
|
function FaasReactClient({
|
|
7
8
|
domain,
|
|
8
9
|
options,
|
|
@@ -67,7 +68,7 @@ function FaasReactClient({
|
|
|
67
68
|
setError
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
const reactClient = {
|
|
71
72
|
faas,
|
|
72
73
|
useFaas,
|
|
73
74
|
FaasData({
|
|
@@ -92,7 +93,16 @@ function FaasReactClient({
|
|
|
92
93
|
return fallback || null;
|
|
93
94
|
}
|
|
94
95
|
};
|
|
96
|
+
clients[domain] = reactClient;
|
|
97
|
+
return reactClient;
|
|
98
|
+
}
|
|
99
|
+
function getClient(domain) {
|
|
100
|
+
const client = clients[domain || Object.keys(clients)[0]];
|
|
101
|
+
if (!client)
|
|
102
|
+
throw Error("FaasReactClient is not initialized");
|
|
103
|
+
return client;
|
|
95
104
|
}
|
|
96
105
|
export {
|
|
97
|
-
FaasReactClient
|
|
106
|
+
FaasReactClient,
|
|
107
|
+
getClient
|
|
98
108
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.342",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@faasjs/browser": "^0.0.2-beta.
|
|
26
|
-
"@faasjs/types": "^0.0.2-beta.
|
|
25
|
+
"@faasjs/browser": "^0.0.2-beta.342",
|
|
26
|
+
"@faasjs/types": "^0.0.2-beta.342",
|
|
27
27
|
"react": "*"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|