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