@sveltejs/kit 1.0.0-next.42 → 1.0.0-next.422
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/README.md +12 -9
- package/package.json +95 -63
- package/src/cli.js +112 -0
- package/src/core/adapt/builder.js +207 -0
- package/src/core/adapt/index.js +19 -0
- package/src/core/config/index.js +86 -0
- package/src/core/config/options.js +482 -0
- package/src/core/config/types.d.ts +1 -0
- package/src/core/constants.js +5 -0
- package/src/core/env.js +91 -0
- package/src/core/generate_manifest/index.js +99 -0
- package/src/core/prerender/crawl.js +194 -0
- package/src/core/prerender/prerender.js +378 -0
- package/src/core/prerender/queue.js +80 -0
- package/src/core/sync/create_manifest_data/index.js +506 -0
- package/src/core/sync/create_manifest_data/types.d.ts +40 -0
- package/src/core/sync/sync.js +59 -0
- package/src/core/sync/utils.js +44 -0
- package/src/core/sync/write_ambient.js +27 -0
- package/src/core/sync/write_client_manifest.js +82 -0
- package/src/core/sync/write_matchers.js +25 -0
- package/src/core/sync/write_root.js +88 -0
- package/src/core/sync/write_tsconfig.js +189 -0
- package/src/core/sync/write_types.js +769 -0
- package/src/core/utils.js +58 -0
- package/src/hooks.js +26 -0
- package/src/index/index.js +45 -0
- package/src/index/private.js +33 -0
- package/src/node/index.js +145 -0
- package/src/node/polyfills.js +40 -0
- package/src/runtime/app/env.js +11 -0
- package/src/runtime/app/navigation.js +22 -0
- package/src/runtime/app/paths.js +1 -0
- package/src/runtime/app/stores.js +91 -0
- package/src/runtime/client/ambient.d.ts +17 -0
- package/src/runtime/client/client.js +1258 -0
- package/src/runtime/client/fetcher.js +60 -0
- package/src/runtime/client/parse.js +36 -0
- package/src/runtime/client/singletons.js +11 -0
- package/src/runtime/client/start.js +46 -0
- package/src/runtime/client/types.d.ts +105 -0
- package/src/runtime/client/utils.js +113 -0
- package/src/runtime/components/error.svelte +16 -0
- package/{assets → src/runtime}/components/layout.svelte +0 -0
- package/src/runtime/env/dynamic/private.js +1 -0
- package/src/runtime/env/dynamic/public.js +1 -0
- package/src/runtime/env-private.js +7 -0
- package/src/runtime/env-public.js +7 -0
- package/src/runtime/env.js +6 -0
- package/src/runtime/hash.js +16 -0
- package/src/runtime/paths.js +11 -0
- package/src/runtime/server/endpoint.js +58 -0
- package/src/runtime/server/index.js +448 -0
- package/src/runtime/server/page/cookie.js +25 -0
- package/src/runtime/server/page/crypto.js +239 -0
- package/src/runtime/server/page/csp.js +249 -0
- package/src/runtime/server/page/fetch.js +266 -0
- package/src/runtime/server/page/index.js +416 -0
- package/src/runtime/server/page/load_data.js +127 -0
- package/src/runtime/server/page/render.js +359 -0
- package/src/runtime/server/page/respond_with_error.js +94 -0
- package/src/runtime/server/page/types.d.ts +44 -0
- package/src/runtime/server/utils.js +116 -0
- package/src/utils/error.js +22 -0
- package/src/utils/escape.js +104 -0
- package/src/utils/filesystem.js +108 -0
- package/src/utils/http.js +55 -0
- package/src/utils/misc.js +1 -0
- package/src/utils/routing.js +107 -0
- package/src/utils/url.js +97 -0
- package/src/vite/build/build_server.js +337 -0
- package/src/vite/build/build_service_worker.js +90 -0
- package/src/vite/build/utils.js +157 -0
- package/src/vite/dev/index.js +568 -0
- package/src/vite/index.js +566 -0
- package/src/vite/preview/index.js +186 -0
- package/src/vite/types.d.ts +3 -0
- package/src/vite/utils.js +334 -0
- package/svelte-kit.js +1 -1
- package/types/ambient.d.ts +355 -0
- package/types/index.d.ts +342 -0
- package/types/internal.d.ts +308 -0
- package/types/private.d.ts +209 -0
- package/CHANGELOG.md +0 -425
- package/assets/components/error.svelte +0 -13
- package/assets/runtime/app/env.js +0 -5
- package/assets/runtime/app/navigation.js +0 -41
- package/assets/runtime/app/paths.js +0 -1
- package/assets/runtime/app/stores.js +0 -93
- package/assets/runtime/chunks/utils.js +0 -19
- package/assets/runtime/internal/singletons.js +0 -23
- package/assets/runtime/internal/start.js +0 -770
- package/assets/runtime/paths.js +0 -12
- package/dist/api.js +0 -28
- package/dist/api.js.map +0 -1
- package/dist/chunks/index.js +0 -3521
- package/dist/chunks/index2.js +0 -587
- package/dist/chunks/index3.js +0 -246
- package/dist/chunks/index4.js +0 -530
- package/dist/chunks/index5.js +0 -761
- package/dist/chunks/index6.js +0 -322
- package/dist/chunks/standard.js +0 -99
- package/dist/chunks/utils.js +0 -83
- package/dist/cli.js +0 -546
- package/dist/cli.js.map +0 -1
- package/dist/create_app.js +0 -592
- package/dist/create_app.js.map +0 -1
- package/dist/index.js +0 -392
- package/dist/index.js.map +0 -1
- package/dist/index2.js +0 -3519
- package/dist/index2.js.map +0 -1
- package/dist/index3.js +0 -320
- package/dist/index3.js.map +0 -1
- package/dist/index4.js +0 -323
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -247
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -761
- package/dist/index6.js.map +0 -1
- package/dist/renderer.js +0 -2499
- package/dist/renderer.js.map +0 -1
- package/dist/ssr.js +0 -2581
- package/dist/standard.js +0 -100
- package/dist/standard.js.map +0 -1
- package/dist/utils.js +0 -84
- package/dist/utils.js.map +0 -1
package/dist/index3.js
DELETED
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { r as rimraf, c as copy_assets } from './utils.js';
|
|
4
|
-
import { c as create_manifest_data, a as create_app } from './create_app.js';
|
|
5
|
-
import vite from 'vite';
|
|
6
|
-
import svelte from '@svitejs/vite-plugin-svelte';
|
|
7
|
-
import './index.js';
|
|
8
|
-
import 'url';
|
|
9
|
-
import './standard.js';
|
|
10
|
-
|
|
11
|
-
/** @param {any} value */
|
|
12
|
-
const s = (value) => JSON.stringify(value);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {import('../../types').ValidatedConfig} config
|
|
16
|
-
* @param {{
|
|
17
|
-
* cwd?: string;
|
|
18
|
-
* renderer?: string;
|
|
19
|
-
* }} [opts]
|
|
20
|
-
*/
|
|
21
|
-
async function build(
|
|
22
|
-
config,
|
|
23
|
-
{ cwd = process.cwd(), renderer = '@sveltejs/kit/renderer' } = {}
|
|
24
|
-
) {
|
|
25
|
-
const build_dir = path.resolve(cwd, '.svelte/build');
|
|
26
|
-
const output_dir = path.resolve(cwd, '.svelte/output');
|
|
27
|
-
|
|
28
|
-
const manifest = create_manifest_data({
|
|
29
|
-
config,
|
|
30
|
-
output: build_dir,
|
|
31
|
-
cwd
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
rimraf(build_dir);
|
|
35
|
-
|
|
36
|
-
create_app({
|
|
37
|
-
manifest_data: manifest,
|
|
38
|
-
output: build_dir,
|
|
39
|
-
cwd
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
copy_assets(build_dir);
|
|
43
|
-
|
|
44
|
-
process.env.VITE_AMP = config.kit.amp ? 'true' : '';
|
|
45
|
-
|
|
46
|
-
const client_entry_file = '.svelte/build/runtime/internal/start.js';
|
|
47
|
-
const client_out_dir = `${output_dir}/client/${config.kit.appDir}`;
|
|
48
|
-
const client_manifest_file = `${client_out_dir}/manifest.json`;
|
|
49
|
-
|
|
50
|
-
const base =
|
|
51
|
-
config.kit.paths.assets === '/.'
|
|
52
|
-
? `/${config.kit.appDir}/`
|
|
53
|
-
: `${config.kit.paths.assets}/${config.kit.appDir}/`;
|
|
54
|
-
|
|
55
|
-
// client build
|
|
56
|
-
await vite.build({
|
|
57
|
-
root: cwd,
|
|
58
|
-
base,
|
|
59
|
-
build: {
|
|
60
|
-
cssCodeSplit: true,
|
|
61
|
-
manifest: true,
|
|
62
|
-
lib: {
|
|
63
|
-
entry: client_entry_file,
|
|
64
|
-
name: 'app',
|
|
65
|
-
formats: ['es']
|
|
66
|
-
},
|
|
67
|
-
outDir: client_out_dir
|
|
68
|
-
},
|
|
69
|
-
resolve: {
|
|
70
|
-
alias: {
|
|
71
|
-
$app: path.resolve(`${build_dir}/runtime/app`)
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
plugins: [
|
|
75
|
-
svelte({
|
|
76
|
-
emitCss: true,
|
|
77
|
-
compilerOptions: {
|
|
78
|
-
dev: true,
|
|
79
|
-
hydratable: true
|
|
80
|
-
},
|
|
81
|
-
hot: true,
|
|
82
|
-
extensions: config.extensions
|
|
83
|
-
})
|
|
84
|
-
]
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
/** @type {Record<string, {
|
|
88
|
-
* file: string;
|
|
89
|
-
* css: string[];
|
|
90
|
-
* imports: string[];
|
|
91
|
-
* }>} */
|
|
92
|
-
const client_manifest = JSON.parse(fs.readFileSync(client_manifest_file, 'utf-8'));
|
|
93
|
-
fs.unlinkSync(client_manifest_file);
|
|
94
|
-
|
|
95
|
-
let setup_file = 'src/setup/index.js'; // TODO this is wrong... should see if we can resolve files.setup using Vite's resolution logic
|
|
96
|
-
if (!fs.existsSync(path.resolve(cwd, setup_file))) {
|
|
97
|
-
setup_file = '.svelte/build/setup.js';
|
|
98
|
-
fs.writeFileSync(path.resolve(cwd, setup_file), '');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const app_file = `${build_dir}/app.js`;
|
|
102
|
-
|
|
103
|
-
/** @type {(file: string) => string} */
|
|
104
|
-
const app_relative = (file) => {
|
|
105
|
-
const relative_file = path.relative('.svelte/build', file);
|
|
106
|
-
return relative_file[0] === '.' ? relative_file : `./${relative_file}`;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const component_indexes = new Map();
|
|
110
|
-
manifest.components.forEach((c, i) => {
|
|
111
|
-
component_indexes.set(c, i);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
/** @param {string} c */
|
|
115
|
-
const stringify_component = (c) => `() => import(${s(`${app_relative(c)}`)})`;
|
|
116
|
-
|
|
117
|
-
// TODO ideally we wouldn't embed the css_lookup, but this is the easiest
|
|
118
|
-
// way to be able to inline CSS into AMP documents. if we come up with
|
|
119
|
-
// something better, we could use it for non-AMP documents too, as
|
|
120
|
-
// critical CSS below a certain threshold _should_ be inlined
|
|
121
|
-
const css_lookup = {};
|
|
122
|
-
// manifest.pages.forEach((data) => {
|
|
123
|
-
// data.parts.forEach((c) => {
|
|
124
|
-
// const deps = client.deps[c];
|
|
125
|
-
// deps.css.forEach((dep) => {
|
|
126
|
-
// const url = `${config.kit.paths.assets}/${config.kit.appDir}/${dep}`.replace(/^\/\./, '');
|
|
127
|
-
// const file = `${OPTIMIZED}/client/${config.kit.appDir}/${dep}`;
|
|
128
|
-
|
|
129
|
-
// css_lookup[url] = fs.readFileSync(file, 'utf-8');
|
|
130
|
-
// });
|
|
131
|
-
// });
|
|
132
|
-
// });
|
|
133
|
-
|
|
134
|
-
// TODO get_stack, below, just returns the stack as-is, without sourcemapping
|
|
135
|
-
|
|
136
|
-
const entry = `${config.kit.paths.assets}/${config.kit.appDir}/${client_manifest[client_entry_file].file}`;
|
|
137
|
-
|
|
138
|
-
// prettier-ignore
|
|
139
|
-
fs.writeFileSync(
|
|
140
|
-
app_file,
|
|
141
|
-
`
|
|
142
|
-
import * as renderer from '${renderer}';
|
|
143
|
-
import root from './generated/root.svelte';
|
|
144
|
-
import { set_paths } from './runtime/internal/singletons.js';
|
|
145
|
-
import * as setup from ${s(app_relative(setup_file))};
|
|
146
|
-
|
|
147
|
-
const template = ({ head, body }) => ${s(fs.readFileSync(config.kit.files.template, 'utf-8'))
|
|
148
|
-
.replace('%svelte.head%', '" + head + "')
|
|
149
|
-
.replace('%svelte.body%', '" + body + "')};
|
|
150
|
-
|
|
151
|
-
set_paths(${s(config.kit.paths)});
|
|
152
|
-
|
|
153
|
-
// allow paths to be overridden in svelte-kit start
|
|
154
|
-
export function init({ paths }) {
|
|
155
|
-
set_paths(paths);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
init({ paths: ${s(config.kit.paths)} });
|
|
159
|
-
|
|
160
|
-
const d = decodeURIComponent;
|
|
161
|
-
const empty = () => ({});
|
|
162
|
-
|
|
163
|
-
const components = [
|
|
164
|
-
${manifest.components.map((c) => stringify_component(c)).join(',\n\t\t\t\t')}
|
|
165
|
-
];
|
|
166
|
-
|
|
167
|
-
${config.kit.amp ? `
|
|
168
|
-
const css_lookup = ${s(css_lookup)};` : ''}
|
|
169
|
-
|
|
170
|
-
const manifest = {
|
|
171
|
-
assets: ${s(manifest.assets)},
|
|
172
|
-
layout: ${stringify_component(manifest.layout)},
|
|
173
|
-
error: ${stringify_component(manifest.error)},
|
|
174
|
-
pages: [
|
|
175
|
-
${manifest.pages
|
|
176
|
-
.map((data) => {
|
|
177
|
-
const params = get_params(data.params);
|
|
178
|
-
const parts = data.parts.map(c => `components[${component_indexes.get(c)}]`);
|
|
179
|
-
|
|
180
|
-
const prefix = config.kit.paths.assets === '/.' ? '' : config.kit.paths.assets;
|
|
181
|
-
|
|
182
|
-
/** @param {string} dep */
|
|
183
|
-
const path_to_dep = dep => prefix + `/${config.kit.appDir}/${dep}`;
|
|
184
|
-
|
|
185
|
-
const js_deps = new Set();
|
|
186
|
-
const css_deps = new Set();
|
|
187
|
-
|
|
188
|
-
/** @param {string} id */
|
|
189
|
-
function find_deps(id) {
|
|
190
|
-
const chunk = client_manifest[id];
|
|
191
|
-
js_deps.add(path_to_dep(chunk.file));
|
|
192
|
-
|
|
193
|
-
if (chunk.css) {
|
|
194
|
-
chunk.css.forEach(file => css_deps.add(path_to_dep(file)));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (chunk.imports) {
|
|
198
|
-
chunk.imports.forEach(find_deps);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
for (const part of data.parts) {
|
|
203
|
-
find_deps(part);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// data.parts.forEach(c => {
|
|
207
|
-
// const deps = client.deps[c];
|
|
208
|
-
// deps.js.forEach(dep => js_deps.add(path_to_dep(dep)));
|
|
209
|
-
// deps.css.forEach(dep => css_deps.add(path_to_dep(dep)));
|
|
210
|
-
// });
|
|
211
|
-
|
|
212
|
-
return `{
|
|
213
|
-
pattern: ${data.pattern},
|
|
214
|
-
params: ${params},
|
|
215
|
-
parts: [${parts.join(', ')}],
|
|
216
|
-
css: [${Array.from(css_deps).map(s).join(', ')}],
|
|
217
|
-
js: [${Array.from(js_deps).map(s).join(', ')}]
|
|
218
|
-
}`;
|
|
219
|
-
})
|
|
220
|
-
.join(',\n\t\t\t\t\t')}
|
|
221
|
-
],
|
|
222
|
-
endpoints: [
|
|
223
|
-
${manifest.endpoints
|
|
224
|
-
.map((data) => {
|
|
225
|
-
const params = get_params(data.params);
|
|
226
|
-
const load = `() => import(${s(app_relative(data.file))})`;
|
|
227
|
-
|
|
228
|
-
return `{ pattern: ${data.pattern}, params: ${params}, load: ${load} }`;
|
|
229
|
-
})
|
|
230
|
-
.join(',\n\t\t\t\t\t')}
|
|
231
|
-
]
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
export function render(request, {
|
|
235
|
-
paths = ${s(config.kit.paths)},
|
|
236
|
-
local = false,
|
|
237
|
-
only_prerender = false,
|
|
238
|
-
get_static_file
|
|
239
|
-
} = {}) {
|
|
240
|
-
return renderer.render(request, {
|
|
241
|
-
paths,
|
|
242
|
-
local,
|
|
243
|
-
template,
|
|
244
|
-
manifest,
|
|
245
|
-
target: ${s(config.kit.target)},${
|
|
246
|
-
config.kit.startGlobal ? `\n\t\t\t\t\tstart_global: ${s(config.kit.startGlobal)},` : ''
|
|
247
|
-
}
|
|
248
|
-
entry: ${s(entry)},
|
|
249
|
-
root,
|
|
250
|
-
setup,
|
|
251
|
-
dev: false,
|
|
252
|
-
amp: ${config.kit.amp},
|
|
253
|
-
only_prerender,
|
|
254
|
-
app_dir: ${s(config.kit.appDir)},
|
|
255
|
-
host: ${s(config.kit.host)},
|
|
256
|
-
host_header: ${s(config.kit.hostHeader)},
|
|
257
|
-
get_stack: error => error.stack,
|
|
258
|
-
get_static_file,
|
|
259
|
-
get_amp_css: dep => css_lookup[dep]
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
`
|
|
263
|
-
.replace(/^\t{3}/gm, '')
|
|
264
|
-
.trim()
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
await vite.build({
|
|
268
|
-
root: cwd,
|
|
269
|
-
base,
|
|
270
|
-
build: {
|
|
271
|
-
ssr: true,
|
|
272
|
-
lib: {
|
|
273
|
-
entry: app_file,
|
|
274
|
-
name: 'app',
|
|
275
|
-
formats: ['es']
|
|
276
|
-
},
|
|
277
|
-
outDir: `${output_dir}/server`
|
|
278
|
-
},
|
|
279
|
-
resolve: {
|
|
280
|
-
alias: {
|
|
281
|
-
$app: path.resolve(`${build_dir}/runtime/app`)
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
plugins: [
|
|
285
|
-
svelte({
|
|
286
|
-
emitCss: true,
|
|
287
|
-
compilerOptions: {
|
|
288
|
-
dev: true,
|
|
289
|
-
hydratable: true
|
|
290
|
-
},
|
|
291
|
-
hot: true,
|
|
292
|
-
extensions: config.extensions
|
|
293
|
-
})
|
|
294
|
-
],
|
|
295
|
-
ssr: {
|
|
296
|
-
noExternal: ['svelte']
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/** @param {string[]} array */
|
|
302
|
-
function get_params(array) {
|
|
303
|
-
// given an array of params like `['x', 'y', 'z']` for
|
|
304
|
-
// src/routes/[x]/[y]/[z]/svelte, create a function
|
|
305
|
-
// that turns a RexExpMatchArray into ({ x, y, z })
|
|
306
|
-
return array.length
|
|
307
|
-
? '(m) => ({ ' +
|
|
308
|
-
array
|
|
309
|
-
.map((param, i) => {
|
|
310
|
-
return param.startsWith('...')
|
|
311
|
-
? `${param.slice(3)}: d(m[${i + 1}]).split('/')`
|
|
312
|
-
: `${param}: d(m[${i + 1}])`;
|
|
313
|
-
})
|
|
314
|
-
.join(', ') +
|
|
315
|
-
'})'
|
|
316
|
-
: 'empty';
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
export { build };
|
|
320
|
-
//# sourceMappingURL=index3.js.map
|
package/dist/index3.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index3.js","sources":["../src/api/build/index.js"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { rimraf } from '@sveltejs/app-utils/files';\nimport create_manifest_data from '../../core/create_manifest_data.js';\nimport { copy_assets } from '../utils.js';\nimport { create_app } from '../../core/create_app.js';\nimport vite from 'vite';\nimport svelte from '@svitejs/vite-plugin-svelte';\n\n/** @param {any} value */\nconst s = (value) => JSON.stringify(value);\n\n/**\n * @param {import('../../types').ValidatedConfig} config\n * @param {{\n * cwd?: string;\n * renderer?: string;\n * }} [opts]\n */\nexport async function build(\n\tconfig,\n\t{ cwd = process.cwd(), renderer = '@sveltejs/kit/renderer' } = {}\n) {\n\tconst build_dir = path.resolve(cwd, '.svelte/build');\n\tconst output_dir = path.resolve(cwd, '.svelte/output');\n\n\tconst manifest = create_manifest_data({\n\t\tconfig,\n\t\toutput: build_dir,\n\t\tcwd\n\t});\n\n\trimraf(build_dir);\n\n\tcreate_app({\n\t\tmanifest_data: manifest,\n\t\toutput: build_dir,\n\t\tcwd\n\t});\n\n\tcopy_assets(build_dir);\n\n\tprocess.env.VITE_AMP = config.kit.amp ? 'true' : '';\n\n\tconst client_entry_file = '.svelte/build/runtime/internal/start.js';\n\tconst client_out_dir = `${output_dir}/client/${config.kit.appDir}`;\n\tconst client_manifest_file = `${client_out_dir}/manifest.json`;\n\n\tconst base =\n\t\tconfig.kit.paths.assets === '/.'\n\t\t\t? `/${config.kit.appDir}/`\n\t\t\t: `${config.kit.paths.assets}/${config.kit.appDir}/`;\n\n\t// client build\n\tawait vite.build({\n\t\troot: cwd,\n\t\tbase,\n\t\tbuild: {\n\t\t\tcssCodeSplit: true,\n\t\t\tmanifest: true,\n\t\t\tlib: {\n\t\t\t\tentry: client_entry_file,\n\t\t\t\tname: 'app',\n\t\t\t\tformats: ['es']\n\t\t\t},\n\t\t\toutDir: client_out_dir\n\t\t},\n\t\tresolve: {\n\t\t\talias: {\n\t\t\t\t$app: path.resolve(`${build_dir}/runtime/app`)\n\t\t\t}\n\t\t},\n\t\tplugins: [\n\t\t\tsvelte({\n\t\t\t\temitCss: true,\n\t\t\t\tcompilerOptions: {\n\t\t\t\t\tdev: true,\n\t\t\t\t\thydratable: true\n\t\t\t\t},\n\t\t\t\thot: true,\n\t\t\t\textensions: config.extensions\n\t\t\t})\n\t\t]\n\t});\n\n\t/** @type {Record<string, {\n\t * file: string;\n\t * css: string[];\n\t * imports: string[];\n\t * }>} */\n\tconst client_manifest = JSON.parse(fs.readFileSync(client_manifest_file, 'utf-8'));\n\tfs.unlinkSync(client_manifest_file);\n\n\tlet setup_file = 'src/setup/index.js'; // TODO this is wrong... should see if we can resolve files.setup using Vite's resolution logic\n\tif (!fs.existsSync(path.resolve(cwd, setup_file))) {\n\t\tsetup_file = '.svelte/build/setup.js';\n\t\tfs.writeFileSync(path.resolve(cwd, setup_file), '');\n\t}\n\n\tconst app_file = `${build_dir}/app.js`;\n\n\t/** @type {(file: string) => string} */\n\tconst app_relative = (file) => {\n\t\tconst relative_file = path.relative('.svelte/build', file);\n\t\treturn relative_file[0] === '.' ? relative_file : `./${relative_file}`;\n\t};\n\n\tconst component_indexes = new Map();\n\tmanifest.components.forEach((c, i) => {\n\t\tcomponent_indexes.set(c, i);\n\t});\n\n\t/** @param {string} c */\n\tconst stringify_component = (c) => `() => import(${s(`${app_relative(c)}`)})`;\n\n\t// TODO ideally we wouldn't embed the css_lookup, but this is the easiest\n\t// way to be able to inline CSS into AMP documents. if we come up with\n\t// something better, we could use it for non-AMP documents too, as\n\t// critical CSS below a certain threshold _should_ be inlined\n\tconst css_lookup = {};\n\t// manifest.pages.forEach((data) => {\n\t// \tdata.parts.forEach((c) => {\n\t// \t\tconst deps = client.deps[c];\n\t// \t\tdeps.css.forEach((dep) => {\n\t// \t\t\tconst url = `${config.kit.paths.assets}/${config.kit.appDir}/${dep}`.replace(/^\\/\\./, '');\n\t// \t\t\tconst file = `${OPTIMIZED}/client/${config.kit.appDir}/${dep}`;\n\n\t// \t\t\tcss_lookup[url] = fs.readFileSync(file, 'utf-8');\n\t// \t\t});\n\t// \t});\n\t// });\n\n\t// TODO get_stack, below, just returns the stack as-is, without sourcemapping\n\n\tconst entry = `${config.kit.paths.assets}/${config.kit.appDir}/${client_manifest[client_entry_file].file}`;\n\n\t// prettier-ignore\n\tfs.writeFileSync(\n\t\tapp_file,\n\t\t`\n\t\t\timport * as renderer from '${renderer}';\n\t\t\timport root from './generated/root.svelte';\n\t\t\timport { set_paths } from './runtime/internal/singletons.js';\n\t\t\timport * as setup from ${s(app_relative(setup_file))};\n\n\t\t\tconst template = ({ head, body }) => ${s(fs.readFileSync(config.kit.files.template, 'utf-8'))\n\t\t\t\t.replace('%svelte.head%', '\" + head + \"')\n\t\t\t\t.replace('%svelte.body%', '\" + body + \"')};\n\n\t\t\tset_paths(${s(config.kit.paths)});\n\n\t\t\t// allow paths to be overridden in svelte-kit start\n\t\t\texport function init({ paths }) {\n\t\t\t\tset_paths(paths);\n\t\t\t}\n\n\t\t\tinit({ paths: ${s(config.kit.paths)} });\n\n\t\t\tconst d = decodeURIComponent;\n\t\t\tconst empty = () => ({});\n\n\t\t\tconst components = [\n\t\t\t\t${manifest.components.map((c) => stringify_component(c)).join(',\\n\\t\\t\\t\\t')}\n\t\t\t];\n\n\t\t\t${config.kit.amp ? `\n\t\t\tconst css_lookup = ${s(css_lookup)};` : ''}\n\n\t\t\tconst manifest = {\n\t\t\t\tassets: ${s(manifest.assets)},\n\t\t\t\tlayout: ${stringify_component(manifest.layout)},\n\t\t\t\terror: ${stringify_component(manifest.error)},\n\t\t\t\tpages: [\n\t\t\t\t\t${manifest.pages\n\t\t\t\t\t\t.map((data) => {\n\t\t\t\t\t\t\tconst params = get_params(data.params);\n\t\t\t\t\t\t\tconst parts = data.parts.map(c => `components[${component_indexes.get(c)}]`);\n\n\t\t\t\t\t\t\tconst prefix = config.kit.paths.assets === '/.' ? '' : config.kit.paths.assets;\n\n\t\t\t\t\t\t\t/** @param {string} dep */\n\t\t\t\t\t\t\tconst path_to_dep = dep => prefix + `/${config.kit.appDir}/${dep}`;\n\n\t\t\t\t\t\t\tconst js_deps = new Set();\n\t\t\t\t\t\t\tconst css_deps = new Set();\n\n\t\t\t\t\t\t\t/** @param {string} id */\n\t\t\t\t\t\t\tfunction find_deps(id) {\n\t\t\t\t\t\t\t\tconst chunk = client_manifest[id];\n\t\t\t\t\t\t\t\tjs_deps.add(path_to_dep(chunk.file));\n\n\t\t\t\t\t\t\t\tif (chunk.css) {\n\t\t\t\t\t\t\t\t\tchunk.css.forEach(file => css_deps.add(path_to_dep(file)));\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (chunk.imports) {\n\t\t\t\t\t\t\t\t\tchunk.imports.forEach(find_deps);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tfor (const part of data.parts) {\n\t\t\t\t\t\t\t\tfind_deps(part);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// data.parts.forEach(c => {\n\t\t\t\t\t\t\t// \tconst deps = client.deps[c];\n\t\t\t\t\t\t\t// \tdeps.js.forEach(dep => js_deps.add(path_to_dep(dep)));\n\t\t\t\t\t\t\t// \tdeps.css.forEach(dep => css_deps.add(path_to_dep(dep)));\n\t\t\t\t\t\t\t// });\n\n\t\t\t\t\t\t\treturn `{\n\t\t\t\t\t\t\t\tpattern: ${data.pattern},\n\t\t\t\t\t\t\t\tparams: ${params},\n\t\t\t\t\t\t\t\tparts: [${parts.join(', ')}],\n\t\t\t\t\t\t\t\tcss: [${Array.from(css_deps).map(s).join(', ')}],\n\t\t\t\t\t\t\t\tjs: [${Array.from(js_deps).map(s).join(', ')}]\n\t\t\t\t\t\t\t}`;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join(',\\n\\t\\t\\t\\t\\t')}\n\t\t\t\t],\n\t\t\t\tendpoints: [\n\t\t\t\t\t${manifest.endpoints\n\t\t\t\t\t\t.map((data) => {\n\t\t\t\t\t\t\tconst params = get_params(data.params);\n\t\t\t\t\t\t\tconst load = `() => import(${s(app_relative(data.file))})`;\n\n\t\t\t\t\t\t\treturn `{ pattern: ${data.pattern}, params: ${params}, load: ${load} }`;\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join(',\\n\\t\\t\\t\\t\\t')}\n\t\t\t\t]\n\t\t\t};\n\n\t\t\texport function render(request, {\n\t\t\t\tpaths = ${s(config.kit.paths)},\n\t\t\t\tlocal = false,\n\t\t\t\tonly_prerender = false,\n\t\t\t\tget_static_file\n\t\t\t} = {}) {\n\t\t\t\treturn renderer.render(request, {\n\t\t\t\t\tpaths,\n\t\t\t\t\tlocal,\n\t\t\t\t\ttemplate,\n\t\t\t\t\tmanifest,\n\t\t\t\t\ttarget: ${s(config.kit.target)},${\n\t\t\t\t\t\tconfig.kit.startGlobal ? `\\n\\t\\t\\t\\t\\tstart_global: ${s(config.kit.startGlobal)},` : ''\n\t\t\t\t\t}\n\t\t\t\t\tentry: ${s(entry)},\n\t\t\t\t\troot,\n\t\t\t\t\tsetup,\n\t\t\t\t\tdev: false,\n\t\t\t\t\tamp: ${config.kit.amp},\n\t\t\t\t\tonly_prerender,\n\t\t\t\t\tapp_dir: ${s(config.kit.appDir)},\n\t\t\t\t\thost: ${s(config.kit.host)},\n\t\t\t\t\thost_header: ${s(config.kit.hostHeader)},\n\t\t\t\t\tget_stack: error => error.stack,\n\t\t\t\t\tget_static_file,\n\t\t\t\t\tget_amp_css: dep => css_lookup[dep]\n\t\t\t\t});\n\t\t\t}\n\t\t`\n\t\t\t.replace(/^\\t{3}/gm, '')\n\t\t\t.trim()\n\t);\n\n\tawait vite.build({\n\t\troot: cwd,\n\t\tbase,\n\t\tbuild: {\n\t\t\tssr: true,\n\t\t\tlib: {\n\t\t\t\tentry: app_file,\n\t\t\t\tname: 'app',\n\t\t\t\tformats: ['es']\n\t\t\t},\n\t\t\toutDir: `${output_dir}/server`\n\t\t},\n\t\tresolve: {\n\t\t\talias: {\n\t\t\t\t$app: path.resolve(`${build_dir}/runtime/app`)\n\t\t\t}\n\t\t},\n\t\tplugins: [\n\t\t\tsvelte({\n\t\t\t\temitCss: true,\n\t\t\t\tcompilerOptions: {\n\t\t\t\t\tdev: true,\n\t\t\t\t\thydratable: true\n\t\t\t\t},\n\t\t\t\thot: true,\n\t\t\t\textensions: config.extensions\n\t\t\t})\n\t\t],\n\t\tssr: {\n\t\t\tnoExternal: ['svelte']\n\t\t}\n\t});\n}\n\n/** @param {string[]} array */\nfunction get_params(array) {\n\t// given an array of params like `['x', 'y', 'z']` for\n\t// src/routes/[x]/[y]/[z]/svelte, create a function\n\t// that turns a RexExpMatchArray into ({ x, y, z })\n\treturn array.length\n\t\t? '(m) => ({ ' +\n\t\t\t\tarray\n\t\t\t\t\t.map((param, i) => {\n\t\t\t\t\t\treturn param.startsWith('...')\n\t\t\t\t\t\t\t? `${param.slice(3)}: d(m[${i + 1}]).split('/')`\n\t\t\t\t\t\t\t: `${param}: d(m[${i + 1}])`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(', ') +\n\t\t\t\t'})'\n\t\t: 'empty';\n}\n"],"names":[],"mappings":";;;;;;;;;;AASA;AACA,MAAM,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,KAAK;AAC3B,CAAC,MAAM;AACP,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,GAAG,wBAAwB,EAAE,GAAG,EAAE;AAClE,EAAE;AACF,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;AACtD,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,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AG,EAAE;AACP,GAAG,UAAU,EAAE,CAAC,QAAQ,CAAC;AACzB,GAAG;AACH,EAAE,CAAC,CAAC;AACJ,CAAC;AACD;AACA;AACA,SAAS,UAAU,CAAC,KAAK,EAAE;AAC3B;AACA;AACA;AACA,CAAC,OAAO,KAAK,CAAC,MAAM;AACpB,IAAI,YAAY;AAChB,IAAI,KAAK;AACT,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK;AACxB,MAAM,OAAO,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;AACpC,SAAS,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC;AACvD,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC;AACP,MAAM,IAAI,CAAC,IAAI,CAAC;AAChB,IAAI,IAAI;AACR,IAAI,OAAO,CAAC;AACZ;;;;"}
|
package/dist/index4.js
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import fs, { readdirSync, statSync, existsSync, createReadStream } from 'fs';
|
|
2
|
-
import http from 'http';
|
|
3
|
-
import { pathToFileURL, parse as parse$1, URLSearchParams } from 'url';
|
|
4
|
-
import { resolve, join, normalize } from 'path';
|
|
5
|
-
import { M as Mime_1, s as standard } from './standard.js';
|
|
6
|
-
import { g as get_body } from './index5.js';
|
|
7
|
-
|
|
8
|
-
function list(dir, callback, pre='') {
|
|
9
|
-
dir = resolve('.', dir);
|
|
10
|
-
let arr = readdirSync(dir);
|
|
11
|
-
let i=0, abs, stats;
|
|
12
|
-
for (; i < arr.length; i++) {
|
|
13
|
-
abs = join(dir, arr[i]);
|
|
14
|
-
stats = statSync(abs);
|
|
15
|
-
stats.isDirectory()
|
|
16
|
-
? list(abs, callback, join(pre, arr[i]))
|
|
17
|
-
: callback(join(pre, arr[i]), abs, stats);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function parse(str) {
|
|
22
|
-
let i=0, j=0, k, v;
|
|
23
|
-
let out={}, arr=str.split('&');
|
|
24
|
-
for (; i < arr.length; i++) {
|
|
25
|
-
j = arr[i].indexOf('=');
|
|
26
|
-
v = !!~j && arr[i].substring(j+1) || '';
|
|
27
|
-
k = !!~j ? arr[i].substring(0, j) : arr[i];
|
|
28
|
-
out[k] = out[k] !== void 0 ? [].concat(out[k], v) : v;
|
|
29
|
-
}
|
|
30
|
-
return out;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function parser (req, toDecode) {
|
|
34
|
-
let url = req.url;
|
|
35
|
-
if (url == null) return;
|
|
36
|
-
|
|
37
|
-
let obj = req._parsedUrl;
|
|
38
|
-
if (obj && obj._raw === url) return obj;
|
|
39
|
-
|
|
40
|
-
obj = {
|
|
41
|
-
path: url,
|
|
42
|
-
pathname: url,
|
|
43
|
-
search: null,
|
|
44
|
-
query: null,
|
|
45
|
-
href: url,
|
|
46
|
-
_raw: url
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
if (url.length > 1) {
|
|
50
|
-
if (toDecode && !req._decoded && !!~url.indexOf('%', 1)) {
|
|
51
|
-
let nxt = url;
|
|
52
|
-
try { nxt = decodeURIComponent(url); } catch (e) {/* bad */}
|
|
53
|
-
url = req.url = obj.href = obj.path = obj.pathname = obj._raw = nxt;
|
|
54
|
-
req._decoded = true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let idx = url.indexOf('?', 1);
|
|
58
|
-
|
|
59
|
-
if (idx !== -1) {
|
|
60
|
-
obj.search = url.substring(idx);
|
|
61
|
-
obj.query = obj.search.substring(1);
|
|
62
|
-
obj.pathname = url.substring(0, idx);
|
|
63
|
-
if (toDecode && obj.query.length > 0) {
|
|
64
|
-
obj.query = parse(obj.query);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return (req._parsedUrl = obj);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
var lite = new Mime_1(standard);
|
|
73
|
-
|
|
74
|
-
const noop = () => {};
|
|
75
|
-
|
|
76
|
-
function isMatch(uri, arr) {
|
|
77
|
-
for (let i=0; i < arr.length; i++) {
|
|
78
|
-
if (arr[i].test(uri)) return true;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function toAssume(uri, extns) {
|
|
83
|
-
let i=0, x, len=uri.length - 1;
|
|
84
|
-
if (uri.charCodeAt(len) === 47) {
|
|
85
|
-
uri = uri.substring(0, len);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let arr=[], tmp=`${uri}/index`;
|
|
89
|
-
for (; i < extns.length; i++) {
|
|
90
|
-
x = extns[i] ? `.${extns[i]}` : '';
|
|
91
|
-
if (uri) arr.push(uri + x);
|
|
92
|
-
arr.push(tmp + x);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return arr;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function viaCache(cache, uri, extns) {
|
|
99
|
-
let i=0, data, arr=toAssume(uri, extns);
|
|
100
|
-
for (; i < arr.length; i++) {
|
|
101
|
-
if (data = cache[arr[i]]) return data;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function viaLocal(dir, isEtag, uri, extns) {
|
|
106
|
-
let i=0, arr=toAssume(uri, extns);
|
|
107
|
-
let abs, stats, name, headers;
|
|
108
|
-
for (; i < arr.length; i++) {
|
|
109
|
-
abs = normalize(join(dir, name=arr[i]));
|
|
110
|
-
if (abs.startsWith(dir) && existsSync(abs)) {
|
|
111
|
-
stats = statSync(abs);
|
|
112
|
-
if (stats.isDirectory()) continue;
|
|
113
|
-
headers = toHeaders(name, stats, isEtag);
|
|
114
|
-
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
|
|
115
|
-
return { abs, stats, headers };
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function is404(req, res) {
|
|
121
|
-
return (res.statusCode=404,res.end());
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function send(req, res, file, stats, headers) {
|
|
125
|
-
let code=200, tmp, opts={};
|
|
126
|
-
headers = { ...headers };
|
|
127
|
-
|
|
128
|
-
for (let key in headers) {
|
|
129
|
-
tmp = res.getHeader(key);
|
|
130
|
-
if (tmp) headers[key] = tmp;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (tmp = res.getHeader('content-type')) {
|
|
134
|
-
headers['Content-Type'] = tmp;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (req.headers.range) {
|
|
138
|
-
code = 206;
|
|
139
|
-
let [x, y] = req.headers.range.replace('bytes=', '').split('-');
|
|
140
|
-
let end = opts.end = parseInt(y, 10) || stats.size - 1;
|
|
141
|
-
let start = opts.start = parseInt(x, 10) || 0;
|
|
142
|
-
|
|
143
|
-
if (start >= stats.size || end >= stats.size) {
|
|
144
|
-
res.setHeader('Content-Range', `bytes */${stats.size}`);
|
|
145
|
-
res.statusCode = 416;
|
|
146
|
-
return res.end();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
headers['Content-Range'] = `bytes ${start}-${end}/${stats.size}`;
|
|
150
|
-
headers['Content-Length'] = (end - start + 1);
|
|
151
|
-
headers['Accept-Ranges'] = 'bytes';
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
res.writeHead(code, headers);
|
|
155
|
-
createReadStream(file, opts).pipe(res);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function isEncoding(name, type, headers) {
|
|
159
|
-
headers['Content-Encoding'] = type;
|
|
160
|
-
headers['Content-Type'] = lite.getType(name.replace(/\.([^.]*)$/, '')) || '';
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function toHeaders(name, stats, isEtag) {
|
|
164
|
-
let headers = {
|
|
165
|
-
'Content-Length': stats.size,
|
|
166
|
-
'Content-Type': lite.getType(name) || '',
|
|
167
|
-
'Last-Modified': stats.mtime.toUTCString(),
|
|
168
|
-
};
|
|
169
|
-
if (isEtag) headers['ETag'] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
|
|
170
|
-
if (/\.br$/.test(name)) isEncoding(name, 'br', headers);
|
|
171
|
-
if (/\.gz$/.test(name)) isEncoding(name, 'gzip', headers);
|
|
172
|
-
return headers;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function sirv (dir, opts={}) {
|
|
176
|
-
dir = resolve(dir || '.');
|
|
177
|
-
|
|
178
|
-
let isNotFound = opts.onNoMatch || is404;
|
|
179
|
-
let setHeaders = opts.setHeaders || noop;
|
|
180
|
-
|
|
181
|
-
let extensions = opts.extensions || ['html', 'htm'];
|
|
182
|
-
let gzips = opts.gzip && extensions.map(x => `${x}.gz`).concat('gz');
|
|
183
|
-
let brots = opts.brotli && extensions.map(x => `${x}.br`).concat('br');
|
|
184
|
-
|
|
185
|
-
const FILES = {};
|
|
186
|
-
|
|
187
|
-
let fallback = '/';
|
|
188
|
-
let isEtag = !!opts.etag;
|
|
189
|
-
let isSPA = !!opts.single;
|
|
190
|
-
if (typeof opts.single === 'string') {
|
|
191
|
-
let idx = opts.single.lastIndexOf('.');
|
|
192
|
-
fallback += !!~idx ? opts.single.substring(0, idx) : opts.single;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
let ignores = [];
|
|
196
|
-
if (opts.ignores !== false) {
|
|
197
|
-
ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/); // any extn
|
|
198
|
-
if (opts.dotfiles) ignores.push(/\/\.\w/);
|
|
199
|
-
else ignores.push(/\/\.well-known/);
|
|
200
|
-
[].concat(opts.ignores || []).forEach(x => {
|
|
201
|
-
ignores.push(new RegExp(x, 'i'));
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
|
|
206
|
-
if (cc && opts.immutable) cc += ',immutable';
|
|
207
|
-
else if (cc && opts.maxAge === 0) cc += ',must-revalidate';
|
|
208
|
-
|
|
209
|
-
if (!opts.dev) {
|
|
210
|
-
list(dir, (name, abs, stats) => {
|
|
211
|
-
if (/\.well-known[\\+\/]/.test(name)) ; // keep
|
|
212
|
-
else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return;
|
|
213
|
-
|
|
214
|
-
let headers = toHeaders(name, stats, isEtag);
|
|
215
|
-
if (cc) headers['Cache-Control'] = cc;
|
|
216
|
-
|
|
217
|
-
FILES['/' + name.normalize().replace(/\\+/g, '/')] = { abs, stats, headers };
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
let lookup = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES);
|
|
222
|
-
|
|
223
|
-
return function (req, res, next) {
|
|
224
|
-
let extns = [''];
|
|
225
|
-
let val = req.headers['accept-encoding'] || '';
|
|
226
|
-
if (gzips && val.includes('gzip')) extns.unshift(...gzips);
|
|
227
|
-
if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots);
|
|
228
|
-
extns.push(...extensions); // [...br, ...gz, orig, ...exts]
|
|
229
|
-
|
|
230
|
-
let pathname = req.path || parser(req, true).pathname;
|
|
231
|
-
let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns);
|
|
232
|
-
if (!data) return next ? next() : isNotFound(req, res);
|
|
233
|
-
|
|
234
|
-
if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
|
|
235
|
-
res.writeHead(304);
|
|
236
|
-
return res.end();
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
if (gzips || brots) {
|
|
240
|
-
res.setHeader('Vary', 'Accept-Encoding');
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
setHeaders(res, pathname, data.stats);
|
|
244
|
-
send(req, res, data.abs, data.stats, data.headers);
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/** @param {string} dir */
|
|
249
|
-
const mutable = (dir) =>
|
|
250
|
-
sirv(dir, {
|
|
251
|
-
etag: true,
|
|
252
|
-
maxAge: 0
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* @param {{
|
|
257
|
-
* port: number;
|
|
258
|
-
* config: import('../../types').ValidatedConfig;
|
|
259
|
-
* cwd: string;
|
|
260
|
-
* }} opts
|
|
261
|
-
* @returns {Promise<import('http').Server>}
|
|
262
|
-
*/
|
|
263
|
-
async function start({ port, config, cwd = process.cwd() }) {
|
|
264
|
-
const app_file = resolve(cwd, '.svelte/output/server/app.js');
|
|
265
|
-
|
|
266
|
-
/** @type {import('../../types').App} */
|
|
267
|
-
const app = await import(pathToFileURL(app_file).href);
|
|
268
|
-
|
|
269
|
-
/** @type {import('sirv').RequestHandler} */
|
|
270
|
-
const static_handler = fs.existsSync(config.kit.files.assets)
|
|
271
|
-
? mutable(config.kit.files.assets)
|
|
272
|
-
: (_req, _res, next) => next();
|
|
273
|
-
|
|
274
|
-
const assets_handler = sirv(resolve(cwd, '.svelte/output/client'), {
|
|
275
|
-
maxAge: 31536000,
|
|
276
|
-
immutable: true
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
return new Promise((fulfil) => {
|
|
280
|
-
const server = http.createServer((req, res) => {
|
|
281
|
-
const parsed = parse$1(req.url || '');
|
|
282
|
-
|
|
283
|
-
assets_handler(req, res, () => {
|
|
284
|
-
static_handler(req, res, async () => {
|
|
285
|
-
const rendered = await app.render(
|
|
286
|
-
{
|
|
287
|
-
method: req.method,
|
|
288
|
-
headers: req.headers,
|
|
289
|
-
path: parsed.pathname,
|
|
290
|
-
body: await get_body(req),
|
|
291
|
-
query: new URLSearchParams(parsed.query || '')
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
paths: {
|
|
295
|
-
base: '',
|
|
296
|
-
assets: '/.'
|
|
297
|
-
},
|
|
298
|
-
get_stack: (error) => error.stack, // TODO should this return a sourcemapped stacktrace?
|
|
299
|
-
get_static_file: (file) => fs.readFileSync(join(config.kit.files.assets, file))
|
|
300
|
-
}
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
if (rendered) {
|
|
304
|
-
res.writeHead(rendered.status, rendered.headers);
|
|
305
|
-
res.end(rendered.body);
|
|
306
|
-
} else {
|
|
307
|
-
res.statusCode = 404;
|
|
308
|
-
res.end('Not found');
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
server.listen(port, () => {
|
|
315
|
-
fulfil(server);
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
return server;
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export { start };
|
|
323
|
-
//# sourceMappingURL=index4.js.map
|