@dxos/plugin-pwa 0.8.3-staging.0fa589b → 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/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "@dxos/plugin-pwa",
3
- "version": "0.8.3-staging.0fa589b",
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
- "@preact-signals/safe-react": "^0.9.0",
27
- "effect": "^3.13.3",
28
- "@dxos/log": "0.8.3-staging.0fa589b",
29
- "@dxos/observability": "0.8.3-staging.0fa589b",
30
- "@dxos/app-framework": "0.8.3-staging.0fa589b"
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
- "@phosphor-icons/react": "^2.1.5",
34
- "@types/react": "~18.2.0",
35
- "@types/react-dom": "~18.2.0",
36
- "react": "~18.2.0",
37
- "react-dom": "~18.2.0",
38
- "vite": "5.4.7",
39
- "vite-plugin-pwa": "^0.18.2",
40
- "workbox-window": "^7.0.0",
41
- "@dxos/react-ui": "0.8.3-staging.0fa589b",
42
- "@dxos/react-ui-theme": "0.8.3-staging.0fa589b",
43
- "@dxos/storybook-utils": "0.8.3-staging.0fa589b"
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
- "@phosphor-icons/react": "^2.1.5",
47
- "effect": "^3.13.3",
48
- "react": "~18.2.0",
49
- "react-dom": "~18.2.0",
50
- "@dxos/react-ui": "0.8.3-staging.0fa589b",
51
- "@dxos/react-ui-theme": "0.8.3-staging.0fa589b"
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
- Capabilities,
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, PWA_PLUGIN } from './meta';
20
- import translations from './translations';
12
+ import { meta } from './meta';
13
+ import { translations } from './translations';
21
14
 
22
- export const PwaPlugin = () =>
23
- definePlugin(meta, [
24
- defineModule({
25
- id: `${meta.id}/module/translations`,
26
- activatesOn: Events.SetupTranslations,
27
- activate: () => contributes(Capabilities.Translations, translations),
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
- return contributes(Capabilities.Null, null);
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 PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
6
7
 
7
- export const PWA_PLUGIN = 'dxos.org/plugin/pwa';
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
  };
@@ -2,12 +2,14 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { PWA_PLUGIN } from './meta';
5
+ import { type Resource } from '@dxos/react-ui';
6
6
 
7
- export default [
7
+ import { meta } from './meta';
8
+
9
+ export const translations = [
8
10
  {
9
11
  'en-US': {
10
- [PWA_PLUGIN]: {
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[];