@dxos/plugin-pwa 0.7.4 → 0.7.5-labs.071a3e2

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,82 +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 } 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
- // 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
12
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-pwa/src/PwaPlugin.tsx";
32
- var PwaPlugin = () => ({
33
- meta: meta_default,
34
- ready: async (plugins) => {
35
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
36
- const updateSW = registerSW({
37
- onNeedRefresh: () => dispatch?.({
38
- action: LayoutAction.SET_LAYOUT,
39
- data: {
40
- element: "toast",
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",
41
22
  subject: {
42
23
  id: `${PWA_PLUGIN}/need-refresh`,
43
- title: translations_default[0]["en-US"][PWA_PLUGIN]["need refresh label"],
44
- description: translations_default[0]["en-US"][PWA_PLUGIN]["need refresh description"],
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
+ ],
45
36
  duration: 4 * 60 * 1e3,
46
- actionLabel: translations_default[0]["en-US"][PWA_PLUGIN]["refresh label"],
47
- actionAlt: translations_default[0]["en-US"][PWA_PLUGIN]["refresh alt"],
37
+ actionLabel: [
38
+ "refresh label",
39
+ {
40
+ ns: PWA_PLUGIN
41
+ }
42
+ ],
43
+ actionAlt: [
44
+ "refresh alt",
45
+ {
46
+ ns: PWA_PLUGIN
47
+ }
48
+ ],
48
49
  onAction: () => updateSW(true)
49
50
  }
50
- }
51
- }),
52
- onOfflineReady: () => dispatch?.({
53
- action: LayoutAction.SET_LAYOUT,
54
- data: {
55
- element: "toast",
51
+ })),
52
+ onOfflineReady: () => dispatch?.(createIntent(LayoutAction.AddToast, {
53
+ part: "toast",
56
54
  subject: {
57
55
  id: `${PWA_PLUGIN}/offline-ready`,
58
- title: translations_default[0]["en-US"][PWA_PLUGIN]["offline ready label"],
59
- closeLabel: translations_default[0]["en-US"][PWA_PLUGIN]["confirm label"]
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
+ ]
60
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
+ });
61
78
  }
62
- }),
63
- onRegisterError: (err) => {
64
- captureException(err);
65
- log.error(err, void 0, {
66
- F: __dxlog_file,
67
- L: 50,
68
- S: void 0,
69
- C: (f, a) => f(...a)
70
- });
71
- }
72
- });
73
- }
74
- });
75
-
76
- // packages/plugins/plugin-pwa/src/index.ts
77
- var src_default = PwaPlugin;
79
+ });
80
+ return contributes(Capabilities.Null, null);
81
+ }
82
+ })
83
+ ]);
78
84
  export {
85
+ PWA_PLUGIN,
79
86
  PwaPlugin,
80
- src_default as default
87
+ meta
81
88
  };
82
89
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/PwaPlugin.tsx", "../../../src/translations.ts", "../../../src/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { registerSW } from 'virtual:pwa-register';\n\nimport { parseIntentPlugin, resolvePlugin, type PluginDefinition, LayoutAction } 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 = (): PluginDefinition => ({\n meta,\n ready: async (plugins) => {\n const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;\n\n const updateSW = registerSW({\n onNeedRefresh: () =>\n dispatch?.({\n action: LayoutAction.SET_LAYOUT,\n data: {\n element: 'toast',\n subject: {\n id: `${PWA_PLUGIN}/need-refresh`,\n title: translations[0]['en-US'][PWA_PLUGIN]['need refresh label'],\n description: translations[0]['en-US'][PWA_PLUGIN]['need refresh description'],\n duration: 4 * 60 * 1000, // 4m\n actionLabel: translations[0]['en-US'][PWA_PLUGIN]['refresh label'],\n actionAlt: translations[0]['en-US'][PWA_PLUGIN]['refresh alt'],\n onAction: () => updateSW(true),\n },\n },\n }),\n onOfflineReady: () =>\n dispatch?.({\n action: LayoutAction.SET_LAYOUT,\n data: {\n element: 'toast',\n subject: {\n id: `${PWA_PLUGIN}/offline-ready`,\n title: translations[0]['en-US'][PWA_PLUGIN]['offline ready label'],\n closeLabel: translations[0]['en-US'][PWA_PLUGIN]['confirm label'],\n },\n },\n }),\n onRegisterError: (err) => {\n captureException(err);\n log.error(err);\n },\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", "//\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,SAASC,mBAAmBC,eAAsCC,oBAAoB;AACtF,SAASC,WAAW;AACpB,SAASC,wBAAwB;;;ACFjC,IAAA,uBAAe;EACb;IACE,SAAS;MACP,CAACC,UAAAA,GAAa;QACZ,sBAAsB;QACtB,4BAA4B;QAC5B,iBAAiB;QACjB,eAAe;;;QAGf,uBAAuB;QACvB,iBAAiB;MACnB;IACF;EACF;;;;;ADPK,IAAMC,YAAY,OAAyB;EAChDC;EACAC,OAAO,OAAOC,YAAAA;AACZ,UAAMC,WAAWC,cAAcF,SAASG,iBAAAA,GAAoBC,SAASC,OAAOJ;AAE5E,UAAMK,WAAWC,WAAW;MAC1BC,eAAe,MACbP,WAAW;QACTQ,QAAQC,aAAaC;QACrBC,MAAM;UACJC,SAAS;UACTC,SAAS;YACPC,IAAI,GAAGC,UAAAA;YACPC,OAAOC,qBAAa,CAAA,EAAG,OAAA,EAASF,UAAAA,EAAY,oBAAA;YAC5CG,aAAaD,qBAAa,CAAA,EAAG,OAAA,EAASF,UAAAA,EAAY,0BAAA;YAClDI,UAAU,IAAI,KAAK;YACnBC,aAAaH,qBAAa,CAAA,EAAG,OAAA,EAASF,UAAAA,EAAY,eAAA;YAClDM,WAAWJ,qBAAa,CAAA,EAAG,OAAA,EAASF,UAAAA,EAAY,aAAA;YAChDO,UAAU,MAAMjB,SAAS,IAAA;UAC3B;QACF;MACF,CAAA;MACFkB,gBAAgB,MACdvB,WAAW;QACTQ,QAAQC,aAAaC;QACrBC,MAAM;UACJC,SAAS;UACTC,SAAS;YACPC,IAAI,GAAGC,UAAAA;YACPC,OAAOC,qBAAa,CAAA,EAAG,OAAA,EAASF,UAAAA,EAAY,qBAAA;YAC5CS,YAAYP,qBAAa,CAAA,EAAG,OAAA,EAASF,UAAAA,EAAY,eAAA;UACnD;QACF;MACF,CAAA;MACFU,iBAAiB,CAACC,QAAAA;AAChBC,yBAAiBD,GAAAA;AACjBE,YAAIC,MAAMH,KAAAA,QAAAA;;;;;;MACZ;IACF,CAAA;EACF;AACF;;;AE/CA,IAAA,cAAeI;",
6
- "names": ["registerSW", "parseIntentPlugin", "resolvePlugin", "LayoutAction", "log", "captureException", "PWA_PLUGIN", "PwaPlugin", "meta", "ready", "plugins", "dispatch", "resolvePlugin", "parseIntentPlugin", "provides", "intent", "updateSW", "registerSW", "onNeedRefresh", "action", "LayoutAction", "SET_LAYOUT", "data", "element", "subject", "id", "PWA_PLUGIN", "title", "translations", "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/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":7317,"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":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":4565},"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":1821},"packages/plugins/plugin-pwa/src/translations.ts":{"bytesInOutput":620},"packages/plugins/plugin-pwa/src/index.ts":{"bytesInOutput":29}},"bytes":2821},"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,EAAoC,KAAK,gBAAgB,EAAgB,MAAM,qBAAqB,CAAC;AAO5G,eAAO,MAAM,SAAS,QAAO,gBAwC3B,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"}
@@ -0,0 +1 @@
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.4",
3
+ "version": "0.7.5-labs.071a3e2",
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.4",
34
- "@dxos/log": "0.7.4",
35
- "@dxos/observability": "0.7.4"
25
+ "@dxos/app-framework": "0.7.5-labs.071a3e2",
26
+ "@dxos/observability": "0.7.5-labs.071a3e2",
27
+ "@dxos/log": "0.7.5-labs.071a3e2"
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.4",
47
- "@dxos/react-ui-theme": "0.7.4",
48
- "@dxos/storybook-utils": "0.7.4"
38
+ "@dxos/react-ui": "0.7.5-labs.071a3e2",
39
+ "@dxos/react-ui-theme": "0.7.5-labs.071a3e2",
40
+ "@dxos/storybook-utils": "0.7.5-labs.071a3e2"
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.4",
54
- "@dxos/react-ui-theme": "0.7.4"
45
+ "@dxos/react-ui": "0.7.5-labs.071a3e2",
46
+ "@dxos/react-ui-theme": "0.7.5-labs.071a3e2"
55
47
  },
56
48
  "publishConfig": {
57
49
  "access": "public"
package/src/PwaPlugin.tsx CHANGED
@@ -4,51 +4,62 @@
4
4
 
5
5
  import { registerSW } from 'virtual:pwa-register';
6
6
 
7
- import { parseIntentPlugin, resolvePlugin, type PluginDefinition, LayoutAction } from '@dxos/app-framework';
7
+ import {
8
+ Capabilities,
9
+ contributes,
10
+ createIntent,
11
+ defineModule,
12
+ definePlugin,
13
+ Events,
14
+ LayoutAction,
15
+ } from '@dxos/app-framework';
8
16
  import { log } from '@dxos/log';
9
17
  import { captureException } from '@dxos/observability/sentry';
10
18
 
11
- import meta, { PWA_PLUGIN } from './meta';
12
- import translations from './translations';
19
+ import { meta, PWA_PLUGIN } from './meta';
13
20
 
14
- export const PwaPlugin = (): PluginDefinition => ({
15
- meta,
16
- ready: async (plugins) => {
17
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
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
- const updateSW = registerSW({
20
- onNeedRefresh: () =>
21
- dispatch?.({
22
- action: LayoutAction.SET_LAYOUT,
23
- data: {
24
- element: 'toast',
25
- subject: {
26
- id: `${PWA_PLUGIN}/need-refresh`,
27
- title: translations[0]['en-US'][PWA_PLUGIN]['need refresh label'],
28
- description: translations[0]['en-US'][PWA_PLUGIN]['need refresh description'],
29
- duration: 4 * 60 * 1000, // 4m
30
- actionLabel: translations[0]['en-US'][PWA_PLUGIN]['refresh label'],
31
- actionAlt: translations[0]['en-US'][PWA_PLUGIN]['refresh alt'],
32
- onAction: () => updateSW(true),
33
- },
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);
34
59
  },
35
- }),
36
- onOfflineReady: () =>
37
- dispatch?.({
38
- action: LayoutAction.SET_LAYOUT,
39
- data: {
40
- element: 'toast',
41
- subject: {
42
- id: `${PWA_PLUGIN}/offline-ready`,
43
- title: translations[0]['en-US'][PWA_PLUGIN]['offline ready label'],
44
- closeLabel: translations[0]['en-US'][PWA_PLUGIN]['confirm label'],
45
- },
46
- },
47
- }),
48
- onRegisterError: (err) => {
49
- captureException(err);
50
- log.error(err);
60
+ });
61
+
62
+ return contributes(Capabilities.Null, null);
51
63
  },
52
- });
53
- },
54
- });
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
- }