@dxos/plugin-space 0.7.4 → 0.7.5-main.937ce75

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 (120) hide show
  1. package/dist/lib/browser/chunk-54VE4GTA.mjs +315 -0
  2. package/dist/lib/browser/chunk-54VE4GTA.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-73BCBSLP.mjs +15 -0
  4. package/dist/lib/browser/chunk-73BCBSLP.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +928 -962
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/meta.mjs +1 -5
  9. package/dist/lib/browser/types/index.mjs +8 -1
  10. package/dist/lib/node/chunk-46S3JOES.cjs +39 -0
  11. package/dist/lib/node/chunk-46S3JOES.cjs.map +7 -0
  12. package/dist/lib/node/chunk-YF2AQ7KP.cjs +343 -0
  13. package/dist/lib/node/chunk-YF2AQ7KP.cjs.map +7 -0
  14. package/dist/lib/node/index.cjs +1053 -1086
  15. package/dist/lib/node/index.cjs.map +4 -4
  16. package/dist/lib/node/meta.cjs +5 -9
  17. package/dist/lib/node/meta.cjs.map +2 -2
  18. package/dist/lib/node/meta.json +1 -1
  19. package/dist/lib/node/types/index.cjs +19 -12
  20. package/dist/lib/node/types/index.cjs.map +2 -2
  21. package/dist/lib/node-esm/chunk-2MNFEB23.mjs +17 -0
  22. package/dist/lib/node-esm/chunk-2MNFEB23.mjs.map +7 -0
  23. package/dist/lib/node-esm/chunk-CDZETPO7.mjs +316 -0
  24. package/dist/lib/node-esm/chunk-CDZETPO7.mjs.map +7 -0
  25. package/dist/lib/node-esm/index.mjs +928 -962
  26. package/dist/lib/node-esm/index.mjs.map +4 -4
  27. package/dist/lib/node-esm/meta.json +1 -1
  28. package/dist/lib/node-esm/meta.mjs +1 -5
  29. package/dist/lib/node-esm/types/index.mjs +8 -1
  30. package/dist/types/src/SpacePlugin.d.ts +2 -2
  31. package/dist/types/src/SpacePlugin.d.ts.map +1 -1
  32. package/dist/types/src/components/AwaitingObject.d.ts.map +1 -1
  33. package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts +4 -2
  34. package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts.map +1 -1
  35. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts +3 -3
  36. package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts.map +1 -1
  37. package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts +1 -0
  38. package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts.map +1 -1
  39. package/dist/types/src/components/JoinDialog.d.ts +1 -0
  40. package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
  41. package/dist/types/src/components/PopoverRenameObject.d.ts +1 -0
  42. package/dist/types/src/components/PopoverRenameObject.d.ts.map +1 -1
  43. package/dist/types/src/components/PopoverRenameSpace.d.ts +1 -0
  44. package/dist/types/src/components/PopoverRenameSpace.d.ts.map +1 -1
  45. package/dist/types/src/components/ShareSpaceButton.d.ts.map +1 -1
  46. package/dist/types/src/components/SpacePluginSettings.d.ts.map +1 -1
  47. package/dist/types/src/components/SpacePresence.d.ts +9 -6
  48. package/dist/types/src/components/SpacePresence.d.ts.map +1 -1
  49. package/dist/types/src/components/SpacePresence.stories.d.ts +1 -1
  50. package/dist/types/src/components/SpacePresence.stories.d.ts.map +1 -1
  51. package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts +1 -0
  52. package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts.map +1 -1
  53. package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.stories.d.ts.map +1 -1
  54. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts +4 -3
  55. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts.map +1 -1
  56. package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.stories.d.ts.map +1 -1
  57. package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts +3 -3
  58. package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts.map +1 -1
  59. package/dist/types/src/components/SyncStatus/SyncStatusDetail.stories.d.ts +2 -2
  60. package/dist/types/src/components/SyncStatus/SyncStatusDetail.stories.d.ts.map +1 -1
  61. package/dist/types/src/hooks/index.d.ts +2 -0
  62. package/dist/types/src/hooks/index.d.ts.map +1 -0
  63. package/dist/types/src/hooks/usePath.d.ts +11 -0
  64. package/dist/types/src/hooks/usePath.d.ts.map +1 -0
  65. package/dist/types/src/meta.d.ts +0 -23
  66. package/dist/types/src/meta.d.ts.map +1 -1
  67. package/dist/types/src/translations.d.ts +6 -3
  68. package/dist/types/src/translations.d.ts.map +1 -1
  69. package/dist/types/src/types/collection.d.ts +8 -12
  70. package/dist/types/src/types/collection.d.ts.map +1 -1
  71. package/dist/types/src/types/thread.d.ts +180 -186
  72. package/dist/types/src/types/thread.d.ts.map +1 -1
  73. package/dist/types/src/types/types.d.ts +234 -4
  74. package/dist/types/src/types/types.d.ts.map +1 -1
  75. package/dist/types/src/util.d.ts +3 -3
  76. package/dist/types/src/util.d.ts.map +1 -1
  77. package/dist/types/tsconfig.tsbuildinfo +1 -0
  78. package/package.json +39 -38
  79. package/src/SpacePlugin.tsx +477 -602
  80. package/src/components/AwaitingObject.tsx +19 -17
  81. package/src/components/CreateDialog/CreateObjectDialog.tsx +33 -22
  82. package/src/components/CreateDialog/CreateObjectPanel.tsx +7 -7
  83. package/src/components/CreateDialog/CreateSpaceDialog.tsx +10 -14
  84. package/src/components/JoinDialog.tsx +18 -34
  85. package/src/components/PersistenceStatus.tsx +1 -1
  86. package/src/components/PopoverRenameObject.tsx +2 -0
  87. package/src/components/PopoverRenameSpace.tsx +2 -0
  88. package/src/components/ShareSpaceButton.tsx +5 -4
  89. package/src/components/SpacePluginSettings.tsx +5 -11
  90. package/src/components/SpacePresence.stories.tsx +25 -17
  91. package/src/components/SpacePresence.tsx +36 -16
  92. package/src/components/SpaceSettings/SpaceSettingsDialog.stories.tsx +2 -3
  93. package/src/components/SpaceSettings/SpaceSettingsDialog.tsx +3 -1
  94. package/src/components/SpaceSettings/SpaceSettingsPanel.stories.tsx +7 -5
  95. package/src/components/SpaceSettings/SpaceSettingsPanel.tsx +6 -5
  96. package/src/components/SyncStatus/InlineSyncStatus.tsx +37 -27
  97. package/src/components/SyncStatus/SyncStatusDetail.stories.tsx +55 -51
  98. package/src/hooks/index.ts +5 -0
  99. package/src/hooks/usePath.ts +44 -0
  100. package/src/meta.ts +0 -26
  101. package/src/translations.ts +3 -2
  102. package/src/types/collection.ts +3 -3
  103. package/src/types/thread.ts +6 -6
  104. package/src/types/types.ts +182 -13
  105. package/src/util.tsx +59 -52
  106. package/dist/lib/browser/chunk-FTKV32QZ.mjs +0 -43
  107. package/dist/lib/browser/chunk-FTKV32QZ.mjs.map +0 -7
  108. package/dist/lib/browser/chunk-MWKXNS5S.mjs +0 -124
  109. package/dist/lib/browser/chunk-MWKXNS5S.mjs.map +0 -7
  110. package/dist/lib/node/chunk-6SNOZF7Y.cjs +0 -152
  111. package/dist/lib/node/chunk-6SNOZF7Y.cjs.map +0 -7
  112. package/dist/lib/node/chunk-QNVEU2UD.cjs +0 -69
  113. package/dist/lib/node/chunk-QNVEU2UD.cjs.map +0 -7
  114. package/dist/lib/node-esm/chunk-OHEAWSCA.mjs +0 -126
  115. package/dist/lib/node-esm/chunk-OHEAWSCA.mjs.map +0 -7
  116. package/dist/lib/node-esm/chunk-UMV7XREB.mjs +0 -45
  117. package/dist/lib/node-esm/chunk-UMV7XREB.mjs.map +0 -7
  118. package/dist/types/src/components/SyncStatus/InlineSyncStatus.stories.d.ts +0 -6
  119. package/dist/types/src/components/SyncStatus/InlineSyncStatus.stories.d.ts.map +0 -1
  120. package/src/components/SyncStatus/InlineSyncStatus.stories.tsx +0 -57
@@ -2,22 +2,26 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import type {
6
- GraphBuilderProvides,
7
- GraphSerializerProvides,
8
- IntentResolverProvides,
9
- MetadataRecordsProvides,
10
- SettingsProvides,
11
- SurfaceProvides,
12
- TranslationsProvides,
13
- Plugin,
5
+ import {
6
+ type GraphBuilderProvides,
7
+ type GraphSerializerProvides,
8
+ type IntentResolverProvides,
9
+ type MetadataRecordsProvides,
10
+ type SettingsProvides,
11
+ type SurfaceProvides,
12
+ type TranslationsProvides,
13
+ type Plugin,
14
+ ActiveParts,
14
15
  } from '@dxos/app-framework';
15
- import { AST, S, type AbstractTypedObject, type Expando } from '@dxos/echo-schema';
16
+ import { AST, S, type TypedObject, type Expando } from '@dxos/echo-schema';
16
17
  import { type PanelProvides } from '@dxos/plugin-deck/types';
17
18
  import { type PublicKey } from '@dxos/react-client';
18
- import { type Space } from '@dxos/react-client/echo';
19
+ import { EchoObjectSchema, ReactiveObjectSchema, type Space, SpaceSchema } from '@dxos/react-client/echo';
19
20
  import { type ComplexMap } from '@dxos/util';
20
21
 
22
+ import { CollectionType } from './collection';
23
+ import { SPACE_PLUGIN } from '../meta';
24
+
21
25
  export const SPACE_DIRECTORY_HANDLE = 'dxos.org/plugin/space/directory';
22
26
 
23
27
  export type ObjectViewerProps = {
@@ -76,8 +80,8 @@ export type SpaceSettingsProps = {
76
80
 
77
81
  export type SchemaProvides = {
78
82
  echo: {
79
- schema?: AbstractTypedObject[];
80
- system?: AbstractTypedObject[];
83
+ schema?: TypedObject[];
84
+ system?: TypedObject[];
81
85
  };
82
86
  };
83
87
 
@@ -115,5 +119,170 @@ export interface TypedObjectSerializer<T extends Expando = Expando> {
115
119
 
116
120
  export const SpaceForm = S.Struct({
117
121
  name: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Name' })),
122
+ // TODO(wittjosiah): Make optional with default value.
118
123
  edgeReplication: S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Enable EDGE Replication' }),
119
124
  });
125
+
126
+ export const SPACE_ACTION = `${SPACE_PLUGIN}/action`;
127
+
128
+ export namespace SpaceAction {
129
+ export class OpenCreateSpace extends S.TaggedClass<OpenCreateSpace>()(`${SPACE_ACTION}/open-create-space`, {
130
+ input: S.Void,
131
+ output: S.Void,
132
+ }) {}
133
+
134
+ export class Create extends S.TaggedClass<Create>()(`${SPACE_ACTION}/create`, {
135
+ input: SpaceForm,
136
+ output: S.Struct({
137
+ id: S.String,
138
+ activeParts: ActiveParts,
139
+ space: SpaceSchema,
140
+ }),
141
+ }) {}
142
+
143
+ export class Join extends S.TaggedClass<Join>()(`${SPACE_ACTION}/join`, {
144
+ input: S.Struct({
145
+ invitationCode: S.optional(S.String),
146
+ onDone: S.optional(S.Any),
147
+ }),
148
+ output: S.Void,
149
+ }) {}
150
+
151
+ export class Share extends S.TaggedClass<Share>()(`${SPACE_ACTION}/share`, {
152
+ input: S.Struct({
153
+ space: SpaceSchema,
154
+ }),
155
+ output: S.Void,
156
+ }) {}
157
+
158
+ export class Lock extends S.TaggedClass<Lock>()(`${SPACE_ACTION}/lock`, {
159
+ input: S.Struct({
160
+ space: SpaceSchema,
161
+ }),
162
+ output: S.Void,
163
+ }) {}
164
+
165
+ export class Unlock extends S.TaggedClass<Unlock>()(`${SPACE_ACTION}/unlock`, {
166
+ input: S.Struct({
167
+ space: SpaceSchema,
168
+ }),
169
+ output: S.Void,
170
+ }) {}
171
+
172
+ export class Rename extends S.TaggedClass<Rename>()(`${SPACE_ACTION}/rename`, {
173
+ input: S.Struct({
174
+ space: SpaceSchema,
175
+ caller: S.optional(S.String),
176
+ }),
177
+ output: S.Void,
178
+ }) {}
179
+
180
+ export class OpenSettings extends S.TaggedClass<OpenSettings>()(`${SPACE_ACTION}/open-settings`, {
181
+ input: S.Struct({
182
+ space: SpaceSchema,
183
+ }),
184
+ output: S.Void,
185
+ }) {}
186
+
187
+ export class Open extends S.TaggedClass<Open>()(`${SPACE_ACTION}/open`, {
188
+ input: S.Struct({
189
+ space: SpaceSchema,
190
+ }),
191
+ output: S.Void,
192
+ }) {}
193
+
194
+ export class Close extends S.TaggedClass<Close>()(`${SPACE_ACTION}/close`, {
195
+ input: S.Struct({
196
+ space: SpaceSchema,
197
+ }),
198
+ output: S.Void,
199
+ }) {}
200
+
201
+ export class Migrate extends S.TaggedClass<Migrate>()(`${SPACE_ACTION}/migrate`, {
202
+ input: S.Struct({
203
+ space: SpaceSchema,
204
+ version: S.optional(S.String),
205
+ }),
206
+ output: S.Boolean,
207
+ }) {}
208
+
209
+ export class OpenCreateObject extends S.TaggedClass<OpenCreateObject>()(`${SPACE_ACTION}/open-create-object`, {
210
+ input: S.Struct({
211
+ target: S.Union(SpaceSchema, CollectionType),
212
+ navigable: S.optional(S.Boolean),
213
+ }),
214
+ output: S.Void,
215
+ }) {}
216
+
217
+ export class AddObject extends S.TaggedClass<AddObject>()(`${SPACE_ACTION}/add-object`, {
218
+ input: S.Struct({
219
+ object: ReactiveObjectSchema,
220
+ target: S.Union(SpaceSchema, CollectionType),
221
+ }),
222
+ output: S.Struct({
223
+ id: S.String,
224
+ activeParts: ActiveParts,
225
+ object: EchoObjectSchema,
226
+ }),
227
+ }) {}
228
+
229
+ export const DeletionData = S.Struct({
230
+ objects: S.Array(EchoObjectSchema),
231
+ parentCollection: CollectionType,
232
+ indices: S.Array(S.Number),
233
+ nestedObjectsList: S.Array(S.Array(EchoObjectSchema)),
234
+ wasActive: S.Array(S.String),
235
+ });
236
+
237
+ export type DeletionData = S.Schema.Type<typeof DeletionData>;
238
+
239
+ export class RemoveObjects extends S.TaggedClass<RemoveObjects>()(`${SPACE_ACTION}/remove-objects`, {
240
+ input: S.Struct({
241
+ objects: S.Array(EchoObjectSchema),
242
+ target: S.optional(CollectionType),
243
+ deletionData: S.optional(DeletionData),
244
+ }),
245
+ output: S.Void,
246
+ }) {}
247
+
248
+ export class RenameObject extends S.TaggedClass<RenameObject>()(`${SPACE_ACTION}/rename-object`, {
249
+ input: S.Struct({
250
+ object: EchoObjectSchema,
251
+ caller: S.optional(S.String),
252
+ }),
253
+ output: S.Void,
254
+ }) {}
255
+
256
+ export class DuplicateObject extends S.TaggedClass<DuplicateObject>()(`${SPACE_ACTION}/duplicate-object`, {
257
+ input: S.Struct({
258
+ object: EchoObjectSchema,
259
+ target: S.Union(SpaceSchema, CollectionType),
260
+ }),
261
+ output: S.Void,
262
+ }) {}
263
+
264
+ export class WaitForObject extends S.TaggedClass<WaitForObject>()(`${SPACE_ACTION}/wait-for-object`, {
265
+ input: S.Struct({
266
+ id: S.optional(S.String),
267
+ }),
268
+ output: S.Void,
269
+ }) {}
270
+
271
+ export class ToggleHidden extends S.TaggedClass<ToggleHidden>()(`${SPACE_ACTION}/toggle-hidden`, {
272
+ input: S.Struct({
273
+ state: S.optional(S.Boolean),
274
+ }),
275
+ output: S.Void,
276
+ }) {}
277
+ }
278
+
279
+ export namespace CollectionAction {
280
+ export class Create extends S.TaggedClass<Create>()('dxos.org/plugin/collection/action/create', {
281
+ input: S.Struct({
282
+ name: S.optional(S.String),
283
+ }),
284
+ output: S.Struct({
285
+ object: CollectionType,
286
+ }),
287
+ }) {}
288
+ }
package/src/util.tsx CHANGED
@@ -2,10 +2,15 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type IntentDispatcher, type MetadataResolver } from '@dxos/app-framework';
5
+ import {
6
+ createIntent,
7
+ type PromiseIntentDispatcher,
8
+ type MetadataResolver,
9
+ NavigationAction,
10
+ } from '@dxos/app-framework';
6
11
  import { EXPANDO_TYPENAME, getObjectAnnotation, getTypename, type Expando } from '@dxos/echo-schema';
7
12
  import { invariant } from '@dxos/invariant';
8
- import { getSchema, isReactiveObject } from '@dxos/live-object';
13
+ import { getSchema, isReactiveObject, makeRef } from '@dxos/live-object';
9
14
  import { Migrations } from '@dxos/migrations';
10
15
  import {
11
16
  ACTION_GROUP_TYPE,
@@ -34,8 +39,8 @@ import {
34
39
  type Space,
35
40
  } from '@dxos/react-client/echo';
36
41
 
37
- import { SPACE_PLUGIN, SpaceAction } from './meta';
38
- import { CollectionType } from './types';
42
+ import { SPACE_PLUGIN } from './meta';
43
+ import { CollectionType, SpaceAction } from './types';
39
44
 
40
45
  export const SPACES = `${SPACE_PLUGIN}-spaces`;
41
46
  export const SPACE_TYPE = 'dxos.org/type/Space';
@@ -106,7 +111,7 @@ const getCollectionGraphNodePartials = ({
106
111
  role: 'branch',
107
112
  onRearrangeChildren: (nextOrder: unknown[]) => {
108
113
  // Change on disk.
109
- collection.objects = nextOrder.filter(isEchoObject);
114
+ collection.objects = nextOrder.filter(isEchoObject).map(makeRef);
110
115
  },
111
116
  onTransferStart: (child: Node<ReactiveEchoObject<any>>, index?: number) => {
112
117
  // TODO(wittjosiah): Support transfer between spaces.
@@ -126,11 +131,12 @@ const getCollectionGraphNodePartials = ({
126
131
  // } else {
127
132
 
128
133
  // Add child to destination collection.
129
- if (!collection.objects.includes(child.data)) {
134
+ // TODO(dmaretskyi): Compare by id.
135
+ if (!collection.objects.find((object) => object.target === child.data)) {
130
136
  if (typeof index !== 'undefined') {
131
- collection.objects.splice(index, 0, child.data);
137
+ collection.objects.splice(index, 0, makeRef(child.data));
132
138
  } else {
133
- collection.objects.push(child.data);
139
+ collection.objects.push(makeRef(child.data));
134
140
  }
135
141
  }
136
142
 
@@ -138,7 +144,7 @@ const getCollectionGraphNodePartials = ({
138
144
  },
139
145
  onTransferEnd: (child: Node<ReactiveEchoObject<any>>, destination: Node) => {
140
146
  // Remove child from origin collection.
141
- const index = collection.objects.indexOf(child.data);
147
+ const index = collection.objects.findIndex((object) => object.target === child.data);
142
148
  if (index > -1) {
143
149
  collection.objects.splice(index, 1);
144
150
  }
@@ -157,9 +163,9 @@ const getCollectionGraphNodePartials = ({
157
163
  const newObject = await cloneObject(child.data, resolve, space);
158
164
  space.db.add(newObject);
159
165
  if (typeof index !== 'undefined') {
160
- collection.objects.splice(index, 0, newObject);
166
+ collection.objects.splice(index, 0, makeRef(newObject));
161
167
  } else {
162
- collection.objects.push(newObject);
168
+ collection.objects.push(makeRef(newObject));
163
169
  }
164
170
  },
165
171
  };
@@ -188,7 +194,7 @@ export const constructSpaceNode = ({
188
194
  resolve: MetadataResolver;
189
195
  }) => {
190
196
  const hasPendingMigration = checkPendingMigration(space);
191
- const collection = space.state.get() === SpaceState.SPACE_READY && space.properties[CollectionType.typename];
197
+ const collection = space.state.get() === SpaceState.SPACE_READY && space.properties[CollectionType.typename]?.target;
192
198
  const partials =
193
199
  space.state.get() === SpaceState.SPACE_READY && collection instanceof CollectionType
194
200
  ? getCollectionGraphNodePartials({ collection, space, resolve, navigable })
@@ -217,7 +223,7 @@ export const constructSpaceActions = ({
217
223
  migrating,
218
224
  }: {
219
225
  space: Space;
220
- dispatch: IntentDispatcher;
226
+ dispatch: PromiseIntentDispatcher;
221
227
  personal?: boolean;
222
228
  migrating?: boolean;
223
229
  }) => {
@@ -228,10 +234,10 @@ export const constructSpaceActions = ({
228
234
 
229
235
  if (hasPendingMigration) {
230
236
  actions.push({
231
- id: getId(SpaceAction.MIGRATE),
237
+ id: getId(SpaceAction.Migrate._tag),
232
238
  type: ACTION_GROUP_TYPE,
233
239
  data: async () => {
234
- await dispatch({ plugin: SPACE_PLUGIN, action: SpaceAction.MIGRATE, data: { space } });
240
+ await dispatch(createIntent(SpaceAction.Migrate, { space }));
235
241
  },
236
242
  properties: {
237
243
  label: ['migrate space label', { ns: SPACE_PLUGIN }],
@@ -246,10 +252,10 @@ export const constructSpaceActions = ({
246
252
  const locked = space.properties[COMPOSER_SPACE_LOCK];
247
253
  actions.push(
248
254
  {
249
- id: getId(SpaceAction.OPEN_CREATE_OBJECT),
255
+ id: getId(SpaceAction.OpenCreateObject._tag),
250
256
  type: ACTION_TYPE,
251
257
  data: async () => {
252
- await dispatch({ plugin: SPACE_PLUGIN, action: SpaceAction.OPEN_CREATE_OBJECT, data: { target: space } });
258
+ await dispatch(createIntent(SpaceAction.OpenCreateObject, { target: space }));
253
259
  },
254
260
  properties: {
255
261
  label: ['create object in space label', { ns: SPACE_PLUGIN }],
@@ -259,13 +265,13 @@ export const constructSpaceActions = ({
259
265
  },
260
266
  },
261
267
  {
262
- id: getId(SpaceAction.SHARE),
268
+ id: getId(SpaceAction.Share._tag),
263
269
  type: ACTION_TYPE,
264
270
  data: async () => {
265
271
  if (locked) {
266
272
  return;
267
273
  }
268
- await dispatch({ plugin: SPACE_PLUGIN, action: SpaceAction.SHARE, data: { space } });
274
+ await dispatch(createIntent(SpaceAction.Share, { space }));
269
275
  },
270
276
  properties: {
271
277
  label: ['share space label', { ns: SPACE_PLUGIN }],
@@ -278,14 +284,14 @@ export const constructSpaceActions = ({
278
284
  },
279
285
  },
280
286
  {
281
- id: locked ? getId(SpaceAction.UNLOCK) : getId(SpaceAction.LOCK),
287
+ id: locked ? getId(SpaceAction.Unlock._tag) : getId(SpaceAction.Lock._tag),
282
288
  type: ACTION_TYPE,
283
289
  data: async () => {
284
- await dispatch({
285
- plugin: SPACE_PLUGIN,
286
- action: locked ? SpaceAction.UNLOCK : SpaceAction.LOCK,
287
- data: { space },
288
- });
290
+ if (locked) {
291
+ await dispatch(createIntent(SpaceAction.Unlock, { space }));
292
+ } else {
293
+ await dispatch(createIntent(SpaceAction.Lock, { space }));
294
+ }
289
295
  },
290
296
  properties: {
291
297
  label: [locked ? 'unlock space label' : 'lock space label', { ns: SPACE_PLUGIN }],
@@ -293,10 +299,10 @@ export const constructSpaceActions = ({
293
299
  },
294
300
  },
295
301
  {
296
- id: getId(SpaceAction.RENAME),
302
+ id: getId(SpaceAction.Rename._tag),
297
303
  type: ACTION_TYPE,
298
304
  data: async (params: InvokeParams) => {
299
- await dispatch({ plugin: SPACE_PLUGIN, action: SpaceAction.RENAME, data: { space, ...params } });
305
+ await dispatch(createIntent(SpaceAction.Rename, { space, caller: params.caller }));
300
306
  },
301
307
  properties: {
302
308
  label: ['rename space label', { ns: SPACE_PLUGIN }],
@@ -308,10 +314,10 @@ export const constructSpaceActions = ({
308
314
  },
309
315
  },
310
316
  {
311
- id: getId(SpaceAction.OPEN_SETTINGS),
317
+ id: getId(SpaceAction.OpenSettings._tag),
312
318
  type: ACTION_TYPE,
313
319
  data: async () => {
314
- await dispatch({ plugin: SPACE_PLUGIN, action: SpaceAction.OPEN_SETTINGS, data: { space } });
320
+ await dispatch(createIntent(SpaceAction.OpenSettings, { space }));
315
321
  },
316
322
  properties: {
317
323
  label: ['open space settings label', { ns: SPACE_PLUGIN }],
@@ -324,10 +330,10 @@ export const constructSpaceActions = ({
324
330
  // TODO(wittjosiah): Consider moving close space into the space settings dialog.
325
331
  if (state !== SpaceState.SPACE_INACTIVE && !hasPendingMigration) {
326
332
  actions.push({
327
- id: getId(SpaceAction.CLOSE),
333
+ id: getId(SpaceAction.Close._tag),
328
334
  type: ACTION_TYPE,
329
335
  data: async () => {
330
- await dispatch({ plugin: SPACE_PLUGIN, action: SpaceAction.CLOSE, data: { space } });
336
+ await dispatch(createIntent(SpaceAction.Close, { space }));
331
337
  },
332
338
  properties: {
333
339
  label: ['close space label', { ns: SPACE_PLUGIN }],
@@ -339,10 +345,10 @@ export const constructSpaceActions = ({
339
345
 
340
346
  if (state === SpaceState.SPACE_INACTIVE) {
341
347
  actions.push({
342
- id: getId(SpaceAction.OPEN),
348
+ id: getId(SpaceAction.Open._tag),
343
349
  type: ACTION_TYPE,
344
350
  data: async () => {
345
- await dispatch({ plugin: SPACE_PLUGIN, action: SpaceAction.OPEN, data: { space } });
351
+ await dispatch(createIntent(SpaceAction.Open, { space }));
346
352
  },
347
353
  properties: {
348
354
  label: ['open space label', { ns: SPACE_PLUGIN }],
@@ -404,7 +410,7 @@ export const constructObjectActions = ({
404
410
  dispatch,
405
411
  }: {
406
412
  node: Node<ReactiveEchoObject<any>>;
407
- dispatch: IntentDispatcher;
413
+ dispatch: PromiseIntentDispatcher;
408
414
  }) => {
409
415
  const object = node.data;
410
416
  const getId = (id: string) => `${id}/${fullyQualifiedId(object)}`;
@@ -412,14 +418,10 @@ export const constructObjectActions = ({
412
418
  ...(object instanceof CollectionType
413
419
  ? [
414
420
  {
415
- id: getId(SpaceAction.ADD_OBJECT),
421
+ id: getId(SpaceAction.OpenCreateObject._tag),
416
422
  type: ACTION_TYPE,
417
423
  data: async () => {
418
- await dispatch({
419
- plugin: SPACE_PLUGIN,
420
- action: SpaceAction.OPEN_CREATE_OBJECT,
421
- data: { target: object },
422
- });
424
+ await dispatch(createIntent(SpaceAction.OpenCreateObject, { target: object }));
423
425
  },
424
426
  properties: {
425
427
  label: ['create object in collection label', { ns: SPACE_PLUGIN }],
@@ -431,13 +433,10 @@ export const constructObjectActions = ({
431
433
  ]
432
434
  : []),
433
435
  {
434
- id: getId(SpaceAction.RENAME_OBJECT),
436
+ id: getId(SpaceAction.RenameObject._tag),
435
437
  type: ACTION_TYPE,
436
438
  data: async (params: InvokeParams) => {
437
- await dispatch({
438
- action: SpaceAction.RENAME_OBJECT,
439
- data: { object, ...params },
440
- });
439
+ await dispatch(createIntent(SpaceAction.RenameObject, { object, caller: params.caller }));
441
440
  },
442
441
  properties: {
443
442
  label: [
@@ -451,19 +450,14 @@ export const constructObjectActions = ({
451
450
  },
452
451
  },
453
452
  {
454
- id: getId(SpaceAction.REMOVE_OBJECTS),
453
+ id: getId(SpaceAction.RemoveObjects._tag),
455
454
  type: ACTION_TYPE,
456
455
  data: async () => {
457
456
  const graph = getGraph(node);
458
457
  const collection = graph
459
458
  .nodes(node, { relation: 'inbound' })
460
459
  .find(({ data }) => data instanceof CollectionType)?.data;
461
- await dispatch([
462
- {
463
- action: SpaceAction.REMOVE_OBJECTS,
464
- data: { objects: [object], collection },
465
- },
466
- ]);
460
+ await dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [object], target: collection }));
467
461
  },
468
462
  properties: {
469
463
  label: [
@@ -488,6 +482,19 @@ export const constructObjectActions = ({
488
482
  testId: 'spacePlugin.copyLink',
489
483
  },
490
484
  },
485
+ // TODO(wittjosiah): Factor out and apply to all nodes.
486
+ {
487
+ id: NavigationAction.Expose._tag,
488
+ type: ACTION_TYPE,
489
+ data: async () => {
490
+ await dispatch(createIntent(NavigationAction.Expose, { id: fullyQualifiedId(object) }));
491
+ },
492
+ properties: {
493
+ label: ['expose object label', { ns: SPACE_PLUGIN }],
494
+ icon: 'ph--eye--regular',
495
+ testId: 'spacePlugin.exposeObject',
496
+ },
497
+ },
491
498
  ];
492
499
 
493
500
  return actions;
@@ -1,43 +0,0 @@
1
- // packages/plugins/plugin-space/src/meta.ts
2
- var SPACE_PLUGIN = "dxos.org/plugin/space";
3
- var SPACE_PLUGIN_SHORT_ID = "space";
4
- var meta_default = {
5
- id: SPACE_PLUGIN,
6
- shortId: SPACE_PLUGIN_SHORT_ID,
7
- name: "Spaces"
8
- };
9
- var SPACE_ACTION = `${SPACE_PLUGIN}/action`;
10
- var SpaceAction;
11
- (function(SpaceAction2) {
12
- SpaceAction2[SpaceAction2["OPEN_CREATE_SPACE"] = `${SPACE_ACTION}/open-create-space`] = "OPEN_CREATE_SPACE";
13
- SpaceAction2[SpaceAction2["CREATE"] = `${SPACE_ACTION}/create`] = "CREATE";
14
- SpaceAction2[SpaceAction2["JOIN"] = `${SPACE_ACTION}/join`] = "JOIN";
15
- SpaceAction2[SpaceAction2["SHARE"] = `${SPACE_ACTION}/share`] = "SHARE";
16
- SpaceAction2[SpaceAction2["LOCK"] = `${SPACE_ACTION}/lock`] = "LOCK";
17
- SpaceAction2[SpaceAction2["UNLOCK"] = `${SPACE_ACTION}/unlock`] = "UNLOCK";
18
- SpaceAction2[SpaceAction2["RENAME"] = `${SPACE_ACTION}/rename`] = "RENAME";
19
- SpaceAction2[SpaceAction2["OPEN"] = `${SPACE_ACTION}/open`] = "OPEN";
20
- SpaceAction2[SpaceAction2["CLOSE"] = `${SPACE_ACTION}/close`] = "CLOSE";
21
- SpaceAction2[SpaceAction2["MIGRATE"] = `${SPACE_ACTION}/migrate`] = "MIGRATE";
22
- SpaceAction2[SpaceAction2["OPEN_CREATE_OBJECT"] = `${SPACE_ACTION}/open-create-object`] = "OPEN_CREATE_OBJECT";
23
- SpaceAction2[SpaceAction2["ADD_OBJECT"] = `${SPACE_ACTION}/add-object`] = "ADD_OBJECT";
24
- SpaceAction2[SpaceAction2["REMOVE_OBJECTS"] = `${SPACE_ACTION}/remove-objects`] = "REMOVE_OBJECTS";
25
- SpaceAction2[SpaceAction2["RENAME_OBJECT"] = `${SPACE_ACTION}/rename-object`] = "RENAME_OBJECT";
26
- SpaceAction2[SpaceAction2["DUPLICATE_OBJECT"] = `${SPACE_ACTION}/duplicate-object`] = "DUPLICATE_OBJECT";
27
- SpaceAction2[SpaceAction2["WAIT_FOR_OBJECT"] = `${SPACE_ACTION}/wait-for-object`] = "WAIT_FOR_OBJECT";
28
- SpaceAction2[SpaceAction2["TOGGLE_HIDDEN"] = `${SPACE_ACTION}/toggle-hidden`] = "TOGGLE_HIDDEN";
29
- SpaceAction2[SpaceAction2["OPEN_SETTINGS"] = `${SPACE_ACTION}/open-settings`] = "OPEN_SETTINGS";
30
- })(SpaceAction || (SpaceAction = {}));
31
- var CollectionAction;
32
- (function(CollectionAction2) {
33
- CollectionAction2["CREATE"] = "dxos.org/plugin/collection/action/create";
34
- })(CollectionAction || (CollectionAction = {}));
35
-
36
- export {
37
- SPACE_PLUGIN,
38
- SPACE_PLUGIN_SHORT_ID,
39
- meta_default,
40
- SpaceAction,
41
- CollectionAction
42
- };
43
- //# sourceMappingURL=chunk-FTKV32QZ.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const SPACE_PLUGIN = 'dxos.org/plugin/space';\nexport const SPACE_PLUGIN_SHORT_ID = 'space';\n\nexport default {\n id: SPACE_PLUGIN,\n shortId: SPACE_PLUGIN_SHORT_ID,\n name: 'Spaces',\n} satisfies PluginMeta;\n\nconst SPACE_ACTION = `${SPACE_PLUGIN}/action`;\nexport enum SpaceAction {\n OPEN_CREATE_SPACE = `${SPACE_ACTION}/open-create-space`,\n CREATE = `${SPACE_ACTION}/create`,\n JOIN = `${SPACE_ACTION}/join`,\n SHARE = `${SPACE_ACTION}/share`,\n LOCK = `${SPACE_ACTION}/lock`,\n UNLOCK = `${SPACE_ACTION}/unlock`,\n RENAME = `${SPACE_ACTION}/rename`,\n OPEN = `${SPACE_ACTION}/open`,\n CLOSE = `${SPACE_ACTION}/close`,\n MIGRATE = `${SPACE_ACTION}/migrate`,\n OPEN_CREATE_OBJECT = `${SPACE_ACTION}/open-create-object`,\n ADD_OBJECT = `${SPACE_ACTION}/add-object`,\n REMOVE_OBJECTS = `${SPACE_ACTION}/remove-objects`,\n RENAME_OBJECT = `${SPACE_ACTION}/rename-object`,\n DUPLICATE_OBJECT = `${SPACE_ACTION}/duplicate-object`,\n WAIT_FOR_OBJECT = `${SPACE_ACTION}/wait-for-object`,\n TOGGLE_HIDDEN = `${SPACE_ACTION}/toggle-hidden`,\n OPEN_SETTINGS = `${SPACE_ACTION}/open-settings`,\n}\n\nexport enum CollectionAction {\n CREATE = 'dxos.org/plugin/collection/action/create',\n}\n"],
5
- "mappings": ";AAMO,IAAMA,eAAe;AACrB,IAAMC,wBAAwB;AAErC,IAAA,eAAe;EACbC,IAAIF;EACJG,SAASF;EACTG,MAAM;AACR;AAEA,IAAMC,eAAe,GAAGL,YAAAA;;UACZM,cAAAA;mDACU,GAAGD,YAAAA,oBAAgC,IAAA;wCAC9C,GAAGA,YAAAA,SAAqB,IAAA;sCAC1B,GAAGA,YAAAA,OAAmB,IAAA;uCACrB,GAAGA,YAAAA,QAAoB,IAAA;sCACxB,GAAGA,YAAAA,OAAmB,IAAA;wCACpB,GAAGA,YAAAA,SAAqB,IAAA;wCACxB,GAAGA,YAAAA,SAAqB,IAAA;sCAC1B,GAAGA,YAAAA,OAAmB,IAAA;uCACrB,GAAGA,YAAAA,QAAoB,IAAA;yCACrB,GAAGA,YAAAA,UAAsB,IAAA;oDACd,GAAGA,YAAAA,qBAAiC,IAAA;4CAC5C,GAAGA,YAAAA,aAAyB,IAAA;gDACxB,GAAGA,YAAAA,iBAA6B,IAAA;+CACjC,GAAGA,YAAAA,gBAA4B,IAAA;kDAC5B,GAAGA,YAAAA,mBAA+B,IAAA;iDACnC,GAAGA,YAAAA,kBAA8B,IAAA;+CACnC,GAAGA,YAAAA,gBAA4B,IAAA;+CAC/B,GAAGA,YAAAA,gBAA4B,IAAA;GAlBrCC,gBAAAA,cAAAA,CAAAA,EAAAA;;UAqBAC,mBAAAA;;GAAAA,qBAAAA,mBAAAA,CAAAA,EAAAA;",
6
- "names": ["SPACE_PLUGIN", "SPACE_PLUGIN_SHORT_ID", "id", "shortId", "name", "SPACE_ACTION", "SpaceAction", "CollectionAction"]
7
- }
@@ -1,124 +0,0 @@
1
- // packages/plugins/plugin-space/src/types/collection.ts
2
- import { Expando, ref, S, TypedObject } from "@dxos/echo-schema";
3
- var CollectionType = class extends TypedObject({
4
- typename: "dxos.org/type/Collection",
5
- version: "0.1.0"
6
- })({
7
- name: S.optional(S.String),
8
- objects: S.mutable(S.Array(ref(Expando))),
9
- // Key is schema typename and value is reference to a view object of the associated schema.
10
- // Having collection reference the views rather than vice versa ensures that the state converges to a single view per key (i.e. type).
11
- // This also leaves open a future where this key could be changed to allow for multiple stack views per section.
12
- // TODO(wittjosiah): Any way to make this more type safe?
13
- // TODO(wittjosiah): Should the views be separate objects or just be schemas for view data in this record?
14
- views: S.mutable(S.Record({
15
- key: S.String,
16
- value: ref(Expando)
17
- }))
18
- }) {
19
- };
20
-
21
- // packages/plugins/plugin-space/src/types/thread.ts
22
- import { Expando as Expando2, ref as ref2, S as S2, TypedObject as TypedObject2 } from "@dxos/echo-schema";
23
- var ContactType = class extends TypedObject2({
24
- typename: "dxos.org/type/Contact",
25
- version: "0.1.0"
26
- })({
27
- name: S2.optional(S2.String),
28
- identifiers: S2.mutable(S2.Array(S2.Struct({
29
- type: S2.String,
30
- value: S2.String
31
- })))
32
- }) {
33
- };
34
- var ActorSchema = S2.mutable(S2.Struct({
35
- contact: S2.optional(ref2(ContactType)),
36
- // TODO(wittjosiah): Should the below fields just be the contact schema?
37
- // i.e. it should either be a reference to an existing contact or an inline contact schema.
38
- identityKey: S2.optional(S2.String),
39
- // TODO(burdon): Generalize to handle/identifier?
40
- email: S2.optional(S2.String),
41
- name: S2.optional(S2.String)
42
- }));
43
- var MessageState;
44
- (function(MessageState2) {
45
- MessageState2[MessageState2["NONE"] = 0] = "NONE";
46
- MessageState2[MessageState2["ARCHIVED"] = 1] = "ARCHIVED";
47
- MessageState2[MessageState2["DELETED"] = 2] = "DELETED";
48
- MessageState2[MessageState2["SPAM"] = 3] = "SPAM";
49
- })(MessageState || (MessageState = {}));
50
- var MessageType = class extends TypedObject2({
51
- typename: "dxos.org/type/Message",
52
- version: "0.1.0"
53
- })({
54
- /** ISO date string when the message was sent. */
55
- timestamp: S2.String,
56
- /** Message state. */
57
- state: S2.optional(S2.Enums(MessageState)),
58
- /** Identity of the message sender. */
59
- sender: ActorSchema,
60
- /** Text content of the message. */
61
- text: S2.String,
62
- /** Non-text content sent with a message (e.g., files, polls, etc.) */
63
- parts: S2.optional(S2.mutable(S2.Array(ref2(Expando2)))),
64
- /** Custom properties for specific message types (e.g. email subject or cc fields). */
65
- properties: S2.optional(S2.mutable(S2.Record({
66
- key: S2.String,
67
- value: S2.Any
68
- }))),
69
- // TODO(wittjosiah): Add read status:
70
- // - Read receipts need to be per space member.
71
- // - Read receipts don't need to be added to schema until they being implemented.
72
- /** Context of the application when message was created. */
73
- // TODO(burdon): Evolve "attention object" to be current UX state? E.g., of Deck?
74
- context: S2.optional(ref2(Expando2))
75
- }) {
76
- };
77
- var ThreadStatus = S2.Union(S2.Literal("staged"), S2.Literal("active"), S2.Literal("resolved"));
78
- var ThreadType = class extends TypedObject2({
79
- typename: "dxos.org/type/Thread",
80
- version: "0.1.0"
81
- })({
82
- name: S2.optional(S2.String),
83
- /** AM cursor-range: 'from:to'. */
84
- anchor: S2.optional(S2.String),
85
- status: S2.optional(ThreadStatus),
86
- messages: S2.mutable(S2.Array(ref2(MessageType)))
87
- }) {
88
- };
89
- var ChannelType = class extends TypedObject2({
90
- typename: "dxos.org/type/Channel",
91
- version: "0.1.0"
92
- })({
93
- name: S2.optional(S2.String),
94
- threads: S2.mutable(S2.Array(ref2(ThreadType)))
95
- }) {
96
- };
97
-
98
- // packages/plugins/plugin-space/src/types/types.ts
99
- import { AST, S as S3 } from "@dxos/echo-schema";
100
- var SPACE_DIRECTORY_HANDLE = "dxos.org/plugin/space/directory";
101
- var parseSchemaPlugin = (plugin) => Array.isArray(plugin?.provides.echo?.schema) || Array.isArray(plugin?.provides.echo?.system) ? plugin : void 0;
102
- var SpaceForm = S3.Struct({
103
- name: S3.optional(S3.String.annotations({
104
- [AST.TitleAnnotationId]: "Name"
105
- })),
106
- edgeReplication: S3.Boolean.annotations({
107
- [AST.TitleAnnotationId]: "Enable EDGE Replication"
108
- })
109
- });
110
-
111
- export {
112
- CollectionType,
113
- ContactType,
114
- ActorSchema,
115
- MessageState,
116
- MessageType,
117
- ThreadStatus,
118
- ThreadType,
119
- ChannelType,
120
- SPACE_DIRECTORY_HANDLE,
121
- parseSchemaPlugin,
122
- SpaceForm
123
- };
124
- //# sourceMappingURL=chunk-MWKXNS5S.mjs.map