@dxos/plugin-space 0.7.4 → 0.7.5-feature-compute.4d9d99a

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