@frontmcp/react 1.9.1-rc.1 → 1.9.1-rc.2
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/api/index.js +12 -8
- package/api/useApiClient.d.ts.map +1 -1
- package/esm/api/index.mjs +7 -3
- package/esm/index.mjs +38 -25
- package/esm/package.json +6 -6
- package/esm/state/index.mjs +20 -14
- package/hooks/useDynamicResource.d.ts.map +1 -1
- package/hooks/useDynamicTool.d.ts.map +1 -1
- package/hooks/useStoreResource.d.ts.map +1 -1
- package/index.js +151 -138
- package/package.json +6 -6
- package/provider/FrontMcpProvider.d.ts.map +1 -1
- package/state/index.js +30 -24
- package/state/useStoreResource.d.ts.map +1 -1
- package/utils/useIsomorphicLayoutEffect.d.ts +4 -0
- package/utils/useIsomorphicLayoutEffect.d.ts.map +1 -0
package/api/index.js
CHANGED
|
@@ -27,7 +27,7 @@ __export(api_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(api_exports);
|
|
28
28
|
|
|
29
29
|
// libs/react/src/api/useApiClient.ts
|
|
30
|
-
var
|
|
30
|
+
var import_react3 = require("react");
|
|
31
31
|
|
|
32
32
|
// libs/react/src/provider/FrontMcpContext.ts
|
|
33
33
|
var import_react = require("react");
|
|
@@ -240,6 +240,10 @@ function getOrCreateContext() {
|
|
|
240
240
|
}
|
|
241
241
|
var FrontMcpContext = getOrCreateContext();
|
|
242
242
|
|
|
243
|
+
// libs/react/src/utils/useIsomorphicLayoutEffect.ts
|
|
244
|
+
var import_react2 = require("react");
|
|
245
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? import_react2.useLayoutEffect : import_react2.useEffect;
|
|
246
|
+
|
|
243
247
|
// libs/react/src/api/createFetchClient.ts
|
|
244
248
|
function createFetchClient(fetchFn) {
|
|
245
249
|
const fn = fetchFn ?? globalThis.fetch.bind(globalThis);
|
|
@@ -338,20 +342,20 @@ function registrationKey(operations) {
|
|
|
338
342
|
}
|
|
339
343
|
function useApiClient(options) {
|
|
340
344
|
const { baseUrl, operations, headers, prefix = "api", client, fetch: customFetch } = options;
|
|
341
|
-
const { getDynamicRegistry } = (0,
|
|
345
|
+
const { getDynamicRegistry } = (0, import_react3.useContext)(FrontMcpContext);
|
|
342
346
|
const dynamicRegistry = getDynamicRegistry(options.server);
|
|
343
|
-
const baseUrlRef = (0,
|
|
344
|
-
const headersRef = (0,
|
|
345
|
-
const operationsRef = (0,
|
|
346
|
-
const clientRef = (0,
|
|
347
|
-
(
|
|
347
|
+
const baseUrlRef = (0, import_react3.useRef)(baseUrl);
|
|
348
|
+
const headersRef = (0, import_react3.useRef)(headers);
|
|
349
|
+
const operationsRef = (0, import_react3.useRef)(operations);
|
|
350
|
+
const clientRef = (0, import_react3.useRef)(client ?? createFetchClient(customFetch));
|
|
351
|
+
useIsomorphicLayoutEffect(() => {
|
|
348
352
|
baseUrlRef.current = baseUrl;
|
|
349
353
|
headersRef.current = headers;
|
|
350
354
|
operationsRef.current = operations;
|
|
351
355
|
clientRef.current = client ?? createFetchClient(customFetch);
|
|
352
356
|
}, [baseUrl, headers, operations, client, customFetch]);
|
|
353
357
|
const key = registrationKey(operations);
|
|
354
|
-
(0,
|
|
358
|
+
(0, import_react3.useEffect)(() => {
|
|
355
359
|
const cleanups = operationsRef.current.map((registered) => {
|
|
356
360
|
const execute = async (args) => {
|
|
357
361
|
const op = operationsRef.current.find((o) => o.operationId === registered.operationId) ?? registered;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApiClient.d.ts","sourceRoot":"","sources":["../../src/api/useApiClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"useApiClient.d.ts","sourceRoot":"","sources":["../../src/api/useApiClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,OAAO,KAAK,EACV,gBAAgB,EAMjB,MAAM,aAAa,CAAC;AAyFrB,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CA0E5D"}
|
package/esm/api/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// libs/react/src/api/useApiClient.ts
|
|
2
|
-
import { useContext, useEffect, useRef } from "react";
|
|
2
|
+
import { useContext, useEffect as useEffect2, useRef } from "react";
|
|
3
3
|
|
|
4
4
|
// libs/react/src/provider/FrontMcpContext.ts
|
|
5
5
|
import { createContext } from "react";
|
|
@@ -212,6 +212,10 @@ function getOrCreateContext() {
|
|
|
212
212
|
}
|
|
213
213
|
var FrontMcpContext = getOrCreateContext();
|
|
214
214
|
|
|
215
|
+
// libs/react/src/utils/useIsomorphicLayoutEffect.ts
|
|
216
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
217
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
218
|
+
|
|
215
219
|
// libs/react/src/api/createFetchClient.ts
|
|
216
220
|
function createFetchClient(fetchFn) {
|
|
217
221
|
const fn = fetchFn ?? globalThis.fetch.bind(globalThis);
|
|
@@ -316,14 +320,14 @@ function useApiClient(options) {
|
|
|
316
320
|
const headersRef = useRef(headers);
|
|
317
321
|
const operationsRef = useRef(operations);
|
|
318
322
|
const clientRef = useRef(client ?? createFetchClient(customFetch));
|
|
319
|
-
|
|
323
|
+
useIsomorphicLayoutEffect(() => {
|
|
320
324
|
baseUrlRef.current = baseUrl;
|
|
321
325
|
headersRef.current = headers;
|
|
322
326
|
operationsRef.current = operations;
|
|
323
327
|
clientRef.current = client ?? createFetchClient(customFetch);
|
|
324
328
|
}, [baseUrl, headers, operations, client, customFetch]);
|
|
325
329
|
const key = registrationKey(operations);
|
|
326
|
-
|
|
330
|
+
useEffect2(() => {
|
|
327
331
|
const cleanups = operationsRef.current.map((registered) => {
|
|
328
332
|
const execute = async (args) => {
|
|
329
333
|
const op = operationsRef.current.find((o) => o.operationId === registered.operationId) ?? registered;
|
package/esm/index.mjs
CHANGED
|
@@ -504,7 +504,7 @@ function getOrCreateContext() {
|
|
|
504
504
|
var FrontMcpContext = getOrCreateContext();
|
|
505
505
|
|
|
506
506
|
// libs/react/src/provider/FrontMcpProvider.tsx
|
|
507
|
-
import React, { useCallback, useEffect as
|
|
507
|
+
import React, { useCallback, useEffect as useEffect3, useMemo, useRef } from "react";
|
|
508
508
|
|
|
509
509
|
// libs/react/src/registry/bindDynamicTools.ts
|
|
510
510
|
function fingerprintOf(def) {
|
|
@@ -712,6 +712,10 @@ function useStoreRegistration(stores, dynamicRegistry) {
|
|
|
712
712
|
}, [stores, dynamicRegistry]);
|
|
713
713
|
}
|
|
714
714
|
|
|
715
|
+
// libs/react/src/utils/useIsomorphicLayoutEffect.ts
|
|
716
|
+
import { useEffect as useEffect2, useLayoutEffect } from "react";
|
|
717
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect2;
|
|
718
|
+
|
|
715
719
|
// libs/react/src/provider/FrontMcpProvider.tsx
|
|
716
720
|
function FrontMcpProvider({
|
|
717
721
|
name: nameProp,
|
|
@@ -729,7 +733,9 @@ function FrontMcpProvider({
|
|
|
729
733
|
const mountedRef = useRef(true);
|
|
730
734
|
const clientRef = useRef(null);
|
|
731
735
|
const onErrorRef = useRef(onError);
|
|
732
|
-
|
|
736
|
+
useIsomorphicLayoutEffect(() => {
|
|
737
|
+
onErrorRef.current = onError;
|
|
738
|
+
}, [onError]);
|
|
733
739
|
const registry = useMemo(() => {
|
|
734
740
|
const reg = new ComponentRegistry();
|
|
735
741
|
if (components) {
|
|
@@ -764,11 +770,11 @@ function FrontMcpProvider({
|
|
|
764
770
|
[dynamicToolAppsKey]
|
|
765
771
|
);
|
|
766
772
|
const primaryToolApp = toolApps[resolvedName];
|
|
767
|
-
|
|
773
|
+
useEffect3(
|
|
768
774
|
() => bindDynamicTools(dynamicRegistry, server, { onError: reportToolError, app: primaryToolApp }),
|
|
769
775
|
[dynamicRegistry, server, reportToolError, primaryToolApp]
|
|
770
776
|
);
|
|
771
|
-
|
|
777
|
+
useEffect3(() => {
|
|
772
778
|
const unbinds = [];
|
|
773
779
|
serverRegistry.register(resolvedName, wrappedServer);
|
|
774
780
|
if (servers) {
|
|
@@ -796,7 +802,7 @@ function FrontMcpProvider({
|
|
|
796
802
|
}
|
|
797
803
|
};
|
|
798
804
|
}, [resolvedName, wrappedServer, servers, getDynamicRegistry, reportToolError, toolApps]);
|
|
799
|
-
|
|
805
|
+
useEffect3(() => {
|
|
800
806
|
const refreshServerEntry = (name) => {
|
|
801
807
|
const entry = serverRegistry.get(name);
|
|
802
808
|
if (!entry || !entry.client) return;
|
|
@@ -885,7 +891,7 @@ function FrontMcpProvider({
|
|
|
885
891
|
}
|
|
886
892
|
}
|
|
887
893
|
}, [resolvedName, wrappedServer, servers, onConnected, onError, dynamicRegistry]);
|
|
888
|
-
|
|
894
|
+
useEffect3(() => {
|
|
889
895
|
mountedRef.current = true;
|
|
890
896
|
if (autoConnect) {
|
|
891
897
|
connectClient();
|
|
@@ -950,7 +956,7 @@ function useFrontMcp(name) {
|
|
|
950
956
|
}
|
|
951
957
|
|
|
952
958
|
// libs/react/src/hooks/useCallTool.ts
|
|
953
|
-
import { useState, useCallback as useCallback3, useEffect as
|
|
959
|
+
import { useState, useCallback as useCallback3, useEffect as useEffect4 } from "react";
|
|
954
960
|
function useCallTool(toolName, options = {}) {
|
|
955
961
|
const { onSuccess, onError, resetOnToolChange = true, server: serverName } = options;
|
|
956
962
|
const { entry } = useResolvedServer(serverName);
|
|
@@ -962,7 +968,7 @@ function useCallTool(toolName, options = {}) {
|
|
|
962
968
|
error: null,
|
|
963
969
|
called: false
|
|
964
970
|
});
|
|
965
|
-
|
|
971
|
+
useEffect4(() => {
|
|
966
972
|
if (resetOnToolChange) {
|
|
967
973
|
setState({ data: null, loading: false, error: null, called: false });
|
|
968
974
|
}
|
|
@@ -998,7 +1004,7 @@ function useCallTool(toolName, options = {}) {
|
|
|
998
1004
|
}
|
|
999
1005
|
|
|
1000
1006
|
// libs/react/src/hooks/useReadResource.ts
|
|
1001
|
-
import { useState as useState2, useCallback as useCallback4, useEffect as
|
|
1007
|
+
import { useState as useState2, useCallback as useCallback4, useEffect as useEffect5 } from "react";
|
|
1002
1008
|
function useReadResource(uriOrOptions, maybeOptions) {
|
|
1003
1009
|
const uri = typeof uriOrOptions === "string" ? uriOrOptions : void 0;
|
|
1004
1010
|
const options = typeof uriOrOptions === "object" ? uriOrOptions : maybeOptions;
|
|
@@ -1031,7 +1037,7 @@ function useReadResource(uriOrOptions, maybeOptions) {
|
|
|
1031
1037
|
},
|
|
1032
1038
|
[client, status]
|
|
1033
1039
|
);
|
|
1034
|
-
|
|
1040
|
+
useEffect5(() => {
|
|
1035
1041
|
if (uri && status === "connected" && client) {
|
|
1036
1042
|
read(uri);
|
|
1037
1043
|
}
|
|
@@ -1107,7 +1113,7 @@ function useListPrompts(options) {
|
|
|
1107
1113
|
}
|
|
1108
1114
|
|
|
1109
1115
|
// libs/react/src/hooks/useStoreResource.ts
|
|
1110
|
-
import {
|
|
1116
|
+
import { useCallback as useCallback6, useEffect as useEffect6, useRef as useRef2, useState as useState4 } from "react";
|
|
1111
1117
|
function parseResourceContent(result) {
|
|
1112
1118
|
const r = result;
|
|
1113
1119
|
if (r?.contents?.[0]?.text) {
|
|
@@ -1125,7 +1131,6 @@ function useStoreResource(uri, options) {
|
|
|
1125
1131
|
const status = entry?.status ?? "idle";
|
|
1126
1132
|
const [state, setState] = useState4({ data: null, loading: true, error: null });
|
|
1127
1133
|
const uriRef = useRef2(uri);
|
|
1128
|
-
uriRef.current = uri;
|
|
1129
1134
|
const fetchResource = useCallback6(async () => {
|
|
1130
1135
|
if (status !== "connected" || !client) return;
|
|
1131
1136
|
try {
|
|
@@ -1136,8 +1141,11 @@ function useStoreResource(uri, options) {
|
|
|
1136
1141
|
}
|
|
1137
1142
|
}, [uri, client, status]);
|
|
1138
1143
|
const fetchRef = useRef2(fetchResource);
|
|
1139
|
-
|
|
1140
|
-
|
|
1144
|
+
useIsomorphicLayoutEffect(() => {
|
|
1145
|
+
uriRef.current = uri;
|
|
1146
|
+
fetchRef.current = fetchResource;
|
|
1147
|
+
}, [uri, fetchResource]);
|
|
1148
|
+
useEffect6(() => {
|
|
1141
1149
|
if (status !== "connected" || !client) return;
|
|
1142
1150
|
let cancelled = false;
|
|
1143
1151
|
setState((prev) => ({ ...prev, loading: true }));
|
|
@@ -1173,7 +1181,7 @@ function useStoreResource(uri, options) {
|
|
|
1173
1181
|
}
|
|
1174
1182
|
|
|
1175
1183
|
// libs/react/src/hooks/useDynamicTool.ts
|
|
1176
|
-
import { useContext as useContext3, useEffect as
|
|
1184
|
+
import { useContext as useContext3, useEffect as useEffect7, useMemo as useMemo2, useRef as useRef3 } from "react";
|
|
1177
1185
|
|
|
1178
1186
|
// libs/react/src/utils/zodToJsonSchema.ts
|
|
1179
1187
|
import { forceMaterialize, toJSONSchema } from "@frontmcp/lazy-zod";
|
|
@@ -1190,21 +1198,24 @@ function stableKey(value) {
|
|
|
1190
1198
|
}
|
|
1191
1199
|
}
|
|
1192
1200
|
function useDynamicTool(options) {
|
|
1193
|
-
const { name, description, app, enabled = true } = options;
|
|
1201
|
+
const { name, description, app, execute, enabled = true } = options;
|
|
1202
|
+
const schema = "schema" in options && options.schema ? options.schema : null;
|
|
1194
1203
|
const { getDynamicRegistry } = useContext3(FrontMcpContext);
|
|
1195
1204
|
const dynamicRegistry = getDynamicRegistry(options.server);
|
|
1196
|
-
const computedInputSchema =
|
|
1205
|
+
const computedInputSchema = schema ? zodToJsonSchema(schema) : options.inputSchema;
|
|
1197
1206
|
const inputSchemaKey = stableKey(computedInputSchema);
|
|
1198
1207
|
const resolvedInputSchema = useMemo2(() => computedInputSchema, [inputSchemaKey]);
|
|
1199
1208
|
const annotationsKey = stableKey(options.annotations ?? null);
|
|
1200
1209
|
const annotations = useMemo2(() => options.annotations, [annotationsKey]);
|
|
1201
1210
|
const availableWhenKey = stableKey(options.availableWhen ?? null);
|
|
1202
1211
|
const availableWhen = useMemo2(() => options.availableWhen, [availableWhenKey]);
|
|
1203
|
-
const executeRef = useRef3(
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1212
|
+
const executeRef = useRef3(execute);
|
|
1213
|
+
const schemaRef = useRef3(schema);
|
|
1214
|
+
useIsomorphicLayoutEffect(() => {
|
|
1215
|
+
executeRef.current = execute;
|
|
1216
|
+
schemaRef.current = schema;
|
|
1217
|
+
}, [execute, schema]);
|
|
1218
|
+
useEffect7(() => {
|
|
1208
1219
|
if (!enabled) return;
|
|
1209
1220
|
const stableExecute = async (args) => {
|
|
1210
1221
|
const zodSchema = schemaRef.current;
|
|
@@ -1245,14 +1256,16 @@ function useDynamicTool(options) {
|
|
|
1245
1256
|
}
|
|
1246
1257
|
|
|
1247
1258
|
// libs/react/src/hooks/useDynamicResource.ts
|
|
1248
|
-
import { useContext as useContext4, useEffect as
|
|
1259
|
+
import { useContext as useContext4, useEffect as useEffect8, useRef as useRef4 } from "react";
|
|
1249
1260
|
function useDynamicResource(options) {
|
|
1250
1261
|
const { uri, name, description, mimeType, read, enabled = true } = options;
|
|
1251
1262
|
const { getDynamicRegistry } = useContext4(FrontMcpContext);
|
|
1252
1263
|
const dynamicRegistry = getDynamicRegistry(options.server);
|
|
1253
1264
|
const readRef = useRef4(read);
|
|
1254
|
-
|
|
1255
|
-
|
|
1265
|
+
useIsomorphicLayoutEffect(() => {
|
|
1266
|
+
readRef.current = read;
|
|
1267
|
+
}, [read]);
|
|
1268
|
+
useEffect8(() => {
|
|
1256
1269
|
if (!enabled) return;
|
|
1257
1270
|
const stableRead = () => readRef.current();
|
|
1258
1271
|
const unregister = dynamicRegistry.registerResource({
|
package/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/react",
|
|
3
|
-
"version": "1.9.1-rc.
|
|
3
|
+
"version": "1.9.1-rc.2",
|
|
4
4
|
"description": "React hooks, components, and AI SDK integration for FrontMCP",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"homepage": "https://docs.agentfront.dev",
|
|
@@ -86,9 +86,9 @@
|
|
|
86
86
|
"node": ">=24.0.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"@frontmcp/lazy-zod": "1.9.1-rc.
|
|
90
|
-
"@frontmcp/sdk": "1.9.1-rc.
|
|
91
|
-
"@frontmcp/utils": "1.9.1-rc.
|
|
89
|
+
"@frontmcp/lazy-zod": "1.9.1-rc.2",
|
|
90
|
+
"@frontmcp/sdk": "1.9.1-rc.2",
|
|
91
|
+
"@frontmcp/utils": "1.9.1-rc.2",
|
|
92
92
|
"react": "^18.0.0 || ^19.0.0",
|
|
93
93
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
94
94
|
"react-router-dom": "^7.0.0"
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@frontmcp/sdk": "1.9.1-rc.
|
|
106
|
-
"@frontmcp/utils": "1.9.1-rc.
|
|
105
|
+
"@frontmcp/sdk": "1.9.1-rc.2",
|
|
106
|
+
"@frontmcp/utils": "1.9.1-rc.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"typescript": "^5.9.3"
|
package/esm/state/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// libs/react/src/state/useStoreResource.ts
|
|
2
|
-
import { useContext, useEffect, useRef } from "react";
|
|
2
|
+
import { useContext, useEffect as useEffect2, useRef } from "react";
|
|
3
3
|
|
|
4
4
|
// libs/react/src/provider/FrontMcpContext.ts
|
|
5
5
|
import { createContext } from "react";
|
|
@@ -212,6 +212,10 @@ function getOrCreateContext() {
|
|
|
212
212
|
}
|
|
213
213
|
var FrontMcpContext = getOrCreateContext();
|
|
214
214
|
|
|
215
|
+
// libs/react/src/utils/useIsomorphicLayoutEffect.ts
|
|
216
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
217
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
218
|
+
|
|
215
219
|
// libs/react/src/state/useStoreResource.ts
|
|
216
220
|
var VALID_NAME_RE = /^[a-zA-Z0-9_-]+$/;
|
|
217
221
|
function keysOf(map, kind) {
|
|
@@ -233,22 +237,24 @@ function jsonResource(uri, value) {
|
|
|
233
237
|
return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify(value ?? null) }] };
|
|
234
238
|
}
|
|
235
239
|
function useStoreResource(options) {
|
|
236
|
-
const { name, subscribe } = options;
|
|
240
|
+
const { name, subscribe, getState, selectors, actions } = options;
|
|
237
241
|
const { getDynamicRegistry } = useContext(FrontMcpContext);
|
|
238
242
|
const dynamicRegistry = getDynamicRegistry(options.server);
|
|
239
243
|
if (!name || !VALID_NAME_RE.test(name)) {
|
|
240
244
|
throw new Error(`useStoreResource: invalid store name "${name}". Names must match ${VALID_NAME_RE}.`);
|
|
241
245
|
}
|
|
242
|
-
const selectorKeys = keysOf(
|
|
243
|
-
const actionKeys = keysOf(
|
|
244
|
-
const getStateRef = useRef(
|
|
245
|
-
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
const selectorKeys = keysOf(selectors, "selector");
|
|
247
|
+
const actionKeys = keysOf(actions, "action");
|
|
248
|
+
const getStateRef = useRef(getState);
|
|
249
|
+
const selectorsRef = useRef(selectors);
|
|
250
|
+
const actionsRef = useRef(actions);
|
|
251
|
+
useIsomorphicLayoutEffect(() => {
|
|
252
|
+
getStateRef.current = getState;
|
|
253
|
+
selectorsRef.current = selectors;
|
|
254
|
+
actionsRef.current = actions;
|
|
255
|
+
}, [getState, selectors, actions]);
|
|
250
256
|
const stateUri = `state://${name}`;
|
|
251
|
-
|
|
257
|
+
useEffect2(
|
|
252
258
|
() => dynamicRegistry.registerResource({
|
|
253
259
|
uri: stateUri,
|
|
254
260
|
name: `${name}-state`,
|
|
@@ -258,7 +264,7 @@ function useStoreResource(options) {
|
|
|
258
264
|
}),
|
|
259
265
|
[dynamicRegistry, name, stateUri]
|
|
260
266
|
);
|
|
261
|
-
|
|
267
|
+
useEffect2(() => {
|
|
262
268
|
const cleanups = parseKeys(selectorKeys).map((key) => {
|
|
263
269
|
const uri = `${stateUri}/${key}`;
|
|
264
270
|
return dynamicRegistry.registerResource({
|
|
@@ -278,7 +284,7 @@ function useStoreResource(options) {
|
|
|
278
284
|
});
|
|
279
285
|
};
|
|
280
286
|
}, [dynamicRegistry, name, stateUri, selectorKeys]);
|
|
281
|
-
|
|
287
|
+
useEffect2(() => {
|
|
282
288
|
const uris = [stateUri, ...parseKeys(selectorKeys).map((key) => `${stateUri}/${key}`)];
|
|
283
289
|
return subscribe(() => {
|
|
284
290
|
for (const uri of uris) {
|
|
@@ -287,7 +293,7 @@ function useStoreResource(options) {
|
|
|
287
293
|
}
|
|
288
294
|
});
|
|
289
295
|
}, [dynamicRegistry, stateUri, selectorKeys, subscribe]);
|
|
290
|
-
|
|
296
|
+
useEffect2(() => {
|
|
291
297
|
const cleanups = parseKeys(actionKeys).map((key) => {
|
|
292
298
|
const execute = async (args) => {
|
|
293
299
|
const action = actionsRef.current?.[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDynamicResource.d.ts","sourceRoot":"","sources":["../../src/hooks/useDynamicResource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"useDynamicResource.d.ts","sourceRoot":"","sources":["../../src/hooks/useDynamicResource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKxD,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,0EAA0E;IAC1E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI,CA2B3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDynamicTool.d.ts","sourceRoot":"","sources":["../../src/hooks/useDynamicTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useDynamicTool.d.ts","sourceRoot":"","sources":["../../src/hooks/useDynamicTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C,2EAA2E;AAC3E,UAAU,2BAA2B;IACnC,2DAA2D;IAC3D,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C,4FAA4F;IAC5F,aAAa,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IAChD;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,MAAM,WAAW,2BAA2B,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAE,SAAQ,2BAA2B;IACpH,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,MAAM,EAAE,CAAC,CAAC;IACV,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,wEAAwE;IACxE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACvD,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,MAAM,WAAW,+BAAgC,SAAQ,2BAA2B;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACpE,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,IAC/F,2BAA2B,CAAC,CAAC,CAAC,GAC9B,+BAA+B,CAAC;AAUpC,wBAAgB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,IAAI,CAwE5G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStoreResource.d.ts","sourceRoot":"","sources":["../../src/hooks/useStoreResource.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"useStoreResource.d.ts","sourceRoot":"","sources":["../../src/hooks/useStoreResource.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,UAAU,kBAAkB;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,UAAU,oBAAoB;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAcD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,sBAAsB,CAiEpG"}
|