@dxos/plugin-pwa 0.7.5-main.499c70c → 0.7.5-main.5ae2ba8

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,114 @@
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
- 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
- ]
65
- }
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
- });
12
+
13
+ // packages/plugins/plugin-pwa/src/translations.ts
14
+ var translations_default = [
15
+ {
16
+ "en-US": {
17
+ [PWA_PLUGIN]: {
18
+ "need refresh label": "Refresh now to get app updates",
19
+ "need refresh description": "You\u2019ll need these updates to continue without interruption.",
20
+ "refresh label": "Refresh",
21
+ "refresh alt": "Click your browser\u2019s refresh button or use the refresh keyboard shortcut.",
22
+ // TODO(wittjosiah): Non-react translation utils.
23
+ // 'offline ready label': '{{appName}} is ready to use offline.',
24
+ "offline ready label": "Ready to use offline.",
25
+ "confirm label": "Okay"
75
26
  }
76
- });
27
+ }
77
28
  }
78
- });
29
+ ];
79
30
 
80
- // packages/plugins/plugin-pwa/src/index.ts
81
- var src_default = PwaPlugin;
31
+ // packages/plugins/plugin-pwa/src/PwaPlugin.tsx
32
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-pwa/src/PwaPlugin.tsx";
33
+ var PwaPlugin = () => definePlugin(meta, [
34
+ defineModule({
35
+ id: `${meta.id}/module/translations`,
36
+ activatesOn: Events.SetupTranslations,
37
+ activate: () => contributes(Capabilities.Translations, translations_default)
38
+ }),
39
+ defineModule({
40
+ id: `${meta.id}/module/register-pwa`,
41
+ activatesOn: Events.DispatcherReady,
42
+ activate: (context) => {
43
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);
44
+ const updateSW = registerSW({
45
+ onNeedRefresh: () => dispatch?.(createIntent(LayoutAction.AddToast, {
46
+ part: "toast",
47
+ subject: {
48
+ id: `${PWA_PLUGIN}/need-refresh`,
49
+ title: [
50
+ "need refresh label",
51
+ {
52
+ ns: PWA_PLUGIN
53
+ }
54
+ ],
55
+ description: [
56
+ "need refresh description",
57
+ {
58
+ ns: PWA_PLUGIN
59
+ }
60
+ ],
61
+ duration: 4 * 60 * 1e3,
62
+ actionLabel: [
63
+ "refresh label",
64
+ {
65
+ ns: PWA_PLUGIN
66
+ }
67
+ ],
68
+ actionAlt: [
69
+ "refresh alt",
70
+ {
71
+ ns: PWA_PLUGIN
72
+ }
73
+ ],
74
+ onAction: () => updateSW(true)
75
+ }
76
+ })),
77
+ onOfflineReady: () => dispatch?.(createIntent(LayoutAction.AddToast, {
78
+ part: "toast",
79
+ subject: {
80
+ id: `${PWA_PLUGIN}/offline-ready`,
81
+ title: [
82
+ "offline ready label",
83
+ {
84
+ ns: PWA_PLUGIN
85
+ }
86
+ ],
87
+ closeLabel: [
88
+ "confirm label",
89
+ {
90
+ ns: PWA_PLUGIN
91
+ }
92
+ ]
93
+ }
94
+ })),
95
+ onRegisterError: (err) => {
96
+ captureException(err);
97
+ log.error(err, void 0, {
98
+ F: __dxlog_file,
99
+ L: 64,
100
+ S: void 0,
101
+ C: (f, a) => f(...a)
102
+ });
103
+ }
104
+ });
105
+ return contributes(Capabilities.Null, null);
106
+ }
107
+ })
108
+ ]);
82
109
  export {
110
+ PWA_PLUGIN,
83
111
  PwaPlugin,
84
- src_default as default
112
+ meta
85
113
  };
86
114
  //# 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", "../../../src/translations.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 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';\nimport translations from './translations';\n\nexport const PwaPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\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", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { PWA_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [PWA_PLUGIN]: {\n 'need refresh label': 'Refresh now to get app updates',\n 'need refresh description': 'You’ll need these updates to continue without interruption.',\n 'refresh label': 'Refresh',\n 'refresh alt': 'Click your browser’s refresh button or use the refresh keyboard shortcut.',\n // TODO(wittjosiah): Non-react translation utils.\n // 'offline ready label': '{{appName}} is ready to use offline.',\n 'offline ready label': 'Ready to use offline.',\n 'confirm label': 'Okay',\n },\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;;;ACVjC,IAAA,uBAAe;EACb;IACE,SAAS;MACP,CAACC,UAAAA,GAAa;QACZ,sBAAsB;QACtB,4BAA4B;QAC5B,iBAAiB;QACjB,eAAe;;;QAGf,uBAAuB;QACvB,iBAAiB;MACnB;IACF;EACF;;;;;ADCK,IAAMC,YAAY,MACvBC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAU,MAAMC,YAAYC,aAAaC,cAAcC,oBAAAA;EACzD,CAAA;EACAT,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOO;IACpBL,UAAU,CAACM,YAAAA;AACT,YAAM,EAAEC,iBAAiBC,SAAQ,IAAKF,QAAQG,kBAAkBP,aAAaQ,gBAAgB;AAE7F,YAAMC,WAAWC,WAAW;QAC1BC,eAAe,MACbL,WACEM,aAAaC,aAAaC,UAAU;UAClCC,MAAM;UACNC,SAAS;YACPtB,IAAI,GAAGuB,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,MACdnB,WACEM,aAAaC,aAAaC,UAAU;UAClCC,MAAM;UACNC,SAAS;YACPtB,IAAI,GAAGuB,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,aAAO7B,YAAYC,aAAagC,MAAM,IAAA;IACxC;EACF,CAAA;CACD;",
6
+ "names": ["PWA_PLUGIN", "meta", "id", "registerSW", "Capabilities", "contributes", "createIntent", "defineModule", "definePlugin", "Events", "LayoutAction", "log", "captureException", "PWA_PLUGIN", "PwaPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupTranslations", "activate", "contributes", "Capabilities", "Translations", "translations", "DispatcherReady", "context", "dispatchPromise", "dispatch", "requestCapability", "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", "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/translations.ts":{"bytes":2353,"imports":[{"path":"packages/plugins/plugin-pwa/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/plugin-pwa/src/PwaPlugin.tsx":{"bytes":9806,"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"},{"path":"packages/plugins/plugin-pwa/src/translations.ts","kind":"import-statement","original":"./translations"}],"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":5452},"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":2470},"packages/plugins/plugin-pwa/src/translations.ts":{"bytesInOutput":620}},"bytes":3439}}}
@@ -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":"AAqBA,eAAO,MAAM,SAAS,4CAiDlB,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,38 +1,31 @@
1
1
  {
2
2
  "name": "@dxos/plugin-pwa",
3
- "version": "0.7.5-main.499c70c",
3
+ "version": "0.7.5-main.5ae2ba8",
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
7
  "license": "MIT",
8
8
  "author": "DXOS.org",
9
9
  "sideEffects": true,
10
+ "type": "module",
10
11
  "exports": {
11
12
  ".": {
12
13
  "types": "./dist/types/src/index.d.ts",
13
14
  "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
15
  }
19
16
  },
20
17
  "types": "dist/types/src/index.d.ts",
21
18
  "typesVersions": {
22
- "*": {
23
- "meta": [
24
- "dist/types/src/meta.d.ts"
25
- ]
26
- }
19
+ "*": {}
27
20
  },
28
21
  "files": [
29
22
  "dist",
30
23
  "src"
31
24
  ],
32
25
  "dependencies": {
33
- "@dxos/app-framework": "0.7.5-main.499c70c",
34
- "@dxos/log": "0.7.5-main.499c70c",
35
- "@dxos/observability": "0.7.5-main.499c70c"
26
+ "@dxos/app-framework": "0.7.5-main.5ae2ba8",
27
+ "@dxos/log": "0.7.5-main.5ae2ba8",
28
+ "@dxos/observability": "0.7.5-main.5ae2ba8"
36
29
  },
37
30
  "devDependencies": {
38
31
  "@phosphor-icons/react": "^2.1.5",
@@ -43,15 +36,15 @@
43
36
  "vite": "5.4.7",
44
37
  "vite-plugin-pwa": "^0.18.2",
45
38
  "workbox-window": "^7.0.0",
46
- "@dxos/react-ui": "0.7.5-main.499c70c",
47
- "@dxos/react-ui-theme": "0.7.5-main.499c70c",
48
- "@dxos/storybook-utils": "0.7.5-main.499c70c"
39
+ "@dxos/react-ui": "0.7.5-main.5ae2ba8",
40
+ "@dxos/storybook-utils": "0.7.5-main.5ae2ba8",
41
+ "@dxos/react-ui-theme": "0.7.5-main.5ae2ba8"
49
42
  },
50
43
  "peerDependencies": {
51
44
  "@phosphor-icons/react": "^2.1.5",
52
45
  "react": "~18.2.0",
53
- "@dxos/react-ui": "0.7.5-main.499c70c",
54
- "@dxos/react-ui-theme": "0.7.5-main.499c70c"
46
+ "@dxos/react-ui-theme": "0.7.5-main.5ae2ba8",
47
+ "@dxos/react-ui": "0.7.5-main.5ae2ba8"
55
48
  },
56
49
  "publishConfig": {
57
50
  "access": "public"
package/src/PwaPlugin.tsx CHANGED
@@ -5,53 +5,67 @@
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
+ import translations from './translations';
21
+
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.requestCapability(Capabilities.IntentDispatcher);
18
34
 
19
- export const PwaPlugin = (): PluginDefinition => ({
20
- meta,
21
- ready: async ({ plugins }) => {
22
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
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
+ });
23
67
 
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);
68
+ return contributes(Capabilities.Null, null);
54
69
  },
55
- });
56
- },
57
- });
70
+ }),
71
+ ]);
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
- }