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