@sveltejs/kit 1.0.0-next.288 → 1.0.0-next.290

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.
package/dist/cli.js CHANGED
@@ -320,17 +320,11 @@ function posixify(str) {
320
320
  return str.replace(/\\/g, '/');
321
321
  }
322
322
 
323
- const SVELTE_KIT = '.svelte-kit';
324
-
325
- // in `svelte-kit dev` and `svelte-kit preview`, we use a fake
326
- // asset path so that we can serve local assets while still
327
- // verifying that requests are correctly prefixed
328
- const SVELTE_KIT_ASSETS = '/_svelte_kit_assets';
329
-
330
323
  const __filename = fileURLToPath(import.meta.url);
331
324
  const __dirname = path__default.dirname(__filename);
332
325
 
333
- const runtime = posixify_path(path__default.resolve(`${SVELTE_KIT}/runtime`))
326
+ const get_runtime_path = /** @param {import('types').ValidatedConfig} config */ (config) =>
327
+ posixify_path(path__default.join(config.kit.outDir, 'runtime'))
334
328
  ;
335
329
 
336
330
  /** @param {string} str */
@@ -425,8 +419,8 @@ function get_mime_lookup(manifest_data) {
425
419
  /** @param {import('types').ValidatedConfig} config */
426
420
  function get_aliases(config) {
427
421
  const alias = {
428
- __GENERATED__: path__default.posix.resolve(`${SVELTE_KIT}/generated`),
429
- $app: `${runtime}/app`,
422
+ __GENERATED__: path__default.posix.join(config.kit.outDir, 'generated'),
423
+ $app: `${get_runtime_path(config)}/app`,
430
424
  $lib: config.kit.files.lib
431
425
  };
432
426
 
@@ -575,6 +569,8 @@ const options = object(
575
569
  })
576
570
  }),
577
571
 
572
+ outDir: string('.svelte-kit'),
573
+
578
574
  package: object({
579
575
  dir: string('package'),
580
576
  // excludes all .d.ts and filename starting with _
@@ -915,6 +911,8 @@ async function load_config({ cwd = process.cwd() } = {}) {
915
911
 
916
912
  const validated = validate_config(config.default);
917
913
 
914
+ validated.kit.outDir = path__default.resolve(cwd, validated.kit.outDir);
915
+
918
916
  validated.kit.files.assets = path__default.resolve(cwd, validated.kit.files.assets);
919
917
  validated.kit.files.hooks = path__default.resolve(cwd, validated.kit.files.hooks);
920
918
  validated.kit.files.lib = path__default.resolve(cwd, validated.kit.files.lib);
@@ -998,7 +996,7 @@ async function launch(port, https) {
998
996
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
999
997
  }
1000
998
 
1001
- const prog = sade('svelte-kit').version('1.0.0-next.288');
999
+ const prog = sade('svelte-kit').version('1.0.0-next.290');
1002
1000
 
1003
1001
  prog
1004
1002
  .command('dev')
@@ -1050,7 +1048,7 @@ prog
1050
1048
  process.env.NODE_ENV = process.env.NODE_ENV || 'production';
1051
1049
  const config = await load_config();
1052
1050
 
1053
- const { build } = await import('./chunks/index3.js');
1051
+ const { build } = await import('./chunks/index2.js');
1054
1052
  const build_data = await build(config);
1055
1053
 
1056
1054
  console.log(
@@ -1058,7 +1056,7 @@ prog
1058
1056
  );
1059
1057
 
1060
1058
  if (config.kit.adapter) {
1061
- const { adapt } = await import('./chunks/index5.js');
1059
+ const { adapt } = await import('./chunks/index4.js');
1062
1060
  await adapt(config, build_data, { verbose });
1063
1061
 
1064
1062
  // this is necessary to close any open db connections, etc
@@ -1093,7 +1091,7 @@ prog
1093
1091
  process.env.NODE_ENV = process.env.NODE_ENV || 'production';
1094
1092
  const config = await load_config();
1095
1093
 
1096
- const { preview } = await import('./chunks/index6.js');
1094
+ const { preview } = await import('./chunks/index5.js');
1097
1095
 
1098
1096
  await preview({ port, host, config, https });
1099
1097
 
@@ -1111,7 +1109,7 @@ prog
1111
1109
  try {
1112
1110
  const config = await load_config();
1113
1111
 
1114
- const { make_package } = await import('./chunks/index7.js');
1112
+ const { make_package } = await import('./chunks/index6.js');
1115
1113
 
1116
1114
  await make_package(config);
1117
1115
  } catch (error) {
@@ -1156,7 +1154,7 @@ async function check_port(port) {
1156
1154
  function welcome({ port, host, https, open, loose, allow, cwd }) {
1157
1155
  if (open) launch(port, https);
1158
1156
 
1159
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.288'}\n`));
1157
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.290'}\n`));
1160
1158
 
1161
1159
  const protocol = https ? 'https:' : 'http:';
1162
1160
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
@@ -1193,4 +1191,4 @@ function welcome({ port, host, https, open, loose, allow, cwd }) {
1193
1191
  console.log('\n');
1194
1192
  }
1195
1193
 
1196
- export { $, SVELTE_KIT_ASSETS as S, resolve_entry as a, SVELTE_KIT as b, coalesce_to_error as c, copy_assets as d, get_aliases as e, posixify as f, get_mime_lookup as g, rimraf as h, copy as i, logger as j, load_template as l, mkdirp as m, print_config_conflicts as p, runtime as r, walk as w };
1194
+ export { $, get_mime_lookup as a, copy_assets as b, coalesce_to_error as c, get_aliases as d, print_config_conflicts as e, rimraf as f, get_runtime_path as g, copy as h, logger as i, load_template as l, mkdirp as m, posixify as p, resolve_entry as r, walk as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.288",
3
+ "version": "1.0.0-next.290",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -79,7 +79,15 @@
79
79
  "build": "rollup -c && node scripts/cp.js src/runtime/components assets/components && npm run types",
80
80
  "dev": "rollup -cw",
81
81
  "lint": "eslint --ignore-path .gitignore --ignore-pattern \"src/packaging/test/**\" \"{src,test}/**/*.{ts,mjs,js,svelte}\" && npm run check-format",
82
- "check": "tsc && svelte-check --ignore test/prerendering,src/packaging/test",
82
+ "check": "tsc && npm run check:integration && npm run check:prerendering",
83
+ "check:integration": "npm run check:integration:amp && npm run check:integration:basics && npm run check:integration:options && npm run check:integration:options-2",
84
+ "check:integration:amp": "cd test/apps/amp && pnpm check",
85
+ "check:integration:basics": "cd test/apps/basics && pnpm check",
86
+ "check:integration:options": "cd test/apps/options && pnpm check",
87
+ "check:integration:options-2": "cd test/apps/options-2 && pnpm check",
88
+ "check:prerendering": "npm run check:prerendering:basics && npm run check:prerendering:options",
89
+ "check:prerendering:basics": "cd test/prerendering/basics && pnpm check",
90
+ "check:prerendering:options": "cd test/prerendering/options && pnpm check",
83
91
  "format": "npm run check-format -- --write",
84
92
  "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
85
93
  "test": "npm run test:unit && npm run test:typings && npm run test:packaging && npm run test:prerendering && npm run test:integration",
package/types/index.d.ts CHANGED
@@ -55,6 +55,7 @@ export interface Config {
55
55
  parameter?: string;
56
56
  allowed?: string[];
57
57
  };
58
+ outDir?: string;
58
59
  package?: {
59
60
  dir?: string;
60
61
  emitTypes?: boolean;
@@ -110,8 +111,24 @@ export interface HandleError {
110
111
  (input: { error: Error & { frame?: string }; event: RequestEvent }): void;
111
112
  }
112
113
 
113
- export interface Load<Params = Record<string, string>, Props = Record<string, any>> {
114
- (input: LoadInput<Params>): MaybePromise<Either<Fallthrough, LoadOutput<Props>>>;
114
+ /**
115
+ * The type of a `load` function exported from `<script context="module">` in a page or layout.
116
+ *
117
+ * Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the Params generic argument.
118
+ */
119
+ export interface Load<
120
+ Params extends Record<string, string> = Record<string, string>,
121
+ InputProps extends Record<string, any> = Record<string, any>,
122
+ OutputProps extends Record<string, any> = InputProps
123
+ > {
124
+ (input: LoadInput<Params, InputProps>): MaybePromise<
125
+ Either<Fallthrough, LoadOutput<OutputProps>>
126
+ >;
127
+ }
128
+
129
+ export interface Navigation {
130
+ from: URL;
131
+ to: URL;
115
132
  }
116
133
 
117
134
  export interface Page<Params extends Record<string, string> = Record<string, string>> {
@@ -122,16 +139,14 @@ export interface Page<Params extends Record<string, string> = Record<string, str
122
139
  error: Error | null;
123
140
  }
124
141
 
125
- export interface Navigation {
126
- from: URL;
127
- to: URL;
128
- }
129
-
130
142
  /**
131
143
  * A function exported from an endpoint that corresponds to an
132
144
  * HTTP verb (`get`, `put`, `patch`, etc) and handles requests with
133
145
  * that method. Note that since 'delete' is a reserved word in
134
146
  * JavaScript, delete handles are called `del` instead.
147
+ *
148
+ * Note that you can use [generated types](/docs/types#generated)
149
+ * instead of manually specifying the `Params` generic argument.
135
150
  */
136
151
  export interface RequestHandler<Params = Record<string, string>, Output extends Body = Body> {
137
152
  (event: RequestEvent<Params>): RequestHandlerOutput<Output>;
@@ -1,12 +1,12 @@
1
1
  import { OutputAsset, OutputChunk } from 'rollup';
2
2
  import {
3
- RequestHandler,
4
- Load,
3
+ Config,
5
4
  ExternalFetch,
6
5
  GetSession,
7
6
  Handle,
8
7
  HandleError,
9
- Config
8
+ Load,
9
+ RequestHandler
10
10
  } from './index';
11
11
  import {
12
12
  Either,
@@ -139,6 +139,10 @@ export interface PageData {
139
139
  b: string[];
140
140
  }
141
141
 
142
+ export type PayloadScriptAttributes =
143
+ | { type: 'data'; url: string; body?: string }
144
+ | { type: 'props' };
145
+
142
146
  export interface PrerenderDependency {
143
147
  response: Response;
144
148
  body: null | string | Uint8Array;
@@ -126,7 +126,7 @@ export namespace Csp {
126
126
  type UriPath = `${HttpDelineator}${string}`;
127
127
  }
128
128
 
129
- export type CspDirectives = {
129
+ export interface CspDirectives {
130
130
  'child-src'?: Csp.Sources;
131
131
  'default-src'?: Array<Csp.Source | Csp.ActionSource>;
132
132
  'frame-src'?: Csp.Sources;
@@ -191,7 +191,7 @@ export type CspDirectives = {
191
191
  | 'unsafe-url'
192
192
  | 'none'
193
193
  >;
194
- };
194
+ }
195
195
 
196
196
  export type Either<T, U> = Only<T, U> | Only<U, T>;
197
197
 
@@ -206,7 +206,9 @@ export interface Fallthrough {
206
206
 
207
207
  export type HttpMethod = 'get' | 'head' | 'post' | 'put' | 'delete' | 'patch';
208
208
 
209
- export type JSONObject = { [key: string]: JSONValue };
209
+ export interface JSONObject {
210
+ [key: string]: JSONValue;
211
+ }
210
212
 
211
213
  export type JSONValue =
212
214
  | string
@@ -218,10 +220,10 @@ export type JSONValue =
218
220
  | JSONValue[]
219
221
  | JSONObject;
220
222
 
221
- export interface LoadInput<Params = Record<string, string>> {
223
+ export interface LoadInput<Params = Record<string, string>, Props = Record<string, any>> {
222
224
  url: URL;
223
225
  params: Params;
224
- props: Record<string, any>;
226
+ props: Props;
225
227
  fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
226
228
  session: App.Session;
227
229
  stuff: Partial<App.Stuff>;
@@ -249,12 +251,6 @@ export type MaybePromise<T> = T | Promise<T>;
249
251
 
250
252
  export type Only<T, U> = { [P in keyof T]: T[P] } & { [P in Exclude<keyof U, keyof T>]?: never };
251
253
 
252
- export type PayloadScriptAttributes = PayloadScriptAttributesData | PayloadScriptAttributesProps;
253
-
254
- type PayloadScriptAttributesData = { type: 'data'; url: string; body?: string };
255
-
256
- type PayloadScriptAttributesProps = { type: 'props' };
257
-
258
254
  export interface Prerendered {
259
255
  pages: Map<
260
256
  string,
@@ -304,10 +300,10 @@ export interface RequestOptions {
304
300
  platform?: App.Platform;
305
301
  }
306
302
 
307
- export type ResolveOptions = {
303
+ export interface ResolveOptions {
308
304
  ssr?: boolean;
309
305
  transformPage?: ({ html }: { html: string }) => MaybePromise<string>;
310
- };
306
+ }
311
307
 
312
308
  /** `string[]` is only for set-cookie, everything else must be type of `string` */
313
309
  export type ResponseHeaders = Record<string, string | number | string[]>;
@@ -346,6 +342,8 @@ export interface SSRManifest {
346
342
  };
347
343
  }
348
344
 
349
- export type ToJSON = { toJSON(...args: any[]): Exclude<JSONValue, ToJSON> };
345
+ export interface ToJSON {
346
+ toJSON(...args: any[]): Exclude<JSONValue, ToJSON>;
347
+ }
350
348
 
351
349
  export type TrailingSlash = 'never' | 'always' | 'ignore';