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
@@ -12,7 +12,6 @@
12
12
  * @since 2.4.0
13
13
  * @param message - Technical diagnostic message describing the failed runtime
14
14
  * invariant.
15
- * @returns A runtime-authored Error instance.
16
15
  */
17
16
  var RuntimeError = class extends Error {
18
17
  constructor(message) {
@@ -20,19 +19,6 @@ var RuntimeError = class extends Error {
20
19
  this.name = "RuntimeError";
21
20
  }
22
21
  };
23
- /**
24
- * Formats a runtime-owned error message with a stable screaming-case code.
25
- *
26
- * @example
27
- * ```ts
28
- * throw new Error(make_error_message("DISPATCHER_DISPOSED", "Dispatcher has been disposed"));
29
- * ```
30
- *
31
- * @since 2.0.0
32
- * @param code - Stable screaming-case identifier for the error category.
33
- * @param message - Human-readable error message without the leading code.
34
- * @returns The complete error message prefixed with the stable code.
35
- */
36
22
  function make_error_message(code, message) {
37
23
  return `[${code}]: ${message}`;
38
24
  }
@@ -49,7 +35,6 @@ function make_error_message(code, message) {
49
35
  * @since 2.0.0
50
36
  * @param message - Technical diagnostic message for the transform failure.
51
37
  * @param filename - Source filename that triggered the transform failure.
52
- * @returns A preprocessor Error instance with source file context.
53
38
  */
54
39
  var PreprocessError = class extends RuntimeError {
55
40
  /**
@@ -77,7 +62,6 @@ var PreprocessError = class extends RuntimeError {
77
62
  * @param filename - Source filename containing the unsupported statement.
78
63
  * @param statement_text - Full source text for the statement containing
79
64
  * mixed async work.
80
- * @returns A preprocessor Error instance with statement context.
81
65
  */
82
66
  var AwaitInEffectWorkError = class extends PreprocessError {
83
67
  /**
@@ -112,7 +96,6 @@ var AwaitInEffectWorkError = class extends PreprocessError {
112
96
  * Effect work.
113
97
  * @param expression_text - Full source text for the rune expression.
114
98
  * @param filename - Source filename containing the unsupported rune.
115
- * @returns A preprocessor Error instance with rune source context.
116
99
  */
117
100
  var AsyncEffectInSyncRuneError = class extends PreprocessError {
118
101
  /**
@@ -156,7 +139,6 @@ var AsyncEffectInSyncRuneError = class extends PreprocessError {
156
139
  * @param filename - Source filename containing the invalid event handler.
157
140
  * @param expression_text - Event handler expression that contains the nested
158
141
  * unsupported async Effect work.
159
- * @returns A preprocessor Error instance with event expression context.
160
142
  */
161
143
  var AsyncEffectInEventCallbackError = class extends PreprocessError {
162
144
  /**
@@ -198,7 +180,6 @@ var AsyncEffectInEventCallbackError = class extends PreprocessError {
198
180
  * invalid event handler callback was found.
199
181
  * @param expression_text - Original event handler callback text that contained
200
182
  * `yield*` and should be rewritten as a direct event Effect expression.
201
- * @returns A preprocessor Error instance with event callback context.
202
183
  */
203
184
  var YieldStarInEventCallbackError = class extends PreprocessError {
204
185
  /**
@@ -240,7 +221,6 @@ var YieldStarInEventCallbackError = class extends PreprocessError {
240
221
  * @since 2.4.2
241
222
  * @param filename - Source filename containing the unsupported markup.
242
223
  * @param expression_text - The unsupported markup expression text.
243
- * @returns A preprocessor Error instance with markup source context.
244
224
  */
245
225
  var UnsupportedMarkupEffectPositionError = class extends PreprocessError {
246
226
  /**
@@ -271,7 +251,6 @@ var UnsupportedMarkupEffectPositionError = class extends PreprocessError {
271
251
  * ```
272
252
  *
273
253
  * @since 2.4.0
274
- * @returns An Error describing missing request context.
275
254
  */
276
255
  var RequestEventUnavailableError = class extends RuntimeError {
277
256
  constructor() {
@@ -288,7 +267,6 @@ var RequestEventUnavailableError = class extends RuntimeError {
288
267
  * ```
289
268
  *
290
269
  * @since 2.4.0
291
- * @returns An Error describing the invalid Query overload usage.
292
270
  */
293
271
  var UncheckedQueryHandlerMissingError = class extends RuntimeError {
294
272
  constructor() {
@@ -305,7 +283,6 @@ var UncheckedQueryHandlerMissingError = class extends RuntimeError {
305
283
  * ```
306
284
  *
307
285
  * @since 2.4.0
308
- * @returns An Error describing the invalid batch Query overload usage.
309
286
  */
310
287
  var BatchQueryHandlerMissingError = class extends RuntimeError {
311
288
  constructor() {
@@ -322,7 +299,6 @@ var BatchQueryHandlerMissingError = class extends RuntimeError {
322
299
  * ```
323
300
  *
324
301
  * @since 2.4.0
325
- * @returns An Error describing the invalid live Query overload usage.
326
302
  */
327
303
  var UncheckedLiveQueryHandlerMissingError = class extends RuntimeError {
328
304
  constructor() {
@@ -339,7 +315,6 @@ var UncheckedLiveQueryHandlerMissingError = class extends RuntimeError {
339
315
  * ```
340
316
  *
341
317
  * @since 2.4.0
342
- * @returns An Error describing the invalid Command overload usage.
343
318
  */
344
319
  var UncheckedCommandHandlerMissingError = class extends RuntimeError {
345
320
  constructor() {
@@ -356,7 +331,6 @@ var UncheckedCommandHandlerMissingError = class extends RuntimeError {
356
331
  * ```
357
332
  *
358
333
  * @since 2.4.0
359
- * @returns An Error describing the invalid Form overload usage.
360
334
  */
361
335
  var UncheckedFormHandlerMissingError = class extends RuntimeError {
362
336
  constructor() {
@@ -373,7 +347,6 @@ var UncheckedFormHandlerMissingError = class extends RuntimeError {
373
347
  * ```
374
348
  *
375
349
  * @since 2.4.0
376
- * @returns An Error describing the invalid Prerender overload usage.
377
350
  */
378
351
  var UncheckedPrerenderHandlerMissingError = class extends RuntimeError {
379
352
  constructor() {
@@ -390,7 +363,6 @@ var UncheckedPrerenderHandlerMissingError = class extends RuntimeError {
390
363
  * ```
391
364
  *
392
365
  * @since 2.4.0
393
- * @returns An Error describing the expected live query return protocol.
394
366
  */
395
367
  var InvalidLiveQueryReturnError = class extends RuntimeError {
396
368
  constructor() {
@@ -408,7 +380,6 @@ var InvalidLiveQueryReturnError = class extends RuntimeError {
408
380
  * ```
409
381
  *
410
382
  * @since 3.4.8
411
- * @returns An Error describing an empty Stream in a value position.
412
383
  */
413
384
  var EmptyStreamYieldError = class extends RuntimeError {
414
385
  constructor() {
@@ -417,6 +388,32 @@ var EmptyStreamYieldError = class extends RuntimeError {
417
388
  }
418
389
  };
419
390
  /**
391
+ * Thrown when generated component code receives a value that cannot be yielded
392
+ * through the SER runtime.
393
+ *
394
+ * @example
395
+ * ```ts
396
+ * throw new InvalidYieldableError(null);
397
+ * ```
398
+ *
399
+ * @since 4.0.0
400
+ * @param value - Runtime value that was expected to be an Effect, generator, or
401
+ * Stream.
402
+ */
403
+ var InvalidYieldableError = class extends RuntimeError {
404
+ /**
405
+ * Runtime value rejected by the generated yield boundary.
406
+ *
407
+ * @since 4.0.0
408
+ */
409
+ value;
410
+ constructor(value) {
411
+ super("Cannot resolve yield* expression because it returned a non-yieldable value. Expected an Effect, generator, or Stream.");
412
+ this.name = "InvalidYieldableError";
413
+ this.value = value;
414
+ }
415
+ };
416
+ /**
420
417
  * Thrown when a dispatcher operation is requested after disposal.
421
418
  *
422
419
  * @example
@@ -425,7 +422,6 @@ var EmptyStreamYieldError = class extends RuntimeError {
425
422
  * ```
426
423
  *
427
424
  * @since 2.4.0
428
- * @returns An Error describing an invalid dispatcher lifecycle transition.
429
425
  */
430
426
  var DispatcherDisposedError = class extends RuntimeError {
431
427
  constructor() {
@@ -434,6 +430,23 @@ var DispatcherDisposedError = class extends RuntimeError {
434
430
  }
435
431
  };
436
432
  /**
433
+ * Thrown when Effect work is bound to a component scope that has already been
434
+ * disposed.
435
+ *
436
+ * @example
437
+ * ```ts
438
+ * throw new ScopeDisposedError();
439
+ * ```
440
+ *
441
+ * @since 3.1.0
442
+ */
443
+ var ScopeDisposedError = class extends RuntimeError {
444
+ constructor() {
445
+ super("Effect scope has been disposed; no new Effect work can be bound to a destroyed component's scope.");
446
+ this.name = "ScopeDisposedError";
447
+ }
448
+ };
449
+ /**
437
450
  * Thrown when an application attempts to configure a runtime after one has
438
451
  * already been initialized.
439
452
  *
@@ -444,7 +457,6 @@ var DispatcherDisposedError = class extends RuntimeError {
444
457
  *
445
458
  * @since 3.4.0
446
459
  * @param runtime_name - Public runtime API that was initialized more than once.
447
- * @returns An Error describing the invalid runtime lifecycle transition.
448
460
  */
449
461
  var RuntimeAlreadyInitializedError = class extends RuntimeError {
450
462
  constructor(runtime_name) {
@@ -461,7 +473,6 @@ var RuntimeAlreadyInitializedError = class extends RuntimeError {
461
473
  * ```
462
474
  *
463
475
  * @since 2.4.0
464
- * @returns An Error describing an invalid query adapter input.
465
476
  */
466
477
  var InvalidQueryFactoryError = class extends RuntimeError {
467
478
  constructor() {
@@ -470,6 +481,17 @@ var InvalidQueryFactoryError = class extends RuntimeError {
470
481
  }
471
482
  };
472
483
  /**
484
+ * Thrown when a generated or native remote prerender export is not callable.
485
+ *
486
+ * @since 4.0.0
487
+ */
488
+ var InvalidPrerenderFactoryError = class extends RuntimeError {
489
+ constructor() {
490
+ super("Invalid prerender factory: expected a function from SvelteKit remote prerender generation.");
491
+ this.name = "InvalidPrerenderFactoryError";
492
+ }
493
+ };
494
+ /**
473
495
  * Thrown when a generated or native remote live query export is not callable.
474
496
  *
475
497
  * @example
@@ -478,7 +500,6 @@ var InvalidQueryFactoryError = class extends RuntimeError {
478
500
  * ```
479
501
  *
480
502
  * @since 2.4.0
481
- * @returns An Error describing an invalid live query adapter input.
482
503
  */
483
504
  var InvalidLiveQueryFactoryError = class extends RuntimeError {
484
505
  constructor() {
@@ -495,7 +516,6 @@ var InvalidLiveQueryFactoryError = class extends RuntimeError {
495
516
  * ```
496
517
  *
497
518
  * @since 2.4.0
498
- * @returns An Error describing an invalid command adapter input.
499
519
  */
500
520
  var InvalidCommandFactoryError = class extends RuntimeError {
501
521
  constructor() {
@@ -512,7 +532,6 @@ var InvalidCommandFactoryError = class extends RuntimeError {
512
532
  * ```
513
533
  *
514
534
  * @since 2.4.0
515
- * @returns An Error describing missing form transport metadata.
516
535
  */
517
536
  var RemoteFormEndpointMissingError = class extends RuntimeError {
518
537
  constructor() {
@@ -531,7 +550,6 @@ var RemoteFormEndpointMissingError = class extends RuntimeError {
531
550
  *
532
551
  * @since 2.4.0
533
552
  * @param envelope - Raw response envelope returned by the remote form endpoint.
534
- * @returns An Error describing malformed form response data.
535
553
  */
536
554
  var InvalidRemoteFormResponseError = class extends RuntimeError {
537
555
  /**
@@ -557,7 +575,6 @@ var InvalidRemoteFormResponseError = class extends RuntimeError {
557
575
  *
558
576
  * @since 2.4.0
559
577
  * @param envelope - Raw response envelope returned by the remote form endpoint.
560
- * @returns An Error describing unsupported form response data.
561
578
  */
562
579
  var UnsupportedRemoteFormResponseError = class extends RuntimeError {
563
580
  /**
@@ -582,7 +599,6 @@ var UnsupportedRemoteFormResponseError = class extends RuntimeError {
582
599
  *
583
600
  * @since 2.4.0
584
601
  * @param raw - Raw serialized remote failure payload that failed decoding.
585
- * @returns An Error describing a malformed remote failure payload.
586
602
  */
587
603
  var RemoteErrorDecodeError = class extends RuntimeError {
588
604
  /**
@@ -607,7 +623,6 @@ var RemoteErrorDecodeError = class extends RuntimeError {
607
623
  *
608
624
  * @since 2.4.0
609
625
  * @param export_name - Name of the server-only root export that was invoked.
610
- * @returns An Error describing a missing server rewrite.
611
626
  */
612
627
  var ServerOnlyImportError = class extends RuntimeError {
613
628
  /**
@@ -632,7 +647,6 @@ var ServerOnlyImportError = class extends RuntimeError {
632
647
  *
633
648
  * @since 2.4.0
634
649
  * @param export_name - Name of the `$app/server` export that was invoked.
635
- * @returns An Error describing an unavailable SvelteKit virtual module export.
636
650
  */
637
651
  var SvelteKitServerExportUnavailableError = class extends RuntimeError {
638
652
  /**
@@ -658,7 +672,6 @@ var SvelteKitServerExportUnavailableError = class extends RuntimeError {
658
672
  *
659
673
  * @since 2.4.0
660
674
  * @param helper_name - SER helper name that triggered the context failure.
661
- * @returns An Error describing the required `.remote.ts` placement.
662
675
  */
663
676
  var RemoteHelperContextError = class extends RuntimeError {
664
677
  /**
@@ -683,7 +696,6 @@ var RemoteHelperContextError = class extends RuntimeError {
683
696
  *
684
697
  * @since 2.4.0
685
698
  * @param value - Non-Error value thrown while creating a remote helper.
686
- * @returns An Error preserving the remote helper failure value.
687
699
  */
688
700
  var RemoteHelperError = class extends RuntimeError {
689
701
  /**
@@ -699,6 +711,6 @@ var RemoteHelperError = class extends RuntimeError {
699
711
  }
700
712
  };
701
713
  //#endregion
702
- export { UncheckedFormHandlerMissingError as C, UnsupportedMarkupEffectPositionError as D, UncheckedQueryHandlerMissingError as E, UnsupportedRemoteFormResponseError as O, UncheckedCommandHandlerMissingError as S, UncheckedPrerenderHandlerMissingError as T, RequestEventUnavailableError as _, DispatcherDisposedError as a, ServerOnlyImportError as b, InvalidLiveQueryFactoryError as c, InvalidRemoteFormResponseError as d, PreprocessError as f, RemoteHelperError as g, RemoteHelperContextError as h, BatchQueryHandlerMissingError as i, YieldStarInEventCallbackError as k, InvalidLiveQueryReturnError as l, RemoteFormEndpointMissingError as m, AsyncEffectInSyncRuneError as n, EmptyStreamYieldError as o, RemoteErrorDecodeError as p, AwaitInEffectWorkError as r, InvalidCommandFactoryError as s, AsyncEffectInEventCallbackError as t, InvalidQueryFactoryError as u, RuntimeAlreadyInitializedError as v, UncheckedLiveQueryHandlerMissingError as w, SvelteKitServerExportUnavailableError as x, RuntimeError as y };
714
+ export { UnsupportedMarkupEffectPositionError as A, ServerOnlyImportError as C, UncheckedLiveQueryHandlerMissingError as D, UncheckedFormHandlerMissingError as E, YieldStarInEventCallbackError as M, UncheckedPrerenderHandlerMissingError as O, ScopeDisposedError as S, UncheckedCommandHandlerMissingError as T, RemoteHelperContextError as _, DispatcherDisposedError as a, RuntimeAlreadyInitializedError as b, InvalidLiveQueryFactoryError as c, InvalidQueryFactoryError as d, InvalidRemoteFormResponseError as f, RemoteFormEndpointMissingError as g, RemoteErrorDecodeError as h, BatchQueryHandlerMissingError as i, UnsupportedRemoteFormResponseError as j, UncheckedQueryHandlerMissingError as k, InvalidLiveQueryReturnError as l, PreprocessError as m, AsyncEffectInSyncRuneError as n, EmptyStreamYieldError as o, InvalidYieldableError as p, AwaitInEffectWorkError as r, InvalidCommandFactoryError as s, AsyncEffectInEventCallbackError as t, InvalidPrerenderFactoryError as u, RemoteHelperError as v, SvelteKitServerExportUnavailableError as w, RuntimeError as x, RequestEventUnavailableError as y };
703
715
 
704
- //# sourceMappingURL=errors-IJjsUwrE.js.map
716
+ //# sourceMappingURL=errors-qhcbUH6o.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-qhcbUH6o.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/errors.ts"],"sourcesContent":["/**\n * Base class for runtime-authored errors. The class gives every local failure\n * a stable JavaScript error name while preserving the technical message that\n * reaches Vite, SvelteKit, and test output.\n *\n * @example\n * ```ts\n * throw new RuntimeError(\"Invariant violated.\");\n * ```\n *\n * @since 2.4.0\n * @param message - Technical diagnostic message describing the failed runtime\n * invariant.\n */\nexport class RuntimeError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RuntimeError\";\n\t}\n}\n\nexport function make_error_message(code: string, message: string): string {\n\treturn `[${code}]: ${message}`;\n}\n\n/**\n * Base error class for all preprocessor errors emitted during script and\n * markup transformation. Carries the source filename so error messages can\n * reference the affected file.\n *\n * @example\n * ```ts\n * throw new PreprocessError(\"Component.svelte: invalid transform input.\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param message - Technical diagnostic message for the transform failure.\n * @param filename - Source filename that triggered the transform failure.\n */\nexport class PreprocessError extends RuntimeError {\n\t/**\n\t * The source filename that triggered this error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly filename: string;\n\n\tconstructor(message: string, filename: string) {\n\t\tsuper(message);\n\t\tthis.name = \"PreprocessError\";\n\t\tthis.filename = filename;\n\t}\n}\n\n/**\n * Thrown when a statement mixes JavaScript `await` with Effect `yield*` work\n * that must be lowered into an `Effect.gen` program.\n *\n * @example\n * ```ts\n * throw new AwaitInEffectWorkError(\"Component.svelte\", \"const value = await load();\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the unsupported statement.\n * @param statement_text - Full source text for the statement containing\n * mixed async work.\n */\nexport class AwaitInEffectWorkError extends PreprocessError {\n\t/**\n\t * The full text of the problematic statement containing mixed async work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly statement_text: string;\n\n\tconstructor(filename: string, statement_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"AWAIT_IN_EFFECT_WORK\",\n\t\t\t\t\t`${filename}: await cannot be mixed with yield* in Effect work.`,\n\t\t\t\t),\n\t\t\t\t`Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic statement:`,\n\t\t\t\tstatement_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AwaitInEffectWorkError\";\n\t\tthis.statement_text = statement_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears inside a Svelte rune position that\n * must stay synchronous.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInSyncRuneError(\"$derived\", \"$derived(yield* load())\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param rune_name - Name of the Svelte rune containing the unsupported async\n * Effect work.\n * @param expression_text - Full source text for the rune expression.\n * @param filename - Source filename containing the unsupported rune.\n */\nexport class AsyncEffectInSyncRuneError extends PreprocessError {\n\t/**\n\t * The name of the rune that contained async Effect work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly rune_name: string;\n\n\t/**\n\t * The full text of the expression that triggered the error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(rune_name: string, expression_text: string, filename: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_SYNC_RUNE\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside ${rune_name}().`,\n\t\t\t\t),\n\t\t\t\t`${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInSyncRuneError\";\n\t\tthis.rune_name = rune_name;\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears inside a non-generator callback nested\n * in a markup event handler.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInEventCallbackError(\n * \"Component.svelte\",\n * \"Effect.try(() => yield* save())\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the invalid event handler.\n * @param expression_text - Event handler expression that contains the nested\n * unsupported async Effect work.\n */\nexport class AsyncEffectInEventCallbackError extends PreprocessError {\n\t/**\n\t * The full text of the problematic event handler body.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`,\n\t\t\t\t),\n\t\t\t\t`Move the yield* to the event handler body. Effect.try and Effect.sync callbacks are plain synchronous JavaScript; do not call Effect-returning functions inside them.`,\n\t\t\t\t\"\",\n\t\t\t\t`Run the remote Effect directly:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Recover from remote failures by composing the Effect value:`,\n\t\t\t\t` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when an event handler callback contains the old raw `yield*`\n * shorthand. Effectful event handlers must put `yield*` directly in the event\n * attribute so the callback boundary is generated by the markup runtime.\n *\n * @example\n * ```ts\n * throw new YieldStarInEventCallbackError(\"Component.svelte\", \"() => yield* save()\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Svelte component filename used to identify where the\n * invalid event handler callback was found.\n * @param expression_text - Original event handler callback text that contained\n * `yield*` and should be rewritten as a direct event Effect expression.\n */\nexport class YieldStarInEventCallbackError extends PreprocessError {\n\t/**\n\t * The full text of the problematic event handler callback.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* in markup event handlers must be written directly as the event attribute value.`,\n\t\t\t\t),\n\t\t\t\t`SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,\n\t\t\t\t\"\",\n\t\t\t\t`Use this form:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Instead of this form:`,\n\t\t\t\t` onclick={() => yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"YieldStarInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when async Effect work appears in a markup position SER cannot lower\n * safely.\n *\n * @example\n * ```ts\n * throw new UnsupportedMarkupEffectPositionError(\n * \"Component.svelte\",\n * \"value={yield* load()}\",\n * );\n * ```\n *\n * @since 2.4.2\n * @param filename - Source filename containing the unsupported markup.\n * @param expression_text - The unsupported markup expression text.\n */\nexport class UnsupportedMarkupEffectPositionError extends PreprocessError {\n\t/**\n\t * The unsupported markup expression text.\n\t *\n\t * @since 2.4.2\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"UNSUPPORTED_MARKUP_EFFECT_POSITION\",\n\t\t\t\t\t`${filename}: yield* cannot be used in this markup position.`,\n\t\t\t\t),\n\t\t\t\t`Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"UnsupportedMarkupEffectPositionError\";\n\t\tthis.expression_text = expression_text;\n\t}\n}\n\n/**\n * Thrown when the request-scoped SvelteKit event context is read outside a\n * remote handler.\n *\n * @example\n * ```ts\n * throw new RequestEventUnavailableError();\n * ```\n *\n * @since 2.4.0\n */\nexport class RequestEventUnavailableError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"RequestEvent is only available while a SER remote handler is executing inside a request-scoped Effect context.\",\n\t\t);\n\t\tthis.name = \"RequestEventUnavailableError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute by itself.\",\n\t\t);\n\t\tthis.name = \"UncheckedQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when a batch Query declaration omits the batch handler.\n *\n * @example\n * ```ts\n * throw new BatchQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class BatchQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.batch requires a concrete batch handler function; the batch helper cannot infer a handler from schema metadata alone.\",\n\t\t);\n\t\tthis.name = \"BatchQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked live Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedLiveQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedLiveQueryHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce a live source.\",\n\t\t);\n\t\tthis.name = \"UncheckedLiveQueryHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Command declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedCommandHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedCommandHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Command('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute a command.\",\n\t\t);\n\t\tthis.name = \"UncheckedCommandHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Form declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedFormHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedFormHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Form('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot process form data.\",\n\t\t);\n\t\tthis.name = \"UncheckedFormHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when an unchecked Prerender declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedPrerenderHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class UncheckedPrerenderHandlerMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Prerender('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce prerendered data.\",\n\t\t);\n\t\tthis.name = \"UncheckedPrerenderHandlerMissingError\";\n\t}\n}\n\n/**\n * Thrown when a live query handler resolves to a value that cannot be streamed.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryReturnError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidLiveQueryReturnError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live handler must return an Effect Stream. Wrap native iterables with Stream.fromIterable, Stream.fromAsyncIterable, or another Stream constructor before returning them.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryReturnError\";\n\t}\n}\n\n/**\n * Thrown when generated component code yields a Stream that completes before\n * producing a value.\n *\n * @example\n * ```ts\n * throw new EmptyStreamYieldError();\n * ```\n *\n * @since 3.4.8\n */\nexport class EmptyStreamYieldError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Cannot resolve yield* stream expression because the Stream completed without emitting a value.\",\n\t\t);\n\t\tthis.name = \"EmptyStreamYieldError\";\n\t}\n}\n\n/**\n * Thrown when generated component code receives a value that cannot be yielded\n * through the SER runtime.\n *\n * @example\n * ```ts\n * throw new InvalidYieldableError(null);\n * ```\n *\n * @since 4.0.0\n * @param value - Runtime value that was expected to be an Effect, generator, or\n * Stream.\n */\nexport class InvalidYieldableError extends RuntimeError {\n\t/**\n\t * Runtime value rejected by the generated yield boundary.\n\t *\n\t * @since 4.0.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(\n\t\t\t\"Cannot resolve yield* expression because it returned a non-yieldable value. Expected an Effect, generator, or Stream.\",\n\t\t);\n\t\tthis.name = \"InvalidYieldableError\";\n\t\tthis.value = value;\n\t}\n}\n\n/**\n * Thrown when a dispatcher operation is requested after disposal.\n *\n * @example\n * ```ts\n * throw new DispatcherDisposedError();\n * ```\n *\n * @since 2.4.0\n */\nexport class DispatcherDisposedError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Dispatcher has been disposed; no new Effect fibers or promise bridges can be started after component teardown.\",\n\t\t);\n\t\tthis.name = \"DispatcherDisposedError\";\n\t}\n}\n\n/**\n * Thrown when Effect work is bound to a component scope that has already been\n * disposed.\n *\n * @example\n * ```ts\n * throw new ScopeDisposedError();\n * ```\n *\n * @since 3.1.0\n */\nexport class ScopeDisposedError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Effect scope has been disposed; no new Effect work can be bound to a destroyed component's scope.\",\n\t\t);\n\t\tthis.name = \"ScopeDisposedError\";\n\t}\n}\n\n/**\n * Thrown when an application attempts to configure a runtime after one has\n * already been initialized.\n *\n * @example\n * ```ts\n * throw new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n * ```\n *\n * @since 3.4.0\n * @param runtime_name - Public runtime API that was initialized more than once.\n */\nexport class RuntimeAlreadyInitializedError extends RuntimeError {\n\tconstructor(runtime_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"RUNTIME_ALREADY_INITIALIZED\",\n\t\t\t\t`${runtime_name}.make(...) cannot be called because the runtime has already been initialized. Configure it once during application startup, before any Effect-backed component, remote handler, or generated runtime code runs.`,\n\t\t\t),\n\t\t);\n\t\tthis.name = \"RuntimeAlreadyInitializedError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidQueryFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid query factory: expected a function or an object exposing query/load methods from SvelteKit remote query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidQueryFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote prerender export is not callable.\n *\n * @since 4.0.0\n */\nexport class InvalidPrerenderFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid prerender factory: expected a function from SvelteKit remote prerender generation.\",\n\t\t);\n\t\tthis.name = \"InvalidPrerenderFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote live query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidLiveQueryFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid live query factory: expected a function or an object exposing a query method from SvelteKit remote live query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryFactoryError\";\n\t}\n}\n\n/**\n * Thrown when a generated or native remote command export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidCommandFactoryError();\n * ```\n *\n * @since 2.4.0\n */\nexport class InvalidCommandFactoryError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid command factory: expected a function or an object exposing an invoke method from SvelteKit remote command generation.\",\n\t\t);\n\t\tthis.name = \"InvalidCommandFactoryError\";\n\t}\n}\n\n/**\n * Thrown when the client-side form adapter cannot derive a remote endpoint.\n *\n * @example\n * ```ts\n * throw new RemoteFormEndpointMissingError();\n * ```\n *\n * @since 2.4.0\n */\nexport class RemoteFormEndpointMissingError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Form has no submit method or remote endpoint; the adapted SvelteKit form object does not expose an action id and no remote base URL was generated.\",\n\t\t);\n\t\tthis.name = \"RemoteFormEndpointMissingError\";\n\t}\n}\n\n/**\n * Thrown when a remote form response envelope is not an object with a response\n * type.\n *\n * @example\n * ```ts\n * throw new InvalidRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n */\nexport class InvalidRemoteFormResponseError extends RuntimeError {\n\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Invalid remote form response: expected an object envelope with a string type field returned by SvelteKit remote form transport.\",\n\t\t);\n\t\tthis.name = \"InvalidRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\n}\n\n/**\n * Thrown when a remote form response has a well-formed envelope but an\n * unsupported response type or payload slot.\n *\n * @example\n * ```ts\n * throw new UnsupportedRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n */\nexport class UnsupportedRemoteFormResponseError extends RuntimeError {\n\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Unsupported remote form response: expected a result envelope with a devalue-encoded result or data string.\",\n\t\t);\n\t\tthis.name = \"UnsupportedRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\n}\n\n/**\n * Thrown when a serialized remote failure envelope cannot be decoded.\n *\n * @example\n * ```ts\n * throw new RemoteErrorDecodeError(raw);\n * ```\n *\n * @since 2.4.0\n * @param raw - Raw serialized remote failure payload that failed decoding.\n */\nexport class RemoteErrorDecodeError extends RuntimeError {\n\t/**\n\t * Raw serialized remote failure payload that failed decoding.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly raw: unknown;\n\n\tconstructor(raw?: unknown) {\n\t\tsuper(\n\t\t\t\"Failed to decode remote error payload: expected a devalue-encoded SER remote failure envelope compatible with the client decoder.\",\n\t\t);\n\t\tthis.name = \"RemoteErrorDecodeError\";\n\t\tthis.raw = raw;\n\t}\n}\n\n/**\n * Thrown when a root server-only helper is imported without Vite rewriting.\n *\n * @example\n * ```ts\n * throw new ServerOnlyImportError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the server-only root export that was invoked.\n */\nexport class ServerOnlyImportError extends RuntimeError {\n\t/**\n\t * Name of the server-only root export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`${export_name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to svelte-effect-runtime/server before execution.`,\n\t\t);\n\t\tthis.name = \"ServerOnlyImportError\";\n\t\tthis.export_name = export_name;\n\t}\n}\n\n/**\n * Thrown when the publish-time `$app/server` shim executes outside SvelteKit.\n *\n * @example\n * ```ts\n * throw new SvelteKitServerExportUnavailableError(\"query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the `$app/server` export that was invoked.\n */\nexport class SvelteKitServerExportUnavailableError extends RuntimeError {\n\t/**\n\t * Name of the `$app/server` export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`SvelteKit virtual $app/server export ${export_name} is only available inside a SvelteKit server module.`,\n\t\t);\n\t\tthis.name = \"SvelteKitServerExportUnavailableError\";\n\t\tthis.export_name = export_name;\n\t}\n}\n\n/**\n * Thrown when a SvelteKit remote helper reports that it was called outside the\n * route-scoped remote module context.\n *\n * @example\n * ```ts\n * throw new RemoteHelperContextError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param helper_name - SER helper name that triggered the context failure.\n */\nexport class RemoteHelperContextError extends RuntimeError {\n\t/**\n\t * SER helper name that triggered the context failure.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly helper_name: string;\n\n\tconstructor(helper_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"REMOTE_HELPER_CONTEXT\",\n\t\t\t\t`${helper_name} was called outside a .remote.ts file. Ensure the file is named \\`*.remote.ts\\` and is located in a route directory so SvelteKit can bind remote helper context.`,\n\t\t\t),\n\t\t);\n\t\tthis.name = \"RemoteHelperContextError\";\n\t\tthis.helper_name = helper_name;\n\t}\n}\n\n/**\n * Thrown when a SvelteKit remote helper normalizes a non-Error thrown value.\n *\n * @example\n * ```ts\n * throw new RemoteHelperError(\"raw failure\");\n * ```\n *\n * @since 2.4.0\n * @param value - Non-Error value thrown while creating a remote helper.\n */\nexport class RemoteHelperError extends RuntimeError {\n\t/**\n\t * Non-Error value that was normalized.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(make_error_message(\"REMOTE_HELPER_ERROR\", String(value)));\n\t\tthis.name = \"RemoteHelperError\";\n\t\tthis.value = value;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,IAAa,eAAb,cAAkC,MAAM;CACvC,YAAY,SAAiB;EAC5B,MAAM,OAAO;EACb,KAAK,OAAO;CACb;AACD;AAEA,SAAgB,mBAAmB,MAAc,SAAyB;CACzE,OAAO,IAAI,KAAK,KAAK;AACtB;;;;;;;;;;;;;;;AAgBA,IAAa,kBAAb,cAAqC,aAAa;;;;;;CAMjD;CAEA,YAAY,SAAiB,UAAkB;EAC9C,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;CACjB;AACD;;;;;;;;;;;;;;;AAgBA,IAAa,yBAAb,cAA4C,gBAAgB;;;;;;CAM3D;CAEA,YAAY,UAAkB,gBAAwB;EACrD,MACC;GACC,mBACC,wBACA,GAAG,SAAS,oDACb;GACA;GACA;GACA;GACA;EACD,CAAC,CAAC,KAAK,IAAI,GACX,QACD;EACA,KAAK,OAAO;EACZ,KAAK,iBAAiB;CACvB;AACD;;;;;;;;;;;;;;;;AAiBA,IAAa,6BAAb,cAAgD,gBAAgB;;;;;;CAM/D;;;;;;CAOA;CAEA,YAAY,WAAmB,iBAAyB,UAAkB;EACzE,MACC;GACC,mBACC,6BACA,GAAG,SAAS,iCAAiC,UAAU,IACxD;GACA,GAAG,UAAU;GACb;GACA;GACA;EACD,CAAC,CAAC,KAAK,IAAI,GACX,QACD;EACA,KAAK,OAAO;EACZ,KAAK,YAAY;EACjB,KAAK,kBAAkB;CACxB;AACD;;;;;;;;;;;;;;;;;;AAmBA,IAAa,kCAAb,cAAqD,gBAAgB;;;;;;CAMpE;CAEA,YAAY,UAAkB,iBAAyB;EACtD,MAC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ueryFactoryError } from "./errors-qhcbUH6o.js";
2
+ import { n as remote_live_stream, t as RemoteLiveYield } from "./live-CHK0RrZu.js";
3
+ import { create_remote_transport_error } from "../remote/shared.js";
4
+ import { Effect, Stream } from "effect";
5
+ import { stringify } from "devalue";
6
+ //#region src/live.ts
7
+ const live_metadata = Symbol.for("ser.remote-live-metadata");
8
+ const live_operator = Symbol.for("ser.live-operator");
9
+ function make_remote_live_stream(resource, on_error, encode_snapshot = stringify) {
10
+ const live_resource = as_native_live_resource(resource);
11
+ return attach_live_metadata(make_live_stream(live_resource, on_error, encode_snapshot), {
12
+ resource: live_resource,
13
+ on_error
14
+ });
15
+ }
16
+ function make_live_stream(resource, on_error, encode_snapshot) {
17
+ const stream = Stream.fromAsyncIterable(resource, on_error);
18
+ const then = resource.then;
19
+ if (typeof then !== "function") return stream;
20
+ const initial_stream = Stream.fromAsyncIterable(make_cached_live_iterable(resource, then, encode_snapshot), on_error);
21
+ return Stream.unwrap(RemoteLiveYield.pipe(Effect.map((is_generated_yield) => is_generated_yield ? initial_stream : stream)));
22
+ }
23
+ function make_cached_live_iterable(resource, then, encode_snapshot) {
24
+ return { async *[Symbol.asyncIterator]() {
25
+ const initial_value = await resolve_live_initial_value(resource, then);
26
+ let is_first_snapshot = true;
27
+ yield initial_value;
28
+ for await (const value of resource) {
29
+ /** Native iterators usually replay their current snapshot before later updates. */
30
+ if (is_first_snapshot) {
31
+ is_first_snapshot = false;
32
+ if (is_same_live_snapshot(initial_value, value, encode_snapshot)) continue;
33
+ }
34
+ yield value;
35
+ }
36
+ } };
37
+ }
38
+ function is_same_live_snapshot(left, right, encode_snapshot) {
39
+ if (Object.is(left, right)) return true;
40
+ try {
41
+ return encode_snapshot(left) === encode_snapshot(right);
42
+ } catch {
43
+ return false;
44
+ }
45
+ }
46
+ function resolve_live_initial_value(resource, then) {
47
+ return new Promise((resolve, reject) => {
48
+ then.call(resource, resolve, reject);
49
+ });
50
+ }
51
+ function make_failed_remote_live_stream(error, on_error) {
52
+ const failure = on_error(error);
53
+ const metadata = {
54
+ resource: {
55
+ connected: false,
56
+ done: true,
57
+ error: failure,
58
+ [Symbol.asyncIterator]: () => ({ next: () => Promise.reject(failure) })
59
+ },
60
+ on_error
61
+ };
62
+ return attach_live_metadata(Stream.fail(failure), metadata);
63
+ }
64
+ /**
65
+ * Remote live transport helpers.
66
+ *
67
+ * @since 3.4.8
68
+ */
69
+ const Live = {
70
+ status: Object.assign(function status(stream) {
71
+ return Stream.unwrap(Effect.sync(() => {
72
+ const metadata = get_live_metadata(stream);
73
+ if (!metadata) return Stream.succeed({ _tag: "Idle" });
74
+ return Stream.succeed(read_live_status(metadata.resource)).pipe(Stream.concat(Stream.tick("250 millis").pipe(Stream.map(() => read_live_status(metadata.resource)))));
75
+ }));
76
+ }, { [live_operator]: true }),
77
+ reconnect: Object.assign(function reconnect(stream) {
78
+ return Effect.gen(function* () {
79
+ const metadata = get_live_metadata(stream);
80
+ const reconnect = metadata?.resource.reconnect;
81
+ if (!metadata || typeof reconnect !== "function") return yield* Effect.fail(create_remote_transport_error(new InvalidLiveQueryFactoryError()));
82
+ yield* Effect.tryPromise({
83
+ try: () => Promise.resolve(reconnect.call(metadata.resource)),
84
+ catch: metadata.on_error
85
+ });
86
+ });
87
+ }, { [live_operator]: true })
88
+ };
89
+ function as_native_live_resource(resource) {
90
+ if (!is_native_live_resource(resource)) throw new InvalidLiveQueryFactoryError();
91
+ return resource;
92
+ }
93
+ function is_native_live_resource(resource) {
94
+ const resource_type = typeof resource;
95
+ if (resource_type !== "object" && resource_type !== "function") return false;
96
+ if (resource === null) return false;
97
+ return typeof resource[Symbol.asyncIterator] === "function";
98
+ }
99
+ function attach_live_metadata(stream, metadata) {
100
+ const carrier = stream;
101
+ if (carrier[live_metadata]) return stream;
102
+ Object.defineProperty(carrier, live_metadata, {
103
+ configurable: true,
104
+ value: metadata
105
+ });
106
+ Object.defineProperty(carrier, remote_live_stream, {
107
+ configurable: true,
108
+ value: true
109
+ });
110
+ propagate_live_metadata_through_pipe(carrier, metadata);
111
+ return stream;
112
+ }
113
+ function propagate_live_metadata_through_pipe(stream, metadata) {
114
+ const pipe = stream.pipe.bind(stream);
115
+ Object.defineProperty(stream, "pipe", {
116
+ configurable: true,
117
+ value: (...args) => {
118
+ const result = pipe(...args);
119
+ if (!Stream.isStream(result) || args.some(is_live_operator)) return result;
120
+ return attach_live_metadata(result, metadata);
121
+ }
122
+ });
123
+ }
124
+ function is_live_operator(value) {
125
+ return typeof value === "function" && value[live_operator] === true;
126
+ }
127
+ function get_live_metadata(stream) {
128
+ return stream[live_metadata];
129
+ }
130
+ function get_native_remote_live_resource(value) {
131
+ if (!Stream.isStream(value)) return;
132
+ return get_live_metadata(value)?.resource;
133
+ }
134
+ function read_live_status(resource) {
135
+ if (resource.error !== void 0) return {
136
+ _tag: "Failed",
137
+ cause: resource.error
138
+ };
139
+ if (resource.done === true) return { _tag: "Closed" };
140
+ if (resource.connected === true) return { _tag: "Open" };
141
+ return { _tag: "Connecting" };
142
+ }
143
+ //#endregion
144
+ export { make_remote_live_stream as i, get_native_remote_live_resource as n, make_failed_remote_live_stream as r, Live as t };
145
+
146
+ //# sourceMappingURL=live-BW7xZKjb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-BW7xZKjb.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/live.ts"],"sourcesContent":["import {\n\tRemoteLiveYield,\n\tremote_live_stream,\n\ttype RemoteLiveStreamCarrier,\n} from \"$/internal/live.ts\";\nimport { create_remote_transport_error } from \"$/remote/shared.ts\";\nimport { InvalidLiveQueryFactoryError } from \"$/errors.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect, Stream } from \"effect\";\nimport { stringify } from \"devalue\";\n\nconst live_metadata: unique symbol = Symbol.for(\"ser.remote-live-metadata\") as never;\n\nconst live_operator: unique symbol = Symbol.for(\"ser.live-operator\") as never;\n\ntype RemoteLivePipe<A, E> = {\n\t(): RemoteLiveStream<A, E>;\n\t(ab: LiveFactory[\"status\"]): Stream.Stream<LiveStatus, never, never>;\n\t(ab: LiveFactory[\"reconnect\"]): Effect.Effect<void, RemoteFailure<E>, never>;\n\t<B>(ab: LiveFactory[\"status\"], bc: (_: Stream.Stream<LiveStatus, never, never>) => B): B;\n\t<B>(\n\t\tab: LiveFactory[\"reconnect\"],\n\t\tbc: (_: Effect.Effect<void, RemoteFailure<E>, never>) => B,\n\t): B;\n\t<B, C>(\n\t\tab: LiveFactory[\"status\"],\n\t\tbc: (_: Stream.Stream<LiveStatus, never, never>) => B,\n\t\tcd: (_: B) => C,\n\t): C;\n\t<B, C>(\n\t\tab: LiveFactory[\"reconnect\"],\n\t\tbc: (_: Effect.Effect<void, RemoteFailure<E>, never>) => B,\n\t\tcd: (_: B) => C,\n\t): C;\n\t<B>(\n\t\tab: (\n\t\t\t_: Stream.Stream<A, RemoteFailure<E>, never>,\n\t\t) => Stream.Stream<B, RemoteFailure<E>, never>,\n\t): RemoteLiveStream<B, E>;\n\t<B>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B): B;\n\t<B, C>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B, bc: (_: B) => C): C;\n\t<B, C, D>(\n\t\tab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B,\n\t\tbc: (_: B) => C,\n\t\tcd: (_: C) => D,\n\t): D;\n};\n\n/**\n * Stream returned by `Query.live` remote functions.\n *\n * @example\n * ```ts\n * const Time = GetTime();\n * const Label = Time.pipe(Stream.map((time) => time.toISOString()));\n * ```\n *\n * @since 3.4.8\n */\nexport type RemoteLiveStream<A, E = never> = Omit<\n\tStream.Stream<A, RemoteFailure<E>, never>,\n\t\"pipe\"\n> & {\n\treadonly [remote_live_stream]: true;\n\treadonly pipe: RemoteLivePipe<A, E>;\n};\n\n/**\n * Transport state exposed separately from the data stream.\n *\n * @example\n * ```ts\n * const Status = GetTime().pipe(Live.status);\n * ```\n *\n * @since 3.4.8\n */\nexport type LiveStatus =\n\t| {\n\t\t\treadonly _tag: \"Idle\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Connecting\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Open\";\n\t }\n\t| {\n\t\t\treadonly _tag: \"Failed\";\n\t\t\treadonly cause: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"Closed\";\n\t };\n\n/**\n * Public live stream control helpers.\n *\n * @example\n * ```ts\n * yield* GetNotifications().pipe(Live.reconnect);\n * ```\n *\n * @since 3.4.8\n */\nexport interface LiveFactory {\n\treadonly status: {\n\t\treadonly [live_operator]: true;\n\t\t/**\n\t\t * Creates a stream of transport status updates for a remote live stream.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * const Status = GetTime().pipe(Live.status);\n\t\t * ```\n\t\t *\n\t\t * @param stream - Remote live stream whose transport status should be read.\n\t\t * @returns A stream of transport status snapshots.\n\t\t */\n\t\t<A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never>;\n\t};\n\treadonly reconnect: {\n\t\treadonly [live_operator]: true;\n\t\t/**\n\t\t * Reconnects the transport behind a remote live stream.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * yield* GetNotifications().pipe(Live.reconnect);\n\t\t * ```\n\t\t *\n\t\t * @param stream - Remote live stream whose transport should reconnect.\n\t\t * @returns An Effect that completes after the reconnect request is sent.\n\t\t */\n\t\t<A, E>(stream: RemoteLiveStream<A, E>): Effect.Effect<void, RemoteFailure<E>, never>;\n\t};\n}\n\ntype NativeLiveResource<A> = {\n\treadonly connected?: boolean;\n\treadonly current?: A;\n\treadonly done?: boolean;\n\treadonly error?: unknown;\n\treadonly loading?: boolean;\n\treadonly ready?: boolean;\n\treadonly reconnect?: () => Promise<void> | void;\n\treadonly then?: PromiseLike<A>[\"then\"];\n\treadonly [Symbol.asyncIterator]?: () => AsyncIterator<A>;\n};\n\ntype LiveMetadata<A = unknown, ErrorType = never> = {\n\treadonly resource: NativeLiveResource<A>;\n\treadonly on_error: (error: unknown) => RemoteFailure<ErrorType>;\n};\n\ntype LiveMetadataCarrier = RemoteLiveStreamCarrier & {\n\treadonly [live_metadata]?: LiveMetadata<unknown, unknown>;\n};\n\ntype PipeableStream<A, E, R> = Stream.Stream<A, E, R> & {\n\treadonly pipe: (...args: readonly unknown[]) => unknown;\n};\n\nexport function make_remote_live_stream<A, ErrorType = never>(\n\tresource: unknown,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n\tencode_snapshot: (value: unknown) => string = stringify,\n): RemoteLiveStream<A, ErrorType> {\n\tconst live_resource = as_native_live_resource<A>(resource);\n\tconst stream = make_live_stream(live_resource, on_error, encode_snapshot);\n\tconst metadata: LiveMetadata<A, ErrorType> = {\n\t\tresource: live_resource,\n\t\ton_error,\n\t};\n\n\treturn attach_live_metadata(stream, metadata) as RemoteLiveStream<A, ErrorType>;\n}\n\nfunction make_live_stream<A, ErrorType>(\n\tresource: NativeLiveResource<A> & AsyncIterable<A>,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n\tencode_snapshot: (value: unknown) => string,\n): Stream.Stream<A, RemoteFailure<ErrorType>, never> {\n\tconst stream = Stream.fromAsyncIterable(resource, on_error);\n\tconst then = resource.then;\n\n\tif (typeof then !== \"function\") {\n\t\treturn stream;\n\t}\n\n\tconst initial_stream = Stream.fromAsyncIterable(\n\t\tmake_cached_live_iterable(resource, then, encode_snapshot),\n\t\ton_error,\n\t);\n\n\treturn Stream.unwrap(\n\t\tRemoteLiveYield.pipe(\n\t\t\tEffect.map((is_generated_yield) => (is_generated_yield ? initial_stream : stream)),\n\t\t),\n\t);\n}\n\nfunction make_cached_live_iterable<A>(\n\tresource: NativeLiveResource<A> & AsyncIterable<A>,\n\tthen: PromiseLike<A>[\"then\"],\n\tencode_snapshot: (value: unknown) => string,\n): AsyncIterable<A> {\n\treturn {\n\t\tasync *[Symbol.asyncIterator]() {\n\t\t\tconst initial_value = await resolve_live_initial_value(resource, then);\n\t\t\tlet is_first_snapshot = true;\n\n\t\t\tyield initial_value;\n\n\t\t\tfor await (const value of resource) {\n\t\t\t\t/** Native iterators usually replay their current snapshot before later updates. */\n\t\t\t\tif (is_first_snapshot) {\n\t\t\t\t\tis_first_snapshot = false;\n\n\t\t\t\t\tif (is_same_live_snapshot(initial_value, value, encode_snapshot)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tyield value;\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction is_same_live_snapshot(\n\tleft: unknown,\n\tright: unknown,\n\tencode_snapshot: (value: unknown) => string,\n): boolean {\n\tif (Object.is(left, right)) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst left_encoded = encode_snapshot(left);\n\t\tconst right_encoded = encode_snapshot(right);\n\n\t\treturn left_encoded === right_encoded;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction resolve_live_initial_value<A>(\n\tresource: NativeLiveResource<A>,\n\tthen: PromiseLike<A>[\"then\"],\n): Promise<A> {\n\treturn new Promise<A>((resolve, reject) => {\n\t\tvoid then.call(resource, resolve, reject);\n\t});\n}\n\nexport function make_failed_remote_live_stream<A, ErrorType = never>(\n\terror: unknown,\n\ton_error: (error: unknown) => RemoteFailure<ErrorType>,\n): RemoteLiveStream<A, ErrorType> {\n\tconst failure = on_error(error);\n\tconst resource: NativeLiveResource<A> & AsyncIterable<A> = {\n\t\tconnected: false,\n\t\tdone: true,\n\t\terror: failure,\n\t\t[Symbol.asyncIterator]: () => ({\n\t\t\tnext: () => Promise.reject(failure),\n\t\t}),\n\t};\n\tconst metadata: LiveMetadata<A, ErrorType> = {\n\t\tresource,\n\t\ton_error,\n\t};\n\tconst stream = Stream.fail(failure);\n\n\treturn attach_live_metadata(stream, metadata) as unknown as RemoteLiveStream<A, ErrorType>;\n}\n\nconst LiveStatusStream = Object.assign(\n\tfunction status<A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never> {\n\t\treturn Stream.unwrap(\n\t\t\tEffect.sync(() => {\n\t\t\t\tconst metadata = get_live_metadata(stream);\n\n\t\t\t\tif (!metadata) {\n\t\t\t\t\treturn Stream.succeed({ _tag: \"Idle\" } as const);\n\t\t\t\t}\n\n\t\t\t\treturn Stream.succeed(read_live_status(metadata.resource)).pipe(\n\t\t\t\t\tStream.concat(\n\t\t\t\t\t\tStream.tick(\"250 millis\").pipe(\n\t\t\t\t\t\t\tStream.map(() => read_live_status(metadata.resource)),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t},\n\t{ [live_operator]: true as const },\n) satisfies LiveFactory[\"status\"];\n\nconst LiveReconnect = Object.assign(\n\tfunction reconnect<A, E>(\n\t\tstream: RemoteLiveStream<A, E>,\n\t): Effect.Effect<void, RemoteFailure<E>, never> {\n\t\treturn Effect.gen(function* () {\n\t\t\tconst metadata = get_live_metadata(stream);\n\t\t\tconst reconnect = metadata?.resource.reconnect;\n\n\t\t\tif (!metadata || typeof reconnect !== \"function\") {\n\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\tcreate_remote_transport_error(new InvalidLiveQueryFactoryError()),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tyield* Effect.tryPromise({\n\t\t\t\ttry: () => Promise.resolve(reconnect.call(metadata.resource)),\n\t\t\t\tcatch: metadata.on_error,\n\t\t\t});\n\t\t});\n\t},\n\t{ [live_operator]: true as const },\n) satisfies LiveFactory[\"reconnect\"];\n\n/**\n * Remote live transport helpers.\n *\n * @since 3.4.8\n */\nexport const Live: LiveFactory = {\n\tstatus: LiveStatusStream,\n\treconnect: LiveReconnect,\n};\n\nfunction as_native_live_resource<A>(resource: unknown): NativeLiveResource<A> & AsyncIterable<A> {\n\tif (!is_native_live_resource<A>(resource)) {\n\t\tthrow new InvalidLiveQueryFactoryError();\n\t}\n\n\treturn resource;\n}\n\nfunction is_native_live_resource<A>(\n\tresource: unknown,\n): resource is NativeLiveResource<A> & AsyncIterable<A> {\n\tconst resource_type = typeof resource;\n\n\tif (resource_type !== \"object\" && resource_type !== \"function\") {\n\t\treturn false;\n\t}\n\n\tif (resource === null) {\n\t\treturn false;\n\t}\n\n\treturn typeof (resource as NativeLiveResource<A>)[Symbol.asyncIterator] === \"function\";\n}\n\nfunction attach_live_metadata<A, E, R>(\n\tstream: Stream.Stream<A, E, R>,\n\tmetadata: LiveMetadata<unknown, unknown>,\n): Stream.Stream<A, E, R> {\n\tconst carrier = stream as Stream.Stream<A, E, R> & LiveMetadataCarrier;\n\n\tif (carrier[live_metadata]) {\n\t\treturn stream;\n\t}\n\n\tObject.defineProperty(carrier, live_metadata, {\n\t\tconfigurable: true,\n\t\tvalue: metadata,\n\t});\n\n\tObject.defineProperty(carrier, remote_live_stream, {\n\t\tconfigurable: true,\n\t\tvalue: true,\n\t});\n\n\tpropagate_live_metadata_through_pipe(carrier as PipeableStream<A, E, R>, metadata);\n\n\treturn stream;\n}\n\nfunction propagate_live_metadata_through_pipe<A, E, R>(\n\tstream: PipeableStream<A, E, R>,\n\tmetadata: LiveMetadata<unknown, unknown>,\n): void {\n\tconst pipe = stream.pipe.bind(stream);\n\n\tObject.defineProperty(stream, \"pipe\", {\n\t\tconfigurable: true,\n\t\tvalue: (...args: readonly unknown[]) => {\n\t\t\tconst result = pipe(...args);\n\n\t\t\tif (!Stream.isStream(result) || args.some(is_live_operator)) {\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\treturn attach_live_metadata(result, metadata);\n\t\t},\n\t});\n}\n\nfunction is_live_operator(value: unknown): boolean {\n\treturn (\n\t\ttypeof value === \"function\" &&\n\t\t(value as { readonly [live_operator]?: true })[live_operator] === true\n\t);\n}\n\nfunction get_live_metadata<A, E>(stream: RemoteLiveStream<A, E>): LiveMetadata<A, E> | undefined;\nfunction get_live_metadata(\n\tstream: Stream.Stream<unknown, unknown, unknown>,\n): LiveMetadata<unknown, unknown> | undefined;\nfunction get_live_metadata(\n\tstream: Stream.Stream<unknown, unknown, unknown>,\n): LiveMetadata<unknown, unknown> | undefined {\n\treturn (stream as LiveMetadataCarrier)[live_metadata];\n}\n\nexport function get_native_remote_live_resource(value: unknown): unknown | undefined {\n\tif (!Stream.isStream(value)) {\n\t\treturn undefined;\n\t}\n\n\treturn get_live_metadata(value)?.resource;\n}\n\nfunction read_live_status(resource: NativeLiveResource<unknown>): LiveStatus {\n\tif (resource.error !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"Failed\",\n\t\t\tcause: resource.error,\n\t\t};\n\t}\n\n\tif (resource.done === true) {\n\t\treturn { _tag: \"Closed\" };\n\t}\n\n\tif (resource.connected === true) {\n\t\treturn { _tag: \"Open\" };\n\t}\n\n\treturn { _tag: \"Connecting\" };\n}\n"],"mappings":";;;;;;AAWA,MAAM,gBAA+B,OAAO,IAAI,0BAA0B;AAE1E,MAAM,gBAA+B,OAAO,IAAI,mBAAmB;AAsJnE,SAAgB,wBACf,UACA,UACA,kBAA8C,WACb;CACjC,MAAM,gBAAgB,wBAA2B,QAAQ;CAOzD,OAAO,qBANQ,iBAAiB,eAAe,UAAU,eAMxB,GAAG;EAJnC,UAAU;EACV;CAG0C,CAAC;AAC7C;AAEA,SAAS,iBACR,UACA,UACA,iBACoD;CACpD,MAAM,SAAS,OAAO,kBAAkB,UAAU,QAAQ;CAC1D,MAAM,OAAO,SAAS;CAEtB,IAAI,OAAO,SAAS,YACnB,OAAO;CAGR,MAAM,iBAAiB,OAAO,kBAC7B,0BAA0B,UAAU,MAAM,eAAe,GACzD,QACD;CAEA,OAAO,OAAO,OACb,gBAAgB,KACf,OAAO,KAAK,uBAAwB,qBAAqB,iBAAiB,MAAO,CAClF,CACD;AACD;AAEA,SAAS,0BACR,UACA,MACA,iBACmB;CACnB,OAAO,EACN,QAAQ,OAAO,iBAAiB;EAC/B,MAAM,gBAAgB,MAAM,2BAA2B,UAAU,IAAI;EACrE,IAAI,oBAAoB;EAExB,MAAM;EAEN,WAAW,MAAM,SAAS,UAAU;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QAC6C;CAC7C,OAAQ,OAA+B;AACxC;AAEA,SAAgB,gCAAgC,OAAqC;CACpF,IAAI,CAAC,OAAO,SAAS,KAAK,GACzB;CAGD,OAAO,kBAAkB,KAAK,CAAC,EAAE;AAClC;AAEA,SAAS,iBAAiB,UAAmD;CAC5E,IAAI,SAAS,UAAU,KAAA,GACtB,OAAO;EACN,MAAM;EACN,OAAO,SAAS;CACjB;CAGD,IAAI,SAAS,SAAS,MACrB,OAAO,EAAE,MAAM,SAAS;CAGzB,IAAI,SAAS,cAAc,MAC1B,OAAO,EAAE,MAAM,OAAO;CAGvB,OAAO,EAAE,MAAM,aAAa;AAC7B"}
@@ -0,0 +1,10 @@
1
+ import { Context } from "effect";
2
+ //#region src/internal/live.ts
3
+ /** Brands remote live streams without relying on class identity. */
4
+ const remote_live_stream = Symbol.for("ser.remote-live-stream");
5
+ /** Selects the cached-first live source while generated yields resolve. */
6
+ const RemoteLiveYield = Context.Reference("ser.remote-live-yield", { defaultValue: () => false });
7
+ //#endregion
8
+ export { remote_live_stream as n, RemoteLiveYield as t };
9
+
10
+ //# sourceMappingURL=live-CHK0RrZu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-CHK0RrZu.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/internal/live.ts"],"sourcesContent":["import { Context } from \"effect\";\n\n/** Brands remote live streams without relying on class identity. */\nexport const remote_live_stream: unique symbol = Symbol.for(\"ser.remote-live-stream\") as never;\n\n/** Selects the cached-first live source while generated yields resolve. */\nexport const RemoteLiveYield = Context.Reference<boolean>(\"ser.remote-live-yield\", {\n\tdefaultValue: () => false,\n});\n\n/** Internal carrier that identifies a remote live Stream. */\nexport type RemoteLiveStreamCarrier = {\n\treadonly [remote_live_stream]?: true;\n};\n"],"mappings":";;;AAGA,MAAa,qBAAoC,OAAO,IAAI,wBAAwB;;AAGpF,MAAa,kBAAkB,QAAQ,UAAmB,yBAAyB,EAClF,oBAAoB,MACrB,CAAC"}