From d030f4bb285e70844d09b3f0c87809bae43014b8 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:08:59 -0800 Subject: [PATCH] feat: support Vite 6 (#12270) --- .changeset/curvy-garlics-walk.md | 8 + .changeset/purple-comics-know.md | 5 + packages/adapter-auto/package.json | 2 +- .../adapter-cloudflare-workers/package.json | 2 +- packages/adapter-cloudflare/package.json | 2 +- packages/adapter-netlify/package.json | 6 +- packages/adapter-node/package.json | 4 +- packages/adapter-static/package.json | 6 +- .../test/apps/prerendered/package.json | 6 +- .../adapter-static/test/apps/spa/package.json | 6 +- packages/adapter-vercel/package.json | 6 +- packages/enhanced-img/package.json | 8 +- packages/kit/package.json | 16 +- packages/kit/src/exports/public.d.ts | 11 +- packages/kit/src/runtime/client/client.js | 2 +- .../kit/src/runtime/server/page/load_data.js | 2 +- .../kit/src/runtime/server/page/render.js | 2 +- packages/kit/test/apps/amp/package.json | 6 +- packages/kit/test/apps/basics/package.json | 6 +- .../basics/test/cross-platform/client.test.js | 40 +- packages/kit/test/apps/dev-only/package.json | 6 +- packages/kit/test/apps/embed/package.json | 6 +- packages/kit/test/apps/no-ssr/package.json | 6 +- packages/kit/test/apps/options-2/package.json | 6 +- packages/kit/test/apps/options/package.json | 6 +- packages/kit/test/apps/writes/package.json | 6 +- .../package.json | 6 +- .../package.json | 6 +- .../package.json | 6 +- .../package.json | 6 +- .../apps/private-dynamic-env/package.json | 6 +- .../package.json | 6 +- .../apps/private-static-env/package.json | 6 +- .../package.json | 6 +- .../apps/server-only-folder/package.json | 6 +- .../package.json | 6 +- .../apps/server-only-module/package.json | 6 +- .../package.json | 6 +- .../service-worker-private-env/package.json | 6 +- .../apps/syntax-error/package.json | 6 +- packages/kit/test/build-errors/package.json | 2 +- .../kit/test/prerendering/basics/package.json | 8 +- .../test/prerendering/options/package.json | 8 +- .../test/prerendering/paths-base/package.json | 8 +- packages/kit/test/utils.d.ts | 3 +- packages/kit/test/utils.js | 30 + packages/kit/types/index.d.ts | 43 +- packages/package/package.json | 4 +- .../javascript/expected/Test.svelte.d.ts | 95 +- .../javascript/expected/Test2.svelte.d.ts | 52 +- .../expected/internal/Test.svelte.d.ts | 52 +- .../resolve-alias/expected/Test.svelte | 12 +- .../resolve-alias/expected/Test.svelte.d.ts | 35 +- .../svelte-3-types/expected/Test.svelte | 2 +- .../svelte-kit/expected/Test.svelte.d.ts | 95 +- .../typescript-esnext/expected/Plain.svelte | 11 +- .../expected/Plain.svelte.d.ts | 52 +- .../typescript-esnext/expected/Test.svelte | 2 +- .../expected/Test.svelte.d.ts | 54 +- .../typescript-esnext/expected/Test2.svelte | 2 +- .../expected/Test2.svelte.d.ts | 37 +- .../typescript-esnext/src/lib/Plain.svelte | 7 +- .../typescript-nodenext/expected/Test.svelte | 2 +- .../expected/Test.svelte.d.ts | 54 +- .../test/watch/expected/Test.svelte.d.ts | 34 +- playgrounds/basic/package.json | 6 +- pnpm-lock.yaml | 1982 +++++++---------- 67 files changed, 1365 insertions(+), 1593 deletions(-) create mode 100644 .changeset/curvy-garlics-walk.md create mode 100644 .changeset/purple-comics-know.md diff --git a/.changeset/curvy-garlics-walk.md b/.changeset/curvy-garlics-walk.md new file mode 100644 index 000000000000..aa68c7585d68 --- /dev/null +++ b/.changeset/curvy-garlics-walk.md @@ -0,0 +1,8 @@ +--- +'@sveltejs/adapter-cloudflare-workers': minor +'@sveltejs/adapter-cloudflare': minor +'@sveltejs/adapter-netlify': minor +'@sveltejs/adapter-vercel': minor +--- + +chore: upgrade esbuild to 0.24.0 diff --git a/.changeset/purple-comics-know.md b/.changeset/purple-comics-know.md new file mode 100644 index 000000000000..9334ee1fdab6 --- /dev/null +++ b/.changeset/purple-comics-know.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': minor +--- + +feat: Vite 6 support diff --git a/packages/adapter-auto/package.json b/packages/adapter-auto/package.json index 2d4016ac220d..ef4fbc3ba707 100644 --- a/packages/adapter-auto/package.json +++ b/packages/adapter-auto/package.json @@ -40,7 +40,7 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "@types/node": "^18.19.48", "typescript": "^5.3.3" }, diff --git a/packages/adapter-cloudflare-workers/package.json b/packages/adapter-cloudflare-workers/package.json index 3e82abd677d4..6715b2b8adeb 100644 --- a/packages/adapter-cloudflare-workers/package.json +++ b/packages/adapter-cloudflare-workers/package.json @@ -40,7 +40,7 @@ "dependencies": { "@cloudflare/workers-types": "^4.20231121.0", "@iarna/toml": "^2.2.5", - "esbuild": "^0.21.5" + "esbuild": "^0.24.0" }, "devDependencies": { "@cloudflare/kv-asset-handler": "^0.3.0", diff --git a/packages/adapter-cloudflare/package.json b/packages/adapter-cloudflare/package.json index fb99d2887e70..27cc3471295f 100644 --- a/packages/adapter-cloudflare/package.json +++ b/packages/adapter-cloudflare/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "@cloudflare/workers-types": "^4.20231121.0", - "esbuild": "^0.21.5", + "esbuild": "^0.24.0", "worktop": "0.8.0-next.18" }, "devDependencies": { diff --git a/packages/adapter-netlify/package.json b/packages/adapter-netlify/package.json index 1b92f575e208..f2f87d9d5edf 100644 --- a/packages/adapter-netlify/package.json +++ b/packages/adapter-netlify/package.json @@ -42,7 +42,7 @@ }, "dependencies": { "@iarna/toml": "^2.2.5", - "esbuild": "^0.21.5", + "esbuild": "^0.24.0", "set-cookie-parser": "^2.6.0" }, "devDependencies": { @@ -51,12 +51,12 @@ "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^15.3.0", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "@types/node": "^18.19.48", "@types/set-cookie-parser": "^2.4.7", "rollup": "^4.14.2", "typescript": "^5.3.3", - "vitest": "^2.0.1" + "vitest": "^2.1.6" }, "peerDependencies": { "@sveltejs/kit": "^2.4.0" diff --git a/packages/adapter-node/package.json b/packages/adapter-node/package.json index a7a0357b352b..a5410682c9bd 100644 --- a/packages/adapter-node/package.json +++ b/packages/adapter-node/package.json @@ -43,12 +43,12 @@ "devDependencies": { "@polka/url": "^1.0.0-next.28", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "@types/node": "^18.19.48", "polka": "^1.0.0-next.28", "sirv": "^3.0.0", "typescript": "^5.3.3", - "vitest": "^2.0.1" + "vitest": "^2.1.6" }, "dependencies": { "@rollup/plugin-commonjs": "^28.0.1", diff --git a/packages/adapter-static/package.json b/packages/adapter-static/package.json index 82d2cad95370..23f53f0746d1 100644 --- a/packages/adapter-static/package.json +++ b/packages/adapter-static/package.json @@ -41,12 +41,12 @@ "devDependencies": { "@playwright/test": "^1.44.1", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "@types/node": "^18.19.48", "sirv": "^3.0.0", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "typescript": "^5.3.3", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "peerDependencies": { "@sveltejs/kit": "^2.0.0" diff --git a/packages/adapter-static/test/apps/prerendered/package.json b/packages/adapter-static/test/apps/prerendered/package.json index da2f395ac99d..c040f5a6b7e2 100644 --- a/packages/adapter-static/test/apps/prerendered/package.json +++ b/packages/adapter-static/test/apps/prerendered/package.json @@ -10,10 +10,10 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "sirv-cli": "^3.0.0", - "svelte": "^4.2.10", - "vite": "^5.3.2" + "svelte": "^5.2.9", + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/adapter-static/test/apps/spa/package.json b/packages/adapter-static/test/apps/spa/package.json index 318c10363757..a13507f14424 100644 --- a/packages/adapter-static/test/apps/spa/package.json +++ b/packages/adapter-static/test/apps/spa/package.json @@ -11,10 +11,10 @@ "devDependencies": { "@sveltejs/adapter-node": "workspace:^", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "sirv-cli": "^3.0.0", - "svelte": "^4.2.10", - "vite": "^5.3.2" + "svelte": "^5.2.9", + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/adapter-vercel/package.json b/packages/adapter-vercel/package.json index 1a415a47c947..884c460f24e1 100644 --- a/packages/adapter-vercel/package.json +++ b/packages/adapter-vercel/package.json @@ -40,14 +40,14 @@ }, "dependencies": { "@vercel/nft": "^0.27.1", - "esbuild": "^0.21.5" + "esbuild": "^0.24.0" }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "@types/node": "^18.19.48", "typescript": "^5.3.3", - "vitest": "^2.0.1" + "vitest": "^2.1.6" }, "peerDependencies": { "@sveltejs/kit": "^2.4.0" diff --git a/packages/enhanced-img/package.json b/packages/enhanced-img/package.json index 6b475bbf7e4c..4fc2bbc76dcb 100644 --- a/packages/enhanced-img/package.json +++ b/packages/enhanced-img/package.json @@ -44,11 +44,11 @@ "devDependencies": { "@types/estree": "^1.0.5", "@types/node": "^18.19.48", - "rollup": "^4.14.2", - "svelte": "^5.1.3", + "rollup": "^4.27.4", + "svelte": "^5.2.9", "typescript": "^5.6.3", - "vite": "^5.3.2", - "vitest": "^2.0.1" + "vite": "^6.0.1", + "vitest": "^2.1.6" }, "peerDependencies": { "svelte": "^5.0.0", diff --git a/packages/kit/package.json b/packages/kit/package.json index fcf5d8bb928c..a0ed5b02bef5 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -21,7 +21,7 @@ "@types/cookie": "^0.6.0", "cookie": "^0.6.0", "devalue": "^5.1.0", - "esm-env": "^1.0.0", + "esm-env": "^1.2.1", "import-meta-resolve": "^4.1.0", "kleur": "^4.1.5", "magic-string": "^0.30.5", @@ -33,22 +33,22 @@ }, "devDependencies": { "@playwright/test": "^1.44.1", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "@types/connect": "^3.4.38", "@types/node": "^18.19.48", "@types/set-cookie-parser": "^2.4.7", - "dts-buddy": "^0.5.3", + "dts-buddy": "^0.5.4", "rollup": "^4.14.2", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-preprocess": "^6.0.0", "typescript": "^5.3.3", - "vite": "^5.3.2", - "vitest": "^2.0.1" + "vite": "^6.0.1", + "vitest": "^2.1.6" }, "peerDependencies": { - "@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1", + "@sveltejs/vite-plugin-svelte": "^3.0.0 || ^4.0.0-next.1 || ^5.0.0", "svelte": "^4.0.0 || ^5.0.0-next.0", - "vite": "^5.0.3" + "vite": "^5.0.3 || ^6.0.0" }, "bin": { "svelte-kit": "svelte-kit.js" diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index 7db17269967f..84a3f041c322 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -79,11 +79,12 @@ export interface ActionFailure | undefined = u [uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure } -type UnpackValidationError = T extends ActionFailure - ? X - : T extends void - ? undefined // needs to be undefined, because void will corrupt union type - : T; +type UnpackValidationError = + T extends ActionFailure + ? X + : T extends void + ? undefined // needs to be undefined, because void will corrupt union type + : T; /** * This object is passed to the `adapt` function of adapters. diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 09618a4b2b9e..bec38c9122fa 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -972,7 +972,7 @@ async function load_route({ id, invalidating, url, params, route, preload }) { server_data_node: create_data_node( // server_data_node is undefined if it wasn't reloaded from the server; // and if current loader uses server data, we want to reuse previous data. - server_data_node === undefined && loader[0] ? { type: 'skip' } : server_data_node ?? null, + server_data_node === undefined && loader[0] ? { type: 'skip' } : (server_data_node ?? null), loader[0] ? previous?.server : undefined ) }); diff --git a/packages/kit/src/runtime/server/page/load_data.js b/packages/kit/src/runtime/server/page/load_data.js index e2af144654e6..42446393ad83 100644 --- a/packages/kit/src/runtime/server/page/load_data.js +++ b/packages/kit/src/runtime/server/page/load_data.js @@ -244,7 +244,7 @@ export function create_universal_fetch(event, state, fetched, csr, resolve_opts) } } else { // simulate CORS errors and "no access to body in no-cors mode" server-side for consistency with client-side behaviour - const mode = input instanceof Request ? input.mode : init?.mode ?? 'cors'; + const mode = input instanceof Request ? input.mode : (init?.mode ?? 'cors'); if (mode === 'no-cors') { response = new Response('', { status: response.status, diff --git a/packages/kit/src/runtime/server/page/render.js b/packages/kit/src/runtime/server/page/render.js index be44c3c7a860..6197d5ba63c6 100644 --- a/packages/kit/src/runtime/server/page/render.js +++ b/packages/kit/src/runtime/server/page/render.js @@ -79,7 +79,7 @@ export async function render_response({ const form_value = action_result?.type === 'success' || action_result?.type === 'failure' - ? action_result.data ?? null + ? (action_result.data ?? null) : null; /** @type {string} */ diff --git a/packages/kit/test/apps/amp/package.json b/packages/kit/test/apps/amp/package.json index 804403145aae..7a6f03eebcb9 100644 --- a/packages/kit/test/apps/amp/package.json +++ b/packages/kit/test/apps/amp/package.json @@ -14,13 +14,13 @@ "devDependencies": { "@sveltejs/amp": "workspace:^", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", "dropcss": "^1.0.16", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/apps/basics/package.json b/packages/kit/test/apps/basics/package.json index 644e52e62a05..fda8f31a4ee2 100644 --- a/packages/kit/test/apps/basics/package.json +++ b/packages/kit/test/apps/basics/package.json @@ -15,12 +15,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/apps/basics/test/cross-platform/client.test.js b/packages/kit/test/apps/basics/test/cross-platform/client.test.js index 2b6da59b9cc2..ce0758ea8dea 100644 --- a/packages/kit/test/apps/basics/test/cross-platform/client.test.js +++ b/packages/kit/test/apps/basics/test/cross-platform/client.test.js @@ -283,13 +283,12 @@ test.describe('Scrolling', () => { test('url-supplied non-ascii anchor works on navigation to page after manual scroll', async ({ page, in_view, - clicknav + clicknav, + scroll_to }) => { await page.goto('/anchor'); await clicknav('#non-ascii-anchor'); - await page.evaluate(() => { - window.scrollTo(0, 50); - }); + await scroll_to(0, 50); await page.locator('#non-ascii-anchor').click(); expect(await in_view('#go-to-encöded')).toBe(true); }); @@ -359,7 +358,8 @@ test.describe('Scrolling', () => { test('scroll is restored after hitting the back button for an in-app cross-document navigation', async ({ page, - clicknav + clicknav, + scroll_to }) => { await page.goto('/scroll/cross-document/a'); @@ -368,7 +368,7 @@ test.describe('Scrolling', () => { if (!rect) throw new Error('Could not determine bounding box'); const target_scroll_y = rect.y + rect.height - height; - await page.evaluate((y) => scrollTo(0, y), target_scroll_y); + await scroll_to(0, target_scroll_y); await page.locator('[href="/scroll/cross-document/b"]').click(); expect(await page.textContent('h1')).toBe('b'); @@ -441,7 +441,8 @@ test.describe('Scrolling', () => { test('scroll positions are recovered on reloading the page', async ({ page, app, - browserName + browserName, + scroll_to }) => { // No idea why the workaround below works only in dev mode // A better solution would probably be to set fission.webContentIsolationStrategy: 1 @@ -451,9 +452,9 @@ test.describe('Scrolling', () => { } await page.goto('/anchor'); - await page.evaluate(() => window.scrollTo(0, 1000)); + await scroll_to(0, 1000); await app.goto('/anchor/anchor'); - await page.evaluate(() => window.scrollTo(0, 1000)); + await scroll_to(0, 1000); await page.reload(); if (browserName === 'firefox') { @@ -461,10 +462,11 @@ test.describe('Scrolling', () => { // See https://github.com/microsoft/playwright/issues/22640 await page.goBack(); } - expect(await page.evaluate(() => window.scrollY)).toBe(1000); + await page.waitForFunction(() => window.scrollY === 1000); + const waiter = page.waitForFunction(() => window.scrollY === 1000); await page.goBack(); - expect(await page.evaluate(() => window.scrollY)).toBe(1000); + await waiter; }); test('scroll position is top of page on ssr:false reload', async ({ page }) => { @@ -474,26 +476,32 @@ test.describe('Scrolling', () => { expect(await page.evaluate(() => window.scrollY)).toBe(0); }); - test('clicking # or #top takes you to the top of the current page', async ({ page }) => { + test('clicking # or #top takes you to the top of the current page', async ({ + page, + scroll_to + }) => { await page.goto('/scroll/top'); for (const href of ['#', '#top']) { - await page.evaluate(() => window.scrollTo(0, 1000)); + await scroll_to(0, 1000); await page.click(`a[href="${href}"]`); expect(await page.evaluate(() => window.scrollY)).toBe(0); - await page.evaluate(() => window.scrollTo(0, 1000)); + await scroll_to(0, 1000); await page.click(`a[href="${href}"]`); expect(await page.evaluate(() => window.scrollY)).toBe(0); } }); - test('Scroll position is correct after going back from a shallow route', async ({ page }) => { + test('Scroll position is correct after going back from a shallow route', async ({ + page, + scroll_to + }) => { await page.goto('/scroll/push-state'); await page.locator('#subpage-link').click(); await page.locator('#back-button').click(); - await page.evaluate(() => window.scrollTo(0, 9999)); + await scroll_to(0, 9999); const scroll = await page.evaluate(() => window.scrollY); expect(scroll).toBeGreaterThan(0); diff --git a/packages/kit/test/apps/dev-only/package.json b/packages/kit/test/apps/dev-only/package.json index 48a7f63ef7e3..d2bef02977a2 100644 --- a/packages/kit/test/apps/dev-only/package.json +++ b/packages/kit/test/apps/dev-only/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", "e2e-test-dep-error": "file:./_test_dependencies/cjs-only", "e2e-test-dep-hooks": "file:./_test_dependencies/cjs-only", @@ -23,10 +23,10 @@ "e2e-test-dep-page-svelte": "file:./_test_dependencies/cjs-only", "e2e-test-dep-page-universal": "file:./_test_dependencies/cjs-only", "e2e-test-dep-server": "file:./_test_dependencies/cjs-only", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/apps/embed/package.json b/packages/kit/test/apps/embed/package.json index a552ae5b9af6..680dfe2235f6 100644 --- a/packages/kit/test/apps/embed/package.json +++ b/packages/kit/test/apps/embed/package.json @@ -13,12 +13,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/apps/no-ssr/package.json b/packages/kit/test/apps/no-ssr/package.json index e91c96955eef..4cc3a5c14f15 100644 --- a/packages/kit/test/apps/no-ssr/package.json +++ b/packages/kit/test/apps/no-ssr/package.json @@ -13,12 +13,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/apps/options-2/package.json b/packages/kit/test/apps/options-2/package.json index b6853c3ff978..623d6cd62285 100644 --- a/packages/kit/test/apps/options-2/package.json +++ b/packages/kit/test/apps/options-2/package.json @@ -14,12 +14,12 @@ "devDependencies": { "@sveltejs/adapter-node": "workspace:^", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/apps/options/package.json b/packages/kit/test/apps/options/package.json index 2d13c0c82cce..96d2a80b24fa 100644 --- a/packages/kit/test/apps/options/package.json +++ b/packages/kit/test/apps/options/package.json @@ -13,12 +13,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/apps/writes/package.json b/packages/kit/test/apps/writes/package.json index 1e699e60a736..fb7f7f684c78 100644 --- a/packages/kit/test/apps/writes/package.json +++ b/packages/kit/test/apps/writes/package.json @@ -13,12 +13,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json b/packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json index 2388c4bee763..0dbfaafe1eb4 100644 --- a/packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json +++ b/packages/kit/test/build-errors/apps/prerender-entry-generator-mismatch/package.json @@ -11,11 +11,11 @@ "devDependencies": { "@sveltejs/adapter-auto": "workspace:^", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json b/packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json index 2388c4bee763..0dbfaafe1eb4 100644 --- a/packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json +++ b/packages/kit/test/build-errors/apps/prerenderable-incorrect-fragment/package.json @@ -11,11 +11,11 @@ "devDependencies": { "@sveltejs/adapter-auto": "workspace:^", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json b/packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json index 3a68c0d05832..8797667db0c7 100644 --- a/packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json +++ b/packages/kit/test/build-errors/apps/prerenderable-not-prerendered/package.json @@ -11,11 +11,11 @@ "devDependencies": { "@sveltejs/adapter-auto": "workspace:^", "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json b/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json index eaeb97a03561..1fa4ba71aa7c 100644 --- a/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json +++ b/packages/kit/test/build-errors/apps/private-dynamic-env-dynamic-import/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/private-dynamic-env/package.json b/packages/kit/test/build-errors/apps/private-dynamic-env/package.json index caae5316af01..9195222826b2 100644 --- a/packages/kit/test/build-errors/apps/private-dynamic-env/package.json +++ b/packages/kit/test/build-errors/apps/private-dynamic-env/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json b/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json index 41167a62cfdb..eb04f276dffa 100644 --- a/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json +++ b/packages/kit/test/build-errors/apps/private-static-env-dynamic-import/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/private-static-env/package.json b/packages/kit/test/build-errors/apps/private-static-env/package.json index 64b2995ad026..fd63031f7d86 100644 --- a/packages/kit/test/build-errors/apps/private-static-env/package.json +++ b/packages/kit/test/build-errors/apps/private-static-env/package.json @@ -11,12 +11,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "cross-env": "^7.0.3", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json b/packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json index d846ef1fe053..92bbc16f021b 100644 --- a/packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json +++ b/packages/kit/test/build-errors/apps/server-only-folder-dynamic-import/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/server-only-folder/package.json b/packages/kit/test/build-errors/apps/server-only-folder/package.json index 5fc1c187f609..e599b0fd8b7d 100644 --- a/packages/kit/test/build-errors/apps/server-only-folder/package.json +++ b/packages/kit/test/build-errors/apps/server-only-folder/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json b/packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json index ed531ea11636..977fb6d29bca 100644 --- a/packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json +++ b/packages/kit/test/build-errors/apps/server-only-module-dynamic-import/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/server-only-module/package.json b/packages/kit/test/build-errors/apps/server-only-module/package.json index 7605391aefdf..2229d146edaa 100644 --- a/packages/kit/test/build-errors/apps/server-only-module/package.json +++ b/packages/kit/test/build-errors/apps/server-only-module/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/package.json b/packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/package.json index ab5338950f09..d70025311be1 100644 --- a/packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/package.json +++ b/packages/kit/test/build-errors/apps/service-worker-dynamic-public-env/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/service-worker-private-env/package.json b/packages/kit/test/build-errors/apps/service-worker-private-env/package.json index e49775aa5e9a..c58e53b08db5 100644 --- a/packages/kit/test/build-errors/apps/service-worker-private-env/package.json +++ b/packages/kit/test/build-errors/apps/service-worker-private-env/package.json @@ -11,11 +11,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/apps/syntax-error/package.json b/packages/kit/test/build-errors/apps/syntax-error/package.json index f199b59239f9..819dcb848a2b 100644 --- a/packages/kit/test/build-errors/apps/syntax-error/package.json +++ b/packages/kit/test/build-errors/apps/syntax-error/package.json @@ -9,11 +9,11 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2" + "vite": "^6.0.1" }, "type": "module" } diff --git a/packages/kit/test/build-errors/package.json b/packages/kit/test/build-errors/package.json index 50c386bfeabd..1a10dab30e56 100644 --- a/packages/kit/test/build-errors/package.json +++ b/packages/kit/test/build-errors/package.json @@ -8,6 +8,6 @@ }, "type": "module", "devDependencies": { - "vitest": "^2.0.1" + "vitest": "^2.1.6" } } diff --git a/packages/kit/test/prerendering/basics/package.json b/packages/kit/test/prerendering/basics/package.json index fb0ce874382e..6ef2d6bda23f 100644 --- a/packages/kit/test/prerendering/basics/package.json +++ b/packages/kit/test/prerendering/basics/package.json @@ -12,12 +12,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2", - "vitest": "^2.0.1" + "vite": "^6.0.1", + "vitest": "^2.1.6" }, "type": "module" } diff --git a/packages/kit/test/prerendering/options/package.json b/packages/kit/test/prerendering/options/package.json index 182c7e58855d..0adfad3a14c2 100644 --- a/packages/kit/test/prerendering/options/package.json +++ b/packages/kit/test/prerendering/options/package.json @@ -11,12 +11,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2", - "vitest": "^2.0.1" + "vite": "^6.0.1", + "vitest": "^2.1.6" }, "type": "module" } diff --git a/packages/kit/test/prerendering/paths-base/package.json b/packages/kit/test/prerendering/paths-base/package.json index d501d3372620..960a2b2dd33e 100644 --- a/packages/kit/test/prerendering/paths-base/package.json +++ b/packages/kit/test/prerendering/paths-base/package.json @@ -11,12 +11,12 @@ }, "devDependencies": { "@sveltejs/kit": "workspace:^", - "@sveltejs/vite-plugin-svelte": "^3.0.1", - "svelte": "^4.2.10", + "@sveltejs/vite-plugin-svelte": "^5.0.1", + "svelte": "^5.2.9", "svelte-check": "^4.0.1", "typescript": "^5.5.4", - "vite": "^5.3.2", - "vitest": "^2.0.1" + "vite": "^6.0.1", + "vitest": "^2.1.6" }, "type": "module" } diff --git a/packages/kit/test/utils.d.ts b/packages/kit/test/utils.d.ts index 2477beb87ae0..7992ee76c493 100644 --- a/packages/kit/test/utils.d.ts +++ b/packages/kit/test/utils.d.ts @@ -7,7 +7,7 @@ import { TestType, Page } from '@playwright/test'; -import { IncomingMessage, ServerResponse } from 'http'; +import { IncomingMessage, ServerResponse } from 'node:http'; import { Plugin } from 'vite'; export const test: TestType< @@ -22,6 +22,7 @@ export const test: TestType< preloadData(url: string): Promise; }; clicknav(selector: string, options?: Parameters[0]): Promise; + scroll_to(x: number, y: number): Promise; in_view(selector: string): Promise; get_computed_style(selector: string, prop: string): Promise; /** diff --git a/packages/kit/test/utils.js b/packages/kit/test/utils.js index 7ddbf3709361..cf03a52ab718 100644 --- a/packages/kit/test/utils.js +++ b/packages/kit/test/utils.js @@ -70,6 +70,36 @@ export const test = base.extend({ await use(clicknav); }, + scroll_to: async ({ page }, use) => { + /** + * @param {number} x + * @param {number} y + */ + async function scroll_to(x, y) { + // The browser will do this for us, but we need to do it pre-emptively + // so that we can check the scroll location. + // Otherwise, we'd be checking a decimal number against an integer. + x = Math.trunc(x); + y = Math.trunc(y); + const watcher = page.waitForFunction( + /** @param {{ x: number, y: number }} opt */ (opt) => + // check if the scroll position reached the desired or maximum position + window.scrollX === + Math.min(opt.x, document.documentElement.offsetWidth - window.innerWidth) && + window.scrollY === + Math.min(opt.y, document.documentElement.offsetHeight - window.innerHeight), + { x, y } + ); + await page.evaluate( + /** @param {{ x: number, y: number }} opt */ (opt) => window.scrollTo(opt.x, opt.y), + { x, y } + ); + await watcher; + } + + await use(scroll_to); + }, + in_view: async ({ page }, use) => { /** @param {string} selector */ async function in_view(selector) { diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 237b3e3ff57e..63fdcb004bf3 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -61,11 +61,12 @@ declare module '@sveltejs/kit' { [uniqueSymbol]: true; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure } - type UnpackValidationError = T extends ActionFailure - ? X - : T extends void - ? undefined // needs to be undefined, because void will corrupt union type - : T; + type UnpackValidationError = + T extends ActionFailure + ? X + : T extends void + ? undefined // needs to be undefined, because void will corrupt union type + : T; /** * This object is passed to the `adapt` function of adapters. @@ -1786,9 +1787,9 @@ declare module '@sveltejs/kit' { * Checks whether this is an error thrown by {@link error}. * @param status The status to filter for. * */ - export function isHttpError(e: unknown, status?: T | undefined): e is HttpError_1 & { + export function isHttpError(e: unknown, status?: T | undefined): e is (HttpError_1 & { status: T extends undefined ? never : T; - }; + }); /** * Redirect a request. When called during request handling, SvelteKit will return a redirect response. * Make sure you're not catching the thrown redirect, which would prevent SvelteKit from handling it. @@ -1830,8 +1831,8 @@ declare module '@sveltejs/kit' { * Checks whether this is an action failure thrown by {@link fail}. * @param e The object to check. * */ - export function isActionFailure(e: unknown): e is ActionFailure; - export type LessThan = TNumber extends TArray['length'] ? TArray[number] : LessThan; + export function isActionFailure(e: unknown): e is ActionFailure; + export type LessThan = TNumber extends TArray["length"] ? TArray[number] : LessThan; export type NumericRange = Exclude, LessThan>; export const VERSION: string; class HttpError_1 { @@ -1924,19 +1925,19 @@ declare module '@sveltejs/kit/hooks' { * * @param handlers The chain of `handle` functions * */ - export function sequence(...handlers: import('@sveltejs/kit').Handle[]): import('@sveltejs/kit').Handle; + export function sequence(...handlers: import("@sveltejs/kit").Handle[]): import("@sveltejs/kit").Handle; export {}; } declare module '@sveltejs/kit/node' { export function getRequest({ request, base, bodySizeLimit }: { - request: import('http').IncomingMessage; + request: import("http").IncomingMessage; base: string; bodySizeLimit?: number; }): Promise; - export function setResponse(res: import('http').ServerResponse, response: Response): Promise; + export function setResponse(res: import("http").ServerResponse, response: Response): Promise; /** * Converts a file on disk to a readable stream * @since 2.4.0 @@ -1961,7 +1962,7 @@ declare module '@sveltejs/kit/vite' { /** * Returns the SvelteKit Vite plugins. * */ - export function sveltekit(): Promise; + export function sveltekit(): Promise; export {}; } @@ -2048,7 +2049,7 @@ declare module '$app/navigation' { * * `afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted. * */ - export function afterNavigate(callback: (navigation: import('@sveltejs/kit').AfterNavigate) => void): void; + export function afterNavigate(callback: (navigation: import("@sveltejs/kit").AfterNavigate) => void): void; /** * A navigation interceptor that triggers before we navigate to a new URL, whether by clicking a link, calling `goto(...)`, or using the browser back/forward controls. * @@ -2060,7 +2061,7 @@ declare module '$app/navigation' { * * `beforeNavigate` must be called during a component initialization. It remains active as long as the component is mounted. * */ - export function beforeNavigate(callback: (navigation: import('@sveltejs/kit').BeforeNavigate) => void): void; + export function beforeNavigate(callback: (navigation: import("@sveltejs/kit").BeforeNavigate) => void): void; /** * A lifecycle function that runs the supplied `callback` immediately before we navigate to a new URL except during full-page navigations. * @@ -2070,7 +2071,7 @@ declare module '$app/navigation' { * * `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted. * */ - export function onNavigate(callback: (navigation: import('@sveltejs/kit').OnNavigate) => MaybePromise<(() => void) | void>): void; + export function onNavigate(callback: (navigation: import("@sveltejs/kit").OnNavigate) => MaybePromise<(() => void) | void>): void; /** * If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling. * This is generally discouraged, since it breaks user expectations. @@ -2124,11 +2125,11 @@ declare module '$app/navigation' { * @param href Page to preload * */ export function preloadData(href: string): Promise<{ - type: 'loaded'; + type: "loaded"; status: number; data: Record; } | { - type: 'redirect'; + type: "redirect"; location: string; }>; /** @@ -2225,7 +2226,7 @@ declare module '$app/stores' { * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. * * */ - export const page: import('svelte/store').Readable; + export const page: import("svelte/store").Readable; /** * A readable store. * When navigating starts, its value is a `Navigation` object with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties. @@ -2233,13 +2234,13 @@ declare module '$app/stores' { * * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. * */ - export const navigating: import('svelte/store').Readable; + export const navigating: import("svelte/store").Readable; /** * A readable store whose initial value is `false`. If [`version.pollInterval`](https://svelte.dev/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling. * * On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time. * */ - export const updated: import('svelte/store').Readable & { + export const updated: import("svelte/store").Readable & { check(): Promise; }; diff --git a/packages/package/package.json b/packages/package/package.json index d5369848ccf5..1ab629b29654 100644 --- a/packages/package/package.json +++ b/packages/package/package.json @@ -27,11 +27,11 @@ "svelte2tsx": "~0.7.16" }, "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@sveltejs/vite-plugin-svelte": "^5.0.1", "@types/node": "^18.19.48", "@types/semver": "^7.5.6", "prettier": "^3.1.1", - "svelte": "^4.2.10", + "svelte": "^5.2.9", "svelte-preprocess": "^6.0.0", "typescript": "^5.3.3", "uvu": "^0.5.6" diff --git a/packages/package/test/fixtures/javascript/expected/Test.svelte.d.ts b/packages/package/test/fixtures/javascript/expected/Test.svelte.d.ts index 674fa1a2ab93..4d8d06cf9ae1 100644 --- a/packages/package/test/fixtures/javascript/expected/Test.svelte.d.ts +++ b/packages/package/test/fixtures/javascript/expected/Test.svelte.d.ts @@ -1,42 +1,55 @@ -/** @typedef {typeof __propDef.props} TestProps */ -/** @typedef {typeof __propDef.events} TestEvents */ -/** @typedef {typeof __propDef.slots} TestSlots */ -export default class Test extends SvelteComponent< - { - astring?: string; - }, - { - event: CustomEvent; - } & { - [evt: string]: CustomEvent; - }, - { - default: { - astring: string; - }; - } -> { - get astring(): string; -} -export type TestProps = typeof __propDef.props; -export type TestEvents = typeof __propDef.events; -export type TestSlots = typeof __propDef.slots; -import { SvelteComponent } from 'svelte'; -declare const __propDef: { - props: { - astring?: string; - }; - events: { - event: CustomEvent; - } & { - [evt: string]: CustomEvent; - }; - slots: { - default: { - astring: string; - }; - }; - exports?: {}; - bindings?: string; +export default Test; +type Test = SvelteComponent<$$__sveltets_2_PropsWithChildren<{ + astring?: string; +}, { + default: { + astring: string; + }; +}>, { + event: CustomEvent; +} & { + [evt: string]: CustomEvent; +}, { + default: { + astring: string; + }; +}> & { + $$bindings?: string; +} & { + astring: string; }; -export {}; +declare const Test: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{ + astring?: string; +}, { + default: { + astring: string; + }; +}>, { + event: CustomEvent; +} & { + [evt: string]: CustomEvent; +}, { + default: { + astring: string; + }; +}, { + astring: string; +}, string>; +type $$__sveltets_2_PropsWithChildren = Props & (Slots extends { + default: any; +} ? Props extends Record ? any : { + children?: any; +} : {}); +interface $$__sveltets_2_IsomorphicComponent = any, Events extends Record = any, Slots extends Record = any, Exports = {}, Bindings = string> { + new (options: import("svelte").ComponentConstructorOptions): import("svelte").SvelteComponent & { + $$bindings?: Bindings; + } & Exports; + (internal: unknown, props: Props & { + $$events?: Events; + $$slots?: Slots; + }): Exports & { + $set?: any; + $on?: any; + }; + z_$$bindings?: Bindings; +} diff --git a/packages/package/test/fixtures/javascript/expected/Test2.svelte.d.ts b/packages/package/test/fixtures/javascript/expected/Test2.svelte.d.ts index b01420475cf3..0774e4032afb 100644 --- a/packages/package/test/fixtures/javascript/expected/Test2.svelte.d.ts +++ b/packages/package/test/fixtures/javascript/expected/Test2.svelte.d.ts @@ -1,28 +1,26 @@ -/** @typedef {typeof __propDef.props} Test2Props */ -/** @typedef {typeof __propDef.events} Test2Events */ -/** @typedef {typeof __propDef.slots} Test2Slots */ -export default class Test2 extends SvelteComponent< - { - foo: boolean; - }, - { - [evt: string]: CustomEvent; - }, - {} -> {} -export type Test2Props = typeof __propDef.props; -export type Test2Events = typeof __propDef.events; -export type Test2Slots = typeof __propDef.slots; -import { SvelteComponent } from 'svelte'; -declare const __propDef: { - props: { - foo: import('./foo').Foo; - }; - events: { - [evt: string]: CustomEvent; - }; - slots: {}; - exports?: {}; - bindings?: string; +export default Test2; +type Test2 = SvelteComponent<{ + foo: boolean; +}, { + [evt: string]: CustomEvent; +}, {}> & { + $$bindings?: string; }; -export {}; +declare const Test2: $$__sveltets_2_IsomorphicComponent<{ + foo: import("./foo").Foo; +}, { + [evt: string]: CustomEvent; +}, {}, {}, string>; +interface $$__sveltets_2_IsomorphicComponent = any, Events extends Record = any, Slots extends Record = any, Exports = {}, Bindings = string> { + new (options: import("svelte").ComponentConstructorOptions): import("svelte").SvelteComponent & { + $$bindings?: Bindings; + } & Exports; + (internal: unknown, props: Props & { + $$events?: Events; + $$slots?: Slots; + }): Exports & { + $set?: any; + $on?: any; + }; + z_$$bindings?: Bindings; +} diff --git a/packages/package/test/fixtures/javascript/expected/internal/Test.svelte.d.ts b/packages/package/test/fixtures/javascript/expected/internal/Test.svelte.d.ts index 406a883fc969..1c3abfd7fb6e 100644 --- a/packages/package/test/fixtures/javascript/expected/internal/Test.svelte.d.ts +++ b/packages/package/test/fixtures/javascript/expected/internal/Test.svelte.d.ts @@ -1,28 +1,26 @@ -/** @typedef {typeof __propDef.props} TestProps */ -/** @typedef {typeof __propDef.events} TestEvents */ -/** @typedef {typeof __propDef.slots} TestSlots */ -export default class Test extends SvelteComponent< - { - foo: boolean; - }, - { - [evt: string]: CustomEvent; - }, - {} -> {} -export type TestProps = typeof __propDef.props; -export type TestEvents = typeof __propDef.events; -export type TestSlots = typeof __propDef.slots; -import { SvelteComponent } from 'svelte'; -declare const __propDef: { - props: { - foo: import('./foo').Foo; - }; - events: { - [evt: string]: CustomEvent; - }; - slots: {}; - exports?: {}; - bindings?: string; +export default Test; +type Test = SvelteComponent<{ + foo: boolean; +}, { + [evt: string]: CustomEvent; +}, {}> & { + $$bindings?: string; }; -export {}; +declare const Test: $$__sveltets_2_IsomorphicComponent<{ + foo: import("./foo").Foo; +}, { + [evt: string]: CustomEvent; +}, {}, {}, string>; +interface $$__sveltets_2_IsomorphicComponent = any, Events extends Record = any, Slots extends Record = any, Exports = {}, Bindings = string> { + new (options: import("svelte").ComponentConstructorOptions): import("svelte").SvelteComponent & { + $$bindings?: Bindings; + } & Exports; + (internal: unknown, props: Props & { + $$events?: Events; + $$slots?: Slots; + }): Exports & { + $set?: any; + $on?: any; + }; + z_$$bindings?: Bindings; +} diff --git a/packages/package/test/fixtures/resolve-alias/expected/Test.svelte b/packages/package/test/fixtures/resolve-alias/expected/Test.svelte index d6dbdc91b465..e1ffec195b89 100644 --- a/packages/package/test/fixtures/resolve-alias/expected/Test.svelte +++ b/packages/package/test/fixtures/resolve-alias/expected/Test.svelte @@ -1,6 +1,8 @@ - diff --git a/packages/package/test/fixtures/resolve-alias/expected/Test.svelte.d.ts b/packages/package/test/fixtures/resolve-alias/expected/Test.svelte.d.ts index 66031c66a487..f2b4fd180e4a 100644 --- a/packages/package/test/fixtures/resolve-alias/expected/Test.svelte.d.ts +++ b/packages/package/test/fixtures/resolve-alias/expected/Test.svelte.d.ts @@ -1,17 +1,20 @@ -import { SvelteComponent } from 'svelte'; -declare const __propDef: { - props: { - bar?: import('./sub/foo').Foo; +interface $$__sveltets_2_IsomorphicComponent = any, Events extends Record = any, Slots extends Record = any, Exports = {}, Bindings = string> { + new (options: import('svelte').ComponentConstructorOptions): import('svelte').SvelteComponent & { + $$bindings?: Bindings; + } & Exports; + (internal: unknown, props: Props & { + $$events?: Events; + $$slots?: Slots; + }): Exports & { + $set?: any; + $on?: any; }; - events: { - [evt: string]: CustomEvent; - }; - slots: {}; - exports?: {}; - bindings?: string; -}; -export type TestProps = typeof __propDef.props; -export type TestEvents = typeof __propDef.events; -export type TestSlots = typeof __propDef.slots; -export default class Test extends SvelteComponent {} -export {}; + z_$$bindings?: Bindings; +} +declare const Test: $$__sveltets_2_IsomorphicComponent<{ + bar?: import("./sub/foo").Foo; +}, { + [evt: string]: CustomEvent; +}, {}, {}, string>; +type Test = InstanceType; +export default Test; diff --git a/packages/package/test/fixtures/svelte-3-types/expected/Test.svelte b/packages/package/test/fixtures/svelte-3-types/expected/Test.svelte index 661b1b8276b0..7613c3ebf28b 100644 --- a/packages/package/test/fixtures/svelte-3-types/expected/Test.svelte +++ b/packages/package/test/fixtures/svelte-3-types/expected/Test.svelte @@ -1,4 +1,4 @@ - - + diff --git a/packages/package/test/fixtures/typescript-esnext/expected/Plain.svelte.d.ts b/packages/package/test/fixtures/typescript-esnext/expected/Plain.svelte.d.ts index 5da27ce522c5..e2632ad81c35 100644 --- a/packages/package/test/fixtures/typescript-esnext/expected/Plain.svelte.d.ts +++ b/packages/package/test/fixtures/typescript-esnext/expected/Plain.svelte.d.ts @@ -1,28 +1,26 @@ -/** @typedef {typeof __propDef.props} PlainProps */ -/** @typedef {typeof __propDef.events} PlainEvents */ -/** @typedef {typeof __propDef.slots} PlainSlots */ -export default class Plain extends SvelteComponent< - { - foo: boolean; - }, - { - [evt: string]: CustomEvent; - }, - {} -> {} -export type PlainProps = typeof __propDef.props; -export type PlainEvents = typeof __propDef.events; -export type PlainSlots = typeof __propDef.slots; -import { SvelteComponent } from 'svelte'; -declare const __propDef: { - props: { - foo: import('./foo').Foo; - }; - events: { - [evt: string]: CustomEvent; - }; - slots: {}; - exports?: {}; - bindings?: string; +export default Plain; +type Plain = SvelteComponent<{ + foo: boolean; +}, { + [evt: string]: CustomEvent; +}, {}> & { + $$bindings?: string; }; -export {}; +declare const Plain: $$__sveltets_2_IsomorphicComponent<{ + foo: import("./foo").Foo; +}, { + [evt: string]: CustomEvent; +}, {}, {}, string>; +interface $$__sveltets_2_IsomorphicComponent = any, Events extends Record = any, Slots extends Record = any, Exports = {}, Bindings = string> { + new (options: import("svelte").ComponentConstructorOptions): import("svelte").SvelteComponent & { + $$bindings?: Bindings; + } & Exports; + (internal: unknown, props: Props & { + $$events?: Events; + $$slots?: Slots; + }): Exports & { + $set?: any; + $on?: any; + }; + z_$$bindings?: Bindings; +} diff --git a/packages/package/test/fixtures/typescript-esnext/expected/Test.svelte b/packages/package/test/fixtures/typescript-esnext/expected/Test.svelte index 661b1b8276b0..7613c3ebf28b 100644 --- a/packages/package/test/fixtures/typescript-esnext/expected/Test.svelte +++ b/packages/package/test/fixtures/typescript-esnext/expected/Test.svelte @@ -1,4 +1,4 @@ - diff --git a/packages/package/test/fixtures/typescript-esnext/expected/Test2.svelte.d.ts b/packages/package/test/fixtures/typescript-esnext/expected/Test2.svelte.d.ts index d47a70a6e3f6..c8d660dcb43f 100644 --- a/packages/package/test/fixtures/typescript-esnext/expected/Test2.svelte.d.ts +++ b/packages/package/test/fixtures/typescript-esnext/expected/Test2.svelte.d.ts @@ -1,18 +1,21 @@ -import { SvelteComponent } from 'svelte'; import type { Foo } from './foo'; -declare const __propDef: { - props: { - foo: Foo; - }; - events: { - [evt: string]: CustomEvent; - }; - slots: {}; - exports?: {}; - bindings?: string; -}; -export type Test2Props = typeof __propDef.props; -export type Test2Events = typeof __propDef.events; -export type Test2Slots = typeof __propDef.slots; -export default class Test2 extends SvelteComponent {} -export {}; +interface $$__sveltets_2_IsomorphicComponent = any, Events extends Record = any, Slots extends Record = any, Exports = {}, Bindings = string> { + new (options: import('svelte').ComponentConstructorOptions): import('svelte').SvelteComponent & { + $$bindings?: Bindings; + } & Exports; + (internal: unknown, props: Props & { + $$events?: Events; + $$slots?: Slots; + }): Exports & { + $set?: any; + $on?: any; + }; + z_$$bindings?: Bindings; +} +declare const Test2: $$__sveltets_2_IsomorphicComponent<{ + foo: Foo; +}, { + [evt: string]: CustomEvent; +}, {}, {}, string>; +type Test2 = InstanceType; +export default Test2; diff --git a/packages/package/test/fixtures/typescript-esnext/src/lib/Plain.svelte b/packages/package/test/fixtures/typescript-esnext/src/lib/Plain.svelte index 1e058c33318f..dea0160a9343 100644 --- a/packages/package/test/fixtures/typescript-esnext/src/lib/Plain.svelte +++ b/packages/package/test/fixtures/typescript-esnext/src/lib/Plain.svelte @@ -6,7 +6,12 @@ diff --git a/packages/package/test/fixtures/typescript-nodenext/expected/Test.svelte b/packages/package/test/fixtures/typescript-nodenext/expected/Test.svelte index 661b1b8276b0..7613c3ebf28b 100644 --- a/packages/package/test/fixtures/typescript-nodenext/expected/Test.svelte +++ b/packages/package/test/fixtures/typescript-nodenext/expected/Test.svelte @@ -1,4 +1,4 @@ -