svelte-effect-runtime 4.0.0 → 4.1.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 (150) hide show
  1. package/.dist/chunks/client-DbwVAMWm.js +530 -0
  2. package/.dist/chunks/client-DbwVAMWm.js.map +1 -0
  3. package/.dist/chunks/compiler-Dpyu4Owd.js +412 -0
  4. package/.dist/chunks/compiler-Dpyu4Owd.js.map +1 -0
  5. package/.dist/chunks/descriptors-q909VWyR.js +216 -0
  6. package/.dist/chunks/descriptors-q909VWyR.js.map +1 -0
  7. package/.dist/chunks/diagnostics-DLwwrBWb.js +359 -0
  8. package/.dist/chunks/diagnostics-DLwwrBWb.js.map +1 -0
  9. package/.dist/chunks/dispatcher-CTWINW5I.js +534 -0
  10. package/.dist/chunks/dispatcher-CTWINW5I.js.map +1 -0
  11. package/.dist/chunks/dispatcher-pZPzarul.js +23 -0
  12. package/.dist/chunks/dispatcher-pZPzarul.js.map +1 -0
  13. package/.dist/chunks/{errors-IJjsUwrE.js → errors-qhcbUH6o.js} +56 -44
  14. package/.dist/chunks/errors-qhcbUH6o.js.map +1 -0
  15. package/.dist/chunks/live-BW7xZKjb.js +146 -0
  16. package/.dist/chunks/live-BW7xZKjb.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-CPosEhGl.js} +3 -27
  22. package/.dist/chunks/runtime-CPosEhGl.js.map +1 -0
  23. package/.dist/chunks/{server-D1LcDnZE.js → server-yQrNoiCR.js} +15 -84
  24. package/.dist/chunks/server-yQrNoiCR.js.map +1 -0
  25. package/.dist/chunks/source-scan-cSawCvsg.js +1059 -0
  26. package/.dist/chunks/source-scan-cSawCvsg.js.map +1 -0
  27. package/.dist/chunks/{transform-jNUr65K9.js → transform-D7TTlPpK.js} +245 -371
  28. package/.dist/chunks/transform-D7TTlPpK.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 +42 -135
  42. package/.dist/dispatcher/scope.d.ts +36 -0
  43. package/.dist/dispatcher/types.d.ts +0 -151
  44. package/.dist/dispatcher.d.ts +2 -1
  45. package/.dist/dispatcher.js +2 -2
  46. package/.dist/errors.d.ts +44 -42
  47. package/.dist/generated/dispatcher.d.ts +6 -51
  48. package/.dist/generators.d.ts +2 -12
  49. package/.dist/internal/descriptors.d.ts +0 -16
  50. package/.dist/internal/generators.js +14 -9
  51. package/.dist/internal/generators.js.map +1 -1
  52. package/.dist/internal/live.d.ts +9 -0
  53. package/.dist/internal/remote-client.js +2 -2
  54. package/.dist/internal/remote-server.js +2 -2
  55. package/.dist/internal/schema.d.ts +0 -54
  56. package/.dist/live.d.ts +9 -26
  57. package/.dist/markup/event-attributes.d.ts +0 -32
  58. package/.dist/markup/promise.d.ts +1 -23
  59. package/.dist/markup/promise.js +2 -18
  60. package/.dist/markup/promise.js.map +1 -1
  61. package/.dist/markup/run.d.ts +1 -10
  62. package/.dist/markup/run.js +2 -11
  63. package/.dist/markup/run.js.map +1 -1
  64. package/.dist/markup/transform/apply.d.ts +5 -4
  65. package/.dist/markup/transform/classify.d.ts +2 -11
  66. package/.dist/markup/transform/constants.d.ts +2 -1
  67. package/.dist/markup/transform/effect-bindings.d.ts +2 -26
  68. package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
  69. package/.dist/markup/transform/emit.d.ts +2 -11
  70. package/.dist/markup/transform/expressions.d.ts +0 -35
  71. package/.dist/markup/transform/scan.d.ts +3 -22
  72. package/.dist/markup/transform/types.d.ts +15 -127
  73. package/.dist/markup/transform.js +1 -1
  74. package/.dist/markup/value.d.ts +1 -18
  75. package/.dist/markup/value.js +2 -19
  76. package/.dist/markup/value.js.map +1 -1
  77. package/.dist/mod.d.ts +3 -8
  78. package/.dist/mod.js +5 -5
  79. package/.dist/mod.js.map +1 -1
  80. package/.dist/remote/cause-codec.d.ts +3 -37
  81. package/.dist/remote/client/command.d.ts +3 -17
  82. package/.dist/remote/client/form-data.d.ts +0 -7
  83. package/.dist/remote/client/form-enhance.d.ts +0 -7
  84. package/.dist/remote/client/form-transport.d.ts +14 -20
  85. package/.dist/remote/client/form.d.ts +4 -24
  86. package/.dist/remote/client/index.d.ts +2 -1
  87. package/.dist/remote/client/prerender.d.ts +6 -0
  88. package/.dist/remote/client/query-result.d.ts +2 -14
  89. package/.dist/remote/client/query.d.ts +8 -48
  90. package/.dist/remote/client/responses.d.ts +3 -27
  91. package/.dist/remote/client/types.d.ts +16 -110
  92. package/.dist/remote/client/utils.d.ts +0 -8
  93. package/.dist/remote/client.d.ts +2 -2
  94. package/.dist/remote/client.js +2 -2
  95. package/.dist/remote/effect.d.ts +6 -0
  96. package/.dist/remote/failures.d.ts +4 -0
  97. package/.dist/remote/query-update.d.ts +2 -0
  98. package/.dist/remote/resource.d.ts +25 -0
  99. package/.dist/remote/server.d.ts +5 -50
  100. package/.dist/remote/server.js +2 -2
  101. package/.dist/remote/shared.d.ts +6 -145
  102. package/.dist/remote/shared.js +6 -127
  103. package/.dist/remote/shared.js.map +1 -1
  104. package/.dist/runtime/transform.js +26 -31
  105. package/.dist/runtime/transform.js.map +1 -1
  106. package/.dist/script-transform/ast.d.ts +0 -46
  107. package/.dist/script-transform/imports.d.ts +3 -39
  108. package/.dist/script-transform/index.d.ts +2 -0
  109. package/.dist/script-transform/lower.d.ts +0 -9
  110. package/.dist/script-transform/runes.d.ts +0 -10
  111. package/.dist/script-transform/runtime-block.d.ts +0 -17
  112. package/.dist/script-transform/source.d.ts +0 -24
  113. package/.dist/script-transform/types.d.ts +9 -126
  114. package/.dist/server/effects.d.ts +4 -53
  115. package/.dist/server/factories.d.ts +7 -7
  116. package/.dist/server/index.d.ts +1 -1
  117. package/.dist/server/invalid.d.ts +0 -7
  118. package/.dist/server/live-snapshot.d.ts +5 -0
  119. package/.dist/server/remote-handler-context.d.ts +5 -0
  120. package/.dist/server/runtime.d.ts +6 -24
  121. package/.dist/server/schema.d.ts +0 -14
  122. package/.dist/server/transport.d.ts +2 -0
  123. package/.dist/server/types.d.ts +49 -26
  124. package/.dist/server/wrappers.d.ts +3 -40
  125. package/.dist/server.d.ts +1 -1
  126. package/.dist/server.js +200 -215
  127. package/.dist/server.js.map +1 -1
  128. package/.dist/yieldable.d.ts +1 -35
  129. package/package.json +2 -2
  130. package/.dist/chunks/client-DcZUV4rR.js +0 -653
  131. package/.dist/chunks/client-DcZUV4rR.js.map +0 -1
  132. package/.dist/chunks/compiler-BBPNyXmQ.js +0 -460
  133. package/.dist/chunks/compiler-BBPNyXmQ.js.map +0 -1
  134. package/.dist/chunks/dispatcher-DOx8iC6r.js +0 -505
  135. package/.dist/chunks/dispatcher-DOx8iC6r.js.map +0 -1
  136. package/.dist/chunks/dispatcher-H-Ia0Os4.js +0 -47
  137. package/.dist/chunks/dispatcher-H-Ia0Os4.js.map +0 -1
  138. package/.dist/chunks/errors-IJjsUwrE.js.map +0 -1
  139. package/.dist/chunks/live-BXAKre_4.js +0 -104
  140. package/.dist/chunks/live-BXAKre_4.js.map +0 -1
  141. package/.dist/chunks/remote-client-CVI4t66c.js.map +0 -1
  142. package/.dist/chunks/runtime-GBQz32DZ.js.map +0 -1
  143. package/.dist/chunks/schema-D9pct6Y5.js +0 -89
  144. package/.dist/chunks/schema-D9pct6Y5.js.map +0 -1
  145. package/.dist/chunks/server-D1LcDnZE.js.map +0 -1
  146. package/.dist/chunks/source-scan-C4PsggID.js +0 -341
  147. package/.dist/chunks/source-scan-C4PsggID.js.map +0 -1
  148. package/.dist/chunks/transform-jNUr65K9.js.map +0 -1
  149. package/.dist/remote/client/effect.d.ts +0 -29
  150. package/.dist/remote/client/failures.d.ts +0 -42
package/.dist/errors.d.ts CHANGED
@@ -11,24 +11,10 @@
11
11
  * @since 2.4.0
12
12
  * @param message - Technical diagnostic message describing the failed runtime
13
13
  * invariant.
14
- * @returns A runtime-authored Error instance.
15
14
  */
16
15
  export declare class RuntimeError extends Error {
17
16
  constructor(message: string);
18
17
  }
19
- /**
20
- * Formats a runtime-owned error message with a stable screaming-case code.
21
- *
22
- * @example
23
- * ```ts
24
- * throw new Error(make_error_message("DISPATCHER_DISPOSED", "Dispatcher has been disposed"));
25
- * ```
26
- *
27
- * @since 2.0.0
28
- * @param code - Stable screaming-case identifier for the error category.
29
- * @param message - Human-readable error message without the leading code.
30
- * @returns The complete error message prefixed with the stable code.
31
- */
32
18
  export declare function make_error_message(code: string, message: string): string;
33
19
  /**
34
20
  * Base error class for all preprocessor errors emitted during script and
@@ -43,7 +29,6 @@ export declare function make_error_message(code: string, message: string): strin
43
29
  * @since 2.0.0
44
30
  * @param message - Technical diagnostic message for the transform failure.
45
31
  * @param filename - Source filename that triggered the transform failure.
46
- * @returns A preprocessor Error instance with source file context.
47
32
  */
48
33
  export declare class PreprocessError extends RuntimeError {
49
34
  /**
@@ -67,7 +52,6 @@ export declare class PreprocessError extends RuntimeError {
67
52
  * @param filename - Source filename containing the unsupported statement.
68
53
  * @param statement_text - Full source text for the statement containing
69
54
  * mixed async work.
70
- * @returns A preprocessor Error instance with statement context.
71
55
  */
72
56
  export declare class AwaitInEffectWorkError extends PreprocessError {
73
57
  /**
@@ -92,7 +76,6 @@ export declare class AwaitInEffectWorkError extends PreprocessError {
92
76
  * Effect work.
93
77
  * @param expression_text - Full source text for the rune expression.
94
78
  * @param filename - Source filename containing the unsupported rune.
95
- * @returns A preprocessor Error instance with rune source context.
96
79
  */
97
80
  export declare class AsyncEffectInSyncRuneError extends PreprocessError {
98
81
  /**
@@ -125,7 +108,6 @@ export declare class AsyncEffectInSyncRuneError extends PreprocessError {
125
108
  * @param filename - Source filename containing the invalid event handler.
126
109
  * @param expression_text - Event handler expression that contains the nested
127
110
  * unsupported async Effect work.
128
- * @returns A preprocessor Error instance with event expression context.
129
111
  */
130
112
  export declare class AsyncEffectInEventCallbackError extends PreprocessError {
131
113
  /**
@@ -151,7 +133,6 @@ export declare class AsyncEffectInEventCallbackError extends PreprocessError {
151
133
  * invalid event handler callback was found.
152
134
  * @param expression_text - Original event handler callback text that contained
153
135
  * `yield*` and should be rewritten as a direct event Effect expression.
154
- * @returns A preprocessor Error instance with event callback context.
155
136
  */
156
137
  export declare class YieldStarInEventCallbackError extends PreprocessError {
157
138
  /**
@@ -177,7 +158,6 @@ export declare class YieldStarInEventCallbackError extends PreprocessError {
177
158
  * @since 2.4.2
178
159
  * @param filename - Source filename containing the unsupported markup.
179
160
  * @param expression_text - The unsupported markup expression text.
180
- * @returns A preprocessor Error instance with markup source context.
181
161
  */
182
162
  export declare class UnsupportedMarkupEffectPositionError extends PreprocessError {
183
163
  /**
@@ -198,7 +178,6 @@ export declare class UnsupportedMarkupEffectPositionError extends PreprocessErro
198
178
  * ```
199
179
  *
200
180
  * @since 2.4.0
201
- * @returns An Error describing missing request context.
202
181
  */
203
182
  export declare class RequestEventUnavailableError extends RuntimeError {
204
183
  constructor();
@@ -212,7 +191,6 @@ export declare class RequestEventUnavailableError extends RuntimeError {
212
191
  * ```
213
192
  *
214
193
  * @since 2.4.0
215
- * @returns An Error describing the invalid Query overload usage.
216
194
  */
217
195
  export declare class UncheckedQueryHandlerMissingError extends RuntimeError {
218
196
  constructor();
@@ -226,7 +204,6 @@ export declare class UncheckedQueryHandlerMissingError extends RuntimeError {
226
204
  * ```
227
205
  *
228
206
  * @since 2.4.0
229
- * @returns An Error describing the invalid batch Query overload usage.
230
207
  */
231
208
  export declare class BatchQueryHandlerMissingError extends RuntimeError {
232
209
  constructor();
@@ -240,7 +217,6 @@ export declare class BatchQueryHandlerMissingError extends RuntimeError {
240
217
  * ```
241
218
  *
242
219
  * @since 2.4.0
243
- * @returns An Error describing the invalid live Query overload usage.
244
220
  */
245
221
  export declare class UncheckedLiveQueryHandlerMissingError extends RuntimeError {
246
222
  constructor();
@@ -254,7 +230,6 @@ export declare class UncheckedLiveQueryHandlerMissingError extends RuntimeError
254
230
  * ```
255
231
  *
256
232
  * @since 2.4.0
257
- * @returns An Error describing the invalid Command overload usage.
258
233
  */
259
234
  export declare class UncheckedCommandHandlerMissingError extends RuntimeError {
260
235
  constructor();
@@ -268,7 +243,6 @@ export declare class UncheckedCommandHandlerMissingError extends RuntimeError {
268
243
  * ```
269
244
  *
270
245
  * @since 2.4.0
271
- * @returns An Error describing the invalid Form overload usage.
272
246
  */
273
247
  export declare class UncheckedFormHandlerMissingError extends RuntimeError {
274
248
  constructor();
@@ -282,7 +256,6 @@ export declare class UncheckedFormHandlerMissingError extends RuntimeError {
282
256
  * ```
283
257
  *
284
258
  * @since 2.4.0
285
- * @returns An Error describing the invalid Prerender overload usage.
286
259
  */
287
260
  export declare class UncheckedPrerenderHandlerMissingError extends RuntimeError {
288
261
  constructor();
@@ -296,7 +269,6 @@ export declare class UncheckedPrerenderHandlerMissingError extends RuntimeError
296
269
  * ```
297
270
  *
298
271
  * @since 2.4.0
299
- * @returns An Error describing the expected live query return protocol.
300
272
  */
301
273
  export declare class InvalidLiveQueryReturnError extends RuntimeError {
302
274
  constructor();
@@ -311,11 +283,32 @@ export declare class InvalidLiveQueryReturnError extends RuntimeError {
311
283
  * ```
312
284
  *
313
285
  * @since 3.4.8
314
- * @returns An Error describing an empty Stream in a value position.
315
286
  */
316
287
  export declare class EmptyStreamYieldError extends RuntimeError {
317
288
  constructor();
318
289
  }
290
+ /**
291
+ * Thrown when generated component code receives a value that cannot be yielded
292
+ * through the SER runtime.
293
+ *
294
+ * @example
295
+ * ```ts
296
+ * throw new InvalidYieldableError(null);
297
+ * ```
298
+ *
299
+ * @since 4.0.0
300
+ * @param value - Runtime value that was expected to be an Effect, generator, or
301
+ * Stream.
302
+ */
303
+ export declare class InvalidYieldableError extends RuntimeError {
304
+ /**
305
+ * Runtime value rejected by the generated yield boundary.
306
+ *
307
+ * @since 4.0.0
308
+ */
309
+ readonly value: unknown;
310
+ constructor(value: unknown);
311
+ }
319
312
  /**
320
313
  * Thrown when a dispatcher operation is requested after disposal.
321
314
  *
@@ -325,11 +318,24 @@ export declare class EmptyStreamYieldError extends RuntimeError {
325
318
  * ```
326
319
  *
327
320
  * @since 2.4.0
328
- * @returns An Error describing an invalid dispatcher lifecycle transition.
329
321
  */
330
322
  export declare class DispatcherDisposedError extends RuntimeError {
331
323
  constructor();
332
324
  }
325
+ /**
326
+ * Thrown when Effect work is bound to a component scope that has already been
327
+ * disposed.
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * throw new ScopeDisposedError();
332
+ * ```
333
+ *
334
+ * @since 3.1.0
335
+ */
336
+ export declare class ScopeDisposedError extends RuntimeError {
337
+ constructor();
338
+ }
333
339
  /**
334
340
  * Thrown when an application attempts to configure a runtime after one has
335
341
  * already been initialized.
@@ -341,7 +347,6 @@ export declare class DispatcherDisposedError extends RuntimeError {
341
347
  *
342
348
  * @since 3.4.0
343
349
  * @param runtime_name - Public runtime API that was initialized more than once.
344
- * @returns An Error describing the invalid runtime lifecycle transition.
345
350
  */
346
351
  export declare class RuntimeAlreadyInitializedError extends RuntimeError {
347
352
  constructor(runtime_name: string);
@@ -355,11 +360,18 @@ export declare class RuntimeAlreadyInitializedError extends RuntimeError {
355
360
  * ```
356
361
  *
357
362
  * @since 2.4.0
358
- * @returns An Error describing an invalid query adapter input.
359
363
  */
360
364
  export declare class InvalidQueryFactoryError extends RuntimeError {
361
365
  constructor();
362
366
  }
367
+ /**
368
+ * Thrown when a generated or native remote prerender export is not callable.
369
+ *
370
+ * @since 4.0.0
371
+ */
372
+ export declare class InvalidPrerenderFactoryError extends RuntimeError {
373
+ constructor();
374
+ }
363
375
  /**
364
376
  * Thrown when a generated or native remote live query export is not callable.
365
377
  *
@@ -369,7 +381,6 @@ export declare class InvalidQueryFactoryError extends RuntimeError {
369
381
  * ```
370
382
  *
371
383
  * @since 2.4.0
372
- * @returns An Error describing an invalid live query adapter input.
373
384
  */
374
385
  export declare class InvalidLiveQueryFactoryError extends RuntimeError {
375
386
  constructor();
@@ -383,7 +394,6 @@ export declare class InvalidLiveQueryFactoryError extends RuntimeError {
383
394
  * ```
384
395
  *
385
396
  * @since 2.4.0
386
- * @returns An Error describing an invalid command adapter input.
387
397
  */
388
398
  export declare class InvalidCommandFactoryError extends RuntimeError {
389
399
  constructor();
@@ -397,7 +407,6 @@ export declare class InvalidCommandFactoryError extends RuntimeError {
397
407
  * ```
398
408
  *
399
409
  * @since 2.4.0
400
- * @returns An Error describing missing form transport metadata.
401
410
  */
402
411
  export declare class RemoteFormEndpointMissingError extends RuntimeError {
403
412
  constructor();
@@ -413,7 +422,6 @@ export declare class RemoteFormEndpointMissingError extends RuntimeError {
413
422
  *
414
423
  * @since 2.4.0
415
424
  * @param envelope - Raw response envelope returned by the remote form endpoint.
416
- * @returns An Error describing malformed form response data.
417
425
  */
418
426
  export declare class InvalidRemoteFormResponseError extends RuntimeError {
419
427
  /**
@@ -435,7 +443,6 @@ export declare class InvalidRemoteFormResponseError extends RuntimeError {
435
443
  *
436
444
  * @since 2.4.0
437
445
  * @param envelope - Raw response envelope returned by the remote form endpoint.
438
- * @returns An Error describing unsupported form response data.
439
446
  */
440
447
  export declare class UnsupportedRemoteFormResponseError extends RuntimeError {
441
448
  /**
@@ -456,7 +463,6 @@ export declare class UnsupportedRemoteFormResponseError extends RuntimeError {
456
463
  *
457
464
  * @since 2.4.0
458
465
  * @param raw - Raw serialized remote failure payload that failed decoding.
459
- * @returns An Error describing a malformed remote failure payload.
460
466
  */
461
467
  export declare class RemoteErrorDecodeError extends RuntimeError {
462
468
  /**
@@ -477,7 +483,6 @@ export declare class RemoteErrorDecodeError extends RuntimeError {
477
483
  *
478
484
  * @since 2.4.0
479
485
  * @param export_name - Name of the server-only root export that was invoked.
480
- * @returns An Error describing a missing server rewrite.
481
486
  */
482
487
  export declare class ServerOnlyImportError extends RuntimeError {
483
488
  /**
@@ -498,7 +503,6 @@ export declare class ServerOnlyImportError extends RuntimeError {
498
503
  *
499
504
  * @since 2.4.0
500
505
  * @param export_name - Name of the `$app/server` export that was invoked.
501
- * @returns An Error describing an unavailable SvelteKit virtual module export.
502
506
  */
503
507
  export declare class SvelteKitServerExportUnavailableError extends RuntimeError {
504
508
  /**
@@ -520,7 +524,6 @@ export declare class SvelteKitServerExportUnavailableError extends RuntimeError
520
524
  *
521
525
  * @since 2.4.0
522
526
  * @param helper_name - SER helper name that triggered the context failure.
523
- * @returns An Error describing the required `.remote.ts` placement.
524
527
  */
525
528
  export declare class RemoteHelperContextError extends RuntimeError {
526
529
  /**
@@ -541,7 +544,6 @@ export declare class RemoteHelperContextError extends RuntimeError {
541
544
  *
542
545
  * @since 2.4.0
543
546
  * @param value - Non-Error value thrown while creating a remote helper.
544
- * @returns An Error preserving the remote helper failure value.
545
547
  */
546
548
  export declare class RemoteHelperError extends RuntimeError {
547
549
  /**
@@ -1,60 +1,15 @@
1
- import type { Dispatcher as RuntimeDispatcher, DispatcherEvent, MarkupPromiseEvent, MarkupRunEvent, MarkupValueEvent } from "../dispatcher.js";
1
+ import type { ComponentScope, Dispatcher as RuntimeDispatcher, DispatcherEvent, MarkupPromiseEvent, MarkupRunEvent, MarkupValueEvent } from "../dispatcher.js";
2
2
  export { Code } from "../dispatcher.js";
3
3
  export type { DispatcherEvent, MarkupPromiseEvent, MarkupPromiseOptions, MarkupRunEvent, MarkupValueEvent, } from "../dispatcher.js";
4
- /**
5
- * Facade used by transform-generated component code to dispatch runtime
6
- * events through the current client or server dispatcher.
7
- *
8
- * @example
9
- * ```ts
10
- * const value = Dispatcher.emit({
11
- * type: Code.Markup.Value,
12
- * id: "Component.svelte:1:2",
13
- * deps: [],
14
- * fallback: undefined,
15
- * fn: function* () {
16
- * return yield* Effect.succeed(1);
17
- * },
18
- * });
19
- * ```
20
- *
21
- * @since 3.3.0
22
- * @internal
23
- */
24
4
  export declare class Dispatcher {
25
- /**
26
- * Emits a transform-generated dispatcher event.
27
- *
28
- * @example
29
- * ```ts
30
- * const promise = Dispatcher.emit({
31
- * type: Code.Markup.Promise,
32
- * id: "Component.svelte:1:2",
33
- * deps: [],
34
- * fn: function* () {
35
- * return yield* Effect.succeed(1);
36
- * },
37
- * });
38
- * ```
39
- *
40
- * @since 3.3.0
41
- * @param event - Generated event describing the dispatcher operation to run.
42
- * @returns The result produced by the active dispatcher.
43
- */
44
5
  static emit<A, F>(event: MarkupValueEvent<A, F>): A | F;
45
6
  static emit<A>(event: MarkupPromiseEvent<A>): Promise<A>;
46
7
  static emit<A>(event: MarkupRunEvent<A>): Promise<A>;
47
8
  static emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;
9
+ /**
10
+ * Runs `fn` with `scope` as the active component scope so emitted work is
11
+ * bound to the calling component's lifetime.
12
+ */
13
+ static with_scope<T>(scope: ComponentScope, fn: () => T): T;
48
14
  }
49
- /**
50
- * Returns the dispatcher appropriate for generated component code.
51
- *
52
- * @example
53
- * ```ts
54
- * const dispatcher = get_dispatcher();
55
- * ```
56
- *
57
- * @since 3.0.1
58
- * @returns The server dispatcher during SSR, otherwise the client dispatcher.
59
- */
60
15
  export declare function get_dispatcher(): RuntimeDispatcher;
@@ -1,16 +1,6 @@
1
- /**
2
- * Barrel module for transform-generated imports. Exports everything the
3
- * transform needs to emit into generated code. Users never import this
4
- * module directly.
5
- *
6
- * Note: `Effect` is NOT re-exported. The script transform emits
7
- * `import { Effect } from "effect"` directly. `onMount` is NOT re-exported
8
- * either; it comes from `"svelte"` directly.
9
- *
10
- * @since 2.0.0
11
- * @internal
12
- */
1
+ /** Generated-code ABI for imports emitted by the Svelte transforms. */
13
2
  export { Code, Dispatcher, get_dispatcher } from "./generated/dispatcher.js";
3
+ export { ComponentScopeRef } from "./dispatcher.js";
14
4
  export { ToEffect } from "./yieldable.js";
15
5
  export type { DispatcherEvent, MarkupPromiseEvent, MarkupPromiseOptions, MarkupRunEvent, MarkupValueEvent, } from "./generated/dispatcher.js";
16
6
  export type { YieldSuccess } from "./yieldable.js";
@@ -1,17 +1 @@
1
- /**
2
- * Copies own property descriptors from a native helper to a wrapper while
3
- * skipping function metadata and any caller-specific keys.
4
- *
5
- * @example
6
- * ```ts
7
- * copy_property_descriptors(native_remote, wrapped_remote);
8
- * ```
9
- *
10
- * @since 2.0.0
11
- * @param source - Source object or function whose descriptors should be
12
- * mirrored.
13
- * @param target - Wrapper object or function that receives copied descriptors.
14
- * @param exclude - Additional property keys that should not be copied.
15
- * @returns Nothing.
16
- */
17
1
  export declare function copy_property_descriptors(source: unknown, target: object, exclude?: ReadonlySet<PropertyKey>): void;
@@ -1,23 +1,28 @@
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";
1
+ import { o as EmptyStreamYieldError, p as InvalidYieldableError } from "../chunks/errors-qhcbUH6o.js";
2
+ import { a as Code, t as ComponentScopeRef } from "../chunks/dispatcher-CTWINW5I.js";
3
+ import { t as RemoteLiveYield } from "../chunks/live-CHK0RrZu.js";
4
+ import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-pZPzarul.js";
4
5
  import { value } from "../markup/value.js";
5
6
  import { promise } from "../markup/promise.js";
6
7
  import { run } from "../markup/run.js";
7
8
  import { Effect, Option, Stream } from "effect";
8
9
  //#region src/yieldable.ts
9
10
  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
- }));
11
+ if (Stream.isStream(value)) {
12
+ const Head = Stream.runHead(value);
13
+ return Effect.provideService(Head, RemoteLiveYield, true).pipe(Effect.flatMap((option) => {
14
+ if (Option.isSome(option)) return Effect.succeed(option.value);
15
+ return Effect.fail(new EmptyStreamYieldError());
16
+ }));
17
+ }
14
18
  if (is_generator_result(value)) return Effect.gen(() => value);
15
- return value;
19
+ if (Effect.isEffect(value)) return value;
20
+ return Effect.fail(new InvalidYieldableError(value));
16
21
  }
17
22
  function is_generator_result(value) {
18
23
  return typeof value === "object" && value !== null && typeof value.next === "function";
19
24
  }
20
25
  //#endregion
21
- export { Code, Dispatcher, ToEffect, get_dispatcher, promise, run, value };
26
+ export { Code, ComponentScopeRef, Dispatcher, ToEffect, get_dispatcher, promise, run, value };
22
27
 
23
28
  //# sourceMappingURL=generators.js.map
@@ -1 +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
+ {"version":3,"file":"generators.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/yieldable.ts"],"sourcesContent":["import { EmptyStreamYieldError, InvalidYieldableError } from \"$/errors.ts\";\nimport { RemoteLiveYield } from \"$/internal/live.ts\";\nimport { Effect, Option, Stream } from \"effect\";\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\nexport type YieldSuccess<Value> =\n\tValue extends Stream.Stream<infer A, unknown, unknown>\n\t\t? A\n\t\t: Value extends Effect.Effect<infer A, unknown, unknown>\n\t\t\t? A\n\t\t\t: Value extends Effect.gen.Return<infer A, unknown, unknown>\n\t\t\t\t? A\n\t\t\t\t: never;\n\n/** Normalizes generated Effect and generator values at the transform ABI boundary. */\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\tconst Head = Stream.runHead(value);\n\t\tconst ResolveHead = Effect.provideService(Head, RemoteLiveYield, true);\n\n\t\treturn ResolveHead.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\tif (Effect.isEffect(value)) {\n\t\treturn value;\n\t}\n\n\treturn Effect.fail(new InvalidYieldableError(value));\n}\n\nfunction is_generator_result<A, E, R>(value: unknown): 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":";;;;;;;;;AAyBA,SAAgB,SACf,OACiD;CACjD,IAAI,OAAO,SAAS,KAAK,GAAG;EAC3B,MAAM,OAAO,OAAO,QAAQ,KAAK;EAGjC,OAFoB,OAAO,eAAe,MAAM,iBAAiB,IAEhD,CAAC,CAAC,KAClB,OAAO,SAAS,WAAW;GAC1B,IAAI,OAAO,OAAO,MAAM,GACvB,OAAO,OAAO,QAAQ,OAAO,KAAK;GAGnC,OAAO,OAAO,KAAK,IAAI,sBAAsB,CAAC;EAC/C,CAAC,CACF;CACD;CAEA,IAAI,oBAA6B,KAAK,GACrC,OAAO,OAAO,UAAU,KAAK;CAG9B,IAAI,OAAO,SAAS,KAAK,GACxB,OAAO;CAGR,OAAO,OAAO,KAAK,IAAI,sBAAsB,KAAK,CAAC;AACpD;AAEA,SAAS,oBAA6B,OAAqD;CAC1F,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAEhD"}
@@ -0,0 +1,9 @@
1
+ import { Context } from "effect";
2
+ /** Brands remote live streams without relying on class identity. */
3
+ export declare const remote_live_stream: unique symbol;
4
+ /** Selects the cached-first live source while generated yields resolve. */
5
+ export declare const RemoteLiveYield: Context.Reference<boolean>;
6
+ /** Internal carrier that identifies a remote live Stream. */
7
+ export type RemoteLiveStreamCarrier = {
8
+ readonly [remote_live_stream]?: true;
9
+ };
@@ -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-DcZUV4rR.js";
2
- export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
1
+ import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-DbwVAMWm.js";
2
+ export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
@@ -1,2 +1,2 @@
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
- export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error };
1
+ import { a as encode_remote_failure, i as throw_remote_cause, n as run_remote_effect, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-yQrNoiCR.js";
2
+ export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause };
@@ -1,18 +1,4 @@
1
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
2
  export type StandardSchema = {
17
3
  readonly "~standard": {
18
4
  readonly types?: {
@@ -22,46 +8,6 @@ export type StandardSchema = {
22
8
  readonly validate: (input: unknown) => unknown;
23
9
  };
24
10
  };
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
11
  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
12
  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
13
  export declare function normalize_validator(value: unknown): unknown;
package/.dist/live.d.ts CHANGED
@@ -1,12 +1,7 @@
1
- import { Effect, Stream } from "effect";
1
+ import { remote_live_stream } from "./internal/live.js";
2
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;
3
+ import { Effect, Stream } from "effect";
4
+ declare const live_operator: unique symbol;
10
5
  type RemoteLivePipe<A, E> = {
11
6
  (): RemoteLiveStream<A, E>;
12
7
  (ab: LiveFactory["status"]): Stream.Stream<LiveStatus, never, never>;
@@ -32,7 +27,7 @@ type RemoteLivePipe<A, E> = {
32
27
  * @since 3.4.8
33
28
  */
34
29
  export type RemoteLiveStream<A, E = never> = Omit<Stream.Stream<A, RemoteFailure<E>, never>, "pipe"> & {
35
- readonly [REMOTE_LIVE_STREAM]: true;
30
+ readonly [remote_live_stream]: true;
36
31
  readonly pipe: RemoteLivePipe<A, E>;
37
32
  };
38
33
  /**
@@ -69,7 +64,7 @@ export type LiveStatus = {
69
64
  */
70
65
  export interface LiveFactory {
71
66
  readonly status: {
72
- readonly [LIVE_OPERATOR]: true;
67
+ readonly [live_operator]: true;
73
68
  /**
74
69
  * Creates a stream of transport status updates for a remote live stream.
75
70
  *
@@ -84,7 +79,7 @@ export interface LiveFactory {
84
79
  <A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never>;
85
80
  };
86
81
  readonly reconnect: {
87
- readonly [LIVE_OPERATOR]: true;
82
+ readonly [live_operator]: true;
88
83
  /**
89
84
  * Reconnects the transport behind a remote live stream.
90
85
  *
@@ -99,25 +94,13 @@ export interface LiveFactory {
99
94
  <A, E>(stream: RemoteLiveStream<A, E>): Effect.Effect<void, RemoteFailure<E>, never>;
100
95
  };
101
96
  }
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>;
97
+ export declare function make_remote_live_stream<A, ErrorType = never>(resource: unknown, on_error: (error: unknown) => RemoteFailure<ErrorType>, encode_snapshot?: (value: unknown) => string): RemoteLiveStream<A, ErrorType>;
98
+ export declare function make_failed_remote_live_stream<A, ErrorType = never>(error: unknown, on_error: (error: unknown) => RemoteFailure<ErrorType>): RemoteLiveStream<A, ErrorType>;
117
99
  /**
118
100
  * Remote live transport helpers.
119
101
  *
120
102
  * @since 3.4.8
121
103
  */
122
104
  export declare const Live: LiveFactory;
105
+ export declare function get_native_remote_live_resource(value: unknown): unknown | undefined;
123
106
  export {};
@@ -1,38 +1,6 @@
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
1
  export declare function is_svelte_event_attribute(attribute: {
20
2
  type: string;
21
3
  name?: string;
22
4
  value?: unknown;
23
5
  }): 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
6
  export declare function normalize_event_attribute_name(name: string): string;