@dxos/app-framework 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea
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-XH4OYQLC.mjs → app-graph-builder-PSA3RESL.mjs} +9 -8
- package/dist/lib/browser/app-graph-builder-PSA3RESL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6V54SRFL.mjs → chunk-2VZ4RF4A.mjs} +202 -232
- package/dist/lib/browser/chunk-2VZ4RF4A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZZVFNUHZ.mjs → chunk-CPVYIS24.mjs} +9 -25
- package/dist/lib/browser/chunk-CPVYIS24.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RGKMLI6U.mjs → chunk-SCPE4ZO2.mjs} +2 -2
- package/dist/lib/browser/chunk-SCPE4ZO2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +6 -6
- package/dist/lib/browser/{intent-dispatcher-VFMJVO2M.mjs → intent-dispatcher-BND6IF4U.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-ICAPD4JL.mjs → intent-resolver-27FJAJDE.mjs} +5 -5
- package/dist/lib/browser/intent-resolver-27FJAJDE.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{store-7ZGMHOGB.mjs → store-F545UOIR.mjs} +2 -2
- package/dist/lib/browser/testing/index.mjs +5 -4
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/worker.mjs +1 -1
- package/dist/lib/node-esm/{app-graph-builder-C7H22SOL.mjs → app-graph-builder-VJGZ6KH7.mjs} +9 -8
- package/dist/lib/node-esm/app-graph-builder-VJGZ6KH7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SOVTUUAY.mjs → chunk-3RRWO5TD.mjs} +202 -232
- package/dist/lib/node-esm/chunk-3RRWO5TD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AXSZKZFD.mjs → chunk-MN37WUJ2.mjs} +9 -25
- package/dist/lib/node-esm/chunk-MN37WUJ2.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LKPMRTRR.mjs → chunk-ZX63QUGE.mjs} +2 -2
- package/dist/lib/node-esm/chunk-ZX63QUGE.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +6 -6
- package/dist/lib/node-esm/{intent-dispatcher-SAPOKSLZ.mjs → intent-dispatcher-254AZ6EE.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-CRNJ6BMD.mjs → intent-resolver-NPMOPNFL.mjs} +5 -5
- package/dist/lib/node-esm/intent-resolver-NPMOPNFL.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{store-H4F4RMYD.mjs → store-CINC4R4L.mjs} +2 -2
- package/dist/lib/node-esm/testing/index.mjs +5 -4
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/worker.mjs +1 -1
- package/dist/types/src/common/capabilities.d.ts +7 -4
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/collaboration.d.ts +1 -1
- package/dist/types/src/common/collaboration.d.ts.map +1 -1
- package/dist/types/src/common/file.d.ts +1 -1
- package/dist/types/src/common/file.d.ts.map +1 -1
- package/dist/types/src/common/layout.d.ts +1 -1
- package/dist/types/src/common/layout.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 +4 -4
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +4 -0
- package/dist/types/src/core/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/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/intent-dispatcher.d.ts +4 -4
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/actions.d.ts +1 -1
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.d.ts +3 -2
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -23
- package/src/common/capabilities.ts +7 -4
- package/src/common/collaboration.ts +1 -1
- package/src/common/file.ts +1 -1
- package/src/common/layout.ts +1 -1
- package/src/common/translations.ts +1 -1
- package/src/core/capabilities.test.ts +1 -1
- package/src/core/capabilities.ts +10 -6
- package/src/core/manager.test.ts +1 -1
- package/src/core/manager.ts +12 -5
- package/src/core/plugin.ts +5 -0
- package/src/playground/generator/generator.ts +1 -1
- package/src/playground/logger/schema.ts +1 -1
- package/src/plugin-intent/actions.ts +1 -1
- package/src/plugin-intent/errors.ts +1 -1
- package/src/plugin-intent/intent-dispatcher.test.ts +10 -3
- package/src/plugin-intent/intent-dispatcher.ts +8 -5
- package/src/plugin-intent/intent.ts +1 -1
- package/src/plugin-settings/actions.ts +1 -1
- package/src/plugin-settings/app-graph-builder.ts +6 -5
- package/src/plugin-settings/intent-resolver.ts +2 -2
- package/src/react/ErrorBoundary.tsx +8 -6
- package/src/testing/withPluginManager.tsx +8 -3
- package/tsconfig.json +1 -1
- package/dist/lib/browser/app-graph-builder-XH4OYQLC.mjs.map +0 -7
- package/dist/lib/browser/chunk-6V54SRFL.mjs.map +0 -7
- package/dist/lib/browser/chunk-RGKMLI6U.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZZVFNUHZ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-ICAPD4JL.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-C7H22SOL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AXSZKZFD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LKPMRTRR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SOVTUUAY.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-CRNJ6BMD.mjs.map +0 -7
- /package/dist/lib/browser/{intent-dispatcher-VFMJVO2M.mjs.map → intent-dispatcher-BND6IF4U.mjs.map} +0 -0
- /package/dist/lib/browser/{store-7ZGMHOGB.mjs.map → store-F545UOIR.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-SAPOKSLZ.mjs.map → intent-dispatcher-254AZ6EE.mjs.map} +0 -0
- /package/dist/lib/node-esm/{store-H4F4RMYD.mjs.map → store-CINC4R4L.mjs.map} +0 -0
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
// src/plugin-intent/intent-dispatcher.ts
|
|
2
|
-
import
|
|
2
|
+
import * as Effect3 from "effect/Effect";
|
|
3
|
+
import * as Function2 from "effect/Function";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Ref2 from "effect/Ref";
|
|
3
6
|
import { live as live2 } from "@dxos/live-object";
|
|
4
7
|
import { log as log3 } from "@dxos/log";
|
|
5
8
|
import { byPosition } from "@dxos/util";
|
|
6
9
|
|
|
7
10
|
// src/core/capabilities.ts
|
|
8
11
|
import { Rx } from "@effect-rx/rx-react";
|
|
9
|
-
import
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
10
13
|
import { Trigger } from "@dxos/async";
|
|
11
14
|
import { invariant } from "@dxos/invariant";
|
|
12
15
|
import { log } from "@dxos/log";
|
|
13
|
-
function _define_property(obj, key, value) {
|
|
14
|
-
if (key in obj) {
|
|
15
|
-
Object.defineProperty(obj, key, {
|
|
16
|
-
value,
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true
|
|
20
|
-
});
|
|
21
|
-
} else {
|
|
22
|
-
obj[key] = value;
|
|
23
|
-
}
|
|
24
|
-
return obj;
|
|
25
|
-
}
|
|
26
16
|
var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
|
|
27
17
|
var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
|
|
28
18
|
var defineCapability = (identifier) => {
|
|
@@ -31,9 +21,9 @@ var defineCapability = (identifier) => {
|
|
|
31
21
|
};
|
|
32
22
|
};
|
|
33
23
|
var CapabilityImpl = class {
|
|
24
|
+
moduleId;
|
|
25
|
+
implementation;
|
|
34
26
|
constructor(moduleId, implementation) {
|
|
35
|
-
_define_property(this, "moduleId", void 0);
|
|
36
|
-
_define_property(this, "implementation", void 0);
|
|
37
27
|
this.moduleId = moduleId;
|
|
38
28
|
this.implementation = implementation;
|
|
39
29
|
}
|
|
@@ -50,6 +40,48 @@ var lazy = (c) => async (props) => {
|
|
|
50
40
|
return async () => getCapability(props);
|
|
51
41
|
};
|
|
52
42
|
var PluginContext = class {
|
|
43
|
+
_registry;
|
|
44
|
+
_capabilityImpls = Rx.family(() => {
|
|
45
|
+
return Rx.make([]).pipe(Rx.keepAlive);
|
|
46
|
+
});
|
|
47
|
+
_capabilities = Rx.family((id) => {
|
|
48
|
+
return Rx.make((get) => {
|
|
49
|
+
const current = get(this._capabilityImpls(id));
|
|
50
|
+
return current.map((c) => c.implementation);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
_capability = Rx.family((id) => {
|
|
54
|
+
return Rx.make((get) => {
|
|
55
|
+
const current = get(this._capabilities(id));
|
|
56
|
+
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
57
|
+
F: __dxlog_file,
|
|
58
|
+
L: 126,
|
|
59
|
+
S: this,
|
|
60
|
+
A: [
|
|
61
|
+
"current.length > 0",
|
|
62
|
+
"`No capability found for ${id}`"
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
return current[0];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Activates plugins based on the activation event.
|
|
70
|
+
* @param event The activation event.
|
|
71
|
+
* @returns Whether the activation was successful.
|
|
72
|
+
*/
|
|
73
|
+
activate;
|
|
74
|
+
/**
|
|
75
|
+
* Re-activates the modules that were activated by the event.
|
|
76
|
+
* @param event The activation event.
|
|
77
|
+
* @returns Whether the reset was successful.
|
|
78
|
+
*/
|
|
79
|
+
reset;
|
|
80
|
+
constructor({ registry, activate, reset }) {
|
|
81
|
+
this._registry = registry;
|
|
82
|
+
this.activate = activate;
|
|
83
|
+
this.reset = reset;
|
|
84
|
+
}
|
|
53
85
|
/**
|
|
54
86
|
* @internal
|
|
55
87
|
*/
|
|
@@ -69,7 +101,7 @@ var PluginContext = class {
|
|
|
69
101
|
count: current.length
|
|
70
102
|
}, {
|
|
71
103
|
F: __dxlog_file,
|
|
72
|
-
L:
|
|
104
|
+
L: 170,
|
|
73
105
|
S: this,
|
|
74
106
|
C: (f, a) => f(...a)
|
|
75
107
|
});
|
|
@@ -90,7 +122,7 @@ var PluginContext = class {
|
|
|
90
122
|
count: current.length
|
|
91
123
|
}, {
|
|
92
124
|
F: __dxlog_file,
|
|
93
|
-
L:
|
|
125
|
+
L: 189,
|
|
94
126
|
S: this,
|
|
95
127
|
C: (f, a) => f(...a)
|
|
96
128
|
});
|
|
@@ -99,7 +131,7 @@ var PluginContext = class {
|
|
|
99
131
|
id: interfaceDef.identifier
|
|
100
132
|
}, {
|
|
101
133
|
F: __dxlog_file,
|
|
102
|
-
L:
|
|
134
|
+
L: 191,
|
|
103
135
|
S: this,
|
|
104
136
|
C: (f, a) => f(...a)
|
|
105
137
|
});
|
|
@@ -164,38 +196,6 @@ var PluginContext = class {
|
|
|
164
196
|
async resetPromise(event) {
|
|
165
197
|
return this.reset(event).pipe(Effect.runPromise);
|
|
166
198
|
}
|
|
167
|
-
constructor({ registry, activate, reset }) {
|
|
168
|
-
_define_property(this, "_registry", void 0);
|
|
169
|
-
_define_property(this, "_capabilityImpls", Rx.family(() => {
|
|
170
|
-
return Rx.make([]).pipe(Rx.keepAlive);
|
|
171
|
-
}));
|
|
172
|
-
_define_property(this, "_capabilities", Rx.family((id) => {
|
|
173
|
-
return Rx.make((get) => {
|
|
174
|
-
const current = get(this._capabilityImpls(id));
|
|
175
|
-
return current.map((c) => c.implementation);
|
|
176
|
-
});
|
|
177
|
-
}));
|
|
178
|
-
_define_property(this, "_capability", Rx.family((id) => {
|
|
179
|
-
return Rx.make((get) => {
|
|
180
|
-
const current = get(this._capabilities(id));
|
|
181
|
-
invariant(current.length > 0, `No capability found for ${id}`, {
|
|
182
|
-
F: __dxlog_file,
|
|
183
|
-
L: 122,
|
|
184
|
-
S: this,
|
|
185
|
-
A: [
|
|
186
|
-
"current.length > 0",
|
|
187
|
-
"`No capability found for ${id}`"
|
|
188
|
-
]
|
|
189
|
-
});
|
|
190
|
-
return current[0];
|
|
191
|
-
});
|
|
192
|
-
}));
|
|
193
|
-
_define_property(this, "activate", void 0);
|
|
194
|
-
_define_property(this, "reset", void 0);
|
|
195
|
-
this._registry = registry;
|
|
196
|
-
this.activate = activate;
|
|
197
|
-
this.reset = reset;
|
|
198
|
-
}
|
|
199
199
|
};
|
|
200
200
|
|
|
201
201
|
// src/core/events.ts
|
|
@@ -223,28 +223,53 @@ var getEvents = (events) => "type" in events ? events.events : [
|
|
|
223
223
|
// src/core/manager.ts
|
|
224
224
|
import { Registry } from "@effect-rx/rx-react";
|
|
225
225
|
import { untracked } from "@preact/signals-core";
|
|
226
|
-
import
|
|
226
|
+
import * as Array from "effect/Array";
|
|
227
|
+
import * as Duration from "effect/Duration";
|
|
228
|
+
import * as Effect2 from "effect/Effect";
|
|
229
|
+
import * as Fiber from "effect/Fiber";
|
|
230
|
+
import * as Function from "effect/Function";
|
|
231
|
+
import * as HashSet from "effect/HashSet";
|
|
232
|
+
import * as Match from "effect/Match";
|
|
233
|
+
import * as Ref from "effect/Ref";
|
|
227
234
|
import { Event } from "@dxos/async";
|
|
228
235
|
import { live } from "@dxos/live-object";
|
|
229
236
|
import { log as log2 } from "@dxos/log";
|
|
230
|
-
function _define_property2(obj, key, value) {
|
|
231
|
-
if (key in obj) {
|
|
232
|
-
Object.defineProperty(obj, key, {
|
|
233
|
-
value,
|
|
234
|
-
enumerable: true,
|
|
235
|
-
configurable: true,
|
|
236
|
-
writable: true
|
|
237
|
-
});
|
|
238
|
-
} else {
|
|
239
|
-
obj[key] = value;
|
|
240
|
-
}
|
|
241
|
-
return obj;
|
|
242
|
-
}
|
|
243
237
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
|
|
244
|
-
var isPromise = (
|
|
245
|
-
return
|
|
238
|
+
var isPromise = (value2) => {
|
|
239
|
+
return value2 !== null && typeof value2 === "object" && "then" in value2;
|
|
246
240
|
};
|
|
247
241
|
var PluginManager = class {
|
|
242
|
+
activation = new Event();
|
|
243
|
+
context;
|
|
244
|
+
registry;
|
|
245
|
+
// TODO(wittjosiah): Replace with Rx.
|
|
246
|
+
_state;
|
|
247
|
+
_pluginLoader;
|
|
248
|
+
_capabilities = /* @__PURE__ */ new Map();
|
|
249
|
+
_moduleMemoMap = /* @__PURE__ */ new Map();
|
|
250
|
+
_activatingEvents = Effect2.runSync(Ref.make([]));
|
|
251
|
+
_activatingModules = Effect2.runSync(Ref.make([]));
|
|
252
|
+
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.id), enabled = [], registry }) {
|
|
253
|
+
this.registry = registry ?? Registry.make();
|
|
254
|
+
this.context = new PluginContext({
|
|
255
|
+
registry: this.registry,
|
|
256
|
+
activate: (event) => this._activate(event),
|
|
257
|
+
reset: (id) => this._reset(id)
|
|
258
|
+
});
|
|
259
|
+
this._pluginLoader = pluginLoader;
|
|
260
|
+
this._state = live({
|
|
261
|
+
plugins,
|
|
262
|
+
core,
|
|
263
|
+
enabled,
|
|
264
|
+
modules: [],
|
|
265
|
+
active: [],
|
|
266
|
+
eventsFired: [],
|
|
267
|
+
pendingReset: []
|
|
268
|
+
});
|
|
269
|
+
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
270
|
+
core.forEach((id) => this.enable(id));
|
|
271
|
+
enabled.forEach((id) => this.enable(id));
|
|
272
|
+
}
|
|
248
273
|
/**
|
|
249
274
|
* Plugins that are currently registered.
|
|
250
275
|
*
|
|
@@ -311,7 +336,7 @@ var PluginManager = class {
|
|
|
311
336
|
id
|
|
312
337
|
}, {
|
|
313
338
|
F: __dxlog_file2,
|
|
314
|
-
L:
|
|
339
|
+
L: 164,
|
|
315
340
|
S: this,
|
|
316
341
|
C: (f, a) => f(...a)
|
|
317
342
|
});
|
|
@@ -330,7 +355,7 @@ var PluginManager = class {
|
|
|
330
355
|
id
|
|
331
356
|
}, {
|
|
332
357
|
F: __dxlog_file2,
|
|
333
|
-
L:
|
|
358
|
+
L: 177,
|
|
334
359
|
S: this,
|
|
335
360
|
C: (f, a) => f(...a)
|
|
336
361
|
});
|
|
@@ -351,7 +376,7 @@ var PluginManager = class {
|
|
|
351
376
|
]
|
|
352
377
|
}, {
|
|
353
378
|
F: __dxlog_file2,
|
|
354
|
-
L:
|
|
379
|
+
L: 192,
|
|
355
380
|
S: this,
|
|
356
381
|
C: (f, a) => f(...a)
|
|
357
382
|
});
|
|
@@ -371,7 +396,7 @@ var PluginManager = class {
|
|
|
371
396
|
id
|
|
372
397
|
}, {
|
|
373
398
|
F: __dxlog_file2,
|
|
374
|
-
L:
|
|
399
|
+
L: 210,
|
|
375
400
|
S: this,
|
|
376
401
|
C: (f, a) => f(...a)
|
|
377
402
|
});
|
|
@@ -393,7 +418,7 @@ var PluginManager = class {
|
|
|
393
418
|
id
|
|
394
419
|
}, {
|
|
395
420
|
F: __dxlog_file2,
|
|
396
|
-
L:
|
|
421
|
+
L: 227,
|
|
397
422
|
S: this,
|
|
398
423
|
C: (f, a) => f(...a)
|
|
399
424
|
});
|
|
@@ -445,7 +470,7 @@ var PluginManager = class {
|
|
|
445
470
|
id: plugin.meta.id
|
|
446
471
|
}, {
|
|
447
472
|
F: __dxlog_file2,
|
|
448
|
-
L:
|
|
473
|
+
L: 280,
|
|
449
474
|
S: this,
|
|
450
475
|
C: (f, a) => f(...a)
|
|
451
476
|
});
|
|
@@ -460,7 +485,7 @@ var PluginManager = class {
|
|
|
460
485
|
id
|
|
461
486
|
}, {
|
|
462
487
|
F: __dxlog_file2,
|
|
463
|
-
L:
|
|
488
|
+
L: 290,
|
|
464
489
|
S: this,
|
|
465
490
|
C: (f, a) => f(...a)
|
|
466
491
|
});
|
|
@@ -476,7 +501,7 @@ var PluginManager = class {
|
|
|
476
501
|
id: module.id
|
|
477
502
|
}, {
|
|
478
503
|
F: __dxlog_file2,
|
|
479
|
-
L:
|
|
504
|
+
L: 300,
|
|
480
505
|
S: this,
|
|
481
506
|
C: (f, a) => f(...a)
|
|
482
507
|
});
|
|
@@ -491,7 +516,7 @@ var PluginManager = class {
|
|
|
491
516
|
id
|
|
492
517
|
}, {
|
|
493
518
|
F: __dxlog_file2,
|
|
494
|
-
L:
|
|
519
|
+
L: 310,
|
|
495
520
|
S: this,
|
|
496
521
|
C: (f, a) => f(...a)
|
|
497
522
|
});
|
|
@@ -525,7 +550,7 @@ var PluginManager = class {
|
|
|
525
550
|
events: pendingReset
|
|
526
551
|
}, {
|
|
527
552
|
F: __dxlog_file2,
|
|
528
|
-
L:
|
|
553
|
+
L: 348,
|
|
529
554
|
S: this,
|
|
530
555
|
C: (f, a) => f(...a)
|
|
531
556
|
});
|
|
@@ -545,7 +570,7 @@ var PluginManager = class {
|
|
|
545
570
|
...params
|
|
546
571
|
}, {
|
|
547
572
|
F: __dxlog_file2,
|
|
548
|
-
L:
|
|
573
|
+
L: 364,
|
|
549
574
|
S: this,
|
|
550
575
|
C: (f, a) => f(...a)
|
|
551
576
|
});
|
|
@@ -570,7 +595,7 @@ var PluginManager = class {
|
|
|
570
595
|
key
|
|
571
596
|
}, {
|
|
572
597
|
F: __dxlog_file2,
|
|
573
|
-
L:
|
|
598
|
+
L: 395,
|
|
574
599
|
S: this,
|
|
575
600
|
C: (f, a) => f(...a)
|
|
576
601
|
});
|
|
@@ -584,7 +609,7 @@ var PluginManager = class {
|
|
|
584
609
|
modules: modules.map((module) => module.id)
|
|
585
610
|
}, {
|
|
586
611
|
F: __dxlog_file2,
|
|
587
|
-
L:
|
|
612
|
+
L: 402,
|
|
588
613
|
S: this,
|
|
589
614
|
C: (f, a) => f(...a)
|
|
590
615
|
});
|
|
@@ -592,12 +617,12 @@ var PluginManager = class {
|
|
|
592
617
|
event: key,
|
|
593
618
|
state: "activating"
|
|
594
619
|
});
|
|
595
|
-
yield* pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
620
|
+
yield* Function.pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
596
621
|
before: key
|
|
597
622
|
})), Effect2.allWith({
|
|
598
623
|
concurrency: "unbounded"
|
|
599
624
|
}));
|
|
600
|
-
const getCapabilities = yield* pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
|
|
625
|
+
const getCapabilities = yield* Function.pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
|
|
601
626
|
concurrency: "unbounded"
|
|
602
627
|
}), Effect2.catchAll((error) => {
|
|
603
628
|
this.activation.emit({
|
|
@@ -607,15 +632,13 @@ var PluginManager = class {
|
|
|
607
632
|
});
|
|
608
633
|
return Effect2.fail(error);
|
|
609
634
|
}));
|
|
610
|
-
yield* pipe(
|
|
635
|
+
yield* Function.pipe(
|
|
611
636
|
modules,
|
|
612
637
|
Array.zip(getCapabilities),
|
|
613
638
|
Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
|
|
614
|
-
// TODO(wittjosiah): This currently can't be run in parallel.
|
|
615
|
-
// Running this with concurrency causes races with `allOf` activation events.
|
|
616
639
|
Effect2.all
|
|
617
640
|
);
|
|
618
|
-
yield* pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
641
|
+
yield* Function.pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
|
|
619
642
|
after: key
|
|
620
643
|
})), Effect2.allWith({
|
|
621
644
|
concurrency: "unbounded"
|
|
@@ -633,13 +656,74 @@ var PluginManager = class {
|
|
|
633
656
|
key
|
|
634
657
|
}, {
|
|
635
658
|
F: __dxlog_file2,
|
|
636
|
-
L:
|
|
659
|
+
L: 458,
|
|
637
660
|
S: this,
|
|
638
661
|
C: (f, a) => f(...a)
|
|
639
662
|
});
|
|
640
663
|
return true;
|
|
641
664
|
});
|
|
642
665
|
}
|
|
666
|
+
// Memoized with _moduleMemoMap
|
|
667
|
+
_loadModule = (mod) => Effect2.tryPromise({
|
|
668
|
+
try: async () => {
|
|
669
|
+
const entry = this._moduleMemoMap.get(mod.id);
|
|
670
|
+
if (entry) {
|
|
671
|
+
return entry;
|
|
672
|
+
}
|
|
673
|
+
const promise2 = (async () => {
|
|
674
|
+
const start = performance.now();
|
|
675
|
+
let failed = false;
|
|
676
|
+
try {
|
|
677
|
+
log2("loading module", {
|
|
678
|
+
module: mod.id
|
|
679
|
+
}, {
|
|
680
|
+
F: __dxlog_file2,
|
|
681
|
+
L: 477,
|
|
682
|
+
S: this,
|
|
683
|
+
C: (f, a) => f(...a)
|
|
684
|
+
});
|
|
685
|
+
let activationResult = await mod.activate(this.context);
|
|
686
|
+
if (typeof activationResult === "function") {
|
|
687
|
+
activationResult = await activationResult();
|
|
688
|
+
}
|
|
689
|
+
return Array.isArray(activationResult) ? activationResult : [
|
|
690
|
+
activationResult
|
|
691
|
+
];
|
|
692
|
+
} catch (error) {
|
|
693
|
+
failed = true;
|
|
694
|
+
throw error;
|
|
695
|
+
} finally {
|
|
696
|
+
performance.measure("activate-module", {
|
|
697
|
+
start,
|
|
698
|
+
end: performance.now(),
|
|
699
|
+
detail: {
|
|
700
|
+
module: mod.id
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
log2("loaded module", {
|
|
704
|
+
module: mod.id,
|
|
705
|
+
elapsed: performance.now() - start,
|
|
706
|
+
failed
|
|
707
|
+
}, {
|
|
708
|
+
F: __dxlog_file2,
|
|
709
|
+
L: 495,
|
|
710
|
+
S: this,
|
|
711
|
+
C: (f, a) => f(...a)
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
})();
|
|
715
|
+
this._moduleMemoMap.set(mod.id, promise2);
|
|
716
|
+
return promise2;
|
|
717
|
+
},
|
|
718
|
+
catch: (error) => error
|
|
719
|
+
}).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
|
|
720
|
+
module: mod.id
|
|
721
|
+
}, {
|
|
722
|
+
F: __dxlog_file2,
|
|
723
|
+
L: 506,
|
|
724
|
+
S: this,
|
|
725
|
+
C: (f, a) => f(...a)
|
|
726
|
+
}))))));
|
|
643
727
|
_contributeCapabilities(module, capabilities) {
|
|
644
728
|
return Effect2.gen(this, function* () {
|
|
645
729
|
capabilities.forEach((capability) => {
|
|
@@ -672,7 +756,7 @@ var PluginManager = class {
|
|
|
672
756
|
id
|
|
673
757
|
}, {
|
|
674
758
|
F: __dxlog_file2,
|
|
675
|
-
L:
|
|
759
|
+
L: 540,
|
|
676
760
|
S: this,
|
|
677
761
|
C: (f, a) => f(...a)
|
|
678
762
|
});
|
|
@@ -682,8 +766,8 @@ var PluginManager = class {
|
|
|
682
766
|
for (const capability of capabilities) {
|
|
683
767
|
this.context.removeCapability(capability.interface, capability.implementation);
|
|
684
768
|
const program = capability.deactivate?.();
|
|
685
|
-
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (
|
|
686
|
-
try: () =>
|
|
769
|
+
yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise2) => Effect2.tryPromise({
|
|
770
|
+
try: () => promise2,
|
|
687
771
|
catch: (error) => error
|
|
688
772
|
})), Match.orElse((program2) => Effect2.succeed(program2)));
|
|
689
773
|
}
|
|
@@ -697,7 +781,7 @@ var PluginManager = class {
|
|
|
697
781
|
id
|
|
698
782
|
}, {
|
|
699
783
|
F: __dxlog_file2,
|
|
700
|
-
L:
|
|
784
|
+
L: 567,
|
|
701
785
|
S: this,
|
|
702
786
|
C: (f, a) => f(...a)
|
|
703
787
|
});
|
|
@@ -711,7 +795,7 @@ var PluginManager = class {
|
|
|
711
795
|
key
|
|
712
796
|
}, {
|
|
713
797
|
F: __dxlog_file2,
|
|
714
|
-
L:
|
|
798
|
+
L: 575,
|
|
715
799
|
S: this,
|
|
716
800
|
C: (f, a) => f(...a)
|
|
717
801
|
});
|
|
@@ -726,96 +810,6 @@ var PluginManager = class {
|
|
|
726
810
|
}
|
|
727
811
|
});
|
|
728
812
|
}
|
|
729
|
-
constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta: meta2 }) => meta2.id), enabled = [], registry }) {
|
|
730
|
-
_define_property2(this, "activation", new Event());
|
|
731
|
-
_define_property2(this, "context", void 0);
|
|
732
|
-
_define_property2(this, "registry", void 0);
|
|
733
|
-
_define_property2(this, "_state", void 0);
|
|
734
|
-
_define_property2(this, "_pluginLoader", void 0);
|
|
735
|
-
_define_property2(this, "_capabilities", /* @__PURE__ */ new Map());
|
|
736
|
-
_define_property2(this, "_moduleMemoMap", /* @__PURE__ */ new Map());
|
|
737
|
-
_define_property2(this, "_activatingEvents", Effect2.runSync(Ref.make([])));
|
|
738
|
-
_define_property2(this, "_activatingModules", Effect2.runSync(Ref.make([])));
|
|
739
|
-
_define_property2(this, "_loadModule", (mod) => Effect2.tryPromise({
|
|
740
|
-
try: async () => {
|
|
741
|
-
const entry = this._moduleMemoMap.get(mod.id);
|
|
742
|
-
if (entry) {
|
|
743
|
-
return entry;
|
|
744
|
-
}
|
|
745
|
-
const promise = (async () => {
|
|
746
|
-
const start = performance.now();
|
|
747
|
-
let failed = false;
|
|
748
|
-
try {
|
|
749
|
-
log2("loading module", {
|
|
750
|
-
module: mod.id
|
|
751
|
-
}, {
|
|
752
|
-
F: __dxlog_file2,
|
|
753
|
-
L: 470,
|
|
754
|
-
S: this,
|
|
755
|
-
C: (f, a) => f(...a)
|
|
756
|
-
});
|
|
757
|
-
let activationResult = await mod.activate(this.context);
|
|
758
|
-
if (typeof activationResult === "function") {
|
|
759
|
-
activationResult = await activationResult();
|
|
760
|
-
}
|
|
761
|
-
return Array.isArray(activationResult) ? activationResult : [
|
|
762
|
-
activationResult
|
|
763
|
-
];
|
|
764
|
-
} catch (error) {
|
|
765
|
-
failed = true;
|
|
766
|
-
throw error;
|
|
767
|
-
} finally {
|
|
768
|
-
performance.measure("activate-module", {
|
|
769
|
-
start,
|
|
770
|
-
end: performance.now(),
|
|
771
|
-
detail: {
|
|
772
|
-
module: mod.id
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
log2("loaded module", {
|
|
776
|
-
module: mod.id,
|
|
777
|
-
elapsed: performance.now() - start,
|
|
778
|
-
failed
|
|
779
|
-
}, {
|
|
780
|
-
F: __dxlog_file2,
|
|
781
|
-
L: 488,
|
|
782
|
-
S: this,
|
|
783
|
-
C: (f, a) => f(...a)
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
})();
|
|
787
|
-
this._moduleMemoMap.set(mod.id, promise);
|
|
788
|
-
return promise;
|
|
789
|
-
},
|
|
790
|
-
catch: (error) => error
|
|
791
|
-
}).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
|
|
792
|
-
module: mod.id
|
|
793
|
-
}, {
|
|
794
|
-
F: __dxlog_file2,
|
|
795
|
-
L: 499,
|
|
796
|
-
S: this,
|
|
797
|
-
C: (f, a) => f(...a)
|
|
798
|
-
})))))));
|
|
799
|
-
this.registry = registry ?? Registry.make();
|
|
800
|
-
this.context = new PluginContext({
|
|
801
|
-
registry: this.registry,
|
|
802
|
-
activate: (event) => this._activate(event),
|
|
803
|
-
reset: (id) => this._reset(id)
|
|
804
|
-
});
|
|
805
|
-
this._pluginLoader = pluginLoader;
|
|
806
|
-
this._state = live({
|
|
807
|
-
plugins,
|
|
808
|
-
core,
|
|
809
|
-
enabled,
|
|
810
|
-
modules: [],
|
|
811
|
-
active: [],
|
|
812
|
-
eventsFired: [],
|
|
813
|
-
pendingReset: []
|
|
814
|
-
});
|
|
815
|
-
plugins.forEach((plugin) => this._addPlugin(plugin));
|
|
816
|
-
core.forEach((id) => this.enable(id));
|
|
817
|
-
enabled.forEach((id) => this.enable(id));
|
|
818
|
-
}
|
|
819
813
|
};
|
|
820
814
|
var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
821
815
|
const togetherFiber = yield* Effect2.fork(togetherEffect);
|
|
@@ -825,26 +819,13 @@ var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
|
|
|
825
819
|
});
|
|
826
820
|
|
|
827
821
|
// src/core/plugin.ts
|
|
828
|
-
function _define_property3(obj, key, value) {
|
|
829
|
-
if (key in obj) {
|
|
830
|
-
Object.defineProperty(obj, key, {
|
|
831
|
-
value,
|
|
832
|
-
enumerable: true,
|
|
833
|
-
configurable: true,
|
|
834
|
-
writable: true
|
|
835
|
-
});
|
|
836
|
-
} else {
|
|
837
|
-
obj[key] = value;
|
|
838
|
-
}
|
|
839
|
-
return obj;
|
|
840
|
-
}
|
|
841
822
|
var PluginModule = class {
|
|
823
|
+
id;
|
|
824
|
+
activatesOn;
|
|
825
|
+
activatesBefore;
|
|
826
|
+
activatesAfter;
|
|
827
|
+
activate;
|
|
842
828
|
constructor(options) {
|
|
843
|
-
_define_property3(this, "id", void 0);
|
|
844
|
-
_define_property3(this, "activatesOn", void 0);
|
|
845
|
-
_define_property3(this, "activatesBefore", void 0);
|
|
846
|
-
_define_property3(this, "activatesAfter", void 0);
|
|
847
|
-
_define_property3(this, "activate", void 0);
|
|
848
829
|
this.id = options.id;
|
|
849
830
|
this.activatesOn = options.activatesOn;
|
|
850
831
|
this.activatesBefore = options.activatesBefore;
|
|
@@ -854,9 +835,9 @@ var PluginModule = class {
|
|
|
854
835
|
};
|
|
855
836
|
var defineModule = (options) => new PluginModule(options);
|
|
856
837
|
var Plugin = class {
|
|
838
|
+
meta;
|
|
839
|
+
modules;
|
|
857
840
|
constructor(meta2, modules) {
|
|
858
|
-
_define_property3(this, "meta", void 0);
|
|
859
|
-
_define_property3(this, "modules", void 0);
|
|
860
841
|
this.meta = meta2;
|
|
861
842
|
this.modules = modules;
|
|
862
843
|
}
|
|
@@ -900,7 +881,7 @@ var definePlugin = (meta2, provider) => {
|
|
|
900
881
|
var Capabilities;
|
|
901
882
|
|
|
902
883
|
// src/common/collaboration.ts
|
|
903
|
-
import
|
|
884
|
+
import * as Schema from "effect/Schema";
|
|
904
885
|
import { DataType } from "@dxos/schema";
|
|
905
886
|
(function(CollaborationActions2) {
|
|
906
887
|
class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
|
|
@@ -935,7 +916,7 @@ var CollaborationActions;
|
|
|
935
916
|
var Events;
|
|
936
917
|
|
|
937
918
|
// src/common/file.ts
|
|
938
|
-
import
|
|
919
|
+
import * as Schema2 from "effect/Schema";
|
|
939
920
|
var defaultFileTypes = {
|
|
940
921
|
images: [
|
|
941
922
|
"png",
|
|
@@ -963,13 +944,13 @@ var FileInfoSchema = Schema2.Struct({
|
|
|
963
944
|
});
|
|
964
945
|
|
|
965
946
|
// src/common/layout.ts
|
|
966
|
-
import
|
|
947
|
+
import * as Schema5 from "effect/Schema";
|
|
967
948
|
|
|
968
949
|
// src/plugin-intent/actions.ts
|
|
969
|
-
import
|
|
950
|
+
import * as Schema4 from "effect/Schema";
|
|
970
951
|
|
|
971
952
|
// src/plugin-intent/intent.ts
|
|
972
|
-
import
|
|
953
|
+
import * as Schema3 from "effect/Schema";
|
|
973
954
|
var createIntent = (schema, data = {}, params = {}) => {
|
|
974
955
|
const _ = Schema3.validateSync(schema.fields.input)(data);
|
|
975
956
|
const intent = {
|
|
@@ -1041,31 +1022,20 @@ var meta = {
|
|
|
1041
1022
|
var IntentAction;
|
|
1042
1023
|
|
|
1043
1024
|
// src/plugin-intent/errors.ts
|
|
1044
|
-
function _define_property4(obj, key, value) {
|
|
1045
|
-
if (key in obj) {
|
|
1046
|
-
Object.defineProperty(obj, key, {
|
|
1047
|
-
value,
|
|
1048
|
-
enumerable: true,
|
|
1049
|
-
configurable: true,
|
|
1050
|
-
writable: true
|
|
1051
|
-
});
|
|
1052
|
-
} else {
|
|
1053
|
-
obj[key] = value;
|
|
1054
|
-
}
|
|
1055
|
-
return obj;
|
|
1056
|
-
}
|
|
1057
1025
|
var BaseError = class extends Error {
|
|
1026
|
+
code;
|
|
1027
|
+
context;
|
|
1058
1028
|
constructor(code, message, context) {
|
|
1059
1029
|
super(message ?? code, {
|
|
1060
1030
|
cause: context
|
|
1061
|
-
}),
|
|
1031
|
+
}), this.code = code, this.context = context;
|
|
1062
1032
|
this.name = code;
|
|
1063
1033
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
1064
1034
|
}
|
|
1065
1035
|
};
|
|
1066
1036
|
var NoResolversError = class extends BaseError {
|
|
1067
1037
|
constructor(action) {
|
|
1068
|
-
super("NO_RESOLVERS",
|
|
1038
|
+
super("NO_RESOLVERS", `No resolvers were found for the action: ${action}`, {
|
|
1069
1039
|
action
|
|
1070
1040
|
});
|
|
1071
1041
|
}
|
|
@@ -1087,7 +1057,7 @@ var IntentPlugin = definePlugin(meta, () => [
|
|
|
1087
1057
|
activatesAfter: [
|
|
1088
1058
|
Events.DispatcherReady
|
|
1089
1059
|
],
|
|
1090
|
-
activate: lazy(() => import("./intent-dispatcher-
|
|
1060
|
+
activate: lazy(() => import("./intent-dispatcher-BND6IF4U.mjs"))
|
|
1091
1061
|
})
|
|
1092
1062
|
]);
|
|
1093
1063
|
|
|
@@ -1431,7 +1401,7 @@ var LayoutAction;
|
|
|
1431
1401
|
var createSurface = (definition) => definition;
|
|
1432
1402
|
|
|
1433
1403
|
// src/common/translations.ts
|
|
1434
|
-
import
|
|
1404
|
+
import * as Schema6 from "effect/Schema";
|
|
1435
1405
|
var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
|
|
1436
1406
|
key: Schema6.String,
|
|
1437
1407
|
value: Schema6.Any
|
|
@@ -1506,7 +1476,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1506
1476
|
return next;
|
|
1507
1477
|
});
|
|
1508
1478
|
if (result.undoable && isUndoable(results)) {
|
|
1509
|
-
yield*
|
|
1479
|
+
yield* Function2.pipe(dispatch(createIntent(IntentAction.ShowUndo, {
|
|
1510
1480
|
message: result.undoable.message
|
|
1511
1481
|
})), Effect3.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect3.succeed(void 0)) : Option.none()));
|
|
1512
1482
|
}
|
|
@@ -1519,7 +1489,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1519
1489
|
})).catch((error) => {
|
|
1520
1490
|
log3.catch(error, void 0, {
|
|
1521
1491
|
F: __dxlog_file3,
|
|
1522
|
-
L:
|
|
1492
|
+
L: 274,
|
|
1523
1493
|
S: void 0,
|
|
1524
1494
|
C: (f, a) => f(...a)
|
|
1525
1495
|
});
|
|
@@ -1534,7 +1504,7 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1534
1504
|
const last = history.findLastIndex(isUndoable);
|
|
1535
1505
|
const result = last !== -1 ? history[last] : void 0;
|
|
1536
1506
|
if (result) {
|
|
1537
|
-
const
|
|
1507
|
+
const all2 = result.map(({ _intent, undoable }) => {
|
|
1538
1508
|
const data = _intent.data;
|
|
1539
1509
|
const undoData = undoable?.data ?? {};
|
|
1540
1510
|
return {
|
|
@@ -1547,9 +1517,9 @@ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, histor
|
|
|
1547
1517
|
};
|
|
1548
1518
|
});
|
|
1549
1519
|
const intent = {
|
|
1550
|
-
first:
|
|
1551
|
-
last:
|
|
1552
|
-
all
|
|
1520
|
+
first: all2[0],
|
|
1521
|
+
last: all2.at(-1),
|
|
1522
|
+
all: all2
|
|
1553
1523
|
};
|
|
1554
1524
|
yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
|
|
1555
1525
|
return yield* dispatch(intent);
|
|
@@ -1635,4 +1605,4 @@ export {
|
|
|
1635
1605
|
ResourceLanguage,
|
|
1636
1606
|
Resource
|
|
1637
1607
|
};
|
|
1638
|
-
//# sourceMappingURL=chunk-
|
|
1608
|
+
//# sourceMappingURL=chunk-2VZ4RF4A.mjs.map
|