@dxos/plugin-pwa 0.8.3 → 0.8.4-main.1068cf700f
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 +83 -88
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/PwaPlugin.d.ts +2 -1
- package/dist/types/src/PwaPlugin.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +11 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -23
- package/src/PwaPlugin.tsx +38 -60
- package/src/meta.ts +8 -5
- package/src/translations.ts +6 -4
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-pwa",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-main.1068cf700f",
|
|
4
4
|
"description": "DXOS Surface plugin for PWA registration and update handling.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
10
14
|
"type": "module",
|
|
11
15
|
"exports": {
|
|
12
16
|
".": {
|
|
17
|
+
"source": "./src/index.ts",
|
|
13
18
|
"types": "./dist/types/src/index.d.ts",
|
|
14
19
|
"browser": "./dist/lib/browser/index.mjs"
|
|
15
20
|
}
|
|
@@ -23,32 +28,32 @@
|
|
|
23
28
|
"src"
|
|
24
29
|
],
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
+
"effect": "3.19.16",
|
|
32
|
+
"@dxos/app-framework": "0.8.4-main.1068cf700f",
|
|
33
|
+
"@dxos/log": "0.8.4-main.1068cf700f",
|
|
34
|
+
"@dxos/util": "0.8.4-main.1068cf700f",
|
|
35
|
+
"@dxos/app-toolkit": "0.8.4-main.1068cf700f",
|
|
36
|
+
"@dxos/observability": "0.8.4-main.1068cf700f",
|
|
37
|
+
"@dxos/operation": "0.8.4-main.1068cf700f"
|
|
31
38
|
},
|
|
32
39
|
"devDependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@types/react": "~
|
|
35
|
-
"
|
|
36
|
-
"react": "~
|
|
37
|
-
"
|
|
38
|
-
"vite": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/react-ui-theme": "0.8.3"
|
|
40
|
+
"@types/react": "~19.2.7",
|
|
41
|
+
"@types/react-dom": "~19.2.3",
|
|
42
|
+
"react": "~19.2.3",
|
|
43
|
+
"react-dom": "~19.2.3",
|
|
44
|
+
"vite": "7.1.9",
|
|
45
|
+
"vite-plugin-pwa": "^1.0.2",
|
|
46
|
+
"workbox-window": "^7.3.0",
|
|
47
|
+
"@dxos/ui-theme": "0.8.4-main.1068cf700f",
|
|
48
|
+
"@dxos/storybook-utils": "0.8.4-main.1068cf700f",
|
|
49
|
+
"@dxos/react-ui": "0.8.4-main.1068cf700f"
|
|
44
50
|
},
|
|
45
51
|
"peerDependencies": {
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"react": "~
|
|
49
|
-
"react-
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/react-ui-theme": "0.8.3"
|
|
52
|
+
"effect": "3.19.16",
|
|
53
|
+
"react": "~19.2.3",
|
|
54
|
+
"react-dom": "~19.2.3",
|
|
55
|
+
"@dxos/react-ui": "0.8.4-main.1068cf700f",
|
|
56
|
+
"@dxos/ui-theme": "0.8.4-main.1068cf700f"
|
|
52
57
|
},
|
|
53
58
|
"publishConfig": {
|
|
54
59
|
"access": "public"
|
package/src/PwaPlugin.tsx
CHANGED
|
@@ -2,70 +2,48 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
5
6
|
import { registerSW } from 'virtual:pwa-register';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
contributes,
|
|
10
|
-
createIntent,
|
|
11
|
-
defineModule,
|
|
12
|
-
definePlugin,
|
|
13
|
-
Events,
|
|
14
|
-
LayoutAction,
|
|
15
|
-
} from '@dxos/app-framework';
|
|
8
|
+
import { ActivationEvents, Capabilities, Capability, Plugin } from '@dxos/app-framework';
|
|
9
|
+
import { AppPlugin, LayoutOperation } from '@dxos/app-toolkit';
|
|
16
10
|
import { log } from '@dxos/log';
|
|
17
|
-
import { captureException } from '@dxos/observability/sentry';
|
|
18
11
|
|
|
19
|
-
import { meta
|
|
20
|
-
import translations from './translations';
|
|
12
|
+
import { meta } from './meta';
|
|
13
|
+
import { translations } from './translations';
|
|
21
14
|
|
|
22
|
-
export const PwaPlugin = ()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
defineModule({
|
|
30
|
-
id: `${meta.id}/module/register-pwa`,
|
|
31
|
-
activatesOn: Events.DispatcherReady,
|
|
32
|
-
activate: (context) => {
|
|
33
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
34
|
-
|
|
35
|
-
const updateSW = registerSW({
|
|
36
|
-
onNeedRefresh: () =>
|
|
37
|
-
dispatch?.(
|
|
38
|
-
createIntent(LayoutAction.AddToast, {
|
|
39
|
-
part: 'toast',
|
|
40
|
-
subject: {
|
|
41
|
-
id: `${PWA_PLUGIN}/need-refresh`,
|
|
42
|
-
title: ['need refresh label', { ns: PWA_PLUGIN }],
|
|
43
|
-
description: ['need refresh description', { ns: PWA_PLUGIN }],
|
|
44
|
-
duration: 4 * 60 * 1000, // 4m
|
|
45
|
-
actionLabel: ['refresh label', { ns: PWA_PLUGIN }],
|
|
46
|
-
actionAlt: ['refresh alt', { ns: PWA_PLUGIN }],
|
|
47
|
-
onAction: () => updateSW(true),
|
|
48
|
-
},
|
|
49
|
-
}),
|
|
50
|
-
),
|
|
51
|
-
onOfflineReady: () =>
|
|
52
|
-
dispatch?.(
|
|
53
|
-
createIntent(LayoutAction.AddToast, {
|
|
54
|
-
part: 'toast',
|
|
55
|
-
subject: {
|
|
56
|
-
id: `${PWA_PLUGIN}/offline-ready`,
|
|
57
|
-
title: ['offline ready label', { ns: PWA_PLUGIN }],
|
|
58
|
-
closeLabel: ['confirm label', { ns: PWA_PLUGIN }],
|
|
59
|
-
},
|
|
60
|
-
}),
|
|
61
|
-
),
|
|
62
|
-
onRegisterError: (err) => {
|
|
63
|
-
captureException(err);
|
|
64
|
-
log.error(err);
|
|
65
|
-
},
|
|
66
|
-
});
|
|
15
|
+
export const PwaPlugin = Plugin.define(meta).pipe(
|
|
16
|
+
AppPlugin.addTranslationsModule({ translations }),
|
|
17
|
+
Plugin.addModule({
|
|
18
|
+
id: 'register-pwa',
|
|
19
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
20
|
+
activate: Effect.fnUntraced(function* () {
|
|
21
|
+
const { invokeSync } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
67
22
|
|
|
68
|
-
|
|
69
|
-
|
|
23
|
+
const updateSW = registerSW({
|
|
24
|
+
onNeedRefresh: () => {
|
|
25
|
+
invokeSync(LayoutOperation.AddToast, {
|
|
26
|
+
id: `${meta.id}/need-refresh`,
|
|
27
|
+
title: ['need refresh label', { ns: meta.id }],
|
|
28
|
+
description: ['need refresh description', { ns: meta.id }],
|
|
29
|
+
duration: 4 * 60 * 1000, // 4m
|
|
30
|
+
actionLabel: ['refresh label', { ns: meta.id }],
|
|
31
|
+
actionAlt: ['refresh alt', { ns: meta.id }],
|
|
32
|
+
onAction: () => updateSW(true),
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
onOfflineReady: () => {
|
|
36
|
+
invokeSync(LayoutOperation.AddToast, {
|
|
37
|
+
id: `${meta.id}/offline-ready`,
|
|
38
|
+
title: ['offline ready label', { ns: meta.id }],
|
|
39
|
+
closeLabel: ['confirm label', { ns: meta.id }],
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
onRegisterError: (err) => {
|
|
43
|
+
log.error(err);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
70
46
|
}),
|
|
71
|
-
|
|
47
|
+
}),
|
|
48
|
+
Plugin.make,
|
|
49
|
+
);
|
package/src/meta.ts
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: PWA_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'dxos.org/plugin/pwa',
|
|
11
10
|
name: 'PWA',
|
|
11
|
+
description: trim`
|
|
12
|
+
Progressive Web App capabilities enabling offline functionality and app-like experience.
|
|
13
|
+
Install to home screen and use the workspace without internet connection.
|
|
14
|
+
`,
|
|
12
15
|
};
|
package/src/translations.ts
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const translations = [
|
|
8
10
|
{
|
|
9
11
|
'en-US': {
|
|
10
|
-
[
|
|
12
|
+
[meta.id]: {
|
|
11
13
|
'need refresh label': 'Refresh now to get app updates',
|
|
12
14
|
'need refresh description': 'You’ll need these updates to continue without interruption.',
|
|
13
15
|
'refresh label': 'Refresh',
|
|
@@ -19,4 +21,4 @@ export default [
|
|
|
19
21
|
},
|
|
20
22
|
},
|
|
21
23
|
},
|
|
22
|
-
];
|
|
24
|
+
] as const satisfies Resource[];
|