svelte-effect-runtime 1.6.2 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/.dist/chunks/client-BeOE81fW.js +577 -0
  2. package/.dist/chunks/client-BeOE81fW.js.map +1 -0
  3. package/.dist/chunks/descriptors-CU2g4U_i.js +36 -0
  4. package/.dist/chunks/descriptors-CU2g4U_i.js.map +1 -0
  5. package/.dist/chunks/dispatcher-BSg2-ttN.js +339 -0
  6. package/.dist/chunks/dispatcher-BSg2-ttN.js.map +1 -0
  7. package/.dist/chunks/preprocess-BZyUYWY7.js +430 -0
  8. package/.dist/chunks/preprocess-BZyUYWY7.js.map +1 -0
  9. package/.dist/chunks/transform-BtlxgJrg.js +836 -0
  10. package/.dist/chunks/transform-BtlxgJrg.js.map +1 -0
  11. package/.dist/detect.d.ts +34 -0
  12. package/.dist/detect.js +56 -0
  13. package/.dist/detect.js.map +1 -0
  14. package/.dist/dispatcher/deps.d.ts +14 -0
  15. package/.dist/dispatcher/fibers.d.ts +52 -0
  16. package/.dist/dispatcher/index.d.ts +138 -0
  17. package/.dist/dispatcher/types.d.ts +63 -0
  18. package/.dist/dispatcher.d.ts +2 -0
  19. package/.dist/dispatcher.js +2 -0
  20. package/.dist/error.d.ts +77 -0
  21. package/.dist/generators.d.ts +16 -0
  22. package/.dist/internal/descriptors.d.ts +17 -0
  23. package/.dist/internal/generators.d.ts +6 -0
  24. package/.dist/internal/generators.js +5 -0
  25. package/.dist/internal/remote-client.d.ts +6 -0
  26. package/.dist/internal/remote-client.js +2 -0
  27. package/.dist/internal/remote-server.d.ts +6 -0
  28. package/.dist/internal/remote-server.js +2 -0
  29. package/.dist/markup/promise.d.ts +15 -0
  30. package/.dist/markup/promise.js +26 -0
  31. package/.dist/markup/promise.js.map +1 -0
  32. package/.dist/markup/run.d.ts +12 -0
  33. package/.dist/markup/run.js +21 -0
  34. package/.dist/markup/run.js.map +1 -0
  35. package/.dist/markup/transform/apply.d.ts +6 -0
  36. package/.dist/markup/transform/classify.d.ts +15 -0
  37. package/.dist/markup/transform/constants.d.ts +5 -0
  38. package/.dist/markup/transform/emit.d.ts +12 -0
  39. package/.dist/markup/transform/expressions.d.ts +39 -0
  40. package/.dist/markup/transform/index.d.ts +19 -0
  41. package/.dist/markup/transform/scan.d.ts +8 -0
  42. package/.dist/markup/transform/types.d.ts +64 -0
  43. package/.dist/markup/transform.d.ts +1 -0
  44. package/.dist/markup/transform.js +2 -0
  45. package/.dist/markup/value.d.ts +20 -0
  46. package/.dist/markup/value.js +32 -0
  47. package/.dist/markup/value.js.map +1 -0
  48. package/.dist/mod.d.ts +186 -0
  49. package/.dist/mod.js +190 -0
  50. package/.dist/mod.js.map +1 -0
  51. package/.dist/preprocess/ast.d.ts +51 -0
  52. package/.dist/preprocess/imports.d.ts +22 -0
  53. package/.dist/preprocess/index.d.ts +21 -0
  54. package/.dist/preprocess/lower.d.ts +12 -0
  55. package/.dist/preprocess/runtime-block.d.ts +8 -0
  56. package/.dist/preprocess/source.d.ts +29 -0
  57. package/.dist/preprocess/types.d.ts +70 -0
  58. package/.dist/preprocess.d.ts +2 -0
  59. package/.dist/preprocess.js +3 -0
  60. package/.dist/remote/client/command.d.ts +17 -0
  61. package/.dist/remote/client/effect.d.ts +15 -0
  62. package/.dist/remote/client/failures.d.ts +57 -0
  63. package/.dist/remote/client/form-data.d.ts +8 -0
  64. package/.dist/remote/client/form-enhance.d.ts +9 -0
  65. package/.dist/remote/client/form-transport.d.ts +20 -0
  66. package/.dist/remote/client/form.d.ts +21 -0
  67. package/.dist/remote/client/index.d.ts +4 -0
  68. package/.dist/remote/client/query-result.d.ts +14 -0
  69. package/.dist/remote/client/query.d.ts +57 -0
  70. package/.dist/remote/client/responses.d.ts +28 -0
  71. package/.dist/remote/client/types.d.ts +83 -0
  72. package/.dist/remote/client/utils.d.ts +11 -0
  73. package/.dist/remote/client.d.ts +2 -0
  74. package/.dist/remote/client.js +2 -0
  75. package/.dist/remote/server.d.ts +66 -0
  76. package/.dist/remote/server.js +104 -0
  77. package/.dist/remote/server.js.map +1 -0
  78. package/.dist/remote/shared.d.ts +202 -0
  79. package/.dist/remote/shared.js +161 -0
  80. package/.dist/remote/shared.js.map +1 -0
  81. package/.dist/runtime/preprocess.d.ts +38 -0
  82. package/.dist/runtime/preprocess.js +54 -0
  83. package/.dist/runtime/preprocess.js.map +1 -0
  84. package/.dist/server/effects.d.ts +49 -0
  85. package/.dist/server/factories.d.ts +97 -0
  86. package/.dist/server/index.d.ts +3 -0
  87. package/.dist/server/invalid.d.ts +9 -0
  88. package/.dist/server/runtime.d.ts +66 -0
  89. package/.dist/server/schema.d.ts +42 -0
  90. package/.dist/server/types.d.ts +271 -0
  91. package/.dist/server/wrappers.d.ts +45 -0
  92. package/.dist/server.d.ts +2 -0
  93. package/.dist/server.js +527 -0
  94. package/.dist/server.js.map +1 -0
  95. package/.dist/vite.d.ts +42 -0
  96. package/.dist/vite.js +118 -0
  97. package/.dist/vite.js.map +1 -0
  98. package/README.md +2 -0
  99. package/package.json +66 -101
  100. package/dist/chunks/client-vV6UAwoP.js +0 -199
  101. package/dist/chunks/client-vV6UAwoP.js.map +0 -1
  102. package/dist/chunks/effect-Crj3S8Cg.js +0 -51
  103. package/dist/chunks/effect-Crj3S8Cg.js.map +0 -1
  104. package/dist/chunks/effect-compat-BhW0YPIs.js +0 -103
  105. package/dist/chunks/effect-compat-BhW0YPIs.js.map +0 -1
  106. package/dist/chunks/magic-string.es-BnGH-5YR.js +0 -1013
  107. package/dist/chunks/magic-string.es-BnGH-5YR.js.map +0 -1
  108. package/dist/chunks/markup-CkPUZIJt.js +0 -13390
  109. package/dist/chunks/markup-CkPUZIJt.js.map +0 -1
  110. package/dist/chunks/preprocess-BFePqOC6.js +0 -49
  111. package/dist/chunks/preprocess-BFePqOC6.js.map +0 -1
  112. package/dist/chunks/server-Dea1CJuY.js +0 -704
  113. package/dist/chunks/server-Dea1CJuY.js.map +0 -1
  114. package/dist/chunks/v3-D0c0MKPf.js +0 -1
  115. package/dist/chunks/v4-MMhHmzIG.js +0 -1
  116. package/dist/chunks/vite-BlUTKv2u.js +0 -152
  117. package/dist/chunks/vite-BlUTKv2u.js.map +0 -1
  118. package/dist/client.d.ts +0 -1
  119. package/dist/client.js +0 -2
  120. package/dist/effect.d.ts +0 -1
  121. package/dist/effect.js +0 -2
  122. package/dist/internal/app-server-shim.d.ts +0 -8
  123. package/dist/internal/effect-compat.d.ts +0 -21
  124. package/dist/internal/markup.d.ts +0 -11
  125. package/dist/internal/markup.js +0 -2
  126. package/dist/internal/remote-client.d.ts +0 -36
  127. package/dist/internal/remote-client.js +0 -527
  128. package/dist/internal/remote-client.js.map +0 -1
  129. package/dist/internal/remote-shared.d.ts +0 -186
  130. package/dist/internal/remote-shared.js +0 -122
  131. package/dist/internal/remote-shared.js.map +0 -1
  132. package/dist/internal/transform.d.ts +0 -18
  133. package/dist/internal/transform.js +0 -418
  134. package/dist/internal/transform.js.map +0 -1
  135. package/dist/language-server.d.ts +0 -9
  136. package/dist/language-server.js +0 -4
  137. package/dist/mod.d.ts +0 -22
  138. package/dist/mod.js +0 -3
  139. package/dist/preprocess.d.ts +0 -29
  140. package/dist/preprocess.js +0 -20
  141. package/dist/preprocess.js.map +0 -1
  142. package/dist/root-node.d.ts +0 -1
  143. package/dist/root-node.js +0 -63
  144. package/dist/root-node.js.map +0 -1
  145. package/dist/server.d.ts +0 -81
  146. package/dist/server.js +0 -85
  147. package/dist/server.js.map +0 -1
  148. package/dist/v3/client.d.ts +0 -117
  149. package/dist/v3/effect.d.ts +0 -17
  150. package/dist/v3/mod.d.ts +0 -27
  151. package/dist/v3/preprocess.d.ts +0 -28
  152. package/dist/v3/root-node.d.ts +0 -59
  153. package/dist/v3/server.d.ts +0 -297
  154. package/dist/v3/vite.d.ts +0 -46
  155. package/dist/v4/client.d.ts +0 -2
  156. package/dist/v4/effect.d.ts +0 -24
  157. package/dist/v4/effect.js +0 -19
  158. package/dist/v4/effect.js.map +0 -1
  159. package/dist/v4/mod.d.ts +0 -27
  160. package/dist/v4/mod.js +0 -3
  161. package/dist/v4/preprocess.d.ts +0 -34
  162. package/dist/v4/preprocess.js +0 -32
  163. package/dist/v4/preprocess.js.map +0 -1
  164. package/dist/v4/root-node.d.ts +0 -59
  165. package/dist/v4/root-node.js +0 -4
  166. package/dist/v4/server.d.ts +0 -340
  167. package/dist/v4/server.js +0 -71
  168. package/dist/v4/server.js.map +0 -1
  169. package/dist/v4/vite.d.ts +0 -34
  170. package/dist/v4/vite.js +0 -31
  171. package/dist/v4/vite.js.map +0 -1
  172. package/dist/vite.d.ts +0 -31
  173. package/dist/vite.js +0 -24
  174. package/dist/vite.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal generated-code helpers used by the remote server runtime.
3
+ *
4
+ * @module
5
+ */
6
+ export * from "../remote/server.js";
@@ -0,0 +1,2 @@
1
+ import { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error } from "../remote/server.js";
2
+ export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error };
@@ -0,0 +1,15 @@
1
+ import type { Effect } from "effect";
2
+ /**
3
+ * Runtime helper emitted by the markup preprocessor for
4
+ * `{#await yield* expr}` blocks. Delegates to the dispatcher's
5
+ * promise mechanism — returns a Promise that resolves when the effect
6
+ * completes.
7
+ *
8
+ * @since 2.0.0
9
+ * @param id - Stable identifier generated from the expression's source
10
+ * position, used for cache lookups.
11
+ * @param deps - Array of reactive dependencies.
12
+ * @param factory - Generator function that yields the effect to run.
13
+ * @returns A Promise that resolves with the effect's result.
14
+ */
15
+ export declare function promise<A, E, R>(id: string, deps: readonly unknown[], factory: () => Effect.gen.Return<A, E, R>): Promise<A>;
@@ -0,0 +1,26 @@
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BSg2-ttN.js";
2
+ //#region src/markup/promise.ts
3
+ /**
4
+ * Runtime helper emitted by the markup preprocessor for
5
+ * `{#await yield* expr}` blocks. Delegates to the dispatcher's
6
+ * promise mechanism — returns a Promise that resolves when the effect
7
+ * completes.
8
+ *
9
+ * @since 2.0.0
10
+ * @param id - Stable identifier generated from the expression's source
11
+ * position, used for cache lookups.
12
+ * @param deps - Array of reactive dependencies.
13
+ * @param factory - Generator function that yields the effect to run.
14
+ * @returns A Promise that resolves with the effect's result.
15
+ */
16
+ function promise(id, deps, factory) {
17
+ return get_dispatcher().promise({
18
+ id,
19
+ deps,
20
+ factory
21
+ });
22
+ }
23
+ //#endregion
24
+ export { promise };
25
+
26
+ //# sourceMappingURL=promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/promise.ts"],"sourcesContent":["import { get_dispatcher } from \"$/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup preprocessor for\n * `{#await yield* expr}` blocks. Delegates to the dispatcher's\n * promise mechanism — returns a Promise that resolves when the effect\n * completes.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies.\n * @param factory - Generator function that yields the effect to run.\n * @returns A Promise that resolves with the effect's result.\n */\nexport function promise<A, E, R>(\n id: string,\n deps: readonly unknown[],\n factory: () => Effect.gen.Return<A, E, R>,\n): Promise<A> {\n return get_dispatcher().promise({ id, deps, factory });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,QACd,IACA,MACA,SACY;AACZ,QAAO,gBAAgB,CAAC,QAAQ;EAAE;EAAI;EAAM;EAAS,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Effect } from "effect";
2
+ /**
3
+ * Runtime helper emitted by the markup preprocessor for inline event
4
+ * handlers containing `yield*`. Wraps the user's generator in an
5
+ * `Effect.gen` and delegates to the dispatcher's fire-and-forget
6
+ * mechanism.
7
+ *
8
+ * @since 2.0.0
9
+ * @param factory - Generator function that yields the effect to run.
10
+ * @returns A Promise that resolves or rejects when the effect completes.
11
+ */
12
+ export declare function run<A, E, R>(factory: () => Effect.gen.Return<A, E, R>): Promise<A>;
@@ -0,0 +1,21 @@
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BSg2-ttN.js";
2
+ import { Effect } from "effect";
3
+ //#region src/markup/run.ts
4
+ /**
5
+ * Runtime helper emitted by the markup preprocessor for inline event
6
+ * handlers containing `yield*`. Wraps the user's generator in an
7
+ * `Effect.gen` and delegates to the dispatcher's fire-and-forget
8
+ * mechanism.
9
+ *
10
+ * @since 2.0.0
11
+ * @param factory - Generator function that yields the effect to run.
12
+ * @returns A Promise that resolves or rejects when the effect completes.
13
+ */
14
+ function run(factory) {
15
+ const effect = Effect.gen(factory);
16
+ return get_dispatcher().run(effect);
17
+ }
18
+ //#endregion
19
+ export { run };
20
+
21
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/run.ts"],"sourcesContent":["import { get_dispatcher } from \"$/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup preprocessor for inline event\n * handlers containing `yield*`. Wraps the user's generator in an\n * `Effect.gen` and delegates to the dispatcher's fire-and-forget\n * mechanism.\n *\n * @since 2.0.0\n * @param factory - Generator function that yields the effect to run.\n * @returns A Promise that resolves or rejects when the effect completes.\n */\nexport function run<A, E, R>(\n factory: () => Effect.gen.Return<A, E, R>,\n): Promise<A> {\n const effect = Effect.gen(factory);\n\n return get_dispatcher().run(effect);\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,IACd,SACY;CACZ,MAAM,SAAS,OAAO,IAAI,QAAQ;AAElC,QAAO,gBAAgB,CAAC,IAAI,OAAO"}
@@ -0,0 +1,6 @@
1
+ import type MagicString from "magic-string";
2
+ import type { HelperDeclaration, Insertion, MarkupRelocation, Replacement } from "./types.js";
3
+ export declare function create_source_map(magic: MagicString, filename: string): Record<string, unknown>;
4
+ export declare function blank_script_blocks(content: string): string;
5
+ export declare function inject_helpers(magic: MagicString, content: string, helpers?: HelperDeclaration[]): Insertion | undefined;
6
+ export declare function create_relocations(replacements: Replacement[], helper_insertion: Insertion | undefined): MarkupRelocation[];
@@ -0,0 +1,15 @@
1
+ import type { AST } from "svelte/compiler";
2
+ import type { MarkupCandidate, TagKind } from "./types.js";
3
+ /**
4
+ * Matches sanitized placeholders back to their Svelte AST context.
5
+ *
6
+ * @since 2.0.0
7
+ * @param ast - Parsed Svelte AST for the sanitized component markup.
8
+ * @param candidates - Placeholder candidates produced by the scanner.
9
+ * @returns Candidates paired with the markup context that determines how they
10
+ * should be emitted.
11
+ */
12
+ export declare function classify_candidates(ast: AST.Root, candidates: MarkupCandidate[]): Array<{
13
+ candidate: MarkupCandidate;
14
+ kind: TagKind;
15
+ }>;
@@ -0,0 +1,5 @@
1
+ export declare const HELPERS: {
2
+ readonly value: "__ser_markup_value";
3
+ readonly promise: "__ser_markup_promise";
4
+ readonly run: "__ser_markup_run";
5
+ };
@@ -0,0 +1,12 @@
1
+ import type { MarkupCandidate, Replacement, TagKind } from "./types.js";
2
+ /**
3
+ * Emits source edits for classified markup Effect expressions.
4
+ *
5
+ * @since 2.0.0
6
+ * @param classified - Candidates paired with their Svelte markup context.
7
+ * @returns Replacements ready to apply to the original component source.
8
+ */
9
+ export declare function emit_replacements(classified: Array<{
10
+ candidate: MarkupCandidate;
11
+ kind: TagKind;
12
+ }>): Replacement[];
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Strips an event handler arrow function down to its executable body.
3
+ *
4
+ * @since 2.0.0
5
+ * @param expr - Event handler expression text from the original markup.
6
+ * @returns Handler parameters, body text, and body offsets inside `expr`.
7
+ */
8
+ export declare function strip_arrow_function(expr: string): {
9
+ params: string;
10
+ body: string;
11
+ body_start: number;
12
+ body_end: number;
13
+ };
14
+ /**
15
+ * Classifies `yield*` placement inside an event handler body.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * analyze_event_body_yield_star("yield* save()");
20
+ * ```
21
+ *
22
+ * @since 2.0.0
23
+ * @param body - Event handler body text after the outer arrow has been
24
+ * stripped.
25
+ * @returns Whether the body has top-level yield* expressions and whether any
26
+ * yield* appears inside a nested non-generator callback.
27
+ */
28
+ export declare function analyze_event_body_yield_star(body: string): {
29
+ has_top_level_yield_star: boolean;
30
+ has_nested_invalid_yield_star: boolean;
31
+ };
32
+ /**
33
+ * Collects free identifiers that must be captured as reactive dependencies.
34
+ *
35
+ * @since 2.0.0
36
+ * @param expr_text - Markup expression text to inspect.
37
+ * @returns Identifier names referenced by the expression.
38
+ */
39
+ export declare function collect_free_identifiers(expr_text: string): string[];
@@ -0,0 +1,19 @@
1
+ import type { MarkupTransformResult } from "./types.js";
2
+ export type { MarkupRelocation, MarkupTransformResult } from "./types.js";
3
+ /**
4
+ * Transforms Svelte markup containing `{yield* expr}` brace expressions
5
+ * into calls to the markup runtime helpers (`value`, `promise`, `run`).
6
+ *
7
+ * Strategy: first find all brace expressions containing `yield*` via
8
+ * character scanning, replace them with placeholder identifiers, then
9
+ * parse the sanitized markup with Svelte's AST to determine the correct
10
+ * context for each placeholder (plain expression, #each, #await, event
11
+ * handler, etc.).
12
+ *
13
+ * @since 2.0.0
14
+ * @param content - The raw `.svelte` file content.
15
+ * @param filename - The source filename, used in error messages.
16
+ * @returns The transformed markup and a flag indicating whether yield* was
17
+ * found.
18
+ */
19
+ export declare function transform_markup_effect(content: string, filename: string): MarkupTransformResult;
@@ -0,0 +1,8 @@
1
+ import type { MarkupCandidate } from "./types.js";
2
+ interface SanitizeResult {
3
+ code: string;
4
+ candidates: MarkupCandidate[];
5
+ }
6
+ export declare function sanitize_markup(content: string, filename: string): SanitizeResult;
7
+ export {};
8
+ /** Free identifier collection helpers for generated closures. */
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Result of the markup preprocessor pass.
3
+ *
4
+ * @since 2.0.0
5
+ */
6
+ export interface MarkupTransformResult {
7
+ /** The transformed source code. */
8
+ code: string;
9
+ /** Whether any yield* expressions were found and lowered. */
10
+ has_yield: boolean;
11
+ /** Source map from transformed markup back to the original component. */
12
+ map?: Record<string, unknown>;
13
+ /** Offset ranges that preserve hoverable source spans inside lowered code. */
14
+ relocations?: MarkupRelocation[];
15
+ }
16
+ /** Offset mapping between original markup and generated helper code. */
17
+ export interface MarkupRelocation {
18
+ /** Start offset in the original source. */
19
+ originalStart: number;
20
+ /** End offset in the original source. */
21
+ originalEnd: number;
22
+ /** Start offset in the transformed source. */
23
+ generatedStart: number;
24
+ /** End offset in the transformed source. */
25
+ generatedEnd: number;
26
+ }
27
+ /** Describes a brace expression that contains yield* and needs lowering. */
28
+ export interface MarkupCandidate {
29
+ /** The placeholder identifier injected into the sanitized markup. */
30
+ placeholder: string;
31
+ /** Start offset of the expression in the original source. */
32
+ start: number;
33
+ /** End offset of the expression in the original source. */
34
+ end: number;
35
+ /** The expression text (without surrounding braces). */
36
+ expr_text: string;
37
+ /** Source filename used to keep generated cache ids component-scoped. */
38
+ filename: string;
39
+ /** Whether this expression is a key context (each/promise/render key). */
40
+ key: TagKind;
41
+ }
42
+ export type TagKind = "plain" | "each" | "await" | "event" | "render";
43
+ export interface Replacement {
44
+ start: number;
45
+ end: number;
46
+ text: string;
47
+ helpers?: HelperDeclaration[];
48
+ relocation?: PendingRelocation;
49
+ }
50
+ export interface HelperDeclaration {
51
+ text: string;
52
+ relocation?: PendingRelocation;
53
+ }
54
+ export interface PendingRelocation {
55
+ originalStart: number;
56
+ originalEnd: number;
57
+ generatedStartInReplacement: number;
58
+ generatedEndInReplacement: number;
59
+ }
60
+ export interface Insertion {
61
+ start: number;
62
+ text: string;
63
+ relocations?: PendingRelocation[];
64
+ }
@@ -0,0 +1 @@
1
+ export { type MarkupRelocation, type MarkupTransformResult, transform_markup_effect, } from "./transform/index.js";
@@ -0,0 +1,2 @@
1
+ import { t as transform_markup_effect } from "../chunks/transform-BtlxgJrg.js";
2
+ export { transform_markup_effect };
@@ -0,0 +1,20 @@
1
+ import type { Effect } from "effect";
2
+ /**
3
+ * Runtime helper emitted by the markup preprocessor for `{yield* expr}`
4
+ * expressions in Svelte templates. Delegates to the dispatcher's
5
+ * cached reactive value mechanism — returns the fallback synchronously,
6
+ * then the resolved value once the effect completes. The effect is still
7
+ * started during SSR so SvelteKit remote queries can register hydratable
8
+ * data before the HTML is sent.
9
+ *
10
+ * @since 2.0.0
11
+ * @param id - Stable identifier generated from the expression's source
12
+ * position, used for cache lookups.
13
+ * @param deps - Array of reactive dependencies (free identifiers in the
14
+ * expression). When any dep changes, the previous fiber is cancelled
15
+ * and a new one starts.
16
+ * @param fallback - Value returned while the effect is running.
17
+ * @param factory - Generator function that yields the effect to run.
18
+ * @returns The cached value if resolved, or the fallback.
19
+ */
20
+ export declare function value(id: string, deps: readonly unknown[], fallback: unknown, factory: () => Effect.gen.Return<unknown, unknown, unknown>): unknown;
@@ -0,0 +1,32 @@
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BSg2-ttN.js";
2
+ //#region src/markup/value.ts
3
+ /**
4
+ * Runtime helper emitted by the markup preprocessor for `{yield* expr}`
5
+ * expressions in Svelte templates. Delegates to the dispatcher's
6
+ * cached reactive value mechanism — returns the fallback synchronously,
7
+ * then the resolved value once the effect completes. The effect is still
8
+ * started during SSR so SvelteKit remote queries can register hydratable
9
+ * data before the HTML is sent.
10
+ *
11
+ * @since 2.0.0
12
+ * @param id - Stable identifier generated from the expression's source
13
+ * position, used for cache lookups.
14
+ * @param deps - Array of reactive dependencies (free identifiers in the
15
+ * expression). When any dep changes, the previous fiber is cancelled
16
+ * and a new one starts.
17
+ * @param fallback - Value returned while the effect is running.
18
+ * @param factory - Generator function that yields the effect to run.
19
+ * @returns The cached value if resolved, or the fallback.
20
+ */
21
+ function value(id, deps, fallback, factory) {
22
+ return get_dispatcher().value({
23
+ id,
24
+ deps,
25
+ fallback,
26
+ factory
27
+ });
28
+ }
29
+ //#endregion
30
+ export { value };
31
+
32
+ //# sourceMappingURL=value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/value.ts"],"sourcesContent":["import { get_dispatcher } from \"$/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup preprocessor for `{yield* expr}`\n * expressions in Svelte templates. Delegates to the dispatcher's\n * cached reactive value mechanism — returns the fallback synchronously,\n * then the resolved value once the effect completes. The effect is still\n * started during SSR so SvelteKit remote queries can register hydratable\n * data before the HTML is sent.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies (free identifiers in the\n * expression). When any dep changes, the previous fiber is cancelled\n * and a new one starts.\n * @param fallback - Value returned while the effect is running.\n * @param factory - Generator function that yields the effect to run.\n * @returns The cached value if resolved, or the fallback.\n */\nexport function value(\n id: string,\n deps: readonly unknown[],\n fallback: unknown,\n factory: () => Effect.gen.Return<unknown, unknown, unknown>,\n): unknown {\n return get_dispatcher().value({ id, deps, fallback, factory });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,MACd,IACA,MACA,UACA,SACS;AACT,QAAO,gBAAgB,CAAC,MAAM;EAAE;EAAI;EAAM;EAAU;EAAS,CAAC"}
package/.dist/mod.d.ts ADDED
@@ -0,0 +1,186 @@
1
+ import type { RequestEvent as RequestEventShape } from "./server/runtime.js";
2
+ import type { CommandFactory, FormFactory, PrerenderFactory, QueryFactory, ServerRuntimeFactory } from "./server/types.js";
3
+ import type { Context, Layer, ManagedRuntime } from "effect";
4
+ /**
5
+ * Result returned by the root Svelte markup preprocessor hook.
6
+ *
7
+ * @since 2.0.0
8
+ */
9
+ interface MarkupResult {
10
+ code: string;
11
+ }
12
+ /**
13
+ * Root preprocessor group shape. The root export keeps transform code lazy so
14
+ * client imports do not pull parser-only dependencies into the browser.
15
+ *
16
+ * @since 2.0.0
17
+ */
18
+ interface PreprocessGroup {
19
+ name: string;
20
+ markup(options: {
21
+ content: string;
22
+ filename: string;
23
+ }): MarkupResult | Promise<MarkupResult>;
24
+ }
25
+ /**
26
+ * Public API surface for `svelte-effect-runtime`.
27
+ *
28
+ * Call {@link ClientRuntime.make} in `hooks.client.ts`, call
29
+ * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin
30
+ * route server-only helpers to the server entrypoint automatically.
31
+ *
32
+ * @module
33
+ */
34
+ /**
35
+ * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once
36
+ * in `hooks.client.ts` to provide services to every component's effect
37
+ * blocks.
38
+ *
39
+ * If never called, a default empty-layer runtime is created lazily on
40
+ * the first `yield*` expression.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { ClientRuntime } from "svelte-effect-runtime";
45
+ * import { Db } from "./db.js";
46
+ *
47
+ * ClientRuntime.make(Db.Live);
48
+ * ```
49
+ *
50
+ * @since 2.0.0
51
+ */
52
+ export declare class ClientRuntime {
53
+ /**
54
+ * Build and cache the client-side dispatcher runtime.
55
+ *
56
+ * @since 2.0.0
57
+ * @param layer - Optional Effect layer to provide to the runtime.
58
+ */
59
+ static make<R = never>(layer?: Layer.Layer<R>): void;
60
+ }
61
+ /**
62
+ * Server-side runtime singleton export. In SvelteKit server files the Vite
63
+ * plugin rewrites root imports to `svelte-effect-runtime/server`, so this
64
+ * name resolves to the real server implementation before it is evaluated.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { ServerRuntime } from "svelte-effect-runtime";
69
+ *
70
+ * ServerRuntime.make();
71
+ * ```
72
+ *
73
+ * @since 2.0.0
74
+ */
75
+ export declare const ServerRuntime: ServerRuntimeFactory;
76
+ /**
77
+ * Remote query factory export for `.remote.ts` files imported from the root
78
+ * entrypoint. The Vite plugin rewrites it to the real server implementation.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * import { Query } from "svelte-effect-runtime";
83
+ *
84
+ * export const GetPosts = Query(Effect.succeed([]));
85
+ * ```
86
+ *
87
+ * @since 2.0.0
88
+ */
89
+ export declare const Query: QueryFactory;
90
+ /**
91
+ * Remote command factory export for `.remote.ts` files imported from the root
92
+ * entrypoint. The Vite plugin rewrites it to the real server implementation.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { Command } from "svelte-effect-runtime";
97
+ *
98
+ * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));
99
+ * ```
100
+ *
101
+ * @since 2.0.0
102
+ */
103
+ export declare const Command: CommandFactory;
104
+ /**
105
+ * Remote form factory export for `.remote.ts` files imported from the root
106
+ * entrypoint. The Vite plugin rewrites it to the real server implementation.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { Form } from "svelte-effect-runtime";
111
+ *
112
+ * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));
113
+ * ```
114
+ *
115
+ * @since 2.0.0
116
+ */
117
+ export declare const Form: FormFactory;
118
+ /**
119
+ * Remote prerender factory export for `.remote.ts` files imported from the
120
+ * root entrypoint. The Vite plugin rewrites it to the real server
121
+ * implementation.
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * import { Prerender } from "svelte-effect-runtime";
126
+ *
127
+ * export const GetBuildInfo = Prerender(() => Effect.succeed("ready"));
128
+ * ```
129
+ *
130
+ * @since 2.0.0
131
+ */
132
+ export declare const Prerender: PrerenderFactory;
133
+ /**
134
+ * Current SvelteKit request event service export for `.remote.ts` files
135
+ * imported from the root entrypoint. The Vite plugin rewrites it to the real
136
+ * server implementation.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * import { RequestEvent } from "svelte-effect-runtime";
141
+ *
142
+ * const event = yield* RequestEvent;
143
+ * ```
144
+ *
145
+ * @since 2.0.0
146
+ */
147
+ export declare const RequestEvent: Context.Reference<RequestEventShape>;
148
+ /**
149
+ * Returns the active server runtime when imported from a server file. The Vite
150
+ * plugin rewrites root imports to the real server implementation.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * import { get_server_runtime_or_throw } from "svelte-effect-runtime";
155
+ *
156
+ * const runtime = get_server_runtime_or_throw();
157
+ * ```
158
+ *
159
+ * @since 2.0.0
160
+ */
161
+ export declare const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never>;
162
+ /** Re-export error types users need for typed catch handlers. */
163
+ export type { FormError, FormIssue, RemoteFailure, RemoteHttpError, RemoteTransportError, RemoteValidationError, } from "./remote/shared.js";
164
+ export { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, } from "./remote/shared.js";
165
+ /** Re-export app setup helpers so users can import them from root. */
166
+ export { effect, type EffectOptions } from "./vite.js";
167
+ /** Re-export server helper types from the root entrypoint. */
168
+ export type { EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteLiveSource, EffectRemoteQuery, EffectRemoteQueryFunction, FormInvalid, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteLiveHandler, RemoteFormHandler, RemoteHandler, SchemaInput, CommandFactory, FormFactory, PrerenderFactory, ServerRuntimeFactory, StandardSchema, } from "./server/types.js";
169
+ /**
170
+ * Creates the Svelte preprocessor that lowers script and markup `yield*`
171
+ * expressions. The heavy transform module is loaded lazily so browser imports
172
+ * from the package root stay client-safe.
173
+ *
174
+ * @example
175
+ * ```js
176
+ * import { preprocess } from "svelte-effect-runtime";
177
+ *
178
+ * export default {
179
+ * preprocess: [preprocess()],
180
+ * };
181
+ * ```
182
+ *
183
+ * @since 2.0.0
184
+ * @returns A Svelte preprocessor group with an async markup hook.
185
+ */
186
+ export declare function preprocess(): PreprocessGroup;