@sveltejs/kit 1.0.0-next.52 → 1.0.0-next.520

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 (128) hide show
  1. package/README.md +6 -3
  2. package/package.json +93 -67
  3. package/postinstall.js +47 -0
  4. package/scripts/special-types/$env+dynamic+private.md +10 -0
  5. package/scripts/special-types/$env+dynamic+public.md +8 -0
  6. package/scripts/special-types/$env+static+private.md +19 -0
  7. package/scripts/special-types/$env+static+public.md +7 -0
  8. package/scripts/special-types/$lib.md +5 -0
  9. package/src/cli.js +108 -0
  10. package/src/constants.js +7 -0
  11. package/src/core/adapt/builder.js +215 -0
  12. package/src/core/adapt/index.js +31 -0
  13. package/src/core/config/default-error.html +56 -0
  14. package/src/core/config/index.js +110 -0
  15. package/src/core/config/options.js +504 -0
  16. package/src/core/config/types.d.ts +1 -0
  17. package/src/core/env.js +121 -0
  18. package/src/core/generate_manifest/index.js +94 -0
  19. package/src/core/prerender/crawl.js +198 -0
  20. package/src/core/prerender/entities.js +2252 -0
  21. package/src/core/prerender/prerender.js +458 -0
  22. package/src/core/prerender/queue.js +80 -0
  23. package/src/core/sync/create_manifest_data/conflict.js +0 -0
  24. package/src/core/sync/create_manifest_data/index.js +470 -0
  25. package/src/core/sync/create_manifest_data/sort.js +163 -0
  26. package/src/core/sync/create_manifest_data/types.d.ts +37 -0
  27. package/src/core/sync/sync.js +78 -0
  28. package/src/core/sync/utils.js +33 -0
  29. package/src/core/sync/write_ambient.js +53 -0
  30. package/src/core/sync/write_client_manifest.js +106 -0
  31. package/src/core/sync/write_matchers.js +25 -0
  32. package/src/core/sync/write_root.js +91 -0
  33. package/src/core/sync/write_tsconfig.js +195 -0
  34. package/src/core/sync/write_types/index.js +783 -0
  35. package/src/core/utils.js +70 -0
  36. package/src/exports/hooks/index.js +1 -0
  37. package/src/exports/hooks/sequence.js +44 -0
  38. package/src/exports/index.js +45 -0
  39. package/src/exports/node/index.js +161 -0
  40. package/src/exports/node/polyfills.js +28 -0
  41. package/src/exports/vite/build/build_server.js +378 -0
  42. package/src/exports/vite/build/build_service_worker.js +91 -0
  43. package/src/exports/vite/build/utils.js +181 -0
  44. package/src/exports/vite/dev/index.js +581 -0
  45. package/src/exports/vite/graph_analysis/index.js +277 -0
  46. package/src/exports/vite/graph_analysis/types.d.ts +5 -0
  47. package/src/exports/vite/graph_analysis/utils.js +30 -0
  48. package/src/exports/vite/index.js +603 -0
  49. package/src/exports/vite/preview/index.js +189 -0
  50. package/src/exports/vite/types.d.ts +3 -0
  51. package/src/exports/vite/utils.js +157 -0
  52. package/src/runtime/app/env.js +1 -0
  53. package/src/runtime/app/environment.js +11 -0
  54. package/src/runtime/app/forms.js +123 -0
  55. package/src/runtime/app/navigation.js +23 -0
  56. package/src/runtime/app/paths.js +1 -0
  57. package/src/runtime/app/stores.js +102 -0
  58. package/src/runtime/client/ambient.d.ts +30 -0
  59. package/src/runtime/client/client.js +1595 -0
  60. package/src/runtime/client/fetcher.js +107 -0
  61. package/src/runtime/client/parse.js +60 -0
  62. package/src/runtime/client/singletons.js +21 -0
  63. package/src/runtime/client/start.js +37 -0
  64. package/src/runtime/client/types.d.ts +84 -0
  65. package/src/runtime/client/utils.js +159 -0
  66. package/src/runtime/components/error.svelte +16 -0
  67. package/{assets → src/runtime}/components/layout.svelte +0 -0
  68. package/src/runtime/control.js +98 -0
  69. package/src/runtime/env/dynamic/private.js +1 -0
  70. package/src/runtime/env/dynamic/public.js +1 -0
  71. package/src/runtime/env-private.js +6 -0
  72. package/src/runtime/env-public.js +6 -0
  73. package/src/runtime/env.js +6 -0
  74. package/src/runtime/hash.js +20 -0
  75. package/src/runtime/paths.js +11 -0
  76. package/src/runtime/server/cookie.js +166 -0
  77. package/src/runtime/server/data/index.js +131 -0
  78. package/src/runtime/server/endpoint.js +92 -0
  79. package/src/runtime/server/fetch.js +174 -0
  80. package/src/runtime/server/index.js +355 -0
  81. package/src/runtime/server/page/actions.js +256 -0
  82. package/src/runtime/server/page/crypto.js +239 -0
  83. package/src/runtime/server/page/csp.js +250 -0
  84. package/src/runtime/server/page/index.js +304 -0
  85. package/src/runtime/server/page/load_data.js +215 -0
  86. package/src/runtime/server/page/render.js +346 -0
  87. package/src/runtime/server/page/respond_with_error.js +102 -0
  88. package/src/runtime/server/page/serialize_data.js +87 -0
  89. package/src/runtime/server/page/types.d.ts +35 -0
  90. package/src/runtime/server/utils.js +181 -0
  91. package/src/utils/array.js +9 -0
  92. package/src/utils/error.js +22 -0
  93. package/src/utils/escape.js +46 -0
  94. package/src/utils/filesystem.js +142 -0
  95. package/src/utils/functions.js +16 -0
  96. package/src/utils/http.js +72 -0
  97. package/src/utils/misc.js +1 -0
  98. package/src/utils/promises.js +17 -0
  99. package/src/utils/routing.js +130 -0
  100. package/src/utils/unit_test.js +11 -0
  101. package/src/utils/url.js +144 -0
  102. package/svelte-kit.js +1 -1
  103. package/types/ambient.d.ts +431 -0
  104. package/types/index.d.ts +477 -0
  105. package/types/internal.d.ts +380 -0
  106. package/types/private.d.ts +224 -0
  107. package/CHANGELOG.md +0 -496
  108. package/assets/components/error.svelte +0 -13
  109. package/assets/runtime/app/env.js +0 -5
  110. package/assets/runtime/app/navigation.js +0 -44
  111. package/assets/runtime/app/paths.js +0 -1
  112. package/assets/runtime/app/stores.js +0 -93
  113. package/assets/runtime/chunks/utils.js +0 -22
  114. package/assets/runtime/internal/singletons.js +0 -23
  115. package/assets/runtime/internal/start.js +0 -776
  116. package/assets/runtime/paths.js +0 -12
  117. package/dist/chunks/index.js +0 -3537
  118. package/dist/chunks/index2.js +0 -587
  119. package/dist/chunks/index3.js +0 -246
  120. package/dist/chunks/index4.js +0 -568
  121. package/dist/chunks/index5.js +0 -763
  122. package/dist/chunks/index6.js +0 -323
  123. package/dist/chunks/standard.js +0 -99
  124. package/dist/chunks/utils.js +0 -83
  125. package/dist/cli.js +0 -555
  126. package/dist/ssr.js +0 -2604
  127. package/types.d.ts +0 -73
  128. package/types.internal.d.ts +0 -222
package/types.d.ts DELETED
@@ -1,73 +0,0 @@
1
- import { Headers, LoadInput, LoadOutput, Logger } from './types.internal';
2
-
3
- export type Config = {
4
- compilerOptions?: any;
5
- extensions?: string[];
6
- kit?: {
7
- adapter?: string | [string, any];
8
- amp?: boolean;
9
- appDir?: string;
10
- files?: {
11
- assets?: string;
12
- lib?: string;
13
- routes?: string;
14
- serviceWorker?: string;
15
- setup?: string;
16
- template?: string;
17
- };
18
- host?: string;
19
- hostHeader?: string;
20
- paths?: {
21
- base?: string;
22
- assets?: string;
23
- };
24
- prerender?: {
25
- crawl?: boolean;
26
- enabled?: boolean;
27
- force?: boolean;
28
- pages?: string[];
29
- };
30
- target?: string;
31
- vite?: {} | (() => {});
32
- };
33
- preprocess?: any;
34
- };
35
-
36
- type Builder = {
37
- copy_client_files: (dest: string) => void;
38
- copy_server_files: (dest: string) => void;
39
- copy_static_files: (dest: string) => void;
40
- prerender: ({ force, dest }: { force?: boolean; dest: string }) => Promise<void>;
41
- log: Logger;
42
- };
43
-
44
- export type Adapter = {
45
- adapt: (builder: Builder) => Promise<void>;
46
- };
47
-
48
- interface ReadOnlyFormData extends Iterator<[string, string]> {
49
- get: (key: string) => string;
50
- getAll: (key: string) => string[];
51
- has: (key: string) => boolean;
52
- entries: () => Iterator<[string, string]>;
53
- keys: () => Iterator<string>;
54
- values: () => Iterator<string>;
55
- }
56
-
57
- export type RequestHandler = (
58
- request?: {
59
- host: string;
60
- headers: Headers;
61
- path: string;
62
- params: Record<string, string>;
63
- query: URLSearchParams;
64
- body: string | Buffer | ReadOnlyFormData;
65
- },
66
- context?: any
67
- ) => {
68
- status?: number;
69
- headers?: Record<string, string>;
70
- body?: any;
71
- };
72
-
73
- export type Load = (input: LoadInput) => LoadOutput | Promise<LoadOutput>;
@@ -1,222 +0,0 @@
1
- import { Load } from './types';
2
-
3
- declare global {
4
- interface ImportMeta {
5
- env: Record<string, string>;
6
- }
7
- }
8
-
9
- export type Logger = {
10
- (msg: string): void;
11
- success: (msg: string) => void;
12
- error: (msg: string) => void;
13
- warn: (msg: string) => void;
14
- minor: (msg: string) => void;
15
- info: (msg: string) => void;
16
- };
17
-
18
- export type ValidatedConfig = {
19
- compilerOptions: any;
20
- extensions: string[];
21
- kit: {
22
- adapter: [string, any];
23
- amp: boolean;
24
- appDir: string;
25
- files: {
26
- assets: string;
27
- lib: string;
28
- routes: string;
29
- serviceWorker: string;
30
- setup: string;
31
- template: string;
32
- };
33
- host: string;
34
- hostHeader: string;
35
- paths: {
36
- base: string;
37
- assets: string;
38
- };
39
- prerender: {
40
- crawl: boolean;
41
- enabled: boolean;
42
- force: boolean;
43
- pages: string[];
44
- };
45
- target: string;
46
- vite: () => {};
47
- };
48
- preprocess: any;
49
- };
50
-
51
- export type App = {
52
- init: ({
53
- paths
54
- }: {
55
- paths: {
56
- base: string;
57
- assets: string;
58
- };
59
- }) => void;
60
- render: (request: Request, options: SSRRenderOptions) => Response;
61
- };
62
-
63
- // TODO we want to differentiate between request headers, which
64
- // always follow this type, and response headers, in which
65
- // 'set-cookie' is a `string[]` (or at least `string | string[]`)
66
- // but this can't happen until TypeScript 4.3
67
- export type Headers = Record<string, string>;
68
-
69
- export type Request = {
70
- host: string;
71
- method: string;
72
- headers: Headers;
73
- path: string;
74
- body: any;
75
- query: URLSearchParams;
76
- };
77
-
78
- export type Response = {
79
- status: number;
80
- headers: Headers;
81
- body?: any;
82
- dependencies?: Record<string, Response>;
83
- };
84
-
85
- export type Page = {
86
- host: string;
87
- path: string;
88
- params: Record<string, string>;
89
- query: URLSearchParams;
90
- };
91
-
92
- export type LoadInput = {
93
- page: Page;
94
- fetch: (info: RequestInfo, init?: RequestInit) => Promise<Response>;
95
- session: any;
96
- context: Record<string, any>;
97
- };
98
-
99
- export type LoadOutput = {
100
- status?: number;
101
- error?: Error;
102
- redirect?: string;
103
- props?: Record<string, any>;
104
- context?: Record<string, any>;
105
- maxage?: number;
106
- };
107
-
108
- export type SSRComponent = {
109
- prerender?: boolean;
110
- preload?: any; // TODO remove for 1.0
111
- load: Load;
112
- default: {
113
- render: (
114
- props: Record<string, any>
115
- ) => {
116
- html: string;
117
- head: string;
118
- css: string;
119
- };
120
- };
121
- };
122
-
123
- export type SSRComponentLoader = () => Promise<SSRComponent>;
124
-
125
- export type CSRComponent = any; // TODO
126
-
127
- export type CSRComponentLoader = () => Promise<CSRComponent>;
128
-
129
- export type SSRPagePart = {
130
- id: string;
131
- load: SSRComponentLoader;
132
- };
133
-
134
- export type SSRPage = {
135
- pattern: RegExp;
136
- params: (match: RegExpExecArray) => Record<string, string>;
137
- parts: SSRPagePart[];
138
- style: string;
139
- css: string[];
140
- js: string[];
141
- };
142
-
143
- export type CSRPage = {
144
- pattern: RegExp;
145
- params: (match: RegExpExecArray) => Record<string, string>;
146
- parts: CSRComponentLoader[];
147
- };
148
-
149
- export type Endpoint = {
150
- pattern: RegExp;
151
- params: (match: RegExpExecArray) => Record<string, string>;
152
- load: () => Promise<any>; // TODO
153
- };
154
-
155
- export type SSRManifest = {
156
- assets: Asset[];
157
- layout: SSRComponentLoader;
158
- error: SSRComponentLoader;
159
- pages: SSRPage[];
160
- endpoints: Endpoint[];
161
- };
162
-
163
- // TODO separate out runtime options from the ones fixed in dev/build
164
- export type SSRRenderOptions = {
165
- paths?: {
166
- base: string;
167
- assets: string;
168
- };
169
- local?: boolean;
170
- template?: ({ head, body }: { head: string; body: string }) => string;
171
- manifest?: SSRManifest;
172
- target?: string;
173
- entry?: string;
174
- root?: SSRComponent['default'];
175
- setup?: {
176
- prepare?: (incoming: {
177
- headers: Headers;
178
- }) => {
179
- context?: any;
180
- headers?: Headers;
181
- };
182
- getSession?: ({ context }: { context: any }) => any;
183
- };
184
- dev?: boolean;
185
- amp?: boolean;
186
- only_prerender?: boolean;
187
- app_dir?: string;
188
- host?: string;
189
- host_header?: string;
190
- get_component_path?: (id: string) => string;
191
- get_stack?: (error: Error) => string;
192
- get_static_file?: (file: string) => Buffer;
193
- get_amp_css?: (dep: string) => string;
194
- fetched?: string;
195
- };
196
-
197
- export type Asset = {
198
- file: string;
199
- size: number;
200
- type: string;
201
- };
202
-
203
- export type PageData = {
204
- pattern: RegExp;
205
- params: string[];
206
- parts: any[]; // TODO
207
- };
208
-
209
- export type EndpointData = {
210
- pattern: RegExp;
211
- params: string[];
212
- file: string;
213
- };
214
-
215
- export type ManifestData = {
216
- assets: Asset[];
217
- layout: string;
218
- error: string;
219
- components: string[];
220
- pages: PageData[];
221
- endpoints: EndpointData[];
222
- };