@sveltejs/kit 1.0.0-next.472 → 1.0.0-next.475
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/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export function write_root(manifest_data, output) {
|
|
|
21
21
|
|
|
22
22
|
let l = max_depth;
|
|
23
23
|
|
|
24
|
-
let pyramid = `<svelte:component this={components[${l}]} data={data_${l}} />`;
|
|
24
|
+
let pyramid = `<svelte:component this={components[${l}]} data={data_${l}} {form} />`;
|
|
25
25
|
|
|
26
26
|
while (l--) {
|
|
27
27
|
pyramid = `
|
|
@@ -147,7 +147,7 @@ export function get_default_build_config({ config, input, ssr, outDir }) {
|
|
|
147
147
|
* @returns {string}
|
|
148
148
|
*/
|
|
149
149
|
export function assets_base(config) {
|
|
150
|
-
return config.paths.assets || config.paths.base || './';
|
|
150
|
+
return config.paths.assets + '/' || config.paths.base + '/' || './';
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
const method_names = new Set(['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH']);
|
|
@@ -35,6 +35,8 @@ export async function handle_action_json_request(event, options, server) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
check_named_default_separate(actions);
|
|
39
|
+
|
|
38
40
|
try {
|
|
39
41
|
const data = await call_action(event, actions);
|
|
40
42
|
|
|
@@ -114,6 +116,8 @@ export async function handle_action_request(event, server) {
|
|
|
114
116
|
};
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
check_named_default_separate(actions);
|
|
120
|
+
|
|
117
121
|
try {
|
|
118
122
|
const data = await call_action(event, actions);
|
|
119
123
|
|
|
@@ -141,6 +145,17 @@ export async function handle_action_request(event, server) {
|
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
|
|
148
|
+
/**
|
|
149
|
+
* @param {import('types').Actions} actions
|
|
150
|
+
*/
|
|
151
|
+
function check_named_default_separate(actions) {
|
|
152
|
+
if (actions.default && Object.keys(actions).length > 1) {
|
|
153
|
+
throw new Error(
|
|
154
|
+
`When using named actions, the default action cannot be used. See the docs for more info: https://kit.svelte.dev/docs/form-actions#named-actions`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
144
159
|
/**
|
|
145
160
|
* @param {import('types').RequestEvent} event
|
|
146
161
|
* @param {NonNullable<import('types').SSRNode['server']['actions']>} actions
|
|
@@ -153,6 +168,9 @@ export async function call_action(event, actions) {
|
|
|
153
168
|
for (const param of url.searchParams) {
|
|
154
169
|
if (param[0].startsWith('/')) {
|
|
155
170
|
name = param[0].slice(1);
|
|
171
|
+
if (name === 'default') {
|
|
172
|
+
throw new Error('Cannot use reserved action name "default"');
|
|
173
|
+
}
|
|
156
174
|
break;
|
|
157
175
|
}
|
|
158
176
|
}
|
package/types/ambient.d.ts
CHANGED
|
@@ -88,6 +88,15 @@ declare module '$app/environment' {
|
|
|
88
88
|
declare module '$app/forms' {
|
|
89
89
|
import type { ActionResult } from '@sveltejs/kit';
|
|
90
90
|
|
|
91
|
+
export type SubmitFunction<
|
|
92
|
+
Success extends Record<string, unknown> | undefined,
|
|
93
|
+
Invalid extends Record<string, unknown> | undefined
|
|
94
|
+
> = (input: {
|
|
95
|
+
data: FormData;
|
|
96
|
+
form: HTMLFormElement;
|
|
97
|
+
cancel: () => void;
|
|
98
|
+
}) => void | ((result: ActionResult<Success, Invalid>) => void);
|
|
99
|
+
|
|
91
100
|
/**
|
|
92
101
|
* This action enhances a `<form>` element that otherwise would work without JavaScript.
|
|
93
102
|
* @param form The form element
|
|
@@ -111,11 +120,7 @@ declare module '$app/forms' {
|
|
|
111
120
|
* - redirects in case of a redirect response
|
|
112
121
|
* - redirects to the nearest error page in case of an unexpected error
|
|
113
122
|
*/
|
|
114
|
-
submit?:
|
|
115
|
-
data: FormData;
|
|
116
|
-
form: HTMLFormElement;
|
|
117
|
-
cancel: () => void;
|
|
118
|
-
}) => void | ((result: ActionResult<Success, Invalid>) => void)
|
|
123
|
+
submit?: SubmitFunction<Success, Invalid>
|
|
119
124
|
): { destroy: () => void };
|
|
120
125
|
|
|
121
126
|
/**
|