svelte-effect-runtime 3.4.11 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.dist/chunks/client-BrZka6DW.js +530 -0
  2. package/.dist/chunks/client-BrZka6DW.js.map +1 -0
  3. package/.dist/chunks/compiler-COVzgLYo.js +412 -0
  4. package/.dist/chunks/compiler-COVzgLYo.js.map +1 -0
  5. package/.dist/chunks/descriptors-B4otDlm1.js +216 -0
  6. package/.dist/chunks/descriptors-B4otDlm1.js.map +1 -0
  7. package/.dist/chunks/diagnostics-BDrky-Di.js +359 -0
  8. package/.dist/chunks/diagnostics-BDrky-Di.js.map +1 -0
  9. package/.dist/chunks/dispatcher-BA0PLQhA.js +16 -0
  10. package/.dist/chunks/dispatcher-BA0PLQhA.js.map +1 -0
  11. package/.dist/chunks/{dispatcher-pHH4JcFR.js → dispatcher-_x0MQZBS.js} +84 -258
  12. package/.dist/chunks/dispatcher-_x0MQZBS.js.map +1 -0
  13. package/.dist/chunks/{errors-Dcf0MVbq.js → errors-CLsbGjIa.js} +57 -106
  14. package/.dist/chunks/errors-CLsbGjIa.js.map +1 -0
  15. package/.dist/chunks/live-BundLSoY.js +146 -0
  16. package/.dist/chunks/live-BundLSoY.js.map +1 -0
  17. package/.dist/chunks/live-CHK0RrZu.js +10 -0
  18. package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
  19. package/.dist/chunks/{remote-client-Bj1pZXgq.js → remote-client-mkQAfP1G.js} +30 -24
  20. package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
  21. package/.dist/chunks/{runtime-ekkMQ-wL.js → runtime-HDTlEnzp.js} +3 -27
  22. package/.dist/chunks/runtime-HDTlEnzp.js.map +1 -0
  23. package/.dist/chunks/server-BNrA1I-u.js +144 -0
  24. package/.dist/chunks/server-BNrA1I-u.js.map +1 -0
  25. package/.dist/chunks/source-scan-9pZxnfct.js +1059 -0
  26. package/.dist/chunks/source-scan-9pZxnfct.js.map +1 -0
  27. package/.dist/chunks/{transform-CtQDGS9c.js → transform-BXyYUAez.js} +308 -484
  28. package/.dist/chunks/transform-BXyYUAez.js.map +1 -0
  29. package/.dist/compiler/markup-identifiers.d.ts +2 -0
  30. package/.dist/compiler/remote-client.d.ts +6 -0
  31. package/.dist/compiler/source-scan.d.ts +101 -0
  32. package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
  33. package/.dist/{vite.d.ts → compiler.d.ts} +7 -1
  34. package/.dist/{vite.js → compiler.js} +1 -1
  35. package/.dist/detect.d.ts +0 -31
  36. package/.dist/detect.js +0 -39
  37. package/.dist/detect.js.map +1 -1
  38. package/.dist/diagnostics.d.ts +0 -16
  39. package/.dist/dispatcher/deps.d.ts +3 -14
  40. package/.dist/dispatcher/fibers.d.ts +5 -46
  41. package/.dist/dispatcher/index.d.ts +1 -143
  42. package/.dist/dispatcher/types.d.ts +0 -151
  43. package/.dist/dispatcher.js +1 -1
  44. package/.dist/errors.d.ts +44 -86
  45. package/.dist/generated/dispatcher.d.ts +0 -50
  46. package/.dist/generators.d.ts +3 -12
  47. package/.dist/internal/descriptors.d.ts +0 -16
  48. package/.dist/internal/generators.js +25 -3
  49. package/.dist/internal/generators.js.map +1 -0
  50. package/.dist/internal/live.d.ts +9 -0
  51. package/.dist/internal/remote-client.js +2 -2
  52. package/.dist/internal/remote-server.js +2 -2
  53. package/.dist/internal/schema.d.ts +13 -0
  54. package/.dist/live.d.ts +106 -0
  55. package/.dist/markup/event-attributes.d.ts +5 -28
  56. package/.dist/markup/promise.d.ts +1 -23
  57. package/.dist/markup/promise.js +2 -18
  58. package/.dist/markup/promise.js.map +1 -1
  59. package/.dist/markup/run.d.ts +1 -10
  60. package/.dist/markup/run.js +2 -11
  61. package/.dist/markup/run.js.map +1 -1
  62. package/.dist/markup/transform/apply.d.ts +4 -4
  63. package/.dist/markup/transform/classify.d.ts +2 -11
  64. package/.dist/markup/transform/constants.d.ts +2 -1
  65. package/.dist/markup/transform/effect-bindings.d.ts +2 -26
  66. package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
  67. package/.dist/markup/transform/emit.d.ts +2 -11
  68. package/.dist/markup/transform/expressions.d.ts +0 -35
  69. package/.dist/markup/transform/scan.d.ts +3 -22
  70. package/.dist/markup/transform/types.d.ts +2 -129
  71. package/.dist/markup/transform.js +1 -1
  72. package/.dist/markup/value.d.ts +1 -18
  73. package/.dist/markup/value.js +2 -19
  74. package/.dist/markup/value.js.map +1 -1
  75. package/.dist/mod.d.ts +6 -8
  76. package/.dist/mod.js +5 -4
  77. package/.dist/mod.js.map +1 -1
  78. package/.dist/remote/cause-codec.d.ts +19 -0
  79. package/.dist/remote/client/command.d.ts +3 -17
  80. package/.dist/remote/client/form-data.d.ts +0 -7
  81. package/.dist/remote/client/form-enhance.d.ts +0 -7
  82. package/.dist/remote/client/form-transport.d.ts +15 -18
  83. package/.dist/remote/client/form.d.ts +9 -20
  84. package/.dist/remote/client/index.d.ts +2 -1
  85. package/.dist/remote/client/prerender.d.ts +6 -0
  86. package/.dist/remote/client/query-result.d.ts +2 -14
  87. package/.dist/remote/client/query.d.ts +9 -59
  88. package/.dist/remote/client/responses.d.ts +3 -27
  89. package/.dist/remote/client/types.d.ts +26 -101
  90. package/.dist/remote/client/utils.d.ts +0 -8
  91. package/.dist/remote/client.d.ts +2 -2
  92. package/.dist/remote/client.js +2 -2
  93. package/.dist/remote/effect.d.ts +6 -0
  94. package/.dist/remote/failures.d.ts +4 -0
  95. package/.dist/remote/query-update.d.ts +2 -0
  96. package/.dist/remote/resource.d.ts +25 -0
  97. package/.dist/remote/server.d.ts +5 -60
  98. package/.dist/remote/server.js +2 -179
  99. package/.dist/remote/shared.d.ts +6 -145
  100. package/.dist/remote/shared.js +6 -127
  101. package/.dist/remote/shared.js.map +1 -1
  102. package/.dist/runtime/transform.js +83 -87
  103. package/.dist/runtime/transform.js.map +1 -1
  104. package/.dist/script-transform/ast.d.ts +0 -46
  105. package/.dist/script-transform/imports.d.ts +2 -38
  106. package/.dist/script-transform/lower.d.ts +0 -9
  107. package/.dist/script-transform/runes.d.ts +0 -10
  108. package/.dist/script-transform/runtime-block.d.ts +0 -17
  109. package/.dist/script-transform/source.d.ts +0 -24
  110. package/.dist/script-transform/types.d.ts +9 -126
  111. package/.dist/server/effects.d.ts +8 -57
  112. package/.dist/server/factories.d.ts +7 -7
  113. package/.dist/server/handler.d.ts +37 -0
  114. package/.dist/server/index.d.ts +4 -1
  115. package/.dist/server/invalid.d.ts +0 -7
  116. package/.dist/server/live-snapshot.d.ts +5 -0
  117. package/.dist/server/remote-handler-context.d.ts +5 -0
  118. package/.dist/server/runtime.d.ts +6 -24
  119. package/.dist/server/schema.d.ts +2 -40
  120. package/.dist/server/transport.d.ts +2 -0
  121. package/.dist/server/types.d.ts +88 -71
  122. package/.dist/server/wrappers.d.ts +4 -41
  123. package/.dist/server.d.ts +2 -2
  124. package/.dist/server.js +255 -279
  125. package/.dist/server.js.map +1 -1
  126. package/.dist/yieldable.d.ts +7 -0
  127. package/README.md +1 -1
  128. package/package.json +5 -5
  129. package/.dist/chunks/client-CsVu54pU.js +0 -627
  130. package/.dist/chunks/client-CsVu54pU.js.map +0 -1
  131. package/.dist/chunks/descriptors-cOe9uRJz.js +0 -36
  132. package/.dist/chunks/descriptors-cOe9uRJz.js.map +0 -1
  133. package/.dist/chunks/dispatcher-LtvFKYUp.js +0 -47
  134. package/.dist/chunks/dispatcher-LtvFKYUp.js.map +0 -1
  135. package/.dist/chunks/dispatcher-pHH4JcFR.js.map +0 -1
  136. package/.dist/chunks/errors-Dcf0MVbq.js.map +0 -1
  137. package/.dist/chunks/event-attributes-gHzP2ycp.js +0 -39
  138. package/.dist/chunks/event-attributes-gHzP2ycp.js.map +0 -1
  139. package/.dist/chunks/remote-client-Bj1pZXgq.js.map +0 -1
  140. package/.dist/chunks/runtime-ekkMQ-wL.js.map +0 -1
  141. package/.dist/chunks/transform-CtQDGS9c.js.map +0 -1
  142. package/.dist/chunks/vite-WGlbSnso.js +0 -486
  143. package/.dist/chunks/vite-WGlbSnso.js.map +0 -1
  144. package/.dist/remote/client/effect.d.ts +0 -29
  145. package/.dist/remote/client/failures.d.ts +0 -42
  146. package/.dist/remote/server.js.map +0 -1
  147. package/.dist/vite/remote-client.d.ts +0 -24
@@ -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
  /**
@@ -65,43 +50,6 @@ var PreprocessError = class extends RuntimeError {
65
50
  }
66
51
  };
67
52
  /**
68
- * Retained for compatibility when callers need a structured representation of
69
- * possible Vite plugin ordering conflicts.
70
- *
71
- * @example
72
- * ```ts
73
- * throw new VitePreTransformPluginConflictError(["wuchale"]);
74
- * ```
75
- *
76
- * @since 2.4.0
77
- * @param plugin_names - Names of Vite plugins that declare pre-transform
78
- * priority and may parse raw component files before SER lowers them.
79
- * @returns A runtime-authored Error describing the possible plugin ordering
80
- * conflict.
81
- */
82
- var VitePreTransformPluginConflictError = class extends RuntimeError {
83
- /**
84
- * Names of conflicting Vite plugins.
85
- *
86
- * @since 2.4.0
87
- */
88
- plugin_names;
89
- constructor(plugin_names) {
90
- super([
91
- `Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,
92
- "",
93
- `These plugins run before normal Svelte component transforms:`,
94
- ...plugin_names.map((plugin_name) => ` - ${plugin_name}`),
95
- "",
96
- `This is usually fine, but if you see Svelte parser errors around <script effect>`,
97
- `or yield* in components, one of those plugins may be reading component files before`,
98
- `SER has lowered its syntax.`
99
- ].join("\n"));
100
- this.name = "VitePreTransformPluginConflictError";
101
- this.plugin_names = plugin_names;
102
- }
103
- };
104
- /**
105
53
  * Thrown when a statement mixes JavaScript `await` with Effect `yield*` work
106
54
  * that must be lowered into an `Effect.gen` program.
107
55
  *
@@ -114,7 +62,6 @@ var VitePreTransformPluginConflictError = class extends RuntimeError {
114
62
  * @param filename - Source filename containing the unsupported statement.
115
63
  * @param statement_text - Full source text for the statement containing
116
64
  * mixed async work.
117
- * @returns A preprocessor Error instance with statement context.
118
65
  */
119
66
  var AwaitInEffectWorkError = class extends PreprocessError {
120
67
  /**
@@ -149,7 +96,6 @@ var AwaitInEffectWorkError = class extends PreprocessError {
149
96
  * Effect work.
150
97
  * @param expression_text - Full source text for the rune expression.
151
98
  * @param filename - Source filename containing the unsupported rune.
152
- * @returns A preprocessor Error instance with rune source context.
153
99
  */
154
100
  var AsyncEffectInSyncRuneError = class extends PreprocessError {
155
101
  /**
@@ -193,7 +139,6 @@ var AsyncEffectInSyncRuneError = class extends PreprocessError {
193
139
  * @param filename - Source filename containing the invalid event handler.
194
140
  * @param expression_text - Event handler expression that contains the nested
195
141
  * unsupported async Effect work.
196
- * @returns A preprocessor Error instance with event expression context.
197
142
  */
198
143
  var AsyncEffectInEventCallbackError = class extends PreprocessError {
199
144
  /**
@@ -235,7 +180,6 @@ var AsyncEffectInEventCallbackError = class extends PreprocessError {
235
180
  * invalid event handler callback was found.
236
181
  * @param expression_text - Original event handler callback text that contained
237
182
  * `yield*` and should be rewritten as a direct event Effect expression.
238
- * @returns A preprocessor Error instance with event callback context.
239
183
  */
240
184
  var YieldStarInEventCallbackError = class extends PreprocessError {
241
185
  /**
@@ -277,7 +221,6 @@ var YieldStarInEventCallbackError = class extends PreprocessError {
277
221
  * @since 2.4.2
278
222
  * @param filename - Source filename containing the unsupported markup.
279
223
  * @param expression_text - The unsupported markup expression text.
280
- * @returns A preprocessor Error instance with markup source context.
281
224
  */
282
225
  var UnsupportedMarkupEffectPositionError = class extends PreprocessError {
283
226
  /**
@@ -308,7 +251,6 @@ var UnsupportedMarkupEffectPositionError = class extends PreprocessError {
308
251
  * ```
309
252
  *
310
253
  * @since 2.4.0
311
- * @returns An Error describing missing request context.
312
254
  */
313
255
  var RequestEventUnavailableError = class extends RuntimeError {
314
256
  constructor() {
@@ -325,7 +267,6 @@ var RequestEventUnavailableError = class extends RuntimeError {
325
267
  * ```
326
268
  *
327
269
  * @since 2.4.0
328
- * @returns An Error describing the invalid Query overload usage.
329
270
  */
330
271
  var UncheckedQueryHandlerMissingError = class extends RuntimeError {
331
272
  constructor() {
@@ -342,7 +283,6 @@ var UncheckedQueryHandlerMissingError = class extends RuntimeError {
342
283
  * ```
343
284
  *
344
285
  * @since 2.4.0
345
- * @returns An Error describing the invalid batch Query overload usage.
346
286
  */
347
287
  var BatchQueryHandlerMissingError = class extends RuntimeError {
348
288
  constructor() {
@@ -359,7 +299,6 @@ var BatchQueryHandlerMissingError = class extends RuntimeError {
359
299
  * ```
360
300
  *
361
301
  * @since 2.4.0
362
- * @returns An Error describing the invalid live Query overload usage.
363
302
  */
364
303
  var UncheckedLiveQueryHandlerMissingError = class extends RuntimeError {
365
304
  constructor() {
@@ -376,7 +315,6 @@ var UncheckedLiveQueryHandlerMissingError = class extends RuntimeError {
376
315
  * ```
377
316
  *
378
317
  * @since 2.4.0
379
- * @returns An Error describing the invalid Command overload usage.
380
318
  */
381
319
  var UncheckedCommandHandlerMissingError = class extends RuntimeError {
382
320
  constructor() {
@@ -393,7 +331,6 @@ var UncheckedCommandHandlerMissingError = class extends RuntimeError {
393
331
  * ```
394
332
  *
395
333
  * @since 2.4.0
396
- * @returns An Error describing the invalid Form overload usage.
397
334
  */
398
335
  var UncheckedFormHandlerMissingError = class extends RuntimeError {
399
336
  constructor() {
@@ -410,7 +347,6 @@ var UncheckedFormHandlerMissingError = class extends RuntimeError {
410
347
  * ```
411
348
  *
412
349
  * @since 2.4.0
413
- * @returns An Error describing the invalid Prerender overload usage.
414
350
  */
415
351
  var UncheckedPrerenderHandlerMissingError = class extends RuntimeError {
416
352
  constructor() {
@@ -427,15 +363,57 @@ var UncheckedPrerenderHandlerMissingError = class extends RuntimeError {
427
363
  * ```
428
364
  *
429
365
  * @since 2.4.0
430
- * @returns An Error describing the expected live query return protocol.
431
366
  */
432
367
  var InvalidLiveQueryReturnError = class extends RuntimeError {
433
368
  constructor() {
434
- super("Query.live handler must return an Effect Stream, Iterable, or AsyncIterable; resolved values must expose a streaming protocol that SER can bridge to SvelteKit.");
369
+ super("Query.live handler must return an Effect Stream. Wrap native iterables with Stream.fromIterable, Stream.fromAsyncIterable, or another Stream constructor before returning them.");
435
370
  this.name = "InvalidLiveQueryReturnError";
436
371
  }
437
372
  };
438
373
  /**
374
+ * Thrown when generated component code yields a Stream that completes before
375
+ * producing a value.
376
+ *
377
+ * @example
378
+ * ```ts
379
+ * throw new EmptyStreamYieldError();
380
+ * ```
381
+ *
382
+ * @since 3.4.8
383
+ */
384
+ var EmptyStreamYieldError = class extends RuntimeError {
385
+ constructor() {
386
+ super("Cannot resolve yield* stream expression because the Stream completed without emitting a value.");
387
+ this.name = "EmptyStreamYieldError";
388
+ }
389
+ };
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
+ /**
439
417
  * Thrown when a dispatcher operation is requested after disposal.
440
418
  *
441
419
  * @example
@@ -444,7 +422,6 @@ var InvalidLiveQueryReturnError = class extends RuntimeError {
444
422
  * ```
445
423
  *
446
424
  * @since 2.4.0
447
- * @returns An Error describing an invalid dispatcher lifecycle transition.
448
425
  */
449
426
  var DispatcherDisposedError = class extends RuntimeError {
450
427
  constructor() {
@@ -463,7 +440,6 @@ var DispatcherDisposedError = class extends RuntimeError {
463
440
  *
464
441
  * @since 3.4.0
465
442
  * @param runtime_name - Public runtime API that was initialized more than once.
466
- * @returns An Error describing the invalid runtime lifecycle transition.
467
443
  */
468
444
  var RuntimeAlreadyInitializedError = class extends RuntimeError {
469
445
  constructor(runtime_name) {
@@ -480,7 +456,6 @@ var RuntimeAlreadyInitializedError = class extends RuntimeError {
480
456
  * ```
481
457
  *
482
458
  * @since 2.4.0
483
- * @returns An Error describing an invalid query adapter input.
484
459
  */
485
460
  var InvalidQueryFactoryError = class extends RuntimeError {
486
461
  constructor() {
@@ -489,6 +464,17 @@ var InvalidQueryFactoryError = class extends RuntimeError {
489
464
  }
490
465
  };
491
466
  /**
467
+ * Thrown when a generated or native remote prerender export is not callable.
468
+ *
469
+ * @since 4.0.0
470
+ */
471
+ var InvalidPrerenderFactoryError = class extends RuntimeError {
472
+ constructor() {
473
+ super("Invalid prerender factory: expected a function from SvelteKit remote prerender generation.");
474
+ this.name = "InvalidPrerenderFactoryError";
475
+ }
476
+ };
477
+ /**
492
478
  * Thrown when a generated or native remote live query export is not callable.
493
479
  *
494
480
  * @example
@@ -497,7 +483,6 @@ var InvalidQueryFactoryError = class extends RuntimeError {
497
483
  * ```
498
484
  *
499
485
  * @since 2.4.0
500
- * @returns An Error describing an invalid live query adapter input.
501
486
  */
502
487
  var InvalidLiveQueryFactoryError = class extends RuntimeError {
503
488
  constructor() {
@@ -514,7 +499,6 @@ var InvalidLiveQueryFactoryError = class extends RuntimeError {
514
499
  * ```
515
500
  *
516
501
  * @since 2.4.0
517
- * @returns An Error describing an invalid command adapter input.
518
502
  */
519
503
  var InvalidCommandFactoryError = class extends RuntimeError {
520
504
  constructor() {
@@ -531,7 +515,6 @@ var InvalidCommandFactoryError = class extends RuntimeError {
531
515
  * ```
532
516
  *
533
517
  * @since 2.4.0
534
- * @returns An Error describing missing form transport metadata.
535
518
  */
536
519
  var RemoteFormEndpointMissingError = class extends RuntimeError {
537
520
  constructor() {
@@ -550,7 +533,6 @@ var RemoteFormEndpointMissingError = class extends RuntimeError {
550
533
  *
551
534
  * @since 2.4.0
552
535
  * @param envelope - Raw response envelope returned by the remote form endpoint.
553
- * @returns An Error describing malformed form response data.
554
536
  */
555
537
  var InvalidRemoteFormResponseError = class extends RuntimeError {
556
538
  /**
@@ -576,7 +558,6 @@ var InvalidRemoteFormResponseError = class extends RuntimeError {
576
558
  *
577
559
  * @since 2.4.0
578
560
  * @param envelope - Raw response envelope returned by the remote form endpoint.
579
- * @returns An Error describing unsupported form response data.
580
561
  */
581
562
  var UnsupportedRemoteFormResponseError = class extends RuntimeError {
582
563
  /**
@@ -601,7 +582,6 @@ var UnsupportedRemoteFormResponseError = class extends RuntimeError {
601
582
  *
602
583
  * @since 2.4.0
603
584
  * @param raw - Raw serialized remote failure payload that failed decoding.
604
- * @returns An Error describing a malformed remote failure payload.
605
585
  */
606
586
  var RemoteErrorDecodeError = class extends RuntimeError {
607
587
  /**
@@ -626,7 +606,6 @@ var RemoteErrorDecodeError = class extends RuntimeError {
626
606
  *
627
607
  * @since 2.4.0
628
608
  * @param export_name - Name of the server-only root export that was invoked.
629
- * @returns An Error describing a missing server rewrite.
630
609
  */
631
610
  var ServerOnlyImportError = class extends RuntimeError {
632
611
  /**
@@ -651,7 +630,6 @@ var ServerOnlyImportError = class extends RuntimeError {
651
630
  *
652
631
  * @since 2.4.0
653
632
  * @param export_name - Name of the `$app/server` export that was invoked.
654
- * @returns An Error describing an unavailable SvelteKit virtual module export.
655
633
  */
656
634
  var SvelteKitServerExportUnavailableError = class extends RuntimeError {
657
635
  /**
@@ -677,7 +655,6 @@ var SvelteKitServerExportUnavailableError = class extends RuntimeError {
677
655
  *
678
656
  * @since 2.4.0
679
657
  * @param helper_name - SER helper name that triggered the context failure.
680
- * @returns An Error describing the required `.remote.ts` placement.
681
658
  */
682
659
  var RemoteHelperContextError = class extends RuntimeError {
683
660
  /**
@@ -702,7 +679,6 @@ var RemoteHelperContextError = class extends RuntimeError {
702
679
  *
703
680
  * @since 2.4.0
704
681
  * @param value - Non-Error value thrown while creating a remote helper.
705
- * @returns An Error preserving the remote helper failure value.
706
682
  */
707
683
  var RemoteHelperError = class extends RuntimeError {
708
684
  /**
@@ -717,32 +693,7 @@ var RemoteHelperError = class extends RuntimeError {
717
693
  this.value = value;
718
694
  }
719
695
  };
720
- /**
721
- * Thrown when a non-Error value must be normalized into an Error instance.
722
- *
723
- * @example
724
- * ```ts
725
- * throw new UnknownRuntimeError("raw failure");
726
- * ```
727
- *
728
- * @since 2.4.0
729
- * @param value - Non-Error value that needs Error normalization.
730
- * @returns An Error preserving the string representation of an unknown value.
731
- */
732
- var UnknownRuntimeError = class extends RuntimeError {
733
- /**
734
- * Non-Error value that was normalized.
735
- *
736
- * @since 2.4.0
737
- */
738
- value;
739
- constructor(value) {
740
- super(String(value));
741
- this.name = "UnknownRuntimeError";
742
- this.value = value;
743
- }
744
- };
745
696
  //#endregion
746
- export { YieldStarInEventCallbackError as A, UncheckedLiveQueryHandlerMissingError as C, UnsupportedMarkupEffectPositionError as D, UnknownRuntimeError as E, UnsupportedRemoteFormResponseError as O, UncheckedFormHandlerMissingError as S, UncheckedQueryHandlerMissingError as T, RuntimeAlreadyInitializedError as _, DispatcherDisposedError as a, SvelteKitServerExportUnavailableError as b, InvalidLiveQueryReturnError as c, PreprocessError as d, RemoteErrorDecodeError as f, RequestEventUnavailableError as g, RemoteHelperError as h, BatchQueryHandlerMissingError as i, VitePreTransformPluginConflictError as k, InvalidQueryFactoryError as l, RemoteHelperContextError as m, AsyncEffectInSyncRuneError as n, InvalidCommandFactoryError as o, RemoteFormEndpointMissingError as p, AwaitInEffectWorkError as r, InvalidLiveQueryFactoryError as s, AsyncEffectInEventCallbackError as t, InvalidRemoteFormResponseError as u, RuntimeError as v, UncheckedPrerenderHandlerMissingError as w, UncheckedCommandHandlerMissingError as x, ServerOnlyImportError as y };
697
+ export { UnsupportedRemoteFormResponseError as A, SvelteKitServerExportUnavailableError as C, UncheckedPrerenderHandlerMissingError as D, UncheckedLiveQueryHandlerMissingError as E, UncheckedQueryHandlerMissingError as O, ServerOnlyImportError as S, UncheckedFormHandlerMissingError 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, YieldStarInEventCallbackError as j, UnsupportedMarkupEffectPositionError 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, UncheckedCommandHandlerMissingError as w, RuntimeError as x, RequestEventUnavailableError as y };
747
698
 
748
- //# sourceMappingURL=errors-Dcf0MVbq.js.map
699
+ //# sourceMappingURL=errors-CLsbGjIa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-CLsbGjIa.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 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;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AAY,oKAChB;EACA,KAAK,OAAO;EACZ,KAAK,cAAc;CACpB;AACD;;;;;;;;;;;;AAaA,IAAa,wCAAb,cAA2D,aAAa;;;;;;CAMvE;CAEA,YAAY,aAAqB;EAChC,MACC,wCAAwC,YAAY,qDACrD;EACA,KAAK,OAAO;EACZ,KAAK,cAAc;CACpB;AACD;;;;;;;;;;;;;AAcA,IAAa,2BAAb,cAA8C,aAAa;;;;;;CAM1D;CAEA,YAAY,aAAqB;EAChC,MACC,mBACC,yBACA,GAAG,YAAY,iKAChB,CACD;EACA,KAAK,OAAO;EACZ,KAAK,cAAc;CACpB;AACD;;;;;;;;;;;;AAaA,IAAa,oBAAb,cAAuC,aAAa;;;;;;CAMnD;CAEA,YAAY,OAAgB;EAC3B,MAAM,mBAAmB,uBAAuB,OAAO,KAAK,CAAC,CAAC;EAC9D,KAAK,OAAO;EACZ,KAAK,QAAQ;CACd;AACD"}
@@ -0,0 +1,146 @@
1
+ import { c as InvalidLiveQueryFactoryError } from "./errors-CLsbGjIa.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-BundLSoY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-BundLSoY.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,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,QAAQ,gBACX,OAAO;CAGR,OAAO,eAAe,SAAS,eAAe;EAC7C,cAAc;EACd,OAAO;CACR,CAAC;CAED,OAAO,eAAe,SAAS,oBAAoB;EAClD,cAAc;EACd,OAAO;CACR,CAAC;CAED,qCAAqC,SAAoC,QAAQ;CAEjF,OAAO;AACR;AAEA,SAAS,qCACR,QACA,UACO;CACP,MAAM,OAAO,OAAO,KAAK,KAAK,MAAM;CAEpC,OAAO,eAAe,QAAQ,QAAQ;EACrC,cAAc;EACd,QAAQ,GAAG,SAA6B;GACvC,MAAM,SAAS,KAAK,GAAG,IAAI;GAE3B,IAAI,CAAC,OAAO,SAAS,MAAM,KAAK,KAAK,KAAK,gBAAgB,GACzD,OAAO;GAGR,OAAO,qBAAqB,QAAQ,QAAQ;EAC7C;CACD,CAAC;AACF;AAEA,SAAS,iBAAiB,OAAyB;CAClD,OACC,OAAO,UAAU,cAChB,MAA8C,mBAAmB;AAEpE;AAMA,SAAS,kBACR,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"}