@dxos/plugin-space 0.7.5-main.9d2a38b → 0.7.5-main.ff8607b

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 (171) hide show
  1. package/dist/lib/browser/{app-graph-builder-F6XSETHX.mjs → app-graph-builder-J4NX44Y4.mjs} +10 -8
  2. package/dist/lib/browser/{app-graph-builder-F6XSETHX.mjs.map → app-graph-builder-J4NX44Y4.mjs.map} +3 -3
  3. package/dist/lib/browser/{app-graph-serializer-FYJE23GN.mjs → app-graph-serializer-QF7VVRCV.mjs} +5 -5
  4. package/dist/lib/browser/{chunk-IZ7QKQ2E.mjs → chunk-6UIFMVVI.mjs} +14 -9
  5. package/dist/lib/browser/chunk-6UIFMVVI.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-SOXNANA6.mjs → chunk-PQXZCNAU.mjs} +3 -2
  7. package/dist/lib/browser/{chunk-SOXNANA6.mjs.map → chunk-PQXZCNAU.mjs.map} +3 -3
  8. package/dist/lib/browser/{chunk-UH5P4UL3.mjs → chunk-RLZQJD47.mjs} +3 -2
  9. package/dist/lib/browser/chunk-RLZQJD47.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-T36CIHPG.mjs → chunk-SDK7RZI3.mjs} +3 -3
  11. package/dist/lib/browser/{chunk-SSJ772GK.mjs → chunk-XPZ6IIXF.mjs} +4 -5
  12. package/dist/lib/browser/chunk-XPZ6IIXF.mjs.map +7 -0
  13. package/dist/lib/browser/{chunk-XXD33C4E.mjs → chunk-XZ2NH3CP.mjs} +291 -250
  14. package/dist/lib/browser/chunk-XZ2NH3CP.mjs.map +7 -0
  15. package/dist/lib/browser/{identity-created-4Q4PFIC5.mjs → identity-created-25TK5XNO.mjs} +3 -3
  16. package/dist/lib/browser/index.mjs +11 -11
  17. package/dist/lib/browser/index.mjs.map +3 -3
  18. package/dist/lib/browser/intent-resolver-IEDVV74T.mjs +523 -0
  19. package/dist/lib/browser/intent-resolver-IEDVV74T.mjs.map +7 -0
  20. package/dist/lib/browser/meta.json +1 -1
  21. package/dist/lib/browser/{react-root-BDOPFJGJ.mjs → react-root-6VRPRLQR.mjs} +6 -6
  22. package/dist/lib/browser/{react-surface-EGOL2JBL.mjs → react-surface-DMNDXLZ7.mjs} +26 -33
  23. package/dist/lib/browser/react-surface-DMNDXLZ7.mjs.map +7 -0
  24. package/dist/lib/browser/{settings-WF67QZSD.mjs → settings-K4JPYYEM.mjs} +3 -3
  25. package/dist/lib/browser/{spaces-ready-WVU7US3C.mjs → spaces-ready-2MUWWVVO.mjs} +31 -32
  26. package/dist/lib/browser/spaces-ready-2MUWWVVO.mjs.map +7 -0
  27. package/dist/lib/browser/{state-MS4KYJWI.mjs → state-6DCY5YJP.mjs} +3 -3
  28. package/dist/lib/browser/types/index.mjs +2 -2
  29. package/dist/lib/node/{app-graph-builder-GKLVZ4PM.cjs → app-graph-builder-ZOPG4MOS.cjs} +58 -56
  30. package/dist/lib/node/{app-graph-builder-GKLVZ4PM.cjs.map → app-graph-builder-ZOPG4MOS.cjs.map} +3 -3
  31. package/dist/lib/node/{app-graph-serializer-RMTU5YSC.cjs → app-graph-serializer-QE2G4MWB.cjs} +21 -21
  32. package/dist/lib/node/{chunk-5D4RWKTV.cjs → chunk-3QWZCN6L.cjs} +65 -60
  33. package/dist/lib/node/chunk-3QWZCN6L.cjs.map +7 -0
  34. package/dist/lib/node/{chunk-YCBBGTFD.cjs → chunk-6MEOP3DH.cjs} +8 -9
  35. package/dist/lib/node/chunk-6MEOP3DH.cjs.map +7 -0
  36. package/dist/lib/node/{chunk-UENH2YBM.cjs → chunk-D6BFKOXY.cjs} +8 -8
  37. package/dist/lib/node/{chunk-AJRP7AD6.cjs → chunk-SZEIQGQU.cjs} +292 -251
  38. package/dist/lib/node/chunk-SZEIQGQU.cjs.map +7 -0
  39. package/dist/lib/node/{chunk-56NGXG2A.cjs → chunk-UX3U4RU2.cjs} +9 -8
  40. package/dist/lib/node/chunk-UX3U4RU2.cjs.map +7 -0
  41. package/dist/lib/node/{chunk-AO4EW2RX.cjs → chunk-WZR6OAN3.cjs} +6 -5
  42. package/dist/lib/node/{chunk-AO4EW2RX.cjs.map → chunk-WZR6OAN3.cjs.map} +3 -3
  43. package/dist/lib/node/{identity-created-QQWX7WX3.cjs → identity-created-7G5U7R36.cjs} +7 -7
  44. package/dist/lib/node/index.cjs +90 -90
  45. package/dist/lib/node/index.cjs.map +3 -3
  46. package/dist/lib/node/intent-resolver-N2W2L6OL.cjs +522 -0
  47. package/dist/lib/node/intent-resolver-N2W2L6OL.cjs.map +7 -0
  48. package/dist/lib/node/meta.json +1 -1
  49. package/dist/lib/node/{react-root-ZTR2J2I3.cjs → react-root-YD35W3VU.cjs} +12 -12
  50. package/dist/lib/node/{react-surface-75KRPQYT.cjs → react-surface-QPLXK7DT.cjs} +72 -76
  51. package/dist/lib/node/react-surface-QPLXK7DT.cjs.map +7 -0
  52. package/dist/lib/node/{settings-KOVSPA3S.cjs → settings-TEELGWS4.cjs} +8 -8
  53. package/dist/lib/node/{spaces-ready-ILVGUHJH.cjs → spaces-ready-PZZQWS6T.cjs} +39 -40
  54. package/dist/lib/node/spaces-ready-PZZQWS6T.cjs.map +7 -0
  55. package/dist/lib/node/{state-4UIOUKLJ.cjs → state-WPZC4JXB.cjs} +8 -8
  56. package/dist/lib/node/types/index.cjs +16 -16
  57. package/dist/lib/node/types/index.cjs.map +1 -1
  58. package/dist/lib/node-esm/{app-graph-builder-NEHQ5Z63.mjs → app-graph-builder-TKGLOK22.mjs} +10 -8
  59. package/dist/lib/node-esm/{app-graph-builder-NEHQ5Z63.mjs.map → app-graph-builder-TKGLOK22.mjs.map} +3 -3
  60. package/dist/lib/node-esm/{app-graph-serializer-UWWS5OVC.mjs → app-graph-serializer-HLX2JRNF.mjs} +5 -5
  61. package/dist/lib/node-esm/{chunk-E5DWIQ3N.mjs → chunk-4UX5WGKJ.mjs} +3 -3
  62. package/dist/lib/node-esm/{chunk-HTBGWQEU.mjs → chunk-AAQRELDK.mjs} +4 -5
  63. package/dist/lib/node-esm/chunk-AAQRELDK.mjs.map +7 -0
  64. package/dist/lib/node-esm/{chunk-7FUVU45N.mjs → chunk-ICCM4YRJ.mjs} +3 -2
  65. package/dist/lib/node-esm/{chunk-7FUVU45N.mjs.map → chunk-ICCM4YRJ.mjs.map} +3 -3
  66. package/dist/lib/node-esm/{chunk-5QMAPAZD.mjs → chunk-LA45TPAN.mjs} +14 -9
  67. package/dist/lib/node-esm/chunk-LA45TPAN.mjs.map +7 -0
  68. package/dist/lib/node-esm/{chunk-375RB3CZ.mjs → chunk-LGL4A5B5.mjs} +3 -2
  69. package/dist/lib/node-esm/chunk-LGL4A5B5.mjs.map +7 -0
  70. package/dist/lib/node-esm/{chunk-GVOPDPS2.mjs → chunk-N6EAOMIS.mjs} +291 -250
  71. package/dist/lib/node-esm/chunk-N6EAOMIS.mjs.map +7 -0
  72. package/dist/lib/node-esm/{identity-created-HMNY2MPB.mjs → identity-created-7THGZ7EW.mjs} +3 -3
  73. package/dist/lib/node-esm/index.mjs +11 -11
  74. package/dist/lib/node-esm/index.mjs.map +3 -3
  75. package/dist/lib/node-esm/intent-resolver-L2TKJU4I.mjs +524 -0
  76. package/dist/lib/node-esm/intent-resolver-L2TKJU4I.mjs.map +7 -0
  77. package/dist/lib/node-esm/meta.json +1 -1
  78. package/dist/lib/node-esm/{react-root-OUPJA4RY.mjs → react-root-Q5MFDXZE.mjs} +6 -6
  79. package/dist/lib/node-esm/{react-surface-7EVWCKIP.mjs → react-surface-RQQZ5BOG.mjs} +26 -33
  80. package/dist/lib/node-esm/react-surface-RQQZ5BOG.mjs.map +7 -0
  81. package/dist/lib/node-esm/{settings-EDK6WI3V.mjs → settings-KXYUZBLN.mjs} +3 -3
  82. package/dist/lib/node-esm/{spaces-ready-CH3W7OGN.mjs → spaces-ready-MWNP3WBX.mjs} +31 -32
  83. package/dist/lib/node-esm/spaces-ready-MWNP3WBX.mjs.map +7 -0
  84. package/dist/lib/node-esm/{state-BMISGQ2O.mjs → state-5GH2D5U4.mjs} +3 -3
  85. package/dist/lib/node-esm/types/index.mjs +2 -2
  86. package/dist/types/src/SpacePlugin.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/app-graph-builder.d.ts +22 -22
  88. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/capabilities.d.ts +6 -0
  90. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  91. package/dist/types/src/capabilities/index.d.ts +33 -33
  92. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  93. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  94. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  95. package/dist/types/src/capabilities/spaces-ready.d.ts.map +1 -1
  96. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts +4 -3
  97. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts.map +1 -1
  98. package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts.map +1 -1
  99. package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
  100. package/dist/types/src/components/SpacePresence.d.ts.map +1 -1
  101. package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts.map +1 -1
  102. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts.map +1 -1
  103. package/dist/types/src/components/SyncStatus/SyncStatus.d.ts.map +1 -1
  104. package/dist/types/src/meta.d.ts +1 -0
  105. package/dist/types/src/meta.d.ts.map +1 -1
  106. package/dist/types/src/types/types.d.ts +2 -2
  107. package/dist/types/src/types/types.d.ts.map +1 -1
  108. package/dist/types/src/util.d.ts.map +1 -1
  109. package/package.json +38 -37
  110. package/src/SpacePlugin.tsx +4 -5
  111. package/src/capabilities/app-graph-builder.ts +4 -2
  112. package/src/capabilities/capabilities.ts +4 -1
  113. package/src/capabilities/intent-resolver.ts +373 -304
  114. package/src/capabilities/react-surface.tsx +22 -30
  115. package/src/capabilities/spaces-ready.ts +20 -21
  116. package/src/components/AwaitingObject.tsx +5 -5
  117. package/src/components/CreateDialog/CreateObjectDialog.tsx +15 -15
  118. package/src/components/CreateDialog/CreateObjectPanel.tsx +114 -114
  119. package/src/components/CreateDialog/CreateSpaceDialog.tsx +10 -8
  120. package/src/components/JoinDialog.tsx +27 -19
  121. package/src/components/SpacePluginSettings.tsx +3 -3
  122. package/src/components/SpacePresence.tsx +2 -3
  123. package/src/components/SpaceSettings/SpaceSettingsDialog.tsx +16 -1
  124. package/src/components/SpaceSettings/SpaceSettingsPanel.tsx +3 -4
  125. package/src/components/SyncStatus/InlineSyncStatus.tsx +2 -2
  126. package/src/components/SyncStatus/SyncStatus.tsx +2 -1
  127. package/src/meta.ts +1 -0
  128. package/src/types/types.ts +2 -3
  129. package/src/util.tsx +8 -4
  130. package/dist/lib/browser/chunk-IZ7QKQ2E.mjs.map +0 -7
  131. package/dist/lib/browser/chunk-SSJ772GK.mjs.map +0 -7
  132. package/dist/lib/browser/chunk-UH5P4UL3.mjs.map +0 -7
  133. package/dist/lib/browser/chunk-XXD33C4E.mjs.map +0 -7
  134. package/dist/lib/browser/intent-resolver-XRZYCXXX.mjs +0 -459
  135. package/dist/lib/browser/intent-resolver-XRZYCXXX.mjs.map +0 -7
  136. package/dist/lib/browser/react-surface-EGOL2JBL.mjs.map +0 -7
  137. package/dist/lib/browser/spaces-ready-WVU7US3C.mjs.map +0 -7
  138. package/dist/lib/node/chunk-56NGXG2A.cjs.map +0 -7
  139. package/dist/lib/node/chunk-5D4RWKTV.cjs.map +0 -7
  140. package/dist/lib/node/chunk-AJRP7AD6.cjs.map +0 -7
  141. package/dist/lib/node/chunk-YCBBGTFD.cjs.map +0 -7
  142. package/dist/lib/node/intent-resolver-3NI6AUAI.cjs +0 -458
  143. package/dist/lib/node/intent-resolver-3NI6AUAI.cjs.map +0 -7
  144. package/dist/lib/node/react-surface-75KRPQYT.cjs.map +0 -7
  145. package/dist/lib/node/spaces-ready-ILVGUHJH.cjs.map +0 -7
  146. package/dist/lib/node-esm/chunk-375RB3CZ.mjs.map +0 -7
  147. package/dist/lib/node-esm/chunk-5QMAPAZD.mjs.map +0 -7
  148. package/dist/lib/node-esm/chunk-GVOPDPS2.mjs.map +0 -7
  149. package/dist/lib/node-esm/chunk-HTBGWQEU.mjs.map +0 -7
  150. package/dist/lib/node-esm/intent-resolver-P5EVBOGP.mjs +0 -460
  151. package/dist/lib/node-esm/intent-resolver-P5EVBOGP.mjs.map +0 -7
  152. package/dist/lib/node-esm/react-surface-7EVWCKIP.mjs.map +0 -7
  153. package/dist/lib/node-esm/spaces-ready-CH3W7OGN.mjs.map +0 -7
  154. /package/dist/lib/browser/{app-graph-serializer-FYJE23GN.mjs.map → app-graph-serializer-QF7VVRCV.mjs.map} +0 -0
  155. /package/dist/lib/browser/{chunk-T36CIHPG.mjs.map → chunk-SDK7RZI3.mjs.map} +0 -0
  156. /package/dist/lib/browser/{identity-created-4Q4PFIC5.mjs.map → identity-created-25TK5XNO.mjs.map} +0 -0
  157. /package/dist/lib/browser/{react-root-BDOPFJGJ.mjs.map → react-root-6VRPRLQR.mjs.map} +0 -0
  158. /package/dist/lib/browser/{settings-WF67QZSD.mjs.map → settings-K4JPYYEM.mjs.map} +0 -0
  159. /package/dist/lib/browser/{state-MS4KYJWI.mjs.map → state-6DCY5YJP.mjs.map} +0 -0
  160. /package/dist/lib/node/{app-graph-serializer-RMTU5YSC.cjs.map → app-graph-serializer-QE2G4MWB.cjs.map} +0 -0
  161. /package/dist/lib/node/{chunk-UENH2YBM.cjs.map → chunk-D6BFKOXY.cjs.map} +0 -0
  162. /package/dist/lib/node/{identity-created-QQWX7WX3.cjs.map → identity-created-7G5U7R36.cjs.map} +0 -0
  163. /package/dist/lib/node/{react-root-ZTR2J2I3.cjs.map → react-root-YD35W3VU.cjs.map} +0 -0
  164. /package/dist/lib/node/{settings-KOVSPA3S.cjs.map → settings-TEELGWS4.cjs.map} +0 -0
  165. /package/dist/lib/node/{state-4UIOUKLJ.cjs.map → state-WPZC4JXB.cjs.map} +0 -0
  166. /package/dist/lib/node-esm/{app-graph-serializer-UWWS5OVC.mjs.map → app-graph-serializer-HLX2JRNF.mjs.map} +0 -0
  167. /package/dist/lib/node-esm/{chunk-E5DWIQ3N.mjs.map → chunk-4UX5WGKJ.mjs.map} +0 -0
  168. /package/dist/lib/node-esm/{identity-created-HMNY2MPB.mjs.map → identity-created-7THGZ7EW.mjs.map} +0 -0
  169. /package/dist/lib/node-esm/{react-root-OUPJA4RY.mjs.map → react-root-Q5MFDXZE.mjs.map} +0 -0
  170. /package/dist/lib/node-esm/{settings-EDK6WI3V.mjs.map → settings-KXYUZBLN.mjs.map} +0 -0
  171. /package/dist/lib/node-esm/{state-BMISGQ2O.mjs.map → state-5GH2D5U4.mjs.map} +0 -0
@@ -7,16 +7,14 @@ import {
7
7
  contributes,
8
8
  createIntent,
9
9
  createResolver,
10
- firstIdInPart,
11
10
  LayoutAction,
12
- NavigationAction,
13
- openIds,
14
11
  type PluginsContext,
15
12
  } from '@dxos/app-framework';
16
13
  import { type Expando, getTypename, type HasId } from '@dxos/echo-schema';
17
14
  import { invariant } from '@dxos/invariant';
18
15
  import { create, makeRef, type ReactiveObject } from '@dxos/live-object';
19
16
  import { Migrations } from '@dxos/migrations';
17
+ import { AttentionCapabilities } from '@dxos/plugin-attention';
20
18
  import { ClientCapabilities } from '@dxos/plugin-client';
21
19
  import { ObservabilityAction } from '@dxos/plugin-observability/types';
22
20
  import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
@@ -51,77 +49,92 @@ export default ({ createInvitationUrl, context }: IntentResolverOptions) => {
51
49
  context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {};
52
50
 
53
51
  return contributes(Capabilities.IntentResolver, [
54
- createResolver(SpaceAction.OpenCreateSpace, () => ({
55
- intents: [
56
- createIntent(LayoutAction.SetLayout, {
57
- element: 'dialog',
58
- component: CREATE_SPACE_DIALOG,
59
- dialogBlockAlign: 'start',
60
- }),
61
- ],
62
- })),
63
- createResolver(SpaceAction.Create, async ({ name, edgeReplication }) => {
64
- const client = context.requestCapability(ClientCapabilities.Client);
65
- const space = await client.spaces.create({ name });
66
- if (edgeReplication) {
67
- await space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED);
68
- }
69
- await space.waitUntilReady();
70
- const collection = create(CollectionType, { objects: [], views: {} });
71
- space.properties[CollectionType.typename] = makeRef(collection);
52
+ createResolver({
53
+ intent: SpaceAction.OpenCreateSpace,
54
+ resolve: () => ({
55
+ intents: [
56
+ createIntent(LayoutAction.UpdateDialog, {
57
+ part: 'dialog',
58
+ subject: CREATE_SPACE_DIALOG,
59
+ options: {
60
+ blockAlign: 'start',
61
+ },
62
+ }),
63
+ ],
64
+ }),
65
+ }),
66
+ createResolver({
67
+ intent: SpaceAction.Create,
68
+ resolve: async ({ name, edgeReplication }) => {
69
+ const client = context.requestCapability(ClientCapabilities.Client);
70
+ const space = await client.spaces.create({ name });
71
+ if (edgeReplication) {
72
+ await space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED);
73
+ }
74
+ await space.waitUntilReady();
75
+ const collection = create(CollectionType, { objects: [], views: {} });
76
+ space.properties[CollectionType.typename] = makeRef(collection);
72
77
 
73
- if (Migrations.versionProperty) {
74
- space.properties[Migrations.versionProperty] = Migrations.targetVersion;
75
- }
78
+ if (Migrations.versionProperty) {
79
+ space.properties[Migrations.versionProperty] = Migrations.targetVersion;
80
+ }
76
81
 
77
- return {
78
- data: {
79
- space,
80
- id: space.id,
81
- activeParts: { main: [space.id] },
82
- },
82
+ return {
83
+ data: {
84
+ id: space.id,
85
+ subject: [space.id],
86
+ space,
87
+ },
88
+ intents: [
89
+ createIntent(ObservabilityAction.SendEvent, {
90
+ name: 'space.create',
91
+ properties: {
92
+ spaceId: space.id,
93
+ },
94
+ }),
95
+ ],
96
+ };
97
+ },
98
+ }),
99
+ createResolver({
100
+ intent: SpaceAction.Join,
101
+ resolve: ({ invitationCode }) => ({
83
102
  intents: [
84
- createIntent(ObservabilityAction.SendEvent, {
85
- name: 'space.create',
86
- properties: {
87
- spaceId: space.id,
103
+ createIntent(LayoutAction.UpdateDialog, {
104
+ part: 'dialog',
105
+ subject: JOIN_DIALOG,
106
+ options: {
107
+ blockAlign: 'start',
108
+ props: {
109
+ initialInvitationCode: invitationCode,
110
+ } satisfies Partial<JoinDialogProps>,
88
111
  },
89
112
  }),
90
113
  ],
91
- };
114
+ }),
92
115
  }),
93
- createResolver(SpaceAction.Join, ({ invitationCode }) => ({
94
- intents: [
95
- createIntent(LayoutAction.SetLayout, {
96
- element: 'dialog',
97
- component: JOIN_DIALOG,
98
- dialogBlockAlign: 'start',
99
- subject: {
100
- initialInvitationCode: invitationCode,
101
- } satisfies Partial<JoinDialogProps>,
102
- }),
103
- ],
104
- })),
105
- createResolver(
106
- SpaceAction.Share,
107
- ({ space }) => {
108
- const location = context.requestCapability(Capabilities.Location);
109
- const layout = context.requestCapability(Capabilities.Layout);
110
- const current = firstIdInPart(location.active, layout.layoutMode === 'solo' ? 'solo' : 'main');
116
+ createResolver({
117
+ intent: SpaceAction.Share,
118
+ filter: (data): data is { space: Space } => !data.space.properties[COMPOSER_SPACE_LOCK],
119
+ resolve: ({ space }) => {
120
+ const attention = context.requestCapability(AttentionCapabilities.Attention);
121
+ const current = attention.current.at(-1);
111
122
  const target = current?.startsWith(space.id) ? current : undefined;
112
123
 
113
124
  return {
114
125
  intents: [
115
- createIntent(LayoutAction.SetLayout, {
116
- element: 'dialog',
117
- component: SPACE_SETTINGS_DIALOG,
118
- dialogBlockAlign: 'start',
119
- subject: {
120
- space,
121
- target,
122
- initialTab: 'members',
123
- createInvitationUrl,
124
- } satisfies Partial<SpaceSettingsDialogProps>,
126
+ createIntent(LayoutAction.UpdateDialog, {
127
+ part: 'dialog',
128
+ subject: SPACE_SETTINGS_DIALOG,
129
+ options: {
130
+ blockAlign: 'start',
131
+ props: {
132
+ space,
133
+ target,
134
+ initialTab: 'members',
135
+ createInvitationUrl,
136
+ } satisfies Partial<SpaceSettingsDialogProps>,
137
+ },
125
138
  }),
126
139
  createIntent(ObservabilityAction.SendEvent, {
127
140
  name: 'space.share',
@@ -132,289 +145,345 @@ export default ({ createInvitationUrl, context }: IntentResolverOptions) => {
132
145
  ],
133
146
  };
134
147
  },
135
- { filter: (data): data is { space: Space } => !data.space.properties[COMPOSER_SPACE_LOCK] },
136
- ),
137
- createResolver(SpaceAction.Lock, ({ space }) => {
138
- space.properties[COMPOSER_SPACE_LOCK] = true;
139
- return {
140
- intents: [
141
- createIntent(ObservabilityAction.SendEvent, {
142
- name: 'space.lock',
143
- properties: {
144
- spaceId: space.id,
145
- },
146
- }),
147
- ],
148
- };
149
- }),
150
- createResolver(SpaceAction.Unlock, ({ space }) => {
151
- space.properties[COMPOSER_SPACE_LOCK] = false;
152
- return {
153
- intents: [
154
- createIntent(ObservabilityAction.SendEvent, {
155
- name: 'space.unlock',
156
- properties: {
157
- spaceId: space.id,
158
- },
159
- }),
160
- ],
161
- };
162
148
  }),
163
- createResolver(SpaceAction.Rename, ({ caller, space }) => {
164
- return {
165
- intents: [
166
- createIntent(LayoutAction.SetLayout, {
167
- element: 'popover',
168
- anchorId: `dxos.org/ui/${caller}/${space.id}`,
169
- component: POPOVER_RENAME_SPACE,
170
- subject: space,
171
- }),
172
- ],
173
- };
149
+ createResolver({
150
+ intent: SpaceAction.Lock,
151
+ resolve: ({ space }) => {
152
+ space.properties[COMPOSER_SPACE_LOCK] = true;
153
+ return {
154
+ intents: [
155
+ createIntent(ObservabilityAction.SendEvent, {
156
+ name: 'space.lock',
157
+ properties: {
158
+ spaceId: space.id,
159
+ },
160
+ }),
161
+ ],
162
+ };
163
+ },
174
164
  }),
175
- createResolver(SpaceAction.OpenSettings, ({ space }) => {
176
- return {
177
- intents: [
178
- createIntent(LayoutAction.SetLayout, {
179
- element: 'dialog',
180
- component: SPACE_SETTINGS_DIALOG,
181
- dialogBlockAlign: 'start',
182
- subject: {
183
- space,
184
- initialTab: 'settings',
185
- createInvitationUrl,
186
- } satisfies Partial<SpaceSettingsDialogProps>,
187
- }),
188
- ],
189
- };
165
+ createResolver({
166
+ intent: SpaceAction.Unlock,
167
+ resolve: ({ space }) => {
168
+ space.properties[COMPOSER_SPACE_LOCK] = false;
169
+ return {
170
+ intents: [
171
+ createIntent(ObservabilityAction.SendEvent, {
172
+ name: 'space.unlock',
173
+ properties: {
174
+ spaceId: space.id,
175
+ },
176
+ }),
177
+ ],
178
+ };
179
+ },
190
180
  }),
191
- createResolver(SpaceAction.Open, async ({ space }) => {
192
- await space.open();
181
+ createResolver({
182
+ intent: SpaceAction.Rename,
183
+ resolve: ({ caller, space }) => {
184
+ return {
185
+ intents: [
186
+ createIntent(LayoutAction.UpdatePopover, {
187
+ part: 'popover',
188
+ subject: POPOVER_RENAME_SPACE,
189
+ options: {
190
+ anchorId: `dxos.org/ui/${caller}/${space.id}`,
191
+ props: space,
192
+ },
193
+ }),
194
+ ],
195
+ };
196
+ },
193
197
  }),
194
- createResolver(SpaceAction.Close, async ({ space }) => {
195
- await space.close();
198
+ createResolver({
199
+ intent: SpaceAction.OpenSettings,
200
+ resolve: ({ space }) => {
201
+ return {
202
+ intents: [
203
+ createIntent(LayoutAction.UpdateDialog, {
204
+ part: 'dialog',
205
+ subject: SPACE_SETTINGS_DIALOG,
206
+ options: {
207
+ blockAlign: 'start',
208
+ props: {
209
+ space,
210
+ initialTab: 'settings',
211
+ createInvitationUrl,
212
+ } satisfies Partial<SpaceSettingsDialogProps>,
213
+ },
214
+ }),
215
+ ],
216
+ };
217
+ },
196
218
  }),
197
- createResolver(SpaceAction.Migrate, async ({ space, version }) => {
198
- const state = context.requestCapability(SpaceCapabilities.MutableState);
199
-
200
- if (space.state.get() === SpaceState.SPACE_REQUIRES_MIGRATION) {
201
- state.sdkMigrationRunning[space.id] = true;
202
- await space.internal.migrate();
203
- state.sdkMigrationRunning[space.id] = false;
204
- }
205
- const result = await Migrations.migrate(space, version);
206
- return {
207
- data: result,
208
- intents: [
209
- createIntent(ObservabilityAction.SendEvent, {
210
- name: 'space.migrate',
211
- properties: {
212
- spaceId: space.id,
213
- version,
214
- },
215
- }),
216
- ],
217
- };
219
+ createResolver({
220
+ intent: SpaceAction.Open,
221
+ resolve: async ({ space }) => {
222
+ await space.open();
223
+ },
218
224
  }),
219
- createResolver(SpaceAction.OpenCreateObject, ({ target, navigable = true }) => {
220
- const state = context.requestCapability(SpaceCapabilities.State);
221
-
222
- return {
223
- intents: [
224
- createIntent(LayoutAction.SetLayout, {
225
- element: 'dialog',
226
- component: CREATE_OBJECT_DIALOG,
227
- dialogBlockAlign: 'start',
228
- subject: {
229
- target,
230
- shouldNavigate: navigable
231
- ? (object: ReactiveObject<any>) => !(object instanceof CollectionType) || state.navigableCollections
232
- : () => false,
233
- } satisfies Partial<CreateObjectDialogProps>,
234
- }),
235
- ],
236
- };
225
+ createResolver({
226
+ intent: SpaceAction.Close,
227
+ resolve: async ({ space }) => {
228
+ await space.close();
229
+ },
237
230
  }),
238
- createResolver(SpaceAction.AddObject, async ({ target, object }) => {
239
- const space = isSpace(target) ? target : getSpace(target);
240
- invariant(space, 'Space not found.');
231
+ createResolver({
232
+ intent: SpaceAction.Migrate,
233
+ resolve: async ({ space, version }) => {
234
+ const state = context.requestCapability(SpaceCapabilities.MutableState);
241
235
 
242
- if (space.db.coreDatabase.getAllObjectIds().length >= SPACE_MAX_OBJECTS) {
236
+ if (space.state.get() === SpaceState.SPACE_REQUIRES_MIGRATION) {
237
+ state.sdkMigrationRunning[space.id] = true;
238
+ await space.internal.migrate();
239
+ state.sdkMigrationRunning[space.id] = false;
240
+ }
241
+ const result = await Migrations.migrate(space, version);
243
242
  return {
244
- error: new Error('Space limit reached.'),
243
+ data: result,
245
244
  intents: [
246
- createIntent(LayoutAction.SetLayout, {
247
- element: 'toast',
248
- subject: {
249
- id: `${SPACE_PLUGIN}/space-limit`,
250
- title: ['space limit label', { ns: SPACE_PLUGIN }],
251
- description: ['space limit description', { ns: SPACE_PLUGIN }],
252
- duration: 5_000,
253
- icon: 'ph--warning--regular',
254
- actionLabel: ['remove deleted objects label', { ns: SPACE_PLUGIN }],
255
- actionAlt: ['remove deleted objects alt', { ns: SPACE_PLUGIN }],
256
- closeLabel: ['close label', { ns: 'os' }],
257
- onAction: () => space.db.coreDatabase.unlinkDeletedObjects(),
258
- },
259
- }),
260
245
  createIntent(ObservabilityAction.SendEvent, {
261
- name: 'space.limit',
246
+ name: 'space.migrate',
262
247
  properties: {
263
248
  spaceId: space.id,
249
+ version,
264
250
  },
265
251
  }),
266
252
  ],
267
253
  };
268
- }
269
-
270
- if (target instanceof CollectionType) {
271
- target.objects.push(makeRef(object as HasId));
272
- } else if (isSpace(target)) {
273
- const collection = space.properties[CollectionType.typename]?.target;
274
- if (collection instanceof CollectionType) {
275
- collection.objects.push(makeRef(object as HasId));
276
- } else {
277
- // TODO(wittjosiah): Can't add non-echo objects by including in a collection because of types.
278
- const collection = create(CollectionType, { objects: [makeRef(object as HasId)], views: {} });
279
- space.properties[CollectionType.typename] = makeRef(collection);
280
- }
281
- }
282
-
283
- return {
284
- data: {
285
- id: fullyQualifiedId(object),
286
- object: object as HasId,
287
- activeParts: { main: [fullyQualifiedId(object)] },
288
- },
289
- intents: [
290
- createIntent(ObservabilityAction.SendEvent, {
291
- name: 'space.object.add',
292
- properties: {
293
- spaceId: space.id,
294
- objectId: object.id,
295
- typename: getTypename(object),
296
- },
297
- }),
298
- ],
299
- };
254
+ },
300
255
  }),
301
- createResolver(SpaceAction.RemoveObjects, async ({ objects, target, deletionData }, undo) => {
302
- const location = context.requestCapability(Capabilities.Location);
303
-
304
- // All objects must be a member of the same space.
305
- const space = getSpace(objects[0]);
306
- invariant(space && objects.every((obj) => isEchoObject(obj) && getSpace(obj) === space));
307
- const openObjectIds = new Set<string>(openIds(location.active));
256
+ createResolver({
257
+ intent: SpaceAction.OpenCreateObject,
258
+ resolve: ({ target, navigable = true }) => {
259
+ const state = context.requestCapability(SpaceCapabilities.State);
308
260
 
309
- if (!undo) {
310
- const parentCollection: CollectionType = target ?? space.properties[CollectionType.typename]?.target;
311
- const nestedObjectsList = await Promise.all(objects.map((obj) => getNestedObjects(obj, resolve)));
312
-
313
- const deletionData = {
314
- objects,
315
- parentCollection,
316
- indices: objects.map((obj) =>
317
- parentCollection instanceof CollectionType
318
- ? parentCollection.objects.findIndex((object) => object.target === obj)
319
- : -1,
320
- ),
321
- nestedObjectsList,
322
- wasActive: objects
323
- .flatMap((obj, i) => [obj, ...nestedObjectsList[i]])
324
- .map((obj) => fullyQualifiedId(obj))
325
- .filter((id) => openObjectIds.has(id)),
326
- } satisfies SpaceAction.DeletionData;
261
+ return {
262
+ intents: [
263
+ createIntent(LayoutAction.UpdateDialog, {
264
+ part: 'dialog',
265
+ subject: CREATE_OBJECT_DIALOG,
266
+ options: {
267
+ blockAlign: 'start',
268
+ props: {
269
+ target,
270
+ shouldNavigate: navigable
271
+ ? (object: ReactiveObject<any>) => !(object instanceof CollectionType) || state.navigableCollections
272
+ : () => false,
273
+ } satisfies Partial<CreateObjectDialogProps>,
274
+ },
275
+ }),
276
+ ],
277
+ };
278
+ },
279
+ }),
280
+ createResolver({
281
+ intent: SpaceAction.AddObject,
282
+ resolve: async ({ target, object }) => {
283
+ const space = isSpace(target) ? target : getSpace(target);
284
+ invariant(space, 'Space not found.');
327
285
 
328
- if (deletionData.parentCollection instanceof CollectionType) {
329
- [...deletionData.indices]
330
- .sort((a, b) => b - a)
331
- .forEach((index: number) => {
332
- if (index !== -1) {
333
- deletionData.parentCollection.objects.splice(index, 1);
334
- }
335
- });
286
+ if (space.db.coreDatabase.getAllObjectIds().length >= SPACE_MAX_OBJECTS) {
287
+ return {
288
+ error: new Error('Space limit reached.'),
289
+ intents: [
290
+ createIntent(LayoutAction.AddToast, {
291
+ part: 'toast',
292
+ subject: {
293
+ id: `${SPACE_PLUGIN}/space-limit`,
294
+ title: ['space limit label', { ns: SPACE_PLUGIN }],
295
+ description: ['space limit description', { ns: SPACE_PLUGIN }],
296
+ duration: 5_000,
297
+ icon: 'ph--warning--regular',
298
+ actionLabel: ['remove deleted objects label', { ns: SPACE_PLUGIN }],
299
+ actionAlt: ['remove deleted objects alt', { ns: SPACE_PLUGIN }],
300
+ closeLabel: ['close label', { ns: 'os' }],
301
+ onAction: () => space.db.coreDatabase.unlinkDeletedObjects(),
302
+ },
303
+ }),
304
+ createIntent(ObservabilityAction.SendEvent, {
305
+ name: 'space.limit',
306
+ properties: {
307
+ spaceId: space.id,
308
+ },
309
+ }),
310
+ ],
311
+ };
336
312
  }
337
313
 
338
- deletionData.nestedObjectsList.flat().forEach((obj) => {
339
- space.db.remove(obj);
340
- });
341
- objects.forEach((obj) => space.db.remove(obj));
342
-
343
- const undoMessageKey = objects.some((obj) => obj instanceof CollectionType)
344
- ? 'collection deleted label'
345
- : objects.length > 1
346
- ? 'objects deleted label'
347
- : 'object deleted label';
314
+ if (target instanceof CollectionType) {
315
+ target.objects.push(makeRef(object as HasId));
316
+ } else if (isSpace(target)) {
317
+ const collection = space.properties[CollectionType.typename]?.target;
318
+ if (collection instanceof CollectionType) {
319
+ collection.objects.push(makeRef(object as HasId));
320
+ } else {
321
+ // TODO(wittjosiah): Can't add non-echo objects by including in a collection because of types.
322
+ const collection = create(CollectionType, { objects: [makeRef(object as HasId)], views: {} });
323
+ space.properties[CollectionType.typename] = makeRef(collection);
324
+ }
325
+ }
348
326
 
349
327
  return {
350
- undoable: {
351
- // TODO(ZaymonFC): Pluralize if more than one object.
352
- message: [undoMessageKey, { ns: SPACE_PLUGIN }],
353
- data: { deletionData },
328
+ data: {
329
+ id: fullyQualifiedId(object),
330
+ subject: [fullyQualifiedId(object)],
331
+ object: object as HasId,
354
332
  },
355
- intents:
356
- deletionData.wasActive.length > 0
357
- ? [createIntent(NavigationAction.Close, { activeParts: { main: deletionData.wasActive } })]
358
- : undefined,
333
+ intents: [
334
+ createIntent(ObservabilityAction.SendEvent, {
335
+ name: 'space.object.add',
336
+ properties: {
337
+ spaceId: space.id,
338
+ objectId: object.id,
339
+ typename: getTypename(object),
340
+ },
341
+ }),
342
+ ],
359
343
  };
360
- } else {
361
- if (
362
- deletionData?.objects?.length &&
363
- deletionData.objects.every(isEchoObject) &&
364
- deletionData.parentCollection instanceof CollectionType
365
- ) {
366
- // Restore the object to the space.
367
- const restoredObjects = deletionData.objects.map((obj: Expando) => space.db.add(obj));
344
+ },
345
+ }),
346
+ createResolver({
347
+ intent: SpaceAction.RemoveObjects,
348
+ resolve: async ({ objects, target, deletionData }, undo) => {
349
+ const layout = context.requestCapability(Capabilities.Layout);
368
350
 
369
- // Restore nested objects to the space.
370
- deletionData.nestedObjectsList.flat().forEach((obj: Expando) => {
371
- space.db.add(obj);
372
- });
351
+ // All objects must be a member of the same space.
352
+ const space = getSpace(objects[0]);
353
+ invariant(space && objects.every((obj) => isEchoObject(obj) && getSpace(obj) === space));
354
+ const openObjectIds = new Set<string>(layout.active);
355
+
356
+ if (!undo) {
357
+ const parentCollection: CollectionType = target ?? space.properties[CollectionType.typename]?.target;
358
+ const nestedObjectsList = await Promise.all(objects.map((obj) => getNestedObjects(obj, resolve)));
359
+
360
+ const deletionData = {
361
+ objects,
362
+ parentCollection,
363
+ indices: objects.map((obj) =>
364
+ parentCollection instanceof CollectionType
365
+ ? parentCollection.objects.findIndex((object) => object.target === obj)
366
+ : -1,
367
+ ),
368
+ nestedObjectsList,
369
+ wasActive: objects
370
+ .flatMap((obj, i) => [obj, ...nestedObjectsList[i]])
371
+ .map((obj) => fullyQualifiedId(obj))
372
+ .filter((id) => openObjectIds.has(id)),
373
+ } satisfies SpaceAction.DeletionData;
373
374
 
374
- deletionData.indices.forEach((index: number, i: number) => {
375
- if (index !== -1) {
376
- deletionData.parentCollection.objects.splice(index, 0, makeRef(restoredObjects[i] as Expando));
377
- }
375
+ if (deletionData.parentCollection instanceof CollectionType) {
376
+ [...deletionData.indices]
377
+ .sort((a, b) => b - a)
378
+ .forEach((index: number) => {
379
+ if (index !== -1) {
380
+ deletionData.parentCollection.objects.splice(index, 1);
381
+ }
382
+ });
383
+ }
384
+
385
+ deletionData.nestedObjectsList.flat().forEach((obj) => {
386
+ space.db.remove(obj);
378
387
  });
388
+ objects.forEach((obj) => space.db.remove(obj));
389
+
390
+ const undoMessageKey = objects.some((obj) => obj instanceof CollectionType)
391
+ ? 'collection deleted label'
392
+ : objects.length > 1
393
+ ? 'objects deleted label'
394
+ : 'object deleted label';
379
395
 
380
396
  return {
397
+ undoable: {
398
+ // TODO(ZaymonFC): Pluralize if more than one object.
399
+ message: [undoMessageKey, { ns: SPACE_PLUGIN }],
400
+ data: { deletionData },
401
+ },
381
402
  intents:
382
403
  deletionData.wasActive.length > 0
383
404
  ? [
384
- createIntent(NavigationAction.Open, {
385
- activeParts: { main: deletionData.wasActive as string[] },
405
+ createIntent(LayoutAction.Close, {
406
+ part: 'main',
407
+ subject: deletionData.wasActive,
408
+ options: { state: false },
386
409
  }),
387
410
  ]
388
411
  : undefined,
389
412
  };
413
+ } else {
414
+ if (
415
+ deletionData?.objects?.length &&
416
+ deletionData.objects.every(isEchoObject) &&
417
+ deletionData.parentCollection instanceof CollectionType
418
+ ) {
419
+ // Restore the object to the space.
420
+ const restoredObjects = deletionData.objects.map((obj: Expando) => space.db.add(obj));
421
+
422
+ // Restore nested objects to the space.
423
+ deletionData.nestedObjectsList.flat().forEach((obj: Expando) => {
424
+ space.db.add(obj);
425
+ });
426
+
427
+ deletionData.indices.forEach((index: number, i: number) => {
428
+ if (index !== -1) {
429
+ deletionData.parentCollection.objects.splice(index, 0, makeRef(restoredObjects[i] as Expando));
430
+ }
431
+ });
432
+
433
+ return {
434
+ intents:
435
+ deletionData.wasActive.length > 0
436
+ ? [
437
+ createIntent(LayoutAction.Open, {
438
+ part: 'main',
439
+ subject: deletionData.wasActive,
440
+ }),
441
+ ]
442
+ : undefined,
443
+ };
444
+ }
390
445
  }
391
- }
446
+ },
447
+ }),
448
+ createResolver({
449
+ intent: SpaceAction.RenameObject,
450
+ resolve: async ({ object, caller }) => ({
451
+ intents: [
452
+ createIntent(LayoutAction.UpdatePopover, {
453
+ part: 'popover',
454
+ subject: POPOVER_RENAME_OBJECT,
455
+ options: {
456
+ anchorId: `dxos.org/ui/${caller}/${fullyQualifiedId(object)}`,
457
+ props: object,
458
+ },
459
+ }),
460
+ ],
461
+ }),
392
462
  }),
393
- createResolver(SpaceAction.RenameObject, async ({ object, caller }) => ({
394
- intents: [
395
- createIntent(LayoutAction.SetLayout, {
396
- element: 'popover',
397
- anchorId: `dxos.org/ui/${caller}/${fullyQualifiedId(object)}`,
398
- component: POPOVER_RENAME_OBJECT,
399
- subject: object,
400
- }),
401
- ],
402
- })),
403
- createResolver(SpaceAction.DuplicateObject, async ({ object, target }) => {
404
- const space = isSpace(target) ? target : getSpace(target);
405
- invariant(space, 'Space not found.');
463
+ createResolver({
464
+ intent: SpaceAction.DuplicateObject,
465
+ resolve: async ({ object, target }) => {
466
+ const space = isSpace(target) ? target : getSpace(target);
467
+ invariant(space, 'Space not found.');
406
468
 
407
- const newObject = await cloneObject(object, resolve, space);
408
- return {
409
- intents: [createIntent(SpaceAction.AddObject, { object: newObject, target })],
410
- };
469
+ const newObject = await cloneObject(object, resolve, space);
470
+ return {
471
+ intents: [createIntent(SpaceAction.AddObject, { object: newObject, target })],
472
+ };
473
+ },
474
+ }),
475
+ createResolver({
476
+ intent: SpaceAction.WaitForObject,
477
+ resolve: async ({ id }) => {
478
+ const state = context.requestCapability(SpaceCapabilities.MutableState);
479
+ state.awaiting = id;
480
+ },
411
481
  }),
412
- createResolver(SpaceAction.WaitForObject, async ({ id }) => {
413
- const state = context.requestCapability(SpaceCapabilities.MutableState);
414
- state.awaiting = id;
482
+ createResolver({
483
+ intent: CollectionAction.Create,
484
+ resolve: async ({ name }) => ({
485
+ data: { object: create(CollectionType, { name, objects: [], views: {} }) },
486
+ }),
415
487
  }),
416
- createResolver(CollectionAction.Create, async ({ name }) => ({
417
- data: { object: create(CollectionType, { name, objects: [], views: {} }) },
418
- })),
419
488
  ]);
420
489
  };