@sveltejs/kit 1.0.0-next.4 → 1.0.0-next.401

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 (69) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +13 -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 +1845 -0
  8. package/assets/components/error.svelte +19 -3
  9. package/assets/env/dynamic/private.js +1 -0
  10. package/assets/env/dynamic/public.js +1 -0
  11. package/assets/env-private.js +9 -0
  12. package/assets/env-public.js +9 -0
  13. package/assets/env.js +8 -0
  14. package/assets/paths.js +13 -0
  15. package/assets/server/index.js +3579 -0
  16. package/dist/chunks/error.js +12 -0
  17. package/dist/chunks/filesystem.js +110 -0
  18. package/dist/chunks/index.js +675 -0
  19. package/dist/chunks/index2.js +15745 -0
  20. package/dist/chunks/index3.js +218 -0
  21. package/dist/chunks/multipart-parser.js +458 -0
  22. package/dist/chunks/sync.js +1368 -0
  23. package/dist/chunks/utils.js +66 -0
  24. package/dist/chunks/write_tsconfig.js +273 -0
  25. package/dist/cli.js +91 -101
  26. package/dist/hooks.js +28 -0
  27. package/dist/node/polyfills.js +17778 -0
  28. package/dist/node.js +348 -0
  29. package/dist/prerender.js +788 -0
  30. package/dist/vite.js +2520 -0
  31. package/package.json +98 -52
  32. package/svelte-kit.js +11 -0
  33. package/types/ambient.d.ts +375 -0
  34. package/types/index.d.ts +298 -0
  35. package/types/internal.d.ts +335 -0
  36. package/types/private.d.ts +235 -0
  37. package/CHANGELOG.md +0 -171
  38. package/assets/runtime/app/navigation.js +0 -47
  39. package/assets/runtime/app/navigation.js.map +0 -1
  40. package/assets/runtime/app/stores.js +0 -78
  41. package/assets/runtime/app/stores.js.map +0 -1
  42. package/assets/runtime/internal/singletons.js +0 -10
  43. package/assets/runtime/internal/singletons.js.map +0 -1
  44. package/assets/runtime/internal/start.js +0 -517
  45. package/assets/runtime/internal/start.js.map +0 -1
  46. package/dist/api.js +0 -40
  47. package/dist/api.js.map +0 -1
  48. package/dist/cli.js.map +0 -1
  49. package/dist/create_app.js +0 -550
  50. package/dist/create_app.js.map +0 -1
  51. package/dist/index.js +0 -8331
  52. package/dist/index.js.map +0 -1
  53. package/dist/index2.js +0 -509
  54. package/dist/index2.js.map +0 -1
  55. package/dist/index3.js +0 -63
  56. package/dist/index3.js.map +0 -1
  57. package/dist/index4.js +0 -466
  58. package/dist/index4.js.map +0 -1
  59. package/dist/index5.js +0 -276
  60. package/dist/index5.js.map +0 -1
  61. package/dist/package.js +0 -235
  62. package/dist/package.js.map +0 -1
  63. package/dist/renderer.js +0 -2397
  64. package/dist/renderer.js.map +0 -1
  65. package/dist/standard.js +0 -101
  66. package/dist/standard.js.map +0 -1
  67. package/dist/utils.js +0 -58
  68. package/dist/utils.js.map +0 -1
  69. package/svelte-kit +0 -3
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @param {unknown} err
3
+ * @return {Error}
4
+ */
5
+ function coalesce_to_error(err) {
6
+ return err instanceof Error ||
7
+ (err && /** @type {any} */ (err).name && /** @type {any} */ (err).message)
8
+ ? /** @type {Error} */ (err)
9
+ : new Error(JSON.stringify(err));
10
+ }
11
+
12
+ export { coalesce_to_error as c };
@@ -0,0 +1,110 @@
1
+ import fs__default from 'fs';
2
+ import path__default from 'path';
3
+
4
+ /** @param {string} dir */
5
+ function mkdirp(dir) {
6
+ try {
7
+ fs__default.mkdirSync(dir, { recursive: true });
8
+ } catch (/** @type {any} */ e) {
9
+ if (e.code === 'EEXIST') return;
10
+ throw e;
11
+ }
12
+ }
13
+
14
+ /** @param {string} path */
15
+ function rimraf(path) {
16
+ fs__default.rmSync(path, { force: true, recursive: true });
17
+ }
18
+
19
+ /**
20
+ * @param {string} source
21
+ * @param {string} target
22
+ * @param {{
23
+ * filter?: (basename: string) => boolean;
24
+ * replace?: Record<string, string>;
25
+ * }} opts
26
+ */
27
+ function copy(source, target, opts = {}) {
28
+ if (!fs__default.existsSync(source)) return [];
29
+
30
+ /** @type {string[]} */
31
+ const files = [];
32
+
33
+ const prefix = posixify(target) + '/';
34
+
35
+ const regex = opts.replace
36
+ ? new RegExp(`\\b(${Object.keys(opts.replace).join('|')})\\b`, 'g')
37
+ : null;
38
+
39
+ /**
40
+ * @param {string} from
41
+ * @param {string} to
42
+ */
43
+ function go(from, to) {
44
+ if (opts.filter && !opts.filter(path__default.basename(from))) return;
45
+
46
+ const stats = fs__default.statSync(from);
47
+
48
+ if (stats.isDirectory()) {
49
+ fs__default.readdirSync(from).forEach((file) => {
50
+ go(path__default.join(from, file), path__default.join(to, file));
51
+ });
52
+ } else {
53
+ mkdirp(path__default.dirname(to));
54
+
55
+ if (opts.replace) {
56
+ const data = fs__default.readFileSync(from, 'utf-8');
57
+ fs__default.writeFileSync(
58
+ to,
59
+ data.replace(
60
+ /** @type {RegExp} */ (regex),
61
+ (_match, key) => /** @type {Record<string, string>} */ (opts.replace)[key]
62
+ )
63
+ );
64
+ } else {
65
+ fs__default.copyFileSync(from, to);
66
+ }
67
+
68
+ files.push(to === target ? posixify(path__default.basename(to)) : posixify(to).replace(prefix, ''));
69
+ }
70
+ }
71
+
72
+ go(source, target);
73
+
74
+ return files;
75
+ }
76
+
77
+ /**
78
+ * Get a list of all files in a directory
79
+ * @param {string} cwd - the directory to walk
80
+ * @param {boolean} [dirs] - whether to include directories in the result
81
+ */
82
+ function walk(cwd, dirs = false) {
83
+ /** @type {string[]} */
84
+ const all_files = [];
85
+
86
+ /** @param {string} dir */
87
+ function walk_dir(dir) {
88
+ const files = fs__default.readdirSync(path__default.join(cwd, dir));
89
+
90
+ for (const file of files) {
91
+ const joined = path__default.join(dir, file);
92
+ const stats = fs__default.statSync(path__default.join(cwd, joined));
93
+ if (stats.isDirectory()) {
94
+ if (dirs) all_files.push(joined);
95
+ walk_dir(joined);
96
+ } else {
97
+ all_files.push(joined);
98
+ }
99
+ }
100
+ }
101
+
102
+ return walk_dir(''), all_files;
103
+ }
104
+
105
+ /** @param {string} str */
106
+ function posixify(str) {
107
+ return str.replace(/\\/g, '/');
108
+ }
109
+
110
+ export { copy as c, mkdirp as m, posixify as p, rimraf as r, walk as w };