@sveltejs/kit 1.0.0-next.368 → 1.0.0-next.369

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.
@@ -347,9 +347,14 @@ function parse_route_id(id) {
347
347
  .split(/\[(.+?)\]/)
348
348
  .map((content, i) => {
349
349
  if (i % 2) {
350
- const [, rest, name, type] = /** @type {RegExpMatchArray} */ (
351
- param_pattern.exec(content)
352
- );
350
+ const match = param_pattern.exec(content);
351
+ if (!match) {
352
+ throw new Error(
353
+ `Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
354
+ );
355
+ }
356
+
357
+ const [, rest, name, type] = match;
353
358
  names.push(name);
354
359
  types.push(type);
355
360
  return rest ? '(.*?)' : '([^/]+?)';
@@ -1319,14 +1324,9 @@ function create_client({ target, session, base, trailing_slash }) {
1319
1324
  const params = route.exec(path);
1320
1325
 
1321
1326
  if (params) {
1327
+ const id = normalize_path(url.pathname, trailing_slash) + url.search;
1322
1328
  /** @type {import('./types').NavigationIntent} */
1323
- const intent = {
1324
- id: url.pathname + url.search,
1325
- route,
1326
- params,
1327
- url
1328
- };
1329
-
1329
+ const intent = { id, route, params, url };
1330
1330
  return intent;
1331
1331
  }
1332
1332
  }
@@ -190,9 +190,14 @@ function parse_route_id(id) {
190
190
  .split(/\[(.+?)\]/)
191
191
  .map((content, i) => {
192
192
  if (i % 2) {
193
- const [, rest, name, type] = /** @type {RegExpMatchArray} */ (
194
- param_pattern.exec(content)
195
- );
193
+ const match = param_pattern.exec(content);
194
+ if (!match) {
195
+ throw new Error(
196
+ `Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
197
+ );
198
+ }
199
+
200
+ const [, rest, name, type] = match;
196
201
  names.push(name);
197
202
  types.push(type);
198
203
  return rest ? '(.*?)' : '([^/]+?)';
@@ -492,11 +497,18 @@ function create_manifest_data({
492
497
  if (!config.kit.moduleExtensions.includes(ext)) continue;
493
498
  const type = file.slice(0, -ext.length);
494
499
 
495
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(type)) {
496
- matchers[type] = path__default.join(params_base, file);
500
+ if (/^\w+$/.test(type)) {
501
+ const matcher_file = path__default.join(params_base, file);
502
+
503
+ // Disallow same matcher with different extensions
504
+ if (matchers[type]) {
505
+ throw new Error(`Duplicate matchers: ${matcher_file} and ${matchers[type]}`);
506
+ } else {
507
+ matchers[type] = matcher_file;
508
+ }
497
509
  } else {
498
510
  throw new Error(
499
- `Matcher names must match /^[a-zA-Z_][a-zA-Z0-9_]*$/ — "${file}" is invalid`
511
+ `Matcher names can only have underscores and alphanumeric characters — "${file}" is invalid`
500
512
  );
501
513
  }
502
514
  }
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ function handle_error(e) {
18
18
  process.exit(1);
19
19
  }
20
20
 
21
- const prog = sade('svelte-kit').version('1.0.0-next.368');
21
+ const prog = sade('svelte-kit').version('1.0.0-next.369');
22
22
 
23
23
  prog
24
24
  .command('package')
package/dist/vite.js CHANGED
@@ -747,11 +747,13 @@ async function build_service_worker(
747
747
  await vite.build(merged_config);
748
748
  }
749
749
 
750
- /** @typedef {{
750
+ /**
751
+ * @typedef {{
751
752
  * fn: () => Promise<any>,
752
753
  * fulfil: (value: any) => void,
753
754
  * reject: (error: Error) => void
754
- * }} Task */
755
+ * }} Task
756
+ */
755
757
 
756
758
  /** @param {number} concurrency */
757
759
  function queue(concurrency) {
@@ -3094,6 +3096,9 @@ function kit() {
3094
3096
  },
3095
3097
 
3096
3098
  async closeBundle() {
3099
+ if (!is_build) {
3100
+ return; // vite calls closeBundle when dev-server restarts, ignore that
3101
+ }
3097
3102
  if (svelte_config.kit.adapter) {
3098
3103
  const { adapt } = await import('./chunks/index2.js');
3099
3104
  await adapt(svelte_config, build_data, prerendered, { log });
@@ -3105,7 +3110,7 @@ function kit() {
3105
3110
  );
3106
3111
  }
3107
3112
 
3108
- if (is_build && svelte_config.kit.prerender.enabled) {
3113
+ if (svelte_config.kit.prerender.enabled) {
3109
3114
  // this is necessary to close any open db connections, etc.
3110
3115
  // TODO: prerender in a subprocess so we can exit in isolation
3111
3116
  // https://github.com/sveltejs/kit/issues/5306
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.368",
3
+ "version": "1.0.0-next.369",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
package/types/index.d.ts CHANGED
@@ -52,7 +52,6 @@ export interface Builder {
52
52
  */
53
53
  writeClient(dest: string): string[];
54
54
  /**
55
- *
56
55
  * @param dest
57
56
  */
58
57
  writePrerendered(