@dxos/app-framework 0.8.4-main.f9ba587 → 0.8.4-main.fffef41
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/.storybook/main.mts +11 -0
- package/.storybook/preview.mts +8 -0
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/.swc/plugins/{v7_linux_x86_64_13.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429 → linux_x86_64_19.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429.wasmer-v7} +0 -0
- package/dist/lib/browser/{app-graph-builder-BGGXLD6T.mjs → app-graph-builder-OIEZZC45.mjs} +32 -31
- package/dist/lib/browser/app-graph-builder-OIEZZC45.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DHZB7HG7.mjs → chunk-6XKO24JP.mjs} +254 -184
- package/dist/lib/browser/chunk-6XKO24JP.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ORWHM7CO.mjs → chunk-SCPE4ZO2.mjs} +11 -8
- package/dist/lib/browser/chunk-SCPE4ZO2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2636QSIK.mjs → chunk-WPW5VVAX.mjs} +399 -266
- package/dist/lib/browser/chunk-WPW5VVAX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -56
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-dispatcher-TWKB22NI.mjs → intent-dispatcher-LZ4AE66E.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-O67UANYP.mjs → intent-resolver-QVCKRX6G.mjs} +7 -7
- package/dist/lib/browser/intent-resolver-QVCKRX6G.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react/index.mjs +34 -0
- package/dist/lib/browser/{store-LFKDWHUQ.mjs → store-CNPHOYTJ.mjs} +5 -5
- package/dist/lib/browser/store-CNPHOYTJ.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +17 -21
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{app-graph-builder-QHIJUYYW.mjs → app-graph-builder-EBU4NVWD.mjs} +32 -31
- package/dist/lib/node-esm/app-graph-builder-EBU4NVWD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NJAFK626.mjs → chunk-3UPX5OIS.mjs} +254 -184
- package/dist/lib/node-esm/chunk-3UPX5OIS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VSKRV3NW.mjs → chunk-XJZGUJ3H.mjs} +399 -266
- package/dist/lib/node-esm/chunk-XJZGUJ3H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UMZQERLE.mjs → chunk-ZX63QUGE.mjs} +11 -8
- package/dist/lib/node-esm/chunk-ZX63QUGE.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -56
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-dispatcher-5PRM3KGH.mjs → intent-dispatcher-MGOJ3CHD.mjs} +2 -2
- package/dist/lib/node-esm/{intent-resolver-K3D4BXQQ.mjs → intent-resolver-URF3HN3G.mjs} +7 -7
- package/dist/lib/node-esm/intent-resolver-URF3HN3G.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react/index.mjs +35 -0
- package/dist/lib/node-esm/{store-53XDUBMD.mjs → store-RK5B4XEL.mjs} +5 -5
- package/dist/lib/node-esm/store-RK5B4XEL.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +17 -21
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/common/capabilities.d.ts +111 -38
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/collaboration.d.ts +10 -9
- package/dist/types/src/common/collaboration.d.ts.map +1 -1
- package/dist/types/src/common/events.d.ts.map +1 -1
- package/dist/types/src/common/file.d.ts +1 -1
- package/dist/types/src/common/file.d.ts.map +1 -1
- package/dist/types/src/common/layout.d.ts +1 -3
- package/dist/types/src/common/layout.d.ts.map +1 -1
- package/dist/types/src/common/surface.d.ts +19 -16
- package/dist/types/src/common/surface.d.ts.map +1 -1
- package/dist/types/src/common/translations.d.ts +1 -1
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/core/capabilities.d.ts +19 -16
- package/dist/types/src/core/capabilities.d.ts.map +1 -1
- package/dist/types/src/core/manager.d.ts +7 -3
- package/dist/types/src/core/manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +8 -1
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/debug/Debug.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts +1 -1
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Main.d.ts +1 -1
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -1
- package/dist/types/src/playground/generator/generator.d.ts +1 -1
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -1
- package/dist/types/src/playground/generator/plugin.d.ts +1 -1
- package/dist/types/src/playground/generator/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/layout/Layout.d.ts +2 -2
- package/dist/types/src/playground/layout/plugin.d.ts +1 -1
- package/dist/types/src/playground/layout/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +1 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -1
- package/dist/types/src/playground/logger/plugin.d.ts +1 -1
- package/dist/types/src/playground/logger/plugin.d.ts.map +1 -1
- package/dist/types/src/playground/logger/schema.d.ts +1 -1
- package/dist/types/src/playground/logger/schema.d.ts.map +1 -1
- package/dist/types/src/playground/playground.stories.d.ts +5 -4
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +1 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/actions.d.ts +5 -7
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/errors.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/index.d.ts +1 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +7 -7
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts +1 -1
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -1
- package/dist/types/src/plugin-intent/meta.d.ts +3 -0
- package/dist/types/src/plugin-intent/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +1 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/actions.d.ts +5 -7
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +1 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +1 -1
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/meta.d.ts +3 -0
- package/dist/types/src/plugin-settings/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/store.d.ts +1 -1
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -1
- package/dist/types/src/plugin-settings/translations.d.ts +2 -1
- package/dist/types/src/plugin-settings/translations.d.ts.map +1 -1
- package/dist/types/src/react/App.d.ts +10 -0
- package/dist/types/src/react/App.d.ts.map +1 -0
- package/dist/types/src/react/App.stories.d.ts +14 -0
- package/dist/types/src/react/App.stories.d.ts.map +1 -0
- package/dist/types/src/react/DefaultFallback.d.ts +8 -0
- package/dist/types/src/react/DefaultFallback.d.ts.map +1 -0
- package/dist/types/src/react/ErrorBoundary.d.ts +13 -14
- package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -1
- package/dist/types/src/react/IntentContext.d.ts.map +1 -1
- package/dist/types/src/react/Surface.d.ts +5 -5
- package/dist/types/src/react/Surface.d.ts.map +1 -1
- package/dist/types/src/react/Surface.stories.d.ts +8 -10
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -1
- package/dist/types/src/react/common.d.ts.map +1 -1
- package/dist/types/src/react/index.d.ts +2 -0
- package/dist/types/src/react/index.d.ts.map +1 -1
- package/dist/types/src/react/types.d.ts +14 -0
- package/dist/types/src/react/types.d.ts.map +1 -0
- package/dist/types/src/{App.d.ts → react/useApp.d.ts} +7 -6
- package/dist/types/src/react/useApp.d.ts.map +1 -0
- package/dist/types/src/react/useCapabilities.d.ts.map +1 -1
- package/dist/types/src/react/useLoading.d.ts +19 -0
- package/dist/types/src/react/useLoading.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +9 -8
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.stories.d.ts +9 -3
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +5 -1
- package/package.json +46 -38
- package/src/common/capabilities.ts +120 -19
- package/src/common/collaboration.ts +6 -9
- package/src/common/events.ts +3 -1
- package/src/common/file.ts +1 -1
- package/src/common/layout.ts +3 -4
- package/src/common/surface.ts +23 -21
- package/src/common/translations.ts +1 -1
- package/src/core/capabilities.test.ts +3 -3
- package/src/core/capabilities.ts +36 -27
- package/src/core/manager.test.ts +22 -21
- package/src/core/manager.ts +141 -56
- package/src/core/plugin.ts +13 -2
- package/src/helpers.test.ts +1 -1
- package/src/index.ts +0 -2
- package/src/playground/debug/Debug.tsx +1 -1
- package/src/playground/debug/plugin.ts +7 -8
- package/src/playground/generator/Main.tsx +0 -1
- package/src/playground/generator/Toolbar.tsx +2 -1
- package/src/playground/generator/generator.ts +4 -4
- package/src/playground/generator/plugin.ts +12 -13
- package/src/playground/layout/plugin.ts +10 -9
- package/src/playground/logger/Toolbar.tsx +2 -1
- package/src/playground/logger/plugin.ts +30 -25
- package/src/playground/logger/schema.ts +1 -1
- package/src/playground/playground.stories.tsx +20 -16
- package/src/plugin-intent/IntentPlugin.ts +13 -13
- package/src/plugin-intent/actions.ts +4 -6
- package/src/plugin-intent/errors.ts +2 -1
- package/src/plugin-intent/index.ts +1 -0
- package/src/plugin-intent/intent-dispatcher.test.ts +10 -3
- package/src/plugin-intent/intent-dispatcher.ts +21 -12
- package/src/plugin-intent/intent.ts +1 -1
- package/src/plugin-intent/meta.ts +10 -0
- package/src/plugin-settings/SettingsPlugin.ts +27 -28
- package/src/plugin-settings/actions.ts +9 -13
- package/src/plugin-settings/app-graph-builder.ts +25 -22
- package/src/plugin-settings/intent-resolver.ts +5 -4
- package/src/plugin-settings/meta.ts +10 -0
- package/src/plugin-settings/store.ts +3 -3
- package/src/plugin-settings/translations.ts +4 -4
- package/src/react/App.stories.tsx +33 -0
- package/src/react/App.tsx +59 -0
- package/src/react/DefaultFallback.tsx +26 -0
- package/src/react/ErrorBoundary.tsx +26 -15
- package/src/react/IntentContext.tsx +3 -2
- package/src/react/Surface.stories.tsx +81 -52
- package/src/react/Surface.tsx +70 -38
- package/src/react/common.ts +2 -1
- package/src/react/index.ts +4 -0
- package/src/react/types.ts +38 -0
- package/src/react/useApp.tsx +165 -0
- package/src/react/useCapabilities.ts +4 -3
- package/src/react/useLoading.tsx +70 -0
- package/src/testing/withPluginManager.stories.tsx +9 -5
- package/src/testing/withPluginManager.tsx +33 -32
- package/tsconfig.json +15 -10
- package/vitest.config.ts +8 -6
- package/.eslintrc.cjs +0 -9
- package/.swc/plugins/v7_linux_x86_64_13.0.0/f45bdff002284d9e8f9ef3f0be909de12da36c049cbcf261ac78fc00abb09a2d +0 -0
- package/dist/lib/browser/app-graph-builder-BGGXLD6T.mjs.map +0 -7
- package/dist/lib/browser/chunk-2636QSIK.mjs.map +0 -7
- package/dist/lib/browser/chunk-DHZB7HG7.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORWHM7CO.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-O67UANYP.mjs.map +0 -7
- package/dist/lib/browser/store-LFKDWHUQ.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -79
- package/dist/lib/node-esm/app-graph-builder-QHIJUYYW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NJAFK626.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UMZQERLE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VSKRV3NW.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-K3D4BXQQ.mjs.map +0 -7
- package/dist/lib/node-esm/store-53XDUBMD.mjs.map +0 -7
- package/dist/lib/node-esm/worker.mjs +0 -80
- package/dist/types/src/App.d.ts.map +0 -1
- package/dist/types/src/worker.d.ts +0 -4
- package/dist/types/src/worker.d.ts.map +0 -1
- package/src/App.tsx +0 -276
- package/src/worker.ts +0 -11
- 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 -421
- 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 -1123
- 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/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/useApp.html +0 -6
- 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 -12
- 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.AnchorSort.html +0 -1
- 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-TWKB22NI.mjs.map → intent-dispatcher-LZ4AE66E.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → react/index.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-dispatcher-5PRM3KGH.mjs.map → intent-dispatcher-MGOJ3CHD.mjs.map} +0 -0
- /package/dist/lib/node-esm/{worker.mjs.map → react/index.mjs.map} +0 -0
|
@@ -2,36 +2,39 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Function from 'effect/Function';
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { ROOT_ID, createExtension } from '@dxos/app-graph';
|
|
9
10
|
import { type SettingsStore, type SettingsValue } from '@dxos/local-storage';
|
|
10
11
|
import { isNonNullable } from '@dxos/util';
|
|
11
12
|
|
|
12
|
-
import { SETTINGS_ID, SETTINGS_KEY, SETTINGS_PLUGIN, SettingsAction } from './actions';
|
|
13
13
|
import { Capabilities } from '../common';
|
|
14
|
-
import {
|
|
14
|
+
import { type PluginContext, type PluginMeta, contributes } from '../core';
|
|
15
15
|
import { createIntent } from '../plugin-intent';
|
|
16
16
|
|
|
17
|
+
import { SETTINGS_ID, SETTINGS_KEY, SettingsAction } from './actions';
|
|
18
|
+
import { meta } from './meta';
|
|
19
|
+
|
|
17
20
|
export default (context: PluginContext) =>
|
|
18
21
|
contributes(Capabilities.AppGraphBuilder, [
|
|
19
22
|
createExtension({
|
|
20
|
-
id: `${
|
|
23
|
+
id: `${meta.id}/action`,
|
|
21
24
|
actions: (node) =>
|
|
22
|
-
|
|
23
|
-
pipe(
|
|
25
|
+
Atom.make((get) =>
|
|
26
|
+
Function.pipe(
|
|
24
27
|
get(node),
|
|
25
28
|
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
26
29
|
Option.map(() => [
|
|
27
30
|
{
|
|
28
|
-
id:
|
|
31
|
+
id: meta.id,
|
|
29
32
|
data: async () => {
|
|
30
33
|
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
31
34
|
await dispatch(createIntent(SettingsAction.Open));
|
|
32
35
|
},
|
|
33
36
|
properties: {
|
|
34
|
-
label: ['open settings label', { ns:
|
|
37
|
+
label: ['open settings label', { ns: meta.id }],
|
|
35
38
|
icon: 'ph--gear--regular',
|
|
36
39
|
disposition: 'menu',
|
|
37
40
|
keyBinding: {
|
|
@@ -46,18 +49,18 @@ export default (context: PluginContext) =>
|
|
|
46
49
|
),
|
|
47
50
|
}),
|
|
48
51
|
createExtension({
|
|
49
|
-
id: `${
|
|
52
|
+
id: `${meta.id}/core`,
|
|
50
53
|
connector: (node) =>
|
|
51
|
-
|
|
52
|
-
pipe(
|
|
54
|
+
Atom.make((get) =>
|
|
55
|
+
Function.pipe(
|
|
53
56
|
get(node),
|
|
54
57
|
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
55
58
|
Option.map(() => [
|
|
56
59
|
{
|
|
57
60
|
id: SETTINGS_ID,
|
|
58
|
-
type:
|
|
61
|
+
type: meta.id,
|
|
59
62
|
properties: {
|
|
60
|
-
label: ['app settings label', { ns:
|
|
63
|
+
label: ['app settings label', { ns: meta.id }],
|
|
61
64
|
icon: 'ph--gear--regular',
|
|
62
65
|
disposition: 'pin-end',
|
|
63
66
|
position: 'hoist',
|
|
@@ -70,10 +73,10 @@ export default (context: PluginContext) =>
|
|
|
70
73
|
),
|
|
71
74
|
}),
|
|
72
75
|
createExtension({
|
|
73
|
-
id: `${
|
|
76
|
+
id: `${meta.id}/core-plugins`,
|
|
74
77
|
connector: (node) =>
|
|
75
|
-
|
|
76
|
-
pipe(
|
|
78
|
+
Atom.make((get) =>
|
|
79
|
+
Function.pipe(
|
|
77
80
|
get(node),
|
|
78
81
|
Option.flatMap((node) => (node.id !== SETTINGS_ID ? Option.none() : Option.some(node))),
|
|
79
82
|
Option.map(() => {
|
|
@@ -105,7 +108,7 @@ export default (context: PluginContext) =>
|
|
|
105
108
|
id: `${SETTINGS_KEY}:custom-plugins`,
|
|
106
109
|
type: 'category',
|
|
107
110
|
properties: {
|
|
108
|
-
label: ['custom plugins label', { ns:
|
|
111
|
+
label: ['custom plugins label', { ns: meta.id }],
|
|
109
112
|
icon: 'ph--squares-four--regular',
|
|
110
113
|
role: 'branch',
|
|
111
114
|
disposition: 'collection',
|
|
@@ -118,10 +121,10 @@ export default (context: PluginContext) =>
|
|
|
118
121
|
),
|
|
119
122
|
}),
|
|
120
123
|
createExtension({
|
|
121
|
-
id: `${
|
|
124
|
+
id: `${meta.id}/custom-plugins`,
|
|
122
125
|
connector: (node) =>
|
|
123
|
-
|
|
124
|
-
pipe(
|
|
126
|
+
Atom.make((get) =>
|
|
127
|
+
Function.pipe(
|
|
125
128
|
get(node),
|
|
126
129
|
Option.flatMap((node) =>
|
|
127
130
|
node.id !== `${SETTINGS_KEY}:custom-plugins` ? Option.none() : Option.some(node),
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Function from 'effect/Function';
|
|
6
6
|
|
|
7
|
-
import { SETTINGS_ID, SETTINGS_KEY, SettingsAction } from './actions';
|
|
8
7
|
import { Capabilities, LayoutAction } from '../common';
|
|
9
8
|
import { contributes } from '../core';
|
|
10
|
-
import {
|
|
9
|
+
import { chain, createIntent, createResolver } from '../plugin-intent';
|
|
10
|
+
|
|
11
|
+
import { SETTINGS_ID, SETTINGS_KEY, SettingsAction } from './actions';
|
|
11
12
|
|
|
12
13
|
export default () =>
|
|
13
14
|
contributes(
|
|
@@ -19,7 +20,7 @@ export default () =>
|
|
|
19
20
|
return {
|
|
20
21
|
intents: [
|
|
21
22
|
plugin
|
|
22
|
-
? pipe(
|
|
23
|
+
? Function.pipe(
|
|
23
24
|
openSettings,
|
|
24
25
|
chain(LayoutAction.Open, {
|
|
25
26
|
part: 'main',
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import { RootSettingsStore } from '@dxos/local-storage';
|
|
6
6
|
|
|
7
7
|
import { Capabilities } from '../common';
|
|
8
|
-
import {
|
|
8
|
+
import { type PluginContext, contributes } from '../core';
|
|
9
9
|
|
|
10
10
|
export default (context: PluginContext) => {
|
|
11
|
-
// TODO(wittjosiah): Replace with
|
|
11
|
+
// TODO(wittjosiah): Replace with atom?
|
|
12
12
|
const settingsStore = new RootSettingsStore();
|
|
13
13
|
|
|
14
14
|
let previous: Capabilities.Settings[] = [];
|
|
15
|
-
const registry = context.getCapability(Capabilities.
|
|
15
|
+
const registry = context.getCapability(Capabilities.AtomRegistry);
|
|
16
16
|
const cancel = registry.subscribe(
|
|
17
17
|
context.capabilities(Capabilities.Settings),
|
|
18
18
|
(allSettings) => {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
//
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Resource } from '
|
|
5
|
+
import { type Resource } from '../common';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { meta } from './meta';
|
|
8
8
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
|
-
[
|
|
12
|
+
[meta.id]: {
|
|
13
13
|
'open settings label': 'Open settings',
|
|
14
14
|
'app settings label': 'Settings',
|
|
15
15
|
'custom plugins label': 'Plugins',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
9
|
+
|
|
10
|
+
import { useApp } from './useApp';
|
|
11
|
+
|
|
12
|
+
const DefaultStory = () => {
|
|
13
|
+
const App = useApp({
|
|
14
|
+
placeholder: () => <div className='fixed inset-0 flex items-center justify-center'>Loading...</div>,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return <App />;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const meta = {
|
|
21
|
+
title: 'sdk/app-framework/App',
|
|
22
|
+
render: DefaultStory,
|
|
23
|
+
decorators: [withTheme],
|
|
24
|
+
parameters: {
|
|
25
|
+
layout: 'fullscreen',
|
|
26
|
+
},
|
|
27
|
+
} satisfies Meta;
|
|
28
|
+
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
type Story = StoryObj<typeof meta>;
|
|
32
|
+
|
|
33
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type PropsWithChildren } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities } from '../common';
|
|
8
|
+
import { topologicalSort } from '../helpers';
|
|
9
|
+
|
|
10
|
+
import { type UseAppOptions } from './useApp';
|
|
11
|
+
import { useCapabilities } from './useCapabilities';
|
|
12
|
+
import { LoadingState, useLoading } from './useLoading';
|
|
13
|
+
|
|
14
|
+
export type AppProps = Pick<UseAppOptions, 'placeholder' | 'debounce'> & {
|
|
15
|
+
state: { ready: boolean; error: unknown };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const App = ({ placeholder: Placeholder, state, debounce }: AppProps) => {
|
|
19
|
+
const reactContexts = useCapabilities(Capabilities.ReactContext);
|
|
20
|
+
const reactRoots = useCapabilities(Capabilities.ReactRoot);
|
|
21
|
+
const stage = useLoading(state, debounce);
|
|
22
|
+
|
|
23
|
+
if (state.error) {
|
|
24
|
+
// This triggers the error boundary to provide UI feedback for the startup error.
|
|
25
|
+
throw state.error;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// TODO(wittjosiah): Consider using Suspense instead.
|
|
29
|
+
if (stage < LoadingState.Done) {
|
|
30
|
+
if (!Placeholder) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return <Placeholder stage={stage} />;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ComposedContext = composeContexts(reactContexts);
|
|
38
|
+
return (
|
|
39
|
+
<ComposedContext>
|
|
40
|
+
{reactRoots.map(({ id, root: Component }) => (
|
|
41
|
+
<Component key={id} />
|
|
42
|
+
))}
|
|
43
|
+
</ComposedContext>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const composeContexts = (contexts: Capabilities.ReactContext[]) => {
|
|
48
|
+
if (contexts.length === 0) {
|
|
49
|
+
return ({ children }: PropsWithChildren) => <>{children}</>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return topologicalSort(contexts)
|
|
53
|
+
.map(({ context }) => context)
|
|
54
|
+
.reduce((Acc, Next) => ({ children }) => (
|
|
55
|
+
<Acc>
|
|
56
|
+
<Next>{children}</Next>
|
|
57
|
+
</Acc>
|
|
58
|
+
));
|
|
59
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* NOTE: Default fallback should not use tailwind or theme.
|
|
9
|
+
*/
|
|
10
|
+
export const DefaultFallback = ({ error }: { error: Error }) => {
|
|
11
|
+
return (
|
|
12
|
+
<div
|
|
13
|
+
style={{
|
|
14
|
+
margin: '1rem',
|
|
15
|
+
padding: '1rem',
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
border: '4px solid teal',
|
|
18
|
+
borderRadius: '1rem',
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
{/* TODO(wittjosiah): Link to docs for replacing default. */}
|
|
22
|
+
<h1 style={{ margin: '0.5rem 0', fontSize: '1.2rem' }}>ERROR: {error.message}</h1>
|
|
23
|
+
<pre style={{ overflow: 'auto', fontSize: '1rem', whiteSpace: 'pre-wrap', color: '#888888' }}>{error.stack}</pre>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -2,38 +2,40 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { Component, type FC, type PropsWithChildren } from 'react';
|
|
5
|
+
import React, { Component, type FC, type PropsWithChildren, type ReactNode } from 'react';
|
|
6
6
|
|
|
7
|
-
type
|
|
8
|
-
|
|
7
|
+
type State = {
|
|
8
|
+
error: Error | undefined;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ErrorBoundaryProps = PropsWithChildren<{
|
|
12
|
+
data?: any;
|
|
13
|
+
fallback?: FC<{ data?: any; error: Error }>;
|
|
14
|
+
}>;
|
|
9
15
|
|
|
10
16
|
/**
|
|
11
17
|
* Surface error boundary.
|
|
12
|
-
*
|
|
13
18
|
* For basic usage prefer providing a fallback component to `Surface`.
|
|
14
19
|
*
|
|
15
|
-
*
|
|
16
|
-
* https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary
|
|
20
|
+
* Ref: https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary
|
|
17
21
|
*/
|
|
18
|
-
export class ErrorBoundary extends Component<
|
|
19
|
-
constructor(props: Props) {
|
|
20
|
-
super(props);
|
|
21
|
-
this.state = { error: undefined };
|
|
22
|
-
}
|
|
23
|
-
|
|
22
|
+
export class ErrorBoundary extends Component<ErrorBoundaryProps, State> {
|
|
24
23
|
static getDerivedStateFromError(error: Error): { error: Error } {
|
|
25
24
|
return { error };
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
override
|
|
27
|
+
override state = { error: undefined };
|
|
28
|
+
|
|
29
|
+
override componentDidUpdate(prevProps: ErrorBoundaryProps): void {
|
|
29
30
|
if (prevProps.data !== this.props.data) {
|
|
30
31
|
this.resetError();
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
override render():
|
|
35
|
+
override render(): ReactNode {
|
|
35
36
|
if (this.state.error) {
|
|
36
|
-
|
|
37
|
+
const Fallback = this.props.fallback ?? DefaultFallback;
|
|
38
|
+
return <Fallback data={this.props.data} error={this.state.error} />;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
return this.props.children;
|
|
@@ -43,3 +45,12 @@ export class ErrorBoundary extends Component<Props, State> {
|
|
|
43
45
|
this.setState({ error: undefined });
|
|
44
46
|
}
|
|
45
47
|
}
|
|
48
|
+
|
|
49
|
+
const DefaultFallback: NonNullable<ErrorBoundaryProps['fallback']> = ({ data, error }) => {
|
|
50
|
+
return (
|
|
51
|
+
<div className='flex flex-col gap-2 overflow-hidden border border-red-500 rounded-sm'>
|
|
52
|
+
<h1 className='p-2'>ERROR: {error.message}</h1>
|
|
53
|
+
<pre className='p-2 overflow-y-auto text-sm text-subdued'>{JSON.stringify(data, null, 2)}</pre>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Context, createContext, useContext,
|
|
5
|
+
import { type Context, type Provider, createContext, useContext, useEffect } from 'react';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
8
|
import { pick } from '@dxos/util';
|
|
9
9
|
|
|
10
|
-
import { usePluginManager } from './PluginManagerProvider';
|
|
11
10
|
import { Capabilities } from '../common';
|
|
12
11
|
import { type AnyIntentResolver, type IntentContext } from '../plugin-intent';
|
|
13
12
|
|
|
13
|
+
import { usePluginManager } from './PluginManagerProvider';
|
|
14
|
+
|
|
14
15
|
const IntentContext: Context<IntentContext | undefined> = createContext<IntentContext | undefined>(undefined);
|
|
15
16
|
|
|
16
17
|
export const useIntentDispatcher = (): Pick<IntentContext, 'dispatch' | 'dispatchPromise'> => {
|
|
@@ -2,95 +2,124 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import React, { useCallback, useState } from 'react';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
8
7
|
|
|
9
8
|
import { faker } from '@dxos/random';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { List, ListItem, Toolbar } from '@dxos/react-ui';
|
|
10
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
import { getHashStyles, mx } from '@dxos/react-ui-theme';
|
|
12
12
|
|
|
13
|
-
import { PluginManagerProvider, usePluginManager } from './PluginManagerProvider';
|
|
14
|
-
import { Surface, useSurfaces } from './Surface';
|
|
15
13
|
import { Capabilities, createSurface } from '../common';
|
|
16
|
-
import {
|
|
17
|
-
import { setupPluginManager } from '../testing';
|
|
18
|
-
|
|
19
|
-
const randomColor = (): string => {
|
|
20
|
-
const hue = faker.number.int({ min: 0, max: 360 });
|
|
21
|
-
const saturation = faker.number.int({ min: 50, max: 90 });
|
|
22
|
-
const lightness = faker.number.int({ min: 40, max: 70 });
|
|
23
|
-
return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
|
|
24
|
-
};
|
|
14
|
+
import { withPluginManager } from '../testing';
|
|
25
15
|
|
|
26
|
-
|
|
16
|
+
import { usePluginManager } from './PluginManagerProvider';
|
|
17
|
+
import { Surface, useSurfaces } from './Surface';
|
|
18
|
+
|
|
19
|
+
const DefaultStory = () => {
|
|
20
|
+
const [selected, setSelected] = useState<string | undefined>();
|
|
27
21
|
const manager = usePluginManager();
|
|
28
22
|
const surfaces = useSurfaces();
|
|
29
|
-
const [picked, setPicked] = useState('test');
|
|
30
23
|
|
|
31
24
|
const handleAdd = useCallback(() => {
|
|
32
|
-
const id = `test-${faker.number.int({ min: 0, max:
|
|
33
|
-
const
|
|
25
|
+
const id = `test-${faker.number.int({ min: 0, max: 1_000 })}`;
|
|
26
|
+
const styles = getHashStyles(id);
|
|
34
27
|
|
|
35
28
|
manager.context.contributeCapability({
|
|
36
29
|
module: 'test',
|
|
37
30
|
interface: Capabilities.ReactSurface,
|
|
38
31
|
implementation: createSurface({
|
|
39
32
|
id,
|
|
40
|
-
role:
|
|
33
|
+
role: 'item',
|
|
34
|
+
filter: (data): data is any => (data as any)?.id === id,
|
|
41
35
|
component: () => (
|
|
42
|
-
<div className='flex-
|
|
43
|
-
{id}
|
|
36
|
+
<div className={mx('flex justify-center items-center border rounded', styles.surface, styles.border)}>
|
|
37
|
+
<span className={mx('dx-tag font-mono text-lg', styles.text)}>{id}</span>
|
|
44
38
|
</div>
|
|
45
39
|
),
|
|
46
40
|
}),
|
|
47
41
|
});
|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
setSelected(id);
|
|
50
44
|
}, [manager]);
|
|
51
45
|
|
|
52
|
-
const
|
|
53
|
-
|
|
46
|
+
const handleSelect = useCallback(() => {
|
|
47
|
+
setSelected(faker.helpers.arrayElement(surfaces)?.id);
|
|
54
48
|
}, [surfaces]);
|
|
55
49
|
|
|
50
|
+
const handleError = useCallback(() => {
|
|
51
|
+
manager.context.contributeCapability({
|
|
52
|
+
module: 'error',
|
|
53
|
+
interface: Capabilities.ReactSurface,
|
|
54
|
+
implementation: createSurface({
|
|
55
|
+
id: 'error',
|
|
56
|
+
role: 'item',
|
|
57
|
+
filter: (data): data is any => (data as any)?.id === 'error',
|
|
58
|
+
component: () => {
|
|
59
|
+
const [count, setCount] = useState(3);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const interval = setInterval(() => {
|
|
62
|
+
setCount((count) => {
|
|
63
|
+
if (count <= 1) {
|
|
64
|
+
clearInterval(interval);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return count - 1;
|
|
68
|
+
});
|
|
69
|
+
}, 1_000);
|
|
70
|
+
return () => clearInterval(interval);
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
if (count <= 0) {
|
|
74
|
+
throw new Error('BANG!');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div className='flex justify-center items-center border border-roseFill rounded'>
|
|
79
|
+
<span className='font-mono'>Ticking... {count}</span>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
setSelected('error');
|
|
87
|
+
}, [manager]);
|
|
88
|
+
|
|
56
89
|
return (
|
|
57
|
-
<div className='flex flex-col
|
|
58
|
-
<
|
|
59
|
-
<Button onClick={handleAdd}>Add</Button>
|
|
60
|
-
<Button onClick={
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
90
|
+
<div className='flex flex-col bs-full overflow-hidden'>
|
|
91
|
+
<Toolbar.Root>
|
|
92
|
+
<Toolbar.Button onClick={handleAdd}>Add</Toolbar.Button>
|
|
93
|
+
<Toolbar.Button onClick={handleSelect}>Pick</Toolbar.Button>
|
|
94
|
+
<Toolbar.Button onClick={handleError}>Error</Toolbar.Button>
|
|
95
|
+
</Toolbar.Root>
|
|
96
|
+
<div className='grid grid-cols-2 bs-full gap-4 overflow-hidden'>
|
|
97
|
+
<Surface role='item' data={selected ? { id: selected } : undefined} limit={1} />
|
|
98
|
+
<div className='overflow-y-auto bs-full'>
|
|
99
|
+
<List>
|
|
65
100
|
{surfaces.map((surface) => (
|
|
66
101
|
<ListItem.Root key={surface.id} id={surface.id}>
|
|
67
|
-
<ListItem.Heading classNames='
|
|
102
|
+
<ListItem.Heading classNames='flex items-center'>{surface.id}</ListItem.Heading>
|
|
68
103
|
</ListItem.Root>
|
|
69
104
|
))}
|
|
70
105
|
</List>
|
|
71
106
|
</div>
|
|
72
|
-
<div className='flex-1'>
|
|
73
|
-
<Surface role={picked} limit={1} />
|
|
74
|
-
</div>
|
|
75
107
|
</div>
|
|
76
108
|
</div>
|
|
77
109
|
);
|
|
78
110
|
};
|
|
79
111
|
|
|
80
|
-
|
|
112
|
+
const meta = {
|
|
81
113
|
title: 'sdk/app-framework/Surface',
|
|
82
|
-
render:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
</PluginManagerProvider>
|
|
87
|
-
);
|
|
88
|
-
},
|
|
89
|
-
// NOTE: Intentionally not using withPluginManager to try to reduce surface area of the story.
|
|
90
|
-
decorators: [withTheme, withLayout()],
|
|
91
|
-
args: {
|
|
92
|
-
manager: setupPluginManager(),
|
|
114
|
+
render: DefaultStory,
|
|
115
|
+
decorators: [withTheme, withPluginManager({ capabilities: [] })],
|
|
116
|
+
parameters: {
|
|
117
|
+
layout: 'fullscreen',
|
|
93
118
|
},
|
|
94
|
-
}
|
|
119
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
120
|
+
|
|
121
|
+
export default meta;
|
|
122
|
+
|
|
123
|
+
type Story = StoryObj<typeof meta>;
|
|
95
124
|
|
|
96
|
-
export const Default = {};
|
|
125
|
+
export const Default: Story = {};
|