@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/common/layout.ts
CHANGED
|
@@ -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
|
import { Label } from '../plugin-intent';
|
|
8
8
|
|
|
@@ -18,17 +18,17 @@ export namespace LayoutAction {
|
|
|
18
18
|
/**
|
|
19
19
|
* Generic layout action.
|
|
20
20
|
*/
|
|
21
|
-
export class UpdateLayout extends
|
|
22
|
-
input:
|
|
23
|
-
part:
|
|
24
|
-
subject:
|
|
25
|
-
options:
|
|
26
|
-
|
|
21
|
+
export class UpdateLayout extends S.TaggedClass<UpdateLayout>()(UPDATE_LAYOUT, {
|
|
22
|
+
input: S.Struct({
|
|
23
|
+
part: S.String.annotations({ description: 'The part of the layout to mutate.' }),
|
|
24
|
+
subject: S.optional(S.Any.annotations({ description: 'The subject of the layout update.' })),
|
|
25
|
+
options: S.optional(
|
|
26
|
+
S.Record({ key: S.String, value: S.Any }).annotations({
|
|
27
27
|
description: 'Additional options for the layout action.',
|
|
28
28
|
}),
|
|
29
29
|
),
|
|
30
30
|
}),
|
|
31
|
-
output:
|
|
31
|
+
output: S.Void,
|
|
32
32
|
}) {}
|
|
33
33
|
|
|
34
34
|
//
|
|
@@ -41,230 +41,199 @@ export namespace LayoutAction {
|
|
|
41
41
|
// This allows for plugins to update the layout without depending on a specific layout plugin.
|
|
42
42
|
// The expectation is that other norms other than these will emerge over time.
|
|
43
43
|
|
|
44
|
-
export class SetLayoutMode extends
|
|
45
|
-
input:
|
|
46
|
-
part:
|
|
47
|
-
subject:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Schema.Struct({ mode: Schema.String.annotations({ description: 'The new layout mode.' }) }),
|
|
52
|
-
Schema.Struct({ revert: Schema.Boolean.annotations({ description: 'Revert to the previous layout mode.' }) }),
|
|
44
|
+
export class SetLayoutMode extends S.TaggedClass<SetLayoutMode>()(UPDATE_LAYOUT, {
|
|
45
|
+
input: S.Struct({
|
|
46
|
+
part: S.Literal('mode').annotations({ description: 'Setting the layout mode.' }),
|
|
47
|
+
subject: S.optional(S.String.annotations({ description: 'Item which is the subject of the new layout mode.' })),
|
|
48
|
+
options: S.Union(
|
|
49
|
+
S.Struct({ mode: S.String.annotations({ description: 'The new layout mode.' }) }),
|
|
50
|
+
S.Struct({ revert: S.Boolean.annotations({ description: 'Revert to the previous layout mode.' }) }),
|
|
53
51
|
),
|
|
54
52
|
}),
|
|
55
|
-
output:
|
|
53
|
+
output: S.Void,
|
|
56
54
|
}) {}
|
|
57
55
|
|
|
58
|
-
export class UpdateSidebar extends
|
|
59
|
-
input:
|
|
60
|
-
part:
|
|
61
|
-
subject:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
Schema.Struct({
|
|
66
|
-
state: Schema.Literal('closed', 'collapsed', 'expanded').annotations({
|
|
56
|
+
export class UpdateSidebar extends S.TaggedClass<UpdateSidebar>()(UPDATE_LAYOUT, {
|
|
57
|
+
input: S.Struct({
|
|
58
|
+
part: S.Literal('sidebar').annotations({ description: 'Updating the sidebar.' }),
|
|
59
|
+
subject: S.optional(S.String.annotations({ description: 'URI of the component to display in the sidebar.' })),
|
|
60
|
+
options: S.optional(
|
|
61
|
+
S.Struct({
|
|
62
|
+
state: S.Literal('closed', 'collapsed', 'expanded').annotations({
|
|
67
63
|
description: 'Whether the sidebar is closed, collapsed, or expanded.',
|
|
68
64
|
}),
|
|
69
65
|
}),
|
|
70
66
|
),
|
|
71
67
|
}),
|
|
72
|
-
output:
|
|
68
|
+
output: S.Void,
|
|
73
69
|
}) {}
|
|
74
70
|
|
|
75
|
-
export class UpdateComplementary extends
|
|
76
|
-
input:
|
|
77
|
-
part:
|
|
78
|
-
subject:
|
|
79
|
-
|
|
71
|
+
export class UpdateComplementary extends S.TaggedClass<UpdateComplementary>()(UPDATE_LAYOUT, {
|
|
72
|
+
input: S.Struct({
|
|
73
|
+
part: S.Literal('complementary').annotations({ description: 'Updating the complementary sidebar.' }),
|
|
74
|
+
subject: S.optional(
|
|
75
|
+
S.String.annotations({ description: 'URI of the component to display in the complementary area.' }),
|
|
80
76
|
),
|
|
81
|
-
options:
|
|
82
|
-
|
|
83
|
-
state:
|
|
77
|
+
options: S.optional(
|
|
78
|
+
S.Struct({
|
|
79
|
+
state: S.Literal('closed', 'collapsed', 'expanded').annotations({
|
|
84
80
|
description: 'Whether the complementary sidebar is closed, collapsed, or expanded.',
|
|
85
81
|
}),
|
|
86
82
|
}),
|
|
87
83
|
),
|
|
88
84
|
}),
|
|
89
|
-
output:
|
|
85
|
+
output: S.Void,
|
|
90
86
|
}) {}
|
|
91
87
|
|
|
92
|
-
export class UpdateDialog extends
|
|
93
|
-
input:
|
|
94
|
-
part:
|
|
95
|
-
subject:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
blockAlign: Schema.optional(
|
|
101
|
-
Schema.Literal('start', 'center', 'end').annotations({ description: 'The alignment of the dialog.' }),
|
|
88
|
+
export class UpdateDialog extends S.TaggedClass<UpdateDialog>()(UPDATE_LAYOUT, {
|
|
89
|
+
input: S.Struct({
|
|
90
|
+
part: S.Literal('dialog').annotations({ description: 'Updating the dialog.' }),
|
|
91
|
+
subject: S.optional(S.String.annotations({ description: 'URI of the component to display in the dialog.' })),
|
|
92
|
+
options: S.Struct({
|
|
93
|
+
state: S.optional(S.Boolean.annotations({ description: 'Whether the dialog is open or closed.' })),
|
|
94
|
+
blockAlign: S.optional(
|
|
95
|
+
S.Literal('start', 'center', 'end').annotations({ description: 'The alignment of the dialog.' }),
|
|
102
96
|
),
|
|
103
|
-
type:
|
|
104
|
-
props:
|
|
105
|
-
|
|
97
|
+
type: S.optional(S.Literal('default', 'alert').annotations({ description: 'The type of dialog.' })),
|
|
98
|
+
props: S.optional(
|
|
99
|
+
S.Record({ key: S.String, value: S.Any }).annotations({
|
|
106
100
|
description: 'Additional props for the dialog.',
|
|
107
101
|
}),
|
|
108
102
|
),
|
|
109
103
|
}),
|
|
110
104
|
}),
|
|
111
|
-
output:
|
|
105
|
+
output: S.Void,
|
|
112
106
|
}) {}
|
|
113
107
|
|
|
114
|
-
export class UpdatePopover extends
|
|
115
|
-
input:
|
|
116
|
-
part:
|
|
117
|
-
subject:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
options: Schema.Struct({
|
|
123
|
-
side: Schema.optional(
|
|
124
|
-
Schema.Literal('top', 'right', 'bottom', 'left').annotations({ description: 'The side of the anchor.' }),
|
|
108
|
+
export class UpdatePopover extends S.TaggedClass<UpdatePopover>()(UPDATE_LAYOUT, {
|
|
109
|
+
input: S.Struct({
|
|
110
|
+
part: S.Literal('popover').annotations({ description: 'Updating the popover.' }),
|
|
111
|
+
subject: S.optional(S.String.annotations({ description: 'URI of the component to display in the popover.' })),
|
|
112
|
+
options: S.Struct({
|
|
113
|
+
anchorId: S.String.annotations({ description: 'The id of the element to anchor the popover to.' }),
|
|
114
|
+
side: S.optional(
|
|
115
|
+
S.Literal('top', 'right', 'bottom', 'left').annotations({ description: 'The side of the anchor.' }),
|
|
125
116
|
),
|
|
126
|
-
state:
|
|
127
|
-
props:
|
|
128
|
-
|
|
117
|
+
state: S.optional(S.Boolean.annotations({ description: 'Whether the popover is open or closed.' })),
|
|
118
|
+
props: S.optional(
|
|
119
|
+
S.Record({ key: S.String, value: S.Any }).annotations({
|
|
129
120
|
description: 'Additional props for the popover.',
|
|
130
121
|
}),
|
|
131
122
|
),
|
|
132
|
-
})
|
|
133
|
-
Schema.extend(
|
|
134
|
-
Schema.Union(
|
|
135
|
-
Schema.Struct({
|
|
136
|
-
variant: Schema.Literal('virtual'),
|
|
137
|
-
anchor: Schema.Any.annotations({ description: 'The DOM element to anchor the popover to.' }),
|
|
138
|
-
}),
|
|
139
|
-
Schema.Struct({
|
|
140
|
-
variant: Schema.optional(Schema.Literal('react')),
|
|
141
|
-
anchorId: Schema.String.annotations({
|
|
142
|
-
description: 'An id that can be used to determine whether to render the anchor subcomponent.',
|
|
143
|
-
}),
|
|
144
|
-
}),
|
|
145
|
-
),
|
|
146
|
-
),
|
|
147
|
-
),
|
|
123
|
+
}),
|
|
148
124
|
}),
|
|
149
|
-
output:
|
|
125
|
+
output: S.Void,
|
|
150
126
|
}) {}
|
|
151
127
|
|
|
152
|
-
export const Toast =
|
|
153
|
-
id:
|
|
154
|
-
title:
|
|
155
|
-
description:
|
|
156
|
-
icon:
|
|
157
|
-
duration:
|
|
158
|
-
closeLabel:
|
|
159
|
-
actionLabel:
|
|
160
|
-
actionAlt:
|
|
161
|
-
onAction:
|
|
162
|
-
|
|
128
|
+
export const Toast = S.Struct({
|
|
129
|
+
id: S.String.annotations({ description: 'The id of the toast.' }),
|
|
130
|
+
title: S.optional(Label.annotations({ description: 'The title of the toast.' })),
|
|
131
|
+
description: S.optional(Label.annotations({ description: 'The description of the toast.' })),
|
|
132
|
+
icon: S.optional(S.String.annotations({ description: 'The icon of the toast.' })),
|
|
133
|
+
duration: S.optional(S.Number.annotations({ description: 'The duration of the toast.' })),
|
|
134
|
+
closeLabel: S.optional(Label.annotations({ description: 'The label of the close button.' })),
|
|
135
|
+
actionLabel: S.optional(Label.annotations({ description: 'The label of the action button.' })),
|
|
136
|
+
actionAlt: S.optional(Label.annotations({ description: 'The alt text of the action button.' })),
|
|
137
|
+
onAction: S.optional(
|
|
138
|
+
S.Any.annotations({ description: 'The action to perform when the action button is clicked.' }),
|
|
163
139
|
),
|
|
164
140
|
});
|
|
165
141
|
|
|
166
|
-
export interface Toast extends Omit<
|
|
142
|
+
export interface Toast extends Omit<S.Schema.Type<typeof Toast>, 'onAction'> {
|
|
167
143
|
onAction?: () => void;
|
|
168
144
|
}
|
|
169
145
|
|
|
170
|
-
export class AddToast extends
|
|
171
|
-
input:
|
|
172
|
-
part:
|
|
146
|
+
export class AddToast extends S.TaggedClass<AddToast>()(UPDATE_LAYOUT, {
|
|
147
|
+
input: S.Struct({
|
|
148
|
+
part: S.Literal('toast').annotations({ description: 'Adding a toast.' }),
|
|
173
149
|
subject: Toast.annotations({ description: 'The toast to add.' }),
|
|
174
150
|
}),
|
|
175
|
-
output:
|
|
151
|
+
output: S.Void,
|
|
176
152
|
}) {}
|
|
177
153
|
|
|
178
|
-
export class SwitchWorkspace extends
|
|
179
|
-
input:
|
|
180
|
-
part:
|
|
181
|
-
subject:
|
|
154
|
+
export class SwitchWorkspace extends S.TaggedClass<SwitchWorkspace>()(UPDATE_LAYOUT, {
|
|
155
|
+
input: S.Struct({
|
|
156
|
+
part: S.Literal('workspace').annotations({ description: 'Switching the workspace.' }),
|
|
157
|
+
subject: S.String.annotations({ description: 'The id of the workspace to switch to.' }),
|
|
182
158
|
}),
|
|
183
|
-
output:
|
|
159
|
+
output: S.Void,
|
|
184
160
|
}) {}
|
|
185
161
|
|
|
186
|
-
export class RevertWorkspace extends
|
|
187
|
-
input:
|
|
188
|
-
part:
|
|
189
|
-
options:
|
|
190
|
-
revert:
|
|
162
|
+
export class RevertWorkspace extends S.TaggedClass<RevertWorkspace>()(UPDATE_LAYOUT, {
|
|
163
|
+
input: S.Struct({
|
|
164
|
+
part: S.Literal('workspace').annotations({ description: 'Switching the workspace.' }),
|
|
165
|
+
options: S.Struct({
|
|
166
|
+
revert: S.Literal(true).annotations({ description: 'Revert to the previous workspace.' }),
|
|
191
167
|
}),
|
|
192
168
|
}),
|
|
193
|
-
output:
|
|
169
|
+
output: S.Void,
|
|
194
170
|
}) {}
|
|
195
171
|
|
|
196
|
-
export class Open extends
|
|
197
|
-
input:
|
|
198
|
-
part:
|
|
199
|
-
subject:
|
|
200
|
-
options:
|
|
201
|
-
|
|
202
|
-
state:
|
|
203
|
-
variant:
|
|
204
|
-
key:
|
|
205
|
-
|
|
206
|
-
description: 'If provided, will replace item with a matching key (id prefix).',
|
|
207
|
-
}),
|
|
172
|
+
export class Open extends S.TaggedClass<Open>()(UPDATE_LAYOUT, {
|
|
173
|
+
input: S.Struct({
|
|
174
|
+
part: S.Literal('main').annotations({ description: 'Opening an item in the main content area.' }),
|
|
175
|
+
subject: S.Array(S.String.annotations({ description: 'Ids of the items to open.' })),
|
|
176
|
+
options: S.optional(
|
|
177
|
+
S.Struct({
|
|
178
|
+
state: S.optional(S.Literal(true).annotations({ description: 'The items are being added.' })),
|
|
179
|
+
variant: S.optional(S.String.annotations({ description: 'The variant of the item to open.' })),
|
|
180
|
+
key: S.optional(
|
|
181
|
+
S.String.annotations({ description: 'If provided, will replace item with a matching key (id prefix).' }),
|
|
208
182
|
),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
Schema.Union(
|
|
216
|
-
Schema.Literal('start').annotations({ description: 'The items are being added before the pivot item.' }),
|
|
217
|
-
Schema.Literal('end').annotations({ description: 'The items are being added after the pivot item.' }),
|
|
183
|
+
scrollIntoView: S.optional(S.Boolean.annotations({ description: 'Scroll the items into view.' })),
|
|
184
|
+
pivotId: S.optional(S.String.annotations({ description: 'The id of the item to place new items next to.' })),
|
|
185
|
+
positioning: S.optional(
|
|
186
|
+
S.Union(
|
|
187
|
+
S.Literal('start').annotations({ description: 'The items are being added before the pivot item.' }),
|
|
188
|
+
S.Literal('end').annotations({ description: 'The items are being added after the pivot item.' }),
|
|
218
189
|
),
|
|
219
190
|
),
|
|
220
191
|
}),
|
|
221
192
|
),
|
|
222
193
|
}),
|
|
223
|
-
output:
|
|
194
|
+
output: S.Void,
|
|
224
195
|
}) {}
|
|
225
196
|
|
|
226
|
-
export class Set extends
|
|
227
|
-
input:
|
|
228
|
-
part:
|
|
229
|
-
subject:
|
|
230
|
-
options:
|
|
231
|
-
override:
|
|
232
|
-
description: 'Override the current items in the main content area.',
|
|
233
|
-
}),
|
|
197
|
+
export class Set extends S.TaggedClass<Set>()(UPDATE_LAYOUT, {
|
|
198
|
+
input: S.Struct({
|
|
199
|
+
part: S.Literal('main').annotations({ description: 'Setting items in the main content area.' }),
|
|
200
|
+
subject: S.Array(S.String.annotations({ description: 'Ids of the items to set.' })),
|
|
201
|
+
options: S.Struct({
|
|
202
|
+
override: S.Literal(true).annotations({ description: 'Override the current items in the main content area.' }),
|
|
234
203
|
}),
|
|
235
204
|
}),
|
|
236
|
-
output:
|
|
205
|
+
output: S.Void,
|
|
237
206
|
}) {}
|
|
238
207
|
|
|
239
|
-
export class Close extends
|
|
240
|
-
input:
|
|
241
|
-
part:
|
|
242
|
-
subject:
|
|
243
|
-
options:
|
|
244
|
-
state:
|
|
208
|
+
export class Close extends S.TaggedClass<Close>()(UPDATE_LAYOUT, {
|
|
209
|
+
input: S.Struct({
|
|
210
|
+
part: S.Literal('main').annotations({ description: 'Closing items in the main content area.' }),
|
|
211
|
+
subject: S.Array(S.String.annotations({ description: 'Ids of the items to close.' })),
|
|
212
|
+
options: S.Struct({
|
|
213
|
+
state: S.Literal(false).annotations({ description: 'The items are being removed.' }),
|
|
245
214
|
}),
|
|
246
215
|
}),
|
|
247
|
-
output:
|
|
216
|
+
output: S.Void,
|
|
248
217
|
}) {}
|
|
249
218
|
|
|
250
|
-
export class ScrollIntoView extends
|
|
251
|
-
input:
|
|
252
|
-
part:
|
|
253
|
-
subject:
|
|
254
|
-
options:
|
|
255
|
-
|
|
219
|
+
export class ScrollIntoView extends S.TaggedClass<ScrollIntoView>()(UPDATE_LAYOUT, {
|
|
220
|
+
input: S.Struct({
|
|
221
|
+
part: S.Literal('current').annotations({ description: 'Setting the current item' }),
|
|
222
|
+
subject: S.optional(S.String.annotations({ description: 'The id of the item to set as current.' })),
|
|
223
|
+
options: S.optional(
|
|
224
|
+
S.Record({ key: S.String, value: S.Any }).annotations({
|
|
256
225
|
description: 'Additional options for the scroll into view.',
|
|
257
226
|
}),
|
|
258
227
|
),
|
|
259
228
|
}),
|
|
260
|
-
output:
|
|
229
|
+
output: S.Void,
|
|
261
230
|
}) {}
|
|
262
231
|
|
|
263
|
-
export class Expose extends
|
|
264
|
-
input:
|
|
265
|
-
part:
|
|
266
|
-
subject:
|
|
232
|
+
export class Expose extends S.TaggedClass<Expose>()(UPDATE_LAYOUT, {
|
|
233
|
+
input: S.Struct({
|
|
234
|
+
part: S.Literal('navigation').annotations({ description: 'Exposing an item in the navigation area.' }),
|
|
235
|
+
subject: S.String.annotations({ description: 'The id of the item to expose.' }),
|
|
267
236
|
}),
|
|
268
|
-
output:
|
|
237
|
+
output: S.Void,
|
|
269
238
|
}) {}
|
|
270
239
|
}
|
|
@@ -2,16 +2,16 @@
|
|
|
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
|
-
export const ResourceKey =
|
|
8
|
-
export type ResourceKey =
|
|
7
|
+
export const ResourceKey = S.Union(S.String, S.Record({ key: S.String, value: S.Any }));
|
|
8
|
+
export type ResourceKey = S.Schema.Type<typeof ResourceKey>;
|
|
9
9
|
|
|
10
|
-
export const ResourceLanguage =
|
|
11
|
-
export type ResourceLanguage =
|
|
10
|
+
export const ResourceLanguage = S.Record({ key: S.String, value: ResourceKey });
|
|
11
|
+
export type ResourceLanguage = S.Schema.Type<typeof ResourceLanguage>;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* A resource is a collection of translations for a language.
|
|
15
15
|
*/
|
|
16
|
-
export const Resource =
|
|
17
|
-
export type Resource =
|
|
16
|
+
export const Resource = S.Record({ key: S.String, value: ResourceLanguage });
|
|
17
|
+
export type Resource = S.Schema.Type<typeof Resource>;
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Registry } from '@effect-rx/rx-react';
|
|
6
5
|
import { Effect } from 'effect';
|
|
7
|
-
import { describe, expect, it
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
8
7
|
|
|
9
|
-
import {
|
|
8
|
+
import { updateCounter } from '@dxos/echo-schema/testing';
|
|
9
|
+
import { registerSignalsRuntime } from '@dxos/echo-signals';
|
|
10
|
+
|
|
11
|
+
import { defineCapability, PluginsContext } from './capabilities';
|
|
12
|
+
|
|
13
|
+
registerSignalsRuntime();
|
|
10
14
|
|
|
11
15
|
const defaultOptions = {
|
|
12
16
|
activate: () => Effect.succeed(false),
|
|
@@ -15,122 +19,99 @@ const defaultOptions = {
|
|
|
15
19
|
|
|
16
20
|
describe('PluginsContext', () => {
|
|
17
21
|
it('should return empty array if no capabilities are contributed', () => {
|
|
18
|
-
const
|
|
19
|
-
const context = new PluginContext({ registry, ...defaultOptions });
|
|
22
|
+
const context = new PluginsContext(defaultOptions);
|
|
20
23
|
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
21
|
-
expect(context.
|
|
24
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([]);
|
|
22
25
|
});
|
|
23
26
|
|
|
24
27
|
it('should be able to contribute and request capabilities', () => {
|
|
25
|
-
const
|
|
26
|
-
const context = new PluginContext({ registry, ...defaultOptions });
|
|
28
|
+
const context = new PluginsContext(defaultOptions);
|
|
27
29
|
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
28
30
|
const implementation = { example: 'identifier' };
|
|
29
31
|
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
30
|
-
expect(context.
|
|
32
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([implementation]);
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
it('should be able to remove capabilities', () => {
|
|
34
|
-
const
|
|
35
|
-
const context = new PluginContext({ registry, ...defaultOptions });
|
|
36
|
+
const context = new PluginsContext(defaultOptions);
|
|
36
37
|
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
37
38
|
const implementation = { example: 'identifier' };
|
|
38
39
|
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
39
|
-
expect(context.
|
|
40
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([implementation]);
|
|
40
41
|
context.removeCapability(interfaceDef, implementation);
|
|
41
|
-
expect(context.
|
|
42
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([]);
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
it('should be able to contribute and request multiple implementations', () => {
|
|
45
|
-
const
|
|
46
|
-
const context = new PluginContext({ registry, ...defaultOptions });
|
|
46
|
+
const context = new PluginsContext(defaultOptions);
|
|
47
47
|
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
48
48
|
const implementation1 = { example: 'first' };
|
|
49
49
|
const implementation2 = { example: 'second' };
|
|
50
50
|
context.contributeCapability({ interface: interfaceDef, implementation: implementation1, module: 'test' });
|
|
51
51
|
context.contributeCapability({ interface: interfaceDef, implementation: implementation2, module: 'test' });
|
|
52
|
-
expect(context.
|
|
52
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([implementation1, implementation2]);
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it('should be able to request multiple capabilities', () => {
|
|
56
|
-
const
|
|
57
|
-
const context = new PluginContext({ registry, ...defaultOptions });
|
|
56
|
+
const context = new PluginsContext(defaultOptions);
|
|
58
57
|
const interfaceDef1 = defineCapability<{ one: number }>('@dxos/app-framework/test/one');
|
|
59
58
|
const interfaceDef2 = defineCapability<{ two: number }>('@dxos/app-framework/test/two');
|
|
60
59
|
const implementation1 = { one: 1 };
|
|
61
60
|
const implementation2 = { two: 2 };
|
|
62
61
|
context.contributeCapability({ interface: interfaceDef1, implementation: implementation1, module: 'test' });
|
|
63
62
|
context.contributeCapability({ interface: interfaceDef2, implementation: implementation2, module: 'test' });
|
|
64
|
-
expect(context.
|
|
65
|
-
expect(context.
|
|
63
|
+
expect(context.requestCapabilities(interfaceDef1)).toEqual([implementation1]);
|
|
64
|
+
expect(context.requestCapabilities(interfaceDef2)).toEqual([implementation2]);
|
|
66
65
|
});
|
|
67
66
|
|
|
68
67
|
it('should be reactive', () => {
|
|
69
|
-
const
|
|
70
|
-
const context = new PluginContext({ registry, ...defaultOptions });
|
|
68
|
+
const context = new PluginsContext(defaultOptions);
|
|
71
69
|
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
count++;
|
|
71
|
+
using updates = updateCounter(() => {
|
|
72
|
+
context.requestCapabilities(interfaceDef);
|
|
76
73
|
});
|
|
77
|
-
onTestFinished(() => cancel());
|
|
78
|
-
expect(count).toEqual(0);
|
|
79
74
|
|
|
80
|
-
|
|
81
|
-
expect(count).toEqual(1);
|
|
75
|
+
expect(updates.count).toEqual(0);
|
|
82
76
|
|
|
83
77
|
const implementation = { example: 'identifier' };
|
|
84
78
|
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
85
|
-
expect(count).toEqual(
|
|
79
|
+
expect(updates.count).toEqual(1);
|
|
86
80
|
|
|
87
81
|
context.removeCapability(interfaceDef, implementation);
|
|
88
|
-
expect(count).toEqual(
|
|
82
|
+
expect(updates.count).toEqual(2);
|
|
89
83
|
});
|
|
90
84
|
|
|
91
85
|
it('should not be reactive to changes within the implementation', () => {
|
|
92
|
-
const
|
|
93
|
-
const context = new PluginContext({ registry, ...defaultOptions });
|
|
86
|
+
const context = new PluginsContext(defaultOptions);
|
|
94
87
|
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
count++;
|
|
89
|
+
using updates = updateCounter(() => {
|
|
90
|
+
context.requestCapabilities(interfaceDef);
|
|
99
91
|
});
|
|
100
|
-
onTestFinished(() => cancel());
|
|
101
|
-
expect(count).toEqual(0);
|
|
102
92
|
|
|
103
|
-
|
|
104
|
-
expect(count).toEqual(1);
|
|
93
|
+
expect(updates.count).toEqual(0);
|
|
105
94
|
|
|
106
95
|
const implementation = { example: 'identifier' };
|
|
107
96
|
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
108
|
-
expect(count).toEqual(
|
|
97
|
+
expect(updates.count).toEqual(1);
|
|
109
98
|
|
|
110
99
|
implementation.example = 'updated';
|
|
111
|
-
expect(count).toEqual(
|
|
100
|
+
expect(updates.count).toEqual(1);
|
|
112
101
|
|
|
113
|
-
const capabilities = context.
|
|
102
|
+
const capabilities = context.requestCapabilities(interfaceDef);
|
|
114
103
|
expect(capabilities).toEqual([implementation]);
|
|
115
104
|
expect(capabilities[0].example).toEqual('updated');
|
|
116
|
-
expect(count).toEqual(
|
|
105
|
+
expect(updates.count).toEqual(1);
|
|
117
106
|
});
|
|
118
107
|
|
|
119
108
|
it('should be able to wait for a capability', async () => {
|
|
120
|
-
const
|
|
121
|
-
const context = new PluginContext({ registry, ...defaultOptions });
|
|
109
|
+
const context = new PluginsContext(defaultOptions);
|
|
122
110
|
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
123
|
-
|
|
124
|
-
let capability: { example: string } | undefined;
|
|
125
|
-
const cancel = registry.subscribe(context.capabilities(interfaceDef), (capabilities) => {
|
|
126
|
-
capability = capabilities[0];
|
|
127
|
-
});
|
|
128
|
-
onTestFinished(() => cancel());
|
|
129
|
-
registry.get(context.capabilities(interfaceDef));
|
|
130
|
-
expect(capability).toBeUndefined();
|
|
131
|
-
|
|
132
111
|
const implementation = { example: 'identifier' };
|
|
112
|
+
const promise = context.waitForCapability(interfaceDef);
|
|
133
113
|
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
114
|
+
const capability = await promise;
|
|
134
115
|
expect(capability).toEqual(implementation);
|
|
135
116
|
});
|
|
136
117
|
});
|