@sveltejs/kit 2.17.3 → 2.19.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.
@@ -68,24 +68,24 @@ export interface BuildData {
68
68
  out_dir: string;
69
69
  service_worker: string | null;
70
70
  client: {
71
- /** Path to the client entry point */
71
+ /** Path to the client entry point. */
72
72
  start: string;
73
- /** Path to the generated `app.js` file that contains the client manifest. Only set in case of `bundleStrategy === 'split'` */
73
+ /** Path to the generated `app.js` file that contains the client manifest. Only set in case of `bundleStrategy === 'split'`. */
74
74
  app?: string;
75
- /** JS files that the client entry point relies on */
75
+ /** JS files that the client entry point relies on. */
76
76
  imports: string[];
77
77
  /**
78
78
  * JS files that represent the entry points of the layouts/pages.
79
79
  * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file).
80
80
  * Only set in case of `router.resolution === 'server'`.
81
81
  */
82
- nodes?: (string | undefined)[];
82
+ nodes?: Array<string | undefined>;
83
83
  /**
84
84
  * CSS files referenced in the entry points of the layouts/pages.
85
85
  * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file) or if has no CSS.
86
86
  * Only set in case of `router.resolution === 'server'`.
87
87
  */
88
- css?: (string[] | undefined)[];
88
+ css?: Array<string[] | undefined>;
89
89
  /**
90
90
  * Contains the client route manifest in a form suitable for the server which is used for server side route resolution.
91
91
  * Notably, it contains all routes, regardless of whether they are prerendered or not (those are missing in the optimized server route manifest).
@@ -95,7 +95,7 @@ export interface BuildData {
95
95
  stylesheets: string[];
96
96
  fonts: string[];
97
97
  uses_env_dynamic_public: boolean;
98
- /** Only set in case of `bundleStrategy === 'inline'` */
98
+ /** Only set in case of `bundleStrategy === 'inline'`. */
99
99
  inline?: {
100
100
  script: string;
101
101
  style: string | undefined;
@@ -172,7 +172,7 @@ export class InternalServer extends Server {
172
172
  options: RequestOptions & {
173
173
  prerendering?: PrerenderOptions;
174
174
  read: (file: string) => Buffer;
175
- /** A hook called before `handle` during dev, so that `AsyncLocalStorage` can be populated */
175
+ /** A hook called before `handle` during dev, so that `AsyncLocalStorage` can be populated. */
176
176
  before_handle?: (event: RequestEvent, config: any, prerender: PrerenderOption) => void;
177
177
  emulator?: Emulator;
178
178
  }
@@ -180,6 +180,7 @@ export class InternalServer extends Server {
180
180
  }
181
181
 
182
182
  export interface ManifestData {
183
+ /** Static files from `kit.config.files.assets`. */
183
184
  assets: Asset[];
184
185
  hooks: {
185
186
  client: string | null;
@@ -193,15 +194,15 @@ export interface ManifestData {
193
194
 
194
195
  export interface PageNode {
195
196
  depth: number;
196
- /** The +page/layout.svelte */
197
+ /** The `+page/layout.svelte`. */
197
198
  component?: string; // TODO supply default component if it's missing (bit of an edge case)
198
- /** The +page/layout.js/.ts */
199
+ /** The `+page/layout.js/.ts`. */
199
200
  universal?: string;
200
- /** The +page/layout.server.js/ts */
201
+ /** The `+page/layout.server.js/ts`. */
201
202
  server?: string;
202
203
  parent_id?: string;
203
204
  parent?: PageNode;
204
- /** Filled with the pages that reference this layout (if this is a layout) */
205
+ /** Filled with the pages that reference this layout (if this is a layout). */
205
206
  child_pages?: PageNode[];
206
207
  }
207
208
 
@@ -219,6 +220,7 @@ export interface PrerenderOptions {
219
220
  export type RecursiveRequired<T> = {
220
221
  // Recursive implementation of TypeScript's Required utility type.
221
222
  // Will recursively continue until it reaches a primitive or Function
223
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
222
224
  [K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
223
225
  ? RecursiveRequired<T[K]> // recursively continue through.
224
226
  : T[K]; // Use the exact type for everything else
@@ -305,20 +307,20 @@ export interface ServerDataChunkNode {
305
307
 
306
308
  /**
307
309
  * Signals that the server `load` function was not run, and the
308
- * client should use what it has in memory
310
+ * client should use what it has in memory.
309
311
  */
310
312
  export interface ServerDataSkippedNode {
311
313
  type: 'skip';
312
314
  }
313
315
 
314
316
  /**
315
- * Signals that the server `load` function failed
317
+ * Signals that the server `load` function failed.
316
318
  */
317
319
  export interface ServerErrorNode {
318
320
  type: 'error';
319
321
  error: App.Error;
320
322
  /**
321
- * Only set for HttpErrors
323
+ * Only set for HttpErrors.
322
324
  */
323
325
  status?: number;
324
326
  }
@@ -338,7 +340,7 @@ export interface ServerMetadataRoute {
338
340
 
339
341
  export interface ServerMetadata {
340
342
  nodes: Array<{
341
- /** Also `true` when using `trailingSlash`, because we need to do a server request in that case to get its value */
343
+ /** Also `true` when using `trailingSlash`, because we need to do a server request in that case to get its value. */
342
344
  has_server_load: boolean;
343
345
  }>;
344
346
  routes: Map<string, ServerMetadataRoute>;
@@ -362,9 +364,29 @@ export interface SSRComponent {
362
364
 
363
365
  export type SSRComponentLoader = () => Promise<SSRComponent>;
364
366
 
367
+ export interface UniversalNode {
368
+ load?: Load;
369
+ prerender?: PrerenderOption;
370
+ ssr?: boolean;
371
+ csr?: boolean;
372
+ trailingSlash?: TrailingSlash;
373
+ config?: any;
374
+ entries?: PrerenderEntryGenerator;
375
+ }
376
+
377
+ export interface ServerNode {
378
+ load?: ServerLoad;
379
+ prerender?: PrerenderOption;
380
+ ssr?: boolean;
381
+ csr?: boolean;
382
+ trailingSlash?: TrailingSlash;
383
+ actions?: Actions;
384
+ config?: any;
385
+ entries?: PrerenderEntryGenerator;
386
+ }
387
+
365
388
  export interface SSRNode {
366
- component: SSRComponentLoader;
367
- /** index into the `nodes` array in the generated `client/app.js` */
389
+ /** index into the `nodes` array in the generated `client/app.js`. */
368
390
  index: number;
369
391
  /** external JS files that are loaded on the client. `imports[0]` is the entry point (e.g. `client/nodes/0.js`) */
370
392
  imports: string[];
@@ -372,32 +394,18 @@ export interface SSRNode {
372
394
  stylesheets: string[];
373
395
  /** external font files that are loaded on the client */
374
396
  fonts: string[];
375
- /** inlined styles */
376
- inline_styles?(): MaybePromise<Record<string, string>>;
377
397
 
378
- universal: {
379
- load?: Load;
380
- prerender?: PrerenderOption;
381
- ssr?: boolean;
382
- csr?: boolean;
383
- trailingSlash?: TrailingSlash;
384
- config?: any;
385
- entries?: PrerenderEntryGenerator;
386
- };
398
+ universal_id?: string;
399
+ server_id?: string;
387
400
 
388
- server: {
389
- load?: ServerLoad;
390
- prerender?: PrerenderOption;
391
- ssr?: boolean;
392
- csr?: boolean;
393
- trailingSlash?: TrailingSlash;
394
- actions?: Actions;
395
- config?: any;
396
- entries?: PrerenderEntryGenerator;
397
- };
398
-
399
- universal_id: string;
400
- server_id: string;
401
+ /** inlined styles. */
402
+ inline_styles?(): MaybePromise<Record<string, string>>;
403
+ /** Svelte component */
404
+ component?: SSRComponentLoader;
405
+ /** +page.js or +layout.js */
406
+ universal?: UniversalNode;
407
+ /** +page.server.js, +layout.server.js, or +server.js */
408
+ server?: ServerNode;
401
409
  }
402
410
 
403
411
  export type SSRNodeLoader = () => Promise<SSRNode>;
@@ -465,21 +473,25 @@ export interface SSRState {
465
473
  fallback?: string;
466
474
  getClientAddress(): string;
467
475
  /**
468
- * True if we're currently attempting to render an error page
476
+ * True if we're currently attempting to render an error page.
469
477
  */
470
478
  error: boolean;
471
479
  /**
472
- * Allows us to prevent `event.fetch` from making infinitely looping internal requests
480
+ * Allows us to prevent `event.fetch` from making infinitely looping internal requests.
473
481
  */
474
482
  depth: number;
475
483
  platform?: any;
476
484
  prerendering?: PrerenderOptions;
477
485
  /**
478
486
  * When fetching data from a +server.js endpoint in `load`, the page's
479
- * prerender option is inherited by the endpoint, unless overridden
487
+ * prerender option is inherited by the endpoint, unless overridden.
480
488
  */
481
489
  prerender_default?: PrerenderOption;
482
490
  read?: (file: string) => Buffer;
491
+ /**
492
+ * Used to setup `__SVELTEKIT_TRACK__` which checks if a used feature is supported.
493
+ * E.g. if `read` from `$app/server` is used, it checks whether the route's config is compatible.
494
+ */
483
495
  before_handle?: (event: RequestEvent, config: any, prerender: PrerenderOption) => void;
484
496
  emulator?: Emulator;
485
497
  }
@@ -0,0 +1,95 @@
1
+ import {
2
+ validate_layout_exports,
3
+ validate_layout_server_exports,
4
+ validate_page_exports,
5
+ validate_page_server_exports
6
+ } from './exports.js';
7
+
8
+ export class PageNodes {
9
+ data;
10
+
11
+ /**
12
+ * @param {Array<import('types').SSRNode | undefined>} nodes
13
+ */
14
+ constructor(nodes) {
15
+ this.data = nodes;
16
+ }
17
+
18
+ layouts() {
19
+ return this.data.slice(0, -1);
20
+ }
21
+
22
+ page() {
23
+ return this.data.at(-1);
24
+ }
25
+
26
+ validate() {
27
+ for (const layout of this.layouts()) {
28
+ if (layout) {
29
+ validate_layout_server_exports(layout.server, /** @type {string} */ (layout.server_id));
30
+ validate_layout_exports(layout.universal, /** @type {string} */ (layout.universal_id));
31
+ }
32
+ }
33
+
34
+ const page = this.page();
35
+ if (page) {
36
+ validate_page_server_exports(page.server, /** @type {string} */ (page.server_id));
37
+ validate_page_exports(page.universal, /** @type {string} */ (page.universal_id));
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash' | 'entries'} Option
43
+ * @template {(import('types').UniversalNode | import('types').ServerNode)[Option]} Value
44
+ * @param {Option} option
45
+ * @returns {Value | undefined}
46
+ */
47
+ #get_option(option) {
48
+ return this.data.reduce((value, node) => {
49
+ return /** @type {Value} TypeScript's too dumb to understand this */ (
50
+ node?.universal?.[option] ?? node?.server?.[option] ?? value
51
+ );
52
+ }, /** @type {Value | undefined} */ (undefined));
53
+ }
54
+
55
+ csr() {
56
+ return this.#get_option('csr') ?? true;
57
+ }
58
+
59
+ ssr() {
60
+ return this.#get_option('ssr') ?? true;
61
+ }
62
+
63
+ prerender() {
64
+ return this.#get_option('prerender') ?? false;
65
+ }
66
+
67
+ trailing_slash() {
68
+ return this.#get_option('trailingSlash') ?? 'never';
69
+ }
70
+
71
+ get_config() {
72
+ /** @type {any} */
73
+ let current = {};
74
+
75
+ for (const node of this.data) {
76
+ if (!node?.universal?.config && !node?.server?.config) continue;
77
+
78
+ current = {
79
+ ...current,
80
+ ...node?.universal?.config,
81
+ ...node?.server?.config
82
+ };
83
+ }
84
+
85
+ // TODO 3.0 always return `current`? then we can get rid of `?? {}` in other places
86
+ return Object.keys(current).length ? current : undefined;
87
+ }
88
+
89
+ should_prerender_data() {
90
+ return this.data.some(
91
+ // prerender in case of trailingSlash because the client retrieves that value from the server
92
+ (node) => node?.server?.load || node?.server?.trailingSlash !== undefined
93
+ );
94
+ }
95
+ }
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // generated during release, do not modify
2
2
 
3
3
  /** @type {string} */
4
- export const VERSION = '2.17.3';
4
+ export const VERSION = '2.19.0';
package/types/index.d.ts CHANGED
@@ -796,7 +796,7 @@ declare module '@sveltejs/kit' {
796
796
  * The [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook allows you to modify the URL before it is used to determine which route to render.
797
797
  * @since 2.3.0
798
798
  */
799
- export type Reroute = (event: { url: URL }) => void | string;
799
+ export type Reroute = (event: { url: URL; fetch: typeof fetch }) => MaybePromise<void | string>;
800
800
 
801
801
  /**
802
802
  * The [`transport`](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport) hook allows you to transport custom types across the server/client boundary.
@@ -1159,7 +1159,7 @@ declare module '@sveltejs/kit' {
1159
1159
  * - During server-side rendering, the response will be captured and inlined into the rendered HTML by hooking into the `text` and `json` methods of the `Response` object. Note that headers will _not_ be serialized, unless explicitly included via [`filterSerializedResponseHeaders`](https://svelte.dev/docs/kit/hooks#Server-hooks-handle)
1160
1160
  * - During hydration, the response will be read from the HTML, guaranteeing consistency and preventing an additional network request.
1161
1161
  *
1162
- * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies)
1162
+ * You can learn more about making credentialed requests with cookies [here](https://svelte.dev/docs/kit/load#Cookies).
1163
1163
  */
1164
1164
  fetch: typeof fetch;
1165
1165
  /**
@@ -1171,7 +1171,7 @@ declare module '@sveltejs/kit' {
1171
1171
  */
1172
1172
  locals: App.Locals;
1173
1173
  /**
1174
- * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object
1174
+ * The parameters of the current route - e.g. for a route like `/blog/[slug]`, a `{ slug: string }` object.
1175
1175
  */
1176
1176
  params: Params;
1177
1177
  /**
@@ -1179,15 +1179,15 @@ declare module '@sveltejs/kit' {
1179
1179
  */
1180
1180
  platform: Readonly<App.Platform> | undefined;
1181
1181
  /**
1182
- * The original request object
1182
+ * The original request object.
1183
1183
  */
1184
1184
  request: Request;
1185
1185
  /**
1186
- * Info about the current route
1186
+ * Info about the current route.
1187
1187
  */
1188
1188
  route: {
1189
1189
  /**
1190
- * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`
1190
+ * The ID of the current route - e.g. for `src/routes/blog/[slug]`, it would be `/blog/[slug]`.
1191
1191
  */
1192
1192
  id: RouteId;
1193
1193
  };
@@ -1284,15 +1284,16 @@ declare module '@sveltejs/kit' {
1284
1284
  }
1285
1285
 
1286
1286
  export interface ServerInitOptions {
1287
- /** A map of environment variables */
1287
+ /** A map of environment variables. */
1288
1288
  env: Record<string, string>;
1289
- /** A function that turns an asset filename into a `ReadableStream`. Required for the `read` export from `$app/server` to work */
1289
+ /** A function that turns an asset filename into a `ReadableStream`. Required for the `read` export from `$app/server` to work. */
1290
1290
  read?: (file: string) => ReadableStream;
1291
1291
  }
1292
1292
 
1293
1293
  export interface SSRManifest {
1294
1294
  appDir: string;
1295
1295
  appPath: string;
1296
+ /** Static files from `kit.config.files.assets` and the service worker (if any). */
1296
1297
  assets: Set<string>;
1297
1298
  mimeTypes: Record<string, string>;
1298
1299
 
@@ -1303,7 +1304,7 @@ declare module '@sveltejs/kit' {
1303
1304
  routes: SSRRoute[];
1304
1305
  prerendered_routes: Set<string>;
1305
1306
  matchers: () => Promise<Record<string, ParamMatcher>>;
1306
- /** A `[file]: size` map of all assets imported by server code */
1307
+ /** A `[file]: size` map of all assets imported by server code. */
1307
1308
  server_assets: Record<string, number>;
1308
1309
  };
1309
1310
  }
@@ -1434,7 +1435,7 @@ declare module '@sveltejs/kit' {
1434
1435
  }
1435
1436
 
1436
1437
  /**
1437
- * The object returned by the [`redirect`](https://svelte.dev/docs/kit/@sveltejs-kit#redirect) function
1438
+ * The object returned by the [`redirect`](https://svelte.dev/docs/kit/@sveltejs-kit#redirect) function.
1438
1439
  */
1439
1440
  export interface Redirect {
1440
1441
  /** The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages), in the range 300-308. */
@@ -1715,24 +1716,24 @@ declare module '@sveltejs/kit' {
1715
1716
  out_dir: string;
1716
1717
  service_worker: string | null;
1717
1718
  client: {
1718
- /** Path to the client entry point */
1719
+ /** Path to the client entry point. */
1719
1720
  start: string;
1720
- /** Path to the generated `app.js` file that contains the client manifest. Only set in case of `bundleStrategy === 'split'` */
1721
+ /** Path to the generated `app.js` file that contains the client manifest. Only set in case of `bundleStrategy === 'split'`. */
1721
1722
  app?: string;
1722
- /** JS files that the client entry point relies on */
1723
+ /** JS files that the client entry point relies on. */
1723
1724
  imports: string[];
1724
1725
  /**
1725
1726
  * JS files that represent the entry points of the layouts/pages.
1726
1727
  * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file).
1727
1728
  * Only set in case of `router.resolution === 'server'`.
1728
1729
  */
1729
- nodes?: (string | undefined)[];
1730
+ nodes?: Array<string | undefined>;
1730
1731
  /**
1731
1732
  * CSS files referenced in the entry points of the layouts/pages.
1732
1733
  * An entry is undefined if the layout/page has no component or universal file (i.e. only has a `.server.js` file) or if has no CSS.
1733
1734
  * Only set in case of `router.resolution === 'server'`.
1734
1735
  */
1735
- css?: (string[] | undefined)[];
1736
+ css?: Array<string[] | undefined>;
1736
1737
  /**
1737
1738
  * Contains the client route manifest in a form suitable for the server which is used for server side route resolution.
1738
1739
  * Notably, it contains all routes, regardless of whether they are prerendered or not (those are missing in the optimized server route manifest).
@@ -1742,7 +1743,7 @@ declare module '@sveltejs/kit' {
1742
1743
  stylesheets: string[];
1743
1744
  fonts: string[];
1744
1745
  uses_env_dynamic_public: boolean;
1745
- /** Only set in case of `bundleStrategy === 'inline'` */
1746
+ /** Only set in case of `bundleStrategy === 'inline'`. */
1746
1747
  inline?: {
1747
1748
  script: string;
1748
1749
  style: string | undefined;
@@ -1752,6 +1753,7 @@ declare module '@sveltejs/kit' {
1752
1753
  }
1753
1754
 
1754
1755
  interface ManifestData {
1756
+ /** Static files from `kit.config.files.assets`. */
1755
1757
  assets: Asset[];
1756
1758
  hooks: {
1757
1759
  client: string | null;
@@ -1765,21 +1767,22 @@ declare module '@sveltejs/kit' {
1765
1767
 
1766
1768
  interface PageNode {
1767
1769
  depth: number;
1768
- /** The +page/layout.svelte */
1770
+ /** The `+page/layout.svelte`. */
1769
1771
  component?: string; // TODO supply default component if it's missing (bit of an edge case)
1770
- /** The +page/layout.js/.ts */
1772
+ /** The `+page/layout.js/.ts`. */
1771
1773
  universal?: string;
1772
- /** The +page/layout.server.js/ts */
1774
+ /** The `+page/layout.server.js/ts`. */
1773
1775
  server?: string;
1774
1776
  parent_id?: string;
1775
1777
  parent?: PageNode;
1776
- /** Filled with the pages that reference this layout (if this is a layout) */
1778
+ /** Filled with the pages that reference this layout (if this is a layout). */
1777
1779
  child_pages?: PageNode[];
1778
1780
  }
1779
1781
 
1780
1782
  type RecursiveRequired<T> = {
1781
1783
  // Recursive implementation of TypeScript's Required utility type.
1782
1784
  // Will recursively continue until it reaches a primitive or Function
1785
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1783
1786
  [K in keyof T]-?: Extract<T[K], Function> extends never // If it does not have a Function type
1784
1787
  ? RecursiveRequired<T[K]> // recursively continue through.
1785
1788
  : T[K]; // Use the exact type for everything else
@@ -1839,9 +1842,29 @@ declare module '@sveltejs/kit' {
1839
1842
 
1840
1843
  type SSRComponentLoader = () => Promise<SSRComponent>;
1841
1844
 
1845
+ interface UniversalNode {
1846
+ load?: Load;
1847
+ prerender?: PrerenderOption;
1848
+ ssr?: boolean;
1849
+ csr?: boolean;
1850
+ trailingSlash?: TrailingSlash;
1851
+ config?: any;
1852
+ entries?: PrerenderEntryGenerator;
1853
+ }
1854
+
1855
+ interface ServerNode {
1856
+ load?: ServerLoad;
1857
+ prerender?: PrerenderOption;
1858
+ ssr?: boolean;
1859
+ csr?: boolean;
1860
+ trailingSlash?: TrailingSlash;
1861
+ actions?: Actions;
1862
+ config?: any;
1863
+ entries?: PrerenderEntryGenerator;
1864
+ }
1865
+
1842
1866
  interface SSRNode {
1843
- component: SSRComponentLoader;
1844
- /** index into the `nodes` array in the generated `client/app.js` */
1867
+ /** index into the `nodes` array in the generated `client/app.js`. */
1845
1868
  index: number;
1846
1869
  /** external JS files that are loaded on the client. `imports[0]` is the entry point (e.g. `client/nodes/0.js`) */
1847
1870
  imports: string[];
@@ -1849,32 +1872,18 @@ declare module '@sveltejs/kit' {
1849
1872
  stylesheets: string[];
1850
1873
  /** external font files that are loaded on the client */
1851
1874
  fonts: string[];
1852
- /** inlined styles */
1853
- inline_styles?(): MaybePromise<Record<string, string>>;
1854
1875
 
1855
- universal: {
1856
- load?: Load;
1857
- prerender?: PrerenderOption;
1858
- ssr?: boolean;
1859
- csr?: boolean;
1860
- trailingSlash?: TrailingSlash;
1861
- config?: any;
1862
- entries?: PrerenderEntryGenerator;
1863
- };
1876
+ universal_id?: string;
1877
+ server_id?: string;
1864
1878
 
1865
- server: {
1866
- load?: ServerLoad;
1867
- prerender?: PrerenderOption;
1868
- ssr?: boolean;
1869
- csr?: boolean;
1870
- trailingSlash?: TrailingSlash;
1871
- actions?: Actions;
1872
- config?: any;
1873
- entries?: PrerenderEntryGenerator;
1874
- };
1875
-
1876
- universal_id: string;
1877
- server_id: string;
1879
+ /** inlined styles. */
1880
+ inline_styles?(): MaybePromise<Record<string, string>>;
1881
+ /** Svelte component */
1882
+ component?: SSRComponentLoader;
1883
+ /** +page.js or +layout.js */
1884
+ universal?: UniversalNode;
1885
+ /** +page.server.js, +layout.server.js, or +server.js */
1886
+ server?: ServerNode;
1878
1887
  }
1879
1888
 
1880
1889
  type SSRNodeLoader = () => Promise<SSRNode>;
@@ -2002,6 +2011,24 @@ declare module '@sveltejs/kit' {
2002
2011
  * @param e The object to check.
2003
2012
  * */
2004
2013
  export function isActionFailure(e: unknown): e is ActionFailure;
2014
+ /**
2015
+ * Strips possible SvelteKit-internal suffixes and trailing slashes from the URL pathname.
2016
+ * Returns the normalized URL as well as a method for adding the potential suffix back
2017
+ * based on a new pathname (possibly including search) or URL.
2018
+ * ```js
2019
+ * import { normalizeUrl } from '@sveltejs/kit';
2020
+ *
2021
+ * const { url, denormalize } = normalizeUrl('/blog/post/__data.json');
2022
+ * console.log(url.pathname); // /blog/post
2023
+ * console.log(denormalize('/blog/post/a')); // /blog/post/a/__data.json
2024
+ * ```
2025
+ * @since 2.18.0
2026
+ */
2027
+ export function normalizeUrl(url: URL | string): {
2028
+ url: URL;
2029
+ wasNormalized: boolean;
2030
+ denormalize: (url?: string | URL) => URL;
2031
+ };
2005
2032
  export type LessThan<TNumber extends number, TArray extends any[] = []> = TNumber extends TArray["length"] ? TArray[number] : LessThan<TNumber, [...TArray, TArray["length"]]>;
2006
2033
  export type NumericRange<TStart extends number, TEnd extends number> = Exclude<TEnd | LessThan<TEnd>, LessThan<TStart>>;
2007
2034
  export const VERSION: string;
@@ -73,6 +73,8 @@
73
73
  "RouteData",
74
74
  "SSRComponent",
75
75
  "SSRComponentLoader",
76
+ "UniversalNode",
77
+ "ServerNode",
76
78
  "SSRNode",
77
79
  "SSRNodeLoader",
78
80
  "PageNodeIndexes",
@@ -88,6 +90,7 @@
88
90
  "json",
89
91
  "text",
90
92
  "isActionFailure",
93
+ "normalizeUrl",
91
94
  "VERSION",
92
95
  "sequence",
93
96
  "getRequest",
@@ -160,6 +163,6 @@
160
163
  null,
161
164
  null
162
165
  ],
163
- "mappings": ";;;;;;;;;kBA2BiBA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;aA2BZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;;;;;;;;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;;iBCoCFC,UAAUA;;;;;;iBAkCVC,WAAWA;;;;;iBAgFjBC,oBAAoBA;;;;;;;;;;;iBC3MpBC,gBAAgBA;;;;;;;;;iBCgHVC,SAASA;;;;;;;;;cC/HlBC,OAAOA;;;;;cAKPC,GAAGA;;;;;cAKHC,QAAQA;;;;;cAKRC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;iBCWJC,WAAWA;;;;;;;;;;;;;;;;;;;;;;;;iBA8CXC,OAAOA;;;;;;;iBCiiEDC,WAAWA;;;;;;;;;;;iBA/TjBC,aAAaA;;;;;;;;;;;;iBAiBbC,cAAcA;;;;;;;;;;iBAedC,UAAUA;;;;;iBASVC,qBAAqBA;;;;;;;;;;iBA8BrBC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCJC,UAAUA;;;;iBA0BVC,aAAaA;;;;;;;;;;;;iBAqBPC,WAAWA;;;;;;;;;;;;;;;;;;iBAoCXC,WAAWA;;;;;iBAsCjBC,SAASA;;;;;iBA+CTC,YAAYA;MVv6DhB/D,YAAYA;;;;;;;;;;;YWtJbgE,IAAIA;;;;;;;YAOJC,MAAMA;;;;;;;;;;;;;;;;;iBAiBDC,YAAYA;;;;;;;;;;;;;;;;;;iBCVZC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cC8BPC,IAAIA;;;;;cAQJC,UAAUA;;;;;;;;;;;cAMVC,OAAOA;;;;;;;;;iBCrDPC,SAASA;;;;;;;;;;;;;;;cAyBTH,IAAIA;;;;;;;;;;cAiBJC,UAAUA;;;;;;;;cAeVC,OAAOA",
164
167
  "ignoreList": []
165
168
  }
@@ -1,11 +0,0 @@
1
- /**
2
- * @param {import('types').PageNodeIndexes} page
3
- * @param {import('@sveltejs/kit').SSRManifest} manifest
4
- */
5
- export function load_page_nodes(page, manifest) {
6
- return Promise.all([
7
- // we use == here rather than === because [undefined] serializes as "[null]"
8
- ...page.layouts.map((n) => (n == undefined ? n : manifest._.nodes[n]())),
9
- manifest._.nodes[page.leaf]()
10
- ]);
11
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash' | 'entries'} Option
3
- * @template {(import('types').SSRNode['universal'] | import('types').SSRNode['server'])[Option]} Value
4
- *
5
- * @param {Array<import('types').SSRNode | undefined>} nodes
6
- * @param {Option} option
7
- *
8
- * @returns {Value | undefined}
9
- */
10
- export function get_option(nodes, option) {
11
- return nodes.reduce((value, node) => {
12
- return /** @type {Value} TypeScript's too dumb to understand this */ (
13
- node?.universal?.[option] ?? node?.server?.[option] ?? value
14
- );
15
- }, /** @type {Value | undefined} */ (undefined));
16
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Do a shallow merge (first level) of the config object
3
- * @param {Array<import('types').SSRNode | undefined>} nodes
4
- */
5
- export function get_page_config(nodes) {
6
- /** @type {any} */
7
- let current = {};
8
-
9
- for (const node of nodes) {
10
- if (!node?.universal?.config && !node?.server?.config) continue;
11
-
12
- current = {
13
- ...current,
14
- ...node?.universal?.config,
15
- ...node?.server?.config
16
- };
17
- }
18
-
19
- // TODO 3.0 always return `current`? then we can get rid of `?? {}` in other places
20
- return Object.keys(current).length ? current : undefined;
21
- }