@dxos/plugin-automation 0.8.4-main.67995b8 → 0.8.4-main.a4bbb77
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/lib/browser/AutomationPanel-4QA5G3ZY.mjs +11 -0
- package/dist/lib/browser/AutomationSettings-6XLG2PCK.mjs +69 -0
- package/dist/lib/browser/AutomationSettings-6XLG2PCK.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsContainer-IOB333TX.mjs → FunctionsContainer-BQ6VBDIG.mjs} +9 -12
- package/dist/lib/browser/FunctionsContainer-BQ6VBDIG.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-56ZKRVM5.mjs → FunctionsPanel-QBTOFFNU.mjs} +3 -3
- package/dist/lib/browser/{app-graph-builder-ZTAUTFI4.mjs → app-graph-builder-6TP6ZNYG.mjs} +8 -8
- package/dist/lib/browser/app-graph-builder-6TP6ZNYG.mjs.map +7 -0
- package/dist/lib/browser/chunk-BDJPBZGC.mjs +14 -0
- package/dist/lib/browser/chunk-BDJPBZGC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LYJVTIVD.mjs → chunk-EAQL33PI.mjs} +5 -5
- package/dist/lib/browser/chunk-EAQL33PI.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HN7OHFCB.mjs → chunk-F4K5EMWL.mjs} +2 -2
- package/dist/lib/browser/{chunk-FSJZXTS2.mjs → chunk-IN2YC7NY.mjs} +18 -18
- package/dist/lib/browser/chunk-IN2YC7NY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ERTIGJYE.mjs → chunk-LNMCGQC2.mjs} +14 -18
- package/dist/lib/browser/chunk-LNMCGQC2.mjs.map +7 -0
- package/dist/lib/browser/chunk-M2WQCY2T.mjs +53 -0
- package/dist/lib/browser/chunk-M2WQCY2T.mjs.map +7 -0
- package/dist/lib/browser/chunk-U66KBK53.mjs +14 -0
- package/dist/lib/browser/chunk-U66KBK53.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GW5U2DGT.mjs → chunk-WWURMV25.mjs} +2 -4
- package/dist/lib/browser/chunk-WWURMV25.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZTXBAXUT.mjs +15 -0
- package/dist/lib/browser/chunk-ZTXBAXUT.mjs.map +7 -0
- package/dist/lib/browser/compute-runtime-OFQPXD5I.mjs +158 -0
- package/dist/lib/browser/compute-runtime-OFQPXD5I.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +12 -0
- package/dist/lib/browser/index.mjs +25 -16
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-U3ZAQEFW.mjs → intent-resolver-JXVWRAAH.mjs} +11 -10
- package/dist/lib/browser/intent-resolver-JXVWRAAH.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-4DFSM7OX.mjs → react-surface-NG3MJCDH.mjs} +17 -17
- package/dist/lib/browser/react-surface-NG3MJCDH.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{AutomationPanel-YYUMSK2W.mjs → AutomationPanel-WMVR3IST.mjs} +4 -4
- package/dist/lib/node-esm/AutomationSettings-4IW7RGMN.mjs +70 -0
- package/dist/lib/node-esm/AutomationSettings-4IW7RGMN.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsContainer-DJWB6WFH.mjs → FunctionsContainer-LHUUOLA5.mjs} +9 -12
- package/dist/lib/node-esm/FunctionsContainer-LHUUOLA5.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-KGIOZSPZ.mjs → FunctionsPanel-SHTQIMDV.mjs} +3 -3
- package/dist/lib/node-esm/FunctionsPanel-SHTQIMDV.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-3FP63ZSG.mjs → app-graph-builder-3A2NIPR5.mjs} +8 -8
- package/dist/lib/node-esm/app-graph-builder-3A2NIPR5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2L2X4JMP.mjs +16 -0
- package/dist/lib/node-esm/chunk-2L2X4JMP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NK5N3QKD.mjs → chunk-5MQJPJR2.mjs} +2 -4
- package/dist/lib/node-esm/chunk-5MQJPJR2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-B6O6UBS7.mjs +16 -0
- package/dist/lib/node-esm/chunk-B6O6UBS7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OEZNHUL2.mjs → chunk-CEWZ2CDM.mjs} +2 -2
- package/dist/lib/node-esm/chunk-DSEZPWSO.mjs +54 -0
- package/dist/lib/node-esm/chunk-DSEZPWSO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HIMYPGHF.mjs → chunk-MN5S5J4O.mjs} +14 -18
- package/dist/lib/node-esm/chunk-MN5S5J4O.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AZH66CED.mjs → chunk-N7NES6SZ.mjs} +18 -18
- package/dist/lib/node-esm/chunk-N7NES6SZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZGPUV5VS.mjs → chunk-PBULJE4B.mjs} +5 -5
- package/dist/lib/node-esm/chunk-PBULJE4B.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UTZIMYCX.mjs +16 -0
- package/dist/lib/node-esm/chunk-UTZIMYCX.mjs.map +7 -0
- package/dist/lib/node-esm/compute-runtime-W5UJNSQY.mjs +159 -0
- package/dist/lib/node-esm/compute-runtime-W5UJNSQY.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +13 -0
- package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +25 -16
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-3QWXEBPX.mjs → intent-resolver-ROEBZXSS.mjs} +11 -10
- package/dist/lib/node-esm/intent-resolver-ROEBZXSS.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-3PNW7NDW.mjs → react-surface-A4KTYX6Z.mjs} +17 -17
- package/dist/lib/node-esm/react-surface-A4KTYX6Z.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/AutomationPlugin.d.ts +1 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +18 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts +5 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +6 -5
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +45 -4
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/AutomationSettings.d.ts +5 -0
- package/dist/types/src/components/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +2 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +45 -4
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TriggerSettings.d.ts +6 -0
- package/dist/types/src/components/TriggerSettings.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +3 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +8 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +11 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +60 -41
- package/src/AutomationPlugin.tsx +35 -31
- package/src/capabilities/app-graph-builder.ts +5 -5
- package/src/capabilities/capabilities.ts +47 -0
- package/src/capabilities/compute-runtime.ts +136 -0
- package/src/capabilities/index.ts +3 -0
- package/src/capabilities/intent-resolver.ts +7 -7
- package/src/capabilities/react-surface.tsx +11 -11
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +13 -13
- package/src/components/AutomationPanel/AutomationPanel.tsx +17 -29
- package/src/components/AutomationSettings.tsx +30 -0
- package/src/components/FunctionsContainer.tsx +11 -13
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +4 -4
- package/src/components/TriggerEditor/SpecSelector.tsx +16 -16
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +15 -14
- package/src/components/TriggerEditor/TriggerEditor.tsx +6 -12
- package/src/components/TriggerSettings.tsx +25 -0
- package/src/components/index.ts +1 -1
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useComputeRuntimeCallback.ts +30 -0
- package/src/hooks/useTriggerRuntimeControls.ts +52 -0
- package/src/index.ts +1 -0
- package/src/meta.ts +1 -3
- package/src/translations.ts +4 -0
- package/dist/lib/browser/AutomationContainer-VZNV2ZQF.mjs +0 -38
- package/dist/lib/browser/AutomationContainer-VZNV2ZQF.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-ZWA6GOFY.mjs +0 -11
- package/dist/lib/browser/FunctionsContainer-IOB333TX.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-ZTAUTFI4.mjs.map +0 -7
- package/dist/lib/browser/chunk-ECSTS2UI.mjs +0 -14
- package/dist/lib/browser/chunk-ECSTS2UI.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERTIGJYE.mjs.map +0 -7
- package/dist/lib/browser/chunk-FSJZXTS2.mjs.map +0 -7
- package/dist/lib/browser/chunk-GW5U2DGT.mjs.map +0 -7
- package/dist/lib/browser/chunk-LYJVTIVD.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-U3ZAQEFW.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4DFSM7OX.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationContainer-WMIH3F4V.mjs +0 -39
- package/dist/lib/node-esm/AutomationContainer-WMIH3F4V.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-DJWB6WFH.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-3FP63ZSG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AZH66CED.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HIMYPGHF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SGZPTJ47.mjs +0 -16
- package/dist/lib/node-esm/chunk-SGZPTJ47.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZGPUV5VS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-3QWXEBPX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-3PNW7NDW.mjs.map +0 -7
- package/dist/types/src/components/AutomationContainer.d.ts +0 -5
- package/dist/types/src/components/AutomationContainer.d.ts.map +0 -1
- package/src/components/AutomationContainer.tsx +0 -30
- /package/dist/lib/browser/{AutomationPanel-ZWA6GOFY.mjs.map → AutomationPanel-4QA5G3ZY.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-56ZKRVM5.mjs.map → FunctionsPanel-QBTOFFNU.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-HN7OHFCB.mjs.map → chunk-F4K5EMWL.mjs.map} +0 -0
- /package/dist/lib/{node-esm/AutomationPanel-YYUMSK2W.mjs.map → browser/hooks/index.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-KGIOZSPZ.mjs.map → AutomationPanel-WMVR3IST.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-OEZNHUL2.mjs.map → chunk-CEWZ2CDM.mjs.map} +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// src/meta.ts
|
|
4
|
-
var AUTOMATION_PLUGIN = "dxos.org/plugin/automation";
|
|
5
4
|
var meta = {
|
|
6
|
-
id:
|
|
5
|
+
id: "dxos.org/plugin/automation",
|
|
7
6
|
name: "Automation",
|
|
8
7
|
description: "The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.",
|
|
9
8
|
icon: "ph--robot--regular",
|
|
@@ -11,7 +10,6 @@ var meta = {
|
|
|
11
10
|
};
|
|
12
11
|
|
|
13
12
|
export {
|
|
14
|
-
AUTOMATION_PLUGIN,
|
|
15
13
|
meta
|
|
16
14
|
};
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
15
|
+
//# sourceMappingURL=chunk-5MQJPJR2.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/automation',\n name: 'Automation',\n description:\n 'The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.',\n icon: 'ph--robot--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',\n};\n"],
|
|
5
|
+
"mappings": ";;;AAMO,IAAMA,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aACE;EACFC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
+
"names": ["meta", "id", "name", "description", "icon", "source"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-5MQJPJR2.mjs";
|
|
5
|
+
|
|
6
|
+
// src/capabilities/capabilities.ts
|
|
7
|
+
import { defineCapability } from "@dxos/app-framework";
|
|
8
|
+
(function(AutomationCapabilities2) {
|
|
9
|
+
AutomationCapabilities2.ComputeRuntime = defineCapability(`${meta.id}/capability/compute-runtime`);
|
|
10
|
+
})(AutomationCapabilities || (AutomationCapabilities = {}));
|
|
11
|
+
var AutomationCapabilities;
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
AutomationCapabilities
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-B6O6UBS7.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/capabilities.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ManagedRuntime } from 'effect';\n\nimport { type AiService, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';\nimport { defineCapability } from '@dxos/app-framework';\nimport type {\n CredentialsService,\n DatabaseService,\n FunctionInvocationService,\n InvocationTracer,\n QueueService,\n TriggerDispatcher,\n TriggerStateStore,\n} from '@dxos/functions';\nimport type { SpaceId } from '@dxos/keys';\n\nimport { meta } from '../meta';\n\nexport namespace AutomationCapabilities {\n /**\n * Service stack for executing agents, functions, and triggers.\n */\n export type ComputeServices =\n | TriggerDispatcher\n | AiService.AiService\n | DatabaseService\n | QueueService\n | CredentialsService\n | FunctionInvocationService\n | InvocationTracer\n | TriggerStateStore\n // TODO(dmaretskyi): Those should be provided at AI-chat call site.\n | ToolResolverService\n | ToolExecutionService;\n\n export interface ComputeRuntimeProvider {\n getRuntime(spaceId: SpaceId): ManagedRuntime.ManagedRuntime<ComputeServices, never>;\n }\n\n /**\n * Runtime for executing agents, functions, and triggers.\n */\n export const ComputeRuntime = defineCapability<ComputeRuntimeProvider>(`${meta.id}/capability/compute-runtime`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;AAOA,SAASA,wBAAwB;UAchBC,yBAAAA;0BAwBFC,iBAAiBC,iBAAyC,GAAGC,KAAKC,EAAE,6BAA6B;AAChH,GAzBiBJ,2BAAAA,yBAAAA,CAAAA,EAAAA;;",
|
|
6
|
+
"names": ["defineCapability", "AutomationCapabilities", "ComputeRuntime", "defineCapability", "meta", "id"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
meta
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5MQJPJR2.mjs";
|
|
5
5
|
|
|
6
6
|
// src/types/schema.ts
|
|
7
7
|
import { Schema } from "effect";
|
|
@@ -36,4 +36,4 @@ var AutomationAction;
|
|
|
36
36
|
export {
|
|
37
37
|
AutomationAction
|
|
38
38
|
};
|
|
39
|
-
//# sourceMappingURL=chunk-
|
|
39
|
+
//# sourceMappingURL=chunk-CEWZ2CDM.mjs.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
AutomationCapabilities
|
|
4
|
+
} from "./chunk-B6O6UBS7.mjs";
|
|
5
|
+
|
|
6
|
+
// src/hooks/useComputeRuntimeCallback.ts
|
|
7
|
+
import { useCallback } from "react";
|
|
8
|
+
import { useCapability } from "@dxos/app-framework";
|
|
9
|
+
var useComputeRuntimeCallback = (space, fn, deps) => {
|
|
10
|
+
const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
11
|
+
const runtime = space !== void 0 ? computeRuntime.getRuntime(space.id) : void 0;
|
|
12
|
+
return useCallback(() => {
|
|
13
|
+
if (!runtime) {
|
|
14
|
+
throw new TypeError("Space not provided to useComputeRuntimeCallback");
|
|
15
|
+
}
|
|
16
|
+
return runtime.runPromise(fn());
|
|
17
|
+
}, [
|
|
18
|
+
runtime,
|
|
19
|
+
...deps ?? []
|
|
20
|
+
]);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/hooks/useTriggerRuntimeControls.ts
|
|
24
|
+
import { Effect } from "effect";
|
|
25
|
+
import { Filter } from "@dxos/echo";
|
|
26
|
+
import { FunctionTrigger, TriggerDispatcher } from "@dxos/functions";
|
|
27
|
+
import { useQuery } from "@dxos/react-client/echo";
|
|
28
|
+
import { useAsyncState } from "@dxos/react-ui";
|
|
29
|
+
var useTriggerRuntimeControls = (space) => {
|
|
30
|
+
const triggers = useQuery(space, Filter.type(FunctionTrigger));
|
|
31
|
+
const [isRunningState, setIsRunningState] = useAsyncState(useComputeRuntimeCallback(space, () => TriggerDispatcher.pipe(Effect.map((t) => t.running))));
|
|
32
|
+
const start = useComputeRuntimeCallback(space, Effect.fnUntraced(function* () {
|
|
33
|
+
const dispatcher = yield* TriggerDispatcher;
|
|
34
|
+
yield* dispatcher.start();
|
|
35
|
+
setIsRunningState(true);
|
|
36
|
+
}));
|
|
37
|
+
const stop = useComputeRuntimeCallback(space, Effect.fnUntraced(function* () {
|
|
38
|
+
const dispatcher = yield* TriggerDispatcher;
|
|
39
|
+
yield* dispatcher.stop();
|
|
40
|
+
setIsRunningState(false);
|
|
41
|
+
}));
|
|
42
|
+
return {
|
|
43
|
+
triggers,
|
|
44
|
+
isRunning: isRunningState ?? false,
|
|
45
|
+
start: () => void start(),
|
|
46
|
+
stop: () => void stop()
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
useComputeRuntimeCallback,
|
|
52
|
+
useTriggerRuntimeControls
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=chunk-DSEZPWSO.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useComputeRuntimeCallback.ts", "../../../src/hooks/useTriggerRuntimeControls.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type { Effect } from 'effect';\nimport { useCallback } from 'react';\n\nimport { useCapability } from '@dxos/app-framework';\nimport type { Space } from '@dxos/react-client/echo';\n\nimport { AutomationCapabilities } from '../capabilities';\n\n/**\n * Create an effectful function that has access to compute services\n */\nexport const useComputeRuntimeCallback = <T>(\n space: Space | undefined,\n fn: () => Effect.Effect<T, any, AutomationCapabilities.ComputeServices>,\n deps?: React.DependencyList,\n): (() => Promise<T>) => {\n const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);\n const runtime = space !== undefined ? computeRuntime.getRuntime(space.id) : undefined;\n\n return useCallback(() => {\n if (!runtime) {\n throw new TypeError('Space not provided to useComputeRuntimeCallback');\n }\n return runtime.runPromise(fn());\n }, [runtime, ...(deps ?? [])]);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Effect } from 'effect';\n\nimport { Filter } from '@dxos/echo';\nimport { FunctionTrigger, TriggerDispatcher } from '@dxos/functions';\nimport { type Space, useQuery } from '@dxos/react-client/echo';\nimport { useAsyncState } from '@dxos/react-ui';\n\nimport { useComputeRuntimeCallback } from './useComputeRuntimeCallback';\n\ninterface TriggerRuntimeControls {\n triggers: FunctionTrigger[];\n isRunning: boolean;\n start: () => void;\n stop: () => void;\n}\n\nexport const useTriggerRuntimeControls = (space: Space | undefined): TriggerRuntimeControls => {\n const triggers = useQuery(space, Filter.type(FunctionTrigger));\n\n const [isRunningState, setIsRunningState] = useAsyncState(\n useComputeRuntimeCallback(space, () => TriggerDispatcher.pipe(Effect.map((t) => t.running))),\n );\n\n const start = useComputeRuntimeCallback(\n space,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.start();\n setIsRunningState(true);\n }),\n );\n\n const stop = useComputeRuntimeCallback(\n space,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.stop();\n setIsRunningState(false);\n }),\n );\n\n return {\n triggers,\n isRunning: isRunningState ?? false,\n start: () => void start(),\n stop: () => void stop(),\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAKA,SAASA,mBAAmB;AAE5B,SAASC,qBAAqB;AAQvB,IAAMC,4BAA4B,CACvCC,OACAC,IACAC,SAAAA;AAEA,QAAMC,iBAAiBC,cAAcC,uBAAuBC,cAAc;AAC1E,QAAMC,UAAUP,UAAUQ,SAAYL,eAAeM,WAAWT,MAAMU,EAAE,IAAIF;AAE5E,SAAOG,YAAY,MAAA;AACjB,QAAI,CAACJ,SAAS;AACZ,YAAM,IAAIK,UAAU,iDAAA;IACtB;AACA,WAAOL,QAAQM,WAAWZ,GAAAA,CAAAA;EAC5B,GAAG;IAACM;OAAaL,QAAQ,CAAA;GAAI;AAC/B;;;ACzBA,SAASY,cAAc;AAEvB,SAASC,cAAc;AACvB,SAASC,iBAAiBC,yBAAyB;AACnD,SAAqBC,gBAAgB;AACrC,SAASC,qBAAqB;AAWvB,IAAMC,4BAA4B,CAACC,UAAAA;AACxC,QAAMC,WAAWC,SAASF,OAAOG,OAAOC,KAAKC,eAAAA,CAAAA;AAE7C,QAAM,CAACC,gBAAgBC,iBAAAA,IAAqBC,cAC1CC,0BAA0BT,OAAO,MAAMU,kBAAkBC,KAAKC,OAAOC,IAAI,CAACC,MAAMA,EAAEC,OAAO,CAAA,CAAA,CAAA;AAG3F,QAAMC,QAAQP,0BACZT,OACAY,OAAOK,WAAW,aAAA;AAChB,UAAMC,aAAa,OAAOR;AAC1B,WAAOQ,WAAWF,MAAK;AACvBT,sBAAkB,IAAA;EACpB,CAAA,CAAA;AAGF,QAAMY,OAAOV,0BACXT,OACAY,OAAOK,WAAW,aAAA;AAChB,UAAMC,aAAa,OAAOR;AAC1B,WAAOQ,WAAWC,KAAI;AACtBZ,sBAAkB,KAAA;EACpB,CAAA,CAAA;AAGF,SAAO;IACLN;IACAmB,WAAWd,kBAAkB;IAC7BU,OAAO,MAAM,KAAKA,MAAAA;IAClBG,MAAM,MAAM,KAAKA,KAAAA;EACnB;AACF;",
|
|
6
|
+
"names": ["useCallback", "useCapability", "useComputeRuntimeCallback", "space", "fn", "deps", "computeRuntime", "useCapability", "AutomationCapabilities", "ComputeRuntime", "runtime", "undefined", "getRuntime", "id", "useCallback", "TypeError", "runPromise", "Effect", "Filter", "FunctionTrigger", "TriggerDispatcher", "useQuery", "useAsyncState", "useTriggerRuntimeControls", "space", "triggers", "useQuery", "Filter", "type", "FunctionTrigger", "isRunningState", "setIsRunningState", "useAsyncState", "useComputeRuntimeCallback", "TriggerDispatcher", "pipe", "Effect", "map", "t", "running", "start", "fnUntraced", "dispatcher", "stop", "isRunning"]
|
|
7
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
TriggerEditor
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-N7NES6SZ.mjs";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
meta
|
|
7
|
+
} from "./chunk-5MQJPJR2.mjs";
|
|
8
8
|
|
|
9
9
|
// src/components/AutomationPanel/AutomationPanel.tsx
|
|
10
10
|
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
11
11
|
import { Schema } from "effect";
|
|
12
12
|
import React, { useState } from "react";
|
|
13
13
|
import { Filter, Obj } from "@dxos/echo";
|
|
14
|
-
import {
|
|
14
|
+
import { FunctionTrigger, FunctionType, ScriptType } from "@dxos/functions";
|
|
15
15
|
import { useClient } from "@dxos/react-client";
|
|
16
|
-
import {
|
|
16
|
+
import { getSpace, useQuery } from "@dxos/react-client/echo";
|
|
17
17
|
import { Clipboard, IconButton, Input, Separator, useTranslation } from "@dxos/react-ui";
|
|
18
18
|
import { ControlItem, controlItemClasses } from "@dxos/react-ui-form";
|
|
19
19
|
import { List } from "@dxos/react-ui-list";
|
|
20
20
|
import { ghostHover, mx } from "@dxos/react-ui-theme";
|
|
21
21
|
var grid = "grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]";
|
|
22
|
-
var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
|
|
22
|
+
var AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }) => {
|
|
23
23
|
var _effect = _useSignals();
|
|
24
24
|
try {
|
|
25
|
-
const { t } = useTranslation(
|
|
25
|
+
const { t } = useTranslation(meta.id);
|
|
26
26
|
const client = useClient();
|
|
27
27
|
const triggers = useQuery(space, Filter.type(FunctionTrigger));
|
|
28
28
|
const functions = useQuery(space, Filter.type(FunctionType));
|
|
@@ -30,12 +30,11 @@ var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
|
|
|
30
30
|
const [trigger, setTrigger] = useState(initialTrigger);
|
|
31
31
|
const [selected, setSelected] = useState();
|
|
32
32
|
const handleSelect = (trigger2) => {
|
|
33
|
-
|
|
34
|
-
setTrigger(values);
|
|
33
|
+
setTrigger(trigger2);
|
|
35
34
|
setSelected(trigger2);
|
|
36
35
|
};
|
|
37
36
|
const handleAdd = () => {
|
|
38
|
-
setTrigger(Obj.make(
|
|
37
|
+
setTrigger(Obj.make(FunctionTrigger, {}));
|
|
39
38
|
setSelected(void 0);
|
|
40
39
|
};
|
|
41
40
|
const handleDelete = (trigger2) => {
|
|
@@ -68,7 +67,7 @@ var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
|
|
|
68
67
|
}));
|
|
69
68
|
}
|
|
70
69
|
return /* @__PURE__ */ React.createElement("div", {
|
|
71
|
-
className: controlItemClasses
|
|
70
|
+
className: mx(controlItemClasses, classNames)
|
|
72
71
|
}, triggers.length > 0 && /* @__PURE__ */ React.createElement(List.Root, {
|
|
73
72
|
items: triggers,
|
|
74
73
|
isItem: Schema.is(FunctionTrigger),
|
|
@@ -108,13 +107,13 @@ var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
|
|
|
108
107
|
}
|
|
109
108
|
};
|
|
110
109
|
var getCopyAction = (client, trigger) => {
|
|
111
|
-
if (trigger?.spec?.kind ===
|
|
110
|
+
if (trigger?.spec?.kind === "email") {
|
|
112
111
|
return {
|
|
113
112
|
translationKey: "trigger copy email",
|
|
114
113
|
contentProvider: () => `${getSpace(trigger).id}@dxos.network`
|
|
115
114
|
};
|
|
116
115
|
}
|
|
117
|
-
if (trigger?.spec?.kind ===
|
|
116
|
+
if (trigger?.spec?.kind === "webhook") {
|
|
118
117
|
return {
|
|
119
118
|
translationKey: "trigger copy url",
|
|
120
119
|
contentProvider: () => getWebhookUrl(client, trigger)
|
|
@@ -132,10 +131,7 @@ var getWebhookUrl = (client, trigger) => {
|
|
|
132
131
|
var getFunctionName = (scripts, functions, trigger) => {
|
|
133
132
|
const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}\u2026`;
|
|
134
133
|
const functionObject = functions.find((fn) => fn === trigger.function?.target);
|
|
135
|
-
|
|
136
|
-
return shortId;
|
|
137
|
-
}
|
|
138
|
-
return scripts.find((s) => functionObject.source?.target?.id === s.id)?.name ?? shortId;
|
|
134
|
+
return functionObject?.name ?? shortId;
|
|
139
135
|
};
|
|
140
136
|
|
|
141
137
|
// src/components/AutomationPanel/index.ts
|
|
@@ -145,4 +141,4 @@ export {
|
|
|
145
141
|
AutomationPanel,
|
|
146
142
|
AutomationPanel_default
|
|
147
143
|
};
|
|
148
|
-
//# sourceMappingURL=chunk-
|
|
144
|
+
//# sourceMappingURL=chunk-MN5S5J4O.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/AutomationPanel/AutomationPanel.tsx", "../../../src/components/AutomationPanel/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\nimport React, { useState } from 'react';\n\nimport { Filter, Obj } from '@dxos/echo';\nimport { FunctionTrigger, FunctionType, ScriptType } from '@dxos/functions';\nimport { type Client, useClient } from '@dxos/react-client';\nimport { type Space, getSpace, useQuery } from '@dxos/react-client/echo';\nimport { Clipboard, IconButton, Input, Separator, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { ControlItem, controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../../meta';\nimport { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';\n\nconst grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';\n\nexport type AutomationPanelProps = ThemedClassName<{\n space: Space;\n object?: Obj.Any;\n initialTrigger?: FunctionTrigger;\n onDone?: () => void;\n}>;\n\n// TODO(burdon): Factor out common layout with ViewEditor.\nexport const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {\n const { t } = useTranslation(meta.id);\n const client = useClient();\n const triggers = useQuery(space, Filter.type(FunctionTrigger));\n const functions = useQuery(space, Filter.type(FunctionType));\n const scripts = useQuery(space, Filter.type(ScriptType));\n\n const [trigger, setTrigger] = useState<FunctionTrigger | undefined>(initialTrigger);\n const [selected, setSelected] = useState<FunctionTrigger>();\n\n const handleSelect = (trigger: FunctionTrigger) => {\n setTrigger(trigger);\n setSelected(trigger);\n };\n\n const handleAdd = () => {\n setTrigger(Obj.make(FunctionTrigger, {}));\n setSelected(undefined);\n };\n\n const handleDelete = (trigger: FunctionTrigger) => {\n space.db.remove(trigger);\n setTrigger(undefined);\n setSelected(undefined);\n };\n\n const handleSave: TriggerEditorProps['onSave'] = (trigger) => {\n if (selected) {\n Object.assign(selected, trigger);\n } else {\n space.db.add(Obj.make(FunctionTrigger, trigger));\n }\n\n setTrigger(undefined);\n setSelected(undefined);\n onDone?.();\n };\n\n const handleCancel: TriggerEditorProps['onCancel'] = () => {\n setTrigger(undefined);\n onDone?.();\n };\n\n if (trigger) {\n return (\n <ControlItem title={t('trigger editor title')}>\n <TriggerEditor space={space} trigger={trigger} onSave={handleSave} onCancel={handleCancel} />\n </ControlItem>\n );\n }\n\n return (\n <div className={mx(controlItemClasses, classNames)}>\n {triggers.length > 0 && (\n <List.Root<FunctionTrigger> items={triggers} isItem={Schema.is(FunctionTrigger)} getId={(field) => field.id}>\n {({ items: triggers }) => (\n <div role='list' className='flex flex-col w-full'>\n {triggers?.map((trigger) => {\n const copyAction = getCopyAction(client, trigger);\n return (\n <List.Item<FunctionTrigger>\n key={trigger.id}\n item={trigger}\n classNames={mx(grid, ghostHover, 'items-center', 'px-2')}\n >\n <Input.Root>\n <Input.Switch\n checked={trigger.enabled}\n onCheckedChange={(checked) => (trigger.enabled = checked)}\n />\n </Input.Root>\n\n <div className={'flex'}>\n <List.ItemTitle\n classNames='px-1 cursor-pointer w-0 shrink truncate'\n onClick={() => handleSelect(trigger)}\n >\n {getFunctionName(scripts, functions, trigger) ?? '∅'}\n </List.ItemTitle>\n\n {/* TODO: a better way to expose copy action */}\n {copyAction && (\n <Clipboard.IconButton\n label={t(copyAction.translationKey)}\n value={copyAction.contentProvider()}\n />\n )}\n </div>\n\n <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />\n </List.Item>\n );\n })}\n </div>\n )}\n </List.Root>\n )}\n {triggers.length > 0 && <Separator classNames='mlb-4' />}\n <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />\n </div>\n );\n};\n\nconst getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) => {\n if (trigger?.spec?.kind === 'email') {\n return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };\n }\n\n if (trigger?.spec?.kind === 'webhook') {\n return { translationKey: 'trigger copy url', contentProvider: () => getWebhookUrl(client, trigger) };\n }\n\n return undefined;\n};\n\nconst getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {\n const spaceId = getSpace(trigger)!.id;\n const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);\n const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');\n edgeUrl.protocol = isSecure ? 'https' : 'http';\n return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();\n};\n\nconst getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger: FunctionTrigger) => {\n // TODO(wittjosiah): Truncation should be done in the UI.\n // Warning that the List component is currently a can of worms.\n const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;\n const functionObject = functions.find((fn) => fn === trigger.function?.target);\n return functionObject?.name ?? shortId;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AutomationPanel } from './AutomationPanel';\n\nexport * from './AutomationPanel';\n\nexport default AutomationPanel;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAIA,SAASA,cAAc;AACvB,OAAOC,SAASC,gBAAgB;AAEhC,SAASC,QAAQC,WAAW;AAC5B,SAASC,iBAAiBC,cAAcC,kBAAkB;AAC1D,SAAsBC,iBAAiB;AACvC,SAAqBC,UAAUC,gBAAgB;AAC/C,SAASC,WAAWC,YAAYC,OAAOC,WAAiCC,sBAAsB;AAC9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E,YAAAA;MAAWO,MAAK;MAAoBN,OAAOrE,EAAE,mBAAA;MAAsBiE,SAAS5C;;;;;AAGnF;AAEA,IAAMiC,gBAAgB,CAAClD,QAAgBW,YAAAA;AACrC,MAAIA,SAAS6D,MAAMC,SAAS,SAAS;AACnC,WAAO;MAAEP,gBAAgB;MAAsBE,iBAAiB,MAAM,GAAGM,SAAS/D,OAAAA,EAAUZ,EAAE;IAAgB;EAChH;AAEA,MAAIY,SAAS6D,MAAMC,SAAS,WAAW;AACrC,WAAO;MAAEP,gBAAgB;MAAoBE,iBAAiB,MAAMO,cAAc3E,QAAQW,OAAAA;IAAS;EACrG;AAEA,SAAOS;AACT;AAEA,IAAMuD,gBAAgB,CAAC3E,QAAgBW,YAAAA;AACrC,QAAMiE,UAAUF,SAAS/D,OAAAA,EAAUZ;AACnC,QAAM8E,UAAU,IAAIC,IAAI9E,OAAO+E,OAAOC,OAAOC,QAASC,SAAUC,KAAMC,GAAG;AACzE,QAAMC,WAAWR,QAAQS,SAASC,WAAW,OAAA,KAAYV,QAAQS,SAASC,WAAW,KAAA;AACrFV,UAAQS,WAAWD,WAAW,UAAU;AACxC,SAAO,IAAIP,IAAI,YAAYF,OAAAA,IAAWjE,QAAQZ,EAAE,IAAI8E,OAAAA,EAASW,SAAQ;AACvE;AAEA,IAAM1B,kBAAkB,CAACrD,SAAuBF,WAA2BI,YAAAA;AAGzE,QAAM8E,UAAU9E,QAAQ+E,YAAY,GAAG/E,QAAQ+E,SAASC,IAAIH,SAAQ,EAAGI,MAAM,GAAG,EAAA,CAAA;AAChF,QAAMC,iBAAiBtF,UAAUuF,KAAK,CAACC,OAAOA,OAAOpF,QAAQ+E,UAAUM,MAAAA;AACvE,SAAOH,gBAAgBI,QAAQR;AACjC;;;ACtJA,IAAA,0BAAeS;",
|
|
6
|
+
"names": ["Schema", "React", "useState", "Filter", "Obj", "FunctionTrigger", "FunctionType", "ScriptType", "useClient", "getSpace", "useQuery", "Clipboard", "IconButton", "Input", "Separator", "useTranslation", "ControlItem", "controlItemClasses", "List", "ghostHover", "mx", "grid", "AutomationPanel", "classNames", "space", "object", "initialTrigger", "onDone", "t", "useTranslation", "meta", "id", "client", "useClient", "triggers", "useQuery", "Filter", "type", "FunctionTrigger", "functions", "FunctionType", "scripts", "ScriptType", "trigger", "setTrigger", "useState", "selected", "setSelected", "handleSelect", "handleAdd", "Obj", "make", "undefined", "handleDelete", "db", "remove", "handleSave", "Object", "assign", "add", "handleCancel", "ControlItem", "title", "TriggerEditor", "onSave", "onCancel", "div", "className", "mx", "controlItemClasses", "length", "List", "Root", "items", "isItem", "Schema", "is", "getId", "field", "role", "map", "copyAction", "getCopyAction", "Item", "key", "item", "ghostHover", "Input", "Switch", "checked", "enabled", "onCheckedChange", "ItemTitle", "onClick", "getFunctionName", "Clipboard", "IconButton", "label", "translationKey", "value", "contentProvider", "ItemDeleteButton", "Separator", "icon", "spec", "kind", "getSpace", "getWebhookUrl", "spaceId", "edgeUrl", "URL", "config", "values", "runtime", "services", "edge", "url", "isSecure", "protocol", "startsWith", "toString", "shortId", "function", "dxn", "slice", "functionObject", "find", "fn", "target", "name", "AutomationPanel"]
|
|
7
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-5MQJPJR2.mjs";
|
|
5
5
|
|
|
6
6
|
// src/components/TriggerEditor/TriggerEditor.tsx
|
|
7
7
|
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
8
8
|
import React3, { useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
9
9
|
import { ComputeGraph } from "@dxos/conductor";
|
|
10
10
|
import { Type as Type2 } from "@dxos/echo";
|
|
11
|
-
import {
|
|
11
|
+
import { FunctionTrigger, FunctionType, ScriptType } from "@dxos/functions";
|
|
12
12
|
import { Filter, Ref as Ref2, useQuery } from "@dxos/react-client/echo";
|
|
13
13
|
import { Form as Form2, SelectInput as SelectInput2, useRefQueryLookupHandler } from "@dxos/react-ui-form";
|
|
14
14
|
|
|
@@ -77,41 +77,41 @@ var FunctionInputEditor = ({ functions, getValue, onValueChange, onQueryRefOptio
|
|
|
77
77
|
// src/components/TriggerEditor/SpecSelector.tsx
|
|
78
78
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
79
79
|
import React2, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
80
|
-
import {
|
|
80
|
+
import { TriggerKinds } from "@dxos/functions";
|
|
81
81
|
import { useTranslation } from "@dxos/react-ui";
|
|
82
82
|
import { SelectInput, useInputProps } from "@dxos/react-ui-form";
|
|
83
83
|
var SpecSelector = (props) => {
|
|
84
84
|
var _effect = _useSignals2();
|
|
85
85
|
try {
|
|
86
|
-
const { t } = useTranslation(
|
|
86
|
+
const { t } = useTranslation(meta.id);
|
|
87
87
|
const specProps = useInputProps([
|
|
88
88
|
"spec"
|
|
89
89
|
]);
|
|
90
90
|
const handleTypeChange = useCallback2((_type, value) => {
|
|
91
91
|
const getDefaultTriggerSpec = (kind) => {
|
|
92
92
|
switch (kind) {
|
|
93
|
-
case
|
|
93
|
+
case "timer":
|
|
94
94
|
return {
|
|
95
|
-
kind:
|
|
95
|
+
kind: "timer",
|
|
96
96
|
cron: ""
|
|
97
97
|
};
|
|
98
|
-
case
|
|
98
|
+
case "subscription":
|
|
99
99
|
return {
|
|
100
|
-
kind:
|
|
100
|
+
kind: "subscription",
|
|
101
101
|
filter: {}
|
|
102
102
|
};
|
|
103
|
-
case
|
|
103
|
+
case "queue":
|
|
104
104
|
return {
|
|
105
|
-
kind:
|
|
105
|
+
kind: "queue",
|
|
106
106
|
queue: ""
|
|
107
107
|
};
|
|
108
|
-
case
|
|
108
|
+
case "email":
|
|
109
109
|
return {
|
|
110
|
-
kind:
|
|
110
|
+
kind: "email"
|
|
111
111
|
};
|
|
112
|
-
case
|
|
112
|
+
case "webhook":
|
|
113
113
|
return {
|
|
114
|
-
kind:
|
|
114
|
+
kind: "webhook"
|
|
115
115
|
};
|
|
116
116
|
default:
|
|
117
117
|
return void 0;
|
|
@@ -125,7 +125,7 @@ var SpecSelector = (props) => {
|
|
|
125
125
|
}, [
|
|
126
126
|
specProps
|
|
127
127
|
]);
|
|
128
|
-
const options = useMemo2(() =>
|
|
128
|
+
const options = useMemo2(() => TriggerKinds.map((kind) => ({
|
|
129
129
|
value: kind,
|
|
130
130
|
label: t(`trigger type ${kind}`)
|
|
131
131
|
})), [
|
|
@@ -155,7 +155,7 @@ var TriggerEditor = ({ space, trigger, onSave, onCancel }) => {
|
|
|
155
155
|
return /* @__PURE__ */ React3.createElement(Form2, {
|
|
156
156
|
outerSpacing: false,
|
|
157
157
|
Custom,
|
|
158
|
-
schema:
|
|
158
|
+
schema: FunctionTrigger,
|
|
159
159
|
values: trigger,
|
|
160
160
|
onSave: handleSave,
|
|
161
161
|
onCancel,
|
|
@@ -228,4 +228,4 @@ var getFunctionOptions = (scripts, functions) => {
|
|
|
228
228
|
export {
|
|
229
229
|
TriggerEditor
|
|
230
230
|
};
|
|
231
|
-
//# sourceMappingURL=chunk-
|
|
231
|
+
//# sourceMappingURL=chunk-N7NES6SZ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/TriggerEditor/TriggerEditor.tsx", "../../../src/components/TriggerEditor/FunctionInputEditor.tsx", "../../../src/components/TriggerEditor/SpecSelector.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { ComputeGraph } from '@dxos/conductor';\nimport { Type } from '@dxos/echo';\nimport { FunctionTrigger, FunctionType, ScriptType } from '@dxos/functions';\nimport { Filter, Ref, type Space, useQuery } from '@dxos/react-client/echo';\nimport { type CustomInputMap, Form, SelectInput, useRefQueryLookupHandler } from '@dxos/react-ui-form';\n\nimport { FunctionInputEditor, type FunctionInputEditorProps } from './FunctionInputEditor';\nimport { SpecSelector } from './SpecSelector';\n\nexport type TriggerEditorProps = {\n space: Space;\n trigger: FunctionTrigger;\n onSave?: (trigger: Omit<FunctionTrigger, 'id'>) => void;\n onCancel?: () => void;\n};\n\nexport const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEditorProps) => {\n const handleSave = (values: FunctionTrigger) => {\n onSave?.(values);\n };\n\n const handleRefQueryLookup = useRefQueryLookupHandler({ space });\n const Custom = useCustomInputs(space, handleRefQueryLookup);\n\n return (\n <Form\n outerSpacing={false}\n Custom={Custom}\n schema={FunctionTrigger}\n values={trigger}\n onSave={handleSave}\n onCancel={onCancel}\n onQueryRefOptions={handleRefQueryLookup}\n />\n );\n};\n\nconst useCustomInputs = (space: Space, onQueryRefOptions: FunctionInputEditorProps['onQueryRefOptions']) => {\n const functions = useQuery(space, Filter.type(FunctionType));\n const workflows = useQuery(space, Filter.type(ComputeGraph));\n const scripts = useQuery(space, Filter.type(ScriptType));\n\n return useMemo(\n (): CustomInputMap => ({\n // Function selector.\n ['function' satisfies keyof FunctionTrigger]: (props) => {\n const getValue = useCallback(() => {\n const formValue = props.getValue();\n if (Ref.isRef(formValue)) {\n return formValue.dxn.toString() as string;\n }\n return undefined;\n }, [props]);\n\n const handleOnValueChange = useCallback(\n (_type: any, dxnString: string) => {\n const dxn = Type.DXN.parse(dxnString);\n if (dxn) {\n const ref = Ref.fromDXN(dxn);\n props.onValueChange('object', ref);\n }\n },\n [props.onValueChange],\n );\n\n return (\n <SelectInput\n {...props}\n getValue={getValue as any}\n onValueChange={handleOnValueChange}\n options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}\n />\n );\n },\n\n // Spec selector.\n ['spec.kind' as const]: SpecSelector,\n\n // Function input editor.\n ['input' as const]: (props) => (\n <FunctionInputEditor {...props} functions={functions} onQueryRefOptions={onQueryRefOptions} />\n ),\n }),\n [workflows, scripts, functions],\n );\n};\n\nconst getWorkflowOptions = (graphs: ComputeGraph[]) => {\n return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));\n};\n\nconst getFunctionOptions = (scripts: ScriptType[], functions: FunctionType[]) => {\n const getLabel = (fn: FunctionType) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;\n return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:echo:@:${fn.id}` }));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { Ref, Type } from '@dxos/echo';\nimport { type JsonPath } from '@dxos/echo-schema';\nimport { type FunctionType } from '@dxos/functions';\nimport { useOnTransition } from '@dxos/react-ui';\nimport { Form, type FormInputStateProps, type QueryRefOptions, useFormValues } from '@dxos/react-ui-form';\n\nexport type FunctionInputEditorProps = {\n functions: FunctionType[];\n onQueryRefOptions: QueryRefOptions;\n} & FormInputStateProps;\n\n/**\n * Editor component for function input parameters.\n */\nexport const FunctionInputEditor = ({\n functions,\n getValue,\n onValueChange,\n onQueryRefOptions,\n}: FunctionInputEditorProps) => {\n const selectedFunctionValue = useFormValues(['function' as JsonPath]);\n const selectedFunctionId = useMemo(() => {\n if (Ref.isRef(selectedFunctionValue)) {\n return selectedFunctionValue.dxn.toString().split('dxn:echo:@:').at(1);\n }\n }, [selectedFunctionValue]);\n\n const selectedFunction = useMemo(\n () => functions.find((fn) => fn.id === selectedFunctionId),\n [functions, selectedFunctionId],\n );\n\n useOnTransition(\n // Clear function parameter input when the function changes.\n selectedFunctionValue,\n (prevValue) => prevValue !== undefined && prevValue !== selectedFunctionValue,\n (currValue) => currValue !== undefined,\n () => onValueChange('object', {}),\n );\n\n const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);\n const effectSchema = useMemo(() => (inputSchema ? Type.toEffectSchema(inputSchema) : undefined), [inputSchema]);\n const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;\n\n const values = useMemo(() => getValue() ?? {}, [getValue]);\n\n const handleValuesChanged = useCallback(\n (values: any) => {\n onValueChange('object', values);\n },\n [onValueChange],\n );\n\n if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {\n return null;\n }\n\n return (\n <>\n <h3 className='text-md'>Function parameters</h3>\n {/* TODO(ZaymonFC): Try using <FormFields /> internal component for this nesting.\n This would allow errors to flow up to the root context. */}\n <Form\n schema={effectSchema}\n values={values}\n onValuesChanged={handleValuesChanged}\n onQueryRefOptions={onQueryRefOptions}\n outerSpacing={false}\n />\n </>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type FunctionTrigger, TriggerKinds, type TriggerType } from '@dxos/functions';\nimport { useTranslation } from '@dxos/react-ui';\nimport { type InputProps, SelectInput, useInputProps } from '@dxos/react-ui-form';\n\nimport { meta } from '../../meta';\n\nexport type SpecSelectorProps = InputProps;\n\nexport const SpecSelector = (props: SpecSelectorProps) => {\n const { t } = useTranslation(meta.id);\n const specProps = useInputProps(['spec' satisfies keyof FunctionTrigger]);\n\n const handleTypeChange = useCallback(\n (_type: any, value: string): TriggerType | undefined => {\n const getDefaultTriggerSpec = (kind: string) => {\n switch (kind) {\n case 'timer':\n return { kind: 'timer', cron: '' };\n case 'subscription':\n return { kind: 'subscription', filter: {} };\n case 'queue':\n return { kind: 'queue', queue: '' };\n case 'email':\n return { kind: 'email' };\n case 'webhook':\n return { kind: 'webhook' };\n default:\n return undefined;\n }\n };\n\n const defaultSpec = getDefaultTriggerSpec(value);\n if (!defaultSpec) {\n return;\n }\n\n // Update the entire spec object, not just the `spec.kind`.\n specProps.onValueChange('object', defaultSpec);\n },\n [specProps],\n );\n\n const options = useMemo(\n () =>\n TriggerKinds.map((kind) => ({\n value: kind,\n label: t(`trigger type ${kind}`),\n })),\n [t],\n );\n\n return <SelectInput {...props} options={options} onValueChange={handleTypeChange} />;\n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A;QAACf,MAAMiB;OAAc;AAGvB,aACE,gBAAAjC,OAAA,cAACkC,cAAAA;QACE,GAAGlB;QACJC;QACAgB,eAAeR;QACfU,SAASC,mBAAmBzB,SAAAA,EAAW0B,OAAOC,mBAAmBzB,SAASP,SAAAA,CAAAA;;IAGhF;;IAGA,CAAC,WAAA,GAAuBiC;;IAGxB,CAAC,OAAA,GAAmB,CAACvB,UACnB,gBAAAhB,OAAA,cAACwC,qBAAAA;MAAqB,GAAGxB;MAAOV;MAAsBD;;EAE1D,IACA;IAACM;IAAWE;IAASP;GAAU;AAEnC;AAEA,IAAM8B,qBAAqB,CAACK,WAAAA;AAC1B,SAAOA,OAAOC,IAAI,CAACC,WAAW;IAAEC,OAAO,WAAWD,MAAME,EAAE;IAAIC,OAAO,cAAcH,MAAME,EAAE;EAAG,EAAA;AAChG;AAEA,IAAMP,qBAAqB,CAACzB,SAAuBP,cAAAA;AACjD,QAAMyC,WAAW,CAACC,OAAqBnC,QAAQoC,KAAK,CAACC,MAAMF,GAAGG,QAAQC,QAAQP,OAAOK,EAAEL,EAAE,GAAGQ,QAAQL,GAAGK;AACvG,SAAO/C,UAAUoC,IAAI,CAACM,QAAQ;IAAEJ,OAAOG,SAASC,EAAAA;IAAKF,OAAO,cAAcE,GAAGH,EAAE;EAAG,EAAA;AACpF;",
|
|
6
|
+
"names": ["React", "useCallback", "useMemo", "ComputeGraph", "Type", "FunctionTrigger", "FunctionType", "ScriptType", "Filter", "Ref", "useQuery", "Form", "SelectInput", "useRefQueryLookupHandler", "React", "useCallback", "useMemo", "Ref", "Type", "useOnTransition", "Form", "useFormValues", "FunctionInputEditor", "functions", "getValue", "onValueChange", "onQueryRefOptions", "selectedFunctionValue", "useFormValues", "selectedFunctionId", "useMemo", "Ref", "isRef", "dxn", "toString", "split", "at", "selectedFunction", "find", "fn", "id", "useOnTransition", "prevValue", "undefined", "currValue", "inputSchema", "effectSchema", "Type", "toEffectSchema", "propertyCount", "properties", "Object", "keys", "length", "values", "handleValuesChanged", "useCallback", "h3", "className", "Form", "schema", "onValuesChanged", "outerSpacing", "React", "useCallback", "useMemo", "TriggerKinds", "useTranslation", "SelectInput", "useInputProps", "SpecSelector", "props", "t", "useTranslation", "meta", "id", "specProps", "useInputProps", "handleTypeChange", "useCallback", "_type", "value", "getDefaultTriggerSpec", "kind", "cron", "filter", "queue", "undefined", "defaultSpec", "onValueChange", "options", "useMemo", "TriggerKinds", "map", "label", "React", "SelectInput", "TriggerEditor", "space", "trigger", "onSave", "onCancel", "handleSave", "values", "handleRefQueryLookup", "useRefQueryLookupHandler", "Custom", "useCustomInputs", "React", "Form", "outerSpacing", "schema", "FunctionTrigger", "onQueryRefOptions", "functions", "useQuery", "Filter", "type", "FunctionType", "workflows", "ComputeGraph", "scripts", "ScriptType", "useMemo", "props", "getValue", "useCallback", "formValue", "Ref", "isRef", "dxn", "toString", "undefined", "handleOnValueChange", "_type", "dxnString", "Type", "DXN", "parse", "ref", "fromDXN", "onValueChange", "SelectInput", "options", "getWorkflowOptions", "concat", "getFunctionOptions", "SpecSelector", "FunctionInputEditor", "graphs", "map", "graph", "label", "id", "value", "getLabel", "fn", "find", "s", "source", "target", "name"]
|
|
7
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-5MQJPJR2.mjs";
|
|
5
5
|
|
|
6
6
|
// src/components/FunctionsPanel/FunctionsPanel.tsx
|
|
7
7
|
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
8
8
|
import { Schema } from "effect";
|
|
9
9
|
import React, { useCallback, useMemo } from "react";
|
|
10
|
-
import {
|
|
10
|
+
import { LayoutAction, createIntent, useIntentDispatcher } from "@dxos/app-framework";
|
|
11
11
|
import { FunctionType, ScriptType } from "@dxos/functions";
|
|
12
12
|
import { Filter, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
|
|
13
13
|
import { Button, useTranslation } from "@dxos/react-ui";
|
|
@@ -18,7 +18,7 @@ var grid = "grid grid-cols-[1fr_auto] min-bs-[2.5rem]";
|
|
|
18
18
|
var FunctionsPanel = ({ space }) => {
|
|
19
19
|
var _effect = _useSignals();
|
|
20
20
|
try {
|
|
21
|
-
const { t } = useTranslation(
|
|
21
|
+
const { t } = useTranslation(meta.id);
|
|
22
22
|
const functions = useQuery(space, Filter.type(FunctionType));
|
|
23
23
|
const scripts = useQuery(space, Filter.type(ScriptType));
|
|
24
24
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
@@ -92,4 +92,4 @@ export {
|
|
|
92
92
|
FunctionsPanel,
|
|
93
93
|
FunctionsPanel_default
|
|
94
94
|
};
|
|
95
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-PBULJE4B.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/FunctionsPanel/FunctionsPanel.tsx", "../../../src/components/FunctionsPanel/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';\nimport { FunctionType, ScriptType } from '@dxos/functions';\nimport { Filter, type Space, fullyQualifiedId, useQuery } from '@dxos/react-client/echo';\nimport { Button, useTranslation } from '@dxos/react-ui';\nimport { controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../../meta';\n\nconst grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';\n\nexport type FunctionsPanelProps = {\n space: Space;\n};\n\nexport const FunctionsPanel = ({ space }: FunctionsPanelProps) => {\n const { t } = useTranslation(meta.id);\n const functions = useQuery(space, Filter.type(FunctionType));\n const scripts = useQuery(space, Filter.type(ScriptType));\n const { dispatchPromise: dispatch } = useIntentDispatcher();\n\n const functionToScriptMap = useMemo(\n () =>\n functions.reduce(\n (map, func) => {\n const scriptId = func.source?.target?.id;\n if (scriptId) {\n const script = scripts.find((s) => s.id === scriptId);\n if (script) {\n map[func.id] = script;\n }\n }\n return map;\n },\n {} as Record<string, ScriptType>,\n ),\n [functions, scripts],\n );\n\n const getScriptName = useCallback(\n (func: FunctionType) => {\n const script = functionToScriptMap[func.id];\n return script?.name;\n },\n [functionToScriptMap],\n );\n\n const handleGoToScript = useCallback(\n (func: FunctionType) => {\n const script = functionToScriptMap[func.id];\n if (script) {\n void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(script)] }));\n }\n },\n [functionToScriptMap, dispatch],\n );\n\n return (\n <div role='none' className={mx(controlItemClasses)}>\n {functions.length > 0 && (\n <List.Root<FunctionType> items={functions} isItem={Schema.is(FunctionType)} getId={(func) => func.id}>\n {({ items }) => (\n <div role='list' className='flex flex-col w-full'>\n {items?.map((func) => (\n <List.Item<FunctionType>\n key={func.id}\n item={func}\n classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}\n >\n <div className='flex flex-col truncate'>\n <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>\n {getScriptName(func) && (\n <div className='text-xs text-description truncate'>{getScriptName(func)}</div>\n )}\n </div>\n {functionToScriptMap[func.id] && (\n <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>\n )}\n </List.Item>\n ))}\n </div>\n )}\n </List.Root>\n )}\n\n {functions.length === 0 && <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>}\n </div>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FunctionsPanel } from './FunctionsPanel';\n\nexport * from './FunctionsPanel';\nexport default FunctionsPanel;\n"],
|
|
5
|
+
"mappings": ";;;;;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pG;IACF,GACA;MAACR;MAAqBF;KAAS;AAGjC,WACE,sBAAA,cAACuB,OAAAA;MAAIC,MAAK;MAAOC,WAAWC,GAAGC,kBAAAA;OAC5BnC,UAAUoC,SAAS,KAClB,sBAAA,cAACC,KAAKC,MAAI;MAAeC,OAAOvC;MAAWwC,QAAQC,OAAOC,GAAGtC,YAAAA;MAAeuC,OAAO,CAAC7B,SAASA,KAAKf;OAC/F,CAAC,EAAEwC,MAAK,MACP,sBAAA,cAACR,OAAAA;MAAIC,MAAK;MAAOC,WAAU;OACxBM,OAAO1B,IAAI,CAACC,SACX,sBAAA,cAACuB,KAAKO,MAAI;MACRC,KAAK/B,KAAKf;MACV+C,MAAMhC;MACNiC,YAAYb,GAAGzC,MAAMuD,YAAY,gBAAgB,SAAS,eAAA;OAE1D,sBAAA,cAACjB,OAAAA;MAAIE,WAAU;OACb,sBAAA,cAACI,KAAKY,WAAS;MAACF,YAAW;OAAYjC,KAAKS,IAAI,GAC/CF,cAAcP,IAAAA,KACb,sBAAA,cAACiB,OAAAA;MAAIE,WAAU;OAAqCZ,cAAcP,IAAAA,CAAAA,CAAAA,GAGrEJ,oBAAoBI,KAAKf,EAAE,KAC1B,sBAAA,cAACmD,QAAAA;MAAOC,SAAS,MAAM3B,iBAAiBV,IAAAA;OAAQlB,EAAE,oCAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAS/DI,UAAUoC,WAAW,KAAK,sBAAA,cAACL,OAAAA;MAAIE,WAAU;OAAmCrC,EAAE,oBAAA,CAAA,CAAA;;;;AAGrF;;;ACzFA,IAAA,yBAAewD;",
|
|
6
|
+
"names": ["Schema", "React", "useCallback", "useMemo", "LayoutAction", "createIntent", "useIntentDispatcher", "FunctionType", "ScriptType", "Filter", "fullyQualifiedId", "useQuery", "Button", "useTranslation", "controlItemClasses", "List", "ghostHover", "mx", "grid", "FunctionsPanel", "space", "t", "useTranslation", "meta", "id", "functions", "useQuery", "Filter", "type", "FunctionType", "scripts", "ScriptType", "dispatchPromise", "dispatch", "useIntentDispatcher", "functionToScriptMap", "useMemo", "reduce", "map", "func", "scriptId", "source", "target", "script", "find", "s", "getScriptName", "useCallback", "name", "handleGoToScript", "createIntent", "LayoutAction", "Open", "part", "subject", "fullyQualifiedId", "div", "role", "className", "mx", "controlItemClasses", "length", "List", "Root", "items", "isItem", "Schema", "is", "getId", "Item", "key", "item", "classNames", "ghostHover", "ItemTitle", "Button", "onClick", "FunctionsPanel"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/capabilities/index.ts
|
|
4
|
+
import { lazy } from "@dxos/app-framework";
|
|
5
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-3A2NIPR5.mjs"));
|
|
6
|
+
var ComputeRuntime = lazy(() => import("./compute-runtime-W5UJNSQY.mjs"));
|
|
7
|
+
var IntentResolver = lazy(() => import("./intent-resolver-ROEBZXSS.mjs"));
|
|
8
|
+
var ReactSurface = lazy(() => import("./react-surface-A4KTYX6Z.mjs"));
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
AppGraphBuilder,
|
|
12
|
+
ComputeRuntime,
|
|
13
|
+
IntentResolver,
|
|
14
|
+
ReactSurface
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-UTZIMYCX.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const AppGraphBuilder = lazy(() => import('./app-graph-builder'));\nexport const ComputeRuntime = lazy(() => import('./compute-runtime'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n\nexport * from './capabilities';\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,YAAY;AAEd,IAAMC,kBAAkBC,KAAK,MAAM,OAAO,kCAAA,CAAA;AAC1C,IAAMC,iBAAiBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,iBAAiBF,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAMG,eAAeH,KAAK,MAAM,OAAO,8BAAA,CAAA;",
|
|
6
|
+
"names": ["lazy", "AppGraphBuilder", "lazy", "ComputeRuntime", "IntentResolver", "ReactSurface"]
|
|
7
|
+
}
|