@dxos/plugin-space 0.6.8-main.046e6cf
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/LICENSE +8 -0
- package/README.md +15 -0
- package/dist/lib/browser/chunk-DTVUOG2C.mjs +95 -0
- package/dist/lib/browser/chunk-DTVUOG2C.mjs.map +7 -0
- package/dist/lib/browser/chunk-LZEGRS7H.mjs +35 -0
- package/dist/lib/browser/chunk-LZEGRS7H.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +2660 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/meta.mjs +13 -0
- package/dist/lib/browser/meta.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +21 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node/chunk-6CNYF6YU.cjs +60 -0
- package/dist/lib/node/chunk-6CNYF6YU.cjs.map +7 -0
- package/dist/lib/node/chunk-CVZPI2P3.cjs +120 -0
- package/dist/lib/node/chunk-CVZPI2P3.cjs.map +7 -0
- package/dist/lib/node/index.cjs +2682 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.cjs +34 -0
- package/dist/lib/node/meta.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node/types/index.cjs +43 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/types/src/SpacePlugin.d.ts +27 -0
- package/dist/types/src/SpacePlugin.d.ts.map +1 -0
- package/dist/types/src/components/AwaitingObject.d.ts +5 -0
- package/dist/types/src/components/AwaitingObject.d.ts.map +1 -0
- package/dist/types/src/components/CollectionMain.d.ts +6 -0
- package/dist/types/src/components/CollectionMain.d.ts.map +1 -0
- package/dist/types/src/components/CollectionSection.d.ts +6 -0
- package/dist/types/src/components/CollectionSection.d.ts.map +1 -0
- package/dist/types/src/components/EmptySpace.d.ts +3 -0
- package/dist/types/src/components/EmptySpace.d.ts.map +1 -0
- package/dist/types/src/components/EmptyTree.d.ts +3 -0
- package/dist/types/src/components/EmptyTree.d.ts.map +1 -0
- package/dist/types/src/components/MenuFooter.d.ts +6 -0
- package/dist/types/src/components/MenuFooter.d.ts.map +1 -0
- package/dist/types/src/components/MissingObject.d.ts +5 -0
- package/dist/types/src/components/MissingObject.d.ts.map +1 -0
- package/dist/types/src/components/PersistenceStatus.d.ts +6 -0
- package/dist/types/src/components/PersistenceStatus.d.ts.map +1 -0
- package/dist/types/src/components/PopoverRenameObject.d.ts +6 -0
- package/dist/types/src/components/PopoverRenameObject.d.ts.map +1 -0
- package/dist/types/src/components/PopoverRenameSpace.d.ts +6 -0
- package/dist/types/src/components/PopoverRenameSpace.d.ts.map +1 -0
- package/dist/types/src/components/ShareSpaceButton.d.ts +8 -0
- package/dist/types/src/components/ShareSpaceButton.d.ts.map +1 -0
- package/dist/types/src/components/ShareSpaceButton.stories.d.ts +98 -0
- package/dist/types/src/components/ShareSpaceButton.stories.d.ts.map +1 -0
- package/dist/types/src/components/SpaceMain/SpaceMain.d.ts +10 -0
- package/dist/types/src/components/SpaceMain/SpaceMain.d.ts.map +1 -0
- package/dist/types/src/components/SpaceMain/SpaceMembersSection.d.ts +6 -0
- package/dist/types/src/components/SpaceMain/SpaceMembersSection.d.ts.map +1 -0
- package/dist/types/src/components/SpaceMain/index.d.ts +2 -0
- package/dist/types/src/components/SpaceMain/index.d.ts.map +1 -0
- package/dist/types/src/components/SpacePresence.d.ts +34 -0
- package/dist/types/src/components/SpacePresence.d.ts.map +1 -0
- package/dist/types/src/components/SpacePresence.stories.d.ts +97 -0
- package/dist/types/src/components/SpacePresence.stories.d.ts.map +1 -0
- package/dist/types/src/components/SpaceSettings.d.ts +6 -0
- package/dist/types/src/components/SpaceSettings.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +15 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +9 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +26 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +83 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/collection.d.ts +18 -0
- package/dist/types/src/types/collection.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/thread.d.ts +225 -0
- package/dist/types/src/types/thread.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +54 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +85 -0
- package/dist/types/src/util.d.ts.map +1 -0
- package/package.json +101 -0
- package/src/SpacePlugin.tsx +1234 -0
- package/src/components/AwaitingObject.tsx +118 -0
- package/src/components/CollectionMain.tsx +33 -0
- package/src/components/CollectionSection.tsx +20 -0
- package/src/components/EmptySpace.tsx +25 -0
- package/src/components/EmptyTree.tsx +25 -0
- package/src/components/MenuFooter.tsx +33 -0
- package/src/components/MissingObject.tsx +54 -0
- package/src/components/PersistenceStatus.tsx +87 -0
- package/src/components/PopoverRenameObject.tsx +54 -0
- package/src/components/PopoverRenameSpace.tsx +44 -0
- package/src/components/ShareSpaceButton.stories.tsx +23 -0
- package/src/components/ShareSpaceButton.tsx +27 -0
- package/src/components/SpaceMain/SpaceMain.tsx +81 -0
- package/src/components/SpaceMain/SpaceMembersSection.tsx +205 -0
- package/src/components/SpaceMain/index.ts +5 -0
- package/src/components/SpacePresence.stories.tsx +102 -0
- package/src/components/SpacePresence.tsx +244 -0
- package/src/components/SpaceSettings.tsx +34 -0
- package/src/components/index.ts +18 -0
- package/src/index.ts +15 -0
- package/src/meta.ts +31 -0
- package/src/translations.ts +92 -0
- package/src/types/collection.ts +16 -0
- package/src/types/index.ts +7 -0
- package/src/types/thread.ts +68 -0
- package/src/types/types.ts +81 -0
- package/src/util.tsx +642 -0
|
@@ -0,0 +1,2660 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SPACE_PLUGIN,
|
|
3
|
+
SPACE_PLUGIN_SHORT_ID,
|
|
4
|
+
SpaceAction,
|
|
5
|
+
meta_default
|
|
6
|
+
} from "./chunk-LZEGRS7H.mjs";
|
|
7
|
+
import {
|
|
8
|
+
ActorSchema,
|
|
9
|
+
ChannelType,
|
|
10
|
+
CollectionType,
|
|
11
|
+
ContactType,
|
|
12
|
+
MessageType,
|
|
13
|
+
SPACE_DIRECTORY_HANDLE,
|
|
14
|
+
ThreadStatus,
|
|
15
|
+
ThreadType
|
|
16
|
+
} from "./chunk-DTVUOG2C.mjs";
|
|
17
|
+
|
|
18
|
+
// packages/plugins/plugin-space/src/SpacePlugin.tsx
|
|
19
|
+
import { Plus as Plus2, SignIn, CardsThree as CardsThree2, Warning as Warning2 } from "@phosphor-icons/react";
|
|
20
|
+
import { effect, signal } from "@preact/signals-core";
|
|
21
|
+
import React17 from "react";
|
|
22
|
+
import { LayoutAction as LayoutAction2, Surface as Surface2, NavigationAction as NavigationAction3, openIds, firstIdInPart, parseIntentPlugin as parseIntentPlugin3, parseNavigationPlugin as parseNavigationPlugin2, parseMetadataResolverPlugin, resolvePlugin, parseGraphPlugin } from "@dxos/app-framework";
|
|
23
|
+
import { EventSubscriptions } from "@dxos/async";
|
|
24
|
+
import { isReactiveObject as isReactiveObject2 } from "@dxos/echo-schema";
|
|
25
|
+
import { LocalStorageStore } from "@dxos/local-storage";
|
|
26
|
+
import { log as log2 } from "@dxos/log";
|
|
27
|
+
import { Migrations as Migrations2 } from "@dxos/migrations";
|
|
28
|
+
import { parseAttentionPlugin } from "@dxos/plugin-attention";
|
|
29
|
+
import { parseClientPlugin } from "@dxos/plugin-client";
|
|
30
|
+
import { createExtension, isGraphNode, memoize as memoize2, toSignal } from "@dxos/plugin-graph";
|
|
31
|
+
import { ObservabilityAction } from "@dxos/plugin-observability/meta";
|
|
32
|
+
import { PublicKey as PublicKey2 } from "@dxos/react-client";
|
|
33
|
+
import { create as create2, Expando, Filter, fullyQualifiedId as fullyQualifiedId4, getSpace as getSpace4, getTypename as getTypename2, isEchoObject as isEchoObject2, isSpace as isSpace2, loadObjectReferences, SpaceState as SpaceState3 } from "@dxos/react-client/echo";
|
|
34
|
+
import { Dialog } from "@dxos/react-ui";
|
|
35
|
+
import { InvitationManager, osTranslations, ClipboardProvider as ClipboardProvider2 } from "@dxos/shell/react";
|
|
36
|
+
import { ComplexMap as ComplexMap2, nonNullable, reduceGroupBy } from "@dxos/util";
|
|
37
|
+
|
|
38
|
+
// packages/plugins/plugin-space/src/components/AwaitingObject.tsx
|
|
39
|
+
import { CheckCircle, CircleDashed, CircleNotch } from "@phosphor-icons/react";
|
|
40
|
+
import React, { useEffect, useState } from "react";
|
|
41
|
+
import { parseIntentPlugin, useResolvePlugin, parseNavigationPlugin, NavigationAction } from "@dxos/app-framework";
|
|
42
|
+
import { useClient } from "@dxos/react-client";
|
|
43
|
+
import { fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
|
|
44
|
+
import { Button, Toast, useTranslation } from "@dxos/react-ui";
|
|
45
|
+
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
46
|
+
var WAIT_FOR_OBJECT_TIMEOUT = 18e4;
|
|
47
|
+
var TOAST_TIMEOUT = 24e4;
|
|
48
|
+
var AwaitingObject = ({ id }) => {
|
|
49
|
+
const [open, setOpen] = useState(true);
|
|
50
|
+
const [waiting, setWaiting] = useState(true);
|
|
51
|
+
const [found, setFound] = useState(false);
|
|
52
|
+
const { t } = useTranslation(SPACE_PLUGIN);
|
|
53
|
+
const intentPlugin = useResolvePlugin(parseIntentPlugin);
|
|
54
|
+
const navigationPlugin = useResolvePlugin(parseNavigationPlugin);
|
|
55
|
+
const client = useClient();
|
|
56
|
+
const objects = useQuery(client.spaces);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!id) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const timeout = setTimeout(() => {
|
|
62
|
+
setWaiting(false);
|
|
63
|
+
}, WAIT_FOR_OBJECT_TIMEOUT);
|
|
64
|
+
() => clearTimeout(timeout);
|
|
65
|
+
}, [
|
|
66
|
+
id
|
|
67
|
+
]);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (objects.findIndex((object) => fullyQualifiedId(object) === id) > -1) {
|
|
70
|
+
setFound(true);
|
|
71
|
+
if (navigationPlugin?.provides.location.active === id) {
|
|
72
|
+
setOpen(false);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, [
|
|
76
|
+
id,
|
|
77
|
+
objects,
|
|
78
|
+
intentPlugin
|
|
79
|
+
]);
|
|
80
|
+
const handleClose = async () => intentPlugin?.provides.intent.dispatch({
|
|
81
|
+
plugin: SPACE_PLUGIN,
|
|
82
|
+
action: SpaceAction.WAIT_FOR_OBJECT,
|
|
83
|
+
data: {
|
|
84
|
+
id: void 0
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
const handleNavigate = () => {
|
|
88
|
+
void intentPlugin?.provides.intent.dispatch({
|
|
89
|
+
action: NavigationAction.OPEN,
|
|
90
|
+
data: {
|
|
91
|
+
activeParts: {
|
|
92
|
+
main: [
|
|
93
|
+
id
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
void handleClose();
|
|
99
|
+
};
|
|
100
|
+
return /* @__PURE__ */ React.createElement(Toast.Root, {
|
|
101
|
+
open,
|
|
102
|
+
duration: TOAST_TIMEOUT,
|
|
103
|
+
onOpenChange: setOpen
|
|
104
|
+
}, /* @__PURE__ */ React.createElement(Toast.Body, null, /* @__PURE__ */ React.createElement(Toast.Title, {
|
|
105
|
+
classNames: "flex items-center gap-2"
|
|
106
|
+
}, found ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CheckCircle, {
|
|
107
|
+
className: getSize(5)
|
|
108
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("found object label"))) : waiting ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CircleNotch, {
|
|
109
|
+
className: mx(getSize(5), "animate-spin")
|
|
110
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("waiting for object label"))) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CircleDashed, {
|
|
111
|
+
className: getSize(5)
|
|
112
|
+
}), /* @__PURE__ */ React.createElement("span", null, t("object not found label")))), /* @__PURE__ */ React.createElement(Toast.Description, null, t(found ? "found object description" : waiting ? "waiting for object description" : "object not found description"))), /* @__PURE__ */ React.createElement(Toast.Actions, null, found ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Toast.Action, {
|
|
113
|
+
altText: t("go to object alt"),
|
|
114
|
+
asChild: true
|
|
115
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
116
|
+
variant: "primary",
|
|
117
|
+
onClick: handleNavigate
|
|
118
|
+
}, t("go to object label"))), /* @__PURE__ */ React.createElement(Toast.Close, {
|
|
119
|
+
asChild: true
|
|
120
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
121
|
+
onClick: handleClose
|
|
122
|
+
}, t("close label", {
|
|
123
|
+
ns: "appkit"
|
|
124
|
+
})))) : /* @__PURE__ */ React.createElement(Toast.Close, {
|
|
125
|
+
asChild: true
|
|
126
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
127
|
+
onClick: handleClose
|
|
128
|
+
}, t(waiting ? "close label" : "confirm label", {
|
|
129
|
+
ns: "appkit"
|
|
130
|
+
})))));
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// packages/plugins/plugin-space/src/components/CollectionMain.tsx
|
|
134
|
+
import React2 from "react";
|
|
135
|
+
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
136
|
+
import { baseSurface, descriptionText, mx as mx2 } from "@dxos/react-ui-theme";
|
|
137
|
+
var CollectionMain = ({ collection }) => {
|
|
138
|
+
const { t } = useTranslation2(SPACE_PLUGIN);
|
|
139
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
140
|
+
role: "none",
|
|
141
|
+
className: mx2(baseSurface, "min-bs-screen is-full flex items-center justify-center p-8"),
|
|
142
|
+
"data-testid": "composer.firstRunMessage"
|
|
143
|
+
}, /* @__PURE__ */ React2.createElement("p", {
|
|
144
|
+
role: "alert",
|
|
145
|
+
className: mx2(descriptionText, "border border-dashed border-neutral-400/50 rounded-lg p-8 font-normal text-lg max-is-[24rem] break-words")
|
|
146
|
+
}, collection.name ?? t("unnamed collection label")));
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// packages/plugins/plugin-space/src/components/CollectionSection.tsx
|
|
150
|
+
import React3 from "react";
|
|
151
|
+
import { useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
152
|
+
var CollectionSection = ({ collection }) => {
|
|
153
|
+
const { t } = useTranslation3(SPACE_PLUGIN);
|
|
154
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
155
|
+
className: "min-bs-[3.5rem] grid grid-rows-subgrid grid-cols-subgrid items-center"
|
|
156
|
+
}, /* @__PURE__ */ React3.createElement("span", {
|
|
157
|
+
className: "truncate"
|
|
158
|
+
}, collection.name ?? t("unnamed collection label")));
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// packages/plugins/plugin-space/src/components/EmptySpace.tsx
|
|
162
|
+
import React4 from "react";
|
|
163
|
+
import { useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
164
|
+
import { descriptionText as descriptionText2, mx as mx3 } from "@dxos/react-ui-theme";
|
|
165
|
+
var EmptySpace = () => {
|
|
166
|
+
const { t } = useTranslation4(SPACE_PLUGIN);
|
|
167
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
168
|
+
role: "none",
|
|
169
|
+
className: mx3("p-2 mli-2 mbe-2 text-center border border-dashed border-neutral-400/50 rounded-lg", descriptionText2)
|
|
170
|
+
}, t("empty space message"));
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// packages/plugins/plugin-space/src/components/EmptyTree.tsx
|
|
174
|
+
import React5 from "react";
|
|
175
|
+
import { useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
176
|
+
import { descriptionText as descriptionText3, mx as mx4 } from "@dxos/react-ui-theme";
|
|
177
|
+
var EmptyTree = () => {
|
|
178
|
+
const { t } = useTranslation5(SPACE_PLUGIN);
|
|
179
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
180
|
+
role: "none",
|
|
181
|
+
className: mx4("p-2 mli-2 mbe-2 text-center border border-dashed border-neutral-400/50 rounded-lg", descriptionText3)
|
|
182
|
+
}, t("empty tree message"));
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// packages/plugins/plugin-space/src/components/MenuFooter.tsx
|
|
186
|
+
import { Planet as Planet2 } from "@phosphor-icons/react";
|
|
187
|
+
import React7 from "react";
|
|
188
|
+
import { getSpace as getSpace2 } from "@dxos/client/echo";
|
|
189
|
+
import { useClient as useClient2 } from "@dxos/react-client";
|
|
190
|
+
import { DropdownMenu, toLocalizedString, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
191
|
+
|
|
192
|
+
// packages/plugins/plugin-space/src/util.tsx
|
|
193
|
+
import { CardsThree, Database, PencilSimpleLine, Planet, Plus, Trash, Users, X, ClockCounterClockwise, LockSimpleOpen, LockSimple, Placeholder, Link } from "@phosphor-icons/react";
|
|
194
|
+
import React6 from "react";
|
|
195
|
+
import { NavigationAction as NavigationAction2 } from "@dxos/app-framework";
|
|
196
|
+
import { create, isReactiveObject, getTypename, getSchema, getEchoObjectAnnotation, EXPANDO_TYPENAME } from "@dxos/echo-schema";
|
|
197
|
+
import { invariant } from "@dxos/invariant";
|
|
198
|
+
import { Migrations } from "@dxos/migrations";
|
|
199
|
+
import { ACTION_TYPE, ACTION_GROUP_TYPE, actionGroupSymbol, getGraph, cleanup, memoize } from "@dxos/plugin-graph";
|
|
200
|
+
import { SpaceState, fullyQualifiedId as fullyQualifiedId2, getSpace, isEchoObject, isSpace } from "@dxos/react-client/echo";
|
|
201
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/util.tsx";
|
|
202
|
+
var SPACES = `${SPACE_PLUGIN}-spaces`;
|
|
203
|
+
var SPACE_TYPE = "dxos.org/type/Space";
|
|
204
|
+
var COMPOSER_SPACE_LOCK = "dxos.org/plugin/space/lock";
|
|
205
|
+
var SHARED = "shared-spaces";
|
|
206
|
+
var EMPTY_ARRAY = [];
|
|
207
|
+
var memoizeQuery = (spaceOrEcho, filter, options) => {
|
|
208
|
+
const key = isSpace(spaceOrEcho) ? spaceOrEcho.id : void 0;
|
|
209
|
+
const query = memoize(() => isSpace(spaceOrEcho) ? spaceOrEcho.db.query(filter, options) : spaceOrEcho?.query(filter, options), key);
|
|
210
|
+
const unsubscribe = memoize(() => query?.subscribe(), key);
|
|
211
|
+
cleanup(() => unsubscribe?.());
|
|
212
|
+
return query?.objects ?? EMPTY_ARRAY;
|
|
213
|
+
};
|
|
214
|
+
var getSpaceDisplayName = (space, { personal, namesCache = {} } = {}) => {
|
|
215
|
+
return space.state.get() === SpaceState.SPACE_READY && (space.properties.name?.length ?? 0) > 0 ? space.properties.name : namesCache[space.id] ? namesCache[space.id] : personal ? [
|
|
216
|
+
"personal space label",
|
|
217
|
+
{
|
|
218
|
+
ns: SPACE_PLUGIN
|
|
219
|
+
}
|
|
220
|
+
] : [
|
|
221
|
+
"unnamed space label",
|
|
222
|
+
{
|
|
223
|
+
ns: SPACE_PLUGIN
|
|
224
|
+
}
|
|
225
|
+
];
|
|
226
|
+
};
|
|
227
|
+
var getCollectionGraphNodePartials = ({ collection, space, resolve }) => {
|
|
228
|
+
return {
|
|
229
|
+
acceptPersistenceClass: /* @__PURE__ */ new Set([
|
|
230
|
+
"echo"
|
|
231
|
+
]),
|
|
232
|
+
acceptPersistenceKey: /* @__PURE__ */ new Set([
|
|
233
|
+
space.id
|
|
234
|
+
]),
|
|
235
|
+
role: "branch",
|
|
236
|
+
onRearrangeChildren: (nextOrder) => {
|
|
237
|
+
collection.objects = nextOrder.filter(isEchoObject);
|
|
238
|
+
},
|
|
239
|
+
onTransferStart: (child, index) => {
|
|
240
|
+
if (!collection.objects.includes(child.data)) {
|
|
241
|
+
if (typeof index !== "undefined") {
|
|
242
|
+
collection.objects.splice(index, 0, child.data);
|
|
243
|
+
} else {
|
|
244
|
+
collection.objects.push(child.data);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
onTransferEnd: (child, destination) => {
|
|
249
|
+
const index = collection.objects.indexOf(child.data);
|
|
250
|
+
if (index > -1) {
|
|
251
|
+
collection.objects.splice(index, 1);
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
onCopy: async (child, index) => {
|
|
255
|
+
const newObject = await cloneObject(child.data, resolve);
|
|
256
|
+
space.db.add(newObject);
|
|
257
|
+
if (typeof index !== "undefined") {
|
|
258
|
+
collection.objects.splice(index, 0, newObject);
|
|
259
|
+
} else {
|
|
260
|
+
collection.objects.push(newObject);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
var checkPendingMigration = (space) => {
|
|
266
|
+
return space.state.get() === SpaceState.SPACE_REQUIRES_MIGRATION || space.state.get() === SpaceState.SPACE_READY && !!Migrations.versionProperty && space.properties[Migrations.versionProperty] !== Migrations.targetVersion;
|
|
267
|
+
};
|
|
268
|
+
var constructSpaceNode = ({ space, personal, namesCache, resolve }) => {
|
|
269
|
+
const hasPendingMigration = checkPendingMigration(space);
|
|
270
|
+
const collection = space.state.get() === SpaceState.SPACE_READY && space.properties[CollectionType.typename];
|
|
271
|
+
const partials = space.state.get() === SpaceState.SPACE_READY && collection instanceof CollectionType ? getCollectionGraphNodePartials({
|
|
272
|
+
collection,
|
|
273
|
+
space,
|
|
274
|
+
resolve
|
|
275
|
+
}) : {};
|
|
276
|
+
return {
|
|
277
|
+
id: space.id,
|
|
278
|
+
type: SPACE_TYPE,
|
|
279
|
+
data: space,
|
|
280
|
+
properties: {
|
|
281
|
+
...partials,
|
|
282
|
+
label: getSpaceDisplayName(space, {
|
|
283
|
+
personal,
|
|
284
|
+
namesCache
|
|
285
|
+
}),
|
|
286
|
+
description: space.state.get() === SpaceState.SPACE_READY && space.properties.description,
|
|
287
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(Planet, props),
|
|
288
|
+
iconSymbol: "ph--planet--regular",
|
|
289
|
+
disabled: space.state.get() !== SpaceState.SPACE_READY || hasPendingMigration,
|
|
290
|
+
testId: "spacePlugin.space"
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
var constructSpaceActionGroups = ({ space, dispatch }) => {
|
|
295
|
+
const state = space.state.get();
|
|
296
|
+
const hasPendingMigration = checkPendingMigration(space);
|
|
297
|
+
const getId = (id) => `${id}/${space.id}`;
|
|
298
|
+
if (state !== SpaceState.SPACE_READY || hasPendingMigration) {
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
const collection = space.properties[CollectionType.typename];
|
|
302
|
+
const actions = [
|
|
303
|
+
{
|
|
304
|
+
id: getId(SpaceAction.ADD_OBJECT),
|
|
305
|
+
type: ACTION_GROUP_TYPE,
|
|
306
|
+
data: actionGroupSymbol,
|
|
307
|
+
properties: {
|
|
308
|
+
label: [
|
|
309
|
+
"create object in space label",
|
|
310
|
+
{
|
|
311
|
+
ns: SPACE_PLUGIN
|
|
312
|
+
}
|
|
313
|
+
],
|
|
314
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(Plus, props),
|
|
315
|
+
iconSymbol: "ph--plus--regular",
|
|
316
|
+
disposition: "toolbar",
|
|
317
|
+
// TODO(wittjosiah): This is currently a navtree feature. Address this with cmd+k integration.
|
|
318
|
+
// mainAreaDisposition: 'in-flow',
|
|
319
|
+
menuType: "searchList",
|
|
320
|
+
testId: "spacePlugin.createObject"
|
|
321
|
+
},
|
|
322
|
+
nodes: [
|
|
323
|
+
{
|
|
324
|
+
id: getId(SpaceAction.ADD_OBJECT.replace("object", "collection")),
|
|
325
|
+
type: ACTION_TYPE,
|
|
326
|
+
data: () => dispatch([
|
|
327
|
+
{
|
|
328
|
+
plugin: SPACE_PLUGIN,
|
|
329
|
+
action: SpaceAction.ADD_OBJECT,
|
|
330
|
+
data: {
|
|
331
|
+
target: collection,
|
|
332
|
+
object: create(CollectionType, {
|
|
333
|
+
objects: [],
|
|
334
|
+
views: {}
|
|
335
|
+
})
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
action: NavigationAction2.OPEN
|
|
340
|
+
}
|
|
341
|
+
]),
|
|
342
|
+
properties: {
|
|
343
|
+
label: [
|
|
344
|
+
"create collection label",
|
|
345
|
+
{
|
|
346
|
+
ns: SPACE_PLUGIN
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(CardsThree, props),
|
|
350
|
+
iconSymbol: "ph--cards-three--regular",
|
|
351
|
+
testId: "spacePlugin.createCollection"
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
];
|
|
357
|
+
return actions;
|
|
358
|
+
};
|
|
359
|
+
var constructSpaceActions = ({ space, dispatch, personal, migrating }) => {
|
|
360
|
+
const state = space.state.get();
|
|
361
|
+
const hasPendingMigration = checkPendingMigration(space);
|
|
362
|
+
const getId = (id) => `${id}/${space.id}`;
|
|
363
|
+
const actions = [];
|
|
364
|
+
if (hasPendingMigration) {
|
|
365
|
+
actions.push({
|
|
366
|
+
id: getId(SpaceAction.MIGRATE),
|
|
367
|
+
type: ACTION_GROUP_TYPE,
|
|
368
|
+
data: async () => {
|
|
369
|
+
await dispatch({
|
|
370
|
+
plugin: SPACE_PLUGIN,
|
|
371
|
+
action: SpaceAction.MIGRATE,
|
|
372
|
+
data: {
|
|
373
|
+
space
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
properties: {
|
|
378
|
+
label: [
|
|
379
|
+
"migrate space label",
|
|
380
|
+
{
|
|
381
|
+
ns: SPACE_PLUGIN
|
|
382
|
+
}
|
|
383
|
+
],
|
|
384
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(Database, props),
|
|
385
|
+
iconSymbol: "ph--database--regular",
|
|
386
|
+
disposition: "toolbar",
|
|
387
|
+
mainAreaDisposition: "in-flow",
|
|
388
|
+
disabled: migrating || Migrations.running(space)
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
if (state === SpaceState.SPACE_READY && !hasPendingMigration) {
|
|
393
|
+
const locked = space.properties[COMPOSER_SPACE_LOCK];
|
|
394
|
+
actions.push({
|
|
395
|
+
id: getId(SpaceAction.SHARE),
|
|
396
|
+
type: ACTION_TYPE,
|
|
397
|
+
data: async () => {
|
|
398
|
+
if (locked) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
await dispatch({
|
|
402
|
+
plugin: SPACE_PLUGIN,
|
|
403
|
+
action: SpaceAction.SHARE,
|
|
404
|
+
data: {
|
|
405
|
+
spaceId: space.id
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
},
|
|
409
|
+
properties: {
|
|
410
|
+
label: [
|
|
411
|
+
"share space label",
|
|
412
|
+
{
|
|
413
|
+
ns: SPACE_PLUGIN
|
|
414
|
+
}
|
|
415
|
+
],
|
|
416
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(Users, props),
|
|
417
|
+
iconSymbol: "ph--users--regular",
|
|
418
|
+
disabled: locked,
|
|
419
|
+
keyBinding: {
|
|
420
|
+
macos: "meta+.",
|
|
421
|
+
windows: "alt+."
|
|
422
|
+
},
|
|
423
|
+
mainAreaDisposition: "absent"
|
|
424
|
+
}
|
|
425
|
+
}, {
|
|
426
|
+
id: locked ? getId(SpaceAction.UNLOCK) : getId(SpaceAction.LOCK),
|
|
427
|
+
type: ACTION_TYPE,
|
|
428
|
+
data: async () => {
|
|
429
|
+
await dispatch({
|
|
430
|
+
plugin: SPACE_PLUGIN,
|
|
431
|
+
action: locked ? SpaceAction.UNLOCK : SpaceAction.LOCK,
|
|
432
|
+
data: {
|
|
433
|
+
space
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
},
|
|
437
|
+
properties: {
|
|
438
|
+
label: [
|
|
439
|
+
locked ? "unlock space label" : "lock space label",
|
|
440
|
+
{
|
|
441
|
+
ns: SPACE_PLUGIN
|
|
442
|
+
}
|
|
443
|
+
],
|
|
444
|
+
icon: locked ? (props) => /* @__PURE__ */ React6.createElement(LockSimpleOpen, props) : (props) => /* @__PURE__ */ React6.createElement(LockSimple, props),
|
|
445
|
+
iconSymbol: locked ? "ph--lock-simple-open--regular" : "ph--lock-simple--regular"
|
|
446
|
+
}
|
|
447
|
+
}, {
|
|
448
|
+
id: getId(SpaceAction.RENAME),
|
|
449
|
+
type: ACTION_TYPE,
|
|
450
|
+
data: async (params) => {
|
|
451
|
+
await dispatch({
|
|
452
|
+
plugin: SPACE_PLUGIN,
|
|
453
|
+
action: SpaceAction.RENAME,
|
|
454
|
+
data: {
|
|
455
|
+
space,
|
|
456
|
+
...params
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
},
|
|
460
|
+
properties: {
|
|
461
|
+
label: [
|
|
462
|
+
"rename space label",
|
|
463
|
+
{
|
|
464
|
+
ns: SPACE_PLUGIN
|
|
465
|
+
}
|
|
466
|
+
],
|
|
467
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(PencilSimpleLine, props),
|
|
468
|
+
iconSymbol: "ph--pencil-simple-line--regular",
|
|
469
|
+
keyBinding: {
|
|
470
|
+
macos: "shift+F6",
|
|
471
|
+
windows: "shift+F6"
|
|
472
|
+
},
|
|
473
|
+
mainAreaDisposition: "absent"
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
if (state !== SpaceState.SPACE_INACTIVE && !hasPendingMigration) {
|
|
478
|
+
actions.push({
|
|
479
|
+
id: getId(SpaceAction.CLOSE),
|
|
480
|
+
type: ACTION_TYPE,
|
|
481
|
+
data: async () => {
|
|
482
|
+
await dispatch({
|
|
483
|
+
plugin: SPACE_PLUGIN,
|
|
484
|
+
action: SpaceAction.CLOSE,
|
|
485
|
+
data: {
|
|
486
|
+
space
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
},
|
|
490
|
+
properties: {
|
|
491
|
+
label: [
|
|
492
|
+
"close space label",
|
|
493
|
+
{
|
|
494
|
+
ns: SPACE_PLUGIN
|
|
495
|
+
}
|
|
496
|
+
],
|
|
497
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(X, props),
|
|
498
|
+
iconSymbol: "ph--x--regular",
|
|
499
|
+
mainAreaDisposition: "menu",
|
|
500
|
+
disabled: personal
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
if (state === SpaceState.SPACE_INACTIVE) {
|
|
505
|
+
actions.push({
|
|
506
|
+
id: getId(SpaceAction.OPEN),
|
|
507
|
+
type: ACTION_TYPE,
|
|
508
|
+
data: async () => {
|
|
509
|
+
await dispatch({
|
|
510
|
+
plugin: SPACE_PLUGIN,
|
|
511
|
+
action: SpaceAction.OPEN,
|
|
512
|
+
data: {
|
|
513
|
+
space
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
},
|
|
517
|
+
properties: {
|
|
518
|
+
label: [
|
|
519
|
+
"open space label",
|
|
520
|
+
{
|
|
521
|
+
ns: SPACE_PLUGIN
|
|
522
|
+
}
|
|
523
|
+
],
|
|
524
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(ClockCounterClockwise, props),
|
|
525
|
+
iconSymbol: "ph--clock-counter-clockwise--regular",
|
|
526
|
+
disposition: "toolbar",
|
|
527
|
+
mainAreaDisposition: "in-flow"
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
return actions;
|
|
532
|
+
};
|
|
533
|
+
var createObjectNode = ({ object, space, resolve }) => {
|
|
534
|
+
const type = getTypename(object);
|
|
535
|
+
if (!type) {
|
|
536
|
+
return void 0;
|
|
537
|
+
}
|
|
538
|
+
const metadata = resolve(type);
|
|
539
|
+
if (Object.keys(metadata).length === 0) {
|
|
540
|
+
return void 0;
|
|
541
|
+
}
|
|
542
|
+
const partials = object instanceof CollectionType ? getCollectionGraphNodePartials({
|
|
543
|
+
collection: object,
|
|
544
|
+
space,
|
|
545
|
+
resolve
|
|
546
|
+
}) : metadata.graphProps;
|
|
547
|
+
return {
|
|
548
|
+
id: fullyQualifiedId2(object),
|
|
549
|
+
type,
|
|
550
|
+
data: object,
|
|
551
|
+
properties: {
|
|
552
|
+
...partials,
|
|
553
|
+
label: metadata.label?.(object) || object.name || metadata.placeholder || [
|
|
554
|
+
"unnamed object label",
|
|
555
|
+
{
|
|
556
|
+
ns: SPACE_PLUGIN
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
icon: metadata.icon ?? (() => /* @__PURE__ */ React6.createElement(Placeholder, null)),
|
|
560
|
+
iconSymbol: metadata.iconSymbol ?? "ph--placeholder--regular",
|
|
561
|
+
testId: "spacePlugin.object",
|
|
562
|
+
persistenceClass: "echo",
|
|
563
|
+
persistenceKey: space?.id
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
var constructObjectActionGroups = ({ object, dispatch }) => {
|
|
568
|
+
if (!(object instanceof CollectionType)) {
|
|
569
|
+
return [];
|
|
570
|
+
}
|
|
571
|
+
const collection = object;
|
|
572
|
+
const getId = (id) => `${id}/${fullyQualifiedId2(object)}`;
|
|
573
|
+
const actions = [
|
|
574
|
+
{
|
|
575
|
+
id: getId(SpaceAction.ADD_OBJECT),
|
|
576
|
+
type: ACTION_GROUP_TYPE,
|
|
577
|
+
data: actionGroupSymbol,
|
|
578
|
+
properties: {
|
|
579
|
+
label: [
|
|
580
|
+
"create object in collection label",
|
|
581
|
+
{
|
|
582
|
+
ns: SPACE_PLUGIN
|
|
583
|
+
}
|
|
584
|
+
],
|
|
585
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(Plus, props),
|
|
586
|
+
iconSymbol: "ph--plus--regular",
|
|
587
|
+
disposition: "toolbar",
|
|
588
|
+
// TODO(wittjosiah): This is currently a navtree feature. Address this with cmd+k integration.
|
|
589
|
+
// mainAreaDisposition: 'in-flow',
|
|
590
|
+
menuType: "searchList",
|
|
591
|
+
testId: "spacePlugin.createObject"
|
|
592
|
+
},
|
|
593
|
+
nodes: [
|
|
594
|
+
{
|
|
595
|
+
id: getId(SpaceAction.ADD_OBJECT.replace("object", "collection")),
|
|
596
|
+
type: ACTION_TYPE,
|
|
597
|
+
data: () => dispatch([
|
|
598
|
+
{
|
|
599
|
+
plugin: SPACE_PLUGIN,
|
|
600
|
+
action: SpaceAction.ADD_OBJECT,
|
|
601
|
+
data: {
|
|
602
|
+
target: collection,
|
|
603
|
+
object: create(CollectionType, {
|
|
604
|
+
objects: [],
|
|
605
|
+
views: {}
|
|
606
|
+
})
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
action: NavigationAction2.OPEN
|
|
611
|
+
}
|
|
612
|
+
]),
|
|
613
|
+
properties: {
|
|
614
|
+
label: [
|
|
615
|
+
"create collection label",
|
|
616
|
+
{
|
|
617
|
+
ns: SPACE_PLUGIN
|
|
618
|
+
}
|
|
619
|
+
],
|
|
620
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(CardsThree, props),
|
|
621
|
+
iconSymbol: "ph--cards-three--regular",
|
|
622
|
+
testId: "spacePlugin.createCollection"
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
]
|
|
626
|
+
}
|
|
627
|
+
];
|
|
628
|
+
return actions;
|
|
629
|
+
};
|
|
630
|
+
var constructObjectActions = ({ node, dispatch }) => {
|
|
631
|
+
const object = node.data;
|
|
632
|
+
const getId = (id) => `${id}/${fullyQualifiedId2(object)}`;
|
|
633
|
+
const actions = [
|
|
634
|
+
{
|
|
635
|
+
id: getId(SpaceAction.RENAME_OBJECT),
|
|
636
|
+
type: ACTION_TYPE,
|
|
637
|
+
data: async (params) => {
|
|
638
|
+
await dispatch({
|
|
639
|
+
action: SpaceAction.RENAME_OBJECT,
|
|
640
|
+
data: {
|
|
641
|
+
object,
|
|
642
|
+
...params
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
},
|
|
646
|
+
properties: {
|
|
647
|
+
label: [
|
|
648
|
+
object instanceof CollectionType ? "rename collection label" : "rename object label",
|
|
649
|
+
{
|
|
650
|
+
ns: SPACE_PLUGIN
|
|
651
|
+
}
|
|
652
|
+
],
|
|
653
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(PencilSimpleLine, props),
|
|
654
|
+
iconSymbol: "ph--pencil-simple-line--regular",
|
|
655
|
+
// TODO(wittjosiah): Doesn't work.
|
|
656
|
+
// keyBinding: 'shift+F6',
|
|
657
|
+
testId: "spacePlugin.renameObject"
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
id: getId(SpaceAction.REMOVE_OBJECT),
|
|
662
|
+
type: ACTION_TYPE,
|
|
663
|
+
data: async () => {
|
|
664
|
+
const graph = getGraph(node);
|
|
665
|
+
const collection = graph.nodes(node, {
|
|
666
|
+
relation: "inbound"
|
|
667
|
+
}).find(({ data }) => data instanceof CollectionType)?.data;
|
|
668
|
+
await dispatch([
|
|
669
|
+
{
|
|
670
|
+
action: SpaceAction.REMOVE_OBJECT,
|
|
671
|
+
data: {
|
|
672
|
+
object,
|
|
673
|
+
collection
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
]);
|
|
677
|
+
},
|
|
678
|
+
properties: {
|
|
679
|
+
label: [
|
|
680
|
+
object instanceof CollectionType ? "delete collection label" : "delete object label",
|
|
681
|
+
{
|
|
682
|
+
ns: SPACE_PLUGIN
|
|
683
|
+
}
|
|
684
|
+
],
|
|
685
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(Trash, props),
|
|
686
|
+
iconSymbol: "ph--trash--regular",
|
|
687
|
+
keyBinding: object instanceof CollectionType ? void 0 : "shift+meta+Backspace",
|
|
688
|
+
testId: "spacePlugin.deleteObject"
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
id: getId("copy-link"),
|
|
693
|
+
type: ACTION_TYPE,
|
|
694
|
+
data: async () => {
|
|
695
|
+
const url = `${window.location.origin}/${fullyQualifiedId2(object)}`;
|
|
696
|
+
await navigator.clipboard.writeText(url);
|
|
697
|
+
},
|
|
698
|
+
properties: {
|
|
699
|
+
label: [
|
|
700
|
+
"copy link label",
|
|
701
|
+
{
|
|
702
|
+
ns: SPACE_PLUGIN
|
|
703
|
+
}
|
|
704
|
+
],
|
|
705
|
+
icon: (props) => /* @__PURE__ */ React6.createElement(Link, props),
|
|
706
|
+
iconSymbol: "ph--link--regular",
|
|
707
|
+
testId: "spacePlugin.copyLink"
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
];
|
|
711
|
+
return actions;
|
|
712
|
+
};
|
|
713
|
+
var getActiveSpace = (graph, active) => {
|
|
714
|
+
if (!active) {
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
const node = graph.findNode(active);
|
|
718
|
+
if (!node || !isReactiveObject(node.data)) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
return getSpace(node.data);
|
|
722
|
+
};
|
|
723
|
+
var getNestedObjects = async (object, resolve) => {
|
|
724
|
+
const type = getTypename(object);
|
|
725
|
+
if (!type) {
|
|
726
|
+
return [];
|
|
727
|
+
}
|
|
728
|
+
const metadata = resolve(type);
|
|
729
|
+
const loadReferences = metadata.loadReferences;
|
|
730
|
+
if (typeof loadReferences !== "function") {
|
|
731
|
+
return [];
|
|
732
|
+
}
|
|
733
|
+
const objects = await loadReferences(object);
|
|
734
|
+
const nested = await Promise.all(objects.map((object2) => getNestedObjects(object2, resolve)));
|
|
735
|
+
return [
|
|
736
|
+
...objects,
|
|
737
|
+
...nested.flat()
|
|
738
|
+
];
|
|
739
|
+
};
|
|
740
|
+
var cloneObject = async (object, resolve) => {
|
|
741
|
+
const schema = getSchema(object);
|
|
742
|
+
const typename = schema ? getEchoObjectAnnotation(schema)?.typename ?? EXPANDO_TYPENAME : EXPANDO_TYPENAME;
|
|
743
|
+
const metadata = resolve(typename);
|
|
744
|
+
const serializer = metadata.serializer;
|
|
745
|
+
invariant(serializer, `No serializer for type: ${typename}`, {
|
|
746
|
+
F: __dxlog_file,
|
|
747
|
+
L: 639,
|
|
748
|
+
S: void 0,
|
|
749
|
+
A: [
|
|
750
|
+
"serializer",
|
|
751
|
+
"`No serializer for type: ${typename}`"
|
|
752
|
+
]
|
|
753
|
+
});
|
|
754
|
+
const content = await serializer.serialize({
|
|
755
|
+
object
|
|
756
|
+
});
|
|
757
|
+
return serializer.deserialize({
|
|
758
|
+
content,
|
|
759
|
+
newId: true
|
|
760
|
+
});
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// packages/plugins/plugin-space/src/components/MenuFooter.tsx
|
|
764
|
+
var MenuFooter = ({ object }) => {
|
|
765
|
+
const { t } = useTranslation6(SPACE_PLUGIN);
|
|
766
|
+
const client = useClient2();
|
|
767
|
+
const space = getSpace2(object);
|
|
768
|
+
const spaceName = space ? getSpaceDisplayName(space, {
|
|
769
|
+
personal: client.spaces.default === space
|
|
770
|
+
}) : "";
|
|
771
|
+
return space ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(DropdownMenu.Separator, null), /* @__PURE__ */ React7.createElement(DropdownMenu.GroupLabel, null, t("menu footer label")), /* @__PURE__ */ React7.createElement("dl", {
|
|
772
|
+
className: "pis-2 mbe-2 text-xs grid grid-cols-[max-content_1fr] gap-2"
|
|
773
|
+
}, /* @__PURE__ */ React7.createElement("dt", {
|
|
774
|
+
className: "uppercase text-[.75em] tracking-wide font-medium mbs-px self-start"
|
|
775
|
+
}, t("location label")), /* @__PURE__ */ React7.createElement("dd", {
|
|
776
|
+
className: "line-clamp-3"
|
|
777
|
+
}, /* @__PURE__ */ React7.createElement(Planet2, {
|
|
778
|
+
className: "inline-block mie-1"
|
|
779
|
+
}), toLocalizedString(spaceName, t)))) : null;
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
// packages/plugins/plugin-space/src/components/MissingObject.tsx
|
|
783
|
+
import React8, { useEffect as useEffect2, useState as useState2 } from "react";
|
|
784
|
+
import { parseIntentPlugin as parseIntentPlugin2, useResolvePlugin as useResolvePlugin2 } from "@dxos/app-framework";
|
|
785
|
+
import { Status, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
786
|
+
import { baseSurface as baseSurface2, descriptionText as descriptionText4, mx as mx5 } from "@dxos/react-ui-theme";
|
|
787
|
+
var WAIT_FOR_OBJECT_TIMEOUT2 = 1e3;
|
|
788
|
+
var MissingObject = ({ id }) => {
|
|
789
|
+
const { t } = useTranslation7(SPACE_PLUGIN);
|
|
790
|
+
const [waiting, setWaiting] = useState2(false);
|
|
791
|
+
const intentPlugin = useResolvePlugin2(parseIntentPlugin2);
|
|
792
|
+
useEffect2(() => {
|
|
793
|
+
if (!intentPlugin) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
const timeout = setTimeout(async () => {
|
|
797
|
+
setWaiting(true);
|
|
798
|
+
await intentPlugin.provides.intent.dispatch({
|
|
799
|
+
plugin: SPACE_PLUGIN,
|
|
800
|
+
action: SpaceAction.WAIT_FOR_OBJECT,
|
|
801
|
+
data: {
|
|
802
|
+
id
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
}, WAIT_FOR_OBJECT_TIMEOUT2);
|
|
806
|
+
return () => clearTimeout(timeout);
|
|
807
|
+
}, [
|
|
808
|
+
intentPlugin,
|
|
809
|
+
id
|
|
810
|
+
]);
|
|
811
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
812
|
+
role: "none",
|
|
813
|
+
className: mx5(baseSurface2, "min-bs-screen is-full flex items-center justify-center p-8")
|
|
814
|
+
}, waiting ? /* @__PURE__ */ React8.createElement("p", {
|
|
815
|
+
role: "alert",
|
|
816
|
+
className: mx5(descriptionText4, "border border-dashed border-neutral-400/50 rounded-lg flex items-center justify-center p-8 font-normal text-lg")
|
|
817
|
+
}, t("missing object message")) : /* @__PURE__ */ React8.createElement(Status, {
|
|
818
|
+
indeterminate: true,
|
|
819
|
+
"aria-label": "Initializing"
|
|
820
|
+
}));
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
// packages/plugins/plugin-space/src/components/PersistenceStatus.tsx
|
|
824
|
+
import { ArrowsCounterClockwise, CheckCircle as CheckCircle2, Warning } from "@phosphor-icons/react";
|
|
825
|
+
import React9, { useEffect as useEffect3, useState as useState3 } from "react";
|
|
826
|
+
import { debounce } from "@dxos/async";
|
|
827
|
+
import { Tooltip, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
828
|
+
import { getSize as getSize2, mx as mx6, staticPlaceholderText, warningText } from "@dxos/react-ui-theme";
|
|
829
|
+
var Status2;
|
|
830
|
+
(function(Status3) {
|
|
831
|
+
Status3[Status3["PERSISTED_LOCALLY"] = 0] = "PERSISTED_LOCALLY";
|
|
832
|
+
Status3[Status3["PENDING"] = 1] = "PENDING";
|
|
833
|
+
Status3[Status3["ERROR"] = 2] = "ERROR";
|
|
834
|
+
})(Status2 || (Status2 = {}));
|
|
835
|
+
var PersistenceStatus = ({ db }) => {
|
|
836
|
+
const { t } = useTranslation8(SPACE_PLUGIN);
|
|
837
|
+
const [displayMessage, setDisplayMessage] = useState3(false);
|
|
838
|
+
const [status, naturalSetStatus] = useState3(0);
|
|
839
|
+
const [prevStatus, setPrevStatus] = useState3(0);
|
|
840
|
+
const _setStatus = debounce(naturalSetStatus, 500);
|
|
841
|
+
useEffect3(() => {
|
|
842
|
+
setPrevStatus(status);
|
|
843
|
+
if (prevStatus !== status && status === 0) {
|
|
844
|
+
setDisplayMessage(true);
|
|
845
|
+
const timeout = setTimeout(() => setDisplayMessage(false), 5e3);
|
|
846
|
+
return () => clearTimeout(timeout);
|
|
847
|
+
}
|
|
848
|
+
}, [
|
|
849
|
+
status
|
|
850
|
+
]);
|
|
851
|
+
switch (status) {
|
|
852
|
+
case 2:
|
|
853
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
854
|
+
className: "flex items-center"
|
|
855
|
+
}, /* @__PURE__ */ React9.createElement(Warning, {
|
|
856
|
+
className: mx6(getSize2(4), "me-1")
|
|
857
|
+
}), /* @__PURE__ */ React9.createElement("span", {
|
|
858
|
+
className: mx6("text-sm", warningText)
|
|
859
|
+
}, t("persistence error label")));
|
|
860
|
+
case 1:
|
|
861
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
862
|
+
className: "flex items-center"
|
|
863
|
+
}, /* @__PURE__ */ React9.createElement(ArrowsCounterClockwise, {
|
|
864
|
+
className: mx6(getSize2(4), "me-1")
|
|
865
|
+
}), /* @__PURE__ */ React9.createElement("span", {
|
|
866
|
+
className: mx6("text-sm", staticPlaceholderText)
|
|
867
|
+
}, t("persistence pending label")));
|
|
868
|
+
case 0:
|
|
869
|
+
default:
|
|
870
|
+
return /* @__PURE__ */ React9.createElement(Tooltip.Root, {
|
|
871
|
+
delayDuration: 400
|
|
872
|
+
}, /* @__PURE__ */ React9.createElement(Tooltip.Trigger, {
|
|
873
|
+
role: "status",
|
|
874
|
+
className: "flex items-center"
|
|
875
|
+
}, /* @__PURE__ */ React9.createElement(CheckCircle2, {
|
|
876
|
+
className: mx6(getSize2(4), "me-1")
|
|
877
|
+
}), displayMessage && /* @__PURE__ */ React9.createElement("span", {
|
|
878
|
+
className: mx6("text-sm", staticPlaceholderText)
|
|
879
|
+
}, t("persisted locally label"))), /* @__PURE__ */ React9.createElement(Tooltip.Portal, null, /* @__PURE__ */ React9.createElement(Tooltip.Content, {
|
|
880
|
+
classNames: "z-10"
|
|
881
|
+
}, t("persisted locally message"), /* @__PURE__ */ React9.createElement(Tooltip.Arrow, null))));
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
// packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx
|
|
886
|
+
import React10, { useCallback, useRef, useState as useState4 } from "react";
|
|
887
|
+
import { log } from "@dxos/log";
|
|
888
|
+
import { Button as Button2, Input, Popover, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
889
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/components/PopoverRenameObject.tsx";
|
|
890
|
+
var PopoverRenameObject = ({ object: obj }) => {
|
|
891
|
+
const { t } = useTranslation9(SPACE_PLUGIN);
|
|
892
|
+
const doneButton = useRef(null);
|
|
893
|
+
const object = obj;
|
|
894
|
+
const [name, setName] = useState4(object.name || object.title || "");
|
|
895
|
+
const handleDone = useCallback(() => {
|
|
896
|
+
try {
|
|
897
|
+
object.name = name;
|
|
898
|
+
} catch {
|
|
899
|
+
try {
|
|
900
|
+
object.title = name;
|
|
901
|
+
} catch (err) {
|
|
902
|
+
log.error("Failed to rename object", {
|
|
903
|
+
err
|
|
904
|
+
}, {
|
|
905
|
+
F: __dxlog_file2,
|
|
906
|
+
L: 28,
|
|
907
|
+
S: void 0,
|
|
908
|
+
C: (f, a) => f(...a)
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}, [
|
|
913
|
+
object,
|
|
914
|
+
name
|
|
915
|
+
]);
|
|
916
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
917
|
+
role: "none",
|
|
918
|
+
className: "p-1 flex gap-2"
|
|
919
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
920
|
+
role: "none",
|
|
921
|
+
className: "flex-1"
|
|
922
|
+
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Label, {
|
|
923
|
+
srOnly: true
|
|
924
|
+
}, t("object name label")), /* @__PURE__ */ React10.createElement(Input.TextInput, {
|
|
925
|
+
placeholder: t("object title placeholder"),
|
|
926
|
+
value: name,
|
|
927
|
+
"data-testid": "spacePlugin.renameObject.input",
|
|
928
|
+
onChange: ({ target: { value } }) => setName(value),
|
|
929
|
+
onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
|
|
930
|
+
}))), /* @__PURE__ */ React10.createElement(Popover.Close, {
|
|
931
|
+
asChild: true
|
|
932
|
+
}, /* @__PURE__ */ React10.createElement(Button2, {
|
|
933
|
+
ref: doneButton,
|
|
934
|
+
classNames: "self-stretch",
|
|
935
|
+
onClick: handleDone
|
|
936
|
+
}, t("done label", {
|
|
937
|
+
ns: "os"
|
|
938
|
+
}))));
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
// packages/plugins/plugin-space/src/components/PopoverRenameSpace.tsx
|
|
942
|
+
import React11, { useCallback as useCallback2, useRef as useRef2, useState as useState5 } from "react";
|
|
943
|
+
import { Button as Button3, Input as Input2, Popover as Popover2, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
944
|
+
var PopoverRenameSpace = ({ space }) => {
|
|
945
|
+
const { t } = useTranslation10(SPACE_PLUGIN);
|
|
946
|
+
const doneButton = useRef2(null);
|
|
947
|
+
const [name, setName] = useState5(space.properties.name ?? "");
|
|
948
|
+
const handleDone = useCallback2(() => {
|
|
949
|
+
space.properties.name = name;
|
|
950
|
+
}, [
|
|
951
|
+
space,
|
|
952
|
+
name
|
|
953
|
+
]);
|
|
954
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
955
|
+
role: "none",
|
|
956
|
+
className: "p-1 flex gap-2"
|
|
957
|
+
}, /* @__PURE__ */ React11.createElement("div", {
|
|
958
|
+
role: "none",
|
|
959
|
+
className: "flex-1"
|
|
960
|
+
}, /* @__PURE__ */ React11.createElement(Input2.Root, null, /* @__PURE__ */ React11.createElement(Input2.Label, {
|
|
961
|
+
srOnly: true
|
|
962
|
+
}, t("space name label")), /* @__PURE__ */ React11.createElement(Input2.TextInput, {
|
|
963
|
+
defaultValue: space.properties.name ?? "",
|
|
964
|
+
placeholder: t("unnamed space label"),
|
|
965
|
+
onChange: ({ target: { value } }) => setName(value),
|
|
966
|
+
// TODO(wittjosiah): Ideally this should access the popover context to close the popover.
|
|
967
|
+
// Currently this is not possible because Radix does not expose the popover context.
|
|
968
|
+
onKeyDown: ({ key }) => key === "Enter" && doneButton.current?.click()
|
|
969
|
+
}))), /* @__PURE__ */ React11.createElement(Popover2.Close, {
|
|
970
|
+
asChild: true
|
|
971
|
+
}, /* @__PURE__ */ React11.createElement(Button3, {
|
|
972
|
+
ref: doneButton,
|
|
973
|
+
classNames: "self-stretch",
|
|
974
|
+
onClick: handleDone
|
|
975
|
+
}, t("done label", {
|
|
976
|
+
ns: "os"
|
|
977
|
+
}))));
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
// packages/plugins/plugin-space/src/components/ShareSpaceButton.tsx
|
|
981
|
+
import React12 from "react";
|
|
982
|
+
import { useIntentDispatcher } from "@dxos/app-framework";
|
|
983
|
+
import { Button as Button4, useTranslation as useTranslation11 } from "@dxos/react-ui";
|
|
984
|
+
var ShareSpaceButton = ({ spaceId }) => {
|
|
985
|
+
const dispatch = useIntentDispatcher();
|
|
986
|
+
return /* @__PURE__ */ React12.createElement(ShareSpaceButtonImpl, {
|
|
987
|
+
onClick: () => dispatch({
|
|
988
|
+
action: SpaceAction.SHARE,
|
|
989
|
+
data: {
|
|
990
|
+
spaceId
|
|
991
|
+
}
|
|
992
|
+
})
|
|
993
|
+
});
|
|
994
|
+
};
|
|
995
|
+
var ShareSpaceButtonImpl = ({ onClick }) => {
|
|
996
|
+
const { t } = useTranslation11(SPACE_PLUGIN);
|
|
997
|
+
return /* @__PURE__ */ React12.createElement(Button4, {
|
|
998
|
+
"data-testid": "spacePlugin.shareSpaceButton",
|
|
999
|
+
onClick,
|
|
1000
|
+
classNames: "mli-1"
|
|
1001
|
+
}, t("share space label"));
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
// packages/plugins/plugin-space/src/components/SpaceMain/SpaceMain.tsx
|
|
1005
|
+
import { Command } from "@phosphor-icons/react";
|
|
1006
|
+
import React14 from "react";
|
|
1007
|
+
import { Surface } from "@dxos/app-framework";
|
|
1008
|
+
import { SpaceState as SpaceState2 } from "@dxos/react-client/echo";
|
|
1009
|
+
import { Button as Button6, Main, useTranslation as useTranslation13, toLocalizedString as toLocalizedString2 } from "@dxos/react-ui";
|
|
1010
|
+
import { getSize as getSize4, mx as mx8, topbarBlockPaddingStart } from "@dxos/react-ui-theme";
|
|
1011
|
+
import { ClipboardProvider } from "@dxos/shell/react";
|
|
1012
|
+
|
|
1013
|
+
// packages/plugins/plugin-space/src/components/SpaceMain/SpaceMembersSection.tsx
|
|
1014
|
+
import { CaretDown, Check, UserPlus, UsersThree } from "@phosphor-icons/react";
|
|
1015
|
+
import React13, { useCallback as useCallback3, useState as useState6 } from "react";
|
|
1016
|
+
import { LayoutAction, useIntent } from "@dxos/app-framework";
|
|
1017
|
+
import { useMembers, SpaceMember, useSpaceInvitations } from "@dxos/react-client/echo";
|
|
1018
|
+
import { InvitationEncoder } from "@dxos/react-client/invitations";
|
|
1019
|
+
import { Invitation } from "@dxos/react-client/invitations";
|
|
1020
|
+
import { Button as Button5, ButtonGroup, DropdownMenu as DropdownMenu2, List, useTranslation as useTranslation12 } from "@dxos/react-ui";
|
|
1021
|
+
import { descriptionText as descriptionText5, getSize as getSize3, mx as mx7 } from "@dxos/react-ui-theme";
|
|
1022
|
+
import { InvitationListItem, IdentityListItem } from "@dxos/shell/react";
|
|
1023
|
+
var activeActionKeyStorageKey = "dxos:react-shell/space-manager/active-action";
|
|
1024
|
+
var Presence = SpaceMember.PresenceState;
|
|
1025
|
+
var handleCreateInvitationUrl = (invitationCode) => `${origin}?spaceInvitationCode=${invitationCode}`;
|
|
1026
|
+
var SpaceMemberList = ({ members }) => {
|
|
1027
|
+
return members.length > 0 ? /* @__PURE__ */ React13.createElement(List, {
|
|
1028
|
+
classNames: "col-start-2 col-end-5 gap-y-1 grid grid-cols-subgrid items-center"
|
|
1029
|
+
}, members.map((member) => /* @__PURE__ */ React13.createElement(IdentityListItem, {
|
|
1030
|
+
classNames: "contents",
|
|
1031
|
+
key: member.identity.identityKey.toHex(),
|
|
1032
|
+
identity: member.identity,
|
|
1033
|
+
presence: member.presence
|
|
1034
|
+
}))) : null;
|
|
1035
|
+
};
|
|
1036
|
+
var SpaceMembersSection = ({ space }) => {
|
|
1037
|
+
const { t } = useTranslation12(SPACE_PLUGIN);
|
|
1038
|
+
const invitations = useSpaceInvitations(space.key);
|
|
1039
|
+
const { dispatch } = useIntent();
|
|
1040
|
+
const handleCloseDialog = () => dispatch({
|
|
1041
|
+
action: LayoutAction.SET_LAYOUT,
|
|
1042
|
+
data: {
|
|
1043
|
+
element: "dialog",
|
|
1044
|
+
state: false
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
const handleInvitationSelect = ({ invitation: invitationObservable }) => {
|
|
1048
|
+
const invitation = invitationObservable.get();
|
|
1049
|
+
void dispatch({
|
|
1050
|
+
action: LayoutAction.SET_LAYOUT,
|
|
1051
|
+
data: {
|
|
1052
|
+
element: "dialog",
|
|
1053
|
+
component: "dxos.org/plugin/space/InvitationManagerDialog",
|
|
1054
|
+
subject: {
|
|
1055
|
+
invitationUrl: handleCreateInvitationUrl(InvitationEncoder.encode(invitation)),
|
|
1056
|
+
send: handleCloseDialog,
|
|
1057
|
+
status: invitation.state,
|
|
1058
|
+
type: invitation.type,
|
|
1059
|
+
authCode: invitation.authCode,
|
|
1060
|
+
id: invitation.invitationId
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
};
|
|
1065
|
+
const inviteActions = {
|
|
1066
|
+
inviteOne: {
|
|
1067
|
+
label: t("invite one label", {
|
|
1068
|
+
ns: "os"
|
|
1069
|
+
}),
|
|
1070
|
+
description: t("invite one description", {
|
|
1071
|
+
ns: "os"
|
|
1072
|
+
}),
|
|
1073
|
+
icon: UserPlus,
|
|
1074
|
+
onClick: useCallback3(() => {
|
|
1075
|
+
space.share?.({
|
|
1076
|
+
type: Invitation.Type.INTERACTIVE,
|
|
1077
|
+
authMethod: Invitation.AuthMethod.SHARED_SECRET
|
|
1078
|
+
});
|
|
1079
|
+
}, [
|
|
1080
|
+
space
|
|
1081
|
+
])
|
|
1082
|
+
},
|
|
1083
|
+
inviteMany: {
|
|
1084
|
+
label: t("invite many label", {
|
|
1085
|
+
ns: "os"
|
|
1086
|
+
}),
|
|
1087
|
+
description: t("invite many description", {
|
|
1088
|
+
ns: "os"
|
|
1089
|
+
}),
|
|
1090
|
+
icon: UsersThree,
|
|
1091
|
+
onClick: useCallback3(() => {
|
|
1092
|
+
space.share?.({
|
|
1093
|
+
type: Invitation.Type.INTERACTIVE,
|
|
1094
|
+
authMethod: Invitation.AuthMethod.NONE,
|
|
1095
|
+
multiUse: true
|
|
1096
|
+
});
|
|
1097
|
+
}, [
|
|
1098
|
+
space
|
|
1099
|
+
])
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
const [activeActionKey, setInternalActiveActionKey] = useState6(localStorage.getItem(activeActionKeyStorageKey) ?? "inviteOne");
|
|
1103
|
+
const setActiveActionKey = (nextKey) => {
|
|
1104
|
+
setInternalActiveActionKey(nextKey);
|
|
1105
|
+
localStorage.setItem(activeActionKeyStorageKey, nextKey);
|
|
1106
|
+
};
|
|
1107
|
+
const activeAction = inviteActions[activeActionKey] ?? {};
|
|
1108
|
+
const members = useMembers(space.key).reduce((acc, member) => {
|
|
1109
|
+
acc[member.presence].push(member);
|
|
1110
|
+
return acc;
|
|
1111
|
+
}, {
|
|
1112
|
+
[Presence.ONLINE]: [],
|
|
1113
|
+
[Presence.OFFLINE]: []
|
|
1114
|
+
});
|
|
1115
|
+
return /* @__PURE__ */ React13.createElement("section", {
|
|
1116
|
+
className: "mbe-4 col-span-3 grid gap-y-2 grid-cols-subgrid auto-rows-min"
|
|
1117
|
+
}, /* @__PURE__ */ React13.createElement("h2", {
|
|
1118
|
+
className: "contents"
|
|
1119
|
+
}, /* @__PURE__ */ React13.createElement(UsersThree, {
|
|
1120
|
+
weight: "duotone",
|
|
1121
|
+
className: mx7(getSize3(5), "place-self-center")
|
|
1122
|
+
}), /* @__PURE__ */ React13.createElement("span", {
|
|
1123
|
+
className: "text-lg col-span-2"
|
|
1124
|
+
}, t("space members label"))), /* @__PURE__ */ React13.createElement("h3", {
|
|
1125
|
+
className: "col-start-2 col-span-3 text-sm italic fg-description"
|
|
1126
|
+
}, t("invitations heading")), invitations.length > 0 && /* @__PURE__ */ React13.createElement(List, {
|
|
1127
|
+
classNames: "col-start-2 col-span-2 gap-y-2 grid grid-cols-[var(--rail-size)_1fr_var(--rail-action)_var(--rail-action)]"
|
|
1128
|
+
}, invitations.map((invitation) => /* @__PURE__ */ React13.createElement(InvitationListItem, {
|
|
1129
|
+
reverseEffects: true,
|
|
1130
|
+
classNames: "pis-0 pie-0 gap-0 col-span-4 grid grid-cols-subgrid",
|
|
1131
|
+
key: invitation.get().invitationId,
|
|
1132
|
+
invitation,
|
|
1133
|
+
send: handleInvitationSelect,
|
|
1134
|
+
createInvitationUrl: handleCreateInvitationUrl
|
|
1135
|
+
}))), /* @__PURE__ */ React13.createElement(ButtonGroup, {
|
|
1136
|
+
classNames: "col-start-2 col-end-4 grid grid-cols-[1fr_var(--rail-action)] place-self-grow gap-px"
|
|
1137
|
+
}, /* @__PURE__ */ React13.createElement(Button5, {
|
|
1138
|
+
classNames: "gap-2",
|
|
1139
|
+
onClick: activeAction.onClick
|
|
1140
|
+
}, /* @__PURE__ */ React13.createElement(activeAction.icon, {
|
|
1141
|
+
className: getSize3(5)
|
|
1142
|
+
}), /* @__PURE__ */ React13.createElement("span", null, t(activeAction.label, {
|
|
1143
|
+
ns: "os"
|
|
1144
|
+
}))), /* @__PURE__ */ React13.createElement(DropdownMenu2.Root, null, /* @__PURE__ */ React13.createElement(DropdownMenu2.Trigger, {
|
|
1145
|
+
asChild: true
|
|
1146
|
+
}, /* @__PURE__ */ React13.createElement(Button5, {
|
|
1147
|
+
classNames: "pli-0"
|
|
1148
|
+
}, /* @__PURE__ */ React13.createElement(CaretDown, {
|
|
1149
|
+
className: getSize3(4)
|
|
1150
|
+
}))), /* @__PURE__ */ React13.createElement(DropdownMenu2.Content, null, /* @__PURE__ */ React13.createElement(DropdownMenu2.Viewport, null, Object.entries(inviteActions).map(([id, action]) => {
|
|
1151
|
+
return /* @__PURE__ */ React13.createElement(DropdownMenu2.CheckboxItem, {
|
|
1152
|
+
key: id,
|
|
1153
|
+
"aria-labelledby": `${id}__label`,
|
|
1154
|
+
"aria-describedby": `${id}__description`,
|
|
1155
|
+
checked: activeActionKey === id,
|
|
1156
|
+
onCheckedChange: (checked) => checked && setActiveActionKey(id),
|
|
1157
|
+
classNames: "gap-2"
|
|
1158
|
+
}, action.icon && /* @__PURE__ */ React13.createElement(action.icon, {
|
|
1159
|
+
className: getSize3(5)
|
|
1160
|
+
}), /* @__PURE__ */ React13.createElement("div", {
|
|
1161
|
+
role: "none",
|
|
1162
|
+
className: "flex-1 min-is-0 space-b-1"
|
|
1163
|
+
}, /* @__PURE__ */ React13.createElement("p", {
|
|
1164
|
+
id: `${id}__label`
|
|
1165
|
+
}, t(action.label, {
|
|
1166
|
+
ns: "os"
|
|
1167
|
+
})), action.description && /* @__PURE__ */ React13.createElement("p", {
|
|
1168
|
+
id: `${id}__description`,
|
|
1169
|
+
className: descriptionText5
|
|
1170
|
+
}, t(action.description, {
|
|
1171
|
+
ns: "os"
|
|
1172
|
+
}))), /* @__PURE__ */ React13.createElement(DropdownMenu2.ItemIndicator, {
|
|
1173
|
+
asChild: true
|
|
1174
|
+
}, /* @__PURE__ */ React13.createElement(Check, {
|
|
1175
|
+
className: getSize3(4)
|
|
1176
|
+
})));
|
|
1177
|
+
})), /* @__PURE__ */ React13.createElement(DropdownMenu2.Arrow, null)))), members[Presence.ONLINE].length + members[Presence.OFFLINE].length < 1 ? /* @__PURE__ */ React13.createElement("p", {
|
|
1178
|
+
className: mx7(descriptionText5, "text-center is-full mlb-2")
|
|
1179
|
+
}, t("empty space members message", {
|
|
1180
|
+
ns: "os"
|
|
1181
|
+
})) : /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement("h3", {
|
|
1182
|
+
className: "col-start-2 col-end-5 text-sm italic fg-description"
|
|
1183
|
+
}, t("active space members heading", {
|
|
1184
|
+
count: members[Presence.ONLINE].length
|
|
1185
|
+
})), /* @__PURE__ */ React13.createElement(SpaceMemberList, {
|
|
1186
|
+
members: members[Presence.ONLINE]
|
|
1187
|
+
}), /* @__PURE__ */ React13.createElement("h3", {
|
|
1188
|
+
className: "col-start-2 col-end-5 text-sm italic fg-description"
|
|
1189
|
+
}, t("inactive space members heading", {
|
|
1190
|
+
count: members[Presence.OFFLINE].length
|
|
1191
|
+
})), /* @__PURE__ */ React13.createElement(SpaceMemberList, {
|
|
1192
|
+
members: members[Presence.OFFLINE]
|
|
1193
|
+
})));
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
// packages/plugins/plugin-space/src/components/SpaceMain/SpaceMain.tsx
|
|
1197
|
+
var KeyShortcuts = () => {
|
|
1198
|
+
const { t } = useTranslation13(SPACE_PLUGIN);
|
|
1199
|
+
return /* @__PURE__ */ React14.createElement("section", {
|
|
1200
|
+
className: "mbe-4 col-span-4 md:col-start-5 md:col-end-7 grid grid-cols-subgrid gap-y-2 auto-rows-min"
|
|
1201
|
+
}, /* @__PURE__ */ React14.createElement("h2", {
|
|
1202
|
+
className: "contents"
|
|
1203
|
+
}, /* @__PURE__ */ React14.createElement(Command, {
|
|
1204
|
+
weight: "duotone",
|
|
1205
|
+
className: mx8(getSize4(5), "place-self-center")
|
|
1206
|
+
}), /* @__PURE__ */ React14.createElement("span", {
|
|
1207
|
+
className: "text-lg col-span-2 md:col-span-1"
|
|
1208
|
+
}, t("keyshortcuts label"))), /* @__PURE__ */ React14.createElement("div", {
|
|
1209
|
+
role: "none",
|
|
1210
|
+
className: "col-start-2 col-end-4 md:col-end-5 pie-2"
|
|
1211
|
+
}, /* @__PURE__ */ React14.createElement(Surface, {
|
|
1212
|
+
role: "keyshortcuts"
|
|
1213
|
+
})));
|
|
1214
|
+
};
|
|
1215
|
+
var spaceMainLayout = "grid gap-y-2 auto-rows-min before:bs-2 before:col-span-5 grid-cols-[var(--rail-size)_var(--rail-size)_1fr_var(--rail-size)] md:grid-cols-[var(--rail-size)_var(--rail-size)_minmax(max-content,1fr)_var(--rail-size)_var(--rail-size)_minmax(max-content,2fr)_var(--rail-size)]";
|
|
1216
|
+
var SpaceMain = ({ space, role }) => {
|
|
1217
|
+
const state = space.state.get();
|
|
1218
|
+
const ready = state === SpaceState2.SPACE_READY;
|
|
1219
|
+
const Root = role === "main" ? Main.Content : "div";
|
|
1220
|
+
return /* @__PURE__ */ React14.createElement(ClipboardProvider, null, /* @__PURE__ */ React14.createElement(Root, {
|
|
1221
|
+
...role === "main" ? {
|
|
1222
|
+
classNames: [
|
|
1223
|
+
topbarBlockPaddingStart,
|
|
1224
|
+
"min-bs-dvh",
|
|
1225
|
+
spaceMainLayout
|
|
1226
|
+
]
|
|
1227
|
+
} : {
|
|
1228
|
+
role: "none",
|
|
1229
|
+
className: mx8(topbarBlockPaddingStart, "row-span-2", spaceMainLayout)
|
|
1230
|
+
},
|
|
1231
|
+
"data-testid": `spacePlugin.${role}`,
|
|
1232
|
+
"data-isready": ready ? "true" : "false"
|
|
1233
|
+
}, ready && /* @__PURE__ */ React14.createElement(SpaceMembersSection, {
|
|
1234
|
+
space
|
|
1235
|
+
}), /* @__PURE__ */ React14.createElement(KeyShortcuts, null)));
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// packages/plugins/plugin-space/src/components/SpacePresence.tsx
|
|
1239
|
+
import React15, { useCallback as useCallback4, useEffect as useEffect4, useState as useState7 } from "react";
|
|
1240
|
+
import { usePlugin } from "@dxos/app-framework";
|
|
1241
|
+
import { generateName } from "@dxos/display-name";
|
|
1242
|
+
import { PublicKey, useClient as useClient3 } from "@dxos/react-client";
|
|
1243
|
+
import { getSpace as getSpace3, useMembers as useMembers2, fullyQualifiedId as fullyQualifiedId3 } from "@dxos/react-client/echo";
|
|
1244
|
+
import { useIdentity } from "@dxos/react-client/halo";
|
|
1245
|
+
import { Avatar, AvatarGroup, AvatarGroupItem, Tooltip as Tooltip2, useDensityContext, useTranslation as useTranslation14, List as List2, ListItem, useDefaultValue } from "@dxos/react-ui";
|
|
1246
|
+
import { AttentionGlyphCloseButton } from "@dxos/react-ui-attention";
|
|
1247
|
+
import { ComplexMap, keyToFallback } from "@dxos/util";
|
|
1248
|
+
var REFRESH_INTERVAL = 5e3;
|
|
1249
|
+
var ACTIVITY_DURATION = 3e4;
|
|
1250
|
+
var noViewers = new ComplexMap(PublicKey.hash);
|
|
1251
|
+
var getName = (identity) => identity.profile?.displayName ?? generateName(identity.identityKey.toHex());
|
|
1252
|
+
var SpacePresence = ({ object, spaceKey }) => {
|
|
1253
|
+
const density = useDensityContext();
|
|
1254
|
+
const spacePlugin = usePlugin(SPACE_PLUGIN);
|
|
1255
|
+
const client = useClient3();
|
|
1256
|
+
const identity = useIdentity();
|
|
1257
|
+
const space = spaceKey ? client.spaces.get(spaceKey) : getSpace3(object);
|
|
1258
|
+
const spaceMembers = useMembers2(space?.key);
|
|
1259
|
+
const [_moment, setMoment] = useState7(Date.now());
|
|
1260
|
+
useEffect4(() => {
|
|
1261
|
+
const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
|
|
1262
|
+
return () => clearInterval(interval);
|
|
1263
|
+
}, []);
|
|
1264
|
+
const memberOnline = useCallback4((member) => member.presence === 1, []);
|
|
1265
|
+
const memberIsNotSelf = useCallback4((member) => !identity?.identityKey.equals(member.identity.identityKey), [
|
|
1266
|
+
identity?.identityKey
|
|
1267
|
+
]);
|
|
1268
|
+
if (!identity || !spacePlugin || !space) {
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1271
|
+
const spaceState = spacePlugin.provides.space;
|
|
1272
|
+
const currentObjectViewers = spaceState.viewersByObject[fullyQualifiedId3(object)] ?? noViewers;
|
|
1273
|
+
const membersForObject = spaceMembers.filter((member) => memberOnline(member) && memberIsNotSelf(member)).filter((member) => currentObjectViewers.has(member.identity.identityKey)).map((member) => {
|
|
1274
|
+
const objectView = currentObjectViewers.get(member.identity.identityKey);
|
|
1275
|
+
const lastSeen = objectView?.lastSeen ?? -Infinity;
|
|
1276
|
+
const currentlyAttended = objectView?.currentlyAttended ?? false;
|
|
1277
|
+
return {
|
|
1278
|
+
...member,
|
|
1279
|
+
currentlyAttended,
|
|
1280
|
+
lastSeen
|
|
1281
|
+
};
|
|
1282
|
+
}).toSorted((a, b) => a.lastSeen - b.lastSeen);
|
|
1283
|
+
return density === "fine" ? /* @__PURE__ */ React15.createElement(SmallPresence, {
|
|
1284
|
+
count: membersForObject.length
|
|
1285
|
+
}) : /* @__PURE__ */ React15.createElement(FullPresence, {
|
|
1286
|
+
members: membersForObject
|
|
1287
|
+
});
|
|
1288
|
+
};
|
|
1289
|
+
var FullPresence = (props) => {
|
|
1290
|
+
const { size = 9, onMemberClick } = props;
|
|
1291
|
+
const members = useDefaultValue(props.members, []);
|
|
1292
|
+
if (members.length === 0) {
|
|
1293
|
+
return null;
|
|
1294
|
+
}
|
|
1295
|
+
return /* @__PURE__ */ React15.createElement(AvatarGroup.Root, {
|
|
1296
|
+
size,
|
|
1297
|
+
classNames: "mbs-2 mie-4",
|
|
1298
|
+
"data-testid": "spacePlugin.presence"
|
|
1299
|
+
}, members.slice(0, 3).map((member, i) => /* @__PURE__ */ React15.createElement(Tooltip2.Root, {
|
|
1300
|
+
key: member.identity.identityKey.toHex()
|
|
1301
|
+
}, /* @__PURE__ */ React15.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React15.createElement(PrensenceAvatar, {
|
|
1302
|
+
identity: member.identity,
|
|
1303
|
+
group: true,
|
|
1304
|
+
match: member.currentlyAttended,
|
|
1305
|
+
index: members.length - i,
|
|
1306
|
+
onClick: () => onMemberClick?.(member)
|
|
1307
|
+
})), /* @__PURE__ */ React15.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React15.createElement(Tooltip2.Content, {
|
|
1308
|
+
side: "bottom"
|
|
1309
|
+
}, /* @__PURE__ */ React15.createElement("span", null, getName(member.identity)), /* @__PURE__ */ React15.createElement(Tooltip2.Arrow, null))))), members.length > 3 && /* @__PURE__ */ React15.createElement(Tooltip2.Root, null, /* @__PURE__ */ React15.createElement(Tooltip2.Trigger, null, /* @__PURE__ */ React15.createElement(AvatarGroupItem.Root, {
|
|
1310
|
+
status: "inactive"
|
|
1311
|
+
}, /* @__PURE__ */ React15.createElement(Avatar.Frame, {
|
|
1312
|
+
style: {
|
|
1313
|
+
zIndex: members.length - 4
|
|
1314
|
+
}
|
|
1315
|
+
}, /* @__PURE__ */ React15.createElement(Avatar.Fallback, {
|
|
1316
|
+
text: `+${members.length - 3}`
|
|
1317
|
+
})))), /* @__PURE__ */ React15.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React15.createElement(Tooltip2.Content, {
|
|
1318
|
+
side: "bottom"
|
|
1319
|
+
}, /* @__PURE__ */ React15.createElement(Tooltip2.Arrow, null), /* @__PURE__ */ React15.createElement(List2, {
|
|
1320
|
+
classNames: "max-h-56 overflow-y-auto"
|
|
1321
|
+
}, members.map((member) => /* @__PURE__ */ React15.createElement(ListItem.Root, {
|
|
1322
|
+
key: member.identity.identityKey.toHex(),
|
|
1323
|
+
classNames: "flex gap-2 items-center cursor-pointer mbe-2",
|
|
1324
|
+
onClick: () => onMemberClick?.(member),
|
|
1325
|
+
"data-testid": "identity-list-item"
|
|
1326
|
+
}, /* @__PURE__ */ React15.createElement(PrensenceAvatar, {
|
|
1327
|
+
identity: member.identity,
|
|
1328
|
+
showName: true,
|
|
1329
|
+
match: member.currentlyAttended
|
|
1330
|
+
}))))))));
|
|
1331
|
+
};
|
|
1332
|
+
var PrensenceAvatar = ({ identity, showName, match, group, index, onClick }) => {
|
|
1333
|
+
const Root = group ? AvatarGroupItem.Root : Avatar.Root;
|
|
1334
|
+
const status = match ? "current" : "active";
|
|
1335
|
+
const fallbackValue = keyToFallback(identity.identityKey);
|
|
1336
|
+
return /* @__PURE__ */ React15.createElement(Root, {
|
|
1337
|
+
status,
|
|
1338
|
+
hue: identity.profile?.data?.hue || fallbackValue.hue
|
|
1339
|
+
}, /* @__PURE__ */ React15.createElement(Avatar.Frame, {
|
|
1340
|
+
"data-testid": "spacePlugin.presence.member",
|
|
1341
|
+
"data-status": status,
|
|
1342
|
+
...index ? {
|
|
1343
|
+
style: {
|
|
1344
|
+
zIndex: index
|
|
1345
|
+
}
|
|
1346
|
+
} : {},
|
|
1347
|
+
onClick: () => onClick?.()
|
|
1348
|
+
}, /* @__PURE__ */ React15.createElement(Avatar.Fallback, {
|
|
1349
|
+
text: identity.profile?.data?.emoji || fallbackValue.emoji
|
|
1350
|
+
})), showName && /* @__PURE__ */ React15.createElement(Avatar.Label, {
|
|
1351
|
+
classNames: "text-sm truncate pli-2"
|
|
1352
|
+
}, getName(identity)));
|
|
1353
|
+
};
|
|
1354
|
+
var SmallPresenceLive = ({ viewers, onCloseClick }) => {
|
|
1355
|
+
const [moment, setMoment] = useState7(Date.now());
|
|
1356
|
+
useEffect4(() => {
|
|
1357
|
+
const interval = setInterval(() => setMoment(Date.now()), REFRESH_INTERVAL);
|
|
1358
|
+
return () => clearInterval(interval);
|
|
1359
|
+
}, []);
|
|
1360
|
+
const activeViewers = viewers ? Array.from(viewers.values()).filter(({ lastSeen }) => moment - lastSeen < ACTIVITY_DURATION) : [];
|
|
1361
|
+
return /* @__PURE__ */ React15.createElement(SmallPresence, {
|
|
1362
|
+
count: activeViewers.length,
|
|
1363
|
+
onCloseClick
|
|
1364
|
+
});
|
|
1365
|
+
};
|
|
1366
|
+
var SmallPresence = ({ count, onCloseClick }) => {
|
|
1367
|
+
const { t } = useTranslation14(SPACE_PLUGIN);
|
|
1368
|
+
return /* @__PURE__ */ React15.createElement(Tooltip2.Root, null, /* @__PURE__ */ React15.createElement(Tooltip2.Trigger, {
|
|
1369
|
+
asChild: true
|
|
1370
|
+
}, /* @__PURE__ */ React15.createElement(AttentionGlyphCloseButton, {
|
|
1371
|
+
presence: count > 1 ? "many" : count === 1 ? "one" : "none",
|
|
1372
|
+
classNames: "self-center mie-1",
|
|
1373
|
+
onClick: onCloseClick
|
|
1374
|
+
})), /* @__PURE__ */ React15.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React15.createElement(Tooltip2.Content, {
|
|
1375
|
+
side: "bottom",
|
|
1376
|
+
classNames: "z-[70]"
|
|
1377
|
+
}, /* @__PURE__ */ React15.createElement("span", null, t("presence label", {
|
|
1378
|
+
count
|
|
1379
|
+
})), /* @__PURE__ */ React15.createElement(Tooltip2.Arrow, null))));
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
// packages/plugins/plugin-space/src/components/SpaceSettings.tsx
|
|
1383
|
+
import React16 from "react";
|
|
1384
|
+
import { useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
1385
|
+
import { SettingsValue } from "@dxos/plugin-settings";
|
|
1386
|
+
import { Input as Input3, useTranslation as useTranslation15 } from "@dxos/react-ui";
|
|
1387
|
+
var SpaceSettings = ({ settings }) => {
|
|
1388
|
+
const { t } = useTranslation15(SPACE_PLUGIN);
|
|
1389
|
+
const dispatch = useIntentDispatcher2();
|
|
1390
|
+
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(SettingsValue, {
|
|
1391
|
+
label: t("show hidden spaces label")
|
|
1392
|
+
}, /* @__PURE__ */ React16.createElement(Input3.Switch, {
|
|
1393
|
+
checked: settings.showHidden,
|
|
1394
|
+
onCheckedChange: (checked) => dispatch({
|
|
1395
|
+
plugin: SPACE_PLUGIN,
|
|
1396
|
+
action: SpaceAction.TOGGLE_HIDDEN,
|
|
1397
|
+
data: {
|
|
1398
|
+
state: !!checked
|
|
1399
|
+
}
|
|
1400
|
+
})
|
|
1401
|
+
})));
|
|
1402
|
+
};
|
|
1403
|
+
|
|
1404
|
+
// packages/plugins/plugin-space/src/translations.ts
|
|
1405
|
+
var translations_default = [
|
|
1406
|
+
{
|
|
1407
|
+
"en-US": {
|
|
1408
|
+
[SPACE_PLUGIN]: {
|
|
1409
|
+
"plugin name": "Spaces",
|
|
1410
|
+
"first run message": "Nothing selected.",
|
|
1411
|
+
"create space label": "Create a new space",
|
|
1412
|
+
"join space label": "Join a space",
|
|
1413
|
+
"empty space message": "No documents",
|
|
1414
|
+
"empty tree message": "No spaces",
|
|
1415
|
+
"unnamed space label": "New space",
|
|
1416
|
+
"closed space label": "Closed",
|
|
1417
|
+
"loading space label": "Loading space\u2026",
|
|
1418
|
+
"lock space label": "Lock space",
|
|
1419
|
+
"unlock space label": "Unlock space",
|
|
1420
|
+
"rename space label": "Rename space",
|
|
1421
|
+
"active space label": "Active space:",
|
|
1422
|
+
"space name label": "Space name",
|
|
1423
|
+
"object name label": "Object name",
|
|
1424
|
+
"close space label": "Close space",
|
|
1425
|
+
"open space label": "Open space",
|
|
1426
|
+
"export data label": "Export data",
|
|
1427
|
+
"import data label": "Import data",
|
|
1428
|
+
"migrate space label": "Migrate space",
|
|
1429
|
+
"share space": "Share space",
|
|
1430
|
+
"save space to disk label": "Save to disk",
|
|
1431
|
+
"load space from disk label": "Load from disk",
|
|
1432
|
+
"confirm restore title": "Overwrite files in this space?",
|
|
1433
|
+
"confirm restore body": "Restoring from a backup will overwrite the contents of any documents that match.",
|
|
1434
|
+
"upload file message": "Drag file here or click to browse",
|
|
1435
|
+
"object title placeholder": "Type a title here\u2026",
|
|
1436
|
+
"personal space label": "Personal Space",
|
|
1437
|
+
"spaces label": "Spaces",
|
|
1438
|
+
"show hidden spaces label": "Show closed spaces",
|
|
1439
|
+
"save files to directory label": "Save files to disk",
|
|
1440
|
+
"select path label": "Select path",
|
|
1441
|
+
"rename collection label": "Rename collection",
|
|
1442
|
+
"rename object label": "Rename item",
|
|
1443
|
+
"duplicate object label": "Duplicate item",
|
|
1444
|
+
"delete collection label": "Delete collection",
|
|
1445
|
+
"delete object label": "Delete item",
|
|
1446
|
+
"collection deleted label": "Collection deleted",
|
|
1447
|
+
"object deleted label": "Item deleted",
|
|
1448
|
+
"go to object label": "Open item",
|
|
1449
|
+
"found object label": "Ready.",
|
|
1450
|
+
"found object description": "The requested object is now available.",
|
|
1451
|
+
"waiting for object label": "Loading\u2026",
|
|
1452
|
+
"waiting for object description": "The requested object is still being synchronized.",
|
|
1453
|
+
"object not found label": "Nothing found.",
|
|
1454
|
+
"object not found description": "The requested object has not been found yet. Ensure there are enough peers online in the space with an updated copy.",
|
|
1455
|
+
"missing object message": "Object not available.",
|
|
1456
|
+
"missing object description": "The requested object has not been found yet. Ensure there are enough peers online in the space with an updated copy.",
|
|
1457
|
+
"create collection label": "Create collection",
|
|
1458
|
+
"unnamed object label": "New object",
|
|
1459
|
+
"unnamed collection label": "New collection",
|
|
1460
|
+
"create object in space label": "Add to space",
|
|
1461
|
+
"create object in collection label": "Add to collection",
|
|
1462
|
+
"share space label": "Share",
|
|
1463
|
+
"space members label": "Space members",
|
|
1464
|
+
"active space members heading": "Online ({{count}})",
|
|
1465
|
+
"inactive space members heading": "Offline ({{count}})",
|
|
1466
|
+
"presence label_zero": "No other viewers",
|
|
1467
|
+
"presence label_one": "1 other viewer",
|
|
1468
|
+
"presence label_other": "{{count}} other viewers",
|
|
1469
|
+
"persisted locally label": "Changes saved locally.",
|
|
1470
|
+
"persisted locally message": "All changes have been saved to disk on this device.",
|
|
1471
|
+
"persistence pending label": "Saving\u2026",
|
|
1472
|
+
"persistence error label": "Error saving changes.",
|
|
1473
|
+
"more actions label": "More actions",
|
|
1474
|
+
"invitations heading": "Invitations",
|
|
1475
|
+
"keyshortcuts label": "Keyboard shortcuts",
|
|
1476
|
+
"menu footer label": "Details",
|
|
1477
|
+
"location label": "Located in",
|
|
1478
|
+
"space limit label": "Space Limit Reached",
|
|
1479
|
+
"space limit description": "This space has reached the maximum number of objects for the beta. This limit includes deleted objects currently, but those can be permanently removed with the cleanup action.",
|
|
1480
|
+
"space limit close label": "Close",
|
|
1481
|
+
"remove deleted objects label": "Cleanup",
|
|
1482
|
+
"remove deleted objects alt": "Permanently remove deleted objects to free up space.",
|
|
1483
|
+
"copy link label": "Copy link"
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
];
|
|
1488
|
+
|
|
1489
|
+
// packages/plugins/plugin-space/src/SpacePlugin.tsx
|
|
1490
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/SpacePlugin.tsx";
|
|
1491
|
+
var ACTIVE_NODE_BROADCAST_INTERVAL = 3e4;
|
|
1492
|
+
var OBJECT_ID_LENGTH = 60;
|
|
1493
|
+
var SPACE_MAX_OBJECTS = 500;
|
|
1494
|
+
var DIRECTORY_TYPE = "text/directory";
|
|
1495
|
+
var parseSpacePlugin = (plugin) => Array.isArray(plugin?.provides.space?.enabled) ? plugin : void 0;
|
|
1496
|
+
var SpacePlugin = ({ firstRun, onFirstRun } = {}) => {
|
|
1497
|
+
const settings = new LocalStorageStore(SPACE_PLUGIN);
|
|
1498
|
+
const state = new LocalStorageStore(SPACE_PLUGIN, {
|
|
1499
|
+
awaiting: void 0,
|
|
1500
|
+
spaceNames: {},
|
|
1501
|
+
viewersByObject: {},
|
|
1502
|
+
viewersByIdentity: new ComplexMap2(PublicKey2.hash),
|
|
1503
|
+
sdkMigrationRunning: {}
|
|
1504
|
+
});
|
|
1505
|
+
const subscriptions = new EventSubscriptions();
|
|
1506
|
+
const spaceSubscriptions = new EventSubscriptions();
|
|
1507
|
+
const graphSubscriptions = /* @__PURE__ */ new Map();
|
|
1508
|
+
let clientPlugin;
|
|
1509
|
+
let intentPlugin;
|
|
1510
|
+
let navigationPlugin;
|
|
1511
|
+
let attentionPlugin;
|
|
1512
|
+
const onSpaceReady = async () => {
|
|
1513
|
+
if (!clientPlugin || !navigationPlugin || !attentionPlugin) {
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
const client = clientPlugin.provides.client;
|
|
1517
|
+
const location = navigationPlugin.provides.location;
|
|
1518
|
+
const attention = attentionPlugin.provides.attention;
|
|
1519
|
+
const defaultSpace = client.spaces.default;
|
|
1520
|
+
if (typeof defaultSpace.properties[COMPOSER_SPACE_LOCK] !== "boolean") {
|
|
1521
|
+
defaultSpace.properties[COMPOSER_SPACE_LOCK] = true;
|
|
1522
|
+
}
|
|
1523
|
+
const { objects: [spacesOrder] } = await defaultSpace.db.query(Filter.schema(Expando, {
|
|
1524
|
+
key: SHARED
|
|
1525
|
+
})).run();
|
|
1526
|
+
if (!spacesOrder) {
|
|
1527
|
+
defaultSpace.db.add(create2({
|
|
1528
|
+
key: SHARED,
|
|
1529
|
+
order: []
|
|
1530
|
+
}));
|
|
1531
|
+
}
|
|
1532
|
+
subscriptions.add(client.spaces.subscribe(async (spaces) => {
|
|
1533
|
+
if (defaultSpace.state.get() === SpaceState3.SPACE_REQUIRES_MIGRATION) {
|
|
1534
|
+
await defaultSpace.internal.migrate();
|
|
1535
|
+
}
|
|
1536
|
+
spaces.filter((space) => space.state.get() === SpaceState3.SPACE_READY).forEach((space) => {
|
|
1537
|
+
subscriptions.add(effect(() => {
|
|
1538
|
+
state.values.spaceNames[space.id] = space.properties.name;
|
|
1539
|
+
}));
|
|
1540
|
+
});
|
|
1541
|
+
}).unsubscribe);
|
|
1542
|
+
subscriptions.add(effect(() => {
|
|
1543
|
+
const send = () => {
|
|
1544
|
+
const spaces = client.spaces.get();
|
|
1545
|
+
const identity = client.halo.identity.get();
|
|
1546
|
+
if (identity && location.active) {
|
|
1547
|
+
const ids = openIds(location.active);
|
|
1548
|
+
const idsBySpace = reduceGroupBy(ids, (id) => {
|
|
1549
|
+
const [spaceId] = id.split(":");
|
|
1550
|
+
return spaceId;
|
|
1551
|
+
});
|
|
1552
|
+
for (const space of spaces) {
|
|
1553
|
+
if (!idsBySpace.has(space.id)) {
|
|
1554
|
+
idsBySpace.set(space.id, []);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
for (const [spaceId, ids2] of idsBySpace) {
|
|
1558
|
+
const space = spaces.find((space2) => space2.id === spaceId);
|
|
1559
|
+
if (!space) {
|
|
1560
|
+
continue;
|
|
1561
|
+
}
|
|
1562
|
+
const removed = location.closed ? [
|
|
1563
|
+
location.closed
|
|
1564
|
+
].flat() : [];
|
|
1565
|
+
void space.postMessage("viewing", {
|
|
1566
|
+
identityKey: identity.identityKey.toHex(),
|
|
1567
|
+
attended: attention.attended ? [
|
|
1568
|
+
...attention.attended
|
|
1569
|
+
] : [],
|
|
1570
|
+
added: ids2,
|
|
1571
|
+
// TODO(Zan): When we re-open a part, we should remove it from the removed list in the navigation plugin.
|
|
1572
|
+
removed: removed.filter((id) => !ids2.includes(id))
|
|
1573
|
+
}).catch((err) => {
|
|
1574
|
+
log2.warn("Failed to broadcast active node for presence.", {
|
|
1575
|
+
err: err.message
|
|
1576
|
+
}, {
|
|
1577
|
+
F: __dxlog_file3,
|
|
1578
|
+
L: 223,
|
|
1579
|
+
S: void 0,
|
|
1580
|
+
C: (f, a) => f(...a)
|
|
1581
|
+
});
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
send();
|
|
1587
|
+
const interval = setInterval(() => send(), ACTIVE_NODE_BROADCAST_INTERVAL);
|
|
1588
|
+
return () => clearInterval(interval);
|
|
1589
|
+
}));
|
|
1590
|
+
subscriptions.add(client.spaces.subscribe((spaces) => {
|
|
1591
|
+
spaceSubscriptions.clear();
|
|
1592
|
+
spaces.forEach((space) => {
|
|
1593
|
+
spaceSubscriptions.add(space.listen("viewing", (message) => {
|
|
1594
|
+
const { added, removed, attended } = message.payload;
|
|
1595
|
+
const identityKey = PublicKey2.safeFrom(message.payload.identityKey);
|
|
1596
|
+
if (identityKey && Array.isArray(added) && Array.isArray(removed)) {
|
|
1597
|
+
added.forEach((id) => {
|
|
1598
|
+
if (typeof id === "string") {
|
|
1599
|
+
if (!(id in state.values.viewersByObject)) {
|
|
1600
|
+
state.values.viewersByObject[id] = new ComplexMap2(PublicKey2.hash);
|
|
1601
|
+
}
|
|
1602
|
+
state.values.viewersByObject[id].set(identityKey, {
|
|
1603
|
+
lastSeen: Date.now(),
|
|
1604
|
+
currentlyAttended: new Set(attended).has(id)
|
|
1605
|
+
});
|
|
1606
|
+
if (!state.values.viewersByIdentity.has(identityKey)) {
|
|
1607
|
+
state.values.viewersByIdentity.set(identityKey, /* @__PURE__ */ new Set());
|
|
1608
|
+
}
|
|
1609
|
+
state.values.viewersByIdentity.get(identityKey).add(id);
|
|
1610
|
+
}
|
|
1611
|
+
});
|
|
1612
|
+
removed.forEach((id) => {
|
|
1613
|
+
if (typeof id === "string") {
|
|
1614
|
+
state.values.viewersByObject[id]?.delete(identityKey);
|
|
1615
|
+
state.values.viewersByIdentity.get(identityKey)?.delete(id);
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
}));
|
|
1620
|
+
});
|
|
1621
|
+
}).unsubscribe);
|
|
1622
|
+
};
|
|
1623
|
+
return {
|
|
1624
|
+
meta: meta_default,
|
|
1625
|
+
ready: async (plugins) => {
|
|
1626
|
+
settings.prop({
|
|
1627
|
+
key: "showHidden",
|
|
1628
|
+
storageKey: "show-hidden",
|
|
1629
|
+
type: LocalStorageStore.bool({
|
|
1630
|
+
allowUndefined: true
|
|
1631
|
+
})
|
|
1632
|
+
});
|
|
1633
|
+
state.prop({
|
|
1634
|
+
key: "spaceNames",
|
|
1635
|
+
storageKey: "space-names",
|
|
1636
|
+
type: LocalStorageStore.json()
|
|
1637
|
+
});
|
|
1638
|
+
navigationPlugin = resolvePlugin(plugins, parseNavigationPlugin2);
|
|
1639
|
+
attentionPlugin = resolvePlugin(plugins, parseAttentionPlugin);
|
|
1640
|
+
clientPlugin = resolvePlugin(plugins, parseClientPlugin);
|
|
1641
|
+
intentPlugin = resolvePlugin(plugins, parseIntentPlugin3);
|
|
1642
|
+
if (!clientPlugin || !intentPlugin) {
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
const client = clientPlugin.provides.client;
|
|
1646
|
+
const dispatch = intentPlugin.provides.intent.dispatch;
|
|
1647
|
+
const handleFirstRun = async () => {
|
|
1648
|
+
const defaultSpace = client.spaces.default;
|
|
1649
|
+
const personalSpaceCollection = create2(CollectionType, {
|
|
1650
|
+
objects: [],
|
|
1651
|
+
views: {}
|
|
1652
|
+
});
|
|
1653
|
+
defaultSpace.properties[CollectionType.typename] = personalSpaceCollection;
|
|
1654
|
+
if (Migrations2.versionProperty) {
|
|
1655
|
+
defaultSpace.properties[Migrations2.versionProperty] = Migrations2.targetVersion;
|
|
1656
|
+
}
|
|
1657
|
+
await onFirstRun?.({
|
|
1658
|
+
client,
|
|
1659
|
+
dispatch
|
|
1660
|
+
});
|
|
1661
|
+
};
|
|
1662
|
+
client.spaces.isReady.subscribe(async (ready) => {
|
|
1663
|
+
if (ready) {
|
|
1664
|
+
await clientPlugin?.provides.client.spaces.default.waitUntilReady();
|
|
1665
|
+
if (firstRun) {
|
|
1666
|
+
void firstRun?.wait().then(handleFirstRun);
|
|
1667
|
+
} else {
|
|
1668
|
+
await handleFirstRun();
|
|
1669
|
+
}
|
|
1670
|
+
await onSpaceReady();
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
},
|
|
1674
|
+
unload: async () => {
|
|
1675
|
+
settings.close();
|
|
1676
|
+
spaceSubscriptions.clear();
|
|
1677
|
+
subscriptions.clear();
|
|
1678
|
+
graphSubscriptions.forEach((cb) => cb());
|
|
1679
|
+
graphSubscriptions.clear();
|
|
1680
|
+
},
|
|
1681
|
+
provides: {
|
|
1682
|
+
space: state.values,
|
|
1683
|
+
settings: settings.values,
|
|
1684
|
+
translations: [
|
|
1685
|
+
...translations_default,
|
|
1686
|
+
osTranslations
|
|
1687
|
+
],
|
|
1688
|
+
root: () => state.values.awaiting ? /* @__PURE__ */ React17.createElement(AwaitingObject, {
|
|
1689
|
+
id: state.values.awaiting
|
|
1690
|
+
}) : null,
|
|
1691
|
+
metadata: {
|
|
1692
|
+
records: {
|
|
1693
|
+
[CollectionType.typename]: {
|
|
1694
|
+
placeholder: [
|
|
1695
|
+
"unnamed collection label",
|
|
1696
|
+
{
|
|
1697
|
+
ns: SPACE_PLUGIN
|
|
1698
|
+
}
|
|
1699
|
+
],
|
|
1700
|
+
icon: (props) => /* @__PURE__ */ React17.createElement(CardsThree2, props),
|
|
1701
|
+
iconSymbol: "ph--cards-three--regular",
|
|
1702
|
+
// TODO(wittjosiah): Move out of metadata.
|
|
1703
|
+
loadReferences: (collection) => loadObjectReferences(collection, (collection2) => [
|
|
1704
|
+
...collection2.objects,
|
|
1705
|
+
...Object.values(collection2.views)
|
|
1706
|
+
])
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
},
|
|
1710
|
+
echo: {
|
|
1711
|
+
schema: [
|
|
1712
|
+
CollectionType
|
|
1713
|
+
]
|
|
1714
|
+
},
|
|
1715
|
+
surface: {
|
|
1716
|
+
component: ({ data, role, ...rest }) => {
|
|
1717
|
+
const primary = data.active ?? data.object;
|
|
1718
|
+
switch (role) {
|
|
1719
|
+
case "article":
|
|
1720
|
+
case "main":
|
|
1721
|
+
return isSpace2(primary) && primary.state.get() === SpaceState3.SPACE_READY ? /* @__PURE__ */ React17.createElement(Surface2, {
|
|
1722
|
+
data: {
|
|
1723
|
+
active: primary.properties[CollectionType.typename]
|
|
1724
|
+
},
|
|
1725
|
+
role,
|
|
1726
|
+
...rest
|
|
1727
|
+
}) : primary instanceof CollectionType ? {
|
|
1728
|
+
node: /* @__PURE__ */ React17.createElement(CollectionMain, {
|
|
1729
|
+
collection: primary
|
|
1730
|
+
}),
|
|
1731
|
+
disposition: "fallback"
|
|
1732
|
+
} : typeof primary === "string" && primary.length === OBJECT_ID_LENGTH ? /* @__PURE__ */ React17.createElement(MissingObject, {
|
|
1733
|
+
id: primary
|
|
1734
|
+
}) : null;
|
|
1735
|
+
case "tree--empty":
|
|
1736
|
+
switch (true) {
|
|
1737
|
+
case data.plugin === SPACE_PLUGIN:
|
|
1738
|
+
return /* @__PURE__ */ React17.createElement(EmptyTree, null);
|
|
1739
|
+
case (isGraphNode(data.activeNode) && isSpace2(data.activeNode.data)):
|
|
1740
|
+
return /* @__PURE__ */ React17.createElement(EmptySpace, null);
|
|
1741
|
+
default:
|
|
1742
|
+
return null;
|
|
1743
|
+
}
|
|
1744
|
+
case "dialog":
|
|
1745
|
+
if (data.component === "dxos.org/plugin/space/InvitationManagerDialog") {
|
|
1746
|
+
return /* @__PURE__ */ React17.createElement(Dialog.Content, null, /* @__PURE__ */ React17.createElement(ClipboardProvider2, null, /* @__PURE__ */ React17.createElement(InvitationManager, {
|
|
1747
|
+
active: true,
|
|
1748
|
+
...data.subject
|
|
1749
|
+
})));
|
|
1750
|
+
} else {
|
|
1751
|
+
return null;
|
|
1752
|
+
}
|
|
1753
|
+
case "popover":
|
|
1754
|
+
if (data.component === "dxos.org/plugin/space/RenameSpacePopover" && isSpace2(data.subject)) {
|
|
1755
|
+
return /* @__PURE__ */ React17.createElement(PopoverRenameSpace, {
|
|
1756
|
+
space: data.subject
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
if (data.component === "dxos.org/plugin/space/RenameObjectPopover" && isReactiveObject2(data.subject)) {
|
|
1760
|
+
return /* @__PURE__ */ React17.createElement(PopoverRenameObject, {
|
|
1761
|
+
object: data.subject
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
return null;
|
|
1765
|
+
case "presence--glyph": {
|
|
1766
|
+
return isReactiveObject2(data.object) ? /* @__PURE__ */ React17.createElement(SmallPresenceLive, {
|
|
1767
|
+
viewers: state.values.viewersByObject[fullyQualifiedId4(data.object)],
|
|
1768
|
+
onCloseClick: () => {
|
|
1769
|
+
const objectId = fullyQualifiedId4(data.object);
|
|
1770
|
+
return intentPlugin?.provides.intent.dispatch({
|
|
1771
|
+
action: NavigationAction3.CLOSE,
|
|
1772
|
+
data: {
|
|
1773
|
+
activeParts: {
|
|
1774
|
+
main: [
|
|
1775
|
+
objectId
|
|
1776
|
+
],
|
|
1777
|
+
sidebar: [
|
|
1778
|
+
objectId
|
|
1779
|
+
],
|
|
1780
|
+
complementary: [
|
|
1781
|
+
objectId
|
|
1782
|
+
]
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
}) : /* @__PURE__ */ React17.createElement(SmallPresence, {
|
|
1788
|
+
count: 0
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
case "navbar-start": {
|
|
1792
|
+
return null;
|
|
1793
|
+
}
|
|
1794
|
+
case "navbar-end": {
|
|
1795
|
+
if (!isEchoObject2(data.object) && !isSpace2(data.object)) {
|
|
1796
|
+
return null;
|
|
1797
|
+
}
|
|
1798
|
+
const space = isSpace2(data.object) ? data.object : getSpace4(data.object);
|
|
1799
|
+
const object = isSpace2(data.object) ? data.object.state.get() === SpaceState3.SPACE_READY ? space?.properties[CollectionType.typename] : void 0 : data.object;
|
|
1800
|
+
return space && object ? {
|
|
1801
|
+
node: /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(SpacePresence, {
|
|
1802
|
+
object
|
|
1803
|
+
}), space.properties[COMPOSER_SPACE_LOCK] ? null : /* @__PURE__ */ React17.createElement(ShareSpaceButton, {
|
|
1804
|
+
spaceId: space.id
|
|
1805
|
+
})),
|
|
1806
|
+
disposition: "hoist"
|
|
1807
|
+
} : null;
|
|
1808
|
+
}
|
|
1809
|
+
case "section":
|
|
1810
|
+
return data.object instanceof CollectionType ? /* @__PURE__ */ React17.createElement(CollectionSection, {
|
|
1811
|
+
collection: data.object
|
|
1812
|
+
}) : null;
|
|
1813
|
+
case "settings":
|
|
1814
|
+
return data.plugin === meta_default.id ? /* @__PURE__ */ React17.createElement(SpaceSettings, {
|
|
1815
|
+
settings: settings.values
|
|
1816
|
+
}) : null;
|
|
1817
|
+
case "menu-footer":
|
|
1818
|
+
if (!isEchoObject2(data.object)) {
|
|
1819
|
+
return null;
|
|
1820
|
+
} else {
|
|
1821
|
+
return /* @__PURE__ */ React17.createElement(MenuFooter, {
|
|
1822
|
+
object: data.object
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1825
|
+
default:
|
|
1826
|
+
return null;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
},
|
|
1830
|
+
graph: {
|
|
1831
|
+
builder: (plugins) => {
|
|
1832
|
+
const clientPlugin2 = resolvePlugin(plugins, parseClientPlugin);
|
|
1833
|
+
const metadataPlugin = resolvePlugin(plugins, parseMetadataResolverPlugin);
|
|
1834
|
+
const graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
|
|
1835
|
+
const client = clientPlugin2?.provides.client;
|
|
1836
|
+
const dispatch = intentPlugin?.provides.intent.dispatch;
|
|
1837
|
+
const resolve = metadataPlugin?.provides.metadata.resolver;
|
|
1838
|
+
const graph = graphPlugin?.provides.graph;
|
|
1839
|
+
if (!graph || !dispatch || !resolve || !client) {
|
|
1840
|
+
return [];
|
|
1841
|
+
}
|
|
1842
|
+
return [
|
|
1843
|
+
// Create spaces group node.
|
|
1844
|
+
createExtension({
|
|
1845
|
+
id: `${SPACE_PLUGIN}/root`,
|
|
1846
|
+
filter: (node) => node.id === "root",
|
|
1847
|
+
connector: () => {
|
|
1848
|
+
const isReady = toSignal((onChange) => {
|
|
1849
|
+
let defaultSpaceUnsubscribe;
|
|
1850
|
+
client.spaces.isReady.subscribe((ready) => {
|
|
1851
|
+
if (ready) {
|
|
1852
|
+
defaultSpaceUnsubscribe = client.spaces.default.state.subscribe(() => onChange()).unsubscribe;
|
|
1853
|
+
}
|
|
1854
|
+
});
|
|
1855
|
+
return () => defaultSpaceUnsubscribe?.();
|
|
1856
|
+
}, () => client.spaces.isReady.get() && client.spaces.default.state.get() === SpaceState3.SPACE_READY);
|
|
1857
|
+
if (!isReady) {
|
|
1858
|
+
return [];
|
|
1859
|
+
}
|
|
1860
|
+
return [
|
|
1861
|
+
{
|
|
1862
|
+
id: SPACES,
|
|
1863
|
+
type: SPACES,
|
|
1864
|
+
properties: {
|
|
1865
|
+
label: [
|
|
1866
|
+
"spaces label",
|
|
1867
|
+
{
|
|
1868
|
+
ns: SPACE_PLUGIN
|
|
1869
|
+
}
|
|
1870
|
+
],
|
|
1871
|
+
palette: "teal",
|
|
1872
|
+
testId: "spacePlugin.spaces",
|
|
1873
|
+
role: "branch",
|
|
1874
|
+
childrenPersistenceClass: "echo",
|
|
1875
|
+
onRearrangeChildren: async (nextOrder) => {
|
|
1876
|
+
graph._sortEdges(SPACES, "outbound", nextOrder.map(({ id }) => id));
|
|
1877
|
+
const { objects: [spacesOrder] } = await client.spaces.default.db.query(Filter.schema(Expando, {
|
|
1878
|
+
key: SHARED
|
|
1879
|
+
})).run();
|
|
1880
|
+
if (spacesOrder) {
|
|
1881
|
+
spacesOrder.order = nextOrder.map(({ id }) => id);
|
|
1882
|
+
} else {
|
|
1883
|
+
log2.warn("spaces order object not found", void 0, {
|
|
1884
|
+
F: __dxlog_file3,
|
|
1885
|
+
L: 526,
|
|
1886
|
+
S: void 0,
|
|
1887
|
+
C: (f, a) => f(...a)
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
];
|
|
1894
|
+
}
|
|
1895
|
+
}),
|
|
1896
|
+
// Create space nodes.
|
|
1897
|
+
createExtension({
|
|
1898
|
+
id: SPACES,
|
|
1899
|
+
filter: (node) => node.id === SPACES,
|
|
1900
|
+
actions: () => [
|
|
1901
|
+
{
|
|
1902
|
+
id: SpaceAction.CREATE,
|
|
1903
|
+
data: async () => {
|
|
1904
|
+
await dispatch([
|
|
1905
|
+
{
|
|
1906
|
+
plugin: SPACE_PLUGIN,
|
|
1907
|
+
action: SpaceAction.CREATE
|
|
1908
|
+
},
|
|
1909
|
+
{
|
|
1910
|
+
action: NavigationAction3.OPEN
|
|
1911
|
+
}
|
|
1912
|
+
]);
|
|
1913
|
+
},
|
|
1914
|
+
properties: {
|
|
1915
|
+
label: [
|
|
1916
|
+
"create space label",
|
|
1917
|
+
{
|
|
1918
|
+
ns: SPACE_PLUGIN
|
|
1919
|
+
}
|
|
1920
|
+
],
|
|
1921
|
+
icon: (props) => /* @__PURE__ */ React17.createElement(Plus2, props),
|
|
1922
|
+
iconSymbol: "ph--plus--regular",
|
|
1923
|
+
disposition: "toolbar",
|
|
1924
|
+
testId: "spacePlugin.createSpace"
|
|
1925
|
+
}
|
|
1926
|
+
},
|
|
1927
|
+
{
|
|
1928
|
+
id: SpaceAction.JOIN,
|
|
1929
|
+
data: async () => {
|
|
1930
|
+
await dispatch([
|
|
1931
|
+
{
|
|
1932
|
+
plugin: SPACE_PLUGIN,
|
|
1933
|
+
action: SpaceAction.JOIN
|
|
1934
|
+
},
|
|
1935
|
+
{
|
|
1936
|
+
action: NavigationAction3.OPEN
|
|
1937
|
+
}
|
|
1938
|
+
]);
|
|
1939
|
+
},
|
|
1940
|
+
properties: {
|
|
1941
|
+
label: [
|
|
1942
|
+
"join space label",
|
|
1943
|
+
{
|
|
1944
|
+
ns: SPACE_PLUGIN
|
|
1945
|
+
}
|
|
1946
|
+
],
|
|
1947
|
+
icon: (props) => /* @__PURE__ */ React17.createElement(SignIn, props),
|
|
1948
|
+
iconSymbol: "ph--sign-in--regular",
|
|
1949
|
+
testId: "spacePlugin.joinSpace"
|
|
1950
|
+
}
|
|
1951
|
+
}
|
|
1952
|
+
],
|
|
1953
|
+
connector: () => {
|
|
1954
|
+
const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
|
|
1955
|
+
if (!spaces) {
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1958
|
+
const [spacesOrder] = memoizeQuery(client.spaces.default, Filter.schema(Expando, {
|
|
1959
|
+
key: SHARED
|
|
1960
|
+
}));
|
|
1961
|
+
const order = spacesOrder?.order ?? [];
|
|
1962
|
+
const orderMap = new Map(order.map((id, index) => [
|
|
1963
|
+
id,
|
|
1964
|
+
index
|
|
1965
|
+
]));
|
|
1966
|
+
return [
|
|
1967
|
+
...spaces.filter((space) => orderMap.has(space.id)).sort((a, b) => orderMap.get(a.id) - orderMap.get(b.id)),
|
|
1968
|
+
...spaces.filter((space) => !orderMap.has(space.id))
|
|
1969
|
+
].filter((space) => settings.values.showHidden ? true : space.state.get() !== SpaceState3.SPACE_INACTIVE).map((space) => constructSpaceNode({
|
|
1970
|
+
space,
|
|
1971
|
+
personal: space === client.spaces.default,
|
|
1972
|
+
namesCache: state.values.spaceNames,
|
|
1973
|
+
resolve
|
|
1974
|
+
}));
|
|
1975
|
+
}
|
|
1976
|
+
}),
|
|
1977
|
+
// Find an object by its fully qualified id.
|
|
1978
|
+
createExtension({
|
|
1979
|
+
id: `${SPACE_PLUGIN}/objects`,
|
|
1980
|
+
resolver: ({ id }) => {
|
|
1981
|
+
const [spaceId, objectId] = id.split(":");
|
|
1982
|
+
const space = client.spaces.get().find((space2) => space2.id === spaceId);
|
|
1983
|
+
if (!space) {
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
const state2 = toSignal((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
|
|
1987
|
+
if (state2 !== SpaceState3.SPACE_READY) {
|
|
1988
|
+
return;
|
|
1989
|
+
}
|
|
1990
|
+
const store = memoize2(() => signal(space.db.getObjectById(objectId)), id);
|
|
1991
|
+
memoize2(() => {
|
|
1992
|
+
if (!store.value) {
|
|
1993
|
+
void space.db.loadObjectById(objectId).then((o) => store.value = o);
|
|
1994
|
+
}
|
|
1995
|
+
}, id);
|
|
1996
|
+
const object = store.value;
|
|
1997
|
+
if (!object) {
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
return createObjectNode({
|
|
2001
|
+
object,
|
|
2002
|
+
space,
|
|
2003
|
+
resolve
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
}),
|
|
2007
|
+
// Create space actions and action groups.
|
|
2008
|
+
createExtension({
|
|
2009
|
+
id: `${SPACE_PLUGIN}/actions`,
|
|
2010
|
+
filter: (node) => isSpace2(node.data),
|
|
2011
|
+
actionGroups: ({ node }) => constructSpaceActionGroups({
|
|
2012
|
+
space: node.data,
|
|
2013
|
+
dispatch
|
|
2014
|
+
}),
|
|
2015
|
+
actions: ({ node }) => {
|
|
2016
|
+
const space = node.data;
|
|
2017
|
+
return constructSpaceActions({
|
|
2018
|
+
space,
|
|
2019
|
+
dispatch,
|
|
2020
|
+
personal: space === client.spaces.default,
|
|
2021
|
+
migrating: state.values.sdkMigrationRunning[space.id]
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
}),
|
|
2025
|
+
// Create nodes for objects in the root collection of a space.
|
|
2026
|
+
createExtension({
|
|
2027
|
+
id: `${SPACE_PLUGIN}/root-collection`,
|
|
2028
|
+
filter: (node) => isSpace2(node.data),
|
|
2029
|
+
connector: ({ node }) => {
|
|
2030
|
+
const space = node.data;
|
|
2031
|
+
const state2 = toSignal((onChange) => space.state.subscribe(() => onChange()).unsubscribe, () => space.state.get(), space.id);
|
|
2032
|
+
if (state2 !== SpaceState3.SPACE_READY) {
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
2035
|
+
const collection = space.properties[CollectionType.typename];
|
|
2036
|
+
if (!collection) {
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
return collection.objects.filter(nonNullable).map((object) => createObjectNode({
|
|
2040
|
+
object,
|
|
2041
|
+
space,
|
|
2042
|
+
resolve
|
|
2043
|
+
})).filter(nonNullable);
|
|
2044
|
+
}
|
|
2045
|
+
}),
|
|
2046
|
+
// Create collection actions and action groups.
|
|
2047
|
+
createExtension({
|
|
2048
|
+
id: `${SPACE_PLUGIN}/object-actions`,
|
|
2049
|
+
filter: (node) => isEchoObject2(node.data),
|
|
2050
|
+
actionGroups: ({ node }) => constructObjectActionGroups({
|
|
2051
|
+
object: node.data,
|
|
2052
|
+
dispatch
|
|
2053
|
+
}),
|
|
2054
|
+
actions: ({ node }) => constructObjectActions({
|
|
2055
|
+
node,
|
|
2056
|
+
dispatch
|
|
2057
|
+
})
|
|
2058
|
+
}),
|
|
2059
|
+
// Create nodes for objects in collections.
|
|
2060
|
+
createExtension({
|
|
2061
|
+
id: `${SPACE_PLUGIN}/collection-objects`,
|
|
2062
|
+
filter: (node) => node.data instanceof CollectionType,
|
|
2063
|
+
connector: ({ node }) => {
|
|
2064
|
+
const collection = node.data;
|
|
2065
|
+
const space = getSpace4(collection);
|
|
2066
|
+
if (!space) {
|
|
2067
|
+
return;
|
|
2068
|
+
}
|
|
2069
|
+
return collection.objects.filter(nonNullable).map((object) => createObjectNode({
|
|
2070
|
+
object,
|
|
2071
|
+
space,
|
|
2072
|
+
resolve
|
|
2073
|
+
})).filter(nonNullable);
|
|
2074
|
+
}
|
|
2075
|
+
})
|
|
2076
|
+
];
|
|
2077
|
+
},
|
|
2078
|
+
serializer: (plugins) => {
|
|
2079
|
+
const dispatch = resolvePlugin(plugins, parseIntentPlugin3)?.provides.intent.dispatch;
|
|
2080
|
+
if (!dispatch) {
|
|
2081
|
+
return [];
|
|
2082
|
+
}
|
|
2083
|
+
return [
|
|
2084
|
+
{
|
|
2085
|
+
inputType: SPACES,
|
|
2086
|
+
outputType: DIRECTORY_TYPE,
|
|
2087
|
+
serialize: (node) => ({
|
|
2088
|
+
name: translations_default[0]["en-US"][SPACE_PLUGIN]["spaces label"],
|
|
2089
|
+
data: translations_default[0]["en-US"][SPACE_PLUGIN]["spaces label"],
|
|
2090
|
+
type: DIRECTORY_TYPE
|
|
2091
|
+
}),
|
|
2092
|
+
deserialize: () => {
|
|
2093
|
+
}
|
|
2094
|
+
},
|
|
2095
|
+
{
|
|
2096
|
+
inputType: SPACE_TYPE,
|
|
2097
|
+
outputType: DIRECTORY_TYPE,
|
|
2098
|
+
serialize: (node) => ({
|
|
2099
|
+
name: node.properties.name ?? translations_default[0]["en-US"][SPACE_PLUGIN]["unnamed space label"],
|
|
2100
|
+
data: node.properties.name ?? translations_default[0]["en-US"][SPACE_PLUGIN]["unnamed space label"],
|
|
2101
|
+
type: DIRECTORY_TYPE
|
|
2102
|
+
}),
|
|
2103
|
+
deserialize: async (data) => {
|
|
2104
|
+
const result = await dispatch({
|
|
2105
|
+
plugin: SPACE_PLUGIN,
|
|
2106
|
+
action: SpaceAction.CREATE,
|
|
2107
|
+
data: {
|
|
2108
|
+
name: data.name
|
|
2109
|
+
}
|
|
2110
|
+
});
|
|
2111
|
+
return result?.data.space;
|
|
2112
|
+
}
|
|
2113
|
+
},
|
|
2114
|
+
{
|
|
2115
|
+
inputType: CollectionType.typename,
|
|
2116
|
+
outputType: DIRECTORY_TYPE,
|
|
2117
|
+
serialize: (node) => ({
|
|
2118
|
+
name: node.properties.name ?? translations_default[0]["en-US"][SPACE_PLUGIN]["unnamed collection label"],
|
|
2119
|
+
data: node.properties.name ?? translations_default[0]["en-US"][SPACE_PLUGIN]["unnamed collection label"],
|
|
2120
|
+
type: DIRECTORY_TYPE
|
|
2121
|
+
}),
|
|
2122
|
+
deserialize: async (data, ancestors) => {
|
|
2123
|
+
const space = ancestors.find(isSpace2);
|
|
2124
|
+
const collection = ancestors.findLast((ancestor) => ancestor instanceof CollectionType) ?? space?.properties[CollectionType.typename];
|
|
2125
|
+
if (!space || !collection) {
|
|
2126
|
+
return;
|
|
2127
|
+
}
|
|
2128
|
+
const result = await dispatch({
|
|
2129
|
+
plugin: SPACE_PLUGIN,
|
|
2130
|
+
action: SpaceAction.ADD_OBJECT,
|
|
2131
|
+
data: {
|
|
2132
|
+
target: collection,
|
|
2133
|
+
object: create2(CollectionType, {
|
|
2134
|
+
name: data.name,
|
|
2135
|
+
objects: [],
|
|
2136
|
+
views: {}
|
|
2137
|
+
})
|
|
2138
|
+
}
|
|
2139
|
+
});
|
|
2140
|
+
return result?.data.object;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
];
|
|
2144
|
+
}
|
|
2145
|
+
},
|
|
2146
|
+
intent: {
|
|
2147
|
+
resolver: async (intent, plugins) => {
|
|
2148
|
+
const clientPlugin2 = resolvePlugin(plugins, parseClientPlugin);
|
|
2149
|
+
const client = clientPlugin2?.provides.client;
|
|
2150
|
+
switch (intent.action) {
|
|
2151
|
+
case SpaceAction.WAIT_FOR_OBJECT: {
|
|
2152
|
+
state.values.awaiting = intent.data?.id;
|
|
2153
|
+
return {
|
|
2154
|
+
data: true
|
|
2155
|
+
};
|
|
2156
|
+
}
|
|
2157
|
+
case SpaceAction.CREATE: {
|
|
2158
|
+
if (!client) {
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
const space = await client.spaces.create(intent.data);
|
|
2162
|
+
await space.waitUntilReady();
|
|
2163
|
+
const collection = create2(CollectionType, {
|
|
2164
|
+
objects: [],
|
|
2165
|
+
views: {}
|
|
2166
|
+
});
|
|
2167
|
+
space.properties[CollectionType.typename] = collection;
|
|
2168
|
+
if (Migrations2.versionProperty) {
|
|
2169
|
+
space.properties[Migrations2.versionProperty] = Migrations2.targetVersion;
|
|
2170
|
+
}
|
|
2171
|
+
return {
|
|
2172
|
+
data: {
|
|
2173
|
+
space,
|
|
2174
|
+
id: space.id,
|
|
2175
|
+
activeParts: {
|
|
2176
|
+
main: [
|
|
2177
|
+
space.id
|
|
2178
|
+
]
|
|
2179
|
+
}
|
|
2180
|
+
},
|
|
2181
|
+
intents: [
|
|
2182
|
+
[
|
|
2183
|
+
{
|
|
2184
|
+
action: ObservabilityAction.SEND_EVENT,
|
|
2185
|
+
data: {
|
|
2186
|
+
name: "space.create",
|
|
2187
|
+
properties: {
|
|
2188
|
+
spaceId: space.id
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
]
|
|
2193
|
+
]
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
case SpaceAction.JOIN: {
|
|
2197
|
+
if (client) {
|
|
2198
|
+
const { space } = await client.shell.joinSpace({
|
|
2199
|
+
invitationCode: intent.data?.invitationCode
|
|
2200
|
+
});
|
|
2201
|
+
if (space) {
|
|
2202
|
+
return {
|
|
2203
|
+
data: {
|
|
2204
|
+
space,
|
|
2205
|
+
id: space.id,
|
|
2206
|
+
activeParts: {
|
|
2207
|
+
main: [
|
|
2208
|
+
space.id
|
|
2209
|
+
]
|
|
2210
|
+
}
|
|
2211
|
+
},
|
|
2212
|
+
intents: [
|
|
2213
|
+
[
|
|
2214
|
+
{
|
|
2215
|
+
action: ObservabilityAction.SEND_EVENT,
|
|
2216
|
+
data: {
|
|
2217
|
+
name: "space.join",
|
|
2218
|
+
properties: {
|
|
2219
|
+
spaceId: space.id
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
]
|
|
2224
|
+
]
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
case SpaceAction.SHARE: {
|
|
2231
|
+
const spaceId = intent.data?.spaceId;
|
|
2232
|
+
if (clientPlugin2 && typeof spaceId === "string") {
|
|
2233
|
+
if (!navigationPlugin?.provides.location.active) {
|
|
2234
|
+
return;
|
|
2235
|
+
}
|
|
2236
|
+
const target = firstIdInPart(navigationPlugin?.provides.location.active, "main");
|
|
2237
|
+
const result = await clientPlugin2.provides.client.shell.shareSpace({
|
|
2238
|
+
spaceId,
|
|
2239
|
+
target
|
|
2240
|
+
});
|
|
2241
|
+
return {
|
|
2242
|
+
data: result,
|
|
2243
|
+
intents: [
|
|
2244
|
+
[
|
|
2245
|
+
{
|
|
2246
|
+
action: ObservabilityAction.SEND_EVENT,
|
|
2247
|
+
data: {
|
|
2248
|
+
name: "space.share",
|
|
2249
|
+
properties: {
|
|
2250
|
+
spaceId,
|
|
2251
|
+
members: result.members?.length,
|
|
2252
|
+
error: result.error?.message,
|
|
2253
|
+
cancelled: result.cancelled
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
]
|
|
2258
|
+
]
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
break;
|
|
2262
|
+
}
|
|
2263
|
+
case SpaceAction.LOCK: {
|
|
2264
|
+
const space = intent.data?.space;
|
|
2265
|
+
if (isSpace2(space)) {
|
|
2266
|
+
space.properties[COMPOSER_SPACE_LOCK] = true;
|
|
2267
|
+
return {
|
|
2268
|
+
data: true,
|
|
2269
|
+
intents: [
|
|
2270
|
+
[
|
|
2271
|
+
{
|
|
2272
|
+
action: ObservabilityAction.SEND_EVENT,
|
|
2273
|
+
data: {
|
|
2274
|
+
name: "space.lock",
|
|
2275
|
+
properties: {
|
|
2276
|
+
spaceId: space.id
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
]
|
|
2281
|
+
]
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2284
|
+
break;
|
|
2285
|
+
}
|
|
2286
|
+
case SpaceAction.UNLOCK: {
|
|
2287
|
+
const space = intent.data?.space;
|
|
2288
|
+
if (isSpace2(space)) {
|
|
2289
|
+
space.properties[COMPOSER_SPACE_LOCK] = false;
|
|
2290
|
+
return {
|
|
2291
|
+
data: true,
|
|
2292
|
+
intents: [
|
|
2293
|
+
[
|
|
2294
|
+
{
|
|
2295
|
+
action: ObservabilityAction.SEND_EVENT,
|
|
2296
|
+
data: {
|
|
2297
|
+
name: "space.unlock",
|
|
2298
|
+
properties: {
|
|
2299
|
+
spaceId: space.id
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
]
|
|
2304
|
+
]
|
|
2305
|
+
};
|
|
2306
|
+
}
|
|
2307
|
+
break;
|
|
2308
|
+
}
|
|
2309
|
+
case SpaceAction.RENAME: {
|
|
2310
|
+
const { caller, space } = intent.data ?? {};
|
|
2311
|
+
if (typeof caller === "string" && isSpace2(space)) {
|
|
2312
|
+
return {
|
|
2313
|
+
intents: [
|
|
2314
|
+
[
|
|
2315
|
+
{
|
|
2316
|
+
action: LayoutAction2.SET_LAYOUT,
|
|
2317
|
+
data: {
|
|
2318
|
+
element: "popover",
|
|
2319
|
+
anchorId: `dxos.org/ui/${caller}/${space.id}`,
|
|
2320
|
+
component: "dxos.org/plugin/space/RenameSpacePopover",
|
|
2321
|
+
subject: space
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2324
|
+
]
|
|
2325
|
+
]
|
|
2326
|
+
};
|
|
2327
|
+
}
|
|
2328
|
+
break;
|
|
2329
|
+
}
|
|
2330
|
+
case SpaceAction.OPEN: {
|
|
2331
|
+
const space = intent.data?.space;
|
|
2332
|
+
if (isSpace2(space)) {
|
|
2333
|
+
await space.open();
|
|
2334
|
+
return {
|
|
2335
|
+
data: true
|
|
2336
|
+
};
|
|
2337
|
+
}
|
|
2338
|
+
break;
|
|
2339
|
+
}
|
|
2340
|
+
case SpaceAction.CLOSE: {
|
|
2341
|
+
const space = intent.data?.space;
|
|
2342
|
+
if (isSpace2(space)) {
|
|
2343
|
+
await space.close();
|
|
2344
|
+
return {
|
|
2345
|
+
data: true
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
break;
|
|
2349
|
+
}
|
|
2350
|
+
case SpaceAction.MIGRATE: {
|
|
2351
|
+
const space = intent.data?.space;
|
|
2352
|
+
if (isSpace2(space)) {
|
|
2353
|
+
if (space.state.get() === SpaceState3.SPACE_REQUIRES_MIGRATION) {
|
|
2354
|
+
state.values.sdkMigrationRunning[space.id] = true;
|
|
2355
|
+
await space.internal.migrate();
|
|
2356
|
+
state.values.sdkMigrationRunning[space.id] = false;
|
|
2357
|
+
}
|
|
2358
|
+
const result = await Migrations2.migrate(space, intent.data?.version);
|
|
2359
|
+
return {
|
|
2360
|
+
data: result,
|
|
2361
|
+
intents: [
|
|
2362
|
+
[
|
|
2363
|
+
{
|
|
2364
|
+
action: ObservabilityAction.SEND_EVENT,
|
|
2365
|
+
data: {
|
|
2366
|
+
name: "space.migrate",
|
|
2367
|
+
properties: {
|
|
2368
|
+
spaceId: space.id,
|
|
2369
|
+
version: intent.data?.version
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
]
|
|
2374
|
+
]
|
|
2375
|
+
};
|
|
2376
|
+
}
|
|
2377
|
+
break;
|
|
2378
|
+
}
|
|
2379
|
+
case SpaceAction.ADD_OBJECT: {
|
|
2380
|
+
const object = intent.data?.object ?? intent.data?.result;
|
|
2381
|
+
if (!isReactiveObject2(object)) {
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
const space = isSpace2(intent.data?.target) ? intent.data?.target : getSpace4(intent.data?.target);
|
|
2385
|
+
if (!space) {
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
if (space.db.coreDatabase.getAllObjectIds().length >= SPACE_MAX_OBJECTS) {
|
|
2389
|
+
return {
|
|
2390
|
+
data: false,
|
|
2391
|
+
intents: [
|
|
2392
|
+
[
|
|
2393
|
+
{
|
|
2394
|
+
action: LayoutAction2.SET_LAYOUT,
|
|
2395
|
+
data: {
|
|
2396
|
+
element: "toast",
|
|
2397
|
+
subject: {
|
|
2398
|
+
id: `${SPACE_PLUGIN}/space-limit`,
|
|
2399
|
+
title: translations_default[0]["en-US"][SPACE_PLUGIN]["space limit label"],
|
|
2400
|
+
description: translations_default[0]["en-US"][SPACE_PLUGIN]["space limit description"],
|
|
2401
|
+
duration: 5e3,
|
|
2402
|
+
icon: (props) => /* @__PURE__ */ React17.createElement(Warning2, props),
|
|
2403
|
+
iconSymbol: "ph--warning--regular",
|
|
2404
|
+
actionLabel: translations_default[0]["en-US"][SPACE_PLUGIN]["remove deleted objects label"],
|
|
2405
|
+
actionAlt: translations_default[0]["en-US"][SPACE_PLUGIN]["remove deleted objects alt"],
|
|
2406
|
+
// TODO(wittjosiah): Use OS namespace.
|
|
2407
|
+
closeLabel: translations_default[0]["en-US"][SPACE_PLUGIN]["space limit close label"],
|
|
2408
|
+
onAction: () => space.db.coreDatabase.unlinkDeletedObjects()
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
],
|
|
2413
|
+
[
|
|
2414
|
+
{
|
|
2415
|
+
action: ObservabilityAction.SEND_EVENT,
|
|
2416
|
+
data: {
|
|
2417
|
+
name: "space.limit",
|
|
2418
|
+
properties: {
|
|
2419
|
+
spaceId: space.id
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
]
|
|
2424
|
+
]
|
|
2425
|
+
};
|
|
2426
|
+
}
|
|
2427
|
+
if (intent.data?.target instanceof CollectionType) {
|
|
2428
|
+
intent.data?.target.objects.push(object);
|
|
2429
|
+
} else if (isSpace2(intent.data?.target)) {
|
|
2430
|
+
const collection = space.properties[CollectionType.typename];
|
|
2431
|
+
if (collection instanceof CollectionType) {
|
|
2432
|
+
collection.objects.push(object);
|
|
2433
|
+
} else {
|
|
2434
|
+
const collection2 = create2(CollectionType, {
|
|
2435
|
+
objects: [
|
|
2436
|
+
object
|
|
2437
|
+
],
|
|
2438
|
+
views: {}
|
|
2439
|
+
});
|
|
2440
|
+
space.properties[CollectionType.typename] = collection2;
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
return {
|
|
2444
|
+
data: {
|
|
2445
|
+
id: object.id,
|
|
2446
|
+
object,
|
|
2447
|
+
activeParts: {
|
|
2448
|
+
main: [
|
|
2449
|
+
fullyQualifiedId4(object)
|
|
2450
|
+
]
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
intents: [
|
|
2454
|
+
[
|
|
2455
|
+
{
|
|
2456
|
+
action: ObservabilityAction.SEND_EVENT,
|
|
2457
|
+
data: {
|
|
2458
|
+
name: "space.object.add",
|
|
2459
|
+
properties: {
|
|
2460
|
+
spaceId: space.id,
|
|
2461
|
+
objectId: object.id,
|
|
2462
|
+
typename: getTypename2(object)
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
]
|
|
2467
|
+
]
|
|
2468
|
+
};
|
|
2469
|
+
}
|
|
2470
|
+
case SpaceAction.REMOVE_OBJECT: {
|
|
2471
|
+
const object = intent.data?.object ?? intent.data?.result;
|
|
2472
|
+
const space = getSpace4(object);
|
|
2473
|
+
if (!(isEchoObject2(object) && space)) {
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
const resolve = resolvePlugin(plugins, parseMetadataResolverPlugin)?.provides.metadata.resolver;
|
|
2477
|
+
const activeParts = navigationPlugin?.provides.location.active;
|
|
2478
|
+
const openObjectIds = new Set(openIds(activeParts ?? {}));
|
|
2479
|
+
if (!intent.undo && resolve) {
|
|
2480
|
+
const parentCollection = intent.data?.collection ?? space.properties[CollectionType.typename];
|
|
2481
|
+
const nestedObjects = await getNestedObjects(object, resolve);
|
|
2482
|
+
const deletionData = {
|
|
2483
|
+
object,
|
|
2484
|
+
parentCollection,
|
|
2485
|
+
index: parentCollection instanceof CollectionType ? parentCollection.objects.indexOf(object) : -1,
|
|
2486
|
+
nestedObjects,
|
|
2487
|
+
wasActive: [
|
|
2488
|
+
object,
|
|
2489
|
+
...nestedObjects
|
|
2490
|
+
].map((obj) => fullyQualifiedId4(obj)).filter((id) => openObjectIds.has(id))
|
|
2491
|
+
};
|
|
2492
|
+
if (deletionData.wasActive.length > 0) {
|
|
2493
|
+
await intentPlugin?.provides.intent.dispatch({
|
|
2494
|
+
action: NavigationAction3.CLOSE,
|
|
2495
|
+
data: {
|
|
2496
|
+
activeParts: {
|
|
2497
|
+
main: deletionData.wasActive,
|
|
2498
|
+
sidebar: deletionData.wasActive,
|
|
2499
|
+
complementary: deletionData.wasActive
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
if (parentCollection instanceof CollectionType) {
|
|
2505
|
+
const index = parentCollection.objects.indexOf(object);
|
|
2506
|
+
if (index !== -1) {
|
|
2507
|
+
parentCollection.objects.splice(index, 1);
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
deletionData.nestedObjects.forEach((obj) => {
|
|
2511
|
+
space.db.remove(obj);
|
|
2512
|
+
});
|
|
2513
|
+
space.db.remove(object);
|
|
2514
|
+
const undoMessageKey = object instanceof CollectionType ? "collection deleted label" : "object deleted label";
|
|
2515
|
+
return {
|
|
2516
|
+
data: true,
|
|
2517
|
+
undoable: {
|
|
2518
|
+
// Consider using a translation key here.
|
|
2519
|
+
message: translations_default[0]["en-US"][SPACE_PLUGIN][undoMessageKey],
|
|
2520
|
+
data: deletionData
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
} else {
|
|
2524
|
+
const undoData = intent.data;
|
|
2525
|
+
if (undoData && isEchoObject2(undoData.object) && undoData.parentCollection instanceof CollectionType) {
|
|
2526
|
+
const restoredObject = space.db.add(undoData.object);
|
|
2527
|
+
undoData.nestedObjects.forEach((obj) => {
|
|
2528
|
+
space.db.add(obj);
|
|
2529
|
+
});
|
|
2530
|
+
if (undoData.index !== -1) {
|
|
2531
|
+
undoData.parentCollection.objects.splice(undoData.index, 0, restoredObject);
|
|
2532
|
+
}
|
|
2533
|
+
if (undoData.wasActive.length > 0) {
|
|
2534
|
+
await intentPlugin?.provides.intent.dispatch({
|
|
2535
|
+
action: NavigationAction3.OPEN,
|
|
2536
|
+
data: {
|
|
2537
|
+
activeParts: {
|
|
2538
|
+
main: undoData.wasActive
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
return {
|
|
2544
|
+
data: true
|
|
2545
|
+
};
|
|
2546
|
+
}
|
|
2547
|
+
return {
|
|
2548
|
+
data: false
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
case SpaceAction.RENAME_OBJECT: {
|
|
2553
|
+
const object = intent.data?.object ?? intent.data?.result;
|
|
2554
|
+
const caller = intent.data?.caller;
|
|
2555
|
+
if (isReactiveObject2(object) && caller) {
|
|
2556
|
+
return {
|
|
2557
|
+
intents: [
|
|
2558
|
+
[
|
|
2559
|
+
{
|
|
2560
|
+
action: LayoutAction2.SET_LAYOUT,
|
|
2561
|
+
data: {
|
|
2562
|
+
element: "popover",
|
|
2563
|
+
anchorId: `dxos.org/ui/${caller}/${fullyQualifiedId4(object)}`,
|
|
2564
|
+
component: "dxos.org/plugin/space/RenameObjectPopover",
|
|
2565
|
+
subject: object
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
]
|
|
2569
|
+
]
|
|
2570
|
+
};
|
|
2571
|
+
}
|
|
2572
|
+
break;
|
|
2573
|
+
}
|
|
2574
|
+
case SpaceAction.DUPLICATE_OBJECT: {
|
|
2575
|
+
const originalObject = intent.data?.object ?? intent.data?.result;
|
|
2576
|
+
const resolve = resolvePlugin(plugins, parseMetadataResolverPlugin)?.provides.metadata.resolver;
|
|
2577
|
+
if (!isEchoObject2(originalObject) || !resolve) {
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
const newObject = await cloneObject(originalObject, resolve);
|
|
2581
|
+
return {
|
|
2582
|
+
intents: [
|
|
2583
|
+
[
|
|
2584
|
+
{
|
|
2585
|
+
action: SpaceAction.ADD_OBJECT,
|
|
2586
|
+
data: {
|
|
2587
|
+
object: newObject,
|
|
2588
|
+
target: intent.data?.target
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
]
|
|
2592
|
+
]
|
|
2593
|
+
};
|
|
2594
|
+
}
|
|
2595
|
+
case SpaceAction.TOGGLE_HIDDEN: {
|
|
2596
|
+
settings.values.showHidden = intent.data?.state ?? !settings.values.showHidden;
|
|
2597
|
+
return {
|
|
2598
|
+
data: true
|
|
2599
|
+
};
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
};
|
|
2606
|
+
};
|
|
2607
|
+
|
|
2608
|
+
// packages/plugins/plugin-space/src/index.ts
|
|
2609
|
+
var src_default = SpacePlugin;
|
|
2610
|
+
export {
|
|
2611
|
+
ActorSchema,
|
|
2612
|
+
AwaitingObject,
|
|
2613
|
+
COMPOSER_SPACE_LOCK,
|
|
2614
|
+
ChannelType,
|
|
2615
|
+
CollectionMain,
|
|
2616
|
+
CollectionSection,
|
|
2617
|
+
CollectionType,
|
|
2618
|
+
ContactType,
|
|
2619
|
+
EmptySpace,
|
|
2620
|
+
EmptyTree,
|
|
2621
|
+
FullPresence,
|
|
2622
|
+
MenuFooter,
|
|
2623
|
+
MessageType,
|
|
2624
|
+
MissingObject,
|
|
2625
|
+
PersistenceStatus,
|
|
2626
|
+
PopoverRenameObject,
|
|
2627
|
+
PopoverRenameSpace,
|
|
2628
|
+
SHARED,
|
|
2629
|
+
SPACES,
|
|
2630
|
+
SPACE_DIRECTORY_HANDLE,
|
|
2631
|
+
SPACE_PLUGIN,
|
|
2632
|
+
SPACE_PLUGIN_SHORT_ID,
|
|
2633
|
+
SPACE_TYPE,
|
|
2634
|
+
ShareSpaceButton,
|
|
2635
|
+
ShareSpaceButtonImpl,
|
|
2636
|
+
SmallPresence,
|
|
2637
|
+
SmallPresenceLive,
|
|
2638
|
+
SpaceAction,
|
|
2639
|
+
SpaceMain,
|
|
2640
|
+
SpacePlugin,
|
|
2641
|
+
SpacePresence,
|
|
2642
|
+
SpaceSettings,
|
|
2643
|
+
ThreadStatus,
|
|
2644
|
+
ThreadType,
|
|
2645
|
+
cloneObject,
|
|
2646
|
+
constructObjectActionGroups,
|
|
2647
|
+
constructObjectActions,
|
|
2648
|
+
constructSpaceActionGroups,
|
|
2649
|
+
constructSpaceActions,
|
|
2650
|
+
constructSpaceNode,
|
|
2651
|
+
createObjectNode,
|
|
2652
|
+
src_default as default,
|
|
2653
|
+
getActiveSpace,
|
|
2654
|
+
getNestedObjects,
|
|
2655
|
+
getSpaceDisplayName,
|
|
2656
|
+
memoizeQuery,
|
|
2657
|
+
parseSpacePlugin,
|
|
2658
|
+
translations_default as translations
|
|
2659
|
+
};
|
|
2660
|
+
//# sourceMappingURL=index.mjs.map
|