@dxos/app-framework 0.8.4-main.c1de068 → 0.8.4-main.c85a9c8dae
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 +9 -0
- package/.storybook/preview.mts +8 -0
- package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
- package/dist/lib/browser/capability-2GL5JAGJ.mjs +37 -0
- package/dist/lib/browser/capability-2GL5JAGJ.mjs.map +7 -0
- package/dist/lib/browser/capability-7RLVE42K.mjs +34 -0
- package/dist/lib/browser/capability-7RLVE42K.mjs.map +7 -0
- package/dist/lib/browser/chunk-4CTRO67U.mjs +703 -0
- package/dist/lib/browser/chunk-4CTRO67U.mjs.map +7 -0
- package/dist/lib/browser/chunk-5RJNZV7K.mjs +44 -0
- package/dist/lib/browser/chunk-5RJNZV7K.mjs.map +7 -0
- package/dist/lib/browser/chunk-FHQTHCX7.mjs +8 -0
- package/dist/lib/browser/chunk-FHQTHCX7.mjs.map +7 -0
- package/dist/lib/browser/chunk-FNKT2QQ2.mjs +145 -0
- package/dist/lib/browser/chunk-FNKT2QQ2.mjs.map +7 -0
- package/dist/lib/browser/chunk-HE27PNNQ.mjs +824 -0
- package/dist/lib/browser/chunk-HE27PNNQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-NPUEVX42.mjs +34 -0
- package/dist/lib/browser/chunk-NPUEVX42.mjs.map +7 -0
- package/dist/lib/browser/chunk-PKQT6C53.mjs +47 -0
- package/dist/lib/browser/chunk-PKQT6C53.mjs.map +7 -0
- package/dist/lib/browser/chunk-REORGDJT.mjs +80 -0
- package/dist/lib/browser/chunk-REORGDJT.mjs.map +7 -0
- package/dist/lib/browser/chunk-YAFEA4GV.mjs +1 -0
- package/dist/lib/browser/chunk-YNFPIQGB.mjs +76 -0
- package/dist/lib/browser/chunk-YNFPIQGB.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZRWBPIZG.mjs +170 -0
- package/dist/lib/browser/chunk-ZRWBPIZG.mjs.map +7 -0
- 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 +20 -0
- package/dist/lib/browser/core/activation-event.mjs.map +7 -0
- package/dist/lib/browser/core/capability.mjs +28 -0
- package/dist/lib/browser/core/capability.mjs.map +7 -0
- package/dist/lib/browser/core/plugin-manager.mjs +15 -0
- package/dist/lib/browser/core/plugin-manager.mjs.map +7 -0
- package/dist/lib/browser/core/plugin.mjs +27 -0
- package/dist/lib/browser/core/plugin.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +87 -156
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/invoker-capability-BNLVNYHU.mjs +36 -0
- package/dist/lib/browser/invoker-capability-BNLVNYHU.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +89 -39
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/browser/ui/index.mjs +45 -0
- package/dist/lib/browser/ui/index.mjs.map +7 -0
- package/dist/lib/node-esm/capability-CHIMU6LX.mjs +38 -0
- package/dist/lib/node-esm/capability-CHIMU6LX.mjs.map +7 -0
- package/dist/lib/node-esm/capability-EVZK4REM.mjs +35 -0
- package/dist/lib/node-esm/capability-EVZK4REM.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2A4PRBIX.mjs +171 -0
- package/dist/lib/node-esm/chunk-2A4PRBIX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7CPNAEGV.mjs +704 -0
- package/dist/lib/node-esm/chunk-7CPNAEGV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7OWSHPYK.mjs +48 -0
- package/dist/lib/node-esm/chunk-7OWSHPYK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CJCQS2YL.mjs +146 -0
- package/dist/lib/node-esm/chunk-CJCQS2YL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DTCHT2X2.mjs +825 -0
- package/dist/lib/node-esm/chunk-DTCHT2X2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JAZVHID3.mjs +35 -0
- package/dist/lib/node-esm/chunk-JAZVHID3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SB5ODNPX.mjs +77 -0
- package/dist/lib/node-esm/chunk-SB5ODNPX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UEWJDI2L.mjs +10 -0
- package/dist/lib/node-esm/chunk-UEWJDI2L.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UFW652GS.mjs +81 -0
- package/dist/lib/node-esm/chunk-UFW652GS.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VUIUFIGT.mjs +45 -0
- package/dist/lib/node-esm/chunk-VUIUFIGT.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 +21 -0
- package/dist/lib/node-esm/core/activation-event.mjs.map +7 -0
- package/dist/lib/node-esm/core/capability.mjs +29 -0
- package/dist/lib/node-esm/core/capability.mjs.map +7 -0
- package/dist/lib/node-esm/core/plugin-manager.mjs +16 -0
- package/dist/lib/node-esm/core/plugin-manager.mjs.map +7 -0
- package/dist/lib/node-esm/core/plugin.mjs +28 -0
- package/dist/lib/node-esm/core/plugin.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +87 -156
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/invoker-capability-VF6SP44V.mjs +37 -0
- package/dist/lib/node-esm/invoker-capability-VF6SP44V.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +89 -39
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/lib/node-esm/ui/index.mjs +46 -0
- package/dist/lib/node-esm/ui/index.mjs.map +7 -0
- package/dist/types/src/cli/cli.d.ts +39 -0
- 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 +114 -123
- package/dist/types/src/common/capabilities.d.ts.map +1 -1
- package/dist/types/src/common/index.d.ts +4 -8
- package/dist/types/src/common/index.d.ts.map +1 -1
- package/dist/types/src/common/operations.d.ts +33 -0
- package/dist/types/src/common/operations.d.ts.map +1 -0
- package/dist/types/src/common/translations.d.ts +8 -8
- package/dist/types/src/common/translations.d.ts.map +1 -1
- package/dist/types/src/context.d.ts +5 -0
- package/dist/types/src/context.d.ts.map +1 -0
- package/dist/types/src/core/{events.d.ts → activation-event.d.ts} +6 -6
- package/dist/types/src/core/activation-event.d.ts.map +1 -0
- package/dist/types/src/core/capability-manager.d.ts +43 -0
- package/dist/types/src/core/capability-manager.d.ts.map +1 -0
- package/dist/types/src/core/capability-manager.test.d.ts +2 -0
- package/dist/types/src/core/capability-manager.test.d.ts.map +1 -0
- package/dist/types/src/core/capability.d.ts +150 -0
- package/dist/types/src/core/capability.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +5 -4
- package/dist/types/src/core/index.d.ts.map +1 -1
- package/dist/types/src/core/plugin-manager.d.ts +66 -0
- package/dist/types/src/core/plugin-manager.d.ts.map +1 -0
- package/dist/types/src/core/plugin-manager.test.d.ts +2 -0
- package/dist/types/src/core/plugin-manager.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin.d.ts +97 -32
- package/dist/types/src/core/plugin.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts +3 -0
- package/dist/types/src/plugin-operation/OperationPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/capability.d.ts +7 -0
- package/dist/types/src/plugin-operation/history/capability.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/errors.d.ts +5 -0
- package/dist/types/src/plugin-operation/history/errors.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts +18 -0
- package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts +2 -0
- package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/index.d.ts +6 -0
- package/dist/types/src/plugin-operation/history/index.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/types.d.ts +13 -0
- package/dist/types/src/plugin-operation/history/types.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +101 -0
- package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts +23 -0
- package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts +2 -0
- package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/index.d.ts +3 -0
- package/dist/types/src/plugin-operation/index.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/invoker-capability.d.ts +6 -0
- package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/meta.d.ts +3 -0
- package/dist/types/src/plugin-operation/meta.d.ts.map +1 -0
- package/dist/types/src/plugin-operation/testing.d.ts +109 -0
- package/dist/types/src/plugin-operation/testing.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts +3 -0
- package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/capability.d.ts +6 -0
- package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/index.d.ts +2 -0
- package/dist/types/src/plugin-runtime/index.d.ts.map +1 -0
- package/dist/types/src/plugin-runtime/meta.d.ts +3 -0
- package/dist/types/src/plugin-runtime/meta.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/service.d.ts +8 -0
- package/dist/types/src/testing/service.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +11 -10
- 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/src/ui/components/App/App.d.ts +8 -0
- package/dist/types/src/ui/components/App/App.d.ts.map +1 -0
- package/dist/types/src/ui/components/App/App.stories.d.ts +19 -0
- 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 +13 -0
- package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts +10 -0
- 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/ui/components/Surface/SurfaceComponent.stories.d.ts +14 -0
- package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -0
- package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts +11 -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/ui/components/Surface/types.d.ts +96 -0
- 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/{App.d.ts → ui/hooks/useApp.d.ts} +21 -14
- package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useCapabilities.d.ts +31 -0
- package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useLoading.d.ts +18 -0
- package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useOperationResolver.d.ts +19 -0
- package/dist/types/src/ui/hooks/useOperationResolver.d.ts.map +1 -0
- package/dist/types/src/ui/hooks/useSettingsState.d.ts +10 -0
- 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 +11 -3
- package/package.json +113 -44
- package/src/cli/cli.ts +107 -0
- package/src/{playground/layout → cli}/index.ts +1 -1
- package/src/common/activation-events.ts +44 -0
- package/src/common/capabilities.ts +174 -114
- package/src/common/index.ts +4 -8
- package/src/common/operations.ts +38 -0
- package/src/common/translations.ts +18 -10
- package/src/context.ts +9 -0
- package/src/core/{events.ts → activation-event.ts} +5 -5
- package/src/core/capability-manager.test.ts +151 -0
- package/src/core/capability-manager.ts +171 -0
- package/src/core/capability.ts +236 -0
- package/src/core/index.ts +5 -4
- package/src/core/plugin-manager.test.ts +845 -0
- package/src/core/plugin-manager.ts +715 -0
- package/src/core/plugin.ts +230 -36
- package/src/helpers.test.ts +1 -1
- package/src/index.ts +3 -4
- package/src/plugin-operation/OperationPlugin.ts +25 -0
- package/src/plugin-operation/history/capability.ts +37 -0
- package/src/plugin-operation/history/errors.ts +11 -0
- package/src/plugin-operation/history/history-tracker.test.ts +380 -0
- package/src/plugin-operation/history/history-tracker.ts +129 -0
- package/src/plugin-operation/history/index.ts +9 -0
- package/src/plugin-operation/history/types.ts +17 -0
- package/src/plugin-operation/history/undo-mapping.ts +135 -0
- package/src/plugin-operation/history/undo-registry.test.ts +73 -0
- package/src/plugin-operation/history/undo-registry.ts +54 -0
- package/src/plugin-operation/index.ts +6 -0
- package/src/plugin-operation/invoker-capability.ts +40 -0
- package/src/plugin-operation/meta.ts +11 -0
- package/src/plugin-operation/testing.ts +174 -0
- package/src/plugin-runtime/RuntimePlugin.ts +20 -0
- package/src/plugin-runtime/capability.ts +53 -0
- package/src/{playground/debug → plugin-runtime}/index.ts +1 -1
- package/src/plugin-runtime/meta.ts +11 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/service.ts +52 -0
- package/src/testing/withPluginManager.stories.tsx +15 -11
- package/src/testing/withPluginManager.tsx +47 -45
- package/src/ui/components/App/App.stories.tsx +92 -0
- package/src/ui/components/App/App.tsx +57 -0
- package/src/{playground/logger → ui/components/App}/index.ts +1 -1
- package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +183 -0
- package/src/{react → ui/components/PluginManager}/PluginManagerProvider.ts +3 -3
- package/src/ui/components/PluginManager/index.ts +5 -0
- package/src/ui/components/Surface/SurfaceComponent.stories.tsx +143 -0
- package/src/ui/components/Surface/SurfaceComponent.tsx +247 -0
- package/src/ui/components/Surface/SurfaceInfo.tsx +107 -0
- package/src/ui/components/Surface/context.ts +12 -0
- package/src/ui/components/Surface/index.ts +20 -0
- package/src/ui/components/Surface/types.ts +117 -0
- package/src/ui/components/index.ts +7 -0
- package/src/ui/hooks/index.ts +10 -0
- package/src/ui/hooks/useApp.tsx +213 -0
- package/src/ui/hooks/useCapabilities.ts +67 -0
- package/src/ui/hooks/useLoading.tsx +68 -0
- package/src/ui/hooks/useOperationResolver.ts +40 -0
- package/src/ui/hooks/useSettingsState.ts +26 -0
- package/src/ui/hooks/useSurface.ts +13 -0
- package/src/ui/index.ts +6 -0
- package/tsconfig.json +14 -30
- package/tsconfig.node.json +1 -3
- package/typedoc.json +2 -4
- package/vitest.config.ts +8 -6
- package/.swc/plugins/v7_linux_x86_64_13.0.0/f45bdff002284d9e8f9ef3f0be909de12da36c049cbcf261ac78fc00abb09a2d +0 -0
- package/.swc/plugins/v7_linux_x86_64_13.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429 +0 -0
- package/dist/lib/browser/app-graph-builder-LYF7EKNN.mjs +0 -137
- package/dist/lib/browser/app-graph-builder-LYF7EKNN.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMN65HSW.mjs +0 -1519
- package/dist/lib/browser/chunk-FMN65HSW.mjs.map +0 -7
- package/dist/lib/browser/chunk-FO2PH7M3.mjs +0 -415
- package/dist/lib/browser/chunk-FO2PH7M3.mjs.map +0 -7
- package/dist/lib/browser/chunk-ORWHM7CO.mjs +0 -32
- package/dist/lib/browser/chunk-ORWHM7CO.mjs.map +0 -7
- package/dist/lib/browser/intent-dispatcher-LSYQZSEB.mjs +0 -11
- package/dist/lib/browser/intent-resolver-ZTNOSO3A.mjs +0 -39
- package/dist/lib/browser/intent-resolver-ZTNOSO3A.mjs.map +0 -7
- package/dist/lib/browser/store-KML2R4IE.mjs +0 -30
- package/dist/lib/browser/store-KML2R4IE.mjs.map +0 -7
- package/dist/lib/browser/worker.mjs +0 -79
- package/dist/lib/node-esm/app-graph-builder-SAOWGJDK.mjs +0 -138
- package/dist/lib/node-esm/app-graph-builder-SAOWGJDK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-73HGSHKE.mjs +0 -416
- package/dist/lib/node-esm/chunk-73HGSHKE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UMZQERLE.mjs +0 -34
- package/dist/lib/node-esm/chunk-UMZQERLE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZEZ4FVEU.mjs +0 -1521
- package/dist/lib/node-esm/chunk-ZEZ4FVEU.mjs.map +0 -7
- package/dist/lib/node-esm/intent-dispatcher-6CYNGPSW.mjs +0 -12
- package/dist/lib/node-esm/intent-resolver-W7Z7WFFM.mjs +0 -40
- package/dist/lib/node-esm/intent-resolver-W7Z7WFFM.mjs.map +0 -7
- package/dist/lib/node-esm/store-QEXGXLWZ.mjs +0 -31
- package/dist/lib/node-esm/store-QEXGXLWZ.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/common/collaboration.d.ts +0 -19
- package/dist/types/src/common/collaboration.d.ts.map +0 -1
- package/dist/types/src/common/events.d.ts +0 -52
- package/dist/types/src/common/events.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/layout.d.ts +0 -281
- package/dist/types/src/common/layout.d.ts.map +0 -1
- package/dist/types/src/common/surface.d.ts +0 -65
- package/dist/types/src/common/surface.d.ts.map +0 -1
- package/dist/types/src/core/capabilities.d.ts +0 -114
- package/dist/types/src/core/capabilities.d.ts.map +0 -1
- package/dist/types/src/core/capabilities.test.d.ts +0 -2
- package/dist/types/src/core/capabilities.test.d.ts.map +0 -1
- package/dist/types/src/core/events.d.ts.map +0 -1
- package/dist/types/src/core/manager.d.ts +0 -122
- package/dist/types/src/core/manager.d.ts.map +0 -1
- package/dist/types/src/core/manager.test.d.ts +0 -2
- package/dist/types/src/core/manager.test.d.ts.map +0 -1
- package/dist/types/src/playground/debug/Debug.d.ts +0 -6
- 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 -2
- package/dist/types/src/playground/debug/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/generator/Main.d.ts +0 -6
- package/dist/types/src/playground/generator/Main.d.ts.map +0 -1
- package/dist/types/src/playground/generator/Toolbar.d.ts +0 -6
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +0 -1
- package/dist/types/src/playground/generator/generator.d.ts +0 -7
- 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 -2
- package/dist/types/src/playground/generator/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/layout/Layout.d.ts +0 -8
- 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 -2
- package/dist/types/src/playground/layout/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/logger/Toolbar.d.ts +0 -6
- 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 -2
- package/dist/types/src/playground/logger/plugin.d.ts.map +0 -1
- package/dist/types/src/playground/logger/schema.d.ts +0 -13
- package/dist/types/src/playground/logger/schema.d.ts.map +0 -1
- package/dist/types/src/playground/playground.stories.d.ts +0 -10
- package/dist/types/src/playground/playground.stories.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +0 -2
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/actions.d.ts +0 -38
- package/dist/types/src/plugin-intent/actions.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/errors.d.ts +0 -16
- package/dist/types/src/plugin-intent/errors.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/index.d.ts +0 -5
- package/dist/types/src/plugin-intent/index.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +0 -139
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +0 -2
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
- package/dist/types/src/plugin-intent/intent.d.ts +0 -63
- package/dist/types/src/plugin-intent/intent.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +0 -2
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/actions.d.ts +0 -27
- package/dist/types/src/plugin-settings/actions.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +0 -4
- 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/intent-resolver.d.ts +0 -4
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/store.d.ts +0 -5
- package/dist/types/src/plugin-settings/store.d.ts.map +0 -1
- package/dist/types/src/plugin-settings/translations.d.ts +0 -10
- package/dist/types/src/plugin-settings/translations.d.ts.map +0 -1
- package/dist/types/src/react/ErrorBoundary.d.ts +0 -31
- package/dist/types/src/react/ErrorBoundary.d.ts.map +0 -1
- package/dist/types/src/react/IntentContext.d.ts +0 -8
- package/dist/types/src/react/IntentContext.d.ts.map +0 -1
- package/dist/types/src/react/PluginManagerProvider.d.ts +0 -10
- package/dist/types/src/react/PluginManagerProvider.d.ts.map +0 -1
- package/dist/types/src/react/Surface.d.ts +0 -12
- package/dist/types/src/react/Surface.d.ts.map +0 -1
- package/dist/types/src/react/Surface.stories.d.ts +0 -16
- package/dist/types/src/react/Surface.stories.d.ts.map +0 -1
- package/dist/types/src/react/common.d.ts +0 -13
- package/dist/types/src/react/common.d.ts.map +0 -1
- package/dist/types/src/react/index.d.ts +0 -7
- package/dist/types/src/react/index.d.ts.map +0 -1
- package/dist/types/src/react/useCapabilities.d.ts +0 -13
- package/dist/types/src/react/useCapabilities.d.ts.map +0 -1
- package/dist/types/src/react/useIntentResolver.d.ts +0 -3
- package/dist/types/src/react/useIntentResolver.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/common/collaboration.ts +0 -21
- package/src/common/events.ts +0 -77
- package/src/common/file.ts +0 -22
- package/src/common/graph.ts +0 -30
- package/src/common/layout.ts +0 -278
- package/src/common/surface.ts +0 -86
- package/src/core/capabilities.test.ts +0 -136
- package/src/core/capabilities.ts +0 -254
- package/src/core/manager.test.ts +0 -515
- package/src/core/manager.ts +0 -519
- package/src/playground/debug/Debug.tsx +0 -39
- package/src/playground/debug/plugin.ts +0 -17
- package/src/playground/generator/Main.tsx +0 -71
- package/src/playground/generator/Toolbar.tsx +0 -46
- package/src/playground/generator/generator.ts +0 -48
- package/src/playground/generator/index.ts +0 -6
- package/src/playground/generator/plugin.ts +0 -23
- package/src/playground/layout/Layout.tsx +0 -33
- package/src/playground/layout/plugin.ts +0 -17
- package/src/playground/logger/Toolbar.tsx +0 -29
- package/src/playground/logger/plugin.ts +0 -36
- package/src/playground/logger/schema.ts +0 -12
- package/src/playground/playground.stories.tsx +0 -42
- package/src/plugin-intent/IntentPlugin.ts +0 -20
- package/src/plugin-intent/actions.ts +0 -33
- package/src/plugin-intent/errors.ts +0 -39
- package/src/plugin-intent/index.ts +0 -8
- package/src/plugin-intent/intent-dispatcher.test.ts +0 -279
- package/src/plugin-intent/intent-dispatcher.ts +0 -333
- package/src/plugin-intent/intent.ts +0 -154
- package/src/plugin-settings/SettingsPlugin.ts +0 -35
- package/src/plugin-settings/actions.ts +0 -29
- package/src/plugin-settings/app-graph-builder.ts +0 -157
- package/src/plugin-settings/index.ts +0 -6
- package/src/plugin-settings/intent-resolver.ts +0 -34
- package/src/plugin-settings/store.ts +0 -33
- package/src/plugin-settings/translations.ts +0 -19
- package/src/react/ErrorBoundary.tsx +0 -45
- package/src/react/IntentContext.tsx +0 -34
- package/src/react/Surface.stories.tsx +0 -96
- package/src/react/Surface.tsx +0 -77
- package/src/react/common.ts +0 -12
- package/src/react/index.ts +0 -10
- package/src/react/useCapabilities.ts +0 -30
- package/src/react/useIntentResolver.ts +0 -22
- package/src/worker.ts +0 -11
- /package/dist/lib/browser/{intent-dispatcher-LSYQZSEB.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{worker.mjs.map → chunk-YAFEA4GV.mjs.map} +0 -0
- /package/dist/lib/{node-esm/intent-dispatcher-6CYNGPSW.mjs.map → browser/common/activation-events.mjs.map} +0 -0
- /package/dist/lib/{node-esm/worker.mjs.map → browser/common/capabilities.mjs.map} +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, {
|
|
6
|
+
Fragment,
|
|
7
|
+
type NamedExoticComponent,
|
|
8
|
+
type RefAttributes,
|
|
9
|
+
Suspense,
|
|
10
|
+
forwardRef,
|
|
11
|
+
memo,
|
|
12
|
+
useEffect,
|
|
13
|
+
useMemo,
|
|
14
|
+
useRef,
|
|
15
|
+
} from 'react';
|
|
16
|
+
|
|
17
|
+
import { log } from '@dxos/log';
|
|
18
|
+
import { ErrorBoundary } from '@dxos/react-error-boundary';
|
|
19
|
+
import { useDefaultValue } from '@dxos/react-hooks';
|
|
20
|
+
import { byPosition } from '@dxos/util';
|
|
21
|
+
|
|
22
|
+
import { Capabilities } from '../../../common';
|
|
23
|
+
import { type CapabilityManager } from '../../../core';
|
|
24
|
+
import { useCapabilities } from '../../hooks';
|
|
25
|
+
|
|
26
|
+
import { SurfaceContext } from './context';
|
|
27
|
+
import { SurfaceInfo } from './SurfaceInfo';
|
|
28
|
+
import { type Definition, type Props, type WebComponentDefinition } from './types';
|
|
29
|
+
|
|
30
|
+
const DEFAULT_PLACEHOLDER = <Fragment />;
|
|
31
|
+
|
|
32
|
+
const DEBUG = import.meta.env.VITE_DEBUG;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Wrapper component for rendering Web Component surfaces.
|
|
36
|
+
* Handles creation, prop setting, and cleanup of Web Components.
|
|
37
|
+
*/
|
|
38
|
+
const WebComponentWrapper = memo(
|
|
39
|
+
forwardRef<HTMLElement, Props & { definition: WebComponentDefinition }>(
|
|
40
|
+
({ id, role, data, limit, definition, ...rest }, forwardedRef) => {
|
|
41
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
42
|
+
const elementRef = useRef<HTMLElement | null>(null);
|
|
43
|
+
const propsRef = useRef({ id, role, data, limit, ...rest });
|
|
44
|
+
|
|
45
|
+
// Update props ref on every render
|
|
46
|
+
propsRef.current = { id, role, data, limit, ...rest };
|
|
47
|
+
|
|
48
|
+
// Create element only once
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!containerRef.current || elementRef.current) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Create the Web Component
|
|
55
|
+
const element = document.createElement(definition.tagName);
|
|
56
|
+
elementRef.current = element;
|
|
57
|
+
|
|
58
|
+
// Set initial properties on the Web Component
|
|
59
|
+
Object.assign(element, propsRef.current);
|
|
60
|
+
|
|
61
|
+
// Append to container
|
|
62
|
+
containerRef.current.appendChild(element);
|
|
63
|
+
|
|
64
|
+
// Setup ref forwarding if provided
|
|
65
|
+
if (typeof forwardedRef === 'function') {
|
|
66
|
+
forwardedRef(element);
|
|
67
|
+
} else if (forwardedRef) {
|
|
68
|
+
forwardedRef.current = element;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Cleanup on unmount to prevent memory leaks
|
|
72
|
+
return () => {
|
|
73
|
+
if (elementRef.current && containerRef.current?.contains(elementRef.current)) {
|
|
74
|
+
containerRef.current.removeChild(elementRef.current);
|
|
75
|
+
}
|
|
76
|
+
if (typeof forwardedRef === 'function') {
|
|
77
|
+
forwardedRef(null);
|
|
78
|
+
} else if (forwardedRef) {
|
|
79
|
+
forwardedRef.current = null;
|
|
80
|
+
}
|
|
81
|
+
elementRef.current = null;
|
|
82
|
+
};
|
|
83
|
+
}, [definition.tagName, forwardedRef]);
|
|
84
|
+
|
|
85
|
+
// Update props on existing element without recreating it
|
|
86
|
+
// This runs on every render to ensure all props (including those in `rest`) are kept up to date
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const element = elementRef.current;
|
|
89
|
+
if (!element) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Update properties on the existing Web Component
|
|
94
|
+
Object.assign(element, propsRef.current);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return <div ref={containerRef} />;
|
|
98
|
+
},
|
|
99
|
+
),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
WebComponentWrapper.displayName = 'WebComponentWrapper';
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Wrapper component that provides context for a surface.
|
|
106
|
+
*/
|
|
107
|
+
// TODO(burdon): Allow DebugPlugin to provide different fallback using react-ui ErrorFallback.
|
|
108
|
+
const SurfaceContextProvider = memo(
|
|
109
|
+
forwardRef<HTMLElement, Props & { definition: Definition }>(
|
|
110
|
+
({ id, role, data, limit, fallback = ErrorFallback, definition, ...rest }, forwardedRef) => {
|
|
111
|
+
const contextValue = useMemo(() => ({ id, role, data }), [id, role, data]);
|
|
112
|
+
|
|
113
|
+
// Handle Web Component surfaces
|
|
114
|
+
if (definition.kind === 'web-component') {
|
|
115
|
+
return (
|
|
116
|
+
<ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
|
|
117
|
+
<SurfaceContext.Provider value={contextValue}>
|
|
118
|
+
<WebComponentWrapper
|
|
119
|
+
id={id}
|
|
120
|
+
role={role}
|
|
121
|
+
data={data}
|
|
122
|
+
limit={limit}
|
|
123
|
+
definition={definition}
|
|
124
|
+
ref={forwardedRef}
|
|
125
|
+
{...rest}
|
|
126
|
+
/>
|
|
127
|
+
</SurfaceContext.Provider>
|
|
128
|
+
</ErrorBoundary>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Handle React component surfaces
|
|
133
|
+
const Component = definition.component;
|
|
134
|
+
|
|
135
|
+
// TODO(burdon): Remove from production build?
|
|
136
|
+
const debug = DEBUG || '__DX_DEBUG__' in window;
|
|
137
|
+
if (debug) {
|
|
138
|
+
return (
|
|
139
|
+
<ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
|
|
140
|
+
<div role='none' className='contents' data-id={id} data-role={role}>
|
|
141
|
+
<SurfaceContext.Provider value={contextValue}>
|
|
142
|
+
<SurfaceInfo ref={forwardedRef}>
|
|
143
|
+
<Component id={id} role={role} data={data} limit={limit} {...rest} />
|
|
144
|
+
</SurfaceInfo>
|
|
145
|
+
</SurfaceContext.Provider>
|
|
146
|
+
</div>
|
|
147
|
+
</ErrorBoundary>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
|
|
153
|
+
<div role='none' className='contents' data-id={id} data-role={role}>
|
|
154
|
+
<SurfaceContext.Provider value={contextValue}>
|
|
155
|
+
<Component id={id} role={role} data={data} limit={limit} {...rest} ref={forwardedRef} />
|
|
156
|
+
</SurfaceContext.Provider>
|
|
157
|
+
</div>
|
|
158
|
+
</ErrorBoundary>
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
SurfaceContextProvider.displayName = 'SurfaceContextProvider';
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A surface is a named region of the screen that can be populated by plugins.
|
|
168
|
+
*/
|
|
169
|
+
// TODO(burdon): Remove `ref` since relying on this would be error prone.
|
|
170
|
+
export const SurfaceComponent: NamedExoticComponent<Props & RefAttributes<HTMLElement>> = memo(
|
|
171
|
+
forwardRef(({ id: _id, role, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {
|
|
172
|
+
const data = useDefaultValue(dataProp, () => ({}));
|
|
173
|
+
|
|
174
|
+
// TODO(wittjosiah): This will make all surfaces depend on a single signal.
|
|
175
|
+
// This isn't ideal because it means that any change to the data will cause all surfaces to re-render.
|
|
176
|
+
// This effectively means that plugin modules which contribute surfaces need to all be activated at startup.
|
|
177
|
+
// This should be fine for now because it's how it worked prior to capabilities api anyway.
|
|
178
|
+
// In the future, it would be nice to be able to bucket the surface contributions by role.
|
|
179
|
+
const surfaces = useSurfaces();
|
|
180
|
+
|
|
181
|
+
// NOTE: Memoizing the candidates makes the surface not re-render based on reactivity within data.
|
|
182
|
+
const definitions = findCandidates(surfaces, { role, data });
|
|
183
|
+
const candidates = limit ? definitions.slice(0, limit) : definitions;
|
|
184
|
+
if (DEBUG && candidates.length === 0) {
|
|
185
|
+
log.warn('no candidates for surface', { role, data });
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<Suspense fallback={placeholder}>
|
|
191
|
+
{candidates.map((definition) => (
|
|
192
|
+
<SurfaceContextProvider
|
|
193
|
+
key={definition.id}
|
|
194
|
+
id={definition.id}
|
|
195
|
+
role={role}
|
|
196
|
+
data={data}
|
|
197
|
+
limit={limit}
|
|
198
|
+
definition={definition}
|
|
199
|
+
ref={forwardedRef}
|
|
200
|
+
{...rest}
|
|
201
|
+
/>
|
|
202
|
+
))}
|
|
203
|
+
</Suspense>
|
|
204
|
+
);
|
|
205
|
+
}),
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
SurfaceComponent.displayName = 'Surface';
|
|
209
|
+
|
|
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'>) => {
|
|
221
|
+
return Object.values(surfaces)
|
|
222
|
+
.filter((definition) =>
|
|
223
|
+
Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,
|
|
224
|
+
)
|
|
225
|
+
.filter(({ filter }) => (filter ? filter(data ?? {}) : true))
|
|
226
|
+
.toSorted(byPosition);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
export const useSurfaces = () => {
|
|
233
|
+
const surfaces = useCapabilities(Capabilities.ReactSurface);
|
|
234
|
+
return useMemo(() => surfaces.flat(), [surfaces]);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @returns `true` if there is a contributed surface which matches the specified role & data, `false` otherwise.
|
|
239
|
+
*/
|
|
240
|
+
export const isSurfaceAvailable = (
|
|
241
|
+
capabilityManager: CapabilityManager.CapabilityManager,
|
|
242
|
+
{ role, data }: Pick<Props, 'role' | 'data'>,
|
|
243
|
+
) => {
|
|
244
|
+
const surfaces = capabilityManager.getAll(Capabilities.ReactSurface);
|
|
245
|
+
const candidates = findCandidates(surfaces.flat(), { role, data });
|
|
246
|
+
return candidates.length > 0;
|
|
247
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, {
|
|
6
|
+
type ReactElement,
|
|
7
|
+
type Ref,
|
|
8
|
+
cloneElement,
|
|
9
|
+
forwardRef,
|
|
10
|
+
useCallback,
|
|
11
|
+
useLayoutEffect,
|
|
12
|
+
useState,
|
|
13
|
+
} from 'react';
|
|
14
|
+
import { createPortal } from 'react-dom';
|
|
15
|
+
|
|
16
|
+
import { addEventListener, combine } from '@dxos/async';
|
|
17
|
+
import { useMergeRefs } from '@dxos/react-hooks';
|
|
18
|
+
|
|
19
|
+
import { useSurface } from '../../hooks';
|
|
20
|
+
|
|
21
|
+
export type SurfaceInfoProps = {
|
|
22
|
+
children: ReactElement<{ ref?: Ref<HTMLElement> }>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Debug wrapper for surfaces.
|
|
27
|
+
*/
|
|
28
|
+
export const SurfaceInfo = forwardRef<HTMLElement, SurfaceInfoProps>(({ children }, forwardedRef) => {
|
|
29
|
+
const [rect, setRect] = useState<DOMRect | null>(null);
|
|
30
|
+
const [expand, setExpand] = useState(false);
|
|
31
|
+
const info = useSurface();
|
|
32
|
+
|
|
33
|
+
const [root, setRoot] = useState<HTMLElement | null>(null);
|
|
34
|
+
const measureRef = useCallback((node: HTMLElement | null) => setRoot(node), []);
|
|
35
|
+
const mergedRef = useMergeRefs([measureRef, forwardedRef]);
|
|
36
|
+
const childWithRef = cloneElement(children, { ref: mergedRef });
|
|
37
|
+
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
if (!root) {
|
|
40
|
+
setRect(null);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const measure = () => {
|
|
45
|
+
setRect(root.getBoundingClientRect());
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const observer = new ResizeObserver(measure);
|
|
49
|
+
observer.observe(root);
|
|
50
|
+
measure();
|
|
51
|
+
|
|
52
|
+
return combine(
|
|
53
|
+
addEventListener(window, 'scroll', measure, true),
|
|
54
|
+
addEventListener(window, 'resize', measure),
|
|
55
|
+
() => {
|
|
56
|
+
observer.disconnect();
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
}, [root]);
|
|
60
|
+
|
|
61
|
+
const padding = 0;
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
{childWithRef}
|
|
65
|
+
{rect &&
|
|
66
|
+
createPortal(
|
|
67
|
+
<div
|
|
68
|
+
role='none'
|
|
69
|
+
className='z-[100] fixed flex flex-col-reverse scrollbar-none overflow-auto pointer-events-none'
|
|
70
|
+
style={{
|
|
71
|
+
top: rect.top + padding,
|
|
72
|
+
left: rect.left + padding,
|
|
73
|
+
width: rect.width - padding * 2,
|
|
74
|
+
height: rect.height - padding * 2,
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{expand ? (
|
|
78
|
+
<div
|
|
79
|
+
className='absolute inset-0 bg-deck-surface border border-green-500 cursor-pointer pointer-events-auto overflow-auto'
|
|
80
|
+
onPointerDown={(ev) => ev.stopPropagation()}
|
|
81
|
+
onClick={(ev) => {
|
|
82
|
+
ev.stopPropagation();
|
|
83
|
+
setExpand(false);
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<pre className='p-2 text-xs text-description font-mono'>{JSON.stringify({ info }, null, 2)}</pre>
|
|
87
|
+
</div>
|
|
88
|
+
) : (
|
|
89
|
+
<span
|
|
90
|
+
className='absolute right-1 bottom-0 flex items-center p-1 text-green-500 opacity-80 hover:opacity-100 text-xl cursor-pointer pointer-events-auto'
|
|
91
|
+
title={info.id}
|
|
92
|
+
onPointerDown={(ev) => ev.stopPropagation()}
|
|
93
|
+
onClick={(ev) => {
|
|
94
|
+
ev.stopPropagation();
|
|
95
|
+
setExpand(true);
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
ⓘ
|
|
99
|
+
</span>
|
|
100
|
+
)}
|
|
101
|
+
</div>,
|
|
102
|
+
// TODO(burdon): Create well-known element to gather all debug portals.
|
|
103
|
+
document.body,
|
|
104
|
+
)}
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
});
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type { FC, PropsWithChildren, ReactNode, RefCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import type { MakeOptional, Position } from '@dxos/util';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Props that are passed to the Surface component.
|
|
11
|
+
*/
|
|
12
|
+
export type Props<T extends Record<string, any> = Record<string, unknown>> = {
|
|
13
|
+
/**
|
|
14
|
+
* If specified, the Surface will be wrapped in an error boundary.
|
|
15
|
+
* The fallback component will be rendered if an error occurs.
|
|
16
|
+
*/
|
|
17
|
+
fallback?: FC<{ error: Error; data?: any }>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* If specified, the Surface will be wrapped in a suspense boundary.
|
|
21
|
+
* The placeholder component will be rendered while the surface component is loading.
|
|
22
|
+
*/
|
|
23
|
+
placeholder?: ReactNode;
|
|
24
|
+
} & MakeOptional<CoreProps<T>, 'id' | 'data'> &
|
|
25
|
+
/**
|
|
26
|
+
* Additional props to pass to the component.
|
|
27
|
+
* These props are not used by Surface itself but may be used by components which resolve the surface.
|
|
28
|
+
* Exclude known prop names to prevent overriding well-defined props.
|
|
29
|
+
*/
|
|
30
|
+
{
|
|
31
|
+
[K in keyof Record<string, any>]: K extends keyof CoreProps<T> | 'fallback' | 'placeholder' ? never : any;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.
|
|
36
|
+
*/
|
|
37
|
+
export type CoreProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{
|
|
38
|
+
/**
|
|
39
|
+
* ID for debugging.
|
|
40
|
+
*/
|
|
41
|
+
id: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Role defines how the data should be rendered.
|
|
45
|
+
*/
|
|
46
|
+
role: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The data to be rendered by the surface.
|
|
50
|
+
* NOTE: This must be a stable value.
|
|
51
|
+
*/
|
|
52
|
+
data: T;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* If more than one component is resolved, the limit determines how many are rendered.
|
|
56
|
+
*/
|
|
57
|
+
limit?: number | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
|
|
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> & {
|
|
62
|
+
ref?: RefCallback<HTMLElement>;
|
|
63
|
+
} & Record<string, any>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* React component used to render a surface once is has matched.
|
|
67
|
+
*/
|
|
68
|
+
export type ComponentFunction<T extends Record<string, any> = Record<string, any>> = (
|
|
69
|
+
props: ComponentProps<T>,
|
|
70
|
+
) => ReactNode;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Definition of when a React component surface should be rendered.
|
|
74
|
+
*/
|
|
75
|
+
export type ReactDefinition<T extends Record<string, any> = any> = Readonly<{
|
|
76
|
+
kind: 'react';
|
|
77
|
+
id: string;
|
|
78
|
+
role: string | string[];
|
|
79
|
+
position?: Position;
|
|
80
|
+
component: ComponentFunction<T>;
|
|
81
|
+
filter?: (data: Record<string, unknown>) => data is T;
|
|
82
|
+
}>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Definition of when a Web Component surface should be rendered.
|
|
86
|
+
*/
|
|
87
|
+
export type WebComponentDefinition<T extends Record<string, any> = any> = Readonly<{
|
|
88
|
+
kind: 'web-component';
|
|
89
|
+
id: string;
|
|
90
|
+
role: string | string[];
|
|
91
|
+
position?: Position;
|
|
92
|
+
/**
|
|
93
|
+
* The tag name of the Web Component to render.
|
|
94
|
+
* The Web Component will receive the same props as React surfaces via properties/attributes.
|
|
95
|
+
*/
|
|
96
|
+
tagName: string;
|
|
97
|
+
filter?: (data: Record<string, unknown>) => data is T;
|
|
98
|
+
}>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Definition of when a surface (React or Web Component) should be rendered.
|
|
102
|
+
*/
|
|
103
|
+
export type Definition<T extends Record<string, any> = any> = ReactDefinition<T> | WebComponentDefinition<T>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Creates a React surface definition.
|
|
107
|
+
*/
|
|
108
|
+
export const create = <T extends Record<string, any> = any>(
|
|
109
|
+
definition: Omit<ReactDefinition<T>, 'kind'>,
|
|
110
|
+
): ReactDefinition<T> => ({ ...definition, kind: 'react' });
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Creates a Web Component surface definition.
|
|
114
|
+
*/
|
|
115
|
+
export const createWeb = <T extends Record<string, any> = any>(
|
|
116
|
+
definition: Omit<WebComponentDefinition<T>, 'kind'>,
|
|
117
|
+
): WebComponentDefinition<T> => ({ ...definition, kind: 'web-component' });
|