@sveltejs/kit 1.0.0-next.44 → 1.0.0-next.442

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