@dxos/app-framework 0.7.5-main.499c70c → 0.7.5-main.5ae2ba8
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-S4MYSHQA.mjs +137 -0
- package/dist/lib/browser/app-graph-builder-S4MYSHQA.mjs.map +7 -0
- package/dist/lib/browser/chunk-BCMEJONP.mjs +1432 -0
- package/dist/lib/browser/chunk-BCMEJONP.mjs.map +7 -0
- package/dist/lib/browser/chunk-QS4J6O47.mjs +285 -0
- package/dist/lib/browser/chunk-QS4J6O47.mjs.map +7 -0
- package/dist/lib/browser/chunk-SRZH2PQ2.mjs +32 -0
- package/dist/lib/browser/chunk-SRZH2PQ2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +119 -642
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-dispatcher-GFBH7T2J.mjs +11 -0
- package/dist/lib/browser/intent-resolver-KAFM7CQH.mjs +39 -0
- package/dist/lib/browser/intent-resolver-KAFM7CQH.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/store-L3VRR7II.mjs +29 -0
- package/dist/lib/browser/store-L3VRR7II.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +77 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/browser/worker.mjs +77 -0
- package/dist/lib/node/app-graph-builder-VMHWFCTP.cjs +146 -0
- package/dist/lib/node/app-graph-builder-VMHWFCTP.cjs.map +7 -0
- package/dist/lib/node/chunk-7Y6KJ3OK.cjs +1466 -0
- package/dist/lib/node/chunk-7Y6KJ3OK.cjs.map +7 -0
- package/dist/lib/node/chunk-B65NJEIJ.cjs +308 -0
- package/dist/lib/node/chunk-B65NJEIJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-FCMHRU3M.cjs → chunk-VCIHQZSN.cjs} +23 -35
- package/dist/lib/node/chunk-VCIHQZSN.cjs.map +7 -0
- package/dist/lib/node/index.cjs +125 -665
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/{plugin-settings-W6UHMH5M.cjs → intent-dispatcher-PRCC4KZT.cjs} +10 -14
- package/dist/lib/node/intent-dispatcher-PRCC4KZT.cjs.map +7 -0
- package/dist/lib/node/intent-resolver-OZDKCHPW.cjs +46 -0
- package/dist/lib/node/intent-resolver-OZDKCHPW.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/store-BVUKNVKL.cjs +44 -0
- package/dist/lib/node/store-BVUKNVKL.cjs.map +7 -0
- package/dist/lib/node/testing/index.cjs +101 -0
- package/dist/lib/node/testing/index.cjs.map +7 -0
- package/dist/lib/node/worker.cjs +99 -0
- package/dist/lib/node/worker.cjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-XHI5IIXQ.mjs +138 -0
- package/dist/lib/node-esm/app-graph-builder-XHI5IIXQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CBT75GCX.mjs +34 -0
- package/dist/lib/node-esm/chunk-CBT75GCX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JDAHZRYQ.mjs +286 -0
- package/dist/lib/node-esm/chunk-JDAHZRYQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-TVIR2PHY.mjs +1434 -0
- package/dist/lib/node-esm/chunk-TVIR2PHY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +119 -642
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-dispatcher-LGACN32C.mjs +12 -0
- package/dist/lib/node-esm/intent-resolver-RBNG76ZX.mjs +40 -0
- package/dist/lib/node-esm/intent-resolver-RBNG76ZX.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/store-PHTOEREN.mjs +30 -0
- package/dist/lib/node-esm/store-PHTOEREN.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +78 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/worker.mjs +78 -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 +304 -0
- package/dist/types/src/common/capabilities.d.ts.map +1 -0
- package/dist/types/src/common/events.d.ts +52 -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/common/index.d.ts +8 -0
- package/dist/types/src/common/index.d.ts.map +1 -0
- package/dist/types/src/common/layout.d.ts +262 -0
- package/dist/types/src/common/layout.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-surface/SurfaceContext.d.ts → common/surface.d.ts} +12 -29
- package/dist/types/src/common/surface.d.ts.map +1 -0
- package/dist/types/src/common/translations.d.ts +11 -0
- package/dist/types/src/common/translations.d.ts.map +1 -0
- package/dist/types/src/core/capabilities.d.ts +94 -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 +119 -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 +97 -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 +5 -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 +5 -0
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts +5 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
- package/dist/types/src/playground/generator/generator.d.ts +7 -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 +5 -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 +9 -0
- package/dist/types/src/playground/playground.stories.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 +5 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +113 -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.map +1 -0
- package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent.d.ts +8 -28
- 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 +27 -0
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +197 -0
- package/dist/types/src/plugin-settings/app-graph-builder.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/plugin-settings/intent-resolver.d.ts +4 -0
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/store.d.ts +5 -0
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/translations.d.ts +11 -0
- package/dist/types/src/plugin-settings/translations.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +1 -1
- package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-intent → react}/IntentContext.d.ts +2 -2
- package/dist/types/src/react/IntentContext.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/Surface.stories.d.ts +15 -0
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -0
- package/dist/types/src/react/common.d.ts +13 -0
- package/dist/types/src/react/common.d.ts.map +1 -0
- package/dist/types/src/react/index.d.ts +7 -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/react/useIntentResolver.d.ts +3 -0
- package/dist/types/src/react/useIntentResolver.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 +12 -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/src/worker.d.ts +4 -0
- package/dist/types/src/worker.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -19
- package/project.json +5 -3
- package/src/App.tsx +140 -34
- package/src/common/capabilities.ts +101 -0
- package/src/common/events.ts +77 -0
- package/src/common/file.ts +22 -0
- package/src/common/graph.ts +30 -0
- package/src/{plugins/common → common}/index.ts +3 -2
- package/src/common/layout.ts +238 -0
- package/src/{plugins/plugin-surface/SurfaceContext.ts → common/surface.ts} +6 -37
- package/src/common/translations.ts +17 -0
- package/src/core/capabilities.test.ts +116 -0
- package/src/core/capabilities.ts +222 -0
- package/src/core/events.ts +58 -0
- package/src/core/index.ts +8 -0
- package/src/core/manager.test.ts +516 -0
- package/src/core/manager.ts +511 -0
- package/src/core/plugin.ts +131 -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 +48 -0
- package/src/playground/generator/index.ts +6 -0
- package/src/playground/generator/plugin.ts +23 -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 +29 -0
- package/src/playground/logger/index.ts +5 -0
- package/src/playground/logger/plugin.ts +36 -0
- package/src/playground/logger/schema.ts +12 -0
- package/src/playground/playground.stories.tsx +34 -0
- package/src/plugin-intent/IntentPlugin.tsx +20 -0
- package/src/plugin-intent/actions.ts +22 -0
- package/src/plugin-intent/errors.ts +39 -0
- package/src/plugin-intent/index.ts +8 -0
- package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.ts +83 -63
- package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.ts +118 -95
- package/src/{plugins/plugin-intent → plugin-intent}/intent.ts +10 -26
- package/src/plugin-settings/SettingsPlugin.ts +35 -0
- package/src/plugin-settings/actions.ts +27 -0
- package/src/plugin-settings/app-graph-builder.ts +122 -0
- package/src/plugin-settings/index.ts +6 -0
- package/src/plugin-settings/intent-resolver.ts +34 -0
- package/src/plugin-settings/store.ts +30 -0
- package/src/plugin-settings/translations.ts +17 -0
- package/src/{plugins/plugin-intent → react}/IntentContext.tsx +13 -5
- package/src/react/PluginManagerProvider.ts +22 -0
- package/src/react/Surface.stories.tsx +96 -0
- package/src/react/Surface.tsx +75 -0
- package/src/react/common.ts +12 -0
- package/src/react/index.ts +10 -0
- package/src/react/useCapabilities.ts +40 -0
- package/src/react/useIntentResolver.ts +22 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/withPluginManager.stories.tsx +47 -0
- package/src/testing/withPluginManager.tsx +91 -0
- package/src/worker.ts +11 -0
- package/tsconfig.json +19 -13
- package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
- package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
- package/dist/lib/browser/chunk-QG25ZU2N.mjs +0 -320
- package/dist/lib/browser/chunk-QG25ZU2N.mjs.map +0 -7
- package/dist/lib/browser/chunk-SPDTXTOV.mjs +0 -163
- package/dist/lib/browser/chunk-SPDTXTOV.mjs.map +0 -7
- package/dist/lib/browser/chunk-WBOXEHBE.mjs +0 -51
- package/dist/lib/browser/chunk-WBOXEHBE.mjs.map +0 -7
- package/dist/lib/browser/plugin-intent-T7Y3MJ5C.mjs +0 -32
- package/dist/lib/browser/plugin-settings-5U2L2NRU.mjs +0 -15
- package/dist/lib/browser/plugin-surface-OKPF3EQI.mjs +0 -24
- package/dist/lib/node/chunk-BW3RNEVI.cjs +0 -185
- package/dist/lib/node/chunk-BW3RNEVI.cjs.map +0 -7
- package/dist/lib/node/chunk-FCMHRU3M.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-VWHAALIN.cjs +0 -344
- package/dist/lib/node/chunk-VWHAALIN.cjs.map +0 -7
- package/dist/lib/node/plugin-intent-F3TQZIUR.cjs +0 -53
- package/dist/lib/node/plugin-intent-F3TQZIUR.cjs.map +0 -7
- package/dist/lib/node/plugin-settings-W6UHMH5M.cjs.map +0 -7
- package/dist/lib/node/plugin-surface-CCSIONYW.cjs +0 -45
- package/dist/lib/node/plugin-surface-CCSIONYW.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-3T5UIJY3.mjs +0 -53
- package/dist/lib/node-esm/chunk-3T5UIJY3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs +0 -164
- package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs +0 -321
- package/dist/lib/node-esm/chunk-CFOUYXQ6.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/plugin-intent-W2HQC6LC.mjs +0 -33
- package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs +0 -16
- package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs +0 -25
- package/dist/lib/node-esm/plugin-surface-V3YET3UL.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 +0 -7
- package/dist/types/src/plugins/common/index.d.ts.map +0 -1
- package/dist/types/src/plugins/common/layout.d.ts +0 -176
- 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 +0 -243
- package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
- package/dist/types/src/plugins/common/translations.d.ts +0 -22
- 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 -16
- 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 -6
- package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -104
- 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.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/index.d.ts +0 -7
- package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts +0 -107
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -6
- package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -16
- 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 -26
- 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 -7
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/SurfaceContext.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/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 -17
- 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 -173
- package/src/plugins/common/metadata.ts +0 -29
- package/src/plugins/common/navigation.ts +0 -214
- 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 -88
- 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 -12
- package/src/plugins/plugin-host/plugin.test.ts +0 -158
- package/src/plugins/plugin-host/plugin.ts +0 -133
- package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -75
- package/src/plugins/plugin-intent/index.ts +0 -13
- package/src/plugins/plugin-intent/meta.ts +0 -11
- package/src/plugins/plugin-intent/provides.ts +0 -26
- 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 -34
- package/src/plugins/plugin-surface/Surface.tsx +0 -62
- package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -45
- 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 -27
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
- /package/dist/lib/browser/{plugin-intent-T7Y3MJ5C.mjs.map → intent-dispatcher-GFBH7T2J.mjs.map} +0 -0
- /package/dist/lib/browser/{plugin-settings-5U2L2NRU.mjs.map → worker.mjs.map} +0 -0
- /package/dist/lib/{browser/plugin-surface-OKPF3EQI.mjs.map → node-esm/intent-dispatcher-LGACN32C.mjs.map} +0 -0
- /package/dist/lib/node-esm/{plugin-intent-W2HQC6LC.mjs.map → worker.mjs.map} +0 -0
- /package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.d.ts +0 -0
- /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Effect, Ref } from 'effect';
|
|
5
|
+
import { Effect, Option, pipe, Ref } from 'effect';
|
|
6
|
+
import { type Simplify } from 'effect/Types';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
+
import { create } from '@dxos/live-object';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
10
|
+
import { byPosition, type MaybePromise, type Position, type GuardedType } from '@dxos/util';
|
|
8
11
|
|
|
12
|
+
import { IntentAction } from './actions';
|
|
13
|
+
import { CycleDetectedError, NoResolversError } from './errors';
|
|
9
14
|
import {
|
|
10
15
|
createIntent,
|
|
11
|
-
IntentAction,
|
|
12
16
|
type AnyIntent,
|
|
13
17
|
type AnyIntentChain,
|
|
14
18
|
type Intent,
|
|
@@ -19,6 +23,8 @@ import {
|
|
|
19
23
|
type IntentSchema,
|
|
20
24
|
type Label,
|
|
21
25
|
} from './intent';
|
|
26
|
+
import { Events, Capabilities } from '../common';
|
|
27
|
+
import { contributes, type PluginsContext } from '../core';
|
|
22
28
|
|
|
23
29
|
const EXECUTION_LIMIT = 100;
|
|
24
30
|
const HISTORY_LIMIT = 100;
|
|
@@ -26,13 +32,13 @@ const HISTORY_LIMIT = 100;
|
|
|
26
32
|
/**
|
|
27
33
|
* The return value of an intent effect.
|
|
28
34
|
*/
|
|
29
|
-
export type IntentEffectResult<
|
|
35
|
+
export type IntentEffectResult<Input, Output> = {
|
|
30
36
|
/**
|
|
31
37
|
* The output of the action that was performed.
|
|
32
38
|
*
|
|
33
39
|
* If the intent is apart of a chain of intents, the data will be passed to the next intent.
|
|
34
40
|
*/
|
|
35
|
-
data?:
|
|
41
|
+
data?: Output;
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* If provided, the action will be undoable.
|
|
@@ -46,13 +52,15 @@ export type IntentEffectResult<Fields extends IntentParams> = {
|
|
|
46
52
|
/**
|
|
47
53
|
* Will be merged with the original intent data when firing the undo intent.
|
|
48
54
|
*/
|
|
49
|
-
data?: Partial<
|
|
55
|
+
data?: Partial<Input>;
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
/**
|
|
53
59
|
* An error that occurred while performing the action.
|
|
54
60
|
*
|
|
55
61
|
* If the intent is apart of a chain of intents and an error occurs, the chain will be aborted.
|
|
62
|
+
*
|
|
63
|
+
* Return caught error instead of throwing to trigger other intent to be triggered prior to returning the error.
|
|
56
64
|
*/
|
|
57
65
|
error?: Error;
|
|
58
66
|
|
|
@@ -62,42 +70,32 @@ export type IntentEffectResult<Fields extends IntentParams> = {
|
|
|
62
70
|
intents?: AnyIntentChain[];
|
|
63
71
|
};
|
|
64
72
|
|
|
65
|
-
export type AnyIntentEffectResult = IntentEffectResult<any>;
|
|
73
|
+
export type AnyIntentEffectResult = IntentEffectResult<any, any>;
|
|
66
74
|
|
|
67
75
|
/**
|
|
68
76
|
* The result of an intent dispatcher.
|
|
69
77
|
*/
|
|
70
|
-
export type IntentDispatcherResult<
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Determines the priority of the effect when multiple intent resolvers are matched.
|
|
74
|
-
*
|
|
75
|
-
* - `static` - The effect is selected in the order it was resolved.
|
|
76
|
-
* - `hoist` - The effect is selected before `static` effects.
|
|
77
|
-
* - `fallback` - The effect is selected after `static` effects.
|
|
78
|
-
*/
|
|
79
|
-
export type IntentDisposition = 'static' | 'hoist' | 'fallback';
|
|
78
|
+
export type IntentDispatcherResult<Input, Output> = Pick<IntentEffectResult<Input, Output>, 'data' | 'error'>;
|
|
80
79
|
|
|
81
80
|
/**
|
|
82
81
|
* The implementation of an intent effect.
|
|
83
82
|
*/
|
|
84
|
-
export type IntentEffectDefinition<
|
|
85
|
-
data:
|
|
83
|
+
export type IntentEffectDefinition<Input, Output> = (
|
|
84
|
+
data: Input,
|
|
86
85
|
undo: boolean,
|
|
87
|
-
) => MaybePromise<IntentEffectResult<
|
|
86
|
+
) => MaybePromise<IntentEffectResult<Input, Output> | void> | Effect.Effect<IntentEffectResult<Input, Output> | void>;
|
|
88
87
|
|
|
89
88
|
/**
|
|
90
89
|
* Intent resolver to match intents to their effects.
|
|
91
90
|
*/
|
|
92
|
-
export type IntentResolver<Tag extends string, Fields extends IntentParams
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
91
|
+
export type IntentResolver<Tag extends string, Fields extends IntentParams, Data = IntentData<Fields>> = Readonly<{
|
|
92
|
+
intent: IntentSchema<Tag, Fields>;
|
|
93
|
+
position?: Position;
|
|
94
|
+
filter?: (data: IntentData<Fields>) => data is Data;
|
|
95
|
+
resolve: IntentEffectDefinition<GuardedType<IntentResolver<Tag, Fields, Data>['filter']>, IntentResultData<Fields>>;
|
|
96
|
+
}>;
|
|
99
97
|
|
|
100
|
-
export type AnyIntentResolver = IntentResolver<any, any>;
|
|
98
|
+
export type AnyIntentResolver = IntentResolver<any, any, any>;
|
|
101
99
|
|
|
102
100
|
/**
|
|
103
101
|
* Creates an intent resolver to match intents to their effects.
|
|
@@ -106,22 +104,16 @@ export type AnyIntentResolver = IntentResolver<any, any>;
|
|
|
106
104
|
* @param params.disposition Determines the priority of the resolver when multiple are resolved.
|
|
107
105
|
* @param params.filter Optional filter to determine if the resolver should be used.
|
|
108
106
|
*/
|
|
109
|
-
export const createResolver = <Tag extends string, Fields extends IntentParams
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
params: Pick<IntentResolver<Tag, Fields>, 'disposition' | 'filter'> = {},
|
|
113
|
-
): IntentResolver<Tag, Fields> => ({
|
|
114
|
-
action: schema._tag,
|
|
115
|
-
effect,
|
|
116
|
-
...params,
|
|
117
|
-
});
|
|
107
|
+
export const createResolver = <Tag extends string, Fields extends IntentParams, Data = IntentData<Fields>>(
|
|
108
|
+
resolver: IntentResolver<Tag, Fields, Data>,
|
|
109
|
+
) => resolver;
|
|
118
110
|
|
|
119
111
|
/**
|
|
120
112
|
* Invokes intents and returns the result.
|
|
121
113
|
*/
|
|
122
114
|
export type PromiseIntentDispatcher = <Fields extends IntentParams>(
|
|
123
115
|
intent: IntentChain<any, any, any, Fields>,
|
|
124
|
-
) => Promise<IntentDispatcherResult<Fields
|
|
116
|
+
) => Promise<Simplify<IntentDispatcherResult<IntentData<Fields>, IntentResultData<Fields>>>>;
|
|
125
117
|
|
|
126
118
|
/**
|
|
127
119
|
* Creates an effect for intents.
|
|
@@ -129,23 +121,29 @@ export type PromiseIntentDispatcher = <Fields extends IntentParams>(
|
|
|
129
121
|
export type IntentDispatcher = <Fields extends IntentParams>(
|
|
130
122
|
intent: IntentChain<any, any, any, Fields>,
|
|
131
123
|
depth?: number,
|
|
132
|
-
) => Effect.Effect<
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
) => Effect.Effect<
|
|
125
|
+
Simplify<Required<IntentDispatcherResult<IntentData<Fields>, IntentResultData<Fields>>>['data']>,
|
|
126
|
+
Error
|
|
127
|
+
>;
|
|
128
|
+
|
|
129
|
+
type IntentResult<Tag extends string, Fields extends IntentParams> = IntentEffectResult<
|
|
130
|
+
IntentData<Fields>,
|
|
131
|
+
IntentResultData<Fields>
|
|
132
|
+
> & {
|
|
135
133
|
_intent: Intent<Tag, Fields>;
|
|
136
134
|
};
|
|
137
135
|
|
|
138
|
-
type AnyIntentResult = IntentResult<any, any>;
|
|
136
|
+
export type AnyIntentResult = IntentResult<any, any>;
|
|
139
137
|
|
|
140
138
|
/**
|
|
141
139
|
* Invokes the most recent undoable intent with undo flags.
|
|
142
140
|
*/
|
|
143
|
-
export type PromiseIntentUndo = () => Promise<IntentDispatcherResult<any
|
|
141
|
+
export type PromiseIntentUndo = () => Promise<IntentDispatcherResult<any, any>>;
|
|
144
142
|
|
|
145
143
|
/**
|
|
146
144
|
* Creates an effect which undoes the last intent.
|
|
147
145
|
*/
|
|
148
|
-
export type IntentUndo = () => Effect.Effect<
|
|
146
|
+
export type IntentUndo = () => Effect.Effect<any, Error>;
|
|
149
147
|
|
|
150
148
|
/**
|
|
151
149
|
* Check if a chain of results is undoable.
|
|
@@ -158,51 +156,40 @@ export type IntentContext = {
|
|
|
158
156
|
dispatchPromise: PromiseIntentDispatcher;
|
|
159
157
|
undo: IntentUndo;
|
|
160
158
|
undoPromise: PromiseIntentUndo;
|
|
161
|
-
registerResolver: (id: string, resolver: AnyIntentResolver) => () => void;
|
|
162
159
|
};
|
|
163
160
|
|
|
164
161
|
/**
|
|
165
162
|
* Sets of an intent dispatcher.
|
|
166
163
|
*
|
|
167
|
-
* @param
|
|
164
|
+
* @param getResolvers A function that returns an array of available intent resolvers.
|
|
168
165
|
* @param params.historyLimit The maximum number of intent results to keep in history.
|
|
169
166
|
* @param params.executionLimit The maximum recursion depth of intent chains.
|
|
170
167
|
*/
|
|
171
168
|
export const createDispatcher = (
|
|
172
|
-
|
|
169
|
+
getResolvers: (module?: string) => AnyIntentResolver[],
|
|
173
170
|
{ executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {},
|
|
174
171
|
): IntentContext => {
|
|
175
172
|
const historyRef = Effect.runSync(Ref.make<AnyIntentResult[][]>([]));
|
|
176
173
|
|
|
177
|
-
const handleIntent = (intent: AnyIntent) =>
|
|
178
|
-
|
|
179
|
-
const candidates =
|
|
180
|
-
.filter((
|
|
181
|
-
.flatMap(([_, resolvers]) => resolvers)
|
|
182
|
-
.filter((r) => r.action === intent.action)
|
|
174
|
+
const handleIntent = (intent: AnyIntent) =>
|
|
175
|
+
Effect.gen(function* () {
|
|
176
|
+
const candidates = getResolvers(intent.module)
|
|
177
|
+
.filter((r) => r.intent._tag === intent.id)
|
|
183
178
|
.filter((r) => !r.filter || r.filter(intent.data))
|
|
184
|
-
.toSorted(
|
|
185
|
-
return a === b ? 0 : a === 'hoist' || b === 'fallback' ? -1 : b === 'hoist' || a === 'fallback' ? 1 : 0;
|
|
186
|
-
});
|
|
179
|
+
.toSorted(byPosition);
|
|
187
180
|
if (candidates.length === 0) {
|
|
188
|
-
|
|
189
|
-
_intent: intent,
|
|
190
|
-
error: new Error(`No resolver found for action: ${intent.action}`),
|
|
191
|
-
} satisfies AnyIntentResult;
|
|
181
|
+
yield* Effect.fail(new NoResolversError(intent.id));
|
|
192
182
|
}
|
|
193
183
|
|
|
194
|
-
const effect = candidates[0].
|
|
184
|
+
const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
|
|
195
185
|
const result = Effect.isEffect(effect) ? yield* effect : yield* Effect.promise(async () => effect);
|
|
196
|
-
return { _intent: intent, ...result }
|
|
186
|
+
return { _intent: intent, ...result } as AnyIntentResult;
|
|
197
187
|
});
|
|
198
|
-
};
|
|
199
188
|
|
|
200
189
|
const dispatch: IntentDispatcher = (intentChain, depth = 0) => {
|
|
201
190
|
return Effect.gen(function* () {
|
|
202
191
|
if (depth > executionLimit) {
|
|
203
|
-
yield* Effect.fail(
|
|
204
|
-
new Error('Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.'),
|
|
205
|
-
);
|
|
192
|
+
yield* Effect.fail(new CycleDetectedError());
|
|
206
193
|
}
|
|
207
194
|
|
|
208
195
|
const resultsRef = yield* Ref.make<AnyIntentResult[]>([]);
|
|
@@ -210,9 +197,6 @@ export const createDispatcher = (
|
|
|
210
197
|
const { data: prev } = (yield* resultsRef.get)[0] ?? {};
|
|
211
198
|
const result = yield* handleIntent({ ...intent, data: { ...intent.data, ...prev } });
|
|
212
199
|
yield* Ref.update(resultsRef, (results) => [result, ...results]);
|
|
213
|
-
if (result.error) {
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
200
|
if (result.intents) {
|
|
217
201
|
for (const intent of result.intents) {
|
|
218
202
|
// Returned intents are dispatched but not yielded into results,
|
|
@@ -221,34 +205,42 @@ export const createDispatcher = (
|
|
|
221
205
|
yield* dispatch(intent, depth + 1);
|
|
222
206
|
}
|
|
223
207
|
}
|
|
208
|
+
if (result.error) {
|
|
209
|
+
yield* Effect.fail(result.error);
|
|
210
|
+
}
|
|
224
211
|
}
|
|
225
212
|
|
|
226
213
|
const results = yield* resultsRef.get;
|
|
227
214
|
const result = results[0];
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
next.splice(0, next.length - historyLimit);
|
|
233
|
-
}
|
|
234
|
-
return next;
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
if (result.undoable && isUndoable(results)) {
|
|
238
|
-
// TODO(wittjosiah): Is there a better way to handle showing undo for chains?
|
|
239
|
-
yield* dispatch(createIntent(IntentAction.ShowUndo, { message: result.undoable.message }));
|
|
215
|
+
yield* Ref.update(historyRef, (history) => {
|
|
216
|
+
const next = [...history, results];
|
|
217
|
+
if (next.length > historyLimit) {
|
|
218
|
+
next.splice(0, next.length - historyLimit);
|
|
240
219
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
220
|
+
return next;
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
if (result.undoable && isUndoable(results)) {
|
|
224
|
+
// TODO(wittjosiah): Is there a better way to handle showing undo for chains?
|
|
225
|
+
yield* pipe(
|
|
226
|
+
dispatch(createIntent(IntentAction.ShowUndo, { message: result.undoable.message })),
|
|
227
|
+
Effect.catchSome((err) =>
|
|
228
|
+
err instanceof NoResolversError ? Option.some(Effect.succeed(undefined)) : Option.none(),
|
|
229
|
+
),
|
|
230
|
+
);
|
|
245
231
|
}
|
|
232
|
+
|
|
233
|
+
return result.data;
|
|
246
234
|
});
|
|
247
235
|
};
|
|
248
236
|
|
|
249
237
|
const dispatchPromise: PromiseIntentDispatcher = (intentChain) => {
|
|
250
|
-
|
|
251
|
-
|
|
238
|
+
return Effect.runPromise(dispatch(intentChain))
|
|
239
|
+
.then((data) => ({ data }))
|
|
240
|
+
.catch((error) => {
|
|
241
|
+
log.catch(error);
|
|
242
|
+
return { error };
|
|
243
|
+
});
|
|
252
244
|
};
|
|
253
245
|
|
|
254
246
|
const undo: IntentUndo = () => {
|
|
@@ -270,16 +262,47 @@ export const createDispatcher = (
|
|
|
270
262
|
};
|
|
271
263
|
|
|
272
264
|
const undoPromise: PromiseIntentUndo = () => {
|
|
273
|
-
|
|
274
|
-
|
|
265
|
+
return Effect.runPromise(undo())
|
|
266
|
+
.then((data) => ({ data }))
|
|
267
|
+
.catch((error) => ({ error }));
|
|
275
268
|
};
|
|
276
269
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
270
|
+
return { dispatch, dispatchPromise, undo, undoPromise };
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const defaultEffect = () => Effect.fail(new Error('Intent runtime not ready'));
|
|
274
|
+
const defaultPromise = () => Effect.runPromise(defaultEffect());
|
|
275
|
+
|
|
276
|
+
export default (context: PluginsContext) => {
|
|
277
|
+
const state = create<IntentContext>({
|
|
278
|
+
dispatch: defaultEffect,
|
|
279
|
+
dispatchPromise: defaultPromise,
|
|
280
|
+
undo: defaultEffect,
|
|
281
|
+
undoPromise: defaultPromise,
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// TODO(wittjosiah): Make getResolver callback async and allow resolvers to be requested on demand.
|
|
285
|
+
const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher((module) =>
|
|
286
|
+
context
|
|
287
|
+
.requestCapabilities(Capabilities.IntentResolver, (c, moduleId): c is AnyIntentResolver => {
|
|
288
|
+
return module ? moduleId === module : true;
|
|
289
|
+
})
|
|
290
|
+
.flat(),
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
const manager = context.requestCapability(Capabilities.PluginManager);
|
|
294
|
+
state.dispatch = (intentChain, depth) => {
|
|
295
|
+
return Effect.gen(function* () {
|
|
296
|
+
yield* manager._activate(Events.SetupIntentResolver);
|
|
297
|
+
return yield* dispatch(intentChain, depth);
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
state.dispatchPromise = async (intentChain) => {
|
|
301
|
+
await manager.activate(Events.SetupIntentResolver);
|
|
302
|
+
return await dispatchPromise(intentChain);
|
|
282
303
|
};
|
|
304
|
+
state.undo = undo;
|
|
305
|
+
state.undoPromise = undoPromise;
|
|
283
306
|
|
|
284
|
-
return
|
|
307
|
+
return contributes(Capabilities.IntentDispatcher, state);
|
|
285
308
|
};
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { S } from '@
|
|
6
|
-
|
|
7
|
-
import { INTENT_PLUGIN } from './meta';
|
|
5
|
+
import { Schema as S } from '@effect/schema';
|
|
8
6
|
|
|
9
7
|
export type IntentParams = {
|
|
10
8
|
readonly input: S.Schema.All;
|
|
@@ -27,9 +25,9 @@ export type Intent<Tag extends string, Fields extends IntentParams> = {
|
|
|
27
25
|
_schema: IntentSchema<Tag, Fields>;
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
|
-
* The
|
|
28
|
+
* The id of the intent.
|
|
31
29
|
*/
|
|
32
|
-
|
|
30
|
+
id: Tag;
|
|
33
31
|
|
|
34
32
|
/**
|
|
35
33
|
* Any data needed to perform the desired action.
|
|
@@ -37,11 +35,11 @@ export type Intent<Tag extends string, Fields extends IntentParams> = {
|
|
|
37
35
|
data: IntentData<Fields>;
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
|
-
*
|
|
41
|
-
* If specified, the intent will be sent explicitly to the plugin.
|
|
38
|
+
* Module ID.
|
|
39
|
+
* If specified, the intent will be sent explicitly to the plugin module.
|
|
42
40
|
* Otherwise, the intent will be sent to all plugins, in order and the first to resolve a non-null value will be used.
|
|
43
41
|
*/
|
|
44
|
-
|
|
42
|
+
module?: string;
|
|
45
43
|
|
|
46
44
|
/**
|
|
47
45
|
* Whether or not the intent is being undone.
|
|
@@ -78,7 +76,7 @@ export type AnyIntentChain = IntentChain<any, any, any, any>;
|
|
|
78
76
|
export const createIntent = <Tag extends string, Fields extends IntentParams>(
|
|
79
77
|
schema: IntentSchema<Tag, Fields>,
|
|
80
78
|
data: IntentData<Fields> = {},
|
|
81
|
-
params: Pick<AnyIntent, '
|
|
79
|
+
params: Pick<AnyIntent, 'module' | 'undo'> = {},
|
|
82
80
|
): IntentChain<Tag, Tag, Fields, Fields> => {
|
|
83
81
|
// The output of validateSync breaks proxy objects so this is just used for validation.
|
|
84
82
|
// TODO(wittjosiah): Is there a better way to make theses types align?
|
|
@@ -86,7 +84,7 @@ export const createIntent = <Tag extends string, Fields extends IntentParams>(
|
|
|
86
84
|
const intent = {
|
|
87
85
|
...params,
|
|
88
86
|
_schema: schema,
|
|
89
|
-
|
|
87
|
+
id: schema._tag,
|
|
90
88
|
data,
|
|
91
89
|
} satisfies Intent<Tag, Fields>;
|
|
92
90
|
|
|
@@ -114,7 +112,7 @@ export const chain =
|
|
|
114
112
|
>(
|
|
115
113
|
schema: IntentSchema<NextTag, NextFields>,
|
|
116
114
|
data: Omit<IntentData<NextFields>, keyof IntentResultData<LastFields>> = {},
|
|
117
|
-
params: Pick<AnyIntent, '
|
|
115
|
+
params: Pick<AnyIntent, 'module' | 'undo'> = {},
|
|
118
116
|
) =>
|
|
119
117
|
(
|
|
120
118
|
intent: IntentChain<FirstTag, any, FirstFields, LastFields>,
|
|
@@ -124,7 +122,7 @@ export const chain =
|
|
|
124
122
|
const last = {
|
|
125
123
|
...params,
|
|
126
124
|
_schema: schema,
|
|
127
|
-
|
|
125
|
+
id: schema._tag,
|
|
128
126
|
data,
|
|
129
127
|
} satisfies Intent<NextTag, NextFields>;
|
|
130
128
|
|
|
@@ -146,17 +144,3 @@ export const Label = S.Union(
|
|
|
146
144
|
S.mutable(S.Tuple(S.String, S.mutable(S.Struct({ ns: S.String, count: S.optional(S.Number) })))),
|
|
147
145
|
);
|
|
148
146
|
export type Label = S.Schema.Type<typeof Label>;
|
|
149
|
-
|
|
150
|
-
export const INTENT_ACTION = `${INTENT_PLUGIN}/action`;
|
|
151
|
-
|
|
152
|
-
export namespace IntentAction {
|
|
153
|
-
/**
|
|
154
|
-
* Fired after an intent is dispatched if the intent is undoable.
|
|
155
|
-
*/
|
|
156
|
-
export class ShowUndo extends S.TaggedClass<ShowUndo>()(`${INTENT_ACTION}/show-undo`, {
|
|
157
|
-
input: S.Struct({
|
|
158
|
-
message: Label,
|
|
159
|
-
}),
|
|
160
|
-
output: S.Void,
|
|
161
|
-
}) {}
|
|
162
|
-
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { SETTINGS_PLUGIN } from './actions';
|
|
6
|
+
import translations from './translations';
|
|
7
|
+
import { Capabilities, Events } from '../common';
|
|
8
|
+
import { contributes, defineModule, definePlugin, lazy } from '../core';
|
|
9
|
+
|
|
10
|
+
// TODO(wittjosiah): Add options to exclude some modules.
|
|
11
|
+
export const SettingsPlugin = () =>
|
|
12
|
+
definePlugin({ id: SETTINGS_PLUGIN }, [
|
|
13
|
+
defineModule({
|
|
14
|
+
id: `${SETTINGS_PLUGIN}/module/store`,
|
|
15
|
+
activatesOn: Events.Startup,
|
|
16
|
+
activatesBefore: [Events.SetupSettings],
|
|
17
|
+
activatesAfter: [Events.SettingsReady],
|
|
18
|
+
activate: lazy(() => import('./store')),
|
|
19
|
+
}),
|
|
20
|
+
defineModule({
|
|
21
|
+
id: `${SETTINGS_PLUGIN}/module/translations`,
|
|
22
|
+
activatesOn: Events.SetupTranslations,
|
|
23
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
24
|
+
}),
|
|
25
|
+
defineModule({
|
|
26
|
+
id: `${SETTINGS_PLUGIN}/module/intent-resolver`,
|
|
27
|
+
activatesOn: Events.SetupIntentResolver,
|
|
28
|
+
activate: lazy(() => import('./intent-resolver')),
|
|
29
|
+
}),
|
|
30
|
+
defineModule({
|
|
31
|
+
id: `${SETTINGS_PLUGIN}/module/app-graph-builder`,
|
|
32
|
+
activatesOn: Events.SetupAppGraph,
|
|
33
|
+
activate: lazy(() => import('./app-graph-builder')),
|
|
34
|
+
}),
|
|
35
|
+
]);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Schema as S } from '@effect/schema';
|
|
6
|
+
|
|
7
|
+
export const SETTINGS_PLUGIN = 'dxos.org/plugin/settings';
|
|
8
|
+
export const SETTINGS_ACTION = `${SETTINGS_PLUGIN}/action`;
|
|
9
|
+
export const SETTINGS_ID = '!dxos:settings';
|
|
10
|
+
export const SETTINGS_KEY = 'settings';
|
|
11
|
+
|
|
12
|
+
export namespace SettingsAction {
|
|
13
|
+
export class Open extends S.TaggedClass<Open>()(`${SETTINGS_ACTION}/open`, {
|
|
14
|
+
input: S.Struct({
|
|
15
|
+
plugin: S.optional(S.String),
|
|
16
|
+
}),
|
|
17
|
+
output: S.Void,
|
|
18
|
+
}) {}
|
|
19
|
+
|
|
20
|
+
export class OpenPluginRegistry extends S.TaggedClass<OpenPluginRegistry>()(
|
|
21
|
+
`${SETTINGS_ACTION}/open-plugin-registry`,
|
|
22
|
+
{
|
|
23
|
+
input: S.Void,
|
|
24
|
+
output: S.Void,
|
|
25
|
+
},
|
|
26
|
+
) {}
|
|
27
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createExtension, type Node } from '@dxos/app-graph';
|
|
6
|
+
import { type SettingsStore, type SettingsValue } from '@dxos/local-storage';
|
|
7
|
+
import { isNonNullable } from '@dxos/util';
|
|
8
|
+
|
|
9
|
+
import { SETTINGS_ID, SETTINGS_KEY, SETTINGS_PLUGIN, SettingsAction } from './actions';
|
|
10
|
+
import { Capabilities } from '../common';
|
|
11
|
+
import { contributes, type PluginMeta, type PluginsContext } from '../core';
|
|
12
|
+
import { createIntent } from '../plugin-intent';
|
|
13
|
+
|
|
14
|
+
export default (context: PluginsContext) =>
|
|
15
|
+
contributes(Capabilities.AppGraphBuilder, [
|
|
16
|
+
createExtension({
|
|
17
|
+
id: `${SETTINGS_PLUGIN}/action`,
|
|
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
|
+
],
|
|
36
|
+
}),
|
|
37
|
+
createExtension({
|
|
38
|
+
id: `${SETTINGS_PLUGIN}/core`,
|
|
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
|
+
],
|
|
53
|
+
}),
|
|
54
|
+
createExtension({
|
|
55
|
+
id: `${SETTINGS_PLUGIN}/core-plugins`,
|
|
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
|
+
}
|
|
68
|
+
|
|
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
|
+
})),
|
|
81
|
+
|
|
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
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
createExtension({
|
|
95
|
+
id: `${SETTINGS_PLUGIN}/custom-plugins`,
|
|
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
|
+
}
|
|
107
|
+
|
|
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
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
]);
|