@effect-app/vue 2.75.2 → 2.75.3
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.
- package/CHANGELOG.md +6 -0
- package/dist/experimental/commander.d.ts +51 -49
- package/dist/experimental/commander.d.ts.map +1 -1
- package/dist/experimental/commander.js +9 -5
- package/dist/experimental/makeUseCommand.d.ts +13 -15
- package/dist/experimental/makeUseCommand.d.ts.map +1 -1
- package/dist/makeClient.d.ts +34 -38
- package/dist/makeClient.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/experimental/commander.ts +428 -261
- package/test/dist/stubs.d.ts +13 -15
- package/test/dist/stubs.d.ts.map +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { asResult, reportRuntimeError } from "@effect-app/vue"
|
|
3
3
|
import { reportMessage } from "@effect-app/vue/errorReporter"
|
|
4
4
|
import { type Result } from "@effect-atom/atom/Result"
|
|
5
|
-
import { Cause, Effect, type Exit, flow, Match, Option, Runtime, S } from "effect-app"
|
|
5
|
+
import { Cause, Context, Effect, type Exit, flow, Match, Option, Runtime, S } from "effect-app"
|
|
6
6
|
import { SupportedErrors } from "effect-app/client"
|
|
7
7
|
import { OperationFailure, OperationSuccess } from "effect-app/Operations"
|
|
8
8
|
import { wrapEffect } from "effect-app/utils"
|
|
@@ -16,10 +16,10 @@ import { I18n } from "./intl.js"
|
|
|
16
16
|
import { WithToast } from "./withToast.js"
|
|
17
17
|
|
|
18
18
|
type IntlRecord = Record<string, PrimitiveType | FormatXMLElementFn<string, string>>
|
|
19
|
-
type FnOptions<I18nCustomKey extends string> = {
|
|
19
|
+
type FnOptions<I18nCustomKey extends string, State extends IntlRecord> = {
|
|
20
20
|
i18nCustomKey?: I18nCustomKey
|
|
21
21
|
/** passed to the i18n formatMessage calls so you can use it in translation messages */
|
|
22
|
-
i18nValues?: ComputedRef<
|
|
22
|
+
i18nValues?: ComputedRef<State> | (() => State)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
type FnOptionsInternal<I18nCustomKey extends string> = {
|
|
@@ -132,7 +132,11 @@ export declare namespace Commander {
|
|
|
132
132
|
>
|
|
133
133
|
|
|
134
134
|
export type Gen<RT, Id extends string, I18nKey extends string> = {
|
|
135
|
-
<
|
|
135
|
+
<
|
|
136
|
+
Eff extends YieldWrap<Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>>,
|
|
137
|
+
AEff,
|
|
138
|
+
Args extends Array<unknown>
|
|
139
|
+
>(
|
|
136
140
|
body: (...args: Args) => Generator<Eff, AEff, never>
|
|
137
141
|
): CommandOut<
|
|
138
142
|
Args,
|
|
@@ -150,7 +154,7 @@ export declare namespace Commander {
|
|
|
150
154
|
Eff extends YieldWrap<Effect.Effect<any, any, any>>,
|
|
151
155
|
AEff,
|
|
152
156
|
Args extends Array<unknown>,
|
|
153
|
-
A extends Effect.Effect<any, any, RT | CommandContext
|
|
157
|
+
A extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
154
158
|
>(
|
|
155
159
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
156
160
|
a: (
|
|
@@ -171,7 +175,7 @@ export declare namespace Commander {
|
|
|
171
175
|
AEff,
|
|
172
176
|
Args extends Array<unknown>,
|
|
173
177
|
A,
|
|
174
|
-
B extends Effect.Effect<any, any, RT | CommandContext
|
|
178
|
+
B extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
175
179
|
>(
|
|
176
180
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
177
181
|
a: (
|
|
@@ -194,7 +198,7 @@ export declare namespace Commander {
|
|
|
194
198
|
Args extends Array<unknown>,
|
|
195
199
|
A,
|
|
196
200
|
B,
|
|
197
|
-
C extends Effect.Effect<any, any, RT | CommandContext
|
|
201
|
+
C extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
198
202
|
>(
|
|
199
203
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
200
204
|
a: (
|
|
@@ -219,7 +223,7 @@ export declare namespace Commander {
|
|
|
219
223
|
A,
|
|
220
224
|
B,
|
|
221
225
|
C,
|
|
222
|
-
D extends Effect.Effect<any, any, RT | CommandContext
|
|
226
|
+
D extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
223
227
|
>(
|
|
224
228
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
225
229
|
a: (
|
|
@@ -246,7 +250,7 @@ export declare namespace Commander {
|
|
|
246
250
|
B,
|
|
247
251
|
C,
|
|
248
252
|
D,
|
|
249
|
-
E extends Effect.Effect<any, any, RT | CommandContext
|
|
253
|
+
E extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
250
254
|
>(
|
|
251
255
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
252
256
|
a: (
|
|
@@ -275,7 +279,7 @@ export declare namespace Commander {
|
|
|
275
279
|
C,
|
|
276
280
|
D,
|
|
277
281
|
E,
|
|
278
|
-
F extends Effect.Effect<any, any, RT | CommandContext
|
|
282
|
+
F extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
279
283
|
>(
|
|
280
284
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
281
285
|
a: (
|
|
@@ -306,7 +310,7 @@ export declare namespace Commander {
|
|
|
306
310
|
D,
|
|
307
311
|
E,
|
|
308
312
|
F,
|
|
309
|
-
G extends Effect.Effect<any, any, RT | CommandContext
|
|
313
|
+
G extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
310
314
|
>(
|
|
311
315
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
312
316
|
a: (
|
|
@@ -339,7 +343,7 @@ export declare namespace Commander {
|
|
|
339
343
|
E,
|
|
340
344
|
F,
|
|
341
345
|
G,
|
|
342
|
-
H extends Effect.Effect<any, any, RT | CommandContext
|
|
346
|
+
H extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
343
347
|
>(
|
|
344
348
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
345
349
|
a: (
|
|
@@ -374,7 +378,7 @@ export declare namespace Commander {
|
|
|
374
378
|
F,
|
|
375
379
|
G,
|
|
376
380
|
H,
|
|
377
|
-
I extends Effect.Effect<any, any, RT | CommandContext
|
|
381
|
+
I extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
378
382
|
>(
|
|
379
383
|
body: (...args: Args) => Generator<Eff, AEff, never>,
|
|
380
384
|
a: (
|
|
@@ -401,32 +405,65 @@ export declare namespace Commander {
|
|
|
401
405
|
}
|
|
402
406
|
|
|
403
407
|
export type NonGen<RT, Id extends string, I18nKey extends string> = {
|
|
404
|
-
<
|
|
408
|
+
<
|
|
409
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
410
|
+
Args extends Array<unknown>
|
|
411
|
+
>(
|
|
405
412
|
body: (...args: Args) => Eff
|
|
406
413
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
407
|
-
<
|
|
414
|
+
<
|
|
415
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
416
|
+
A,
|
|
417
|
+
Args extends Array<unknown>
|
|
418
|
+
>(
|
|
408
419
|
body: (...args: Args) => A,
|
|
409
420
|
a: (_: A, ...args: NoInfer<Args>) => Eff
|
|
410
421
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
411
|
-
<
|
|
422
|
+
<
|
|
423
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
424
|
+
A,
|
|
425
|
+
B,
|
|
426
|
+
Args extends Array<unknown>
|
|
427
|
+
>(
|
|
412
428
|
body: (...args: Args) => A,
|
|
413
429
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
414
430
|
b: (_: B, ...args: NoInfer<Args>) => Eff
|
|
415
431
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
416
|
-
<
|
|
432
|
+
<
|
|
433
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
434
|
+
A,
|
|
435
|
+
B,
|
|
436
|
+
C,
|
|
437
|
+
Args extends Array<unknown>
|
|
438
|
+
>(
|
|
417
439
|
body: (...args: Args) => A,
|
|
418
440
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
419
441
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
420
442
|
c: (_: C, ...args: NoInfer<Args>) => Eff
|
|
421
443
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
422
|
-
<
|
|
444
|
+
<
|
|
445
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
446
|
+
A,
|
|
447
|
+
B,
|
|
448
|
+
C,
|
|
449
|
+
D,
|
|
450
|
+
Args extends Array<unknown>
|
|
451
|
+
>(
|
|
423
452
|
body: (...args: Args) => A,
|
|
424
453
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
425
454
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
426
455
|
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
427
456
|
d: (_: D, ...args: NoInfer<Args>) => Eff
|
|
428
457
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
429
|
-
<
|
|
458
|
+
<
|
|
459
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
460
|
+
A,
|
|
461
|
+
B,
|
|
462
|
+
C,
|
|
463
|
+
D,
|
|
464
|
+
E,
|
|
465
|
+
Args extends Array<unknown>
|
|
466
|
+
>(
|
|
430
467
|
body: (...args: Args) => A,
|
|
431
468
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
432
469
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
@@ -434,7 +471,16 @@ export declare namespace Commander {
|
|
|
434
471
|
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
435
472
|
e: (_: E, ...args: NoInfer<Args>) => Eff
|
|
436
473
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
437
|
-
<
|
|
474
|
+
<
|
|
475
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
476
|
+
A,
|
|
477
|
+
B,
|
|
478
|
+
C,
|
|
479
|
+
D,
|
|
480
|
+
E,
|
|
481
|
+
F,
|
|
482
|
+
Args extends Array<unknown>
|
|
483
|
+
>(
|
|
438
484
|
body: (...args: Args) => A,
|
|
439
485
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
440
486
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
@@ -443,7 +489,17 @@ export declare namespace Commander {
|
|
|
443
489
|
e: (_: E, ...args: NoInfer<Args>) => F,
|
|
444
490
|
f: (_: F, ...args: NoInfer<Args>) => Eff
|
|
445
491
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
446
|
-
<
|
|
492
|
+
<
|
|
493
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
494
|
+
A,
|
|
495
|
+
B,
|
|
496
|
+
C,
|
|
497
|
+
D,
|
|
498
|
+
E,
|
|
499
|
+
F,
|
|
500
|
+
G,
|
|
501
|
+
Args extends Array<unknown>
|
|
502
|
+
>(
|
|
447
503
|
body: (...args: Args) => A,
|
|
448
504
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
449
505
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
@@ -453,7 +509,18 @@ export declare namespace Commander {
|
|
|
453
509
|
f: (_: F, ...args: NoInfer<Args>) => G,
|
|
454
510
|
g: (_: G, ...args: NoInfer<Args>) => Eff
|
|
455
511
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
456
|
-
<
|
|
512
|
+
<
|
|
513
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
514
|
+
A,
|
|
515
|
+
B,
|
|
516
|
+
C,
|
|
517
|
+
D,
|
|
518
|
+
E,
|
|
519
|
+
F,
|
|
520
|
+
G,
|
|
521
|
+
H,
|
|
522
|
+
Args extends Array<unknown>
|
|
523
|
+
>(
|
|
457
524
|
body: (...args: Args) => A,
|
|
458
525
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
459
526
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
@@ -464,7 +531,19 @@ export declare namespace Commander {
|
|
|
464
531
|
g: (_: G, ...args: NoInfer<Args>) => H,
|
|
465
532
|
h: (_: H, ...args: NoInfer<Args>) => Eff
|
|
466
533
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
467
|
-
<
|
|
534
|
+
<
|
|
535
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
536
|
+
A,
|
|
537
|
+
B,
|
|
538
|
+
C,
|
|
539
|
+
D,
|
|
540
|
+
E,
|
|
541
|
+
F,
|
|
542
|
+
G,
|
|
543
|
+
H,
|
|
544
|
+
I,
|
|
545
|
+
Args extends Array<unknown>
|
|
546
|
+
>(
|
|
468
547
|
body: (...args: Args) => A,
|
|
469
548
|
a: (_: A, ...args: NoInfer<Args>) => B,
|
|
470
549
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
@@ -483,12 +562,12 @@ export declare namespace Commander {
|
|
|
483
562
|
Args,
|
|
484
563
|
AEff,
|
|
485
564
|
EEff,
|
|
486
|
-
REff, // TODO: only allowed to be RT | CommandContext
|
|
565
|
+
REff, // TODO: only allowed to be RT | CommandContext | `Commander.Command.${Id}.state`
|
|
487
566
|
Id,
|
|
488
567
|
I18nKey
|
|
489
568
|
>
|
|
490
569
|
<
|
|
491
|
-
A extends Effect.Effect<any, any, RT | CommandContext
|
|
570
|
+
A extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
492
571
|
>(
|
|
493
572
|
a: (
|
|
494
573
|
_: Effect.Effect<
|
|
@@ -501,7 +580,7 @@ export declare namespace Commander {
|
|
|
501
580
|
): CommandOutHelper<Args, A, Id, I18nKey>
|
|
502
581
|
<
|
|
503
582
|
A,
|
|
504
|
-
B extends Effect.Effect<any, any, RT | CommandContext
|
|
583
|
+
B extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
505
584
|
>(
|
|
506
585
|
a: (
|
|
507
586
|
_: Effect.Effect<
|
|
@@ -516,7 +595,7 @@ export declare namespace Commander {
|
|
|
516
595
|
<
|
|
517
596
|
A,
|
|
518
597
|
B,
|
|
519
|
-
C extends Effect.Effect<any, any, RT | CommandContext
|
|
598
|
+
C extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
520
599
|
>(
|
|
521
600
|
a: (
|
|
522
601
|
_: Effect.Effect<
|
|
@@ -533,7 +612,7 @@ export declare namespace Commander {
|
|
|
533
612
|
A,
|
|
534
613
|
B,
|
|
535
614
|
C,
|
|
536
|
-
D extends Effect.Effect<any, any, RT | CommandContext
|
|
615
|
+
D extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
537
616
|
>(
|
|
538
617
|
a: (
|
|
539
618
|
_: Effect.Effect<
|
|
@@ -552,7 +631,7 @@ export declare namespace Commander {
|
|
|
552
631
|
B,
|
|
553
632
|
C,
|
|
554
633
|
D,
|
|
555
|
-
E extends Effect.Effect<any, any, RT | CommandContext
|
|
634
|
+
E extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
556
635
|
>(
|
|
557
636
|
a: (
|
|
558
637
|
_: Effect.Effect<
|
|
@@ -573,7 +652,7 @@ export declare namespace Commander {
|
|
|
573
652
|
C,
|
|
574
653
|
D,
|
|
575
654
|
E,
|
|
576
|
-
F extends Effect.Effect<any, any, RT | CommandContext
|
|
655
|
+
F extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
577
656
|
>(
|
|
578
657
|
a: (
|
|
579
658
|
_: Effect.Effect<
|
|
@@ -596,7 +675,7 @@ export declare namespace Commander {
|
|
|
596
675
|
D,
|
|
597
676
|
E,
|
|
598
677
|
F,
|
|
599
|
-
G extends Effect.Effect<any, any, RT | CommandContext
|
|
678
|
+
G extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>
|
|
600
679
|
>(
|
|
601
680
|
a: (
|
|
602
681
|
_: Effect.Effect<
|
|
@@ -613,7 +692,7 @@ export declare namespace Commander {
|
|
|
613
692
|
f: (_: E, ...args: NoInfer<Args>) => F,
|
|
614
693
|
g: (_: F, ...args: NoInfer<Args>) => G
|
|
615
694
|
): CommandOutHelper<Args, G, Id, I18nKey>
|
|
616
|
-
<A, B, C, D, E, F, G, H extends Effect.Effect<any, any, RT | CommandContext
|
|
695
|
+
<A, B, C, D, E, F, G, H extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>>(
|
|
617
696
|
a: (
|
|
618
697
|
_: Effect.Effect<
|
|
619
698
|
AEff,
|
|
@@ -630,7 +709,7 @@ export declare namespace Commander {
|
|
|
630
709
|
g: (_: F, ...args: NoInfer<Args>) => G,
|
|
631
710
|
h: (_: G, ...args: NoInfer<Args>) => H
|
|
632
711
|
): CommandOutHelper<Args, H, Id, I18nKey>
|
|
633
|
-
<A, B, C, D, E, F, G, H, I extends Effect.Effect<any, any, RT | CommandContext
|
|
712
|
+
<A, B, C, D, E, F, G, H, I extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>>(
|
|
634
713
|
a: (
|
|
635
714
|
_: Effect.Effect<
|
|
636
715
|
AEff,
|
|
@@ -653,7 +732,10 @@ export declare namespace Commander {
|
|
|
653
732
|
export type NonGenWrap<RT, Id extends string, I18nKey extends string, Args extends Array<unknown>, AEff, EEff, REff> =
|
|
654
733
|
{
|
|
655
734
|
(): CommandOutHelper<Args, Effect.Effect<AEff, EEff, REff>, Id, I18nKey>
|
|
656
|
-
<
|
|
735
|
+
<
|
|
736
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
737
|
+
Args extends Array<unknown>
|
|
738
|
+
>(
|
|
657
739
|
a: (
|
|
658
740
|
_: Effect.Effect<
|
|
659
741
|
AEff,
|
|
@@ -663,7 +745,11 @@ export declare namespace Commander {
|
|
|
663
745
|
...args: NoInfer<Args>
|
|
664
746
|
) => Eff
|
|
665
747
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
666
|
-
<
|
|
748
|
+
<
|
|
749
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
750
|
+
B,
|
|
751
|
+
Args extends Array<unknown>
|
|
752
|
+
>(
|
|
667
753
|
a: (
|
|
668
754
|
_: Effect.Effect<
|
|
669
755
|
AEff,
|
|
@@ -674,7 +760,12 @@ export declare namespace Commander {
|
|
|
674
760
|
) => B,
|
|
675
761
|
b: (_: B, ...args: NoInfer<Args>) => Eff
|
|
676
762
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
677
|
-
<
|
|
763
|
+
<
|
|
764
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
765
|
+
B,
|
|
766
|
+
C,
|
|
767
|
+
Args extends Array<unknown>
|
|
768
|
+
>(
|
|
678
769
|
a: (
|
|
679
770
|
_: Effect.Effect<
|
|
680
771
|
AEff,
|
|
@@ -686,7 +777,13 @@ export declare namespace Commander {
|
|
|
686
777
|
b: (_: B, ...args: NoInfer<Args>) => C,
|
|
687
778
|
c: (_: C, ...args: NoInfer<Args>) => Eff
|
|
688
779
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
689
|
-
<
|
|
780
|
+
<
|
|
781
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
782
|
+
B,
|
|
783
|
+
C,
|
|
784
|
+
D,
|
|
785
|
+
Args extends Array<unknown>
|
|
786
|
+
>(
|
|
690
787
|
a: (
|
|
691
788
|
_: Effect.Effect<
|
|
692
789
|
AEff,
|
|
@@ -699,7 +796,14 @@ export declare namespace Commander {
|
|
|
699
796
|
c: (_: C, ...args: NoInfer<Args>) => D,
|
|
700
797
|
d: (_: D, ...args: NoInfer<Args>) => Eff
|
|
701
798
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
702
|
-
<
|
|
799
|
+
<
|
|
800
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
801
|
+
B,
|
|
802
|
+
C,
|
|
803
|
+
D,
|
|
804
|
+
E,
|
|
805
|
+
Args extends Array<unknown>
|
|
806
|
+
>(
|
|
703
807
|
a: (
|
|
704
808
|
_: Effect.Effect<
|
|
705
809
|
AEff,
|
|
@@ -713,7 +817,15 @@ export declare namespace Commander {
|
|
|
713
817
|
d: (_: D, ...args: NoInfer<Args>) => E,
|
|
714
818
|
e: (_: E, ...args: NoInfer<Args>) => Eff
|
|
715
819
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
716
|
-
<
|
|
820
|
+
<
|
|
821
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
822
|
+
B,
|
|
823
|
+
C,
|
|
824
|
+
D,
|
|
825
|
+
E,
|
|
826
|
+
F,
|
|
827
|
+
Args extends Array<unknown>
|
|
828
|
+
>(
|
|
717
829
|
a: (
|
|
718
830
|
_: Effect.Effect<
|
|
719
831
|
AEff,
|
|
@@ -728,7 +840,16 @@ export declare namespace Commander {
|
|
|
728
840
|
e: (_: E, ...args: NoInfer<Args>) => F,
|
|
729
841
|
f: (_: F, ...args: NoInfer<Args>) => Eff
|
|
730
842
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
731
|
-
<
|
|
843
|
+
<
|
|
844
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
845
|
+
B,
|
|
846
|
+
C,
|
|
847
|
+
D,
|
|
848
|
+
E,
|
|
849
|
+
F,
|
|
850
|
+
G,
|
|
851
|
+
Args extends Array<unknown>
|
|
852
|
+
>(
|
|
732
853
|
a: (
|
|
733
854
|
_: Effect.Effect<
|
|
734
855
|
AEff,
|
|
@@ -744,7 +865,17 @@ export declare namespace Commander {
|
|
|
744
865
|
f: (_: F, ...args: NoInfer<Args>) => G,
|
|
745
866
|
g: (_: G, ...args: NoInfer<Args>) => Eff
|
|
746
867
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
747
|
-
<
|
|
868
|
+
<
|
|
869
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
870
|
+
B,
|
|
871
|
+
C,
|
|
872
|
+
D,
|
|
873
|
+
E,
|
|
874
|
+
F,
|
|
875
|
+
G,
|
|
876
|
+
H,
|
|
877
|
+
Args extends Array<unknown>
|
|
878
|
+
>(
|
|
748
879
|
a: (
|
|
749
880
|
_: Effect.Effect<
|
|
750
881
|
AEff,
|
|
@@ -761,7 +892,18 @@ export declare namespace Commander {
|
|
|
761
892
|
g: (_: G, ...args: NoInfer<Args>) => H,
|
|
762
893
|
h: (_: H, ...args: NoInfer<Args>) => Eff
|
|
763
894
|
): CommandOutHelper<Args, Eff, Id, I18nKey>
|
|
764
|
-
<
|
|
895
|
+
<
|
|
896
|
+
Eff extends Effect.Effect<any, any, RT | CommandContext | `Commander.Command.${Id}.state`>,
|
|
897
|
+
B,
|
|
898
|
+
C,
|
|
899
|
+
D,
|
|
900
|
+
E,
|
|
901
|
+
F,
|
|
902
|
+
G,
|
|
903
|
+
H,
|
|
904
|
+
I,
|
|
905
|
+
Args extends Array<unknown>
|
|
906
|
+
>(
|
|
765
907
|
a: (
|
|
766
908
|
_: Effect.Effect<
|
|
767
909
|
AEff,
|
|
@@ -964,7 +1106,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
964
1106
|
return context
|
|
965
1107
|
}
|
|
966
1108
|
|
|
967
|
-
const getI18nValues = <const I18nKey extends string>(options?: FnOptions<I18nKey>) => {
|
|
1109
|
+
const getI18nValues = <const I18nKey extends string>(options?: FnOptions<I18nKey, any>) => {
|
|
968
1110
|
const i18nValues = !options?.i18nValues ? undefined : typeof options.i18nValues === "function"
|
|
969
1111
|
? computed(options.i18nValues)
|
|
970
1112
|
: options.i18nValues
|
|
@@ -973,260 +1115,270 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
973
1115
|
|
|
974
1116
|
const makeCommand = <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
975
1117
|
const runFork = Runtime.runFork(runtime)
|
|
976
|
-
return <const Id extends string, const I18nKey extends string = Id>(
|
|
1118
|
+
return <const Id extends string, State extends IntlRecord, const I18nKey extends string = Id>(
|
|
977
1119
|
id_: Id | { id: Id },
|
|
978
|
-
options?: FnOptions<I18nKey>,
|
|
1120
|
+
options?: FnOptions<I18nKey, State>,
|
|
979
1121
|
errorDef?: Error
|
|
980
1122
|
) => {
|
|
981
1123
|
const id = typeof id_ === "string" ? id_ : id_.id
|
|
982
1124
|
const i18nValues = getI18nValues(options)
|
|
983
1125
|
|
|
984
|
-
return Object.assign(
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
errorDef
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
const makeContext_ = () => makeContext(id, { ...options, i18nValues: i18nValues?.value })
|
|
997
|
-
const initialContext = makeContext_()
|
|
998
|
-
const action = computed(() => makeContext_().action)
|
|
999
|
-
|
|
1000
|
-
const errorReporter = <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
1001
|
-
self.pipe(
|
|
1002
|
-
Effect.tapErrorCause(
|
|
1003
|
-
Effect.fnUntraced(function*(cause) {
|
|
1004
|
-
if (Cause.isInterruptedOnly(cause)) {
|
|
1005
|
-
console.info(`Interrupted while trying to ${id}`)
|
|
1006
|
-
return
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
const fail = Cause.failureOption(cause)
|
|
1010
|
-
if (Option.isSome(fail)) {
|
|
1011
|
-
// if (fail.value._tag === "SuppressErrors") {
|
|
1012
|
-
// console.info(
|
|
1013
|
-
// `Suppressed error trying to ${action}`,
|
|
1014
|
-
// fail.value,
|
|
1015
|
-
// )
|
|
1016
|
-
// return
|
|
1017
|
-
// }
|
|
1018
|
-
const message = `Failure trying to ${id}`
|
|
1019
|
-
yield* reportMessage(message, {
|
|
1020
|
-
action: id,
|
|
1021
|
-
error: fail.value
|
|
1022
|
-
})
|
|
1023
|
-
return
|
|
1024
|
-
}
|
|
1126
|
+
return Object.assign(
|
|
1127
|
+
<Args extends ReadonlyArray<unknown>, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>(
|
|
1128
|
+
handler: (...args: Args) => Effect.Effect<A, E, R>
|
|
1129
|
+
) => {
|
|
1130
|
+
// we capture the definition stack here, so we can append it to later stack traces
|
|
1131
|
+
const limit = Error.stackTraceLimit
|
|
1132
|
+
Error.stackTraceLimit = 2
|
|
1133
|
+
const localErrorDef = new Error()
|
|
1134
|
+
Error.stackTraceLimit = limit
|
|
1135
|
+
if (!errorDef) {
|
|
1136
|
+
errorDef = localErrorDef
|
|
1137
|
+
}
|
|
1025
1138
|
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1139
|
+
const key = `Commander.Command.${id}.state` as const
|
|
1140
|
+
const state = Context.GenericTag<typeof key, State>(key)
|
|
1141
|
+
|
|
1142
|
+
const makeContext_ = () => makeContext(id, { ...options, i18nValues: i18nValues?.value })
|
|
1143
|
+
const initialContext = makeContext_()
|
|
1144
|
+
const action = computed(() => makeContext_().action)
|
|
1145
|
+
|
|
1146
|
+
const errorReporter = <A, E, R>(self: Effect.Effect<A, E, R>) =>
|
|
1147
|
+
self.pipe(
|
|
1148
|
+
Effect.tapErrorCause(
|
|
1149
|
+
Effect.fnUntraced(function*(cause) {
|
|
1150
|
+
if (Cause.isInterruptedOnly(cause)) {
|
|
1151
|
+
console.info(`Interrupted while trying to ${id}`)
|
|
1152
|
+
return
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
const fail = Cause.failureOption(cause)
|
|
1156
|
+
if (Option.isSome(fail)) {
|
|
1157
|
+
// if (fail.value._tag === "SuppressErrors") {
|
|
1158
|
+
// console.info(
|
|
1159
|
+
// `Suppressed error trying to ${action}`,
|
|
1160
|
+
// fail.value,
|
|
1161
|
+
// )
|
|
1162
|
+
// return
|
|
1163
|
+
// }
|
|
1164
|
+
const message = `Failure trying to ${id}`
|
|
1165
|
+
yield* reportMessage(message, {
|
|
1166
|
+
action: id,
|
|
1167
|
+
error: fail.value
|
|
1168
|
+
})
|
|
1169
|
+
return
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
const context = yield* CommandContext
|
|
1173
|
+
const extra = {
|
|
1174
|
+
action: context.action,
|
|
1175
|
+
message: `Unexpected Error trying to ${id}`
|
|
1176
|
+
}
|
|
1177
|
+
yield* reportRuntimeError(cause, extra)
|
|
1178
|
+
}, Effect.uninterruptible)
|
|
1179
|
+
)
|
|
1033
1180
|
)
|
|
1034
|
-
)
|
|
1035
1181
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1182
|
+
const theHandler = flow(
|
|
1183
|
+
handler,
|
|
1184
|
+
errorReporter,
|
|
1185
|
+
// all must be within the Effect.fn to fit within the Span
|
|
1186
|
+
Effect.provideServiceEffect(
|
|
1187
|
+
CommandContext,
|
|
1188
|
+
Effect.sync(() => makeContext_())
|
|
1189
|
+
),
|
|
1190
|
+
Effect.provideServiceEffect(
|
|
1191
|
+
state,
|
|
1192
|
+
Effect.sync(() => i18nValues?.value)
|
|
1193
|
+
), // todo; service make errors?
|
|
1194
|
+
(_) => Effect.annotateCurrentSpan({ action }).pipe(Effect.zipRight(_))
|
|
1195
|
+
)
|
|
1046
1196
|
|
|
1047
|
-
|
|
1197
|
+
const [result, exec] = asResult(theHandler)
|
|
1048
1198
|
|
|
1049
|
-
|
|
1199
|
+
const waiting = computed(() => result.value.waiting)
|
|
1050
1200
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1201
|
+
const handle = Object.assign((...args: Args) => {
|
|
1202
|
+
// we capture the call site stack here
|
|
1203
|
+
const limit = Error.stackTraceLimit
|
|
1204
|
+
Error.stackTraceLimit = 2
|
|
1205
|
+
const errorCall = new Error()
|
|
1206
|
+
Error.stackTraceLimit = limit
|
|
1057
1207
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1208
|
+
let cache: false | string = false
|
|
1209
|
+
const captureStackTrace = () => {
|
|
1210
|
+
// in case of an error, we want to append the definition stack to the call site stack,
|
|
1211
|
+
// so we can see where the handler was defined too
|
|
1062
1212
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
}
|
|
1066
|
-
if (errorCall.stack) {
|
|
1067
|
-
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
1068
|
-
const stackCall = errorCall.stack.trim().split("\n")
|
|
1069
|
-
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
1070
|
-
if (!endStackDef.includes(`(`)) {
|
|
1071
|
-
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
1213
|
+
if (cache !== false) {
|
|
1214
|
+
return cache
|
|
1072
1215
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1216
|
+
if (errorCall.stack) {
|
|
1217
|
+
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
1218
|
+
const stackCall = errorCall.stack.trim().split("\n")
|
|
1219
|
+
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
1220
|
+
if (!endStackDef.includes(`(`)) {
|
|
1221
|
+
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
1222
|
+
}
|
|
1223
|
+
let endStackCall = stackCall.slice(2).join("\n").trim()
|
|
1224
|
+
if (!endStackCall.includes(`(`)) {
|
|
1225
|
+
endStackCall = endStackCall.replace(/at (.*)/, "at ($1)")
|
|
1226
|
+
}
|
|
1227
|
+
cache = `${endStackDef}\n${endStackCall}`
|
|
1228
|
+
return cache
|
|
1076
1229
|
}
|
|
1077
|
-
cache = `${endStackDef}\n${endStackCall}`
|
|
1078
|
-
return cache
|
|
1079
1230
|
}
|
|
1080
|
-
}
|
|
1081
1231
|
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1232
|
+
const command = Effect.withSpan(
|
|
1233
|
+
exec(...args),
|
|
1234
|
+
id,
|
|
1235
|
+
{ captureStackTrace }
|
|
1236
|
+
)
|
|
1087
1237
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1238
|
+
return runFork(command)
|
|
1239
|
+
}, { action })
|
|
1090
1240
|
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1241
|
+
const handleEffect = Object.assign((...args: Args) => {
|
|
1242
|
+
// we capture the call site stack here
|
|
1243
|
+
const limit = Error.stackTraceLimit
|
|
1244
|
+
Error.stackTraceLimit = 2
|
|
1245
|
+
const errorCall = new Error()
|
|
1246
|
+
Error.stackTraceLimit = limit
|
|
1097
1247
|
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1248
|
+
let cache: false | string = false
|
|
1249
|
+
const captureStackTrace = () => {
|
|
1250
|
+
// in case of an error, we want to append the definition stack to the call site stack,
|
|
1251
|
+
// so we can see where the handler was defined too
|
|
1102
1252
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
}
|
|
1106
|
-
if (errorCall.stack) {
|
|
1107
|
-
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
1108
|
-
const stackCall = errorCall.stack.trim().split("\n")
|
|
1109
|
-
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
1110
|
-
if (!endStackDef.includes(`(`)) {
|
|
1111
|
-
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
1253
|
+
if (cache !== false) {
|
|
1254
|
+
return cache
|
|
1112
1255
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1256
|
+
if (errorCall.stack) {
|
|
1257
|
+
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
1258
|
+
const stackCall = errorCall.stack.trim().split("\n")
|
|
1259
|
+
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
1260
|
+
if (!endStackDef.includes(`(`)) {
|
|
1261
|
+
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
1262
|
+
}
|
|
1263
|
+
let endStackCall = stackCall.slice(2).join("\n").trim()
|
|
1264
|
+
if (!endStackCall.includes(`(`)) {
|
|
1265
|
+
endStackCall = endStackCall.replace(/at (.*)/, "at ($1)")
|
|
1266
|
+
}
|
|
1267
|
+
cache = `${endStackDef}\n${endStackCall}`
|
|
1268
|
+
return cache
|
|
1116
1269
|
}
|
|
1117
|
-
cache = `${endStackDef}\n${endStackCall}`
|
|
1118
|
-
return cache
|
|
1119
1270
|
}
|
|
1120
|
-
}
|
|
1121
1271
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1272
|
+
const command = Effect.withSpan(
|
|
1273
|
+
exec(...args),
|
|
1274
|
+
id,
|
|
1275
|
+
{ captureStackTrace }
|
|
1276
|
+
)
|
|
1127
1277
|
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1278
|
+
return Effect.currentSpan.pipe(
|
|
1279
|
+
Effect.option,
|
|
1280
|
+
Effect.map((span) =>
|
|
1281
|
+
runFork(Option.isSome(span) ? command.pipe(Effect.withParentSpan(span.value)) : command)
|
|
1282
|
+
)
|
|
1132
1283
|
)
|
|
1133
|
-
)
|
|
1134
|
-
}, { action })
|
|
1284
|
+
}, { action, state })
|
|
1135
1285
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1286
|
+
const compose = Object.assign((...args: Args) => {
|
|
1287
|
+
// we capture the call site stack here
|
|
1288
|
+
const limit = Error.stackTraceLimit
|
|
1289
|
+
Error.stackTraceLimit = 2
|
|
1290
|
+
const errorCall = new Error()
|
|
1291
|
+
Error.stackTraceLimit = limit
|
|
1142
1292
|
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1293
|
+
let cache: false | string = false
|
|
1294
|
+
const captureStackTrace = () => {
|
|
1295
|
+
// in case of an error, we want to append the definition stack to the call site stack,
|
|
1296
|
+
// so we can see where the handler was defined too
|
|
1147
1297
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1151
|
-
if (errorCall.stack) {
|
|
1152
|
-
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
1153
|
-
const stackCall = errorCall.stack.trim().split("\n")
|
|
1154
|
-
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
1155
|
-
if (!endStackDef.includes(`(`)) {
|
|
1156
|
-
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
1298
|
+
if (cache !== false) {
|
|
1299
|
+
return cache
|
|
1157
1300
|
}
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1301
|
+
if (errorCall.stack) {
|
|
1302
|
+
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
1303
|
+
const stackCall = errorCall.stack.trim().split("\n")
|
|
1304
|
+
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
1305
|
+
if (!endStackDef.includes(`(`)) {
|
|
1306
|
+
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
1307
|
+
}
|
|
1308
|
+
let endStackCall = stackCall.slice(2).join("\n").trim()
|
|
1309
|
+
if (!endStackCall.includes(`(`)) {
|
|
1310
|
+
endStackCall = endStackCall.replace(/at (.*)/, "at ($1)")
|
|
1311
|
+
}
|
|
1312
|
+
cache = `${endStackDef}\n${endStackCall}`
|
|
1313
|
+
return cache
|
|
1161
1314
|
}
|
|
1162
|
-
cache = `${endStackDef}\n${endStackCall}`
|
|
1163
|
-
return cache
|
|
1164
1315
|
}
|
|
1165
|
-
}
|
|
1166
1316
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1317
|
+
const command = Effect.withSpan(
|
|
1318
|
+
exec(...args),
|
|
1319
|
+
id,
|
|
1320
|
+
{ captureStackTrace }
|
|
1321
|
+
)
|
|
1172
1322
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1323
|
+
return command
|
|
1324
|
+
}, { action })
|
|
1175
1325
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1326
|
+
const compose2 = Object.assign((...args: Args) => {
|
|
1327
|
+
// we capture the call site stack here
|
|
1328
|
+
const limit = Error.stackTraceLimit
|
|
1329
|
+
Error.stackTraceLimit = 2
|
|
1330
|
+
const errorCall = new Error()
|
|
1331
|
+
Error.stackTraceLimit = limit
|
|
1182
1332
|
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1333
|
+
let cache: false | string = false
|
|
1334
|
+
const captureStackTrace = () => {
|
|
1335
|
+
// in case of an error, we want to append the definition stack to the call site stack,
|
|
1336
|
+
// so we can see where the handler was defined too
|
|
1187
1337
|
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
}
|
|
1191
|
-
if (errorCall.stack) {
|
|
1192
|
-
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
1193
|
-
const stackCall = errorCall.stack.trim().split("\n")
|
|
1194
|
-
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
1195
|
-
if (!endStackDef.includes(`(`)) {
|
|
1196
|
-
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
1338
|
+
if (cache !== false) {
|
|
1339
|
+
return cache
|
|
1197
1340
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1341
|
+
if (errorCall.stack) {
|
|
1342
|
+
const stackDef = errorDef!.stack!.trim().split("\n")
|
|
1343
|
+
const stackCall = errorCall.stack.trim().split("\n")
|
|
1344
|
+
let endStackDef = stackDef.slice(2).join("\n").trim()
|
|
1345
|
+
if (!endStackDef.includes(`(`)) {
|
|
1346
|
+
endStackDef = endStackDef.replace(/at (.*)/, "at ($1)")
|
|
1347
|
+
}
|
|
1348
|
+
let endStackCall = stackCall.slice(2).join("\n").trim()
|
|
1349
|
+
if (!endStackCall.includes(`(`)) {
|
|
1350
|
+
endStackCall = endStackCall.replace(/at (.*)/, "at ($1)")
|
|
1351
|
+
}
|
|
1352
|
+
cache = `${endStackDef}\n${endStackCall}`
|
|
1353
|
+
return cache
|
|
1201
1354
|
}
|
|
1202
|
-
cache = `${endStackDef}\n${endStackCall}`
|
|
1203
|
-
return cache
|
|
1204
1355
|
}
|
|
1205
|
-
}
|
|
1206
1356
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1357
|
+
const command = Effect.withSpan(
|
|
1358
|
+
exec(...args).pipe(Effect.flatten),
|
|
1359
|
+
id,
|
|
1360
|
+
{ captureStackTrace }
|
|
1361
|
+
)
|
|
1212
1362
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1363
|
+
return command
|
|
1364
|
+
}, { action })
|
|
1215
1365
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1366
|
+
return reactive({
|
|
1367
|
+
id,
|
|
1368
|
+
namespaced: initialContext.namespaced,
|
|
1369
|
+
namespace: initialContext.namespace,
|
|
1370
|
+
result,
|
|
1371
|
+
waiting,
|
|
1372
|
+
action,
|
|
1373
|
+
handle,
|
|
1374
|
+
handleEffect,
|
|
1375
|
+
compose,
|
|
1376
|
+
compose2,
|
|
1377
|
+
exec
|
|
1378
|
+
})
|
|
1379
|
+
},
|
|
1380
|
+
{ id }
|
|
1381
|
+
)
|
|
1230
1382
|
}
|
|
1231
1383
|
}
|
|
1232
1384
|
|
|
@@ -1303,10 +1455,12 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1303
1455
|
*/
|
|
1304
1456
|
fn: <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
1305
1457
|
const make = makeCommand(runtime)
|
|
1306
|
-
return <const Id extends string, const I18nKey extends string = Id>(
|
|
1458
|
+
return <const Id extends string, State extends IntlRecord, const I18nKey extends string = Id>(
|
|
1307
1459
|
id: Id | { id: Id },
|
|
1308
|
-
options?: FnOptions<I18nKey>
|
|
1309
|
-
): Commander.Gen<RT, Id, I18nKey> & Commander.NonGen<RT, Id, I18nKey>
|
|
1460
|
+
options?: FnOptions<I18nKey, State>
|
|
1461
|
+
): Commander.Gen<RT, Id, I18nKey> & Commander.NonGen<RT, Id, I18nKey> & {
|
|
1462
|
+
state: Context.Tag<`Commander.Command.${Id}.state`, State>
|
|
1463
|
+
} =>
|
|
1310
1464
|
Object.assign(
|
|
1311
1465
|
(
|
|
1312
1466
|
fn: any,
|
|
@@ -1328,13 +1482,18 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1328
1482
|
) as any
|
|
1329
1483
|
)
|
|
1330
1484
|
},
|
|
1331
|
-
makeContext(typeof id === "string" ? id : id.id, { ...options, i18nValues: getI18nValues(options)?.value })
|
|
1485
|
+
makeContext(typeof id === "string" ? id : id.id, { ...options, i18nValues: getI18nValues(options)?.value }),
|
|
1486
|
+
{
|
|
1487
|
+
state: Context.GenericTag<`Commander.Command.${Id}.state`, State>(
|
|
1488
|
+
`Commander.Command.${typeof id === "string" ? id : id.id}.state`
|
|
1489
|
+
)
|
|
1490
|
+
}
|
|
1332
1491
|
)
|
|
1333
1492
|
},
|
|
1334
1493
|
|
|
1335
1494
|
alt2: ((rt: any) => {
|
|
1336
1495
|
const cmd = makeCommand(rt)
|
|
1337
|
-
return (_id: any, options?: FnOptions<string>) => {
|
|
1496
|
+
return (_id: any, options?: FnOptions<string, IntlRecord>) => {
|
|
1338
1497
|
const isObject = typeof _id === "object" || typeof _id === "function"
|
|
1339
1498
|
const id = isObject ? _id.id : _id
|
|
1340
1499
|
const context = makeContext(id, { ...options, i18nValues: getI18nValues(options)?.value })
|
|
@@ -1375,7 +1534,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1375
1534
|
customI18nKey?: I18nKey
|
|
1376
1535
|
) =>
|
|
1377
1536
|
& Commander.CommandContextLocal<Id, I18nKey>
|
|
1378
|
-
& (<Args extends Array<unknown>, A, E, R extends RT | CommandContext
|
|
1537
|
+
& (<Args extends Array<unknown>, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>(
|
|
1379
1538
|
handler: (
|
|
1380
1539
|
ctx: Effect.fn.Gen & Effect.fn.NonGen & Commander.CommandContextLocal<Id, I18nKey> & {
|
|
1381
1540
|
// todo: only if we passed in one
|
|
@@ -1392,18 +1551,26 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
|
|
|
1392
1551
|
customI18nKey?: I18nKey
|
|
1393
1552
|
) =>
|
|
1394
1553
|
& Commander.CommandContextLocal<Id, I18nKey>
|
|
1395
|
-
& (<Args extends Array<unknown>, A, E, R extends RT | CommandContext
|
|
1554
|
+
& (<Args extends Array<unknown>, A, E, R extends RT | CommandContext | `Commander.Command.${Id}.state`>(
|
|
1396
1555
|
handler: (...args: Args) => Effect.Effect<A, E, R>
|
|
1397
1556
|
) => Commander.CommandOut<Args, A, E, R, Id, I18nKey>),
|
|
1398
1557
|
|
|
1399
1558
|
/** @experimental */
|
|
1400
1559
|
wrap: <RT>(runtime: Runtime.Runtime<RT>) => {
|
|
1401
1560
|
const make = makeCommand(runtime)
|
|
1402
|
-
return <
|
|
1561
|
+
return <
|
|
1562
|
+
const Id extends string,
|
|
1563
|
+
Args extends Array<unknown>,
|
|
1564
|
+
A,
|
|
1565
|
+
E,
|
|
1566
|
+
R,
|
|
1567
|
+
State extends IntlRecord,
|
|
1568
|
+
I18nKey extends string = Id
|
|
1569
|
+
>(
|
|
1403
1570
|
mutation:
|
|
1404
1571
|
| { mutate: (...args: Args) => Effect.Effect<A, E, R>; id: Id }
|
|
1405
1572
|
| ((...args: Args) => Effect.Effect<A, E, R>) & { id: Id },
|
|
1406
|
-
options?: FnOptions<I18nKey>
|
|
1573
|
+
options?: FnOptions<I18nKey, State>
|
|
1407
1574
|
):
|
|
1408
1575
|
& Commander.CommandContextLocal<Id, I18nKey>
|
|
1409
1576
|
& Commander.GenWrap<RT, Id, I18nKey, Args, A, E, R>
|