cogsbox-state 0.5.490 → 0.5.491

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/src/plugins.ts CHANGED
@@ -27,14 +27,14 @@ export type ChainMethodContext<TOptions = any, THookReturn = any> = {
27
27
  $update: (payload: any) => { synced: () => void };
28
28
  $applyOperation: (operation: any, metaData?: Record<string, any>) => void;
29
29
  getFieldMetaData: () => any;
30
- setFieldMetaData: (data: Record<string, any>) => void;
31
- removeFieldMetaData: () => void;
32
- watchPluginMeta: (scope?: string) => void;
33
- notifyPluginMeta: (scope?: string) => void;
34
- getFieldRefs: () => RefObject<any>[];
35
- getFieldElements: () => HTMLElement[];
36
- setFieldDisabled: (disabled: boolean) => void;
37
- };
30
+ setFieldMetaData: (data: Record<string, any>) => void;
31
+ removeFieldMetaData: () => void;
32
+ watchPluginMeta: (scope?: string) => void;
33
+ notifyPluginMeta: (scope?: string) => void;
34
+ getFieldRefs: () => RefObject<any>[];
35
+ getFieldElements: () => HTMLElement[];
36
+ setFieldDisabled: (disabled: boolean) => void;
37
+ };
38
38
 
39
39
  export type ChainMethodHandler = (
40
40
  ctx: ChainMethodContext<any, any>,
@@ -58,13 +58,17 @@ type ChainMethodCallable<THandler> = THandler extends (
58
58
  ? (...args: TArgs) => TReturn
59
59
  : never;
60
60
 
61
- export type ChainMethodCallables<TMethods> = {
62
- [K in keyof TMethods as K extends string
63
- ? `$${K}`
64
- : never]: TMethods[K] extends ChainMethodDefinition<infer TFn>
65
- ? ChainMethodCallable<TFn>
66
- : never;
67
- };
61
+ type LiteralStringKeys<T> = string extends keyof T
62
+ ? never
63
+ : Extract<keyof T, string>;
64
+
65
+ export type ChainMethodCallables<TMethods> = {
66
+ [K in LiteralStringKeys<TMethods> as K extends string
67
+ ? `$${K}`
68
+ : never]: TMethods[K] extends ChainMethodDefinition<infer TFn>
69
+ ? ChainMethodCallable<TFn>
70
+ : never;
71
+ };
68
72
 
69
73
  export type KeyedTypes<TMap extends Record<string, any>> = {
70
74
  __key: 'keyed';
@@ -474,14 +478,14 @@ type ZodObjOutput<T extends z.ZodObject<any>> = {
474
478
  type OutputOf<T extends z.ZodTypeAny> =
475
479
  T extends z.ZodObject<any> ? Prettify<ZodObjOutput<T>> : z.output<T>;
476
480
 
477
- type MethodFactory = <TArgs extends any[], TReturn>(
478
- handler: (
479
- ctx: ChainMethodContext<any, any>,
480
- ...args: TArgs
481
- ) => TReturn
482
- ) => ChainMethodDefinition<
483
- (ctx: ChainMethodContext<any, any>, ...args: TArgs) => TReturn
484
- >;
481
+ type MethodFactory = <TArgs extends any[], TReturn>(
482
+ handler: (
483
+ ctx: ChainMethodContext<any, any>,
484
+ ...args: TArgs
485
+ ) => TReturn
486
+ ) => ChainMethodDefinition<
487
+ (ctx: ChainMethodContext<any, any>, ...args: TArgs) => TReturn
488
+ >;
485
489
 
486
490
  type PathMethodFactory = MethodFactory & {
487
491
  array: MethodFactory;