@tramvai/module-progressive-web-app 5.49.1 → 6.59.0

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Progressiwe Web App module.
4
4
 
5
- Complete documentation is available in [PWA page](03-features/017-pwa.md).
5
+ Complete documentation is available in [PWA page](03-features/018-pwa.md).
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,4 +22,4 @@ createApp({
22
22
  name: 'tincoin',
23
23
  modules: [TramvaiPwaModule],
24
24
  });
25
- ```
25
+ ```
package/lib/browser.js CHANGED
@@ -4,7 +4,7 @@ export { TramvaiPwaWorkboxModule } from './workbox/browser.browser.js';
4
4
  import { TramvaiPwaManifestModule, TramvaiPwaLightManifestModule } from './manifest/browser.browser.js';
5
5
  export { TramvaiPwaManifestModule } from './manifest/browser.browser.js';
6
6
  import { TramvaiPwaMetaModule } from './meta/browser.browser.js';
7
- export { PWA_MANIFEST_INIT_COMMAND_LINE, PWA_MANIFEST_URL_TOKEN, PWA_META_TOKEN, PWA_SW_PARAMS_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_URL_TOKEN, PWA_WORKBOX_TOKEN } from './tokens.browser.js';
7
+ export { PWA_MANIFEST_INIT_COMMAND_LINE, PWA_MANIFEST_SCOPE_TOKEN, PWA_MANIFEST_URL_TOKEN, PWA_META_TOKEN, PWA_SW_PARAMS_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_URL_TOKEN, PWA_WORKBOX_TOKEN } from './tokens.browser.js';
8
8
 
9
9
  const TramvaiPwaModule = declareModule({
10
10
  name: 'TramvaiPwaModule',
@@ -2,7 +2,7 @@ import { declareModule, provide, Scope } from '@tramvai/core';
2
2
  import { PROXY_CONFIG_TOKEN } from '@tramvai/tokens-server';
3
3
  import { ASSETS_PREFIX_TOKEN } from '@tramvai/tokens-render';
4
4
  import { appConfig } from '@tramvai/cli/lib/external/config';
5
- import { PWA_MANIFEST_URL_TOKEN, PWA_SW_SCOPE_TOKEN } from '../tokens.es.js';
5
+ import { PWA_MANIFEST_URL_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_MANIFEST_SCOPE_TOKEN } from '../tokens.es.js';
6
6
  import { registerWebManifestProvider, validateRelativeUrlProvider } from './shared/providers.es.js';
7
7
 
8
8
  const TramvaiPwaManifestModule = declareModule({
@@ -11,13 +11,13 @@ const TramvaiPwaManifestModule = declareModule({
11
11
  provide({
12
12
  provide: PROXY_CONFIG_TOKEN,
13
13
  scope: Scope.SINGLETON,
14
- useFactory: ({ manifestUrl, swScope, assetsPrefixFactory }) => {
14
+ useFactory: ({ manifestUrl, swScope, manifestScope, assetsPrefixFactory }) => {
15
15
  return {
16
16
  context: [manifestUrl],
17
17
  // appConfig.assetsPrefix available in 'development' mode
18
18
  target: appConfig.assetsPrefix ?? assetsPrefixFactory() ?? '',
19
19
  pathRewrite: (path) => {
20
- return path.replace(swScope, '/');
20
+ return path.replace(manifestScope ?? swScope, '/');
21
21
  },
22
22
  // support local proxy for `tramvai start --https`
23
23
  secure: process.env.NODE_ENV !== 'development',
@@ -26,21 +26,28 @@ const TramvaiPwaManifestModule = declareModule({
26
26
  deps: {
27
27
  manifestUrl: PWA_MANIFEST_URL_TOKEN,
28
28
  swScope: PWA_SW_SCOPE_TOKEN,
29
+ manifestScope: PWA_MANIFEST_SCOPE_TOKEN,
29
30
  assetsPrefixFactory: ASSETS_PREFIX_TOKEN,
30
31
  },
31
32
  }),
33
+ provide({
34
+ provide: PWA_MANIFEST_SCOPE_TOKEN,
35
+ scope: Scope.SINGLETON,
36
+ useValue: process.env.TRAMVAI_PWA_MANIFEST_SCOPE,
37
+ }),
32
38
  provide({
33
39
  provide: PWA_MANIFEST_URL_TOKEN,
34
40
  scope: Scope.SINGLETON,
35
- useFactory: ({ swScope }) => {
41
+ useFactory: ({ swScope, manifestScope }) => {
36
42
  const manifestDest = process.env.TRAMVAI_PWA_MANIFEST_DEST;
37
43
  const normalizedUrl = manifestDest.startsWith('/') ? manifestDest : `/${manifestDest}`;
38
- const normalizedScope = swScope.replace(/\/$/, '');
44
+ const normalizedScope = (manifestScope ?? swScope).replace(/\/$/, '');
39
45
  const finalUrl = `${normalizedScope}${normalizedUrl}`;
40
46
  return finalUrl;
41
47
  },
42
48
  deps: {
43
49
  swScope: PWA_SW_SCOPE_TOKEN,
50
+ manifestScope: PWA_MANIFEST_SCOPE_TOKEN,
44
51
  },
45
52
  }),
46
53
  ...(process.env.TRAMVAI_PWA_MANIFEST_ENABLED
@@ -15,13 +15,13 @@ const TramvaiPwaManifestModule = core.declareModule({
15
15
  core.provide({
16
16
  provide: tokensServer.PROXY_CONFIG_TOKEN,
17
17
  scope: core.Scope.SINGLETON,
18
- useFactory: ({ manifestUrl, swScope, assetsPrefixFactory }) => {
18
+ useFactory: ({ manifestUrl, swScope, manifestScope, assetsPrefixFactory }) => {
19
19
  return {
20
20
  context: [manifestUrl],
21
21
  // appConfig.assetsPrefix available in 'development' mode
22
22
  target: config.appConfig.assetsPrefix ?? assetsPrefixFactory() ?? '',
23
23
  pathRewrite: (path) => {
24
- return path.replace(swScope, '/');
24
+ return path.replace(manifestScope ?? swScope, '/');
25
25
  },
26
26
  // support local proxy for `tramvai start --https`
27
27
  secure: process.env.NODE_ENV !== 'development',
@@ -30,21 +30,28 @@ const TramvaiPwaManifestModule = core.declareModule({
30
30
  deps: {
31
31
  manifestUrl: tokens.PWA_MANIFEST_URL_TOKEN,
32
32
  swScope: tokens.PWA_SW_SCOPE_TOKEN,
33
+ manifestScope: tokens.PWA_MANIFEST_SCOPE_TOKEN,
33
34
  assetsPrefixFactory: tokensRender.ASSETS_PREFIX_TOKEN,
34
35
  },
35
36
  }),
37
+ core.provide({
38
+ provide: tokens.PWA_MANIFEST_SCOPE_TOKEN,
39
+ scope: core.Scope.SINGLETON,
40
+ useValue: process.env.TRAMVAI_PWA_MANIFEST_SCOPE,
41
+ }),
36
42
  core.provide({
37
43
  provide: tokens.PWA_MANIFEST_URL_TOKEN,
38
44
  scope: core.Scope.SINGLETON,
39
- useFactory: ({ swScope }) => {
45
+ useFactory: ({ swScope, manifestScope }) => {
40
46
  const manifestDest = process.env.TRAMVAI_PWA_MANIFEST_DEST;
41
47
  const normalizedUrl = manifestDest.startsWith('/') ? manifestDest : `/${manifestDest}`;
42
- const normalizedScope = swScope.replace(/\/$/, '');
48
+ const normalizedScope = (manifestScope ?? swScope).replace(/\/$/, '');
43
49
  const finalUrl = `${normalizedScope}${normalizedUrl}`;
44
50
  return finalUrl;
45
51
  },
46
52
  deps: {
47
53
  swScope: tokens.PWA_SW_SCOPE_TOKEN,
54
+ manifestScope: tokens.PWA_MANIFEST_SCOPE_TOKEN,
48
55
  },
49
56
  }),
50
57
  ...(process.env.TRAMVAI_PWA_MANIFEST_ENABLED
package/lib/server.es.js CHANGED
@@ -4,7 +4,7 @@ export { TramvaiPwaWorkboxModule } from './workbox/server.es.js';
4
4
  import { TramvaiPwaManifestModule, TramvaiPwaLightManifestModule } from './manifest/server.es.js';
5
5
  export { TramvaiPwaManifestModule } from './manifest/server.es.js';
6
6
  import { TramvaiPwaMetaModule } from './meta/server.es.js';
7
- export { PWA_MANIFEST_INIT_COMMAND_LINE, PWA_MANIFEST_URL_TOKEN, PWA_META_TOKEN, PWA_SW_PARAMS_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_URL_TOKEN, PWA_WORKBOX_TOKEN } from './tokens.es.js';
7
+ export { PWA_MANIFEST_INIT_COMMAND_LINE, PWA_MANIFEST_SCOPE_TOKEN, PWA_MANIFEST_URL_TOKEN, PWA_META_TOKEN, PWA_SW_PARAMS_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_URL_TOKEN, PWA_WORKBOX_TOKEN } from './tokens.es.js';
8
8
 
9
9
  const TramvaiPwaModule = declareModule({
10
10
  name: 'TramvaiPwaModule',
package/lib/server.js CHANGED
@@ -22,6 +22,7 @@ const TramvaiPwaLightModule = /* @__PURE__ */ core.declareModule({
22
22
  exports.TramvaiPwaWorkboxModule = server.TramvaiPwaWorkboxModule;
23
23
  exports.TramvaiPwaManifestModule = server$1.TramvaiPwaManifestModule;
24
24
  exports.PWA_MANIFEST_INIT_COMMAND_LINE = tokens.PWA_MANIFEST_INIT_COMMAND_LINE;
25
+ exports.PWA_MANIFEST_SCOPE_TOKEN = tokens.PWA_MANIFEST_SCOPE_TOKEN;
25
26
  exports.PWA_MANIFEST_URL_TOKEN = tokens.PWA_MANIFEST_URL_TOKEN;
26
27
  exports.PWA_META_TOKEN = tokens.PWA_META_TOKEN;
27
28
  exports.PWA_SW_PARAMS_TOKEN = tokens.PWA_SW_PARAMS_TOKEN;
@@ -12,6 +12,10 @@ const PWA_SW_URL_TOKEN = createToken('pwa sw url');
12
12
  * @description Token to owerwrite default - `pwa.sw.scope`
13
13
  */
14
14
  const PWA_SW_SCOPE_TOKEN = createToken('pwa sw scope');
15
+ /**
16
+ * @description Token to owerwrite default - `pwa.manifest.scope`
17
+ */
18
+ const PWA_MANIFEST_SCOPE_TOKEN = createToken('pwa manifest scope');
15
19
  /**
16
20
  * @description Token to add query params to sw url
17
21
  */
@@ -31,4 +35,4 @@ const PWA_META_TOKEN = createToken('pwa meta');
31
35
  */
32
36
  const PWA_MANIFEST_INIT_COMMAND_LINE = createToken('pwa manifest init command line');
33
37
 
34
- export { PWA_MANIFEST_INIT_COMMAND_LINE, PWA_MANIFEST_URL_TOKEN, PWA_META_TOKEN, PWA_SW_PARAMS_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_URL_TOKEN, PWA_WORKBOX_TOKEN };
38
+ export { PWA_MANIFEST_INIT_COMMAND_LINE, PWA_MANIFEST_SCOPE_TOKEN, PWA_MANIFEST_URL_TOKEN, PWA_META_TOKEN, PWA_SW_PARAMS_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_URL_TOKEN, PWA_WORKBOX_TOKEN };
package/lib/tokens.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Workbox } from 'workbox-window';
2
- import type { PwaMetaOptions } from '@tramvai/cli/lib/typings/public';
2
+ import type { PwaMetaOptions } from '@tramvai/plugin-webpack-pwa';
3
3
  export type WebManifest = {
4
4
  [key: string]: any;
5
5
  };
@@ -21,13 +21,16 @@ export declare const PWA_SW_URL_TOKEN: string & {
21
21
  export declare const PWA_SW_SCOPE_TOKEN: string & {
22
22
  __type?: "base token" | undefined;
23
23
  };
24
+ /**
25
+ * @description Token to owerwrite default - `pwa.manifest.scope`
26
+ */
27
+ export declare const PWA_MANIFEST_SCOPE_TOKEN: (string & {
28
+ __type?: "base token" | undefined;
29
+ }) | undefined;
24
30
  /**
25
31
  * @description Token to add query params to sw url
26
32
  */
27
33
  export declare const PWA_SW_PARAMS_TOKEN: Record<string, string> & {
28
- /**
29
- * @description Token to owerwrite default - `${pwa.webmanifest.path}manifest.${pwa.webmanifest.ext}`
30
- */
31
34
  __type?: "multi token" | undefined;
32
35
  };
33
36
  /**
package/lib/tokens.es.js CHANGED
@@ -12,6 +12,10 @@ const PWA_SW_URL_TOKEN = createToken('pwa sw url');
12
12
  * @description Token to owerwrite default - `pwa.sw.scope`
13
13
  */
14
14
  const PWA_SW_SCOPE_TOKEN = createToken('pwa sw scope');
15
+ /**
16
+ * @description Token to owerwrite default - `pwa.manifest.scope`
17
+ */
18
+ const PWA_MANIFEST_SCOPE_TOKEN = createToken('pwa manifest scope');
15
19
  /**
16
20
  * @description Token to add query params to sw url
17
21
  */
@@ -31,4 +35,4 @@ const PWA_META_TOKEN = createToken('pwa meta');
31
35
  */
32
36
  const PWA_MANIFEST_INIT_COMMAND_LINE = createToken('pwa manifest init command line');
33
37
 
34
- export { PWA_MANIFEST_INIT_COMMAND_LINE, PWA_MANIFEST_URL_TOKEN, PWA_META_TOKEN, PWA_SW_PARAMS_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_URL_TOKEN, PWA_WORKBOX_TOKEN };
38
+ export { PWA_MANIFEST_INIT_COMMAND_LINE, PWA_MANIFEST_SCOPE_TOKEN, PWA_MANIFEST_URL_TOKEN, PWA_META_TOKEN, PWA_SW_PARAMS_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_URL_TOKEN, PWA_WORKBOX_TOKEN };
package/lib/tokens.js CHANGED
@@ -16,6 +16,10 @@ const PWA_SW_URL_TOKEN = dippy.createToken('pwa sw url');
16
16
  * @description Token to owerwrite default - `pwa.sw.scope`
17
17
  */
18
18
  const PWA_SW_SCOPE_TOKEN = dippy.createToken('pwa sw scope');
19
+ /**
20
+ * @description Token to owerwrite default - `pwa.manifest.scope`
21
+ */
22
+ const PWA_MANIFEST_SCOPE_TOKEN = dippy.createToken('pwa manifest scope');
19
23
  /**
20
24
  * @description Token to add query params to sw url
21
25
  */
@@ -36,6 +40,7 @@ const PWA_META_TOKEN = dippy.createToken('pwa meta');
36
40
  const PWA_MANIFEST_INIT_COMMAND_LINE = dippy.createToken('pwa manifest init command line');
37
41
 
38
42
  exports.PWA_MANIFEST_INIT_COMMAND_LINE = PWA_MANIFEST_INIT_COMMAND_LINE;
43
+ exports.PWA_MANIFEST_SCOPE_TOKEN = PWA_MANIFEST_SCOPE_TOKEN;
39
44
  exports.PWA_MANIFEST_URL_TOKEN = PWA_MANIFEST_URL_TOKEN;
40
45
  exports.PWA_META_TOKEN = PWA_META_TOKEN;
41
46
  exports.PWA_SW_PARAMS_TOKEN = PWA_SW_PARAMS_TOKEN;
@@ -1,6 +1,4 @@
1
1
  import { declareModule, provide, optional } from '@tramvai/core';
2
- import { MODERN_SATISFIES_TOKEN } from '@tramvai/tokens-render';
3
- import { ENV_MANAGER_TOKEN } from '@tramvai/tokens-common';
4
2
  import { PWA_SW_URL_TOKEN, PWA_SW_SCOPE_TOKEN, PWA_SW_PARAMS_TOKEN } from '../tokens.browser.js';
5
3
  import { providers, sharedPwaLightModuleProviders } from './shared/providers/swProviders.browser.js';
6
4
  import { pwaWorkboxTokenProvider, workboxRegisterProvider } from './shared/providers/workboxProviders.browser.js';
@@ -12,17 +10,10 @@ const TramvaiPwaWorkboxModule = declareModule({
12
10
  ...providers,
13
11
  provide({
14
12
  provide: PWA_SW_URL_TOKEN,
15
- useFactory: ({ swScope, modern, envManager, swParams }) => {
13
+ useFactory: ({ swScope, swParams }) => {
16
14
  const swDest = process.env.TRAMVAI_PWA_SW_DEST;
17
15
  const swUrl = normalizeSwUrl(swDest, swScope);
18
- const hasModernBuild = !!process.env.TRAMVAI_MODERN_BUILD;
19
- const isCsrMode = envManager.get('TRAMVAI_FORCE_CLIENT_SIDE_RENDERING') === 'true';
20
- // tramvai modern build is not supported for CSR and not compatible with PWA module in CSR mode
21
- const addModernPrefix = modern && hasModernBuild && !isCsrMode;
22
16
  let finalSwUrl = swUrl;
23
- if (addModernPrefix) {
24
- finalSwUrl = finalSwUrl.replace(/\.js$/, '.modern.js');
25
- }
26
17
  if (swParams && swParams.length) {
27
18
  const params = swParams
28
19
  .filter(Boolean)
@@ -38,8 +29,6 @@ const TramvaiPwaWorkboxModule = declareModule({
38
29
  },
39
30
  deps: {
40
31
  swScope: PWA_SW_SCOPE_TOKEN,
41
- modern: MODERN_SATISFIES_TOKEN,
42
- envManager: ENV_MANAGER_TOKEN,
43
32
  swParams: optional(PWA_SW_PARAMS_TOKEN),
44
33
  },
45
34
  }),
@@ -41,7 +41,7 @@ const TramvaiPwaWorkboxModule = declareModule({
41
41
  scope: Scope.SINGLETON,
42
42
  useFactory: ({ swUrl, swScope, assetsPrefixFactory }) => {
43
43
  return {
44
- context: [swUrl, swUrl.replace(/\.js$/, '.modern.js')],
44
+ context: [swUrl],
45
45
  // appConfig.assetsPrefix available in 'development' mode
46
46
  target: appConfig.assetsPrefix ?? assetsPrefixFactory() ?? '',
47
47
  pathRewrite: (path) => {
@@ -45,7 +45,7 @@ const TramvaiPwaWorkboxModule = core.declareModule({
45
45
  scope: core.Scope.SINGLETON,
46
46
  useFactory: ({ swUrl, swScope, assetsPrefixFactory }) => {
47
47
  return {
48
- context: [swUrl, swUrl.replace(/\.js$/, '.modern.js')],
48
+ context: [swUrl],
49
49
  // appConfig.assetsPrefix available in 'development' mode
50
50
  target: config.appConfig.assetsPrefix ?? assetsPrefixFactory() ?? '',
51
51
  pathRewrite: (path) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-progressive-web-app",
3
- "version": "5.49.1",
3
+ "version": "6.59.0",
4
4
  "description": "Pwa integration - SW, manifest, icons and meta",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -23,16 +23,19 @@
23
23
  "registry": "https://registry.npmjs.org/"
24
24
  },
25
25
  "dependencies": {
26
- "@tramvai/tokens-common": "5.49.1",
27
- "@tramvai/tokens-render": "5.49.1",
28
- "@tramvai/tokens-server": "5.49.1",
26
+ "@tramvai/tokens-common": "6.59.0",
27
+ "@tramvai/tokens-render": "6.59.0",
28
+ "@tramvai/tokens-server": "6.59.0",
29
29
  "workbox-window": "^6.6.1"
30
30
  },
31
- "devDependencies": {},
31
+ "devDependencies": {
32
+ "@tramvai/plugin-webpack-pwa": "6.59.0"
33
+ },
32
34
  "peerDependencies": {
33
- "@tramvai/cli": "5.49.1",
34
- "@tramvai/core": "5.49.1",
35
- "@tinkoff/dippy": "0.11.4",
35
+ "@tinkoff/dippy": "0.12.3",
36
+ "@tramvai/cli": "6.59.0",
37
+ "@tramvai/core": "6.59.0",
38
+ "@tramvai/plugin-webpack-pwa": "6.59.0",
36
39
  "tslib": "^2.4.0"
37
40
  }
38
41
  }