@dxos/app-framework 0.7.4 → 0.7.5-labs.5f04cf6

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 (327) hide show
  1. package/dist/lib/browser/chunk-22MGDQXD.mjs +1621 -0
  2. package/dist/lib/browser/chunk-22MGDQXD.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +136 -527
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +67 -0
  7. package/dist/lib/browser/testing/index.mjs.map +7 -0
  8. package/dist/lib/node/chunk-7PNEFY2G.cjs +1665 -0
  9. package/dist/lib/node/chunk-7PNEFY2G.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +141 -551
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +91 -0
  14. package/dist/lib/node/testing/index.cjs.map +7 -0
  15. package/dist/lib/node-esm/chunk-ZFOOPWBG.mjs +1623 -0
  16. package/dist/lib/node-esm/chunk-ZFOOPWBG.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +136 -527
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +68 -0
  21. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  22. package/dist/types/src/App.d.ts +22 -13
  23. package/dist/types/src/App.d.ts.map +1 -1
  24. package/dist/types/src/common/capabilities.d.ts +343 -0
  25. package/dist/types/src/common/capabilities.d.ts.map +1 -0
  26. package/dist/types/src/common/events.d.ts +41 -0
  27. package/dist/types/src/common/events.d.ts.map +1 -0
  28. package/dist/types/src/common/file.d.ts +14 -0
  29. package/dist/types/src/common/file.d.ts.map +1 -0
  30. package/dist/types/src/common/graph.d.ts +21 -0
  31. package/dist/types/src/common/graph.d.ts.map +1 -0
  32. package/dist/types/src/{plugins/common → common}/index.d.ts +3 -1
  33. package/dist/types/src/common/index.d.ts.map +1 -0
  34. package/dist/types/src/common/layout.d.ts +165 -0
  35. package/dist/types/src/common/layout.d.ts.map +1 -0
  36. package/dist/types/src/{plugins/common → common}/navigation.d.ts +77 -32
  37. package/dist/types/src/common/navigation.d.ts.map +1 -0
  38. package/dist/types/src/common/surface.d.ts +68 -0
  39. package/dist/types/src/common/surface.d.ts.map +1 -0
  40. package/dist/types/src/{plugins/common → common}/translations.d.ts +0 -11
  41. package/dist/types/src/common/translations.d.ts.map +1 -0
  42. package/dist/types/src/core/capabilities.d.ts +90 -0
  43. package/dist/types/src/core/capabilities.d.ts.map +1 -0
  44. package/dist/types/src/core/capabilities.test.d.ts +2 -0
  45. package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
  46. package/dist/types/src/core/events.d.ts +58 -0
  47. package/dist/types/src/core/events.d.ts.map +1 -0
  48. package/dist/types/src/core/index.d.ts +5 -0
  49. package/dist/types/src/core/index.d.ts.map +1 -0
  50. package/dist/types/src/core/manager.d.ts +126 -0
  51. package/dist/types/src/core/manager.d.ts.map +1 -0
  52. package/dist/types/src/core/manager.test.d.ts +2 -0
  53. package/dist/types/src/core/manager.test.d.ts.map +1 -0
  54. package/dist/types/src/core/plugin.d.ts +94 -0
  55. package/dist/types/src/core/plugin.d.ts.map +1 -0
  56. package/dist/types/src/helpers.d.ts +10 -0
  57. package/dist/types/src/helpers.d.ts.map +1 -0
  58. package/dist/types/src/helpers.test.d.ts +2 -0
  59. package/dist/types/src/helpers.test.d.ts.map +1 -0
  60. package/dist/types/src/index.d.ts +5 -1
  61. package/dist/types/src/index.d.ts.map +1 -1
  62. package/dist/types/src/playground/debug/Debug.d.ts +6 -0
  63. package/dist/types/src/playground/debug/Debug.d.ts.map +1 -0
  64. package/dist/types/src/playground/debug/index.d.ts +2 -0
  65. package/dist/types/src/playground/debug/index.d.ts.map +1 -0
  66. package/dist/types/src/playground/debug/plugin.d.ts +2 -0
  67. package/dist/types/src/playground/debug/plugin.d.ts.map +1 -0
  68. package/dist/types/src/playground/generator/Main.d.ts +6 -0
  69. package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
  70. package/dist/types/src/playground/generator/Toolbar.d.ts +6 -0
  71. package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
  72. package/dist/types/src/playground/generator/generator.d.ts +5 -0
  73. package/dist/types/src/playground/generator/generator.d.ts.map +1 -0
  74. package/dist/types/src/playground/generator/index.d.ts +3 -0
  75. package/dist/types/src/playground/generator/index.d.ts.map +1 -0
  76. package/dist/types/src/playground/generator/plugin.d.ts +2 -0
  77. package/dist/types/src/playground/generator/plugin.d.ts.map +1 -0
  78. package/dist/types/src/playground/layout/Layout.d.ts +8 -0
  79. package/dist/types/src/playground/layout/Layout.d.ts.map +1 -0
  80. package/dist/types/src/playground/layout/index.d.ts +2 -0
  81. package/dist/types/src/playground/layout/index.d.ts.map +1 -0
  82. package/dist/types/src/playground/layout/plugin.d.ts +2 -0
  83. package/dist/types/src/playground/layout/plugin.d.ts.map +1 -0
  84. package/dist/types/src/playground/logger/Toolbar.d.ts +6 -0
  85. package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -0
  86. package/dist/types/src/playground/logger/index.d.ts +2 -0
  87. package/dist/types/src/playground/logger/index.d.ts.map +1 -0
  88. package/dist/types/src/playground/logger/plugin.d.ts +2 -0
  89. package/dist/types/src/playground/logger/plugin.d.ts.map +1 -0
  90. package/dist/types/src/playground/logger/schema.d.ts +13 -0
  91. package/dist/types/src/playground/logger/schema.d.ts.map +1 -0
  92. package/dist/types/src/playground/playground.stories.d.ts +10 -0
  93. package/dist/types/src/playground/playground.stories.d.ts.map +1 -0
  94. package/dist/types/src/plugin-intent/IntentContext.d.ts +8 -0
  95. package/dist/types/src/plugin-intent/IntentContext.d.ts.map +1 -0
  96. package/dist/types/src/plugin-intent/IntentPlugin.d.ts +2 -0
  97. package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -0
  98. package/dist/types/src/plugin-intent/actions.d.ts +23 -0
  99. package/dist/types/src/plugin-intent/actions.d.ts.map +1 -0
  100. package/dist/types/src/plugin-intent/errors.d.ts +16 -0
  101. package/dist/types/src/plugin-intent/errors.d.ts.map +1 -0
  102. package/dist/types/src/plugin-intent/index.d.ts +6 -0
  103. package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
  104. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +106 -0
  105. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -0
  106. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +2 -0
  107. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
  108. package/dist/types/src/plugin-intent/intent.d.ts +68 -0
  109. package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
  110. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
  111. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
  112. package/dist/types/src/plugin-settings/actions.d.ts +17 -0
  113. package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
  114. package/dist/types/src/plugin-settings/index.d.ts +3 -0
  115. package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
  116. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
  117. package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
  118. package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
  119. package/dist/types/src/react/Surface.d.ts +12 -0
  120. package/dist/types/src/react/Surface.d.ts.map +1 -0
  121. package/dist/types/src/react/index.d.ts +5 -0
  122. package/dist/types/src/react/index.d.ts.map +1 -0
  123. package/dist/types/src/react/useCapabilities.d.ts +13 -0
  124. package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
  125. package/dist/types/src/testing/index.d.ts +2 -0
  126. package/dist/types/src/testing/index.d.ts.map +1 -0
  127. package/dist/types/src/testing/withPluginManager.d.ts +10 -0
  128. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
  129. package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
  130. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
  131. package/dist/types/tsconfig.tsbuildinfo +1 -0
  132. package/package.json +31 -14
  133. package/project.json +2 -1
  134. package/src/App.tsx +138 -34
  135. package/src/common/capabilities.ts +88 -0
  136. package/src/common/events.ts +63 -0
  137. package/src/common/file.ts +22 -0
  138. package/src/common/graph.ts +30 -0
  139. package/src/{plugins/common → common}/index.ts +3 -1
  140. package/src/common/layout.ts +157 -0
  141. package/src/{plugins/common → common}/navigation.ts +69 -50
  142. package/src/common/surface.ts +81 -0
  143. package/src/common/translations.ts +18 -0
  144. package/src/core/capabilities.test.ts +116 -0
  145. package/src/core/capabilities.ts +213 -0
  146. package/src/core/events.ts +58 -0
  147. package/src/core/index.ts +8 -0
  148. package/src/core/manager.test.ts +567 -0
  149. package/src/core/manager.ts +497 -0
  150. package/src/core/plugin.ts +128 -0
  151. package/src/helpers.test.ts +97 -0
  152. package/src/helpers.ts +45 -0
  153. package/src/index.ts +6 -3
  154. package/src/playground/debug/Debug.tsx +39 -0
  155. package/src/playground/debug/index.ts +5 -0
  156. package/src/playground/debug/plugin.ts +17 -0
  157. package/src/playground/generator/Main.tsx +71 -0
  158. package/src/playground/generator/Toolbar.tsx +46 -0
  159. package/src/playground/generator/generator.ts +23 -0
  160. package/src/playground/generator/index.ts +6 -0
  161. package/src/playground/generator/plugin.ts +18 -0
  162. package/src/playground/layout/Layout.tsx +33 -0
  163. package/src/playground/layout/index.ts +5 -0
  164. package/src/playground/layout/plugin.ts +17 -0
  165. package/src/playground/logger/Toolbar.tsx +28 -0
  166. package/src/playground/logger/index.ts +5 -0
  167. package/src/playground/logger/plugin.ts +33 -0
  168. package/src/playground/logger/schema.ts +12 -0
  169. package/src/playground/playground.stories.tsx +34 -0
  170. package/src/plugin-intent/IntentContext.tsx +34 -0
  171. package/src/plugin-intent/IntentPlugin.tsx +60 -0
  172. package/src/plugin-intent/actions.ts +22 -0
  173. package/src/plugin-intent/errors.ts +39 -0
  174. package/src/plugin-intent/index.ts +9 -0
  175. package/src/plugin-intent/intent-dispatcher.test.ts +280 -0
  176. package/src/plugin-intent/intent-dispatcher.ts +269 -0
  177. package/src/plugin-intent/intent.ts +146 -0
  178. package/src/plugin-settings/SettingsPlugin.ts +29 -0
  179. package/src/plugin-settings/actions.ts +17 -0
  180. package/src/plugin-settings/index.ts +6 -0
  181. package/src/react/PluginManagerProvider.ts +22 -0
  182. package/src/react/Surface.tsx +72 -0
  183. package/src/react/index.ts +8 -0
  184. package/src/react/useCapabilities.ts +40 -0
  185. package/src/testing/index.ts +5 -0
  186. package/src/testing/withPluginManager.stories.tsx +47 -0
  187. package/src/testing/withPluginManager.tsx +67 -0
  188. package/tsconfig.json +54 -2
  189. package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
  190. package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
  191. package/dist/lib/browser/chunk-653Y45CL.mjs +0 -41
  192. package/dist/lib/browser/chunk-653Y45CL.mjs.map +0 -7
  193. package/dist/lib/browser/chunk-FRXJ25VI.mjs +0 -214
  194. package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +0 -7
  195. package/dist/lib/browser/chunk-YXM35XRE.mjs +0 -213
  196. package/dist/lib/browser/chunk-YXM35XRE.mjs.map +0 -7
  197. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs +0 -22
  198. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs.map +0 -7
  199. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +0 -11
  200. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs.map +0 -7
  201. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs +0 -24
  202. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs.map +0 -7
  203. package/dist/lib/node/chunk-JZ2JVKRY.cjs +0 -58
  204. package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +0 -7
  205. package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
  206. package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
  207. package/dist/lib/node/chunk-QSVP5HOW.cjs +0 -238
  208. package/dist/lib/node/chunk-QSVP5HOW.cjs.map +0 -7
  209. package/dist/lib/node/chunk-SOVLKUWI.cjs +0 -236
  210. package/dist/lib/node/chunk-SOVLKUWI.cjs.map +0 -7
  211. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs +0 -43
  212. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs.map +0 -7
  213. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs +0 -32
  214. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +0 -7
  215. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs +0 -45
  216. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs.map +0 -7
  217. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs +0 -215
  218. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs.map +0 -7
  219. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
  220. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
  221. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs +0 -214
  222. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs.map +0 -7
  223. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +0 -43
  224. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +0 -7
  225. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs +0 -23
  226. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs.map +0 -7
  227. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +0 -12
  228. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +0 -7
  229. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs +0 -25
  230. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs.map +0 -7
  231. package/dist/types/src/plugins/common/file.d.ts +0 -22
  232. package/dist/types/src/plugins/common/file.d.ts.map +0 -1
  233. package/dist/types/src/plugins/common/graph.d.ts +0 -51
  234. package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
  235. package/dist/types/src/plugins/common/index.d.ts.map +0 -1
  236. package/dist/types/src/plugins/common/layout.d.ts +0 -202
  237. package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
  238. package/dist/types/src/plugins/common/metadata.d.ts +0 -16
  239. package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
  240. package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
  241. package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
  242. package/dist/types/src/plugins/helpers.d.ts +0 -41
  243. package/dist/types/src/plugins/helpers.d.ts.map +0 -1
  244. package/dist/types/src/plugins/index.d.ts +0 -7
  245. package/dist/types/src/plugins/index.d.ts.map +0 -1
  246. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -21
  247. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
  248. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
  249. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
  250. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
  251. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
  252. package/dist/types/src/plugins/plugin-host/index.d.ts +0 -4
  253. package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
  254. package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -98
  255. package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
  256. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
  257. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
  258. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts +0 -21
  259. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
  260. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
  261. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
  262. package/dist/types/src/plugins/plugin-intent/helpers.d.ts +0 -6
  263. package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +0 -1
  264. package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -6
  265. package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
  266. package/dist/types/src/plugins/plugin-intent/intent.d.ts +0 -81
  267. package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
  268. package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -5
  269. package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
  270. package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -20
  271. package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
  272. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
  273. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  274. package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
  275. package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
  276. package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
  277. package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
  278. package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -13
  279. package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
  280. package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
  281. package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -62
  282. package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
  283. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
  284. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
  285. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts +0 -39
  286. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +0 -1
  287. package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
  288. package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
  289. package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
  290. package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
  291. package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
  292. package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
  293. package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -16
  294. package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
  295. package/src/plugins/common/file.ts +0 -36
  296. package/src/plugins/common/graph.ts +0 -70
  297. package/src/plugins/common/layout.ts +0 -155
  298. package/src/plugins/common/metadata.ts +0 -29
  299. package/src/plugins/common/translations.ts +0 -36
  300. package/src/plugins/helpers.ts +0 -92
  301. package/src/plugins/index.ts +0 -11
  302. package/src/plugins/plugin-host/HostPlugin.tsx +0 -96
  303. package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
  304. package/src/plugins/plugin-host/PluginContext.tsx +0 -79
  305. package/src/plugins/plugin-host/index.ts +0 -8
  306. package/src/plugins/plugin-host/plugin.test.ts +0 -158
  307. package/src/plugins/plugin-host/plugin.ts +0 -126
  308. package/src/plugins/plugin-intent/IntentContext.tsx +0 -49
  309. package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -151
  310. package/src/plugins/plugin-intent/helpers.ts +0 -11
  311. package/src/plugins/plugin-intent/index.ts +0 -12
  312. package/src/plugins/plugin-intent/intent.ts +0 -101
  313. package/src/plugins/plugin-intent/meta.ts +0 -9
  314. package/src/plugins/plugin-intent/provides.ts +0 -38
  315. package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
  316. package/src/plugins/plugin-settings/index.ts +0 -9
  317. package/src/plugins/plugin-settings/meta.ts +0 -9
  318. package/src/plugins/plugin-settings/provides.ts +0 -29
  319. package/src/plugins/plugin-surface/Surface.tsx +0 -195
  320. package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -33
  321. package/src/plugins/plugin-surface/SurfaceRootContext.tsx +0 -60
  322. package/src/plugins/plugin-surface/helpers.ts +0 -22
  323. package/src/plugins/plugin-surface/index.ts +0 -14
  324. package/src/plugins/plugin-surface/meta.ts +0 -9
  325. package/src/plugins/plugin-surface/provides.ts +0 -26
  326. /package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
  327. /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
@@ -0,0 +1,1665 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_7PNEFY2G_exports = {};
30
+ __export(chunk_7PNEFY2G_exports, {
31
+ ActiveParts: () => ActiveParts,
32
+ Capabilities: () => Capabilities,
33
+ ErrorBoundary: () => ErrorBoundary,
34
+ Events: () => Events,
35
+ FileInfoSchema: () => FileInfoSchema,
36
+ INTENT_ACTION: () => INTENT_ACTION,
37
+ INTENT_PLUGIN: () => INTENT_PLUGIN,
38
+ IntentAction: () => IntentAction,
39
+ IntentPlugin: () => IntentPlugin,
40
+ IntentProvider: () => IntentProvider,
41
+ LAYOUT_ACTION: () => LAYOUT_ACTION,
42
+ LAYOUT_PLUGIN: () => LAYOUT_PLUGIN,
43
+ Label: () => Label,
44
+ Layout: () => Layout,
45
+ LayoutAction: () => LayoutAction,
46
+ NAVIGATION_ACTION: () => NAVIGATION_ACTION,
47
+ NAVIGATION_PLUGIN: () => NAVIGATION_PLUGIN,
48
+ NavigationAction: () => NavigationAction,
49
+ Plugin: () => Plugin,
50
+ PluginManager: () => PluginManager,
51
+ PluginManagerProvider: () => PluginManagerProvider,
52
+ PluginModule: () => PluginModule,
53
+ PluginsContext: () => PluginsContext,
54
+ Resource: () => Resource,
55
+ ResourceKey: () => ResourceKey,
56
+ ResourceLanguage: () => ResourceLanguage,
57
+ SLUG_COLLECTION_INDICATOR: () => SLUG_COLLECTION_INDICATOR,
58
+ SLUG_ENTRY_SEPARATOR: () => SLUG_ENTRY_SEPARATOR,
59
+ SLUG_KEY_VALUE_SEPARATOR: () => SLUG_KEY_VALUE_SEPARATOR,
60
+ SLUG_LIST_SEPARATOR: () => SLUG_LIST_SEPARATOR,
61
+ SLUG_PATH_SEPARATOR: () => SLUG_PATH_SEPARATOR,
62
+ Surface: () => Surface,
63
+ Toast: () => Toast,
64
+ allOf: () => allOf,
65
+ chain: () => chain,
66
+ contributes: () => contributes,
67
+ createApp: () => createApp,
68
+ createDispatcher: () => createDispatcher,
69
+ createIntent: () => createIntent,
70
+ createResolver: () => createResolver,
71
+ createSurface: () => createSurface,
72
+ defaultFileTypes: () => defaultFileTypes,
73
+ defineCapability: () => defineCapability,
74
+ defineEvent: () => defineEvent,
75
+ defineModule: () => defineModule,
76
+ definePlugin: () => definePlugin,
77
+ eventKey: () => eventKey,
78
+ firstIdInPart: () => firstIdInPart,
79
+ getEvents: () => getEvents,
80
+ indexInPart: () => indexInPart,
81
+ isAllOf: () => isAllOf,
82
+ isLayoutAdjustment: () => isLayoutAdjustment,
83
+ isLayoutMode: () => isLayoutMode,
84
+ isLayoutParts: () => isLayoutParts,
85
+ isOneOf: () => isOneOf,
86
+ isSurfaceAvailable: () => isSurfaceAvailable,
87
+ lazy: () => lazy,
88
+ oneOf: () => oneOf,
89
+ openIds: () => openIds,
90
+ partLength: () => partLength,
91
+ useCapabilities: () => useCapabilities,
92
+ useCapability: () => useCapability,
93
+ useIntentDispatcher: () => useIntentDispatcher,
94
+ useIntentResolver: () => useIntentResolver,
95
+ usePluginManager: () => usePluginManager
96
+ });
97
+ module.exports = __toCommonJS(chunk_7PNEFY2G_exports);
98
+ var import_signals_core = require("@preact/signals-core");
99
+ var import_async = require("@dxos/async");
100
+ var import_invariant = require("@dxos/invariant");
101
+ var import_live_object = require("@dxos/live-object");
102
+ var import_log = require("@dxos/log");
103
+ var import_signals_core2 = require("@preact/signals-core");
104
+ var import_effect = require("effect");
105
+ var import_async2 = require("@dxos/async");
106
+ var import_live_object2 = require("@dxos/live-object");
107
+ var import_log2 = require("@dxos/log");
108
+ var import_echo_schema = require("@dxos/echo-schema");
109
+ var import_echo_schema2 = require("@dxos/echo-schema");
110
+ var import_echo_schema3 = require("@dxos/echo-schema");
111
+ var import_effect2 = require("effect");
112
+ var import_util = require("@dxos/util");
113
+ var import_react = __toESM(require("react"));
114
+ var import_react2 = require("react");
115
+ var import_debug = require("@dxos/debug");
116
+ var import_signals_core3 = require("@preact/signals-core");
117
+ var import_react3 = require("react");
118
+ var import_react4 = __toESM(require("react"));
119
+ var import_react_hooks = require("@dxos/react-hooks");
120
+ var import_util2 = require("@dxos/util");
121
+ var import_echo_schema4 = require("@dxos/echo-schema");
122
+ var import_react5 = require("react");
123
+ var import_debug2 = require("@dxos/debug");
124
+ var import_util3 = require("@dxos/util");
125
+ var import_effect3 = require("effect");
126
+ var import_react6 = __toESM(require("react"));
127
+ var import_live_object3 = require("@dxos/live-object");
128
+ var import_schema = require("@effect/schema");
129
+ var import_util4 = require("@dxos/util");
130
+ var import_zod = require("zod");
131
+ var import_signals_core4 = require("@preact/signals-core");
132
+ var import_react7 = __toESM(require("react"));
133
+ var import_invariant2 = require("@dxos/invariant");
134
+ var import_live_object4 = require("@dxos/live-object");
135
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
136
+ var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
137
+ var defineCapability = (identifier) => {
138
+ return {
139
+ identifier
140
+ };
141
+ };
142
+ var CapabilityImpl = class {
143
+ constructor(moduleId, implementation) {
144
+ this.moduleId = moduleId;
145
+ this.implementation = implementation;
146
+ }
147
+ };
148
+ var contributes = (interfaceDef, implementation, deactivate) => {
149
+ return {
150
+ interface: interfaceDef,
151
+ implementation,
152
+ deactivate
153
+ };
154
+ };
155
+ var lazy = (c) => (props) => c().then(({ default: getCapability }) => {
156
+ return getCapability(props);
157
+ });
158
+ var PluginsContext = class {
159
+ constructor({ activate, reset }) {
160
+ this._definedCapabilities = /* @__PURE__ */ new Map();
161
+ this.activate = activate;
162
+ this.reset = reset;
163
+ }
164
+ /**
165
+ * @internal
166
+ */
167
+ contributeCapability({ module: moduleId, interface: interfaceDef, implementation }) {
168
+ let current = this._definedCapabilities.get(interfaceDef.identifier);
169
+ if (!current) {
170
+ const object = (0, import_live_object.create)({
171
+ value: []
172
+ });
173
+ current = (0, import_signals_core.untracked)(() => object.value);
174
+ this._definedCapabilities.set(interfaceDef.identifier, current);
175
+ }
176
+ current.push(new CapabilityImpl(moduleId, implementation));
177
+ (0, import_log.log)("capability contributed", {
178
+ id: interfaceDef.identifier,
179
+ count: (0, import_signals_core.untracked)(() => current.length)
180
+ }, {
181
+ F: __dxlog_file,
182
+ L: 139,
183
+ S: this,
184
+ C: (f, a) => f(...a)
185
+ });
186
+ }
187
+ /**
188
+ * @internal
189
+ */
190
+ removeCapability(interfaceDef, implementation) {
191
+ const current = this._definedCapabilities.get(interfaceDef.identifier);
192
+ if (!current) {
193
+ return;
194
+ }
195
+ const index = current.findIndex((i) => i.implementation === implementation);
196
+ if (index !== -1) {
197
+ current.splice(index, 1);
198
+ (0, import_log.log)("capability removed", {
199
+ id: interfaceDef.identifier,
200
+ count: (0, import_signals_core.untracked)(() => current.length)
201
+ }, {
202
+ F: __dxlog_file,
203
+ L: 154,
204
+ S: this,
205
+ C: (f, a) => f(...a)
206
+ });
207
+ }
208
+ }
209
+ /**
210
+ * Requests capabilities from the plugin context.
211
+ * @returns An array of capabilities.
212
+ * @reactive
213
+ */
214
+ requestCapabilities(interfaceDef, filter) {
215
+ let current = this._definedCapabilities.get(interfaceDef.identifier);
216
+ if (!current) {
217
+ const object = (0, import_live_object.create)({
218
+ value: []
219
+ });
220
+ current = (0, import_signals_core.untracked)(() => object.value);
221
+ this._definedCapabilities.set(interfaceDef.identifier, current);
222
+ }
223
+ const capabilities = filter ? current.filter((c) => filter(c.implementation, c.moduleId)) : current;
224
+ return capabilities.map((c) => c.implementation);
225
+ }
226
+ /**
227
+ * Requests a single capability from the plugin context.
228
+ * @returns The capability.
229
+ * @throws If no capability is found.
230
+ * @reactive
231
+ */
232
+ requestCapability(interfaceDef, filter) {
233
+ const capability = this.requestCapabilities(interfaceDef, filter)[0];
234
+ (0, import_invariant.invariant)(capability, `No capability found for ${interfaceDef.identifier}`, {
235
+ F: __dxlog_file,
236
+ L: 190,
237
+ S: this,
238
+ A: [
239
+ "capability",
240
+ "`No capability found for ${interfaceDef.identifier}`"
241
+ ]
242
+ });
243
+ return capability;
244
+ }
245
+ /**
246
+ * Waits for a capability to be contributed.
247
+ * @returns The capability.
248
+ */
249
+ async waitForCapability(interfaceDef, filter) {
250
+ const trigger = new import_async.Trigger();
251
+ const unsubscribe = (0, import_signals_core.effect)(() => {
252
+ const capabilities = this.requestCapabilities(interfaceDef, filter);
253
+ if (capabilities[0]) {
254
+ trigger.wake(capabilities[0]);
255
+ }
256
+ });
257
+ const capability = await trigger.wait();
258
+ unsubscribe();
259
+ return capability;
260
+ }
261
+ };
262
+ var defineEvent = (id, specifier) => {
263
+ return {
264
+ id,
265
+ specifier
266
+ };
267
+ };
268
+ var eventKey = (event) => event.specifier ? `${event.id}:${event.specifier}` : event.id;
269
+ var oneOf = (...events) => ({
270
+ type: "one-of",
271
+ events
272
+ });
273
+ var allOf = (...events) => ({
274
+ type: "all-of",
275
+ events
276
+ });
277
+ var isOneOf = (events) => "type" in events && events.type === "one-of";
278
+ var isAllOf = (events) => "type" in events && events.type === "all-of";
279
+ var getEvents = (events) => "type" in events ? events.events : [
280
+ events
281
+ ];
282
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
283
+ var isPromise = (value) => {
284
+ return value !== null && typeof value === "object" && "then" in value;
285
+ };
286
+ var PluginManager = class {
287
+ constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [] }) {
288
+ this.activation = new import_async2.Event();
289
+ this.context = new PluginsContext({
290
+ activate: (event) => this.activate(event),
291
+ reset: (id) => this.reset(id)
292
+ });
293
+ this._capabilities = /* @__PURE__ */ new Map();
294
+ this._pluginLoader = pluginLoader;
295
+ this._state = (0, import_live_object2.create)({
296
+ plugins,
297
+ core,
298
+ enabled,
299
+ modules: [],
300
+ active: [],
301
+ pendingRemoval: [],
302
+ pendingReset: [],
303
+ eventsFired: []
304
+ });
305
+ plugins.forEach((plugin) => this._addPlugin(plugin));
306
+ core.forEach((id) => this.enable(id));
307
+ enabled.forEach((id) => this.enable(id));
308
+ }
309
+ /**
310
+ * Plugins that are currently registered.
311
+ *
312
+ * @reactive
313
+ */
314
+ get plugins() {
315
+ return this._state.plugins;
316
+ }
317
+ /**
318
+ * Ids of plugins that are core and cannot be removed.
319
+ *
320
+ * @reactive
321
+ */
322
+ get core() {
323
+ return this._state.core;
324
+ }
325
+ /**
326
+ * Ids of plugins that are currently enabled.
327
+ *
328
+ * @reactive
329
+ */
330
+ get enabled() {
331
+ return this._state.enabled;
332
+ }
333
+ /**
334
+ * Modules of plugins which are currently enabled.
335
+ *
336
+ * @reactive
337
+ */
338
+ get modules() {
339
+ return this._state.modules;
340
+ }
341
+ /**
342
+ * Ids of modules which are currently active.
343
+ *
344
+ * @reactive
345
+ */
346
+ get active() {
347
+ return this._state.active;
348
+ }
349
+ /**
350
+ * Ids of modules which are pending removal.
351
+ *
352
+ * @reactive
353
+ */
354
+ get pendingRemoval() {
355
+ return this._state.pendingRemoval;
356
+ }
357
+ /**
358
+ * Ids of events which have been fired.
359
+ *
360
+ * @reactive
361
+ */
362
+ get eventsFired() {
363
+ return this._state.eventsFired;
364
+ }
365
+ /**
366
+ * Ids of modules which are pending reset.
367
+ *
368
+ * @reactive
369
+ */
370
+ get pendingReset() {
371
+ return this._state.pendingReset;
372
+ }
373
+ /**
374
+ * Adds a plugin to the manager via the plugin loader.
375
+ * @param id The id of the plugin.
376
+ */
377
+ async add(id) {
378
+ return (0, import_signals_core2.untracked)(async () => {
379
+ (0, import_log2.log)("add plugin", {
380
+ id
381
+ }, {
382
+ F: __dxlog_file2,
383
+ L: 157,
384
+ S: this,
385
+ C: (f, a) => f(...a)
386
+ });
387
+ const plugin = await this._pluginLoader(id);
388
+ this._addPlugin(plugin);
389
+ return this.enable(id);
390
+ });
391
+ }
392
+ /**
393
+ * Enables a plugin.
394
+ * @param id The id of the plugin.
395
+ */
396
+ enable(id) {
397
+ return (0, import_signals_core2.untracked)(() => {
398
+ (0, import_log2.log)("enable plugin", {
399
+ id
400
+ }, {
401
+ F: __dxlog_file2,
402
+ L: 170,
403
+ S: this,
404
+ C: (f, a) => f(...a)
405
+ });
406
+ const plugin = this._getPlugin(id);
407
+ if (!plugin) {
408
+ return false;
409
+ }
410
+ if (!this._state.enabled.includes(id)) {
411
+ this._state.enabled.push(id);
412
+ }
413
+ plugin.modules.forEach((module2) => {
414
+ this._addModule(module2);
415
+ this._setPendingResetByModule(module2);
416
+ });
417
+ return true;
418
+ });
419
+ }
420
+ /**
421
+ * Removes a plugin from the manager.
422
+ * @param id The id of the plugin.
423
+ */
424
+ remove(id) {
425
+ return (0, import_signals_core2.untracked)(() => {
426
+ (0, import_log2.log)("remove plugin", {
427
+ id
428
+ }, {
429
+ F: __dxlog_file2,
430
+ L: 194,
431
+ S: this,
432
+ C: (f, a) => f(...a)
433
+ });
434
+ const result = this.disable(id);
435
+ if (!result) {
436
+ return false;
437
+ }
438
+ this._removePlugin(id);
439
+ return true;
440
+ });
441
+ }
442
+ /**
443
+ * Disables a plugin.
444
+ * @param id The id of the plugin.
445
+ */
446
+ disable(id) {
447
+ return (0, import_signals_core2.untracked)(() => {
448
+ (0, import_log2.log)("disable plugin", {
449
+ id
450
+ }, {
451
+ F: __dxlog_file2,
452
+ L: 211,
453
+ S: this,
454
+ C: (f, a) => f(...a)
455
+ });
456
+ if (this._state.core.includes(id)) {
457
+ return false;
458
+ }
459
+ const plugin = this._getPlugin(id);
460
+ if (!plugin) {
461
+ return false;
462
+ }
463
+ const enabledIndex = this._state.enabled.findIndex((enabled) => enabled === id);
464
+ if (enabledIndex !== -1) {
465
+ this._state.enabled.splice(enabledIndex, 1);
466
+ plugin.modules.forEach((module2) => {
467
+ if (this._state.active.includes(module2.id)) {
468
+ this._setPendingResetByModule(module2);
469
+ if (!this._state.pendingRemoval.includes(module2.id)) {
470
+ this._state.pendingRemoval.push(module2.id);
471
+ }
472
+ } else {
473
+ this._removeModule(module2.id);
474
+ }
475
+ });
476
+ }
477
+ return true;
478
+ });
479
+ }
480
+ /**
481
+ * Activates plugins based on the activation event.
482
+ * @param event The activation event.
483
+ * @returns Whether the activation was successful.
484
+ */
485
+ activate(event) {
486
+ return (0, import_signals_core2.untracked)(() => import_effect.Effect.runPromise(this._activate(event)));
487
+ }
488
+ /**
489
+ * Deactivates all of the modules for a plugin.
490
+ * @param id The id of the plugin.
491
+ * @returns Whether the deactivation was successful.
492
+ */
493
+ deactivate(id) {
494
+ return (0, import_signals_core2.untracked)(() => import_effect.Effect.runPromise(this._deactivate(id)));
495
+ }
496
+ /**
497
+ * Re-activates the modules that were activated by the event.
498
+ * @param event The activation event.
499
+ * @returns Whether the reset was successful.
500
+ */
501
+ reset(event) {
502
+ return (0, import_signals_core2.untracked)(() => import_effect.Effect.runPromise(this._reset(event)));
503
+ }
504
+ _addPlugin(plugin) {
505
+ (0, import_signals_core2.untracked)(() => {
506
+ (0, import_log2.log)("add plugin", {
507
+ id: plugin.meta.id
508
+ }, {
509
+ F: __dxlog_file2,
510
+ L: 270,
511
+ S: this,
512
+ C: (f, a) => f(...a)
513
+ });
514
+ if (!this._state.plugins.includes(plugin)) {
515
+ this._state.plugins.push(plugin);
516
+ }
517
+ });
518
+ }
519
+ _removePlugin(id) {
520
+ (0, import_signals_core2.untracked)(() => {
521
+ (0, import_log2.log)("remove plugin", {
522
+ id
523
+ }, {
524
+ F: __dxlog_file2,
525
+ L: 279,
526
+ S: this,
527
+ C: (f, a) => f(...a)
528
+ });
529
+ const pluginIndex = this._state.plugins.findIndex((plugin) => plugin.meta.id === id);
530
+ if (pluginIndex !== -1) {
531
+ this._state.plugins.splice(pluginIndex, 1);
532
+ }
533
+ });
534
+ }
535
+ _addModule(module2) {
536
+ (0, import_signals_core2.untracked)(() => {
537
+ (0, import_log2.log)("add module", {
538
+ id: module2.id
539
+ }, {
540
+ F: __dxlog_file2,
541
+ L: 289,
542
+ S: this,
543
+ C: (f, a) => f(...a)
544
+ });
545
+ if (!this._state.modules.includes(module2)) {
546
+ this._state.modules.push(module2);
547
+ }
548
+ });
549
+ }
550
+ _removeModule(id) {
551
+ (0, import_signals_core2.untracked)(() => {
552
+ (0, import_log2.log)("remove module", {
553
+ id
554
+ }, {
555
+ F: __dxlog_file2,
556
+ L: 298,
557
+ S: this,
558
+ C: (f, a) => f(...a)
559
+ });
560
+ const moduleIndex = this._state.modules.findIndex((module2) => module2.id === id);
561
+ if (moduleIndex !== -1) {
562
+ this._state.modules.splice(moduleIndex, 1);
563
+ }
564
+ });
565
+ }
566
+ _getPlugin(id) {
567
+ return this._state.plugins.find((plugin) => plugin.meta.id === id);
568
+ }
569
+ _getActiveModules() {
570
+ return this._state.modules.filter((module2) => this._state.active.includes(module2.id));
571
+ }
572
+ _getInactiveModules() {
573
+ return this._state.modules.filter((module2) => !this._state.active.includes(module2.id));
574
+ }
575
+ _getActiveModulesByEvent(key) {
576
+ return this._getActiveModules().filter((module2) => getEvents(module2.activatesOn).map(eventKey).includes(key));
577
+ }
578
+ _getInactiveModulesByEvent(key) {
579
+ return this._getInactiveModules().filter((module2) => getEvents(module2.activatesOn).map(eventKey).includes(key));
580
+ }
581
+ _setPendingResetByModule(module2) {
582
+ return (0, import_signals_core2.untracked)(() => {
583
+ const activationEvents = getEvents(module2.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
584
+ const parentEvents = activationEvents.flatMap((event) => {
585
+ const modules = this._getActiveModules().filter((module22) => module22.activatesBefore?.map(eventKey).includes(event));
586
+ return modules.flatMap((module22) => getEvents(module22.activatesOn)).map(eventKey);
587
+ });
588
+ const pendingReset = Array.from(/* @__PURE__ */ new Set([
589
+ ...activationEvents,
590
+ ...parentEvents
591
+ ])).filter((event) => !this._state.pendingReset.includes(event));
592
+ if (pendingReset.length > 0) {
593
+ (0, import_log2.log)("pending reset", {
594
+ events: pendingReset
595
+ }, {
596
+ F: __dxlog_file2,
597
+ L: 342,
598
+ S: this,
599
+ C: (f, a) => f(...a)
600
+ });
601
+ this._state.pendingReset.push(...pendingReset);
602
+ }
603
+ });
604
+ }
605
+ // TODO(wittjosiah): Improve error typing.
606
+ _activate(event) {
607
+ const self = this;
608
+ return import_effect.Effect.gen(function* () {
609
+ const key = typeof event === "string" ? event : eventKey(event);
610
+ (0, import_log2.log)("activating", {
611
+ key
612
+ }, {
613
+ F: __dxlog_file2,
614
+ L: 353,
615
+ S: this,
616
+ C: (f, a) => f(...a)
617
+ });
618
+ const pendingIndex = self._state.pendingReset.findIndex((event2) => event2 === key);
619
+ if (pendingIndex !== -1) {
620
+ self._state.pendingReset.splice(pendingIndex, 1);
621
+ }
622
+ const modules = self._getInactiveModulesByEvent(key);
623
+ if (modules.length === 0) {
624
+ (0, import_log2.log)("no modules to activate", {
625
+ key
626
+ }, {
627
+ F: __dxlog_file2,
628
+ L: 361,
629
+ S: this,
630
+ C: (f, a) => f(...a)
631
+ });
632
+ return false;
633
+ }
634
+ self.activation.emit({
635
+ event: key,
636
+ state: "activating"
637
+ });
638
+ for (const module2 of modules) {
639
+ if (isAllOf(module2.activatesOn) && !module2.activatesOn.events.filter((event2) => eventKey(event2) !== key).every((event2) => self._state.eventsFired.includes(eventKey(event2)))) {
640
+ continue;
641
+ }
642
+ yield* import_effect.Effect.all(module2.activatesBefore?.map((event2) => self._activate(event2)) ?? []);
643
+ const result = yield* self._activateModule(module2).pipe(import_effect.Effect.either);
644
+ if (import_effect.Either.isLeft(result)) {
645
+ self.activation.emit({
646
+ event: key,
647
+ state: "error",
648
+ error: result.left
649
+ });
650
+ yield* import_effect.Effect.fail(result.left);
651
+ }
652
+ yield* import_effect.Effect.all(module2.activatesAfter?.map((event2) => self._activate(event2)) ?? []);
653
+ }
654
+ if (!self._state.eventsFired.includes(key)) {
655
+ self._state.eventsFired.push(key);
656
+ }
657
+ self.activation.emit({
658
+ event: key,
659
+ state: "activated"
660
+ });
661
+ (0, import_log2.log)("activated", {
662
+ key
663
+ }, {
664
+ F: __dxlog_file2,
665
+ L: 393,
666
+ S: this,
667
+ C: (f, a) => f(...a)
668
+ });
669
+ return true;
670
+ });
671
+ }
672
+ _activateModule(module2) {
673
+ const self = this;
674
+ return import_effect.Effect.gen(function* () {
675
+ const program = module2.activate(self.context);
676
+ const maybeCapabilities = yield* import_effect.Match.value(program).pipe(import_effect.Match.when(import_effect.Effect.isEffect, (effect3) => effect3), import_effect.Match.when(isPromise, (promise) => import_effect.Effect.tryPromise({
677
+ try: () => promise,
678
+ catch: (error) => error
679
+ })), import_effect.Match.orElse((program2) => import_effect.Effect.succeed(program2)));
680
+ const capabilities = import_effect.Match.value(maybeCapabilities).pipe(import_effect.Match.when(Array.isArray, (array) => array), import_effect.Match.orElse((value) => [
681
+ value
682
+ ]));
683
+ capabilities.forEach((capability) => {
684
+ self.context.contributeCapability({
685
+ module: module2.id,
686
+ ...capability
687
+ });
688
+ });
689
+ self._state.active.push(module2.id);
690
+ self._capabilities.set(module2.id, capabilities);
691
+ });
692
+ }
693
+ _deactivate(id) {
694
+ const self = this;
695
+ return import_effect.Effect.gen(function* () {
696
+ const plugin = self._getPlugin(id);
697
+ if (!plugin) {
698
+ return false;
699
+ }
700
+ const modules = plugin.modules;
701
+ const results = yield* import_effect.Effect.all(modules.map((module2) => self._deactivateModule(module2)));
702
+ return results.every((result) => result);
703
+ });
704
+ }
705
+ _deactivateModule(module2) {
706
+ const self = this;
707
+ return import_effect.Effect.gen(function* () {
708
+ const id = module2.id;
709
+ (0, import_log2.log)("deactivating", {
710
+ id
711
+ }, {
712
+ F: __dxlog_file2,
713
+ L: 444,
714
+ S: this,
715
+ C: (f, a) => f(...a)
716
+ });
717
+ const capabilities = self._capabilities.get(id);
718
+ if (capabilities) {
719
+ for (const capability of capabilities) {
720
+ self.context.removeCapability(capability.interface, capability.implementation);
721
+ const program = capability.deactivate?.();
722
+ yield* import_effect.Match.value(program).pipe(import_effect.Match.when(import_effect.Effect.isEffect, (effect3) => effect3), import_effect.Match.when(isPromise, (promise) => import_effect.Effect.tryPromise({
723
+ try: () => promise,
724
+ catch: (error) => error
725
+ })), import_effect.Match.orElse((program2) => import_effect.Effect.succeed(program2)));
726
+ }
727
+ self._capabilities.delete(id);
728
+ }
729
+ const activeIndex = self._state.active.findIndex((event) => event === id);
730
+ if (activeIndex !== -1) {
731
+ self._state.active.splice(activeIndex, 1);
732
+ }
733
+ (0, import_log2.log)("deactivated", {
734
+ id
735
+ }, {
736
+ F: __dxlog_file2,
737
+ L: 470,
738
+ S: this,
739
+ C: (f, a) => f(...a)
740
+ });
741
+ return true;
742
+ });
743
+ }
744
+ _reset(event) {
745
+ const self = this;
746
+ return import_effect.Effect.gen(function* () {
747
+ const key = typeof event === "string" ? event : eventKey(event);
748
+ (0, import_log2.log)("reset", {
749
+ key
750
+ }, {
751
+ F: __dxlog_file2,
752
+ L: 479,
753
+ S: this,
754
+ C: (f, a) => f(...a)
755
+ });
756
+ const modules = self._getActiveModulesByEvent(key);
757
+ const results = yield* import_effect.Effect.all(modules.map((module2) => self._deactivateModule(module2)));
758
+ if (self._state.pendingRemoval.length > 0) {
759
+ self._state.pendingRemoval.forEach((id) => {
760
+ self._removeModule(id);
761
+ });
762
+ self._state.pendingRemoval.splice(0, self._state.pendingRemoval.length);
763
+ }
764
+ if (results.every((result) => result)) {
765
+ return yield* self._activate(key);
766
+ } else {
767
+ return false;
768
+ }
769
+ });
770
+ }
771
+ };
772
+ var PluginModule = class {
773
+ constructor(options) {
774
+ this.id = options.id;
775
+ this.activatesOn = options.activatesOn;
776
+ this.activatesBefore = options.activatesBefore;
777
+ this.activatesAfter = options.activatesAfter;
778
+ this.activate = options.activate;
779
+ }
780
+ };
781
+ var defineModule = (options) => new PluginModule(options);
782
+ var Plugin = class {
783
+ constructor(meta, modules) {
784
+ this.meta = meta;
785
+ this.modules = modules;
786
+ }
787
+ };
788
+ var definePlugin = (meta, modules) => {
789
+ return new Plugin(meta, modules);
790
+ };
791
+ var Capabilities;
792
+ (function(Capabilities2) {
793
+ Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
794
+ Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
795
+ Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
796
+ Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
797
+ Capabilities2.ReactSurface = defineCapability("dxos.org/app-framework/common/react-surface");
798
+ Capabilities2.IntentResolver = defineCapability("dxos.org/app-framework/capability/intent-resolver");
799
+ Capabilities2.IntentDispatcher = defineCapability("dxos.org/app-framework/capability/intent-dispatcher");
800
+ Capabilities2.Layout = defineCapability("dxos.org/app-framework/capability/layout");
801
+ Capabilities2.MutableLayout = defineCapability("dxos.org/app-framework/capability/layout");
802
+ Capabilities2.Location = defineCapability("dxos.org/app-framework/capability/location");
803
+ Capabilities2.MutableLocation = defineCapability("dxos.org/app-framework/capability/location");
804
+ Capabilities2.Translations = defineCapability("dxos.org/app-framework/capability/translations");
805
+ Capabilities2.AppGraph = defineCapability("dxos.org/app-framework/capability/app-graph");
806
+ Capabilities2.AppGraphBuilder = defineCapability("dxos.org/app-framework/capability/app-graph-builder");
807
+ Capabilities2.AppGraphSerializer = defineCapability("dxos.org/app-framework/capability/app-graph-serializer");
808
+ Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
809
+ Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
810
+ Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
811
+ Capabilities2.Tools = defineCapability("dxos.org/app-framework/capability/tools");
812
+ Capabilities2.ArtifactDefinition = defineCapability("dxos.org/app-framework/capability/artifact-definition");
813
+ Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
814
+ })(Capabilities || (Capabilities = {}));
815
+ var Events;
816
+ (function(Events2) {
817
+ Events2.Startup = defineEvent("dxos.org/app-framework/event/startup");
818
+ Events2.SetupIntents = defineEvent("dxos.org/app-framework/event/setup-intents");
819
+ Events2.SetupSettings = defineEvent("dxos.org/app-framework/event/setup-settings");
820
+ Events2.SetupAppGraph = defineEvent("dxos.org/app-framework/event/setup-graph");
821
+ Events2.SetupTranslations = defineEvent("dxos.org/app-framework/event/setup-translations");
822
+ Events2.DispatcherReady = defineEvent("dxos.org/app-framework/event/dispatcher-ready");
823
+ Events2.SettingsReady = defineEvent("dxos.org/app-framework/event/settings-ready");
824
+ Events2.AppGraphReady = defineEvent("dxos.org/app-framework/event/graph-ready");
825
+ Events2.createStateEvent = (specifier) => defineEvent("dxos.org/app-framework/event/state", specifier);
826
+ Events2.LayoutReady = Events2.createStateEvent(Capabilities.Layout.identifier);
827
+ Events2.LocationReady = Events2.createStateEvent(Capabilities.Location.identifier);
828
+ })(Events || (Events = {}));
829
+ var defaultFileTypes = {
830
+ images: [
831
+ "png",
832
+ "jpg",
833
+ "jpeg",
834
+ "gif"
835
+ ],
836
+ media: [
837
+ "mp3",
838
+ "mp4",
839
+ "mov",
840
+ "avi"
841
+ ],
842
+ text: [
843
+ "pdf",
844
+ "txt",
845
+ "md"
846
+ ]
847
+ };
848
+ var FileInfoSchema = import_echo_schema.S.Struct({
849
+ name: import_echo_schema.S.String,
850
+ type: import_echo_schema.S.String,
851
+ url: import_echo_schema.S.optional(import_echo_schema.S.String),
852
+ cid: import_echo_schema.S.optional(import_echo_schema.S.String)
853
+ });
854
+ var createIntent = (schema, data = {}, params = {}) => {
855
+ const _ = import_echo_schema2.S.validateSync(schema.fields.input)(data);
856
+ const intent = {
857
+ ...params,
858
+ _schema: schema,
859
+ action: schema._tag,
860
+ data
861
+ };
862
+ return {
863
+ first: intent,
864
+ last: intent,
865
+ all: [
866
+ intent
867
+ ]
868
+ };
869
+ };
870
+ var chain = (schema, data = {}, params = {}) => (intent) => {
871
+ const intents = "all" in intent ? intent.all : [
872
+ intent
873
+ ];
874
+ const first = intents[0];
875
+ const last = {
876
+ ...params,
877
+ _schema: schema,
878
+ action: schema._tag,
879
+ data
880
+ };
881
+ return {
882
+ first,
883
+ last,
884
+ all: [
885
+ ...intents,
886
+ last
887
+ ]
888
+ };
889
+ };
890
+ var Label = import_echo_schema2.S.Union(import_echo_schema2.S.String, import_echo_schema2.S.mutable(import_echo_schema2.S.Tuple(import_echo_schema2.S.String, import_echo_schema2.S.mutable(import_echo_schema2.S.Struct({
891
+ ns: import_echo_schema2.S.String,
892
+ count: import_echo_schema2.S.optional(import_echo_schema2.S.Number)
893
+ })))));
894
+ var INTENT_PLUGIN = "dxos.org/plugin/intent";
895
+ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
896
+ var IntentAction;
897
+ (function(IntentAction2) {
898
+ class ShowUndo extends import_echo_schema3.S.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
899
+ input: import_echo_schema3.S.Struct({
900
+ message: Label
901
+ }),
902
+ output: import_echo_schema3.S.Void
903
+ }) {
904
+ }
905
+ IntentAction2.ShowUndo = ShowUndo;
906
+ })(IntentAction || (IntentAction = {}));
907
+ var BaseError = class extends Error {
908
+ constructor(code, message, context) {
909
+ super(message ?? code);
910
+ this.code = code;
911
+ this.context = context;
912
+ this.name = code;
913
+ Object.setPrototypeOf(this, new.target.prototype);
914
+ }
915
+ };
916
+ var NoResolversError = class extends BaseError {
917
+ constructor(action) {
918
+ super("NO_RESOLVERS", "No resolvers were found for the action", {
919
+ action
920
+ });
921
+ }
922
+ };
923
+ var CycleDetectedError = class extends BaseError {
924
+ constructor(context) {
925
+ super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
926
+ }
927
+ };
928
+ var EXECUTION_LIMIT = 100;
929
+ var HISTORY_LIMIT = 100;
930
+ var createResolver = (schema, effect3, params = {}) => ({
931
+ action: schema._tag,
932
+ effect: effect3,
933
+ ...params
934
+ });
935
+ var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
936
+ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
937
+ const historyRef = import_effect2.Effect.runSync(import_effect2.Ref.make([]));
938
+ const handleIntent = (intent) => {
939
+ return import_effect2.Effect.gen(function* () {
940
+ const candidates = getResolvers(intent.module).filter((r) => r.action === intent.action).filter((r) => !r.filter || r.filter(intent.data)).toSorted(import_util.byDisposition);
941
+ if (candidates.length === 0) {
942
+ return {
943
+ _intent: intent,
944
+ error: new NoResolversError(intent.action)
945
+ };
946
+ }
947
+ const effect3 = candidates[0].effect(intent.data, intent.undo ?? false);
948
+ const result = import_effect2.Effect.isEffect(effect3) ? yield* effect3 : yield* import_effect2.Effect.promise(async () => effect3);
949
+ return {
950
+ _intent: intent,
951
+ ...result
952
+ };
953
+ });
954
+ };
955
+ const dispatch = (intentChain, depth = 0) => {
956
+ return import_effect2.Effect.gen(function* () {
957
+ if (depth > executionLimit) {
958
+ yield* import_effect2.Effect.fail(new CycleDetectedError());
959
+ }
960
+ const resultsRef = yield* import_effect2.Ref.make([]);
961
+ for (const intent of intentChain.all) {
962
+ const { data: prev } = (yield* resultsRef.get)[0] ?? {};
963
+ const result2 = yield* handleIntent({
964
+ ...intent,
965
+ data: {
966
+ ...intent.data,
967
+ ...prev
968
+ }
969
+ });
970
+ yield* import_effect2.Ref.update(resultsRef, (results2) => [
971
+ result2,
972
+ ...results2
973
+ ]);
974
+ if (result2.intents) {
975
+ for (const intent2 of result2.intents) {
976
+ yield* dispatch(intent2, depth + 1);
977
+ }
978
+ }
979
+ if (result2.error) {
980
+ yield* import_effect2.Effect.fail(result2.error);
981
+ }
982
+ }
983
+ const results = yield* resultsRef.get;
984
+ const result = results[0];
985
+ yield* import_effect2.Ref.update(historyRef, (history) => {
986
+ const next = [
987
+ ...history,
988
+ results
989
+ ];
990
+ if (next.length > historyLimit) {
991
+ next.splice(0, next.length - historyLimit);
992
+ }
993
+ return next;
994
+ });
995
+ if (result.undoable && isUndoable(results)) {
996
+ yield* (0, import_effect2.pipe)(dispatch(createIntent(IntentAction.ShowUndo, {
997
+ message: result.undoable.message
998
+ })), import_effect2.Effect.catchSome((err) => err instanceof NoResolversError ? import_effect2.Option.some(import_effect2.Effect.succeed(void 0)) : import_effect2.Option.none()));
999
+ }
1000
+ return result.data;
1001
+ });
1002
+ };
1003
+ const dispatchPromise = (intentChain) => {
1004
+ return import_effect2.Effect.runPromise(dispatch(intentChain)).then((data) => ({
1005
+ data
1006
+ })).catch((error) => ({
1007
+ error
1008
+ }));
1009
+ };
1010
+ const undo = () => {
1011
+ return import_effect2.Effect.gen(function* () {
1012
+ const history = yield* historyRef.get;
1013
+ const last = history.findLastIndex(isUndoable);
1014
+ const result = last !== -1 ? history[last] : void 0;
1015
+ if (result) {
1016
+ const all = result.map(({ _intent, undoable }) => {
1017
+ const data = _intent.data;
1018
+ const undoData = undoable?.data ?? {};
1019
+ return {
1020
+ ..._intent,
1021
+ data: {
1022
+ ...data,
1023
+ ...undoData
1024
+ },
1025
+ undo: true
1026
+ };
1027
+ });
1028
+ const intent = {
1029
+ first: all[0],
1030
+ last: all.at(-1),
1031
+ all
1032
+ };
1033
+ yield* import_effect2.Ref.update(historyRef, (h) => h.filter((_, index) => index !== last));
1034
+ return yield* dispatch(intent);
1035
+ }
1036
+ });
1037
+ };
1038
+ const undoPromise = () => {
1039
+ return import_effect2.Effect.runPromise(undo()).then((data) => ({
1040
+ data
1041
+ })).catch((error) => ({
1042
+ error
1043
+ }));
1044
+ };
1045
+ return {
1046
+ dispatch,
1047
+ dispatchPromise,
1048
+ undo,
1049
+ undoPromise
1050
+ };
1051
+ };
1052
+ var ErrorBoundary = class extends import_react.Component {
1053
+ constructor(props) {
1054
+ super(props);
1055
+ this.state = {
1056
+ error: void 0
1057
+ };
1058
+ }
1059
+ static getDerivedStateFromError(error) {
1060
+ return {
1061
+ error
1062
+ };
1063
+ }
1064
+ componentDidUpdate(prevProps) {
1065
+ if (prevProps.data !== this.props.data) {
1066
+ this.resetError();
1067
+ }
1068
+ }
1069
+ render() {
1070
+ if (this.state.error) {
1071
+ return /* @__PURE__ */ import_react.default.createElement(this.props.fallback, {
1072
+ data: this.props.data,
1073
+ error: this.state.error,
1074
+ reset: this.resetError
1075
+ });
1076
+ }
1077
+ return this.props.children;
1078
+ }
1079
+ resetError() {
1080
+ this.setState({
1081
+ error: void 0
1082
+ });
1083
+ }
1084
+ };
1085
+ var PluginManagerContext = (0, import_react2.createContext)(void 0);
1086
+ var usePluginManager = () => (0, import_react2.useContext)(PluginManagerContext) ?? (0, import_debug.raise)(new Error("Missing PluginManagerContext"));
1087
+ var PluginManagerProvider = PluginManagerContext.Provider;
1088
+ var useCapabilities = (interfaceDef, filter) => {
1089
+ const manager = usePluginManager();
1090
+ const signal = (0, import_react3.useMemo)(() => (0, import_signals_core3.computed)(() => manager.context.requestCapabilities(interfaceDef, filter)), [
1091
+ interfaceDef
1092
+ ]);
1093
+ return signal.value;
1094
+ };
1095
+ var useCapability = (interfaceDef, filter) => {
1096
+ const manager = usePluginManager();
1097
+ const signal = (0, import_react3.useMemo)(() => (0, import_signals_core3.computed)(() => manager.context.requestCapability(interfaceDef, filter)), [
1098
+ interfaceDef
1099
+ ]);
1100
+ return signal.value;
1101
+ };
1102
+ var IntentContext = /* @__PURE__ */ (0, import_react5.createContext)(void 0);
1103
+ var useIntentDispatcher = () => {
1104
+ const context = (0, import_react5.useContext)(IntentContext) ?? (0, import_debug2.raise)(new Error("IntentContext not found"));
1105
+ return (0, import_util3.pick)(context, [
1106
+ "dispatch",
1107
+ "dispatchPromise"
1108
+ ]);
1109
+ };
1110
+ var useIntentResolver = (module2, resolver) => {
1111
+ const manager = usePluginManager();
1112
+ (0, import_react5.useEffect)(() => {
1113
+ manager.context.contributeCapability({
1114
+ module: module2,
1115
+ interface: Capabilities.IntentResolver,
1116
+ implementation: resolver
1117
+ });
1118
+ return () => manager.context.removeCapability(Capabilities.IntentResolver, resolver);
1119
+ }, [
1120
+ module2,
1121
+ resolver
1122
+ ]);
1123
+ };
1124
+ var IntentProvider = IntentContext.Provider;
1125
+ var defaultEffect = () => import_effect3.Effect.fail(new Error("Intent runtime not ready"));
1126
+ var defaultPromise = () => import_effect3.Effect.runPromise(defaultEffect());
1127
+ var IntentPlugin = () => definePlugin({
1128
+ id: INTENT_PLUGIN
1129
+ }, [
1130
+ defineModule({
1131
+ id: `${INTENT_PLUGIN}/module/dispatcher`,
1132
+ // TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
1133
+ // This is fine for now because it's how it worked prior to capabilities api anyways.
1134
+ // In the future, the intent dispatcher should be able to be reset without resetting the entire app.
1135
+ activatesOn: Events.Startup,
1136
+ activatesBefore: [
1137
+ Events.SetupIntents
1138
+ ],
1139
+ activatesAfter: [
1140
+ Events.DispatcherReady
1141
+ ],
1142
+ activate: (context) => {
1143
+ const state = (0, import_live_object3.create)({
1144
+ dispatch: defaultEffect,
1145
+ dispatchPromise: defaultPromise,
1146
+ undo: defaultEffect,
1147
+ undoPromise: defaultPromise
1148
+ });
1149
+ const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher((module2) => context.requestCapabilities(Capabilities.IntentResolver, (c, moduleId) => {
1150
+ return module2 ? moduleId === module2 : true;
1151
+ }).flat());
1152
+ state.dispatch = dispatch;
1153
+ state.dispatchPromise = dispatchPromise;
1154
+ state.undo = undo;
1155
+ state.undoPromise = undoPromise;
1156
+ return [
1157
+ contributes(Capabilities.IntentDispatcher, state),
1158
+ contributes(Capabilities.ReactContext, {
1159
+ id: INTENT_PLUGIN,
1160
+ context: ({ children }) => /* @__PURE__ */ import_react6.default.createElement(IntentProvider, {
1161
+ value: state
1162
+ }, children)
1163
+ })
1164
+ ];
1165
+ }
1166
+ })
1167
+ ]);
1168
+ var Toast = import_echo_schema4.S.Struct({
1169
+ id: import_echo_schema4.S.String,
1170
+ title: import_echo_schema4.S.optional(Label),
1171
+ description: import_echo_schema4.S.optional(Label),
1172
+ icon: import_echo_schema4.S.optional(import_echo_schema4.S.String),
1173
+ duration: import_echo_schema4.S.optional(import_echo_schema4.S.Number),
1174
+ closeLabel: import_echo_schema4.S.optional(Label),
1175
+ actionLabel: import_echo_schema4.S.optional(Label),
1176
+ actionAlt: import_echo_schema4.S.optional(Label),
1177
+ // TODO(wittjosiah): Make class with customizable method?
1178
+ onAction: import_echo_schema4.S.optional(import_echo_schema4.S.Any)
1179
+ });
1180
+ var LayoutMode = import_echo_schema4.S.Union(import_echo_schema4.S.Literal("deck"), import_echo_schema4.S.Literal("solo"), import_echo_schema4.S.Literal("fullscreen"));
1181
+ var isLayoutMode = (value) => import_echo_schema4.S.is(LayoutMode)(value);
1182
+ var Layout = import_echo_schema4.S.mutable(import_echo_schema4.S.Struct({
1183
+ layoutMode: LayoutMode,
1184
+ sidebarOpen: import_echo_schema4.S.Boolean,
1185
+ complementarySidebarOpen: import_echo_schema4.S.Boolean,
1186
+ /**
1187
+ * @deprecated Data to be passed to the complementary sidebar Surface.
1188
+ */
1189
+ complementarySidebarContent: import_echo_schema4.S.optional(import_echo_schema4.S.Any),
1190
+ dialogOpen: import_echo_schema4.S.Boolean,
1191
+ /**
1192
+ * Data to be passed to the dialog Surface.
1193
+ */
1194
+ dialogContent: import_echo_schema4.S.optional(import_echo_schema4.S.Any),
1195
+ // TODO(wittjosiah): Custom properties?
1196
+ dialogBlockAlign: import_echo_schema4.S.optional(import_echo_schema4.S.Literal("start", "center")),
1197
+ dialogType: import_echo_schema4.S.optional(import_echo_schema4.S.Literal("default", "alert")),
1198
+ popoverOpen: import_echo_schema4.S.Boolean,
1199
+ /**
1200
+ * Data to be passed to the popover Surface.
1201
+ */
1202
+ popoverContent: import_echo_schema4.S.optional(import_echo_schema4.S.Any),
1203
+ popoverAnchorId: import_echo_schema4.S.optional(import_echo_schema4.S.String),
1204
+ toasts: import_echo_schema4.S.mutable(import_echo_schema4.S.Array(Toast)),
1205
+ /**
1206
+ * The identifier of a component to scroll into view when it is mounted.
1207
+ */
1208
+ scrollIntoView: import_echo_schema4.S.optional(import_echo_schema4.S.String)
1209
+ }));
1210
+ var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
1211
+ var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
1212
+ var LayoutAction;
1213
+ (function(LayoutAction2) {
1214
+ class SetLayout extends import_echo_schema4.S.TaggedClass()(`${LAYOUT_ACTION}/set-layout`, {
1215
+ input: import_echo_schema4.S.Struct({
1216
+ /**
1217
+ * Element to set the state of.
1218
+ */
1219
+ element: import_echo_schema4.S.Literal("fullscreen", "sidebar", "complementary", "dialog", "popover", "toast"),
1220
+ /**
1221
+ * Whether the element is on or off.
1222
+ *
1223
+ * If omitted, the element's state will be toggled or set based on other provided data.
1224
+ * For example, if `component` is provided, the state will be set to `true`.
1225
+ */
1226
+ state: import_echo_schema4.S.optional(import_echo_schema4.S.Boolean),
1227
+ /**
1228
+ * Component to render in the dialog or popover.
1229
+ */
1230
+ component: import_echo_schema4.S.optional(import_echo_schema4.S.String),
1231
+ /**
1232
+ * Data to be passed to the dialog or popover Surface.
1233
+ */
1234
+ subject: import_echo_schema4.S.optional(import_echo_schema4.S.Any),
1235
+ /**
1236
+ * Anchor ID for the popover.
1237
+ */
1238
+ anchorId: import_echo_schema4.S.optional(import_echo_schema4.S.String),
1239
+ // TODO(wittjosiah): Custom properties?
1240
+ /**
1241
+ * Block alignment for the dialog.
1242
+ */
1243
+ dialogBlockAlign: import_echo_schema4.S.optional(import_echo_schema4.S.Literal("start", "center")),
1244
+ /**
1245
+ * Type of dialog.
1246
+ */
1247
+ dialogType: import_echo_schema4.S.optional(import_echo_schema4.S.Literal("default", "alert"))
1248
+ }),
1249
+ output: import_echo_schema4.S.Void
1250
+ }) {
1251
+ }
1252
+ LayoutAction2.SetLayout = SetLayout;
1253
+ class SetLayoutMode extends import_echo_schema4.S.TaggedClass()(`${LAYOUT_ACTION}/set-layout-mode`, {
1254
+ input: import_echo_schema4.S.Union(import_echo_schema4.S.Struct({
1255
+ layoutMode: LayoutMode
1256
+ }), import_echo_schema4.S.Struct({
1257
+ revert: import_echo_schema4.S.Literal(true)
1258
+ })),
1259
+ output: import_echo_schema4.S.Void
1260
+ }) {
1261
+ }
1262
+ LayoutAction2.SetLayoutMode = SetLayoutMode;
1263
+ class ScrollIntoView extends import_echo_schema4.S.TaggedClass()(`${LAYOUT_ACTION}/scroll-into-view`, {
1264
+ input: import_echo_schema4.S.Struct({
1265
+ id: import_echo_schema4.S.optional(import_echo_schema4.S.String),
1266
+ // TODO(wittjosiah): Factor out to thread scroll into view action?
1267
+ cursor: import_echo_schema4.S.optional(import_echo_schema4.S.String),
1268
+ ref: import_echo_schema4.S.optional(import_echo_schema4.S.String)
1269
+ }),
1270
+ output: import_echo_schema4.S.Void
1271
+ }) {
1272
+ }
1273
+ LayoutAction2.ScrollIntoView = ScrollIntoView;
1274
+ })(LayoutAction || (LayoutAction = {}));
1275
+ var SLUG_LIST_SEPARATOR = "+";
1276
+ var SLUG_ENTRY_SEPARATOR = "_";
1277
+ var SLUG_KEY_VALUE_SEPARATOR = "-";
1278
+ var SLUG_PATH_SEPARATOR = "~";
1279
+ var SLUG_COLLECTION_INDICATOR = "";
1280
+ var LayoutEntrySchema = import_schema.Schema.mutable(import_schema.Schema.Struct({
1281
+ id: import_schema.Schema.String,
1282
+ path: import_schema.Schema.optional(import_schema.Schema.String)
1283
+ }));
1284
+ var LayoutPartSchema = import_schema.Schema.Union(import_schema.Schema.Literal("sidebar").annotations({
1285
+ description: "The primary sidebar."
1286
+ }), import_schema.Schema.Literal("main").annotations({
1287
+ description: "The main content area."
1288
+ }), import_schema.Schema.Literal("solo").annotations({
1289
+ description: "The solo content area."
1290
+ }), import_schema.Schema.Literal("complementary").annotations({
1291
+ description: "The secondary sidebar."
1292
+ }), import_schema.Schema.Literal("fullScreen").annotations({
1293
+ description: "Full screen content."
1294
+ }));
1295
+ var LayoutPartsSchema = import_schema.Schema.partial(import_schema.Schema.mutable(import_schema.Schema.Record({
1296
+ key: LayoutPartSchema,
1297
+ value: import_schema.Schema.mutable(import_schema.Schema.Array(LayoutEntrySchema))
1298
+ })));
1299
+ var LayoutCoordinateSchema = import_schema.Schema.mutable(import_schema.Schema.Struct({
1300
+ part: LayoutPartSchema,
1301
+ entryId: import_schema.Schema.String
1302
+ }));
1303
+ var PartAdjustmentSchema = import_schema.Schema.Union(import_schema.Schema.Literal("increment-start"), import_schema.Schema.Literal("increment-end"), import_schema.Schema.Literal("pin-start"), import_schema.Schema.Literal("pin-end"), import_schema.Schema.Literal("close"), import_schema.Schema.Literal("solo"));
1304
+ var LayoutAdjustmentSchema = import_schema.Schema.mutable(import_schema.Schema.Struct({
1305
+ layoutCoordinate: LayoutCoordinateSchema,
1306
+ type: PartAdjustmentSchema
1307
+ }));
1308
+ var ActiveParts = import_schema.Schema.Record({
1309
+ key: import_schema.Schema.String,
1310
+ value: import_schema.Schema.Union(import_schema.Schema.String, import_schema.Schema.mutable(import_schema.Schema.Array(import_schema.Schema.String)))
1311
+ });
1312
+ var LocationProvidesSchema = import_schema.Schema.mutable(import_schema.Schema.Struct({
1313
+ location: import_schema.Schema.Struct({
1314
+ active: LayoutPartsSchema,
1315
+ closed: import_schema.Schema.Array(import_schema.Schema.String)
1316
+ })
1317
+ }));
1318
+ var isLayoutParts = (value) => {
1319
+ return import_schema.Schema.is(LayoutPartsSchema)(value);
1320
+ };
1321
+ var isLayoutAdjustment = (value) => {
1322
+ return import_schema.Schema.is(LayoutAdjustmentSchema)(value);
1323
+ };
1324
+ var openIds = (layout, parts) => {
1325
+ return Object.values(parts ? (0, import_util4.pick)(layout, parts) : layout).flatMap((part) => part?.map((entry) => entry.id) ?? []).filter((id) => id !== void 0);
1326
+ };
1327
+ var firstIdInPart = (layout, part) => {
1328
+ if (!layout) {
1329
+ return void 0;
1330
+ }
1331
+ return layout[part]?.at(0)?.id;
1332
+ };
1333
+ var indexInPart = (layout, layoutCoordinate) => {
1334
+ if (!layout || !layoutCoordinate) {
1335
+ return void 0;
1336
+ }
1337
+ const { part, entryId } = layoutCoordinate;
1338
+ return layout[part]?.findIndex((entry) => entry.id === entryId);
1339
+ };
1340
+ var partLength = (layout, part) => {
1341
+ if (!layout || !part) {
1342
+ return 0;
1343
+ }
1344
+ return layout[part]?.length ?? 0;
1345
+ };
1346
+ var NAVIGATION_PLUGIN = "dxos.org/plugin/navigation";
1347
+ var NAVIGATION_ACTION = `${NAVIGATION_PLUGIN}/action`;
1348
+ var NavigationAction;
1349
+ (function(NavigationAction2) {
1350
+ class Open extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/open`, {
1351
+ input: import_schema.Schema.Struct({
1352
+ activeParts: ActiveParts,
1353
+ noToggle: import_schema.Schema.optional(import_schema.Schema.Boolean)
1354
+ }),
1355
+ output: import_schema.Schema.Struct({
1356
+ open: import_schema.Schema.Array(import_schema.Schema.String)
1357
+ })
1358
+ }) {
1359
+ }
1360
+ NavigationAction2.Open = Open;
1361
+ class AddToActive extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/add-to-active`, {
1362
+ input: import_schema.Schema.Struct({
1363
+ id: import_schema.Schema.String.annotations({
1364
+ description: "The ID of the item to add."
1365
+ }),
1366
+ part: LayoutPartSchema.annotations({
1367
+ description: "The part to add the item to."
1368
+ }),
1369
+ scrollIntoView: import_schema.Schema.optional(import_schema.Schema.Boolean.annotations({
1370
+ description: "Scroll the item into view."
1371
+ })),
1372
+ pivotId: import_schema.Schema.optional(import_schema.Schema.String.annotations({
1373
+ description: "The ID of the item to place the new item next to."
1374
+ })),
1375
+ positioning: import_schema.Schema.optional(import_schema.Schema.Union(import_schema.Schema.Literal("start").annotations({
1376
+ description: "Place the new item before the pivot item."
1377
+ }), import_schema.Schema.Literal("end").annotations({
1378
+ description: "Place the new item after the pivot item."
1379
+ })).annotations({
1380
+ description: "The position to place the new item."
1381
+ }))
1382
+ }),
1383
+ output: import_schema.Schema.Void
1384
+ }) {
1385
+ }
1386
+ NavigationAction2.AddToActive = AddToActive;
1387
+ class Set2 extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/set`, {
1388
+ input: import_schema.Schema.Struct({
1389
+ activeParts: ActiveParts
1390
+ }),
1391
+ output: import_schema.Schema.Void
1392
+ }) {
1393
+ }
1394
+ NavigationAction2.Set = Set2;
1395
+ class Close extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/close`, {
1396
+ input: import_schema.Schema.Struct({
1397
+ activeParts: ActiveParts,
1398
+ noToggle: import_schema.Schema.optional(import_schema.Schema.Boolean)
1399
+ }),
1400
+ output: import_schema.Schema.Void
1401
+ }) {
1402
+ }
1403
+ NavigationAction2.Close = Close;
1404
+ class Adjust extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/adjust`, {
1405
+ input: LayoutAdjustmentSchema,
1406
+ output: import_schema.Schema.Void
1407
+ }) {
1408
+ }
1409
+ NavigationAction2.Adjust = Adjust;
1410
+ class Expose extends import_schema.Schema.TaggedClass()(`${NAVIGATION_ACTION}/expose`, {
1411
+ input: import_schema.Schema.Struct({
1412
+ id: import_schema.Schema.String
1413
+ }),
1414
+ output: import_schema.Schema.Void
1415
+ }) {
1416
+ }
1417
+ NavigationAction2.Expose = Expose;
1418
+ })(NavigationAction || (NavigationAction = {}));
1419
+ var createSurface = (definition) => definition;
1420
+ var ResourceKey = import_zod.z.union([
1421
+ import_zod.z.string(),
1422
+ import_zod.z.record(import_zod.z.any())
1423
+ ]);
1424
+ var ResourceLanguage = import_zod.z.record(ResourceKey);
1425
+ var Resource = import_zod.z.record(ResourceLanguage);
1426
+ var useSurfaces = () => {
1427
+ const surfaces = useCapabilities(Capabilities.ReactSurface);
1428
+ return (0, import_react4.useMemo)(() => surfaces.flat(), [
1429
+ surfaces
1430
+ ]);
1431
+ };
1432
+ var findCandidates = (surfaces, { role, data }) => {
1433
+ return Object.values(surfaces).filter((definition) => Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role).filter(({ filter }) => filter ? filter(data ?? {}) : true).toSorted(import_util2.byDisposition);
1434
+ };
1435
+ var isSurfaceAvailable = (context, { role, data }) => {
1436
+ const surfaces = context.requestCapabilities(Capabilities.ReactSurface);
1437
+ const candidates = findCandidates(surfaces.flat(), {
1438
+ role,
1439
+ data
1440
+ });
1441
+ return candidates.length > 0;
1442
+ };
1443
+ var Surface = /* @__PURE__ */ (0, import_react4.memo)(/* @__PURE__ */ (0, import_react4.forwardRef)(({ id: _id, role, data: _data, limit, fallback, placeholder, ...rest }, forwardedRef) => {
1444
+ const surfaces = useSurfaces();
1445
+ const data = (0, import_react_hooks.useDefaultValue)(_data, () => ({}));
1446
+ const candidates = (0, import_react4.useMemo)(() => {
1447
+ const definitions = findCandidates(surfaces, {
1448
+ role,
1449
+ data
1450
+ });
1451
+ return limit ? definitions.slice(0, limit) : definitions;
1452
+ }, [
1453
+ surfaces,
1454
+ role,
1455
+ data,
1456
+ limit
1457
+ ]);
1458
+ const nodes = candidates.map(({ component: Component2, id }) => /* @__PURE__ */ import_react4.default.createElement(Component2, {
1459
+ ref: forwardedRef,
1460
+ key: id,
1461
+ id,
1462
+ role,
1463
+ data,
1464
+ limit,
1465
+ ...rest
1466
+ }));
1467
+ const suspense = placeholder ? /* @__PURE__ */ import_react4.default.createElement(import_react4.Suspense, {
1468
+ fallback: placeholder
1469
+ }, nodes) : nodes;
1470
+ return fallback ? /* @__PURE__ */ import_react4.default.createElement(ErrorBoundary, {
1471
+ data,
1472
+ fallback
1473
+ }, suspense) : suspense;
1474
+ }));
1475
+ var topologicalSort = (nodes) => {
1476
+ const getDependencies = (nodeId, seen = /* @__PURE__ */ new Set(), path = /* @__PURE__ */ new Set()) => {
1477
+ if (path.has(nodeId)) {
1478
+ throw new Error(`Circular dependency detected involving ${nodeId}`);
1479
+ }
1480
+ if (seen.has(nodeId)) {
1481
+ return [];
1482
+ }
1483
+ const node = nodes.find((n) => n.id === nodeId);
1484
+ if (!node) {
1485
+ throw new Error(`Node ${nodeId} not found but is listed as a dependency`);
1486
+ }
1487
+ const newPath = /* @__PURE__ */ new Set([
1488
+ ...path,
1489
+ nodeId
1490
+ ]);
1491
+ const newSeen = /* @__PURE__ */ new Set([
1492
+ ...seen,
1493
+ nodeId
1494
+ ]);
1495
+ const dependsOn = node.dependsOn ?? [];
1496
+ return [
1497
+ ...dependsOn.flatMap((depId) => getDependencies(depId, newSeen, newPath)),
1498
+ nodeId
1499
+ ];
1500
+ };
1501
+ const allDependencies = nodes.map((node) => node.id).flatMap((id) => getDependencies(id)).filter((id, index, self) => self.indexOf(id) === index);
1502
+ return allDependencies.map((id) => nodes.find((node) => node.id === id)).filter((node) => node !== void 0);
1503
+ };
1504
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
1505
+ var ENABLED_KEY = "dxos.org/app-framework/enabled";
1506
+ var createApp = ({ pluginManager, pluginLoader: _pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), defaults = [], placeholder = null, fallback = DefaultFallback, cacheEnabled = false }) => {
1507
+ const pluginLoader = _pluginLoader ?? ((id) => {
1508
+ const plugin = plugins.find((plugin2) => plugin2.meta.id === id);
1509
+ (0, import_invariant2.invariant)(plugin, `Plugin not found: ${id}`, {
1510
+ F: __dxlog_file3,
1511
+ L: 68,
1512
+ S: void 0,
1513
+ A: [
1514
+ "plugin",
1515
+ "`Plugin not found: ${id}`"
1516
+ ]
1517
+ });
1518
+ return plugin;
1519
+ });
1520
+ const state = (0, import_live_object4.create)({
1521
+ ready: false,
1522
+ error: null
1523
+ });
1524
+ const cached = JSON.parse(localStorage.getItem(ENABLED_KEY) ?? "[]");
1525
+ const enabled = cacheEnabled && cached.length > 0 ? cached : defaults;
1526
+ const manager = pluginManager ?? new PluginManager({
1527
+ pluginLoader,
1528
+ plugins,
1529
+ core,
1530
+ enabled
1531
+ });
1532
+ manager.activation.on(({ event, state: _state, error }) => {
1533
+ if (event === Events.Startup.id) {
1534
+ state.ready = _state === "activated";
1535
+ }
1536
+ if (error && !state.ready && !state.error) {
1537
+ state.error = error;
1538
+ }
1539
+ });
1540
+ (0, import_signals_core4.effect)(() => {
1541
+ cacheEnabled && localStorage.setItem(ENABLED_KEY, JSON.stringify(manager.enabled));
1542
+ });
1543
+ manager.context.contributeCapability({
1544
+ interface: Capabilities.PluginManager,
1545
+ implementation: manager,
1546
+ module: "dxos.org/app-framework/plugin-manager"
1547
+ });
1548
+ setupDevtools(manager);
1549
+ void manager.activate(Events.Startup);
1550
+ return () => /* @__PURE__ */ import_react7.default.createElement(ErrorBoundary, {
1551
+ fallback
1552
+ }, /* @__PURE__ */ import_react7.default.createElement(App, {
1553
+ placeholder,
1554
+ manager,
1555
+ state
1556
+ }));
1557
+ };
1558
+ var App = ({ placeholder, manager, state }) => {
1559
+ if (state.error) {
1560
+ throw state.error;
1561
+ }
1562
+ if (!state.ready) {
1563
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, placeholder);
1564
+ }
1565
+ const reactContexts = manager.context.requestCapabilities(Capabilities.ReactContext);
1566
+ const reactRoots = manager.context.requestCapabilities(Capabilities.ReactRoot);
1567
+ const ComposedContext = composeContexts(reactContexts);
1568
+ return /* @__PURE__ */ import_react7.default.createElement(PluginManagerProvider, {
1569
+ value: manager
1570
+ }, /* @__PURE__ */ import_react7.default.createElement(ComposedContext, null, reactRoots.map(({ id, root: Component2 }) => /* @__PURE__ */ import_react7.default.createElement(Component2, {
1571
+ key: id
1572
+ }))));
1573
+ };
1574
+ var DefaultFallback = ({ error }) => {
1575
+ return /* @__PURE__ */ import_react7.default.createElement("div", {
1576
+ style: {
1577
+ padding: "1rem"
1578
+ }
1579
+ }, /* @__PURE__ */ import_react7.default.createElement("h1", {
1580
+ style: {
1581
+ fontSize: "1.2rem",
1582
+ fontWeight: 700,
1583
+ margin: "0.5rem 0"
1584
+ }
1585
+ }, error.message), /* @__PURE__ */ import_react7.default.createElement("pre", null, error.stack));
1586
+ };
1587
+ var composeContexts = (contexts) => {
1588
+ if (contexts.length === 0) {
1589
+ return ({ children }) => /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, children);
1590
+ }
1591
+ return topologicalSort(contexts).map(({ context }) => context).reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ import_react7.default.createElement(Acc, null, /* @__PURE__ */ import_react7.default.createElement(Next, null, children)));
1592
+ };
1593
+ var setupDevtools = (manager) => {
1594
+ globalThis.composer ??= {};
1595
+ globalThis.composer.manager = manager;
1596
+ };
1597
+ // Annotate the CommonJS export names for ESM import in node:
1598
+ 0 && (module.exports = {
1599
+ ActiveParts,
1600
+ Capabilities,
1601
+ ErrorBoundary,
1602
+ Events,
1603
+ FileInfoSchema,
1604
+ INTENT_ACTION,
1605
+ INTENT_PLUGIN,
1606
+ IntentAction,
1607
+ IntentPlugin,
1608
+ IntentProvider,
1609
+ LAYOUT_ACTION,
1610
+ LAYOUT_PLUGIN,
1611
+ Label,
1612
+ Layout,
1613
+ LayoutAction,
1614
+ NAVIGATION_ACTION,
1615
+ NAVIGATION_PLUGIN,
1616
+ NavigationAction,
1617
+ Plugin,
1618
+ PluginManager,
1619
+ PluginManagerProvider,
1620
+ PluginModule,
1621
+ PluginsContext,
1622
+ Resource,
1623
+ ResourceKey,
1624
+ ResourceLanguage,
1625
+ SLUG_COLLECTION_INDICATOR,
1626
+ SLUG_ENTRY_SEPARATOR,
1627
+ SLUG_KEY_VALUE_SEPARATOR,
1628
+ SLUG_LIST_SEPARATOR,
1629
+ SLUG_PATH_SEPARATOR,
1630
+ Surface,
1631
+ Toast,
1632
+ allOf,
1633
+ chain,
1634
+ contributes,
1635
+ createApp,
1636
+ createDispatcher,
1637
+ createIntent,
1638
+ createResolver,
1639
+ createSurface,
1640
+ defaultFileTypes,
1641
+ defineCapability,
1642
+ defineEvent,
1643
+ defineModule,
1644
+ definePlugin,
1645
+ eventKey,
1646
+ firstIdInPart,
1647
+ getEvents,
1648
+ indexInPart,
1649
+ isAllOf,
1650
+ isLayoutAdjustment,
1651
+ isLayoutMode,
1652
+ isLayoutParts,
1653
+ isOneOf,
1654
+ isSurfaceAvailable,
1655
+ lazy,
1656
+ oneOf,
1657
+ openIds,
1658
+ partLength,
1659
+ useCapabilities,
1660
+ useCapability,
1661
+ useIntentDispatcher,
1662
+ useIntentResolver,
1663
+ usePluginManager
1664
+ });
1665
+ //# sourceMappingURL=chunk-7PNEFY2G.cjs.map