@dxos/app-framework 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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-6E7NCZ77.mjs → app-graph-builder-576BHZC7.mjs} +23 -23
- package/dist/lib/browser/app-graph-builder-576BHZC7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2KSDY3EZ.mjs → chunk-6AVTZPMT.mjs} +267 -325
- package/dist/lib/browser/chunk-6AVTZPMT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K3HOLGVH.mjs → chunk-PPIBZ5N4.mjs} +28 -40
- package/dist/lib/browser/chunk-PPIBZ5N4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KPRHX73H.mjs → chunk-SFPT4Z2C.mjs} +9 -9
- package/dist/lib/browser/chunk-SFPT4Z2C.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -10
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/{intent-dispatcher-VGUJBPPN.mjs → intent-dispatcher-3Q67MHZZ.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-QLFZY5R5.mjs → intent-resolver-O763LCLG.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{store-QGVXOY4T.mjs → store-URSN7DZI.mjs} +6 -7
- package/dist/lib/browser/store-URSN7DZI.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +3 -7
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/worker.mjs +3 -5
- package/dist/lib/node/app-graph-builder-JZCSKYPY.cjs +146 -0
- package/dist/lib/node/app-graph-builder-JZCSKYPY.cjs.map +7 -0
- package/dist/lib/node/{chunk-JQMNABMK.cjs → chunk-JUSEAFDU.cjs} +4 -4
- package/dist/lib/node/chunk-JUSEAFDU.cjs.map +7 -0
- package/dist/lib/node/{chunk-2EBZ2ICH.cjs → chunk-YIFTVCOR.cjs} +247 -304
- package/dist/lib/node/chunk-YIFTVCOR.cjs.map +7 -0
- package/dist/lib/node/{chunk-7J66KH2T.cjs → chunk-YNTKVTVX.cjs} +67 -79
- package/dist/lib/node/chunk-YNTKVTVX.cjs.map +7 -0
- package/dist/lib/node/index.cjs +79 -81
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/{intent-dispatcher-TASJBG5M.cjs → intent-dispatcher-H334XLFD.cjs} +8 -8
- package/dist/lib/node/{intent-dispatcher-TASJBG5M.cjs.map → intent-dispatcher-H334XLFD.cjs.map} +2 -2
- package/dist/lib/node/{intent-resolver-5CG5NIJY.cjs → intent-resolver-3F4POWAM.cjs} +12 -12
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{store-IF3UR2KA.cjs → store-OFDHTDCB.cjs} +9 -10
- package/dist/lib/node/store-OFDHTDCB.cjs.map +7 -0
- package/dist/lib/node/testing/index.cjs +9 -14
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node/worker.cjs +38 -40
- package/dist/lib/node/worker.cjs.map +2 -2
- package/dist/lib/node-esm/{app-graph-builder-LYCG5CO3.mjs → app-graph-builder-VYKLSMSZ.mjs} +23 -23
- package/dist/lib/node-esm/app-graph-builder-VYKLSMSZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BOEJMAVK.mjs → chunk-AHKIPS2L.mjs} +267 -325
- package/dist/lib/node-esm/chunk-AHKIPS2L.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JUJF5L4G.mjs → chunk-PHOUQACM.mjs} +9 -9
- package/dist/lib/node-esm/chunk-PHOUQACM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ISNBS46Y.mjs → chunk-R6A7Z4LU.mjs} +28 -40
- package/dist/lib/node-esm/chunk-R6A7Z4LU.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +8 -10
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/{intent-dispatcher-ZUSNX2OY.mjs → intent-dispatcher-YDE2ONZA.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-NGDHUKDD.mjs → intent-resolver-LAGJ7LXM.mjs} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{store-NCRSE25X.mjs → store-EYSUVNCS.mjs} +6 -7
- package/dist/lib/node-esm/store-EYSUVNCS.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +3 -7
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/worker.mjs +3 -5
- package/dist/types/src/App.d.ts +1 -3
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/common/capabilities.d.ts +196 -6
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/events.d.ts.map +1 -1
- package/dist/types/src/common/file.d.ts +7 -7
- package/dist/types/src/common/file.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +0 -1
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/layout.d.ts +158 -164
- package/dist/types/src/common/layout.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts.map +1 -1
- package/dist/types/src/common/translations.d.ts +7 -7
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/core/capabilities.d.ts +15 -33
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/events.d.ts +1 -4
- package/dist/types/src/core/events.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts +11 -14
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +3 -4
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -1
- package/dist/types/src/playground/logger/schema.d.ts +6 -6
- package/dist/types/src/playground/logger/schema.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/actions.d.ts +14 -14
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +3 -29
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts +20 -14
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/actions.d.ts +10 -10
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +195 -2
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/store.d.ts +2 -2
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -1
- package/dist/types/src/react/IntentContext.d.ts.map +1 -1
- package/dist/types/src/react/Surface.d.ts +2 -2
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/useCapabilities.d.ts +2 -2
- package/dist/types/src/react/useCapabilities.d.ts.map +1 -1
- package/dist/types/src/react/useIntentResolver.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.d.ts +2 -5
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -29
- package/project.json +1 -2
- package/src/App.tsx +4 -16
- package/src/common/capabilities.ts +4 -7
- package/src/common/file.ts +7 -7
- package/src/common/index.ts +0 -1
- package/src/common/layout.ts +128 -159
- package/src/common/translations.ts +7 -7
- package/src/core/capabilities.test.ts +36 -55
- package/src/core/capabilities.ts +58 -82
- package/src/core/events.ts +1 -4
- package/src/core/manager.test.ts +22 -22
- package/src/core/manager.ts +16 -24
- package/src/core/plugin.ts +3 -4
- package/src/playground/generator/generator.ts +4 -4
- package/src/playground/logger/schema.ts +5 -5
- package/src/playground/playground.stories.tsx +1 -1
- package/src/plugin-intent/actions.ts +9 -9
- package/src/plugin-intent/intent-dispatcher.test.ts +42 -23
- package/src/plugin-intent/intent-dispatcher.ts +13 -25
- package/src/plugin-intent/intent.ts +20 -22
- package/src/plugin-settings/actions.ts +8 -8
- package/src/plugin-settings/app-graph-builder.ts +94 -129
- package/src/plugin-settings/store.ts +17 -20
- package/src/react/Surface.stories.tsx +1 -1
- package/src/react/Surface.tsx +3 -3
- package/src/react/useCapabilities.ts +19 -9
- package/src/testing/withPluginManager.stories.tsx +1 -0
- package/src/testing/withPluginManager.tsx +3 -11
- package/tsconfig.json +0 -3
- package/dist/lib/browser/app-graph-builder-6E7NCZ77.mjs.map +0 -7
- package/dist/lib/browser/chunk-2KSDY3EZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-K3HOLGVH.mjs.map +0 -7
- package/dist/lib/browser/chunk-KPRHX73H.mjs.map +0 -7
- package/dist/lib/browser/store-QGVXOY4T.mjs.map +0 -7
- package/dist/lib/node/app-graph-builder-4IWMG67O.cjs +0 -146
- package/dist/lib/node/app-graph-builder-4IWMG67O.cjs.map +0 -7
- package/dist/lib/node/chunk-2EBZ2ICH.cjs.map +0 -7
- package/dist/lib/node/chunk-7J66KH2T.cjs.map +0 -7
- package/dist/lib/node/chunk-JQMNABMK.cjs.map +0 -7
- package/dist/lib/node/store-IF3UR2KA.cjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-LYCG5CO3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BOEJMAVK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ISNBS46Y.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JUJF5L4G.mjs.map +0 -7
- package/dist/lib/node-esm/store-NCRSE25X.mjs.map +0 -7
- package/dist/types/src/common/collaboration.d.ts +0 -26
- package/dist/types/src/common/collaboration.d.ts.map +0 -1
- package/src/common/collaboration.ts +0 -24
- package/typedoc/.nojekyll +0 -1
- package/typedoc/assets/hierarchy.js +0 -1
- package/typedoc/assets/highlight.css +0 -106
- package/typedoc/assets/icons.js +0 -18
- package/typedoc/assets/icons.svg +0 -1
- package/typedoc/assets/main.js +0 -60
- package/typedoc/assets/navigation.js +0 -1
- package/typedoc/assets/search.js +0 -1
- package/typedoc/assets/style.css +0 -1640
- package/typedoc/classes/CollaborationActions.InsertContent.html +0 -460
- package/typedoc/classes/ErrorBoundary.html +0 -125
- package/typedoc/classes/IntentAction.ShowUndo.html +0 -227
- package/typedoc/classes/IntentAction.Track.html +0 -266
- package/typedoc/classes/LayoutAction.AddToast.html +0 -265
- package/typedoc/classes/LayoutAction.Close.html +0 -382
- package/typedoc/classes/LayoutAction.Expose.html +0 -265
- package/typedoc/classes/LayoutAction.Open.html +0 -1123
- package/typedoc/classes/LayoutAction.RevertWorkspace.html +0 -343
- package/typedoc/classes/LayoutAction.ScrollIntoView.html +0 -460
- package/typedoc/classes/LayoutAction.Set.html +0 -460
- package/typedoc/classes/LayoutAction.SetLayoutMode.html +0 -499
- package/typedoc/classes/LayoutAction.SwitchWorkspace.html +0 -265
- package/typedoc/classes/LayoutAction.UpdateComplementary.html +0 -616
- package/typedoc/classes/LayoutAction.UpdateDialog.html +0 -811
- package/typedoc/classes/LayoutAction.UpdateLayout.html +0 -461
- package/typedoc/classes/LayoutAction.UpdatePopover.html +0 -1435
- package/typedoc/classes/LayoutAction.UpdateSidebar.html +0 -616
- package/typedoc/classes/Plugin.html +0 -6
- package/typedoc/classes/PluginContext.html +0 -38
- package/typedoc/classes/PluginManager.html +0 -43
- package/typedoc/classes/PluginModule.html +0 -18
- package/typedoc/classes/SettingsAction.Open.html +0 -226
- package/typedoc/classes/SettingsAction.OpenPluginRegistry.html +0 -265
- package/typedoc/functions/Events.createStateEvent.html +0 -2
- package/typedoc/functions/IntentPlugin.html +0 -1
- package/typedoc/functions/SettingsPlugin.html +0 -1
- package/typedoc/functions/allOf.html +0 -2
- package/typedoc/functions/chain.html +0 -3
- package/typedoc/functions/contributes.html +0 -2
- package/typedoc/functions/createApp.html +0 -6
- package/typedoc/functions/createDispatcher.html +0 -3
- package/typedoc/functions/createIntent.html +0 -6
- package/typedoc/functions/createResolver.html +0 -2
- package/typedoc/functions/createSurface.html +0 -2
- package/typedoc/functions/defineCapability.html +0 -2
- package/typedoc/functions/defineEvent.html +0 -2
- package/typedoc/functions/defineModule.html +0 -2
- package/typedoc/functions/definePlugin.html +0 -2
- package/typedoc/functions/eventKey.html +0 -2
- package/typedoc/functions/getEvents.html +0 -2
- package/typedoc/functions/isAllOf.html +0 -2
- package/typedoc/functions/isOneOf.html +0 -2
- package/typedoc/functions/isSurfaceAvailable.html +0 -2
- package/typedoc/functions/lazy.html +0 -2
- package/typedoc/functions/oneOf.html +0 -2
- package/typedoc/functions/useAppGraph.html +0 -1
- package/typedoc/functions/useCapabilities.html +0 -3
- package/typedoc/functions/useCapability.html +0 -4
- package/typedoc/functions/useIntentDispatcher.html +0 -1
- package/typedoc/functions/useIntentResolver.html +0 -1
- package/typedoc/functions/useLayout.html +0 -1
- package/typedoc/functions/usePluginManager.html +0 -2
- package/typedoc/hierarchy.html +0 -1
- package/typedoc/index.html +0 -16
- package/typedoc/interfaces/LayoutAction.Toast.html +0 -10
- package/typedoc/media/LICENSE +0 -8
- package/typedoc/modules/Capabilities.html +0 -1
- package/typedoc/modules/CollaborationActions.html +0 -1
- package/typedoc/modules/Events.html +0 -1
- package/typedoc/modules/IntentAction.html +0 -1
- package/typedoc/modules/LayoutAction.html +0 -2
- package/typedoc/modules/SettingsAction.html +0 -1
- package/typedoc/modules.html +0 -1
- package/typedoc/types/ActivationEvent.html +0 -8
- package/typedoc/types/ActivationEvents.html +0 -2
- package/typedoc/types/AnyCapability.html +0 -1
- package/typedoc/types/AnyIntent.html +0 -1
- package/typedoc/types/AnyIntentChain.html +0 -1
- package/typedoc/types/AnyIntentEffectResult.html +0 -1
- package/typedoc/types/AnyIntentResolver.html +0 -1
- package/typedoc/types/AnyIntentResult.html +0 -1
- package/typedoc/types/Capabilities.FileUploader.html +0 -1
- package/typedoc/types/Capabilities.IntentResolver.html +0 -1
- package/typedoc/types/Capabilities.Layout.html +0 -1
- package/typedoc/types/Capabilities.Metadata.html +0 -1
- package/typedoc/types/Capabilities.ReactContext.html +0 -1
- package/typedoc/types/Capabilities.ReactRoot.html +0 -1
- package/typedoc/types/Capabilities.ReactSurface.html +0 -1
- package/typedoc/types/Capabilities.Settings.html +0 -4
- package/typedoc/types/Capability.html +0 -9
- package/typedoc/types/CreateAppOptions.html +0 -10
- package/typedoc/types/FileInfo.html +0 -1
- package/typedoc/types/Intent.html +0 -10
- package/typedoc/types/IntentChain.html +0 -6
- package/typedoc/types/IntentContext.html +0 -5
- package/typedoc/types/IntentData.html +0 -1
- package/typedoc/types/IntentDispatcher.html +0 -2
- package/typedoc/types/IntentDispatcherResult.html +0 -2
- package/typedoc/types/IntentEffectDefinition.html +0 -2
- package/typedoc/types/IntentEffectResult.html +0 -15
- package/typedoc/types/IntentParams.html +0 -3
- package/typedoc/types/IntentResolver.html +0 -2
- package/typedoc/types/IntentResultData.html +0 -1
- package/typedoc/types/IntentSchema.html +0 -1
- package/typedoc/types/IntentUndo.html +0 -2
- package/typedoc/types/InterfaceDef.html +0 -4
- package/typedoc/types/Label.html +0 -1
- package/typedoc/types/NodeSerializer.html +0 -8
- package/typedoc/types/PluginManagerOptions.html +0 -6
- package/typedoc/types/PluginMeta.html +0 -21
- package/typedoc/types/PromiseIntentDispatcher.html +0 -2
- package/typedoc/types/PromiseIntentUndo.html +0 -2
- package/typedoc/types/Resource.html +0 -1
- package/typedoc/types/ResourceKey.html +0 -1
- package/typedoc/types/ResourceLanguage.html +0 -1
- package/typedoc/types/SerializedNode.html +0 -4
- package/typedoc/types/SurfaceComponent.html +0 -2
- package/typedoc/types/SurfaceDefinition.html +0 -2
- package/typedoc/types/SurfaceProps.html +0 -4
- package/typedoc/variables/Capabilities.AppGraph.html +0 -1
- package/typedoc/variables/Capabilities.AppGraphBuilder.html +0 -1
- package/typedoc/variables/Capabilities.AppGraphSerializer.html +0 -1
- package/typedoc/variables/Capabilities.ArtifactDefinition.html +0 -1
- package/typedoc/variables/Capabilities.FileUploader.html +0 -1
- package/typedoc/variables/Capabilities.IntentDispatcher.html +0 -1
- package/typedoc/variables/Capabilities.IntentResolver.html +0 -1
- package/typedoc/variables/Capabilities.Layout.html +0 -1
- package/typedoc/variables/Capabilities.Metadata.html +0 -1
- package/typedoc/variables/Capabilities.Null.html +0 -1
- package/typedoc/variables/Capabilities.PluginManager.html +0 -1
- package/typedoc/variables/Capabilities.ReactContext.html +0 -1
- package/typedoc/variables/Capabilities.ReactRoot.html +0 -1
- package/typedoc/variables/Capabilities.ReactSurface.html +0 -1
- package/typedoc/variables/Capabilities.RxRegistry.html +0 -1
- package/typedoc/variables/Capabilities.Settings.html +0 -1
- package/typedoc/variables/Capabilities.SettingsStore.html +0 -1
- package/typedoc/variables/Capabilities.Tools.html +0 -1
- package/typedoc/variables/Capabilities.Translations.html +0 -1
- package/typedoc/variables/Events.AppGraphReady.html +0 -2
- package/typedoc/variables/Events.DispatcherReady.html +0 -2
- package/typedoc/variables/Events.LayoutReady.html +0 -1
- package/typedoc/variables/Events.SettingsReady.html +0 -2
- package/typedoc/variables/Events.SetupAppGraph.html +0 -2
- package/typedoc/variables/Events.SetupArtifactDefinition.html +0 -2
- package/typedoc/variables/Events.SetupIntentResolver.html +0 -2
- package/typedoc/variables/Events.SetupMetadata.html +0 -2
- package/typedoc/variables/Events.SetupReactSurface.html +0 -2
- package/typedoc/variables/Events.SetupSettings.html +0 -2
- package/typedoc/variables/Events.SetupTranslations.html +0 -2
- package/typedoc/variables/Events.Startup.html +0 -2
- package/typedoc/variables/FileInfoSchema.html +0 -1
- package/typedoc/variables/INTENT_ACTION.html +0 -1
- package/typedoc/variables/INTENT_PLUGIN.html +0 -1
- package/typedoc/variables/LAYOUT_ACTION.html +0 -1
- package/typedoc/variables/LAYOUT_PLUGIN.html +0 -1
- package/typedoc/variables/Label.html +0 -1
- package/typedoc/variables/LayoutAction.Toast.html +0 -1
- package/typedoc/variables/LayoutAction.UPDATE_LAYOUT.html +0 -1
- package/typedoc/variables/PluginManagerProvider.html +0 -2
- package/typedoc/variables/Resource.html +0 -2
- package/typedoc/variables/ResourceKey.html +0 -1
- package/typedoc/variables/ResourceLanguage.html +0 -1
- package/typedoc/variables/SETTINGS_ACTION.html +0 -1
- package/typedoc/variables/SETTINGS_ID.html +0 -1
- package/typedoc/variables/SETTINGS_KEY.html +0 -1
- package/typedoc/variables/SETTINGS_PLUGIN.html +0 -1
- package/typedoc/variables/Surface.html +0 -2
- package/typedoc/variables/defaultFileTypes.html +0 -1
- /package/dist/lib/browser/{intent-dispatcher-VGUJBPPN.mjs.map → intent-dispatcher-3Q67MHZZ.mjs.map} +0 -0
- /package/dist/lib/browser/{intent-resolver-QLFZY5R5.mjs.map → intent-resolver-O763LCLG.mjs.map} +0 -0
- /package/dist/lib/node/{intent-resolver-5CG5NIJY.cjs.map → intent-resolver-3F4POWAM.cjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-ZUSNX2OY.mjs.map → intent-dispatcher-YDE2ONZA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-NGDHUKDD.mjs.map → intent-resolver-LAGJ7LXM.mjs.map} +0 -0
package/src/core/capabilities.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface definition for a capability.
|
|
3
|
+
*/
|
|
1
4
|
//
|
|
2
5
|
// Copyright 2025 DXOS.org
|
|
3
6
|
//
|
|
4
7
|
|
|
5
|
-
import {
|
|
8
|
+
import { effect, untracked } from '@preact/signals-core';
|
|
6
9
|
import { Effect } from 'effect';
|
|
7
10
|
|
|
8
11
|
import { Trigger } from '@dxos/async';
|
|
9
12
|
import { invariant } from '@dxos/invariant';
|
|
13
|
+
import { create } from '@dxos/live-object';
|
|
10
14
|
import { log } from '@dxos/log';
|
|
11
15
|
import { type MaybePromise } from '@dxos/util';
|
|
12
16
|
|
|
@@ -30,8 +34,7 @@ export const defineCapability = <T>(identifier: string) => {
|
|
|
30
34
|
};
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
|
-
*
|
|
34
|
-
* When a capability is contributed to the application an implementation of the interface is provided.
|
|
37
|
+
* Functionality contributed to the application by a plugin module.
|
|
35
38
|
*/
|
|
36
39
|
export type Capability<T> = {
|
|
37
40
|
/**
|
|
@@ -53,7 +56,6 @@ export type Capability<T> = {
|
|
|
53
56
|
export type AnyCapability = Capability<any>;
|
|
54
57
|
|
|
55
58
|
type PluginsContextOptions = {
|
|
56
|
-
registry: Registry.Registry;
|
|
57
59
|
activate: (event: ActivationEvent) => Effect.Effect<boolean, Error>;
|
|
58
60
|
reset: (event: ActivationEvent) => Effect.Effect<boolean, Error>;
|
|
59
61
|
};
|
|
@@ -93,31 +95,10 @@ export const lazy =
|
|
|
93
95
|
};
|
|
94
96
|
|
|
95
97
|
/**
|
|
96
|
-
*
|
|
97
|
-
* It tracks the capabilities that are contributed in an in-memory live object.
|
|
98
|
-
* This allows the application to subscribe to this state and incorporate plugins which are added dynamically.
|
|
98
|
+
* Context which is passed to plugins, allowing them to interact with each other.
|
|
99
99
|
*/
|
|
100
|
-
export class
|
|
101
|
-
private readonly
|
|
102
|
-
|
|
103
|
-
private readonly _capabilityImpls = Rx.family<string, Rx.Writable<CapabilityImpl<unknown>[]>>(() => {
|
|
104
|
-
return Rx.make<CapabilityImpl<unknown>[]>([]).pipe(Rx.keepAlive);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
readonly _capabilities = Rx.family<string, Rx.Rx<unknown[]>>((id: string) => {
|
|
108
|
-
return Rx.make((get) => {
|
|
109
|
-
const current = get(this._capabilityImpls(id));
|
|
110
|
-
return current.map((c) => c.implementation);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
readonly _capability = Rx.family<string, Rx.Rx<unknown>>((id: string) => {
|
|
115
|
-
return Rx.make((get) => {
|
|
116
|
-
const current = get(this._capabilities(id));
|
|
117
|
-
invariant(current.length > 0, `No capability found for ${id}`);
|
|
118
|
-
return current[0];
|
|
119
|
-
});
|
|
120
|
-
});
|
|
100
|
+
export class PluginsContext {
|
|
101
|
+
private readonly _definedCapabilities = new Map<string, CapabilityImpl<unknown>[]>();
|
|
121
102
|
|
|
122
103
|
/**
|
|
123
104
|
* Activates plugins based on the activation event.
|
|
@@ -133,8 +114,7 @@ export class PluginContext {
|
|
|
133
114
|
*/
|
|
134
115
|
readonly reset: PluginsContextOptions['reset'];
|
|
135
116
|
|
|
136
|
-
constructor({
|
|
137
|
-
this._registry = registry;
|
|
117
|
+
constructor({ activate, reset }: PluginsContextOptions) {
|
|
138
118
|
this.activate = activate;
|
|
139
119
|
this.reset = reset;
|
|
140
120
|
}
|
|
@@ -151,17 +131,18 @@ export class PluginContext {
|
|
|
151
131
|
interface: InterfaceDef<T>;
|
|
152
132
|
implementation: T;
|
|
153
133
|
}) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
134
|
+
let current = this._definedCapabilities.get(interfaceDef.identifier);
|
|
135
|
+
if (!current) {
|
|
136
|
+
const object = create<{ value: CapabilityImpl<unknown>[] }>({ value: [] });
|
|
137
|
+
current = untracked(() => object.value);
|
|
138
|
+
this._definedCapabilities.set(interfaceDef.identifier, current);
|
|
158
139
|
}
|
|
159
140
|
|
|
160
|
-
|
|
141
|
+
current.push(new CapabilityImpl(moduleId, implementation));
|
|
161
142
|
log('capability contributed', {
|
|
162
143
|
id: interfaceDef.identifier,
|
|
163
144
|
moduleId,
|
|
164
|
-
count: current.length,
|
|
145
|
+
count: untracked(() => current.length),
|
|
165
146
|
});
|
|
166
147
|
}
|
|
167
148
|
|
|
@@ -169,79 +150,74 @@ export class PluginContext {
|
|
|
169
150
|
* @internal
|
|
170
151
|
*/
|
|
171
152
|
removeCapability<T>(interfaceDef: InterfaceDef<T>, implementation: T) {
|
|
172
|
-
const current = this.
|
|
173
|
-
if (current
|
|
153
|
+
const current = this._definedCapabilities.get(interfaceDef.identifier);
|
|
154
|
+
if (!current) {
|
|
174
155
|
return;
|
|
175
156
|
}
|
|
176
157
|
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
log('capability removed', { id: interfaceDef.identifier, count: current.length });
|
|
158
|
+
const index = current.findIndex((i) => i.implementation === implementation);
|
|
159
|
+
if (index !== -1) {
|
|
160
|
+
current.splice(index, 1);
|
|
161
|
+
log('capability removed', { id: interfaceDef.identifier, count: untracked(() => current.length) });
|
|
181
162
|
} else {
|
|
182
163
|
log.warn('capability not removed', { id: interfaceDef.identifier });
|
|
183
164
|
}
|
|
184
165
|
}
|
|
185
166
|
|
|
186
167
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* @returns An Rx reference to the available capabilities.
|
|
168
|
+
* Requests capabilities from the plugin context.
|
|
169
|
+
* @returns An array of capabilities.
|
|
170
|
+
* @reactive
|
|
191
171
|
*/
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
172
|
+
requestCapabilities<T, U extends T = T>(
|
|
173
|
+
interfaceDef: InterfaceDef<T>,
|
|
174
|
+
filter?: (capability: T, moduleId: string) => capability is U,
|
|
175
|
+
): U[] {
|
|
176
|
+
let current = this._definedCapabilities.get(interfaceDef.identifier);
|
|
177
|
+
if (!current) {
|
|
178
|
+
const object = create<{ value: CapabilityImpl<unknown>[] }>({ value: [] });
|
|
179
|
+
current = untracked(() => object.value);
|
|
180
|
+
this._definedCapabilities.set(interfaceDef.identifier, current);
|
|
181
|
+
}
|
|
196
182
|
|
|
197
|
-
/**
|
|
198
|
-
* Get the Rx reference to the available capabilities for a given interface.
|
|
199
|
-
* Primarily useful for deriving other Rx values based on the capability or
|
|
200
|
-
* for subscribing to changes in the capability.
|
|
201
|
-
* @returns An Rx reference to the available capability.
|
|
202
|
-
* @throws If no capability is found.
|
|
203
|
-
*/
|
|
204
|
-
capability<T>(interfaceDef: InterfaceDef<T>): Rx.Rx<T> {
|
|
205
183
|
// NOTE: This the type-checking for capabilities is done at the time of contribution.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Get capabilities from the plugin context.
|
|
211
|
-
* @returns An array of capabilities.
|
|
212
|
-
*/
|
|
213
|
-
getCapabilities<T>(interfaceDef: InterfaceDef<T>): T[] {
|
|
214
|
-
return this._registry.get(this.capabilities(interfaceDef));
|
|
184
|
+
const capabilities = filter ? current.filter((c) => filter(c.implementation as T, c.moduleId)) : current;
|
|
185
|
+
return capabilities.map((c) => c.implementation) as U[];
|
|
215
186
|
}
|
|
216
187
|
|
|
217
188
|
/**
|
|
218
189
|
* Requests a single capability from the plugin context.
|
|
219
190
|
* @returns The capability.
|
|
220
191
|
* @throws If no capability is found.
|
|
192
|
+
* @reactive
|
|
221
193
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
194
|
+
requestCapability<T, U extends T = T>(
|
|
195
|
+
interfaceDef: InterfaceDef<T>,
|
|
196
|
+
filter?: (capability: T, moduleId: string) => capability is U,
|
|
197
|
+
): U {
|
|
198
|
+
const capability = this.requestCapabilities(interfaceDef, filter)[0];
|
|
199
|
+
invariant(capability, `No capability found for ${interfaceDef.identifier}`);
|
|
200
|
+
return capability;
|
|
224
201
|
}
|
|
225
202
|
|
|
226
203
|
/**
|
|
227
|
-
* Waits for a capability to be
|
|
204
|
+
* Waits for a capability to be contributed.
|
|
228
205
|
* @returns The capability.
|
|
229
206
|
*/
|
|
230
|
-
async waitForCapability<T
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (capabilities.length > 0) {
|
|
207
|
+
async waitForCapability<T, U extends T = T>(
|
|
208
|
+
interfaceDef: InterfaceDef<T>,
|
|
209
|
+
filter?: (capability: T) => capability is U,
|
|
210
|
+
): Promise<U> {
|
|
211
|
+
const trigger = new Trigger<U>();
|
|
212
|
+
const unsubscribe = effect(() => {
|
|
213
|
+
const capabilities = this.requestCapabilities(interfaceDef, filter);
|
|
214
|
+
if (capabilities[0]) {
|
|
239
215
|
trigger.wake(capabilities[0]);
|
|
240
216
|
}
|
|
241
217
|
});
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
return
|
|
218
|
+
const capability = await trigger.wait();
|
|
219
|
+
unsubscribe();
|
|
220
|
+
return capability;
|
|
245
221
|
}
|
|
246
222
|
|
|
247
223
|
async activatePromise(event: ActivationEvent): Promise<boolean> {
|
package/src/core/events.ts
CHANGED
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* This is expected to be a URI, where initial parts are often the id of the plugin whose package defines the event.
|
|
8
|
-
*
|
|
9
|
-
* @example dxos.org/plugin/example/event/ready
|
|
6
|
+
* An event which activates a plugin module.
|
|
10
7
|
*/
|
|
11
8
|
export type ActivationEvent = {
|
|
12
9
|
id: string;
|
package/src/core/manager.test.ts
CHANGED
|
@@ -11,9 +11,9 @@ import { raise } from '@dxos/debug';
|
|
|
11
11
|
import { updateCounter } from '@dxos/echo-schema/testing';
|
|
12
12
|
import { registerSignalsRuntime } from '@dxos/echo-signals';
|
|
13
13
|
import { invariant } from '@dxos/invariant';
|
|
14
|
-
import {
|
|
14
|
+
import { create } from '@dxos/live-object';
|
|
15
15
|
|
|
16
|
-
import { contributes, defineCapability, type
|
|
16
|
+
import { contributes, defineCapability, type PluginsContext } from './capabilities';
|
|
17
17
|
import { allOf, defineEvent, oneOf } from './events';
|
|
18
18
|
import { PluginManager } from './manager';
|
|
19
19
|
import { definePlugin, defineModule, type Plugin } from './plugin';
|
|
@@ -205,22 +205,22 @@ describe('PluginManager', () => {
|
|
|
205
205
|
|
|
206
206
|
const manager = new PluginManager({ pluginLoader });
|
|
207
207
|
expect(manager.active).toEqual([]);
|
|
208
|
-
expect(manager.context.
|
|
208
|
+
expect(manager.context.requestCapabilities(Number)).toHaveLength(0);
|
|
209
209
|
|
|
210
210
|
await manager.add(Plugin1.meta.id);
|
|
211
211
|
await manager.activate(CountEvent);
|
|
212
212
|
expect(manager.active).toEqual([Plugin1.meta.id]);
|
|
213
|
-
expect(manager.context.
|
|
213
|
+
expect(manager.context.requestCapabilities(Number)).toHaveLength(1);
|
|
214
214
|
|
|
215
215
|
await manager.add(Plugin2.meta.id);
|
|
216
216
|
await manager.activate(CountEvent);
|
|
217
217
|
expect(manager.active).toEqual([Plugin1.meta.id, Plugin2.meta.id]);
|
|
218
|
-
expect(manager.context.
|
|
218
|
+
expect(manager.context.requestCapabilities(Number)).toHaveLength(2);
|
|
219
219
|
|
|
220
220
|
await manager.add(Plugin3.meta.id);
|
|
221
221
|
await manager.activate(CountEvent);
|
|
222
222
|
expect(manager.active).toEqual([Plugin1.meta.id, Plugin2.meta.id, Plugin3.meta.id]);
|
|
223
|
-
expect(manager.context.
|
|
223
|
+
expect(manager.context.requestCapabilities(Number)).toHaveLength(3);
|
|
224
224
|
});
|
|
225
225
|
|
|
226
226
|
it('should only activate modules after all activatation events have been fired', async () => {
|
|
@@ -235,16 +235,16 @@ describe('PluginManager', () => {
|
|
|
235
235
|
|
|
236
236
|
const manager = new PluginManager({ pluginLoader });
|
|
237
237
|
expect(manager.active).toEqual([]);
|
|
238
|
-
expect(manager.context.
|
|
238
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(0);
|
|
239
239
|
|
|
240
240
|
await manager.add(testMeta.id);
|
|
241
241
|
await manager.activate(Events.Startup);
|
|
242
242
|
expect(manager.active).toEqual([]);
|
|
243
|
-
expect(manager.context.
|
|
243
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(0);
|
|
244
244
|
|
|
245
245
|
await manager.activate(CountEvent);
|
|
246
246
|
expect(manager.active).toEqual([Hello.id]);
|
|
247
|
-
expect(manager.context.
|
|
247
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(1);
|
|
248
248
|
});
|
|
249
249
|
|
|
250
250
|
it('should only activate modules once when multiple activatation events have been fired', async () => {
|
|
@@ -261,25 +261,25 @@ describe('PluginManager', () => {
|
|
|
261
261
|
|
|
262
262
|
const manager = new PluginManager({ pluginLoader });
|
|
263
263
|
expect(manager.active).toEqual([]);
|
|
264
|
-
expect(manager.context.
|
|
264
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(0);
|
|
265
265
|
expect(count).toEqual(0);
|
|
266
266
|
|
|
267
267
|
await manager.add(testMeta.id);
|
|
268
268
|
await manager.activate(CountEvent);
|
|
269
269
|
expect(manager.active).toEqual([Hello.id]);
|
|
270
|
-
expect(manager.context.
|
|
270
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(1);
|
|
271
271
|
expect(count).toEqual(1);
|
|
272
272
|
|
|
273
273
|
await manager.activate(Events.Startup);
|
|
274
274
|
expect(manager.active).toEqual([Hello.id]);
|
|
275
|
-
expect(manager.context.
|
|
275
|
+
expect(manager.context.requestCapabilities(String)).toHaveLength(1);
|
|
276
276
|
expect(count).toEqual(1);
|
|
277
277
|
});
|
|
278
278
|
|
|
279
279
|
it('should be able to disable and re-enable an active plugin', async () => {
|
|
280
280
|
const state = { total: 0 };
|
|
281
|
-
const computeTotal = (context:
|
|
282
|
-
const numbers = context.
|
|
281
|
+
const computeTotal = (context: PluginsContext) => {
|
|
282
|
+
const numbers = context.requestCapabilities(Number);
|
|
283
283
|
state.total = numbers.reduce((acc, n) => acc + n.number, 0);
|
|
284
284
|
};
|
|
285
285
|
|
|
@@ -322,7 +322,7 @@ describe('PluginManager', () => {
|
|
|
322
322
|
expect(manager.active).toEqual([...Test.modules.map((m) => m.id), Count.meta.id]);
|
|
323
323
|
expect(manager.pendingReset).toEqual([]);
|
|
324
324
|
|
|
325
|
-
const totals = manager.context.
|
|
325
|
+
const totals = manager.context.requestCapabilities(Total);
|
|
326
326
|
expect(totals).toHaveLength(1);
|
|
327
327
|
expect(totals[0].total).toEqual(6);
|
|
328
328
|
}
|
|
@@ -332,7 +332,7 @@ describe('PluginManager', () => {
|
|
|
332
332
|
expect(manager.active).toEqual([Count.meta.id]);
|
|
333
333
|
expect(manager.pendingReset).toEqual([]);
|
|
334
334
|
|
|
335
|
-
const totals = manager.context.
|
|
335
|
+
const totals = manager.context.requestCapabilities(Total);
|
|
336
336
|
expect(totals).toHaveLength(1);
|
|
337
337
|
// Total doesn't change because it is not reactive.
|
|
338
338
|
expect(totals[0].total).toEqual(6);
|
|
@@ -343,7 +343,7 @@ describe('PluginManager', () => {
|
|
|
343
343
|
expect(manager.active).toEqual([Count.meta.id, ...Test.modules.map((m) => m.id)]);
|
|
344
344
|
expect(manager.pendingReset).toEqual([]);
|
|
345
345
|
|
|
346
|
-
const totals = manager.context.
|
|
346
|
+
const totals = manager.context.requestCapabilities(Total);
|
|
347
347
|
expect(totals).toHaveLength(1);
|
|
348
348
|
expect(totals[0].total).toEqual(6);
|
|
349
349
|
}
|
|
@@ -358,14 +358,14 @@ describe('PluginManager', () => {
|
|
|
358
358
|
id,
|
|
359
359
|
activatesOn: Events.Startup,
|
|
360
360
|
activatesAfter: [stateEvent],
|
|
361
|
-
activate: () => contributes(Number,
|
|
361
|
+
activate: () => contributes(Number, create({ number: 1 })),
|
|
362
362
|
}),
|
|
363
363
|
defineModule({
|
|
364
364
|
id: 'dxos.org/test/doubler',
|
|
365
365
|
activatesOn: stateEvent,
|
|
366
366
|
activate: (context) => {
|
|
367
|
-
const counter = context.
|
|
368
|
-
const state =
|
|
367
|
+
const counter = context.requestCapability(Number);
|
|
368
|
+
const state = create({ total: counter.number * 2 });
|
|
369
369
|
const unsubscribe = effect(() => {
|
|
370
370
|
state.total = counter.number * 2;
|
|
371
371
|
});
|
|
@@ -380,8 +380,8 @@ describe('PluginManager', () => {
|
|
|
380
380
|
await manager.activate(Events.Startup);
|
|
381
381
|
expect(manager.active).toEqual(Test.modules.map((m) => m.id));
|
|
382
382
|
|
|
383
|
-
const counter = manager.context.
|
|
384
|
-
const doubler = manager.context.
|
|
383
|
+
const counter = manager.context.requestCapability(Number);
|
|
384
|
+
const doubler = manager.context.requestCapability(Total);
|
|
385
385
|
expect(counter.number).toEqual(1);
|
|
386
386
|
expect(doubler.total).toEqual(2);
|
|
387
387
|
|
package/src/core/manager.ts
CHANGED
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Registry } from '@effect-rx/rx-react';
|
|
6
5
|
import { untracked } from '@preact/signals-core';
|
|
7
6
|
import { Array as A, Effect, Either, Match, pipe } from 'effect';
|
|
8
7
|
|
|
9
8
|
import { Event } from '@dxos/async';
|
|
10
|
-
import {
|
|
9
|
+
import { create, type ReactiveObject } from '@dxos/live-object';
|
|
11
10
|
import { log } from '@dxos/log';
|
|
12
11
|
import { type MaybePromise } from '@dxos/util';
|
|
13
12
|
|
|
14
|
-
import { type AnyCapability,
|
|
13
|
+
import { type AnyCapability, PluginsContext } from './capabilities';
|
|
15
14
|
import { type ActivationEvent, eventKey, getEvents, isAllOf } from './events';
|
|
16
15
|
import { type PluginModule, type Plugin } from './plugin';
|
|
17
16
|
|
|
@@ -25,7 +24,6 @@ export type PluginManagerOptions = {
|
|
|
25
24
|
plugins?: Plugin[];
|
|
26
25
|
core?: string[];
|
|
27
26
|
enabled?: string[];
|
|
28
|
-
registry?: Registry.Registry;
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
type PluginManagerState = {
|
|
@@ -45,11 +43,13 @@ type PluginManagerState = {
|
|
|
45
43
|
|
|
46
44
|
export class PluginManager {
|
|
47
45
|
readonly activation = new Event<{ event: string; state: 'activating' | 'activated' | 'error'; error?: any }>();
|
|
48
|
-
readonly context: PluginContext;
|
|
49
|
-
readonly registry: Registry.Registry;
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
readonly context = new PluginsContext({
|
|
48
|
+
activate: (event) => this._activate(event),
|
|
49
|
+
reset: (id) => this._reset(id),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
private readonly _state: ReactiveObject<PluginManagerState>;
|
|
53
53
|
private readonly _pluginLoader: PluginManagerOptions['pluginLoader'];
|
|
54
54
|
private readonly _capabilities = new Map<string, AnyCapability[]>();
|
|
55
55
|
|
|
@@ -58,17 +58,9 @@ export class PluginManager {
|
|
|
58
58
|
plugins = [],
|
|
59
59
|
core = plugins.map(({ meta }) => meta.id),
|
|
60
60
|
enabled = [],
|
|
61
|
-
registry,
|
|
62
61
|
}: PluginManagerOptions) {
|
|
63
|
-
this.registry = registry ?? Registry.make();
|
|
64
|
-
this.context = new PluginContext({
|
|
65
|
-
registry: this.registry,
|
|
66
|
-
activate: (event) => this._activate(event),
|
|
67
|
-
reset: (id) => this._reset(id),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
62
|
this._pluginLoader = pluginLoader;
|
|
71
|
-
this._state =
|
|
63
|
+
this._state = create({
|
|
72
64
|
plugins,
|
|
73
65
|
core,
|
|
74
66
|
enabled,
|
|
@@ -87,7 +79,7 @@ export class PluginManager {
|
|
|
87
79
|
*
|
|
88
80
|
* @reactive
|
|
89
81
|
*/
|
|
90
|
-
get plugins():
|
|
82
|
+
get plugins(): ReactiveObject<readonly Plugin[]> {
|
|
91
83
|
return this._state.plugins;
|
|
92
84
|
}
|
|
93
85
|
|
|
@@ -96,7 +88,7 @@ export class PluginManager {
|
|
|
96
88
|
*
|
|
97
89
|
* @reactive
|
|
98
90
|
*/
|
|
99
|
-
get core():
|
|
91
|
+
get core(): ReactiveObject<readonly string[]> {
|
|
100
92
|
return this._state.core;
|
|
101
93
|
}
|
|
102
94
|
|
|
@@ -105,7 +97,7 @@ export class PluginManager {
|
|
|
105
97
|
*
|
|
106
98
|
* @reactive
|
|
107
99
|
*/
|
|
108
|
-
get enabled():
|
|
100
|
+
get enabled(): ReactiveObject<readonly string[]> {
|
|
109
101
|
return this._state.enabled;
|
|
110
102
|
}
|
|
111
103
|
|
|
@@ -114,7 +106,7 @@ export class PluginManager {
|
|
|
114
106
|
*
|
|
115
107
|
* @reactive
|
|
116
108
|
*/
|
|
117
|
-
get modules():
|
|
109
|
+
get modules(): ReactiveObject<readonly PluginModule[]> {
|
|
118
110
|
return this._state.modules;
|
|
119
111
|
}
|
|
120
112
|
|
|
@@ -123,7 +115,7 @@ export class PluginManager {
|
|
|
123
115
|
*
|
|
124
116
|
* @reactive
|
|
125
117
|
*/
|
|
126
|
-
get active():
|
|
118
|
+
get active(): ReactiveObject<readonly string[]> {
|
|
127
119
|
return this._state.active;
|
|
128
120
|
}
|
|
129
121
|
|
|
@@ -132,7 +124,7 @@ export class PluginManager {
|
|
|
132
124
|
*
|
|
133
125
|
* @reactive
|
|
134
126
|
*/
|
|
135
|
-
get eventsFired():
|
|
127
|
+
get eventsFired(): ReactiveObject<readonly string[]> {
|
|
136
128
|
return this._state.eventsFired;
|
|
137
129
|
}
|
|
138
130
|
|
|
@@ -141,7 +133,7 @@ export class PluginManager {
|
|
|
141
133
|
*
|
|
142
134
|
* @reactive
|
|
143
135
|
*/
|
|
144
|
-
get pendingReset():
|
|
136
|
+
get pendingReset(): ReactiveObject<readonly string[]> {
|
|
145
137
|
return this._state.pendingReset;
|
|
146
138
|
}
|
|
147
139
|
|
package/src/core/plugin.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { type MaybePromise } from '@dxos/util';
|
|
6
6
|
|
|
7
|
-
import { type AnyCapability, type
|
|
7
|
+
import { type AnyCapability, type PluginsContext } from './capabilities';
|
|
8
8
|
import { type ActivationEvent, type ActivationEvents } from './events';
|
|
9
9
|
|
|
10
10
|
interface PluginModuleInterface {
|
|
@@ -36,13 +36,13 @@ interface PluginModuleInterface {
|
|
|
36
36
|
* @returns The capabilities of the module.
|
|
37
37
|
*/
|
|
38
38
|
activate: (
|
|
39
|
-
context:
|
|
39
|
+
context: PluginsContext,
|
|
40
40
|
) => MaybePromise<AnyCapability | AnyCapability[]> | Promise<() => Promise<AnyCapability | AnyCapability[]>>;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* A unit of containment of modular functionality that can be provided to an application.
|
|
45
|
-
*
|
|
45
|
+
* Plugins provide things like components, state, actions, etc. to the application.
|
|
46
46
|
*/
|
|
47
47
|
// NOTE: This is implemented as a class to prevent it from being proxied by PluginManager state.
|
|
48
48
|
export class PluginModule implements PluginModuleInterface {
|
|
@@ -114,7 +114,6 @@ export type PluginMeta = {
|
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* A collection of modules that are be enabled/disabled as a unit.
|
|
117
|
-
* Plugins provide things such as components, state, actions, etc. to the application.
|
|
118
117
|
*/
|
|
119
118
|
// NOTE: This is implemented as a class to prevent it from being proxied by PluginManager state.
|
|
120
119
|
export class Plugin {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, Events } from '../../common';
|
|
8
8
|
import { contributes, defineEvent, defineCapability, defineModule, definePlugin } from '../../core';
|
|
@@ -15,9 +15,9 @@ export const CountEvent = defineEvent('dxos.org/test/generator/count');
|
|
|
15
15
|
export const createPluginId = (id: string) => `dxos.org/test/generator/${id}`;
|
|
16
16
|
|
|
17
17
|
export const createGeneratorIntent = (id: string) => {
|
|
18
|
-
class Alert extends
|
|
19
|
-
input:
|
|
20
|
-
output:
|
|
18
|
+
class Alert extends S.TaggedClass<Alert>()(`${createPluginId(id)}/action/alert`, {
|
|
19
|
+
input: S.Void,
|
|
20
|
+
output: S.Void,
|
|
21
21
|
}) {}
|
|
22
22
|
|
|
23
23
|
return Alert as unknown as IntentSchema<any, any>;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
|
-
export class Log extends
|
|
8
|
-
input:
|
|
9
|
-
message:
|
|
7
|
+
export class Log extends S.TaggedClass<Log>()('dxos.org/test/logger/log', {
|
|
8
|
+
input: S.Struct({
|
|
9
|
+
message: S.String,
|
|
10
10
|
}),
|
|
11
|
-
output:
|
|
11
|
+
output: S.Void,
|
|
12
12
|
}) {}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { Label } from './intent';
|
|
8
8
|
|
|
@@ -13,21 +13,21 @@ export namespace IntentAction {
|
|
|
13
13
|
/**
|
|
14
14
|
* Log an intent.
|
|
15
15
|
*/
|
|
16
|
-
export class Track extends
|
|
17
|
-
input:
|
|
18
|
-
intents:
|
|
19
|
-
error:
|
|
16
|
+
export class Track extends S.TaggedClass<Track>()(`${INTENT_ACTION}/track`, {
|
|
17
|
+
input: S.Struct({
|
|
18
|
+
intents: S.Array(S.String),
|
|
19
|
+
error: S.optional(S.String),
|
|
20
20
|
}),
|
|
21
|
-
output:
|
|
21
|
+
output: S.Void,
|
|
22
22
|
}) {}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Fired after an intent is dispatched if the intent is undoable.
|
|
26
26
|
*/
|
|
27
|
-
export class ShowUndo extends
|
|
28
|
-
input:
|
|
27
|
+
export class ShowUndo extends S.TaggedClass<ShowUndo>()(`${INTENT_ACTION}/show-undo`, {
|
|
28
|
+
input: S.Struct({
|
|
29
29
|
message: Label,
|
|
30
30
|
}),
|
|
31
|
-
output:
|
|
31
|
+
output: S.Void,
|
|
32
32
|
}) {}
|
|
33
33
|
}
|