@dxos/app-framework 0.9.0 → 0.9.1-main.c7dcc2e112

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.
Files changed (208) hide show
  1. package/dist/lib/browser/{capability-BOPAKKWG.mjs → capability-Z4MRP3CP.mjs} +9 -9
  2. package/dist/lib/browser/{chunk-CO3XLNUX.mjs → chunk-37PG7XJC.mjs} +18 -18
  3. package/dist/lib/browser/chunk-37PG7XJC.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-66IXTIVK.mjs → chunk-3NQLTQCP.mjs} +6 -7
  5. package/dist/lib/browser/chunk-3NQLTQCP.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-KZUDO43J.mjs → chunk-3UTDRCKX.mjs} +31 -23
  7. package/dist/lib/browser/chunk-3UTDRCKX.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-53HJHMS5.mjs +7 -0
  9. package/dist/lib/browser/chunk-53HJHMS5.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-IW44C7UL.mjs → chunk-CMINFVA5.mjs} +1 -1
  11. package/dist/lib/browser/chunk-CMINFVA5.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-Y66ELD4U.mjs → chunk-DFVSOBV2.mjs} +17 -7
  13. package/dist/lib/browser/chunk-DFVSOBV2.mjs.map +7 -0
  14. package/dist/lib/browser/{chunk-DC3WRPBV.mjs → chunk-S2ZBYQPI.mjs} +45 -12
  15. package/dist/lib/browser/chunk-S2ZBYQPI.mjs.map +7 -0
  16. package/dist/lib/browser/{chunk-HFLKXMT7.mjs → chunk-SWECIICH.mjs} +57 -41
  17. package/dist/lib/browser/chunk-SWECIICH.mjs.map +7 -0
  18. package/dist/lib/browser/{chunk-5GY3YOEL.mjs → chunk-VF37YTXJ.mjs} +5 -5
  19. package/dist/lib/browser/chunk-VF37YTXJ.mjs.map +7 -0
  20. package/dist/lib/browser/{chunk-XHS5KDNX.mjs → chunk-W4BHZING.mjs} +25 -25
  21. package/dist/lib/browser/chunk-W4BHZING.mjs.map +7 -0
  22. package/dist/lib/browser/{chunk-FO3IYSLV.mjs → chunk-YUVQIOTB.mjs} +29 -37
  23. package/dist/lib/browser/chunk-YUVQIOTB.mjs.map +7 -0
  24. package/dist/lib/browser/cli/index.mjs +9 -9
  25. package/dist/lib/browser/cli/index.mjs.map +2 -2
  26. package/dist/lib/browser/common/activation-events.mjs +7 -7
  27. package/dist/lib/browser/common/capabilities.mjs +7 -7
  28. package/dist/lib/browser/config/index.mjs +8 -0
  29. package/dist/lib/browser/config/index.mjs.map +7 -0
  30. package/dist/lib/browser/core/activation-event.mjs +1 -1
  31. package/dist/lib/browser/core/capability.mjs +1 -1
  32. package/dist/lib/browser/core/plugin-manager.mjs +4 -4
  33. package/dist/lib/browser/core/plugin.mjs +12 -2
  34. package/dist/lib/browser/core/url-loader.mjs +3 -3
  35. package/dist/lib/browser/index.mjs +14 -10
  36. package/dist/lib/browser/index.mjs.map +1 -1
  37. package/dist/lib/browser/meta.json +1 -1
  38. package/dist/lib/browser/{process-manager-capability-GXNUO7AR.mjs → process-manager-capability-RDROCCQD.mjs} +9 -9
  39. package/dist/lib/browser/testing/index.mjs +15 -15
  40. package/dist/lib/browser/testing/index.mjs.map +3 -3
  41. package/dist/lib/browser/testing/react.mjs +11 -11
  42. package/dist/lib/browser/testing/react.mjs.map +3 -3
  43. package/dist/lib/browser/ui/index.mjs +16 -10
  44. package/dist/lib/node-esm/{capability-KZWRTX7R.mjs → capability-34Z6NPVR.mjs} +9 -9
  45. package/dist/lib/node-esm/chunk-2UPUZXGU.mjs +9 -0
  46. package/dist/lib/node-esm/chunk-2UPUZXGU.mjs.map +7 -0
  47. package/dist/lib/node-esm/{chunk-FSVGKTF6.mjs → chunk-A4O42ZO3.mjs} +17 -7
  48. package/dist/lib/node-esm/chunk-A4O42ZO3.mjs.map +7 -0
  49. package/dist/lib/node-esm/{chunk-CTKEZHKF.mjs → chunk-AIDZMJ3U.mjs} +1 -1
  50. package/dist/lib/node-esm/chunk-AIDZMJ3U.mjs.map +7 -0
  51. package/dist/lib/node-esm/{chunk-XOCUANHO.mjs → chunk-BMW6P6QA.mjs} +6 -7
  52. package/dist/lib/node-esm/chunk-BMW6P6QA.mjs.map +7 -0
  53. package/dist/lib/node-esm/{chunk-A5CHGAZE.mjs → chunk-H7T7XXLS.mjs} +57 -41
  54. package/dist/lib/node-esm/chunk-H7T7XXLS.mjs.map +7 -0
  55. package/dist/lib/node-esm/{chunk-NULBHQYS.mjs → chunk-LUK3FCTH.mjs} +18 -18
  56. package/dist/lib/node-esm/chunk-LUK3FCTH.mjs.map +7 -0
  57. package/dist/lib/node-esm/{chunk-XGBUKRCK.mjs → chunk-TEQSMP2O.mjs} +31 -23
  58. package/dist/lib/node-esm/chunk-TEQSMP2O.mjs.map +7 -0
  59. package/dist/lib/node-esm/{chunk-KFZEB6BV.mjs → chunk-TLKYZKPW.mjs} +5 -5
  60. package/dist/lib/node-esm/chunk-TLKYZKPW.mjs.map +7 -0
  61. package/dist/lib/node-esm/{chunk-WK7OIQKI.mjs → chunk-VCPGX7WN.mjs} +29 -37
  62. package/dist/lib/node-esm/chunk-VCPGX7WN.mjs.map +7 -0
  63. package/dist/lib/node-esm/{chunk-XIGPWXCQ.mjs → chunk-WERVO5EK.mjs} +45 -12
  64. package/dist/lib/node-esm/chunk-WERVO5EK.mjs.map +7 -0
  65. package/dist/lib/node-esm/{chunk-SX5NVETP.mjs → chunk-ZRTG4TSS.mjs} +25 -25
  66. package/dist/lib/node-esm/chunk-ZRTG4TSS.mjs.map +7 -0
  67. package/dist/lib/node-esm/cli/index.mjs +9 -9
  68. package/dist/lib/node-esm/cli/index.mjs.map +2 -2
  69. package/dist/lib/node-esm/common/activation-events.mjs +7 -7
  70. package/dist/lib/node-esm/common/capabilities.mjs +7 -7
  71. package/dist/lib/node-esm/config/index.mjs +9 -0
  72. package/dist/lib/node-esm/config/index.mjs.map +7 -0
  73. package/dist/lib/node-esm/core/activation-event.mjs +1 -1
  74. package/dist/lib/node-esm/core/capability.mjs +1 -1
  75. package/dist/lib/node-esm/core/plugin-manager.mjs +4 -4
  76. package/dist/lib/node-esm/core/plugin.mjs +12 -2
  77. package/dist/lib/node-esm/core/url-loader.mjs +3 -3
  78. package/dist/lib/node-esm/index.mjs +14 -10
  79. package/dist/lib/node-esm/index.mjs.map +1 -1
  80. package/dist/lib/node-esm/meta.json +1 -1
  81. package/dist/lib/node-esm/{process-manager-capability-TX5TA6YN.mjs → process-manager-capability-6OCXSKUW.mjs} +9 -9
  82. package/dist/lib/node-esm/testing/index.mjs +15 -15
  83. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  84. package/dist/lib/node-esm/testing/react.mjs +11 -11
  85. package/dist/lib/node-esm/testing/react.mjs.map +3 -3
  86. package/dist/lib/node-esm/ui/index.mjs +16 -10
  87. package/dist/plugin/node-esm/index.mjs +406 -71
  88. package/dist/plugin/node-esm/index.mjs.map +4 -4
  89. package/dist/plugin/node-esm/meta.json +1 -1
  90. package/dist/types/src/cli/cli.d.ts +1 -1
  91. package/dist/types/src/common/activation-events.d.ts.map +1 -1
  92. package/dist/types/src/common/capabilities.d.ts.map +1 -1
  93. package/dist/types/src/config/index.d.ts +2 -0
  94. package/dist/types/src/config/index.d.ts.map +1 -0
  95. package/dist/types/src/core/activation-event.d.ts +9 -6
  96. package/dist/types/src/core/activation-event.d.ts.map +1 -1
  97. package/dist/types/src/core/capability.d.ts +6 -2
  98. package/dist/types/src/core/capability.d.ts.map +1 -1
  99. package/dist/types/src/core/edge-registry-plugin-provider.d.ts +6 -11
  100. package/dist/types/src/core/edge-registry-plugin-provider.d.ts.map +1 -1
  101. package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
  102. package/dist/types/src/core/plugin-manifest.d.ts +25 -7
  103. package/dist/types/src/core/plugin-manifest.d.ts.map +1 -1
  104. package/dist/types/src/core/plugin.d.ts +81 -91
  105. package/dist/types/src/core/plugin.d.ts.map +1 -1
  106. package/dist/types/src/core/registry.d.ts +17 -57
  107. package/dist/types/src/core/registry.d.ts.map +1 -1
  108. package/dist/types/src/core/url-loader.d.ts +2 -2
  109. package/dist/types/src/core/url-loader.d.ts.map +1 -1
  110. package/dist/types/src/index.d.ts +1 -0
  111. package/dist/types/src/index.d.ts.map +1 -1
  112. package/dist/types/src/plugin-process-manager/meta.d.ts +28 -2
  113. package/dist/types/src/plugin-process-manager/meta.d.ts.map +1 -1
  114. package/dist/types/src/testing/harness.d.ts +1 -1
  115. package/dist/types/src/testing/harness.d.ts.map +1 -1
  116. package/dist/types/src/testing/react.d.ts +6 -5
  117. package/dist/types/src/testing/react.d.ts.map +1 -1
  118. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
  119. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
  120. package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts +6 -0
  121. package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts.map +1 -1
  122. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +6 -10
  123. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -1
  124. package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
  125. package/dist/types/src/ui/components/Surface/context.d.ts +6 -2
  126. package/dist/types/src/ui/components/Surface/context.d.ts.map +1 -1
  127. package/dist/types/src/ui/components/Surface/index.d.ts +10 -3
  128. package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -1
  129. package/dist/types/src/ui/components/Surface/types.d.ts +50 -70
  130. package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -1
  131. package/dist/types/src/ui/hooks/useApp.d.ts +1 -1
  132. package/dist/types/src/ui/hooks/useCapabilities.d.ts +11 -1
  133. package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -1
  134. package/dist/types/src/vite-plugin/composer/index.d.ts +11 -4
  135. package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -1
  136. package/dist/types/src/vite-plugin/index.d.ts +1 -0
  137. package/dist/types/src/vite-plugin/index.d.ts.map +1 -1
  138. package/dist/types/src/vite-plugin/load.d.ts +16 -0
  139. package/dist/types/src/vite-plugin/load.d.ts.map +1 -0
  140. package/dist/types/src/vite-plugin/manifest.d.ts +16 -4
  141. package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -1
  142. package/dist/types/src/vite-plugin/packages.d.ts.map +1 -1
  143. package/dist/types/tsconfig.tsbuildinfo +1 -1
  144. package/docs/registry-spec.md +331 -0
  145. package/moon.yml +1 -0
  146. package/package.json +32 -27
  147. package/src/cli/cli.ts +2 -2
  148. package/src/common/activation-events.ts +3 -3
  149. package/src/common/capabilities.ts +16 -16
  150. package/src/config/index.ts +5 -0
  151. package/src/core/activation-event.ts +15 -8
  152. package/src/core/capability.ts +15 -4
  153. package/src/core/edge-registry-plugin-provider.ts +41 -42
  154. package/src/core/plugin-manager.test.ts +133 -137
  155. package/src/core/plugin-manager.ts +25 -19
  156. package/src/core/plugin-manifest.test.ts +5 -5
  157. package/src/core/plugin-manifest.ts +13 -10
  158. package/src/core/plugin.ts +58 -114
  159. package/src/core/registry.ts +20 -60
  160. package/src/core/url-loader.test.ts +2 -2
  161. package/src/core/url-loader.ts +23 -19
  162. package/src/index.ts +1 -0
  163. package/src/testing/harness.ts +5 -3
  164. package/src/testing/react.test.tsx +4 -2
  165. package/src/testing/react.tsx +9 -8
  166. package/src/testing/service.ts +2 -2
  167. package/src/testing/withPluginManager.stories.tsx +4 -2
  168. package/src/testing/withPluginManager.tsx +3 -1
  169. package/src/ui/components/PluginManager/PluginManagerProvider.ts +7 -0
  170. package/src/ui/components/Surface/SurfaceComponent.stories.tsx +11 -14
  171. package/src/ui/components/Surface/SurfaceComponent.tsx +84 -74
  172. package/src/ui/components/Surface/context.ts +6 -3
  173. package/src/ui/components/Surface/index.ts +12 -1
  174. package/src/ui/components/Surface/types.test.ts +39 -49
  175. package/src/ui/components/Surface/types.ts +95 -60
  176. package/src/ui/hooks/useApp.test.tsx +1 -1
  177. package/src/ui/hooks/useApp.tsx +2 -2
  178. package/src/ui/hooks/useCapabilities.ts +24 -2
  179. package/src/vite-plugin/composer/index.ts +134 -61
  180. package/src/vite-plugin/index.ts +1 -0
  181. package/src/vite-plugin/load.ts +57 -0
  182. package/src/vite-plugin/manifest.test.ts +3 -3
  183. package/src/vite-plugin/manifest.ts +21 -10
  184. package/src/vite-plugin/packages.ts +0 -1
  185. package/dist/lib/browser/chunk-5GY3YOEL.mjs.map +0 -7
  186. package/dist/lib/browser/chunk-66IXTIVK.mjs.map +0 -7
  187. package/dist/lib/browser/chunk-CO3XLNUX.mjs.map +0 -7
  188. package/dist/lib/browser/chunk-DC3WRPBV.mjs.map +0 -7
  189. package/dist/lib/browser/chunk-FO3IYSLV.mjs.map +0 -7
  190. package/dist/lib/browser/chunk-HFLKXMT7.mjs.map +0 -7
  191. package/dist/lib/browser/chunk-IW44C7UL.mjs.map +0 -7
  192. package/dist/lib/browser/chunk-KZUDO43J.mjs.map +0 -7
  193. package/dist/lib/browser/chunk-XHS5KDNX.mjs.map +0 -7
  194. package/dist/lib/browser/chunk-Y66ELD4U.mjs.map +0 -7
  195. package/dist/lib/node-esm/chunk-A5CHGAZE.mjs.map +0 -7
  196. package/dist/lib/node-esm/chunk-CTKEZHKF.mjs.map +0 -7
  197. package/dist/lib/node-esm/chunk-FSVGKTF6.mjs.map +0 -7
  198. package/dist/lib/node-esm/chunk-KFZEB6BV.mjs.map +0 -7
  199. package/dist/lib/node-esm/chunk-NULBHQYS.mjs.map +0 -7
  200. package/dist/lib/node-esm/chunk-SX5NVETP.mjs.map +0 -7
  201. package/dist/lib/node-esm/chunk-WK7OIQKI.mjs.map +0 -7
  202. package/dist/lib/node-esm/chunk-XGBUKRCK.mjs.map +0 -7
  203. package/dist/lib/node-esm/chunk-XIGPWXCQ.mjs.map +0 -7
  204. package/dist/lib/node-esm/chunk-XOCUANHO.mjs.map +0 -7
  205. /package/dist/lib/browser/{capability-BOPAKKWG.mjs.map → capability-Z4MRP3CP.mjs.map} +0 -0
  206. /package/dist/lib/browser/{process-manager-capability-GXNUO7AR.mjs.map → process-manager-capability-RDROCCQD.mjs.map} +0 -0
  207. /package/dist/lib/node-esm/{capability-KZWRTX7R.mjs.map → capability-34Z6NPVR.mjs.map} +0 -0
  208. /package/dist/lib/node-esm/{process-manager-capability-TX5TA6YN.mjs.map → process-manager-capability-6OCXSKUW.mjs.map} +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/ui/components/App/App.tsx", "../../../src/ui/hooks/useApp.tsx", "../../../src/ui/hooks/useCapabilities.ts", "../../../src/ui/hooks/useLoading.tsx", "../../../src/ui/hooks/useProcessManagerRuntime.ts", "../../../src/ui/hooks/useSettingsState.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, useEffect, useLayoutEffect } from 'react';\n\nimport { Capabilities } from '../../../common';\nimport { topologicalSort } from '../../../helpers';\nimport { LoadingState, type StartupProgress, type UseAppOptions, useCapabilities, useLoading } from '../../hooks';\n\ndeclare global {\n interface Window {\n /**\n * Driver injected by `@dxos/app-framework/vite-plugin`'s `bootLoaderPlugin`\n * (a Solid app inlined into `index.html`). Declared here — on a module that\n * is part of the `@dxos/app-framework/ui` export surface — so the React side\n * and host apps (e.g. composer-app) can drive the loader without each\n * re-declaring the type. The canonical definition lives in the plugin's\n * `loader-app/types.ts`; this mirror exists because that source compiles in a\n * separate (Solid) program that doesn't ship its globals to consumers.\n */\n __bootLoader?: {\n status: (payload: {\n event?: string;\n module?: string;\n humanized: string;\n /**\n * Optional `(index/total)` tick. When present, the loader replaces the\n * current line in place (\"Loading plugins (12/80)\") instead of appending\n * a new entry — keeps the visible log compact during long counted phases.\n */\n range?: { index: number; total: number };\n }) => void;\n progress: (fraction?: number) => void;\n ready: () => void;\n dismiss: () => void;\n };\n }\n}\n\nexport type AppProps = Pick<UseAppOptions, 'debounce'> & {\n ready: boolean;\n error: unknown;\n progress?: StartupProgress;\n};\n\nconst FIRST_INTERACTIVE_MARK = 'app-framework:first-interactive';\n\nexport const App = ({ ready, error, debounce, progress }: AppProps) => {\n const reactContexts = useCapabilities(Capabilities.ReactContext);\n const reactRoots = useCapabilities(Capabilities.ReactRoot);\n const stage = useLoading(ready, debounce);\n const placeholderDismissed = stage >= LoadingState.Done;\n\n // Relay the startup lifecycle into the boot loader injected by\n // `@dxos/app-framework/vite-plugin` (a Solid app inlined into `index.html`,\n // the only visible loading UI). Plugin activation fills the `[0.5, 1]` half\n // of the ring; the raw `event` / `module` ids ride along so the loader owns\n // how each transition is rendered and traced. No-op once the outro has\n // started (`FadeOut`), so the dismissal runs uncontended.\n useEffect(() => {\n if (stage >= LoadingState.FadeOut) {\n return;\n }\n const fraction = progress?.progress ?? 0;\n window.__bootLoader?.progress(0.5 + fraction * 0.5);\n if (progress?.humanizedName) {\n window.__bootLoader?.status({\n event: progress.event,\n module: progress.module,\n humanized: `Activating ${progress.humanizedName}`,\n });\n }\n }, [stage, progress?.progress, progress?.event, progress?.module, progress?.humanizedName]);\n\n // Hand off at fade-out: play the loader's graceful shrink-and-fade outro.\n // `useLayoutEffect` runs before the next paint so the outro begins in the\n // same frame the real shell starts rendering beneath it.\n useLayoutEffect(() => {\n if (stage >= LoadingState.FadeOut) {\n window.__bootLoader?.ready();\n }\n }, [stage]);\n\n // Emit a once-per-app `app-framework:first-interactive` mark the first time\n // the loader is dismissed and the real app shell renders. Closes the gap\n // between `Startup` activated and the first interactive paint.\n //\n // Also the framework-owned handoff-complete signal: `dismiss()` removes the\n // loader immediately on the fast-load path (where `useLoading` skips\n // `FadeOut`), and is a no-op once an outro is already in flight, so it never\n // cuts the animation short.\n useEffect(() => {\n if (!placeholderDismissed) {\n return;\n }\n if (performance.getEntriesByName(FIRST_INTERACTIVE_MARK).length === 0) {\n performance.mark(FIRST_INTERACTIVE_MARK);\n }\n window.__bootLoader?.dismiss();\n }, [placeholderDismissed]);\n\n // Used in tests to exercise the error boundary & reset dialog (see\n // composer-app's `basic.spec.ts`). Thrown into the surrounding `ErrorBoundary`.\n if (location.search === '?throw') {\n throw new Error('Test error');\n }\n\n if (error) {\n // This triggers the error boundary to provide UI feedback for the startup error.\n throw error;\n }\n\n // The boot loader owns the screen until handoff completes; render nothing\n // until then (any DOM here would sit invisibly behind the `z-index: 10`\n // loader anyway).\n // TODO(wittjosiah): Consider using Suspense instead.\n if (!placeholderDismissed) {\n return null;\n }\n\n const ComposedContext = composeContexts(reactContexts);\n return (\n <ComposedContext>\n {reactRoots.map(({ id, root: Component }) => (\n <Component key={id} />\n ))}\n </ComposedContext>\n );\n};\n\nconst composeContexts = (contexts: Capabilities.ReactContext[]) => {\n if (contexts.length === 0) {\n return ({ children }: PropsWithChildren) => <>{children}</>;\n }\n\n return topologicalSort(contexts)\n .map(({ context }) => context)\n .reduce((Acc, Next) => ({ children }) => (\n <Acc>\n <Next>{children}</Next>\n </Acc>\n ));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport * as Effect from 'effect/Effect';\nimport * as Fiber from 'effect/Fiber';\nimport * as PubSub from 'effect/PubSub';\nimport * as Queue from 'effect/Queue';\nimport React, { type FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { EffectEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { ErrorBoundary, ErrorFallback, type FallbackProps } from '@dxos/react-error-boundary';\nimport { useAsyncEffect, useDefaultValue } from '@dxos/react-hooks';\nimport { ContextProtocolProvider } from '@dxos/web-context-react';\n\nimport { ActivationEvents, Capabilities } from '../../common';\nimport { PluginManagerContext } from '../../context';\nimport { type ActivationEvent, type Plugin, PluginManager } from '../../core';\nimport { App, PluginManagerProvider } from '../components';\n\nconst ENABLED_KEY = 'org.dxos.app-framework.enabled';\n\nexport type StartupProgress = {\n /** Number of modules that have been activated. */\n activated: number;\n /** Total number of modules registered. */\n total: number;\n /** Fractional progress (0-1). */\n progress: number;\n /**\n * Raw activation event key (e.g. `org.dxos.app-framework.event.startup`).\n * Set on event-level transitions, *and* on module-level transitions where\n * it carries the parent activation event that first triggered the\n * module's load (plumbed through `_loadCapabilitiesForModules` →\n * `_loadModule`). Consumers can use this either as the primary id (when\n * {@link module} is absent) or as an extra \"context\" field alongside\n * {@link module}.\n */\n event?: string;\n /**\n * Raw module id (e.g. `org.dxos.plugin.observability.module.ReactSurface`)\n * when the in-flight activation is module-level. When present,\n * {@link event} may also be set, identifying the parent activation that\n * triggered this module's load.\n */\n module?: string;\n /**\n * Pre-humanized label for the currently surfaced transition (module\n * label if {@link module} is set, otherwise the event label), supplied\n * for consumers that want a sensible default. Hosts that prefer to\n * render their own label can read the raw {@link event}/{@link module}\n * fields and ignore this — the framework leaves the policy choice\n * (which transitions to surface, how to format them, whether to drop\n * sub-modules entirely) to the host's `Placeholder`.\n */\n humanizedName?: string;\n};\n\nexport type UseAppOptions = {\n pluginManager?: PluginManager.PluginManager;\n pluginLoader?: PluginManager.ManagerOptions['pluginLoader'];\n onPluginRemove?: PluginManager.ManagerOptions['onRemove'];\n pluginRegistryProvider?: PluginManager.ManagerOptions['pluginRegistryProvider'];\n plugins?: Plugin.Plugin[];\n defaults?: string[];\n /**\n * Additional activation events to fire before startup.\n * These are fired alongside SetupReactSurface before the Startup event.\n */\n setupEvents?: ActivationEvent.ActivationEvent[];\n cacheEnabled?: boolean;\n safeMode?: boolean;\n debounce?: number;\n timeout?: number;\n fallback?: FC<FallbackProps>;\n};\n\n/**\n * Expected usage is for this to be the entrypoint of the application.\n * Initializes plugins and renders the root components.\n *\n * @example\n * const plugins = [LayoutPlugin(), MyPlugin()];\n * const defaults = [MyPluginId];\n * const fallback = () => <div>Initializing Plugins...</div>;\n * const App = useApp({ plugins, defaults, fallback });\n * createRoot(document.getElementById('root')!).render(\n * <StrictMode>\n * <App />\n * </StrictMode>,\n * );\n *\n * @param params.pluginLoader A function which loads new plugins.\n * @param params.plugins All plugins available to the application. Plugins whose `meta.profile.tags` includes `'system'` are treated as core (force-enabled, not user-toggleable).\n * @param params.defaults Default plugins are enabled by default but can be disabled by the user.\n * @param params.cacheEnabled Whether to cache enabled plugins in localStorage.\n * @param params.safeMode Whether to enable safe mode, which disables optional plugins.\n * @param params.fallback Fallback component to render if an error occurs during startup.\n */\nexport const useApp = ({\n pluginManager,\n pluginLoader: pluginLoaderProp,\n onPluginRemove,\n pluginRegistryProvider,\n plugins: pluginsProp,\n defaults: defaultsProp,\n setupEvents: setupEventsProp,\n fallback = ErrorFallback,\n cacheEnabled = false,\n safeMode = false,\n debounce = 0,\n timeout = 30_000,\n}: UseAppOptions) => {\n const plugins = useDefaultValue(pluginsProp, () => []);\n const defaults = useDefaultValue(defaultsProp, () => []);\n const setupEvents = useDefaultValue(setupEventsProp, () => []);\n\n const pluginLoader = useMemo(\n () =>\n pluginLoaderProp ??\n ((id: string) =>\n Effect.sync(() => {\n const plugin = plugins.find((plugin) => plugin.meta.profile.key === id);\n invariant(plugin, `Plugin not found: ${id}`);\n return { plugin };\n })),\n [pluginLoaderProp, plugins],\n );\n\n const readyRef = useRef(false);\n const [ready, setReady] = useState(false);\n const errorRef = useRef<unknown>(null);\n const [error, setError] = useState<unknown>(null);\n const [startupProgress, setStartupProgress] = useState<StartupProgress>({\n activated: 0,\n total: 0,\n progress: 0,\n });\n // TODO(wittjosiah): Migrate to Atom.kvs for isomorphic storage.\n const cached: string[] = useMemo(() => JSON.parse(localStorage.getItem(ENABLED_KEY) ?? '[]'), []);\n const enabled = useMemo(\n () => (safeMode ? [] : cacheEnabled && cached.length > 0 ? cached : defaults),\n [safeMode, cacheEnabled, cached, defaults],\n );\n const isExternalManager = !!pluginManager;\n const manager = useMemo(() => {\n const mgr =\n pluginManager ??\n PluginManager.make({\n pluginLoader,\n plugins,\n enabled,\n onRemove: onPluginRemove,\n pluginRegistryProvider,\n });\n log('useApp: useMemo created/reused manager', { provided: !!pluginManager });\n return mgr;\n }, [pluginManager, pluginLoader, plugins, enabled, onPluginRemove, pluginRegistryProvider]);\n\n useEffect(() => {\n if (!cacheEnabled) {\n return;\n }\n return manager.registry.subscribe(manager.enabled, (value) => {\n localStorage.setItem(ENABLED_KEY, JSON.stringify(value));\n });\n }, [cacheEnabled, manager]);\n\n useEffect(() => {\n setupDevtools(manager);\n }, [manager]);\n\n useAsyncEffect(async () => {\n log('useApp: effect mount');\n\n manager.capabilities.contribute({\n interface: Capabilities.PluginManager,\n implementation: manager,\n module: 'org.dxos.app-framework.plugin-manager',\n });\n\n manager.capabilities.contribute({\n interface: Capabilities.AtomRegistry,\n implementation: manager.registry,\n module: 'org.dxos.app-framework.atom-registry',\n });\n\n const fiber = Effect.gen(function* () {\n const queue = yield* PubSub.subscribe(manager.activation);\n const listener = yield* Effect.forkDaemon(\n Queue.take(queue).pipe(\n Effect.tap(({ event, state, module, error: error$ }) =>\n Effect.sync(() => {\n // Event-level Startup activated (no `module` field) fires once,\n // after every module triggered by Startup has finished. Module\n // activations now also carry their parent event id (so the trace\n // can attribute a module to its triggering event), which means\n // each module activated under Startup publishes\n // `{ event: 'startup', state: 'activated', module: <id> }`. Without\n // the `!module` guard the listener would mark the app ready on\n // the *first* such module rather than waiting for the event-level\n // completion — leaving downstream capabilities (operation-invoker,\n // app-graph, …) un-registered when the boot loader dismisses.\n if (event === ActivationEvents.Startup.id && state === 'activated' && !module) {\n clearTimeout(timeoutId);\n setReady(true);\n readyRef.current = true;\n // Trigger startup profiler dump if available.\n (globalThis as any).composer?.profiler?.dump();\n // Notify any host observability layer that startup completed.\n // A `CustomEvent` keeps this generic — app-framework doesn't\n // import a provider, and consumers can capture the startup\n // summary without us picking one.\n if (typeof window !== 'undefined') {\n window.dispatchEvent(new CustomEvent('app-framework:startup-activated'));\n }\n return;\n }\n // `activating` is the start-of-load signal. Surface the raw\n // `module` (or `event`) plus a pre-humanized label so the\n // boot loader can decide how to render each transition — show\n // everything, suppress noisy sub-modules, group by plugin,\n // or apply its own formatting. We intentionally do NOT touch\n // these fields on `activated`: pairing the two would cause\n // back-to-back identical updates to the host's effect, which\n // the boot loader treats as a re-trigger because\n // `progress.progress` moved. Leaving the label alone on\n // completion keeps it accurate (\"now activating X\") until\n // the next module starts.\n if (module && state === 'activating' && !readyRef.current) {\n setStartupProgress((current) => ({\n ...current,\n // `event` here is the activation event that first\n // triggered this module load (plumbed through\n // `_loadCapabilitiesForModules` → `_loadModule`).\n // Falsy/empty falls back to undefined so consumers can\n // tell \"no parent context\" from \"parent context: <X>\".\n event: event || undefined,\n module,\n humanizedName: humanizeModuleId(module),\n }));\n }\n // Update the activation count when a module commits. The\n // ring's fraction comes from this; `event`/`module`/\n // `humanizedName` were set by the matching `activating`\n // message above and are left alone so the count can advance\n // without re-firing the host's status callback.\n if (module && state === 'activated' && !readyRef.current) {\n const active = manager.getActive();\n const total = manager.getModules().length;\n setStartupProgress((current) => ({\n ...current,\n activated: active.length,\n total,\n progress: total > 0 ? active.length / total : 0,\n }));\n }\n // Event-level `activating` (no `module`) — fired at the start\n // of `_activateModulesForEvent` and recursively for each\n // before/after event. Surfaces a label during the gap before\n // the first module-level message lands; subsequent module\n // updates immediately overwrite this with a more specific\n // label.\n if (event && !module && state === 'activating' && !readyRef.current) {\n setStartupProgress((current) => ({\n ...current,\n event,\n module: undefined,\n humanizedName: humanizeEventKey(event),\n }));\n }\n if (error$ && !readyRef.current) {\n setError(error$);\n errorRef.current = error$;\n }\n }),\n ),\n Effect.forever,\n ),\n );\n\n yield* Effect.all([\n ...setupEvents.map((event) => manager.activate(event)),\n manager.activate(ActivationEvents.SetupReactSurface),\n manager.activate(ActivationEvents.Startup),\n ]);\n\n return yield* Fiber.join(listener);\n }).pipe(Effect.scoped, Effect.runFork);\n\n // Set up a timeout for startup.\n const timeoutId = setTimeout(() => {\n if (!readyRef.current && !errorRef.current) {\n log.warn('startup timeout diagnostic', {\n eventsFired: manager.getEventsFired(),\n activeModules: manager.getActive(),\n pendingReset: manager.getPendingReset(),\n });\n void EffectEx.runAndForwardErrors(Fiber.interrupt(fiber));\n setError(new Error(`Startup timed out after ${timeout}ms`));\n }\n }, timeout);\n\n return () => {\n log('useApp: effect cleanup');\n clearTimeout(timeoutId);\n void EffectEx.runAndForwardErrors(Fiber.interrupt(fiber));\n if (!isExternalManager) {\n void EffectEx.runAndForwardErrors(manager.shutdown());\n }\n };\n }, [manager]);\n\n const progressRef = useRef(startupProgress);\n progressRef.current = startupProgress;\n\n return useCallback(\n () => (\n <ErrorBoundary name='app' FallbackComponent={fallback}>\n <PluginManagerProvider value={manager}>\n <ContextProtocolProvider value={manager} context={PluginManagerContext}>\n <RegistryContext.Provider value={manager.registry}>\n <App ready={ready} error={error} debounce={debounce} progress={progressRef.current} />\n </RegistryContext.Provider>\n </ContextProtocolProvider>\n </PluginManagerProvider>\n </ErrorBoundary>\n ),\n [fallback, manager, ready, error],\n );\n};\n\nconst setupDevtools = (manager: PluginManager.PluginManager) => {\n (globalThis as any).composer ??= {};\n (globalThis as any).composer.manager = manager;\n};\n\n/**\n * Extracts a human-readable label from a module ID.\n *\n * Module IDs follow `org.dxos.plugin.<plugin-slug>.module.<module-name>`,\n * where `<plugin-slug>` is kebab-case and `<module-name>` is either an\n * explicit string (often kebab-case, e.g. `'observability'`, `'namespace'`)\n * or a capability tag in PascalCase from `Capability.getModuleTag(...)`\n * (e.g. `'ReactSurface'`, `'AppGraphBuilder'`). The output is\n * `\"Title Case Plugin: kebab-module\"` so the visible status names both the\n * plugin and the aspect being activated, helping disambiguate the multiple\n * modules a plugin contributes.\n *\n * Examples:\n * - \"org.dxos.plugin.markdown.module.ReactSurface\" → \"Markdown: react-surface\"\n * - \"org.dxos.plugin.observability.module.AppGraphBuilder\" → \"Observability: app-graph-builder\"\n * - \"org.dxos.plugin.observability.module.observability\" → \"Observability\"\n * (the module name matches the plugin slug — collapsed to avoid\n * \"Observability: observability\" noise.)\n */\nconst humanizeModuleId = (moduleId: string): string => {\n const match = moduleId.match(/\\.plugin\\.([^.]+)\\.module\\.(.+)$/);\n if (!match) {\n // Fallback: use the last segment.\n const parts = moduleId.split('.');\n return parts[parts.length - 1];\n }\n const [, pluginSlug, moduleName] = match;\n const pluginLabel = pluginSlug\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n // Normalise the module name to kebab-case so PascalCase capability tags\n // (\"ReactSurface\") read consistently with explicit kebab IDs\n // (\"operation-handler\"). The two-step substitution handles consecutive\n // uppercase runs (`URLLoader` → `url-loader`) without splitting them\n // mid-acronym.\n const moduleLabel = moduleName\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')\n .toLowerCase();\n // Capability modules whose name matches the plugin slug (e.g. the\n // observability plugin's `observability` capability module) would render\n // as \"Observability: observability\" — drop the redundant suffix.\n if (moduleLabel === pluginSlug) {\n return pluginLabel;\n }\n return `${pluginLabel}: ${moduleLabel}`;\n};\n\n/**\n * Extracts a human-readable label from an activation event key.\n * E.g., \"org.dxos.app-framework.event.setup-react-surface\" → \"Setup React Surface\".\n */\nconst humanizeEventKey = (eventKey: string): string => {\n // Strip a leading specifier (composite key form: \"<id>:<specifier>\").\n const id = eventKey.split(':')[0];\n // Match the trailing segment after `.event.`.\n const match = id.match(/\\.event\\.(.+)$/);\n const slug = match ? match[1] : (id.split('.').pop() ?? id);\n return slug\n .split('-')\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom } from '@effect-atom/atom';\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport { useCallback } from 'react';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { Capabilities } from '../../common';\nimport { type Capability } from '../../core';\nimport { useOptionalPluginManager, usePluginManager } from '../components';\n\n/** Stable empty result for capability lookups made outside a plugin manager. */\nconst emptyCapabilities = Atom.make(() => [] as const);\n\n/**\n * Hook to request capabilities from the plugin context.\n * @returns An array of capabilities.\n */\nexport const useCapabilities = <T>(interfaceDef: Capability.InterfaceDef<T>) => {\n const manager = usePluginManager();\n return useAtomValue(manager.capabilities.atom(interfaceDef));\n};\n\n/**\n * Hook to request a capability from the plugin context.\n * @returns The capability.\n * @throws If no capability is found.\n */\n// TODO(burdon): Option not to throw?\nexport const useCapability = <T>(interfaceDef: Capability.InterfaceDef<T>) => {\n const capabilities = useCapabilities(interfaceDef);\n invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`);\n return capabilities[0];\n};\n\n/**\n * Hook to request capabilities without requiring a plugin manager.\n * @returns An array of capabilities, or an empty array when rendered outside a {@link PluginManagerProvider}.\n */\nexport const useOptionalCapabilities = <T>(interfaceDef: Capability.InterfaceDef<T>): readonly T[] => {\n const manager = useOptionalPluginManager();\n return useAtomValue(\n manager ? manager.capabilities.atom(interfaceDef) : (emptyCapabilities as Atom.Atom<readonly T[]>),\n );\n};\n\n/**\n * Hook to request a single capability without requiring a plugin manager.\n * @returns The first matching capability, or `undefined` when none is registered (or there is no plugin manager).\n */\nexport const useOptionalCapability = <T>(interfaceDef: Capability.InterfaceDef<T>): T | undefined =>\n useOptionalCapabilities(interfaceDef)[0];\n\n/**\n * Hook to get the current value of an atom capability.\n * Automatically subscribes to changes.\n * @example const settings = useAtomCapability(CommentCapabilities.Settings);\n */\nexport const useAtomCapability = <T>(atomCapability: Capability.InterfaceDef<Atom.Atom<T>>): T => {\n const atom = useCapability(atomCapability);\n return useAtomValue(atom);\n};\n\n/**\n * Hook to get value and updater for an atom capability.\n * Returns [currentValue, updateFn] similar to useState.\n * @example const [settings, updateSettings] = useAtomCapabilityState(CommentCapabilities.Settings);\n */\nexport const useAtomCapabilityState = <T>(\n atomCapability: Capability.InterfaceDef<Atom.Writable<T>>,\n): [T, (fn: (current: T) => T) => void] => {\n const registry = useCapability(Capabilities.AtomRegistry);\n const atom = useCapability(atomCapability);\n const value = useAtomValue(atom);\n const update = useCallback(\n (fn: (current: T) => T) => {\n registry.set(atom, fn(registry.get(atom)));\n },\n [registry, atom],\n );\n return [value, update];\n};\n\n/**\n * Hook to get the operation invoker capability.\n */\nexport const useOperationInvoker = (): Capabilities.OperationInvoker => useCapability(Capabilities.OperationInvoker);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useEffect, useRef, useState } from 'react';\n\nexport enum LoadingState {\n Loading = 0,\n FadeIn = 1,\n FadeOut = 2,\n Done = 3,\n}\n\n/**\n * To avoid \"flashing\" the placeholder, we wait a period of time before starting the loading animation.\n * If loading completes during this time the placehoder is not shown, otherwise is it displayed for a minimum period of time.\n *\n * States:\n * 0: Loading - Wait for a period of time before starting the loading animation.\n * 1: Fade-in - Display a loading animation.\n * 2: Fade-out - Fade out the loading animation.\n * 3: Done - Remove the placeholder.\n */\nexport const useLoading = (ready: boolean, debounce = 0) => {\n const [stage, setStage] = useState<LoadingState>(LoadingState.Loading);\n // Mirror `ready` into a ref so the interval's `setStage` callback can read\n // the latest value without depending on the effect re-running. The pure\n // closure-capture pattern (with `ready` in deps) sticks the FSM at\n // `FadeIn` whenever HMR doesn't propagate the dep change end-to-end —\n // a ref sidesteps that entirely and fires the read on every tick.\n const readyRef = useRef(ready);\n readyRef.current = ready;\n\n useEffect(() => {\n if (!debounce) {\n return;\n }\n\n const i = setInterval(() => {\n setStage((stage) => {\n const isReady = readyRef.current;\n switch (stage) {\n case LoadingState.Loading: {\n if (!isReady) {\n return LoadingState.FadeIn;\n }\n clearInterval(i);\n return LoadingState.Done;\n }\n\n case LoadingState.FadeIn: {\n if (isReady) {\n return LoadingState.FadeOut;\n }\n break;\n }\n\n case LoadingState.FadeOut: {\n clearInterval(i);\n return LoadingState.Done;\n }\n }\n\n return stage;\n });\n }, debounce);\n\n return () => clearInterval(i);\n }, [debounce]);\n\n if (!debounce) {\n return ready ? LoadingState.Done : LoadingState.Loading;\n }\n\n return stage;\n};\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\nimport { type DependencyList, use, useCallback, useMemo } from 'react';\n\nimport { Operation, ServiceResolver } from '@dxos/compute';\nimport { EffectEx } from '@dxos/effect';\nimport type { SpaceId } from '@dxos/keys';\n\nimport { Capabilities } from '../../common';\nimport { useCapability } from './useCapabilities';\n\n/**\n * Resolve the shared {@link Capabilities.ProcessManagerRuntime} from the plugin context.\n */\nexport const useProcessManagerRuntime = (): Capabilities.ProcessManagerRuntime =>\n useCapability(Capabilities.ProcessManagerRuntime);\n\n/**\n * Build a callback that runs an effect on the {@link Capabilities.ProcessManagerRuntime}\n * with space-scoped services resolved via {@link ServiceResolver.provide}.\n *\n * The `tags` tuple must list every service the effect requires (beyond the\n * fixed {@link Capabilities.ProcessManagerRuntimeServices}); these services are\n * resolved for the given `spaceId` through the runtime's service resolver.\n *\n * Nested `Operation.invoke` / `Operation.schedule` calls within the effect\n * inherit `spaceId` as a default {@link Operation.InvokeOptions} so that\n * spawned operation processes have a space context (and therefore can resolve\n * space-scoped services like `Database.Service`) without each call site having\n * to thread the id through manually.\n */\nexport const useSpaceCallback = <const Tags extends readonly Context.Tag<any, any>[], T>(\n spaceId: SpaceId | undefined,\n tags: Tags,\n fn: () => Effect.Effect<T, any, Context.Tag.Identifier<Tags[number]> | Capabilities.ProcessManagerRuntimeServices>,\n deps?: DependencyList,\n): (() => Promise<T>) => {\n const runtime = useProcessManagerRuntime();\n return useCallback(() => {\n if (spaceId === undefined) {\n throw new TypeError('Space not provided to useSpaceCallback');\n }\n const layer = Layer.merge(\n ServiceResolver.provide({ space: spaceId }, ...tags),\n Operation.withInvocationOptions({ spaceId }),\n );\n return runtime.runPromise(fn().pipe(Effect.provide(layer)) as Effect.Effect<T, any, any>);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [runtime, spaceId, ...(deps ?? [])]);\n};\n\n/**\n * Suspensefully resolve a single space-scoped service via the\n * {@link Capabilities.ProcessManagerRuntime}'s service resolver.\n */\nexport const useSpaceService = <T extends Context.Tag<any, any>>(\n tag: T,\n spaceId: SpaceId | undefined,\n): Context.Tag.Service<T> | undefined => {\n const runtime = useProcessManagerRuntime();\n const promise = useMemo(() => {\n if (spaceId === undefined) {\n return undefined;\n }\n const layer = ServiceResolver.provide({ space: spaceId }, tag);\n const effect = Effect.flatMap(tag, (service) => Effect.succeed(service)).pipe(Effect.provide(layer));\n return runtime.runPromiseExit(effect as Effect.Effect<Context.Tag.Service<T>, any, any>);\n }, [runtime, spaceId, tag]);\n if (!promise) {\n return undefined;\n }\n return EffectEx.unwrapExit(use(promise));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom, RegistryContext, useAtomValue } from '@effect-atom/atom-react';\nimport { useCallback, useContext } from 'react';\n\n/**\n * Hook to read and update a settings atom.\n * Returns the current value and an update function.\n */\nexport const useSettingsState = <T>(\n atom: Atom.Writable<T>,\n): { settings: T; updateSettings: (fn: (current: T) => T) => void } => {\n const registry = useContext(RegistryContext);\n const settings = useAtomValue(atom);\n\n const updateSettings = useCallback(\n (fn: (current: T) => T) => {\n registry.set(atom, fn(registry.get(atom)));\n },\n [registry, atom],\n );\n\n return { settings, updateSettings };\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAIA,OAAOA,UAAiCC,aAAAA,YAAWC,uBAAuB;;;ACA1E,SAASC,uBAAuB;AAChC,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,WAAW;AACvB,OAAOC,SAAkBC,aAAaC,WAAWC,SAASC,QAAQC,gBAAgB;AAElF,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,WAAW;AACpB,SAASC,eAAeC,qBAAyC;AACjE,SAASC,gBAAgBC,uBAAuB;AAChD,SAASC,+BAA+B;AAOxC,IAAA,eAAMC;;AA8FEC,IAAAA,SAAWC,CAAAA,EAAAA,eAAgBC,cAAsB,kBAAA,gBAAA,w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,WAAO,CAAC,EAAEe,SAAQ,MAA0B,gBAAAP,OAAA,cAAAA,OAAA,UAAA,MAAGO,QAAAA;EACjD;AAEA,SAAOC,gBAAgBF,QAAAA,EACpBL,IAAI,CAAC,EAAEQ,QAAO,MAAOA,OAAAA,EACrBC,OAAO,CAACC,KAAKC,SAAS,CAAC,EAAEL,SAAQ,MAChC,gBAAAP,OAAA,cAACW,KAAAA,MACC,gBAAAX,OAAA,cAACY,MAAAA,MAAML,QAAAA,CAAAA,CAAAA;AAGf;",
6
+ "names": ["React", "useEffect", "useLayoutEffect", "RegistryContext", "Effect", "Fiber", "PubSub", "Queue", "React", "useCallback", "useEffect", "useMemo", "useRef", "useState", "EffectEx", "invariant", "log", "ErrorBoundary", "ErrorFallback", "useAsyncEffect", "useDefaultValue", "ContextProtocolProvider", "ENABLED_KEY", "defaults", "useDefaultValue", "defaultsProp", "setupEvents", "setupEventsProp", "pluginLoader", "pluginLoaderProp", "plugin", "find", "meta", "invariant", "id", "plugins", "errorRef", "useRef", "error", "setError", "useState", "startupProgress", "setStartupProgress", "activated", "total", "progress", "safeMode", "cacheEnabled", "cached", "pluginManager", "enabled", "onRemove", "pluginRegistryProvider", "mgr", "onPluginRemove", "useEffect", "manager", "useAsyncEffect", "capabilities", "contribute", "interface", "Capabilities", "PluginManager", "implementation", "module", "registry", "fiber", "forkDaemon", "setReady", "readyRef", "current", "globalThis", "humanizedName", "humanizeModuleId", "length", "active", "event", "error$", "Effect", "forever", "activate", "ActivationEvents", "Startup", "join", "listener", "pipe", "timeoutId", "eventsFired", "getEventsFired", "activeModules", "pendingReset", "getPendingReset", "runAndForwardErrors", "interrupt", "Error", "timeout", "clearTimeout", "Fiber", "isExternalManager", "EffectEx", "shutdown", "progressRef", "name", "FallbackComponent", "fallback", "value", "ContextProtocolProvider", "PluginManagerContext", "App", "ready", "debounce", "composer", "match", "parts", "pluginSlug", "moduleName", "pluginLabel", "split", "map", "word", "Atom", "useAtomValue", "useCallback", "invariant", "__dxlog_file", "useAtomValue", "capabilities", "interfaceDef", "invariant", "length", "atom", "useCapability", "atomCapability", "value", "update", "fn", "registry", "set", "useCallback", "useEffect", "useRef", "useState", "LoadingState", "useLoading", "ready", "debounce", "stage", "setStage", "readyRef", "current", "i", "setInterval", "isReady", "clearInterval", "Effect", "Layer", "use", "useCallback", "useMemo", "Operation", "ServiceResolver", "EffectEx", "useProcessManagerRuntime", "useCapability", "Capabilities", "ProcessManagerRuntime", "useSpaceCallback", "spaceId", "tags", "fn", "deps", "runtime", "useCallback", "undefined", "TypeError", "layer", "merge", "ServiceResolver", "provide", "space", "Operation", "withInvocationOptions", "runPromise", "pipe", "useSpaceService", "tag", "promise", "useMemo", "effect", "flatMap", "service", "succeed", "runPromiseExit", "EffectEx", "unwrapExit", "use", "RegistryContext", "useAtomValue", "useCallback", "useContext", "useSettingsState", "atom", "registry", "settings", "updateSettings", "fn", "set", "get", "FIRST_INTERACTIVE_MARK", "App", "ready", "error", "debounce", "progress", "reactContexts", "useCapabilities", "Capabilities", "ReactContext", "reactRoots", "ReactRoot", "stage", "useLoading", "placeholderDismissed", "LoadingState", "Done", "useEffect", "FadeOut", "fraction", "window", "__bootLoader", "humanizedName", "status", "event", "module", "humanized", "useLayoutEffect", "performance", "getEntriesByName", "length", "mark", "dismiss", "location", "search", "Error", "ComposedContext", "composeContexts", "React", "map", "id", "root", "Component", "key", "contexts", "children", "topologicalSort", "context", "reduce", "Acc", "Next"]
7
+ }
@@ -81,4 +81,4 @@ export {
81
81
  makeModule,
82
82
  capability_exports
83
83
  };
84
- //# sourceMappingURL=chunk-CTKEZHKF.mjs.map
84
+ //# sourceMappingURL=chunk-AIDZMJ3U.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/core/capability.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom } from '@effect-atom/atom-react';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Layer from 'effect/Layer';\n\nimport type { DXN } from '@dxos/keys';\n\nimport type * as CapabilityManager from './capability-manager';\nimport type * as Plugin from './plugin';\n\n//\n// Capability Service Layer\n//\n\n/**\n * Effect Context.Tag for accessing CapabilityManager via the Effect layer system.\n * This allows capability modules to access the capability manager without having it passed as an argument.\n */\nexport class Service extends Context.Tag('@dxos/app-framework/CapabilityManager')<\n Service,\n CapabilityManager.CapabilityManager\n>() {}\n\n/**\n * Get a single capability from the capability manager.\n * @param interfaceDef The interface definition of the capability.\n * @returns The capability implementation.\n * @throws If no capability is found.\n */\n// TODO(wittjosiah): Add custom tagged errors (Data.TaggedError) for app-framework to enable\n// type-safe error handling with Effect. Consider CapabilityNotFoundError, ModuleActivationError, etc.\nexport const get = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T, Error, Service> =>\n Effect.flatMap(Service, (manager) =>\n Effect.try({\n try: () => manager.get(interfaceDef),\n catch: (error) => (error instanceof Error ? error : new Error(String(error))),\n }),\n );\n\n/**\n * Get all capabilities from the capability manager for a given interface.\n * @param interfaceDef The interface definition of the capability.\n * @returns An array of capability implementations.\n */\nexport const getAll = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T[], never, Service> =>\n Effect.map(Service, (manager) => manager.getAll(interfaceDef));\n\n/**\n * Wait for a capability to be available.\n * @param interfaceDef The interface definition of the capability.\n * @returns The capability implementation once available.\n */\nexport const waitFor = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.waitFor(interfaceDef));\n\n/**\n * Get the Atom reference to capabilities for reactive access.\n * @param interfaceDef The interface definition of the capability.\n * @returns An Atom containing the array of capability implementations.\n */\nexport const atom = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<Atom.Atom<T[]>, never, Service> =>\n Effect.map(Service, (manager) => manager.atom(interfaceDef));\n\n/**\n * Get capabilities grouped by the module that contributed them.\n * @param interfaceDef The interface definition of the capability.\n * @returns An Atom containing a record from module ID to capability implementations.\n */\nexport const atomByModule = <T>(\n interfaceDef: InterfaceDef<T>,\n): Effect.Effect<Atom.Atom<Record<string, T[]>>, never, Service> =>\n Effect.map(Service, (manager) => manager.atomByModule(interfaceDef));\n\n/**\n * Constructs a layer that will request its interface implementation from the capability manager.\n */\nexport const asLayer = <T, I>(interfaceDef: InterfaceDef<T>, tag: Context.Tag<I, T>): Layer.Layer<I, never, Service> =>\n Layer.effect(tag, get(interfaceDef).pipe(Effect.orDie));\n\nconst InterfaceDefTypeId: unique symbol = Symbol.for('InterfaceDefTypeId');\n\n/**\n * Symbol used to tag lazy capability functions with their module ID.\n */\nexport const ModuleTag: unique symbol = Symbol.for('@dxos/app-framework/ModuleTag');\n\n/**\n * The interface definition of a capability.\n */\nexport type InterfaceDef<T> = {\n [InterfaceDefTypeId]: T;\n identifier: string;\n};\n\nexport namespace InterfaceDef {\n export type Implementation<I extends InterfaceDef<any>> = I extends InterfaceDef<infer T> ? T : never;\n}\n\n/**\n * Helper to define the interface of a capability.\n * Static NSID strings are validated at compile time via {@link DXN.Name}.\n */\nexport const make: {\n <T, S extends string = string>(\n identifier: [DXN.Name<S>] extends [never] ? `Invalid NSID \"${S}\": final segment must be camelCase (no hyphens)` : S,\n ): InterfaceDef<T>;\n} = <T>(identifier: string): InterfaceDef<T> => {\n return { identifier } as InterfaceDef<T>;\n};\n\n/**\n * A unique string identifier with a Typescript type associated with it.\n * When a capability is contributed to the application an implementation of the interface is provided.\n */\nexport type Capability<T> = {\n /**\n * The interface definition of the capability.\n */\n readonly interface: InterfaceDef<T>;\n\n /**\n * The implementation of the capability.\n */\n readonly implementation: T;\n\n /**\n * Called when the capability is deactivated.\n */\n readonly deactivate?: () => Effect.Effect<void, Error>;\n};\n\nexport type Any = Capability<any>;\n\n/**\n * Union type representing all valid return types for a capability module.\n * Supports single capabilities, arrays, and tuples of different capability types.\n */\nexport type ModuleReturn = void | Any | Any[] | readonly Any[] | [Any, ...Any[]] | readonly [Any, ...Any[]];\n\n/**\n * Helper to define the implementation of a capability.\n */\n// TODO(dmaretskyi): Make the return type non-generic so capabilities are non-discernable.\nexport const contributes = <I extends InterfaceDef<any>>(\n interfaceDef: I,\n implementation: Capability<InterfaceDef.Implementation<I>>['implementation'],\n deactivate?: Capability<InterfaceDef.Implementation<I>>['deactivate'],\n): Capability<I> => {\n return {\n interface: interfaceDef,\n implementation,\n deactivate,\n } satisfies Capability<I>;\n};\n\ntype LoadCapability<Props, Capabilities extends ModuleReturn = ModuleReturn> = () => Promise<{\n default: (props: Props) => Effect.Effect<Capabilities, Error, Service | Plugin.Service | never>;\n}>;\ntype LoadCapabilities<Props, Capabilities extends ModuleReturn = ModuleReturn> = () => Promise<{\n default: (props: Props) => Effect.Effect<Capabilities, Error, Service | Plugin.Service | never>;\n}>;\n\ntype NormalizeReturn<R> = R extends readonly (infer A)[]\n ? A[]\n : R extends (infer A)[]\n ? A[]\n : R extends Any\n ? [R]\n : Any[];\n\nexport type LazyCapability<Props = void, Capabilities extends ModuleReturn = ModuleReturn, E extends Error = Error> = (\n props: Props,\n) => Effect.Effect<NormalizeReturn<Capabilities>, E, Service | Plugin.Service | never>;\n\n/**\n * Helper to define a lazily loaded implementation of a capability.\n * Supports single capabilities, arrays, and tuples of different capability types.\n * @param name The export name (e.g., 'AppGraphBuilder') - used to auto-compute module IDs.\n * @param loader The lazy loader function.\n * @returns A lazy capability function with ModuleTag symbol attached.\n */\nexport const lazy = <T = void, R extends ModuleReturn = ModuleReturn>(\n name: string,\n c: LoadCapability<T, R> | LoadCapabilities<T, R>,\n): LazyCapability<T> => {\n const lazyFn = (props: T) =>\n Effect.gen(function* () {\n const { default: getCapability } = yield* Effect.promise(() => c());\n const result = yield* getCapability(props);\n const normalized = result == null ? [] : Array.isArray(result) ? Array.from(result) : [result];\n return normalized as NormalizeReturn<R>;\n });\n\n // Props (T) are preserved so callers pass correctly-typed options, but the contributed\n // Capabilities type is widened to the opaque base. The concrete capability type often traces to a\n // module-internal source path that TypeScript cannot name in declaration files (TS2883); the base\n // type is portable. The contributed type is checked at Capability.contributes regardless.\n return Object.assign(lazyFn, { [ModuleTag]: name }) as LazyCapability<T>;\n};\n\n/**\n * Gets the module tag (export name) from a lazy capability function.\n * @param capability The lazy capability function.\n * @returns The module tag if present, undefined otherwise.\n */\n// TODO(wittjosiah): Stricter type for capability.\nexport const getModuleTag = (capability: unknown): string | undefined => {\n return capability && typeof capability === 'function' && ModuleTag in capability\n ? String(capability[ModuleTag])\n : undefined;\n};\n\n/**\n * Helper to define a capability module with explicit typing.\n * Wraps the default export function to provide better type inference and make the pattern explicit.\n *\n * This helper provides explicit typing for the module activation function,\n * making it clear that the function should:\n * - Access CapabilityManager via the Effect layer system (Capability.get, Capability.getAll, etc.)\n * - Return a capability, array of capabilities, or tuple of different capability types (sync or async)\n *\n * Supports returning multiple capabilities of different types as a tuple, which will be normalized\n * to an array at runtime for compatibility with the plugin system.\n *\n * @example\n * ```ts\n * // Module without options - single capability\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* () {\n * const client = yield* Capability.get(ClientCapabilities.Client);\n * return contributes(Capabilities.SettingsStore, store);\n * })\n * );\n *\n * // Module with multiple capabilities\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* () {\n * return [\n * contributes(Capabilities.SettingsStore, store),\n * contributes(Capabilities.Translations, translations),\n * ];\n * })\n * );\n *\n * // Module with required options (context accessed via layer)\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* (props: { observability: boolean }) {\n * const invoker = yield* Capability.get(Capabilities.OperationInvoker);\n * return contributes(Capabilities.OperationHandler, ...);\n * })\n * );\n * ```\n */\nexport const makeModule = <\n TProps = void,\n TReturn extends ModuleReturn = ModuleReturn,\n E extends Error = Error,\n R extends Service | Plugin.Service | never = Service,\n>(\n fn: (props: TProps) => Effect.Effect<TReturn, E, R>,\n): ((props: TProps) => Effect.Effect<TReturn, E, R>) => fn;\n"],
5
+ "mappings": ";;;;;;AAAA;;;;;;;;;;;;;;;;AAKA,YA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CAAA,IAAKE,MAAMC,QAAQH,MAAAA,IAAUE,MAAME,KAAKJ,MAAAA,IAAU;MAACA;;AACvF,WAAOC;EACT,CAAA;AAMF,SAAOI,OAAOC,OAAOZ,QAAQ;IAAE,CAACb,SAAAA,GAAYW;EAAK,CAAA;AACnD;AAQO,IAAMe,eAAe,CAACC,eAAAA;AAC3B,SAAOA,cAAc,OAAOA,eAAe,cAAc3B,aAAa2B,aAClEC,OAAOD,WAAW3B,SAAAA,CAAU,IAC5B6B;AACN;AA2CO,IAAMC,aAAa,CAMxBC,OACsDA;",
6
+ "names": ["Context", "Effect", "Layer", "Service", "Tag", "get", "interfaceDef", "flatMap", "manager", "try", "catch", "error", "Error", "String", "getAll", "map", "waitFor", "atom", "atomByModule", "asLayer", "tag", "effect", "pipe", "orDie", "ModuleTag", "Symbol", "for", "make", "identifier", "contributes", "interfaceDef", "implementation", "deactivate", "interface", "lazy", "name", "c", "lazyFn", "props", "gen", "default", "getCapability", "promise", "result", "normalized", "Array", "isArray", "from", "Object", "assign", "getModuleTag", "capability", "String", "undefined", "makeModule", "fn"]
7
+ }
@@ -14,13 +14,12 @@ __export(activation_event_exports, {
14
14
  make: () => make,
15
15
  oneOf: () => oneOf
16
16
  });
17
+ import { DXN } from "@dxos/keys";
17
18
  import { compositeKey } from "@dxos/util";
18
- var make = (id, specifier) => {
19
- return {
20
- id,
21
- specifier
22
- };
23
- };
19
+ var make = (nsid, specifier) => ({
20
+ id: DXN.make(nsid),
21
+ specifier
22
+ });
24
23
  var eventKey = (event) => event.specifier ? compositeKey(event.id, event.specifier) : event.id;
25
24
  var oneOf = (...events) => ({
26
25
  type: "one-of",
@@ -46,4 +45,4 @@ export {
46
45
  getEvents,
47
46
  activation_event_exports
48
47
  };
49
- //# sourceMappingURL=chunk-XOCUANHO.mjs.map
48
+ //# sourceMappingURL=chunk-BMW6P6QA.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/core/activation-event.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { DXN } from '@dxos/keys';\nimport { compositeKey } from '@dxos/util';\n\n/**\n * A unique DXN identifier representing an event.\n *\n * @example dxn:org.dxos.plugin.example.event.ready\n */\nexport type ActivationEvent = {\n id: DXN.DXN;\n specifier?: string;\n};\n\n/**\n * An activation event that can be a single event, or a combination of events.\n */\nexport type Events =\n | ActivationEvent\n | { type: 'one-of'; events: ActivationEvent[] }\n | { type: 'all-of'; events: ActivationEvent[] };\n\n/**\n * Helper to define an activation event from an NSID.\n * Static NSID strings are validated at compile time via {@link DXN.Name}.\n */\nexport const make: {\n <T extends string>(\n nsid: [DXN.Name<T>] extends [never] ? `Invalid NSID \"${T}\": final segment must be camelCase (no hyphens)` : T,\n specifier?: string,\n ): ActivationEvent;\n} = (nsid: string, specifier?: string): ActivationEvent => ({\n id: DXN.make(nsid),\n specifier,\n});\n\n/**\n * Helper to create an activation event key.\n */\nexport const eventKey = (event: ActivationEvent) =>\n event.specifier ? compositeKey(event.id, event.specifier) : event.id;\n\n/**\n * Helper to create an activation event that triggers when any of the given events are activated.\n */\nexport const oneOf = (...events: ActivationEvent[]) => ({ type: 'one-of' as const, events });\n\n/**\n * Helper to create an activation event that triggers when all of the given events are activated.\n */\nexport const allOf = (...events: ActivationEvent[]) => ({ type: 'all-of' as const, events });\n\n/**\n * Helper to check if an activation event is a one-of event.\n */\nexport const isOneOf = (events: Events): events is { type: 'one-of'; events: ActivationEvent[] } =>\n 'type' in events && events.type === 'one-of';\n\n/**\n * Helper to check if an activation event is an all-of event.\n */\nexport const isAllOf = (events: Events): events is { type: 'all-of'; events: ActivationEvent[] } =>\n 'type' in events && events.type === 'all-of';\n\n/**\n * Helper to get the events from an activation event.\n */\nexport const getEvents = (events: Events) => ('type' in events ? events.events : [events]);\n"],
5
+ "mappings": ";;;;;;AAAA;;;;;;;;;;AAIA,SAASA,WAAW;AACpB,SAASC,oBAAoB;AAwBtB,IAAMC,OAKT,CAACC,MAAcC,eAAyC;EAC1DC,IAAIL,IAAIE,KAAKC,IAAAA;EACbC;AACF;AAKO,IAAME,WAAW,CAACC,UACvBA,MAAMH,YAAYH,aAAaM,MAAMF,IAAIE,MAAMH,SAAS,IAAIG,MAAMF;AAK7D,IAAMG,QAAQ,IAAIC,YAA+B;EAAEC,MAAM;EAAmBD;AAAO;AAKnF,IAAME,QAAQ,IAAIF,YAA+B;EAAEC,MAAM;EAAmBD;AAAO;AAKnF,IAAMG,UAAU,CAACH,WACtB,UAAUA,UAAUA,OAAOC,SAAS;AAK/B,IAAMG,UAAU,CAACJ,WACtB,UAAUA,UAAUA,OAAOC,SAAS;AAK/B,IAAMI,YAAY,CAACL,WAAoB,UAAUA,SAASA,OAAOA,SAAS;EAACA;;",
6
+ "names": ["DXN", "compositeKey", "make", "nsid", "specifier", "id", "eventKey", "event", "oneOf", "events", "type", "allOf", "isOneOf", "isAllOf", "getEvents"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  capabilities_exports
4
- } from "./chunk-NULBHQYS.mjs";
4
+ } from "./chunk-LUK3FCTH.mjs";
5
5
 
6
6
  // src/helpers.ts
7
7
  var topologicalSort = (nodes) => {
@@ -43,6 +43,7 @@ import { createContext, useContext } from "react";
43
43
  import { raise } from "@dxos/debug";
44
44
  var PluginManagerContext = createContext(void 0);
45
45
  var usePluginManager = () => useContext(PluginManagerContext) ?? raise(new Error("Missing PluginManagerContext"));
46
+ var useOptionalPluginManager = () => useContext(PluginManagerContext);
46
47
  var PluginManagerProvider = PluginManagerContext.Provider;
47
48
 
48
49
  // src/ui/components/Surface/context.ts
@@ -410,15 +411,15 @@ var SurfaceContextProvider = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({
410
411
  }))));
411
412
  }));
412
413
  SurfaceContextProvider.displayName = "SurfaceContextProvider";
413
- var SurfaceComponent = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id: _id, role, type, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {
414
+ var SurfaceComponent = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id: _id, type, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {
414
415
  const data = useDefaultValue(dataProp, () => ({}));
415
416
  const surfaces = useSurfaces();
416
- const effectiveRole = role ?? type?.role;
417
+ const effectiveRole = type?.role;
417
418
  if (effectiveRole == null) {
418
419
  if (DEBUG) {
419
- log.warn("Surface has neither `role` nor `type` prop", {
420
+ log.warn("Surface is missing required `type` prop", {
420
421
  id: _id
421
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 194, S: void 0 });
422
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 193, S: void 0 });
422
423
  }
423
424
  return null;
424
425
  }
@@ -431,7 +432,7 @@ var SurfaceComponent = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id: _
431
432
  log.warn("no candidates for surface", {
432
433
  role: effectiveRole,
433
434
  data
434
- }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 207, S: void 0 });
435
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 206, S: void 0 });
435
436
  return null;
436
437
  }
437
438
  return /* @__PURE__ */ React3.createElement(Suspense, {
@@ -477,24 +478,49 @@ var useSurfaces = () => {
477
478
  surfacesByModule
478
479
  ]);
479
480
  };
480
- function isSurfaceAvailable(capabilityManager, { role, type, data }) {
481
- const effectiveRole = role ?? type?.role;
481
+ function isSurfaceAvailable(capabilityManager, args) {
482
+ const effectiveRole = args.type?.role;
482
483
  if (effectiveRole == null) {
483
484
  return false;
484
485
  }
485
486
  const surfaces = capabilityManager.getAll(capabilities_exports.ReactSurface);
486
487
  const candidates = findCandidates(surfaces.flat(), {
487
488
  role: effectiveRole,
488
- data
489
+ data: args.data
489
490
  });
490
491
  return candidates.length > 0;
491
492
  }
492
493
 
493
494
  // src/ui/components/Surface/types.ts
495
+ import { log as log2 } from "@dxos/log";
496
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/ui/components/Surface/types.ts";
494
497
  var isSurfaceFilter = (value) => typeof value === "object" && value !== null && Array.isArray(value.bindings);
495
- var makeType = (role) => ({
496
- role
497
- });
498
+ var makeType = (nsid) => {
499
+ if (typeof nsid !== "string" || !/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\.[a-zA-Z][a-zA-Z0-9]{0,62})$/.test(nsid)) {
500
+ throw new Error(`Invalid role NSID: "${nsid}". Must be a dotted name with a camelCase final segment (no hyphens in the last segment).`);
501
+ }
502
+ return {
503
+ role: nsid
504
+ };
505
+ };
506
+ var makeFilter = (token, guard) => {
507
+ const boundGuard = guard == null ? () => true : (data) => {
508
+ try {
509
+ return guard(data);
510
+ } catch (err) {
511
+ log2.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 39, S: void 0 });
512
+ return false;
513
+ }
514
+ };
515
+ return {
516
+ bindings: [
517
+ {
518
+ role: token.role,
519
+ guard: boundGuard
520
+ }
521
+ ]
522
+ };
523
+ };
498
524
  var expandBindings = (filter) => {
499
525
  const bindings = filter.bindings;
500
526
  const roles = Array.from(new Set(bindings.map((binding) => binding.role)));
@@ -518,40 +544,28 @@ var validateLocalId = (id) => {
518
544
  };
519
545
  function create(definition) {
520
546
  validateLocalId(definition.id);
521
- if (isSurfaceFilter(definition.filter)) {
522
- const { id, filter, component, position } = definition;
523
- const { role, guard } = expandBindings(filter);
524
- return {
525
- kind: "react",
526
- id,
527
- role,
528
- position,
529
- component,
530
- filter: guard
531
- };
532
- }
547
+ const { id, filter, component, position } = definition;
548
+ const { role, guard } = expandBindings(filter);
533
549
  return {
534
- ...definition,
535
- kind: "react"
550
+ kind: "react",
551
+ id,
552
+ role,
553
+ position,
554
+ component,
555
+ filter: guard
536
556
  };
537
557
  }
538
558
  function createWeb(definition) {
539
559
  validateLocalId(definition.id);
540
- if (isSurfaceFilter(definition.filter)) {
541
- const { id, filter, tagName, position } = definition;
542
- const { role, guard } = expandBindings(filter);
543
- return {
544
- kind: "web-component",
545
- id,
546
- role,
547
- position,
548
- tagName,
549
- filter: guard
550
- };
551
- }
560
+ const { id, filter, tagName, position } = definition;
561
+ const { role, guard } = expandBindings(filter);
552
562
  return {
553
- ...definition,
554
- kind: "web-component"
563
+ kind: "web-component",
564
+ id,
565
+ role,
566
+ position,
567
+ tagName,
568
+ filter: guard
555
569
  };
556
570
  }
557
571
 
@@ -563,6 +577,7 @@ function createWeb(definition) {
563
577
  Surface2.Surface = SurfaceComponent;
564
578
  Surface2.isAvailable = isSurfaceAvailable;
565
579
  Surface2.makeType = makeType;
580
+ Surface2.makeFilter = makeFilter;
566
581
  Surface2.isFilter = isSurfaceFilter;
567
582
  Surface2.ProfilerProvider = SurfaceProfilerProvider;
568
583
  Surface2.useProfilerCallback = useSurfaceProfilerCallback;
@@ -581,8 +596,9 @@ export {
581
596
  topologicalSort,
582
597
  useSurface,
583
598
  usePluginManager,
599
+ useOptionalPluginManager,
584
600
  PluginManagerProvider,
585
601
  SurfaceComponent,
586
602
  Surface
587
603
  };
588
- //# sourceMappingURL=chunk-A5CHGAZE.mjs.map
604
+ //# sourceMappingURL=chunk-H7T7XXLS.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/helpers.ts", "../../../src/ui/hooks/useSurface.ts", "../../../src/ui/components/PluginManager/PluginManagerProvider.ts", "../../../src/ui/components/Surface/context.ts", "../../../src/ui/components/Surface/SurfaceComponent.tsx", "../../../src/ui/components/Surface/SurfaceInfo.tsx", "../../../src/ui/components/Surface/SurfaceProfilerContext.tsx", "../../../src/ui/components/Surface/types.ts", "../../../src/ui/components/Surface/index.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\ntype DependencyNode = {\n id: string;\n dependsOn?: string[];\n};\n\n/**\n * Topologically sorts a list of nodes based on their dependencies.\n */\n// TODO(wittjosiah): Factor out?\nexport const topologicalSort = <T extends DependencyNode>(nodes: T[]): T[] => {\n const getDependencies = (nodeId: string, seen = new Set<string>(), path = new Set<string>()): string[] => {\n if (path.has(nodeId)) {\n throw new Error(`Circular dependency detected involving ${nodeId}`);\n }\n if (seen.has(nodeId)) {\n return [];\n }\n\n const node = nodes.find((n) => n.id === nodeId);\n if (!node) {\n throw new Error(`Node ${nodeId} not found but is listed as a dependency`);\n }\n\n const newPath = new Set([...path, nodeId]);\n const newSeen = new Set([...seen, nodeId]);\n\n const dependsOn = node.dependsOn ?? [];\n return [...dependsOn.flatMap((depId) => getDependencies(depId, newSeen, newPath)), nodeId];\n };\n\n // Get all unique dependencies.\n const allDependencies = nodes\n .map((node) => node.id)\n .flatMap((id) => getDependencies(id))\n .filter((id, index, self) => self.indexOf(id) === index);\n\n // Map back to original nodes\n return allDependencies\n .map((id) => nodes.find((node) => node.id === id))\n .filter((node): node is T => node !== undefined);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { Surface } from '../components';\n\nexport const useSurface = (): Surface.Context => {\n return useContext(Surface.Context) ?? raise(new Error('Missing SurfaceContext'));\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type PluginManager } from '../../../core';\n\nconst PluginManagerContext = createContext<PluginManager.PluginManager | undefined>(undefined);\n\n/**\n * Get the plugin manager.\n */\nexport const usePluginManager = (): PluginManager.PluginManager =>\n useContext(PluginManagerContext) ?? raise(new Error('Missing PluginManagerContext'));\n\n/**\n * Get the plugin manager if present, or `undefined` when rendered outside a {@link PluginManagerProvider}\n * (e.g. a standalone component story). Lets components treat plugin capabilities as a progressive\n * enhancement rather than a hard requirement.\n */\nexport const useOptionalPluginManager = (): PluginManager.PluginManager | undefined => useContext(PluginManagerContext);\n\n/**\n * Context provider for a plugin manager.\n */\nexport const PluginManagerProvider = PluginManagerContext.Provider;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Context, createContext } from 'react';\n\nexport type SurfaceContext = {\n id?: string;\n /** The resolved role NSID (e.g. `org.dxos.role.article`). */\n role: string;\n data?: Record<string, any>;\n};\n\n// TODO(burdon): Use @radix-ui/react-context\nexport const SurfaceContext: Context<SurfaceContext | undefined> = createContext<SurfaceContext | undefined>(undefined);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, {\n type FC,\n Fragment,\n type NamedExoticComponent,\n Profiler,\n type RefAttributes,\n Suspense,\n forwardRef,\n memo,\n useEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport { log } from '@dxos/log';\nimport { ErrorBoundary } from '@dxos/react-error-boundary';\nimport { useDefaultValue } from '@dxos/react-hooks';\nimport { byPosition } from '@dxos/util';\n\nimport { Capabilities } from '../../../common';\nimport { type CapabilityManager } from '../../../core';\nimport { usePluginManager } from '../PluginManager/PluginManagerProvider';\nimport { SurfaceContext } from './context';\nimport { SurfaceInfo } from './SurfaceInfo';\nimport { useSurfaceProfilerCallback } from './SurfaceProfilerContext';\nimport {\n type Definition,\n type Props,\n type RoleToken,\n type TokenData,\n type TypedProps,\n type WebComponentDefinition,\n} from './types';\n\nconst DEBUG = import.meta.env.VITE_DEBUG;\n\nconst DEFAULT_PLACEHOLDER = <Fragment />;\n\n/**\n * Wrapper component for rendering Web Component surfaces.\n * Handles creation, prop setting, and cleanup of Web Components.\n */\ntype WebComponentWrapperProps = {\n id?: string;\n role: string;\n data?: Record<string, any>;\n limit?: number;\n definition: WebComponentDefinition;\n [key: string]: any;\n};\n\nconst WebComponentWrapper = memo(\n forwardRef<HTMLElement, WebComponentWrapperProps>(({ id, role, data, limit, definition, ...rest }, forwardedRef) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const elementRef = useRef<HTMLElement | null>(null);\n const propsRef = useRef({ id, role, data, limit, ...rest });\n\n // Update props ref on every render\n propsRef.current = { id, role, data, limit, ...rest };\n\n // Create element only once\n useEffect(() => {\n if (!containerRef.current || elementRef.current) {\n return;\n }\n\n // Create the Web Component\n const element = document.createElement(definition.tagName);\n elementRef.current = element;\n\n // Set initial properties on the Web Component\n Object.assign(element, propsRef.current);\n\n // Append to container\n containerRef.current.appendChild(element);\n\n // Setup ref forwarding if provided\n if (typeof forwardedRef === 'function') {\n forwardedRef(element);\n } else if (forwardedRef) {\n forwardedRef.current = element;\n }\n\n // Cleanup on unmount to prevent memory leaks\n return () => {\n if (elementRef.current && containerRef.current?.contains(elementRef.current)) {\n containerRef.current.removeChild(elementRef.current);\n }\n if (typeof forwardedRef === 'function') {\n forwardedRef(null);\n } else if (forwardedRef) {\n forwardedRef.current = null;\n }\n elementRef.current = null;\n };\n }, [definition.tagName, forwardedRef]);\n\n // Update props on existing element without recreating it\n // This runs on every render to ensure all props (including those in `rest`) are kept up to date\n useEffect(() => {\n const element = elementRef.current;\n if (!element) {\n return;\n }\n\n // Update properties on the existing Web Component\n Object.assign(element, propsRef.current);\n });\n\n return <div ref={containerRef} />;\n }),\n);\n\nWebComponentWrapper.displayName = 'WebComponentWrapper';\n\ntype SurfaceContextProviderProps = {\n id: string;\n role: string;\n data?: Record<string, any>;\n limit?: number;\n fallback?: FC<{ error: Error; data?: any }>;\n definition: Definition;\n [key: string]: any;\n};\n\n/**\n * Wrapper component that provides context for a surface.\n */\n// TODO(burdon): Allow DebugPlugin to provide different fallback using react-ui ErrorFallback.\nconst SurfaceContextProvider = memo(\n forwardRef<HTMLElement, SurfaceContextProviderProps>(\n ({ id, role, data, limit, fallback = ErrorFallback, definition, ...rest }, forwardedRef) => {\n const contextValue = useMemo(() => ({ id, role, data }), [id, role, data]);\n const onProfilerRender = useSurfaceProfilerCallback();\n const profilerId = `surface/${id}/${role}`;\n\n // Handle Web Component surfaces\n if (definition.kind === 'web-component') {\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <SurfaceContext.Provider value={contextValue}>\n <WebComponentWrapper\n id={id}\n role={role}\n data={data}\n limit={limit}\n definition={definition}\n ref={forwardedRef}\n {...rest}\n />\n </SurfaceContext.Provider>\n </ErrorBoundary>\n );\n }\n\n // Handle React component surfaces\n const Component = definition.component;\n\n // TODO(burdon): Remove from production build?\n const debug = DEBUG || '__DX_DEBUG__' in window;\n if (debug) {\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <div className='contents' data-id={id} data-role={role}>\n <SurfaceContext.Provider value={contextValue}>\n <SurfaceInfo ref={forwardedRef}>\n {onProfilerRender && !profilerId.includes('org.dxos.plugin.debug') ? (\n <Profiler id={profilerId} onRender={onProfilerRender}>\n <Component id={id} role={role} data={data} limit={limit} {...rest} />\n </Profiler>\n ) : (\n <Component id={id} role={role} data={data} limit={limit} {...rest} />\n )}\n </SurfaceInfo>\n </SurfaceContext.Provider>\n </div>\n </ErrorBoundary>\n );\n }\n\n return (\n <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>\n <div className='contents' data-id={id} data-role={role}>\n <SurfaceContext.Provider value={contextValue}>\n <Component id={id} role={role} data={data} limit={limit} {...rest} ref={forwardedRef} />\n </SurfaceContext.Provider>\n </div>\n </ErrorBoundary>\n );\n },\n ),\n);\n\nSurfaceContextProvider.displayName = 'SurfaceContextProvider';\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n * The `type` prop is a {@link RoleToken} that defines which region and its\n * associated data contract.\n */\n// TODO(burdon): Remove `ref` since relying on this would be error prone.\nexport const SurfaceComponent = memo(\n forwardRef<HTMLElement, TypedProps<RoleToken<any>>>(\n ({ id: _id, type, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {\n const data = useDefaultValue(dataProp, () => ({}));\n // TODO(wittjosiah): This will make all surfaces depend on a single signal.\n // This isn't ideal because it means that any change to the data will cause all surfaces to re-render.\n // This effectively means that plugin modules which contribute surfaces need to all be activated at startup.\n // This should be fine for now because it's how it worked prior to capabilities api anyway.\n // In the future, it would be nice to be able to bucket the surface contributions by role.\n const surfaces = useSurfaces();\n\n const effectiveRole = type?.role;\n if (effectiveRole == null) {\n if (DEBUG) {\n log.warn('Surface is missing required `type` prop', { id: _id });\n }\n return null;\n }\n\n // NOTE: Memoizing the candidates makes the surface not re-render based on reactivity within data.\n const definitions = findCandidates(surfaces, { role: effectiveRole, data });\n const candidates = limit ? definitions.slice(0, limit) : definitions;\n if (DEBUG && candidates.length === 0) {\n log.warn('no candidates for surface', { role: effectiveRole, data });\n return null;\n }\n\n return (\n <Suspense fallback={placeholder}>\n {candidates.map((definition) => (\n <SurfaceContextProvider\n key={definition.id}\n id={definition.id}\n role={effectiveRole}\n data={data}\n limit={limit}\n definition={definition}\n ref={forwardedRef}\n {...rest}\n />\n ))}\n </Suspense>\n );\n },\n ),\n) as (<TToken extends RoleToken<any>>(props: TypedProps<TToken> & RefAttributes<HTMLElement>) => React.ReactNode) &\n NamedExoticComponent<TypedProps<RoleToken<any>> & RefAttributes<HTMLElement>>;\n\nSurfaceComponent.displayName = 'Surface';\n\n// TODO(burdon): Make user facing, with telemetry.\nconst ErrorFallback = ({ error }: { error: Error }) => {\n const { message } = error instanceof Error ? error : { message: String(error) };\n return (\n <div role='alert' data-testid='error-boundary-fallback'>\n <h1 className='flex gap-2 text-sm mt-2 text-info-text'>{message}</h1>\n </div>\n );\n};\n\nconst findCandidates = (surfaces: Definition[], { role, data }: { role: string; data: Props['data'] }) => {\n return Object.values(surfaces)\n .filter((definition) =>\n Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,\n )\n .filter(({ filter }) => (filter ? filter(data ?? {}, role) : true))\n .toSorted(byPosition);\n};\n\n/**\n * @internal\n */\nexport const useSurfaces = () => {\n const manager = usePluginManager();\n const surfacesByModule = useAtomValue(manager.capabilities.atomByModule(Capabilities.ReactSurface));\n return useMemo(() => {\n const result: Definition[] = [];\n for (const [moduleId, surfaces] of Object.entries(surfacesByModule)) {\n for (const def of surfaces.flat()) {\n result.push(def);\n }\n }\n return result;\n }, [surfacesByModule]);\n};\n\n/**\n * @returns `true` if there is a contributed surface which matches the specified role & data, `false` otherwise.\n *\n * Typed: pass a `type` role token and `data` is constrained to the token's\n * declared contract (e.g. `AppSurface.Section` requires `attendableId`).\n */\nexport function isSurfaceAvailable<TToken extends RoleToken<any>>(\n capabilityManager: CapabilityManager.CapabilityManager,\n args: { type: TToken; data?: TokenData<TToken> },\n): boolean {\n const effectiveRole = args.type?.role;\n if (effectiveRole == null) {\n return false;\n }\n const surfaces = capabilityManager.getAll(Capabilities.ReactSurface);\n const candidates = findCandidates(surfaces.flat(), {\n role: effectiveRole,\n data: args.data as Props['data'],\n });\n return candidates.length > 0;\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, {\n type ReactElement,\n type Ref,\n cloneElement,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { addEventListener, combine } from '@dxos/async';\nimport { useMergeRefs } from '@dxos/react-hooks';\n\nimport { useSurface } from '../../hooks';\n\nexport type SurfaceInfoProps = {\n children: ReactElement<{ ref?: Ref<HTMLElement> }>;\n};\n\n/**\n * Debug wrapper for surfaces.\n */\nexport const SurfaceInfo = forwardRef<HTMLElement, SurfaceInfoProps>(({ children }, forwardedRef) => {\n const [rect, setRect] = useState<DOMRect | null>(null);\n const [expand, setExpand] = useState(false);\n const info = useSurface();\n\n const [root, setRoot] = useState<HTMLElement | null>(null);\n const measureRef = useCallback((node: HTMLElement | null) => setRoot(node), []);\n const mergedRef = useMergeRefs([measureRef, forwardedRef]);\n const childWithRef = cloneElement(children, { ref: mergedRef });\n\n useLayoutEffect(() => {\n if (!root) {\n setRect(null);\n return;\n }\n\n const measure = () => {\n setRect(root.getBoundingClientRect());\n };\n\n const observer = new ResizeObserver(measure);\n observer.observe(root);\n measure();\n\n return combine(\n addEventListener(window, 'scroll', measure, true),\n addEventListener(window, 'resize', measure),\n () => {\n observer.disconnect();\n },\n );\n }, [root]);\n\n const padding = 0;\n return (\n <>\n {childWithRef}\n {rect &&\n createPortal(\n <div\n className='z-[100] fixed flex flex-col-reverse scrollbar-none overflow-auto pointer-events-none'\n style={{\n top: rect.top + padding,\n left: rect.left + padding,\n width: rect.width - padding * 2,\n height: rect.height - padding * 2,\n }}\n >\n {expand ? (\n <div\n className='absolute inset-0 bg-deck-surface border border-green-500 cursor-pointer pointer-events-auto overflow-auto'\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n setExpand(false);\n }}\n >\n <pre className='p-2 text-xs text-description font-mono'>{JSON.stringify({ info }, null, 2)}</pre>\n </div>\n ) : (\n <span\n 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'\n title={info.id}\n onPointerDown={(ev) => ev.stopPropagation()}\n onClick={(ev) => {\n ev.stopPropagation();\n setExpand(true);\n }}\n >\n ⓘ\n </span>\n )}\n </div>,\n // TODO(burdon): Create well-known element to gather all debug portals.\n document.body,\n )}\n </>\n );\n});\n", "//\n// Copyright 2026 DXOS.org\n//\n\nimport React, {\n type Context,\n type PropsWithChildren,\n type ProfilerOnRenderCallback,\n createContext,\n useContext,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from 'react';\n\nconst MAX_ENTRIES = 500;\n\n/**\n * Single profiler record captured from React Profiler onRender callback.\n */\nexport type SurfaceProfilerEntry = {\n id: string;\n phase: 'mount' | 'update' | 'nested-update';\n actualDuration: number;\n baseDuration: number;\n startTime: number;\n commitTime: number;\n timestamp: number;\n};\n\n/**\n * Aggregated stats for a single profiled surface.\n */\nexport type SurfaceProfilerStats = {\n id: string;\n mountCount: number;\n updateCount: number;\n totalRenders: number;\n avgActualDuration: number;\n maxActualDuration: number;\n avgBaseDuration: number;\n lastActualDuration: number;\n lastCommitTime: number;\n};\n\n/**\n * Store that collects profiler entries and notifies subscribers.\n */\nclass SurfaceProfilerStore {\n private _entries: SurfaceProfilerEntry[] = [];\n private _listeners = new Set<() => void>();\n private _snapshot: readonly SurfaceProfilerEntry[] = [];\n private _pendingNotify = false;\n\n /** Records an entry and schedules a deferred notification to avoid re-render loops. */\n record(entry: SurfaceProfilerEntry) {\n this._entries.push(entry);\n if (this._entries.length > MAX_ENTRIES) {\n this._entries = this._entries.slice(-MAX_ENTRIES);\n }\n this._snapshot = [...this._entries];\n this._scheduleNotify();\n }\n\n clear() {\n this._entries = [];\n this._snapshot = [];\n this._notifySync();\n }\n\n subscribe = (listener: () => void) => {\n this._listeners.add(listener);\n return () => {\n this._listeners.delete(listener);\n };\n };\n\n getSnapshot = (): readonly SurfaceProfilerEntry[] => {\n return this._snapshot;\n };\n\n /**\n * Defers notification to the next animation frame to break the\n * Profiler onRender → record → notify → re-render → onRender loop.\n */\n private _scheduleNotify() {\n if (!this._pendingNotify) {\n this._pendingNotify = true;\n requestAnimationFrame(() => {\n this._pendingNotify = false;\n this._notifySync();\n });\n }\n }\n\n private _notifySync() {\n for (const listener of this._listeners) {\n listener();\n }\n }\n}\n\ntype SurfaceProfilerContextValue = {\n store: SurfaceProfilerStore;\n};\n\nconst SurfaceProfilerContext: Context<SurfaceProfilerContextValue | undefined> = createContext<\n SurfaceProfilerContextValue | undefined\n>(undefined);\n\n/**\n * Provider that collects React Profiler data from Surface components.\n */\nexport const SurfaceProfilerProvider = ({ children }: PropsWithChildren) => {\n const storeRef = useRef<SurfaceProfilerStore>(null);\n if (!storeRef.current) {\n storeRef.current = new SurfaceProfilerStore();\n }\n return (\n <SurfaceProfilerContext.Provider value={{ store: storeRef.current }}>{children}</SurfaceProfilerContext.Provider>\n );\n};\n\n/**\n * Returns a stable onRender callback for use with React Profiler.\n */\nexport const useSurfaceProfilerCallback = (): ProfilerOnRenderCallback | undefined => {\n const store = useContext(SurfaceProfilerContext)?.store;\n return useMemo<ProfilerOnRenderCallback | undefined>(() => {\n if (!store) {\n return undefined;\n }\n return (id, phase, actualDuration, baseDuration, startTime, commitTime) => {\n store.record({\n id,\n phase,\n actualDuration,\n baseDuration,\n startTime,\n commitTime,\n timestamp: Date.now(),\n });\n };\n }, [store]);\n};\n\n/**\n * Returns all profiler entries reactively.\n */\nexport const useSurfaceProfilerEntries = (): readonly SurfaceProfilerEntry[] => {\n const context = useContext(SurfaceProfilerContext);\n return useSyncExternalStore(context?.store.subscribe ?? noop, context?.store.getSnapshot ?? emptySnapshot);\n};\n\n/**\n * Returns aggregated stats grouped by surface id.\n */\nexport const useSurfaceProfilerStats = (): SurfaceProfilerStats[] => {\n const entries = useSurfaceProfilerEntries();\n const statsMap = new Map<string, SurfaceProfilerStats>();\n\n for (const entry of entries) {\n let stats = statsMap.get(entry.id);\n if (!stats) {\n stats = {\n id: entry.id,\n mountCount: 0,\n updateCount: 0,\n totalRenders: 0,\n avgActualDuration: 0,\n maxActualDuration: 0,\n avgBaseDuration: 0,\n lastActualDuration: 0,\n lastCommitTime: 0,\n };\n statsMap.set(entry.id, stats);\n }\n\n if (entry.phase === 'mount') {\n stats.mountCount++;\n } else {\n stats.updateCount++;\n }\n stats.totalRenders++;\n stats.avgActualDuration =\n (stats.avgActualDuration * (stats.totalRenders - 1) + entry.actualDuration) / stats.totalRenders;\n stats.avgBaseDuration =\n (stats.avgBaseDuration * (stats.totalRenders - 1) + entry.baseDuration) / stats.totalRenders;\n stats.maxActualDuration = Math.max(stats.maxActualDuration, entry.actualDuration);\n stats.lastActualDuration = entry.actualDuration;\n stats.lastCommitTime = entry.commitTime;\n }\n\n return [...statsMap.values()].sort((a, b) => b.maxActualDuration - a.maxActualDuration);\n};\n\n/**\n * Clears all collected profiler entries.\n */\nexport const useSurfaceProfilerClear = (): (() => void) | undefined => {\n const store = useContext(SurfaceProfilerContext)?.store;\n return useMemo(() => (store ? () => store.clear() : undefined), [store]);\n};\n\nconst noop = () => () => {};\nconst EMPTY_SNAPSHOT: readonly SurfaceProfilerEntry[] = [];\nconst emptySnapshot = () => EMPTY_SNAPSHOT;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { FC, PropsWithChildren, ReactNode, Ref } from 'react';\n\nimport type { DXN } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport type { MakeOptional, Position } from '@dxos/util';\n\n/**\n * A typed role token. Carries a role NSID for runtime dispatch plus a phantom\n * data type so consumers using `type={SomeToken}` and providers using\n * `AppSurface.object(SomeToken, ...)` share a single type-level contract.\n *\n * Mint via {@link makeType}. The `role` field holds the bare NSID (e.g.\n * `org.dxos.role.article`) — the dispatch key, `data-role` attribute value,\n * and what `.role` comparisons inside matched components see.\n */\nexport type RoleToken<TData> = {\n readonly role: string;\n /** Covariant phantom; never accessed at runtime. */\n readonly _phantom?: TData;\n};\n\n/**\n * One entry in a {@link SurfaceFilter} — a role NSID plus the guard that\n * validates the data shape when the Surface dispatcher is matching that role.\n */\nexport type SurfaceBinding = {\n readonly role: string;\n readonly guard: (data: unknown) => boolean;\n};\n\n/**\n * Typed filter binding for {@link create}. Combines one or more `(role, guard)`\n * pairs so a provider can register against multiple roles while keeping the\n * role and its data shape in a single expression.\n */\nexport type SurfaceFilter<TData> = {\n readonly bindings: ReadonlyArray<SurfaceBinding>;\n /** Covariant phantom; never accessed at runtime. */\n readonly _phantom?: TData;\n};\n\n/**\n * Narrow data type carried by a role token.\n */\nexport type TokenData<T> = T extends RoleToken<infer D> ? D : never;\n\n/**\n * Runtime guard for {@link SurfaceFilter}. Distinguishes new-style filter\n * bindings from legacy predicate filters.\n */\nexport const isSurfaceFilter = (value: unknown): value is SurfaceFilter<any> =>\n typeof value === 'object' && value !== null && Array.isArray((value as { bindings?: unknown }).bindings);\n\n/**\n * Mints a typed role token. The NSID is validated at compile time via\n * {@link DXN.Name}: the final segment must be camelCase (no hyphens).\n * Dynamic NSIDs (template-literal / runtime strings) are validated at runtime.\n *\n * Identity is structural; all tokens with the same `role` string are\n * interchangeable at runtime.\n */\nexport const makeType: {\n <TData = unknown, T extends string = string>(\n nsid: [DXN.Name<T>] extends [never] ? `Invalid NSID \"${T}\": final segment must be camelCase (no hyphens)` : T,\n ): RoleToken<TData>;\n} = <TData>(nsid: string): RoleToken<TData> => {\n // Runtime guard for dynamic NSIDs that bypass the compile-time DXN.Name<T> check.\n if (\n typeof nsid !== 'string' ||\n !/^[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(\\.[a-zA-Z][a-zA-Z0-9]{0,62})$/.test(\n nsid,\n )\n ) {\n throw new Error(\n `Invalid role NSID: \"${nsid}\". Must be a dotted name with a camelCase final segment (no hyphens in the last segment).`,\n );\n }\n return { role: nsid };\n};\n\n/**\n * Creates a {@link SurfaceFilter} from a role token and an optional guard.\n *\n * When `guard` is omitted the filter matches any data at the token's role\n * (role-only dispatch). Pass a guard to add runtime data-shape validation on\n * top of the role match.\n *\n * This is the framework-level primitive; `@dxos/app-toolkit` builds richer\n * domain-aware helpers (ECHO schema checks, literal matching, etc.) on top of it.\n */\nexport const makeFilter = <TData>(token: RoleToken<TData>, guard?: (data: TData) => boolean): SurfaceFilter<TData> => {\n const boundGuard =\n guard == null\n ? () => true\n : (data: unknown): boolean => {\n try {\n return guard(data as TData);\n } catch (err) {\n log.catch(err);\n return false;\n }\n };\n return { bindings: [{ role: token.role, guard: boundGuard }] };\n};\n\n/**\n * Typed Surface consumer props — carries the role/data-shape contract via a\n * {@link RoleToken}. The `type` prop is required; the string `role` prop has\n * been removed from the consumer-facing API.\n */\nexport type Props<T extends Record<string, any> = Record<string, unknown>> = {\n /**\n * If specified, the Surface will be wrapped in an error boundary.\n * The fallback component will be rendered if an error occurs.\n */\n fallback?: FC<{ error: Error; data?: any }>;\n\n /**\n * If specified, the Surface will be wrapped in a suspense boundary.\n * The placeholder component will be rendered while the surface component is loading.\n */\n placeholder?: ReactNode;\n} & MakeOptional<CoreProps<T>, 'id' | 'data'>;\n\n/**\n * Typed Surface consumer props — carries the role/data-shape contract via a\n * {@link RoleToken}. Available as a typed overload of the Surface component so\n * ad-hoc `type` fields on arbitrary spread props don't conflict with the\n * untyped consumer form.\n */\nexport type TypedProps<TToken extends RoleToken<any>> = {\n fallback?: FC<{ error: Error; data?: any }>;\n placeholder?: ReactNode;\n id?: string;\n type: TToken;\n data?: TokenData<TToken>;\n limit?: number | undefined;\n} & {\n /**\n * Additional pass-through props. Known prop names are excluded so the\n * catch-all doesn't widen `data` / `type` / etc. to `any` at the intersection.\n */\n [K in keyof Record<string, any>]: K extends 'fallback' | 'placeholder' | 'id' | 'type' | 'data' | 'limit'\n ? never\n : any;\n};\n\n/**\n * NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.\n * The `type` prop is the only way to set the role; it is required here and\n * optional in {@link Props} via MakeOptional.\n */\nexport type CoreProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{\n /**\n * ID for debugging.\n */\n id: string;\n\n /**\n * The role token defining how the data should be rendered.\n */\n type: RoleToken<T>;\n\n /**\n * The data to be rendered by the surface.\n * NOTE: This must be a stable value.\n */\n data: T;\n\n /**\n * If more than one component is resolved, the limit determines how many are rendered.\n */\n limit?: number | undefined;\n}>;\n\n// TODO(burdon): Remove ref since relying on this would be error prone.\nexport type ComponentProps<T extends Record<string, any> = Record<string, any>> = {\n /**\n * The resolved role NSID string (e.g. `org.dxos.role.article`). Present on\n * matched components only — multi-role containers can branch on this value\n * by comparing against a token's `.role` (e.g. `role === AppSurface.Section.role`).\n */\n role: string;\n ref?: Ref<HTMLElement>;\n} & PropsWithChildren<{\n id: string;\n data: T;\n limit?: number | undefined;\n}> &\n Record<string, any>;\n\n/**\n * React component used to render a surface once is has matched.\n */\nexport type ComponentFunction<T extends Record<string, any> = Record<string, any>> = (\n props: ComponentProps<T>,\n) => ReactNode;\n\n/**\n * Definition of when a React component surface should be rendered.\n *\n * The optional `filter` receives the consumer-supplied `role` as its second\n * argument so a single definition can encode role-specific guards (used by the\n * {@link SurfaceFilter}-based `create` overload).\n *\n * @internal The `role` field is populated by the framework from the filter\n * bindings and is not authored directly.\n */\nexport type ReactDefinition<T extends Record<string, any> = any> = Readonly<{\n kind: 'react';\n id: string;\n role: string | string[];\n position?: Position;\n component: ComponentFunction<T>;\n filter?: (data: Record<string, unknown>, role?: string) => data is T;\n}>;\n\n/**\n * Definition of when a Web Component surface should be rendered.\n *\n * @internal The `role` field is populated by the framework from the filter\n * bindings and is not authored directly.\n */\nexport type WebComponentDefinition<T extends Record<string, any> = any> = Readonly<{\n kind: 'web-component';\n id: string;\n role: string | string[];\n position?: Position;\n /**\n * The tag name of the Web Component to render.\n * The Web Component will receive the same props as React surfaces via properties/attributes.\n */\n tagName: string;\n filter?: (data: Record<string, unknown>, role?: string) => data is T;\n}>;\n\n/**\n * Definition of when a surface (React or Web Component) should be rendered.\n */\nexport type Definition<T extends Record<string, any> = any> = ReactDefinition<T> | WebComponentDefinition<T>;\n\n/**\n * Typed React surface definition — role is derived from the filter's bindings.\n */\nexport type TypedReactDefinition<T extends Record<string, any> = any> = Readonly<{\n id: string;\n filter: SurfaceFilter<T>;\n component: ComponentFunction<T>;\n position?: Position;\n}>;\n\n/**\n * Typed Web Component surface definition.\n */\nexport type TypedWebComponentDefinition<T extends Record<string, any> = any> = Readonly<{\n id: string;\n filter: SurfaceFilter<T>;\n tagName: string;\n position?: Position;\n}>;\n\nconst expandBindings = <T extends Record<string, any>>(\n filter: SurfaceFilter<T>,\n): { role: string | string[]; guard: (data: Record<string, unknown>, role?: string) => data is T } => {\n const bindings = filter.bindings;\n const roles = Array.from(new Set(bindings.map((binding) => binding.role)));\n const guard = (data: Record<string, unknown>, role?: string): data is T => {\n if (role != null) {\n // Multiple bindings may share a role (e.g. via `oneOf` of same-role filters);\n // the role matches if ANY of them passes.\n return bindings.some((entry) => entry.role === role && entry.guard(data));\n }\n return bindings.some((entry) => entry.guard(data));\n };\n return { role: roles.length === 1 ? roles[0] : roles, guard };\n};\n\n/**\n * Validates that a surface or extension local ID follows NSID conventions:\n * each dot-separated segment must be alphanumeric, and the final segment must\n * be camelCase (no hyphens). This mirrors the rule enforced when the id is\n * appended to a plugin's NSID to form a full DXN path.\n *\n * @example Valid: 'about', 'integrationArticle', 'article.journal'\n * @example Invalid: 'integration-article', 'plugin-spec'\n */\nconst validateLocalId = (id: string): void => {\n const segments = id.split('.');\n const finalSegment = segments[segments.length - 1];\n if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(finalSegment)) {\n throw new Error(\n `Invalid surface id: \"${id}\". The final segment \"${finalSegment}\" must be camelCase (letters and digits only, starting with a letter — no hyphens or underscores).`,\n );\n }\n};\n\n/**\n * Creates a React surface definition from a typed filter.\n */\nexport function create<T extends Record<string, any> = any>(definition: TypedReactDefinition<T>): ReactDefinition<T>;\nexport function create<T extends Record<string, any> = any>(definition: TypedReactDefinition<T>): ReactDefinition<T> {\n validateLocalId(definition.id);\n const { id, filter, component, position } = definition;\n const { role, guard } = expandBindings(filter);\n return { kind: 'react', id, role, position, component, filter: guard };\n}\n\n/**\n * Creates a Web Component surface definition from a typed filter.\n */\nexport function createWeb<T extends Record<string, any> = any>(\n definition: TypedWebComponentDefinition<T>,\n): WebComponentDefinition<T>;\nexport function createWeb<T extends Record<string, any> = any>(\n definition: TypedWebComponentDefinition<T>,\n): WebComponentDefinition<T> {\n validateLocalId(definition.id);\n const { id, filter, tagName, position } = definition;\n const { role, guard } = expandBindings(filter);\n return { kind: 'web-component', id, role, position, tagName, filter: guard };\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type { DXN } from '@dxos/keys';\n\n// TODO(wittjosiah): Cleanup to avoid re-naming.\nimport { SurfaceContext } from './context';\nimport { SurfaceComponent, isSurfaceAvailable } from './SurfaceComponent';\nimport {\n SurfaceProfilerProvider,\n useSurfaceProfilerCallback,\n useSurfaceProfilerClear,\n useSurfaceProfilerEntries,\n useSurfaceProfilerStats,\n} from './SurfaceProfilerContext';\nimport {\n type Definition as SurfaceDefinition,\n type RoleToken as SurfaceRoleToken,\n type SurfaceBinding as SurfaceBindingType,\n type SurfaceFilter as SurfaceFilterType,\n type TokenData as SurfaceTokenData,\n type TypedProps as SurfaceTypedProps,\n create as createSurface,\n createWeb as createWebSurface,\n isSurfaceFilter as isSurfaceFilterFn,\n makeFilter as makeFilterFn,\n makeType as makeTypeFn,\n} from './types';\n\nexport namespace Surface {\n export type Definition = SurfaceDefinition;\n export const create = createSurface;\n export const createWeb = createWebSurface;\n\n export type Context = SurfaceContext;\n export const Context = SurfaceContext;\n\n export const Surface = SurfaceComponent;\n export const isAvailable = isSurfaceAvailable;\n\n export type RoleToken<TData> = SurfaceRoleToken<TData>;\n export type Binding = SurfaceBindingType;\n export type Filter<TData> = SurfaceFilterType<TData>;\n export type TokenData<T> = SurfaceTokenData<T>;\n export type TypedProps<TToken extends SurfaceRoleToken<any>> = SurfaceTypedProps<TToken>;\n\n /** Mints a typed role token. The NSID is validated at compile time via {@link DXN.Name}. */\n export const makeType: {\n <TData = unknown, T extends string = string>(\n nsid: [DXN.Name<T>] extends [never] ? `Invalid NSID \"${T}\": final segment must be camelCase (no hyphens)` : T,\n ): SurfaceRoleToken<TData>;\n } = makeTypeFn;\n\n export const makeFilter = makeFilterFn;\n export const isFilter = isSurfaceFilterFn;\n\n export const ProfilerProvider = SurfaceProfilerProvider;\n export const useProfilerCallback = useSurfaceProfilerCallback;\n export const useProfilerEntries = useSurfaceProfilerEntries;\n export const useProfilerStats = useSurfaceProfilerStats;\n export const useProfilerClear = useSurfaceProfilerClear;\n}\n\nexport type { SurfaceProfilerEntry, SurfaceProfilerStats } from './SurfaceProfilerContext';\n"],
5
+ "mappings": ";;;;;;AAaO,IAAMA,kBAAkB,CAA2BC,UAAAA;AACxD,QAAMC,kBAAkB,CAACC,QAAgBC,OAAO,oBAAIC,IAAAA,G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C7E,QAAA;;;;;UCtSiBO,UAAAA;WAEFC,SAASC;WACTC,YAAYC;WAGZC,UAAUC;WAEVN,UAAUO;WACVC,cAAcC;WASdC,WAITC;WAESC,aAAaC;WACbC,WAAWC;WAEXC,mBAAmBC;WACnBC,sBAAsBC;WACtBC,qBAAqBC;WACrBC,mBAAmBC;WACnBC,mBAAmBC;AAClC,GAhCiBzB,YAAAA,UAAAA,CAAAA,EAAAA;;;;APpBV,IAAM0B,aAAa,MAAA;AACxB,SAAOC,YAAWC,QAAQC,OAAO,KAAKC,OAAM,IAAIC,MAAM,wBAAA,CAAA;AACxD;",
6
+ "names": ["topologicalSort", "nodes", "getDependencies", "nodeId", "seen", "Set", "path", "has", "Error", "node", "find", "n", "id", "newPath", "newSeen", "dependsOn", "flatMap", "depId", "allDependencies", "map", "filter", "index", "self", "indexOf", "undefined", "useContext", "raise", "createContext", "useContext", "raise", "PluginManagerContext", "undefined", "usePluginManager", "Error", "useOptionalPluginManager", "PluginManagerProvider", "Provider", "createContext", "SurfaceContext", "undefined", "useAtomValue", "React", "Fragment", "Profiler", "Suspense", "forwardRef", "memo", "useEffect", "useMemo", "useRef", "log", "ErrorBoundary", "useDefaultValue", "byPosition", "React", "cloneElement", "forwardRef", "useCallback", "useLayoutEffect", "useState", "createPortal", "addEventListener", "combine", "useMergeRefs", "SurfaceInfo", "forwardRef", "children", "forwardedRef", "rect", "setRect", "useState", "expand", "setExpand", "info", "useSurface", "root", "setRoot", "measureRef", "useCallback", "node", "mergedRef", "useMergeRefs", "childWithRef", "cloneElement", "ref", "useLayoutEffect", "measure", "getBoundingClientRect", "observer", "ResizeObserver", "observe", "combine", "addEventListener", "window", "disconnect", "padding", "createPortal", "div", "className", "style", "top", "left", "width", "height", "onPointerDown", "ev", "stopPropagation", "onClick", "pre", "JSON", "stringify", "span", "title", "id", "document", "body", "React", "createContext", "useContext", "useMemo", "useRef", "useSyncExternalStore", "MAX_ENTRIES", "SurfaceProfilerStore", "_entries", "_listeners", "Set", "_snapshot", "_pendingNotify", "record", "entry", "push", "length", "slice", "_scheduleNotify", "clear", "_notifySync", "subscribe", "listener", "add", "delete", "getSnapshot", "requestAnimationFrame", "SurfaceProfilerContext", "undefined", "SurfaceProfilerProvider", "children", "storeRef", "current", "Provider", "value", "store", "useSurfaceProfilerCallback", "id", "phase", "actualDuration", "baseDuration", "startTime", "commitTime", "timestamp", "Date", "now", "useSurfaceProfilerEntries", "context", "noop", "emptySnapshot", "useSurfaceProfilerStats", "entries", "statsMap", "Map", "stats", "get", "mountCount", "updateCount", "totalRenders", "avgActualDuration", "maxActualDuration", "avgBaseDuration", "lastActualDuration", "lastCommitTime", "set", "Math", "max", "values", "sort", "a", "b", "useSurfaceProfilerClear", "EMPTY_SNAPSHOT", "WebComponentWrapper", "React", "forwardRef", "propsRef", "useRef", "id", "role", "data", "limit", "useEffect", "Object", "assign", "element", "containerRef", "current", "appendChild", "forwardedRef", "elementRef", "definition", "div", "FallbackComponent", "value", "contextValue", "ref", "debug", "DEBUG", "name", "className", "data-role", "SurfaceInfo", "onProfilerRender", "includes", "profilerId", "Component", "SurfaceContextProvider", "effectiveRole", "log", "SurfaceComponent", "ErrorFallback", "String", "error", "message", "findCandidates", "surfacesByModule", "useAtomValue", "useMemo", "moduleId", "def", "result", "surfaces", "candidates", "log", "__dxlog_file", "nsid", "guard", "data", "catch", "err", "role", "Array", "from", "Set", "bindings", "entry", "finalSegment", "segments", "filter", "position", "expandBindings", "kind", "id", "component", "tagName", "Surface", "create", "createSurface", "createWeb", "createWebSurface", "Context", "SurfaceContext", "SurfaceComponent", "isAvailable", "isSurfaceAvailable", "makeType", "makeTypeFn", "makeFilter", "makeFilterFn", "isFilter", "isSurfaceFilterFn", "ProfilerProvider", "SurfaceProfilerProvider", "useProfilerCallback", "useSurfaceProfilerCallback", "useProfilerEntries", "useSurfaceProfilerEntries", "useProfilerStats", "useSurfaceProfilerStats", "useProfilerClear", "useSurfaceProfilerClear", "useSurface", "useContext", "Surface", "Context", "raise", "Error"]
7
+ }
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
3
  capability_exports
4
- } from "./chunk-CTKEZHKF.mjs";
4
+ } from "./chunk-AIDZMJ3U.mjs";
5
5
  import {
6
6
  __export
7
7
  } from "./chunk-HSLMI22Q.mjs";
@@ -34,24 +34,24 @@ __export(capabilities_exports, {
34
34
  });
35
35
  import * as Effect from "effect/Effect";
36
36
  var Null = capability_exports.make("org.dxos.app-framework.capability.null");
37
- var PluginManager = capability_exports.make("org.dxos.app-framework.capability.plugin-manager");
38
- var AtomRegistry = capability_exports.make("org.dxos.app-framework.capability.atom-registry");
39
- var ReactContext = capability_exports.make("org.dxos.app-framework.capability.react-context");
40
- var ReactRoot = capability_exports.make("org.dxos.app-framework.capability.react-root");
41
- var ReactSurface = capability_exports.make("org.dxos.app-framework.common.react-surface");
37
+ var PluginManager = capability_exports.make("org.dxos.app-framework.capability.pluginManager");
38
+ var AtomRegistry = capability_exports.make("org.dxos.app-framework.capability.atomRegistry");
39
+ var ReactContext = capability_exports.make("org.dxos.app-framework.capability.reactContext");
40
+ var ReactRoot = capability_exports.make("org.dxos.app-framework.capability.reactRoot");
41
+ var ReactSurface = capability_exports.make("org.dxos.app-framework.capability.reactSurface");
42
42
  var Command = capability_exports.make("org.dxos.app-framework.capability.command");
43
43
  var Layer = capability_exports.make("org.dxos.app-framework.capability.layer");
44
- var LayerSpec = capability_exports.make("org.dxos.app-framework.capability.layer-spec");
45
- var TraceSink = capability_exports.make("org.dxos.app-framework.capability.trace-sink");
46
- var ServiceResolver = capability_exports.make("org.dxos.app-framework.capability.service-resolver");
47
- var ProcessMonitor = capability_exports.make("org.dxos.app-framework.capability.process-monitor");
48
- var ProcessManagerRuntime = capability_exports.make("org.dxos.app-framework.capability.process-manager-runtime");
49
- var ManagedRuntime = capability_exports.make("org.dxos.app-framework.capability.managed-runtime");
50
- var OperationHandler = capability_exports.make("org.dxos.app-framework.capability.operation-handler");
51
- var UndoMapping = capability_exports.make("org.dxos.app-framework.capability.undo-mapping");
52
- var OperationInvoker = capability_exports.make("org.dxos.app-framework.capability.operation-invoker");
53
- var UndoRegistry = capability_exports.make("org.dxos.app-framework.capability.undo-registry");
54
- var HistoryTracker = capability_exports.make("org.dxos.app-framework.capability.history-tracker");
44
+ var LayerSpec = capability_exports.make("org.dxos.app-framework.capability.layerSpec");
45
+ var TraceSink = capability_exports.make("org.dxos.app-framework.capability.traceSink");
46
+ var ServiceResolver = capability_exports.make("org.dxos.app-framework.capability.serviceResolver");
47
+ var ProcessMonitor = capability_exports.make("org.dxos.app-framework.capability.processMonitor");
48
+ var ProcessManagerRuntime = capability_exports.make("org.dxos.app-framework.capability.processManagerRuntime");
49
+ var ManagedRuntime = capability_exports.make("org.dxos.app-framework.capability.managedRuntime");
50
+ var OperationHandler = capability_exports.make("org.dxos.app-framework.capability.operationHandler");
51
+ var UndoMapping = capability_exports.make("org.dxos.app-framework.capability.undoMapping");
52
+ var OperationInvoker = capability_exports.make("org.dxos.app-framework.capability.operationInvoker");
53
+ var UndoRegistry = capability_exports.make("org.dxos.app-framework.capability.undoRegistry");
54
+ var HistoryTracker = capability_exports.make("org.dxos.app-framework.capability.historyTracker");
55
55
  var getAtomValue = (atomCapability) => Effect.gen(function* () {
56
56
  const registry = yield* capability_exports.get(AtomRegistry);
57
57
  const atom = yield* capability_exports.get(atomCapability);
@@ -93,4 +93,4 @@ export {
93
93
  subscribeAtom,
94
94
  capabilities_exports
95
95
  };
96
- //# sourceMappingURL=chunk-NULBHQYS.mjs.map
96
+ //# sourceMappingURL=chunk-LUK3FCTH.mjs.map