@sveltejs/kit 1.0.0-next.33 → 1.0.0-next.330

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 (75) hide show
  1. package/README.md +12 -9
  2. package/assets/app/env.js +20 -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 +1689 -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 +3408 -0
  12. package/dist/chunks/amp_hook.js +56 -0
  13. package/dist/chunks/cert.js +28154 -0
  14. package/dist/chunks/constants.js +663 -0
  15. package/dist/chunks/filesystem.js +110 -0
  16. package/dist/chunks/index.js +514 -0
  17. package/dist/chunks/index2.js +1384 -0
  18. package/dist/chunks/index3.js +118 -0
  19. package/dist/chunks/index4.js +182 -0
  20. package/dist/chunks/index5.js +252 -0
  21. package/dist/chunks/index6.js +15741 -0
  22. package/dist/chunks/index7.js +4207 -0
  23. package/dist/chunks/misc.js +78 -0
  24. package/dist/chunks/multipart-parser.js +449 -0
  25. package/dist/chunks/object.js +83 -0
  26. package/dist/chunks/sync.js +848 -0
  27. package/dist/chunks/write_tsconfig.js +150 -0
  28. package/dist/cli.js +1025 -65
  29. package/dist/hooks.js +28 -0
  30. package/dist/install-fetch.js +6518 -0
  31. package/dist/node.js +94 -0
  32. package/package.json +96 -62
  33. package/svelte-kit.js +0 -1
  34. package/types/ambient.d.ts +298 -0
  35. package/types/index.d.ts +279 -0
  36. package/types/internal.d.ts +320 -0
  37. package/types/private.d.ts +246 -0
  38. package/CHANGELOG.md +0 -356
  39. package/assets/runtime/app/navigation.js +0 -23
  40. package/assets/runtime/app/navigation.js.map +0 -1
  41. package/assets/runtime/app/paths.js +0 -2
  42. package/assets/runtime/app/paths.js.map +0 -1
  43. package/assets/runtime/app/stores.js +0 -78
  44. package/assets/runtime/app/stores.js.map +0 -1
  45. package/assets/runtime/internal/singletons.js +0 -15
  46. package/assets/runtime/internal/singletons.js.map +0 -1
  47. package/assets/runtime/internal/start.js +0 -591
  48. package/assets/runtime/internal/start.js.map +0 -1
  49. package/assets/runtime/utils-85ebcc60.js +0 -18
  50. package/assets/runtime/utils-85ebcc60.js.map +0 -1
  51. package/dist/api.js +0 -32
  52. package/dist/api.js.map +0 -1
  53. package/dist/cli.js.map +0 -1
  54. package/dist/create_app.js +0 -577
  55. package/dist/create_app.js.map +0 -1
  56. package/dist/index.js +0 -329
  57. package/dist/index.js.map +0 -1
  58. package/dist/index2.js +0 -14368
  59. package/dist/index2.js.map +0 -1
  60. package/dist/index3.js +0 -544
  61. package/dist/index3.js.map +0 -1
  62. package/dist/index4.js +0 -71
  63. package/dist/index4.js.map +0 -1
  64. package/dist/index5.js +0 -465
  65. package/dist/index5.js.map +0 -1
  66. package/dist/index6.js +0 -727
  67. package/dist/index6.js.map +0 -1
  68. package/dist/renderer.js +0 -2413
  69. package/dist/renderer.js.map +0 -1
  70. package/dist/standard.js +0 -100
  71. package/dist/standard.js.map +0 -1
  72. package/dist/utils.js +0 -57
  73. package/dist/utils.js.map +0 -1
  74. package/dist/vite.js +0 -317
  75. package/dist/vite.js.map +0 -1
@@ -0,0 +1,150 @@
1
+ import fs__default from 'fs';
2
+ import path__default from 'path';
3
+ import { $ } from '../cli.js';
4
+ import { m as mkdirp, p as posixify } from './filesystem.js';
5
+
6
+ /** @type {Map<string, string>} */
7
+ const previous_contents = new Map();
8
+
9
+ /**
10
+ * @param {string} file
11
+ * @param {string} code
12
+ */
13
+ function write_if_changed(file, code) {
14
+ if (code !== previous_contents.get(file)) {
15
+ previous_contents.set(file, code);
16
+ mkdirp(path__default.dirname(file));
17
+ fs__default.writeFileSync(file, code);
18
+ }
19
+ }
20
+
21
+ /** @param {string} str */
22
+ function trim(str) {
23
+ const indentation = /** @type {RegExpExecArray} */ (/\n?(\s*)/.exec(str))[1];
24
+ const pattern = new RegExp(`^${indentation}`, 'gm');
25
+ return str.replace(pattern, '').trim();
26
+ }
27
+
28
+ /** @param {string} file */
29
+ const exists = (file) => fs__default.existsSync(file) && file;
30
+
31
+ /** @param {import('types').ValidatedConfig} config */
32
+ function write_tsconfig(config) {
33
+ const out = path__default.join(config.kit.outDir, 'tsconfig.json');
34
+ const user_file = exists('tsconfig.json') || exists('jsconfig.json');
35
+
36
+ if (user_file) validate(config, out, user_file);
37
+
38
+ /** @param {string} file */
39
+ const project_relative = (file) => posixify(path__default.relative('.', file));
40
+
41
+ /** @param {string} file */
42
+ const config_relative = (file) => posixify(path__default.relative(config.kit.outDir, file));
43
+
44
+ const dirs = new Set([
45
+ project_relative(path__default.dirname(config.kit.files.routes)),
46
+ project_relative(path__default.dirname(config.kit.files.lib))
47
+ ]);
48
+
49
+ /** @type {string[]} */
50
+ const include = [];
51
+ dirs.forEach((dir) => {
52
+ include.push(config_relative(`${dir}/**/*.js`));
53
+ include.push(config_relative(`${dir}/**/*.ts`));
54
+ include.push(config_relative(`${dir}/**/*.svelte`));
55
+ });
56
+
57
+ write_if_changed(
58
+ out,
59
+ JSON.stringify(
60
+ {
61
+ compilerOptions: {
62
+ // generated options
63
+ baseUrl: config_relative('.'),
64
+ paths: fs__default.existsSync(config.kit.files.lib)
65
+ ? {
66
+ $lib: [project_relative(config.kit.files.lib)],
67
+ '$lib/*': [project_relative(config.kit.files.lib + '/*')]
68
+ }
69
+ : {},
70
+ rootDirs: [config_relative('.'), './types'],
71
+
72
+ // essential options
73
+ // svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
74
+ // to enforce using \`import type\` instead of \`import\` for Types.
75
+ importsNotUsedAsValues: 'error',
76
+ // Vite compiles modules one at a time
77
+ isolatedModules: true,
78
+ // TypeScript doesn't know about import usages in the template because it only sees the
79
+ // script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher.
80
+ preserveValueImports: true,
81
+
82
+ // This is required for svelte-kit package to work as expected
83
+ // Can be overwritten
84
+ lib: ['esnext', 'DOM'],
85
+ moduleResolution: 'node',
86
+ module: 'esnext',
87
+ target: 'esnext'
88
+ },
89
+ include,
90
+ exclude: [config_relative('node_modules/**'), './**']
91
+ },
92
+ null,
93
+ '\t'
94
+ )
95
+ );
96
+ }
97
+
98
+ /**
99
+ * @param {import('types').ValidatedConfig} config
100
+ * @param {string} out
101
+ * @param {string} user_file
102
+ */
103
+ function validate(config, out, user_file) {
104
+ // we have to eval the file, since it's not parseable as JSON (contains comments)
105
+ const user_tsconfig_json = fs__default.readFileSync(user_file, 'utf-8');
106
+ const user_tsconfig = (0, eval)(`(${user_tsconfig_json})`);
107
+
108
+ // we need to check that the user's tsconfig extends the framework config
109
+ const extend = user_tsconfig.extends;
110
+ const extends_framework_config = extend && path__default.resolve('.', extend) === out;
111
+
112
+ if (extends_framework_config) {
113
+ const { paths: user_paths } = user_tsconfig.compilerOptions || {};
114
+
115
+ if (user_paths && fs__default.existsSync(config.kit.files.lib)) {
116
+ /** @type {string[]} */
117
+ const lib = user_paths['$lib'] || [];
118
+ /** @type {string[]} */
119
+ const lib_ = user_paths['$lib/*'] || [];
120
+
121
+ const missing_lib_paths =
122
+ !lib.some((relative) => path__default.resolve('.', relative) === config.kit.files.lib) ||
123
+ !lib_.some(
124
+ (relative) => path__default.resolve('.', relative) === path__default.join(config.kit.files.lib, '/*')
125
+ );
126
+
127
+ if (missing_lib_paths) {
128
+ console.warn(
129
+ $
130
+ .bold()
131
+ .yellow(`Your compilerOptions.paths in ${user_file} should include the following:`)
132
+ );
133
+ const relative = posixify(path__default.relative('.', config.kit.files.lib));
134
+ console.warn(`{\n "$lib":["${relative}"],\n "$lib/*":["${relative}/*"]\n}`);
135
+ }
136
+ }
137
+ } else {
138
+ let relative = posixify(path__default.relative('.', out));
139
+ if (!relative.startsWith('./')) relative = './' + relative;
140
+
141
+ console.warn(
142
+ $
143
+ .bold()
144
+ .yellow(`Your ${user_file} should extend the configuration generated by SvelteKit:`)
145
+ );
146
+ console.warn(`{\n "extends": "${relative}"\n}`);
147
+ }
148
+ }
149
+
150
+ export { write_tsconfig as a, trim as t, write_if_changed as w };