@dxos/app-framework 0.7.5-main.9d2a38b → 0.7.5-main.e94eead
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/dist/lib/browser/app-graph-builder-S4MYSHQA.mjs +137 -0
- package/dist/lib/browser/app-graph-builder-S4MYSHQA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GNLU3GAU.mjs → chunk-BCMEJONP.mjs} +660 -823
- package/dist/lib/browser/chunk-BCMEJONP.mjs.map +7 -0
- package/dist/lib/browser/chunk-QS4J6O47.mjs +285 -0
- package/dist/lib/browser/chunk-QS4J6O47.mjs.map +7 -0
- package/dist/lib/browser/chunk-SRZH2PQ2.mjs +32 -0
- package/dist/lib/browser/chunk-SRZH2PQ2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +57 -74
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-dispatcher-GFBH7T2J.mjs +11 -0
- package/dist/lib/browser/intent-dispatcher-GFBH7T2J.mjs.map +7 -0
- package/dist/lib/browser/intent-resolver-KAFM7CQH.mjs +39 -0
- package/dist/lib/browser/intent-resolver-KAFM7CQH.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/store-L3VRR7II.mjs +29 -0
- package/dist/lib/browser/store-L3VRR7II.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +13 -3
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/worker.mjs +77 -0
- package/dist/lib/browser/worker.mjs.map +7 -0
- package/dist/lib/node/app-graph-builder-VMHWFCTP.cjs +146 -0
- package/dist/lib/node/app-graph-builder-VMHWFCTP.cjs.map +7 -0
- package/dist/lib/node/chunk-7Y6KJ3OK.cjs +1466 -0
- package/dist/lib/node/chunk-7Y6KJ3OK.cjs.map +7 -0
- package/dist/lib/node/chunk-B65NJEIJ.cjs +308 -0
- package/dist/lib/node/chunk-B65NJEIJ.cjs.map +7 -0
- package/dist/lib/node/chunk-VCIHQZSN.cjs +58 -0
- package/dist/lib/node/chunk-VCIHQZSN.cjs.map +7 -0
- package/dist/lib/node/index.cjs +106 -118
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-dispatcher-PRCC4KZT.cjs +32 -0
- package/dist/lib/node/intent-dispatcher-PRCC4KZT.cjs.map +7 -0
- package/dist/lib/node/intent-resolver-OZDKCHPW.cjs +46 -0
- package/dist/lib/node/intent-resolver-OZDKCHPW.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/store-BVUKNVKL.cjs +44 -0
- package/dist/lib/node/store-BVUKNVKL.cjs.map +7 -0
- package/dist/lib/node/testing/index.cjs +18 -8
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node/worker.cjs +99 -0
- package/dist/lib/node/worker.cjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-XHI5IIXQ.mjs +138 -0
- package/dist/lib/node-esm/app-graph-builder-XHI5IIXQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CBT75GCX.mjs +34 -0
- package/dist/lib/node-esm/chunk-CBT75GCX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JDAHZRYQ.mjs +286 -0
- package/dist/lib/node-esm/chunk-JDAHZRYQ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-KPMTPXQI.mjs → chunk-TVIR2PHY.mjs} +660 -823
- package/dist/lib/node-esm/chunk-TVIR2PHY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +57 -74
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-dispatcher-LGACN32C.mjs +12 -0
- package/dist/lib/node-esm/intent-dispatcher-LGACN32C.mjs.map +7 -0
- package/dist/lib/node-esm/intent-resolver-RBNG76ZX.mjs +40 -0
- package/dist/lib/node-esm/intent-resolver-RBNG76ZX.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/store-PHTOEREN.mjs +30 -0
- package/dist/lib/node-esm/store-PHTOEREN.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +13 -3
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/worker.mjs +78 -0
- package/dist/lib/node-esm/worker.mjs.map +7 -0
- package/dist/types/src/App.d.ts +2 -2
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/common/capabilities.d.ts +88 -124
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/events.d.ts +22 -11
- 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/graph.d.ts +2 -2
- package/dist/types/src/common/graph.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +0 -1
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/layout.d.ts +218 -121
- package/dist/types/src/common/layout.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts +3 -3
- package/dist/types/src/common/surface.d.ts.map +1 -1
- package/dist/types/src/common/translations.d.ts +7 -7
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/core/capabilities.d.ts +6 -2
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts +2 -9
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +5 -2
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/debug/Debug.d.ts +2 -3
- package/dist/types/src/playground/debug/Debug.d.ts.map +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Main.d.ts +2 -3
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +2 -3
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -1
- package/dist/types/src/playground/generator/generator.d.ts +5 -3
- 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/Layout.d.ts.map +1 -1
- package/dist/types/src/playground/layout/plugin.d.ts +1 -1
- package/dist/types/src/playground/layout/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +2 -3
- 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 +2 -3
- 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 +1 -1
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/index.d.ts +0 -1
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +27 -20
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts +3 -3
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -1
- 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 +11 -1
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +197 -0
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +4 -0
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/store.d.ts +5 -0
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/translations.d.ts +11 -0
- package/dist/types/src/plugin-settings/translations.d.ts.map +1 -0
- package/dist/types/src/react/ErrorBoundary.d.ts +1 -1
- package/dist/types/src/{plugin-intent → react}/IntentContext.d.ts +1 -1
- package/dist/types/src/react/IntentContext.d.ts.map +1 -0
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/Surface.stories.d.ts +15 -0
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -0
- package/dist/types/src/react/common.d.ts +13 -0
- package/dist/types/src/react/common.d.ts.map +1 -0
- 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/useCapabilities.d.ts.map +1 -1
- package/dist/types/src/react/useIntentResolver.d.ts +3 -0
- package/dist/types/src/react/useIntentResolver.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +6 -4
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/worker.d.ts +4 -0
- package/dist/types/src/worker.d.ts.map +1 -0
- package/package.json +29 -21
- package/project.json +4 -3
- package/src/App.tsx +17 -15
- package/src/common/capabilities.ts +30 -11
- package/src/common/events.ts +16 -2
- package/src/common/file.ts +1 -1
- package/src/common/graph.ts +2 -2
- package/src/common/index.ts +0 -1
- package/src/common/layout.ts +207 -126
- package/src/common/surface.ts +2 -2
- package/src/common/translations.ts +7 -8
- package/src/core/capabilities.ts +16 -7
- package/src/core/manager.test.ts +22 -73
- package/src/core/manager.ts +105 -91
- package/src/core/plugin.ts +6 -3
- package/src/playground/debug/plugin.ts +1 -1
- package/src/playground/generator/Toolbar.tsx +11 -11
- package/src/playground/generator/generator.ts +25 -0
- package/src/playground/generator/plugin.ts +6 -1
- package/src/playground/layout/plugin.ts +1 -1
- package/src/playground/logger/Toolbar.tsx +2 -1
- package/src/playground/logger/plugin.ts +7 -4
- package/src/playground/logger/schema.ts +1 -1
- package/src/plugin-intent/IntentPlugin.tsx +3 -43
- package/src/plugin-intent/actions.ts +1 -1
- package/src/plugin-intent/errors.ts +1 -1
- package/src/plugin-intent/index.ts +0 -1
- package/src/plugin-intent/intent-dispatcher.test.ts +48 -29
- package/src/plugin-intent/intent-dispatcher.ts +81 -42
- package/src/plugin-intent/intent.ts +5 -5
- package/src/plugin-settings/SettingsPlugin.ts +19 -13
- package/src/plugin-settings/actions.ts +11 -1
- package/src/plugin-settings/app-graph-builder.ts +122 -0
- package/src/plugin-settings/intent-resolver.ts +34 -0
- package/src/plugin-settings/store.ts +30 -0
- package/src/plugin-settings/translations.ts +17 -0
- package/src/{plugin-intent → react}/IntentContext.tsx +2 -2
- package/src/react/Surface.stories.tsx +96 -0
- package/src/react/Surface.tsx +11 -8
- package/src/react/common.ts +12 -0
- package/src/react/index.ts +2 -0
- package/src/react/useCapabilities.ts +1 -0
- package/src/react/useIntentResolver.ts +22 -0
- package/src/testing/withPluginManager.tsx +28 -4
- package/src/worker.ts +11 -0
- package/tsconfig.json +7 -13
- package/dist/lib/browser/chunk-GNLU3GAU.mjs.map +0 -7
- package/dist/lib/node/chunk-FBA4BB3J.cjs +0 -1639
- package/dist/lib/node/chunk-FBA4BB3J.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-KPMTPXQI.mjs.map +0 -7
- package/dist/types/src/common/navigation.d.ts +0 -241
- package/dist/types/src/common/navigation.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/IntentContext.d.ts.map +0 -1
- package/src/common/navigation.ts +0 -199
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
|
@@ -1,5 +1,97 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
+
// packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts
|
|
4
|
+
import { Effect as Effect2, Option, pipe as pipe2, Ref } from "effect";
|
|
5
|
+
import { create as create3 } from "@dxos/live-object";
|
|
6
|
+
import { log as log3 } from "@dxos/log";
|
|
7
|
+
import { byPosition } from "@dxos/util";
|
|
8
|
+
|
|
9
|
+
// packages/sdk/app-framework/src/plugin-intent/actions.ts
|
|
10
|
+
import { Schema as S2 } from "@effect/schema";
|
|
11
|
+
|
|
12
|
+
// packages/sdk/app-framework/src/plugin-intent/intent.ts
|
|
13
|
+
import { Schema as S } from "@effect/schema";
|
|
14
|
+
var createIntent = (schema, data = {}, params = {}) => {
|
|
15
|
+
const _ = S.validateSync(schema.fields.input)(data);
|
|
16
|
+
const intent = {
|
|
17
|
+
...params,
|
|
18
|
+
_schema: schema,
|
|
19
|
+
id: schema._tag,
|
|
20
|
+
data
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
first: intent,
|
|
24
|
+
last: intent,
|
|
25
|
+
all: [
|
|
26
|
+
intent
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
var chain = (schema, data = {}, params = {}) => (intent) => {
|
|
31
|
+
const intents = "all" in intent ? intent.all : [
|
|
32
|
+
intent
|
|
33
|
+
];
|
|
34
|
+
const first = intents[0];
|
|
35
|
+
const last = {
|
|
36
|
+
...params,
|
|
37
|
+
_schema: schema,
|
|
38
|
+
id: schema._tag,
|
|
39
|
+
data
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
first,
|
|
43
|
+
last,
|
|
44
|
+
all: [
|
|
45
|
+
...intents,
|
|
46
|
+
last
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
var Label = S.Union(S.String, S.mutable(S.Tuple(S.String, S.mutable(S.Struct({
|
|
51
|
+
ns: S.String,
|
|
52
|
+
count: S.optional(S.Number)
|
|
53
|
+
})))));
|
|
54
|
+
|
|
55
|
+
// packages/sdk/app-framework/src/plugin-intent/actions.ts
|
|
56
|
+
var INTENT_PLUGIN = "dxos.org/plugin/intent";
|
|
57
|
+
var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
58
|
+
var IntentAction;
|
|
59
|
+
(function(IntentAction2) {
|
|
60
|
+
class ShowUndo extends S2.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
|
|
61
|
+
input: S2.Struct({
|
|
62
|
+
message: Label
|
|
63
|
+
}),
|
|
64
|
+
output: S2.Void
|
|
65
|
+
}) {
|
|
66
|
+
}
|
|
67
|
+
IntentAction2.ShowUndo = ShowUndo;
|
|
68
|
+
})(IntentAction || (IntentAction = {}));
|
|
69
|
+
|
|
70
|
+
// packages/sdk/app-framework/src/plugin-intent/errors.ts
|
|
71
|
+
var BaseError = class extends Error {
|
|
72
|
+
constructor(code, message, context) {
|
|
73
|
+
super(message ?? code, {
|
|
74
|
+
cause: context
|
|
75
|
+
});
|
|
76
|
+
this.code = code;
|
|
77
|
+
this.context = context;
|
|
78
|
+
this.name = code;
|
|
79
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var NoResolversError = class extends BaseError {
|
|
83
|
+
constructor(action) {
|
|
84
|
+
super("NO_RESOLVERS", "No resolvers were found for the action", {
|
|
85
|
+
action
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var CycleDetectedError = class extends BaseError {
|
|
90
|
+
constructor(context) {
|
|
91
|
+
super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
3
95
|
// packages/sdk/app-framework/src/core/capabilities.ts
|
|
4
96
|
import { effect, untracked } from "@preact/signals-core";
|
|
5
97
|
import { Trigger } from "@dxos/async";
|
|
@@ -26,9 +118,10 @@ var contributes = (interfaceDef, implementation, deactivate) => {
|
|
|
26
118
|
deactivate
|
|
27
119
|
};
|
|
28
120
|
};
|
|
29
|
-
var lazy = (c) => (props) =>
|
|
30
|
-
|
|
31
|
-
|
|
121
|
+
var lazy = (c) => async (props) => {
|
|
122
|
+
const { default: getCapability } = await c();
|
|
123
|
+
return async () => getCapability(props);
|
|
124
|
+
};
|
|
32
125
|
var PluginsContext = class {
|
|
33
126
|
constructor({ activate, reset }) {
|
|
34
127
|
this._definedCapabilities = /* @__PURE__ */ new Map();
|
|
@@ -50,10 +143,11 @@ var PluginsContext = class {
|
|
|
50
143
|
current.push(new CapabilityImpl(moduleId, implementation));
|
|
51
144
|
log("capability contributed", {
|
|
52
145
|
id: interfaceDef.identifier,
|
|
146
|
+
moduleId,
|
|
53
147
|
count: untracked(() => current.length)
|
|
54
148
|
}, {
|
|
55
149
|
F: __dxlog_file,
|
|
56
|
-
L:
|
|
150
|
+
L: 142,
|
|
57
151
|
S: this,
|
|
58
152
|
C: (f, a) => f(...a)
|
|
59
153
|
});
|
|
@@ -74,7 +168,16 @@ var PluginsContext = class {
|
|
|
74
168
|
count: untracked(() => current.length)
|
|
75
169
|
}, {
|
|
76
170
|
F: __dxlog_file,
|
|
77
|
-
L:
|
|
171
|
+
L: 161,
|
|
172
|
+
S: this,
|
|
173
|
+
C: (f, a) => f(...a)
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
log.warn("capability not removed", {
|
|
177
|
+
id: interfaceDef.identifier
|
|
178
|
+
}, {
|
|
179
|
+
F: __dxlog_file,
|
|
180
|
+
L: 163,
|
|
78
181
|
S: this,
|
|
79
182
|
C: (f, a) => f(...a)
|
|
80
183
|
});
|
|
@@ -107,7 +210,7 @@ var PluginsContext = class {
|
|
|
107
210
|
const capability = this.requestCapabilities(interfaceDef, filter)[0];
|
|
108
211
|
invariant(capability, `No capability found for ${interfaceDef.identifier}`, {
|
|
109
212
|
F: __dxlog_file,
|
|
110
|
-
L:
|
|
213
|
+
L: 199,
|
|
111
214
|
S: this,
|
|
112
215
|
A: [
|
|
113
216
|
"capability",
|
|
@@ -158,7 +261,7 @@ var getEvents = (events) => "type" in events ? events.events : [
|
|
|
158
261
|
|
|
159
262
|
// packages/sdk/app-framework/src/core/manager.ts
|
|
160
263
|
import { untracked as untracked2 } from "@preact/signals-core";
|
|
161
|
-
import { Effect, Either, Match } from "effect";
|
|
264
|
+
import { Array as A, Effect, Either, Match, pipe } from "effect";
|
|
162
265
|
import { Event } from "@dxos/async";
|
|
163
266
|
import { create as create2 } from "@dxos/live-object";
|
|
164
267
|
import { log as log2 } from "@dxos/log";
|
|
@@ -181,7 +284,6 @@ var PluginManager = class {
|
|
|
181
284
|
enabled,
|
|
182
285
|
modules: [],
|
|
183
286
|
active: [],
|
|
184
|
-
pendingRemoval: [],
|
|
185
287
|
pendingReset: [],
|
|
186
288
|
eventsFired: []
|
|
187
289
|
});
|
|
@@ -230,14 +332,6 @@ var PluginManager = class {
|
|
|
230
332
|
return this._state.active;
|
|
231
333
|
}
|
|
232
334
|
/**
|
|
233
|
-
* Ids of modules which are pending removal.
|
|
234
|
-
*
|
|
235
|
-
* @reactive
|
|
236
|
-
*/
|
|
237
|
-
get pendingRemoval() {
|
|
238
|
-
return this._state.pendingRemoval;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
335
|
* Ids of events which have been fired.
|
|
242
336
|
*
|
|
243
337
|
* @reactive
|
|
@@ -263,7 +357,7 @@ var PluginManager = class {
|
|
|
263
357
|
id
|
|
264
358
|
}, {
|
|
265
359
|
F: __dxlog_file2,
|
|
266
|
-
L:
|
|
360
|
+
L: 146,
|
|
267
361
|
S: this,
|
|
268
362
|
C: (f, a) => f(...a)
|
|
269
363
|
});
|
|
@@ -277,12 +371,12 @@ var PluginManager = class {
|
|
|
277
371
|
* @param id The id of the plugin.
|
|
278
372
|
*/
|
|
279
373
|
enable(id) {
|
|
280
|
-
return untracked2(() => {
|
|
374
|
+
return untracked2(async () => {
|
|
281
375
|
log2("enable plugin", {
|
|
282
376
|
id
|
|
283
377
|
}, {
|
|
284
378
|
F: __dxlog_file2,
|
|
285
|
-
L:
|
|
379
|
+
L: 159,
|
|
286
380
|
S: this,
|
|
287
381
|
C: (f, a) => f(...a)
|
|
288
382
|
});
|
|
@@ -297,6 +391,19 @@ var PluginManager = class {
|
|
|
297
391
|
this._addModule(module);
|
|
298
392
|
this._setPendingResetByModule(module);
|
|
299
393
|
});
|
|
394
|
+
log2("pending reset", {
|
|
395
|
+
events: [
|
|
396
|
+
...this.pendingReset
|
|
397
|
+
]
|
|
398
|
+
}, {
|
|
399
|
+
F: __dxlog_file2,
|
|
400
|
+
L: 174,
|
|
401
|
+
S: this,
|
|
402
|
+
C: (f, a) => f(...a)
|
|
403
|
+
});
|
|
404
|
+
await Effect.runPromise(Effect.all(this.pendingReset.map((event) => this._activate(event)), {
|
|
405
|
+
concurrency: "unbounded"
|
|
406
|
+
}));
|
|
300
407
|
return true;
|
|
301
408
|
});
|
|
302
409
|
}
|
|
@@ -310,7 +417,7 @@ var PluginManager = class {
|
|
|
310
417
|
id
|
|
311
418
|
}, {
|
|
312
419
|
F: __dxlog_file2,
|
|
313
|
-
L:
|
|
420
|
+
L: 192,
|
|
314
421
|
S: this,
|
|
315
422
|
C: (f, a) => f(...a)
|
|
316
423
|
});
|
|
@@ -327,12 +434,12 @@ var PluginManager = class {
|
|
|
327
434
|
* @param id The id of the plugin.
|
|
328
435
|
*/
|
|
329
436
|
disable(id) {
|
|
330
|
-
return untracked2(() => {
|
|
437
|
+
return untracked2(async () => {
|
|
331
438
|
log2("disable plugin", {
|
|
332
439
|
id
|
|
333
440
|
}, {
|
|
334
441
|
F: __dxlog_file2,
|
|
335
|
-
L:
|
|
442
|
+
L: 209,
|
|
336
443
|
S: this,
|
|
337
444
|
C: (f, a) => f(...a)
|
|
338
445
|
});
|
|
@@ -346,15 +453,9 @@ var PluginManager = class {
|
|
|
346
453
|
const enabledIndex = this._state.enabled.findIndex((enabled) => enabled === id);
|
|
347
454
|
if (enabledIndex !== -1) {
|
|
348
455
|
this._state.enabled.splice(enabledIndex, 1);
|
|
456
|
+
await Effect.runPromise(this._deactivate(id));
|
|
349
457
|
plugin.modules.forEach((module) => {
|
|
350
|
-
|
|
351
|
-
this._setPendingResetByModule(module);
|
|
352
|
-
if (!this._state.pendingRemoval.includes(module.id)) {
|
|
353
|
-
this._state.pendingRemoval.push(module.id);
|
|
354
|
-
}
|
|
355
|
-
} else {
|
|
356
|
-
this._removeModule(module.id);
|
|
357
|
-
}
|
|
458
|
+
this._removeModule(module.id);
|
|
358
459
|
});
|
|
359
460
|
}
|
|
360
461
|
return true;
|
|
@@ -390,7 +491,7 @@ var PluginManager = class {
|
|
|
390
491
|
id: plugin.meta.id
|
|
391
492
|
}, {
|
|
392
493
|
F: __dxlog_file2,
|
|
393
|
-
L:
|
|
494
|
+
L: 262,
|
|
394
495
|
S: this,
|
|
395
496
|
C: (f, a) => f(...a)
|
|
396
497
|
});
|
|
@@ -405,7 +506,7 @@ var PluginManager = class {
|
|
|
405
506
|
id
|
|
406
507
|
}, {
|
|
407
508
|
F: __dxlog_file2,
|
|
408
|
-
L:
|
|
509
|
+
L: 271,
|
|
409
510
|
S: this,
|
|
410
511
|
C: (f, a) => f(...a)
|
|
411
512
|
});
|
|
@@ -421,7 +522,7 @@ var PluginManager = class {
|
|
|
421
522
|
id: module.id
|
|
422
523
|
}, {
|
|
423
524
|
F: __dxlog_file2,
|
|
424
|
-
L:
|
|
525
|
+
L: 281,
|
|
425
526
|
S: this,
|
|
426
527
|
C: (f, a) => f(...a)
|
|
427
528
|
});
|
|
@@ -436,7 +537,7 @@ var PluginManager = class {
|
|
|
436
537
|
id
|
|
437
538
|
}, {
|
|
438
539
|
F: __dxlog_file2,
|
|
439
|
-
L:
|
|
540
|
+
L: 290,
|
|
440
541
|
S: this,
|
|
441
542
|
C: (f, a) => f(...a)
|
|
442
543
|
});
|
|
@@ -464,20 +565,13 @@ var PluginManager = class {
|
|
|
464
565
|
_setPendingResetByModule(module) {
|
|
465
566
|
return untracked2(() => {
|
|
466
567
|
const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
|
|
467
|
-
const
|
|
468
|
-
const modules = this._getActiveModules().filter((module2) => module2.activatesBefore?.map(eventKey).includes(event));
|
|
469
|
-
return modules.flatMap((module2) => getEvents(module2.activatesOn)).map(eventKey);
|
|
470
|
-
});
|
|
471
|
-
const pendingReset = Array.from(/* @__PURE__ */ new Set([
|
|
472
|
-
...activationEvents,
|
|
473
|
-
...parentEvents
|
|
474
|
-
])).filter((event) => !this._state.pendingReset.includes(event));
|
|
568
|
+
const pendingReset = Array.from(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
|
|
475
569
|
if (pendingReset.length > 0) {
|
|
476
570
|
log2("pending reset", {
|
|
477
571
|
events: pendingReset
|
|
478
572
|
}, {
|
|
479
573
|
F: __dxlog_file2,
|
|
480
|
-
L:
|
|
574
|
+
L: 328,
|
|
481
575
|
S: this,
|
|
482
576
|
C: (f, a) => f(...a)
|
|
483
577
|
});
|
|
@@ -485,59 +579,87 @@ var PluginManager = class {
|
|
|
485
579
|
}
|
|
486
580
|
});
|
|
487
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* @internal
|
|
584
|
+
*/
|
|
488
585
|
// TODO(wittjosiah): Improve error typing.
|
|
489
586
|
_activate(event) {
|
|
490
|
-
|
|
491
|
-
return Effect.gen(function* () {
|
|
587
|
+
return Effect.gen(this, function* () {
|
|
492
588
|
const key = typeof event === "string" ? event : eventKey(event);
|
|
493
589
|
log2("activating", {
|
|
494
590
|
key
|
|
495
591
|
}, {
|
|
496
592
|
F: __dxlog_file2,
|
|
497
|
-
L:
|
|
593
|
+
L: 341,
|
|
498
594
|
S: this,
|
|
499
595
|
C: (f, a) => f(...a)
|
|
500
596
|
});
|
|
501
|
-
const pendingIndex =
|
|
597
|
+
const pendingIndex = this._state.pendingReset.findIndex((event2) => event2 === key);
|
|
502
598
|
if (pendingIndex !== -1) {
|
|
503
|
-
|
|
599
|
+
this._state.pendingReset.splice(pendingIndex, 1);
|
|
504
600
|
}
|
|
505
|
-
const modules =
|
|
601
|
+
const modules = this._getInactiveModulesByEvent(key).filter((module) => {
|
|
602
|
+
const allOf2 = isAllOf(module.activatesOn);
|
|
603
|
+
if (!allOf2) {
|
|
604
|
+
return true;
|
|
605
|
+
}
|
|
606
|
+
const events = module.activatesOn.events.filter((event2) => eventKey(event2) !== key);
|
|
607
|
+
return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)));
|
|
608
|
+
});
|
|
506
609
|
if (modules.length === 0) {
|
|
507
610
|
log2("no modules to activate", {
|
|
508
611
|
key
|
|
509
612
|
}, {
|
|
510
613
|
F: __dxlog_file2,
|
|
511
|
-
L:
|
|
614
|
+
L: 357,
|
|
512
615
|
S: this,
|
|
513
616
|
C: (f, a) => f(...a)
|
|
514
617
|
});
|
|
618
|
+
if (!this._state.eventsFired.includes(key)) {
|
|
619
|
+
this._state.eventsFired.push(key);
|
|
620
|
+
}
|
|
515
621
|
return false;
|
|
516
622
|
}
|
|
517
|
-
|
|
623
|
+
log2("activating modules", {
|
|
624
|
+
key,
|
|
625
|
+
modules: modules.map((module) => module.id)
|
|
626
|
+
}, {
|
|
627
|
+
F: __dxlog_file2,
|
|
628
|
+
L: 364,
|
|
629
|
+
S: this,
|
|
630
|
+
C: (f, a) => f(...a)
|
|
631
|
+
});
|
|
632
|
+
this.activation.emit({
|
|
518
633
|
event: key,
|
|
519
634
|
state: "activating"
|
|
520
635
|
});
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
636
|
+
const getCapabilities = yield* Effect.all(modules.map(({ activate }) => Effect.tryPromise({
|
|
637
|
+
try: async () => activate(this.context),
|
|
638
|
+
catch: (error) => error
|
|
639
|
+
})), {
|
|
640
|
+
concurrency: "unbounded"
|
|
641
|
+
});
|
|
642
|
+
const result = yield* pipe(
|
|
643
|
+
modules,
|
|
644
|
+
A.zip(getCapabilities),
|
|
645
|
+
A.map(([module, getCapabilities2]) => this._activateModule(module, getCapabilities2)),
|
|
646
|
+
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
647
|
+
// Running this with concurrency causes races with `allOf` activation events.
|
|
648
|
+
Effect.all,
|
|
649
|
+
Effect.either
|
|
650
|
+
);
|
|
651
|
+
if (Either.isLeft(result)) {
|
|
652
|
+
this.activation.emit({
|
|
653
|
+
event: key,
|
|
654
|
+
state: "error",
|
|
655
|
+
error: result.left
|
|
656
|
+
});
|
|
657
|
+
yield* Effect.fail(result.left);
|
|
536
658
|
}
|
|
537
|
-
if (!
|
|
538
|
-
|
|
659
|
+
if (!this._state.eventsFired.includes(key)) {
|
|
660
|
+
this._state.eventsFired.push(key);
|
|
539
661
|
}
|
|
540
|
-
|
|
662
|
+
this.activation.emit({
|
|
541
663
|
event: key,
|
|
542
664
|
state: "activated"
|
|
543
665
|
});
|
|
@@ -545,79 +667,105 @@ var PluginManager = class {
|
|
|
545
667
|
key
|
|
546
668
|
}, {
|
|
547
669
|
F: __dxlog_file2,
|
|
548
|
-
L:
|
|
670
|
+
L: 398,
|
|
549
671
|
S: this,
|
|
550
672
|
C: (f, a) => f(...a)
|
|
551
673
|
});
|
|
552
674
|
return true;
|
|
553
675
|
});
|
|
554
676
|
}
|
|
555
|
-
_activateModule(module) {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}
|
|
563
|
-
|
|
677
|
+
_activateModule(module, getCapabilities) {
|
|
678
|
+
return Effect.gen(this, function* () {
|
|
679
|
+
yield* Effect.all(module.activatesBefore?.map((event) => this._activate(event)) ?? [], {
|
|
680
|
+
concurrency: "unbounded"
|
|
681
|
+
});
|
|
682
|
+
log2("activating module...", {
|
|
683
|
+
module: module.id
|
|
684
|
+
}, {
|
|
685
|
+
F: __dxlog_file2,
|
|
686
|
+
L: 413,
|
|
687
|
+
S: this,
|
|
688
|
+
C: (f, a) => f(...a)
|
|
689
|
+
});
|
|
690
|
+
const maybeCapabilities = typeof getCapabilities === "function" ? getCapabilities() : getCapabilities;
|
|
691
|
+
const resolvedCapabilities = yield* Match.value(maybeCapabilities).pipe(
|
|
692
|
+
// TODO(wittjosiah): Activate with an effect?
|
|
693
|
+
// Match.when(Effect.isEffect, (effect) => effect),
|
|
694
|
+
Match.when(isPromise, (promise) => Effect.tryPromise({
|
|
695
|
+
try: () => promise,
|
|
696
|
+
catch: (error) => error
|
|
697
|
+
})),
|
|
698
|
+
Match.orElse((program) => Effect.succeed(program))
|
|
699
|
+
);
|
|
700
|
+
const capabilities = Match.value(resolvedCapabilities).pipe(Match.when(Array.isArray, (array) => array), Match.orElse((value) => [
|
|
564
701
|
value
|
|
565
702
|
]));
|
|
566
703
|
capabilities.forEach((capability) => {
|
|
567
|
-
|
|
704
|
+
this.context.contributeCapability({
|
|
568
705
|
module: module.id,
|
|
569
706
|
...capability
|
|
570
707
|
});
|
|
571
708
|
});
|
|
572
|
-
|
|
573
|
-
|
|
709
|
+
this._state.active.push(module.id);
|
|
710
|
+
this._capabilities.set(module.id, capabilities);
|
|
711
|
+
log2("activated module", {
|
|
712
|
+
module: module.id
|
|
713
|
+
}, {
|
|
714
|
+
F: __dxlog_file2,
|
|
715
|
+
L: 436,
|
|
716
|
+
S: this,
|
|
717
|
+
C: (f, a) => f(...a)
|
|
718
|
+
});
|
|
719
|
+
yield* Effect.all(module.activatesAfter?.map((event) => this._activate(event)) ?? [], {
|
|
720
|
+
concurrency: "unbounded"
|
|
721
|
+
});
|
|
574
722
|
});
|
|
575
723
|
}
|
|
576
724
|
_deactivate(id) {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
const plugin = self._getPlugin(id);
|
|
725
|
+
return Effect.gen(this, function* () {
|
|
726
|
+
const plugin = this._getPlugin(id);
|
|
580
727
|
if (!plugin) {
|
|
581
728
|
return false;
|
|
582
729
|
}
|
|
583
730
|
const modules = plugin.modules;
|
|
584
|
-
const results = yield* Effect.all(modules.map((module) =>
|
|
731
|
+
const results = yield* Effect.all(modules.map((module) => this._deactivateModule(module)), {
|
|
732
|
+
concurrency: "unbounded"
|
|
733
|
+
});
|
|
585
734
|
return results.every((result) => result);
|
|
586
735
|
});
|
|
587
736
|
}
|
|
588
737
|
_deactivateModule(module) {
|
|
589
|
-
|
|
590
|
-
return Effect.gen(function* () {
|
|
738
|
+
return Effect.gen(this, function* () {
|
|
591
739
|
const id = module.id;
|
|
592
740
|
log2("deactivating", {
|
|
593
741
|
id
|
|
594
742
|
}, {
|
|
595
743
|
F: __dxlog_file2,
|
|
596
|
-
L:
|
|
744
|
+
L: 463,
|
|
597
745
|
S: this,
|
|
598
746
|
C: (f, a) => f(...a)
|
|
599
747
|
});
|
|
600
|
-
const capabilities =
|
|
748
|
+
const capabilities = this._capabilities.get(id);
|
|
601
749
|
if (capabilities) {
|
|
602
750
|
for (const capability of capabilities) {
|
|
603
|
-
|
|
751
|
+
this.context.removeCapability(capability.interface, capability.implementation);
|
|
604
752
|
const program = capability.deactivate?.();
|
|
605
|
-
yield* Match.value(program).pipe(Match.when(Effect.isEffect, (
|
|
753
|
+
yield* Match.value(program).pipe(Match.when(Effect.isEffect, (effect2) => effect2), Match.when(isPromise, (promise) => Effect.tryPromise({
|
|
606
754
|
try: () => promise,
|
|
607
755
|
catch: (error) => error
|
|
608
756
|
})), Match.orElse((program2) => Effect.succeed(program2)));
|
|
609
757
|
}
|
|
610
|
-
|
|
758
|
+
this._capabilities.delete(id);
|
|
611
759
|
}
|
|
612
|
-
const activeIndex =
|
|
760
|
+
const activeIndex = this._state.active.findIndex((event) => event === id);
|
|
613
761
|
if (activeIndex !== -1) {
|
|
614
|
-
|
|
762
|
+
this._state.active.splice(activeIndex, 1);
|
|
615
763
|
}
|
|
616
764
|
log2("deactivated", {
|
|
617
765
|
id
|
|
618
766
|
}, {
|
|
619
767
|
F: __dxlog_file2,
|
|
620
|
-
L:
|
|
768
|
+
L: 489,
|
|
621
769
|
S: this,
|
|
622
770
|
C: (f, a) => f(...a)
|
|
623
771
|
});
|
|
@@ -625,27 +773,22 @@ var PluginManager = class {
|
|
|
625
773
|
});
|
|
626
774
|
}
|
|
627
775
|
_reset(event) {
|
|
628
|
-
|
|
629
|
-
return Effect.gen(function* () {
|
|
776
|
+
return Effect.gen(this, function* () {
|
|
630
777
|
const key = typeof event === "string" ? event : eventKey(event);
|
|
631
778
|
log2("reset", {
|
|
632
779
|
key
|
|
633
780
|
}, {
|
|
634
781
|
F: __dxlog_file2,
|
|
635
|
-
L:
|
|
782
|
+
L: 497,
|
|
636
783
|
S: this,
|
|
637
784
|
C: (f, a) => f(...a)
|
|
638
785
|
});
|
|
639
|
-
const modules =
|
|
640
|
-
const results = yield* Effect.all(modules.map((module) =>
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
self._removeModule(id);
|
|
644
|
-
});
|
|
645
|
-
self._state.pendingRemoval.splice(0, self._state.pendingRemoval.length);
|
|
646
|
-
}
|
|
786
|
+
const modules = this._getActiveModulesByEvent(key);
|
|
787
|
+
const results = yield* Effect.all(modules.map((module) => this._deactivateModule(module)), {
|
|
788
|
+
concurrency: "unbounded"
|
|
789
|
+
});
|
|
647
790
|
if (results.every((result) => result)) {
|
|
648
|
-
return yield*
|
|
791
|
+
return yield* this._activate(key);
|
|
649
792
|
} else {
|
|
650
793
|
return false;
|
|
651
794
|
}
|
|
@@ -685,9 +828,6 @@ var Capabilities;
|
|
|
685
828
|
Capabilities2.IntentResolver = defineCapability("dxos.org/app-framework/capability/intent-resolver");
|
|
686
829
|
Capabilities2.IntentDispatcher = defineCapability("dxos.org/app-framework/capability/intent-dispatcher");
|
|
687
830
|
Capabilities2.Layout = defineCapability("dxos.org/app-framework/capability/layout");
|
|
688
|
-
Capabilities2.MutableLayout = defineCapability("dxos.org/app-framework/capability/layout");
|
|
689
|
-
Capabilities2.Location = defineCapability("dxos.org/app-framework/capability/location");
|
|
690
|
-
Capabilities2.MutableLocation = defineCapability("dxos.org/app-framework/capability/location");
|
|
691
831
|
Capabilities2.Translations = defineCapability("dxos.org/app-framework/capability/translations");
|
|
692
832
|
Capabilities2.AppGraph = defineCapability("dxos.org/app-framework/capability/app-graph");
|
|
693
833
|
Capabilities2.AppGraphBuilder = defineCapability("dxos.org/app-framework/capability/app-graph-builder");
|
|
@@ -695,6 +835,8 @@ var Capabilities;
|
|
|
695
835
|
Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
|
|
696
836
|
Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
|
|
697
837
|
Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
|
|
838
|
+
Capabilities2.Tools = defineCapability("dxos.org/app-framework/capability/tools");
|
|
839
|
+
Capabilities2.ArtifactDefinition = defineCapability("dxos.org/app-framework/capability/artifact-definition");
|
|
698
840
|
Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
|
|
699
841
|
})(Capabilities || (Capabilities = {}));
|
|
700
842
|
|
|
@@ -702,20 +844,22 @@ var Capabilities;
|
|
|
702
844
|
var Events;
|
|
703
845
|
(function(Events2) {
|
|
704
846
|
Events2.Startup = defineEvent("dxos.org/app-framework/event/startup");
|
|
705
|
-
Events2.
|
|
847
|
+
Events2.SetupReactSurface = defineEvent("dxos.org/app-framework/event/setup-react-surface");
|
|
848
|
+
Events2.SetupMetadata = defineEvent("dxos.org/app-framework/event/setup-metadata");
|
|
849
|
+
Events2.SetupIntentResolver = defineEvent("dxos.org/app-framework/event/setup-intent-resolver");
|
|
706
850
|
Events2.SetupSettings = defineEvent("dxos.org/app-framework/event/setup-settings");
|
|
707
851
|
Events2.SetupAppGraph = defineEvent("dxos.org/app-framework/event/setup-graph");
|
|
708
852
|
Events2.SetupTranslations = defineEvent("dxos.org/app-framework/event/setup-translations");
|
|
853
|
+
Events2.SetupArtifactDefinition = defineEvent("dxos.org/app-framework/event/setup-artifact-definition");
|
|
709
854
|
Events2.DispatcherReady = defineEvent("dxos.org/app-framework/event/dispatcher-ready");
|
|
710
855
|
Events2.SettingsReady = defineEvent("dxos.org/app-framework/event/settings-ready");
|
|
711
856
|
Events2.AppGraphReady = defineEvent("dxos.org/app-framework/event/graph-ready");
|
|
712
857
|
Events2.createStateEvent = (specifier) => defineEvent("dxos.org/app-framework/event/state", specifier);
|
|
713
858
|
Events2.LayoutReady = Events2.createStateEvent(Capabilities.Layout.identifier);
|
|
714
|
-
Events2.LocationReady = Events2.createStateEvent(Capabilities.Location.identifier);
|
|
715
859
|
})(Events || (Events = {}));
|
|
716
860
|
|
|
717
861
|
// packages/sdk/app-framework/src/common/file.ts
|
|
718
|
-
import {
|
|
862
|
+
import { Schema as S3 } from "@effect/schema";
|
|
719
863
|
var defaultFileTypes = {
|
|
720
864
|
images: [
|
|
721
865
|
"png",
|
|
@@ -735,127 +879,386 @@ var defaultFileTypes = {
|
|
|
735
879
|
"md"
|
|
736
880
|
]
|
|
737
881
|
};
|
|
738
|
-
var FileInfoSchema =
|
|
739
|
-
name:
|
|
740
|
-
type:
|
|
741
|
-
url:
|
|
742
|
-
cid:
|
|
882
|
+
var FileInfoSchema = S3.Struct({
|
|
883
|
+
name: S3.String,
|
|
884
|
+
type: S3.String,
|
|
885
|
+
url: S3.optional(S3.String),
|
|
886
|
+
cid: S3.optional(S3.String)
|
|
743
887
|
});
|
|
744
888
|
|
|
745
|
-
// packages/sdk/app-framework/src/
|
|
746
|
-
import {
|
|
747
|
-
var createIntent = (schema, data = {}, params = {}) => {
|
|
748
|
-
const _ = S2.validateSync(schema.fields.input)(data);
|
|
749
|
-
const intent = {
|
|
750
|
-
...params,
|
|
751
|
-
_schema: schema,
|
|
752
|
-
action: schema._tag,
|
|
753
|
-
data
|
|
754
|
-
};
|
|
755
|
-
return {
|
|
756
|
-
first: intent,
|
|
757
|
-
last: intent,
|
|
758
|
-
all: [
|
|
759
|
-
intent
|
|
760
|
-
]
|
|
761
|
-
};
|
|
762
|
-
};
|
|
763
|
-
var chain = (schema, data = {}, params = {}) => (intent) => {
|
|
764
|
-
const intents = "all" in intent ? intent.all : [
|
|
765
|
-
intent
|
|
766
|
-
];
|
|
767
|
-
const first = intents[0];
|
|
768
|
-
const last = {
|
|
769
|
-
...params,
|
|
770
|
-
_schema: schema,
|
|
771
|
-
action: schema._tag,
|
|
772
|
-
data
|
|
773
|
-
};
|
|
774
|
-
return {
|
|
775
|
-
first,
|
|
776
|
-
last,
|
|
777
|
-
all: [
|
|
778
|
-
...intents,
|
|
779
|
-
last
|
|
780
|
-
]
|
|
781
|
-
};
|
|
782
|
-
};
|
|
783
|
-
var Label = S2.Union(S2.String, S2.mutable(S2.Tuple(S2.String, S2.mutable(S2.Struct({
|
|
784
|
-
ns: S2.String,
|
|
785
|
-
count: S2.optional(S2.Number)
|
|
786
|
-
})))));
|
|
889
|
+
// packages/sdk/app-framework/src/common/layout.ts
|
|
890
|
+
import { Schema as S4 } from "@effect/schema";
|
|
787
891
|
|
|
788
|
-
// packages/sdk/app-framework/src/plugin-intent/
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
892
|
+
// packages/sdk/app-framework/src/plugin-intent/IntentPlugin.tsx
|
|
893
|
+
var IntentPlugin = () => definePlugin({
|
|
894
|
+
id: INTENT_PLUGIN
|
|
895
|
+
}, [
|
|
896
|
+
defineModule({
|
|
897
|
+
id: `${INTENT_PLUGIN}/module/dispatcher`,
|
|
898
|
+
// TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
|
|
899
|
+
// This is fine for now because it's how it worked prior to capabilities api anyways.
|
|
900
|
+
// In the future, the intent dispatcher should be able to be reset without resetting the entire app.
|
|
901
|
+
activatesOn: Events.Startup,
|
|
902
|
+
activatesAfter: [
|
|
903
|
+
Events.DispatcherReady
|
|
904
|
+
],
|
|
905
|
+
activate: lazy(() => import("./intent-dispatcher-LGACN32C.mjs"))
|
|
906
|
+
})
|
|
907
|
+
]);
|
|
908
|
+
|
|
909
|
+
// packages/sdk/app-framework/src/common/layout.ts
|
|
910
|
+
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
|
|
911
|
+
var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
|
|
912
|
+
var LayoutAction;
|
|
913
|
+
(function(LayoutAction2) {
|
|
914
|
+
LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_ACTION}/update-layout`;
|
|
915
|
+
class UpdateLayout extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
916
|
+
input: S4.Struct({
|
|
917
|
+
part: S4.String.annotations({
|
|
918
|
+
description: "The part of the layout to mutate."
|
|
919
|
+
}),
|
|
920
|
+
subject: S4.optional(S4.Any.annotations({
|
|
921
|
+
description: "The subject of the layout update."
|
|
922
|
+
})),
|
|
923
|
+
options: S4.optional(S4.Record({
|
|
924
|
+
key: S4.String,
|
|
925
|
+
value: S4.Any
|
|
926
|
+
}).annotations({
|
|
927
|
+
description: "Additional options for the layout action."
|
|
928
|
+
}))
|
|
797
929
|
}),
|
|
798
|
-
output:
|
|
930
|
+
output: S4.Void
|
|
799
931
|
}) {
|
|
800
932
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
933
|
+
LayoutAction2.UpdateLayout = UpdateLayout;
|
|
934
|
+
class SetLayoutMode extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
935
|
+
input: S4.Struct({
|
|
936
|
+
part: S4.Literal("mode").annotations({
|
|
937
|
+
description: "Setting the layout mode."
|
|
938
|
+
}),
|
|
939
|
+
subject: S4.optional(S4.String.annotations({
|
|
940
|
+
description: "Item which is the subject of the new layout mode."
|
|
941
|
+
})),
|
|
942
|
+
options: S4.Union(S4.Struct({
|
|
943
|
+
mode: S4.String.annotations({
|
|
944
|
+
description: "The new layout mode."
|
|
945
|
+
})
|
|
946
|
+
}), S4.Struct({
|
|
947
|
+
revert: S4.Boolean.annotations({
|
|
948
|
+
description: "Revert to the previous layout mode."
|
|
949
|
+
})
|
|
950
|
+
}))
|
|
951
|
+
}),
|
|
952
|
+
output: S4.Void
|
|
953
|
+
}) {
|
|
816
954
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
955
|
+
LayoutAction2.SetLayoutMode = SetLayoutMode;
|
|
956
|
+
class UpdateSidebar extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
957
|
+
input: S4.Struct({
|
|
958
|
+
part: S4.Literal("sidebar").annotations({
|
|
959
|
+
description: "Updating the sidebar."
|
|
960
|
+
}),
|
|
961
|
+
subject: S4.optional(S4.String.annotations({
|
|
962
|
+
description: "URI of the component to display in the sidebar."
|
|
963
|
+
})),
|
|
964
|
+
options: S4.optional(S4.Struct({
|
|
965
|
+
state: S4.Literal("closed", "collapsed", "expanded").annotations({
|
|
966
|
+
description: "Whether the sidebar is closed, collapsed, or expanded."
|
|
967
|
+
})
|
|
968
|
+
}))
|
|
969
|
+
}),
|
|
970
|
+
output: S4.Void
|
|
971
|
+
}) {
|
|
823
972
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
973
|
+
LayoutAction2.UpdateSidebar = UpdateSidebar;
|
|
974
|
+
class UpdateComplementary extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
975
|
+
input: S4.Struct({
|
|
976
|
+
part: S4.Literal("complementary").annotations({
|
|
977
|
+
description: "Updating the complementary sidebar."
|
|
978
|
+
}),
|
|
979
|
+
subject: S4.optional(S4.String.annotations({
|
|
980
|
+
description: "URI of the component to display in the complementary area."
|
|
981
|
+
})),
|
|
982
|
+
options: S4.optional(S4.Struct({
|
|
983
|
+
state: S4.Literal("closed", "collapsed", "expanded").annotations({
|
|
984
|
+
description: "Whether the complementary sidebar is closed, collapsed, or expanded."
|
|
985
|
+
})
|
|
986
|
+
}))
|
|
987
|
+
}),
|
|
988
|
+
output: S4.Void
|
|
989
|
+
}) {
|
|
828
990
|
}
|
|
829
|
-
|
|
991
|
+
LayoutAction2.UpdateComplementary = UpdateComplementary;
|
|
992
|
+
class UpdateDialog extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
993
|
+
input: S4.Struct({
|
|
994
|
+
part: S4.Literal("dialog").annotations({
|
|
995
|
+
description: "Updating the dialog."
|
|
996
|
+
}),
|
|
997
|
+
subject: S4.optional(S4.String.annotations({
|
|
998
|
+
description: "URI of the component to display in the dialog."
|
|
999
|
+
})),
|
|
1000
|
+
options: S4.Struct({
|
|
1001
|
+
state: S4.optional(S4.Boolean.annotations({
|
|
1002
|
+
description: "Whether the dialog is open or closed."
|
|
1003
|
+
})),
|
|
1004
|
+
blockAlign: S4.optional(S4.Literal("start", "center", "end").annotations({
|
|
1005
|
+
description: "The alignment of the dialog."
|
|
1006
|
+
})),
|
|
1007
|
+
type: S4.optional(S4.Literal("default", "alert").annotations({
|
|
1008
|
+
description: "The type of dialog."
|
|
1009
|
+
})),
|
|
1010
|
+
props: S4.optional(S4.Record({
|
|
1011
|
+
key: S4.String,
|
|
1012
|
+
value: S4.Any
|
|
1013
|
+
}).annotations({
|
|
1014
|
+
description: "Additional props for the dialog."
|
|
1015
|
+
}))
|
|
1016
|
+
})
|
|
1017
|
+
}),
|
|
1018
|
+
output: S4.Void
|
|
1019
|
+
}) {
|
|
1020
|
+
}
|
|
1021
|
+
LayoutAction2.UpdateDialog = UpdateDialog;
|
|
1022
|
+
class UpdatePopover extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1023
|
+
input: S4.Struct({
|
|
1024
|
+
part: S4.Literal("popover").annotations({
|
|
1025
|
+
description: "Updating the popover."
|
|
1026
|
+
}),
|
|
1027
|
+
subject: S4.optional(S4.String.annotations({
|
|
1028
|
+
description: "URI of the component to display in the popover."
|
|
1029
|
+
})),
|
|
1030
|
+
options: S4.Struct({
|
|
1031
|
+
anchorId: S4.String.annotations({
|
|
1032
|
+
description: "The id of the element to anchor the popover to."
|
|
1033
|
+
}),
|
|
1034
|
+
side: S4.optional(S4.Literal("top", "right", "bottom", "left").annotations({
|
|
1035
|
+
description: "The side of the anchor."
|
|
1036
|
+
})),
|
|
1037
|
+
state: S4.optional(S4.Boolean.annotations({
|
|
1038
|
+
description: "Whether the popover is open or closed."
|
|
1039
|
+
})),
|
|
1040
|
+
props: S4.optional(S4.Record({
|
|
1041
|
+
key: S4.String,
|
|
1042
|
+
value: S4.Any
|
|
1043
|
+
}).annotations({
|
|
1044
|
+
description: "Additional props for the popover."
|
|
1045
|
+
}))
|
|
1046
|
+
})
|
|
1047
|
+
}),
|
|
1048
|
+
output: S4.Void
|
|
1049
|
+
}) {
|
|
1050
|
+
}
|
|
1051
|
+
LayoutAction2.UpdatePopover = UpdatePopover;
|
|
1052
|
+
LayoutAction2.Toast = S4.Struct({
|
|
1053
|
+
id: S4.String.annotations({
|
|
1054
|
+
description: "The id of the toast."
|
|
1055
|
+
}),
|
|
1056
|
+
title: S4.optional(Label.annotations({
|
|
1057
|
+
description: "The title of the toast."
|
|
1058
|
+
})),
|
|
1059
|
+
description: S4.optional(Label.annotations({
|
|
1060
|
+
description: "The description of the toast."
|
|
1061
|
+
})),
|
|
1062
|
+
icon: S4.optional(S4.String.annotations({
|
|
1063
|
+
description: "The icon of the toast."
|
|
1064
|
+
})),
|
|
1065
|
+
duration: S4.optional(S4.Number.annotations({
|
|
1066
|
+
description: "The duration of the toast."
|
|
1067
|
+
})),
|
|
1068
|
+
closeLabel: S4.optional(Label.annotations({
|
|
1069
|
+
description: "The label of the close button."
|
|
1070
|
+
})),
|
|
1071
|
+
actionLabel: S4.optional(Label.annotations({
|
|
1072
|
+
description: "The label of the action button."
|
|
1073
|
+
})),
|
|
1074
|
+
actionAlt: S4.optional(Label.annotations({
|
|
1075
|
+
description: "The alt text of the action button."
|
|
1076
|
+
})),
|
|
1077
|
+
onAction: S4.optional(S4.Any.annotations({
|
|
1078
|
+
description: "The action to perform when the action button is clicked."
|
|
1079
|
+
}))
|
|
1080
|
+
});
|
|
1081
|
+
class AddToast extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1082
|
+
input: S4.Struct({
|
|
1083
|
+
part: S4.Literal("toast").annotations({
|
|
1084
|
+
description: "Adding a toast."
|
|
1085
|
+
}),
|
|
1086
|
+
subject: LayoutAction2.Toast.annotations({
|
|
1087
|
+
description: "The toast to add."
|
|
1088
|
+
})
|
|
1089
|
+
}),
|
|
1090
|
+
output: S4.Void
|
|
1091
|
+
}) {
|
|
1092
|
+
}
|
|
1093
|
+
LayoutAction2.AddToast = AddToast;
|
|
1094
|
+
class SwitchWorkspace extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1095
|
+
input: S4.Struct({
|
|
1096
|
+
part: S4.Literal("workspace").annotations({
|
|
1097
|
+
description: "Switching the workspace."
|
|
1098
|
+
}),
|
|
1099
|
+
subject: S4.String.annotations({
|
|
1100
|
+
description: "The id of the workspace to switch to."
|
|
1101
|
+
})
|
|
1102
|
+
}),
|
|
1103
|
+
output: S4.Void
|
|
1104
|
+
}) {
|
|
1105
|
+
}
|
|
1106
|
+
LayoutAction2.SwitchWorkspace = SwitchWorkspace;
|
|
1107
|
+
class RevertWorkspace extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1108
|
+
input: S4.Struct({
|
|
1109
|
+
part: S4.Literal("workspace").annotations({
|
|
1110
|
+
description: "Switching the workspace."
|
|
1111
|
+
}),
|
|
1112
|
+
options: S4.Struct({
|
|
1113
|
+
revert: S4.Literal(true).annotations({
|
|
1114
|
+
description: "Revert to the previous workspace."
|
|
1115
|
+
})
|
|
1116
|
+
})
|
|
1117
|
+
}),
|
|
1118
|
+
output: S4.Void
|
|
1119
|
+
}) {
|
|
1120
|
+
}
|
|
1121
|
+
LayoutAction2.RevertWorkspace = RevertWorkspace;
|
|
1122
|
+
class Open extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1123
|
+
input: S4.Struct({
|
|
1124
|
+
part: S4.Literal("main").annotations({
|
|
1125
|
+
description: "Opening an item in the main content area."
|
|
1126
|
+
}),
|
|
1127
|
+
subject: S4.Array(S4.String.annotations({
|
|
1128
|
+
description: "Ids of the items to open."
|
|
1129
|
+
})),
|
|
1130
|
+
options: S4.optional(S4.Struct({
|
|
1131
|
+
state: S4.optional(S4.Literal(true).annotations({
|
|
1132
|
+
description: "The items are being added."
|
|
1133
|
+
})),
|
|
1134
|
+
key: S4.optional(S4.String.annotations({
|
|
1135
|
+
description: "If provided, will replace item with a matching key (id prefix)."
|
|
1136
|
+
})),
|
|
1137
|
+
scrollIntoView: S4.optional(S4.Boolean.annotations({
|
|
1138
|
+
description: "Scroll the items into view."
|
|
1139
|
+
})),
|
|
1140
|
+
pivotId: S4.optional(S4.String.annotations({
|
|
1141
|
+
description: "The id of the item to place new items next to."
|
|
1142
|
+
})),
|
|
1143
|
+
positioning: S4.optional(S4.Union(S4.Literal("start").annotations({
|
|
1144
|
+
description: "The items are being added before the pivot item."
|
|
1145
|
+
}), S4.Literal("end").annotations({
|
|
1146
|
+
description: "The items are being added after the pivot item."
|
|
1147
|
+
})))
|
|
1148
|
+
}))
|
|
1149
|
+
}),
|
|
1150
|
+
output: S4.Void
|
|
1151
|
+
}) {
|
|
1152
|
+
}
|
|
1153
|
+
LayoutAction2.Open = Open;
|
|
1154
|
+
class Set2 extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1155
|
+
input: S4.Struct({
|
|
1156
|
+
part: S4.Literal("main").annotations({
|
|
1157
|
+
description: "Setting items in the main content area."
|
|
1158
|
+
}),
|
|
1159
|
+
subject: S4.Array(S4.String.annotations({
|
|
1160
|
+
description: "Ids of the items to set."
|
|
1161
|
+
})),
|
|
1162
|
+
options: S4.Struct({
|
|
1163
|
+
override: S4.Literal(true).annotations({
|
|
1164
|
+
description: "Override the current items in the main content area."
|
|
1165
|
+
})
|
|
1166
|
+
})
|
|
1167
|
+
}),
|
|
1168
|
+
output: S4.Void
|
|
1169
|
+
}) {
|
|
1170
|
+
}
|
|
1171
|
+
LayoutAction2.Set = Set2;
|
|
1172
|
+
class Close extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1173
|
+
input: S4.Struct({
|
|
1174
|
+
part: S4.Literal("main").annotations({
|
|
1175
|
+
description: "Closing items in the main content area."
|
|
1176
|
+
}),
|
|
1177
|
+
subject: S4.Array(S4.String.annotations({
|
|
1178
|
+
description: "Ids of the items to close."
|
|
1179
|
+
})),
|
|
1180
|
+
options: S4.Struct({
|
|
1181
|
+
state: S4.Literal(false).annotations({
|
|
1182
|
+
description: "The items are being removed."
|
|
1183
|
+
})
|
|
1184
|
+
})
|
|
1185
|
+
}),
|
|
1186
|
+
output: S4.Void
|
|
1187
|
+
}) {
|
|
1188
|
+
}
|
|
1189
|
+
LayoutAction2.Close = Close;
|
|
1190
|
+
class ScrollIntoView extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1191
|
+
input: S4.Struct({
|
|
1192
|
+
part: S4.Literal("current").annotations({
|
|
1193
|
+
description: "Setting the current item"
|
|
1194
|
+
}),
|
|
1195
|
+
subject: S4.optional(S4.String.annotations({
|
|
1196
|
+
description: "The id of the item to set as current."
|
|
1197
|
+
})),
|
|
1198
|
+
options: S4.optional(S4.Record({
|
|
1199
|
+
key: S4.String,
|
|
1200
|
+
value: S4.Any
|
|
1201
|
+
}).annotations({
|
|
1202
|
+
description: "Additional options for the scroll into view."
|
|
1203
|
+
}))
|
|
1204
|
+
}),
|
|
1205
|
+
output: S4.Void
|
|
1206
|
+
}) {
|
|
1207
|
+
}
|
|
1208
|
+
LayoutAction2.ScrollIntoView = ScrollIntoView;
|
|
1209
|
+
class Expose extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
|
|
1210
|
+
input: S4.Struct({
|
|
1211
|
+
part: S4.Literal("navigation").annotations({
|
|
1212
|
+
description: "Exposing an item in the navigation area."
|
|
1213
|
+
}),
|
|
1214
|
+
subject: S4.String.annotations({
|
|
1215
|
+
description: "The id of the item to expose."
|
|
1216
|
+
})
|
|
1217
|
+
}),
|
|
1218
|
+
output: S4.Void
|
|
1219
|
+
}) {
|
|
1220
|
+
}
|
|
1221
|
+
LayoutAction2.Expose = Expose;
|
|
1222
|
+
})(LayoutAction || (LayoutAction = {}));
|
|
1223
|
+
|
|
1224
|
+
// packages/sdk/app-framework/src/common/surface.ts
|
|
1225
|
+
var createSurface = (definition) => definition;
|
|
1226
|
+
|
|
1227
|
+
// packages/sdk/app-framework/src/common/translations.ts
|
|
1228
|
+
import { Schema as S5 } from "@effect/schema";
|
|
1229
|
+
var ResourceKey = S5.Union(S5.String, S5.Record({
|
|
1230
|
+
key: S5.String,
|
|
1231
|
+
value: S5.Any
|
|
1232
|
+
}));
|
|
1233
|
+
var ResourceLanguage = S5.Record({
|
|
1234
|
+
key: S5.String,
|
|
1235
|
+
value: ResourceKey
|
|
1236
|
+
});
|
|
1237
|
+
var Resource = S5.Record({
|
|
1238
|
+
key: S5.String,
|
|
1239
|
+
value: ResourceLanguage
|
|
1240
|
+
});
|
|
830
1241
|
|
|
831
1242
|
// packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts
|
|
1243
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts";
|
|
832
1244
|
var EXECUTION_LIMIT = 100;
|
|
833
1245
|
var HISTORY_LIMIT = 100;
|
|
834
|
-
var createResolver = (
|
|
835
|
-
action: schema._tag,
|
|
836
|
-
effect: effect3,
|
|
837
|
-
...params
|
|
838
|
-
});
|
|
1246
|
+
var createResolver = (resolver) => resolver;
|
|
839
1247
|
var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
|
|
840
1248
|
var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
|
|
841
1249
|
const historyRef = Effect2.runSync(Ref.make([]));
|
|
842
|
-
const handleIntent = (intent) => {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
_intent: intent,
|
|
855
|
-
...result
|
|
856
|
-
};
|
|
857
|
-
});
|
|
858
|
-
};
|
|
1250
|
+
const handleIntent = (intent) => Effect2.gen(function* () {
|
|
1251
|
+
const candidates = getResolvers(intent.module).filter((r) => r.intent._tag === intent.id).filter((r) => !r.filter || r.filter(intent.data)).toSorted(byPosition);
|
|
1252
|
+
if (candidates.length === 0) {
|
|
1253
|
+
yield* Effect2.fail(new NoResolversError(intent.id));
|
|
1254
|
+
}
|
|
1255
|
+
const effect2 = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
1256
|
+
const result = Effect2.isEffect(effect2) ? yield* effect2 : yield* Effect2.promise(async () => effect2);
|
|
1257
|
+
return {
|
|
1258
|
+
_intent: intent,
|
|
1259
|
+
...result
|
|
1260
|
+
};
|
|
1261
|
+
});
|
|
859
1262
|
const dispatch = (intentChain, depth = 0) => {
|
|
860
1263
|
return Effect2.gen(function* () {
|
|
861
1264
|
if (depth > executionLimit) {
|
|
@@ -897,7 +1300,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
897
1300
|
return next;
|
|
898
1301
|
});
|
|
899
1302
|
if (result.undoable && isUndoable(results)) {
|
|
900
|
-
yield*
|
|
1303
|
+
yield* pipe2(dispatch(createIntent(IntentAction.ShowUndo, {
|
|
901
1304
|
message: result.undoable.message
|
|
902
1305
|
})), Effect2.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect2.succeed(void 0)) : Option.none()));
|
|
903
1306
|
}
|
|
@@ -907,9 +1310,17 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
907
1310
|
const dispatchPromise = (intentChain) => {
|
|
908
1311
|
return Effect2.runPromise(dispatch(intentChain)).then((data) => ({
|
|
909
1312
|
data
|
|
910
|
-
})).catch((error) =>
|
|
911
|
-
error
|
|
912
|
-
|
|
1313
|
+
})).catch((error) => {
|
|
1314
|
+
log3.catch(error, void 0, {
|
|
1315
|
+
F: __dxlog_file3,
|
|
1316
|
+
L: 241,
|
|
1317
|
+
S: void 0,
|
|
1318
|
+
C: (f, a) => f(...a)
|
|
1319
|
+
});
|
|
1320
|
+
return {
|
|
1321
|
+
error
|
|
1322
|
+
};
|
|
1323
|
+
});
|
|
913
1324
|
};
|
|
914
1325
|
const undo = () => {
|
|
915
1326
|
return Effect2.gen(function* () {
|
|
@@ -953,578 +1364,32 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
953
1364
|
undoPromise
|
|
954
1365
|
};
|
|
955
1366
|
};
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
static getDerivedStateFromError(error) {
|
|
967
|
-
return {
|
|
968
|
-
error
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
componentDidUpdate(prevProps) {
|
|
972
|
-
if (prevProps.data !== this.props.data) {
|
|
973
|
-
this.resetError();
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
render() {
|
|
977
|
-
if (this.state.error) {
|
|
978
|
-
return /* @__PURE__ */ React.createElement(this.props.fallback, {
|
|
979
|
-
data: this.props.data,
|
|
980
|
-
error: this.state.error,
|
|
981
|
-
reset: this.resetError
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
return this.props.children;
|
|
985
|
-
}
|
|
986
|
-
resetError() {
|
|
987
|
-
this.setState({
|
|
988
|
-
error: void 0
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
};
|
|
992
|
-
|
|
993
|
-
// packages/sdk/app-framework/src/react/PluginManagerProvider.ts
|
|
994
|
-
import { createContext, useContext } from "react";
|
|
995
|
-
import { raise } from "@dxos/debug";
|
|
996
|
-
var PluginManagerContext = createContext(void 0);
|
|
997
|
-
var usePluginManager = () => useContext(PluginManagerContext) ?? raise(new Error("Missing PluginManagerContext"));
|
|
998
|
-
var PluginManagerProvider = PluginManagerContext.Provider;
|
|
999
|
-
|
|
1000
|
-
// packages/sdk/app-framework/src/react/useCapabilities.ts
|
|
1001
|
-
import { computed } from "@preact/signals-core";
|
|
1002
|
-
import { useMemo } from "react";
|
|
1003
|
-
var useCapabilities = (interfaceDef, filter) => {
|
|
1004
|
-
const manager = usePluginManager();
|
|
1005
|
-
const signal = useMemo(() => computed(() => manager.context.requestCapabilities(interfaceDef, filter)), [
|
|
1006
|
-
interfaceDef
|
|
1007
|
-
]);
|
|
1008
|
-
return signal.value;
|
|
1009
|
-
};
|
|
1010
|
-
var useCapability = (interfaceDef, filter) => {
|
|
1011
|
-
const manager = usePluginManager();
|
|
1012
|
-
const signal = useMemo(() => computed(() => manager.context.requestCapability(interfaceDef, filter)), [
|
|
1013
|
-
interfaceDef
|
|
1014
|
-
]);
|
|
1015
|
-
return signal.value;
|
|
1016
|
-
};
|
|
1017
|
-
|
|
1018
|
-
// packages/sdk/app-framework/src/react/Surface.tsx
|
|
1019
|
-
import React3, { memo, forwardRef, Suspense, useMemo as useMemo2 } from "react";
|
|
1020
|
-
import { useDefaultValue } from "@dxos/react-hooks";
|
|
1021
|
-
import { byDisposition as byDisposition2 } from "@dxos/util";
|
|
1022
|
-
|
|
1023
|
-
// packages/sdk/app-framework/src/common/layout.ts
|
|
1024
|
-
import { S as S4 } from "@dxos/echo-schema";
|
|
1025
|
-
|
|
1026
|
-
// packages/sdk/app-framework/src/plugin-intent/IntentContext.tsx
|
|
1027
|
-
import { createContext as createContext2, useContext as useContext2, useEffect } from "react";
|
|
1028
|
-
import { raise as raise2 } from "@dxos/debug";
|
|
1029
|
-
import { pick } from "@dxos/util";
|
|
1030
|
-
var IntentContext = /* @__PURE__ */ createContext2(void 0);
|
|
1031
|
-
var useIntentDispatcher = () => {
|
|
1032
|
-
const context = useContext2(IntentContext) ?? raise2(new Error("IntentContext not found"));
|
|
1033
|
-
return pick(context, [
|
|
1034
|
-
"dispatch",
|
|
1035
|
-
"dispatchPromise"
|
|
1036
|
-
]);
|
|
1037
|
-
};
|
|
1038
|
-
var useIntentResolver = (module, resolver) => {
|
|
1039
|
-
const manager = usePluginManager();
|
|
1040
|
-
useEffect(() => {
|
|
1041
|
-
manager.context.contributeCapability({
|
|
1042
|
-
module,
|
|
1043
|
-
interface: Capabilities.IntentResolver,
|
|
1044
|
-
implementation: resolver
|
|
1045
|
-
});
|
|
1046
|
-
return () => manager.context.removeCapability(Capabilities.IntentResolver, resolver);
|
|
1047
|
-
}, [
|
|
1048
|
-
module,
|
|
1049
|
-
resolver
|
|
1050
|
-
]);
|
|
1051
|
-
};
|
|
1052
|
-
var IntentProvider = IntentContext.Provider;
|
|
1053
|
-
|
|
1054
|
-
// packages/sdk/app-framework/src/plugin-intent/IntentPlugin.tsx
|
|
1055
|
-
import { Effect as Effect3 } from "effect";
|
|
1056
|
-
import React2 from "react";
|
|
1057
|
-
import { create as create3 } from "@dxos/live-object";
|
|
1058
|
-
var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
|
|
1059
|
-
var defaultPromise = () => Effect3.runPromise(defaultEffect());
|
|
1060
|
-
var IntentPlugin = () => definePlugin({
|
|
1061
|
-
id: INTENT_PLUGIN
|
|
1062
|
-
}, [
|
|
1063
|
-
defineModule({
|
|
1064
|
-
id: `${INTENT_PLUGIN}/module/dispatcher`,
|
|
1065
|
-
// TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
|
|
1066
|
-
// This is fine for now because it's how it worked prior to capabilities api anyways.
|
|
1067
|
-
// In the future, the intent dispatcher should be able to be reset without resetting the entire app.
|
|
1068
|
-
activatesOn: Events.Startup,
|
|
1069
|
-
activatesBefore: [
|
|
1070
|
-
Events.SetupIntents
|
|
1071
|
-
],
|
|
1072
|
-
activatesAfter: [
|
|
1073
|
-
Events.DispatcherReady
|
|
1074
|
-
],
|
|
1075
|
-
activate: (context) => {
|
|
1076
|
-
const state = create3({
|
|
1077
|
-
dispatch: defaultEffect,
|
|
1078
|
-
dispatchPromise: defaultPromise,
|
|
1079
|
-
undo: defaultEffect,
|
|
1080
|
-
undoPromise: defaultPromise
|
|
1081
|
-
});
|
|
1082
|
-
const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher((module) => context.requestCapabilities(Capabilities.IntentResolver, (c, moduleId) => {
|
|
1083
|
-
return module ? moduleId === module : true;
|
|
1084
|
-
}).flat());
|
|
1085
|
-
state.dispatch = dispatch;
|
|
1086
|
-
state.dispatchPromise = dispatchPromise;
|
|
1087
|
-
state.undo = undo;
|
|
1088
|
-
state.undoPromise = undoPromise;
|
|
1089
|
-
return [
|
|
1090
|
-
contributes(Capabilities.IntentDispatcher, state),
|
|
1091
|
-
contributes(Capabilities.ReactContext, {
|
|
1092
|
-
id: INTENT_PLUGIN,
|
|
1093
|
-
context: ({ children }) => /* @__PURE__ */ React2.createElement(IntentProvider, {
|
|
1094
|
-
value: state
|
|
1095
|
-
}, children)
|
|
1096
|
-
})
|
|
1097
|
-
];
|
|
1098
|
-
}
|
|
1099
|
-
})
|
|
1100
|
-
]);
|
|
1101
|
-
|
|
1102
|
-
// packages/sdk/app-framework/src/common/layout.ts
|
|
1103
|
-
var Toast = S4.Struct({
|
|
1104
|
-
id: S4.String,
|
|
1105
|
-
title: S4.optional(Label),
|
|
1106
|
-
description: S4.optional(Label),
|
|
1107
|
-
icon: S4.optional(S4.String),
|
|
1108
|
-
duration: S4.optional(S4.Number),
|
|
1109
|
-
closeLabel: S4.optional(Label),
|
|
1110
|
-
actionLabel: S4.optional(Label),
|
|
1111
|
-
actionAlt: S4.optional(Label),
|
|
1112
|
-
// TODO(wittjosiah): Make class with customizable method?
|
|
1113
|
-
onAction: S4.optional(S4.Any)
|
|
1114
|
-
});
|
|
1115
|
-
var LayoutMode = S4.Union(S4.Literal("deck"), S4.Literal("solo"), S4.Literal("fullscreen"));
|
|
1116
|
-
var isLayoutMode = (value) => S4.is(LayoutMode)(value);
|
|
1117
|
-
var Layout = S4.mutable(S4.Struct({
|
|
1118
|
-
layoutMode: LayoutMode,
|
|
1119
|
-
sidebarOpen: S4.Boolean,
|
|
1120
|
-
complementarySidebarOpen: S4.Boolean,
|
|
1121
|
-
/**
|
|
1122
|
-
* @deprecated Data to be passed to the complementary sidebar Surface.
|
|
1123
|
-
*/
|
|
1124
|
-
complementarySidebarContent: S4.optional(S4.Any),
|
|
1125
|
-
dialogOpen: S4.Boolean,
|
|
1126
|
-
/**
|
|
1127
|
-
* Data to be passed to the dialog Surface.
|
|
1128
|
-
*/
|
|
1129
|
-
dialogContent: S4.optional(S4.Any),
|
|
1130
|
-
// TODO(wittjosiah): Custom properties?
|
|
1131
|
-
dialogBlockAlign: S4.optional(S4.Literal("start", "center")),
|
|
1132
|
-
dialogType: S4.optional(S4.Literal("default", "alert")),
|
|
1133
|
-
popoverOpen: S4.Boolean,
|
|
1134
|
-
/**
|
|
1135
|
-
* Data to be passed to the popover Surface.
|
|
1136
|
-
*/
|
|
1137
|
-
popoverContent: S4.optional(S4.Any),
|
|
1138
|
-
popoverAnchorId: S4.optional(S4.String),
|
|
1139
|
-
toasts: S4.mutable(S4.Array(Toast)),
|
|
1140
|
-
/**
|
|
1141
|
-
* The identifier of a component to scroll into view when it is mounted.
|
|
1142
|
-
*/
|
|
1143
|
-
scrollIntoView: S4.optional(S4.String)
|
|
1144
|
-
}));
|
|
1145
|
-
var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
|
|
1146
|
-
var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
|
|
1147
|
-
var LayoutAction;
|
|
1148
|
-
(function(LayoutAction2) {
|
|
1149
|
-
class SetLayout extends S4.TaggedClass()(`${LAYOUT_ACTION}/set-layout`, {
|
|
1150
|
-
input: S4.Struct({
|
|
1151
|
-
/**
|
|
1152
|
-
* Element to set the state of.
|
|
1153
|
-
*/
|
|
1154
|
-
element: S4.Literal("fullscreen", "sidebar", "complementary", "dialog", "popover", "toast"),
|
|
1155
|
-
/**
|
|
1156
|
-
* Whether the element is on or off.
|
|
1157
|
-
*
|
|
1158
|
-
* If omitted, the element's state will be toggled or set based on other provided data.
|
|
1159
|
-
* For example, if `component` is provided, the state will be set to `true`.
|
|
1160
|
-
*/
|
|
1161
|
-
state: S4.optional(S4.Boolean),
|
|
1162
|
-
/**
|
|
1163
|
-
* Component to render in the dialog or popover.
|
|
1164
|
-
*/
|
|
1165
|
-
component: S4.optional(S4.String),
|
|
1166
|
-
/**
|
|
1167
|
-
* Data to be passed to the dialog or popover Surface.
|
|
1168
|
-
*/
|
|
1169
|
-
subject: S4.optional(S4.Any),
|
|
1170
|
-
/**
|
|
1171
|
-
* Anchor ID for the popover.
|
|
1172
|
-
*/
|
|
1173
|
-
anchorId: S4.optional(S4.String),
|
|
1174
|
-
// TODO(wittjosiah): Custom properties?
|
|
1175
|
-
/**
|
|
1176
|
-
* Block alignment for the dialog.
|
|
1177
|
-
*/
|
|
1178
|
-
dialogBlockAlign: S4.optional(S4.Literal("start", "center")),
|
|
1179
|
-
/**
|
|
1180
|
-
* Type of dialog.
|
|
1181
|
-
*/
|
|
1182
|
-
dialogType: S4.optional(S4.Literal("default", "alert"))
|
|
1183
|
-
}),
|
|
1184
|
-
output: S4.Void
|
|
1185
|
-
}) {
|
|
1186
|
-
}
|
|
1187
|
-
LayoutAction2.SetLayout = SetLayout;
|
|
1188
|
-
class SetLayoutMode extends S4.TaggedClass()(`${LAYOUT_ACTION}/set-layout-mode`, {
|
|
1189
|
-
input: S4.Union(S4.Struct({
|
|
1190
|
-
layoutMode: LayoutMode
|
|
1191
|
-
}), S4.Struct({
|
|
1192
|
-
revert: S4.Literal(true)
|
|
1193
|
-
})),
|
|
1194
|
-
output: S4.Void
|
|
1195
|
-
}) {
|
|
1196
|
-
}
|
|
1197
|
-
LayoutAction2.SetLayoutMode = SetLayoutMode;
|
|
1198
|
-
class ScrollIntoView extends S4.TaggedClass()(`${LAYOUT_ACTION}/scroll-into-view`, {
|
|
1199
|
-
input: S4.Struct({
|
|
1200
|
-
id: S4.optional(S4.String),
|
|
1201
|
-
// TODO(wittjosiah): Factor out to thread scroll into view action?
|
|
1202
|
-
cursor: S4.optional(S4.String),
|
|
1203
|
-
ref: S4.optional(S4.String)
|
|
1204
|
-
}),
|
|
1205
|
-
output: S4.Void
|
|
1206
|
-
}) {
|
|
1207
|
-
}
|
|
1208
|
-
LayoutAction2.ScrollIntoView = ScrollIntoView;
|
|
1209
|
-
})(LayoutAction || (LayoutAction = {}));
|
|
1210
|
-
|
|
1211
|
-
// packages/sdk/app-framework/src/common/navigation.ts
|
|
1212
|
-
import { Schema as S5 } from "@effect/schema";
|
|
1213
|
-
import { pick as pick2 } from "@dxos/util";
|
|
1214
|
-
var SLUG_LIST_SEPARATOR = "+";
|
|
1215
|
-
var SLUG_ENTRY_SEPARATOR = "_";
|
|
1216
|
-
var SLUG_KEY_VALUE_SEPARATOR = "-";
|
|
1217
|
-
var SLUG_PATH_SEPARATOR = "~";
|
|
1218
|
-
var SLUG_COLLECTION_INDICATOR = "";
|
|
1219
|
-
var LayoutEntrySchema = S5.mutable(S5.Struct({
|
|
1220
|
-
id: S5.String,
|
|
1221
|
-
path: S5.optional(S5.String)
|
|
1222
|
-
}));
|
|
1223
|
-
var LayoutPartSchema = S5.Union(S5.Literal("sidebar"), S5.Literal("main"), S5.Literal("solo"), S5.Literal("complementary"), S5.Literal("fullScreen"));
|
|
1224
|
-
var LayoutPartsSchema = S5.partial(S5.mutable(S5.Record({
|
|
1225
|
-
key: LayoutPartSchema,
|
|
1226
|
-
value: S5.mutable(S5.Array(LayoutEntrySchema))
|
|
1227
|
-
})));
|
|
1228
|
-
var LayoutCoordinateSchema = S5.mutable(S5.Struct({
|
|
1229
|
-
part: LayoutPartSchema,
|
|
1230
|
-
entryId: S5.String
|
|
1231
|
-
}));
|
|
1232
|
-
var PartAdjustmentSchema = S5.Union(S5.Literal("increment-start"), S5.Literal("increment-end"), S5.Literal("pin-start"), S5.Literal("pin-end"), S5.Literal("close"), S5.Literal("solo"));
|
|
1233
|
-
var LayoutAdjustmentSchema = S5.mutable(S5.Struct({
|
|
1234
|
-
layoutCoordinate: LayoutCoordinateSchema,
|
|
1235
|
-
type: PartAdjustmentSchema
|
|
1236
|
-
}));
|
|
1237
|
-
var ActiveParts = S5.Record({
|
|
1238
|
-
key: S5.String,
|
|
1239
|
-
value: S5.Union(S5.String, S5.mutable(S5.Array(S5.String)))
|
|
1240
|
-
});
|
|
1241
|
-
var LocationProvidesSchema = S5.mutable(S5.Struct({
|
|
1242
|
-
location: S5.Struct({
|
|
1243
|
-
active: LayoutPartsSchema,
|
|
1244
|
-
closed: S5.Array(S5.String)
|
|
1245
|
-
})
|
|
1246
|
-
}));
|
|
1247
|
-
var isLayoutParts = (value) => {
|
|
1248
|
-
return S5.is(LayoutPartsSchema)(value);
|
|
1249
|
-
};
|
|
1250
|
-
var isLayoutAdjustment = (value) => {
|
|
1251
|
-
return S5.is(LayoutAdjustmentSchema)(value);
|
|
1252
|
-
};
|
|
1253
|
-
var openIds = (layout, parts) => {
|
|
1254
|
-
return Object.values(parts ? pick2(layout, parts) : layout).flatMap((part) => part?.map((entry) => entry.id) ?? []).filter((id) => id !== void 0);
|
|
1255
|
-
};
|
|
1256
|
-
var firstIdInPart = (layout, part) => {
|
|
1257
|
-
if (!layout) {
|
|
1258
|
-
return void 0;
|
|
1259
|
-
}
|
|
1260
|
-
return layout[part]?.at(0)?.id;
|
|
1261
|
-
};
|
|
1262
|
-
var indexInPart = (layout, layoutCoordinate) => {
|
|
1263
|
-
if (!layout || !layoutCoordinate) {
|
|
1264
|
-
return void 0;
|
|
1265
|
-
}
|
|
1266
|
-
const { part, entryId } = layoutCoordinate;
|
|
1267
|
-
return layout[part]?.findIndex((entry) => entry.id === entryId);
|
|
1268
|
-
};
|
|
1269
|
-
var partLength = (layout, part) => {
|
|
1270
|
-
if (!layout || !part) {
|
|
1271
|
-
return 0;
|
|
1272
|
-
}
|
|
1273
|
-
return layout[part]?.length ?? 0;
|
|
1274
|
-
};
|
|
1275
|
-
var NAVIGATION_PLUGIN = "dxos.org/plugin/navigation";
|
|
1276
|
-
var NAVIGATION_ACTION = `${NAVIGATION_PLUGIN}/action`;
|
|
1277
|
-
var NavigationAction;
|
|
1278
|
-
(function(NavigationAction2) {
|
|
1279
|
-
class Open extends S5.TaggedClass()(`${NAVIGATION_ACTION}/open`, {
|
|
1280
|
-
input: S5.Struct({
|
|
1281
|
-
activeParts: ActiveParts,
|
|
1282
|
-
noToggle: S5.optional(S5.Boolean)
|
|
1283
|
-
}),
|
|
1284
|
-
output: S5.Struct({
|
|
1285
|
-
open: S5.Array(S5.String)
|
|
1286
|
-
})
|
|
1287
|
-
}) {
|
|
1288
|
-
}
|
|
1289
|
-
NavigationAction2.Open = Open;
|
|
1290
|
-
class AddToActive extends S5.TaggedClass()(`${NAVIGATION_ACTION}/add-to-active`, {
|
|
1291
|
-
input: S5.Struct({
|
|
1292
|
-
id: S5.String,
|
|
1293
|
-
part: LayoutPartSchema,
|
|
1294
|
-
scrollIntoView: S5.optional(S5.Boolean),
|
|
1295
|
-
pivotId: S5.optional(S5.String),
|
|
1296
|
-
positioning: S5.optional(S5.Literal("start", "end"))
|
|
1297
|
-
}),
|
|
1298
|
-
output: S5.Void
|
|
1299
|
-
}) {
|
|
1300
|
-
}
|
|
1301
|
-
NavigationAction2.AddToActive = AddToActive;
|
|
1302
|
-
class Set2 extends S5.TaggedClass()(`${NAVIGATION_ACTION}/set`, {
|
|
1303
|
-
input: S5.Struct({
|
|
1304
|
-
activeParts: ActiveParts
|
|
1305
|
-
}),
|
|
1306
|
-
output: S5.Void
|
|
1307
|
-
}) {
|
|
1308
|
-
}
|
|
1309
|
-
NavigationAction2.Set = Set2;
|
|
1310
|
-
class Close extends S5.TaggedClass()(`${NAVIGATION_ACTION}/close`, {
|
|
1311
|
-
input: S5.Struct({
|
|
1312
|
-
activeParts: ActiveParts,
|
|
1313
|
-
noToggle: S5.optional(S5.Boolean)
|
|
1314
|
-
}),
|
|
1315
|
-
output: S5.Void
|
|
1316
|
-
}) {
|
|
1317
|
-
}
|
|
1318
|
-
NavigationAction2.Close = Close;
|
|
1319
|
-
class Adjust extends S5.TaggedClass()(`${NAVIGATION_ACTION}/adjust`, {
|
|
1320
|
-
input: LayoutAdjustmentSchema,
|
|
1321
|
-
output: S5.Void
|
|
1322
|
-
}) {
|
|
1323
|
-
}
|
|
1324
|
-
NavigationAction2.Adjust = Adjust;
|
|
1325
|
-
class Expose extends S5.TaggedClass()(`${NAVIGATION_ACTION}/expose`, {
|
|
1326
|
-
input: S5.Struct({
|
|
1327
|
-
id: S5.String
|
|
1328
|
-
}),
|
|
1329
|
-
output: S5.Void
|
|
1330
|
-
}) {
|
|
1331
|
-
}
|
|
1332
|
-
NavigationAction2.Expose = Expose;
|
|
1333
|
-
})(NavigationAction || (NavigationAction = {}));
|
|
1334
|
-
|
|
1335
|
-
// packages/sdk/app-framework/src/common/surface.ts
|
|
1336
|
-
var createSurface = (definition) => definition;
|
|
1337
|
-
|
|
1338
|
-
// packages/sdk/app-framework/src/common/translations.ts
|
|
1339
|
-
import { z } from "zod";
|
|
1340
|
-
var ResourceKey = z.union([
|
|
1341
|
-
z.string(),
|
|
1342
|
-
z.record(z.any())
|
|
1343
|
-
]);
|
|
1344
|
-
var ResourceLanguage = z.record(ResourceKey);
|
|
1345
|
-
var Resource = z.record(ResourceLanguage);
|
|
1346
|
-
|
|
1347
|
-
// packages/sdk/app-framework/src/react/Surface.tsx
|
|
1348
|
-
var useSurfaces = () => {
|
|
1349
|
-
const surfaces = useCapabilities(Capabilities.ReactSurface);
|
|
1350
|
-
return useMemo2(() => surfaces.flat(), [
|
|
1351
|
-
surfaces
|
|
1352
|
-
]);
|
|
1353
|
-
};
|
|
1354
|
-
var findCandidates = (surfaces, { role, data }) => {
|
|
1355
|
-
return Object.values(surfaces).filter((definition) => Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role).filter(({ filter }) => filter ? filter(data ?? {}) : true).toSorted(byDisposition2);
|
|
1356
|
-
};
|
|
1357
|
-
var isSurfaceAvailable = (context, { role, data }) => {
|
|
1358
|
-
const surfaces = context.requestCapabilities(Capabilities.ReactSurface);
|
|
1359
|
-
const candidates = findCandidates(surfaces.flat(), {
|
|
1360
|
-
role,
|
|
1361
|
-
data
|
|
1367
|
+
var defaultEffect = () => Effect2.fail(new Error("Intent runtime not ready"));
|
|
1368
|
+
var defaultPromise = () => Effect2.runPromise(defaultEffect());
|
|
1369
|
+
var intent_dispatcher_default = (context) => {
|
|
1370
|
+
const state = create3({
|
|
1371
|
+
dispatch: defaultEffect,
|
|
1372
|
+
dispatchPromise: defaultPromise,
|
|
1373
|
+
undo: defaultEffect,
|
|
1374
|
+
undoPromise: defaultPromise
|
|
1362
1375
|
});
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
const
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
data
|
|
1376
|
+
const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher((module) => context.requestCapabilities(Capabilities.IntentResolver, (c, moduleId) => {
|
|
1377
|
+
return module ? moduleId === module : true;
|
|
1378
|
+
}).flat());
|
|
1379
|
+
const manager = context.requestCapability(Capabilities.PluginManager);
|
|
1380
|
+
state.dispatch = (intentChain, depth) => {
|
|
1381
|
+
return Effect2.gen(function* () {
|
|
1382
|
+
yield* manager._activate(Events.SetupIntentResolver);
|
|
1383
|
+
return yield* dispatch(intentChain, depth);
|
|
1372
1384
|
});
|
|
1373
|
-
return limit ? definitions.slice(0, limit) : definitions;
|
|
1374
|
-
}, [
|
|
1375
|
-
surfaces,
|
|
1376
|
-
role,
|
|
1377
|
-
data,
|
|
1378
|
-
limit
|
|
1379
|
-
]);
|
|
1380
|
-
const nodes = candidates.map(({ component: Component2, id }) => /* @__PURE__ */ React3.createElement(Component2, {
|
|
1381
|
-
ref: forwardedRef,
|
|
1382
|
-
key: id,
|
|
1383
|
-
id,
|
|
1384
|
-
role,
|
|
1385
|
-
data,
|
|
1386
|
-
limit,
|
|
1387
|
-
...rest
|
|
1388
|
-
}));
|
|
1389
|
-
const suspense = placeholder ? /* @__PURE__ */ React3.createElement(Suspense, {
|
|
1390
|
-
fallback: placeholder
|
|
1391
|
-
}, nodes) : nodes;
|
|
1392
|
-
return fallback ? /* @__PURE__ */ React3.createElement(ErrorBoundary, {
|
|
1393
|
-
data,
|
|
1394
|
-
fallback
|
|
1395
|
-
}, suspense) : suspense;
|
|
1396
|
-
}));
|
|
1397
|
-
|
|
1398
|
-
// packages/sdk/app-framework/src/App.tsx
|
|
1399
|
-
import { effect as effect2 } from "@preact/signals-core";
|
|
1400
|
-
import React4 from "react";
|
|
1401
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1402
|
-
import { create as create4 } from "@dxos/live-object";
|
|
1403
|
-
|
|
1404
|
-
// packages/sdk/app-framework/src/helpers.ts
|
|
1405
|
-
var topologicalSort = (nodes) => {
|
|
1406
|
-
const getDependencies = (nodeId, seen = /* @__PURE__ */ new Set(), path = /* @__PURE__ */ new Set()) => {
|
|
1407
|
-
if (path.has(nodeId)) {
|
|
1408
|
-
throw new Error(`Circular dependency detected involving ${nodeId}`);
|
|
1409
|
-
}
|
|
1410
|
-
if (seen.has(nodeId)) {
|
|
1411
|
-
return [];
|
|
1412
|
-
}
|
|
1413
|
-
const node = nodes.find((n) => n.id === nodeId);
|
|
1414
|
-
if (!node) {
|
|
1415
|
-
throw new Error(`Node ${nodeId} not found but is listed as a dependency`);
|
|
1416
|
-
}
|
|
1417
|
-
const newPath = /* @__PURE__ */ new Set([
|
|
1418
|
-
...path,
|
|
1419
|
-
nodeId
|
|
1420
|
-
]);
|
|
1421
|
-
const newSeen = /* @__PURE__ */ new Set([
|
|
1422
|
-
...seen,
|
|
1423
|
-
nodeId
|
|
1424
|
-
]);
|
|
1425
|
-
const dependsOn = node.dependsOn ?? [];
|
|
1426
|
-
return [
|
|
1427
|
-
...dependsOn.flatMap((depId) => getDependencies(depId, newSeen, newPath)),
|
|
1428
|
-
nodeId
|
|
1429
|
-
];
|
|
1430
1385
|
};
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
var createApp = ({ pluginManager, pluginLoader: _pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), defaults = [], placeholder = null, fallback = DefaultFallback, cacheEnabled = false }) => {
|
|
1439
|
-
const pluginLoader = _pluginLoader ?? ((id) => {
|
|
1440
|
-
const plugin = plugins.find((plugin2) => plugin2.meta.id === id);
|
|
1441
|
-
invariant2(plugin, `Plugin not found: ${id}`, {
|
|
1442
|
-
F: __dxlog_file3,
|
|
1443
|
-
L: 68,
|
|
1444
|
-
S: void 0,
|
|
1445
|
-
A: [
|
|
1446
|
-
"plugin",
|
|
1447
|
-
"`Plugin not found: ${id}`"
|
|
1448
|
-
]
|
|
1449
|
-
});
|
|
1450
|
-
return plugin;
|
|
1451
|
-
});
|
|
1452
|
-
const state = create4({
|
|
1453
|
-
ready: false,
|
|
1454
|
-
error: null
|
|
1455
|
-
});
|
|
1456
|
-
const cached = JSON.parse(localStorage.getItem(ENABLED_KEY) ?? "[]");
|
|
1457
|
-
const enabled = cacheEnabled && cached.length > 0 ? cached : defaults;
|
|
1458
|
-
const manager = pluginManager ?? new PluginManager({
|
|
1459
|
-
pluginLoader,
|
|
1460
|
-
plugins,
|
|
1461
|
-
core,
|
|
1462
|
-
enabled
|
|
1463
|
-
});
|
|
1464
|
-
manager.activation.on(({ event, state: _state, error }) => {
|
|
1465
|
-
if (event === Events.Startup.id) {
|
|
1466
|
-
state.ready = _state === "activated";
|
|
1467
|
-
}
|
|
1468
|
-
if (error && !state.ready && !state.error) {
|
|
1469
|
-
state.error = error;
|
|
1470
|
-
}
|
|
1471
|
-
});
|
|
1472
|
-
effect2(() => {
|
|
1473
|
-
cacheEnabled && localStorage.setItem(ENABLED_KEY, JSON.stringify(manager.enabled));
|
|
1474
|
-
});
|
|
1475
|
-
manager.context.contributeCapability({
|
|
1476
|
-
interface: Capabilities.PluginManager,
|
|
1477
|
-
implementation: manager,
|
|
1478
|
-
module: "dxos.org/app-framework/plugin-manager"
|
|
1479
|
-
});
|
|
1480
|
-
setupDevtools(manager);
|
|
1481
|
-
void manager.activate(Events.Startup);
|
|
1482
|
-
return () => /* @__PURE__ */ React4.createElement(ErrorBoundary, {
|
|
1483
|
-
fallback
|
|
1484
|
-
}, /* @__PURE__ */ React4.createElement(App, {
|
|
1485
|
-
placeholder,
|
|
1486
|
-
manager,
|
|
1487
|
-
state
|
|
1488
|
-
}));
|
|
1489
|
-
};
|
|
1490
|
-
var App = ({ placeholder, manager, state }) => {
|
|
1491
|
-
if (state.error) {
|
|
1492
|
-
throw state.error;
|
|
1493
|
-
}
|
|
1494
|
-
if (!state.ready) {
|
|
1495
|
-
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, placeholder);
|
|
1496
|
-
}
|
|
1497
|
-
const reactContexts = manager.context.requestCapabilities(Capabilities.ReactContext);
|
|
1498
|
-
const reactRoots = manager.context.requestCapabilities(Capabilities.ReactRoot);
|
|
1499
|
-
const ComposedContext = composeContexts(reactContexts);
|
|
1500
|
-
return /* @__PURE__ */ React4.createElement(PluginManagerProvider, {
|
|
1501
|
-
value: manager
|
|
1502
|
-
}, /* @__PURE__ */ React4.createElement(ComposedContext, null, reactRoots.map(({ id, root: Component2 }) => /* @__PURE__ */ React4.createElement(Component2, {
|
|
1503
|
-
key: id
|
|
1504
|
-
}))));
|
|
1505
|
-
};
|
|
1506
|
-
var DefaultFallback = ({ error }) => {
|
|
1507
|
-
return /* @__PURE__ */ React4.createElement("div", {
|
|
1508
|
-
style: {
|
|
1509
|
-
padding: "1rem"
|
|
1510
|
-
}
|
|
1511
|
-
}, /* @__PURE__ */ React4.createElement("h1", {
|
|
1512
|
-
style: {
|
|
1513
|
-
fontSize: "1.2rem",
|
|
1514
|
-
fontWeight: 700,
|
|
1515
|
-
margin: "0.5rem 0"
|
|
1516
|
-
}
|
|
1517
|
-
}, error.message), /* @__PURE__ */ React4.createElement("pre", null, error.stack));
|
|
1518
|
-
};
|
|
1519
|
-
var composeContexts = (contexts) => {
|
|
1520
|
-
if (contexts.length === 0) {
|
|
1521
|
-
return ({ children }) => /* @__PURE__ */ React4.createElement(React4.Fragment, null, children);
|
|
1522
|
-
}
|
|
1523
|
-
return topologicalSort(contexts).map(({ context }) => context).reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React4.createElement(Acc, null, /* @__PURE__ */ React4.createElement(Next, null, children)));
|
|
1524
|
-
};
|
|
1525
|
-
var setupDevtools = (manager) => {
|
|
1526
|
-
globalThis.composer ??= {};
|
|
1527
|
-
globalThis.composer.manager = manager;
|
|
1386
|
+
state.dispatchPromise = async (intentChain) => {
|
|
1387
|
+
await manager.activate(Events.SetupIntentResolver);
|
|
1388
|
+
return await dispatchPromise(intentChain);
|
|
1389
|
+
};
|
|
1390
|
+
state.undo = undo;
|
|
1391
|
+
state.undoPromise = undoPromise;
|
|
1392
|
+
return contributes(Capabilities.IntentDispatcher, state);
|
|
1528
1393
|
};
|
|
1529
1394
|
|
|
1530
1395
|
export {
|
|
@@ -1556,42 +1421,14 @@ export {
|
|
|
1556
1421
|
IntentAction,
|
|
1557
1422
|
createResolver,
|
|
1558
1423
|
createDispatcher,
|
|
1559
|
-
|
|
1560
|
-
usePluginManager,
|
|
1561
|
-
PluginManagerProvider,
|
|
1562
|
-
useCapabilities,
|
|
1563
|
-
useCapability,
|
|
1564
|
-
isSurfaceAvailable,
|
|
1565
|
-
Surface,
|
|
1566
|
-
useIntentDispatcher,
|
|
1567
|
-
useIntentResolver,
|
|
1568
|
-
IntentProvider,
|
|
1424
|
+
intent_dispatcher_default,
|
|
1569
1425
|
IntentPlugin,
|
|
1570
|
-
Toast,
|
|
1571
|
-
isLayoutMode,
|
|
1572
|
-
Layout,
|
|
1573
1426
|
LAYOUT_PLUGIN,
|
|
1574
1427
|
LAYOUT_ACTION,
|
|
1575
1428
|
LayoutAction,
|
|
1576
|
-
SLUG_LIST_SEPARATOR,
|
|
1577
|
-
SLUG_ENTRY_SEPARATOR,
|
|
1578
|
-
SLUG_KEY_VALUE_SEPARATOR,
|
|
1579
|
-
SLUG_PATH_SEPARATOR,
|
|
1580
|
-
SLUG_COLLECTION_INDICATOR,
|
|
1581
|
-
ActiveParts,
|
|
1582
|
-
isLayoutParts,
|
|
1583
|
-
isLayoutAdjustment,
|
|
1584
|
-
openIds,
|
|
1585
|
-
firstIdInPart,
|
|
1586
|
-
indexInPart,
|
|
1587
|
-
partLength,
|
|
1588
|
-
NAVIGATION_PLUGIN,
|
|
1589
|
-
NAVIGATION_ACTION,
|
|
1590
|
-
NavigationAction,
|
|
1591
1429
|
createSurface,
|
|
1592
1430
|
ResourceKey,
|
|
1593
1431
|
ResourceLanguage,
|
|
1594
|
-
Resource
|
|
1595
|
-
createApp
|
|
1432
|
+
Resource
|
|
1596
1433
|
};
|
|
1597
|
-
//# sourceMappingURL=chunk-
|
|
1434
|
+
//# sourceMappingURL=chunk-TVIR2PHY.mjs.map
|