@sveltejs/kit 2.62.0 → 3.0.0-next.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.
Files changed (104) hide show
  1. package/package.json +28 -22
  2. package/src/cli.js +49 -20
  3. package/src/core/adapt/builder.js +38 -69
  4. package/src/core/adapt/index.js +11 -6
  5. package/src/core/config/index.js +12 -82
  6. package/src/core/config/options.js +36 -45
  7. package/src/core/env.js +240 -60
  8. package/src/core/generate_manifest/find_server_assets.js +3 -2
  9. package/src/core/generate_manifest/index.js +11 -3
  10. package/src/core/postbuild/analyse.js +20 -16
  11. package/src/core/postbuild/fallback.js +0 -3
  12. package/src/core/postbuild/prerender.js +19 -17
  13. package/src/core/postbuild/queue.js +3 -4
  14. package/src/core/sync/create_manifest_data/index.js +16 -18
  15. package/src/core/sync/sync.js +44 -23
  16. package/src/core/sync/utils.js +0 -15
  17. package/src/core/sync/write_ambient.js +5 -50
  18. package/src/core/sync/write_client_manifest.js +8 -9
  19. package/src/core/sync/write_env.js +36 -0
  20. package/src/core/sync/write_non_ambient.js +7 -7
  21. package/src/core/sync/write_root.js +41 -89
  22. package/src/core/sync/write_server.js +18 -24
  23. package/src/core/sync/write_tsconfig.js +29 -24
  24. package/src/core/sync/write_types/index.js +31 -25
  25. package/src/core/utils.js +14 -11
  26. package/src/exports/hooks/index.js +13 -0
  27. package/src/exports/index.js +8 -21
  28. package/src/exports/internal/env.js +71 -0
  29. package/src/exports/internal/types.d.ts +3 -0
  30. package/src/exports/node/index.js +8 -13
  31. package/src/exports/public.d.ts +68 -69
  32. package/src/exports/vite/build/build_server.js +14 -11
  33. package/src/exports/vite/build/remote.js +6 -7
  34. package/src/exports/vite/build/utils.js +7 -5
  35. package/src/exports/vite/dev/index.js +32 -33
  36. package/src/exports/vite/index.js +1015 -711
  37. package/src/exports/vite/module_ids.js +10 -6
  38. package/src/exports/vite/options.js +17 -0
  39. package/src/exports/vite/preview/index.js +3 -5
  40. package/src/exports/vite/static_analysis/index.js +11 -5
  41. package/src/exports/vite/utils.js +11 -41
  42. package/src/runtime/app/env/index.js +2 -0
  43. package/src/runtime/app/env/internal.js +14 -0
  44. package/src/runtime/app/env/private.js +1 -0
  45. package/src/runtime/app/env/public/client.js +1 -0
  46. package/src/runtime/app/env/public/index.js +1 -0
  47. package/src/runtime/app/env/public/server.js +1 -0
  48. package/src/runtime/app/env/standard-schema.d.ts +0 -0
  49. package/src/runtime/app/server/index.js +4 -2
  50. package/src/runtime/app/server/remote/form.js +0 -51
  51. package/src/runtime/app/server/remote/query.js +1 -8
  52. package/src/runtime/app/server/remote/shared.js +4 -3
  53. package/src/runtime/app/state/client.js +1 -12
  54. package/src/runtime/client/client.js +1 -1
  55. package/src/runtime/client/constants.js +0 -1
  56. package/src/runtime/client/remote-functions/form.svelte.js +0 -31
  57. package/src/runtime/client/remote-functions/prerender.svelte.js +1 -1
  58. package/src/runtime/client/remote-functions/query/index.js +2 -2
  59. package/src/runtime/client/remote-functions/query/instance.svelte.js +1 -2
  60. package/src/runtime/client/remote-functions/query-batch.svelte.js +2 -2
  61. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +5 -8
  62. package/src/runtime/client/utils.js +9 -11
  63. package/src/runtime/components/{svelte-5/layout.svelte → layout.svelte} +1 -1
  64. package/src/runtime/form-utils.js +4 -41
  65. package/src/runtime/server/cookie.js +21 -37
  66. package/src/runtime/server/env_module.js +12 -4
  67. package/src/runtime/server/fetch.js +6 -10
  68. package/src/runtime/server/index.js +5 -9
  69. package/src/runtime/server/page/render.js +33 -37
  70. package/src/runtime/server/page/types.d.ts +4 -2
  71. package/src/runtime/server/respond.js +3 -3
  72. package/src/runtime/server/utils.js +2 -4
  73. package/src/runtime/shared-server.js +0 -22
  74. package/src/runtime/shared.js +0 -15
  75. package/src/types/ambient-private.d.ts +25 -9
  76. package/src/types/global-private.d.ts +6 -0
  77. package/src/types/internal.d.ts +4 -8
  78. package/src/utils/css.js +3 -19
  79. package/src/utils/filesystem.js +1 -30
  80. package/src/utils/http.js +0 -21
  81. package/src/utils/import.js +8 -7
  82. package/src/utils/os.js +7 -0
  83. package/src/utils/path.js +23 -0
  84. package/src/utils/shared-iterator.js +3 -0
  85. package/src/utils/streaming.js +2 -4
  86. package/src/utils/url.js +1 -1
  87. package/src/utils/vite.js +28 -0
  88. package/src/version.js +1 -1
  89. package/types/index.d.ts +85 -109
  90. package/types/index.d.ts.map +5 -6
  91. package/src/exports/vite/build/build_service_worker.js +0 -149
  92. package/src/runtime/app/environment/index.js +0 -2
  93. package/src/runtime/components/svelte-4/error.svelte +0 -6
  94. package/src/runtime/components/svelte-4/layout.svelte +0 -1
  95. package/src/runtime/env/dynamic/private.js +0 -1
  96. package/src/runtime/env/dynamic/public.js +0 -1
  97. package/src/types/synthetic/$env+dynamic+private.md +0 -43
  98. package/src/types/synthetic/$env+dynamic+public.md +0 -46
  99. package/src/types/synthetic/$env+static+private.md +0 -31
  100. package/src/types/synthetic/$env+static+public.md +0 -31
  101. package/src/utils/env.js +0 -13
  102. package/src/utils/promise.js +0 -29
  103. /package/src/runtime/app/{environment → env}/types.d.ts +0 -0
  104. /package/src/runtime/components/{svelte-5/error.svelte → error.svelte} +0 -0
@@ -1,43 +0,0 @@
1
- This module provides access to environment variables set _dynamically_ at runtime and that are limited to _private_ access.
2
-
3
- | | Runtime | Build time |
4
- | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
5
- | Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |
6
- | Public | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public) | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) |
7
-
8
- Dynamic environment variables are defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`.
9
-
10
- **_Private_ access:**
11
-
12
- - This module cannot be imported into client-side code
13
- - This module includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured)
14
-
15
- > [!NOTE] In `dev`, `$env/dynamic` includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter.
16
-
17
- > [!NOTE] To get correct types, environment variables referenced in your code should be declared (for example in an `.env` file), even if they don't have a value until the app is deployed:
18
- >
19
- > ```env
20
- > MY_FEATURE_FLAG=
21
- > ```
22
- >
23
- > You can override `.env` values from the command line like so:
24
- >
25
- > ```sh
26
- > MY_FEATURE_FLAG="enabled" npm run dev
27
- > ```
28
-
29
- For example, given the following runtime environment:
30
-
31
- ```env
32
- ENVIRONMENT=production
33
- PUBLIC_BASE_URL=http://site.com
34
- ```
35
-
36
- With the default `publicPrefix` and `privatePrefix`:
37
-
38
- ```ts
39
- import { env } from '$env/dynamic/private';
40
-
41
- console.log(env.ENVIRONMENT); // => "production"
42
- console.log(env.PUBLIC_BASE_URL); // => undefined
43
- ```
@@ -1,46 +0,0 @@
1
- This module provides access to environment variables set _dynamically_ at runtime and that are _publicly_ accessible.
2
-
3
- | | Runtime | Build time |
4
- | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
5
- | Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |
6
- | Public | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public) | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) |
7
-
8
- Dynamic environment variables are defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`.
9
-
10
- **_Public_ access:**
11
-
12
- - This module _can_ be imported into client-side code
13
- - **Only** variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`) are included
14
-
15
- > [!NOTE] In `dev`, `$env/dynamic` includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter.
16
-
17
- > [!NOTE] To get correct types, environment variables referenced in your code should be declared (for example in an `.env` file), even if they don't have a value until the app is deployed:
18
- >
19
- > ```env
20
- > MY_FEATURE_FLAG=
21
- > ```
22
- >
23
- > You can override `.env` values from the command line like so:
24
- >
25
- > ```sh
26
- > MY_FEATURE_FLAG="enabled" npm run dev
27
- > ```
28
-
29
- For example, given the following runtime environment:
30
-
31
- ```env
32
- ENVIRONMENT=production
33
- PUBLIC_BASE_URL=http://example.com
34
- ```
35
-
36
- With the default `publicPrefix` and `privatePrefix`:
37
-
38
- ```ts
39
- import { env } from '$env/dynamic/public';
40
- console.log(env.ENVIRONMENT); // => undefined, not public
41
- console.log(env.PUBLIC_BASE_URL); // => "http://example.com"
42
- ```
43
-
44
- ```
45
-
46
- ```
@@ -1,31 +0,0 @@
1
- This module provides access to environment variables that are injected _statically_ into your bundle at build time and are limited to _private_ access.
2
-
3
- | | Runtime | Build time |
4
- | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
5
- | Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |
6
- | Public | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public) | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) |
7
-
8
- Static environment variables are [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env` at build time and then statically injected into your bundle at build time, enabling optimisations like dead code elimination.
9
-
10
- **_Private_ access:**
11
-
12
- - This module cannot be imported into client-side code
13
- - This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured)
14
-
15
- For example, given the following build time environment:
16
-
17
- ```env
18
- ENVIRONMENT=production
19
- PUBLIC_BASE_URL=http://site.com
20
- ```
21
-
22
- With the default `publicPrefix` and `privatePrefix`:
23
-
24
- ```ts
25
- import { ENVIRONMENT, PUBLIC_BASE_URL } from '$env/static/private';
26
-
27
- console.log(ENVIRONMENT); // => "production"
28
- console.log(PUBLIC_BASE_URL); // => throws error during build
29
- ```
30
-
31
- The above values will be the same _even if_ different values for `ENVIRONMENT` or `PUBLIC_BASE_URL` are set at runtime, as they are statically replaced in your code with their build time values.
@@ -1,31 +0,0 @@
1
- This module provides access to environment variables that are injected _statically_ into your bundle at build time and are _publicly_ accessible.
2
-
3
- | | Runtime | Build time |
4
- | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
5
- | Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |
6
- | Public | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public) | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) |
7
-
8
- Static environment variables are [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env` at build time and then statically injected into your bundle at build time, enabling optimisations like dead code elimination.
9
-
10
- **_Public_ access:**
11
-
12
- - This module _can_ be imported into client-side code
13
- - **Only** variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`) are included
14
-
15
- For example, given the following build time environment:
16
-
17
- ```env
18
- ENVIRONMENT=production
19
- PUBLIC_BASE_URL=http://site.com
20
- ```
21
-
22
- With the default `publicPrefix` and `privatePrefix`:
23
-
24
- ```ts
25
- import { ENVIRONMENT, PUBLIC_BASE_URL } from '$env/static/public';
26
-
27
- console.log(ENVIRONMENT); // => throws error during build
28
- console.log(PUBLIC_BASE_URL); // => "http://site.com"
29
- ```
30
-
31
- The above values will be the same _even if_ different values for `ENVIRONMENT` or `PUBLIC_BASE_URL` are set at runtime, as they are statically replaced in your code with their build time values.
package/src/utils/env.js DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * @param {Record<string, string>} env
3
- * @param {string} allowed
4
- * @param {string} disallowed
5
- * @returns {Record<string, string>}
6
- */
7
- export function filter_env(env, allowed, disallowed) {
8
- return Object.fromEntries(
9
- Object.entries(env).filter(
10
- ([k]) => k.startsWith(allowed) && (disallowed === '' || !k.startsWith(disallowed))
11
- )
12
- );
13
- }
@@ -1,29 +0,0 @@
1
- /** @see https://github.com/microsoft/TypeScript/blob/904e7dd97dc8da1352c8e05d70829dff17c73214/src/lib/es2024.promise.d.ts */
2
-
3
- /**
4
- * @template T
5
- * @typedef {{
6
- * promise: Promise<T>;
7
- * resolve: (value: T | PromiseLike<T>) => void;
8
- * reject: (reason?: any) => void;
9
- * }} PromiseWithResolvers<T>
10
- */
11
-
12
- /**
13
- * TODO: Whenever Node >21 is minimum supported version, we can use `Promise.withResolvers` to avoid this ceremony
14
- *
15
- * @template T
16
- * @returns {PromiseWithResolvers<T>}
17
- */
18
- export function with_resolvers() {
19
- let resolve;
20
- let reject;
21
-
22
- const promise = new Promise((res, rej) => {
23
- resolve = res;
24
- reject = rej;
25
- });
26
-
27
- // @ts-expect-error `resolve` and `reject` are assigned!
28
- return { promise, resolve, reject };
29
- }
File without changes