@dxos/app-framework 0.8.4-main.67995b8 → 0.8.4-main.a4bbb77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.mts +11 -0
- package/.storybook/preview.mts +8 -0
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/.swc/plugins/{v7_linux_x86_64_13.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429 → linux_x86_64_19.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429.wasmer-v7} +0 -0
- package/dist/lib/browser/{app-graph-builder-LYF7EKNN.mjs → app-graph-builder-XH4OYQLC.mjs} +25 -25
- package/dist/lib/browser/app-graph-builder-XH4OYQLC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FMN65HSW.mjs → chunk-6V54SRFL.mjs} +388 -269
- package/dist/lib/browser/chunk-6V54SRFL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ORWHM7CO.mjs → chunk-RGKMLI6U.mjs} +10 -7
- package/dist/lib/browser/chunk-RGKMLI6U.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FO2PH7M3.mjs → chunk-ZZVFNUHZ.mjs} +189 -137
- package/dist/lib/browser/chunk-ZZVFNUHZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -28
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-dispatcher-LSYQZSEB.mjs → intent-dispatcher-VFMJVO2M.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-ZTNOSO3A.mjs → intent-resolver-ICAPD4JL.mjs} +5 -5
- package/dist/lib/browser/intent-resolver-ICAPD4JL.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{store-KML2R4IE.mjs → store-7ZGMHOGB.mjs} +4 -4
- package/dist/lib/browser/{store-KML2R4IE.mjs.map → store-7ZGMHOGB.mjs.map} +2 -2
- package/dist/lib/browser/testing/index.mjs +14 -19
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/worker.mjs +7 -9
- package/dist/lib/node-esm/{app-graph-builder-SAOWGJDK.mjs → app-graph-builder-C7H22SOL.mjs} +25 -25
- package/dist/lib/node-esm/app-graph-builder-C7H22SOL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-73HGSHKE.mjs → chunk-AXSZKZFD.mjs} +189 -137
- package/dist/lib/node-esm/chunk-AXSZKZFD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UMZQERLE.mjs → chunk-LKPMRTRR.mjs} +10 -7
- package/dist/lib/node-esm/chunk-LKPMRTRR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZEZ4FVEU.mjs → chunk-SOVTUUAY.mjs} +388 -269
- package/dist/lib/node-esm/chunk-SOVTUUAY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -28
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-dispatcher-6CYNGPSW.mjs → intent-dispatcher-SAPOKSLZ.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-W7Z7WFFM.mjs → intent-resolver-CRNJ6BMD.mjs} +5 -5
- package/dist/lib/node-esm/intent-resolver-CRNJ6BMD.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{store-QEXGXLWZ.mjs → store-H4F4RMYD.mjs} +4 -4
- package/dist/lib/node-esm/{store-QEXGXLWZ.mjs.map → store-H4F4RMYD.mjs.map} +2 -2
- package/dist/lib/node-esm/testing/index.mjs +14 -19
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/worker.mjs +7 -9
- package/dist/types/src/common/capabilities.d.ts +82 -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/layout.d.ts +0 -2
- package/dist/types/src/common/layout.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts +7 -13
- 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 +14 -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/core/plugin.d.ts +4 -1
- package/dist/types/src/core/plugin.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/debug/plugin.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Main.d.ts +1 -1
- package/dist/types/src/playground/generator/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 +1 -1
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -1
- package/dist/types/src/playground/generator/plugin.d.ts +1 -1
- package/dist/types/src/playground/generator/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/layout/Layout.d.ts +2 -2
- package/dist/types/src/playground/layout/plugin.d.ts +1 -1
- package/dist/types/src/playground/layout/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/logger/Toolbar.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/playground.stories.d.ts +5 -4
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/actions.d.ts +4 -6
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/errors.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/index.d.ts +1 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +3 -3
- package/dist/types/src/plugin-intent/intent-dispatcher.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 +4 -6
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +1 -1
- package/dist/types/src/plugin-settings/intent-resolver.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/store.d.ts +1 -1
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/translations.d.ts +2 -1
- package/dist/types/src/plugin-settings/translations.d.ts.map +1 -1
- package/dist/types/src/react/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 +2 -2
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/Surface.stories.d.ts +6 -5
- 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 +6 -6
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts +9 -3
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +4 -0
- package/package.json +37 -35
- package/src/common/capabilities.ts +106 -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/layout.ts +2 -3
- package/src/common/surface.ts +15 -18
- package/src/components/App.stories.tsx +33 -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} +24 -136
- 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 +21 -20
- package/src/core/manager.ts +132 -54
- package/src/core/plugin.ts +8 -2
- package/src/helpers.test.ts +1 -1
- package/src/index.ts +1 -1
- package/src/playground/debug/Debug.tsx +1 -1
- package/src/playground/debug/plugin.ts +7 -8
- package/src/playground/generator/Toolbar.tsx +2 -1
- package/src/playground/generator/generator.ts +3 -3
- package/src/playground/generator/plugin.ts +12 -13
- package/src/playground/layout/plugin.ts +10 -9
- package/src/playground/logger/Toolbar.tsx +2 -1
- package/src/playground/logger/plugin.ts +30 -25
- package/src/playground/playground.stories.tsx +20 -16
- package/src/plugin-intent/IntentPlugin.ts +13 -13
- package/src/plugin-intent/actions.ts +3 -5
- package/src/plugin-intent/errors.ts +1 -0
- 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 +9 -8
- package/src/plugin-intent/meta.ts +10 -0
- package/src/plugin-settings/SettingsPlugin.ts +27 -28
- package/src/plugin-settings/actions.ts +8 -12
- package/src/plugin-settings/app-graph-builder.ts +14 -12
- package/src/plugin-settings/intent-resolver.ts +3 -2
- package/src/plugin-settings/meta.ts +10 -0
- package/src/plugin-settings/store.ts +1 -1
- package/src/plugin-settings/translations.ts +3 -3
- package/src/react/ErrorBoundary.tsx +24 -15
- package/src/react/IntentContext.tsx +3 -2
- package/src/react/Surface.stories.tsx +23 -18
- package/src/react/Surface.tsx +14 -5
- 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 +25 -29
- package/tsconfig.json +1 -8
- package/vitest.config.ts +8 -6
- 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/chunk-ORWHM7CO.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-UMZQERLE.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-VFMJVO2M.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-6CYNGPSW.mjs.map → intent-dispatcher-SAPOKSLZ.mjs.map} +0 -0
|
@@ -1,109 +1,28 @@
|
|
|
1
1
|
// src/plugin-intent/intent-dispatcher.ts
|
|
2
|
-
import { Effect as Effect3, Option,
|
|
2
|
+
import { Effect as Effect3, Option, Ref as Ref2, pipe as pipe2 } from "effect";
|
|
3
3
|
import { live as live2 } from "@dxos/live-object";
|
|
4
4
|
import { log as log3 } from "@dxos/log";
|
|
5
5
|
import { byPosition } from "@dxos/util";
|
|
6
6
|
|
|
7
|
-
// src/plugin-intent/actions.ts
|
|
8
|
-
import { Schema as Schema2 } from "effect";
|
|
9
|
-
|
|
10
|
-
// src/plugin-intent/intent.ts
|
|
11
|
-
import { Schema } from "effect";
|
|
12
|
-
var createIntent = (schema, data = {}, params = {}) => {
|
|
13
|
-
const _ = Schema.validateSync(schema.fields.input)(data);
|
|
14
|
-
const intent = {
|
|
15
|
-
...params,
|
|
16
|
-
_schema: schema,
|
|
17
|
-
id: schema._tag,
|
|
18
|
-
data
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
first: intent,
|
|
22
|
-
last: intent,
|
|
23
|
-
all: [
|
|
24
|
-
intent
|
|
25
|
-
]
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
var chain = (schema, data = {}, params = {}) => (intent) => {
|
|
29
|
-
const intents = "all" in intent ? intent.all : [
|
|
30
|
-
intent
|
|
31
|
-
];
|
|
32
|
-
const first = intents[0];
|
|
33
|
-
const last = {
|
|
34
|
-
...params,
|
|
35
|
-
_schema: schema,
|
|
36
|
-
id: schema._tag,
|
|
37
|
-
data
|
|
38
|
-
};
|
|
39
|
-
return {
|
|
40
|
-
first,
|
|
41
|
-
last,
|
|
42
|
-
all: [
|
|
43
|
-
...intents,
|
|
44
|
-
last
|
|
45
|
-
]
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
var Label = Schema.Union(Schema.String, Schema.mutable(Schema.Tuple(Schema.String, Schema.mutable(Schema.Struct({
|
|
49
|
-
ns: Schema.String,
|
|
50
|
-
count: Schema.optional(Schema.Number),
|
|
51
|
-
defaultValue: Schema.optional(Schema.String)
|
|
52
|
-
})))));
|
|
53
|
-
|
|
54
|
-
// src/plugin-intent/actions.ts
|
|
55
|
-
var INTENT_PLUGIN = "dxos.org/plugin/intent";
|
|
56
|
-
var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
57
|
-
(function(IntentAction2) {
|
|
58
|
-
class Track extends Schema2.TaggedClass()(`${INTENT_ACTION}/track`, {
|
|
59
|
-
input: Schema2.Struct({
|
|
60
|
-
intents: Schema2.Array(Schema2.String),
|
|
61
|
-
error: Schema2.optional(Schema2.String)
|
|
62
|
-
}),
|
|
63
|
-
output: Schema2.Void
|
|
64
|
-
}) {
|
|
65
|
-
}
|
|
66
|
-
IntentAction2.Track = Track;
|
|
67
|
-
class ShowUndo extends Schema2.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
|
|
68
|
-
input: Schema2.Struct({
|
|
69
|
-
message: Label
|
|
70
|
-
}),
|
|
71
|
-
output: Schema2.Void
|
|
72
|
-
}) {
|
|
73
|
-
}
|
|
74
|
-
IntentAction2.ShowUndo = ShowUndo;
|
|
75
|
-
})(IntentAction || (IntentAction = {}));
|
|
76
|
-
var IntentAction;
|
|
77
|
-
|
|
78
|
-
// src/plugin-intent/errors.ts
|
|
79
|
-
var BaseError = class extends Error {
|
|
80
|
-
constructor(code, message, context) {
|
|
81
|
-
super(message ?? code, {
|
|
82
|
-
cause: context
|
|
83
|
-
}), this.code = code, this.context = context;
|
|
84
|
-
this.name = code;
|
|
85
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
var NoResolversError = class extends BaseError {
|
|
89
|
-
constructor(action) {
|
|
90
|
-
super("NO_RESOLVERS", "No resolvers were found for the action", {
|
|
91
|
-
action
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var CycleDetectedError = class extends BaseError {
|
|
96
|
-
constructor(context) {
|
|
97
|
-
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
7
|
// src/core/capabilities.ts
|
|
102
8
|
import { Rx } from "@effect-rx/rx-react";
|
|
103
9
|
import { Effect } from "effect";
|
|
104
10
|
import { Trigger } from "@dxos/async";
|
|
105
11
|
import { invariant } from "@dxos/invariant";
|
|
106
12
|
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
|
+
}
|
|
107
26
|
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
|
|
108
27
|
var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
|
|
109
28
|
var defineCapability = (identifier) => {
|
|
@@ -113,6 +32,8 @@ var defineCapability = (identifier) => {
|
|
|
113
32
|
};
|
|
114
33
|
var CapabilityImpl = class {
|
|
115
34
|
constructor(moduleId, implementation) {
|
|
35
|
+
_define_property(this, "moduleId", void 0);
|
|
36
|
+
_define_property(this, "implementation", void 0);
|
|
116
37
|
this.moduleId = moduleId;
|
|
117
38
|
this.implementation = implementation;
|
|
118
39
|
}
|
|
@@ -129,35 +50,6 @@ var lazy = (c) => async (props) => {
|
|
|
129
50
|
return async () => getCapability(props);
|
|
130
51
|
};
|
|
131
52
|
var PluginContext = class {
|
|
132
|
-
constructor({ registry, activate, reset }) {
|
|
133
|
-
this._capabilityImpls = Rx.family(() => {
|
|
134
|
-
return Rx.make([]).pipe(Rx.keepAlive);
|
|
135
|
-
});
|
|
136
|
-
this._capabilities = Rx.family((id) => {
|
|
137
|
-
return Rx.make((get) => {
|
|
138
|
-
const current = get(this._capabilityImpls(id));
|
|
139
|
-
return current.map((c) => c.implementation);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
this._capability = Rx.family((id) => {
|
|
143
|
-
return Rx.make((get) => {
|
|
144
|
-
const current = get(this._capabilities(id));
|
|
145
|
-
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
146
|
-
F: __dxlog_file,
|
|
147
|
-
L: 117,
|
|
148
|
-
S: this,
|
|
149
|
-
A: [
|
|
150
|
-
"current.length > 0",
|
|
151
|
-
"`No capability found for ${id}`"
|
|
152
|
-
]
|
|
153
|
-
});
|
|
154
|
-
return current[0];
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
this._registry = registry;
|
|
158
|
-
this.activate = activate;
|
|
159
|
-
this.reset = reset;
|
|
160
|
-
}
|
|
161
53
|
/**
|
|
162
54
|
* @internal
|
|
163
55
|
*/
|
|
@@ -177,7 +69,7 @@ var PluginContext = class {
|
|
|
177
69
|
count: current.length
|
|
178
70
|
}, {
|
|
179
71
|
F: __dxlog_file,
|
|
180
|
-
L:
|
|
72
|
+
L: 166,
|
|
181
73
|
S: this,
|
|
182
74
|
C: (f, a) => f(...a)
|
|
183
75
|
});
|
|
@@ -198,7 +90,7 @@ var PluginContext = class {
|
|
|
198
90
|
count: current.length
|
|
199
91
|
}, {
|
|
200
92
|
F: __dxlog_file,
|
|
201
|
-
L:
|
|
93
|
+
L: 185,
|
|
202
94
|
S: this,
|
|
203
95
|
C: (f, a) => f(...a)
|
|
204
96
|
});
|
|
@@ -207,7 +99,7 @@ var PluginContext = class {
|
|
|
207
99
|
id: interfaceDef.identifier
|
|
208
100
|
}, {
|
|
209
101
|
F: __dxlog_file,
|
|
210
|
-
L:
|
|
102
|
+
L: 187,
|
|
211
103
|
S: this,
|
|
212
104
|
C: (f, a) => f(...a)
|
|
213
105
|
});
|
|
@@ -272,6 +164,38 @@ var PluginContext = class {
|
|
|
272
164
|
async resetPromise(event) {
|
|
273
165
|
return this.reset(event).pipe(Effect.runPromise);
|
|
274
166
|
}
|
|
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
|
+
}
|
|
275
199
|
};
|
|
276
200
|
|
|
277
201
|
// src/core/events.ts
|
|
@@ -299,38 +223,28 @@ var getEvents = (events) => "type" in events ? events.events : [
|
|
|
299
223
|
// src/core/manager.ts
|
|
300
224
|
import { Registry } from "@effect-rx/rx-react";
|
|
301
225
|
import { untracked } from "@preact/signals-core";
|
|
302
|
-
import { Array
|
|
226
|
+
import { Array, Duration, Effect as Effect2, Fiber, HashSet, Match, Ref, pipe } from "effect";
|
|
303
227
|
import { Event } from "@dxos/async";
|
|
304
228
|
import { live } from "@dxos/live-object";
|
|
305
229
|
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
|
+
}
|
|
306
243
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
|
|
307
244
|
var isPromise = (value) => {
|
|
308
245
|
return value !== null && typeof value === "object" && "then" in value;
|
|
309
246
|
};
|
|
310
247
|
var PluginManager = class {
|
|
311
|
-
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry }) {
|
|
312
|
-
this.activation = new Event();
|
|
313
|
-
this._capabilities = /* @__PURE__ */ new Map();
|
|
314
|
-
this.registry = registry ?? Registry.make();
|
|
315
|
-
this.context = new PluginContext({
|
|
316
|
-
registry: this.registry,
|
|
317
|
-
activate: (event) => this._activate(event),
|
|
318
|
-
reset: (id) => this._reset(id)
|
|
319
|
-
});
|
|
320
|
-
this._pluginLoader = pluginLoader;
|
|
321
|
-
this._state = live({
|
|
322
|
-
plugins,
|
|
323
|
-
core,
|
|
324
|
-
enabled,
|
|
325
|
-
modules: [],
|
|
326
|
-
active: [],
|
|
327
|
-
pendingReset: [],
|
|
328
|
-
eventsFired: []
|
|
329
|
-
});
|
|
330
|
-
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
331
|
-
core.forEach((id) => this.enable(id));
|
|
332
|
-
enabled.forEach((id) => this.enable(id));
|
|
333
|
-
}
|
|
334
248
|
/**
|
|
335
249
|
* Plugins that are currently registered.
|
|
336
250
|
*
|
|
@@ -397,7 +311,7 @@ var PluginManager = class {
|
|
|
397
311
|
id
|
|
398
312
|
}, {
|
|
399
313
|
F: __dxlog_file2,
|
|
400
|
-
L:
|
|
314
|
+
L: 157,
|
|
401
315
|
S: this,
|
|
402
316
|
C: (f, a) => f(...a)
|
|
403
317
|
});
|
|
@@ -416,7 +330,7 @@ var PluginManager = class {
|
|
|
416
330
|
id
|
|
417
331
|
}, {
|
|
418
332
|
F: __dxlog_file2,
|
|
419
|
-
L:
|
|
333
|
+
L: 170,
|
|
420
334
|
S: this,
|
|
421
335
|
C: (f, a) => f(...a)
|
|
422
336
|
});
|
|
@@ -437,7 +351,7 @@ var PluginManager = class {
|
|
|
437
351
|
]
|
|
438
352
|
}, {
|
|
439
353
|
F: __dxlog_file2,
|
|
440
|
-
L:
|
|
354
|
+
L: 185,
|
|
441
355
|
S: this,
|
|
442
356
|
C: (f, a) => f(...a)
|
|
443
357
|
});
|
|
@@ -457,7 +371,7 @@ var PluginManager = class {
|
|
|
457
371
|
id
|
|
458
372
|
}, {
|
|
459
373
|
F: __dxlog_file2,
|
|
460
|
-
L:
|
|
374
|
+
L: 203,
|
|
461
375
|
S: this,
|
|
462
376
|
C: (f, a) => f(...a)
|
|
463
377
|
});
|
|
@@ -479,7 +393,7 @@ var PluginManager = class {
|
|
|
479
393
|
id
|
|
480
394
|
}, {
|
|
481
395
|
F: __dxlog_file2,
|
|
482
|
-
L:
|
|
396
|
+
L: 220,
|
|
483
397
|
S: this,
|
|
484
398
|
C: (f, a) => f(...a)
|
|
485
399
|
});
|
|
@@ -531,7 +445,7 @@ var PluginManager = class {
|
|
|
531
445
|
id: plugin.meta.id
|
|
532
446
|
}, {
|
|
533
447
|
F: __dxlog_file2,
|
|
534
|
-
L:
|
|
448
|
+
L: 273,
|
|
535
449
|
S: this,
|
|
536
450
|
C: (f, a) => f(...a)
|
|
537
451
|
});
|
|
@@ -546,7 +460,7 @@ var PluginManager = class {
|
|
|
546
460
|
id
|
|
547
461
|
}, {
|
|
548
462
|
F: __dxlog_file2,
|
|
549
|
-
L:
|
|
463
|
+
L: 283,
|
|
550
464
|
S: this,
|
|
551
465
|
C: (f, a) => f(...a)
|
|
552
466
|
});
|
|
@@ -562,7 +476,7 @@ var PluginManager = class {
|
|
|
562
476
|
id: module.id
|
|
563
477
|
}, {
|
|
564
478
|
F: __dxlog_file2,
|
|
565
|
-
L:
|
|
479
|
+
L: 293,
|
|
566
480
|
S: this,
|
|
567
481
|
C: (f, a) => f(...a)
|
|
568
482
|
});
|
|
@@ -577,7 +491,7 @@ var PluginManager = class {
|
|
|
577
491
|
id
|
|
578
492
|
}, {
|
|
579
493
|
F: __dxlog_file2,
|
|
580
|
-
L:
|
|
494
|
+
L: 303,
|
|
581
495
|
S: this,
|
|
582
496
|
C: (f, a) => f(...a)
|
|
583
497
|
});
|
|
@@ -605,13 +519,13 @@ var PluginManager = class {
|
|
|
605
519
|
_setPendingResetByModule(module) {
|
|
606
520
|
return untracked(() => {
|
|
607
521
|
const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
|
|
608
|
-
const pendingReset = Array.
|
|
522
|
+
const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
|
|
609
523
|
if (pendingReset.length > 0) {
|
|
610
524
|
log2("pending reset", {
|
|
611
525
|
events: pendingReset
|
|
612
526
|
}, {
|
|
613
527
|
F: __dxlog_file2,
|
|
614
|
-
L:
|
|
528
|
+
L: 341,
|
|
615
529
|
S: this,
|
|
616
530
|
C: (f, a) => f(...a)
|
|
617
531
|
});
|
|
@@ -623,35 +537,40 @@ var PluginManager = class {
|
|
|
623
537
|
* @internal
|
|
624
538
|
*/
|
|
625
539
|
// TODO(wittjosiah): Improve error typing.
|
|
626
|
-
_activate(event) {
|
|
540
|
+
_activate(event, params) {
|
|
627
541
|
return Effect2.gen(this, function* () {
|
|
628
542
|
const key = typeof event === "string" ? event : eventKey(event);
|
|
629
543
|
log2("activating", {
|
|
630
|
-
key
|
|
544
|
+
key,
|
|
545
|
+
...params
|
|
631
546
|
}, {
|
|
632
547
|
F: __dxlog_file2,
|
|
633
|
-
L:
|
|
548
|
+
L: 357,
|
|
634
549
|
S: this,
|
|
635
550
|
C: (f, a) => f(...a)
|
|
636
551
|
});
|
|
552
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
|
|
637
553
|
const pendingIndex = this._state.pendingReset.findIndex((event2) => event2 === key);
|
|
638
554
|
if (pendingIndex !== -1) {
|
|
639
555
|
this._state.pendingReset.splice(pendingIndex, 1);
|
|
640
556
|
}
|
|
557
|
+
const activatingEvents = yield* this._activatingEvents;
|
|
558
|
+
const activatingModules = yield* this._activatingModules;
|
|
641
559
|
const modules = this._getInactiveModulesByEvent(key).filter((module) => {
|
|
642
560
|
const allOf2 = isAllOf(module.activatesOn);
|
|
643
561
|
if (!allOf2) {
|
|
644
562
|
return true;
|
|
645
563
|
}
|
|
646
564
|
const events = module.activatesOn.events.filter((event2) => eventKey(event2) !== key);
|
|
647
|
-
return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)));
|
|
565
|
+
return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)) || activatingEvents.includes(eventKey(event2))) && !activatingModules.includes(module.id);
|
|
648
566
|
});
|
|
567
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, modules.map((module) => module.id)));
|
|
649
568
|
if (modules.length === 0) {
|
|
650
569
|
log2("no modules to activate", {
|
|
651
570
|
key
|
|
652
571
|
}, {
|
|
653
572
|
F: __dxlog_file2,
|
|
654
|
-
L:
|
|
573
|
+
L: 388,
|
|
655
574
|
S: this,
|
|
656
575
|
C: (f, a) => f(...a)
|
|
657
576
|
});
|
|
@@ -665,7 +584,7 @@ var PluginManager = class {
|
|
|
665
584
|
modules: modules.map((module) => module.id)
|
|
666
585
|
}, {
|
|
667
586
|
F: __dxlog_file2,
|
|
668
|
-
L:
|
|
587
|
+
L: 395,
|
|
669
588
|
S: this,
|
|
670
589
|
C: (f, a) => f(...a)
|
|
671
590
|
});
|
|
@@ -673,29 +592,36 @@ var PluginManager = class {
|
|
|
673
592
|
event: key,
|
|
674
593
|
state: "activating"
|
|
675
594
|
});
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
})), {
|
|
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, {
|
|
596
|
+
before: key
|
|
597
|
+
})), Effect2.allWith({
|
|
680
598
|
concurrency: "unbounded"
|
|
681
|
-
});
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
A.map(([module, getCapabilities2]) => this._activateModule(module, getCapabilities2)),
|
|
686
|
-
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
687
|
-
// Running this with concurrency causes races with `allOf` activation events.
|
|
688
|
-
Effect2.all,
|
|
689
|
-
Effect2.either
|
|
690
|
-
);
|
|
691
|
-
if (Either.isLeft(result)) {
|
|
599
|
+
}));
|
|
600
|
+
const getCapabilities = yield* pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
|
|
601
|
+
concurrency: "unbounded"
|
|
602
|
+
}), Effect2.catchAll((error) => {
|
|
692
603
|
this.activation.emit({
|
|
693
604
|
event: key,
|
|
694
605
|
state: "error",
|
|
695
|
-
error
|
|
606
|
+
error
|
|
696
607
|
});
|
|
697
|
-
|
|
698
|
-
}
|
|
608
|
+
return Effect2.fail(error);
|
|
609
|
+
}));
|
|
610
|
+
yield* pipe(
|
|
611
|
+
modules,
|
|
612
|
+
Array.zip(getCapabilities),
|
|
613
|
+
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
|
+
Effect2.all
|
|
617
|
+
);
|
|
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, {
|
|
619
|
+
after: key
|
|
620
|
+
})), Effect2.allWith({
|
|
621
|
+
concurrency: "unbounded"
|
|
622
|
+
}));
|
|
623
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event2) => event2 !== key));
|
|
624
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !modules.map((module2) => module2.id).includes(module)));
|
|
699
625
|
if (!this._state.eventsFired.includes(key)) {
|
|
700
626
|
this._state.eventsFired.push(key);
|
|
701
627
|
}
|
|
@@ -707,39 +633,15 @@ var PluginManager = class {
|
|
|
707
633
|
key
|
|
708
634
|
}, {
|
|
709
635
|
F: __dxlog_file2,
|
|
710
|
-
L:
|
|
636
|
+
L: 451,
|
|
711
637
|
S: this,
|
|
712
638
|
C: (f, a) => f(...a)
|
|
713
639
|
});
|
|
714
640
|
return true;
|
|
715
641
|
});
|
|
716
642
|
}
|
|
717
|
-
|
|
643
|
+
_contributeCapabilities(module, capabilities) {
|
|
718
644
|
return Effect2.gen(this, function* () {
|
|
719
|
-
yield* Effect2.all(module.activatesBefore?.map((event) => this._activate(event)) ?? [], {
|
|
720
|
-
concurrency: "unbounded"
|
|
721
|
-
});
|
|
722
|
-
log2("activating module...", {
|
|
723
|
-
module: module.id
|
|
724
|
-
}, {
|
|
725
|
-
F: __dxlog_file2,
|
|
726
|
-
L: 421,
|
|
727
|
-
S: this,
|
|
728
|
-
C: (f, a) => f(...a)
|
|
729
|
-
});
|
|
730
|
-
const maybeCapabilities = typeof getCapabilities === "function" ? getCapabilities() : getCapabilities;
|
|
731
|
-
const resolvedCapabilities = yield* Match.value(maybeCapabilities).pipe(
|
|
732
|
-
// TODO(wittjosiah): Activate with an effect?
|
|
733
|
-
// Match.when(Effect.isEffect, (effect) => effect),
|
|
734
|
-
Match.when(isPromise, (promise) => Effect2.tryPromise({
|
|
735
|
-
try: () => promise,
|
|
736
|
-
catch: (error) => error
|
|
737
|
-
})),
|
|
738
|
-
Match.orElse((program) => Effect2.succeed(program))
|
|
739
|
-
);
|
|
740
|
-
const capabilities = Match.value(resolvedCapabilities).pipe(Match.when(Array.isArray, (array) => array), Match.orElse((value) => [
|
|
741
|
-
value
|
|
742
|
-
]));
|
|
743
645
|
capabilities.forEach((capability) => {
|
|
744
646
|
this.context.contributeCapability({
|
|
745
647
|
module: module.id,
|
|
@@ -748,17 +650,6 @@ var PluginManager = class {
|
|
|
748
650
|
});
|
|
749
651
|
this._state.active.push(module.id);
|
|
750
652
|
this._capabilities.set(module.id, capabilities);
|
|
751
|
-
log2("activated module", {
|
|
752
|
-
module: module.id
|
|
753
|
-
}, {
|
|
754
|
-
F: __dxlog_file2,
|
|
755
|
-
L: 444,
|
|
756
|
-
S: this,
|
|
757
|
-
C: (f, a) => f(...a)
|
|
758
|
-
});
|
|
759
|
-
yield* Effect2.all(module.activatesAfter?.map((event) => this._activate(event)) ?? [], {
|
|
760
|
-
concurrency: "unbounded"
|
|
761
|
-
});
|
|
762
653
|
});
|
|
763
654
|
}
|
|
764
655
|
_deactivate(id) {
|
|
@@ -781,10 +672,11 @@ var PluginManager = class {
|
|
|
781
672
|
id
|
|
782
673
|
}, {
|
|
783
674
|
F: __dxlog_file2,
|
|
784
|
-
L:
|
|
675
|
+
L: 533,
|
|
785
676
|
S: this,
|
|
786
677
|
C: (f, a) => f(...a)
|
|
787
678
|
});
|
|
679
|
+
this._moduleMemoMap.delete(id);
|
|
788
680
|
const capabilities = this._capabilities.get(id);
|
|
789
681
|
if (capabilities) {
|
|
790
682
|
for (const capability of capabilities) {
|
|
@@ -805,7 +697,7 @@ var PluginManager = class {
|
|
|
805
697
|
id
|
|
806
698
|
}, {
|
|
807
699
|
F: __dxlog_file2,
|
|
808
|
-
L:
|
|
700
|
+
L: 560,
|
|
809
701
|
S: this,
|
|
810
702
|
C: (f, a) => f(...a)
|
|
811
703
|
});
|
|
@@ -819,7 +711,7 @@ var PluginManager = class {
|
|
|
819
711
|
key
|
|
820
712
|
}, {
|
|
821
713
|
F: __dxlog_file2,
|
|
822
|
-
L:
|
|
714
|
+
L: 568,
|
|
823
715
|
S: this,
|
|
824
716
|
C: (f, a) => f(...a)
|
|
825
717
|
});
|
|
@@ -834,11 +726,125 @@ var PluginManager = class {
|
|
|
834
726
|
}
|
|
835
727
|
});
|
|
836
728
|
}
|
|
729
|
+
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.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
|
+
}
|
|
837
819
|
};
|
|
820
|
+
var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
821
|
+
const togetherFiber = yield* Effect2.fork(togetherEffect);
|
|
822
|
+
const result = yield* effect;
|
|
823
|
+
yield* Fiber.interrupt(togetherFiber);
|
|
824
|
+
return result;
|
|
825
|
+
});
|
|
838
826
|
|
|
839
827
|
// 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
|
+
}
|
|
840
841
|
var PluginModule = class {
|
|
841
842
|
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);
|
|
842
848
|
this.id = options.id;
|
|
843
849
|
this.activatesOn = options.activatesOn;
|
|
844
850
|
this.activatesBefore = options.activatesBefore;
|
|
@@ -848,13 +854,20 @@ var PluginModule = class {
|
|
|
848
854
|
};
|
|
849
855
|
var defineModule = (options) => new PluginModule(options);
|
|
850
856
|
var Plugin = class {
|
|
851
|
-
constructor(
|
|
852
|
-
this
|
|
857
|
+
constructor(meta2, modules) {
|
|
858
|
+
_define_property3(this, "meta", void 0);
|
|
859
|
+
_define_property3(this, "modules", void 0);
|
|
860
|
+
this.meta = meta2;
|
|
853
861
|
this.modules = modules;
|
|
854
862
|
}
|
|
855
863
|
};
|
|
856
|
-
var definePlugin = (
|
|
857
|
-
|
|
864
|
+
var definePlugin = (meta2, provider) => {
|
|
865
|
+
const factory = (args) => {
|
|
866
|
+
return new Plugin(meta2, provider(args));
|
|
867
|
+
};
|
|
868
|
+
return Object.assign(factory, {
|
|
869
|
+
meta: meta2
|
|
870
|
+
});
|
|
858
871
|
};
|
|
859
872
|
|
|
860
873
|
// src/common/capabilities.ts
|
|
@@ -875,8 +888,11 @@ var definePlugin = (meta, modules) => {
|
|
|
875
888
|
Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
|
|
876
889
|
Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
|
|
877
890
|
Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
|
|
878
|
-
Capabilities2.
|
|
879
|
-
Capabilities2.
|
|
891
|
+
Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
|
|
892
|
+
Capabilities2.ToolkitHandler = defineCapability("dxos.org/app-framework/capability/ai-toolkit-handler");
|
|
893
|
+
Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
|
|
894
|
+
Capabilities2.AiServiceLayer = defineCapability("dxos.org/app-framework/capability/ai-service-factory");
|
|
895
|
+
Capabilities2.AiModelResolver = defineCapability("dxos.org/app-framework/capability/ai-model-resolver");
|
|
880
896
|
Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
|
|
881
897
|
Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
|
|
882
898
|
Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
|
|
@@ -884,22 +900,19 @@ var definePlugin = (meta, modules) => {
|
|
|
884
900
|
var Capabilities;
|
|
885
901
|
|
|
886
902
|
// src/common/collaboration.ts
|
|
887
|
-
import { Schema
|
|
888
|
-
import {
|
|
903
|
+
import { Schema } from "effect";
|
|
904
|
+
import { DataType } from "@dxos/schema";
|
|
889
905
|
(function(CollaborationActions2) {
|
|
890
|
-
class
|
|
891
|
-
input:
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
label: Schema3.String.pipe(Schema3.optional)
|
|
896
|
-
}).annotations({
|
|
897
|
-
description: "Enables plugins to inject content blocks or references into a related entity."
|
|
906
|
+
class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
|
|
907
|
+
input: Schema.Struct({
|
|
908
|
+
subject: Schema.Any,
|
|
909
|
+
anchor: Schema.String,
|
|
910
|
+
proposal: DataType.MessageBlock.Proposal
|
|
898
911
|
}),
|
|
899
|
-
output:
|
|
912
|
+
output: Schema.Void
|
|
900
913
|
}) {
|
|
901
914
|
}
|
|
902
|
-
CollaborationActions2.
|
|
915
|
+
CollaborationActions2.AcceptProposal = AcceptProposal;
|
|
903
916
|
})(CollaborationActions || (CollaborationActions = {}));
|
|
904
917
|
var CollaborationActions;
|
|
905
918
|
|
|
@@ -922,7 +935,7 @@ var CollaborationActions;
|
|
|
922
935
|
var Events;
|
|
923
936
|
|
|
924
937
|
// src/common/file.ts
|
|
925
|
-
import { Schema as
|
|
938
|
+
import { Schema as Schema2 } from "effect";
|
|
926
939
|
var defaultFileTypes = {
|
|
927
940
|
images: [
|
|
928
941
|
"png",
|
|
@@ -942,23 +955,131 @@ var defaultFileTypes = {
|
|
|
942
955
|
"md"
|
|
943
956
|
]
|
|
944
957
|
};
|
|
945
|
-
var FileInfoSchema =
|
|
946
|
-
name:
|
|
947
|
-
type:
|
|
948
|
-
url:
|
|
949
|
-
cid:
|
|
958
|
+
var FileInfoSchema = Schema2.Struct({
|
|
959
|
+
name: Schema2.String,
|
|
960
|
+
type: Schema2.String,
|
|
961
|
+
url: Schema2.optional(Schema2.String),
|
|
962
|
+
cid: Schema2.optional(Schema2.String)
|
|
950
963
|
});
|
|
951
964
|
|
|
952
965
|
// src/common/layout.ts
|
|
953
966
|
import { Schema as Schema5 } from "effect";
|
|
954
967
|
|
|
955
|
-
// src/plugin-intent/
|
|
956
|
-
|
|
957
|
-
|
|
968
|
+
// src/plugin-intent/actions.ts
|
|
969
|
+
import { Schema as Schema4 } from "effect";
|
|
970
|
+
|
|
971
|
+
// src/plugin-intent/intent.ts
|
|
972
|
+
import { Schema as Schema3 } from "effect";
|
|
973
|
+
var createIntent = (schema, data = {}, params = {}) => {
|
|
974
|
+
const _ = Schema3.validateSync(schema.fields.input)(data);
|
|
975
|
+
const intent = {
|
|
976
|
+
...params,
|
|
977
|
+
_schema: schema,
|
|
978
|
+
id: schema._tag,
|
|
979
|
+
data
|
|
980
|
+
};
|
|
981
|
+
return {
|
|
982
|
+
first: intent,
|
|
983
|
+
last: intent,
|
|
984
|
+
all: [
|
|
985
|
+
intent
|
|
986
|
+
]
|
|
987
|
+
};
|
|
988
|
+
};
|
|
989
|
+
var chain = (schema, data = {}, params = {}) => (intent) => {
|
|
990
|
+
const intents = "all" in intent ? intent.all : [
|
|
991
|
+
intent
|
|
992
|
+
];
|
|
993
|
+
const first = intents[0];
|
|
994
|
+
const last = {
|
|
995
|
+
...params,
|
|
996
|
+
_schema: schema,
|
|
997
|
+
id: schema._tag,
|
|
998
|
+
data
|
|
999
|
+
};
|
|
1000
|
+
return {
|
|
1001
|
+
first,
|
|
1002
|
+
last,
|
|
1003
|
+
all: [
|
|
1004
|
+
...intents,
|
|
1005
|
+
last
|
|
1006
|
+
]
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.String, Schema3.mutable(Schema3.Struct({
|
|
1010
|
+
ns: Schema3.String,
|
|
1011
|
+
count: Schema3.optional(Schema3.Number),
|
|
1012
|
+
defaultValue: Schema3.optional(Schema3.String)
|
|
1013
|
+
})))));
|
|
1014
|
+
|
|
1015
|
+
// src/plugin-intent/meta.ts
|
|
1016
|
+
var meta = {
|
|
1017
|
+
id: "dxos.org/plugin/intent",
|
|
958
1018
|
name: "Intent"
|
|
959
|
-
}
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
// src/plugin-intent/actions.ts
|
|
1022
|
+
(function(IntentAction2) {
|
|
1023
|
+
class Track extends Schema4.TaggedClass()(`${meta.id}/action/track`, {
|
|
1024
|
+
input: Schema4.Struct({
|
|
1025
|
+
intents: Schema4.Array(Schema4.String),
|
|
1026
|
+
error: Schema4.optional(Schema4.String)
|
|
1027
|
+
}),
|
|
1028
|
+
output: Schema4.Void
|
|
1029
|
+
}) {
|
|
1030
|
+
}
|
|
1031
|
+
IntentAction2.Track = Track;
|
|
1032
|
+
class ShowUndo extends Schema4.TaggedClass()(`${meta.id}/action/show-undo`, {
|
|
1033
|
+
input: Schema4.Struct({
|
|
1034
|
+
message: Label
|
|
1035
|
+
}),
|
|
1036
|
+
output: Schema4.Void
|
|
1037
|
+
}) {
|
|
1038
|
+
}
|
|
1039
|
+
IntentAction2.ShowUndo = ShowUndo;
|
|
1040
|
+
})(IntentAction || (IntentAction = {}));
|
|
1041
|
+
var IntentAction;
|
|
1042
|
+
|
|
1043
|
+
// src/plugin-intent/errors.ts
|
|
1044
|
+
function _define_property4(obj, key, value) {
|
|
1045
|
+
if (key in obj) {
|
|
1046
|
+
Object.defineProperty(obj, key, {
|
|
1047
|
+
value,
|
|
1048
|
+
enumerable: true,
|
|
1049
|
+
configurable: true,
|
|
1050
|
+
writable: true
|
|
1051
|
+
});
|
|
1052
|
+
} else {
|
|
1053
|
+
obj[key] = value;
|
|
1054
|
+
}
|
|
1055
|
+
return obj;
|
|
1056
|
+
}
|
|
1057
|
+
var BaseError = class extends Error {
|
|
1058
|
+
constructor(code, message, context) {
|
|
1059
|
+
super(message ?? code, {
|
|
1060
|
+
cause: context
|
|
1061
|
+
}), _define_property4(this, "code", void 0), _define_property4(this, "context", void 0), this.code = code, this.context = context;
|
|
1062
|
+
this.name = code;
|
|
1063
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
var NoResolversError = class extends BaseError {
|
|
1067
|
+
constructor(action) {
|
|
1068
|
+
super("NO_RESOLVERS", "No resolvers were found for the action", {
|
|
1069
|
+
action
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
var CycleDetectedError = class extends BaseError {
|
|
1074
|
+
constructor(context) {
|
|
1075
|
+
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
|
|
1079
|
+
// src/plugin-intent/IntentPlugin.ts
|
|
1080
|
+
var IntentPlugin = definePlugin(meta, () => [
|
|
960
1081
|
defineModule({
|
|
961
|
-
id: `${
|
|
1082
|
+
id: `${meta.id}/module/dispatcher`,
|
|
962
1083
|
// TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
|
|
963
1084
|
// This is fine for now because it's how it worked prior to capabilities api anyways.
|
|
964
1085
|
// In the future, the intent dispatcher should be able to be reset without resetting the entire app.
|
|
@@ -966,15 +1087,14 @@ var IntentPlugin = () => definePlugin({
|
|
|
966
1087
|
activatesAfter: [
|
|
967
1088
|
Events.DispatcherReady
|
|
968
1089
|
],
|
|
969
|
-
activate: lazy(() => import("./intent-dispatcher-
|
|
1090
|
+
activate: lazy(() => import("./intent-dispatcher-VFMJVO2M.mjs"))
|
|
970
1091
|
})
|
|
971
1092
|
]);
|
|
972
1093
|
|
|
973
1094
|
// src/common/layout.ts
|
|
974
1095
|
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
|
|
975
|
-
var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
|
|
976
1096
|
(function(LayoutAction2) {
|
|
977
|
-
LayoutAction2.UPDATE_LAYOUT = `${
|
|
1097
|
+
LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_PLUGIN}/action/update-layout`;
|
|
978
1098
|
class UpdateLayout extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
979
1099
|
input: Schema5.Struct({
|
|
980
1100
|
part: Schema5.String.annotations({
|
|
@@ -1336,7 +1456,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1336
1456
|
const handleIntent = (intent) => Effect3.gen(function* () {
|
|
1337
1457
|
const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
|
|
1338
1458
|
if (candidates.length === 0) {
|
|
1339
|
-
yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1459
|
+
return yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1340
1460
|
}
|
|
1341
1461
|
const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
1342
1462
|
const result = Effect3.isEffect(effect) ? yield* effect : yield* Effect3.promise(async () => effect);
|
|
@@ -1348,7 +1468,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1348
1468
|
const dispatch = (intentChain, depth = 0) => {
|
|
1349
1469
|
return Effect3.gen(function* () {
|
|
1350
1470
|
if (depth > executionLimit) {
|
|
1351
|
-
yield* Effect3.fail(new CycleDetectedError());
|
|
1471
|
+
return yield* Effect3.fail(new CycleDetectedError());
|
|
1352
1472
|
}
|
|
1353
1473
|
const resultsRef = yield* Ref2.make([]);
|
|
1354
1474
|
for (const intent of intentChain.all) {
|
|
@@ -1370,7 +1490,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1370
1490
|
}
|
|
1371
1491
|
}
|
|
1372
1492
|
if (result2.error) {
|
|
1373
|
-
yield* Effect3.fail(result2.error);
|
|
1493
|
+
return yield* Effect3.fail(result2.error);
|
|
1374
1494
|
}
|
|
1375
1495
|
}
|
|
1376
1496
|
const results = yield* resultsRef.get;
|
|
@@ -1399,7 +1519,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1399
1519
|
})).catch((error) => {
|
|
1400
1520
|
log3.catch(error, void 0, {
|
|
1401
1521
|
F: __dxlog_file3,
|
|
1402
|
-
L:
|
|
1522
|
+
L: 271,
|
|
1403
1523
|
S: void 0,
|
|
1404
1524
|
C: (f, a) => f(...a)
|
|
1405
1525
|
});
|
|
@@ -1452,7 +1572,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1452
1572
|
};
|
|
1453
1573
|
var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
|
|
1454
1574
|
var defaultPromise = () => Effect3.runPromise(defaultEffect());
|
|
1455
|
-
var intent_dispatcher_default = (context) => {
|
|
1575
|
+
var intent_dispatcher_default = ((context) => {
|
|
1456
1576
|
const state = live2({
|
|
1457
1577
|
dispatch: defaultEffect,
|
|
1458
1578
|
dispatchPromise: defaultPromise,
|
|
@@ -1474,7 +1594,7 @@ var intent_dispatcher_default = (context) => {
|
|
|
1474
1594
|
state.undo = undo;
|
|
1475
1595
|
state.undoPromise = undoPromise;
|
|
1476
1596
|
return contributes(Capabilities.IntentDispatcher, state);
|
|
1477
|
-
};
|
|
1597
|
+
});
|
|
1478
1598
|
|
|
1479
1599
|
export {
|
|
1480
1600
|
defineCapability,
|
|
@@ -1501,19 +1621,18 @@ export {
|
|
|
1501
1621
|
createIntent,
|
|
1502
1622
|
chain,
|
|
1503
1623
|
Label,
|
|
1504
|
-
INTENT_PLUGIN,
|
|
1505
|
-
INTENT_ACTION,
|
|
1506
1624
|
IntentAction,
|
|
1625
|
+
BaseError,
|
|
1626
|
+
NoResolversError,
|
|
1627
|
+
CycleDetectedError,
|
|
1507
1628
|
createResolver,
|
|
1508
1629
|
createDispatcher,
|
|
1509
1630
|
intent_dispatcher_default,
|
|
1510
1631
|
IntentPlugin,
|
|
1511
|
-
LAYOUT_PLUGIN,
|
|
1512
|
-
LAYOUT_ACTION,
|
|
1513
1632
|
LayoutAction,
|
|
1514
1633
|
createSurface,
|
|
1515
1634
|
ResourceKey,
|
|
1516
1635
|
ResourceLanguage,
|
|
1517
1636
|
Resource
|
|
1518
1637
|
};
|
|
1519
|
-
//# sourceMappingURL=chunk-
|
|
1638
|
+
//# sourceMappingURL=chunk-6V54SRFL.mjs.map
|