@actdim/dynstruct 1.1.0 → 1.1.2

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.
@@ -120,12 +120,12 @@ export type BaseApiConfig = {
120
120
  url?: string;
121
121
  versions?: string[];
122
122
  };
123
- export type BaseAppDomainConfig<TSecurityDomainConfig extends BaseSecurityDomainConfig = BaseSecurityDomainConfig, TApiConfig extends BaseApiConfig = BaseApiConfig> = {
123
+ export type BaseAppDomainConfig<TSecurityDomainConfig extends BaseSecurityDomainConfig = BaseSecurityDomainConfig, TApiConfig extends BaseApiConfig = BaseApiConfig, TApiName extends PropertyKey = string> = {
124
124
  id: string;
125
125
  name?: string;
126
126
  baseUrl: string;
127
127
  security: TSecurityDomainConfig;
128
- apis: Record<string, TApiConfig>;
128
+ apis: Record<TApiName, TApiConfig>;
129
129
  };
130
130
  export type BaseAppMsgChannels<TChannel extends keyof BaseAppMsgStruct | Array<keyof BaseAppMsgStruct>> = KeysOf<BaseAppMsgStruct, TChannel>;
131
131
  export type BaseAppContext<TMsgStruct extends BaseAppMsgStruct = BaseAppMsgStruct> = ComponentRegistryContext<TMsgStruct> & {};
@@ -1 +1 @@
1
- {"version":3,"file":"appContracts.d.ts","sourceRoot":"","sources":["../../src/appDomain/appContracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,aAAa,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC3G,OAAO,EAAE,wBAAwB,IAAI,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACrI,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,eAAO,MAAM,SAAS,iBAAiB,CAAC;AACxC,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AACtD,eAAO,MAAM,oBAAoB,4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wBAAwB,EACjF,UAAU,SAAS,aAAa,GAAG,aAAa,EAChD,QAAQ,SAAS,WAAW,GAAG,MAAM,IAErC;IACA,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,qBAAqB,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;CAEtC,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,QAAQ,SAAS,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,gBAAgB,CAAC,IAAI,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AAE7I,MAAM,MAAM,cAAc,CAAC,UAAU,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,wBAAwB,CAAC,UAAU,CAAC,GAAG,EAE3H,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,SAAS,gBAAgB,GAAG,gBAAgB,OAAgC,cAAc,CAAC,UAAU,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"appContracts.es.js","sources":["../../src/appDomain/appContracts.ts"],"sourcesContent":["import { $CG_ERROR, MsgBus, MsgStruct, MsgStructBase, MsgStructFactory } from \"@actdim/msgmesh/msgBusCore\";\r\nimport { BaseSecurityDomainConfig as BaseSecurityDomainConfig, BaseSecurityMsgStruct } from \"@/appDomain/security/securityContracts\";\r\nimport { ReactNode } from \"react\";\r\nimport { KeysOf } from \"@actdim/utico/typeCore\";\r\nimport { ComponentRegistryContext } from \"@/componentModel/contracts\";\r\nimport { useComponentContext } from \"@/componentModel/componentContext\";\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)ApiMsgStruct\r\nexport type BaseApiMsgStruct = BaseSecurityMsgStruct &\r\n MsgStructFactory<{\r\n // \"GET-VERSION\"?: {\r\n // in: any;\r\n // };\r\n }>;\r\n\r\n// BaseAppMsgStruct\r\nexport type BaseAppMsgStruct<TNavRoutes extends NavRoutes = NavRoutes> = BaseApiMsgStruct &\r\n MsgStructFactory<\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 } & MsgStructBase\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 BaseAppMsgChannels<TChannel extends keyof BaseAppMsgStruct | Array<keyof BaseAppMsgStruct>> = KeysOf<BaseAppMsgStruct, TChannel>;\r\n\r\nexport type BaseAppContext<TMsgStruct extends BaseAppMsgStruct = BaseAppMsgStruct> = ComponentRegistryContext<TMsgStruct> & {\r\n // securityProvider: SecurityProvider;\r\n};\r\n\r\nexport const useBaseAppContext = <TMsgStruct extends BaseAppMsgStruct = BaseAppMsgStruct>() => useComponentContext() as BaseAppContext<TMsgStruct>;"],"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","useBaseAppContext","useComponentContext"],"mappings":";AAOO,MAAMA,IAAY,gBACZC,IAAmB,uBACnBC,IAAuB,2BACvBC,IAAoB,wBAEpBC,IAAU,cACVC,IAAc,kBAEdC,IAAS,aAETC,IAAgB,oBAChBC,IAAgB,oBAChBC,IAAmB,uBAqMnBC,IAAoB,MAA8DC,EAAA;"}
1
+ {"version":3,"file":"appContracts.es.js","sources":["../../src/appDomain/appContracts.ts"],"sourcesContent":["import { $CG_ERROR, MsgBus, MsgStruct, MsgStructBase, MsgStructFactory } from \"@actdim/msgmesh/msgBusCore\";\r\nimport { BaseSecurityDomainConfig as BaseSecurityDomainConfig, BaseSecurityMsgStruct } from \"@/appDomain/security/securityContracts\";\r\nimport { ReactNode } from \"react\";\r\nimport { KeysOf } from \"@actdim/utico/typeCore\";\r\nimport { ComponentRegistryContext } from \"@/componentModel/contracts\";\r\nimport { useComponentContext } from \"@/componentModel/componentContext\";\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)ApiMsgStruct\r\nexport type BaseApiMsgStruct = BaseSecurityMsgStruct &\r\n MsgStructFactory<{\r\n // \"GET-VERSION\"?: {\r\n // in: any;\r\n // };\r\n }>;\r\n\r\n// BaseAppMsgStruct\r\nexport type BaseAppMsgStruct<TNavRoutes extends NavRoutes = NavRoutes> = BaseApiMsgStruct &\r\n MsgStructFactory<\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 } & MsgStructBase\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 TApiName extends PropertyKey = string\r\n// TApiName extends keyof any = string\r\n> = {\r\n id: string;\r\n name?: string;\r\n baseUrl: string;\r\n security: TSecurityDomainConfig;\r\n apis: Record<TApiName, TApiConfig>;\r\n // HATEOAS? (React Admin)\r\n};\r\n\r\nexport type BaseAppMsgChannels<TChannel extends keyof BaseAppMsgStruct | Array<keyof BaseAppMsgStruct>> = KeysOf<BaseAppMsgStruct, TChannel>;\r\n\r\nexport type BaseAppContext<TMsgStruct extends BaseAppMsgStruct = BaseAppMsgStruct> = ComponentRegistryContext<TMsgStruct> & {\r\n // securityProvider: SecurityProvider;\r\n};\r\n\r\nexport const useBaseAppContext = <TMsgStruct extends BaseAppMsgStruct = BaseAppMsgStruct>() => useComponentContext() as BaseAppContext<TMsgStruct>;"],"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","useBaseAppContext","useComponentContext"],"mappings":";AAOO,MAAMA,IAAY,gBACZC,IAAmB,uBACnBC,IAAuB,2BACvBC,IAAoB,wBAEpBC,IAAU,cACVC,IAAc,kBAEdC,IAAS,aAETC,IAAgB,oBAChBC,IAAgB,oBAChBC,IAAmB,uBAuMnBC,IAAoB,MAA8DC,EAAA;"}
@@ -1,13 +1,19 @@
1
- import { MsgBus, MsgStruct } from '@actdim/msgmesh/msgBusCore';
2
- import { RemoveSuffix } from '@actdim/utico/typeCore';
1
+ import { MsgBus, MsgStruct, MsgStructFactory } from '@actdim/msgmesh/msgBusCore';
2
+ import { AddPrefix, Filter, Func, RemoveSuffix, Skip, ToUpper } from '@actdim/utico/typeCore';
3
3
  export type MsgProviderAdapter = {
4
- service: Disposable;
4
+ service: any;
5
5
  channelSelector: (service: any, methodName: string) => string;
6
6
  };
7
7
  export declare function registerAdapters<TMsgStruct extends MsgStruct = MsgStruct>(msgBus: MsgBus<TMsgStruct>, adapters: MsgProviderAdapter[], abortSignal?: AbortSignal): void;
8
- export declare const BASE_API_CHANNEL_PREFIX: "API_";
9
- type BaseApiChannelPrefix = typeof BASE_API_CHANNEL_PREFIX;
10
- type BaseApiClientSuffix = 'CLIENT' | 'API';
11
- export type ToApiChannelPrefix<T extends string, Prefix extends string = BaseApiChannelPrefix, Suffix extends string = BaseApiClientSuffix> = `${Prefix}${RemoveSuffix<Uppercase<T>, Suffix>}_`;
8
+ export type BaseServiceSuffix = 'CLIENT' | 'API' | 'SERVICE' | 'FETCHER' | 'CONTROLLER' | 'LOADER' | 'REPOSITORY' | 'PROVIDER';
9
+ export type ToMsgChannelPrefix<TServiceName extends string, Prefix extends string, Suffix extends string = BaseServiceSuffix> = `${Prefix}${RemoveSuffix<Uppercase<TServiceName>, Suffix>}_`;
10
+ type ToMsgStructSource<TService, TPrefix extends string, TSkip extends keyof TService = never> = Filter<ToUpper<AddPrefix<Skip<TService, TSkip>, TPrefix>>, Func>;
11
+ export type ToMsgStruct<TService, TPrefix extends string, TSkip extends keyof TService = never, TMsgStructSource = ToMsgStructSource<TService, TPrefix, TSkip>> = MsgStructFactory<{
12
+ [K in keyof TMsgStructSource as TMsgStructSource[K] extends Func ? (Uppercase<K extends string ? K : never>) : never]: {
13
+ in: TMsgStructSource[K] extends Func ? Parameters<TMsgStructSource[K]> : never;
14
+ out: TMsgStructSource[K] extends Func ? ReturnType<TMsgStructSource[K]> : never;
15
+ };
16
+ }>;
17
+ export declare function getMsgChannelSelector<TTPrefix extends string>(services: Record<TTPrefix, any>): (service: any, methodName: string) => string;
12
18
  export {};
13
19
  //# sourceMappingURL=adapters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../src/componentModel/adapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAQ,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAY5D,MAAM,MAAM,kBAAkB,GAAG;IAC7B,OAAO,EAAE,UAAU,CAAC;IAEpB,eAAe,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;CACjE,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,UAAU,SAAS,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE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t).filter(
1
+ import { ClientBase as p } from "../net/client.es.js";
2
+ const i = (t) => Object.getOwnPropertyNames(t).filter(
3
3
  (e) => e !== "constructor" && typeof t[e] == "function"
4
4
  );
5
- a(s.prototype);
6
- function d(t, e, f) {
5
+ i(p.prototype);
6
+ function u(t, e, n) {
7
7
  if (e)
8
- for (const i of e) {
9
- const { service: o, channelSelector: r } = i;
10
- if (!o || !r)
8
+ for (const o of e) {
9
+ const { service: r, channelSelector: c } = o;
10
+ if (!r || !c)
11
11
  throw new Error("Service and channelSelector are required for an adapter");
12
- for (const n of a(Object.getPrototypeOf(o))) {
13
- const c = r?.(o, n);
14
- c && t.provide({
15
- channel: c,
12
+ for (const a of i(Object.getPrototypeOf(r))) {
13
+ const f = c?.(r, a);
14
+ f && t.provide({
15
+ channel: f,
16
16
  topic: "/.*/",
17
- callback: (p) => o[n](...p.payload || []),
17
+ callback: (s) => r[a](...s.payload || []),
18
18
  config: {
19
- abortSignal: f
19
+ abortSignal: n
20
20
  }
21
21
  });
22
22
  }
23
23
  }
24
24
  }
25
- const h = "API_";
25
+ function d(t) {
26
+ return (e, n) => {
27
+ const o = Object.entries(t).find((r) => r[1] === e);
28
+ return o ? `${o[0]}${n.toUpperCase()}` : null;
29
+ };
30
+ }
26
31
  export {
27
- h as BASE_API_CHANNEL_PREFIX,
28
- d as registerAdapters
32
+ d as getMsgChannelSelector,
33
+ u as registerAdapters
29
34
  };
30
35
  //# sourceMappingURL=adapters.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapters.es.js","sources":["../../src/componentModel/adapters.ts"],"sourcesContent":["import { ClientBase } from \"@/net/client\";\r\nimport { MsgBus, MsgStruct } from \"@actdim/msgmesh/msgBusCore\";\r\nimport { Func, RemoveSuffix } from \"@actdim/utico/typeCore\";\r\n\r\nconst getMethodNames = (client: any) => {\r\n // return new Set(...)\r\n return Object.getOwnPropertyNames(client).filter(\r\n (name) => name !== 'constructor' && typeof client[name] === 'function',\r\n );\r\n};\r\n\r\nconst baseMethodNames = getMethodNames(ClientBase.prototype);\r\n\r\n// ServiceMsgDispatcher\r\nexport type MsgProviderAdapter = {\r\n service: Disposable;\r\n // channelResolver/channelMapper\r\n channelSelector: (service: any, methodName: string) => string;\r\n};\r\n\r\nexport function registerAdapters<TMsgStruct extends MsgStruct = MsgStruct>(msgBus: MsgBus<TMsgStruct>, adapters: MsgProviderAdapter[], abortSignal?: AbortSignal) {\r\n if (adapters) {\r\n for (const adapter of adapters) {\r\n const { service, channelSelector } = adapter;\r\n if (!service || !channelSelector) {\r\n throw new Error(\"Service and channelSelector are required for an adapter\")\r\n }\r\n for (const methodName of getMethodNames(Object.getPrototypeOf(service))) {\r\n const channel = channelSelector?.(service, methodName);\r\n if (channel) {\r\n msgBus.provide({\r\n channel: channel as keyof TMsgStruct,\r\n topic: '/.*/',\r\n callback: (msg) => {\r\n return (service[methodName] as Func)(...((msg.payload || []) as any[]));\r\n },\r\n config: {\r\n abortSignal: abortSignal\r\n }\r\n });\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport const BASE_API_CHANNEL_PREFIX = 'API_' as const;\r\ntype BaseApiChannelPrefix = typeof BASE_API_CHANNEL_PREFIX;\r\n\r\ntype BaseApiClientSuffix = 'CLIENT' | 'API';\r\n\r\nexport type ToApiChannelPrefix<\r\n T extends string,\r\n Prefix extends string = BaseApiChannelPrefix,\r\n Suffix extends string = BaseApiClientSuffix,\r\n> = `${Prefix}${RemoveSuffix<Uppercase<T>, Suffix>}_`;"],"names":["getMethodNames","client","name","ClientBase","registerAdapters","msgBus","adapters","abortSignal","adapter","service","channelSelector","methodName","channel","msg","BASE_API_CHANNEL_PREFIX"],"mappings":";AAIA,MAAMA,IAAiB,CAACC,MAEb,OAAO,oBAAoBA,CAAM,EAAE;AAAA,EACtC,CAACC,MAASA,MAAS,iBAAiB,OAAOD,EAAOC,CAAI,KAAM;AAAA;AAI5CF,EAAeG,EAAW,SAAS;AASpD,SAASC,EAA2DC,GAA4BC,GAAgCC,GAA2B;AAC9J,MAAID;AACA,eAAWE,KAAWF,GAAU;AAC5B,YAAM,EAAE,SAAAG,GAAS,iBAAAC,EAAA,IAAoBF;AACrC,UAAI,CAACC,KAAW,CAACC;AACb,cAAM,IAAI,MAAM,yDAAyD;AAE7E,iBAAWC,KAAcX,EAAe,OAAO,eAAeS,CAAO,CAAC,GAAG;AACrE,cAAMG,IAAUF,IAAkBD,GAASE,CAAU;AACrD,QAAIC,KACAP,EAAO,QAAQ;AAAA,UACX,SAAAO;AAAA,UACA,OAAO;AAAA,UACP,UAAU,CAACC,MACCJ,EAAQE,CAAU,EAAW,GAAKE,EAAI,WAAW,CAAA,CAAa;AAAA,UAE1E,QAAQ;AAAA,YACJ,aAAAN;AAAA,UAAA;AAAA,QACJ,CACH;AAAA,MAET;AAAA,IACJ;AAER;AAEO,MAAMO,IAA0B;"}
1
+ {"version":3,"file":"adapters.es.js","sources":["../../src/componentModel/adapters.ts"],"sourcesContent":["import { ClientBase } from \"@/net/client\";\r\nimport { MsgBus, MsgStruct, MsgStructFactory } from \"@actdim/msgmesh/msgBusCore\";\r\nimport { AddPrefix, Diff, Filter, Func, KeysOf, RemoveSuffix, Skip, ToUpper } from \"@actdim/utico/typeCore\";\r\n\r\nconst getMethodNames = (client: any) => {\r\n // return new Set(...)\r\n return Object.getOwnPropertyNames(client).filter(\r\n (name) => name !== 'constructor' && typeof client[name] === 'function',\r\n );\r\n};\r\n\r\nconst baseMethodNames = getMethodNames(ClientBase.prototype);\r\n\r\n// ServiceMsgDispatcher\r\nexport type MsgProviderAdapter = {\r\n service: any;\r\n // channelResolver/channelMapper\r\n channelSelector: (service: any, methodName: string) => string;\r\n};\r\n\r\nexport function registerAdapters<TMsgStruct extends MsgStruct = MsgStruct>(msgBus: MsgBus<TMsgStruct>, adapters: MsgProviderAdapter[], abortSignal?: AbortSignal) {\r\n if (adapters) {\r\n for (const adapter of adapters) {\r\n const { service, channelSelector } = adapter;\r\n if (!service || !channelSelector) {\r\n throw new Error(\"Service and channelSelector are required for an adapter\")\r\n }\r\n for (const methodName of getMethodNames(Object.getPrototypeOf(service))) {\r\n const channel = channelSelector?.(service, methodName);\r\n if (channel) {\r\n msgBus.provide({\r\n channel: channel as keyof TMsgStruct,\r\n topic: '/.*/',\r\n callback: (msg) => {\r\n return (service[methodName] as Func)(...((msg.payload || []) as any[]));\r\n },\r\n config: {\r\n abortSignal: abortSignal\r\n }\r\n });\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport type BaseServiceSuffix = 'CLIENT' | 'API' | 'SERVICE' | 'FETCHER' | 'CONTROLLER' | 'LOADER' | 'REPOSITORY' | 'PROVIDER';\r\n\r\n// const suffixes = ['CLIENT', 'API', 'SERVICE'] satisfies Uppercase<BaseServiceSuffix>[];\r\n// runtime version: `${prefix}${removeSuffix(serviceName.toUpperCase(), suffixes)}_`\r\nexport type ToMsgChannelPrefix<\r\n TServiceName extends string,\r\n Prefix extends string,\r\n Suffix extends string = BaseServiceSuffix,\r\n> = `${Prefix}${RemoveSuffix<Uppercase<TServiceName>, Suffix>}_`;\r\n\r\ntype ToMsgStructSource<TService, TPrefix extends string, TSkip extends keyof TService = never> = Filter<\r\n ToUpper<AddPrefix<Skip<TService, TSkip>, TPrefix>>,\r\n Func\r\n>;\r\n\r\nexport type ToMsgStruct<TService, TPrefix extends string, TSkip extends keyof TService = never, TMsgStructSource = ToMsgStructSource<TService, TPrefix, TSkip>> = MsgStructFactory<{\r\n [K in keyof TMsgStructSource as TMsgStructSource[K] extends Func ? (Uppercase<K extends string ? K : never>) : never]: {\r\n in: TMsgStructSource[K] extends Func ? Parameters<TMsgStructSource[K]> : never;\r\n out: TMsgStructSource[K] extends Func ? ReturnType<TMsgStructSource[K]> : never;\r\n };\r\n}>;\r\n\r\nexport function getMsgChannelSelector<TTPrefix extends string>(\r\n services: Record<TTPrefix, any>,\r\n) {\r\n return (service: any, methodName: string) => {\r\n const entry = Object.entries(services).find((entry) => entry[1] === service);\r\n if (!entry) {\r\n return null;\r\n }\r\n return `${entry[0]}${methodName.toUpperCase()}`;\r\n };\r\n}"],"names":["getMethodNames","client","name","ClientBase","registerAdapters","msgBus","adapters","abortSignal","adapter","service","channelSelector","methodName","channel","msg","getMsgChannelSelector","services","entry"],"mappings":";AAIA,MAAMA,IAAiB,CAACC,MAEb,OAAO,oBAAoBA,CAAM,EAAE;AAAA,EACtC,CAACC,MAASA,MAAS,iBAAiB,OAAOD,EAAOC,CAAI,KAAM;AAAA;AAI5CF,EAAeG,EAAW,SAAS;AASpD,SAASC,EAA2DC,GAA4BC,GAAgCC,GAA2B;AAC9J,MAAID;AACA,eAAWE,KAAWF,GAAU;AAC5B,YAAM,EAAE,SAAAG,GAAS,iBAAAC,EAAA,IAAoBF;AACrC,UAAI,CAACC,KAAW,CAACC;AACb,cAAM,IAAI,MAAM,yDAAyD;AAE7E,iBAAWC,KAAcX,EAAe,OAAO,eAAeS,CAAO,CAAC,GAAG;AACrE,cAAMG,IAAUF,IAAkBD,GAASE,CAAU;AACrD,QAAIC,KACAP,EAAO,QAAQ;AAAA,UACX,SAAAO;AAAA,UACA,OAAO;AAAA,UACP,UAAU,CAACC,MACCJ,EAAQE,CAAU,EAAW,GAAKE,EAAI,WAAW,CAAA,CAAa;AAAA,UAE1E,QAAQ;AAAA,YACJ,aAAAN;AAAA,UAAA;AAAA,QACJ,CACH;AAAA,MAET;AAAA,IACJ;AAER;AAwBO,SAASO,EACZC,GACF;AACE,SAAO,CAACN,GAAcE,MAAuB;AACzC,UAAMK,IAAQ,OAAO,QAAQD,CAAQ,EAAE,KAAK,CAACC,MAAUA,EAAM,CAAC,MAAMP,CAAO;AAC3E,WAAKO,IAGE,GAAGA,EAAM,CAAC,CAAC,GAAGL,EAAW,aAAa,KAFlC;AAAA,EAGf;AACJ;"}
@@ -109,7 +109,7 @@ type ComponentViewProps = {
109
109
  } & PropsWithChildren;
110
110
  type ComponentViewImplFn<TStruct extends ComponentStruct, TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders> = (props: ComponentViewProps, component?: Component<TStruct, TMsgHeaders>) => ReactNode;
111
111
  type ComponentViewFn = (props: ComponentViewProps) => ReactNode;
112
- export type ComponentMsgBroker<TStruct extends ComponentStruct, TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders> = MsgBroker<Pick<TStruct['msg'], TStruct['msgScope']['provide']>, Pick<TStruct['msg'], TStruct['msgScope']['subscribe']>, TMsgHeaders, Component<TStruct, TMsgHeaders>>;
112
+ export type ComponentMsgBroker<TStruct extends ComponentStruct, TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders> = MsgBroker<Pick<TStruct['msg'], MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['provide']>>, Pick<TStruct['msg'], MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['subscribe']>>, TMsgHeaders, Component<TStruct, TMsgHeaders>>;
113
113
  export type EffectFn<TStruct extends ComponentStruct, TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders> = (component: Component<TStruct, TMsgHeaders>) => void | (() => void);
114
114
  export type ComponentDef<TStruct extends ComponentStruct, TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders> = {
115
115
  name?: string;
@@ -1 +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,MAAM,OAAO,CAAC;AACrF,OAAO,EACH,MAAM,EACN,OAAO,EAGP,GAAG,EACH,MAAM,EACN,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,SAAS,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEH,OAAO,EAGP,UAAU,EACV,YAAY,EAEZ,OAAO,EACP,IAAI,EACP,MAAM,wBAAwB,CAAC;AAchC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5D,oBAAY,kBAAkB;IAC1B,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C;IACnB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAEF,wBAAgB,YAAY,CACxB,OAAO,SAAS,eAAe,EAC/B,WAAW,SAAS,mBAAmB,GAAG,mBAAmB,EAE7D,SAAS,EAAE,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,EAC1C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,GACnC,gBAAgB,CAiDlB;AAoVD,wBAAgB,YAAY,CACxB,OAAO,SAAS,eAAe,GAAG,eAAe,EACjD,WAAW,SAAS,mBAAmB,GAAG,mBAAmB,EAC/D,YAAY,EAAE,YAAY,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,OAQnF;AAGD,wBAAgB,KAAK,CAAC,OAAO,SAAS,eAAe,EACjD,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC,OAAO,CAAC,GAClE,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAS9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"componentModel.es.js","sources":["../../src/componentModel/componentModel.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\nimport { PropsWithChildren, useEffect, useLayoutEffect, FC, ReactNode } from 'react';\r\nimport {\r\n $CG_IN,\r\n $CG_OUT,\r\n $TypeArgHeaders,\r\n $TypeArgStruct,\r\n Msg,\r\n MsgBus,\r\n MsgProviderParams,\r\n MsgStruct,\r\n MsgSubscriberParams,\r\n OutStruct,\r\n} from '@actdim/msgmesh/msgBusCore';\r\nimport {\r\n Extends,\r\n HasKeys,\r\n IF,\r\n IsEmpty,\r\n MaybeKeyOf,\r\n MaybePromise,\r\n Mutable,\r\n Require,\r\n Skip,\r\n} from '@actdim/utico/typeCore';\r\nimport { observer } from 'mobx-react-lite';\r\nimport {\r\n action,\r\n isObservable,\r\n observable,\r\n runInAction,\r\n toJS,\r\n autorun,\r\n IReactionDisposer,\r\n} from 'mobx';\r\nimport { useLazyRef } from '@/reactHooks';\r\nimport { getGlobalFlags } from '@/globals';\r\nimport { ReactComponentContext, useComponentContext } from './componentContext';\r\nimport { ComponentMsgHeaders, TreeNode } from './contracts';\r\nimport { lazy } from '@actdim/utico/utils';\r\nimport { isPlainObject } from 'mobx/dist/internal';\r\n\r\nexport enum ComponentMsgFilter {\r\n None = 0,\r\n // AcceptFrom...\r\n FromAncestors = 1 << 0,\r\n FromDescendants = 1 << 1,\r\n}\r\n\r\nexport type MsgChannelGroupProviderParams<\r\n TStruct extends MsgStruct = MsgStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n TScope = any,\r\n> = Skip<\r\n MsgProviderParams<TStruct, TChannel, TGroup>,\r\n 'channel' | 'group' | 'callback' | 'filter'\r\n> & {\r\n // resolve\r\n callback?: (\r\n msgIn: Msg<TStruct, TChannel, TGroup, TMsgHeaders>,\r\n headers: TMsgHeaders,\r\n scope: TScope,\r\n ) => MaybePromise<OutStruct<TStruct, TChannel>>;\r\n filter?: (msg: Msg<TStruct, TChannel, TGroup, TMsgHeaders>, scope: TScope) => boolean;\r\n componentFilter?: ComponentMsgFilter;\r\n};\r\n\r\nexport type MsgChannelGroupSubscriberParams<\r\n TStruct extends MsgStruct = MsgStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n TScope = any,\r\n> = Skip<\r\n MsgSubscriberParams<TStruct, TChannel, TGroup>,\r\n 'channel' | 'group' | 'callback' | 'filter'\r\n> & {\r\n callback?: (msg: Msg<TStruct, TChannel, TGroup, TMsgHeaders>, scope: TScope) => void;\r\n filter?: (msg: Msg<TStruct, TChannel, TGroup, TMsgHeaders>, scope: TScope) => boolean;\r\n componentFilter?: ComponentMsgFilter;\r\n};\r\n\r\n// MsgScope\r\nexport type MsgBrokerScope<\r\n TStruct extends MsgStruct /*= MsgStruct*/,\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<TMsgStruct, T>>;\r\nexport type ComponentRefStruct = {\r\n [name: string]: ComponentStruct | ((params: any) => ComponentStruct);\r\n};\r\n\r\nexport type ComponentStructBase<\r\n TMsgStruct extends MsgStruct = MsgStruct,\r\n TPropStruct extends ComponentPropStruct = ComponentPropStruct,\r\n TMsgScope extends MsgBrokerScope<TMsgStruct> = MsgBrokerScope<TMsgStruct>,\r\n> = {\r\n props?: TPropStruct;\r\n actions?: ComponentMethodStruct;\r\n effects?: string[] | string | undefined;\r\n children?: ComponentRefStruct;\r\n // msgs?\r\n msgScope?: TMsgScope;\r\n};\r\n\r\n// ComponentShape\r\nexport type ComponentStruct<\r\n TMsgStruct extends MsgStruct = MsgStruct,\r\n T extends ComponentStructBase<TMsgStruct> = ComponentStructBase<TMsgStruct>,\r\n> = T & {\r\n msg: TMsgStruct;\r\n};\r\n\r\nexport type MsgBroker<\r\n TStructToProvide extends MsgStruct = MsgStruct,\r\n TStructToSubscribe extends MsgStruct = MsgStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n TScope = any,\r\n> = Require<\r\n {\r\n // providers\r\n provide?: Require<\r\n {\r\n [TChannel in keyof TStructToProvide]: {\r\n [TGroup in keyof Skip<\r\n TStructToProvide[TChannel],\r\n typeof $CG_OUT\r\n >]?: MsgChannelGroupProviderParams<\r\n TStructToProvide,\r\n TChannel,\r\n TGroup,\r\n TMsgHeaders,\r\n TScope\r\n >;\r\n };\r\n },\r\n HasKeys<TStructToProvide>\r\n >;\r\n // subscribers\r\n subscribe?: Require<\r\n {\r\n [TChannel in keyof TStructToSubscribe]: {\r\n [TGroup in keyof TStructToSubscribe[TChannel]]?: MsgChannelGroupSubscriberParams<\r\n TStructToSubscribe,\r\n TChannel,\r\n TGroup,\r\n TMsgHeaders,\r\n TScope\r\n >;\r\n };\r\n },\r\n HasKeys<TStructToSubscribe>\r\n >;\r\n abortController?: AbortController;\r\n },\r\n HasKeys<TStructToProvide & TStructToSubscribe>\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'); // brand\r\n\r\nclass Binding<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 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 Binding {\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 = PropertyKey> = (\r\n prop: TProp,\r\n oldValue: any,\r\n newValue: any,\r\n) => boolean;\r\ntype PropValueChangeHandler<TProp = PropertyKey> = (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?: (component: Component<TStruct>) => void;\r\n onLayout?: (component: Component<TStruct>) => void;\r\n onReady?: (component: Component<TStruct>) => void;\r\n onLayoutDestroy?: (component: Component<TStruct>) => void; // onLayoutCleanup\r\n onDestroy?: (component: Component<TStruct>) => void; // onDispose/onCleanup\r\n onError?: (component: Component<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<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = (props: ComponentViewProps, component?: Component<TStruct, TMsgHeaders>) => 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 ComponentMsgBroker<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = MsgBroker<\r\n // Pick<TStruct['msg'], MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['provide']>>,\r\n Pick<TStruct['msg'], TStruct['msgScope']['provide']>,\r\n // Pick<TStruct['msg'], MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['subscribe']>>,\r\n Pick<TStruct['msg'], TStruct['msgScope']['subscribe']>,\r\n TMsgHeaders,\r\n Component<TStruct, TMsgHeaders>\r\n>;\r\n\r\nexport type EffectFn<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = (component: Component<TStruct, TMsgHeaders>) => void | (() => void);\r\n\r\nexport type ComponentDef<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = {\r\n name?: string;\r\n props?: Require<TStruct['props'], HasKeys<TStruct['props']>>;\r\n actions?: Require<TStruct['actions'], HasKeys<TStruct['actions']>>;\r\n effects?: keyof TStruct['effects'] extends never\r\n ? never\r\n : Record<\r\n TStruct['effects'] extends string ? TStruct['effects'] : TStruct['effects'][number],\r\n EffectFn<TStruct, TMsgHeaders>\r\n >;\r\n children?: ComponentDefChildren<TStruct['children']>;\r\n events?: ComponentEvents<TStruct>;\r\n // msgs?\r\n msgBroker?: ComponentMsgBroker<TStruct, TMsgHeaders>;\r\n msgBus?: MsgBus<TStruct['msg'], TMsgHeaders>;\r\n view?: ComponentViewImplFn<TStruct, TMsgHeaders>;\r\n};\r\n\r\ntype ComponentDefChildren<TRefStruct extends ComponentRefStruct> = Require<\r\n {\r\n [P in keyof TRefStruct]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? (params: TParams) => Component<T>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? Component<TRefStruct[P]>\r\n : never;\r\n },\r\n HasKeys<TRefStruct>\r\n>;\r\n\r\ntype ComponentChildren<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 ? Component<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\nexport type ComponentMsgStruct<TStruct extends ComponentStruct = ComponentStruct> = Pick<\r\n TStruct['msg'],\r\n | MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['provide']>\r\n | MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['subscribe']>\r\n | MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['publish']>\r\n>;\r\n\r\nexport type ComponentBase<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = {\r\n id: string;\r\n parentId: string;\r\n // getHierarchyPath?\r\n getHierarchyId(): string;\r\n getParent(): string | undefined;\r\n getChildren(): string[];\r\n getChainUp(): string[];\r\n getChainDown(): string[];\r\n getNodeMap(): Map<string, TreeNode>;\r\n bindings: Map<PropertyKey, Binding>;\r\n msgBus: MsgBus<ComponentMsgStruct<TStruct>, TMsgHeaders>;\r\n msgBroker: ComponentMsgBroker<TStruct>;\r\n effects: Record<string, EffectController>;\r\n View: ComponentViewFn;\r\n};\r\n\r\nexport type ComponentModel<TStruct extends ComponentStruct = ComponentStruct> = TStruct['props'] &\r\n Readonly<TStruct['actions']>;\r\n\r\nexport type Component<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = {\r\n readonly model: ComponentModel<TStruct>;\r\n readonly children: Readonly<ComponentChildren<TStruct['children']>>;\r\n} & Readonly<ComponentBase<TStruct, TMsgHeaders>>;\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 ProxyEventHandlers = {\r\n onPropChanging?: PropValueChangingHandler<PropertyKey>;\r\n onPropChange?: PropValueChangeHandler<PropertyKey>;\r\n} & Record<PropertyKey, 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\nconst proxyCache = new WeakMap<object, any>();\r\nfunction createRecursiveProxy(\r\n target: any,\r\n bindings: Map<PropertyKey, Binding>,\r\n handlers: ProxyEventHandlers,\r\n) {\r\n if (typeof target !== 'object' || target === null) {\r\n return target;\r\n }\r\n\r\n // isPlainObject\r\n if (!isObservable(target)) {\r\n return target;\r\n }\r\n\r\n if (proxyCache.has(target)) {\r\n return proxyCache.get(target);\r\n }\r\n\r\n const proxy = new Proxy(target, {\r\n get(obj, prop, receiver) {\r\n // 1. custom handlers\r\n const onGet = handlers[prop]?.onGet;\r\n if (onGet) return onGet();\r\n\r\n // 2. bindings\r\n const binding = bindings.get(prop);\r\n if (binding?.get) {\r\n return binding.get();\r\n }\r\n\r\n const value = Reflect.get(obj, prop, receiver);\r\n\r\n if (typeof value === 'object' && value !== null && isObservable(value)) {\r\n return createRecursiveProxy(value, bindings, handlers);\r\n }\r\n\r\n return value;\r\n },\r\n\r\n set(obj, prop, value, receiver) {\r\n const oldValue = obj[prop];\r\n\r\n // before-change hooks\r\n const onChanging = handlers[prop]?.onChanging;\r\n if (onChanging && onChanging(oldValue, value) === false) {\r\n return true;\r\n }\r\n\r\n if (\r\n handlers.onPropChanging &&\r\n handlers.onPropChanging(prop, oldValue, value) === false\r\n ) {\r\n return true;\r\n }\r\n\r\n const result = runInAction(() => {\r\n return Reflect.set(obj, prop, value, receiver);\r\n });\r\n\r\n // bindings\r\n const binding = bindings.get(prop);\r\n binding?.set?.(value);\r\n\r\n // after-change hooks\r\n handlers[prop]?.onChange?.(value);\r\n handlers.onPropChange?.(prop, value);\r\n\r\n return result;\r\n },\r\n });\r\n\r\n proxyCache.set(target, proxy);\r\n return proxy;\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 registerMsgBroker<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n) {\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 [g, p] of Object.entries(providerGroups)) {\r\n const provider = p as MsgChannelGroupProviderParams;\r\n const callback = provider.callback;\r\n if (callback) {\r\n provider.callback = (msg, headers) => {\r\n return callback(msg, headers, component);\r\n };\r\n }\r\n const filter = provider.filter;\r\n const componentFilter = provider.componentFilter || ComponentMsgFilter.None;\r\n const msgFilter = (msg) => {\r\n let result = true;\r\n if (componentFilter & ComponentMsgFilter.FromAncestors) {\r\n const ancestorIds = component.getChainUp();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && componentFilter & ComponentMsgFilter.FromDescendants) {\r\n const ancestorIds = component.getChainDown();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && filter) {\r\n result = filter(msg, component);\r\n }\r\n return result;\r\n };\r\n provider.filter = msgFilter;\r\n\r\n component.msgBus.provide({\r\n ...p,\r\n channel: channel,\r\n group: g,\r\n config: {\r\n abortSignal: component.msgBroker.abortController.signal,\r\n },\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 [g, s] of Object.entries(subscriberGroups)) {\r\n const subscriber = s as MsgChannelGroupSubscriberParams;\r\n const callback = subscriber.callback;\r\n if (callback) {\r\n subscriber.callback = (msg) => {\r\n return callback(msg, component);\r\n };\r\n }\r\n const filter = subscriber.filter;\r\n const componentFilter = subscriber.componentFilter || ComponentMsgFilter.None;\r\n const msgFilter = (msg) => {\r\n let result = true;\r\n if (componentFilter & ComponentMsgFilter.FromAncestors) {\r\n const ancestorIds = component.getChainUp();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && componentFilter & ComponentMsgFilter.FromDescendants) {\r\n const ancestorIds = component.getChainDown();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && filter) {\r\n result = filter(msg, component);\r\n }\r\n return result;\r\n };\r\n subscriber.filter = msgFilter;\r\n\r\n component.msgBus.on({\r\n ...s,\r\n channel: channel,\r\n group: g,\r\n config: {\r\n abortSignal: component.msgBroker.abortController.signal,\r\n },\r\n });\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction getComponentMsgBus<TStruct extends ComponentStruct = ComponentStruct>(\r\n msgBus: MsgBus<TStruct['msg']>,\r\n headerSetter: (headers?: ComponentMsgHeaders) => void,\r\n) {\r\n const updateParams = (params: { payload?: any; headers?: ComponentMsgHeaders }) => {\r\n if (params.payload != undefined) {\r\n params.payload = structuredClone(toJS(params.payload)); // always?\r\n }\r\n if (!params.headers) {\r\n params.headers = {};\r\n }\r\n headerSetter?.(params.headers);\r\n };\r\n return {\r\n config: msgBus.config,\r\n on: (params) => {\r\n return msgBus.on(params);\r\n },\r\n onceAsync: (params) => {\r\n return msgBus.onceAsync(params);\r\n },\r\n stream: (params) => {\r\n return msgBus.stream(params);\r\n },\r\n provide: (params) => {\r\n updateParams(params);\r\n return msgBus.provide(params);\r\n },\r\n dispatch: (params) => {\r\n updateParams(params);\r\n return msgBus.dispatch(params);\r\n },\r\n dispatchAsync: (params) => {\r\n updateParams(params);\r\n return msgBus.dispatchAsync(params);\r\n },\r\n } as MsgBus<TStruct['msg']>;\r\n}\r\n\r\nexport type EffectController = {\r\n start: () => void;\r\n pause: () => void;\r\n resume: () => void;\r\n stop: () => void;\r\n restart: () => void;\r\n};\r\n\r\nexport function createEffect<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n>(\r\n component: Component<TStruct, TMsgHeaders>,\r\n name: string,\r\n fn: EffectFn<TStruct, TMsgHeaders>,\r\n): EffectController {\r\n let disposer: IReactionDisposer | null = null;\r\n let paused = false;\r\n let effectCleanup: () => void = undefined;\r\n\r\n const start = () => {\r\n if (disposer) {\r\n return;\r\n }\r\n\r\n disposer = autorun(\r\n () => {\r\n if (!paused) {\r\n const cleanup = fn(component);\r\n if (typeof cleanup === 'function') {\r\n cleanup();\r\n effectCleanup = cleanup;\r\n }\r\n }\r\n },\r\n { name: `effect:${name}` },\r\n );\r\n };\r\n\r\n const stop = () => {\r\n disposer?.();\r\n disposer = null;\r\n if (effectCleanup) {\r\n effectCleanup();\r\n effectCleanup = undefined;\r\n }\r\n };\r\n\r\n const pause = () => {\r\n paused = true;\r\n };\r\n\r\n const resume = () => {\r\n paused = false;\r\n };\r\n\r\n const restart = () => {\r\n stop();\r\n start();\r\n };\r\n\r\n start();\r\n\r\n return { start, pause, resume, stop, restart };\r\n}\r\n\r\nfunction createComponent<TStruct extends ComponentStruct = ComponentStruct>(\r\n componentDef: ComponentDef<TStruct>,\r\n params?: ComponentParams<TStruct>,\r\n): Component<TStruct> {\r\n // result\r\n let component: Mutable<Component<TStruct>>;\r\n let model: Mutable<ComponentModel<TStruct>>;\r\n\r\n if (!componentDef) {\r\n componentDef = {};\r\n }\r\n\r\n if (!params) {\r\n params = {};\r\n }\r\n\r\n const view = componentDef.view;\r\n let msgBus = componentDef.msgBus;\r\n\r\n const bindings = new Map<PropertyKey, Binding>();\r\n\r\n const componentMsgBus = lazy(() => {\r\n return getComponentMsgBus(msgBus, (headers) => {\r\n if (headers?.sourceId == undefined) {\r\n headers.sourceId = component.id;\r\n }\r\n }); // as ComponentModel<TStruct>['msgBus']\r\n });\r\n\r\n let msgBroker = {\r\n ...componentDef.msgBroker,\r\n };\r\n\r\n if (!msgBroker.abortController) {\r\n msgBroker.abortController = new AbortController();\r\n }\r\n\r\n const ViewFC = observer((props: ComponentViewProps) => {\r\n const id = component.id;\r\n const context = useComponentContext();\r\n const parentId = context.currentId;\r\n\r\n component.parentId = parentId;\r\n\r\n if (!msgBus) {\r\n msgBus = context.msgBus;\r\n }\r\n\r\n const scopeContext = useMemo(\r\n () => ({ ...context, currentId: id }),\r\n [componentDef, params, context],\r\n );\r\n\r\n useLayoutEffect(() => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>layout`);\r\n }\r\n\r\n context.register(id, parentId);\r\n\r\n component.getHierarchyId = () => context.getHierarchyPath(id);\r\n component.getChainDown = () => context.getChainDown(id);\r\n component.getChainUp = () => context.getChainUp(id);\r\n component.getChildren = () => context.getChildren(id);\r\n component.getParent = () => context.getParent(id);\r\n component.getNodeMap = () => context.getNodeMap();\r\n\r\n registerMsgBroker(component);\r\n\r\n componentDef.events?.onLayout?.(component);\r\n params.onLayout?.(component);\r\n } catch (err) {\r\n componentDef.events?.onError?.(component, err);\r\n params.onError?.(component, err);\r\n }\r\n\r\n return () => {\r\n if (getGlobalFlags().debug) {\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>layout-destroy`);\r\n }\r\n context.unregister(id);\r\n\r\n msgBroker.abortController?.abort();\r\n\r\n componentDef.events?.onLayoutDestroy?.(component);\r\n params.onLayoutDestroy?.(component);\r\n };\r\n }, [componentDef, params, context]);\r\n\r\n useEffect(() => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n // mount\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>ready`);\r\n }\r\n componentDef.events?.onReady?.(component);\r\n params.onReady?.(component);\r\n } catch (err) {\r\n if (getGlobalFlags().debug) {\r\n // unmount\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>destroy`);\r\n }\r\n componentDef.events?.onError?.(component, err);\r\n params.onError?.(component, err);\r\n }\r\n return () => {\r\n componentDef.events?.onDestroy?.(component);\r\n params.onDestroy?.(component);\r\n };\r\n }, [componentDef, params, context]);\r\n\r\n let content: React.ReactNode;\r\n // let content: any;\r\n try {\r\n if (getGlobalFlags().debug) {\r\n // render\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>view`);\r\n }\r\n if (typeof view === 'function') {\r\n content = view(props, component);\r\n } else {\r\n // content = props.children;\r\n content = <>{props.children}</>;\r\n }\r\n } catch (err) {\r\n // throw err;\r\n const errDetails = JSON.stringify(err);\r\n // msgBus.dispatch\r\n content = <>{errDetails}</>;\r\n }\r\n return (\r\n <ReactComponentContext.Provider value={scopeContext}>\r\n {content}\r\n </ReactComponentContext.Provider>\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 = componentDef.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 id = `${srcInfo.structId}#${srcInfo.count}`;\r\n\r\n const children = {} as ComponentChildren<TStruct['children']>;\r\n\r\n model = {} as Mutable<ComponentModel<TStruct>>;\r\n\r\n if (componentDef.props) {\r\n Object.assign(model, componentDef.props);\r\n }\r\n\r\n if (componentDef.actions) {\r\n Object.assign(model, componentDef.actions);\r\n }\r\n\r\n if (componentDef.children) {\r\n for (const [key, value] of Object.entries(componentDef.children)) {\r\n if (typeof value == 'function') {\r\n const view = value as (params: any) => Component;\r\n // observer\r\n const ChildViewFC: ComponentViewImplFn<TStruct> = (props) => {\r\n const c = view(props);\r\n return <c.View />;\r\n // if (typeof c.view === \"function\") {\r\n // return c.view(props);\r\n // }\r\n // return <>{props.children}</>;\r\n };\r\n Reflect.set(children, capitalize(key), ChildViewFC);\r\n } else {\r\n Reflect.set(children, key, value);\r\n }\r\n }\r\n }\r\n\r\n // Reflect.ownKeys/Object.keys\r\n for (const [key, value] of Object.entries(params)) {\r\n // model.hasOwnProperty(key)\r\n if (key in model) {\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\r\n const proxyEventHandlers: Pick<ProxyEventHandlers, 'onPropChanging' | 'onPropChange'> = {\r\n onPropChanging:\r\n params.onPropChanging || componentDef.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 = componentDef.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 || componentDef.events?.onPropChange\r\n ? (prop, value) => {\r\n params.onPropChange?.(String(prop), value);\r\n componentDef.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] || componentDef.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 = componentDef.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 (componentDef.events?.[key] as ValueChangeHandler<any>)?.(value);\r\n }) as ValueChangeHandler;\r\n }\r\n\r\n let annotationMap: Record<string, any> = {};\r\n\r\n if (componentDef.props) {\r\n for (const prop of Object.keys(componentDef.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 for (const key of Object.keys(componentDef.props)) {\r\n annotationMap[key] = observable.deep;\r\n }\r\n }\r\n\r\n if (componentDef.actions) {\r\n const annotationMap: Record<string, any> = {};\r\n for (const key of Object.keys(componentDef.actions)) {\r\n annotationMap[key] = action;\r\n }\r\n }\r\n\r\n model = observable(model, annotationMap, {\r\n deep: true,\r\n });\r\n\r\n model = createRecursiveProxy(model, bindings, proxyEventHandlers);\r\n\r\n let effects: Record<string, EffectController> = {};\r\n component = {\r\n id: id,\r\n parentId: undefined,\r\n getHierarchyId: () => undefined,\r\n getChainDown: () => undefined,\r\n getChainUp: () => undefined,\r\n getChildren: () => undefined,\r\n getParent: () => undefined,\r\n getNodeMap: () => undefined,\r\n bindings: bindings,\r\n get msgBus() {\r\n return componentMsgBus();\r\n },\r\n msgBroker: msgBroker,\r\n effects: effects,\r\n // view: componentDef.view,\r\n View: ViewFC,\r\n children: children,\r\n model: model,\r\n };\r\n\r\n if (componentDef.effects) {\r\n for (const [name, fn] of Object.entries(componentDef.effects)) {\r\n effects[name] = createEffect(\r\n component,\r\n name,\r\n fn as EffectFn<TStruct, ComponentMsgHeaders>,\r\n );\r\n }\r\n }\r\n\r\n if (componentDef.events?.onInit) {\r\n componentDef.events.onInit(component);\r\n }\r\n\r\n if (params.onInit) {\r\n params.onInit(component);\r\n }\r\n\r\n return component;\r\n}\r\n\r\nexport function useComponent<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n>(componentDef: ComponentDef<TStruct, TMsgHeaders>, params: ComponentParams<TStruct>) {\r\n const ref = useLazyRef(() => createComponent(componentDef, params));\r\n useLayoutEffect(() => {\r\n return () => {\r\n ref.current = null;\r\n };\r\n }, [componentDef, params]);\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>) => Component<TStruct>,\r\n): FC<ComponentParams<TStruct>> {\r\n // observer\r\n const fc = (params: ComponentParams<TStruct> & PropsWithChildren) => {\r\n // componentHook\r\n const c = factory(params); // without useRef!\r\n // return c.view();\r\n return <c.View {...params} />;\r\n };\r\n return fc;\r\n}\r\n"],"names":["ComponentMsgFilter","$isBinding","Binding","get","set","converter","validator","isBinding","obj","bind","bindProp","target","prop","value","$ON_GET","$ON_CHANGING","$ON_CHANGE","proxyCache","createRecursiveProxy","bindings","handlers","isObservable","proxy","receiver","onGet","binding","oldValue","onChanging","result","runInAction","capitalize","name","componentData","toHtmlId","url","segmentsCount","segment","getCallerFileName","depth","stack","match","registerMsgBroker","component","providers","channel","providerGroups","g","p","provider","callback","msg","headers","filter","componentFilter","msgFilter","subscribers","subscriberGroups","s","subscriber","getComponentMsgBus","msgBus","headerSetter","updateParams","params","toJS","createEffect","fn","disposer","paused","effectCleanup","start","autorun","cleanup","stop","pause","resume","restart","createComponent","componentDef","model","view","componentMsgBus","lazy","msgBroker","ViewFC","observer","props","id","context","useComponentContext","parentId","scopeContext","useMemo","useLayoutEffect","getGlobalFlags","hierarchyId","err","useEffect","content","React","errDetails","ReactComponentContext","srcInfo","sources","fileName","srcName","children","key","ChildViewFC","c","proxyEventHandlers","newValue","handler","resolveOnGetEventHandler","resolveOnChangingEventHandler","resolveOnChangeEventHandler","annotationMap","observable","effects","useComponent","ref","useLazyRef","getFC","factory"],"mappings":";;;;;;;AA0CO,IAAKA,sBAAAA,OACRA,EAAAA,EAAA,OAAO,CAAA,IAAP,QAEAA,EAAAA,EAAA,gBAAgB,CAAA,IAAhB,iBACAA,EAAAA,EAAA,kBAAkB,CAAA,IAAlB,mBAJQA,IAAAA,KAAA,CAAA,CAAA;AA4JZ,MAAMC,IAAa,OAAO,YAAY;AAEtC,MAAMC,EAA8B;AAAA;AAAA,EAEvB;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,GAA0B;AAChD,SAAOA,EAAIP,CAAU,MAAM;AAC/B;AAEO,SAASQ,GACZN,GACAC,GACAC,GACAC,GACF;AACE,SAAO,IAAIJ,EAAQC,GAAKC,GAAKC,GAAWC,CAAS;AACrD;AAEO,SAASI,GAA8CC,GAAiBC,GAAS;AACpF,SAAO,IAAIV;AAAA,IACP,MAAMS,EAAA,EAASC,CAAI;AAAA,IACnB,CAACC,MAAgB;AACb,MAAAF,EAAA,EAASC,CAAI,IAAIC;AAAA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AAA;AAAA;AAAA,IACb,WAAW,MAAA;AAAA;AAAA,IACX,YAAY,MAAA;AAAA;AAAA,IACZ,UAAApE;AAAA,IACA,IAAI,SAAS;AACT,aAAO8D,EAAA;AAAA,IACX;AAAA,IACA,WAAAE;AAAA,IACA,SAAAmC;AAAA;AAAA,IAEA,MAAMlC;AAAA,IACN,UAAAsB;AAAA,IACA,OAAA3B;AAAA,EAAA,GAGAD,EAAa;AACb,eAAW,CAAC/C,GAAMmC,CAAE,KAAK,OAAO,QAAQY,EAAa,OAAO;AACxD,MAAAwC,EAAQvF,CAAI,IAAIkC;AAAA,QACZvB;AAAA,QACAX;AAAA,QACAmC;AAAA,MAAA;AAKZ,SAAIY,EAAa,QAAQ,UACrBA,EAAa,OAAO,OAAOpC,CAAS,GAGpCqB,EAAO,UACPA,EAAO,OAAOrB,CAAS,GAGpBA;AACX;AAEO,SAAS6E,GAGdzC,GAAkDf,GAAkC;AAClF,QAAMyD,IAAMC,EAAW,MAAM5C,GAAgBC,GAAcf,CAAM,CAAC;AAClE,SAAA8B,EAAgB,MACL,MAAM;AACT,IAAA2B,EAAI,UAAU;AAAA,EAClB,GACD,CAAC1C,GAAcf,CAAM,CAAC,GAClByD,EAAI;AACf;AAGO,SAASE,GACZC,GAC4B;AAQ5B,SANW,CAAC5D,MAAyD;AAEjE,UAAM8C,IAAIc,EAAQ5D,CAAM;AAExB,WAAO,gBAAAoC,EAAA,cAACU,EAAE,MAAF,EAAQ,GAAG9C,GAAQ;AAAA,EAC/B;AAEJ;"}
1
+ {"version":3,"file":"componentModel.es.js","sources":["../../src/componentModel/componentModel.tsx"],"sourcesContent":["import React, { useMemo } from 'react';\r\nimport { PropsWithChildren, useEffect, useLayoutEffect, FC, ReactNode } from 'react';\r\nimport {\r\n $CG_IN,\r\n $CG_OUT,\r\n $TypeArgHeaders,\r\n $TypeArgStruct,\r\n Msg,\r\n MsgBus,\r\n MsgProviderParams,\r\n MsgStruct,\r\n MsgSubscriberParams,\r\n OutStruct,\r\n} from '@actdim/msgmesh/msgBusCore';\r\nimport {\r\n Extends,\r\n HasKeys,\r\n IF,\r\n IsEmpty,\r\n KeyOf,\r\n MaybeKeyOf,\r\n MaybePromise,\r\n Mutable,\r\n Require,\r\n Skip,\r\n} from '@actdim/utico/typeCore';\r\nimport { observer } from 'mobx-react-lite';\r\nimport {\r\n action,\r\n isObservable,\r\n observable,\r\n runInAction,\r\n toJS,\r\n autorun,\r\n IReactionDisposer,\r\n} from 'mobx';\r\nimport { useLazyRef } from '@/reactHooks';\r\nimport { getGlobalFlags } from '@/globals';\r\nimport { ReactComponentContext, useComponentContext } from './componentContext';\r\nimport { ComponentMsgHeaders, TreeNode } from './contracts';\r\nimport { lazy } from '@actdim/utico/utils';\r\nimport { isPlainObject } from 'mobx/dist/internal';\r\n\r\nexport enum ComponentMsgFilter {\r\n None = 0,\r\n // AcceptFrom...\r\n FromAncestors = 1 << 0,\r\n FromDescendants = 1 << 1,\r\n}\r\n\r\nexport type MsgChannelGroupProviderParams<\r\n TStruct extends MsgStruct = MsgStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n TScope = any,\r\n> = Skip<\r\n MsgProviderParams<TStruct, TChannel, TGroup>,\r\n 'channel' | 'group' | 'callback' | 'filter'\r\n> & {\r\n // resolve\r\n callback?: (\r\n msgIn: Msg<TStruct, TChannel, TGroup, TMsgHeaders>,\r\n headers: TMsgHeaders,\r\n scope: TScope,\r\n ) => MaybePromise<OutStruct<TStruct, TChannel>>;\r\n filter?: (msg: Msg<TStruct, TChannel, TGroup, TMsgHeaders>, scope: TScope) => boolean;\r\n componentFilter?: ComponentMsgFilter;\r\n};\r\n\r\nexport type MsgChannelGroupSubscriberParams<\r\n TStruct extends MsgStruct = MsgStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n TScope = any,\r\n> = Skip<\r\n MsgSubscriberParams<TStruct, TChannel, TGroup>,\r\n 'channel' | 'group' | 'callback' | 'filter'\r\n> & {\r\n callback?: (msg: Msg<TStruct, TChannel, TGroup, TMsgHeaders>, scope: TScope) => void;\r\n filter?: (msg: Msg<TStruct, TChannel, TGroup, TMsgHeaders>, scope: TScope) => boolean;\r\n componentFilter?: ComponentMsgFilter;\r\n};\r\n\r\n// MsgScope\r\nexport type MsgBrokerScope<\r\n TStruct extends MsgStruct /*= MsgStruct*/,\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<TMsgStruct, T>>;\r\nexport type ComponentRefStruct = {\r\n [name: string]: ComponentStruct | ((params: any) => ComponentStruct);\r\n};\r\n\r\nexport type ComponentStructBase<\r\n TMsgStruct extends MsgStruct = MsgStruct,\r\n TPropStruct extends ComponentPropStruct = ComponentPropStruct,\r\n TMsgScope extends MsgBrokerScope<TMsgStruct> = MsgBrokerScope<TMsgStruct>,\r\n> = {\r\n props?: TPropStruct;\r\n actions?: ComponentMethodStruct;\r\n effects?: string[] | string | undefined;\r\n children?: ComponentRefStruct;\r\n // msgs?\r\n msgScope?: TMsgScope;\r\n};\r\n\r\n// ComponentShape\r\nexport type ComponentStruct<\r\n TMsgStruct extends MsgStruct = MsgStruct,\r\n T extends ComponentStructBase<TMsgStruct> = ComponentStructBase<TMsgStruct>,\r\n> = T & {\r\n msg: TMsgStruct;\r\n};\r\n\r\nexport type MsgBroker<\r\n TStructToProvide extends MsgStruct = MsgStruct,\r\n TStructToSubscribe extends MsgStruct = MsgStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n TScope = any,\r\n> = Require<\r\n {\r\n // providers\r\n provide?: Require<\r\n {\r\n [TChannel in keyof TStructToProvide]: {\r\n [TGroup in keyof Skip<\r\n TStructToProvide[TChannel],\r\n typeof $CG_OUT\r\n >]?: MsgChannelGroupProviderParams<\r\n TStructToProvide,\r\n TChannel,\r\n TGroup,\r\n TMsgHeaders,\r\n TScope\r\n >;\r\n };\r\n },\r\n HasKeys<TStructToProvide>\r\n >;\r\n // subscribers\r\n subscribe?: Require<\r\n {\r\n [TChannel in keyof TStructToSubscribe]: {\r\n [TGroup in keyof TStructToSubscribe[TChannel]]?: MsgChannelGroupSubscriberParams<\r\n TStructToSubscribe,\r\n TChannel,\r\n TGroup,\r\n TMsgHeaders,\r\n TScope\r\n >;\r\n };\r\n },\r\n HasKeys<TStructToSubscribe>\r\n >;\r\n abortController?: AbortController;\r\n },\r\n HasKeys<TStructToProvide & TStructToSubscribe>\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'); // brand\r\n\r\nclass Binding<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 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 Binding {\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 = PropertyKey> = (\r\n prop: TProp,\r\n oldValue: any,\r\n newValue: any,\r\n) => boolean;\r\ntype PropValueChangeHandler<TProp = PropertyKey> = (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?: (component: Component<TStruct>) => void;\r\n onLayout?: (component: Component<TStruct>) => void;\r\n onReady?: (component: Component<TStruct>) => void;\r\n onLayoutDestroy?: (component: Component<TStruct>) => void; // onLayoutCleanup\r\n onDestroy?: (component: Component<TStruct>) => void; // onDispose/onCleanup\r\n onError?: (component: Component<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<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = (props: ComponentViewProps, component?: Component<TStruct, TMsgHeaders>) => 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 ComponentMsgBroker<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = MsgBroker<\r\n Pick<TStruct['msg'], MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['provide']>>,\r\n Pick<TStruct['msg'], MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['subscribe']>>,\r\n TMsgHeaders,\r\n Component<TStruct, TMsgHeaders>\r\n>;\r\n\r\nexport type EffectFn<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = (component: Component<TStruct, TMsgHeaders>) => void | (() => void);\r\n\r\nexport type ComponentDef<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = {\r\n name?: string;\r\n props?: Require<TStruct['props'], HasKeys<TStruct['props']>>;\r\n actions?: Require<TStruct['actions'], HasKeys<TStruct['actions']>>;\r\n effects?: keyof TStruct['effects'] extends never\r\n ? never\r\n : Record<\r\n TStruct['effects'] extends string ? TStruct['effects'] : TStruct['effects'][number],\r\n EffectFn<TStruct, TMsgHeaders>\r\n >;\r\n children?: ComponentDefChildren<TStruct['children']>;\r\n events?: ComponentEvents<TStruct>;\r\n // msgs?\r\n msgBroker?: ComponentMsgBroker<TStruct, TMsgHeaders>;\r\n msgBus?: MsgBus<TStruct['msg'], TMsgHeaders>;\r\n view?: ComponentViewImplFn<TStruct, TMsgHeaders>;\r\n};\r\n\r\ntype ComponentDefChildren<TRefStruct extends ComponentRefStruct> = Require<\r\n {\r\n [P in keyof TRefStruct]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? (params: TParams) => Component<T>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? Component<TRefStruct[P]>\r\n : never;\r\n },\r\n HasKeys<TRefStruct>\r\n>;\r\n\r\ntype ComponentChildren<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 ? Component<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\nexport type ComponentMsgStruct<TStruct extends ComponentStruct = ComponentStruct> = Pick<\r\n TStruct['msg'],\r\n | MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['provide']>\r\n | MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['subscribe']>\r\n | MaybeKeyOf<TStruct['msg'], TStruct['msgScope']['publish']>\r\n>;\r\n\r\nexport type ComponentBase<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = {\r\n id: string;\r\n parentId: string;\r\n // getHierarchyPath?\r\n getHierarchyId(): string;\r\n getParent(): string | undefined;\r\n getChildren(): string[];\r\n getChainUp(): string[];\r\n getChainDown(): string[];\r\n getNodeMap(): Map<string, TreeNode>;\r\n bindings: Map<PropertyKey, Binding>;\r\n msgBus: MsgBus<ComponentMsgStruct<TStruct>, TMsgHeaders>;\r\n msgBroker: ComponentMsgBroker<TStruct>;\r\n effects: Record<string, EffectController>;\r\n View: ComponentViewFn;\r\n};\r\n\r\nexport type ComponentModel<TStruct extends ComponentStruct = ComponentStruct> = TStruct['props'] &\r\n Readonly<TStruct['actions']>;\r\n\r\nexport type Component<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = {\r\n readonly model: ComponentModel<TStruct>;\r\n readonly children: Readonly<ComponentChildren<TStruct['children']>>;\r\n} & Readonly<ComponentBase<TStruct, TMsgHeaders>>;\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 ProxyEventHandlers = {\r\n onPropChanging?: PropValueChangingHandler<PropertyKey>;\r\n onPropChange?: PropValueChangeHandler<PropertyKey>;\r\n} & Record<PropertyKey, 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\nconst proxyCache = new WeakMap<object, any>();\r\nfunction createRecursiveProxy(\r\n target: any,\r\n bindings: Map<PropertyKey, Binding>,\r\n handlers: ProxyEventHandlers,\r\n) {\r\n if (typeof target !== 'object' || target === null) {\r\n return target;\r\n }\r\n\r\n // isPlainObject\r\n if (!isObservable(target)) {\r\n return target;\r\n }\r\n\r\n if (proxyCache.has(target)) {\r\n return proxyCache.get(target);\r\n }\r\n\r\n const proxy = new Proxy(target, {\r\n get(obj, prop, receiver) {\r\n // 1. custom handlers\r\n const onGet = handlers[prop]?.onGet;\r\n if (onGet) return onGet();\r\n\r\n // 2. bindings\r\n const binding = bindings.get(prop);\r\n if (binding?.get) {\r\n return binding.get();\r\n }\r\n\r\n const value = Reflect.get(obj, prop, receiver);\r\n\r\n if (typeof value === 'object' && value !== null && isObservable(value)) {\r\n return createRecursiveProxy(value, bindings, handlers);\r\n }\r\n\r\n return value;\r\n },\r\n\r\n set(obj, prop, value, receiver) {\r\n const oldValue = obj[prop];\r\n\r\n // before-change hooks\r\n const onChanging = handlers[prop]?.onChanging;\r\n if (onChanging && onChanging(oldValue, value) === false) {\r\n return true;\r\n }\r\n\r\n if (\r\n handlers.onPropChanging &&\r\n handlers.onPropChanging(prop, oldValue, value) === false\r\n ) {\r\n return true;\r\n }\r\n\r\n const result = runInAction(() => {\r\n return Reflect.set(obj, prop, value, receiver);\r\n });\r\n\r\n // bindings\r\n const binding = bindings.get(prop);\r\n binding?.set?.(value);\r\n\r\n // after-change hooks\r\n handlers[prop]?.onChange?.(value);\r\n handlers.onPropChange?.(prop, value);\r\n\r\n return result;\r\n },\r\n });\r\n\r\n proxyCache.set(target, proxy);\r\n return proxy;\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 registerMsgBroker<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n) {\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 [g, p] of Object.entries(providerGroups)) {\r\n const provider = p as MsgChannelGroupProviderParams;\r\n const callback = provider.callback;\r\n if (callback) {\r\n provider.callback = (msg, headers) => {\r\n return callback(msg, headers, component);\r\n };\r\n }\r\n const filter = provider.filter;\r\n const componentFilter = provider.componentFilter || ComponentMsgFilter.None;\r\n const msgFilter = (msg) => {\r\n let result = true;\r\n if (componentFilter & ComponentMsgFilter.FromAncestors) {\r\n const ancestorIds = component.getChainUp();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && componentFilter & ComponentMsgFilter.FromDescendants) {\r\n const ancestorIds = component.getChainDown();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && filter) {\r\n result = filter(msg, component);\r\n }\r\n return result;\r\n };\r\n provider.filter = msgFilter;\r\n\r\n component.msgBus.provide({\r\n ...p,\r\n channel: channel,\r\n group: g,\r\n config: {\r\n abortSignal: component.msgBroker.abortController.signal,\r\n },\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 [g, s] of Object.entries(subscriberGroups)) {\r\n const subscriber = s as MsgChannelGroupSubscriberParams;\r\n const callback = subscriber.callback;\r\n if (callback) {\r\n subscriber.callback = (msg) => {\r\n return callback(msg, component);\r\n };\r\n }\r\n const filter = subscriber.filter;\r\n const componentFilter = subscriber.componentFilter || ComponentMsgFilter.None;\r\n const msgFilter = (msg) => {\r\n let result = true;\r\n if (componentFilter & ComponentMsgFilter.FromAncestors) {\r\n const ancestorIds = component.getChainUp();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && componentFilter & ComponentMsgFilter.FromDescendants) {\r\n const ancestorIds = component.getChainDown();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && filter) {\r\n result = filter(msg, component);\r\n }\r\n return result;\r\n };\r\n subscriber.filter = msgFilter;\r\n\r\n component.msgBus.on({\r\n ...s,\r\n channel: channel,\r\n group: g,\r\n config: {\r\n abortSignal: component.msgBroker.abortController.signal,\r\n },\r\n });\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction getComponentMsgBus<TStruct extends ComponentStruct = ComponentStruct>(\r\n msgBus: MsgBus<TStruct['msg']>,\r\n headerSetter: (headers?: ComponentMsgHeaders) => void,\r\n) {\r\n const updateParams = (params: { payload?: any; headers?: ComponentMsgHeaders }) => {\r\n if (params.payload != undefined) {\r\n params.payload = structuredClone(toJS(params.payload)); // always?\r\n }\r\n if (!params.headers) {\r\n params.headers = {};\r\n }\r\n headerSetter?.(params.headers);\r\n };\r\n return {\r\n config: msgBus.config,\r\n on: (params) => {\r\n return msgBus.on(params);\r\n },\r\n onceAsync: (params) => {\r\n return msgBus.onceAsync(params);\r\n },\r\n stream: (params) => {\r\n return msgBus.stream(params);\r\n },\r\n provide: (params) => {\r\n updateParams(params);\r\n return msgBus.provide(params);\r\n },\r\n dispatch: (params) => {\r\n updateParams(params);\r\n return msgBus.dispatch(params);\r\n },\r\n dispatchAsync: (params) => {\r\n updateParams(params);\r\n return msgBus.dispatchAsync(params);\r\n },\r\n } as MsgBus<TStruct['msg']>;\r\n}\r\n\r\nexport type EffectController = {\r\n start: () => void;\r\n pause: () => void;\r\n resume: () => void;\r\n stop: () => void;\r\n restart: () => void;\r\n};\r\n\r\nexport function createEffect<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n>(\r\n component: Component<TStruct, TMsgHeaders>,\r\n name: string,\r\n fn: EffectFn<TStruct, TMsgHeaders>,\r\n): EffectController {\r\n let disposer: IReactionDisposer | null = null;\r\n let paused = false;\r\n let effectCleanup: () => void = undefined;\r\n\r\n const start = () => {\r\n if (disposer) {\r\n return;\r\n }\r\n\r\n disposer = autorun(\r\n () => {\r\n if (!paused) {\r\n const cleanup = fn(component);\r\n if (typeof cleanup === 'function') {\r\n cleanup();\r\n effectCleanup = cleanup;\r\n }\r\n }\r\n },\r\n { name: `effect:${name}` },\r\n );\r\n };\r\n\r\n const stop = () => {\r\n disposer?.();\r\n disposer = null;\r\n if (effectCleanup) {\r\n effectCleanup();\r\n effectCleanup = undefined;\r\n }\r\n };\r\n\r\n const pause = () => {\r\n paused = true;\r\n };\r\n\r\n const resume = () => {\r\n paused = false;\r\n };\r\n\r\n const restart = () => {\r\n stop();\r\n start();\r\n };\r\n\r\n start();\r\n\r\n return { start, pause, resume, stop, restart };\r\n}\r\n\r\nfunction createComponent<TStruct extends ComponentStruct = ComponentStruct>(\r\n componentDef: ComponentDef<TStruct>,\r\n params?: ComponentParams<TStruct>,\r\n): Component<TStruct> {\r\n // result\r\n let component: Mutable<Component<TStruct>>;\r\n let model: Mutable<ComponentModel<TStruct>>;\r\n\r\n if (!componentDef) {\r\n componentDef = {};\r\n }\r\n\r\n if (!params) {\r\n params = {};\r\n }\r\n\r\n const view = componentDef.view;\r\n let msgBus = componentDef.msgBus;\r\n\r\n const bindings = new Map<PropertyKey, Binding>();\r\n\r\n const componentMsgBus = lazy(() => {\r\n return getComponentMsgBus(msgBus, (headers) => {\r\n if (headers?.sourceId == undefined) {\r\n headers.sourceId = component.id;\r\n }\r\n }); // as ComponentModel<TStruct>['msgBus']\r\n });\r\n\r\n let msgBroker = {\r\n ...componentDef.msgBroker,\r\n };\r\n\r\n if (!msgBroker.abortController) {\r\n msgBroker.abortController = new AbortController();\r\n }\r\n\r\n const ViewFC = observer((props: ComponentViewProps) => {\r\n const id = component.id;\r\n const context = useComponentContext();\r\n const parentId = context.currentId;\r\n\r\n component.parentId = parentId;\r\n\r\n if (!msgBus) {\r\n msgBus = context.msgBus;\r\n }\r\n\r\n const scopeContext = useMemo(\r\n () => ({ ...context, currentId: id }),\r\n [componentDef, params, context],\r\n );\r\n\r\n useLayoutEffect(() => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>layout`);\r\n }\r\n\r\n context.register(id, parentId);\r\n\r\n component.getHierarchyId = () => context.getHierarchyPath(id);\r\n component.getChainDown = () => context.getChainDown(id);\r\n component.getChainUp = () => context.getChainUp(id);\r\n component.getChildren = () => context.getChildren(id);\r\n component.getParent = () => context.getParent(id);\r\n component.getNodeMap = () => context.getNodeMap();\r\n\r\n registerMsgBroker(component);\r\n\r\n componentDef.events?.onLayout?.(component);\r\n params.onLayout?.(component);\r\n } catch (err) {\r\n componentDef.events?.onError?.(component, err);\r\n params.onError?.(component, err);\r\n }\r\n\r\n return () => {\r\n if (getGlobalFlags().debug) {\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>layout-destroy`);\r\n }\r\n context.unregister(id);\r\n\r\n msgBroker.abortController?.abort();\r\n\r\n componentDef.events?.onLayoutDestroy?.(component);\r\n params.onLayoutDestroy?.(component);\r\n };\r\n }, [componentDef, params, context]);\r\n\r\n useEffect(() => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n // mount\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>ready`);\r\n }\r\n componentDef.events?.onReady?.(component);\r\n params.onReady?.(component);\r\n } catch (err) {\r\n if (getGlobalFlags().debug) {\r\n // unmount\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>destroy`);\r\n }\r\n componentDef.events?.onError?.(component, err);\r\n params.onError?.(component, err);\r\n }\r\n return () => {\r\n componentDef.events?.onDestroy?.(component);\r\n params.onDestroy?.(component);\r\n };\r\n }, [componentDef, params, context]);\r\n\r\n let content: React.ReactNode;\r\n // let content: any;\r\n try {\r\n if (getGlobalFlags().debug) {\r\n // render\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>view`);\r\n }\r\n if (typeof view === 'function') {\r\n content = view(props, component);\r\n } else {\r\n // content = props.children;\r\n content = <>{props.children}</>;\r\n }\r\n } catch (err) {\r\n // throw err;\r\n const errDetails = JSON.stringify(err);\r\n // msgBus.dispatch\r\n content = <>{errDetails}</>;\r\n }\r\n return (\r\n <ReactComponentContext.Provider value={scopeContext}>\r\n {content}\r\n </ReactComponentContext.Provider>\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 = componentDef.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 id = `${srcInfo.structId}#${srcInfo.count}`;\r\n\r\n const children = {} as ComponentChildren<TStruct['children']>;\r\n\r\n model = {} as Mutable<ComponentModel<TStruct>>;\r\n\r\n if (componentDef.props) {\r\n Object.assign(model, componentDef.props);\r\n }\r\n\r\n if (componentDef.actions) {\r\n Object.assign(model, componentDef.actions);\r\n }\r\n\r\n if (componentDef.children) {\r\n for (const [key, value] of Object.entries(componentDef.children)) {\r\n if (typeof value == 'function') {\r\n const view = value as (params: any) => Component;\r\n // observer\r\n const ChildViewFC: ComponentViewImplFn<TStruct> = (props) => {\r\n const c = view(props);\r\n return <c.View />;\r\n // if (typeof c.view === \"function\") {\r\n // return c.view(props);\r\n // }\r\n // return <>{props.children}</>;\r\n };\r\n Reflect.set(children, capitalize(key), ChildViewFC);\r\n } else {\r\n Reflect.set(children, key, value);\r\n }\r\n }\r\n }\r\n\r\n // Reflect.ownKeys/Object.keys\r\n for (const [key, value] of Object.entries(params)) {\r\n // model.hasOwnProperty(key)\r\n if (key in model) {\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\r\n const proxyEventHandlers: Pick<ProxyEventHandlers, 'onPropChanging' | 'onPropChange'> = {\r\n onPropChanging:\r\n params.onPropChanging || componentDef.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 = componentDef.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 || componentDef.events?.onPropChange\r\n ? (prop, value) => {\r\n params.onPropChange?.(String(prop), value);\r\n componentDef.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] || componentDef.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 = componentDef.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 (componentDef.events?.[key] as ValueChangeHandler<any>)?.(value);\r\n }) as ValueChangeHandler;\r\n }\r\n\r\n let annotationMap: Record<string, any> = {};\r\n\r\n if (componentDef.props) {\r\n for (const prop of Object.keys(componentDef.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 for (const key of Object.keys(componentDef.props)) {\r\n annotationMap[key] = observable.deep;\r\n }\r\n }\r\n\r\n if (componentDef.actions) {\r\n const annotationMap: Record<string, any> = {};\r\n for (const key of Object.keys(componentDef.actions)) {\r\n annotationMap[key] = action;\r\n }\r\n }\r\n\r\n model = observable(model, annotationMap, {\r\n deep: true,\r\n });\r\n\r\n model = createRecursiveProxy(model, bindings, proxyEventHandlers);\r\n\r\n let effects: Record<string, EffectController> = {};\r\n component = {\r\n id: id,\r\n parentId: undefined,\r\n getHierarchyId: () => undefined,\r\n getChainDown: () => undefined,\r\n getChainUp: () => undefined,\r\n getChildren: () => undefined,\r\n getParent: () => undefined,\r\n getNodeMap: () => undefined,\r\n bindings: bindings,\r\n get msgBus() {\r\n return componentMsgBus();\r\n },\r\n msgBroker: msgBroker,\r\n effects: effects,\r\n // view: componentDef.view,\r\n View: ViewFC,\r\n children: children,\r\n model: model,\r\n };\r\n\r\n if (componentDef.effects) {\r\n for (const [name, fn] of Object.entries(componentDef.effects)) {\r\n effects[name] = createEffect(\r\n component,\r\n name,\r\n fn as EffectFn<TStruct, ComponentMsgHeaders>,\r\n );\r\n }\r\n }\r\n\r\n if (componentDef.events?.onInit) {\r\n componentDef.events.onInit(component);\r\n }\r\n\r\n if (params.onInit) {\r\n params.onInit(component);\r\n }\r\n\r\n return component;\r\n}\r\n\r\nexport function useComponent<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n>(componentDef: ComponentDef<TStruct, TMsgHeaders>, params: ComponentParams<TStruct>) {\r\n const ref = useLazyRef(() => createComponent(componentDef, params));\r\n useLayoutEffect(() => {\r\n return () => {\r\n ref.current = null;\r\n };\r\n }, [componentDef, params]);\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>) => Component<TStruct>,\r\n): FC<ComponentParams<TStruct>> {\r\n // observer\r\n const fc = (params: ComponentParams<TStruct> & PropsWithChildren) => {\r\n // componentHook\r\n const c = factory(params); // without useRef!\r\n // return c.view();\r\n return <c.View {...params} />;\r\n };\r\n return fc;\r\n}\r\n"],"names":["ComponentMsgFilter","$isBinding","Binding","get","set","converter","validator","isBinding","obj","bind","bindProp","target","prop","value","$ON_GET","$ON_CHANGING","$ON_CHANGE","proxyCache","createRecursiveProxy","bindings","handlers","isObservable","proxy","receiver","onGet","binding","oldValue","onChanging","result","runInAction","capitalize","name","componentData","toHtmlId","url","segmentsCount","segment","getCallerFileName","depth","stack","match","registerMsgBroker","component","providers","channel","providerGroups","g","p","provider","callback","msg","headers","filter","componentFilter","msgFilter","subscribers","subscriberGroups","s","subscriber","getComponentMsgBus","msgBus","headerSetter","updateParams","params","toJS","createEffect","fn","disposer","paused","effectCleanup","start","autorun","cleanup","stop","pause","resume","restart","createComponent","componentDef","model","view","componentMsgBus","lazy","msgBroker","ViewFC","observer","props","id","context","useComponentContext","parentId","scopeContext","useMemo","useLayoutEffect","getGlobalFlags","hierarchyId","err","useEffect","content","React","errDetails","ReactComponentContext","srcInfo","sources","fileName","srcName","children","key","ChildViewFC","c","proxyEventHandlers","newValue","handler","resolveOnGetEventHandler","resolveOnChangingEventHandler","resolveOnChangeEventHandler","annotationMap","observable","effects","useComponent","ref","useLazyRef","getFC","factory"],"mappings":";;;;;;;AA2CO,IAAKA,sBAAAA,OACRA,EAAAA,EAAA,OAAO,CAAA,IAAP,QAEAA,EAAAA,EAAA,gBAAgB,CAAA,IAAhB,iBACAA,EAAAA,EAAA,kBAAkB,CAAA,IAAlB,mBAJQA,IAAAA,KAAA,CAAA,CAAA;AA4JZ,MAAMC,IAAa,OAAO,YAAY;AAEtC,MAAMC,EAA8B;AAAA;AAAA,EAEvB;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,GAA0B;AAChD,SAAOA,EAAIP,CAAU,MAAM;AAC/B;AAEO,SAASQ,GACZN,GACAC,GACAC,GACAC,GACF;AACE,SAAO,IAAIJ,EAAQC,GAAKC,GAAKC,GAAWC,CAAS;AACrD;AAEO,SAASI,GAA8CC,GAAi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AA6C;AAAA,IACA,UAAU;AAAA,IACV,gBAAgB,MAAA;AAAA;AAAA,IAChB,cAAc,MAAA;AAAA;AAAA,IACd,YAAY,MAAA;AAAA;AAAA,IACZ,aAAa,MAAA;AAAA;AAAA,IACb,WAAW,MAAA;AAAA;AAAA,IACX,YAAY,MAAA;AAAA;AAAA,IACZ,UAAApE;AAAA,IACA,IAAI,SAAS;AACT,aAAO8D,EAAA;AAAA,IACX;AAAA,IACA,WAAAE;AAAA,IACA,SAAAmC;AAAA;AAAA,IAEA,MAAMlC;AAAA,IACN,UAAAsB;AAAA,IACA,OAAA3B;AAAA,EAAA,GAGAD,EAAa;AACb,eAAW,CAAC/C,GAAMmC,CAAE,KAAK,OAAO,QAAQY,EAAa,OAAO;AACxD,MAAAwC,EAAQvF,CAAI,IAAIkC;AAAA,QACZvB;AAAA,QACAX;AAAA,QACAmC;AAAA,MAAA;AAKZ,SAAIY,EAAa,QAAQ,UACrBA,EAAa,OAAO,OAAOpC,CAAS,GAGpCqB,EAAO,UACPA,EAAO,OAAOrB,CAAS,GAGpBA;AACX;AAEO,SAAS6E,GAGdzC,GAAkDf,GAAkC;AAClF,QAAMyD,IAAMC,EAAW,MAAM5C,GAAgBC,GAAcf,CAAM,CAAC;AAClE,SAAA8B,EAAgB,MACL,MAAM;AACT,IAAA2B,EAAI,UAAU;AAAA,EAClB,GACD,CAAC1C,GAAcf,CAAM,CAAC,GAClByD,EAAI;AACf;AAGO,SAASE,GACZC,GAC4B;AAQ5B,SANW,CAAC5D,MAAyD;AAEjE,UAAM8C,IAAIc,EAAQ5D,CAAM;AAExB,WAAO,gBAAAoC,EAAA,cAACU,EAAE,MAAF,EAAQ,GAAG9C,GAAQ;AAAA,EAC/B;AAEJ;"}
@@ -9,7 +9,8 @@ export declare class ClientBase {
9
9
  private msgBus;
10
10
  private accessToken;
11
11
  private init;
12
- constructor(context: BaseAppContext, fetcher?: IFetcher);
12
+ private apiSuffixes;
13
+ constructor(context: BaseAppContext, fetcher?: IFetcher, apiSuffixes?: string[]);
13
14
  protected getBaseUrlAsync(): Promise<void>;
14
15
  private updateSecurityAsync;
15
16
  private addAuthorizationAsync;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/net/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,QAAQ,EAAqB,cAAc,EAAiB,MAAM,WAAW,CAAC;AAE1G,OAAO,EAAoB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAS5E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAY9E;AAID,qBAAa,UAAU;IACnB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IAEvB,OAAO,CAAC,eAAe,CAA6B;IAEpD,OAAO,CAAC,OAAO,CAAW;IAE1B,OAAO,CAAC,MAAM,CAA2B;IAEzC,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,IAAI,CAAe;gBAEf,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,QAAQ;cAevC,eAAe;YAUjB,mBAAmB;YAUnB,qBAAqB;YAqBrB,2BAA2B;YAkD3B,mBAAmB;IA+CpB,UAAU,CAAC,CAAC,EAAE,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;CA2CxE"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/net/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,QAAQ,EAAqB,cAAc,EAAiB,MAAM,WAAW,CAAC;AAE1G,OAAO,EAAoB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAS5E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAa9E;AAID,qBAAa,UAAU;IACnB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAE1B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IAGvB,OAAO,CAAC,eAAe,CAA6B;IAEpD,OAAO,CAAC,OAAO,CAAW;IAE1B,OAAO,CAAC,MAAM,CAA2B;IAEzC,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,IAAI,CAAe;IAE3B,OAAO,CAAC,WAAW,CAAW;gBAElB,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,WAAW,WAAe;cAgBnE,eAAe;YAcjB,mBAAmB;YAUnB,qBAAqB;YAqBrB,2BAA2B;YAkD3B,mBAAmB;IA+CpB,UAAU,CAAC,CAAC,EAAE,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;CA2CxE"}
@@ -1,16 +1,16 @@
1
1
  import { v4 as d } from "uuid";
2
2
  import o from "http-status";
3
- import { getResponseResult as p } from "./request.es.js";
3
+ import { getResponseResult as u } from "./request.es.js";
4
4
  import { ApiError as r } from "./apiError.es.js";
5
- function u(c, e) {
6
- if (!c)
7
- return c;
8
- const t = e.map((i) => i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), a = new RegExp(`(_?(${t}))+?$`, "i");
9
- let n = c.replace(a, "");
10
- return n = n.trim(), n.length > 0 ? n : c;
5
+ function f(i, e) {
6
+ if (!i)
7
+ return i;
8
+ const t = e.map((c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), s = new RegExp(`(_?(${t}))+?$`, "i");
9
+ let a = i.replace(s, "");
10
+ return a = a.trim(), a.length > 0 ? a : i;
11
11
  }
12
- const f = ["api", "controller", "client", "fetcher"];
13
- class R {
12
+ const p = ["api", "controller", "client", "fetcher"];
13
+ class g {
14
14
  baseUrl;
15
15
  name;
16
16
  // private requestStates
@@ -19,20 +19,21 @@ class R {
19
19
  msgBus;
20
20
  accessToken;
21
21
  init;
22
- constructor(e, s) {
23
- this.fetcher = s || window, this.requestStateMap = /* @__PURE__ */ new Map(), this.msgBus = e.msgBus, this.msgBus.on({
22
+ apiSuffixes;
23
+ constructor(e, n, t = p) {
24
+ this.apiSuffixes = t, this.fetcher = n || window, this.requestStateMap = /* @__PURE__ */ new Map(), this.msgBus = e.msgBus, this.msgBus.on({
24
25
  channel: "APP-SECURITY-AUTH-SIGNIN",
25
26
  group: "out",
26
- callback: (t) => {
27
- this.accessToken = t.payload.accessToken;
27
+ callback: (s) => {
28
+ this.accessToken = s.payload.accessToken;
28
29
  }
29
30
  }), this.init = Promise.all([this.getBaseUrlAsync(), this.updateSecurityAsync()]);
30
31
  }
31
32
  async getBaseUrlAsync() {
32
- const s = (await this.msgBus.dispatchAsync({
33
+ const n = (await this.msgBus.dispatchAsync({
33
34
  channel: "APP-CONFIG-GET"
34
- })).payload, t = u(this.name, f), a = Object.entries(s.apis).find((n) => n[0].toLowerCase() === t?.toLowerCase());
35
- this.baseUrl = a?.[1].url || s.baseUrl;
35
+ })).payload, t = f(this.name, this.apiSuffixes), s = Object.entries(n.apis).find((a) => a[0].toLowerCase() === t?.toLowerCase());
36
+ s || console.warn(`API "${t}" is not defined in the current configuration. Using default configuration.`), this.baseUrl = s?.[1].url || n.baseUrl;
36
37
  }
37
38
  async updateSecurityAsync() {
38
39
  if (!this.accessToken) {
@@ -44,60 +45,60 @@ class R {
44
45
  return this.accessToken;
45
46
  }
46
47
  async addAuthorizationAsync(e) {
47
- const s = await this.updateSecurityAsync();
48
- if (!s)
48
+ const n = await this.updateSecurityAsync();
49
+ if (!n)
49
50
  throw r.create({
50
51
  status: o.UNAUTHORIZED
51
52
  });
52
- const t = "Authorization", a = e.headers, n = `Bearer ${s}`;
53
- if (a instanceof Headers)
54
- a.set(t, n);
53
+ const t = "Authorization", s = e.headers, a = `Bearer ${n}`;
54
+ if (s instanceof Headers)
55
+ s.set(t, a);
55
56
  else
56
57
  throw new Error("Unsupported headers");
57
58
  }
58
59
  async executeRequestInternalAsync(e) {
59
60
  try {
60
- let s = !0;
61
+ let n = !0;
61
62
  const t = e.callbacks && e.callbacks.onBeforeSendRequest;
62
63
  if (t) {
63
- const a = {
64
+ const s = {
64
65
  request: e,
65
66
  cancel: !1,
66
67
  handled: !1
67
68
  };
68
- if (await t(a), a.cancel)
69
- if (s = !1, e.status = "canceled", a.handled)
70
- e.result = a.result;
69
+ if (await t(s), s.cancel)
70
+ if (n = !1, e.status = "canceled", s.handled)
71
+ e.result = s.result;
71
72
  else
72
73
  throw new Error("The request was aborted");
73
74
  }
74
- if (s) {
75
+ if (n) {
75
76
  e.status = "executing";
76
- const a = await this.fetcher.fetch(e.url, e);
77
- r.assert(a, e);
78
- let n = e.callbacks && e.callbacks.onResponseRead;
79
- n || (n = async (l) => {
80
- const h = await p(a, e);
77
+ const s = await this.fetcher.fetch(e.url, e);
78
+ r.assert(s, e);
79
+ let a = e.callbacks && e.callbacks.onResponseRead;
80
+ a || (a = async (l) => {
81
+ const h = await u(s, e);
81
82
  l.result = h;
82
83
  });
83
- const i = {
84
- response: a
84
+ const c = {
85
+ response: s
85
86
  };
86
- await n(i), e.result = i.result, e.status = "succeeded";
87
+ await a(c), e.result = c.result, e.status = "succeeded";
87
88
  }
88
- } catch (s) {
89
- throw e.status = "failed", s;
89
+ } catch (n) {
90
+ throw e.status = "failed", n;
90
91
  }
91
92
  return e;
92
93
  }
93
94
  async executeRequestAsync(e) {
94
- let s = 0;
95
+ let n = 0;
95
96
  do
96
97
  try {
97
98
  return e.useAuth && await this.addAuthorizationAsync(e), await this.executeRequestInternalAsync(e);
98
99
  } catch (t) {
99
100
  if (t instanceof r) {
100
- if (s > 0 || t.status === o.UPGRADE_REQUIRED)
101
+ if (n > 0 || t.status === o.UPGRADE_REQUIRED)
101
102
  throw t;
102
103
  if (t.status === o.UNAUTHORIZED) {
103
104
  t.response?.headers?.get("token-expired") ? await this.msgBus.dispatchAsync({
@@ -111,7 +112,7 @@ class R {
111
112
  }
112
113
  throw t;
113
114
  } finally {
114
- s++;
115
+ n++;
115
116
  }
116
117
  while (!0);
117
118
  }
@@ -136,7 +137,7 @@ class R {
136
137
  }
137
138
  }
138
139
  export {
139
- R as ClientBase,
140
- u as extractApiName
140
+ g as ClientBase,
141
+ f as extractApiName
141
142
  };
142
143
  //# sourceMappingURL=client.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.es.js","sources":["../../src/net/client.ts"],"sourcesContent":["import { v4 as uuid } from \"uuid\";\r\nimport httpStatus from \"http-status\";\r\nimport { getResponseResult, IFetcher, IRequestCallbacks, IRequestParams, IRequestState } from \"./request\";\r\nimport { ApiError } from \"./apiError\";\r\nimport { BaseAppMsgStruct, BaseAppContext } from \"@/appDomain/appContracts\";\r\nimport { MsgBus } from \"@actdim/msgmesh/msgBusCore\";\r\n\r\n// MLWEB-2172\r\n\r\n// TODO: support request cancellation\r\n// https://stackoverflow.com/questions/31061838/how-do-i-cancel-an-http-fetch-request\r\n// https://mukeshprajapati0251.medium.com/cancel-rest-api-pending-request-1af65e70366d\r\n\r\nexport function extractApiName(name: string, suffixes: string[]): string | null {\r\n if (!name) {\r\n return name;\r\n }\r\n const escaped = suffixes.map((s) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\r\n const group = escaped.join(\"|\");\r\n const pattern = new RegExp(`(_?(${group}))+?$`, \"i\");\r\n\r\n let result = name.replace(pattern, \"\");\r\n\r\n result = result.trim();\r\n return result.length > 0 ? result : name;\r\n}\r\n\r\nconst API_SUFFIXES = [\"api\", \"controller\", \"client\", \"fetcher\"];\r\n// App(Api)ClientBase\r\nexport class ClientBase {\r\n protected baseUrl: string;\r\n protected name: string;\r\n // private requestStates\r\n private requestStateMap: Map<string, IRequestState>;\r\n\r\n private fetcher: IFetcher;\r\n\r\n private msgBus: MsgBus<BaseAppMsgStruct>;\r\n\r\n private accessToken: string;\r\n\r\n private init: Promise<any>;\r\n\r\n constructor(context: BaseAppContext, fetcher?: IFetcher) {\r\n this.fetcher = fetcher || window;\r\n this.requestStateMap = new Map<string, IRequestState>();\r\n this.msgBus = context.msgBus;\r\n // TODO: unsubscribe\r\n this.msgBus.on({\r\n channel: \"APP-SECURITY-AUTH-SIGNIN\",\r\n group: \"out\",\r\n callback: (msg) => {\r\n this.accessToken = msg.payload.accessToken;\r\n }\r\n });\r\n this.init = Promise.all([this.getBaseUrlAsync(), this.updateSecurityAsync()]);\r\n }\r\n\r\n protected async getBaseUrlAsync() {\r\n const msg = await this.msgBus.dispatchAsync({\r\n channel: \"APP-CONFIG-GET\"\r\n });\r\n const config = msg.payload;\r\n const apiName = extractApiName(this.name, API_SUFFIXES);\r\n const apiEntry = Object.entries(config.apis).find((entry) => entry[0].toLowerCase() === apiName?.toLowerCase());\r\n this.baseUrl = apiEntry?.[1].url || config.baseUrl;\r\n }\r\n\r\n private async updateSecurityAsync() {\r\n if (!this.accessToken) {\r\n const msg = await this.msgBus.dispatchAsync({\r\n channel: \"APP-SECURITY-GET-CONTEXT\"\r\n });\r\n this.accessToken = msg.payload.accessToken;\r\n }\r\n return this.accessToken;\r\n }\r\n\r\n private async addAuthorizationAsync(request: IRequestParams) {\r\n const accessToken = await this.updateSecurityAsync();\r\n if (!accessToken) {\r\n throw ApiError.create({\r\n status: httpStatus.UNAUTHORIZED\r\n });\r\n }\r\n const authorizationHeader = \"Authorization\";\r\n const headers = request.headers;\r\n const headerValue = `Bearer ${accessToken}`;\r\n if (headers instanceof Headers) {\r\n // if (headers.has(authorizationHeader)) {\r\n // headers.delete(authorizationHeader)\r\n // }\r\n // headers.append(authorizationHeader, headerValue);\r\n headers.set(authorizationHeader, headerValue);\r\n } else {\r\n throw new Error(\"Unsupported headers\"); // object type\r\n }\r\n }\r\n\r\n private async executeRequestInternalAsync(request: IRequestState) {\r\n try {\r\n let proceed = true;\r\n const onBeforeSendRequest = request.callbacks && request.callbacks.onBeforeSendRequest;\r\n if (onBeforeSendRequest) {\r\n const event = {\r\n request: request,\r\n cancel: false,\r\n handled: false\r\n } as Parameters<IRequestCallbacks[\"onBeforeSendRequest\"]>[0];\r\n await onBeforeSendRequest(event);\r\n if (event.cancel) {\r\n // interrupt\r\n proceed = false;\r\n request.status = \"canceled\";\r\n if (event.handled) {\r\n request.result = event.result;\r\n } else {\r\n // ApiError?\r\n throw new Error(\"The request was aborted\"); // has been? canceled?\r\n }\r\n }\r\n }\r\n if (proceed) {\r\n request.status = \"executing\";\r\n const response = await this.fetcher.fetch(request.url, request);\r\n ApiError.assert(response, request);\r\n let onResponseRead = request.callbacks && request.callbacks.onResponseRead;\r\n if (!onResponseRead) {\r\n onResponseRead = async (event) => {\r\n const result = await getResponseResult(response, request);\r\n event.result = result;\r\n };\r\n }\r\n const event = {\r\n response: response\r\n } as Parameters<IRequestCallbacks[\"onResponseRead\"]>[0];\r\n\r\n await onResponseRead(event);\r\n request.result = event.result;\r\n request.status = \"succeeded\";\r\n }\r\n } catch (err) {\r\n request.status = \"failed\";\r\n // throw ApiError.create(undefined, request);\r\n throw err;\r\n }\r\n return request;\r\n }\r\n\r\n private async executeRequestAsync(request: IRequestState): Promise<IRequestState> {\r\n let attempt = 0;\r\n do {\r\n try {\r\n if (request.useAuth) {\r\n await this.addAuthorizationAsync(request);\r\n }\r\n return await this.executeRequestInternalAsync(request);\r\n } catch (err) {\r\n if (err instanceof ApiError) {\r\n if (attempt > 0) {\r\n throw err;\r\n }\r\n if (err.status === httpStatus.UPGRADE_REQUIRED) {\r\n // await this.context.msgBus.dispatchAsync({\r\n // channel: \"APP_RELOAD\" // APP_REQUEST_UPDGRADE\r\n // });\r\n throw err;\r\n } else if (err.status === httpStatus.UNAUTHORIZED) {\r\n if (err.response?.headers?.get(\"token-expired\")) {\r\n // token expired or invalid\r\n await this.msgBus.dispatchAsync({\r\n channel: \"APP-SECURITY-AUTH-REFRESH\"\r\n });\r\n } else {\r\n await this.msgBus.dispatchAsync({\r\n channel: \"APP-SECURITY-REQUEST-AUTH\"\r\n });\r\n }\r\n // codes:\r\n // TOKEN_EXPIRED\r\n // TOKEN_INVALID\r\n // TOKEN_MISSING\r\n // AUTH_REQUIRED\r\n // header: WWW-Authenticate\r\n continue;\r\n }\r\n continue;\r\n }\r\n throw err;\r\n } finally {\r\n attempt++;\r\n }\r\n } while (true);\r\n }\r\n\r\n // T extends IApiResponse\r\n public async fetchAsync<T>(requestParams: IRequestParams): Promise<T> {\r\n await this.init;\r\n\r\n const defaultParams: Partial<IRequestParams> = {\r\n contentType: \"application/json\",\r\n method: \"POST\",\r\n body: null,\r\n headers: {},\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n mode: \"cors\"\r\n };\r\n\r\n requestParams = { ...defaultParams, ...requestParams };\r\n if (!requestParams.id) {\r\n requestParams.id = uuid();\r\n }\r\n\r\n if (!(requestParams.headers instanceof Headers)) {\r\n requestParams.headers = new Headers(requestParams.headers);\r\n }\r\n\r\n requestParams.headers.append(\"Content-Type\", requestParams.contentType);\r\n // \"api-version\"\r\n\r\n if (requestParams.method === \"POST\") {\r\n if (!requestParams.body) {\r\n requestParams.body = \"\";\r\n }\r\n }\r\n\r\n let request = {\r\n ...requestParams,\r\n status: \"queued\",\r\n response: undefined,\r\n result: undefined\r\n } as IRequestState;\r\n\r\n this.requestStateMap.set(requestParams.id, request);\r\n\r\n await this.executeRequestAsync(request);\r\n return request.result;\r\n }\r\n}\r\n/* \r\nif (status === 404) {\r\n return response.text().then((_responseText) => {\r\n let result404: any = null;\r\n result404 = _responseText === \"\" ? null : JSON.parse(_responseText, this.jsonParseReviver) as __API__ProblemDetails;\r\n return throwException(\"Not Found\", status, _responseText, _headers, result404);\r\n });\r\n } else if (status !== 200 && status !== 204) {\r\n return response.text().then((_responseText) => {\r\n return throwException(\"An unexpected server error occurred.\", status, _responseText, _headers);\r\n });\r\n }\r\n\r\nBLOB\r\nlet reader = new FileReader();\r\n reader.onload = event => resolve((event.target as any).result);\r\n reader.readAsText(blob);\r\n*/\r\n"],"names":["extractApiName","name","suffixes","group","s","pattern","result","API_SUFFIXES","ClientBase","context","fetcher","msg","config","apiName","apiEntry","entry","request","accessToken","ApiError","httpStatus","authorizationHeader","headers","headerValue","proceed","onBeforeSendRequest","event","response","onResponseRead","getResponseResult","err","attempt","requestParams","uuid"],"mappings":";;;;AAaO,SAASA,EAAeC,GAAcC,GAAmC;AAC5E,MAAI,CAACD;AACD,WAAOA;AAGX,QAAME,IADUD,EAAS,IAAI,CAACE,MAAMA,EAAE,QAAQ,uBAAuB,MAAM,CAAC,EACtD,KAAK,GAAG,GACxBC,IAAU,IAAI,OAAO,OAAOF,CAAK,SAAS,GAAG;AAEnD,MAAIG,IAASL,EAAK,QAAQI,GAAS,EAAE;AAErC,SAAAC,IAASA,EAAO,KAAA,GACTA,EAAO,SAAS,IAAIA,IAASL;AACxC;AAEA,MAAMM,IAAe,CAAC,OAAO,cAAc,UAAU,SAAS;AAEvD,MAAMC,EAAW;AAAA,EACV;AAAA,EACA;AAAA;AAAA,EAEF;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAER,YAAYC,GAAyBC,GAAoB;AACrD,SAAK,UAAUA,KAAW,QAC1B,KAAK,sCAAsB,IAAA,GAC3B,KAAK,SAASD,EAAQ,QAEtB,KAAK,OAAO,GAAG;AAAA,MACX,SAAS;AAAA,MACT,OAAO;AAAA,MACP,UAAU,CAACE,MAAQ;AACf,aAAK,cAAcA,EAAI,QAAQ;AAAA,MACnC;AAAA,IAAA,CACH,GACD,KAAK,OAAO,QAAQ,IAAI,CAAC,KAAK,mBAAmB,KAAK,oBAAA,CAAqB,CAAC;AAAA,EAChF;AAAA,EAEA,MAAgB,kBAAkB;AAI9B,UAAMC,KAHM,MAAM,KAAK,OAAO,cAAc;AAAA,MACxC,SAAS;AAAA,IAAA,CACZ,GACkB,SACbC,IAAUb,EAAe,KAAK,MAAMO,CAAY,GAChDO,IAAW,OAAO,QAAQF,EAAO,IAAI,EAAE,KAAK,CAACG,MAAUA,EAAM,CAAC,EAAE,YAAA,MAAkBF,GAAS,aAAa;AAC9G,SAAK,UAAUC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mB,YACnCA,EAAc,UAAU,IAAI,QAAQA,EAAc,OAAO,IAG7DA,EAAc,QAAQ,OAAO,gBAAgBA,EAAc,WAAW,GAGlEA,EAAc,WAAW,WACpBA,EAAc,SACfA,EAAc,OAAO;AAI7B,QAAIf,IAAU;AAAA,MACV,GAAGe;AAAA,MACH,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,QAAQ;AAAA,IAAA;AAGZ,gBAAK,gBAAgB,IAAIA,EAAc,IAAIf,CAAO,GAElD,MAAM,KAAK,oBAAoBA,CAAO,GAC/BA,EAAQ;AAAA,EACnB;AACJ;"}
1
+ {"version":3,"file":"client.es.js","sources":["../../src/net/client.ts"],"sourcesContent":["import { v4 as uuid } from \"uuid\";\r\nimport httpStatus from \"http-status\";\r\nimport { getResponseResult, IFetcher, IRequestCallbacks, IRequestParams, IRequestState } from \"./request\";\r\nimport { ApiError } from \"./apiError\";\r\nimport { BaseAppMsgStruct, BaseAppContext } from \"@/appDomain/appContracts\";\r\nimport { MsgBus } from \"@actdim/msgmesh/msgBusCore\";\r\n\r\n// MLWEB-2172\r\n\r\n// TODO: support request cancellation\r\n// https://stackoverflow.com/questions/31061838/how-do-i-cancel-an-http-fetch-request\r\n// https://mukeshprajapati0251.medium.com/cancel-rest-api-pending-request-1af65e70366d\r\n\r\nexport function extractApiName(name: string, suffixes: string[]): string | null {\r\n if (!name) {\r\n return name;\r\n // return null; // ?\r\n }\r\n const escaped = suffixes.map((s) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"));\r\n const group = escaped.join(\"|\");\r\n const pattern = new RegExp(`(_?(${group}))+?$`, \"i\");\r\n\r\n let result = name.replace(pattern, \"\");\r\n\r\n result = result.trim();\r\n return result.length > 0 ? result : name;\r\n}\r\n\r\nconst API_SUFFIXES = [\"api\", \"controller\", \"client\", \"fetcher\"];\r\n// App(Api)ClientBase\r\nexport class ClientBase {\r\n protected baseUrl: string;\r\n\r\n protected name: string;\r\n\r\n // private requestStates\r\n private requestStateMap: Map<string, IRequestState>;\r\n\r\n private fetcher: IFetcher;\r\n\r\n private msgBus: MsgBus<BaseAppMsgStruct>;\r\n\r\n private accessToken: string;\r\n\r\n private init: Promise<any>;\r\n\r\n private apiSuffixes: string[];\r\n\r\n constructor(context: BaseAppContext, fetcher?: IFetcher, apiSuffixes = API_SUFFIXES) {\r\n this.apiSuffixes = apiSuffixes;\r\n this.fetcher = fetcher || window;\r\n this.requestStateMap = new Map<string, IRequestState>();\r\n this.msgBus = context.msgBus;\r\n // TODO: unsubscribe\r\n this.msgBus.on({\r\n channel: \"APP-SECURITY-AUTH-SIGNIN\",\r\n group: \"out\",\r\n callback: (msg) => {\r\n this.accessToken = msg.payload.accessToken;\r\n }\r\n });\r\n this.init = Promise.all([this.getBaseUrlAsync(), this.updateSecurityAsync()]);\r\n }\r\n\r\n protected async getBaseUrlAsync() {\r\n const msg = await this.msgBus.dispatchAsync({\r\n channel: \"APP-CONFIG-GET\"\r\n });\r\n const config = msg.payload;\r\n const apiName = extractApiName(this.name, this.apiSuffixes);\r\n const apiEntry = Object.entries(config.apis).find((entry) => entry[0].toLowerCase() === apiName?.toLowerCase());\r\n if (!apiEntry) {\r\n // console.debug\r\n console.warn(`API \"${apiName}\" is not defined in the current configuration. Using default configuration.`);\r\n }\r\n this.baseUrl = apiEntry?.[1].url || config.baseUrl;\r\n }\r\n\r\n private async updateSecurityAsync() {\r\n if (!this.accessToken) {\r\n const msg = await this.msgBus.dispatchAsync({\r\n channel: \"APP-SECURITY-GET-CONTEXT\"\r\n });\r\n this.accessToken = msg.payload.accessToken;\r\n }\r\n return this.accessToken;\r\n }\r\n\r\n private async addAuthorizationAsync(request: IRequestParams) {\r\n const accessToken = await this.updateSecurityAsync();\r\n if (!accessToken) {\r\n throw ApiError.create({\r\n status: httpStatus.UNAUTHORIZED\r\n });\r\n }\r\n const authorizationHeader = \"Authorization\";\r\n const headers = request.headers;\r\n const headerValue = `Bearer ${accessToken}`;\r\n if (headers instanceof Headers) {\r\n // if (headers.has(authorizationHeader)) {\r\n // headers.delete(authorizationHeader)\r\n // }\r\n // headers.append(authorizationHeader, headerValue);\r\n headers.set(authorizationHeader, headerValue);\r\n } else {\r\n throw new Error(\"Unsupported headers\"); // object type\r\n }\r\n }\r\n\r\n private async executeRequestInternalAsync(request: IRequestState) {\r\n try {\r\n let proceed = true;\r\n const onBeforeSendRequest = request.callbacks && request.callbacks.onBeforeSendRequest;\r\n if (onBeforeSendRequest) {\r\n const event = {\r\n request: request,\r\n cancel: false,\r\n handled: false\r\n } as Parameters<IRequestCallbacks[\"onBeforeSendRequest\"]>[0];\r\n await onBeforeSendRequest(event);\r\n if (event.cancel) {\r\n // interrupt\r\n proceed = false;\r\n request.status = \"canceled\";\r\n if (event.handled) {\r\n request.result = event.result;\r\n } else {\r\n // ApiError?\r\n throw new Error(\"The request was aborted\"); // has been? canceled?\r\n }\r\n }\r\n }\r\n if (proceed) {\r\n request.status = \"executing\";\r\n const response = await this.fetcher.fetch(request.url, request);\r\n ApiError.assert(response, request);\r\n let onResponseRead = request.callbacks && request.callbacks.onResponseRead;\r\n if (!onResponseRead) {\r\n onResponseRead = async (event) => {\r\n const result = await getResponseResult(response, request);\r\n event.result = result;\r\n };\r\n }\r\n const event = {\r\n response: response\r\n } as Parameters<IRequestCallbacks[\"onResponseRead\"]>[0];\r\n\r\n await onResponseRead(event);\r\n request.result = event.result;\r\n request.status = \"succeeded\";\r\n }\r\n } catch (err) {\r\n request.status = \"failed\";\r\n // throw ApiError.create(undefined, request);\r\n throw err;\r\n }\r\n return request;\r\n }\r\n\r\n private async executeRequestAsync(request: IRequestState): Promise<IRequestState> {\r\n let attempt = 0;\r\n do {\r\n try {\r\n if (request.useAuth) {\r\n await this.addAuthorizationAsync(request);\r\n }\r\n return await this.executeRequestInternalAsync(request);\r\n } catch (err) {\r\n if (err instanceof ApiError) {\r\n if (attempt > 0) {\r\n throw err;\r\n }\r\n if (err.status === httpStatus.UPGRADE_REQUIRED) {\r\n // await this.context.msgBus.dispatchAsync({\r\n // channel: \"APP_RELOAD\" // APP_REQUEST_UPDGRADE\r\n // });\r\n throw err;\r\n } else if (err.status === httpStatus.UNAUTHORIZED) {\r\n if (err.response?.headers?.get(\"token-expired\")) {\r\n // token expired or invalid\r\n await this.msgBus.dispatchAsync({\r\n channel: \"APP-SECURITY-AUTH-REFRESH\"\r\n });\r\n } else {\r\n await this.msgBus.dispatchAsync({\r\n channel: \"APP-SECURITY-REQUEST-AUTH\"\r\n });\r\n }\r\n // codes:\r\n // TOKEN_EXPIRED\r\n // TOKEN_INVALID\r\n // TOKEN_MISSING\r\n // AUTH_REQUIRED\r\n // header: WWW-Authenticate\r\n continue;\r\n }\r\n continue;\r\n }\r\n throw err;\r\n } finally {\r\n attempt++;\r\n }\r\n } while (true);\r\n }\r\n\r\n // T extends IApiResponse\r\n public async fetchAsync<T>(requestParams: IRequestParams): Promise<T> {\r\n await this.init;\r\n\r\n const defaultParams: Partial<IRequestParams> = {\r\n contentType: \"application/json\",\r\n method: \"POST\",\r\n body: null,\r\n headers: {},\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n mode: \"cors\"\r\n };\r\n\r\n requestParams = { ...defaultParams, ...requestParams };\r\n if (!requestParams.id) {\r\n requestParams.id = uuid();\r\n }\r\n\r\n if (!(requestParams.headers instanceof Headers)) {\r\n requestParams.headers = new Headers(requestParams.headers);\r\n }\r\n\r\n requestParams.headers.append(\"Content-Type\", requestParams.contentType);\r\n // \"api-version\"\r\n\r\n if (requestParams.method === \"POST\") {\r\n if (!requestParams.body) {\r\n requestParams.body = \"\";\r\n }\r\n }\r\n\r\n let request = {\r\n ...requestParams,\r\n status: \"queued\",\r\n response: undefined,\r\n result: undefined\r\n } as IRequestState;\r\n\r\n this.requestStateMap.set(requestParams.id, request);\r\n\r\n await this.executeRequestAsync(request);\r\n return request.result;\r\n }\r\n}\r\n/* \r\nif (status === 404) {\r\n return response.text().then((_responseText) => {\r\n let result404: any = null;\r\n result404 = _responseText === \"\" ? null : JSON.parse(_responseText, this.jsonParseReviver) as __API__ProblemDetails;\r\n return throwException(\"Not Found\", status, _responseText, _headers, result404);\r\n });\r\n } else if (status !== 200 && status !== 204) {\r\n return response.text().then((_responseText) => {\r\n return throwException(\"An unexpected server error occurred.\", status, _responseText, _headers);\r\n });\r\n }\r\n\r\nBLOB\r\nlet reader = new FileReader();\r\n reader.onload = event => resolve((event.target as any).result);\r\n reader.readAsText(blob);\r\n*/\r\n"],"names":["extractApiName","name","suffixes","group","s","pattern","result","API_SUFFIXES","ClientBase","context","fetcher","apiSuffixes","msg","config","apiName","apiEntry","entry","request","accessToken","ApiError","httpStatus","authorizationHeader","headers","headerValue","proceed","onBeforeSendRequest","event","response","onResponseRead","getResponseResult","err","attempt","requestParams","uuid"],"mappings":";;;;AAaO,SAASA,EAAeC,GAAcC,GAAmC;AAC5E,MAAI,CAACD;AACD,WAAOA;AAIX,QAAME,IADUD,EAAS,IAAI,CAACE,MAAMA,EAAE,QAAQ,uBAAuB,MAAM,CAAC,EACtD,KAAK,GAAG,GACxBC,IAAU,IAAI,OAAO,OAAOF,CAAK,SAAS,GAAG;AAEnD,MAAIG,IAASL,EAAK,QAAQI,GAAS,EAAE;AAErC,SAAAC,IAASA,EAAO,KAAA,GACTA,EAAO,SAAS,IAAIA,IAASL;AACxC;AAEA,MAAMM,IAAe,CAAC,OAAO,cAAc,UAAU,SAAS;AAEvD,MAAMC,EAAW;AAAA,EACV;AAAA,EAEA;AAAA;AAAA,EAGF;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAER,YAAYC,GAAyBC,GAAoBC,IAAcJ,GAAc;AACjF,SAAK,cAAcI,GACnB,KAAK,UAAUD,KAAW,QAC1B,KAAK,sCAAsB,IAAA,GAC3B,KAAK,SAASD,EAAQ,QAEtB,KAAK,OAAO,GAAG;AAAA,MACX,SAAS;AAAA,MACT,OAAO;AAAA,MACP,UAAU,CAACG,MAAQ;AACf,aAA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,IAED,MAAM,KAAK,OAAO,cAAc;AAAA,cAC5B,SAAS;AAAA,YAAA,CACZ;AAQL;AAAA,UACJ;AACA;AAAA,QACJ;AACA,cAAMA;AAAA,MACV,UAAA;AACI,QAAAC;AAAA,MACJ;AAAA,WACK;AAAA,EACb;AAAA;AAAA,EAGA,MAAa,WAAcC,GAA2C;AAClE,UAAM,KAAK,MAYXA,IAAgB,EAAE,GAV6B;AAAA,MAC3C,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS,CAAA;AAAA,MACT,OAAO;AAAA,MACP,aAAa;AAAA,MACb,MAAM;AAAA,IAAA,GAG0B,GAAGA,EAAA,GAClCA,EAAc,OACfA,EAAc,KAAKC,EAAA,IAGjBD,EAAc,mBAAmB,YACnCA,EAAc,UAAU,IAAI,QAAQA,EAAc,OAAO,IAG7DA,EAAc,QAAQ,OAAO,gBAAgBA,EAAc,WAAW,GAGlEA,EAAc,WAAW,WACpBA,EAAc,SACfA,EAAc,OAAO;AAI7B,QAAIf,IAAU;AAAA,MACV,GAAGe;AAAA,MACH,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,QAAQ;AAAA,IAAA;AAGZ,gBAAK,gBAAgB,IAAIA,EAAc,IAAIf,CAAO,GAElD,MAAM,KAAK,oBAAoBA,CAAO,GAC/BA,EAAQ;AAAA,EACnB;AACJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actdim/dynstruct",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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",
@@ -70,8 +70,8 @@
70
70
  "build-storybook": "storybook build"
71
71
  },
72
72
  "peerDependencies": {
73
- "@actdim/msgmesh": "^1.2.1",
74
- "@actdim/utico": "^1.1.0",
73
+ "@actdim/msgmesh": "^1.2.2",
74
+ "@actdim/utico": "^1.1.1",
75
75
  "http-status": "^2.1.0",
76
76
  "jwt-decode": "^4.0.0",
77
77
  "mobx": "^6.15.0",