@sveltejs/kit 1.0.0-next.292 → 1.0.0-next.295

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.
@@ -1,6 +1,6 @@
1
1
  import { onMount, tick } from 'svelte';
2
2
  import { writable } from 'svelte/store';
3
- import { base, set_paths } from '../paths.js';
3
+ import { assets, set_paths } from '../paths.js';
4
4
  import Root from '__GENERATED__/root.svelte';
5
5
  import { routes, fallback } from '__GENERATED__/manifest.js';
6
6
  import { init } from './singletons.js';
@@ -198,7 +198,7 @@ function create_updated_store() {
198
198
 
199
199
  const file = import.meta.env.VITE_SVELTEKIT_APP_VERSION_FILE;
200
200
 
201
- const res = await fetch(`${base}/${file}`, {
201
+ const res = await fetch(`${assets}/${file}`, {
202
202
  headers: {
203
203
  pragma: 'no-cache',
204
204
  'cache-control': 'no-cache'
@@ -864,11 +864,6 @@ function create_client({ target, session, base, trailing_slash }) {
864
864
  }
865
865
  );
866
866
 
867
- if (res.status === 204) {
868
- // fallthrough
869
- return;
870
- }
871
-
872
867
  if (res.ok) {
873
868
  const redirect = res.headers.get('x-sveltekit-location');
874
869
 
@@ -880,6 +875,10 @@ function create_client({ target, session, base, trailing_slash }) {
880
875
  };
881
876
  }
882
877
 
878
+ if (res.status === 204) {
879
+ // fallthrough
880
+ return;
881
+ }
883
882
  props = await res.json();
884
883
  } else {
885
884
  status = res.status;
@@ -56,7 +56,12 @@ async function build_service_worker(
56
56
  fs__default.writeFileSync(
57
57
  service_worker,
58
58
  `
59
- export const timestamp = ${Date.now()};
59
+ // TODO remove for 1.0
60
+ export const timestamp = {
61
+ toString: () => {
62
+ throw new Error('\`timestamp\` has been removed from $service-worker. Use \`version\` instead');
63
+ }
64
+ };
60
65
 
61
66
  export const build = [
62
67
  ${Array.from(app_files)
@@ -75,6 +80,8 @@ async function build_service_worker(
75
80
  .map((path) => s(normalize_path(path, config.kit.trailingSlash)))
76
81
  .join(',\n\t\t\t\t')}
77
82
  ];
83
+
84
+ export const version = ${s(config.kit.version.name)};
78
85
  `
79
86
  .replace(/^\t{3}/gm, '')
80
87
  .trim()
@@ -361,7 +368,7 @@ export class Server {
361
368
 
362
369
  respond(request, options = {}) {
363
370
  if (!(request instanceof Request)) {
364
- throw new Error('The first argument to app.render must be a Request object. See https://github.com/sveltejs/kit/pull/3384 for details');
371
+ throw new Error('The first argument to server.respond must be a Request object. See https://github.com/sveltejs/kit/pull/3384 for details');
365
372
  }
366
373
 
367
374
  return respond(request, this.options, options);
@@ -424,7 +431,7 @@ async function build_server(
424
431
  const relative = path__default.relative(config.kit.files.routes, resolved);
425
432
 
426
433
  const name = relative.startsWith('..')
427
- ? posixify(path__default.join('entries/pages', path__default.basename(file)))
434
+ ? posixify(path__default.join('entries/fallbacks', path__default.basename(file)))
428
435
  : posixify(path__default.join('entries/pages', relative));
429
436
  input[name] = resolved;
430
437
  });
package/dist/cli.js CHANGED
@@ -870,7 +870,7 @@ async function launch(port, https) {
870
870
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
871
871
  }
872
872
 
873
- const prog = sade('svelte-kit').version('1.0.0-next.292');
873
+ const prog = sade('svelte-kit').version('1.0.0-next.295');
874
874
 
875
875
  prog
876
876
  .command('dev')
@@ -1043,7 +1043,7 @@ async function check_port(port) {
1043
1043
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1044
1044
  if (open) launch(port, https);
1045
1045
 
1046
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.292'}\n`));
1046
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.295'}\n`));
1047
1047
 
1048
1048
  const protocol = https ? 'https:' : 'http:';
1049
1049
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.292",
3
+ "version": "1.0.0-next.295",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -207,14 +207,9 @@ declare module '$app/stores' {
207
207
  export const updated: Readable<boolean> & { check: () => boolean };
208
208
  }
209
209
 
210
- /**
211
- * This is a simple alias to `src/lib`, or whatever directory is specified as [`config.kit.files.lib`](/docs/configuration#files). It allows you to access common components and utility modules without `../../../../` nonsense.
212
- */
213
- declare module '$lib' {}
214
-
215
210
  /**
216
211
  * ```ts
217
- * import { build, files, timestamp } from '$service-worker';
212
+ * import { build, files, prerendered, version } from '$service-worker';
218
213
  * ```
219
214
  *
220
215
  * This module is only available to [service workers](/docs/service-workers).
@@ -233,9 +228,9 @@ declare module '$service-worker' {
233
228
  */
234
229
  export const prerendered: string[];
235
230
  /**
236
- * The result of calling `Date.now()` at build time. It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
231
+ * See [`config.kit.version`](/docs/configuration#version). It's useful for generating unique cache names inside your service worker, so that a later deployment of your app can invalidate old caches.
237
232
  */
238
- export const timestamp: number;
233
+ export const version: string;
239
234
  }
240
235
 
241
236
  declare module '@sveltejs/kit/hooks' {
package/types/index.d.ts CHANGED
@@ -5,27 +5,95 @@ import './ambient';
5
5
 
6
6
  import { CompileOptions } from 'svelte/types/compiler/interfaces';
7
7
  import {
8
+ AdapterEntry,
8
9
  Body,
9
- Builder,
10
10
  CspDirectives,
11
11
  Either,
12
12
  ErrorLoadInput,
13
13
  Fallthrough,
14
14
  LoadInput,
15
15
  LoadOutput,
16
+ Logger,
16
17
  MaybePromise,
18
+ Prerendered,
17
19
  PrerenderOnErrorValue,
18
20
  RequestEvent,
21
+ RequestOptions,
19
22
  ResolveOptions,
20
23
  ResponseHeaders,
24
+ RouteDefinition,
21
25
  TrailingSlash
22
26
  } from './private';
27
+ import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal';
23
28
 
24
29
  export interface Adapter {
25
30
  name: string;
26
31
  adapt(builder: Builder): Promise<void>;
27
32
  }
28
33
 
34
+ export interface Builder {
35
+ log: Logger;
36
+ rimraf(dir: string): void;
37
+ mkdirp(dir: string): void;
38
+
39
+ config: ValidatedConfig;
40
+ prerendered: Prerendered;
41
+
42
+ /**
43
+ * Create entry points that map to individual functions
44
+ * @param fn A function that groups a set of routes into an entry point
45
+ */
46
+ createEntries(fn: (route: RouteDefinition) => AdapterEntry): void;
47
+
48
+ generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
49
+
50
+ getBuildDirectory(name: string): string;
51
+ getClientDirectory(): string;
52
+ getServerDirectory(): string;
53
+ getStaticDirectory(): string;
54
+
55
+ /**
56
+ * @param dest the destination folder to which files should be copied
57
+ * @returns an array of paths corresponding to the files that have been created by the copy
58
+ */
59
+ writeClient(dest: string): string[];
60
+ /**
61
+ *
62
+ * @param dest
63
+ */
64
+ writePrerendered(
65
+ dest: string,
66
+ opts?: {
67
+ fallback?: string;
68
+ }
69
+ ): string[];
70
+ /**
71
+ * @param dest the destination folder to which files should be copied
72
+ * @returns an array of paths corresponding to the files that have been created by the copy
73
+ */
74
+ writeServer(dest: string): string[];
75
+ /**
76
+ * @param dest the destination folder to which files should be copied
77
+ * @returns an array of paths corresponding to the files that have been created by the copy
78
+ */
79
+ writeStatic(dest: string): string[];
80
+ /**
81
+ * @param from the source file or folder
82
+ * @param to the destination file or folder
83
+ * @param opts.filter a function to determine whether a file or folder should be copied
84
+ * @param opts.replace a map of strings to replace
85
+ * @returns an array of paths corresponding to the files that have been created by the copy
86
+ */
87
+ copy(
88
+ from: string,
89
+ to: string,
90
+ opts?: {
91
+ filter?: (basename: string) => boolean;
92
+ replace?: Record<string, string>;
93
+ }
94
+ ): string[];
95
+ }
96
+
29
97
  export interface Config {
30
98
  compilerOptions?: CompileOptions;
31
99
  extensions?: string[];
@@ -164,3 +232,24 @@ export type RequestHandlerOutput<Output extends Body = Body> = MaybePromise<
164
232
  Fallthrough
165
233
  >
166
234
  >;
235
+
236
+ export class Server {
237
+ constructor(manifest: SSRManifest);
238
+ respond(request: Request, options?: RequestOptions): Promise<Response>;
239
+ }
240
+
241
+ export interface SSRManifest {
242
+ appDir: string;
243
+ assets: Set<string>;
244
+ /** private fields */
245
+ _: {
246
+ mime: Record<string, string>;
247
+ entry: {
248
+ file: string;
249
+ js: string[];
250
+ css: string[];
251
+ };
252
+ nodes: SSRNodeLoader[];
253
+ routes: SSRRoute[];
254
+ };
255
+ }
@@ -6,7 +6,9 @@ import {
6
6
  Handle,
7
7
  HandleError,
8
8
  Load,
9
- RequestHandler
9
+ RequestHandler,
10
+ Server,
11
+ SSRManifest
10
12
  } from './index';
11
13
  import {
12
14
  Either,
@@ -14,14 +16,11 @@ import {
14
16
  HttpMethod,
15
17
  JSONObject,
16
18
  MaybePromise,
17
- Prerendered,
18
19
  RequestEvent,
19
20
  RequestOptions,
20
21
  ResolveOptions,
21
22
  ResponseHeaders,
22
23
  RouteSegment,
23
- Server,
24
- SSRManifest,
25
24
  TrailingSlash
26
25
  } from './private';
27
26
 
@@ -2,7 +2,7 @@
2
2
  // but which cannot be imported from `@sveltejs/kit`. Care should
3
3
  // be taken to avoid breaking changes when editing this file
4
4
 
5
- import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal';
5
+ import { ValidatedConfig } from './internal';
6
6
 
7
7
  export interface AdapterEntry {
8
8
  /**
@@ -30,69 +30,6 @@ export interface AdapterEntry {
30
30
 
31
31
  export type Body = JSONValue | Uint8Array | ReadableStream | import('stream').Readable;
32
32
 
33
- export interface Builder {
34
- log: Logger;
35
- rimraf(dir: string): void;
36
- mkdirp(dir: string): void;
37
-
38
- config: ValidatedConfig;
39
- prerendered: Prerendered;
40
-
41
- /**
42
- * Create entry points that map to individual functions
43
- * @param fn A function that groups a set of routes into an entry point
44
- */
45
- createEntries(fn: (route: RouteDefinition) => AdapterEntry): void;
46
-
47
- generateManifest: (opts: { relativePath: string; format?: 'esm' | 'cjs' }) => string;
48
-
49
- getBuildDirectory(name: string): string;
50
- getClientDirectory(): string;
51
- getServerDirectory(): string;
52
- getStaticDirectory(): string;
53
-
54
- /**
55
- * @param dest the destination folder to which files should be copied
56
- * @returns an array of paths corresponding to the files that have been created by the copy
57
- */
58
- writeClient(dest: string): string[];
59
- /**
60
- *
61
- * @param dest
62
- */
63
- writePrerendered(
64
- dest: string,
65
- opts?: {
66
- fallback?: string;
67
- }
68
- ): string[];
69
- /**
70
- * @param dest the destination folder to which files should be copied
71
- * @returns an array of paths corresponding to the files that have been created by the copy
72
- */
73
- writeServer(dest: string): string[];
74
- /**
75
- * @param dest the destination folder to which files should be copied
76
- * @returns an array of paths corresponding to the files that have been created by the copy
77
- */
78
- writeStatic(dest: string): string[];
79
- /**
80
- * @param from the source file or folder
81
- * @param to the destination file or folder
82
- * @param opts.filter a function to determine whether a file or folder should be copied
83
- * @param opts.replace a map of strings to replace
84
- * @returns an array of paths corresponding to the files that have been created by the copy
85
- */
86
- copy(
87
- from: string,
88
- to: string,
89
- opts?: {
90
- filter?: (basename: string) => boolean;
91
- replace?: Record<string, string>;
92
- }
93
- ): string[];
94
- }
95
-
96
33
  // Based on https://github.com/josh-hemphill/csp-typed-directives/blob/latest/src/csp.types.ts
97
34
  //
98
35
  // MIT License
@@ -329,27 +266,6 @@ export interface RouteSegment {
329
266
  rest: boolean;
330
267
  }
331
268
 
332
- export class Server {
333
- constructor(manifest: SSRManifest);
334
- respond(request: Request, options?: RequestOptions): Promise<Response>;
335
- }
336
-
337
- export interface SSRManifest {
338
- appDir: string;
339
- assets: Set<string>;
340
- /** private fields */
341
- _: {
342
- mime: Record<string, string>;
343
- entry: {
344
- file: string;
345
- js: string[];
346
- css: string[];
347
- };
348
- nodes: SSRNodeLoader[];
349
- routes: SSRRoute[];
350
- };
351
- }
352
-
353
269
  export interface ToJSON {
354
270
  toJSON(...args: any[]): Exclude<JSONValue, ToJSON>;
355
271
  }