@sveltejs/kit 1.0.0-next.336 → 1.0.0-next.339
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/assets/app/env.js +1 -5
- package/assets/client/start.js +89 -7
- package/assets/server/index.js +51 -70
- package/dist/chunks/filesystem.js +1 -1
- package/dist/chunks/index.js +25 -28
- package/dist/chunks/index2.js +7 -15
- package/dist/chunks/index6.js +23 -17
- package/dist/chunks/sync.js +94 -92
- package/dist/chunks/write_tsconfig.js +13 -11
- package/dist/cli.js +17 -4
- package/package.json +3 -20
- package/types/ambient.d.ts +1 -5
- package/types/index.d.ts +0 -1
- package/types/internal.d.ts +0 -1
- package/dist/chunks/amp_hook.js +0 -56
- package/dist/chunks/index7.js +0 -4207
package/dist/chunks/sync.js
CHANGED
|
@@ -193,118 +193,120 @@ function create_manifest_data({
|
|
|
193
193
|
const routes_base = posixify(path__default.relative(cwd, config.kit.files.routes));
|
|
194
194
|
const valid_extensions = [...config.extensions, ...config.kit.endpointExtensions];
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
if (fs__default.existsSync(config.kit.files.routes)) {
|
|
197
|
+
list_files(config.kit.files.routes).forEach((file) => {
|
|
198
|
+
const extension = valid_extensions.find((ext) => file.endsWith(ext));
|
|
199
|
+
if (!extension) return;
|
|
199
200
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
const id = file
|
|
202
|
+
.slice(0, -extension.length)
|
|
203
|
+
.replace(/(?:^|\/)index((?:@[a-zA-Z0-9_-]+)?(?:\.[a-z]+)?)?$/, '$1');
|
|
204
|
+
const project_relative = `${routes_base}/${file}`;
|
|
204
205
|
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
const segments = id.split('/');
|
|
207
|
+
const name = /** @type {string} */ (segments.pop());
|
|
207
208
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
209
|
+
if (name === '__layout.reset') {
|
|
210
|
+
throw new Error(
|
|
211
|
+
'__layout.reset has been removed in favour of named layouts: https://kit.svelte.dev/docs/layouts#named-layouts'
|
|
212
|
+
);
|
|
213
|
+
}
|
|
213
214
|
|
|
214
|
-
|
|
215
|
-
|
|
215
|
+
if (name === '__error' || layout_pattern.test(name)) {
|
|
216
|
+
const dir = segments.join('/');
|
|
216
217
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
if (!tree.has(dir)) {
|
|
219
|
+
tree.set(dir, {
|
|
220
|
+
error: undefined,
|
|
221
|
+
layouts: {}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
223
224
|
|
|
224
|
-
|
|
225
|
+
const group = /** @type {Node} */ (tree.get(dir));
|
|
225
226
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
if (name === '__error') {
|
|
228
|
+
group.error = project_relative;
|
|
229
|
+
} else {
|
|
230
|
+
const match = /** @type {RegExpMatchArray} */ (layout_pattern.exec(name));
|
|
230
231
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
if (match[1] === DEFAULT) {
|
|
233
|
+
throw new Error(`${project_relative} cannot use reserved "${DEFAULT}" name`);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const layout_id = match[1] || DEFAULT;
|
|
234
237
|
|
|
235
|
-
|
|
238
|
+
const defined = group.layouts[layout_id];
|
|
239
|
+
if (defined && defined !== default_layout) {
|
|
240
|
+
throw new Error(
|
|
241
|
+
`Duplicate layout ${project_relative} already defined at ${defined.file}`
|
|
242
|
+
);
|
|
243
|
+
}
|
|
236
244
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
);
|
|
245
|
+
group.layouts[layout_id] = {
|
|
246
|
+
file: project_relative,
|
|
247
|
+
name
|
|
248
|
+
};
|
|
242
249
|
}
|
|
243
250
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
251
|
+
return;
|
|
252
|
+
} else if (dunder_pattern.test(file)) {
|
|
253
|
+
throw new Error(
|
|
254
|
+
`Files and directories prefixed with __ are reserved (saw ${project_relative})`
|
|
255
|
+
);
|
|
248
256
|
}
|
|
249
257
|
|
|
250
|
-
return;
|
|
251
|
-
} else if (dunder_pattern.test(file)) {
|
|
252
|
-
throw new Error(
|
|
253
|
-
`Files and directories prefixed with __ are reserved (saw ${project_relative})`
|
|
254
|
-
);
|
|
255
|
-
}
|
|
258
|
+
if (!config.kit.routes(file)) return;
|
|
256
259
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
throw new Error(`Invalid route ${project_relative} — parameters must be separated`);
|
|
261
|
-
}
|
|
260
|
+
if (/\]\[/.test(id)) {
|
|
261
|
+
throw new Error(`Invalid route ${project_relative} — parameters must be separated`);
|
|
262
|
+
}
|
|
262
263
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
if (count_occurrences('[', id) !== count_occurrences(']', id)) {
|
|
265
|
+
throw new Error(`Invalid route ${project_relative} — brackets are unbalanced`);
|
|
266
|
+
}
|
|
266
267
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
268
|
+
if (!units.has(id)) {
|
|
269
|
+
units.set(id, {
|
|
270
|
+
id,
|
|
271
|
+
pattern: parse_route_id(id).pattern,
|
|
272
|
+
segments: id
|
|
273
|
+
.split('/')
|
|
274
|
+
.filter(Boolean)
|
|
275
|
+
.map((segment) => {
|
|
276
|
+
/** @type {Part[]} */
|
|
277
|
+
const parts = [];
|
|
278
|
+
segment.split(/\[(.+?)\]/).map((content, i) => {
|
|
279
|
+
const dynamic = !!(i % 2);
|
|
280
|
+
|
|
281
|
+
if (!content) return;
|
|
282
|
+
|
|
283
|
+
parts.push({
|
|
284
|
+
content,
|
|
285
|
+
dynamic,
|
|
286
|
+
rest: dynamic && content.startsWith('...'),
|
|
287
|
+
type: (dynamic && content.split('=')[1]) || null
|
|
288
|
+
});
|
|
287
289
|
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
}
|
|
290
|
+
return parts;
|
|
291
|
+
}),
|
|
292
|
+
page: undefined,
|
|
293
|
+
endpoint: undefined
|
|
294
|
+
});
|
|
295
|
+
}
|
|
295
296
|
|
|
296
|
-
|
|
297
|
+
const unit = /** @type {Unit} */ (units.get(id));
|
|
297
298
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
299
|
+
if (config.extensions.find((ext) => file.endsWith(ext))) {
|
|
300
|
+
const { layouts, errors } = trace(project_relative, file, tree, config.extensions);
|
|
301
|
+
unit.page = {
|
|
302
|
+
a: layouts.concat(project_relative),
|
|
303
|
+
b: errors
|
|
304
|
+
};
|
|
305
|
+
} else {
|
|
306
|
+
unit.endpoint = project_relative;
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
308
310
|
|
|
309
311
|
/** @type {string[]} */
|
|
310
312
|
const components = [];
|
|
@@ -29,11 +29,12 @@ function trim(str) {
|
|
|
29
29
|
const exists = (file) => fs__default.existsSync(file) && file;
|
|
30
30
|
|
|
31
31
|
/** @param {import('types').ValidatedConfig} config */
|
|
32
|
-
function write_tsconfig(config) {
|
|
32
|
+
function write_tsconfig(config, cwd = process.cwd()) {
|
|
33
33
|
const out = path__default.join(config.kit.outDir, 'tsconfig.json');
|
|
34
|
-
const user_file =
|
|
34
|
+
const user_file =
|
|
35
|
+
exists(path__default.resolve(cwd, 'tsconfig.json')) || exists(path__default.resolve(cwd, 'jsconfig.json'));
|
|
35
36
|
|
|
36
|
-
if (user_file) validate(config, out, user_file);
|
|
37
|
+
if (user_file) validate(config, cwd, out, user_file);
|
|
37
38
|
|
|
38
39
|
/** @param {string} file */
|
|
39
40
|
const project_relative = (file) => posixify(path__default.relative('.', file));
|
|
@@ -97,17 +98,20 @@ function write_tsconfig(config) {
|
|
|
97
98
|
|
|
98
99
|
/**
|
|
99
100
|
* @param {import('types').ValidatedConfig} config
|
|
101
|
+
* @param {string} cwd
|
|
100
102
|
* @param {string} out
|
|
101
103
|
* @param {string} user_file
|
|
102
104
|
*/
|
|
103
|
-
function validate(config, out, user_file) {
|
|
105
|
+
function validate(config, cwd, out, user_file) {
|
|
104
106
|
// we have to eval the file, since it's not parseable as JSON (contains comments)
|
|
105
107
|
const user_tsconfig_json = fs__default.readFileSync(user_file, 'utf-8');
|
|
106
108
|
const user_tsconfig = (0, eval)(`(${user_tsconfig_json})`);
|
|
107
109
|
|
|
108
110
|
// we need to check that the user's tsconfig extends the framework config
|
|
109
111
|
const extend = user_tsconfig.extends;
|
|
110
|
-
const extends_framework_config = extend && path__default.resolve(
|
|
112
|
+
const extends_framework_config = extend && path__default.resolve(cwd, extend) === out;
|
|
113
|
+
|
|
114
|
+
const kind = path__default.basename(user_file);
|
|
111
115
|
|
|
112
116
|
if (extends_framework_config) {
|
|
113
117
|
const { paths: user_paths } = user_tsconfig.compilerOptions || {};
|
|
@@ -119,16 +123,16 @@ function validate(config, out, user_file) {
|
|
|
119
123
|
const lib_ = user_paths['$lib/*'] || [];
|
|
120
124
|
|
|
121
125
|
const missing_lib_paths =
|
|
122
|
-
!lib.some((relative) => path__default.resolve(
|
|
126
|
+
!lib.some((relative) => path__default.resolve(cwd, relative) === config.kit.files.lib) ||
|
|
123
127
|
!lib_.some(
|
|
124
|
-
(relative) => path__default.resolve(
|
|
128
|
+
(relative) => path__default.resolve(cwd, relative) === path__default.join(config.kit.files.lib, '/*')
|
|
125
129
|
);
|
|
126
130
|
|
|
127
131
|
if (missing_lib_paths) {
|
|
128
132
|
console.warn(
|
|
129
133
|
$
|
|
130
134
|
.bold()
|
|
131
|
-
.yellow(`Your compilerOptions.paths in ${
|
|
135
|
+
.yellow(`Your compilerOptions.paths in ${kind} should include the following:`)
|
|
132
136
|
);
|
|
133
137
|
const relative = posixify(path__default.relative('.', config.kit.files.lib));
|
|
134
138
|
console.warn(`{\n "$lib":["${relative}"],\n "$lib/*":["${relative}/*"]\n}`);
|
|
@@ -139,9 +143,7 @@ function validate(config, out, user_file) {
|
|
|
139
143
|
if (!relative.startsWith('./')) relative = './' + relative;
|
|
140
144
|
|
|
141
145
|
console.warn(
|
|
142
|
-
$
|
|
143
|
-
.bold()
|
|
144
|
-
.yellow(`Your ${user_file} should extend the configuration generated by SvelteKit:`)
|
|
146
|
+
$.bold().yellow(`Your ${kind} should extend the configuration generated by SvelteKit:`)
|
|
145
147
|
);
|
|
146
148
|
console.warn(`{\n "extends": "${relative}"\n}`);
|
|
147
149
|
}
|
package/dist/cli.js
CHANGED
|
@@ -338,7 +338,11 @@ const options = object(
|
|
|
338
338
|
return input;
|
|
339
339
|
}),
|
|
340
340
|
|
|
341
|
-
|
|
341
|
+
// TODO: remove this for the 1.0 release
|
|
342
|
+
amp: error(
|
|
343
|
+
(keypath) =>
|
|
344
|
+
`${keypath} has been removed. See https://kit.svelte.dev/docs/seo#amp for details on how to support AMP`
|
|
345
|
+
),
|
|
342
346
|
|
|
343
347
|
appDir: validate('_app', (input, keypath) => {
|
|
344
348
|
assert_string(input, keypath);
|
|
@@ -761,7 +765,16 @@ function load_template(cwd, config) {
|
|
|
761
765
|
|
|
762
766
|
if (fs__default.existsSync(template)) {
|
|
763
767
|
const contents = fs__default.readFileSync(template, 'utf8');
|
|
764
|
-
|
|
768
|
+
|
|
769
|
+
// TODO remove this for 1.0
|
|
770
|
+
const match = /%svelte\.([a-z]+)%/.exec(contents);
|
|
771
|
+
if (match) {
|
|
772
|
+
throw new Error(
|
|
773
|
+
`%svelte.${match[1]}% in ${relative} should be replaced with %sveltekit.${match[1]}%`
|
|
774
|
+
);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const expected_tags = ['%sveltekit.head%', '%sveltekit.body%'];
|
|
765
778
|
expected_tags.forEach((tag) => {
|
|
766
779
|
if (contents.indexOf(tag) === -1) {
|
|
767
780
|
throw new Error(`${relative} is missing ${tag}`);
|
|
@@ -871,7 +884,7 @@ async function launch(port, https, base) {
|
|
|
871
884
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
872
885
|
}
|
|
873
886
|
|
|
874
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
887
|
+
const prog = sade('svelte-kit').version('1.0.0-next.339');
|
|
875
888
|
|
|
876
889
|
prog
|
|
877
890
|
.command('dev')
|
|
@@ -1093,7 +1106,7 @@ async function check_port(port) {
|
|
|
1093
1106
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1094
1107
|
if (open) launch(port, https, base);
|
|
1095
1108
|
|
|
1096
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1109
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.339'}\n`));
|
|
1097
1110
|
|
|
1098
1111
|
const protocol = https ? 'https:' : 'http:';
|
|
1099
1112
|
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.
|
|
3
|
+
"version": "1.0.0-next.339",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -13,41 +13,24 @@
|
|
|
13
13
|
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.44",
|
|
14
14
|
"chokidar": "^3.5.3",
|
|
15
15
|
"sade": "^1.7.4",
|
|
16
|
-
"vite": "^2.9.
|
|
16
|
+
"vite": "^2.9.9"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@playwright/test": "^1.21.0",
|
|
20
|
-
"@rollup/plugin-replace": "^4.0.0",
|
|
21
|
-
"@types/amphtml-validator": "^1.0.1",
|
|
22
19
|
"@types/connect": "^3.4.35",
|
|
23
20
|
"@types/cookie": "^0.5.0",
|
|
24
21
|
"@types/marked": "^4.0.1",
|
|
25
22
|
"@types/mime": "^2.0.3",
|
|
26
|
-
"@types/node": "^16.11.11",
|
|
27
23
|
"@types/sade": "^1.7.3",
|
|
28
24
|
"@types/set-cookie-parser": "^2.4.2",
|
|
29
|
-
"amphtml-validator": "^1.0.35",
|
|
30
25
|
"cookie": "^0.5.0",
|
|
31
|
-
"cross-env": "^7.0.3",
|
|
32
26
|
"devalue": "^2.0.1",
|
|
33
|
-
"eslint": "^8.3.0",
|
|
34
27
|
"kleur": "^4.1.4",
|
|
35
28
|
"locate-character": "^2.0.5",
|
|
36
|
-
"marked": "^4.0.5",
|
|
37
29
|
"mime": "^3.0.0",
|
|
38
30
|
"node-fetch": "^3.1.0",
|
|
39
|
-
"port-authority": "^1.1.2",
|
|
40
|
-
"rollup": "^2.60.2",
|
|
41
31
|
"selfsigned": "^2.0.0",
|
|
42
32
|
"set-cookie-parser": "^2.4.8",
|
|
43
|
-
"
|
|
44
|
-
"svelte": "^3.44.2",
|
|
45
|
-
"svelte-check": "^2.5.0",
|
|
46
|
-
"svelte-preprocess": "^4.9.8",
|
|
47
|
-
"svelte2tsx": "~0.5.0",
|
|
48
|
-
"tiny-glob": "^0.2.9",
|
|
49
|
-
"typescript": "^4.6.4",
|
|
50
|
-
"uvu": "^0.5.2"
|
|
33
|
+
"svelte": "^3.48.0"
|
|
51
34
|
},
|
|
52
35
|
"peerDependencies": {
|
|
53
36
|
"svelte": "^3.44.0"
|
package/types/ambient.d.ts
CHANGED
|
@@ -49,14 +49,10 @@ declare namespace App {
|
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* ```ts
|
|
52
|
-
* import {
|
|
52
|
+
* import { browser, dev, mode, prerendering } from '$app/env';
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
declare module '$app/env' {
|
|
56
|
-
/**
|
|
57
|
-
* Whether or not the app is running in [AMP mode](/docs/seo#manual-setup-amp).
|
|
58
|
-
*/
|
|
59
|
-
export const amp: boolean;
|
|
60
56
|
/**
|
|
61
57
|
* Whether the app is running in the browser or on the server.
|
|
62
58
|
*/
|
package/types/index.d.ts
CHANGED
package/types/internal.d.ts
CHANGED
package/dist/chunks/amp_hook.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** @type {import('amphtml-validator').Validator} */
|
|
2
|
-
const amp = await (await import('./index7.js').then(function (n) { return n.i; })).getInstance();
|
|
3
|
-
|
|
4
|
-
/** @type {import('types').Handle} */
|
|
5
|
-
async function handle({ event, resolve }) {
|
|
6
|
-
const response = await resolve(event);
|
|
7
|
-
if (response.headers.get('content-type') !== 'text/html') {
|
|
8
|
-
return response;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let rendered = await response.text();
|
|
12
|
-
const result = amp.validateString(rendered);
|
|
13
|
-
|
|
14
|
-
if (result.status !== 'PASS') {
|
|
15
|
-
const lines = rendered.split('\n');
|
|
16
|
-
|
|
17
|
-
/** @param {string} str */
|
|
18
|
-
const escape = (str) => str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
19
|
-
|
|
20
|
-
rendered = `<!doctype html>
|
|
21
|
-
<head>
|
|
22
|
-
<meta charset="utf-8" />
|
|
23
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
24
|
-
<style>
|
|
25
|
-
body {
|
|
26
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
27
|
-
color: #333;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
pre {
|
|
31
|
-
background: #f4f4f4;
|
|
32
|
-
padding: 1em;
|
|
33
|
-
overflow-x: auto;
|
|
34
|
-
}
|
|
35
|
-
</style>
|
|
36
|
-
</head>
|
|
37
|
-
<h1>AMP validation failed</h1>
|
|
38
|
-
|
|
39
|
-
${result.errors
|
|
40
|
-
.map(
|
|
41
|
-
(error) => `
|
|
42
|
-
<h2>${error.severity}</h2>
|
|
43
|
-
<p>Line ${error.line}, column ${error.col}: ${error.message} (<a href="${error.specUrl}">${
|
|
44
|
-
error.code
|
|
45
|
-
}</a>)</p>
|
|
46
|
-
<pre>${escape(lines[error.line - 1])}</pre>
|
|
47
|
-
`
|
|
48
|
-
)
|
|
49
|
-
.join('\n\n')}
|
|
50
|
-
`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return new Response(rendered, { status: response.status, headers: response.headers });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { handle };
|