@actdim/dynstruct 1.0.0 → 1.0.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/README.md CHANGED
@@ -1,18 +1,22 @@
1
1
  # @actdim/dynstruct
2
+
2
3
  Build scalable applications with dynamic structured components, explicit wiring, and decoupled message flow. Keep architecture clean and modular.
3
4
 
4
5
  # use dedupe:
5
- 'rxjs',
6
- 'uuid',
7
- 'http-status',
8
- 'jwt-decode',
9
- 'mobx',
10
- 'mobx-react-lite',
11
- 'mobx-utils',
12
- 'path-to-regexp',
13
- 'react',
14
- 'react-dom',
15
- 'react-router',
16
- 'react-router-dom',
17
- '@actdim/utico',
18
- '@actdim/msgmesh'
6
+
7
+ http-status,
8
+ jwt-decode,
9
+ mobx,
10
+ mobx-react-lite,
11
+ mobx-utils,
12
+ path-to-regexp,
13
+ react,
14
+ react-dom,
15
+ react-router,
16
+ react-router-dom,
17
+ @actdim/utico,
18
+ @actdim/msgmesh,
19
+ rxjs,
20
+ dexie,
21
+ moment,
22
+ uuid
@@ -2,7 +2,8 @@ import { MsgBus, MsgBusStructBase, MsgBusStructFactory } from '@actdim/msgmesh/m
2
2
  import { BaseSecurityDomainConfig as BaseSecurityDomainConfig, BaseSecurityBusStruct } from './security/securityContracts';
3
3
  import { ReactNode } from 'react';
4
4
  export declare const $NAV_GOTO = "APP-NAV-GOTO";
5
- export declare const $NAV_GET_CONTEXT = "APP-NAV-CONTEXT";
5
+ export declare const $NAV_GET_CONTEXT = "APP-NAV-GET-CONTEXT";
6
+ export declare const $NAV_CONTEXT_CHANGED = "APP-NAV-CONTEXT-CHANGED";
6
7
  export declare const $NAV_READ_HISTORY = "APP-NAV-READ-HISTORY";
7
8
  export declare const $NOTICE = "APP-NOTICE";
8
9
  export declare const $CONFIG_GET = "APP-CONFIG-GET";
@@ -29,6 +30,12 @@ export type NavRoute<TParams extends NavRouteParams = NavRouteParams> = {
29
30
  defaultParams?: TParams;
30
31
  };
31
32
  export type NavRoutes = Record<string, NavRoute>;
33
+ type NavRouteStruct<TNavRoutes extends NavRoutes> = {
34
+ [K in keyof TNavRoutes]: {
35
+ route: K;
36
+ params?: TNavRoutes[K]["defaultParams"];
37
+ };
38
+ }[keyof TNavRoutes];
32
39
  export type NavContext = {
33
40
  location?: NavLocation;
34
41
  searchParams?: URLSearchParams;
@@ -48,7 +55,7 @@ export type AppError<TModule = Module> = {
48
55
  reason?: string;
49
56
  };
50
57
  export type BaseApiBusStruct = BaseSecurityBusStruct & MsgBusStructFactory<{}>;
51
- export type BaseAppBusStruct = BaseApiBusStruct & MsgBusStructFactory<{
58
+ export type BaseAppBusStruct<TNavRoutes extends NavRoutes = NavRoutes> = BaseApiBusStruct & MsgBusStructFactory<{
52
59
  [$NOTICE]: {
53
60
  in: {
54
61
  text: string;
@@ -63,12 +70,17 @@ export type BaseAppBusStruct = BaseApiBusStruct & MsgBusStructFactory<{
63
70
  };
64
71
  [$NAV_GOTO]: {
65
72
  in: string | number;
73
+ ex: NavRouteStruct<TNavRoutes>;
66
74
  out: void;
67
75
  };
68
76
  [$NAV_GET_CONTEXT]: {
69
77
  in: void;
70
78
  out: NavContext;
71
79
  };
80
+ [$NAV_CONTEXT_CHANGED]: {
81
+ in: NavContext;
82
+ out: void;
83
+ };
72
84
  [$NAV_READ_HISTORY]: {
73
85
  in: number;
74
86
  out: NavContext;
@@ -116,4 +128,5 @@ export type BaseAppDomainConfig<TSecurityDomainConfig extends BaseSecurityDomain
116
128
  export type BaseAppContext<TMsgBusStruct extends BaseAppBusStruct = BaseAppBusStruct> = {
117
129
  msgBus: MsgBus<TMsgBusStruct>;
118
130
  };
131
+ export {};
119
132
  //# sourceMappingURL=appContracts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"appContracts.d.ts","sourceRoot":"","sources":["../../src/appDomain/appContracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,MAAM,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,4B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E-SET", _ = "APP-KV-STORE-REMOVE";
1
+ const E = "APP-NAV-GOTO", T = "APP-NAV-GET-CONTEXT", A = "APP-NAV-CONTEXT-CHANGED", O = "APP-NAV-READ-HISTORY", P = "APP-NOTICE", N = "APP-CONFIG-GET", V = "APP-FETCH", _ = "APP-KV-STORE-GET", C = "APP-KV-STORE-SET", G = "APP-KV-STORE-REMOVE";
2
2
  export {
3
- A as $CONFIG_GET,
3
+ N as $CONFIG_GET,
4
4
  V as $FETCH,
5
- N as $KV_STORE_GET,
6
- _ as $KV_STORE_REMOVE,
7
- R as $KV_STORE_SET,
5
+ _ as $KV_STORE_GET,
6
+ G as $KV_STORE_REMOVE,
7
+ C as $KV_STORE_SET,
8
+ A as $NAV_CONTEXT_CHANGED,
8
9
  T as $NAV_GET_CONTEXT,
9
10
  E as $NAV_GOTO,
10
11
  O as $NAV_READ_HISTORY,
@@ -1 +1 @@
1
- {"version":3,"file":"appContracts.es.js","sources":["../../src/appDomain/appContracts.ts"],"sourcesContent":["import { $CG_ERROR, MsgBus, MsgBusStructBase, MsgBusStructFactory } from \"@actdim/msgmesh/msgBusCore\";\r\nimport { BaseSecurityDomainConfig as BaseSecurityDomainConfig, BaseSecurityBusStruct } from \"@/appDomain/security/securityContracts\";\r\nimport { ReactNode } from \"react\";\r\n\r\nexport const $NAV_GOTO = \"APP-NAV-GOTO\";\r\nexport const $NAV_GET_CONTEXT = \"APP-NAV-CONTEXT\";\r\nexport const $NAV_READ_HISTORY = \"APP-NAV-READ-HISTORY\";\r\n// TOAST\r\nexport const $NOTICE = \"APP-NOTICE\";\r\nexport const $CONFIG_GET = \"APP-CONFIG-GET\";\r\n// ERROR?\r\nexport const $FETCH = \"APP-FETCH\";\r\n\r\nexport const $KV_STORE_GET = \"APP-KV-STORE-GET\";\r\nexport const $KV_STORE_SET = \"APP-KV-STORE-SET\";\r\nexport const $KV_STORE_REMOVE = \"APP-KV-STORE-REMOVE\";\r\n// TODO: has, clear, entries\r\n\r\nexport type Module = \"security\" | \"api-client\";\r\n\r\nexport type NavPath = {\r\n /**\r\n * A URL pathname, beginning with a /.\r\n */\r\n pathname: string;\r\n /**\r\n * A URL search string, beginning with a ?.\r\n */\r\n search: string;\r\n /**\r\n * A URL fragment identifier, beginning with a #.\r\n */\r\n hash: string;\r\n};\r\n\r\nexport type NavLocation<State = any> = NavPath & {\r\n /**\r\n * A value of arbitrary data associated with this location.\r\n */\r\n state: State;\r\n /**\r\n * A unique string associated with this location. May be used to safely store\r\n * and retrieve data in some other storage API, like `localStorage`.\r\n *\r\n * Note: This value is always \"default\" on the initial location.\r\n */\r\n key: string;\r\n};\r\n\r\nexport type NavAction =\r\n /**\r\n * A POP indicates a change to an arbitrary index in the history stack, such\r\n * as a back or forward navigation. It does not describe the direction of the\r\n * navigation, only that the current index changed.\r\n *\r\n * Note: This is the default action for newly created history objects.\r\n */\r\n | \"POP\"\r\n /**\r\n * A PUSH indicates a new entry being added to the history stack, such as when\r\n * a link is clicked and a new page loads. When this happens, all subsequent\r\n * entries in the stack are lost.\r\n */\r\n | \"PUSH\"\r\n /**\r\n * A REPLACE indicates the entry at the current index in the history stack\r\n * being replaced by a new one.\r\n */\r\n | \"REPLACE\";\r\n\r\n// AppRouteParams\r\nexport type NavRouteParams = Record<string, string | undefined>;\r\n\r\n// AppRoute\r\nexport type NavRoute<TParams extends NavRouteParams = NavRouteParams> = {\r\n path(params?: TParams): string;\r\n match(path: string): TParams;\r\n element: ReactNode;\r\n defaultParams?: TParams;\r\n};\r\n\r\nexport type NavRoutes = Record<string, NavRoute>;\r\n\r\nexport type NavContext = {\r\n // route?: NavRoute;\r\n location?: NavLocation;\r\n searchParams?: URLSearchParams;\r\n params?: NavRouteParams;\r\n navType?: NavAction;\r\n};\r\n\r\nexport type NavHistory = Array<NavContext>;\r\n\r\n// OperationContext?\r\nexport type AppError<TModule = Module> = {\r\n module: TModule;\r\n // code: string;\r\n type: string;\r\n title?: string;\r\n source?: any;\r\n details?: any;\r\n // instance?: string;\r\n timestamp?: string;\r\n // errors: AppError[];\r\n traceId?: string;\r\n field?: string;\r\n reason?: string;\r\n};\r\n\r\n// Base(App)Api(Msg)BusStruct\r\nexport type BaseApiBusStruct = BaseSecurityBusStruct &\r\n MsgBusStructFactory<{\r\n // \"GET-VERSION\"?: {\r\n // in: any;\r\n // };\r\n }>;\r\n\r\n// BaseAppMsgBusStruct\r\nexport type BaseAppBusStruct = BaseApiBusStruct &\r\n MsgBusStructFactory<\r\n {\r\n [$NOTICE]: {\r\n in: {\r\n text: string;\r\n title?: string;\r\n type: any;\r\n };\r\n out: void;\r\n };\r\n [$CONFIG_GET]: {\r\n in: void;\r\n out: BaseAppDomainConfig;\r\n };\r\n [$NAV_GOTO]: {\r\n in: string | number;\r\n out: void;\r\n };\r\n [$NAV_GET_CONTEXT]: {\r\n in: void;\r\n out: NavContext;\r\n };\r\n [$NAV_READ_HISTORY]: {\r\n in: number;\r\n out: NavContext;\r\n };\r\n [$FETCH]: {\r\n in: {\r\n url: string;\r\n params: RequestInit;\r\n };\r\n out: Response;\r\n };\r\n [$KV_STORE_GET]: {\r\n in: {\r\n key: string;\r\n useEncryption?: boolean;\r\n };\r\n out: string;\r\n };\r\n [$KV_STORE_SET]: {\r\n in: {\r\n key: string;\r\n value: any;\r\n useEncryption?: boolean;\r\n };\r\n out: void;\r\n };\r\n [$KV_STORE_REMOVE]: {\r\n in: {\r\n key: string;\r\n };\r\n out: void;\r\n };\r\n } & MsgBusStructBase\r\n >;\r\n\r\nexport type BaseApiConfig = {\r\n url?: string;\r\n versions?: string[];\r\n};\r\n\r\n// BaseApp(Domain)Config\r\nexport type BaseAppDomainConfig<\r\n TSecurityDomainConfig extends BaseSecurityDomainConfig = BaseSecurityDomainConfig,\r\n TApiConfig extends BaseApiConfig = BaseApiConfig\r\n> = {\r\n id: string;\r\n name?: string;\r\n baseUrl: string;\r\n security: TSecurityDomainConfig;\r\n apis: Record<string, TApiConfig>;\r\n // HATEOAS? (React Admin)\r\n};\r\n\r\nexport type BaseAppContext<TMsgBusStruct extends BaseAppBusStruct = BaseAppBusStruct> = {\r\n msgBus: MsgBus<TMsgBusStruct>;\r\n};\r\n"],"names":["$NAV_GOTO","$NAV_GET_CONTEXT","$NAV_READ_HISTORY","$NOTICE","$CONFIG_GET","$FETCH","$KV_STORE_GET","$KV_STORE_SET","$KV_STORE_REMOVE"],"mappings":"AAIO,MAAMA,IAAY,gBACZC,IAAmB,mBACnBC,IAAoB,wBAEpBC,IAAU,cACVC,IAAc,kBAEdC,IAAS,aAETC,IAAgB,oBAChBC,IAAgB,oBAChBC,IAAmB;"}
1
+ {"version":3,"file":"appContracts.es.js","sources":["../../src/appDomain/appContracts.ts"],"sourcesContent":["import { $CG_ERROR, MsgBus, MsgBusStructBase, MsgBusStructFactory } from \"@actdim/msgmesh/msgBusCore\";\r\nimport { BaseSecurityDomainConfig as BaseSecurityDomainConfig, BaseSecurityBusStruct } from \"@/appDomain/security/securityContracts\";\r\nimport { ReactNode } from \"react\";\r\n\r\nexport const $NAV_GOTO = \"APP-NAV-GOTO\";\r\nexport const $NAV_GET_CONTEXT = \"APP-NAV-GET-CONTEXT\";\r\nexport const $NAV_CONTEXT_CHANGED = \"APP-NAV-CONTEXT-CHANGED\";\r\nexport const $NAV_READ_HISTORY = \"APP-NAV-READ-HISTORY\";\r\n// TOAST\r\nexport const $NOTICE = \"APP-NOTICE\";\r\nexport const $CONFIG_GET = \"APP-CONFIG-GET\";\r\n// ERROR?\r\nexport const $FETCH = \"APP-FETCH\";\r\n\r\nexport const $KV_STORE_GET = \"APP-KV-STORE-GET\";\r\nexport const $KV_STORE_SET = \"APP-KV-STORE-SET\";\r\nexport const $KV_STORE_REMOVE = \"APP-KV-STORE-REMOVE\";\r\n// TODO: has, clear, entries\r\n\r\nexport type Module = \"security\" | \"api-client\";\r\n\r\nexport type NavPath = {\r\n /**\r\n * A URL pathname, beginning with a /.\r\n */\r\n pathname: string;\r\n /**\r\n * A URL search string, beginning with a ?.\r\n */\r\n search: string;\r\n /**\r\n * A URL fragment identifier, beginning with a #.\r\n */\r\n hash: string;\r\n};\r\n\r\nexport type NavLocation<State = any> = NavPath & {\r\n /**\r\n * A value of arbitrary data associated with this location.\r\n */\r\n state: State;\r\n /**\r\n * A unique string associated with this location. May be used to safely store\r\n * and retrieve data in some other storage API, like `localStorage`.\r\n *\r\n * Note: This value is always \"default\" on the initial location.\r\n */\r\n key: string;\r\n};\r\n\r\nexport type NavAction =\r\n /**\r\n * A POP indicates a change to an arbitrary index in the history stack, such\r\n * as a back or forward navigation. It does not describe the direction of the\r\n * navigation, only that the current index changed.\r\n *\r\n * Note: This is the default action for newly created history objects.\r\n */\r\n | \"POP\"\r\n /**\r\n * A PUSH indicates a new entry being added to the history stack, such as when\r\n * a link is clicked and a new page loads. When this happens, all subsequent\r\n * entries in the stack are lost.\r\n */\r\n | \"PUSH\"\r\n /**\r\n * A REPLACE indicates the entry at the current index in the history stack\r\n * being replaced by a new one.\r\n */\r\n | \"REPLACE\";\r\n\r\n// AppRouteParams\r\nexport type NavRouteParams = Record<string, string | undefined>;\r\n\r\n// AppRoute\r\nexport type NavRoute<TParams extends NavRouteParams = NavRouteParams> = {\r\n path(params?: TParams): string;\r\n match(path: string): TParams;\r\n element: ReactNode;\r\n defaultParams?: TParams;\r\n};\r\n\r\nexport type NavRoutes = Record<string, NavRoute>;\r\n\r\ntype NavRouteStruct<TNavRoutes extends NavRoutes> = {\r\n [K in keyof TNavRoutes]: {\r\n route: K;\r\n params?: TNavRoutes[K][\"defaultParams\"];\r\n };\r\n}[keyof TNavRoutes];\r\n\r\nexport type NavContext = {\r\n // route?: NavRoute;\r\n location?: NavLocation;\r\n searchParams?: URLSearchParams;\r\n params?: NavRouteParams;\r\n navType?: NavAction;\r\n};\r\n\r\nexport type NavHistory = Array<NavContext>;\r\n\r\n// OperationContext?\r\nexport type AppError<TModule = Module> = {\r\n module: TModule;\r\n // code: string;\r\n type: string;\r\n title?: string;\r\n source?: any;\r\n details?: any;\r\n // instance?: string;\r\n timestamp?: string;\r\n // errors: AppError[];\r\n traceId?: string;\r\n field?: string;\r\n reason?: string;\r\n};\r\n\r\n// Base(App)Api(Msg)BusStruct\r\nexport type BaseApiBusStruct = BaseSecurityBusStruct &\r\n MsgBusStructFactory<{\r\n // \"GET-VERSION\"?: {\r\n // in: any;\r\n // };\r\n }>;\r\n\r\n// BaseAppMsgBusStruct\r\nexport type BaseAppBusStruct<TNavRoutes extends NavRoutes = NavRoutes> = BaseApiBusStruct &\r\n MsgBusStructFactory<\r\n {\r\n [$NOTICE]: {\r\n in: {\r\n text: string;\r\n title?: string;\r\n type: any;\r\n };\r\n out: void;\r\n };\r\n [$CONFIG_GET]: {\r\n in: void;\r\n out: BaseAppDomainConfig;\r\n };\r\n [$NAV_GOTO]: {\r\n in: string | number;\r\n ex: NavRouteStruct<TNavRoutes>;\r\n out: void;\r\n };\r\n [$NAV_GET_CONTEXT]: {\r\n in: void;\r\n out: NavContext;\r\n };\r\n [$NAV_CONTEXT_CHANGED]: {\r\n in: NavContext;\r\n out: void;\r\n };\r\n [$NAV_READ_HISTORY]: {\r\n in: number;\r\n out: NavContext;\r\n };\r\n [$FETCH]: {\r\n in: {\r\n url: string;\r\n params: RequestInit;\r\n };\r\n out: Response;\r\n };\r\n [$KV_STORE_GET]: {\r\n in: {\r\n key: string;\r\n useEncryption?: boolean;\r\n };\r\n out: string;\r\n };\r\n [$KV_STORE_SET]: {\r\n in: {\r\n key: string;\r\n value: any;\r\n useEncryption?: boolean;\r\n };\r\n out: void;\r\n };\r\n [$KV_STORE_REMOVE]: {\r\n in: {\r\n key: string;\r\n };\r\n out: void;\r\n };\r\n } & MsgBusStructBase\r\n >;\r\n\r\nexport type BaseApiConfig = {\r\n url?: string;\r\n versions?: string[];\r\n};\r\n\r\n// BaseApp(Domain)Config\r\nexport type BaseAppDomainConfig<\r\n TSecurityDomainConfig extends BaseSecurityDomainConfig = BaseSecurityDomainConfig,\r\n TApiConfig extends BaseApiConfig = BaseApiConfig\r\n> = {\r\n id: string;\r\n name?: string;\r\n baseUrl: string;\r\n security: TSecurityDomainConfig;\r\n apis: Record<string, TApiConfig>;\r\n // HATEOAS? (React Admin)\r\n};\r\n\r\nexport type BaseAppContext<TMsgBusStruct extends BaseAppBusStruct = BaseAppBusStruct> = {\r\n msgBus: MsgBus<TMsgBusStruct>;\r\n};\r\n"],"names":["$NAV_GOTO","$NAV_GET_CONTEXT","$NAV_CONTEXT_CHANGED","$NAV_READ_HISTORY","$NOTICE","$CONFIG_GET","$FETCH","$KV_STORE_GET","$KV_STORE_SET","$KV_STORE_REMOVE"],"mappings":"AAIO,MAAMA,IAAY,gBACZC,IAAmB,uBACnBC,IAAuB,2BACvBC,IAAoB,wBAEpBC,IAAU,cACVC,IAAc,kBAEdC,IAAS,aAETC,IAAgB,oBAChBC,IAAgB,oBAChBC,IAAmB;"}
@@ -0,0 +1,136 @@
1
+ import { PropsWithChildren, FC, ReactNode } from 'react';
2
+ import { $CG_IN, $CG_OUT, MsgBus, MsgBusProviderParams, MsgBusStruct, MsgBusSubscriberParams } from '@actdim/msgmesh/msgBusCore';
3
+ import { MaybePromise, SafeKey, Skip } from '@actdim/utico/typeCore';
4
+ export type MsgBusChannelGroupProviderParams<TStruct extends MsgBusStruct = MsgBusStruct, TChannel extends keyof TStruct = keyof TStruct, TGroup extends keyof TStruct[TChannel] = typeof $CG_IN> = Skip<MsgBusProviderParams<TStruct, TChannel, TGroup>, 'channel' | 'group'>;
5
+ export type MsgBusChannelGroupSubscriberParams<TStruct extends MsgBusStruct = MsgBusStruct, TChannel extends keyof TStruct = keyof TStruct, TGroup extends keyof TStruct[TChannel] = typeof $CG_IN> = Skip<MsgBusSubscriberParams<TStruct, TChannel, TGroup>, 'channel' | 'group'>;
6
+ export type MsgBusBrokerScope<TStruct extends MsgBusStruct, TKeysToProvide extends keyof TStruct = keyof TStruct, TKeysToSubscribe extends keyof TStruct = keyof TStruct, TKeysToPublish extends keyof TStruct = keyof TStruct> = {
7
+ provide?: TKeysToProvide;
8
+ subscribe?: TKeysToSubscribe;
9
+ publish?: TKeysToPublish;
10
+ };
11
+ export type ComponentPropStruct = Record<string, any>;
12
+ export type ComponentMethodStruct = Record<string, Function>;
13
+ export type ComponentRefStruct = {
14
+ [name: string]: ComponentStruct | ((params: any) => ComponentStruct);
15
+ };
16
+ export type ComponentStructBase<TMsgBusStruct extends MsgBusStruct = MsgBusStruct, TPropStruct extends ComponentPropStruct = ComponentPropStruct, TMsgScope extends MsgBusBrokerScope<TMsgBusStruct> = MsgBusBrokerScope<TMsgBusStruct>> = {
17
+ props?: TPropStruct;
18
+ methods?: ComponentMethodStruct;
19
+ children?: ComponentRefStruct;
20
+ msgScope?: TMsgScope;
21
+ };
22
+ export type ComponentStruct<TMsgBusStruct extends MsgBusStruct = MsgBusStruct, T extends ComponentStructBase<TMsgBusStruct> = ComponentStructBase<TMsgBusStruct>> = T & {
23
+ msgBus: TMsgBusStruct;
24
+ };
25
+ export type MsgBusBroker<TStructToProvide extends MsgBusStruct = MsgBusStruct, TStructToSubscribe extends MsgBusStruct = MsgBusStruct> = {
26
+ provide?: {
27
+ [TChannel in keyof TStructToProvide]?: {
28
+ [TGroup in keyof Skip<TStructToProvide[TChannel], typeof $CG_OUT>]?: MsgBusChannelGroupProviderParams<TStructToProvide, TChannel, TGroup>;
29
+ };
30
+ };
31
+ subscribe?: {
32
+ [TChannel in keyof TStructToSubscribe]: {
33
+ [TGroup in keyof TStructToSubscribe[TChannel]]?: MsgBusChannelGroupSubscriberParams<TStructToSubscribe, TChannel, TGroup>;
34
+ };
35
+ };
36
+ };
37
+ type ValueConverter<TTo, TFrom> = {
38
+ convert(value: TFrom): TTo;
39
+ convertBack(value: TTo): TFrom;
40
+ };
41
+ type ValidationResult = {
42
+ valid: boolean;
43
+ message: string;
44
+ };
45
+ type Validator<T> = {
46
+ options: {
47
+ blur: boolean;
48
+ };
49
+ validate: (value: T) => MaybePromise<ValidationResult>;
50
+ };
51
+ declare const $isBinding: unique symbol;
52
+ export interface IBinding<T = any, TFrom = any> {
53
+ readonly get: () => T;
54
+ readonly set: (value: T) => void;
55
+ readonly converter: ValueConverter<T, TFrom>;
56
+ readonly validator: Validator<T>;
57
+ readonly readOnly: boolean;
58
+ [$isBinding]: boolean;
59
+ }
60
+ declare class Binding<T = any, TFrom = any> implements IBinding<any, any> {
61
+ readonly get: () => T;
62
+ readonly set: (value: T) => void;
63
+ readonly converter: ValueConverter<T, TFrom>;
64
+ readonly validator: Validator<T>;
65
+ readonly readOnly: boolean;
66
+ constructor(get: () => T, set?: (value: T) => void, converter?: ValueConverter<T, TFrom>, validator?: Validator<T>);
67
+ [$isBinding]: boolean;
68
+ }
69
+ export declare function isBinding(obj: any): obj is IBinding;
70
+ export declare function bind<T, TFrom = any>(get: () => T, set?: (value: T) => void, converter?: ValueConverter<T, TFrom>, validator?: Validator<T>): Binding<T, TFrom>;
71
+ export declare function bindProp<T extends object, P extends keyof T>(target: () => T, prop: P): Binding<T[P], any>;
72
+ export type ComponentPropSource<T> = T | Binding<T>;
73
+ export type ComponentPropParams<TPropStruct extends ComponentPropStruct> = {
74
+ [P in keyof TPropStruct]?: ComponentPropSource<TPropStruct[P]>;
75
+ };
76
+ declare const $ON_GET = "onGet";
77
+ declare const $ON_CHANGING = "onChanging";
78
+ declare const $ON_CHANGE = "onChange";
79
+ type PropValueChangingHandler<TProp = PropKey> = (prop: TProp, oldValue: any, newValue: any) => boolean;
80
+ type PropValueChangeHandler<TProp = PropKey> = (prop: TProp, value: any) => void;
81
+ type ValueChangingHandler<T = any> = (oldValue: T, newValue: T) => boolean;
82
+ type ValueChangeHandler<T = any> = (value: T) => void;
83
+ type ComponentEvents<TStruct extends ComponentStruct = ComponentStruct> = {
84
+ onPropChanging?: PropValueChangingHandler<keyof TStruct['props']>;
85
+ onPropChange?: PropValueChangeHandler<keyof TStruct['props']>;
86
+ onInit?: (model: ComponentModel<TStruct>) => void;
87
+ onLayout?: (model: ComponentModel<TStruct>) => void;
88
+ onReady?: (model: ComponentModel<TStruct>) => void;
89
+ onLayoutDestroy?: (model: ComponentModel<TStruct>) => void;
90
+ onDestroy?: (model: ComponentModel<TStruct>) => void;
91
+ onError?: (model: ComponentModel<TStruct>, error: any) => void;
92
+ } & {
93
+ [P in keyof TStruct['props'] as `${typeof $ON_GET}${Capitalize<P & string>}`]?: () => TStruct['props'][P];
94
+ } & {
95
+ [P in keyof TStruct['props'] as `${typeof $ON_CHANGING}${Capitalize<P & string>}`]?: ValueChangingHandler<TStruct['props']>;
96
+ } & {
97
+ [P in keyof TStruct['props'] as `${typeof $ON_CHANGE}${Capitalize<P & string>}`]?: ValueChangeHandler<TStruct['props']>;
98
+ };
99
+ type ComponentViewProps = {
100
+ render?: boolean;
101
+ } & PropsWithChildren;
102
+ type ComponentViewImplFn<TStruct extends ComponentStruct> = (props: ComponentViewProps, model?: ComponentModel<TStruct>) => ReactNode;
103
+ type ComponentViewFn = (props: ComponentViewProps) => ReactNode;
104
+ export type Component<TStruct extends ComponentStruct> = {
105
+ name?: string;
106
+ props?: TStruct['props'];
107
+ methods?: TStruct['methods'];
108
+ children?: ComponentChildren<TStruct['children']>;
109
+ events?: ComponentEvents<TStruct>;
110
+ msgBroker?: MsgBusBroker<Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>>, Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>>>;
111
+ msgBus?: MsgBus<Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']> | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']> | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>>>;
112
+ view?: ComponentViewImplFn<TStruct>;
113
+ };
114
+ type ComponentChildren<TRefStruct extends ComponentRefStruct> = {
115
+ [P in keyof TRefStruct]: TRefStruct[P] extends (params: infer TParams) => infer T ? T extends ComponentStruct ? (params: TParams) => ComponentModel<T> : never : TRefStruct[P] extends ComponentStruct ? ComponentModel<TRefStruct[P]> : never;
116
+ };
117
+ type ComponentModelChildren<TRefStruct extends ComponentRefStruct> = {
118
+ [P in keyof TRefStruct as TRefStruct[P] extends Function ? `${Capitalize<P & string>}` : P]: TRefStruct[P] extends (params: infer TParams) => infer T ? T extends ComponentStruct ? FC<ComponentParams<T> & TParams> : never : TRefStruct[P] extends ComponentStruct ? ComponentModel<TRefStruct[P]> : never;
119
+ };
120
+ export type ComponentModelContext = {
121
+ bindings?: Map<PropKey, IBinding>;
122
+ id: string;
123
+ };
124
+ export type ComponentModelBase<TStruct extends ComponentStruct = ComponentStruct> = {
125
+ readonly msgBus?: MsgBus<Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']> | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']> | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>>>;
126
+ readonly View: ComponentViewFn;
127
+ $: ComponentModelContext;
128
+ };
129
+ export type ComponentModel<TStruct extends ComponentStruct = ComponentStruct> = TStruct['props'] & TStruct['methods'] & ComponentModelChildren<TStruct['children']> & ComponentModelBase<TStruct>;
130
+ type PropKey = string | symbol;
131
+ export type ComponentParams<TStruct extends ComponentStruct = ComponentStruct> = ComponentPropParams<TStruct['props']> & ComponentEvents<TStruct>;
132
+ export declare function toHtmlId(url: string, segmentsCount?: number): string;
133
+ export declare function useComponent<TStruct extends ComponentStruct = ComponentStruct>(component: Component<TStruct>, params: ComponentParams<TStruct>): ComponentModel<TStruct>;
134
+ export declare function getFC<TStruct extends ComponentStruct>(factory: (params: ComponentParams<TStruct>) => ComponentModel<TStruct>): FC<ComponentParams<TStruct>>;
135
+ export {};
136
+ //# sourceMappingURL=componentModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentModel.d.ts","sourceRoot":"","sources":["../../src/componentModel/componentModel.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAA8B,EAAE,EAAE,SAAS,EAAE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CAAC,OAAO,CAAC,GAC5F,OAAO,CAAC,SAAS,CAAC,GAClB,sBAAsB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAC3C,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAUhC,KAAK,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAO/B,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,eAAe,GAAG,eAAe,IACzE,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AA6FrE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,GAAE,MAAU,GAAG,MAAM,CAgBvE;AAgPD,wBAAgB,YAAY,CAAC,OAAO,SAAS,eAAe,GAAG,eAAe,EAC1E,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,EAC7B,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,GACjC,cAAc,CAAC,OAAO,CAAC,CAkDzB;AAGD,wBAAgB,KAAK,CAAC,OAAO,SAAS,eAAe,EACjD,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,cAAc,CAAC,OAAO,CAAC,GACvE,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAU9B"}
@@ -1,11 +1,10 @@
1
- import { useLayoutEffect as k, useEffect as B } from "react";
2
- import { observer as R } from "mobx-react-lite";
3
- import { observable as P, runInAction as E } from "mobx";
4
- import { useLazyRef as G } from "../reactHooks.es.js";
5
- const O = {
6
- $isBinding: Symbol("$isBinding")
7
- };
8
- class $ {
1
+ import v, { useLayoutEffect as R, useEffect as F } from "react";
2
+ import { observer as D } from "mobx-react-lite";
3
+ import { observable as G, runInAction as S } from "mobx";
4
+ import { useLazyRef as L } from "../reactHooks.es.js";
5
+ import { getGlobalFlags as O } from "../globals.es.js";
6
+ const I = Symbol("$isBinding");
7
+ class B {
9
8
  // getter
10
9
  get;
11
10
  // setter
@@ -13,170 +12,211 @@ class $ {
13
12
  converter;
14
13
  validator;
15
14
  readOnly;
16
- constructor(t, o, i, l) {
17
- this.get = t, this.set = o, this.converter = i, this.validator = l, this.readOnly = !!o, this[O.$isBinding] = !0;
15
+ constructor(r, o, n, l) {
16
+ this.get = r, this.set = o, this.converter = n, this.validator = l, this.readOnly = !!o, this[I] = !0;
18
17
  }
19
- [O.$isBinding];
18
+ [I];
20
19
  }
21
- function w(e) {
22
- return e[O.$isBinding] === !0;
20
+ function z(e) {
21
+ return e[I] === !0;
23
22
  }
24
- function V(e, t, o, i) {
25
- return new $(e, t, o, i);
23
+ function Q(e, r, o, n) {
24
+ return new B(e, r, o, n);
26
25
  }
27
- function _(e, t) {
28
- return new $(
29
- () => e[t],
26
+ function W(e, r) {
27
+ return new B(
28
+ () => e()[r],
30
29
  (o) => {
31
- e[t] = o;
30
+ e()[r] = o;
32
31
  }
33
32
  );
34
33
  }
35
- const j = "onGet", I = "onChanging", L = "onChange";
36
- function N(e, t, o) {
37
- const i = o.onPropChanging, l = o.onPropChange;
34
+ const A = "onGet", _ = "onChanging", M = "onChange";
35
+ function H(e, r, o) {
36
+ const n = o.onPropChanging, l = o.onPropChange;
38
37
  return new Proxy(e, {
39
- get(c, u, g) {
40
- const C = o[u]?.onGet;
41
- if (C)
42
- return C();
43
- const a = t.get(String(u));
44
- return a ? a.get() : Reflect.get(c, u, g);
38
+ get(i, g, c) {
39
+ const y = o[g]?.onGet;
40
+ if (y)
41
+ return y();
42
+ const h = r.get(String(g));
43
+ if (h) {
44
+ let b;
45
+ return b = h.get(), b;
46
+ }
47
+ return Reflect.get(i, g, c);
45
48
  },
46
- set(c, u, g, C) {
47
- const a = c[u], y = o[u]?.onChanging;
48
- if (y && !y(a, g) || i && !i(u, a, g))
49
+ set(i, g, c, y) {
50
+ const h = i[g], b = o[g]?.onChanging;
51
+ if (b && !b(h, c) || n && !n(g, h, c))
49
52
  return !0;
50
- const b = E(() => Reflect.set(c, u, g, C)), n = t.get(u);
51
- n?.set && n.set(g);
52
- const r = o[u]?.onChange;
53
- return r && r(g), l && l(u, g), b;
53
+ const P = S(() => Reflect.set(i, g, c, y)), C = r.get(g);
54
+ C?.set && C.set(c);
55
+ const $ = o[g]?.onChange;
56
+ return $ && $(c), l && l(g, c), P;
54
57
  }
55
58
  });
56
59
  }
57
- function v(e) {
60
+ function k(e) {
58
61
  return e.replace(/^./, e[0].toUpperCase());
59
62
  }
60
- function S(e, t) {
61
- const o = e.msgBus, i = e.view, l = R((n) => typeof i == "function" ? i(n) : /* @__PURE__ */ React.createElement(React.Fragment, null, n.children));
62
- let c = {
63
+ const E = {
64
+ sources: /* @__PURE__ */ new Map(),
65
+ count: 0
66
+ };
67
+ function V(e, r = 1) {
68
+ return e.split(/[?#]/)[0].split("/").filter(Boolean).map((c) => decodeURIComponent(c)).slice(-r).join("-").normalize("NFKD").replace(/[^a-zA-Z0-9\-_:.+#]/g, "-").replace(/-+/g, "-").replace(/^[^a-zA-Z]+/, "-").replace(/[+#]$/, "-");
69
+ }
70
+ function U(e = 2) {
71
+ const o = new Error().stack?.split(`
72
+ `);
73
+ if (!o || o.length <= e) return null;
74
+ const n = o[e].match(/\((.*):\d+:\d+\)/);
75
+ return n ? n[1] : null;
76
+ }
77
+ function Z(e, r) {
78
+ const o = e.msgBus, n = /* @__PURE__ */ new Map(), l = e.view;
79
+ let i;
80
+ const g = D((t) => {
81
+ try {
82
+ return O().debug && console.debug(`${i.$.id}>view`), typeof l == "function" ? l(t, i) : /* @__PURE__ */ v.createElement(v.Fragment, null, t.children);
83
+ } catch (s) {
84
+ const u = JSON.stringify(s);
85
+ return /* @__PURE__ */ v.createElement(v.Fragment, null, u);
86
+ } finally {
87
+ }
88
+ });
89
+ let c;
90
+ const y = E.sources, h = U(6), b = V(h, 2);
91
+ y.has(h) ? (c = y.get(h), c.count++) : (c = {
92
+ structId: e.name || b || `Component_${E.count}`,
93
+ count: 0
94
+ }, y.set(h, c), E.count++);
95
+ const P = `${c.structId}#${c.count}`;
96
+ if (i = {
63
97
  ...e.props,
64
98
  ...e.methods,
65
99
  // view: component.view,
66
- // View: ViewerFC,
67
- View: l,
68
- msgBus: o
69
- };
70
- if (e.children)
71
- for (const [n, r] of Object.entries(e.children))
72
- if (typeof r == "function") {
73
- const s = (h) => {
74
- const f = r(h);
75
- return /* @__PURE__ */ React.createElement(f.View, null);
100
+ View: g,
101
+ msgBus: o,
102
+ $: {
103
+ bindings: n,
104
+ id: P
105
+ }
106
+ }, e.children)
107
+ for (const [t, s] of Object.entries(e.children))
108
+ if (typeof s == "function") {
109
+ const u = s, d = (f) => {
110
+ const a = u(f);
111
+ return /* @__PURE__ */ v.createElement(a.View, null);
76
112
  };
77
- Reflect.set(c, v(n), s);
113
+ Reflect.set(i, k(t), d);
78
114
  } else
79
- Reflect.set(c, n, r);
115
+ Reflect.set(i, t, s);
80
116
  if (e.msgBroker) {
81
- const n = e.msgBroker.provide;
82
- if (n)
83
- for (const [s, h] of Object.entries(n))
84
- for (const [f, d] of Object.entries(h))
117
+ const t = e.msgBroker.provide;
118
+ if (t)
119
+ for (const [u, d] of Object.entries(t))
120
+ for (const [f, a] of Object.entries(d))
85
121
  o.provide({
86
- ...d,
87
- channel: s,
122
+ ...a,
123
+ channel: u,
88
124
  group: f
89
125
  });
90
- const r = e.msgBroker.subscribe;
91
- if (r)
92
- for (const [s, h] of Object.entries(r))
93
- for (const [f, d] of Object.entries(h))
126
+ const s = e.msgBroker.subscribe;
127
+ if (s)
128
+ for (const [u, d] of Object.entries(s))
129
+ for (const [f, a] of Object.entries(d))
94
130
  o.on({
95
- ...d,
96
- channel: s,
131
+ ...a,
132
+ channel: u,
97
133
  group: f
98
134
  });
99
135
  }
100
- const u = /* @__PURE__ */ new Map();
101
- for (const [n, r] of Object.entries(t))
102
- w(r) ? u.set(n, r) : Reflect.set(c, n, r);
103
- const g = {};
136
+ for (const [t, s] of Object.entries(r))
137
+ z(s) ? n.set(t, s) : Reflect.set(i, t, s);
138
+ const C = {};
104
139
  if (e.props)
105
- for (const n of Object.keys(e.props))
106
- g[n] = P.ref;
140
+ for (const t of Object.keys(e.props))
141
+ C[t] = G.ref;
107
142
  if (e.methods)
108
- for (const n of Object.keys(e.methods))
109
- g[n] = !1;
110
- g.View = !1, g.msgBus = !1;
111
- const C = {
112
- onPropChanging: t?.onPropChanging || e.events?.onPropChanging ? (n, r, s) => {
113
- let h = !0, f = t.onPropChanging;
114
- return f && (h = f(String(n), r, s)), h && (f = e.events?.onPropChanging, f && (h = f(String(n), r, s))), h;
143
+ for (const t of Object.keys(e.methods))
144
+ C[t] = !1;
145
+ if (e.children)
146
+ for (const t of Object.keys(e.children))
147
+ C[t] = !1;
148
+ C.View = !1, C.msgBus = !1, C.$ = !1;
149
+ const $ = {
150
+ onPropChanging: r?.onPropChanging || e.events?.onPropChanging ? (t, s, u) => {
151
+ let d = !0, f = r.onPropChanging;
152
+ return f && (d = f(String(t), s, u)), d && (f = e.events?.onPropChanging, f && (d = f(String(t), s, u))), d;
115
153
  } : void 0,
116
- onPropChange: t?.onPropChange || e.events?.onPropChange ? (n, r) => {
117
- t.onPropChange?.(String(n), r), e.events.onPropChange?.(String(n), r);
154
+ onPropChange: r?.onPropChange || e.events?.onPropChange ? (t, s) => {
155
+ r.onPropChange?.(String(t), s), e.events.onPropChange?.(String(t), s);
118
156
  } : void 0
119
157
  };
120
- function a(n) {
121
- const r = `${j}${v(n)}`;
122
- return t[r] || e.events[r];
158
+ function w(t) {
159
+ const s = `${A}${k(t)}`;
160
+ return r[s] || e.events?.[s];
123
161
  }
124
- function y(n) {
125
- const r = `${I}${v(n)}`;
126
- return ((s, h) => {
127
- let f = !0, d = t[r];
128
- return d && (f = d(s, h)), f && (d = e.events[r], d && (f = d(s, h))), f;
162
+ function N(t) {
163
+ const s = `${_}${k(t)}`;
164
+ return ((u, d) => {
165
+ let f = !0, a = r[s];
166
+ return a && (f = a(u, d)), f && (a = e.events[s], a && (f = a(u, d))), f;
129
167
  });
130
168
  }
131
- function b(n) {
132
- const r = `${L}${v(n)}`;
133
- return ((s) => {
134
- t[r]?.(s), e.events[r]?.(s);
169
+ function j(t) {
170
+ const s = `${M}${k(t)}`;
171
+ return ((u) => {
172
+ r[s]?.(u), e.events[s]?.(u);
135
173
  });
136
174
  }
137
175
  if (e.props)
138
- for (const n of Object.keys(e.props))
139
- C[n] = {
140
- onGet: a(n),
141
- onChanging: y(n),
142
- onChange: b(n)
176
+ for (const t of Object.keys(e.props))
177
+ $[t] = {
178
+ onGet: w(t),
179
+ onChanging: N(t),
180
+ onChange: j(t)
143
181
  };
144
- return c = P(c, g), c = N(c, u, C), e.events?.onInit && e.events.onInit(c), t?.onInit && t.onInit(c), c;
182
+ return i = G(i, C, {
183
+ deep: !0
184
+ }), i = H(i, n, $), e.events?.onInit && e.events.onInit(i), r?.onInit && r.onInit(i), i;
145
185
  }
146
- function z(e, t) {
147
- const o = G(() => S(e, t)), i = o.current;
148
- return k(() => {
186
+ function X(e, r) {
187
+ const o = L(() => Z(e, r)), n = o.current;
188
+ return R(() => {
149
189
  try {
150
- e.events?.onLayout?.(i), t?.onLayout?.(i);
190
+ O().debug && console.debug(`${n.$.id}>layout`), e.events?.onLayout?.(n), r?.onLayout?.(n);
151
191
  } catch (l) {
152
- e.events?.onError?.(i, l), t?.onError?.(i, l);
192
+ e.events?.onError?.(n, l), r?.onError?.(n, l);
153
193
  }
154
194
  return () => {
155
- e.events?.onLayoutDestroy?.(i), t?.onLayoutDestroy?.(i), o.current = null;
195
+ O().debug && console.debug(`${n.$.id}>layout-destroy`), e.events?.onLayoutDestroy?.(n), r?.onLayoutDestroy?.(n), o.current = null;
156
196
  };
157
- }, []), B(() => {
197
+ }, []), F(() => {
158
198
  try {
159
- e.events?.onReady?.(i), t?.onReady?.(i);
199
+ O().debug && console.debug(`${n.$.id}>ready`), e.events?.onReady?.(n), r?.onReady?.(n);
160
200
  } catch (l) {
161
- e.events?.onError?.(i, l), t?.onError?.(i, l);
201
+ O().debug && console.debug(`${n.$.id}>destroy`), e.events?.onError?.(n, l), r?.onError?.(n, l);
162
202
  }
163
203
  return () => {
164
- e.events?.onDestroy?.(i), t?.onDestroy?.(i);
204
+ e.events?.onDestroy?.(n), r?.onDestroy?.(n);
165
205
  };
166
206
  }, []), o.current;
167
207
  }
168
- function H(e) {
208
+ function Y(e) {
169
209
  return (o) => {
170
- const i = e(o);
171
- return /* @__PURE__ */ React.createElement(i.View, { ...o });
210
+ const n = e(o);
211
+ return /* @__PURE__ */ v.createElement(n.View, { ...o });
172
212
  };
173
213
  }
174
214
  export {
175
- V as bind,
176
- _ as bindProp,
177
- H as getFC,
178
- w as isBinding,
179
- O as symbols,
180
- z as useComponent
215
+ Q as bind,
216
+ W as bindProp,
217
+ Y as getFC,
218
+ z as isBinding,
219
+ V as toHtmlId,
220
+ X as useComponent
181
221
  };
182
222
  //# sourceMappingURL=componentModel.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"componentModel.es.js","sources":["../../src/componentModel/componentModel.tsx"],"sourcesContent":["import { PropsWithChildren, useEffect, useLayoutEffect, FC, ReactNode } from 'react';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport {\r\n $CG_IN,\r\n $CG_OUT,\r\n MsgBus,\r\n MsgBusProviderParams,\r\n MsgBusStruct,\r\n MsgBusSubscriberParams,\r\n} from '@actdim/msgmesh/msgBusCore';\r\nimport { MaybePromise, SafeKey, Skip } from '@actdim/utico/typeCore';\r\nimport { observer } from 'mobx-react-lite';\r\nimport { observable, runInAction } from 'mobx';\r\nimport { useLazyRef } from '@/reactHooks';\r\n\r\nexport type MsgBusChannelGroupProviderParams<\r\n TStruct extends MsgBusStruct = MsgBusStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n> = Skip<MsgBusProviderParams<TStruct, TChannel, TGroup>, 'channel' | 'group'>;\r\n\r\nexport type MsgBusChannelGroupSubscriberParams<\r\n TStruct extends MsgBusStruct = MsgBusStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n> = Skip<MsgBusSubscriberParams<TStruct, TChannel, TGroup>, 'channel' | 'group'>;\r\n\r\n// MsgBusScope\r\nexport type MsgBusBrokerScope<\r\n TStruct extends MsgBusStruct /*= MsgBusStruct*/,\r\n TKeysToProvide extends keyof TStruct = keyof TStruct,\r\n TKeysToSubscribe extends keyof TStruct = keyof TStruct,\r\n TKeysToPublish extends keyof TStruct = keyof TStruct,\r\n> = {\r\n provide?: TKeysToProvide;\r\n // consume\r\n subscribe?: TKeysToSubscribe;\r\n // produce\r\n publish?: TKeysToPublish;\r\n};\r\n\r\nexport type ComponentPropStruct = Record<string, any>;\r\n// export type ComponentPropStruct = {\r\n// [prop: string]: any;\r\n// };\r\n\r\nexport type ComponentMethodStruct = Record<string, Function>;\r\n// export type ComponentMethodStruct = {\r\n// [action: string]: Function;\r\n// };\r\n\r\n// export type ComponentRefStruct = Record<string, ComponentStruct<TMsgBusStruct, T>>;\r\nexport type ComponentRefStruct = {\r\n [name: string]: ComponentStruct | ((params: any) => ComponentStruct);\r\n};\r\n\r\nexport type ComponentStructBase<\r\n TMsgBusStruct extends MsgBusStruct = MsgBusStruct,\r\n TPropStruct extends ComponentPropStruct = ComponentPropStruct,\r\n TMsgScope extends MsgBusBrokerScope<TMsgBusStruct> = MsgBusBrokerScope<TMsgBusStruct>,\r\n> = {\r\n props?: TPropStruct;\r\n methods?: ComponentMethodStruct;\r\n children?: ComponentRefStruct;\r\n msgScope?: TMsgScope;\r\n};\r\n\r\n// ComponentShape\r\nexport type ComponentStruct<\r\n TMsgBusStruct extends MsgBusStruct = MsgBusStruct,\r\n T extends ComponentStructBase<TMsgBusStruct> = ComponentStructBase<TMsgBusStruct>,\r\n> = T & {\r\n msgBus: TMsgBusStruct;\r\n};\r\n\r\nexport type MsgBusBroker<\r\n TStructToProvide extends MsgBusStruct = MsgBusStruct,\r\n TStructToSubscribe extends MsgBusStruct = MsgBusStruct,\r\n> = {\r\n // providers\r\n provide?: {\r\n [TChannel in keyof TStructToProvide]: {\r\n [TGroup in keyof Skip<\r\n TStructToProvide[TChannel],\r\n typeof $CG_OUT\r\n >]?: MsgBusChannelGroupProviderParams<TStructToProvide, TChannel, TGroup>;\r\n };\r\n };\r\n // subscribers\r\n subscribe?: {\r\n [TChannel in keyof TStructToSubscribe]: {\r\n [TGroup in keyof TStructToSubscribe[TChannel]]?: MsgBusChannelGroupSubscriberParams<\r\n TStructToSubscribe,\r\n TChannel,\r\n TGroup\r\n >;\r\n };\r\n };\r\n};\r\n\r\ntype ValueConverter<TTo, TFrom> = {\r\n // ConvertFrom\r\n convert(value: TFrom): TTo;\r\n // ConvertTo\r\n convertBack(value: TTo): TFrom;\r\n};\r\n\r\ntype ValidationResult = {\r\n valid: boolean;\r\n message: string;\r\n};\r\n\r\ntype Validator<T> = {\r\n options: {\r\n blur: boolean;\r\n };\r\n validate: (value: T) => MaybePromise<ValidationResult>;\r\n};\r\n\r\nexport const symbols = {\r\n $isBinding: Symbol('$isBinding'),\r\n};\r\n\r\nexport interface IBinding<T = any, TFrom = any> {\r\n // getter\r\n readonly get: () => T;\r\n // setter\r\n readonly set: (value: T) => void;\r\n readonly converter: ValueConverter<T, TFrom>;\r\n readonly validator: Validator<T>;\r\n readonly readOnly: boolean;\r\n [symbols.$isBinding]: boolean;\r\n}\r\n\r\nclass Binding<T = any, TFrom = any> implements IBinding<any, any> {\r\n // getter\r\n readonly get: () => T;\r\n // setter\r\n readonly set: (value: T) => void;\r\n readonly converter: ValueConverter<T, TFrom>;\r\n readonly validator: Validator<T>;\r\n readonly readOnly: boolean;\r\n constructor(\r\n get: () => T,\r\n set?: (value: T) => void,\r\n converter?: ValueConverter<T, TFrom>,\r\n validator?: Validator<T>\r\n ) {\r\n this.get = get;\r\n this.set = set;\r\n this.converter = converter;\r\n this.validator = validator;\r\n this.readOnly = !!set;\r\n this[symbols.$isBinding] = true;\r\n }\r\n [symbols.$isBinding]: boolean;\r\n}\r\n\r\nexport function isBinding(obj: any): obj is IBinding {\r\n return obj[symbols.$isBinding] === true;\r\n}\r\n\r\nexport function bind<T, TFrom = any>(\r\n get: () => T,\r\n set?: (value: T) => void,\r\n converter?: ValueConverter<T, TFrom>,\r\n validator?: Validator<T>\r\n) {\r\n return new Binding(get, set, converter, validator);\r\n}\r\n\r\nexport function bindProp<T extends object, P extends keyof T>(obj: T, prop: P) {\r\n return new Binding(\r\n () => obj[prop],\r\n (value: T[P]) => {\r\n obj[prop] = value;\r\n }\r\n );\r\n}\r\n\r\nexport type ComponentPropSource<T> = T | Binding<T>;\r\n\r\nexport type ComponentPropParams<TPropStruct extends ComponentPropStruct> = {\r\n [P in keyof TPropStruct]?: ComponentPropSource<TPropStruct[P]>;\r\n};\r\n\r\n// const $ON_PROP_CHANGING = \"onPropChanging\";\r\n// const $ON_PROP_CHANGE = \"onPropChange\";\r\n\r\nconst $ON_GET = 'onGet';\r\n// const $ON_BEFORE_SET = \"onBeforeSet\";\r\nconst $ON_CHANGING = 'onChanging';\r\nconst $ON_CHANGE = 'onChange';\r\n// const $ON_SET = \"onSet\";\r\n\r\ntype PropValueChangingHandler<TProp = PropKey> = (\r\n prop: TProp,\r\n oldValue: any,\r\n newValue: any\r\n) => boolean;\r\ntype PropValueChangeHandler<TProp = PropKey> = (prop: TProp, value: any) => void;\r\n\r\n// BeforeValueSetHandler\r\ntype ValueChangingHandler<T = any> = (oldValue: T, newValue: T) => boolean;\r\n// ValueSetHandler\r\ntype ValueChangeHandler<T = any> = (value: T) => void;\r\n\r\ntype ComponentEvents<TStruct extends ComponentStruct = ComponentStruct> = {\r\n onPropChanging?: PropValueChangingHandler<keyof TStruct['props']>;\r\n onPropChange?: PropValueChangeHandler<keyof TStruct['props']>;\r\n onInit?: (model: ComponentModel<TStruct>) => void;\r\n onLayout?: (model: ComponentModel<TStruct>) => void;\r\n onReady?: (model: ComponentModel<TStruct>) => void;\r\n onLayoutDestroy?: (model: ComponentModel<TStruct>) => void; // onLayoutCleanup\r\n onDestroy?: (model: ComponentModel<TStruct>) => void; // onDispose/onCleanup\r\n onError?: (model: ComponentModel<TStruct>, error: any) => void;\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_GET}${Capitalize<P & string>}`]?: () => TStruct['props'][P];\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_CHANGING}${Capitalize<P & string>}`]?: ValueChangingHandler<\r\n TStruct['props']\r\n >;\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_CHANGE}${Capitalize<P & string>}`]?: ValueChangeHandler<\r\n TStruct['props']\r\n >;\r\n};\r\n\r\n// AllHTMLAttributes<JSX.Element>\r\n\r\n// type ComponentViewerProps = {\r\n// render?: boolean;\r\n// view?: () => ReactNode;\r\n// } & PropsWithChildren;\r\n\r\ntype ComponentViewProps = {\r\n render?: boolean;\r\n} & PropsWithChildren;\r\n\r\ntype ComponentViewFn = (props?: ComponentViewProps) => ReactNode; // JSX.Element\r\n\r\ntype PublicKeys<T> = {\r\n [K in keyof T]: K extends `_${string}` ? never : K;\r\n}[keyof T];\r\n\r\nexport type Component<TStruct extends ComponentStruct> = {\r\n props?: TStruct['props'];\r\n methods?: TStruct['methods'];\r\n children?: ComponentChildren<TStruct['children']>;\r\n events?: ComponentEvents<TStruct>;\r\n // msgs?\r\n msgBroker?: MsgBusBroker<\r\n Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>>,\r\n Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>>\r\n >;\r\n msgBus?: MsgBus<\r\n // TStruct[\"msgBus\"]\r\n Pick<\r\n TStruct['msgBus'],\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>\r\n >\r\n >;\r\n view?: ComponentViewFn;\r\n};\r\n\r\ntype ComponentChildren<TRefStruct extends ComponentRefStruct> = {\r\n [P in keyof TRefStruct]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? (params: TParams) => ComponentModel<T>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? ComponentModel<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\ntype ComponentModelChildren<TRefStruct extends ComponentRefStruct> = {\r\n [P in keyof TRefStruct as TRefStruct[P] extends Function\r\n ? `${Capitalize<P & string>}`\r\n : P]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? FC<ComponentParams<T> & TParams>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? ComponentModel<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\nexport type ComponentModelBase<TStruct extends ComponentStruct = ComponentStruct> = {\r\n readonly msgBus?: MsgBus<\r\n // TStruct[\"msgBus\"]\r\n Pick<\r\n TStruct['msgBus'],\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>\r\n >\r\n >;\r\n\r\n readonly View: ComponentViewFn;\r\n};\r\n\r\nexport type ComponentModel<TStruct extends ComponentStruct = ComponentStruct> = TStruct['props'] &\r\n TStruct['methods'] &\r\n ComponentModelChildren<TStruct['children']> &\r\n ComponentModelBase<TStruct>;\r\n\r\n// style: CSSProperties;\r\n\r\ntype PropEventHandlers = {\r\n onGet?: () => any;\r\n onChanging?: (oldValue: any, newValue: any) => boolean;\r\n onChange?: (value: any) => void;\r\n};\r\n\r\ntype PropKey = string | symbol;\r\ntype ProxyEventHandlers = {\r\n onPropChanging?: PropValueChangingHandler<PropKey>;\r\n onPropChange?: PropValueChangeHandler<PropKey>;\r\n} & Record<PropKey, PropEventHandlers>;\r\n\r\n// ComponentConfig\r\nexport type ComponentParams<TStruct extends ComponentStruct = ComponentStruct> =\r\n ComponentPropParams<TStruct['props']> & ComponentEvents<TStruct>; // & PropsWithChildren\r\n\r\nconst blankView = () => null;\r\n\r\nfunction createProxy(\r\n state: any,\r\n bindings: Map<PropKey, IBinding>,\r\n proxyEventHandlers: ProxyEventHandlers\r\n) {\r\n const onPropChanging = proxyEventHandlers.onPropChanging;\r\n const onPropChange = proxyEventHandlers.onPropChange;\r\n return new Proxy(state, {\r\n get(obj, prop, receiver) {\r\n const onGet = proxyEventHandlers[prop]?.onGet;\r\n if (onGet) {\r\n return onGet();\r\n }\r\n const binding = bindings.get(String(prop));\r\n if (binding) {\r\n return binding.get();\r\n }\r\n return Reflect.get(obj, prop, receiver);\r\n },\r\n set(obj, prop, value, receiver) {\r\n const oldValue = obj[prop];\r\n\r\n const onChanging = proxyEventHandlers[prop]?.onChanging;\r\n if (onChanging) {\r\n const shouldChange = onChanging(oldValue, value);\r\n if (!shouldChange) {\r\n return true;\r\n }\r\n }\r\n\r\n if (onPropChanging) {\r\n const shouldChange = onPropChanging(prop, oldValue, value);\r\n if (!shouldChange) {\r\n return true;\r\n }\r\n }\r\n\r\n const result = runInAction(() => {\r\n return Reflect.set(obj, prop, value, receiver);\r\n });\r\n\r\n const binding = bindings.get(prop);\r\n\r\n if (binding?.set) {\r\n binding.set(value);\r\n }\r\n\r\n const onChange = proxyEventHandlers[prop]?.onChange;\r\n if (onChange) {\r\n onChange(value);\r\n }\r\n\r\n if (onPropChange) {\r\n onPropChange(prop, value);\r\n }\r\n\r\n return result;\r\n },\r\n });\r\n}\r\n\r\nfunction capitalize(name: string) {\r\n return name.replace(/^./, name[0].toUpperCase());\r\n}\r\n\r\nfunction asyncToGeneratorFlow(asyncFn: (...args: any[]) => Promise<any>) {\r\n return function* (...args: any[]) {\r\n const result = yield asyncFn(...args);\r\n return result;\r\n };\r\n}\r\n\r\n// const ViewerFC = observer((props: ComponentViewerProps) => {\r\n// if (typeof props.view === \"function\") {\r\n// return props.view();\r\n// }\r\n// return <>{props.children}</>;\r\n// });\r\n\r\nfunction createModel<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n params: ComponentParams<TStruct>\r\n): ComponentModel<TStruct> {\r\n const msgBus = component.msgBus;\r\n const view = component.view;\r\n\r\n const ViewFC = observer((props: ComponentViewProps) => {\r\n if (typeof view === 'function') {\r\n return view(props);\r\n }\r\n return <>{props.children}</>;\r\n });\r\n\r\n let model: ComponentModel<TStruct> = {\r\n ...component.props,\r\n ...component.methods,\r\n // view: component.view,\r\n // View: ViewerFC,\r\n View: ViewFC,\r\n msgBus: msgBus,\r\n };\r\n if (component.children) {\r\n for (const [key, value] of Object.entries(component.children)) {\r\n if (typeof value == 'function') {\r\n // observer\r\n const ChildViewFC: ComponentViewFn = (props) => {\r\n const model = value(props) as ComponentModel;\r\n return <model.View />;\r\n // if (typeof model.view === \"function\") {\r\n // return model.view(props);\r\n // }\r\n // return <>{props.children}</>;\r\n // return <ViewerFC view={model.view} />;\r\n };\r\n Reflect.set(model, capitalize(key), ChildViewFC);\r\n } else {\r\n Reflect.set(model, key, value);\r\n }\r\n }\r\n }\r\n if (component.msgBroker) {\r\n const providers = component.msgBroker.provide;\r\n if (providers) {\r\n for (const [channel, providerGroups] of Object.entries(providers)) {\r\n for (const [group, provider] of Object.entries(providerGroups)) {\r\n msgBus.provide({\r\n ...provider,\r\n channel: channel,\r\n group: group,\r\n });\r\n }\r\n }\r\n }\r\n const subscribers = component.msgBroker.subscribe;\r\n if (subscribers) {\r\n for (const [channel, subscriberGroups] of Object.entries(subscribers)) {\r\n for (const [group, subscriber] of Object.entries(subscriberGroups)) {\r\n msgBus.on({\r\n ...subscriber,\r\n channel: channel,\r\n group: group,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n const bindings = new Map<PropKey, IBinding>();\r\n // Reflect.ownKeys\r\n for (const [key, value] of Object.entries(params)) {\r\n if (isBinding(value)) {\r\n bindings.set(key, value);\r\n } else {\r\n Reflect.set(model, key, value);\r\n }\r\n }\r\n\r\n // decorators\r\n const annotationMap: Record<string, any> = {};\r\n\r\n if (component.props) {\r\n for (const key of Object.keys(component.props)) {\r\n annotationMap[key] = observable.ref;\r\n }\r\n }\r\n if (component.methods) {\r\n for (const key of Object.keys(component.methods)) {\r\n annotationMap[key] = false;\r\n }\r\n }\r\n\r\n annotationMap['View' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n annotationMap['msgBus' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n // annotationMap[\"view\" satisfies keyof Component<TStruct>] = false;\r\n\r\n const proxyEventHandlers: Pick<ProxyEventHandlers, 'onPropChanging' | 'onPropChange'> = {\r\n onPropChanging:\r\n params?.onPropChanging || component.events?.onPropChanging\r\n ? (prop, oldValue, newValue) => {\r\n let result = true;\r\n let handler = params.onPropChanging;\r\n if (handler) {\r\n result = handler(String(prop), oldValue, newValue);\r\n }\r\n if (result) {\r\n handler = component.events?.onPropChanging;\r\n if (handler) {\r\n result = handler(String(prop), oldValue, newValue);\r\n }\r\n }\r\n return result;\r\n }\r\n : undefined,\r\n onPropChange:\r\n params?.onPropChange || component.events?.onPropChange\r\n ? (prop, value) => {\r\n params.onPropChange?.(String(prop), value);\r\n component.events.onPropChange?.(String(prop), value);\r\n }\r\n : undefined,\r\n };\r\n\r\n function resolveOnGetEventHandler(prop: string) {\r\n const key = `${$ON_GET}${capitalize(prop)}`;\r\n return params[key] || component.events[key];\r\n }\r\n\r\n function resolveOnChangingEventHandler(prop: string) {\r\n const key = `${$ON_CHANGING}${capitalize(prop)}`;\r\n return ((oldValue: any, newValue: any) => {\r\n let result = true;\r\n let handler = params[key] as ValueChangingHandler<any>;\r\n if (handler) {\r\n result = handler(oldValue, newValue);\r\n }\r\n if (result) {\r\n handler = component.events[key] as ValueChangingHandler<any>;\r\n if (handler) {\r\n result = handler(oldValue, newValue);\r\n }\r\n }\r\n return result;\r\n }) as ValueChangingHandler;\r\n }\r\n\r\n function resolveOnChangeEventHandler(prop: string) {\r\n const key = `${$ON_CHANGE}${capitalize(prop)}`;\r\n return ((value: any) => {\r\n (params[key] as ValueChangeHandler<any>)?.(value);\r\n (component.events[key] as ValueChangeHandler<any>)?.(value);\r\n }) as ValueChangeHandler;\r\n }\r\n\r\n if (component.props) {\r\n for (const prop of Object.keys(component.props)) {\r\n proxyEventHandlers[prop] = {\r\n onGet: resolveOnGetEventHandler(prop),\r\n onChanging: resolveOnChangingEventHandler(prop),\r\n onChange: resolveOnChangeEventHandler(prop),\r\n };\r\n }\r\n }\r\n\r\n model = observable(model, annotationMap);\r\n\r\n model = createProxy(model, bindings, proxyEventHandlers);\r\n\r\n if (component.events?.onInit) {\r\n component.events.onInit(model);\r\n }\r\n\r\n if (params?.onInit) {\r\n params.onInit(model);\r\n }\r\n\r\n return model;\r\n}\r\n\r\nexport function useComponent<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n params: ComponentParams<TStruct>\r\n): ComponentModel<TStruct> {\r\n const ref = useLazyRef(() => createModel(component, params));\r\n const model = ref.current;\r\n\r\n useLayoutEffect(() => {\r\n try {\r\n component.events?.onLayout?.(model);\r\n params?.onLayout?.(model);\r\n } catch (err) {\r\n component.events?.onError?.(model, err);\r\n params?.onError?.(model, err);\r\n }\r\n\r\n return () => {\r\n component.events?.onLayoutDestroy?.(model);\r\n params?.onLayoutDestroy?.(model);\r\n // ref.current?.dispose();\r\n ref.current = null;\r\n };\r\n }, []);\r\n\r\n useEffect(() => {\r\n try {\r\n component.events?.onReady?.(model);\r\n params?.onReady?.(model);\r\n } catch (err) {\r\n component.events?.onError?.(model, err);\r\n params?.onError?.(model, err);\r\n }\r\n return () => {\r\n component.events?.onDestroy?.(model);\r\n params?.onDestroy?.(model);\r\n };\r\n }, []);\r\n\r\n return ref.current;\r\n}\r\n\r\n// asFC/toFC\r\nexport function getFC<TStruct extends ComponentStruct>(\r\n factory: (params: ComponentParams<TStruct>) => ComponentModel<TStruct>\r\n): FC<ComponentParams<TStruct>> {\r\n // observer\r\n const fc = (params: ComponentParams<TStruct> & PropsWithChildren) => {\r\n // modelHook\r\n const model = factory(params); // without useRef!\r\n // return model.view();\r\n return <model.View {...params} />;\r\n // return <ViewerFC {...params} view={model.view} />;\r\n };\r\n return fc;\r\n}\r\n"],"names":["symbols","Binding","get","set","converter","validator","isBinding","obj","bind","bindProp","prop","value","$ON_GET","$ON_CHANGING","$ON_CHANGE","createProxy","state","bindings","proxyEventHandlers","onPropChanging","onPropChange","receiver","onGet","binding","oldValue","onChanging","result","runInAction","onChange","capitalize","name","createModel","component","params","msgBus","view","ViewFC","observer","props","model","key","ChildViewFC","providers","channel","providerGroups","group","provider","subscribers","subscriberGroups","subscriber","annotationMap","observable","newValue","handler","resolveOnGetEventHandler","resolveOnChangingEventHandler","resolveOnChangeEventHandler","useComponent","ref","useLazyRef","useLayoutEffect","err","useEffect","getFC","factory"],"mappings":";;;;AAuHO,MAAMA,IAAU;AAAA,EACnB,YAAY,OAAO,YAAY;AACnC;AAaA,MAAMC,EAA4D;AAAA;AAAA,EAErD;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACT,YACIC,GACAC,GACAC,GACAC,GACF;AACE,SAAK,MAAMH,GACX,KAAK,MAAMC,GACX,KAAK,YAAYC,GACjB,KAAK,YAAYC,GACjB,KAAK,WAAW,CAAC,CAACF,GAClB,KAAKH,EAAQ,UAAU,IAAI;AAAA,EAC/B;AAAA,EACA,CAACA,EAAQ,UAAU;AACvB;AAEO,SAASM,EAAUC,GAA2B;AACjD,SAAOA,EAAIP,EAAQ,UAAU,MAAM;AACvC;AAEO,SAASQ,EACZN,GACAC,GACAC,GACAC,GACF;AACE,SAAO,IAAIJ,EAAQC,GAAKC,GAAKC,GAAWC,CAAS;AACrD;AAEO,SAASI,EAA8CF,GAAQG,GAAS;AAC3E,SAAO,IAAIT;AAAA,IACP,MAAMM,EA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ACtC5B,GAAQ,UAAUM,GAAOsB,CAAG;AAAA,IAChC;AAEA,WAAO,MAAM;AACT,MAAA7B,EAAU,QAAQ,kBAAkBO,CAAK,GACzCN,GAAQ,kBAAkBM,CAAK,GAE/BmB,EAAI,UAAU;AAAA,IAClB;AAAA,EACJ,GAAG,CAAA,CAAE,GAELI,EAAU,MAAM;AACZ,QAAI;AACA,MAAA9B,EAAU,QAAQ,UAAUO,CAAK,GACjCN,GAAQ,UAAUM,CAAK;AAAA,IAC3B,SAASsB,GAAK;AACV,MAAA7B,EAAU,QAAQ,UAAUO,GAAOsB,CAAG,GACtC5B,GAAQ,UAAUM,GAAOsB,CAAG;AAAA,IAChC;AACA,WAAO,MAAM;AACT,MAAA7B,EAAU,QAAQ,YAAYO,CAAK,GACnCN,GAAQ,YAAYM,CAAK;AAAA,IAC7B;AAAA,EACJ,GAAG,CAAA,CAAE,GAEEmB,EAAI;AACf;AAGO,SAASK,EACZC,GAC4B;AAS5B,SAPW,CAAC/B,MAAyD;AAEjE,UAAMM,IAAQyB,EAAQ/B,CAAM;AAE5B,WAAO,sBAAA,cAACM,EAAM,MAAN,EAAY,GAAGN,GAAQ;AAAA,EAEnC;AAEJ;"}
1
+ {"version":3,"file":"componentModel.es.js","sources":["../../src/componentModel/componentModel.tsx"],"sourcesContent":["import React, { ReactElement, useReducer, useRef, useState } from 'react';\r\nimport { PropsWithChildren, useEffect, useLayoutEffect, FC, ReactNode } from 'react';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport {\r\n $CG_IN,\r\n $CG_OUT,\r\n MsgBus,\r\n MsgBusProviderParams,\r\n MsgBusStruct,\r\n MsgBusSubscriberParams,\r\n} from '@actdim/msgmesh/msgBusCore';\r\nimport { MaybePromise, SafeKey, Skip } from '@actdim/utico/typeCore';\r\nimport { observer, useLocalObservable } from 'mobx-react-lite';\r\nimport { autorun, observable, reaction, runInAction, untracked } from 'mobx';\r\nimport { useLazyRef } from '@/reactHooks';\r\nimport { deepObserve } from 'mobx-utils';\r\nimport { getGlobalFlags } from '@/globals';\r\n\r\nexport type MsgBusChannelGroupProviderParams<\r\n TStruct extends MsgBusStruct = MsgBusStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n> = Skip<MsgBusProviderParams<TStruct, TChannel, TGroup>, 'channel' | 'group'>;\r\n\r\nexport type MsgBusChannelGroupSubscriberParams<\r\n TStruct extends MsgBusStruct = MsgBusStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n> = Skip<MsgBusSubscriberParams<TStruct, TChannel, TGroup>, 'channel' | 'group'>;\r\n\r\n// MsgBusScope\r\nexport type MsgBusBrokerScope<\r\n TStruct extends MsgBusStruct /*= MsgBusStruct*/,\r\n TKeysToProvide extends keyof TStruct = keyof TStruct,\r\n TKeysToSubscribe extends keyof TStruct = keyof TStruct,\r\n TKeysToPublish extends keyof TStruct = keyof TStruct,\r\n> = {\r\n provide?: TKeysToProvide;\r\n // consume\r\n subscribe?: TKeysToSubscribe;\r\n // produce\r\n publish?: TKeysToPublish;\r\n};\r\n\r\nexport type ComponentPropStruct = Record<string, any>;\r\n// export type ComponentPropStruct = {\r\n// [prop: string]: any;\r\n// };\r\n\r\nexport type ComponentMethodStruct = Record<string, Function>;\r\n// export type ComponentMethodStruct = {\r\n// [action: string]: Function;\r\n// };\r\n\r\n// export type ComponentRefStruct = Record<string, ComponentStruct<TMsgBusStruct, T>>;\r\nexport type ComponentRefStruct = {\r\n [name: string]: ComponentStruct | ((params: any) => ComponentStruct);\r\n};\r\n\r\nexport type ComponentStructBase<\r\n TMsgBusStruct extends MsgBusStruct = MsgBusStruct,\r\n TPropStruct extends ComponentPropStruct = ComponentPropStruct,\r\n TMsgScope extends MsgBusBrokerScope<TMsgBusStruct> = MsgBusBrokerScope<TMsgBusStruct>,\r\n> = {\r\n props?: TPropStruct;\r\n methods?: ComponentMethodStruct;\r\n children?: ComponentRefStruct;\r\n msgScope?: TMsgScope;\r\n};\r\n\r\n// ComponentShape\r\nexport type ComponentStruct<\r\n TMsgBusStruct extends MsgBusStruct = MsgBusStruct,\r\n T extends ComponentStructBase<TMsgBusStruct> = ComponentStructBase<TMsgBusStruct>,\r\n> = T & {\r\n msgBus: TMsgBusStruct;\r\n};\r\n\r\nexport type MsgBusBroker<\r\n TStructToProvide extends MsgBusStruct = MsgBusStruct,\r\n TStructToSubscribe extends MsgBusStruct = MsgBusStruct,\r\n> = {\r\n // providers\r\n provide?: {\r\n [TChannel in keyof TStructToProvide]?: {\r\n [TGroup in keyof Skip<\r\n TStructToProvide[TChannel],\r\n typeof $CG_OUT\r\n >]?: MsgBusChannelGroupProviderParams<TStructToProvide, TChannel, TGroup>;\r\n };\r\n };\r\n // subscribers\r\n subscribe?: {\r\n [TChannel in keyof TStructToSubscribe]: {\r\n [TGroup in keyof TStructToSubscribe[TChannel]]?: MsgBusChannelGroupSubscriberParams<\r\n TStructToSubscribe,\r\n TChannel,\r\n TGroup\r\n >;\r\n };\r\n };\r\n};\r\n\r\ntype ValueConverter<TTo, TFrom> = {\r\n // ConvertFrom\r\n convert(value: TFrom): TTo;\r\n // ConvertTo\r\n convertBack(value: TTo): TFrom;\r\n};\r\n\r\ntype ValidationResult = {\r\n valid: boolean;\r\n message: string;\r\n};\r\n\r\ntype Validator<T> = {\r\n options: {\r\n blur: boolean;\r\n };\r\n validate: (value: T) => MaybePromise<ValidationResult>;\r\n};\r\n\r\nconst $isBinding = Symbol('$isBinding');\r\n// const $bindings = Symbol('$bindings');\r\nexport interface IBinding<T = any, TFrom = any> {\r\n // getter\r\n readonly get: () => T;\r\n // setter\r\n readonly set: (value: T) => void;\r\n readonly converter: ValueConverter<T, TFrom>;\r\n readonly validator: Validator<T>;\r\n readonly readOnly: boolean;\r\n [$isBinding]: boolean;\r\n}\r\n\r\nclass Binding<T = any, TFrom = any> implements IBinding<any, any> {\r\n // getter\r\n readonly get: () => T;\r\n // setter\r\n readonly set: (value: T) => void;\r\n readonly converter: ValueConverter<T, TFrom>;\r\n readonly validator: Validator<T>;\r\n readonly readOnly: boolean;\r\n constructor(\r\n get: () => T,\r\n set?: (value: T) => void,\r\n converter?: ValueConverter<T, TFrom>,\r\n validator?: Validator<T>,\r\n ) {\r\n this.get = get;\r\n this.set = set;\r\n this.converter = converter;\r\n this.validator = validator;\r\n this.readOnly = !!set;\r\n this[$isBinding] = true;\r\n }\r\n [$isBinding]: boolean;\r\n}\r\n\r\nexport function isBinding(obj: any): obj is IBinding {\r\n return obj[$isBinding] === true;\r\n}\r\n\r\nexport function bind<T, TFrom = any>(\r\n get: () => T,\r\n set?: (value: T) => void,\r\n converter?: ValueConverter<T, TFrom>,\r\n validator?: Validator<T>,\r\n) {\r\n return new Binding(get, set, converter, validator);\r\n}\r\n\r\nexport function bindProp<T extends object, P extends keyof T>(target: () => T, prop: P) {\r\n return new Binding(\r\n () => target()[prop],\r\n (value: T[P]) => {\r\n target()[prop] = value;\r\n },\r\n );\r\n}\r\n\r\nexport type ComponentPropSource<T> = T | Binding<T>;\r\n\r\nexport type ComponentPropParams<TPropStruct extends ComponentPropStruct> = {\r\n [P in keyof TPropStruct]?: ComponentPropSource<TPropStruct[P]>;\r\n};\r\n\r\n// const $ON_PROP_CHANGING = \"onPropChanging\";\r\n// const $ON_PROP_CHANGE = \"onPropChange\";\r\n\r\nconst $ON_GET = 'onGet';\r\n// const $ON_BEFORE_SET = \"onBeforeSet\";\r\nconst $ON_CHANGING = 'onChanging';\r\nconst $ON_CHANGE = 'onChange';\r\n// const $ON_SET = \"onSet\";\r\n\r\ntype PropValueChangingHandler<TProp = PropKey> = (\r\n prop: TProp,\r\n oldValue: any,\r\n newValue: any,\r\n) => boolean;\r\ntype PropValueChangeHandler<TProp = PropKey> = (prop: TProp, value: any) => void;\r\n\r\n// BeforeValueSetHandler\r\ntype ValueChangingHandler<T = any> = (oldValue: T, newValue: T) => boolean;\r\n// ValueSetHandler\r\ntype ValueChangeHandler<T = any> = (value: T) => void;\r\n\r\ntype ComponentEvents<TStruct extends ComponentStruct = ComponentStruct> = {\r\n onPropChanging?: PropValueChangingHandler<keyof TStruct['props']>;\r\n onPropChange?: PropValueChangeHandler<keyof TStruct['props']>;\r\n onInit?: (model: ComponentModel<TStruct>) => void;\r\n onLayout?: (model: ComponentModel<TStruct>) => void;\r\n onReady?: (model: ComponentModel<TStruct>) => void;\r\n onLayoutDestroy?: (model: ComponentModel<TStruct>) => void; // onLayoutCleanup\r\n onDestroy?: (model: ComponentModel<TStruct>) => void; // onDispose/onCleanup\r\n onError?: (model: ComponentModel<TStruct>, error: any) => void;\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_GET}${Capitalize<P & string>}`]?: () => TStruct['props'][P];\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_CHANGING}${Capitalize<P & string>}`]?: ValueChangingHandler<\r\n TStruct['props']\r\n >;\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_CHANGE}${Capitalize<P & string>}`]?: ValueChangeHandler<\r\n TStruct['props']\r\n >;\r\n};\r\n\r\n// AllHTMLAttributes<JSX.Element>\r\n\r\ntype ComponentViewProps = {\r\n render?: boolean;\r\n} & PropsWithChildren;\r\n\r\n// ComponentRenderImplFn\r\ntype ComponentViewImplFn<TStruct extends ComponentStruct> = (\r\n props: ComponentViewProps,\r\n model?: ComponentModel<TStruct>,\r\n) => ReactNode; // JSX.Element\r\n\r\n// ComponentRenderFn\r\ntype ComponentViewFn = (props: ComponentViewProps) => ReactNode; // JSX.Element\r\n\r\ntype PublicKeys<T> = {\r\n [K in keyof T]: K extends `_${string}` ? never : K;\r\n}[keyof T];\r\n\r\nexport type Component<TStruct extends ComponentStruct> = {\r\n name?: string;\r\n props?: TStruct['props'];\r\n methods?: TStruct['methods'];\r\n children?: ComponentChildren<TStruct['children']>;\r\n events?: ComponentEvents<TStruct>;\r\n // msgs?\r\n msgBroker?: MsgBusBroker<\r\n Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>>,\r\n Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>>\r\n >;\r\n msgBus?: MsgBus<\r\n // TStruct[\"msgBus\"]\r\n Pick<\r\n TStruct['msgBus'],\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>\r\n >\r\n >;\r\n view?: ComponentViewImplFn<TStruct>;\r\n};\r\n\r\ntype ComponentChildren<TRefStruct extends ComponentRefStruct> = {\r\n [P in keyof TRefStruct]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? (params: TParams) => ComponentModel<T>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? ComponentModel<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\ntype ComponentModelChildren<TRefStruct extends ComponentRefStruct> = {\r\n [P in keyof TRefStruct as TRefStruct[P] extends Function\r\n ? `${Capitalize<P & string>}`\r\n : P]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? FC<ComponentParams<T> & TParams>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? ComponentModel<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\nexport type ComponentModelContext = {\r\n bindings?: Map<PropKey, IBinding>;\r\n id: string;\r\n};\r\n\r\nexport type ComponentModelBase<TStruct extends ComponentStruct = ComponentStruct> = {\r\n readonly msgBus?: MsgBus<\r\n // TStruct[\"msgBus\"]\r\n Pick<\r\n TStruct['msgBus'],\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>\r\n >\r\n >;\r\n readonly View: ComponentViewFn;\r\n $: ComponentModelContext;\r\n};\r\n\r\nexport type ComponentModel<TStruct extends ComponentStruct = ComponentStruct> = TStruct['props'] &\r\n TStruct['methods'] &\r\n ComponentModelChildren<TStruct['children']> &\r\n ComponentModelBase<TStruct>;\r\n\r\n// style: CSSProperties;\r\n\r\ntype PropEventHandlers = {\r\n onGet?: () => any;\r\n onChanging?: (oldValue: any, newValue: any) => boolean;\r\n onChange?: (value: any) => void;\r\n};\r\n\r\ntype PropKey = string | symbol;\r\ntype ProxyEventHandlers = {\r\n onPropChanging?: PropValueChangingHandler<PropKey>;\r\n onPropChange?: PropValueChangeHandler<PropKey>;\r\n} & Record<PropKey, PropEventHandlers>;\r\n\r\n// ComponentConfig\r\nexport type ComponentParams<TStruct extends ComponentStruct = ComponentStruct> =\r\n ComponentPropParams<TStruct['props']> & ComponentEvents<TStruct>; // & PropsWithChildren\r\n\r\nconst blankView = () => null;\r\n\r\nfunction createProxy(\r\n state: any,\r\n bindings: Map<PropKey, IBinding>,\r\n proxyEventHandlers: ProxyEventHandlers,\r\n) {\r\n const onPropChanging = proxyEventHandlers.onPropChanging;\r\n const onPropChange = proxyEventHandlers.onPropChange;\r\n return new Proxy(state, {\r\n get(obj, prop, receiver) {\r\n const onGet = proxyEventHandlers[prop]?.onGet;\r\n if (onGet) {\r\n return onGet();\r\n }\r\n\r\n const binding = bindings.get(String(prop));\r\n if (binding) {\r\n let value: any = undefined;\r\n // untracked(() => {\r\n value = binding.get();\r\n // });\r\n return value;\r\n }\r\n return Reflect.get(obj, prop, receiver);\r\n },\r\n set(obj, prop, value, receiver) {\r\n const oldValue = obj[prop];\r\n\r\n const onChanging = proxyEventHandlers[prop]?.onChanging;\r\n if (onChanging) {\r\n const shouldChange = onChanging(oldValue, value);\r\n if (!shouldChange) {\r\n return true;\r\n }\r\n }\r\n\r\n if (onPropChanging) {\r\n const shouldChange = onPropChanging(prop, oldValue, value);\r\n if (!shouldChange) {\r\n return true;\r\n }\r\n }\r\n\r\n const result = runInAction(() => {\r\n return Reflect.set(obj, prop, value, receiver);\r\n });\r\n\r\n const binding = bindings.get(prop);\r\n if (binding?.set) {\r\n // untracked(() => {\r\n binding.set(value);\r\n // });\r\n }\r\n\r\n const onChange = proxyEventHandlers[prop]?.onChange;\r\n if (onChange) {\r\n onChange(value);\r\n }\r\n\r\n if (onPropChange) {\r\n onPropChange(prop, value);\r\n }\r\n\r\n return result;\r\n },\r\n });\r\n}\r\n\r\nfunction capitalize(name: string) {\r\n return name.replace(/^./, name[0].toUpperCase());\r\n}\r\n\r\nfunction asyncToGeneratorFlow(asyncFn: (...args: any[]) => Promise<any>) {\r\n return function* (...args: any[]) {\r\n const result = yield asyncFn(...args);\r\n return result;\r\n };\r\n}\r\n\r\ntype ComponentSourceInfo = {\r\n // classId\r\n structId: string;\r\n count: 0;\r\n};\r\n\r\nconst componentData = {\r\n sources: new Map<string, ComponentSourceInfo>(),\r\n count: 0,\r\n};\r\n\r\nexport function toHtmlId(url: string, segmentsCount: number = 1): string {\r\n const clean = url.split(/[?#]/)[0];\r\n const parts = clean\r\n .split('/')\r\n .filter(Boolean)\r\n .map((segment) => decodeURIComponent(segment));\r\n\r\n const last = parts.slice(-segmentsCount);\r\n const raw = last.join('-');\r\n let id = raw\r\n .normalize('NFKD')\r\n .replace(/[^a-zA-Z0-9\\-_:.+#]/g, '-')\r\n .replace(/-+/g, '-')\r\n .replace(/^[^a-zA-Z]+/, '-')\r\n .replace(/[+#]$/, '-');\r\n return id;\r\n}\r\n\r\nfunction getCallerFileName(depth = 2): string | null {\r\n const err = new Error();\r\n const stack = err.stack?.split('\\n');\r\n if (!stack || stack.length <= depth) return null;\r\n\r\n const match = stack[depth].match(/\\((.*):\\d+:\\d+\\)/);\r\n if (match) {\r\n return match[1];\r\n }\r\n return null;\r\n}\r\n\r\nfunction createModel<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n params: ComponentParams<TStruct>,\r\n): ComponentModel<TStruct> {\r\n const msgBus = component.msgBus;\r\n\r\n const bindings = new Map<PropKey, IBinding>();\r\n\r\n const view = component.view;\r\n\r\n let model: ComponentModel<TStruct>;\r\n const ViewFC = observer((props: ComponentViewProps) => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n // render\r\n console.debug(`${model.$.id}>view`);\r\n }\r\n if (typeof view === 'function') {\r\n return view(props, model);\r\n }\r\n return <>{props.children}</>;\r\n } catch (err) {\r\n // throw err;\r\n const errDetails = JSON.stringify(err);\r\n return <>{errDetails}</>;\r\n } finally {\r\n }\r\n });\r\n\r\n let srcInfo: ComponentSourceInfo;\r\n const sources = componentData.sources;\r\n\r\n const fileName = getCallerFileName(6);\r\n const srcName = toHtmlId(fileName, 2);\r\n\r\n if (sources.has(fileName)) {\r\n srcInfo = sources.get(fileName);\r\n srcInfo.count++;\r\n } else {\r\n const structId = component.name || srcName || `Component_${componentData.count}`;\r\n srcInfo = {\r\n structId: structId,\r\n count: 0,\r\n };\r\n sources.set(fileName, srcInfo);\r\n componentData.count++;\r\n }\r\n\r\n const rootId = `${srcInfo.structId}#${srcInfo.count}`;\r\n model = {\r\n ...component.props,\r\n ...component.methods,\r\n // view: component.view,\r\n View: ViewFC,\r\n msgBus: msgBus,\r\n $: {\r\n bindings: bindings,\r\n id: rootId,\r\n },\r\n };\r\n\r\n if (component.children) {\r\n for (const [key, value] of Object.entries(component.children)) {\r\n if (typeof value == 'function') {\r\n const view = value as (params: any) => ComponentModel;\r\n // observer\r\n const ChildViewFC: ComponentViewImplFn<TStruct> = (props) => {\r\n const model = view(props);\r\n return <model.View />;\r\n // if (typeof model.view === \"function\") {\r\n // return model.view(props);\r\n // }\r\n // return <>{props.children}</>;\r\n };\r\n Reflect.set(model, capitalize(key), ChildViewFC);\r\n } else {\r\n Reflect.set(model, key, value);\r\n }\r\n }\r\n }\r\n if (component.msgBroker) {\r\n const providers = component.msgBroker.provide;\r\n if (providers) {\r\n for (const [channel, providerGroups] of Object.entries(providers)) {\r\n for (const [group, provider] of Object.entries(providerGroups)) {\r\n msgBus.provide({\r\n ...provider,\r\n channel: channel,\r\n group: group,\r\n });\r\n }\r\n }\r\n }\r\n const subscribers = component.msgBroker.subscribe;\r\n if (subscribers) {\r\n for (const [channel, subscriberGroups] of Object.entries(subscribers)) {\r\n for (const [group, subscriber] of Object.entries(subscriberGroups)) {\r\n msgBus.on({\r\n ...subscriber,\r\n channel: channel,\r\n group: group,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Reflect.ownKeys\r\n for (const [key, value] of Object.entries(params)) {\r\n if (isBinding(value)) {\r\n bindings.set(key, value);\r\n } else {\r\n Reflect.set(model, key, value);\r\n }\r\n }\r\n\r\n // decorators\r\n const annotationMap: Record<string, any> = {};\r\n\r\n if (component.props) {\r\n for (const key of Object.keys(component.props)) {\r\n annotationMap[key] = observable.ref;\r\n }\r\n }\r\n if (component.methods) {\r\n for (const key of Object.keys(component.methods)) {\r\n annotationMap[key] = false;\r\n }\r\n }\r\n if (component.children) {\r\n for (const key of Object.keys(component.children)) {\r\n annotationMap[key] = false;\r\n }\r\n }\r\n\r\n // annotationMap[\"view\" satisfies keyof Component<TStruct>] = false;\r\n annotationMap['View' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n annotationMap['msgBus' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n annotationMap['$' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n\r\n const proxyEventHandlers: Pick<ProxyEventHandlers, 'onPropChanging' | 'onPropChange'> = {\r\n onPropChanging:\r\n params?.onPropChanging || component.events?.onPropChanging\r\n ? (prop, oldValue, newValue) => {\r\n let result = true;\r\n let handler = params.onPropChanging;\r\n if (handler) {\r\n result = handler(String(prop), oldValue, newValue);\r\n }\r\n if (result) {\r\n handler = component.events?.onPropChanging;\r\n if (handler) {\r\n result = handler(String(prop), oldValue, newValue);\r\n }\r\n }\r\n return result;\r\n }\r\n : undefined,\r\n onPropChange:\r\n params?.onPropChange || component.events?.onPropChange\r\n ? (prop, value) => {\r\n params.onPropChange?.(String(prop), value);\r\n component.events.onPropChange?.(String(prop), value);\r\n }\r\n : undefined,\r\n };\r\n\r\n function resolveOnGetEventHandler(prop: string) {\r\n const key = `${$ON_GET}${capitalize(prop)}`;\r\n return params[key] || component.events?.[key];\r\n }\r\n\r\n function resolveOnChangingEventHandler(prop: string) {\r\n const key = `${$ON_CHANGING}${capitalize(prop)}`;\r\n return ((oldValue: any, newValue: any) => {\r\n let result = true;\r\n let handler = params[key] as ValueChangingHandler<any>;\r\n if (handler) {\r\n result = handler(oldValue, newValue);\r\n }\r\n if (result) {\r\n handler = component.events[key] as ValueChangingHandler<any>;\r\n if (handler) {\r\n result = handler(oldValue, newValue);\r\n }\r\n }\r\n return result;\r\n }) as ValueChangingHandler;\r\n }\r\n\r\n function resolveOnChangeEventHandler(prop: string) {\r\n const key = `${$ON_CHANGE}${capitalize(prop)}`;\r\n return ((value: any) => {\r\n (params[key] as ValueChangeHandler<any>)?.(value);\r\n (component.events[key] as ValueChangeHandler<any>)?.(value);\r\n }) as ValueChangeHandler;\r\n }\r\n\r\n if (component.props) {\r\n for (const prop of Object.keys(component.props)) {\r\n proxyEventHandlers[prop] = {\r\n onGet: resolveOnGetEventHandler(prop),\r\n onChanging: resolveOnChangingEventHandler(prop),\r\n onChange: resolveOnChangeEventHandler(prop),\r\n };\r\n }\r\n }\r\n\r\n model = observable(model, annotationMap, {\r\n deep: true,\r\n });\r\n // model = useLocalObservable(() => model, annotationMap);\r\n\r\n model = createProxy(model, bindings, proxyEventHandlers);\r\n\r\n if (component.events?.onInit) {\r\n component.events.onInit(model);\r\n }\r\n\r\n if (params?.onInit) {\r\n params.onInit(model);\r\n }\r\n\r\n return model;\r\n}\r\n\r\nexport function useComponent<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n params: ComponentParams<TStruct>,\r\n): ComponentModel<TStruct> {\r\n const ref = useLazyRef(() => createModel(component, params));\r\n const model = ref.current;\r\n\r\n useLayoutEffect(() => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n console.debug(`${model.$.id}>layout`);\r\n }\r\n component.events?.onLayout?.(model);\r\n params?.onLayout?.(model);\r\n } catch (err) {\r\n component.events?.onError?.(model, err);\r\n params?.onError?.(model, err);\r\n }\r\n\r\n return () => {\r\n if (getGlobalFlags().debug) {\r\n console.debug(`${model.$.id}>layout-destroy`);\r\n }\r\n component.events?.onLayoutDestroy?.(model);\r\n params?.onLayoutDestroy?.(model);\r\n // ref.current?.dispose();\r\n ref.current = null;\r\n };\r\n }, []);\r\n\r\n useEffect(() => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n // mount\r\n console.debug(`${model.$.id}>ready`);\r\n }\r\n component.events?.onReady?.(model);\r\n params?.onReady?.(model);\r\n } catch (err) {\r\n if (getGlobalFlags().debug) {\r\n // unmount\r\n console.debug(`${model.$.id}>destroy`);\r\n }\r\n component.events?.onError?.(model, err);\r\n params?.onError?.(model, err);\r\n }\r\n return () => {\r\n component.events?.onDestroy?.(model);\r\n params?.onDestroy?.(model);\r\n };\r\n }, []);\r\n\r\n return ref.current;\r\n}\r\n\r\n// asFC/toFC\r\nexport function getFC<TStruct extends ComponentStruct>(\r\n factory: (params: ComponentParams<TStruct>) => ComponentModel<TStruct>,\r\n): FC<ComponentParams<TStruct>> {\r\n // observer\r\n const fc = (params: ComponentParams<TStruct> & PropsWithChildren) => {\r\n // modelHook\r\n const model = factory(params); // without useRef!\r\n // return model.view();\r\n return <model.View {...params} />;\r\n // return <ViewerFC {...params} view={model.view} />;\r\n };\r\n return fc;\r\n}\r\n"],"names":["$isBinding","Binding","get","set","converter","validator","isBinding","obj","bind","bindProp","target","prop","value","$ON_GET","$ON_CHANGING","$ON_CHANGE","createProxy","state","bindings","proxyEventHandlers","onPropChanging","onPropChange","receiver","onGet","binding","oldValue","onChanging","result","runInAction","onChange","capitalize","name","componentData","toHtmlId","url","segmentsCount","segment","getCallerFileName","depth","stack","match","createModel","component","params","msgBus","view","model","ViewFC","observer","props","getGlobalFlags","React","err","errDetails","srcInfo","sources","fileName","srcName","rootId","key","ChildViewFC","providers","channel","providerGroups","group","provider","subscribers","subscriberGroups","subscriber","annotationMap","observable","newValue","handler","resolveOnGetEventHandler","resolveOnChangingEventHandler","resolveOnChangeEventHandler","useComponent","ref","useLazyRef","useLayoutEffect","useEffect","getFC","factory"],"mappings":";;;;;AA0HA,MAAMA,IAAa,OAAO,YAAY;AAatC,MAAMC,EAA4D;AAAA;AAAA,EAErD;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACT,YACIC,GACAC,GACAC,GACAC,GACF;AACE,SAAK,MAAMH,GACX,KAAK,MAAMC,GACX,KAAK,YAAYC,GACjB,KAAK,YAAYC,GACjB,KAAK,WAAW,CAAC,CAACF,GAClB,KAAKH,CAAU,IAAI;AAAA,EACvB;AAAA,EACA,CAACA,CAAU;AACf;AAEO,SAASM,EAAUC,GAA2B;AACjD,SAAOA,EAAIP,CAAU,MAAM;AAC/B;AAEO,SAASQ,EACZN,GACAC,GACAC,GACAC,GACF;AACE,SAAO,IAAIJ,EAAQC,GAAKC,GAAKC,GAAWC,CAAS;AACrD;AAEO,SAASI,EAA8CC,GAAiBC,GAAS;AACpF,SAAO,IAAIV;AAAA,IACP,MAAMS,EAAA,EAASC,CAAI;AAAA,IACnB,CAACC,MAAgB;AACb,MAAAF,EAAA,EAASC,CAAI,IAAIC;AAAA,IACrB;AAAA,EAAA;AAER;AAWA,MAAMC,IAAU,SAEVC,IAAe,cACfC,IAAa;AAgJnB,SAASC,EACLC,GACAC,GACAC,GACF;AACE,QAAMC,IAAiBD,EAAmB,gBACpCE,IAAeF,EAAmB;AACxC,SAAO,IAAI,MAAMF,GAAO;AAAA,IACpB,IAAIV,GAAKI,GAAMW,GAAU;AACrB,YAAMC,IAAQJ,EAAmBR,CAAI,GAAG;AACxC,UAAIY;AACA,eAAOA,EAAA;AAGX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
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAMF,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,aAAa,CAAC,EAAE,WAAW,CAAC;KAC/B;CAEJ;AAGD,wBAAgB,cAAc,gBAS7B"}
@@ -0,0 +1,10 @@
1
+ const l = {
2
+ debug: !1
3
+ };
4
+ function e() {
5
+ return typeof globalThis > "u" ? l : window.__DYNSTRUCT__ || l;
6
+ }
7
+ export {
8
+ e as getGlobalFlags
9
+ };
10
+ //# sourceMappingURL=globals.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.es.js","sources":["../src/globals.ts"],"sourcesContent":["export { };\r\n\r\nexport type GlobalFlags = {\r\n debug?: boolean;\r\n};\r\n\r\nconst defaultGlobalFlags: GlobalFlags = {\r\n debug: false\r\n}\r\n\r\ndeclare global {\r\n interface Window {\r\n __DYNSTRUCT__?: GlobalFlags;\r\n }\r\n\r\n}\r\n\r\n// getUserFlags\r\nexport function getGlobalFlags() {\r\n // window\r\n const globalObj = globalThis as Window & typeof globalThis;\r\n\r\n if (typeof globalObj === 'undefined') {\r\n return defaultGlobalFlags;\r\n }\r\n\r\n return window.__DYNSTRUCT__ || defaultGlobalFlags;\r\n}"],"names":["defaultGlobalFlags","getGlobalFlags"],"mappings":"AAMA,MAAMA,IAAkC;AAAA,EACpC,OAAO;AACX;AAUO,SAASC,IAAiB;AAI7B,SAAI,OAFc,aAEO,MACdD,IAGJ,OAAO,iBAAiBA;AACnC;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actdim/dynstruct",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "A type-safe component system for large-scale apps: explicit dependencies, message bus communication, and structure-first, declarative design",
5
5
  "author": "Pavel Borodaev",
6
6
  "license": "Proprietary",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "sideEffects": false,
52
52
  "sideEffects?": [],
53
- "scripts": {
53
+ "scripts": {
54
54
  "test": "npx vitest --config=vitest.node.config.ts --no-cache",
55
55
  "test:w": "npx vitest --config=vitest.node.config.ts --watch",
56
56
  "test:v8": "npx vite",
@@ -64,48 +64,55 @@
64
64
  "nvm:la": "nvm list available",
65
65
  "nvm:il": "nvm install lts",
66
66
  "format": "prettier --write .",
67
- "format:check": "prettier --check ."
67
+ "format:check": "prettier --check .",
68
+ "storybook": "storybook dev -p 6006",
69
+ "build-storybook": "storybook build"
68
70
  },
69
71
  "peerDependencies": {
72
+ "@actdim/msgmesh": "^1.0.2",
73
+ "@actdim/utico": "^1.0.2",
74
+ "dexie": "^4.2.0",
70
75
  "http-status": "^2.1.0",
71
76
  "jwt-decode": "^4.0.0",
72
77
  "mobx": "^6.15.0",
73
78
  "mobx-react-lite": "^4.1.1",
74
79
  "mobx-utils": "^6.1.1",
80
+ "moment": "^2.30.1",
75
81
  "path-to-regexp": "^8.3.0",
76
82
  "react": "^19.2.0",
77
83
  "react-dom": "^19.2.0",
78
84
  "react-router": "^7.9.3",
79
85
  "react-router-dom": "^7.9.4",
80
- "@actdim/utico": "^1.0.0",
81
- "@actdim/msgmesh": "^1.0.0",
82
86
  "rxjs": "^7.8.2",
83
- "dexie": "^4.2.0",
84
- "moment": "^2.30.1",
85
87
  "uuid": "^13.0.0"
86
88
  },
87
89
  "devDependencies": {
90
+ "@storybook/addon-docs": "10.0.7",
91
+ "@storybook/addon-onboarding": "10.0.7",
92
+ "@storybook/react-vite": "10.0.7",
88
93
  "@swc/core": "^1.15.1",
89
- "@vitejs/plugin-react-swc": "^4.2.1",
90
- "eslint-plugin-react": "^7.37.5",
91
- "eslint-plugin-react-hooks": "^7.0.1",
92
- "eslint-plugin-react-refresh": "^0.4.24",
93
94
  "@types/chai": "^5.2.3",
94
95
  "@types/mocha": "^10.0.10",
95
96
  "@types/node": "^24.10.0",
96
97
  "@typescript-eslint/eslint-plugin": "^8.46.3",
97
98
  "@typescript-eslint/parser": "^8.46.3",
99
+ "@vitejs/plugin-react-swc": "^4.2.1",
98
100
  "chai": "^6.2.0",
99
101
  "eslint": "^9.39.1",
100
102
  "eslint-config-prettier": "^10.1.8",
101
103
  "eslint-formatter-visualstudio": "^9.0.1",
102
- "eslint-plugin-prettier": "^5.5.4",
104
+ "eslint-plugin-prettier": "^5.5.4",
105
+ "eslint-plugin-react": "^7.37.5",
106
+ "eslint-plugin-react-hooks": "^7.0.1",
107
+ "eslint-plugin-react-refresh": "^0.4.24",
108
+ "eslint-plugin-storybook": "10.0.7",
103
109
  "globals": "^16.5.0",
104
110
  "mocha": "^11.7.5",
105
111
  "npm-check-updates": "^19.1.2",
106
112
  "prettier": "^3.6.2",
107
113
  "prettier-plugin-classnames": "^0.8.5",
108
114
  "shx": "^0.4.0",
115
+ "storybook": "10.0.7",
109
116
  "typescript": "^5.9.3",
110
117
  "typescript-eslint": "^8.46.3",
111
118
  "vite": "^7.2.2",