@dxos/app-framework 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
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 +1 -3
- package/dist/lib/browser/capability-5OFLR7J4.mjs +34 -0
- package/dist/lib/browser/capability-5OFLR7J4.mjs.map +7 -0
- package/dist/lib/browser/{capability-7PCNSWBT.mjs → capability-ZHQDZRP5.mjs} +15 -11
- package/dist/lib/browser/capability-ZHQDZRP5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PKQT6C53.mjs → chunk-272IPLHQ.mjs} +1 -1
- package/dist/lib/browser/{chunk-PKQT6C53.mjs.map → chunk-272IPLHQ.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-FMZN33N4.mjs → chunk-3VXJONTI.mjs} +304 -178
- package/dist/lib/browser/chunk-3VXJONTI.mjs.map +7 -0
- package/dist/lib/browser/{chunk-XYNO72GQ.mjs → chunk-7AL6SKIV.mjs} +459 -477
- package/dist/lib/browser/chunk-7AL6SKIV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-TCLLRCS3.mjs → chunk-GH3M2LIW.mjs} +10 -7
- package/dist/lib/browser/chunk-GH3M2LIW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7IQHKD4U.mjs → chunk-JGWCBVKJ.mjs} +2 -2
- package/dist/lib/browser/chunk-JGWCBVKJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-M5IC326L.mjs +34 -0
- package/dist/lib/browser/chunk-M5IC326L.mjs.map +7 -0
- package/dist/lib/browser/chunk-TGX63LTL.mjs +8 -0
- package/dist/lib/browser/{chunk-FHQTHCX7.mjs.map → chunk-TGX63LTL.mjs.map} +1 -1
- package/dist/lib/browser/chunk-TIEBZMTF.mjs +44 -0
- package/dist/lib/browser/chunk-TIEBZMTF.mjs.map +7 -0
- package/dist/lib/browser/chunk-WEBSGU5L.mjs +80 -0
- package/dist/lib/browser/chunk-WEBSGU5L.mjs.map +7 -0
- package/dist/lib/browser/chunk-YAFEA4GV.mjs +1 -0
- package/dist/lib/browser/{chunk-6Y7PZV72.mjs → chunk-YNFPIQGB.mjs} +2 -3
- package/dist/lib/browser/{chunk-6Y7PZV72.mjs.map → chunk-YNFPIQGB.mjs.map} +3 -3
- package/dist/lib/browser/cli/index.mjs +89 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/common/activation-events.mjs +23 -0
- package/dist/lib/browser/common/capabilities.mjs +45 -0
- package/dist/lib/browser/core/activation-event.mjs +1 -1
- package/dist/lib/browser/core/capability.mjs +1 -1
- package/dist/lib/browser/core/plugin-manager.mjs +4 -4
- package/dist/lib/browser/core/plugin.mjs +6 -4
- package/dist/lib/browser/index.mjs +37 -132
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{invoker-capability-SZRSTHEH.mjs → invoker-capability-YTTQ2OBB.mjs} +16 -12
- package/dist/lib/browser/invoker-capability-YTTQ2OBB.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +55 -34
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/browser/{react → ui}/index.mjs +18 -19
- package/dist/lib/node-esm/capability-CRHZKL6T.mjs +35 -0
- package/dist/lib/node-esm/capability-CRHZKL6T.mjs.map +7 -0
- package/dist/lib/node-esm/{capability-CFLQ2QQU.mjs → capability-W5C5464H.mjs} +15 -11
- package/dist/lib/node-esm/capability-W5C5464H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-663A54LQ.mjs → chunk-3D66SZHP.mjs} +2 -2
- package/dist/lib/node-esm/chunk-3D66SZHP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs → chunk-6REV5DE7.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs.map → chunk-6REV5DE7.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-XYQTBFPA.mjs → chunk-CMDON4NG.mjs} +304 -178
- package/dist/lib/node-esm/chunk-CMDON4NG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs → chunk-FKE4Z3D6.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs.map → chunk-FKE4Z3D6.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-6WXBT3EC.mjs → chunk-I7FZT4A7.mjs} +459 -477
- package/dist/lib/node-esm/chunk-I7FZT4A7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GT6OKM5I.mjs → chunk-LHCJGNXK.mjs} +10 -7
- package/dist/lib/node-esm/chunk-LHCJGNXK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NHXBSAQR.mjs +35 -0
- package/dist/lib/node-esm/chunk-NHXBSAQR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-STMXUEPO.mjs → chunk-SB5ODNPX.mjs} +2 -3
- package/dist/lib/node-esm/{chunk-STMXUEPO.mjs.map → chunk-SB5ODNPX.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-SCDGIGGU.mjs +45 -0
- package/dist/lib/node-esm/chunk-SCDGIGGU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SQICGJBW.mjs +81 -0
- package/dist/lib/node-esm/chunk-SQICGJBW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs +2 -0
- package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +90 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/common/activation-events.mjs +24 -0
- package/dist/lib/node-esm/common/activation-events.mjs.map +7 -0
- package/dist/lib/node-esm/common/capabilities.mjs +46 -0
- package/dist/lib/node-esm/common/capabilities.mjs.map +7 -0
- package/dist/lib/node-esm/core/activation-event.mjs +1 -1
- package/dist/lib/node-esm/core/capability.mjs +1 -1
- package/dist/lib/node-esm/core/plugin-manager.mjs +4 -4
- package/dist/lib/node-esm/core/plugin.mjs +6 -4
- package/dist/lib/node-esm/index.mjs +37 -132
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{invoker-capability-PNMA5JOS.mjs → invoker-capability-BU26474T.mjs} +16 -12
- package/dist/lib/node-esm/invoker-capability-BU26474T.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +55 -34
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{react → ui}/index.mjs +18 -19
- package/dist/lib/node-esm/ui/index.mjs.map +7 -0
- package/dist/types/src/{cli.d.ts → cli/cli.d.ts} +2 -2
- package/dist/types/src/cli/cli.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/common/activation-events.d.ts +27 -0
- package/dist/types/src/common/activation-events.d.ts.map +1 -0
- package/dist/types/src/common/capabilities.d.ts +115 -0
- package/dist/types/src/common/capabilities.d.ts.map +1 -0
- package/dist/types/src/common/index.d.ts +4 -9
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/operations.d.ts +1 -348
- package/dist/types/src/common/operations.d.ts.map +1 -1
- package/dist/types/src/common/translations.d.ts +0 -9
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/core/activation-event.d.ts +1 -1
- package/dist/types/src/core/capability.d.ts +7 -7
- package/dist/types/src/core/capability.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager.d.ts +6 -0
- package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
- package/dist/types/src/core/plugin.d.ts +6 -1
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/history/capability.d.ts +1 -1
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +11 -3
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/invoker-capability.d.ts +1 -1
- package/dist/types/src/plugin-runtime/capability.d.ts +2 -2
- package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -1
- package/dist/types/src/testing/withPluginManager.d.ts +1 -1
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
- package/dist/types/src/{react → ui/components/App}/App.d.ts +1 -1
- package/dist/types/src/ui/components/App/App.d.ts.map +1 -0
- package/dist/types/src/{react/Surface.stories.d.ts → ui/components/App/App.stories.d.ts} +7 -2
- package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/App/index.d.ts +2 -0
- package/dist/types/src/ui/components/App/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -0
- package/dist/types/src/{react → ui/components/PluginManager}/PluginManagerProvider.d.ts +1 -1
- package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts.map +1 -0
- package/dist/types/src/ui/components/PluginManager/index.d.ts +2 -0
- package/dist/types/src/ui/components/PluginManager/index.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +12 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -0
- package/dist/types/src/{react/App.stories.d.ts → ui/components/Surface/SurfaceComponent.stories.d.ts} +1 -1
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/context.d.ts +5 -0
- package/dist/types/src/ui/components/Surface/context.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/index.d.ts +20 -0
- package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -0
- package/dist/types/src/{common/surface.d.ts → ui/components/Surface/types.d.ts} +20 -18
- package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -0
- package/dist/types/src/ui/components/index.d.ts +4 -0
- package/dist/types/src/ui/components/index.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/index.d.ts +7 -0
- package/dist/types/src/ui/hooks/index.d.ts.map +1 -0
- package/dist/types/src/{react → ui/hooks}/useApp.d.ts +14 -9
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
- package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
- package/dist/types/src/{react → ui/hooks}/useCapabilities.d.ts +6 -1
- package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -0
- package/dist/types/src/{react → ui/hooks}/useOperationResolver.d.ts +2 -2
- package/dist/types/src/ui/hooks/useOperationResolver.d.ts.map +1 -0
- package/dist/types/src/{react/common.d.ts → ui/hooks/useSettingsState.d.ts} +1 -5
- package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useSurface.d.ts +3 -0
- package/dist/types/src/ui/hooks/useSurface.d.ts.map +1 -0
- package/dist/types/src/ui/index.d.ts +3 -0
- package/dist/types/src/ui/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/moon.yml +6 -6
- package/package.json +72 -64
- package/src/{cli.ts → cli/cli.ts} +10 -10
- package/src/{playground/debug → cli}/index.ts +1 -1
- package/src/common/activation-events.ts +44 -0
- package/src/common/capabilities.ts +178 -0
- package/src/common/index.ts +4 -9
- package/src/common/operations.ts +2 -376
- package/src/common/translations.ts +0 -12
- package/src/context.ts +1 -1
- package/src/core/activation-event.ts +1 -1
- package/src/core/capability.ts +9 -9
- package/src/core/plugin-manager.test.ts +292 -44
- package/src/core/plugin-manager.ts +326 -154
- package/src/core/plugin.ts +10 -2
- package/src/index.ts +1 -3
- package/src/plugin-operation/OperationPlugin.ts +5 -5
- package/src/plugin-operation/history/capability.ts +5 -5
- package/src/plugin-operation/history/undo-mapping.ts +6 -3
- package/src/plugin-operation/invoker-capability.ts +5 -5
- package/src/plugin-operation/meta.ts +1 -1
- package/src/plugin-runtime/RuntimePlugin.ts +4 -4
- package/src/plugin-runtime/capability.ts +5 -5
- package/src/plugin-runtime/meta.ts +1 -1
- package/src/testing/service.ts +6 -6
- package/src/testing/withPluginManager.stories.tsx +6 -6
- package/src/testing/withPluginManager.tsx +46 -19
- package/src/ui/components/App/App.stories.tsx +92 -0
- package/src/{react → ui/components/App}/App.tsx +6 -9
- package/src/{playground/layout → ui/components/App}/index.ts +1 -1
- package/src/{react → ui/components/PluginManager}/PluginManagerContext.stories.tsx +13 -14
- package/src/{react → ui/components/PluginManager}/PluginManagerProvider.ts +1 -1
- package/src/ui/components/PluginManager/index.ts +5 -0
- package/src/{react/Surface.stories.tsx → ui/components/Surface/SurfaceComponent.stories.tsx} +18 -16
- package/src/{react/Surface.tsx → ui/components/Surface/SurfaceComponent.tsx} +36 -56
- package/src/{react → ui/components/Surface}/SurfaceInfo.tsx +2 -2
- package/src/ui/components/Surface/context.ts +12 -0
- package/src/ui/components/Surface/index.ts +20 -0
- package/src/{common/surface.ts → ui/components/Surface/types.ts} +22 -25
- package/src/ui/components/index.ts +7 -0
- package/src/ui/hooks/index.ts +10 -0
- package/src/ui/hooks/useApp.test.tsx +159 -0
- package/src/{react → ui/hooks}/useApp.tsx +39 -29
- package/src/{react → ui/hooks}/useCapabilities.ts +9 -5
- package/src/{react → ui/hooks}/useOperationResolver.ts +5 -5
- package/src/{react/common.ts → ui/hooks/useSettingsState.ts} +0 -11
- package/src/ui/hooks/useSurface.ts +13 -0
- package/src/ui/index.ts +6 -0
- package/tsconfig.json +2 -29
- package/tsconfig.node.json +1 -3
- package/typedoc.json +2 -4
- package/vitest.config.ts +1 -1
- package/dist/lib/browser/app-graph-builder-M2VPYQC6.mjs +0 -149
- package/dist/lib/browser/app-graph-builder-M2VPYQC6.mjs.map +0 -7
- package/dist/lib/browser/capability-7PCNSWBT.mjs.map +0 -7
- package/dist/lib/browser/capability-KP3PFEXD.mjs +0 -31
- package/dist/lib/browser/capability-KP3PFEXD.mjs.map +0 -7
- package/dist/lib/browser/chunk-7IQHKD4U.mjs.map +0 -7
- package/dist/lib/browser/chunk-BLQJSGL3.mjs +0 -732
- package/dist/lib/browser/chunk-BLQJSGL3.mjs.map +0 -7
- package/dist/lib/browser/chunk-FHQTHCX7.mjs +0 -8
- package/dist/lib/browser/chunk-FMZN33N4.mjs.map +0 -7
- package/dist/lib/browser/chunk-H4WPA7U7.mjs +0 -77
- package/dist/lib/browser/chunk-H4WPA7U7.mjs.map +0 -7
- package/dist/lib/browser/chunk-TCLLRCS3.mjs.map +0 -7
- package/dist/lib/browser/chunk-XYNO72GQ.mjs.map +0 -7
- package/dist/lib/browser/common/index.mjs +0 -38
- package/dist/lib/browser/invoker-capability-SZRSTHEH.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-6MP2MYOY.mjs +0 -64
- package/dist/lib/browser/operation-resolver-6MP2MYOY.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-LROHGJEM.mjs +0 -150
- package/dist/lib/node-esm/app-graph-builder-LROHGJEM.mjs.map +0 -7
- package/dist/lib/node-esm/capability-CFLQ2QQU.mjs.map +0 -7
- package/dist/lib/node-esm/capability-RCUNM2M7.mjs +0 -32
- package/dist/lib/node-esm/capability-RCUNM2M7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-663A54LQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6WXBT3EC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GQEBIGKD.mjs +0 -733
- package/dist/lib/node-esm/chunk-GQEBIGKD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GT6OKM5I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XR6NMKEP.mjs +0 -78
- package/dist/lib/node-esm/chunk-XR6NMKEP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XYQTBFPA.mjs.map +0 -7
- package/dist/lib/node-esm/common/index.mjs +0 -39
- package/dist/lib/node-esm/invoker-capability-PNMA5JOS.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-7YWDMTNU.mjs +0 -65
- package/dist/lib/node-esm/operation-resolver-7YWDMTNU.mjs.map +0 -7
- package/dist/types/src/cli.d.ts.map +0 -1
- package/dist/types/src/common/activation-event.d.ts +0 -66
- package/dist/types/src/common/activation-event.d.ts.map +0 -1
- package/dist/types/src/common/capability.d.ts +0 -265
- package/dist/types/src/common/capability.d.ts.map +0 -1
- package/dist/types/src/common/collaboration.d.ts +0 -26
- package/dist/types/src/common/collaboration.d.ts.map +0 -1
- package/dist/types/src/common/file.d.ts +0 -14
- package/dist/types/src/common/file.d.ts.map +0 -1
- package/dist/types/src/common/graph.d.ts +0 -21
- package/dist/types/src/common/graph.d.ts.map +0 -1
- package/dist/types/src/common/plugin.d.ts +0 -201
- package/dist/types/src/common/plugin.d.ts.map +0 -1
- package/dist/types/src/common/surface.d.ts.map +0 -1
- package/dist/types/src/playground/debug/Debug.d.ts +0 -8
- package/dist/types/src/playground/debug/Debug.d.ts.map +0 -1
- package/dist/types/src/playground/debug/index.d.ts +0 -2
- package/dist/types/src/playground/debug/index.d.ts.map +0 -1
- package/dist/types/src/playground/debug/plugin.d.ts +0 -3
- package/dist/types/src/playground/debug/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/generator/Main.d.ts +0 -8
- package/dist/types/src/playground/generator/Main.d.ts.map +0 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +0 -8
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +0 -1
- package/dist/types/src/playground/generator/generator.d.ts +0 -19
- package/dist/types/src/playground/generator/generator.d.ts.map +0 -1
- package/dist/types/src/playground/generator/index.d.ts +0 -3
- package/dist/types/src/playground/generator/index.d.ts.map +0 -1
- package/dist/types/src/playground/generator/plugin.d.ts +0 -3
- package/dist/types/src/playground/generator/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/layout/Layout.d.ts +0 -10
- package/dist/types/src/playground/layout/Layout.d.ts.map +0 -1
- package/dist/types/src/playground/layout/index.d.ts +0 -2
- package/dist/types/src/playground/layout/index.d.ts.map +0 -1
- package/dist/types/src/playground/layout/plugin.d.ts +0 -3
- package/dist/types/src/playground/layout/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +0 -8
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +0 -1
- package/dist/types/src/playground/logger/index.d.ts +0 -2
- package/dist/types/src/playground/logger/index.d.ts.map +0 -1
- package/dist/types/src/playground/logger/plugin.d.ts +0 -3
- package/dist/types/src/playground/logger/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/logger/schema.d.ts +0 -27
- package/dist/types/src/playground/logger/schema.d.ts.map +0 -1
- package/dist/types/src/playground/playground.stories.d.ts +0 -11
- package/dist/types/src/playground/playground.stories.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +0 -3
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/actions.d.ts +0 -61
- package/dist/types/src/plugin-settings/actions.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +0 -6
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/index.d.ts +0 -3
- package/dist/types/src/plugin-settings/index.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/meta.d.ts +0 -3
- package/dist/types/src/plugin-settings/meta.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/operation-resolver.d.ts +0 -6
- package/dist/types/src/plugin-settings/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/translations.d.ts +0 -11
- package/dist/types/src/plugin-settings/translations.d.ts.map +0 -1
- package/dist/types/src/react/App.d.ts.map +0 -1
- package/dist/types/src/react/App.stories.d.ts.map +0 -1
- package/dist/types/src/react/DefaultFallback.d.ts +0 -8
- package/dist/types/src/react/DefaultFallback.d.ts.map +0 -1
- package/dist/types/src/react/ErrorBoundary.d.ts +0 -30
- package/dist/types/src/react/ErrorBoundary.d.ts.map +0 -1
- package/dist/types/src/react/PluginManagerContext.stories.d.ts.map +0 -1
- package/dist/types/src/react/PluginManagerProvider.d.ts.map +0 -1
- package/dist/types/src/react/Surface.d.ts +0 -14
- package/dist/types/src/react/Surface.d.ts.map +0 -1
- package/dist/types/src/react/Surface.stories.d.ts.map +0 -1
- package/dist/types/src/react/SurfaceInfo.d.ts.map +0 -1
- package/dist/types/src/react/common.d.ts.map +0 -1
- package/dist/types/src/react/index.d.ts +0 -9
- package/dist/types/src/react/index.d.ts.map +0 -1
- package/dist/types/src/react/types.d.ts +0 -12
- package/dist/types/src/react/types.d.ts.map +0 -1
- package/dist/types/src/react/useApp.d.ts.map +0 -1
- package/dist/types/src/react/useCapabilities.d.ts.map +0 -1
- package/dist/types/src/react/useLoading.d.ts.map +0 -1
- package/dist/types/src/react/useOperationResolver.d.ts.map +0 -1
- package/src/common/activation-event.ts +0 -99
- package/src/common/capability.ts +0 -343
- package/src/common/collaboration.ts +0 -31
- package/src/common/file.ts +0 -22
- package/src/common/graph.ts +0 -30
- package/src/common/plugin.ts +0 -364
- package/src/playground/debug/Debug.tsx +0 -49
- package/src/playground/debug/plugin.ts +0 -16
- package/src/playground/generator/Main.tsx +0 -80
- package/src/playground/generator/Toolbar.tsx +0 -57
- package/src/playground/generator/generator.ts +0 -48
- package/src/playground/generator/index.ts +0 -6
- package/src/playground/generator/plugin.ts +0 -21
- package/src/playground/layout/Layout.tsx +0 -37
- package/src/playground/layout/plugin.ts +0 -18
- package/src/playground/logger/Toolbar.tsx +0 -33
- package/src/playground/logger/index.ts +0 -5
- package/src/playground/logger/plugin.ts +0 -42
- package/src/playground/logger/schema.ts +0 -22
- package/src/playground/playground.stories.tsx +0 -54
- package/src/plugin-settings/SettingsPlugin.ts +0 -19
- package/src/plugin-settings/actions.ts +0 -64
- package/src/plugin-settings/app-graph-builder.ts +0 -140
- package/src/plugin-settings/index.ts +0 -6
- package/src/plugin-settings/meta.ts +0 -10
- package/src/plugin-settings/operation-resolver.ts +0 -55
- package/src/plugin-settings/translations.ts +0 -19
- package/src/react/App.stories.tsx +0 -63
- package/src/react/DefaultFallback.tsx +0 -26
- package/src/react/ErrorBoundary.tsx +0 -56
- package/src/react/index.ts +0 -14
- package/src/react/types.ts +0 -27
- /package/dist/lib/{node-esm/react/index.mjs.map → browser/chunk-YAFEA4GV.mjs.map} +0 -0
- /package/dist/lib/{node-esm/common/index.mjs.map → browser/common/activation-events.mjs.map} +0 -0
- /package/dist/lib/browser/{react/index.mjs.map → common/capabilities.mjs.map} +0 -0
- /package/dist/lib/browser/{common → ui}/index.mjs.map +0 -0
- /package/dist/types/src/{react → ui/components/PluginManager}/PluginManagerContext.stories.d.ts +0 -0
- /package/dist/types/src/{react → ui/components/Surface}/SurfaceInfo.d.ts +0 -0
- /package/dist/types/src/{react → ui/hooks}/useLoading.d.ts +0 -0
- /package/src/{react → ui/hooks}/useLoading.tsx +0 -0
|
@@ -3,47 +3,40 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import React, {
|
|
6
|
-
type Context,
|
|
7
6
|
Fragment,
|
|
8
7
|
type NamedExoticComponent,
|
|
9
8
|
type RefAttributes,
|
|
10
9
|
Suspense,
|
|
11
|
-
createContext,
|
|
12
10
|
forwardRef,
|
|
13
11
|
memo,
|
|
14
|
-
useContext,
|
|
15
12
|
useEffect,
|
|
16
13
|
useMemo,
|
|
17
14
|
useRef,
|
|
18
15
|
} from 'react';
|
|
19
16
|
|
|
20
|
-
import { raise } from '@dxos/debug';
|
|
21
17
|
import { log } from '@dxos/log';
|
|
18
|
+
import { ErrorBoundary } from '@dxos/react-error-boundary';
|
|
22
19
|
import { useDefaultValue } from '@dxos/react-hooks';
|
|
23
20
|
import { byPosition } from '@dxos/util';
|
|
24
21
|
|
|
25
|
-
import
|
|
26
|
-
import { type CapabilityManager } from '
|
|
22
|
+
import { Capabilities } from '../../../common';
|
|
23
|
+
import { type CapabilityManager } from '../../../core';
|
|
24
|
+
import { useCapabilities } from '../../hooks';
|
|
27
25
|
|
|
28
|
-
import {
|
|
26
|
+
import { SurfaceContext } from './context';
|
|
29
27
|
import { SurfaceInfo } from './SurfaceInfo';
|
|
30
|
-
import {
|
|
28
|
+
import { type Definition, type Props, type WebComponentDefinition } from './types';
|
|
31
29
|
|
|
32
30
|
const DEFAULT_PLACEHOLDER = <Fragment />;
|
|
33
31
|
|
|
34
32
|
const DEBUG = import.meta.env.VITE_DEBUG;
|
|
35
33
|
|
|
36
|
-
export type SurfaceContext = Pick<Common.SurfaceProps, 'id' | 'role' | 'data'>;
|
|
37
|
-
|
|
38
|
-
// TODO(burdon): Use @radix-ui/react-context
|
|
39
|
-
const SurfaceContext: Context<SurfaceContext | undefined> = createContext<SurfaceContext | undefined>(undefined);
|
|
40
|
-
|
|
41
34
|
/**
|
|
42
35
|
* Wrapper component for rendering Web Component surfaces.
|
|
43
36
|
* Handles creation, prop setting, and cleanup of Web Components.
|
|
44
37
|
*/
|
|
45
38
|
const WebComponentWrapper = memo(
|
|
46
|
-
forwardRef<HTMLElement,
|
|
39
|
+
forwardRef<HTMLElement, Props & { definition: WebComponentDefinition }>(
|
|
47
40
|
({ id, role, data, limit, definition, ...rest }, forwardedRef) => {
|
|
48
41
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
49
42
|
const elementRef = useRef<HTMLElement | null>(null);
|
|
@@ -54,7 +47,9 @@ const WebComponentWrapper = memo(
|
|
|
54
47
|
|
|
55
48
|
// Create element only once
|
|
56
49
|
useEffect(() => {
|
|
57
|
-
if (!containerRef.current || elementRef.current)
|
|
50
|
+
if (!containerRef.current || elementRef.current) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
58
53
|
|
|
59
54
|
// Create the Web Component
|
|
60
55
|
const element = document.createElement(definition.tagName);
|
|
@@ -91,7 +86,9 @@ const WebComponentWrapper = memo(
|
|
|
91
86
|
// This runs on every render to ensure all props (including those in `rest`) are kept up to date
|
|
92
87
|
useEffect(() => {
|
|
93
88
|
const element = elementRef.current;
|
|
94
|
-
if (!element)
|
|
89
|
+
if (!element) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
95
92
|
|
|
96
93
|
// Update properties on the existing Web Component
|
|
97
94
|
Object.assign(element, propsRef.current);
|
|
@@ -107,15 +104,16 @@ WebComponentWrapper.displayName = 'WebComponentWrapper';
|
|
|
107
104
|
/**
|
|
108
105
|
* Wrapper component that provides context for a surface.
|
|
109
106
|
*/
|
|
107
|
+
// TODO(burdon): Allow DebugPlugin to provide different fallback using react-ui ErrorFallback.
|
|
110
108
|
const SurfaceContextProvider = memo(
|
|
111
|
-
forwardRef<HTMLElement,
|
|
112
|
-
({ id, role, data, limit, fallback =
|
|
109
|
+
forwardRef<HTMLElement, Props & { definition: Definition }>(
|
|
110
|
+
({ id, role, data, limit, fallback = ErrorFallback, definition, ...rest }, forwardedRef) => {
|
|
113
111
|
const contextValue = useMemo(() => ({ id, role, data }), [id, role, data]);
|
|
114
112
|
|
|
115
113
|
// Handle Web Component surfaces
|
|
116
114
|
if (definition.kind === 'web-component') {
|
|
117
115
|
return (
|
|
118
|
-
<ErrorBoundary
|
|
116
|
+
<ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
|
|
119
117
|
<SurfaceContext.Provider value={contextValue}>
|
|
120
118
|
<WebComponentWrapper
|
|
121
119
|
id={id}
|
|
@@ -138,7 +136,7 @@ const SurfaceContextProvider = memo(
|
|
|
138
136
|
const debug = DEBUG || '__DX_DEBUG__' in window;
|
|
139
137
|
if (debug) {
|
|
140
138
|
return (
|
|
141
|
-
<ErrorBoundary
|
|
139
|
+
<ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
|
|
142
140
|
<div role='none' className='contents' data-id={id} data-role={role}>
|
|
143
141
|
<SurfaceContext.Provider value={contextValue}>
|
|
144
142
|
<SurfaceInfo ref={forwardedRef}>
|
|
@@ -151,7 +149,7 @@ const SurfaceContextProvider = memo(
|
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
return (
|
|
154
|
-
<ErrorBoundary
|
|
152
|
+
<ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
|
|
155
153
|
<div role='none' className='contents' data-id={id} data-role={role}>
|
|
156
154
|
<SurfaceContext.Provider value={contextValue}>
|
|
157
155
|
<Component id={id} role={role} data={data} limit={limit} {...rest} ref={forwardedRef} />
|
|
@@ -165,15 +163,11 @@ const SurfaceContextProvider = memo(
|
|
|
165
163
|
|
|
166
164
|
SurfaceContextProvider.displayName = 'SurfaceContextProvider';
|
|
167
165
|
|
|
168
|
-
export const useSurface = (): SurfaceContext => {
|
|
169
|
-
const context = useContext(SurfaceContext) ?? raise(new Error('Missing SurfaceContext'));
|
|
170
|
-
return context;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
166
|
/**
|
|
174
167
|
* A surface is a named region of the screen that can be populated by plugins.
|
|
175
168
|
*/
|
|
176
|
-
|
|
169
|
+
// TODO(burdon): Remove `ref` since relying on this would be error prone.
|
|
170
|
+
export const SurfaceComponent: NamedExoticComponent<Props & RefAttributes<HTMLElement>> = memo(
|
|
177
171
|
forwardRef(({ id: _id, role, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {
|
|
178
172
|
const data = useDefaultValue(dataProp, () => ({}));
|
|
179
173
|
|
|
@@ -211,12 +205,19 @@ export const Surface: NamedExoticComponent<Common.SurfaceProps & RefAttributes<H
|
|
|
211
205
|
}),
|
|
212
206
|
);
|
|
213
207
|
|
|
214
|
-
|
|
208
|
+
SurfaceComponent.displayName = 'Surface';
|
|
215
209
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
{
|
|
219
|
-
|
|
210
|
+
// TODO(burdon): Make user facing, with telemetry.
|
|
211
|
+
const ErrorFallback = ({ error }: Props) => {
|
|
212
|
+
const { message } = error instanceof Error ? error : { message: String(error) };
|
|
213
|
+
return (
|
|
214
|
+
<div role='alert' data-testid='error-boundary-fallback'>
|
|
215
|
+
<h1 className='flex gap-2 text-sm mt-2 text-info-text'>{message}</h1>
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const findCandidates = (surfaces: Definition[], { role, data }: Pick<Props, 'role' | 'data'>) => {
|
|
220
221
|
return Object.values(surfaces)
|
|
221
222
|
.filter((definition) =>
|
|
222
223
|
Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,
|
|
@@ -225,32 +226,11 @@ const findCandidates = (
|
|
|
225
226
|
.toSorted(byPosition);
|
|
226
227
|
};
|
|
227
228
|
|
|
228
|
-
// TODO(burdon): Make user facing, with telemetry.
|
|
229
|
-
// TODO(burdon): Change based on dev/prod mode; infer subject type, id.
|
|
230
|
-
const DefaultFallback = ({ data, error, dev }: { data: any; error: Error; dev?: boolean }) => {
|
|
231
|
-
if (dev) {
|
|
232
|
-
return (
|
|
233
|
-
<div className='flex flex-col gap-4 p-4 is-full overflow-y-auto'>
|
|
234
|
-
<h1 className='flex gap-2 text-sm mbs-2'>{error.message}</h1>
|
|
235
|
-
<pre className='overflow-auto text-xs text-description'>{JSON.stringify(data, null, 2)}</pre>
|
|
236
|
-
</div>
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return (
|
|
241
|
-
<div className='flex flex-col gap-4 p-4 is-full overflow-y-auto border border-roseFill'>
|
|
242
|
-
<h1 className='flex gap-2 text-sm mbs-2 text-rose-500'>{error.message}</h1>
|
|
243
|
-
<pre className='overflow-auto text-xs text-description'>{error.stack}</pre>
|
|
244
|
-
<pre className='overflow-auto text-xs text-description'>{JSON.stringify(data, null, 2)}</pre>
|
|
245
|
-
</div>
|
|
246
|
-
);
|
|
247
|
-
};
|
|
248
|
-
|
|
249
229
|
/**
|
|
250
230
|
* @internal
|
|
251
231
|
*/
|
|
252
232
|
export const useSurfaces = () => {
|
|
253
|
-
const surfaces = useCapabilities(
|
|
233
|
+
const surfaces = useCapabilities(Capabilities.ReactSurface);
|
|
254
234
|
return useMemo(() => surfaces.flat(), [surfaces]);
|
|
255
235
|
};
|
|
256
236
|
|
|
@@ -259,9 +239,9 @@ export const useSurfaces = () => {
|
|
|
259
239
|
*/
|
|
260
240
|
export const isSurfaceAvailable = (
|
|
261
241
|
capabilityManager: CapabilityManager.CapabilityManager,
|
|
262
|
-
{ role, data }: Pick<
|
|
242
|
+
{ role, data }: Pick<Props, 'role' | 'data'>,
|
|
263
243
|
) => {
|
|
264
|
-
const surfaces = capabilityManager.getAll(
|
|
244
|
+
const surfaces = capabilityManager.getAll(Capabilities.ReactSurface);
|
|
265
245
|
const candidates = findCandidates(surfaces.flat(), { role, data });
|
|
266
246
|
return candidates.length > 0;
|
|
267
247
|
};
|
|
@@ -16,7 +16,7 @@ import { createPortal } from 'react-dom';
|
|
|
16
16
|
import { addEventListener, combine } from '@dxos/async';
|
|
17
17
|
import { useMergeRefs } from '@dxos/react-hooks';
|
|
18
18
|
|
|
19
|
-
import { useSurface } from '
|
|
19
|
+
import { useSurface } from '../../hooks';
|
|
20
20
|
|
|
21
21
|
export type SurfaceInfoProps = {
|
|
22
22
|
children: ReactElement<{ ref?: Ref<HTMLElement> }>;
|
|
@@ -76,7 +76,7 @@ export const SurfaceInfo = forwardRef<HTMLElement, SurfaceInfoProps>(({ children
|
|
|
76
76
|
>
|
|
77
77
|
{expand ? (
|
|
78
78
|
<div
|
|
79
|
-
className='absolute inset-0 bg-
|
|
79
|
+
className='absolute inset-0 bg-deck-surface border border-green-500 cursor-pointer pointer-events-auto overflow-auto'
|
|
80
80
|
onPointerDown={(ev) => ev.stopPropagation()}
|
|
81
81
|
onClick={(ev) => {
|
|
82
82
|
ev.stopPropagation();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Context, createContext } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Props } from './types';
|
|
8
|
+
|
|
9
|
+
export type SurfaceContext = Pick<Props, 'id' | 'role' | 'data'>;
|
|
10
|
+
|
|
11
|
+
// TODO(burdon): Use @radix-ui/react-context
|
|
12
|
+
export const SurfaceContext: Context<SurfaceContext | undefined> = createContext<SurfaceContext | undefined>(undefined);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
// TODO(wittjosiah): Cleanup to avoid re-naming.
|
|
6
|
+
import { SurfaceContext } from './context';
|
|
7
|
+
import { SurfaceComponent, isSurfaceAvailable } from './SurfaceComponent';
|
|
8
|
+
import { type Definition as SurfaceDefinition, create as createSurface, createWeb as createWebSurface } from './types';
|
|
9
|
+
|
|
10
|
+
export namespace Surface {
|
|
11
|
+
export type Definition = SurfaceDefinition;
|
|
12
|
+
export const create = createSurface;
|
|
13
|
+
export const createWeb = createWebSurface;
|
|
14
|
+
|
|
15
|
+
export type Context = SurfaceContext;
|
|
16
|
+
export const Context = SurfaceContext;
|
|
17
|
+
|
|
18
|
+
export const Surface = SurfaceComponent;
|
|
19
|
+
export const isAvailable = isSurfaceAvailable;
|
|
20
|
+
}
|
|
@@ -2,41 +2,39 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type { PropsWithChildren, ReactNode, RefCallback } from 'react';
|
|
5
|
+
import type { FC, PropsWithChildren, ReactNode, RefCallback } from 'react';
|
|
6
6
|
|
|
7
7
|
import type { MakeOptional, Position } from '@dxos/util';
|
|
8
8
|
|
|
9
|
-
import type { ErrorBoundary } from '../react';
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
10
|
+
* Props that are passed to the Surface component.
|
|
13
11
|
*/
|
|
14
|
-
export type
|
|
12
|
+
export type Props<T extends Record<string, any> = Record<string, unknown>> = {
|
|
15
13
|
/**
|
|
16
14
|
* If specified, the Surface will be wrapped in an error boundary.
|
|
17
15
|
* The fallback component will be rendered if an error occurs.
|
|
18
16
|
*/
|
|
19
|
-
fallback?:
|
|
17
|
+
fallback?: FC<{ error: Error; data?: any }>;
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* If specified, the Surface will be wrapped in a suspense boundary.
|
|
23
21
|
* The placeholder component will be rendered while the surface component is loading.
|
|
24
22
|
*/
|
|
25
23
|
placeholder?: ReactNode;
|
|
26
|
-
} & MakeOptional<
|
|
24
|
+
} & MakeOptional<CoreProps<T>, 'id' | 'data'> &
|
|
27
25
|
/**
|
|
28
26
|
* Additional props to pass to the component.
|
|
29
27
|
* These props are not used by Surface itself but may be used by components which resolve the surface.
|
|
30
28
|
* Exclude known prop names to prevent overriding well-defined props.
|
|
31
29
|
*/
|
|
32
30
|
{
|
|
33
|
-
[K in keyof Record<string, any>]: K extends keyof
|
|
31
|
+
[K in keyof Record<string, any>]: K extends keyof CoreProps<T> | 'fallback' | 'placeholder' ? never : any;
|
|
34
32
|
};
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.
|
|
38
36
|
*/
|
|
39
|
-
export type
|
|
37
|
+
export type CoreProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{
|
|
40
38
|
/**
|
|
41
39
|
* ID for debugging.
|
|
42
40
|
*/
|
|
@@ -59,33 +57,34 @@ export type CoreSurfaceProps<T extends Record<string, any> = Record<string, unkn
|
|
|
59
57
|
limit?: number | undefined;
|
|
60
58
|
}>;
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
// TODO(burdon): Remove ref since relying on this would be error prone.
|
|
61
|
+
export type ComponentProps<T extends Record<string, any> = Record<string, any>> = CoreProps<T> & {
|
|
63
62
|
ref?: RefCallback<HTMLElement>;
|
|
64
63
|
} & Record<string, any>;
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
66
|
* React component used to render a surface once is has matched.
|
|
68
67
|
*/
|
|
69
|
-
export type
|
|
70
|
-
props:
|
|
68
|
+
export type ComponentFunction<T extends Record<string, any> = Record<string, any>> = (
|
|
69
|
+
props: ComponentProps<T>,
|
|
71
70
|
) => ReactNode;
|
|
72
71
|
|
|
73
72
|
/**
|
|
74
|
-
* Definition of when a React
|
|
73
|
+
* Definition of when a React component surface should be rendered.
|
|
75
74
|
*/
|
|
76
|
-
export type
|
|
75
|
+
export type ReactDefinition<T extends Record<string, any> = any> = Readonly<{
|
|
77
76
|
kind: 'react';
|
|
78
77
|
id: string;
|
|
79
78
|
role: string | string[];
|
|
80
79
|
position?: Position;
|
|
81
|
-
component:
|
|
80
|
+
component: ComponentFunction<T>;
|
|
82
81
|
filter?: (data: Record<string, unknown>) => data is T;
|
|
83
82
|
}>;
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
85
|
* Definition of when a Web Component surface should be rendered.
|
|
87
86
|
*/
|
|
88
|
-
export type
|
|
87
|
+
export type WebComponentDefinition<T extends Record<string, any> = any> = Readonly<{
|
|
89
88
|
kind: 'web-component';
|
|
90
89
|
id: string;
|
|
91
90
|
role: string | string[];
|
|
@@ -101,20 +100,18 @@ export type WebComponentSurfaceDefinition<T extends Record<string, any> = any> =
|
|
|
101
100
|
/**
|
|
102
101
|
* Definition of when a surface (React or Web Component) should be rendered.
|
|
103
102
|
*/
|
|
104
|
-
export type
|
|
105
|
-
| ReactSurfaceDefinition<T>
|
|
106
|
-
| WebComponentSurfaceDefinition<T>;
|
|
103
|
+
export type Definition<T extends Record<string, any> = any> = ReactDefinition<T> | WebComponentDefinition<T>;
|
|
107
104
|
|
|
108
105
|
/**
|
|
109
106
|
* Creates a React surface definition.
|
|
110
107
|
*/
|
|
111
|
-
export const
|
|
112
|
-
definition: Omit<
|
|
113
|
-
):
|
|
108
|
+
export const create = <T extends Record<string, any> = any>(
|
|
109
|
+
definition: Omit<ReactDefinition<T>, 'kind'>,
|
|
110
|
+
): ReactDefinition<T> => ({ ...definition, kind: 'react' });
|
|
114
111
|
|
|
115
112
|
/**
|
|
116
113
|
* Creates a Web Component surface definition.
|
|
117
114
|
*/
|
|
118
|
-
export const
|
|
119
|
-
definition: Omit<
|
|
120
|
-
):
|
|
115
|
+
export const createWeb = <T extends Record<string, any> = any>(
|
|
116
|
+
definition: Omit<WebComponentDefinition<T>, 'kind'>,
|
|
117
|
+
): WebComponentDefinition<T> => ({ ...definition, kind: 'web-component' });
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { assert, describe, it } from '@effect/vitest';
|
|
6
|
+
import { render, waitFor } from '@testing-library/react';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { ActivationEvents, Capabilities } from '../../common';
|
|
11
|
+
import { Capability, Plugin, PluginManager } from '../../core';
|
|
12
|
+
import { useApp } from './useApp';
|
|
13
|
+
|
|
14
|
+
const String = Capability.make<{ string: string }>('org.dxos.test.string');
|
|
15
|
+
const testMeta = { id: 'org.dxos.plugin.test', name: 'Test' };
|
|
16
|
+
|
|
17
|
+
const pluginLoader = (plugins: Plugin.Plugin[]) =>
|
|
18
|
+
Effect.fn(function* (id: string) {
|
|
19
|
+
const plugin = plugins.find((plugin) => plugin.meta.id === id);
|
|
20
|
+
if (!plugin) {
|
|
21
|
+
return yield* Effect.fail(new Error(`Plugin not found: ${id}`));
|
|
22
|
+
}
|
|
23
|
+
return plugin;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const TestHost = ({ manager }: { manager: PluginManager.PluginManager }) => {
|
|
27
|
+
const App = useApp({ pluginManager: manager });
|
|
28
|
+
return <App />;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe('useApp cleanup integration', () => {
|
|
32
|
+
it.effect('external manager is not shut down when useApp does not own it', () =>
|
|
33
|
+
Effect.gen(function* () {
|
|
34
|
+
const plugin = Plugin.define(testMeta).pipe(
|
|
35
|
+
Plugin.addModule({
|
|
36
|
+
id: 'Hello',
|
|
37
|
+
activatesOn: ActivationEvents.Startup,
|
|
38
|
+
activate: () => Effect.succeed(Capability.contributes(String, { string: 'hello' })),
|
|
39
|
+
}),
|
|
40
|
+
Plugin.make,
|
|
41
|
+
)();
|
|
42
|
+
|
|
43
|
+
const manager = PluginManager.make({
|
|
44
|
+
pluginLoader: pluginLoader([plugin]),
|
|
45
|
+
plugins: [plugin],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
manager.capabilities.contribute({
|
|
49
|
+
interface: Capabilities.PluginManager,
|
|
50
|
+
implementation: manager,
|
|
51
|
+
module: 'org.dxos.app-framework.plugin-manager',
|
|
52
|
+
});
|
|
53
|
+
manager.capabilities.contribute({
|
|
54
|
+
interface: Capabilities.AtomRegistry,
|
|
55
|
+
implementation: manager.registry,
|
|
56
|
+
module: 'org.dxos.app-framework.atom-registry',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const view = yield* Effect.promise(() => Promise.resolve(render(<TestHost manager={manager} />)));
|
|
60
|
+
yield* Effect.promise(() =>
|
|
61
|
+
waitFor(() => {
|
|
62
|
+
assert.strictEqual(manager.capabilities.getAll(Capabilities.PluginManager).length, 1);
|
|
63
|
+
assert.strictEqual(manager.capabilities.getAll(Capabilities.AtomRegistry).length, 1);
|
|
64
|
+
assert.strictEqual(manager.capabilities.getAll(String).length, 1);
|
|
65
|
+
assert.isTrue(manager.getActive().length > 0);
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
yield* Effect.promise(() => Promise.resolve(view.unmount()));
|
|
70
|
+
yield* Effect.promise(() =>
|
|
71
|
+
waitFor(() => {
|
|
72
|
+
assert.strictEqual(manager.capabilities.getAll(Capabilities.PluginManager).length, 1);
|
|
73
|
+
assert.strictEqual(manager.capabilities.getAll(Capabilities.AtomRegistry).length, 1);
|
|
74
|
+
assert.strictEqual(manager.capabilities.getAll(String).length, 1);
|
|
75
|
+
assert.isTrue(manager.getActive().length > 0);
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
yield* manager.shutdown();
|
|
80
|
+
|
|
81
|
+
assert.strictEqual(manager.capabilities.getAll(Capabilities.PluginManager).length, 1);
|
|
82
|
+
assert.strictEqual(manager.capabilities.getAll(Capabilities.AtomRegistry).length, 1);
|
|
83
|
+
assert.strictEqual(manager.capabilities.getAll(String).length, 0);
|
|
84
|
+
assert.deepStrictEqual(manager.getActive(), []);
|
|
85
|
+
}),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
it.effect('shutdown deactivates modules and clears bookkeeping', () =>
|
|
89
|
+
Effect.gen(function* () {
|
|
90
|
+
const plugin = Plugin.define(testMeta).pipe(
|
|
91
|
+
Plugin.addModule({
|
|
92
|
+
id: 'Hello',
|
|
93
|
+
activatesOn: ActivationEvents.Startup,
|
|
94
|
+
activate: () => Effect.succeed(Capability.contributes(String, { string: 'hello' })),
|
|
95
|
+
}),
|
|
96
|
+
Plugin.make,
|
|
97
|
+
)();
|
|
98
|
+
|
|
99
|
+
const manager = PluginManager.make({
|
|
100
|
+
pluginLoader: pluginLoader([plugin]),
|
|
101
|
+
plugins: [plugin],
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
manager.capabilities.contribute({
|
|
105
|
+
interface: Capabilities.PluginManager,
|
|
106
|
+
implementation: manager,
|
|
107
|
+
module: 'org.dxos.app-framework.plugin-manager',
|
|
108
|
+
});
|
|
109
|
+
manager.capabilities.contribute({
|
|
110
|
+
interface: Capabilities.AtomRegistry,
|
|
111
|
+
implementation: manager.registry,
|
|
112
|
+
module: 'org.dxos.app-framework.atom-registry',
|
|
113
|
+
});
|
|
114
|
+
yield* manager.activate(ActivationEvents.Startup);
|
|
115
|
+
|
|
116
|
+
assert.strictEqual(manager.capabilities.getAll(String).length, 1);
|
|
117
|
+
assert.isTrue(manager.getActive().length > 0);
|
|
118
|
+
|
|
119
|
+
yield* manager.shutdown();
|
|
120
|
+
|
|
121
|
+
assert.strictEqual(manager.capabilities.getAll(String).length, 0);
|
|
122
|
+
assert.deepStrictEqual(manager.getActive(), []);
|
|
123
|
+
assert.deepStrictEqual(manager.getEventsFired(), []);
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
it.effect('shutdown is idempotent when called multiple times', () =>
|
|
128
|
+
Effect.gen(function* () {
|
|
129
|
+
const plugin = Plugin.define(testMeta).pipe(
|
|
130
|
+
Plugin.addModule({
|
|
131
|
+
id: 'Hello',
|
|
132
|
+
activatesOn: ActivationEvents.Startup,
|
|
133
|
+
activate: () => Effect.succeed(Capability.contributes(String, { string: 'hello' })),
|
|
134
|
+
}),
|
|
135
|
+
Plugin.make,
|
|
136
|
+
)();
|
|
137
|
+
|
|
138
|
+
const manager = PluginManager.make({
|
|
139
|
+
pluginLoader: pluginLoader([plugin]),
|
|
140
|
+
plugins: [plugin],
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
manager.capabilities.contribute({
|
|
144
|
+
interface: Capabilities.PluginManager,
|
|
145
|
+
implementation: manager,
|
|
146
|
+
module: 'org.dxos.app-framework.plugin-manager',
|
|
147
|
+
});
|
|
148
|
+
yield* manager.activate(ActivationEvents.Startup);
|
|
149
|
+
|
|
150
|
+
yield* manager.shutdown();
|
|
151
|
+
assert.deepStrictEqual(manager.getActive(), []);
|
|
152
|
+
|
|
153
|
+
// Second shutdown should succeed without error.
|
|
154
|
+
const result = yield* manager.shutdown();
|
|
155
|
+
assert.isTrue(result);
|
|
156
|
+
assert.deepStrictEqual(manager.getActive(), []);
|
|
157
|
+
}),
|
|
158
|
+
);
|
|
159
|
+
});
|