@rasputin-ai/sveltekit 0.7.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/README.md +5 -0
- package/dist/client/hooks.d.ts +12 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +39 -0
- package/dist/client/options.d.ts +15 -0
- package/dist/client/options.d.ts.map +1 -0
- package/dist/compiler/svelte-generated.d.ts +7 -0
- package/dist/compiler/svelte-generated.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +130 -0
- package/dist/runtime/node.d.ts +10 -0
- package/dist/runtime/node.d.ts.map +1 -0
- package/dist/runtime/node.js +180 -0
- package/dist/sdk-meta.d.ts +4 -0
- package/dist/sdk-meta.d.ts.map +1 -0
- package/dist/server/expected-error.d.ts +3 -0
- package/dist/server/expected-error.d.ts.map +1 -0
- package/dist/server/hooks.d.ts +22 -0
- package/dist/server/hooks.d.ts.map +1 -0
- package/dist/server/request-scopes.d.ts +5 -0
- package/dist/server/request-scopes.d.ts.map +1 -0
- package/dist/shared/server-runtime.d.ts +44 -0
- package/dist/shared/server-runtime.d.ts.map +1 -0
- package/dist/vite/build-identity.d.ts +4 -0
- package/dist/vite/build-identity.d.ts.map +1 -0
- package/dist/vite/identify-environment.d.ts +8 -0
- package/dist/vite/identify-environment.d.ts.map +1 -0
- package/dist/vite/index.d.ts +3 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +5095 -0
- package/dist/vite/module-kind.d.ts +7 -0
- package/dist/vite/module-kind.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +15 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/rasputin-sdk-path.d.ts +7 -0
- package/dist/vite/rasputin-sdk-path.d.ts.map +1 -0
- package/dist/vite/upload-build-artifacts.d.ts +68 -0
- package/dist/vite/upload-build-artifacts.d.ts.map +1 -0
- package/dist/vite/virtual-identity.d.ts +11 -0
- package/dist/vite/virtual-identity.d.ts.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ClientInit, type HandleClientError } from '@sveltejs/kit';
|
|
2
|
+
import type { RasputinSvelteKitClientOptions } from './options';
|
|
3
|
+
export type RasputinSvelteKitClientHooks = {
|
|
4
|
+
init: ClientInit;
|
|
5
|
+
handleError: HandleClientError;
|
|
6
|
+
};
|
|
7
|
+
export type RasputinSvelteKitClientHooksOptions = RasputinSvelteKitClientOptions & {
|
|
8
|
+
init?: ClientInit;
|
|
9
|
+
handleError?: HandleClientError;
|
|
10
|
+
};
|
|
11
|
+
export declare function rasputinClientHooks(options: RasputinSvelteKitClientHooksOptions): RasputinSvelteKitClientHooks;
|
|
12
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/client/hooks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAe,MAAM,eAAe,CAAC;AACrF,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAOhE,MAAM,MAAM,4BAA4B,GAAG;IAC1C,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,iBAAiB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,8BAA8B,GAAG;IAClF,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAOF,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,mCAAmC,GAC1C,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/client/hooks.ts
|
|
2
|
+
import { RasputinInit } from "@rasputin-ai/browser";
|
|
3
|
+
import { isHttpError } from "@sveltejs/kit";
|
|
4
|
+
var shouldCaptureClientError = (error) => {
|
|
5
|
+
if (isHttpError(error)) return false;
|
|
6
|
+
return error instanceof Error || typeof error === "string";
|
|
7
|
+
};
|
|
8
|
+
function rasputinClientHooks(options, internals = {}) {
|
|
9
|
+
const { init: userInit, handleError: userHandleError, ...clientOptions } = options;
|
|
10
|
+
let client;
|
|
11
|
+
const createClient = internals.createClient ?? RasputinInit;
|
|
12
|
+
return {
|
|
13
|
+
init: () => {
|
|
14
|
+
try {
|
|
15
|
+
client = createClient({
|
|
16
|
+
...clientOptions,
|
|
17
|
+
// Event-handler throws never reach Kit handleError.
|
|
18
|
+
installGlobalHandlers: clientOptions.installGlobalHandlers ?? true
|
|
19
|
+
});
|
|
20
|
+
} catch {
|
|
21
|
+
client = void 0;
|
|
22
|
+
}
|
|
23
|
+
return userInit?.();
|
|
24
|
+
},
|
|
25
|
+
handleError: (input) => {
|
|
26
|
+
try {
|
|
27
|
+
if (shouldCaptureClientError(input.error)) {
|
|
28
|
+
client?.captureException(input.error);
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
if (userHandleError) return userHandleError(input);
|
|
33
|
+
return { message: input.message };
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
rasputinClientHooks
|
|
39
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public browser configuration only. The privileged project key cannot appear
|
|
3
|
+
* here, so it is structurally excluded from the client hook API.
|
|
4
|
+
*/
|
|
5
|
+
export type RasputinSvelteKitClientOptions = {
|
|
6
|
+
dsn?: string;
|
|
7
|
+
environment: string;
|
|
8
|
+
release: string;
|
|
9
|
+
buildId?: string;
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
apiUrl?: string;
|
|
12
|
+
logSuccess?: boolean;
|
|
13
|
+
installGlobalHandlers?: boolean;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/client/options.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
export declare const svelteCallMethod: (call: ts.CallExpression | ts.NewExpression) => string | undefined;
|
|
3
|
+
export declare const svelteRuntimeMethod: (node: ts.FunctionLikeDeclaration) => string | undefined;
|
|
4
|
+
export declare const enclosingSvelteRuntimeMethod: (node: ts.FunctionLikeDeclaration) => string | undefined;
|
|
5
|
+
export declare const svelteGeneratedIdentifierCallees: (sourceFile: ts.SourceFile) => Set<string>;
|
|
6
|
+
export declare const isSvelteCompilerCall: (call: ts.CallExpression | ts.NewExpression, sourceFile: ts.SourceFile, identifierCallees?: Set<string>) => boolean;
|
|
7
|
+
//# sourceMappingURL=svelte-generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelte-generated.d.ts","sourceRoot":"","sources":["../../src/compiler/svelte-generated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAsB5B,eAAO,MAAM,gBAAgB,GAC5B,MAAM,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC,aAAa,KACxC,MAAM,GAAG,SAOX,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,MAAM,EAAE,CAAC,uBAAuB,KAAG,MAAM,GAAG,SAK/E,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACxC,MAAM,EAAE,CAAC,uBAAuB,KAC9B,MAAM,GAAG,SAsBX,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAAI,YAAY,EAAE,CAAC,UAAU,KAAG,GAAG,CAAC,MAAM,CAkBtF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAChC,MAAM,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC,aAAa,EAC1C,YAAY,EAAE,CAAC,UAAU,EACzB,oBAAoB,GAAG,CAAC,MAAM,CAAC,KAC7B,OAMF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { RasputinSvelteKitServerHooks, RasputinSvelteKitServerHooksOptions, } from './server/hooks';
|
|
2
|
+
export { rasputinServerHooks } from './server/hooks';
|
|
3
|
+
export type { ServerRuntime, ServerRuntimeCaptureContext, ServerRuntimeRequest, ServerRuntimeScope, ServerRuntimeStartContext, } from './shared/server-runtime';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,4BAA4B,EAC5B,mCAAmC,GACnC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EACX,aAAa,EACb,2BAA2B,EAC3B,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,GACzB,MAAM,yBAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// src/shared/server-runtime.ts
|
|
2
|
+
var unusedErrorObservation = () => Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
3
|
+
|
|
4
|
+
// src/server/expected-error.ts
|
|
5
|
+
import { isActionFailure, isHttpError, isRedirect } from "@sveltejs/kit";
|
|
6
|
+
var isExpectedFrameworkError = (error) => {
|
|
7
|
+
try {
|
|
8
|
+
return isHttpError(error) || isRedirect(error) || isActionFailure(error);
|
|
9
|
+
} catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/server/request-scopes.ts
|
|
15
|
+
var eventScopes = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
var requestBindings = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
var rememberRequestScope = (event, scope) => {
|
|
18
|
+
eventScopes.set(event, scope);
|
|
19
|
+
const request = event.request;
|
|
20
|
+
const existing = requestBindings.get(request);
|
|
21
|
+
if (existing === void 0) {
|
|
22
|
+
requestBindings.set(request, { status: "unique", scope });
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (existing.status === "ambiguous") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (existing.scope !== scope) {
|
|
29
|
+
requestBindings.set(request, { status: "ambiguous" });
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var requestScopeFor = (event) => {
|
|
33
|
+
const exact = eventScopes.get(event);
|
|
34
|
+
if (exact !== void 0) {
|
|
35
|
+
return exact;
|
|
36
|
+
}
|
|
37
|
+
const binding = requestBindings.get(event.request);
|
|
38
|
+
if (binding?.status === "unique") {
|
|
39
|
+
return binding.scope;
|
|
40
|
+
}
|
|
41
|
+
return void 0;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/server/hooks.ts
|
|
45
|
+
var inertScope = () => ({
|
|
46
|
+
run: (callback) => callback(),
|
|
47
|
+
observeError: () => unusedErrorObservation(),
|
|
48
|
+
finish: () => {
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
var finishScope = (scope, status) => {
|
|
52
|
+
try {
|
|
53
|
+
scope.finish(status === void 0 ? void 0 : { status });
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var observeUnexpected = (scope, error) => {
|
|
58
|
+
if (isExpectedFrameworkError(error)) return void 0;
|
|
59
|
+
try {
|
|
60
|
+
return scope.observeError(error);
|
|
61
|
+
} catch {
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var shouldCapture = (options) => {
|
|
66
|
+
if (options.capture !== void 0) return options.capture;
|
|
67
|
+
if (options.building === true) return false;
|
|
68
|
+
if (options.building === false) return true;
|
|
69
|
+
return false;
|
|
70
|
+
};
|
|
71
|
+
var rasputinServerHooks = (options) => {
|
|
72
|
+
const startRuntime = () => {
|
|
73
|
+
try {
|
|
74
|
+
options.server.start({ capture: shouldCapture(options) });
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
startRuntime();
|
|
79
|
+
return {
|
|
80
|
+
init: () => {
|
|
81
|
+
startRuntime();
|
|
82
|
+
return options.init?.();
|
|
83
|
+
},
|
|
84
|
+
handle: ({ event, resolve }) => {
|
|
85
|
+
let scope;
|
|
86
|
+
try {
|
|
87
|
+
scope = options.server.createRequestScope({
|
|
88
|
+
method: event.request.method,
|
|
89
|
+
...event.route.id ? { route: event.route.id } : {}
|
|
90
|
+
});
|
|
91
|
+
rememberRequestScope(event, scope);
|
|
92
|
+
} catch {
|
|
93
|
+
scope = inertScope();
|
|
94
|
+
}
|
|
95
|
+
return scope.run(async () => {
|
|
96
|
+
try {
|
|
97
|
+
const result = await (options.handle ? options.handle({ event, resolve }) : resolve(event));
|
|
98
|
+
finishScope(scope, result.status);
|
|
99
|
+
return result;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
observeUnexpected(scope, error);
|
|
102
|
+
finishScope(scope);
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
handleError: (input) => {
|
|
108
|
+
try {
|
|
109
|
+
if (!isExpectedFrameworkError(input.error)) {
|
|
110
|
+
const scope = requestScopeFor(input.event);
|
|
111
|
+
const observation = scope ? observeUnexpected(scope, input.error) : void 0;
|
|
112
|
+
options.server.captureException(input.error, {
|
|
113
|
+
request: {
|
|
114
|
+
method: input.event.request.method,
|
|
115
|
+
...input.event.route.id ? { route: input.event.route.id } : {},
|
|
116
|
+
status: input.status
|
|
117
|
+
},
|
|
118
|
+
...observation ? { observation } : {}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
}
|
|
123
|
+
if (options.handleError) return options.handleError(input);
|
|
124
|
+
return { message: input.message };
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
rasputinServerHooks
|
|
130
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RasputinNodeOptions } from '@rasputin-ai/node';
|
|
2
|
+
import type { ServerRuntime } from '../shared/server-runtime';
|
|
3
|
+
export type NodeServerRuntimeOptions = RasputinNodeOptions;
|
|
4
|
+
/**
|
|
5
|
+
* SvelteKit reports through `handleError`. Process-global
|
|
6
|
+
* `uncaughtException` / `unhandledRejection` handlers stay off unless
|
|
7
|
+
* `installGlobalHandlers` is explicitly true.
|
|
8
|
+
*/
|
|
9
|
+
export declare function node(options: NodeServerRuntimeOptions): ServerRuntime;
|
|
10
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/runtime/node.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAU7D,OAAO,KAAK,EACX,aAAa,EAKb,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAoJ3D;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// src/runtime/node.ts
|
|
2
|
+
import {
|
|
3
|
+
createClient,
|
|
4
|
+
isClientEnabled
|
|
5
|
+
} from "@rasputin-ai/core";
|
|
6
|
+
import {
|
|
7
|
+
createExecutionRecorder,
|
|
8
|
+
inertErrorObservation,
|
|
9
|
+
installAutomaticExecutionRuntime,
|
|
10
|
+
installGlobalHandlers,
|
|
11
|
+
scheduleInstrumentationManifestUpload
|
|
12
|
+
} from "@rasputin-ai/node/internal";
|
|
13
|
+
|
|
14
|
+
// src/sdk-meta.ts
|
|
15
|
+
var SDK_NAME = "@rasputin-ai/sveltekit";
|
|
16
|
+
var SDK_VERSION = "0.7.0";
|
|
17
|
+
|
|
18
|
+
// src/runtime/node.ts
|
|
19
|
+
var inertScope = () => ({
|
|
20
|
+
run: (callback) => callback(),
|
|
21
|
+
observeError: () => inertErrorObservation(),
|
|
22
|
+
finish: () => {
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var publicScope = (runtime, request) => {
|
|
26
|
+
try {
|
|
27
|
+
const scope = runtime.createScope({
|
|
28
|
+
kind: "http",
|
|
29
|
+
request: {
|
|
30
|
+
method: request.method,
|
|
31
|
+
...request.route ? { route: request.route } : {}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
run: scope.run,
|
|
36
|
+
observeError: scope.observeError,
|
|
37
|
+
finish: (metadata) => {
|
|
38
|
+
scope.finish(
|
|
39
|
+
metadata?.status === void 0 ? void 0 : { request: { status: metadata.status } }
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
} catch {
|
|
44
|
+
return inertScope();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var bindClient = (client, runtime, installRuntime, manifest, uninstallHandlers) => {
|
|
48
|
+
const uninstallRuntime = installRuntime ? installAutomaticExecutionRuntime(runtime) : () => {
|
|
49
|
+
};
|
|
50
|
+
const manifestUpload = scheduleInstrumentationManifestUpload({
|
|
51
|
+
...manifest,
|
|
52
|
+
deferStart: true
|
|
53
|
+
});
|
|
54
|
+
if (manifest.enabled) manifestUpload.start();
|
|
55
|
+
const shutdown = async () => {
|
|
56
|
+
uninstallHandlers();
|
|
57
|
+
uninstallRuntime();
|
|
58
|
+
manifestUpload.disconnect();
|
|
59
|
+
const startedAt = Date.now();
|
|
60
|
+
await client.close();
|
|
61
|
+
await manifestUpload.wait(Math.max(0, 2e3 - (Date.now() - startedAt)));
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
client: {
|
|
65
|
+
...client,
|
|
66
|
+
captureException: (error, context) => {
|
|
67
|
+
const result = client.captureException(error, context);
|
|
68
|
+
manifestUpload.flushSoon();
|
|
69
|
+
return result;
|
|
70
|
+
},
|
|
71
|
+
flush: async (timeoutMs) => {
|
|
72
|
+
const startedAt = Date.now();
|
|
73
|
+
await client.flush(timeoutMs);
|
|
74
|
+
if (timeoutMs === void 0) {
|
|
75
|
+
await manifestUpload.wait();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
await manifestUpload.wait(Math.max(0, timeoutMs - (Date.now() - startedAt)));
|
|
79
|
+
},
|
|
80
|
+
close: shutdown
|
|
81
|
+
},
|
|
82
|
+
close: shutdown
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
var createBoundRuntime = (options, hooks, capture) => {
|
|
86
|
+
const enabled = capture && isClientEnabled(options);
|
|
87
|
+
const recorderEnabled = enabled && options.executionRecorder?.enabled !== false;
|
|
88
|
+
const runtime = createExecutionRecorder({
|
|
89
|
+
...options.executionRecorder,
|
|
90
|
+
enabled: recorderEnabled
|
|
91
|
+
});
|
|
92
|
+
const client = createClient(
|
|
93
|
+
{ ...options, enabled },
|
|
94
|
+
{
|
|
95
|
+
fetch: hooks.fetch,
|
|
96
|
+
announceDeploy: capture && hooks.announceDeploy !== false,
|
|
97
|
+
installTransportSignalHandlers: hooks.installTransportSignalHandlers ?? options.installTransportSignalHandlers,
|
|
98
|
+
sdkVersion: SDK_VERSION,
|
|
99
|
+
sdkName: SDK_NAME,
|
|
100
|
+
resolveObservation: (observation) => runtime.getErrorState(observation)
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
let uninstallHandlers = () => {
|
|
104
|
+
};
|
|
105
|
+
const bound = bindClient(
|
|
106
|
+
client,
|
|
107
|
+
runtime,
|
|
108
|
+
recorderEnabled,
|
|
109
|
+
{
|
|
110
|
+
projectApiKey: options.projectApiKey,
|
|
111
|
+
release: options.release,
|
|
112
|
+
apiUrl: options.apiUrl,
|
|
113
|
+
fetch: hooks.fetch,
|
|
114
|
+
enabled,
|
|
115
|
+
sourceRoot: options.sourceRoot,
|
|
116
|
+
sourceRoots: options.sourceRoots,
|
|
117
|
+
logSuccess: options.logSuccess
|
|
118
|
+
},
|
|
119
|
+
() => uninstallHandlers()
|
|
120
|
+
);
|
|
121
|
+
if (enabled && (hooks.installGlobalHandlers ?? options.installGlobalHandlers) === true) {
|
|
122
|
+
uninstallHandlers = installGlobalHandlers(bound.client);
|
|
123
|
+
}
|
|
124
|
+
return { runtime, client: bound.client, close: bound.close };
|
|
125
|
+
};
|
|
126
|
+
function node(options, hooks = {}) {
|
|
127
|
+
let started;
|
|
128
|
+
let startedLive = false;
|
|
129
|
+
const ensureStarted = (capture) => {
|
|
130
|
+
if (started && (startedLive || !capture)) return started;
|
|
131
|
+
try {
|
|
132
|
+
started = createBoundRuntime(options, hooks, capture);
|
|
133
|
+
startedLive = capture;
|
|
134
|
+
} catch {
|
|
135
|
+
started = createBoundRuntime({ ...options, enabled: false }, hooks, false);
|
|
136
|
+
startedLive = false;
|
|
137
|
+
}
|
|
138
|
+
return started;
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
start: (context) => {
|
|
142
|
+
try {
|
|
143
|
+
ensureStarted(context.capture);
|
|
144
|
+
} catch {
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
createRequestScope: (request) => {
|
|
148
|
+
try {
|
|
149
|
+
const current = started;
|
|
150
|
+
if (!current) return inertScope();
|
|
151
|
+
return publicScope(current.runtime, request);
|
|
152
|
+
} catch {
|
|
153
|
+
return inertScope();
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
captureException: (error, context) => {
|
|
157
|
+
try {
|
|
158
|
+
started?.client.captureException(error, context);
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
flush: async (timeoutMs) => {
|
|
163
|
+
try {
|
|
164
|
+
await started?.client.flush(timeoutMs);
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
close: async () => {
|
|
169
|
+
try {
|
|
170
|
+
await started?.close();
|
|
171
|
+
} catch {
|
|
172
|
+
} finally {
|
|
173
|
+
started = void 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
node
|
|
180
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-meta.d.ts","sourceRoot":"","sources":["../src/sdk-meta.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,eAAO,MAAM,QAAQ,2BAA2B,CAAC;AACjD,eAAO,MAAM,WAAW,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expected-error.d.ts","sourceRoot":"","sources":["../../src/server/expected-error.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,OAMzD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Handle, HandleServerError, ServerInit } from '@sveltejs/kit';
|
|
2
|
+
import { type ServerRuntime } from '../shared/server-runtime';
|
|
3
|
+
export type RasputinSvelteKitServerHooks = {
|
|
4
|
+
init: ServerInit;
|
|
5
|
+
handle: Handle;
|
|
6
|
+
handleError: HandleServerError;
|
|
7
|
+
};
|
|
8
|
+
export type RasputinSvelteKitServerHooksOptions = {
|
|
9
|
+
server: ServerRuntime;
|
|
10
|
+
/**
|
|
11
|
+
* SvelteKit `$app/environment`.building. True during build and prerender.
|
|
12
|
+
* An omitted or non-boolean value fails closed instead of starting capture.
|
|
13
|
+
*/
|
|
14
|
+
building?: boolean;
|
|
15
|
+
/** Overrides `building`. When false, the runtime stays inert. */
|
|
16
|
+
capture?: boolean;
|
|
17
|
+
init?: ServerInit;
|
|
18
|
+
handle?: Handle;
|
|
19
|
+
handleError?: HandleServerError;
|
|
20
|
+
};
|
|
21
|
+
export declare const rasputinServerHooks: (options: RasputinSvelteKitServerHooksOptions) => RasputinSvelteKitServerHooks;
|
|
22
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/server/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EACN,KAAK,aAAa,EAGlB,MAAM,0BAA0B,CAAC;AAIlC,MAAM,MAAM,4BAA4B,GAAG;IAC1C,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,iBAAiB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG;IACjD,MAAM,EAAE,aAAa,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAgCF,eAAO,MAAM,mBAAmB,GAC/B,SAAS,mCAAmC,KAC1C,4BA8DF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import type { ServerRuntimeScope } from '../shared/server-runtime';
|
|
3
|
+
export declare const rememberRequestScope: (event: RequestEvent, scope: ServerRuntimeScope) => void;
|
|
4
|
+
export declare const requestScopeFor: (event: RequestEvent) => ServerRuntimeScope | undefined;
|
|
5
|
+
//# sourceMappingURL=request-scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-scopes.d.ts","sourceRoot":"","sources":["../../src/server/request-scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AASnE,eAAO,MAAM,oBAAoB,GAAI,OAAO,YAAY,EAAE,OAAO,kBAAkB,KAAG,IAcrF,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,YAAY,KAAG,kBAAkB,GAAG,SAU1E,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable server-runtime contract for framework integrations.
|
|
3
|
+
*
|
|
4
|
+
* Frameworks own request lifecycle and metadata. Runtimes own isolation,
|
|
5
|
+
* recording, transport, and platform process behavior. This file must stay
|
|
6
|
+
* free of framework types so Bun, Deno, and Cloudflare can satisfy it later.
|
|
7
|
+
*/
|
|
8
|
+
import type { ErrorObservation, RuntimeExecutionState, RuntimeStateUnavailable } from '@rasputin-ai/core';
|
|
9
|
+
export declare const unusedErrorObservation: () => ErrorObservation;
|
|
10
|
+
export type ServerRuntimeRequest = {
|
|
11
|
+
method: string;
|
|
12
|
+
route?: string;
|
|
13
|
+
};
|
|
14
|
+
export type ServerRuntimeScope = {
|
|
15
|
+
run: <T>(callback: () => T) => T;
|
|
16
|
+
observeError: (error: unknown) => ErrorObservation;
|
|
17
|
+
finish: (metadata?: {
|
|
18
|
+
status?: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
};
|
|
21
|
+
export type ServerRuntimeCaptureContext = {
|
|
22
|
+
request?: {
|
|
23
|
+
method?: string;
|
|
24
|
+
route?: string;
|
|
25
|
+
status?: number;
|
|
26
|
+
};
|
|
27
|
+
observation?: ErrorObservation;
|
|
28
|
+
runtimeState?: RuntimeExecutionState | RuntimeStateUnavailable;
|
|
29
|
+
};
|
|
30
|
+
export type ServerRuntimeStartContext = {
|
|
31
|
+
/**
|
|
32
|
+
* When false, install nothing that sends ingest, announces a deploy,
|
|
33
|
+
* or records production executions. Build analysis and prerender use this.
|
|
34
|
+
*/
|
|
35
|
+
capture: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type ServerRuntime = {
|
|
38
|
+
start: (context: ServerRuntimeStartContext) => void;
|
|
39
|
+
createRequestScope: (request: ServerRuntimeRequest) => ServerRuntimeScope;
|
|
40
|
+
captureException: (error: unknown, context?: ServerRuntimeCaptureContext) => void;
|
|
41
|
+
flush: (timeoutMs?: number) => Promise<void>;
|
|
42
|
+
close: () => Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=server-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-runtime.d.ts","sourceRoot":"","sources":["../../src/shared/server-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACX,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,sBAAsB,QAAO,gBAAsD,CAAC;AAEjG,MAAM,MAAM,oBAAoB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAChC,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,gBAAgB,CAAC;IACnD,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACzC,OAAO,CAAC,EAAE;QACT,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAC/B,YAAY,CAAC,EAAE,qBAAqB,GAAG,uBAAuB,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACvC;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACpD,kBAAkB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,kBAAkB,CAAC;IAC1E,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,2BAA2B,KAAK,IAAI,CAAC;IAClF,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-identity.d.ts","sourceRoot":"","sources":["../../src/vite/build-identity.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,QAAO,MAA6B,CAAC;AAEvE,eAAO,MAAM,qBAAqB,QAAO,MAA6B,CAAC;AAEvE,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,MAKtE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ViteBuildTarget = 'client' | 'ssr';
|
|
2
|
+
export type IdentifiedBuildTarget = ViteBuildTarget | 'unknown';
|
|
3
|
+
export declare const identifyBuildTarget: (input: {
|
|
4
|
+
environmentName?: string;
|
|
5
|
+
ssr?: boolean;
|
|
6
|
+
configSsr?: boolean;
|
|
7
|
+
}) => IdentifiedBuildTarget;
|
|
8
|
+
//# sourceMappingURL=identify-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identify-environment.d.ts","sourceRoot":"","sources":["../../src/vite/identify-environment.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE/C,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG,SAAS,CAAC;AAEhE,eAAO,MAAM,mBAAmB,GAAI,OAAO;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,KAAG,qBAUH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC"}
|