@actdim/dynstruct 1.0.2 → 1.0.5

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.
Files changed (55) hide show
  1. package/dist/appDomain/adapters.d.ts +10 -0
  2. package/dist/appDomain/adapters.d.ts.map +1 -0
  3. package/dist/appDomain/adapters.es.js +25 -0
  4. package/dist/appDomain/adapters.es.js.map +1 -0
  5. package/dist/appDomain/appContracts.d.ts +24 -9
  6. package/dist/appDomain/appContracts.d.ts.map +1 -1
  7. package/dist/appDomain/appContracts.es.js +12 -9
  8. package/dist/appDomain/appContracts.es.js.map +1 -1
  9. package/dist/appDomain/reactHooks.d.ts +6 -0
  10. package/dist/appDomain/reactHooks.d.ts.map +1 -0
  11. package/dist/appDomain/reactHooks.es.js +12 -0
  12. package/dist/appDomain/reactHooks.es.js.map +1 -0
  13. package/dist/appDomain/security/securityContracts.d.ts +3 -3
  14. package/dist/appDomain/security/securityContracts.d.ts.map +1 -1
  15. package/dist/appDomain/security/securityContracts.es.js.map +1 -1
  16. package/dist/appDomain/security/securityProvider.d.ts +2 -2
  17. package/dist/appDomain/security/securityProvider.es.js.map +1 -1
  18. package/dist/componentModel/DynamicContent.d.ts +14 -0
  19. package/dist/componentModel/DynamicContent.d.ts.map +1 -0
  20. package/dist/componentModel/DynamicContent.es.js +14 -0
  21. package/dist/componentModel/DynamicContent.es.js.map +1 -0
  22. package/dist/componentModel/componentContext.d.ts +8 -0
  23. package/dist/componentModel/componentContext.d.ts.map +1 -0
  24. package/dist/componentModel/componentContext.es.js +77 -0
  25. package/dist/componentModel/componentContext.es.js.map +1 -0
  26. package/dist/componentModel/componentModel.d.ts +58 -34
  27. package/dist/componentModel/componentModel.d.ts.map +1 -1
  28. package/dist/componentModel/componentModel.es.js +263 -134
  29. package/dist/componentModel/componentModel.es.js.map +1 -1
  30. package/dist/componentModel/contracts.d.ts +22 -0
  31. package/dist/componentModel/contracts.d.ts.map +1 -0
  32. package/dist/componentModel/contracts.es.js +2 -0
  33. package/dist/componentModel/contracts.es.js.map +1 -0
  34. package/dist/dist/componentModel/componentContext.es.es.js +15 -0
  35. package/dist/dist/componentModel/componentContext.es.es.js.map +1 -0
  36. package/dist/dist/componentModel/componentModel.es.es.js +260 -0
  37. package/dist/dist/componentModel/componentModel.es.es.js.map +1 -0
  38. package/dist/dist/globals.es.es.js +10 -0
  39. package/dist/dist/globals.es.es.js.map +1 -0
  40. package/dist/dist/reactHooks.es.es.js +9 -0
  41. package/dist/dist/reactHooks.es.es.js.map +1 -0
  42. package/dist/globals.d.ts +11 -0
  43. package/dist/globals.d.ts.map +1 -0
  44. package/dist/globals.es.js +10 -0
  45. package/dist/globals.es.js.map +1 -0
  46. package/dist/net/client.es.js.map +1 -1
  47. package/dist/services/NavService.d.ts +17 -0
  48. package/dist/services/NavService.d.ts.map +1 -0
  49. package/dist/services/NavService.es.js +65 -0
  50. package/dist/services/NavService.es.js.map +1 -0
  51. package/dist/services/StorageService.d.ts +15 -0
  52. package/dist/services/StorageService.d.ts.map +1 -0
  53. package/dist/services/StorageService.es.js +54 -0
  54. package/dist/services/StorageService.es.js.map +1 -0
  55. package/package.json +18 -12
@@ -1 +1 @@
1
- {"version":3,"file":"componentModel.es.js","sources":["../../src/componentModel/componentModel.tsx"],"sourcesContent":["import { PropsWithChildren, useEffect, useLayoutEffect, FC, ReactNode } from 'react';\r\nimport { v4 as uuidv4 } from 'uuid';\r\nimport {\r\n $CG_IN,\r\n $CG_OUT,\r\n MsgBus,\r\n MsgBusProviderParams,\r\n MsgBusStruct,\r\n MsgBusSubscriberParams,\r\n} from '@actdim/msgmesh/msgBusCore';\r\nimport { MaybePromise, SafeKey, Skip } from '@actdim/utico/typeCore';\r\nimport { observer } from 'mobx-react-lite';\r\nimport { observable, runInAction } from 'mobx';\r\nimport { useLazyRef } from '@/reactHooks';\r\n\r\nexport type MsgBusChannelGroupProviderParams<\r\n TStruct extends MsgBusStruct = MsgBusStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n> = Skip<MsgBusProviderParams<TStruct, TChannel, TGroup>, 'channel' | 'group'>;\r\n\r\nexport type MsgBusChannelGroupSubscriberParams<\r\n TStruct extends MsgBusStruct = MsgBusStruct,\r\n TChannel extends keyof TStruct = keyof TStruct,\r\n TGroup extends keyof TStruct[TChannel] = typeof $CG_IN, // keyof TStruct[TChannel]\r\n> = Skip<MsgBusSubscriberParams<TStruct, TChannel, TGroup>, 'channel' | 'group'>;\r\n\r\n// MsgBusScope\r\nexport type MsgBusBrokerScope<\r\n TStruct extends MsgBusStruct /*= MsgBusStruct*/,\r\n TKeysToProvide extends keyof TStruct = keyof TStruct,\r\n TKeysToSubscribe extends keyof TStruct = keyof TStruct,\r\n TKeysToPublish extends keyof TStruct = keyof TStruct,\r\n> = {\r\n provide?: TKeysToProvide;\r\n // consume\r\n subscribe?: TKeysToSubscribe;\r\n // produce\r\n publish?: TKeysToPublish;\r\n};\r\n\r\nexport type ComponentPropStruct = Record<string, any>;\r\n// export type ComponentPropStruct = {\r\n// [prop: string]: any;\r\n// };\r\n\r\nexport type ComponentMethodStruct = Record<string, Function>;\r\n// export type ComponentMethodStruct = {\r\n// [action: string]: Function;\r\n// };\r\n\r\n// export type ComponentRefStruct = Record<string, ComponentStruct<TMsgBusStruct, T>>;\r\nexport type ComponentRefStruct = {\r\n [name: string]: ComponentStruct | ((params: any) => ComponentStruct);\r\n};\r\n\r\nexport type ComponentStructBase<\r\n TMsgBusStruct extends MsgBusStruct = MsgBusStruct,\r\n TPropStruct extends ComponentPropStruct = ComponentPropStruct,\r\n TMsgScope extends MsgBusBrokerScope<TMsgBusStruct> = MsgBusBrokerScope<TMsgBusStruct>,\r\n> = {\r\n props?: TPropStruct;\r\n methods?: ComponentMethodStruct;\r\n children?: ComponentRefStruct;\r\n msgScope?: TMsgScope;\r\n};\r\n\r\n// ComponentShape\r\nexport type ComponentStruct<\r\n TMsgBusStruct extends MsgBusStruct = MsgBusStruct,\r\n T extends ComponentStructBase<TMsgBusStruct> = ComponentStructBase<TMsgBusStruct>,\r\n> = T & {\r\n msgBus: TMsgBusStruct;\r\n};\r\n\r\nexport type MsgBusBroker<\r\n TStructToProvide extends MsgBusStruct = MsgBusStruct,\r\n TStructToSubscribe extends MsgBusStruct = MsgBusStruct,\r\n> = {\r\n // providers\r\n provide?: {\r\n [TChannel in keyof TStructToProvide]: {\r\n [TGroup in keyof Skip<\r\n TStructToProvide[TChannel],\r\n typeof $CG_OUT\r\n >]?: MsgBusChannelGroupProviderParams<TStructToProvide, TChannel, TGroup>;\r\n };\r\n };\r\n // subscribers\r\n subscribe?: {\r\n [TChannel in keyof TStructToSubscribe]: {\r\n [TGroup in keyof TStructToSubscribe[TChannel]]?: MsgBusChannelGroupSubscriberParams<\r\n TStructToSubscribe,\r\n TChannel,\r\n TGroup\r\n >;\r\n };\r\n };\r\n};\r\n\r\ntype ValueConverter<TTo, TFrom> = {\r\n // ConvertFrom\r\n convert(value: TFrom): TTo;\r\n // ConvertTo\r\n convertBack(value: TTo): TFrom;\r\n};\r\n\r\ntype ValidationResult = {\r\n valid: boolean;\r\n message: string;\r\n};\r\n\r\ntype Validator<T> = {\r\n options: {\r\n blur: boolean;\r\n };\r\n validate: (value: T) => MaybePromise<ValidationResult>;\r\n};\r\n\r\nexport const symbols = {\r\n $isBinding: Symbol('$isBinding'),\r\n};\r\n\r\nexport interface IBinding<T = any, TFrom = any> {\r\n // getter\r\n readonly get: () => T;\r\n // setter\r\n readonly set: (value: T) => void;\r\n readonly converter: ValueConverter<T, TFrom>;\r\n readonly validator: Validator<T>;\r\n readonly readOnly: boolean;\r\n [symbols.$isBinding]: boolean;\r\n}\r\n\r\nclass Binding<T = any, TFrom = any> implements IBinding<any, any> {\r\n // getter\r\n readonly get: () => T;\r\n // setter\r\n readonly set: (value: T) => void;\r\n readonly converter: ValueConverter<T, TFrom>;\r\n readonly validator: Validator<T>;\r\n readonly readOnly: boolean;\r\n constructor(\r\n get: () => T,\r\n set?: (value: T) => void,\r\n converter?: ValueConverter<T, TFrom>,\r\n validator?: Validator<T>\r\n ) {\r\n this.get = get;\r\n this.set = set;\r\n this.converter = converter;\r\n this.validator = validator;\r\n this.readOnly = !!set;\r\n this[symbols.$isBinding] = true;\r\n }\r\n [symbols.$isBinding]: boolean;\r\n}\r\n\r\nexport function isBinding(obj: any): obj is IBinding {\r\n return obj[symbols.$isBinding] === true;\r\n}\r\n\r\nexport function bind<T, TFrom = any>(\r\n get: () => T,\r\n set?: (value: T) => void,\r\n converter?: ValueConverter<T, TFrom>,\r\n validator?: Validator<T>\r\n) {\r\n return new Binding(get, set, converter, validator);\r\n}\r\n\r\nexport function bindProp<T extends object, P extends keyof T>(obj: T, prop: P) {\r\n return new Binding(\r\n () => obj[prop],\r\n (value: T[P]) => {\r\n obj[prop] = value;\r\n }\r\n );\r\n}\r\n\r\nexport type ComponentPropSource<T> = T | Binding<T>;\r\n\r\nexport type ComponentPropParams<TPropStruct extends ComponentPropStruct> = {\r\n [P in keyof TPropStruct]?: ComponentPropSource<TPropStruct[P]>;\r\n};\r\n\r\n// const $ON_PROP_CHANGING = \"onPropChanging\";\r\n// const $ON_PROP_CHANGE = \"onPropChange\";\r\n\r\nconst $ON_GET = 'onGet';\r\n// const $ON_BEFORE_SET = \"onBeforeSet\";\r\nconst $ON_CHANGING = 'onChanging';\r\nconst $ON_CHANGE = 'onChange';\r\n// const $ON_SET = \"onSet\";\r\n\r\ntype PropValueChangingHandler<TProp = PropKey> = (\r\n prop: TProp,\r\n oldValue: any,\r\n newValue: any\r\n) => boolean;\r\ntype PropValueChangeHandler<TProp = PropKey> = (prop: TProp, value: any) => void;\r\n\r\n// BeforeValueSetHandler\r\ntype ValueChangingHandler<T = any> = (oldValue: T, newValue: T) => boolean;\r\n// ValueSetHandler\r\ntype ValueChangeHandler<T = any> = (value: T) => void;\r\n\r\ntype ComponentEvents<TStruct extends ComponentStruct = ComponentStruct> = {\r\n onPropChanging?: PropValueChangingHandler<keyof TStruct['props']>;\r\n onPropChange?: PropValueChangeHandler<keyof TStruct['props']>;\r\n onInit?: (model: ComponentModel<TStruct>) => void;\r\n onLayout?: (model: ComponentModel<TStruct>) => void;\r\n onReady?: (model: ComponentModel<TStruct>) => void;\r\n onLayoutDestroy?: (model: ComponentModel<TStruct>) => void; // onLayoutCleanup\r\n onDestroy?: (model: ComponentModel<TStruct>) => void; // onDispose/onCleanup\r\n onError?: (model: ComponentModel<TStruct>, error: any) => void;\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_GET}${Capitalize<P & string>}`]?: () => TStruct['props'][P];\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_CHANGING}${Capitalize<P & string>}`]?: ValueChangingHandler<\r\n TStruct['props']\r\n >;\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_CHANGE}${Capitalize<P & string>}`]?: ValueChangeHandler<\r\n TStruct['props']\r\n >;\r\n};\r\n\r\n// AllHTMLAttributes<JSX.Element>\r\n\r\n// type ComponentViewerProps = {\r\n// render?: boolean;\r\n// view?: () => ReactNode;\r\n// } & PropsWithChildren;\r\n\r\ntype ComponentViewProps = {\r\n render?: boolean;\r\n} & PropsWithChildren;\r\n\r\ntype ComponentViewFn = (props?: ComponentViewProps) => ReactNode; // JSX.Element\r\n\r\ntype PublicKeys<T> = {\r\n [K in keyof T]: K extends `_${string}` ? never : K;\r\n}[keyof T];\r\n\r\nexport type Component<TStruct extends ComponentStruct> = {\r\n props?: TStruct['props'];\r\n methods?: TStruct['methods'];\r\n children?: ComponentChildren<TStruct['children']>;\r\n events?: ComponentEvents<TStruct>;\r\n // msgs?\r\n msgBroker?: MsgBusBroker<\r\n Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>>,\r\n Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>>\r\n >;\r\n msgBus?: MsgBus<\r\n // TStruct[\"msgBus\"]\r\n Pick<\r\n TStruct['msgBus'],\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>\r\n >\r\n >;\r\n view?: ComponentViewFn;\r\n};\r\n\r\ntype ComponentChildren<TRefStruct extends ComponentRefStruct> = {\r\n [P in keyof TRefStruct]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? (params: TParams) => ComponentModel<T>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? ComponentModel<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\ntype ComponentModelChildren<TRefStruct extends ComponentRefStruct> = {\r\n [P in keyof TRefStruct as TRefStruct[P] extends Function\r\n ? `${Capitalize<P & string>}`\r\n : P]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? FC<ComponentParams<T> & TParams>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? ComponentModel<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\nexport type ComponentModelBase<TStruct extends ComponentStruct = ComponentStruct> = {\r\n readonly msgBus?: MsgBus<\r\n // TStruct[\"msgBus\"]\r\n Pick<\r\n TStruct['msgBus'],\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>\r\n >\r\n >;\r\n\r\n readonly View: ComponentViewFn;\r\n};\r\n\r\nexport type ComponentModel<TStruct extends ComponentStruct = ComponentStruct> = TStruct['props'] &\r\n TStruct['methods'] &\r\n ComponentModelChildren<TStruct['children']> &\r\n ComponentModelBase<TStruct>;\r\n\r\n// style: CSSProperties;\r\n\r\ntype PropEventHandlers = {\r\n onGet?: () => any;\r\n onChanging?: (oldValue: any, newValue: any) => boolean;\r\n onChange?: (value: any) => void;\r\n};\r\n\r\ntype PropKey = string | symbol;\r\ntype ProxyEventHandlers = {\r\n onPropChanging?: PropValueChangingHandler<PropKey>;\r\n onPropChange?: PropValueChangeHandler<PropKey>;\r\n} & Record<PropKey, PropEventHandlers>;\r\n\r\n// ComponentConfig\r\nexport type ComponentParams<TStruct extends ComponentStruct = ComponentStruct> =\r\n ComponentPropParams<TStruct['props']> & ComponentEvents<TStruct>; // & PropsWithChildren\r\n\r\nconst blankView = () => null;\r\n\r\nfunction createProxy(\r\n state: any,\r\n bindings: Map<PropKey, IBinding>,\r\n proxyEventHandlers: ProxyEventHandlers\r\n) {\r\n const onPropChanging = proxyEventHandlers.onPropChanging;\r\n const onPropChange = proxyEventHandlers.onPropChange;\r\n return new Proxy(state, {\r\n get(obj, prop, receiver) {\r\n const onGet = proxyEventHandlers[prop]?.onGet;\r\n if (onGet) {\r\n return onGet();\r\n }\r\n const binding = bindings.get(String(prop));\r\n if (binding) {\r\n return binding.get();\r\n }\r\n return Reflect.get(obj, prop, receiver);\r\n },\r\n set(obj, prop, value, receiver) {\r\n const oldValue = obj[prop];\r\n\r\n const onChanging = proxyEventHandlers[prop]?.onChanging;\r\n if (onChanging) {\r\n const shouldChange = onChanging(oldValue, value);\r\n if (!shouldChange) {\r\n return true;\r\n }\r\n }\r\n\r\n if (onPropChanging) {\r\n const shouldChange = onPropChanging(prop, oldValue, value);\r\n if (!shouldChange) {\r\n return true;\r\n }\r\n }\r\n\r\n const result = runInAction(() => {\r\n return Reflect.set(obj, prop, value, receiver);\r\n });\r\n\r\n const binding = bindings.get(prop);\r\n\r\n if (binding?.set) {\r\n binding.set(value);\r\n }\r\n\r\n const onChange = proxyEventHandlers[prop]?.onChange;\r\n if (onChange) {\r\n onChange(value);\r\n }\r\n\r\n if (onPropChange) {\r\n onPropChange(prop, value);\r\n }\r\n\r\n return result;\r\n },\r\n });\r\n}\r\n\r\nfunction capitalize(name: string) {\r\n return name.replace(/^./, name[0].toUpperCase());\r\n}\r\n\r\nfunction asyncToGeneratorFlow(asyncFn: (...args: any[]) => Promise<any>) {\r\n return function* (...args: any[]) {\r\n const result = yield asyncFn(...args);\r\n return result;\r\n };\r\n}\r\n\r\n// const ViewerFC = observer((props: ComponentViewerProps) => {\r\n// if (typeof props.view === \"function\") {\r\n// return props.view();\r\n// }\r\n// return <>{props.children}</>;\r\n// });\r\n\r\nfunction createModel<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n params: ComponentParams<TStruct>\r\n): ComponentModel<TStruct> {\r\n const msgBus = component.msgBus;\r\n const view = component.view;\r\n\r\n const ViewFC = observer((props: ComponentViewProps) => {\r\n if (typeof view === 'function') {\r\n return view(props);\r\n }\r\n return <>{props.children}</>;\r\n });\r\n\r\n let model: ComponentModel<TStruct> = {\r\n ...component.props,\r\n ...component.methods,\r\n // view: component.view,\r\n // View: ViewerFC,\r\n View: ViewFC,\r\n msgBus: msgBus,\r\n };\r\n if (component.children) {\r\n for (const [key, value] of Object.entries(component.children)) {\r\n if (typeof value == 'function') {\r\n // observer\r\n const ChildViewFC: ComponentViewFn = (props) => {\r\n const model = value(props) as ComponentModel;\r\n return <model.View />;\r\n // if (typeof model.view === \"function\") {\r\n // return model.view(props);\r\n // }\r\n // return <>{props.children}</>;\r\n // return <ViewerFC view={model.view} />;\r\n };\r\n Reflect.set(model, capitalize(key), ChildViewFC);\r\n } else {\r\n Reflect.set(model, key, value);\r\n }\r\n }\r\n }\r\n if (component.msgBroker) {\r\n const providers = component.msgBroker.provide;\r\n if (providers) {\r\n for (const [channel, providerGroups] of Object.entries(providers)) {\r\n for (const [group, provider] of Object.entries(providerGroups)) {\r\n msgBus.provide({\r\n ...provider,\r\n channel: channel,\r\n group: group,\r\n });\r\n }\r\n }\r\n }\r\n const subscribers = component.msgBroker.subscribe;\r\n if (subscribers) {\r\n for (const [channel, subscriberGroups] of Object.entries(subscribers)) {\r\n for (const [group, subscriber] of Object.entries(subscriberGroups)) {\r\n msgBus.on({\r\n ...subscriber,\r\n channel: channel,\r\n group: group,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n const bindings = new Map<PropKey, IBinding>();\r\n // Reflect.ownKeys\r\n for (const [key, value] of Object.entries(params)) {\r\n if (isBinding(value)) {\r\n bindings.set(key, value);\r\n } else {\r\n Reflect.set(model, key, value);\r\n }\r\n }\r\n\r\n // decorators\r\n const annotationMap: Record<string, any> = {};\r\n\r\n if (component.props) {\r\n for (const key of Object.keys(component.props)) {\r\n annotationMap[key] = observable.ref;\r\n }\r\n }\r\n if (component.methods) {\r\n for (const key of Object.keys(component.methods)) {\r\n annotationMap[key] = false;\r\n }\r\n }\r\n\r\n annotationMap['View' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n annotationMap['msgBus' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n // annotationMap[\"view\" satisfies keyof Component<TStruct>] = false;\r\n\r\n const proxyEventHandlers: Pick<ProxyEventHandlers, 'onPropChanging' | 'onPropChange'> = {\r\n onPropChanging:\r\n params?.onPropChanging || component.events?.onPropChanging\r\n ? (prop, oldValue, newValue) => {\r\n let result = true;\r\n let handler = params.onPropChanging;\r\n if (handler) {\r\n result = handler(String(prop), oldValue, newValue);\r\n }\r\n if (result) {\r\n handler = component.events?.onPropChanging;\r\n if (handler) {\r\n result = handler(String(prop), oldValue, newValue);\r\n }\r\n }\r\n return result;\r\n }\r\n : undefined,\r\n onPropChange:\r\n params?.onPropChange || component.events?.onPropChange\r\n ? (prop, value) => {\r\n params.onPropChange?.(String(prop), value);\r\n component.events.onPropChange?.(String(prop), value);\r\n }\r\n : undefined,\r\n };\r\n\r\n function resolveOnGetEventHandler(prop: string) {\r\n const key = `${$ON_GET}${capitalize(prop)}`;\r\n return params[key] || component.events[key];\r\n }\r\n\r\n function resolveOnChangingEventHandler(prop: string) {\r\n const key = `${$ON_CHANGING}${capitalize(prop)}`;\r\n return ((oldValue: any, newValue: any) => {\r\n let result = true;\r\n let handler = params[key] as ValueChangingHandler<any>;\r\n if (handler) {\r\n result = handler(oldValue, newValue);\r\n }\r\n if (result) {\r\n handler = component.events[key] as ValueChangingHandler<any>;\r\n if (handler) {\r\n result = handler(oldValue, newValue);\r\n }\r\n }\r\n return result;\r\n }) as ValueChangingHandler;\r\n }\r\n\r\n function resolveOnChangeEventHandler(prop: string) {\r\n const key = `${$ON_CHANGE}${capitalize(prop)}`;\r\n return ((value: any) => {\r\n (params[key] as ValueChangeHandler<any>)?.(value);\r\n (component.events[key] as ValueChangeHandler<any>)?.(value);\r\n }) as ValueChangeHandler;\r\n }\r\n\r\n if (component.props) {\r\n for (const prop of Object.keys(component.props)) {\r\n proxyEventHandlers[prop] = {\r\n onGet: resolveOnGetEventHandler(prop),\r\n onChanging: resolveOnChangingEventHandler(prop),\r\n onChange: resolveOnChangeEventHandler(prop),\r\n };\r\n }\r\n }\r\n\r\n model = observable(model, annotationMap);\r\n\r\n model = createProxy(model, bindings, proxyEventHandlers);\r\n\r\n if (component.events?.onInit) {\r\n component.events.onInit(model);\r\n }\r\n\r\n if (params?.onInit) {\r\n params.onInit(model);\r\n }\r\n\r\n return model;\r\n}\r\n\r\nexport function useComponent<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n params: ComponentParams<TStruct>\r\n): ComponentModel<TStruct> {\r\n const ref = useLazyRef(() => createModel(component, params));\r\n const model = ref.current;\r\n\r\n useLayoutEffect(() => {\r\n try {\r\n component.events?.onLayout?.(model);\r\n params?.onLayout?.(model);\r\n } catch (err) {\r\n component.events?.onError?.(model, err);\r\n params?.onError?.(model, err);\r\n }\r\n\r\n return () => {\r\n component.events?.onLayoutDestroy?.(model);\r\n params?.onLayoutDestroy?.(model);\r\n // ref.current?.dispose();\r\n ref.current = null;\r\n };\r\n }, []);\r\n\r\n useEffect(() => {\r\n try {\r\n component.events?.onReady?.(model);\r\n params?.onReady?.(model);\r\n } catch (err) {\r\n component.events?.onError?.(model, err);\r\n params?.onError?.(model, err);\r\n }\r\n return () => {\r\n component.events?.onDestroy?.(model);\r\n params?.onDestroy?.(model);\r\n };\r\n }, []);\r\n\r\n return ref.current;\r\n}\r\n\r\n// asFC/toFC\r\nexport function getFC<TStruct extends ComponentStruct>(\r\n factory: (params: ComponentParams<TStruct>) => ComponentModel<TStruct>\r\n): FC<ComponentParams<TStruct>> {\r\n // observer\r\n const fc = (params: ComponentParams<TStruct> & PropsWithChildren) => {\r\n // modelHook\r\n const model = factory(params); // without useRef!\r\n // return model.view();\r\n return <model.View {...params} />;\r\n // return <ViewerFC {...params} view={model.view} />;\r\n };\r\n return fc;\r\n}\r\n"],"names":["symbols","Binding","get","set","converter","validator","isBinding","obj","bind","bindProp","prop","value","$ON_GET","$ON_CHANGING","$ON_CHANGE","createProxy","state","bindings","proxyEventHandlers","onPropChanging","onPropChange","receiver","onGet","binding","oldValue","onChanging","result","runInAction","onChange","capitalize","name","createModel","component","params","msgBus","view","ViewFC","observer","props","model","key","ChildViewFC","providers","channel","providerGroups","group","provider","subscribers","subscriberGroups","subscriber","annotationMap","observable","newValue","handler","resolveOnGetEventHandler","resolveOnChangingEventHandler","resolveOnChangeEventHandler","useComponent","ref","useLazyRef","useLayoutEffect","err","useEffect","getFC","factory"],"mappings":";;;;AAuHO,MAAMA,IAAU;AAAA,EACnB,YAAY,OAAO,YAAY;AACnC;AAaA,MAAMC,EAA4D;AAAA;AAAA,EAErD;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACT,YACIC,GACAC,GACAC,GACAC,GACF;AACE,SAAK,MAAMH,GACX,KAAK,MAAMC,GACX,KAAK,YAAYC,GACjB,KAAK,YAAYC,GACjB,KAAK,WAAW,CAAC,CAACF,GAClB,KAAKH,EAAQ,UAAU,IAAI;AAAA,EAC/B;AAAA,EACA,CAACA,EAAQ,UAAU;AACvB;AAEO,SAASM,EAAUC,GAA2B;AACjD,SAAOA,EAAIP,EAAQ,UAAU,MAAM;AAC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AElB,SAAAE,EAAgB,MAAM;AAClB,QAAI;AACA,MAAA5B,EAAU,QAAQ,WAAWO,CAAK,GAClCN,GAAQ,WAAWM,CAAK;AAAA,IAC5B,SAASsB,GAAK;AACV,MAAA7B,EAAU,QAAQ,UAAUO,GAAOsB,CAAG,GACtC5B,GAAQ,UAAUM,GAAOsB,CAAG;AAAA,IAChC;AAEA,WAAO,MAAM;AACT,MAAA7B,EAAU,QAAQ,kBAAkBO,CAAK,GACzCN,GAAQ,kBAAkBM,CAAK,GAE/BmB,EAAI,UAAU;AAAA,IAClB;AAAA,EACJ,GAAG,CAAA,CAAE,GAELI,EAAU,MAAM;AACZ,QAAI;AACA,MAAA9B,EAAU,QAAQ,UAAUO,CAAK,GACjCN,GAAQ,UAAUM,CAAK;AAAA,IAC3B,SAASsB,GAAK;AACV,MAAA7B,EAAU,QAAQ,UAAUO,GAAOsB,CAAG,GACtC5B,GAAQ,UAAUM,GAAOsB,CAAG;AAAA,IAChC;AACA,WAAO,MAAM;AACT,MAAA7B,EAAU,QAAQ,YAAYO,CAAK,GACnCN,GAAQ,YAAYM,CAAK;AAAA,IAC7B;AAAA,EACJ,GAAG,CAAA,CAAE,GAEEmB,EAAI;AACf;AAGO,SAASK,EACZC,GAC4B;AAS5B,SAPW,CAAC/B,MAAyD;AAEjE,UAAMM,IAAQyB,EAAQ/B,CAAM;AAE5B,WAAO,sBAAA,cAACM,EAAM,MAAN,EAAY,GAAGN,GAAQ;AAAA,EAEnC;AAEJ;"}
1
+ {"version":3,"file":"componentModel.es.js","sources":["../../src/componentModel/componentModel.tsx"],"sourcesContent":["import React, { 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 { MaybePromise, SafeKey, Skip } from '@actdim/utico/typeCore';\r\nimport { observer } from 'mobx-react-lite';\r\nimport { observable, runInAction } from 'mobx';\r\nimport { useLazyRef } from '@/reactHooks';\r\nimport { getGlobalFlags } from '@/globals';\r\nimport { ReactComponentContext, useComponentContext } from './componentContext';\r\nimport { ComponentMsgHeaders, TreeNode } from './contracts';\r\nimport { lazy } from '@actdim/utico/utils';\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 methods?: ComponentMethodStruct;\r\n children?: ComponentRefStruct;\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 // TMsgBus extends MsgBus<MsgStruct> = MsgBus<MsgStruct>,\r\n // T extends ComponentStructBase<TMsgBus[typeof $TypeArgStruct]> = ComponentStructBase<\r\n // TMsgBus[typeof $TypeArgStruct]\r\n // >,\r\n> = T & {\r\n msgBus: TMsgStruct;\r\n // msgBus: TMsgBus;\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> = {\r\n // providers\r\n provide?: {\r\n [TChannel in keyof TStructToProvide]: {\r\n [TGroup in keyof Skip<\r\n TStructToProvide[TChannel],\r\n typeof $CG_OUT\r\n >]?: MsgChannelGroupProviderParams<\r\n TStructToProvide,\r\n TChannel,\r\n TGroup,\r\n TMsgHeaders,\r\n TScope\r\n >;\r\n };\r\n };\r\n // subscribers\r\n subscribe?: {\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 abortController?: AbortController;\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 = PropKey> = (\r\n prop: TProp,\r\n oldValue: any,\r\n newValue: any,\r\n) => boolean;\r\ntype PropValueChangeHandler<TProp = PropKey> = (prop: TProp, value: any) => void;\r\n\r\n// BeforeValueSetHandler\r\ntype ValueChangingHandler<T = any> = (oldValue: T, newValue: T) => boolean;\r\n// ValueSetHandler\r\ntype ValueChangeHandler<T = any> = (value: T) => void;\r\n\r\ntype ComponentEvents<TStruct extends ComponentStruct = ComponentStruct> = {\r\n onPropChanging?: PropValueChangingHandler<keyof TStruct['props']>;\r\n onPropChange?: PropValueChangeHandler<keyof TStruct['props']>;\r\n onInit?: (model: ComponentModel<TStruct>) => void;\r\n onLayout?: (model: ComponentModel<TStruct>) => void;\r\n onReady?: (model: ComponentModel<TStruct>) => void;\r\n onLayoutDestroy?: (model: ComponentModel<TStruct>) => void; // onLayoutCleanup\r\n onDestroy?: (model: ComponentModel<TStruct>) => void; // onDispose/onCleanup\r\n onError?: (model: ComponentModel<TStruct>, error: any) => void;\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_GET}${Capitalize<P & string>}`]?: () => TStruct['props'][P];\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_CHANGING}${Capitalize<P & string>}`]?: ValueChangingHandler<\r\n TStruct['props']\r\n >;\r\n} & {\r\n [P in keyof TStruct['props'] as `${typeof $ON_CHANGE}${Capitalize<P & string>}`]?: ValueChangeHandler<\r\n TStruct['props']\r\n >;\r\n};\r\n\r\n// AllHTMLAttributes<JSX.Element>\r\n\r\ntype ComponentViewProps = {\r\n render?: boolean;\r\n} & PropsWithChildren;\r\n\r\n// ComponentRenderImplFn\r\ntype ComponentViewImplFn<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = (props: ComponentViewProps, model?: ComponentModel<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['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>>,\r\n Pick<TStruct['msgBus'], SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>>,\r\n // Pick<\r\n // TStruct['msgBus'][typeof $TypeArgStruct],\r\n // SafeKey<TStruct['msgBus'][typeof $TypeArgStruct], TStruct['msgScope']['provide']>\r\n // >,\r\n // Pick<\r\n // TStruct['msgBus'][typeof $TypeArgStruct],\r\n // SafeKey<TStruct['msgBus'][typeof $TypeArgStruct], TStruct['msgScope']['subscribe']>\r\n // >,\r\n // TStruct['msgBus'][typeof $TypeArgHeaders],\r\n TMsgHeaders,\r\n // ComponentModel<TStruct, TStruct['msgBus'][typeof $TypeArgHeaders]>\r\n ComponentModel<TStruct, TMsgHeaders>\r\n>;\r\n\r\nexport type Component<\r\n TStruct extends ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = {\r\n name?: string;\r\n props?: TStruct['props'];\r\n methods?: TStruct['methods'];\r\n children?: ComponentChildren<TStruct['children']>;\r\n events?: ComponentEvents<TStruct>;\r\n // msgs?\r\n msgBroker?: ComponentMsgBroker<TStruct, TMsgHeaders>;\r\n msgBus?: MsgBus<TStruct['msgBus'], TMsgHeaders>;\r\n // msgBus?: TStruct['msgBus'];\r\n view?: ComponentViewImplFn<TStruct, TMsgHeaders>;\r\n};\r\n\r\ntype ComponentChildren<TRefStruct extends ComponentRefStruct> = {\r\n [P in keyof TRefStruct]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? (params: TParams) => ComponentModel<T>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? ComponentModel<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\ntype ComponentModelChildren<TRefStruct extends ComponentRefStruct> = {\r\n [P in keyof TRefStruct as TRefStruct[P] extends Function\r\n ? `${Capitalize<P & string>}`\r\n : P]: TRefStruct[P] extends (params: infer TParams) => infer T\r\n ? T extends ComponentStruct\r\n ? FC<ComponentParams<T> & TParams>\r\n : never\r\n : TRefStruct[P] extends ComponentStruct\r\n ? ComponentModel<TRefStruct[P]>\r\n : never;\r\n};\r\n\r\nexport type ComponentModelContext = {\r\n bindings?: Map<PropKey, Binding>;\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};\r\n\r\nexport type ComponentMsgStruct<TStruct extends ComponentStruct = ComponentStruct> = Pick<\r\n TStruct['msgBus'],\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['provide']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['subscribe']>\r\n | SafeKey<TStruct['msgBus'], TStruct['msgScope']['publish']>\r\n // TStruct['msgBus'][typeof $TypeArgStruct],\r\n // | SafeKey<TStruct['msgBus'][typeof $TypeArgStruct], TStruct['msgScope']['provide']>\r\n // | SafeKey<TStruct['msgBus'][typeof $TypeArgStruct], TStruct['msgScope']['subscribe']>\r\n // | SafeKey<TStruct['msgBus'][typeof $TypeArgStruct], TStruct['msgScope']['publish']>\r\n>;\r\n\r\nexport type ComponentModelBase<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = {\r\n msgBus: MsgBus<\r\n // TStruct[\"msgBus\"]\r\n // TStruct[\"msgBus\"][typeof $TypeArgStruct],\r\n ComponentMsgStruct<TStruct>,\r\n // TStruct['msgBus'][typeof $TypeArgHeaders]\r\n TMsgHeaders\r\n >;\r\n msgBroker: ComponentMsgBroker<TStruct>;\r\n View: ComponentViewFn;\r\n $: Readonly<ComponentModelContext>;\r\n};\r\n\r\nexport type ComponentModel<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n> = TStruct['props'] &\r\n Readonly<TStruct['methods']> &\r\n Readonly<ComponentModelChildren<TStruct['children']>> &\r\n Readonly<ComponentModelBase<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 PropKey = string | symbol;\r\ntype ProxyEventHandlers = {\r\n onPropChanging?: PropValueChangingHandler<PropKey>;\r\n onPropChange?: PropValueChangeHandler<PropKey>;\r\n} & Record<PropKey, PropEventHandlers>;\r\n\r\n// ComponentConfig\r\nexport type ComponentParams<TStruct extends ComponentStruct = ComponentStruct> =\r\n ComponentPropParams<TStruct['props']> & ComponentEvents<TStruct>; // & PropsWithChildren\r\n\r\nconst blankView = () => null;\r\n\r\nfunction createProxy(\r\n state: any,\r\n bindings: Map<PropKey, Binding>,\r\n proxyEventHandlers: ProxyEventHandlers,\r\n) {\r\n const onPropChanging = proxyEventHandlers.onPropChanging;\r\n const onPropChange = proxyEventHandlers.onPropChange;\r\n return new Proxy(state, {\r\n get(obj, prop, receiver) {\r\n const onGet = proxyEventHandlers[prop]?.onGet;\r\n if (onGet) {\r\n return onGet();\r\n }\r\n\r\n const binding = bindings.get(String(prop));\r\n if (binding) {\r\n let value: any = undefined;\r\n value = binding.get();\r\n return value;\r\n }\r\n return Reflect.get(obj, prop, receiver);\r\n },\r\n set(obj, prop, value, receiver) {\r\n const oldValue = obj[prop];\r\n\r\n const onChanging = proxyEventHandlers[prop]?.onChanging;\r\n if (onChanging) {\r\n const shouldChange = onChanging(oldValue, value);\r\n if (!shouldChange) {\r\n return true;\r\n }\r\n }\r\n\r\n if (onPropChanging) {\r\n const shouldChange = onPropChanging(prop, oldValue, value);\r\n if (!shouldChange) {\r\n return true;\r\n }\r\n }\r\n\r\n const result = runInAction(() => {\r\n return Reflect.set(obj, prop, value, receiver);\r\n });\r\n\r\n const binding = bindings.get(prop);\r\n if (binding?.set) {\r\n binding.set(value);\r\n }\r\n\r\n const onChange = proxyEventHandlers[prop]?.onChange;\r\n if (onChange) {\r\n onChange(value);\r\n }\r\n\r\n if (onPropChange) {\r\n onPropChange(prop, value);\r\n }\r\n\r\n return result;\r\n },\r\n });\r\n}\r\n\r\nfunction capitalize(name: string) {\r\n return name.replace(/^./, name[0].toUpperCase());\r\n}\r\n\r\nfunction asyncToGeneratorFlow(asyncFn: (...args: any[]) => Promise<any>) {\r\n return function* (...args: any[]) {\r\n const result = yield asyncFn(...args);\r\n return result;\r\n };\r\n}\r\n\r\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 model: ComponentModel<TStruct>,\r\n) {\r\n const providers = model?.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, model);\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 = model.$.getChainUp();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && componentFilter & ComponentMsgFilter.FromDescendants) {\r\n const ancestorIds = model.$.getChainDown();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && filter) {\r\n result = filter(msg, model);\r\n }\r\n return result;\r\n };\r\n provider.filter = msgFilter;\r\n\r\n model.msgBus.provide({\r\n ...p,\r\n channel: channel,\r\n group: g,\r\n config: {\r\n abortSignal: model.msgBroker.abortController.signal,\r\n },\r\n });\r\n }\r\n }\r\n }\r\n const subscribers = model?.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, model);\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 = model.$.getChainUp();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && componentFilter & ComponentMsgFilter.FromDescendants) {\r\n const ancestorIds = model.$.getChainDown();\r\n result = ancestorIds.indexOf(msg.headers?.sourceId) >= 0;\r\n }\r\n if (result && filter) {\r\n result = filter(msg, model);\r\n }\r\n return result;\r\n };\r\n subscriber.filter = msgFilter;\r\n\r\n model.msgBus.on({\r\n ...s,\r\n channel: channel,\r\n group: g,\r\n config: {\r\n abortSignal: model.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['msgBus']>,\r\n modelContext: ComponentModelContext,\r\n) {\r\n // ComponentModel<TStruct>['msgBus']\r\n const updateParams = (params: { headers?: ComponentMsgHeaders }) => {\r\n if (!params.headers) {\r\n params.headers = {};\r\n }\r\n if (params.headers.sourceId == undefined) {\r\n params.headers.sourceId = modelContext.id;\r\n }\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['msgBus']>;\r\n}\r\n\r\nfunction createModel<TStruct extends ComponentStruct = ComponentStruct>(\r\n component: Component<TStruct>,\r\n params: ComponentParams<TStruct>,\r\n): ComponentModel<TStruct> {\r\n const bindings = new Map<PropKey, Binding>();\r\n const view = component.view;\r\n\r\n let model: ComponentModel<TStruct>;\r\n\r\n let modelContext: ComponentModelContext;\r\n\r\n let msgBus = component.msgBus;\r\n\r\n const componentMsgBus = lazy(() => {\r\n return getComponentMsgBus(msgBus, modelContext) as ComponentModel<TStruct>['msgBus'];\r\n });\r\n\r\n let msgBroker = {\r\n ...component.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 = modelContext.id;\r\n const context = useComponentContext();\r\n const parentId = context.currentId;\r\n\r\n modelContext.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 [component, params, context],\r\n );\r\n\r\n useLayoutEffect(() => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n const hierarchyId = modelContext.getHierarchyId;\r\n console.debug(`${hierarchyId}>layout`);\r\n }\r\n\r\n context.register(id, parentId);\r\n\r\n modelContext.getHierarchyId = () => context.getHierarchyPath(id);\r\n\r\n modelContext.getChainDown = () => context.getChainDown(id);\r\n modelContext.getChainUp = () => context.getChainUp(id);\r\n modelContext.getChildren = () => context.getChildren(id);\r\n modelContext.getParent = () => context.getParent(id);\r\n modelContext.getNodeMap = () => context.getNodeMap();\r\n\r\n registerMsgBroker(model);\r\n\r\n component.events?.onLayout?.(model);\r\n params?.onLayout?.(model);\r\n } catch (err) {\r\n component.events?.onError?.(model, err);\r\n params?.onError?.(model, err);\r\n }\r\n\r\n return () => {\r\n if (getGlobalFlags().debug) {\r\n const hierarchyId = modelContext.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 component.events?.onLayoutDestroy?.(model);\r\n params?.onLayoutDestroy?.(model);\r\n };\r\n }, [component, params, context]);\r\n\r\n useEffect(() => {\r\n try {\r\n if (getGlobalFlags().debug) {\r\n // mount\r\n const hierarchyId = modelContext.getHierarchyId;\r\n console.debug(`${hierarchyId}>ready`);\r\n }\r\n component.events?.onReady?.(model);\r\n params?.onReady?.(model);\r\n } catch (err) {\r\n if (getGlobalFlags().debug) {\r\n // unmount\r\n const hierarchyId = modelContext.getHierarchyId;\r\n console.debug(`${hierarchyId}>destroy`);\r\n }\r\n component.events?.onError?.(model, err);\r\n params?.onError?.(model, err);\r\n }\r\n return () => {\r\n component.events?.onDestroy?.(model);\r\n params?.onDestroy?.(model);\r\n };\r\n }, [component, 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 = modelContext.getHierarchyId;\r\n console.debug(`${hierarchyId}>view`);\r\n }\r\n if (typeof view === 'function') {\r\n content = view(props, model);\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 = component.name || srcName || `Component_${componentData.count}`;\r\n srcInfo = {\r\n structId: structId,\r\n count: 0,\r\n };\r\n sources.set(fileName, srcInfo);\r\n componentData.count++;\r\n }\r\n\r\n const id = `${srcInfo.structId}#${srcInfo.count}`;\r\n modelContext = {\r\n bindings: bindings,\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 };\r\n\r\n model = {\r\n ...component.props,\r\n ...component.methods,\r\n // view: component.view,\r\n View: ViewFC,\r\n get msgBus() {\r\n return componentMsgBus();\r\n },\r\n msgBroker: msgBroker,\r\n $: modelContext,\r\n };\r\n\r\n if (component.children) {\r\n for (const [key, value] of Object.entries(component.children)) {\r\n if (typeof value == 'function') {\r\n const view = value as (params: any) => ComponentModel;\r\n // observer\r\n const ChildViewFC: ComponentViewImplFn<TStruct> = (props) => {\r\n const model = view(props);\r\n return <model.View />;\r\n // if (typeof model.view === \"function\") {\r\n // return model.view(props);\r\n // }\r\n // return <>{props.children}</>;\r\n };\r\n Reflect.set(model, capitalize(key), ChildViewFC);\r\n } else {\r\n Reflect.set(model, key, value);\r\n }\r\n }\r\n }\r\n\r\n // Reflect.ownKeys\r\n for (const [key, value] of Object.entries(params)) {\r\n if (isBinding(value)) {\r\n bindings.set(key, value);\r\n } else {\r\n Reflect.set(model, key, value);\r\n }\r\n }\r\n\r\n // decorators\r\n const annotationMap: Record<string, any> = {};\r\n\r\n if (component.props) {\r\n for (const key of Object.keys(component.props)) {\r\n annotationMap[key] = observable.ref;\r\n }\r\n }\r\n if (component.methods) {\r\n for (const key of Object.keys(component.methods)) {\r\n annotationMap[key] = false;\r\n }\r\n }\r\n if (component.children) {\r\n for (const key of Object.keys(component.children)) {\r\n annotationMap[key] = false;\r\n }\r\n }\r\n\r\n // annotationMap[\"view\" satisfies keyof Component<TStruct>] = false;\r\n annotationMap['View' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n annotationMap['msgBus' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n annotationMap['$' satisfies keyof ComponentModelBase<TStruct>] = false;\r\n\r\n const proxyEventHandlers: Pick<ProxyEventHandlers, 'onPropChanging' | 'onPropChange'> = {\r\n onPropChanging:\r\n params?.onPropChanging || component.events?.onPropChanging\r\n ? (prop, oldValue, newValue) => {\r\n let result = true;\r\n let handler = params.onPropChanging;\r\n if (handler) {\r\n result = handler(String(prop), oldValue, newValue);\r\n }\r\n if (result) {\r\n handler = component.events?.onPropChanging;\r\n if (handler) {\r\n result = handler(String(prop), oldValue, newValue);\r\n }\r\n }\r\n return result;\r\n }\r\n : undefined,\r\n onPropChange:\r\n params?.onPropChange || component.events?.onPropChange\r\n ? (prop, value) => {\r\n params.onPropChange?.(String(prop), value);\r\n component.events.onPropChange?.(String(prop), value);\r\n }\r\n : undefined,\r\n };\r\n\r\n function resolveOnGetEventHandler(prop: string) {\r\n const key = `${$ON_GET}${capitalize(prop)}`;\r\n return params[key] || component.events?.[key];\r\n }\r\n\r\n function resolveOnChangingEventHandler(prop: string) {\r\n const key = `${$ON_CHANGING}${capitalize(prop)}`;\r\n return ((oldValue: any, newValue: any) => {\r\n let result = true;\r\n let handler = params[key] as ValueChangingHandler<any>;\r\n if (handler) {\r\n result = handler(oldValue, newValue);\r\n }\r\n if (result) {\r\n handler = component.events[key] as ValueChangingHandler<any>;\r\n if (handler) {\r\n result = handler(oldValue, newValue);\r\n }\r\n }\r\n return result;\r\n }) as ValueChangingHandler;\r\n }\r\n\r\n function resolveOnChangeEventHandler(prop: string) {\r\n const key = `${$ON_CHANGE}${capitalize(prop)}`;\r\n return ((value: any) => {\r\n (params[key] as ValueChangeHandler<any>)?.(value);\r\n (component.events[key] as ValueChangeHandler<any>)?.(value);\r\n }) as ValueChangeHandler;\r\n }\r\n\r\n if (component.props) {\r\n for (const prop of Object.keys(component.props)) {\r\n proxyEventHandlers[prop] = {\r\n onGet: resolveOnGetEventHandler(prop),\r\n onChanging: resolveOnChangingEventHandler(prop),\r\n onChange: resolveOnChangeEventHandler(prop),\r\n };\r\n }\r\n }\r\n\r\n model = observable(model, annotationMap, {\r\n deep: true,\r\n });\r\n // model = useLocalObservable(() => model, annotationMap);\r\n\r\n model = createProxy(model, bindings, proxyEventHandlers);\r\n\r\n if (component.events?.onInit) {\r\n component.events.onInit(model);\r\n }\r\n\r\n if (params?.onInit) {\r\n params.onInit(model);\r\n }\r\n\r\n return model;\r\n}\r\n\r\nexport function useComponent<\r\n TStruct extends ComponentStruct = ComponentStruct,\r\n TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders,\r\n>(component: Component<TStruct, TMsgHeaders>, params: ComponentParams<TStruct>) {\r\n const ref = useLazyRef(() => createModel(component, params));\r\n useLayoutEffect(() => {\r\n return () => {\r\n ref.current = null;\r\n };\r\n }, [component, 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>) => ComponentModel<TStruct>,\r\n): FC<ComponentParams<TStruct>> {\r\n // observer\r\n const fc = (params: ComponentParams<TStruct> & PropsWithChildren) => {\r\n // modelHook\r\n const model = factory(params); // without useRef!\r\n // return model.view();\r\n return <model.View {...params} />;\r\n // return <ViewerFC {...params} view={model.view} />;\r\n };\r\n return fc;\r\n}\r\n"],"names":["ComponentMsgFilter","$isBinding","Binding","get","set","converter","validator","isBinding","obj","bind","bindProp","target","prop","value","$ON_GET","$ON_CHANGING","$ON_CHANGE","createProxy","state","bindings","proxyEventHandlers","onPropChanging","onPropChange","receiver","onGet","binding","oldValue","onChanging","result","runInAction","onChange","capitalize","name","componentData","toHtmlId","url","segmentsCount","segment","getCallerFileName","depth","stack","match","registerMsgBroker","model","providers","channel","providerGroups","g","p","provider","callback","msg","headers","filter","componentFilter","msgFilter","subscribers","subscriberGroups","s","subscriber","getComponentMsgBus","msgBus","modelContext","updateParams","params","createModel","component","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","key","ChildViewFC","annotationMap","observable","newValue","handler","resolveOnGetEventHandler","resolveOnChangingEventHandler","resolveOnChangeEventHandler","useComponent","ref","useLazyRef","getFC","factory"],"mappings":";;;;;;;AAuBO,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;AAsJZ,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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gBusCore';
2
+ export type BaseComponentContext<TMsgStruct extends MsgStruct = MsgStruct> = {
3
+ msgBus: MsgBus<TMsgStruct>;
4
+ currentId?: string;
5
+ };
6
+ export type TreeNode = {
7
+ id: string;
8
+ parentId?: string;
9
+ children: Set<string>;
10
+ };
11
+ export type ComponentRegistryContext<TMsgStruct extends MsgStruct = MsgStruct> = BaseComponentContext<TMsgStruct> & {
12
+ register: (id: string, parentId?: string) => void;
13
+ unregister: (id: string) => void;
14
+ getParent: (id: string) => string | undefined;
15
+ getChildren: (id: string) => string[];
16
+ getChainUp: (id: string) => string[];
17
+ getChainDown: (id: string) => string[];
18
+ getHierarchyPath: (id: string) => string;
19
+ getNodeMap: () => Map<string, TreeNode>;
20
+ };
21
+ export type ComponentMsgHeaders = MsgHeaders & {};
22
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/componentModel/contracts.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE3E,MAAM,MAAM,oBAAoB,CAAC,UAAU,SAAS,SAAS,GAAG,SAAS,IAAI;IACzE,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC;AAGF,MAAM,MAAM,wBAAwB,CAAC,UAAU,SAAS,SAAS,GAAG,SAAS,IACzE,oBAAoB,CAAC,UAAU,CAAC,GAAG;IAC/B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC9C,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACtC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACrC,YAAY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IACvC,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,UAAU,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC3C,CAAC;AAEN,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=contracts.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { createContext as t, useContext as e } from "react";
2
+ const n = t(void 0);
3
+ function C() {
4
+ const o = e(n);
5
+ if (!o)
6
+ throw new Error(
7
+ "Can't resolve ComponentContext. Please wrap your component tree with <ComponentContextProvider>."
8
+ );
9
+ return o;
10
+ }
11
+ export {
12
+ n as ReactComponentContext,
13
+ C as useComponentContext
14
+ };
15
+ //# sourceMappingURL=componentContext.es.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentContext.es.es.js","sources":["../../componentModel/componentContext.es.js"],"sourcesContent":["import P, { createContext as R, useContext as k, useRef as i } from \"react\";\nconst f = R(void 0);\nfunction E(o) {\n let h;\n const c = i(/* @__PURE__ */ new Map()), u = i([]), g = () => u.current[u.current.length - 1], d = (e, t) => {\n let n = c.current.get(e);\n if (n ? n.parentId = t : (n = {\n id: e,\n parentId: t,\n children: /* @__PURE__ */ new Set()\n }, c.current.set(e, n)), t) {\n let r = c.current.get(t);\n r || (r = {\n id: t,\n children: /* @__PURE__ */ new Set()\n }, c.current.set(t, r)), r.children.has(e) || r.children.add(e);\n }\n u.current.push(e);\n }, a = (e) => {\n const t = c.current.get(e);\n if (!t)\n return;\n t.parentId && c.current.get(t.parentId)?.children.delete(e), t.children.forEach((r) => a(r)), c.current.delete(e);\n const n = u.current.lastIndexOf(e);\n n >= 0 && u.current.splice(n, 1);\n }, s = (e) => c.current.get(e)?.parentId, p = (e) => Array.from(c.current.get(e)?.children ?? []), C = (e) => {\n const t = [];\n let n = e;\n for (; ; ) {\n const r = s(n);\n if (!r)\n break;\n t.push(r), n = r;\n }\n return t;\n }, x = (e) => {\n const t = [], n = [e];\n for (; n.length > 0; ) {\n const r = n.pop(), v = p(r);\n for (const l of v)\n t.includes(l) || (t.push(l), n.push(l));\n }\n return t;\n }, w = (e) => {\n e || (e = g());\n const t = [];\n let n = e;\n for (; n; )\n t.push(n), n = s(n);\n return t.reverse().join(\"/\");\n }, m = () => c.current;\n return h = i({\n ...o.value,\n register: d,\n unregister: a,\n getParent: s,\n getChildren: p,\n getChainUp: C,\n getChainDown: x,\n getHierarchyPath: w,\n getNodeMap: m\n }), /* @__PURE__ */ P.createElement(f.Provider, { value: h.current }, o.children);\n}\nfunction S() {\n const o = k(f);\n if (!o)\n throw new Error(\n \"Can't resolve ComponentContext. Please wrap your component tree with <ComponentContextProvider>.\"\n );\n return o;\n}\nexport {\n E as ComponentContextProvider,\n f as ReactComponentContext,\n S as useComponentContext\n};\n//# sourceMappingURL=componentContext.es.js.map\n"],"names":["f","R","S","k"],"mappings":";AACK,MAACA,IAAIC,EAAE,MAAM;AA8DlB,SAASC,IAAI;AACX,QAAM,IAAIC,EAAEH,CAAC;AACb,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACN;AACE,SAAO;AACT;"}
@@ -0,0 +1,260 @@
1
+ import y, { useLayoutEffect as R, useMemo as F, useEffect as L } from "react";
2
+ import { observer as M } from "mobx-react-lite";
3
+ import { observable as j, runInAction as N } from "mobx";
4
+ import { useLazyRef as A } from "../reactHooks.es.es.js";
5
+ import { getGlobalFlags as I } from "../globals.es.es.js";
6
+ import { useComponentContext as U, ReactComponentContext as x } from "./componentContext.es.es.js";
7
+ const z = Symbol("$isBinding");
8
+ function G(n) {
9
+ return n[z] === !0;
10
+ }
11
+ const V = "onGet", Z = "onChanging", J = "onChange";
12
+ function K(n, e, a) {
13
+ const C = a.onPropChanging, t = a.onPropChange;
14
+ return new Proxy(n, {
15
+ get(c, u, i) {
16
+ const p = a[u]?.onGet;
17
+ if (p)
18
+ return p();
19
+ const g = e.get(String(u));
20
+ if (g) {
21
+ let l;
22
+ return l = g.get(), l;
23
+ }
24
+ return Reflect.get(c, u, i);
25
+ },
26
+ set(c, u, i, p) {
27
+ const g = c[u], l = a[u]?.onChanging;
28
+ if (l && !l(g, i) || C && !C(u, g, i))
29
+ return !0;
30
+ const v = N(() => Reflect.set(c, u, i, p)), P = e.get(u);
31
+ P?.set && P.set(i);
32
+ const k = a[u]?.onChange;
33
+ return k && k(i), t && t(u, i), v;
34
+ }
35
+ });
36
+ }
37
+ function w(n) {
38
+ return n.replace(/^./, n[0].toUpperCase());
39
+ }
40
+ const E = {
41
+ sources: /* @__PURE__ */ new Map(),
42
+ count: 0
43
+ };
44
+ function _(n, e = 1) {
45
+ return n.split(/[?#]/)[0].split("/").filter(Boolean).map((a) => decodeURIComponent(a)).slice(-e).join("-").normalize("NFKD").replace(/[^a-zA-Z0-9\-_:.+#]/g, "-").replace(/-+/g, "-").replace(/^[^a-zA-Z]+/, "-").replace(/[+#]$/, "-");
46
+ }
47
+ function q(n = 2) {
48
+ const e = new Error().stack?.split(`
49
+ `);
50
+ if (!e || e.length <= n) return null;
51
+ const a = e[n].match(/\((.*):\d+:\d+\)/);
52
+ return a ? a[1] : null;
53
+ }
54
+ function Q(n) {
55
+ const e = n?.msgBroker.provide;
56
+ if (e)
57
+ for (const [C, t] of Object.entries(e))
58
+ for (const [c, u] of Object.entries(t)) {
59
+ const i = u, p = i.callback;
60
+ p && (i.callback = (l) => p(l, n));
61
+ const g = i.filter;
62
+ g && (i.filter = (l) => g(l, n)), n.msgBus.provide({
63
+ ...u,
64
+ channel: C,
65
+ group: c,
66
+ config: {
67
+ abortSignal: n.msgBroker.abortController.signal
68
+ }
69
+ });
70
+ }
71
+ const a = n?.msgBroker?.subscribe;
72
+ if (a)
73
+ for (const [C, t] of Object.entries(a))
74
+ for (const [c, u] of Object.entries(t)) {
75
+ const i = u, p = i.callback;
76
+ p && (i.callback = (l) => p(l, n));
77
+ const g = i.filter;
78
+ g && (i.filter = (l) => g(l, n)), n.msgBus.on({
79
+ ...u,
80
+ channel: C,
81
+ group: c,
82
+ config: {
83
+ abortSignal: n.msgBroker.abortController.signal
84
+ }
85
+ });
86
+ }
87
+ }
88
+ function T(n, e) {
89
+ const a = /* @__PURE__ */ new Map(), C = n.view;
90
+ let t, c, u = n.msgBus, i = {
91
+ ...n.msgBroker
92
+ };
93
+ i.abortController || (i.abortController = new AbortController());
94
+ const p = M((o) => {
95
+ const r = c.id, s = U(), h = s.currentId;
96
+ c.parentId = h, u || (u = s.msgBus);
97
+ const d = F(
98
+ () => ({ ...s, currentId: r }),
99
+ [n, e, s]
100
+ );
101
+ R(() => {
102
+ try {
103
+ if (I().debug) {
104
+ const f = c.getHierarchyId;
105
+ console.debug(`${f}>layout`);
106
+ }
107
+ s.register(r, h), c.getHierarchyId = () => s.getHierarchyPath(r), c.getChainDown = () => s.getChainDown(r), c.getChainUp = () => s.getChainUp(r), c.getChildren = () => s.getChildren(r), c.getParent = () => s.getParent(r), c.getNodeMap = () => s.getNodeMap(), Q(t), n.events?.onLayout?.(t), e?.onLayout?.(t);
108
+ } catch (f) {
109
+ n.events?.onError?.(t, f), e?.onError?.(t, f);
110
+ }
111
+ return () => {
112
+ if (I().debug) {
113
+ const f = c.getHierarchyId;
114
+ console.debug(`${f}>layout-destroy`);
115
+ }
116
+ s.unregister(r), i.abortController.abort(), n.events?.onLayoutDestroy?.(t), e?.onLayoutDestroy?.(t);
117
+ };
118
+ }, [n, e, s]), L(() => {
119
+ try {
120
+ if (I().debug) {
121
+ const f = c.getHierarchyId;
122
+ console.debug(`${f}>ready`);
123
+ }
124
+ n.events?.onReady?.(t), e?.onReady?.(t);
125
+ } catch (f) {
126
+ if (I().debug) {
127
+ const B = c.getHierarchyId;
128
+ console.debug(`${B}>destroy`);
129
+ }
130
+ n.events?.onError?.(t, f), e?.onError?.(t, f);
131
+ }
132
+ return () => {
133
+ n.events?.onDestroy?.(t), e?.onDestroy?.(t);
134
+ };
135
+ }, [n, e, s]);
136
+ let m;
137
+ try {
138
+ if (I().debug) {
139
+ const f = c.getHierarchyId;
140
+ console.debug(`${f}>view`);
141
+ }
142
+ typeof C == "function" ? m = C(o, t) : m = /* @__PURE__ */ y.createElement(y.Fragment, null, o.children);
143
+ } catch (f) {
144
+ const B = JSON.stringify(f);
145
+ m = /* @__PURE__ */ y.createElement(y.Fragment, null, B);
146
+ }
147
+ return /* @__PURE__ */ y.createElement(x.Provider, { value: d }, m);
148
+ });
149
+ let g;
150
+ const l = E.sources, v = q(6), P = _(v, 2);
151
+ l.has(v) ? (g = l.get(v), g.count++) : (g = {
152
+ structId: n.name || P || `Component_${E.count}`,
153
+ count: 0
154
+ }, l.set(v, g), E.count++);
155
+ const k = `${g.structId}#${g.count}`;
156
+ if (c = {
157
+ bindings: a,
158
+ id: k,
159
+ parentId: void 0,
160
+ getHierarchyId: () => {
161
+ },
162
+ getChainDown: () => {
163
+ },
164
+ getChainUp: () => {
165
+ },
166
+ getChildren: () => {
167
+ },
168
+ getParent: () => {
169
+ },
170
+ getNodeMap: () => {
171
+ }
172
+ }, t = {
173
+ ...n.props,
174
+ ...n.methods,
175
+ // view: component.view,
176
+ View: p,
177
+ get msgBus() {
178
+ return u;
179
+ },
180
+ msgBroker: i,
181
+ $: c
182
+ }, n.children)
183
+ for (const [o, r] of Object.entries(n.children))
184
+ if (typeof r == "function") {
185
+ const s = r, h = (d) => {
186
+ const m = s(d);
187
+ return /* @__PURE__ */ y.createElement(m.View, null);
188
+ };
189
+ Reflect.set(t, w(o), h);
190
+ } else
191
+ Reflect.set(t, o, r);
192
+ for (const [o, r] of Object.entries(e))
193
+ G(r) ? a.set(o, r) : Reflect.set(t, o, r);
194
+ const b = {};
195
+ if (n.props)
196
+ for (const o of Object.keys(n.props))
197
+ b[o] = j.ref;
198
+ if (n.methods)
199
+ for (const o of Object.keys(n.methods))
200
+ b[o] = !1;
201
+ if (n.children)
202
+ for (const o of Object.keys(n.children))
203
+ b[o] = !1;
204
+ b.View = !1, b.msgBus = !1, b.$ = !1;
205
+ const O = {
206
+ onPropChanging: e?.onPropChanging || n.events?.onPropChanging ? (o, r, s) => {
207
+ let h = !0, d = e.onPropChanging;
208
+ return d && (h = d(String(o), r, s)), h && (d = n.events?.onPropChanging, d && (h = d(String(o), r, s))), h;
209
+ } : void 0,
210
+ onPropChange: e?.onPropChange || n.events?.onPropChange ? (o, r) => {
211
+ e.onPropChange?.(String(o), r), n.events.onPropChange?.(String(o), r);
212
+ } : void 0
213
+ };
214
+ function S(o) {
215
+ const r = `${V}${w(o)}`;
216
+ return e[r] || n.events?.[r];
217
+ }
218
+ function D(o) {
219
+ const r = `${Z}${w(o)}`;
220
+ return ((s, h) => {
221
+ let d = !0, m = e[r];
222
+ return m && (d = m(s, h)), d && (m = n.events[r], m && (d = m(s, h))), d;
223
+ });
224
+ }
225
+ function H(o) {
226
+ const r = `${J}${w(o)}`;
227
+ return ((s) => {
228
+ e[r]?.(s), n.events[r]?.(s);
229
+ });
230
+ }
231
+ if (n.props)
232
+ for (const o of Object.keys(n.props))
233
+ O[o] = {
234
+ onGet: S(o),
235
+ onChanging: D(o),
236
+ onChange: H(o)
237
+ };
238
+ return t = j(t, b, {
239
+ deep: !0
240
+ }), t = K(t, a, O), n.events?.onInit && n.events.onInit(t), e?.onInit && e.onInit(t), t;
241
+ }
242
+ function tn(n, e) {
243
+ const a = A(() => T(n, e));
244
+ return R(() => () => {
245
+ a.current = null;
246
+ }, [n, e]), a.current;
247
+ }
248
+ function on(n) {
249
+ return (e) => {
250
+ const a = n(e);
251
+ return /* @__PURE__ */ y.createElement(a.View, { ...e });
252
+ };
253
+ }
254
+ export {
255
+ on as getFC,
256
+ G as isBinding,
257
+ _ as toHtmlId,
258
+ tn as useComponent
259
+ };
260
+ //# sourceMappingURL=componentModel.es.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentModel.es.es.js","sources":["../../componentModel/componentModel.es.js"],"sourcesContent":["import I, { useLayoutEffect as R, useMemo as H, useEffect as L } from \"react\";\nimport { observer as x } from \"mobx-react-lite\";\nimport { observable as G, runInAction as z } from \"mobx\";\nimport { useLazyRef as U } from \"../reactHooks.es.js\";\nimport { getGlobalFlags as P } from \"../globals.es.js\";\nimport { useComponentContext as _, ReactComponentContext as M } from \"./componentContext.es.js\";\nvar V = /* @__PURE__ */ ((e) => (e[e.None = 0] = \"None\", e[e.FromAncestors = 1] = \"FromAncestors\", e[e.FromDescendants = 2] = \"FromDescendants\", e))(V || {});\nconst E = Symbol(\"$isBinding\");\nclass j {\n // getter\n get;\n // setter\n set;\n converter;\n validator;\n readOnly;\n constructor(t, s, u, n) {\n this.get = t, this.set = s, this.converter = u, this.validator = n, this.readOnly = !!s, this[E] = !0;\n }\n [E];\n}\nfunction Z(e) {\n return e[E] === !0;\n}\nfunction oe(e, t, s, u) {\n return new j(e, t, s, u);\n}\nfunction se(e, t) {\n return new j(\n () => e()[t],\n (s) => {\n e()[t] = s;\n }\n );\n}\nconst J = \"onGet\", K = \"onChanging\", T = \"onChange\";\nfunction q(e, t, s) {\n const u = s.onPropChanging, n = s.onPropChange;\n return new Proxy(e, {\n get(i, g, c) {\n const C = s[g]?.onGet;\n if (C)\n return C();\n const f = t.get(String(g));\n if (f) {\n let a;\n return a = f.get(), a;\n }\n return Reflect.get(i, g, c);\n },\n set(i, g, c, C) {\n const f = i[g], a = s[g]?.onChanging;\n if (a && !a(f, c) || u && !u(g, f, c))\n return !0;\n const k = z(() => Reflect.set(i, g, c, C)), $ = t.get(g);\n $?.set && $.set(c);\n const w = s[g]?.onChange;\n return w && w(c), n && n(g, c), k;\n }\n });\n}\nfunction B(e) {\n return e.replace(/^./, e[0].toUpperCase());\n}\nconst N = {\n sources: /* @__PURE__ */ new Map(),\n count: 0\n};\nfunction Q(e, t = 1) {\n return e.split(/[?#]/)[0].split(\"/\").filter(Boolean).map((c) => decodeURIComponent(c)).slice(-t).join(\"-\").normalize(\"NFKD\").replace(/[^a-zA-Z0-9\\-_:.+#]/g, \"-\").replace(/-+/g, \"-\").replace(/^[^a-zA-Z]+/, \"-\").replace(/[+#]$/, \"-\");\n}\nfunction W(e = 2) {\n const s = new Error().stack?.split(`\n`);\n if (!s || s.length <= e) return null;\n const u = s[e].match(/\\((.*):\\d+:\\d+\\)/);\n return u ? u[1] : null;\n}\nfunction X(e) {\n const t = e?.msgBroker.provide;\n if (t)\n for (const [u, n] of Object.entries(t))\n for (const [i, g] of Object.entries(n)) {\n const c = g, C = c.callback;\n C && (c.callback = (a) => C(a, e));\n const f = c.filter;\n f && (c.filter = (a) => f(a, e)), e.msgBus.provide({\n ...g,\n channel: u,\n group: i,\n config: {\n abortSignal: e.msgBroker.abortController.signal\n }\n });\n }\n const s = e?.msgBroker?.subscribe;\n if (s)\n for (const [u, n] of Object.entries(s))\n for (const [i, g] of Object.entries(n)) {\n const c = g, C = c.callback;\n C && (c.callback = (a) => C(a, e));\n const f = c.filter;\n f && (c.filter = (a) => f(a, e)), e.msgBus.on({\n ...g,\n channel: u,\n group: i,\n config: {\n abortSignal: e.msgBroker.abortController.signal\n }\n });\n }\n}\nfunction Y(e, t) {\n const s = /* @__PURE__ */ new Map(), u = e.view;\n let n, i, g = e.msgBus, c = {\n ...e.msgBroker\n };\n c.abortController || (c.abortController = new AbortController());\n const C = x((r) => {\n const o = i.id, l = _(), b = l.currentId;\n i.parentId = b, g || (g = l.msgBus);\n const h = H(\n () => ({ ...l, currentId: o }),\n [e, t, l]\n );\n R(() => {\n try {\n if (P().debug) {\n const d = i.getHierarchyId;\n console.debug(`${d}>layout`);\n }\n l.register(o, b), i.getHierarchyId = () => l.getHierarchyPath(o), i.getChainDown = () => l.getChainDown(o), i.getChainUp = () => l.getChainUp(o), i.getChildren = () => l.getChildren(o), i.getParent = () => l.getParent(o), i.getNodeMap = () => l.getNodeMap(), X(n), e.events?.onLayout?.(n), t?.onLayout?.(n);\n } catch (d) {\n e.events?.onError?.(n, d), t?.onError?.(n, d);\n }\n return () => {\n if (P().debug) {\n const d = i.getHierarchyId;\n console.debug(`${d}>layout-destroy`);\n }\n l.unregister(o), c.abortController.abort(), e.events?.onLayoutDestroy?.(n), t?.onLayoutDestroy?.(n);\n };\n }, [e, t, l]), L(() => {\n try {\n if (P().debug) {\n const d = i.getHierarchyId;\n console.debug(`${d}>ready`);\n }\n e.events?.onReady?.(n), t?.onReady?.(n);\n } catch (d) {\n if (P().debug) {\n const O = i.getHierarchyId;\n console.debug(`${O}>destroy`);\n }\n e.events?.onError?.(n, d), t?.onError?.(n, d);\n }\n return () => {\n e.events?.onDestroy?.(n), t?.onDestroy?.(n);\n };\n }, [e, t, l]);\n let y;\n try {\n if (P().debug) {\n const d = i.getHierarchyId;\n console.debug(`${d}>view`);\n }\n typeof u == \"function\" ? y = u(r, n) : y = /* @__PURE__ */ I.createElement(I.Fragment, null, r.children);\n } catch (d) {\n const O = JSON.stringify(d);\n y = /* @__PURE__ */ I.createElement(I.Fragment, null, O);\n }\n return /* @__PURE__ */ I.createElement(M.Provider, { value: h }, y);\n });\n let f;\n const a = N.sources, k = W(6), $ = Q(k, 2);\n a.has(k) ? (f = a.get(k), f.count++) : (f = {\n structId: e.name || $ || `Component_${N.count}`,\n count: 0\n }, a.set(k, f), N.count++);\n const w = `${f.structId}#${f.count}`;\n if (i = {\n bindings: s,\n id: w,\n parentId: void 0,\n getHierarchyId: () => {\n },\n getChainDown: () => {\n },\n getChainUp: () => {\n },\n getChildren: () => {\n },\n getParent: () => {\n },\n getNodeMap: () => {\n }\n }, n = {\n ...e.props,\n ...e.methods,\n // view: component.view,\n View: C,\n get msgBus() {\n return g;\n },\n msgBroker: c,\n $: i\n }, e.children)\n for (const [r, o] of Object.entries(e.children))\n if (typeof o == \"function\") {\n const l = o, b = (h) => {\n const y = l(h);\n return /* @__PURE__ */ I.createElement(y.View, null);\n };\n Reflect.set(n, B(r), b);\n } else\n Reflect.set(n, r, o);\n for (const [r, o] of Object.entries(t))\n Z(o) ? s.set(r, o) : Reflect.set(n, r, o);\n const v = {};\n if (e.props)\n for (const r of Object.keys(e.props))\n v[r] = G.ref;\n if (e.methods)\n for (const r of Object.keys(e.methods))\n v[r] = !1;\n if (e.children)\n for (const r of Object.keys(e.children))\n v[r] = !1;\n v.View = !1, v.msgBus = !1, v.$ = !1;\n const D = {\n onPropChanging: t?.onPropChanging || e.events?.onPropChanging ? (r, o, l) => {\n let b = !0, h = t.onPropChanging;\n return h && (b = h(String(r), o, l)), b && (h = e.events?.onPropChanging, h && (b = h(String(r), o, l))), b;\n } : void 0,\n onPropChange: t?.onPropChange || e.events?.onPropChange ? (r, o) => {\n t.onPropChange?.(String(r), o), e.events.onPropChange?.(String(r), o);\n } : void 0\n };\n function S(r) {\n const o = `${J}${B(r)}`;\n return t[o] || e.events?.[o];\n }\n function A(r) {\n const o = `${K}${B(r)}`;\n return ((l, b) => {\n let h = !0, y = t[o];\n return y && (h = y(l, b)), h && (y = e.events[o], y && (h = y(l, b))), h;\n });\n }\n function F(r) {\n const o = `${T}${B(r)}`;\n return ((l) => {\n t[o]?.(l), e.events[o]?.(l);\n });\n }\n if (e.props)\n for (const r of Object.keys(e.props))\n D[r] = {\n onGet: S(r),\n onChanging: A(r),\n onChange: F(r)\n };\n return n = G(n, v, {\n deep: !0\n }), n = q(n, s, D), e.events?.onInit && e.events.onInit(n), t?.onInit && t.onInit(n), n;\n}\nfunction ie(e, t) {\n const s = U(() => Y(e, t));\n return R(() => () => {\n s.current = null;\n }, [e, t]), s.current;\n}\nfunction ce(e) {\n return (s) => {\n const u = e(s);\n return /* @__PURE__ */ I.createElement(u.View, { ...s });\n };\n}\nexport {\n V as ComponentMsgHeaderFilter,\n oe as bind,\n se as bindProp,\n ce as getFC,\n Z as isBinding,\n Q as toHtmlId,\n ie as useComponent\n};\n//# sourceMappingURL=componentModel.es.js.map\n"],"names":["E","Z","e","J","K","T","q","t","s","u","n","i","g","c","C","f","a","k","z","$","w","B","N","Q","W","X","Y","x","r","o","l","_","b","h","H","R","P","d","L","O","y","I","M","v","G","D","S","A","F","ie","U","ce"],"mappings":";;;;;;AAOA,MAAMA,IAAI,OAAO,YAAY;AAc7B,SAASC,EAAEC,GAAG;AACZ,SAAOA,EAAEF,CAAC,MAAM;AAClB;AAYA,MAAMG,IAAI,SAASC,IAAI,cAAcC,IAAI;AACzC,SAASC,EAAEJ,GAAGK,GAAGC,GAAG;AAClB,QAAMC,IAAID,EAAE,gBAAgBE,IAAIF,EAAE;AAClC,SAAO,IAAI,MAAMN,GAAG;AAAA,IAClB,IAAIS,GAAGC,GAAGC,GAAG;AACX,YAAMC,IAAIN,EAAEI,CAAC,GAAG;AAChB,UAAIE;AACF,eAAOA,EAAC;AACV,YAAMC,IAAIR,EAAE,IAAI,OAAOK,CAAC,CAAC;AACzB,UAAIG,GAAG;AACL,YAAIC;AACJ,eAAOA,IAAID,EAAE,IAAG,GAAIC;AAAA,MACtB;AACA,aAAO,QAAQ,IAAIL,GAAGC,GAAGC,CAAC;AAAA,IAC5B;AAAA,IACA,IAAIF,GAAGC,GAAGC,GAAGC,GAAG;AACd,YAAMC,IAAIJ,EAAEC,CAAC,GAAGI,IAAIR,EAAEI,CAAC,GAAG;AAC1B,UAAII,KAAK,CAACA,EAAED,GAAGF,CAAC,KAAKJ,KAAK,CAACA,EAAEG,GAAGG,GAAGF,CAAC;AAClC,eAAO;AACT,YAAMI,IAAIC,EAAE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AG;AAAA,EACzD;AACF;"}
@@ -0,0 +1,10 @@
1
+ const e = {
2
+ debug: !1
3
+ };
4
+ function l() {
5
+ return typeof globalThis > "u" ? e : window.__DYNSTRUCT__ || e;
6
+ }
7
+ export {
8
+ l as getGlobalFlags
9
+ };
10
+ //# sourceMappingURL=globals.es.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.es.es.js","sources":["../globals.es.js"],"sourcesContent":["const l = {\n debug: !1\n};\nfunction e() {\n return typeof globalThis > \"u\" ? l : window.__DYNSTRUCT__ || l;\n}\nexport {\n e as getGlobalFlags\n};\n//# sourceMappingURL=globals.es.js.map\n"],"names":["l","e"],"mappings":"AAAA,MAAMA,IAAI;AAAA,EACR,OAAO;AACT;AACA,SAASC,IAAI;AACX,SAAO,OAAO,aAAa,MAAMD,IAAI,OAAO,iBAAiBA;AAC/D;"}
@@ -0,0 +1,9 @@
1
+ import { useRef as n } from "react";
2
+ function u(e) {
3
+ const r = n(null);
4
+ return r.current === null && (r.current = e()), r;
5
+ }
6
+ export {
7
+ u as useLazyRef
8
+ };
9
+ //# sourceMappingURL=reactHooks.es.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactHooks.es.es.js","sources":["../reactHooks.es.js"],"sourcesContent":["import { useRef as n } from \"react\";\nfunction t(e) {\n const r = n(null);\n return r.current === null && (r.current = e()), r;\n}\nexport {\n t as useLazyRef\n};\n//# sourceMappingURL=reactHooks.es.js.map\n"],"names":["t","n"],"mappings":";AACA,SAASA,EAAE,GAAG;AACZ,QAAM,IAAIC,EAAE,IAAI;AAChB,SAAO,EAAE,YAAY,SAAS,EAAE,UAAU,EAAC,IAAK;AAClD;"}
@@ -0,0 +1,11 @@
1
+ export {};
2
+ export type GlobalFlags = {
3
+ debug?: boolean;
4
+ };
5
+ declare global {
6
+ interface Window {
7
+ __DYNSTRUCT__?: GlobalFlags;
8
+ }
9
+ }
10
+ export declare function getGlobalFlags(): GlobalFlags;
11
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAG,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAMF,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,aAAa,CAAC,EAAE,WAAW,CAAC;KAC/B;CAEJ;AAGD,wBAAgB,cAAc,gBAS7B"}
@@ -0,0 +1,10 @@
1
+ const l = {
2
+ debug: !1
3
+ };
4
+ function e() {
5
+ return typeof globalThis > "u" ? l : window.__DYNSTRUCT__ || l;
6
+ }
7
+ export {
8
+ e as getGlobalFlags
9
+ };
10
+ //# sourceMappingURL=globals.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.es.js","sources":["../src/globals.ts"],"sourcesContent":["export { };\r\n\r\nexport type GlobalFlags = {\r\n debug?: boolean;\r\n};\r\n\r\nconst defaultGlobalFlags: GlobalFlags = {\r\n debug: false\r\n}\r\n\r\ndeclare global {\r\n interface Window {\r\n __DYNSTRUCT__?: GlobalFlags;\r\n }\r\n\r\n}\r\n\r\n// getUserFlags\r\nexport function getGlobalFlags() {\r\n // window\r\n const globalObj = globalThis as Window & typeof globalThis;\r\n\r\n if (typeof globalObj === 'undefined') {\r\n return defaultGlobalFlags;\r\n }\r\n\r\n return window.__DYNSTRUCT__ || defaultGlobalFlags;\r\n}"],"names":["defaultGlobalFlags","getGlobalFlags"],"mappings":"AAMA,MAAMA,IAAkC;AAAA,EACpC,OAAO;AACX;AAUO,SAASC,IAAiB;AAI7B,SAAI,OAFc,aAEO,MACdD,IAGJ,OAAO,iBAAiBA;AACnC;"}