@dxos/plugin-pwa 0.7.5-main.9d26e3a → 0.7.5-main.e9bb01b

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.
@@ -1,86 +1,89 @@
1
- import {
2
- PWA_PLUGIN,
3
- meta_default
4
- } from "./chunk-WYTLXSAY.mjs";
1
+ // packages/plugins/plugin-pwa/src/meta.ts
2
+ var PWA_PLUGIN = "dxos.org/plugin/pwa";
3
+ var meta = {
4
+ id: PWA_PLUGIN
5
+ };
5
6
 
6
7
  // packages/plugins/plugin-pwa/src/PwaPlugin.tsx
7
8
  import { registerSW } from "virtual:pwa-register";
8
- import { parseIntentPlugin, resolvePlugin, LayoutAction, createIntent } from "@dxos/app-framework";
9
+ import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events, LayoutAction } from "@dxos/app-framework";
9
10
  import { log } from "@dxos/log";
10
11
  import { captureException } from "@dxos/observability/sentry";
11
12
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-pwa/src/PwaPlugin.tsx";
12
- var PwaPlugin = () => ({
13
- meta: meta_default,
14
- ready: async ({ plugins }) => {
15
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
16
- const updateSW = registerSW({
17
- onNeedRefresh: () => dispatch?.(createIntent(LayoutAction.SetLayout, {
18
- element: "toast",
19
- subject: {
20
- id: `${PWA_PLUGIN}/need-refresh`,
21
- title: [
22
- "need refresh label",
23
- {
24
- ns: PWA_PLUGIN
25
- }
26
- ],
27
- description: [
28
- "need refresh description",
29
- {
30
- ns: PWA_PLUGIN
31
- }
32
- ],
33
- duration: 4 * 60 * 1e3,
34
- actionLabel: [
35
- "refresh label",
36
- {
37
- ns: PWA_PLUGIN
38
- }
39
- ],
40
- actionAlt: [
41
- "refresh alt",
42
- {
43
- ns: PWA_PLUGIN
44
- }
45
- ],
46
- onAction: () => updateSW(true)
47
- }
48
- })),
49
- onOfflineReady: () => dispatch?.(createIntent(LayoutAction.SetLayout, {
50
- element: "toast",
51
- subject: {
52
- id: `${PWA_PLUGIN}/offline-ready`,
53
- title: [
54
- "offline ready label",
55
- {
56
- ns: PWA_PLUGIN
57
- }
58
- ],
59
- closeLabel: [
60
- "confirm label",
61
- {
62
- ns: PWA_PLUGIN
63
- }
64
- ]
13
+ var PwaPlugin = () => definePlugin(meta, [
14
+ defineModule({
15
+ id: `${meta.id}/module/register-pwa`,
16
+ activatesOn: Events.DispatcherReady,
17
+ activate: (context) => {
18
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
19
+ const updateSW = registerSW({
20
+ onNeedRefresh: () => dispatch?.(createIntent(LayoutAction.AddToast, {
21
+ part: "toast",
22
+ subject: {
23
+ id: `${PWA_PLUGIN}/need-refresh`,
24
+ title: [
25
+ "need refresh label",
26
+ {
27
+ ns: PWA_PLUGIN
28
+ }
29
+ ],
30
+ description: [
31
+ "need refresh description",
32
+ {
33
+ ns: PWA_PLUGIN
34
+ }
35
+ ],
36
+ duration: 4 * 60 * 1e3,
37
+ actionLabel: [
38
+ "refresh label",
39
+ {
40
+ ns: PWA_PLUGIN
41
+ }
42
+ ],
43
+ actionAlt: [
44
+ "refresh alt",
45
+ {
46
+ ns: PWA_PLUGIN
47
+ }
48
+ ],
49
+ onAction: () => updateSW(true)
50
+ }
51
+ })),
52
+ onOfflineReady: () => dispatch?.(createIntent(LayoutAction.AddToast, {
53
+ part: "toast",
54
+ subject: {
55
+ id: `${PWA_PLUGIN}/offline-ready`,
56
+ title: [
57
+ "offline ready label",
58
+ {
59
+ ns: PWA_PLUGIN
60
+ }
61
+ ],
62
+ closeLabel: [
63
+ "confirm label",
64
+ {
65
+ ns: PWA_PLUGIN
66
+ }
67
+ ]
68
+ }
69
+ })),
70
+ onRegisterError: (err) => {
71
+ captureException(err);
72
+ log.error(err, void 0, {
73
+ F: __dxlog_file,
74
+ L: 58,
75
+ S: void 0,
76
+ C: (f, a) => f(...a)
77
+ });
65
78
  }
66
- })),
67
- onRegisterError: (err) => {
68
- captureException(err);
69
- log.error(err, void 0, {
70
- F: __dxlog_file,
71
- L: 53,
72
- S: void 0,
73
- C: (f, a) => f(...a)
74
- });
75
- }
76
- });
77
- }
78
- });
79
-
80
- // packages/plugins/plugin-pwa/src/index.ts
81
- var src_default = PwaPlugin;
79
+ });
80
+ return contributes(Capabilities.Null, null);
81
+ }
82
+ })
83
+ ]);
82
84
  export {
85
+ PWA_PLUGIN,
83
86
  PwaPlugin,
84
- src_default as default
87
+ meta
85
88
  };
86
89
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/PwaPlugin.tsx", "../../../src/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { registerSW } from 'virtual:pwa-register';\n\nimport {\n parseIntentPlugin,\n resolvePlugin,\n type PluginDefinition,\n LayoutAction,\n createIntent,\n} from '@dxos/app-framework';\nimport { log } from '@dxos/log';\nimport { captureException } from '@dxos/observability/sentry';\n\nimport meta, { PWA_PLUGIN } from './meta';\n\nexport const PwaPlugin = (): PluginDefinition => ({\n meta,\n ready: async ({ plugins }) => {\n const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;\n\n const updateSW = registerSW({\n onNeedRefresh: () =>\n dispatch?.(\n createIntent(LayoutAction.SetLayout, {\n element: 'toast',\n subject: {\n id: `${PWA_PLUGIN}/need-refresh`,\n title: ['need refresh label', { ns: PWA_PLUGIN }],\n description: ['need refresh description', { ns: PWA_PLUGIN }],\n duration: 4 * 60 * 1000, // 4m\n actionLabel: ['refresh label', { ns: PWA_PLUGIN }],\n actionAlt: ['refresh alt', { ns: PWA_PLUGIN }],\n onAction: () => updateSW(true),\n },\n }),\n ),\n onOfflineReady: () =>\n dispatch?.(\n createIntent(LayoutAction.SetLayout, {\n element: 'toast',\n subject: {\n id: `${PWA_PLUGIN}/offline-ready`,\n title: ['offline ready label', { ns: PWA_PLUGIN }],\n closeLabel: ['confirm label', { ns: PWA_PLUGIN }],\n },\n }),\n ),\n onRegisterError: (err) => {\n captureException(err);\n log.error(err);\n },\n });\n },\n});\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { PwaPlugin } from './PwaPlugin';\n\nexport default PwaPlugin;\n\nexport * from './PwaPlugin';\n"],
5
- "mappings": ";;;;;;AAIA,SAASA,kBAAkB;AAE3B,SACEC,mBACAC,eAEAC,cACAC,oBACK;AACP,SAASC,WAAW;AACpB,SAASC,wBAAwB;;AAI1B,IAAMC,YAAY,OAAyB;EAChDC;EACAC,OAAO,OAAO,EAAEC,QAAO,MAAE;AACvB,UAAMC,WAAWC,cAAcF,SAASG,iBAAAA,GAAoBC,SAASC,OAAOC;AAE5E,UAAMC,WAAWC,WAAW;MAC1BC,eAAe,MACbR,WACES,aAAaC,aAAaC,WAAW;QACnCC,SAAS;QACTC,SAAS;UACPC,IAAI,GAAGC,UAAAA;UACPC,OAAO;YAAC;YAAsB;cAAEC,IAAIF;YAAW;;UAC/CG,aAAa;YAAC;YAA4B;cAAED,IAAIF;YAAW;;UAC3DI,UAAU,IAAI,KAAK;UACnBC,aAAa;YAAC;YAAiB;cAAEH,IAAIF;YAAW;;UAChDM,WAAW;YAAC;YAAe;cAAEJ,IAAIF;YAAW;;UAC5CO,UAAU,MAAMhB,SAAS,IAAA;QAC3B;MACF,CAAA,CAAA;MAEJiB,gBAAgB,MACdvB,WACES,aAAaC,aAAaC,WAAW;QACnCC,SAAS;QACTC,SAAS;UACPC,IAAI,GAAGC,UAAAA;UACPC,OAAO;YAAC;YAAuB;cAAEC,IAAIF;YAAW;;UAChDS,YAAY;YAAC;YAAiB;cAAEP,IAAIF;YAAW;;QACjD;MACF,CAAA,CAAA;MAEJU,iBAAiB,CAACC,QAAAA;AAChBC,yBAAiBD,GAAAA;AACjBE,YAAIC,MAAMH,KAAAA,QAAAA;;;;;;MACZ;IACF,CAAA;EACF;AACF;;;AClDA,IAAA,cAAeI;",
6
- "names": ["registerSW", "parseIntentPlugin", "resolvePlugin", "LayoutAction", "createIntent", "log", "captureException", "PwaPlugin", "meta", "ready", "plugins", "dispatch", "resolvePlugin", "parseIntentPlugin", "provides", "intent", "dispatchPromise", "updateSW", "registerSW", "onNeedRefresh", "createIntent", "LayoutAction", "SetLayout", "element", "subject", "id", "PWA_PLUGIN", "title", "ns", "description", "duration", "actionLabel", "actionAlt", "onAction", "onOfflineReady", "closeLabel", "onRegisterError", "err", "captureException", "log", "error", "PwaPlugin"]
3
+ "sources": ["../../../src/meta.ts", "../../../src/PwaPlugin.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const PWA_PLUGIN = 'dxos.org/plugin/pwa';\n\nexport const meta = {\n id: PWA_PLUGIN,\n} satisfies PluginMeta;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { registerSW } from 'virtual:pwa-register';\n\nimport {\n Capabilities,\n contributes,\n createIntent,\n defineModule,\n definePlugin,\n Events,\n LayoutAction,\n} from '@dxos/app-framework';\nimport { log } from '@dxos/log';\nimport { captureException } from '@dxos/observability/sentry';\n\nimport { meta, PWA_PLUGIN } from './meta';\n\nexport const PwaPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/register-pwa`,\n activatesOn: Events.DispatcherReady,\n activate: (context) => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n\n const updateSW = registerSW({\n onNeedRefresh: () =>\n dispatch?.(\n createIntent(LayoutAction.AddToast, {\n part: 'toast',\n subject: {\n id: `${PWA_PLUGIN}/need-refresh`,\n title: ['need refresh label', { ns: PWA_PLUGIN }],\n description: ['need refresh description', { ns: PWA_PLUGIN }],\n duration: 4 * 60 * 1000, // 4m\n actionLabel: ['refresh label', { ns: PWA_PLUGIN }],\n actionAlt: ['refresh alt', { ns: PWA_PLUGIN }],\n onAction: () => updateSW(true),\n },\n }),\n ),\n onOfflineReady: () =>\n dispatch?.(\n createIntent(LayoutAction.AddToast, {\n part: 'toast',\n subject: {\n id: `${PWA_PLUGIN}/offline-ready`,\n title: ['offline ready label', { ns: PWA_PLUGIN }],\n closeLabel: ['confirm label', { ns: PWA_PLUGIN }],\n },\n }),\n ),\n onRegisterError: (err) => {\n captureException(err);\n log.error(err);\n },\n });\n\n return contributes(Capabilities.Null, null);\n },\n }),\n ]);\n"],
5
+ "mappings": ";AAMO,IAAMA,aAAa;AAEnB,IAAMC,OAAO;EAClBC,IAAIF;AACN;;;ACNA,SAASG,kBAAkB;AAE3B,SACEC,cACAC,aACAC,cACAC,cACAC,cACAC,QACAC,oBACK;AACP,SAASC,WAAW;AACpB,SAASC,wBAAwB;;AAI1B,IAAMC,YAAY,MACvBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAU,CAACC,YAAAA;AACT,YAAM,EAAEC,iBAAiBC,SAAQ,IAAKF,QAAQG,kBAAkBC,aAAaC,gBAAgB;AAE7F,YAAMC,WAAWC,WAAW;QAC1BC,eAAe,MACbN,WACEO,aAAaC,aAAaC,UAAU;UAClCC,MAAM;UACNC,SAAS;YACPlB,IAAI,GAAGmB,UAAAA;YACPC,OAAO;cAAC;cAAsB;gBAAEC,IAAIF;cAAW;;YAC/CG,aAAa;cAAC;cAA4B;gBAAED,IAAIF;cAAW;;YAC3DI,UAAU,IAAI,KAAK;YACnBC,aAAa;cAAC;cAAiB;gBAAEH,IAAIF;cAAW;;YAChDM,WAAW;cAAC;cAAe;gBAAEJ,IAAIF;cAAW;;YAC5CO,UAAU,MAAMf,SAAS,IAAA;UAC3B;QACF,CAAA,CAAA;QAEJgB,gBAAgB,MACdpB,WACEO,aAAaC,aAAaC,UAAU;UAClCC,MAAM;UACNC,SAAS;YACPlB,IAAI,GAAGmB,UAAAA;YACPC,OAAO;cAAC;cAAuB;gBAAEC,IAAIF;cAAW;;YAChDS,YAAY;cAAC;cAAiB;gBAAEP,IAAIF;cAAW;;UACjD;QACF,CAAA,CAAA;QAEJU,iBAAiB,CAACC,QAAAA;AAChBC,2BAAiBD,GAAAA;AACjBE,cAAIC,MAAMH,KAAAA,QAAAA;;;;;;QACZ;MACF,CAAA;AAEA,aAAOI,YAAYzB,aAAa0B,MAAM,IAAA;IACxC;EACF,CAAA;CACD;",
6
+ "names": ["PWA_PLUGIN", "meta", "id", "registerSW", "Capabilities", "contributes", "createIntent", "defineModule", "definePlugin", "Events", "LayoutAction", "log", "captureException", "PwaPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "DispatcherReady", "activate", "context", "dispatchPromise", "dispatch", "requestCapability", "Capabilities", "IntentDispatcher", "updateSW", "registerSW", "onNeedRefresh", "createIntent", "LayoutAction", "AddToast", "part", "subject", "PWA_PLUGIN", "title", "ns", "description", "duration", "actionLabel", "actionAlt", "onAction", "onOfflineReady", "closeLabel", "onRegisterError", "err", "captureException", "log", "error", "contributes", "Null"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/plugins/plugin-pwa/src/meta.ts":{"bytes":838,"imports":[],"format":"esm"},"packages/plugins/plugin-pwa/src/PwaPlugin.tsx":{"bytes":7685,"imports":[{"path":"virtual:pwa-register","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/observability/sentry","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-pwa/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-pwa/src/index.ts":{"bytes":743,"imports":[{"path":"packages/plugins/plugin-pwa/src/PwaPlugin.tsx","kind":"import-statement","original":"./PwaPlugin"},{"path":"packages/plugins/plugin-pwa/src/PwaPlugin.tsx","kind":"import-statement","original":"./PwaPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-pwa/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3457},"packages/plugins/plugin-pwa/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/plugin-pwa/dist/lib/browser/chunk-WYTLXSAY.mjs","kind":"import-statement"},{"path":"virtual:pwa-register","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/observability/sentry","kind":"import-statement","external":true}],"exports":["PwaPlugin","default"],"entryPoint":"packages/plugins/plugin-pwa/src/index.ts","inputs":{"packages/plugins/plugin-pwa/src/PwaPlugin.tsx":{"bytesInOutput":1984},"packages/plugins/plugin-pwa/src/index.ts":{"bytesInOutput":29}},"bytes":2262},"packages/plugins/plugin-pwa/dist/lib/browser/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/plugin-pwa/dist/lib/browser/meta.mjs":{"imports":[{"path":"packages/plugins/plugin-pwa/dist/lib/browser/chunk-WYTLXSAY.mjs","kind":"import-statement"}],"exports":["PWA_PLUGIN","default"],"entryPoint":"packages/plugins/plugin-pwa/src/meta.ts","inputs":{},"bytes":155},"packages/plugins/plugin-pwa/dist/lib/browser/chunk-WYTLXSAY.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":395},"packages/plugins/plugin-pwa/dist/lib/browser/chunk-WYTLXSAY.mjs":{"imports":[],"exports":["PWA_PLUGIN","meta_default"],"inputs":{"packages/plugins/plugin-pwa/src/meta.ts":{"bytesInOutput":81}},"bytes":210}}}
1
+ {"inputs":{"packages/plugins/plugin-pwa/src/meta.ts":{"bytes":875,"imports":[],"format":"esm"},"packages/plugins/plugin-pwa/src/PwaPlugin.tsx":{"bytes":8936,"imports":[{"path":"virtual:pwa-register","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/observability/sentry","kind":"import-statement","external":true},{"path":"packages/plugins/plugin-pwa/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-pwa/src/index.ts":{"bytes":580,"imports":[{"path":"packages/plugins/plugin-pwa/src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"packages/plugins/plugin-pwa/src/PwaPlugin.tsx","kind":"import-statement","original":"./PwaPlugin"}],"format":"esm"}},"outputs":{"packages/plugins/plugin-pwa/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":4147},"packages/plugins/plugin-pwa/dist/lib/browser/index.mjs":{"imports":[{"path":"virtual:pwa-register","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/observability/sentry","kind":"import-statement","external":true}],"exports":["PWA_PLUGIN","PwaPlugin","meta"],"entryPoint":"packages/plugins/plugin-pwa/src/index.ts","inputs":{"packages/plugins/plugin-pwa/src/meta.ts":{"bytesInOutput":73},"packages/plugins/plugin-pwa/src/index.ts":{"bytesInOutput":0},"packages/plugins/plugin-pwa/src/PwaPlugin.tsx":{"bytesInOutput":2281}},"bytes":2528}}}
@@ -1,3 +1,2 @@
1
- import { type PluginDefinition } from '@dxos/app-framework';
2
- export declare const PwaPlugin: () => PluginDefinition;
1
+ export declare const PwaPlugin: () => import("@dxos/app-framework").Plugin;
3
2
  //# sourceMappingURL=PwaPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PwaPlugin.d.ts","sourceRoot":"","sources":["../../../src/PwaPlugin.tsx"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,gBAAgB,EAGtB,MAAM,qBAAqB,CAAC;AAM7B,eAAO,MAAM,SAAS,QAAO,gBAsC3B,CAAC"}
1
+ {"version":3,"file":"PwaPlugin.d.ts","sourceRoot":"","sources":["../../../src/PwaPlugin.tsx"],"names":[],"mappings":"AAoBA,eAAO,MAAM,SAAS,4CA4ClB,CAAC"}
@@ -1,4 +1,3 @@
1
- import { PwaPlugin } from './PwaPlugin';
2
- export default PwaPlugin;
1
+ export * from './meta';
3
2
  export * from './PwaPlugin';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAe,SAAS,CAAC;AAEzB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
@@ -1,6 +1,5 @@
1
1
  export declare const PWA_PLUGIN = "dxos.org/plugin/pwa";
2
- declare const _default: {
2
+ export declare const meta: {
3
3
  id: string;
4
4
  };
5
- export default _default;
6
5
  //# sourceMappingURL=meta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,wBAAwB,CAAC;;;;AAEhD,wBAEuB"}
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU,wBAAwB,CAAC;AAEhD,eAAO,MAAM,IAAI;;CAEK,CAAC"}
@@ -1 +1 @@
1
- {"version":"5.7.2"}
1
+ {"version":"5.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-pwa",
3
- "version": "0.7.5-main.9d26e3a",
3
+ "version": "0.7.5-main.e9bb01b",
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",
@@ -11,28 +11,20 @@
11
11
  ".": {
12
12
  "types": "./dist/types/src/index.d.ts",
13
13
  "browser": "./dist/lib/browser/index.mjs"
14
- },
15
- "./meta": {
16
- "types": "./dist/types/src/meta.d.ts",
17
- "browser": "./dist/lib/browser/meta.mjs"
18
14
  }
19
15
  },
20
16
  "types": "dist/types/src/index.d.ts",
21
17
  "typesVersions": {
22
- "*": {
23
- "meta": [
24
- "dist/types/src/meta.d.ts"
25
- ]
26
- }
18
+ "*": {}
27
19
  },
28
20
  "files": [
29
21
  "dist",
30
22
  "src"
31
23
  ],
32
24
  "dependencies": {
33
- "@dxos/app-framework": "0.7.5-main.9d26e3a",
34
- "@dxos/log": "0.7.5-main.9d26e3a",
35
- "@dxos/observability": "0.7.5-main.9d26e3a"
25
+ "@dxos/app-framework": "0.7.5-main.e9bb01b",
26
+ "@dxos/observability": "0.7.5-main.e9bb01b",
27
+ "@dxos/log": "0.7.5-main.e9bb01b"
36
28
  },
37
29
  "devDependencies": {
38
30
  "@phosphor-icons/react": "^2.1.5",
@@ -43,15 +35,15 @@
43
35
  "vite": "5.4.7",
44
36
  "vite-plugin-pwa": "^0.18.2",
45
37
  "workbox-window": "^7.0.0",
46
- "@dxos/react-ui": "0.7.5-main.9d26e3a",
47
- "@dxos/storybook-utils": "0.7.5-main.9d26e3a",
48
- "@dxos/react-ui-theme": "0.7.5-main.9d26e3a"
38
+ "@dxos/react-ui-theme": "0.7.5-main.e9bb01b",
39
+ "@dxos/storybook-utils": "0.7.5-main.e9bb01b",
40
+ "@dxos/react-ui": "0.7.5-main.e9bb01b"
49
41
  },
50
42
  "peerDependencies": {
51
43
  "@phosphor-icons/react": "^2.1.5",
52
44
  "react": "~18.2.0",
53
- "@dxos/react-ui": "0.7.5-main.9d26e3a",
54
- "@dxos/react-ui-theme": "0.7.5-main.9d26e3a"
45
+ "@dxos/react-ui": "0.7.5-main.e9bb01b",
46
+ "@dxos/react-ui-theme": "0.7.5-main.e9bb01b"
55
47
  },
56
48
  "publishConfig": {
57
49
  "access": "public"
package/src/PwaPlugin.tsx CHANGED
@@ -5,53 +5,61 @@
5
5
  import { registerSW } from 'virtual:pwa-register';
6
6
 
7
7
  import {
8
- parseIntentPlugin,
9
- resolvePlugin,
10
- type PluginDefinition,
11
- LayoutAction,
8
+ Capabilities,
9
+ contributes,
12
10
  createIntent,
11
+ defineModule,
12
+ definePlugin,
13
+ Events,
14
+ LayoutAction,
13
15
  } from '@dxos/app-framework';
14
16
  import { log } from '@dxos/log';
15
17
  import { captureException } from '@dxos/observability/sentry';
16
18
 
17
- import meta, { PWA_PLUGIN } from './meta';
19
+ import { meta, PWA_PLUGIN } from './meta';
20
+
21
+ export const PwaPlugin = () =>
22
+ definePlugin(meta, [
23
+ defineModule({
24
+ id: `${meta.id}/module/register-pwa`,
25
+ activatesOn: Events.DispatcherReady,
26
+ activate: (context) => {
27
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
18
28
 
19
- export const PwaPlugin = (): PluginDefinition => ({
20
- meta,
21
- ready: async ({ plugins }) => {
22
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
29
+ const updateSW = registerSW({
30
+ onNeedRefresh: () =>
31
+ dispatch?.(
32
+ createIntent(LayoutAction.AddToast, {
33
+ part: 'toast',
34
+ subject: {
35
+ id: `${PWA_PLUGIN}/need-refresh`,
36
+ title: ['need refresh label', { ns: PWA_PLUGIN }],
37
+ description: ['need refresh description', { ns: PWA_PLUGIN }],
38
+ duration: 4 * 60 * 1000, // 4m
39
+ actionLabel: ['refresh label', { ns: PWA_PLUGIN }],
40
+ actionAlt: ['refresh alt', { ns: PWA_PLUGIN }],
41
+ onAction: () => updateSW(true),
42
+ },
43
+ }),
44
+ ),
45
+ onOfflineReady: () =>
46
+ dispatch?.(
47
+ createIntent(LayoutAction.AddToast, {
48
+ part: 'toast',
49
+ subject: {
50
+ id: `${PWA_PLUGIN}/offline-ready`,
51
+ title: ['offline ready label', { ns: PWA_PLUGIN }],
52
+ closeLabel: ['confirm label', { ns: PWA_PLUGIN }],
53
+ },
54
+ }),
55
+ ),
56
+ onRegisterError: (err) => {
57
+ captureException(err);
58
+ log.error(err);
59
+ },
60
+ });
23
61
 
24
- const updateSW = registerSW({
25
- onNeedRefresh: () =>
26
- dispatch?.(
27
- createIntent(LayoutAction.SetLayout, {
28
- element: 'toast',
29
- subject: {
30
- id: `${PWA_PLUGIN}/need-refresh`,
31
- title: ['need refresh label', { ns: PWA_PLUGIN }],
32
- description: ['need refresh description', { ns: PWA_PLUGIN }],
33
- duration: 4 * 60 * 1000, // 4m
34
- actionLabel: ['refresh label', { ns: PWA_PLUGIN }],
35
- actionAlt: ['refresh alt', { ns: PWA_PLUGIN }],
36
- onAction: () => updateSW(true),
37
- },
38
- }),
39
- ),
40
- onOfflineReady: () =>
41
- dispatch?.(
42
- createIntent(LayoutAction.SetLayout, {
43
- element: 'toast',
44
- subject: {
45
- id: `${PWA_PLUGIN}/offline-ready`,
46
- title: ['offline ready label', { ns: PWA_PLUGIN }],
47
- closeLabel: ['confirm label', { ns: PWA_PLUGIN }],
48
- },
49
- }),
50
- ),
51
- onRegisterError: (err) => {
52
- captureException(err);
53
- log.error(err);
62
+ return contributes(Capabilities.Null, null);
54
63
  },
55
- });
56
- },
57
- });
64
+ }),
65
+ ]);
package/src/index.ts CHANGED
@@ -2,8 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { PwaPlugin } from './PwaPlugin';
6
-
7
- export default PwaPlugin;
8
-
5
+ export * from './meta';
9
6
  export * from './PwaPlugin';
package/src/meta.ts CHANGED
@@ -6,6 +6,6 @@ import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
7
  export const PWA_PLUGIN = 'dxos.org/plugin/pwa';
8
8
 
9
- export default {
9
+ export const meta = {
10
10
  id: PWA_PLUGIN,
11
11
  } satisfies PluginMeta;
@@ -1,11 +0,0 @@
1
- // packages/plugins/plugin-pwa/src/meta.ts
2
- var PWA_PLUGIN = "dxos.org/plugin/pwa";
3
- var meta_default = {
4
- id: PWA_PLUGIN
5
- };
6
-
7
- export {
8
- PWA_PLUGIN,
9
- meta_default
10
- };
11
- //# sourceMappingURL=chunk-WYTLXSAY.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const PWA_PLUGIN = 'dxos.org/plugin/pwa';\n\nexport default {\n id: PWA_PLUGIN,\n} satisfies PluginMeta;\n"],
5
- "mappings": ";AAMO,IAAMA,aAAa;AAE1B,IAAA,eAAe;EACbC,IAAID;AACN;",
6
- "names": ["PWA_PLUGIN", "id"]
7
- }
@@ -1,9 +0,0 @@
1
- import {
2
- PWA_PLUGIN,
3
- meta_default
4
- } from "./chunk-WYTLXSAY.mjs";
5
- export {
6
- PWA_PLUGIN,
7
- meta_default as default
8
- };
9
- //# sourceMappingURL=meta.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }