@dxos/app-framework 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.mts +1 -1
- package/.storybook/preview.mts +2 -2
- package/CHANGELOG.md +120 -0
- package/TASKS.md +11 -0
- package/dist/lib/chunk-SurfaceManager.mjs +960 -0
- package/dist/lib/chunk-SurfaceManager.mjs.map +1 -0
- package/dist/lib/chunk-capability.mjs +15 -0
- package/dist/lib/chunk-capability.mjs.map +1 -0
- package/dist/lib/{browser/chunk-FJ4765WW.mjs → chunk-context.mjs} +4 -5
- package/dist/lib/chunk-context.mjs.map +1 -0
- package/dist/lib/chunk-history-tracker.mjs +160 -0
- package/dist/lib/chunk-history-tracker.mjs.map +1 -0
- package/dist/lib/chunk-plugin-manager.mjs +1390 -0
- package/dist/lib/chunk-plugin-manager.mjs.map +1 -0
- package/dist/lib/chunk-plugin-manifest.mjs +125 -0
- package/dist/lib/chunk-plugin-manifest.mjs.map +1 -0
- package/dist/lib/chunk-process-manager-capability.mjs +126 -0
- package/dist/lib/chunk-process-manager-capability.mjs.map +1 -0
- package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
- package/dist/lib/chunk-url-loader.mjs +347 -0
- package/dist/lib/chunk-url-loader.mjs.map +1 -0
- package/dist/lib/cli.mjs +78 -0
- package/dist/lib/cli.mjs.map +1 -0
- package/dist/lib/common/activation-events.mjs +35 -0
- package/dist/lib/common/activation-events.mjs.map +1 -0
- package/dist/lib/common/capabilities.mjs +184 -0
- package/dist/lib/common/capabilities.mjs.map +1 -0
- package/dist/lib/config.mjs +2 -0
- package/dist/lib/core/activation-event.mjs +55 -0
- package/dist/lib/core/activation-event.mjs.map +1 -0
- package/dist/lib/core/capability.mjs +189 -0
- package/dist/lib/core/capability.mjs.map +1 -0
- package/dist/lib/core/plugin-manager.mjs +2 -0
- package/dist/lib/core/plugin.mjs +340 -0
- package/dist/lib/core/plugin.mjs.map +1 -0
- package/dist/lib/core/url-loader.mjs +2 -0
- package/dist/lib/index.mjs +134 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/testing/react.mjs +70 -0
- package/dist/lib/testing/react.mjs.map +1 -0
- package/dist/lib/testing.mjs +399 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/lib/ui.mjs +636 -0
- package/dist/lib/ui.mjs.map +1 -0
- package/dist/lib/vite-plugin.mjs +986 -0
- package/dist/lib/vite-plugin.mjs.map +1 -0
- package/dist/plugin/node-esm/index.mjs +4 -3
- package/dist/plugin/node-esm/index.mjs.map +3 -3
- package/dist/plugin/node-esm/meta.json +1 -1
- package/dist/types/src/common/Role.d.ts +31 -0
- package/dist/types/src/common/Role.d.ts.map +1 -0
- package/dist/types/src/common/Role.test.d.ts +2 -0
- package/dist/types/src/common/Role.test.d.ts.map +1 -0
- package/dist/types/src/common/capabilities.d.ts +11 -2
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +1 -0
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/core/capability-manager.d.ts +1 -1
- package/dist/types/src/core/capability-manager.d.ts.map +1 -1
- package/dist/types/src/core/capability.d.ts +38 -5
- package/dist/types/src/core/capability.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager.d.ts +1 -1
- package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +14 -1
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/core/registry.d.ts +1 -1
- package/dist/types/src/core/registry.d.ts.map +1 -1
- package/dist/types/src/plugin-process-manager/history/capability.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts +1 -1
- package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts.map +1 -1
- package/dist/types/src/testing/StorybookErrorFallback.d.ts +15 -0
- package/dist/types/src/testing/StorybookErrorFallback.d.ts.map +1 -0
- package/dist/types/src/testing/harness.d.ts +1 -1
- package/dist/types/src/testing/harness.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/react.d.ts +4 -4
- package/dist/types/src/testing/react.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts +6 -0
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/src/testing/withSurfaceDebug.d.ts +10 -0
- package/dist/types/src/testing/withSurfaceDebug.d.ts.map +1 -0
- package/dist/types/src/ui/components/App/App.d.ts +0 -32
- package/dist/types/src/ui/components/App/App.d.ts.map +1 -1
- package/dist/types/src/ui/components/App/index.d.ts +1 -0
- package/dist/types/src/ui/components/App/index.d.ts.map +1 -1
- package/dist/types/src/ui/components/App/loader.d.ts +35 -0
- package/dist/types/src/ui/components/App/loader.d.ts.map +1 -0
- package/dist/types/src/ui/components/HomeSection/HomeSection.d.ts +26 -0
- package/dist/types/src/ui/components/HomeSection/HomeSection.d.ts.map +1 -0
- package/dist/types/src/ui/components/HomeSection/HomeSection.stories.d.ts +15 -0
- package/dist/types/src/ui/components/HomeSection/HomeSection.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/HomeSection/index.d.ts +2 -0
- package/dist/types/src/ui/components/HomeSection/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/NamePopover/NamePopover.d.ts +14 -0
- package/dist/types/src/ui/components/NamePopover/NamePopover.d.ts.map +1 -0
- package/dist/types/src/ui/components/NamePopover/index.d.ts +2 -0
- package/dist/types/src/ui/components/NamePopover/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +21 -9
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts +4 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.test.d.ts +2 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.test.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceDebug.d.ts +40 -0
- package/dist/types/src/ui/components/Surface/SurfaceDebug.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceManager.d.ts +23 -0
- package/dist/types/src/ui/components/Surface/SurfaceManager.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceManagerContext.d.ts +11 -0
- package/dist/types/src/ui/components/Surface/SurfaceManagerContext.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceMetrics.d.ts +72 -0
- package/dist/types/src/ui/components/Surface/SurfaceMetrics.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/index.d.ts +20 -25
- package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -1
- package/dist/types/src/ui/components/Surface/types.d.ts +56 -52
- package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -1
- package/dist/types/src/ui/components/index.d.ts +2 -0
- package/dist/types/src/ui/components/index.d.ts.map +1 -1
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +25 -18
- package/package.json +58 -73
- package/src/common/Role.test.ts +41 -0
- package/src/common/Role.ts +54 -0
- package/src/common/capabilities.ts +17 -2
- package/src/common/index.ts +1 -0
- package/src/core/capability-manager.test.ts +1 -1
- package/src/core/capability-manager.ts +1 -1
- package/src/core/capability.ts +45 -6
- package/src/core/plugin-manager.test.ts +38 -3
- package/src/core/plugin-manager.ts +18 -1
- package/src/core/plugin.ts +16 -1
- package/src/core/registry.ts +1 -1
- package/src/plugin-process-manager/process-manager-capability.ts +25 -2
- package/src/testing/StorybookErrorFallback.tsx +40 -0
- package/src/testing/harness.ts +1 -1
- package/src/testing/index.ts +2 -0
- package/src/testing/react.test.tsx +2 -1
- package/src/testing/react.tsx +14 -8
- package/src/testing/withPluginManager.stories.tsx +16 -1
- package/src/testing/withPluginManager.tsx +13 -2
- package/src/testing/withSurfaceDebug.tsx +22 -0
- package/src/ui/components/App/App.tsx +7 -35
- package/src/ui/components/App/index.ts +1 -0
- package/src/ui/components/App/loader.ts +39 -0
- package/src/ui/components/HomeSection/HomeSection.stories.tsx +43 -0
- package/src/ui/components/HomeSection/HomeSection.tsx +69 -0
- package/src/ui/components/HomeSection/index.ts +5 -0
- package/src/ui/components/NamePopover/NamePopover.tsx +70 -0
- package/src/ui/components/NamePopover/index.ts +5 -0
- package/src/ui/components/Surface/DESIGN.md +136 -0
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +70 -41
- package/src/ui/components/Surface/SurfaceComponent.test.tsx +403 -0
- package/src/ui/components/Surface/SurfaceComponent.tsx +209 -189
- package/src/ui/components/Surface/SurfaceDebug.tsx +435 -0
- package/src/ui/components/Surface/SurfaceManager.ts +95 -0
- package/src/ui/components/Surface/SurfaceManagerContext.ts +23 -0
- package/src/ui/components/Surface/SurfaceMetrics.ts +202 -0
- package/src/ui/components/Surface/SurfaceProfilerContext.tsx +12 -2
- package/src/ui/components/Surface/index.ts +24 -22
- package/src/ui/components/Surface/types.test.ts +47 -54
- package/src/ui/components/Surface/types.ts +66 -91
- package/src/ui/components/index.ts +2 -0
- package/src/ui/hooks/useApp.tsx +7 -3
- package/src/vite-plugin/boot-loader/loader-app/boot-loader.css +1 -1
- package/tsconfig.json +3 -0
- package/vite.config.ts +26 -0
- package/dist/lib/browser/capability-S44TE2H7.mjs +0 -35
- package/dist/lib/browser/capability-S44TE2H7.mjs.map +0 -7
- package/dist/lib/browser/chunk-3NQLTQCP.mjs +0 -47
- package/dist/lib/browser/chunk-3NQLTQCP.mjs.map +0 -7
- package/dist/lib/browser/chunk-53HJHMS5.mjs +0 -7
- package/dist/lib/browser/chunk-53HJHMS5.mjs.map +0 -7
- package/dist/lib/browser/chunk-FJ4765WW.mjs.map +0 -7
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/browser/chunk-KRJ4KK2W.mjs +0 -505
- package/dist/lib/browser/chunk-KRJ4KK2W.mjs.map +0 -7
- package/dist/lib/browser/chunk-LUH4Y5F2.mjs +0 -430
- package/dist/lib/browser/chunk-LUH4Y5F2.mjs.map +0 -7
- package/dist/lib/browser/chunk-NKVRSMFN.mjs +0 -95
- package/dist/lib/browser/chunk-NKVRSMFN.mjs.map +0 -7
- package/dist/lib/browser/chunk-OO53M5UK.mjs +0 -260
- package/dist/lib/browser/chunk-OO53M5UK.mjs.map +0 -7
- package/dist/lib/browser/chunk-OPTS3ZSN.mjs +0 -83
- package/dist/lib/browser/chunk-OPTS3ZSN.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q2GLJTVV.mjs +0 -12
- package/dist/lib/browser/chunk-Q2GLJTVV.mjs.map +0 -7
- package/dist/lib/browser/chunk-SYXIYT6T.mjs +0 -143
- package/dist/lib/browser/chunk-SYXIYT6T.mjs.map +0 -7
- package/dist/lib/browser/chunk-U5MESPM5.mjs +0 -603
- package/dist/lib/browser/chunk-U5MESPM5.mjs.map +0 -7
- package/dist/lib/browser/chunk-UGYCLOXE.mjs +0 -1471
- package/dist/lib/browser/chunk-UGYCLOXE.mjs.map +0 -7
- package/dist/lib/browser/chunk-VF37YTXJ.mjs +0 -28
- package/dist/lib/browser/chunk-VF37YTXJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-YUVQIOTB.mjs +0 -60
- package/dist/lib/browser/chunk-YUVQIOTB.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs +0 -74
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/common/activation-events.mjs +0 -20
- package/dist/lib/browser/common/activation-events.mjs.map +0 -7
- package/dist/lib/browser/common/capabilities.mjs +0 -56
- package/dist/lib/browser/common/capabilities.mjs.map +0 -7
- package/dist/lib/browser/config/index.mjs +0 -8
- package/dist/lib/browser/config/index.mjs.map +0 -7
- package/dist/lib/browser/core/activation-event.mjs +0 -20
- package/dist/lib/browser/core/activation-event.mjs.map +0 -7
- package/dist/lib/browser/core/capability.mjs +0 -32
- package/dist/lib/browser/core/capability.mjs.map +0 -7
- package/dist/lib/browser/core/plugin-manager.mjs +0 -19
- package/dist/lib/browser/core/plugin-manager.mjs.map +0 -7
- package/dist/lib/browser/core/plugin.mjs +0 -51
- package/dist/lib/browser/core/plugin.mjs.map +0 -7
- package/dist/lib/browser/core/url-loader.mjs +0 -24
- package/dist/lib/browser/core/url-loader.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -98
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/process-manager-capability-QK4BMKMN.mjs +0 -132
- package/dist/lib/browser/process-manager-capability-QK4BMKMN.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -359
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/browser/testing/react.mjs +0 -78
- package/dist/lib/browser/testing/react.mjs.map +0 -7
- package/dist/lib/browser/ui/index.mjs +0 -60
- package/dist/lib/browser/ui/index.mjs.map +0 -7
- package/dist/lib/node-esm/capability-3YRF77LV.mjs +0 -36
- package/dist/lib/node-esm/capability-3YRF77LV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2UPUZXGU.mjs +0 -9
- package/dist/lib/node-esm/chunk-2UPUZXGU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-37Z53PXZ.mjs +0 -10
- package/dist/lib/node-esm/chunk-37Z53PXZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4SE7SX7N.mjs +0 -261
- package/dist/lib/node-esm/chunk-4SE7SX7N.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BMW6P6QA.mjs +0 -48
- package/dist/lib/node-esm/chunk-BMW6P6QA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-COHOWGGJ.mjs +0 -144
- package/dist/lib/node-esm/chunk-COHOWGGJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DRT75WGD.mjs +0 -604
- package/dist/lib/node-esm/chunk-DRT75WGD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FKMVORZN.mjs +0 -431
- package/dist/lib/node-esm/chunk-FKMVORZN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-FPW45EZH.mjs +0 -14
- package/dist/lib/node-esm/chunk-FPW45EZH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GLH4LGHZ.mjs +0 -84
- package/dist/lib/node-esm/chunk-GLH4LGHZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IL7O7IRX.mjs +0 -1472
- package/dist/lib/node-esm/chunk-IL7O7IRX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ND2HETHD.mjs +0 -506
- package/dist/lib/node-esm/chunk-ND2HETHD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TLKYZKPW.mjs +0 -29
- package/dist/lib/node-esm/chunk-TLKYZKPW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VCPGX7WN.mjs +0 -62
- package/dist/lib/node-esm/chunk-VCPGX7WN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XSZMX53L.mjs +0 -96
- package/dist/lib/node-esm/chunk-XSZMX53L.mjs.map +0 -7
- package/dist/lib/node-esm/cli/index.mjs +0 -75
- package/dist/lib/node-esm/cli/index.mjs.map +0 -7
- package/dist/lib/node-esm/common/activation-events.mjs +0 -21
- package/dist/lib/node-esm/common/activation-events.mjs.map +0 -7
- package/dist/lib/node-esm/common/capabilities.mjs +0 -57
- package/dist/lib/node-esm/common/capabilities.mjs.map +0 -7
- package/dist/lib/node-esm/config/index.mjs +0 -9
- package/dist/lib/node-esm/config/index.mjs.map +0 -7
- package/dist/lib/node-esm/core/activation-event.mjs +0 -21
- package/dist/lib/node-esm/core/activation-event.mjs.map +0 -7
- package/dist/lib/node-esm/core/capability.mjs +0 -33
- package/dist/lib/node-esm/core/capability.mjs.map +0 -7
- package/dist/lib/node-esm/core/plugin-manager.mjs +0 -20
- package/dist/lib/node-esm/core/plugin-manager.mjs.map +0 -7
- package/dist/lib/node-esm/core/plugin.mjs +0 -52
- package/dist/lib/node-esm/core/plugin.mjs.map +0 -7
- package/dist/lib/node-esm/core/url-loader.mjs +0 -25
- package/dist/lib/node-esm/core/url-loader.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -99
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/process-manager-capability-5S7WZ2JR.mjs +0 -133
- package/dist/lib/node-esm/process-manager-capability-5S7WZ2JR.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -360
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/testing/react.mjs +0 -79
- package/dist/lib/node-esm/testing/react.mjs.map +0 -7
- package/dist/lib/node-esm/ui/index.mjs +0 -61
- package/dist/lib/node-esm/ui/index.mjs.map +0 -7
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts +0 -11
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +0 -1
- package/src/ui/components/Surface/SurfaceInfo.tsx +0 -106
- package/vitest.config.ts +0 -14
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { t as __exportAll } from "../chunk-rolldown-runtime.mjs";
|
|
2
|
+
import { get, make } from "../core/capability.mjs";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
//#region src/common/capabilities.ts
|
|
5
|
+
var capabilities_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
AtomRegistry: () => AtomRegistry,
|
|
7
|
+
Command: () => Command,
|
|
8
|
+
HistoryTracker: () => HistoryTracker,
|
|
9
|
+
Layer: () => Layer,
|
|
10
|
+
LayerSpec: () => LayerSpec,
|
|
11
|
+
ManagedRuntime: () => ManagedRuntime,
|
|
12
|
+
Null: () => Null,
|
|
13
|
+
OperationHandler: () => OperationHandler,
|
|
14
|
+
OperationInvoker: () => OperationInvoker,
|
|
15
|
+
PluginManager: () => PluginManager,
|
|
16
|
+
ProcessManagerRuntime: () => ProcessManagerRuntime,
|
|
17
|
+
ProcessMonitor: () => ProcessMonitor,
|
|
18
|
+
ReactContext: () => ReactContext,
|
|
19
|
+
ReactRoot: () => ReactRoot,
|
|
20
|
+
ReactSurface: () => ReactSurface,
|
|
21
|
+
RemoteTraceMonitor: () => RemoteTraceMonitor,
|
|
22
|
+
ServiceResolver: () => ServiceResolver,
|
|
23
|
+
TraceSink: () => TraceSink,
|
|
24
|
+
UndoMapping: () => UndoMapping,
|
|
25
|
+
UndoRegistry: () => UndoRegistry,
|
|
26
|
+
getAtomValue: () => getAtomValue,
|
|
27
|
+
subscribeAtom: () => subscribeAtom,
|
|
28
|
+
updateAtomValue: () => updateAtomValue
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Null capability.
|
|
32
|
+
* @category Capability
|
|
33
|
+
*/
|
|
34
|
+
var Null = make("org.dxos.app-framework.capability.null");
|
|
35
|
+
/**
|
|
36
|
+
* @category Capability
|
|
37
|
+
*/
|
|
38
|
+
var PluginManager = make("org.dxos.app-framework.capability.pluginManager");
|
|
39
|
+
/**
|
|
40
|
+
* @category Capability
|
|
41
|
+
*/
|
|
42
|
+
var AtomRegistry = make("org.dxos.app-framework.capability.atomRegistry");
|
|
43
|
+
/**
|
|
44
|
+
* @category Capability
|
|
45
|
+
*/
|
|
46
|
+
var ReactContext = make("org.dxos.app-framework.capability.reactContext");
|
|
47
|
+
/**
|
|
48
|
+
* @category Capability
|
|
49
|
+
*/
|
|
50
|
+
var ReactRoot = make("org.dxos.app-framework.capability.reactRoot");
|
|
51
|
+
/**
|
|
52
|
+
* @category Capability
|
|
53
|
+
*/
|
|
54
|
+
var ReactSurface = make("org.dxos.app-framework.capability.reactSurface");
|
|
55
|
+
/**
|
|
56
|
+
* @category Capability
|
|
57
|
+
*/
|
|
58
|
+
var Command = make("org.dxos.app-framework.capability.command");
|
|
59
|
+
/**
|
|
60
|
+
* @category Capability
|
|
61
|
+
*/
|
|
62
|
+
var Layer = make("org.dxos.app-framework.capability.layer");
|
|
63
|
+
/**
|
|
64
|
+
* Layer specification contributed by plugins.
|
|
65
|
+
*
|
|
66
|
+
* Plugins contribute {@link LayerSpec.LayerSpec} entries that are collected by the
|
|
67
|
+
* process-manager module and composed into a {@link LayerStack} which backs the
|
|
68
|
+
* {@link ProcessManagerRuntime}'s service resolver.
|
|
69
|
+
*
|
|
70
|
+
* @category Capability
|
|
71
|
+
*/
|
|
72
|
+
var LayerSpec = make("org.dxos.app-framework.capability.layerSpec");
|
|
73
|
+
/**
|
|
74
|
+
* Trace sink contribution.
|
|
75
|
+
*
|
|
76
|
+
* Plugins contribute {@link TraceSinkFactory} functions; the process-manager
|
|
77
|
+
* capability invokes each factory with the runtime's
|
|
78
|
+
* {@link ServiceResolver$.ServiceResolver}, collects the resulting
|
|
79
|
+
* {@link Trace$.Sink}s, merges them via {@link Trace$.mergeSinks}, and
|
|
80
|
+
* installs the merged sink as {@link Trace$.TraceSink} in the runtime layer
|
|
81
|
+
* so every process writes to every contributed sink.
|
|
82
|
+
*
|
|
83
|
+
* @category Capability
|
|
84
|
+
*/
|
|
85
|
+
var TraceSink = make("org.dxos.app-framework.capability.traceSink");
|
|
86
|
+
/**
|
|
87
|
+
* Source of ephemeral trace messages broadcast by remote runtimes over the space swarm (DX-1125).
|
|
88
|
+
* Contributed by a client-aware plugin; the process-manager capability wires the first contribution
|
|
89
|
+
* (or a no-op) into the aggregate {@link ProcessMonitor} so its `subscribeToTraceMessages` surfaces
|
|
90
|
+
* remote progress alongside local.
|
|
91
|
+
*
|
|
92
|
+
* @category Capability
|
|
93
|
+
*/
|
|
94
|
+
var RemoteTraceMonitor = make("org.dxos.app-framework.capability.remoteTraceMonitor");
|
|
95
|
+
/**
|
|
96
|
+
* Service resolver backing the shared {@link ProcessManagerRuntime}.
|
|
97
|
+
*
|
|
98
|
+
* Contributed by the process-manager capability module. Consumers can combine
|
|
99
|
+
* it with {@link ServiceResolver$.provide} to build space-scoped layers without
|
|
100
|
+
* having to go through the process-manager runtime:
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const resolver = yield* Capability.get(Capabilities.ServiceResolver);
|
|
105
|
+
* yield* effect.pipe(
|
|
106
|
+
* Effect.provide(
|
|
107
|
+
* ServiceResolver.provide({ space }, Database.Service).pipe(
|
|
108
|
+
* Layer.provide(Layer.succeed(ServiceResolver.ServiceResolver, resolver)),
|
|
109
|
+
* ),
|
|
110
|
+
* ),
|
|
111
|
+
* );
|
|
112
|
+
* ```
|
|
113
|
+
*
|
|
114
|
+
* @category Capability
|
|
115
|
+
*/
|
|
116
|
+
var ServiceResolver = make("org.dxos.app-framework.capability.serviceResolver");
|
|
117
|
+
/**
|
|
118
|
+
* Process monitor backing the shared {@link ProcessManagerRuntime}. Exposes the
|
|
119
|
+
* live process tree (including inactive/terminated entries) via
|
|
120
|
+
* {@link Process$.Monitor#processTreeAtom}.
|
|
121
|
+
*
|
|
122
|
+
* @category Capability
|
|
123
|
+
*/
|
|
124
|
+
var ProcessMonitor = make("org.dxos.app-framework.capability.processMonitor");
|
|
125
|
+
/**
|
|
126
|
+
* @category Capability
|
|
127
|
+
*/
|
|
128
|
+
var ProcessManagerRuntime = make("org.dxos.app-framework.capability.processManagerRuntime");
|
|
129
|
+
/**
|
|
130
|
+
* @category Capability
|
|
131
|
+
*/
|
|
132
|
+
var ManagedRuntime = make("org.dxos.app-framework.capability.managedRuntime");
|
|
133
|
+
var OperationHandler = make("org.dxos.app-framework.capability.operationHandler");
|
|
134
|
+
/**
|
|
135
|
+
* Undo mapping registration - contributed by plugins.
|
|
136
|
+
* @category Capability
|
|
137
|
+
*/
|
|
138
|
+
var UndoMapping = make("org.dxos.app-framework.capability.undoMapping");
|
|
139
|
+
/**
|
|
140
|
+
* Operation invoker - provided by the process-manager capability.
|
|
141
|
+
* @category Capability
|
|
142
|
+
*/
|
|
143
|
+
var OperationInvoker = make("org.dxos.app-framework.capability.operationInvoker");
|
|
144
|
+
/**
|
|
145
|
+
* Undo registry - provided by ProcessManagerPlugin.
|
|
146
|
+
* @category Capability
|
|
147
|
+
*/
|
|
148
|
+
var UndoRegistry = make("org.dxos.app-framework.capability.undoRegistry");
|
|
149
|
+
/**
|
|
150
|
+
* History tracker - provided by ProcessManagerPlugin.
|
|
151
|
+
* @category Capability
|
|
152
|
+
*/
|
|
153
|
+
var HistoryTracker = make("org.dxos.app-framework.capability.historyTracker");
|
|
154
|
+
/**
|
|
155
|
+
* Get the current value of an atom capability.
|
|
156
|
+
* @example const settings = yield* Capabilities.getAtomValue(CommentCapabilities.Settings);
|
|
157
|
+
*/
|
|
158
|
+
var getAtomValue = (atomCapability) => Effect.gen(function* () {
|
|
159
|
+
const registry = yield* get(AtomRegistry);
|
|
160
|
+
const atom = yield* get(atomCapability);
|
|
161
|
+
return registry.get(atom);
|
|
162
|
+
});
|
|
163
|
+
/**
|
|
164
|
+
* Update an atom capability value (requires writable atom).
|
|
165
|
+
* @example yield* Capabilities.updateAtomValue(CommentCapabilities.Settings, (s) => ({ ...s, foo: true }));
|
|
166
|
+
*/
|
|
167
|
+
var updateAtomValue = (atomCapability, fn) => Effect.gen(function* () {
|
|
168
|
+
const registry = yield* get(AtomRegistry);
|
|
169
|
+
const atom = yield* get(atomCapability);
|
|
170
|
+
registry.set(atom, fn(registry.get(atom)));
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Subscribe to an atom capability.
|
|
174
|
+
* @example const unsubscribe = yield* Capabilities.subscribeAtom(CommentCapabilities.Settings, (value) => ...);
|
|
175
|
+
*/
|
|
176
|
+
var subscribeAtom = (atomCapability, callback) => Effect.gen(function* () {
|
|
177
|
+
const registry = yield* get(AtomRegistry);
|
|
178
|
+
const atom = yield* get(atomCapability);
|
|
179
|
+
return registry.subscribe(atom, () => callback(registry.get(atom)));
|
|
180
|
+
});
|
|
181
|
+
//#endregion
|
|
182
|
+
export { AtomRegistry, Command, HistoryTracker, Layer, LayerSpec, ManagedRuntime, Null, OperationHandler, OperationInvoker, PluginManager, ProcessManagerRuntime, ProcessMonitor, ReactContext, ReactRoot, ReactSurface, RemoteTraceMonitor, ServiceResolver, TraceSink, UndoMapping, UndoRegistry, getAtomValue, subscribeAtom, capabilities_exports as t, updateAtomValue };
|
|
183
|
+
|
|
184
|
+
//# sourceMappingURL=capabilities.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.mjs","names":[],"sources":["../../../src/common/capabilities.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom, type Registry } from '@effect-atom/atom';\nimport type * as Command$ from '@effect/cli/Command';\nimport * as Effect from 'effect/Effect';\nimport type * as Exit$ from 'effect/Exit';\nimport type * as Fiber$ from 'effect/Fiber';\nimport type * as Layer$ from 'effect/Layer';\nimport type * as ManagedRuntime$ from 'effect/ManagedRuntime';\nimport type * as Runtime$ from 'effect/Runtime';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport type {\n OperationHandlerSet,\n LayerSpec as LayerSpec$,\n Operation as Operation$,\n Process as Process$,\n ServiceResolver as ServiceResolver$,\n Trace as Trace$,\n} from '@dxos/compute';\nimport type {\n ProcessManager as ProcessManager$,\n RemoteTraceMonitor as RemoteTraceMonitor$,\n} from '@dxos/compute-runtime';\nimport { OperationInvoker as OperationInvoker$ } from '@dxos/operation';\n\nimport { Capability as Capability$, Plugin as Plugin$, type PluginManager as PluginManager$ } from '../core';\nimport type {\n HistoryTracker as HistoryTracker$,\n UndoMapping as UndoMapping$,\n UndoRegistry as UndoRegistry$,\n} from '../plugin-process-manager';\nimport type { Surface } from '../ui';\n\n/**\n * Null capability.\n * @category Capability\n */\nexport const Null = Capability$.make<null>('org.dxos.app-framework.capability.null');\n\n/**\n * @category Capability\n */\nexport const PluginManager = Capability$.make<PluginManager$.PluginManager>(\n 'org.dxos.app-framework.capability.pluginManager',\n);\n\n/**\n * @category Capability\n */\nexport const AtomRegistry = Capability$.make<Registry.Registry>('org.dxos.app-framework.capability.atomRegistry');\n\nexport type ReactContext = Readonly<{\n id: string;\n dependsOn?: string[];\n context: FC<PropsWithChildren>;\n}>;\n\n/**\n * @category Capability\n */\nexport const ReactContext = Capability$.make<ReactContext>('org.dxos.app-framework.capability.reactContext');\n\nexport type ReactRoot = Readonly<{ id: string; root: FC<PropsWithChildren> }>;\n\n/**\n * @category Capability\n */\nexport const ReactRoot = Capability$.make<ReactRoot>('org.dxos.app-framework.capability.reactRoot');\n\n/**\n * Surface definitions that can be either React components or Web Components.\n */\nexport type ReactSurface = Surface.Definition | readonly Surface.Definition[];\n\n/**\n * @category Capability\n */\nexport const ReactSurface = Capability$.make<ReactSurface>('org.dxos.app-framework.capability.reactSurface');\n\nexport type AnyCommand = Command$.Command<any, any, any, any>;\n\n/**\n * @category Capability\n */\nexport const Command = Capability$.make<AnyCommand>('org.dxos.app-framework.capability.command');\n\n/**\n * @category Capability\n */\nexport const Layer = Capability$.make<Layer$.Layer<any, any, any>>('org.dxos.app-framework.capability.layer');\n\n/**\n * Layer specification contributed by plugins.\n *\n * Plugins contribute {@link LayerSpec.LayerSpec} entries that are collected by the\n * process-manager module and composed into a {@link LayerStack} which backs the\n * {@link ProcessManagerRuntime}'s service resolver.\n *\n * @category Capability\n */\nexport const LayerSpec = Capability$.make<LayerSpec$.LayerSpec>('org.dxos.app-framework.capability.layerSpec');\n\n/**\n * Context passed to {@link TraceSinkFactory} implementations when the\n * process-manager capability materialises contributed sinks.\n */\nexport interface TraceSinkFactoryContext {\n /**\n * Service resolver backing the shared {@link ProcessManagerRuntime}. Use it\n * to resolve per-space (or per-process) services like `FeedTraceSink` when\n * building a routing sink.\n */\n readonly resolver: ServiceResolver$.ServiceResolver;\n}\n\n/**\n * Factory that builds a {@link Trace$.Sink} when the process-manager\n * capability is ready. Plugins that only need a static sink can ignore the\n * context (e.g. `() => myConsoleSink`); plugins that need per-space routing\n * can use {@link TraceSinkFactoryContext.resolver} to look up services.\n */\nexport type TraceSinkFactory = (ctx: TraceSinkFactoryContext) => Trace$.Sink;\n\n/**\n * Trace sink contribution.\n *\n * Plugins contribute {@link TraceSinkFactory} functions; the process-manager\n * capability invokes each factory with the runtime's\n * {@link ServiceResolver$.ServiceResolver}, collects the resulting\n * {@link Trace$.Sink}s, merges them via {@link Trace$.mergeSinks}, and\n * installs the merged sink as {@link Trace$.TraceSink} in the runtime layer\n * so every process writes to every contributed sink.\n *\n * @category Capability\n */\nexport const TraceSink = Capability$.make<TraceSinkFactory>('org.dxos.app-framework.capability.traceSink');\n\n/**\n * Source of ephemeral trace messages broadcast by remote runtimes over the space swarm (DX-1125).\n * Contributed by a client-aware plugin; the process-manager capability wires the first contribution\n * (or a no-op) into the aggregate {@link ProcessMonitor} so its `subscribeToTraceMessages` surfaces\n * remote progress alongside local.\n *\n * @category Capability\n */\nexport const RemoteTraceMonitor = Capability$.make<RemoteTraceMonitor$.Monitor>(\n 'org.dxos.app-framework.capability.remoteTraceMonitor',\n);\n\n/**\n * Service resolver backing the shared {@link ProcessManagerRuntime}.\n *\n * Contributed by the process-manager capability module. Consumers can combine\n * it with {@link ServiceResolver$.provide} to build space-scoped layers without\n * having to go through the process-manager runtime:\n *\n * @example\n * ```ts\n * const resolver = yield* Capability.get(Capabilities.ServiceResolver);\n * yield* effect.pipe(\n * Effect.provide(\n * ServiceResolver.provide({ space }, Database.Service).pipe(\n * Layer.provide(Layer.succeed(ServiceResolver.ServiceResolver, resolver)),\n * ),\n * ),\n * );\n * ```\n *\n * @category Capability\n */\nexport const ServiceResolver = Capability$.make<ServiceResolver$.ServiceResolver>(\n 'org.dxos.app-framework.capability.serviceResolver',\n);\n\n/**\n * Process monitor backing the shared {@link ProcessManagerRuntime}. Exposes the\n * live process tree (including inactive/terminated entries) via\n * {@link Process$.Monitor#processTreeAtom}.\n *\n * @category Capability\n */\nexport const ProcessMonitor = Capability$.make<Process$.Monitor>('org.dxos.app-framework.capability.processMonitor');\n\n/**\n * Services that are always available when running effects through a {@link ProcessManagerRuntime}.\n */\nexport type ProcessManagerRuntimeServices =\n | Capability$.Service\n | Plugin$.Service\n | ProcessManager$.ProcessManagerService\n | Operation$.Service\n | ProcessManager$.ProcessOperationInvoker.Service\n | ServiceResolver$.ServiceResolver;\n\n/**\n * Runtime that runs effects requiring a fixed set of capability-manager and\n * process-manager services.\n *\n * The shape mirrors {@link ManagedRuntime$.ManagedRuntime} but deliberately does\n * not expose `dispose` – lifecycle is driven by the host plugin manager.\n */\nexport interface ProcessManagerRuntime {\n runPromise<A, E>(\n effect: Effect.Effect<A, E, ProcessManagerRuntimeServices>,\n options?: { readonly signal?: AbortSignal },\n ): Promise<A>;\n runPromiseExit<A, E>(\n effect: Effect.Effect<A, E, ProcessManagerRuntimeServices>,\n options?: { readonly signal?: AbortSignal },\n ): Promise<Exit$.Exit<A, E>>;\n runFork<A, E>(\n effect: Effect.Effect<A, E, ProcessManagerRuntimeServices>,\n options?: Runtime$.RunForkOptions,\n ): Fiber$.RuntimeFiber<A, E>;\n runSync<A, E>(effect: Effect.Effect<A, E, ProcessManagerRuntimeServices>): A;\n}\n\n/**\n * @category Capability\n */\nexport const ProcessManagerRuntime = Capability$.make<ProcessManagerRuntime>(\n 'org.dxos.app-framework.capability.processManagerRuntime',\n);\n\nexport type ManagedRuntime = ManagedRuntime$.ManagedRuntime<any, any>;\n\n/**\n * @category Capability\n */\nexport const ManagedRuntime = Capability$.make<ManagedRuntime>('org.dxos.app-framework.capability.managedRuntime');\n\n//\n// Operation System Capabilities\n//\n\nexport const OperationHandler = Capability$.make<OperationHandlerSet.OperationHandlerSet>(\n 'org.dxos.app-framework.capability.operationHandler',\n);\n\nexport type UndoMapping = UndoMapping$.UndoMapping;\n\n/**\n * Undo mapping registration - contributed by plugins.\n * @category Capability\n */\nexport const UndoMapping = Capability$.make<UndoMapping[]>('org.dxos.app-framework.capability.undoMapping');\n\n/**\n * Operation invoker backed by the process manager. Spawns a process per\n * operation invocation; see {@link ProcessManager$.ProcessOperationInvoker}.\n */\nexport type OperationInvoker = OperationInvoker$.OperationInvoker;\n\n/**\n * Operation invoker - provided by the process-manager capability.\n * @category Capability\n */\nexport const OperationInvoker = Capability$.make<OperationInvoker>(\n 'org.dxos.app-framework.capability.operationInvoker',\n);\n\nexport type UndoRegistry = UndoRegistry$.UndoRegistry;\n\n/**\n * Undo registry - provided by ProcessManagerPlugin.\n * @category Capability\n */\nexport const UndoRegistry = Capability$.make<UndoRegistry>('org.dxos.app-framework.capability.undoRegistry');\n\nexport type HistoryTracker = HistoryTracker$.HistoryTracker;\n\n/**\n * History tracker - provided by ProcessManagerPlugin.\n * @category Capability\n */\nexport const HistoryTracker = Capability$.make<HistoryTracker>('org.dxos.app-framework.capability.historyTracker');\n\n//\n// Atom Capability Helpers\n//\n\n/**\n * Get the current value of an atom capability.\n * @example const settings = yield* Capabilities.getAtomValue(CommentCapabilities.Settings);\n */\nexport const getAtomValue = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n): Effect.Effect<T, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n return registry.get(atom);\n });\n\n/**\n * Update an atom capability value (requires writable atom).\n * @example yield* Capabilities.updateAtomValue(CommentCapabilities.Settings, (s) => ({ ...s, foo: true }));\n */\nexport const updateAtomValue = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Writable<T>>,\n fn: (current: T) => T,\n): Effect.Effect<void, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n registry.set(atom, fn(registry.get(atom)));\n });\n\n/**\n * Subscribe to an atom capability.\n * @example const unsubscribe = yield* Capabilities.subscribeAtom(CommentCapabilities.Settings, (value) => ...);\n */\nexport const subscribeAtom = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n callback: (value: T) => void,\n): Effect.Effect<() => void, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n return registry.subscribe(atom, () => callback(registry.get(atom)));\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,OAAO,KAAuB,wCAAwC;;;;AAKnF,IAAa,gBAAgB,KAC3B,iDACF;;;;AAKA,IAAa,eAAe,KAAoC,gDAAgD;;;;AAWhH,IAAa,eAAe,KAA+B,gDAAgD;;;;AAO3G,IAAa,YAAY,KAA4B,6CAA6C;;;;AAUlG,IAAa,eAAe,KAA+B,gDAAgD;;;;AAO3G,IAAa,UAAU,KAA6B,2CAA2C;;;;AAK/F,IAAa,QAAQ,KAA8C,yCAAyC;;;;;;;;;;AAW5G,IAAa,YAAY,KAAuC,6CAA6C;;;;;;;;;;;;;AAmC7G,IAAa,YAAY,KAAmC,6CAA6C;;;;;;;;;AAUzG,IAAa,qBAAqB,KAChC,sDACF;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,kBAAkB,KAC7B,mDACF;;;;;;;;AASA,IAAa,iBAAiB,KAAmC,kDAAkD;;;;AAuCnH,IAAa,wBAAwB,KACnC,yDACF;;;;AAOA,IAAa,iBAAiB,KAAiC,kDAAkD;AAMjH,IAAa,mBAAmB,KAC9B,oDACF;;;;;AAQA,IAAa,cAAc,KAAgC,+CAA+C;;;;;AAY1G,IAAa,mBAAmB,KAC9B,oDACF;;;;;AAQA,IAAa,eAAe,KAA+B,gDAAgD;;;;;AAQ3G,IAAa,iBAAiB,KAAiC,kDAAkD;;;;;AAUjH,IAAa,gBACX,mBAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAO,IAAgB,YAAY;CACpD,MAAM,OAAO,OAAO,IAAgB,cAAc;CAClD,OAAO,SAAS,IAAI,IAAI;AAC1B,CAAC;;;;;AAMH,IAAa,mBACX,gBACA,OAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAO,IAAgB,YAAY;CACpD,MAAM,OAAO,OAAO,IAAgB,cAAc;CAClD,SAAS,IAAI,MAAM,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC;AAC3C,CAAC;;;;;AAMH,IAAa,iBACX,gBACA,aAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAO,IAAgB,YAAY;CACpD,MAAM,OAAO,OAAO,IAAgB,cAAc;CAClD,OAAO,SAAS,UAAU,YAAY,SAAS,SAAS,IAAI,IAAI,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { t as __exportAll } from "../chunk-rolldown-runtime.mjs";
|
|
2
|
+
import { DXN } from "@dxos/keys";
|
|
3
|
+
import { compositeKey } from "@dxos/util";
|
|
4
|
+
//#region src/core/activation-event.ts
|
|
5
|
+
var activation_event_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
allOf: () => allOf,
|
|
7
|
+
eventKey: () => eventKey,
|
|
8
|
+
getEvents: () => getEvents,
|
|
9
|
+
isAllOf: () => isAllOf,
|
|
10
|
+
isOneOf: () => isOneOf,
|
|
11
|
+
make: () => make,
|
|
12
|
+
oneOf: () => oneOf
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Helper to define an activation event from an NSID.
|
|
16
|
+
* Static NSID strings are validated at compile time via {@link DXN.Name}.
|
|
17
|
+
*/
|
|
18
|
+
var make = (nsid, specifier) => ({
|
|
19
|
+
id: DXN.make(nsid),
|
|
20
|
+
specifier
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Helper to create an activation event key.
|
|
24
|
+
*/
|
|
25
|
+
var eventKey = (event) => event.specifier ? compositeKey(event.id, event.specifier) : event.id;
|
|
26
|
+
/**
|
|
27
|
+
* Helper to create an activation event that triggers when any of the given events are activated.
|
|
28
|
+
*/
|
|
29
|
+
var oneOf = (...events) => ({
|
|
30
|
+
type: "one-of",
|
|
31
|
+
events
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Helper to create an activation event that triggers when all of the given events are activated.
|
|
35
|
+
*/
|
|
36
|
+
var allOf = (...events) => ({
|
|
37
|
+
type: "all-of",
|
|
38
|
+
events
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Helper to check if an activation event is a one-of event.
|
|
42
|
+
*/
|
|
43
|
+
var isOneOf = (events) => "type" in events && events.type === "one-of";
|
|
44
|
+
/**
|
|
45
|
+
* Helper to check if an activation event is an all-of event.
|
|
46
|
+
*/
|
|
47
|
+
var isAllOf = (events) => "type" in events && events.type === "all-of";
|
|
48
|
+
/**
|
|
49
|
+
* Helper to get the events from an activation event.
|
|
50
|
+
*/
|
|
51
|
+
var getEvents = (events) => "type" in events ? events.events : [events];
|
|
52
|
+
//#endregion
|
|
53
|
+
export { allOf, eventKey, getEvents, isAllOf, isOneOf, make, oneOf, activation_event_exports as t };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=activation-event.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activation-event.mjs","names":[],"sources":["../../../src/core/activation-event.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { DXN } from '@dxos/keys';\nimport { compositeKey } from '@dxos/util';\n\n/**\n * A unique DXN identifier representing an event.\n *\n * @example dxn:org.dxos.plugin.example.event.ready\n */\nexport type ActivationEvent = {\n id: DXN.DXN;\n specifier?: string;\n};\n\n/**\n * An activation event that can be a single event, or a combination of events.\n */\nexport type Events =\n | ActivationEvent\n | { type: 'one-of'; events: ActivationEvent[] }\n | { type: 'all-of'; events: ActivationEvent[] };\n\n/**\n * Helper to define an activation event from an NSID.\n * Static NSID strings are validated at compile time via {@link DXN.Name}.\n */\nexport const make: {\n <T extends string>(\n nsid: [DXN.Name<T>] extends [never] ? `Invalid NSID \"${T}\": final segment must be camelCase (no hyphens)` : T,\n specifier?: string,\n ): ActivationEvent;\n} = (nsid: string, specifier?: string): ActivationEvent => ({\n id: DXN.make(nsid),\n specifier,\n});\n\n/**\n * Helper to create an activation event key.\n */\nexport const eventKey = (event: ActivationEvent) =>\n event.specifier ? compositeKey(event.id, event.specifier) : event.id;\n\n/**\n * Helper to create an activation event that triggers when any of the given events are activated.\n */\nexport const oneOf = (...events: ActivationEvent[]) => ({ type: 'one-of' as const, events });\n\n/**\n * Helper to create an activation event that triggers when all of the given events are activated.\n */\nexport const allOf = (...events: ActivationEvent[]) => ({ type: 'all-of' as const, events });\n\n/**\n * Helper to check if an activation event is a one-of event.\n */\nexport const isOneOf = (events: Events): events is { type: 'one-of'; events: ActivationEvent[] } =>\n 'type' in events && events.type === 'one-of';\n\n/**\n * Helper to check if an activation event is an all-of event.\n */\nexport const isAllOf = (events: Events): events is { type: 'all-of'; events: ActivationEvent[] } =>\n 'type' in events && events.type === 'all-of';\n\n/**\n * Helper to get the events from an activation event.\n */\nexport const getEvents = (events: Events) => ('type' in events ? events.events : [events]);\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BA,IAAa,QAKR,MAAc,eAAyC;CAC1D,IAAI,IAAI,KAAK,IAAI;CACjB;AACF;;;;AAKA,IAAa,YAAY,UACvB,MAAM,YAAY,aAAa,MAAM,IAAI,MAAM,SAAS,IAAI,MAAM;;;;AAKpE,IAAa,SAAS,GAAG,YAA+B;CAAE,MAAM;CAAmB;AAAO;;;;AAK1F,IAAa,SAAS,GAAG,YAA+B;CAAE,MAAM;CAAmB;AAAO;;;;AAK1F,IAAa,WAAW,WACtB,UAAU,UAAU,OAAO,SAAS;;;;AAKtC,IAAa,WAAW,WACtB,UAAU,UAAU,OAAO,SAAS;;;;AAKtC,IAAa,aAAa,WAAoB,UAAU,SAAS,OAAO,SAAS,CAAC,MAAM"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { t as __exportAll } from "../chunk-rolldown-runtime.mjs";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Option from "effect/Option";
|
|
6
|
+
//#region src/core/capability.ts
|
|
7
|
+
var capability_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
ModuleTag: () => ModuleTag,
|
|
9
|
+
Service: () => Service,
|
|
10
|
+
asLayer: () => asLayer,
|
|
11
|
+
atom: () => atom,
|
|
12
|
+
atomByModule: () => atomByModule,
|
|
13
|
+
contributes: () => contributes,
|
|
14
|
+
get: () => get,
|
|
15
|
+
getAll: () => getAll,
|
|
16
|
+
getModuleTag: () => getModuleTag,
|
|
17
|
+
getOption: () => getOption,
|
|
18
|
+
layerWith: () => layerWith,
|
|
19
|
+
lazy: () => lazy,
|
|
20
|
+
make: () => make,
|
|
21
|
+
makeModule: () => makeModule,
|
|
22
|
+
waitFor: () => waitFor
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Effect Context.Tag for accessing CapabilityManager via the Effect layer system.
|
|
26
|
+
* This allows capability modules to access the capability manager without having it passed as an argument.
|
|
27
|
+
*/
|
|
28
|
+
var Service = class extends Context.Tag("@dxos/app-framework/CapabilityManager")() {};
|
|
29
|
+
/**
|
|
30
|
+
* Get a single capability from the capability manager.
|
|
31
|
+
* @param interfaceDef The interface definition of the capability.
|
|
32
|
+
* @returns The capability implementation.
|
|
33
|
+
* @throws If no capability is found.
|
|
34
|
+
*/
|
|
35
|
+
var get = (interfaceDef) => Effect.flatMap(Service, (manager) => Effect.try({
|
|
36
|
+
try: () => manager.get(interfaceDef),
|
|
37
|
+
catch: (error) => error instanceof Error ? error : new Error(String(error))
|
|
38
|
+
}));
|
|
39
|
+
/**
|
|
40
|
+
* Get all capabilities from the capability manager for a given interface.
|
|
41
|
+
* @param interfaceDef The interface definition of the capability.
|
|
42
|
+
* @returns An array of capability implementations.
|
|
43
|
+
*/
|
|
44
|
+
var getAll = (interfaceDef) => Effect.map(Service, (manager) => manager.getAll(interfaceDef));
|
|
45
|
+
/**
|
|
46
|
+
* Get a single capability from the capability manager, if one is contributed.
|
|
47
|
+
* Never fails — use this over {@link get} when the capability's absence (e.g. an optional plugin
|
|
48
|
+
* isn't loaded) is a legitimate case to handle rather than an error.
|
|
49
|
+
* @param interfaceDef The interface definition of the capability.
|
|
50
|
+
* @returns The first capability implementation, or `Option.none()` if none is contributed.
|
|
51
|
+
*/
|
|
52
|
+
var getOption = (interfaceDef) => Effect.map(getAll(interfaceDef), (all) => Option.fromNullable(all[0]));
|
|
53
|
+
/**
|
|
54
|
+
* Wait for a capability to be available.
|
|
55
|
+
* @param interfaceDef The interface definition of the capability.
|
|
56
|
+
* @returns The capability implementation once available.
|
|
57
|
+
*/
|
|
58
|
+
var waitFor = (interfaceDef) => Effect.flatMap(Service, (manager) => manager.waitFor(interfaceDef));
|
|
59
|
+
/**
|
|
60
|
+
* Get the Atom reference to capabilities for reactive access.
|
|
61
|
+
* @param interfaceDef The interface definition of the capability.
|
|
62
|
+
* @returns An Atom containing the array of capability implementations.
|
|
63
|
+
*/
|
|
64
|
+
var atom = (interfaceDef) => Effect.map(Service, (manager) => manager.atom(interfaceDef));
|
|
65
|
+
/**
|
|
66
|
+
* Get capabilities grouped by the module that contributed them.
|
|
67
|
+
* @param interfaceDef The interface definition of the capability.
|
|
68
|
+
* @returns An Atom containing a record from module ID to capability implementations.
|
|
69
|
+
*/
|
|
70
|
+
var atomByModule = (interfaceDef) => Effect.map(Service, (manager) => manager.atomByModule(interfaceDef));
|
|
71
|
+
/**
|
|
72
|
+
* Constructs a layer that will request its interface implementation from the capability manager.
|
|
73
|
+
*/
|
|
74
|
+
var asLayer = (interfaceDef, tag) => Layer.effect(tag, get(interfaceDef).pipe(Effect.orDie));
|
|
75
|
+
/**
|
|
76
|
+
* Constructs a layer from a capability by resolving it from the capability manager and passing the
|
|
77
|
+
* value to `build`. Lets a consumer depend on a canonical service (e.g. `Identity.Service`) and
|
|
78
|
+
* have it provided from a capability without the consumer referencing the capability system:
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* effect.pipe(
|
|
82
|
+
* Effect.provide(Capability.layerWith(ClientCapabilities.IdentityService, (service) =>
|
|
83
|
+
* Layer.succeed(Identity.Service, service),
|
|
84
|
+
* )),
|
|
85
|
+
* );
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
var layerWith = (interfaceDef, build) => Layer.unwrapEffect(get(interfaceDef).pipe(Effect.orDie, Effect.map(build)));
|
|
89
|
+
/**
|
|
90
|
+
* Symbol used to tag lazy capability functions with their module ID.
|
|
91
|
+
*/
|
|
92
|
+
var ModuleTag = Symbol.for("@dxos/app-framework/ModuleTag");
|
|
93
|
+
/**
|
|
94
|
+
* Helper to define the interface of a capability.
|
|
95
|
+
* Static NSID strings are validated at compile time via {@link DXN.Name}.
|
|
96
|
+
*/
|
|
97
|
+
var make = (identifier) => {
|
|
98
|
+
return { identifier };
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Helper to define the implementation of a capability.
|
|
102
|
+
* Returns the opaque base type so callers cannot discriminate on capability kind,
|
|
103
|
+
* keeping d.ts emit portable across packages.
|
|
104
|
+
*/
|
|
105
|
+
var contributes = (interfaceDef, implementation, deactivate) => {
|
|
106
|
+
return {
|
|
107
|
+
interface: interfaceDef,
|
|
108
|
+
implementation,
|
|
109
|
+
deactivate
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Helper to define a lazily loaded implementation of a capability.
|
|
114
|
+
* Supports single capabilities, arrays, and tuples of different capability types.
|
|
115
|
+
* @param name The export name (e.g., 'AppGraphBuilder') - used to auto-compute module IDs.
|
|
116
|
+
* @param loader The lazy loader function.
|
|
117
|
+
* @returns A lazy capability function with ModuleTag symbol attached.
|
|
118
|
+
*/
|
|
119
|
+
var lazy = (name, c) => {
|
|
120
|
+
const lazyFn = (props) => Effect.gen(function* () {
|
|
121
|
+
const { default: getCapability } = yield* Effect.promise(() => c());
|
|
122
|
+
const result = yield* getCapability(props);
|
|
123
|
+
return result == null ? [] : Array.isArray(result) ? Array.from(result) : [result];
|
|
124
|
+
});
|
|
125
|
+
return Object.assign(lazyFn, { [ModuleTag]: name });
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Gets the module tag (export name) from a lazy capability function.
|
|
129
|
+
* @param capability The lazy capability function.
|
|
130
|
+
* @returns The module tag if present, undefined otherwise.
|
|
131
|
+
*/
|
|
132
|
+
var getModuleTag = (capability) => {
|
|
133
|
+
return capability && typeof capability === "function" && ModuleTag in capability ? String(capability[ModuleTag]) : void 0;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Helper to define a capability module with explicit typing.
|
|
137
|
+
* Wraps the default export function to provide better type inference and make the pattern explicit.
|
|
138
|
+
*
|
|
139
|
+
* This helper provides explicit typing for the module activation function,
|
|
140
|
+
* making it clear that the function should:
|
|
141
|
+
* - Access CapabilityManager via the Effect layer system (Capability.get, Capability.getAll, etc.)
|
|
142
|
+
* - Return a capability, array of capabilities, or tuple of different capability types (sync or async)
|
|
143
|
+
*
|
|
144
|
+
* Supports returning multiple capabilities of different types as a tuple, which will be normalized
|
|
145
|
+
* to an array at runtime for compatibility with the plugin system.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* // Module without options - single capability
|
|
150
|
+
* export default Capability.makeModule(
|
|
151
|
+
* Effect.fnUntraced(function* () {
|
|
152
|
+
* const client = yield* Capability.get(ClientCapabilities.Client);
|
|
153
|
+
* return contributes(Capabilities.SettingsStore, store);
|
|
154
|
+
* })
|
|
155
|
+
* );
|
|
156
|
+
*
|
|
157
|
+
* // Module with multiple capabilities
|
|
158
|
+
* export default Capability.makeModule(
|
|
159
|
+
* Effect.fnUntraced(function* () {
|
|
160
|
+
* return [
|
|
161
|
+
* contributes(Capabilities.SettingsStore, store),
|
|
162
|
+
* contributes(Capabilities.Translations, translations),
|
|
163
|
+
* ];
|
|
164
|
+
* })
|
|
165
|
+
* );
|
|
166
|
+
*
|
|
167
|
+
* // Module with required options (context accessed via layer)
|
|
168
|
+
* export default Capability.makeModule(
|
|
169
|
+
* Effect.fnUntraced(function* (props: { observability: boolean }) {
|
|
170
|
+
* const invoker = yield* Capability.get(Capabilities.OperationInvoker);
|
|
171
|
+
* return contributes(Capabilities.OperationHandler, ...);
|
|
172
|
+
* })
|
|
173
|
+
* );
|
|
174
|
+
*
|
|
175
|
+
* // Module with scoped resources (closed automatically on deactivation)
|
|
176
|
+
* export default Capability.makeModule(
|
|
177
|
+
* Effect.fnUntraced(function* () {
|
|
178
|
+
* const scope = yield* Scope.Scope;
|
|
179
|
+
* yield* Scope.addFinalizer(scope, Effect.sync(() => cleanup()));
|
|
180
|
+
* return contributes(Capabilities.MyCapability, implementation);
|
|
181
|
+
* })
|
|
182
|
+
* );
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
var makeModule = (fn) => fn;
|
|
186
|
+
//#endregion
|
|
187
|
+
export { ModuleTag, Service, asLayer, atom, atomByModule, contributes, get, getAll, getModuleTag, getOption, layerWith, lazy, make, makeModule, capability_exports as t, waitFor };
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=capability.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability.mjs","names":[],"sources":["../../../src/core/capability.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom } from '@effect-atom/atom';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\nimport type * as Scope from 'effect/Scope';\n\nimport type { DXN } from '@dxos/keys';\n\nimport type * as CapabilityManager from './capability-manager';\nimport type * as Plugin from './plugin';\n\n//\n// Capability Service Layer\n//\n\n/**\n * Effect Context.Tag for accessing CapabilityManager via the Effect layer system.\n * This allows capability modules to access the capability manager without having it passed as an argument.\n */\nexport class Service extends Context.Tag('@dxos/app-framework/CapabilityManager')<\n Service,\n CapabilityManager.CapabilityManager\n>() {}\n\n/**\n * Get a single capability from the capability manager.\n * @param interfaceDef The interface definition of the capability.\n * @returns The capability implementation.\n * @throws If no capability is found.\n */\n// TODO(wittjosiah): Add custom tagged errors (Data.TaggedError) for app-framework to enable\n// type-safe error handling with Effect. Consider CapabilityNotFoundError, ModuleActivationError, etc.\nexport const get = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T, Error, Service> =>\n Effect.flatMap(Service, (manager) =>\n Effect.try({\n try: () => manager.get(interfaceDef),\n catch: (error) => (error instanceof Error ? error : new Error(String(error))),\n }),\n );\n\n/**\n * Get all capabilities from the capability manager for a given interface.\n * @param interfaceDef The interface definition of the capability.\n * @returns An array of capability implementations.\n */\nexport const getAll = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T[], never, Service> =>\n Effect.map(Service, (manager) => manager.getAll(interfaceDef));\n\n/**\n * Get a single capability from the capability manager, if one is contributed.\n * Never fails — use this over {@link get} when the capability's absence (e.g. an optional plugin\n * isn't loaded) is a legitimate case to handle rather than an error.\n * @param interfaceDef The interface definition of the capability.\n * @returns The first capability implementation, or `Option.none()` if none is contributed.\n */\nexport const getOption = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<Option.Option<T>, never, Service> =>\n Effect.map(getAll(interfaceDef), (all) => Option.fromNullable(all[0]));\n\n/**\n * Wait for a capability to be available.\n * @param interfaceDef The interface definition of the capability.\n * @returns The capability implementation once available.\n */\nexport const waitFor = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.waitFor(interfaceDef));\n\n/**\n * Get the Atom reference to capabilities for reactive access.\n * @param interfaceDef The interface definition of the capability.\n * @returns An Atom containing the array of capability implementations.\n */\nexport const atom = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<Atom.Atom<T[]>, never, Service> =>\n Effect.map(Service, (manager) => manager.atom(interfaceDef));\n\n/**\n * Get capabilities grouped by the module that contributed them.\n * @param interfaceDef The interface definition of the capability.\n * @returns An Atom containing a record from module ID to capability implementations.\n */\nexport const atomByModule = <T>(\n interfaceDef: InterfaceDef<T>,\n): Effect.Effect<Atom.Atom<Record<string, T[]>>, never, Service> =>\n Effect.map(Service, (manager) => manager.atomByModule(interfaceDef));\n\n/**\n * Constructs a layer that will request its interface implementation from the capability manager.\n */\nexport const asLayer = <T, I>(interfaceDef: InterfaceDef<T>, tag: Context.Tag<I, T>): Layer.Layer<I, never, Service> =>\n Layer.effect(tag, get(interfaceDef).pipe(Effect.orDie));\n\n/**\n * Constructs a layer from a capability by resolving it from the capability manager and passing the\n * value to `build`. Lets a consumer depend on a canonical service (e.g. `Identity.Service`) and\n * have it provided from a capability without the consumer referencing the capability system:\n *\n * ```ts\n * effect.pipe(\n * Effect.provide(Capability.layerWith(ClientCapabilities.IdentityService, (service) =>\n * Layer.succeed(Identity.Service, service),\n * )),\n * );\n * ```\n */\nexport const layerWith = <T, A, E, R>(\n interfaceDef: InterfaceDef<T>,\n build: (value: T) => Layer.Layer<A, E, R>,\n): Layer.Layer<A, E, R | Service> => Layer.unwrapEffect(get(interfaceDef).pipe(Effect.orDie, Effect.map(build)));\n\nconst InterfaceDefTypeId: unique symbol = Symbol.for('InterfaceDefTypeId');\n\n/**\n * Symbol used to tag lazy capability functions with their module ID.\n */\nexport const ModuleTag: unique symbol = Symbol.for('@dxos/app-framework/ModuleTag');\n\n/**\n * The interface definition of a capability.\n */\nexport type InterfaceDef<T> = {\n [InterfaceDefTypeId]: T;\n identifier: string;\n};\n\nexport namespace InterfaceDef {\n export type Implementation<I extends InterfaceDef<any>> = I extends InterfaceDef<infer T> ? T : never;\n}\n\n/**\n * Helper to define the interface of a capability.\n * Static NSID strings are validated at compile time via {@link DXN.Name}.\n */\nexport const make: {\n <T, S extends string = string>(\n identifier: [DXN.Name<S>] extends [never] ? `Invalid NSID \"${S}\": final segment must be camelCase (no hyphens)` : S,\n ): InterfaceDef<T>;\n} = <T>(identifier: string): InterfaceDef<T> => {\n return { identifier } as InterfaceDef<T>;\n};\n\n/**\n * A unique string identifier with a Typescript type associated with it.\n * When a capability is contributed to the application an implementation of the interface is provided.\n */\nexport type Capability<T> = {\n /**\n * The interface definition of the capability.\n */\n readonly interface: InterfaceDef<T>;\n\n /**\n * The implementation of the capability.\n */\n readonly implementation: T;\n\n /**\n * Called when the capability is deactivated.\n */\n readonly deactivate?: () => Effect.Effect<void, Error>;\n};\n\nexport type Any = Capability<any>;\n\n/**\n * Union type representing all valid return types for a capability module.\n * Supports single capabilities, arrays, and tuples of different capability types.\n */\nexport type ModuleReturn = void | Any | Any[] | readonly Any[] | [Any, ...Any[]] | readonly [Any, ...Any[]];\n\n/**\n * Helper to define the implementation of a capability.\n * Returns the opaque base type so callers cannot discriminate on capability kind,\n * keeping d.ts emit portable across packages.\n */\nexport const contributes = <I extends InterfaceDef<any>>(\n interfaceDef: I,\n implementation: Capability<InterfaceDef.Implementation<I>>['implementation'],\n deactivate?: Capability<InterfaceDef.Implementation<I>>['deactivate'],\n): Any => {\n return {\n interface: interfaceDef,\n implementation,\n deactivate,\n } satisfies Capability<I>;\n};\n\ntype LoadCapability<Props, Capabilities extends ModuleReturn = ModuleReturn> = () => Promise<{\n default: (props: Props) => Effect.Effect<Capabilities, Error, Service | Plugin.Service | Scope.Scope | never>;\n}>;\ntype LoadCapabilities<Props, Capabilities extends ModuleReturn = ModuleReturn> = () => Promise<{\n default: (props: Props) => Effect.Effect<Capabilities, Error, Service | Plugin.Service | Scope.Scope | never>;\n}>;\n\ntype NormalizeReturn<R> = R extends readonly (infer A)[]\n ? A[]\n : R extends (infer A)[]\n ? A[]\n : R extends Any\n ? [R]\n : Any[];\n\nexport type LazyCapability<Props = void, Capabilities extends ModuleReturn = ModuleReturn, E extends Error = Error> = (\n props: Props,\n) => Effect.Effect<NormalizeReturn<Capabilities>, E, Service | Plugin.Service | Scope.Scope | never>;\n\n/**\n * Helper to define a lazily loaded implementation of a capability.\n * Supports single capabilities, arrays, and tuples of different capability types.\n * @param name The export name (e.g., 'AppGraphBuilder') - used to auto-compute module IDs.\n * @param loader The lazy loader function.\n * @returns A lazy capability function with ModuleTag symbol attached.\n */\nexport const lazy = <T = void, R extends ModuleReturn = ModuleReturn>(\n name: string,\n c: LoadCapability<T, R> | LoadCapabilities<T, R>,\n): LazyCapability<T> => {\n const lazyFn = (props: T) =>\n Effect.gen(function* () {\n const { default: getCapability } = yield* Effect.promise(() => c());\n const result = yield* getCapability(props);\n const normalized = result == null ? [] : Array.isArray(result) ? Array.from(result) : [result];\n return normalized as NormalizeReturn<R>;\n });\n\n // Props (T) are preserved so callers pass correctly-typed options, but the contributed\n // Capabilities type is widened to the opaque base. The concrete capability type often traces to a\n // module-internal source path that TypeScript cannot name in declaration files (TS2883); the base\n // type is portable. The contributed type is checked at Capability.contributes regardless.\n return Object.assign(lazyFn, { [ModuleTag]: name }) as LazyCapability<T>;\n};\n\n/**\n * Gets the module tag (export name) from a lazy capability function.\n * @param capability The lazy capability function.\n * @returns The module tag if present, undefined otherwise.\n */\n// TODO(wittjosiah): Stricter type for capability.\nexport const getModuleTag = (capability: unknown): string | undefined => {\n return capability && typeof capability === 'function' && ModuleTag in capability\n ? String(capability[ModuleTag])\n : undefined;\n};\n\n/**\n * Helper to define a capability module with explicit typing.\n * Wraps the default export function to provide better type inference and make the pattern explicit.\n *\n * This helper provides explicit typing for the module activation function,\n * making it clear that the function should:\n * - Access CapabilityManager via the Effect layer system (Capability.get, Capability.getAll, etc.)\n * - Return a capability, array of capabilities, or tuple of different capability types (sync or async)\n *\n * Supports returning multiple capabilities of different types as a tuple, which will be normalized\n * to an array at runtime for compatibility with the plugin system.\n *\n * @example\n * ```ts\n * // Module without options - single capability\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* () {\n * const client = yield* Capability.get(ClientCapabilities.Client);\n * return contributes(Capabilities.SettingsStore, store);\n * })\n * );\n *\n * // Module with multiple capabilities\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* () {\n * return [\n * contributes(Capabilities.SettingsStore, store),\n * contributes(Capabilities.Translations, translations),\n * ];\n * })\n * );\n *\n * // Module with required options (context accessed via layer)\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* (props: { observability: boolean }) {\n * const invoker = yield* Capability.get(Capabilities.OperationInvoker);\n * return contributes(Capabilities.OperationHandler, ...);\n * })\n * );\n *\n * // Module with scoped resources (closed automatically on deactivation)\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* () {\n * const scope = yield* Scope.Scope;\n * yield* Scope.addFinalizer(scope, Effect.sync(() => cleanup()));\n * return contributes(Capabilities.MyCapability, implementation);\n * })\n * );\n * ```\n */\nexport const makeModule = <\n TProps = void,\n TReturn extends ModuleReturn = ModuleReturn,\n E extends Error = Error,\n R extends Service | Plugin.Service | never = Service,\n>(\n fn: (props: TProps) => Effect.Effect<TReturn, E, R | Scope.Scope>,\n): ((props: TProps) => Effect.Effect<TReturn, E, R | Scope.Scope>) => fn;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAa,UAAb,cAA6B,QAAQ,IAAI,uCAAuC,CAAC,CAG/E,CAAC,CAAC,CAAC;;;;;;;AAUL,IAAa,OAAU,iBACrB,OAAO,QAAQ,UAAU,YACvB,OAAO,IAAI;CACT,WAAW,QAAQ,IAAI,YAAY;CACnC,QAAQ,UAAW,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAC7E,CAAC,CACH;;;;;;AAOF,IAAa,UAAa,iBACxB,OAAO,IAAI,UAAU,YAAY,QAAQ,OAAO,YAAY,CAAC;;;;;;;;AAS/D,IAAa,aAAgB,iBAC3B,OAAO,IAAI,OAAO,YAAY,IAAI,QAAQ,OAAO,aAAa,IAAI,EAAE,CAAC;;;;;;AAOvE,IAAa,WAAc,iBACzB,OAAO,QAAQ,UAAU,YAAY,QAAQ,QAAQ,YAAY,CAAC;;;;;;AAOpE,IAAa,QAAW,iBACtB,OAAO,IAAI,UAAU,YAAY,QAAQ,KAAK,YAAY,CAAC;;;;;;AAO7D,IAAa,gBACX,iBAEA,OAAO,IAAI,UAAU,YAAY,QAAQ,aAAa,YAAY,CAAC;;;;AAKrE,IAAa,WAAiB,cAA+B,QAC3D,MAAM,OAAO,KAAK,IAAI,YAAY,CAAC,CAAC,KAAK,OAAO,KAAK,CAAC;;;;;;;;;;;;;;AAexD,IAAa,aACX,cACA,UACmC,MAAM,aAAa,IAAI,YAAY,CAAC,CAAC,KAAK,OAAO,OAAO,OAAO,IAAI,KAAK,CAAC,CAAC;;;;AAO/G,IAAa,YAA2B,OAAO,IAAI,+BAA+B;;;;;AAkBlF,IAAa,QAIL,eAAwC;CAC9C,OAAO,EAAE,WAAW;AACtB;;;;;;AAoCA,IAAa,eACX,cACA,gBACA,eACQ;CACR,OAAO;EACL,WAAW;EACX;EACA;CACF;AACF;;;;;;;;AA4BA,IAAa,QACX,MACA,MACsB;CACtB,MAAM,UAAU,UACd,OAAO,IAAI,aAAa;EACtB,MAAM,EAAE,SAAS,kBAAkB,OAAO,OAAO,cAAc,EAAE,CAAC;EAClE,MAAM,SAAS,OAAO,cAAc,KAAK;EAEzC,OADmB,UAAU,OAAO,CAAC,IAAI,MAAM,QAAQ,MAAM,IAAI,MAAM,KAAK,MAAM,IAAI,CAAC,MAAM;CAE/F,CAAC;CAMH,OAAO,OAAO,OAAO,QAAQ,GAAG,YAAY,KAAK,CAAC;AACpD;;;;;;AAQA,IAAa,gBAAgB,eAA4C;CACvE,OAAO,cAAc,OAAO,eAAe,cAAc,aAAa,aAClE,OAAO,WAAW,UAAU,IAC5B,KAAA;AACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAa,cAMX,OACoE"}
|