svelte-effect-runtime 1.2.3 → 1.3.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.
Files changed (74) hide show
  1. package/dist/chunks/client-DkW4e4dD.js +199 -0
  2. package/dist/chunks/client-DkW4e4dD.js.map +1 -0
  3. package/dist/chunks/effect-CL8GJs8A.js +51 -0
  4. package/dist/chunks/effect-CL8GJs8A.js.map +1 -0
  5. package/dist/chunks/effect-compat-BhW0YPIs.js +103 -0
  6. package/dist/chunks/effect-compat-BhW0YPIs.js.map +1 -0
  7. package/dist/chunks/{magic-string.es-5gRBdMgP.js → magic-string.es-BnGH-5YR.js} +1 -1
  8. package/dist/chunks/{magic-string.es-5gRBdMgP.js.map → magic-string.es-BnGH-5YR.js.map} +1 -1
  9. package/dist/chunks/{markup-Ccw42uCl.js → markup-BpSHnnYD.js} +4 -4
  10. package/dist/chunks/{markup-Ccw42uCl.js.map → markup-BpSHnnYD.js.map} +1 -1
  11. package/dist/chunks/preprocess-CtLrnJcK.js +44 -0
  12. package/dist/chunks/preprocess-CtLrnJcK.js.map +1 -0
  13. package/dist/chunks/server-DR-6LMdP.js +629 -0
  14. package/dist/chunks/server-DR-6LMdP.js.map +1 -0
  15. package/dist/chunks/v3-p8V3Drpp.js +1 -0
  16. package/dist/chunks/v4-DIhYCbb_.js +1 -0
  17. package/dist/chunks/vite-DqjXRZd4.js +143 -0
  18. package/dist/chunks/vite-DqjXRZd4.js.map +1 -0
  19. package/dist/client.d.ts +1 -64
  20. package/dist/client.js +2 -170
  21. package/dist/effect.d.ts +1 -7
  22. package/dist/effect.js +1 -27
  23. package/dist/internal/effect-compat.d.ts +21 -0
  24. package/dist/internal/markup.d.ts +1 -1
  25. package/dist/internal/markup.js +1 -1
  26. package/dist/internal/remote-client.js +30 -6
  27. package/dist/internal/remote-client.js.map +1 -1
  28. package/dist/internal/transform.d.ts +1 -1
  29. package/dist/internal/transform.js +3 -4
  30. package/dist/internal/transform.js.map +1 -1
  31. package/dist/language-server.d.ts +9 -3
  32. package/dist/language-server.js +3 -3
  33. package/dist/mod.d.ts +1 -6
  34. package/dist/mod.js +3 -5
  35. package/dist/preprocess.d.ts +23 -6
  36. package/dist/preprocess.js +10 -31
  37. package/dist/preprocess.js.map +1 -1
  38. package/dist/root-node.d.ts +1 -14
  39. package/dist/root-node.js +63 -8
  40. package/dist/root-node.js.map +1 -0
  41. package/dist/server.d.ts +56 -129
  42. package/dist/server.js +44 -508
  43. package/dist/server.js.map +1 -1
  44. package/dist/v3/client.d.ts +93 -0
  45. package/dist/v3/effect.d.ts +17 -0
  46. package/dist/v3/mod.d.ts +3 -0
  47. package/dist/v3/preprocess.d.ts +28 -0
  48. package/dist/v3/root-node.d.ts +59 -0
  49. package/dist/v3/server.d.ts +167 -0
  50. package/dist/v3/vite.d.ts +46 -0
  51. package/dist/v4/client.d.ts +2 -0
  52. package/dist/v4/effect.d.ts +24 -0
  53. package/dist/v4/effect.js +19 -0
  54. package/dist/v4/effect.js.map +1 -0
  55. package/dist/v4/mod.d.ts +3 -0
  56. package/dist/v4/mod.js +3 -0
  57. package/dist/v4/preprocess.d.ts +30 -0
  58. package/dist/v4/preprocess.js +28 -0
  59. package/dist/v4/preprocess.js.map +1 -0
  60. package/dist/v4/root-node.d.ts +59 -0
  61. package/dist/v4/root-node.js +63 -0
  62. package/dist/v4/root-node.js.map +1 -0
  63. package/dist/v4/server.d.ts +118 -0
  64. package/dist/v4/server.js +22 -0
  65. package/dist/v4/server.js.map +1 -0
  66. package/dist/v4/vite.d.ts +34 -0
  67. package/dist/v4/vite.js +31 -0
  68. package/dist/v4/vite.js.map +1 -0
  69. package/dist/vite.d.ts +30 -15
  70. package/dist/vite.js +18 -101
  71. package/dist/vite.js.map +1 -1
  72. package/package.json +46 -3
  73. package/dist/client.js.map +0 -1
  74. 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 * 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,63 @@
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 { Command as Command$1, Form as Form$1, Prerender as Prerender$1, Query as Query$1, RequestEvent as RequestEvent$1, ServerRuntime as ServerRuntime$1, create_effect_transport as create_effect_transport$1, get_server_runtime_or_throw as get_server_runtime_or_throw$1 } from "./server.js";
4
+ import { effect } from "./effect.js";
5
+ //#region v4/root-node.ts
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
+ const Query = Query$1;
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
+ const Command = Command$1;
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
+ const Form = Form$1;
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
+ const Prerender = Prerender$1;
32
+ /**
33
+ * Effect `Context.Tag` for the current SvelteKit `RequestEvent`.
34
+ *
35
+ * @see https://ser.barekey.dev/content/runtimes/server
36
+ */
37
+ const RequestEvent = RequestEvent$1;
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
+ const ServerRuntime = ServerRuntime$1;
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
+ const create_effect_transport = create_effect_transport$1;
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
+ const get_server_runtime_or_throw = get_server_runtime_or_throw$1;
60
+ //#endregion
61
+ export { ClientRuntime, Command, Form, Prerender, Query, RequestEvent, ServerRuntime, create_effect_transport, effect, get_effect_runtime_or_throw, get_server_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native };
62
+
63
+ //# sourceMappingURL=root-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-node.js","names":["Server_module.Query","Server_module.Command","Server_module.Form","Server_module.Prerender","Server_module.RequestEvent","Server_module.ServerRuntime","Server_module.create_effect_transport","Server_module.get_server_runtime_or_throw"],"sources":["../../../modules/svelte-effect-runtime/v4/root-node.ts"],"sourcesContent":["import * as Server_module from \"$/v4/server.ts\";\n\nexport * from \"$/v4/mod.ts\";\nexport type * from \"$/v4/server.ts\";\nexport type { EffectPluginOptions } from \"$/v4/effect.ts\";\nexport { effect } from \"$/v4/effect.ts\";\n\n/**\n * Define a read-only remote function that returns an `Effect` on the client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport const Query: typeof Server_module.Query = Server_module.Query;\n/**\n * Define a write-oriented remote function that returns an `Effect` on the\n * client.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport const Command: typeof Server_module.Command = Server_module.Command;\n/**\n * Define a remote form handler that maps submitted data into an Effect\n * program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport const Form: typeof Server_module.Form = Server_module.Form;\n/**\n * Define a prerenderable remote function backed by an Effect program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport const Prerender: typeof Server_module.Prerender = Server_module.Prerender;\n/**\n * Effect `Context.Tag` for the current SvelteKit `RequestEvent`.\n *\n * @see https://ser.barekey.dev/content/runtimes/server\n */\nexport const RequestEvent: typeof Server_module.RequestEvent =\n Server_module.RequestEvent;\n/**\n * Server-side runtime builder used to provide long-lived Effect services to\n * remote functions.\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const ServerRuntime: typeof Server_module.ServerRuntime =\n Server_module.ServerRuntime;\n/**\n * Build a devalue transport table from Effect schemas so remote payloads can\n * round-trip custom data across the client/server boundary.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport const create_effect_transport: typeof Server_module.create_effect_transport =\n Server_module.create_effect_transport;\n/**\n * Resolve the active server runtime, lazily creating a default empty runtime\n * when no explicit one has been registered.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const get_server_runtime_or_throw:\n typeof Server_module.get_server_runtime_or_throw =\n Server_module.get_server_runtime_or_throw;\n"],"mappings":";;;;;;;;;;AAYA,MAAa,QAAoCA;;;;;;;AAOjD,MAAa,UAAwCC;;;;;;;AAOrD,MAAa,OAAkCC;;;;;;AAM/C,MAAa,YAA4CC;;;;;;AAMzD,MAAa,eACXC;;;;;;;AAOF,MAAa,gBACXC;;;;;;;AAOF,MAAa,0BACXC;;;;;;;;AAQF,MAAa,8BAETC"}
@@ -0,0 +1,118 @@
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: unknown) => unknown;
25
+ type SchemaInput<SchemaType extends EffectSchemaLike> = SchemaType extends {
26
+ readonly Encoded: infer Input;
27
+ } ? Input : never;
28
+ type SchemaOutput<SchemaType extends EffectSchemaLike> = SchemaType extends {
29
+ readonly Type: infer Output;
30
+ } ? Output : never;
31
+ type FieldHelpers<FormShape, SchemaType> = FormShape extends Record<string, unknown> ? {
32
+ [Key in keyof FormShape as Key extends string ? Key : never]: (message: string) => Effect_type.Effect<never, FormError<SchemaType>, never>;
33
+ } : Record<PropertyKey, never>;
34
+ export type Invalid<SchemaType = unknown> = {
35
+ form: (message: string) => Effect_type.Effect<never, FormError<SchemaType>, never>;
36
+ } & FieldHelpers<SchemaType extends EffectSchemaLike ? SchemaOutput<SchemaType> : unknown, SchemaType>;
37
+ export type EffectQueryFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
38
+ native: RemoteQueryFunction<Input, Output>;
39
+ };
40
+ export type EffectCommand<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
41
+ native: RemoteCommand<Input, Output>;
42
+ readonly pending: number;
43
+ };
44
+ export type EffectPrerenderFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
45
+ native: RemotePrerenderFunction<Input, Output>;
46
+ };
47
+ export type EffectForm<Input extends RemoteFormInput | void, Output, Error = never> = RemoteForm<Input, Output> & {
48
+ native: RemoteForm<Input, Output>;
49
+ submit(data: OptionalArgument<Input>): Effect_type.Effect<Output, RemoteFailure<Error>, never>;
50
+ for: RemoteForm<Input, Output>["for"] extends (...args: infer Args) => infer Result ? (...args: Args) => EffectForm<Input, Output, Error> & Result : never;
51
+ };
52
+ export type RequestEventService = ReturnType<typeof get_native_request_event>;
53
+ export interface ServerRuntimeSeed {
54
+ pipe(): Layer_type.Layer<never>;
55
+ pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): unknown;
56
+ make(): void;
57
+ make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): void;
58
+ }
59
+ export interface EffectManagedRuntime {
60
+ runPromiseExit<A, E, R>(effect: Effect_type.Effect<A, E, R>): Promise<unknown>;
61
+ dispose(): Promise<void>;
62
+ }
63
+ export interface EffectQueryBatchFactory {
64
+ (...args: Array<unknown>): unknown;
65
+ }
66
+ export interface EffectQueryFactory {
67
+ <Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<void, Output, Error>;
68
+ <Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<Input, Output, Error>;
69
+ <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<SchemaInput<SchemaType>, Output, Error>;
70
+ batch: EffectQueryBatchFactory;
71
+ }
72
+ export interface EffectCommandFactory {
73
+ <Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<void, Output, Error>;
74
+ <Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<Input, Output, Error>;
75
+ <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<SchemaInput<SchemaType>, Output, Error>;
76
+ }
77
+ type RemotePrerenderInputsGenerator<Input> = (event: RequestEventService) => AsyncIterable<Input> | Iterable<Input>;
78
+ export interface EffectFormFactory {
79
+ <Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectForm<void, Output, Error>;
80
+ <Input extends RemoteFormInput, Output, Error, Requirements>(validate: "unchecked", fn: (args: {
81
+ data: Input;
82
+ invalid: Invalid;
83
+ }) => Effect_type.Effect<Output, Error | FormError, Requirements>): EffectForm<Input, Output, Error>;
84
+ <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (args: {
85
+ data: SchemaOutput<SchemaType>;
86
+ invalid: Invalid<SchemaType>;
87
+ }) => Effect_type.Effect<Output, Error | FormError<SchemaType>, Requirements>): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, Error>;
88
+ }
89
+ export interface EffectPrerenderFactory {
90
+ <Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>, options?: {
91
+ inputs?: RemotePrerenderInputsGenerator<void>;
92
+ dynamic?: boolean;
93
+ }): EffectPrerenderFunction<void, Output, Error>;
94
+ <Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>, options?: {
95
+ inputs?: RemotePrerenderInputsGenerator<Input>;
96
+ dynamic?: boolean;
97
+ }): EffectPrerenderFunction<Input, Output, Error>;
98
+ <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>, options?: {
99
+ inputs?: RemotePrerenderInputsGenerator<SchemaInput<SchemaType>>;
100
+ dynamic?: boolean;
101
+ }): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, Error>;
102
+ }
103
+ export declare const Query: EffectQueryFactory;
104
+ export declare const Command: EffectCommandFactory;
105
+ export declare const Form: EffectFormFactory;
106
+ export declare const Prerender: EffectPrerenderFactory;
107
+ export declare const RequestEvent: EffectContextKey<RequestEventService, RequestEventService> & Effect_type.Effect<RequestEventService, never, RequestEventService>;
108
+ export declare const ServerRuntime: ServerRuntimeSeed;
109
+ export declare const create_effect_transport: typeof base_server.create_effect_transport;
110
+ export declare const get_server_runtime_or_throw: () => EffectManagedRuntime;
111
+ /**
112
+ * Remap low-level request-store crashes into a clearer setup error when remote
113
+ * helpers are evaluated outside SvelteKit's remote-function runtime.
114
+ *
115
+ * @internal Internal - do not use.
116
+ */
117
+ export declare const normalize_remote_helper_error: typeof base_server.normalize_remote_helper_error;
118
+ 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 = (self: unknown) => unknown;\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 ): unknown;\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":";;;AAwPA,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;
@@ -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
- import { type Options as SveltePluginOptions } from "@sveltejs/vite-plugin-svelte";
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 EffectPreprocessOptions } from "./preprocess.ts";
4
- export interface SvelteEffectRuntimeOptions {
5
- effect?: EffectPreprocessOptions;
6
- svelte?: SveltePluginOptions;
7
- }
8
- export interface SveltekitEffectRuntimeOptions {
9
- /**
10
- * Override the client-side module SvelteKit uses for generated `.remote.ts`
11
- * imports so remote calls default to Effect-returning adapters.
12
- */
13
- remoteModuleId?: string;
14
- }
15
- export declare function svelteEffectRuntime(options?: SvelteEffectRuntimeOptions): Plugin[];
16
- export declare function sveltekitEffectRuntime(options?: SveltekitEffectRuntimeOptions): Plugin;
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 { effectPreprocess } from "./preprocess.js";
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
- const ROOT_PACKAGE_ID = "svelte-effect-runtime";
9
- const INTERNAL_SERVER_PACKAGE_ID = "svelte-effect-runtime/_server";
10
- const SERVER_SOURCE_PATTERN = /(?:^|\/)(?:hooks\.server\.[cm]?[jt]s|.+\.server\.[cm]?[jt]s|.+\.remote\.[cm]?[jt]s)$/;
11
- function arrayify(value) {
12
- if (value === void 0) return [];
13
- return Array.isArray(value) ? value : [value];
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
- function svelteEffectRuntime(options = {}) {
16
- const existingPreprocessors = arrayify(options.svelte?.preprocess);
17
- return svelte({
18
- ...options.svelte,
19
- preprocess: [effectPreprocess(options.effect), ...existingPreprocessors]
20
- });
21
- }
22
- function resolve_runtime_internal_path(source_relative_path, dist_relative_path) {
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 { svelteEffectRuntime, sveltekitEffectRuntime };
22
+ export { svelte_effect_runtime, sveltekit_effect_runtime };
106
23
 
107
24
  //# sourceMappingURL=vite.js.map