MCPcopy Create free account
hub / github.com/effect-app/libs / CommanderImpl

Class CommanderImpl

packages/vue/src/commander.ts:2532–3401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2530
2531// class preserves JSDoc throughout..
2532export class CommanderImpl<RT, RTHooks> {
2533 private readonly rt: Context.Context<RT>
2534 private readonly intl: I18n
2535 private readonly hooks: Layer.Layer<RTHooks, never, RT>
2536
2537 constructor(
2538 rt: Context.Context<RT>,
2539 intl: I18n,
2540 hooks: Layer.Layer<RTHooks, never, RT>
2541 ) {
2542 this.rt = rt
2543 this.intl = intl
2544 this.hooks = hooks
2545 }
2546
2547 readonly makeContext = <const Id extends string, const I18nKey extends string = Id>(
2548 id: Id,
2549 options?: FnOptionsInternal<I18nKey>
2550 ) => {
2551 if (!id) throw new Error("must specify an id")
2552 const i18nKey: I18nKey = options?.i18nCustomKey ?? id as unknown as I18nKey
2553
2554 const namespace = `action.${i18nKey}` as const
2555
2556 // must remain stable through out single call
2557 const action = this.intl.formatMessage({
2558 id: namespace,
2559 defaultMessage: id
2560 }, { ...options?.state, _isLabel: false })
2561
2562 const label = this.intl.formatMessage({
2563 id: namespace,
2564 defaultMessage: id
2565 }, { ...options?.state, _isLabel: true })
2566
2567 const context = CommandContext.of({
2568 ...makeBaseInfo(id, options),
2569 action,
2570 label,
2571 state: options?.state
2572 })
2573
2574 return context
2575 }
2576
2577 readonly makeCommand = <
2578 const Id extends string,
2579 const State extends IntlRecord | undefined,
2580 const I18nKey extends string = Id
2581 >(
2582 id_: Id | { id: Id },
2583 options?: FnOptions<Id, I18nKey, State>,
2584 errorDef?: Error
2585 ) => {
2586 const id = typeof id_ === "string" ? id_ : id_.id
2587 const state = getStateValues(options)
2588
2589 return Object.assign(

Callers

nothing calls this directly

Calls 15

asResultFunction · 0.90
deepToRawFunction · 0.90
asStreamResultFunction · 0.90
makeBaseInfoFunction · 0.85
getStateValuesFunction · 0.85
computedFunction · 0.85
registerWaitFunction · 0.85
unregisterWaitFunction · 0.85
runForkFunction · 0.85
reactiveFunction · 0.85
syncMethod · 0.80
fnFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…