@sveltejs/kit 2.30.1 → 2.31.0
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 +12 -1
- package/src/core/adapt/builder.js +122 -13
- package/src/core/config/options.js +6 -0
- package/src/exports/hooks/sequence.js +53 -31
- package/src/{runtime/app/server → exports/internal}/event.js +24 -9
- package/src/exports/internal/server.js +22 -0
- package/src/exports/public.d.ts +117 -5
- package/src/exports/vite/dev/index.js +8 -0
- package/src/exports/vite/index.js +30 -3
- package/src/exports/vite/utils.js +44 -0
- package/src/runtime/app/server/index.js +1 -1
- package/src/runtime/app/server/remote/command.js +4 -5
- package/src/runtime/app/server/remote/form.js +5 -7
- package/src/runtime/app/server/remote/prerender.js +5 -7
- package/src/runtime/app/server/remote/query.js +6 -8
- package/src/runtime/app/server/remote/shared.js +9 -13
- package/src/runtime/client/client.js +9 -14
- package/src/runtime/server/data/index.js +10 -5
- package/src/runtime/server/endpoint.js +4 -3
- package/src/runtime/server/page/actions.js +55 -24
- package/src/runtime/server/page/index.js +22 -5
- package/src/runtime/server/page/load_data.js +131 -121
- package/src/runtime/server/page/render.js +15 -7
- package/src/runtime/server/page/respond_with_error.js +7 -2
- package/src/runtime/server/remote.js +59 -13
- package/src/runtime/server/respond.js +110 -34
- package/src/runtime/server/utils.js +20 -5
- package/src/runtime/shared.js +20 -0
- package/src/runtime/telemetry/noop.js +81 -0
- package/src/runtime/telemetry/otel.js +21 -0
- package/src/runtime/telemetry/record_span.js +65 -0
- package/src/types/global-private.d.ts +2 -0
- package/src/types/internal.d.ts +28 -0
- package/src/types/synthetic/$env+dynamic+private.md +1 -1
- package/src/version.js +1 -1
- package/types/index.d.ts +117 -4
- package/types/index.d.ts.map +2 -2
- package/src/runtime/server/event-state.js +0 -40
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** @import { Tracer, Span, SpanContext } from '@opentelemetry/api' */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tracer implementation that does nothing (null object).
|
|
5
|
+
* @type {Tracer}
|
|
6
|
+
*/
|
|
7
|
+
export const noop_tracer = {
|
|
8
|
+
/**
|
|
9
|
+
* @returns {Span}
|
|
10
|
+
*/
|
|
11
|
+
startSpan() {
|
|
12
|
+
return noop_span;
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {unknown} _name
|
|
17
|
+
* @param {unknown} arg_1
|
|
18
|
+
* @param {unknown} [arg_2]
|
|
19
|
+
* @param {Function} [arg_3]
|
|
20
|
+
* @returns {unknown}
|
|
21
|
+
*/
|
|
22
|
+
startActiveSpan(_name, arg_1, arg_2, arg_3) {
|
|
23
|
+
if (typeof arg_1 === 'function') {
|
|
24
|
+
return arg_1(noop_span);
|
|
25
|
+
}
|
|
26
|
+
if (typeof arg_2 === 'function') {
|
|
27
|
+
return arg_2(noop_span);
|
|
28
|
+
}
|
|
29
|
+
if (typeof arg_3 === 'function') {
|
|
30
|
+
return arg_3(noop_span);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @type {Span}
|
|
37
|
+
*/
|
|
38
|
+
export const noop_span = {
|
|
39
|
+
spanContext() {
|
|
40
|
+
return noop_span_context;
|
|
41
|
+
},
|
|
42
|
+
setAttribute() {
|
|
43
|
+
return this;
|
|
44
|
+
},
|
|
45
|
+
setAttributes() {
|
|
46
|
+
return this;
|
|
47
|
+
},
|
|
48
|
+
addEvent() {
|
|
49
|
+
return this;
|
|
50
|
+
},
|
|
51
|
+
setStatus() {
|
|
52
|
+
return this;
|
|
53
|
+
},
|
|
54
|
+
updateName() {
|
|
55
|
+
return this;
|
|
56
|
+
},
|
|
57
|
+
end() {
|
|
58
|
+
return this;
|
|
59
|
+
},
|
|
60
|
+
isRecording() {
|
|
61
|
+
return false;
|
|
62
|
+
},
|
|
63
|
+
recordException() {
|
|
64
|
+
return this;
|
|
65
|
+
},
|
|
66
|
+
addLink() {
|
|
67
|
+
return this;
|
|
68
|
+
},
|
|
69
|
+
addLinks() {
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @type {SpanContext}
|
|
76
|
+
*/
|
|
77
|
+
const noop_span_context = {
|
|
78
|
+
traceId: '',
|
|
79
|
+
spanId: '',
|
|
80
|
+
traceFlags: 0
|
|
81
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
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 `config.kit.experimental.instrumentation.server` in your svelte.config.js), but `@opentelemetry/api` is not available. Have you installed it?'
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
}
|
|
@@ -4,6 +4,8 @@ declare global {
|
|
|
4
4
|
const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;
|
|
5
5
|
const __SVELTEKIT_DEV__: boolean;
|
|
6
6
|
const __SVELTEKIT_EMBEDDED__: boolean;
|
|
7
|
+
/** True if `config.kit.experimental.instrumentation.server` is `true` */
|
|
8
|
+
const __SVELTEKIT_SERVER_TRACING_ENABLED__: boolean;
|
|
7
9
|
/** true if corresponding config option is set to true */
|
|
8
10
|
const __SVELTEKIT_EXPERIMENTAL__REMOTE_FUNCTIONS__: boolean;
|
|
9
11
|
/** True if `config.kit.router.resolution === 'client'` */
|
package/src/types/internal.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
RequestOptions,
|
|
31
31
|
TrailingSlash
|
|
32
32
|
} from './private.js';
|
|
33
|
+
import { Span } from '@opentelemetry/api';
|
|
33
34
|
|
|
34
35
|
export interface ServerModule {
|
|
35
36
|
Server: typeof InternalServer;
|
|
@@ -567,5 +568,32 @@ export type RemoteInfo =
|
|
|
567
568
|
inputs?: RemotePrerenderInputsGenerator;
|
|
568
569
|
};
|
|
569
570
|
|
|
571
|
+
export type RecordSpan = <T>(options: {
|
|
572
|
+
name: string;
|
|
573
|
+
attributes: Record<string, any>;
|
|
574
|
+
fn: (current: Span) => Promise<T>;
|
|
575
|
+
}) => Promise<T>;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Internal state associated with the current `RequestEvent`,
|
|
579
|
+
* used for tracking things like remote function calls
|
|
580
|
+
*/
|
|
581
|
+
export interface RequestState {
|
|
582
|
+
prerendering: PrerenderOptions | undefined;
|
|
583
|
+
transport: ServerHooks['transport'];
|
|
584
|
+
handleValidationError: ServerHooks['handleValidationError'];
|
|
585
|
+
tracing: {
|
|
586
|
+
record_span: RecordSpan;
|
|
587
|
+
};
|
|
588
|
+
form_instances?: Map<any, any>;
|
|
589
|
+
remote_data?: Record<string, MaybePromise<any>>;
|
|
590
|
+
refreshes?: Record<string, any>;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
export interface RequestStore {
|
|
594
|
+
event: RequestEvent;
|
|
595
|
+
state: RequestState;
|
|
596
|
+
}
|
|
597
|
+
|
|
570
598
|
export * from '../exports/index.js';
|
|
571
599
|
export * from './private.js';
|
|
@@ -9,4 +9,4 @@ import { env } from '$env/dynamic/private';
|
|
|
9
9
|
console.log(env.DEPLOYMENT_SPECIFIC_VARIABLE);
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
> In `dev`, `$env/dynamic` always includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter.
|
|
12
|
+
> [!NOTE] In `dev`, `$env/dynamic` always includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter.
|
package/src/version.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare module '@sveltejs/kit' {
|
|
|
5
5
|
import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
|
|
6
6
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
7
7
|
import type { RouteId as AppRouteId, LayoutParams as AppLayoutParams, ResolvedPathname } from '$app/types';
|
|
8
|
+
import type { Span } from '@opentelemetry/api';
|
|
8
9
|
/**
|
|
9
10
|
* [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.
|
|
10
11
|
*/
|
|
@@ -27,6 +28,12 @@ declare module '@sveltejs/kit' {
|
|
|
27
28
|
* @param details.config The merged route config
|
|
28
29
|
*/
|
|
29
30
|
read?: (details: { config: any; route: { id: string } }) => boolean;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Test support for `instrumentation.server.js`. To pass, the adapter must support running `instrumentation.server.js` prior to the application code.
|
|
34
|
+
* @since 2.31.0
|
|
35
|
+
*/
|
|
36
|
+
instrumentation?: () => boolean;
|
|
30
37
|
};
|
|
31
38
|
/**
|
|
32
39
|
* Creates an `Emulator`, which allows the adapter to influence the environment
|
|
@@ -164,6 +171,46 @@ declare module '@sveltejs/kit' {
|
|
|
164
171
|
}
|
|
165
172
|
) => string[];
|
|
166
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Check if the server instrumentation file exists.
|
|
176
|
+
* @returns true if the server instrumentation file exists, false otherwise
|
|
177
|
+
* @since 2.31.0
|
|
178
|
+
*/
|
|
179
|
+
hasServerInstrumentationFile: () => boolean;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Instrument `entrypoint` with `instrumentation`.
|
|
183
|
+
*
|
|
184
|
+
* Renames `entrypoint` to `start` and creates a new module at
|
|
185
|
+
* `entrypoint` which imports `instrumentation` and then dynamically imports `start`. This allows
|
|
186
|
+
* the module hooks necessary for instrumentation libraries to be loaded prior to any application code.
|
|
187
|
+
*
|
|
188
|
+
* Caveats:
|
|
189
|
+
* - "Live exports" will not work. If your adapter uses live exports, your users will need to manually import the server instrumentation on startup.
|
|
190
|
+
* - If `tla` is `false`, OTEL auto-instrumentation may not work properly. Use it if your environment supports it.
|
|
191
|
+
* - Use `hasServerInstrumentationFile` to check if the user has a server instrumentation file; if they don't, you shouldn't do this.
|
|
192
|
+
*
|
|
193
|
+
* @param options an object containing the following properties:
|
|
194
|
+
* @param options.entrypoint the path to the entrypoint to trace.
|
|
195
|
+
* @param options.instrumentation the path to the instrumentation file.
|
|
196
|
+
* @param options.start the name of the start file. This is what `entrypoint` will be renamed to.
|
|
197
|
+
* @param options.module configuration for the resulting entrypoint module.
|
|
198
|
+
* @param options.module.generateText a function that receives the relative paths to the instrumentation and start files, and generates the text of the module to be traced. If not provided, the default implementation will be used, which uses top-level await.
|
|
199
|
+
* @since 2.31.0
|
|
200
|
+
*/
|
|
201
|
+
instrument: (args: {
|
|
202
|
+
entrypoint: string;
|
|
203
|
+
instrumentation: string;
|
|
204
|
+
start?: string;
|
|
205
|
+
module?:
|
|
206
|
+
| {
|
|
207
|
+
exports: string[];
|
|
208
|
+
}
|
|
209
|
+
| {
|
|
210
|
+
generateText: (args: { instrumentation: string; start: string }) => string;
|
|
211
|
+
};
|
|
212
|
+
}) => void;
|
|
213
|
+
|
|
167
214
|
/**
|
|
168
215
|
* Compress files in `directory` with gzip and brotli, where appropriate. Generates `.gz` and `.br` files alongside the originals.
|
|
169
216
|
* @param directory The directory containing the files to be compressed
|
|
@@ -385,10 +432,34 @@ declare module '@sveltejs/kit' {
|
|
|
385
432
|
*/
|
|
386
433
|
privatePrefix?: string;
|
|
387
434
|
};
|
|
388
|
-
/**
|
|
389
|
-
* Experimental features which are exempt from semantic versioning. These features may be changed or removed at any time.
|
|
390
|
-
*/
|
|
435
|
+
/** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */
|
|
391
436
|
experimental?: {
|
|
437
|
+
/**
|
|
438
|
+
* Options for enabling server-side [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).
|
|
439
|
+
* @default { server: false, serverFile: false }
|
|
440
|
+
* @since 2.31.0
|
|
441
|
+
*/
|
|
442
|
+
tracing?: {
|
|
443
|
+
/**
|
|
444
|
+
* Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#Server-hooks-handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions).
|
|
445
|
+
* @default false
|
|
446
|
+
* @since 2.31.0
|
|
447
|
+
*/
|
|
448
|
+
server?: boolean;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* @since 2.31.0
|
|
453
|
+
*/
|
|
454
|
+
instrumentation?: {
|
|
455
|
+
/**
|
|
456
|
+
* Enables `instrumentation.server.js` for tracing and observability instrumentation.
|
|
457
|
+
* @default false
|
|
458
|
+
* @since 2.31.0
|
|
459
|
+
*/
|
|
460
|
+
server?: boolean;
|
|
461
|
+
};
|
|
462
|
+
|
|
392
463
|
/**
|
|
393
464
|
* Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.
|
|
394
465
|
* @default false
|
|
@@ -1004,6 +1075,19 @@ declare module '@sveltejs/kit' {
|
|
|
1004
1075
|
* ```
|
|
1005
1076
|
*/
|
|
1006
1077
|
untrack: <T>(fn: () => T) => T;
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Access to spans for tracing. If tracing is not enabled or the function is being run in the browser, these spans will do nothing.
|
|
1081
|
+
* @since 2.31.0
|
|
1082
|
+
*/
|
|
1083
|
+
tracing: {
|
|
1084
|
+
/** Whether tracing is enabled. */
|
|
1085
|
+
enabled: boolean;
|
|
1086
|
+
/** The root span for the request. This span is named `sveltekit.handle.root`. */
|
|
1087
|
+
root: Span;
|
|
1088
|
+
/** The span associated with the current `load` function. */
|
|
1089
|
+
current: Span;
|
|
1090
|
+
};
|
|
1007
1091
|
}
|
|
1008
1092
|
|
|
1009
1093
|
export interface NavigationEvent<
|
|
@@ -1282,6 +1366,20 @@ declare module '@sveltejs/kit' {
|
|
|
1282
1366
|
* `true` for `+server.js` calls coming from SvelteKit without the overhead of actually making an HTTP request. This happens when you make same-origin `fetch` requests on the server.
|
|
1283
1367
|
*/
|
|
1284
1368
|
isSubRequest: boolean;
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* Access to spans for tracing. If tracing is not enabled, these spans will do nothing.
|
|
1372
|
+
* @since 2.31.0
|
|
1373
|
+
*/
|
|
1374
|
+
tracing: {
|
|
1375
|
+
/** Whether tracing is enabled. */
|
|
1376
|
+
enabled: boolean;
|
|
1377
|
+
/** The root span for the request. This span is named `sveltekit.handle.root`. */
|
|
1378
|
+
root: Span;
|
|
1379
|
+
/** The span associated with the current `handle` hook, `load` function, or form action. */
|
|
1380
|
+
current: Span;
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1285
1383
|
/**
|
|
1286
1384
|
* `true` if the request comes from the client via a remote function. The `url` property will be stripped of the internal information
|
|
1287
1385
|
* related to the data request in this case. Use this property instead if the distinction is important to you.
|
|
@@ -1445,6 +1543,19 @@ declare module '@sveltejs/kit' {
|
|
|
1445
1543
|
* ```
|
|
1446
1544
|
*/
|
|
1447
1545
|
untrack: <T>(fn: () => T) => T;
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* Access to spans for tracing. If tracing is not enabled, these spans will do nothing.
|
|
1549
|
+
* @since 2.31.0
|
|
1550
|
+
*/
|
|
1551
|
+
tracing: {
|
|
1552
|
+
/** Whether tracing is enabled. */
|
|
1553
|
+
enabled: boolean;
|
|
1554
|
+
/** The root span for the request. This span is named `sveltekit.handle.root`. */
|
|
1555
|
+
root: Span;
|
|
1556
|
+
/** The span associated with the current server `load` function. */
|
|
1557
|
+
current: Span;
|
|
1558
|
+
};
|
|
1448
1559
|
}
|
|
1449
1560
|
|
|
1450
1561
|
/**
|
|
@@ -2260,6 +2371,7 @@ declare module '@sveltejs/kit' {
|
|
|
2260
2371
|
}
|
|
2261
2372
|
|
|
2262
2373
|
declare module '@sveltejs/kit/hooks' {
|
|
2374
|
+
import type { Handle } from '@sveltejs/kit';
|
|
2263
2375
|
/**
|
|
2264
2376
|
* A helper function for sequencing multiple `handle` calls in a middleware-like manner.
|
|
2265
2377
|
* The behavior for the `handle` options is as follows:
|
|
@@ -2330,7 +2442,7 @@ declare module '@sveltejs/kit/hooks' {
|
|
|
2330
2442
|
*
|
|
2331
2443
|
* @param handlers The chain of `handle` functions
|
|
2332
2444
|
* */
|
|
2333
|
-
export function sequence(...handlers:
|
|
2445
|
+
export function sequence(...handlers: Handle[]): Handle;
|
|
2334
2446
|
|
|
2335
2447
|
export {};
|
|
2336
2448
|
}
|
|
@@ -2671,6 +2783,7 @@ declare module '$app/server' {
|
|
|
2671
2783
|
*
|
|
2672
2784
|
* In environments without [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage), this must be called synchronously (i.e. not after an `await`).
|
|
2673
2785
|
* @since 2.20.0
|
|
2786
|
+
*
|
|
2674
2787
|
* */
|
|
2675
2788
|
export function getRequestEvent(): RequestEvent;
|
|
2676
2789
|
/**
|
package/types/index.d.ts.map
CHANGED
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"../src/runtime/client/client.js",
|
|
160
160
|
"../src/runtime/app/paths/types.d.ts",
|
|
161
161
|
"../src/runtime/app/server/index.js",
|
|
162
|
-
"../src/
|
|
162
|
+
"../src/exports/internal/event.js",
|
|
163
163
|
"../src/runtime/app/server/remote/form.js",
|
|
164
164
|
"../src/runtime/app/state/index.js",
|
|
165
165
|
"../src/runtime/app/stores.js"
|
|
@@ -185,6 +185,6 @@
|
|
|
185
185
|
null,
|
|
186
186
|
null
|
|
187
187
|
],
|
|
188
|
-
"mappings": "
|
|
188
|
+
"mappings": ";;;;;;;;;;;kBAiCiBA,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAiCZC,cAAcA;;;;;;aAMdC,cAAcA;;;;;;;;MAQrBC,aAAaA;;;;;OAKJC,YAAYA;;kBAETC,aAAaA;;;;;;MAMzBC,qBAAqBA;;;;;;;;;;;kBAWTC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA8IPC,MAAMA;;;;;;;;;;;kBAWNC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA4DPC,QAAQA;;;;;;;;kBAQRC,SAASA;;;;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;;;;;;;;;;;;;;;;;MbycRC,8BAA8BA;MD/T9B1E,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ce1GX2E,IAAIA;;;;;cAQJC,UAAUA;;;;;;;;;;;cAMVC,OAAOA;;;;;;;;;iBCrDPC,SAASA;;;;;;;;;;;;;;;cAyBTH,IAAIA;;;;;;;;;;cAiBJC,UAAUA;;;;;;;;cAeVC,OAAOA",
|
|
189
189
|
"ignoreList": []
|
|
190
190
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/** @import { RequestEvent } from '@sveltejs/kit' */
|
|
2
|
-
/** @import { MaybePromise, PrerenderOptions, ServerHooks, SSROptions, SSRState } from 'types' */
|
|
3
|
-
|
|
4
|
-
export const EVENT_STATE = Symbol('remote');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal state associated with the current `RequestEvent`,
|
|
8
|
-
* used for tracking things like remote function calls
|
|
9
|
-
* @typedef {{
|
|
10
|
-
* prerendering: PrerenderOptions | undefined
|
|
11
|
-
* transport: ServerHooks['transport'];
|
|
12
|
-
* handleValidationError: ServerHooks['handleValidationError'];
|
|
13
|
-
* form_instances?: Map<any, any>;
|
|
14
|
-
* remote_data?: Record<string, MaybePromise<any>>;
|
|
15
|
-
* refreshes?: Record<string, any>;
|
|
16
|
-
* }} RequestEventState
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {SSRState} state
|
|
21
|
-
* @param {SSROptions} options
|
|
22
|
-
* @returns {RequestEventState}
|
|
23
|
-
*/
|
|
24
|
-
export function create_event_state(state, options) {
|
|
25
|
-
return {
|
|
26
|
-
prerendering: state.prerendering,
|
|
27
|
-
transport: options.hooks.transport,
|
|
28
|
-
handleValidationError: options.hooks.handleValidationError
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Returns internal state associated with the current `RequestEvent`
|
|
34
|
-
* @param {RequestEvent} event
|
|
35
|
-
* @returns {RequestEventState}
|
|
36
|
-
*/
|
|
37
|
-
export function get_event_state(event) {
|
|
38
|
-
// @ts-expect-error the symbol isn't exposed on the public `RequestEvent` type
|
|
39
|
-
return event[EVENT_STATE];
|
|
40
|
-
}
|