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

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 (138) hide show
  1. package/README.md +12 -9
  2. package/package.json +94 -52
  3. package/postinstall.js +38 -0
  4. package/scripts/special-types/$env+dynamic+private.md +10 -0
  5. package/scripts/special-types/$env+dynamic+public.md +8 -0
  6. package/scripts/special-types/$env+static+private.md +19 -0
  7. package/scripts/special-types/$env+static+public.md +7 -0
  8. package/scripts/special-types/$lib.md +5 -0
  9. package/src/cli.js +108 -0
  10. package/src/constants.js +7 -0
  11. package/src/core/adapt/builder.js +206 -0
  12. package/src/core/adapt/index.js +31 -0
  13. package/src/core/config/default-error.html +56 -0
  14. package/src/core/config/index.js +110 -0
  15. package/src/core/config/options.js +504 -0
  16. package/src/core/config/types.d.ts +1 -0
  17. package/src/core/env.js +121 -0
  18. package/src/core/generate_manifest/index.js +93 -0
  19. package/src/core/prerender/crawl.js +198 -0
  20. package/src/core/prerender/entities.js +2252 -0
  21. package/src/core/prerender/prerender.js +431 -0
  22. package/src/core/prerender/queue.js +80 -0
  23. package/src/core/sync/create_manifest_data/index.js +488 -0
  24. package/src/core/sync/create_manifest_data/types.d.ts +37 -0
  25. package/src/core/sync/sync.js +70 -0
  26. package/src/core/sync/utils.js +33 -0
  27. package/src/core/sync/write_ambient.js +53 -0
  28. package/src/core/sync/write_client_manifest.js +106 -0
  29. package/src/core/sync/write_matchers.js +25 -0
  30. package/src/core/sync/write_root.js +91 -0
  31. package/src/core/sync/write_tsconfig.js +195 -0
  32. package/src/core/sync/write_types/index.js +678 -0
  33. package/src/core/utils.js +70 -0
  34. package/src/exports/hooks/index.js +1 -0
  35. package/src/exports/hooks/sequence.js +44 -0
  36. package/src/exports/index.js +45 -0
  37. package/src/exports/node/index.js +173 -0
  38. package/src/exports/node/polyfills.js +41 -0
  39. package/src/exports/vite/build/build_server.js +378 -0
  40. package/src/exports/vite/build/build_service_worker.js +90 -0
  41. package/src/exports/vite/build/utils.js +180 -0
  42. package/src/exports/vite/dev/index.js +577 -0
  43. package/src/exports/vite/graph_analysis/index.js +277 -0
  44. package/src/exports/vite/graph_analysis/types.d.ts +5 -0
  45. package/src/exports/vite/graph_analysis/utils.js +30 -0
  46. package/src/exports/vite/index.js +598 -0
  47. package/src/exports/vite/preview/index.js +189 -0
  48. package/src/exports/vite/types.d.ts +3 -0
  49. package/src/exports/vite/utils.js +157 -0
  50. package/src/runtime/app/env.js +1 -0
  51. package/src/runtime/app/environment.js +11 -0
  52. package/src/runtime/app/forms.js +114 -0
  53. package/src/runtime/app/navigation.js +23 -0
  54. package/src/runtime/app/paths.js +1 -0
  55. package/src/runtime/app/stores.js +102 -0
  56. package/src/runtime/client/ambient.d.ts +26 -0
  57. package/src/runtime/client/client.js +1583 -0
  58. package/src/runtime/client/fetcher.js +107 -0
  59. package/src/runtime/client/parse.js +60 -0
  60. package/src/runtime/client/singletons.js +21 -0
  61. package/src/runtime/client/start.js +37 -0
  62. package/src/runtime/client/types.d.ts +84 -0
  63. package/src/runtime/client/utils.js +159 -0
  64. package/src/runtime/components/error.svelte +16 -0
  65. package/{assets → src/runtime}/components/layout.svelte +0 -0
  66. package/src/runtime/control.js +98 -0
  67. package/src/runtime/env/dynamic/private.js +1 -0
  68. package/src/runtime/env/dynamic/public.js +1 -0
  69. package/src/runtime/env-private.js +6 -0
  70. package/src/runtime/env-public.js +6 -0
  71. package/src/runtime/env.js +6 -0
  72. package/src/runtime/hash.js +16 -0
  73. package/src/runtime/paths.js +11 -0
  74. package/src/runtime/server/cookie.js +127 -0
  75. package/src/runtime/server/data/index.js +136 -0
  76. package/src/runtime/server/endpoint.js +90 -0
  77. package/src/runtime/server/index.js +340 -0
  78. package/src/runtime/server/page/actions.js +243 -0
  79. package/src/runtime/server/page/crypto.js +239 -0
  80. package/src/runtime/server/page/csp.js +250 -0
  81. package/src/runtime/server/page/fetch.js +301 -0
  82. package/src/runtime/server/page/index.js +304 -0
  83. package/src/runtime/server/page/load_data.js +124 -0
  84. package/src/runtime/server/page/render.js +342 -0
  85. package/src/runtime/server/page/respond_with_error.js +104 -0
  86. package/src/runtime/server/page/serialize_data.js +87 -0
  87. package/src/runtime/server/page/types.d.ts +41 -0
  88. package/src/runtime/server/utils.js +179 -0
  89. package/src/utils/array.js +9 -0
  90. package/src/utils/error.js +22 -0
  91. package/src/utils/escape.js +46 -0
  92. package/src/utils/filesystem.js +137 -0
  93. package/src/utils/functions.js +16 -0
  94. package/src/utils/http.js +55 -0
  95. package/src/utils/misc.js +1 -0
  96. package/src/utils/routing.js +117 -0
  97. package/src/utils/unit_test.js +11 -0
  98. package/src/utils/url.js +142 -0
  99. package/svelte-kit.js +2 -0
  100. package/types/ambient.d.ts +426 -0
  101. package/types/index.d.ts +444 -0
  102. package/types/internal.d.ts +378 -0
  103. package/types/private.d.ts +224 -0
  104. package/CHANGELOG.md +0 -177
  105. package/assets/components/error.svelte +0 -13
  106. package/assets/runtime/app/navigation.js +0 -47
  107. package/assets/runtime/app/navigation.js.map +0 -1
  108. package/assets/runtime/app/stores.js +0 -78
  109. package/assets/runtime/app/stores.js.map +0 -1
  110. package/assets/runtime/internal/singletons.js +0 -10
  111. package/assets/runtime/internal/singletons.js.map +0 -1
  112. package/assets/runtime/internal/start.js +0 -517
  113. package/assets/runtime/internal/start.js.map +0 -1
  114. package/dist/api.js +0 -40
  115. package/dist/api.js.map +0 -1
  116. package/dist/cli.js +0 -128
  117. package/dist/cli.js.map +0 -1
  118. package/dist/create_app.js +0 -550
  119. package/dist/create_app.js.map +0 -1
  120. package/dist/index.js +0 -8331
  121. package/dist/index.js.map +0 -1
  122. package/dist/index2.js +0 -509
  123. package/dist/index2.js.map +0 -1
  124. package/dist/index3.js +0 -63
  125. package/dist/index3.js.map +0 -1
  126. package/dist/index4.js +0 -466
  127. package/dist/index4.js.map +0 -1
  128. package/dist/index5.js +0 -276
  129. package/dist/index5.js.map +0 -1
  130. package/dist/package.js +0 -235
  131. package/dist/package.js.map +0 -1
  132. package/dist/renderer.js +0 -2398
  133. package/dist/renderer.js.map +0 -1
  134. package/dist/standard.js +0 -101
  135. package/dist/standard.js.map +0 -1
  136. package/dist/utils.js +0 -58
  137. package/dist/utils.js.map +0 -1
  138. package/svelte-kit +0 -3
@@ -0,0 +1,189 @@
1
+ import fs from 'fs';
2
+ import { join } from 'path';
3
+ import sirv from 'sirv';
4
+ import { pathToFileURL } from 'url';
5
+ import { getRequest, setResponse } from '../../../exports/node/index.js';
6
+ import { installPolyfills } from '../../../exports/node/polyfills.js';
7
+ import { SVELTE_KIT_ASSETS } from '../../../constants.js';
8
+ import { loadEnv } from 'vite';
9
+
10
+ /** @typedef {import('http').IncomingMessage} Req */
11
+ /** @typedef {import('http').ServerResponse} Res */
12
+ /** @typedef {(req: Req, res: Res, next: () => void) => void} Handler */
13
+
14
+ /**
15
+ * @param {{
16
+ * middlewares: import('connect').Server;
17
+ * httpServer: import('http').Server;
18
+ * }} vite
19
+ * @param {import('vite').ResolvedConfig} vite_config
20
+ * @param {import('types').ValidatedConfig} svelte_config
21
+ */
22
+ export async function preview(vite, vite_config, svelte_config) {
23
+ installPolyfills();
24
+
25
+ const { paths } = svelte_config.kit;
26
+ const base = paths.base;
27
+ const assets = paths.assets ? SVELTE_KIT_ASSETS : paths.base;
28
+
29
+ const protocol = vite_config.preview.https ? 'https' : 'http';
30
+
31
+ const etag = `"${Date.now()}"`;
32
+
33
+ const index_file = join(svelte_config.kit.outDir, 'output/server/index.js');
34
+ const manifest_file = join(svelte_config.kit.outDir, 'output/server/manifest.js');
35
+
36
+ /** @type {import('types').ServerModule} */
37
+ const { Server, override } = await import(pathToFileURL(index_file).href);
38
+ const { manifest } = await import(pathToFileURL(manifest_file).href);
39
+
40
+ override({
41
+ paths: { base, assets },
42
+ prerendering: false,
43
+ protocol,
44
+ read: (file) => fs.readFileSync(join(svelte_config.kit.files.assets, file))
45
+ });
46
+
47
+ const server = new Server(manifest);
48
+ await server.init({
49
+ env: loadEnv(vite_config.mode, process.cwd(), '')
50
+ });
51
+
52
+ return () => {
53
+ // generated client assets and the contents of `static`
54
+ vite.middlewares.use(
55
+ scoped(
56
+ assets,
57
+ sirv(join(svelte_config.kit.outDir, 'output/client'), {
58
+ setHeaders: (res, pathname) => {
59
+ // only apply to immutable directory, not e.g. version.json
60
+ if (pathname.startsWith(`/${svelte_config.kit.appDir}/immutable`)) {
61
+ res.setHeader('cache-control', 'public,max-age=31536000,immutable');
62
+ }
63
+ }
64
+ })
65
+ )
66
+ );
67
+
68
+ vite.middlewares.use((req, res, next) => {
69
+ const original_url = /** @type {string} */ (req.url);
70
+ const { pathname } = new URL(original_url, 'http://dummy');
71
+
72
+ if (pathname.startsWith(base)) {
73
+ next();
74
+ } else {
75
+ res.statusCode = 404;
76
+ res.end(`Not found (did you mean ${base + pathname}?)`);
77
+ }
78
+ });
79
+
80
+ // prerendered dependencies
81
+ vite.middlewares.use(
82
+ scoped(base, mutable(join(svelte_config.kit.outDir, 'output/prerendered/dependencies')))
83
+ );
84
+
85
+ // prerendered pages (we can't just use sirv because we need to
86
+ // preserve the correct trailingSlash behaviour)
87
+ vite.middlewares.use(
88
+ scoped(base, (req, res, next) => {
89
+ let if_none_match_value = req.headers['if-none-match'];
90
+
91
+ if (if_none_match_value?.startsWith('W/"')) {
92
+ if_none_match_value = if_none_match_value.substring(2);
93
+ }
94
+
95
+ if (if_none_match_value === etag) {
96
+ res.statusCode = 304;
97
+ res.end();
98
+ return;
99
+ }
100
+
101
+ const { pathname } = new URL(/** @type {string} */ (req.url), 'http://dummy');
102
+
103
+ // only treat this as a page if it doesn't include an extension
104
+ if (pathname === '/' || /\/[^./]+\/?$/.test(pathname)) {
105
+ const file = join(
106
+ svelte_config.kit.outDir,
107
+ 'output/prerendered/pages' +
108
+ pathname +
109
+ (pathname.endsWith('/') ? 'index.html' : '.html')
110
+ );
111
+
112
+ if (fs.existsSync(file)) {
113
+ res.writeHead(200, {
114
+ 'content-type': 'text/html',
115
+ etag
116
+ });
117
+
118
+ fs.createReadStream(file).pipe(res);
119
+ return;
120
+ }
121
+ }
122
+
123
+ next();
124
+ })
125
+ );
126
+
127
+ // SSR
128
+ vite.middlewares.use(async (req, res) => {
129
+ const host = req.headers['host'];
130
+
131
+ let request;
132
+
133
+ try {
134
+ request = await getRequest({
135
+ base: `${protocol}://${host}`,
136
+ request: req
137
+ });
138
+ } catch (/** @type {any} */ err) {
139
+ res.statusCode = err.status || 400;
140
+ return res.end('Invalid request body');
141
+ }
142
+
143
+ setResponse(
144
+ res,
145
+ await server.respond(request, {
146
+ getClientAddress: () => {
147
+ const { remoteAddress } = req.socket;
148
+ if (remoteAddress) return remoteAddress;
149
+ throw new Error('Could not determine clientAddress');
150
+ }
151
+ })
152
+ );
153
+ });
154
+ };
155
+ }
156
+
157
+ /**
158
+ * @param {string} dir
159
+ * @returns {Handler}
160
+ */
161
+ const mutable = (dir) =>
162
+ fs.existsSync(dir)
163
+ ? sirv(dir, {
164
+ etag: true,
165
+ maxAge: 0
166
+ })
167
+ : (_req, _res, next) => next();
168
+
169
+ /**
170
+ * @param {string} scope
171
+ * @param {Handler} handler
172
+ * @returns {Handler}
173
+ */
174
+ function scoped(scope, handler) {
175
+ if (scope === '') return handler;
176
+
177
+ return (req, res, next) => {
178
+ if (req.url?.startsWith(scope)) {
179
+ const original_url = req.url;
180
+ req.url = req.url.slice(scope.length);
181
+ handler(req, res, () => {
182
+ req.url = original_url;
183
+ next();
184
+ });
185
+ } else {
186
+ next();
187
+ }
188
+ };
189
+ }
@@ -0,0 +1,3 @@
1
+ export interface EnforcedConfig {
2
+ [key: string]: EnforcedConfig | true;
3
+ }
@@ -0,0 +1,157 @@
1
+ import path from 'path';
2
+ import { loadConfigFromFile, loadEnv } from 'vite';
3
+ import { runtime_directory } from '../../core/utils.js';
4
+ import { posixify } from '../../utils/filesystem.js';
5
+
6
+ /**
7
+ * @param {import('vite').ResolvedConfig} config
8
+ * @param {import('vite').ConfigEnv} config_env
9
+ * @return {Promise<import('vite').UserConfig>}
10
+ */
11
+ export async function get_vite_config(config, config_env) {
12
+ const loaded = await loadConfigFromFile(
13
+ config_env,
14
+ config.configFile,
15
+ undefined,
16
+ config.logLevel
17
+ );
18
+
19
+ if (!loaded) {
20
+ throw new Error('Could not load Vite config');
21
+ }
22
+ return { ...loaded.config, mode: config_env.mode };
23
+ }
24
+
25
+ /**
26
+ * @param {...import('vite').UserConfig} configs
27
+ * @returns {import('vite').UserConfig}
28
+ */
29
+ export function merge_vite_configs(...configs) {
30
+ return deep_merge(
31
+ ...configs.map((config) => ({
32
+ ...config,
33
+ resolve: {
34
+ ...config.resolve,
35
+ alias: normalize_alias(config.resolve?.alias || {})
36
+ }
37
+ }))
38
+ );
39
+ }
40
+
41
+ /**
42
+ * Takes zero or more objects and returns a new object that has all the values
43
+ * deeply merged together. None of the original objects will be mutated at any
44
+ * level, and the returned object will have no references to the original
45
+ * objects at any depth. If there's a conflict the last one wins, except for
46
+ * arrays which will be combined.
47
+ * @param {...Object} objects
48
+ * @returns {Record<string, any>} the merged object
49
+ */
50
+ export function deep_merge(...objects) {
51
+ const result = {};
52
+ /** @type {string[]} */
53
+ objects.forEach((o) => merge_into(result, o));
54
+ return result;
55
+ }
56
+
57
+ /**
58
+ * normalize kit.vite.resolve.alias as an array
59
+ * @param {import('vite').AliasOptions} o
60
+ * @returns {import('vite').Alias[]}
61
+ */
62
+ function normalize_alias(o) {
63
+ if (Array.isArray(o)) return o;
64
+ return Object.entries(o).map(([find, replacement]) => ({ find, replacement }));
65
+ }
66
+
67
+ /**
68
+ * Merges b into a, recursively, mutating a.
69
+ * @param {Record<string, any>} a
70
+ * @param {Record<string, any>} b
71
+ */
72
+ function merge_into(a, b) {
73
+ /**
74
+ * Checks for "plain old Javascript object", typically made as an object
75
+ * literal. Excludes Arrays and built-in types like Buffer.
76
+ * @param {any} x
77
+ */
78
+ const is_plain_object = (x) => typeof x === 'object' && x.constructor === Object;
79
+
80
+ for (const prop in b) {
81
+ if (is_plain_object(b[prop])) {
82
+ if (!is_plain_object(a[prop])) {
83
+ a[prop] = {};
84
+ }
85
+ merge_into(a[prop], b[prop]);
86
+ } else if (Array.isArray(b[prop])) {
87
+ if (!Array.isArray(a[prop])) {
88
+ a[prop] = [];
89
+ }
90
+ a[prop].push(...b[prop]);
91
+ } else {
92
+ a[prop] = b[prop];
93
+ }
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Transforms kit.alias to a valid vite.resolve.alias array.
99
+ * Related to tsconfig path alias creation.
100
+ *
101
+ * @param {import('types').ValidatedKitConfig} config
102
+ * */
103
+ export function get_aliases(config) {
104
+ /** @type {import('vite').Alias[]} */
105
+ const alias = [
106
+ { find: '__GENERATED__', replacement: path.posix.join(config.outDir, 'generated') },
107
+ { find: '$app', replacement: `${runtime_directory}/app` },
108
+ // For now, we handle `$lib` specially here rather than make it a default value for
109
+ // `config.kit.alias` since it has special meaning for packaging, etc.
110
+ { find: '$lib', replacement: config.files.lib }
111
+ ];
112
+
113
+ for (let [key, value] of Object.entries(config.alias)) {
114
+ value = posixify(value);
115
+ if (value.endsWith('/*')) {
116
+ value = value.slice(0, -2);
117
+ }
118
+ if (key.endsWith('/*')) {
119
+ // Doing just `{ find: key.slice(0, -2) ,..}` would mean `import .. from "key"` would also be matched, which we don't want
120
+ alias.push({
121
+ find: new RegExp(`^${escape_for_regexp(key.slice(0, -2))}\\/(.+)$`),
122
+ replacement: `${path.resolve(value)}/$1`
123
+ });
124
+ } else if (key + '/*' in config.alias) {
125
+ // key and key/* both exist -> the replacement for key needs to happen _only_ on import .. from "key"
126
+ alias.push({
127
+ find: new RegExp(`^${escape_for_regexp(key)}$`),
128
+ replacement: path.resolve(value)
129
+ });
130
+ } else {
131
+ alias.push({ find: key, replacement: path.resolve(value) });
132
+ }
133
+ }
134
+
135
+ return alias;
136
+ }
137
+
138
+ /**
139
+ * @param {string} str
140
+ */
141
+ function escape_for_regexp(str) {
142
+ return str.replace(/[.*+?^${}()|[\]\\]/g, (match) => '\\' + match);
143
+ }
144
+
145
+ /**
146
+ * Load environment variables from process.env and .env files
147
+ * @param {import('types').ValidatedKitConfig['env']} env_config
148
+ * @param {string} mode
149
+ */
150
+ export function get_env(env_config, mode) {
151
+ const entries = Object.entries(loadEnv(mode, env_config.dir, ''));
152
+
153
+ return {
154
+ public: Object.fromEntries(entries.filter(([k]) => k.startsWith(env_config.publicPrefix))),
155
+ private: Object.fromEntries(entries.filter(([k]) => !k.startsWith(env_config.publicPrefix)))
156
+ };
157
+ }
@@ -0,0 +1 @@
1
+ throw new Error('$app/env has been renamed to $app/environment');
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @type {import('$app/environment').browser}
3
+ */
4
+ export const browser = !import.meta.env.SSR;
5
+
6
+ /**
7
+ * @type {import('$app/environment').dev}
8
+ */
9
+ export const dev = __SVELTEKIT_DEV__;
10
+
11
+ export { prerendering } from '../env.js';
@@ -0,0 +1,114 @@
1
+ import { invalidateAll } from './navigation.js';
2
+ import { client } from '../client/singletons.js';
3
+
4
+ /**
5
+ * @param {string} name
6
+ */
7
+ function guard(name) {
8
+ return () => {
9
+ throw new Error(`Cannot call ${name}(...) on the server`);
10
+ };
11
+ }
12
+
13
+ const ssr = import.meta.env.SSR;
14
+
15
+ /** @type {import('$app/forms').applyAction} */
16
+ export const applyAction = ssr ? guard('applyAction') : client.apply_action;
17
+
18
+ /** @type {import('$app/forms').enhance} */
19
+ export function enhance(form, submit = () => {}) {
20
+ /**
21
+ * @param {{
22
+ * action: URL;
23
+ * result: import('types').ActionResult;
24
+ * }} opts
25
+ */
26
+ const fallback_callback = async ({ action, result }) => {
27
+ if (result.type === 'success') {
28
+ await invalidateAll();
29
+ }
30
+
31
+ // For success/invalid results, only apply action if it belongs to the
32
+ // current page, otherwise `form` will be updated erroneously
33
+ if (
34
+ location.origin + location.pathname === action.origin + action.pathname ||
35
+ result.type === 'redirect' ||
36
+ result.type === 'error'
37
+ ) {
38
+ applyAction(result);
39
+ }
40
+ };
41
+
42
+ /** @param {SubmitEvent} event */
43
+ async function handle_submit(event) {
44
+ event.preventDefault();
45
+
46
+ const action = new URL(
47
+ // We can't do submitter.formAction directly because that property is always set
48
+ event.submitter?.hasAttribute('formaction')
49
+ ? /** @type {HTMLButtonElement | HTMLInputElement} */ (event.submitter).formAction
50
+ : form.action
51
+ );
52
+
53
+ const data = new FormData(form);
54
+ const controller = new AbortController();
55
+
56
+ let cancelled = false;
57
+ const cancel = () => (cancelled = true);
58
+
59
+ const callback =
60
+ submit({
61
+ action,
62
+ cancel,
63
+ controller,
64
+ data,
65
+ form
66
+ }) ?? fallback_callback;
67
+ if (cancelled) return;
68
+
69
+ /** @type {import('types').ActionResult} */
70
+ let result;
71
+
72
+ try {
73
+ const response = await fetch(action, {
74
+ method: 'POST',
75
+ headers: {
76
+ accept: 'application/json'
77
+ },
78
+ body: data,
79
+ signal: controller.signal
80
+ });
81
+
82
+ result = await response.json();
83
+ } catch (error) {
84
+ if (/** @type {any} */ (error)?.name === 'AbortError') return;
85
+ result = { type: 'error', error };
86
+ }
87
+
88
+ callback({
89
+ action,
90
+ data,
91
+ form,
92
+ // @ts-expect-error generic constraints stuff we don't care about
93
+ result,
94
+ // TODO remove for 1.0
95
+ get type() {
96
+ throw new Error('(result) => {...} has changed to ({ result }) => {...}');
97
+ },
98
+ get location() {
99
+ throw new Error('(result) => {...} has changed to ({ result }) => {...}');
100
+ },
101
+ get error() {
102
+ throw new Error('(result) => {...} has changed to ({ result }) => {...}');
103
+ }
104
+ });
105
+ }
106
+
107
+ form.addEventListener('submit', handle_submit);
108
+
109
+ return {
110
+ destroy() {
111
+ form.removeEventListener('submit', handle_submit);
112
+ }
113
+ };
114
+ }
@@ -0,0 +1,23 @@
1
+ import { client } from '../client/singletons.js';
2
+
3
+ /**
4
+ * @param {string} name
5
+ */
6
+ function guard(name) {
7
+ return () => {
8
+ throw new Error(`Cannot call ${name}(...) on the server`);
9
+ };
10
+ }
11
+
12
+ const ssr = import.meta.env.SSR;
13
+
14
+ export const disableScrollHandling = ssr
15
+ ? guard('disableScrollHandling')
16
+ : client.disable_scroll_handling;
17
+ export const goto = ssr ? guard('goto') : client.goto;
18
+ export const invalidate = ssr ? guard('invalidate') : client.invalidate;
19
+ export const invalidateAll = ssr ? guard('invalidateAll') : client.invalidateAll;
20
+ export const prefetch = ssr ? guard('prefetch') : client.prefetch;
21
+ export const prefetchRoutes = ssr ? guard('prefetchRoutes') : client.prefetch_routes;
22
+ export const beforeNavigate = ssr ? () => {} : client.before_navigate;
23
+ export const afterNavigate = ssr ? () => {} : client.after_navigate;
@@ -0,0 +1 @@
1
+ export { base, assets } from '../paths.js';
@@ -0,0 +1,102 @@
1
+ import { getContext } from 'svelte';
2
+ import { browser } from './environment.js';
3
+ import { stores as browser_stores } from '../client/singletons.js';
4
+
5
+ // TODO remove this (for 1.0? after 1.0?)
6
+ let warned = false;
7
+ export function stores() {
8
+ if (!warned) {
9
+ console.error('stores() is deprecated; use getStores() instead');
10
+ warned = true;
11
+ }
12
+ return getStores();
13
+ }
14
+
15
+ /**
16
+ * @type {import('$app/stores').getStores}
17
+ */
18
+ export const getStores = () => {
19
+ const stores = browser ? browser_stores : getContext('__svelte__');
20
+
21
+ const readonly_stores = {
22
+ page: {
23
+ subscribe: stores.page.subscribe
24
+ },
25
+ navigating: {
26
+ subscribe: stores.navigating.subscribe
27
+ },
28
+ updated: stores.updated
29
+ };
30
+
31
+ // TODO remove this for 1.0
32
+ Object.defineProperties(readonly_stores, {
33
+ preloading: {
34
+ get() {
35
+ console.error('stores.preloading is deprecated; use stores.navigating instead');
36
+ return {
37
+ subscribe: stores.navigating.subscribe
38
+ };
39
+ },
40
+ enumerable: false
41
+ },
42
+ session: {
43
+ get() {
44
+ removed_session();
45
+ return {};
46
+ },
47
+ enumerable: false
48
+ }
49
+ });
50
+
51
+ return readonly_stores;
52
+ };
53
+
54
+ /** @type {typeof import('$app/stores').page} */
55
+ export const page = {
56
+ /** @param {(value: any) => void} fn */
57
+ subscribe(fn) {
58
+ const store = getStores().page;
59
+ return store.subscribe(fn);
60
+ }
61
+ };
62
+
63
+ /** @type {typeof import('$app/stores').navigating} */
64
+ export const navigating = {
65
+ subscribe(fn) {
66
+ const store = getStores().navigating;
67
+ return store.subscribe(fn);
68
+ }
69
+ };
70
+
71
+ function removed_session() {
72
+ // TODO remove for 1.0
73
+ throw new Error(
74
+ 'stores.session is no longer available. See https://github.com/sveltejs/kit/discussions/5883'
75
+ );
76
+ }
77
+
78
+ export const session = {
79
+ subscribe: removed_session,
80
+ set: removed_session,
81
+ update: removed_session
82
+ };
83
+
84
+ /** @type {typeof import('$app/stores').updated} */
85
+ export const updated = {
86
+ subscribe(fn) {
87
+ const store = getStores().updated;
88
+
89
+ if (browser) {
90
+ updated.check = store.check;
91
+ }
92
+
93
+ return store.subscribe(fn);
94
+ },
95
+ check: () => {
96
+ throw new Error(
97
+ browser
98
+ ? `Cannot check updated store before subscribing`
99
+ : `Can only check updated store in browser`
100
+ );
101
+ }
102
+ };
@@ -0,0 +1,26 @@
1
+ declare module '__GENERATED__/client-manifest.js' {
2
+ import { CSRPageNodeLoader, ClientHooks, ParamMatcher } from 'types';
3
+
4
+ /**
5
+ * A list of all the error/layout/page nodes used in the app
6
+ */
7
+ export const nodes: CSRPageNodeLoader[];
8
+
9
+ /**
10
+ * A list of all layout node ids that have a server load function.
11
+ * Pages are not present because it's shorter to encode it on the leaf itself.
12
+ */
13
+ export const server_loads: number[];
14
+
15
+ /**
16
+ * A map of `[routeId: string]: [leaf, layouts, errors]` tuples, which
17
+ * is parsed into an array of routes on startup. The numbers refer to the indices in `nodes`.
18
+ * If the leaf number is negative, it means it does use a server load function and the complement is the node index.
19
+ * The route layout and error nodes are not referenced, they are always number 0 and 1 and always apply.
20
+ */
21
+ export const dictionary: Record<string, [leaf: number, layouts: number[], errors?: number[]]>;
22
+
23
+ export const matchers: Record<string, ParamMatcher>;
24
+
25
+ export const hooks: ClientHooks;
26
+ }