@sveltejs/kit 2.62.0 → 2.63.1
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 +12 -1
- package/src/cli.js +32 -6
- package/src/core/adapt/builder.js +26 -5
- package/src/core/adapt/index.js +5 -2
- package/src/core/config/index.js +7 -5
- package/src/core/config/options.js +1 -0
- package/src/core/env.js +313 -8
- package/src/core/postbuild/analyse.js +2 -1
- package/src/core/postbuild/prerender.js +2 -1
- package/src/core/sync/create_manifest_data/index.js +24 -1
- package/src/core/sync/sync.js +16 -0
- package/src/core/sync/write_ambient.js +12 -6
- package/src/core/sync/write_env.js +33 -0
- package/src/core/sync/write_root.js +1 -1
- package/src/core/sync/write_server.js +3 -2
- package/src/core/sync/write_tsconfig.js +1 -0
- package/src/exports/hooks/index.js +13 -0
- package/src/exports/internal/env.js +71 -0
- package/src/exports/internal/types.d.ts +3 -0
- package/src/exports/public.d.ts +40 -0
- package/src/exports/vite/build/build_service_worker.js +20 -4
- package/src/exports/vite/dev/index.js +2 -2
- package/src/exports/vite/index.js +129 -36
- package/src/exports/vite/module_ids.js +10 -1
- package/src/exports/vite/static_analysis/index.js +2 -4
- package/src/exports/vite/static_analysis/types.d.ts +14 -0
- package/src/exports/vite/utils.js +7 -12
- package/src/runtime/app/env/index.js +2 -0
- package/src/runtime/app/env/internal.js +11 -0
- package/src/runtime/app/env/private.js +1 -0
- package/src/runtime/app/env/public/client.js +7 -0
- package/src/runtime/app/env/public/index.js +1 -0
- package/src/runtime/app/env/public/server.js +7 -0
- package/src/runtime/app/env/standard-schema.d.ts +0 -0
- package/src/runtime/app/env/types.d.ts +19 -0
- package/src/runtime/app/environment/index.js +8 -2
- package/src/runtime/app/server/remote/query.js +1 -1
- package/src/runtime/client/ndjson.js +6 -33
- package/src/runtime/client/remote-functions/prerender.svelte.js +1 -1
- package/src/runtime/client/remote-functions/query-live/iterator.js +36 -55
- package/src/runtime/client/sse.js +32 -0
- package/src/runtime/client/stream.js +38 -0
- package/src/runtime/client/utils.js +1 -1
- package/src/runtime/server/env_module.js +13 -3
- package/src/runtime/server/index.js +2 -0
- package/src/runtime/server/page/render.js +14 -3
- package/src/runtime/server/remote.js +2 -2
- package/src/runtime/server/respond.js +1 -1
- package/src/types/ambient-private.d.ts +25 -9
- package/src/types/global-private.d.ts +2 -0
- package/src/types/internal.d.ts +2 -1
- package/src/utils/error.js +12 -0
- package/src/utils/import.js +2 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +81 -3
- package/types/index.d.ts.map +11 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @import { EnvVarConfig } from '@sveltejs/kit' */
|
|
1
2
|
/** @import { Options, SvelteConfig } from '@sveltejs/vite-plugin-svelte' */
|
|
2
3
|
/** @import { PreprocessorGroup } from 'svelte/compiler' */
|
|
3
4
|
/** @import { KitConfig } from '@sveltejs/kit' */
|
|
@@ -6,11 +7,18 @@
|
|
|
6
7
|
import fs from 'node:fs';
|
|
7
8
|
import path from 'node:path';
|
|
8
9
|
import process from 'node:process';
|
|
9
|
-
|
|
10
10
|
import colors from 'kleur';
|
|
11
11
|
|
|
12
12
|
import { copy, mkdirp, posixify, read, resolve_entry, rimraf } from '../../utils/filesystem.js';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
create_dynamic_module,
|
|
15
|
+
create_sveltekit_env,
|
|
16
|
+
create_sveltekit_env_public,
|
|
17
|
+
create_static_module,
|
|
18
|
+
resolve_explicit_env_entry,
|
|
19
|
+
create_sveltekit_env_service_worker_dev,
|
|
20
|
+
create_sveltekit_env_private
|
|
21
|
+
} from '../../core/env.js';
|
|
14
22
|
import * as sync from '../../core/sync/sync.js';
|
|
15
23
|
import { create_assets } from '../../core/sync/create_manifest_data/index.js';
|
|
16
24
|
import { runtime_directory, logger } from '../../core/utils.js';
|
|
@@ -21,13 +29,8 @@ import { build_service_worker } from './build/build_service_worker.js';
|
|
|
21
29
|
import { assets_base, find_deps, resolve_symlinks } from './build/utils.js';
|
|
22
30
|
import { dev } from './dev/index.js';
|
|
23
31
|
import { preview } from './preview/index.js';
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
get_config_aliases,
|
|
27
|
-
get_env,
|
|
28
|
-
normalize_id,
|
|
29
|
-
stackless
|
|
30
|
-
} from './utils.js';
|
|
32
|
+
import { error_for_missing_config, get_config_aliases, get_env, normalize_id } from './utils.js';
|
|
33
|
+
import { stackless } from '../../utils/error.js';
|
|
31
34
|
import { write_client_manifest } from '../../core/sync/write_client_manifest.js';
|
|
32
35
|
import prerender from '../../core/postbuild/prerender.js';
|
|
33
36
|
import analyse from '../../core/postbuild/analyse.js';
|
|
@@ -40,8 +43,12 @@ import {
|
|
|
40
43
|
env_static_private,
|
|
41
44
|
env_static_public,
|
|
42
45
|
service_worker,
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
sveltekit_env,
|
|
47
|
+
sveltekit_env_private,
|
|
48
|
+
sveltekit_env_service_worker,
|
|
49
|
+
sveltekit_server,
|
|
50
|
+
sveltekit_env_public_client,
|
|
51
|
+
sveltekit_env_public_server
|
|
45
52
|
} from './module_ids.js';
|
|
46
53
|
import { import_peer } from '../../utils/import.js';
|
|
47
54
|
import { compact } from '../../utils/array.js';
|
|
@@ -237,7 +244,7 @@ async function kit({ svelte_config }) {
|
|
|
237
244
|
/** @type {boolean} */
|
|
238
245
|
let is_build;
|
|
239
246
|
|
|
240
|
-
/** @type {{ public: Record<string, string>; private: Record<string, string> }} */
|
|
247
|
+
/** @type {{ all: Record<string, string>; public: Record<string, string>; private: Record<string, string> }} */
|
|
241
248
|
let env;
|
|
242
249
|
|
|
243
250
|
/** @type {() => Promise<void>} */
|
|
@@ -350,7 +357,7 @@ async function kit({ svelte_config }) {
|
|
|
350
357
|
// because they for example use esbuild.build with `platform: 'browser'`
|
|
351
358
|
'esm-env',
|
|
352
359
|
// This forces `$app/*` modules to be bundled, since they depend on
|
|
353
|
-
// virtual modules like `__sveltekit/
|
|
360
|
+
// virtual modules like `__sveltekit/env` (this isn't a valid bare
|
|
354
361
|
// import, but it works with vite-node's externalization logic, which
|
|
355
362
|
// uses basic concatenation)
|
|
356
363
|
'@sveltejs/kit/src/runtime'
|
|
@@ -394,6 +401,7 @@ async function kit({ svelte_config }) {
|
|
|
394
401
|
|
|
395
402
|
const define = {
|
|
396
403
|
__SVELTEKIT_APP_DIR__: s(kit.appDir),
|
|
404
|
+
__SVELTEKIT_APP_VERSION__: s(kit.version.name),
|
|
397
405
|
__SVELTEKIT_EMBEDDED__: s(kit.embedded),
|
|
398
406
|
__SVELTEKIT_FORK_PRELOADS__: s(kit.experimental.forkPreloads),
|
|
399
407
|
__SVELTEKIT_PATHS_ASSETS__: s(kit.paths.assets),
|
|
@@ -403,6 +411,9 @@ async function kit({ svelte_config }) {
|
|
|
403
411
|
__SVELTEKIT_HASH_ROUTING__: s(kit.router.type === 'hash'),
|
|
404
412
|
__SVELTEKIT_SERVER_TRACING_ENABLED__: s(kit.experimental.tracing.server),
|
|
405
413
|
__SVELTEKIT_EXPERIMENTAL_USE_TRANSFORM_ERROR__: s(kit.experimental.handleRenderingErrors),
|
|
414
|
+
__SVELTEKIT_EXPERIMENTAL_EXPLICIT_ENVIRONMENT_VARIABLES__: s(
|
|
415
|
+
kit.experimental.explicitEnvironmentVariables
|
|
416
|
+
),
|
|
406
417
|
__SVELTEKIT_DEV__: s(!is_build)
|
|
407
418
|
};
|
|
408
419
|
|
|
@@ -471,10 +482,50 @@ async function kit({ svelte_config }) {
|
|
|
471
482
|
}
|
|
472
483
|
};
|
|
473
484
|
|
|
485
|
+
/** @type {string | null} */
|
|
486
|
+
let explicit_env_entry = null;
|
|
487
|
+
|
|
488
|
+
/** @type {Record<string, EnvVarConfig<any>> | null} */
|
|
489
|
+
let explicit_env_config = null;
|
|
490
|
+
|
|
474
491
|
/** @type {Plugin} */
|
|
475
492
|
const plugin_virtual_modules = {
|
|
476
493
|
name: 'vite-plugin-sveltekit-virtual-modules',
|
|
477
494
|
|
|
495
|
+
async configResolved(config) {
|
|
496
|
+
explicit_env_entry = resolve_explicit_env_entry(kit);
|
|
497
|
+
explicit_env_config = await sync.env(kit, explicit_env_entry, config.mode);
|
|
498
|
+
},
|
|
499
|
+
|
|
500
|
+
configureServer(server) {
|
|
501
|
+
if (!kit.experimental.explicitEnvironmentVariables) {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
server.watcher.on('all', async (_, file) => {
|
|
506
|
+
if (!file.includes('env')) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const resolved = resolve_explicit_env_entry(kit);
|
|
511
|
+
|
|
512
|
+
if (file === explicit_env_entry || file === resolved) {
|
|
513
|
+
explicit_env_entry = resolved;
|
|
514
|
+
explicit_env_config = await sync.env(kit, explicit_env_entry, vite_config_env.mode);
|
|
515
|
+
|
|
516
|
+
for (const id of [sveltekit_env, sveltekit_env_public_client]) {
|
|
517
|
+
const module = server.moduleGraph.getModuleById(id);
|
|
518
|
+
|
|
519
|
+
if (module) {
|
|
520
|
+
server.moduleGraph.invalidateModule(module);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
server.ws.send({ type: 'full-reload' });
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
},
|
|
528
|
+
|
|
478
529
|
resolveId(id, importer) {
|
|
479
530
|
if (id === '__sveltekit/manifest') {
|
|
480
531
|
return `${out_dir}/generated/client-optimized/app.js`;
|
|
@@ -484,6 +535,7 @@ async function kit({ svelte_config }) {
|
|
|
484
535
|
// This check won't catch transitive imports, but it will warn when the import comes from a service-worker directly.
|
|
485
536
|
// Transitive imports will be caught during the build.
|
|
486
537
|
// TODO move this logic to plugin_guard
|
|
538
|
+
// TODO allow $app/env/public
|
|
487
539
|
if (importer) {
|
|
488
540
|
const parsed_importer = path.parse(importer);
|
|
489
541
|
|
|
@@ -491,13 +543,19 @@ async function kit({ svelte_config }) {
|
|
|
491
543
|
parsed_importer.dir === parsed_service_worker.dir &&
|
|
492
544
|
parsed_importer.name === parsed_service_worker.name;
|
|
493
545
|
|
|
494
|
-
if (
|
|
546
|
+
if (
|
|
547
|
+
importer_is_service_worker &&
|
|
548
|
+
id !== '$service-worker' &&
|
|
549
|
+
id !== '$env/static/public' &&
|
|
550
|
+
id !== 'virtual:$app/env/public' &&
|
|
551
|
+
id !== '__sveltekit/env/service-worker'
|
|
552
|
+
) {
|
|
495
553
|
throw new Error(
|
|
496
554
|
`Cannot import ${normalize_id(
|
|
497
555
|
id,
|
|
498
556
|
normalized_lib,
|
|
499
557
|
normalized_cwd
|
|
500
|
-
)} into service-worker code. Only the modules $service-worker
|
|
558
|
+
)} into service-worker code. Only the modules $service-worker, $env/static/public and $app/env/public are available in service workers.`
|
|
501
559
|
);
|
|
502
560
|
}
|
|
503
561
|
}
|
|
@@ -524,17 +582,20 @@ async function kit({ svelte_config }) {
|
|
|
524
582
|
? `globalThis.__sveltekit_${version_hash}`
|
|
525
583
|
: 'globalThis.__sveltekit_dev';
|
|
526
584
|
|
|
585
|
+
const explicit_env_flag = kit.experimental.explicitEnvironmentVariables;
|
|
586
|
+
|
|
527
587
|
switch (id) {
|
|
528
588
|
case env_static_private:
|
|
529
|
-
return create_static_module('$env/static/private', env.private);
|
|
589
|
+
return create_static_module('$env/static/private', env.private, explicit_env_flag);
|
|
530
590
|
|
|
531
591
|
case env_static_public:
|
|
532
|
-
return create_static_module('$env/static/public', env.public);
|
|
592
|
+
return create_static_module('$env/static/public', env.public, explicit_env_flag);
|
|
533
593
|
|
|
534
594
|
case env_dynamic_private:
|
|
535
595
|
return create_dynamic_module(
|
|
536
596
|
'private',
|
|
537
|
-
vite_config_env.command === 'serve' ? env.private : undefined
|
|
597
|
+
vite_config_env.command === 'serve' ? env.private : undefined,
|
|
598
|
+
explicit_env_flag
|
|
538
599
|
);
|
|
539
600
|
|
|
540
601
|
case env_dynamic_public:
|
|
@@ -545,29 +606,35 @@ async function kit({ svelte_config }) {
|
|
|
545
606
|
|
|
546
607
|
return create_dynamic_module(
|
|
547
608
|
'public',
|
|
548
|
-
vite_config_env.command === 'serve' ? env.public : undefined
|
|
609
|
+
vite_config_env.command === 'serve' ? env.public : undefined,
|
|
610
|
+
explicit_env_flag
|
|
549
611
|
);
|
|
550
612
|
|
|
551
613
|
case service_worker:
|
|
552
614
|
return create_service_worker_module(svelte_config);
|
|
553
615
|
|
|
554
|
-
case
|
|
555
|
-
|
|
616
|
+
case sveltekit_env:
|
|
617
|
+
return create_sveltekit_env(explicit_env_config, env.all, explicit_env_entry);
|
|
556
618
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
619
|
+
case sveltekit_env_public_client:
|
|
620
|
+
return create_sveltekit_env_public(
|
|
621
|
+
explicit_env_config,
|
|
622
|
+
env.all,
|
|
623
|
+
`const env = ${global}.env;`
|
|
624
|
+
);
|
|
561
625
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
626
|
+
case sveltekit_env_public_server:
|
|
627
|
+
return create_sveltekit_env_public(
|
|
628
|
+
explicit_env_config,
|
|
629
|
+
env.all,
|
|
630
|
+
`import { rendered_env as env } from '__sveltekit/env';`
|
|
631
|
+
);
|
|
565
632
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
633
|
+
case sveltekit_env_private:
|
|
634
|
+
return create_sveltekit_env_private(explicit_env_config, env.all);
|
|
635
|
+
|
|
636
|
+
case sveltekit_env_service_worker:
|
|
637
|
+
return create_sveltekit_env_service_worker_dev(explicit_env_config, env.all, global);
|
|
571
638
|
|
|
572
639
|
case sveltekit_server: {
|
|
573
640
|
return dedent`
|
|
@@ -594,7 +661,7 @@ async function kit({ svelte_config }) {
|
|
|
594
661
|
|
|
595
662
|
/**
|
|
596
663
|
* Ensures that client-side code can't accidentally import server-side code,
|
|
597
|
-
* whether in `*.server.js` files, `$app/server`, `$lib/server`, or `$env/[static|dynamic]/private`
|
|
664
|
+
* whether in `*.server.js` files, `$app/server`, `$lib/server`, `$app/env/private`, or `$env/[static|dynamic]/private`
|
|
598
665
|
* @type {Plugin}
|
|
599
666
|
*/
|
|
600
667
|
const plugin_guard = {
|
|
@@ -636,6 +703,7 @@ async function kit({ svelte_config }) {
|
|
|
636
703
|
const is_server_only =
|
|
637
704
|
normalized === '$env/static/private' ||
|
|
638
705
|
normalized === '$env/dynamic/private' ||
|
|
706
|
+
normalized === '$app/env/private' ||
|
|
639
707
|
normalized === '$app/server' ||
|
|
640
708
|
normalized.startsWith('$lib/server/') ||
|
|
641
709
|
(is_internal && server_only_pattern.test(path.basename(id)));
|
|
@@ -843,6 +911,26 @@ async function kit({ svelte_config }) {
|
|
|
843
911
|
}
|
|
844
912
|
};
|
|
845
913
|
|
|
914
|
+
/** @type {Plugin} */
|
|
915
|
+
const plugin_service_worker_env = {
|
|
916
|
+
name: 'vite-plugin-sveltekit-service-worker-env',
|
|
917
|
+
|
|
918
|
+
transform: {
|
|
919
|
+
filter: {
|
|
920
|
+
id: service_worker_entry_file || '<skip>'
|
|
921
|
+
},
|
|
922
|
+
handler(code) {
|
|
923
|
+
// in dev, we prepend the service worker with an import that
|
|
924
|
+
// configures `env`, in case `$app/env/public` is imported,
|
|
925
|
+
// in prod, where we currently use non-module service
|
|
926
|
+
// workers, we have to use `importScripts` instead
|
|
927
|
+
return {
|
|
928
|
+
code: `import '__sveltekit/env/service-worker';\n${code}`
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
|
|
846
934
|
/** @type {Plugin} */
|
|
847
935
|
const plugin_compile = {
|
|
848
936
|
name: 'vite-plugin-sveltekit-compile',
|
|
@@ -1391,7 +1479,8 @@ async function kit({ svelte_config }) {
|
|
|
1391
1479
|
manifest_data,
|
|
1392
1480
|
service_worker_entry_file,
|
|
1393
1481
|
prerendered,
|
|
1394
|
-
client_manifest
|
|
1482
|
+
client_manifest,
|
|
1483
|
+
explicit_env_config
|
|
1395
1484
|
);
|
|
1396
1485
|
}
|
|
1397
1486
|
|
|
@@ -1414,7 +1503,8 @@ async function kit({ svelte_config }) {
|
|
|
1414
1503
|
prerender_map,
|
|
1415
1504
|
log,
|
|
1416
1505
|
remotes,
|
|
1417
|
-
vite_config
|
|
1506
|
+
vite_config,
|
|
1507
|
+
explicit_env_config
|
|
1418
1508
|
);
|
|
1419
1509
|
} else {
|
|
1420
1510
|
console.log(colors.bold().yellow('\nNo adapter specified'));
|
|
@@ -1447,6 +1537,9 @@ async function kit({ svelte_config }) {
|
|
|
1447
1537
|
kit.experimental.remoteFunctions && plugin_remote,
|
|
1448
1538
|
plugin_virtual_modules,
|
|
1449
1539
|
plugin_guard,
|
|
1540
|
+
kit.experimental.explicitEnvironmentVariables &&
|
|
1541
|
+
service_worker_entry_file &&
|
|
1542
|
+
plugin_service_worker_env,
|
|
1450
1543
|
plugin_compile
|
|
1451
1544
|
].filter((p) => !!p);
|
|
1452
1545
|
}
|
|
@@ -6,11 +6,20 @@ export const env_static_public = '\0virtual:env/static/public';
|
|
|
6
6
|
export const env_dynamic_private = '\0virtual:env/dynamic/private';
|
|
7
7
|
export const env_dynamic_public = '\0virtual:env/dynamic/public';
|
|
8
8
|
|
|
9
|
+
export const sveltekit_env = '\0virtual:__sveltekit/env';
|
|
10
|
+
export const sveltekit_env_public_client = '\0virtual:__sveltekit/env/public/client';
|
|
11
|
+
export const sveltekit_env_public_server = '\0virtual:__sveltekit/env/public/server';
|
|
12
|
+
export const sveltekit_env_private = '\0virtual:__sveltekit/env/private';
|
|
13
|
+
export const sveltekit_env_service_worker = '\0virtual:__sveltekit/env/service-worker';
|
|
14
|
+
|
|
9
15
|
export const service_worker = '\0virtual:service-worker';
|
|
10
16
|
|
|
11
|
-
export const sveltekit_environment = '\0virtual:__sveltekit/environment';
|
|
12
17
|
export const sveltekit_server = '\0virtual:__sveltekit/server';
|
|
13
18
|
|
|
14
19
|
export const app_server = posixify(
|
|
15
20
|
fileURLToPath(new URL('../../runtime/app/server/index.js', import.meta.url))
|
|
16
21
|
);
|
|
22
|
+
|
|
23
|
+
export const app_env_private = posixify(
|
|
24
|
+
fileURLToPath(new URL('../../runtime/app/env/private.js', import.meta.url))
|
|
25
|
+
);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
/** @import { PageOptions } from './types.js' */
|
|
1
2
|
import { tsPlugin } from '@sveltejs/acorn-typescript';
|
|
2
3
|
import { Parser } from 'acorn';
|
|
3
4
|
import { read } from '../../../utils/filesystem.js';
|
|
4
5
|
|
|
5
|
-
const valid_page_options_array = /** @type {const} */ ([
|
|
6
|
+
export const valid_page_options_array = /** @type {const} */ ([
|
|
6
7
|
'ssr',
|
|
7
8
|
'prerender',
|
|
8
9
|
'csr',
|
|
@@ -15,9 +16,6 @@ const valid_page_options_array = /** @type {const} */ ([
|
|
|
15
16
|
/** @type {Set<string>} */
|
|
16
17
|
const valid_page_options = new Set(valid_page_options_array);
|
|
17
18
|
|
|
18
|
-
/** @typedef {typeof valid_page_options_array[number]} ValidPageOption */
|
|
19
|
-
/** @typedef {Partial<Record<ValidPageOption, any>>} PageOptions */
|
|
20
|
-
|
|
21
19
|
const skip_parsing_regex = new RegExp(
|
|
22
20
|
`${Array.from(valid_page_options).join('|')}|(?:export[\\s\\n]+\\*[\\s\\n]+from)`
|
|
23
21
|
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PrerenderOption, TrailingSlash } from 'types';
|
|
2
|
+
import type { valid_page_options_array } from './index.js';
|
|
3
|
+
|
|
4
|
+
type ValidPageOption = (typeof valid_page_options_array)[number];
|
|
5
|
+
|
|
6
|
+
export type PageOptions = Partial<{
|
|
7
|
+
[K in ValidPageOption]: K extends 'ssr' | 'csr'
|
|
8
|
+
? boolean
|
|
9
|
+
: K extends 'prerender'
|
|
10
|
+
? PrerenderOption
|
|
11
|
+
: K extends 'trailingSlash'
|
|
12
|
+
? TrailingSlash
|
|
13
|
+
: any;
|
|
14
|
+
}>;
|
|
@@ -4,9 +4,11 @@ import { posixify } from '../../utils/filesystem.js';
|
|
|
4
4
|
import { negotiate } from '../../utils/http.js';
|
|
5
5
|
import { filter_env } from '../../utils/env.js';
|
|
6
6
|
import { escape_html } from '../../utils/escape.js';
|
|
7
|
+
import { stackless } from '../../utils/error.js';
|
|
7
8
|
import { dedent } from '../../core/sync/utils.js';
|
|
8
9
|
import {
|
|
9
10
|
app_server,
|
|
11
|
+
app_env_private,
|
|
10
12
|
env_dynamic_private,
|
|
11
13
|
env_dynamic_public,
|
|
12
14
|
env_static_private,
|
|
@@ -71,6 +73,7 @@ export function get_env(env_config, mode) {
|
|
|
71
73
|
const env = loadEnv(mode, env_config.dir, '');
|
|
72
74
|
|
|
73
75
|
return {
|
|
76
|
+
all: env,
|
|
74
77
|
public: filter_env(env, public_prefix, private_prefix),
|
|
75
78
|
private: filter_env(env, private_prefix, public_prefix)
|
|
76
79
|
};
|
|
@@ -155,6 +158,10 @@ export function normalize_id(id, lib, cwd) {
|
|
|
155
158
|
return '$app/server';
|
|
156
159
|
}
|
|
157
160
|
|
|
161
|
+
if (id === app_env_private) {
|
|
162
|
+
return '$app/env/private';
|
|
163
|
+
}
|
|
164
|
+
|
|
158
165
|
if (id === env_static_private) {
|
|
159
166
|
return '$env/static/private';
|
|
160
167
|
}
|
|
@@ -178,18 +185,6 @@ export function normalize_id(id, lib, cwd) {
|
|
|
178
185
|
return posixify(id);
|
|
179
186
|
}
|
|
180
187
|
|
|
181
|
-
/**
|
|
182
|
-
* For times when you need to throw an error, but without
|
|
183
|
-
* displaying a useless stack trace (since the developer
|
|
184
|
-
* can't do anything useful with it)
|
|
185
|
-
* @param {string} message
|
|
186
|
-
*/
|
|
187
|
-
export function stackless(message) {
|
|
188
|
-
const error = new Error(message);
|
|
189
|
-
error.stack = '';
|
|
190
|
-
return error;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
188
|
export const strip_virtual_prefix = /** @param {string} id */ (id) => id.replace('\0virtual:', '');
|
|
194
189
|
|
|
195
190
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '__sveltekit/env/private';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '#app/env/public';
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `true` if the app is running in the browser.
|
|
3
|
+
*/
|
|
4
|
+
export const browser: boolean;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Whether the dev server is running. This is not guaranteed to correspond to `NODE_ENV` or `MODE`.
|
|
8
|
+
*/
|
|
9
|
+
export const dev: boolean;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SvelteKit analyses your app during the `build` step by running it. During this process, `building` is `true`. This also applies during prerendering.
|
|
13
|
+
*/
|
|
14
|
+
export const building: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The value of `config.kit.version.name`.
|
|
18
|
+
*/
|
|
19
|
+
export const version: string;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import { dev } from '../env/index.js';
|
|
2
|
+
export * from '../env/index.js';
|
|
3
|
+
|
|
4
|
+
if (dev && __SVELTEKIT_EXPERIMENTAL_EXPLICIT_ENVIRONMENT_VARIABLES__) {
|
|
5
|
+
console.warn(
|
|
6
|
+
'Use `$app/env` instead of `$app/environment` when `experimental.explicitEnvironmentVariables` is enabled'
|
|
7
|
+
);
|
|
8
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
4
4
|
import { get_request_store } from '@sveltejs/kit/internal/server';
|
|
5
5
|
import { create_remote_key, stringify, stringify_remote_arg } from '../../../shared.js';
|
|
6
|
-
import { prerendering } from '
|
|
6
|
+
import { prerendering } from '$app/env/internal';
|
|
7
7
|
import {
|
|
8
8
|
create_validator,
|
|
9
9
|
get_cache,
|
|
@@ -1,42 +1,15 @@
|
|
|
1
|
+
import { read_stream } from './stream.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Yields parsed JSON objects from a ReadableStream of newline-delimited JSON.
|
|
3
5
|
* Each yielded value is the raw `JSON.parse`'d object — callers handle deserialization.
|
|
4
6
|
* @param {ReadableStreamDefaultReader<Uint8Array>} reader
|
|
5
7
|
*/
|
|
6
8
|
export async function* read_ndjson(reader) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
while (true) {
|
|
12
|
-
let split = buffer.indexOf('\n');
|
|
13
|
-
while (split !== -1) {
|
|
14
|
-
const line = buffer.slice(0, split).trim();
|
|
15
|
-
buffer = buffer.slice(split + 1);
|
|
16
|
-
|
|
17
|
-
if (line) {
|
|
18
|
-
yield JSON.parse(line);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
split = buffer.indexOf('\n');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (done) {
|
|
25
|
-
const line = buffer.trim();
|
|
26
|
-
if (line) {
|
|
27
|
-
yield JSON.parse(line);
|
|
28
|
-
}
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const chunk = await reader.read();
|
|
33
|
-
done = chunk.done;
|
|
34
|
-
if (chunk.value) {
|
|
35
|
-
buffer += decoder.decode(chunk.value, { stream: true });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (done) {
|
|
39
|
-
buffer += decoder.decode();
|
|
9
|
+
for await (const block of read_stream(reader, '\n')) {
|
|
10
|
+
const line = block.trim();
|
|
11
|
+
if (line) {
|
|
12
|
+
yield JSON.parse(line);
|
|
40
13
|
}
|
|
41
14
|
}
|
|
42
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @import { RemotePrerenderFunction } from '@sveltejs/kit' */
|
|
2
2
|
import { app_dir, base } from '$app/paths/internal/client';
|
|
3
|
-
import { version } from '
|
|
3
|
+
import { version } from '$app/env';
|
|
4
4
|
import * as devalue from 'devalue';
|
|
5
5
|
import { app, prerender_responses } from '../client.js';
|
|
6
6
|
import { get_remote_request_headers, remote_request } from './shared.svelte.js';
|