@serwist/window 9.0.0 → 9.0.2

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
@@ -1 +1 @@
1
- This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-window
1
+ This module's documentation can be found at https://serwist.pages.dev/docs/window.
@@ -1 +1 @@
1
- {"version":3,"file":"Serwist.d.ts","sourceRoot":"","sources":["../src/Serwist.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAK1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAgBnE;;;;;;;;;;GAUG;AACH,qBAAa,OAAQ,SAAQ,kBAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA4B;IACvD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA2B;IAC5D,OAAO,CAAC,iBAAiB,CAAK;IAG9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2C;IACvE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA2C;IAC3E,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA2C;IAEhF,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,SAAS,CAAC,CAAU;IAC5B,OAAO,CAAC,wBAAwB,CAAC,CAAgB;IACjD,OAAO,CAAC,aAAa,CAAC,CAA4B;IAClD,OAAO,CAAC,GAAG,CAAC,CAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,WAAW,CAAC,CAAgB;IACpC,OAAO,CAAC,eAAe,CAAC,CAAS;IAEjC;;;;;;;;OAQG;gBACS,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,eAAe,GAAE,mBAAwB;IAY3F;;;;;;OAMG;IACG,QAAQ,CAAC,EACb,SAAiB,GAClB,GAAE;QACD;;;WAGG;QACH,SAAS,CAAC,EAA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;OAMG;IACH,kBAAkB,IAAI,IAAI;IAM1B;;;;;;OAMG;IACH,OAAO,CAAC,6BAA6B;IAQrC;;;;;OAKG;YACW,eAAe;IAsB7B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAsE7B;IAEF;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAqF7B;IAEF;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAuBlC;IAEF;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAuBzB;CACH;AAKD;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;GAaG"}
@@ -0,0 +1,3 @@
1
+ import { isCurrentPageOutOfScope } from "./utils/isCurrentPageOutOfScope.js";
2
+ export { isCurrentPageOutOfScope };
3
+ //# sourceMappingURL=index.internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.internal.d.ts","sourceRoot":"","sources":["../src/index.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ const isCurrentPageOutOfScope = (scope)=>{
2
+ const scopeURL = new URL(scope, document.baseURI);
3
+ const scopeURLBasePath = new URL("./", scopeURL.href).pathname;
4
+ return !location.pathname.startsWith(scopeURLBasePath);
5
+ };
6
+
7
+ export { isCurrentPageOutOfScope };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Deferred, logger } from 'serwist/internal';
2
+ import { isCurrentPageOutOfScope } from './index.internal.js';
2
3
 
3
4
  const messageSW = (sw, data)=>{
4
5
  return new Promise((resolve)=>{
@@ -126,12 +127,7 @@ class Serwist extends SerwistEventTarget {
126
127
  logger.debug("A service worker with a different script URL is currently controlling the page. The browser is now fetching the new script now...");
127
128
  }
128
129
  }
129
- const currentPageIsOutOfScope = ()=>{
130
- const scopeURL = new URL(this._registerOptions.scope || this._scriptURL.toString(), document.baseURI);
131
- const scopeURLBasePath = new URL("./", scopeURL.href).pathname;
132
- return !location.pathname.startsWith(scopeURLBasePath);
133
- };
134
- if (currentPageIsOutOfScope()) {
130
+ if (isCurrentPageOutOfScope(this._registerOptions.scope || this._scriptURL.toString())) {
135
131
  logger.warn("The current page is not in scope for the registered service worker. Was this a mistake?");
136
132
  }
137
133
  }
@@ -0,0 +1,2 @@
1
+ export declare const isCurrentPageOutOfScope: (scope: string) => boolean;
2
+ //# sourceMappingURL=isCurrentPageOutOfScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isCurrentPageOutOfScope.d.ts","sourceRoot":"","sources":["../../src/utils/isCurrentPageOutOfScope.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,UAAW,MAAM,YAIpD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/window",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "type": "module",
5
5
  "description": "Simplifies communications with Serwist packages running in the service worker",
6
6
  "files": [
@@ -23,21 +23,32 @@
23
23
  "homepage": "https://serwist.pages.dev",
24
24
  "main": "./dist/index.js",
25
25
  "types": "./dist/index.d.ts",
26
+ "typesVersions": {
27
+ "*": {
28
+ "internal": [
29
+ "./dist/index.internal.d.ts"
30
+ ]
31
+ }
32
+ },
26
33
  "exports": {
27
34
  ".": {
28
35
  "types": "./dist/index.d.ts",
29
36
  "default": "./dist/index.js"
30
37
  },
38
+ "./internal": {
39
+ "types": "./dist/index.internal.d.ts",
40
+ "default": "./dist/index.internal.js"
41
+ },
31
42
  "./package.json": "./package.json"
32
43
  },
33
44
  "dependencies": {
34
45
  "@types/trusted-types": "2.0.7",
35
- "serwist": "9.0.0"
46
+ "serwist": "9.0.2"
36
47
  },
37
48
  "devDependencies": {
38
49
  "rollup": "4.14.3",
39
50
  "typescript": "5.5.0-dev.20240415",
40
- "@serwist/configs": "9.0.0"
51
+ "@serwist/configs": "9.0.2"
41
52
  },
42
53
  "peerDependencies": {
43
54
  "typescript": ">=5.0.0"
@@ -48,7 +59,7 @@
48
59
  }
49
60
  },
50
61
  "scripts": {
51
- "build": "rimraf dist && cross-env NODE_ENV=production rollup --config rollup.config.js",
62
+ "build": "rimraf dist && NODE_ENV=production rollup --config rollup.config.js",
52
63
  "dev": "rollup --config rollup.config.js --watch",
53
64
  "lint": "biome lint ./src",
54
65
  "typecheck": "tsc"
package/src/Serwist.ts CHANGED
@@ -13,6 +13,7 @@ import { messageSW } from "./messageSW.js";
13
13
  import type { SerwistLifecycleEventMap } from "./utils/SerwistEvent.js";
14
14
  import { SerwistEvent } from "./utils/SerwistEvent.js";
15
15
  import { SerwistEventTarget } from "./utils/SerwistEventTarget.js";
16
+ import { isCurrentPageOutOfScope } from "./utils/isCurrentPageOutOfScope.js";
16
17
  import { urlsMatch } from "./utils/urlsMatch.js";
17
18
 
18
19
  // The time a SW must be in the waiting phase before we can conclude
@@ -172,12 +173,7 @@ export class Serwist extends SerwistEventTarget {
172
173
  }
173
174
  }
174
175
 
175
- const currentPageIsOutOfScope = () => {
176
- const scopeURL = new URL(this._registerOptions.scope || this._scriptURL.toString(), document.baseURI);
177
- const scopeURLBasePath = new URL("./", scopeURL.href).pathname;
178
- return !location.pathname.startsWith(scopeURLBasePath);
179
- };
180
- if (currentPageIsOutOfScope()) {
176
+ if (isCurrentPageOutOfScope(this._registerOptions.scope || this._scriptURL.toString())) {
181
177
  logger.warn("The current page is not in scope for the registered service worker. Was this a mistake?");
182
178
  }
183
179
  }
@@ -0,0 +1,3 @@
1
+ import { isCurrentPageOutOfScope } from "./utils/isCurrentPageOutOfScope.js";
2
+
3
+ export { isCurrentPageOutOfScope };
@@ -0,0 +1,5 @@
1
+ export const isCurrentPageOutOfScope = (scope: string) => {
2
+ const scopeURL = new URL(scope, document.baseURI);
3
+ const scopeURLBasePath = new URL("./", scopeURL.href).pathname;
4
+ return !location.pathname.startsWith(scopeURLBasePath);
5
+ };