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