@sveltejs/kit 1.0.0-next.38 → 1.0.0-next.380

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 (42) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +28 -0
  3. package/assets/app/navigation.js +24 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/{runtime/app → app}/stores.js +33 -29
  6. package/assets/client/singletons.js +13 -0
  7. package/assets/client/start.js +1803 -0
  8. package/assets/components/error.svelte +18 -2
  9. package/assets/env.js +8 -0
  10. package/assets/{runtime/chunks/paths.js → paths.js} +4 -3
  11. package/assets/server/index.js +3563 -0
  12. package/dist/chunks/_commonjsHelpers.js +3 -0
  13. package/dist/chunks/error.js +664 -0
  14. package/dist/chunks/index.js +15292 -3067
  15. package/dist/chunks/index2.js +186 -555
  16. package/dist/chunks/multipart-parser.js +445 -0
  17. package/dist/chunks/sync.js +1007 -0
  18. package/dist/chunks/write_tsconfig.js +274 -0
  19. package/dist/cli.js +66 -514
  20. package/dist/hooks.js +28 -0
  21. package/dist/node/polyfills.js +12240 -0
  22. package/dist/node.js +5883 -0
  23. package/dist/vite.js +3243 -0
  24. package/package.json +97 -64
  25. package/types/ambient.d.ts +345 -0
  26. package/types/index.d.ts +289 -0
  27. package/types/internal.d.ts +326 -0
  28. package/types/private.d.ts +235 -0
  29. package/CHANGELOG.md +0 -399
  30. package/assets/runtime/app/env.js +0 -5
  31. package/assets/runtime/app/navigation.js +0 -41
  32. package/assets/runtime/app/paths.js +0 -1
  33. package/assets/runtime/chunks/utils.js +0 -19
  34. package/assets/runtime/internal/singletons.js +0 -23
  35. package/assets/runtime/internal/start.js +0 -770
  36. package/dist/chunks/index3.js +0 -246
  37. package/dist/chunks/index4.js +0 -511
  38. package/dist/chunks/index5.js +0 -761
  39. package/dist/chunks/index6.js +0 -322
  40. package/dist/chunks/standard.js +0 -99
  41. package/dist/chunks/utils.js +0 -83
  42. package/dist/ssr.js +0 -2523
@@ -0,0 +1,235 @@
1
+ // This module contains types that are visible in the documentation,
2
+ // but which cannot be imported from `@sveltejs/kit`. Care should
3
+ // be taken to avoid breaking changes when editing this file
4
+
5
+ export interface AdapterEntry {
6
+ /**
7
+ * A string that uniquely identifies an HTTP service (e.g. serverless function) and is used for deduplication.
8
+ * For example, `/foo/a-[b]` and `/foo/[c]` are different routes, but would both
9
+ * be represented in a Netlify _redirects file as `/foo/:param`, so they share an ID
10
+ */
11
+ id: string;
12
+
13
+ /**
14
+ * A function that compares the candidate route with the current route to determine
15
+ * if it should be treated as a fallback for the current route. For example, `/foo/[c]`
16
+ * is a fallback for `/foo/a-[b]`, and `/[...catchall]` is a fallback for all routes
17
+ */
18
+ filter: (route: RouteDefinition) => boolean;
19
+
20
+ /**
21
+ * A function that is invoked once the entry has been created. This is where you
22
+ * should write the function to the filesystem and generate redirect manifests.
23
+ */
24
+ complete: (entry: {
25
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
26
+ }) => MaybePromise<void>;
27
+ }
28
+
29
+ export type BodyValidator<T> = {
30
+ [P in keyof T]: T[P] extends { [k: string]: unknown }
31
+ ? BodyValidator<T[P]> // recurse when T[P] is an object
32
+ : T[P] extends BigInt | Function | Symbol
33
+ ? never
34
+ : T[P];
35
+ };
36
+
37
+ // Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts
38
+ //
39
+ // MIT License
40
+ //
41
+ // Copyright (c) 2021-present, Joshua Hemphill
42
+ // Copyright (c) 2021, Tecnico Corporation
43
+ //
44
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
45
+ // of this software and associated documentation files (the "Software"), to deal
46
+ // in the Software without restriction, including without limitation the rights
47
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
48
+ // copies of the Software, and to permit persons to whom the Software is
49
+ // furnished to do so, subject to the following conditions:
50
+ //
51
+ // The above copyright notice and this permission notice shall be included in all
52
+ // copies or substantial portions of the Software.
53
+ //
54
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
56
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
59
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
60
+ // SOFTWARE.
61
+
62
+ export namespace Csp {
63
+ type ActionSource = 'strict-dynamic' | 'report-sample';
64
+ type BaseSource = 'self' | 'unsafe-eval' | 'unsafe-hashes' | 'unsafe-inline' | 'none';
65
+ type CryptoSource = `${'nonce' | 'sha256' | 'sha384' | 'sha512'}-${string}`;
66
+ type FrameSource = HostSource | SchemeSource | 'self' | 'none';
67
+ type HostNameScheme = `${string}.${string}` | 'localhost';
68
+ type HostSource = `${HostProtocolSchemes}${HostNameScheme}${PortScheme}`;
69
+ type HostProtocolSchemes = `${string}://` | '';
70
+ type HttpDelineator = '/' | '?' | '#' | '\\';
71
+ type PortScheme = `:${number}` | '' | ':*';
72
+ type SchemeSource = 'http:' | 'https:' | 'data:' | 'mediastream:' | 'blob:' | 'filesystem:';
73
+ type Source = HostSource | SchemeSource | CryptoSource | BaseSource;
74
+ type Sources = Source[];
75
+ type UriPath = `${HttpDelineator}${string}`;
76
+ }
77
+
78
+ export interface CspDirectives {
79
+ 'child-src'?: Csp.Sources;
80
+ 'default-src'?: Array<Csp.Source | Csp.ActionSource>;
81
+ 'frame-src'?: Csp.Sources;
82
+ 'worker-src'?: Csp.Sources;
83
+ 'connect-src'?: Csp.Sources;
84
+ 'font-src'?: Csp.Sources;
85
+ 'img-src'?: Csp.Sources;
86
+ 'manifest-src'?: Csp.Sources;
87
+ 'media-src'?: Csp.Sources;
88
+ 'object-src'?: Csp.Sources;
89
+ 'prefetch-src'?: Csp.Sources;
90
+ 'script-src'?: Array<Csp.Source | Csp.ActionSource>;
91
+ 'script-src-elem'?: Csp.Sources;
92
+ 'script-src-attr'?: Csp.Sources;
93
+ 'style-src'?: Array<Csp.Source | Csp.ActionSource>;
94
+ 'style-src-elem'?: Csp.Sources;
95
+ 'style-src-attr'?: Csp.Sources;
96
+ 'base-uri'?: Array<Csp.Source | Csp.ActionSource>;
97
+ sandbox?: Array<
98
+ | 'allow-downloads-without-user-activation'
99
+ | 'allow-forms'
100
+ | 'allow-modals'
101
+ | 'allow-orientation-lock'
102
+ | 'allow-pointer-lock'
103
+ | 'allow-popups'
104
+ | 'allow-popups-to-escape-sandbox'
105
+ | 'allow-presentation'
106
+ | 'allow-same-origin'
107
+ | 'allow-scripts'
108
+ | 'allow-storage-access-by-user-activation'
109
+ | 'allow-top-navigation'
110
+ | 'allow-top-navigation-by-user-activation'
111
+ >;
112
+ 'form-action'?: Array<Csp.Source | Csp.ActionSource>;
113
+ 'frame-ancestors'?: Array<Csp.HostSource | Csp.SchemeSource | Csp.FrameSource>;
114
+ 'navigate-to'?: Array<Csp.Source | Csp.ActionSource>;
115
+ 'report-uri'?: Csp.UriPath[];
116
+ 'report-to'?: string[];
117
+
118
+ 'require-trusted-types-for'?: Array<'script'>;
119
+ 'trusted-types'?: Array<'none' | 'allow-duplicates' | '*' | string>;
120
+ 'upgrade-insecure-requests'?: boolean;
121
+
122
+ /** @deprecated */
123
+ 'require-sri-for'?: Array<'script' | 'style' | 'script style'>;
124
+
125
+ /** @deprecated */
126
+ 'block-all-mixed-content'?: boolean;
127
+
128
+ /** @deprecated */
129
+ 'plugin-types'?: Array<`${string}/${string}` | 'none'>;
130
+
131
+ /** @deprecated */
132
+ referrer?: Array<
133
+ | 'no-referrer'
134
+ | 'no-referrer-when-downgrade'
135
+ | 'origin'
136
+ | 'origin-when-cross-origin'
137
+ | 'same-origin'
138
+ | 'strict-origin'
139
+ | 'strict-origin-when-cross-origin'
140
+ | 'unsafe-url'
141
+ | 'none'
142
+ >;
143
+ }
144
+
145
+ export type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
146
+
147
+ export interface JSONObject {
148
+ [key: string]: JSONValue;
149
+ }
150
+
151
+ export type JSONValue =
152
+ | string
153
+ | number
154
+ | boolean
155
+ | null
156
+ | undefined
157
+ | ToJSON
158
+ | JSONValue[]
159
+ | JSONObject;
160
+
161
+ export interface Logger {
162
+ (msg: string): void;
163
+ success(msg: string): void;
164
+ error(msg: string): void;
165
+ warn(msg: string): void;
166
+ minor(msg: string): void;
167
+ info(msg: string): void;
168
+ }
169
+
170
+ export type MaybePromise<T> = T | Promise<T>;
171
+
172
+ export interface Prerendered {
173
+ pages: Map<
174
+ string,
175
+ {
176
+ /** The location of the .html file relative to the output directory */
177
+ file: string;
178
+ }
179
+ >;
180
+ assets: Map<
181
+ string,
182
+ {
183
+ /** The MIME type of the asset */
184
+ type: string;
185
+ }
186
+ >;
187
+ redirects: Map<
188
+ string,
189
+ {
190
+ status: number;
191
+ location: string;
192
+ }
193
+ >;
194
+ /** An array of prerendered paths (without trailing slashes, regardless of the trailingSlash config) */
195
+ paths: string[];
196
+ }
197
+
198
+ export interface PrerenderErrorHandler {
199
+ (details: {
200
+ status: number;
201
+ path: string;
202
+ referrer: string | null;
203
+ referenceType: 'linked' | 'fetched';
204
+ }): void;
205
+ }
206
+
207
+ export type PrerenderOnErrorValue = 'fail' | 'continue' | PrerenderErrorHandler;
208
+
209
+ export interface RequestOptions {
210
+ getClientAddress: () => string;
211
+ platform?: App.Platform;
212
+ }
213
+
214
+ /** `string[]` is only for set-cookie, everything else must be type of `string` */
215
+ export type ResponseHeaders = Record<string, string | number | string[]>;
216
+
217
+ export interface RouteDefinition {
218
+ id: string;
219
+ type: 'page' | 'endpoint';
220
+ pattern: RegExp;
221
+ segments: RouteSegment[];
222
+ methods: HttpMethod[];
223
+ }
224
+
225
+ export interface RouteSegment {
226
+ content: string;
227
+ dynamic: boolean;
228
+ rest: boolean;
229
+ }
230
+
231
+ export interface ToJSON {
232
+ toJSON(...args: any[]): Exclude<JSONValue, ToJSON>;
233
+ }
234
+
235
+ export type TrailingSlash = 'never' | 'always' | 'ignore';
package/CHANGELOG.md DELETED
@@ -1,399 +0,0 @@
1
- # @sveltejs/kit
2
-
3
- ## 1.0.0-next.38
4
-
5
- ### Patch Changes
6
-
7
- - 15402b1: Add service worker support
8
- - 0c630b5: Ignore dynamically imported components when constructing styles in dev mode
9
- - ac06af5: Fix svelte-kit adapt for Windows
10
- - 061fa46: Implement improved redirect API
11
- - b800049: Include type declarations
12
- - 07c6de4: Use posix paths in manifest even on Windows
13
- - 27ba872: Error if preload function exists
14
- - 0c630b5: Add default paths in case singletons module is invalidated
15
- - 73dd998: Allow custom extensions
16
-
17
- ## 1.0.0-next.37
18
-
19
- ### Patch Changes
20
-
21
- - 230c6d9: Indicate which request failed, if fetch fails inside load function
22
- - f1bc218: Run adapt via svelte-kit build
23
- - 6850ddc: Fix svelte-kit start for Windows
24
-
25
- ## 1.0.0-next.36
26
-
27
- ### Patch Changes
28
-
29
- - 7b70a33: Force version bump so that Kit uses updated vite-plugin-svelte
30
-
31
- ## 1.0.0-next.35
32
-
33
- ### Patch Changes
34
-
35
- - Use Vite
36
- - Fix Windows issues
37
- - Preserve load context during navigation
38
- - Return error from load
39
-
40
- ## 1.0.0-next.34
41
-
42
- ### Patch Changes
43
-
44
- - Fix adapters and convert to ES modules
45
-
46
- ## 1.0.0-next.33
47
-
48
- ### Patch Changes
49
-
50
- - 474070e: Better errors when modules cannot be found
51
-
52
- ## 1.0.0-next.32
53
-
54
- ### Patch Changes
55
-
56
- - Convert everything to ESM
57
-
58
- ## 1.0.0-next.31
59
-
60
- ### Patch Changes
61
-
62
- - b6c2434: app.js -> app.cjs
63
-
64
- ## 1.0.0-next.30
65
-
66
- ### Patch Changes
67
-
68
- - 00cbaf6: Rename _.config.js to _.config.cjs
69
-
70
- ## 1.0.0-next.29
71
-
72
- ### Patch Changes
73
-
74
- - 4c0edce: Use addEventListener instead of onload
75
-
76
- ## 1.0.0-next.28
77
-
78
- ### Patch Changes
79
-
80
- - 4353025: Prevent infinite loop when fetching bad URLs inside error responses
81
- - 2860065: Handle assets path when prerendering
82
-
83
- ## 1.0.0-next.27
84
-
85
- ### Patch Changes
86
-
87
- - Fail build if prerender errors
88
- - Hide logging behind --verbose option
89
-
90
- ## 1.0.0-next.26
91
-
92
- ### Patch Changes
93
-
94
- - Fix svelte-announcer CSS
95
-
96
- ## 1.0.0-next.25
97
-
98
- ### Patch Changes
99
-
100
- - Surface stack traces for endpoint/page rendering errors
101
-
102
- ## 1.0.0-next.24
103
-
104
- ### Patch Changes
105
-
106
- - 26643df: Account for config.paths when prerendering
107
-
108
- ## 1.0.0-next.23
109
-
110
- ### Patch Changes
111
-
112
- - 9b758aa: Upgrade to Snowpack 3
113
-
114
- ## 1.0.0-next.22
115
-
116
- ### Patch Changes
117
-
118
- - bb68595: use readFileSync instead of createReadStream
119
-
120
- ## 1.0.0-next.21
121
-
122
- ### Patch Changes
123
-
124
- - 217e4cc: Set paths to empty string before prerender
125
-
126
- ## 1.0.0-next.20
127
-
128
- ### Patch Changes
129
-
130
- - ccf4aa7: Implement prerender config
131
-
132
- ## 1.0.0-next.19
133
-
134
- ### Patch Changes
135
-
136
- - deda984: Make navigating store contain from and to properties
137
-
138
- ## 1.0.0-next.18
139
-
140
- ### Patch Changes
141
-
142
- - c29b61e: Announce page changes
143
- - 72da270: Reset focus properly
144
-
145
- ## 1.0.0-next.17
146
-
147
- ### Patch Changes
148
-
149
- - f7dea55: Set process.env.NODE_ENV when invoking via the CLI
150
-
151
- ## 1.0.0-next.16
152
-
153
- ### Patch Changes
154
-
155
- - Remove temporary logging
156
- - Add sveltekit:prefetch and sveltekit:noscroll
157
-
158
- ## 1.0.0-next.15
159
-
160
- ### Patch Changes
161
-
162
- - 6d1bb11: Fix AMP CSS
163
- - d8b53af: Ignore $layout and $error files when finding static paths
164
- - Better scroll tracking
165
-
166
- ## 1.0.0-next.14
167
-
168
- ### Patch Changes
169
-
170
- - Fix dev loader
171
-
172
- ## 1.0.0-next.13
173
-
174
- ### Patch Changes
175
-
176
- - 1ea4d6b: More robust CSS extraction
177
-
178
- ## 1.0.0-next.12
179
-
180
- ### Patch Changes
181
-
182
- - e7c88dd: Tweak AMP validation screen
183
-
184
- ## 1.0.0-next.11
185
-
186
- ### Patch Changes
187
-
188
- - a31f218: Fix SSR loader invalidation
189
-
190
- ## 1.0.0-next.10
191
-
192
- ### Patch Changes
193
-
194
- - 8b14d29: Omit svelte-data scripts from AMP pages
195
-
196
- ## 1.0.0-next.9
197
-
198
- ### Patch Changes
199
-
200
- - f5fa223: AMP support
201
- - 47f2ee1: Always remove trailing slashes
202
- - 1becb94: Replace preload with load
203
-
204
- ## 1.0.0-next.8
205
-
206
- ### Patch Changes
207
-
208
- - 15dd751: Use meta http-equiv=refresh
209
- - be7e031: Fix handling of static files
210
- - ed6b8fd: Implement \$app/env
211
-
212
- ## 1.0.0-next.7
213
-
214
- ### Patch Changes
215
-
216
- - 76705b0: make HMR work outside localhost
217
-
218
- ## 1.0.0-next.6
219
-
220
- ### Patch Changes
221
-
222
- - 0e45255: Move options behind kit namespace, change paths -> kit.files
223
- - fa7f2b2: Implement live bindings for SSR code
224
-
225
- ## 1.0.0-next.5
226
-
227
- ### Patch Changes
228
-
229
- - Return dependencies from render
230
-
231
- ## 1.0.0-next.4
232
-
233
- ### Patch Changes
234
-
235
- - af01b0d: Move renderer out of app assets folder
236
-
237
- ## 1.0.0-next.3
238
-
239
- ### Patch Changes
240
-
241
- - Add paths to manifest, for static prerendering
242
-
243
- ## 1.0.0-next.2
244
-
245
- ### Patch Changes
246
-
247
- - Fix typo causing misnamed assets folder
248
-
249
- ## 1.0.0-next.1
250
-
251
- ### Patch Changes
252
-
253
- - a4bc090: Transform exported functions correctly
254
- - 00bbf98: Fix nested layouts
255
-
256
- ## 0.0.31-next.0
257
-
258
- ### Patch Changes
259
-
260
- - ffd7bba: Fix SSR cache invalidation
261
-
262
- ## 0.0.30
263
-
264
- ### Patch Changes
265
-
266
- - Add back stores(), but with deprecation warning
267
- - Rename stores.preloading to stores.navigating
268
- - Rewrite routing logic
269
-
270
- ## 0.0.29
271
-
272
- ### Patch Changes
273
-
274
- - 10872cc: Normalize request.query
275
-
276
- ## 0.0.28
277
-
278
- ### Patch Changes
279
-
280
- - Add svelte-kit start command
281
-
282
- ## 0.0.27
283
-
284
- ### Patch Changes
285
-
286
- - rename CLI to svelte-kit
287
- - 0904e22: rename svelte CLI to svelte-kit
288
- - Validate route responses
289
- - Make paths and target configurable
290
-
291
- ## 0.0.26
292
-
293
- ### Patch Changes
294
-
295
- - b475ed4: Overhaul adapter API - fixes #166
296
- - Updated dependencies [b475ed4]
297
- - @sveltejs/app-utils@0.0.18
298
-
299
- ## 0.0.25
300
-
301
- ### Patch Changes
302
-
303
- - Updated dependencies [3bdf33b]
304
- - @sveltejs/app-utils@0.0.17
305
-
306
- ## 0.0.24
307
-
308
- ### Patch Changes
309
-
310
- - 67eaeea: Move app-utils stuff into subpackages
311
- - 7f8df30: Move kit runtime code, expose via \$app aliases
312
- - Updated dependencies [67eaeea]
313
- - @sveltejs/app-utils@0.0.16
314
-
315
- ## 0.0.23
316
-
317
- ### Patch Changes
318
-
319
- - a163000: Parse body on incoming requests
320
- - a346eab: Copy over latest Sapper router code
321
- - Updated dependencies [a163000]
322
- - @sveltejs/app-utils@0.0.15
323
-
324
- ## 0.0.22
325
-
326
- ### Patch Changes
327
-
328
- - Force bump version
329
-
330
- ## 0.0.21
331
-
332
- ### Patch Changes
333
-
334
- - Build setup entry point
335
- - Work around pkg.exports constraint
336
- - Respond with 500s if render fails
337
- - Updated dependencies [undefined]
338
- - Updated dependencies [undefined]
339
- - Updated dependencies [undefined]
340
- - @sveltejs/app-utils@0.0.14
341
-
342
- ## 0.0.20
343
-
344
- ### Patch Changes
345
-
346
- - Pass setup module to renderer
347
- - Bump Snowpack version
348
- - Updated dependencies [undefined]
349
- - Updated dependencies [96c06d8]
350
- - @sveltejs/app-utils@0.0.13
351
-
352
- ## 0.0.19
353
-
354
- ### Patch Changes
355
-
356
- - fa9d7ce: Handle import.meta in SSR module loader
357
- - 0320208: Rename 'server route' to 'endpoint'
358
- - b9444d2: Update to Snowpack 2.15
359
- - 5ca907c: Use shared mkdirp helper
360
- - Updated dependencies [0320208]
361
- - Updated dependencies [5ca907c]
362
- - @sveltejs/app-utils@0.0.12
363
-
364
- ## 0.0.18
365
-
366
- ### Patch Changes
367
-
368
- - Updated dependencies [undefined]
369
- - @sveltejs/app-utils@0.0.11
370
-
371
- ## 0.0.17
372
-
373
- ### Patch Changes
374
-
375
- - 19323e9: Update Snowpack
376
- - Updated dependencies [19323e9]
377
- - @sveltejs/app-utils@0.0.10
378
-
379
- ## 0.0.16
380
-
381
- ### Patch Changes
382
-
383
- - Updated dependencies [90a98ae]
384
- - @sveltejs/app-utils@0.0.9
385
-
386
- ## 0.0.15
387
-
388
- ### Patch Changes
389
-
390
- - Updated dependencies [undefined]
391
- - @sveltejs/app-utils@0.0.8
392
-
393
- ## 0.0.14
394
-
395
- ### Patch Changes
396
-
397
- - various
398
- - Updated dependencies [undefined]
399
- - @sveltejs/app-utils@0.0.7
@@ -1,5 +0,0 @@
1
- const browser = !import.meta.env.SSR;
2
- const dev = !!import.meta.env.DEV;
3
- const amp = !!import.meta.env.VITE_SVELTEKIT_AMP;
4
-
5
- export { amp, browser, dev };
@@ -1,41 +0,0 @@
1
- import { router, renderer } from '../internal/singletons.js';
2
- import { g as get_base_uri } from '../chunks/utils.js';
3
-
4
- function guard(name) {
5
- return () => {
6
- throw new Error(`Cannot call ${name}(...) on the server`);
7
- };
8
- }
9
-
10
- const goto = import.meta.env.SSR ? guard('goto') : goto_;
11
- const prefetch = import.meta.env.SSR ? guard('prefetch') : prefetch_;
12
- const prefetchRoutes = import.meta.env.SSR ? guard('prefetchRoutes') : prefetchRoutes_;
13
-
14
- /**
15
- * @param {string} href
16
- * @param {{
17
- * noscroll?: boolean;
18
- * resplaceState?: boolean;
19
- * }} [opts]
20
- */
21
- async function goto_(href, opts) {
22
- return router.goto(href, opts, []);
23
- }
24
-
25
- /** @param {string} href */
26
- function prefetch_(href) {
27
- return renderer.prefetch(new URL(href, get_base_uri(document)));
28
- }
29
-
30
- /** @param {string[]} [pathnames] */
31
- async function prefetchRoutes_(pathnames) {
32
- const path_routes = pathnames
33
- ? router.pages.filter((page) => pathnames.some((pathname) => page.pattern.test(pathname)))
34
- : router.pages;
35
-
36
- const promises = path_routes.map((r) => Promise.all(r.parts.map((load) => load())));
37
-
38
- await Promise.all(promises);
39
- }
40
-
41
- export { goto, prefetch, prefetchRoutes };
@@ -1 +0,0 @@
1
- export { a as assets, b as base } from '../chunks/paths.js';
@@ -1,19 +0,0 @@
1
- /** @param {Node} node */
2
- function find_anchor(node) {
3
- while (node && node.nodeName.toUpperCase() !== 'A') node = node.parentNode; // SVG <a> elements have a lowercase name
4
- return node;
5
- }
6
-
7
- /** @param {HTMLDocument} doc */
8
- function get_base_uri(doc) {
9
- let baseURI = doc.baseURI;
10
-
11
- if (!baseURI) {
12
- const baseTags = doc.getElementsByTagName('base');
13
- baseURI = baseTags.length ? baseTags[0].href : doc.URL;
14
- }
15
-
16
- return baseURI;
17
- }
18
-
19
- export { find_anchor as f, get_base_uri as g };