@sveltejs/kit 2.28.0 → 2.29.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "2.28.0",
3
+ "version": "2.29.0",
4
4
  "description": "SvelteKit is the fastest way to build Svelte apps",
5
5
  "keywords": [
6
6
  "framework",
@@ -126,6 +126,17 @@ export function validate_config(config) {
126
126
  }
127
127
 
128
128
  const validated = options(config, 'config');
129
+ const files = validated.kit.files;
130
+
131
+ files.hooks.client ??= path.join(files.src, 'hooks.client');
132
+ files.hooks.server ??= path.join(files.src, 'hooks.server');
133
+ files.hooks.universal ??= path.join(files.src, 'hooks');
134
+ files.lib ??= path.join(files.src, 'lib');
135
+ files.params ??= path.join(files.src, 'params');
136
+ files.routes ??= path.join(files.src, 'routes');
137
+ files.serviceWorker ??= path.join(files.src, 'service-worker');
138
+ files.appTemplate ??= path.join(files.src, 'app.html');
139
+ files.errorTemplate ??= path.join(files.src, 'error.html');
129
140
 
130
141
  if (validated.kit.router.resolution === 'server') {
131
142
  if (validated.kit.router.type === 'hash') {
@@ -1,4 +1,3 @@
1
- import { join } from 'node:path';
2
1
  import process from 'node:process';
3
2
 
4
3
  /** @typedef {import('./types.js').Validator} Validator */
@@ -125,18 +124,19 @@ const options = object(
125
124
  }),
126
125
 
127
126
  files: object({
128
- assets: string('static'),
127
+ src: deprecate(string('src')),
128
+ assets: deprecate(string('static')),
129
129
  hooks: object({
130
- client: string(join('src', 'hooks.client')),
131
- server: string(join('src', 'hooks.server')),
132
- universal: string(join('src', 'hooks'))
130
+ client: deprecate(string(null)),
131
+ server: deprecate(string(null)),
132
+ universal: deprecate(string(null))
133
133
  }),
134
- lib: string(join('src', 'lib')),
135
- params: string(join('src', 'params')),
136
- routes: string(join('src', 'routes')),
137
- serviceWorker: string(join('src', 'service-worker')),
138
- appTemplate: string(join('src', 'app.html')),
139
- errorTemplate: string(join('src', 'error.html'))
134
+ lib: deprecate(string(null)),
135
+ params: deprecate(string(null)),
136
+ routes: deprecate(string(null)),
137
+ serviceWorker: deprecate(string(null)),
138
+ appTemplate: deprecate(string(null)),
139
+ errorTemplate: deprecate(string(null))
140
140
  }),
141
141
 
142
142
  inlineStyleThreshold: number(0),
@@ -287,6 +287,25 @@ const options = object(
287
287
  true
288
288
  );
289
289
 
290
+ /**
291
+ * @param {Validator} fn
292
+ * @param {(keypath: string) => string} get_message
293
+ * @returns {Validator}
294
+ */
295
+ function deprecate(
296
+ fn,
297
+ get_message = (keypath) =>
298
+ `The \`${keypath}\` option is deprecated, and will be removed in a future version`
299
+ ) {
300
+ return (input, keypath) => {
301
+ if (input !== undefined) {
302
+ console.warn(get_message(keypath));
303
+ }
304
+
305
+ return fn(input, keypath);
306
+ };
307
+ }
308
+
290
309
  /**
291
310
  * @param {Record<string, Validator>} children
292
311
  * @param {boolean} [allow_unknown]
@@ -420,26 +420,38 @@ export interface KitConfig {
420
420
  };
421
421
  /**
422
422
  * Where to find various files within your project.
423
+ * @deprecated
423
424
  */
424
425
  files?: {
426
+ /**
427
+ * the location of your source code
428
+ * @deprecated
429
+ * @default "src"
430
+ * @since 2.28
431
+ */
432
+ src?: string;
425
433
  /**
426
434
  * a place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`
435
+ * @deprecated
427
436
  * @default "static"
428
437
  */
429
438
  assets?: string;
430
439
  hooks?: {
431
440
  /**
432
441
  * The location of your client [hooks](https://svelte.dev/docs/kit/hooks).
442
+ * @deprecated
433
443
  * @default "src/hooks.client"
434
444
  */
435
445
  client?: string;
436
446
  /**
437
447
  * The location of your server [hooks](https://svelte.dev/docs/kit/hooks).
448
+ * @deprecated
438
449
  * @default "src/hooks.server"
439
450
  */
440
451
  server?: string;
441
452
  /**
442
453
  * The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).
454
+ * @deprecated
443
455
  * @default "src/hooks"
444
456
  * @since 2.3.0
445
457
  */
@@ -447,31 +459,37 @@ export interface KitConfig {
447
459
  };
448
460
  /**
449
461
  * your app's internal library, accessible throughout the codebase as `$lib`
462
+ * @deprecated
450
463
  * @default "src/lib"
451
464
  */
452
465
  lib?: string;
453
466
  /**
454
467
  * a directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching)
468
+ * @deprecated
455
469
  * @default "src/params"
456
470
  */
457
471
  params?: string;
458
472
  /**
459
473
  * the files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing))
474
+ * @deprecated
460
475
  * @default "src/routes"
461
476
  */
462
477
  routes?: string;
463
478
  /**
464
479
  * the location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers))
480
+ * @deprecated
465
481
  * @default "src/service-worker"
466
482
  */
467
483
  serviceWorker?: string;
468
484
  /**
469
485
  * the location of the template for HTML responses
486
+ * @deprecated
470
487
  * @default "src/app.html"
471
488
  */
472
489
  appTemplate?: string;
473
490
  /**
474
491
  * the location of the template for fallback error responses
492
+ * @deprecated
475
493
  * @default "src/error.html"
476
494
  */
477
495
  errorTemplate?: string;
@@ -1046,8 +1064,8 @@ export interface NavigationTarget<
1046
1064
 
1047
1065
  /**
1048
1066
  * - `enter`: The app has hydrated/started
1049
- * - `form`: The user submitted a `<form>` with a GET method
1050
- * - `leave`: The user is leaving the app by closing the tab or using the back/forward buttons to go to a different document
1067
+ * - `form`: The user submitted a `<form method="GET">`
1068
+ * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1051
1069
  * - `link`: Navigation was triggered by a link click
1052
1070
  * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1053
1071
  * - `popstate`: Navigation was triggered by back/forward navigation
@@ -1065,7 +1083,7 @@ export interface Navigation {
1065
1083
  to: NavigationTarget | null;
1066
1084
  /**
1067
1085
  * The type of navigation:
1068
- * - `form`: The user submitted a `<form>`
1086
+ * - `form`: The user submitted a `<form method="GET">`
1069
1087
  * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1070
1088
  * - `link`: Navigation was triggered by a link click
1071
1089
  * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
@@ -1103,7 +1121,7 @@ export interface BeforeNavigate extends Navigation {
1103
1121
  export interface OnNavigate extends Navigation {
1104
1122
  /**
1105
1123
  * The type of navigation:
1106
- * - `form`: The user submitted a `<form>`
1124
+ * - `form`: The user submitted a `<form method="GET">`
1107
1125
  * - `link`: Navigation was triggered by a link click
1108
1126
  * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1109
1127
  * - `popstate`: Navigation was triggered by back/forward navigation
@@ -1122,7 +1140,7 @@ export interface AfterNavigate extends Omit<Navigation, 'type'> {
1122
1140
  /**
1123
1141
  * The type of navigation:
1124
1142
  * - `enter`: The app has hydrated/started
1125
- * - `form`: The user submitted a `<form>`
1143
+ * - `form`: The user submitted a `<form method="GET">`
1126
1144
  * - `link`: Navigation was triggered by a link click
1127
1145
  * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1128
1146
  * - `popstate`: Navigation was triggered by back/forward navigation
@@ -15,9 +15,8 @@ import { build_server_nodes } from './build/build_server.js';
15
15
  import { build_service_worker } from './build/build_service_worker.js';
16
16
  import { assets_base, find_deps, resolve_symlinks } from './build/utils.js';
17
17
  import { dev } from './dev/index.js';
18
- import { is_illegal, module_guard } from './graph_analysis/index.js';
19
18
  import { preview } from './preview/index.js';
20
- import { get_config_aliases, get_env, normalize_id, strip_virtual_prefix } from './utils.js';
19
+ import { get_config_aliases, get_env, normalize_id, stackless } from './utils.js';
21
20
  import { write_client_manifest } from '../../core/sync/write_client_manifest.js';
22
21
  import prerender from '../../core/postbuild/prerender.js';
23
22
  import analyse from '../../core/postbuild/analyse.js';
@@ -37,6 +36,7 @@ import {
37
36
  import { import_peer } from '../../utils/import.js';
38
37
  import { compact } from '../../utils/array.js';
39
38
  import { build_remotes, treeshake_prerendered_remotes } from './build/build_remote.js';
39
+ import { should_ignore } from './static_analysis/utils.js';
40
40
 
41
41
  const cwd = process.cwd();
42
42
 
@@ -90,7 +90,7 @@ const warning_preprocessor = {
90
90
  const basename = path.basename(filename);
91
91
  if (basename.startsWith('+page.') || basename.startsWith('+layout.')) {
92
92
  const match = content.match(options_regex);
93
- if (match) {
93
+ if (match && match.index !== undefined && !should_ignore(content, match.index)) {
94
94
  const fixed = basename.replace('.svelte', '(.server).js/ts');
95
95
 
96
96
  const message =
@@ -219,6 +219,7 @@ async function kit({ svelte_config }) {
219
219
 
220
220
  const normalized_cwd = vite.normalizePath(cwd);
221
221
  const normalized_lib = vite.normalizePath(kit.files.lib);
222
+ const normalized_node_modules = vite.normalizePath(path.resolve('node_modules'));
222
223
 
223
224
  /**
224
225
  * A map showing which features (such as `$app/server:read`) are defined
@@ -374,9 +375,6 @@ async function kit({ svelte_config }) {
374
375
  }
375
376
  };
376
377
 
377
- /** @type {Map<string, string>} */
378
- const import_map = new Map();
379
-
380
378
  /** @type {import('vite').Plugin} */
381
379
  const plugin_virtual_modules = {
382
380
  name: 'vite-plugin-sveltekit-virtual-modules',
@@ -389,6 +387,7 @@ async function kit({ svelte_config }) {
389
387
  // If importing from a service-worker, only allow $service-worker & $env/static/public, but none of the other virtual modules.
390
388
  // This check won't catch transitive imports, but it will warn when the import comes from a service-worker directly.
391
389
  // Transitive imports will be caught during the build.
390
+ // TODO move this logic to plugin_guard
392
391
  if (importer) {
393
392
  const parsed_importer = path.parse(importer);
394
393
 
@@ -405,8 +404,6 @@ async function kit({ svelte_config }) {
405
404
  )} into service-worker code. Only the modules $service-worker and $env/static/public are available in service workers.`
406
405
  );
407
406
  }
408
-
409
- import_map.set(id, importer);
410
407
  }
411
408
 
412
409
  // treat $env/static/[public|private] as virtual
@@ -414,9 +411,11 @@ async function kit({ svelte_config }) {
414
411
  // ids with :$ don't work with reverse proxies like nginx
415
412
  return `\0virtual:${id.substring(1)}`;
416
413
  }
414
+
417
415
  if (id === '__sveltekit/remote') {
418
416
  return `${runtime_directory}/client/remote-functions/index.js`;
419
417
  }
418
+
420
419
  if (id.startsWith('__sveltekit/')) {
421
420
  return `\0virtual:${id}`;
422
421
  }
@@ -429,37 +428,6 @@ async function kit({ svelte_config }) {
429
428
  ? `globalThis.__sveltekit_${version_hash}`
430
429
  : 'globalThis.__sveltekit_dev';
431
430
 
432
- if (options?.ssr === false && process.env.TEST !== 'true') {
433
- if (
434
- is_illegal(id, {
435
- cwd: normalized_cwd,
436
- node_modules: vite.normalizePath(path.resolve('node_modules')),
437
- server: vite.normalizePath(path.join(normalized_lib, 'server'))
438
- })
439
- ) {
440
- const relative = normalize_id(id, normalized_lib, normalized_cwd);
441
-
442
- const illegal_module = strip_virtual_prefix(relative);
443
-
444
- const error_prefix = `Cannot import ${illegal_module} into client-side code. This could leak sensitive information.`;
445
- const error_suffix = `
446
- Tips:
447
- - To resolve this error, ensure that no exports from ${illegal_module} are used, even transitively, in client-side code.
448
- - If you're only using the import as a type, change it to \`import type\`.
449
- - If you're not sure which module is causing this, try building your app -- it will create a more helpful error.`;
450
-
451
- if (import_map.has(illegal_module)) {
452
- const importer = path.relative(
453
- cwd,
454
- /** @type {string} */ (import_map.get(illegal_module))
455
- );
456
- throw new Error(`${error_prefix}\nImported by: ${importer}.${error_suffix}`);
457
- }
458
-
459
- throw new Error(`${error_prefix}${error_suffix}`);
460
- }
461
- }
462
-
463
431
  switch (id) {
464
432
  case env_static_private:
465
433
  return create_static_module('$env/static/private', env.private);
@@ -566,6 +534,10 @@ Tips:
566
534
  }
567
535
  };
568
536
 
537
+ /** @type {Map<string, Set<string>>} */
538
+ const import_map = new Map();
539
+ const server_only_pattern = /.*\.server\..+/;
540
+
569
541
  /**
570
542
  * Ensures that client-side code can't accidentally import server-side code,
571
543
  * whether in `*.server.js` files, `$app/server`, `$lib/server`, or `$env/[static|dynamic]/private`
@@ -574,23 +546,89 @@ Tips:
574
546
  const plugin_guard = {
575
547
  name: 'vite-plugin-sveltekit-guard',
576
548
 
577
- writeBundle: {
578
- sequential: true,
579
- handler(_options) {
580
- if (vite_config.build.ssr) return;
549
+ // Run this plugin before built-in resolution, so that relative imports
550
+ // are added to the module graph
551
+ enforce: 'pre',
581
552
 
582
- const guard = module_guard(this, {
583
- cwd: vite.normalizePath(process.cwd()),
584
- lib: vite.normalizePath(kit.files.lib)
585
- });
553
+ async resolveId(id, importer) {
554
+ if (importer && !importer.endsWith('index.html')) {
555
+ const resolved = await this.resolve(id, importer, { skipSelf: true });
586
556
 
587
- manifest_data.nodes.forEach((_node, i) => {
588
- const id = vite.normalizePath(
589
- path.resolve(kit.outDir, `generated/client-optimized/nodes/${i}.js`)
590
- );
557
+ if (resolved) {
558
+ const normalized = normalize_id(resolved.id, normalized_lib, normalized_cwd);
591
559
 
592
- guard.check(id);
593
- });
560
+ let importers = import_map.get(normalized);
561
+
562
+ if (!importers) {
563
+ importers = new Set();
564
+ import_map.set(normalized, importers);
565
+ }
566
+
567
+ importers.add(normalize_id(importer, normalized_lib, normalized_cwd));
568
+ }
569
+ }
570
+ },
571
+
572
+ load(id, options) {
573
+ if (options?.ssr === true || process.env.TEST === 'true') {
574
+ return;
575
+ }
576
+
577
+ // skip .server.js files outside the cwd or in node_modules, as the filename might not mean 'server-only module' in this context
578
+ const is_internal = id.startsWith(normalized_cwd) && !id.startsWith(normalized_node_modules);
579
+
580
+ const normalized = normalize_id(id, normalized_lib, normalized_cwd);
581
+
582
+ const is_server_only =
583
+ normalized === '$env/static/private' ||
584
+ normalized === '$env/dynamic/private' ||
585
+ normalized === '$app/server' ||
586
+ normalized.startsWith('$lib/server/') ||
587
+ (is_internal && server_only_pattern.test(path.basename(id)));
588
+
589
+ if (is_server_only) {
590
+ // in dev, this doesn't exist, so we need to create it
591
+ manifest_data ??= sync.all(svelte_config, vite_config_env.mode).manifest_data;
592
+
593
+ /** @type {Set<string>} */
594
+ const entrypoints = new Set();
595
+ for (const node of manifest_data.nodes) {
596
+ if (node.component) entrypoints.add(node.component);
597
+ if (node.universal) entrypoints.add(node.universal);
598
+ }
599
+
600
+ const normalized = normalize_id(id, normalized_lib, normalized_cwd);
601
+ const chain = [normalized];
602
+
603
+ let current = normalized;
604
+
605
+ while (true) {
606
+ const importers = import_map.get(current);
607
+ if (!importers) break;
608
+
609
+ const candidates = Array.from(importers).filter((importer) => !chain.includes(importer));
610
+ if (candidates.length === 0) break;
611
+
612
+ chain.push((current = candidates[0]));
613
+
614
+ if (entrypoints.has(current)) {
615
+ let message = `Cannot import ${normalized} into code that runs in the browser, as this could leak sensitive information.`;
616
+
617
+ const pyramid = chain
618
+ .reverse()
619
+ .map((id, i) => {
620
+ return `${' '.repeat(i + 1)}${id}`;
621
+ })
622
+ .join(' imports\n');
623
+
624
+ message += `\n\n${pyramid}`;
625
+ message += `\n\nIf you're only using the import as a type, change it to \`import type\`.`;
626
+
627
+ throw stackless(message);
628
+ }
629
+ }
630
+
631
+ throw new Error('An impossible situation occurred');
594
632
  }
595
633
  }
596
634
  };
@@ -956,23 +994,36 @@ Tips:
956
994
 
957
995
  secondary_build_started = true;
958
996
 
959
- const { output: client_chunks } = /** @type {import('vite').Rollup.RollupOutput} */ (
960
- await vite.build({
961
- configFile: vite_config.configFile,
962
- // CLI args
963
- mode: vite_config_env.mode,
964
- logLevel: vite_config.logLevel,
965
- clearScreen: vite_config.clearScreen,
966
- build: {
967
- minify: initial_config.build?.minify,
968
- assetsInlineLimit: vite_config.build.assetsInlineLimit,
969
- sourcemap: vite_config.build.sourcemap
970
- },
971
- optimizeDeps: {
972
- force: vite_config.optimizeDeps.force
973
- }
974
- })
975
- );
997
+ let client_chunks;
998
+
999
+ try {
1000
+ const bundle = /** @type {import('vite').Rollup.RollupOutput} */ (
1001
+ await vite.build({
1002
+ configFile: vite_config.configFile,
1003
+ // CLI args
1004
+ mode: vite_config_env.mode,
1005
+ logLevel: vite_config.logLevel,
1006
+ clearScreen: vite_config.clearScreen,
1007
+ build: {
1008
+ minify: initial_config.build?.minify,
1009
+ assetsInlineLimit: vite_config.build.assetsInlineLimit,
1010
+ sourcemap: vite_config.build.sourcemap
1011
+ },
1012
+ optimizeDeps: {
1013
+ force: vite_config.optimizeDeps.force
1014
+ }
1015
+ })
1016
+ );
1017
+
1018
+ client_chunks = bundle.output;
1019
+ } catch (e) {
1020
+ const error =
1021
+ e instanceof Error ? e : new Error(/** @type {any} */ (e).message ?? e ?? '<unknown>');
1022
+
1023
+ // without this, errors that occur during the secondary build
1024
+ // will be logged twice
1025
+ throw stackless(error.stack ?? error.message);
1026
+ }
976
1027
 
977
1028
  copy(
978
1029
  `${out}/server/${kit.appDir}/immutable/assets`,
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Check if a match position is within a comment or a string
3
+ * @param {string} content - The full content
4
+ * @param {number} match_index - The index where the match starts
5
+ * @returns {boolean} - True if the match is within a comment
6
+ */
7
+ export function should_ignore(content, match_index) {
8
+ // Track if we're inside different types of quotes and comments
9
+ let in_single_quote = false;
10
+ let in_double_quote = false;
11
+ let in_template_literal = false;
12
+ let in_single_line_comment = false;
13
+ let in_multi_line_comment = false;
14
+ let in_html_comment = false;
15
+
16
+ for (let i = 0; i < match_index; i++) {
17
+ const char = content[i];
18
+ const next_two = content.slice(i, i + 2);
19
+ const next_four = content.slice(i, i + 4);
20
+
21
+ // Handle end of single line comment
22
+ if (in_single_line_comment && char === '\n') {
23
+ in_single_line_comment = false;
24
+ continue;
25
+ }
26
+
27
+ // Handle end of multi-line comment
28
+ if (in_multi_line_comment && next_two === '*/') {
29
+ in_multi_line_comment = false;
30
+ i++; // Skip the '/' part
31
+ continue;
32
+ }
33
+
34
+ // Handle end of HTML comment
35
+ if (in_html_comment && content.slice(i, i + 3) === '-->') {
36
+ in_html_comment = false;
37
+ i += 2; // Skip the '-->' part
38
+ continue;
39
+ }
40
+
41
+ // If we're in any comment, skip processing
42
+ if (in_single_line_comment || in_multi_line_comment || in_html_comment) {
43
+ continue;
44
+ }
45
+
46
+ // Handle escape sequences in strings
47
+ if ((in_single_quote || in_double_quote || in_template_literal) && char === '\\') {
48
+ i++; // Skip the escaped character
49
+ continue;
50
+ }
51
+
52
+ // Handle string boundaries
53
+ if (!in_double_quote && !in_template_literal && char === "'") {
54
+ in_single_quote = !in_single_quote;
55
+ continue;
56
+ }
57
+
58
+ if (!in_single_quote && !in_template_literal && char === '"') {
59
+ in_double_quote = !in_double_quote;
60
+ continue;
61
+ }
62
+
63
+ if (!in_single_quote && !in_double_quote && char === '`') {
64
+ in_template_literal = !in_template_literal;
65
+ continue;
66
+ }
67
+
68
+ // If we're inside any string, don't process comment delimiters
69
+ if (in_single_quote || in_double_quote || in_template_literal) {
70
+ continue;
71
+ }
72
+
73
+ // Check for comment starts
74
+ if (next_two === '//') {
75
+ in_single_line_comment = true;
76
+ i++; // Skip the second '/'
77
+ continue;
78
+ }
79
+
80
+ if (next_two === '/*') {
81
+ in_multi_line_comment = true;
82
+ i++; // Skip the '*'
83
+ continue;
84
+ }
85
+
86
+ if (next_four === '<!--') {
87
+ in_html_comment = true;
88
+ i += 3; // Skip the '<!--'
89
+ continue;
90
+ }
91
+ }
92
+
93
+ return (
94
+ in_single_line_comment ||
95
+ in_multi_line_comment ||
96
+ in_html_comment ||
97
+ in_single_quote ||
98
+ in_double_quote ||
99
+ in_template_literal
100
+ );
101
+ }
@@ -113,6 +113,8 @@ export function not_found(req, res, base) {
113
113
  }
114
114
  }
115
115
 
116
+ const query_pattern = /\?.*$/s;
117
+
116
118
  /**
117
119
  * Removes cwd/lib path from the start of the id
118
120
  * @param {string} id
@@ -120,6 +122,8 @@ export function not_found(req, res, base) {
120
122
  * @param {string} cwd
121
123
  */
122
124
  export function normalize_id(id, lib, cwd) {
125
+ id = id.replace(query_pattern, '');
126
+
123
127
  if (id.startsWith(lib)) {
124
128
  id = id.replace(lib, '$lib');
125
129
  }
@@ -155,4 +159,16 @@ export function normalize_id(id, lib, cwd) {
155
159
  return posixify(id);
156
160
  }
157
161
 
162
+ /**
163
+ * For times when you need to throw an error, but without
164
+ * displaying a useless stack trace (since the developer
165
+ * can't do anything useful with it)
166
+ * @param {string} message
167
+ */
168
+ export function stackless(message) {
169
+ const error = new Error(message);
170
+ error.stack = '';
171
+ return error;
172
+ }
173
+
158
174
  export const strip_virtual_prefix = /** @param {string} id */ (id) => id.replace('\0virtual:', '');
@@ -19,6 +19,7 @@ import('node:async_hooks')
19
19
  *
20
20
  * In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
21
21
  * @since 2.20.0
22
+ * @returns {RequestEvent}
22
23
  */
23
24
  export function getRequestEvent() {
24
25
  const event = request_event ?? als?.getStore();
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.28.0';
4
+ export const VERSION = '2.29.0';
package/types/index.d.ts CHANGED
@@ -397,26 +397,38 @@ declare module '@sveltejs/kit' {
397
397
  };
398
398
  /**
399
399
  * Where to find various files within your project.
400
+ * @deprecated
400
401
  */
401
402
  files?: {
403
+ /**
404
+ * the location of your source code
405
+ * @deprecated
406
+ * @default "src"
407
+ * @since 2.28
408
+ */
409
+ src?: string;
402
410
  /**
403
411
  * a place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`
412
+ * @deprecated
404
413
  * @default "static"
405
414
  */
406
415
  assets?: string;
407
416
  hooks?: {
408
417
  /**
409
418
  * The location of your client [hooks](https://svelte.dev/docs/kit/hooks).
419
+ * @deprecated
410
420
  * @default "src/hooks.client"
411
421
  */
412
422
  client?: string;
413
423
  /**
414
424
  * The location of your server [hooks](https://svelte.dev/docs/kit/hooks).
425
+ * @deprecated
415
426
  * @default "src/hooks.server"
416
427
  */
417
428
  server?: string;
418
429
  /**
419
430
  * The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).
431
+ * @deprecated
420
432
  * @default "src/hooks"
421
433
  * @since 2.3.0
422
434
  */
@@ -424,31 +436,37 @@ declare module '@sveltejs/kit' {
424
436
  };
425
437
  /**
426
438
  * your app's internal library, accessible throughout the codebase as `$lib`
439
+ * @deprecated
427
440
  * @default "src/lib"
428
441
  */
429
442
  lib?: string;
430
443
  /**
431
444
  * a directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching)
445
+ * @deprecated
432
446
  * @default "src/params"
433
447
  */
434
448
  params?: string;
435
449
  /**
436
450
  * the files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing))
451
+ * @deprecated
437
452
  * @default "src/routes"
438
453
  */
439
454
  routes?: string;
440
455
  /**
441
456
  * the location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers))
457
+ * @deprecated
442
458
  * @default "src/service-worker"
443
459
  */
444
460
  serviceWorker?: string;
445
461
  /**
446
462
  * the location of the template for HTML responses
463
+ * @deprecated
447
464
  * @default "src/app.html"
448
465
  */
449
466
  appTemplate?: string;
450
467
  /**
451
468
  * the location of the template for fallback error responses
469
+ * @deprecated
452
470
  * @default "src/error.html"
453
471
  */
454
472
  errorTemplate?: string;
@@ -1023,8 +1041,8 @@ declare module '@sveltejs/kit' {
1023
1041
 
1024
1042
  /**
1025
1043
  * - `enter`: The app has hydrated/started
1026
- * - `form`: The user submitted a `<form>` with a GET method
1027
- * - `leave`: The user is leaving the app by closing the tab or using the back/forward buttons to go to a different document
1044
+ * - `form`: The user submitted a `<form method="GET">`
1045
+ * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1028
1046
  * - `link`: Navigation was triggered by a link click
1029
1047
  * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1030
1048
  * - `popstate`: Navigation was triggered by back/forward navigation
@@ -1042,7 +1060,7 @@ declare module '@sveltejs/kit' {
1042
1060
  to: NavigationTarget | null;
1043
1061
  /**
1044
1062
  * The type of navigation:
1045
- * - `form`: The user submitted a `<form>`
1063
+ * - `form`: The user submitted a `<form method="GET">`
1046
1064
  * - `leave`: The app is being left either because the tab is being closed or a navigation to a different document is occurring
1047
1065
  * - `link`: Navigation was triggered by a link click
1048
1066
  * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
@@ -1080,7 +1098,7 @@ declare module '@sveltejs/kit' {
1080
1098
  export interface OnNavigate extends Navigation {
1081
1099
  /**
1082
1100
  * The type of navigation:
1083
- * - `form`: The user submitted a `<form>`
1101
+ * - `form`: The user submitted a `<form method="GET">`
1084
1102
  * - `link`: Navigation was triggered by a link click
1085
1103
  * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1086
1104
  * - `popstate`: Navigation was triggered by back/forward navigation
@@ -1099,7 +1117,7 @@ declare module '@sveltejs/kit' {
1099
1117
  /**
1100
1118
  * The type of navigation:
1101
1119
  * - `enter`: The app has hydrated/started
1102
- * - `form`: The user submitted a `<form>`
1120
+ * - `form`: The user submitted a `<form method="GET">`
1103
1121
  * - `link`: Navigation was triggered by a link click
1104
1122
  * - `goto`: Navigation was triggered by a `goto(...)` call or a redirect
1105
1123
  * - `popstate`: Navigation was triggered by back/forward navigation
@@ -2616,8 +2634,6 @@ declare module '$app/paths' {
2616
2634
  }
2617
2635
 
2618
2636
  declare module '$app/server' {
2619
- // @ts-ignore
2620
- import { LayoutParams as AppLayoutParams, RouteId as AppRouteId } from '$app/types'
2621
2637
  import type { RequestEvent, RemoteCommand, RemoteForm, RemotePrerenderFunction, RemoteQueryFunction } from '@sveltejs/kit';
2622
2638
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2623
2639
  /**
@@ -2638,8 +2654,8 @@ declare module '$app/server' {
2638
2654
  *
2639
2655
  * In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
2640
2656
  * @since 2.20.0
2641
- */
2642
- export function getRequestEvent(): RequestEvent<AppLayoutParams<"/">, any>;
2657
+ * */
2658
+ export function getRequestEvent(): RequestEvent;
2643
2659
  /**
2644
2660
  * Creates a remote command. When called from the browser, the function will be invoked on the server via a `fetch` call.
2645
2661
  *
@@ -185,6 +185,6 @@
185
185
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AOA;;;;;;;;;iBCrDPC,SAASA;;;;;;;;;;;;;;;cAyBTH,IAAIA;;;;;;;;;;cAiBJC,UAAUA;;;;;;;;cAeVC,OAAOA",
189
189
  "ignoreList": []
190
190
  }
@@ -1,87 +0,0 @@
1
- import path from 'node:path';
2
- import { posixify } from '../../../utils/filesystem.js';
3
- import { normalize_id, strip_virtual_prefix } from '../utils.js';
4
- import { app_server, env_dynamic_private, env_static_private } from '../module_ids.js';
5
-
6
- const ILLEGAL_IMPORTS = new Set([env_dynamic_private, env_static_private, app_server]);
7
- const ILLEGAL_MODULE_NAME_PATTERN = /.*\.server\..+/;
8
-
9
- /**
10
- * Checks if given id imports a module that is not allowed to be imported into client-side code.
11
- * @param {string} id
12
- * @param {{
13
- * cwd: string;
14
- * node_modules: string;
15
- * server: string;
16
- * }} dirs
17
- */
18
- export function is_illegal(id, dirs) {
19
- if (ILLEGAL_IMPORTS.has(id)) return true;
20
- if (!id.startsWith(dirs.cwd) || id.startsWith(dirs.node_modules)) return false;
21
- return ILLEGAL_MODULE_NAME_PATTERN.test(path.basename(id)) || id.startsWith(dirs.server);
22
- }
23
-
24
- /**
25
- * Creates a guard that checks that no id imports a module that is not allowed to be imported into client-side code.
26
- * @param {import('vite').Rollup.PluginContext} context
27
- * @param {{ cwd: string; lib: string }} paths
28
- */
29
- export function module_guard(context, { cwd, lib }) {
30
- /** @type {Set<string>} */
31
- const seen = new Set();
32
-
33
- const dirs = {
34
- // ids will be posixified, so we need to posixify these, too
35
- cwd: posixify(cwd),
36
- node_modules: posixify(path.join(cwd, 'node_modules')),
37
- server: posixify(path.join(lib, 'server'))
38
- };
39
-
40
- /**
41
- * @param {string} id
42
- * @param {Array<{ id: string; dynamic: boolean }>} chain
43
- */
44
- function follow(id, chain) {
45
- if (seen.has(id)) return;
46
- seen.add(id);
47
-
48
- if (is_illegal(id, dirs)) {
49
- chain.shift(); // discard the entry point
50
- id = normalize_id(id, lib, cwd);
51
-
52
- const pyramid =
53
- chain.map(({ id, dynamic }, i) => {
54
- id = normalize_id(id, lib, cwd);
55
-
56
- return `${' '.repeat(i * 2)}- ${strip_virtual_prefix(id)} ${
57
- dynamic ? 'dynamically imports' : 'imports'
58
- }\n`;
59
- }) + `${' '.repeat(chain.length)}- ${strip_virtual_prefix(id)}`;
60
-
61
- const message = `Cannot import ${strip_virtual_prefix(
62
- id
63
- )} into client-side code:\n${pyramid}`;
64
-
65
- throw new Error(message);
66
- }
67
-
68
- const module = context.getModuleInfo(id);
69
-
70
- if (module) {
71
- for (const child of module.importedIds) {
72
- follow(child, [...chain, { id, dynamic: false }]);
73
- }
74
-
75
- for (const child of module.dynamicallyImportedIds) {
76
- follow(child, [...chain, { id, dynamic: true }]);
77
- }
78
- }
79
- }
80
-
81
- return {
82
- /** @param {string} id should be posixified */
83
- check: (id) => {
84
- follow(id, []);
85
- }
86
- };
87
- }
@@ -1,5 +0,0 @@
1
- export interface ImportGraph {
2
- readonly id: string;
3
- readonly dynamic: boolean;
4
- readonly children: Generator<ImportGraph>;
5
- }
@@ -1,6 +0,0 @@
1
- const query_pattern = /\?.*$/s;
2
-
3
- /** @param {string} path */
4
- export function remove_query_from_id(path) {
5
- return path.replace(query_pattern, '');
6
- }