-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add SvelteKit 2 support (#76)
* feat!: add SvelteKit 2 support * chore: update Vitest to v1 * chore: update readme * chore: fix readme typo * chore: . * chore: add offline and trailing slash tests * chore: add reload about page when offline test
- Loading branch information
Showing
10 changed files
with
1,009 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
node-version=16.14.0 | ||
engine-strict=true | ||
ignore-workspace-root-check=true | ||
shamefully-hoist=true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {test, expect} from '@playwright/test'; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
import {generateSW} from "../pwa.mjs"; | ||
|
||
test('Test offline and trailing slashes', async ({ browser}) => { | ||
// test offline + trailing slashes routes | ||
const context = await browser.newContext() | ||
const offlinePage = await context.newPage() | ||
await offlinePage.goto('/') | ||
const offlineSwURL = await offlinePage.evaluate(async () => { | ||
const registration = await Promise.race([ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
navigator.serviceWorker.ready, | ||
new Promise((_, reject) => setTimeout(() => reject(new Error('Service worker registration failed: time out')), 10000)) | ||
]) | ||
// @ts-expect-error registration is of type unknown | ||
return registration.active?.scriptURL | ||
}); | ||
const offlineSwName = generateSW ? 'sw.js' : 'prompt-sw.js' | ||
expect(offlineSwURL).toBe(`http://localhost:4173/${offlineSwName}`); | ||
await context.setOffline(true) | ||
const aboutAnchor = offlinePage.getByRole('link', { name: 'About' }) | ||
expect(await aboutAnchor.getAttribute('href')).toBe('/about') | ||
await aboutAnchor.click({ noWaitAfter: false }) | ||
const url = await offlinePage.evaluate(async () => { | ||
await new Promise(resolve => setTimeout(resolve, 3000)) | ||
return location.href | ||
}) | ||
expect(url).toBe('http://localhost:4173/about') | ||
expect(offlinePage.locator('li[aria-current="page"] a').getByText('About')).toBeTruthy() | ||
await offlinePage.reload({ waitUntil: 'load' }) | ||
expect(offlinePage.url()).toBe('http://localhost:4173/about') | ||
expect(offlinePage.locator('li[aria-current="page"] a').getByText('About')).toBeTruthy() | ||
// Dispose context once it's no longer needed. | ||
await context.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"name": "@vite-pwa/sveltekit", | ||
"type": "module", | ||
"version": "0.2.10", | ||
"packageManager": "pnpm@8.11.0", | ||
"packageManager": "pnpm@8.12.1", | ||
"description": "Zero-config PWA for SvelteKit", | ||
"author": "antfu <[email protected]>", | ||
"license": "MIT", | ||
|
@@ -39,7 +39,7 @@ | |
"*.d.ts" | ||
], | ||
"engines": { | ||
"node": ">=16.14 || >=18" | ||
"node": ">=16.14 || >=18.13" | ||
}, | ||
"scripts": { | ||
"build": "unbuild", | ||
|
@@ -50,8 +50,8 @@ | |
"test": "pnpm run -C examples/sveltekit-ts test" | ||
}, | ||
"peerDependencies": { | ||
"@sveltejs/kit": "^1.3.1", | ||
"vite-plugin-pwa": ">=0.16.7 <1" | ||
"@sveltejs/kit": "^1.3.1 || ^2.0.1", | ||
"vite-plugin-pwa": ">=0.17.4 <1" | ||
}, | ||
"dependencies": { | ||
"kolorist": "^1.8.0" | ||
|
@@ -62,12 +62,11 @@ | |
"@types/debug": "^4.1.8", | ||
"@types/node": "^18.17.15", | ||
"@typescript-eslint/eslint-plugin": "^6.13.2", | ||
"@vite-pwa/sveltekit": "workspace:*", | ||
"bumpp": "^9.2.0", | ||
"eslint": "^8.55.0", | ||
"typescript": "^5.3.3", | ||
"unbuild": "^2.0.0", | ||
"vite": "^4.5.1", | ||
"vite-plugin-pwa": ">=0.16.7 <1" | ||
"vite": "^5.0.10", | ||
"vite-plugin-pwa": ">=0.17.4 <1" | ||
} | ||
} |
Oops, something went wrong.