svelte-effect-runtime 3.4.10 → 4.0.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 (83) hide show
  1. package/.dist/chunks/{client-CsVu54pU.js → client-DcZUV4rR.js} +76 -50
  2. package/.dist/chunks/client-DcZUV4rR.js.map +1 -0
  3. package/.dist/chunks/{vite-Dm3bXmR3.js → compiler-BBPNyXmQ.js} +84 -112
  4. package/.dist/chunks/compiler-BBPNyXmQ.js.map +1 -0
  5. package/.dist/chunks/{dispatcher-pHH4JcFR.js → dispatcher-DOx8iC6r.js} +2 -2
  6. package/.dist/chunks/{dispatcher-pHH4JcFR.js.map → dispatcher-DOx8iC6r.js.map} +1 -1
  7. package/.dist/chunks/{dispatcher-LtvFKYUp.js → dispatcher-H-Ia0Os4.js} +3 -3
  8. package/.dist/chunks/{dispatcher-LtvFKYUp.js.map → dispatcher-H-Ia0Os4.js.map} +1 -1
  9. package/.dist/chunks/{errors-Dcf0MVbq.js → errors-IJjsUwrE.js} +21 -65
  10. package/.dist/chunks/errors-IJjsUwrE.js.map +1 -0
  11. package/.dist/chunks/live-BXAKre_4.js +104 -0
  12. package/.dist/chunks/live-BXAKre_4.js.map +1 -0
  13. package/.dist/chunks/{remote-client-Bj1pZXgq.js → remote-client-CVI4t66c.js} +2 -2
  14. package/.dist/chunks/remote-client-CVI4t66c.js.map +1 -0
  15. package/.dist/chunks/{runtime-ekkMQ-wL.js → runtime-GBQz32DZ.js} +3 -3
  16. package/.dist/chunks/{runtime-ekkMQ-wL.js.map → runtime-GBQz32DZ.js.map} +1 -1
  17. package/.dist/chunks/schema-D9pct6Y5.js +89 -0
  18. package/.dist/chunks/schema-D9pct6Y5.js.map +1 -0
  19. package/.dist/chunks/server-D1LcDnZE.js +213 -0
  20. package/.dist/chunks/server-D1LcDnZE.js.map +1 -0
  21. package/.dist/chunks/source-scan-C4PsggID.js +341 -0
  22. package/.dist/chunks/source-scan-C4PsggID.js.map +1 -0
  23. package/.dist/chunks/{transform-CEK6Ccll.js → transform-jNUr65K9.js} +289 -248
  24. package/.dist/chunks/transform-jNUr65K9.js.map +1 -0
  25. package/.dist/compiler/source-scan.d.ts +198 -0
  26. package/.dist/{vite.d.ts → compiler.d.ts} +1 -1
  27. package/.dist/{vite.js → compiler.js} +1 -1
  28. package/.dist/dispatcher.js +1 -1
  29. package/.dist/errors.d.ts +15 -45
  30. package/.dist/generators.d.ts +3 -1
  31. package/.dist/internal/generators.js +20 -3
  32. package/.dist/internal/generators.js.map +1 -0
  33. package/.dist/internal/remote-client.js +1 -1
  34. package/.dist/internal/remote-server.js +1 -1
  35. package/.dist/internal/schema.d.ts +67 -0
  36. package/.dist/live.d.ts +123 -0
  37. package/.dist/markup/event-attributes.d.ts +38 -0
  38. package/.dist/markup/promise.js +1 -1
  39. package/.dist/markup/run.js +1 -1
  40. package/.dist/markup/transform/classify.d.ts +12 -4
  41. package/.dist/markup/transform/constants.d.ts +1 -0
  42. package/.dist/markup/transform/emit.d.ts +12 -4
  43. package/.dist/markup/transform/types.d.ts +1 -0
  44. package/.dist/markup/transform.js +1 -1
  45. package/.dist/markup/value.js +1 -1
  46. package/.dist/mod.d.ts +6 -3
  47. package/.dist/mod.js +5 -4
  48. package/.dist/mod.js.map +1 -1
  49. package/.dist/remote/cause-codec.d.ts +53 -0
  50. package/.dist/remote/client/form-transport.d.ts +4 -1
  51. package/.dist/remote/client/form.d.ts +10 -1
  52. package/.dist/remote/client/index.d.ts +1 -1
  53. package/.dist/remote/client/query.d.ts +6 -16
  54. package/.dist/remote/client/types.d.ts +32 -13
  55. package/.dist/remote/client.d.ts +1 -1
  56. package/.dist/remote/client.js +1 -1
  57. package/.dist/remote/server.d.ts +2 -12
  58. package/.dist/remote/server.js +1 -178
  59. package/.dist/runtime/transform.js +81 -68
  60. package/.dist/runtime/transform.js.map +1 -1
  61. package/.dist/script-transform/imports.d.ts +2 -0
  62. package/.dist/script-transform/types.d.ts +8 -0
  63. package/.dist/server/effects.d.ts +7 -7
  64. package/.dist/server/handler.d.ts +37 -0
  65. package/.dist/server/index.d.ts +4 -1
  66. package/.dist/server/schema.d.ts +2 -26
  67. package/.dist/server/types.d.ts +44 -50
  68. package/.dist/server/wrappers.d.ts +2 -2
  69. package/.dist/server.d.ts +2 -2
  70. package/.dist/server.js +88 -97
  71. package/.dist/server.js.map +1 -1
  72. package/.dist/yieldable.d.ts +41 -0
  73. package/README.md +1 -1
  74. package/package.json +4 -4
  75. package/.dist/chunks/client-CsVu54pU.js.map +0 -1
  76. package/.dist/chunks/descriptors-cOe9uRJz.js +0 -36
  77. package/.dist/chunks/descriptors-cOe9uRJz.js.map +0 -1
  78. package/.dist/chunks/errors-Dcf0MVbq.js.map +0 -1
  79. package/.dist/chunks/remote-client-Bj1pZXgq.js.map +0 -1
  80. package/.dist/chunks/transform-CEK6Ccll.js.map +0 -1
  81. package/.dist/chunks/vite-Dm3bXmR3.js.map +0 -1
  82. package/.dist/remote/server.js.map +0 -1
  83. /package/.dist/{vite → compiler}/remote-client.d.ts +0 -0
@@ -1,6 +1,23 @@
1
- import { i as Code } from "../chunks/dispatcher-pHH4JcFR.js";
2
- import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-LtvFKYUp.js";
1
+ import { o as EmptyStreamYieldError } from "../chunks/errors-IJjsUwrE.js";
2
+ import { i as Code } from "../chunks/dispatcher-DOx8iC6r.js";
3
+ import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-H-Ia0Os4.js";
3
4
  import { value } from "../markup/value.js";
4
5
  import { promise } from "../markup/promise.js";
5
6
  import { run } from "../markup/run.js";
6
- export { Code, Dispatcher, get_dispatcher, promise, run, value };
7
+ import { Effect, Option, Stream } from "effect";
8
+ //#region src/yieldable.ts
9
+ function ToEffect(value) {
10
+ if (Stream.isStream(value)) return Stream.runHead(value).pipe(Effect.flatMap((option) => {
11
+ if (Option.isSome(option)) return Effect.succeed(option.value);
12
+ return Effect.fail(new EmptyStreamYieldError());
13
+ }));
14
+ if (is_generator_result(value)) return Effect.gen(() => value);
15
+ return value;
16
+ }
17
+ function is_generator_result(value) {
18
+ return typeof value === "object" && value !== null && typeof value.next === "function";
19
+ }
20
+ //#endregion
21
+ export { Code, Dispatcher, ToEffect, get_dispatcher, promise, run, value };
22
+
23
+ //# sourceMappingURL=generators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/yieldable.ts"],"sourcesContent":["import { EmptyStreamYieldError } from \"$/errors.ts\";\nimport { Effect, Option, Stream } from \"effect\";\n\n/**\n * Values generated `yield*` positions can normalize into an Effect.\n *\n * @example\n * ```ts\n * const value: Yieldable<number> = Stream.make(1);\n * ```\n *\n * @since 3.4.8\n */\nexport type Yieldable<A = unknown, E = unknown, R = unknown> =\n\t| Effect.Effect<A, E, R>\n\t| Effect.gen.Return<A, E, R>\n\t| Stream.Stream<A, E, R>;\n\n/**\n * Success type produced when generated code yields an Effect or a Stream.\n *\n * @example\n * ```ts\n * type User = YieldSuccess<ReturnType<typeof loadUser>>;\n * ```\n *\n * @since 3.4.8\n */\nexport type YieldSuccess<Value> = Value extends Stream.Stream<infer A, unknown, unknown>\n\t? A\n\t: Value extends Effect.Effect<infer A, unknown, unknown>\n\t\t? A\n\t\t: Value extends Effect.gen.Return<infer A, unknown, unknown>\n\t\t\t? A\n\t\t\t: never;\n\n/**\n * Normalizes generated `yield*` operands into Effects.\n *\n * @example\n * ```ts\n * const first = yield* ToEffect(Stream.make(\"ready\"));\n * ```\n *\n * @since 3.4.8\n * @param value - Effect, generator return object, or Stream emitted from a\n * lowered component `yield*` expression.\n * @returns An Effect that resolves with the original Effect success value or\n * the first Stream emission.\n * @internal\n */\nexport function ToEffect<A, E, R>(\n\tvalue: Effect.Effect<A, E, R> | Effect.gen.Return<A, E, R>,\n): Effect.Effect<A, E, R>;\nexport function ToEffect<A, E, R>(\n\tvalue: Stream.Stream<A, E, R>,\n): Effect.Effect<A, E | EmptyStreamYieldError, R>;\nexport function ToEffect<A, E, R>(\n\tvalue: Yieldable<A, E, R>,\n): Effect.Effect<A, E | EmptyStreamYieldError, R> {\n\tif (Stream.isStream(value)) {\n\t\treturn Stream.runHead(value).pipe(\n\t\t\tEffect.flatMap((option) => {\n\t\t\t\tif (Option.isSome(option)) {\n\t\t\t\t\treturn Effect.succeed(option.value);\n\t\t\t\t}\n\n\t\t\t\treturn Effect.fail(new EmptyStreamYieldError());\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (is_generator_result<A, E, R>(value)) {\n\t\treturn Effect.gen(() => value) as Effect.Effect<A, E, R>;\n\t}\n\n\treturn value;\n}\n\nfunction is_generator_result<A, E, R>(\n\tvalue: unknown,\n): value is Effect.gen.Return<A, E, R> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as { next?: unknown }).next === \"function\"\n\t);\n}\n"],"mappings":";;;;;;;;AAyDA,SAAgB,SACf,OACiD;CACjD,IAAI,OAAO,SAAS,KAAK,GACxB,OAAO,OAAO,QAAQ,KAAK,CAAC,CAAC,KAC5B,OAAO,SAAS,WAAW;EAC1B,IAAI,OAAO,OAAO,MAAM,GACvB,OAAO,OAAO,QAAQ,OAAO,KAAK;EAGnC,OAAO,OAAO,KAAK,IAAI,sBAAsB,CAAC;CAC/C,CAAC,CACF;CAGD,IAAI,oBAA6B,KAAK,GACrC,OAAO,OAAO,UAAU,KAAK;CAG9B,OAAO;AACR;AAEA,SAAS,oBACR,OACsC;CACtC,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAEhD"}
@@ -1,2 +1,2 @@
1
- import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-CsVu54pU.js";
1
+ import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-DcZUV4rR.js";
2
2
  export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
@@ -1,2 +1,2 @@
1
- import { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error } from "../remote/server.js";
1
+ import { i as encode_remote_failure, n as run_remote_effect, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-D1LcDnZE.js";
2
2
  export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error };
@@ -0,0 +1,67 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * Minimal Standard Schema shape accepted by SvelteKit remote helpers.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const schema: StandardSchema = {
8
+ * "~standard": {
9
+ * validate: (input) => ({ value: input }),
10
+ * },
11
+ * };
12
+ * ```
13
+ *
14
+ * @since 2.0.0
15
+ */
16
+ export type StandardSchema = {
17
+ readonly "~standard": {
18
+ readonly types?: {
19
+ readonly input: unknown;
20
+ readonly output: unknown;
21
+ };
22
+ readonly validate: (input: unknown) => unknown;
23
+ };
24
+ };
25
+ /**
26
+ * Checks whether a value implements the Standard Schema contract.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * if (is_standard_schema(value)) {
31
+ * value["~standard"].validate(input);
32
+ * }
33
+ * ```
34
+ *
35
+ * @since 2.0.0
36
+ * @param value - Value to inspect.
37
+ * @returns Whether the value is a Standard Schema.
38
+ */
39
+ export declare function is_standard_schema(value: unknown): value is StandardSchema;
40
+ /**
41
+ * Checks whether a value looks like an Effect Schema.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * if (is_effect_schema(value)) {
46
+ * Schema.toStandardSchemaV1(value);
47
+ * }
48
+ * ```
49
+ *
50
+ * @since 2.0.0
51
+ * @param value - Value to inspect.
52
+ * @returns Whether the value should be converted to Standard Schema.
53
+ */
54
+ export declare function is_effect_schema(value: unknown): value is Schema.Schema<unknown>;
55
+ /**
56
+ * Converts Effect Schema inputs to Standard Schema for SvelteKit.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const validator = normalize_validator(Schema.Struct({ title: Schema.String }));
61
+ * ```
62
+ *
63
+ * @since 2.0.0
64
+ * @param value - Schema or handler input.
65
+ * @returns Original value or Standard Schema view of an Effect Schema.
66
+ */
67
+ export declare function normalize_validator(value: unknown): unknown;
@@ -0,0 +1,123 @@
1
+ import { Effect, Stream } from "effect";
2
+ import type { RemoteFailure } from "./remote/shared.js";
3
+ /**
4
+ * Runtime marker attached to remote live streams created by SER.
5
+ *
6
+ * @since 3.4.8
7
+ */
8
+ export declare const REMOTE_LIVE_STREAM: unique symbol;
9
+ declare const LIVE_OPERATOR: unique symbol;
10
+ type RemoteLivePipe<A, E> = {
11
+ (): RemoteLiveStream<A, E>;
12
+ (ab: LiveFactory["status"]): Stream.Stream<LiveStatus, never, never>;
13
+ (ab: LiveFactory["reconnect"]): Effect.Effect<void, RemoteFailure<E>, never>;
14
+ <B>(ab: LiveFactory["status"], bc: (_: Stream.Stream<LiveStatus, never, never>) => B): B;
15
+ <B>(ab: LiveFactory["reconnect"], bc: (_: Effect.Effect<void, RemoteFailure<E>, never>) => B): B;
16
+ <B, C>(ab: LiveFactory["status"], bc: (_: Stream.Stream<LiveStatus, never, never>) => B, cd: (_: B) => C): C;
17
+ <B, C>(ab: LiveFactory["reconnect"], bc: (_: Effect.Effect<void, RemoteFailure<E>, never>) => B, cd: (_: B) => C): C;
18
+ <B>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => Stream.Stream<B, RemoteFailure<E>, never>): RemoteLiveStream<B, E>;
19
+ <B>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B): B;
20
+ <B, C>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B, bc: (_: B) => C): C;
21
+ <B, C, D>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B, bc: (_: B) => C, cd: (_: C) => D): D;
22
+ };
23
+ /**
24
+ * Stream returned by `Query.live` remote functions.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const Time = GetTime();
29
+ * const Label = Time.pipe(Stream.map((time) => time.toISOString()));
30
+ * ```
31
+ *
32
+ * @since 3.4.8
33
+ */
34
+ export type RemoteLiveStream<A, E = never> = Omit<Stream.Stream<A, RemoteFailure<E>, never>, "pipe"> & {
35
+ readonly [REMOTE_LIVE_STREAM]: true;
36
+ readonly pipe: RemoteLivePipe<A, E>;
37
+ };
38
+ /**
39
+ * Transport state exposed separately from the data stream.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const Status = GetTime().pipe(Live.status);
44
+ * ```
45
+ *
46
+ * @since 3.4.8
47
+ */
48
+ export type LiveStatus = {
49
+ readonly _tag: "Idle";
50
+ } | {
51
+ readonly _tag: "Connecting";
52
+ } | {
53
+ readonly _tag: "Open";
54
+ } | {
55
+ readonly _tag: "Failed";
56
+ readonly cause: unknown;
57
+ } | {
58
+ readonly _tag: "Closed";
59
+ };
60
+ /**
61
+ * Public live stream control helpers.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * yield* GetNotifications().pipe(Live.reconnect);
66
+ * ```
67
+ *
68
+ * @since 3.4.8
69
+ */
70
+ export interface LiveFactory {
71
+ readonly status: {
72
+ readonly [LIVE_OPERATOR]: true;
73
+ /**
74
+ * Creates a stream of transport status updates for a remote live stream.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const Status = GetTime().pipe(Live.status);
79
+ * ```
80
+ *
81
+ * @param stream - Remote live stream whose transport status should be read.
82
+ * @returns A stream of transport status snapshots.
83
+ */
84
+ <A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never>;
85
+ };
86
+ readonly reconnect: {
87
+ readonly [LIVE_OPERATOR]: true;
88
+ /**
89
+ * Reconnects the transport behind a remote live stream.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * yield* GetNotifications().pipe(Live.reconnect);
94
+ * ```
95
+ *
96
+ * @param stream - Remote live stream whose transport should reconnect.
97
+ * @returns An Effect that completes after the reconnect request is sent.
98
+ */
99
+ <A, E>(stream: RemoteLiveStream<A, E>): Effect.Effect<void, RemoteFailure<E>, never>;
100
+ };
101
+ }
102
+ /**
103
+ * Builds a remote live stream from SvelteKit's native live resource.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * const stream = make_remote_live_stream(resource, normalize_native_error);
108
+ * ```
109
+ *
110
+ * @since 3.4.8
111
+ * @param resource - Native SvelteKit live query resource.
112
+ * @param on_error - Error mapper used for stream and reconnect failures.
113
+ * @returns A remote live stream carrying hidden transport metadata.
114
+ * @internal
115
+ */
116
+ export declare function make_remote_live_stream<A, ErrorType = never>(resource: unknown, on_error: (error: unknown) => RemoteFailure<ErrorType>): RemoteLiveStream<A, ErrorType>;
117
+ /**
118
+ * Remote live transport helpers.
119
+ *
120
+ * @since 3.4.8
121
+ */
122
+ export declare const Live: LiveFactory;
123
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Checks whether a parsed Svelte attribute has the same event shape that
3
+ * Svelte's compiler recognizes.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * is_svelte_event_attribute({
8
+ * type: "Attribute",
9
+ * name: "onclick",
10
+ * value: { type: "ExpressionTag" },
11
+ * });
12
+ * ```
13
+ *
14
+ * @since 4.0.0
15
+ * @param attribute - Parsed Svelte attribute with its name and complete value
16
+ * shape.
17
+ * @returns Whether Svelte treats the attribute as an event attribute.
18
+ */
19
+ export declare function is_svelte_event_attribute(attribute: {
20
+ type: string;
21
+ name?: string;
22
+ value?: unknown;
23
+ }): boolean;
24
+ /**
25
+ * Normalizes an event-like attribute name to Svelte's lowercase DOM event
26
+ * spelling while keeping the legacy directive prefix intact.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * normalize_event_attribute_name("onChange");
31
+ * ```
32
+ *
33
+ * @since 3.4.11
34
+ * @param name - Event-like attribute name read from Svelte source or the
35
+ * parsed AST.
36
+ * @returns Lowercase event attribute spelling for DOM-facing Svelte nodes.
37
+ */
38
+ export declare function normalize_event_attribute_name(name: string): string;
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-LtvFKYUp.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-H-Ia0Os4.js";
2
2
  //#region src/markup/promise.ts
3
3
  /**
4
4
  * Runtime helper emitted by the markup transform for
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-LtvFKYUp.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-H-Ia0Os4.js";
2
2
  import { Effect } from "effect";
3
3
  //#region src/markup/run.ts
4
4
  /**
@@ -1,5 +1,15 @@
1
1
  import type { AST } from "svelte/compiler";
2
2
  import type { MarkupCandidate, TagKind } from "./types.js";
3
+ interface ClassifiedCandidate {
4
+ candidate: MarkupCandidate;
5
+ kind: TagKind;
6
+ attribute_name_replacement?: AttributeNameReplacement;
7
+ }
8
+ interface AttributeNameReplacement {
9
+ start: number;
10
+ end: number;
11
+ text: string;
12
+ }
3
13
  /**
4
14
  * Matches sanitized placeholders back to their Svelte AST context.
5
15
  *
@@ -9,7 +19,5 @@ import type { MarkupCandidate, TagKind } from "./types.js";
9
19
  * @returns Candidates paired with the markup context that determines how they
10
20
  * should be emitted.
11
21
  */
12
- export declare function classify_candidates(ast: AST.Root, candidates: MarkupCandidate[]): Array<{
13
- candidate: MarkupCandidate;
14
- kind: TagKind;
15
- }>;
22
+ export declare function classify_candidates(ast: AST.Root, candidates: MarkupCandidate[]): ClassifiedCandidate[];
23
+ export {};
@@ -1,4 +1,5 @@
1
1
  export declare const HELPERS: {
2
2
  readonly codes: "Code";
3
3
  readonly dispatcher: "Dispatcher";
4
+ readonly yieldable: "ToEffect";
4
5
  };
@@ -1,5 +1,15 @@
1
1
  import type { EffectCallbackRewriteContext } from "./effect-bindings.js";
2
2
  import type { MarkupCandidate, MarkupHelperBindings, MarkupNameAllocator, MarkupTransformTarget, Replacement, TagKind } from "./types.js";
3
+ interface ClassifiedCandidate {
4
+ candidate: MarkupCandidate;
5
+ kind: TagKind;
6
+ attribute_name_replacement?: AttributeNameReplacement;
7
+ }
8
+ interface AttributeNameReplacement {
9
+ start: number;
10
+ end: number;
11
+ text: string;
12
+ }
3
13
  /**
4
14
  * Emits source edits for classified markup Effect expressions.
5
15
  *
@@ -9,7 +19,5 @@ import type { MarkupCandidate, MarkupHelperBindings, MarkupNameAllocator, Markup
9
19
  * expression rewrites.
10
20
  * @returns Replacements ready to apply to the original component source.
11
21
  */
12
- export declare function emit_replacements(classified: Array<{
13
- candidate: MarkupCandidate;
14
- kind: TagKind;
15
- }>, effect_context: EffectCallbackRewriteContext, helper_bindings: MarkupHelperBindings, name_allocator: MarkupNameAllocator, target: MarkupTransformTarget): Replacement[];
22
+ export declare function emit_replacements(classified: ClassifiedCandidate[], effect_context: EffectCallbackRewriteContext, helper_bindings: MarkupHelperBindings, name_allocator: MarkupNameAllocator, target: MarkupTransformTarget): Replacement[];
23
+ export {};
@@ -205,6 +205,7 @@ export interface Insertion {
205
205
  export interface MarkupHelperBindings {
206
206
  codes: string;
207
207
  dispatcher: string;
208
+ yieldable: string;
208
209
  }
209
210
  /**
210
211
  * Allocator that reserves collision-free helper names for generated markup.
@@ -1,2 +1,2 @@
1
- import { t as transform_markup_effect } from "../chunks/transform-CEK6Ccll.js";
1
+ import { t as transform_markup_effect } from "../chunks/transform-jNUr65K9.js";
2
2
  export { transform_markup_effect };
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-LtvFKYUp.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-H-Ia0Os4.js";
2
2
  //#region src/markup/value.ts
3
3
  /**
4
4
  * Runtime helper emitted by the markup transform for `{yield* expr}`
package/.dist/mod.d.ts CHANGED
@@ -125,6 +125,7 @@ export declare const Form: FormFactory;
125
125
  * @since 2.0.0
126
126
  */
127
127
  export declare const Prerender: PrerenderFactory;
128
+ export { Live } from "./live.js";
128
129
  /**
129
130
  * SvelteKit redirect control-flow export for `.remote.ts` files imported from
130
131
  * the root entrypoint. The Vite plugin rewrites it to the real server
@@ -171,11 +172,13 @@ export declare const RequestEvent: Context.Reference<RequestEventShape>;
171
172
  export declare const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never>;
172
173
  /** Re-export error types users need for typed catch handlers. */
173
174
  export type { FormError, FormIssue, RemoteFailure, RemoteHttpError, RemoteTransportError, RemoteValidationError, } from "./remote/shared.js";
174
- export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, DispatcherDisposedError, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, VitePreTransformPluginConflictError, YieldStarInEventCallbackError, } from "./errors.js";
175
+ export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, DispatcherDisposedError, EmptyStreamYieldError, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, YieldStarInEventCallbackError, } from "./errors.js";
175
176
  export { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, } from "./remote/shared.js";
176
177
  /** Re-export app setup helpers so users can import them from root. */
177
- export { effect, type EffectOptions } from "./vite.js";
178
+ export { effect, type EffectOptions } from "./compiler.js";
178
179
  /** Re-export server helper types from the root entrypoint. */
179
180
  export type { ErrorBody, ErrorEffectFactory, ErrorProperties, ErrorStatus, ErrorStatusName, RedirectEffectFactory, RedirectOptions, RedirectStatus, RedirectStatusName, } from "./server/control-flow.js";
180
181
  /** Re-export server helper types from the root entrypoint. */
181
- export type { CommandFactory, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteLiveQueryResource, EffectRemoteLiveSource, EffectRemoteQuery, EffectRemoteQueryFunction, FormFactory, FormInvalid, PrerenderFactory, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteFormHandler, RemoteHandler, RemoteLiveHandler, SchemaEncodedInput, SchemaInput, ServerRuntimeFactory, StandardSchema, StandardSchemaInput, StandardSchemaOutput, } from "./server/types.js";
182
+ export type { LiveFactory, LiveStatus, RemoteLiveStream } from "./live.js";
183
+ /** Re-export server helper types from the root entrypoint. */
184
+ export type { CommandFactory, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteQuery, EffectRemoteQueryFunction, FormFactory, FormInvalid, PrerenderFactory, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteFormHandler, RemoteHandler, RemoteLiveHandler, RemoteLiveSource, SchemaEncodedInput, SchemaInput, ServerRuntimeFactory, StandardSchema, StandardSchemaInput, StandardSchemaOutput, } from "./server/types.js";
package/.dist/mod.js CHANGED
@@ -1,7 +1,8 @@
1
- import { A as YieldStarInEventCallbackError, C as UncheckedLiveQueryHandlerMissingError, D as UnsupportedMarkupEffectPositionError, E as UnknownRuntimeError, O as UnsupportedRemoteFormResponseError, S as UncheckedFormHandlerMissingError, T as UncheckedQueryHandlerMissingError, _ as RuntimeAlreadyInitializedError, a as DispatcherDisposedError, b as SvelteKitServerExportUnavailableError, c as InvalidLiveQueryReturnError, d as PreprocessError, f as RemoteErrorDecodeError, g as RequestEventUnavailableError, h as RemoteHelperError, i as BatchQueryHandlerMissingError, k as VitePreTransformPluginConflictError, l as InvalidQueryFactoryError, m as RemoteHelperContextError, n as AsyncEffectInSyncRuneError, o as InvalidCommandFactoryError, p as RemoteFormEndpointMissingError, r as AwaitInEffectWorkError, s as InvalidLiveQueryFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidRemoteFormResponseError, v as RuntimeError, w as UncheckedPrerenderHandlerMissingError, x as UncheckedCommandHandlerMissingError, y as ServerOnlyImportError } from "./chunks/errors-Dcf0MVbq.js";
2
- import { t as Dispatcher } from "./chunks/dispatcher-pHH4JcFR.js";
1
+ import { C as UncheckedFormHandlerMissingError, D as UnsupportedMarkupEffectPositionError, E as UncheckedQueryHandlerMissingError, O as UnsupportedRemoteFormResponseError, S as UncheckedCommandHandlerMissingError, T as UncheckedPrerenderHandlerMissingError, _ as RequestEventUnavailableError, a as DispatcherDisposedError, b as ServerOnlyImportError, c as InvalidLiveQueryFactoryError, d as InvalidRemoteFormResponseError, f as PreprocessError, g as RemoteHelperError, h as RemoteHelperContextError, i as BatchQueryHandlerMissingError, k as YieldStarInEventCallbackError, l as InvalidLiveQueryReturnError, m as RemoteFormEndpointMissingError, n as AsyncEffectInSyncRuneError, o as EmptyStreamYieldError, p as RemoteErrorDecodeError, r as AwaitInEffectWorkError, s as InvalidCommandFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidQueryFactoryError, v as RuntimeAlreadyInitializedError, w as UncheckedLiveQueryHandlerMissingError, x as SvelteKitServerExportUnavailableError, y as RuntimeError } from "./chunks/errors-IJjsUwrE.js";
2
+ import { t as Dispatcher } from "./chunks/dispatcher-DOx8iC6r.js";
3
+ import { t as Live } from "./chunks/live-BXAKre_4.js";
3
4
  import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
4
- import { t as effect } from "./chunks/vite-Dm3bXmR3.js";
5
+ import { t as effect } from "./chunks/compiler-BBPNyXmQ.js";
5
6
  //#region src/mod.ts
6
7
  /**
7
8
  * Public API surface for `svelte-effect-runtime`.
@@ -191,6 +192,6 @@ function make_server_only_error(name) {
191
192
  return new ServerOnlyImportError(name);
192
193
  }
193
194
  //#endregion
194
- export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, ClientRuntime, Command, DispatcherDisposedError, Error, Form, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, Prerender, Query, Redirect, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEvent, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, ServerRuntime, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, VitePreTransformPluginConflictError, YieldStarInEventCallbackError, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error };
195
+ export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, ClientRuntime, Command, DispatcherDisposedError, EmptyStreamYieldError, Error, Form, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, Live, PreprocessError, Prerender, Query, Redirect, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEvent, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, ServerRuntime, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, YieldStarInEventCallbackError, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error };
195
196
 
196
197
  //# sourceMappingURL=mod.js.map
package/.dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\nimport type { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\"ServerRuntime\") as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\n}) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\"Command\") as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\"Error\") as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\"Form\") as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\"Prerender\") as never;\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\"Redirect\") as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> = make_server_only_function(\n\t\"RequestEvent\",\n) as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never> =\n\tmake_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnknownRuntimeError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tVitePreTransformPluginConflictError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemoteLiveQueryResource,\n\tEffectRemoteLiveSource,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAgBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAoGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
1
+ {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\nimport type { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\"ServerRuntime\") as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\n}) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\"Command\") as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\"Error\") as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\"Form\") as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\"Prerender\") as never;\n\nexport { Live } from \"$/live.ts\";\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\"Redirect\") as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> = make_server_only_function(\n\t\"RequestEvent\",\n) as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never> =\n\tmake_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tEmptyStreamYieldError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/compiler.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type { LiveFactory, LiveStatus, RemoteLiveStream } from \"$/live.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAkBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAqGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
@@ -0,0 +1,53 @@
1
+ import type { FormIssue } from "./shared.js";
2
+ import { Cause } from "effect";
3
+ /**
4
+ * Classified result of inspecting an Effect Cause at the remote server boundary.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const resolution = classify_remote_cause(cause);
9
+ * if (resolution._tag === "RemoteFailure") {
10
+ * console.log(resolution.encoded);
11
+ * }
12
+ * ```
13
+ *
14
+ * @since 4.0.0
15
+ */
16
+ export type RemoteCauseResolution = {
17
+ readonly _tag: "SvelteKitControlFlow";
18
+ readonly value: unknown;
19
+ } | {
20
+ readonly _tag: "InterruptOnly";
21
+ readonly cause: Cause.Cause<unknown>;
22
+ } | {
23
+ readonly _tag: "FormInvalid";
24
+ readonly issues: readonly FormIssue[];
25
+ } | {
26
+ readonly _tag: "RemoteFailure";
27
+ readonly encoded: string;
28
+ };
29
+ /**
30
+ * Classifies a failed Effect Cause into the server action SER should take.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const resolution = classify_remote_cause(Cause.fail({ _tag: "DbError" }));
35
+ * ```
36
+ *
37
+ * @since 4.0.0
38
+ * @param cause - Failed Effect Cause produced by a remote handler.
39
+ * @returns A remote boundary decision preserving control flow, form errors,
40
+ * interrupts, or encoded typed failures.
41
+ * @internal
42
+ */
43
+ export declare function classify_remote_cause(cause: Cause.Cause<unknown>): RemoteCauseResolution;
44
+ /**
45
+ * Encodes an Effect Cause into a string that the client-side adapter can
46
+ * decode back into a typed `RemoteFailure`.
47
+ *
48
+ * @since 2.0.0
49
+ * @param cause - The Effect Cause from a failed execution.
50
+ * @returns A devalue-encoded string representing the serialised failure.
51
+ * @internal
52
+ */
53
+ export declare function encode_remote_failure(cause: Cause.Cause<unknown>): string;
@@ -1,3 +1,4 @@
1
+ import type { StandardSchema } from "../../internal/schema.js";
1
2
  import type { NativeFormRecord } from "./types.js";
2
3
  /**
3
4
  * Submits a native remote form through the SvelteKit remote endpoint.
@@ -7,9 +8,11 @@ import type { NativeFormRecord } from "./types.js";
7
8
  * @param input - Form input value.
8
9
  * @param decode_payload - Function to decode successful payloads.
9
10
  * @param remote_base - Base URL for the remote endpoint.
11
+ * @param preflight_schema - Optional schema used to mirror SvelteKit's
12
+ * client-side preflight before posting direct programmatic input.
10
13
  * @returns Decoded form output.
11
14
  */
12
- export declare function submit_remote_form<Output>(form_obj: NativeFormRecord, input: unknown, decode_payload: (value: unknown) => unknown, remote_base: string): Promise<Output>;
15
+ export declare function submit_remote_form<Output>(form_obj: NativeFormRecord, input: unknown, decode_payload: (value: unknown) => unknown, remote_base: string, preflight_schema?: StandardSchema): Promise<Output>;
13
16
  /**
14
17
  * Extracts SvelteKit's remote action id from a native form action URL.
15
18
  *
@@ -1,5 +1,9 @@
1
1
  import type { RemoteFormInput } from "@sveltejs/kit";
2
+ import { type StandardSchema } from "../../internal/schema.js";
2
3
  import type { EffectRemoteForm } from "./types.js";
4
+ interface RemoteFormAdapterState {
5
+ shared_preflight_schema?: StandardSchema;
6
+ }
3
7
  /**
4
8
  * Creates a remote form adapter. The callable preserves SvelteKit's native
5
9
  * form descriptors while wrapping `validate`, `enhance`, and programmatic
@@ -15,7 +19,12 @@ import type { EffectRemoteForm } from "./types.js";
15
19
  * @param native_factory - SvelteKit's native form object.
16
20
  * @param decode_payload - Function to decode the response payload.
17
21
  * @param remote_base - Base URL for SvelteKit's remote endpoint.
22
+ * @param adapter_state - Shared mutable state used to mirror root form
23
+ * preflight schemas across keyed form instances.
24
+ * @param keyed - Whether this adapter wraps a keyed form instance returned by
25
+ * SvelteKit's native `for(...)` helper.
18
26
  * @returns A callable form function whose properties mirror the native form.
19
27
  * @internal
20
28
  */
21
- export declare function create_remote_form_adapter<Input extends RemoteFormInput | void, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown, remote_base?: string): EffectRemoteForm<Input, Output, ErrorType>;
29
+ export declare function create_remote_form_adapter<Input extends RemoteFormInput | void, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown, remote_base?: string, adapter_state?: RemoteFormAdapterState, keyed?: boolean): EffectRemoteForm<Input, Output, ErrorType>;
30
+ export {};
@@ -1,4 +1,4 @@
1
1
  export { create_remote_command_adapter } from "./command.js";
2
2
  export { create_remote_form_adapter } from "./form.js";
3
3
  export { create_remote_live_query_adapter, create_remote_query_adapter } from "./query.js";
4
- export type { EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormSubmit, Pending, } from "./types.js";
4
+ export type { EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormPreflightSchema, EffectRemoteFormSubmit, EffectRemoteFormValidateOptions, Pending, } from "./types.js";
@@ -1,5 +1,6 @@
1
1
  import type { EffectRemoteQueryUpdateBrand } from "./types.js";
2
2
  import type { RemoteFailure } from "../shared.js";
3
+ import { type RemoteLiveStream } from "../../live.js";
3
4
  import { Effect } from "effect";
4
5
  type RemoteInput<Input> = undefined extends Input ? Input | void : Input;
5
6
  type DecodePayload<Output> = (value: unknown) => Output;
@@ -17,16 +18,6 @@ type RemoteQueryEffect<Output, ErrorType = never> = RemoteResourceEffect<Output,
17
18
  readonly set: (value: Output) => void;
18
19
  readonly withOverride: (update: (current: Output) => Output) => unknown;
19
20
  };
20
- type RemoteLiveQueryEffect<Output, ErrorType = never> = Effect.Effect<RemoteLiveQueryResource<Output>, RemoteFailure<ErrorType>>;
21
- type RemoteLiveQueryResource<Output> = {
22
- readonly connected: boolean;
23
- readonly current: Output | undefined;
24
- readonly done: boolean;
25
- readonly error: unknown;
26
- readonly loading: boolean;
27
- readonly ready: boolean;
28
- readonly reconnect: () => Effect.Effect<void, unknown, never>;
29
- } & AsyncIterable<Output>;
30
21
  /**
31
22
  * Creates a remote query adapter. The returned function takes input and
32
23
  * returns an `Effect` that executes SvelteKit's native query function.
@@ -49,14 +40,13 @@ export declare function create_remote_query_adapter<Input, Output, ErrorType = n
49
40
  export declare function create_remote_query_adapter<Input, Output, ErrorType = never>(native_factory: NativeQueryFactory<Input>, decode_payload: (value: unknown) => unknown, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);
50
41
  /**
51
42
  * Creates a remote live query adapter. The returned function takes input and
52
- * returns an `Effect` that resolves to a live query resource with stream state
53
- * and reconnect controls.
43
+ * returns an Effect Stream whose transport state is exposed through `Live`.
54
44
  *
55
45
  * @example
56
46
  * ```ts
57
47
  * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);
58
- * const time = yield* getTime();
59
- * const current = time.current;
48
+ * const time = getTime();
49
+ * const first = yield* Stream.runHead(time);
60
50
  * ```
61
51
  *
62
52
  * @since 2.0.0
@@ -64,8 +54,8 @@ export declare function create_remote_query_adapter<Input, Output, ErrorType = n
64
54
  * @param _decode_payload - Deprecated payload decoder retained for parity with
65
55
  * other remote adapters.
66
56
  * @param _base - Deprecated transport base retained for compatibility.
67
- * @returns A function returning an Effect-backed live query resource.
57
+ * @returns A function returning a remote live stream.
68
58
  * @internal
69
59
  */
70
- export declare function create_remote_live_query_adapter<Input, Output, ErrorType = never>(native_factory: unknown, _decode_payload: (value: unknown) => unknown, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteLiveQueryEffect<Output, ErrorType>);
60
+ export declare function create_remote_live_query_adapter<Input, Output, ErrorType = never>(native_factory: unknown, _decode_payload: (value: unknown) => unknown, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);
71
61
  export {};