@dxos/app-framework 0.8.4-main.fd6878d → 0.8.4-main.fffef41
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/.storybook/main.mts +11 -0
- package/.storybook/preview.mts +8 -0
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/.swc/plugins/{v7_linux_x86_64_13.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429 → linux_x86_64_19.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429.wasmer-v7} +0 -0
- package/dist/lib/browser/{app-graph-builder-MOVKFH3J.mjs → app-graph-builder-OIEZZC45.mjs} +31 -30
- package/dist/lib/browser/app-graph-builder-OIEZZC45.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OSBZFKMO.mjs → chunk-6XKO24JP.mjs} +232 -177
- package/dist/lib/browser/chunk-6XKO24JP.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ORWHM7CO.mjs → chunk-SCPE4ZO2.mjs} +11 -8
- package/dist/lib/browser/chunk-SCPE4ZO2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NKCIDYDI.mjs → chunk-WPW5VVAX.mjs} +189 -136
- package/dist/lib/browser/chunk-WPW5VVAX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -56
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-dispatcher-FTTJLVGN.mjs → intent-dispatcher-LZ4AE66E.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-ZCGEAG3E.mjs → intent-resolver-QVCKRX6G.mjs} +7 -7
- package/dist/lib/browser/intent-resolver-QVCKRX6G.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react/index.mjs +34 -0
- package/dist/lib/browser/{store-3QB6Q2BC.mjs → store-CNPHOYTJ.mjs} +5 -5
- package/dist/lib/browser/store-CNPHOYTJ.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +17 -21
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{app-graph-builder-ODE4B5GT.mjs → app-graph-builder-EBU4NVWD.mjs} +31 -30
- package/dist/lib/node-esm/app-graph-builder-EBU4NVWD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WU3QN5B6.mjs → chunk-3UPX5OIS.mjs} +232 -177
- package/dist/lib/node-esm/chunk-3UPX5OIS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YEN7NKTF.mjs → chunk-XJZGUJ3H.mjs} +189 -136
- package/dist/lib/node-esm/chunk-XJZGUJ3H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UMZQERLE.mjs → chunk-ZX63QUGE.mjs} +11 -8
- package/dist/lib/node-esm/chunk-ZX63QUGE.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -56
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-dispatcher-YQIQ55LJ.mjs → intent-dispatcher-MGOJ3CHD.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-KG27L7EQ.mjs → intent-resolver-URF3HN3G.mjs} +7 -7
- package/dist/lib/node-esm/intent-resolver-URF3HN3G.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react/index.mjs +35 -0
- package/dist/lib/node-esm/{store-TIJAVO3D.mjs → store-RK5B4XEL.mjs} +5 -5
- package/dist/lib/node-esm/store-RK5B4XEL.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +17 -21
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/common/capabilities.d.ts +41 -43
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/collaboration.d.ts +10 -9
- package/dist/types/src/common/collaboration.d.ts.map +1 -1
- package/dist/types/src/common/file.d.ts +1 -1
- package/dist/types/src/common/file.d.ts.map +1 -1
- package/dist/types/src/common/layout.d.ts +1 -3
- package/dist/types/src/common/layout.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts +19 -16
- package/dist/types/src/common/surface.d.ts.map +1 -1
- package/dist/types/src/common/translations.d.ts +1 -1
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/core/capabilities.d.ts +19 -16
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts +1 -1
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +8 -1
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/debug/Debug.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Main.d.ts +1 -1
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/generator/generator.d.ts +1 -1
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -1
- package/dist/types/src/playground/generator/plugin.d.ts +1 -1
- package/dist/types/src/playground/generator/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/layout/Layout.d.ts +2 -2
- package/dist/types/src/playground/layout/plugin.d.ts +1 -1
- package/dist/types/src/playground/layout/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/logger/plugin.d.ts +1 -1
- package/dist/types/src/playground/logger/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/logger/schema.d.ts +1 -1
- package/dist/types/src/playground/logger/schema.d.ts.map +1 -1
- package/dist/types/src/playground/playground.stories.d.ts +5 -4
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/actions.d.ts +5 -7
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/errors.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/index.d.ts +1 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +5 -5
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/meta.d.ts +3 -0
- package/dist/types/src/plugin-intent/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +1 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/actions.d.ts +5 -7
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +1 -1
- package/dist/types/src/plugin-settings/meta.d.ts +3 -0
- package/dist/types/src/plugin-settings/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/store.d.ts +1 -1
- package/dist/types/src/plugin-settings/translations.d.ts +2 -1
- package/dist/types/src/plugin-settings/translations.d.ts.map +1 -1
- package/dist/types/src/react/App.d.ts +10 -0
- package/dist/types/src/react/App.d.ts.map +1 -0
- package/dist/types/src/react/App.stories.d.ts +14 -0
- package/dist/types/src/react/App.stories.d.ts.map +1 -0
- package/dist/types/src/react/DefaultFallback.d.ts +8 -0
- package/dist/types/src/react/DefaultFallback.d.ts.map +1 -0
- package/dist/types/src/react/ErrorBoundary.d.ts +2 -2
- package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -1
- package/dist/types/src/react/Surface.d.ts +5 -5
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/Surface.stories.d.ts +8 -10
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -1
- package/dist/types/src/react/index.d.ts +2 -0
- package/dist/types/src/react/index.d.ts.map +1 -1
- package/dist/types/src/react/types.d.ts +14 -0
- package/dist/types/src/react/types.d.ts.map +1 -0
- package/dist/types/src/{App.d.ts → react/useApp.d.ts} +7 -6
- package/dist/types/src/react/useApp.d.ts.map +1 -0
- package/dist/types/src/react/useLoading.d.ts +19 -0
- package/dist/types/src/react/useLoading.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +7 -8
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts +9 -3
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +5 -1
- package/package.json +44 -40
- package/src/common/capabilities.ts +33 -25
- package/src/common/collaboration.ts +6 -9
- package/src/common/file.ts +1 -1
- package/src/common/layout.ts +3 -4
- package/src/common/surface.ts +23 -21
- package/src/common/translations.ts +1 -1
- package/src/core/capabilities.test.ts +2 -2
- package/src/core/capabilities.ts +35 -27
- package/src/core/manager.test.ts +19 -19
- package/src/core/manager.ts +14 -7
- package/src/core/plugin.ts +13 -2
- package/src/index.ts +0 -2
- package/src/playground/debug/Debug.tsx +1 -1
- package/src/playground/debug/plugin.ts +7 -8
- package/src/playground/generator/Main.tsx +0 -1
- package/src/playground/generator/generator.ts +2 -2
- package/src/playground/generator/plugin.ts +12 -13
- package/src/playground/layout/plugin.ts +9 -8
- package/src/playground/logger/plugin.ts +27 -23
- package/src/playground/logger/schema.ts +1 -1
- package/src/playground/playground.stories.tsx +17 -14
- package/src/plugin-intent/IntentPlugin.ts +12 -13
- package/src/plugin-intent/actions.ts +4 -6
- package/src/plugin-intent/errors.ts +2 -1
- package/src/plugin-intent/index.ts +1 -0
- package/src/plugin-intent/intent-dispatcher.test.ts +10 -3
- package/src/plugin-intent/intent-dispatcher.ts +16 -8
- package/src/plugin-intent/intent.ts +1 -1
- package/src/plugin-intent/meta.ts +10 -0
- package/src/plugin-settings/SettingsPlugin.ts +25 -27
- package/src/plugin-settings/actions.ts +9 -13
- package/src/plugin-settings/app-graph-builder.ts +22 -20
- package/src/plugin-settings/intent-resolver.ts +2 -2
- package/src/plugin-settings/meta.ts +10 -0
- package/src/plugin-settings/store.ts +2 -2
- package/src/plugin-settings/translations.ts +4 -4
- package/src/react/App.stories.tsx +33 -0
- package/src/react/App.tsx +59 -0
- package/src/react/DefaultFallback.tsx +26 -0
- package/src/react/ErrorBoundary.tsx +10 -8
- package/src/react/Surface.stories.tsx +79 -51
- package/src/react/Surface.tsx +67 -36
- package/src/react/index.ts +4 -0
- package/src/react/types.ts +38 -0
- package/src/react/useApp.tsx +165 -0
- package/src/react/useCapabilities.ts +2 -2
- package/src/react/useLoading.tsx +70 -0
- package/src/testing/withPluginManager.stories.tsx +7 -4
- package/src/testing/withPluginManager.tsx +27 -29
- package/tsconfig.json +11 -9
- package/vitest.config.ts +8 -6
- package/.swc/plugins/v7_linux_x86_64_13.0.0/c614d7475354583212fbd7669acbae95b9832c305bf51bdaabe2e6de05abb6bf +0 -0
- package/dist/lib/browser/app-graph-builder-MOVKFH3J.mjs.map +0 -7
- package/dist/lib/browser/chunk-NKCIDYDI.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORWHM7CO.mjs.map +0 -7
- package/dist/lib/browser/chunk-OSBZFKMO.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-ZCGEAG3E.mjs.map +0 -7
- package/dist/lib/browser/store-3QB6Q2BC.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -79
- package/dist/lib/node-esm/app-graph-builder-ODE4B5GT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UMZQERLE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WU3QN5B6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YEN7NKTF.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-KG27L7EQ.mjs.map +0 -7
- package/dist/lib/node-esm/store-TIJAVO3D.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -80
- package/dist/types/src/App.d.ts.map +0 -1
- package/dist/types/src/worker.d.ts +0 -4
- package/dist/types/src/worker.d.ts.map +0 -1
- package/src/App.tsx +0 -284
- package/src/worker.ts +0 -11
- /package/dist/lib/browser/{intent-dispatcher-FTTJLVGN.mjs.map → intent-dispatcher-LZ4AE66E.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → react/index.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-YQIQ55LJ.mjs.map → intent-dispatcher-MGOJ3CHD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{worker.mjs.map → react/index.mjs.map} +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// src/plugin-intent/intent-dispatcher.ts
|
|
2
|
-
import
|
|
2
|
+
import * as Effect3 from "effect/Effect";
|
|
3
|
+
import * as Function2 from "effect/Function";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Ref2 from "effect/Ref";
|
|
3
6
|
import { live as live2 } from "@dxos/live-object";
|
|
4
7
|
import { log as log3 } from "@dxos/log";
|
|
5
8
|
import { byPosition } from "@dxos/util";
|
|
6
9
|
|
|
7
10
|
// src/core/capabilities.ts
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
11
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
10
13
|
import { Trigger } from "@dxos/async";
|
|
11
14
|
import { invariant } from "@dxos/invariant";
|
|
12
15
|
import { log } from "@dxos/log";
|
|
@@ -38,21 +41,21 @@ var lazy = (c) => async (props) => {
|
|
|
38
41
|
};
|
|
39
42
|
var PluginContext = class {
|
|
40
43
|
_registry;
|
|
41
|
-
_capabilityImpls =
|
|
42
|
-
return
|
|
44
|
+
_capabilityImpls = Atom.family(() => {
|
|
45
|
+
return Atom.make([]).pipe(Atom.keepAlive);
|
|
43
46
|
});
|
|
44
|
-
_capabilities =
|
|
45
|
-
return
|
|
47
|
+
_capabilities = Atom.family((id) => {
|
|
48
|
+
return Atom.make((get) => {
|
|
46
49
|
const current = get(this._capabilityImpls(id));
|
|
47
50
|
return current.map((c) => c.implementation);
|
|
48
51
|
});
|
|
49
52
|
});
|
|
50
|
-
_capability =
|
|
51
|
-
return
|
|
53
|
+
_capability = Atom.family((id) => {
|
|
54
|
+
return Atom.make((get) => {
|
|
52
55
|
const current = get(this._capabilities(id));
|
|
53
56
|
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
54
57
|
F: __dxlog_file,
|
|
55
|
-
L:
|
|
58
|
+
L: 126,
|
|
56
59
|
S: this,
|
|
57
60
|
A: [
|
|
58
61
|
"current.length > 0",
|
|
@@ -98,7 +101,7 @@ var PluginContext = class {
|
|
|
98
101
|
count: current.length
|
|
99
102
|
}, {
|
|
100
103
|
F: __dxlog_file,
|
|
101
|
-
L:
|
|
104
|
+
L: 170,
|
|
102
105
|
S: this,
|
|
103
106
|
C: (f, a) => f(...a)
|
|
104
107
|
});
|
|
@@ -119,7 +122,7 @@ var PluginContext = class {
|
|
|
119
122
|
count: current.length
|
|
120
123
|
}, {
|
|
121
124
|
F: __dxlog_file,
|
|
122
|
-
L:
|
|
125
|
+
L: 189,
|
|
123
126
|
S: this,
|
|
124
127
|
C: (f, a) => f(...a)
|
|
125
128
|
});
|
|
@@ -128,26 +131,26 @@ var PluginContext = class {
|
|
|
128
131
|
id: interfaceDef.identifier
|
|
129
132
|
}, {
|
|
130
133
|
F: __dxlog_file,
|
|
131
|
-
L:
|
|
134
|
+
L: 191,
|
|
132
135
|
S: this,
|
|
133
136
|
C: (f, a) => f(...a)
|
|
134
137
|
});
|
|
135
138
|
}
|
|
136
139
|
}
|
|
137
140
|
/**
|
|
138
|
-
* Get the
|
|
139
|
-
* Primarily useful for deriving other
|
|
141
|
+
* Get the Atom reference to the available capabilities for a given interface.
|
|
142
|
+
* Primarily useful for deriving other Atom values based on the capabilities or
|
|
140
143
|
* for subscribing to changes in the capabilities.
|
|
141
|
-
* @returns An
|
|
144
|
+
* @returns An atom reference to the available capabilities.
|
|
142
145
|
*/
|
|
143
146
|
capabilities(interfaceDef) {
|
|
144
147
|
return this._capabilities(interfaceDef.identifier);
|
|
145
148
|
}
|
|
146
149
|
/**
|
|
147
|
-
* Get the
|
|
148
|
-
* Primarily useful for deriving other
|
|
150
|
+
* Get the Atom reference to the available capabilities for a given interface.
|
|
151
|
+
* Primarily useful for deriving other Atom values based on the capability or
|
|
149
152
|
* for subscribing to changes in the capability.
|
|
150
|
-
* @returns An
|
|
153
|
+
* @returns An atom reference to the available capability.
|
|
151
154
|
* @throws If no capability is found.
|
|
152
155
|
*/
|
|
153
156
|
capability(interfaceDef) {
|
|
@@ -218,28 +221,35 @@ var getEvents = (events) => "type" in events ? events.events : [
|
|
|
218
221
|
];
|
|
219
222
|
|
|
220
223
|
// src/core/manager.ts
|
|
221
|
-
import { Registry } from "@effect-
|
|
224
|
+
import { Registry } from "@effect-atom/atom-react";
|
|
222
225
|
import { untracked } from "@preact/signals-core";
|
|
223
|
-
import
|
|
226
|
+
import * as Array from "effect/Array";
|
|
227
|
+
import * as Duration from "effect/Duration";
|
|
228
|
+
import * as Effect2 from "effect/Effect";
|
|
229
|
+
import * as Fiber from "effect/Fiber";
|
|
230
|
+
import * as Function from "effect/Function";
|
|
231
|
+
import * as HashSet from "effect/HashSet";
|
|
232
|
+
import * as Match from "effect/Match";
|
|
233
|
+
import * as Ref from "effect/Ref";
|
|
224
234
|
import { Event } from "@dxos/async";
|
|
225
235
|
import { live } from "@dxos/live-object";
|
|
226
236
|
import { log as log2 } from "@dxos/log";
|
|
227
237
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
|
|
228
|
-
var isPromise = (
|
|
229
|
-
return
|
|
238
|
+
var isPromise = (value2) => {
|
|
239
|
+
return value2 !== null && typeof value2 === "object" && "then" in value2;
|
|
230
240
|
};
|
|
231
241
|
var PluginManager = class {
|
|
232
242
|
activation = new Event();
|
|
233
243
|
context;
|
|
234
244
|
registry;
|
|
235
|
-
// TODO(wittjosiah): Replace with
|
|
245
|
+
// TODO(wittjosiah): Replace with Atom.
|
|
236
246
|
_state;
|
|
237
247
|
_pluginLoader;
|
|
238
248
|
_capabilities = /* @__PURE__ */ new Map();
|
|
239
249
|
_moduleMemoMap = /* @__PURE__ */ new Map();
|
|
240
250
|
_activatingEvents = Effect2.runSync(Ref.make([]));
|
|
241
251
|
_activatingModules = Effect2.runSync(Ref.make([]));
|
|
242
|
-
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) =>
|
|
252
|
+
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.id), enabled = [], registry }) {
|
|
243
253
|
this.registry = registry ?? Registry.make();
|
|
244
254
|
this.context = new PluginContext({
|
|
245
255
|
registry: this.registry,
|
|
@@ -326,7 +336,7 @@ var PluginManager = class {
|
|
|
326
336
|
id
|
|
327
337
|
}, {
|
|
328
338
|
F: __dxlog_file2,
|
|
329
|
-
L:
|
|
339
|
+
L: 164,
|
|
330
340
|
S: this,
|
|
331
341
|
C: (f, a) => f(...a)
|
|
332
342
|
});
|
|
@@ -345,7 +355,7 @@ var PluginManager = class {
|
|
|
345
355
|
id
|
|
346
356
|
}, {
|
|
347
357
|
F: __dxlog_file2,
|
|
348
|
-
L:
|
|
358
|
+
L: 177,
|
|
349
359
|
S: this,
|
|
350
360
|
C: (f, a) => f(...a)
|
|
351
361
|
});
|
|
@@ -366,7 +376,7 @@ var PluginManager = class {
|
|
|
366
376
|
]
|
|
367
377
|
}, {
|
|
368
378
|
F: __dxlog_file2,
|
|
369
|
-
L:
|
|
379
|
+
L: 192,
|
|
370
380
|
S: this,
|
|
371
381
|
C: (f, a) => f(...a)
|
|
372
382
|
});
|
|
@@ -386,7 +396,7 @@ var PluginManager = class {
|
|
|
386
396
|
id
|
|
387
397
|
}, {
|
|
388
398
|
F: __dxlog_file2,
|
|
389
|
-
L:
|
|
399
|
+
L: 210,
|
|
390
400
|
S: this,
|
|
391
401
|
C: (f, a) => f(...a)
|
|
392
402
|
});
|
|
@@ -408,7 +418,7 @@ var PluginManager = class {
|
|
|
408
418
|
id
|
|
409
419
|
}, {
|
|
410
420
|
F: __dxlog_file2,
|
|
411
|
-
L:
|
|
421
|
+
L: 227,
|
|
412
422
|
S: this,
|
|
413
423
|
C: (f, a) => f(...a)
|
|
414
424
|
});
|
|
@@ -460,7 +470,7 @@ var PluginManager = class {
|
|
|
460
470
|
id: plugin.meta.id
|
|
461
471
|
}, {
|
|
462
472
|
F: __dxlog_file2,
|
|
463
|
-
L:
|
|
473
|
+
L: 280,
|
|
464
474
|
S: this,
|
|
465
475
|
C: (f, a) => f(...a)
|
|
466
476
|
});
|
|
@@ -475,7 +485,7 @@ var PluginManager = class {
|
|
|
475
485
|
id
|
|
476
486
|
}, {
|
|
477
487
|
F: __dxlog_file2,
|
|
478
|
-
L:
|
|
488
|
+
L: 290,
|
|
479
489
|
S: this,
|
|
480
490
|
C: (f, a) => f(...a)
|
|
481
491
|
});
|
|
@@ -491,7 +501,7 @@ var PluginManager = class {
|
|
|
491
501
|
id: module.id
|
|
492
502
|
}, {
|
|
493
503
|
F: __dxlog_file2,
|
|
494
|
-
L:
|
|
504
|
+
L: 300,
|
|
495
505
|
S: this,
|
|
496
506
|
C: (f, a) => f(...a)
|
|
497
507
|
});
|
|
@@ -506,7 +516,7 @@ var PluginManager = class {
|
|
|
506
516
|
id
|
|
507
517
|
}, {
|
|
508
518
|
F: __dxlog_file2,
|
|
509
|
-
L:
|
|
519
|
+
L: 310,
|
|
510
520
|
S: this,
|
|
511
521
|
C: (f, a) => f(...a)
|
|
512
522
|
});
|
|
@@ -540,7 +550,7 @@ var PluginManager = class {
|
|
|
540
550
|
events: pendingReset
|
|
541
551
|
}, {
|
|
542
552
|
F: __dxlog_file2,
|
|
543
|
-
L:
|
|
553
|
+
L: 348,
|
|
544
554
|
S: this,
|
|
545
555
|
C: (f, a) => f(...a)
|
|
546
556
|
});
|
|
@@ -560,7 +570,7 @@ var PluginManager = class {
|
|
|
560
570
|
...params
|
|
561
571
|
}, {
|
|
562
572
|
F: __dxlog_file2,
|
|
563
|
-
L:
|
|
573
|
+
L: 364,
|
|
564
574
|
S: this,
|
|
565
575
|
C: (f, a) => f(...a)
|
|
566
576
|
});
|
|
@@ -585,7 +595,7 @@ var PluginManager = class {
|
|
|
585
595
|
key
|
|
586
596
|
}, {
|
|
587
597
|
F: __dxlog_file2,
|
|
588
|
-
L:
|
|
598
|
+
L: 395,
|
|
589
599
|
S: this,
|
|
590
600
|
C: (f, a) => f(...a)
|
|
591
601
|
});
|
|
@@ -599,7 +609,7 @@ var PluginManager = class {
|
|
|
599
609
|
modules: modules.map((module) => module.id)
|
|
600
610
|
}, {
|
|
601
611
|
F: __dxlog_file2,
|
|
602
|
-
L:
|
|
612
|
+
L: 402,
|
|
603
613
|
S: this,
|
|
604
614
|
C: (f, a) => f(...a)
|
|
605
615
|
});
|
|
@@ -607,12 +617,12 @@ var PluginManager = class {
|
|
|
607
617
|
event: key,
|
|
608
618
|
state: "activating"
|
|
609
619
|
});
|
|
610
|
-
yield* pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
620
|
+
yield* Function.pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
611
621
|
before: key
|
|
612
622
|
})), Effect2.allWith({
|
|
613
623
|
concurrency: "unbounded"
|
|
614
624
|
}));
|
|
615
|
-
const getCapabilities = yield* pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
|
|
625
|
+
const getCapabilities = yield* Function.pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
|
|
616
626
|
concurrency: "unbounded"
|
|
617
627
|
}), Effect2.catchAll((error) => {
|
|
618
628
|
this.activation.emit({
|
|
@@ -622,15 +632,13 @@ var PluginManager = class {
|
|
|
622
632
|
});
|
|
623
633
|
return Effect2.fail(error);
|
|
624
634
|
}));
|
|
625
|
-
yield* pipe(
|
|
635
|
+
yield* Function.pipe(
|
|
626
636
|
modules,
|
|
627
637
|
Array.zip(getCapabilities),
|
|
628
638
|
Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
|
|
629
|
-
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
630
|
-
// Running this with concurrency causes races with `allOf` activation events.
|
|
631
639
|
Effect2.all
|
|
632
640
|
);
|
|
633
|
-
yield* pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
641
|
+
yield* Function.pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
634
642
|
after: key
|
|
635
643
|
})), Effect2.allWith({
|
|
636
644
|
concurrency: "unbounded"
|
|
@@ -648,7 +656,7 @@ var PluginManager = class {
|
|
|
648
656
|
key
|
|
649
657
|
}, {
|
|
650
658
|
F: __dxlog_file2,
|
|
651
|
-
L:
|
|
659
|
+
L: 458,
|
|
652
660
|
S: this,
|
|
653
661
|
C: (f, a) => f(...a)
|
|
654
662
|
});
|
|
@@ -662,7 +670,7 @@ var PluginManager = class {
|
|
|
662
670
|
if (entry) {
|
|
663
671
|
return entry;
|
|
664
672
|
}
|
|
665
|
-
const
|
|
673
|
+
const promise2 = (async () => {
|
|
666
674
|
const start = performance.now();
|
|
667
675
|
let failed = false;
|
|
668
676
|
try {
|
|
@@ -670,7 +678,7 @@ var PluginManager = class {
|
|
|
670
678
|
module: mod.id
|
|
671
679
|
}, {
|
|
672
680
|
F: __dxlog_file2,
|
|
673
|
-
L:
|
|
681
|
+
L: 477,
|
|
674
682
|
S: this,
|
|
675
683
|
C: (f, a) => f(...a)
|
|
676
684
|
});
|
|
@@ -698,21 +706,21 @@ var PluginManager = class {
|
|
|
698
706
|
failed
|
|
699
707
|
}, {
|
|
700
708
|
F: __dxlog_file2,
|
|
701
|
-
L:
|
|
709
|
+
L: 495,
|
|
702
710
|
S: this,
|
|
703
711
|
C: (f, a) => f(...a)
|
|
704
712
|
});
|
|
705
713
|
}
|
|
706
714
|
})();
|
|
707
|
-
this._moduleMemoMap.set(mod.id,
|
|
708
|
-
return
|
|
715
|
+
this._moduleMemoMap.set(mod.id, promise2);
|
|
716
|
+
return promise2;
|
|
709
717
|
},
|
|
710
718
|
catch: (error) => error
|
|
711
719
|
}).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
|
|
712
720
|
module: mod.id
|
|
713
721
|
}, {
|
|
714
722
|
F: __dxlog_file2,
|
|
715
|
-
L:
|
|
723
|
+
L: 506,
|
|
716
724
|
S: this,
|
|
717
725
|
C: (f, a) => f(...a)
|
|
718
726
|
}))))));
|
|
@@ -748,7 +756,7 @@ var PluginManager = class {
|
|
|
748
756
|
id
|
|
749
757
|
}, {
|
|
750
758
|
F: __dxlog_file2,
|
|
751
|
-
L:
|
|
759
|
+
L: 540,
|
|
752
760
|
S: this,
|
|
753
761
|
C: (f, a) => f(...a)
|
|
754
762
|
});
|
|
@@ -758,8 +766,8 @@ var PluginManager = class {
|
|
|
758
766
|
for (const capability of capabilities) {
|
|
759
767
|
this.context.removeCapability(capability.interface, capability.implementation);
|
|
760
768
|
const program = capability.deactivate?.();
|
|
761
|
-
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (
|
|
762
|
-
try: () =>
|
|
769
|
+
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise2) => Effect2.tryPromise({
|
|
770
|
+
try: () => promise2,
|
|
763
771
|
catch: (error) => error
|
|
764
772
|
})), Match.orElse((program2) => Effect2.succeed(program2)));
|
|
765
773
|
}
|
|
@@ -773,7 +781,7 @@ var PluginManager = class {
|
|
|
773
781
|
id
|
|
774
782
|
}, {
|
|
775
783
|
F: __dxlog_file2,
|
|
776
|
-
L:
|
|
784
|
+
L: 567,
|
|
777
785
|
S: this,
|
|
778
786
|
C: (f, a) => f(...a)
|
|
779
787
|
});
|
|
@@ -787,7 +795,7 @@ var PluginManager = class {
|
|
|
787
795
|
key
|
|
788
796
|
}, {
|
|
789
797
|
F: __dxlog_file2,
|
|
790
|
-
L:
|
|
798
|
+
L: 575,
|
|
791
799
|
S: this,
|
|
792
800
|
C: (f, a) => f(...a)
|
|
793
801
|
});
|
|
@@ -829,20 +837,25 @@ var defineModule = (options) => new PluginModule(options);
|
|
|
829
837
|
var Plugin = class {
|
|
830
838
|
meta;
|
|
831
839
|
modules;
|
|
832
|
-
constructor(
|
|
833
|
-
this.meta =
|
|
840
|
+
constructor(meta2, modules) {
|
|
841
|
+
this.meta = meta2;
|
|
834
842
|
this.modules = modules;
|
|
835
843
|
}
|
|
836
844
|
};
|
|
837
|
-
var definePlugin = (
|
|
838
|
-
|
|
845
|
+
var definePlugin = (meta2, provider) => {
|
|
846
|
+
const factory = (args) => {
|
|
847
|
+
return new Plugin(meta2, provider(args));
|
|
848
|
+
};
|
|
849
|
+
return Object.assign(factory, {
|
|
850
|
+
meta: meta2
|
|
851
|
+
});
|
|
839
852
|
};
|
|
840
853
|
|
|
841
854
|
// src/common/capabilities.ts
|
|
842
855
|
(function(Capabilities2) {
|
|
843
856
|
Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
|
|
844
857
|
Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
|
|
845
|
-
Capabilities2.
|
|
858
|
+
Capabilities2.AtomRegistry = defineCapability("dxos.org/app-framework/capability/atom-registry");
|
|
846
859
|
Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
|
|
847
860
|
Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
|
|
848
861
|
Capabilities2.ReactSurface = defineCapability("dxos.org/app-framework/common/react-surface");
|
|
@@ -856,10 +869,10 @@ var definePlugin = (meta, modules) => {
|
|
|
856
869
|
Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
|
|
857
870
|
Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
|
|
858
871
|
Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
|
|
859
|
-
Capabilities2.Tools = defineCapability("dxos.org/app-framework/capability/tools");
|
|
860
872
|
Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
|
|
861
|
-
Capabilities2.ToolkitHandler = defineCapability("dxos.org/app-framework/capability/ai-toolkit-handler");
|
|
862
873
|
Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
|
|
874
|
+
Capabilities2.AiServiceLayer = defineCapability("dxos.org/app-framework/capability/ai-service-factory");
|
|
875
|
+
Capabilities2.AiModelResolver = defineCapability("dxos.org/app-framework/capability/ai-model-resolver");
|
|
863
876
|
Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
|
|
864
877
|
Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
|
|
865
878
|
Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
|
|
@@ -867,22 +880,19 @@ var definePlugin = (meta, modules) => {
|
|
|
867
880
|
var Capabilities;
|
|
868
881
|
|
|
869
882
|
// src/common/collaboration.ts
|
|
870
|
-
import
|
|
871
|
-
import {
|
|
883
|
+
import * as Schema from "effect/Schema";
|
|
884
|
+
import { ContentBlock } from "@dxos/types";
|
|
872
885
|
(function(CollaborationActions2) {
|
|
873
|
-
class
|
|
886
|
+
class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
|
|
874
887
|
input: Schema.Struct({
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
label: Schema.String.pipe(Schema.optional)
|
|
879
|
-
}).annotations({
|
|
880
|
-
description: "Enables plugins to inject content blocks or references into a related entity."
|
|
888
|
+
subject: Schema.Any,
|
|
889
|
+
anchor: Schema.String,
|
|
890
|
+
proposal: ContentBlock.Proposal
|
|
881
891
|
}),
|
|
882
892
|
output: Schema.Void
|
|
883
893
|
}) {
|
|
884
894
|
}
|
|
885
|
-
CollaborationActions2.
|
|
895
|
+
CollaborationActions2.AcceptProposal = AcceptProposal;
|
|
886
896
|
})(CollaborationActions || (CollaborationActions = {}));
|
|
887
897
|
var CollaborationActions;
|
|
888
898
|
|
|
@@ -905,7 +915,7 @@ var CollaborationActions;
|
|
|
905
915
|
var Events;
|
|
906
916
|
|
|
907
917
|
// src/common/file.ts
|
|
908
|
-
import
|
|
918
|
+
import * as Schema2 from "effect/Schema";
|
|
909
919
|
var defaultFileTypes = {
|
|
910
920
|
images: [
|
|
911
921
|
"png",
|
|
@@ -933,13 +943,13 @@ var FileInfoSchema = Schema2.Struct({
|
|
|
933
943
|
});
|
|
934
944
|
|
|
935
945
|
// src/common/layout.ts
|
|
936
|
-
import
|
|
946
|
+
import * as Schema5 from "effect/Schema";
|
|
937
947
|
|
|
938
948
|
// src/plugin-intent/actions.ts
|
|
939
|
-
import
|
|
949
|
+
import * as Schema4 from "effect/Schema";
|
|
940
950
|
|
|
941
951
|
// src/plugin-intent/intent.ts
|
|
942
|
-
import
|
|
952
|
+
import * as Schema3 from "effect/Schema";
|
|
943
953
|
var createIntent = (schema, data = {}, params = {}) => {
|
|
944
954
|
const _ = Schema3.validateSync(schema.fields.input)(data);
|
|
945
955
|
const intent = {
|
|
@@ -982,11 +992,15 @@ var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.
|
|
|
982
992
|
defaultValue: Schema3.optional(Schema3.String)
|
|
983
993
|
})))));
|
|
984
994
|
|
|
995
|
+
// src/plugin-intent/meta.ts
|
|
996
|
+
var meta = {
|
|
997
|
+
id: "dxos.org/plugin/intent",
|
|
998
|
+
name: "Intent"
|
|
999
|
+
};
|
|
1000
|
+
|
|
985
1001
|
// src/plugin-intent/actions.ts
|
|
986
|
-
var INTENT_PLUGIN = "dxos.org/plugin/intent";
|
|
987
|
-
var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
988
1002
|
(function(IntentAction2) {
|
|
989
|
-
class Track extends Schema4.TaggedClass()(`${
|
|
1003
|
+
class Track extends Schema4.TaggedClass()(`${meta.id}/action/track`, {
|
|
990
1004
|
input: Schema4.Struct({
|
|
991
1005
|
intents: Schema4.Array(Schema4.String),
|
|
992
1006
|
error: Schema4.optional(Schema4.String)
|
|
@@ -995,7 +1009,7 @@ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
|
995
1009
|
}) {
|
|
996
1010
|
}
|
|
997
1011
|
IntentAction2.Track = Track;
|
|
998
|
-
class ShowUndo extends Schema4.TaggedClass()(`${
|
|
1012
|
+
class ShowUndo extends Schema4.TaggedClass()(`${meta.id}/action/show-undo`, {
|
|
999
1013
|
input: Schema4.Struct({
|
|
1000
1014
|
message: Label
|
|
1001
1015
|
}),
|
|
@@ -1006,13 +1020,35 @@ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
|
1006
1020
|
})(IntentAction || (IntentAction = {}));
|
|
1007
1021
|
var IntentAction;
|
|
1008
1022
|
|
|
1023
|
+
// src/plugin-intent/errors.ts
|
|
1024
|
+
var BaseError = class extends Error {
|
|
1025
|
+
code;
|
|
1026
|
+
context;
|
|
1027
|
+
constructor(code, message, context) {
|
|
1028
|
+
super(message ?? code, {
|
|
1029
|
+
cause: context
|
|
1030
|
+
}), this.code = code, this.context = context;
|
|
1031
|
+
this.name = code;
|
|
1032
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
var NoResolversError = class extends BaseError {
|
|
1036
|
+
constructor(action) {
|
|
1037
|
+
super("NO_RESOLVERS", `No resolvers were found for the action: ${action}`, {
|
|
1038
|
+
action
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
var CycleDetectedError = class extends BaseError {
|
|
1043
|
+
constructor(context) {
|
|
1044
|
+
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1009
1048
|
// src/plugin-intent/IntentPlugin.ts
|
|
1010
|
-
var IntentPlugin = () =>
|
|
1011
|
-
id: INTENT_PLUGIN,
|
|
1012
|
-
name: "Intent"
|
|
1013
|
-
}, [
|
|
1049
|
+
var IntentPlugin = definePlugin(meta, () => [
|
|
1014
1050
|
defineModule({
|
|
1015
|
-
id: `${
|
|
1051
|
+
id: `${meta.id}/module/dispatcher`,
|
|
1016
1052
|
// TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
|
|
1017
1053
|
// This is fine for now because it's how it worked prior to capabilities api anyways.
|
|
1018
1054
|
// In the future, the intent dispatcher should be able to be reset without resetting the entire app.
|
|
@@ -1020,15 +1056,14 @@ var IntentPlugin = () => definePlugin({
|
|
|
1020
1056
|
activatesAfter: [
|
|
1021
1057
|
Events.DispatcherReady
|
|
1022
1058
|
],
|
|
1023
|
-
activate: lazy(() => import("./intent-dispatcher-
|
|
1059
|
+
activate: lazy(() => import("./intent-dispatcher-LZ4AE66E.mjs"))
|
|
1024
1060
|
})
|
|
1025
1061
|
]);
|
|
1026
1062
|
|
|
1027
1063
|
// src/common/layout.ts
|
|
1028
1064
|
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
|
|
1029
|
-
var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
|
|
1030
1065
|
(function(LayoutAction2) {
|
|
1031
|
-
LayoutAction2.UPDATE_LAYOUT = `${
|
|
1066
|
+
LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_PLUGIN}/action/update-layout`;
|
|
1032
1067
|
class UpdateLayout extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1033
1068
|
input: Schema5.Struct({
|
|
1034
1069
|
part: Schema5.String.annotations({
|
|
@@ -1365,7 +1400,7 @@ var LayoutAction;
|
|
|
1365
1400
|
var createSurface = (definition) => definition;
|
|
1366
1401
|
|
|
1367
1402
|
// src/common/translations.ts
|
|
1368
|
-
import
|
|
1403
|
+
import * as Schema6 from "effect/Schema";
|
|
1369
1404
|
var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
|
|
1370
1405
|
key: Schema6.String,
|
|
1371
1406
|
value: Schema6.Any
|
|
@@ -1379,31 +1414,6 @@ var Resource = Schema6.Record({
|
|
|
1379
1414
|
value: ResourceLanguage
|
|
1380
1415
|
});
|
|
1381
1416
|
|
|
1382
|
-
// src/plugin-intent/errors.ts
|
|
1383
|
-
var BaseError = class extends Error {
|
|
1384
|
-
code;
|
|
1385
|
-
context;
|
|
1386
|
-
constructor(code, message, context) {
|
|
1387
|
-
super(message ?? code, {
|
|
1388
|
-
cause: context
|
|
1389
|
-
}), this.code = code, this.context = context;
|
|
1390
|
-
this.name = code;
|
|
1391
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
1392
|
-
}
|
|
1393
|
-
};
|
|
1394
|
-
var NoResolversError = class extends BaseError {
|
|
1395
|
-
constructor(action) {
|
|
1396
|
-
super("NO_RESOLVERS", "No resolvers were found for the action", {
|
|
1397
|
-
action
|
|
1398
|
-
});
|
|
1399
|
-
}
|
|
1400
|
-
};
|
|
1401
|
-
var CycleDetectedError = class extends BaseError {
|
|
1402
|
-
constructor(context) {
|
|
1403
|
-
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
1404
|
-
}
|
|
1405
|
-
};
|
|
1406
|
-
|
|
1407
1417
|
// src/plugin-intent/intent-dispatcher.ts
|
|
1408
1418
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts";
|
|
1409
1419
|
var EXECUTION_LIMIT = 100;
|
|
@@ -1411,11 +1421,11 @@ var HISTORY_LIMIT = 100;
|
|
|
1411
1421
|
var createResolver = (resolver) => resolver;
|
|
1412
1422
|
var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
|
|
1413
1423
|
var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
|
|
1414
|
-
const historyRef = Effect3.runSync(
|
|
1424
|
+
const historyRef = Effect3.runSync(Ref2.make([]));
|
|
1415
1425
|
const handleIntent = (intent) => Effect3.gen(function* () {
|
|
1416
1426
|
const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
|
|
1417
1427
|
if (candidates.length === 0) {
|
|
1418
|
-
yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1428
|
+
return yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1419
1429
|
}
|
|
1420
1430
|
const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
1421
1431
|
const result = Effect3.isEffect(effect) ? yield* effect : yield* Effect3.promise(async () => effect);
|
|
@@ -1425,12 +1435,29 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1425
1435
|
};
|
|
1426
1436
|
});
|
|
1427
1437
|
const dispatch = (intentChain, depth = 0) => {
|
|
1438
|
+
log3("dispatch", {
|
|
1439
|
+
intentChain: intentChain.all.map((i) => i.id),
|
|
1440
|
+
depth
|
|
1441
|
+
}, {
|
|
1442
|
+
F: __dxlog_file3,
|
|
1443
|
+
L: 212,
|
|
1444
|
+
S: void 0,
|
|
1445
|
+
C: (f, a) => f(...a)
|
|
1446
|
+
});
|
|
1428
1447
|
return Effect3.gen(function* () {
|
|
1429
1448
|
if (depth > executionLimit) {
|
|
1430
|
-
yield* Effect3.fail(new CycleDetectedError());
|
|
1449
|
+
return yield* Effect3.fail(new CycleDetectedError());
|
|
1431
1450
|
}
|
|
1432
|
-
const resultsRef = yield*
|
|
1451
|
+
const resultsRef = yield* Ref2.make([]);
|
|
1433
1452
|
for (const intent of intentChain.all) {
|
|
1453
|
+
log3("processing", {
|
|
1454
|
+
intent
|
|
1455
|
+
}, {
|
|
1456
|
+
F: __dxlog_file3,
|
|
1457
|
+
L: 220,
|
|
1458
|
+
S: this,
|
|
1459
|
+
C: (f, a) => f(...a)
|
|
1460
|
+
});
|
|
1434
1461
|
const { data: prev } = (yield* resultsRef.get)[0] ?? {};
|
|
1435
1462
|
const result2 = yield* handleIntent({
|
|
1436
1463
|
...intent,
|
|
@@ -1439,7 +1466,16 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1439
1466
|
...prev
|
|
1440
1467
|
}
|
|
1441
1468
|
});
|
|
1442
|
-
|
|
1469
|
+
log3("ok", {
|
|
1470
|
+
intent: intent.id,
|
|
1471
|
+
result: result2
|
|
1472
|
+
}, {
|
|
1473
|
+
F: __dxlog_file3,
|
|
1474
|
+
L: 223,
|
|
1475
|
+
S: this,
|
|
1476
|
+
C: (f, a) => f(...a)
|
|
1477
|
+
});
|
|
1478
|
+
yield* Ref2.update(resultsRef, (results2) => [
|
|
1443
1479
|
result2,
|
|
1444
1480
|
...results2
|
|
1445
1481
|
]);
|
|
@@ -1449,12 +1485,21 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1449
1485
|
}
|
|
1450
1486
|
}
|
|
1451
1487
|
if (result2.error) {
|
|
1452
|
-
|
|
1488
|
+
log3.error("failed", {
|
|
1489
|
+
intent: intent.id,
|
|
1490
|
+
error: result2.error
|
|
1491
|
+
}, {
|
|
1492
|
+
F: __dxlog_file3,
|
|
1493
|
+
L: 240,
|
|
1494
|
+
S: this,
|
|
1495
|
+
C: (f, a) => f(...a)
|
|
1496
|
+
});
|
|
1497
|
+
return yield* Effect3.fail(result2.error);
|
|
1453
1498
|
}
|
|
1454
1499
|
}
|
|
1455
1500
|
const results = yield* resultsRef.get;
|
|
1456
1501
|
const result = results[0];
|
|
1457
|
-
yield*
|
|
1502
|
+
yield* Ref2.update(historyRef, (history) => {
|
|
1458
1503
|
const next = [
|
|
1459
1504
|
...history,
|
|
1460
1505
|
results
|
|
@@ -1465,10 +1510,19 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1465
1510
|
return next;
|
|
1466
1511
|
});
|
|
1467
1512
|
if (result.undoable && isUndoable(results)) {
|
|
1468
|
-
yield*
|
|
1513
|
+
yield* Function2.pipe(dispatch(createIntent(IntentAction.ShowUndo, {
|
|
1469
1514
|
message: result.undoable.message
|
|
1470
1515
|
})), Effect3.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect3.succeed(void 0)) : Option.none()));
|
|
1471
1516
|
}
|
|
1517
|
+
log3("done", {
|
|
1518
|
+
intent: intentChain.all.map((i) => i.id),
|
|
1519
|
+
result: result.data
|
|
1520
|
+
}, {
|
|
1521
|
+
F: __dxlog_file3,
|
|
1522
|
+
L: 270,
|
|
1523
|
+
S: this,
|
|
1524
|
+
C: (f, a) => f(...a)
|
|
1525
|
+
});
|
|
1472
1526
|
return result.data;
|
|
1473
1527
|
});
|
|
1474
1528
|
};
|
|
@@ -1478,7 +1532,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1478
1532
|
})).catch((error) => {
|
|
1479
1533
|
log3.catch(error, void 0, {
|
|
1480
1534
|
F: __dxlog_file3,
|
|
1481
|
-
L:
|
|
1535
|
+
L: 279,
|
|
1482
1536
|
S: void 0,
|
|
1483
1537
|
C: (f, a) => f(...a)
|
|
1484
1538
|
});
|
|
@@ -1493,7 +1547,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1493
1547
|
const last = history.findLastIndex(isUndoable);
|
|
1494
1548
|
const result = last !== -1 ? history[last] : void 0;
|
|
1495
1549
|
if (result) {
|
|
1496
|
-
const
|
|
1550
|
+
const all2 = result.map(({ _intent, undoable }) => {
|
|
1497
1551
|
const data = _intent.data;
|
|
1498
1552
|
const undoData = undoable?.data ?? {};
|
|
1499
1553
|
return {
|
|
@@ -1506,11 +1560,11 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1506
1560
|
};
|
|
1507
1561
|
});
|
|
1508
1562
|
const intent = {
|
|
1509
|
-
first:
|
|
1510
|
-
last:
|
|
1511
|
-
all
|
|
1563
|
+
first: all2[0],
|
|
1564
|
+
last: all2.at(-1),
|
|
1565
|
+
all: all2
|
|
1512
1566
|
};
|
|
1513
|
-
yield*
|
|
1567
|
+
yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
|
|
1514
1568
|
return yield* dispatch(intent);
|
|
1515
1569
|
}
|
|
1516
1570
|
});
|
|
@@ -1531,7 +1585,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1531
1585
|
};
|
|
1532
1586
|
var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
|
|
1533
1587
|
var defaultPromise = () => Effect3.runPromise(defaultEffect());
|
|
1534
|
-
var intent_dispatcher_default = (context) => {
|
|
1588
|
+
var intent_dispatcher_default = ((context) => {
|
|
1535
1589
|
const state = live2({
|
|
1536
1590
|
dispatch: defaultEffect,
|
|
1537
1591
|
dispatchPromise: defaultPromise,
|
|
@@ -1553,7 +1607,7 @@ var intent_dispatcher_default = (context) => {
|
|
|
1553
1607
|
state.undo = undo;
|
|
1554
1608
|
state.undoPromise = undoPromise;
|
|
1555
1609
|
return contributes(Capabilities.IntentDispatcher, state);
|
|
1556
|
-
};
|
|
1610
|
+
});
|
|
1557
1611
|
|
|
1558
1612
|
export {
|
|
1559
1613
|
defineCapability,
|
|
@@ -1580,19 +1634,18 @@ export {
|
|
|
1580
1634
|
createIntent,
|
|
1581
1635
|
chain,
|
|
1582
1636
|
Label,
|
|
1583
|
-
INTENT_PLUGIN,
|
|
1584
|
-
INTENT_ACTION,
|
|
1585
1637
|
IntentAction,
|
|
1638
|
+
BaseError,
|
|
1639
|
+
NoResolversError,
|
|
1640
|
+
CycleDetectedError,
|
|
1586
1641
|
createResolver,
|
|
1587
1642
|
createDispatcher,
|
|
1588
1643
|
intent_dispatcher_default,
|
|
1589
1644
|
IntentPlugin,
|
|
1590
|
-
LAYOUT_PLUGIN,
|
|
1591
|
-
LAYOUT_ACTION,
|
|
1592
1645
|
LayoutAction,
|
|
1593
1646
|
createSurface,
|
|
1594
1647
|
ResourceKey,
|
|
1595
1648
|
ResourceLanguage,
|
|
1596
1649
|
Resource
|
|
1597
1650
|
};
|
|
1598
|
-
//# sourceMappingURL=chunk-
|
|
1651
|
+
//# sourceMappingURL=chunk-WPW5VVAX.mjs.map
|