@sveltejs/kit 1.0.0-next.170 → 1.0.0-next.174

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/dist/cli.js CHANGED
@@ -426,14 +426,9 @@ const options = object(
426
426
 
427
427
  package: object({
428
428
  dir: string('package'),
429
- exports: object({
430
- include: array_of_strings(['**']),
431
- exclude: array_of_strings(['**/_*'])
432
- }),
433
- files: object({
434
- include: array_of_strings(['**']),
435
- exclude: array_of_strings([])
436
- }),
429
+ // excludes all .d.ts and filename starting with _
430
+ exports: fun((filepath) => !/^_|\/_|\.d\.ts$/.test(filepath)),
431
+ files: fun(() => true),
437
432
  emitTypes: boolean(true)
438
433
  }),
439
434
 
@@ -518,7 +513,7 @@ const options = object(
518
513
  router: boolean(true),
519
514
 
520
515
  serviceWorker: object({
521
- exclude: array_of_strings([])
516
+ files: fun((filename) => !/\.DS_STORE/.test(filename))
522
517
  }),
523
518
 
524
519
  ssr: boolean(true),
@@ -617,19 +612,6 @@ function string(fallback, allow_empty = true) {
617
612
  });
618
613
  }
619
614
 
620
- /**
621
- * @param {string[]} array
622
- * @returns {Validator}
623
- */
624
- function array_of_strings(array) {
625
- return validate(array, (input, keypath) => {
626
- if (!Array.isArray(input) || !input.every((glob) => typeof glob === 'string')) {
627
- throw new Error(`${keypath} must be an array of strings`);
628
- }
629
- return input;
630
- });
631
- }
632
-
633
615
  /**
634
616
  * @param {boolean} fallback
635
617
  * @returns {Validator}
@@ -661,6 +643,19 @@ function list(options, fallback = options[0]) {
661
643
  });
662
644
  }
663
645
 
646
+ /**
647
+ * @param {(filename: string) => boolean} fallback
648
+ * @returns {Validator}
649
+ */
650
+ function fun(fallback) {
651
+ return validate(fallback, (input, keypath) => {
652
+ if (typeof input !== 'function') {
653
+ throw new Error(`${keypath} should be a function, if specified`);
654
+ }
655
+ return input;
656
+ });
657
+ }
658
+
664
659
  /**
665
660
  * @param {string} input
666
661
  * @param {string} keypath
@@ -822,7 +817,7 @@ async function launch(port, https) {
822
817
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
823
818
  }
824
819
 
825
- const prog = sade('svelte-kit').version('1.0.0-next.170');
820
+ const prog = sade('svelte-kit').version('1.0.0-next.174');
826
821
 
827
822
  prog
828
823
  .command('dev')
@@ -965,7 +960,7 @@ async function check_port(port) {
965
960
  function welcome({ port, host, https, open }) {
966
961
  if (open) launch(port, https);
967
962
 
968
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.170'}\n`));
963
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.174'}\n`));
969
964
 
970
965
  const protocol = https ? 'https:' : 'http:';
971
966
  const exposed = host !== 'localhost' && host !== '127.0.0.1';
package/dist/ssr.js CHANGED
@@ -675,6 +675,14 @@ function normalize(loaded) {
675
675
  }
676
676
  }
677
677
 
678
+ // TODO remove before 1.0
679
+ if (/** @type {any} */ (loaded).context) {
680
+ throw new Error(
681
+ 'You are returning "context" from a load function. ' +
682
+ '"context" was renamed to "stuff", please adjust your code accordingly.'
683
+ );
684
+ }
685
+
678
686
  return /** @type {import('types/internal').NormalizedLoadOutput} */ (loaded);
679
687
  }
680
688
 
@@ -689,7 +697,7 @@ const s = JSON.stringify;
689
697
  * page: import('types/page').Page;
690
698
  * node: import('types/internal').SSRNode;
691
699
  * $session: any;
692
- * context: Record<string, any>;
700
+ * stuff: Record<string, any>;
693
701
  * prerender_enabled: boolean;
694
702
  * is_leaf: boolean;
695
703
  * is_error: boolean;
@@ -706,7 +714,7 @@ async function load_node({
706
714
  page,
707
715
  node,
708
716
  $session,
709
- context,
717
+ stuff,
710
718
  prerender_enabled,
711
719
  is_leaf,
712
720
  is_error,
@@ -946,7 +954,7 @@ async function load_node({
946
954
  })
947
955
  );
948
956
  },
949
- context: { ...context }
957
+ stuff: { ...stuff }
950
958
  };
951
959
 
952
960
  if (is_error) {
@@ -970,7 +978,7 @@ async function load_node({
970
978
  return {
971
979
  node,
972
980
  loaded: normalize(loaded),
973
- context: loaded.context || context,
981
+ stuff: loaded.stuff || stuff,
974
982
  fetched,
975
983
  set_cookie_headers,
976
984
  uses_credentials
@@ -1093,7 +1101,7 @@ async function respond_with_error({ request, options, state, $session, status, e
1093
1101
  page,
1094
1102
  node: default_layout,
1095
1103
  $session,
1096
- context: {},
1104
+ stuff: {},
1097
1105
  prerender_enabled: is_prerender_enabled(options, default_error, state),
1098
1106
  is_leaf: false,
1099
1107
  is_error: false
@@ -1111,7 +1119,7 @@ async function respond_with_error({ request, options, state, $session, status, e
1111
1119
  page,
1112
1120
  node: default_error,
1113
1121
  $session,
1114
- context: loaded ? loaded.context : {},
1122
+ stuff: loaded ? loaded.stuff : {},
1115
1123
  prerender_enabled: is_prerender_enabled(options, default_error, state),
1116
1124
  is_leaf: false,
1117
1125
  is_error: true,
@@ -1229,7 +1237,7 @@ async function respond$1(opts) {
1229
1237
  let set_cookie_headers = [];
1230
1238
 
1231
1239
  ssr: if (page_config.ssr) {
1232
- let context = {};
1240
+ let stuff = {};
1233
1241
 
1234
1242
  for (let i = 0; i < nodes.length; i += 1) {
1235
1243
  const node = nodes[i];
@@ -1242,7 +1250,7 @@ async function respond$1(opts) {
1242
1250
  loaded = await load_node({
1243
1251
  ...opts,
1244
1252
  node,
1245
- context,
1253
+ stuff,
1246
1254
  prerender_enabled: is_prerender_enabled(options, node, state),
1247
1255
  is_leaf: i === nodes.length - 1,
1248
1256
  is_error: false
@@ -1298,7 +1306,7 @@ async function respond$1(opts) {
1298
1306
  await load_node({
1299
1307
  ...opts,
1300
1308
  node: error_node,
1301
- context: node_loaded.context,
1309
+ stuff: node_loaded.stuff,
1302
1310
  prerender_enabled: is_prerender_enabled(options, error_node, state),
1303
1311
  is_leaf: false,
1304
1312
  is_error: true,
@@ -1341,11 +1349,10 @@ async function respond$1(opts) {
1341
1349
  }
1342
1350
  }
1343
1351
 
1344
- if (loaded && loaded.loaded.context) {
1345
- // TODO come up with better names for stuff
1346
- context = {
1347
- ...context,
1348
- ...loaded.loaded.context
1352
+ if (loaded && loaded.loaded.stuff) {
1353
+ stuff = {
1354
+ ...stuff,
1355
+ ...loaded.loaded.stuff
1349
1356
  };
1350
1357
  }
1351
1358
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.170",
3
+ "version": "1.0.0-next.174",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -19,7 +19,6 @@
19
19
  "@types/amphtml-validator": "^1.0.1",
20
20
  "@types/cookie": "^0.4.1",
21
21
  "@types/marked": "^3.0.1",
22
- "@types/micromatch": "^4.0.2",
23
22
  "@types/mime": "^2.0.3",
24
23
  "@types/node": "^16.9.1",
25
24
  "@types/rimraf": "^3.0.2",
@@ -31,7 +30,6 @@
31
30
  "kleur": "^4.1.4",
32
31
  "locate-character": "^2.0.5",
33
32
  "marked": "^3.0.4",
34
- "micromatch": "^4.0.4",
35
33
  "mime": "^2.5.2",
36
34
  "node-fetch": "3.0.0-beta.9",
37
35
  "port-authority": "^1.1.2",
@@ -39,14 +37,14 @@
39
37
  "rollup": "^2.56.3",
40
38
  "selfsigned": "^1.10.11",
41
39
  "sirv": "^1.0.17",
42
- "svelte": "^3.42.6",
40
+ "svelte": "^3.43.0",
43
41
  "svelte-check": "^2.2.6",
44
42
  "svelte2tsx": "~0.4.6",
45
43
  "tiny-glob": "^0.2.9",
46
44
  "uvu": "^0.5.1"
47
45
  },
48
46
  "peerDependencies": {
49
- "svelte": "^3.39.0"
47
+ "svelte": "^3.43.0"
50
48
  },
51
49
  "bin": {
52
50
  "svelte-kit": "svelte-kit.js"
package/types/config.d.ts CHANGED
@@ -51,14 +51,8 @@ export interface Config {
51
51
  package?: {
52
52
  dir?: string;
53
53
  emitTypes?: boolean;
54
- exports?: {
55
- include?: string[];
56
- exclude?: string[];
57
- };
58
- files?: {
59
- include?: string[];
60
- exclude?: string[];
61
- };
54
+ exports?(filepath: string): boolean;
55
+ files?(filepath: string): boolean;
62
56
  };
63
57
  paths?: {
64
58
  assets?: string;
@@ -72,7 +66,7 @@ export interface Config {
72
66
  };
73
67
  router?: boolean;
74
68
  serviceWorker?: {
75
- exclude?: string[];
69
+ files?(filepath: string): boolean;
76
70
  };
77
71
  ssr?: boolean;
78
72
  target?: string;
@@ -192,7 +192,7 @@ export interface NormalizedLoadOutput {
192
192
  error?: Error;
193
193
  redirect?: string;
194
194
  props?: Record<string, any> | Promise<Record<string, any>>;
195
- context?: Record<string, any>;
195
+ stuff?: Record<string, any>;
196
196
  maxage?: number;
197
197
  }
198
198
 
package/types/page.d.ts CHANGED
@@ -9,41 +9,41 @@ export interface Page<Params extends Record<string, string> = Record<string, str
9
9
 
10
10
  export interface LoadInput<
11
11
  PageParams extends Rec<string> = Rec<string>,
12
- Context extends Rec = Rec,
12
+ Stuff extends Rec = Rec,
13
13
  Session = any
14
14
  > {
15
15
  page: Page<PageParams>;
16
16
  fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
17
17
  session: Session;
18
- context: Context;
18
+ stuff: Stuff;
19
19
  }
20
20
 
21
21
  export interface ErrorLoadInput<
22
22
  PageParams extends Rec<string> = Rec<string>,
23
- Context extends Rec = Rec,
23
+ Stuff extends Rec = Rec,
24
24
  Session = any
25
- > extends LoadInput<PageParams, Context, Session> {
25
+ > extends LoadInput<PageParams, Stuff, Session> {
26
26
  status?: number;
27
27
  error?: Error;
28
28
  }
29
29
 
30
- export interface LoadOutput<Props extends Rec = Rec, Context extends Rec = Rec> {
30
+ export interface LoadOutput<Props extends Rec = Rec, Stuff extends Rec = Rec> {
31
31
  status?: number;
32
32
  error?: string | Error;
33
33
  redirect?: string;
34
34
  props?: Props;
35
- context?: Context;
35
+ stuff?: Stuff;
36
36
  maxage?: number;
37
37
  }
38
38
 
39
39
  interface LoadInputExtends {
40
- context?: Rec;
40
+ stuff?: Rec;
41
41
  pageParams?: Rec<string>;
42
42
  session?: any;
43
43
  }
44
44
 
45
45
  interface LoadOutputExtends {
46
- context?: Rec;
46
+ stuff?: Rec;
47
47
  props?: Rec;
48
48
  }
49
49
 
@@ -54,12 +54,12 @@ export interface Load<
54
54
  (
55
55
  input: LoadInput<
56
56
  InferValue<Input, 'pageParams', Rec<string>>,
57
- InferValue<Input, 'context', Rec>,
57
+ InferValue<Input, 'stuff', Rec>,
58
58
  InferValue<Input, 'session', any>
59
59
  >
60
60
  ): MaybePromise<void | LoadOutput<
61
61
  InferValue<Output, 'props', Rec>,
62
- InferValue<Output, 'context', Rec>
62
+ InferValue<Output, 'stuff', Rec>
63
63
  >>;
64
64
  }
65
65
 
@@ -70,8 +70,8 @@ export interface ErrorLoad<
70
70
  (
71
71
  input: ErrorLoadInput<
72
72
  InferValue<Input, 'pageParams', Rec<string>>,
73
- InferValue<Input, 'context', Rec>,
73
+ InferValue<Input, 'stuff', Rec>,
74
74
  InferValue<Input, 'session', any>
75
75
  >
76
- ): MaybePromise<LoadOutput<InferValue<Output, 'props', Rec>, InferValue<Output, 'context', Rec>>>;
76
+ ): MaybePromise<LoadOutput<InferValue<Output, 'props', Rec>, InferValue<Output, 'stuff', Rec>>>;
77
77
  }