@dxos/app-framework 0.7.5-main.9d26e3a → 0.7.5-main.e9bb01b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/app-graph-builder-F7VZ6LRN.mjs +137 -0
- package/dist/lib/browser/app-graph-builder-F7VZ6LRN.mjs.map +7 -0
- package/dist/lib/browser/chunk-ATRNTMSS.mjs +1399 -0
- package/dist/lib/browser/chunk-ATRNTMSS.mjs.map +7 -0
- package/dist/lib/browser/chunk-LDJ3T4V3.mjs +32 -0
- package/dist/lib/browser/chunk-LDJ3T4V3.mjs.map +7 -0
- package/dist/lib/browser/chunk-WS6SU6HI.mjs +285 -0
- package/dist/lib/browser/chunk-WS6SU6HI.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +119 -642
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-dispatcher-E6J7E5Y5.mjs +11 -0
- package/dist/lib/browser/intent-resolver-XLE4L3LS.mjs +38 -0
- package/dist/lib/browser/intent-resolver-XLE4L3LS.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/store-QU2IKFAI.mjs +19 -0
- package/dist/lib/browser/store-QU2IKFAI.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +74 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/browser/worker.mjs +77 -0
- package/dist/lib/node/app-graph-builder-JGBADFF7.cjs +146 -0
- package/dist/lib/node/app-graph-builder-JGBADFF7.cjs.map +7 -0
- package/dist/lib/node/{chunk-FCMHRU3M.cjs → chunk-QLVQ6PND.cjs} +23 -35
- package/dist/lib/node/chunk-QLVQ6PND.cjs.map +7 -0
- package/dist/lib/node/chunk-WKC6YMEQ.cjs +1433 -0
- package/dist/lib/node/chunk-WKC6YMEQ.cjs.map +7 -0
- package/dist/lib/node/chunk-WRWRZKZU.cjs +308 -0
- package/dist/lib/node/chunk-WRWRZKZU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +125 -665
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/{plugin-settings-W6UHMH5M.cjs → intent-dispatcher-CFBKDZQR.cjs} +10 -14
- package/dist/lib/node/intent-dispatcher-CFBKDZQR.cjs.map +7 -0
- package/dist/lib/node/intent-resolver-3TKCXP4S.cjs +45 -0
- package/dist/lib/node/intent-resolver-3TKCXP4S.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/store-4QMUUU2A.cjs +34 -0
- package/dist/lib/node/store-4QMUUU2A.cjs.map +7 -0
- package/dist/lib/node/testing/index.cjs +98 -0
- package/dist/lib/node/testing/index.cjs.map +7 -0
- package/dist/lib/node/worker.cjs +99 -0
- package/dist/lib/node/worker.cjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-2QEX57NX.mjs +138 -0
- package/dist/lib/node-esm/app-graph-builder-2QEX57NX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-44J2VZBB.mjs +1401 -0
- package/dist/lib/node-esm/chunk-44J2VZBB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CNJYZNSL.mjs +34 -0
- package/dist/lib/node-esm/chunk-CNJYZNSL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HTLXL32I.mjs +286 -0
- package/dist/lib/node-esm/chunk-HTLXL32I.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +119 -642
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-dispatcher-LDQGDZ62.mjs +12 -0
- package/dist/lib/node-esm/intent-resolver-7VJWN67U.mjs +39 -0
- package/dist/lib/node-esm/intent-resolver-7VJWN67U.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/store-VWDAYUQY.mjs +20 -0
- package/dist/lib/node-esm/store-VWDAYUQY.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +75 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/worker.mjs +78 -0
- package/dist/types/src/App.d.ts +22 -13
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/common/capabilities.d.ts +293 -0
- package/dist/types/src/common/capabilities.d.ts.map +1 -0
- package/dist/types/src/common/events.d.ts +48 -0
- package/dist/types/src/common/events.d.ts.map +1 -0
- package/dist/types/src/common/file.d.ts +14 -0
- package/dist/types/src/common/file.d.ts.map +1 -0
- package/dist/types/src/common/graph.d.ts +21 -0
- package/dist/types/src/common/graph.d.ts.map +1 -0
- package/dist/types/src/common/index.d.ts +8 -0
- package/dist/types/src/common/index.d.ts.map +1 -0
- package/dist/types/src/common/layout.d.ts +248 -0
- package/dist/types/src/common/layout.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-surface/SurfaceContext.d.ts → common/surface.d.ts} +12 -29
- package/dist/types/src/common/surface.d.ts.map +1 -0
- package/dist/types/src/common/translations.d.ts +11 -0
- package/dist/types/src/common/translations.d.ts.map +1 -0
- package/dist/types/src/core/capabilities.d.ts +94 -0
- package/dist/types/src/core/capabilities.d.ts.map +1 -0
- package/dist/types/src/core/capabilities.test.d.ts +2 -0
- package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
- package/dist/types/src/core/events.d.ts +58 -0
- package/dist/types/src/core/events.d.ts.map +1 -0
- package/dist/types/src/core/index.d.ts +5 -0
- package/dist/types/src/core/index.d.ts.map +1 -0
- package/dist/types/src/core/manager.d.ts +119 -0
- package/dist/types/src/core/manager.d.ts.map +1 -0
- package/dist/types/src/core/manager.test.d.ts +2 -0
- package/dist/types/src/core/manager.test.d.ts.map +1 -0
- package/dist/types/src/core/plugin.d.ts +97 -0
- package/dist/types/src/core/plugin.d.ts.map +1 -0
- package/dist/types/src/helpers.d.ts +10 -0
- package/dist/types/src/helpers.d.ts.map +1 -0
- package/dist/types/src/helpers.test.d.ts +2 -0
- package/dist/types/src/helpers.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/playground/debug/Debug.d.ts +6 -0
- package/dist/types/src/playground/debug/Debug.d.ts.map +1 -0
- package/dist/types/src/playground/debug/index.d.ts +2 -0
- package/dist/types/src/playground/debug/index.d.ts.map +1 -0
- package/dist/types/src/playground/debug/plugin.d.ts +2 -0
- package/dist/types/src/playground/debug/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/generator/Main.d.ts +6 -0
- package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts +6 -0
- package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
- package/dist/types/src/playground/generator/generator.d.ts +7 -0
- package/dist/types/src/playground/generator/generator.d.ts.map +1 -0
- package/dist/types/src/playground/generator/index.d.ts +3 -0
- package/dist/types/src/playground/generator/index.d.ts.map +1 -0
- package/dist/types/src/playground/generator/plugin.d.ts +2 -0
- package/dist/types/src/playground/generator/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/layout/Layout.d.ts +8 -0
- package/dist/types/src/playground/layout/Layout.d.ts.map +1 -0
- package/dist/types/src/playground/layout/index.d.ts +2 -0
- package/dist/types/src/playground/layout/index.d.ts.map +1 -0
- package/dist/types/src/playground/layout/plugin.d.ts +2 -0
- package/dist/types/src/playground/layout/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/logger/Toolbar.d.ts +6 -0
- package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -0
- package/dist/types/src/playground/logger/index.d.ts +2 -0
- package/dist/types/src/playground/logger/index.d.ts.map +1 -0
- package/dist/types/src/playground/logger/plugin.d.ts +2 -0
- package/dist/types/src/playground/logger/plugin.d.ts.map +1 -0
- package/dist/types/src/playground/logger/schema.d.ts +13 -0
- package/dist/types/src/playground/logger/schema.d.ts.map +1 -0
- package/dist/types/src/playground/playground.stories.d.ts +10 -0
- package/dist/types/src/playground/playground.stories.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts +2 -0
- package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/actions.d.ts +23 -0
- package/dist/types/src/plugin-intent/actions.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/errors.d.ts +16 -0
- package/dist/types/src/plugin-intent/errors.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/index.d.ts +5 -0
- package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +113 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -0
- package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent.d.ts +8 -28
- package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
- package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/actions.d.ts +27 -0
- package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts +197 -0
- package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/index.d.ts +3 -0
- package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/intent-resolver.d.ts +4 -0
- package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/store.d.ts +5 -0
- package/dist/types/src/plugin-settings/store.d.ts.map +1 -0
- package/dist/types/src/plugin-settings/translations.d.ts +11 -0
- package/dist/types/src/plugin-settings/translations.d.ts.map +1 -0
- package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
- package/dist/types/src/{plugins/plugin-intent → react}/IntentContext.d.ts +2 -2
- package/dist/types/src/react/IntentContext.d.ts.map +1 -0
- package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
- package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
- package/dist/types/src/react/Surface.d.ts +12 -0
- package/dist/types/src/react/Surface.d.ts.map +1 -0
- package/dist/types/src/react/Surface.stories.d.ts +16 -0
- package/dist/types/src/react/Surface.stories.d.ts.map +1 -0
- package/dist/types/src/react/common.d.ts +12 -0
- package/dist/types/src/react/common.d.ts.map +1 -0
- package/dist/types/src/react/index.d.ts +7 -0
- package/dist/types/src/react/index.d.ts.map +1 -0
- package/dist/types/src/react/useCapabilities.d.ts +13 -0
- package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
- package/dist/types/src/react/useIntentResolver.d.ts +3 -0
- package/dist/types/src/react/useIntentResolver.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.d.ts +10 -0
- package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
- package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
- package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
- package/dist/types/src/worker.d.ts +4 -0
- package/dist/types/src/worker.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -18
- package/project.json +4 -3
- package/src/App.tsx +139 -34
- package/src/common/capabilities.ts +91 -0
- package/src/common/events.ts +72 -0
- package/src/common/file.ts +22 -0
- package/src/common/graph.ts +30 -0
- package/src/{plugins/common → common}/index.ts +3 -2
- package/src/common/layout.ts +225 -0
- package/src/{plugins/plugin-surface/SurfaceContext.ts → common/surface.ts} +6 -37
- package/src/common/translations.ts +17 -0
- package/src/core/capabilities.test.ts +116 -0
- package/src/core/capabilities.ts +222 -0
- package/src/core/events.ts +58 -0
- package/src/core/index.ts +8 -0
- package/src/core/manager.test.ts +516 -0
- package/src/core/manager.ts +511 -0
- package/src/core/plugin.ts +131 -0
- package/src/helpers.test.ts +97 -0
- package/src/helpers.ts +45 -0
- package/src/index.ts +6 -3
- package/src/playground/debug/Debug.tsx +39 -0
- package/src/playground/debug/index.ts +5 -0
- package/src/playground/debug/plugin.ts +17 -0
- package/src/playground/generator/Main.tsx +71 -0
- package/src/playground/generator/Toolbar.tsx +46 -0
- package/src/playground/generator/generator.ts +48 -0
- package/src/playground/generator/index.ts +6 -0
- package/src/playground/generator/plugin.ts +23 -0
- package/src/playground/layout/Layout.tsx +33 -0
- package/src/playground/layout/index.ts +5 -0
- package/src/playground/layout/plugin.ts +17 -0
- package/src/playground/logger/Toolbar.tsx +29 -0
- package/src/playground/logger/index.ts +5 -0
- package/src/playground/logger/plugin.ts +36 -0
- package/src/playground/logger/schema.ts +12 -0
- package/src/playground/playground.stories.tsx +34 -0
- package/src/plugin-intent/IntentPlugin.tsx +20 -0
- package/src/plugin-intent/actions.ts +22 -0
- package/src/plugin-intent/errors.ts +39 -0
- package/src/plugin-intent/index.ts +8 -0
- package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.ts +83 -63
- package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.ts +114 -95
- package/src/{plugins/plugin-intent → plugin-intent}/intent.ts +10 -26
- package/src/plugin-settings/SettingsPlugin.ts +35 -0
- package/src/plugin-settings/actions.ts +27 -0
- package/src/plugin-settings/app-graph-builder.ts +122 -0
- package/src/plugin-settings/index.ts +6 -0
- package/src/plugin-settings/intent-resolver.ts +28 -0
- package/src/plugin-settings/store.ts +20 -0
- package/src/plugin-settings/translations.ts +17 -0
- package/src/{plugins/plugin-intent → react}/IntentContext.tsx +13 -5
- package/src/react/PluginManagerProvider.ts +22 -0
- package/src/react/Surface.stories.tsx +96 -0
- package/src/react/Surface.tsx +75 -0
- package/src/react/common.ts +12 -0
- package/src/react/index.ts +10 -0
- package/src/react/useCapabilities.ts +39 -0
- package/src/react/useIntentResolver.ts +22 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/withPluginManager.stories.tsx +47 -0
- package/src/testing/withPluginManager.tsx +75 -0
- package/src/worker.ts +11 -0
- package/tsconfig.json +16 -4
- package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
- package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
- package/dist/lib/browser/chunk-QG25ZU2N.mjs +0 -320
- package/dist/lib/browser/chunk-QG25ZU2N.mjs.map +0 -7
- package/dist/lib/browser/chunk-SPDTXTOV.mjs +0 -163
- package/dist/lib/browser/chunk-SPDTXTOV.mjs.map +0 -7
- package/dist/lib/browser/chunk-WBOXEHBE.mjs +0 -51
- package/dist/lib/browser/chunk-WBOXEHBE.mjs.map +0 -7
- package/dist/lib/browser/plugin-intent-T7Y3MJ5C.mjs +0 -32
- package/dist/lib/browser/plugin-settings-5U2L2NRU.mjs +0 -15
- package/dist/lib/browser/plugin-surface-OKPF3EQI.mjs +0 -24
- package/dist/lib/node/chunk-BW3RNEVI.cjs +0 -185
- package/dist/lib/node/chunk-BW3RNEVI.cjs.map +0 -7
- package/dist/lib/node/chunk-FCMHRU3M.cjs.map +0 -7
- package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
- package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
- package/dist/lib/node/chunk-VWHAALIN.cjs +0 -344
- package/dist/lib/node/chunk-VWHAALIN.cjs.map +0 -7
- package/dist/lib/node/plugin-intent-F3TQZIUR.cjs +0 -53
- package/dist/lib/node/plugin-intent-F3TQZIUR.cjs.map +0 -7
- package/dist/lib/node/plugin-settings-W6UHMH5M.cjs.map +0 -7
- package/dist/lib/node/plugin-surface-CCSIONYW.cjs +0 -45
- package/dist/lib/node/plugin-surface-CCSIONYW.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-3T5UIJY3.mjs +0 -53
- package/dist/lib/node-esm/chunk-3T5UIJY3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs +0 -164
- package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs +0 -321
- package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
- package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-intent-W2HQC6LC.mjs +0 -33
- package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs +0 -16
- package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs +0 -25
- package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs.map +0 -7
- package/dist/types/src/plugins/common/file.d.ts +0 -22
- package/dist/types/src/plugins/common/file.d.ts.map +0 -1
- package/dist/types/src/plugins/common/graph.d.ts +0 -51
- package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
- package/dist/types/src/plugins/common/index.d.ts +0 -7
- package/dist/types/src/plugins/common/index.d.ts.map +0 -1
- package/dist/types/src/plugins/common/layout.d.ts +0 -176
- package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
- package/dist/types/src/plugins/common/metadata.d.ts +0 -16
- package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
- package/dist/types/src/plugins/common/navigation.d.ts +0 -243
- package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
- package/dist/types/src/plugins/common/translations.d.ts +0 -22
- package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
- package/dist/types/src/plugins/helpers.d.ts +0 -41
- package/dist/types/src/plugins/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/index.d.ts +0 -7
- package/dist/types/src/plugins/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -16
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
- package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
- package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/index.d.ts +0 -6
- package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -104
- package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
- package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
- package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -7
- package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts +0 -107
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -6
- package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -16
- package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
- package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
- package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
- package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -26
- package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -7
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/SurfaceContext.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
- package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
- package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
- package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -17
- package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
- package/src/plugins/common/file.ts +0 -36
- package/src/plugins/common/graph.ts +0 -70
- package/src/plugins/common/layout.ts +0 -173
- package/src/plugins/common/metadata.ts +0 -29
- package/src/plugins/common/navigation.ts +0 -214
- package/src/plugins/common/translations.ts +0 -36
- package/src/plugins/helpers.ts +0 -92
- package/src/plugins/index.ts +0 -11
- package/src/plugins/plugin-host/HostPlugin.tsx +0 -88
- package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
- package/src/plugins/plugin-host/PluginContext.tsx +0 -79
- package/src/plugins/plugin-host/index.ts +0 -12
- package/src/plugins/plugin-host/plugin.test.ts +0 -158
- package/src/plugins/plugin-host/plugin.ts +0 -133
- package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -75
- package/src/plugins/plugin-intent/index.ts +0 -13
- package/src/plugins/plugin-intent/meta.ts +0 -11
- package/src/plugins/plugin-intent/provides.ts +0 -26
- package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
- package/src/plugins/plugin-settings/index.ts +0 -9
- package/src/plugins/plugin-settings/meta.ts +0 -9
- package/src/plugins/plugin-settings/provides.ts +0 -34
- package/src/plugins/plugin-surface/Surface.tsx +0 -62
- package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -45
- package/src/plugins/plugin-surface/helpers.ts +0 -22
- package/src/plugins/plugin-surface/index.ts +0 -14
- package/src/plugins/plugin-surface/meta.ts +0 -9
- package/src/plugins/plugin-surface/provides.ts +0 -27
- /package/dist/lib/browser/{plugin-intent-T7Y3MJ5C.mjs.map → intent-dispatcher-E6J7E5Y5.mjs.map} +0 -0
- /package/dist/lib/browser/{plugin-settings-5U2L2NRU.mjs.map → worker.mjs.map} +0 -0
- /package/dist/lib/{browser/plugin-surface-OKPF3EQI.mjs.map → node-esm/intent-dispatcher-LDQGDZ62.mjs.map} +0 -0
- /package/dist/lib/node-esm/{plugin-intent-W2HQC6LC.mjs.map → worker.mjs.map} +0 -0
- /package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.d.ts +0 -0
- /package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
- /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema as S } from '@effect/schema';
|
|
6
|
-
|
|
7
|
-
import { pick } from '@dxos/util';
|
|
8
|
-
|
|
9
|
-
import { type Plugin } from '../plugin-host';
|
|
10
|
-
|
|
11
|
-
// NOTE(thure): These are chosen from RFC 1738’s `safe` characters: http://www.faqs.org/rfcs/rfc1738.html
|
|
12
|
-
export const SLUG_LIST_SEPARATOR = '+';
|
|
13
|
-
export const SLUG_ENTRY_SEPARATOR = '_';
|
|
14
|
-
export const SLUG_KEY_VALUE_SEPARATOR = '-';
|
|
15
|
-
export const SLUG_PATH_SEPARATOR = '~';
|
|
16
|
-
export const SLUG_COLLECTION_INDICATOR = '';
|
|
17
|
-
|
|
18
|
-
const LayoutEntrySchema = S.mutable(S.Struct({ id: S.String, path: S.optional(S.String) }));
|
|
19
|
-
export type LayoutEntry = S.Schema.Type<typeof LayoutEntrySchema>;
|
|
20
|
-
|
|
21
|
-
// TODO(Zan): Consider renaming the 'main' part to 'deck' part now that we are throwing out the old layout plugin.
|
|
22
|
-
// TODO(Zan): Extend to all strings?
|
|
23
|
-
const LayoutPartSchema = S.Union(
|
|
24
|
-
S.Literal('sidebar'),
|
|
25
|
-
S.Literal('main'),
|
|
26
|
-
S.Literal('solo'),
|
|
27
|
-
S.Literal('complementary'),
|
|
28
|
-
S.Literal('fullScreen'),
|
|
29
|
-
);
|
|
30
|
-
export type LayoutPart = S.Schema.Type<typeof LayoutPartSchema>;
|
|
31
|
-
|
|
32
|
-
const LayoutPartsSchema = S.partial(
|
|
33
|
-
S.mutable(S.Record({ key: LayoutPartSchema, value: S.mutable(S.Array(LayoutEntrySchema)) })),
|
|
34
|
-
);
|
|
35
|
-
export type LayoutParts = S.Schema.Type<typeof LayoutPartsSchema>;
|
|
36
|
-
|
|
37
|
-
const LayoutCoordinateSchema = S.mutable(S.Struct({ part: LayoutPartSchema, entryId: S.String }));
|
|
38
|
-
export type LayoutCoordinate = S.Schema.Type<typeof LayoutCoordinateSchema>;
|
|
39
|
-
|
|
40
|
-
const PartAdjustmentSchema = S.Union(
|
|
41
|
-
S.Literal('increment-start'),
|
|
42
|
-
S.Literal('increment-end'),
|
|
43
|
-
S.Literal('pin-start'),
|
|
44
|
-
S.Literal('pin-end'),
|
|
45
|
-
S.Literal('close'),
|
|
46
|
-
S.Literal('solo'),
|
|
47
|
-
);
|
|
48
|
-
export type PartAdjustment = S.Schema.Type<typeof PartAdjustmentSchema>;
|
|
49
|
-
|
|
50
|
-
const LayoutAdjustmentSchema = S.mutable(
|
|
51
|
-
S.Struct({ layoutCoordinate: LayoutCoordinateSchema, type: PartAdjustmentSchema }),
|
|
52
|
-
);
|
|
53
|
-
export type LayoutAdjustment = S.Schema.Type<typeof LayoutAdjustmentSchema>;
|
|
54
|
-
|
|
55
|
-
/** @deprecated */
|
|
56
|
-
export const ActiveParts = S.Record({ key: S.String, value: S.Union(S.String, S.mutable(S.Array(S.String))) });
|
|
57
|
-
export type ActiveParts = S.Schema.Type<typeof ActiveParts>;
|
|
58
|
-
|
|
59
|
-
// TODO(burdon): Where should this go?
|
|
60
|
-
export type LayoutContainerProps<T> = T & { role?: string; coordinate?: LayoutCoordinate };
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Provides for a plugin that can manage the app navigation.
|
|
64
|
-
*/
|
|
65
|
-
const LocationProvidesSchema = S.mutable(
|
|
66
|
-
S.Struct({
|
|
67
|
-
location: S.Struct({
|
|
68
|
-
active: LayoutPartsSchema,
|
|
69
|
-
closed: S.Array(S.String),
|
|
70
|
-
}),
|
|
71
|
-
}),
|
|
72
|
-
);
|
|
73
|
-
export type LocationProvides = S.Schema.Type<typeof LocationProvidesSchema>;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Type guard for layout plugins.
|
|
77
|
-
*/
|
|
78
|
-
export const isLayoutParts = (value: unknown): value is LayoutParts => {
|
|
79
|
-
return S.is(LayoutPartsSchema)(value);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// Type guard for PartAdjustment.
|
|
83
|
-
export const isLayoutAdjustment = (value: unknown): value is LayoutAdjustment => {
|
|
84
|
-
return S.is(LayoutAdjustmentSchema)(value);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const parseNavigationPlugin = (plugin: Plugin): Plugin<LocationProvides> | undefined => {
|
|
88
|
-
const location = (plugin.provides as any)?.location;
|
|
89
|
-
if (!location) {
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (S.is(LocationProvidesSchema)({ location })) {
|
|
94
|
-
return plugin as Plugin<LocationProvides>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return undefined;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Utilities.
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
/** Extracts all unique IDs from the layout parts. */
|
|
105
|
-
export const openIds = (layout: LayoutParts, parts?: LayoutPart[]): string[] => {
|
|
106
|
-
return Object.values(parts ? pick(layout, parts) : layout)
|
|
107
|
-
.flatMap((part) => part?.map((entry) => entry.id) ?? [])
|
|
108
|
-
.filter((id): id is string => id !== undefined);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const firstIdInPart = (layout: LayoutParts | undefined, part: LayoutPart): string | undefined => {
|
|
112
|
-
if (!layout) {
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return layout[part]?.at(0)?.id;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const indexInPart = (
|
|
120
|
-
layout: LayoutParts | undefined,
|
|
121
|
-
layoutCoordinate: LayoutCoordinate | undefined,
|
|
122
|
-
): number | undefined => {
|
|
123
|
-
if (!layout || !layoutCoordinate) {
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const { part, entryId } = layoutCoordinate;
|
|
128
|
-
return layout[part]?.findIndex((entry) => entry.id === entryId);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const partLength = (layout: LayoutParts | undefined, part: LayoutPart | undefined): number => {
|
|
132
|
-
if (!layout || !part) {
|
|
133
|
-
return 0;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return layout[part]?.length ?? 0;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
//
|
|
140
|
-
// Intents
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
export const NAVIGATION_PLUGIN = 'dxos.org/plugin/navigation';
|
|
144
|
-
export const NAVIGATION_ACTION = `${NAVIGATION_PLUGIN}/action`;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Expected payload for navigation actions.
|
|
148
|
-
*/
|
|
149
|
-
// TODO(wittjosiah): These seem to be too deck-specific.
|
|
150
|
-
export namespace NavigationAction {
|
|
151
|
-
/**
|
|
152
|
-
* An additive overlay to apply to `location.active` (i.e. the result is a union of previous active and the argument)
|
|
153
|
-
*/
|
|
154
|
-
export class Open extends S.TaggedClass<Open>()(`${NAVIGATION_ACTION}/open`, {
|
|
155
|
-
input: S.Struct({
|
|
156
|
-
activeParts: ActiveParts,
|
|
157
|
-
noToggle: S.optional(S.Boolean),
|
|
158
|
-
}),
|
|
159
|
-
output: S.Struct({
|
|
160
|
-
open: S.Array(S.String),
|
|
161
|
-
}),
|
|
162
|
-
}) {}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Payload for adding an item to the active items.
|
|
166
|
-
*/
|
|
167
|
-
export class AddToActive extends S.TaggedClass<AddToActive>()(`${NAVIGATION_ACTION}/add-to-active`, {
|
|
168
|
-
input: S.Struct({
|
|
169
|
-
id: S.String,
|
|
170
|
-
part: LayoutPartSchema,
|
|
171
|
-
scrollIntoView: S.optional(S.Boolean),
|
|
172
|
-
pivotId: S.optional(S.String),
|
|
173
|
-
positioning: S.optional(S.Literal('start', 'end')),
|
|
174
|
-
}),
|
|
175
|
-
output: S.Void,
|
|
176
|
-
}) {}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* The active parts to directly set, to be used when working with URLs or restoring a specific state.
|
|
180
|
-
*/
|
|
181
|
-
export class Set extends S.TaggedClass<Set>()(`${NAVIGATION_ACTION}/set`, {
|
|
182
|
-
input: S.Struct({
|
|
183
|
-
activeParts: ActiveParts,
|
|
184
|
-
}),
|
|
185
|
-
output: S.Void,
|
|
186
|
-
}) {}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* A subtractive overlay to apply to `location.active` (i.e. the result is a subtraction from the previous active of the argument)
|
|
190
|
-
*/
|
|
191
|
-
export class Close extends S.TaggedClass<Close>()(`${NAVIGATION_ACTION}/close`, {
|
|
192
|
-
input: S.Struct({
|
|
193
|
-
activeParts: ActiveParts,
|
|
194
|
-
noToggle: S.optional(S.Boolean),
|
|
195
|
-
}),
|
|
196
|
-
output: S.Void,
|
|
197
|
-
}) {}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* An atomic transaction to apply to `location.active`, describing which element to (attempt to) move to which location.
|
|
201
|
-
*/
|
|
202
|
-
export class Adjust extends S.TaggedClass<Adjust>()(`${NAVIGATION_ACTION}/adjust`, {
|
|
203
|
-
input: LayoutAdjustmentSchema,
|
|
204
|
-
output: S.Void,
|
|
205
|
-
}) {}
|
|
206
|
-
|
|
207
|
-
// TODO(wittjosiah): This action seems unrelated to the others.
|
|
208
|
-
export class Expose extends S.TaggedClass<Expose>()(`${NAVIGATION_ACTION}/expose`, {
|
|
209
|
-
input: S.Struct({
|
|
210
|
-
id: S.String,
|
|
211
|
-
}),
|
|
212
|
-
output: S.Void,
|
|
213
|
-
}) {}
|
|
214
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
|
|
7
|
-
import { type Plugin } from '../plugin-host';
|
|
8
|
-
|
|
9
|
-
// TODO(burdon): Replace zed with effect.
|
|
10
|
-
export const ResourceKey = z.union([z.string(), z.record(z.any())]);
|
|
11
|
-
export type ResourceKey = z.infer<typeof ResourceKey>;
|
|
12
|
-
|
|
13
|
-
export const ResourceLanguage = z.record(ResourceKey);
|
|
14
|
-
export type ResourceLanguage = z.infer<typeof ResourceLanguage>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* A resource is a collection of translations for a language.
|
|
18
|
-
*/
|
|
19
|
-
export const Resource = z.record(ResourceLanguage);
|
|
20
|
-
export type Resource = z.infer<typeof Resource>;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Provides for a plugin that exposes translations.
|
|
24
|
-
*/
|
|
25
|
-
// TODO(wittjosiah): Rename to TranslationResourcesProvides.
|
|
26
|
-
export type TranslationsProvides = {
|
|
27
|
-
translations: Readonly<Resource[]>;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Type guard for translation plugins.
|
|
32
|
-
*/
|
|
33
|
-
export const parseTranslationsPlugin = (plugin: Plugin) => {
|
|
34
|
-
const { success } = z.array(Resource).safeParse((plugin.provides as any).translations);
|
|
35
|
-
return success ? (plugin as Plugin<TranslationsProvides>) : undefined;
|
|
36
|
-
};
|
package/src/plugins/helpers.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Context, type DisposeCallback } from '@dxos/context';
|
|
6
|
-
import { raise } from '@dxos/debug';
|
|
7
|
-
import { invariant } from '@dxos/invariant';
|
|
8
|
-
|
|
9
|
-
import { type Plugin, type PluginDefinition } from './plugin-host';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Resolvers allow different instances of plugins to provide a particular capability.
|
|
13
|
-
*/
|
|
14
|
-
export type PluginResolver<T> = (plugin: Plugin) => Plugin<T> | undefined;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Find a plugin by ID.
|
|
18
|
-
*/
|
|
19
|
-
export const findPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> | undefined => {
|
|
20
|
-
return plugins.find(
|
|
21
|
-
(plugin) => plugin.meta.id === id || (typeof plugin.meta.shortId === 'string' && plugin.meta.shortId === id),
|
|
22
|
-
) as Plugin<T>;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Find a plugin by ID, or raise an error if not found.
|
|
27
|
-
*/
|
|
28
|
-
export const getPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> => {
|
|
29
|
-
return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Filter a list of plugins to only those that match a predicate.
|
|
34
|
-
*/
|
|
35
|
-
export const filterPlugins = <T>(plugins: Plugin[], predicate: PluginResolver<T>): Plugin<T>[] =>
|
|
36
|
-
plugins.map((plugin) => predicate(plugin)).filter((plugin): plugin is Plugin<T> => !!plugin);
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Resolves a plugin by predicate.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* import { parseIntentPlugin, resolvePlugin } from '@dxos/app-framework';
|
|
43
|
-
* const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
|
|
44
|
-
*/
|
|
45
|
-
export const resolvePlugin = <T>(plugins: Plugin[], predicate: PluginResolver<T>): Plugin<T> | undefined =>
|
|
46
|
-
filterPlugins(plugins, predicate)[0];
|
|
47
|
-
|
|
48
|
-
class PluginContext {
|
|
49
|
-
// TODO(burdon): Use Resource (@dima)?
|
|
50
|
-
public readonly ctx = new Context();
|
|
51
|
-
|
|
52
|
-
private _plugins?: Plugin[];
|
|
53
|
-
|
|
54
|
-
init(plugins: Plugin[]) {
|
|
55
|
-
this._plugins = plugins;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
getPlugin<T>(id: string): Plugin<T> {
|
|
59
|
-
invariant(this._plugins);
|
|
60
|
-
return getPlugin(this._plugins, id);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
resolvePlugin<T>(resolver: PluginResolver<T>): Plugin<T>;
|
|
64
|
-
resolvePlugin<T>(resolver: PluginResolver<T>, required = false): Plugin<T> | undefined {
|
|
65
|
-
invariant(this._plugins, 'context not initialized');
|
|
66
|
-
const plugin = resolvePlugin(this._plugins, resolver);
|
|
67
|
-
if (required && !plugin) {
|
|
68
|
-
// TODO(burdon): Resolver should have a name.
|
|
69
|
-
throw new Error('Plugin not found.');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return plugin;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
onDispose(cb: DisposeCallback) {
|
|
76
|
-
this.ctx.onDispose(cb);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
dispose() {
|
|
80
|
-
void this.ctx.dispose();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Plugin helper with dependency injection and life-cycle support.
|
|
86
|
-
*/
|
|
87
|
-
export const definePlugin = <Provides>(
|
|
88
|
-
cb: (context: PluginContext) => PluginDefinition<Provides>,
|
|
89
|
-
): (() => PluginDefinition<Provides>) => {
|
|
90
|
-
const context = new PluginContext();
|
|
91
|
-
return () => cb(context);
|
|
92
|
-
};
|
package/src/plugins/index.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type ReactNode } from 'react';
|
|
6
|
-
|
|
7
|
-
import { LocalStorageStore } from '@dxos/local-storage';
|
|
8
|
-
|
|
9
|
-
import { PluginContainer } from './PluginContainer';
|
|
10
|
-
import { type PluginContext, PluginProvider } from './PluginContext';
|
|
11
|
-
import { type PluginDefinition, type PluginMeta } from './plugin';
|
|
12
|
-
import { ErrorBoundary } from '../plugin-surface';
|
|
13
|
-
|
|
14
|
-
export type HostPluginParams = {
|
|
15
|
-
plugins: Record<string, () => Promise<PluginDefinition>>;
|
|
16
|
-
// Ordered list of plugins.
|
|
17
|
-
meta: PluginMeta[];
|
|
18
|
-
core: string[];
|
|
19
|
-
defaults?: string[];
|
|
20
|
-
fallback?: ErrorBoundary['props']['fallback'];
|
|
21
|
-
placeholder?: ReactNode;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const HOST_PLUGIN = 'dxos.org/plugin/host';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Bootstraps an application by initializing plugins and rendering root components.
|
|
28
|
-
*/
|
|
29
|
-
export const HostPlugin = ({
|
|
30
|
-
plugins,
|
|
31
|
-
meta,
|
|
32
|
-
core,
|
|
33
|
-
defaults = [],
|
|
34
|
-
fallback = DefaultFallback,
|
|
35
|
-
placeholder = null,
|
|
36
|
-
}: HostPluginParams): PluginDefinition => {
|
|
37
|
-
const state = new LocalStorageStore<PluginContext>(HOST_PLUGIN, {
|
|
38
|
-
ready: false,
|
|
39
|
-
core,
|
|
40
|
-
enabled: [...defaults],
|
|
41
|
-
plugins: [],
|
|
42
|
-
available: meta.filter(({ id }) => !core.includes(id)),
|
|
43
|
-
// TODO(burdon): Functions should not be part of the settings type.
|
|
44
|
-
setPlugin: (id: string, enabled: boolean) => {
|
|
45
|
-
if (enabled) {
|
|
46
|
-
state.values.enabled.push(id);
|
|
47
|
-
} else {
|
|
48
|
-
const index = state.values.enabled.findIndex((enabled) => enabled === id);
|
|
49
|
-
index !== -1 && state.values.enabled.splice(index, 1);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Register and load values.
|
|
55
|
-
state.prop({ key: 'enabled', type: LocalStorageStore.json<string[]>() });
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
meta: {
|
|
59
|
-
id: HOST_PLUGIN,
|
|
60
|
-
name: 'Plugin host',
|
|
61
|
-
},
|
|
62
|
-
provides: {
|
|
63
|
-
context: ({ children }) => {
|
|
64
|
-
return <PluginProvider value={state.values}>{children}</PluginProvider>;
|
|
65
|
-
},
|
|
66
|
-
root: () => {
|
|
67
|
-
return (
|
|
68
|
-
<ErrorBoundary fallback={fallback}>
|
|
69
|
-
<PluginContainer plugins={plugins} core={core} state={state.values} placeholder={placeholder} />
|
|
70
|
-
</ErrorBoundary>
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Fallback does not use tailwind or theme.
|
|
79
|
-
*/
|
|
80
|
-
const DefaultFallback = ({ error }: { error: Error }) => {
|
|
81
|
-
return (
|
|
82
|
-
<div style={{ padding: '1rem' }}>
|
|
83
|
-
{/* TODO(wittjosiah): Link to docs for replacing default. */}
|
|
84
|
-
<h1 style={{ fontSize: '1.2rem', fontWeight: 700, margin: '0.5rem 0' }}>{error.message}</h1>
|
|
85
|
-
<pre>{error.stack}</pre>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type JSX, type FC, type PropsWithChildren, type ReactNode, useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { log } from '@dxos/log';
|
|
8
|
-
|
|
9
|
-
import { type HostPluginParams } from './HostPlugin';
|
|
10
|
-
import { type PluginContext } from './PluginContext';
|
|
11
|
-
import { type Plugin, type PluginDefinition, type PluginProvides } from './plugin';
|
|
12
|
-
|
|
13
|
-
export type PluginContainerProps = Pick<HostPluginParams, 'core'> & {
|
|
14
|
-
plugins: Record<string, () => Promise<PluginDefinition>>;
|
|
15
|
-
state: PluginContext;
|
|
16
|
-
placeholder: ReactNode;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Root component initializes plugins.
|
|
21
|
-
*/
|
|
22
|
-
export const PluginContainer = ({ plugins: definitions, core, state, placeholder }: PluginContainerProps) => {
|
|
23
|
-
const [error, setError] = useState<unknown>();
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
log('initializing plugins', { enabled: state.enabled });
|
|
27
|
-
const t = setTimeout(async () => {
|
|
28
|
-
try {
|
|
29
|
-
const enabledIds = [...core, ...state.enabled];
|
|
30
|
-
const enabled = await Promise.all(
|
|
31
|
-
enabledIds
|
|
32
|
-
.map((id) => definitions[id])
|
|
33
|
-
// If local storage indicates a plugin is enabled, but it is not available, ignore it.
|
|
34
|
-
.filter((definition): definition is () => Promise<PluginDefinition> => Boolean(definition))
|
|
35
|
-
.map((definition) => definition()),
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const plugins = await Promise.all(
|
|
39
|
-
enabled.map(async (definition) => {
|
|
40
|
-
const plugin = await initializePlugin(definition).catch((err) => {
|
|
41
|
-
log.error('Failed to initialize plugin:', { id: definition.meta.id, err });
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
log('initialized', { plugin: definition.meta.id });
|
|
45
|
-
return plugin;
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const initialized = plugins.filter((plugin): plugin is Plugin => Boolean(plugin));
|
|
50
|
-
log('plugins initialized', { plugins: initialized });
|
|
51
|
-
|
|
52
|
-
await Promise.all(enabled.map((plugin) => plugin.ready?.({ plugins: initialized })));
|
|
53
|
-
log('plugins ready', { plugins: initialized });
|
|
54
|
-
|
|
55
|
-
state.plugins = initialized;
|
|
56
|
-
state.ready = true;
|
|
57
|
-
} catch (err) {
|
|
58
|
-
setError(err);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return () => {
|
|
63
|
-
clearTimeout(t);
|
|
64
|
-
state.ready = false;
|
|
65
|
-
// TODO(wittjosiah): Does this ever need to be called prior to having dynamic plugins?
|
|
66
|
-
// void Promise.all(enabled.map((definition) => definition.unload?.()));
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
if (error) {
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!state.ready) {
|
|
75
|
-
return <>{placeholder}</>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const ComposedContext = composeContext(state.plugins);
|
|
79
|
-
|
|
80
|
-
return <ComposedContext>{rootComponents(state.plugins)}</ComposedContext>;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Resolve a `PluginDefinition` into a fully initialized `Plugin`.
|
|
85
|
-
*/
|
|
86
|
-
const initializePlugin = async <T, U>(pluginDefinition: PluginDefinition<T, U>): Promise<Plugin<T & U>> => {
|
|
87
|
-
const provides = await pluginDefinition.initialize?.();
|
|
88
|
-
return {
|
|
89
|
-
...pluginDefinition,
|
|
90
|
-
provides: {
|
|
91
|
-
...pluginDefinition.provides,
|
|
92
|
-
...provides,
|
|
93
|
-
} as PluginProvides<T & U>,
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const rootComponents = (plugins: Plugin[]) => {
|
|
98
|
-
return plugins
|
|
99
|
-
.map((plugin) => {
|
|
100
|
-
const Component = plugin.provides.root;
|
|
101
|
-
if (Component) {
|
|
102
|
-
return <Component key={plugin.meta.id} />;
|
|
103
|
-
} else {
|
|
104
|
-
return null;
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
.filter((node): node is JSX.Element => Boolean(node));
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const composeContext = (plugins: Plugin[]) => {
|
|
111
|
-
return compose(plugins.map((p) => p.provides.context!).filter(Boolean));
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const compose = (contexts: FC<PropsWithChildren>[]) => {
|
|
115
|
-
return [...contexts].reduce((Acc, Next) => ({ children }) => (
|
|
116
|
-
<Acc>
|
|
117
|
-
<Next>{children}</Next>
|
|
118
|
-
</Acc>
|
|
119
|
-
));
|
|
120
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { createContext, useContext, useMemo } from 'react';
|
|
6
|
-
|
|
7
|
-
import { raise } from '@dxos/debug';
|
|
8
|
-
import { nonNullable } from '@dxos/util';
|
|
9
|
-
|
|
10
|
-
import { type Plugin, type PluginMeta } from './plugin';
|
|
11
|
-
import { findPlugin, resolvePlugin } from '../helpers';
|
|
12
|
-
|
|
13
|
-
export type PluginContext = {
|
|
14
|
-
/**
|
|
15
|
-
* All plugins are ready.
|
|
16
|
-
*/
|
|
17
|
-
ready: boolean;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Core plugins.
|
|
21
|
-
*/
|
|
22
|
-
core: string[];
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Ids of plugins which are enabled on this device.
|
|
26
|
-
*/
|
|
27
|
-
enabled: string[];
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Initialized and ready plugins.
|
|
31
|
-
*/
|
|
32
|
-
plugins: Plugin[];
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* All available plugins.
|
|
36
|
-
* NOTE: This is metadata rather than just ids because it includes plugins which have not been fully loaded yet.
|
|
37
|
-
*/
|
|
38
|
-
available: PluginMeta[];
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Mark plugin as enabled.
|
|
42
|
-
* Requires reload to take effect.
|
|
43
|
-
*/
|
|
44
|
-
// TODO(burdon): Functions should not be part of the settings type.
|
|
45
|
-
setPlugin: (id: string, enabled: boolean) => void;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const PluginContext = createContext<PluginContext | undefined>(undefined);
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Get all plugins.
|
|
52
|
-
*/
|
|
53
|
-
export const usePlugins = (): PluginContext => useContext(PluginContext) ?? raise(new Error('Missing PluginContext'));
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Get a plugin by ID.
|
|
57
|
-
*/
|
|
58
|
-
export const usePlugin = <T,>(id: string): Plugin<T> | undefined => {
|
|
59
|
-
const { plugins } = usePlugins();
|
|
60
|
-
return findPlugin<T>(plugins, id);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Resolve a plugin by predicate.
|
|
65
|
-
*/
|
|
66
|
-
export const useResolvePlugin = <T,>(predicate: (plugin: Plugin) => Plugin<T> | undefined): Plugin<T> | undefined => {
|
|
67
|
-
const { plugins } = usePlugins();
|
|
68
|
-
return resolvePlugin(plugins, predicate);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Resolve a collection of plugins by predicate.
|
|
73
|
-
*/
|
|
74
|
-
export const useResolvePlugins = <T,>(predicate: (plugin: Plugin) => Plugin<T> | undefined): Plugin<T>[] => {
|
|
75
|
-
const { plugins } = usePlugins();
|
|
76
|
-
return useMemo(() => plugins.map(predicate).filter(nonNullable), [plugins, predicate]);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export const PluginProvider = PluginContext.Provider;
|