svelte-effect-runtime 1.2.4 → 1.3.1
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/dist/chunks/client-DkW4e4dD.js +199 -0
- package/dist/chunks/client-DkW4e4dD.js.map +1 -0
- package/dist/chunks/effect-CL8GJs8A.js +51 -0
- package/dist/chunks/effect-CL8GJs8A.js.map +1 -0
- package/dist/chunks/effect-compat-BhW0YPIs.js +103 -0
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +1 -0
- package/dist/chunks/{magic-string.es-5gRBdMgP.js → magic-string.es-BnGH-5YR.js} +1 -1
- package/dist/chunks/{magic-string.es-5gRBdMgP.js.map → magic-string.es-BnGH-5YR.js.map} +1 -1
- package/dist/chunks/{markup-Ccw42uCl.js → markup-BpSHnnYD.js} +4 -4
- package/dist/chunks/{markup-Ccw42uCl.js.map → markup-BpSHnnYD.js.map} +1 -1
- package/dist/chunks/preprocess-CtLrnJcK.js +44 -0
- package/dist/chunks/preprocess-CtLrnJcK.js.map +1 -0
- package/dist/chunks/server-DR-6LMdP.js +629 -0
- package/dist/chunks/server-DR-6LMdP.js.map +1 -0
- package/dist/chunks/v3-p8V3Drpp.js +1 -0
- package/dist/chunks/v4-DIhYCbb_.js +1 -0
- package/dist/chunks/vite-DqjXRZd4.js +143 -0
- package/dist/chunks/vite-DqjXRZd4.js.map +1 -0
- package/dist/client.d.ts +1 -64
- package/dist/client.js +2 -170
- package/dist/effect.d.ts +1 -7
- package/dist/effect.js +1 -27
- package/dist/internal/effect-compat.d.ts +21 -0
- package/dist/internal/markup.d.ts +1 -1
- package/dist/internal/markup.js +1 -1
- package/dist/internal/remote-client.js +30 -6
- package/dist/internal/remote-client.js.map +1 -1
- package/dist/internal/transform.d.ts +1 -1
- package/dist/internal/transform.js +3 -4
- package/dist/internal/transform.js.map +1 -1
- package/dist/language-server.d.ts +9 -3
- package/dist/language-server.js +3 -3
- package/dist/mod.d.ts +1 -6
- package/dist/mod.js +3 -5
- package/dist/preprocess.d.ts +23 -6
- package/dist/preprocess.js +10 -31
- package/dist/preprocess.js.map +1 -1
- package/dist/root-node.d.ts +1 -14
- package/dist/root-node.js +63 -8
- package/dist/root-node.js.map +1 -0
- package/dist/server.d.ts +56 -129
- package/dist/server.js +44 -508
- package/dist/server.js.map +1 -1
- package/dist/v3/client.d.ts +93 -0
- package/dist/v3/effect.d.ts +17 -0
- package/dist/v3/mod.d.ts +3 -0
- package/dist/v3/preprocess.d.ts +28 -0
- package/dist/v3/root-node.d.ts +59 -0
- package/dist/v3/server.d.ts +167 -0
- package/dist/v3/vite.d.ts +46 -0
- package/dist/v4/client.d.ts +2 -0
- package/dist/v4/effect.d.ts +24 -0
- package/dist/v4/effect.js +19 -0
- package/dist/v4/effect.js.map +1 -0
- package/dist/v4/mod.d.ts +3 -0
- package/dist/v4/mod.js +3 -0
- package/dist/v4/preprocess.d.ts +30 -0
- package/dist/v4/preprocess.js +28 -0
- package/dist/v4/preprocess.js.map +1 -0
- package/dist/v4/root-node.d.ts +59 -0
- package/dist/v4/root-node.js +4 -0
- package/dist/v4/server.d.ts +124 -0
- package/dist/v4/server.js +22 -0
- package/dist/v4/server.js.map +1 -0
- package/dist/v4/vite.d.ts +34 -0
- package/dist/v4/vite.js +31 -0
- package/dist/v4/vite.js.map +1 -0
- package/dist/vite.d.ts +30 -15
- package/dist/vite.js +18 -101
- package/dist/vite.js.map +1 -1
- package/package.json +46 -3
- package/dist/client.js.map +0 -1
- package/dist/effect.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v4-specific preprocess entrypoints and helpers.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { effect_preprocess } from "svelte-effect-runtime/v4/preprocess";
|
|
7
|
+
*
|
|
8
|
+
* const preprocess = effect_preprocess();
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { PreprocessorGroup } from "svelte/compiler";
|
|
14
|
+
import { type EffectPreprocessOptions } from "../v3/preprocess.js";
|
|
15
|
+
export type { EffectPreprocessOptions } from "../v3/preprocess.js";
|
|
16
|
+
export declare const V4_RUNTIME_MODULE_ID = "svelte-effect-runtime/v4";
|
|
17
|
+
/**
|
|
18
|
+
* Apply the default v4 runtime module id to a preprocess options bag.
|
|
19
|
+
*
|
|
20
|
+
* @internal Internal — do not use.
|
|
21
|
+
*/
|
|
22
|
+
export declare function with_v4_effect_preprocess_options(options?: EffectPreprocessOptions): EffectPreprocessOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Low-level Svelte preprocessor for the v4 runtime entry.
|
|
25
|
+
*
|
|
26
|
+
* Advanced entry point used by tooling and custom build setups.
|
|
27
|
+
*
|
|
28
|
+
* @see https://ser.barekey.dev/content/reference/preprocess
|
|
29
|
+
*/
|
|
30
|
+
export declare function effect_preprocess(options?: EffectPreprocessOptions): PreprocessorGroup;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { t as effect_preprocess$1 } from "../chunks/preprocess-CtLrnJcK.js";
|
|
2
|
+
//#region v4/preprocess.ts
|
|
3
|
+
const V4_RUNTIME_MODULE_ID = "svelte-effect-runtime/v4";
|
|
4
|
+
/**
|
|
5
|
+
* Apply the default v4 runtime module id to a preprocess options bag.
|
|
6
|
+
*
|
|
7
|
+
* @internal Internal — do not use.
|
|
8
|
+
*/
|
|
9
|
+
function with_v4_effect_preprocess_options(options = {}) {
|
|
10
|
+
return {
|
|
11
|
+
...options,
|
|
12
|
+
runtimeModuleId: options.runtimeModuleId ?? "svelte-effect-runtime/v4"
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Low-level Svelte preprocessor for the v4 runtime entry.
|
|
17
|
+
*
|
|
18
|
+
* Advanced entry point used by tooling and custom build setups.
|
|
19
|
+
*
|
|
20
|
+
* @see https://ser.barekey.dev/content/reference/preprocess
|
|
21
|
+
*/
|
|
22
|
+
function effect_preprocess(options = {}) {
|
|
23
|
+
return effect_preprocess$1(with_v4_effect_preprocess_options(options));
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { V4_RUNTIME_MODULE_ID, effect_preprocess, with_v4_effect_preprocess_options };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=preprocess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preprocess.js","names":["create_effect_preprocess"],"sources":["../../../modules/svelte-effect-runtime/v4/preprocess.ts"],"sourcesContent":["/**\n * v4-specific preprocess entrypoints and helpers.\n *\n * @example\n * ```ts\n * import { effect_preprocess } from \"svelte-effect-runtime/v4/preprocess\";\n *\n * const preprocess = effect_preprocess();\n * ```\n *\n * @module\n */\nimport type { PreprocessorGroup } from \"svelte/compiler\";\nimport {\n effect_preprocess as create_effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\n\nexport type { EffectPreprocessOptions } from \"$/v3/preprocess.ts\";\n\nexport const V4_RUNTIME_MODULE_ID = \"svelte-effect-runtime/v4\";\n\n/**\n * Apply the default v4 runtime module id to a preprocess options bag.\n *\n * @internal Internal — do not use.\n */\nexport function with_v4_effect_preprocess_options(\n options: EffectPreprocessOptions = {},\n): EffectPreprocessOptions {\n return {\n ...options,\n runtimeModuleId: options.runtimeModuleId ?? V4_RUNTIME_MODULE_ID,\n };\n}\n\n/**\n * Low-level Svelte preprocessor for the v4 runtime entry.\n *\n * Advanced entry point used by tooling and custom build setups.\n *\n * @see https://ser.barekey.dev/content/reference/preprocess\n */\nexport function effect_preprocess(\n options: EffectPreprocessOptions = {},\n): PreprocessorGroup {\n return create_effect_preprocess(with_v4_effect_preprocess_options(options));\n}\n"],"mappings":";;AAoBA,MAAa,uBAAuB;;;;;;AAOpC,SAAgB,kCACd,UAAmC,EAAE,EACZ;AACzB,QAAO;EACL,GAAG;EACH,iBAAiB,QAAQ,mBAAA;EAC1B;;;;;;;;;AAUH,SAAgB,kBACd,UAAmC,EAAE,EAClB;AACnB,QAAOA,oBAAyB,kCAAkC,QAAQ,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type * as Server_module from "./server.js";
|
|
2
|
+
export * from "./mod.js";
|
|
3
|
+
export type * from "./server.js";
|
|
4
|
+
export type { EffectPluginOptions } from "./effect.js";
|
|
5
|
+
export { effect } from "./effect.js";
|
|
6
|
+
/**
|
|
7
|
+
* Define a read-only remote function that returns an `Effect` on the client.
|
|
8
|
+
*
|
|
9
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
10
|
+
*/
|
|
11
|
+
export declare const Query: typeof Server_module.Query;
|
|
12
|
+
/**
|
|
13
|
+
* Define a write-oriented remote function that returns an `Effect` on the
|
|
14
|
+
* client.
|
|
15
|
+
*
|
|
16
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
17
|
+
*/
|
|
18
|
+
export declare const Command: typeof Server_module.Command;
|
|
19
|
+
/**
|
|
20
|
+
* Define a remote form handler that maps submitted data into an Effect
|
|
21
|
+
* program.
|
|
22
|
+
*
|
|
23
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
24
|
+
*/
|
|
25
|
+
export declare const Form: typeof Server_module.Form;
|
|
26
|
+
/**
|
|
27
|
+
* Define a prerenderable remote function backed by an Effect program.
|
|
28
|
+
*
|
|
29
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
30
|
+
*/
|
|
31
|
+
export declare const Prerender: typeof Server_module.Prerender;
|
|
32
|
+
/**
|
|
33
|
+
* Effect `Context.Tag` for the current SvelteKit `RequestEvent`.
|
|
34
|
+
*
|
|
35
|
+
* @see https://ser.barekey.dev/content/runtimes/server
|
|
36
|
+
*/
|
|
37
|
+
export declare const RequestEvent: typeof Server_module.RequestEvent;
|
|
38
|
+
/**
|
|
39
|
+
* Server-side runtime builder used to provide long-lived Effect services to
|
|
40
|
+
* remote functions.
|
|
41
|
+
*
|
|
42
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
43
|
+
*/
|
|
44
|
+
export declare const ServerRuntime: typeof Server_module.ServerRuntime;
|
|
45
|
+
/**
|
|
46
|
+
* Build a devalue transport table from Effect schemas so remote payloads can
|
|
47
|
+
* round-trip custom data across the client/server boundary.
|
|
48
|
+
*
|
|
49
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
50
|
+
*/
|
|
51
|
+
export declare const create_effect_transport: typeof Server_module.create_effect_transport;
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the active server runtime, lazily creating a default empty runtime
|
|
54
|
+
* when no explicit one has been registered.
|
|
55
|
+
*
|
|
56
|
+
* @internal Internal - do not use.
|
|
57
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
58
|
+
*/
|
|
59
|
+
export declare const get_server_runtime_or_throw: typeof Server_module.get_server_runtime_or_throw;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "../chunks/client-DkW4e4dD.js";
|
|
2
|
+
import "../chunks/v4-DIhYCbb_.js";
|
|
3
|
+
import { effect } from "./effect.js";
|
|
4
|
+
export { ClientRuntime, effect, get_effect_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { RemoteForm as SvelteKitRemoteForm, RemoteFormInput as SvelteKitRemoteFormInput } from "@sveltejs/kit";
|
|
2
|
+
import type { getRequestEvent as get_native_request_event } from "$app/server";
|
|
3
|
+
import type { Effect as Effect_type, Layer as Layer_type } from "effect";
|
|
4
|
+
import * as base_server from "../v3/server.js";
|
|
5
|
+
import type { FormError, RemoteFailure } from "../internal/remote-shared.js";
|
|
6
|
+
import { type EffectContextKey, type EffectSchemaLike } from "../internal/effect-compat.js";
|
|
7
|
+
export interface Transporter<T = unknown, U = {
|
|
8
|
+
value: unknown;
|
|
9
|
+
}> {
|
|
10
|
+
decode: (data: U) => T;
|
|
11
|
+
encode: (value: T) => false | U;
|
|
12
|
+
}
|
|
13
|
+
export type Transport = Record<string, Transporter>;
|
|
14
|
+
export type RemoteFormInput = SvelteKitRemoteFormInput;
|
|
15
|
+
export type RemoteQueryFunction<Input, Output> = (arg: OptionalArgument<Input>) => Promise<Output>;
|
|
16
|
+
export type RemoteCommand<Input, Output> = ((arg: OptionalArgument<Input>) => Promise<Output> & {
|
|
17
|
+
updates(...updates: Array<unknown>): Promise<Output>;
|
|
18
|
+
}) & {
|
|
19
|
+
readonly pending: number;
|
|
20
|
+
};
|
|
21
|
+
export type RemotePrerenderFunction<Input, Output> = (arg: OptionalArgument<Input>) => Promise<Output>;
|
|
22
|
+
export type RemoteForm<Input extends RemoteFormInput | void, Output> = SvelteKitRemoteForm<Input, Output>;
|
|
23
|
+
type OptionalArgument<Input> = undefined extends Input ? Input | void : Input;
|
|
24
|
+
type RuntimeOperator = (self: Layer_type.Layer<unknown, unknown, unknown>) => Layer_type.Layer<unknown, unknown, unknown>;
|
|
25
|
+
type RuntimeSeedLayer<Requirements> = Layer_type.Layer<Requirements, never, Requirements>;
|
|
26
|
+
type ProvidedBy<Op> = Op extends (self: RuntimeSeedLayer<infer Requirements>) => Layer_type.Layer<unknown, unknown, infer Incoming> ? Exclude<Requirements, Incoming> : never;
|
|
27
|
+
type ProvidedByAll<Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends readonly [infer Head, ...infer Tail] ? ProvidedBy<Head> | ProvidedByAll<Extract<Tail, ReadonlyArray<RuntimeOperator>>> : never;
|
|
28
|
+
type ApplyOperator<Seed, Op> = Op extends (self: Seed) => infer Out ? Out : never;
|
|
29
|
+
type ApplyOperators<Seed, Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends readonly [infer Head, ...infer Tail] ? ApplyOperators<ApplyOperator<Seed, Head>, Extract<Tail, ReadonlyArray<RuntimeOperator>>> : Seed;
|
|
30
|
+
type FinalRuntimeLayer<Ops extends ReadonlyArray<RuntimeOperator>> = ApplyOperators<RuntimeSeedLayer<ProvidedByAll<Ops>>, Ops> extends infer Out ? Out extends Layer_type.Layer<unknown, unknown, infer Incoming> ? [Incoming] extends [never] ? Out : never : never : never;
|
|
31
|
+
type SchemaInput<SchemaType extends EffectSchemaLike> = SchemaType extends {
|
|
32
|
+
readonly Encoded: infer Input;
|
|
33
|
+
} ? Input : never;
|
|
34
|
+
type SchemaOutput<SchemaType extends EffectSchemaLike> = SchemaType extends {
|
|
35
|
+
readonly Type: infer Output;
|
|
36
|
+
} ? Output : never;
|
|
37
|
+
type FieldHelpers<FormShape, SchemaType> = FormShape extends Record<string, unknown> ? {
|
|
38
|
+
[Key in keyof FormShape as Key extends string ? Key : never]: (message: string) => Effect_type.Effect<never, FormError<SchemaType>, never>;
|
|
39
|
+
} : Record<PropertyKey, never>;
|
|
40
|
+
export type Invalid<SchemaType = unknown> = {
|
|
41
|
+
form: (message: string) => Effect_type.Effect<never, FormError<SchemaType>, never>;
|
|
42
|
+
} & FieldHelpers<SchemaType extends EffectSchemaLike ? SchemaOutput<SchemaType> : unknown, SchemaType>;
|
|
43
|
+
export type EffectQueryFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
44
|
+
native: RemoteQueryFunction<Input, Output>;
|
|
45
|
+
};
|
|
46
|
+
export type EffectCommand<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
47
|
+
native: RemoteCommand<Input, Output>;
|
|
48
|
+
readonly pending: number;
|
|
49
|
+
};
|
|
50
|
+
export type EffectPrerenderFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
51
|
+
native: RemotePrerenderFunction<Input, Output>;
|
|
52
|
+
};
|
|
53
|
+
export type EffectForm<Input extends RemoteFormInput | void, Output, Error = never> = RemoteForm<Input, Output> & {
|
|
54
|
+
native: RemoteForm<Input, Output>;
|
|
55
|
+
submit(data: OptionalArgument<Input>): Effect_type.Effect<Output, RemoteFailure<Error>, never>;
|
|
56
|
+
for: RemoteForm<Input, Output>["for"] extends (...args: infer Args) => infer Result ? (...args: Args) => EffectForm<Input, Output, Error> & Result : never;
|
|
57
|
+
};
|
|
58
|
+
export type RequestEventService = ReturnType<typeof get_native_request_event>;
|
|
59
|
+
export interface ServerRuntimeSeed {
|
|
60
|
+
pipe(): Layer_type.Layer<never>;
|
|
61
|
+
pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): FinalRuntimeLayer<Ops>;
|
|
62
|
+
make(): void;
|
|
63
|
+
make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): void;
|
|
64
|
+
}
|
|
65
|
+
export interface EffectManagedRuntime {
|
|
66
|
+
runPromiseExit<A, E, R>(effect: Effect_type.Effect<A, E, R>): Promise<unknown>;
|
|
67
|
+
dispose(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
export interface EffectQueryBatchFactory {
|
|
70
|
+
(...args: Array<unknown>): unknown;
|
|
71
|
+
}
|
|
72
|
+
export interface EffectQueryFactory {
|
|
73
|
+
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<void, Output, Error>;
|
|
74
|
+
<Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<Input, Output, Error>;
|
|
75
|
+
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<SchemaInput<SchemaType>, Output, Error>;
|
|
76
|
+
batch: EffectQueryBatchFactory;
|
|
77
|
+
}
|
|
78
|
+
export interface EffectCommandFactory {
|
|
79
|
+
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<void, Output, Error>;
|
|
80
|
+
<Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<Input, Output, Error>;
|
|
81
|
+
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<SchemaInput<SchemaType>, Output, Error>;
|
|
82
|
+
}
|
|
83
|
+
type RemotePrerenderInputsGenerator<Input> = (event: RequestEventService) => AsyncIterable<Input> | Iterable<Input>;
|
|
84
|
+
export interface EffectFormFactory {
|
|
85
|
+
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectForm<void, Output, Error>;
|
|
86
|
+
<Input extends RemoteFormInput, Output, Error, Requirements>(validate: "unchecked", fn: (args: {
|
|
87
|
+
data: Input;
|
|
88
|
+
invalid: Invalid;
|
|
89
|
+
}) => Effect_type.Effect<Output, Error | FormError, Requirements>): EffectForm<Input, Output, Error>;
|
|
90
|
+
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (args: {
|
|
91
|
+
data: SchemaOutput<SchemaType>;
|
|
92
|
+
invalid: Invalid<SchemaType>;
|
|
93
|
+
}) => Effect_type.Effect<Output, Error | FormError<SchemaType>, Requirements>): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, Error>;
|
|
94
|
+
}
|
|
95
|
+
export interface EffectPrerenderFactory {
|
|
96
|
+
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>, options?: {
|
|
97
|
+
inputs?: RemotePrerenderInputsGenerator<void>;
|
|
98
|
+
dynamic?: boolean;
|
|
99
|
+
}): EffectPrerenderFunction<void, Output, Error>;
|
|
100
|
+
<Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>, options?: {
|
|
101
|
+
inputs?: RemotePrerenderInputsGenerator<Input>;
|
|
102
|
+
dynamic?: boolean;
|
|
103
|
+
}): EffectPrerenderFunction<Input, Output, Error>;
|
|
104
|
+
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>, options?: {
|
|
105
|
+
inputs?: RemotePrerenderInputsGenerator<SchemaInput<SchemaType>>;
|
|
106
|
+
dynamic?: boolean;
|
|
107
|
+
}): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, Error>;
|
|
108
|
+
}
|
|
109
|
+
export declare const Query: EffectQueryFactory;
|
|
110
|
+
export declare const Command: EffectCommandFactory;
|
|
111
|
+
export declare const Form: EffectFormFactory;
|
|
112
|
+
export declare const Prerender: EffectPrerenderFactory;
|
|
113
|
+
export declare const RequestEvent: EffectContextKey<RequestEventService, RequestEventService> & Effect_type.Effect<RequestEventService, never, RequestEventService>;
|
|
114
|
+
export declare const ServerRuntime: ServerRuntimeSeed;
|
|
115
|
+
export declare const create_effect_transport: typeof base_server.create_effect_transport;
|
|
116
|
+
export declare const get_server_runtime_or_throw: () => EffectManagedRuntime;
|
|
117
|
+
/**
|
|
118
|
+
* Remap low-level request-store crashes into a clearer setup error when remote
|
|
119
|
+
* helpers are evaluated outside SvelteKit's remote-function runtime.
|
|
120
|
+
*
|
|
121
|
+
* @internal Internal - do not use.
|
|
122
|
+
*/
|
|
123
|
+
export declare const normalize_remote_helper_error: typeof base_server.normalize_remote_helper_error;
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { a as make_context_key } from "../chunks/effect-compat-BhW0YPIs.js";
|
|
2
|
+
import { c as get_server_runtime_or_throw$1, i as Query$1, l as normalize_remote_helper_error$1, n as Form$1, o as ServerRuntime$1, r as Prerender$1, s as create_effect_transport$1, t as Command$1 } from "../chunks/server-DR-6LMdP.js";
|
|
3
|
+
//#region v4/server.ts
|
|
4
|
+
const Query = Query$1;
|
|
5
|
+
const Command = Command$1;
|
|
6
|
+
const Form = Form$1;
|
|
7
|
+
const Prerender = Prerender$1;
|
|
8
|
+
const RequestEvent = make_context_key("svelte-effect-runtime/RequestEvent");
|
|
9
|
+
const ServerRuntime = ServerRuntime$1;
|
|
10
|
+
const create_effect_transport = create_effect_transport$1;
|
|
11
|
+
const get_server_runtime_or_throw = get_server_runtime_or_throw$1;
|
|
12
|
+
/**
|
|
13
|
+
* Remap low-level request-store crashes into a clearer setup error when remote
|
|
14
|
+
* helpers are evaluated outside SvelteKit's remote-function runtime.
|
|
15
|
+
*
|
|
16
|
+
* @internal Internal - do not use.
|
|
17
|
+
*/
|
|
18
|
+
const normalize_remote_helper_error = normalize_remote_helper_error$1;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Command, Form, Prerender, Query, RequestEvent, ServerRuntime, create_effect_transport, get_server_runtime_or_throw, normalize_remote_helper_error };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","names":["base_server.Query","base_server.Command","base_server.Form","base_server.Prerender","base_server.ServerRuntime","base_server.create_effect_transport","base_server.get_server_runtime_or_throw","base_server.normalize_remote_helper_error"],"sources":["../../../modules/svelte-effect-runtime/v4/server.ts"],"sourcesContent":["import type {\n RemoteForm as SvelteKitRemoteForm,\n RemoteFormInput as SvelteKitRemoteFormInput,\n} from \"@sveltejs/kit\";\nimport type { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport type { Effect as Effect_type, Layer as Layer_type } from \"effect\";\nimport * as base_server from \"$/v3/server.ts\";\nimport type { FormError, RemoteFailure } from \"$internal/remote-shared.ts\";\nimport {\n type EffectContextKey,\n type EffectSchemaLike,\n make_context_key,\n} from \"$internal/effect-compat.ts\";\n\nexport interface Transporter<T = unknown, U = { value: unknown }> {\n decode: (data: U) => T;\n encode: (value: T) => false | U;\n}\n\nexport type Transport = Record<string, Transporter>;\n\nexport type RemoteFormInput = SvelteKitRemoteFormInput;\n\nexport type RemoteQueryFunction<Input, Output> = (\n arg: OptionalArgument<Input>,\n) => Promise<Output>;\n\nexport type RemoteCommand<Input, Output> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Promise<Output> & {\n updates(...updates: Array<unknown>): Promise<Output>;\n })\n & {\n readonly pending: number;\n };\n\nexport type RemotePrerenderFunction<Input, Output> = (\n arg: OptionalArgument<Input>,\n) => Promise<Output>;\n\nexport type RemoteForm<Input extends RemoteFormInput | void, Output> =\n SvelteKitRemoteForm<Input, Output>;\n\ntype OptionalArgument<Input> = undefined extends Input ? Input | void : Input;\n\ntype RuntimeOperator = (\n self: Layer_type.Layer<unknown, unknown, unknown>,\n) => Layer_type.Layer<unknown, unknown, unknown>;\n\ntype RuntimeSeedLayer<Requirements> = Layer_type.Layer<\n Requirements,\n never,\n Requirements\n>;\n\ntype ProvidedBy<Op> = Op extends (\n self: RuntimeSeedLayer<infer Requirements>,\n) => Layer_type.Layer<unknown, unknown, infer Incoming>\n ? Exclude<Requirements, Incoming>\n : never;\n\ntype ProvidedByAll<Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends\n readonly [infer Head, ...infer Tail] ?\n | ProvidedBy<Head>\n | ProvidedByAll<Extract<Tail, ReadonlyArray<RuntimeOperator>>>\n : never;\n\ntype ApplyOperator<Seed, Op> = Op extends (self: Seed) => infer Out ? Out\n : never;\n\ntype ApplyOperators<\n Seed,\n Ops extends ReadonlyArray<RuntimeOperator>,\n> = Ops extends readonly [infer Head, ...infer Tail] ? ApplyOperators<\n ApplyOperator<Seed, Head>,\n Extract<Tail, ReadonlyArray<RuntimeOperator>>\n >\n : Seed;\n\ntype FinalRuntimeLayer<Ops extends ReadonlyArray<RuntimeOperator>> =\n ApplyOperators<RuntimeSeedLayer<ProvidedByAll<Ops>>, Ops> extends infer Out\n ? Out extends Layer_type.Layer<unknown, unknown, infer Incoming>\n ? [Incoming] extends [never] ? Out\n : never\n : never\n : never;\n\ntype SchemaInput<SchemaType extends EffectSchemaLike> = SchemaType extends\n { readonly Encoded: infer Input } ? Input\n : never;\n\ntype SchemaOutput<SchemaType extends EffectSchemaLike> = SchemaType extends\n { readonly Type: infer Output } ? Output\n : never;\n\ntype FieldHelpers<FormShape, SchemaType> = FormShape extends\n Record<string, unknown> ? {\n [Key in keyof FormShape as Key extends string ? Key : never]: (\n message: string,\n ) => Effect_type.Effect<never, FormError<SchemaType>, never>;\n }\n : Record<PropertyKey, never>;\n\nexport type Invalid<SchemaType = unknown> =\n & {\n form: (\n message: string,\n ) => Effect_type.Effect<never, FormError<SchemaType>, never>;\n }\n & FieldHelpers<\n SchemaType extends EffectSchemaLike ? SchemaOutput<SchemaType> : unknown,\n SchemaType\n >;\n\nexport type EffectQueryFunction<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n native: RemoteQueryFunction<Input, Output>;\n };\n\nexport type EffectCommand<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n native: RemoteCommand<Input, Output>;\n readonly pending: number;\n };\n\nexport type EffectPrerenderFunction<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n native: RemotePrerenderFunction<Input, Output>;\n };\n\nexport type EffectForm<\n Input extends RemoteFormInput | void,\n Output,\n Error = never,\n> = RemoteForm<Input, Output> & {\n native: RemoteForm<Input, Output>;\n submit(\n data: OptionalArgument<Input>,\n ): Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >;\n for: RemoteForm<Input, Output>[\"for\"] extends\n (...args: infer Args) => infer Result\n ? (...args: Args) => EffectForm<Input, Output, Error> & Result\n : never;\n};\n\nexport type RequestEventService = ReturnType<typeof get_native_request_event>;\n\nexport interface ServerRuntimeSeed {\n pipe(): Layer_type.Layer<never>;\n pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): FinalRuntimeLayer<Ops>;\n make(): void;\n make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): void;\n}\n\nexport interface EffectManagedRuntime {\n runPromiseExit<A, E, R>(\n effect: Effect_type.Effect<A, E, R>,\n ): Promise<unknown>;\n dispose(): Promise<void>;\n}\n\nexport interface EffectQueryBatchFactory {\n (...args: Array<unknown>): unknown;\n}\n\nexport interface EffectQueryFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<void, Output, Error>;\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<SchemaInput<SchemaType>, Output, Error>;\n batch: EffectQueryBatchFactory;\n}\n\nexport interface EffectCommandFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<void, Output, Error>;\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<SchemaInput<SchemaType>, Output, Error>;\n}\n\ntype RemotePrerenderInputsGenerator<Input> = (\n event: RequestEventService,\n) => AsyncIterable<Input> | Iterable<Input>;\n\nexport interface EffectFormFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectForm<void, Output, Error>;\n <Input extends RemoteFormInput, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (\n args: {\n data: Input;\n invalid: Invalid;\n },\n ) => Effect_type.Effect<Output, Error | FormError, Requirements>,\n ): EffectForm<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n args: {\n data: SchemaOutput<SchemaType>;\n invalid: Invalid<SchemaType>;\n },\n ) => Effect_type.Effect<\n Output,\n Error | FormError<SchemaType>,\n Requirements\n >,\n ): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, Error>;\n}\n\nexport interface EffectPrerenderFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<void>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<void, Output, Error>;\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<Input>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<SchemaInput<SchemaType>>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, Error>;\n}\n\nexport const Query: EffectQueryFactory = base_server.Query;\nexport const Command: EffectCommandFactory = base_server.Command;\nexport const Form: EffectFormFactory = base_server.Form;\nexport const Prerender: EffectPrerenderFactory = base_server.Prerender;\nexport const RequestEvent = make_context_key<\n RequestEventService,\n RequestEventService\n>(\n \"svelte-effect-runtime/RequestEvent\",\n) as\n & EffectContextKey<RequestEventService, RequestEventService>\n & Effect_type.Effect<RequestEventService, never, RequestEventService>;\nexport const ServerRuntime: ServerRuntimeSeed = base_server.ServerRuntime;\nexport const create_effect_transport:\n typeof base_server.create_effect_transport =\n base_server.create_effect_transport;\nexport const get_server_runtime_or_throw: () => EffectManagedRuntime =\n base_server.get_server_runtime_or_throw;\n/**\n * Remap low-level request-store crashes into a clearer setup error when remote\n * helpers are evaluated outside SvelteKit's remote-function runtime.\n *\n * @internal Internal - do not use.\n */\nexport const normalize_remote_helper_error =\n base_server.normalize_remote_helper_error;\n"],"mappings":";;;AAgSA,MAAa,QAA4BA;AACzC,MAAa,UAAgCC;AAC7C,MAAa,OAA0BC;AACvC,MAAa,YAAoCC;AACjD,MAAa,eAAe,iBAI1B,qCACD;AAGD,MAAa,gBAAmCC;AAChD,MAAa,0BAETC;AACJ,MAAa,8BACXC;;;;;;;AAOF,MAAa,gCACXC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v4-specific low-level Vite entrypoints for `svelte-effect-runtime`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { sveltekit_effect_runtime } from "svelte-effect-runtime/v4/vite";
|
|
7
|
+
*
|
|
8
|
+
* export default {
|
|
9
|
+
* plugins: [sveltekit_effect_runtime()],
|
|
10
|
+
* };
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type { Plugin } from "vite";
|
|
16
|
+
import { type SvelteEffectRuntimeOptions, type SveltekitEffectRuntimeOptions } from "../v3/vite.js";
|
|
17
|
+
export type { SvelteEffectRuntimeOptions, SveltekitEffectRuntimeOptions, } from "../v3/vite.js";
|
|
18
|
+
/**
|
|
19
|
+
* Low-level Vite plugin wrapper for non-SvelteKit builds targeting the v4
|
|
20
|
+
* runtime module id.
|
|
21
|
+
*
|
|
22
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
23
|
+
*/
|
|
24
|
+
export declare function svelte_effect_runtime(options?: SvelteEffectRuntimeOptions): Plugin[];
|
|
25
|
+
/**
|
|
26
|
+
* Low-level Vite plugin that swaps SvelteKit's generated remote client module
|
|
27
|
+
* for the Effect-aware adapters used by `effect()` when targeting the v4
|
|
28
|
+
* runtime entry.
|
|
29
|
+
*
|
|
30
|
+
* Prefer `effect()` unless you are assembling a custom Vite plugin stack.
|
|
31
|
+
*
|
|
32
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
33
|
+
*/
|
|
34
|
+
export declare function sveltekit_effect_runtime(options?: SveltekitEffectRuntimeOptions): Plugin;
|
package/dist/v4/vite.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { n as sveltekit_effect_runtime$1, t as svelte_effect_runtime$1 } from "../chunks/vite-DqjXRZd4.js";
|
|
2
|
+
import { with_v4_effect_preprocess_options } from "./preprocess.js";
|
|
3
|
+
//#region v4/vite.ts
|
|
4
|
+
/**
|
|
5
|
+
* Low-level Vite plugin wrapper for non-SvelteKit builds targeting the v4
|
|
6
|
+
* runtime module id.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
9
|
+
*/
|
|
10
|
+
function svelte_effect_runtime(options = {}) {
|
|
11
|
+
return svelte_effect_runtime$1({
|
|
12
|
+
...options,
|
|
13
|
+
effect: with_v4_effect_preprocess_options(options.effect)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Low-level Vite plugin that swaps SvelteKit's generated remote client module
|
|
18
|
+
* for the Effect-aware adapters used by `effect()` when targeting the v4
|
|
19
|
+
* runtime entry.
|
|
20
|
+
*
|
|
21
|
+
* Prefer `effect()` unless you are assembling a custom Vite plugin stack.
|
|
22
|
+
*
|
|
23
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
24
|
+
*/
|
|
25
|
+
function sveltekit_effect_runtime(options = {}) {
|
|
26
|
+
return sveltekit_effect_runtime$1(options);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { svelte_effect_runtime, sveltekit_effect_runtime };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=vite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","names":["create_svelte_effect_runtime","create_sveltekit_effect_runtime"],"sources":["../../../modules/svelte-effect-runtime/v4/vite.ts"],"sourcesContent":["/**\n * v4-specific low-level Vite entrypoints for `svelte-effect-runtime`.\n *\n * @example\n * ```ts\n * import { sveltekit_effect_runtime } from \"svelte-effect-runtime/v4/vite\";\n *\n * export default {\n * plugins: [sveltekit_effect_runtime()],\n * };\n * ```\n *\n * @module\n */\nimport type { Plugin } from \"vite\";\nimport {\n svelte_effect_runtime as create_svelte_effect_runtime,\n type SvelteEffectRuntimeOptions,\n sveltekit_effect_runtime as create_sveltekit_effect_runtime,\n type SveltekitEffectRuntimeOptions,\n} from \"$/v3/vite.ts\";\nimport { with_v4_effect_preprocess_options } from \"$/v4/preprocess.ts\";\n\nexport type {\n SvelteEffectRuntimeOptions,\n SveltekitEffectRuntimeOptions,\n} from \"$/v3/vite.ts\";\n\n/**\n * Low-level Vite plugin wrapper for non-SvelteKit builds targeting the v4\n * runtime module id.\n *\n * @see https://ser.barekey.dev/content/reference/tooling\n */\nexport function svelte_effect_runtime(\n options: SvelteEffectRuntimeOptions = {},\n): Plugin[] {\n return create_svelte_effect_runtime({\n ...options,\n effect: with_v4_effect_preprocess_options(options.effect),\n });\n}\n\n/**\n * Low-level Vite plugin that swaps SvelteKit's generated remote client module\n * for the Effect-aware adapters used by `effect()` when targeting the v4\n * runtime entry.\n *\n * Prefer `effect()` unless you are assembling a custom Vite plugin stack.\n *\n * @see https://ser.barekey.dev/content/reference/tooling\n */\nexport function sveltekit_effect_runtime(\n options: SveltekitEffectRuntimeOptions = {},\n): Plugin {\n return create_sveltekit_effect_runtime(options);\n}\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,sBACd,UAAsC,EAAE,EAC9B;AACV,QAAOA,wBAA6B;EAClC,GAAG;EACH,QAAQ,kCAAkC,QAAQ,OAAO;EAC1D,CAAC;;;;;;;;;;;AAYJ,SAAgB,yBACd,UAAyC,EAAE,EACnC;AACR,QAAOC,2BAAgC,QAAQ"}
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Public Vite entrypoint wrappers for `svelte-effect-runtime`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { sveltekit_effect_runtime } from "svelte-effect-runtime/vite";
|
|
7
|
+
*
|
|
8
|
+
* export default {
|
|
9
|
+
* plugins: [sveltekit_effect_runtime()],
|
|
10
|
+
* };
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
2
15
|
import type { Plugin } from "vite";
|
|
3
|
-
import { type
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
import { type SvelteEffectRuntimeOptions, type SveltekitEffectRuntimeOptions } from "./v3/vite.js";
|
|
17
|
+
export type { SvelteEffectRuntimeOptions, SveltekitEffectRuntimeOptions, } from "./v3/vite.js";
|
|
18
|
+
/**
|
|
19
|
+
* Compose the low-level Svelte preprocessor directly into a plain Vite +
|
|
20
|
+
* Svelte project.
|
|
21
|
+
*
|
|
22
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
23
|
+
*/
|
|
24
|
+
export declare function svelte_effect_runtime(options?: SvelteEffectRuntimeOptions): Plugin[];
|
|
25
|
+
/**
|
|
26
|
+
* Install the remote-function adapter that rewrites SvelteKit remote helpers
|
|
27
|
+
* to return `Effect` values.
|
|
28
|
+
*
|
|
29
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
30
|
+
*/
|
|
31
|
+
export declare function sveltekit_effect_runtime(options?: SveltekitEffectRuntimeOptions): Plugin;
|
package/dist/vite.js
CHANGED
|
@@ -1,107 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import { dirname, resolve } from "node:path";
|
|
5
|
-
import process from "node:process";
|
|
6
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
1
|
+
import { n as sveltekit_effect_runtime$1, t as svelte_effect_runtime$1 } from "./chunks/vite-DqjXRZd4.js";
|
|
7
2
|
//#region vite.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Compose the low-level Svelte preprocessor directly into a plain Vite +
|
|
5
|
+
* Svelte project.
|
|
6
|
+
*
|
|
7
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
8
|
+
*/
|
|
9
|
+
function svelte_effect_runtime(options) {
|
|
10
|
+
return svelte_effect_runtime$1(options);
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const relative_path = import.meta.url.endsWith(".ts") ? source_relative_path : dist_relative_path;
|
|
24
|
-
return fileURLToPath(new URL(relative_path, import.meta.url));
|
|
25
|
-
}
|
|
26
|
-
function resolve_kit_internal_runtime_path(relative_path) {
|
|
27
|
-
return pathToFileURL(resolve(dirname(createRequire(resolve(process.cwd(), "package.json")).resolve("@sveltejs/kit/package.json")), relative_path)).href;
|
|
28
|
-
}
|
|
29
|
-
function create_remote_runtime_module_code() {
|
|
30
|
-
const adapter_module_path = resolve_runtime_internal_path("./internal/remote-client.ts", "./internal/remote-client.js");
|
|
31
|
-
const kit_query_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/query.svelte.js");
|
|
32
|
-
const kit_command_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/command.svelte.js");
|
|
33
|
-
const kit_form_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/form.svelte.js");
|
|
34
|
-
const kit_prerender_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/prerender.svelte.js");
|
|
35
|
-
const kit_shared_module_path = resolve_kit_internal_runtime_path("src/runtime/client/remote-functions/shared.svelte.js");
|
|
36
|
-
const kit_client_module_path = resolve_kit_internal_runtime_path("src/runtime/client/client.js");
|
|
37
|
-
const kit_form_utils_module_path = resolve_kit_internal_runtime_path("src/runtime/form-utils.js");
|
|
38
|
-
const kit_shared_runtime_module_path = resolve_kit_internal_runtime_path("src/runtime/shared.js");
|
|
39
|
-
return `
|
|
40
|
-
import * as devalue from "devalue";
|
|
41
|
-
import { base, app_dir } from "$app/paths/internal/client";
|
|
42
|
-
import { query as native_query, query_batch as native_query_batch } from ${JSON.stringify(kit_query_module_path)};
|
|
43
|
-
import { command as native_command } from ${JSON.stringify(kit_command_module_path)};
|
|
44
|
-
import { form as native_form } from ${JSON.stringify(kit_form_module_path)};
|
|
45
|
-
import { prerender as native_prerender } from ${JSON.stringify(kit_prerender_module_path)};
|
|
46
|
-
import {
|
|
47
|
-
apply_refreshes,
|
|
48
|
-
get_remote_request_headers,
|
|
49
|
-
remote_request
|
|
50
|
-
} from ${JSON.stringify(kit_shared_module_path)};
|
|
51
|
-
import { app, invalidateAll, _goto } from ${JSON.stringify(kit_client_module_path)};
|
|
52
|
-
import { BINARY_FORM_CONTENT_TYPE, serialize_binary_form } from ${JSON.stringify(kit_form_utils_module_path)};
|
|
53
|
-
import { stringify_remote_arg } from ${JSON.stringify(kit_shared_runtime_module_path)};
|
|
54
|
-
import {
|
|
55
|
-
create_remote_command_adapter,
|
|
56
|
-
create_remote_form_adapter,
|
|
57
|
-
create_remote_query_adapter
|
|
58
|
-
} from ${JSON.stringify(adapter_module_path)};
|
|
59
|
-
|
|
60
|
-
const decode_payload = (encoded) => devalue.parse(encoded, app?.decoders ?? {});
|
|
61
|
-
const request_dependencies = {
|
|
62
|
-
app,
|
|
63
|
-
app_dir,
|
|
64
|
-
apply_refreshes,
|
|
65
|
-
base,
|
|
66
|
-
get_remote_request_headers,
|
|
67
|
-
remote_request,
|
|
68
|
-
stringify_remote_arg
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const query = create_remote_query_adapter(native_query, decode_payload, request_dependencies, "query");
|
|
72
|
-
export const query_batch = create_remote_query_adapter(native_query_batch, decode_payload, request_dependencies, "query_batch");
|
|
73
|
-
export const command = create_remote_command_adapter(native_command, decode_payload, request_dependencies);
|
|
74
|
-
export const prerender = create_remote_query_adapter(native_prerender, decode_payload, request_dependencies, "prerender");
|
|
75
|
-
export const form = create_remote_form_adapter(native_form, decode_payload, {
|
|
76
|
-
binary_form_content_type: BINARY_FORM_CONTENT_TYPE,
|
|
77
|
-
goto: _goto,
|
|
78
|
-
invalidate_all: invalidateAll,
|
|
79
|
-
serialize_binary_form,
|
|
80
|
-
...request_dependencies
|
|
81
|
-
});
|
|
82
|
-
`;
|
|
83
|
-
}
|
|
84
|
-
function sveltekitEffectRuntime(options = {}) {
|
|
85
|
-
const remote_module_id = options.remoteModuleId ?? "\0svelte-effect-runtime:remote";
|
|
86
|
-
return {
|
|
87
|
-
name: "svelte-effect-runtime-remote",
|
|
88
|
-
enforce: "pre",
|
|
89
|
-
resolveId(id) {
|
|
90
|
-
if (id === "__sveltekit/remote") return remote_module_id;
|
|
91
|
-
},
|
|
92
|
-
load(id) {
|
|
93
|
-
if (id !== remote_module_id) return;
|
|
94
|
-
return create_remote_runtime_module_code();
|
|
95
|
-
},
|
|
96
|
-
transform(code, id) {
|
|
97
|
-
const filename = id.split("?", 1)[0];
|
|
98
|
-
if (!SERVER_SOURCE_PATTERN.test(filename)) return null;
|
|
99
|
-
if (!code.includes(ROOT_PACKAGE_ID)) return null;
|
|
100
|
-
return code.replaceAll(ROOT_PACKAGE_ID, INTERNAL_SERVER_PACKAGE_ID);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
12
|
+
/**
|
|
13
|
+
* Install the remote-function adapter that rewrites SvelteKit remote helpers
|
|
14
|
+
* to return `Effect` values.
|
|
15
|
+
*
|
|
16
|
+
* @see https://ser.barekey.dev/content/reference/tooling
|
|
17
|
+
*/
|
|
18
|
+
function sveltekit_effect_runtime(options) {
|
|
19
|
+
return sveltekit_effect_runtime$1(options);
|
|
103
20
|
}
|
|
104
21
|
//#endregion
|
|
105
|
-
export {
|
|
22
|
+
export { svelte_effect_runtime, sveltekit_effect_runtime };
|
|
106
23
|
|
|
107
24
|
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","names":[],"sources":["../../modules/svelte-effect-runtime/vite.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"vite.js","names":["create_svelte_effect_runtime","create_sveltekit_effect_runtime"],"sources":["../../modules/svelte-effect-runtime/vite.ts"],"sourcesContent":["/**\n * Public Vite entrypoint wrappers for `svelte-effect-runtime`.\n *\n * @example\n * ```ts\n * import { sveltekit_effect_runtime } from \"svelte-effect-runtime/vite\";\n *\n * export default {\n * plugins: [sveltekit_effect_runtime()],\n * };\n * ```\n *\n * @module\n */\nimport type { Plugin } from \"vite\";\nimport {\n svelte_effect_runtime as create_svelte_effect_runtime,\n type SvelteEffectRuntimeOptions,\n sveltekit_effect_runtime as create_sveltekit_effect_runtime,\n type SveltekitEffectRuntimeOptions,\n} from \"$/v3/vite.ts\";\n\nexport type {\n SvelteEffectRuntimeOptions,\n SveltekitEffectRuntimeOptions,\n} from \"$/v3/vite.ts\";\n\n/**\n * Compose the low-level Svelte preprocessor directly into a plain Vite +\n * Svelte project.\n *\n * @see https://ser.barekey.dev/content/reference/tooling\n */\nexport function svelte_effect_runtime(\n options?: SvelteEffectRuntimeOptions,\n): Plugin[] {\n return create_svelte_effect_runtime(options);\n}\n\n/**\n * Install the remote-function adapter that rewrites SvelteKit remote helpers\n * to return `Effect` values.\n *\n * @see https://ser.barekey.dev/content/reference/tooling\n */\nexport function sveltekit_effect_runtime(\n options?: SveltekitEffectRuntimeOptions,\n): Plugin {\n return create_sveltekit_effect_runtime(options);\n}\n"],"mappings":";;;;;;;;AAiCA,SAAgB,sBACd,SACU;AACV,QAAOA,wBAA6B,QAAQ;;;;;;;;AAS9C,SAAgB,yBACd,SACQ;AACR,QAAOC,2BAAgC,QAAQ"}
|