@sveltejs/kit 1.0.0-next.500 → 1.0.0-next.501

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": "1.0.0-next.500",
3
+ "version": "1.0.0-next.501",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -24,3 +24,7 @@ declare module '__GENERATED__/client-manifest.js' {
24
24
 
25
25
  export const hooks: ClientHooks;
26
26
  }
27
+
28
+ declare module '__GENERATED__/root.svelte' {
29
+ export { SvelteComponent as default } from 'svelte';
30
+ }
@@ -9,6 +9,7 @@ import { nodes, server_loads, dictionary, matchers, hooks } from '__GENERATED__/
9
9
  import { HttpError, Redirect } from '../control.js';
10
10
  import { stores } from './singletons.js';
11
11
  import { DATA_SUFFIX } from '../../constants.js';
12
+ import { unwrap_promises } from '../../utils/promises.js';
12
13
 
13
14
  const SCROLL_KEY = 'sveltekit:scroll';
14
15
  const INDEX_KEY = 'sveltekit:index';
@@ -608,6 +609,7 @@ export function create_client({ target, base, trailing_slash }) {
608
609
  } else {
609
610
  data = (await node.shared.load.call(null, load_input)) ?? null;
610
611
  }
612
+ data = data ? await unwrap_promises(data) : null;
611
613
  }
612
614
 
613
615
  return {
@@ -1,5 +1,5 @@
1
1
  import { disable_search, make_trackable } from '../../../utils/url.js';
2
-
2
+ import { unwrap_promises } from '../../../utils/promises.js';
3
3
  /**
4
4
  * Calls the user's `load` function.
5
5
  * @param {{
@@ -110,15 +110,3 @@ export async function load_data({ event, fetcher, node, parent, server_data_prom
110
110
 
111
111
  return data ? unwrap_promises(data) : null;
112
112
  }
113
-
114
- /** @param {Record<string, any>} object */
115
- async function unwrap_promises(object) {
116
- /** @type {Record<string, any>} */
117
- const unwrapped = {};
118
-
119
- for (const key in object) {
120
- unwrapped[key] = await object[key];
121
- }
122
-
123
- return unwrapped;
124
- }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Given an object, return a new object where all top level values are awaited
3
+ *
4
+ * @param {Record<string, any>} object
5
+ * @returns {Promise<Record<string, any>>}
6
+ */
7
+ export async function unwrap_promises(object) {
8
+ for (const key in object) {
9
+ if (typeof object[key]?.then === 'function') {
10
+ return Object.fromEntries(
11
+ await Promise.all(Object.entries(object).map(async ([key, value]) => [key, await value]))
12
+ );
13
+ }
14
+ }
15
+
16
+ return object;
17
+ }