@dxos/plugin-space 0.8.2-staging.7ac8446 → 0.8.2

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 (341) hide show
  1. package/dist/lib/browser/app-graph-builder-DCWUULKX.mjs +328 -0
  2. package/dist/lib/browser/app-graph-builder-DCWUULKX.mjs.map +7 -0
  3. package/dist/lib/browser/{app-graph-serializer-DSF2U3A5.mjs → app-graph-serializer-MLU7XI2P.mjs} +10 -10
  4. package/dist/lib/browser/app-graph-serializer-MLU7XI2P.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-KVRYWFZU.mjs → chunk-3LN4LJN6.mjs} +3 -8
  6. package/dist/lib/{node-esm/chunk-PIYAWT5N.mjs.map → browser/chunk-3LN4LJN6.mjs.map} +3 -3
  7. package/dist/lib/browser/chunk-7Y4M7GXO.mjs +94 -0
  8. package/dist/lib/browser/chunk-7Y4M7GXO.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-LO5UL6RU.mjs → chunk-N5QMRLKI.mjs} +78 -173
  10. package/dist/lib/browser/chunk-N5QMRLKI.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-Q4BTFH2P.mjs +1900 -0
  12. package/dist/lib/browser/chunk-Q4BTFH2P.mjs.map +7 -0
  13. package/dist/lib/browser/{chunk-5BDV575R.mjs → chunk-VEBKN45O.mjs} +21 -10
  14. package/dist/lib/browser/chunk-VEBKN45O.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-W46VVHFM.mjs +288 -0
  16. package/dist/lib/browser/chunk-W46VVHFM.mjs.map +7 -0
  17. package/dist/lib/browser/{identity-created-JR7BNXFH.mjs → identity-created-O63SIYOF.mjs} +5 -5
  18. package/dist/lib/browser/identity-created-O63SIYOF.mjs.map +7 -0
  19. package/dist/lib/browser/index.mjs +34 -54
  20. package/dist/lib/browser/index.mjs.map +3 -3
  21. package/dist/lib/browser/{intent-resolver-RKYILWWQ.mjs → intent-resolver-KBF3YU6I.mjs} +116 -108
  22. package/dist/lib/browser/intent-resolver-KBF3YU6I.mjs.map +7 -0
  23. package/dist/lib/browser/meta.json +1 -1
  24. package/dist/lib/browser/{react-root-6H7NX2M2.mjs → react-root-PVKJE4EZ.mjs} +6 -5
  25. package/dist/lib/browser/{react-surface-7AGLOVMK.mjs → react-surface-252P4NCK.mjs} +121 -54
  26. package/dist/lib/browser/react-surface-252P4NCK.mjs.map +7 -0
  27. package/dist/lib/browser/schema-defs-JMN74RNK.mjs +26 -0
  28. package/dist/lib/browser/schema-defs-JMN74RNK.mjs.map +7 -0
  29. package/dist/lib/browser/{schema-tools-YAXPRIXP.mjs → schema-tools-JIEMHUXV.mjs} +26 -26
  30. package/dist/lib/browser/schema-tools-JIEMHUXV.mjs.map +7 -0
  31. package/dist/lib/browser/{settings-PJPTJUPE.mjs → settings-2IN2WLUK.mjs} +4 -4
  32. package/dist/lib/browser/settings-2IN2WLUK.mjs.map +7 -0
  33. package/dist/lib/browser/{spaces-ready-BSSP7HHG.mjs → spaces-ready-L4QAGTDE.mjs} +20 -19
  34. package/dist/lib/browser/spaces-ready-L4QAGTDE.mjs.map +7 -0
  35. package/dist/lib/browser/{state-X7VLCC6E.mjs → state-6HOSHLIN.mjs} +3 -5
  36. package/dist/lib/browser/state-6HOSHLIN.mjs.map +7 -0
  37. package/dist/lib/browser/types/index.mjs +7 -7
  38. package/dist/lib/node/app-graph-builder-WC445X77.cjs +328 -0
  39. package/dist/lib/node/app-graph-builder-WC445X77.cjs.map +7 -0
  40. package/dist/lib/node/{app-graph-serializer-JELGJUAY.cjs → app-graph-serializer-UPQOQVMJ.cjs} +22 -22
  41. package/dist/lib/node/app-graph-serializer-UPQOQVMJ.cjs.map +7 -0
  42. package/dist/lib/node/chunk-5WLAXYE3.cjs +125 -0
  43. package/dist/lib/node/chunk-5WLAXYE3.cjs.map +7 -0
  44. package/dist/lib/node/{chunk-IKIDS6XF.cjs → chunk-7GQGM4ZF.cjs} +7 -13
  45. package/dist/lib/node/{chunk-IKIDS6XF.cjs.map → chunk-7GQGM4ZF.cjs.map} +3 -3
  46. package/dist/lib/node/{chunk-TUZWEPGX.cjs → chunk-COQYISES.cjs} +100 -198
  47. package/dist/lib/node/chunk-COQYISES.cjs.map +7 -0
  48. package/dist/lib/node/{chunk-PU2EYH4E.cjs → chunk-DXL5TDFP.cjs} +25 -14
  49. package/dist/lib/node/chunk-DXL5TDFP.cjs.map +7 -0
  50. package/dist/lib/node/chunk-FXHI7JNY.cjs +315 -0
  51. package/dist/lib/node/chunk-FXHI7JNY.cjs.map +7 -0
  52. package/dist/lib/node/chunk-Q3YZEYZT.cjs +1904 -0
  53. package/dist/lib/node/chunk-Q3YZEYZT.cjs.map +7 -0
  54. package/dist/lib/node/{identity-created-XU4HFV2T.cjs → identity-created-UXEAUGC7.cjs} +7 -7
  55. package/dist/lib/node/identity-created-UXEAUGC7.cjs.map +7 -0
  56. package/dist/lib/node/index.cjs +83 -105
  57. package/dist/lib/node/index.cjs.map +3 -3
  58. package/dist/lib/node/{intent-resolver-VJ7YV74L.cjs → intent-resolver-SVFJKUH7.cjs} +161 -152
  59. package/dist/lib/node/intent-resolver-SVFJKUH7.cjs.map +7 -0
  60. package/dist/lib/node/meta.json +1 -1
  61. package/dist/lib/node/{react-root-TEL5RW3N.cjs → react-root-DDPDUMCG.cjs} +11 -10
  62. package/dist/lib/node/{react-root-TEL5RW3N.cjs.map → react-root-DDPDUMCG.cjs.map} +1 -1
  63. package/dist/lib/node/{react-surface-2H3S5TY5.cjs → react-surface-JUIU37BX.cjs} +144 -77
  64. package/dist/lib/node/react-surface-JUIU37BX.cjs.map +7 -0
  65. package/dist/lib/node/{schema-PPJ5BZ3A.cjs → schema-defs-XLFBG3XK.cjs} +14 -12
  66. package/dist/lib/node/schema-defs-XLFBG3XK.cjs.map +7 -0
  67. package/dist/lib/node/{schema-tools-BLIMOZYY.cjs → schema-tools-ZG6Z2QRC.cjs} +32 -32
  68. package/dist/lib/node/schema-tools-ZG6Z2QRC.cjs.map +7 -0
  69. package/dist/lib/node/{settings-WVFP2UEP.cjs → settings-FOH7EB5C.cjs} +7 -7
  70. package/dist/lib/node/settings-FOH7EB5C.cjs.map +7 -0
  71. package/dist/lib/node/{spaces-ready-7DNZSUOG.cjs → spaces-ready-VXQYCBII.cjs} +27 -26
  72. package/dist/lib/node/spaces-ready-VXQYCBII.cjs.map +7 -0
  73. package/dist/lib/node/{state-5KX6WBJH.cjs → state-ZT3MTZXB.cjs} +7 -9
  74. package/dist/lib/node/state-ZT3MTZXB.cjs.map +7 -0
  75. package/dist/lib/node/types/index.cjs +15 -15
  76. package/dist/lib/node/types/index.cjs.map +1 -1
  77. package/dist/lib/node-esm/app-graph-builder-E7CCGPQJ.mjs +329 -0
  78. package/dist/lib/node-esm/app-graph-builder-E7CCGPQJ.mjs.map +7 -0
  79. package/dist/lib/node-esm/{app-graph-serializer-FXONFKOE.mjs → app-graph-serializer-UCMSLPIA.mjs} +10 -10
  80. package/dist/lib/node-esm/app-graph-serializer-UCMSLPIA.mjs.map +7 -0
  81. package/dist/lib/node-esm/{chunk-PIYAWT5N.mjs → chunk-4X4Y63ND.mjs} +3 -8
  82. package/dist/lib/{browser/chunk-KVRYWFZU.mjs.map → node-esm/chunk-4X4Y63ND.mjs.map} +3 -3
  83. package/dist/lib/node-esm/chunk-FTELJGEG.mjs +289 -0
  84. package/dist/lib/node-esm/chunk-FTELJGEG.mjs.map +7 -0
  85. package/dist/lib/node-esm/chunk-GH2FGJXH.mjs +96 -0
  86. package/dist/lib/node-esm/chunk-GH2FGJXH.mjs.map +7 -0
  87. package/dist/lib/node-esm/chunk-HL2Z2GNW.mjs +1901 -0
  88. package/dist/lib/node-esm/chunk-HL2Z2GNW.mjs.map +7 -0
  89. package/dist/lib/node-esm/{chunk-3ZOUV4DF.mjs → chunk-OSPEGYX3.mjs} +21 -10
  90. package/dist/lib/node-esm/chunk-OSPEGYX3.mjs.map +7 -0
  91. package/dist/lib/node-esm/{chunk-ZGLK25WQ.mjs → chunk-XAZNQ3QN.mjs} +78 -173
  92. package/dist/lib/node-esm/chunk-XAZNQ3QN.mjs.map +7 -0
  93. package/dist/lib/node-esm/{identity-created-WJKAS2PV.mjs → identity-created-ZECO4NH3.mjs} +5 -5
  94. package/dist/lib/node-esm/identity-created-ZECO4NH3.mjs.map +7 -0
  95. package/dist/lib/node-esm/index.mjs +34 -54
  96. package/dist/lib/node-esm/index.mjs.map +3 -3
  97. package/dist/lib/node-esm/{intent-resolver-ZFNSA4CM.mjs → intent-resolver-K2UDBF2R.mjs} +116 -108
  98. package/dist/lib/node-esm/intent-resolver-K2UDBF2R.mjs.map +7 -0
  99. package/dist/lib/node-esm/meta.json +1 -1
  100. package/dist/lib/node-esm/{react-root-PRBJMWLQ.mjs → react-root-6F7B3OVO.mjs} +6 -5
  101. package/dist/lib/{browser/react-root-6H7NX2M2.mjs.map → node-esm/react-root-6F7B3OVO.mjs.map} +1 -1
  102. package/dist/lib/node-esm/{react-surface-RCZG2PNF.mjs → react-surface-NP3Y6BNZ.mjs} +121 -54
  103. package/dist/lib/node-esm/react-surface-NP3Y6BNZ.mjs.map +7 -0
  104. package/dist/lib/node-esm/schema-defs-QZJS6UXN.mjs +27 -0
  105. package/dist/lib/node-esm/schema-defs-QZJS6UXN.mjs.map +7 -0
  106. package/dist/lib/node-esm/{schema-tools-IU7EX5A5.mjs → schema-tools-2Y4D42PD.mjs} +26 -26
  107. package/dist/lib/node-esm/schema-tools-2Y4D42PD.mjs.map +7 -0
  108. package/dist/lib/node-esm/{settings-FJZPC2TV.mjs → settings-Q4XDFSYD.mjs} +4 -4
  109. package/dist/lib/node-esm/settings-Q4XDFSYD.mjs.map +7 -0
  110. package/dist/lib/node-esm/{spaces-ready-7X5PGB2V.mjs → spaces-ready-JHKPD4PH.mjs} +20 -19
  111. package/dist/lib/node-esm/spaces-ready-JHKPD4PH.mjs.map +7 -0
  112. package/dist/lib/node-esm/{state-Z6E2YTNC.mjs → state-4ATRHSKA.mjs} +3 -5
  113. package/dist/lib/node-esm/state-4ATRHSKA.mjs.map +7 -0
  114. package/dist/lib/node-esm/types/index.mjs +7 -7
  115. package/dist/types/src/SpacePlugin.d.ts.map +1 -1
  116. package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
  117. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  118. package/dist/types/src/capabilities/app-graph-serializer.d.ts +2 -2
  119. package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +1 -1
  120. package/dist/types/src/capabilities/capabilities.d.ts +0 -8
  121. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  122. package/dist/types/src/capabilities/identity-created.d.ts +2 -2
  123. package/dist/types/src/capabilities/identity-created.d.ts.map +1 -1
  124. package/dist/types/src/capabilities/index.d.ts +9 -184
  125. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  126. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -3
  127. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  128. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  129. package/dist/types/src/capabilities/schema-defs.d.ts +4 -0
  130. package/dist/types/src/capabilities/schema-defs.d.ts.map +1 -0
  131. package/dist/types/src/capabilities/schema-tools.d.ts +3 -3
  132. package/dist/types/src/capabilities/schema-tools.d.ts.map +1 -1
  133. package/dist/types/src/capabilities/spaces-ready.d.ts +2 -2
  134. package/dist/types/src/capabilities/spaces-ready.d.ts.map +1 -1
  135. package/dist/types/src/capabilities/state.d.ts +2 -2
  136. package/dist/types/src/capabilities/state.d.ts.map +1 -1
  137. package/dist/types/src/components/AwaitingObject.d.ts.map +1 -1
  138. package/dist/types/src/components/CollectionMain.d.ts.map +1 -1
  139. package/dist/types/src/components/CollectionSection.d.ts.map +1 -1
  140. package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts +2 -2
  141. package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts.map +1 -1
  142. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts.map +1 -1
  143. package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts.map +1 -1
  144. package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
  145. package/dist/types/src/components/MembersContainer.d.ts.map +1 -1
  146. package/dist/types/src/components/MembersContainer.stories.d.ts.map +1 -1
  147. package/dist/types/src/components/MenuFooter.d.ts +2 -2
  148. package/dist/types/src/components/MenuFooter.d.ts.map +1 -1
  149. package/dist/types/src/components/{ObjectSettingsContainer → ObjectSettings}/AdvancedObjectSettings.d.ts +2 -2
  150. package/dist/types/src/components/ObjectSettings/AdvancedObjectSettings.d.ts.map +1 -0
  151. package/dist/types/src/components/{ObjectSettingsContainer → ObjectSettings}/BaseObjectSettings.d.ts +2 -2
  152. package/dist/types/src/components/ObjectSettings/BaseObjectSettings.d.ts.map +1 -0
  153. package/dist/types/src/components/ObjectSettings/ForeignKeys.d.ts.map +1 -0
  154. package/dist/types/src/components/{ObjectSettingsContainer → ObjectSettings}/ObjectSettingsContainer.d.ts +2 -2
  155. package/dist/types/src/components/ObjectSettings/ObjectSettingsContainer.d.ts.map +1 -0
  156. package/dist/types/src/components/ObjectSettings/index.d.ts.map +1 -0
  157. package/dist/types/src/components/PersistenceStatus.d.ts.map +1 -1
  158. package/dist/types/src/components/PopoverRenameObject.d.ts +2 -2
  159. package/dist/types/src/components/PopoverRenameObject.d.ts.map +1 -1
  160. package/dist/types/src/components/PopoverRenameSpace.d.ts.map +1 -1
  161. package/dist/types/src/components/SchemaContainer.d.ts +13 -0
  162. package/dist/types/src/components/SchemaContainer.d.ts.map +1 -0
  163. package/dist/types/src/components/SpacePluginSettings.d.ts.map +1 -1
  164. package/dist/types/src/components/SpacePresence.d.ts.map +1 -1
  165. package/dist/types/src/components/SpacePresence.stories.d.ts.map +1 -1
  166. package/dist/types/src/components/SpaceSettings/SpaceSettingsContainer.d.ts +0 -2
  167. package/dist/types/src/components/SpaceSettings/SpaceSettingsContainer.d.ts.map +1 -1
  168. package/dist/types/src/components/SpaceSettings/SpaceSettingsContainer.stories.d.ts +7 -0
  169. package/dist/types/src/components/SpaceSettings/SpaceSettingsContainer.stories.d.ts.map +1 -0
  170. package/dist/types/src/components/SpaceSettings/index.d.ts +0 -1
  171. package/dist/types/src/components/SpaceSettings/index.d.ts.map +1 -1
  172. package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts.map +1 -1
  173. package/dist/types/src/components/SyncStatus/SyncStatus.d.ts +1 -8
  174. package/dist/types/src/components/SyncStatus/SyncStatus.d.ts.map +1 -1
  175. package/dist/types/src/components/SyncStatus/save-tracker.d.ts.map +1 -1
  176. package/dist/types/src/components/SyncStatus/status.d.ts.map +1 -1
  177. package/dist/types/src/components/index.d.ts +2 -3
  178. package/dist/types/src/components/index.d.ts.map +1 -1
  179. package/dist/types/src/hooks/index.d.ts +2 -0
  180. package/dist/types/src/hooks/index.d.ts.map +1 -1
  181. package/dist/types/src/hooks/useActiveSpace.d.ts +4 -0
  182. package/dist/types/src/hooks/useActiveSpace.d.ts.map +1 -0
  183. package/dist/types/src/hooks/useInputSurfaceLookup.d.ts +14 -0
  184. package/dist/types/src/hooks/useInputSurfaceLookup.d.ts.map +1 -0
  185. package/dist/types/src/hooks/usePath.d.ts +3 -2
  186. package/dist/types/src/hooks/usePath.d.ts.map +1 -1
  187. package/dist/types/src/index.d.ts +3 -2
  188. package/dist/types/src/index.d.ts.map +1 -1
  189. package/dist/types/src/translations.d.ts +17 -242
  190. package/dist/types/src/translations.d.ts.map +1 -1
  191. package/dist/types/src/types/collection.d.ts +9 -8
  192. package/dist/types/src/types/collection.d.ts.map +1 -1
  193. package/dist/types/src/types/index.d.ts +0 -1
  194. package/dist/types/src/types/index.d.ts.map +1 -1
  195. package/dist/types/src/types/types.d.ts +173 -146
  196. package/dist/types/src/types/types.d.ts.map +1 -1
  197. package/dist/types/src/util.d.ts +36 -20
  198. package/dist/types/src/util.d.ts.map +1 -1
  199. package/dist/types/tsconfig.tsbuildinfo +1 -1
  200. package/package.json +54 -47
  201. package/src/SpacePlugin.tsx +11 -20
  202. package/src/capabilities/app-graph-builder.ts +377 -230
  203. package/src/capabilities/app-graph-serializer.ts +8 -8
  204. package/src/capabilities/capabilities.ts +0 -9
  205. package/src/capabilities/identity-created.ts +5 -5
  206. package/src/capabilities/index.ts +2 -2
  207. package/src/capabilities/intent-resolver.ts +107 -111
  208. package/src/capabilities/react-surface.tsx +111 -50
  209. package/src/capabilities/schema-defs.ts +30 -0
  210. package/src/capabilities/schema-tool.test.ts +2 -3
  211. package/src/capabilities/schema-tools.ts +29 -29
  212. package/src/capabilities/settings.ts +2 -2
  213. package/src/capabilities/spaces-ready.ts +17 -15
  214. package/src/capabilities/state.ts +3 -5
  215. package/src/components/AwaitingObject.tsx +1 -1
  216. package/src/components/CollectionMain.tsx +2 -5
  217. package/src/components/CreateDialog/CreateObjectDialog.stories.tsx +4 -4
  218. package/src/components/CreateDialog/CreateObjectDialog.tsx +4 -4
  219. package/src/components/CreateDialog/CreateObjectPanel.tsx +3 -25
  220. package/src/components/CreateDialog/CreateSpaceDialog.tsx +6 -3
  221. package/src/components/MembersContainer.stories.tsx +1 -5
  222. package/src/components/MembersContainer.tsx +80 -54
  223. package/src/components/MenuFooter.tsx +2 -2
  224. package/src/components/{ObjectSettingsContainer → ObjectSettings}/AdvancedObjectSettings.tsx +4 -4
  225. package/src/components/{ObjectSettingsContainer → ObjectSettings}/BaseObjectSettings.tsx +2 -2
  226. package/src/components/{ObjectSettingsContainer → ObjectSettings}/ObjectSettingsContainer.tsx +4 -4
  227. package/src/components/PersistenceStatus.tsx +11 -14
  228. package/src/components/PopoverRenameObject.tsx +15 -9
  229. package/src/components/PopoverRenameSpace.tsx +9 -1
  230. package/src/components/SchemaContainer.tsx +59 -0
  231. package/src/components/SpacePluginSettings.tsx +27 -2
  232. package/src/components/SpacePresence.stories.tsx +1 -1
  233. package/src/components/SpacePresence.tsx +60 -65
  234. package/src/components/SpaceSettings/{SpacePropertiesForm.stories.tsx → SpaceSettingsContainer.stories.tsx} +6 -6
  235. package/src/components/SpaceSettings/SpaceSettingsContainer.tsx +159 -39
  236. package/src/components/SpaceSettings/index.ts +0 -1
  237. package/src/components/SyncStatus/InlineSyncStatus.tsx +15 -24
  238. package/src/components/SyncStatus/SyncStatus.tsx +6 -69
  239. package/src/components/index.ts +2 -3
  240. package/src/hooks/index.ts +2 -0
  241. package/src/hooks/useActiveSpace.ts +20 -0
  242. package/src/hooks/useInputSurfaceLookup.tsx +31 -0
  243. package/src/hooks/usePath.ts +9 -6
  244. package/src/index.ts +3 -2
  245. package/src/translations.ts +19 -7
  246. package/src/types/collection.ts +6 -4
  247. package/src/types/index.ts +0 -1
  248. package/src/types/types.ts +130 -101
  249. package/src/util.tsx +75 -172
  250. package/dist/lib/browser/app-graph-builder-GMFCSOLG.mjs +0 -315
  251. package/dist/lib/browser/app-graph-builder-GMFCSOLG.mjs.map +0 -7
  252. package/dist/lib/browser/app-graph-serializer-DSF2U3A5.mjs.map +0 -7
  253. package/dist/lib/browser/chunk-5BDV575R.mjs.map +0 -7
  254. package/dist/lib/browser/chunk-AYW4IDRT.mjs +0 -275
  255. package/dist/lib/browser/chunk-AYW4IDRT.mjs.map +0 -7
  256. package/dist/lib/browser/chunk-JZXWPMLA.mjs +0 -2081
  257. package/dist/lib/browser/chunk-JZXWPMLA.mjs.map +0 -7
  258. package/dist/lib/browser/chunk-LO5UL6RU.mjs.map +0 -7
  259. package/dist/lib/browser/identity-created-JR7BNXFH.mjs.map +0 -7
  260. package/dist/lib/browser/intent-resolver-RKYILWWQ.mjs.map +0 -7
  261. package/dist/lib/browser/react-surface-7AGLOVMK.mjs.map +0 -7
  262. package/dist/lib/browser/schema-FHTA26SW.mjs +0 -24
  263. package/dist/lib/browser/schema-FHTA26SW.mjs.map +0 -7
  264. package/dist/lib/browser/schema-tools-YAXPRIXP.mjs.map +0 -7
  265. package/dist/lib/browser/settings-PJPTJUPE.mjs.map +0 -7
  266. package/dist/lib/browser/spaces-ready-BSSP7HHG.mjs.map +0 -7
  267. package/dist/lib/browser/state-X7VLCC6E.mjs.map +0 -7
  268. package/dist/lib/node/app-graph-builder-DPY7AUZE.cjs +0 -318
  269. package/dist/lib/node/app-graph-builder-DPY7AUZE.cjs.map +0 -7
  270. package/dist/lib/node/app-graph-serializer-JELGJUAY.cjs.map +0 -7
  271. package/dist/lib/node/chunk-3GKCNADA.cjs +0 -2074
  272. package/dist/lib/node/chunk-3GKCNADA.cjs.map +0 -7
  273. package/dist/lib/node/chunk-PU2EYH4E.cjs.map +0 -7
  274. package/dist/lib/node/chunk-TUZWEPGX.cjs.map +0 -7
  275. package/dist/lib/node/chunk-WDEIFDTX.cjs +0 -300
  276. package/dist/lib/node/chunk-WDEIFDTX.cjs.map +0 -7
  277. package/dist/lib/node/identity-created-XU4HFV2T.cjs.map +0 -7
  278. package/dist/lib/node/intent-resolver-VJ7YV74L.cjs.map +0 -7
  279. package/dist/lib/node/react-surface-2H3S5TY5.cjs.map +0 -7
  280. package/dist/lib/node/schema-PPJ5BZ3A.cjs.map +0 -7
  281. package/dist/lib/node/schema-tools-BLIMOZYY.cjs.map +0 -7
  282. package/dist/lib/node/settings-WVFP2UEP.cjs.map +0 -7
  283. package/dist/lib/node/spaces-ready-7DNZSUOG.cjs.map +0 -7
  284. package/dist/lib/node/state-5KX6WBJH.cjs.map +0 -7
  285. package/dist/lib/node-esm/app-graph-builder-42IGWRPL.mjs +0 -316
  286. package/dist/lib/node-esm/app-graph-builder-42IGWRPL.mjs.map +0 -7
  287. package/dist/lib/node-esm/app-graph-serializer-FXONFKOE.mjs.map +0 -7
  288. package/dist/lib/node-esm/chunk-3ZOUV4DF.mjs.map +0 -7
  289. package/dist/lib/node-esm/chunk-BEWBZ4Q4.mjs +0 -2082
  290. package/dist/lib/node-esm/chunk-BEWBZ4Q4.mjs.map +0 -7
  291. package/dist/lib/node-esm/chunk-FC4UHDPL.mjs +0 -276
  292. package/dist/lib/node-esm/chunk-FC4UHDPL.mjs.map +0 -7
  293. package/dist/lib/node-esm/chunk-ZGLK25WQ.mjs.map +0 -7
  294. package/dist/lib/node-esm/identity-created-WJKAS2PV.mjs.map +0 -7
  295. package/dist/lib/node-esm/intent-resolver-ZFNSA4CM.mjs.map +0 -7
  296. package/dist/lib/node-esm/react-surface-RCZG2PNF.mjs.map +0 -7
  297. package/dist/lib/node-esm/schema-OUZKVYM5.mjs +0 -25
  298. package/dist/lib/node-esm/schema-OUZKVYM5.mjs.map +0 -7
  299. package/dist/lib/node-esm/schema-tools-IU7EX5A5.mjs.map +0 -7
  300. package/dist/lib/node-esm/settings-FJZPC2TV.mjs.map +0 -7
  301. package/dist/lib/node-esm/spaces-ready-7X5PGB2V.mjs.map +0 -7
  302. package/dist/lib/node-esm/state-Z6E2YTNC.mjs.map +0 -7
  303. package/dist/types/src/capabilities/schema.d.ts +0 -4
  304. package/dist/types/src/capabilities/schema.d.ts.map +0 -1
  305. package/dist/types/src/components/ObjectSettingsContainer/AdvancedObjectSettings.d.ts.map +0 -1
  306. package/dist/types/src/components/ObjectSettingsContainer/BaseObjectSettings.d.ts.map +0 -1
  307. package/dist/types/src/components/ObjectSettingsContainer/ForeignKeys.d.ts.map +0 -1
  308. package/dist/types/src/components/ObjectSettingsContainer/ObjectSettingsContainer.d.ts.map +0 -1
  309. package/dist/types/src/components/ObjectSettingsContainer/index.d.ts.map +0 -1
  310. package/dist/types/src/components/PopoverAddSpace.d.ts +0 -4
  311. package/dist/types/src/components/PopoverAddSpace.d.ts.map +0 -1
  312. package/dist/types/src/components/ShareSpaceButton.d.ts +0 -9
  313. package/dist/types/src/components/ShareSpaceButton.d.ts.map +0 -1
  314. package/dist/types/src/components/ShareSpaceButton.stories.d.ts +0 -10
  315. package/dist/types/src/components/ShareSpaceButton.stories.d.ts.map +0 -1
  316. package/dist/types/src/components/SpaceSettings/SpacePropertiesForm.d.ts +0 -7
  317. package/dist/types/src/components/SpaceSettings/SpacePropertiesForm.d.ts.map +0 -1
  318. package/dist/types/src/components/SpaceSettings/SpacePropertiesForm.stories.d.ts +0 -7
  319. package/dist/types/src/components/SpaceSettings/SpacePropertiesForm.stories.d.ts.map +0 -1
  320. package/dist/types/src/components/SyncStatus/Space.d.ts +0 -13
  321. package/dist/types/src/components/SyncStatus/Space.d.ts.map +0 -1
  322. package/dist/types/src/components/SyncStatus/SyncStatusDetail.stories.d.ts +0 -9
  323. package/dist/types/src/components/SyncStatus/SyncStatusDetail.stories.d.ts.map +0 -1
  324. package/dist/types/src/components/SyncStatus/sync-state.d.ts +0 -18
  325. package/dist/types/src/components/SyncStatus/sync-state.d.ts.map +0 -1
  326. package/dist/types/src/types/thread.d.ts +0 -128
  327. package/dist/types/src/types/thread.d.ts.map +0 -1
  328. package/src/capabilities/schema.ts +0 -27
  329. package/src/components/PopoverAddSpace.tsx +0 -46
  330. package/src/components/ShareSpaceButton.stories.tsx +0 -27
  331. package/src/components/ShareSpaceButton.tsx +0 -32
  332. package/src/components/SpaceSettings/SpacePropertiesForm.tsx +0 -136
  333. package/src/components/SyncStatus/Space.tsx +0 -133
  334. package/src/components/SyncStatus/SyncStatusDetail.stories.tsx +0 -89
  335. package/src/components/SyncStatus/sync-state.ts +0 -101
  336. package/src/types/thread.ts +0 -24
  337. /package/dist/lib/{node-esm/react-root-PRBJMWLQ.mjs.map → browser/react-root-PVKJE4EZ.mjs.map} +0 -0
  338. /package/dist/types/src/components/{ObjectSettingsContainer → ObjectSettings}/ForeignKeys.d.ts +0 -0
  339. /package/dist/types/src/components/{ObjectSettingsContainer → ObjectSettings}/index.d.ts +0 -0
  340. /package/src/components/{ObjectSettingsContainer → ObjectSettings}/ForeignKeys.tsx +0 -0
  341. /package/src/components/{ObjectSettingsContainer → ObjectSettings}/index.ts +0 -0
@@ -1,2081 +0,0 @@
1
- import {
2
- SpaceCapabilities
3
- } from "./chunk-KVRYWFZU.mjs";
4
- import {
5
- getSpaceDisplayName
6
- } from "./chunk-LO5UL6RU.mjs";
7
- import {
8
- CollectionType,
9
- SpaceAction,
10
- SpaceForm
11
- } from "./chunk-AYW4IDRT.mjs";
12
- import {
13
- SPACE_PLUGIN,
14
- meta
15
- } from "./chunk-PTKYMZWO.mjs";
16
-
17
- // packages/plugins/plugin-space/src/components/AwaitingObject.tsx
18
- import { CheckCircle, CircleDashed, CircleNotch } from "@phosphor-icons/react";
19
- import React, { useCallback, useEffect, useState } from "react";
20
- import { createIntent, LayoutAction, useIntentDispatcher, useLayout } from "@dxos/app-framework";
21
- import { useClient } from "@dxos/react-client";
22
- import { Filter, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
23
- import { Button, Toast, useTranslation } from "@dxos/react-ui";
24
- import { getSize, mx } from "@dxos/react-ui-theme";
25
- var WAIT_FOR_OBJECT_TIMEOUT = 18e4;
26
- var TOAST_TIMEOUT = 24e4;
27
- var AwaitingObject = ({ id }) => {
28
- const [open, setOpen] = useState(true);
29
- const [waiting, setWaiting] = useState(true);
30
- const [found, setFound] = useState(false);
31
- const { t } = useTranslation(SPACE_PLUGIN);
32
- const { dispatchPromise: dispatch } = useIntentDispatcher();
33
- const layout = useLayout();
34
- const client = useClient();
35
- const objects = useQuery(client.spaces, Filter.all());
36
- useEffect(() => {
37
- if (!id) {
38
- return;
39
- }
40
- const timeout = setTimeout(() => {
41
- setWaiting(false);
42
- }, WAIT_FOR_OBJECT_TIMEOUT);
43
- () => clearTimeout(timeout);
44
- }, [
45
- id
46
- ]);
47
- useEffect(() => {
48
- if (objects.findIndex((object) => fullyQualifiedId(object) === id) > -1) {
49
- setFound(true);
50
- if (layout.active.includes(id)) {
51
- setOpen(false);
52
- }
53
- }
54
- }, [
55
- id,
56
- objects,
57
- layout
58
- ]);
59
- const handleClose = useCallback(async () => dispatch(createIntent(SpaceAction.WaitForObject, {
60
- id: void 0
61
- })), [
62
- dispatch
63
- ]);
64
- const handleNavigate = useCallback(() => {
65
- void dispatch(createIntent(LayoutAction.Open, {
66
- part: "main",
67
- subject: [
68
- id
69
- ]
70
- }));
71
- void handleClose();
72
- }, [
73
- id,
74
- handleClose,
75
- dispatch
76
- ]);
77
- return /* @__PURE__ */ React.createElement(Toast.Root, {
78
- open,
79
- duration: TOAST_TIMEOUT,
80
- onOpenChange: setOpen
81
- }, /* @__PURE__ */ React.createElement(Toast.Body, null, /* @__PURE__ */ React.createElement(Toast.Title, {
82
- classNames: "flex items-center gap-2"
83
- }, found ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CheckCircle, {
84
- className: getSize(5)
85
- }), /* @__PURE__ */ React.createElement("span", null, t("found object label"))) : waiting ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CircleNotch, {
86
- className: mx(getSize(5), "animate-spin")
87
- }), /* @__PURE__ */ React.createElement("span", null, t("waiting for object label"))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CircleDashed, {
88
- className: getSize(5)
89
- }), /* @__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, {
90
- altText: t("go to object alt"),
91
- asChild: true
92
- }, /* @__PURE__ */ React.createElement(Button, {
93
- variant: "primary",
94
- onClick: handleNavigate
95
- }, t("go to object label"))), /* @__PURE__ */ React.createElement(Toast.Close, {
96
- asChild: true
97
- }, /* @__PURE__ */ React.createElement(Button, {
98
- onClick: handleClose
99
- }, t("close label", {
100
- ns: "appkit"
101
- })))) : /* @__PURE__ */ React.createElement(Toast.Close, {
102
- asChild: true
103
- }, /* @__PURE__ */ React.createElement(Button, {
104
- onClick: handleClose
105
- }, t(waiting ? "close label" : "confirm label", {
106
- ns: "appkit"
107
- })))));
108
- };
109
-
110
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
111
- import { pipe } from "effect";
112
- import React3, { useCallback as useCallback3, useRef } from "react";
113
- import { Capabilities, chain, createIntent as createIntent2, LayoutAction as LayoutAction2, useCapabilities, useIntentDispatcher as useIntentDispatcher2, usePluginManager as usePluginManager2 } from "@dxos/app-framework";
114
- import { invariant as invariant2 } from "@dxos/invariant";
115
- import { useClient as useClient2 } from "@dxos/react-client";
116
- import { getSpace, isReactiveObject, isSpace, useSpaces } from "@dxos/react-client/echo";
117
- import { Button as Button2, Dialog, Icon as Icon2, useTranslation as useTranslation3 } from "@dxos/react-ui";
118
-
119
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx
120
- import React2, { useCallback as useCallback2, useState as useState2 } from "react";
121
- import { Surface, isSurfaceAvailable, usePluginManager } from "@dxos/app-framework";
122
- import { getTypeAnnotation } from "@dxos/echo-schema";
123
- import { invariant } from "@dxos/invariant";
124
- import { Icon, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
125
- import { Form } from "@dxos/react-ui-form";
126
- import { SearchList } from "@dxos/react-ui-searchlist";
127
- import { mx as mx2 } from "@dxos/react-ui-theme";
128
- import { isNonNullable } from "@dxos/util";
129
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectPanel.tsx";
130
- var useInputSurfaceLookup = (baseData) => {
131
- const pluginManager = usePluginManager();
132
- return useCallback2(({ prop, schema, inputProps }) => {
133
- const composedData = {
134
- prop,
135
- schema,
136
- ...baseData
137
- };
138
- if (!isSurfaceAvailable(pluginManager.context, {
139
- role: "form-input",
140
- data: composedData
141
- })) {
142
- return void 0;
143
- }
144
- return /* @__PURE__ */ React2.createElement(Surface, {
145
- role: "form-input",
146
- data: composedData,
147
- ...inputProps
148
- });
149
- }, [
150
- pluginManager,
151
- baseData
152
- ]);
153
- };
154
- var CreateObjectPanel = ({ classNames, forms, spaces, typename: initialTypename, target: initialTarget, name: initialName, defaultSpaceId, resolve, onCreateObject }) => {
155
- const { t } = useTranslation2(SPACE_PLUGIN);
156
- const [typename, setTypename] = useState2(initialTypename);
157
- const [target, setTarget] = useState2(initialTarget);
158
- const form = forms.find((form2) => getTypeAnnotation(form2.objectSchema)?.typename === typename);
159
- const options = forms.map((form2) => getTypeAnnotation(form2.objectSchema)).filter(isNonNullable).sort((a, b) => {
160
- const nameA = t("typename label", {
161
- ns: a.typename,
162
- defaultValue: a.typename
163
- });
164
- const nameB = t("typename label", {
165
- ns: b.typename,
166
- defaultValue: b.typename
167
- });
168
- return nameA.localeCompare(nameB);
169
- });
170
- const handleCreateObject = useCallback2(async (props) => {
171
- if (!form || !target) {
172
- return;
173
- }
174
- await onCreateObject?.({
175
- form,
176
- target,
177
- data: props
178
- });
179
- }, [
180
- onCreateObject,
181
- form,
182
- target
183
- ]);
184
- const handleSetTypename = useCallback2(async (typename2) => {
185
- invariant(target, "target is required", {
186
- F: __dxlog_file,
187
- L: 94,
188
- S: void 0,
189
- A: [
190
- "target",
191
- "'target is required'"
192
- ]
193
- });
194
- const form2 = forms.find((form3) => getTypeAnnotation(form3.objectSchema)?.typename === typename2);
195
- if (form2 && !form2.formSchema) {
196
- await onCreateObject?.({
197
- form: form2,
198
- target
199
- });
200
- } else {
201
- setTypename(typename2);
202
- }
203
- }, [
204
- forms,
205
- onCreateObject,
206
- target
207
- ]);
208
- const inputSurfaceLookup = useInputSurfaceLookup({
209
- target
210
- });
211
- return /* @__PURE__ */ React2.createElement("div", {
212
- role: "form",
213
- className: mx2("flex flex-col gap-2", classNames)
214
- }, !form ? /* @__PURE__ */ React2.createElement(SelectSchema, {
215
- options,
216
- resolve,
217
- onChange: handleSetTypename
218
- }) : !target ? /* @__PURE__ */ React2.createElement(SelectSpace, {
219
- spaces,
220
- defaultSpaceId,
221
- onChange: setTarget
222
- }) : form.formSchema ? /* @__PURE__ */ React2.createElement(Form, {
223
- classNames: "!p-0",
224
- autoFocus: true,
225
- values: {
226
- name: initialName
227
- },
228
- schema: form.formSchema,
229
- testId: "create-object-form",
230
- onSave: handleCreateObject,
231
- lookupComponent: inputSurfaceLookup
232
- }) : void 0);
233
- };
234
- var SelectSpace = ({ spaces, defaultSpaceId, onChange }) => {
235
- const { t } = useTranslation2(SPACE_PLUGIN);
236
- return /* @__PURE__ */ React2.createElement(SearchList.Root, {
237
- label: t("space input label"),
238
- classNames: "flex flex-col grow overflow-hidden"
239
- }, /* @__PURE__ */ React2.createElement(SearchList.Input, {
240
- autoFocus: true,
241
- "data-testid": "create-object-form.space-input",
242
- placeholder: t("space input placeholder"),
243
- classNames: "px-1 my-2"
244
- }), /* @__PURE__ */ React2.createElement(SearchList.Content, {
245
- classNames: "max-bs-[24rem] overflow-auto"
246
- }, spaces.sort((a, b) => {
247
- const aName = toLocalizedString(getSpaceDisplayName(a, {
248
- personal: a.id === defaultSpaceId
249
- }), t);
250
- const bName = toLocalizedString(getSpaceDisplayName(b, {
251
- personal: b.id === defaultSpaceId
252
- }), t);
253
- return aName.localeCompare(bName);
254
- }).map((space) => /* @__PURE__ */ React2.createElement(SearchList.Item, {
255
- key: space.id,
256
- value: toLocalizedString(getSpaceDisplayName(space, {
257
- personal: space.id === defaultSpaceId
258
- }), t),
259
- onSelect: () => onChange(space),
260
- classNames: "flex items-center gap-2"
261
- }, /* @__PURE__ */ React2.createElement("span", {
262
- className: "grow truncate"
263
- }, toLocalizedString(getSpaceDisplayName(space, {
264
- personal: space.id === defaultSpaceId
265
- }), t))))));
266
- };
267
- var SelectSchema = ({ options, resolve, onChange }) => {
268
- const { t } = useTranslation2(SPACE_PLUGIN);
269
- return /* @__PURE__ */ React2.createElement(SearchList.Root, {
270
- label: t("schema input label"),
271
- classNames: "flex flex-col grow overflow-hidden"
272
- }, /* @__PURE__ */ React2.createElement(SearchList.Input, {
273
- autoFocus: true,
274
- "data-testid": "create-object-form.schema-input",
275
- placeholder: t("schema input placeholder"),
276
- classNames: "px-1 my-2"
277
- }), /* @__PURE__ */ React2.createElement(SearchList.Content, {
278
- classNames: "max-bs-[24rem] overflow-auto"
279
- }, options.map((option) => /* @__PURE__ */ React2.createElement(SearchList.Item, {
280
- key: option.typename,
281
- value: t("typename label", {
282
- ns: option.typename,
283
- defaultValue: option.typename
284
- }),
285
- onSelect: () => onChange(option.typename),
286
- classNames: "flex items-center gap-2"
287
- }, /* @__PURE__ */ React2.createElement("span", {
288
- className: "flex gap-2 items-center grow truncate"
289
- }, /* @__PURE__ */ React2.createElement(Icon, {
290
- icon: resolve?.(option.typename).icon ?? "ph--placeholder--regular",
291
- size: 5
292
- }), t("typename label", {
293
- ns: option.typename,
294
- defaultValue: option.typename
295
- }))))));
296
- };
297
-
298
- // packages/plugins/plugin-space/src/capabilities/index.ts
299
- import { lazy } from "@dxos/app-framework";
300
- var AppGraphBuilder = lazy(() => import("./app-graph-builder-GMFCSOLG.mjs"));
301
- var AppGraphSerializer = lazy(() => import("./app-graph-serializer-DSF2U3A5.mjs"));
302
- var IdentityCreated = lazy(() => import("./identity-created-JR7BNXFH.mjs"));
303
- var IntentResolver = lazy(() => import("./intent-resolver-RKYILWWQ.mjs"));
304
- var ReactRoot = lazy(() => import("./react-root-6H7NX2M2.mjs"));
305
- var ReactSurface = lazy(() => import("./react-surface-7AGLOVMK.mjs"));
306
- var Schema = lazy(() => import("./schema-FHTA26SW.mjs"));
307
- var Tools = lazy(() => import("./schema-tools-YAXPRIXP.mjs"));
308
- var SpaceSettings = lazy(() => import("./settings-PJPTJUPE.mjs"));
309
- var SpaceState = lazy(() => import("./state-X7VLCC6E.mjs"));
310
- var SpacesReady = lazy(() => import("./spaces-ready-BSSP7HHG.mjs"));
311
-
312
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx
313
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/CreateDialog/CreateObjectDialog.tsx";
314
- var CREATE_OBJECT_DIALOG = `${SPACE_PLUGIN}/CreateObjectDialog`;
315
- var CreateObjectDialog = ({ target, typename, name, shouldNavigate: _shouldNavigate }) => {
316
- const closeRef = useRef(null);
317
- const manager = usePluginManager2();
318
- const { t } = useTranslation3(SPACE_PLUGIN);
319
- const client = useClient2();
320
- const spaces = useSpaces();
321
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
322
- const forms = useCapabilities(SpaceCapabilities.ObjectForm);
323
- const resolve = useCallback3((typename2) => manager.context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename2)?.metadata ?? {}, [
324
- manager
325
- ]);
326
- const handleCreateObject = useCallback3(async ({ form, target: target2, data = {} }) => {
327
- if (!target2) {
328
- return;
329
- }
330
- closeRef.current?.click();
331
- const space = isSpace(target2) ? target2 : getSpace(target2);
332
- invariant2(space, "Missing space", {
333
- F: __dxlog_file2,
334
- L: 72,
335
- S: void 0,
336
- A: [
337
- "space",
338
- "'Missing space'"
339
- ]
340
- });
341
- const result = await dispatch(form.getIntent(data, {
342
- space
343
- }));
344
- const object = result.data?.object;
345
- if (isReactiveObject(object)) {
346
- const addObjectIntent = createIntent2(SpaceAction.AddObject, {
347
- target: target2,
348
- object,
349
- hidden: form.hidden
350
- });
351
- const shouldNavigate = _shouldNavigate ?? (() => true);
352
- if (shouldNavigate(object)) {
353
- await dispatch(pipe(addObjectIntent, chain(LayoutAction2.Open, {
354
- part: "main"
355
- })));
356
- } else {
357
- await dispatch(addObjectIntent);
358
- }
359
- }
360
- }, [
361
- dispatch,
362
- resolve
363
- ]);
364
- return (
365
- // TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
366
- // Consider factoring it out to the tabs package.
367
- /* @__PURE__ */ React3.createElement(Dialog.Content, {
368
- classNames: "p-0 bs-content max-bs-full md:max-is-[40rem] overflow-hidden"
369
- }, /* @__PURE__ */ React3.createElement("div", {
370
- role: "none",
371
- className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
372
- }, /* @__PURE__ */ React3.createElement(Dialog.Title, null, t("create object dialog title")), /* @__PURE__ */ React3.createElement(Dialog.Close, {
373
- asChild: true
374
- }, /* @__PURE__ */ React3.createElement(Button2, {
375
- ref: closeRef,
376
- density: "fine",
377
- variant: "ghost",
378
- autoFocus: true
379
- }, /* @__PURE__ */ React3.createElement(Icon2, {
380
- icon: "ph--x--regular",
381
- size: 4
382
- })))), /* @__PURE__ */ React3.createElement(CreateObjectPanel, {
383
- classNames: "p-4",
384
- forms,
385
- spaces,
386
- target,
387
- typename,
388
- name,
389
- defaultSpaceId: client.spaces.default.id,
390
- resolve,
391
- onCreateObject: handleCreateObject
392
- }))
393
- );
394
- };
395
-
396
- // packages/plugins/plugin-space/src/components/CreateDialog/CreateSpaceDialog.tsx
397
- import { Effect } from "effect";
398
- import React4, { useCallback as useCallback4, useRef as useRef2 } from "react";
399
- import { createIntent as createIntent3, LayoutAction as LayoutAction3, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
400
- import { Button as Button3, Dialog as Dialog2, Icon as Icon3, useTranslation as useTranslation4 } from "@dxos/react-ui";
401
- import { Form as Form2 } from "@dxos/react-ui-form";
402
- var CREATE_SPACE_DIALOG = `${SPACE_PLUGIN}/CreateSpaceDialog`;
403
- var initialValues = {
404
- edgeReplication: true
405
- };
406
- var CreateSpaceDialog = () => {
407
- const closeRef = useRef2(null);
408
- const { t } = useTranslation4(SPACE_PLUGIN);
409
- const { dispatch } = useIntentDispatcher3();
410
- const handleCreateSpace = useCallback4(async (data) => {
411
- const program = Effect.gen(function* () {
412
- const { space } = yield* dispatch(createIntent3(SpaceAction.Create, data));
413
- yield* dispatch(createIntent3(LayoutAction3.SwitchWorkspace, {
414
- part: "workspace",
415
- subject: space.id
416
- }));
417
- yield* dispatch(createIntent3(SpaceAction.OpenCreateObject, {
418
- target: space
419
- }));
420
- });
421
- await Effect.runPromise(program);
422
- }, [
423
- dispatch
424
- ]);
425
- return (
426
- // TODO(wittjosiah): The tablist dialog pattern is copied from @dxos/plugin-manager.
427
- // Consider factoring it out to the tabs package.
428
- /* @__PURE__ */ React4.createElement(Dialog2.Content, {
429
- classNames: "p-0 bs-content min-bs-[16rem] max-bs-full md:max-is-[32rem] overflow-hidden"
430
- }, /* @__PURE__ */ React4.createElement("div", {
431
- role: "none",
432
- className: "flex justify-between pbs-2 pis-2 pie-2 @md:pbs-4 @md:pis-4 @md:pie-4"
433
- }, /* @__PURE__ */ React4.createElement(Dialog2.Title, null, t("create space dialog title")), /* @__PURE__ */ React4.createElement(Dialog2.Close, {
434
- asChild: true
435
- }, /* @__PURE__ */ React4.createElement(Button3, {
436
- ref: closeRef,
437
- density: "fine",
438
- variant: "ghost",
439
- autoFocus: true
440
- }, /* @__PURE__ */ React4.createElement(Icon3, {
441
- icon: "ph--x--regular",
442
- size: 4
443
- })))), /* @__PURE__ */ React4.createElement("div", {
444
- className: "p-4"
445
- }, /* @__PURE__ */ React4.createElement(Form2, {
446
- testId: "create-space-form",
447
- classNames: "!p-0",
448
- autoFocus: true,
449
- values: initialValues,
450
- schema: SpaceForm,
451
- onSave: handleCreateSpace
452
- })))
453
- );
454
- };
455
-
456
- // packages/plugins/plugin-space/src/components/CollectionMain.tsx
457
- import React5 from "react";
458
- import { useTranslation as useTranslation5 } from "@dxos/react-ui";
459
- import { baseSurface, descriptionText, mx as mx3 } from "@dxos/react-ui-theme";
460
- var CollectionMain = ({ collection }) => {
461
- const { t } = useTranslation5(SPACE_PLUGIN);
462
- return /* @__PURE__ */ React5.createElement("div", {
463
- role: "none",
464
- className: mx3(baseSurface, "min-bs-screen is-full flex items-center justify-center p-8"),
465
- "data-testid": "composer.firstRunMessage"
466
- }, /* @__PURE__ */ React5.createElement("p", {
467
- role: "alert",
468
- className: mx3(descriptionText, "border border-dashed border-neutral-400/50 rounded-lg p-8 font-normal text-lg max-is-[24rem] break-words")
469
- }, collection.name ?? t("unnamed collection label")));
470
- };
471
-
472
- // packages/plugins/plugin-space/src/components/CollectionSection.tsx
473
- import React6 from "react";
474
- import { useTranslation as useTranslation6 } from "@dxos/react-ui";
475
- var CollectionSection = ({ collection }) => {
476
- const { t } = useTranslation6(SPACE_PLUGIN);
477
- return /* @__PURE__ */ React6.createElement("div", {
478
- className: "min-bs-[3.5rem] grid grid-rows-subgrid grid-cols-subgrid items-center"
479
- }, /* @__PURE__ */ React6.createElement("span", {
480
- className: "truncate"
481
- }, collection.name ?? t("unnamed collection label")));
482
- };
483
-
484
- // packages/plugins/plugin-space/src/components/JoinDialog.tsx
485
- import React7, { useCallback as useCallback5 } from "react";
486
- import { createIntent as createIntent4, LayoutAction as LayoutAction4, useAppGraph, useIntentDispatcher as useIntentDispatcher4 } from "@dxos/app-framework";
487
- import { Trigger } from "@dxos/async";
488
- import { ObservabilityAction } from "@dxos/plugin-observability/types";
489
- import { useClient as useClient3 } from "@dxos/react-client";
490
- import { Dialog as Dialog3, useTranslation as useTranslation7 } from "@dxos/react-ui";
491
- import { JoinPanel } from "@dxos/shell/react";
492
- var JOIN_DIALOG = `${SPACE_PLUGIN}/JoinDialog`;
493
- var JoinDialog = ({ navigableCollections, onDone, ...props }) => {
494
- const { dispatchPromise: dispatch } = useIntentDispatcher4();
495
- const client = useClient3();
496
- const { graph } = useAppGraph();
497
- const { t } = useTranslation7(SPACE_PLUGIN);
498
- const handleDone = useCallback5(async (result) => {
499
- const spaceKey = result?.spaceKey;
500
- if (!spaceKey) {
501
- return;
502
- }
503
- await Promise.all([
504
- dispatch(createIntent4(LayoutAction4.AddToast, {
505
- part: "toast",
506
- subject: {
507
- id: `${SPACE_PLUGIN}/join-success`,
508
- duration: 5e3,
509
- title: [
510
- "join success label",
511
- {
512
- ns: SPACE_PLUGIN
513
- }
514
- ],
515
- closeLabel: [
516
- "dismiss label",
517
- {
518
- ns: SPACE_PLUGIN
519
- }
520
- ]
521
- }
522
- })),
523
- dispatch(createIntent4(LayoutAction4.UpdateDialog, {
524
- part: "dialog",
525
- options: {
526
- state: false
527
- }
528
- }))
529
- ]);
530
- let space = client.spaces.get(spaceKey);
531
- if (!space) {
532
- const trigger = new Trigger();
533
- client.spaces.subscribe(() => {
534
- const space2 = client.spaces.get(spaceKey);
535
- if (space2) {
536
- trigger.wake(space2);
537
- }
538
- });
539
- space = await trigger.wait();
540
- }
541
- await dispatch(createIntent4(LayoutAction4.SwitchWorkspace, {
542
- part: "workspace",
543
- subject: space.id
544
- }));
545
- const target = result?.target || (navigableCollections ? space?.id : void 0);
546
- if (target) {
547
- await graph.waitForPath({
548
- target
549
- }).catch(() => {
550
- });
551
- await Promise.all([
552
- dispatch(createIntent4(LayoutAction4.Open, {
553
- part: "main",
554
- subject: [
555
- target
556
- ]
557
- })),
558
- dispatch(createIntent4(LayoutAction4.Expose, {
559
- part: "navigation",
560
- subject: target
561
- }))
562
- ]);
563
- }
564
- await onDone?.(result);
565
- if (space) {
566
- await dispatch(createIntent4(ObservabilityAction.SendEvent, {
567
- name: "space.join",
568
- properties: {
569
- spaceId: space.id
570
- }
571
- }));
572
- }
573
- }, [
574
- dispatch,
575
- client,
576
- graph
577
- ]);
578
- return /* @__PURE__ */ React7.createElement(Dialog3.Content, null, /* @__PURE__ */ React7.createElement(Dialog3.Title, {
579
- classNames: "sr-only"
580
- }, t("join space label", {
581
- ns: "os"
582
- })), /* @__PURE__ */ React7.createElement(JoinPanel, {
583
- ...props,
584
- exitActionParent: /* @__PURE__ */ React7.createElement(Dialog3.Close, {
585
- asChild: true
586
- }),
587
- doneActionParent: /* @__PURE__ */ React7.createElement(Dialog3.Close, {
588
- asChild: true
589
- }),
590
- onDone: handleDone
591
- }));
592
- };
593
-
594
- // packages/plugins/plugin-space/src/components/MembersContainer.tsx
595
- import { Check, X } from "@phosphor-icons/react";
596
- import React8, { useMemo, useState as useState3 } from "react";
597
- import { QR } from "react-qr-rounded";
598
- import { log } from "@dxos/log";
599
- import { useConfig } from "@dxos/react-client";
600
- import { fullyQualifiedId as fullyQualifiedId2, useSpaceInvitations } from "@dxos/react-client/echo";
601
- import { Invitation, InvitationEncoder } from "@dxos/react-client/invitations";
602
- import { Button as Button4, Clipboard, Icon as Icon4, useId, useTranslation as useTranslation8 } from "@dxos/react-ui";
603
- import { ControlSection, ControlFrame, ControlFrameItem } from "@dxos/react-ui-form";
604
- import { StackItem } from "@dxos/react-ui-stack";
605
- import { getSize as getSize2, mx as mx4 } from "@dxos/react-ui-theme";
606
- import { AuthCode, BifurcatedAction, Centered, Emoji, InvitationList, SpaceMemberList, Viewport } from "@dxos/shell/react";
607
- import { hexToEmoji } from "@dxos/util";
608
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/MembersContainer.tsx";
609
- var activeActionKey = "dxos:react-shell/space-manager/active-action";
610
- var handleInvitationEvent = (invitation, subscription) => {
611
- const invitationCode = InvitationEncoder.encode(invitation);
612
- if (invitation.state === Invitation.State.CONNECTING) {
613
- log.info(JSON.stringify({
614
- invitationCode,
615
- authCode: invitation.authCode
616
- }), void 0, {
617
- F: __dxlog_file3,
618
- L: 38,
619
- S: void 0,
620
- C: (f, a) => f(...a)
621
- });
622
- subscription.unsubscribe();
623
- }
624
- };
625
- var MembersContainer = ({ space, createInvitationUrl }) => {
626
- const { t } = useTranslation8("os");
627
- const config = useConfig();
628
- const invitations = useSpaceInvitations(space.key);
629
- const visibleInvitations = invitations?.filter((invitation) => ![
630
- Invitation.State.CANCELLED
631
- ].includes(invitation.get().state));
632
- const [activeAction, setInternalActiveAction] = useState3(localStorage.getItem(activeActionKey) ?? "inviteMany");
633
- const setActiveAction = (nextAction) => {
634
- setInternalActiveAction(nextAction);
635
- localStorage.setItem(activeActionKey, nextAction);
636
- };
637
- const target = space.properties[CollectionType.typename]?.target?.objects[0]?.target;
638
- const inviteActions = useMemo(() => ({
639
- inviteOne: {
640
- label: t("invite one label"),
641
- description: t("invite one description"),
642
- icon: () => /* @__PURE__ */ React8.createElement(Icon4, {
643
- icon: "ph--user-plus--regular",
644
- size: 5
645
- }),
646
- testId: "membersContainer.inviteOne",
647
- onClick: () => {
648
- const invitation = space.share?.({
649
- type: Invitation.Type.INTERACTIVE,
650
- authMethod: Invitation.AuthMethod.SHARED_SECRET,
651
- multiUse: false,
652
- target: target && fullyQualifiedId2(target)
653
- });
654
- if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
655
- const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
656
- }
657
- }
658
- },
659
- inviteMany: {
660
- label: t("invite many label"),
661
- description: t("invite many description"),
662
- icon: () => /* @__PURE__ */ React8.createElement(Icon4, {
663
- icon: "ph--users-three--regular",
664
- size: 5
665
- }),
666
- testId: "membersContainer.inviteMany",
667
- onClick: () => {
668
- const invitation = space.share?.({
669
- type: Invitation.Type.DELEGATED,
670
- authMethod: Invitation.AuthMethod.KNOWN_PUBLIC_KEY,
671
- multiUse: true,
672
- target: target && fullyQualifiedId2(target)
673
- });
674
- if (invitation && config.values.runtime?.app?.env?.DX_ENVIRONMENT !== "production") {
675
- const subscription = invitation.subscribe((invitation2) => handleInvitationEvent(invitation2, subscription));
676
- }
677
- }
678
- }
679
- }), [
680
- t,
681
- space,
682
- target
683
- ]);
684
- const [selectedInvitation, setSelectedInvitation] = useState3(null);
685
- const handleSend = (event) => {
686
- setSelectedInvitation(event.invitation);
687
- };
688
- const handleBack = () => {
689
- setSelectedInvitation(null);
690
- };
691
- return /* @__PURE__ */ React8.createElement(Clipboard.Provider, null, /* @__PURE__ */ React8.createElement(StackItem.Content, {
692
- classNames: "p-2 block overflow-y-auto"
693
- }, /* @__PURE__ */ React8.createElement(ControlSection, {
694
- title: t("members verbose label", {
695
- ns: SPACE_PLUGIN
696
- }),
697
- description: t("members description", {
698
- ns: SPACE_PLUGIN
699
- })
700
- }, /* @__PURE__ */ React8.createElement(ControlFrame, null, /* @__PURE__ */ React8.createElement(ControlFrameItem, {
701
- title: t("members label", {
702
- ns: SPACE_PLUGIN
703
- })
704
- }, /* @__PURE__ */ React8.createElement(SpaceMemberList, {
705
- spaceKey: space.key,
706
- includeSelf: true
707
- })), /* @__PURE__ */ React8.createElement(ControlFrameItem, {
708
- title: t("invitations label", {
709
- ns: SPACE_PLUGIN
710
- })
711
- }, selectedInvitation && /* @__PURE__ */ React8.createElement(InvitationSection, {
712
- ...selectedInvitation,
713
- onBack: handleBack
714
- }), !selectedInvitation && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("p", {
715
- className: "text-description mbe-2"
716
- }, t("space invitation description", {
717
- ns: SPACE_PLUGIN
718
- })), /* @__PURE__ */ React8.createElement(InvitationList, {
719
- className: "mb-2",
720
- send: handleSend,
721
- invitations: visibleInvitations ?? [],
722
- onClickRemove: (invitation) => invitation.cancel(),
723
- createInvitationUrl
724
- }), /* @__PURE__ */ React8.createElement(BifurcatedAction, {
725
- actions: inviteActions,
726
- activeAction,
727
- onChangeActiveAction: setActiveAction,
728
- "data-testid": "membersContainer.createInvitation"
729
- })))))));
730
- };
731
- var InvitationSection = ({ state = Invitation.State.INIT, authCode, invitationId = "never", url = "never", onBack }) => {
732
- const activeView = state < 0 ? "init" : state >= Invitation.State.CANCELLED ? "complete" : state >= Invitation.State.READY_FOR_AUTHENTICATION && authCode ? "auth-code" : "qr-code";
733
- return /* @__PURE__ */ React8.createElement(Viewport.Root, {
734
- activeView
735
- }, /* @__PURE__ */ React8.createElement(Viewport.Views, null, /* @__PURE__ */ React8.createElement(Viewport.View, {
736
- id: "init"
737
- }), /* @__PURE__ */ React8.createElement(Viewport.View, {
738
- id: "complete"
739
- }, /* @__PURE__ */ React8.createElement(InvitationComplete, {
740
- statusValue: state
741
- })), /* @__PURE__ */ React8.createElement(Viewport.View, {
742
- id: "auth-code"
743
- }, /* @__PURE__ */ React8.createElement(InvitationAuthCode, {
744
- id: invitationId,
745
- code: authCode ?? "never",
746
- onCancel: onBack
747
- })), /* @__PURE__ */ React8.createElement(Viewport.View, {
748
- id: "qr-code"
749
- }, /* @__PURE__ */ React8.createElement(InvitationQR, {
750
- id: invitationId,
751
- url,
752
- onCancel: onBack
753
- }))));
754
- };
755
- var InvitationQR = ({ id, url, onCancel }) => {
756
- const { t } = useTranslation8("os");
757
- const qrLabel = useId("members-container__qr-code");
758
- const emoji = hexToEmoji(id);
759
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("p", {
760
- className: "text-description"
761
- }, t("qr code description", {
762
- ns: SPACE_PLUGIN
763
- })), /* @__PURE__ */ React8.createElement("div", {
764
- role: "group",
765
- className: "grid grid-cols-[1fr_min-content] mlb-2 gap-2"
766
- }, /* @__PURE__ */ React8.createElement("div", {
767
- role: "none",
768
- className: "is-full aspect-square relative text-description"
769
- }, /* @__PURE__ */ React8.createElement(QR, {
770
- rounding: 100,
771
- backgroundColor: "transparent",
772
- color: "currentColor",
773
- "aria-labelledby": qrLabel,
774
- errorCorrectionLevel: "Q",
775
- cutout: true
776
- }, url ?? "never"), /* @__PURE__ */ React8.createElement(Centered, null, /* @__PURE__ */ React8.createElement(Emoji, {
777
- text: emoji
778
- }))), /* @__PURE__ */ React8.createElement("span", {
779
- id: qrLabel,
780
- className: "sr-only"
781
- }, t("qr label")), /* @__PURE__ */ React8.createElement(Clipboard.Button, {
782
- value: url ?? "never"
783
- })), /* @__PURE__ */ React8.createElement(Button4, {
784
- variant: "ghost",
785
- onClick: onCancel
786
- }, t("cancel label")));
787
- };
788
- var InvitationAuthCode = ({ id, code, onCancel }) => {
789
- const { t } = useTranslation8("os");
790
- const emoji = hexToEmoji(id);
791
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("p", {
792
- className: "text-description"
793
- }, t("auth other device emoji message")), emoji && /* @__PURE__ */ React8.createElement(Emoji, {
794
- text: emoji,
795
- className: "mli-auto mlb-2 text-center"
796
- }), /* @__PURE__ */ React8.createElement("p", {
797
- className: "text-description"
798
- }, t("auth code message")), /* @__PURE__ */ React8.createElement(AuthCode, {
799
- code,
800
- large: true,
801
- classNames: "mli-auto mlb-2 text-center grow"
802
- }), /* @__PURE__ */ React8.createElement(Button4, {
803
- variant: "ghost",
804
- onClick: onCancel
805
- }, t("cancel label")));
806
- };
807
- var InvitationComplete = ({ statusValue }) => {
808
- return statusValue > 0 ? /* @__PURE__ */ React8.createElement(Check, {
809
- className: mx4("m-1.5", getSize2(6))
810
- }) : /* @__PURE__ */ React8.createElement(X, {
811
- className: mx4("m-1.5", getSize2(6))
812
- });
813
- };
814
-
815
- // packages/plugins/plugin-space/src/components/MenuFooter.tsx
816
- import { Planet } from "@phosphor-icons/react";
817
- import React9 from "react";
818
- import { getSpace as getSpace2 } from "@dxos/client/echo";
819
- import { useClient as useClient4 } from "@dxos/react-client";
820
- import { DropdownMenu, toLocalizedString as toLocalizedString2, useTranslation as useTranslation9 } from "@dxos/react-ui";
821
- var MenuFooter = ({ object }) => {
822
- const { t } = useTranslation9(SPACE_PLUGIN);
823
- const client = useClient4();
824
- const space = getSpace2(object);
825
- const spaceName = space ? getSpaceDisplayName(space, {
826
- personal: client.spaces.default === space
827
- }) : "";
828
- 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", {
829
- className: "pis-2 mbe-2 text-xs grid grid-cols-[max-content_1fr] gap-2"
830
- }, /* @__PURE__ */ React9.createElement("dt", {
831
- className: "uppercase text-[.75em] tracking-wide font-medium mbs-px self-start"
832
- }, t("location label")), /* @__PURE__ */ React9.createElement("dd", {
833
- className: "line-clamp-3"
834
- }, /* @__PURE__ */ React9.createElement(Planet, {
835
- className: "inline-block mie-1"
836
- }), toLocalizedString2(spaceName, t)))) : null;
837
- };
838
-
839
- // packages/plugins/plugin-space/src/components/ObjectSettingsContainer/ObjectSettingsContainer.tsx
840
- import React13, { useMemo as useMemo2 } from "react";
841
- import { Surface as Surface2 } from "@dxos/app-framework";
842
- import { Clipboard as Clipboard2 } from "@dxos/react-ui";
843
- import { StackItem as StackItem2 } from "@dxos/react-ui-stack";
844
-
845
- // packages/plugins/plugin-space/src/components/ObjectSettingsContainer/AdvancedObjectSettings.tsx
846
- import React11, { useCallback as useCallback7, useState as useState4 } from "react";
847
- import { ForeignKeySchema } from "@dxos/echo-schema";
848
- import { getMeta } from "@dxos/react-client/echo";
849
- import { IconButton as IconButton2, useTranslation as useTranslation11 } from "@dxos/react-ui";
850
- import { Form as Form3 } from "@dxos/react-ui-form";
851
-
852
- // packages/plugins/plugin-space/src/components/ObjectSettingsContainer/ForeignKeys.tsx
853
- import React10, { useCallback as useCallback6 } from "react";
854
- import { IconButton, List, ListItem, useTranslation as useTranslation10 } from "@dxos/react-ui";
855
- var ForeignKeys = ({ keys, onDelete }) => {
856
- return /* @__PURE__ */ React10.createElement(List, {
857
- classNames: "flex flex-col gap-2"
858
- }, keys.map((key) => /* @__PURE__ */ React10.createElement(KeyItem, {
859
- key: key.id,
860
- forignKey: key,
861
- onDelete
862
- })));
863
- };
864
- var KeyItem = ({ forignKey, onDelete }) => {
865
- const { t } = useTranslation10(SPACE_PLUGIN);
866
- const handleDelete = useCallback6(() => {
867
- onDelete?.(forignKey);
868
- }, [
869
- forignKey,
870
- onDelete
871
- ]);
872
- return /* @__PURE__ */ React10.createElement(ListItem.Root, {
873
- classNames: "px-2"
874
- }, /* @__PURE__ */ React10.createElement(ListItem.Heading, {
875
- classNames: "flex flex-col grow truncate"
876
- }, /* @__PURE__ */ React10.createElement("div", null, forignKey.source), /* @__PURE__ */ React10.createElement("div", {
877
- className: "text-description text-sm truncate"
878
- }, forignKey.id)), /* @__PURE__ */ React10.createElement(ListItem.Endcap, null, /* @__PURE__ */ React10.createElement(IconButton, {
879
- iconOnly: true,
880
- icon: "ph--x--regular",
881
- variant: "ghost",
882
- label: t("delete key"),
883
- onClick: handleDelete
884
- })));
885
- };
886
-
887
- // packages/plugins/plugin-space/src/components/ObjectSettingsContainer/AdvancedObjectSettings.tsx
888
- var initialValues2 = {
889
- source: "",
890
- id: ""
891
- };
892
- var AdvancedObjectSettings = ({ object }) => {
893
- const { t } = useTranslation11(SPACE_PLUGIN);
894
- const [adding, setAdding] = useState4(false);
895
- const keys = getMeta(object).keys;
896
- const handleNew = useCallback7(() => setAdding(true), []);
897
- const handleCancel = useCallback7(() => setAdding(false), []);
898
- const handleSave = useCallback7((key) => {
899
- const index = keys.findIndex(({ source, id }) => source === key.source && id === key.id);
900
- if (index === -1) {
901
- keys.push(key);
902
- }
903
- setAdding(false);
904
- }, [
905
- keys
906
- ]);
907
- const handleDelete = useCallback7((key) => {
908
- const index = keys.findIndex(({ source, id }) => source === key.source && id === key.id);
909
- if (index !== -1) {
910
- keys.splice(index, 1);
911
- }
912
- }, [
913
- keys
914
- ]);
915
- return /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement("div", {
916
- className: "p-2 flex flex-col gap-4"
917
- }, /* @__PURE__ */ React11.createElement("h2", null, t("advanced settings label")), /* @__PURE__ */ React11.createElement("div", {
918
- className: "flex items-center"
919
- }, /* @__PURE__ */ React11.createElement("h3", {
920
- className: "text-sm font-semibold"
921
- }, t("foreign keys")), /* @__PURE__ */ React11.createElement("div", {
922
- className: "grow"
923
- }), /* @__PURE__ */ React11.createElement(IconButton2, {
924
- classNames: adding && "invisible",
925
- icon: "ph--plus--regular",
926
- label: t("add key"),
927
- onClick: handleNew
928
- })), !adding && /* @__PURE__ */ React11.createElement(ForeignKeys, {
929
- keys,
930
- onDelete: handleDelete
931
- })), adding && /* @__PURE__ */ React11.createElement(Form3, {
932
- schema: ForeignKeySchema,
933
- values: initialValues2,
934
- onSave: handleSave,
935
- onCancel: handleCancel
936
- }));
937
- };
938
-
939
- // packages/plugins/plugin-space/src/components/ObjectSettingsContainer/BaseObjectSettings.tsx
940
- import React12, { useRef as useRef3 } from "react";
941
- import { Input, useTranslation as useTranslation12 } from "@dxos/react-ui";
942
- import { mx as mx5 } from "@dxos/react-ui-theme";
943
- var BaseObjectSettings = ({ classNames, children, object }) => {
944
- const { t } = useTranslation12(meta.id);
945
- const inputRef = useRef3(null);
946
- return /* @__PURE__ */ React12.createElement("form", {
947
- className: mx5("flex flex-col p-2 gap-2", classNames)
948
- }, /* @__PURE__ */ React12.createElement(Input.Root, null, /* @__PURE__ */ React12.createElement(Input.Label, null, t("name label")), /* @__PURE__ */ React12.createElement(Input.TextInput, {
949
- ref: inputRef,
950
- placeholder: t("name placeholder"),
951
- value: object.name ?? "",
952
- onChange: (event) => {
953
- object.name = event.target.value;
954
- },
955
- onKeyDown: (event) => {
956
- if (event.key === "Enter") {
957
- inputRef.current?.blur();
958
- }
959
- }
960
- })), children);
961
- };
962
-
963
- // packages/plugins/plugin-space/src/components/ObjectSettingsContainer/ObjectSettingsContainer.tsx
964
- var ObjectSettingsContainer = ({ object, role }) => {
965
- const data = useMemo2(() => ({
966
- subject: object
967
- }), [
968
- object
969
- ]);
970
- return /* @__PURE__ */ React13.createElement(Clipboard2.Provider, null, /* @__PURE__ */ React13.createElement(StackItem2.Content, {
971
- toolbar: false,
972
- role
973
- }, /* @__PURE__ */ React13.createElement("div", {
974
- className: "flex flex-col overflow-y-auto divide-y divide-separator"
975
- }, /* @__PURE__ */ React13.createElement(BaseObjectSettings, {
976
- object
977
- }, /* @__PURE__ */ React13.createElement(Surface2, {
978
- role: "base-object-settings",
979
- data
980
- })), /* @__PURE__ */ React13.createElement(Surface2, {
981
- role: "object-settings",
982
- data
983
- }), /* @__PURE__ */ React13.createElement(AdvancedObjectSettings, {
984
- object
985
- }))));
986
- };
987
-
988
- // packages/plugins/plugin-space/src/components/PersistenceStatus.tsx
989
- import { ArrowsCounterClockwise, CheckCircle as CheckCircle2, Warning } from "@phosphor-icons/react";
990
- import React14, { useEffect as useEffect2, useState as useState5 } from "react";
991
- import { debounce } from "@dxos/async";
992
- import { Tooltip, useTranslation as useTranslation13 } from "@dxos/react-ui";
993
- import { getSize as getSize3, mx as mx6, staticPlaceholderText, warningText } from "@dxos/react-ui-theme";
994
- var Status;
995
- (function(Status2) {
996
- Status2[Status2["PERSISTED_LOCALLY"] = 0] = "PERSISTED_LOCALLY";
997
- Status2[Status2["PENDING"] = 1] = "PENDING";
998
- Status2[Status2["ERROR"] = 2] = "ERROR";
999
- })(Status || (Status = {}));
1000
- var PersistenceStatus = ({ db }) => {
1001
- const { t } = useTranslation13(SPACE_PLUGIN);
1002
- const [displayMessage, setDisplayMessage] = useState5(false);
1003
- const [status, naturalSetStatus] = useState5(0);
1004
- const [prevStatus, setPrevStatus] = useState5(0);
1005
- const _setStatus = debounce(naturalSetStatus, 500);
1006
- useEffect2(() => {
1007
- setPrevStatus(status);
1008
- if (prevStatus !== status && status === 0) {
1009
- setDisplayMessage(true);
1010
- const timeout = setTimeout(() => setDisplayMessage(false), 5e3);
1011
- return () => clearTimeout(timeout);
1012
- }
1013
- }, [
1014
- status
1015
- ]);
1016
- switch (status) {
1017
- case 2:
1018
- return /* @__PURE__ */ React14.createElement("div", {
1019
- className: "flex items-center"
1020
- }, /* @__PURE__ */ React14.createElement(Warning, {
1021
- className: mx6(getSize3(4), "me-1")
1022
- }), /* @__PURE__ */ React14.createElement("span", {
1023
- className: mx6("text-sm", warningText)
1024
- }, t("persistence error label")));
1025
- case 1:
1026
- return /* @__PURE__ */ React14.createElement("div", {
1027
- className: "flex items-center"
1028
- }, /* @__PURE__ */ React14.createElement(ArrowsCounterClockwise, {
1029
- className: mx6(getSize3(4), "me-1")
1030
- }), /* @__PURE__ */ React14.createElement("span", {
1031
- className: mx6("text-sm", staticPlaceholderText)
1032
- }, t("persistence pending label")));
1033
- case 0:
1034
- default:
1035
- return /* @__PURE__ */ React14.createElement(Tooltip.Root, {
1036
- delayDuration: 400
1037
- }, /* @__PURE__ */ React14.createElement(Tooltip.Trigger, {
1038
- role: "status",
1039
- className: "flex items-center"
1040
- }, /* @__PURE__ */ React14.createElement(CheckCircle2, {
1041
- className: mx6(getSize3(4), "me-1")
1042
- }), displayMessage && /* @__PURE__ */ React14.createElement("span", {
1043
- className: mx6("text-sm", staticPlaceholderText)
1044
- }, t("persisted locally label"))), /* @__PURE__ */ React14.createElement(Tooltip.Portal, null, /* @__PURE__ */ React14.createElement(Tooltip.Content, null, t("persisted locally message"), /* @__PURE__ */ React14.createElement(Tooltip.Arrow, null))));
1045
- }
1046
- };
1047
-
1048
- // packages/plugins/plugin-space/src/components/PopoverAddSpace.tsx
1049
- import React15 from "react";
1050
- import { createIntent as createIntent5, LayoutAction as LayoutAction5, useIntentDispatcher as useIntentDispatcher5 } from "@dxos/app-framework";
1051
- import { IconButton as IconButton3, useTranslation as useTranslation14 } from "@dxos/react-ui";
1052
- var POPOVER_ADD_SPACE = `${SPACE_PLUGIN}/PopoverRenameSpace`;
1053
- var PopoverAddSpace = () => {
1054
- const { t } = useTranslation14(SPACE_PLUGIN);
1055
- const { dispatchPromise: dispatch } = useIntentDispatcher5();
1056
- return /* @__PURE__ */ React15.createElement("div", {
1057
- role: "none",
1058
- className: "grid grid-cols-1 gap-1 [&>button]:justify-start"
1059
- }, /* @__PURE__ */ React15.createElement(IconButton3, {
1060
- variant: "ghost",
1061
- label: t("create space label"),
1062
- icon: "ph--plus--regular",
1063
- onClick: () => {
1064
- void dispatch(createIntent5(SpaceAction.OpenCreateSpace));
1065
- void dispatch(createIntent5(LayoutAction5.UpdatePopover, {
1066
- part: "popover",
1067
- options: {
1068
- anchorId: "",
1069
- state: false
1070
- }
1071
- }));
1072
- },
1073
- "data-testid": "spacePlugin.createSpace"
1074
- }), /* @__PURE__ */ React15.createElement(IconButton3, {
1075
- variant: "ghost",
1076
- label: t("join space label"),
1077
- icon: "ph--sign-in--regular",
1078
- onClick: () => {
1079
- void dispatch(createIntent5(SpaceAction.Join));
1080
- void dispatch(createIntent5(LayoutAction5.UpdatePopover, {
1081
- part: "popover",
1082
- options: {
1083
- anchorId: "",
1084
- state: false
1085
- }
1086
- }));
1087
- },
1088
- "data-testid": "spacePlugin.joinSpace"
1089
- }));
1090
- };
1091
-
1092
- // packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx
1093
- import React16, { useCallback as useCallback8, useRef as useRef4, useState as useState6 } from "react";
1094
- import { log as log2 } from "@dxos/log";
1095
- import { Button as Button5, Input as Input2, Popover, useTranslation as useTranslation15 } from "@dxos/react-ui";
1096
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx";
1097
- var POPOVER_RENAME_OBJECT = `${SPACE_PLUGIN}/PopoverRenameObject`;
1098
- var PopoverRenameObject = ({ object: obj }) => {
1099
- const { t } = useTranslation15(SPACE_PLUGIN);
1100
- const doneButton = useRef4(null);
1101
- const object = obj;
1102
- const [name, setName] = useState6(object.name || object.title || "");
1103
- const handleDone = useCallback8(() => {
1104
- try {
1105
- object.name = name;
1106
- } catch {
1107
- try {
1108
- object.title = name;
1109
- } catch (err) {
1110
- log2.error("Failed to rename object", {
1111
- err
1112
- }, {
1113
- F: __dxlog_file4,
1114
- L: 30,
1115
- S: void 0,
1116
- C: (f, a) => f(...a)
1117
- });
1118
- }
1119
- }
1120
- }, [
1121
- object,
1122
- name
1123
- ]);
1124
- return /* @__PURE__ */ React16.createElement("div", {
1125
- role: "none",
1126
- className: "p-1 flex gap-2"
1127
- }, /* @__PURE__ */ React16.createElement("div", {
1128
- role: "none",
1129
- className: "flex-1"
1130
- }, /* @__PURE__ */ React16.createElement(Input2.Root, null, /* @__PURE__ */ React16.createElement(Input2.Label, {
1131
- srOnly: true
1132
- }, t("object name label")), /* @__PURE__ */ React16.createElement(Input2.TextInput, {
1133
- placeholder: t("object placeholder"),
1134
- value: name,
1135
- "data-testid": "spacePlugin.renameObject.input",
1136
- onChange: ({ target: { value } }) => setName(value),
1137
- onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
1138
- }))), /* @__PURE__ */ React16.createElement(Popover.Close, {
1139
- asChild: true
1140
- }, /* @__PURE__ */ React16.createElement(Button5, {
1141
- ref: doneButton,
1142
- classNames: "self-stretch",
1143
- onClick: handleDone
1144
- }, t("done label", {
1145
- ns: "os"
1146
- }))));
1147
- };
1148
-
1149
- // packages/plugins/plugin-space/src/components/PopoverRenameSpace.tsx
1150
- import React17, { useCallback as useCallback9, useRef as useRef5, useState as useState7 } from "react";
1151
- import { Button as Button6, Input as Input3, Popover as Popover2, useTranslation as useTranslation16 } from "@dxos/react-ui";
1152
- var POPOVER_RENAME_SPACE = `${SPACE_PLUGIN}/PopoverRenameSpace`;
1153
- var PopoverRenameSpace = ({ space }) => {
1154
- const { t } = useTranslation16(SPACE_PLUGIN);
1155
- const doneButton = useRef5(null);
1156
- const [name, setName] = useState7(space.properties.name ?? "");
1157
- const handleDone = useCallback9(() => {
1158
- space.properties.name = name;
1159
- }, [
1160
- space,
1161
- name
1162
- ]);
1163
- return /* @__PURE__ */ React17.createElement("div", {
1164
- role: "none",
1165
- className: "p-1 flex gap-2"
1166
- }, /* @__PURE__ */ React17.createElement("div", {
1167
- role: "none",
1168
- className: "flex-1"
1169
- }, /* @__PURE__ */ React17.createElement(Input3.Root, null, /* @__PURE__ */ React17.createElement(Input3.Label, {
1170
- srOnly: true
1171
- }, t("space name label")), /* @__PURE__ */ React17.createElement(Input3.TextInput, {
1172
- defaultValue: space.properties.name ?? "",
1173
- placeholder: t("unnamed space label"),
1174
- onChange: ({ target: { value } }) => setName(value),
1175
- // TODO(wittjosiah): Ideally this should access the popover context to close the popover.
1176
- // Currently this is not possible because Radix does not expose the popover context.
1177
- onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
1178
- }))), /* @__PURE__ */ React17.createElement(Popover2.Close, {
1179
- asChild: true
1180
- }, /* @__PURE__ */ React17.createElement(Button6, {
1181
- ref: doneButton,
1182
- classNames: "self-stretch",
1183
- onClick: handleDone
1184
- }, t("done label", {
1185
- ns: "os"
1186
- }))));
1187
- };
1188
-
1189
- // packages/plugins/plugin-space/src/components/ShareSpaceButton.tsx
1190
- import React18 from "react";
1191
- import { createIntent as createIntent6, useIntentDispatcher as useIntentDispatcher6 } from "@dxos/app-framework";
1192
- import { IconButton as IconButton4, useTranslation as useTranslation17 } from "@dxos/react-ui";
1193
- var ShareSpaceButton = ({ space }) => {
1194
- const { dispatchPromise: dispatch } = useIntentDispatcher6();
1195
- return /* @__PURE__ */ React18.createElement(ShareSpaceButtonImpl, {
1196
- onClick: () => dispatch(createIntent6(SpaceAction.Share, {
1197
- space
1198
- }))
1199
- });
1200
- };
1201
- var ShareSpaceButtonImpl = ({ onClick }) => {
1202
- const { t } = useTranslation17(SPACE_PLUGIN);
1203
- return /* @__PURE__ */ React18.createElement(IconButton4, {
1204
- "data-testid": "spacePlugin.shareSpaceButton",
1205
- icon: "ph--users--regular",
1206
- label: t("share space label"),
1207
- onClick
1208
- });
1209
- };
1210
-
1211
- // packages/plugins/plugin-space/src/components/SpacePresence.tsx
1212
- import React19, { useCallback as useCallback10, useEffect as useEffect4, useState as useState9 } from "react";
1213
- import { useAppGraph as useAppGraph2, useCapability } from "@dxos/app-framework";
1214
- import { generateName } from "@dxos/display-name";
1215
- import { PublicKey, useClient as useClient5 } from "@dxos/react-client";
1216
- import { getSpace as getSpace3, useMembers, fullyQualifiedId as fullyQualifiedId3 } from "@dxos/react-client/echo";
1217
- import { useIdentity } from "@dxos/react-client/halo";
1218
- import { Avatar, Tooltip as Tooltip2, useTranslation as useTranslation18, List as List2, ListItem as ListItem2, useDefaultValue } from "@dxos/react-ui";
1219
- import { AttentionGlyph, useAttended, useAttention } from "@dxos/react-ui-attention";
1220
- import { ComplexMap, keyToFallback } from "@dxos/util";
1221
-
1222
- // packages/plugins/plugin-space/src/hooks/usePath.ts
1223
- import { useEffect as useEffect3, useState as useState8 } from "react";
1224
- var usePath = (graph, id, timeout) => {
1225
- const [pathState, setPathState] = useState8(id ? graph.getPath({
1226
- target: id
1227
- }) : void 0);
1228
- useEffect3(() => {
1229
- if (!id && pathState) {
1230
- setPathState(void 0);
1231
- }
1232
- if (pathState?.at(-1) === id || !id) {
1233
- return;
1234
- }
1235
- const frame = requestAnimationFrame(async () => {
1236
- try {
1237
- const path = await graph.waitForPath({
1238
- target: id
1239
- }, {
1240
- timeout
1241
- });
1242
- if (path) {
1243
- setPathState(path);
1244
- }
1245
- } catch {
1246
- }
1247
- });
1248
- return () => cancelAnimationFrame(frame);
1249
- }, [
1250
- graph,
1251
- id,
1252
- timeout,
1253
- pathState
1254
- ]);
1255
- return pathState;
1256
- };
1257
-
1258
- // packages/plugins/plugin-space/src/components/SpacePresence.tsx
1259
- var REFRESH_INTERVAL = 5e3;
1260
- var ACTIVITY_DURATION = 3e4;
1261
- var noViewers = new ComplexMap(PublicKey.hash);
1262
- var getName = (identity) => identity.profile?.displayName ?? generateName(identity.identityKey.toHex());
1263
- var SpacePresence = ({ object, spaceKey }) => {
1264
- const spaceState = useCapability(SpaceCapabilities.MutableState);
1265
- const client = useClient5();
1266
- const identity = useIdentity();
1267
- const space = spaceKey ? client.spaces.get(spaceKey) : getSpace3(object);
1268
- const spaceMembers = useMembers(space?.key);
1269
- const [_moment, setMoment] = useState9(Date.now());
1270
- useEffect4(() => {
1271
- const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
1272
- return () => clearInterval(interval);
1273
- }, []);
1274
- const memberOnline = useCallback10((member) => member.presence === 1, []);
1275
- const memberIsNotSelf = useCallback10((member) => !identity?.identityKey.equals(member.identity.identityKey), [
1276
- identity?.identityKey
1277
- ]);
1278
- if (!identity || !spaceState || !space) {
1279
- return null;
1280
- }
1281
- const currentObjectViewers = spaceState.viewersByObject[fullyQualifiedId3(object)] ?? noViewers;
1282
- const membersForObject = spaceMembers.filter((member) => memberOnline(member) && memberIsNotSelf(member)).filter((member) => currentObjectViewers.has(member.identity.identityKey)).map((member) => {
1283
- const objectView = currentObjectViewers.get(member.identity.identityKey);
1284
- const lastSeen = objectView?.lastSeen ?? -Infinity;
1285
- const currentlyAttended = objectView?.currentlyAttended ?? false;
1286
- return {
1287
- ...member,
1288
- currentlyAttended,
1289
- lastSeen
1290
- };
1291
- }).toSorted((a, b) => a.lastSeen - b.lastSeen);
1292
- return /* @__PURE__ */ React19.createElement(FullPresence, {
1293
- members: membersForObject
1294
- });
1295
- };
1296
- var FullPresence = (props) => {
1297
- const { size = 9, onMemberClick } = props;
1298
- const members = useDefaultValue(props.members, () => []);
1299
- if (members.length === 0) {
1300
- return null;
1301
- }
1302
- return /* @__PURE__ */ React19.createElement("div", {
1303
- className: "dx-avatar-group",
1304
- "data-testid": "spacePlugin.presence"
1305
- }, members.slice(0, 3).map((member, i) => /* @__PURE__ */ React19.createElement(Tooltip2.Root, {
1306
- key: member.identity.identityKey.toHex()
1307
- }, /* @__PURE__ */ React19.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React19.createElement(PrensenceAvatar, {
1308
- identity: member.identity,
1309
- match: member.currentlyAttended,
1310
- index: members.length - i,
1311
- onClick: () => onMemberClick?.(member),
1312
- size
1313
- })), /* @__PURE__ */ React19.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React19.createElement(Tooltip2.Content, {
1314
- side: "bottom"
1315
- }, /* @__PURE__ */ React19.createElement("span", null, getName(member.identity)), /* @__PURE__ */ React19.createElement(Tooltip2.Arrow, null))))), members.length > 3 && /* @__PURE__ */ React19.createElement(Tooltip2.Root, null, /* @__PURE__ */ React19.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React19.createElement(Avatar.Root, null, /* @__PURE__ */ React19.createElement(Avatar.Content, {
1316
- status: "inactive",
1317
- style: {
1318
- zIndex: members.length - 4
1319
- },
1320
- fallback: `+${members.length - 3}`
1321
- }))), /* @__PURE__ */ React19.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React19.createElement(Tooltip2.Content, {
1322
- side: "bottom"
1323
- }, /* @__PURE__ */ React19.createElement(Tooltip2.Arrow, null), /* @__PURE__ */ React19.createElement(List2, {
1324
- classNames: "max-h-56 overflow-y-auto"
1325
- }, members.map((member) => /* @__PURE__ */ React19.createElement(ListItem2.Root, {
1326
- key: member.identity.identityKey.toHex(),
1327
- classNames: "flex gap-2 items-center cursor-pointer mbe-2",
1328
- onClick: () => onMemberClick?.(member),
1329
- "data-testid": "identity-list-item"
1330
- }, /* @__PURE__ */ React19.createElement(PrensenceAvatar, {
1331
- identity: member.identity,
1332
- size,
1333
- showName: true,
1334
- match: member.currentlyAttended
1335
- }))))))));
1336
- };
1337
- var PrensenceAvatar = ({ identity, showName, match, index, onClick, size }) => {
1338
- const status = match ? "current" : "active";
1339
- const fallbackValue = keyToFallback(identity.identityKey);
1340
- return /* @__PURE__ */ React19.createElement(Avatar.Root, null, /* @__PURE__ */ React19.createElement(Avatar.Content, {
1341
- status,
1342
- hue: identity.profile?.data?.hue || fallbackValue.hue,
1343
- "data-testid": "spacePlugin.presence.member",
1344
- "data-status": status,
1345
- size,
1346
- classNames: "mbs-2 mie-4",
1347
- ...index ? {
1348
- style: {
1349
- zIndex: index
1350
- }
1351
- } : {},
1352
- onClick: () => onClick?.(),
1353
- fallback: identity.profile?.data?.emoji || fallbackValue.emoji
1354
- }), /* @__PURE__ */ React19.createElement(Avatar.Label, {
1355
- classNames: showName ? "text-sm truncate pli-2" : "sr-only"
1356
- }, getName(identity)));
1357
- };
1358
- var SmallPresenceLive = ({ id, open, viewers }) => {
1359
- const { hasAttention, isAncestor, isRelated } = useAttention(id);
1360
- const isAttended = hasAttention || isAncestor || isRelated;
1361
- const { graph } = useAppGraph2();
1362
- const attended = useAttended();
1363
- const startOfAttention = attended.at(-1);
1364
- const path = usePath(graph, startOfAttention);
1365
- const containsAttended = !open && !isAttended && id && path ? path.includes(id) : false;
1366
- const getActiveViewers = (viewers2) => {
1367
- const moment = Date.now();
1368
- return Array.from(viewers2.values()).filter((viewer) => moment - viewer.lastSeen < ACTIVITY_DURATION);
1369
- };
1370
- const [activeViewers, setActiveViewers] = useState9(viewers ? getActiveViewers(viewers) : []);
1371
- useEffect4(() => {
1372
- if (viewers) {
1373
- setActiveViewers(getActiveViewers(viewers));
1374
- const interval = setInterval(() => {
1375
- setActiveViewers(getActiveViewers(viewers));
1376
- }, REFRESH_INTERVAL);
1377
- return () => clearInterval(interval);
1378
- }
1379
- }, [
1380
- viewers
1381
- ]);
1382
- return /* @__PURE__ */ React19.createElement(SmallPresence, {
1383
- count: activeViewers.length,
1384
- attended: isAttended,
1385
- containsAttended
1386
- });
1387
- };
1388
- var SmallPresence = ({ count = 0, attended, containsAttended }) => {
1389
- const { t } = useTranslation18(SPACE_PLUGIN);
1390
- return /* @__PURE__ */ React19.createElement(Tooltip2.Root, null, /* @__PURE__ */ React19.createElement(Tooltip2.Trigger, {
1391
- asChild: true
1392
- }, /* @__PURE__ */ React19.createElement(AttentionGlyph, {
1393
- attended,
1394
- containsAttended,
1395
- presence: count > 1 ? "many" : count === 1 ? "one" : "none",
1396
- classNames: "self-center mie-1"
1397
- })), /* @__PURE__ */ React19.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React19.createElement(Tooltip2.Content, {
1398
- side: "bottom"
1399
- }, /* @__PURE__ */ React19.createElement("span", null, t("presence label", {
1400
- count
1401
- })), /* @__PURE__ */ React19.createElement(Tooltip2.Arrow, null))));
1402
- };
1403
-
1404
- // packages/plugins/plugin-space/src/components/SpacePluginSettings.tsx
1405
- import React20 from "react";
1406
- import { Input as Input4, useTranslation as useTranslation19 } from "@dxos/react-ui";
1407
- import { DeprecatedFormContainer, DeprecatedFormInput } from "@dxos/react-ui-form";
1408
- var SpacePluginSettings = ({ settings }) => {
1409
- const { t } = useTranslation19(SPACE_PLUGIN);
1410
- return /* @__PURE__ */ React20.createElement(DeprecatedFormContainer, null, /* @__PURE__ */ React20.createElement(DeprecatedFormInput, {
1411
- label: t("show hidden spaces label")
1412
- }, /* @__PURE__ */ React20.createElement(Input4.Switch, {
1413
- checked: settings.showHidden,
1414
- onCheckedChange: (checked) => settings.showHidden = !!checked
1415
- })));
1416
- };
1417
-
1418
- // packages/plugins/plugin-space/src/components/SpaceSettings/SpacePropertiesForm.tsx
1419
- import React21, { useCallback as useCallback11, useMemo as useMemo3, useState as useState10 } from "react";
1420
- import { log as log3 } from "@dxos/log";
1421
- import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
1422
- import { Input as Input5, useTranslation as useTranslation20 } from "@dxos/react-ui";
1423
- import { Form as Form4, ControlItem, ControlItemInput } from "@dxos/react-ui-form";
1424
- import { HuePicker, IconPicker } from "@dxos/react-ui-pickers";
1425
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SpaceSettings/SpacePropertiesForm.tsx";
1426
- var SpacePropertiesForm = ({ space }) => {
1427
- const { t } = useTranslation20(SPACE_PLUGIN);
1428
- const [edgeReplication, setEdgeReplication] = useState10(space.internal.data.edgeReplication === EdgeReplicationSetting.ENABLED);
1429
- const toggleEdgeReplication = useCallback11(async (next) => {
1430
- setEdgeReplication(next);
1431
- await space?.internal.setEdgeReplicationPreference(next ? EdgeReplicationSetting.ENABLED : EdgeReplicationSetting.DISABLED).catch((err) => {
1432
- log3.catch(err, void 0, {
1433
- F: __dxlog_file5,
1434
- L: 34,
1435
- S: void 0,
1436
- C: (f, a) => f(...a)
1437
- });
1438
- setEdgeReplication(!next);
1439
- });
1440
- }, [
1441
- space
1442
- ]);
1443
- const handleSave = useCallback11((properties) => {
1444
- void toggleEdgeReplication(properties.edgeReplication);
1445
- if (properties.name !== space.properties.name) {
1446
- space.properties.name = properties.name;
1447
- }
1448
- if (properties.icon !== space.properties.icon) {
1449
- space.properties.icon = properties.icon;
1450
- }
1451
- if (properties.hue !== space.properties.hue) {
1452
- space.properties.hue = properties.hue;
1453
- }
1454
- }, [
1455
- space,
1456
- toggleEdgeReplication
1457
- ]);
1458
- const values = useMemo3(() => ({
1459
- name: space.properties.name,
1460
- icon: space.properties.icon,
1461
- hue: space.properties.hue,
1462
- edgeReplication
1463
- }), [
1464
- space.properties.name,
1465
- space.properties.icon,
1466
- space.properties.hue,
1467
- edgeReplication
1468
- ]);
1469
- const customElements = useMemo3(() => ({
1470
- name: ({ type, label, getValue, onValueChange }) => {
1471
- const handleChange = useCallback11(({ target: { value } }) => onValueChange(type, value), [
1472
- onValueChange,
1473
- type
1474
- ]);
1475
- return /* @__PURE__ */ React21.createElement(ControlItemInput, {
1476
- title: label,
1477
- description: t("display name description")
1478
- }, /* @__PURE__ */ React21.createElement(Input5.TextInput, {
1479
- value: getValue(),
1480
- onChange: handleChange,
1481
- placeholder: t("display name input placeholder"),
1482
- classNames: "min-is-64"
1483
- }));
1484
- },
1485
- icon: ({ type, label, getValue, onValueChange }) => {
1486
- const handleChange = useCallback11((nextEmoji) => onValueChange(type, nextEmoji), [
1487
- onValueChange,
1488
- type
1489
- ]);
1490
- const handleEmojiReset = useCallback11(() => onValueChange(type, void 0), [
1491
- onValueChange,
1492
- type
1493
- ]);
1494
- return /* @__PURE__ */ React21.createElement(ControlItem, {
1495
- title: label,
1496
- description: t("icon description")
1497
- }, /* @__PURE__ */ React21.createElement(IconPicker, {
1498
- value: getValue(),
1499
- onChange: handleChange,
1500
- onReset: handleEmojiReset,
1501
- classNames: "justify-self-end",
1502
- iconSize: 5
1503
- }));
1504
- },
1505
- hue: ({ type, label, getValue, onValueChange }) => {
1506
- const handleChange = useCallback11((nextHue) => onValueChange(type, nextHue), [
1507
- onValueChange,
1508
- type
1509
- ]);
1510
- const handleHueReset = useCallback11(() => onValueChange(type, void 0), [
1511
- onValueChange,
1512
- type
1513
- ]);
1514
- return /* @__PURE__ */ React21.createElement(ControlItem, {
1515
- title: label,
1516
- description: t("hue description")
1517
- }, /* @__PURE__ */ React21.createElement(HuePicker, {
1518
- value: getValue(),
1519
- onChange: handleChange,
1520
- onReset: handleHueReset,
1521
- classNames: "[--hue-preview-size:1.25rem] justify-self-end"
1522
- }));
1523
- },
1524
- edgeReplication: ({ type, label, getValue, onValueChange }) => {
1525
- const handleChange = useCallback11((checked) => onValueChange(type, checked), [
1526
- onValueChange,
1527
- type
1528
- ]);
1529
- return /* @__PURE__ */ React21.createElement(ControlItemInput, {
1530
- title: label,
1531
- description: t("edge replication description")
1532
- }, /* @__PURE__ */ React21.createElement(Input5.Switch, {
1533
- checked: getValue(),
1534
- onCheckedChange: handleChange,
1535
- classNames: "justify-self-end"
1536
- }));
1537
- }
1538
- }), [
1539
- t
1540
- ]);
1541
- return /* @__PURE__ */ React21.createElement(Form4, {
1542
- schema: SpaceForm,
1543
- values,
1544
- autoSave: true,
1545
- onSave: handleSave,
1546
- Custom: customElements,
1547
- classNames: 'p-0 container-max-width [&_[role="form"]]:grid [&_[role="form"]]:grid-cols-1 md:[&_[role="form"]]:grid-cols-[1fr_min-content] [&_[role="form"]]:gap-4'
1548
- });
1549
- };
1550
-
1551
- // packages/plugins/plugin-space/src/components/SpaceSettings/SpaceSettingsContainer.tsx
1552
- import React22, { useCallback as useCallback12, useMemo as useMemo4 } from "react";
1553
- import { Surface as Surface3, useCapabilities as useCapabilities2, useCapability as useCapability2 } from "@dxos/app-framework";
1554
- import { toLocalizedString as toLocalizedString3, useTranslation as useTranslation21 } from "@dxos/react-ui";
1555
- import { ControlSectionHeading } from "@dxos/react-ui-form";
1556
- import { Accordion } from "@dxos/react-ui-list";
1557
- import { StackItem as StackItem3 } from "@dxos/react-ui-stack";
1558
- import { byPosition } from "@dxos/util";
1559
- var SPACE_SETTINGS_DIALOG = `${SPACE_PLUGIN}/SpaceSettingsDialog`;
1560
- var SpaceSettingsContainer = ({ space }) => {
1561
- const { t } = useTranslation21(SPACE_PLUGIN);
1562
- const state = useCapability2(SpaceCapabilities.MutableState);
1563
- const items = useCapabilities2(SpaceCapabilities.SettingsSection).toSorted(byPosition);
1564
- const data = useMemo4(() => ({
1565
- subject: space
1566
- }), [
1567
- space
1568
- ]);
1569
- const handleOpenSectionChange = useCallback12((sections) => {
1570
- state.spaceSettingsOpenSections.splice(0, state.spaceSettingsOpenSections.length, ...sections);
1571
- }, [
1572
- state
1573
- ]);
1574
- return /* @__PURE__ */ React22.createElement(StackItem3.Content, {
1575
- classNames: "p-2 block overflow-y-auto"
1576
- }, /* @__PURE__ */ React22.createElement(Accordion.Root, {
1577
- items,
1578
- value: state.spaceSettingsOpenSections,
1579
- onValueChange: handleOpenSectionChange
1580
- }, ({ items: items2 }) => /* @__PURE__ */ React22.createElement(React22.Fragment, null, items2.map((item) => /* @__PURE__ */ React22.createElement(Accordion.Item, {
1581
- key: item.id,
1582
- item,
1583
- classNames: "container-max-width"
1584
- }, /* @__PURE__ */ React22.createElement(Accordion.ItemHeader, {
1585
- classNames: "pie-6",
1586
- asChild: true
1587
- }, /* @__PURE__ */ React22.createElement(ControlSectionHeading, {
1588
- title: toLocalizedString3(item.label, t)
1589
- })), /* @__PURE__ */ React22.createElement(Accordion.ItemBody, null, /* @__PURE__ */ React22.createElement(Surface3, {
1590
- role: `space-settings--${item.id}`,
1591
- data
1592
- })))))));
1593
- };
1594
-
1595
- // packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
1596
- import React23, { useEffect as useEffect6, useState as useState12 } from "react";
1597
- import { useAppGraph as useAppGraph3 } from "@dxos/app-framework";
1598
- import { QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
1599
- import { EdgeReplicationSetting as EdgeReplicationSetting2 } from "@dxos/protocols/proto/dxos/echo/metadata";
1600
- import { useClient as useClient7 } from "@dxos/react-client";
1601
- import { Tooltip as Tooltip3, useTranslation as useTranslation22 } from "@dxos/react-ui";
1602
- import { AttentionGlyph as AttentionGlyph2, useAttended as useAttended2, useAttention as useAttention2 } from "@dxos/react-ui-attention";
1603
-
1604
- // packages/plugins/plugin-space/src/components/SyncStatus/sync-state.ts
1605
- import { useEffect as useEffect5, useState as useState11 } from "react";
1606
- import { Context } from "@dxos/context";
1607
- import { EdgeService } from "@dxos/protocols";
1608
- import { useClient as useClient6 } from "@dxos/react-client";
1609
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/sync-state.ts";
1610
- var createEmptyEdgeSyncState = () => ({
1611
- missingOnLocal: 0,
1612
- missingOnRemote: 0,
1613
- localDocumentCount: 0,
1614
- remoteDocumentCount: 0,
1615
- differentDocuments: 0
1616
- });
1617
- var getSyncSummary = (syncMap) => {
1618
- return Object.entries(syncMap).reduce((summary, [_spaceId, peerState]) => {
1619
- summary.missingOnLocal += peerState.missingOnLocal;
1620
- summary.missingOnRemote += peerState.missingOnRemote;
1621
- summary.localDocumentCount += peerState.localDocumentCount;
1622
- summary.remoteDocumentCount += peerState.remoteDocumentCount;
1623
- summary.differentDocuments += peerState.differentDocuments;
1624
- return summary;
1625
- }, createEmptyEdgeSyncState());
1626
- };
1627
- var isEdgePeerId = (peerId, spaceId) => peerId.startsWith(`${EdgeService.AUTOMERGE_REPLICATOR}:${spaceId}`);
1628
- var useSyncState = () => {
1629
- const client = useClient6();
1630
- const [spaceState, setSpaceState] = useState11({});
1631
- useEffect5(() => {
1632
- const ctx = new Context(void 0, {
1633
- F: __dxlog_file6,
1634
- L: 48
1635
- });
1636
- const createSubscriptions = (spaces) => {
1637
- for (const space of spaces) {
1638
- if (spaceState[space.id]) {
1639
- continue;
1640
- }
1641
- ctx.onDispose(space.crud.subscribeToSyncState(ctx, ({ peers = [] }) => {
1642
- const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
1643
- if (syncState) {
1644
- setSpaceState((spaceState2) => ({
1645
- ...spaceState2,
1646
- [space.id]: syncState
1647
- }));
1648
- }
1649
- }));
1650
- }
1651
- };
1652
- createSubscriptions(client.spaces.get());
1653
- client.spaces.subscribe((spaces) => {
1654
- createSubscriptions(spaces);
1655
- });
1656
- return () => {
1657
- void ctx.dispose();
1658
- };
1659
- }, [
1660
- client
1661
- ]);
1662
- return spaceState;
1663
- };
1664
- var useSpaceSyncState = (space) => {
1665
- const [spaceState, setSpaceState] = useState11();
1666
- useEffect5(() => {
1667
- const ctx = new Context(void 0, {
1668
- F: __dxlog_file6,
1669
- L: 87
1670
- });
1671
- space.crud.subscribeToSyncState(ctx, ({ peers = [] }) => {
1672
- const syncState = peers.find((state) => isEdgePeerId(state.peerId, space.id));
1673
- if (syncState) {
1674
- setSpaceState(syncState);
1675
- }
1676
- });
1677
- return () => {
1678
- void ctx.dispose();
1679
- };
1680
- }, [
1681
- space
1682
- ]);
1683
- return spaceState;
1684
- };
1685
-
1686
- // packages/plugins/plugin-space/src/components/SyncStatus/InlineSyncStatus.tsx
1687
- var useEdgeStatus = () => {
1688
- const [status, setStatus] = useState12(QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED);
1689
- const client = useClient7();
1690
- useEffect6(() => {
1691
- client.services.services.EdgeAgentService?.queryEdgeStatus().subscribe(({ status: status2 }) => {
1692
- setStatus(status2);
1693
- });
1694
- }, [
1695
- client
1696
- ]);
1697
- return status;
1698
- };
1699
- var InlineSyncStatus = ({ space, open }) => {
1700
- const { t } = useTranslation22(SPACE_PLUGIN);
1701
- const id = space.id;
1702
- const { hasAttention, isAncestor, isRelated } = useAttention2(id);
1703
- const isAttended = hasAttention || isAncestor || isRelated;
1704
- const { graph } = useAppGraph3();
1705
- const attended = useAttended2();
1706
- const startOfAttention = attended.at(-1);
1707
- const path = usePath(graph, startOfAttention);
1708
- const containsAttended = !open && !isAttended && id && path ? path.includes(id) : false;
1709
- const connectedToEdge = useEdgeStatus() === QueryEdgeStatusResponse.EdgeStatus.CONNECTED;
1710
- const edgeSyncEnabled = space.internal.data.edgeReplication === EdgeReplicationSetting2.ENABLED;
1711
- const syncState = useSpaceSyncState(space);
1712
- const syncing = connectedToEdge && edgeSyncEnabled && syncState && syncState.missingOnLocal > 0;
1713
- return /* @__PURE__ */ React23.createElement(Tooltip3.Root, null, /* @__PURE__ */ React23.createElement(Tooltip3.Trigger, {
1714
- asChild: true
1715
- }, /* @__PURE__ */ React23.createElement(AttentionGlyph2, {
1716
- syncing,
1717
- attended: isAttended,
1718
- containsAttended,
1719
- classNames: "self-center mie-1"
1720
- })), /* @__PURE__ */ React23.createElement(Tooltip3.Portal, null, /* @__PURE__ */ React23.createElement(Tooltip3.Content, {
1721
- side: "bottom",
1722
- classNames: "z-[70]"
1723
- }, /* @__PURE__ */ React23.createElement("span", null, t("syncing label")), /* @__PURE__ */ React23.createElement(Tooltip3.Arrow, null))));
1724
- };
1725
-
1726
- // packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
1727
- import React25, { useCallback as useCallback13, useEffect as useEffect8, useState as useState14 } from "react";
1728
- import { StatusBar } from "@dxos/plugin-status-bar";
1729
- import { useClient as useClient9 } from "@dxos/react-client";
1730
- import { Icon as Icon6, Input as Input6, Popover as Popover3, useTranslation as useTranslation24 } from "@dxos/react-ui";
1731
- import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
1732
- import { mx as mx8 } from "@dxos/react-ui-theme";
1733
-
1734
- // packages/plugins/plugin-space/src/components/SyncStatus/Space.tsx
1735
- import React24, { useEffect as useEffect7, useState as useState13 } from "react";
1736
- import { useClient as useClient8 } from "@dxos/react-client";
1737
- import { useSpace } from "@dxos/react-client/echo";
1738
- import { Icon as Icon5, toLocalizedString as toLocalizedString4, useTranslation as useTranslation23 } from "@dxos/react-ui";
1739
- import { mx as mx7 } from "@dxos/react-ui-theme";
1740
- var SYNC_STALLED_TIMEOUT = 5e3;
1741
- var styles = {
1742
- barBg: "bg-neutral-50 dark:bg-green-900 text-black",
1743
- barFg: "bg-neutral-100 bg-green-500",
1744
- barHover: "dark:hover:bg-green-500"
1745
- };
1746
- var useActive = (count) => {
1747
- const [current, setCurrent] = useState13(count);
1748
- const [active, setActive] = useState13(false);
1749
- useEffect7(() => {
1750
- let t;
1751
- if (count !== current) {
1752
- setActive(true);
1753
- setCurrent(count);
1754
- t && clearTimeout(t);
1755
- t = setTimeout(() => {
1756
- setActive(false);
1757
- }, SYNC_STALLED_TIMEOUT);
1758
- }
1759
- return () => {
1760
- setActive(false);
1761
- clearTimeout(t);
1762
- };
1763
- }, [
1764
- count,
1765
- current
1766
- ]);
1767
- return active;
1768
- };
1769
- var SpaceRowContainer = ({ spaceId, state }) => {
1770
- const { t } = useTranslation23(SPACE_PLUGIN);
1771
- const client = useClient8();
1772
- const space = useSpace(spaceId);
1773
- if (!space) {
1774
- return null;
1775
- }
1776
- const spaceName = toLocalizedString4(getSpaceDisplayName(space, {
1777
- personal: space === client.spaces.default
1778
- }), t);
1779
- return /* @__PURE__ */ React24.createElement(SpaceRow, {
1780
- spaceId,
1781
- spaceName,
1782
- state
1783
- });
1784
- };
1785
- var SpaceRow = ({ spaceId, spaceName, state: { localDocumentCount, remoteDocumentCount, missingOnLocal, missingOnRemote } }) => {
1786
- const downActive = useActive(localDocumentCount);
1787
- const upActive = useActive(remoteDocumentCount);
1788
- return /* @__PURE__ */ React24.createElement("div", {
1789
- className: "flex items-center mx-0.5 gap-0.5 cursor-pointer",
1790
- title: spaceId,
1791
- onClick: () => {
1792
- void navigator.clipboard.writeText(spaceId);
1793
- }
1794
- }, /* @__PURE__ */ React24.createElement("span", {
1795
- className: "is-1/2 truncate"
1796
- }, spaceName), /* @__PURE__ */ React24.createElement(Icon5, {
1797
- icon: "ph--arrow-fat-line-left--regular",
1798
- size: 3,
1799
- classNames: mx7(downActive && "animate-[pulse_1s_infinite]")
1800
- }), /* @__PURE__ */ React24.createElement(Candle, {
1801
- up: {
1802
- count: remoteDocumentCount,
1803
- total: remoteDocumentCount + missingOnRemote
1804
- },
1805
- down: {
1806
- count: localDocumentCount,
1807
- total: localDocumentCount + missingOnLocal
1808
- },
1809
- title: spaceId
1810
- }), /* @__PURE__ */ React24.createElement(Icon5, {
1811
- icon: "ph--arrow-fat-line-right--regular",
1812
- size: 3,
1813
- classNames: mx7(upActive && "animate-[pulse_1s_step-start_infinite]")
1814
- }));
1815
- };
1816
- var Candle = ({ classNames, up, down }) => {
1817
- return /* @__PURE__ */ React24.createElement("div", {
1818
- className: mx7("grid grid-cols-[1fr_2rem_1fr] w-full h-3", classNames)
1819
- }, /* @__PURE__ */ React24.createElement(Bar, {
1820
- classNames: "justify-end",
1821
- ...up
1822
- }), /* @__PURE__ */ React24.createElement("div", {
1823
- className: "relative"
1824
- }, /* @__PURE__ */ React24.createElement("div", {
1825
- className: mx7("absolute inset-0 flex items-center justify-center text-xs", styles.barBg)
1826
- }, up.total)), /* @__PURE__ */ React24.createElement(Bar, down));
1827
- };
1828
- var Bar = ({ classNames, count, total }) => {
1829
- let p = count / total * 100;
1830
- if (count < total) {
1831
- p = Math.min(p, 95);
1832
- }
1833
- return /* @__PURE__ */ React24.createElement("div", {
1834
- className: mx7("relative flex w-full", styles.barBg, classNames)
1835
- }, /* @__PURE__ */ React24.createElement("div", {
1836
- className: mx7("shrink-0", styles.barFg),
1837
- style: {
1838
- width: `${p}%`
1839
- }
1840
- }), count !== total && /* @__PURE__ */ React24.createElement("div", {
1841
- className: "absolute top-0 bottom-0 flex items-center mx-0.5 text-black text-xs"
1842
- }, count));
1843
- };
1844
-
1845
- // packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts
1846
- import { Context as Context2 } from "@dxos/context";
1847
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/SyncStatus/save-tracker.ts";
1848
- var createClientSaveTracker = (client, cb) => {
1849
- const CleanupFns = {};
1850
- const state = {};
1851
- const install = (spaces) => {
1852
- for (const space of spaces) {
1853
- if (state[space.id]) {
1854
- continue;
1855
- }
1856
- state[space.id] = "saved";
1857
- CleanupFns[space.id] = createSpaceSaveTracker(space, (s) => {
1858
- state[space.id] = s;
1859
- cb(Object.values(state).some((s2) => s2 === "saving") ? "saving" : "saved");
1860
- });
1861
- }
1862
- };
1863
- client.spaces.subscribe((spaces) => {
1864
- install(spaces);
1865
- });
1866
- install(client.spaces.get());
1867
- return () => {
1868
- for (const unsubscribe of Object.values(CleanupFns)) {
1869
- unsubscribe();
1870
- }
1871
- };
1872
- };
1873
- var createSpaceSaveTracker = (space, cb) => {
1874
- const ctx = new Context2(void 0, {
1875
- F: __dxlog_file7,
1876
- L: 40
1877
- });
1878
- void space.waitUntilReady().then(() => {
1879
- if (ctx.disposed) {
1880
- return;
1881
- }
1882
- let hasUnsavedChanges = false;
1883
- let lastFlushPromise;
1884
- space.crud.saveStateChanged.on(ctx, ({ unsavedDocuments }) => {
1885
- hasUnsavedChanges = unsavedDocuments.length > 0;
1886
- });
1887
- space.crud.saveStateChanged.debounce(500).on(ctx, () => {
1888
- if (hasUnsavedChanges) {
1889
- lastFlushPromise = void 0;
1890
- cb("saving");
1891
- } else {
1892
- const flushPromise = space.crud.flush();
1893
- lastFlushPromise = flushPromise;
1894
- void flushPromise.then(() => {
1895
- if (lastFlushPromise === flushPromise) {
1896
- cb("saved");
1897
- }
1898
- });
1899
- }
1900
- });
1901
- });
1902
- return () => {
1903
- void ctx.dispose();
1904
- };
1905
- };
1906
-
1907
- // packages/plugins/plugin-space/src/components/SyncStatus/status.ts
1908
- var getStatus = ({ offline, saved, needsToUpload, needsToDownload }) => {
1909
- if (!saved) {
1910
- return "saving locally";
1911
- } else if (!offline && needsToDownload) {
1912
- return "downloading";
1913
- } else if (!offline && needsToUpload) {
1914
- return "uploading";
1915
- } else if (offline && !needsToUpload && !needsToDownload) {
1916
- return "offline persisted";
1917
- } else {
1918
- return "remote synced";
1919
- }
1920
- };
1921
- var getIcon = (status) => {
1922
- switch (status) {
1923
- case "saving locally":
1924
- return "ph--download--regular";
1925
- case "downloading":
1926
- return "ph--cloud-arrow-down--regular";
1927
- case "uploading":
1928
- return "ph--cloud-arrow-up--regular";
1929
- case "offline persisted":
1930
- return "ph--check-circle--regular";
1931
- case "remote synced":
1932
- return "ph--cloud-check--regular";
1933
- }
1934
- };
1935
-
1936
- // packages/plugins/plugin-space/src/components/SyncStatus/SyncStatus.tsx
1937
- var SyncStatus = () => {
1938
- const client = useClient9();
1939
- const state = useSyncState();
1940
- const [saved, setSaved] = useState14(true);
1941
- useEffect8(() => {
1942
- return createClientSaveTracker(client, (state2) => {
1943
- setSaved(state2 === "saved");
1944
- });
1945
- }, []);
1946
- return /* @__PURE__ */ React25.createElement(SyncStatusIndicator, {
1947
- state,
1948
- saved
1949
- });
1950
- };
1951
- var SyncStatusIndicator = ({ state, saved }) => {
1952
- const { t } = useTranslation24(SPACE_PLUGIN);
1953
- const summary = getSyncSummary(state);
1954
- const offline = Object.values(state).length === 0;
1955
- const needsToUpload = summary.differentDocuments > 0 || summary.missingOnRemote > 0;
1956
- const needsToDownload = summary.differentDocuments > 0 || summary.missingOnLocal > 0;
1957
- const status = getStatus({
1958
- offline,
1959
- saved,
1960
- needsToUpload,
1961
- needsToDownload
1962
- });
1963
- const [classNames, setClassNames] = useState14();
1964
- useEffect8(() => {
1965
- setClassNames(void 0);
1966
- if (offline || !needsToUpload && !needsToDownload) {
1967
- return;
1968
- }
1969
- const t2 = setTimeout(() => {
1970
- setClassNames("text-orange-500");
1971
- }, SYNC_STALLED_TIMEOUT);
1972
- return () => clearTimeout(t2);
1973
- }, [
1974
- offline,
1975
- needsToUpload,
1976
- needsToDownload
1977
- ]);
1978
- const title = t(`${status} label`);
1979
- const icon = /* @__PURE__ */ React25.createElement(Icon6, {
1980
- icon: getIcon(status),
1981
- size: 4,
1982
- classNames
1983
- });
1984
- if (offline) {
1985
- return /* @__PURE__ */ React25.createElement(StatusBar.Item, {
1986
- title
1987
- }, icon);
1988
- } else {
1989
- return /* @__PURE__ */ React25.createElement(Popover3.Root, null, /* @__PURE__ */ React25.createElement(Popover3.Trigger, {
1990
- asChild: true
1991
- }, /* @__PURE__ */ React25.createElement(StatusBar.Button, {
1992
- title
1993
- }, icon)), /* @__PURE__ */ React25.createElement(Popover3.Portal, null, /* @__PURE__ */ React25.createElement(Popover3.Content, null, /* @__PURE__ */ React25.createElement(SyncStatusDetail, {
1994
- state,
1995
- summary,
1996
- debug: false
1997
- }), /* @__PURE__ */ React25.createElement(Popover3.Arrow, null))));
1998
- }
1999
- };
2000
- var SyncStatusDetail = ({ classNames, state, summary, debug }) => {
2001
- const [showAll, setShowAll] = useState14(false);
2002
- const { t } = useTranslation24(SPACE_PLUGIN);
2003
- const entries = Object.entries(state).filter(([_, value]) => showAll || value.missingOnLocal + value.missingOnRemote > 0).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
2004
- const handleCheckedChange = useCallback13((state2) => setShowAll(state2), [
2005
- setShowAll
2006
- ]);
2007
- return /* @__PURE__ */ React25.createElement("div", {
2008
- className: mx8("flex flex-col gap-3 p-2 text-xs min-w-[400px]", classNames)
2009
- }, /* @__PURE__ */ React25.createElement("div", {
2010
- role: "none",
2011
- className: "flex items-center"
2012
- }, /* @__PURE__ */ React25.createElement("h1", {
2013
- className: "flex-1"
2014
- }, t("sync status title")), /* @__PURE__ */ React25.createElement("div", {
2015
- className: "flex items-center gap-2"
2016
- }, /* @__PURE__ */ React25.createElement(Input6.Root, null, /* @__PURE__ */ React25.createElement(Input6.Label, {
2017
- classNames: "text-xs"
2018
- }, t("show all label")), /* @__PURE__ */ React25.createElement(Input6.Checkbox, {
2019
- checked: showAll,
2020
- onCheckedChange: handleCheckedChange
2021
- })))), /* @__PURE__ */ React25.createElement("div", {
2022
- className: "flex flex-col gap-2"
2023
- }, entries.length === 0 && /* @__PURE__ */ React25.createElement("div", {
2024
- role: "none",
2025
- className: "flex justify-center"
2026
- }, t("no sync status label")), entries.map(([spaceId, state2]) => /* @__PURE__ */ React25.createElement(SpaceRowContainer, {
2027
- key: spaceId,
2028
- spaceId,
2029
- state: state2
2030
- }))), debug && /* @__PURE__ */ React25.createElement(SyntaxHighlighter, {
2031
- language: "json"
2032
- }, JSON.stringify(summary, null, 2)));
2033
- };
2034
-
2035
- export {
2036
- AwaitingObject,
2037
- CREATE_OBJECT_DIALOG,
2038
- CreateObjectDialog,
2039
- CREATE_SPACE_DIALOG,
2040
- CreateSpaceDialog,
2041
- CollectionMain,
2042
- CollectionSection,
2043
- JOIN_DIALOG,
2044
- JoinDialog,
2045
- MembersContainer,
2046
- MenuFooter,
2047
- ObjectSettingsContainer,
2048
- PersistenceStatus,
2049
- POPOVER_ADD_SPACE,
2050
- PopoverAddSpace,
2051
- POPOVER_RENAME_OBJECT,
2052
- PopoverRenameObject,
2053
- POPOVER_RENAME_SPACE,
2054
- PopoverRenameSpace,
2055
- ShareSpaceButton,
2056
- ShareSpaceButtonImpl,
2057
- SpacePresence,
2058
- FullPresence,
2059
- SmallPresenceLive,
2060
- SmallPresence,
2061
- SpacePluginSettings,
2062
- SpacePropertiesForm,
2063
- SPACE_SETTINGS_DIALOG,
2064
- SpaceSettingsContainer,
2065
- InlineSyncStatus,
2066
- SyncStatus,
2067
- SyncStatusIndicator,
2068
- SyncStatusDetail,
2069
- AppGraphBuilder,
2070
- AppGraphSerializer,
2071
- IdentityCreated,
2072
- IntentResolver,
2073
- ReactRoot,
2074
- ReactSurface,
2075
- Schema,
2076
- Tools,
2077
- SpaceSettings,
2078
- SpaceState,
2079
- SpacesReady
2080
- };
2081
- //# sourceMappingURL=chunk-JZXWPMLA.mjs.map