@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/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "@dxos/plugin-pwa",
3
- "version": "0.8.4-main.b97322e",
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
- "@preact-signals/safe-react": "^0.9.0",
27
- "effect": "3.17.0",
28
- "@dxos/app-framework": "0.8.4-main.b97322e",
29
- "@dxos/observability": "0.8.4-main.b97322e",
30
- "@dxos/log": "0.8.4-main.b97322e"
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": "~18.2.0",
34
- "@types/react-dom": "~18.2.0",
35
- "react": "~18.2.0",
36
- "react-dom": "~18.2.0",
37
- "vite": "5.4.7",
38
- "vite-plugin-pwa": "^0.18.2",
39
- "workbox-window": "^7.0.0",
40
- "@dxos/react-ui": "0.8.4-main.b97322e",
41
- "@dxos/storybook-utils": "0.8.4-main.b97322e",
42
- "@dxos/react-ui-theme": "0.8.4-main.b97322e"
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": "^3.13.3",
46
- "react": "~18.2.0",
47
- "react-dom": "~18.2.0",
48
- "@dxos/react-ui": "0.8.4-main.b97322e",
49
- "@dxos/react-ui-theme": "0.8.4-main.b97322e"
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, PWA_PLUGIN } from './meta';
12
+ import { meta } from './meta';
20
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
+ 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
- return contributes(Capabilities.Null, null);
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 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
  };