@dxos/app-framework 0.7.4 → 0.7.5-feature-compute.4d9d99a
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/chunk-EGGZVV7Q.mjs +1595 -0
- package/dist/lib/browser/chunk-EGGZVV7Q.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +136 -527
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +67 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/node/chunk-UBX6GP2N.cjs +1639 -0
- package/dist/lib/node/chunk-UBX6GP2N.cjs.map +7 -0
- package/dist/lib/node/index.cjs +141 -551
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +91 -0
- package/dist/lib/node/testing/index.cjs.map +7 -0
- package/dist/lib/node-esm/chunk-HG5P55WF.mjs +1597 -0
- package/dist/lib/node-esm/chunk-HG5P55WF.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +136 -527
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +68 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/types/src/App.d.ts +22 -13
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/common/capabilities.d.ts +340 -0
- package/dist/types/src/common/capabilities.d.ts.map +1 -0
- package/dist/types/src/common/events.d.ts +41 -0
- package/dist/types/src/common/events.d.ts.map +1 -0
- package/dist/types/src/common/file.d.ts +14 -0
- package/dist/types/src/common/file.d.ts.map +1 -0
- package/dist/types/src/common/graph.d.ts +21 -0
- package/dist/types/src/common/graph.d.ts.map +1 -0
- package/dist/types/src/{plugins/common → common}/index.d.ts +3 -1
- package/dist/types/src/common/index.d.ts.map +1 -0
- package/dist/types/src/common/layout.d.ts +165 -0
- package/dist/types/src/common/layout.d.ts.map +1 -0
- package/dist/types/src/{plugins/common → common}/navigation.d.ts +77 -32
- package/dist/types/src/common/navigation.d.ts.map +1 -0
- package/dist/types/src/common/surface.d.ts +68 -0
- package/dist/types/src/common/surface.d.ts.map +1 -0
- package/dist/types/src/{plugins/common → common}/translations.d.ts +0 -11
- package/dist/types/src/common/translations.d.ts.map +1 -0
- package/dist/types/src/core/capabilities.d.ts +90 -0
- package/dist/types/src/core/capabilities.d.ts.map +1 -0
- package/dist/types/src/core/capabilities.test.d.ts +2 -0
- package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
- package/dist/types/src/core/events.d.ts +58 -0
- package/dist/types/src/core/events.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +5 -0
- package/dist/types/src/core/index.d.ts.map +1 -0
- package/dist/types/src/core/manager.d.ts +126 -0
- package/dist/types/src/core/manager.d.ts.map +1 -0
- package/dist/types/src/core/manager.test.d.ts +2 -0
- package/dist/types/src/core/manager.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin.d.ts +94 -0
- package/dist/types/src/core/plugin.d.ts.map +1 -0
- package/dist/types/src/helpers.d.ts +10 -0
- package/dist/types/src/helpers.d.ts.map +1 -0
- package/dist/types/src/helpers.test.d.ts +2 -0
- package/dist/types/src/helpers.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/debug/Debug.d.ts +6 -0
- package/dist/types/src/playground/debug/Debug.d.ts.map +1 -0
- package/dist/types/src/playground/debug/index.d.ts +2 -0
- package/dist/types/src/playground/debug/index.d.ts.map +1 -0
- package/dist/types/src/playground/debug/plugin.d.ts +2 -0
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/generator/Main.d.ts +6 -0
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts +6 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
- package/dist/types/src/playground/generator/generator.d.ts +5 -0
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -0
- package/dist/types/src/playground/generator/index.d.ts +3 -0
- package/dist/types/src/playground/generator/index.d.ts.map +1 -0
- package/dist/types/src/playground/generator/plugin.d.ts +2 -0
- package/dist/types/src/playground/generator/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/layout/Layout.d.ts +8 -0
- package/dist/types/src/playground/layout/Layout.d.ts.map +1 -0
- package/dist/types/src/playground/layout/index.d.ts +2 -0
- package/dist/types/src/playground/layout/index.d.ts.map +1 -0
- package/dist/types/src/playground/layout/plugin.d.ts +2 -0
- package/dist/types/src/playground/layout/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/logger/Toolbar.d.ts +6 -0
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -0
- package/dist/types/src/playground/logger/index.d.ts +2 -0
- package/dist/types/src/playground/logger/index.d.ts.map +1 -0
- package/dist/types/src/playground/logger/plugin.d.ts +2 -0
- package/dist/types/src/playground/logger/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/logger/schema.d.ts +13 -0
- package/dist/types/src/playground/logger/schema.d.ts.map +1 -0
- package/dist/types/src/playground/playground.stories.d.ts +10 -0
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/IntentContext.d.ts +8 -0
- package/dist/types/src/plugin-intent/IntentContext.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +2 -0
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/actions.d.ts +23 -0
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/errors.d.ts +16 -0
- package/dist/types/src/plugin-intent/errors.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/index.d.ts +6 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +106 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +2 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent.d.ts +68 -0
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/actions.d.ts +17 -0
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/index.d.ts +3 -0
- package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
- package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
- package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
- package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
- package/dist/types/src/react/Surface.d.ts +12 -0
- package/dist/types/src/react/Surface.d.ts.map +1 -0
- package/dist/types/src/react/index.d.ts +5 -0
- package/dist/types/src/react/index.d.ts.map +1 -0
- package/dist/types/src/react/useCapabilities.d.ts +13 -0
- package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +10 -0
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +30 -14
- package/project.json +2 -1
- package/src/App.tsx +138 -34
- package/src/common/capabilities.ts +82 -0
- package/src/common/events.ts +63 -0
- package/src/common/file.ts +22 -0
- package/src/common/graph.ts +30 -0
- package/src/{plugins/common → common}/index.ts +3 -1
- package/src/common/layout.ts +157 -0
- package/src/{plugins/common → common}/navigation.ts +59 -45
- package/src/common/surface.ts +81 -0
- package/src/common/translations.ts +18 -0
- package/src/core/capabilities.test.ts +116 -0
- package/src/core/capabilities.ts +213 -0
- package/src/core/events.ts +58 -0
- package/src/core/index.ts +8 -0
- package/src/core/manager.test.ts +567 -0
- package/src/core/manager.ts +497 -0
- package/src/core/plugin.ts +128 -0
- package/src/helpers.test.ts +97 -0
- package/src/helpers.ts +45 -0
- package/src/index.ts +6 -3
- package/src/playground/debug/Debug.tsx +39 -0
- package/src/playground/debug/index.ts +5 -0
- package/src/playground/debug/plugin.ts +17 -0
- package/src/playground/generator/Main.tsx +71 -0
- package/src/playground/generator/Toolbar.tsx +46 -0
- package/src/playground/generator/generator.ts +23 -0
- package/src/playground/generator/index.ts +6 -0
- package/src/playground/generator/plugin.ts +18 -0
- package/src/playground/layout/Layout.tsx +33 -0
- package/src/playground/layout/index.ts +5 -0
- package/src/playground/layout/plugin.ts +17 -0
- package/src/playground/logger/Toolbar.tsx +28 -0
- package/src/playground/logger/index.ts +5 -0
- package/src/playground/logger/plugin.ts +33 -0
- package/src/playground/logger/schema.ts +12 -0
- package/src/playground/playground.stories.tsx +34 -0
- package/src/plugin-intent/IntentContext.tsx +34 -0
- package/src/plugin-intent/IntentPlugin.tsx +60 -0
- package/src/plugin-intent/actions.ts +22 -0
- package/src/plugin-intent/errors.ts +39 -0
- package/src/plugin-intent/index.ts +9 -0
- package/src/plugin-intent/intent-dispatcher.test.ts +280 -0
- package/src/plugin-intent/intent-dispatcher.ts +269 -0
- package/src/plugin-intent/intent.ts +146 -0
- package/src/plugin-settings/SettingsPlugin.ts +29 -0
- package/src/plugin-settings/actions.ts +17 -0
- package/src/plugin-settings/index.ts +6 -0
- package/src/react/PluginManagerProvider.ts +22 -0
- package/src/react/Surface.tsx +72 -0
- package/src/react/index.ts +8 -0
- package/src/react/useCapabilities.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/withPluginManager.stories.tsx +47 -0
- package/src/testing/withPluginManager.tsx +67 -0
- package/tsconfig.json +51 -2
- package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
- package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
- package/dist/lib/browser/chunk-653Y45CL.mjs +0 -41
- package/dist/lib/browser/chunk-653Y45CL.mjs.map +0 -7
- package/dist/lib/browser/chunk-FRXJ25VI.mjs +0 -214
- package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +0 -7
- package/dist/lib/browser/chunk-YXM35XRE.mjs +0 -213
- package/dist/lib/browser/chunk-YXM35XRE.mjs.map +0 -7
- package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs +0 -22
- package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs.map +0 -7
- package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +0 -11
- package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs.map +0 -7
- package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs +0 -24
- package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs.map +0 -7
- package/dist/lib/node/chunk-JZ2JVKRY.cjs +0 -58
- package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +0 -7
- package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
- package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
- package/dist/lib/node/chunk-QSVP5HOW.cjs +0 -238
- package/dist/lib/node/chunk-QSVP5HOW.cjs.map +0 -7
- package/dist/lib/node/chunk-SOVLKUWI.cjs +0 -236
- package/dist/lib/node/chunk-SOVLKUWI.cjs.map +0 -7
- package/dist/lib/node/plugin-intent-FVFR2LKB.cjs +0 -43
- package/dist/lib/node/plugin-intent-FVFR2LKB.cjs.map +0 -7
- package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs +0 -32
- package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +0 -7
- package/dist/lib/node/plugin-surface-YWDRXQTD.cjs +0 -45
- package/dist/lib/node/plugin-surface-YWDRXQTD.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-2R4GVK7O.mjs +0 -215
- package/dist/lib/node-esm/chunk-2R4GVK7O.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
- package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YFMFQBB4.mjs +0 -214
- package/dist/lib/node-esm/chunk-YFMFQBB4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +0 -43
- package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs +0 -23
- package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +0 -12
- package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs +0 -25
- package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs.map +0 -7
- package/dist/types/src/plugins/common/file.d.ts +0 -22
- package/dist/types/src/plugins/common/file.d.ts.map +0 -1
- package/dist/types/src/plugins/common/graph.d.ts +0 -51
- package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
- package/dist/types/src/plugins/common/index.d.ts.map +0 -1
- package/dist/types/src/plugins/common/layout.d.ts +0 -202
- package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
- package/dist/types/src/plugins/common/metadata.d.ts +0 -16
- package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
- package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
- package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
- package/dist/types/src/plugins/helpers.d.ts +0 -41
- package/dist/types/src/plugins/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/index.d.ts +0 -7
- package/dist/types/src/plugins/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -21
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
- package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
- package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/index.d.ts +0 -4
- package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -98
- package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
- package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts +0 -21
- package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
- package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/helpers.d.ts +0 -6
- package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -6
- package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent.d.ts +0 -81
- package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -5
- package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -20
- package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
- package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
- package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
- package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -13
- package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -62
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts +0 -39
- package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
- package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
- package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
- package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -16
- package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
- package/src/plugins/common/file.ts +0 -36
- package/src/plugins/common/graph.ts +0 -70
- package/src/plugins/common/layout.ts +0 -155
- package/src/plugins/common/metadata.ts +0 -29
- package/src/plugins/common/translations.ts +0 -36
- package/src/plugins/helpers.ts +0 -92
- package/src/plugins/index.ts +0 -11
- package/src/plugins/plugin-host/HostPlugin.tsx +0 -96
- package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
- package/src/plugins/plugin-host/PluginContext.tsx +0 -79
- package/src/plugins/plugin-host/index.ts +0 -8
- package/src/plugins/plugin-host/plugin.test.ts +0 -158
- package/src/plugins/plugin-host/plugin.ts +0 -126
- package/src/plugins/plugin-intent/IntentContext.tsx +0 -49
- package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -151
- package/src/plugins/plugin-intent/helpers.ts +0 -11
- package/src/plugins/plugin-intent/index.ts +0 -12
- package/src/plugins/plugin-intent/intent.ts +0 -101
- package/src/plugins/plugin-intent/meta.ts +0 -9
- package/src/plugins/plugin-intent/provides.ts +0 -38
- package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
- package/src/plugins/plugin-settings/index.ts +0 -9
- package/src/plugins/plugin-settings/meta.ts +0 -9
- package/src/plugins/plugin-settings/provides.ts +0 -29
- package/src/plugins/plugin-surface/Surface.tsx +0 -195
- package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -33
- package/src/plugins/plugin-surface/SurfaceRootContext.tsx +0 -60
- package/src/plugins/plugin-surface/helpers.ts +0 -22
- package/src/plugins/plugin-surface/index.ts +0 -14
- package/src/plugins/plugin-surface/meta.ts +0 -9
- package/src/plugins/plugin-surface/provides.ts +0 -26
- /package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
- /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { S } from '@dxos/echo-schema';
|
|
6
|
+
|
|
7
|
+
import { Label } from '../plugin-intent';
|
|
8
|
+
|
|
9
|
+
//
|
|
10
|
+
// Provides
|
|
11
|
+
//
|
|
12
|
+
|
|
13
|
+
export const Toast = S.Struct({
|
|
14
|
+
id: S.String,
|
|
15
|
+
title: S.optional(Label),
|
|
16
|
+
description: S.optional(Label),
|
|
17
|
+
icon: S.optional(S.String),
|
|
18
|
+
duration: S.optional(S.Number),
|
|
19
|
+
closeLabel: S.optional(Label),
|
|
20
|
+
actionLabel: S.optional(Label),
|
|
21
|
+
actionAlt: S.optional(Label),
|
|
22
|
+
// TODO(wittjosiah): Make class with customizable method?
|
|
23
|
+
onAction: S.optional(S.Any),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type Toast = S.Schema.Type<typeof Toast>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Basic state provided by a layout plugin.
|
|
30
|
+
*
|
|
31
|
+
* Layout provides the state of global UI landmarks, such as the sidebar, dialog, and popover.
|
|
32
|
+
* Generally only one dialog or popover should be open at a time, a layout plugin should manage this.
|
|
33
|
+
* For other landmarks, such as toasts, rendering them in the layout prevents them from unmounting when navigating.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const LayoutMode = S.Union(S.Literal('deck'), S.Literal('solo'), S.Literal('fullscreen'));
|
|
37
|
+
export const isLayoutMode = (value: any): value is LayoutMode => S.is(LayoutMode)(value);
|
|
38
|
+
export type LayoutMode = S.Schema.Type<typeof LayoutMode>;
|
|
39
|
+
|
|
40
|
+
export const Layout = S.mutable(
|
|
41
|
+
S.Struct({
|
|
42
|
+
layoutMode: LayoutMode,
|
|
43
|
+
|
|
44
|
+
sidebarOpen: S.Boolean,
|
|
45
|
+
complementarySidebarOpen: S.Boolean,
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Data to be passed to the complementary sidebar Surface.
|
|
48
|
+
*/
|
|
49
|
+
complementarySidebarContent: S.optional(S.Any),
|
|
50
|
+
|
|
51
|
+
dialogOpen: S.Boolean,
|
|
52
|
+
/**
|
|
53
|
+
* Data to be passed to the dialog Surface.
|
|
54
|
+
*/
|
|
55
|
+
dialogContent: S.optional(S.Any),
|
|
56
|
+
// TODO(wittjosiah): Custom properties?
|
|
57
|
+
dialogBlockAlign: S.optional(S.Literal('start', 'center')),
|
|
58
|
+
dialogType: S.optional(S.Literal('default', 'alert')),
|
|
59
|
+
|
|
60
|
+
popoverOpen: S.Boolean,
|
|
61
|
+
/**
|
|
62
|
+
* Data to be passed to the popover Surface.
|
|
63
|
+
*/
|
|
64
|
+
popoverContent: S.optional(S.Any),
|
|
65
|
+
popoverAnchorId: S.optional(S.String),
|
|
66
|
+
|
|
67
|
+
toasts: S.mutable(S.Array(Toast)),
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The identifier of a component to scroll into view when it is mounted.
|
|
71
|
+
*/
|
|
72
|
+
scrollIntoView: S.optional(S.String),
|
|
73
|
+
}),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export type Layout = S.Schema.Type<typeof Layout>;
|
|
77
|
+
|
|
78
|
+
//
|
|
79
|
+
// Intents
|
|
80
|
+
//
|
|
81
|
+
|
|
82
|
+
export const LAYOUT_PLUGIN = 'dxos.org/plugin/layout';
|
|
83
|
+
export const LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Expected payload for layout actions.
|
|
87
|
+
*/
|
|
88
|
+
export namespace LayoutAction {
|
|
89
|
+
export class SetLayout extends S.TaggedClass<SetLayout>()(`${LAYOUT_ACTION}/set-layout`, {
|
|
90
|
+
input: S.Struct({
|
|
91
|
+
/**
|
|
92
|
+
* Element to set the state of.
|
|
93
|
+
*/
|
|
94
|
+
element: S.Literal('fullscreen', 'sidebar', 'complementary', 'dialog', 'popover', 'toast'),
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Whether the element is on or off.
|
|
98
|
+
*
|
|
99
|
+
* If omitted, the element's state will be toggled or set based on other provided data.
|
|
100
|
+
* For example, if `component` is provided, the state will be set to `true`.
|
|
101
|
+
*/
|
|
102
|
+
state: S.optional(S.Boolean),
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Component to render in the dialog or popover.
|
|
106
|
+
*/
|
|
107
|
+
component: S.optional(S.String),
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Data to be passed to the dialog or popover Surface.
|
|
111
|
+
*/
|
|
112
|
+
subject: S.optional(S.Any),
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Anchor ID for the popover.
|
|
116
|
+
*/
|
|
117
|
+
anchorId: S.optional(S.String),
|
|
118
|
+
|
|
119
|
+
// TODO(wittjosiah): Custom properties?
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Block alignment for the dialog.
|
|
123
|
+
*/
|
|
124
|
+
dialogBlockAlign: S.optional(S.Literal('start', 'center')),
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Type of dialog.
|
|
128
|
+
*/
|
|
129
|
+
dialogType: S.optional(S.Literal('default', 'alert')),
|
|
130
|
+
}),
|
|
131
|
+
output: S.Void,
|
|
132
|
+
}) {}
|
|
133
|
+
|
|
134
|
+
// TODO(wittjosiah): Do all these need to be separate actions?
|
|
135
|
+
|
|
136
|
+
export class SetLayoutMode extends S.TaggedClass<SetLayoutMode>()(`${LAYOUT_ACTION}/set-layout-mode`, {
|
|
137
|
+
input: S.Union(
|
|
138
|
+
S.Struct({
|
|
139
|
+
layoutMode: LayoutMode,
|
|
140
|
+
}),
|
|
141
|
+
S.Struct({
|
|
142
|
+
revert: S.Literal(true),
|
|
143
|
+
}),
|
|
144
|
+
),
|
|
145
|
+
output: S.Void,
|
|
146
|
+
}) {}
|
|
147
|
+
|
|
148
|
+
export class ScrollIntoView extends S.TaggedClass<ScrollIntoView>()(`${LAYOUT_ACTION}/scroll-into-view`, {
|
|
149
|
+
input: S.Struct({
|
|
150
|
+
id: S.optional(S.String),
|
|
151
|
+
// TODO(wittjosiah): Factor out to thread scroll into view action?
|
|
152
|
+
cursor: S.optional(S.String),
|
|
153
|
+
ref: S.optional(S.String),
|
|
154
|
+
}),
|
|
155
|
+
output: S.Void,
|
|
156
|
+
}) {}
|
|
157
|
+
}
|
|
@@ -3,13 +3,9 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Schema as S } from '@effect/schema';
|
|
6
|
-
import { z } from 'zod';
|
|
7
6
|
|
|
8
7
|
import { pick } from '@dxos/util';
|
|
9
8
|
|
|
10
|
-
import { type Plugin } from '../plugin-host';
|
|
11
|
-
import { type IntentData } from '../plugin-intent';
|
|
12
|
-
|
|
13
9
|
// NOTE(thure): These are chosen from RFC 1738’s `safe` characters: http://www.faqs.org/rfcs/rfc1738.html
|
|
14
10
|
export const SLUG_LIST_SEPARATOR = '+';
|
|
15
11
|
export const SLUG_ENTRY_SEPARATOR = '_';
|
|
@@ -39,7 +35,14 @@ export type LayoutParts = S.Schema.Type<typeof LayoutPartsSchema>;
|
|
|
39
35
|
const LayoutCoordinateSchema = S.mutable(S.Struct({ part: LayoutPartSchema, entryId: S.String }));
|
|
40
36
|
export type LayoutCoordinate = S.Schema.Type<typeof LayoutCoordinateSchema>;
|
|
41
37
|
|
|
42
|
-
const PartAdjustmentSchema = S.Union(
|
|
38
|
+
const PartAdjustmentSchema = S.Union(
|
|
39
|
+
S.Literal('increment-start'),
|
|
40
|
+
S.Literal('increment-end'),
|
|
41
|
+
S.Literal('pin-start'),
|
|
42
|
+
S.Literal('pin-end'),
|
|
43
|
+
S.Literal('close'),
|
|
44
|
+
S.Literal('solo'),
|
|
45
|
+
);
|
|
43
46
|
export type PartAdjustment = S.Schema.Type<typeof PartAdjustmentSchema>;
|
|
44
47
|
|
|
45
48
|
const LayoutAdjustmentSchema = S.mutable(
|
|
@@ -48,8 +51,8 @@ const LayoutAdjustmentSchema = S.mutable(
|
|
|
48
51
|
export type LayoutAdjustment = S.Schema.Type<typeof LayoutAdjustmentSchema>;
|
|
49
52
|
|
|
50
53
|
/** @deprecated */
|
|
51
|
-
export const ActiveParts =
|
|
52
|
-
export type ActiveParts =
|
|
54
|
+
export const ActiveParts = S.Record({ key: S.String, value: S.Union(S.String, S.mutable(S.Array(S.String))) });
|
|
55
|
+
export type ActiveParts = S.Schema.Type<typeof ActiveParts>;
|
|
53
56
|
|
|
54
57
|
// TODO(burdon): Where should this go?
|
|
55
58
|
export type LayoutContainerProps<T> = T & { role?: string; coordinate?: LayoutCoordinate };
|
|
@@ -79,19 +82,6 @@ export const isLayoutAdjustment = (value: unknown): value is LayoutAdjustment =>
|
|
|
79
82
|
return S.is(LayoutAdjustmentSchema)(value);
|
|
80
83
|
};
|
|
81
84
|
|
|
82
|
-
export const parseNavigationPlugin = (plugin: Plugin): Plugin<LocationProvides> | undefined => {
|
|
83
|
-
const location = (plugin.provides as any)?.location;
|
|
84
|
-
if (!location) {
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (S.is(LocationProvidesSchema)({ location })) {
|
|
89
|
-
return plugin as Plugin<LocationProvides>;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return undefined;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
85
|
/**
|
|
96
86
|
* Utilities.
|
|
97
87
|
*/
|
|
@@ -135,51 +125,75 @@ export const partLength = (layout: LayoutParts | undefined, part: LayoutPart | u
|
|
|
135
125
|
// Intents
|
|
136
126
|
//
|
|
137
127
|
|
|
138
|
-
const NAVIGATION_PLUGIN = 'dxos.org/plugin/navigation';
|
|
139
|
-
|
|
140
|
-
const NAVIGATION_ACTION = `${NAVIGATION_PLUGIN}/action`;
|
|
141
|
-
|
|
142
|
-
export enum NavigationAction {
|
|
143
|
-
OPEN = `${NAVIGATION_ACTION}/open`,
|
|
144
|
-
ADD_TO_ACTIVE = `${NAVIGATION_ACTION}/add-to-active`,
|
|
145
|
-
SET = `${NAVIGATION_ACTION}/set`,
|
|
146
|
-
ADJUST = `${NAVIGATION_ACTION}/adjust`,
|
|
147
|
-
CLOSE = `${NAVIGATION_ACTION}/close`,
|
|
148
|
-
EXPOSE = `${NAVIGATION_ACTION}/expose`,
|
|
149
|
-
}
|
|
128
|
+
export const NAVIGATION_PLUGIN = 'dxos.org/plugin/navigation';
|
|
129
|
+
export const NAVIGATION_ACTION = `${NAVIGATION_PLUGIN}/action`;
|
|
150
130
|
|
|
151
131
|
/**
|
|
152
132
|
* Expected payload for navigation actions.
|
|
153
133
|
*/
|
|
134
|
+
// TODO(wittjosiah): These seem to be too deck-specific.
|
|
154
135
|
export namespace NavigationAction {
|
|
155
136
|
/**
|
|
156
137
|
* An additive overlay to apply to `location.active` (i.e. the result is a union of previous active and the argument)
|
|
157
138
|
*/
|
|
158
|
-
export
|
|
139
|
+
export class Open extends S.TaggedClass<Open>()(`${NAVIGATION_ACTION}/open`, {
|
|
140
|
+
input: S.Struct({
|
|
141
|
+
activeParts: ActiveParts,
|
|
142
|
+
noToggle: S.optional(S.Boolean),
|
|
143
|
+
}),
|
|
144
|
+
output: S.Struct({
|
|
145
|
+
open: S.Array(S.String),
|
|
146
|
+
}),
|
|
147
|
+
}) {}
|
|
159
148
|
|
|
160
149
|
/**
|
|
161
150
|
* Payload for adding an item to the active items.
|
|
162
151
|
*/
|
|
163
|
-
export
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
152
|
+
export class AddToActive extends S.TaggedClass<AddToActive>()(`${NAVIGATION_ACTION}/add-to-active`, {
|
|
153
|
+
input: S.Struct({
|
|
154
|
+
id: S.String,
|
|
155
|
+
part: LayoutPartSchema,
|
|
156
|
+
scrollIntoView: S.optional(S.Boolean),
|
|
157
|
+
pivotId: S.optional(S.String),
|
|
158
|
+
positioning: S.optional(S.Literal('start', 'end')),
|
|
159
|
+
}),
|
|
160
|
+
output: S.Void,
|
|
161
|
+
}) {}
|
|
170
162
|
|
|
171
163
|
/**
|
|
172
|
-
*
|
|
164
|
+
* The active parts to directly set, to be used when working with URLs or restoring a specific state.
|
|
173
165
|
*/
|
|
174
|
-
export
|
|
166
|
+
export class Set extends S.TaggedClass<Set>()(`${NAVIGATION_ACTION}/set`, {
|
|
167
|
+
input: S.Struct({
|
|
168
|
+
activeParts: ActiveParts,
|
|
169
|
+
}),
|
|
170
|
+
output: S.Void,
|
|
171
|
+
}) {}
|
|
175
172
|
|
|
176
173
|
/**
|
|
177
|
-
*
|
|
174
|
+
* A subtractive overlay to apply to `location.active` (i.e. the result is a subtraction from the previous active of the argument)
|
|
178
175
|
*/
|
|
179
|
-
export
|
|
176
|
+
export class Close extends S.TaggedClass<Close>()(`${NAVIGATION_ACTION}/close`, {
|
|
177
|
+
input: S.Struct({
|
|
178
|
+
activeParts: ActiveParts,
|
|
179
|
+
noToggle: S.optional(S.Boolean),
|
|
180
|
+
}),
|
|
181
|
+
output: S.Void,
|
|
182
|
+
}) {}
|
|
180
183
|
|
|
181
184
|
/**
|
|
182
185
|
* An atomic transaction to apply to `location.active`, describing which element to (attempt to) move to which location.
|
|
183
186
|
*/
|
|
184
|
-
export
|
|
187
|
+
export class Adjust extends S.TaggedClass<Adjust>()(`${NAVIGATION_ACTION}/adjust`, {
|
|
188
|
+
input: LayoutAdjustmentSchema,
|
|
189
|
+
output: S.Void,
|
|
190
|
+
}) {}
|
|
191
|
+
|
|
192
|
+
// TODO(wittjosiah): This action seems unrelated to the others.
|
|
193
|
+
export class Expose extends S.TaggedClass<Expose>()(`${NAVIGATION_ACTION}/expose`, {
|
|
194
|
+
input: S.Struct({
|
|
195
|
+
id: S.String,
|
|
196
|
+
}),
|
|
197
|
+
output: S.Void,
|
|
198
|
+
}) {}
|
|
185
199
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type JSX, type ForwardedRef, type PropsWithChildren, type ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type GuardedType, type MakeOptional, type Disposition } from '@dxos/util';
|
|
8
|
+
|
|
9
|
+
import { type ErrorBoundary } from '../react';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SurfaceProps are the props that are passed to the Surface component.
|
|
13
|
+
*/
|
|
14
|
+
export type SurfaceProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{
|
|
15
|
+
/**
|
|
16
|
+
* If specified, the Surface will be wrapped in an error boundary.
|
|
17
|
+
* The fallback component will be rendered if an error occurs.
|
|
18
|
+
*/
|
|
19
|
+
fallback?: ErrorBoundary['props']['fallback'];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* If specified, the Surface will be wrapped in a suspense boundary.
|
|
23
|
+
* The placeholder component will be rendered while the surface component is loading.
|
|
24
|
+
*/
|
|
25
|
+
placeholder?: ReactNode;
|
|
26
|
+
}> &
|
|
27
|
+
MakeOptional<CoreSurfaceProps<T>, 'id' | 'data'> & {
|
|
28
|
+
/**
|
|
29
|
+
* Additional props to pass to the component.
|
|
30
|
+
* These props are not used by Surface itself but may be used by components which resolve the surface.
|
|
31
|
+
*/
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.
|
|
36
|
+
type CoreSurfaceProps<T extends Record<string, any> = Record<string, unknown>> = {
|
|
37
|
+
/**
|
|
38
|
+
* ID for debugging.
|
|
39
|
+
*/
|
|
40
|
+
id: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Role defines how the data should be rendered.
|
|
44
|
+
*/
|
|
45
|
+
role: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The data to be rendered by the surface.
|
|
49
|
+
*/
|
|
50
|
+
data: T;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* If more than one component is resolved, the limit determines how many are rendered.
|
|
54
|
+
*/
|
|
55
|
+
limit?: number | undefined;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type SurfaceComponentProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<
|
|
59
|
+
CoreSurfaceProps<T> & { [key: string]: unknown }
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* React component used to render a surface once is has matched.
|
|
64
|
+
*/
|
|
65
|
+
export type SurfaceComponent<T extends Record<string, any> = Record<string, unknown>> = (
|
|
66
|
+
props: SurfaceComponentProps<T>,
|
|
67
|
+
forwardedRef: ForwardedRef<HTMLElement>,
|
|
68
|
+
) => JSX.Element | null;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Definition of when a SurfaceComponent should be rendered.
|
|
72
|
+
*/
|
|
73
|
+
export type SurfaceDefinition<T extends Record<string, any> = any> = Readonly<{
|
|
74
|
+
id: string;
|
|
75
|
+
role: string | string[];
|
|
76
|
+
disposition?: Disposition;
|
|
77
|
+
filter?: (data: Record<string, unknown>) => data is T;
|
|
78
|
+
component: SurfaceComponent<GuardedType<SurfaceDefinition<T>['filter']>>;
|
|
79
|
+
}>;
|
|
80
|
+
|
|
81
|
+
export const createSurface = <T extends Record<string, any> = any>(definition: SurfaceDefinition<T>) => definition;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
// TODO(burdon): Replace zod with effect.
|
|
8
|
+
export const ResourceKey = z.union([z.string(), z.record(z.any())]);
|
|
9
|
+
export type ResourceKey = z.infer<typeof ResourceKey>;
|
|
10
|
+
|
|
11
|
+
export const ResourceLanguage = z.record(ResourceKey);
|
|
12
|
+
export type ResourceLanguage = z.infer<typeof ResourceLanguage>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A resource is a collection of translations for a language.
|
|
16
|
+
*/
|
|
17
|
+
export const Resource = z.record(ResourceLanguage);
|
|
18
|
+
export type Resource = z.infer<typeof Resource>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { updateCounter } from '@dxos/echo-schema/testing';
|
|
8
|
+
import { registerSignalsRuntime } from '@dxos/echo-signals';
|
|
9
|
+
|
|
10
|
+
import { defineCapability, PluginsContext } from './capabilities';
|
|
11
|
+
|
|
12
|
+
registerSignalsRuntime();
|
|
13
|
+
|
|
14
|
+
const defaultOptions = {
|
|
15
|
+
activate: () => Promise.resolve(false),
|
|
16
|
+
reset: () => Promise.resolve(false),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe('PluginsContext', () => {
|
|
20
|
+
it('should return empty array if no capabilities are contributed', () => {
|
|
21
|
+
const context = new PluginsContext(defaultOptions);
|
|
22
|
+
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
23
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([]);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should be able to contribute and request capabilities', () => {
|
|
27
|
+
const context = new PluginsContext(defaultOptions);
|
|
28
|
+
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
29
|
+
const implementation = { example: 'identifier' };
|
|
30
|
+
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
31
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([implementation]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should be able to remove capabilities', () => {
|
|
35
|
+
const context = new PluginsContext(defaultOptions);
|
|
36
|
+
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
37
|
+
const implementation = { example: 'identifier' };
|
|
38
|
+
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
39
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([implementation]);
|
|
40
|
+
context.removeCapability(interfaceDef, implementation);
|
|
41
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should be able to contribute and request multiple implementations', () => {
|
|
45
|
+
const context = new PluginsContext(defaultOptions);
|
|
46
|
+
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
47
|
+
const implementation1 = { example: 'first' };
|
|
48
|
+
const implementation2 = { example: 'second' };
|
|
49
|
+
context.contributeCapability({ interface: interfaceDef, implementation: implementation1, module: 'test' });
|
|
50
|
+
context.contributeCapability({ interface: interfaceDef, implementation: implementation2, module: 'test' });
|
|
51
|
+
expect(context.requestCapabilities(interfaceDef)).toEqual([implementation1, implementation2]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should be able to request multiple capabilities', () => {
|
|
55
|
+
const context = new PluginsContext(defaultOptions);
|
|
56
|
+
const interfaceDef1 = defineCapability<{ one: number }>('@dxos/app-framework/test/one');
|
|
57
|
+
const interfaceDef2 = defineCapability<{ two: number }>('@dxos/app-framework/test/two');
|
|
58
|
+
const implementation1 = { one: 1 };
|
|
59
|
+
const implementation2 = { two: 2 };
|
|
60
|
+
context.contributeCapability({ interface: interfaceDef1, implementation: implementation1, module: 'test' });
|
|
61
|
+
context.contributeCapability({ interface: interfaceDef2, implementation: implementation2, module: 'test' });
|
|
62
|
+
expect(context.requestCapabilities(interfaceDef1)).toEqual([implementation1]);
|
|
63
|
+
expect(context.requestCapabilities(interfaceDef2)).toEqual([implementation2]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should be reactive', () => {
|
|
67
|
+
const context = new PluginsContext(defaultOptions);
|
|
68
|
+
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
69
|
+
|
|
70
|
+
using updates = updateCounter(() => {
|
|
71
|
+
context.requestCapabilities(interfaceDef);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(updates.count).toEqual(0);
|
|
75
|
+
|
|
76
|
+
const implementation = { example: 'identifier' };
|
|
77
|
+
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
78
|
+
expect(updates.count).toEqual(1);
|
|
79
|
+
|
|
80
|
+
context.removeCapability(interfaceDef, implementation);
|
|
81
|
+
expect(updates.count).toEqual(2);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should not be reactive to changes within the implementation', () => {
|
|
85
|
+
const context = new PluginsContext(defaultOptions);
|
|
86
|
+
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
87
|
+
|
|
88
|
+
using updates = updateCounter(() => {
|
|
89
|
+
context.requestCapabilities(interfaceDef);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(updates.count).toEqual(0);
|
|
93
|
+
|
|
94
|
+
const implementation = { example: 'identifier' };
|
|
95
|
+
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
96
|
+
expect(updates.count).toEqual(1);
|
|
97
|
+
|
|
98
|
+
implementation.example = 'updated';
|
|
99
|
+
expect(updates.count).toEqual(1);
|
|
100
|
+
|
|
101
|
+
const capabilities = context.requestCapabilities(interfaceDef);
|
|
102
|
+
expect(capabilities).toEqual([implementation]);
|
|
103
|
+
expect(capabilities[0].example).toEqual('updated');
|
|
104
|
+
expect(updates.count).toEqual(1);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should be able to wait for a capability', async () => {
|
|
108
|
+
const context = new PluginsContext(defaultOptions);
|
|
109
|
+
const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
|
|
110
|
+
const implementation = { example: 'identifier' };
|
|
111
|
+
const promise = context.waitForCapability(interfaceDef);
|
|
112
|
+
context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
|
|
113
|
+
const capability = await promise;
|
|
114
|
+
expect(capability).toEqual(implementation);
|
|
115
|
+
});
|
|
116
|
+
});
|