@sveltejs/kit 3.0.0-next.16 → 3.0.0-next.18
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 +1 -1
- package/src/core/sync/write_types/index.js +1 -0
- package/src/exports/hooks/sequence.js +2 -1
- package/src/exports/internal/server/index.js +2 -0
- package/src/exports/internal/server/telemetry.js +95 -0
- package/src/exports/public.d.ts +33 -12
- package/src/exports/vite/index.js +3 -2
- package/src/runtime/app/forms.js +51 -39
- package/src/runtime/app/navigation.js +1 -0
- package/src/runtime/client/client.js +203 -49
- package/src/runtime/client/constants.js +1 -0
- package/src/runtime/client/snapshots.js +147 -0
- package/src/runtime/props.svelte.js +1 -0
- package/src/runtime/server/csrf.js +1 -1
- package/src/runtime/server/index.js +3 -0
- package/src/runtime/server/page/actions.js +34 -6
- package/src/runtime/server/page/load_data.js +1 -2
- package/src/runtime/server/remote-functions.js +7 -4
- package/src/runtime/server/respond.js +6 -3
- package/src/runtime/server/state.js +0 -4
- package/src/types/internal.d.ts +0 -3
- package/src/utils/import.js +1 -0
- package/src/version.js +1 -1
- package/types/index.d.ts +58 -20
- package/types/index.d.ts.map +4 -1
- package/src/runtime/telemetry/otel.js +0 -21
- package/src/runtime/telemetry/record_span.js +0 -65
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
import { DEV } from 'esm-env';
|
|
4
4
|
import { json } from '@sveltejs/kit';
|
|
5
5
|
import { HttpError, Redirect, ActionFailure, SvelteKitError } from '@sveltejs/kit/internal';
|
|
6
|
-
import { with_request_store, merge_tracing } from '@sveltejs/kit/internal/server';
|
|
6
|
+
import { with_request_store, merge_tracing, record_span } from '@sveltejs/kit/internal/server';
|
|
7
7
|
import { normalize_error } from '../../../utils/error.js';
|
|
8
8
|
import { is_form_content_type, negotiate } from '../../../utils/http.js';
|
|
9
9
|
import { with_version_header } from '../utils.js';
|
|
10
10
|
import { handle_error_and_jsonify } from '../errors.js';
|
|
11
|
-
import { record_span } from '../../telemetry/record_span.js';
|
|
12
11
|
import { stringify, uneval } from '#app/internal/transport';
|
|
13
12
|
|
|
14
13
|
/** @param {RequestEvent} event */
|
|
@@ -29,6 +28,7 @@ export function is_action_json_request(event) {
|
|
|
29
28
|
*/
|
|
30
29
|
export async function handle_action_json_request(event, state, options, server) {
|
|
31
30
|
const actions = server?.actions;
|
|
31
|
+
const location = get_action_location(event.url);
|
|
32
32
|
|
|
33
33
|
if (!actions) {
|
|
34
34
|
const no_actions_error = new SvelteKitError(
|
|
@@ -42,7 +42,8 @@ export async function handle_action_json_request(event, state, options, server)
|
|
|
42
42
|
return action_json(
|
|
43
43
|
{
|
|
44
44
|
type: 'error',
|
|
45
|
-
error
|
|
45
|
+
error,
|
|
46
|
+
location
|
|
46
47
|
},
|
|
47
48
|
{
|
|
48
49
|
status: error.status,
|
|
@@ -69,6 +70,7 @@ export async function handle_action_json_request(event, state, options, server)
|
|
|
69
70
|
{
|
|
70
71
|
type: 'failure',
|
|
71
72
|
status: data.status,
|
|
73
|
+
location,
|
|
72
74
|
// @ts-expect-error we assign a string to what is supposed to be an object. That's ok
|
|
73
75
|
// because we don't use the object outside, and this way we have better code navigation
|
|
74
76
|
// through knowing where the related interface is used.
|
|
@@ -82,12 +84,16 @@ export async function handle_action_json_request(event, state, options, server)
|
|
|
82
84
|
return action_json({
|
|
83
85
|
type: 'success',
|
|
84
86
|
status: 200,
|
|
87
|
+
location,
|
|
85
88
|
// @ts-expect-error see comment above
|
|
86
89
|
data: try_serialize(data, stringify, /** @type {string} */ (event.route.id))
|
|
87
90
|
});
|
|
88
91
|
} else {
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
return action_json({
|
|
93
|
+
type: 'success',
|
|
94
|
+
status: 204,
|
|
95
|
+
location
|
|
96
|
+
});
|
|
91
97
|
}
|
|
92
98
|
} catch (e) {
|
|
93
99
|
const err = normalize_error(e);
|
|
@@ -106,7 +112,8 @@ export async function handle_action_json_request(event, state, options, server)
|
|
|
106
112
|
return action_json(
|
|
107
113
|
{
|
|
108
114
|
type: 'error',
|
|
109
|
-
error: transformed
|
|
115
|
+
error: transformed,
|
|
116
|
+
location
|
|
110
117
|
},
|
|
111
118
|
{
|
|
112
119
|
status: transformed.status
|
|
@@ -115,6 +122,22 @@ export async function handle_action_json_request(event, state, options, server)
|
|
|
115
122
|
}
|
|
116
123
|
}
|
|
117
124
|
|
|
125
|
+
/**
|
|
126
|
+
* @param {URL} url
|
|
127
|
+
*/
|
|
128
|
+
export function get_action_location(url) {
|
|
129
|
+
const location = new URL(url);
|
|
130
|
+
|
|
131
|
+
for (const key of location.searchParams.keys()) {
|
|
132
|
+
if (key.startsWith('/')) {
|
|
133
|
+
location.searchParams.delete(key);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return location.pathname + location.search;
|
|
139
|
+
}
|
|
140
|
+
|
|
118
141
|
/**
|
|
119
142
|
* @param {HttpError | Error} error
|
|
120
143
|
*/
|
|
@@ -158,6 +181,7 @@ export function is_action_request(event) {
|
|
|
158
181
|
*/
|
|
159
182
|
export async function handle_action_request(event, state, server) {
|
|
160
183
|
const actions = server?.actions;
|
|
184
|
+
const location = get_action_location(event.url);
|
|
161
185
|
|
|
162
186
|
if (!actions) {
|
|
163
187
|
// TODO should this be a different error altogether?
|
|
@@ -168,6 +192,7 @@ export async function handle_action_request(event, state, server) {
|
|
|
168
192
|
});
|
|
169
193
|
return {
|
|
170
194
|
type: 'error',
|
|
195
|
+
location,
|
|
171
196
|
// We're lying a bit with the types here; this will be transformed into a proper App.Error object later
|
|
172
197
|
error: new SvelteKitError(
|
|
173
198
|
405,
|
|
@@ -190,12 +215,14 @@ export async function handle_action_request(event, state, server) {
|
|
|
190
215
|
return {
|
|
191
216
|
type: 'failure',
|
|
192
217
|
status: data.status,
|
|
218
|
+
location,
|
|
193
219
|
data: data.data
|
|
194
220
|
};
|
|
195
221
|
} else {
|
|
196
222
|
return {
|
|
197
223
|
type: 'success',
|
|
198
224
|
status: 200,
|
|
225
|
+
location,
|
|
199
226
|
// @ts-expect-error this will be removed upon serialization, so `undefined` is the same as omission
|
|
200
227
|
data
|
|
201
228
|
};
|
|
@@ -213,6 +240,7 @@ export async function handle_action_request(event, state, server) {
|
|
|
213
240
|
|
|
214
241
|
return {
|
|
215
242
|
type: 'error',
|
|
243
|
+
location,
|
|
216
244
|
// @ts-expect-error We're lying a bit with the types here; this will be transformed into a proper App.Error object later
|
|
217
245
|
error: check_incorrect_fail_use(err)
|
|
218
246
|
};
|
|
@@ -2,8 +2,7 @@ import { DEV } from 'esm-env';
|
|
|
2
2
|
import { noop } from '../../../utils/functions.js';
|
|
3
3
|
import { disable_search, make_trackable } from '../../../utils/url.js';
|
|
4
4
|
import { validate_depends, validate_load_response } from '../../shared.js';
|
|
5
|
-
import { with_request_store, merge_tracing } from '@sveltejs/kit/internal/server';
|
|
6
|
-
import { record_span } from '../../telemetry/record_span.js';
|
|
5
|
+
import { with_request_store, merge_tracing, record_span } from '@sveltejs/kit/internal/server';
|
|
7
6
|
import { base64_encode } from '../../utils.js';
|
|
8
7
|
import { NULL_BODY_STATUS } from '../constants.js';
|
|
9
8
|
import { get_node_type } from '../utils.js';
|
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
import { json, error } from '@sveltejs/kit';
|
|
5
5
|
import { Redirect, SvelteKitError } from '@sveltejs/kit/internal';
|
|
6
|
-
import { with_request_store, merge_tracing } from '@sveltejs/kit/internal/server';
|
|
6
|
+
import { with_request_store, merge_tracing, record_span } from '@sveltejs/kit/internal/server';
|
|
7
7
|
import { app_dir, base } from '$app/paths/internal/server';
|
|
8
8
|
import { is_form_content_type } from '../../utils/http.js';
|
|
9
9
|
import { create_remote_key, parse_remote_arg, split_remote_key } from '../shared.js';
|
|
10
10
|
import { stringify } from '#app/internal/transport';
|
|
11
11
|
import { handle_error_and_jsonify } from './errors.js';
|
|
12
12
|
import { normalize_error } from '../../utils/error.js';
|
|
13
|
-
import { check_incorrect_fail_use } from './page/actions.js';
|
|
13
|
+
import { check_incorrect_fail_use, get_action_location } from './page/actions.js';
|
|
14
14
|
import { DEV } from 'esm-env';
|
|
15
|
-
import { record_span } from '../telemetry/record_span.js';
|
|
16
15
|
import { deserialize_binary_form } from '../form-utils.js';
|
|
17
16
|
import { with_version_header } from './utils.js';
|
|
18
17
|
|
|
@@ -533,6 +532,7 @@ export async function handle_remote_form_post(event, state, manifest, id) {
|
|
|
533
532
|
* @returns {Promise<ActionResult>}
|
|
534
533
|
*/
|
|
535
534
|
async function handle_remote_form_post_internal(event, state, manifest, id) {
|
|
535
|
+
const location = get_action_location(event.url);
|
|
536
536
|
// `hash` and `name` can never contain a `/`, but the JSON-stringified key of a
|
|
537
537
|
// keyed (`form.for(key)`) instance can — rejoin the remaining segments
|
|
538
538
|
const [hash, name, ...rest] = id.split('/');
|
|
@@ -552,6 +552,7 @@ async function handle_remote_form_post_internal(event, state, manifest, id) {
|
|
|
552
552
|
});
|
|
553
553
|
return {
|
|
554
554
|
type: 'error',
|
|
555
|
+
location,
|
|
555
556
|
// We're lying a bit with the types here; this will be transformed into a proper App.Error object later
|
|
556
557
|
error: new SvelteKitError(
|
|
557
558
|
405,
|
|
@@ -584,7 +585,8 @@ async function handle_remote_form_post_internal(event, state, manifest, id) {
|
|
|
584
585
|
// It is instead available on `myForm.result`, setting of which happens within the remote `form` function.
|
|
585
586
|
return {
|
|
586
587
|
type: 'success',
|
|
587
|
-
status: 200
|
|
588
|
+
status: 200,
|
|
589
|
+
location
|
|
588
590
|
};
|
|
589
591
|
} catch (e) {
|
|
590
592
|
const err = normalize_error(e);
|
|
@@ -599,6 +601,7 @@ async function handle_remote_form_post_internal(event, state, manifest, id) {
|
|
|
599
601
|
|
|
600
602
|
return {
|
|
601
603
|
type: 'error',
|
|
604
|
+
location,
|
|
602
605
|
// @ts-expect-error We're lying a bit with the types here; this will be transformed into a proper App.Error object later
|
|
603
606
|
error: check_incorrect_fail_use(err)
|
|
604
607
|
};
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
import { DEV } from 'esm-env';
|
|
3
3
|
import { json, text } from '@sveltejs/kit';
|
|
4
4
|
import { Redirect, SvelteKitError } from '@sveltejs/kit/internal';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
merge_tracing,
|
|
7
|
+
otel,
|
|
8
|
+
record_span,
|
|
9
|
+
with_request_store
|
|
10
|
+
} from '@sveltejs/kit/internal/server';
|
|
6
11
|
import { base, app_dir } from '$app/paths/internal/server';
|
|
7
12
|
import { is_endpoint_request, render_endpoint } from './endpoint.js';
|
|
8
13
|
import { render_page } from './page/index.js';
|
|
@@ -40,8 +45,6 @@ import {
|
|
|
40
45
|
} from '../pathname.js';
|
|
41
46
|
import { server_data_serializer } from './page/data_serializer.js';
|
|
42
47
|
import { get_remote_id, handle_remote_call } from './remote-functions.js';
|
|
43
|
-
import { record_span } from '../telemetry/record_span.js';
|
|
44
|
-
import { otel } from '../telemetry/otel.js';
|
|
45
48
|
|
|
46
49
|
/** @type {import('types').RequiredResolveOptions['transformPageChunk']} */
|
|
47
50
|
const default_transform = ({ html }) => html;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @import { InternalRequestOptions, RequestState, ServerHooks } from 'types' */
|
|
2
|
-
import { record_span } from '../telemetry/record_span.js';
|
|
3
2
|
|
|
4
3
|
/** Per-request caches and context flags — never carried into a fork. */
|
|
5
4
|
function transient_fields() {
|
|
@@ -40,9 +39,6 @@ export function create_request_state(options, hooks) {
|
|
|
40
39
|
error: false,
|
|
41
40
|
depth: 0,
|
|
42
41
|
handleValidationError: hooks.handleValidationError,
|
|
43
|
-
tracing: {
|
|
44
|
-
record_span
|
|
45
|
-
},
|
|
46
42
|
...transient_fields()
|
|
47
43
|
};
|
|
48
44
|
}
|
package/src/types/internal.d.ts
CHANGED
|
@@ -679,9 +679,6 @@ export interface RequestState {
|
|
|
679
679
|
*/
|
|
680
680
|
readonly depth: number;
|
|
681
681
|
readonly handleValidationError: ServerHooks['handleValidationError'];
|
|
682
|
-
readonly tracing: {
|
|
683
|
-
record_span: RecordSpan;
|
|
684
|
-
};
|
|
685
682
|
readonly remote: {
|
|
686
683
|
/** Resolved query/prerender data, populated by `await myQuery()` or `myQuery.set(...)` */
|
|
687
684
|
data: null | Map<RemoteInternals, Record<string, MaybePromise<any>>>;
|
package/src/utils/import.js
CHANGED
|
@@ -54,6 +54,7 @@ export async function import_peer(dependency, root) {
|
|
|
54
54
|
try {
|
|
55
55
|
return await import(/* @vite-ignore */ pathToFileURL(resolve_peer(dependency, root)).href);
|
|
56
56
|
} catch {
|
|
57
|
+
// eslint-disable-next-line kit-node-custom/require-path-to-file-url -- bare package specifier, not a path
|
|
57
58
|
return await import(/* @vite-ignore */ dependency);
|
|
58
59
|
}
|
|
59
60
|
}
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -46,11 +46,18 @@ declare module '@sveltejs/kit' {
|
|
|
46
46
|
*/
|
|
47
47
|
emulate?: () => MaybePromise<Emulator>;
|
|
48
48
|
vite?: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
plugins?: {
|
|
50
|
+
/**
|
|
51
|
+
* Vite plugins placed before any of SvelteKit's own plugins.
|
|
52
|
+
* @since 3.0.0
|
|
53
|
+
*/
|
|
54
|
+
pre?: Plugin[];
|
|
55
|
+
/**
|
|
56
|
+
* Vite plugins placed after any of SvelteKit's own plugins.
|
|
57
|
+
* @since 3.0.0
|
|
58
|
+
*/
|
|
59
|
+
post?: Plugin[];
|
|
60
|
+
};
|
|
54
61
|
};
|
|
55
62
|
}
|
|
56
63
|
|
|
@@ -432,7 +439,10 @@ declare module '@sveltejs/kit' {
|
|
|
432
439
|
*
|
|
433
440
|
* CSRF checks only apply in production, not in local development.
|
|
434
441
|
* @default []
|
|
435
|
-
* @example
|
|
442
|
+
* @example
|
|
443
|
+
* ```js
|
|
444
|
+
* ['https://checkout.stripe.com', 'https://accounts.google.com']
|
|
445
|
+
* ```
|
|
436
446
|
*/
|
|
437
447
|
trustedOrigins?: string[];
|
|
438
448
|
};
|
|
@@ -1898,15 +1908,20 @@ declare module '@sveltejs/kit' {
|
|
|
1898
1908
|
* };
|
|
1899
1909
|
* }}
|
|
1900
1910
|
* ```
|
|
1911
|
+
*
|
|
1912
|
+
* Success and failure results carry the root-relative `pathname + search` of the action URL, with
|
|
1913
|
+
* the `?/actionName` parameter removed. Redirect results carry the redirect target. Server-generated
|
|
1914
|
+
* error results also carry the action location, while client-generated errors such as network
|
|
1915
|
+
* failures do not. `update` uses this location to emulate native form navigation.
|
|
1901
1916
|
*/
|
|
1902
1917
|
export type ActionResult<
|
|
1903
1918
|
Success extends Record<string, unknown> | undefined = Record<string, any>,
|
|
1904
1919
|
Failure extends Record<string, unknown> | undefined = Record<string, any>
|
|
1905
1920
|
> =
|
|
1906
|
-
| { type: 'success'; status: number; data?: Success }
|
|
1907
|
-
| { type: 'failure'; status: number; data?: Failure }
|
|
1921
|
+
| { type: 'success'; status: number; data?: Success; location: string }
|
|
1922
|
+
| { type: 'failure'; status: number; data?: Failure; location: string }
|
|
1908
1923
|
| { type: 'redirect'; status: number; location: string }
|
|
1909
|
-
| { type: 'error'; status?: number; error: App.Error };
|
|
1924
|
+
| { type: 'error'; status?: number; error: App.Error; location?: string };
|
|
1910
1925
|
|
|
1911
1926
|
/**
|
|
1912
1927
|
* The object returned by the [`error`](https://svelte.dev/docs/kit/@sveltejs-kit#error) function.
|
|
@@ -1947,15 +1962,21 @@ declare module '@sveltejs/kit' {
|
|
|
1947
1962
|
result: ActionResult<Success, Failure>;
|
|
1948
1963
|
/**
|
|
1949
1964
|
* Call this to get the default behavior of a form submission response.
|
|
1950
|
-
* @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission.
|
|
1951
|
-
* @param invalidateAll Set `invalidateAll: false` if you don't want the action to call `invalidateAll` after submission.
|
|
1965
|
+
* @param options Set `reset: false` if you don't want the `<form>` values to be reset after a successful submission. `refreshAll` defaults to `true` for successful results and `false` for failures. When the submission navigates, setting it to `false` still runs the destination's `load` functions but may reuse shared layout data. Set `navigate: false` to apply non-redirect results to the current page instead of navigating to `result.location`. Redirects are always followed.
|
|
1952
1966
|
*/
|
|
1953
|
-
update: (options?: {
|
|
1967
|
+
update: (options?: {
|
|
1968
|
+
reset?: boolean;
|
|
1969
|
+
refreshAll?: boolean;
|
|
1970
|
+
navigate?: boolean;
|
|
1971
|
+
/** @deprecated Use `refreshAll` instead. */
|
|
1972
|
+
invalidateAll?: boolean;
|
|
1973
|
+
}) => Promise<void>;
|
|
1954
1974
|
}) => MaybePromise<void>)
|
|
1955
1975
|
>;
|
|
1956
1976
|
|
|
1957
1977
|
/**
|
|
1958
1978
|
* The type of `export const snapshot` exported from a page or layout component.
|
|
1979
|
+
* @deprecated Use the [`snapshot`](https://svelte.dev/docs/kit/$app-navigation#snapshot) helper from `$app/navigation` instead.
|
|
1959
1980
|
*/
|
|
1960
1981
|
export interface Snapshot<T = any> {
|
|
1961
1982
|
capture: () => T;
|
|
@@ -3112,17 +3133,18 @@ declare module '$app/forms' {
|
|
|
3112
3133
|
* If a function is returned, that function is called with the response from the server.
|
|
3113
3134
|
* If nothing is returned, the fallback will be used.
|
|
3114
3135
|
*
|
|
3115
|
-
* If this function or its return value isn't set, it
|
|
3116
|
-
* -
|
|
3117
|
-
* - updates `page.status`
|
|
3118
|
-
* -
|
|
3136
|
+
* If this function or its return value isn't set, it emulates the browser-native behaviour, just without the full-page reload. It
|
|
3137
|
+
* - resets the `<form>` element and refreshes all data in case of a successful submission with no redirect response
|
|
3138
|
+
* - updates the `form` prop, `page.form` and `page.status` if the action is on the same page as the form
|
|
3139
|
+
* - navigates to the page the submission lands on — populating that page's `form` prop and `page.status` — on success and failure if that isn't the current page, just as a native form submission would, but with the `?/actionName` param stripped from the destination URL
|
|
3119
3140
|
* - redirects in case of a redirect response
|
|
3120
|
-
* -
|
|
3141
|
+
* - renders the nearest error page in case of an unexpected error — the one nearest the action's route, if the action is on a different page
|
|
3121
3142
|
*
|
|
3122
3143
|
* If you provide a custom function with a callback and want to use the default behavior, invoke `update` in your callback.
|
|
3123
3144
|
* It accepts an options object
|
|
3124
3145
|
* - `reset: false` if you don't want the `<form>` values to be reset after a successful submission
|
|
3125
|
-
* - `
|
|
3146
|
+
* - `refreshAll` to control whether all data is refreshed after submission; it defaults to `true` for successes and `false` for failures
|
|
3147
|
+
* - `navigate: false` to apply non-redirect results to the current page rather than navigating to `result.location`; redirects are always followed
|
|
3126
3148
|
* @param form_element The form element
|
|
3127
3149
|
* @param submit Submit callback
|
|
3128
3150
|
*/
|
|
@@ -3130,8 +3152,9 @@ declare module '$app/forms' {
|
|
|
3130
3152
|
destroy(): void;
|
|
3131
3153
|
};
|
|
3132
3154
|
/**
|
|
3133
|
-
*
|
|
3134
|
-
* In case of an error, it
|
|
3155
|
+
* Updates the `form` property of the current page with the given data and updates `page.status`.
|
|
3156
|
+
* In case of an error, it renders the nearest error page. In case of a redirect, it navigates to
|
|
3157
|
+
* the redirect location.
|
|
3135
3158
|
* */
|
|
3136
3159
|
export function applyAction<Success extends Record<string, unknown> | undefined, Failure extends Record<string, unknown> | undefined>(result: import("@sveltejs/kit").ActionResult<Success, Failure>): Promise<void>;
|
|
3137
3160
|
|
|
@@ -3140,6 +3163,21 @@ declare module '$app/forms' {
|
|
|
3140
3163
|
|
|
3141
3164
|
declare module '$app/navigation' {
|
|
3142
3165
|
import type { RouteId } from '$app/types';
|
|
3166
|
+
/**
|
|
3167
|
+
* A lifecycle function that captures state before navigating and restores it when traversing history.
|
|
3168
|
+
*
|
|
3169
|
+
* By default, the snapshot `id` is generated from the call site. Pass an explicit `id` to keep snapshots stable across deployments or distinguish multiple uses of a shared helper.
|
|
3170
|
+
*
|
|
3171
|
+
* The optional `reset` callback runs on navigations where there is no captured value to restore, such as when a new history entry is created. Captured values are serialized with the app's transport hook.
|
|
3172
|
+
*
|
|
3173
|
+
* `snapshot` must be called during a component initialization. It remains active as long as the component is mounted.
|
|
3174
|
+
* */
|
|
3175
|
+
export function snapshot<T>(options: {
|
|
3176
|
+
id?: string;
|
|
3177
|
+
capture: () => T;
|
|
3178
|
+
restore: (value: T) => void;
|
|
3179
|
+
reset?: () => void;
|
|
3180
|
+
}): void;
|
|
3143
3181
|
/**
|
|
3144
3182
|
* A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a URL.
|
|
3145
3183
|
*
|
package/types/index.d.ts.map
CHANGED
|
@@ -159,6 +159,7 @@
|
|
|
159
159
|
"deserialize",
|
|
160
160
|
"enhance",
|
|
161
161
|
"applyAction",
|
|
162
|
+
"snapshot",
|
|
162
163
|
"afterNavigate",
|
|
163
164
|
"beforeNavigate",
|
|
164
165
|
"onNavigate",
|
|
@@ -199,6 +200,7 @@
|
|
|
199
200
|
"../src/runtime/app/env/types.d.ts",
|
|
200
201
|
"../src/runtime/app/forms.js",
|
|
201
202
|
"../src/runtime/client/client.js",
|
|
203
|
+
"../src/runtime/client/snapshots.js",
|
|
202
204
|
"../src/runtime/app/paths/client.js",
|
|
203
205
|
"../src/runtime/app/paths/types.d.ts",
|
|
204
206
|
"../src/runtime/app/server/index.js",
|
|
@@ -224,8 +226,9 @@
|
|
|
224
226
|
null,
|
|
225
227
|
null,
|
|
226
228
|
null,
|
|
229
|
+
null,
|
|
227
230
|
null
|
|
228
231
|
],
|
|
229
|
-
"mappings": ";;;;;;;;;MAmCKA,IAAIA;;MAEJC,0BAA0BA;;;;;kBAKdC,OAAOA
|
|
232
|
+
"mappings": ";;;;;;;;;MAmCKA,IAAIA;;MAEJC,0BAA0BA;;;;;kBAKdC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA+CZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;MAQrBC,aAAaA;;;;;OAKJC,YAAYA;;kBAETC,aAAaA;;;;;;MAMzBC,qBAAqBA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AAaA;;;;;iBAcbC,UAAUA;;;;;;;;;;;;iBAqBJC,WAAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgEXC,WAAWA;;;;;;iBA6DXC,SAASA;;;;;;iBA8BTC,YAAYA;MVrtFtBvD,YAAYA;;;;;;;;;;;;;;;;;;;;;;;iBYvJRwD,KAAKA;;;;;;;;;;;;;;;;;;;;;iBAsCLC,OAAOA;;;;;;;;;;;;;;;;;;;iBAmCPC,KAAKA;;;;MC/FhBC,iBAAiBA;;;;;;MAMVC,WAAWA;;;;;;;;;;;;;;;;;;;;;;;;;;iBCUPC,IAAIA;;;;;;;;iBCSJC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Md8TnBC,qCAAqCA;;;;;;;;MAqKrCC,8BAA8BA;MD/U9BhE,YAAYA;;MAkGZgB,KAAKA;;MAELiD,qBAAqBA;;;;;;;;;;;;;;;;;;;;;cgBvQpBC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCqCJC,IAAIA;;;;;cAQJC,UAAUA;;;;;;;;;;;cAMVC,OAAOA",
|
|
230
233
|
"ignoreList": []
|
|
231
234
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** @import { Tracer, SpanStatusCode, PropagationAPI, ContextAPI } from '@opentelemetry/api' */
|
|
2
|
-
|
|
3
|
-
/** @type {Promise<{ tracer: Tracer, SpanStatusCode: typeof SpanStatusCode, propagation: PropagationAPI, context: ContextAPI }> | null} */
|
|
4
|
-
export let otel = null;
|
|
5
|
-
|
|
6
|
-
if (__SVELTEKIT_SERVER_TRACING_ENABLED__) {
|
|
7
|
-
otel = import('@opentelemetry/api')
|
|
8
|
-
.then((module) => {
|
|
9
|
-
return {
|
|
10
|
-
tracer: module.trace.getTracer('sveltekit'),
|
|
11
|
-
propagation: module.propagation,
|
|
12
|
-
context: module.context,
|
|
13
|
-
SpanStatusCode: module.SpanStatusCode
|
|
14
|
-
};
|
|
15
|
-
})
|
|
16
|
-
.catch(() => {
|
|
17
|
-
throw new Error(
|
|
18
|
-
'Tracing is enabled (see the SvelteKit plugin `tracing.server` option in your vite.config.js), but `@opentelemetry/api` is not available. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation.server.js`. For more information, see https://svelte.dev/docs/kit/observability#opentelemetry-api'
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/** @import { RecordSpan } from 'types' */
|
|
2
|
-
import { HttpError, Redirect } from '@sveltejs/kit/internal';
|
|
3
|
-
import { noop_span } from './noop.js';
|
|
4
|
-
import { otel } from './otel.js';
|
|
5
|
-
|
|
6
|
-
/** @type {RecordSpan} */
|
|
7
|
-
export async function record_span({ name, attributes, fn }) {
|
|
8
|
-
if (otel === null) {
|
|
9
|
-
return fn(noop_span);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { SpanStatusCode, tracer } = await otel;
|
|
13
|
-
|
|
14
|
-
return tracer.startActiveSpan(name, { attributes }, async (span) => {
|
|
15
|
-
try {
|
|
16
|
-
return await fn(span);
|
|
17
|
-
} catch (error) {
|
|
18
|
-
if (error instanceof HttpError) {
|
|
19
|
-
span.setAttributes({
|
|
20
|
-
[`${name}.result.type`]: 'known_error',
|
|
21
|
-
[`${name}.result.status`]: error.status,
|
|
22
|
-
[`${name}.result.message`]: error.body.message
|
|
23
|
-
});
|
|
24
|
-
if (error.status >= 500) {
|
|
25
|
-
span.recordException({
|
|
26
|
-
name: 'HttpError',
|
|
27
|
-
message: error.body.message
|
|
28
|
-
});
|
|
29
|
-
span.setStatus({
|
|
30
|
-
code: SpanStatusCode.ERROR,
|
|
31
|
-
message: error.body.message
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
} else if (error instanceof Redirect) {
|
|
35
|
-
span.setAttributes({
|
|
36
|
-
[`${name}.result.type`]: 'redirect',
|
|
37
|
-
[`${name}.result.status`]: error.status,
|
|
38
|
-
[`${name}.result.location`]: error.location
|
|
39
|
-
});
|
|
40
|
-
} else if (error instanceof Error) {
|
|
41
|
-
span.setAttributes({
|
|
42
|
-
[`${name}.result.type`]: 'unknown_error'
|
|
43
|
-
});
|
|
44
|
-
span.recordException({
|
|
45
|
-
name: error.name,
|
|
46
|
-
message: error.message,
|
|
47
|
-
stack: error.stack
|
|
48
|
-
});
|
|
49
|
-
span.setStatus({
|
|
50
|
-
code: SpanStatusCode.ERROR,
|
|
51
|
-
message: error.message
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
span.setAttributes({
|
|
55
|
-
[`${name}.result.type`]: 'unknown_error'
|
|
56
|
-
});
|
|
57
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
throw error;
|
|
61
|
-
} finally {
|
|
62
|
-
span.end();
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|