@dxos/plugin-pwa 0.8.4-main.b97322e → 0.8.4-main.bc674ce
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 +76 -80
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +27 -21
- package/src/PwaPlugin.tsx +37 -58
- package/src/meta.ts +8 -5
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-pwa",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bc674ce",
|
|
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,30 +28,31 @@
|
|
|
23
28
|
"src"
|
|
24
29
|
],
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
29
|
-
"@dxos/observability": "0.8.4-main.
|
|
30
|
-
"@dxos/
|
|
31
|
+
"effect": "3.19.11",
|
|
32
|
+
"@dxos/log": "0.8.4-main.bc674ce",
|
|
33
|
+
"@dxos/app-framework": "0.8.4-main.bc674ce",
|
|
34
|
+
"@dxos/observability": "0.8.4-main.bc674ce",
|
|
35
|
+
"@dxos/operation": "0.8.4-main.bc674ce",
|
|
36
|
+
"@dxos/util": "0.8.4-main.bc674ce"
|
|
31
37
|
},
|
|
32
38
|
"devDependencies": {
|
|
33
|
-
"@types/react": "~
|
|
34
|
-
"@types/react-dom": "~
|
|
35
|
-
"react": "~
|
|
36
|
-
"react-dom": "~
|
|
37
|
-
"vite": "
|
|
38
|
-
"vite-plugin-pwa": "^0.
|
|
39
|
-
"workbox-window": "^7.
|
|
40
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
41
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
42
|
-
"@dxos/
|
|
39
|
+
"@types/react": "~19.2.7",
|
|
40
|
+
"@types/react-dom": "~19.2.3",
|
|
41
|
+
"react": "~19.2.3",
|
|
42
|
+
"react-dom": "~19.2.3",
|
|
43
|
+
"vite": "7.1.9",
|
|
44
|
+
"vite-plugin-pwa": "^1.0.2",
|
|
45
|
+
"workbox-window": "^7.3.0",
|
|
46
|
+
"@dxos/react-ui": "0.8.4-main.bc674ce",
|
|
47
|
+
"@dxos/storybook-utils": "0.8.4-main.bc674ce",
|
|
48
|
+
"@dxos/ui-theme": "0.8.4-main.bc674ce"
|
|
43
49
|
},
|
|
44
50
|
"peerDependencies": {
|
|
45
|
-
"effect": "
|
|
46
|
-
"react": "~
|
|
47
|
-
"react-dom": "~
|
|
48
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
49
|
-
"@dxos/
|
|
51
|
+
"effect": "3.19.11",
|
|
52
|
+
"react": "~19.2.3",
|
|
53
|
+
"react-dom": "~19.2.3",
|
|
54
|
+
"@dxos/react-ui": "0.8.4-main.bc674ce",
|
|
55
|
+
"@dxos/ui-theme": "0.8.4-main.bc674ce"
|
|
50
56
|
},
|
|
51
57
|
"publishConfig": {
|
|
52
58
|
"access": "public"
|
package/src/PwaPlugin.tsx
CHANGED
|
@@ -2,70 +2,49 @@
|
|
|
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
|
-
Capabilities,
|
|
9
|
-
contributes,
|
|
10
|
-
createIntent,
|
|
11
|
-
defineModule,
|
|
12
|
-
definePlugin,
|
|
13
|
-
Events,
|
|
14
|
-
LayoutAction,
|
|
15
|
-
} from '@dxos/app-framework';
|
|
8
|
+
import { Capability, Common, Plugin } from '@dxos/app-framework';
|
|
16
9
|
import { log } from '@dxos/log';
|
|
17
10
|
import { captureException } from '@dxos/observability/sentry';
|
|
18
11
|
|
|
19
|
-
import { meta
|
|
12
|
+
import { meta } from './meta';
|
|
20
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
|
+
Common.Plugin.addTranslationsModule({ translations }),
|
|
17
|
+
Plugin.addModule({
|
|
18
|
+
id: 'register-pwa',
|
|
19
|
+
activatesOn: Common.ActivationEvent.OperationInvokerReady,
|
|
20
|
+
activate: Effect.fnUntraced(function* () {
|
|
21
|
+
const { invokeSync } = yield* Capability.get(Common.Capability.OperationInvoker);
|
|
67
22
|
|
|
68
|
-
|
|
69
|
-
|
|
23
|
+
const updateSW = registerSW({
|
|
24
|
+
onNeedRefresh: () => {
|
|
25
|
+
invokeSync(Common.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(Common.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
|
+
captureException(err);
|
|
44
|
+
log.error(err);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
70
47
|
}),
|
|
71
|
-
|
|
48
|
+
}),
|
|
49
|
+
Plugin.make,
|
|
50
|
+
);
|
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
|
};
|