@dxos/app-framework 0.8.4-main.dedc0f3 → 0.8.4-main.e8ec1fe
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/dist/lib/browser/{app-graph-builder-AFFC6VB2.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-ORWHM7CO.mjs → chunk-SCPE4ZO2.mjs} +11 -8
- package/dist/lib/browser/chunk-SCPE4ZO2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-T6M7JB7M.mjs → chunk-VFUKEZIN.mjs} +121 -109
- package/dist/lib/browser/chunk-VFUKEZIN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OZY7HV2A.mjs → chunk-WPW5VVAX.mjs} +281 -273
- package/dist/lib/browser/chunk-WPW5VVAX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +14 -56
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-dispatcher-QG7UPGQX.mjs → intent-dispatcher-LZ4AE66E.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-4S4PSTM5.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-6E33KLGK.mjs → store-CNPHOYTJ.mjs} +5 -5
- package/dist/lib/browser/store-CNPHOYTJ.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +14 -16
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{app-graph-builder-S4OAULX5.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-HJFU7QOR.mjs → chunk-IJOHO66N.mjs} +121 -109
- package/dist/lib/node-esm/chunk-IJOHO66N.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-F63ZRXMK.mjs → chunk-XJZGUJ3H.mjs} +281 -273
- 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 +14 -56
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-dispatcher-NXBGPJOX.mjs → intent-dispatcher-MGOJ3CHD.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-2ZKXI5ET.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-QQUTQHHT.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 +14 -16
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/common/capabilities.d.ts +41 -37
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/collaboration.d.ts +1 -1
- 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 +15 -15
- 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/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.map +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/plugin.d.ts +1 -1
- package/dist/types/src/playground/layout/plugin.d.ts.map +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 +0 -1
- 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/intent-dispatcher.d.ts +4 -4
- 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.map +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/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.map +1 -0
- package/dist/types/src/{components → react}/App.stories.d.ts +0 -1
- package/dist/types/src/react/App.stories.d.ts.map +1 -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 +3 -7
- 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/{components → react}/useApp.d.ts +2 -2
- package/dist/types/src/react/useApp.d.ts.map +1 -0
- package/dist/types/src/react/useLoading.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +6 -7
- package/dist/types/src/testing/withPluginManager.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 +34 -19
- package/src/common/collaboration.ts +3 -3
- 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 +26 -22
- 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/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 +6 -7
- 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/intent-dispatcher.test.ts +10 -3
- package/src/plugin-intent/intent-dispatcher.ts +13 -6
- 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/{components → react}/App.stories.tsx +1 -3
- package/src/{components → react}/App.tsx +1 -1
- package/src/{components → react}/DefaultFallback.tsx +1 -1
- package/src/react/ErrorBoundary.tsx +10 -8
- package/src/react/Surface.stories.tsx +70 -49
- package/src/react/Surface.tsx +67 -36
- package/src/react/index.ts +4 -0
- package/src/react/types.ts +37 -0
- package/src/{components → react}/useApp.tsx +23 -24
- package/src/react/useCapabilities.ts +2 -2
- package/src/testing/withPluginManager.stories.tsx +1 -1
- package/src/testing/withPluginManager.tsx +22 -21
- package/tsconfig.json +10 -1
- package/vitest.config.ts +8 -6
- package/dist/lib/browser/app-graph-builder-AFFC6VB2.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORWHM7CO.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZY7HV2A.mjs.map +0 -7
- package/dist/lib/browser/chunk-T6M7JB7M.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-4S4PSTM5.mjs.map +0 -7
- package/dist/lib/browser/store-6E33KLGK.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -85
- package/dist/lib/node-esm/app-graph-builder-S4OAULX5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F63ZRXMK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HJFU7QOR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UMZQERLE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-2ZKXI5ET.mjs.map +0 -7
- package/dist/lib/node-esm/store-QQUTQHHT.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -86
- package/dist/types/src/components/App.d.ts.map +0 -1
- package/dist/types/src/components/App.stories.d.ts.map +0 -1
- package/dist/types/src/components/DefaultFallback.d.ts.map +0 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +0 -1
- package/dist/types/src/components/useApp.d.ts.map +0 -1
- package/dist/types/src/components/useLoading.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/components/index.ts +0 -5
- package/src/worker.ts +0 -11
- /package/dist/lib/browser/{intent-dispatcher-QG7UPGQX.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-NXBGPJOX.mjs.map → intent-dispatcher-MGOJ3CHD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{worker.mjs.map → react/index.mjs.map} +0 -0
- /package/dist/types/src/{components → react}/App.d.ts +0 -0
- /package/dist/types/src/{components → react}/DefaultFallback.d.ts +0 -0
- /package/dist/types/src/{components → react}/useLoading.d.ts +0 -0
- /package/src/{components → react}/useLoading.tsx +0 -0
|
@@ -1,28 +1,18 @@
|
|
|
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";
|
|
13
|
-
function _define_property(obj, key, value) {
|
|
14
|
-
if (key in obj) {
|
|
15
|
-
Object.defineProperty(obj, key, {
|
|
16
|
-
value,
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true
|
|
20
|
-
});
|
|
21
|
-
} else {
|
|
22
|
-
obj[key] = value;
|
|
23
|
-
}
|
|
24
|
-
return obj;
|
|
25
|
-
}
|
|
26
16
|
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
|
|
27
17
|
var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
|
|
28
18
|
var defineCapability = (identifier) => {
|
|
@@ -31,9 +21,9 @@ var defineCapability = (identifier) => {
|
|
|
31
21
|
};
|
|
32
22
|
};
|
|
33
23
|
var CapabilityImpl = class {
|
|
24
|
+
moduleId;
|
|
25
|
+
implementation;
|
|
34
26
|
constructor(moduleId, implementation) {
|
|
35
|
-
_define_property(this, "moduleId", void 0);
|
|
36
|
-
_define_property(this, "implementation", void 0);
|
|
37
27
|
this.moduleId = moduleId;
|
|
38
28
|
this.implementation = implementation;
|
|
39
29
|
}
|
|
@@ -50,6 +40,48 @@ var lazy = (c) => async (props) => {
|
|
|
50
40
|
return async () => getCapability(props);
|
|
51
41
|
};
|
|
52
42
|
var PluginContext = class {
|
|
43
|
+
_registry;
|
|
44
|
+
_capabilityImpls = Atom.family(() => {
|
|
45
|
+
return Atom.make([]).pipe(Atom.keepAlive);
|
|
46
|
+
});
|
|
47
|
+
_capabilities = Atom.family((id) => {
|
|
48
|
+
return Atom.make((get) => {
|
|
49
|
+
const current = get(this._capabilityImpls(id));
|
|
50
|
+
return current.map((c) => c.implementation);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
_capability = Atom.family((id) => {
|
|
54
|
+
return Atom.make((get) => {
|
|
55
|
+
const current = get(this._capabilities(id));
|
|
56
|
+
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
57
|
+
F: __dxlog_file,
|
|
58
|
+
L: 126,
|
|
59
|
+
S: this,
|
|
60
|
+
A: [
|
|
61
|
+
"current.length > 0",
|
|
62
|
+
"`No capability found for ${id}`"
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
return current[0];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Activates plugins based on the activation event.
|
|
70
|
+
* @param event The activation event.
|
|
71
|
+
* @returns Whether the activation was successful.
|
|
72
|
+
*/
|
|
73
|
+
activate;
|
|
74
|
+
/**
|
|
75
|
+
* Re-activates the modules that were activated by the event.
|
|
76
|
+
* @param event The activation event.
|
|
77
|
+
* @returns Whether the reset was successful.
|
|
78
|
+
*/
|
|
79
|
+
reset;
|
|
80
|
+
constructor({ registry, activate, reset }) {
|
|
81
|
+
this._registry = registry;
|
|
82
|
+
this.activate = activate;
|
|
83
|
+
this.reset = reset;
|
|
84
|
+
}
|
|
53
85
|
/**
|
|
54
86
|
* @internal
|
|
55
87
|
*/
|
|
@@ -69,7 +101,7 @@ var PluginContext = class {
|
|
|
69
101
|
count: current.length
|
|
70
102
|
}, {
|
|
71
103
|
F: __dxlog_file,
|
|
72
|
-
L:
|
|
104
|
+
L: 170,
|
|
73
105
|
S: this,
|
|
74
106
|
C: (f, a) => f(...a)
|
|
75
107
|
});
|
|
@@ -90,7 +122,7 @@ var PluginContext = class {
|
|
|
90
122
|
count: current.length
|
|
91
123
|
}, {
|
|
92
124
|
F: __dxlog_file,
|
|
93
|
-
L:
|
|
125
|
+
L: 189,
|
|
94
126
|
S: this,
|
|
95
127
|
C: (f, a) => f(...a)
|
|
96
128
|
});
|
|
@@ -99,26 +131,26 @@ var PluginContext = class {
|
|
|
99
131
|
id: interfaceDef.identifier
|
|
100
132
|
}, {
|
|
101
133
|
F: __dxlog_file,
|
|
102
|
-
L:
|
|
134
|
+
L: 191,
|
|
103
135
|
S: this,
|
|
104
136
|
C: (f, a) => f(...a)
|
|
105
137
|
});
|
|
106
138
|
}
|
|
107
139
|
}
|
|
108
140
|
/**
|
|
109
|
-
* Get the
|
|
110
|
-
* 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
|
|
111
143
|
* for subscribing to changes in the capabilities.
|
|
112
|
-
* @returns An
|
|
144
|
+
* @returns An atom reference to the available capabilities.
|
|
113
145
|
*/
|
|
114
146
|
capabilities(interfaceDef) {
|
|
115
147
|
return this._capabilities(interfaceDef.identifier);
|
|
116
148
|
}
|
|
117
149
|
/**
|
|
118
|
-
* Get the
|
|
119
|
-
* 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
|
|
120
152
|
* for subscribing to changes in the capability.
|
|
121
|
-
* @returns An
|
|
153
|
+
* @returns An atom reference to the available capability.
|
|
122
154
|
* @throws If no capability is found.
|
|
123
155
|
*/
|
|
124
156
|
capability(interfaceDef) {
|
|
@@ -164,38 +196,6 @@ var PluginContext = class {
|
|
|
164
196
|
async resetPromise(event) {
|
|
165
197
|
return this.reset(event).pipe(Effect.runPromise);
|
|
166
198
|
}
|
|
167
|
-
constructor({ registry, activate, reset }) {
|
|
168
|
-
_define_property(this, "_registry", void 0);
|
|
169
|
-
_define_property(this, "_capabilityImpls", Rx.family(() => {
|
|
170
|
-
return Rx.make([]).pipe(Rx.keepAlive);
|
|
171
|
-
}));
|
|
172
|
-
_define_property(this, "_capabilities", Rx.family((id) => {
|
|
173
|
-
return Rx.make((get) => {
|
|
174
|
-
const current = get(this._capabilityImpls(id));
|
|
175
|
-
return current.map((c) => c.implementation);
|
|
176
|
-
});
|
|
177
|
-
}));
|
|
178
|
-
_define_property(this, "_capability", Rx.family((id) => {
|
|
179
|
-
return Rx.make((get) => {
|
|
180
|
-
const current = get(this._capabilities(id));
|
|
181
|
-
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
182
|
-
F: __dxlog_file,
|
|
183
|
-
L: 122,
|
|
184
|
-
S: this,
|
|
185
|
-
A: [
|
|
186
|
-
"current.length > 0",
|
|
187
|
-
"`No capability found for ${id}`"
|
|
188
|
-
]
|
|
189
|
-
});
|
|
190
|
-
return current[0];
|
|
191
|
-
});
|
|
192
|
-
}));
|
|
193
|
-
_define_property(this, "activate", void 0);
|
|
194
|
-
_define_property(this, "reset", void 0);
|
|
195
|
-
this._registry = registry;
|
|
196
|
-
this.activate = activate;
|
|
197
|
-
this.reset = reset;
|
|
198
|
-
}
|
|
199
199
|
};
|
|
200
200
|
|
|
201
201
|
// src/core/events.ts
|
|
@@ -221,30 +221,55 @@ var getEvents = (events) => "type" in events ? events.events : [
|
|
|
221
221
|
];
|
|
222
222
|
|
|
223
223
|
// src/core/manager.ts
|
|
224
|
-
import { Registry } from "@effect-
|
|
224
|
+
import { Registry } from "@effect-atom/atom-react";
|
|
225
225
|
import { untracked } from "@preact/signals-core";
|
|
226
|
-
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";
|
|
227
234
|
import { Event } from "@dxos/async";
|
|
228
235
|
import { live } from "@dxos/live-object";
|
|
229
236
|
import { log as log2 } from "@dxos/log";
|
|
230
|
-
function _define_property2(obj, key, value) {
|
|
231
|
-
if (key in obj) {
|
|
232
|
-
Object.defineProperty(obj, key, {
|
|
233
|
-
value,
|
|
234
|
-
enumerable: true,
|
|
235
|
-
configurable: true,
|
|
236
|
-
writable: true
|
|
237
|
-
});
|
|
238
|
-
} else {
|
|
239
|
-
obj[key] = value;
|
|
240
|
-
}
|
|
241
|
-
return obj;
|
|
242
|
-
}
|
|
243
237
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
|
|
244
|
-
var isPromise = (
|
|
245
|
-
return
|
|
238
|
+
var isPromise = (value2) => {
|
|
239
|
+
return value2 !== null && typeof value2 === "object" && "then" in value2;
|
|
246
240
|
};
|
|
247
241
|
var PluginManager = class {
|
|
242
|
+
activation = new Event();
|
|
243
|
+
context;
|
|
244
|
+
registry;
|
|
245
|
+
// TODO(wittjosiah): Replace with Atom.
|
|
246
|
+
_state;
|
|
247
|
+
_pluginLoader;
|
|
248
|
+
_capabilities = /* @__PURE__ */ new Map();
|
|
249
|
+
_moduleMemoMap = /* @__PURE__ */ new Map();
|
|
250
|
+
_activatingEvents = Effect2.runSync(Ref.make([]));
|
|
251
|
+
_activatingModules = Effect2.runSync(Ref.make([]));
|
|
252
|
+
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.id), enabled = [], registry }) {
|
|
253
|
+
this.registry = registry ?? Registry.make();
|
|
254
|
+
this.context = new PluginContext({
|
|
255
|
+
registry: this.registry,
|
|
256
|
+
activate: (event) => this._activate(event),
|
|
257
|
+
reset: (id) => this._reset(id)
|
|
258
|
+
});
|
|
259
|
+
this._pluginLoader = pluginLoader;
|
|
260
|
+
this._state = live({
|
|
261
|
+
plugins,
|
|
262
|
+
core,
|
|
263
|
+
enabled,
|
|
264
|
+
modules: [],
|
|
265
|
+
active: [],
|
|
266
|
+
eventsFired: [],
|
|
267
|
+
pendingReset: []
|
|
268
|
+
});
|
|
269
|
+
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
270
|
+
core.forEach((id) => this.enable(id));
|
|
271
|
+
enabled.forEach((id) => this.enable(id));
|
|
272
|
+
}
|
|
248
273
|
/**
|
|
249
274
|
* Plugins that are currently registered.
|
|
250
275
|
*
|
|
@@ -311,7 +336,7 @@ var PluginManager = class {
|
|
|
311
336
|
id
|
|
312
337
|
}, {
|
|
313
338
|
F: __dxlog_file2,
|
|
314
|
-
L:
|
|
339
|
+
L: 164,
|
|
315
340
|
S: this,
|
|
316
341
|
C: (f, a) => f(...a)
|
|
317
342
|
});
|
|
@@ -330,7 +355,7 @@ var PluginManager = class {
|
|
|
330
355
|
id
|
|
331
356
|
}, {
|
|
332
357
|
F: __dxlog_file2,
|
|
333
|
-
L:
|
|
358
|
+
L: 177,
|
|
334
359
|
S: this,
|
|
335
360
|
C: (f, a) => f(...a)
|
|
336
361
|
});
|
|
@@ -351,7 +376,7 @@ var PluginManager = class {
|
|
|
351
376
|
]
|
|
352
377
|
}, {
|
|
353
378
|
F: __dxlog_file2,
|
|
354
|
-
L:
|
|
379
|
+
L: 192,
|
|
355
380
|
S: this,
|
|
356
381
|
C: (f, a) => f(...a)
|
|
357
382
|
});
|
|
@@ -371,7 +396,7 @@ var PluginManager = class {
|
|
|
371
396
|
id
|
|
372
397
|
}, {
|
|
373
398
|
F: __dxlog_file2,
|
|
374
|
-
L:
|
|
399
|
+
L: 210,
|
|
375
400
|
S: this,
|
|
376
401
|
C: (f, a) => f(...a)
|
|
377
402
|
});
|
|
@@ -393,7 +418,7 @@ var PluginManager = class {
|
|
|
393
418
|
id
|
|
394
419
|
}, {
|
|
395
420
|
F: __dxlog_file2,
|
|
396
|
-
L:
|
|
421
|
+
L: 227,
|
|
397
422
|
S: this,
|
|
398
423
|
C: (f, a) => f(...a)
|
|
399
424
|
});
|
|
@@ -445,7 +470,7 @@ var PluginManager = class {
|
|
|
445
470
|
id: plugin.meta.id
|
|
446
471
|
}, {
|
|
447
472
|
F: __dxlog_file2,
|
|
448
|
-
L:
|
|
473
|
+
L: 280,
|
|
449
474
|
S: this,
|
|
450
475
|
C: (f, a) => f(...a)
|
|
451
476
|
});
|
|
@@ -460,7 +485,7 @@ var PluginManager = class {
|
|
|
460
485
|
id
|
|
461
486
|
}, {
|
|
462
487
|
F: __dxlog_file2,
|
|
463
|
-
L:
|
|
488
|
+
L: 290,
|
|
464
489
|
S: this,
|
|
465
490
|
C: (f, a) => f(...a)
|
|
466
491
|
});
|
|
@@ -476,7 +501,7 @@ var PluginManager = class {
|
|
|
476
501
|
id: module.id
|
|
477
502
|
}, {
|
|
478
503
|
F: __dxlog_file2,
|
|
479
|
-
L:
|
|
504
|
+
L: 300,
|
|
480
505
|
S: this,
|
|
481
506
|
C: (f, a) => f(...a)
|
|
482
507
|
});
|
|
@@ -491,7 +516,7 @@ var PluginManager = class {
|
|
|
491
516
|
id
|
|
492
517
|
}, {
|
|
493
518
|
F: __dxlog_file2,
|
|
494
|
-
L:
|
|
519
|
+
L: 310,
|
|
495
520
|
S: this,
|
|
496
521
|
C: (f, a) => f(...a)
|
|
497
522
|
});
|
|
@@ -525,7 +550,7 @@ var PluginManager = class {
|
|
|
525
550
|
events: pendingReset
|
|
526
551
|
}, {
|
|
527
552
|
F: __dxlog_file2,
|
|
528
|
-
L:
|
|
553
|
+
L: 348,
|
|
529
554
|
S: this,
|
|
530
555
|
C: (f, a) => f(...a)
|
|
531
556
|
});
|
|
@@ -545,7 +570,7 @@ var PluginManager = class {
|
|
|
545
570
|
...params
|
|
546
571
|
}, {
|
|
547
572
|
F: __dxlog_file2,
|
|
548
|
-
L:
|
|
573
|
+
L: 364,
|
|
549
574
|
S: this,
|
|
550
575
|
C: (f, a) => f(...a)
|
|
551
576
|
});
|
|
@@ -570,7 +595,7 @@ var PluginManager = class {
|
|
|
570
595
|
key
|
|
571
596
|
}, {
|
|
572
597
|
F: __dxlog_file2,
|
|
573
|
-
L:
|
|
598
|
+
L: 395,
|
|
574
599
|
S: this,
|
|
575
600
|
C: (f, a) => f(...a)
|
|
576
601
|
});
|
|
@@ -584,7 +609,7 @@ var PluginManager = class {
|
|
|
584
609
|
modules: modules.map((module) => module.id)
|
|
585
610
|
}, {
|
|
586
611
|
F: __dxlog_file2,
|
|
587
|
-
L:
|
|
612
|
+
L: 402,
|
|
588
613
|
S: this,
|
|
589
614
|
C: (f, a) => f(...a)
|
|
590
615
|
});
|
|
@@ -592,12 +617,12 @@ var PluginManager = class {
|
|
|
592
617
|
event: key,
|
|
593
618
|
state: "activating"
|
|
594
619
|
});
|
|
595
|
-
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, {
|
|
596
621
|
before: key
|
|
597
622
|
})), Effect2.allWith({
|
|
598
623
|
concurrency: "unbounded"
|
|
599
624
|
}));
|
|
600
|
-
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({
|
|
601
626
|
concurrency: "unbounded"
|
|
602
627
|
}), Effect2.catchAll((error) => {
|
|
603
628
|
this.activation.emit({
|
|
@@ -607,15 +632,13 @@ var PluginManager = class {
|
|
|
607
632
|
});
|
|
608
633
|
return Effect2.fail(error);
|
|
609
634
|
}));
|
|
610
|
-
yield* pipe(
|
|
635
|
+
yield* Function.pipe(
|
|
611
636
|
modules,
|
|
612
637
|
Array.zip(getCapabilities),
|
|
613
638
|
Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
|
|
614
|
-
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
615
|
-
// Running this with concurrency causes races with `allOf` activation events.
|
|
616
639
|
Effect2.all
|
|
617
640
|
);
|
|
618
|
-
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, {
|
|
619
642
|
after: key
|
|
620
643
|
})), Effect2.allWith({
|
|
621
644
|
concurrency: "unbounded"
|
|
@@ -633,13 +656,74 @@ var PluginManager = class {
|
|
|
633
656
|
key
|
|
634
657
|
}, {
|
|
635
658
|
F: __dxlog_file2,
|
|
636
|
-
L:
|
|
659
|
+
L: 458,
|
|
637
660
|
S: this,
|
|
638
661
|
C: (f, a) => f(...a)
|
|
639
662
|
});
|
|
640
663
|
return true;
|
|
641
664
|
});
|
|
642
665
|
}
|
|
666
|
+
// Memoized with _moduleMemoMap
|
|
667
|
+
_loadModule = (mod) => Effect2.tryPromise({
|
|
668
|
+
try: async () => {
|
|
669
|
+
const entry = this._moduleMemoMap.get(mod.id);
|
|
670
|
+
if (entry) {
|
|
671
|
+
return entry;
|
|
672
|
+
}
|
|
673
|
+
const promise2 = (async () => {
|
|
674
|
+
const start = performance.now();
|
|
675
|
+
let failed = false;
|
|
676
|
+
try {
|
|
677
|
+
log2("loading module", {
|
|
678
|
+
module: mod.id
|
|
679
|
+
}, {
|
|
680
|
+
F: __dxlog_file2,
|
|
681
|
+
L: 477,
|
|
682
|
+
S: this,
|
|
683
|
+
C: (f, a) => f(...a)
|
|
684
|
+
});
|
|
685
|
+
let activationResult = await mod.activate(this.context);
|
|
686
|
+
if (typeof activationResult === "function") {
|
|
687
|
+
activationResult = await activationResult();
|
|
688
|
+
}
|
|
689
|
+
return Array.isArray(activationResult) ? activationResult : [
|
|
690
|
+
activationResult
|
|
691
|
+
];
|
|
692
|
+
} catch (error) {
|
|
693
|
+
failed = true;
|
|
694
|
+
throw error;
|
|
695
|
+
} finally {
|
|
696
|
+
performance.measure("activate-module", {
|
|
697
|
+
start,
|
|
698
|
+
end: performance.now(),
|
|
699
|
+
detail: {
|
|
700
|
+
module: mod.id
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
log2("loaded module", {
|
|
704
|
+
module: mod.id,
|
|
705
|
+
elapsed: performance.now() - start,
|
|
706
|
+
failed
|
|
707
|
+
}, {
|
|
708
|
+
F: __dxlog_file2,
|
|
709
|
+
L: 495,
|
|
710
|
+
S: this,
|
|
711
|
+
C: (f, a) => f(...a)
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
})();
|
|
715
|
+
this._moduleMemoMap.set(mod.id, promise2);
|
|
716
|
+
return promise2;
|
|
717
|
+
},
|
|
718
|
+
catch: (error) => error
|
|
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`, {
|
|
720
|
+
module: mod.id
|
|
721
|
+
}, {
|
|
722
|
+
F: __dxlog_file2,
|
|
723
|
+
L: 506,
|
|
724
|
+
S: this,
|
|
725
|
+
C: (f, a) => f(...a)
|
|
726
|
+
}))))));
|
|
643
727
|
_contributeCapabilities(module, capabilities) {
|
|
644
728
|
return Effect2.gen(this, function* () {
|
|
645
729
|
capabilities.forEach((capability) => {
|
|
@@ -672,7 +756,7 @@ var PluginManager = class {
|
|
|
672
756
|
id
|
|
673
757
|
}, {
|
|
674
758
|
F: __dxlog_file2,
|
|
675
|
-
L:
|
|
759
|
+
L: 540,
|
|
676
760
|
S: this,
|
|
677
761
|
C: (f, a) => f(...a)
|
|
678
762
|
});
|
|
@@ -682,8 +766,8 @@ var PluginManager = class {
|
|
|
682
766
|
for (const capability of capabilities) {
|
|
683
767
|
this.context.removeCapability(capability.interface, capability.implementation);
|
|
684
768
|
const program = capability.deactivate?.();
|
|
685
|
-
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (
|
|
686
|
-
try: () =>
|
|
769
|
+
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise2) => Effect2.tryPromise({
|
|
770
|
+
try: () => promise2,
|
|
687
771
|
catch: (error) => error
|
|
688
772
|
})), Match.orElse((program2) => Effect2.succeed(program2)));
|
|
689
773
|
}
|
|
@@ -697,7 +781,7 @@ var PluginManager = class {
|
|
|
697
781
|
id
|
|
698
782
|
}, {
|
|
699
783
|
F: __dxlog_file2,
|
|
700
|
-
L:
|
|
784
|
+
L: 567,
|
|
701
785
|
S: this,
|
|
702
786
|
C: (f, a) => f(...a)
|
|
703
787
|
});
|
|
@@ -711,7 +795,7 @@ var PluginManager = class {
|
|
|
711
795
|
key
|
|
712
796
|
}, {
|
|
713
797
|
F: __dxlog_file2,
|
|
714
|
-
L:
|
|
798
|
+
L: 575,
|
|
715
799
|
S: this,
|
|
716
800
|
C: (f, a) => f(...a)
|
|
717
801
|
});
|
|
@@ -726,96 +810,6 @@ var PluginManager = class {
|
|
|
726
810
|
}
|
|
727
811
|
});
|
|
728
812
|
}
|
|
729
|
-
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry }) {
|
|
730
|
-
_define_property2(this, "activation", new Event());
|
|
731
|
-
_define_property2(this, "context", void 0);
|
|
732
|
-
_define_property2(this, "registry", void 0);
|
|
733
|
-
_define_property2(this, "_state", void 0);
|
|
734
|
-
_define_property2(this, "_pluginLoader", void 0);
|
|
735
|
-
_define_property2(this, "_capabilities", /* @__PURE__ */ new Map());
|
|
736
|
-
_define_property2(this, "_moduleMemoMap", /* @__PURE__ */ new Map());
|
|
737
|
-
_define_property2(this, "_activatingEvents", Effect2.runSync(Ref.make([])));
|
|
738
|
-
_define_property2(this, "_activatingModules", Effect2.runSync(Ref.make([])));
|
|
739
|
-
_define_property2(this, "_loadModule", (mod) => Effect2.tryPromise({
|
|
740
|
-
try: async () => {
|
|
741
|
-
const entry = this._moduleMemoMap.get(mod.id);
|
|
742
|
-
if (entry) {
|
|
743
|
-
return entry;
|
|
744
|
-
}
|
|
745
|
-
const promise = (async () => {
|
|
746
|
-
const start = performance.now();
|
|
747
|
-
let failed = false;
|
|
748
|
-
try {
|
|
749
|
-
log2("loading module", {
|
|
750
|
-
module: mod.id
|
|
751
|
-
}, {
|
|
752
|
-
F: __dxlog_file2,
|
|
753
|
-
L: 470,
|
|
754
|
-
S: this,
|
|
755
|
-
C: (f, a) => f(...a)
|
|
756
|
-
});
|
|
757
|
-
let activationResult = await mod.activate(this.context);
|
|
758
|
-
if (typeof activationResult === "function") {
|
|
759
|
-
activationResult = await activationResult();
|
|
760
|
-
}
|
|
761
|
-
return Array.isArray(activationResult) ? activationResult : [
|
|
762
|
-
activationResult
|
|
763
|
-
];
|
|
764
|
-
} catch (error) {
|
|
765
|
-
failed = true;
|
|
766
|
-
throw error;
|
|
767
|
-
} finally {
|
|
768
|
-
performance.measure("activate-module", {
|
|
769
|
-
start,
|
|
770
|
-
end: performance.now(),
|
|
771
|
-
detail: {
|
|
772
|
-
module: mod.id
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
log2("loaded module", {
|
|
776
|
-
module: mod.id,
|
|
777
|
-
elapsed: performance.now() - start,
|
|
778
|
-
failed
|
|
779
|
-
}, {
|
|
780
|
-
F: __dxlog_file2,
|
|
781
|
-
L: 488,
|
|
782
|
-
S: this,
|
|
783
|
-
C: (f, a) => f(...a)
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
})();
|
|
787
|
-
this._moduleMemoMap.set(mod.id, promise);
|
|
788
|
-
return promise;
|
|
789
|
-
},
|
|
790
|
-
catch: (error) => error
|
|
791
|
-
}).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`, {
|
|
792
|
-
module: mod.id
|
|
793
|
-
}, {
|
|
794
|
-
F: __dxlog_file2,
|
|
795
|
-
L: 499,
|
|
796
|
-
S: this,
|
|
797
|
-
C: (f, a) => f(...a)
|
|
798
|
-
})))))));
|
|
799
|
-
this.registry = registry ?? Registry.make();
|
|
800
|
-
this.context = new PluginContext({
|
|
801
|
-
registry: this.registry,
|
|
802
|
-
activate: (event) => this._activate(event),
|
|
803
|
-
reset: (id) => this._reset(id)
|
|
804
|
-
});
|
|
805
|
-
this._pluginLoader = pluginLoader;
|
|
806
|
-
this._state = live({
|
|
807
|
-
plugins,
|
|
808
|
-
core,
|
|
809
|
-
enabled,
|
|
810
|
-
modules: [],
|
|
811
|
-
active: [],
|
|
812
|
-
eventsFired: [],
|
|
813
|
-
pendingReset: []
|
|
814
|
-
});
|
|
815
|
-
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
816
|
-
core.forEach((id) => this.enable(id));
|
|
817
|
-
enabled.forEach((id) => this.enable(id));
|
|
818
|
-
}
|
|
819
813
|
};
|
|
820
814
|
var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
821
815
|
const togetherFiber = yield* Effect2.fork(togetherEffect);
|
|
@@ -825,26 +819,13 @@ var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
|
825
819
|
});
|
|
826
820
|
|
|
827
821
|
// src/core/plugin.ts
|
|
828
|
-
function _define_property3(obj, key, value) {
|
|
829
|
-
if (key in obj) {
|
|
830
|
-
Object.defineProperty(obj, key, {
|
|
831
|
-
value,
|
|
832
|
-
enumerable: true,
|
|
833
|
-
configurable: true,
|
|
834
|
-
writable: true
|
|
835
|
-
});
|
|
836
|
-
} else {
|
|
837
|
-
obj[key] = value;
|
|
838
|
-
}
|
|
839
|
-
return obj;
|
|
840
|
-
}
|
|
841
822
|
var PluginModule = class {
|
|
823
|
+
id;
|
|
824
|
+
activatesOn;
|
|
825
|
+
activatesBefore;
|
|
826
|
+
activatesAfter;
|
|
827
|
+
activate;
|
|
842
828
|
constructor(options) {
|
|
843
|
-
_define_property3(this, "id", void 0);
|
|
844
|
-
_define_property3(this, "activatesOn", void 0);
|
|
845
|
-
_define_property3(this, "activatesBefore", void 0);
|
|
846
|
-
_define_property3(this, "activatesAfter", void 0);
|
|
847
|
-
_define_property3(this, "activate", void 0);
|
|
848
829
|
this.id = options.id;
|
|
849
830
|
this.activatesOn = options.activatesOn;
|
|
850
831
|
this.activatesBefore = options.activatesBefore;
|
|
@@ -854,22 +835,27 @@ var PluginModule = class {
|
|
|
854
835
|
};
|
|
855
836
|
var defineModule = (options) => new PluginModule(options);
|
|
856
837
|
var Plugin = class {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
this.meta =
|
|
838
|
+
meta;
|
|
839
|
+
modules;
|
|
840
|
+
constructor(meta2, modules) {
|
|
841
|
+
this.meta = meta2;
|
|
861
842
|
this.modules = modules;
|
|
862
843
|
}
|
|
863
844
|
};
|
|
864
|
-
var definePlugin = (
|
|
865
|
-
|
|
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
|
+
});
|
|
866
852
|
};
|
|
867
853
|
|
|
868
854
|
// src/common/capabilities.ts
|
|
869
855
|
(function(Capabilities2) {
|
|
870
856
|
Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
|
|
871
857
|
Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
|
|
872
|
-
Capabilities2.
|
|
858
|
+
Capabilities2.AtomRegistry = defineCapability("dxos.org/app-framework/capability/atom-registry");
|
|
873
859
|
Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
|
|
874
860
|
Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
|
|
875
861
|
Capabilities2.ReactSurface = defineCapability("dxos.org/app-framework/common/react-surface");
|
|
@@ -884,8 +870,9 @@ var definePlugin = (meta, modules) => {
|
|
|
884
870
|
Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
|
|
885
871
|
Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
|
|
886
872
|
Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
|
|
887
|
-
Capabilities2.ToolkitHandler = defineCapability("dxos.org/app-framework/capability/ai-toolkit-handler");
|
|
888
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");
|
|
889
876
|
Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
|
|
890
877
|
Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
|
|
891
878
|
Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
|
|
@@ -893,14 +880,14 @@ var definePlugin = (meta, modules) => {
|
|
|
893
880
|
var Capabilities;
|
|
894
881
|
|
|
895
882
|
// src/common/collaboration.ts
|
|
896
|
-
import
|
|
897
|
-
import {
|
|
883
|
+
import * as Schema from "effect/Schema";
|
|
884
|
+
import { ContentBlock } from "@dxos/types";
|
|
898
885
|
(function(CollaborationActions2) {
|
|
899
886
|
class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
|
|
900
887
|
input: Schema.Struct({
|
|
901
888
|
subject: Schema.Any,
|
|
902
889
|
anchor: Schema.String,
|
|
903
|
-
proposal:
|
|
890
|
+
proposal: ContentBlock.Proposal
|
|
904
891
|
}),
|
|
905
892
|
output: Schema.Void
|
|
906
893
|
}) {
|
|
@@ -928,7 +915,7 @@ var CollaborationActions;
|
|
|
928
915
|
var Events;
|
|
929
916
|
|
|
930
917
|
// src/common/file.ts
|
|
931
|
-
import
|
|
918
|
+
import * as Schema2 from "effect/Schema";
|
|
932
919
|
var defaultFileTypes = {
|
|
933
920
|
images: [
|
|
934
921
|
"png",
|
|
@@ -956,13 +943,13 @@ var FileInfoSchema = Schema2.Struct({
|
|
|
956
943
|
});
|
|
957
944
|
|
|
958
945
|
// src/common/layout.ts
|
|
959
|
-
import
|
|
946
|
+
import * as Schema5 from "effect/Schema";
|
|
960
947
|
|
|
961
948
|
// src/plugin-intent/actions.ts
|
|
962
|
-
import
|
|
949
|
+
import * as Schema4 from "effect/Schema";
|
|
963
950
|
|
|
964
951
|
// src/plugin-intent/intent.ts
|
|
965
|
-
import
|
|
952
|
+
import * as Schema3 from "effect/Schema";
|
|
966
953
|
var createIntent = (schema, data = {}, params = {}) => {
|
|
967
954
|
const _ = Schema3.validateSync(schema.fields.input)(data);
|
|
968
955
|
const intent = {
|
|
@@ -1005,11 +992,15 @@ var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.
|
|
|
1005
992
|
defaultValue: Schema3.optional(Schema3.String)
|
|
1006
993
|
})))));
|
|
1007
994
|
|
|
995
|
+
// src/plugin-intent/meta.ts
|
|
996
|
+
var meta = {
|
|
997
|
+
id: "dxos.org/plugin/intent",
|
|
998
|
+
name: "Intent"
|
|
999
|
+
};
|
|
1000
|
+
|
|
1008
1001
|
// src/plugin-intent/actions.ts
|
|
1009
|
-
var INTENT_PLUGIN = "dxos.org/plugin/intent";
|
|
1010
|
-
var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
1011
1002
|
(function(IntentAction2) {
|
|
1012
|
-
class Track extends Schema4.TaggedClass()(`${
|
|
1003
|
+
class Track extends Schema4.TaggedClass()(`${meta.id}/action/track`, {
|
|
1013
1004
|
input: Schema4.Struct({
|
|
1014
1005
|
intents: Schema4.Array(Schema4.String),
|
|
1015
1006
|
error: Schema4.optional(Schema4.String)
|
|
@@ -1018,7 +1009,7 @@ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
|
1018
1009
|
}) {
|
|
1019
1010
|
}
|
|
1020
1011
|
IntentAction2.Track = Track;
|
|
1021
|
-
class ShowUndo extends Schema4.TaggedClass()(`${
|
|
1012
|
+
class ShowUndo extends Schema4.TaggedClass()(`${meta.id}/action/show-undo`, {
|
|
1022
1013
|
input: Schema4.Struct({
|
|
1023
1014
|
message: Label
|
|
1024
1015
|
}),
|
|
@@ -1030,31 +1021,20 @@ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
|
1030
1021
|
var IntentAction;
|
|
1031
1022
|
|
|
1032
1023
|
// src/plugin-intent/errors.ts
|
|
1033
|
-
function _define_property4(obj, key, value) {
|
|
1034
|
-
if (key in obj) {
|
|
1035
|
-
Object.defineProperty(obj, key, {
|
|
1036
|
-
value,
|
|
1037
|
-
enumerable: true,
|
|
1038
|
-
configurable: true,
|
|
1039
|
-
writable: true
|
|
1040
|
-
});
|
|
1041
|
-
} else {
|
|
1042
|
-
obj[key] = value;
|
|
1043
|
-
}
|
|
1044
|
-
return obj;
|
|
1045
|
-
}
|
|
1046
1024
|
var BaseError = class extends Error {
|
|
1025
|
+
code;
|
|
1026
|
+
context;
|
|
1047
1027
|
constructor(code, message, context) {
|
|
1048
1028
|
super(message ?? code, {
|
|
1049
1029
|
cause: context
|
|
1050
|
-
}),
|
|
1030
|
+
}), this.code = code, this.context = context;
|
|
1051
1031
|
this.name = code;
|
|
1052
1032
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
1053
1033
|
}
|
|
1054
1034
|
};
|
|
1055
1035
|
var NoResolversError = class extends BaseError {
|
|
1056
1036
|
constructor(action) {
|
|
1057
|
-
super("NO_RESOLVERS",
|
|
1037
|
+
super("NO_RESOLVERS", `No resolvers were found for the action: ${action}`, {
|
|
1058
1038
|
action
|
|
1059
1039
|
});
|
|
1060
1040
|
}
|
|
@@ -1066,12 +1046,9 @@ var CycleDetectedError = class extends BaseError {
|
|
|
1066
1046
|
};
|
|
1067
1047
|
|
|
1068
1048
|
// src/plugin-intent/IntentPlugin.ts
|
|
1069
|
-
var IntentPlugin = () =>
|
|
1070
|
-
id: INTENT_PLUGIN,
|
|
1071
|
-
name: "Intent"
|
|
1072
|
-
}, [
|
|
1049
|
+
var IntentPlugin = definePlugin(meta, () => [
|
|
1073
1050
|
defineModule({
|
|
1074
|
-
id: `${
|
|
1051
|
+
id: `${meta.id}/module/dispatcher`,
|
|
1075
1052
|
// TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
|
|
1076
1053
|
// This is fine for now because it's how it worked prior to capabilities api anyways.
|
|
1077
1054
|
// In the future, the intent dispatcher should be able to be reset without resetting the entire app.
|
|
@@ -1079,15 +1056,14 @@ var IntentPlugin = () => definePlugin({
|
|
|
1079
1056
|
activatesAfter: [
|
|
1080
1057
|
Events.DispatcherReady
|
|
1081
1058
|
],
|
|
1082
|
-
activate: lazy(() => import("./intent-dispatcher-
|
|
1059
|
+
activate: lazy(() => import("./intent-dispatcher-LZ4AE66E.mjs"))
|
|
1083
1060
|
})
|
|
1084
1061
|
]);
|
|
1085
1062
|
|
|
1086
1063
|
// src/common/layout.ts
|
|
1087
1064
|
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
|
|
1088
|
-
var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
|
|
1089
1065
|
(function(LayoutAction2) {
|
|
1090
|
-
LayoutAction2.UPDATE_LAYOUT = `${
|
|
1066
|
+
LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_PLUGIN}/action/update-layout`;
|
|
1091
1067
|
class UpdateLayout extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1092
1068
|
input: Schema5.Struct({
|
|
1093
1069
|
part: Schema5.String.annotations({
|
|
@@ -1424,7 +1400,7 @@ var LayoutAction;
|
|
|
1424
1400
|
var createSurface = (definition) => definition;
|
|
1425
1401
|
|
|
1426
1402
|
// src/common/translations.ts
|
|
1427
|
-
import
|
|
1403
|
+
import * as Schema6 from "effect/Schema";
|
|
1428
1404
|
var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
|
|
1429
1405
|
key: Schema6.String,
|
|
1430
1406
|
value: Schema6.Any
|
|
@@ -1449,14 +1425,6 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1449
1425
|
const handleIntent = (intent) => Effect3.gen(function* () {
|
|
1450
1426
|
const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
|
|
1451
1427
|
if (candidates.length === 0) {
|
|
1452
|
-
log3.info("no resolvers found", {
|
|
1453
|
-
intent: intent.id
|
|
1454
|
-
}, {
|
|
1455
|
-
F: __dxlog_file3,
|
|
1456
|
-
L: 200,
|
|
1457
|
-
S: this,
|
|
1458
|
-
C: (f, a) => f(...a)
|
|
1459
|
-
});
|
|
1460
1428
|
return yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1461
1429
|
}
|
|
1462
1430
|
const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
@@ -1467,12 +1435,29 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1467
1435
|
};
|
|
1468
1436
|
});
|
|
1469
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
|
+
});
|
|
1470
1447
|
return Effect3.gen(function* () {
|
|
1471
1448
|
if (depth > executionLimit) {
|
|
1472
1449
|
return yield* Effect3.fail(new CycleDetectedError());
|
|
1473
1450
|
}
|
|
1474
1451
|
const resultsRef = yield* Ref2.make([]);
|
|
1475
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
|
+
});
|
|
1476
1461
|
const { data: prev } = (yield* resultsRef.get)[0] ?? {};
|
|
1477
1462
|
const result2 = yield* handleIntent({
|
|
1478
1463
|
...intent,
|
|
@@ -1481,6 +1466,15 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1481
1466
|
...prev
|
|
1482
1467
|
}
|
|
1483
1468
|
});
|
|
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
|
+
});
|
|
1484
1478
|
yield* Ref2.update(resultsRef, (results2) => [
|
|
1485
1479
|
result2,
|
|
1486
1480
|
...results2
|
|
@@ -1491,6 +1485,15 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1491
1485
|
}
|
|
1492
1486
|
}
|
|
1493
1487
|
if (result2.error) {
|
|
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
|
+
});
|
|
1494
1497
|
return yield* Effect3.fail(result2.error);
|
|
1495
1498
|
}
|
|
1496
1499
|
}
|
|
@@ -1507,10 +1510,19 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1507
1510
|
return next;
|
|
1508
1511
|
});
|
|
1509
1512
|
if (result.undoable && isUndoable(results)) {
|
|
1510
|
-
yield*
|
|
1513
|
+
yield* Function2.pipe(dispatch(createIntent(IntentAction.ShowUndo, {
|
|
1511
1514
|
message: result.undoable.message
|
|
1512
1515
|
})), Effect3.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect3.succeed(void 0)) : Option.none()));
|
|
1513
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
|
+
});
|
|
1514
1526
|
return result.data;
|
|
1515
1527
|
});
|
|
1516
1528
|
};
|
|
@@ -1520,7 +1532,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1520
1532
|
})).catch((error) => {
|
|
1521
1533
|
log3.catch(error, void 0, {
|
|
1522
1534
|
F: __dxlog_file3,
|
|
1523
|
-
L:
|
|
1535
|
+
L: 279,
|
|
1524
1536
|
S: void 0,
|
|
1525
1537
|
C: (f, a) => f(...a)
|
|
1526
1538
|
});
|
|
@@ -1535,7 +1547,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1535
1547
|
const last = history.findLastIndex(isUndoable);
|
|
1536
1548
|
const result = last !== -1 ? history[last] : void 0;
|
|
1537
1549
|
if (result) {
|
|
1538
|
-
const
|
|
1550
|
+
const all2 = result.map(({ _intent, undoable }) => {
|
|
1539
1551
|
const data = _intent.data;
|
|
1540
1552
|
const undoData = undoable?.data ?? {};
|
|
1541
1553
|
return {
|
|
@@ -1548,9 +1560,9 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1548
1560
|
};
|
|
1549
1561
|
});
|
|
1550
1562
|
const intent = {
|
|
1551
|
-
first:
|
|
1552
|
-
last:
|
|
1553
|
-
all
|
|
1563
|
+
first: all2[0],
|
|
1564
|
+
last: all2.at(-1),
|
|
1565
|
+
all: all2
|
|
1554
1566
|
};
|
|
1555
1567
|
yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
|
|
1556
1568
|
return yield* dispatch(intent);
|
|
@@ -1573,7 +1585,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1573
1585
|
};
|
|
1574
1586
|
var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
|
|
1575
1587
|
var defaultPromise = () => Effect3.runPromise(defaultEffect());
|
|
1576
|
-
var intent_dispatcher_default = (context) => {
|
|
1588
|
+
var intent_dispatcher_default = ((context) => {
|
|
1577
1589
|
const state = live2({
|
|
1578
1590
|
dispatch: defaultEffect,
|
|
1579
1591
|
dispatchPromise: defaultPromise,
|
|
@@ -1595,7 +1607,7 @@ var intent_dispatcher_default = (context) => {
|
|
|
1595
1607
|
state.undo = undo;
|
|
1596
1608
|
state.undoPromise = undoPromise;
|
|
1597
1609
|
return contributes(Capabilities.IntentDispatcher, state);
|
|
1598
|
-
};
|
|
1610
|
+
});
|
|
1599
1611
|
|
|
1600
1612
|
export {
|
|
1601
1613
|
defineCapability,
|
|
@@ -1622,8 +1634,6 @@ export {
|
|
|
1622
1634
|
createIntent,
|
|
1623
1635
|
chain,
|
|
1624
1636
|
Label,
|
|
1625
|
-
INTENT_PLUGIN,
|
|
1626
|
-
INTENT_ACTION,
|
|
1627
1637
|
IntentAction,
|
|
1628
1638
|
BaseError,
|
|
1629
1639
|
NoResolversError,
|
|
@@ -1632,12 +1642,10 @@ export {
|
|
|
1632
1642
|
createDispatcher,
|
|
1633
1643
|
intent_dispatcher_default,
|
|
1634
1644
|
IntentPlugin,
|
|
1635
|
-
LAYOUT_PLUGIN,
|
|
1636
|
-
LAYOUT_ACTION,
|
|
1637
1645
|
LayoutAction,
|
|
1638
1646
|
createSurface,
|
|
1639
1647
|
ResourceKey,
|
|
1640
1648
|
ResourceLanguage,
|
|
1641
1649
|
Resource
|
|
1642
1650
|
};
|
|
1643
|
-
//# sourceMappingURL=chunk-
|
|
1651
|
+
//# sourceMappingURL=chunk-WPW5VVAX.mjs.map
|