@sveltejs/kit 1.0.0-next.34 → 1.0.0-next.342

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.
Files changed (73) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +16 -0
  3. package/assets/app/navigation.js +24 -0
  4. package/assets/app/paths.js +1 -0
  5. package/assets/app/stores.js +97 -0
  6. package/assets/client/singletons.js +13 -0
  7. package/assets/client/start.js +1782 -0
  8. package/assets/components/error.svelte +18 -2
  9. package/assets/env.js +8 -0
  10. package/assets/paths.js +13 -0
  11. package/assets/server/index.js +3367 -0
  12. package/dist/chunks/cert.js +28154 -0
  13. package/dist/chunks/constants.js +663 -0
  14. package/dist/chunks/filesystem.js +110 -0
  15. package/dist/chunks/index.js +549 -0
  16. package/dist/chunks/index2.js +1385 -0
  17. package/dist/chunks/index3.js +118 -0
  18. package/dist/chunks/index4.js +183 -0
  19. package/dist/chunks/index5.js +253 -0
  20. package/dist/chunks/index6.js +15749 -0
  21. package/dist/chunks/misc.js +78 -0
  22. package/dist/chunks/multipart-parser.js +450 -0
  23. package/dist/chunks/object.js +83 -0
  24. package/dist/chunks/sync.js +858 -0
  25. package/dist/chunks/write_tsconfig.js +160 -0
  26. package/dist/cli.js +1097 -64
  27. package/dist/hooks.js +28 -0
  28. package/dist/node/polyfills.js +6514 -0
  29. package/dist/node.js +301 -0
  30. package/package.json +80 -62
  31. package/svelte-kit.js +0 -1
  32. package/types/ambient.d.ts +307 -0
  33. package/types/index.d.ts +292 -0
  34. package/types/internal.d.ts +321 -0
  35. package/types/private.d.ts +235 -0
  36. package/CHANGELOG.md +0 -362
  37. package/assets/runtime/app/navigation.js +0 -23
  38. package/assets/runtime/app/navigation.js.map +0 -1
  39. package/assets/runtime/app/paths.js +0 -2
  40. package/assets/runtime/app/paths.js.map +0 -1
  41. package/assets/runtime/app/stores.js +0 -78
  42. package/assets/runtime/app/stores.js.map +0 -1
  43. package/assets/runtime/internal/singletons.js +0 -15
  44. package/assets/runtime/internal/singletons.js.map +0 -1
  45. package/assets/runtime/internal/start.js +0 -591
  46. package/assets/runtime/internal/start.js.map +0 -1
  47. package/assets/runtime/utils-85ebcc60.js +0 -18
  48. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  49. package/dist/api.js +0 -32
  50. package/dist/api.js.map +0 -1
  51. package/dist/cli.js.map +0 -1
  52. package/dist/create_app.js +0 -577
  53. package/dist/create_app.js.map +0 -1
  54. package/dist/index.js +0 -329
  55. package/dist/index.js.map +0 -1
  56. package/dist/index2.js +0 -14368
  57. package/dist/index2.js.map +0 -1
  58. package/dist/index3.js +0 -545
  59. package/dist/index3.js.map +0 -1
  60. package/dist/index4.js +0 -71
  61. package/dist/index4.js.map +0 -1
  62. package/dist/index5.js +0 -465
  63. package/dist/index5.js.map +0 -1
  64. package/dist/index6.js +0 -729
  65. package/dist/index6.js.map +0 -1
  66. package/dist/renderer.js +0 -2413
  67. package/dist/renderer.js.map +0 -1
  68. package/dist/standard.js +0 -100
  69. package/dist/standard.js.map +0 -1
  70. package/dist/utils.js +0 -57
  71. package/dist/utils.js.map +0 -1
  72. package/dist/vite.js +0 -317
  73. package/dist/vite.js.map +0 -1
package/dist/node.js ADDED
@@ -0,0 +1,301 @@
1
+ import { Readable } from 'stream';
2
+
3
+ var setCookie = {exports: {}};
4
+
5
+ var defaultParseOptions = {
6
+ decodeValues: true,
7
+ map: false,
8
+ silent: false,
9
+ };
10
+
11
+ function isNonEmptyString(str) {
12
+ return typeof str === "string" && !!str.trim();
13
+ }
14
+
15
+ function parseString(setCookieValue, options) {
16
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
17
+ var nameValue = parts.shift().split("=");
18
+ var name = nameValue.shift();
19
+ var value = nameValue.join("="); // everything after the first =, joined by a "=" if there was more than one part
20
+
21
+ options = options
22
+ ? Object.assign({}, defaultParseOptions, options)
23
+ : defaultParseOptions;
24
+
25
+ try {
26
+ value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
27
+ } catch (e) {
28
+ console.error(
29
+ "set-cookie-parser encountered an error while decoding a cookie with value '" +
30
+ value +
31
+ "'. Set options.decodeValues to false to disable this feature.",
32
+ e
33
+ );
34
+ }
35
+
36
+ var cookie = {
37
+ name: name, // grab everything before the first =
38
+ value: value,
39
+ };
40
+
41
+ parts.forEach(function (part) {
42
+ var sides = part.split("=");
43
+ var key = sides.shift().trimLeft().toLowerCase();
44
+ var value = sides.join("=");
45
+ if (key === "expires") {
46
+ cookie.expires = new Date(value);
47
+ } else if (key === "max-age") {
48
+ cookie.maxAge = parseInt(value, 10);
49
+ } else if (key === "secure") {
50
+ cookie.secure = true;
51
+ } else if (key === "httponly") {
52
+ cookie.httpOnly = true;
53
+ } else if (key === "samesite") {
54
+ cookie.sameSite = value;
55
+ } else {
56
+ cookie[key] = value;
57
+ }
58
+ });
59
+
60
+ return cookie;
61
+ }
62
+
63
+ function parse(input, options) {
64
+ options = options
65
+ ? Object.assign({}, defaultParseOptions, options)
66
+ : defaultParseOptions;
67
+
68
+ if (!input) {
69
+ if (!options.map) {
70
+ return [];
71
+ } else {
72
+ return {};
73
+ }
74
+ }
75
+
76
+ if (input.headers && input.headers["set-cookie"]) {
77
+ // fast-path for node.js (which automatically normalizes header names to lower-case
78
+ input = input.headers["set-cookie"];
79
+ } else if (input.headers) {
80
+ // slow-path for other environments - see #25
81
+ var sch =
82
+ input.headers[
83
+ Object.keys(input.headers).find(function (key) {
84
+ return key.toLowerCase() === "set-cookie";
85
+ })
86
+ ];
87
+ // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
88
+ if (!sch && input.headers.cookie && !options.silent) {
89
+ console.warn(
90
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
91
+ );
92
+ }
93
+ input = sch;
94
+ }
95
+ if (!Array.isArray(input)) {
96
+ input = [input];
97
+ }
98
+
99
+ options = options
100
+ ? Object.assign({}, defaultParseOptions, options)
101
+ : defaultParseOptions;
102
+
103
+ if (!options.map) {
104
+ return input.filter(isNonEmptyString).map(function (str) {
105
+ return parseString(str, options);
106
+ });
107
+ } else {
108
+ var cookies = {};
109
+ return input.filter(isNonEmptyString).reduce(function (cookies, str) {
110
+ var cookie = parseString(str, options);
111
+ cookies[cookie.name] = cookie;
112
+ return cookies;
113
+ }, cookies);
114
+ }
115
+ }
116
+
117
+ /*
118
+ Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
119
+ that are within a single set-cookie field-value, such as in the Expires portion.
120
+
121
+ This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
122
+ Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
123
+ React Native's fetch does this for *every* header, including set-cookie.
124
+
125
+ Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
126
+ Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
127
+ */
128
+ function splitCookiesString(cookiesString) {
129
+ if (Array.isArray(cookiesString)) {
130
+ return cookiesString;
131
+ }
132
+ if (typeof cookiesString !== "string") {
133
+ return [];
134
+ }
135
+
136
+ var cookiesStrings = [];
137
+ var pos = 0;
138
+ var start;
139
+ var ch;
140
+ var lastComma;
141
+ var nextStart;
142
+ var cookiesSeparatorFound;
143
+
144
+ function skipWhitespace() {
145
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
146
+ pos += 1;
147
+ }
148
+ return pos < cookiesString.length;
149
+ }
150
+
151
+ function notSpecialChar() {
152
+ ch = cookiesString.charAt(pos);
153
+
154
+ return ch !== "=" && ch !== ";" && ch !== ",";
155
+ }
156
+
157
+ while (pos < cookiesString.length) {
158
+ start = pos;
159
+ cookiesSeparatorFound = false;
160
+
161
+ while (skipWhitespace()) {
162
+ ch = cookiesString.charAt(pos);
163
+ if (ch === ",") {
164
+ // ',' is a cookie separator if we have later first '=', not ';' or ','
165
+ lastComma = pos;
166
+ pos += 1;
167
+
168
+ skipWhitespace();
169
+ nextStart = pos;
170
+
171
+ while (pos < cookiesString.length && notSpecialChar()) {
172
+ pos += 1;
173
+ }
174
+
175
+ // currently special character
176
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
177
+ // we found cookies separator
178
+ cookiesSeparatorFound = true;
179
+ // pos is inside the next cookie, so back up and return it.
180
+ pos = nextStart;
181
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
182
+ start = pos;
183
+ } else {
184
+ // in param ',' or param separator ';',
185
+ // we continue from that comma
186
+ pos = lastComma + 1;
187
+ }
188
+ } else {
189
+ pos += 1;
190
+ }
191
+ }
192
+
193
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
194
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
195
+ }
196
+ }
197
+
198
+ return cookiesStrings;
199
+ }
200
+
201
+ setCookie.exports = parse;
202
+ setCookie.exports.parse = parse;
203
+ setCookie.exports.parseString = parseString;
204
+ var splitCookiesString_1 = setCookie.exports.splitCookiesString = splitCookiesString;
205
+
206
+ /** @param {import('http').IncomingMessage} req */
207
+ function get_raw_body(req) {
208
+ return new Promise((fulfil, reject) => {
209
+ const h = req.headers;
210
+
211
+ if (!h['content-type']) {
212
+ return fulfil(null);
213
+ }
214
+
215
+ req.on('error', reject);
216
+
217
+ const length = Number(h['content-length']);
218
+
219
+ // https://github.com/jshttp/type-is/blob/c1f4388c71c8a01f79934e68f630ca4a15fffcd6/index.js#L81-L95
220
+ if (isNaN(length) && h['transfer-encoding'] == null) {
221
+ return fulfil(null);
222
+ }
223
+
224
+ let data = new Uint8Array(length || 0);
225
+
226
+ if (length > 0) {
227
+ let offset = 0;
228
+ req.on('data', (chunk) => {
229
+ const new_len = offset + Buffer.byteLength(chunk);
230
+
231
+ if (new_len > length) {
232
+ return reject({
233
+ status: 413,
234
+ reason: 'Exceeded "Content-Length" limit'
235
+ });
236
+ }
237
+
238
+ data.set(chunk, offset);
239
+ offset = new_len;
240
+ });
241
+ } else {
242
+ req.on('data', (chunk) => {
243
+ const new_data = new Uint8Array(data.length + chunk.length);
244
+ new_data.set(data, 0);
245
+ new_data.set(chunk, data.length);
246
+ data = new_data;
247
+ });
248
+ }
249
+
250
+ req.on('end', () => {
251
+ fulfil(data);
252
+ });
253
+ });
254
+ }
255
+
256
+ /** @type {import('@sveltejs/kit/node').getRequest} */
257
+ async function getRequest(base, req) {
258
+ let headers = /** @type {Record<string, string>} */ (req.headers);
259
+ if (req.httpVersionMajor === 2) {
260
+ // we need to strip out the HTTP/2 pseudo-headers because node-fetch's
261
+ // Request implementation doesn't like them
262
+ // TODO is this still true with Node 18
263
+ headers = Object.assign({}, headers);
264
+ delete headers[':method'];
265
+ delete headers[':path'];
266
+ delete headers[':authority'];
267
+ delete headers[':scheme'];
268
+ }
269
+ return new Request(base + req.url, {
270
+ method: req.method,
271
+ headers,
272
+ body: await get_raw_body(req) // TODO stream rather than buffer
273
+ });
274
+ }
275
+
276
+ /** @type {import('@sveltejs/kit/node').setResponse} */
277
+ async function setResponse(res, response) {
278
+ const headers = Object.fromEntries(response.headers);
279
+
280
+ if (response.headers.has('set-cookie')) {
281
+ const header = /** @type {string} */ (response.headers.get('set-cookie'));
282
+ const split = splitCookiesString_1(header);
283
+
284
+ // @ts-expect-error
285
+ headers['set-cookie'] = split;
286
+ }
287
+
288
+ res.writeHead(response.status, headers);
289
+
290
+ if (response.body instanceof Readable) {
291
+ response.body.pipe(res);
292
+ } else {
293
+ if (response.body) {
294
+ res.write(new Uint8Array(await response.arrayBuffer()));
295
+ }
296
+
297
+ res.end();
298
+ }
299
+ }
300
+
301
+ export { getRequest, setResponse };
package/package.json CHANGED
@@ -1,63 +1,81 @@
1
1
  {
2
- "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.34",
4
- "type": "module",
5
- "dependencies": {
6
- "cheap-watch": "^1.0.3",
7
- "http-proxy": "^1.18.1",
8
- "rollup": "^2.38.3",
9
- "rollup-plugin-css-chunks": "^2.0.2",
10
- "rollup-plugin-terser": "^7.0.2",
11
- "sade": "^1.7.4",
12
- "scorta": "^1.0.0",
13
- "snowpack": "^3.0.11",
14
- "source-map": "^0.7.3"
15
- },
16
- "devDependencies": {
17
- "@sveltejs/app-utils": "1.0.0-next.1",
18
- "@types/node": "^14.14.22",
19
- "@types/rimraf": "^3.0.0",
20
- "@types/sade": "^1.7.2",
21
- "amphtml-validator": "^1.0.34",
22
- "eslint": "^7.19.0",
23
- "estree-walker": "^2.0.2",
24
- "is-reference": "^1.2.1",
25
- "kleur": "^4.1.4",
26
- "magic-string": "^0.25.7",
27
- "meriyah": "^4.1.2",
28
- "node-fetch": "^2.6.1",
29
- "periscopic": "^3.0.0",
30
- "port-authority": "^1.1.2",
31
- "require-relative": "^0.8.7",
32
- "rimraf": "^3.0.2",
33
- "sirv": "^1.0.11",
34
- "source-map-support": "^0.5.19",
35
- "svelte": "^3.32.1",
36
- "tiny-glob": "^0.2.8"
37
- },
38
- "bin": {
39
- "svelte-kit": "svelte-kit.js"
40
- },
41
- "files": [
42
- "assets",
43
- "dist",
44
- "client"
45
- ],
46
- "scripts": {
47
- "dev": "rollup -cw",
48
- "build": "rollup -c",
49
- "lint": "eslint --ignore-path .gitignore \"**/*.{ts,mjs,js,svelte}\" && npm run check-format",
50
- "format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
51
- "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
52
- "prepublishOnly": "npm run build",
53
- "test": "uvu src \"(spec.mjs|test/index.mjs)\""
54
- },
55
- "exports": {
56
- "./api": {
57
- "import": "./dist/api.js"
58
- },
59
- "./renderer": {
60
- "import": "./dist/renderer.js"
61
- }
62
- }
63
- }
2
+ "name": "@sveltejs/kit",
3
+ "version": "1.0.0-next.342",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/sveltejs/kit",
7
+ "directory": "packages/kit"
8
+ },
9
+ "license": "MIT",
10
+ "homepage": "https://kit.svelte.dev",
11
+ "type": "module",
12
+ "dependencies": {
13
+ "@sveltejs/vite-plugin-svelte": "^1.0.0-next.44",
14
+ "chokidar": "^3.5.3",
15
+ "sade": "^1.7.4",
16
+ "vite": "^2.9.9"
17
+ },
18
+ "devDependencies": {
19
+ "@types/connect": "^3.4.35",
20
+ "@types/cookie": "^0.5.0",
21
+ "@types/marked": "^4.0.1",
22
+ "@types/mime": "^2.0.3",
23
+ "@types/sade": "^1.7.3",
24
+ "@types/set-cookie-parser": "^2.4.2",
25
+ "cookie": "^0.5.0",
26
+ "devalue": "^2.0.1",
27
+ "kleur": "^4.1.4",
28
+ "locate-character": "^2.0.5",
29
+ "mime": "^3.0.0",
30
+ "node-fetch": "^3.1.0",
31
+ "selfsigned": "^2.0.0",
32
+ "set-cookie-parser": "^2.4.8",
33
+ "svelte": "^3.48.0"
34
+ },
35
+ "peerDependencies": {
36
+ "svelte": "^3.44.0"
37
+ },
38
+ "bin": {
39
+ "svelte-kit": "svelte-kit.js"
40
+ },
41
+ "files": [
42
+ "assets",
43
+ "dist",
44
+ "types",
45
+ "svelte-kit.js"
46
+ ],
47
+ "exports": {
48
+ "./package.json": "./package.json",
49
+ ".": {
50
+ "types": "./types/index.d.ts"
51
+ },
52
+ "./node": {
53
+ "import": "./dist/node.js"
54
+ },
55
+ "./node/polyfills": {
56
+ "import": "./dist/node/polyfills.js"
57
+ },
58
+ "./hooks": {
59
+ "import": "./dist/hooks.js"
60
+ }
61
+ },
62
+ "types": "types/index.d.ts",
63
+ "engines": {
64
+ "node": ">=16"
65
+ },
66
+ "scripts": {
67
+ "build": "rollup -c && node scripts/cp.js src/runtime/components assets/components && npm run types",
68
+ "dev": "rollup -cw",
69
+ "lint": "eslint --ignore-path .gitignore --ignore-pattern \"src/packaging/test/**\" \"{src,test}/**/*.{ts,mjs,js,svelte}\" && npm run check-format",
70
+ "check": "tsc",
71
+ "check:all": "tsc && pnpm -r --filter=\"./**\" check",
72
+ "format": "npm run check-format -- --write",
73
+ "check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
74
+ "test": "npm run test:unit && npm run test:typings && npm run test:packaging && npm run test:integration",
75
+ "test:integration": "pnpm run -r --workspace-concurrency 1 --filter=\"./test/**\" test",
76
+ "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
77
+ "test:typings": "tsc --project test/typings",
78
+ "test:packaging": "uvu src/packaging \"(spec\\.js|test[\\\\/]index\\.js)\"",
79
+ "types": "node scripts/extract-types.js"
80
+ }
81
+ }
package/svelte-kit.js CHANGED
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import 'source-map-support/register.js';
3
2
  import './dist/cli.js';