@sveltejs/kit 1.0.0-next.39 → 1.0.0-next.390

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 (41) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +13 -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 +1836 -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 +3565 -0
  12. package/dist/chunks/error.js +682 -0
  13. package/dist/chunks/index.js +15292 -3067
  14. package/dist/chunks/index2.js +175 -548
  15. package/dist/chunks/multipart-parser.js +458 -0
  16. package/dist/chunks/sync.js +1007 -0
  17. package/dist/chunks/write_tsconfig.js +274 -0
  18. package/dist/cli.js +66 -514
  19. package/dist/hooks.js +28 -0
  20. package/dist/node/polyfills.js +17778 -0
  21. package/dist/node.js +348 -0
  22. package/dist/vite.js +3289 -0
  23. package/package.json +97 -64
  24. package/types/ambient.d.ts +328 -0
  25. package/types/index.d.ts +290 -0
  26. package/types/internal.d.ts +327 -0
  27. package/types/private.d.ts +235 -0
  28. package/CHANGELOG.md +0 -405
  29. package/assets/runtime/app/env.js +0 -5
  30. package/assets/runtime/app/navigation.js +0 -41
  31. package/assets/runtime/app/paths.js +0 -1
  32. package/assets/runtime/chunks/utils.js +0 -19
  33. package/assets/runtime/internal/singletons.js +0 -23
  34. package/assets/runtime/internal/start.js +0 -770
  35. package/dist/chunks/index3.js +0 -246
  36. package/dist/chunks/index4.js +0 -517
  37. package/dist/chunks/index5.js +0 -761
  38. package/dist/chunks/index6.js +0 -322
  39. package/dist/chunks/standard.js +0 -99
  40. package/dist/chunks/utils.js +0 -83
  41. 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,405 +0,0 @@
1
- # @sveltejs/kit
2
-
3
- ## 1.0.0-next.39
4
-
5
- ### Patch Changes
6
-
7
- - b7fdb0d: Skip pre-bundling
8
-
9
- ## 1.0.0-next.38
10
-
11
- ### Patch Changes
12
-
13
- - 15402b1: Add service worker support
14
- - 0c630b5: Ignore dynamically imported components when constructing styles in dev mode
15
- - ac06af5: Fix svelte-kit adapt for Windows
16
- - 061fa46: Implement improved redirect API
17
- - b800049: Include type declarations
18
- - 07c6de4: Use posix paths in manifest even on Windows
19
- - 27ba872: Error if preload function exists
20
- - 0c630b5: Add default paths in case singletons module is invalidated
21
- - 73dd998: Allow custom extensions
22
-
23
- ## 1.0.0-next.37
24
-
25
- ### Patch Changes
26
-
27
- - 230c6d9: Indicate which request failed, if fetch fails inside load function
28
- - f1bc218: Run adapt via svelte-kit build
29
- - 6850ddc: Fix svelte-kit start for Windows
30
-
31
- ## 1.0.0-next.36
32
-
33
- ### Patch Changes
34
-
35
- - 7b70a33: Force version bump so that Kit uses updated vite-plugin-svelte
36
-
37
- ## 1.0.0-next.35
38
-
39
- ### Patch Changes
40
-
41
- - Use Vite
42
- - Fix Windows issues
43
- - Preserve load context during navigation
44
- - Return error from load
45
-
46
- ## 1.0.0-next.34
47
-
48
- ### Patch Changes
49
-
50
- - Fix adapters and convert to ES modules
51
-
52
- ## 1.0.0-next.33
53
-
54
- ### Patch Changes
55
-
56
- - 474070e: Better errors when modules cannot be found
57
-
58
- ## 1.0.0-next.32
59
-
60
- ### Patch Changes
61
-
62
- - Convert everything to ESM
63
-
64
- ## 1.0.0-next.31
65
-
66
- ### Patch Changes
67
-
68
- - b6c2434: app.js -> app.cjs
69
-
70
- ## 1.0.0-next.30
71
-
72
- ### Patch Changes
73
-
74
- - 00cbaf6: Rename _.config.js to _.config.cjs
75
-
76
- ## 1.0.0-next.29
77
-
78
- ### Patch Changes
79
-
80
- - 4c0edce: Use addEventListener instead of onload
81
-
82
- ## 1.0.0-next.28
83
-
84
- ### Patch Changes
85
-
86
- - 4353025: Prevent infinite loop when fetching bad URLs inside error responses
87
- - 2860065: Handle assets path when prerendering
88
-
89
- ## 1.0.0-next.27
90
-
91
- ### Patch Changes
92
-
93
- - Fail build if prerender errors
94
- - Hide logging behind --verbose option
95
-
96
- ## 1.0.0-next.26
97
-
98
- ### Patch Changes
99
-
100
- - Fix svelte-announcer CSS
101
-
102
- ## 1.0.0-next.25
103
-
104
- ### Patch Changes
105
-
106
- - Surface stack traces for endpoint/page rendering errors
107
-
108
- ## 1.0.0-next.24
109
-
110
- ### Patch Changes
111
-
112
- - 26643df: Account for config.paths when prerendering
113
-
114
- ## 1.0.0-next.23
115
-
116
- ### Patch Changes
117
-
118
- - 9b758aa: Upgrade to Snowpack 3
119
-
120
- ## 1.0.0-next.22
121
-
122
- ### Patch Changes
123
-
124
- - bb68595: use readFileSync instead of createReadStream
125
-
126
- ## 1.0.0-next.21
127
-
128
- ### Patch Changes
129
-
130
- - 217e4cc: Set paths to empty string before prerender
131
-
132
- ## 1.0.0-next.20
133
-
134
- ### Patch Changes
135
-
136
- - ccf4aa7: Implement prerender config
137
-
138
- ## 1.0.0-next.19
139
-
140
- ### Patch Changes
141
-
142
- - deda984: Make navigating store contain from and to properties
143
-
144
- ## 1.0.0-next.18
145
-
146
- ### Patch Changes
147
-
148
- - c29b61e: Announce page changes
149
- - 72da270: Reset focus properly
150
-
151
- ## 1.0.0-next.17
152
-
153
- ### Patch Changes
154
-
155
- - f7dea55: Set process.env.NODE_ENV when invoking via the CLI
156
-
157
- ## 1.0.0-next.16
158
-
159
- ### Patch Changes
160
-
161
- - Remove temporary logging
162
- - Add sveltekit:prefetch and sveltekit:noscroll
163
-
164
- ## 1.0.0-next.15
165
-
166
- ### Patch Changes
167
-
168
- - 6d1bb11: Fix AMP CSS
169
- - d8b53af: Ignore $layout and $error files when finding static paths
170
- - Better scroll tracking
171
-
172
- ## 1.0.0-next.14
173
-
174
- ### Patch Changes
175
-
176
- - Fix dev loader
177
-
178
- ## 1.0.0-next.13
179
-
180
- ### Patch Changes
181
-
182
- - 1ea4d6b: More robust CSS extraction
183
-
184
- ## 1.0.0-next.12
185
-
186
- ### Patch Changes
187
-
188
- - e7c88dd: Tweak AMP validation screen
189
-
190
- ## 1.0.0-next.11
191
-
192
- ### Patch Changes
193
-
194
- - a31f218: Fix SSR loader invalidation
195
-
196
- ## 1.0.0-next.10
197
-
198
- ### Patch Changes
199
-
200
- - 8b14d29: Omit svelte-data scripts from AMP pages
201
-
202
- ## 1.0.0-next.9
203
-
204
- ### Patch Changes
205
-
206
- - f5fa223: AMP support
207
- - 47f2ee1: Always remove trailing slashes
208
- - 1becb94: Replace preload with load
209
-
210
- ## 1.0.0-next.8
211
-
212
- ### Patch Changes
213
-
214
- - 15dd751: Use meta http-equiv=refresh
215
- - be7e031: Fix handling of static files
216
- - ed6b8fd: Implement \$app/env
217
-
218
- ## 1.0.0-next.7
219
-
220
- ### Patch Changes
221
-
222
- - 76705b0: make HMR work outside localhost
223
-
224
- ## 1.0.0-next.6
225
-
226
- ### Patch Changes
227
-
228
- - 0e45255: Move options behind kit namespace, change paths -> kit.files
229
- - fa7f2b2: Implement live bindings for SSR code
230
-
231
- ## 1.0.0-next.5
232
-
233
- ### Patch Changes
234
-
235
- - Return dependencies from render
236
-
237
- ## 1.0.0-next.4
238
-
239
- ### Patch Changes
240
-
241
- - af01b0d: Move renderer out of app assets folder
242
-
243
- ## 1.0.0-next.3
244
-
245
- ### Patch Changes
246
-
247
- - Add paths to manifest, for static prerendering
248
-
249
- ## 1.0.0-next.2
250
-
251
- ### Patch Changes
252
-
253
- - Fix typo causing misnamed assets folder
254
-
255
- ## 1.0.0-next.1
256
-
257
- ### Patch Changes
258
-
259
- - a4bc090: Transform exported functions correctly
260
- - 00bbf98: Fix nested layouts
261
-
262
- ## 0.0.31-next.0
263
-
264
- ### Patch Changes
265
-
266
- - ffd7bba: Fix SSR cache invalidation
267
-
268
- ## 0.0.30
269
-
270
- ### Patch Changes
271
-
272
- - Add back stores(), but with deprecation warning
273
- - Rename stores.preloading to stores.navigating
274
- - Rewrite routing logic
275
-
276
- ## 0.0.29
277
-
278
- ### Patch Changes
279
-
280
- - 10872cc: Normalize request.query
281
-
282
- ## 0.0.28
283
-
284
- ### Patch Changes
285
-
286
- - Add svelte-kit start command
287
-
288
- ## 0.0.27
289
-
290
- ### Patch Changes
291
-
292
- - rename CLI to svelte-kit
293
- - 0904e22: rename svelte CLI to svelte-kit
294
- - Validate route responses
295
- - Make paths and target configurable
296
-
297
- ## 0.0.26
298
-
299
- ### Patch Changes
300
-
301
- - b475ed4: Overhaul adapter API - fixes #166
302
- - Updated dependencies [b475ed4]
303
- - @sveltejs/app-utils@0.0.18
304
-
305
- ## 0.0.25
306
-
307
- ### Patch Changes
308
-
309
- - Updated dependencies [3bdf33b]
310
- - @sveltejs/app-utils@0.0.17
311
-
312
- ## 0.0.24
313
-
314
- ### Patch Changes
315
-
316
- - 67eaeea: Move app-utils stuff into subpackages
317
- - 7f8df30: Move kit runtime code, expose via \$app aliases
318
- - Updated dependencies [67eaeea]
319
- - @sveltejs/app-utils@0.0.16
320
-
321
- ## 0.0.23
322
-
323
- ### Patch Changes
324
-
325
- - a163000: Parse body on incoming requests
326
- - a346eab: Copy over latest Sapper router code
327
- - Updated dependencies [a163000]
328
- - @sveltejs/app-utils@0.0.15
329
-
330
- ## 0.0.22
331
-
332
- ### Patch Changes
333
-
334
- - Force bump version
335
-
336
- ## 0.0.21
337
-
338
- ### Patch Changes
339
-
340
- - Build setup entry point
341
- - Work around pkg.exports constraint
342
- - Respond with 500s if render fails
343
- - Updated dependencies [undefined]
344
- - Updated dependencies [undefined]
345
- - Updated dependencies [undefined]
346
- - @sveltejs/app-utils@0.0.14
347
-
348
- ## 0.0.20
349
-
350
- ### Patch Changes
351
-
352
- - Pass setup module to renderer
353
- - Bump Snowpack version
354
- - Updated dependencies [undefined]
355
- - Updated dependencies [96c06d8]
356
- - @sveltejs/app-utils@0.0.13
357
-
358
- ## 0.0.19
359
-
360
- ### Patch Changes
361
-
362
- - fa9d7ce: Handle import.meta in SSR module loader
363
- - 0320208: Rename 'server route' to 'endpoint'
364
- - b9444d2: Update to Snowpack 2.15
365
- - 5ca907c: Use shared mkdirp helper
366
- - Updated dependencies [0320208]
367
- - Updated dependencies [5ca907c]
368
- - @sveltejs/app-utils@0.0.12
369
-
370
- ## 0.0.18
371
-
372
- ### Patch Changes
373
-
374
- - Updated dependencies [undefined]
375
- - @sveltejs/app-utils@0.0.11
376
-
377
- ## 0.0.17
378
-
379
- ### Patch Changes
380
-
381
- - 19323e9: Update Snowpack
382
- - Updated dependencies [19323e9]
383
- - @sveltejs/app-utils@0.0.10
384
-
385
- ## 0.0.16
386
-
387
- ### Patch Changes
388
-
389
- - Updated dependencies [90a98ae]
390
- - @sveltejs/app-utils@0.0.9
391
-
392
- ## 0.0.15
393
-
394
- ### Patch Changes
395
-
396
- - Updated dependencies [undefined]
397
- - @sveltejs/app-utils@0.0.8
398
-
399
- ## 0.0.14
400
-
401
- ### Patch Changes
402
-
403
- - various
404
- - Updated dependencies [undefined]
405
- - @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 };