@sveltejs/kit 1.30.2 → 2.0.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 +24 -24
- package/src/core/adapt/builder.js +8 -1
- package/src/core/config/index.js +9 -1
- package/src/core/config/options.js +1 -12
- package/src/core/postbuild/analyse.js +98 -80
- package/src/core/postbuild/prerender.js +11 -9
- package/src/core/sync/sync.js +2 -0
- package/src/core/sync/write_non_ambient.js +42 -0
- package/src/core/sync/write_server.js +3 -3
- package/src/core/sync/write_tsconfig.js +27 -78
- package/src/core/sync/write_types/index.js +1 -1
- package/src/exports/hooks/sequence.js +1 -1
- package/src/exports/index.js +88 -71
- package/src/exports/node/index.js +21 -24
- package/src/exports/node/polyfills.js +5 -34
- package/src/exports/public.d.ts +82 -61
- package/src/exports/vite/dev/index.js +11 -19
- package/src/exports/vite/graph_analysis/index.js +2 -4
- package/src/exports/vite/index.js +73 -14
- package/src/exports/vite/module_ids.js +7 -0
- package/src/exports/vite/preview/index.js +56 -130
- package/src/runtime/app/forms.js +2 -35
- package/src/runtime/app/navigation.js +33 -18
- package/src/runtime/app/paths.js +2 -29
- package/src/runtime/client/client.js +449 -199
- package/src/runtime/client/constants.js +5 -1
- package/src/runtime/client/session-storage.js +7 -5
- package/src/runtime/client/singletons.js +7 -1
- package/src/runtime/client/types.d.ts +6 -2
- package/src/runtime/client/utils.js +12 -10
- package/src/runtime/control.js +16 -8
- package/src/runtime/server/cookie.js +38 -61
- package/src/runtime/server/data/index.js +6 -4
- package/src/runtime/server/env_module.js +29 -0
- package/src/runtime/server/fetch.js +7 -6
- package/src/runtime/server/index.js +23 -20
- package/src/runtime/server/page/actions.js +24 -15
- package/src/runtime/server/page/index.js +6 -8
- package/src/runtime/server/page/load_data.js +58 -40
- package/src/runtime/server/page/render.js +12 -7
- package/src/runtime/server/page/respond_with_error.js +4 -4
- package/src/runtime/server/page/types.d.ts +1 -1
- package/src/runtime/server/respond.js +14 -12
- package/src/runtime/server/utils.js +11 -8
- package/src/runtime/shared-server.js +19 -2
- package/src/types/ambient.d.ts +7 -1
- package/src/types/internal.d.ts +4 -1
- package/src/types/synthetic/$env+dynamic+private.md +2 -0
- package/src/types/synthetic/$env+dynamic+public.md +2 -0
- package/src/utils/error.js +17 -1
- package/src/utils/routing.js +47 -1
- package/src/utils/url.js +45 -27
- package/src/version.js +1 -1
- package/types/index.d.ts +171 -118
- package/types/index.d.ts.map +9 -5
- package/src/utils/platform.js +0 -1
- package/src/utils/promises.js +0 -61
package/src/utils/promises.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { DEV } from 'esm-env';
|
|
2
|
-
|
|
3
|
-
/** @type {Set<string> | null} */
|
|
4
|
-
let warned = null;
|
|
5
|
-
|
|
6
|
-
// TODO v2: remove all references to unwrap_promises
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Given an object, return a new object where all top level values are awaited
|
|
10
|
-
*
|
|
11
|
-
* @param {Record<string, any>} object
|
|
12
|
-
* @param {string | null} [id]
|
|
13
|
-
* @returns {Promise<Record<string, any>>}
|
|
14
|
-
*/
|
|
15
|
-
export async function unwrap_promises(object, id) {
|
|
16
|
-
if (DEV) {
|
|
17
|
-
/** @type {string[]} */
|
|
18
|
-
const promises = [];
|
|
19
|
-
|
|
20
|
-
for (const key in object) {
|
|
21
|
-
if (typeof object[key]?.then === 'function') {
|
|
22
|
-
promises.push(key);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (promises.length > 0) {
|
|
27
|
-
if (!warned) warned = new Set();
|
|
28
|
-
|
|
29
|
-
const last = promises.pop();
|
|
30
|
-
|
|
31
|
-
const properties =
|
|
32
|
-
promises.length > 0
|
|
33
|
-
? `${promises.map((p) => `"${p}"`).join(', ')} and "${last}" properties`
|
|
34
|
-
: `"${last}" property`;
|
|
35
|
-
|
|
36
|
-
const location = id ? `the \`load\` function in ${id}` : 'a `load` function';
|
|
37
|
-
|
|
38
|
-
const description = promises.length > 0 ? 'are promises' : 'is a promise';
|
|
39
|
-
|
|
40
|
-
const message = `The top-level ${properties} returned from ${location} ${description}.`;
|
|
41
|
-
|
|
42
|
-
if (!warned.has(message)) {
|
|
43
|
-
console.warn(
|
|
44
|
-
`\n${message}\n\nIn SvelteKit 2.0, these will no longer be awaited automatically. To get rid of this warning, await all promises included as top-level properties in \`load\` return values.\n`
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
warned.add(message);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
for (const key in object) {
|
|
53
|
-
if (typeof object[key]?.then === 'function') {
|
|
54
|
-
return Object.fromEntries(
|
|
55
|
-
await Promise.all(Object.entries(object).map(async ([key, value]) => [key, await value]))
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return object;
|
|
61
|
-
}
|