@dxos/app-framework 0.8.4-main.c1de068 → 0.8.4-main.dedc0f3
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/.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-LYF7EKNN.mjs → app-graph-builder-AFFC6VB2.mjs} +3 -3
- package/dist/lib/browser/app-graph-builder-AFFC6VB2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FMN65HSW.mjs → chunk-OZY7HV2A.mjs} +376 -252
- package/dist/lib/browser/chunk-OZY7HV2A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FO2PH7M3.mjs → chunk-T6M7JB7M.mjs} +186 -130
- package/dist/lib/browser/chunk-T6M7JB7M.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +11 -5
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/{intent-dispatcher-LSYQZSEB.mjs → intent-dispatcher-QG7UPGQX.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-ZTNOSO3A.mjs → intent-resolver-4S4PSTM5.mjs} +2 -2
- package/dist/lib/browser/intent-resolver-4S4PSTM5.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{store-KML2R4IE.mjs → store-6E33KLGK.mjs} +2 -2
- package/dist/lib/browser/{store-KML2R4IE.mjs.map → store-6E33KLGK.mjs.map} +1 -1
- package/dist/lib/browser/testing/index.mjs +5 -7
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/worker.mjs +7 -1
- package/dist/lib/node-esm/{app-graph-builder-SAOWGJDK.mjs → app-graph-builder-S4OAULX5.mjs} +3 -3
- package/dist/lib/node-esm/app-graph-builder-S4OAULX5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZEZ4FVEU.mjs → chunk-F63ZRXMK.mjs} +376 -252
- package/dist/lib/node-esm/chunk-F63ZRXMK.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-73HGSHKE.mjs → chunk-HJFU7QOR.mjs} +186 -130
- package/dist/lib/node-esm/chunk-HJFU7QOR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +11 -5
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/{intent-dispatcher-6CYNGPSW.mjs → intent-dispatcher-NXBGPJOX.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-W7Z7WFFM.mjs → intent-resolver-2ZKXI5ET.mjs} +2 -2
- package/dist/lib/node-esm/intent-resolver-2ZKXI5ET.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{store-QEXGXLWZ.mjs → store-QQUTQHHT.mjs} +2 -2
- package/dist/lib/node-esm/{store-QEXGXLWZ.mjs.map → store-QQUTQHHT.mjs.map} +1 -1
- package/dist/lib/node-esm/testing/index.mjs +5 -7
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/worker.mjs +7 -1
- package/dist/types/src/common/capabilities.d.ts +75 -8
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/collaboration.d.ts +9 -8
- package/dist/types/src/common/collaboration.d.ts.map +1 -1
- package/dist/types/src/common/events.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +1 -1
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts +1 -1
- package/dist/types/src/common/surface.d.ts.map +1 -1
- package/dist/types/src/components/App.d.ts +10 -0
- package/dist/types/src/components/App.d.ts.map +1 -0
- package/dist/types/src/components/App.stories.d.ts +15 -0
- package/dist/types/src/components/App.stories.d.ts.map +1 -0
- package/dist/types/src/components/DefaultFallback.d.ts +8 -0
- package/dist/types/src/components/DefaultFallback.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/{App.d.ts → components/useApp.d.ts} +7 -6
- package/dist/types/src/components/useApp.d.ts.map +1 -0
- package/dist/types/src/components/useLoading.d.ts +19 -0
- package/dist/types/src/components/useLoading.d.ts.map +1 -0
- package/dist/types/src/core/capabilities.d.ts +4 -1
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts +6 -2
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- 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/generator/Main.d.ts +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -1
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -1
- package/dist/types/src/playground/layout/Layout.d.ts +2 -2
- package/dist/types/src/playground/logger/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -1
- package/dist/types/src/playground/logger/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/playground.stories.d.ts +5 -3
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.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 +3 -3
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.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/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/store.d.ts +1 -1
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -1
- package/dist/types/src/react/ErrorBoundary.d.ts +13 -14
- package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -1
- package/dist/types/src/react/IntentContext.d.ts.map +1 -1
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/Surface.stories.d.ts +6 -4
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -1
- package/dist/types/src/react/common.d.ts.map +1 -1
- package/dist/types/src/react/useCapabilities.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.d.ts +4 -2
- 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/package.json +28 -24
- package/src/common/capabilities.ts +91 -10
- package/src/common/collaboration.ts +5 -8
- package/src/common/events.ts +3 -1
- package/src/common/index.ts +1 -1
- package/src/common/surface.ts +1 -1
- package/src/components/App.stories.tsx +35 -0
- package/src/components/App.tsx +59 -0
- package/src/components/DefaultFallback.tsx +26 -0
- package/src/components/index.ts +5 -0
- package/src/{App.tsx → components/useApp.tsx} +20 -130
- package/src/components/useLoading.tsx +70 -0
- package/src/core/capabilities.test.ts +1 -1
- package/src/core/capabilities.ts +11 -6
- package/src/core/manager.test.ts +4 -3
- package/src/core/manager.ts +132 -54
- package/src/helpers.test.ts +1 -1
- package/src/index.ts +1 -1
- package/src/playground/debug/Debug.tsx +1 -1
- package/src/playground/generator/Toolbar.tsx +2 -1
- package/src/playground/generator/generator.ts +2 -2
- package/src/playground/layout/plugin.ts +1 -1
- package/src/playground/logger/Toolbar.tsx +2 -1
- package/src/playground/logger/plugin.ts +3 -2
- package/src/playground/playground.stories.tsx +15 -10
- package/src/plugin-intent/IntentPlugin.ts +2 -1
- package/src/plugin-intent/index.ts +1 -0
- package/src/plugin-intent/intent-dispatcher.test.ts +1 -1
- package/src/plugin-intent/intent-dispatcher.ts +10 -8
- package/src/plugin-settings/SettingsPlugin.ts +3 -2
- package/src/plugin-settings/app-graph-builder.ts +4 -3
- package/src/plugin-settings/intent-resolver.ts +3 -2
- package/src/plugin-settings/store.ts +1 -1
- package/src/react/ErrorBoundary.tsx +24 -15
- package/src/react/IntentContext.tsx +3 -2
- package/src/react/Surface.stories.tsx +21 -13
- package/src/react/Surface.tsx +4 -3
- package/src/react/common.ts +2 -1
- package/src/react/useCapabilities.ts +2 -1
- package/src/testing/withPluginManager.stories.tsx +9 -5
- package/src/testing/withPluginManager.tsx +13 -13
- package/tsconfig.json +1 -8
- package/.swc/plugins/v7_linux_x86_64_13.0.0/f45bdff002284d9e8f9ef3f0be909de12da36c049cbcf261ac78fc00abb09a2d +0 -0
- package/dist/lib/browser/app-graph-builder-LYF7EKNN.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMN65HSW.mjs.map +0 -7
- package/dist/lib/browser/chunk-FO2PH7M3.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-ZTNOSO3A.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-SAOWGJDK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-73HGSHKE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZEZ4FVEU.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-W7Z7WFFM.mjs.map +0 -7
- package/dist/types/src/App.d.ts.map +0 -1
- /package/dist/lib/browser/{intent-dispatcher-LSYQZSEB.mjs.map → intent-dispatcher-QG7UPGQX.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-6CYNGPSW.mjs.map → intent-dispatcher-NXBGPJOX.mjs.map} +0 -0
|
@@ -1,111 +1,30 @@
|
|
|
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 { Effect as Effect3, Option,
|
|
4
|
+
import { Effect as Effect3, Option, Ref as Ref2, pipe as pipe2 } from "effect";
|
|
5
5
|
import { live as live2 } from "@dxos/live-object";
|
|
6
6
|
import { log as log3 } from "@dxos/log";
|
|
7
7
|
import { byPosition } from "@dxos/util";
|
|
8
8
|
|
|
9
|
-
// src/plugin-intent/actions.ts
|
|
10
|
-
import { Schema as Schema2 } from "effect";
|
|
11
|
-
|
|
12
|
-
// src/plugin-intent/intent.ts
|
|
13
|
-
import { Schema } from "effect";
|
|
14
|
-
var createIntent = (schema, data = {}, params = {}) => {
|
|
15
|
-
const _ = Schema.validateSync(schema.fields.input)(data);
|
|
16
|
-
const intent = {
|
|
17
|
-
...params,
|
|
18
|
-
_schema: schema,
|
|
19
|
-
id: schema._tag,
|
|
20
|
-
data
|
|
21
|
-
};
|
|
22
|
-
return {
|
|
23
|
-
first: intent,
|
|
24
|
-
last: intent,
|
|
25
|
-
all: [
|
|
26
|
-
intent
|
|
27
|
-
]
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
var chain = (schema, data = {}, params = {}) => (intent) => {
|
|
31
|
-
const intents = "all" in intent ? intent.all : [
|
|
32
|
-
intent
|
|
33
|
-
];
|
|
34
|
-
const first = intents[0];
|
|
35
|
-
const last = {
|
|
36
|
-
...params,
|
|
37
|
-
_schema: schema,
|
|
38
|
-
id: schema._tag,
|
|
39
|
-
data
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
first,
|
|
43
|
-
last,
|
|
44
|
-
all: [
|
|
45
|
-
...intents,
|
|
46
|
-
last
|
|
47
|
-
]
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
var Label = Schema.Union(Schema.String, Schema.mutable(Schema.Tuple(Schema.String, Schema.mutable(Schema.Struct({
|
|
51
|
-
ns: Schema.String,
|
|
52
|
-
count: Schema.optional(Schema.Number),
|
|
53
|
-
defaultValue: Schema.optional(Schema.String)
|
|
54
|
-
})))));
|
|
55
|
-
|
|
56
|
-
// src/plugin-intent/actions.ts
|
|
57
|
-
var INTENT_PLUGIN = "dxos.org/plugin/intent";
|
|
58
|
-
var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
59
|
-
(function(IntentAction2) {
|
|
60
|
-
class Track extends Schema2.TaggedClass()(`${INTENT_ACTION}/track`, {
|
|
61
|
-
input: Schema2.Struct({
|
|
62
|
-
intents: Schema2.Array(Schema2.String),
|
|
63
|
-
error: Schema2.optional(Schema2.String)
|
|
64
|
-
}),
|
|
65
|
-
output: Schema2.Void
|
|
66
|
-
}) {
|
|
67
|
-
}
|
|
68
|
-
IntentAction2.Track = Track;
|
|
69
|
-
class ShowUndo extends Schema2.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
|
|
70
|
-
input: Schema2.Struct({
|
|
71
|
-
message: Label
|
|
72
|
-
}),
|
|
73
|
-
output: Schema2.Void
|
|
74
|
-
}) {
|
|
75
|
-
}
|
|
76
|
-
IntentAction2.ShowUndo = ShowUndo;
|
|
77
|
-
})(IntentAction || (IntentAction = {}));
|
|
78
|
-
var IntentAction;
|
|
79
|
-
|
|
80
|
-
// src/plugin-intent/errors.ts
|
|
81
|
-
var BaseError = class extends Error {
|
|
82
|
-
constructor(code, message, context) {
|
|
83
|
-
super(message ?? code, {
|
|
84
|
-
cause: context
|
|
85
|
-
}), this.code = code, this.context = context;
|
|
86
|
-
this.name = code;
|
|
87
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
var NoResolversError = class extends BaseError {
|
|
91
|
-
constructor(action) {
|
|
92
|
-
super("NO_RESOLVERS", "No resolvers were found for the action", {
|
|
93
|
-
action
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
var CycleDetectedError = class extends BaseError {
|
|
98
|
-
constructor(context) {
|
|
99
|
-
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
9
|
// src/core/capabilities.ts
|
|
104
10
|
import { Rx } from "@effect-rx/rx-react";
|
|
105
11
|
import { Effect } from "effect";
|
|
106
12
|
import { Trigger } from "@dxos/async";
|
|
107
13
|
import { invariant } from "@dxos/invariant";
|
|
108
14
|
import { log } from "@dxos/log";
|
|
15
|
+
function _define_property(obj, key, value) {
|
|
16
|
+
if (key in obj) {
|
|
17
|
+
Object.defineProperty(obj, key, {
|
|
18
|
+
value,
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
obj[key] = value;
|
|
25
|
+
}
|
|
26
|
+
return obj;
|
|
27
|
+
}
|
|
109
28
|
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
|
|
110
29
|
var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
|
|
111
30
|
var defineCapability = (identifier) => {
|
|
@@ -115,6 +34,8 @@ var defineCapability = (identifier) => {
|
|
|
115
34
|
};
|
|
116
35
|
var CapabilityImpl = class {
|
|
117
36
|
constructor(moduleId, implementation) {
|
|
37
|
+
_define_property(this, "moduleId", void 0);
|
|
38
|
+
_define_property(this, "implementation", void 0);
|
|
118
39
|
this.moduleId = moduleId;
|
|
119
40
|
this.implementation = implementation;
|
|
120
41
|
}
|
|
@@ -131,35 +52,6 @@ var lazy = (c) => async (props) => {
|
|
|
131
52
|
return async () => getCapability(props);
|
|
132
53
|
};
|
|
133
54
|
var PluginContext = class {
|
|
134
|
-
constructor({ registry, activate, reset }) {
|
|
135
|
-
this._capabilityImpls = Rx.family(() => {
|
|
136
|
-
return Rx.make([]).pipe(Rx.keepAlive);
|
|
137
|
-
});
|
|
138
|
-
this._capabilities = Rx.family((id) => {
|
|
139
|
-
return Rx.make((get) => {
|
|
140
|
-
const current = get(this._capabilityImpls(id));
|
|
141
|
-
return current.map((c) => c.implementation);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
this._capability = Rx.family((id) => {
|
|
145
|
-
return Rx.make((get) => {
|
|
146
|
-
const current = get(this._capabilities(id));
|
|
147
|
-
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
148
|
-
F: __dxlog_file,
|
|
149
|
-
L: 117,
|
|
150
|
-
S: this,
|
|
151
|
-
A: [
|
|
152
|
-
"current.length > 0",
|
|
153
|
-
"`No capability found for ${id}`"
|
|
154
|
-
]
|
|
155
|
-
});
|
|
156
|
-
return current[0];
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
this._registry = registry;
|
|
160
|
-
this.activate = activate;
|
|
161
|
-
this.reset = reset;
|
|
162
|
-
}
|
|
163
55
|
/**
|
|
164
56
|
* @internal
|
|
165
57
|
*/
|
|
@@ -179,7 +71,7 @@ var PluginContext = class {
|
|
|
179
71
|
count: current.length
|
|
180
72
|
}, {
|
|
181
73
|
F: __dxlog_file,
|
|
182
|
-
L:
|
|
74
|
+
L: 166,
|
|
183
75
|
S: this,
|
|
184
76
|
C: (f, a) => f(...a)
|
|
185
77
|
});
|
|
@@ -200,7 +92,7 @@ var PluginContext = class {
|
|
|
200
92
|
count: current.length
|
|
201
93
|
}, {
|
|
202
94
|
F: __dxlog_file,
|
|
203
|
-
L:
|
|
95
|
+
L: 185,
|
|
204
96
|
S: this,
|
|
205
97
|
C: (f, a) => f(...a)
|
|
206
98
|
});
|
|
@@ -209,7 +101,7 @@ var PluginContext = class {
|
|
|
209
101
|
id: interfaceDef.identifier
|
|
210
102
|
}, {
|
|
211
103
|
F: __dxlog_file,
|
|
212
|
-
L:
|
|
104
|
+
L: 187,
|
|
213
105
|
S: this,
|
|
214
106
|
C: (f, a) => f(...a)
|
|
215
107
|
});
|
|
@@ -274,6 +166,38 @@ var PluginContext = class {
|
|
|
274
166
|
async resetPromise(event) {
|
|
275
167
|
return this.reset(event).pipe(Effect.runPromise);
|
|
276
168
|
}
|
|
169
|
+
constructor({ registry, activate, reset }) {
|
|
170
|
+
_define_property(this, "_registry", void 0);
|
|
171
|
+
_define_property(this, "_capabilityImpls", Rx.family(() => {
|
|
172
|
+
return Rx.make([]).pipe(Rx.keepAlive);
|
|
173
|
+
}));
|
|
174
|
+
_define_property(this, "_capabilities", Rx.family((id) => {
|
|
175
|
+
return Rx.make((get) => {
|
|
176
|
+
const current = get(this._capabilityImpls(id));
|
|
177
|
+
return current.map((c) => c.implementation);
|
|
178
|
+
});
|
|
179
|
+
}));
|
|
180
|
+
_define_property(this, "_capability", Rx.family((id) => {
|
|
181
|
+
return Rx.make((get) => {
|
|
182
|
+
const current = get(this._capabilities(id));
|
|
183
|
+
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
184
|
+
F: __dxlog_file,
|
|
185
|
+
L: 122,
|
|
186
|
+
S: this,
|
|
187
|
+
A: [
|
|
188
|
+
"current.length > 0",
|
|
189
|
+
"`No capability found for ${id}`"
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
return current[0];
|
|
193
|
+
});
|
|
194
|
+
}));
|
|
195
|
+
_define_property(this, "activate", void 0);
|
|
196
|
+
_define_property(this, "reset", void 0);
|
|
197
|
+
this._registry = registry;
|
|
198
|
+
this.activate = activate;
|
|
199
|
+
this.reset = reset;
|
|
200
|
+
}
|
|
277
201
|
};
|
|
278
202
|
|
|
279
203
|
// src/core/events.ts
|
|
@@ -301,38 +225,28 @@ var getEvents = (events) => "type" in events ? events.events : [
|
|
|
301
225
|
// src/core/manager.ts
|
|
302
226
|
import { Registry } from "@effect-rx/rx-react";
|
|
303
227
|
import { untracked } from "@preact/signals-core";
|
|
304
|
-
import { Array
|
|
228
|
+
import { Array, Duration, Effect as Effect2, Fiber, HashSet, Match, Ref, pipe } from "effect";
|
|
305
229
|
import { Event } from "@dxos/async";
|
|
306
230
|
import { live } from "@dxos/live-object";
|
|
307
231
|
import { log as log2 } from "@dxos/log";
|
|
232
|
+
function _define_property2(obj, key, value) {
|
|
233
|
+
if (key in obj) {
|
|
234
|
+
Object.defineProperty(obj, key, {
|
|
235
|
+
value,
|
|
236
|
+
enumerable: true,
|
|
237
|
+
configurable: true,
|
|
238
|
+
writable: true
|
|
239
|
+
});
|
|
240
|
+
} else {
|
|
241
|
+
obj[key] = value;
|
|
242
|
+
}
|
|
243
|
+
return obj;
|
|
244
|
+
}
|
|
308
245
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
|
|
309
246
|
var isPromise = (value) => {
|
|
310
247
|
return value !== null && typeof value === "object" && "then" in value;
|
|
311
248
|
};
|
|
312
249
|
var PluginManager = class {
|
|
313
|
-
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry }) {
|
|
314
|
-
this.activation = new Event();
|
|
315
|
-
this._capabilities = /* @__PURE__ */ new Map();
|
|
316
|
-
this.registry = registry ?? Registry.make();
|
|
317
|
-
this.context = new PluginContext({
|
|
318
|
-
registry: this.registry,
|
|
319
|
-
activate: (event) => this._activate(event),
|
|
320
|
-
reset: (id) => this._reset(id)
|
|
321
|
-
});
|
|
322
|
-
this._pluginLoader = pluginLoader;
|
|
323
|
-
this._state = live({
|
|
324
|
-
plugins,
|
|
325
|
-
core,
|
|
326
|
-
enabled,
|
|
327
|
-
modules: [],
|
|
328
|
-
active: [],
|
|
329
|
-
pendingReset: [],
|
|
330
|
-
eventsFired: []
|
|
331
|
-
});
|
|
332
|
-
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
333
|
-
core.forEach((id) => this.enable(id));
|
|
334
|
-
enabled.forEach((id) => this.enable(id));
|
|
335
|
-
}
|
|
336
250
|
/**
|
|
337
251
|
* Plugins that are currently registered.
|
|
338
252
|
*
|
|
@@ -399,7 +313,7 @@ var PluginManager = class {
|
|
|
399
313
|
id
|
|
400
314
|
}, {
|
|
401
315
|
F: __dxlog_file2,
|
|
402
|
-
L:
|
|
316
|
+
L: 157,
|
|
403
317
|
S: this,
|
|
404
318
|
C: (f, a) => f(...a)
|
|
405
319
|
});
|
|
@@ -418,7 +332,7 @@ var PluginManager = class {
|
|
|
418
332
|
id
|
|
419
333
|
}, {
|
|
420
334
|
F: __dxlog_file2,
|
|
421
|
-
L:
|
|
335
|
+
L: 170,
|
|
422
336
|
S: this,
|
|
423
337
|
C: (f, a) => f(...a)
|
|
424
338
|
});
|
|
@@ -439,7 +353,7 @@ var PluginManager = class {
|
|
|
439
353
|
]
|
|
440
354
|
}, {
|
|
441
355
|
F: __dxlog_file2,
|
|
442
|
-
L:
|
|
356
|
+
L: 185,
|
|
443
357
|
S: this,
|
|
444
358
|
C: (f, a) => f(...a)
|
|
445
359
|
});
|
|
@@ -459,7 +373,7 @@ var PluginManager = class {
|
|
|
459
373
|
id
|
|
460
374
|
}, {
|
|
461
375
|
F: __dxlog_file2,
|
|
462
|
-
L:
|
|
376
|
+
L: 203,
|
|
463
377
|
S: this,
|
|
464
378
|
C: (f, a) => f(...a)
|
|
465
379
|
});
|
|
@@ -481,7 +395,7 @@ var PluginManager = class {
|
|
|
481
395
|
id
|
|
482
396
|
}, {
|
|
483
397
|
F: __dxlog_file2,
|
|
484
|
-
L:
|
|
398
|
+
L: 220,
|
|
485
399
|
S: this,
|
|
486
400
|
C: (f, a) => f(...a)
|
|
487
401
|
});
|
|
@@ -533,7 +447,7 @@ var PluginManager = class {
|
|
|
533
447
|
id: plugin.meta.id
|
|
534
448
|
}, {
|
|
535
449
|
F: __dxlog_file2,
|
|
536
|
-
L:
|
|
450
|
+
L: 273,
|
|
537
451
|
S: this,
|
|
538
452
|
C: (f, a) => f(...a)
|
|
539
453
|
});
|
|
@@ -548,7 +462,7 @@ var PluginManager = class {
|
|
|
548
462
|
id
|
|
549
463
|
}, {
|
|
550
464
|
F: __dxlog_file2,
|
|
551
|
-
L:
|
|
465
|
+
L: 283,
|
|
552
466
|
S: this,
|
|
553
467
|
C: (f, a) => f(...a)
|
|
554
468
|
});
|
|
@@ -564,7 +478,7 @@ var PluginManager = class {
|
|
|
564
478
|
id: module.id
|
|
565
479
|
}, {
|
|
566
480
|
F: __dxlog_file2,
|
|
567
|
-
L:
|
|
481
|
+
L: 293,
|
|
568
482
|
S: this,
|
|
569
483
|
C: (f, a) => f(...a)
|
|
570
484
|
});
|
|
@@ -579,7 +493,7 @@ var PluginManager = class {
|
|
|
579
493
|
id
|
|
580
494
|
}, {
|
|
581
495
|
F: __dxlog_file2,
|
|
582
|
-
L:
|
|
496
|
+
L: 303,
|
|
583
497
|
S: this,
|
|
584
498
|
C: (f, a) => f(...a)
|
|
585
499
|
});
|
|
@@ -607,13 +521,13 @@ var PluginManager = class {
|
|
|
607
521
|
_setPendingResetByModule(module) {
|
|
608
522
|
return untracked(() => {
|
|
609
523
|
const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
|
|
610
|
-
const pendingReset = Array.
|
|
524
|
+
const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
|
|
611
525
|
if (pendingReset.length > 0) {
|
|
612
526
|
log2("pending reset", {
|
|
613
527
|
events: pendingReset
|
|
614
528
|
}, {
|
|
615
529
|
F: __dxlog_file2,
|
|
616
|
-
L:
|
|
530
|
+
L: 341,
|
|
617
531
|
S: this,
|
|
618
532
|
C: (f, a) => f(...a)
|
|
619
533
|
});
|
|
@@ -625,35 +539,40 @@ var PluginManager = class {
|
|
|
625
539
|
* @internal
|
|
626
540
|
*/
|
|
627
541
|
// TODO(wittjosiah): Improve error typing.
|
|
628
|
-
_activate(event) {
|
|
542
|
+
_activate(event, params) {
|
|
629
543
|
return Effect2.gen(this, function* () {
|
|
630
544
|
const key = typeof event === "string" ? event : eventKey(event);
|
|
631
545
|
log2("activating", {
|
|
632
|
-
key
|
|
546
|
+
key,
|
|
547
|
+
...params
|
|
633
548
|
}, {
|
|
634
549
|
F: __dxlog_file2,
|
|
635
|
-
L:
|
|
550
|
+
L: 357,
|
|
636
551
|
S: this,
|
|
637
552
|
C: (f, a) => f(...a)
|
|
638
553
|
});
|
|
554
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
|
|
639
555
|
const pendingIndex = this._state.pendingReset.findIndex((event2) => event2 === key);
|
|
640
556
|
if (pendingIndex !== -1) {
|
|
641
557
|
this._state.pendingReset.splice(pendingIndex, 1);
|
|
642
558
|
}
|
|
559
|
+
const activatingEvents = yield* this._activatingEvents;
|
|
560
|
+
const activatingModules = yield* this._activatingModules;
|
|
643
561
|
const modules = this._getInactiveModulesByEvent(key).filter((module) => {
|
|
644
562
|
const allOf2 = isAllOf(module.activatesOn);
|
|
645
563
|
if (!allOf2) {
|
|
646
564
|
return true;
|
|
647
565
|
}
|
|
648
566
|
const events = module.activatesOn.events.filter((event2) => eventKey(event2) !== key);
|
|
649
|
-
return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)));
|
|
567
|
+
return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)) || activatingEvents.includes(eventKey(event2))) && !activatingModules.includes(module.id);
|
|
650
568
|
});
|
|
569
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, modules.map((module) => module.id)));
|
|
651
570
|
if (modules.length === 0) {
|
|
652
571
|
log2("no modules to activate", {
|
|
653
572
|
key
|
|
654
573
|
}, {
|
|
655
574
|
F: __dxlog_file2,
|
|
656
|
-
L:
|
|
575
|
+
L: 388,
|
|
657
576
|
S: this,
|
|
658
577
|
C: (f, a) => f(...a)
|
|
659
578
|
});
|
|
@@ -667,7 +586,7 @@ var PluginManager = class {
|
|
|
667
586
|
modules: modules.map((module) => module.id)
|
|
668
587
|
}, {
|
|
669
588
|
F: __dxlog_file2,
|
|
670
|
-
L:
|
|
589
|
+
L: 395,
|
|
671
590
|
S: this,
|
|
672
591
|
C: (f, a) => f(...a)
|
|
673
592
|
});
|
|
@@ -675,29 +594,36 @@ var PluginManager = class {
|
|
|
675
594
|
event: key,
|
|
676
595
|
state: "activating"
|
|
677
596
|
});
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
})), {
|
|
597
|
+
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, {
|
|
598
|
+
before: key
|
|
599
|
+
})), Effect2.allWith({
|
|
682
600
|
concurrency: "unbounded"
|
|
683
|
-
});
|
|
684
|
-
const
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
A.map(([module, getCapabilities2]) => this._activateModule(module, getCapabilities2)),
|
|
688
|
-
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
689
|
-
// Running this with concurrency causes races with `allOf` activation events.
|
|
690
|
-
Effect2.all,
|
|
691
|
-
Effect2.either
|
|
692
|
-
);
|
|
693
|
-
if (Either.isLeft(result)) {
|
|
601
|
+
}));
|
|
602
|
+
const getCapabilities = yield* pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
|
|
603
|
+
concurrency: "unbounded"
|
|
604
|
+
}), Effect2.catchAll((error) => {
|
|
694
605
|
this.activation.emit({
|
|
695
606
|
event: key,
|
|
696
607
|
state: "error",
|
|
697
|
-
error
|
|
608
|
+
error
|
|
698
609
|
});
|
|
699
|
-
|
|
700
|
-
}
|
|
610
|
+
return Effect2.fail(error);
|
|
611
|
+
}));
|
|
612
|
+
yield* pipe(
|
|
613
|
+
modules,
|
|
614
|
+
Array.zip(getCapabilities),
|
|
615
|
+
Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
|
|
616
|
+
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
617
|
+
// Running this with concurrency causes races with `allOf` activation events.
|
|
618
|
+
Effect2.all
|
|
619
|
+
);
|
|
620
|
+
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, {
|
|
621
|
+
after: key
|
|
622
|
+
})), Effect2.allWith({
|
|
623
|
+
concurrency: "unbounded"
|
|
624
|
+
}));
|
|
625
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event2) => event2 !== key));
|
|
626
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !modules.map((module2) => module2.id).includes(module)));
|
|
701
627
|
if (!this._state.eventsFired.includes(key)) {
|
|
702
628
|
this._state.eventsFired.push(key);
|
|
703
629
|
}
|
|
@@ -709,39 +635,15 @@ var PluginManager = class {
|
|
|
709
635
|
key
|
|
710
636
|
}, {
|
|
711
637
|
F: __dxlog_file2,
|
|
712
|
-
L:
|
|
638
|
+
L: 451,
|
|
713
639
|
S: this,
|
|
714
640
|
C: (f, a) => f(...a)
|
|
715
641
|
});
|
|
716
642
|
return true;
|
|
717
643
|
});
|
|
718
644
|
}
|
|
719
|
-
|
|
645
|
+
_contributeCapabilities(module, capabilities) {
|
|
720
646
|
return Effect2.gen(this, function* () {
|
|
721
|
-
yield* Effect2.all(module.activatesBefore?.map((event) => this._activate(event)) ?? [], {
|
|
722
|
-
concurrency: "unbounded"
|
|
723
|
-
});
|
|
724
|
-
log2("activating module...", {
|
|
725
|
-
module: module.id
|
|
726
|
-
}, {
|
|
727
|
-
F: __dxlog_file2,
|
|
728
|
-
L: 421,
|
|
729
|
-
S: this,
|
|
730
|
-
C: (f, a) => f(...a)
|
|
731
|
-
});
|
|
732
|
-
const maybeCapabilities = typeof getCapabilities === "function" ? getCapabilities() : getCapabilities;
|
|
733
|
-
const resolvedCapabilities = yield* Match.value(maybeCapabilities).pipe(
|
|
734
|
-
// TODO(wittjosiah): Activate with an effect?
|
|
735
|
-
// Match.when(Effect.isEffect, (effect) => effect),
|
|
736
|
-
Match.when(isPromise, (promise) => Effect2.tryPromise({
|
|
737
|
-
try: () => promise,
|
|
738
|
-
catch: (error) => error
|
|
739
|
-
})),
|
|
740
|
-
Match.orElse((program) => Effect2.succeed(program))
|
|
741
|
-
);
|
|
742
|
-
const capabilities = Match.value(resolvedCapabilities).pipe(Match.when(Array.isArray, (array) => array), Match.orElse((value) => [
|
|
743
|
-
value
|
|
744
|
-
]));
|
|
745
647
|
capabilities.forEach((capability) => {
|
|
746
648
|
this.context.contributeCapability({
|
|
747
649
|
module: module.id,
|
|
@@ -750,17 +652,6 @@ var PluginManager = class {
|
|
|
750
652
|
});
|
|
751
653
|
this._state.active.push(module.id);
|
|
752
654
|
this._capabilities.set(module.id, capabilities);
|
|
753
|
-
log2("activated module", {
|
|
754
|
-
module: module.id
|
|
755
|
-
}, {
|
|
756
|
-
F: __dxlog_file2,
|
|
757
|
-
L: 444,
|
|
758
|
-
S: this,
|
|
759
|
-
C: (f, a) => f(...a)
|
|
760
|
-
});
|
|
761
|
-
yield* Effect2.all(module.activatesAfter?.map((event) => this._activate(event)) ?? [], {
|
|
762
|
-
concurrency: "unbounded"
|
|
763
|
-
});
|
|
764
655
|
});
|
|
765
656
|
}
|
|
766
657
|
_deactivate(id) {
|
|
@@ -783,10 +674,11 @@ var PluginManager = class {
|
|
|
783
674
|
id
|
|
784
675
|
}, {
|
|
785
676
|
F: __dxlog_file2,
|
|
786
|
-
L:
|
|
677
|
+
L: 533,
|
|
787
678
|
S: this,
|
|
788
679
|
C: (f, a) => f(...a)
|
|
789
680
|
});
|
|
681
|
+
this._moduleMemoMap.delete(id);
|
|
790
682
|
const capabilities = this._capabilities.get(id);
|
|
791
683
|
if (capabilities) {
|
|
792
684
|
for (const capability of capabilities) {
|
|
@@ -807,7 +699,7 @@ var PluginManager = class {
|
|
|
807
699
|
id
|
|
808
700
|
}, {
|
|
809
701
|
F: __dxlog_file2,
|
|
810
|
-
L:
|
|
702
|
+
L: 560,
|
|
811
703
|
S: this,
|
|
812
704
|
C: (f, a) => f(...a)
|
|
813
705
|
});
|
|
@@ -821,7 +713,7 @@ var PluginManager = class {
|
|
|
821
713
|
key
|
|
822
714
|
}, {
|
|
823
715
|
F: __dxlog_file2,
|
|
824
|
-
L:
|
|
716
|
+
L: 568,
|
|
825
717
|
S: this,
|
|
826
718
|
C: (f, a) => f(...a)
|
|
827
719
|
});
|
|
@@ -836,11 +728,125 @@ var PluginManager = class {
|
|
|
836
728
|
}
|
|
837
729
|
});
|
|
838
730
|
}
|
|
731
|
+
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry }) {
|
|
732
|
+
_define_property2(this, "activation", new Event());
|
|
733
|
+
_define_property2(this, "context", void 0);
|
|
734
|
+
_define_property2(this, "registry", void 0);
|
|
735
|
+
_define_property2(this, "_state", void 0);
|
|
736
|
+
_define_property2(this, "_pluginLoader", void 0);
|
|
737
|
+
_define_property2(this, "_capabilities", /* @__PURE__ */ new Map());
|
|
738
|
+
_define_property2(this, "_moduleMemoMap", /* @__PURE__ */ new Map());
|
|
739
|
+
_define_property2(this, "_activatingEvents", Effect2.runSync(Ref.make([])));
|
|
740
|
+
_define_property2(this, "_activatingModules", Effect2.runSync(Ref.make([])));
|
|
741
|
+
_define_property2(this, "_loadModule", (mod) => Effect2.tryPromise({
|
|
742
|
+
try: async () => {
|
|
743
|
+
const entry = this._moduleMemoMap.get(mod.id);
|
|
744
|
+
if (entry) {
|
|
745
|
+
return entry;
|
|
746
|
+
}
|
|
747
|
+
const promise = (async () => {
|
|
748
|
+
const start = performance.now();
|
|
749
|
+
let failed = false;
|
|
750
|
+
try {
|
|
751
|
+
log2("loading module", {
|
|
752
|
+
module: mod.id
|
|
753
|
+
}, {
|
|
754
|
+
F: __dxlog_file2,
|
|
755
|
+
L: 470,
|
|
756
|
+
S: this,
|
|
757
|
+
C: (f, a) => f(...a)
|
|
758
|
+
});
|
|
759
|
+
let activationResult = await mod.activate(this.context);
|
|
760
|
+
if (typeof activationResult === "function") {
|
|
761
|
+
activationResult = await activationResult();
|
|
762
|
+
}
|
|
763
|
+
return Array.isArray(activationResult) ? activationResult : [
|
|
764
|
+
activationResult
|
|
765
|
+
];
|
|
766
|
+
} catch (error) {
|
|
767
|
+
failed = true;
|
|
768
|
+
throw error;
|
|
769
|
+
} finally {
|
|
770
|
+
performance.measure("activate-module", {
|
|
771
|
+
start,
|
|
772
|
+
end: performance.now(),
|
|
773
|
+
detail: {
|
|
774
|
+
module: mod.id
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
log2("loaded module", {
|
|
778
|
+
module: mod.id,
|
|
779
|
+
elapsed: performance.now() - start,
|
|
780
|
+
failed
|
|
781
|
+
}, {
|
|
782
|
+
F: __dxlog_file2,
|
|
783
|
+
L: 488,
|
|
784
|
+
S: this,
|
|
785
|
+
C: (f, a) => f(...a)
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
})();
|
|
789
|
+
this._moduleMemoMap.set(mod.id, promise);
|
|
790
|
+
return promise;
|
|
791
|
+
},
|
|
792
|
+
catch: (error) => error
|
|
793
|
+
}).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`, {
|
|
794
|
+
module: mod.id
|
|
795
|
+
}, {
|
|
796
|
+
F: __dxlog_file2,
|
|
797
|
+
L: 499,
|
|
798
|
+
S: this,
|
|
799
|
+
C: (f, a) => f(...a)
|
|
800
|
+
})))))));
|
|
801
|
+
this.registry = registry ?? Registry.make();
|
|
802
|
+
this.context = new PluginContext({
|
|
803
|
+
registry: this.registry,
|
|
804
|
+
activate: (event) => this._activate(event),
|
|
805
|
+
reset: (id) => this._reset(id)
|
|
806
|
+
});
|
|
807
|
+
this._pluginLoader = pluginLoader;
|
|
808
|
+
this._state = live({
|
|
809
|
+
plugins,
|
|
810
|
+
core,
|
|
811
|
+
enabled,
|
|
812
|
+
modules: [],
|
|
813
|
+
active: [],
|
|
814
|
+
eventsFired: [],
|
|
815
|
+
pendingReset: []
|
|
816
|
+
});
|
|
817
|
+
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
818
|
+
core.forEach((id) => this.enable(id));
|
|
819
|
+
enabled.forEach((id) => this.enable(id));
|
|
820
|
+
}
|
|
839
821
|
};
|
|
822
|
+
var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
823
|
+
const togetherFiber = yield* Effect2.fork(togetherEffect);
|
|
824
|
+
const result = yield* effect;
|
|
825
|
+
yield* Fiber.interrupt(togetherFiber);
|
|
826
|
+
return result;
|
|
827
|
+
});
|
|
840
828
|
|
|
841
829
|
// src/core/plugin.ts
|
|
830
|
+
function _define_property3(obj, key, value) {
|
|
831
|
+
if (key in obj) {
|
|
832
|
+
Object.defineProperty(obj, key, {
|
|
833
|
+
value,
|
|
834
|
+
enumerable: true,
|
|
835
|
+
configurable: true,
|
|
836
|
+
writable: true
|
|
837
|
+
});
|
|
838
|
+
} else {
|
|
839
|
+
obj[key] = value;
|
|
840
|
+
}
|
|
841
|
+
return obj;
|
|
842
|
+
}
|
|
842
843
|
var PluginModule = class {
|
|
843
844
|
constructor(options) {
|
|
845
|
+
_define_property3(this, "id", void 0);
|
|
846
|
+
_define_property3(this, "activatesOn", void 0);
|
|
847
|
+
_define_property3(this, "activatesBefore", void 0);
|
|
848
|
+
_define_property3(this, "activatesAfter", void 0);
|
|
849
|
+
_define_property3(this, "activate", void 0);
|
|
844
850
|
this.id = options.id;
|
|
845
851
|
this.activatesOn = options.activatesOn;
|
|
846
852
|
this.activatesBefore = options.activatesBefore;
|
|
@@ -851,6 +857,8 @@ var PluginModule = class {
|
|
|
851
857
|
var defineModule = (options) => new PluginModule(options);
|
|
852
858
|
var Plugin = class {
|
|
853
859
|
constructor(meta, modules) {
|
|
860
|
+
_define_property3(this, "meta", void 0);
|
|
861
|
+
_define_property3(this, "modules", void 0);
|
|
854
862
|
this.meta = meta;
|
|
855
863
|
this.modules = modules;
|
|
856
864
|
}
|
|
@@ -877,8 +885,9 @@ var definePlugin = (meta, modules) => {
|
|
|
877
885
|
Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
|
|
878
886
|
Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
|
|
879
887
|
Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
|
|
880
|
-
Capabilities2.
|
|
881
|
-
Capabilities2.
|
|
888
|
+
Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
|
|
889
|
+
Capabilities2.ToolkitHandler = defineCapability("dxos.org/app-framework/capability/ai-toolkit-handler");
|
|
890
|
+
Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
|
|
882
891
|
Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
|
|
883
892
|
Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
|
|
884
893
|
Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
|
|
@@ -886,22 +895,19 @@ var definePlugin = (meta, modules) => {
|
|
|
886
895
|
var Capabilities;
|
|
887
896
|
|
|
888
897
|
// src/common/collaboration.ts
|
|
889
|
-
import { Schema
|
|
890
|
-
import {
|
|
898
|
+
import { Schema } from "effect";
|
|
899
|
+
import { DataType } from "@dxos/schema";
|
|
891
900
|
(function(CollaborationActions2) {
|
|
892
|
-
class
|
|
893
|
-
input:
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
label: Schema3.String.pipe(Schema3.optional)
|
|
898
|
-
}).annotations({
|
|
899
|
-
description: "Enables plugins to inject content blocks or references into a related entity."
|
|
901
|
+
class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
|
|
902
|
+
input: Schema.Struct({
|
|
903
|
+
subject: Schema.Any,
|
|
904
|
+
anchor: Schema.String,
|
|
905
|
+
proposal: DataType.MessageBlock.Proposal
|
|
900
906
|
}),
|
|
901
|
-
output:
|
|
907
|
+
output: Schema.Void
|
|
902
908
|
}) {
|
|
903
909
|
}
|
|
904
|
-
CollaborationActions2.
|
|
910
|
+
CollaborationActions2.AcceptProposal = AcceptProposal;
|
|
905
911
|
})(CollaborationActions || (CollaborationActions = {}));
|
|
906
912
|
var CollaborationActions;
|
|
907
913
|
|
|
@@ -924,7 +930,7 @@ var CollaborationActions;
|
|
|
924
930
|
var Events;
|
|
925
931
|
|
|
926
932
|
// src/common/file.ts
|
|
927
|
-
import { Schema as
|
|
933
|
+
import { Schema as Schema2 } from "effect";
|
|
928
934
|
var defaultFileTypes = {
|
|
929
935
|
images: [
|
|
930
936
|
"png",
|
|
@@ -944,16 +950,123 @@ var defaultFileTypes = {
|
|
|
944
950
|
"md"
|
|
945
951
|
]
|
|
946
952
|
};
|
|
947
|
-
var FileInfoSchema =
|
|
948
|
-
name:
|
|
949
|
-
type:
|
|
950
|
-
url:
|
|
951
|
-
cid:
|
|
953
|
+
var FileInfoSchema = Schema2.Struct({
|
|
954
|
+
name: Schema2.String,
|
|
955
|
+
type: Schema2.String,
|
|
956
|
+
url: Schema2.optional(Schema2.String),
|
|
957
|
+
cid: Schema2.optional(Schema2.String)
|
|
952
958
|
});
|
|
953
959
|
|
|
954
960
|
// src/common/layout.ts
|
|
955
961
|
import { Schema as Schema5 } from "effect";
|
|
956
962
|
|
|
963
|
+
// src/plugin-intent/actions.ts
|
|
964
|
+
import { Schema as Schema4 } from "effect";
|
|
965
|
+
|
|
966
|
+
// src/plugin-intent/intent.ts
|
|
967
|
+
import { Schema as Schema3 } from "effect";
|
|
968
|
+
var createIntent = (schema, data = {}, params = {}) => {
|
|
969
|
+
const _ = Schema3.validateSync(schema.fields.input)(data);
|
|
970
|
+
const intent = {
|
|
971
|
+
...params,
|
|
972
|
+
_schema: schema,
|
|
973
|
+
id: schema._tag,
|
|
974
|
+
data
|
|
975
|
+
};
|
|
976
|
+
return {
|
|
977
|
+
first: intent,
|
|
978
|
+
last: intent,
|
|
979
|
+
all: [
|
|
980
|
+
intent
|
|
981
|
+
]
|
|
982
|
+
};
|
|
983
|
+
};
|
|
984
|
+
var chain = (schema, data = {}, params = {}) => (intent) => {
|
|
985
|
+
const intents = "all" in intent ? intent.all : [
|
|
986
|
+
intent
|
|
987
|
+
];
|
|
988
|
+
const first = intents[0];
|
|
989
|
+
const last = {
|
|
990
|
+
...params,
|
|
991
|
+
_schema: schema,
|
|
992
|
+
id: schema._tag,
|
|
993
|
+
data
|
|
994
|
+
};
|
|
995
|
+
return {
|
|
996
|
+
first,
|
|
997
|
+
last,
|
|
998
|
+
all: [
|
|
999
|
+
...intents,
|
|
1000
|
+
last
|
|
1001
|
+
]
|
|
1002
|
+
};
|
|
1003
|
+
};
|
|
1004
|
+
var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.String, Schema3.mutable(Schema3.Struct({
|
|
1005
|
+
ns: Schema3.String,
|
|
1006
|
+
count: Schema3.optional(Schema3.Number),
|
|
1007
|
+
defaultValue: Schema3.optional(Schema3.String)
|
|
1008
|
+
})))));
|
|
1009
|
+
|
|
1010
|
+
// src/plugin-intent/actions.ts
|
|
1011
|
+
var INTENT_PLUGIN = "dxos.org/plugin/intent";
|
|
1012
|
+
var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
1013
|
+
(function(IntentAction2) {
|
|
1014
|
+
class Track extends Schema4.TaggedClass()(`${INTENT_ACTION}/track`, {
|
|
1015
|
+
input: Schema4.Struct({
|
|
1016
|
+
intents: Schema4.Array(Schema4.String),
|
|
1017
|
+
error: Schema4.optional(Schema4.String)
|
|
1018
|
+
}),
|
|
1019
|
+
output: Schema4.Void
|
|
1020
|
+
}) {
|
|
1021
|
+
}
|
|
1022
|
+
IntentAction2.Track = Track;
|
|
1023
|
+
class ShowUndo extends Schema4.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
|
|
1024
|
+
input: Schema4.Struct({
|
|
1025
|
+
message: Label
|
|
1026
|
+
}),
|
|
1027
|
+
output: Schema4.Void
|
|
1028
|
+
}) {
|
|
1029
|
+
}
|
|
1030
|
+
IntentAction2.ShowUndo = ShowUndo;
|
|
1031
|
+
})(IntentAction || (IntentAction = {}));
|
|
1032
|
+
var IntentAction;
|
|
1033
|
+
|
|
1034
|
+
// src/plugin-intent/errors.ts
|
|
1035
|
+
function _define_property4(obj, key, value) {
|
|
1036
|
+
if (key in obj) {
|
|
1037
|
+
Object.defineProperty(obj, key, {
|
|
1038
|
+
value,
|
|
1039
|
+
enumerable: true,
|
|
1040
|
+
configurable: true,
|
|
1041
|
+
writable: true
|
|
1042
|
+
});
|
|
1043
|
+
} else {
|
|
1044
|
+
obj[key] = value;
|
|
1045
|
+
}
|
|
1046
|
+
return obj;
|
|
1047
|
+
}
|
|
1048
|
+
var BaseError = class extends Error {
|
|
1049
|
+
constructor(code, message, context) {
|
|
1050
|
+
super(message ?? code, {
|
|
1051
|
+
cause: context
|
|
1052
|
+
}), _define_property4(this, "code", void 0), _define_property4(this, "context", void 0), this.code = code, this.context = context;
|
|
1053
|
+
this.name = code;
|
|
1054
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
var NoResolversError = class extends BaseError {
|
|
1058
|
+
constructor(action) {
|
|
1059
|
+
super("NO_RESOLVERS", "No resolvers were found for the action", {
|
|
1060
|
+
action
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
var CycleDetectedError = class extends BaseError {
|
|
1065
|
+
constructor(context) {
|
|
1066
|
+
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
|
|
957
1070
|
// src/plugin-intent/IntentPlugin.ts
|
|
958
1071
|
var IntentPlugin = () => definePlugin({
|
|
959
1072
|
id: INTENT_PLUGIN,
|
|
@@ -968,7 +1081,7 @@ var IntentPlugin = () => definePlugin({
|
|
|
968
1081
|
activatesAfter: [
|
|
969
1082
|
Events.DispatcherReady
|
|
970
1083
|
],
|
|
971
|
-
activate: lazy(() => import("./intent-dispatcher-
|
|
1084
|
+
activate: lazy(() => import("./intent-dispatcher-NXBGPJOX.mjs"))
|
|
972
1085
|
})
|
|
973
1086
|
]);
|
|
974
1087
|
|
|
@@ -1338,7 +1451,15 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1338
1451
|
const handleIntent = (intent) => Effect3.gen(function* () {
|
|
1339
1452
|
const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
|
|
1340
1453
|
if (candidates.length === 0) {
|
|
1341
|
-
|
|
1454
|
+
log3.info("no resolvers found", {
|
|
1455
|
+
intent: intent.id
|
|
1456
|
+
}, {
|
|
1457
|
+
F: __dxlog_file3,
|
|
1458
|
+
L: 200,
|
|
1459
|
+
S: this,
|
|
1460
|
+
C: (f, a) => f(...a)
|
|
1461
|
+
});
|
|
1462
|
+
return yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1342
1463
|
}
|
|
1343
1464
|
const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
1344
1465
|
const result = Effect3.isEffect(effect) ? yield* effect : yield* Effect3.promise(async () => effect);
|
|
@@ -1350,7 +1471,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1350
1471
|
const dispatch = (intentChain, depth = 0) => {
|
|
1351
1472
|
return Effect3.gen(function* () {
|
|
1352
1473
|
if (depth > executionLimit) {
|
|
1353
|
-
yield* Effect3.fail(new CycleDetectedError());
|
|
1474
|
+
return yield* Effect3.fail(new CycleDetectedError());
|
|
1354
1475
|
}
|
|
1355
1476
|
const resultsRef = yield* Ref2.make([]);
|
|
1356
1477
|
for (const intent of intentChain.all) {
|
|
@@ -1372,7 +1493,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1372
1493
|
}
|
|
1373
1494
|
}
|
|
1374
1495
|
if (result2.error) {
|
|
1375
|
-
yield* Effect3.fail(result2.error);
|
|
1496
|
+
return yield* Effect3.fail(result2.error);
|
|
1376
1497
|
}
|
|
1377
1498
|
}
|
|
1378
1499
|
const results = yield* resultsRef.get;
|
|
@@ -1401,7 +1522,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1401
1522
|
})).catch((error) => {
|
|
1402
1523
|
log3.catch(error, void 0, {
|
|
1403
1524
|
F: __dxlog_file3,
|
|
1404
|
-
L:
|
|
1525
|
+
L: 272,
|
|
1405
1526
|
S: void 0,
|
|
1406
1527
|
C: (f, a) => f(...a)
|
|
1407
1528
|
});
|
|
@@ -1506,6 +1627,9 @@ export {
|
|
|
1506
1627
|
INTENT_PLUGIN,
|
|
1507
1628
|
INTENT_ACTION,
|
|
1508
1629
|
IntentAction,
|
|
1630
|
+
BaseError,
|
|
1631
|
+
NoResolversError,
|
|
1632
|
+
CycleDetectedError,
|
|
1509
1633
|
createResolver,
|
|
1510
1634
|
createDispatcher,
|
|
1511
1635
|
intent_dispatcher_default,
|
|
@@ -1518,4 +1642,4 @@ export {
|
|
|
1518
1642
|
ResourceLanguage,
|
|
1519
1643
|
Resource
|
|
1520
1644
|
};
|
|
1521
|
-
//# sourceMappingURL=chunk-
|
|
1645
|
+
//# sourceMappingURL=chunk-F63ZRXMK.mjs.map
|