@sveltejs/kit 1.0.0-next.278 → 1.0.0-next.281
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/client/start.js +12 -12
- package/assets/server/index.js +93 -98
- package/dist/chunks/amp_hook.js +1 -1
- package/dist/chunks/index.js +9 -9
- package/dist/chunks/index2.js +6 -6
- package/dist/chunks/index3.js +18 -18
- package/dist/chunks/index4.js +2 -2
- package/dist/chunks/index5.js +54 -59
- package/dist/chunks/index6.js +9 -9
- package/dist/chunks/index7.js +3 -3
- package/dist/cli.js +6 -6
- package/dist/hooks.js +4 -4
- package/dist/node.js +1 -1
- package/package.json +4 -3
- package/types/{ambient-modules.d.ts → ambient.d.ts} +0 -0
- package/types/index.d.ts +388 -21
- package/types/internal.d.ts +257 -145
- package/types/app.d.ts +0 -35
- package/types/config.d.ts +0 -200
- package/types/csp.d.ts +0 -115
- package/types/endpoint.d.ts +0 -39
- package/types/helper.d.ts +0 -23
- package/types/hooks.d.ts +0 -37
- package/types/page.d.ts +0 -33
package/assets/client/start.js
CHANGED
|
@@ -69,8 +69,8 @@ class Router {
|
|
|
69
69
|
/**
|
|
70
70
|
* @param {{
|
|
71
71
|
* base: string;
|
|
72
|
-
* routes: import('types
|
|
73
|
-
* trailing_slash: import('types
|
|
72
|
+
* routes: import('types').CSRRoute[];
|
|
73
|
+
* trailing_slash: import('types').TrailingSlash;
|
|
74
74
|
* renderer: import('./renderer').Renderer
|
|
75
75
|
* }} opts
|
|
76
76
|
*/
|
|
@@ -481,7 +481,7 @@ function coalesce_to_error(err) {
|
|
|
481
481
|
|
|
482
482
|
/**
|
|
483
483
|
* Hash using djb2
|
|
484
|
-
* @param {import('types
|
|
484
|
+
* @param {import('types').StrictBody} value
|
|
485
485
|
*/
|
|
486
486
|
function hash(value) {
|
|
487
487
|
let hash = 5381;
|
|
@@ -497,8 +497,8 @@ function hash(value) {
|
|
|
497
497
|
}
|
|
498
498
|
|
|
499
499
|
/**
|
|
500
|
-
* @param {import('types
|
|
501
|
-
* @returns {import('types
|
|
500
|
+
* @param {import('types').LoadOutput} loaded
|
|
501
|
+
* @returns {import('types').NormalizedLoadOutput}
|
|
502
502
|
*/
|
|
503
503
|
function normalize(loaded) {
|
|
504
504
|
const has_error_status =
|
|
@@ -558,11 +558,11 @@ function normalize(loaded) {
|
|
|
558
558
|
);
|
|
559
559
|
}
|
|
560
560
|
|
|
561
|
-
return /** @type {import('types
|
|
561
|
+
return /** @type {import('types').NormalizedLoadOutput} */ (loaded);
|
|
562
562
|
}
|
|
563
563
|
|
|
564
564
|
/**
|
|
565
|
-
* @typedef {import('types
|
|
565
|
+
* @typedef {import('types').CSRComponent} CSRComponent
|
|
566
566
|
* @typedef {{ from: URL; to: URL }} Navigating
|
|
567
567
|
*/
|
|
568
568
|
|
|
@@ -1208,7 +1208,7 @@ class Renderer {
|
|
|
1208
1208
|
if (module.load) {
|
|
1209
1209
|
const { started } = this;
|
|
1210
1210
|
|
|
1211
|
-
/** @type {import('types
|
|
1211
|
+
/** @type {import('types').LoadInput | import('types').ErrorLoadInput} */
|
|
1212
1212
|
const load_input = {
|
|
1213
1213
|
params: uses_params,
|
|
1214
1214
|
props: props || {},
|
|
@@ -1243,8 +1243,8 @@ class Renderer {
|
|
|
1243
1243
|
}
|
|
1244
1244
|
|
|
1245
1245
|
if (error) {
|
|
1246
|
-
/** @type {import('types
|
|
1247
|
-
/** @type {import('types
|
|
1246
|
+
/** @type {import('types').ErrorLoadInput} */ (load_input).status = status;
|
|
1247
|
+
/** @type {import('types').ErrorLoadInput} */ (load_input).error = error;
|
|
1248
1248
|
}
|
|
1249
1249
|
|
|
1250
1250
|
const loaded = await module.load.call(null, load_input);
|
|
@@ -1519,11 +1519,11 @@ class Renderer {
|
|
|
1519
1519
|
* session: any;
|
|
1520
1520
|
* route: boolean;
|
|
1521
1521
|
* spa: boolean;
|
|
1522
|
-
* trailing_slash: import('types
|
|
1522
|
+
* trailing_slash: import('types').TrailingSlash;
|
|
1523
1523
|
* hydrate: {
|
|
1524
1524
|
* status: number;
|
|
1525
1525
|
* error: Error;
|
|
1526
|
-
* nodes: Array<Promise<import('types
|
|
1526
|
+
* nodes: Array<Promise<import('types').CSRComponent>>;
|
|
1527
1527
|
* params: Record<string, string>;
|
|
1528
1528
|
* };
|
|
1529
1529
|
* }} opts
|
package/assets/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @param {Partial<import('types
|
|
1
|
+
/** @param {Partial<import('types').ResponseHeaders> | undefined} object */
|
|
2
2
|
function to_headers(object) {
|
|
3
3
|
const headers = new Headers();
|
|
4
4
|
|
|
@@ -22,7 +22,7 @@ function to_headers(object) {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Hash using djb2
|
|
25
|
-
* @param {import('types
|
|
25
|
+
* @param {import('types').StrictBody} value
|
|
26
26
|
*/
|
|
27
27
|
function hash(value) {
|
|
28
28
|
let hash = 5381;
|
|
@@ -89,7 +89,7 @@ function is_pojo(body) {
|
|
|
89
89
|
return true;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* @param {import('types
|
|
92
|
+
* @param {import('types').RequestEvent} event
|
|
93
93
|
* @returns string
|
|
94
94
|
*/
|
|
95
95
|
function normalize_request_method(event) {
|
|
@@ -130,14 +130,14 @@ function is_text(content_type) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* @param {import('types
|
|
134
|
-
* @param {{ [method: string]: import('types
|
|
133
|
+
* @param {import('types').RequestEvent} event
|
|
134
|
+
* @param {{ [method: string]: import('types').RequestHandler }} mod
|
|
135
135
|
* @returns {Promise<Response | undefined>}
|
|
136
136
|
*/
|
|
137
137
|
async function render_endpoint(event, mod) {
|
|
138
138
|
const method = normalize_request_method(event);
|
|
139
139
|
|
|
140
|
-
/** @type {import('types
|
|
140
|
+
/** @type {import('types').RequestHandler} */
|
|
141
141
|
let handler = mod[method];
|
|
142
142
|
|
|
143
143
|
if (!handler && method === 'head') {
|
|
@@ -172,14 +172,14 @@ async function render_endpoint(event, mod) {
|
|
|
172
172
|
);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
/** @type {import('types
|
|
175
|
+
/** @type {import('types').StrictBody} */
|
|
176
176
|
let normalized_body;
|
|
177
177
|
|
|
178
178
|
if (is_pojo(body) && (!type || type.startsWith('application/json'))) {
|
|
179
179
|
headers.set('content-type', 'application/json; charset=utf-8');
|
|
180
180
|
normalized_body = JSON.stringify(body);
|
|
181
181
|
} else {
|
|
182
|
-
normalized_body = /** @type {import('types
|
|
182
|
+
normalized_body = /** @type {import('types').StrictBody} */ (body);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
if (
|
|
@@ -515,7 +515,7 @@ const escape_json_in_html_regex = new RegExp(
|
|
|
515
515
|
|
|
516
516
|
/**
|
|
517
517
|
* Escape a JSONValue that's going to be embedded in a `<script>` tag
|
|
518
|
-
* @param {import(
|
|
518
|
+
* @param {import('types').JSONValue} val
|
|
519
519
|
*/
|
|
520
520
|
function escape_json_in_html(val) {
|
|
521
521
|
return JSON.stringify(val).replace(
|
|
@@ -525,55 +525,50 @@ function escape_json_in_html(val) {
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
/**
|
|
528
|
-
*
|
|
529
|
-
* @
|
|
530
|
-
* @
|
|
531
|
-
* @returns {string}
|
|
528
|
+
* When inside a double-quoted attribute value, only `&` and `"` hold special meaning.
|
|
529
|
+
* @see https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(double-quoted)-state
|
|
530
|
+
* @type {Record<string, string>}
|
|
532
531
|
*/
|
|
533
|
-
function escape(str, dict, unicode_encoder) {
|
|
534
|
-
let result = '';
|
|
535
|
-
|
|
536
|
-
for (let i = 0; i < str.length; i += 1) {
|
|
537
|
-
const char = str.charAt(i);
|
|
538
|
-
const code = char.charCodeAt(0);
|
|
539
|
-
|
|
540
|
-
if (char in dict) {
|
|
541
|
-
result += dict[char];
|
|
542
|
-
} else if (code >= 0xd800 && code <= 0xdfff) {
|
|
543
|
-
const next = str.charCodeAt(i + 1);
|
|
544
|
-
|
|
545
|
-
// If this is the beginning of a [high, low] surrogate pair,
|
|
546
|
-
// add the next two characters, otherwise escape
|
|
547
|
-
if (code <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
|
|
548
|
-
result += char + str[++i];
|
|
549
|
-
} else {
|
|
550
|
-
result += unicode_encoder(code);
|
|
551
|
-
}
|
|
552
|
-
} else {
|
|
553
|
-
result += char;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
return result;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
/** @type {Record<string, string>} */
|
|
561
532
|
const escape_html_attr_dict = {
|
|
562
|
-
'
|
|
563
|
-
'>': '>',
|
|
533
|
+
'&': '&',
|
|
564
534
|
'"': '"'
|
|
565
535
|
};
|
|
566
536
|
|
|
537
|
+
const escape_html_attr_regex = new RegExp(
|
|
538
|
+
// special characters
|
|
539
|
+
`[${Object.keys(escape_html_attr_dict).join('')}]|` +
|
|
540
|
+
// high surrogate without paired low surrogate
|
|
541
|
+
'[\\ud800-\\udbff](?![\\udc00-\\udfff])|' +
|
|
542
|
+
// a valid surrogate pair, the only match with 2 code units
|
|
543
|
+
// we match it so that we can match unpaired low surrogates in the same pass
|
|
544
|
+
// TODO: use lookbehind assertions once they are widely supported: (?<![\ud800-udbff])[\udc00-\udfff]
|
|
545
|
+
'[\\ud800-\\udbff][\\udc00-\\udfff]|' +
|
|
546
|
+
// unpaired low surrogate (see previous match)
|
|
547
|
+
'[\\udc00-\\udfff]',
|
|
548
|
+
'g'
|
|
549
|
+
);
|
|
550
|
+
|
|
567
551
|
/**
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
552
|
+
* Formats a string to be used as an attribute's value in raw HTML.
|
|
553
|
+
*
|
|
554
|
+
* It escapes unpaired surrogates (which are allowed in js strings but invalid in HTML), escapes
|
|
555
|
+
* characters that are special in attributes, and surrounds the whole string in double-quotes.
|
|
571
556
|
*
|
|
572
557
|
* @param {string} str
|
|
573
|
-
* @returns string
|
|
558
|
+
* @returns {string} Escaped string surrounded by double-quotes.
|
|
559
|
+
* @example const html = `<tag data-value=${escape_html_attr('value')}>...</tag>`;
|
|
574
560
|
*/
|
|
575
561
|
function escape_html_attr(str) {
|
|
576
|
-
|
|
562
|
+
const escaped_str = str.replace(escape_html_attr_regex, (match) => {
|
|
563
|
+
if (match.length === 2) {
|
|
564
|
+
// valid surrogate pair
|
|
565
|
+
return match;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
return escape_html_attr_dict[match] ?? `&#${match.charCodeAt(0)};`;
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
return `"${escaped_str}"`;
|
|
577
572
|
}
|
|
578
573
|
|
|
579
574
|
const s = JSON.stringify;
|
|
@@ -887,19 +882,19 @@ class Csp {
|
|
|
887
882
|
/** @type {boolean} */
|
|
888
883
|
#style_needs_csp;
|
|
889
884
|
|
|
890
|
-
/** @type {import('types
|
|
885
|
+
/** @type {import('types').CspDirectives} */
|
|
891
886
|
#directives;
|
|
892
887
|
|
|
893
|
-
/** @type {import('types
|
|
888
|
+
/** @type {import('types').Csp.Source[]} */
|
|
894
889
|
#script_src;
|
|
895
890
|
|
|
896
|
-
/** @type {import('types
|
|
891
|
+
/** @type {import('types').Csp.Source[]} */
|
|
897
892
|
#style_src;
|
|
898
893
|
|
|
899
894
|
/**
|
|
900
895
|
* @param {{
|
|
901
896
|
* mode: string,
|
|
902
|
-
* directives: import('types
|
|
897
|
+
* directives: import('types').CspDirectives
|
|
903
898
|
* }} config
|
|
904
899
|
* @param {{
|
|
905
900
|
* dev: boolean;
|
|
@@ -1049,15 +1044,15 @@ const updated = {
|
|
|
1049
1044
|
/**
|
|
1050
1045
|
* @param {{
|
|
1051
1046
|
* branch: Array<import('./types').Loaded>;
|
|
1052
|
-
* options: import('types
|
|
1053
|
-
* state: import('types
|
|
1047
|
+
* options: import('types').SSROptions;
|
|
1048
|
+
* state: import('types').SSRState;
|
|
1054
1049
|
* $session: any;
|
|
1055
1050
|
* page_config: { hydrate: boolean, router: boolean };
|
|
1056
1051
|
* status: number;
|
|
1057
1052
|
* error?: Error;
|
|
1058
1053
|
* url: URL;
|
|
1059
1054
|
* params: Record<string, string>;
|
|
1060
|
-
* resolve_opts: import('types
|
|
1055
|
+
* resolve_opts: import('types').RequiredResolveOptions;
|
|
1061
1056
|
* stuff: Record<string, any>;
|
|
1062
1057
|
* }} opts
|
|
1063
1058
|
*/
|
|
@@ -1331,7 +1326,7 @@ async function render_response({
|
|
|
1331
1326
|
const assets =
|
|
1332
1327
|
options.paths.assets || (segments.length > 0 ? segments.map(() => '..').join('/') : '.');
|
|
1333
1328
|
|
|
1334
|
-
const html = resolve_opts.transformPage({
|
|
1329
|
+
const html = await resolve_opts.transformPage({
|
|
1335
1330
|
html: options.template({ head, body, assets, nonce: /** @type {string} */ (csp.nonce) })
|
|
1336
1331
|
});
|
|
1337
1332
|
|
|
@@ -1391,8 +1386,8 @@ function serialize_error(error) {
|
|
|
1391
1386
|
}
|
|
1392
1387
|
|
|
1393
1388
|
/**
|
|
1394
|
-
* @param {import('types
|
|
1395
|
-
* @returns {import('types
|
|
1389
|
+
* @param {import('types').LoadOutput} loaded
|
|
1390
|
+
* @returns {import('types').NormalizedLoadOutput}
|
|
1396
1391
|
*/
|
|
1397
1392
|
function normalize(loaded) {
|
|
1398
1393
|
const has_error_status =
|
|
@@ -1452,7 +1447,7 @@ function normalize(loaded) {
|
|
|
1452
1447
|
);
|
|
1453
1448
|
}
|
|
1454
1449
|
|
|
1455
|
-
return /** @type {import('types
|
|
1450
|
+
return /** @type {import('types').NormalizedLoadOutput} */ (loaded);
|
|
1456
1451
|
}
|
|
1457
1452
|
|
|
1458
1453
|
const absolute = /^([a-z]+:)?\/?\//;
|
|
@@ -1512,13 +1507,13 @@ function normalize_path(path, trailing_slash) {
|
|
|
1512
1507
|
|
|
1513
1508
|
/**
|
|
1514
1509
|
* @param {{
|
|
1515
|
-
* event: import('types
|
|
1516
|
-
* options: import('types
|
|
1517
|
-
* state: import('types
|
|
1518
|
-
* route: import('types
|
|
1510
|
+
* event: import('types').RequestEvent;
|
|
1511
|
+
* options: import('types').SSROptions;
|
|
1512
|
+
* state: import('types').SSRState;
|
|
1513
|
+
* route: import('types').SSRPage | null;
|
|
1519
1514
|
* url: URL;
|
|
1520
1515
|
* params: Record<string, string>;
|
|
1521
|
-
* node: import('types
|
|
1516
|
+
* node: import('types').SSRNode;
|
|
1522
1517
|
* $session: any;
|
|
1523
1518
|
* stuff: Record<string, any>;
|
|
1524
1519
|
* is_error: boolean;
|
|
@@ -1561,13 +1556,13 @@ async function load_node({
|
|
|
1561
1556
|
*/
|
|
1562
1557
|
let set_cookie_headers = [];
|
|
1563
1558
|
|
|
1564
|
-
/** @type {import('types
|
|
1559
|
+
/** @type {import('types').Either<import('types').Fallthrough, import('types').LoadOutput>} */
|
|
1565
1560
|
let loaded;
|
|
1566
1561
|
|
|
1567
|
-
/** @type {import('types
|
|
1562
|
+
/** @type {import('types').ShadowData} */
|
|
1568
1563
|
const shadow = is_leaf
|
|
1569
1564
|
? await load_shadow_data(
|
|
1570
|
-
/** @type {import('types
|
|
1565
|
+
/** @type {import('types').SSRPage} */ (route),
|
|
1571
1566
|
event,
|
|
1572
1567
|
options,
|
|
1573
1568
|
!!state.prerender
|
|
@@ -1591,7 +1586,7 @@ async function load_node({
|
|
|
1591
1586
|
redirect: shadow.redirect
|
|
1592
1587
|
};
|
|
1593
1588
|
} else if (module.load) {
|
|
1594
|
-
/** @type {import('types
|
|
1589
|
+
/** @type {import('types').LoadInput | import('types').ErrorLoadInput} */
|
|
1595
1590
|
const load_input = {
|
|
1596
1591
|
url: state.prerender ? create_prerendering_url_proxy(url) : url,
|
|
1597
1592
|
params,
|
|
@@ -1649,7 +1644,7 @@ async function load_node({
|
|
|
1649
1644
|
/** @type {Response} */
|
|
1650
1645
|
let response;
|
|
1651
1646
|
|
|
1652
|
-
/** @type {import('types
|
|
1647
|
+
/** @type {import('types').PrerenderDependency} */
|
|
1653
1648
|
let dependency;
|
|
1654
1649
|
|
|
1655
1650
|
// handle fetch requests for static assets. e.g. prebaked data, etc.
|
|
@@ -1744,7 +1739,7 @@ async function load_node({
|
|
|
1744
1739
|
async function text() {
|
|
1745
1740
|
const body = await response.text();
|
|
1746
1741
|
|
|
1747
|
-
/** @type {import('types
|
|
1742
|
+
/** @type {import('types').ResponseHeaders} */
|
|
1748
1743
|
const headers = {};
|
|
1749
1744
|
for (const [key, value] of response.headers) {
|
|
1750
1745
|
if (key === 'set-cookie') {
|
|
@@ -1826,8 +1821,8 @@ async function load_node({
|
|
|
1826
1821
|
}
|
|
1827
1822
|
|
|
1828
1823
|
if (is_error) {
|
|
1829
|
-
/** @type {import('types
|
|
1830
|
-
/** @type {import('types
|
|
1824
|
+
/** @type {import('types').ErrorLoadInput} */ (load_input).status = status;
|
|
1825
|
+
/** @type {import('types').ErrorLoadInput} */ (load_input).error = error;
|
|
1831
1826
|
}
|
|
1832
1827
|
|
|
1833
1828
|
loaded = await module.load.call(null, load_input);
|
|
@@ -1872,11 +1867,11 @@ async function load_node({
|
|
|
1872
1867
|
|
|
1873
1868
|
/**
|
|
1874
1869
|
*
|
|
1875
|
-
* @param {import('types
|
|
1876
|
-
* @param {import('types
|
|
1877
|
-
* @param {import('types
|
|
1870
|
+
* @param {import('types').SSRPage} route
|
|
1871
|
+
* @param {import('types').RequestEvent} event
|
|
1872
|
+
* @param {import('types').SSROptions} options
|
|
1878
1873
|
* @param {boolean} prerender
|
|
1879
|
-
* @returns {Promise<import('types
|
|
1874
|
+
* @returns {Promise<import('types').ShadowData>}
|
|
1880
1875
|
*/
|
|
1881
1876
|
async function load_shadow_data(route, event, options, prerender) {
|
|
1882
1877
|
if (!route.shadow) return {};
|
|
@@ -1899,7 +1894,7 @@ async function load_shadow_data(route, event, options, prerender) {
|
|
|
1899
1894
|
};
|
|
1900
1895
|
}
|
|
1901
1896
|
|
|
1902
|
-
/** @type {import('types
|
|
1897
|
+
/** @type {import('types').ShadowData} */
|
|
1903
1898
|
const data = {
|
|
1904
1899
|
status: 200,
|
|
1905
1900
|
cookies: [],
|
|
@@ -1969,7 +1964,7 @@ async function load_shadow_data(route, event, options, prerender) {
|
|
|
1969
1964
|
|
|
1970
1965
|
/**
|
|
1971
1966
|
* @param {string[]} target
|
|
1972
|
-
* @param {Partial<import('types
|
|
1967
|
+
* @param {Partial<import('types').ResponseHeaders>} headers
|
|
1973
1968
|
*/
|
|
1974
1969
|
function add_cookies(target, headers) {
|
|
1975
1970
|
const cookies = headers['set-cookie'];
|
|
@@ -1983,7 +1978,7 @@ function add_cookies(target, headers) {
|
|
|
1983
1978
|
}
|
|
1984
1979
|
|
|
1985
1980
|
/**
|
|
1986
|
-
* @param {import('types
|
|
1981
|
+
* @param {import('types').ShadowEndpointOutput} result
|
|
1987
1982
|
*/
|
|
1988
1983
|
function validate_shadow_output(result) {
|
|
1989
1984
|
const { status = 200, body = {} } = result;
|
|
@@ -2008,19 +2003,19 @@ function validate_shadow_output(result) {
|
|
|
2008
2003
|
|
|
2009
2004
|
/**
|
|
2010
2005
|
* @typedef {import('./types.js').Loaded} Loaded
|
|
2011
|
-
* @typedef {import('types
|
|
2012
|
-
* @typedef {import('types
|
|
2006
|
+
* @typedef {import('types').SSROptions} SSROptions
|
|
2007
|
+
* @typedef {import('types').SSRState} SSRState
|
|
2013
2008
|
*/
|
|
2014
2009
|
|
|
2015
2010
|
/**
|
|
2016
2011
|
* @param {{
|
|
2017
|
-
* event: import('types
|
|
2012
|
+
* event: import('types').RequestEvent;
|
|
2018
2013
|
* options: SSROptions;
|
|
2019
2014
|
* state: SSRState;
|
|
2020
2015
|
* $session: any;
|
|
2021
2016
|
* status: number;
|
|
2022
2017
|
* error: Error;
|
|
2023
|
-
* resolve_opts: import('types
|
|
2018
|
+
* resolve_opts: import('types').RequiredResolveOptions;
|
|
2024
2019
|
* }} opts
|
|
2025
2020
|
*/
|
|
2026
2021
|
async function respond_with_error({
|
|
@@ -2102,19 +2097,19 @@ async function respond_with_error({
|
|
|
2102
2097
|
|
|
2103
2098
|
/**
|
|
2104
2099
|
* @typedef {import('./types.js').Loaded} Loaded
|
|
2105
|
-
* @typedef {import('types
|
|
2106
|
-
* @typedef {import('types
|
|
2107
|
-
* @typedef {import('types
|
|
2100
|
+
* @typedef {import('types').SSRNode} SSRNode
|
|
2101
|
+
* @typedef {import('types').SSROptions} SSROptions
|
|
2102
|
+
* @typedef {import('types').SSRState} SSRState
|
|
2108
2103
|
*/
|
|
2109
2104
|
|
|
2110
2105
|
/**
|
|
2111
2106
|
* @param {{
|
|
2112
|
-
* event: import('types
|
|
2107
|
+
* event: import('types').RequestEvent;
|
|
2113
2108
|
* options: SSROptions;
|
|
2114
2109
|
* state: SSRState;
|
|
2115
2110
|
* $session: any;
|
|
2116
|
-
* resolve_opts: import('types
|
|
2117
|
-
* route: import('types
|
|
2111
|
+
* resolve_opts: import('types').RequiredResolveOptions;
|
|
2112
|
+
* route: import('types').SSRPage;
|
|
2118
2113
|
* params: Record<string, string>;
|
|
2119
2114
|
* }} opts
|
|
2120
2115
|
* @returns {Promise<Response | undefined>}
|
|
@@ -2337,7 +2332,7 @@ async function respond$1(opts) {
|
|
|
2337
2332
|
}
|
|
2338
2333
|
|
|
2339
2334
|
/**
|
|
2340
|
-
* @param {import('types
|
|
2335
|
+
* @param {import('types').SSRComponent} leaf
|
|
2341
2336
|
* @param {SSROptions} options
|
|
2342
2337
|
*/
|
|
2343
2338
|
function get_page_config(leaf, options) {
|
|
@@ -2368,11 +2363,11 @@ function with_cookies(response, set_cookie_headers) {
|
|
|
2368
2363
|
}
|
|
2369
2364
|
|
|
2370
2365
|
/**
|
|
2371
|
-
* @param {import('types
|
|
2372
|
-
* @param {import('types
|
|
2373
|
-
* @param {import('types
|
|
2374
|
-
* @param {import('types
|
|
2375
|
-
* @param {import('types
|
|
2366
|
+
* @param {import('types').RequestEvent} event
|
|
2367
|
+
* @param {import('types').SSRPage} route
|
|
2368
|
+
* @param {import('types').SSROptions} options
|
|
2369
|
+
* @param {import('types').SSRState} state
|
|
2370
|
+
* @param {import('types').RequiredResolveOptions} resolve_opts
|
|
2376
2371
|
* @returns {Promise<Response | undefined>}
|
|
2377
2372
|
*/
|
|
2378
2373
|
async function render_page(event, route, options, state, resolve_opts) {
|
|
@@ -2478,7 +2473,7 @@ const DATA_SUFFIX = '/__data.json';
|
|
|
2478
2473
|
/** @param {{ html: string }} opts */
|
|
2479
2474
|
const default_transform = ({ html }) => html;
|
|
2480
2475
|
|
|
2481
|
-
/** @type {import('types
|
|
2476
|
+
/** @type {import('types').Respond} */
|
|
2482
2477
|
async function respond(request, options, state = {}) {
|
|
2483
2478
|
const url = new URL(request.url);
|
|
2484
2479
|
|
|
@@ -2518,7 +2513,7 @@ async function respond(request, options, state = {}) {
|
|
|
2518
2513
|
}
|
|
2519
2514
|
}
|
|
2520
2515
|
|
|
2521
|
-
/** @type {import('types
|
|
2516
|
+
/** @type {import('types').RequestEvent} */
|
|
2522
2517
|
const event = {
|
|
2523
2518
|
request,
|
|
2524
2519
|
url,
|
|
@@ -2561,7 +2556,7 @@ async function respond(request, options, state = {}) {
|
|
|
2561
2556
|
rawBody: body_getter
|
|
2562
2557
|
});
|
|
2563
2558
|
|
|
2564
|
-
/** @type {import('types
|
|
2559
|
+
/** @type {import('types').RequiredResolveOptions} */
|
|
2565
2560
|
let resolve_opts = {
|
|
2566
2561
|
ssr: true,
|
|
2567
2562
|
transformPage: default_transform
|
package/dist/chunks/amp_hook.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @type {import('amphtml-validator').Validator} */
|
|
2
2
|
const amp = await (await import('./index8.js').then(function (n) { return n.i; })).getInstance();
|
|
3
3
|
|
|
4
|
-
/** @type {import('types
|
|
4
|
+
/** @type {import('types').Handle} */
|
|
5
5
|
async function handle({ event, resolve }) {
|
|
6
6
|
const response = await resolve(event);
|
|
7
7
|
if (response.headers.get('content-type') !== 'text/html') {
|
package/dist/chunks/index.js
CHANGED
|
@@ -24,12 +24,12 @@ import 'node:url';
|
|
|
24
24
|
import 'stream';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* @param {import('types
|
|
27
|
+
* @param {import('types').ValidatedConfig} config
|
|
28
28
|
* @param {string} cwd
|
|
29
29
|
* @returns {Promise<import('vite').Plugin>}
|
|
30
30
|
*/
|
|
31
31
|
async function create_plugin(config, cwd) {
|
|
32
|
-
/** @type {import('types
|
|
32
|
+
/** @type {import('types').Handle} */
|
|
33
33
|
let amp;
|
|
34
34
|
|
|
35
35
|
if (config.kit.amp) {
|
|
@@ -39,7 +39,7 @@ async function create_plugin(config, cwd) {
|
|
|
39
39
|
|
|
40
40
|
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
|
|
41
41
|
|
|
42
|
-
/** @type {import('types
|
|
42
|
+
/** @type {import('types').Respond} */
|
|
43
43
|
const respond = (await import(`${runtime}/server/index.js`)).respond;
|
|
44
44
|
|
|
45
45
|
return {
|
|
@@ -48,7 +48,7 @@ async function create_plugin(config, cwd) {
|
|
|
48
48
|
configureServer(vite) {
|
|
49
49
|
__fetch_polyfill();
|
|
50
50
|
|
|
51
|
-
/** @type {import('types
|
|
51
|
+
/** @type {import('types').SSRManifest} */
|
|
52
52
|
let manifest;
|
|
53
53
|
|
|
54
54
|
function update_manifest() {
|
|
@@ -70,7 +70,7 @@ async function create_plugin(config, cwd) {
|
|
|
70
70
|
return async () => {
|
|
71
71
|
const url = id.startsWith('..') ? `/@fs${path__default.posix.resolve(id)}` : `/${id}`;
|
|
72
72
|
|
|
73
|
-
const module = /** @type {import('types
|
|
73
|
+
const module = /** @type {import('types').SSRComponent} */ (
|
|
74
74
|
await vite.ssrLoadModule(url)
|
|
75
75
|
);
|
|
76
76
|
const node = await vite.moduleGraph.getModuleByUrl(url);
|
|
@@ -183,14 +183,14 @@ async function create_plugin(config, cwd) {
|
|
|
183
183
|
|
|
184
184
|
if (!decoded.startsWith(config.kit.paths.base)) return not_found(res);
|
|
185
185
|
|
|
186
|
-
/** @type {Partial<import('types
|
|
186
|
+
/** @type {Partial<import('types').Hooks>} */
|
|
187
187
|
const user_hooks = resolve_entry(config.kit.files.hooks)
|
|
188
188
|
? await vite.ssrLoadModule(`/${config.kit.files.hooks}`)
|
|
189
189
|
: {};
|
|
190
190
|
|
|
191
191
|
const handle = user_hooks.handle || (({ event, resolve }) => resolve(event));
|
|
192
192
|
|
|
193
|
-
/** @type {import('types
|
|
193
|
+
/** @type {import('types').Hooks} */
|
|
194
194
|
const hooks = {
|
|
195
195
|
// @ts-expect-error this picks up types that belong to the tests
|
|
196
196
|
getSession: user_hooks.getSession || (() => ({})),
|
|
@@ -375,9 +375,9 @@ function find_deps(node, deps) {
|
|
|
375
375
|
* port: number,
|
|
376
376
|
* host?: string,
|
|
377
377
|
* https: boolean,
|
|
378
|
-
* config: import('types
|
|
378
|
+
* config: import('types').ValidatedConfig
|
|
379
379
|
* }} Options
|
|
380
|
-
* @typedef {import('types
|
|
380
|
+
* @typedef {import('types').SSRComponent} SSRComponent
|
|
381
381
|
*/
|
|
382
382
|
|
|
383
383
|
/** @param {Options} opts */
|
package/dist/chunks/index2.js
CHANGED
|
@@ -100,7 +100,7 @@ function write_if_changed(file, code) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
/** @typedef {import('types
|
|
103
|
+
/** @typedef {import('types').ManifestData} ManifestData */
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* @param {{
|
|
@@ -400,11 +400,11 @@ const specials = new Set(['__layout', '__layout.reset', '__error']);
|
|
|
400
400
|
|
|
401
401
|
/**
|
|
402
402
|
* @param {{
|
|
403
|
-
* config: import('types
|
|
403
|
+
* config: import('types').ValidatedConfig;
|
|
404
404
|
* fallback?: string;
|
|
405
405
|
* cwd?: string;
|
|
406
406
|
* }} opts
|
|
407
|
-
* @returns {import('types
|
|
407
|
+
* @returns {import('types').ManifestData}
|
|
408
408
|
*/
|
|
409
409
|
function create_manifest_data({
|
|
410
410
|
config,
|
|
@@ -423,7 +423,7 @@ function create_manifest_data({
|
|
|
423
423
|
/** @type {string[]} */
|
|
424
424
|
const components = [];
|
|
425
425
|
|
|
426
|
-
/** @type {import('types
|
|
426
|
+
/** @type {import('types').RouteData[]} */
|
|
427
427
|
const routes = [];
|
|
428
428
|
|
|
429
429
|
const default_layout = posixify(path__default.relative(cwd, `${fallback}/layout.svelte`));
|
|
@@ -806,10 +806,10 @@ function get_pattern(segments, add_trailing_slash) {
|
|
|
806
806
|
|
|
807
807
|
/**
|
|
808
808
|
* @param {{
|
|
809
|
-
* config: import('types
|
|
809
|
+
* config: import('types').ValidatedConfig;
|
|
810
810
|
* dir: string;
|
|
811
811
|
* path: string;
|
|
812
|
-
* files?: import('types
|
|
812
|
+
* files?: import('types').Asset[]
|
|
813
813
|
* }} args
|
|
814
814
|
*/
|
|
815
815
|
function list_files({ config, dir, path, files = [] }) {
|