@effect-app/vue 2.62.1 → 2.63.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.
@@ -42,7 +42,7 @@ export const DefaultIntl = {
42
42
 
43
43
  export class CommandContext extends Effect.Tag("CommandContext")<
44
44
  CommandContext,
45
- { action: string; baseName: string; namespace: string; namespaced: (key: string) => string }
45
+ { id: string; action: string; namespace: string; namespaced: (key: string) => string }
46
46
  >() {}
47
47
 
48
48
  export type EmitWithCallback<A, Event extends string> = (event: Event, value: A, onDone: () => void) => void
@@ -68,14 +68,18 @@ export const wrapEmitSubmit = <A>(
68
68
  }
69
69
 
70
70
  export declare namespace Commander {
71
- export interface CommandProps<A, E, Name extends string> {
72
- name: Name
71
+ export interface CommandProps<A, E, Id extends string> {
72
+ id: Id
73
+ namespace: `action.${Id}`
74
+ namespaced: <K extends string>(k: K) => `action.${Id}.${K}`
73
75
  action: string
74
76
  result: Result<A, E>
75
77
  waiting: boolean
76
78
  }
77
79
 
78
- export interface CommandOut<Args extends Array<any>, A, E, R, Name extends string> extends CommandProps<A, E, Name> {
80
+ export interface CommandOut<Args extends Array<any>, A, E, R, Id extends string> extends CommandProps<A, E, Id> {
81
+ new(): {}
82
+
79
83
  /** click handlers */
80
84
  handle: (...args: Args) => RuntimeFiber<Exit.Exit<A, E>, never>
81
85
 
@@ -95,16 +99,16 @@ export declare namespace Commander {
95
99
  exec: (...args: Args) => Effect.Effect<Exit.Exit<A, E>, never, Exclude<R, CommandContext>>
96
100
  }
97
101
 
98
- type CommandOutHelper<Args extends Array<any>, Eff extends Effect.Effect<any, any, any>, Name extends string> =
102
+ type CommandOutHelper<Args extends Array<any>, Eff extends Effect.Effect<any, any, any>, Id extends string> =
99
103
  CommandOut<
100
104
  Args,
101
105
  Effect.Effect.Success<Eff>,
102
106
  Effect.Effect.Error<Eff>,
103
107
  Effect.Effect.Context<Eff>,
104
- Name
108
+ Id
105
109
  >
106
110
 
107
- export type Gen<RT, Name extends string> = {
111
+ export type Gen<RT, Id extends string> = {
108
112
  <Eff extends YieldWrap<Effect.Effect<any, any, RT | CommandContext>>, AEff, Args extends Array<any>>(
109
113
  body: (...args: Args) => Generator<Eff, AEff, never>
110
114
  ): CommandOut<
@@ -116,7 +120,7 @@ export declare namespace Commander {
116
120
  [Eff] extends [never] ? never
117
121
  : [Eff] extends [YieldWrap<Effect.Effect<infer _A, infer _E, infer R>>] ? R
118
122
  : never,
119
- Name
123
+ Id
120
124
  >
121
125
  <
122
126
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
@@ -137,7 +141,7 @@ export declare namespace Commander {
137
141
  >,
138
142
  ...args: NoInfer<Args>
139
143
  ) => A
140
- ): CommandOutHelper<Args, A, Name>
144
+ ): CommandOutHelper<Args, A, Id>
141
145
  <
142
146
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
143
147
  AEff,
@@ -159,7 +163,7 @@ export declare namespace Commander {
159
163
  ...args: NoInfer<Args>
160
164
  ) => A,
161
165
  b: (_: A, ...args: NoInfer<Args>) => B
162
- ): CommandOutHelper<Args, B, Name>
166
+ ): CommandOutHelper<Args, B, Id>
163
167
  <
164
168
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
165
169
  AEff,
@@ -183,7 +187,7 @@ export declare namespace Commander {
183
187
  ) => A,
184
188
  b: (_: A, ...args: NoInfer<Args>) => B,
185
189
  c: (_: B, ...args: NoInfer<Args>) => C
186
- ): CommandOutHelper<Args, C, Name>
190
+ ): CommandOutHelper<Args, C, Id>
187
191
  <
188
192
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
189
193
  AEff,
@@ -209,7 +213,7 @@ export declare namespace Commander {
209
213
  b: (_: A, ...args: NoInfer<Args>) => B,
210
214
  c: (_: B, ...args: NoInfer<Args>) => C,
211
215
  d: (_: C, ...args: NoInfer<Args>) => D
212
- ): CommandOutHelper<Args, D, Name>
216
+ ): CommandOutHelper<Args, D, Id>
213
217
  <
214
218
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
215
219
  AEff,
@@ -237,7 +241,7 @@ export declare namespace Commander {
237
241
  c: (_: B, ...args: NoInfer<Args>) => C,
238
242
  d: (_: C, ...args: NoInfer<Args>) => D,
239
243
  e: (_: D, ...args: NoInfer<Args>) => E
240
- ): CommandOutHelper<Args, E, Name>
244
+ ): CommandOutHelper<Args, E, Id>
241
245
  <
242
246
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
243
247
  AEff,
@@ -267,7 +271,7 @@ export declare namespace Commander {
267
271
  d: (_: C, ...args: NoInfer<Args>) => D,
268
272
  e: (_: D, ...args: NoInfer<Args>) => E,
269
273
  f: (_: E, ...args: NoInfer<Args>) => F
270
- ): CommandOutHelper<Args, F, Name>
274
+ ): CommandOutHelper<Args, F, Id>
271
275
  <
272
276
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
273
277
  AEff,
@@ -299,7 +303,7 @@ export declare namespace Commander {
299
303
  e: (_: D, ...args: NoInfer<Args>) => E,
300
304
  f: (_: E, ...args: NoInfer<Args>) => F,
301
305
  g: (_: F, ...args: NoInfer<Args>) => G
302
- ): CommandOutHelper<Args, G, Name>
306
+ ): CommandOutHelper<Args, G, Id>
303
307
  <
304
308
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
305
309
  AEff,
@@ -333,7 +337,7 @@ export declare namespace Commander {
333
337
  f: (_: E, ...args: NoInfer<Args>) => F,
334
338
  g: (_: F, ...args: NoInfer<Args>) => G,
335
339
  h: (_: G, ...args: NoInfer<Args>) => H
336
- ): CommandOutHelper<Args, H, Name>
340
+ ): CommandOutHelper<Args, H, Id>
337
341
  <
338
342
  Eff extends YieldWrap<Effect.Effect<any, any, any>>,
339
343
  AEff,
@@ -369,35 +373,35 @@ export declare namespace Commander {
369
373
  g: (_: F, ...args: NoInfer<Args>) => G,
370
374
  h: (_: G, ...args: NoInfer<Args>) => H,
371
375
  i: (_: H, ...args: NoInfer<Args>) => I
372
- ): CommandOutHelper<Args, I, Name>
376
+ ): CommandOutHelper<Args, I, Id>
373
377
  }
374
378
 
375
- export type NonGen<RT, Name extends string> = {
379
+ export type NonGen<RT, Id extends string> = {
376
380
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, Args extends Array<any>>(
377
381
  body: (...args: Args) => Eff
378
- ): CommandOutHelper<Args, Eff, Name>
382
+ ): CommandOutHelper<Args, Eff, Id>
379
383
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, Args extends Array<any>>(
380
384
  body: (...args: Args) => A,
381
385
  a: (_: A, ...args: NoInfer<Args>) => Eff
382
- ): CommandOutHelper<Args, Eff, Name>
386
+ ): CommandOutHelper<Args, Eff, Id>
383
387
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, Args extends Array<any>>(
384
388
  body: (...args: Args) => A,
385
389
  a: (_: A, ...args: NoInfer<Args>) => B,
386
390
  b: (_: B, ...args: NoInfer<Args>) => Eff
387
- ): CommandOutHelper<Args, Eff, Name>
391
+ ): CommandOutHelper<Args, Eff, Id>
388
392
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, Args extends Array<any>>(
389
393
  body: (...args: Args) => A,
390
394
  a: (_: A, ...args: NoInfer<Args>) => B,
391
395
  b: (_: B, ...args: NoInfer<Args>) => C,
392
396
  c: (_: C, ...args: NoInfer<Args>) => Eff
393
- ): CommandOutHelper<Args, Eff, Name>
397
+ ): CommandOutHelper<Args, Eff, Id>
394
398
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, Args extends Array<any>>(
395
399
  body: (...args: Args) => A,
396
400
  a: (_: A, ...args: NoInfer<Args>) => B,
397
401
  b: (_: B, ...args: NoInfer<Args>) => C,
398
402
  c: (_: C, ...args: NoInfer<Args>) => D,
399
403
  d: (_: D, ...args: NoInfer<Args>) => Eff
400
- ): CommandOutHelper<Args, Eff, Name>
404
+ ): CommandOutHelper<Args, Eff, Id>
401
405
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, Args extends Array<any>>(
402
406
  body: (...args: Args) => A,
403
407
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -405,7 +409,7 @@ export declare namespace Commander {
405
409
  c: (_: C, ...args: NoInfer<Args>) => D,
406
410
  d: (_: D, ...args: NoInfer<Args>) => E,
407
411
  e: (_: E, ...args: NoInfer<Args>) => Eff
408
- ): CommandOutHelper<Args, Eff, Name>
412
+ ): CommandOutHelper<Args, Eff, Id>
409
413
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, Args extends Array<any>>(
410
414
  body: (...args: Args) => A,
411
415
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -414,7 +418,7 @@ export declare namespace Commander {
414
418
  d: (_: D, ...args: NoInfer<Args>) => E,
415
419
  e: (_: E, ...args: NoInfer<Args>) => F,
416
420
  f: (_: F, ...args: NoInfer<Args>) => Eff
417
- ): CommandOutHelper<Args, Eff, Name>
421
+ ): CommandOutHelper<Args, Eff, Id>
418
422
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, Args extends Array<any>>(
419
423
  body: (...args: Args) => A,
420
424
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -424,7 +428,7 @@ export declare namespace Commander {
424
428
  e: (_: E, ...args: NoInfer<Args>) => F,
425
429
  f: (_: F, ...args: NoInfer<Args>) => G,
426
430
  g: (_: G, ...args: NoInfer<Args>) => Eff
427
- ): CommandOutHelper<Args, Eff, Name>
431
+ ): CommandOutHelper<Args, Eff, Id>
428
432
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, H, Args extends Array<any>>(
429
433
  body: (...args: Args) => A,
430
434
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -435,7 +439,7 @@ export declare namespace Commander {
435
439
  f: (_: F, ...args: NoInfer<Args>) => G,
436
440
  g: (_: G, ...args: NoInfer<Args>) => H,
437
441
  h: (_: H, ...args: NoInfer<Args>) => Eff
438
- ): CommandOutHelper<Args, Eff, Name>
442
+ ): CommandOutHelper<Args, Eff, Id>
439
443
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, A, B, C, D, E, F, G, H, I, Args extends Array<any>>(
440
444
  body: (...args: Args) => A,
441
445
  a: (_: A, ...args: NoInfer<Args>) => B,
@@ -447,16 +451,16 @@ export declare namespace Commander {
447
451
  g: (_: G, ...args: NoInfer<Args>) => H,
448
452
  h: (_: H, ...args: NoInfer<Args>) => I,
449
453
  i: (_: H, ...args: NoInfer<Args>) => Eff
450
- ): CommandOutHelper<Args, Eff, Name>
454
+ ): CommandOutHelper<Args, Eff, Id>
451
455
  }
452
456
 
453
- export type GenWrap<RT, Name extends string, Args extends Array<any>, AEff, EEff, REff> = {
457
+ export type GenWrap<RT, Id extends string, Args extends Array<any>, AEff, EEff, REff> = {
454
458
  (): CommandOut<
455
459
  Args,
456
460
  AEff,
457
461
  EEff,
458
462
  REff, // TODO: only allowed to be RT | CommandContext
459
- Name
463
+ Id
460
464
  >
461
465
  <
462
466
  A extends Effect.Effect<any, any, RT | CommandContext>
@@ -469,7 +473,7 @@ export declare namespace Commander {
469
473
  >,
470
474
  ...args: NoInfer<Args>
471
475
  ) => A
472
- ): CommandOutHelper<Args, A, Name>
476
+ ): CommandOutHelper<Args, A, Id>
473
477
  <
474
478
  A,
475
479
  B extends Effect.Effect<any, any, RT | CommandContext>
@@ -483,7 +487,7 @@ export declare namespace Commander {
483
487
  ...args: NoInfer<Args>
484
488
  ) => A,
485
489
  b: (_: A, ...args: NoInfer<Args>) => B
486
- ): CommandOutHelper<Args, B, Name>
490
+ ): CommandOutHelper<Args, B, Id>
487
491
  <
488
492
  A,
489
493
  B,
@@ -499,7 +503,7 @@ export declare namespace Commander {
499
503
  ) => A,
500
504
  b: (_: A, ...args: NoInfer<Args>) => B,
501
505
  c: (_: B, ...args: NoInfer<Args>) => C
502
- ): CommandOutHelper<Args, C, Name>
506
+ ): CommandOutHelper<Args, C, Id>
503
507
  <
504
508
  A,
505
509
  B,
@@ -517,7 +521,7 @@ export declare namespace Commander {
517
521
  b: (_: A, ...args: NoInfer<Args>) => B,
518
522
  c: (_: B, ...args: NoInfer<Args>) => C,
519
523
  d: (_: C, ...args: NoInfer<Args>) => D
520
- ): CommandOutHelper<Args, D, Name>
524
+ ): CommandOutHelper<Args, D, Id>
521
525
  <
522
526
  A,
523
527
  B,
@@ -537,7 +541,7 @@ export declare namespace Commander {
537
541
  c: (_: B, ...args: NoInfer<Args>) => C,
538
542
  d: (_: C, ...args: NoInfer<Args>) => D,
539
543
  e: (_: D, ...args: NoInfer<Args>) => E
540
- ): CommandOutHelper<Args, E, Name>
544
+ ): CommandOutHelper<Args, E, Id>
541
545
  <
542
546
  A,
543
547
  B,
@@ -559,7 +563,7 @@ export declare namespace Commander {
559
563
  d: (_: C, ...args: NoInfer<Args>) => D,
560
564
  e: (_: D, ...args: NoInfer<Args>) => E,
561
565
  f: (_: E, ...args: NoInfer<Args>) => F
562
- ): CommandOutHelper<Args, F, Name>
566
+ ): CommandOutHelper<Args, F, Id>
563
567
  <
564
568
  A,
565
569
  B,
@@ -583,7 +587,7 @@ export declare namespace Commander {
583
587
  e: (_: D, ...args: NoInfer<Args>) => E,
584
588
  f: (_: E, ...args: NoInfer<Args>) => F,
585
589
  g: (_: F, ...args: NoInfer<Args>) => G
586
- ): CommandOutHelper<Args, G, Name>
590
+ ): CommandOutHelper<Args, G, Id>
587
591
  <A, B, C, D, E, F, G, H extends Effect.Effect<any, any, RT | CommandContext>>(
588
592
  a: (
589
593
  _: Effect.Effect<
@@ -600,7 +604,7 @@ export declare namespace Commander {
600
604
  f: (_: E, ...args: NoInfer<Args>) => F,
601
605
  g: (_: F, ...args: NoInfer<Args>) => G,
602
606
  h: (_: G, ...args: NoInfer<Args>) => H
603
- ): CommandOutHelper<Args, H, Name>
607
+ ): CommandOutHelper<Args, H, Id>
604
608
  <A, B, C, D, E, F, G, H, I extends Effect.Effect<any, any, RT | CommandContext>>(
605
609
  a: (
606
610
  _: Effect.Effect<
@@ -618,11 +622,11 @@ export declare namespace Commander {
618
622
  g: (_: F, ...args: NoInfer<Args>) => G,
619
623
  h: (_: G, ...args: NoInfer<Args>) => H,
620
624
  i: (_: H, ...args: NoInfer<Args>) => I
621
- ): CommandOutHelper<Args, I, Name>
625
+ ): CommandOutHelper<Args, I, Id>
622
626
  }
623
627
 
624
- export type NonGenWrap<RT, Name extends string, Args extends Array<any>, AEff, EEff, REff> = {
625
- (): CommandOutHelper<Args, Effect.Effect<AEff, EEff, REff>, Name>
628
+ export type NonGenWrap<RT, Id extends string, Args extends Array<any>, AEff, EEff, REff> = {
629
+ (): CommandOutHelper<Args, Effect.Effect<AEff, EEff, REff>, Id>
626
630
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, Args extends Array<any>>(
627
631
  a: (
628
632
  _: Effect.Effect<
@@ -632,7 +636,7 @@ export declare namespace Commander {
632
636
  >,
633
637
  ...args: NoInfer<Args>
634
638
  ) => Eff
635
- ): CommandOutHelper<Args, Eff, Name>
639
+ ): CommandOutHelper<Args, Eff, Id>
636
640
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, Args extends Array<any>>(
637
641
  a: (
638
642
  _: Effect.Effect<
@@ -643,7 +647,7 @@ export declare namespace Commander {
643
647
  ...args: NoInfer<Args>
644
648
  ) => B,
645
649
  b: (_: B, ...args: NoInfer<Args>) => Eff
646
- ): CommandOutHelper<Args, Eff, Name>
650
+ ): CommandOutHelper<Args, Eff, Id>
647
651
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, Args extends Array<any>>(
648
652
  a: (
649
653
  _: Effect.Effect<
@@ -655,7 +659,7 @@ export declare namespace Commander {
655
659
  ) => B,
656
660
  b: (_: B, ...args: NoInfer<Args>) => C,
657
661
  c: (_: C, ...args: NoInfer<Args>) => Eff
658
- ): CommandOutHelper<Args, Eff, Name>
662
+ ): CommandOutHelper<Args, Eff, Id>
659
663
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, Args extends Array<any>>(
660
664
  a: (
661
665
  _: Effect.Effect<
@@ -668,7 +672,7 @@ export declare namespace Commander {
668
672
  b: (_: B, ...args: NoInfer<Args>) => C,
669
673
  c: (_: C, ...args: NoInfer<Args>) => D,
670
674
  d: (_: D, ...args: NoInfer<Args>) => Eff
671
- ): CommandOutHelper<Args, Eff, Name>
675
+ ): CommandOutHelper<Args, Eff, Id>
672
676
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, Args extends Array<any>>(
673
677
  a: (
674
678
  _: Effect.Effect<
@@ -682,7 +686,7 @@ export declare namespace Commander {
682
686
  c: (_: C, ...args: NoInfer<Args>) => D,
683
687
  d: (_: D, ...args: NoInfer<Args>) => E,
684
688
  e: (_: E, ...args: NoInfer<Args>) => Eff
685
- ): CommandOutHelper<Args, Eff, Name>
689
+ ): CommandOutHelper<Args, Eff, Id>
686
690
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, Args extends Array<any>>(
687
691
  a: (
688
692
  _: Effect.Effect<
@@ -697,7 +701,7 @@ export declare namespace Commander {
697
701
  d: (_: D, ...args: NoInfer<Args>) => E,
698
702
  e: (_: E, ...args: NoInfer<Args>) => F,
699
703
  f: (_: F, ...args: NoInfer<Args>) => Eff
700
- ): CommandOutHelper<Args, Eff, Name>
704
+ ): CommandOutHelper<Args, Eff, Id>
701
705
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, Args extends Array<any>>(
702
706
  a: (
703
707
  _: Effect.Effect<
@@ -713,7 +717,7 @@ export declare namespace Commander {
713
717
  e: (_: E, ...args: NoInfer<Args>) => F,
714
718
  f: (_: F, ...args: NoInfer<Args>) => G,
715
719
  g: (_: G, ...args: NoInfer<Args>) => Eff
716
- ): CommandOutHelper<Args, Eff, Name>
720
+ ): CommandOutHelper<Args, Eff, Id>
717
721
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, H, Args extends Array<any>>(
718
722
  a: (
719
723
  _: Effect.Effect<
@@ -730,7 +734,7 @@ export declare namespace Commander {
730
734
  f: (_: F, ...args: NoInfer<Args>) => G,
731
735
  g: (_: G, ...args: NoInfer<Args>) => H,
732
736
  h: (_: H, ...args: NoInfer<Args>) => Eff
733
- ): CommandOutHelper<Args, Eff, Name>
737
+ ): CommandOutHelper<Args, Eff, Id>
734
738
  <Eff extends Effect.Effect<any, any, RT | CommandContext>, B, C, D, E, F, G, H, I, Args extends Array<any>>(
735
739
  a: (
736
740
  _: Effect.Effect<
@@ -748,7 +752,7 @@ export declare namespace Commander {
748
752
  g: (_: G, ...args: NoInfer<Args>) => H,
749
753
  h: (_: H, ...args: NoInfer<Args>) => I,
750
754
  i: (_: H, ...args: NoInfer<Args>) => Eff
751
- ): CommandOutHelper<Args, Eff, Name>
755
+ ): CommandOutHelper<Args, Eff, Id>
752
756
  }
753
757
  }
754
758
 
@@ -764,7 +768,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
764
768
 
765
769
  const makeCommand = <RT>(runtime: Runtime.Runtime<RT>) => {
766
770
  const runFork = Runtime.runFork(runtime)
767
- return (actionName: string, errorDef?: Error) =>
771
+ return <const Id extends string>(id: Id, errorDef?: Error) =>
768
772
  <Args extends ReadonlyArray<any>, A, E, R extends RT | CommandContext>(
769
773
  handler: (...args: Args) => Effect.Effect<A, E, R>
770
774
  ) => {
@@ -777,20 +781,25 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
777
781
  errorDef = localErrorDef
778
782
  }
779
783
 
780
- const namespace = `action.${actionName}`
784
+ const namespace = `action.${id}` as const
781
785
 
782
786
  const action = intl.formatMessage({
783
787
  id: namespace,
784
- defaultMessage: actionName
788
+ defaultMessage: id
785
789
  })
786
- const context = { action, baseName: actionName, namespace, namespaced: (k: string) => `${namespace}.${k}` }
790
+ const context = {
791
+ action,
792
+ id,
793
+ namespace,
794
+ namespaced: <const K extends string>(k: K) => `${namespace}.${k}` as const
795
+ }
787
796
 
788
797
  const errorReporter = <A, E, R>(self: Effect.Effect<A, E, R>) =>
789
798
  self.pipe(
790
799
  Effect.tapErrorCause(
791
800
  Effect.fnUntraced(function*(cause) {
792
801
  if (Cause.isInterruptedOnly(cause)) {
793
- console.info(`Interrupted while trying to ${actionName}`)
802
+ console.info(`Interrupted while trying to ${id}`)
794
803
  return
795
804
  }
796
805
 
@@ -803,9 +812,9 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
803
812
  // )
804
813
  // return
805
814
  // }
806
- const message = `Failure trying to ${actionName}`
815
+ const message = `Failure trying to ${id}`
807
816
  yield* reportMessage(message, {
808
- action: actionName,
817
+ action: id,
809
818
  error: fail.value
810
819
  })
811
820
  return
@@ -813,7 +822,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
813
822
 
814
823
  const extra = {
815
824
  action,
816
- message: `Unexpected Error trying to ${actionName}`
825
+ message: `Unexpected Error trying to ${id}`
817
826
  }
818
827
  yield* reportRuntimeError(cause, extra)
819
828
  }, Effect.uninterruptible)
@@ -865,7 +874,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
865
874
 
866
875
  const command = Effect.withSpan(
867
876
  exec(...args),
868
- actionName,
877
+ id,
869
878
  { captureStackTrace }
870
879
  )
871
880
 
@@ -905,7 +914,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
905
914
 
906
915
  const command = Effect.withSpan(
907
916
  exec(...args),
908
- actionName,
917
+ id,
909
918
  { captureStackTrace }
910
919
  )
911
920
 
@@ -950,7 +959,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
950
959
 
951
960
  const command = Effect.withSpan(
952
961
  exec(...args),
953
- actionName,
962
+ id,
954
963
  { captureStackTrace }
955
964
  )
956
965
 
@@ -990,7 +999,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
990
999
 
991
1000
  const command = Effect.withSpan(
992
1001
  exec(...args).pipe(Effect.flatten),
993
- actionName,
1002
+ id,
994
1003
  { captureStackTrace }
995
1004
  )
996
1005
 
@@ -998,7 +1007,9 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
998
1007
  }, { action })
999
1008
 
1000
1009
  return reactive({
1001
- name: actionName,
1010
+ id,
1011
+ namespaced: context.namespaced,
1012
+ namespace: context.namespace,
1002
1013
  result,
1003
1014
  waiting,
1004
1015
  action,
@@ -1077,7 +1088,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1077
1088
  return {
1078
1089
  /** @experimental */
1079
1090
  takeOver:
1080
- <Args extends any[], A, E, R, const Name extends string>(command: Commander.CommandOut<Args, A, E, R, Name>) =>
1091
+ <Args extends any[], A, E, R, const Id extends string>(command: Commander.CommandOut<Args, A, E, R, Id>) =>
1081
1092
  (...args: Args) => {
1082
1093
  // we capture the call site stack here
1083
1094
  const limit = Error.stackTraceLimit
@@ -1153,7 +1164,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1153
1164
  )
1154
1165
  }),
1155
1166
  updateAction:
1156
- <Args extends Array<any>>(update: (currentActionName: string, ...args: Args) => string) =>
1167
+ <Args extends Array<any>>(update: (currentActionId: string, ...args: Args) => string) =>
1157
1168
  <A, E, R>(_: Effect.Effect<A, E, R>, ...input: Args) =>
1158
1169
  Effect.updateService(
1159
1170
  _,
@@ -1196,8 +1207,8 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1196
1207
  /**
1197
1208
  * Define a Command for handling user actions with built-in error reporting and state management.
1198
1209
  *
1199
- * @param actionName The internal identifier for the action. Used as a tracing span and to lookup
1200
- * the user-facing name via internationalization (`action.${actionName}`).
1210
+ * @param id The internal identifier for the action. Used as a tracing span and to lookup
1211
+ * the user-facing name via internationalization (`action.${id}`).
1201
1212
  * @returns A function that executes the command when called (e.g., directly in `@click` handlers).
1202
1213
  * Built-in error reporting handles failures automatically.
1203
1214
  *
@@ -1215,7 +1226,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1215
1226
  */
1216
1227
  fn: <RT>(runtime: Runtime.Runtime<RT>) => {
1217
1228
  const make = makeCommand(runtime)
1218
- return <const Name extends string>(actionName: Name): Commander.Gen<RT, Name> & Commander.NonGen<RT, Name> =>
1229
+ return <const Id extends string>(id: Id): Commander.Gen<RT, Id> & Commander.NonGen<RT, Id> =>
1219
1230
  (
1220
1231
  fn: any,
1221
1232
  ...combinators: any[]
@@ -1226,7 +1237,7 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1226
1237
  const errorDef = new Error()
1227
1238
  Error.stackTraceLimit = limit
1228
1239
 
1229
- return make(actionName, errorDef)(
1240
+ return make(id, errorDef)(
1230
1241
  Effect.fnUntraced(
1231
1242
  // fnUntraced only supports generators as first arg, so we convert to generator if needed
1232
1243
  isGeneratorFunction(fn) ? fn : function*(...args) {
@@ -1239,18 +1250,18 @@ export class Commander extends Effect.Service<Commander>()("Commander", {
1239
1250
  },
1240
1251
 
1241
1252
  /** @experimental */
1242
- alt: makeCommand as unknown as <RT>(runtime: Runtime.Runtime<RT>) => <const Name extends string>(
1243
- actionName: Name
1253
+ alt: makeCommand as unknown as <RT>(runtime: Runtime.Runtime<RT>) => <const Id extends string>(
1254
+ id: Id
1244
1255
  ) => <Args extends Array<any>, A, E, R extends RT | CommandContext>(
1245
1256
  handler: (...args: Args) => Effect.Effect<A, E, R>
1246
- ) => Commander.CommandOut<Args, A, E, R, Name>,
1257
+ ) => Commander.CommandOut<Args, A, E, R, Id>,
1247
1258
 
1248
1259
  /** @experimental */
1249
1260
  wrap: <RT>(runtime: Runtime.Runtime<RT>) => {
1250
1261
  const make = makeCommand(runtime)
1251
- return <const Name extends string, Args extends Array<any>, A, E, R>(
1252
- mutation: { mutate: (...args: Args) => Effect.Effect<A, E, R>; name: Name }
1253
- ): Commander.GenWrap<RT, Name, Args, A, E, R> & Commander.NonGenWrap<RT, Name, Args, A, E, R> =>
1262
+ return <const Id extends string, Args extends Array<any>, A, E, R>(
1263
+ mutation: { mutate: (...args: Args) => Effect.Effect<A, E, R>; name: Id }
1264
+ ): Commander.GenWrap<RT, Id, Args, A, E, R> & Commander.NonGenWrap<RT, Id, Args, A, E, R> =>
1254
1265
  (
1255
1266
  ...combinators: any[]
1256
1267
  ): any => {
@@ -23,10 +23,14 @@ it.live("works", () =>
23
23
 
24
24
  const command = Command.fn("Test Action")(
25
25
  function*() {
26
+ expect(command.id).toBe("Test Action")
27
+ expect(command.namespace).toBe("action.Test Action")
28
+ expect(command.namespaced("a")).toBe("action.Test Action.a")
29
+
26
30
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
27
31
  expect(command.waiting).toBe(true)
28
32
 
29
- expect(yield* CommandContext).toEqual({ action: "Test Action", name: "Test Action" })
33
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action", id: "Test Action" })
30
34
 
31
35
  expect(toasts.length).toBe(0)
32
36
 
@@ -41,6 +45,9 @@ it.live("works", () =>
41
45
  Effect.tap(() => executed = true)
42
46
  )
43
47
  expect(command.action).toBe("Test Action")
48
+ expect(command.id).toBe("Test Action")
49
+ expect(command.namespace).toBe("action.Test Action")
50
+ expect(command.namespaced("a")).toBe("action.Test Action.a")
44
51
 
45
52
  const r = yield* unwrap(command.handle())
46
53
  expect(command.waiting).toBe(false)
@@ -72,7 +79,7 @@ it.live("works non-gen", () =>
72
79
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
73
80
  expect(command.waiting).toBe(true)
74
81
 
75
- expect(yield* CommandContext).toEqual({ action: "Test Action", name: "Test Action" })
82
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action", id: "Test Action" })
76
83
 
77
84
  expect(toasts.length).toBe(0)
78
85
 
@@ -115,7 +122,7 @@ it.live("has custom action name", () =>
115
122
  function*() {
116
123
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
117
124
 
118
- expect(yield* CommandContext).toEqual({ action: "Test Action Translated", name: "Test Action" })
125
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action Translated", id: "Test Action" })
119
126
  return "test-value"
120
127
  },
121
128
  Effect.tap(() => executed = true)
@@ -229,6 +236,7 @@ it.live("with toasts", () =>
229
236
  // onSuccess: () => Effect.map(CommandContext, (_) => _.action),
230
237
  // onWaiting: null
231
238
  // }),
239
+ Command.withDefaultToast(),
232
240
  Effect.tap(() => executed = true)
233
241
  )
234
242
 
@@ -365,7 +373,7 @@ it.live("works with alt", () =>
365
373
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
366
374
  expect(command.waiting).toBe(true)
367
375
 
368
- expect(yield* CommandContext).toEqual({ action: "Test Action", name: "Test Action" })
376
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action", id: "Test Action" })
369
377
 
370
378
  expect(toasts.length).toBe(0)
371
379
 
@@ -409,7 +417,7 @@ it.live("has custom action name with alt", () =>
409
417
  function*() {
410
418
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
411
419
 
412
- expect(yield* CommandContext).toEqual({ action: "Test Action Translated", name: "Test Action" })
420
+ expect(yield* CommandContext).toMatchObject({ action: "Test Action Translated", id: "Test Action" })
413
421
  return "test-value"
414
422
  },
415
423
  Effect.tap(() => executed = true)
@@ -9,16 +9,16 @@ export declare const useExperimental: (options?: {
9
9
  messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
10
10
  toasts: any[];
11
11
  }) => {
12
- alt: <const Name extends string>(actionName: Name) => <Args extends Array<any>, A, E, R_1 extends Toast.Toast | WithToast | import("../src/experimental/commander.js").CommandContext>(handler: (...args: Args) => Effect.Effect<A, E, R_1>) => Commander.CommandOut<Args, A, E, R_1, Name>;
13
- fn: <const Name extends string>(actionName: Name) => Commander.Gen<Toast.Toast | WithToast, Name> & Commander.NonGen<Toast.Toast | WithToast, Name>;
14
- wrap: <const Name extends string, Args extends Array<any>, A_1, E_1, R_2>(mutation: {
12
+ alt: <const Id extends string>(id: Id) => <Args extends Array<any>, A, E, R_1 extends Toast.Toast | WithToast | import("../src/experimental/commander.js").CommandContext>(handler: (...args: Args) => Effect.Effect<A, E, R_1>) => Commander.CommandOut<Args, A, E, R_1, Id>;
13
+ fn: <const Id extends string>(id: Id) => Commander.Gen<Toast.Toast | WithToast, Id> & Commander.NonGen<Toast.Toast | WithToast, Id>;
14
+ wrap: <const Id extends string, Args extends Array<any>, A_1, E_1, R_2>(mutation: {
15
15
  mutate: (...args: Args) => Effect.Effect<A_1, E_1, R_2>;
16
- name: Name;
17
- }) => Commander.GenWrap<Toast.Toast | WithToast, Name, Args, A_1, E_1, R_2> & Commander.NonGenWrap<Toast.Toast | WithToast, Name, Args, A_1, E_1, R_2>;
18
- takeOver: <Args_1 extends any[], A_2, E_2, R_3, const Name extends string>(command: Commander.CommandOut<Args_1, A_2, E_2, R_3, Name>) => (...args: Args_1) => Effect.Effect<A_2, E_2, import("../src/experimental/commander.js").CommandContext | Exclude<Exclude<R_3, import("../src/experimental/commander.js").CommandContext>, import("effect/Tracer").ParentSpan>>;
16
+ name: Id;
17
+ }) => Commander.GenWrap<Toast.Toast | WithToast, Id, Args, A_1, E_1, R_2> & Commander.NonGenWrap<Toast.Toast | WithToast, Id, Args, A_1, E_1, R_2>;
18
+ takeOver: <Args_1 extends any[], A_2, E_2, R_3, const Id extends string>(command: Commander.CommandOut<Args_1, A_2, E_2, R_3, Id>) => (...args: Args_1) => Effect.Effect<A_2, E_2, import("../src/experimental/commander.js").CommandContext | Exclude<Exclude<R_3, import("../src/experimental/commander.js").CommandContext>, import("effect/Tracer").ParentSpan>>;
19
19
  confirmOrInterrupt: (message?: string | undefined) => Effect.Effect<void, never, import("../src/experimental/commander.js").CommandContext>;
20
20
  confirm: (message?: string | undefined) => Effect.Effect<boolean, never, import("../src/experimental/commander.js").CommandContext>;
21
- updateAction: <Args_1 extends Array<any>>(update: (currentActionName: string, ...args: Args_1) => string) => <A_3, E_3, R_4>(_: Effect.Effect<A_3, E_3, R_4>, ...input: Args_1) => Effect.Effect<A_3, E_3, import("../src/experimental/commander.js").CommandContext | R_4>;
21
+ updateAction: <Args_1 extends Array<any>>(update: (currentActionId: string, ...args: Args_1) => string) => <A_3, E_3, R_4>(_: Effect.Effect<A_3, E_3, R_4>, ...input: Args_1) => Effect.Effect<A_3, E_3, import("../src/experimental/commander.js").CommandContext | R_4>;
22
22
  defaultFailureMessageHandler: <E_4, Args_1 extends readonly any[]>(action: string, errorRenderer?: ((e: E_4, action: string, ...args: Args_1) => string | undefined) | undefined) => (o: import("effect/Option").Option<E_4>, ...args: Args_1) => string | {
23
23
  level: "warn";
24
24
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../stubs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAElD,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AA4C5D,eAAO,MAAM,aAAa,GAAI,WAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAM,oCAgBzG,CAAA;AAEH,eAAO,MAAM,eAAe,GAC1B,UAAU;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,GAAG,EAAE,CAAA;CAAE;;;;;;;+IAlD5F,GAAG;gCAIW,CAAC;qBAGG,CAAC;kFAKrB,GAAG,6EAEwB,GAAI;oGAQjC,CAAC,4BACG,GAAI,8FAIN,GACV;;;;mFAMK,CAAL,4BAA2B,GAAI,8DAE1B,GAAI;oFAGI,CAAC;qBAGP,CAAH,2BAEG,GAAH;iBAAsD,CAAC,6BACtC,GAAI;iBAKrB,CAAC,qCAAoC,GAAI;2DAES,GACrD;;CAMD,CAAA"}
1
+ {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../stubs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAE9E,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAElD,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AA4C5D,eAAO,MAAM,aAAa,GAAI,WAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAM,oCAgBzG,CAAA;AAEH,eAAO,MAAM,eAAe,GAC1B,UAAU;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,GAAG,EAAE,CAAA;CAAE;;;;;;;2IArD1F,GAAG;gCAKwB,CAAC;qBAIhC,CAAC;gFAI+B,GACzC,6EAEO,GAAI;oGAKS,CAAC,4BAGnB,GAAD,8FAIa,GAAI;;;;mFAM0F,CAAA,4BAEtG,GAAI,8DAEH,GAAI;oFAEI,CAAC;qBACL,CAAC,2BAGR,GAAA;iBAGS,CAAC,6BAA4B,GAAI;iBAG9C,CAAF,qCAE+B,GAC7B;2DAES,GAAI;;CAOd,CAAA"}