@dxos/plugin-space 0.7.4 → 0.7.5-feature-compute.4d9d99a
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.
- package/dist/lib/browser/app-graph-builder-5D2QB43K.mjs +365 -0
- package/dist/lib/browser/app-graph-builder-5D2QB43K.mjs.map +7 -0
- package/dist/lib/browser/app-graph-serializer-VNWPLPDF.mjs +80 -0
- package/dist/lib/browser/app-graph-serializer-VNWPLPDF.mjs.map +7 -0
- package/dist/lib/browser/chunk-5TBRONF6.mjs +133 -0
- package/dist/lib/browser/chunk-5TBRONF6.mjs.map +7 -0
- package/dist/lib/browser/chunk-6SWQRWOD.mjs +1672 -0
- package/dist/lib/browser/chunk-6SWQRWOD.mjs.map +7 -0
- package/dist/lib/browser/chunk-HCXWKGTE.mjs +316 -0
- package/dist/lib/browser/chunk-HCXWKGTE.mjs.map +7 -0
- package/dist/lib/browser/chunk-SOXNANA6.mjs +12 -0
- package/dist/lib/browser/chunk-SOXNANA6.mjs.map +7 -0
- package/dist/lib/browser/chunk-UH5P4UL3.mjs +21 -0
- package/dist/lib/browser/chunk-UH5P4UL3.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZBKFJNHH.mjs +523 -0
- package/dist/lib/browser/chunk-ZBKFJNHH.mjs.map +7 -0
- package/dist/lib/browser/identity-created-EC5FOCX2.mjs +28 -0
- package/dist/lib/browser/identity-created-EC5FOCX2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +192 -3521
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-VBL572N7.mjs +459 -0
- package/dist/lib/browser/intent-resolver-VBL572N7.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-root-AZJFNTKK.mjs +28 -0
- package/dist/lib/browser/react-root-AZJFNTKK.mjs.map +7 -0
- package/dist/lib/browser/react-surface-E2VSYVNZ.mjs +238 -0
- package/dist/lib/browser/react-surface-E2VSYVNZ.mjs.map +7 -0
- package/dist/lib/browser/settings-ASFF5BZL.mjs +24 -0
- package/dist/lib/browser/settings-ASFF5BZL.mjs.map +7 -0
- package/dist/lib/browser/spaces-ready-4SFNS5JQ.mjs +200 -0
- package/dist/lib/browser/spaces-ready-4SFNS5JQ.mjs.map +7 -0
- package/dist/lib/browser/state-MS4KYJWI.mjs +47 -0
- package/dist/lib/browser/state-MS4KYJWI.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +14 -5
- package/dist/lib/node/app-graph-builder-ZQ5S62YR.cjs +368 -0
- package/dist/lib/node/app-graph-builder-ZQ5S62YR.cjs.map +7 -0
- package/dist/lib/node/app-graph-serializer-72S7P33H.cjs +88 -0
- package/dist/lib/node/app-graph-serializer-72S7P33H.cjs.map +7 -0
- package/dist/lib/node/chunk-56NGXG2A.cjs +41 -0
- package/dist/lib/node/chunk-56NGXG2A.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-AO4EW2RX.cjs} +12 -13
- package/dist/lib/node/chunk-AO4EW2RX.cjs.map +7 -0
- package/dist/lib/node/chunk-BQRNTKSQ.cjs +150 -0
- package/dist/lib/node/chunk-BQRNTKSQ.cjs.map +7 -0
- package/dist/lib/node/chunk-DDZYVNVP.cjs +345 -0
- package/dist/lib/node/chunk-DDZYVNVP.cjs.map +7 -0
- package/dist/lib/node/chunk-M64YG2FY.cjs +1669 -0
- package/dist/lib/node/chunk-M64YG2FY.cjs.map +7 -0
- package/dist/lib/node/chunk-Z34MTEU7.cjs +551 -0
- package/dist/lib/node/chunk-Z34MTEU7.cjs.map +7 -0
- package/dist/lib/node/identity-created-IMDS4A6A.cjs +44 -0
- package/dist/lib/node/identity-created-IMDS4A6A.cjs.map +7 -0
- package/dist/lib/node/index.cjs +175 -3506
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-S4HZABYI.cjs +458 -0
- package/dist/lib/node/intent-resolver-S4HZABYI.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-root-RB3OM3QG.cjs +50 -0
- package/dist/lib/node/react-root-RB3OM3QG.cjs.map +7 -0
- package/dist/lib/node/react-surface-TLKQEHHT.cjs +233 -0
- package/dist/lib/node/react-surface-TLKQEHHT.cjs.map +7 -0
- package/dist/lib/node/settings-QLCKAUHK.cjs +38 -0
- package/dist/lib/node/settings-QLCKAUHK.cjs.map +7 -0
- package/dist/lib/node/spaces-ready-RZTKEXOL.cjs +211 -0
- package/dist/lib/node/spaces-ready-RZTKEXOL.cjs.map +7 -0
- package/dist/lib/node/state-4UIOUKLJ.cjs +61 -0
- package/dist/lib/node/state-4UIOUKLJ.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +23 -14
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/app-graph-builder-CD6IYPSS.mjs +366 -0
- package/dist/lib/node-esm/app-graph-builder-CD6IYPSS.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-serializer-CFXS6ZE2.mjs +81 -0
- package/dist/lib/node-esm/app-graph-serializer-CFXS6ZE2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-375RB3CZ.mjs +22 -0
- package/dist/lib/node-esm/chunk-375RB3CZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7FUVU45N.mjs +14 -0
- package/dist/lib/node-esm/chunk-7FUVU45N.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CLGCKZ2D.mjs +317 -0
- package/dist/lib/node-esm/chunk-CLGCKZ2D.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CMKML5IN.mjs +1673 -0
- package/dist/lib/node-esm/chunk-CMKML5IN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FUMGYUD3.mjs +524 -0
- package/dist/lib/node-esm/chunk-FUMGYUD3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-M4XTHK35.mjs +134 -0
- package/dist/lib/node-esm/chunk-M4XTHK35.mjs.map +7 -0
- package/dist/lib/node-esm/identity-created-SJYZZ7Q3.mjs +29 -0
- package/dist/lib/node-esm/identity-created-SJYZZ7Q3.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +192 -3521
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-OIQH7HN7.mjs +460 -0
- package/dist/lib/node-esm/intent-resolver-OIQH7HN7.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-root-WKJWCHXR.mjs +29 -0
- package/dist/lib/node-esm/react-root-WKJWCHXR.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-RVEHOSAD.mjs +239 -0
- package/dist/lib/node-esm/react-surface-RVEHOSAD.mjs.map +7 -0
- package/dist/lib/node-esm/settings-WLVEO4JM.mjs +25 -0
- package/dist/lib/node-esm/settings-WLVEO4JM.mjs.map +7 -0
- package/dist/lib/node-esm/spaces-ready-ITGYYT5A.mjs +201 -0
- package/dist/lib/node-esm/spaces-ready-ITGYYT5A.mjs.map +7 -0
- package/dist/lib/node-esm/state-BMISGQ2O.mjs +48 -0
- package/dist/lib/node-esm/state-BMISGQ2O.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +14 -5
- package/dist/types/src/SpacePlugin.d.ts +1 -24
- package/dist/types/src/SpacePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-serializer.d.ts +4 -0
- package/dist/types/src/capabilities/app-graph-serializer.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +15 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/identity-created.d.ts +4 -0
- package/dist/types/src/capabilities/identity-created.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +195 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +8 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root.d.ts +7 -0
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +7 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/spaces-ready.d.ts +4 -0
- package/dist/types/src/capabilities/spaces-ready.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +5 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/components/AdvancedObjectSettings/AdvancedObjectSettings.d.ts +7 -0
- package/dist/types/src/components/AdvancedObjectSettings/AdvancedObjectSettings.d.ts.map +1 -0
- package/dist/types/src/components/AdvancedObjectSettings/ForeignKeys.d.ts +8 -0
- package/dist/types/src/components/AdvancedObjectSettings/ForeignKeys.d.ts.map +1 -0
- package/dist/types/src/components/AdvancedObjectSettings/index.d.ts +2 -0
- package/dist/types/src/components/AdvancedObjectSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/AwaitingObject.d.ts.map +1 -1
- package/dist/types/src/components/BaseObjectSettings.d.ts +7 -0
- package/dist/types/src/components/BaseObjectSettings.d.ts.map +1 -0
- package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts +5 -4
- package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts.map +1 -1
- package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts +5 -6
- package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts +1 -0
- package/dist/types/src/components/CreateDialog/CreateSpaceDialog.d.ts.map +1 -1
- package/dist/types/src/components/JoinDialog.d.ts +1 -0
- package/dist/types/src/components/JoinDialog.d.ts.map +1 -1
- package/dist/types/src/components/PopoverRenameObject.d.ts +1 -0
- package/dist/types/src/components/PopoverRenameObject.d.ts.map +1 -1
- package/dist/types/src/components/PopoverRenameSpace.d.ts +1 -0
- package/dist/types/src/components/PopoverRenameSpace.d.ts.map +1 -1
- package/dist/types/src/components/ShareSpaceButton.d.ts.map +1 -1
- package/dist/types/src/components/SpacePluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/SpacePresence.d.ts +9 -6
- package/dist/types/src/components/SpacePresence.d.ts.map +1 -1
- package/dist/types/src/components/SpacePresence.stories.d.ts +1 -1
- package/dist/types/src/components/SpacePresence.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts +1 -0
- package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts +4 -3
- package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts +3 -3
- package/dist/types/src/components/SyncStatus/InlineSyncStatus.d.ts.map +1 -1
- package/dist/types/src/components/SyncStatus/SyncStatusDetail.stories.d.ts +2 -2
- package/dist/types/src/components/SyncStatus/SyncStatusDetail.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +5 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/usePath.d.ts +11 -0
- package/dist/types/src/hooks/usePath.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -27
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +18 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/collection.d.ts +8 -12
- package/dist/types/src/types/collection.d.ts.map +1 -1
- package/dist/types/src/types/thread.d.ts +180 -186
- package/dist/types/src/types/thread.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +228 -16
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +9 -8
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +38 -46
- package/src/SpacePlugin.tsx +119 -1541
- package/src/capabilities/app-graph-builder.ts +392 -0
- package/src/capabilities/app-graph-serializer.ts +73 -0
- package/src/capabilities/capabilities.ts +23 -0
- package/src/capabilities/identity-created.ts +26 -0
- package/src/capabilities/index.ts +17 -0
- package/src/capabilities/intent-resolver.ts +420 -0
- package/src/capabilities/react-root.tsx +20 -0
- package/src/capabilities/react-surface.tsx +234 -0
- package/src/capabilities/settings.ts +17 -0
- package/src/capabilities/spaces-ready.ts +231 -0
- package/src/capabilities/state.ts +45 -0
- package/src/components/AdvancedObjectSettings/AdvancedObjectSettings.tsx +72 -0
- package/src/components/AdvancedObjectSettings/ForeignKeys.tsx +51 -0
- package/src/components/AdvancedObjectSettings/index.ts +5 -0
- package/src/components/AwaitingObject.tsx +15 -19
- package/src/components/{DefaultObjectSettings.tsx → BaseObjectSettings.tsx} +2 -2
- package/src/components/CreateDialog/CreateObjectDialog.tsx +36 -25
- package/src/components/CreateDialog/CreateObjectPanel.tsx +61 -24
- package/src/components/CreateDialog/CreateSpaceDialog.tsx +10 -14
- package/src/components/JoinDialog.tsx +18 -34
- package/src/components/PersistenceStatus.tsx +1 -1
- package/src/components/PopoverRenameObject.tsx +2 -0
- package/src/components/PopoverRenameSpace.tsx +2 -0
- package/src/components/ShareSpaceButton.tsx +5 -4
- package/src/components/SpacePluginSettings.tsx +2 -13
- package/src/components/SpacePresence.stories.tsx +25 -17
- package/src/components/SpacePresence.tsx +42 -21
- package/src/components/SpaceSettings/SpaceSettingsDialog.stories.tsx +2 -3
- package/src/components/SpaceSettings/SpaceSettingsDialog.tsx +3 -1
- package/src/components/SpaceSettings/SpaceSettingsPanel.stories.tsx +7 -5
- package/src/components/SpaceSettings/SpaceSettingsPanel.tsx +6 -5
- package/src/components/SyncStatus/InlineSyncStatus.tsx +37 -27
- package/src/components/SyncStatus/SyncStatusDetail.stories.tsx +55 -51
- package/src/components/index.ts +2 -1
- package/src/events.ts +12 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/usePath.ts +44 -0
- package/src/index.ts +3 -7
- package/src/meta.ts +1 -29
- package/src/translations.ts +7 -2
- package/src/types/collection.ts +3 -3
- package/src/types/thread.ts +6 -6
- package/src/types/types.ts +177 -42
- package/src/util.tsx +77 -64
- package/dist/lib/browser/chunk-FTKV32QZ.mjs +0 -43
- package/dist/lib/browser/chunk-FTKV32QZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-MWKXNS5S.mjs +0 -124
- package/dist/lib/browser/chunk-MWKXNS5S.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -15
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/chunk-6SNOZF7Y.cjs +0 -152
- package/dist/lib/node/chunk-6SNOZF7Y.cjs.map +0 -7
- package/dist/lib/node/chunk-QNVEU2UD.cjs +0 -69
- package/dist/lib/node/chunk-QNVEU2UD.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-OHEAWSCA.mjs +0 -126
- package/dist/lib/node-esm/chunk-OHEAWSCA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UMV7XREB.mjs +0 -45
- package/dist/lib/node-esm/chunk-UMV7XREB.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -16
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/components/DefaultObjectSettings.d.ts +0 -7
- package/dist/types/src/components/DefaultObjectSettings.d.ts.map +0 -1
- package/dist/types/src/components/SyncStatus/InlineSyncStatus.stories.d.ts +0 -6
- package/dist/types/src/components/SyncStatus/InlineSyncStatus.stories.d.ts.map +0 -1
- package/src/components/SyncStatus/InlineSyncStatus.stories.tsx +0 -57
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
+
import {
|
|
7
|
+
Expando,
|
|
8
|
+
Filter,
|
|
9
|
+
FQ_ID_LENGTH,
|
|
10
|
+
getSpace,
|
|
11
|
+
isEchoObject,
|
|
12
|
+
isSpace,
|
|
13
|
+
OBJECT_ID_LENGTH,
|
|
14
|
+
parseId,
|
|
15
|
+
type ReactiveEchoObject,
|
|
16
|
+
SPACE_ID_LENGTH,
|
|
17
|
+
SpaceState,
|
|
18
|
+
type Space,
|
|
19
|
+
} from '@dxos/client/echo';
|
|
20
|
+
import { getTypename, isDeleted } from '@dxos/live-object';
|
|
21
|
+
import { log } from '@dxos/log';
|
|
22
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
23
|
+
import { createExtension, toSignal, type Node } from '@dxos/plugin-graph';
|
|
24
|
+
import { nonNullable } from '@dxos/util';
|
|
25
|
+
|
|
26
|
+
import { SpaceCapabilities } from './capabilities';
|
|
27
|
+
import { SPACE_PLUGIN } from '../meta';
|
|
28
|
+
import { CollectionType, SpaceAction, type SpaceSettingsProps } from '../types';
|
|
29
|
+
import {
|
|
30
|
+
constructObjectActions,
|
|
31
|
+
constructSpaceActions,
|
|
32
|
+
constructSpaceNode,
|
|
33
|
+
createObjectNode,
|
|
34
|
+
memoizeQuery,
|
|
35
|
+
SHARED,
|
|
36
|
+
SPACES,
|
|
37
|
+
} from '../util';
|
|
38
|
+
|
|
39
|
+
export default (context: PluginsContext) => {
|
|
40
|
+
const resolve = (typename: string) =>
|
|
41
|
+
context.requestCapabilities(Capabilities.Metadata).find(({ id }) => id === typename)?.metadata ?? {};
|
|
42
|
+
|
|
43
|
+
const spacesNode = {
|
|
44
|
+
id: SPACES,
|
|
45
|
+
type: SPACES,
|
|
46
|
+
cacheable: ['label', 'role'],
|
|
47
|
+
properties: {
|
|
48
|
+
label: ['spaces label', { ns: SPACE_PLUGIN }],
|
|
49
|
+
testId: 'spacePlugin.spaces',
|
|
50
|
+
role: 'branch',
|
|
51
|
+
disabled: true,
|
|
52
|
+
childrenPersistenceClass: 'echo',
|
|
53
|
+
onRearrangeChildren: async (nextOrder: Space[]) => {
|
|
54
|
+
const { graph } = context.requestCapability(Capabilities.AppGraph);
|
|
55
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
56
|
+
|
|
57
|
+
// NOTE: This is needed to ensure order is updated by next animation frame.
|
|
58
|
+
// TODO(wittjosiah): Is there a better way to do this?
|
|
59
|
+
// If not, graph should be passed as an argument to the extension.
|
|
60
|
+
graph._sortEdges(
|
|
61
|
+
SPACES,
|
|
62
|
+
'outbound',
|
|
63
|
+
nextOrder.map(({ id }) => id),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const {
|
|
67
|
+
objects: [spacesOrder],
|
|
68
|
+
} = await client.spaces.default.db.query(Filter.schema(Expando, { key: SHARED })).run();
|
|
69
|
+
if (spacesOrder) {
|
|
70
|
+
spacesOrder.order = nextOrder.map(({ id }) => id);
|
|
71
|
+
} else {
|
|
72
|
+
log.warn('spaces order object not found');
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return contributes(Capabilities.AppGraphBuilder, [
|
|
79
|
+
// Primary actions.
|
|
80
|
+
createExtension({
|
|
81
|
+
id: `${SPACE_PLUGIN}/primary-actions`,
|
|
82
|
+
disposition: 'hoist',
|
|
83
|
+
filter: (node): node is Node<null> => node.id === 'root',
|
|
84
|
+
actions: () => [
|
|
85
|
+
{
|
|
86
|
+
id: SpaceAction.OpenCreateSpace._tag,
|
|
87
|
+
data: async () => {
|
|
88
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
89
|
+
await dispatch(createIntent(SpaceAction.OpenCreateSpace));
|
|
90
|
+
},
|
|
91
|
+
properties: {
|
|
92
|
+
label: ['create space label', { ns: SPACE_PLUGIN }],
|
|
93
|
+
icon: 'ph--plus--regular',
|
|
94
|
+
testId: 'spacePlugin.createSpace',
|
|
95
|
+
disposition: 'item',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: SpaceAction.Join._tag,
|
|
100
|
+
data: async () => {
|
|
101
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
102
|
+
await dispatch(createIntent(SpaceAction.Join));
|
|
103
|
+
},
|
|
104
|
+
properties: {
|
|
105
|
+
label: ['join space label', { ns: SPACE_PLUGIN }],
|
|
106
|
+
icon: 'ph--sign-in--regular',
|
|
107
|
+
testId: 'spacePlugin.joinSpace',
|
|
108
|
+
disposition: 'item',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
}),
|
|
113
|
+
|
|
114
|
+
// Create spaces group node.
|
|
115
|
+
createExtension({
|
|
116
|
+
id: `${SPACE_PLUGIN}/root`,
|
|
117
|
+
disposition: 'hoist',
|
|
118
|
+
filter: (node): node is Node<null> => node.id === 'root',
|
|
119
|
+
connector: () => [spacesNode],
|
|
120
|
+
resolver: ({ id }) => (id === SPACES ? spacesNode : undefined),
|
|
121
|
+
}),
|
|
122
|
+
|
|
123
|
+
// Create space nodes.
|
|
124
|
+
createExtension({
|
|
125
|
+
id: SPACES,
|
|
126
|
+
filter: (node): node is Node<null> => node.id === SPACES,
|
|
127
|
+
connector: () => {
|
|
128
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
129
|
+
const spaces = toSignal(
|
|
130
|
+
(onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
|
|
131
|
+
() => client.spaces.get(),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const isReady = toSignal(
|
|
135
|
+
(onChange) => client.spaces.isReady.subscribe(() => onChange()).unsubscribe,
|
|
136
|
+
() => client.spaces.isReady.get(),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
if (!spaces || !isReady) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const state = context.requestCapability(SpaceCapabilities.State);
|
|
144
|
+
const settings = context
|
|
145
|
+
.requestCapabilities(Capabilities.SettingsStore)[0]
|
|
146
|
+
?.getStore<SpaceSettingsProps>(SPACE_PLUGIN)?.value;
|
|
147
|
+
|
|
148
|
+
// TODO(wittjosiah): During client reset, accessing default space throws.
|
|
149
|
+
try {
|
|
150
|
+
const [spacesOrder] = memoizeQuery(client.spaces.default, Filter.schema(Expando, { key: SHARED }));
|
|
151
|
+
const order: string[] = spacesOrder?.order ?? [];
|
|
152
|
+
const orderMap = new Map(order.map((id, index) => [id, index]));
|
|
153
|
+
return [
|
|
154
|
+
...spaces
|
|
155
|
+
.filter((space) => orderMap.has(space.id))
|
|
156
|
+
.sort((a, b) => orderMap.get(a.id)! - orderMap.get(b.id)!),
|
|
157
|
+
...spaces.filter((space) => !orderMap.has(space.id)),
|
|
158
|
+
]
|
|
159
|
+
.filter((space) => (settings?.showHidden ? true : space.state.get() !== SpaceState.SPACE_INACTIVE))
|
|
160
|
+
.map((space) =>
|
|
161
|
+
constructSpaceNode({
|
|
162
|
+
space,
|
|
163
|
+
navigable: state.navigableCollections,
|
|
164
|
+
personal: space === client.spaces.default,
|
|
165
|
+
namesCache: state.spaceNames,
|
|
166
|
+
resolve,
|
|
167
|
+
}),
|
|
168
|
+
);
|
|
169
|
+
} catch {}
|
|
170
|
+
},
|
|
171
|
+
resolver: ({ id }) => {
|
|
172
|
+
if (id.length !== SPACE_ID_LENGTH) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
177
|
+
const spaces = toSignal(
|
|
178
|
+
(onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
|
|
179
|
+
() => client.spaces.get(),
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const isReady = toSignal(
|
|
183
|
+
(onChange) => client.spaces.isReady.subscribe(() => onChange()).unsubscribe,
|
|
184
|
+
() => client.spaces.isReady.get(),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
if (!spaces || !isReady) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const space = spaces.find((space) => space.id === id);
|
|
192
|
+
if (!space) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (space.state.get() === SpaceState.SPACE_INACTIVE) {
|
|
197
|
+
return false;
|
|
198
|
+
} else {
|
|
199
|
+
const state = context.requestCapability(SpaceCapabilities.State);
|
|
200
|
+
return constructSpaceNode({
|
|
201
|
+
space,
|
|
202
|
+
navigable: state.navigableCollections,
|
|
203
|
+
personal: space === client.spaces.default,
|
|
204
|
+
namesCache: state.spaceNames,
|
|
205
|
+
resolve,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
}),
|
|
210
|
+
|
|
211
|
+
// Create space actions.
|
|
212
|
+
createExtension({
|
|
213
|
+
id: `${SPACE_PLUGIN}/actions`,
|
|
214
|
+
filter: (node): node is Node<Space> => isSpace(node.data),
|
|
215
|
+
actions: ({ node }) => {
|
|
216
|
+
const space = node.data;
|
|
217
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
218
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
219
|
+
const state = context.requestCapability(SpaceCapabilities.State);
|
|
220
|
+
return constructSpaceActions({
|
|
221
|
+
space,
|
|
222
|
+
dispatch,
|
|
223
|
+
personal: space === client.spaces.default,
|
|
224
|
+
migrating: state.sdkMigrationRunning[space.id],
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
}),
|
|
228
|
+
|
|
229
|
+
// Create nodes for objects in the root collection of a space.
|
|
230
|
+
createExtension({
|
|
231
|
+
id: `${SPACE_PLUGIN}/root-collection`,
|
|
232
|
+
filter: (node): node is Node<Space> => isSpace(node.data),
|
|
233
|
+
connector: ({ node }) => {
|
|
234
|
+
const space = node.data;
|
|
235
|
+
const spaceState = toSignal(
|
|
236
|
+
(onChange) => space.state.subscribe(() => onChange()).unsubscribe,
|
|
237
|
+
() => space.state.get(),
|
|
238
|
+
space.id,
|
|
239
|
+
);
|
|
240
|
+
if (spaceState !== SpaceState.SPACE_READY) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const collection = space.properties[CollectionType.typename]?.target as CollectionType | undefined;
|
|
245
|
+
if (!collection) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const state = context.requestCapability(SpaceCapabilities.State);
|
|
250
|
+
|
|
251
|
+
return collection.objects
|
|
252
|
+
.map((object) => object.target)
|
|
253
|
+
.filter(nonNullable)
|
|
254
|
+
.map((object) => createObjectNode({ object, space, resolve, navigable: state.navigableCollections }))
|
|
255
|
+
.filter(nonNullable);
|
|
256
|
+
},
|
|
257
|
+
}),
|
|
258
|
+
|
|
259
|
+
// Create nodes for objects in a collection or by its fully qualified id.
|
|
260
|
+
createExtension({
|
|
261
|
+
id: `${SPACE_PLUGIN}/objects`,
|
|
262
|
+
filter: (node): node is Node<CollectionType> => node.data instanceof CollectionType,
|
|
263
|
+
connector: ({ node }) => {
|
|
264
|
+
const collection = node.data;
|
|
265
|
+
const space = getSpace(collection);
|
|
266
|
+
if (!space) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const state = context.requestCapability(SpaceCapabilities.State);
|
|
271
|
+
|
|
272
|
+
return collection.objects
|
|
273
|
+
.map((object) => object.target)
|
|
274
|
+
.filter(nonNullable)
|
|
275
|
+
.map((object) => createObjectNode({ object, space, resolve, navigable: state.navigableCollections }))
|
|
276
|
+
.filter(nonNullable);
|
|
277
|
+
},
|
|
278
|
+
resolver: ({ id }) => {
|
|
279
|
+
if (id.length !== FQ_ID_LENGTH) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const [spaceId, objectId] = id.split(':');
|
|
284
|
+
if (spaceId.length !== SPACE_ID_LENGTH && objectId.length !== OBJECT_ID_LENGTH) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
289
|
+
const space = client.spaces.get().find((space) => space.id === spaceId);
|
|
290
|
+
if (!space) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const spaceState = toSignal(
|
|
295
|
+
(onChange) => space.state.subscribe(() => onChange()).unsubscribe,
|
|
296
|
+
() => space.state.get(),
|
|
297
|
+
space.id,
|
|
298
|
+
);
|
|
299
|
+
if (spaceState !== SpaceState.SPACE_READY) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const [object] = memoizeQuery(space, { id: objectId });
|
|
304
|
+
if (!object) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (isDeleted(object)) {
|
|
309
|
+
return false;
|
|
310
|
+
} else {
|
|
311
|
+
const state = context.requestCapability(SpaceCapabilities.State);
|
|
312
|
+
return createObjectNode({ object, space, resolve, navigable: state.navigableCollections });
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
}),
|
|
316
|
+
|
|
317
|
+
// Create collection actions and action groups.
|
|
318
|
+
createExtension({
|
|
319
|
+
id: `${SPACE_PLUGIN}/object-actions`,
|
|
320
|
+
filter: (node): node is Node<ReactiveEchoObject<any>> => isEchoObject(node.data),
|
|
321
|
+
actions: ({ node }) => {
|
|
322
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
323
|
+
const state = context.requestCapability(SpaceCapabilities.State);
|
|
324
|
+
return constructObjectActions({ node, dispatch, navigable: state.navigableCollections });
|
|
325
|
+
},
|
|
326
|
+
}),
|
|
327
|
+
|
|
328
|
+
// Create nodes for object settings.
|
|
329
|
+
createExtension({
|
|
330
|
+
id: `${SPACE_PLUGIN}/settings-for-subject`,
|
|
331
|
+
resolver: ({ id }) => {
|
|
332
|
+
// TODO(Zan): Find util (or make one).
|
|
333
|
+
if (!id.endsWith('~settings')) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const type = 'orphan-settings-for-subject';
|
|
338
|
+
const icon = 'ph--gear--regular';
|
|
339
|
+
|
|
340
|
+
const [subjectId] = id.split('~');
|
|
341
|
+
const { spaceId, objectId } = parseId(subjectId);
|
|
342
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
343
|
+
const spaces = toSignal(
|
|
344
|
+
(onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
|
|
345
|
+
() => client.spaces.get(),
|
|
346
|
+
);
|
|
347
|
+
const space = spaces?.find((space) => space.id === spaceId && space.state.get() === SpaceState.SPACE_READY);
|
|
348
|
+
if (!objectId) {
|
|
349
|
+
const label = space
|
|
350
|
+
? space.properties.name || ['unnamed space label', { ns: SPACE_PLUGIN }]
|
|
351
|
+
: ['unnamed object settings label', { ns: SPACE_PLUGIN }];
|
|
352
|
+
|
|
353
|
+
// TODO(wittjosiah): Support comments for arbitrary subjects.
|
|
354
|
+
// This is to ensure that the comments panel is not stuck on an old object.
|
|
355
|
+
return {
|
|
356
|
+
id,
|
|
357
|
+
type,
|
|
358
|
+
data: null,
|
|
359
|
+
properties: {
|
|
360
|
+
icon,
|
|
361
|
+
label,
|
|
362
|
+
showResolvedThreads: false,
|
|
363
|
+
object: null,
|
|
364
|
+
space,
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const [object] = memoizeQuery(space, { id: objectId });
|
|
370
|
+
if (!object || !subjectId) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const meta = resolve(getTypename(object) ?? '');
|
|
375
|
+
const label = meta.label?.(object) ||
|
|
376
|
+
object.name ||
|
|
377
|
+
meta.placeholder || ['unnamed object settings label', { ns: SPACE_PLUGIN }];
|
|
378
|
+
|
|
379
|
+
return {
|
|
380
|
+
id,
|
|
381
|
+
type,
|
|
382
|
+
data: null,
|
|
383
|
+
properties: {
|
|
384
|
+
icon,
|
|
385
|
+
label,
|
|
386
|
+
object,
|
|
387
|
+
},
|
|
388
|
+
};
|
|
389
|
+
},
|
|
390
|
+
}),
|
|
391
|
+
]);
|
|
392
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, contributes, createIntent, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
+
import { isSpace } from '@dxos/client/echo';
|
|
7
|
+
import { create } from '@dxos/live-object';
|
|
8
|
+
|
|
9
|
+
import { SPACE_PLUGIN } from '../meta';
|
|
10
|
+
import translations from '../translations';
|
|
11
|
+
import { CollectionType, SpaceAction } from '../types';
|
|
12
|
+
import { SPACES, SPACE_TYPE } from '../util';
|
|
13
|
+
|
|
14
|
+
// https://stackoverflow.com/a/19016910
|
|
15
|
+
const DIRECTORY_TYPE = 'text/directory';
|
|
16
|
+
|
|
17
|
+
export default (context: PluginsContext) =>
|
|
18
|
+
contributes(Capabilities.AppGraphSerializer, [
|
|
19
|
+
{
|
|
20
|
+
inputType: SPACES,
|
|
21
|
+
outputType: DIRECTORY_TYPE,
|
|
22
|
+
serialize: (node) => ({
|
|
23
|
+
name: translations[0]['en-US'][SPACE_PLUGIN]['spaces label'],
|
|
24
|
+
data: translations[0]['en-US'][SPACE_PLUGIN]['spaces label'],
|
|
25
|
+
type: DIRECTORY_TYPE,
|
|
26
|
+
}),
|
|
27
|
+
deserialize: () => {
|
|
28
|
+
// No-op.
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
inputType: SPACE_TYPE,
|
|
33
|
+
outputType: DIRECTORY_TYPE,
|
|
34
|
+
serialize: (node) => ({
|
|
35
|
+
name: node.data.properties.name ?? translations[0]['en-US'][SPACE_PLUGIN]['unnamed space label'],
|
|
36
|
+
data: node.data.properties.name ?? translations[0]['en-US'][SPACE_PLUGIN]['unnamed space label'],
|
|
37
|
+
type: DIRECTORY_TYPE,
|
|
38
|
+
}),
|
|
39
|
+
deserialize: async (data) => {
|
|
40
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
41
|
+
const result = await dispatch(createIntent(SpaceAction.Create, { name: data.name, edgeReplication: true }));
|
|
42
|
+
return result.data?.space;
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
inputType: CollectionType.typename,
|
|
47
|
+
outputType: DIRECTORY_TYPE,
|
|
48
|
+
serialize: (node) => ({
|
|
49
|
+
name: node.data.name ?? translations[0]['en-US'][SPACE_PLUGIN]['unnamed collection label'],
|
|
50
|
+
data: node.data.name ?? translations[0]['en-US'][SPACE_PLUGIN]['unnamed collection label'],
|
|
51
|
+
type: DIRECTORY_TYPE,
|
|
52
|
+
}),
|
|
53
|
+
deserialize: async (data, ancestors) => {
|
|
54
|
+
const space = ancestors.find(isSpace);
|
|
55
|
+
const collection =
|
|
56
|
+
ancestors.findLast((ancestor) => ancestor instanceof CollectionType) ??
|
|
57
|
+
space?.properties[CollectionType.typename]?.target;
|
|
58
|
+
if (!space || !collection) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
|
|
63
|
+
const result = await dispatch(
|
|
64
|
+
createIntent(SpaceAction.AddObject, {
|
|
65
|
+
target: collection,
|
|
66
|
+
object: create(CollectionType, { name: data.name, objects: [], views: {} }),
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return result.data?.object;
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineCapability } from '@dxos/app-framework';
|
|
6
|
+
import { type DeepReadonly } from '@dxos/util';
|
|
7
|
+
|
|
8
|
+
import { SPACE_PLUGIN } from '../meta';
|
|
9
|
+
import { type PluginState } from '../types';
|
|
10
|
+
|
|
11
|
+
export namespace SpaceCapabilities {
|
|
12
|
+
export const State = defineCapability<DeepReadonly<PluginState>>(`${SPACE_PLUGIN}/capability/state`);
|
|
13
|
+
export const MutableState = defineCapability<PluginState>(`${SPACE_PLUGIN}/capability/state`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// TODO(wittjosiah): Factor out.
|
|
17
|
+
export namespace ThreadCapabilities {
|
|
18
|
+
type ThreadCapability<T = any> = {
|
|
19
|
+
predicate: (obj: any) => obj is T;
|
|
20
|
+
createSort: (obj: T) => (anchorA: string | undefined, anchorB: string | undefined) => number;
|
|
21
|
+
};
|
|
22
|
+
export const Thread = defineCapability<ThreadCapability>(`${SPACE_PLUGIN}/capability/thread`);
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes, type PluginsContext, Capabilities } from '@dxos/app-framework';
|
|
6
|
+
import { create, makeRef } from '@dxos/live-object';
|
|
7
|
+
import { Migrations } from '@dxos/migrations';
|
|
8
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
9
|
+
|
|
10
|
+
import { CollectionType } from '../types';
|
|
11
|
+
|
|
12
|
+
export default async (context: PluginsContext) => {
|
|
13
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
14
|
+
await client.spaces.waitUntilReady();
|
|
15
|
+
|
|
16
|
+
const defaultSpace = client.spaces.default;
|
|
17
|
+
await defaultSpace.waitUntilReady();
|
|
18
|
+
|
|
19
|
+
// Create root collection structure.
|
|
20
|
+
defaultSpace.properties[CollectionType.typename] = makeRef(create(CollectionType, { objects: [], views: {} }));
|
|
21
|
+
if (Migrations.versionProperty) {
|
|
22
|
+
defaultSpace.properties[Migrations.versionProperty] = Migrations.targetVersion;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return contributes(Capabilities.Null, null);
|
|
26
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { lazy } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
|
|
8
|
+
export const AppGraphSerializer = lazy(() => import('./app-graph-serializer'));
|
|
9
|
+
export const IdentityCreated = lazy(() => import('./identity-created'));
|
|
10
|
+
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
11
|
+
export const ReactRoot = lazy(() => import('./react-root'));
|
|
12
|
+
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
13
|
+
export const SpaceSettings = lazy(() => import('./settings'));
|
|
14
|
+
export const SpaceState = lazy(() => import('./state'));
|
|
15
|
+
export const SpacesReady = lazy(() => import('./spaces-ready'));
|
|
16
|
+
|
|
17
|
+
export * from './capabilities';
|