svelte-effect-runtime 4.0.0 → 4.0.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 (146) hide show
  1. package/.dist/chunks/client-BrZka6DW.js +530 -0
  2. package/.dist/chunks/client-BrZka6DW.js.map +1 -0
  3. package/.dist/chunks/compiler-COVzgLYo.js +412 -0
  4. package/.dist/chunks/compiler-COVzgLYo.js.map +1 -0
  5. package/.dist/chunks/descriptors-B4otDlm1.js +216 -0
  6. package/.dist/chunks/descriptors-B4otDlm1.js.map +1 -0
  7. package/.dist/chunks/diagnostics-BDrky-Di.js +359 -0
  8. package/.dist/chunks/diagnostics-BDrky-Di.js.map +1 -0
  9. package/.dist/chunks/dispatcher-BA0PLQhA.js +16 -0
  10. package/.dist/chunks/dispatcher-BA0PLQhA.js.map +1 -0
  11. package/.dist/chunks/{dispatcher-DOx8iC6r.js → dispatcher-_x0MQZBS.js} +84 -258
  12. package/.dist/chunks/dispatcher-_x0MQZBS.js.map +1 -0
  13. package/.dist/chunks/{errors-IJjsUwrE.js → errors-CLsbGjIa.js} +39 -44
  14. package/.dist/chunks/errors-CLsbGjIa.js.map +1 -0
  15. package/.dist/chunks/live-BundLSoY.js +146 -0
  16. package/.dist/chunks/live-BundLSoY.js.map +1 -0
  17. package/.dist/chunks/live-CHK0RrZu.js +10 -0
  18. package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
  19. package/.dist/chunks/{remote-client-CVI4t66c.js → remote-client-mkQAfP1G.js} +29 -23
  20. package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
  21. package/.dist/chunks/{runtime-GBQz32DZ.js → runtime-HDTlEnzp.js} +3 -27
  22. package/.dist/chunks/runtime-HDTlEnzp.js.map +1 -0
  23. package/.dist/chunks/{server-D1LcDnZE.js → server-BNrA1I-u.js} +15 -84
  24. package/.dist/chunks/server-BNrA1I-u.js.map +1 -0
  25. package/.dist/chunks/source-scan-9pZxnfct.js +1059 -0
  26. package/.dist/chunks/source-scan-9pZxnfct.js.map +1 -0
  27. package/.dist/chunks/{transform-jNUr65K9.js → transform-BXyYUAez.js} +184 -358
  28. package/.dist/chunks/transform-BXyYUAez.js.map +1 -0
  29. package/.dist/compiler/markup-identifiers.d.ts +2 -0
  30. package/.dist/compiler/remote-client.d.ts +1 -19
  31. package/.dist/compiler/source-scan.d.ts +11 -108
  32. package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
  33. package/.dist/compiler.d.ts +6 -0
  34. package/.dist/compiler.js +1 -1
  35. package/.dist/detect.d.ts +0 -31
  36. package/.dist/detect.js +0 -39
  37. package/.dist/detect.js.map +1 -1
  38. package/.dist/diagnostics.d.ts +0 -16
  39. package/.dist/dispatcher/deps.d.ts +3 -14
  40. package/.dist/dispatcher/fibers.d.ts +5 -46
  41. package/.dist/dispatcher/index.d.ts +1 -143
  42. package/.dist/dispatcher/types.d.ts +0 -151
  43. package/.dist/dispatcher.js +1 -1
  44. package/.dist/errors.d.ts +30 -42
  45. package/.dist/generated/dispatcher.d.ts +0 -50
  46. package/.dist/generators.d.ts +1 -12
  47. package/.dist/internal/descriptors.d.ts +0 -16
  48. package/.dist/internal/generators.js +13 -8
  49. package/.dist/internal/generators.js.map +1 -1
  50. package/.dist/internal/live.d.ts +9 -0
  51. package/.dist/internal/remote-client.js +2 -2
  52. package/.dist/internal/remote-server.js +2 -2
  53. package/.dist/internal/schema.d.ts +0 -54
  54. package/.dist/live.d.ts +9 -26
  55. package/.dist/markup/event-attributes.d.ts +0 -32
  56. package/.dist/markup/promise.d.ts +1 -23
  57. package/.dist/markup/promise.js +2 -18
  58. package/.dist/markup/promise.js.map +1 -1
  59. package/.dist/markup/run.d.ts +1 -10
  60. package/.dist/markup/run.js +2 -11
  61. package/.dist/markup/run.js.map +1 -1
  62. package/.dist/markup/transform/apply.d.ts +4 -4
  63. package/.dist/markup/transform/classify.d.ts +2 -11
  64. package/.dist/markup/transform/constants.d.ts +1 -1
  65. package/.dist/markup/transform/effect-bindings.d.ts +2 -26
  66. package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
  67. package/.dist/markup/transform/emit.d.ts +2 -11
  68. package/.dist/markup/transform/expressions.d.ts +0 -35
  69. package/.dist/markup/transform/scan.d.ts +3 -22
  70. package/.dist/markup/transform/types.d.ts +1 -129
  71. package/.dist/markup/transform.js +1 -1
  72. package/.dist/markup/value.d.ts +1 -18
  73. package/.dist/markup/value.js +2 -19
  74. package/.dist/markup/value.js.map +1 -1
  75. package/.dist/mod.d.ts +3 -8
  76. package/.dist/mod.js +5 -5
  77. package/.dist/mod.js.map +1 -1
  78. package/.dist/remote/cause-codec.d.ts +3 -37
  79. package/.dist/remote/client/command.d.ts +3 -17
  80. package/.dist/remote/client/form-data.d.ts +0 -7
  81. package/.dist/remote/client/form-enhance.d.ts +0 -7
  82. package/.dist/remote/client/form-transport.d.ts +14 -20
  83. package/.dist/remote/client/form.d.ts +4 -24
  84. package/.dist/remote/client/index.d.ts +2 -1
  85. package/.dist/remote/client/prerender.d.ts +6 -0
  86. package/.dist/remote/client/query-result.d.ts +2 -14
  87. package/.dist/remote/client/query.d.ts +8 -48
  88. package/.dist/remote/client/responses.d.ts +3 -27
  89. package/.dist/remote/client/types.d.ts +16 -110
  90. package/.dist/remote/client/utils.d.ts +0 -8
  91. package/.dist/remote/client.d.ts +2 -2
  92. package/.dist/remote/client.js +2 -2
  93. package/.dist/remote/effect.d.ts +6 -0
  94. package/.dist/remote/failures.d.ts +4 -0
  95. package/.dist/remote/query-update.d.ts +2 -0
  96. package/.dist/remote/resource.d.ts +25 -0
  97. package/.dist/remote/server.d.ts +5 -50
  98. package/.dist/remote/server.js +2 -2
  99. package/.dist/remote/shared.d.ts +6 -145
  100. package/.dist/remote/shared.js +6 -127
  101. package/.dist/remote/shared.js.map +1 -1
  102. package/.dist/runtime/transform.js +5 -22
  103. package/.dist/runtime/transform.js.map +1 -1
  104. package/.dist/script-transform/ast.d.ts +0 -46
  105. package/.dist/script-transform/imports.d.ts +0 -38
  106. package/.dist/script-transform/lower.d.ts +0 -9
  107. package/.dist/script-transform/runes.d.ts +0 -10
  108. package/.dist/script-transform/runtime-block.d.ts +0 -17
  109. package/.dist/script-transform/source.d.ts +0 -24
  110. package/.dist/script-transform/types.d.ts +1 -126
  111. package/.dist/server/effects.d.ts +4 -53
  112. package/.dist/server/factories.d.ts +7 -7
  113. package/.dist/server/index.d.ts +1 -1
  114. package/.dist/server/invalid.d.ts +0 -7
  115. package/.dist/server/live-snapshot.d.ts +5 -0
  116. package/.dist/server/remote-handler-context.d.ts +5 -0
  117. package/.dist/server/runtime.d.ts +6 -24
  118. package/.dist/server/schema.d.ts +0 -14
  119. package/.dist/server/transport.d.ts +2 -0
  120. package/.dist/server/types.d.ts +49 -26
  121. package/.dist/server/wrappers.d.ts +3 -40
  122. package/.dist/server.d.ts +1 -1
  123. package/.dist/server.js +200 -215
  124. package/.dist/server.js.map +1 -1
  125. package/.dist/yieldable.d.ts +1 -35
  126. package/package.json +2 -2
  127. package/.dist/chunks/client-DcZUV4rR.js +0 -653
  128. package/.dist/chunks/client-DcZUV4rR.js.map +0 -1
  129. package/.dist/chunks/compiler-BBPNyXmQ.js +0 -460
  130. package/.dist/chunks/compiler-BBPNyXmQ.js.map +0 -1
  131. package/.dist/chunks/dispatcher-DOx8iC6r.js.map +0 -1
  132. package/.dist/chunks/dispatcher-H-Ia0Os4.js +0 -47
  133. package/.dist/chunks/dispatcher-H-Ia0Os4.js.map +0 -1
  134. package/.dist/chunks/errors-IJjsUwrE.js.map +0 -1
  135. package/.dist/chunks/live-BXAKre_4.js +0 -104
  136. package/.dist/chunks/live-BXAKre_4.js.map +0 -1
  137. package/.dist/chunks/remote-client-CVI4t66c.js.map +0 -1
  138. package/.dist/chunks/runtime-GBQz32DZ.js.map +0 -1
  139. package/.dist/chunks/schema-D9pct6Y5.js +0 -89
  140. package/.dist/chunks/schema-D9pct6Y5.js.map +0 -1
  141. package/.dist/chunks/server-D1LcDnZE.js.map +0 -1
  142. package/.dist/chunks/source-scan-C4PsggID.js +0 -341
  143. package/.dist/chunks/source-scan-C4PsggID.js.map +0 -1
  144. package/.dist/chunks/transform-jNUr65K9.js.map +0 -1
  145. package/.dist/remote/client/effect.d.ts +0 -29
  146. package/.dist/remote/client/failures.d.ts +0 -42
@@ -1 +1 @@
1
- {"version":3,"file":"detect.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/detect.ts"],"sourcesContent":["import ts from \"typescript\";\n\n/**\n * Returns `true` when the node tree contains a `yield*` expression that is\n * not inside any function boundary (arrow function, function declaration,\n * function expression, method).\n *\n * @example\n * ```ts\n * const sf = ts.createSourceFile(\"test.ts\", \"yield* foo()\", ...);\n * contains_top_level_yield_star(sf.statements[0]); // true\n * ```\n *\n * @since 2.0.0\n * @param node - The root node to search from.\n * @returns Whether a top-level yield* expression was found.\n */\nexport function contains_top_level_yield_star(node: ts.Node): boolean {\n\tif (is_function_boundary(node)) {\n\t\treturn false;\n\t}\n\n\tif (is_yield_star_expression(node)) {\n\t\treturn true;\n\t}\n\n\treturn node.getChildren().some((child) => contains_top_level_yield_star(child));\n}\n\n/**\n * Returns `true` when the node is a function-like boundary that owns its\n * own yield/yield* semantics. A function boundary includes arrow functions,\n * function declarations, function expressions, methods, get accessors, and\n * set accessors.\n *\n * @example\n * ```ts\n * const stmt = parseStatement(\"function foo() {}\");\n * is_function_boundary(stmt); // true\n * ```\n *\n * @since 2.0.0\n * @param node - The node to check.\n * @returns Whether the node is a function boundary.\n */\nexport function is_function_boundary(node: ts.Node): boolean {\n\treturn (\n\t\tts.isArrowFunction(node) ||\n\t\tts.isFunctionDeclaration(node) ||\n\t\tts.isFunctionExpression(node) ||\n\t\tts.isMethodDeclaration(node) ||\n\t\tts.isGetAccessorDeclaration(node) ||\n\t\tts.isSetAccessorDeclaration(node)\n\t);\n}\n\n/**\n * Returns `true` when the node is a binary expression shaped like\n * `yield * operand` — a yield* delegate expression in TypeScript's AST.\n *\n * @since 2.0.0\n * @param node - The node to check.\n * @returns Whether the node is a `yield*` expression.\n */\nfunction is_yield_star_expression(node: ts.Node): boolean {\n\treturn (\n\t\tts.isBinaryExpression(node) &&\n\t\tnode.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n\t\tts.isIdentifier(node.left) &&\n\t\tnode.left.text === \"yield\"\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,8BAA8B,MAAwB;CACrE,IAAI,qBAAqB,IAAI,GAC5B,OAAO;CAGR,IAAI,yBAAyB,IAAI,GAChC,OAAO;CAGR,OAAO,KAAK,YAAY,CAAC,CAAC,MAAM,UAAU,8BAA8B,KAAK,CAAC;AAC/E;;;;;;;;;;;;;;;;;AAkBA,SAAgB,qBAAqB,MAAwB;CAC5D,OACC,GAAG,gBAAgB,IAAI,KACvB,GAAG,sBAAsB,IAAI,KAC7B,GAAG,qBAAqB,IAAI,KAC5B,GAAG,oBAAoB,IAAI,KAC3B,GAAG,yBAAyB,IAAI,KAChC,GAAG,yBAAyB,IAAI;AAElC;;;;;;;;;AAUA,SAAS,yBAAyB,MAAwB;CACzD,OACC,GAAG,mBAAmB,IAAI,KAC1B,KAAK,cAAc,SAAS,GAAG,WAAW,iBAC1C,GAAG,aAAa,KAAK,IAAI,KACzB,KAAK,KAAK,SAAS;AAErB"}
1
+ {"version":3,"file":"detect.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/detect.ts"],"sourcesContent":["import ts from \"typescript\";\n\nexport function contains_top_level_yield_star(node: ts.Node): boolean {\n\tif (is_function_boundary(node)) {\n\t\treturn false;\n\t}\n\n\tif (is_yield_star_expression(node)) {\n\t\treturn true;\n\t}\n\n\treturn node.getChildren().some((child) => contains_top_level_yield_star(child));\n}\n\nexport function is_function_boundary(node: ts.Node): boolean {\n\treturn (\n\t\tts.isArrowFunction(node) ||\n\t\tts.isFunctionDeclaration(node) ||\n\t\tts.isFunctionExpression(node) ||\n\t\tts.isMethodDeclaration(node) ||\n\t\tts.isGetAccessorDeclaration(node) ||\n\t\tts.isSetAccessorDeclaration(node)\n\t);\n}\n\nfunction is_yield_star_expression(node: ts.Node): boolean {\n\treturn (\n\t\tts.isBinaryExpression(node) &&\n\t\tnode.operatorToken.kind === ts.SyntaxKind.AsteriskToken &&\n\t\tts.isIdentifier(node.left) &&\n\t\tnode.left.text === \"yield\"\n\t);\n}\n"],"mappings":";;AAEA,SAAgB,8BAA8B,MAAwB;CACrE,IAAI,qBAAqB,IAAI,GAC5B,OAAO;CAGR,IAAI,yBAAyB,IAAI,GAChC,OAAO;CAGR,OAAO,KAAK,YAAY,CAAC,CAAC,MAAM,UAAU,8BAA8B,KAAK,CAAC;AAC/E;AAEA,SAAgB,qBAAqB,MAAwB;CAC5D,OACC,GAAG,gBAAgB,IAAI,KACvB,GAAG,sBAAsB,IAAI,KAC7B,GAAG,qBAAqB,IAAI,KAC5B,GAAG,oBAAoB,IAAI,KAC3B,GAAG,yBAAyB,IAAI,KAChC,GAAG,yBAAyB,IAAI;AAElC;AAEA,SAAS,yBAAyB,MAAwB;CACzD,OACC,GAAG,mBAAmB,IAAI,KAC1B,KAAK,cAAc,SAAS,GAAG,WAAW,iBAC1C,GAAG,aAAa,KAAK,IAAI,KACzB,KAAK,KAAK,SAAS;AAErB"}
@@ -1,19 +1,3 @@
1
- /**
2
- * Finds best-effort SER usage diagnostics in Svelte component markup.
3
- *
4
- * @example
5
- * ```ts
6
- * const diagnostics = find_svelte_effect_diagnostics(
7
- * `<button onclick={Effect.gen}>save</button>`,
8
- * "Button.svelte",
9
- * );
10
- * ```
11
- *
12
- * @since 2.0.0
13
- * @param code - Svelte component source to scan for suspicious Effect usage.
14
- * @param filename - Filename used in diagnostic messages.
15
- * @returns Warning diagnostics with a message and source location.
16
- */
17
1
  export declare function find_svelte_effect_diagnostics(code: string, filename: string): Array<{
18
2
  message: string;
19
3
  line: number;
@@ -1,14 +1,3 @@
1
- /**
2
- * Builds a deterministic cache key from a dependency array.
3
- *
4
- * @example
5
- * ```ts
6
- * const key = hash_deps([user_id, filters]);
7
- * ```
8
- *
9
- * @since 2.0.0
10
- * @param deps - Dependency array to encode for cache lookup.
11
- * @returns A structured string key suitable for Map lookups.
12
- * @internal
13
- */
14
- export declare function hash_deps(deps: readonly unknown[]): string;
1
+ /** Assigns stable identities to object dependencies while hashing value dependencies. */
2
+ export type DependencyHasher = (deps: readonly unknown[]) => string;
3
+ export declare function make_dependency_hasher(): DependencyHasher;
@@ -1,54 +1,13 @@
1
1
  import type { Fiber as FiberType } from "effect/Fiber";
2
- import type { ManagedRuntime as ManagedRuntimeType } from "effect/ManagedRuntime";
3
- /**
4
- * Callbacks fired when a watched dispatcher fiber completes.
5
- *
6
- * @example
7
- * ```ts
8
- * const callbacks: FiberWatchCallbacks<number> = {
9
- * on_success: (value) => cache.set(key, value),
10
- * };
11
- * ```
12
- *
13
- * @since 2.0.0
14
- * @internal
15
- */
2
+ import { Effect } from "effect";
16
3
  export interface FiberWatchCallbacks<A> {
17
4
  on_complete?: () => void;
18
5
  on_success?: (value: A) => void;
19
6
  on_failure?: (error: unknown) => void;
20
7
  surface_failure?: boolean;
21
8
  }
22
- /**
23
- * Interrupts a dispatcher fiber through its managed runtime.
24
- *
25
- * @example
26
- * ```ts
27
- * interrupt_fiber(runtime, fiber);
28
- * ```
29
- *
30
- * @since 2.0.0
31
- * @param runtime - Managed runtime that owns the fiber.
32
- * @param fiber - Fiber to interrupt.
33
- * @returns Nothing.
34
- * @internal
35
- */
36
- export declare function interrupt_fiber(runtime: ManagedRuntimeType<unknown, unknown>, fiber: FiberType<unknown, unknown>): void;
37
- /**
38
- * Watches a dispatcher fiber, runs completion callbacks, and surfaces
39
- * non-interrupt failures on the microtask queue.
40
- *
41
- * @example
42
- * ```ts
43
- * watch_fiber_exit({ runtime, fiber, on_complete: cleanup });
44
- * ```
45
- *
46
- * @since 2.0.0
47
- * @param options - Runtime, fiber, and callbacks used for the watcher.
48
- * @returns Nothing.
49
- * @internal
50
- */
51
- export declare function watch_fiber_exit<A>(options: {
52
- runtime: ManagedRuntimeType<unknown, unknown>;
9
+ export declare const InterruptFiber: (fiber: FiberType<unknown, unknown>) => Effect.Effect<void, never, never>;
10
+ /** Observes fiber completion and surfaces failures without taking ownership of the fiber. */
11
+ export declare const WatchFiberExit: <A>(options: {
53
12
  fiber: FiberType<unknown, unknown>;
54
- } & FiberWatchCallbacks<A>): void;
13
+ } & FiberWatchCallbacks<A>) => Effect.Effect<void, never, never>;
@@ -1,163 +1,21 @@
1
+ import type { DispatcherEvent, Dispose, MarkupPromiseEvent, MarkupRunEvent, MarkupValueEvent, PromiseOptions, ValueOptions } from "./types.js";
1
2
  import type { ManagedRuntime as ManagedRuntimeType } from "effect/ManagedRuntime";
2
3
  import { Effect, Layer } from "effect";
3
- import type { DispatcherEvent, Dispose, MarkupPromiseEvent, MarkupRunEvent, MarkupValueEvent, PromiseOptions, ValueOptions } from "./types.js";
4
4
  export { Code } from "./types.js";
5
5
  export type { Dispose, PromiseOptions, ValueOptions } from "./types.js";
6
- /**
7
- * Unified effect block dispatcher. Manages the fiber lifecycle of every
8
- * effect block and wires results into reactive channels.
9
- *
10
- * @example
11
- * ```ts
12
- * const dispatcher = new Dispatcher();
13
- * const cancel = dispatcher.fork(Effect.log("running"));
14
- * cancel();
15
- * ```
16
- *
17
- * @since 2.0.0
18
- * @internal
19
- */
20
6
  export declare class Dispatcher {
21
7
  #private;
22
- /**
23
- * Creates a dispatcher with an optional layer and installs it as the global
24
- * singleton returned by {@link get_dispatcher}.
25
- *
26
- * @example
27
- * ```ts
28
- * const dispatcher = Dispatcher.make(Db.Live);
29
- * ```
30
- *
31
- * @since 2.0.0
32
- * @param layer - Optional Effect layer to provide to the runtime.
33
- * @returns The newly created dispatcher.
34
- */
35
8
  static make<R = never>(layer?: Layer.Layer<R>): Dispatcher;
36
- /**
37
- * Creates a dispatcher backed by the provided managed runtime.
38
- *
39
- * @example
40
- * ```ts
41
- * const dispatcher = new Dispatcher(runtime);
42
- * ```
43
- *
44
- * @since 2.0.0
45
- * @param runtime - Managed runtime to use, or an empty-layer runtime when
46
- * omitted.
47
- */
48
9
  constructor(runtime?: ManagedRuntimeType<unknown, unknown>);
49
- /**
50
- * Handles a transform-generated dispatcher event.
51
- *
52
- * @example
53
- * ```ts
54
- * const value = dispatcher.emit({
55
- * type: Code.Markup.Value,
56
- * id: "Component.svelte:1:2",
57
- * deps: [],
58
- * fallback: undefined,
59
- * fn: function* () {
60
- * return yield* Effect.succeed(1);
61
- * },
62
- * });
63
- * ```
64
- *
65
- * @since 3.3.0
66
- * @param event - Generated event describing the dispatcher operation to run.
67
- * @returns The operation result for the emitted dispatcher event.
68
- */
69
10
  emit<A, F>(event: MarkupValueEvent<A, F>): A | F;
70
11
  emit<A>(event: MarkupPromiseEvent<A>): Promise<A>;
71
12
  emit<A>(event: MarkupRunEvent<A>): Promise<A>;
72
13
  emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;
73
- /**
74
- * Forks an effect as a managed fiber and returns a cleanup function.
75
- *
76
- * @example
77
- * ```ts
78
- * const dispose = dispatcher.fork(Effect.log("clicked"));
79
- * ```
80
- *
81
- * @since 2.0.0
82
- * @param effect - Effect to fork.
83
- * @returns A function that interrupts the fiber.
84
- */
85
14
  fork<A, E, R>(effect: Effect.Effect<A, E, R>): Dispose;
86
- /**
87
- * Forks an effect and exposes its result as a cached reactive value.
88
- *
89
- * @example
90
- * ```ts
91
- * const user = dispatcher.value({ id, deps, fallback, factory });
92
- * ```
93
- *
94
- * @since 2.0.0
95
- * @param options - Value id, dependency array, fallback, and effect factory.
96
- * @returns The cached value if resolved, otherwise the fallback.
97
- */
98
15
  value<A>(options: ValueOptions<A>): A;
99
- /**
100
- * Forks an effect and exposes its completion as a cached promise.
101
- *
102
- * @example
103
- * ```ts
104
- * const promise = dispatcher.promise({ id, deps, factory });
105
- * ```
106
- *
107
- * @since 2.0.0
108
- * @param options - Promise id, dependency array, and effect factory.
109
- * @returns A promise that resolves with the effect result.
110
- */
111
16
  promise<A>(options: PromiseOptions<A>): Promise<A>;
112
- /**
113
- * Runs an event-handler effect and surfaces failures to Svelte.
114
- *
115
- * @example
116
- * ```ts
117
- * await dispatcher.run(Effect.log("submit"));
118
- * ```
119
- *
120
- * @since 2.0.0
121
- * @param effect - Effect to execute.
122
- * @returns A promise that resolves or rejects when the effect completes.
123
- */
124
17
  run<A, E, R>(effect: Effect.Effect<A, E, R>): Promise<A>;
125
- /**
126
- * Cancels all running fibers and releases cached values.
127
- *
128
- * @example
129
- * ```ts
130
- * dispatcher.dispose();
131
- * ```
132
- *
133
- * @since 2.0.0
134
- * @returns Nothing.
135
- */
136
18
  dispose(): void;
137
19
  }
138
- /**
139
- * Resolves the active dispatcher, creating a default one if necessary.
140
- *
141
- * @example
142
- * ```ts
143
- * const dispatcher = get_dispatcher();
144
- * ```
145
- *
146
- * @since 2.0.0
147
- * @returns The active dispatcher singleton.
148
- * @internal
149
- */
150
20
  export declare function get_dispatcher(): Dispatcher;
151
- /**
152
- * Resets the internal singleton dispatcher used by source-level tests.
153
- *
154
- * @example
155
- * ```ts
156
- * reset_dispatcher();
157
- * ```
158
- *
159
- * @since 2.0.0
160
- * @returns Nothing.
161
- * @internal
162
- */
163
21
  export declare function reset_dispatcher(): void;
@@ -1,15 +1,4 @@
1
1
  import type { Effect } from "effect";
2
- /**
3
- * Stable operation codes used by transform-generated dispatcher events.
4
- *
5
- * @example
6
- * ```ts
7
- * const type = Code.Markup.Promise;
8
- * ```
9
- *
10
- * @since 3.3.0
11
- * @internal
12
- */
13
2
  export declare const Code: {
14
3
  readonly Markup: {
15
4
  readonly Promise: "MarkupPromise";
@@ -17,187 +6,47 @@ export declare const Code: {
17
6
  readonly Value: "MarkupValue";
18
7
  };
19
8
  };
20
- /**
21
- * Options for markup promise behavior during server rendering.
22
- *
23
- * @example
24
- * ```ts
25
- * const options: MarkupPromiseOptions = { ssr: "pending" };
26
- * ```
27
- *
28
- * @since 3.3.0
29
- * @internal
30
- */
31
9
  export interface MarkupPromiseOptions {
32
10
  /** Keep the SSR promise pending so Svelte renders an await block fallback. */
33
11
  ssr?: "pending";
34
12
  }
35
- /**
36
- * Minimal cleanup handle returned by dispatcher lifecycle hooks.
37
- *
38
- * @example
39
- * ```ts
40
- * const dispose: Dispose = dispatcher.fork(program);
41
- * dispose();
42
- * ```
43
- *
44
- * @since 2.0.0
45
- * @internal
46
- */
47
13
  export type Dispose = () => void;
48
- /**
49
- * Options for a cached dispatcher value block.
50
- *
51
- * @example
52
- * ```ts
53
- * const options: ValueOptions<number> = {
54
- * id: "count",
55
- * deps: [],
56
- * fallback: 0,
57
- * factory: () => Effect.succeed(1),
58
- * };
59
- * ```
60
- *
61
- * @since 2.0.0
62
- * @internal
63
- */
64
14
  export interface ValueOptions<A> {
65
15
  /** Stable cache key for this value block. */
66
16
  id: string;
67
- /** Reactive dependency array. */
68
17
  deps: readonly unknown[];
69
18
  /** Value returned synchronously while the effect is running or during SSR. */
70
19
  fallback: A;
71
- /** Generator function that yields the effect to run. */
72
20
  factory: () => Effect.gen.Return<A, unknown, unknown>;
73
21
  }
74
- /**
75
- * Options for a cached dispatcher promise block.
76
- *
77
- * @example
78
- * ```ts
79
- * const options: PromiseOptions<number> = {
80
- * id: "count",
81
- * deps: [],
82
- * factory: () => Effect.succeed(1),
83
- * };
84
- * ```
85
- *
86
- * @since 2.0.0
87
- * @internal
88
- */
89
22
  export interface PromiseOptions<A> {
90
23
  /** Stable cache key for this promise block. */
91
24
  id: string;
92
- /** Reactive dependency array. */
93
25
  deps: readonly unknown[];
94
- /** Generator function that yields the effect to run. */
95
26
  factory: () => Effect.gen.Return<A, unknown, unknown>;
96
27
  }
97
- /**
98
- * Generated event that reads a markup expression through the cached value
99
- * channel.
100
- *
101
- * @example
102
- * ```ts
103
- * const event: MarkupValueEvent<number, undefined> = {
104
- * type: Code.Markup.Value,
105
- * id: "Component.svelte:1:2",
106
- * deps: [],
107
- * fallback: undefined,
108
- * fn: function* () {
109
- * return yield* Effect.succeed(1);
110
- * },
111
- * };
112
- * ```
113
- *
114
- * @since 3.3.0
115
- * @internal
116
- */
117
28
  export interface MarkupValueEvent<A, F> {
118
- /** Dispatcher code identifying a markup value read. */
119
29
  type: typeof Code.Markup.Value;
120
30
  /** Stable identifier generated from the expression's source position. */
121
31
  id: string;
122
- /** Reactive dependency array captured from free identifiers. */
123
32
  deps: readonly unknown[];
124
33
  /** Value returned synchronously while the effect is pending. */
125
34
  fallback: F;
126
- /** Generator function that yields the effect to run. */
127
35
  fn: () => Effect.gen.Return<A, unknown, unknown>;
128
36
  }
129
- /**
130
- * Generated event that reads a markup expression through the cached promise
131
- * channel.
132
- *
133
- * @example
134
- * ```ts
135
- * const event: MarkupPromiseEvent<number> = {
136
- * type: Code.Markup.Promise,
137
- * id: "Component.svelte:1:2",
138
- * deps: [],
139
- * fn: function* () {
140
- * return yield* Effect.succeed(1);
141
- * },
142
- * };
143
- * ```
144
- *
145
- * @since 3.3.0
146
- * @internal
147
- */
148
37
  export interface MarkupPromiseEvent<A> {
149
- /** Dispatcher code identifying a markup promise read. */
150
38
  type: typeof Code.Markup.Promise;
151
39
  /** Stable identifier generated from the expression's source position. */
152
40
  id: string;
153
- /** Reactive dependency array captured from free identifiers. */
154
41
  deps: readonly unknown[];
155
- /** Generator function that yields the effect to run. */
156
42
  fn: () => Effect.gen.Return<A, unknown, unknown>;
157
43
  /** Value resolved during SSR when a fallback is required. */
158
44
  ssr_fallback?: A;
159
45
  /** Optional SSR behavior for await blocks and similar contexts. */
160
46
  options?: MarkupPromiseOptions;
161
47
  }
162
- /**
163
- * Generated event that runs an event-handler Effect.
164
- *
165
- * @example
166
- * ```ts
167
- * const event: MarkupRunEvent<void> = {
168
- * type: Code.Markup.Run,
169
- * fn: function* () {
170
- * yield* Effect.void;
171
- * },
172
- * };
173
- * ```
174
- *
175
- * @since 3.3.0
176
- * @internal
177
- */
178
48
  export interface MarkupRunEvent<A> {
179
- /** Dispatcher code identifying a markup event-handler run. */
180
49
  type: typeof Code.Markup.Run;
181
- /** Generator function that yields the effect to run. */
182
50
  fn: () => Effect.gen.Return<A, unknown, unknown>;
183
51
  }
184
- /**
185
- * Union of generated dispatcher events.
186
- *
187
- * @example
188
- * ```ts
189
- * const event: DispatcherEvent<number, undefined> = {
190
- * type: Code.Markup.Value,
191
- * id: "Component.svelte:1:2",
192
- * deps: [],
193
- * fallback: undefined,
194
- * fn: function* () {
195
- * return yield* Effect.succeed(1);
196
- * },
197
- * };
198
- * ```
199
- *
200
- * @since 3.3.0
201
- * @internal
202
- */
203
52
  export type DispatcherEvent<A, F = A> = MarkupPromiseEvent<A> | MarkupRunEvent<A> | MarkupValueEvent<A, F>;
@@ -1,2 +1,2 @@
1
- import { i as Code, n as get_dispatcher, r as reset_dispatcher, t as Dispatcher } from "./chunks/dispatcher-DOx8iC6r.js";
1
+ import { i as Code, n as get_dispatcher, r as reset_dispatcher, t as Dispatcher } from "./chunks/dispatcher-_x0MQZBS.js";
2
2
  export { Code, Dispatcher, get_dispatcher, reset_dispatcher };