@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
@@ -1,3532 +1,274 @@
1
1
  import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
2
  import {
3
- ActorSchema,
4
- ChannelType,
3
+ translations_default
4
+ } from "./chunk-2TQ2AJEZ.mjs";
5
+ import {
6
+ AdvancedObjectSettings,
7
+ AppGraphBuilder,
8
+ AppGraphSerializer,
9
+ AwaitingObject,
10
+ BaseObjectSettings,
11
+ CREATE_OBJECT_DIALOG,
12
+ CREATE_SPACE_DIALOG,
13
+ CollectionMain,
14
+ CollectionSection,
15
+ CreateObjectDialog,
16
+ CreateSpaceDialog,
17
+ FullPresence,
18
+ IdentityCreated,
19
+ InlineSyncStatus,
20
+ IntentResolver,
21
+ JOIN_DIALOG,
22
+ JoinDialog,
23
+ MenuFooter,
24
+ POPOVER_ADD_SPACE,
25
+ POPOVER_RENAME_OBJECT,
26
+ POPOVER_RENAME_SPACE,
27
+ PersistenceStatus,
28
+ PopoverAddSpace,
29
+ PopoverRenameObject,
30
+ PopoverRenameSpace,
31
+ ReactRoot,
32
+ ReactSurface,
33
+ SPACE_SETTINGS_DIALOG,
34
+ Schema,
35
+ ShareSpaceButton,
36
+ ShareSpaceButtonImpl,
37
+ SmallPresence,
38
+ SmallPresenceLive,
39
+ SpacePluginSettings,
40
+ SpacePresence,
41
+ SpaceSettings,
42
+ SpaceSettingsDialog,
43
+ SpaceSettingsPanel,
44
+ SpaceState,
45
+ SpacesReady,
46
+ SyncStatus,
47
+ SyncStatusDetail,
48
+ SyncStatusIndicator
49
+ } from "./chunk-DIKRH2IK.mjs";
50
+ import {
51
+ SpaceCapabilities,
52
+ ThreadCapabilities
53
+ } from "./chunk-6RSVVEPS.mjs";
54
+ import {
55
+ COMPOSER_SPACE_LOCK,
56
+ SHARED,
57
+ SPACES,
58
+ SPACE_TYPE,
59
+ cloneObject,
60
+ constructObjectActions,
61
+ constructSpaceActions,
62
+ constructSpaceNode,
63
+ createObjectNode,
64
+ getActiveSpace,
65
+ getNestedObjects,
66
+ getSpaceDisplayName,
67
+ memoizeQuery
68
+ } from "./chunk-PGH5L7MV.mjs";
69
+ import {
5
70
  CollectionAction,
6
71
  CollectionType,
7
- ContactType,
8
- MessageState,
9
- MessageType,
10
- SPACE_ACTION,
11
- SPACE_DIRECTORY_HANDLE,
12
- SpaceAction,
13
- SpaceForm,
14
- ThreadStatus,
15
- ThreadType,
16
- parseSchemaPlugin
17
- } from "./chunk-CDZETPO7.mjs";
72
+ defineObjectForm
73
+ } from "./chunk-TRNZQEEN.mjs";
18
74
  import {
19
75
  SPACE_PLUGIN,
20
- SPACE_PLUGIN_SHORT_ID,
21
- meta_default
22
- } from "./chunk-2MNFEB23.mjs";
76
+ meta
77
+ } from "./chunk-ICCM4YRJ.mjs";
78
+
79
+ // packages/plugins/plugin-space/src/events.ts
80
+ import { defineEvent } from "@dxos/app-framework";
81
+ var SpaceEvents;
82
+ (function(SpaceEvents2) {
83
+ SpaceEvents2.SetupSettingsPanel = defineEvent(`${SPACE_PLUGIN}/event/setup-settings-panel`);
84
+ SpaceEvents2.StateReady = defineEvent(`${SPACE_PLUGIN}/event/state-ready`);
85
+ SpaceEvents2.DefaultSpaceReady = defineEvent(`${SPACE_PLUGIN}/event/default-space-ready`);
86
+ })(SpaceEvents || (SpaceEvents = {}));
87
+ var ThreadEvents;
88
+ (function(ThreadEvents2) {
89
+ ThreadEvents2.SetupThread = defineEvent(`${SPACE_PLUGIN}/event/setup-thread`);
90
+ })(ThreadEvents || (ThreadEvents = {}));
23
91
 
24
92
  // packages/plugins/plugin-space/src/SpacePlugin.tsx
25
- import { signal } from "@preact/signals-core";
26
- import React21 from "react";
27
- import { LayoutAction as LayoutAction2, NavigationAction as NavigationAction5, Surface, createIntent as createIntent8, createResolver, createSurface, filterPlugins, findPlugin, firstIdInPart, openIds, parseGraphPlugin, parseIntentPlugin, parseLayoutPlugin, parseMetadataResolverPlugin, parseNavigationPlugin as parseNavigationPlugin2, resolvePlugin } from "@dxos/app-framework";
28
- import { EventSubscriptions } from "@dxos/async";
29
- import { scheduledEffect } from "@dxos/echo-signals/core";
30
- import { invariant as invariant2 } from "@dxos/invariant";
31
- import { RefArray, create, isDeleted, isReactiveObject as isReactiveObject3, makeRef as makeRef2 } from "@dxos/live-object";
32
- import { LocalStorageStore } from "@dxos/local-storage";
33
- import { log as log3 } from "@dxos/log";
34
- import { Migrations as Migrations2 } from "@dxos/migrations";
35
- import { parseAttentionPlugin } from "@dxos/plugin-attention";
36
- import { parseClientPlugin } from "@dxos/plugin-client/types";
37
- import { createExtension, memoize as memoize2, toSignal } from "@dxos/plugin-graph";
38
- import { ObservabilityAction as ObservabilityAction2 } from "@dxos/plugin-observability/types";
39
- import { EdgeReplicationSetting as EdgeReplicationSetting3 } from "@dxos/protocols/proto/dxos/echo/metadata";
40
- import { PublicKey as PublicKey2 } from "@dxos/react-client";
41
- import { Expando, FQ_ID_LENGTH, Filter as Filter3, OBJECT_ID_LENGTH, QueryOptions, SPACE_ID_LENGTH, SpaceState as SpaceState2, fullyQualifiedId as fullyQualifiedId4, getSpace as getSpace5, getTypename as getTypename2, isEchoObject as isEchoObject2, isSpace as isSpace4, parseFullyQualifiedId, parseId } from "@dxos/react-client/echo";
93
+ import { allOf, Capabilities, contributes, createIntent, defineModule, definePlugin, Events, oneOf } from "@dxos/app-framework";
94
+ import { S } from "@dxos/echo-schema";
95
+ import { RefArray } from "@dxos/live-object";
96
+ import { AttentionEvents } from "@dxos/plugin-attention";
97
+ import { ClientEvents } from "@dxos/plugin-client";
98
+ import { DeckCapabilities, DeckEvents } from "@dxos/plugin-deck";
99
+ import { isEchoObject, getSpace } from "@dxos/react-client/echo";
42
100
  import { osTranslations } from "@dxos/shell/react";
43
- import { ComplexMap as ComplexMap2, nonNullable as nonNullable2, reduceGroupBy } from "@dxos/util";
44
-
45
- // packages/plugins/plugin-space/src/components/AwaitingObject.tsx
46
- import { CheckCircle, CircleDashed, CircleNotch } from "@phosphor-icons/react";
47
- import React, { useCallback, useEffect, useState } from "react";
48
- import { useResolvePlugin, parseNavigationPlugin, NavigationAction, useIntentDispatcher, createIntent } from "@dxos/app-framework";
49
- import { useClient } from "@dxos/react-client";
50
- import { Filter, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
51
- import { Button, Toast, useTranslation } from "@dxos/react-ui";
52
- import { getSize, mx } from "@dxos/react-ui-theme";
53
- var WAIT_FOR_OBJECT_TIMEOUT = 18e4;
54
- var TOAST_TIMEOUT = 24e4;
55
- var AwaitingObject = ({ id }) => {
56
- const [open, setOpen] = useState(true);
57
- const [waiting, setWaiting] = useState(true);
58
- const [found, setFound] = useState(false);
59
- const { t } = useTranslation(SPACE_PLUGIN);
60
- const { dispatchPromise: dispatch } = useIntentDispatcher();
61
- const navigationPlugin = useResolvePlugin(parseNavigationPlugin);
62
- const client = useClient();
63
- const objects = useQuery(client.spaces, Filter.all());
64
- useEffect(() => {
65
- if (!id) {
66
- return;
67
- }
68
- const timeout = setTimeout(() => {
69
- setWaiting(false);
70
- }, WAIT_FOR_OBJECT_TIMEOUT);
71
- () => clearTimeout(timeout);
72
- }, [
73
- id
74
- ]);
75
- useEffect(() => {
76
- if (objects.findIndex((object) => fullyQualifiedId(object) === id) > -1) {
77
- setFound(true);
78
- if (navigationPlugin?.provides.location.active.solo?.[0].id === id) {
79
- setOpen(false);
80
- }
81
- }
82
- }, [
83
- id,
84
- objects,
85
- navigationPlugin
86
- ]);
87
- const handleClose = useCallback(async () => dispatch(createIntent(SpaceAction.WaitForObject, {
88
- id: void 0
89
- })), [
90
- dispatch
91
- ]);
92
- const handleNavigate = useCallback(() => {
93
- void dispatch(createIntent(NavigationAction.Open, {
94
- activeParts: {
95
- main: [
96
- id
97
- ]
98
- }
99
- }));
100
- void handleClose();
101
- }, [
102
- id,
103
- handleClose,
104
- dispatch
105
- ]);
106
- return /* @__PURE__ */ React.createElement(Toast.Root, {
107
- open,
108
- duration: TOAST_TIMEOUT,
109
- onOpenChange: setOpen
110
- }, /* @__PURE__ */ React.createElement(Toast.Body, null, /* @__PURE__ */ React.createElement(Toast.Title, {
111
- classNames: "flex items-center gap-2"
112
- }, found ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CheckCircle, {
113
- className: getSize(5)
114
- }), /* @__PURE__ */ React.createElement("span", null, t("found object label"))) : waiting ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CircleNotch, {
115
- className: mx(getSize(5), "animate-spin")
116
- }), /* @__PURE__ */ React.createElement("span", null, t("waiting for object label"))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CircleDashed, {
117
- className: getSize(5)
118
- }), /* @__PURE__ */ React.createElement("span", null, t("object not found label")))), /* @__PURE__ */ React.createElement(Toast.Description, null, t(found ? "found object description" : waiting ? "waiting for object description" : "object not found description"))), /* @__PURE__ */ React.createElement(Toast.Actions, null, found ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Toast.Action, {
119
- altText: t("go to object alt"),
120
- asChild: true
121
- }, /* @__PURE__ */ React.createElement(Button, {
122
- variant: "primary",
123
- onClick: handleNavigate
124
- }, t("go to object label"))), /* @__PURE__ */ React.createElement(Toast.Close, {
125
- asChild: true
126
- }, /* @__PURE__ */ React.createElement(Button, {
127
- onClick: handleClose
128
- }, t("close label", {
129
- ns: "appkit"
130
- })))) : /* @__PURE__ */ React.createElement(Toast.Close, {
131
- asChild: true
132
- }, /* @__PURE__ */ React.createElement(Button, {
133
- onClick: handleClose
134
- }, t(waiting ? "close label" : "confirm label", {
135
- ns: "appkit"
136
- })))));
137
- };
138
-
139
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
140
- import { pipe } from "effect";
141
- import React3, { useCallback as useCallback3, useRef } from "react";
142
- import { chain, createIntent as createIntent3, NavigationAction as NavigationAction3, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
143
- import { useClient as useClient2 } from "@dxos/react-client";
144
- import { getSpace as getSpace2, isReactiveObject as isReactiveObject2, isSpace as isSpace3, useSpaces } from "@dxos/react-client/echo";
145
- import { Button as Button2, Dialog, Icon as Icon2, useTranslation as useTranslation3 } from "@dxos/react-ui";
146
-
147
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx
148
- import React2, { useCallback as useCallback2, useState as useState2 } from "react";
149
- import { getObjectAnnotation as getObjectAnnotation2, S } from "@dxos/echo-schema";
150
- import { isSpace as isSpace2 } from "@dxos/react-client/echo";
151
- import { Icon, IconButton, Input, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
152
- import { Form, InputHeader } from "@dxos/react-ui-form";
153
- import { SearchList } from "@dxos/react-ui-searchlist";
154
- import { nonNullable } from "@dxos/util";
155
-
156
- // packages/plugins/plugin-space/src/util.tsx
157
- import { createIntent as createIntent2, NavigationAction as NavigationAction2 } from "@dxos/app-framework";
158
- import { EXPANDO_TYPENAME, getObjectAnnotation, getTypename } from "@dxos/echo-schema";
159
- import { invariant } from "@dxos/invariant";
160
- import { getSchema, isReactiveObject, makeRef } from "@dxos/live-object";
161
- import { Migrations } from "@dxos/migrations";
162
- import { ACTION_GROUP_TYPE, ACTION_TYPE, cleanup, getGraph, memoize } from "@dxos/plugin-graph";
163
- import { Filter as Filter2, fullyQualifiedId as fullyQualifiedId2, getSpace, isEchoObject, isSpace, SpaceState } from "@dxos/react-client/echo";
164
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/util.tsx";
165
- var SPACES = `${SPACE_PLUGIN}-spaces`;
166
- var SPACE_TYPE = "dxos.org/type/Space";
167
- var COMPOSER_SPACE_LOCK = "dxos.org/plugin/space/lock";
168
- var SHARED = "shared-spaces";
169
- var EMPTY_ARRAY = [];
170
- var memoizeQuery = (spaceOrEcho, filter, options) => {
171
- const key = JSON.stringify({
172
- space: isSpace(spaceOrEcho) ? spaceOrEcho.id : void 0,
173
- filter: Filter2.from(filter).toProto()
174
- });
175
- const query = memoize(() => isSpace(spaceOrEcho) ? spaceOrEcho.db.query(filter, options) : spaceOrEcho?.query(filter, options), key);
176
- const unsubscribe = memoize(() => query?.subscribe(), key);
177
- cleanup(() => unsubscribe?.());
178
- return query?.objects ?? EMPTY_ARRAY;
179
- };
180
- var getSpaceDisplayName = (space, { personal, namesCache = {} } = {}) => {
181
- return space.state.get() === SpaceState.SPACE_READY && (space.properties.name?.length ?? 0) > 0 ? space.properties.name : namesCache[space.id] ? namesCache[space.id] : personal ? [
182
- "personal space label",
183
- {
184
- ns: SPACE_PLUGIN
185
- }
186
- ] : [
187
- "unnamed space label",
188
- {
189
- ns: SPACE_PLUGIN
190
- }
191
- ];
192
- };
193
- var getCollectionGraphNodePartials = ({ navigable, collection, space, resolve }) => {
194
- return {
195
- disabled: !navigable,
196
- acceptPersistenceClass: /* @__PURE__ */ new Set([
197
- "echo"
198
- ]),
199
- acceptPersistenceKey: /* @__PURE__ */ new Set([
200
- space.id
201
- ]),
202
- role: "branch",
203
- onRearrangeChildren: (nextOrder) => {
204
- collection.objects = nextOrder.filter(isEchoObject).map(makeRef);
205
- },
206
- onTransferStart: (child, index) => {
207
- if (!collection.objects.find((object) => object.target === child.data)) {
208
- if (typeof index !== "undefined") {
209
- collection.objects.splice(index, 0, makeRef(child.data));
210
- } else {
211
- collection.objects.push(makeRef(child.data));
212
- }
213
- }
214
- },
215
- onTransferEnd: (child, destination) => {
216
- const index = collection.objects.findIndex((object) => object.target === child.data);
217
- if (index > -1) {
218
- collection.objects.splice(index, 1);
219
- }
220
- },
221
- onCopy: async (child, index) => {
222
- const newObject = await cloneObject(child.data, resolve, space);
223
- space.db.add(newObject);
224
- if (typeof index !== "undefined") {
225
- collection.objects.splice(index, 0, makeRef(newObject));
226
- } else {
227
- collection.objects.push(makeRef(newObject));
228
- }
229
- }
230
- };
231
- };
232
- var checkPendingMigration = (space) => {
233
- return space.state.get() === SpaceState.SPACE_REQUIRES_MIGRATION || space.state.get() === SpaceState.SPACE_READY && !!Migrations.versionProperty && space.properties[Migrations.versionProperty] !== Migrations.targetVersion;
234
- };
235
- var constructSpaceNode = ({ space, navigable = false, personal, namesCache, resolve }) => {
236
- const hasPendingMigration = checkPendingMigration(space);
237
- const collection = space.state.get() === SpaceState.SPACE_READY && space.properties[CollectionType.typename]?.target;
238
- const partials = space.state.get() === SpaceState.SPACE_READY && collection instanceof CollectionType ? getCollectionGraphNodePartials({
239
- collection,
240
- space,
241
- resolve,
242
- navigable
243
- }) : {};
244
- return {
245
- id: space.id,
246
- type: SPACE_TYPE,
247
- cacheable: [
248
- "label",
249
- "icon",
250
- "role"
251
- ],
252
- data: space,
253
- properties: {
254
- ...partials,
255
- label: getSpaceDisplayName(space, {
256
- personal,
257
- namesCache
258
- }),
259
- description: space.state.get() === SpaceState.SPACE_READY && space.properties.description,
260
- icon: "ph--planet--regular",
261
- disabled: !navigable || space.state.get() !== SpaceState.SPACE_READY || hasPendingMigration,
262
- testId: "spacePlugin.space"
263
- }
101
+ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "spaceInvitationCode", observability = true } = {}) => {
102
+ const createInvitationUrl = (invitationCode) => {
103
+ const baseUrl = new URL(invitationUrl);
104
+ baseUrl.searchParams.set(invitationParam, invitationCode);
105
+ return baseUrl.toString();
264
106
  };
265
- };
266
- var constructSpaceActions = ({ space, dispatch, personal, migrating }) => {
267
- const state = space.state.get();
268
- const hasPendingMigration = checkPendingMigration(space);
269
- const getId = (id) => `${id}/${space.id}`;
270
- const actions = [];
271
- if (hasPendingMigration) {
272
- actions.push({
273
- id: getId(SpaceAction.Migrate._tag),
274
- type: ACTION_GROUP_TYPE,
275
- data: async () => {
276
- await dispatch(createIntent2(SpaceAction.Migrate, {
277
- space
278
- }));
279
- },
280
- properties: {
281
- label: [
282
- "migrate space label",
283
- {
284
- ns: SPACE_PLUGIN
285
- }
286
- ],
287
- icon: "ph--database--regular",
288
- disposition: "toolbar",
289
- disabled: migrating || Migrations.running(space)
290
- }
291
- });
292
- }
293
- if (state === SpaceState.SPACE_READY && !hasPendingMigration) {
294
- const locked = space.properties[COMPOSER_SPACE_LOCK];
295
- actions.push({
296
- id: getId(SpaceAction.OpenCreateObject._tag),
297
- type: ACTION_TYPE,
298
- data: async () => {
299
- await dispatch(createIntent2(SpaceAction.OpenCreateObject, {
300
- target: space
301
- }));
302
- },
303
- properties: {
304
- label: [
305
- "create object in space label",
306
- {
307
- ns: SPACE_PLUGIN
308
- }
309
- ],
310
- icon: "ph--plus--regular",
311
- disposition: "toolbar",
312
- testId: "spacePlugin.createObject"
313
- }
314
- }, {
315
- id: getId(SpaceAction.Share._tag),
316
- type: ACTION_TYPE,
317
- data: async () => {
318
- if (locked) {
319
- return;
320
- }
321
- await dispatch(createIntent2(SpaceAction.Share, {
322
- space
323
- }));
324
- },
325
- properties: {
326
- label: [
327
- "share space label",
328
- {
329
- ns: SPACE_PLUGIN
330
- }
331
- ],
332
- icon: "ph--users--regular",
333
- disabled: locked,
334
- keyBinding: {
335
- macos: "meta+.",
336
- windows: "alt+."
337
- }
338
- }
339
- }, {
340
- id: locked ? getId(SpaceAction.Unlock._tag) : getId(SpaceAction.Lock._tag),
341
- type: ACTION_TYPE,
342
- data: async () => {
343
- if (locked) {
344
- await dispatch(createIntent2(SpaceAction.Unlock, {
345
- space
346
- }));
347
- } else {
348
- await dispatch(createIntent2(SpaceAction.Lock, {
349
- space
350
- }));
351
- }
352
- },
353
- properties: {
354
- label: [
355
- locked ? "unlock space label" : "lock space label",
356
- {
357
- ns: SPACE_PLUGIN
358
- }
359
- ],
360
- icon: locked ? "ph--lock-simple-open--regular" : "ph--lock-simple--regular"
361
- }
362
- }, {
363
- id: getId(SpaceAction.Rename._tag),
364
- type: ACTION_TYPE,
365
- data: async (params) => {
366
- await dispatch(createIntent2(SpaceAction.Rename, {
367
- space,
368
- caller: params.caller
369
- }));
370
- },
371
- properties: {
372
- label: [
373
- "rename space label",
374
- {
375
- ns: SPACE_PLUGIN
376
- }
377
- ],
378
- icon: "ph--pencil-simple-line--regular",
379
- keyBinding: {
380
- macos: "shift+F6",
381
- windows: "shift+F6"
382
- }
383
- }
384
- }, {
385
- id: getId(SpaceAction.OpenSettings._tag),
386
- type: ACTION_TYPE,
387
- data: async () => {
388
- await dispatch(createIntent2(SpaceAction.OpenSettings, {
389
- space
390
- }));
391
- },
392
- properties: {
393
- label: [
394
- "open space settings label",
395
- {
396
- ns: SPACE_PLUGIN
397
- }
398
- ],
399
- icon: "ph--gear--regular"
400
- }
401
- });
402
- }
403
- if (state !== SpaceState.SPACE_INACTIVE && !hasPendingMigration) {
404
- actions.push({
405
- id: getId(SpaceAction.Close._tag),
406
- type: ACTION_TYPE,
407
- data: async () => {
408
- await dispatch(createIntent2(SpaceAction.Close, {
409
- space
410
- }));
411
- },
412
- properties: {
413
- label: [
414
- "close space label",
415
- {
416
- ns: SPACE_PLUGIN
417
- }
418
- ],
419
- icon: "ph--x--regular",
420
- disabled: personal
421
- }
422
- });
423
- }
424
- if (state === SpaceState.SPACE_INACTIVE) {
425
- actions.push({
426
- id: getId(SpaceAction.Open._tag),
427
- type: ACTION_TYPE,
428
- data: async () => {
429
- await dispatch(createIntent2(SpaceAction.Open, {
430
- space
431
- }));
432
- },
433
- properties: {
434
- label: [
435
- "open space label",
436
- {
437
- ns: SPACE_PLUGIN
438
- }
439
- ],
440
- icon: "ph--clock-counter-clockwise--regular",
441
- disposition: "toolbar"
442
- }
443
- });
444
- }
445
- return actions;
446
- };
447
- var createObjectNode = ({ object, space, navigable = false, resolve }) => {
448
- const type = getTypename(object);
449
- if (!type) {
450
- return void 0;
451
- }
452
- const metadata = resolve(type);
453
- if (Object.keys(metadata).length === 0) {
454
- return void 0;
455
- }
456
- const partials = object instanceof CollectionType ? getCollectionGraphNodePartials({
457
- collection: object,
458
- space,
459
- resolve,
460
- navigable
461
- }) : metadata.graphProps;
462
- return {
463
- id: fullyQualifiedId2(object),
464
- type,
465
- cacheable: [
466
- "label",
467
- "icon",
468
- "role"
469
- ],
470
- data: object,
471
- properties: {
472
- ...partials,
473
- label: metadata.label?.(object) || object.name || metadata.placeholder || [
474
- "unnamed object label",
475
- {
476
- ns: SPACE_PLUGIN
477
- }
107
+ return definePlugin(meta, [
108
+ defineModule({
109
+ id: `${meta.id}/module/state`,
110
+ // TODO(wittjosiah): Does not integrate with settings store.
111
+ // Should this be a different event?
112
+ // Should settings store be renamed to be more generic?
113
+ activatesOn: oneOf(Events.SetupSettings, Events.SetupAppGraph),
114
+ activatesAfter: [
115
+ SpaceEvents.StateReady
478
116
  ],
479
- icon: metadata.icon ?? "ph--placeholder--regular",
480
- testId: "spacePlugin.object",
481
- persistenceClass: "echo",
482
- persistenceKey: space?.id
483
- }
484
- };
485
- };
486
- var constructObjectActions = ({ node, dispatch }) => {
487
- const object = node.data;
488
- const getId = (id) => `${id}/${fullyQualifiedId2(object)}`;
489
- const actions = [
490
- ...object instanceof CollectionType ? [
491
- {
492
- id: getId(SpaceAction.OpenCreateObject._tag),
493
- type: ACTION_TYPE,
494
- data: async () => {
495
- await dispatch(createIntent2(SpaceAction.OpenCreateObject, {
496
- target: object
497
- }));
498
- },
499
- properties: {
500
- label: [
501
- "create object in collection label",
117
+ activate: SpaceState
118
+ }),
119
+ defineModule({
120
+ id: `${meta.id}/module/settings`,
121
+ activatesOn: Events.SetupSettings,
122
+ activate: SpaceSettings
123
+ }),
124
+ defineModule({
125
+ id: `${meta.id}/module/translations`,
126
+ activatesOn: Events.SetupTranslations,
127
+ activate: () => contributes(Capabilities.Translations, [
128
+ ...translations_default,
129
+ osTranslations
130
+ ])
131
+ }),
132
+ defineModule({
133
+ id: `${meta.id}/module/metadata`,
134
+ activatesOn: Events.SetupMetadata,
135
+ activate: () => contributes(Capabilities.Metadata, {
136
+ id: CollectionType.typename,
137
+ metadata: {
138
+ placeholder: [
139
+ "unnamed collection label",
502
140
  {
503
141
  ns: SPACE_PLUGIN
504
142
  }
505
143
  ],
506
- icon: "ph--plus--regular",
507
- disposition: "toolbar",
508
- testId: "spacePlugin.createObject"
144
+ icon: "ph--cards-three--regular",
145
+ // TODO(wittjosiah): Move out of metadata.
146
+ loadReferences: async (collection) => await RefArray.loadAll([
147
+ ...collection.objects,
148
+ ...Object.values(collection.views)
149
+ ])
509
150
  }
510
- }
511
- ] : [],
512
- {
513
- id: getId(SpaceAction.RenameObject._tag),
514
- type: ACTION_TYPE,
515
- data: async (params) => {
516
- await dispatch(createIntent2(SpaceAction.RenameObject, {
517
- object,
518
- caller: params.caller
519
- }));
520
- },
521
- properties: {
522
- label: [
523
- object instanceof CollectionType ? "rename collection label" : "rename object label",
524
- {
525
- ns: SPACE_PLUGIN
526
- }
527
- ],
528
- icon: "ph--pencil-simple-line--regular",
529
- // TODO(wittjosiah): Doesn't work.
530
- // keyBinding: 'shift+F6',
531
- testId: "spacePlugin.renameObject"
532
- }
533
- },
534
- {
535
- id: getId(SpaceAction.RemoveObjects._tag),
536
- type: ACTION_TYPE,
537
- data: async () => {
538
- const graph = getGraph(node);
539
- const collection = graph.nodes(node, {
540
- relation: "inbound"
541
- }).find(({ data }) => data instanceof CollectionType)?.data;
542
- await dispatch(createIntent2(SpaceAction.RemoveObjects, {
543
- objects: [
544
- object
545
- ],
546
- target: collection
547
- }));
548
- },
549
- properties: {
550
- label: [
551
- object instanceof CollectionType ? "delete collection label" : "delete object label",
552
- {
553
- ns: SPACE_PLUGIN
554
- }
555
- ],
556
- icon: "ph--trash--regular",
557
- keyBinding: object instanceof CollectionType ? void 0 : "shift+meta+Backspace",
558
- testId: "spacePlugin.deleteObject"
559
- }
560
- },
561
- {
562
- id: getId("copy-link"),
563
- type: ACTION_TYPE,
564
- data: async () => {
565
- const url = `${window.location.origin}/${fullyQualifiedId2(object)}`;
566
- await navigator.clipboard.writeText(url);
567
- },
568
- properties: {
569
- label: [
570
- "copy link label",
571
- {
572
- ns: SPACE_PLUGIN
573
- }
574
- ],
575
- icon: "ph--link--regular",
576
- testId: "spacePlugin.copyLink"
577
- }
578
- },
579
- // TODO(wittjosiah): Factor out and apply to all nodes.
580
- {
581
- id: NavigationAction2.Expose._tag,
582
- type: ACTION_TYPE,
583
- data: async () => {
584
- await dispatch(createIntent2(NavigationAction2.Expose, {
585
- id: fullyQualifiedId2(object)
586
- }));
587
- },
588
- properties: {
151
+ })
152
+ }),
153
+ defineModule({
154
+ id: `${meta.id}/module/object-form`,
155
+ activatesOn: ClientEvents.SetupSchema,
156
+ activate: () => contributes(SpaceCapabilities.ObjectForm, defineObjectForm({
157
+ objectSchema: CollectionType,
158
+ formSchema: S.Struct({
159
+ name: S.optional(S.String)
160
+ }),
161
+ getIntent: (props) => createIntent(CollectionAction.Create, props)
162
+ }))
163
+ }),
164
+ defineModule({
165
+ id: `${meta.id}/module/complementary-panel`,
166
+ activatesOn: DeckEvents.SetupComplementaryPanels,
167
+ activate: () => contributes(DeckCapabilities.ComplementaryPanel, {
168
+ id: "settings",
589
169
  label: [
590
- "expose object label",
170
+ "settings panel label",
591
171
  {
592
172
  ns: SPACE_PLUGIN
593
173
  }
594
174
  ],
595
- icon: "ph--eye--regular",
596
- testId: "spacePlugin.exposeObject"
597
- }
598
- }
599
- ];
600
- return actions;
601
- };
602
- var getActiveSpace = (graph, active) => {
603
- if (!active) {
604
- return;
605
- }
606
- const node = graph.findNode(active);
607
- if (!node || !isReactiveObject(node.data)) {
608
- return;
609
- }
610
- return getSpace(node.data);
611
- };
612
- var getNestedObjects = async (object, resolve) => {
613
- const type = getTypename(object);
614
- if (!type) {
615
- return [];
616
- }
617
- const metadata = resolve(type);
618
- const loadReferences = metadata.loadReferences;
619
- if (typeof loadReferences !== "function") {
620
- return [];
621
- }
622
- const objects = await loadReferences(object);
623
- const nested = await Promise.all(objects.map((object2) => getNestedObjects(object2, resolve)));
624
- return [
625
- ...objects,
626
- ...nested.flat()
627
- ];
628
- };
629
- var cloneObject = async (object, resolve, newSpace) => {
630
- const schema = getSchema(object);
631
- const typename = schema ? getObjectAnnotation(schema)?.typename ?? EXPANDO_TYPENAME : EXPANDO_TYPENAME;
632
- const metadata = resolve(typename);
633
- const serializer = metadata.serializer;
634
- invariant(serializer, `No serializer for type: ${typename}`, {
635
- F: __dxlog_file,
636
- L: 551,
637
- S: void 0,
638
- A: [
639
- "serializer",
640
- "`No serializer for type: ${typename}`"
641
- ]
642
- });
643
- const content = await serializer.serialize({
644
- object
645
- });
646
- return serializer.deserialize({
647
- content,
648
- space: newSpace,
649
- newId: true
650
- });
651
- };
652
-
653
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx
654
- var CreateObjectPanel = ({ schemas, spaces, typename: initialTypename, target: initialTarget, name: initialName, defaultSpaceId, resolve, onCreateObject }) => {
655
- const { t } = useTranslation2(SPACE_PLUGIN);
656
- const [typename, setTypename] = useState2(initialTypename);
657
- const [target, setTarget] = useState2(initialTarget);
658
- const schema = schemas.find((schema2) => getObjectAnnotation2(schema2)?.typename === typename);
659
- const options = schemas.map(getObjectAnnotation2).filter(nonNullable);
660
- const handleClearSchema = useCallback2(() => setTypename(void 0), []);
661
- const handleClearTarget = useCallback2(() => setTarget(void 0), []);
662
- const handleCreateObject = useCallback2(async ({ name }) => {
663
- if (!schema || !target) {
664
- return;
665
- }
666
- await onCreateObject?.({
667
- schema,
668
- target,
669
- name
670
- });
671
- }, [
672
- onCreateObject,
673
- schema,
674
- target
675
- ]);
676
- const schemaInput = /* @__PURE__ */ React2.createElement(SearchList.Root, {
677
- label: t("schema input label"),
678
- classNames: "flex flex-col grow overflow-hidden"
679
- }, /* @__PURE__ */ React2.createElement(SearchList.Input, {
680
- autoFocus: true,
681
- "data-testid": "create-object-form.schema-input",
682
- placeholder: t("schema input placeholder"),
683
- classNames: "px-1 my-2"
684
- }), /* @__PURE__ */ React2.createElement(SearchList.Content, {
685
- classNames: "max-bs-[24rem] overflow-auto"
686
- }, options.map((option) => /* @__PURE__ */ React2.createElement(SearchList.Item, {
687
- key: option.typename,
688
- value: t("typename label", {
689
- ns: option.typename,
690
- defaultValue: option.typename
175
+ icon: "ph--sliders--regular",
176
+ filter: (node) => isEchoObject(node.data) && !!getSpace(node.data)
177
+ })
691
178
  }),
692
- onSelect: () => setTypename(option.typename),
693
- classNames: "flex items-center gap-2"
694
- }, /* @__PURE__ */ React2.createElement("span", {
695
- className: "flex gap-2 items-center grow truncate"
696
- }, /* @__PURE__ */ React2.createElement(Icon, {
697
- icon: resolve?.(option.typename).icon ?? "ph--placeholder--regular",
698
- size: 5
699
- }), t("typename label", {
700
- ns: option.typename,
701
- defaultValue: option.typename
702
- }))))));
703
- const spaceInput = /* @__PURE__ */ React2.createElement(SearchList.Root, {
704
- label: t("space input label"),
705
- classNames: "flex flex-col grow overflow-hidden"
706
- }, /* @__PURE__ */ React2.createElement(SearchList.Input, {
707
- autoFocus: true,
708
- "data-testid": "create-object-form.space-input",
709
- placeholder: t("space input placeholder"),
710
- classNames: "px-1 my-2"
711
- }), /* @__PURE__ */ React2.createElement(SearchList.Content, {
712
- classNames: "max-bs-[24rem] overflow-auto"
713
- }, spaces.map((space) => /* @__PURE__ */ React2.createElement(SearchList.Item, {
714
- key: space.id,
715
- value: toLocalizedString(getSpaceDisplayName(space, {
716
- personal: space.id === defaultSpaceId
717
- }), t),
718
- onSelect: () => setTarget(space),
719
- classNames: "flex items-center gap-2"
720
- }, /* @__PURE__ */ React2.createElement("span", {
721
- className: "grow truncate"
722
- }, toLocalizedString(getSpaceDisplayName(space, {
723
- personal: space.id === defaultSpaceId
724
- }), t))))));
725
- const form = /* @__PURE__ */ React2.createElement(Form, {
726
- autoFocus: true,
727
- values: {
728
- name: initialName
729
- },
730
- schema: S.Struct({
731
- name: S.optional(S.String)
179
+ defineModule({
180
+ id: `${meta.id}/module/schema`,
181
+ activatesOn: ClientEvents.ClientReady,
182
+ activatesBefore: [
183
+ ClientEvents.SetupSchema
184
+ ],
185
+ activate: Schema
732
186
  }),
733
- testId: "create-object-form",
734
- onSave: handleCreateObject
735
- });
736
- return /* @__PURE__ */ React2.createElement("div", {
737
- role: "form",
738
- className: "flex flex-col gap-2"
739
- }, target && /* @__PURE__ */ React2.createElement("div", {
740
- role: "none"
741
- }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(InputHeader, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t(isSpace2(target) ? "creating in space label" : "creating in collection label"))), /* @__PURE__ */ React2.createElement("div", {
742
- role: "none",
743
- className: "flex gap-2"
744
- }, /* @__PURE__ */ React2.createElement(Input.TextInput, {
745
- disabled: true,
746
- value: isSpace2(target) ? toLocalizedString(getSpaceDisplayName(target, {
747
- personal: target.id === defaultSpaceId
748
- }), t) : target.name || t("unnamed collection label")
749
- }), /* @__PURE__ */ React2.createElement(IconButton, {
750
- iconOnly: true,
751
- icon: "ph--x--regular",
752
- label: t("clear input label"),
753
- onClick: handleClearTarget
754
- })))), schema && /* @__PURE__ */ React2.createElement("div", {
755
- role: "none"
756
- }, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(InputHeader, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("creating object type label"))), /* @__PURE__ */ React2.createElement("div", {
757
- role: "none",
758
- className: "flex gap-2"
759
- }, /* @__PURE__ */ React2.createElement(Input.TextInput, {
760
- disabled: true,
761
- value: t("typename label", {
762
- ns: schema.typename,
763
- defaultValue: schema.typename
764
- })
765
- }), /* @__PURE__ */ React2.createElement(IconButton, {
766
- iconOnly: true,
767
- icon: "ph--x--regular",
768
- label: t("clear input label"),
769
- onClick: handleClearSchema
770
- })))), !schema ? schemaInput : !target ? spaceInput : form);
771
- };
772
-
773
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
774
- var CREATE_OBJECT_DIALOG = `${SPACE_PLUGIN}/CreateObjectDialog`;
775
- var CreateObjectDialog = ({ schemas, target, typename, name, shouldNavigate: _shouldNavigate, resolve }) => {
776
- const closeRef = useRef(null);
777
- const { t } = useTranslation3(SPACE_PLUGIN);
778
- const client = useClient2();
779
- const spaces = useSpaces();
780
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
781
- const handleCreateObject = useCallback3(async ({ schema, target: _target, name: name2 }) => {
782
- const target2 = isSpace3(_target) ? _target.properties[CollectionType.typename]?.target : _target;
783
- const createObjectIntent = resolve?.(schema.typename)?.createObject;
784
- if (!createObjectIntent || !target2) {
785
- return;
786
- }
787
- closeRef.current?.click();
788
- const space = isSpace3(target2) ? target2 : getSpace2(target2);
789
- const result = await dispatch(createObjectIntent({
790
- name: name2,
791
- space
792
- }));
793
- const object = result.data?.object;
794
- if (isReactiveObject2(object)) {
795
- const addObjectIntent = createIntent3(SpaceAction.AddObject, {
796
- target: target2,
797
- object
798
- });
799
- const shouldNavigate = _shouldNavigate ?? (() => true);
800
- if (shouldNavigate(object)) {
801
- await dispatch(pipe(addObjectIntent, chain(NavigationAction3.Open, {})));
802
- } else {
803
- await dispatch(addObjectIntent);
804
- }
805
- }
806
- }, [
807
- dispatch,
808
- resolve
809
- ]);
810
- return (
811
- // TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
812
- // Consider factoring it out to the tabs package.
813
- /* @__PURE__ */ React3.createElement(Dialog.Content, {
814
- classNames: "p-0 bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
815
- }, /* @__PURE__ */ React3.createElement("div", {
816
- role: "none",
817
- className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
818
- }, /* @__PURE__ */ React3.createElement(Dialog.Title, null, t("create object dialog title")), /* @__PURE__ */ React3.createElement(Dialog.Close, {
819
- asChild: true
820
- }, /* @__PURE__ */ React3.createElement(Button2, {
821
- ref: closeRef,
822
- density: "fine",
823
- variant: "ghost",
824
- autoFocus: true
825
- }, /* @__PURE__ */ React3.createElement(Icon2, {
826
- icon: "ph--x--regular",
827
- size: 4
828
- })))), /* @__PURE__ */ React3.createElement("div", {
829
- className: "p-4"
830
- }, /* @__PURE__ */ React3.createElement(CreateObjectPanel, {
831
- schemas,
832
- spaces,
833
- target,
834
- typename,
835
- name,
836
- defaultSpaceId: client.spaces.default.id,
837
- resolve,
838
- onCreateObject: handleCreateObject
839
- })))
840
- );
841
- };
842
-
843
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateSpaceDialog.tsx
844
- import React4, { useCallback as useCallback4, useRef as useRef2 } from "react";
845
- import { createIntent as createIntent4, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
846
- import { Button as Button3, Dialog as Dialog2, Icon as Icon3, useTranslation as useTranslation4 } from "@dxos/react-ui";
847
- import { Form as Form2 } from "@dxos/react-ui-form";
848
- var CREATE_SPACE_DIALOG = `${SPACE_PLUGIN}/CreateSpaceDialog`;
849
- var initialValues = {
850
- edgeReplication: true
851
- };
852
- var CreateSpaceDialog = () => {
853
- const closeRef = useRef2(null);
854
- const { t } = useTranslation4(SPACE_PLUGIN);
855
- const { dispatchPromise: dispatch } = useIntentDispatcher3();
856
- const handleCreateSpace = useCallback4(async (data) => {
857
- const result = await dispatch(createIntent4(SpaceAction.Create, data));
858
- const target = result.data?.space;
859
- if (target) {
860
- await dispatch(createIntent4(SpaceAction.OpenCreateObject, {
861
- target
862
- }));
863
- }
864
- }, [
865
- dispatch
866
- ]);
867
- return (
868
- // TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
869
- // Consider factoring it out to the tabs package.
870
- /* @__PURE__ */ React4.createElement(Dialog2.Content, {
871
- classNames: "p-0 bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
872
- }, /* @__PURE__ */ React4.createElement("div", {
873
- role: "none",
874
- className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
875
- }, /* @__PURE__ */ React4.createElement(Dialog2.Title, null, t("create space dialog title")), /* @__PURE__ */ React4.createElement(Dialog2.Close, {
876
- asChild: true
877
- }, /* @__PURE__ */ React4.createElement(Button3, {
878
- ref: closeRef,
879
- density: "fine",
880
- variant: "ghost",
881
- autoFocus: true
882
- }, /* @__PURE__ */ React4.createElement(Icon3, {
883
- icon: "ph--x--regular",
884
- size: 4
885
- })))), /* @__PURE__ */ React4.createElement("div", {
886
- className: "p-4"
887
- }, /* @__PURE__ */ React4.createElement(Form2, {
888
- testId: "create-space-form",
889
- values: initialValues,
890
- schema: SpaceForm,
891
- onSave: handleCreateSpace
892
- })))
893
- );
894
- };
895
-
896
- // packages/plugins/plugin-space/src/components/CollectionMain.tsx
897
- import React5 from "react";
898
- import { useTranslation as useTranslation5 } from "@dxos/react-ui";
899
- import { baseSurface, descriptionText, mx as mx2 } from "@dxos/react-ui-theme";
900
- var CollectionMain = ({ collection }) => {
901
- const { t } = useTranslation5(SPACE_PLUGIN);
902
- return /* @__PURE__ */ React5.createElement("div", {
903
- role: "none",
904
- className: mx2(baseSurface, "min-bs-screen is-full flex items-center justify-center p-8"),
905
- "data-testid": "composer.firstRunMessage"
906
- }, /* @__PURE__ */ React5.createElement("p", {
907
- role: "alert",
908
- className: mx2(descriptionText, "border border-dashed border-neutral-400/50 rounded-lg p-8 font-normal text-lg max-is-[24rem] break-words")
909
- }, collection.name ?? t("unnamed collection label")));
910
- };
911
-
912
- // packages/plugins/plugin-space/src/components/CollectionSection.tsx
913
- import React6 from "react";
914
- import { useTranslation as useTranslation6 } from "@dxos/react-ui";
915
- var CollectionSection = ({ collection }) => {
916
- const { t } = useTranslation6(SPACE_PLUGIN);
917
- return /* @__PURE__ */ React6.createElement("div", {
918
- className: "min-bs-[3.5rem] grid grid-rows-subgrid grid-cols-subgrid items-center"
919
- }, /* @__PURE__ */ React6.createElement("span", {
920
- className: "truncate"
921
- }, collection.name ?? t("unnamed collection label")));
922
- };
923
-
924
- // packages/plugins/plugin-space/src/components/DefaultObjectSettings.tsx
925
- import React7 from "react";
926
- import { Input as Input2, useTranslation as useTranslation7 } from "@dxos/react-ui";
927
- var DefaultObjectSettings = ({ object }) => {
928
- const { t } = useTranslation7(SPACE_PLUGIN);
929
- return /* @__PURE__ */ React7.createElement("div", {
930
- role: "form",
931
- className: "flex flex-col w-full p-2 gap-1"
932
- }, /* @__PURE__ */ React7.createElement(Input2.Root, null, /* @__PURE__ */ React7.createElement(Input2.Label, null, t("name label")), /* @__PURE__ */ React7.createElement(Input2.TextInput, {
933
- placeholder: t("name placeholder"),
934
- value: object.name ?? "",
935
- onChange: (event) => {
936
- object.name = event.target.value;
937
- }
938
- })));
939
- };
940
-
941
- // packages/plugins/plugin-space/src/components/JoinDialog.tsx
942
- import React8, { useCallback as useCallback5 } from "react";
943
- import { createIntent as createIntent5, LayoutAction, NavigationAction as NavigationAction4, useIntentDispatcher as useIntentDispatcher4 } from "@dxos/app-framework";
944
- import { useGraph } from "@dxos/plugin-graph";
945
- import { ObservabilityAction } from "@dxos/plugin-observability/types";
946
- import { useSpaces as useSpaces2 } from "@dxos/react-client/echo";
947
- import { Dialog as Dialog3, useTranslation as useTranslation8 } from "@dxos/react-ui";
948
- import { JoinPanel } from "@dxos/shell/react";
949
- var JOIN_DIALOG = `${SPACE_PLUGIN}/JoinDialog`;
950
- var JoinDialog = ({ navigableCollections, onDone, ...props }) => {
951
- const { t } = useTranslation8(SPACE_PLUGIN);
952
- const { dispatchPromise: dispatch } = useIntentDispatcher4();
953
- const spaces = useSpaces2();
954
- const { graph } = useGraph();
955
- const handleDone = useCallback5(async (result) => {
956
- if (result?.spaceKey) {
957
- await Promise.all([
958
- dispatch(createIntent5(LayoutAction.SetLayout, {
959
- element: "toast",
960
- subject: {
961
- id: `${SPACE_PLUGIN}/join-success`,
962
- duration: 5e3,
963
- title: t("join success label"),
964
- closeLabel: t("dismiss label")
965
- }
966
- })),
967
- dispatch(createIntent5(LayoutAction.SetLayout, {
968
- element: "dialog",
969
- state: false
970
- }))
971
- ]);
972
- }
973
- const space = spaces.find(({ key }) => result?.spaceKey?.equals(key));
974
- const target = result?.target || (navigableCollections ? space?.id : void 0);
975
- if (target) {
976
- await graph.waitForPath({
977
- target
978
- }).catch(() => {
979
- });
980
- await Promise.all([
981
- dispatch(createIntent5(NavigationAction4.Open, {
982
- activeParts: {
983
- main: [
984
- target
985
- ]
986
- }
987
- })),
988
- dispatch(createIntent5(NavigationAction4.Expose, {
989
- id: target
990
- }))
991
- ]);
992
- }
993
- await onDone?.(result);
994
- if (space) {
995
- await dispatch(createIntent5(ObservabilityAction.SendEvent, {
996
- name: "space.join",
997
- properties: {
998
- spaceId: space.id
999
- }
1000
- }));
1001
- }
1002
- }, [
1003
- dispatch,
1004
- spaces
1005
- ]);
1006
- return /* @__PURE__ */ React8.createElement(Dialog3.Content, null, /* @__PURE__ */ React8.createElement(JoinPanel, {
1007
- ...props,
1008
- exitActionParent: /* @__PURE__ */ React8.createElement(Dialog3.Close, {
1009
- asChild: true
187
+ defineModule({
188
+ id: `${meta.id}/module/react-root`,
189
+ activatesOn: Events.Startup,
190
+ activate: ReactRoot
1010
191
  }),
1011
- doneActionParent: /* @__PURE__ */ React8.createElement(Dialog3.Close, {
1012
- asChild: true
192
+ defineModule({
193
+ id: `${meta.id}/module/react-surface`,
194
+ activatesOn: Events.SetupReactSurface,
195
+ // TODO(wittjosiah): Should occur before the settings dialog is loaded when surfaces activation is more granular.
196
+ activatesBefore: [
197
+ SpaceEvents.SetupSettingsPanel
198
+ ],
199
+ activate: () => ReactSurface({
200
+ createInvitationUrl
201
+ })
1013
202
  }),
1014
- onDone: handleDone
1015
- }));
1016
- };
1017
-
1018
- // packages/plugins/plugin-space/src/components/MenuFooter.tsx
1019
- import { Planet } from "@phosphor-icons/react";
1020
- import React9 from "react";
1021
- import { getSpace as getSpace3 } from "@dxos/client/echo";
1022
- import { useClient as useClient3 } from "@dxos/react-client";
1023
- import { DropdownMenu, toLocalizedString as toLocalizedString2, useTranslation as useTranslation9 } from "@dxos/react-ui";
1024
- var MenuFooter = ({ object }) => {
1025
- const { t } = useTranslation9(SPACE_PLUGIN);
1026
- const client = useClient3();
1027
- const space = getSpace3(object);
1028
- const spaceName = space ? getSpaceDisplayName(space, {
1029
- personal: client.spaces.default === space
1030
- }) : "";
1031
- return space ? /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(DropdownMenu.Separator, null), /* @__PURE__ */ React9.createElement(DropdownMenu.GroupLabel, null, t("menu footer label")), /* @__PURE__ */ React9.createElement("dl", {
1032
- className: "pis-2 mbe-2 text-xs grid grid-cols-[max-content_1fr] gap-2"
1033
- }, /* @__PURE__ */ React9.createElement("dt", {
1034
- className: "uppercase text-[.75em] tracking-wide font-medium mbs-px self-start"
1035
- }, t("location label")), /* @__PURE__ */ React9.createElement("dd", {
1036
- className: "line-clamp-3"
1037
- }, /* @__PURE__ */ React9.createElement(Planet, {
1038
- className: "inline-block mie-1"
1039
- }), toLocalizedString2(spaceName, t)))) : null;
1040
- };
1041
-
1042
- // packages/plugins/plugin-space/src/components/PersistenceStatus.tsx
1043
- import { ArrowsCounterClockwise, CheckCircle as CheckCircle2, Warning } from "@phosphor-icons/react";
1044
- import React10, { useEffect as useEffect2, useState as useState3 } from "react";
1045
- import { debounce } from "@dxos/async";
1046
- import { Tooltip, useTranslation as useTranslation10 } from "@dxos/react-ui";
1047
- import { getSize as getSize2, mx as mx3, staticPlaceholderText, warningText } from "@dxos/react-ui-theme";
1048
- var Status;
1049
- (function(Status2) {
1050
- Status2[Status2["PERSISTED_LOCALLY"] = 0] = "PERSISTED_LOCALLY";
1051
- Status2[Status2["PENDING"] = 1] = "PENDING";
1052
- Status2[Status2["ERROR"] = 2] = "ERROR";
1053
- })(Status || (Status = {}));
1054
- var PersistenceStatus = ({ db }) => {
1055
- const { t } = useTranslation10(SPACE_PLUGIN);
1056
- const [displayMessage, setDisplayMessage] = useState3(false);
1057
- const [status, naturalSetStatus] = useState3(0);
1058
- const [prevStatus, setPrevStatus] = useState3(0);
1059
- const _setStatus = debounce(naturalSetStatus, 500);
1060
- useEffect2(() => {
1061
- setPrevStatus(status);
1062
- if (prevStatus !== status && status === 0) {
1063
- setDisplayMessage(true);
1064
- const timeout = setTimeout(() => setDisplayMessage(false), 5e3);
1065
- return () => clearTimeout(timeout);
1066
- }
1067
- }, [
1068
- status
1069
- ]);
1070
- switch (status) {
1071
- case 2:
1072
- return /* @__PURE__ */ React10.createElement("div", {
1073
- className: "flex items-center"
1074
- }, /* @__PURE__ */ React10.createElement(Warning, {
1075
- className: mx3(getSize2(4), "me-1")
1076
- }), /* @__PURE__ */ React10.createElement("span", {
1077
- className: mx3("text-sm", warningText)
1078
- }, t("persistence error label")));
1079
- case 1:
1080
- return /* @__PURE__ */ React10.createElement("div", {
1081
- className: "flex items-center"
1082
- }, /* @__PURE__ */ React10.createElement(ArrowsCounterClockwise, {
1083
- className: mx3(getSize2(4), "me-1")
1084
- }), /* @__PURE__ */ React10.createElement("span", {
1085
- className: mx3("text-sm", staticPlaceholderText)
1086
- }, t("persistence pending label")));
1087
- case 0:
1088
- default:
1089
- return /* @__PURE__ */ React10.createElement(Tooltip.Root, {
1090
- delayDuration: 400
1091
- }, /* @__PURE__ */ React10.createElement(Tooltip.Trigger, {
1092
- role: "status",
1093
- className: "flex items-center"
1094
- }, /* @__PURE__ */ React10.createElement(CheckCircle2, {
1095
- className: mx3(getSize2(4), "me-1")
1096
- }), displayMessage && /* @__PURE__ */ React10.createElement("span", {
1097
- className: mx3("text-sm", staticPlaceholderText)
1098
- }, t("persisted locally label"))), /* @__PURE__ */ React10.createElement(Tooltip.Portal, null, /* @__PURE__ */ React10.createElement(Tooltip.Content, null, t("persisted locally message"), /* @__PURE__ */ React10.createElement(Tooltip.Arrow, null))));
1099
- }
1100
- };
1101
-
1102
- // packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx
1103
- import React11, { useCallback as useCallback6, useRef as useRef3, useState as useState4 } from "react";
1104
- import { log } from "@dxos/log";
1105
- import { Button as Button4, Input as Input3, Popover, useTranslation as useTranslation11 } from "@dxos/react-ui";
1106
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx";
1107
- var POPOVER_RENAME_OBJECT = `${SPACE_PLUGIN}/PopoverRenameObject`;
1108
- var PopoverRenameObject = ({ object: obj }) => {
1109
- const { t } = useTranslation11(SPACE_PLUGIN);
1110
- const doneButton = useRef3(null);
1111
- const object = obj;
1112
- const [name, setName] = useState4(object.name || object.title || "");
1113
- const handleDone = useCallback6(() => {
1114
- try {
1115
- object.name = name;
1116
- } catch {
1117
- try {
1118
- object.title = name;
1119
- } catch (err) {
1120
- log.error("Failed to rename object", {
1121
- err
1122
- }, {
1123
- F: __dxlog_file2,
1124
- L: 30,
1125
- S: void 0,
1126
- C: (f, a) => f(...a)
1127
- });
1128
- }
1129
- }
1130
- }, [
1131
- object,
1132
- name
1133
- ]);
1134
- return /* @__PURE__ */ React11.createElement("div", {
1135
- role: "none",
1136
- className: "p-1 flex gap-2"
1137
- }, /* @__PURE__ */ React11.createElement("div", {
1138
- role: "none",
1139
- className: "flex-1"
1140
- }, /* @__PURE__ */ React11.createElement(Input3.Root, null, /* @__PURE__ */ React11.createElement(Input3.Label, {
1141
- srOnly: true
1142
- }, t("object name label")), /* @__PURE__ */ React11.createElement(Input3.TextInput, {
1143
- placeholder: t("object title placeholder"),
1144
- value: name,
1145
- "data-testid": "spacePlugin.renameObject.input",
1146
- onChange: ({ target: { value } }) => setName(value),
1147
- onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
1148
- }))), /* @__PURE__ */ React11.createElement(Popover.Close, {
1149
- asChild: true
1150
- }, /* @__PURE__ */ React11.createElement(Button4, {
1151
- ref: doneButton,
1152
- classNames: "self-stretch",
1153
- onClick: handleDone
1154
- }, t("done label", {
1155
- ns: "os"
1156
- }))));
1157
- };
1158
-
1159
- // packages/plugins/plugin-space/src/components/PopoverRenameSpace.tsx
1160
- import React12, { useCallback as useCallback7, useRef as useRef4, useState as useState5 } from "react";
1161
- import { Button as Button5, Input as Input4, Popover as Popover2, useTranslation as useTranslation12 } from "@dxos/react-ui";
1162
- var POPOVER_RENAME_SPACE = `${SPACE_PLUGIN}/PopoverRenameSpace`;
1163
- var PopoverRenameSpace = ({ space }) => {
1164
- const { t } = useTranslation12(SPACE_PLUGIN);
1165
- const doneButton = useRef4(null);
1166
- const [name, setName] = useState5(space.properties.name ?? "");
1167
- const handleDone = useCallback7(() => {
1168
- space.properties.name = name;
1169
- }, [
1170
- space,
1171
- name
1172
- ]);
1173
- return /* @__PURE__ */ React12.createElement("div", {
1174
- role: "none",
1175
- className: "p-1 flex gap-2"
1176
- }, /* @__PURE__ */ React12.createElement("div", {
1177
- role: "none",
1178
- className: "flex-1"
1179
- }, /* @__PURE__ */ React12.createElement(Input4.Root, null, /* @__PURE__ */ React12.createElement(Input4.Label, {
1180
- srOnly: true
1181
- }, t("space name label")), /* @__PURE__ */ React12.createElement(Input4.TextInput, {
1182
- defaultValue: space.properties.name ?? "",
1183
- placeholder: t("unnamed space label"),
1184
- onChange: ({ target: { value } }) => setName(value),
1185
- // TODO(wittjosiah): Ideally this should access the popover context to close the popover.
1186
- // Currently this is not possible because Radix does not expose the popover context.
1187
- onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
1188
- }))), /* @__PURE__ */ React12.createElement(Popover2.Close, {
1189
- asChild: true
1190
- }, /* @__PURE__ */ React12.createElement(Button5, {
1191
- ref: doneButton,
1192
- classNames: "self-stretch",
1193
- onClick: handleDone
1194
- }, t("done label", {
1195
- ns: "os"
1196
- }))));
1197
- };
1198
-
1199
- // packages/plugins/plugin-space/src/components/ShareSpaceButton.tsx
1200
- import React13 from "react";
1201
- import { createIntent as createIntent6, useIntentDispatcher as useIntentDispatcher5 } from "@dxos/app-framework";
1202
- import { IconButton as IconButton2, useTranslation as useTranslation13 } from "@dxos/react-ui";
1203
- var ShareSpaceButton = ({ space }) => {
1204
- const { dispatchPromise: dispatch } = useIntentDispatcher5();
1205
- return /* @__PURE__ */ React13.createElement(ShareSpaceButtonImpl, {
1206
- onClick: () => dispatch(createIntent6(SpaceAction.Share, {
1207
- space
1208
- }))
1209
- });
1210
- };
1211
- var ShareSpaceButtonImpl = ({ onClick }) => {
1212
- const { t } = useTranslation13(SPACE_PLUGIN);
1213
- return /* @__PURE__ */ React13.createElement(IconButton2, {
1214
- "data-testid": "spacePlugin.shareSpaceButton",
1215
- icon: "ph--users--regular",
1216
- label: t("share space label"),
1217
- onClick
1218
- });
1219
- };
1220
-
1221
- // packages/plugins/plugin-space/src/components/SpacePresence.tsx
1222
- import React14, { useCallback as useCallback8, useEffect as useEffect4, useState as useState7 } from "react";
1223
- import { usePlugin } from "@dxos/app-framework";
1224
- import { generateName } from "@dxos/display-name";
1225
- import { useGraph as useGraph2 } from "@dxos/plugin-graph";
1226
- import { PublicKey, useClient as useClient4 } from "@dxos/react-client";
1227
- import { getSpace as getSpace4, useMembers, fullyQualifiedId as fullyQualifiedId3 } from "@dxos/react-client/echo";
1228
- import { useIdentity } from "@dxos/react-client/halo";
1229
- import { Avatar, AvatarGroup, AvatarGroupItem, Tooltip as Tooltip2, useTranslation as useTranslation14, List, ListItem, useDefaultValue } from "@dxos/react-ui";
1230
- import { AttentionGlyph, useAttended, useAttention } from "@dxos/react-ui-attention";
1231
- import { ComplexMap, keyToFallback } from "@dxos/util";
1232
-
1233
- // packages/plugins/plugin-space/src/hooks/usePath.ts
1234
- import { useEffect as useEffect3, useState as useState6 } from "react";
1235
- var usePath = (graph, id, timeout) => {
1236
- const [pathState, setPathState] = useState6(id ? graph.getPath({
1237
- target: id
1238
- }) : void 0);
1239
- useEffect3(() => {
1240
- if (!id && pathState) {
1241
- setPathState(void 0);
1242
- }
1243
- if (pathState?.at(-1) === id || !id) {
1244
- return;
1245
- }
1246
- const frame = requestAnimationFrame(async () => {
1247
- try {
1248
- const path = await graph.waitForPath({
1249
- target: id
1250
- }, {
1251
- timeout
1252
- });
1253
- if (path) {
1254
- setPathState(path);
1255
- }
1256
- } catch {
1257
- }
1258
- });
1259
- return () => cancelAnimationFrame(frame);
1260
- }, [
1261
- graph,
1262
- id,
1263
- timeout,
1264
- pathState
1265
- ]);
1266
- return pathState;
1267
- };
1268
-
1269
- // packages/plugins/plugin-space/src/components/SpacePresence.tsx
1270
- var REFRESH_INTERVAL = 5e3;
1271
- var ACTIVITY_DURATION = 3e4;
1272
- var noViewers = new ComplexMap(PublicKey.hash);
1273
- var getName = (identity) => identity.profile?.displayName ?? generateName(identity.identityKey.toHex());
1274
- var SpacePresence = ({ object, spaceKey }) => {
1275
- const spacePlugin = usePlugin(SPACE_PLUGIN);
1276
- const client = useClient4();
1277
- const identity = useIdentity();
1278
- const space = spaceKey ? client.spaces.get(spaceKey) : getSpace4(object);
1279
- const spaceMembers = useMembers(space?.key);
1280
- const [_moment, setMoment] = useState7(Date.now());
1281
- useEffect4(() => {
1282
- const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
1283
- return () => clearInterval(interval);
1284
- }, []);
1285
- const memberOnline = useCallback8((member) => member.presence === 1, []);
1286
- const memberIsNotSelf = useCallback8((member) => !identity?.identityKey.equals(member.identity.identityKey), [
1287
- identity?.identityKey
1288
- ]);
1289
- if (!identity || !spacePlugin || !space) {
1290
- return null;
1291
- }
1292
- const spaceState = spacePlugin.provides.space;
1293
- const currentObjectViewers = spaceState.viewersByObject[fullyQualifiedId3(object)] ?? noViewers;
1294
- const membersForObject = spaceMembers.filter((member) => memberOnline(member) && memberIsNotSelf(member)).filter((member) => currentObjectViewers.has(member.identity.identityKey)).map((member) => {
1295
- const objectView = currentObjectViewers.get(member.identity.identityKey);
1296
- const lastSeen = objectView?.lastSeen ?? -Infinity;
1297
- const currentlyAttended = objectView?.currentlyAttended ?? false;
1298
- return {
1299
- ...member,
1300
- currentlyAttended,
1301
- lastSeen
1302
- };
1303
- }).toSorted((a, b) => a.lastSeen - b.lastSeen);
1304
- return /* @__PURE__ */ React14.createElement(FullPresence, {
1305
- members: membersForObject
1306
- });
1307
- };
1308
- var FullPresence = (props) => {
1309
- const { size = 9, onMemberClick } = props;
1310
- const members = useDefaultValue(props.members, () => []);
1311
- if (members.length === 0) {
1312
- return null;
1313
- }
1314
- return /* @__PURE__ */ React14.createElement(AvatarGroup.Root, {
1315
- size,
1316
- classNames: "mbs-2 mie-4",
1317
- "data-testid": "spacePlugin.presence"
1318
- }, members.slice(0, 3).map((member, i) => /* @__PURE__ */ React14.createElement(Tooltip2.Root, {
1319
- key: member.identity.identityKey.toHex()
1320
- }, /* @__PURE__ */ React14.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React14.createElement(PrensenceAvatar, {
1321
- identity: member.identity,
1322
- group: true,
1323
- match: member.currentlyAttended,
1324
- index: members.length - i,
1325
- onClick: () => onMemberClick?.(member)
1326
- })), /* @__PURE__ */ React14.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React14.createElement(Tooltip2.Content, {
1327
- side: "bottom"
1328
- }, /* @__PURE__ */ React14.createElement("span", null, getName(member.identity)), /* @__PURE__ */ React14.createElement(Tooltip2.Arrow, null))))), members.length > 3 && /* @__PURE__ */ React14.createElement(Tooltip2.Root, null, /* @__PURE__ */ React14.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React14.createElement(AvatarGroupItem.Root, {
1329
- status: "inactive"
1330
- }, /* @__PURE__ */ React14.createElement(Avatar.Frame, {
1331
- style: {
1332
- zIndex: members.length - 4
1333
- }
1334
- }, /* @__PURE__ */ React14.createElement(Avatar.Fallback, {
1335
- text: `+${members.length - 3}`
1336
- })))), /* @__PURE__ */ React14.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React14.createElement(Tooltip2.Content, {
1337
- side: "bottom"
1338
- }, /* @__PURE__ */ React14.createElement(Tooltip2.Arrow, null), /* @__PURE__ */ React14.createElement(List, {
1339
- classNames: "max-h-56 overflow-y-auto"
1340
- }, members.map((member) => /* @__PURE__ */ React14.createElement(ListItem.Root, {
1341
- key: member.identity.identityKey.toHex(),
1342
- classNames: "flex gap-2 items-center cursor-pointer mbe-2",
1343
- onClick: () => onMemberClick?.(member),
1344
- "data-testid": "identity-list-item"
1345
- }, /* @__PURE__ */ React14.createElement(PrensenceAvatar, {
1346
- identity: member.identity,
1347
- showName: true,
1348
- match: member.currentlyAttended
1349
- }))))))));
1350
- };
1351
- var PrensenceAvatar = ({ identity, showName, match, group, index, onClick }) => {
1352
- const Root = group ? AvatarGroupItem.Root : Avatar.Root;
1353
- const status = match ? "current" : "active";
1354
- const fallbackValue = keyToFallback(identity.identityKey);
1355
- return /* @__PURE__ */ React14.createElement(Root, {
1356
- status,
1357
- hue: identity.profile?.data?.hue || fallbackValue.hue
1358
- }, /* @__PURE__ */ React14.createElement(Avatar.Frame, {
1359
- "data-testid": "spacePlugin.presence.member",
1360
- "data-status": status,
1361
- ...index ? {
1362
- style: {
1363
- zIndex: index
1364
- }
1365
- } : {},
1366
- onClick: () => onClick?.()
1367
- }, /* @__PURE__ */ React14.createElement(Avatar.Fallback, {
1368
- text: identity.profile?.data?.emoji || fallbackValue.emoji
1369
- })), showName && /* @__PURE__ */ React14.createElement(Avatar.Label, {
1370
- classNames: "text-sm truncate pli-2"
1371
- }, getName(identity)));
1372
- };
1373
- var SmallPresenceLive = ({ id, open, viewers }) => {
1374
- const { hasAttention, isAncestor, isRelated } = useAttention(id);
1375
- const isAttended = hasAttention || isAncestor || isRelated;
1376
- const { graph } = useGraph2();
1377
- const attended = useAttended();
1378
- const startOfAttention = attended.at(-1);
1379
- const path = usePath(graph, startOfAttention);
1380
- const containsAttended = !open && !isAttended && id && path ? path.includes(id) : false;
1381
- const getActiveViewers = (viewers2) => {
1382
- const moment = Date.now();
1383
- return Array.from(viewers2.values()).filter((viewer) => moment - viewer.lastSeen < ACTIVITY_DURATION);
1384
- };
1385
- const [activeViewers, setActiveViewers] = useState7(viewers ? getActiveViewers(viewers) : []);
1386
- useEffect4(() => {
1387
- if (viewers) {
1388
- setActiveViewers(getActiveViewers(viewers));
1389
- const interval = setInterval(() => {
1390
- setActiveViewers(getActiveViewers(viewers));
1391
- }, REFRESH_INTERVAL);
1392
- return () => clearInterval(interval);
1393
- }
1394
- }, [
1395
- viewers
1396
- ]);
1397
- return /* @__PURE__ */ React14.createElement(SmallPresence, {
1398
- count: activeViewers.length,
1399
- attended: isAttended,
1400
- containsAttended
1401
- });
1402
- };
1403
- var SmallPresence = ({ count = 0, attended, containsAttended }) => {
1404
- const { t } = useTranslation14(SPACE_PLUGIN);
1405
- return /* @__PURE__ */ React14.createElement(Tooltip2.Root, null, /* @__PURE__ */ React14.createElement(Tooltip2.Trigger, {
1406
- asChild: true
1407
- }, /* @__PURE__ */ React14.createElement(AttentionGlyph, {
1408
- attended,
1409
- containsAttended,
1410
- presence: count > 1 ? "many" : count === 1 ? "one" : "none",
1411
- classNames: "self-center mie-1"
1412
- })), /* @__PURE__ */ React14.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React14.createElement(Tooltip2.Content, {
1413
- side: "bottom"
1414
- }, /* @__PURE__ */ React14.createElement("span", null, t("presence label", {
1415
- count
1416
- })), /* @__PURE__ */ React14.createElement(Tooltip2.Arrow, null))));
1417
- };
1418
-
1419
- // packages/plugins/plugin-space/src/components/SpacePluginSettings.tsx
1420
- import React15 from "react";
1421
- import { createIntent as createIntent7, useIntentDispatcher as useIntentDispatcher6 } from "@dxos/app-framework";
1422
- import { Input as Input5, useTranslation as useTranslation15 } from "@dxos/react-ui";
1423
- import { DeprecatedFormInput } from "@dxos/react-ui-form";
1424
- var SpacePluginSettings = ({ settings }) => {
1425
- const { t } = useTranslation15(SPACE_PLUGIN);
1426
- const { dispatchPromise: dispatch } = useIntentDispatcher6();
1427
- return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(DeprecatedFormInput, {
1428
- label: t("show hidden spaces label")
1429
- }, /* @__PURE__ */ React15.createElement(Input5.Switch, {
1430
- checked: settings.showHidden,
1431
- onCheckedChange: (checked) => dispatch(createIntent7(SpaceAction.ToggleHidden, {
1432
- state: !!checked
1433
- }))
1434
- })));
1435
- };
1436
-
1437
- // packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsDialog.tsx
1438
- import React17, { useState as useState9 } from "react";
1439
- import { useClient as useClient6 } from "@dxos/react-client";
1440
- import { Button as Button6, Clipboard, Dialog as Dialog4, Icon as Icon4, toLocalizedString as toLocalizedString3, useTranslation as useTranslation17 } from "@dxos/react-ui";
1441
- import { Tabs } from "@dxos/react-ui-tabs";
1442
- import { SpacePanel } from "@dxos/shell/react";
1443
-
1444
- // packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsPanel.tsx
1445
- import React16, { useCallback as useCallback9, useState as useState8 } from "react";
1446
- import { log as log2 } from "@dxos/log";
1447
- import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
1448
- import { useClient as useClient5 } from "@dxos/react-client";
1449
- import { Input as Input6, useTranslation as useTranslation16 } from "@dxos/react-ui";
1450
- import { DeprecatedFormInput as DeprecatedFormInput2 } from "@dxos/react-ui-form";
1451
- import { mx as mx4 } from "@dxos/react-ui-theme";
1452
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsPanel.tsx";
1453
- var SpaceSettingsPanel = ({ classNames, space }) => {
1454
- const { t } = useTranslation16(SPACE_PLUGIN);
1455
- const client = useClient5();
1456
- const edgeEnabled = Boolean(client.config.values.runtime?.client?.edgeFeatures?.echoReplicator);
1457
- const [edgeReplication, setEdgeReplication] = useState8(space.internal.data.edgeReplication === EdgeReplicationSetting.ENABLED);
1458
- const toggleEdgeReplication = useCallback9(async (next) => {
1459
- setEdgeReplication(next);
1460
- await space?.internal.setEdgeReplicationPreference(next ? EdgeReplicationSetting.ENABLED : EdgeReplicationSetting.DISABLED).catch((err) => {
1461
- log2.catch(err, void 0, {
1462
- F: __dxlog_file3,
1463
- L: 36,
1464
- S: void 0,
1465
- C: (f, a) => f(...a)
1466
- });
1467
- setEdgeReplication(!next);
1468
- });
1469
- }, [
1470
- space
1471
- ]);
1472
- return /* @__PURE__ */ React16.createElement("div", {
1473
- role: "form",
1474
- className: mx4("flex flex-col", classNames)
1475
- }, /* @__PURE__ */ React16.createElement(DeprecatedFormInput2, {
1476
- label: t("name label")
1477
- }, /* @__PURE__ */ React16.createElement(Input6.TextInput, {
1478
- placeholder: t("unnamed space label"),
1479
- value: space.properties.name ?? "",
1480
- onChange: (event) => {
1481
- space.properties.name = event.target.value;
1482
- }
1483
- })), edgeEnabled && /* @__PURE__ */ React16.createElement(DeprecatedFormInput2, {
1484
- label: t("edge replication label")
1485
- }, /* @__PURE__ */ React16.createElement(Input6.Switch, {
1486
- checked: edgeReplication,
1487
- onCheckedChange: toggleEdgeReplication
1488
- })));
1489
- };
1490
-
1491
- // packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsDialog.tsx
1492
- var SPACE_SETTINGS_DIALOG = `${SPACE_PLUGIN}/SpaceSettingsDialog`;
1493
- var SpaceSettingsDialog = ({ space, target, createInvitationUrl, initialTab = "members", namesCache }) => {
1494
- const { t } = useTranslation17(SPACE_PLUGIN);
1495
- const client = useClient6();
1496
- const [tabsActivePart, setTabsActivePart] = useState9("list");
1497
- const [selected, setSelected] = useState9(initialTab);
1498
- const locked = space.properties[COMPOSER_SPACE_LOCK];
1499
- const name = getSpaceDisplayName(space, {
1500
- personal: client.spaces.default === space,
1501
- namesCache
1502
- });
1503
- return (
1504
- // TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
1505
- // Consider factoring it out to the tabs package.
1506
- /* @__PURE__ */ React17.createElement(Dialog4.Content, {
1507
- classNames: "p-0 bs-content min-bs-[15rem] max-bs-full md:max-is-[40rem] overflow-hidden"
1508
- }, /* @__PURE__ */ React17.createElement("div", {
1509
- role: "none",
1510
- className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
1511
- }, /* @__PURE__ */ React17.createElement(Dialog4.Title, {
1512
- onClick: () => setTabsActivePart("list"),
1513
- "aria-description": t("click to return to tablist description"),
1514
- classNames: "flex cursor-pointer items-center group/title"
1515
- }, /* @__PURE__ */ React17.createElement(Icon4, {
1516
- icon: "ph--caret-left--regular",
1517
- size: 4,
1518
- classNames: [
1519
- "@md:hidden",
1520
- tabsActivePart === "list" && "invisible"
1521
- ]
1522
- }), /* @__PURE__ */ React17.createElement("span", {
1523
- className: tabsActivePart !== "list" ? "group-hover/title:underline @md:group-hover/title:no-underline underline-offset-4 decoration-1" : ""
1524
- }, toLocalizedString3(name, t))), /* @__PURE__ */ React17.createElement(Dialog4.Close, {
1525
- asChild: true
1526
- }, /* @__PURE__ */ React17.createElement(Button6, {
1527
- density: "fine",
1528
- variant: "ghost",
1529
- autoFocus: true
1530
- }, /* @__PURE__ */ React17.createElement(Icon4, {
1531
- icon: "ph--x--regular",
1532
- size: 4
1533
- })))), /* @__PURE__ */ React17.createElement(Tabs.Root, {
1534
- orientation: "vertical",
1535
- value: selected,
1536
- onValueChange: setSelected,
1537
- activePart: tabsActivePart,
1538
- onActivePartChange: setTabsActivePart,
1539
- classNames: "flex flex-col flex-1 mbs-2"
1540
- }, /* @__PURE__ */ React17.createElement(Tabs.Viewport, {
1541
- classNames: "flex-1 min-bs-0"
1542
- }, /* @__PURE__ */ React17.createElement("div", {
1543
- role: "none",
1544
- className: "overflow-y-auto pli-3 @md:pis-2 @md:pie-0 mbe-4 border-r border-separator"
1545
- }, /* @__PURE__ */ React17.createElement(Tabs.Tablist, {
1546
- classNames: "flex flex-col max-bs-none min-is-[200px] gap-4 overflow-y-auto"
1547
- }, /* @__PURE__ */ React17.createElement("div", {
1548
- role: "none",
1549
- className: "flex flex-col ml-1"
1550
- }, /* @__PURE__ */ React17.createElement(Tabs.Tab, {
1551
- value: "settings"
1552
- }, t("settings tab label")), /* @__PURE__ */ React17.createElement(Tabs.Tab, {
1553
- value: "members",
1554
- disabled: locked
1555
- }, t("members tab label"))))), /* @__PURE__ */ React17.createElement(Tabs.Tabpanel, {
1556
- value: "settings",
1557
- classNames: "pli-3 @md:pli-5 max-bs-dvh overflow-y-auto"
1558
- }, /* @__PURE__ */ React17.createElement(SpaceSettingsPanel, {
1559
- space
1560
- })), /* @__PURE__ */ React17.createElement(Tabs.Tabpanel, {
1561
- value: "members",
1562
- classNames: "pli-3 @md:pli-5 max-bs-dvh overflow-y-auto"
1563
- }, /* @__PURE__ */ React17.createElement(Clipboard.Provider, null, /* @__PURE__ */ React17.createElement(SpacePanel, {
1564
- space,
1565
- hideHeading: true,
1566
- target,
1567
- createInvitationUrl
1568
- }))))))
1569
- );
1570
- };
1571
-
1572
- // packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
1573
- import React18, { useEffect as useEffect6, useState as useState11 } from "react";
1574
- import { useGraph as useGraph3 } from "@dxos/plugin-graph";
1575
- import { QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
1576
- import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
1577
- import { useClient as useClient8 } from "@dxos/react-client";
1578
- import { Tooltip as Tooltip3, useTranslation as useTranslation18 } from "@dxos/react-ui";
1579
- import { AttentionGlyph as AttentionGlyph2, useAttended as useAttended2, useAttention as useAttention2 } from "@dxos/react-ui-attention";
1580
-
1581
- // packages/plugins/plugin-space/src/components/SyncStatus/sync-state.ts
1582
- import { useEffect as useEffect5, useState as useState10 } from "react";
1583
- import { Context } from "@dxos/context";
1584
- import { EdgeService } from "@dxos/protocols";
1585
- import { useClient as useClient7 } from "@dxos/react-client";
1586
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/sync-state.ts";
1587
- var createEmptyEdgeSyncState = () => ({
1588
- missingOnLocal: 0,
1589
- missingOnRemote: 0,
1590
- localDocumentCount: 0,
1591
- remoteDocumentCount: 0,
1592
- differentDocuments: 0
1593
- });
1594
- var getSyncSummary = (syncMap) => {
1595
- return Object.entries(syncMap).reduce((summary, [_spaceId, peerState]) => {
1596
- summary.missingOnLocal += peerState.missingOnLocal;
1597
- summary.missingOnRemote += peerState.missingOnRemote;
1598
- summary.localDocumentCount += peerState.localDocumentCount;
1599
- summary.remoteDocumentCount += peerState.remoteDocumentCount;
1600
- summary.differentDocuments += peerState.differentDocuments;
1601
- return summary;
1602
- }, createEmptyEdgeSyncState());
1603
- };
1604
- var isEdgePeerId = (peerId, spaceId) => peerId.startsWith(`${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}`);
1605
- var useSyncState = () => {
1606
- const client = useClient7();
1607
- const [spaceState, setSpaceState] = useState10({});
1608
- useEffect5(() => {
1609
- const ctx = new Context(void 0, {
1610
- F: __dxlog_file4,
1611
- L: 48
1612
- });
1613
- const createSubscriptions = (spaces) => {
1614
- for (const space of spaces) {
1615
- if (spaceState[space.id]) {
1616
- continue;
1617
- }
1618
- ctx.onDispose(space.crud.subscribeToSyncState(ctx, ({ peers = [] }) => {
1619
- const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
1620
- if (syncState) {
1621
- setSpaceState((spaceState2) => ({
1622
- ...spaceState2,
1623
- [space.id]: syncState
1624
- }));
1625
- }
1626
- }));
1627
- }
1628
- };
1629
- createSubscriptions(client.spaces.get());
1630
- client.spaces.subscribe((spaces) => {
1631
- createSubscriptions(spaces);
1632
- });
1633
- return () => {
1634
- void ctx.dispose();
1635
- };
1636
- }, [
1637
- client
1638
- ]);
1639
- return spaceState;
1640
- };
1641
- var useSpaceSyncState = (space) => {
1642
- const [spaceState, setSpaceState] = useState10();
1643
- useEffect5(() => {
1644
- const ctx = new Context(void 0, {
1645
- F: __dxlog_file4,
1646
- L: 87
1647
- });
1648
- space.crud.subscribeToSyncState(ctx, ({ peers = [] }) => {
1649
- const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
1650
- if (syncState) {
1651
- setSpaceState(syncState);
1652
- }
1653
- });
1654
- return () => {
1655
- void ctx.dispose();
1656
- };
1657
- }, [
1658
- space
1659
- ]);
1660
- return spaceState;
1661
- };
1662
-
1663
- // packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
1664
- var useEdgeStatus = () => {
1665
- const [status, setStatus] = useState11(QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED);
1666
- const client = useClient8();
1667
- useEffect6(() => {
1668
- client.services.services.EdgeAgentService?.queryEdgeStatus().subscribe(({ status: status2 }) => {
1669
- setStatus(status2);
1670
- });
1671
- }, [
1672
- client
1673
- ]);
1674
- return status;
1675
- };
1676
- var InlineSyncStatus = ({ space, open }) => {
1677
- const { t } = useTranslation18(SPACE_PLUGIN);
1678
- const id = space.id;
1679
- const { hasAttention, isAncestor, isRelated } = useAttention2(id);
1680
- const isAttended = hasAttention || isAncestor || isRelated;
1681
- const { graph } = useGraph3();
1682
- const attended = useAttended2();
1683
- const startOfAttention = attended.at(-1);
1684
- const path = usePath(graph, startOfAttention);
1685
- const containsAttended = !open && !isAttended && id && path ? path.includes(id) : false;
1686
- const connectedToEdge = useEdgeStatus() === QueryEdgeStatusResponse.EdgeStatus.CONNECTED;
1687
- const edgeSyncEnabled = space.internal.data.edgeReplication === EdgeReplicationSetting2.ENABLED;
1688
- const syncState = useSpaceSyncState(space);
1689
- const syncing = connectedToEdge && edgeSyncEnabled && syncState && syncState.missingOnLocal > 0;
1690
- return /* @__PURE__ */ React18.createElement(Tooltip3.Root, null, /* @__PURE__ */ React18.createElement(Tooltip3.Trigger, {
1691
- asChild: true
1692
- }, /* @__PURE__ */ React18.createElement(AttentionGlyph2, {
1693
- syncing,
1694
- attended: isAttended,
1695
- containsAttended,
1696
- classNames: "self-center mie-1"
1697
- })), /* @__PURE__ */ React18.createElement(Tooltip3.Portal, null, /* @__PURE__ */ React18.createElement(Tooltip3.Content, {
1698
- side: "bottom",
1699
- classNames: "z-[70]"
1700
- }, /* @__PURE__ */ React18.createElement("span", null, t("syncing label")), /* @__PURE__ */ React18.createElement(Tooltip3.Arrow, null))));
1701
- };
1702
-
1703
- // packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
1704
- import React20, { useCallback as useCallback10, useEffect as useEffect8, useState as useState13 } from "react";
1705
- import { StatusBar } from "@dxos/plugin-status-bar";
1706
- import { useClient as useClient10 } from "@dxos/react-client";
1707
- import { Icon as Icon6, Input as Input7, Popover as Popover3, useTranslation as useTranslation20 } from "@dxos/react-ui";
1708
- import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
1709
- import { mx as mx6 } from "@dxos/react-ui-theme";
1710
-
1711
- // packages/plugins/plugin-space/src/components/SyncStatus/Space.tsx
1712
- import React19, { useEffect as useEffect7, useState as useState12 } from "react";
1713
- import { useClient as useClient9 } from "@dxos/react-client";
1714
- import { useSpace } from "@dxos/react-client/echo";
1715
- import { Icon as Icon5, toLocalizedString as toLocalizedString4, useTranslation as useTranslation19 } from "@dxos/react-ui";
1716
- import { mx as mx5 } from "@dxos/react-ui-theme";
1717
- var SYNC_STALLED_TIMEOUT = 5e3;
1718
- var styles = {
1719
- barBg: "bg-neutral-50 dark:bg-green-900 text-black",
1720
- barFg: "bg-neutral-100 bg-green-500",
1721
- barHover: "dark:hover:bg-green-500"
1722
- };
1723
- var useActive = (count) => {
1724
- const [current, setCurrent] = useState12(count);
1725
- const [active, setActive] = useState12(false);
1726
- useEffect7(() => {
1727
- let t;
1728
- if (count !== current) {
1729
- setActive(true);
1730
- setCurrent(count);
1731
- t && clearTimeout(t);
1732
- t = setTimeout(() => {
1733
- setActive(false);
1734
- }, SYNC_STALLED_TIMEOUT);
1735
- }
1736
- return () => {
1737
- setActive(false);
1738
- clearTimeout(t);
1739
- };
1740
- }, [
1741
- count,
1742
- current
1743
- ]);
1744
- return active;
1745
- };
1746
- var SpaceRowContainer = ({ spaceId, state }) => {
1747
- const { t } = useTranslation19(SPACE_PLUGIN);
1748
- const client = useClient9();
1749
- const space = useSpace(spaceId);
1750
- if (!space) {
1751
- return null;
1752
- }
1753
- const spaceName = toLocalizedString4(getSpaceDisplayName(space, {
1754
- personal: space === client.spaces.default
1755
- }), t);
1756
- return /* @__PURE__ */ React19.createElement(SpaceRow, {
1757
- spaceId,
1758
- spaceName,
1759
- state
1760
- });
1761
- };
1762
- var SpaceRow = ({ spaceId, spaceName, state: { localDocumentCount, remoteDocumentCount, missingOnLocal, missingOnRemote } }) => {
1763
- const downActive = useActive(localDocumentCount);
1764
- const upActive = useActive(remoteDocumentCount);
1765
- return /* @__PURE__ */ React19.createElement("div", {
1766
- className: "flex items-center mx-0.5 gap-0.5 cursor-pointer",
1767
- title: spaceId,
1768
- onClick: () => {
1769
- void navigator.clipboard.writeText(spaceId);
1770
- }
1771
- }, /* @__PURE__ */ React19.createElement("span", {
1772
- className: "is-1/2 truncate"
1773
- }, spaceName), /* @__PURE__ */ React19.createElement(Icon5, {
1774
- icon: "ph--arrow-fat-line-left--regular",
1775
- size: 3,
1776
- classNames: mx5(downActive && "animate-[pulse_1s_infinite]")
1777
- }), /* @__PURE__ */ React19.createElement(Candle, {
1778
- up: {
1779
- count: remoteDocumentCount,
1780
- total: remoteDocumentCount + missingOnRemote
1781
- },
1782
- down: {
1783
- count: localDocumentCount,
1784
- total: localDocumentCount + missingOnLocal
1785
- },
1786
- title: spaceId
1787
- }), /* @__PURE__ */ React19.createElement(Icon5, {
1788
- icon: "ph--arrow-fat-line-right--regular",
1789
- size: 3,
1790
- classNames: mx5(upActive && "animate-[pulse_1s_step-start_infinite]")
1791
- }));
1792
- };
1793
- var Candle = ({ classNames, up, down }) => {
1794
- return /* @__PURE__ */ React19.createElement("div", {
1795
- className: mx5("grid grid-cols-[1fr_2rem_1fr] w-full h-3", classNames)
1796
- }, /* @__PURE__ */ React19.createElement(Bar, {
1797
- classNames: "justify-end",
1798
- ...up
1799
- }), /* @__PURE__ */ React19.createElement("div", {
1800
- className: "relative"
1801
- }, /* @__PURE__ */ React19.createElement("div", {
1802
- className: mx5("absolute inset-0 flex items-center justify-center text-xs", styles.barBg)
1803
- }, up.total)), /* @__PURE__ */ React19.createElement(Bar, down));
1804
- };
1805
- var Bar = ({ classNames, count, total }) => {
1806
- let p = count / total * 100;
1807
- if (count < total) {
1808
- p = Math.min(p, 95);
1809
- }
1810
- return /* @__PURE__ */ React19.createElement("div", {
1811
- className: mx5("relative flex w-full", styles.barBg, classNames)
1812
- }, /* @__PURE__ */ React19.createElement("div", {
1813
- className: mx5("shrink-0", styles.barFg),
1814
- style: {
1815
- width: `${p}%`
1816
- }
1817
- }), count !== total && /* @__PURE__ */ React19.createElement("div", {
1818
- className: "absolute top-0 bottom-0 flex items-center mx-0.5 text-black text-xs"
1819
- }, count));
1820
- };
1821
-
1822
- // packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts
1823
- import { Context as Context2 } from "@dxos/context";
1824
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts";
1825
- var createClientSaveTracker = (client, cb) => {
1826
- const unsubscribeCallbacks = {};
1827
- const state = {};
1828
- const install = (spaces) => {
1829
- for (const space of spaces) {
1830
- if (state[space.id]) {
1831
- continue;
1832
- }
1833
- state[space.id] = "saved";
1834
- unsubscribeCallbacks[space.id] = createSpaceSaveTracker(space, (s) => {
1835
- state[space.id] = s;
1836
- cb(Object.values(state).some((s2) => s2 === "saving") ? "saving" : "saved");
1837
- });
1838
- }
1839
- };
1840
- client.spaces.subscribe((spaces) => {
1841
- install(spaces);
1842
- });
1843
- install(client.spaces.get());
1844
- return () => {
1845
- for (const unsubscribe of Object.values(unsubscribeCallbacks)) {
1846
- unsubscribe();
1847
- }
1848
- };
1849
- };
1850
- var createSpaceSaveTracker = (space, cb) => {
1851
- const ctx = new Context2(void 0, {
1852
- F: __dxlog_file5,
1853
- L: 40
1854
- });
1855
- void space.waitUntilReady().then(() => {
1856
- if (ctx.disposed) {
1857
- return;
1858
- }
1859
- let hasUnsavedChanges = false;
1860
- let lastFlushPromise;
1861
- space.crud.saveStateChanged.on(ctx, ({ unsavedDocuments }) => {
1862
- hasUnsavedChanges = unsavedDocuments.length > 0;
1863
- });
1864
- space.crud.saveStateChanged.debounce(500).on(ctx, () => {
1865
- if (hasUnsavedChanges) {
1866
- lastFlushPromise = void 0;
1867
- cb("saving");
1868
- } else {
1869
- const flushPromise = space.crud.flush();
1870
- lastFlushPromise = flushPromise;
1871
- void flushPromise.then(() => {
1872
- if (lastFlushPromise === flushPromise) {
1873
- cb("saved");
1874
- }
1875
- });
1876
- }
1877
- });
1878
- });
1879
- return () => {
1880
- void ctx.dispose();
1881
- };
1882
- };
1883
-
1884
- // packages/plugins/plugin-space/src/components/SyncStatus/status.ts
1885
- var getStatus = ({ offline, saved, needsToUpload, needsToDownload }) => {
1886
- if (!saved) {
1887
- return "saving locally";
1888
- } else if (!offline && needsToDownload) {
1889
- return "downloading";
1890
- } else if (!offline && needsToUpload) {
1891
- return "uploading";
1892
- } else if (offline && !needsToUpload && !needsToDownload) {
1893
- return "offline persisted";
1894
- } else {
1895
- return "remote synced";
1896
- }
1897
- };
1898
- var getIcon = (status) => {
1899
- switch (status) {
1900
- case "saving locally":
1901
- return "ph--download--regular";
1902
- case "downloading":
1903
- return "ph--cloud-arrow-down--regular";
1904
- case "uploading":
1905
- return "ph--cloud-arrow-up--regular";
1906
- case "offline persisted":
1907
- return "ph--check-circle--regular";
1908
- case "remote synced":
1909
- return "ph--cloud-check--regular";
1910
- }
1911
- };
1912
-
1913
- // packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
1914
- var SyncStatus = () => {
1915
- const client = useClient10();
1916
- const state = useSyncState();
1917
- const [saved, setSaved] = useState13(true);
1918
- useEffect8(() => {
1919
- return createClientSaveTracker(client, (state2) => {
1920
- setSaved(state2 === "saved");
1921
- });
1922
- }, []);
1923
- return /* @__PURE__ */ React20.createElement(SyncStatusIndicator, {
1924
- state,
1925
- saved
1926
- });
1927
- };
1928
- var SyncStatusIndicator = ({ state, saved }) => {
1929
- const { t } = useTranslation20(SPACE_PLUGIN);
1930
- const summary = getSyncSummary(state);
1931
- const offline = Object.values(state).length === 0;
1932
- const needsToUpload = summary.differentDocuments > 0 || summary.missingOnRemote > 0;
1933
- const needsToDownload = summary.differentDocuments > 0 || summary.missingOnLocal > 0;
1934
- const status = getStatus({
1935
- offline,
1936
- saved,
1937
- needsToUpload,
1938
- needsToDownload
1939
- });
1940
- const [classNames, setClassNames] = useState13();
1941
- useEffect8(() => {
1942
- setClassNames(void 0);
1943
- if (offline || !needsToUpload && !needsToDownload) {
1944
- return;
1945
- }
1946
- const t2 = setTimeout(() => {
1947
- setClassNames("text-orange-500");
1948
- }, SYNC_STALLED_TIMEOUT);
1949
- return () => clearTimeout(t2);
1950
- }, [
1951
- offline,
1952
- needsToUpload,
1953
- needsToDownload
1954
- ]);
1955
- const title = t(`${status} label`);
1956
- const icon = /* @__PURE__ */ React20.createElement(Icon6, {
1957
- icon: getIcon(status),
1958
- size: 4,
1959
- classNames
1960
- });
1961
- if (offline) {
1962
- return /* @__PURE__ */ React20.createElement(StatusBar.Item, {
1963
- title
1964
- }, icon);
1965
- } else {
1966
- return /* @__PURE__ */ React20.createElement(Popover3.Root, null, /* @__PURE__ */ React20.createElement(Popover3.Trigger, {
1967
- asChild: true
1968
- }, /* @__PURE__ */ React20.createElement(StatusBar.Button, {
1969
- title
1970
- }, icon)), /* @__PURE__ */ React20.createElement(Popover3.Portal, null, /* @__PURE__ */ React20.createElement(Popover3.Content, {
1971
- sideOffset: 16
1972
- }, /* @__PURE__ */ React20.createElement(SyncStatusDetail, {
1973
- state,
1974
- summary,
1975
- debug: false
1976
- }))));
1977
- }
1978
- };
1979
- var SyncStatusDetail = ({ classNames, state, summary, debug }) => {
1980
- const [showAll, setShowAll] = useState13(false);
1981
- const { t } = useTranslation20(SPACE_PLUGIN);
1982
- const entries = Object.entries(state).filter(([_, value]) => showAll || value.missingOnLocal + value.missingOnRemote > 0).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
1983
- const handleCheckedChange = useCallback10((state2) => setShowAll(state2), [
1984
- setShowAll
1985
- ]);
1986
- return /* @__PURE__ */ React20.createElement("div", {
1987
- className: mx6("flex flex-col gap-3 p-2 text-xs min-w-96", classNames)
1988
- }, /* @__PURE__ */ React20.createElement("div", {
1989
- role: "none",
1990
- className: "flex items-center"
1991
- }, /* @__PURE__ */ React20.createElement("h1", {
1992
- className: "flex-1"
1993
- }, t("sync status title")), /* @__PURE__ */ React20.createElement("div", {
1994
- className: "flex items-center gap-2"
1995
- }, /* @__PURE__ */ React20.createElement(Input7.Root, null, /* @__PURE__ */ React20.createElement(Input7.Label, {
1996
- classNames: "text-xs"
1997
- }, t("show all label")), /* @__PURE__ */ React20.createElement(Input7.Checkbox, {
1998
- checked: showAll,
1999
- onCheckedChange: handleCheckedChange
2000
- })))), /* @__PURE__ */ React20.createElement("div", {
2001
- className: "flex flex-col gap-2"
2002
- }, entries.length === 0 && /* @__PURE__ */ React20.createElement("div", {
2003
- role: "none",
2004
- className: "flex justify-center"
2005
- }, t("no sync status label")), entries.map(([spaceId, state2]) => /* @__PURE__ */ React20.createElement(SpaceRowContainer, {
2006
- key: spaceId,
2007
- spaceId,
2008
- state: state2
2009
- }))), debug && /* @__PURE__ */ React20.createElement(SyntaxHighlighter, {
2010
- language: "json"
2011
- }, JSON.stringify(summary, null, 2)));
2012
- };
2013
-
2014
- // packages/plugins/plugin-space/src/translations.ts
2015
- var translations_default = [
2016
- {
2017
- "en-US": {
2018
- [CollectionType.typename]: {
2019
- "typename label": "Collection"
2020
- },
2021
- [SPACE_PLUGIN]: {
2022
- "plugin name": "Spaces",
2023
- "first run message": "Nothing selected.",
2024
- "create space label": "Create space",
2025
- "join space label": "Join space",
2026
- "empty space message": "No documents",
2027
- "empty tree message": "No spaces",
2028
- "unnamed space label": "New space",
2029
- "closed space label": "Closed",
2030
- "loading space label": "Loading space\u2026",
2031
- "lock space label": "Lock space",
2032
- "unlock space label": "Unlock space",
2033
- "rename space label": "Rename space",
2034
- "active space label": "Active space:",
2035
- "space name label": "Space name",
2036
- "object name label": "Object name",
2037
- "close space label": "Close space",
2038
- "open space label": "Open space",
2039
- "export data label": "Export data",
2040
- "import data label": "Import data",
2041
- "migrate space label": "Migrate space",
2042
- "share space": "Share space",
2043
- "save space to disk label": "Save to disk",
2044
- "load space from disk label": "Load from disk",
2045
- "confirm restore title": "Overwrite files in this space?",
2046
- "confirm restore body": "Restoring from a backup will overwrite the contents of any documents that match.",
2047
- "upload file message": "Drag file here or click to browse",
2048
- "object title placeholder": "Type a title here\u2026",
2049
- "personal space label": "Personal Space",
2050
- "spaces label": "Spaces",
2051
- "show hidden spaces label": "Show closed spaces",
2052
- "save files to directory label": "Save files to disk",
2053
- "select path label": "Select path",
2054
- "rename collection label": "Rename collection",
2055
- "rename object label": "Rename item",
2056
- "duplicate object label": "Duplicate item",
2057
- "delete collection label": "Delete collection",
2058
- "delete object label": "Delete item",
2059
- "collection deleted label": "Collection deleted",
2060
- "object deleted label": "Item deleted",
2061
- "objects deleted label": "Items deleted",
2062
- "go to object label": "Open item",
2063
- "found object label": "Ready.",
2064
- "found object description": "The requested object is now available.",
2065
- "waiting for object label": "Loading\u2026",
2066
- "waiting for object description": "The requested object is still being synchronized.",
2067
- "object not found label": "Nothing found.",
2068
- "object not found description": "The requested object has not been found yet. Ensure there are enough peers online in the space with an updated copy.",
2069
- "missing object message": "Object not available.",
2070
- "missing object description": "The requested object has not been found yet. Ensure there are enough peers online in the space with an updated copy.",
2071
- "create collection label": "Create collection",
2072
- "unnamed object label": "New object",
2073
- "unnamed collection label": "New collection",
2074
- "create object in space label": "Add to space",
2075
- "create object in collection label": "Add to collection",
2076
- "share space label": "Share",
2077
- "space members label": "Space members",
2078
- "active space members heading": "Online ({{count}})",
2079
- "inactive space members heading": "Offline ({{count}})",
2080
- "presence label_zero": "No other viewers",
2081
- "presence label_one": "1 other viewer",
2082
- "presence label_other": "{{count}} other viewers",
2083
- "persisted locally label": "Changes saved locally.",
2084
- "persisted locally message": "All changes have been saved to disk on this device.",
2085
- "persistence pending label": "Saving\u2026",
2086
- "persistence error label": "Error saving changes.",
2087
- "more actions label": "More actions",
2088
- "invitations heading": "Invitations",
2089
- "keyshortcuts label": "Keyboard shortcuts",
2090
- "menu footer label": "Details",
2091
- "location label": "Located in",
2092
- "space limit label": "Space Limit Reached",
2093
- "space limit description": "This space has reached the maximum number of objects for the beta. This limit includes deleted objects currently, but those can be permanently removed with the cleanup action.",
2094
- "space limit close label": "Close",
2095
- "remove deleted objects label": "Cleanup",
2096
- "remove deleted objects alt": "Permanently remove deleted objects to free up space.",
2097
- "copy link label": "Copy link",
2098
- "default on space create label": "On space create",
2099
- "sync status title": "Sync status",
2100
- "dismiss label": "Dismiss",
2101
- "join success label": "Successfully joined space",
2102
- "name label": "Name",
2103
- "name placeholder": "Name",
2104
- "unnamed object settings label": "Settings",
2105
- "edge replication label": "Enable EDGE Replication",
2106
- "saving locally label": "Writing to disk",
2107
- "downloading label": "Replicating from peers",
2108
- "uploading label": "Replicating to peers",
2109
- "offline persisted label": "Saved to disk (offline)",
2110
- "remote synced label": "Synced with peers",
2111
- "open settings panel label": "Show Settings",
2112
- "open space settings label": "Space Settings",
2113
- "members tab label": "Members",
2114
- "settings tab label": "Settings",
2115
- "syncing label": "Space syncing",
2116
- "show all label": "Show all",
2117
- "no sync status label": "No space with missing objects.",
2118
- "create space dialog title": "Create Space",
2119
- "create object dialog title": "Create Object",
2120
- "space input placeholder": "Select space",
2121
- "schema input placeholder": "Select object type",
2122
- "creating object type label": "Type",
2123
- "creating in space label": "Location",
2124
- "creating in collection label": "In Collection",
2125
- "clear input label": "Clear",
2126
- "expose object label": "Expose in navtree"
2127
- }
2128
- }
2129
- }
2130
- ];
2131
-
2132
- // packages/plugins/plugin-space/src/SpacePlugin.tsx
2133
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/SpacePlugin.tsx";
2134
- var ACTIVE_NODE_BROADCAST_INTERVAL = 3e4;
2135
- var WAIT_FOR_OBJECT_TIMEOUT2 = 1e3;
2136
- var SPACE_MAX_OBJECTS = 500;
2137
- var DIRECTORY_TYPE = "text/directory";
2138
- var parseSpacePlugin = (plugin) => Array.isArray(plugin?.provides.space?.enabled) ? plugin : void 0;
2139
- var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "spaceInvitationCode", firstRun, onFirstRun } = {}) => {
2140
- const settings = new LocalStorageStore(SPACE_PLUGIN, {});
2141
- const state = new LocalStorageStore(SPACE_PLUGIN, {
2142
- awaiting: void 0,
2143
- spaceNames: {},
2144
- viewersByObject: {},
2145
- // TODO(wittjosiah): Stop using (Complex)Map inside reactive object.
2146
- viewersByIdentity: new ComplexMap2(PublicKey2.hash),
2147
- sdkMigrationRunning: {},
2148
- navigableCollections: false,
2149
- enabledEdgeReplication: false
2150
- });
2151
- const subscriptions = new EventSubscriptions();
2152
- const spaceSubscriptions = new EventSubscriptions();
2153
- const graphSubscriptions = /* @__PURE__ */ new Map();
2154
- const schemas = [];
2155
- let clientPlugin;
2156
- let graphPlugin;
2157
- let intentPlugin;
2158
- let layoutPlugin;
2159
- let navigationPlugin;
2160
- let attentionPlugin;
2161
- const createSpaceInvitationUrl = (invitationCode) => {
2162
- const baseUrl = new URL(invitationUrl);
2163
- baseUrl.searchParams.set(invitationParam, invitationCode);
2164
- return baseUrl.toString();
2165
- };
2166
- const onSpaceReady = async () => {
2167
- if (!clientPlugin || !intentPlugin || !graphPlugin || !navigationPlugin || !layoutPlugin || !attentionPlugin) {
2168
- return;
2169
- }
2170
- const client = clientPlugin.provides.client;
2171
- const dispatch = intentPlugin.provides.intent.dispatch;
2172
- const graph = graphPlugin.provides.graph;
2173
- const location = navigationPlugin.provides.location;
2174
- const layout = layoutPlugin.provides.layout;
2175
- const attention = attentionPlugin.provides.attention;
2176
- const defaultSpace = client.spaces.default;
2177
- if (typeof defaultSpace.properties[COMPOSER_SPACE_LOCK] !== "boolean") {
2178
- defaultSpace.properties[COMPOSER_SPACE_LOCK] = true;
2179
- }
2180
- const { objects: [spacesOrder] } = await defaultSpace.db.query(Filter3.schema(Expando, {
2181
- key: SHARED
2182
- })).run();
2183
- if (!spacesOrder) {
2184
- defaultSpace.db.add(create({
2185
- key: SHARED,
2186
- order: []
2187
- }));
2188
- }
2189
- subscriptions.add(scheduledEffect(() => ({
2190
- layoutMode: layout.layoutMode,
2191
- soloPart: location.active.solo?.[0]
2192
- }), ({ layoutMode, soloPart }) => {
2193
- if (layoutMode !== "solo" || !soloPart) {
2194
- return;
2195
- }
2196
- const node = graph.findNode(soloPart.id);
2197
- if (!node && soloPart.id.length === FQ_ID_LENGTH) {
2198
- const timeout = setTimeout(async () => {
2199
- const node2 = graph.findNode(soloPart.id);
2200
- if (!node2) {
2201
- await dispatch(createIntent8(SpaceAction.WaitForObject, {
2202
- id: soloPart.id
2203
- }));
2204
- }
2205
- }, WAIT_FOR_OBJECT_TIMEOUT2);
2206
- return () => clearTimeout(timeout);
2207
- }
2208
- }));
2209
- subscriptions.add(client.spaces.subscribe(async (spaces) => {
2210
- if (defaultSpace.state.get() === SpaceState2.SPACE_REQUIRES_MIGRATION) {
2211
- await defaultSpace.internal.migrate();
2212
- }
2213
- spaces.filter((space) => space.state.get() === SpaceState2.SPACE_READY).forEach((space) => {
2214
- subscriptions.add(scheduledEffect(() => ({
2215
- name: space.properties.name
2216
- }), ({ name }) => state.values.spaceNames[space.id] = name));
2217
- });
2218
- }).unsubscribe);
2219
- subscriptions.add(scheduledEffect(() => ({
2220
- open: openIds(location.active, layout.layoutMode === "solo" ? [
2221
- "solo"
2222
- ] : [
2223
- "main"
2224
- ]),
2225
- closed: [
2226
- ...location.closed
2227
- ]
2228
- }), ({ open, closed }) => {
2229
- const send = () => {
2230
- const spaces = client.spaces.get();
2231
- const identity = client.halo.identity.get();
2232
- if (identity && location.active) {
2233
- const idsBySpace = reduceGroupBy(open, (id) => {
2234
- try {
2235
- const [spaceId] = parseFullyQualifiedId(id);
2236
- return spaceId;
2237
- } catch {
2238
- return null;
2239
- }
2240
- });
2241
- const removedBySpace = reduceGroupBy(closed, (id) => {
2242
- try {
2243
- const [spaceId] = parseFullyQualifiedId(id);
2244
- return spaceId;
2245
- } catch {
2246
- return null;
2247
- }
2248
- });
2249
- for (const space of spaces) {
2250
- if (!idsBySpace.has(space.id)) {
2251
- idsBySpace.set(space.id, []);
2252
- }
2253
- }
2254
- for (const [spaceId, added] of idsBySpace) {
2255
- const removed = removedBySpace.get(spaceId) ?? [];
2256
- const space = spaces.find((space2) => space2.id === spaceId);
2257
- if (!space) {
2258
- continue;
2259
- }
2260
- void space.postMessage("viewing", {
2261
- identityKey: identity.identityKey.toHex(),
2262
- attended: attention.attended ? [
2263
- ...attention.attended
2264
- ] : [],
2265
- added,
2266
- removed
2267
- }).catch((err) => {
2268
- log3.warn("Failed to broadcast active node for presence.", {
2269
- err: err.message
2270
- }, {
2271
- F: __dxlog_file6,
2272
- L: 324,
2273
- S: void 0,
2274
- C: (f, a) => f(...a)
2275
- });
2276
- });
2277
- }
2278
- }
2279
- };
2280
- send();
2281
- const interval = setInterval(() => send(), ACTIVE_NODE_BROADCAST_INTERVAL);
2282
- return () => clearInterval(interval);
2283
- }));
2284
- subscriptions.add(client.spaces.subscribe((spaces) => {
2285
- spaceSubscriptions.clear();
2286
- spaces.forEach((space) => {
2287
- spaceSubscriptions.add(space.listen("viewing", (message) => {
2288
- const { added, removed, attended } = message.payload;
2289
- const identityKey = PublicKey2.safeFrom(message.payload.identityKey);
2290
- const currentIdentity = client.halo.identity.get();
2291
- if (identityKey && !currentIdentity?.identityKey.equals(identityKey) && Array.isArray(added) && Array.isArray(removed)) {
2292
- added.forEach((id) => {
2293
- if (typeof id === "string") {
2294
- if (!(id in state.values.viewersByObject)) {
2295
- state.values.viewersByObject[id] = new ComplexMap2(PublicKey2.hash);
2296
- }
2297
- state.values.viewersByObject[id].set(identityKey, {
2298
- lastSeen: Date.now(),
2299
- currentlyAttended: new Set(attended).has(id)
2300
- });
2301
- if (!state.values.viewersByIdentity.has(identityKey)) {
2302
- state.values.viewersByIdentity.set(identityKey, /* @__PURE__ */ new Set());
2303
- }
2304
- state.values.viewersByIdentity.get(identityKey).add(id);
2305
- }
2306
- });
2307
- removed.forEach((id) => {
2308
- if (typeof id === "string") {
2309
- state.values.viewersByObject[id]?.delete(identityKey);
2310
- state.values.viewersByIdentity.get(identityKey)?.delete(id);
2311
- }
2312
- });
2313
- }
2314
- }));
2315
- });
2316
- }).unsubscribe);
2317
- };
2318
- const setEdgeReplicationDefault = async (client) => {
2319
- try {
2320
- await Promise.all(client.spaces.get().map((space) => space.internal.setEdgeReplicationPreference(EdgeReplicationSetting3.ENABLED)));
2321
- state.values.enabledEdgeReplication = true;
2322
- } catch (err) {
2323
- log3.catch(err, void 0, {
2324
- F: __dxlog_file6,
2325
- L: 393,
2326
- S: void 0,
2327
- C: (f, a) => f(...a)
2328
- });
2329
- }
2330
- };
2331
- return {
2332
- meta: meta_default,
2333
- ready: async ({ plugins }) => {
2334
- settings.prop({
2335
- key: "showHidden",
2336
- type: LocalStorageStore.bool({
2337
- allowUndefined: true
2338
- })
2339
- });
2340
- state.prop({
2341
- key: "spaceNames",
2342
- type: LocalStorageStore.json()
2343
- }).prop({
2344
- key: "enabledEdgeReplication",
2345
- type: LocalStorageStore.bool()
2346
- });
2347
- if (findPlugin(plugins, "dxos.org/plugin/stack")) {
2348
- state.values.navigableCollections = true;
2349
- }
2350
- graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
2351
- layoutPlugin = resolvePlugin(plugins, parseLayoutPlugin);
2352
- navigationPlugin = resolvePlugin(plugins, parseNavigationPlugin2);
2353
- attentionPlugin = resolvePlugin(plugins, parseAttentionPlugin);
2354
- clientPlugin = resolvePlugin(plugins, parseClientPlugin);
2355
- intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
2356
- if (!clientPlugin || !intentPlugin) {
2357
- return;
2358
- }
2359
- const client = clientPlugin.provides.client;
2360
- const dispatch = intentPlugin.provides.intent.dispatchPromise;
2361
- schemas.push(...filterPlugins(plugins, parseSchemaPlugin).map((plugin) => plugin.provides.echo.schema).filter(nonNullable2).reduce((acc, schema) => {
2362
- return [
2363
- ...acc,
2364
- ...schema
2365
- ];
2366
- }));
2367
- client.addTypes(schemas);
2368
- filterPlugins(plugins, parseSchemaPlugin).forEach((plugin) => {
2369
- if (plugin.provides.echo.system) {
2370
- client.addTypes(plugin.provides.echo.system);
2371
- }
2372
- });
2373
- const handleFirstRun = async () => {
2374
- const defaultSpace = client.spaces.default;
2375
- defaultSpace.properties[CollectionType.typename] = makeRef2(create(CollectionType, {
2376
- objects: [],
2377
- views: {}
2378
- }));
2379
- if (Migrations2.versionProperty) {
2380
- defaultSpace.properties[Migrations2.versionProperty] = Migrations2.targetVersion;
2381
- }
2382
- await onFirstRun?.({
2383
- client,
2384
- dispatch
2385
- });
2386
- };
2387
- subscriptions.add(client.spaces.isReady.subscribe(async (ready) => {
2388
- if (ready) {
2389
- await clientPlugin?.provides.client.spaces.default.waitUntilReady();
2390
- if (firstRun) {
2391
- void firstRun?.wait().then(handleFirstRun);
2392
- } else {
2393
- await handleFirstRun();
2394
- }
2395
- await onSpaceReady();
2396
- await setEdgeReplicationDefault(client);
2397
- }
2398
- }).unsubscribe);
2399
- },
2400
- unload: async () => {
2401
- settings.close();
2402
- spaceSubscriptions.clear();
2403
- subscriptions.clear();
2404
- graphSubscriptions.forEach((cb) => cb());
2405
- graphSubscriptions.clear();
2406
- },
2407
- provides: {
2408
- space: state.values,
2409
- settings: settings.values,
2410
- translations: [
2411
- ...translations_default,
2412
- osTranslations
203
+ defineModule({
204
+ id: `${meta.id}/module/intent-resolver`,
205
+ activatesOn: Events.SetupIntentResolver,
206
+ activate: (context) => IntentResolver({
207
+ createInvitationUrl,
208
+ context,
209
+ observability
210
+ })
211
+ }),
212
+ defineModule({
213
+ id: `${meta.id}/module/app-graph-builder`,
214
+ activatesOn: Events.SetupAppGraph,
215
+ activate: AppGraphBuilder
216
+ }),
217
+ // TODO(wittjosiah): This could probably be deferred.
218
+ defineModule({
219
+ id: `${meta.id}/module/app-graph-serializer`,
220
+ activatesOn: Events.AppGraphReady,
221
+ activate: AppGraphSerializer
222
+ }),
223
+ defineModule({
224
+ id: `${meta.id}/module/identity-created`,
225
+ activatesOn: ClientEvents.IdentityCreated,
226
+ activatesAfter: [
227
+ SpaceEvents.DefaultSpaceReady
2413
228
  ],
2414
- complementary: {
2415
- panels: [
2416
- {
2417
- id: "settings",
2418
- label: [
2419
- "open settings panel label",
2420
- {
2421
- ns: SPACE_PLUGIN
2422
- }
2423
- ],
2424
- icon: "ph--gear--regular"
2425
- }
2426
- ]
2427
- },
2428
- root: () => state.values.awaiting ? /* @__PURE__ */ React21.createElement(AwaitingObject, {
2429
- id: state.values.awaiting
2430
- }) : null,
2431
- metadata: {
2432
- records: {
2433
- [CollectionType.typename]: {
2434
- createObject: (props) => createIntent8(CollectionAction.Create, props),
2435
- placeholder: [
2436
- "unnamed collection label",
2437
- {
2438
- ns: SPACE_PLUGIN
2439
- }
2440
- ],
2441
- icon: "ph--cards-three--regular",
2442
- // TODO(wittjosiah): Move out of metadata.
2443
- loadReferences: async (collection) => await RefArray.loadAll([
2444
- ...collection.objects,
2445
- ...Object.values(collection.views)
2446
- ])
2447
- }
2448
- }
2449
- },
2450
- echo: {
2451
- schema: [
2452
- CollectionType
2453
- ]
2454
- },
2455
- surface: {
2456
- definitions: ({ plugins }) => {
2457
- const resolve = resolvePlugin(plugins, parseMetadataResolverPlugin)?.provides.metadata.resolver;
2458
- const attention = resolvePlugin(plugins, parseAttentionPlugin)?.provides.attention;
2459
- invariant2(resolve, "Metadata plugin not found.", {
2460
- F: __dxlog_file6,
2461
- L: 503,
2462
- S: void 0,
2463
- A: [
2464
- "resolve",
2465
- "'Metadata plugin not found.'"
2466
- ]
2467
- });
2468
- invariant2(attention, "Attention plugin not found.", {
2469
- F: __dxlog_file6,
2470
- L: 504,
2471
- S: void 0,
2472
- A: [
2473
- "attention",
2474
- "'Attention plugin not found.'"
2475
- ]
2476
- });
2477
- return [
2478
- createSurface({
2479
- id: `${SPACE_PLUGIN}/article`,
2480
- role: "article",
2481
- filter: (data) => (
2482
- // TODO(wittjosiah): Need to avoid shotgun parsing space state everywhere.
2483
- isSpace4(data.subject) && data.subject.state.get() === SpaceState2.SPACE_READY
2484
- ),
2485
- component: ({ data, role, ...rest }) => /* @__PURE__ */ React21.createElement(Surface, {
2486
- data: {
2487
- id: data.subject.id,
2488
- subject: data.subject.properties[CollectionType.typename]?.target
2489
- },
2490
- role,
2491
- ...rest
2492
- })
2493
- }),
2494
- createSurface({
2495
- id: `${SPACE_PLUGIN}/collection-fallback`,
2496
- role: "article",
2497
- disposition: "fallback",
2498
- filter: (data) => data.subject instanceof CollectionType,
2499
- component: ({ data }) => /* @__PURE__ */ React21.createElement(CollectionMain, {
2500
- collection: data.subject
2501
- })
2502
- }),
2503
- createSurface({
2504
- id: `${SPACE_PLUGIN}/settings-panel`,
2505
- // TODO(burdon): Add role name syntax to minimal plugin docs.
2506
- role: "complementary--settings",
2507
- filter: (data) => isSpace4(data.subject),
2508
- component: ({ data }) => /* @__PURE__ */ React21.createElement(SpaceSettingsPanel, {
2509
- space: data.subject
2510
- })
2511
- }),
2512
- createSurface({
2513
- id: `${SPACE_PLUGIN}/object-settings-panel-fallback`,
2514
- role: "complementary--settings",
2515
- disposition: "fallback",
2516
- filter: (data) => isEchoObject2(data.subject),
2517
- component: ({ data }) => /* @__PURE__ */ React21.createElement(DefaultObjectSettings, {
2518
- object: data.subject
2519
- })
2520
- }),
2521
- createSurface({
2522
- id: SPACE_SETTINGS_DIALOG,
2523
- role: "dialog",
2524
- filter: (data) => data.component === SPACE_SETTINGS_DIALOG,
2525
- component: ({ data }) => /* @__PURE__ */ React21.createElement(SpaceSettingsDialog, {
2526
- ...data.subject,
2527
- createInvitationUrl: createSpaceInvitationUrl
2528
- })
2529
- }),
2530
- createSurface({
2531
- id: JOIN_DIALOG,
2532
- role: "dialog",
2533
- filter: (data) => data.component === JOIN_DIALOG,
2534
- component: ({ data }) => /* @__PURE__ */ React21.createElement(JoinDialog, data.subject)
2535
- }),
2536
- createSurface({
2537
- id: CREATE_SPACE_DIALOG,
2538
- role: "dialog",
2539
- filter: (data) => data.component === CREATE_SPACE_DIALOG,
2540
- component: () => /* @__PURE__ */ React21.createElement(CreateSpaceDialog, null)
2541
- }),
2542
- createSurface({
2543
- id: CREATE_OBJECT_DIALOG,
2544
- role: "dialog",
2545
- filter: (data) => data.component === CREATE_OBJECT_DIALOG,
2546
- component: ({ data }) => /* @__PURE__ */ React21.createElement(CreateObjectDialog, {
2547
- schemas,
2548
- resolve,
2549
- ...data.subject
2550
- })
2551
- }),
2552
- createSurface({
2553
- id: POPOVER_RENAME_SPACE,
2554
- role: "popover",
2555
- filter: (data) => data.component === POPOVER_RENAME_SPACE && isSpace4(data.subject),
2556
- component: ({ data }) => /* @__PURE__ */ React21.createElement(PopoverRenameSpace, {
2557
- space: data.subject
2558
- })
2559
- }),
2560
- createSurface({
2561
- id: POPOVER_RENAME_OBJECT,
2562
- role: "popover",
2563
- filter: (data) => data.component === POPOVER_RENAME_OBJECT && isReactiveObject3(data.subject),
2564
- component: ({ data }) => /* @__PURE__ */ React21.createElement(PopoverRenameObject, {
2565
- object: data.subject
2566
- })
2567
- }),
2568
- createSurface({
2569
- id: `${SPACE_PLUGIN}/navtree-presence`,
2570
- role: "navtree-item-end",
2571
- filter: (data) => typeof data.id === "string" && isEchoObject2(data.subject),
2572
- component: ({ data }) => /* @__PURE__ */ React21.createElement(SmallPresenceLive, {
2573
- id: data.id,
2574
- open: data.open,
2575
- viewers: state.values.viewersByObject[data.id]
2576
- })
2577
- }),
2578
- createSurface({
2579
- // TODO(wittjosiah): Attention glyph for non-echo items should be handled elsewhere.
2580
- id: `${SPACE_PLUGIN}/navtree-presence-fallback`,
2581
- role: "navtree-item-end",
2582
- disposition: "fallback",
2583
- filter: (data) => typeof data.id === "string",
2584
- component: ({ data }) => /* @__PURE__ */ React21.createElement(SmallPresenceLive, {
2585
- id: data.id,
2586
- open: data.open
2587
- })
2588
- }),
2589
- createSurface({
2590
- id: `${SPACE_PLUGIN}/navtree-sync-status`,
2591
- role: "navtree-item-end",
2592
- filter: (data) => isSpace4(data.subject),
2593
- component: ({ data }) => /* @__PURE__ */ React21.createElement(InlineSyncStatus, {
2594
- space: data.subject,
2595
- open: data.open
2596
- })
2597
- }),
2598
- createSurface({
2599
- id: `${SPACE_PLUGIN}/navbar-presence`,
2600
- role: "navbar-end",
2601
- disposition: "hoist",
2602
- filter: (data) => isSpace4(data.subject) || isEchoObject2(data.subject),
2603
- component: ({ data }) => {
2604
- const space = isSpace4(data.subject) ? data.subject : getSpace5(data.subject);
2605
- const object = isSpace4(data.subject) ? data.subject.state.get() === SpaceState2.SPACE_READY ? space?.properties[CollectionType.typename]?.target : void 0 : data.subject;
2606
- return space && object ? /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(SpacePresence, {
2607
- object
2608
- }), space.properties[COMPOSER_SPACE_LOCK] ? null : /* @__PURE__ */ React21.createElement(ShareSpaceButton, {
2609
- space
2610
- })) : null;
2611
- }
2612
- }),
2613
- createSurface({
2614
- id: `${SPACE_PLUGIN}/collection-section`,
2615
- role: "section",
2616
- filter: (data) => data.subject instanceof CollectionType,
2617
- component: ({ data }) => /* @__PURE__ */ React21.createElement(CollectionSection, {
2618
- collection: data.subject
2619
- })
2620
- }),
2621
- createSurface({
2622
- id: `${SPACE_PLUGIN}/settings`,
2623
- role: "settings",
2624
- filter: (data) => data.subject === SPACE_PLUGIN,
2625
- component: () => /* @__PURE__ */ React21.createElement(SpacePluginSettings, {
2626
- settings: settings.values
2627
- })
2628
- }),
2629
- createSurface({
2630
- id: `${SPACE_PLUGIN}/menu-footer`,
2631
- role: "menu-footer",
2632
- filter: (data) => isEchoObject2(data.subject),
2633
- component: ({ data }) => /* @__PURE__ */ React21.createElement(MenuFooter, {
2634
- object: data.subject
2635
- })
2636
- }),
2637
- createSurface({
2638
- id: `${SPACE_PLUGIN}/status`,
2639
- role: "status",
2640
- component: () => /* @__PURE__ */ React21.createElement(SyncStatus, null)
2641
- })
2642
- ];
2643
- }
2644
- },
2645
- graph: {
2646
- builder: (plugins) => {
2647
- const clientPlugin2 = resolvePlugin(plugins, parseClientPlugin);
2648
- const metadataPlugin = resolvePlugin(plugins, parseMetadataResolverPlugin);
2649
- const graphPlugin2 = resolvePlugin(plugins, parseGraphPlugin);
2650
- const client = clientPlugin2?.provides.client;
2651
- const dispatch = intentPlugin?.provides.intent.dispatchPromise;
2652
- const resolve = metadataPlugin?.provides.metadata.resolver;
2653
- const graph = graphPlugin2?.provides.graph;
2654
- if (!client || !dispatch || !resolve || !graph) {
2655
- return [];
2656
- }
2657
- const spacesNode = {
2658
- id: SPACES,
2659
- type: SPACES,
2660
- cacheable: [
2661
- "label",
2662
- "role"
2663
- ],
2664
- properties: {
2665
- label: [
2666
- "spaces label",
2667
- {
2668
- ns: SPACE_PLUGIN
2669
- }
2670
- ],
2671
- testId: "spacePlugin.spaces",
2672
- role: "branch",
2673
- disabled: true,
2674
- childrenPersistenceClass: "echo",
2675
- onRearrangeChildren: async (nextOrder) => {
2676
- graph._sortEdges(SPACES, "outbound", nextOrder.map(({ id }) => id));
2677
- const { objects: [spacesOrder] } = await client.spaces.default.db.query(Filter3.schema(Expando, {
2678
- key: SHARED
2679
- })).run();
2680
- if (spacesOrder) {
2681
- spacesOrder.order = nextOrder.map(({ id }) => id);
2682
- } else {
2683
- log3.warn("spaces order object not found", void 0, {
2684
- F: __dxlog_file6,
2685
- L: 694,
2686
- S: void 0,
2687
- C: (f, a) => f(...a)
2688
- });
2689
- }
2690
- }
2691
- }
2692
- };
2693
- return [
2694
- // Primary actions.
2695
- createExtension({
2696
- id: `${SPACE_PLUGIN}/primary-actions`,
2697
- filter: (node) => node.id === "root",
2698
- actions: () => [
2699
- {
2700
- id: SpaceAction.OpenCreateSpace._tag,
2701
- data: async () => {
2702
- await dispatch(createIntent8(SpaceAction.OpenCreateSpace));
2703
- },
2704
- properties: {
2705
- label: [
2706
- "create space label",
2707
- {
2708
- ns: SPACE_PLUGIN
2709
- }
2710
- ],
2711
- icon: "ph--plus--regular",
2712
- testId: "spacePlugin.createSpace",
2713
- disposition: "item"
2714
- }
2715
- },
2716
- {
2717
- id: SpaceAction.Join._tag,
2718
- data: async () => {
2719
- await dispatch(createIntent8(SpaceAction.Join));
2720
- },
2721
- properties: {
2722
- label: [
2723
- "join space label",
2724
- {
2725
- ns: SPACE_PLUGIN
2726
- }
2727
- ],
2728
- icon: "ph--sign-in--regular",
2729
- testId: "spacePlugin.joinSpace",
2730
- disposition: "item",
2731
- className: "border-b border-separator"
2732
- }
2733
- }
2734
- ]
2735
- }),
2736
- // Create spaces group node.
2737
- createExtension({
2738
- id: `${SPACE_PLUGIN}/root`,
2739
- filter: (node) => node.id === "root",
2740
- connector: () => [
2741
- spacesNode
2742
- ],
2743
- resolver: ({ id }) => id === SPACES ? spacesNode : void 0
2744
- }),
2745
- // Create space nodes.
2746
- createExtension({
2747
- id: SPACES,
2748
- filter: (node) => node.id === SPACES,
2749
- connector: () => {
2750
- const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
2751
- const isReady = toSignal((onChange) => client.spaces.isReady.subscribe(() => onChange()).unsubscribe, () => client.spaces.isReady.get());
2752
- if (!spaces || !isReady) {
2753
- return;
2754
- }
2755
- try {
2756
- const [spacesOrder] = memoizeQuery(client.spaces.default, Filter3.schema(Expando, {
2757
- key: SHARED
2758
- }));
2759
- const order = spacesOrder?.order ?? [];
2760
- const orderMap = new Map(order.map((id, index) => [
2761
- id,
2762
- index
2763
- ]));
2764
- return [
2765
- ...spaces.filter((space) => orderMap.has(space.id)).sort((a, b) => orderMap.get(a.id) - orderMap.get(b.id)),
2766
- ...spaces.filter((space) => !orderMap.has(space.id))
2767
- ].filter((space) => settings.values.showHidden ? true : space.state.get() !== SpaceState2.SPACE_INACTIVE).map((space) => constructSpaceNode({
2768
- space,
2769
- navigable: state.values.navigableCollections,
2770
- personal: space === client.spaces.default,
2771
- namesCache: state.values.spaceNames,
2772
- resolve
2773
- }));
2774
- } catch {
2775
- }
2776
- },
2777
- resolver: ({ id }) => {
2778
- if (id.length !== SPACE_ID_LENGTH) {
2779
- return;
2780
- }
2781
- const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
2782
- const isReady = toSignal((onChange) => client.spaces.isReady.subscribe(() => onChange()).unsubscribe, () => client.spaces.isReady.get());
2783
- if (!spaces || !isReady) {
2784
- return;
2785
- }
2786
- const space = spaces.find((space2) => space2.id === id);
2787
- if (!space) {
2788
- return;
2789
- }
2790
- if (space.state.get() === SpaceState2.SPACE_INACTIVE) {
2791
- return false;
2792
- } else {
2793
- return constructSpaceNode({
2794
- space,
2795
- navigable: state.values.navigableCollections,
2796
- personal: space === client.spaces.default,
2797
- namesCache: state.values.spaceNames,
2798
- resolve
2799
- });
2800
- }
2801
- }
2802
- }),
2803
- // Create space actions.
2804
- createExtension({
2805
- id: `${SPACE_PLUGIN}/actions`,
2806
- filter: (node) => isSpace4(node.data),
2807
- actions: ({ node }) => {
2808
- const space = node.data;
2809
- return constructSpaceActions({
2810
- space,
2811
- dispatch,
2812
- personal: space === client.spaces.default,
2813
- migrating: state.values.sdkMigrationRunning[space.id]
2814
- });
2815
- }
2816
- }),
2817
- // Create nodes for objects in the root collection of a space.
2818
- createExtension({
2819
- id: `${SPACE_PLUGIN}/root-collection`,
2820
- filter: (node) => isSpace4(node.data),
2821
- connector: ({ node }) => {
2822
- const space = node.data;
2823
- const spaceState = toSignal((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
2824
- if (spaceState !== SpaceState2.SPACE_READY) {
2825
- return;
2826
- }
2827
- const collection = space.properties[CollectionType.typename]?.target;
2828
- if (!collection) {
2829
- return;
2830
- }
2831
- return collection.objects.map((object) => object.target).filter(nonNullable2).map((object) => createObjectNode({
2832
- object,
2833
- space,
2834
- resolve,
2835
- navigable: state.values.navigableCollections
2836
- })).filter(nonNullable2);
2837
- }
2838
- }),
2839
- // Create nodes for objects in a collection or by its fully qualified id.
2840
- createExtension({
2841
- id: `${SPACE_PLUGIN}/objects`,
2842
- filter: (node) => node.data instanceof CollectionType,
2843
- connector: ({ node }) => {
2844
- const collection = node.data;
2845
- const space = getSpace5(collection);
2846
- if (!space) {
2847
- return;
2848
- }
2849
- return collection.objects.map((object) => object.target).filter(nonNullable2).map((object) => createObjectNode({
2850
- object,
2851
- space,
2852
- resolve,
2853
- navigable: state.values.navigableCollections
2854
- })).filter(nonNullable2);
2855
- },
2856
- resolver: ({ id }) => {
2857
- if (id.length !== FQ_ID_LENGTH) {
2858
- return;
2859
- }
2860
- const [spaceId, objectId] = id.split(":");
2861
- if (spaceId.length !== SPACE_ID_LENGTH && objectId.length !== OBJECT_ID_LENGTH) {
2862
- return;
2863
- }
2864
- const space = client.spaces.get().find((space2) => space2.id === spaceId);
2865
- if (!space) {
2866
- return;
2867
- }
2868
- const spaceState = toSignal((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
2869
- if (spaceState !== SpaceState2.SPACE_READY) {
2870
- return;
2871
- }
2872
- const store = memoize2(() => signal(space.db.getObjectById(objectId)), id);
2873
- memoize2(() => {
2874
- if (!store.value) {
2875
- void space.db.query({
2876
- id: objectId
2877
- }, {
2878
- deleted: QueryOptions.ShowDeletedOption.SHOW_DELETED
2879
- }).first().then((o) => store.value = o).catch((err) => log3.catch(err, {
2880
- objectId
2881
- }, {
2882
- F: __dxlog_file6,
2883
- L: 919,
2884
- S: void 0,
2885
- C: (f, a) => f(...a)
2886
- }));
2887
- }
2888
- }, id);
2889
- const object = store.value;
2890
- if (!object) {
2891
- return;
2892
- }
2893
- if (isDeleted(object)) {
2894
- return false;
2895
- } else {
2896
- return createObjectNode({
2897
- object,
2898
- space,
2899
- resolve,
2900
- navigable: state.values.navigableCollections
2901
- });
2902
- }
2903
- }
2904
- }),
2905
- // Create collection actions and action groups.
2906
- createExtension({
2907
- id: `${SPACE_PLUGIN}/object-actions`,
2908
- filter: (node) => isEchoObject2(node.data),
2909
- actions: ({ node }) => constructObjectActions({
2910
- node,
2911
- dispatch
2912
- })
2913
- }),
2914
- // Create nodes for object settings.
2915
- createExtension({
2916
- id: `${SPACE_PLUGIN}/settings-for-subject`,
2917
- resolver: ({ id }) => {
2918
- if (!id.endsWith("~settings")) {
2919
- return;
2920
- }
2921
- const type = "orphan-settings-for-subject";
2922
- const icon = "ph--gear--regular";
2923
- const [subjectId] = id.split("~");
2924
- const { spaceId, objectId } = parseId(subjectId);
2925
- const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
2926
- const space = spaces?.find((space2) => space2.id === spaceId && space2.state.get() === SpaceState2.SPACE_READY);
2927
- if (!objectId) {
2928
- const label2 = space ? space.properties.name || [
2929
- "unnamed space label",
2930
- {
2931
- ns: SPACE_PLUGIN
2932
- }
2933
- ] : [
2934
- "unnamed object settings label",
2935
- {
2936
- ns: SPACE_PLUGIN
2937
- }
2938
- ];
2939
- return {
2940
- id,
2941
- type,
2942
- data: null,
2943
- properties: {
2944
- icon,
2945
- label: label2,
2946
- showResolvedThreads: false,
2947
- object: null,
2948
- space
2949
- }
2950
- };
2951
- }
2952
- const [object] = memoizeQuery(space, {
2953
- id: objectId
2954
- });
2955
- if (!object || !subjectId) {
2956
- return;
2957
- }
2958
- const meta = resolve(getTypename2(object) ?? "");
2959
- const label = meta.label?.(object) || object.name || meta.placeholder || [
2960
- "unnamed object settings label",
2961
- {
2962
- ns: SPACE_PLUGIN
2963
- }
2964
- ];
2965
- return {
2966
- id,
2967
- type,
2968
- data: null,
2969
- properties: {
2970
- icon,
2971
- label,
2972
- object
2973
- }
2974
- };
2975
- }
2976
- })
2977
- ];
2978
- },
2979
- serializer: (plugins) => {
2980
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
2981
- if (!dispatch) {
2982
- return [];
2983
- }
2984
- return [
2985
- {
2986
- inputType: SPACES,
2987
- outputType: DIRECTORY_TYPE,
2988
- serialize: (node) => ({
2989
- name: translations_default[0]["en-US"][SPACE_PLUGIN]["spaces label"],
2990
- data: translations_default[0]["en-US"][SPACE_PLUGIN]["spaces label"],
2991
- type: DIRECTORY_TYPE
2992
- }),
2993
- deserialize: () => {
2994
- }
2995
- },
2996
- {
2997
- inputType: SPACE_TYPE,
2998
- outputType: DIRECTORY_TYPE,
2999
- serialize: (node) => ({
3000
- name: node.data.properties.name ?? translations_default[0]["en-US"][SPACE_PLUGIN]["unnamed space label"],
3001
- data: node.data.properties.name ?? translations_default[0]["en-US"][SPACE_PLUGIN]["unnamed space label"],
3002
- type: DIRECTORY_TYPE
3003
- }),
3004
- deserialize: async (data) => {
3005
- const result = await dispatch(createIntent8(SpaceAction.Create, {
3006
- name: data.name,
3007
- edgeReplication: true
3008
- }));
3009
- return result.data?.space;
3010
- }
3011
- },
3012
- {
3013
- inputType: CollectionType.typename,
3014
- outputType: DIRECTORY_TYPE,
3015
- serialize: (node) => ({
3016
- name: node.data.name ?? translations_default[0]["en-US"][SPACE_PLUGIN]["unnamed collection label"],
3017
- data: node.data.name ?? translations_default[0]["en-US"][SPACE_PLUGIN]["unnamed collection label"],
3018
- type: DIRECTORY_TYPE
3019
- }),
3020
- deserialize: async (data, ancestors) => {
3021
- const space = ancestors.find(isSpace4);
3022
- const collection = ancestors.findLast((ancestor) => ancestor instanceof CollectionType) ?? space?.properties[CollectionType.typename]?.target;
3023
- if (!space || !collection) {
3024
- return;
3025
- }
3026
- const result = await dispatch(createIntent8(SpaceAction.AddObject, {
3027
- target: collection,
3028
- object: create(CollectionType, {
3029
- name: data.name,
3030
- objects: [],
3031
- views: {}
3032
- })
3033
- }));
3034
- return result.data?.object;
3035
- }
3036
- }
3037
- ];
3038
- }
3039
- },
3040
- intent: {
3041
- resolvers: ({ plugins, dispatchPromise: dispatch }) => {
3042
- const activeParts = resolvePlugin(plugins, parseNavigationPlugin2)?.provides.location.active;
3043
- const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
3044
- const resolve = resolvePlugin(plugins, parseMetadataResolverPlugin)?.provides.metadata.resolver;
3045
- invariant2(activeParts, "Active parts not available.", {
3046
- F: __dxlog_file6,
3047
- L: 1078,
3048
- S: void 0,
3049
- A: [
3050
- "activeParts",
3051
- "'Active parts not available.'"
3052
- ]
3053
- });
3054
- invariant2(client, "Client not available.", {
3055
- F: __dxlog_file6,
3056
- L: 1079,
3057
- S: void 0,
3058
- A: [
3059
- "client",
3060
- "'Client not available.'"
3061
- ]
3062
- });
3063
- invariant2(resolve, "Metadata resolver not available.", {
3064
- F: __dxlog_file6,
3065
- L: 1080,
3066
- S: void 0,
3067
- A: [
3068
- "resolve",
3069
- "'Metadata resolver not available.'"
3070
- ]
3071
- });
3072
- return [
3073
- createResolver(SpaceAction.OpenCreateSpace, () => ({
3074
- intents: [
3075
- createIntent8(LayoutAction2.SetLayout, {
3076
- element: "dialog",
3077
- component: CREATE_SPACE_DIALOG,
3078
- dialogBlockAlign: "start"
3079
- })
3080
- ]
3081
- })),
3082
- createResolver(SpaceAction.Create, async ({ name, edgeReplication }) => {
3083
- const space = await client.spaces.create({
3084
- name
3085
- });
3086
- if (edgeReplication) {
3087
- await space.internal.setEdgeReplicationPreference(EdgeReplicationSetting3.ENABLED);
3088
- }
3089
- await space.waitUntilReady();
3090
- const collection = create(CollectionType, {
3091
- objects: [],
3092
- views: {}
3093
- });
3094
- space.properties[CollectionType.typename] = makeRef2(collection);
3095
- if (Migrations2.versionProperty) {
3096
- space.properties[Migrations2.versionProperty] = Migrations2.targetVersion;
3097
- }
3098
- return {
3099
- data: {
3100
- space,
3101
- id: space.id,
3102
- activeParts: {
3103
- main: [
3104
- space.id
3105
- ]
3106
- }
3107
- },
3108
- intents: [
3109
- createIntent8(ObservabilityAction2.SendEvent, {
3110
- name: "space.create",
3111
- properties: {
3112
- spaceId: space.id
3113
- }
3114
- })
3115
- ]
3116
- };
3117
- }),
3118
- createResolver(SpaceAction.Join, ({ invitationCode }) => ({
3119
- intents: [
3120
- createIntent8(LayoutAction2.SetLayout, {
3121
- element: "dialog",
3122
- component: JOIN_DIALOG,
3123
- dialogBlockAlign: "start",
3124
- subject: {
3125
- initialInvitationCode: invitationCode
3126
- }
3127
- })
3128
- ]
3129
- })),
3130
- createResolver(SpaceAction.Share, ({ space }) => {
3131
- const active = navigationPlugin?.provides.location.active;
3132
- const mode = layoutPlugin?.provides.layout.layoutMode;
3133
- const current = active ? firstIdInPart(active, mode === "solo" ? "solo" : "main") : void 0;
3134
- const target = current?.startsWith(space.id) ? current : void 0;
3135
- return {
3136
- intents: [
3137
- createIntent8(LayoutAction2.SetLayout, {
3138
- element: "dialog",
3139
- component: SPACE_SETTINGS_DIALOG,
3140
- dialogBlockAlign: "start",
3141
- subject: {
3142
- space,
3143
- target,
3144
- initialTab: "members",
3145
- createInvitationUrl: createSpaceInvitationUrl
3146
- }
3147
- }),
3148
- createIntent8(ObservabilityAction2.SendEvent, {
3149
- name: "space.share",
3150
- properties: {
3151
- space: space.id
3152
- }
3153
- })
3154
- ]
3155
- };
3156
- }, {
3157
- filter: (data) => !data.space.properties[COMPOSER_SPACE_LOCK]
3158
- }),
3159
- createResolver(SpaceAction.Lock, ({ space }) => {
3160
- space.properties[COMPOSER_SPACE_LOCK] = true;
3161
- return {
3162
- intents: [
3163
- createIntent8(ObservabilityAction2.SendEvent, {
3164
- name: "space.lock",
3165
- properties: {
3166
- spaceId: space.id
3167
- }
3168
- })
3169
- ]
3170
- };
3171
- }),
3172
- createResolver(SpaceAction.Unlock, ({ space }) => {
3173
- space.properties[COMPOSER_SPACE_LOCK] = false;
3174
- return {
3175
- intents: [
3176
- createIntent8(ObservabilityAction2.SendEvent, {
3177
- name: "space.unlock",
3178
- properties: {
3179
- spaceId: space.id
3180
- }
3181
- })
3182
- ]
3183
- };
3184
- }),
3185
- createResolver(SpaceAction.Rename, ({ caller, space }) => {
3186
- return {
3187
- intents: [
3188
- createIntent8(LayoutAction2.SetLayout, {
3189
- element: "popover",
3190
- anchorId: `dxos.org/ui/${caller}/${space.id}`,
3191
- component: POPOVER_RENAME_SPACE,
3192
- subject: space
3193
- })
3194
- ]
3195
- };
3196
- }),
3197
- createResolver(SpaceAction.OpenSettings, ({ space }) => {
3198
- return {
3199
- intents: [
3200
- createIntent8(LayoutAction2.SetLayout, {
3201
- element: "dialog",
3202
- component: SPACE_SETTINGS_DIALOG,
3203
- dialogBlockAlign: "start",
3204
- subject: {
3205
- space,
3206
- initialTab: "settings",
3207
- createInvitationUrl: createSpaceInvitationUrl
3208
- }
3209
- })
3210
- ]
3211
- };
3212
- }),
3213
- createResolver(SpaceAction.Open, async ({ space }) => {
3214
- await space.open();
3215
- }),
3216
- createResolver(SpaceAction.Close, async ({ space }) => {
3217
- await space.close();
3218
- }),
3219
- createResolver(SpaceAction.Migrate, async ({ space, version }) => {
3220
- if (space.state.get() === SpaceState2.SPACE_REQUIRES_MIGRATION) {
3221
- state.values.sdkMigrationRunning[space.id] = true;
3222
- await space.internal.migrate();
3223
- state.values.sdkMigrationRunning[space.id] = false;
3224
- }
3225
- const result = await Migrations2.migrate(space, version);
3226
- return {
3227
- data: result,
3228
- intents: [
3229
- createIntent8(ObservabilityAction2.SendEvent, {
3230
- name: "space.migrate",
3231
- properties: {
3232
- spaceId: space.id,
3233
- version
3234
- }
3235
- })
3236
- ]
3237
- };
3238
- }),
3239
- createResolver(SpaceAction.OpenCreateObject, ({ target, navigable = true }) => {
3240
- return {
3241
- intents: [
3242
- createIntent8(LayoutAction2.SetLayout, {
3243
- element: "dialog",
3244
- component: CREATE_OBJECT_DIALOG,
3245
- dialogBlockAlign: "start",
3246
- subject: {
3247
- target,
3248
- shouldNavigate: navigable ? (object) => !(object instanceof CollectionType) || state.values.navigableCollections : () => false
3249
- }
3250
- })
3251
- ]
3252
- };
3253
- }),
3254
- createResolver(SpaceAction.AddObject, async ({ target, object }) => {
3255
- const space = isSpace4(target) ? target : getSpace5(target);
3256
- invariant2(space, "Space not found.", {
3257
- F: __dxlog_file6,
3258
- L: 1265,
3259
- S: void 0,
3260
- A: [
3261
- "space",
3262
- "'Space not found.'"
3263
- ]
3264
- });
3265
- if (space.db.coreDatabase.getAllObjectIds().length >= SPACE_MAX_OBJECTS) {
3266
- void dispatch(createIntent8(LayoutAction2.SetLayout, {
3267
- element: "toast",
3268
- subject: {
3269
- id: `${SPACE_PLUGIN}/space-limit`,
3270
- title: [
3271
- "space limit label",
3272
- {
3273
- ns: SPACE_PLUGIN
3274
- }
3275
- ],
3276
- description: [
3277
- "space limit description",
3278
- {
3279
- ns: SPACE_PLUGIN
3280
- }
3281
- ],
3282
- duration: 5e3,
3283
- icon: "ph--warning--regular",
3284
- actionLabel: [
3285
- "remove deleted objects label",
3286
- {
3287
- ns: SPACE_PLUGIN
3288
- }
3289
- ],
3290
- actionAlt: [
3291
- "remove deleted objects alt",
3292
- {
3293
- ns: SPACE_PLUGIN
3294
- }
3295
- ],
3296
- closeLabel: [
3297
- "close label",
3298
- {
3299
- ns: "os"
3300
- }
3301
- ],
3302
- onAction: () => space.db.coreDatabase.unlinkDeletedObjects()
3303
- }
3304
- }));
3305
- void dispatch(createIntent8(ObservabilityAction2.SendEvent, {
3306
- name: "space.limit",
3307
- properties: {
3308
- spaceId: space.id
3309
- }
3310
- }));
3311
- throw new Error("Space limit reached.");
3312
- }
3313
- if (target instanceof CollectionType) {
3314
- target.objects.push(makeRef2(object));
3315
- } else if (isSpace4(target)) {
3316
- const collection = space.properties[CollectionType.typename]?.target;
3317
- if (collection instanceof CollectionType) {
3318
- collection.objects.push(makeRef2(object));
3319
- } else {
3320
- const collection2 = create(CollectionType, {
3321
- objects: [
3322
- makeRef2(object)
3323
- ],
3324
- views: {}
3325
- });
3326
- space.properties[CollectionType.typename] = makeRef2(collection2);
3327
- }
3328
- }
3329
- return {
3330
- data: {
3331
- id: fullyQualifiedId4(object),
3332
- object,
3333
- activeParts: {
3334
- main: [
3335
- fullyQualifiedId4(object)
3336
- ]
3337
- }
3338
- },
3339
- intents: [
3340
- createIntent8(ObservabilityAction2.SendEvent, {
3341
- name: "space.object.add",
3342
- properties: {
3343
- spaceId: space.id,
3344
- objectId: object.id,
3345
- typename: getTypename2(object)
3346
- }
3347
- })
3348
- ]
3349
- };
3350
- }),
3351
- createResolver(SpaceAction.RemoveObjects, async ({ objects, target, deletionData }, undo) => {
3352
- const space = getSpace5(objects[0]);
3353
- invariant2(space && objects.every((obj) => isEchoObject2(obj) && getSpace5(obj) === space), void 0, {
3354
- F: __dxlog_file6,
3355
- L: 1330,
3356
- S: void 0,
3357
- A: [
3358
- "space && objects.every((obj) => isEchoObject(obj) && getSpace(obj) === space)",
3359
- ""
3360
- ]
3361
- });
3362
- const openObjectIds = new Set(openIds(activeParts ?? {}));
3363
- if (!undo) {
3364
- const parentCollection = target ?? space.properties[CollectionType.typename]?.target;
3365
- const nestedObjectsList = await Promise.all(objects.map((obj) => getNestedObjects(obj, resolve)));
3366
- const deletionData2 = {
3367
- objects,
3368
- parentCollection,
3369
- indices: objects.map((obj) => parentCollection instanceof CollectionType ? parentCollection.objects.findIndex((object) => object.target === obj) : -1),
3370
- nestedObjectsList,
3371
- wasActive: objects.flatMap((obj, i) => [
3372
- obj,
3373
- ...nestedObjectsList[i]
3374
- ]).map((obj) => fullyQualifiedId4(obj)).filter((id) => openObjectIds.has(id))
3375
- };
3376
- if (deletionData2.parentCollection instanceof CollectionType) {
3377
- [
3378
- ...deletionData2.indices
3379
- ].sort((a, b) => b - a).forEach((index) => {
3380
- if (index !== -1) {
3381
- deletionData2.parentCollection.objects.splice(index, 1);
3382
- }
3383
- });
3384
- }
3385
- deletionData2.nestedObjectsList.flat().forEach((obj) => {
3386
- space.db.remove(obj);
3387
- });
3388
- objects.forEach((obj) => space.db.remove(obj));
3389
- const undoMessageKey = objects.some((obj) => obj instanceof CollectionType) ? "collection deleted label" : objects.length > 1 ? "objects deleted label" : "object deleted label";
3390
- return {
3391
- undoable: {
3392
- // TODO(ZaymonFC): Pluralize if more than one object.
3393
- message: [
3394
- undoMessageKey,
3395
- {
3396
- ns: SPACE_PLUGIN
3397
- }
3398
- ],
3399
- data: {
3400
- deletionData: deletionData2
3401
- }
3402
- },
3403
- intents: deletionData2.wasActive.length > 0 ? [
3404
- createIntent8(NavigationAction5.Close, {
3405
- activeParts: {
3406
- main: deletionData2.wasActive
3407
- }
3408
- })
3409
- ] : void 0
3410
- };
3411
- } else {
3412
- if (deletionData?.objects?.length && deletionData.objects.every(isEchoObject2) && deletionData.parentCollection instanceof CollectionType) {
3413
- const restoredObjects = deletionData.objects.map((obj) => space.db.add(obj));
3414
- deletionData.nestedObjectsList.flat().forEach((obj) => {
3415
- space.db.add(obj);
3416
- });
3417
- deletionData.indices.forEach((index, i) => {
3418
- if (index !== -1) {
3419
- deletionData.parentCollection.objects.splice(index, 0, makeRef2(restoredObjects[i]));
3420
- }
3421
- });
3422
- return {
3423
- intents: deletionData.wasActive.length > 0 ? [
3424
- createIntent8(NavigationAction5.Open, {
3425
- activeParts: {
3426
- main: deletionData.wasActive
3427
- }
3428
- })
3429
- ] : void 0
3430
- };
3431
- }
3432
- }
3433
- }),
3434
- createResolver(SpaceAction.RenameObject, async ({ object, caller }) => ({
3435
- intents: [
3436
- createIntent8(LayoutAction2.SetLayout, {
3437
- element: "popover",
3438
- anchorId: `dxos.org/ui/${caller}/${fullyQualifiedId4(object)}`,
3439
- component: POPOVER_RENAME_OBJECT,
3440
- subject: object
3441
- })
3442
- ]
3443
- })),
3444
- createResolver(SpaceAction.DuplicateObject, async ({ object, target }) => {
3445
- const space = isSpace4(target) ? target : getSpace5(target);
3446
- invariant2(space, "Space not found.", {
3447
- F: __dxlog_file6,
3448
- L: 1429,
3449
- S: void 0,
3450
- A: [
3451
- "space",
3452
- "'Space not found.'"
3453
- ]
3454
- });
3455
- const newObject = await cloneObject(object, resolve, space);
3456
- return {
3457
- intents: [
3458
- createIntent8(SpaceAction.AddObject, {
3459
- object: newObject,
3460
- target
3461
- })
3462
- ]
3463
- };
3464
- }),
3465
- createResolver(SpaceAction.WaitForObject, async ({ id }) => {
3466
- state.values.awaiting = id;
3467
- }),
3468
- createResolver(SpaceAction.ToggleHidden, async ({ state: state2 }) => {
3469
- settings.values.showHidden = state2;
3470
- }),
3471
- createResolver(CollectionAction.Create, async ({ name }) => ({
3472
- data: {
3473
- object: create(CollectionType, {
3474
- name,
3475
- objects: [],
3476
- views: {}
3477
- })
3478
- }
3479
- }))
3480
- ];
3481
- }
3482
- }
3483
- }
3484
- };
229
+ activate: IdentityCreated
230
+ }),
231
+ defineModule({
232
+ id: `${meta.id}/module/spaces-ready`,
233
+ activatesOn: allOf(Events.DispatcherReady, Events.LayoutReady, Events.AppGraphReady, AttentionEvents.AttentionReady, SpaceEvents.StateReady, ClientEvents.SpacesReady),
234
+ activate: SpacesReady
235
+ })
236
+ ]);
3485
237
  };
3486
-
3487
- // packages/plugins/plugin-space/src/index.ts
3488
- var src_default = SpacePlugin;
3489
238
  export {
3490
- ActorSchema,
239
+ AdvancedObjectSettings,
3491
240
  AwaitingObject,
241
+ BaseObjectSettings,
3492
242
  COMPOSER_SPACE_LOCK,
3493
243
  CREATE_OBJECT_DIALOG,
3494
244
  CREATE_SPACE_DIALOG,
3495
- ChannelType,
3496
- CollectionAction,
3497
245
  CollectionMain,
3498
246
  CollectionSection,
3499
- CollectionType,
3500
- ContactType,
3501
247
  CreateObjectDialog,
3502
248
  CreateSpaceDialog,
3503
- DefaultObjectSettings,
3504
249
  FullPresence,
3505
250
  InlineSyncStatus,
3506
251
  JOIN_DIALOG,
3507
252
  JoinDialog,
3508
253
  MenuFooter,
3509
- MessageState,
3510
- MessageType,
254
+ POPOVER_ADD_SPACE,
3511
255
  POPOVER_RENAME_OBJECT,
3512
256
  POPOVER_RENAME_SPACE,
3513
257
  PersistenceStatus,
258
+ PopoverAddSpace,
3514
259
  PopoverRenameObject,
3515
260
  PopoverRenameSpace,
3516
261
  SHARED,
3517
262
  SPACES,
3518
- SPACE_ACTION,
3519
- SPACE_DIRECTORY_HANDLE,
3520
263
  SPACE_PLUGIN,
3521
- SPACE_PLUGIN_SHORT_ID,
3522
264
  SPACE_SETTINGS_DIALOG,
3523
265
  SPACE_TYPE,
3524
266
  ShareSpaceButton,
3525
267
  ShareSpaceButtonImpl,
3526
268
  SmallPresence,
3527
269
  SmallPresenceLive,
3528
- SpaceAction,
3529
- SpaceForm,
270
+ SpaceCapabilities,
271
+ SpaceEvents,
3530
272
  SpacePlugin,
3531
273
  SpacePluginSettings,
3532
274
  SpacePresence,
@@ -3535,20 +277,17 @@ export {
3535
277
  SyncStatus,
3536
278
  SyncStatusDetail,
3537
279
  SyncStatusIndicator,
3538
- ThreadStatus,
3539
- ThreadType,
280
+ ThreadCapabilities,
281
+ ThreadEvents,
3540
282
  cloneObject,
3541
283
  constructObjectActions,
3542
284
  constructSpaceActions,
3543
285
  constructSpaceNode,
3544
286
  createObjectNode,
3545
- src_default as default,
3546
287
  getActiveSpace,
3547
288
  getNestedObjects,
3548
289
  getSpaceDisplayName,
3549
290
  memoizeQuery,
3550
- parseSchemaPlugin,
3551
- parseSpacePlugin,
3552
- translations_default as translations
291
+ meta
3553
292
  };
3554
293
  //# sourceMappingURL=index.mjs.map