@sveltejs/kit 1.0.0-next.587 → 1.0.0-next.589
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/package.json +1 -1
- package/src/cli.js +0 -64
- package/src/core/adapt/builder.js +17 -33
- package/src/core/config/index.js +0 -11
- package/src/core/config/options.js +7 -144
- package/src/core/prerender/prerender.js +0 -13
- package/src/core/sync/create_manifest_data/index.js +1 -10
- package/src/core/sync/sync.js +0 -19
- package/src/core/sync/write_types/index.js +1 -1
- package/src/exports/vite/build/build_server.js +3 -31
- package/src/exports/vite/build/build_service_worker.js +0 -7
- package/src/exports/vite/dev/index.js +1 -45
- package/src/exports/vite/index.js +0 -16
- package/src/runtime/app/forms.js +1 -11
- package/src/runtime/app/navigation.js +0 -10
- package/src/runtime/app/stores.js +1 -46
- package/src/runtime/client/client.js +8 -167
- package/src/runtime/server/endpoint.js +1 -4
- package/src/runtime/server/index.js +1 -48
- package/src/runtime/server/page/load_data.js +1 -15
- package/src/runtime/server/page/render.js +0 -17
- package/src/runtime/server/utils.js +0 -28
- package/src/utils/filesystem.js +1 -0
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -27,20 +27,6 @@ prog
|
|
|
27
27
|
.describe('Synchronise generated files')
|
|
28
28
|
.option('--mode', 'Specify a mode for loading environment variables', 'development')
|
|
29
29
|
.action(async ({ mode }) => {
|
|
30
|
-
const event = process.env.npm_lifecycle_event;
|
|
31
|
-
|
|
32
|
-
// TODO remove for 1.0
|
|
33
|
-
if (event === 'prepare') {
|
|
34
|
-
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
35
|
-
const message =
|
|
36
|
-
pkg.scripts.prepare === 'svelte-kit sync'
|
|
37
|
-
? `\`svelte-kit sync\` now runs on "postinstall" — please remove the "prepare" script from your package.json\n`
|
|
38
|
-
: `\`svelte-kit sync\` now runs on "postinstall" — please remove it from your "prepare" script\n`;
|
|
39
|
-
|
|
40
|
-
console.error(colors.bold().red(message));
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
30
|
if (!fs.existsSync('svelte.config.js')) {
|
|
45
31
|
console.warn(`Missing ${path.resolve('svelte.config.js')} — skipping`);
|
|
46
32
|
return;
|
|
@@ -55,54 +41,4 @@ prog
|
|
|
55
41
|
}
|
|
56
42
|
});
|
|
57
43
|
|
|
58
|
-
// TODO remove for 1.0
|
|
59
|
-
replace('dev');
|
|
60
|
-
replace('build');
|
|
61
|
-
replace('preview');
|
|
62
|
-
prog
|
|
63
|
-
.command('package')
|
|
64
|
-
.describe('No longer available - use @sveltejs/package instead')
|
|
65
|
-
.action(() => {
|
|
66
|
-
console.error(
|
|
67
|
-
'svelte-kit package has been removed. It now lives in its own npm package. See the PR on how to migrate: https://github.com/sveltejs/kit/pull/5730'
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
44
|
prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });
|
|
72
|
-
|
|
73
|
-
/** @param {string} command */
|
|
74
|
-
function replace(command) {
|
|
75
|
-
prog
|
|
76
|
-
.command(command)
|
|
77
|
-
.describe(`No longer available — use vite ${command} instead`)
|
|
78
|
-
.action(async () => {
|
|
79
|
-
const message = `\n> svelte-kit ${command} is no longer available — use vite ${command} instead`;
|
|
80
|
-
console.error(colors.bold().red(message));
|
|
81
|
-
|
|
82
|
-
const steps = [
|
|
83
|
-
'Install vite as a devDependency with npm/pnpm/etc',
|
|
84
|
-
'Create a vite.config.js with the @sveltejs/kit/vite plugin (see below)',
|
|
85
|
-
`Update your package.json scripts to reference \`vite ${command}\` instead of \`svelte-kit ${command}\``
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
steps.forEach((step, i) => {
|
|
89
|
-
console.error(` ${i + 1}. ${colors.cyan(step)}`);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
console.error(
|
|
93
|
-
`
|
|
94
|
-
${colors.grey('// vite.config.js')}
|
|
95
|
-
import { sveltekit } from '@sveltejs/kit/vite';
|
|
96
|
-
|
|
97
|
-
/** @type {import('vite').UserConfig} */
|
|
98
|
-
const config = {
|
|
99
|
-
plugins: [sveltekit()]
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
export default config;
|
|
103
|
-
|
|
104
|
-
`.replace(/^\t{4}/gm, '')
|
|
105
|
-
);
|
|
106
|
-
process.exit(1);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
@@ -33,6 +33,23 @@ export function create_builder({ config, build_data, routes, prerendered, log })
|
|
|
33
33
|
config,
|
|
34
34
|
prerendered,
|
|
35
35
|
|
|
36
|
+
async compress(directory) {
|
|
37
|
+
if (!existsSync(directory)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const files = await glob('**/*.{html,js,json,css,svg,xml,wasm}', {
|
|
42
|
+
cwd: directory,
|
|
43
|
+
dot: true,
|
|
44
|
+
absolute: true,
|
|
45
|
+
filesOnly: true
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
await Promise.all(
|
|
49
|
+
files.map((file) => Promise.all([compress_file(file, 'gz'), compress_file(file, 'br')]))
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
|
|
36
53
|
async createEntries(fn) {
|
|
37
54
|
/** @type {import('types').RouteDefinition[]} */
|
|
38
55
|
const facades = routes.map((route) => {
|
|
@@ -177,39 +194,6 @@ export function create_builder({ config, build_data, routes, prerendered, log })
|
|
|
177
194
|
|
|
178
195
|
writeServer(dest) {
|
|
179
196
|
return copy(`${config.kit.outDir}/output/server`, dest);
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
// TODO remove these methods for 1.0
|
|
183
|
-
// @ts-expect-error
|
|
184
|
-
writeStatic() {
|
|
185
|
-
throw new Error(
|
|
186
|
-
`writeStatic has been removed. Please ensure you are using the latest version of ${
|
|
187
|
-
config.kit.adapter.name || 'your adapter'
|
|
188
|
-
}`
|
|
189
|
-
);
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
async compress(directory) {
|
|
193
|
-
if (!existsSync(directory)) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const files = await glob('**/*.{html,js,json,css,svg,xml,wasm}', {
|
|
198
|
-
cwd: directory,
|
|
199
|
-
dot: true,
|
|
200
|
-
absolute: true,
|
|
201
|
-
filesOnly: true
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
await Promise.all(
|
|
205
|
-
files.map((file) => Promise.all([compress_file(file, 'gz'), compress_file(file, 'br')]))
|
|
206
|
-
);
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
async prerender() {
|
|
210
|
-
throw new Error(
|
|
211
|
-
'builder.prerender() has been removed. Prerendering now takes place in the build phase — see builder.prerender and builder.writePrerendered'
|
|
212
|
-
);
|
|
213
197
|
}
|
|
214
198
|
};
|
|
215
199
|
}
|
package/src/core/config/index.js
CHANGED
|
@@ -16,14 +16,6 @@ export function load_template(cwd, config) {
|
|
|
16
16
|
if (fs.existsSync(appTemplate)) {
|
|
17
17
|
const contents = fs.readFileSync(appTemplate, 'utf8');
|
|
18
18
|
|
|
19
|
-
// TODO remove this for 1.0
|
|
20
|
-
const match = /%svelte\.([a-z]+)%/.exec(contents);
|
|
21
|
-
if (match) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
`%svelte.${match[1]}% in ${relative} should be replaced with %sveltekit.${match[1]}%`
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
const expected_tags = ['%sveltekit.head%', '%sveltekit.body%'];
|
|
28
20
|
expected_tags.forEach((tag) => {
|
|
29
21
|
if (contents.indexOf(tag) === -1) {
|
|
@@ -81,9 +73,6 @@ function process_config(config, { cwd = process.cwd() } = {}) {
|
|
|
81
73
|
validated.kit.outDir = path.resolve(cwd, validated.kit.outDir);
|
|
82
74
|
|
|
83
75
|
for (const key in validated.kit.files) {
|
|
84
|
-
// TODO remove for 1.0
|
|
85
|
-
if (key === 'template') continue;
|
|
86
|
-
|
|
87
76
|
if (key === 'hooks') {
|
|
88
77
|
validated.kit.files.hooks.client = path.resolve(cwd, validated.kit.files.hooks.client);
|
|
89
78
|
validated.kit.files.hooks.server = path.resolve(cwd, validated.kit.files.hooks.server);
|
|
@@ -85,12 +85,6 @@ const options = object(
|
|
|
85
85
|
return input;
|
|
86
86
|
}),
|
|
87
87
|
|
|
88
|
-
// TODO: remove this for the 1.0 release
|
|
89
|
-
amp: error(
|
|
90
|
-
(keypath) =>
|
|
91
|
-
`${keypath} has been removed. See https://kit.svelte.dev/docs/seo#manual-setup-amp for details on how to support AMP`
|
|
92
|
-
),
|
|
93
|
-
|
|
94
88
|
appDir: validate('_app', (input, keypath) => {
|
|
95
89
|
assert_string(input, keypath);
|
|
96
90
|
|
|
@@ -107,18 +101,6 @@ const options = object(
|
|
|
107
101
|
return input;
|
|
108
102
|
}),
|
|
109
103
|
|
|
110
|
-
// TODO: remove this for the 1.0 release
|
|
111
|
-
browser: object({
|
|
112
|
-
hydrate: error(
|
|
113
|
-
(keypath) =>
|
|
114
|
-
`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
|
|
115
|
-
),
|
|
116
|
-
router: error(
|
|
117
|
-
(keypath) =>
|
|
118
|
-
`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
|
|
119
|
-
)
|
|
120
|
-
}),
|
|
121
|
-
|
|
122
104
|
csp: object({
|
|
123
105
|
mode: list(['auto', 'hash', 'nonce']),
|
|
124
106
|
directives,
|
|
@@ -131,11 +113,6 @@ const options = object(
|
|
|
131
113
|
|
|
132
114
|
embedded: boolean(false),
|
|
133
115
|
|
|
134
|
-
// TODO: remove this for the 1.0 release
|
|
135
|
-
endpointExtensions: error(
|
|
136
|
-
(keypath) => `${keypath} has been renamed to config.kit.moduleExtensions`
|
|
137
|
-
),
|
|
138
|
-
|
|
139
116
|
env: object({
|
|
140
117
|
dir: string(process.cwd()),
|
|
141
118
|
publicPrefix: string('PUBLIC_')
|
|
@@ -143,59 +120,24 @@ const options = object(
|
|
|
143
120
|
|
|
144
121
|
files: object({
|
|
145
122
|
assets: string('static'),
|
|
146
|
-
hooks: (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
`${keypath} is an object with { server: string, client: string } now. See the PR for more information: https://github.com/sveltejs/kit/pull/6586`
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return object({
|
|
155
|
-
client: string(join('src', 'hooks.client')),
|
|
156
|
-
server: string(join('src', 'hooks.server'))
|
|
157
|
-
})(input, keypath);
|
|
158
|
-
},
|
|
123
|
+
hooks: object({
|
|
124
|
+
client: string(join('src', 'hooks.client')),
|
|
125
|
+
server: string(join('src', 'hooks.server'))
|
|
126
|
+
}),
|
|
159
127
|
lib: string(join('src', 'lib')),
|
|
160
128
|
params: string(join('src', 'params')),
|
|
161
129
|
routes: string(join('src', 'routes')),
|
|
162
130
|
serviceWorker: string(join('src', 'service-worker')),
|
|
163
131
|
appTemplate: string(join('src', 'app.html')),
|
|
164
|
-
errorTemplate: string(join('src', 'error.html'))
|
|
165
|
-
// TODO: remove this for the 1.0 release
|
|
166
|
-
template: error(
|
|
167
|
-
() => 'config.kit.files.template has been renamed to config.kit.files.appTemplate'
|
|
168
|
-
)
|
|
132
|
+
errorTemplate: string(join('src', 'error.html'))
|
|
169
133
|
}),
|
|
170
134
|
|
|
171
|
-
// TODO: remove this for the 1.0 release
|
|
172
|
-
headers: error(
|
|
173
|
-
(keypath) =>
|
|
174
|
-
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
175
|
-
),
|
|
176
|
-
|
|
177
|
-
// TODO: remove this for the 1.0 release
|
|
178
|
-
host: error(
|
|
179
|
-
(keypath) =>
|
|
180
|
-
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
181
|
-
),
|
|
182
|
-
|
|
183
|
-
// TODO remove for 1.0
|
|
184
|
-
hydrate: error((keypath) => `${keypath} has been moved to config.kit.browser.hydrate`),
|
|
185
|
-
|
|
186
135
|
inlineStyleThreshold: number(0),
|
|
187
136
|
|
|
188
|
-
methodOverride: error(
|
|
189
|
-
() =>
|
|
190
|
-
'Method overrides have been removed in favor of actions. See the PR for more information: https://github.com/sveltejs/kit/pull/6469'
|
|
191
|
-
),
|
|
192
|
-
|
|
193
137
|
moduleExtensions: string_array(['.js', '.ts']),
|
|
194
138
|
|
|
195
139
|
outDir: string('.svelte-kit'),
|
|
196
140
|
|
|
197
|
-
package: error((keypath) => `${keypath} has been removed — use @sveltejs/package instead`),
|
|
198
|
-
|
|
199
141
|
paths: object({
|
|
200
142
|
base: validate('', (input, keypath) => {
|
|
201
143
|
assert_string(input, keypath);
|
|
@@ -232,18 +174,6 @@ const options = object(
|
|
|
232
174
|
prerender: object({
|
|
233
175
|
concurrency: number(1),
|
|
234
176
|
crawl: boolean(true),
|
|
235
|
-
createIndexFiles: error(
|
|
236
|
-
(keypath) =>
|
|
237
|
-
`${keypath} has been removed — it is now controlled by the trailingSlash option. See https://kit.svelte.dev/docs/page-options#trailingslash`
|
|
238
|
-
),
|
|
239
|
-
default: error(
|
|
240
|
-
(keypath) =>
|
|
241
|
-
`${keypath} has been removed. You can set it inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
|
|
242
|
-
),
|
|
243
|
-
enabled: error(
|
|
244
|
-
(keypath) =>
|
|
245
|
-
`${keypath} has been removed. You can wrap any code that should not be executed during build in a \`if (!building) {...}\` block. See the discussion for more information: https://github.com/sveltejs/kit/discussions/7716`
|
|
246
|
-
),
|
|
247
177
|
entries: validate(['*'], (input, keypath) => {
|
|
248
178
|
if (!Array.isArray(input) || !input.every((page) => typeof page === 'string')) {
|
|
249
179
|
throw new Error(`${keypath} must be an array of strings`);
|
|
@@ -260,17 +190,6 @@ const options = object(
|
|
|
260
190
|
return input;
|
|
261
191
|
}),
|
|
262
192
|
|
|
263
|
-
// TODO: remove this for the 1.0 release
|
|
264
|
-
force: validate(undefined, (input, keypath) => {
|
|
265
|
-
const new_input = input ? 'warn' : 'fail';
|
|
266
|
-
const needs_option = new_input === 'warn';
|
|
267
|
-
throw new Error(
|
|
268
|
-
`${keypath} has been removed in favor of \`handleHttpError\`. In your case, set \`handleHttpError\` to "${new_input}"${
|
|
269
|
-
needs_option ? '' : ' (or leave it undefined)'
|
|
270
|
-
} to get the same behavior as you would with \`force: ${JSON.stringify(input)}\``
|
|
271
|
-
);
|
|
272
|
-
}),
|
|
273
|
-
|
|
274
193
|
handleHttpError: validate('fail', (input, keypath) => {
|
|
275
194
|
if (typeof input === 'function') return input;
|
|
276
195
|
if (['fail', 'warn', 'ignore'].includes(input)) return input;
|
|
@@ -283,17 +202,6 @@ const options = object(
|
|
|
283
202
|
throw new Error(`${keypath} should be "fail", "warn", "ignore" or a custom function`);
|
|
284
203
|
}),
|
|
285
204
|
|
|
286
|
-
// TODO: remove this for the 1.0 release
|
|
287
|
-
onError: validate(undefined, (input, keypath) => {
|
|
288
|
-
let message = `${keypath} has been renamed to \`handleHttpError\``;
|
|
289
|
-
|
|
290
|
-
if (input === 'continue') {
|
|
291
|
-
message += ', and "continue" has been renamed to "warn"';
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
throw new Error(message);
|
|
295
|
-
}),
|
|
296
|
-
|
|
297
205
|
origin: validate('http://sveltekit-prerender', (input, keypath) => {
|
|
298
206
|
assert_string(input, keypath);
|
|
299
207
|
|
|
@@ -310,56 +218,18 @@ const options = object(
|
|
|
310
218
|
}
|
|
311
219
|
|
|
312
220
|
return origin;
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
// TODO: remove this for the 1.0 release
|
|
316
|
-
pages: error((keypath) => `${keypath} has been renamed to \`entries\`.`)
|
|
221
|
+
})
|
|
317
222
|
}),
|
|
318
223
|
|
|
319
|
-
// TODO: remove this for the 1.0 release
|
|
320
|
-
protocol: error(
|
|
321
|
-
(keypath) =>
|
|
322
|
-
`${keypath} has been removed. See https://github.com/sveltejs/kit/pull/3384 for details`
|
|
323
|
-
),
|
|
324
|
-
|
|
325
|
-
// TODO remove for 1.0
|
|
326
|
-
router: error(
|
|
327
|
-
(keypath) =>
|
|
328
|
-
`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js (or +layout.server.js) instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
|
|
329
|
-
),
|
|
330
|
-
|
|
331
|
-
// TODO remove for 1.0
|
|
332
|
-
routes: error(
|
|
333
|
-
(keypath) =>
|
|
334
|
-
`${keypath} has been removed. See https://github.com/sveltejs/kit/discussions/5774 for details`
|
|
335
|
-
),
|
|
336
|
-
|
|
337
224
|
serviceWorker: object({
|
|
338
225
|
register: boolean(true),
|
|
339
226
|
files: fun((filename) => !/\.DS_Store/.test(filename))
|
|
340
227
|
}),
|
|
341
228
|
|
|
342
|
-
// TODO remove this for 1.0
|
|
343
|
-
ssr: error(
|
|
344
|
-
(keypath) =>
|
|
345
|
-
`${keypath} has been removed — use the handle hook instead: https://kit.svelte.dev/docs/hooks#server-hooks-handle`
|
|
346
|
-
),
|
|
347
|
-
|
|
348
|
-
// TODO remove this for 1.0
|
|
349
|
-
target: error((keypath) => `${keypath} is no longer required, and should be removed`),
|
|
350
|
-
|
|
351
|
-
trailingSlash: error(
|
|
352
|
-
(keypath, input) =>
|
|
353
|
-
`${keypath} has been removed. You can set \`export const trailingSlash = '${input}'\` inside a top level +layout.js (or +layout.server.js) instead. See the PR for more information: https://github.com/sveltejs/kit/pull/7719`
|
|
354
|
-
),
|
|
355
|
-
|
|
356
229
|
version: object({
|
|
357
230
|
name: string(Date.now().toString()),
|
|
358
231
|
pollInterval: number(0)
|
|
359
|
-
})
|
|
360
|
-
|
|
361
|
-
// TODO remove this for 1.0
|
|
362
|
-
vite: error((keypath) => `${keypath} has been removed — use vite.config.js instead`)
|
|
232
|
+
})
|
|
363
233
|
})
|
|
364
234
|
},
|
|
365
235
|
true
|
|
@@ -514,11 +384,4 @@ function assert_string(input, keypath) {
|
|
|
514
384
|
}
|
|
515
385
|
}
|
|
516
386
|
|
|
517
|
-
/** @param {(keypath?: string, input?: any) => string} fn */
|
|
518
|
-
function error(fn) {
|
|
519
|
-
return validate(undefined, (input, keypath) => {
|
|
520
|
-
throw new Error(fn(keypath, input));
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
|
|
524
387
|
export default options;
|
|
@@ -91,19 +91,6 @@ export async function prerender() {
|
|
|
91
91
|
|
|
92
92
|
installPolyfills();
|
|
93
93
|
|
|
94
|
-
// TODO remove this for 1.0
|
|
95
|
-
const { fetch } = globalThis;
|
|
96
|
-
globalThis.fetch = async (info, init) => {
|
|
97
|
-
const url = info instanceof Request ? info.url : info.toString();
|
|
98
|
-
|
|
99
|
-
if (url.startsWith(config.prerender.origin + '/')) {
|
|
100
|
-
const sliced = url.slice(config.prerender.origin.length);
|
|
101
|
-
throw new Error(`Use \`event.fetch('${sliced}')\` instead of the global \`fetch('${url}')\``);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return fetch(info, init);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
94
|
const server_root = join(config.outDir, 'output');
|
|
108
95
|
|
|
109
96
|
/** @type {import('types').ServerModule} */
|
|
@@ -266,9 +266,7 @@ function create_routes_and_nodes(cwd, config, fallback) {
|
|
|
266
266
|
const root = routes[0];
|
|
267
267
|
if (!root.leaf && !root.error && !root.layout && !root.endpoint) {
|
|
268
268
|
throw new Error(
|
|
269
|
-
|
|
270
|
-
// 'No routes found. If you are using a custom src/routes directory, make sure it is specified in svelte.config.js'
|
|
271
|
-
'The filesystem router API has changed, see https://github.com/sveltejs/kit/discussions/5774 for details'
|
|
269
|
+
'No routes found. If you are using a custom src/routes directory, make sure it is specified in svelte.config.js'
|
|
272
270
|
);
|
|
273
271
|
}
|
|
274
272
|
}
|
|
@@ -386,13 +384,6 @@ function analyze(project_relative, file, component_extensions, module_extensions
|
|
|
386
384
|
const pattern = /^\+(?:(page(?:@(.*))?)|(layout(?:@(.*))?)|(error))$/;
|
|
387
385
|
const match = pattern.exec(name);
|
|
388
386
|
if (!match) {
|
|
389
|
-
// TODO remove for 1.0
|
|
390
|
-
if (/^\+layout-/.test(name)) {
|
|
391
|
-
throw new Error(
|
|
392
|
-
`${project_relative} should be reimplemented with layout groups: https://kit.svelte.dev/docs/advanced-routing#advanced-layouts`
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
387
|
throw new Error(`Files prefixed with + are reserved (saw ${project_relative})`);
|
|
397
388
|
}
|
|
398
389
|
|
package/src/core/sync/sync.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
1
|
import path from 'path';
|
|
3
2
|
import create_manifest_data from './create_manifest_data/index.js';
|
|
4
3
|
import { write_client_manifest } from './write_client_manifest.js';
|
|
@@ -14,24 +13,6 @@ import { write_ambient } from './write_ambient.js';
|
|
|
14
13
|
* @param {string} mode
|
|
15
14
|
*/
|
|
16
15
|
export function init(config, mode) {
|
|
17
|
-
// TODO remove for 1.0
|
|
18
|
-
if (fs.existsSync('src/app.d.ts')) {
|
|
19
|
-
const content = fs.readFileSync('src/app.d.ts', 'utf-8');
|
|
20
|
-
if (content.includes('PageError')) {
|
|
21
|
-
if (content.includes('// interface PageError')) {
|
|
22
|
-
fs.writeFileSync(
|
|
23
|
-
'src/app.d.ts',
|
|
24
|
-
content.replace(/\/\/ interface PageError/g, '// interface Error')
|
|
25
|
-
);
|
|
26
|
-
console.warn('App.PageError has been renamed to App.Error — we updated your src/app.d.ts');
|
|
27
|
-
} else {
|
|
28
|
-
throw new Error(
|
|
29
|
-
'App.PageError has been renamed to App.Error — please update your src/app.d.ts'
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
16
|
write_tsconfig(config.kit);
|
|
36
17
|
write_ambient(config.kit, mode);
|
|
37
18
|
}
|
|
@@ -68,16 +68,9 @@ export class Server {
|
|
|
68
68
|
dev: false,
|
|
69
69
|
embedded: ${config.kit.embedded},
|
|
70
70
|
handle_error: (error, event) => {
|
|
71
|
-
return this.options.hooks.handleError({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// TODO remove for 1.0
|
|
76
|
-
// @ts-expect-error
|
|
77
|
-
get request() {
|
|
78
|
-
throw new Error('request in handleError has been replaced with event. See https://github.com/sveltejs/kit/pull/3384 for details');
|
|
79
|
-
}
|
|
80
|
-
}) ?? { message: event.route.id != null ? 'Internal Error' : 'Not Found' };
|
|
71
|
+
return this.options.hooks.handleError({ error, event }) ?? {
|
|
72
|
+
message: event.route.id != null ? 'Internal Error' : 'Not Found'
|
|
73
|
+
};
|
|
81
74
|
},
|
|
82
75
|
hooks: null,
|
|
83
76
|
manifest,
|
|
@@ -117,11 +110,6 @@ export class Server {
|
|
|
117
110
|
if (!this.options.hooks) {
|
|
118
111
|
const module = await import(${s(hooks)});
|
|
119
112
|
|
|
120
|
-
// TODO remove this for 1.0
|
|
121
|
-
if (module.externalFetch) {
|
|
122
|
-
throw new Error('externalFetch has been removed — use handleFetch instead. See https://github.com/sveltejs/kit/pull/6565 for details');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
113
|
this.options.hooks = {
|
|
126
114
|
handle: module.handle || (({ event, resolve }) => resolve(event)),
|
|
127
115
|
handleError: module.handleError || (({ error }) => console.error(error.stack)),
|
|
@@ -167,22 +155,6 @@ export async function build_server(options, client) {
|
|
|
167
155
|
|
|
168
156
|
let hooks_file = resolve_entry(config.kit.files.hooks.server);
|
|
169
157
|
|
|
170
|
-
// TODO remove for 1.0
|
|
171
|
-
if (!hooks_file) {
|
|
172
|
-
const old_file = resolve_entry(path.join(process.cwd(), 'src', 'hooks'));
|
|
173
|
-
if (old_file && fs.existsSync(old_file)) {
|
|
174
|
-
throw new Error(
|
|
175
|
-
`Rename your server hook file from ${posixify(
|
|
176
|
-
path.relative(process.cwd(), old_file)
|
|
177
|
-
)} to ${posixify(
|
|
178
|
-
path.relative(process.cwd(), config.kit.files.hooks.server)
|
|
179
|
-
)}${path.extname(
|
|
180
|
-
old_file
|
|
181
|
-
)} (because there's also client hooks now). See the PR for more information: https://github.com/sveltejs/kit/pull/6586`
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
158
|
if (!hooks_file || !fs.existsSync(hooks_file)) {
|
|
187
159
|
hooks_file = path.join(config.kit.outDir, 'build/hooks.js');
|
|
188
160
|
fs.writeFileSync(hooks_file, '');
|
|
@@ -34,13 +34,6 @@ export async function build_service_worker(
|
|
|
34
34
|
fs.writeFileSync(
|
|
35
35
|
service_worker,
|
|
36
36
|
`
|
|
37
|
-
// TODO remove for 1.0
|
|
38
|
-
export const timestamp = {
|
|
39
|
-
toString: () => {
|
|
40
|
-
throw new Error('\`timestamp\` has been removed from $service-worker. Use \`version\` instead');
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
37
|
export const build = [
|
|
45
38
|
${Array.from(build)
|
|
46
39
|
.map((file) => `${s(`${config.kit.paths.base}/${file}`)}`)
|
|
@@ -377,32 +377,8 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
377
377
|
? await vite.ssrLoadModule(`/${hooks_file}`)
|
|
378
378
|
: {};
|
|
379
379
|
|
|
380
|
-
// TODO remove for 1.0
|
|
381
|
-
if (!resolve_entry(hooks_file)) {
|
|
382
|
-
const old_file = resolve_entry(path.join(process.cwd(), 'src', 'hooks'));
|
|
383
|
-
if (old_file && fs.existsSync(old_file)) {
|
|
384
|
-
throw new Error(
|
|
385
|
-
`Rename your server hook file from ${posixify(
|
|
386
|
-
path.relative(process.cwd(), old_file)
|
|
387
|
-
)} to ${posixify(
|
|
388
|
-
path.relative(process.cwd(), svelte_config.kit.files.hooks.server)
|
|
389
|
-
)}${path.extname(
|
|
390
|
-
old_file
|
|
391
|
-
)} (because there's also client hooks now). See the PR for more information: https://github.com/sveltejs/kit/pull/6586`
|
|
392
|
-
);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
380
|
const handle = user_hooks.handle || (({ event, resolve }) => resolve(event));
|
|
397
381
|
|
|
398
|
-
// TODO remove for 1.0
|
|
399
|
-
// @ts-expect-error
|
|
400
|
-
if (user_hooks.externalFetch) {
|
|
401
|
-
throw new Error(
|
|
402
|
-
'externalFetch has been removed — use handleFetch instead. See https://github.com/sveltejs/kit/pull/6565 for details'
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
382
|
/** @type {import('types').ServerHooks} */
|
|
407
383
|
const hooks = {
|
|
408
384
|
handle,
|
|
@@ -421,18 +397,6 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
421
397
|
handleFetch: user_hooks.handleFetch || (({ request, fetch }) => fetch(request))
|
|
422
398
|
};
|
|
423
399
|
|
|
424
|
-
if (/** @type {any} */ (hooks).getContext) {
|
|
425
|
-
// TODO remove this for 1.0
|
|
426
|
-
throw new Error(
|
|
427
|
-
'The getContext hook has been removed. See https://kit.svelte.dev/docs/hooks'
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (/** @type {any} */ (hooks).serverFetch) {
|
|
432
|
-
// TODO remove this for 1.0
|
|
433
|
-
throw new Error('The serverFetch hook has been renamed to externalFetch.');
|
|
434
|
-
}
|
|
435
|
-
|
|
436
400
|
// TODO the / prefix will probably fail if outDir is outside the cwd (which
|
|
437
401
|
// could be the case in a monorepo setup), but without it these modules
|
|
438
402
|
// can get loaded twice via different URLs, which causes failures. Might
|
|
@@ -497,15 +461,7 @@ export async function dev(vite, vite_config, svelte_config) {
|
|
|
497
461
|
return Reflect.get(target, property, target);
|
|
498
462
|
}
|
|
499
463
|
}),
|
|
500
|
-
event
|
|
501
|
-
|
|
502
|
-
// TODO remove for 1.0
|
|
503
|
-
// @ts-expect-error
|
|
504
|
-
get request() {
|
|
505
|
-
throw new Error(
|
|
506
|
-
'request in handleError has been replaced with event. See https://github.com/sveltejs/kit/pull/3384 for details'
|
|
507
|
-
);
|
|
508
|
-
}
|
|
464
|
+
event
|
|
509
465
|
});
|
|
510
466
|
return (
|
|
511
467
|
error_object ?? { message: event.route.id != null ? 'Internal Error' : 'Not Found' }
|
|
@@ -199,9 +199,6 @@ function kit({ svelte_config }) {
|
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
// TODO remove this for 1.0
|
|
203
|
-
check_vite_version();
|
|
204
|
-
|
|
205
202
|
/** @type {import('vite').Plugin} */
|
|
206
203
|
const plugin_setup = {
|
|
207
204
|
name: 'vite-plugin-sveltekit-setup',
|
|
@@ -631,19 +628,6 @@ function kit({ svelte_config }) {
|
|
|
631
628
|
return [plugin_setup, plugin_compile];
|
|
632
629
|
}
|
|
633
630
|
|
|
634
|
-
function check_vite_version() {
|
|
635
|
-
// TODO parse from kit peer deps and maybe do a full semver compare if we ever require feature releases a min
|
|
636
|
-
const min_required_vite_major = 4;
|
|
637
|
-
const vite_version = vite.version ?? '2.x'; // vite started exporting it's version in 3.0
|
|
638
|
-
const current_vite_major = parseInt(vite_version.split('.')[0], 10);
|
|
639
|
-
|
|
640
|
-
if (current_vite_major < min_required_vite_major) {
|
|
641
|
-
throw new Error(
|
|
642
|
-
`Vite version ${current_vite_major} is no longer supported. Please upgrade to version ${min_required_vite_major}`
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
|
|
647
631
|
/** @param {import('rollup').OutputBundle} bundle */
|
|
648
632
|
function collect_output(bundle) {
|
|
649
633
|
/** @type {import('rollup').OutputChunk[]} */
|
package/src/runtime/app/forms.js
CHANGED
|
@@ -119,17 +119,7 @@ export function enhance(form, submit = () => {}) {
|
|
|
119
119
|
form,
|
|
120
120
|
update: (opts) => fallback_callback({ action, result, reset: opts?.reset }),
|
|
121
121
|
// @ts-expect-error generic constraints stuff we don't care about
|
|
122
|
-
result
|
|
123
|
-
// TODO remove for 1.0
|
|
124
|
-
get type() {
|
|
125
|
-
throw new Error('(result) => {...} has changed to ({ result }) => {...}');
|
|
126
|
-
},
|
|
127
|
-
get location() {
|
|
128
|
-
throw new Error('(result) => {...} has changed to ({ result }) => {...}');
|
|
129
|
-
},
|
|
130
|
-
get error() {
|
|
131
|
-
throw new Error('(result) => {...} has changed to ({ result }) => {...}');
|
|
132
|
-
}
|
|
122
|
+
result
|
|
133
123
|
});
|
|
134
124
|
}
|
|
135
125
|
|
|
@@ -20,13 +20,3 @@ export const preloadData = BROWSER ? client.preload_data : guard('preloadData');
|
|
|
20
20
|
export const preloadCode = BROWSER ? client.preload_code : guard('preloadCode');
|
|
21
21
|
export const beforeNavigate = BROWSER ? client.before_navigate : () => {};
|
|
22
22
|
export const afterNavigate = BROWSER ? client.after_navigate : () => {};
|
|
23
|
-
|
|
24
|
-
// TODO remove for 1.0 release
|
|
25
|
-
/** @param {any} _args */
|
|
26
|
-
export const prefetch = (..._args) => {
|
|
27
|
-
throw new Error('prefetch has been renamed to preloadData');
|
|
28
|
-
};
|
|
29
|
-
/** @param {any} _args */
|
|
30
|
-
export const prefetchRoutes = (..._args) => {
|
|
31
|
-
throw new Error('prefetchRoutes has been renamed to preloadCode');
|
|
32
|
-
};
|
|
@@ -2,23 +2,13 @@ import { getContext } from 'svelte';
|
|
|
2
2
|
import { browser } from './environment.js';
|
|
3
3
|
import { stores as browser_stores } from '../client/singletons.js';
|
|
4
4
|
|
|
5
|
-
// TODO remove this (for 1.0? after 1.0?)
|
|
6
|
-
let warned = false;
|
|
7
|
-
export function stores() {
|
|
8
|
-
if (!warned) {
|
|
9
|
-
console.error('stores() is deprecated; use getStores() instead');
|
|
10
|
-
warned = true;
|
|
11
|
-
}
|
|
12
|
-
return getStores();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
5
|
/**
|
|
16
6
|
* @type {import('$app/stores').getStores}
|
|
17
7
|
*/
|
|
18
8
|
export const getStores = () => {
|
|
19
9
|
const stores = browser ? browser_stores : getContext('__svelte__');
|
|
20
10
|
|
|
21
|
-
|
|
11
|
+
return {
|
|
22
12
|
page: {
|
|
23
13
|
subscribe: stores.page.subscribe
|
|
24
14
|
},
|
|
@@ -27,28 +17,6 @@ export const getStores = () => {
|
|
|
27
17
|
},
|
|
28
18
|
updated: stores.updated
|
|
29
19
|
};
|
|
30
|
-
|
|
31
|
-
// TODO remove this for 1.0
|
|
32
|
-
Object.defineProperties(readonly_stores, {
|
|
33
|
-
preloading: {
|
|
34
|
-
get() {
|
|
35
|
-
console.error('stores.preloading is deprecated; use stores.navigating instead');
|
|
36
|
-
return {
|
|
37
|
-
subscribe: stores.navigating.subscribe
|
|
38
|
-
};
|
|
39
|
-
},
|
|
40
|
-
enumerable: false
|
|
41
|
-
},
|
|
42
|
-
session: {
|
|
43
|
-
get() {
|
|
44
|
-
removed_session();
|
|
45
|
-
return {};
|
|
46
|
-
},
|
|
47
|
-
enumerable: false
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return readonly_stores;
|
|
52
20
|
};
|
|
53
21
|
|
|
54
22
|
/** @type {typeof import('$app/stores').page} */
|
|
@@ -68,19 +36,6 @@ export const navigating = {
|
|
|
68
36
|
}
|
|
69
37
|
};
|
|
70
38
|
|
|
71
|
-
function removed_session() {
|
|
72
|
-
// TODO remove for 1.0
|
|
73
|
-
throw new Error(
|
|
74
|
-
'stores.session is no longer available. See https://github.com/sveltejs/kit/discussions/5883'
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const session = {
|
|
79
|
-
subscribe: removed_session,
|
|
80
|
-
set: removed_session,
|
|
81
|
-
update: removed_session
|
|
82
|
-
};
|
|
83
|
-
|
|
84
39
|
/** @type {typeof import('$app/stores').updated} */
|
|
85
40
|
export const updated = {
|
|
86
41
|
subscribe(fn) {
|
|
@@ -62,26 +62,6 @@ function update_scroll_positions(index) {
|
|
|
62
62
|
scroll_positions[index] = scroll_state();
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
// TODO remove for 1.0
|
|
66
|
-
/** @type {Record<string, true>} */
|
|
67
|
-
let warned_about_attributes = {};
|
|
68
|
-
|
|
69
|
-
function check_for_removed_attributes() {
|
|
70
|
-
const attrs = ['prefetch', 'noscroll', 'reload'];
|
|
71
|
-
for (const attr of attrs) {
|
|
72
|
-
if (document.querySelector(`[sveltekit\\:${attr}]`)) {
|
|
73
|
-
if (!warned_about_attributes[attr]) {
|
|
74
|
-
warned_about_attributes[attr] = true;
|
|
75
|
-
console.error(
|
|
76
|
-
`The sveltekit:${attr} attribute has been replaced with data-sveltekit-${
|
|
77
|
-
attr === 'prefetch' ? 'preload-data' : attr
|
|
78
|
-
}`
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
65
|
/**
|
|
86
66
|
* @param {{
|
|
87
67
|
* target: HTMLElement;
|
|
@@ -337,9 +317,7 @@ export function create_client({ target, base }) {
|
|
|
337
317
|
navigation_result.props.page.url = url;
|
|
338
318
|
}
|
|
339
319
|
|
|
340
|
-
const post_update = pre_update();
|
|
341
320
|
root.$set(navigation_result.props);
|
|
342
|
-
post_update();
|
|
343
321
|
} else {
|
|
344
322
|
initialize(navigation_result);
|
|
345
323
|
}
|
|
@@ -393,22 +371,20 @@ export function create_client({ target, base }) {
|
|
|
393
371
|
|
|
394
372
|
page = result.props.page;
|
|
395
373
|
|
|
396
|
-
const post_update = pre_update();
|
|
397
374
|
root = new Root({
|
|
398
375
|
target,
|
|
399
376
|
props: { ...result.props, stores },
|
|
400
377
|
hydrate: true
|
|
401
378
|
});
|
|
402
|
-
post_update();
|
|
403
379
|
|
|
404
380
|
/** @type {import('types').AfterNavigate} */
|
|
405
381
|
const navigation = {
|
|
406
382
|
from: null,
|
|
407
|
-
to:
|
|
383
|
+
to: {
|
|
408
384
|
params: current.params,
|
|
409
385
|
route: { id: current.route?.id ?? null },
|
|
410
386
|
url: new URL(location.href)
|
|
411
|
-
}
|
|
387
|
+
},
|
|
412
388
|
willUnload: false,
|
|
413
389
|
type: 'enter'
|
|
414
390
|
};
|
|
@@ -504,29 +480,6 @@ export function create_client({ target, base }) {
|
|
|
504
480
|
// The whole page store is updated, but this way the object reference stays the same
|
|
505
481
|
data: data_changed ? data : page.data
|
|
506
482
|
};
|
|
507
|
-
|
|
508
|
-
// TODO remove this for 1.0
|
|
509
|
-
Object.defineProperty(result.props.page, 'routeId', {
|
|
510
|
-
get() {
|
|
511
|
-
throw new Error('$page.routeId has been replaced by $page.route.id');
|
|
512
|
-
},
|
|
513
|
-
enumerable: false
|
|
514
|
-
});
|
|
515
|
-
/**
|
|
516
|
-
* @param {string} property
|
|
517
|
-
* @param {string} replacement
|
|
518
|
-
*/
|
|
519
|
-
const print_error = (property, replacement) => {
|
|
520
|
-
Object.defineProperty(result.props.page, property, {
|
|
521
|
-
get: () => {
|
|
522
|
-
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
print_error('origin', 'origin');
|
|
528
|
-
print_error('path', 'pathname');
|
|
529
|
-
print_error('query', 'searchParams');
|
|
530
483
|
}
|
|
531
484
|
|
|
532
485
|
return result;
|
|
@@ -642,40 +595,6 @@ export function create_client({ target, base }) {
|
|
|
642
595
|
}
|
|
643
596
|
};
|
|
644
597
|
|
|
645
|
-
// TODO remove this for 1.0
|
|
646
|
-
Object.defineProperties(load_input, {
|
|
647
|
-
props: {
|
|
648
|
-
get() {
|
|
649
|
-
throw new Error(
|
|
650
|
-
'@migration task: Replace `props` with `data` stuff https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292693'
|
|
651
|
-
);
|
|
652
|
-
},
|
|
653
|
-
enumerable: false
|
|
654
|
-
},
|
|
655
|
-
session: {
|
|
656
|
-
get() {
|
|
657
|
-
throw new Error(
|
|
658
|
-
'session is no longer available. See https://github.com/sveltejs/kit/discussions/5883'
|
|
659
|
-
);
|
|
660
|
-
},
|
|
661
|
-
enumerable: false
|
|
662
|
-
},
|
|
663
|
-
stuff: {
|
|
664
|
-
get() {
|
|
665
|
-
throw new Error(
|
|
666
|
-
'@migration task: Remove stuff https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292693'
|
|
667
|
-
);
|
|
668
|
-
},
|
|
669
|
-
enumerable: false
|
|
670
|
-
},
|
|
671
|
-
routeId: {
|
|
672
|
-
get() {
|
|
673
|
-
throw new Error('routeId has been replaced by route.id');
|
|
674
|
-
},
|
|
675
|
-
enumerable: false
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
|
|
679
598
|
if (DEV) {
|
|
680
599
|
try {
|
|
681
600
|
lock_fetch();
|
|
@@ -1072,16 +991,16 @@ export function create_client({ target, base }) {
|
|
|
1072
991
|
|
|
1073
992
|
/** @type {import('types').Navigation} */
|
|
1074
993
|
const navigation = {
|
|
1075
|
-
from:
|
|
994
|
+
from: {
|
|
1076
995
|
params: current.params,
|
|
1077
996
|
route: { id: current.route?.id ?? null },
|
|
1078
997
|
url: current.url
|
|
1079
|
-
}
|
|
1080
|
-
to:
|
|
998
|
+
},
|
|
999
|
+
to: {
|
|
1081
1000
|
params: intent?.params ?? null,
|
|
1082
1001
|
route: { id: intent?.route?.id ?? null },
|
|
1083
1002
|
url
|
|
1084
|
-
}
|
|
1003
|
+
},
|
|
1085
1004
|
willUnload: !intent,
|
|
1086
1005
|
type
|
|
1087
1006
|
};
|
|
@@ -1324,30 +1243,10 @@ export function create_client({ target, base }) {
|
|
|
1324
1243
|
},
|
|
1325
1244
|
|
|
1326
1245
|
goto: (href, opts = {}) => {
|
|
1327
|
-
// TODO remove for 1.0
|
|
1328
|
-
if ('keepfocus' in opts && !('keepFocus' in opts)) {
|
|
1329
|
-
throw new Error(
|
|
1330
|
-
'`keepfocus` has been renamed to `keepFocus` (note the difference in casing)'
|
|
1331
|
-
);
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
if ('noscroll' in opts && !('noScroll' in opts)) {
|
|
1335
|
-
throw new Error(
|
|
1336
|
-
'`noscroll` has been renamed to `noScroll` (note the difference in casing)'
|
|
1337
|
-
);
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
1246
|
return goto(href, opts, []);
|
|
1341
1247
|
},
|
|
1342
1248
|
|
|
1343
1249
|
invalidate: (resource) => {
|
|
1344
|
-
if (resource === undefined) {
|
|
1345
|
-
// TODO remove for 1.0
|
|
1346
|
-
throw new Error(
|
|
1347
|
-
'`invalidate()` (with no arguments) has been replaced by `invalidateAll()`'
|
|
1348
|
-
);
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
1250
|
if (typeof resource === 'function') {
|
|
1352
1251
|
invalidated.push(resource);
|
|
1353
1252
|
} else {
|
|
@@ -1394,9 +1293,7 @@ export function create_client({ target, base }) {
|
|
|
1394
1293
|
|
|
1395
1294
|
current = navigation_result.state;
|
|
1396
1295
|
|
|
1397
|
-
const post_update = pre_update();
|
|
1398
1296
|
root.$set(navigation_result.props);
|
|
1399
|
-
post_update();
|
|
1400
1297
|
|
|
1401
1298
|
tick().then(reset_focus);
|
|
1402
1299
|
}
|
|
@@ -1408,9 +1305,7 @@ export function create_client({ target, base }) {
|
|
|
1408
1305
|
form: result.data,
|
|
1409
1306
|
page: { ...page, form: result.data, status: result.status }
|
|
1410
1307
|
};
|
|
1411
|
-
const post_update = pre_update();
|
|
1412
1308
|
root.$set(props);
|
|
1413
|
-
post_update();
|
|
1414
1309
|
|
|
1415
1310
|
if (result.type === 'success') {
|
|
1416
1311
|
tick().then(reset_focus);
|
|
@@ -1433,11 +1328,11 @@ export function create_client({ target, base }) {
|
|
|
1433
1328
|
// it's due to an external or full-page-reload link, for which we don't want to call the hook again.
|
|
1434
1329
|
/** @type {import('types').BeforeNavigate} */
|
|
1435
1330
|
const navigation = {
|
|
1436
|
-
from:
|
|
1331
|
+
from: {
|
|
1437
1332
|
params: current.params,
|
|
1438
1333
|
route: { id: current.route?.id ?? null },
|
|
1439
1334
|
url: current.url
|
|
1440
|
-
}
|
|
1335
|
+
},
|
|
1441
1336
|
to: null,
|
|
1442
1337
|
willUnload: true,
|
|
1443
1338
|
type: 'leave',
|
|
@@ -1783,60 +1678,6 @@ function handle_error(error, event) {
|
|
|
1783
1678
|
);
|
|
1784
1679
|
}
|
|
1785
1680
|
|
|
1786
|
-
// TODO remove for 1.0
|
|
1787
|
-
const properties = [
|
|
1788
|
-
'hash',
|
|
1789
|
-
'href',
|
|
1790
|
-
'host',
|
|
1791
|
-
'hostname',
|
|
1792
|
-
'origin',
|
|
1793
|
-
'pathname',
|
|
1794
|
-
'port',
|
|
1795
|
-
'protocol',
|
|
1796
|
-
'search',
|
|
1797
|
-
'searchParams',
|
|
1798
|
-
'toString',
|
|
1799
|
-
'toJSON'
|
|
1800
|
-
];
|
|
1801
|
-
|
|
1802
|
-
/**
|
|
1803
|
-
* @param {'from' | 'to'} type
|
|
1804
|
-
* @param {import('types').NavigationTarget} target
|
|
1805
|
-
*/
|
|
1806
|
-
function add_url_properties(type, target) {
|
|
1807
|
-
for (const prop of properties) {
|
|
1808
|
-
Object.defineProperty(target, prop, {
|
|
1809
|
-
get() {
|
|
1810
|
-
throw new Error(
|
|
1811
|
-
`The navigation shape changed - ${type}.${prop} should now be ${type}.url.${prop}`
|
|
1812
|
-
);
|
|
1813
|
-
},
|
|
1814
|
-
enumerable: false
|
|
1815
|
-
});
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
Object.defineProperty(target, 'routeId', {
|
|
1819
|
-
get() {
|
|
1820
|
-
throw new Error(
|
|
1821
|
-
`The navigation shape changed - ${type}.routeId should now be ${type}.route.id`
|
|
1822
|
-
);
|
|
1823
|
-
},
|
|
1824
|
-
enumerable: false
|
|
1825
|
-
});
|
|
1826
|
-
|
|
1827
|
-
return target;
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
function pre_update() {
|
|
1831
|
-
if (DEV) {
|
|
1832
|
-
return () => {
|
|
1833
|
-
check_for_removed_attributes();
|
|
1834
|
-
};
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
|
-
return () => {};
|
|
1838
|
-
}
|
|
1839
|
-
|
|
1840
1681
|
function reset_focus() {
|
|
1841
1682
|
const autofocus = document.querySelector('[autofocus]');
|
|
1842
1683
|
if (autofocus) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { negotiate } from '../../utils/http.js';
|
|
2
2
|
import { Redirect } from '../control.js';
|
|
3
|
-
import {
|
|
3
|
+
import { method_not_allowed } from './utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param {import('types').RequestEvent} event
|
|
@@ -11,9 +11,6 @@ import { check_method_names, method_not_allowed } from './utils.js';
|
|
|
11
11
|
export async function render_endpoint(event, mod, state) {
|
|
12
12
|
const method = /** @type {import('types').HttpMethod} */ (event.request.method);
|
|
13
13
|
|
|
14
|
-
// TODO: Remove for 1.0
|
|
15
|
-
check_method_names(mod);
|
|
16
|
-
|
|
17
14
|
let handler = mod[method];
|
|
18
15
|
|
|
19
16
|
if (!handler && method === 'HEAD') {
|
|
@@ -151,41 +151,6 @@ export async function respond(request, options, state) {
|
|
|
151
151
|
isDataRequest: is_data_request
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
// TODO remove this for 1.0
|
|
155
|
-
/**
|
|
156
|
-
* @param {string} property
|
|
157
|
-
* @param {string} replacement
|
|
158
|
-
* @param {string} suffix
|
|
159
|
-
*/
|
|
160
|
-
const removed = (property, replacement, suffix = '') => ({
|
|
161
|
-
get: () => {
|
|
162
|
-
throw new Error(`event.${property} has been replaced by event.${replacement}` + suffix);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
const details = '. See https://github.com/sveltejs/kit/pull/3384 for details';
|
|
167
|
-
|
|
168
|
-
const body_getter = {
|
|
169
|
-
get: () => {
|
|
170
|
-
throw new Error(
|
|
171
|
-
'To access the request body use the text/json/arrayBuffer/formData methods, e.g. `body = await request.json()`' +
|
|
172
|
-
details
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
Object.defineProperties(event, {
|
|
178
|
-
clientAddress: removed('clientAddress', 'getClientAddress'),
|
|
179
|
-
method: removed('method', 'request.method', details),
|
|
180
|
-
headers: removed('headers', 'request.headers', details),
|
|
181
|
-
origin: removed('origin', 'url.origin'),
|
|
182
|
-
path: removed('path', 'url.pathname'),
|
|
183
|
-
query: removed('query', 'url.searchParams'),
|
|
184
|
-
body: body_getter,
|
|
185
|
-
rawBody: body_getter,
|
|
186
|
-
routeId: removed('routeId', 'route.id')
|
|
187
|
-
});
|
|
188
|
-
|
|
189
154
|
/** @type {import('types').RequiredResolveOptions} */
|
|
190
155
|
let resolve_opts = {
|
|
191
156
|
transformPageChunk: default_transform,
|
|
@@ -279,12 +244,7 @@ export async function respond(request, options, state) {
|
|
|
279
244
|
}
|
|
280
245
|
|
|
281
246
|
return response;
|
|
282
|
-
})
|
|
283
|
-
// TODO remove for 1.0
|
|
284
|
-
// @ts-expect-error
|
|
285
|
-
get request() {
|
|
286
|
-
throw new Error('request in handle has been replaced with event' + details);
|
|
287
|
-
}
|
|
247
|
+
})
|
|
288
248
|
});
|
|
289
249
|
|
|
290
250
|
// respond with 304 if etag matches
|
|
@@ -350,13 +310,6 @@ export async function respond(request, options, state) {
|
|
|
350
310
|
async function resolve(event, opts) {
|
|
351
311
|
try {
|
|
352
312
|
if (opts) {
|
|
353
|
-
// TODO remove for 1.0
|
|
354
|
-
if ('transformPage' in opts) {
|
|
355
|
-
throw new Error(
|
|
356
|
-
'transformPage has been replaced by transformPageChunk — see https://github.com/sveltejs/kit/pull/5657 for more information'
|
|
357
|
-
);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
313
|
if ('ssr' in opts) {
|
|
361
314
|
throw new Error(
|
|
362
315
|
'ssr has been removed, set it in the appropriate +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197'
|
|
@@ -102,8 +102,7 @@ export async function load_data({
|
|
|
102
102
|
return server_data_node?.data ?? null;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
const load_event = {
|
|
105
|
+
const result = await node.universal.load.call(null, {
|
|
107
106
|
url: event.url,
|
|
108
107
|
params: event.params,
|
|
109
108
|
data: server_data_node?.data ?? null,
|
|
@@ -226,21 +225,8 @@ export async function load_data({
|
|
|
226
225
|
setHeaders: event.setHeaders,
|
|
227
226
|
depends: () => {},
|
|
228
227
|
parent
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// TODO remove this for 1.0
|
|
232
|
-
Object.defineProperties(load_event, {
|
|
233
|
-
session: {
|
|
234
|
-
get() {
|
|
235
|
-
throw new Error(
|
|
236
|
-
'session is no longer available. See https://github.com/sveltejs/kit/discussions/5883'
|
|
237
|
-
);
|
|
238
|
-
},
|
|
239
|
-
enumerable: false
|
|
240
|
-
}
|
|
241
228
|
});
|
|
242
229
|
|
|
243
|
-
const result = await node.universal.load.call(null, load_event);
|
|
244
230
|
const data = result ? await unwrap_promises(result) : null;
|
|
245
231
|
validate_load_response(data, /** @type {string} */ (event.route.id));
|
|
246
232
|
return data;
|
|
@@ -102,23 +102,6 @@ export async function render_response({
|
|
|
102
102
|
form: form_value
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
// TODO remove this for 1.0
|
|
106
|
-
/**
|
|
107
|
-
* @param {string} property
|
|
108
|
-
* @param {string} replacement
|
|
109
|
-
*/
|
|
110
|
-
const print_error = (property, replacement) => {
|
|
111
|
-
Object.defineProperty(props.page, property, {
|
|
112
|
-
get: () => {
|
|
113
|
-
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
print_error('origin', 'origin');
|
|
119
|
-
print_error('path', 'pathname');
|
|
120
|
-
print_error('query', 'searchParams');
|
|
121
|
-
|
|
122
105
|
rendered = options.root.render(props);
|
|
123
106
|
|
|
124
107
|
for (const { node } of branch) {
|
|
@@ -11,30 +11,11 @@ export function is_pojo(body) {
|
|
|
11
11
|
if (body) {
|
|
12
12
|
if (body instanceof Uint8Array) return false;
|
|
13
13
|
if (body instanceof ReadableStream) return false;
|
|
14
|
-
|
|
15
|
-
// if body is a node Readable, throw an error
|
|
16
|
-
// TODO remove this for 1.0
|
|
17
|
-
if (body._readableState && typeof body.pipe === 'function') {
|
|
18
|
-
throw new Error('Node streams are no longer supported — use a ReadableStream instead');
|
|
19
|
-
}
|
|
20
14
|
}
|
|
21
15
|
|
|
22
16
|
return true;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
|
-
// TODO: Remove for 1.0
|
|
26
|
-
/** @param {Record<string, any>} mod */
|
|
27
|
-
export function check_method_names(mod) {
|
|
28
|
-
['get', 'post', 'put', 'patch', 'del'].forEach((m) => {
|
|
29
|
-
if (m in mod) {
|
|
30
|
-
const replacement = m === 'del' ? 'DELETE' : m.toUpperCase();
|
|
31
|
-
throw Error(
|
|
32
|
-
`Endpoint method "${m}" has changed to "${replacement}". See https://github.com/sveltejs/kit/discussions/5359 for more information.`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
19
|
/** @type {import('types').SSRErrorPage} */
|
|
39
20
|
export const GENERIC_ERROR = {
|
|
40
21
|
id: '__error'
|
|
@@ -79,15 +60,6 @@ export function allowed_methods(mod) {
|
|
|
79
60
|
*/
|
|
80
61
|
export function get_option(nodes, option) {
|
|
81
62
|
return nodes.reduce((value, node) => {
|
|
82
|
-
// TODO remove for 1.0
|
|
83
|
-
for (const thing of [node?.server, node?.universal]) {
|
|
84
|
-
if (thing && ('router' in thing || 'hydrate' in thing)) {
|
|
85
|
-
throw new Error(
|
|
86
|
-
'`export const hydrate` and `export const router` have been replaced with `export const csr`. See https://github.com/sveltejs/kit/pull/6446'
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
63
|
return /** @type {any} TypeScript's too dumb to understand this */ (
|
|
92
64
|
node?.universal?.[option] ?? node?.server?.[option] ?? value
|
|
93
65
|
);
|
package/src/utils/filesystem.js
CHANGED
|
@@ -83,6 +83,7 @@ export function copy(source, target, opts = {}) {
|
|
|
83
83
|
* Get a list of all files in a directory
|
|
84
84
|
* @param {string} cwd - the directory to walk
|
|
85
85
|
* @param {boolean} [dirs] - whether to include directories in the result
|
|
86
|
+
* @returns {string[]} a list of all found files (and possibly directories) relative to `cwd`
|
|
86
87
|
*/
|
|
87
88
|
export function walk(cwd, dirs = false) {
|
|
88
89
|
/** @type {string[]} */
|