diff --git a/package.json b/package.json index 3e2c3f6b5..ef1835578 100644 --- a/package.json +++ b/package.json @@ -77,12 +77,12 @@ }, { "path": "./build/releases/OneSignalSDK.page.es6.js", - "limit": "42.4 kB", + "limit": "42.7 kB", "gzip": true }, { "path": "./build/releases/OneSignalSDK.sw.js", - "limit": "12.354 kB", + "limit": "12.65 kB", "gzip": true }, { diff --git a/preview/OneSignalSDKWorker.js b/preview/OneSignalSDKWorker.js index 0e7564295..964788d31 100644 --- a/preview/OneSignalSDKWorker.js +++ b/preview/OneSignalSDKWorker.js @@ -1,4 +1,9 @@ -importScripts('https://localhost:4001/sdks/web/v16/Dev-OneSignalSDK.sw.js'); +// Use self.location.origin so the worker imports from whichever origin +// served it (localhost during local dev, an ngrok/Cloudflare tunnel during +// device testing, etc.). Hardcoding localhost:4001 breaks any test that +// loads this worker from a non-localhost origin (the inner script is +// fetched as part of registration and produces a NetworkError otherwise). +importScripts(`${self.location.origin}/sdks/web/v16/Dev-OneSignalSDK.sw.js`); // For testing on staging // importScripts( diff --git a/preview/pageA.html b/preview/pageA.html new file mode 100644 index 000000000..179ccb547 --- /dev/null +++ b/preview/pageA.html @@ -0,0 +1,76 @@ + + +
+ + ++ Go to Page B +
++ +
+Repro steps (per the ticket):
+init() should hang.+ Go to Page A +
++ This page intentionally does not initialize the SDK. It just navigates back to Page A + so we can exercise the multi-page navigation flow described in SDK-4336. +
+ + diff --git a/preview/push/onesignal/OneSignalSDKWorker.js b/preview/push/onesignal/OneSignalSDKWorker.js index 0e7564295..f47bf0c0a 100644 --- a/preview/push/onesignal/OneSignalSDKWorker.js +++ b/preview/push/onesignal/OneSignalSDKWorker.js @@ -1,4 +1,4 @@ -importScripts('https://localhost:4001/sdks/web/v16/Dev-OneSignalSDK.sw.js'); +importScripts(`${self.location.origin}/sdks/web/v16/Dev-OneSignalSDK.sw.js`); // For testing on staging // importScripts( diff --git a/preview/vite.config.ts b/preview/vite.config.ts index 58a97bd00..c06151568 100644 --- a/preview/vite.config.ts +++ b/preview/vite.config.ts @@ -43,8 +43,25 @@ export default defineConfig({ // SDK fetch URL (e.g. `http://localhost:4000/...` in HTTP mode) lands here. port: useHttps ? 4001 : 4000, strictPort: true, + // HMR's WebSocket targets `wss://localhost: