@dxos/plugin-space 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

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