@dxos/app-framework 0.8.4-main.3f58842 → 0.8.4-main.548089c
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-JPUFNED5.mjs} +32 -31
- package/dist/lib/browser/app-graph-builder-JPUFNED5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FMN65HSW.mjs → chunk-LVSO2N4X.mjs} +351 -263
- package/dist/lib/browser/chunk-LVSO2N4X.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ORWHM7CO.mjs → chunk-SCPE4ZO2.mjs} +11 -8
- package/dist/lib/browser/chunk-SCPE4ZO2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FO2PH7M3.mjs → chunk-XRAWIHTQ.mjs} +247 -184
- package/dist/lib/browser/chunk-XRAWIHTQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -56
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-dispatcher-LSYQZSEB.mjs → intent-dispatcher-TNEVDPI6.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-ZTNOSO3A.mjs → intent-resolver-SYLXP62Y.mjs} +7 -7
- package/dist/lib/browser/intent-resolver-SYLXP62Y.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react/index.mjs +32 -0
- package/dist/lib/browser/{store-KML2R4IE.mjs → store-3HDXKFXP.mjs} +4 -4
- package/dist/lib/browser/{store-KML2R4IE.mjs.map → store-3HDXKFXP.mjs.map} +2 -2
- package/dist/lib/browser/testing/index.mjs +17 -21
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{app-graph-builder-SAOWGJDK.mjs → app-graph-builder-VO6RTSOS.mjs} +32 -31
- package/dist/lib/node-esm/app-graph-builder-VO6RTSOS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ZEZ4FVEU.mjs → chunk-FO5NIDOR.mjs} +351 -263
- package/dist/lib/node-esm/chunk-FO5NIDOR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-73HGSHKE.mjs → chunk-JH3SFOXA.mjs} +247 -184
- package/dist/lib/node-esm/chunk-JH3SFOXA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UMZQERLE.mjs → chunk-ZX63QUGE.mjs} +11 -8
- package/dist/lib/node-esm/chunk-ZX63QUGE.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -56
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-dispatcher-6CYNGPSW.mjs → intent-dispatcher-WUNOPJES.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-W7Z7WFFM.mjs → intent-resolver-VTZI3NO7.mjs} +7 -7
- package/dist/lib/node-esm/intent-resolver-VTZI3NO7.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react/index.mjs +33 -0
- package/dist/lib/node-esm/{store-QEXGXLWZ.mjs → store-PAJPVOLG.mjs} +4 -4
- package/dist/lib/node-esm/{store-QEXGXLWZ.mjs.map → store-PAJPVOLG.mjs.map} +2 -2
- package/dist/lib/node-esm/testing/index.mjs +17 -21
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/common/capabilities.d.ts +110 -39
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/collaboration.d.ts +10 -9
- package/dist/types/src/common/collaboration.d.ts.map +1 -1
- package/dist/types/src/common/events.d.ts.map +1 -1
- package/dist/types/src/common/file.d.ts +1 -1
- package/dist/types/src/common/file.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +1 -1
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/layout.d.ts +1 -3
- package/dist/types/src/common/layout.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts +8 -13
- package/dist/types/src/common/surface.d.ts.map +1 -1
- package/dist/types/src/common/translations.d.ts +1 -1
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/core/capabilities.d.ts +17 -14
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts +7 -3
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +8 -1
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/debug/Debug.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Main.d.ts +1 -1
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/generator/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/logger/schema.d.ts +1 -1
- package/dist/types/src/playground/logger/schema.d.ts.map +1 -1
- package/dist/types/src/playground/playground.stories.d.ts +5 -4
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/actions.d.ts +5 -7
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/errors.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/index.d.ts +1 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +7 -7
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/meta.d.ts +3 -0
- package/dist/types/src/plugin-intent/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +1 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/actions.d.ts +5 -7
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +1 -1
- package/dist/types/src/plugin-settings/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/App.d.ts +10 -0
- package/dist/types/src/react/App.d.ts.map +1 -0
- package/dist/types/src/react/App.stories.d.ts +14 -0
- package/dist/types/src/react/App.stories.d.ts.map +1 -0
- package/dist/types/src/react/DefaultFallback.d.ts +8 -0
- package/dist/types/src/react/DefaultFallback.d.ts.map +1 -0
- package/dist/types/src/react/ErrorBoundary.d.ts +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 +5 -5
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/Surface.stories.d.ts +8 -10
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -1
- package/dist/types/src/react/common.d.ts.map +1 -1
- package/dist/types/src/react/index.d.ts +2 -0
- package/dist/types/src/react/index.d.ts.map +1 -1
- package/dist/types/src/react/types.d.ts +6 -0
- package/dist/types/src/react/types.d.ts.map +1 -0
- package/dist/types/src/{App.d.ts → react/useApp.d.ts} +7 -6
- package/dist/types/src/react/useApp.d.ts.map +1 -0
- package/dist/types/src/react/useCapabilities.d.ts.map +1 -1
- package/dist/types/src/react/useLoading.d.ts +19 -0
- package/dist/types/src/react/useLoading.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +9 -8
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts +9 -3
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +5 -1
- package/package.json +46 -38
- package/src/common/capabilities.ts +116 -18
- package/src/common/collaboration.ts +6 -9
- package/src/common/events.ts +3 -1
- package/src/common/file.ts +1 -1
- package/src/common/index.ts +1 -1
- package/src/common/layout.ts +3 -4
- package/src/common/surface.ts +16 -18
- package/src/common/translations.ts +1 -1
- package/src/core/capabilities.test.ts +3 -3
- package/src/core/capabilities.ts +34 -25
- package/src/core/manager.test.ts +22 -21
- package/src/core/manager.ts +141 -56
- package/src/core/plugin.ts +13 -2
- package/src/helpers.test.ts +1 -1
- package/src/index.ts +0 -2
- package/src/playground/debug/Debug.tsx +1 -1
- package/src/playground/debug/plugin.ts +7 -8
- package/src/playground/generator/Main.tsx +0 -1
- package/src/playground/generator/Toolbar.tsx +2 -1
- package/src/playground/generator/generator.ts +4 -4
- 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/logger/schema.ts +1 -1
- package/src/playground/playground.stories.tsx +20 -16
- package/src/plugin-intent/IntentPlugin.ts +13 -13
- package/src/plugin-intent/actions.ts +4 -6
- package/src/plugin-intent/errors.ts +2 -1
- package/src/plugin-intent/index.ts +1 -0
- package/src/plugin-intent/intent-dispatcher.test.ts +10 -3
- package/src/plugin-intent/intent-dispatcher.ts +16 -12
- package/src/plugin-intent/intent.ts +1 -1
- package/src/plugin-intent/meta.ts +10 -0
- package/src/plugin-settings/SettingsPlugin.ts +27 -28
- package/src/plugin-settings/actions.ts +9 -13
- package/src/plugin-settings/app-graph-builder.ts +25 -22
- package/src/plugin-settings/intent-resolver.ts +5 -4
- package/src/plugin-settings/meta.ts +10 -0
- package/src/plugin-settings/store.ts +1 -1
- package/src/plugin-settings/translations.ts +4 -4
- package/src/react/App.stories.tsx +33 -0
- package/src/react/App.tsx +59 -0
- package/src/react/DefaultFallback.tsx +26 -0
- package/src/react/ErrorBoundary.tsx +26 -15
- package/src/react/IntentContext.tsx +3 -2
- package/src/react/Surface.stories.tsx +81 -52
- package/src/react/Surface.tsx +70 -38
- package/src/react/common.ts +2 -1
- package/src/react/index.ts +4 -0
- package/src/react/types.ts +13 -0
- package/src/react/useApp.tsx +165 -0
- package/src/react/useCapabilities.ts +4 -3
- package/src/react/useLoading.tsx +70 -0
- package/src/testing/withPluginManager.stories.tsx +9 -5
- package/src/testing/withPluginManager.tsx +33 -32
- package/tsconfig.json +11 -9
- 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/browser/worker.mjs +0 -79
- 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/lib/node-esm/worker.mjs +0 -80
- package/dist/types/src/App.d.ts.map +0 -1
- package/dist/types/src/worker.d.ts +0 -4
- package/dist/types/src/worker.d.ts.map +0 -1
- package/src/App.tsx +0 -276
- package/src/worker.ts +0 -11
- /package/dist/lib/browser/{intent-dispatcher-LSYQZSEB.mjs.map → intent-dispatcher-TNEVDPI6.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → react/index.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-6CYNGPSW.mjs.map → intent-dispatcher-WUNOPJES.mjs.map} +0 -0
- /package/dist/lib/node-esm/{worker.mjs.map → react/index.mjs.map} +0 -0
|
@@ -1,106 +1,15 @@
|
|
|
1
1
|
// src/plugin-intent/intent-dispatcher.ts
|
|
2
|
-
import
|
|
2
|
+
import * as Effect3 from "effect/Effect";
|
|
3
|
+
import * as Function2 from "effect/Function";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Ref2 from "effect/Ref";
|
|
3
6
|
import { live as live2 } from "@dxos/live-object";
|
|
4
7
|
import { log as log3 } from "@dxos/log";
|
|
5
8
|
import { byPosition } from "@dxos/util";
|
|
6
9
|
|
|
7
|
-
// 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
10
|
// src/core/capabilities.ts
|
|
102
|
-
import {
|
|
103
|
-
import
|
|
11
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
104
13
|
import { Trigger } from "@dxos/async";
|
|
105
14
|
import { invariant } from "@dxos/invariant";
|
|
106
15
|
import { log } from "@dxos/log";
|
|
@@ -112,6 +21,8 @@ var defineCapability = (identifier) => {
|
|
|
112
21
|
};
|
|
113
22
|
};
|
|
114
23
|
var CapabilityImpl = class {
|
|
24
|
+
moduleId;
|
|
25
|
+
implementation;
|
|
115
26
|
constructor(moduleId, implementation) {
|
|
116
27
|
this.moduleId = moduleId;
|
|
117
28
|
this.implementation = implementation;
|
|
@@ -129,31 +40,44 @@ var lazy = (c) => async (props) => {
|
|
|
129
40
|
return async () => getCapability(props);
|
|
130
41
|
};
|
|
131
42
|
var PluginContext = class {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
43
|
+
_registry;
|
|
44
|
+
_capabilityImpls = Atom.family(() => {
|
|
45
|
+
return Atom.make([]).pipe(Atom.keepAlive);
|
|
46
|
+
});
|
|
47
|
+
_capabilities = Atom.family((id) => {
|
|
48
|
+
return Atom.make((get) => {
|
|
49
|
+
const current = get(this._capabilityImpls(id));
|
|
50
|
+
return current.map((c) => c.implementation);
|
|
141
51
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return current[0];
|
|
52
|
+
});
|
|
53
|
+
_capability = Atom.family((id) => {
|
|
54
|
+
return Atom.make((get) => {
|
|
55
|
+
const current = get(this._capabilities(id));
|
|
56
|
+
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
57
|
+
F: __dxlog_file,
|
|
58
|
+
L: 126,
|
|
59
|
+
S: this,
|
|
60
|
+
A: [
|
|
61
|
+
"current.length > 0",
|
|
62
|
+
"`No capability found for ${id}`"
|
|
63
|
+
]
|
|
155
64
|
});
|
|
65
|
+
return current[0];
|
|
156
66
|
});
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Activates plugins based on the activation event.
|
|
70
|
+
* @param event The activation event.
|
|
71
|
+
* @returns Whether the activation was successful.
|
|
72
|
+
*/
|
|
73
|
+
activate;
|
|
74
|
+
/**
|
|
75
|
+
* Re-activates the modules that were activated by the event.
|
|
76
|
+
* @param event The activation event.
|
|
77
|
+
* @returns Whether the reset was successful.
|
|
78
|
+
*/
|
|
79
|
+
reset;
|
|
80
|
+
constructor({ registry, activate, reset }) {
|
|
157
81
|
this._registry = registry;
|
|
158
82
|
this.activate = activate;
|
|
159
83
|
this.reset = reset;
|
|
@@ -177,7 +101,7 @@ var PluginContext = class {
|
|
|
177
101
|
count: current.length
|
|
178
102
|
}, {
|
|
179
103
|
F: __dxlog_file,
|
|
180
|
-
L:
|
|
104
|
+
L: 170,
|
|
181
105
|
S: this,
|
|
182
106
|
C: (f, a) => f(...a)
|
|
183
107
|
});
|
|
@@ -198,7 +122,7 @@ var PluginContext = class {
|
|
|
198
122
|
count: current.length
|
|
199
123
|
}, {
|
|
200
124
|
F: __dxlog_file,
|
|
201
|
-
L:
|
|
125
|
+
L: 189,
|
|
202
126
|
S: this,
|
|
203
127
|
C: (f, a) => f(...a)
|
|
204
128
|
});
|
|
@@ -207,15 +131,15 @@ var PluginContext = class {
|
|
|
207
131
|
id: interfaceDef.identifier
|
|
208
132
|
}, {
|
|
209
133
|
F: __dxlog_file,
|
|
210
|
-
L:
|
|
134
|
+
L: 191,
|
|
211
135
|
S: this,
|
|
212
136
|
C: (f, a) => f(...a)
|
|
213
137
|
});
|
|
214
138
|
}
|
|
215
139
|
}
|
|
216
140
|
/**
|
|
217
|
-
* Get the
|
|
218
|
-
* Primarily useful for deriving other
|
|
141
|
+
* Get the Atom reference to the available capabilities for a given interface.
|
|
142
|
+
* Primarily useful for deriving other Atom values based on the capabilities or
|
|
219
143
|
* for subscribing to changes in the capabilities.
|
|
220
144
|
* @returns An Rx reference to the available capabilities.
|
|
221
145
|
*/
|
|
@@ -223,8 +147,8 @@ var PluginContext = class {
|
|
|
223
147
|
return this._capabilities(interfaceDef.identifier);
|
|
224
148
|
}
|
|
225
149
|
/**
|
|
226
|
-
* Get the
|
|
227
|
-
* Primarily useful for deriving other
|
|
150
|
+
* Get the Atom reference to the available capabilities for a given interface.
|
|
151
|
+
* Primarily useful for deriving other Atom values based on the capability or
|
|
228
152
|
* for subscribing to changes in the capability.
|
|
229
153
|
* @returns An Rx reference to the available capability.
|
|
230
154
|
* @throws If no capability is found.
|
|
@@ -297,20 +221,35 @@ var getEvents = (events) => "type" in events ? events.events : [
|
|
|
297
221
|
];
|
|
298
222
|
|
|
299
223
|
// src/core/manager.ts
|
|
300
|
-
import { Registry } from "@effect-
|
|
224
|
+
import { Registry } from "@effect-atom/atom-react";
|
|
301
225
|
import { untracked } from "@preact/signals-core";
|
|
302
|
-
import
|
|
226
|
+
import * as Array from "effect/Array";
|
|
227
|
+
import * as Duration from "effect/Duration";
|
|
228
|
+
import * as Effect2 from "effect/Effect";
|
|
229
|
+
import * as Fiber from "effect/Fiber";
|
|
230
|
+
import * as Function from "effect/Function";
|
|
231
|
+
import * as HashSet from "effect/HashSet";
|
|
232
|
+
import * as Match from "effect/Match";
|
|
233
|
+
import * as Ref from "effect/Ref";
|
|
303
234
|
import { Event } from "@dxos/async";
|
|
304
235
|
import { live } from "@dxos/live-object";
|
|
305
236
|
import { log as log2 } from "@dxos/log";
|
|
306
237
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
|
|
307
|
-
var isPromise = (
|
|
308
|
-
return
|
|
238
|
+
var isPromise = (value2) => {
|
|
239
|
+
return value2 !== null && typeof value2 === "object" && "then" in value2;
|
|
309
240
|
};
|
|
310
241
|
var PluginManager = class {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
242
|
+
activation = new Event();
|
|
243
|
+
context;
|
|
244
|
+
registry;
|
|
245
|
+
// TODO(wittjosiah): Replace with Atom.
|
|
246
|
+
_state;
|
|
247
|
+
_pluginLoader;
|
|
248
|
+
_capabilities = /* @__PURE__ */ new Map();
|
|
249
|
+
_moduleMemoMap = /* @__PURE__ */ new Map();
|
|
250
|
+
_activatingEvents = Effect2.runSync(Ref.make([]));
|
|
251
|
+
_activatingModules = Effect2.runSync(Ref.make([]));
|
|
252
|
+
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.id), enabled = [], registry }) {
|
|
314
253
|
this.registry = registry ?? Registry.make();
|
|
315
254
|
this.context = new PluginContext({
|
|
316
255
|
registry: this.registry,
|
|
@@ -324,8 +263,8 @@ var PluginManager = class {
|
|
|
324
263
|
enabled,
|
|
325
264
|
modules: [],
|
|
326
265
|
active: [],
|
|
327
|
-
|
|
328
|
-
|
|
266
|
+
eventsFired: [],
|
|
267
|
+
pendingReset: []
|
|
329
268
|
});
|
|
330
269
|
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
331
270
|
core.forEach((id) => this.enable(id));
|
|
@@ -397,7 +336,7 @@ var PluginManager = class {
|
|
|
397
336
|
id
|
|
398
337
|
}, {
|
|
399
338
|
F: __dxlog_file2,
|
|
400
|
-
L:
|
|
339
|
+
L: 164,
|
|
401
340
|
S: this,
|
|
402
341
|
C: (f, a) => f(...a)
|
|
403
342
|
});
|
|
@@ -416,7 +355,7 @@ var PluginManager = class {
|
|
|
416
355
|
id
|
|
417
356
|
}, {
|
|
418
357
|
F: __dxlog_file2,
|
|
419
|
-
L:
|
|
358
|
+
L: 177,
|
|
420
359
|
S: this,
|
|
421
360
|
C: (f, a) => f(...a)
|
|
422
361
|
});
|
|
@@ -437,7 +376,7 @@ var PluginManager = class {
|
|
|
437
376
|
]
|
|
438
377
|
}, {
|
|
439
378
|
F: __dxlog_file2,
|
|
440
|
-
L:
|
|
379
|
+
L: 192,
|
|
441
380
|
S: this,
|
|
442
381
|
C: (f, a) => f(...a)
|
|
443
382
|
});
|
|
@@ -457,7 +396,7 @@ var PluginManager = class {
|
|
|
457
396
|
id
|
|
458
397
|
}, {
|
|
459
398
|
F: __dxlog_file2,
|
|
460
|
-
L:
|
|
399
|
+
L: 210,
|
|
461
400
|
S: this,
|
|
462
401
|
C: (f, a) => f(...a)
|
|
463
402
|
});
|
|
@@ -479,7 +418,7 @@ var PluginManager = class {
|
|
|
479
418
|
id
|
|
480
419
|
}, {
|
|
481
420
|
F: __dxlog_file2,
|
|
482
|
-
L:
|
|
421
|
+
L: 227,
|
|
483
422
|
S: this,
|
|
484
423
|
C: (f, a) => f(...a)
|
|
485
424
|
});
|
|
@@ -531,7 +470,7 @@ var PluginManager = class {
|
|
|
531
470
|
id: plugin.meta.id
|
|
532
471
|
}, {
|
|
533
472
|
F: __dxlog_file2,
|
|
534
|
-
L:
|
|
473
|
+
L: 280,
|
|
535
474
|
S: this,
|
|
536
475
|
C: (f, a) => f(...a)
|
|
537
476
|
});
|
|
@@ -546,7 +485,7 @@ var PluginManager = class {
|
|
|
546
485
|
id
|
|
547
486
|
}, {
|
|
548
487
|
F: __dxlog_file2,
|
|
549
|
-
L:
|
|
488
|
+
L: 290,
|
|
550
489
|
S: this,
|
|
551
490
|
C: (f, a) => f(...a)
|
|
552
491
|
});
|
|
@@ -562,7 +501,7 @@ var PluginManager = class {
|
|
|
562
501
|
id: module.id
|
|
563
502
|
}, {
|
|
564
503
|
F: __dxlog_file2,
|
|
565
|
-
L:
|
|
504
|
+
L: 300,
|
|
566
505
|
S: this,
|
|
567
506
|
C: (f, a) => f(...a)
|
|
568
507
|
});
|
|
@@ -577,7 +516,7 @@ var PluginManager = class {
|
|
|
577
516
|
id
|
|
578
517
|
}, {
|
|
579
518
|
F: __dxlog_file2,
|
|
580
|
-
L:
|
|
519
|
+
L: 310,
|
|
581
520
|
S: this,
|
|
582
521
|
C: (f, a) => f(...a)
|
|
583
522
|
});
|
|
@@ -605,13 +544,13 @@ var PluginManager = class {
|
|
|
605
544
|
_setPendingResetByModule(module) {
|
|
606
545
|
return untracked(() => {
|
|
607
546
|
const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
|
|
608
|
-
const pendingReset = Array.
|
|
547
|
+
const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
|
|
609
548
|
if (pendingReset.length > 0) {
|
|
610
549
|
log2("pending reset", {
|
|
611
550
|
events: pendingReset
|
|
612
551
|
}, {
|
|
613
552
|
F: __dxlog_file2,
|
|
614
|
-
L:
|
|
553
|
+
L: 348,
|
|
615
554
|
S: this,
|
|
616
555
|
C: (f, a) => f(...a)
|
|
617
556
|
});
|
|
@@ -623,35 +562,40 @@ var PluginManager = class {
|
|
|
623
562
|
* @internal
|
|
624
563
|
*/
|
|
625
564
|
// TODO(wittjosiah): Improve error typing.
|
|
626
|
-
_activate(event) {
|
|
565
|
+
_activate(event, params) {
|
|
627
566
|
return Effect2.gen(this, function* () {
|
|
628
567
|
const key = typeof event === "string" ? event : eventKey(event);
|
|
629
568
|
log2("activating", {
|
|
630
|
-
key
|
|
569
|
+
key,
|
|
570
|
+
...params
|
|
631
571
|
}, {
|
|
632
572
|
F: __dxlog_file2,
|
|
633
|
-
L:
|
|
573
|
+
L: 364,
|
|
634
574
|
S: this,
|
|
635
575
|
C: (f, a) => f(...a)
|
|
636
576
|
});
|
|
577
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
|
|
637
578
|
const pendingIndex = this._state.pendingReset.findIndex((event2) => event2 === key);
|
|
638
579
|
if (pendingIndex !== -1) {
|
|
639
580
|
this._state.pendingReset.splice(pendingIndex, 1);
|
|
640
581
|
}
|
|
582
|
+
const activatingEvents = yield* this._activatingEvents;
|
|
583
|
+
const activatingModules = yield* this._activatingModules;
|
|
641
584
|
const modules = this._getInactiveModulesByEvent(key).filter((module) => {
|
|
642
585
|
const allOf2 = isAllOf(module.activatesOn);
|
|
643
586
|
if (!allOf2) {
|
|
644
587
|
return true;
|
|
645
588
|
}
|
|
646
589
|
const events = module.activatesOn.events.filter((event2) => eventKey(event2) !== key);
|
|
647
|
-
return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)));
|
|
590
|
+
return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)) || activatingEvents.includes(eventKey(event2))) && !activatingModules.includes(module.id);
|
|
648
591
|
});
|
|
592
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, modules.map((module) => module.id)));
|
|
649
593
|
if (modules.length === 0) {
|
|
650
594
|
log2("no modules to activate", {
|
|
651
595
|
key
|
|
652
596
|
}, {
|
|
653
597
|
F: __dxlog_file2,
|
|
654
|
-
L:
|
|
598
|
+
L: 395,
|
|
655
599
|
S: this,
|
|
656
600
|
C: (f, a) => f(...a)
|
|
657
601
|
});
|
|
@@ -665,7 +609,7 @@ var PluginManager = class {
|
|
|
665
609
|
modules: modules.map((module) => module.id)
|
|
666
610
|
}, {
|
|
667
611
|
F: __dxlog_file2,
|
|
668
|
-
L:
|
|
612
|
+
L: 402,
|
|
669
613
|
S: this,
|
|
670
614
|
C: (f, a) => f(...a)
|
|
671
615
|
});
|
|
@@ -673,29 +617,34 @@ var PluginManager = class {
|
|
|
673
617
|
event: key,
|
|
674
618
|
state: "activating"
|
|
675
619
|
});
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
})), {
|
|
620
|
+
yield* Function.pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
621
|
+
before: key
|
|
622
|
+
})), Effect2.allWith({
|
|
680
623
|
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)) {
|
|
624
|
+
}));
|
|
625
|
+
const getCapabilities = yield* Function.pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
|
|
626
|
+
concurrency: "unbounded"
|
|
627
|
+
}), Effect2.catchAll((error) => {
|
|
692
628
|
this.activation.emit({
|
|
693
629
|
event: key,
|
|
694
630
|
state: "error",
|
|
695
|
-
error
|
|
631
|
+
error
|
|
696
632
|
});
|
|
697
|
-
|
|
698
|
-
}
|
|
633
|
+
return Effect2.fail(error);
|
|
634
|
+
}));
|
|
635
|
+
yield* Function.pipe(
|
|
636
|
+
modules,
|
|
637
|
+
Array.zip(getCapabilities),
|
|
638
|
+
Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
|
|
639
|
+
Effect2.all
|
|
640
|
+
);
|
|
641
|
+
yield* Function.pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
642
|
+
after: key
|
|
643
|
+
})), Effect2.allWith({
|
|
644
|
+
concurrency: "unbounded"
|
|
645
|
+
}));
|
|
646
|
+
yield* Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event2) => event2 !== key));
|
|
647
|
+
yield* Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !modules.map((module2) => module2.id).includes(module)));
|
|
699
648
|
if (!this._state.eventsFired.includes(key)) {
|
|
700
649
|
this._state.eventsFired.push(key);
|
|
701
650
|
}
|
|
@@ -707,39 +656,76 @@ var PluginManager = class {
|
|
|
707
656
|
key
|
|
708
657
|
}, {
|
|
709
658
|
F: __dxlog_file2,
|
|
710
|
-
L:
|
|
659
|
+
L: 458,
|
|
711
660
|
S: this,
|
|
712
661
|
C: (f, a) => f(...a)
|
|
713
662
|
});
|
|
714
663
|
return true;
|
|
715
664
|
});
|
|
716
665
|
}
|
|
717
|
-
|
|
666
|
+
// Memoized with _moduleMemoMap
|
|
667
|
+
_loadModule = (mod) => Effect2.tryPromise({
|
|
668
|
+
try: async () => {
|
|
669
|
+
const entry = this._moduleMemoMap.get(mod.id);
|
|
670
|
+
if (entry) {
|
|
671
|
+
return entry;
|
|
672
|
+
}
|
|
673
|
+
const promise2 = (async () => {
|
|
674
|
+
const start = performance.now();
|
|
675
|
+
let failed = false;
|
|
676
|
+
try {
|
|
677
|
+
log2("loading module", {
|
|
678
|
+
module: mod.id
|
|
679
|
+
}, {
|
|
680
|
+
F: __dxlog_file2,
|
|
681
|
+
L: 477,
|
|
682
|
+
S: this,
|
|
683
|
+
C: (f, a) => f(...a)
|
|
684
|
+
});
|
|
685
|
+
let activationResult = await mod.activate(this.context);
|
|
686
|
+
if (typeof activationResult === "function") {
|
|
687
|
+
activationResult = await activationResult();
|
|
688
|
+
}
|
|
689
|
+
return Array.isArray(activationResult) ? activationResult : [
|
|
690
|
+
activationResult
|
|
691
|
+
];
|
|
692
|
+
} catch (error) {
|
|
693
|
+
failed = true;
|
|
694
|
+
throw error;
|
|
695
|
+
} finally {
|
|
696
|
+
performance.measure("activate-module", {
|
|
697
|
+
start,
|
|
698
|
+
end: performance.now(),
|
|
699
|
+
detail: {
|
|
700
|
+
module: mod.id
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
log2("loaded module", {
|
|
704
|
+
module: mod.id,
|
|
705
|
+
elapsed: performance.now() - start,
|
|
706
|
+
failed
|
|
707
|
+
}, {
|
|
708
|
+
F: __dxlog_file2,
|
|
709
|
+
L: 495,
|
|
710
|
+
S: this,
|
|
711
|
+
C: (f, a) => f(...a)
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
})();
|
|
715
|
+
this._moduleMemoMap.set(mod.id, promise2);
|
|
716
|
+
return promise2;
|
|
717
|
+
},
|
|
718
|
+
catch: (error) => error
|
|
719
|
+
}).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
|
|
720
|
+
module: mod.id
|
|
721
|
+
}, {
|
|
722
|
+
F: __dxlog_file2,
|
|
723
|
+
L: 506,
|
|
724
|
+
S: this,
|
|
725
|
+
C: (f, a) => f(...a)
|
|
726
|
+
}))))));
|
|
727
|
+
_contributeCapabilities(module, capabilities) {
|
|
718
728
|
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
729
|
capabilities.forEach((capability) => {
|
|
744
730
|
this.context.contributeCapability({
|
|
745
731
|
module: module.id,
|
|
@@ -748,17 +734,6 @@ var PluginManager = class {
|
|
|
748
734
|
});
|
|
749
735
|
this._state.active.push(module.id);
|
|
750
736
|
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
737
|
});
|
|
763
738
|
}
|
|
764
739
|
_deactivate(id) {
|
|
@@ -781,17 +756,18 @@ var PluginManager = class {
|
|
|
781
756
|
id
|
|
782
757
|
}, {
|
|
783
758
|
F: __dxlog_file2,
|
|
784
|
-
L:
|
|
759
|
+
L: 540,
|
|
785
760
|
S: this,
|
|
786
761
|
C: (f, a) => f(...a)
|
|
787
762
|
});
|
|
763
|
+
this._moduleMemoMap.delete(id);
|
|
788
764
|
const capabilities = this._capabilities.get(id);
|
|
789
765
|
if (capabilities) {
|
|
790
766
|
for (const capability of capabilities) {
|
|
791
767
|
this.context.removeCapability(capability.interface, capability.implementation);
|
|
792
768
|
const program = capability.deactivate?.();
|
|
793
|
-
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (
|
|
794
|
-
try: () =>
|
|
769
|
+
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise2) => Effect2.tryPromise({
|
|
770
|
+
try: () => promise2,
|
|
795
771
|
catch: (error) => error
|
|
796
772
|
})), Match.orElse((program2) => Effect2.succeed(program2)));
|
|
797
773
|
}
|
|
@@ -805,7 +781,7 @@ var PluginManager = class {
|
|
|
805
781
|
id
|
|
806
782
|
}, {
|
|
807
783
|
F: __dxlog_file2,
|
|
808
|
-
L:
|
|
784
|
+
L: 567,
|
|
809
785
|
S: this,
|
|
810
786
|
C: (f, a) => f(...a)
|
|
811
787
|
});
|
|
@@ -819,7 +795,7 @@ var PluginManager = class {
|
|
|
819
795
|
key
|
|
820
796
|
}, {
|
|
821
797
|
F: __dxlog_file2,
|
|
822
|
-
L:
|
|
798
|
+
L: 575,
|
|
823
799
|
S: this,
|
|
824
800
|
C: (f, a) => f(...a)
|
|
825
801
|
});
|
|
@@ -835,9 +811,20 @@ var PluginManager = class {
|
|
|
835
811
|
});
|
|
836
812
|
}
|
|
837
813
|
};
|
|
814
|
+
var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
815
|
+
const togetherFiber = yield* Effect2.fork(togetherEffect);
|
|
816
|
+
const result = yield* effect;
|
|
817
|
+
yield* Fiber.interrupt(togetherFiber);
|
|
818
|
+
return result;
|
|
819
|
+
});
|
|
838
820
|
|
|
839
821
|
// src/core/plugin.ts
|
|
840
822
|
var PluginModule = class {
|
|
823
|
+
id;
|
|
824
|
+
activatesOn;
|
|
825
|
+
activatesBefore;
|
|
826
|
+
activatesAfter;
|
|
827
|
+
activate;
|
|
841
828
|
constructor(options) {
|
|
842
829
|
this.id = options.id;
|
|
843
830
|
this.activatesOn = options.activatesOn;
|
|
@@ -848,20 +835,27 @@ var PluginModule = class {
|
|
|
848
835
|
};
|
|
849
836
|
var defineModule = (options) => new PluginModule(options);
|
|
850
837
|
var Plugin = class {
|
|
851
|
-
|
|
852
|
-
|
|
838
|
+
meta;
|
|
839
|
+
modules;
|
|
840
|
+
constructor(meta2, modules) {
|
|
841
|
+
this.meta = meta2;
|
|
853
842
|
this.modules = modules;
|
|
854
843
|
}
|
|
855
844
|
};
|
|
856
|
-
var definePlugin = (
|
|
857
|
-
|
|
845
|
+
var definePlugin = (meta2, provider) => {
|
|
846
|
+
const factory = (args) => {
|
|
847
|
+
return new Plugin(meta2, provider(args));
|
|
848
|
+
};
|
|
849
|
+
return Object.assign(factory, {
|
|
850
|
+
meta: meta2
|
|
851
|
+
});
|
|
858
852
|
};
|
|
859
853
|
|
|
860
854
|
// src/common/capabilities.ts
|
|
861
855
|
(function(Capabilities2) {
|
|
862
856
|
Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
|
|
863
857
|
Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
|
|
864
|
-
Capabilities2.RxRegistry = defineCapability("dxos.org/app-framework/capability/
|
|
858
|
+
Capabilities2.RxRegistry = defineCapability("dxos.org/app-framework/capability/atom-registry");
|
|
865
859
|
Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
|
|
866
860
|
Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
|
|
867
861
|
Capabilities2.ReactSurface = defineCapability("dxos.org/app-framework/common/react-surface");
|
|
@@ -875,8 +869,10 @@ var definePlugin = (meta, modules) => {
|
|
|
875
869
|
Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
|
|
876
870
|
Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
|
|
877
871
|
Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
|
|
878
|
-
Capabilities2.
|
|
879
|
-
Capabilities2.
|
|
872
|
+
Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
|
|
873
|
+
Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
|
|
874
|
+
Capabilities2.AiServiceLayer = defineCapability("dxos.org/app-framework/capability/ai-service-factory");
|
|
875
|
+
Capabilities2.AiModelResolver = defineCapability("dxos.org/app-framework/capability/ai-model-resolver");
|
|
880
876
|
Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
|
|
881
877
|
Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
|
|
882
878
|
Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
|
|
@@ -884,22 +880,19 @@ var definePlugin = (meta, modules) => {
|
|
|
884
880
|
var Capabilities;
|
|
885
881
|
|
|
886
882
|
// src/common/collaboration.ts
|
|
887
|
-
import
|
|
888
|
-
import {
|
|
883
|
+
import * as Schema from "effect/Schema";
|
|
884
|
+
import { ContentBlock } from "@dxos/types";
|
|
889
885
|
(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."
|
|
886
|
+
class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
|
|
887
|
+
input: Schema.Struct({
|
|
888
|
+
subject: Schema.Any,
|
|
889
|
+
anchor: Schema.String,
|
|
890
|
+
proposal: ContentBlock.Proposal
|
|
898
891
|
}),
|
|
899
|
-
output:
|
|
892
|
+
output: Schema.Void
|
|
900
893
|
}) {
|
|
901
894
|
}
|
|
902
|
-
CollaborationActions2.
|
|
895
|
+
CollaborationActions2.AcceptProposal = AcceptProposal;
|
|
903
896
|
})(CollaborationActions || (CollaborationActions = {}));
|
|
904
897
|
var CollaborationActions;
|
|
905
898
|
|
|
@@ -922,7 +915,7 @@ var CollaborationActions;
|
|
|
922
915
|
var Events;
|
|
923
916
|
|
|
924
917
|
// src/common/file.ts
|
|
925
|
-
import
|
|
918
|
+
import * as Schema2 from "effect/Schema";
|
|
926
919
|
var defaultFileTypes = {
|
|
927
920
|
images: [
|
|
928
921
|
"png",
|
|
@@ -942,23 +935,120 @@ var defaultFileTypes = {
|
|
|
942
935
|
"md"
|
|
943
936
|
]
|
|
944
937
|
};
|
|
945
|
-
var FileInfoSchema =
|
|
946
|
-
name:
|
|
947
|
-
type:
|
|
948
|
-
url:
|
|
949
|
-
cid:
|
|
938
|
+
var FileInfoSchema = Schema2.Struct({
|
|
939
|
+
name: Schema2.String,
|
|
940
|
+
type: Schema2.String,
|
|
941
|
+
url: Schema2.optional(Schema2.String),
|
|
942
|
+
cid: Schema2.optional(Schema2.String)
|
|
950
943
|
});
|
|
951
944
|
|
|
952
945
|
// src/common/layout.ts
|
|
953
|
-
import
|
|
946
|
+
import * as Schema5 from "effect/Schema";
|
|
954
947
|
|
|
955
|
-
// src/plugin-intent/
|
|
956
|
-
|
|
957
|
-
|
|
948
|
+
// src/plugin-intent/actions.ts
|
|
949
|
+
import * as Schema4 from "effect/Schema";
|
|
950
|
+
|
|
951
|
+
// src/plugin-intent/intent.ts
|
|
952
|
+
import * as Schema3 from "effect/Schema";
|
|
953
|
+
var createIntent = (schema, data = {}, params = {}) => {
|
|
954
|
+
const _ = Schema3.validateSync(schema.fields.input)(data);
|
|
955
|
+
const intent = {
|
|
956
|
+
...params,
|
|
957
|
+
_schema: schema,
|
|
958
|
+
id: schema._tag,
|
|
959
|
+
data
|
|
960
|
+
};
|
|
961
|
+
return {
|
|
962
|
+
first: intent,
|
|
963
|
+
last: intent,
|
|
964
|
+
all: [
|
|
965
|
+
intent
|
|
966
|
+
]
|
|
967
|
+
};
|
|
968
|
+
};
|
|
969
|
+
var chain = (schema, data = {}, params = {}) => (intent) => {
|
|
970
|
+
const intents = "all" in intent ? intent.all : [
|
|
971
|
+
intent
|
|
972
|
+
];
|
|
973
|
+
const first = intents[0];
|
|
974
|
+
const last = {
|
|
975
|
+
...params,
|
|
976
|
+
_schema: schema,
|
|
977
|
+
id: schema._tag,
|
|
978
|
+
data
|
|
979
|
+
};
|
|
980
|
+
return {
|
|
981
|
+
first,
|
|
982
|
+
last,
|
|
983
|
+
all: [
|
|
984
|
+
...intents,
|
|
985
|
+
last
|
|
986
|
+
]
|
|
987
|
+
};
|
|
988
|
+
};
|
|
989
|
+
var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.String, Schema3.mutable(Schema3.Struct({
|
|
990
|
+
ns: Schema3.String,
|
|
991
|
+
count: Schema3.optional(Schema3.Number),
|
|
992
|
+
defaultValue: Schema3.optional(Schema3.String)
|
|
993
|
+
})))));
|
|
994
|
+
|
|
995
|
+
// src/plugin-intent/meta.ts
|
|
996
|
+
var meta = {
|
|
997
|
+
id: "dxos.org/plugin/intent",
|
|
958
998
|
name: "Intent"
|
|
959
|
-
}
|
|
999
|
+
};
|
|
1000
|
+
|
|
1001
|
+
// src/plugin-intent/actions.ts
|
|
1002
|
+
(function(IntentAction2) {
|
|
1003
|
+
class Track extends Schema4.TaggedClass()(`${meta.id}/action/track`, {
|
|
1004
|
+
input: Schema4.Struct({
|
|
1005
|
+
intents: Schema4.Array(Schema4.String),
|
|
1006
|
+
error: Schema4.optional(Schema4.String)
|
|
1007
|
+
}),
|
|
1008
|
+
output: Schema4.Void
|
|
1009
|
+
}) {
|
|
1010
|
+
}
|
|
1011
|
+
IntentAction2.Track = Track;
|
|
1012
|
+
class ShowUndo extends Schema4.TaggedClass()(`${meta.id}/action/show-undo`, {
|
|
1013
|
+
input: Schema4.Struct({
|
|
1014
|
+
message: Label
|
|
1015
|
+
}),
|
|
1016
|
+
output: Schema4.Void
|
|
1017
|
+
}) {
|
|
1018
|
+
}
|
|
1019
|
+
IntentAction2.ShowUndo = ShowUndo;
|
|
1020
|
+
})(IntentAction || (IntentAction = {}));
|
|
1021
|
+
var IntentAction;
|
|
1022
|
+
|
|
1023
|
+
// src/plugin-intent/errors.ts
|
|
1024
|
+
var BaseError = class extends Error {
|
|
1025
|
+
code;
|
|
1026
|
+
context;
|
|
1027
|
+
constructor(code, message, context) {
|
|
1028
|
+
super(message ?? code, {
|
|
1029
|
+
cause: context
|
|
1030
|
+
}), this.code = code, this.context = context;
|
|
1031
|
+
this.name = code;
|
|
1032
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
var NoResolversError = class extends BaseError {
|
|
1036
|
+
constructor(action) {
|
|
1037
|
+
super("NO_RESOLVERS", `No resolvers were found for the action: ${action}`, {
|
|
1038
|
+
action
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
var CycleDetectedError = class extends BaseError {
|
|
1043
|
+
constructor(context) {
|
|
1044
|
+
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
// src/plugin-intent/IntentPlugin.ts
|
|
1049
|
+
var IntentPlugin = definePlugin(meta, () => [
|
|
960
1050
|
defineModule({
|
|
961
|
-
id: `${
|
|
1051
|
+
id: `${meta.id}/module/dispatcher`,
|
|
962
1052
|
// TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
|
|
963
1053
|
// This is fine for now because it's how it worked prior to capabilities api anyways.
|
|
964
1054
|
// In the future, the intent dispatcher should be able to be reset without resetting the entire app.
|
|
@@ -966,15 +1056,14 @@ var IntentPlugin = () => definePlugin({
|
|
|
966
1056
|
activatesAfter: [
|
|
967
1057
|
Events.DispatcherReady
|
|
968
1058
|
],
|
|
969
|
-
activate: lazy(() => import("./intent-dispatcher-
|
|
1059
|
+
activate: lazy(() => import("./intent-dispatcher-TNEVDPI6.mjs"))
|
|
970
1060
|
})
|
|
971
1061
|
]);
|
|
972
1062
|
|
|
973
1063
|
// src/common/layout.ts
|
|
974
1064
|
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
|
|
975
|
-
var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
|
|
976
1065
|
(function(LayoutAction2) {
|
|
977
|
-
LayoutAction2.UPDATE_LAYOUT = `${
|
|
1066
|
+
LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_PLUGIN}/action/update-layout`;
|
|
978
1067
|
class UpdateLayout extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
979
1068
|
input: Schema5.Struct({
|
|
980
1069
|
part: Schema5.String.annotations({
|
|
@@ -1311,7 +1400,7 @@ var LayoutAction;
|
|
|
1311
1400
|
var createSurface = (definition) => definition;
|
|
1312
1401
|
|
|
1313
1402
|
// src/common/translations.ts
|
|
1314
|
-
import
|
|
1403
|
+
import * as Schema6 from "effect/Schema";
|
|
1315
1404
|
var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
|
|
1316
1405
|
key: Schema6.String,
|
|
1317
1406
|
value: Schema6.Any
|
|
@@ -1336,7 +1425,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1336
1425
|
const handleIntent = (intent) => Effect3.gen(function* () {
|
|
1337
1426
|
const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
|
|
1338
1427
|
if (candidates.length === 0) {
|
|
1339
|
-
yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1428
|
+
return yield* Effect3.fail(new NoResolversError(intent.id));
|
|
1340
1429
|
}
|
|
1341
1430
|
const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
1342
1431
|
const result = Effect3.isEffect(effect) ? yield* effect : yield* Effect3.promise(async () => effect);
|
|
@@ -1348,7 +1437,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1348
1437
|
const dispatch = (intentChain, depth = 0) => {
|
|
1349
1438
|
return Effect3.gen(function* () {
|
|
1350
1439
|
if (depth > executionLimit) {
|
|
1351
|
-
yield* Effect3.fail(new CycleDetectedError());
|
|
1440
|
+
return yield* Effect3.fail(new CycleDetectedError());
|
|
1352
1441
|
}
|
|
1353
1442
|
const resultsRef = yield* Ref2.make([]);
|
|
1354
1443
|
for (const intent of intentChain.all) {
|
|
@@ -1370,7 +1459,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1370
1459
|
}
|
|
1371
1460
|
}
|
|
1372
1461
|
if (result2.error) {
|
|
1373
|
-
yield* Effect3.fail(result2.error);
|
|
1462
|
+
return yield* Effect3.fail(result2.error);
|
|
1374
1463
|
}
|
|
1375
1464
|
}
|
|
1376
1465
|
const results = yield* resultsRef.get;
|
|
@@ -1386,7 +1475,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1386
1475
|
return next;
|
|
1387
1476
|
});
|
|
1388
1477
|
if (result.undoable && isUndoable(results)) {
|
|
1389
|
-
yield*
|
|
1478
|
+
yield* Function2.pipe(dispatch(createIntent(IntentAction.ShowUndo, {
|
|
1390
1479
|
message: result.undoable.message
|
|
1391
1480
|
})), Effect3.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect3.succeed(void 0)) : Option.none()));
|
|
1392
1481
|
}
|
|
@@ -1399,7 +1488,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1399
1488
|
})).catch((error) => {
|
|
1400
1489
|
log3.catch(error, void 0, {
|
|
1401
1490
|
F: __dxlog_file3,
|
|
1402
|
-
L:
|
|
1491
|
+
L: 274,
|
|
1403
1492
|
S: void 0,
|
|
1404
1493
|
C: (f, a) => f(...a)
|
|
1405
1494
|
});
|
|
@@ -1414,7 +1503,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1414
1503
|
const last = history.findLastIndex(isUndoable);
|
|
1415
1504
|
const result = last !== -1 ? history[last] : void 0;
|
|
1416
1505
|
if (result) {
|
|
1417
|
-
const
|
|
1506
|
+
const all2 = result.map(({ _intent, undoable }) => {
|
|
1418
1507
|
const data = _intent.data;
|
|
1419
1508
|
const undoData = undoable?.data ?? {};
|
|
1420
1509
|
return {
|
|
@@ -1427,9 +1516,9 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1427
1516
|
};
|
|
1428
1517
|
});
|
|
1429
1518
|
const intent = {
|
|
1430
|
-
first:
|
|
1431
|
-
last:
|
|
1432
|
-
all
|
|
1519
|
+
first: all2[0],
|
|
1520
|
+
last: all2.at(-1),
|
|
1521
|
+
all: all2
|
|
1433
1522
|
};
|
|
1434
1523
|
yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
|
|
1435
1524
|
return yield* dispatch(intent);
|
|
@@ -1452,7 +1541,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1452
1541
|
};
|
|
1453
1542
|
var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
|
|
1454
1543
|
var defaultPromise = () => Effect3.runPromise(defaultEffect());
|
|
1455
|
-
var intent_dispatcher_default = (context) => {
|
|
1544
|
+
var intent_dispatcher_default = ((context) => {
|
|
1456
1545
|
const state = live2({
|
|
1457
1546
|
dispatch: defaultEffect,
|
|
1458
1547
|
dispatchPromise: defaultPromise,
|
|
@@ -1474,7 +1563,7 @@ var intent_dispatcher_default = (context) => {
|
|
|
1474
1563
|
state.undo = undo;
|
|
1475
1564
|
state.undoPromise = undoPromise;
|
|
1476
1565
|
return contributes(Capabilities.IntentDispatcher, state);
|
|
1477
|
-
};
|
|
1566
|
+
});
|
|
1478
1567
|
|
|
1479
1568
|
export {
|
|
1480
1569
|
defineCapability,
|
|
@@ -1501,19 +1590,18 @@ export {
|
|
|
1501
1590
|
createIntent,
|
|
1502
1591
|
chain,
|
|
1503
1592
|
Label,
|
|
1504
|
-
INTENT_PLUGIN,
|
|
1505
|
-
INTENT_ACTION,
|
|
1506
1593
|
IntentAction,
|
|
1594
|
+
BaseError,
|
|
1595
|
+
NoResolversError,
|
|
1596
|
+
CycleDetectedError,
|
|
1507
1597
|
createResolver,
|
|
1508
1598
|
createDispatcher,
|
|
1509
1599
|
intent_dispatcher_default,
|
|
1510
1600
|
IntentPlugin,
|
|
1511
|
-
LAYOUT_PLUGIN,
|
|
1512
|
-
LAYOUT_ACTION,
|
|
1513
1601
|
LayoutAction,
|
|
1514
1602
|
createSurface,
|
|
1515
1603
|
ResourceKey,
|
|
1516
1604
|
ResourceLanguage,
|
|
1517
1605
|
Resource
|
|
1518
1606
|
};
|
|
1519
|
-
//# sourceMappingURL=chunk-
|
|
1607
|
+
//# sourceMappingURL=chunk-LVSO2N4X.mjs.map
|