@dxos/plugin-space 0.7.2-main.f1adc9f → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +32 -45
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +27 -40
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +32 -45
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/SpacePlugin.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/package.json +35 -35
- package/src/SpacePlugin.tsx +24 -27
- package/src/util.tsx +1 -6
|
@@ -33,7 +33,7 @@ import { parseClientPlugin } from "@dxos/plugin-client";
|
|
|
33
33
|
import { createExtension, memoize as memoize2, toSignal } from "@dxos/plugin-graph";
|
|
34
34
|
import { ObservabilityAction as ObservabilityAction2 } from "@dxos/plugin-observability/meta";
|
|
35
35
|
import { PublicKey as PublicKey2 } from "@dxos/react-client";
|
|
36
|
-
import { Expando, Filter
|
|
36
|
+
import { Expando, Filter, SpaceState as SpaceState2, create as create2, fullyQualifiedId as fullyQualifiedId4, getSpace as getSpace4, getTypename as getTypename2, isEchoObject as isEchoObject2, isSpace as isSpace2, loadObjectReferences, parseId, FQ_ID_LENGTH, SPACE_ID_LENGTH, OBJECT_ID_LENGTH } from "@dxos/react-client/echo";
|
|
37
37
|
import { osTranslations } from "@dxos/shell/react";
|
|
38
38
|
import { ComplexMap as ComplexMap2, nonNullable, reduceGroupBy } from "@dxos/util";
|
|
39
39
|
|
|
@@ -280,7 +280,7 @@ import { create, isReactiveObject, getTypename, getSchema, getObjectAnnotation,
|
|
|
280
280
|
import { invariant } from "@dxos/invariant";
|
|
281
281
|
import { Migrations } from "@dxos/migrations";
|
|
282
282
|
import { ACTION_TYPE, ACTION_GROUP_TYPE, actionGroupSymbol, getGraph, cleanup, memoize } from "@dxos/plugin-graph";
|
|
283
|
-
import { fullyQualifiedId as fullyQualifiedId2, getSpace, isEchoObject, isSpace, SpaceState
|
|
283
|
+
import { fullyQualifiedId as fullyQualifiedId2, getSpace, isEchoObject, isSpace, SpaceState } from "@dxos/react-client/echo";
|
|
284
284
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-space/src/util.tsx";
|
|
285
285
|
var SPACES = `${SPACE_PLUGIN}-spaces`;
|
|
286
286
|
var SPACE_TYPE = "dxos.org/type/Space";
|
|
@@ -288,10 +288,7 @@ var COMPOSER_SPACE_LOCK = "dxos.org/plugin/space/lock";
|
|
|
288
288
|
var SHARED = "shared-spaces";
|
|
289
289
|
var EMPTY_ARRAY = [];
|
|
290
290
|
var memoizeQuery = (spaceOrEcho, filter, options) => {
|
|
291
|
-
const key =
|
|
292
|
-
space: isSpace(spaceOrEcho) ? spaceOrEcho.id : void 0,
|
|
293
|
-
filter: Filter.from(filter).toProto()
|
|
294
|
-
});
|
|
291
|
+
const key = isSpace(spaceOrEcho) ? spaceOrEcho.id : void 0;
|
|
295
292
|
const query = memoize(() => isSpace(spaceOrEcho) ? spaceOrEcho.db.query(filter, options) : spaceOrEcho?.query(filter, options), key);
|
|
296
293
|
const unsubscribe = memoize(() => query?.subscribe(), key);
|
|
297
294
|
cleanup(() => unsubscribe?.());
|
|
@@ -846,7 +843,7 @@ var cloneObject = async (object, resolve, newSpace) => {
|
|
|
846
843
|
const serializer = metadata.serializer;
|
|
847
844
|
invariant(serializer, `No serializer for type: ${typename}`, {
|
|
848
845
|
F: __dxlog_file,
|
|
849
|
-
L:
|
|
846
|
+
L: 634,
|
|
850
847
|
S: void 0,
|
|
851
848
|
A: [
|
|
852
849
|
"serializer",
|
|
@@ -1874,7 +1871,7 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
1874
1871
|
if (typeof defaultSpace.properties[COMPOSER_SPACE_LOCK] !== "boolean") {
|
|
1875
1872
|
defaultSpace.properties[COMPOSER_SPACE_LOCK] = true;
|
|
1876
1873
|
}
|
|
1877
|
-
const { objects: [spacesOrder] } = await defaultSpace.db.query(
|
|
1874
|
+
const { objects: [spacesOrder] } = await defaultSpace.db.query(Filter.schema(Expando, {
|
|
1878
1875
|
key: SHARED
|
|
1879
1876
|
})).run();
|
|
1880
1877
|
if (!spacesOrder) {
|
|
@@ -1918,25 +1915,17 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
1918
1915
|
});
|
|
1919
1916
|
}).unsubscribe);
|
|
1920
1917
|
subscriptions.add(scheduledEffect(() => ({
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
closed: [
|
|
1927
|
-
...location.closed
|
|
1928
|
-
]
|
|
1929
|
-
}), ({ open, closed }) => {
|
|
1918
|
+
ids: openIds(location.active),
|
|
1919
|
+
removed: location.closed ? [
|
|
1920
|
+
location.closed
|
|
1921
|
+
].flat() : []
|
|
1922
|
+
}), ({ ids, removed }) => {
|
|
1930
1923
|
const send = () => {
|
|
1931
1924
|
const spaces = client.spaces.get();
|
|
1932
1925
|
const identity = client.halo.identity.get();
|
|
1933
1926
|
if (identity && location.active) {
|
|
1934
|
-
const idsBySpace = reduceGroupBy(
|
|
1935
|
-
const [spaceId] =
|
|
1936
|
-
return spaceId;
|
|
1937
|
-
});
|
|
1938
|
-
const removedBySpace = reduceGroupBy(closed, (id) => {
|
|
1939
|
-
const [spaceId] = parseFullyQualifiedId(id);
|
|
1927
|
+
const idsBySpace = reduceGroupBy(ids, (id) => {
|
|
1928
|
+
const [spaceId] = id.split(":");
|
|
1940
1929
|
return spaceId;
|
|
1941
1930
|
});
|
|
1942
1931
|
for (const space of spaces) {
|
|
@@ -1944,8 +1933,7 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
1944
1933
|
idsBySpace.set(space.id, []);
|
|
1945
1934
|
}
|
|
1946
1935
|
}
|
|
1947
|
-
for (const [spaceId,
|
|
1948
|
-
const removed = removedBySpace.get(spaceId) ?? [];
|
|
1936
|
+
for (const [spaceId, ids2] of idsBySpace) {
|
|
1949
1937
|
const space = spaces.find((space2) => space2.id === spaceId);
|
|
1950
1938
|
if (!space) {
|
|
1951
1939
|
continue;
|
|
@@ -1955,14 +1943,15 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
1955
1943
|
attended: attention.attended ? [
|
|
1956
1944
|
...attention.attended
|
|
1957
1945
|
] : [],
|
|
1958
|
-
added,
|
|
1959
|
-
removed
|
|
1946
|
+
added: ids2,
|
|
1947
|
+
// TODO(Zan): When we re-open a part, we should remove it from the removed list in the navigation plugin.
|
|
1948
|
+
removed: removed.filter((id) => !ids2.includes(id))
|
|
1960
1949
|
}).catch((err) => {
|
|
1961
1950
|
log3.warn("Failed to broadcast active node for presence.", {
|
|
1962
1951
|
err: err.message
|
|
1963
1952
|
}, {
|
|
1964
1953
|
F: __dxlog_file6,
|
|
1965
|
-
L:
|
|
1954
|
+
L: 294,
|
|
1966
1955
|
S: void 0,
|
|
1967
1956
|
C: (f, a) => f(...a)
|
|
1968
1957
|
});
|
|
@@ -1980,8 +1969,7 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
1980
1969
|
spaceSubscriptions.add(space.listen("viewing", (message) => {
|
|
1981
1970
|
const { added, removed, attended } = message.payload;
|
|
1982
1971
|
const identityKey = PublicKey2.safeFrom(message.payload.identityKey);
|
|
1983
|
-
|
|
1984
|
-
if (identityKey && !currentIdentity?.identityKey.equals(identityKey) && Array.isArray(added) && Array.isArray(removed)) {
|
|
1972
|
+
if (identityKey && Array.isArray(added) && Array.isArray(removed)) {
|
|
1985
1973
|
added.forEach((id) => {
|
|
1986
1974
|
if (typeof id === "string") {
|
|
1987
1975
|
if (!(id in state.values.viewersByObject)) {
|
|
@@ -2267,7 +2255,7 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
2267
2255
|
childrenPersistenceClass: "echo",
|
|
2268
2256
|
onRearrangeChildren: async (nextOrder) => {
|
|
2269
2257
|
graph._sortEdges(SPACES, "outbound", nextOrder.map(({ id }) => id));
|
|
2270
|
-
const { objects: [spacesOrder] } = await client.spaces.default.db.query(
|
|
2258
|
+
const { objects: [spacesOrder] } = await client.spaces.default.db.query(Filter.schema(Expando, {
|
|
2271
2259
|
key: SHARED
|
|
2272
2260
|
})).run();
|
|
2273
2261
|
if (spacesOrder) {
|
|
@@ -2275,7 +2263,7 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
2275
2263
|
} else {
|
|
2276
2264
|
log3.warn("spaces order object not found", void 0, {
|
|
2277
2265
|
F: __dxlog_file6,
|
|
2278
|
-
L:
|
|
2266
|
+
L: 599,
|
|
2279
2267
|
S: void 0,
|
|
2280
2268
|
C: (f, a) => f(...a)
|
|
2281
2269
|
});
|
|
@@ -2340,7 +2328,7 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
2340
2328
|
return;
|
|
2341
2329
|
}
|
|
2342
2330
|
try {
|
|
2343
|
-
const [spacesOrder] = memoizeQuery(client.spaces.default,
|
|
2331
|
+
const [spacesOrder] = memoizeQuery(client.spaces.default, Filter.schema(Expando, {
|
|
2344
2332
|
key: SHARED
|
|
2345
2333
|
}));
|
|
2346
2334
|
const order = spacesOrder?.order ?? [];
|
|
@@ -2466,14 +2454,7 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
2466
2454
|
if (!store.value) {
|
|
2467
2455
|
void space.db.query({
|
|
2468
2456
|
id: objectId
|
|
2469
|
-
}).first().then((o) => store.value = o)
|
|
2470
|
-
objectId
|
|
2471
|
-
}, {
|
|
2472
|
-
F: __dxlog_file6,
|
|
2473
|
-
L: 835,
|
|
2474
|
-
S: void 0,
|
|
2475
|
-
C: (f, a) => f(...a)
|
|
2476
|
-
}));
|
|
2457
|
+
}).first().then((o) => store.value = o);
|
|
2477
2458
|
}
|
|
2478
2459
|
}, id);
|
|
2479
2460
|
const object = store.value;
|
|
@@ -2544,9 +2525,15 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
2544
2525
|
}
|
|
2545
2526
|
};
|
|
2546
2527
|
}
|
|
2547
|
-
const
|
|
2548
|
-
|
|
2549
|
-
|
|
2528
|
+
const object = toSignal((onChange) => {
|
|
2529
|
+
const timeout = setTimeout(async () => {
|
|
2530
|
+
await space?.db.query({
|
|
2531
|
+
id: objectId
|
|
2532
|
+
}).first();
|
|
2533
|
+
onChange();
|
|
2534
|
+
});
|
|
2535
|
+
return () => clearTimeout(timeout);
|
|
2536
|
+
}, () => space?.db.getObjectById(objectId), subjectId);
|
|
2550
2537
|
if (!object || !subjectId) {
|
|
2551
2538
|
return;
|
|
2552
2539
|
}
|
|
@@ -3009,7 +2996,7 @@ var SpacePlugin = ({ invitationUrl = window.location.origin, invitationParam = "
|
|
|
3009
2996
|
const objects = intent.data?.objects ?? intent.data?.result;
|
|
3010
2997
|
invariant2(Array.isArray(objects), void 0, {
|
|
3011
2998
|
F: __dxlog_file6,
|
|
3012
|
-
L:
|
|
2999
|
+
L: 1346,
|
|
3013
3000
|
S: void 0,
|
|
3014
3001
|
A: [
|
|
3015
3002
|
"Array.isArray(objects)",
|