@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.
@@ -373,6 +373,14 @@ function normalize(loaded) {
373
373
  }
374
374
  }
375
375
 
376
+ // TODO remove before 1.0
377
+ if (/** @type {any} */ (loaded).context) {
378
+ throw new Error(
379
+ 'You are returning "context" from a load function. ' +
380
+ '"context" was renamed to "stuff", please adjust your code accordingly.'
381
+ );
382
+ }
383
+
376
384
  return /** @type {import('types/internal').NormalizedLoadOutput} */ (loaded);
377
385
  }
378
386
 
@@ -512,7 +520,7 @@ class Renderer {
512
520
  const branch = [];
513
521
 
514
522
  /** @type {Record<string, any>} */
515
- let context = {};
523
+ let stuff = {};
516
524
 
517
525
  /** @type {import('./types').NavigationResult | undefined} */
518
526
  let result;
@@ -526,7 +534,7 @@ class Renderer {
526
534
  const node = await this._load_node({
527
535
  module: await nodes[i],
528
536
  page,
529
- context,
537
+ stuff,
530
538
  status: is_leaf ? status : undefined,
531
539
  error: is_leaf ? error : undefined
532
540
  });
@@ -542,10 +550,10 @@ class Renderer {
542
550
  path: page.path,
543
551
  query: page.query
544
552
  };
545
- } else if (node.loaded.context) {
546
- context = {
547
- ...context,
548
- ...node.loaded.context
553
+ } else if (node.loaded.stuff) {
554
+ stuff = {
555
+ ...stuff,
556
+ ...node.loaded.stuff
549
557
  };
550
558
  }
551
559
  }
@@ -824,11 +832,11 @@ class Renderer {
824
832
  * error?: Error;
825
833
  * module: CSRComponent;
826
834
  * page: import('types/page').Page;
827
- * context: Record<string, any>;
835
+ * stuff: Record<string, any>;
828
836
  * }} options
829
837
  * @returns
830
838
  */
831
- async _load_node({ status, error, module, page, context }) {
839
+ async _load_node({ status, error, module, page, stuff }) {
832
840
  /** @type {import('./types').BranchNode} */
833
841
  const node = {
834
842
  module,
@@ -837,11 +845,11 @@ class Renderer {
837
845
  path: false,
838
846
  query: false,
839
847
  session: false,
840
- context: false,
848
+ stuff: false,
841
849
  dependencies: []
842
850
  },
843
851
  loaded: null,
844
- context
852
+ stuff
845
853
  };
846
854
 
847
855
  /** @type {Record<string, string>} */
@@ -879,9 +887,9 @@ class Renderer {
879
887
  node.uses.session = true;
880
888
  return session;
881
889
  },
882
- get context() {
883
- node.uses.context = true;
884
- return { ...context };
890
+ get stuff() {
891
+ node.uses.stuff = true;
892
+ return { ...stuff };
885
893
  },
886
894
  fetch(resource, info) {
887
895
  const url = typeof resource === 'string' ? resource : resource.url;
@@ -903,7 +911,7 @@ class Renderer {
903
911
  if (!loaded) return;
904
912
 
905
913
  node.loaded = normalize(loaded);
906
- if (node.loaded.context) node.context = node.loaded.context;
914
+ if (node.loaded.stuff) node.stuff = node.loaded.stuff;
907
915
  }
908
916
 
909
917
  return node;
@@ -942,8 +950,8 @@ class Renderer {
942
950
  let branch = [];
943
951
 
944
952
  /** @type {Record<string, any>} */
945
- let context = {};
946
- let context_changed = false;
953
+ let stuff = {};
954
+ let stuff_changed = false;
947
955
 
948
956
  /** @type {number | undefined} */
949
957
  let status = 200;
@@ -972,13 +980,13 @@ class Renderer {
972
980
  (changed.query && previous.uses.query) ||
973
981
  (changed.session && previous.uses.session) ||
974
982
  previous.uses.dependencies.some((dep) => this.invalid.has(dep)) ||
975
- (context_changed && previous.uses.context);
983
+ (stuff_changed && previous.uses.stuff);
976
984
 
977
985
  if (changed_since_last_render) {
978
986
  node = await this._load_node({
979
987
  module,
980
988
  page,
981
- context
989
+ stuff
982
990
  });
983
991
 
984
992
  const is_leaf = i === a.length - 1;
@@ -997,8 +1005,8 @@ class Renderer {
997
1005
  };
998
1006
  }
999
1007
 
1000
- if (node.loaded.context) {
1001
- context_changed = true;
1008
+ if (node.loaded.stuff) {
1009
+ stuff_changed = true;
1002
1010
  }
1003
1011
  } else if (is_leaf && module.load) {
1004
1012
  // if the leaf node has a `load` function
@@ -1031,7 +1039,7 @@ class Renderer {
1031
1039
  error,
1032
1040
  module: await b[i](),
1033
1041
  page,
1034
- context: node_loaded.context
1042
+ stuff: node_loaded.stuff
1035
1043
  });
1036
1044
 
1037
1045
  if (error_loaded && error_loaded.loaded && error_loaded.loaded.error) {
@@ -1053,10 +1061,10 @@ class Renderer {
1053
1061
  query
1054
1062
  });
1055
1063
  } else {
1056
- if (node && node.loaded && node.loaded.context) {
1057
- context = {
1058
- ...context,
1059
- ...node.loaded.context
1064
+ if (node && node.loaded && node.loaded.stuff) {
1065
+ stuff = {
1066
+ ...stuff,
1067
+ ...node.loaded.stuff
1060
1068
  };
1061
1069
  }
1062
1070
 
@@ -1086,7 +1094,7 @@ class Renderer {
1086
1094
  const node = await this._load_node({
1087
1095
  module: await this.fallback[0],
1088
1096
  page,
1089
- context: {}
1097
+ stuff: {}
1090
1098
  });
1091
1099
 
1092
1100
  const branch = [
@@ -1096,7 +1104,7 @@ class Renderer {
1096
1104
  error,
1097
1105
  module: await this.fallback[1],
1098
1106
  page,
1099
- context: (node && node.loaded && node.loaded.context) || {}
1107
+ stuff: (node && node.loaded && node.loaded.stuff) || {}
1100
1108
  })
1101
1109
  ];
1102
1110