@dxos/plugin-pwa 0.7.4 → 0.7.5-main.9cb18ac
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.
|
@@ -5,66 +5,70 @@ import {
|
|
|
5
5
|
|
|
6
6
|
// packages/plugins/plugin-pwa/src/PwaPlugin.tsx
|
|
7
7
|
import { registerSW } from "virtual:pwa-register";
|
|
8
|
-
import { parseIntentPlugin, resolvePlugin, LayoutAction } from "@dxos/app-framework";
|
|
8
|
+
import { parseIntentPlugin, resolvePlugin, LayoutAction, createIntent } from "@dxos/app-framework";
|
|
9
9
|
import { log } from "@dxos/log";
|
|
10
10
|
import { captureException } from "@dxos/observability/sentry";
|
|
11
|
-
|
|
12
|
-
// packages/plugins/plugin-pwa/src/translations.ts
|
|
13
|
-
var translations_default = [
|
|
14
|
-
{
|
|
15
|
-
"en-US": {
|
|
16
|
-
[PWA_PLUGIN]: {
|
|
17
|
-
"need refresh label": "Refresh now to get app updates",
|
|
18
|
-
"need refresh description": "You\u2019ll need these updates to continue without interruption.",
|
|
19
|
-
"refresh label": "Refresh",
|
|
20
|
-
"refresh alt": "Click your browser\u2019s refresh button or use the refresh keyboard shortcut.",
|
|
21
|
-
// TODO(wittjosiah): Non-react translation utils.
|
|
22
|
-
// 'offline ready label': '{{appName}} is ready to use offline.',
|
|
23
|
-
"offline ready label": "Ready to use offline.",
|
|
24
|
-
"confirm label": "Okay"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
// packages/plugins/plugin-pwa/src/PwaPlugin.tsx
|
|
31
11
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-pwa/src/PwaPlugin.tsx";
|
|
32
12
|
var PwaPlugin = () => ({
|
|
33
13
|
meta: meta_default,
|
|
34
|
-
ready: async (plugins) => {
|
|
35
|
-
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.
|
|
14
|
+
ready: async ({ plugins }) => {
|
|
15
|
+
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
|
|
36
16
|
const updateSW = registerSW({
|
|
37
|
-
onNeedRefresh: () => dispatch?.({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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)
|
|
50
47
|
}
|
|
51
|
-
}),
|
|
52
|
-
onOfflineReady: () => dispatch?.({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
]
|
|
61
65
|
}
|
|
62
|
-
}),
|
|
66
|
+
})),
|
|
63
67
|
onRegisterError: (err) => {
|
|
64
68
|
captureException(err);
|
|
65
69
|
log.error(err, void 0, {
|
|
66
70
|
F: __dxlog_file,
|
|
67
|
-
L:
|
|
71
|
+
L: 53,
|
|
68
72
|
S: void 0,
|
|
69
73
|
C: (f, a) => f(...a)
|
|
70
74
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/PwaPlugin.tsx", "../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { registerSW } from 'virtual:pwa-register';\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,kBAAkB;AAE3B,
|
|
6
|
-
"names": ["registerSW", "parseIntentPlugin", "resolvePlugin", "LayoutAction", "
|
|
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"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/plugin-pwa/src/meta.ts":{"bytes":838,"imports":[],"format":"esm"},"packages/plugins/plugin-pwa/src/
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PwaPlugin.d.ts","sourceRoot":"","sources":["../../../src/PwaPlugin.tsx"],"names":[],"mappings":"AAMA,OAAO,
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.7.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-pwa",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-main.9cb18ac",
|
|
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",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"src"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@dxos/app-framework": "0.7.
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
33
|
+
"@dxos/app-framework": "0.7.5-main.9cb18ac",
|
|
34
|
+
"@dxos/observability": "0.7.5-main.9cb18ac",
|
|
35
|
+
"@dxos/log": "0.7.5-main.9cb18ac"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"vite": "5.4.7",
|
|
44
44
|
"vite-plugin-pwa": "^0.18.2",
|
|
45
45
|
"workbox-window": "^7.0.0",
|
|
46
|
-
"@dxos/react-ui": "0.7.
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
46
|
+
"@dxos/react-ui-theme": "0.7.5-main.9cb18ac",
|
|
47
|
+
"@dxos/storybook-utils": "0.7.5-main.9cb18ac",
|
|
48
|
+
"@dxos/react-ui": "0.7.5-main.9cb18ac"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@phosphor-icons/react": "^2.1.5",
|
|
52
52
|
"react": "~18.2.0",
|
|
53
|
-
"@dxos/react-ui": "0.7.
|
|
54
|
-
"@dxos/react-ui
|
|
53
|
+
"@dxos/react-ui-theme": "0.7.5-main.9cb18ac",
|
|
54
|
+
"@dxos/react-ui": "0.7.5-main.9cb18ac"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
package/src/PwaPlugin.tsx
CHANGED
|
@@ -4,47 +4,50 @@
|
|
|
4
4
|
|
|
5
5
|
import { registerSW } from 'virtual:pwa-register';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
parseIntentPlugin,
|
|
9
|
+
resolvePlugin,
|
|
10
|
+
type PluginDefinition,
|
|
11
|
+
LayoutAction,
|
|
12
|
+
createIntent,
|
|
13
|
+
} from '@dxos/app-framework';
|
|
8
14
|
import { log } from '@dxos/log';
|
|
9
15
|
import { captureException } from '@dxos/observability/sentry';
|
|
10
16
|
|
|
11
17
|
import meta, { PWA_PLUGIN } from './meta';
|
|
12
|
-
import translations from './translations';
|
|
13
18
|
|
|
14
19
|
export const PwaPlugin = (): PluginDefinition => ({
|
|
15
20
|
meta,
|
|
16
|
-
ready: async (plugins) => {
|
|
17
|
-
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.
|
|
21
|
+
ready: async ({ plugins }) => {
|
|
22
|
+
const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
|
|
18
23
|
|
|
19
24
|
const updateSW = registerSW({
|
|
20
25
|
onNeedRefresh: () =>
|
|
21
|
-
dispatch?.(
|
|
22
|
-
|
|
23
|
-
data: {
|
|
26
|
+
dispatch?.(
|
|
27
|
+
createIntent(LayoutAction.SetLayout, {
|
|
24
28
|
element: 'toast',
|
|
25
29
|
subject: {
|
|
26
30
|
id: `${PWA_PLUGIN}/need-refresh`,
|
|
27
|
-
title:
|
|
28
|
-
description:
|
|
31
|
+
title: ['need refresh label', { ns: PWA_PLUGIN }],
|
|
32
|
+
description: ['need refresh description', { ns: PWA_PLUGIN }],
|
|
29
33
|
duration: 4 * 60 * 1000, // 4m
|
|
30
|
-
actionLabel:
|
|
31
|
-
actionAlt:
|
|
34
|
+
actionLabel: ['refresh label', { ns: PWA_PLUGIN }],
|
|
35
|
+
actionAlt: ['refresh alt', { ns: PWA_PLUGIN }],
|
|
32
36
|
onAction: () => updateSW(true),
|
|
33
37
|
},
|
|
34
|
-
},
|
|
35
|
-
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
36
40
|
onOfflineReady: () =>
|
|
37
|
-
dispatch?.(
|
|
38
|
-
|
|
39
|
-
data: {
|
|
41
|
+
dispatch?.(
|
|
42
|
+
createIntent(LayoutAction.SetLayout, {
|
|
40
43
|
element: 'toast',
|
|
41
44
|
subject: {
|
|
42
45
|
id: `${PWA_PLUGIN}/offline-ready`,
|
|
43
|
-
title:
|
|
44
|
-
closeLabel:
|
|
46
|
+
title: ['offline ready label', { ns: PWA_PLUGIN }],
|
|
47
|
+
closeLabel: ['confirm label', { ns: PWA_PLUGIN }],
|
|
45
48
|
},
|
|
46
|
-
},
|
|
47
|
-
|
|
49
|
+
}),
|
|
50
|
+
),
|
|
48
51
|
onRegisterError: (err) => {
|
|
49
52
|
captureException(err);
|
|
50
53
|
log.error(err);
|