@dxos/plugin-space 0.6.14-main.f49f251 → 0.6.14-staging.54a8bab
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/{chunk-FOI7DAUV.mjs → chunk-WZAM3FNP.mjs} +1 -1
- package/dist/lib/browser/{chunk-FOI7DAUV.mjs.map → chunk-WZAM3FNP.mjs.map} +2 -2
- package/dist/lib/browser/index.mjs +432 -387
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node/{chunk-OTDRTHT4.cjs → chunk-HTAM5LQD.cjs} +4 -4
- package/dist/lib/node/{chunk-OTDRTHT4.cjs.map → chunk-HTAM5LQD.cjs.map} +2 -2
- package/dist/lib/node/index.cjs +474 -433
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +11 -11
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{chunk-FYDGMPSC.mjs → chunk-TRJKV4PK.mjs} +1 -1
- package/dist/lib/node-esm/{chunk-FYDGMPSC.mjs.map → chunk-TRJKV4PK.mjs.map} +2 -2
- package/dist/lib/node-esm/index.mjs +432 -387
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/SpacePlugin.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettingsPanel.d.ts.map +1 -1
- package/dist/types/src/components/SyncStatus/Space.d.ts +8 -0
- package/dist/types/src/components/SyncStatus/Space.d.ts.map +1 -0
- package/dist/types/src/components/SyncStatus/SyncStatus.d.ts +3 -2
- package/dist/types/src/components/SyncStatus/SyncStatus.d.ts.map +1 -1
- package/dist/types/src/components/SyncStatus/SyncStatus.stories.d.ts +5 -20
- package/dist/types/src/components/SyncStatus/SyncStatus.stories.d.ts.map +1 -1
- package/dist/types/src/components/SyncStatus/save-tracker.d.ts +3 -0
- package/dist/types/src/components/SyncStatus/save-tracker.d.ts.map +1 -0
- package/dist/types/src/components/SyncStatus/status.d.ts +9 -0
- package/dist/types/src/components/SyncStatus/status.d.ts.map +1 -0
- package/dist/types/src/components/SyncStatus/{types.d.ts → sync-state.d.ts} +1 -1
- package/dist/types/src/components/SyncStatus/sync-state.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +6 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -1
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +34 -33
- package/src/SpacePlugin.tsx +55 -30
- package/src/components/SpaceSettings.tsx +5 -5
- package/src/components/SpaceSettingsPanel.tsx +18 -8
- package/src/components/SyncStatus/Space.tsx +109 -0
- package/src/components/SyncStatus/SyncStatus.stories.tsx +13 -4
- package/src/components/SyncStatus/SyncStatus.tsx +43 -129
- package/src/components/{SaveStatus.tsx → SyncStatus/save-tracker.ts} +1 -25
- package/src/components/SyncStatus/status.ts +44 -0
- package/src/components/index.ts +0 -2
- package/src/translations.ts +6 -0
- package/src/types/types.ts +3 -1
- package/dist/types/src/components/MissingObject.d.ts +0 -5
- package/dist/types/src/components/MissingObject.d.ts.map +0 -1
- package/dist/types/src/components/SaveStatus.d.ts +0 -3
- package/dist/types/src/components/SaveStatus.d.ts.map +0 -1
- package/dist/types/src/components/SyncStatus/types.d.ts.map +0 -1
- package/src/components/MissingObject.tsx +0 -54
- /package/src/components/SyncStatus/{types.ts → sync-state.ts} +0 -0
|
@@ -2,36 +2,12 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
5
|
import { type UnsubscribeCallback } from '@dxos/async';
|
|
8
6
|
import { type Client } from '@dxos/client';
|
|
9
7
|
import { type Space, type SpaceId } from '@dxos/client/echo';
|
|
10
8
|
import { Context } from '@dxos/context';
|
|
11
|
-
import { StatusBar } from '@dxos/plugin-status-bar';
|
|
12
|
-
import { useClient } from '@dxos/react-client';
|
|
13
|
-
import { Icon, useTranslation } from '@dxos/react-ui';
|
|
14
|
-
|
|
15
|
-
import { SPACE_PLUGIN } from '../meta';
|
|
16
|
-
|
|
17
|
-
export const SaveStatus = () => {
|
|
18
|
-
const { t } = useTranslation(SPACE_PLUGIN);
|
|
19
|
-
const client = useClient();
|
|
20
|
-
const [state, setState] = useState<'saved' | 'saving'>('saved');
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
return createClientSaveTracker(client, (state) => {
|
|
23
|
-
setState(state);
|
|
24
|
-
});
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<StatusBar.Item title={state === 'saving' ? t('saving label') : t('saved label')}>
|
|
29
|
-
<Icon icon={state === 'saving' ? 'ph--arrows-clockwise--regular' : 'ph--check-circle--regular'} size={4} />
|
|
30
|
-
</StatusBar.Item>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
9
|
|
|
34
|
-
const createClientSaveTracker = (client: Client, cb: (state: 'saved' | 'saving') => void) => {
|
|
10
|
+
export const createClientSaveTracker = (client: Client, cb: (state: 'saved' | 'saving') => void) => {
|
|
35
11
|
const unsubscribeCallbacks: Record<SpaceId, UnsubscribeCallback> = {};
|
|
36
12
|
const state: Record<SpaceId, 'saved' | 'saving'> = {};
|
|
37
13
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
export type Status = 'saving locally' | 'downloading' | 'uploading' | 'offline persisted' | 'remote synced';
|
|
6
|
+
|
|
7
|
+
export const getStatus = ({
|
|
8
|
+
offline,
|
|
9
|
+
saved,
|
|
10
|
+
needsToUpload,
|
|
11
|
+
needsToDownload,
|
|
12
|
+
}: {
|
|
13
|
+
offline: Boolean;
|
|
14
|
+
saved: Boolean;
|
|
15
|
+
needsToUpload: Boolean;
|
|
16
|
+
needsToDownload: Boolean;
|
|
17
|
+
}): Status => {
|
|
18
|
+
if (!saved) {
|
|
19
|
+
return 'saving locally';
|
|
20
|
+
} else if (!offline && needsToDownload) {
|
|
21
|
+
return 'downloading';
|
|
22
|
+
} else if (!offline && needsToUpload) {
|
|
23
|
+
return 'uploading';
|
|
24
|
+
} else if (offline && !needsToUpload && !needsToDownload) {
|
|
25
|
+
return 'offline persisted';
|
|
26
|
+
} else {
|
|
27
|
+
return 'remote synced';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getIcon = (status: Status) => {
|
|
32
|
+
switch (status) {
|
|
33
|
+
case 'saving locally':
|
|
34
|
+
return 'ph--download--regular';
|
|
35
|
+
case 'downloading':
|
|
36
|
+
return 'ph--cloud-arrow-down--regular';
|
|
37
|
+
case 'uploading':
|
|
38
|
+
return 'ph--cloud-arrow-up--regular';
|
|
39
|
+
case 'offline persisted':
|
|
40
|
+
return 'ph--check-circle--regular';
|
|
41
|
+
case 'remote synced':
|
|
42
|
+
return 'ph--cloud-check--regular';
|
|
43
|
+
}
|
|
44
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ export * from './CollectionMain';
|
|
|
7
7
|
export * from './CollectionSection';
|
|
8
8
|
export * from './DefaultObjectSettings';
|
|
9
9
|
export * from './MenuFooter';
|
|
10
|
-
export * from './MissingObject';
|
|
11
10
|
export * from './PersistenceStatus';
|
|
12
11
|
export * from './PopoverRenameObject';
|
|
13
12
|
export * from './PopoverRenameSpace';
|
|
@@ -16,5 +15,4 @@ export * from './SpaceMain';
|
|
|
16
15
|
export * from './SpacePresence';
|
|
17
16
|
export * from './SpaceSettings';
|
|
18
17
|
export * from './SpaceSettingsPanel';
|
|
19
|
-
export * from './SaveStatus';
|
|
20
18
|
export * from './SyncStatus';
|
package/src/translations.ts
CHANGED
|
@@ -94,6 +94,12 @@ export default [
|
|
|
94
94
|
'name placeholder': 'Name',
|
|
95
95
|
'unnamed object settings label': 'Settings',
|
|
96
96
|
'edge replication label': 'Enable EDGE Replication',
|
|
97
|
+
'saving locally label': 'Writing to disk',
|
|
98
|
+
'downloading label': 'Replicating from peers',
|
|
99
|
+
'uploading label': 'Replicating to peers',
|
|
100
|
+
'offline persisted label': 'Saved to disk (offline)',
|
|
101
|
+
'remote synced label': 'Synced with peers',
|
|
102
|
+
'open settings panel label': 'Show Settings',
|
|
97
103
|
},
|
|
98
104
|
},
|
|
99
105
|
},
|
package/src/types/types.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
} from '@dxos/app-framework';
|
|
15
15
|
import { type Expando } from '@dxos/echo-schema';
|
|
16
16
|
import { type SchemaProvides } from '@dxos/plugin-client';
|
|
17
|
+
import { type PanelProvides } from '@dxos/plugin-deck/types';
|
|
17
18
|
import { type PublicKey } from '@dxos/react-client';
|
|
18
19
|
import { type Space } from '@dxos/react-client/echo';
|
|
19
20
|
import { type Label } from '@dxos/react-ui';
|
|
@@ -87,7 +88,8 @@ export type SpacePluginProvides = SurfaceProvides &
|
|
|
87
88
|
MetadataRecordsProvides &
|
|
88
89
|
SettingsProvides<SpaceSettingsProps> &
|
|
89
90
|
TranslationsProvides &
|
|
90
|
-
SchemaProvides &
|
|
91
|
+
SchemaProvides &
|
|
92
|
+
PanelProvides & {
|
|
91
93
|
space: Readonly<PluginState>;
|
|
92
94
|
};
|
|
93
95
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MissingObject.d.ts","sourceRoot":"","sources":["../../../../src/components/MissingObject.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAUnD,eAAO,MAAM,aAAa,WAAY;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,sBAuCnD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SaveStatus.d.ts","sourceRoot":"","sources":["../../../../src/components/SaveStatus.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAYnD,eAAO,MAAM,UAAU,yBAetB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/SyncStatus/types.ts"],"names":[],"mappings":"AAMA,OAAO,EAAc,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKlF,MAAM,MAAM,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAErE,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAE/D,eAAO,MAAM,wBAAwB,QAAO,aAM1C,CAAC;AAEH,eAAO,MAAM,cAAc,YAAa,iBAAiB,KAAG,aAS3D,CAAC;AAKF;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,iBAkC/B,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { parseIntentPlugin, useResolvePlugin } from '@dxos/app-framework';
|
|
8
|
-
import { Status, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
import { baseSurface, descriptionText, mx } from '@dxos/react-ui-theme';
|
|
10
|
-
|
|
11
|
-
import { SpaceAction, SPACE_PLUGIN } from '../meta';
|
|
12
|
-
|
|
13
|
-
const WAIT_FOR_OBJECT_TIMEOUT = 1_000;
|
|
14
|
-
|
|
15
|
-
export const MissingObject = ({ id }: { id: string }) => {
|
|
16
|
-
const { t } = useTranslation(SPACE_PLUGIN);
|
|
17
|
-
const [waiting, setWaiting] = useState(false);
|
|
18
|
-
const intentPlugin = useResolvePlugin(parseIntentPlugin);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!intentPlugin) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const timeout = setTimeout(async () => {
|
|
26
|
-
setWaiting(true);
|
|
27
|
-
await intentPlugin.provides.intent.dispatch({
|
|
28
|
-
plugin: SPACE_PLUGIN,
|
|
29
|
-
action: SpaceAction.WAIT_FOR_OBJECT,
|
|
30
|
-
data: { id },
|
|
31
|
-
});
|
|
32
|
-
}, WAIT_FOR_OBJECT_TIMEOUT);
|
|
33
|
-
|
|
34
|
-
return () => clearTimeout(timeout);
|
|
35
|
-
}, [intentPlugin, id]);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div role='none' className={mx(baseSurface, 'min-bs-screen is-full flex items-center justify-center p-8')}>
|
|
39
|
-
{waiting ? (
|
|
40
|
-
<p
|
|
41
|
-
role='alert'
|
|
42
|
-
className={mx(
|
|
43
|
-
descriptionText,
|
|
44
|
-
'border border-dashed border-neutral-400/50 rounded-lg flex items-center justify-center p-8 font-normal text-lg',
|
|
45
|
-
)}
|
|
46
|
-
>
|
|
47
|
-
{t('missing object message')}
|
|
48
|
-
</p>
|
|
49
|
-
) : (
|
|
50
|
-
<Status indeterminate aria-label='Initializing' />
|
|
51
|
-
)}
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
File without changes
|