@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema, Effect, Fiber, pipe } from 'effect';
|
|
5
|
+
import { Schema as S, Effect, Fiber, pipe } from 'effect';
|
|
6
6
|
import { describe, expect, test } from 'vitest';
|
|
7
7
|
|
|
8
8
|
import { chain, createIntent } from './intent';
|
|
@@ -134,6 +134,25 @@ describe('Intent dispatcher', () => {
|
|
|
134
134
|
await Effect.runPromise(program);
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
+
test('filter resolvers by plugin', async () => {
|
|
138
|
+
const otherComputeResolver = createResolver({
|
|
139
|
+
intent: Compute,
|
|
140
|
+
resolve: async (data) => ({ data: { value: data?.value * 3 } }),
|
|
141
|
+
});
|
|
142
|
+
const { dispatch } = createDispatcher((module) => (module === 'test' ? [computeResolver] : [otherComputeResolver]));
|
|
143
|
+
const program = Effect.gen(function* () {
|
|
144
|
+
const a = yield* dispatch(createIntent(Compute, { value: 1 }));
|
|
145
|
+
|
|
146
|
+
expect(a.value).toBe(3);
|
|
147
|
+
|
|
148
|
+
const b = yield* dispatch(createIntent(Compute, { value: 1 }, { module: 'test' }));
|
|
149
|
+
|
|
150
|
+
expect(b.value).toBe(2);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
await Effect.runPromise(program);
|
|
154
|
+
});
|
|
155
|
+
|
|
137
156
|
test('filter resolvers by predicate', async () => {
|
|
138
157
|
const conditionalComputeResolver = createResolver({
|
|
139
158
|
intent: Compute,
|
|
@@ -205,12 +224,12 @@ describe('Intent dispatcher', () => {
|
|
|
205
224
|
test.todo('follow up intents');
|
|
206
225
|
});
|
|
207
226
|
|
|
208
|
-
class ToString extends
|
|
209
|
-
input:
|
|
210
|
-
value:
|
|
227
|
+
class ToString extends S.TaggedClass<ToString>()('ToString', {
|
|
228
|
+
input: S.Struct({
|
|
229
|
+
value: S.Number,
|
|
211
230
|
}),
|
|
212
|
-
output:
|
|
213
|
-
string:
|
|
231
|
+
output: S.Struct({
|
|
232
|
+
string: S.String,
|
|
214
233
|
}),
|
|
215
234
|
}) {}
|
|
216
235
|
|
|
@@ -219,12 +238,12 @@ const toStringResolver = createResolver({
|
|
|
219
238
|
resolve: async (data) => ({ data: { string: data.value.toString() } }),
|
|
220
239
|
});
|
|
221
240
|
|
|
222
|
-
class Compute extends
|
|
223
|
-
input:
|
|
224
|
-
value:
|
|
241
|
+
class Compute extends S.TaggedClass<Compute>()('Compute', {
|
|
242
|
+
input: S.Struct({
|
|
243
|
+
value: S.Number,
|
|
225
244
|
}),
|
|
226
|
-
output:
|
|
227
|
-
value:
|
|
245
|
+
output: S.Struct({
|
|
246
|
+
value: S.Number,
|
|
228
247
|
}),
|
|
229
248
|
}) {}
|
|
230
249
|
|
|
@@ -243,13 +262,13 @@ const computeResolver = createResolver({
|
|
|
243
262
|
},
|
|
244
263
|
});
|
|
245
264
|
|
|
246
|
-
class Concat extends
|
|
247
|
-
input:
|
|
248
|
-
string:
|
|
249
|
-
plus:
|
|
265
|
+
class Concat extends S.TaggedClass<Concat>()('Concat', {
|
|
266
|
+
input: S.Struct({
|
|
267
|
+
string: S.String,
|
|
268
|
+
plus: S.String,
|
|
250
269
|
}),
|
|
251
|
-
output:
|
|
252
|
-
string:
|
|
270
|
+
output: S.Struct({
|
|
271
|
+
string: S.String,
|
|
253
272
|
}),
|
|
254
273
|
}) {}
|
|
255
274
|
|
|
@@ -258,9 +277,9 @@ const concatResolver = createResolver({
|
|
|
258
277
|
resolve: async (data) => ({ data: { string: data.string + data.plus } }),
|
|
259
278
|
});
|
|
260
279
|
|
|
261
|
-
class Add extends
|
|
262
|
-
input:
|
|
263
|
-
output:
|
|
280
|
+
class Add extends S.TaggedClass<Add>()('Add', {
|
|
281
|
+
input: S.Tuple(S.Number, S.Number),
|
|
282
|
+
output: S.Number,
|
|
264
283
|
}) {}
|
|
265
284
|
|
|
266
285
|
const addResolver = createResolver({
|
|
@@ -268,9 +287,9 @@ const addResolver = createResolver({
|
|
|
268
287
|
resolve: async (data) => ({ data: data[0] + data[1] }),
|
|
269
288
|
});
|
|
270
289
|
|
|
271
|
-
class SideEffect extends
|
|
272
|
-
input:
|
|
273
|
-
output:
|
|
290
|
+
class SideEffect extends S.TaggedClass<SideEffect>()('SideEffect', {
|
|
291
|
+
input: S.Void,
|
|
292
|
+
output: S.Void,
|
|
274
293
|
}) {}
|
|
275
294
|
|
|
276
295
|
const sideEffectResolver = createResolver({
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Effect, Option, pipe, Ref } from 'effect';
|
|
6
6
|
import { type Simplify } from 'effect/Types';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { create } from '@dxos/live-object';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { byPosition, type MaybePromise, type Position, type GuardedType } from '@dxos/util';
|
|
11
11
|
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
type Label,
|
|
25
25
|
} from './intent';
|
|
26
26
|
import { Events, Capabilities } from '../common';
|
|
27
|
-
import { contributes, type
|
|
27
|
+
import { contributes, type PluginsContext } from '../core';
|
|
28
28
|
|
|
29
29
|
const EXECUTION_LIMIT = 100;
|
|
30
30
|
const HISTORY_LIMIT = 100;
|
|
@@ -91,25 +91,9 @@ export type IntentEffectDefinition<Input, Output> = (
|
|
|
91
91
|
* Intent resolver to match intents to their effects.
|
|
92
92
|
*/
|
|
93
93
|
export type IntentResolver<Tag extends string, Fields extends IntentParams, Data = IntentData<Fields>> = Readonly<{
|
|
94
|
-
/**
|
|
95
|
-
* The schema of the intent to be resolved.
|
|
96
|
-
*/
|
|
97
94
|
intent: IntentSchema<Tag, Fields>;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Hint to determine the order the resolvers are processed if multiple resolvers are defined for the same intent.
|
|
101
|
-
* Only one resolver will be used.
|
|
102
|
-
*/
|
|
103
95
|
position?: Position;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Optional filter to determine if the resolver should be used.
|
|
107
|
-
*/
|
|
108
96
|
filter?: (data: IntentData<Fields>) => data is Data;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* The effect to be performed when the intent is resolved.
|
|
112
|
-
*/
|
|
113
97
|
resolve: IntentEffectDefinition<GuardedType<IntentResolver<Tag, Fields, Data>['filter']>, IntentResultData<Fields>>;
|
|
114
98
|
}>;
|
|
115
99
|
|
|
@@ -184,14 +168,14 @@ export type IntentContext = {
|
|
|
184
168
|
* @param params.executionLimit The maximum recursion depth of intent chains.
|
|
185
169
|
*/
|
|
186
170
|
export const createDispatcher = (
|
|
187
|
-
getResolvers: () => AnyIntentResolver[],
|
|
171
|
+
getResolvers: (module?: string) => AnyIntentResolver[],
|
|
188
172
|
{ executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {},
|
|
189
173
|
): IntentContext => {
|
|
190
174
|
const historyRef = Effect.runSync(Ref.make<AnyIntentResult[][]>([]));
|
|
191
175
|
|
|
192
176
|
const handleIntent = (intent: AnyIntent) =>
|
|
193
177
|
Effect.gen(function* () {
|
|
194
|
-
const candidates = getResolvers()
|
|
178
|
+
const candidates = getResolvers(intent.module)
|
|
195
179
|
.filter((resolver) => resolver.intent._tag === intent.id)
|
|
196
180
|
.filter((resolver) => !resolver.filter || resolver.filter(intent.data))
|
|
197
181
|
.toSorted(byPosition);
|
|
@@ -302,8 +286,8 @@ export const createDispatcher = (
|
|
|
302
286
|
const defaultEffect = () => Effect.fail(new Error('Intent runtime not ready'));
|
|
303
287
|
const defaultPromise = () => Effect.runPromise(defaultEffect());
|
|
304
288
|
|
|
305
|
-
export default (context:
|
|
306
|
-
const state =
|
|
289
|
+
export default (context: PluginsContext) => {
|
|
290
|
+
const state = create<IntentContext>({
|
|
307
291
|
dispatch: defaultEffect,
|
|
308
292
|
dispatchPromise: defaultPromise,
|
|
309
293
|
undo: defaultEffect,
|
|
@@ -311,11 +295,15 @@ export default (context: PluginContext) => {
|
|
|
311
295
|
});
|
|
312
296
|
|
|
313
297
|
// TODO(wittjosiah): Make getResolver callback async and allow resolvers to be requested on demand.
|
|
314
|
-
const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher(() =>
|
|
315
|
-
context
|
|
298
|
+
const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher((module) =>
|
|
299
|
+
context
|
|
300
|
+
.requestCapabilities(Capabilities.IntentResolver, (c, moduleId): c is AnyIntentResolver => {
|
|
301
|
+
return module ? moduleId === module : true;
|
|
302
|
+
})
|
|
303
|
+
.flat(),
|
|
316
304
|
);
|
|
317
305
|
|
|
318
|
-
const manager = context.
|
|
306
|
+
const manager = context.requestCapability(Capabilities.PluginManager);
|
|
319
307
|
state.dispatch = (intentChain, depth) => {
|
|
320
308
|
return Effect.gen(function* () {
|
|
321
309
|
yield* manager._activate(Events.SetupIntentResolver);
|
|
@@ -2,24 +2,20 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
7
|
export type IntentParams = {
|
|
8
|
-
readonly input:
|
|
9
|
-
readonly output:
|
|
8
|
+
readonly input: S.Schema.All;
|
|
9
|
+
readonly output: S.Schema.All;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export type IntentData<Fields extends IntentParams> =
|
|
13
|
-
|
|
14
|
-
? Schema.Schema.Type<Schema.Struct<Fields>>['input']
|
|
15
|
-
: any;
|
|
13
|
+
S.Schema.Type<S.Struct<Fields>> extends { readonly input: any } ? S.Schema.Type<S.Struct<Fields>>['input'] : any;
|
|
16
14
|
|
|
17
15
|
export type IntentResultData<Fields extends IntentParams> =
|
|
18
|
-
|
|
19
|
-
? Schema.Schema.Type<Schema.Struct<Fields>>['output']
|
|
20
|
-
: any;
|
|
16
|
+
S.Schema.Type<S.Struct<Fields>> extends { readonly output: any } ? S.Schema.Type<S.Struct<Fields>>['output'] : any;
|
|
21
17
|
|
|
22
|
-
export type IntentSchema<Tag extends string, Fields extends IntentParams> =
|
|
18
|
+
export type IntentSchema<Tag extends string, Fields extends IntentParams> = S.TaggedClass<any, Tag, Fields>;
|
|
23
19
|
|
|
24
20
|
/**
|
|
25
21
|
* An intent is an abstract description of an operation to be performed.
|
|
@@ -38,6 +34,13 @@ export type Intent<Tag extends string, Fields extends IntentParams> = {
|
|
|
38
34
|
*/
|
|
39
35
|
data: IntentData<Fields>;
|
|
40
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Module ID.
|
|
39
|
+
* If specified, the intent will be sent explicitly to the plugin module.
|
|
40
|
+
* Otherwise, the intent will be sent to all plugins, in order and the first to resolve a non-null value will be used.
|
|
41
|
+
*/
|
|
42
|
+
module?: string;
|
|
43
|
+
|
|
41
44
|
/**
|
|
42
45
|
* Whether or not the intent is being undone.
|
|
43
46
|
*/
|
|
@@ -73,11 +76,11 @@ export type AnyIntentChain = IntentChain<any, any, any, any>;
|
|
|
73
76
|
export const createIntent = <Tag extends string, Fields extends IntentParams>(
|
|
74
77
|
schema: IntentSchema<Tag, Fields>,
|
|
75
78
|
data: IntentData<Fields> = {},
|
|
76
|
-
params: Pick<AnyIntent, 'undo'> = {},
|
|
79
|
+
params: Pick<AnyIntent, 'module' | 'undo'> = {},
|
|
77
80
|
): IntentChain<Tag, Tag, Fields, Fields> => {
|
|
78
81
|
// The output of validateSync breaks proxy objects so this is just used for validation.
|
|
79
82
|
// TODO(wittjosiah): Is there a better way to make theses types align?
|
|
80
|
-
const _ =
|
|
83
|
+
const _ = S.validateSync(schema.fields.input as S.Schema<any, any, unknown>)(data);
|
|
81
84
|
const intent = {
|
|
82
85
|
...params,
|
|
83
86
|
_schema: schema,
|
|
@@ -109,7 +112,7 @@ export const chain =
|
|
|
109
112
|
>(
|
|
110
113
|
schema: IntentSchema<NextTag, NextFields>,
|
|
111
114
|
data: Omit<IntentData<NextFields>, keyof IntentResultData<LastFields>> = {},
|
|
112
|
-
params: Pick<AnyIntent, 'undo'> = {},
|
|
115
|
+
params: Pick<AnyIntent, 'module' | 'undo'> = {},
|
|
113
116
|
) =>
|
|
114
117
|
(
|
|
115
118
|
intent: IntentChain<FirstTag, any, FirstFields, LastFields>,
|
|
@@ -136,13 +139,8 @@ export const chain =
|
|
|
136
139
|
|
|
137
140
|
// NOTE: Should maintain compatibility with `i18next` (and @dxos/react-ui).
|
|
138
141
|
// TODO(wittjosiah): Making this immutable breaks type compatibility.
|
|
139
|
-
export const Label =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
Schema.Tuple(
|
|
143
|
-
Schema.String,
|
|
144
|
-
Schema.mutable(Schema.Struct({ ns: Schema.String, count: Schema.optional(Schema.Number) })),
|
|
145
|
-
),
|
|
146
|
-
),
|
|
142
|
+
export const Label = S.Union(
|
|
143
|
+
S.String,
|
|
144
|
+
S.mutable(S.Tuple(S.String, S.mutable(S.Struct({ ns: S.String, count: S.optional(S.Number) })))),
|
|
147
145
|
);
|
|
148
|
-
export type Label =
|
|
146
|
+
export type Label = S.Schema.Type<typeof Label>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
7
|
export const SETTINGS_PLUGIN = 'dxos.org/plugin/settings';
|
|
8
8
|
export const SETTINGS_ACTION = `${SETTINGS_PLUGIN}/action`;
|
|
@@ -12,18 +12,18 @@ export const SETTINGS_ID = '!dxos:settings';
|
|
|
12
12
|
export const SETTINGS_KEY = 'settings';
|
|
13
13
|
|
|
14
14
|
export namespace SettingsAction {
|
|
15
|
-
export class Open extends
|
|
16
|
-
input:
|
|
17
|
-
plugin:
|
|
15
|
+
export class Open extends S.TaggedClass<Open>()(`${SETTINGS_ACTION}/open`, {
|
|
16
|
+
input: S.Struct({
|
|
17
|
+
plugin: S.optional(S.String),
|
|
18
18
|
}),
|
|
19
|
-
output:
|
|
19
|
+
output: S.Void,
|
|
20
20
|
}) {}
|
|
21
21
|
|
|
22
|
-
export class OpenPluginRegistry extends
|
|
22
|
+
export class OpenPluginRegistry extends S.TaggedClass<OpenPluginRegistry>()(
|
|
23
23
|
`${SETTINGS_ACTION}/open-plugin-registry`,
|
|
24
24
|
{
|
|
25
|
-
input:
|
|
26
|
-
output:
|
|
25
|
+
input: S.Void,
|
|
26
|
+
output: S.Void,
|
|
27
27
|
},
|
|
28
28
|
) {}
|
|
29
29
|
}
|
|
@@ -2,156 +2,121 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { Option, pipe } from 'effect';
|
|
7
|
-
|
|
8
|
-
import { createExtension, ROOT_ID } from '@dxos/app-graph';
|
|
5
|
+
import { createExtension, type Node } from '@dxos/app-graph';
|
|
9
6
|
import { type SettingsStore, type SettingsValue } from '@dxos/local-storage';
|
|
10
7
|
import { isNonNullable } from '@dxos/util';
|
|
11
8
|
|
|
12
9
|
import { SETTINGS_ID, SETTINGS_KEY, SETTINGS_PLUGIN, SettingsAction } from './actions';
|
|
13
10
|
import { Capabilities } from '../common';
|
|
14
|
-
import { contributes, type PluginMeta, type
|
|
11
|
+
import { contributes, type PluginMeta, type PluginsContext } from '../core';
|
|
15
12
|
import { createIntent } from '../plugin-intent';
|
|
16
13
|
|
|
17
|
-
export default (context:
|
|
14
|
+
export default (context: PluginsContext) =>
|
|
18
15
|
contributes(Capabilities.AppGraphBuilder, [
|
|
19
16
|
createExtension({
|
|
20
17
|
id: `${SETTINGS_PLUGIN}/action`,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
windows: 'alt+,',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
]),
|
|
44
|
-
Option.getOrElse(() => []),
|
|
45
|
-
),
|
|
46
|
-
),
|
|
18
|
+
filter: (node): node is Node<null> => node.id === 'root',
|
|
19
|
+
actions: () => [
|
|
20
|
+
{
|
|
21
|
+
id: SETTINGS_PLUGIN,
|
|
22
|
+
data: async () => {
|
|
23
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
24
|
+
await dispatch(createIntent(SettingsAction.Open));
|
|
25
|
+
},
|
|
26
|
+
properties: {
|
|
27
|
+
label: ['open settings label', { ns: SETTINGS_PLUGIN }],
|
|
28
|
+
icon: 'ph--gear--regular',
|
|
29
|
+
keyBinding: {
|
|
30
|
+
macos: 'meta+,',
|
|
31
|
+
windows: 'alt+,',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
47
36
|
}),
|
|
48
37
|
createExtension({
|
|
49
38
|
id: `${SETTINGS_PLUGIN}/core`,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
testId: 'treeView.appSettings',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
]),
|
|
68
|
-
Option.getOrElse(() => []),
|
|
69
|
-
),
|
|
70
|
-
),
|
|
39
|
+
filter: (node): node is Node<null> => node.id === 'root',
|
|
40
|
+
connector: () => [
|
|
41
|
+
{
|
|
42
|
+
id: SETTINGS_ID,
|
|
43
|
+
type: SETTINGS_PLUGIN,
|
|
44
|
+
properties: {
|
|
45
|
+
label: ['app settings label', { ns: SETTINGS_PLUGIN }],
|
|
46
|
+
icon: 'ph--gear--regular',
|
|
47
|
+
disposition: 'pin-end',
|
|
48
|
+
position: 'hoist',
|
|
49
|
+
testId: 'treeView.appSettings',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
71
53
|
}),
|
|
72
54
|
createExtension({
|
|
73
55
|
id: `${SETTINGS_PLUGIN}/core-plugins`,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const settings = settingsStore?.getStore(plugin.meta.id);
|
|
87
|
-
if (!settings) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
56
|
+
filter: (node): node is Node<null> => node.id === SETTINGS_ID,
|
|
57
|
+
connector: () => {
|
|
58
|
+
const manager = context.requestCapability(Capabilities.PluginManager);
|
|
59
|
+
const [settingsStore] = context.requestCapabilities(Capabilities.SettingsStore);
|
|
60
|
+
return [
|
|
61
|
+
...manager.plugins
|
|
62
|
+
.filter((plugin) => manager.core.includes(plugin.meta.id))
|
|
63
|
+
.map((plugin): [PluginMeta, SettingsStore<SettingsValue>] | null => {
|
|
64
|
+
const settings = settingsStore?.getStore(plugin.meta.id);
|
|
65
|
+
if (!settings) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
90
68
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
69
|
+
return [plugin.meta, settings];
|
|
70
|
+
})
|
|
71
|
+
.filter(isNonNullable)
|
|
72
|
+
.map(([meta, settings]) => ({
|
|
73
|
+
id: `${SETTINGS_KEY}:${meta.id.replaceAll('/', ':')}`,
|
|
74
|
+
type: 'category',
|
|
75
|
+
data: settings,
|
|
76
|
+
properties: {
|
|
77
|
+
label: meta.name ?? meta.id,
|
|
78
|
+
icon: meta.icon ?? 'ph--circle--regular',
|
|
79
|
+
},
|
|
80
|
+
})),
|
|
103
81
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}),
|
|
116
|
-
Option.getOrElse(() => []),
|
|
117
|
-
),
|
|
118
|
-
),
|
|
82
|
+
{
|
|
83
|
+
id: `${SETTINGS_KEY}:custom-plugins`,
|
|
84
|
+
type: 'collection',
|
|
85
|
+
properties: {
|
|
86
|
+
label: ['custom plugins label', { ns: SETTINGS_PLUGIN }],
|
|
87
|
+
icon: 'ph--squares-four--regular',
|
|
88
|
+
role: 'branch',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
},
|
|
119
93
|
}),
|
|
120
94
|
createExtension({
|
|
121
95
|
id: `${SETTINGS_PLUGIN}/custom-plugins`,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.filter((plugin) => !manager.core.includes(plugin.meta.id))
|
|
134
|
-
.map((plugin): [PluginMeta, SettingsStore<SettingsValue>] | null => {
|
|
135
|
-
const settings = settingsStore?.getStore(plugin.meta.id);
|
|
136
|
-
if (!settings) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
96
|
+
filter: (node): node is Node<null> => node.id === `${SETTINGS_KEY}:custom-plugins`,
|
|
97
|
+
connector: () => {
|
|
98
|
+
const manager = context.requestCapability(Capabilities.PluginManager);
|
|
99
|
+
const [settingsStore] = context.requestCapabilities(Capabilities.SettingsStore);
|
|
100
|
+
return manager.plugins
|
|
101
|
+
.filter((plugin) => !manager.core.includes(plugin.meta.id))
|
|
102
|
+
.map((plugin): [PluginMeta, SettingsStore<SettingsValue>] | null => {
|
|
103
|
+
const settings = settingsStore?.getStore(plugin.meta.id);
|
|
104
|
+
if (!settings) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
139
107
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
Option.getOrElse(() => []),
|
|
154
|
-
),
|
|
155
|
-
),
|
|
108
|
+
return [plugin.meta, settings];
|
|
109
|
+
})
|
|
110
|
+
.filter(isNonNullable)
|
|
111
|
+
.map(([meta, settings]) => ({
|
|
112
|
+
id: `${SETTINGS_KEY}:${meta.id.replaceAll('/', ':')}`,
|
|
113
|
+
type: 'category',
|
|
114
|
+
data: settings,
|
|
115
|
+
properties: {
|
|
116
|
+
label: meta.name ?? meta.id,
|
|
117
|
+
icon: meta.icon ?? 'ph--circle--regular',
|
|
118
|
+
},
|
|
119
|
+
}));
|
|
120
|
+
},
|
|
156
121
|
}),
|
|
157
122
|
]);
|
|
@@ -2,32 +2,29 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { effect } from '@preact/signals-core';
|
|
6
|
+
|
|
5
7
|
import { RootSettingsStore } from '@dxos/local-storage';
|
|
6
8
|
|
|
7
9
|
import { Capabilities } from '../common';
|
|
8
|
-
import { contributes, type
|
|
10
|
+
import { contributes, type PluginsContext } from '../core';
|
|
9
11
|
|
|
10
|
-
export default (context:
|
|
11
|
-
// TODO(wittjosiah): Replace with rx?
|
|
12
|
+
export default (context: PluginsContext) => {
|
|
12
13
|
const settingsStore = new RootSettingsStore();
|
|
13
14
|
|
|
14
15
|
let previous: Capabilities.Settings[] = [];
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
{ immediate: true },
|
|
30
|
-
);
|
|
16
|
+
const unsubscribe = effect(() => {
|
|
17
|
+
const allSettings = context.requestCapabilities(Capabilities.Settings);
|
|
18
|
+
const added = allSettings.filter((setting) => !previous.includes(setting));
|
|
19
|
+
const removed = previous.filter((setting) => !allSettings.includes(setting));
|
|
20
|
+
previous = allSettings;
|
|
21
|
+
added.forEach((setting) => {
|
|
22
|
+
settingsStore.createStore(setting as any);
|
|
23
|
+
});
|
|
24
|
+
removed.forEach((setting) => {
|
|
25
|
+
settingsStore.removeStore(setting.prefix);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
31
28
|
|
|
32
|
-
return contributes(Capabilities.SettingsStore, settingsStore, () =>
|
|
29
|
+
return contributes(Capabilities.SettingsStore, settingsStore, () => unsubscribe());
|
|
33
30
|
};
|
|
@@ -87,7 +87,7 @@ export default {
|
|
|
87
87
|
);
|
|
88
88
|
},
|
|
89
89
|
// NOTE: Intentionally not using withPluginManager to try to reduce surface area of the story.
|
|
90
|
-
decorators: [withTheme, withLayout()],
|
|
90
|
+
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
91
91
|
args: {
|
|
92
92
|
manager: setupPluginManager(),
|
|
93
93
|
},
|
package/src/react/Surface.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import { byPosition } from '@dxos/util';
|
|
|
10
10
|
import { ErrorBoundary } from './ErrorBoundary';
|
|
11
11
|
import { useCapabilities } from './useCapabilities';
|
|
12
12
|
import { Capabilities, type SurfaceDefinition, type SurfaceProps } from '../common';
|
|
13
|
-
import { type
|
|
13
|
+
import { type PluginsContext } from '../core';
|
|
14
14
|
|
|
15
15
|
const DEFAULT_PLACEHOLDER = <Fragment />;
|
|
16
16
|
|
|
@@ -34,8 +34,8 @@ const findCandidates = (surfaces: SurfaceDefinition[], { role, data }: Pick<Surf
|
|
|
34
34
|
/**
|
|
35
35
|
* @returns `true` if there is a contributed surface which matches the specified role & data, `false` otherwise.
|
|
36
36
|
*/
|
|
37
|
-
export const isSurfaceAvailable = (context:
|
|
38
|
-
const surfaces = context.
|
|
37
|
+
export const isSurfaceAvailable = (context: PluginsContext, { role, data }: Pick<SurfaceProps, 'role' | 'data'>) => {
|
|
38
|
+
const surfaces = context.requestCapabilities(Capabilities.ReactSurface);
|
|
39
39
|
const candidates = findCandidates(surfaces.flat(), { role, data });
|
|
40
40
|
return candidates.length > 0;
|
|
41
41
|
};
|