@dxos/plugin-space 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

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 (258) hide show
  1. package/dist/lib/browser/app-graph-builder-MGK5HWPZ.mjs +288 -0
  2. package/dist/lib/browser/app-graph-builder-MGK5HWPZ.mjs.map +7 -0
  3. package/dist/lib/browser/app-graph-serializer-FOWFLYGU.mjs +80 -0
  4. package/dist/lib/browser/app-graph-serializer-FOWFLYGU.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-23RVI5FZ.mjs +539 -0
  6. package/dist/lib/browser/chunk-23RVI5FZ.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-NU7WDVGN.mjs +23 -0
  8. package/dist/lib/browser/chunk-NU7WDVGN.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-PQXZCNAU.mjs +13 -0
  10. package/dist/lib/browser/chunk-PQXZCNAU.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-S6B7627U.mjs +1809 -0
  12. package/dist/lib/browser/chunk-S6B7627U.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-UDWHTKB5.mjs +136 -0
  14. package/dist/lib/browser/chunk-UDWHTKB5.mjs.map +7 -0
  15. package/dist/lib/browser/{chunk-54VE4GTA.mjs → chunk-ULA2UQJ4.mjs} +25 -15
  16. package/dist/lib/browser/chunk-ULA2UQJ4.mjs.map +7 -0
  17. package/dist/lib/browser/identity-created-FYGS6TBH.mjs +28 -0
  18. package/dist/lib/browser/identity-created-FYGS6TBH.mjs.map +7 -0
  19. package/dist/lib/browser/index.mjs +219 -3480
  20. package/dist/lib/browser/index.mjs.map +4 -4
  21. package/dist/lib/browser/intent-resolver-QVR4MSJV.mjs +555 -0
  22. package/dist/lib/browser/intent-resolver-QVR4MSJV.mjs.map +7 -0
  23. package/dist/lib/browser/meta.json +1 -1
  24. package/dist/lib/browser/react-root-IP2ZB245.mjs +28 -0
  25. package/dist/lib/browser/react-root-IP2ZB245.mjs.map +7 -0
  26. package/dist/lib/browser/react-surface-BT3EHB6V.mjs +225 -0
  27. package/dist/lib/browser/react-surface-BT3EHB6V.mjs.map +7 -0
  28. package/dist/lib/browser/schema-5W3DSY2E.mjs +24 -0
  29. package/dist/lib/browser/schema-5W3DSY2E.mjs.map +7 -0
  30. package/dist/lib/browser/settings-PHPCXX33.mjs +24 -0
  31. package/dist/lib/browser/settings-PHPCXX33.mjs.map +7 -0
  32. package/dist/lib/browser/spaces-ready-K47RR7N2.mjs +199 -0
  33. package/dist/lib/browser/spaces-ready-K47RR7N2.mjs.map +7 -0
  34. package/dist/lib/browser/state-INJ63O57.mjs +47 -0
  35. package/dist/lib/browser/state-INJ63O57.mjs.map +7 -0
  36. package/dist/lib/browser/types/index.mjs +6 -4
  37. package/dist/lib/node/app-graph-builder-ZIUBXRPA.cjs +291 -0
  38. package/dist/lib/node/app-graph-builder-ZIUBXRPA.cjs.map +7 -0
  39. package/dist/lib/node/app-graph-serializer-VQOGHKXL.cjs +88 -0
  40. package/dist/lib/node/app-graph-serializer-VQOGHKXL.cjs.map +7 -0
  41. package/dist/lib/node/chunk-N2FS7PRA.cjs +1807 -0
  42. package/dist/lib/node/chunk-N2FS7PRA.cjs.map +7 -0
  43. package/dist/lib/node/chunk-OVGKWJOC.cjs +567 -0
  44. package/dist/lib/node/chunk-OVGKWJOC.cjs.map +7 -0
  45. package/dist/lib/node/chunk-U6DYXAR3.cjs +153 -0
  46. package/dist/lib/node/chunk-U6DYXAR3.cjs.map +7 -0
  47. package/dist/lib/node/{chunk-YF2AQ7KP.cjs → chunk-WAJKBO3J.cjs} +31 -20
  48. package/dist/lib/node/chunk-WAJKBO3J.cjs.map +7 -0
  49. package/dist/lib/node/{chunk-46S3JOES.cjs → chunk-WZR6OAN3.cjs} +9 -12
  50. package/dist/lib/node/chunk-WZR6OAN3.cjs.map +7 -0
  51. package/dist/lib/node/chunk-YZKNRFHU.cjs +43 -0
  52. package/dist/lib/node/chunk-YZKNRFHU.cjs.map +7 -0
  53. package/dist/lib/node/identity-created-AXI64BLE.cjs +44 -0
  54. package/dist/lib/node/identity-created-AXI64BLE.cjs.map +7 -0
  55. package/dist/lib/node/index.cjs +203 -3468
  56. package/dist/lib/node/index.cjs.map +4 -4
  57. package/dist/lib/node/intent-resolver-MLENGECT.cjs +553 -0
  58. package/dist/lib/node/intent-resolver-MLENGECT.cjs.map +7 -0
  59. package/dist/lib/node/meta.json +1 -1
  60. package/dist/lib/node/react-root-3OX5Z5CX.cjs +50 -0
  61. package/dist/lib/node/react-root-3OX5Z5CX.cjs.map +7 -0
  62. package/dist/lib/node/react-surface-5NYCMXSM.cjs +221 -0
  63. package/dist/lib/node/react-surface-5NYCMXSM.cjs.map +7 -0
  64. package/dist/lib/node/schema-YN7WVFRX.cjs +40 -0
  65. package/dist/lib/node/schema-YN7WVFRX.cjs.map +7 -0
  66. package/dist/lib/node/{meta.cjs → settings-5QYFWNH7.cjs} +19 -13
  67. package/dist/lib/node/settings-5QYFWNH7.cjs.map +7 -0
  68. package/dist/lib/node/spaces-ready-FQNAKR7G.cjs +210 -0
  69. package/dist/lib/node/spaces-ready-FQNAKR7G.cjs.map +7 -0
  70. package/dist/lib/node/state-57UE3DYE.cjs +61 -0
  71. package/dist/lib/node/state-57UE3DYE.cjs.map +7 -0
  72. package/dist/lib/node/types/index.cjs +19 -17
  73. package/dist/lib/node/types/index.cjs.map +2 -2
  74. package/dist/lib/node-esm/app-graph-builder-TERVM2SL.mjs +289 -0
  75. package/dist/lib/node-esm/app-graph-builder-TERVM2SL.mjs.map +7 -0
  76. package/dist/lib/node-esm/app-graph-serializer-GZRSWHEN.mjs +81 -0
  77. package/dist/lib/node-esm/app-graph-serializer-GZRSWHEN.mjs.map +7 -0
  78. package/dist/lib/node-esm/chunk-2TQ2AJEZ.mjs +137 -0
  79. package/dist/lib/node-esm/chunk-2TQ2AJEZ.mjs.map +7 -0
  80. package/dist/lib/node-esm/chunk-6RSVVEPS.mjs +24 -0
  81. package/dist/lib/node-esm/chunk-6RSVVEPS.mjs.map +7 -0
  82. package/dist/lib/node-esm/chunk-DIKRH2IK.mjs +1810 -0
  83. package/dist/lib/node-esm/chunk-DIKRH2IK.mjs.map +7 -0
  84. package/dist/lib/node-esm/{chunk-2MNFEB23.mjs → chunk-ICCM4YRJ.mjs} +5 -7
  85. package/dist/lib/node-esm/chunk-ICCM4YRJ.mjs.map +7 -0
  86. package/dist/lib/node-esm/chunk-PGH5L7MV.mjs +540 -0
  87. package/dist/lib/node-esm/chunk-PGH5L7MV.mjs.map +7 -0
  88. package/dist/lib/node-esm/{chunk-CDZETPO7.mjs → chunk-TRNZQEEN.mjs} +25 -15
  89. package/dist/lib/node-esm/chunk-TRNZQEEN.mjs.map +7 -0
  90. package/dist/lib/node-esm/identity-created-3CGEXNPO.mjs +29 -0
  91. package/dist/lib/node-esm/identity-created-3CGEXNPO.mjs.map +7 -0
  92. package/dist/lib/node-esm/index.mjs +219 -3480
  93. package/dist/lib/node-esm/index.mjs.map +4 -4
  94. package/dist/lib/node-esm/intent-resolver-BLW4RM6X.mjs +556 -0
  95. package/dist/lib/node-esm/intent-resolver-BLW4RM6X.mjs.map +7 -0
  96. package/dist/lib/node-esm/meta.json +1 -1
  97. package/dist/lib/node-esm/react-root-7XXGP56B.mjs +29 -0
  98. package/dist/lib/node-esm/react-root-7XXGP56B.mjs.map +7 -0
  99. package/dist/lib/node-esm/react-surface-R2ECJSFB.mjs +226 -0
  100. package/dist/lib/node-esm/react-surface-R2ECJSFB.mjs.map +7 -0
  101. package/dist/lib/node-esm/schema-LOR2EVGY.mjs +25 -0
  102. package/dist/lib/node-esm/schema-LOR2EVGY.mjs.map +7 -0
  103. package/dist/lib/node-esm/settings-H6MXTEQM.mjs +25 -0
  104. package/dist/lib/node-esm/settings-H6MXTEQM.mjs.map +7 -0
  105. package/dist/lib/node-esm/spaces-ready-HKAQG5SA.mjs +200 -0
  106. package/dist/lib/node-esm/spaces-ready-HKAQG5SA.mjs.map +7 -0
  107. package/dist/lib/node-esm/state-VYA6OFHD.mjs +48 -0
  108. package/dist/lib/node-esm/state-VYA6OFHD.mjs.map +7 -0
  109. package/dist/lib/node-esm/types/index.mjs +6 -4
  110. package/dist/types/src/SpacePlugin.d.ts +3 -22
  111. package/dist/types/src/SpacePlugin.d.ts.map +1 -1
  112. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  113. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  114. package/dist/types/src/capabilities/app-graph-serializer.d.ts +4 -0
  115. package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +1 -0
  116. package/dist/types/src/capabilities/capabilities.d.ts +22 -0
  117. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  118. package/dist/types/src/capabilities/identity-created.d.ts +4 -0
  119. package/dist/types/src/capabilities/identity-created.d.ts.map +1 -0
  120. package/dist/types/src/capabilities/index.d.ts +197 -0
  121. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  122. package/dist/types/src/capabilities/intent-resolver.d.ts +9 -0
  123. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  124. package/dist/types/src/capabilities/react-root.d.ts +7 -0
  125. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  126. package/dist/types/src/capabilities/react-surface.d.ts +7 -0
  127. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  128. package/dist/types/src/capabilities/schema.d.ts +4 -0
  129. package/dist/types/src/capabilities/schema.d.ts.map +1 -0
  130. package/dist/types/src/capabilities/settings.d.ts +4 -0
  131. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  132. package/dist/types/src/capabilities/spaces-ready.d.ts +4 -0
  133. package/dist/types/src/capabilities/spaces-ready.d.ts.map +1 -0
  134. package/dist/types/src/capabilities/state.d.ts +5 -0
  135. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  136. package/dist/types/src/components/AdvancedObjectSettings/AdvancedObjectSettings.d.ts +6 -0
  137. package/dist/types/src/components/AdvancedObjectSettings/AdvancedObjectSettings.d.ts.map +1 -0
  138. package/dist/types/src/components/AdvancedObjectSettings/ForeignKeys.d.ts +7 -0
  139. package/dist/types/src/components/AdvancedObjectSettings/ForeignKeys.d.ts.map +1 -0
  140. package/dist/types/src/components/AdvancedObjectSettings/index.d.ts +2 -0
  141. package/dist/types/src/components/AdvancedObjectSettings/index.d.ts.map +1 -0
  142. package/dist/types/src/components/AwaitingObject.d.ts +1 -2
  143. package/dist/types/src/components/AwaitingObject.d.ts.map +1 -1
  144. package/dist/types/src/components/BaseObjectSettings.d.ts +6 -0
  145. package/dist/types/src/components/BaseObjectSettings.d.ts.map +1 -0
  146. package/dist/types/src/components/CollectionMain.d.ts +1 -2
  147. package/dist/types/src/components/CollectionMain.d.ts.map +1 -1
  148. package/dist/types/src/components/CollectionSection.d.ts +1 -2
  149. package/dist/types/src/components/CollectionSection.d.ts.map +1 -1
  150. package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts +2 -5
  151. package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts.map +1 -1
  152. package/dist/types/src/components/CreateDialog/CreateObjectDialog.stories.d.ts.map +1 -1
  153. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts +9 -11
  154. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts.map +1 -1
  155. package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts +1 -2
  156. package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts.map +1 -1
  157. package/dist/types/src/components/JoinDialog.d.ts +1 -2
  158. package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
  159. package/dist/types/src/components/MenuFooter.d.ts +1 -2
  160. package/dist/types/src/components/MenuFooter.d.ts.map +1 -1
  161. package/dist/types/src/components/PersistenceStatus.d.ts +1 -2
  162. package/dist/types/src/components/PersistenceStatus.d.ts.map +1 -1
  163. package/dist/types/src/components/PopoverAddSpace.d.ts +3 -0
  164. package/dist/types/src/components/PopoverAddSpace.d.ts.map +1 -0
  165. package/dist/types/src/components/PopoverRenameObject.d.ts +1 -2
  166. package/dist/types/src/components/PopoverRenameObject.d.ts.map +1 -1
  167. package/dist/types/src/components/PopoverRenameSpace.d.ts +1 -2
  168. package/dist/types/src/components/PopoverRenameSpace.d.ts.map +1 -1
  169. package/dist/types/src/components/ShareSpaceButton.d.ts +2 -3
  170. package/dist/types/src/components/ShareSpaceButton.d.ts.map +1 -1
  171. package/dist/types/src/components/SpacePluginSettings.d.ts +1 -2
  172. package/dist/types/src/components/SpacePluginSettings.d.ts.map +1 -1
  173. package/dist/types/src/components/SpacePresence.d.ts +4 -5
  174. package/dist/types/src/components/SpacePresence.d.ts.map +1 -1
  175. package/dist/types/src/components/SpacePresence.stories.d.ts +2 -3
  176. package/dist/types/src/components/SpacePresence.stories.d.ts.map +1 -1
  177. package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts +1 -2
  178. package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts.map +1 -1
  179. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts +3 -5
  180. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts.map +1 -1
  181. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.stories.d.ts.map +1 -1
  182. package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts +1 -2
  183. package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts.map +1 -1
  184. package/dist/types/src/components/SyncStatus/Space.d.ts +2 -3
  185. package/dist/types/src/components/SyncStatus/Space.d.ts.map +1 -1
  186. package/dist/types/src/components/SyncStatus/SyncStatus.d.ts +3 -4
  187. package/dist/types/src/components/SyncStatus/SyncStatus.d.ts.map +1 -1
  188. package/dist/types/src/components/index.d.ts +3 -1
  189. package/dist/types/src/components/index.d.ts.map +1 -1
  190. package/dist/types/src/events.d.ts +9 -0
  191. package/dist/types/src/events.d.ts.map +1 -0
  192. package/dist/types/src/index.d.ts +3 -5
  193. package/dist/types/src/index.d.ts.map +1 -1
  194. package/dist/types/src/meta.d.ts +2 -4
  195. package/dist/types/src/meta.d.ts.map +1 -1
  196. package/dist/types/src/translations.d.ts +21 -0
  197. package/dist/types/src/translations.d.ts.map +1 -1
  198. package/dist/types/src/types/collection.d.ts +2 -2
  199. package/dist/types/src/types/thread.d.ts +34 -34
  200. package/dist/types/src/types/types.d.ts +41 -37
  201. package/dist/types/src/types/types.d.ts.map +1 -1
  202. package/dist/types/src/util.d.ts +10 -8
  203. package/dist/types/src/util.d.ts.map +1 -1
  204. package/dist/types/tsconfig.tsbuildinfo +1 -1
  205. package/package.json +41 -47
  206. package/src/SpacePlugin.tsx +141 -1410
  207. package/src/capabilities/app-graph-builder.ts +319 -0
  208. package/src/capabilities/app-graph-serializer.ts +73 -0
  209. package/src/capabilities/capabilities.ts +28 -0
  210. package/src/capabilities/identity-created.ts +26 -0
  211. package/src/capabilities/index.ts +18 -0
  212. package/src/capabilities/intent-resolver.ts +536 -0
  213. package/src/capabilities/react-root.tsx +20 -0
  214. package/src/capabilities/react-surface.tsx +210 -0
  215. package/src/capabilities/schema.ts +27 -0
  216. package/src/capabilities/settings.ts +17 -0
  217. package/src/capabilities/spaces-ready.ts +230 -0
  218. package/src/capabilities/state.ts +45 -0
  219. package/src/components/AdvancedObjectSettings/AdvancedObjectSettings.tsx +72 -0
  220. package/src/components/AdvancedObjectSettings/ForeignKeys.tsx +51 -0
  221. package/src/components/AdvancedObjectSettings/index.ts +5 -0
  222. package/src/components/AwaitingObject.tsx +5 -11
  223. package/src/components/{DefaultObjectSettings.tsx → BaseObjectSettings.tsx} +9 -2
  224. package/src/components/CreateDialog/CreateObjectDialog.stories.tsx +1 -3
  225. package/src/components/CreateDialog/CreateObjectDialog.tsx +43 -35
  226. package/src/components/CreateDialog/CreateObjectPanel.tsx +139 -105
  227. package/src/components/CreateDialog/CreateSpaceDialog.tsx +18 -9
  228. package/src/components/JoinDialog.tsx +27 -19
  229. package/src/components/PopoverAddSpace.tsx +46 -0
  230. package/src/components/SpacePluginSettings.tsx +5 -10
  231. package/src/components/SpacePresence.stories.tsx +2 -2
  232. package/src/components/SpacePresence.tsx +7 -7
  233. package/src/components/SpaceSettings/SpaceSettingsDialog.tsx +16 -1
  234. package/src/components/SpaceSettings/SpaceSettingsPanel.stories.tsx +5 -1
  235. package/src/components/SpaceSettings/SpaceSettingsPanel.tsx +30 -8
  236. package/src/components/SyncStatus/InlineSyncStatus.tsx +2 -2
  237. package/src/components/SyncStatus/SyncStatus.tsx +2 -1
  238. package/src/components/index.ts +3 -1
  239. package/src/events.ts +18 -0
  240. package/src/index.ts +3 -7
  241. package/src/meta.ts +2 -3
  242. package/src/translations.ts +7 -0
  243. package/src/types/types.ts +32 -51
  244. package/src/util.tsx +45 -29
  245. package/dist/lib/browser/chunk-54VE4GTA.mjs.map +0 -7
  246. package/dist/lib/browser/chunk-73BCBSLP.mjs +0 -15
  247. package/dist/lib/browser/chunk-73BCBSLP.mjs.map +0 -7
  248. package/dist/lib/browser/meta.mjs +0 -11
  249. package/dist/lib/browser/meta.mjs.map +0 -7
  250. package/dist/lib/node/chunk-46S3JOES.cjs.map +0 -7
  251. package/dist/lib/node/chunk-YF2AQ7KP.cjs.map +0 -7
  252. package/dist/lib/node/meta.cjs.map +0 -7
  253. package/dist/lib/node-esm/chunk-2MNFEB23.mjs.map +0 -7
  254. package/dist/lib/node-esm/chunk-CDZETPO7.mjs.map +0 -7
  255. package/dist/lib/node-esm/meta.mjs +0 -12
  256. package/dist/lib/node-esm/meta.mjs.map +0 -7
  257. package/dist/types/src/components/DefaultObjectSettings.d.ts +0 -7
  258. package/dist/types/src/components/DefaultObjectSettings.d.ts.map +0 -1
@@ -0,0 +1,319 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';
6
+ import {
7
+ Expando,
8
+ Filter,
9
+ FQ_ID_LENGTH,
10
+ getSpace,
11
+ isEchoObject,
12
+ isSpace,
13
+ OBJECT_ID_LENGTH,
14
+ type ReactiveEchoObject,
15
+ SPACE_ID_LENGTH,
16
+ SpaceState,
17
+ type Space,
18
+ } from '@dxos/client/echo';
19
+ import { isDeleted } from '@dxos/live-object';
20
+ import { log } from '@dxos/log';
21
+ import { ClientCapabilities } from '@dxos/plugin-client';
22
+ import { createExtension, toSignal, type Node, type InvokeParams } from '@dxos/plugin-graph';
23
+ import { isNonNullable } from '@dxos/util';
24
+
25
+ import { SpaceCapabilities } from './capabilities';
26
+ import { SPACE_PLUGIN } from '../meta';
27
+ import { CollectionType, SpaceAction, type SpaceSettingsProps } from '../types';
28
+ import {
29
+ constructObjectActions,
30
+ constructSpaceActions,
31
+ constructSpaceNode,
32
+ createObjectNode,
33
+ memoizeQuery,
34
+ SHARED,
35
+ SPACES,
36
+ } from '../util';
37
+
38
+ export default (context: PluginsContext) => {
39
+ const resolve = (typename: string) =>
40
+ context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {};
41
+
42
+ const spacesNode = {
43
+ id: SPACES,
44
+ type: SPACES,
45
+ cacheable: ['label', 'role'],
46
+ properties: {
47
+ label: ['spaces label', { ns: SPACE_PLUGIN }],
48
+ icon: 'ph--planet--regular',
49
+ testId: 'spacePlugin.spaces',
50
+ role: 'branch',
51
+ disposition: 'collection',
52
+ disabled: true,
53
+ childrenPersistenceClass: 'echo',
54
+ onRearrangeChildren: async (nextOrder: Space[]) => {
55
+ const { graph } = context.requestCapability(Capabilities.AppGraph);
56
+ const client = context.requestCapability(ClientCapabilities.Client);
57
+
58
+ // NOTE: This is needed to ensure order is updated by next animation frame.
59
+ // TODO(wittjosiah): Is there a better way to do this?
60
+ // If not, graph should be passed as an argument to the extension.
61
+ graph._sortEdges(
62
+ SPACES,
63
+ 'outbound',
64
+ nextOrder.map(({ id }) => id),
65
+ );
66
+
67
+ const {
68
+ objects: [spacesOrder],
69
+ } = await client.spaces.default.db.query(Filter.schema(Expando, { key: SHARED })).run();
70
+ if (spacesOrder) {
71
+ spacesOrder.order = nextOrder.map(({ id }) => id);
72
+ } else {
73
+ log.warn('spaces order object not found');
74
+ }
75
+ },
76
+ },
77
+ };
78
+
79
+ return contributes(Capabilities.AppGraphBuilder, [
80
+ // Primary actions.
81
+ createExtension({
82
+ id: `${SPACE_PLUGIN}/primary-actions`,
83
+ position: 'hoist',
84
+ filter: (node): node is Node<null> => node.id === 'root',
85
+ actions: () => [
86
+ {
87
+ id: SpaceAction.AddSpace._tag,
88
+ data: async (params: InvokeParams) => {
89
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
90
+ await dispatch(createIntent(SpaceAction.AddSpace));
91
+ },
92
+ properties: {
93
+ label: ['add space label', { ns: SPACE_PLUGIN }],
94
+ icon: 'ph--plus--regular',
95
+ testId: 'spacePlugin.addSpace',
96
+ disposition: 'item',
97
+ position: 'fallback',
98
+ },
99
+ },
100
+ ],
101
+ }),
102
+
103
+ // Create spaces group node.
104
+ createExtension({
105
+ id: `${SPACE_PLUGIN}/root`,
106
+ position: 'hoist',
107
+ filter: (node): node is Node<null> => node.id === 'root',
108
+ connector: () => [spacesNode],
109
+ resolver: ({ id }) => (id === SPACES ? spacesNode : undefined),
110
+ }),
111
+
112
+ // Create space nodes.
113
+ createExtension({
114
+ id: SPACES,
115
+ filter: (node): node is Node<null> => node.id === SPACES,
116
+ connector: () => {
117
+ const client = context.requestCapability(ClientCapabilities.Client);
118
+ const spaces = toSignal(
119
+ (onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
120
+ () => client.spaces.get(),
121
+ );
122
+
123
+ const isReady = toSignal(
124
+ (onChange) => client.spaces.isReady.subscribe(() => onChange()).unsubscribe,
125
+ () => client.spaces.isReady.get(),
126
+ );
127
+
128
+ if (!spaces || !isReady) {
129
+ return;
130
+ }
131
+
132
+ const state = context.requestCapability(SpaceCapabilities.State);
133
+ const settings = context
134
+ .requestCapabilities(Capabilities.SettingsStore)[0]
135
+ ?.getStore<SpaceSettingsProps>(SPACE_PLUGIN)?.value;
136
+
137
+ // TODO(wittjosiah): During client reset, accessing default space throws.
138
+ try {
139
+ const [spacesOrder] = memoizeQuery(client.spaces.default, Filter.schema(Expando, { key: SHARED }));
140
+ const order: string[] = spacesOrder?.order ?? [];
141
+ const orderMap = new Map(order.map((id, index) => [id, index]));
142
+ return [
143
+ ...spaces
144
+ .filter((space) => orderMap.has(space.id))
145
+ .sort((a, b) => orderMap.get(a.id)! - orderMap.get(b.id)!),
146
+ ...spaces.filter((space) => !orderMap.has(space.id)),
147
+ ]
148
+ .filter((space) => (settings?.showHidden ? true : space.state.get() !== SpaceState.SPACE_INACTIVE))
149
+ .map((space) =>
150
+ constructSpaceNode({
151
+ space,
152
+ navigable: state.navigableCollections,
153
+ personal: space === client.spaces.default,
154
+ namesCache: state.spaceNames,
155
+ resolve,
156
+ }),
157
+ );
158
+ } catch {}
159
+ },
160
+ resolver: ({ id }) => {
161
+ if (id.length !== SPACE_ID_LENGTH) {
162
+ return;
163
+ }
164
+
165
+ const client = context.requestCapability(ClientCapabilities.Client);
166
+ const spaces = toSignal(
167
+ (onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
168
+ () => client.spaces.get(),
169
+ );
170
+
171
+ const isReady = toSignal(
172
+ (onChange) => client.spaces.isReady.subscribe(() => onChange()).unsubscribe,
173
+ () => client.spaces.isReady.get(),
174
+ );
175
+
176
+ if (!spaces || !isReady) {
177
+ return;
178
+ }
179
+
180
+ const space = spaces.find((space) => space.id === id);
181
+ if (!space) {
182
+ return;
183
+ }
184
+
185
+ if (space.state.get() === SpaceState.SPACE_INACTIVE) {
186
+ return false;
187
+ } else if (space.state.get() !== SpaceState.SPACE_READY) {
188
+ return undefined;
189
+ } else {
190
+ const state = context.requestCapability(SpaceCapabilities.State);
191
+ return constructSpaceNode({
192
+ space,
193
+ navigable: state.navigableCollections,
194
+ personal: space === client.spaces.default,
195
+ namesCache: state.spaceNames,
196
+ resolve,
197
+ });
198
+ }
199
+ },
200
+ }),
201
+
202
+ // Create space actions.
203
+ createExtension({
204
+ id: `${SPACE_PLUGIN}/actions`,
205
+ filter: (node): node is Node<Space> => isSpace(node.data),
206
+ actions: ({ node }) => {
207
+ const space = node.data;
208
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
209
+ const client = context.requestCapability(ClientCapabilities.Client);
210
+ const state = context.requestCapability(SpaceCapabilities.State);
211
+ return constructSpaceActions({
212
+ space,
213
+ dispatch,
214
+ personal: space === client.spaces.default,
215
+ migrating: state.sdkMigrationRunning[space.id],
216
+ });
217
+ },
218
+ }),
219
+
220
+ // Create nodes for objects in the root collection of a space.
221
+ createExtension({
222
+ id: `${SPACE_PLUGIN}/root-collection`,
223
+ filter: (node): node is Node<Space> => isSpace(node.data),
224
+ connector: ({ node }) => {
225
+ const space = node.data;
226
+ const spaceState = toSignal(
227
+ (onChange) => space.state.subscribe(() => onChange()).unsubscribe,
228
+ () => space.state.get(),
229
+ space.id,
230
+ );
231
+ if (spaceState !== SpaceState.SPACE_READY) {
232
+ return;
233
+ }
234
+
235
+ const collection = space.properties[CollectionType.typename]?.target as CollectionType | undefined;
236
+ if (!collection) {
237
+ return;
238
+ }
239
+
240
+ const state = context.requestCapability(SpaceCapabilities.State);
241
+
242
+ return collection.objects
243
+ .map((object) => object.target)
244
+ .filter(isNonNullable)
245
+ .map((object) => createObjectNode({ object, space, resolve, navigable: state.navigableCollections }))
246
+ .filter(isNonNullable);
247
+ },
248
+ }),
249
+
250
+ // Create nodes for objects in a collection or by its fully qualified id.
251
+ createExtension({
252
+ id: `${SPACE_PLUGIN}/objects`,
253
+ filter: (node): node is Node<CollectionType> => node.data instanceof CollectionType,
254
+ connector: ({ node }) => {
255
+ const collection = node.data;
256
+ const space = getSpace(collection);
257
+ if (!space) {
258
+ return;
259
+ }
260
+
261
+ const state = context.requestCapability(SpaceCapabilities.State);
262
+
263
+ return collection.objects
264
+ .map((object) => object.target)
265
+ .filter(isNonNullable)
266
+ .map((object) => createObjectNode({ object, space, resolve, navigable: state.navigableCollections }))
267
+ .filter(isNonNullable);
268
+ },
269
+ resolver: ({ id }) => {
270
+ if (id.length !== FQ_ID_LENGTH) {
271
+ return;
272
+ }
273
+
274
+ const [spaceId, objectId] = id.split(':');
275
+ if (spaceId.length !== SPACE_ID_LENGTH && objectId.length !== OBJECT_ID_LENGTH) {
276
+ return;
277
+ }
278
+
279
+ const client = context.requestCapability(ClientCapabilities.Client);
280
+ const space = client.spaces.get().find((space) => space.id === spaceId);
281
+ if (!space) {
282
+ return;
283
+ }
284
+
285
+ const spaceState = toSignal(
286
+ (onChange) => space.state.subscribe(() => onChange()).unsubscribe,
287
+ () => space.state.get(),
288
+ space.id,
289
+ );
290
+ if (spaceState !== SpaceState.SPACE_READY) {
291
+ return;
292
+ }
293
+
294
+ const [object] = memoizeQuery(space, { id: objectId });
295
+ if (!object) {
296
+ return;
297
+ }
298
+
299
+ if (isDeleted(object)) {
300
+ return false;
301
+ } else {
302
+ const state = context.requestCapability(SpaceCapabilities.State);
303
+ return createObjectNode({ object, space, resolve, navigable: state.navigableCollections });
304
+ }
305
+ },
306
+ }),
307
+
308
+ // Create collection actions and action groups.
309
+ createExtension({
310
+ id: `${SPACE_PLUGIN}/object-actions`,
311
+ filter: (node): node is Node<ReactiveEchoObject<any>> => isEchoObject(node.data),
312
+ actions: ({ node }) => {
313
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
314
+ const state = context.requestCapability(SpaceCapabilities.State);
315
+ return constructObjectActions({ node, dispatch, navigable: state.navigableCollections });
316
+ },
317
+ }),
318
+ ]);
319
+ };
@@ -0,0 +1,73 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';
6
+ import { isSpace } from '@dxos/client/echo';
7
+ import { create } from '@dxos/live-object';
8
+
9
+ import { SPACE_PLUGIN } from '../meta';
10
+ import translations from '../translations';
11
+ import { CollectionType, SpaceAction } from '../types';
12
+ import { SPACES, SPACE_TYPE } from '../util';
13
+
14
+ // https://stackoverflow.com/a/19016910
15
+ const DIRECTORY_TYPE = 'text/directory';
16
+
17
+ export default (context: PluginsContext) =>
18
+ contributes(Capabilities.AppGraphSerializer, [
19
+ {
20
+ inputType: SPACES,
21
+ outputType: DIRECTORY_TYPE,
22
+ serialize: (node) => ({
23
+ name: translations[0]['en-US'][SPACE_PLUGIN]['spaces label'],
24
+ data: translations[0]['en-US'][SPACE_PLUGIN]['spaces label'],
25
+ type: DIRECTORY_TYPE,
26
+ }),
27
+ deserialize: () => {
28
+ // No-op.
29
+ },
30
+ },
31
+ {
32
+ inputType: SPACE_TYPE,
33
+ outputType: DIRECTORY_TYPE,
34
+ serialize: (node) => ({
35
+ name: node.data.properties.name ?? translations[0]['en-US'][SPACE_PLUGIN]['unnamed space label'],
36
+ data: node.data.properties.name ?? translations[0]['en-US'][SPACE_PLUGIN]['unnamed space label'],
37
+ type: DIRECTORY_TYPE,
38
+ }),
39
+ deserialize: async (data) => {
40
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
41
+ const result = await dispatch(createIntent(SpaceAction.Create, { name: data.name, edgeReplication: true }));
42
+ return result.data?.space;
43
+ },
44
+ },
45
+ {
46
+ inputType: CollectionType.typename,
47
+ outputType: DIRECTORY_TYPE,
48
+ serialize: (node) => ({
49
+ name: node.data.name ?? translations[0]['en-US'][SPACE_PLUGIN]['unnamed collection label'],
50
+ data: node.data.name ?? translations[0]['en-US'][SPACE_PLUGIN]['unnamed collection label'],
51
+ type: DIRECTORY_TYPE,
52
+ }),
53
+ deserialize: async (data, ancestors) => {
54
+ const space = ancestors.find(isSpace);
55
+ const collection =
56
+ ancestors.findLast((ancestor) => ancestor instanceof CollectionType) ??
57
+ space?.properties[CollectionType.typename]?.target;
58
+ if (!space || !collection) {
59
+ return;
60
+ }
61
+
62
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
63
+ const result = await dispatch(
64
+ createIntent(SpaceAction.AddObject, {
65
+ target: collection,
66
+ object: create(CollectionType, { name: data.name, objects: [], views: {} }),
67
+ }),
68
+ );
69
+
70
+ return result.data?.object;
71
+ },
72
+ },
73
+ ]);
@@ -0,0 +1,28 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { defineCapability, type Label } from '@dxos/app-framework';
6
+ import { type DeepReadonly } from '@dxos/util';
7
+
8
+ import { SPACE_PLUGIN } from '../meta';
9
+ import { type ObjectForm, type PluginState } from '../types';
10
+
11
+ export namespace SpaceCapabilities {
12
+ export const State = defineCapability<DeepReadonly<PluginState>>(`${SPACE_PLUGIN}/capability/state`);
13
+ export const MutableState = defineCapability<PluginState>(`${SPACE_PLUGIN}/capability/state`);
14
+
15
+ export type SpaceSettingsPanel = { id: string; label: Label };
16
+ export const SettingsPanel = defineCapability<SpaceSettingsPanel>(`${SPACE_PLUGIN}/capability/settings-panel`);
17
+
18
+ export const ObjectForm = defineCapability<ObjectForm<any>>(`${SPACE_PLUGIN}/capability/object-form`);
19
+ }
20
+
21
+ // TODO(wittjosiah): Factor out.
22
+ export namespace ThreadCapabilities {
23
+ type ThreadCapability<T = any> = {
24
+ predicate: (obj: any) => obj is T;
25
+ createSort: (obj: T) => (anchorA: string | undefined, anchorB: string | undefined) => number;
26
+ };
27
+ export const Thread = defineCapability<ThreadCapability>(`${SPACE_PLUGIN}/capability/thread`);
28
+ }
@@ -0,0 +1,26 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { contributes, type PluginsContext, Capabilities } from '@dxos/app-framework';
6
+ import { create, makeRef } from '@dxos/live-object';
7
+ import { Migrations } from '@dxos/migrations';
8
+ import { ClientCapabilities } from '@dxos/plugin-client';
9
+
10
+ import { CollectionType } from '../types';
11
+
12
+ export default async (context: PluginsContext) => {
13
+ const client = context.requestCapability(ClientCapabilities.Client);
14
+ await client.spaces.waitUntilReady();
15
+
16
+ const defaultSpace = client.spaces.default;
17
+ await defaultSpace.waitUntilReady();
18
+
19
+ // Create root collection structure.
20
+ defaultSpace.properties[CollectionType.typename] = makeRef(create(CollectionType, { objects: [], views: {} }));
21
+ if (Migrations.versionProperty) {
22
+ defaultSpace.properties[Migrations.versionProperty] = Migrations.targetVersion;
23
+ }
24
+
25
+ return contributes(Capabilities.Null, null);
26
+ };
@@ -0,0 +1,18 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { lazy } from '@dxos/app-framework';
6
+
7
+ export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
8
+ export const AppGraphSerializer = lazy(() => import('./app-graph-serializer'));
9
+ export const IdentityCreated = lazy(() => import('./identity-created'));
10
+ export const IntentResolver = lazy(() => import('./intent-resolver'));
11
+ export const ReactRoot = lazy(() => import('./react-root'));
12
+ export const ReactSurface = lazy(() => import('./react-surface'));
13
+ export const Schema = lazy(() => import('./schema'));
14
+ export const SpaceSettings = lazy(() => import('./settings'));
15
+ export const SpaceState = lazy(() => import('./state'));
16
+ export const SpacesReady = lazy(() => import('./spaces-ready'));
17
+
18
+ export * from './capabilities';