@actdim/dynstruct 1.1.8 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appDomain/appContracts.d.ts +1 -1
- package/dist/appDomain/appContracts.d.ts.map +1 -1
- package/dist/appDomain/appContracts.es.js.map +1 -1
- package/dist/componentModel/react.d.ts +2 -2
- package/dist/componentModel/react.d.ts.map +1 -1
- package/dist/componentModel/react.es.js +37 -37
- package/dist/componentModel/react.es.js.map +1 -1
- package/dist/services/react/NavService.d.ts +1 -1
- package/dist/services/react/NavService.d.ts.map +1 -1
- package/dist/services/react/NavService.es.js.map +1 -1
- package/dist/services/react/StorageService.d.ts +1 -1
- package/dist/services/react/StorageService.d.ts.map +1 -1
- package/dist/services/react/StorageService.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appContracts.d.ts","sourceRoot":"","sources":["../../src/appDomain/appContracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC5E,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,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/D,eAAO,MAAM,SAAS,iBAAiB,CAAC;AACxC,eAAO,MAAM,gBAAgB,wBAAwB,CAAC;AACtD,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAC9D,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AAExD,eAAO,MAAM,OAAO,eAAe,CAAC;AACpC,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C,eAAO,MAAM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AC,MAAM,gBAAgB,CAAC,IAAI,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AAE7I,MAAM,MAAM,cAAc,CAAC,UAAU,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,EAE9G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appContracts.es.js","sources":["../../src/appDomain/appContracts.ts"],"sourcesContent":["import { MsgStructBase, MsgStructFactory } from \"@actdim/msgmesh/contracts\";\r\nimport { BaseSecurityDomainConfig as BaseSecurityDomainConfig, BaseSecurityMsgStruct } from \"@/appDomain/security/securityContracts\";\r\nimport { ReactNode } from \"react\";\r\nimport { KeysOf } from \"@actdim/utico/typeCore\";\r\nimport { BaseContext } from \"@/componentModel/contracts\";\r\nimport { StoreItem } from \"@actdim/utico/store/storeContracts\";\r\n\r\nexport const $NAV_GOTO = \"APP.NAV.GOTO\";\r\nexport const $NAV_CONTEXT_GET = \"APP.NAV.CONTEXT.GET\";\r\nexport const $NAV_CONTEXT_CHANGED = \"APP.NAV.CONTEXT.CHANGED\";\r\nexport const $NAV_HISTORY_READ = \"APP.NAV.HISTORY.READ\";\r\n\r\nexport const $NOTICE = \"APP.NOTICE\";\r\nexport const $CONFIG_GET = \"APP.CONFIG.GET\";\r\n\r\nexport const $ERROR = \"APP.ERROR\";\r\nexport const $FETCH = \"APP.FETCH\";\r\n\r\nexport const $STORE_GET = \"APP.STORE.GET\";\r\nexport const $STORE_SET = \"APP.STORE.SET\";\r\nexport const $STORE_REMOVE = \"APP.STORE.REMOVE\";\r\n// TODO: HAS, CLEAR\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 = {\r\n // code?: string;\r\n type?: string;\r\n name?: string;\r\n source?: any;\r\n // module: string;\r\n // description\r\n detail?: string;\r\n timestamp?: string;\r\n // errors: AppError[];\r\n // traceId?: string; \r\n message: string;\r\n // reason?: string;\r\n // propertyBag/context\r\n properties?: Record<string | number, any>;\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\nexport type Importance =\r\n | \"critical\"\r\n | \"high\"\r\n | \"normal\"\r\n | \"low\"\r\n | undefined\r\n\r\n// Intent\r\nexport type Severity =\r\n // critical/high\r\n | 'emergency'\r\n | 'alert' // danger\r\n | 'error' // failure\r\n | 'warn' // caution\r\n // normal\r\n | 'notice' // notification\r\n | 'info' // default\r\n | 'success' // confirmation\r\n // low\r\n | 'hint' // note\r\n | 'debug' // trace\r\n | undefined;\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 detail?: string;\r\n severity
|
|
1
|
+
{"version":3,"file":"appContracts.es.js","sources":["../../src/appDomain/appContracts.ts"],"sourcesContent":["import { MsgStructBase, MsgStructFactory } from \"@actdim/msgmesh/contracts\";\r\nimport { BaseSecurityDomainConfig as BaseSecurityDomainConfig, BaseSecurityMsgStruct } from \"@/appDomain/security/securityContracts\";\r\nimport { ReactNode } from \"react\";\r\nimport { KeysOf } from \"@actdim/utico/typeCore\";\r\nimport { BaseContext } from \"@/componentModel/contracts\";\r\nimport { StoreItem } from \"@actdim/utico/store/storeContracts\";\r\n\r\nexport const $NAV_GOTO = \"APP.NAV.GOTO\";\r\nexport const $NAV_CONTEXT_GET = \"APP.NAV.CONTEXT.GET\";\r\nexport const $NAV_CONTEXT_CHANGED = \"APP.NAV.CONTEXT.CHANGED\";\r\nexport const $NAV_HISTORY_READ = \"APP.NAV.HISTORY.READ\";\r\n\r\nexport const $NOTICE = \"APP.NOTICE\";\r\nexport const $CONFIG_GET = \"APP.CONFIG.GET\";\r\n\r\nexport const $ERROR = \"APP.ERROR\";\r\nexport const $FETCH = \"APP.FETCH\";\r\n\r\nexport const $STORE_GET = \"APP.STORE.GET\";\r\nexport const $STORE_SET = \"APP.STORE.SET\";\r\nexport const $STORE_REMOVE = \"APP.STORE.REMOVE\";\r\n// TODO: HAS, CLEAR\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 = {\r\n // code?: string;\r\n type?: string;\r\n name?: string;\r\n source?: any;\r\n // module: string;\r\n // description\r\n detail?: string;\r\n timestamp?: string;\r\n // errors: AppError[];\r\n // traceId?: string; \r\n message: string;\r\n // reason?: string;\r\n // propertyBag/context\r\n properties?: Record<string | number, any>;\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\nexport type Importance =\r\n | \"critical\"\r\n | \"high\"\r\n | \"normal\"\r\n | \"low\"\r\n | undefined\r\n\r\n// Intent\r\nexport type Severity =\r\n // critical/high\r\n | 'emergency'\r\n | 'alert' // danger\r\n | 'error' // failure\r\n | 'warn' // caution\r\n // normal\r\n | 'notice' // notification\r\n | 'info' // default\r\n | 'success' // confirmation\r\n // low\r\n | 'hint' // note\r\n | 'debug' // trace\r\n | undefined;\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 detail?: string;\r\n severity?: Severity;\r\n // propertyBag/context\r\n properties?: Record<string | number, 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_CONTEXT_GET]: {\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_HISTORY_READ]: {\r\n in: number;\r\n out: NavContext;\r\n };\r\n [$ERROR]: {\r\n in: AppError;\r\n out: boolean;\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 [$STORE_GET]: {\r\n in: {\r\n key: string;\r\n useEncryption?: boolean;\r\n };\r\n out: StoreItem;\r\n };\r\n [$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 [$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 defaultApi?: string;\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> = BaseContext<TMsgStruct> & {\r\n // securityProvider: SecurityProvider;\r\n};"],"names":["$NAV_GOTO","$NAV_CONTEXT_GET","$NAV_CONTEXT_CHANGED","$NAV_HISTORY_READ","$NOTICE","$CONFIG_GET","$ERROR","$FETCH","$STORE_GET","$STORE_SET","$STORE_REMOVE"],"mappings":"AAOO,MAAMA,IAAY,gBACZC,IAAmB,uBACnBC,IAAuB,2BACvBC,IAAoB,wBAEpBC,IAAU,cACVC,IAAc,kBAEdC,IAAS,aACTC,IAAS,aAETC,IAAa,iBACbC,IAAa,iBACbC,IAAgB;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
2
|
import { Component, ComponentDef, ComponentMsgHeaders, ComponentParams, ComponentStruct } from './contracts';
|
|
3
3
|
export declare function useComponent<TStruct extends ComponentStruct = ComponentStruct, TMsgHeaders extends ComponentMsgHeaders = ComponentMsgHeaders>(componentDef: ComponentDef<TStruct, TMsgHeaders>, params: ComponentParams<TStruct>): any;
|
|
4
|
-
export declare function getFC<TStruct extends ComponentStruct>(factory: (params: ComponentParams<TStruct>) => Component<TStruct>): FC<ComponentParams<TStruct>>;
|
|
4
|
+
export declare function getFC<TStruct extends ComponentStruct>(factory: (params: ComponentParams<TStruct>) => Component<TStruct>): React.FC<ComponentParams<TStruct>>;
|
|
5
5
|
//# sourceMappingURL=react.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/componentModel/react.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/componentModel/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAO3E,OAAO,EAEH,SAAS,EAET,YAAY,EAEZ,mBAAmB,EACnB,eAAe,EAEf,eAAe,EAOlB,MAAM,aAAa,CAAC;AAkWrB,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,OASnF;AAGD,wBAAgB,KAAK,CAAC,OAAO,SAAS,eAAe,EACjD,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC,OAAO,CAAC,GAClE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAQpC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { observer as
|
|
1
|
+
import y, { useLayoutEffect as H, useEffect as G, useMemo as S } from "react";
|
|
2
|
+
import { observer as F } from "mobx-react-lite";
|
|
3
3
|
import { observable as P } from "mobx";
|
|
4
|
-
import { useLazyRef as
|
|
4
|
+
import { useLazyRef as L } from "../reactHooks.es.js";
|
|
5
5
|
import { getGlobalFlags as h } from "../globals.es.js";
|
|
6
|
-
import { useComponentContext as
|
|
7
|
-
import { $ON_CHANGE as
|
|
6
|
+
import { useComponentContext as w, ReactComponentContext as z } from "./componentContext.es.js";
|
|
7
|
+
import { $ON_CHANGE as x, $ON_CHANGING as A, $ON_GET as T } from "./contracts.es.js";
|
|
8
8
|
import { lazy as U } from "@actdim/utico/utils";
|
|
9
9
|
import { getComponentSourceByCaller as _, getComponentMsgBus as J, toHtmlId as V, registerMsgBroker as q, isBinding as K, createRecursiveProxy as Q, createEffect as W } from "./core.es.js";
|
|
10
10
|
function C(e) {
|
|
@@ -13,11 +13,11 @@ function C(e) {
|
|
|
13
13
|
function X(e) {
|
|
14
14
|
return e.replace(/^[a-z][a-z0-9+.-]*:\/\/[^\/]+/, "");
|
|
15
15
|
}
|
|
16
|
-
function Y(e, i) {
|
|
16
|
+
function Y(e, u, i) {
|
|
17
17
|
let t, l;
|
|
18
18
|
e || (e = {});
|
|
19
|
-
let
|
|
20
|
-
|
|
19
|
+
let d = e.regType;
|
|
20
|
+
d || (d = _(6), d = X(d)), i || (i = {});
|
|
21
21
|
const $ = e.view;
|
|
22
22
|
let v = e.msgBus;
|
|
23
23
|
const b = /* @__PURE__ */ new Map(), B = U(() => J(v, (r) => {
|
|
@@ -27,19 +27,19 @@ function Y(e, i) {
|
|
|
27
27
|
...e.msgBroker
|
|
28
28
|
};
|
|
29
29
|
a.abortController || (a.abortController = new AbortController());
|
|
30
|
-
const
|
|
31
|
-
const n =
|
|
30
|
+
const N = F((r) => {
|
|
31
|
+
const n = w(), g = n.currentId;
|
|
32
32
|
if (t.parentId = g, v || (v = n.msgBus), !t.id) {
|
|
33
33
|
let o = i.$id;
|
|
34
34
|
if (!o) {
|
|
35
35
|
const f = i.$key;
|
|
36
|
-
f ? o = `${V(
|
|
36
|
+
f ? o = `${V(d)}#${f}` : o = n.getNextId(d);
|
|
37
37
|
}
|
|
38
38
|
t.id = o;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
H(() => {
|
|
41
41
|
try {
|
|
42
|
-
if (n.register(t.id,
|
|
42
|
+
if (n.register(t.id, d, g), h().debug) {
|
|
43
43
|
const o = t.getHierarchyId();
|
|
44
44
|
console.debug(`${o}>layout`);
|
|
45
45
|
}
|
|
@@ -54,7 +54,7 @@ function Y(e, i) {
|
|
|
54
54
|
}
|
|
55
55
|
n.unregister(t.id), a.abortController?.abort(), e.events?.onLayoutDestroy?.(t), i.onLayoutDestroy?.(t);
|
|
56
56
|
};
|
|
57
|
-
}, [e, i, n]),
|
|
57
|
+
}, [e, i, n]), G(() => {
|
|
58
58
|
try {
|
|
59
59
|
if (h().debug) {
|
|
60
60
|
const o = t.getHierarchyId();
|
|
@@ -78,23 +78,23 @@ function Y(e, i) {
|
|
|
78
78
|
const o = t.getHierarchyId();
|
|
79
79
|
console.debug(`${o}>view`);
|
|
80
80
|
}
|
|
81
|
-
typeof $ == "function" ? s = $(r, t) : s = /* @__PURE__ */
|
|
81
|
+
typeof $ == "function" ? s = $(r, t) : s = /* @__PURE__ */ y.createElement(y.Fragment, null, r.children);
|
|
82
82
|
} catch (o) {
|
|
83
83
|
const f = JSON.stringify(o);
|
|
84
|
-
s = /* @__PURE__ */
|
|
84
|
+
s = /* @__PURE__ */ y.createElement(y.Fragment, null, f);
|
|
85
85
|
}
|
|
86
|
-
const c =
|
|
86
|
+
const c = S(
|
|
87
87
|
() => ({ ...n, currentId: t.id }),
|
|
88
88
|
[e, i, n]
|
|
89
89
|
);
|
|
90
|
-
return /* @__PURE__ */
|
|
90
|
+
return /* @__PURE__ */ y.createElement(z.Provider, { value: c }, s);
|
|
91
91
|
}), I = {};
|
|
92
92
|
if (l = {}, e.props && Object.assign(l, e.props), e.actions && Object.assign(l, e.actions), e.children)
|
|
93
93
|
for (const [r, n] of Object.entries(e.children))
|
|
94
94
|
if (typeof n == "function") {
|
|
95
95
|
const g = n, s = (c) => {
|
|
96
96
|
const o = g(c);
|
|
97
|
-
return /* @__PURE__ */
|
|
97
|
+
return /* @__PURE__ */ y.createElement(o.View, null);
|
|
98
98
|
};
|
|
99
99
|
Reflect.set(I, C(r), s);
|
|
100
100
|
} else
|
|
@@ -114,15 +114,15 @@ function Y(e, i) {
|
|
|
114
114
|
const n = `${T}${C(r)}`;
|
|
115
115
|
return i[n] || e.events?.[n];
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function j(r) {
|
|
118
118
|
const n = `${A}${C(r)}`;
|
|
119
119
|
return ((g, s) => {
|
|
120
120
|
let c = !0, o = i[n];
|
|
121
121
|
return o && (c = o(g, s)), c && (o = e.events?.[n], o && (c = o(g, s))), c;
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
const n = `${
|
|
124
|
+
function M(r) {
|
|
125
|
+
const n = `${x}${C(r)}`;
|
|
126
126
|
return ((g) => {
|
|
127
127
|
i[n]?.(g), e.events?.[n]?.(g);
|
|
128
128
|
});
|
|
@@ -132,8 +132,8 @@ function Y(e, i) {
|
|
|
132
132
|
for (const r of Object.keys(e.props))
|
|
133
133
|
E[r] = {
|
|
134
134
|
onGet: R(r),
|
|
135
|
-
onChanging:
|
|
136
|
-
onChange:
|
|
135
|
+
onChanging: j(r),
|
|
136
|
+
onChange: M(r)
|
|
137
137
|
};
|
|
138
138
|
for (const r of Object.keys(e.props))
|
|
139
139
|
k[r] = P.deep;
|
|
@@ -148,14 +148,14 @@ function Y(e, i) {
|
|
|
148
148
|
if (t = {
|
|
149
149
|
id: i.$id,
|
|
150
150
|
key: i.$key,
|
|
151
|
-
regType:
|
|
151
|
+
regType: d,
|
|
152
152
|
parentId: void 0,
|
|
153
|
-
getHierarchyId: () =>
|
|
154
|
-
getChainDown: () =>
|
|
155
|
-
getChainUp: () =>
|
|
156
|
-
getChildren: () =>
|
|
157
|
-
getParent: () =>
|
|
158
|
-
getNodeMap: () =>
|
|
153
|
+
getHierarchyId: () => u.getHierarchyPath(t.id),
|
|
154
|
+
getChainDown: () => u.getChainDown(t.id),
|
|
155
|
+
getChainUp: () => u.getChainUp(t.id),
|
|
156
|
+
getChildren: () => u.getChildren(t.id),
|
|
157
|
+
getParent: () => u.getParent(t.id),
|
|
158
|
+
getNodeMap: () => u.getNodeMap(),
|
|
159
159
|
bindings: b,
|
|
160
160
|
get msgBus() {
|
|
161
161
|
return B();
|
|
@@ -175,16 +175,16 @@ function Y(e, i) {
|
|
|
175
175
|
);
|
|
176
176
|
return e.events?.onInit && e.events.onInit(t), i.onInit && i.onInit(t), t;
|
|
177
177
|
}
|
|
178
|
-
function oe(e,
|
|
179
|
-
const t =
|
|
180
|
-
return
|
|
178
|
+
function oe(e, u) {
|
|
179
|
+
const i = w(), t = L(() => Y(e, i, u));
|
|
180
|
+
return H(() => () => {
|
|
181
181
|
t.current = null;
|
|
182
182
|
}, []), t.current;
|
|
183
183
|
}
|
|
184
184
|
function se(e) {
|
|
185
|
-
return (
|
|
186
|
-
const
|
|
187
|
-
return /* @__PURE__ */
|
|
185
|
+
return (i) => {
|
|
186
|
+
const t = e(i);
|
|
187
|
+
return /* @__PURE__ */ y.createElement(t.View, { ...i });
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.es.js","sources":["../../src/componentModel/react.tsx"],"sourcesContent":["import React, { PropsWithChildren, useEffect, useLayoutEffect, FC, useMemo } from 'react';\r\nimport { Mutable } from '@actdim/utico/typeCore';\r\nimport { observer } from 'mobx-react-lite';\r\nimport { action, observable } from 'mobx';\r\nimport { useLazyRef } from '@/reactHooks';\r\nimport { getGlobalFlags } from '@/globals';\r\nimport { ReactComponentContext, useComponentContext } from './componentContext';\r\nimport {\r\n Binding,\r\n Component,\r\n ComponentChildren,\r\n ComponentDef,\r\n ComponentModel,\r\n ComponentMsgHeaders,\r\n ComponentParams,\r\n ComponentStruct,\r\n ComponentViewImplFn,\r\n ComponentViewProps,\r\n EffectController,\r\n EffectFn,\r\n ValueChangeHandler,\r\n ValueChangingHandler,\r\n} from './contracts';\r\nimport { $ON_CHANGE, $ON_CHANGING, $ON_GET, $isBinding, ComponentMsgFilter } from './contracts';\r\nimport { lazy } from '@actdim/utico/utils';\r\nimport {\r\n createEffect,\r\n createRecursiveProxy,\r\n getComponentSourceByCaller,\r\n getComponentMsgBus,\r\n isBinding,\r\n ProxyEventHandlers,\r\n registerMsgBroker,\r\n toHtmlId,\r\n} from './core';\r\n\r\nfunction capitalize(name: string) {\r\n return name.replace(/^./, name[0].toUpperCase());\r\n}\r\n\r\nfunction cleanSourceRef(sourceRef: string) {\r\n // remove origin\r\n return sourceRef.replace(/^[a-z][a-z0-9+.-]*:\\/\\/[^\\/]+/, '');\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 let regType = componentDef.regType;\r\n if (!regType) {\r\n regType = getComponentSourceByCaller(6);\r\n // type = getComponentNameByCaller(6);\r\n regType = cleanSourceRef(regType);\r\n // throw new Error('Valid component definition is required');\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 context = useComponentContext();\r\n\r\n const ViewFC = observer((props: ComponentViewProps) => {\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 if (!component.id) {\r\n let id = params.$id;\r\n if (!id) {\r\n const key = params.$key;\r\n if (key) {\r\n id = `${toHtmlId(regType)}#${key}`;\r\n } else {\r\n id = context.getNextId(regType);\r\n }\r\n }\r\n component.id = id;\r\n }\r\n\r\n useLayoutEffect(() => {\r\n try {\r\n context.register(component.id, regType, parentId);\r\n\r\n if (getGlobalFlags().debug) {\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>layout`);\r\n }\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(component.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.send\r\n content = <>{errDetails}</>;\r\n }\r\n const scopeContext = useMemo(\r\n () => ({ ...context, currentId: component.id }),\r\n [componentDef, params, context],\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 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 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: params.$id,\r\n key: params.$key,\r\n regType: regType,\r\n parentId: undefined,\r\n getHierarchyId: () => context.getHierarchyPath(component.id),\r\n getChainDown: () => context.getChainDown(component.id),\r\n getChainUp: () => context.getChainUp(component.id),\r\n getChildren: () => context.getChildren(component.id),\r\n getParent: () => context.getParent(component.id),\r\n getNodeMap: () => context.getNodeMap(),\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 }, []); // [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 const result = (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 result;\r\n}\r\n\r\n// TODO:\r\n// do not observe props with \"_\", \"$\" prefixes\r\n"],"names":["capitalize","name","cleanSourceRef","sourceRef","createComponent","componentDef","params","component","model","regType","getComponentSourceByCaller","view","msgBus","bindings","componentMsgBus","lazy","getComponentMsgBus","headers","msgBroker","context","useComponentContext","ViewFC","observer","props","parentId","id","key","toHtmlId","useLayoutEffect","getGlobalFlags","hierarchyId","registerMsgBroker","err","useEffect","content","React","errDetails","scopeContext","useMemo","ReactComponentContext","children","value","ChildViewFC","c","isBinding","proxyEventHandlers","prop","oldValue","newValue","result","handler","resolveOnGetEventHandler","$ON_GET","resolveOnChangingEventHandler","$ON_CHANGING","resolveOnChangeEventHandler","$ON_CHANGE","annotationMap","observable","createRecursiveProxy","effects","fn","createEffect","useComponent","ref","useLazyRef","getFC","factory"],"mappings":";;;;;;;;;AAoCA,SAASA,EAAWC,GAAc;AAC9B,SAAOA,EAAK,QAAQ,MAAMA,EAAK,CAAC,EAAE,aAAa;AACnD;AAEA,SAASC,EAAeC,GAAmB;AAEvC,SAAOA,EAAU,QAAQ,iCAAiC,EAAE;AAChE;AAEA,SAASC,EACLC,GACAC,GACkB;AAElB,MAAIC,GACAC;AAEJ,EAAKH,MACDA,IAAe,CAAA;AAGnB,MAAII,IAAUJ,EAAa;AAC3B,EAA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,SAAIxD,EAAa,QAAQ,UACrBA,EAAa,OAAO,OAAOE,CAAS,GAGpCD,EAAO,UACPA,EAAO,OAAOC,CAAS,GAGpBA;AACX;AAEO,SAASwD,GAGd1D,GAAkDC,GAAkC;AAClF,QAAM0D,IAAMC,EAAW,MAAM7D,EAAgBC,GAAcC,CAAM,CAAC;AAClE,SAAAsB,EAAgB,MACL,MAAM;AACT,IAAAoC,EAAI,UAAU;AAAA,EAClB,GACD,CAAA,CAAE,GACEA,EAAI;AACf;AAGO,SAASE,GACZC,GAC4B;AAO5B,SANe,CAAC7D,MAAyD;AAErE,UAAMqC,IAAIwB,EAAQ7D,CAAM;AAExB,WAAO,gBAAA6B,EAAA,cAACQ,EAAE,MAAF,EAAQ,GAAGrC,GAAQ;AAAA,EAC/B;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"react.es.js","sources":["../../src/componentModel/react.tsx"],"sourcesContent":["import React, { useEffect, useLayoutEffect, useMemo, useRef } from 'react';\r\nimport { Mutable } from '@actdim/utico/typeCore';\r\nimport { observer } from 'mobx-react-lite';\r\nimport { action, observable } from 'mobx';\r\nimport { useLazyRef } from '@/reactHooks';\r\nimport { getGlobalFlags } from '@/globals';\r\nimport { ReactComponentContext, useComponentContext } from './componentContext';\r\nimport {\r\n Binding,\r\n Component,\r\n ComponentChildren,\r\n ComponentDef,\r\n ComponentModel,\r\n ComponentMsgHeaders,\r\n ComponentParams,\r\n ComponentRegistryContext,\r\n ComponentStruct,\r\n ComponentViewImplFn,\r\n ComponentViewProps,\r\n EffectController,\r\n EffectFn,\r\n ValueChangeHandler,\r\n ValueChangingHandler,\r\n} from './contracts';\r\nimport { $ON_CHANGE, $ON_CHANGING, $ON_GET, $isBinding, ComponentMsgFilter } from './contracts';\r\nimport { lazy } from '@actdim/utico/utils';\r\nimport {\r\n createEffect,\r\n createRecursiveProxy,\r\n getComponentSourceByCaller,\r\n getComponentMsgBus,\r\n isBinding,\r\n ProxyEventHandlers,\r\n registerMsgBroker,\r\n toHtmlId,\r\n} from './core';\r\n\r\nfunction capitalize(name: string) {\r\n return name.replace(/^./, name[0].toUpperCase());\r\n}\r\n\r\nfunction cleanSourceRef(sourceRef: string) {\r\n // remove origin\r\n return sourceRef.replace(/^[a-z][a-z0-9+.-]*:\\/\\/[^\\/]+/, '');\r\n}\r\n\r\nfunction createComponent<TStruct extends ComponentStruct = ComponentStruct>(\r\n componentDef: ComponentDef<TStruct>,\r\n context: ComponentRegistryContext,\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 let regType = componentDef.regType;\r\n if (!regType) {\r\n regType = getComponentSourceByCaller(6);\r\n // type = getComponentNameByCaller(6);\r\n regType = cleanSourceRef(regType);\r\n // throw new Error('Valid component definition is required');\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 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 if (!component.id) {\r\n let id = params.$id;\r\n if (!id) {\r\n const key = params.$key;\r\n if (key) {\r\n id = `${toHtmlId(regType)}#${key}`;\r\n } else {\r\n id = context.getNextId(regType);\r\n }\r\n }\r\n component.id = id;\r\n }\r\n\r\n useLayoutEffect(() => {\r\n try {\r\n context.register(component.id, regType, parentId);\r\n\r\n if (getGlobalFlags().debug) {\r\n const hierarchyId = component.getHierarchyId();\r\n console.debug(`${hierarchyId}>layout`);\r\n }\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(component.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.send\r\n content = <>{errDetails}</>;\r\n }\r\n const scopeContext = useMemo(\r\n () => ({ ...context, currentId: component.id }),\r\n [componentDef, params, context],\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 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 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: params.$id,\r\n key: params.$key,\r\n regType: regType,\r\n parentId: undefined,\r\n getHierarchyId: () => context.getHierarchyPath(component.id),\r\n getChainDown: () => context.getChainDown(component.id),\r\n getChainUp: () => context.getChainUp(component.id),\r\n getChildren: () => context.getChildren(component.id),\r\n getParent: () => context.getParent(component.id),\r\n getNodeMap: () => context.getNodeMap(),\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 context = useComponentContext();\r\n const ref = useLazyRef(() => createComponent(componentDef, context, params));\r\n useLayoutEffect(() => {\r\n return () => {\r\n ref.current = null;\r\n };\r\n }, []); // [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): React.FC<ComponentParams<TStruct>> {\r\n const result = (params: ComponentParams<TStruct> & React.PropsWithChildren) => {\r\n // componentHook\r\n const c = factory(params);\r\n // return c.view();\r\n return <c.View {...params} />;\r\n };\r\n return result;\r\n}\r\n\r\n// TODO:\r\n// do not observe props with \"_\", \"$\" prefixes\r\n"],"names":["capitalize","name","cleanSourceRef","sourceRef","createComponent","componentDef","context","params","component","model","regType","getComponentSourceByCaller","view","msgBus","bindings","componentMsgBus","lazy","getComponentMsgBus","headers","msgBroker","ViewFC","observer","props","useComponentContext","parentId","id","key","toHtmlId","useLayoutEffect","getGlobalFlags","hierarchyId","registerMsgBroker","err","useEffect","content","React","errDetails","scopeContext","useMemo","ReactComponentContext","children","value","ChildViewFC","c","isBinding","proxyEventHandlers","prop","oldValue","newValue","result","handler","resolveOnGetEventHandler","$ON_GET","resolveOnChangingEventHandler","$ON_CHANGING","resolveOnChangeEventHandler","$ON_CHANGE","annotationMap","observable","createRecursiveProxy","effects","fn","createEffect","useComponent","ref","useLazyRef","getFC","factory"],"mappings":";;;;;;;;;AAqCA,SAASA,EAAWC,GAAc;AAC9B,SAAOA,EAAK,QAAQ,MAAMA,EAAK,CAAC,EAAE,aAAa;AACnD;AAEA,SAASC,EAAeC,GAAmB;AAEvC,SAAOA,EAAU,QAAQ,iCAAiC,EAAE;AAChE;AAEA,SAASC,EACLC,GACAC,GACAC,GACkB;AAElB,MAAIC,GACAC;AAEJ,EAAKJ,MACDA,IAAe,CAAA;AAGnB,MAAIK,IAAUL,EAAa;AAC3B,EAAKK,MACDA,IAAUC,EAA2B,CAAC,GAEtCD,IAAUR,EAAeQ,CAAO,IAI/BH,MACDA,IAAS,CAAA;AAGb,QAAMK,IAAOP,EAAa;AAC1B,MAAIQ,IAASR,EAAa;AAE1B,QAAMS,wBAAe,IAAA,GAEfC,IAAkBC,EAAK,MAClBC,EAAmBJ,GAAQ,CAACK,MAAY;AAC3C,IAAIA,GAAS,YAAY,SACrBA,EAAQ,WAAWV,EAAU;AAAA,EAErC,CAAC,CACJ;AAED,MAAIW,IAAY;AAAA,IACZ,GAAGd,EAAa;AAAA,EAAA;AAGpB,EAAKc,EAAU,oBACXA,EAAU,kBAAkB,IAAI,gBAAA;AAGpC,QAAMC,IAASC,EAAS,CAACC,MAA8B;AACnD,UAAMhB,IAAUiB,EAAA,GACVC,IAAWlB,EAAQ;AAQzB,QANAE,EAAU,WAAWgB,GAEhBX,MACDA,IAASP,EAAQ,SAGjB,CAACE,EAAU,IAAI;AACf,UAAIiB,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Params<Struct>) => Component<Struct>;
|
|
14
14
|
export type NavServiceStruct = Struct;
|
|
15
|
-
export declare const NavService: FC<ComponentParams<
|
|
15
|
+
export declare const NavService: React.FC<ComponentParams<Struct>>;
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=NavService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavService.d.ts","sourceRoot":"","sources":["../../../src/services/react/NavService.tsx"],"names":[],"mappings":"AAQA,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACR,SAAS,EAGT,eAAe,EACf,eAAe,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,KAAK,MAAM,GAAG,eAAe,CACzB,gBAAgB,EAChB;IACI,KAAK,EAAE,iBAAiB,GAAG;QACvB,OAAO,EAAE,UAAU,EAAE,CAAC;QACtB,MAAM,EAAE,SAAS,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE;QACN,OAAO,EAAE,kBAAkB,CACrB,cAAc,GACd,qBAAqB,GACrB,sBAAsB,GACtB,yBAAyB,CAC9B,CAAC;KACL,CAAC;CACL,CACJ,CAAC;AAIF,eAAO,MAAM,aAAa,GAAI,QAAQ,eAAe,CAAC,MAAM,CAAC,sBA+E5D,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACtC,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"NavService.d.ts","sourceRoot":"","sources":["../../../src/services/react/NavService.tsx"],"names":[],"mappings":"AAQA,OAAO,EACH,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACR,SAAS,EAGT,eAAe,EACf,eAAe,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,KAAK,MAAM,GAAG,eAAe,CACzB,gBAAgB,EAChB;IACI,KAAK,EAAE,iBAAiB,GAAG;QACvB,OAAO,EAAE,UAAU,EAAE,CAAC;QACtB,MAAM,EAAE,SAAS,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE;QACN,OAAO,EAAE,kBAAkB,CACrB,cAAc,GACd,qBAAqB,GACrB,sBAAsB,GACtB,yBAAyB,CAC9B,CAAC;KACL,CAAC;CACL,CACJ,CAAC;AAIF,eAAO,MAAM,aAAa,GAAI,QAAQ,eAAe,CAAC,MAAM,CAAC,sBA+E5D,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACtC,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavService.es.js","sources":["../../../src/services/react/NavService.tsx"],"sourcesContent":["import {\r\n To,\r\n useLocation,\r\n useNavigate,\r\n useNavigationType,\r\n useParams,\r\n useSearchParams,\r\n} from 'react-router-dom';\r\nimport {\r\n BaseAppMsgChannels,\r\n BaseAppMsgStruct,\r\n NavContext,\r\n NavRoutes,\r\n} from '@/appDomain/appContracts';\r\nimport type {\r\n Component,\r\n ComponentDef,\r\n ComponentModel,\r\n ComponentParams,\r\n ComponentStruct,\r\n} from '@/componentModel/contracts';\r\nimport { getFC, useComponent } from '@/componentModel/react';\r\nimport { PropsWithChildren } from 'react';\r\n\r\ntype Struct = ComponentStruct<\r\n BaseAppMsgStruct,\r\n {\r\n props: PropsWithChildren & {\r\n history: NavContext[];\r\n routes: NavRoutes;\r\n };\r\n msgScope: {\r\n provide: BaseAppMsgChannels<\r\n | 'APP.NAV.GOTO'\r\n | 'APP.NAV.CONTEXT.GET'\r\n | 'APP.NAV.HISTORY.READ'\r\n | 'APP.NAV.CONTEXT.CHANGED'\r\n >;\r\n };\r\n }\r\n>;\r\n\r\n// const store = new PersistentStore('history');\r\n\r\nexport const useNavService = (params: ComponentParams<Struct>) => {\r\n let c: Component<Struct>;\r\n let m: ComponentModel<Struct>;\r\n\r\n const navigate = useNavigate();\r\n\r\n const location = useLocation();\r\n const navType = useNavigationType();\r\n const nvaParams = useParams();\r\n const [searchParams] = useSearchParams();\r\n\r\n const def: ComponentDef<Struct> = {\r\n props: {\r\n history: [],\r\n routes: undefined,\r\n },\r\n msgBroker: {\r\n provide: {\r\n 'APP.NAV.GOTO': {\r\n in: {\r\n callback: async (msg) => {\r\n navigate(msg.payload as To);\r\n },\r\n },\r\n ex: {\r\n callback: async (msg) => {\r\n const route = msg.payload.route;\r\n navigate(m.routes[route].path(msg.payload.params));\r\n },\r\n },\r\n },\r\n 'APP.NAV.CONTEXT.GET': {\r\n in: {\r\n callback: (msg) => {\r\n return m.history[m.history.length - 1];\r\n },\r\n },\r\n },\r\n 'APP.NAV.HISTORY.READ': {\r\n in: {\r\n callback: (msg) => {\r\n return m.history[m.history.length - 1];\r\n },\r\n },\r\n },\r\n 'APP.NAV.CONTEXT.CHANGED': {},\r\n },\r\n },\r\n events: {\r\n onLayout: (c) => {\r\n const history = m.history;\r\n if (history) {\r\n const ctx = {\r\n location: location,\r\n searchParams: searchParams,\r\n params: nvaParams,\r\n navType: navType,\r\n };\r\n history.push(ctx);\r\n c.msgBus.send({\r\n channel: 'APP.NAV.CONTEXT.CHANGED',\r\n group: 'in',\r\n payload: ctx,\r\n });\r\n }\r\n },\r\n },\r\n view: () => {\r\n return null;\r\n },\r\n };\r\n\r\n c = useComponent(def, params);\r\n m = c.model;\r\n\r\n // deps\r\n // location, navType, params, searchParams\r\n\r\n return c;\r\n};\r\n\r\nexport type NavServiceStruct = Struct;\r\nexport const NavService = getFC(useNavService);\r\n"],"names":["useNavService","params","c","m","navigate","useNavigate","location","useLocation","navType","useNavigationType","nvaParams","useParams","searchParams","useSearchParams","useComponent","msg","route","history","ctx","Nav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AAAA,YACV,SAAS;AAAA,YACT,OAAO;AAAA,YACP,SAASgB;AAAA,UAAA,CACZ;AAAA,QACL;AAAA,MACJ;AAAA,IAAA;AAAA,IAEJ,MAAM,MACK;AAAA,EACX,GAGkBjB,CAAM,GAC5BE,IAAID,EAAE,OAKCA;AACX,GAGaiB,
|
|
1
|
+
{"version":3,"file":"NavService.es.js","sources":["../../../src/services/react/NavService.tsx"],"sourcesContent":["import {\r\n To,\r\n useLocation,\r\n useNavigate,\r\n useNavigationType,\r\n useParams,\r\n useSearchParams,\r\n} from 'react-router-dom';\r\nimport {\r\n BaseAppMsgChannels,\r\n BaseAppMsgStruct,\r\n NavContext,\r\n NavRoutes,\r\n} from '@/appDomain/appContracts';\r\nimport type {\r\n Component,\r\n ComponentDef,\r\n ComponentModel,\r\n ComponentParams,\r\n ComponentStruct,\r\n} from '@/componentModel/contracts';\r\nimport { getFC, useComponent } from '@/componentModel/react';\r\nimport { PropsWithChildren } from 'react';\r\n\r\ntype Struct = ComponentStruct<\r\n BaseAppMsgStruct,\r\n {\r\n props: PropsWithChildren & {\r\n history: NavContext[];\r\n routes: NavRoutes;\r\n };\r\n msgScope: {\r\n provide: BaseAppMsgChannels<\r\n | 'APP.NAV.GOTO'\r\n | 'APP.NAV.CONTEXT.GET'\r\n | 'APP.NAV.HISTORY.READ'\r\n | 'APP.NAV.CONTEXT.CHANGED'\r\n >;\r\n };\r\n }\r\n>;\r\n\r\n// const store = new PersistentStore('history');\r\n\r\nexport const useNavService = (params: ComponentParams<Struct>) => {\r\n let c: Component<Struct>;\r\n let m: ComponentModel<Struct>;\r\n\r\n const navigate = useNavigate();\r\n\r\n const location = useLocation();\r\n const navType = useNavigationType();\r\n const nvaParams = useParams();\r\n const [searchParams] = useSearchParams();\r\n\r\n const def: ComponentDef<Struct> = {\r\n props: {\r\n history: [],\r\n routes: undefined,\r\n },\r\n msgBroker: {\r\n provide: {\r\n 'APP.NAV.GOTO': {\r\n in: {\r\n callback: async (msg) => {\r\n navigate(msg.payload as To);\r\n },\r\n },\r\n ex: {\r\n callback: async (msg) => {\r\n const route = msg.payload.route;\r\n navigate(m.routes[route].path(msg.payload.params));\r\n },\r\n },\r\n },\r\n 'APP.NAV.CONTEXT.GET': {\r\n in: {\r\n callback: (msg) => {\r\n return m.history[m.history.length - 1];\r\n },\r\n },\r\n },\r\n 'APP.NAV.HISTORY.READ': {\r\n in: {\r\n callback: (msg) => {\r\n return m.history[m.history.length - 1];\r\n },\r\n },\r\n },\r\n 'APP.NAV.CONTEXT.CHANGED': {},\r\n },\r\n },\r\n events: {\r\n onLayout: (c) => {\r\n const history = m.history;\r\n if (history) {\r\n const ctx = {\r\n location: location,\r\n searchParams: searchParams,\r\n params: nvaParams,\r\n navType: navType,\r\n };\r\n history.push(ctx);\r\n c.msgBus.send({\r\n channel: 'APP.NAV.CONTEXT.CHANGED',\r\n group: 'in',\r\n payload: ctx,\r\n });\r\n }\r\n },\r\n },\r\n view: () => {\r\n return null;\r\n },\r\n };\r\n\r\n c = useComponent(def, params);\r\n m = c.model;\r\n\r\n // deps\r\n // location, navType, params, searchParams\r\n\r\n return c;\r\n};\r\n\r\nexport type NavServiceStruct = Struct;\r\nexport const NavService: React.FC<ComponentParams<Struct>> = getFC(useNavService);\r\n"],"names":["useNavService","params","c","m","navigate","useNavigate","location","useLocation","navType","useNavigationType","nvaParams","useParams","searchParams","useSearchParams","useComponent","msg","route","history","ctx","NavService","getFC"],"mappings":";;AA4CO,MAAMA,IAAgB,CAACC,MAAoC;AAC9D,MAAIC,GACAC;AAEJ,QAAMC,IAAWC,EAAA,GAEXC,IAAWC,EAAA,GACXC,IAAUC,EAAA,GACVC,IAAYC,EAAA,GACZ,CAACC,CAAY,IAAIC,EAAA;AA+DvB,SAAAX,IAAIY,EA7D8B;AAAA,IAC9B,OAAO;AAAA,MACH,SAAS,CAAA;AAAA,MACT,QAAQ;AAAA,IAAA;AAAA,IAEZ,WAAW;AAAA,MACP,SAAS;AAAA,QACL,gBAAgB;AAAA,UACZ,IAAI;AAAA,YACA,UAAU,OAAOC,MAAQ;AACrB,cAAAX,EAASW,EAAI,OAAa;AAAA,YAC9B;AAAA,UAAA;AAAA,UAEJ,IAAI;AAAA,YACA,UAAU,OAAOA,MAAQ;AACrB,oBAAMC,IAAQD,EAAI,QAAQ;AAC1B,cAAAX,EAASD,EAAE,OAAOa,CAAK,EAAE,KAAKD,EAAI,QAAQ,MAAM,CAAC;AAAA,YACrD;AAAA,UAAA;AAAA,QACJ;AAAA,QAEJ,uBAAuB;AAAA,UACnB,IAAI;AAAA,YACA,UAAU,CAACA,MACAZ,EAAE,QAAQA,EAAE,QAAQ,SAAS,CAAC;AAAA,UACzC;AAAA,QACJ;AAAA,QAEJ,wBAAwB;AAAA,UACpB,IAAI;AAAA,YACA,UAAU,CAACY,MACAZ,EAAE,QAAQA,EAAE,QAAQ,SAAS,CAAC;AAAA,UACzC;AAAA,QACJ;AAAA,QAEJ,2BAA2B,CAAA;AAAA,MAAC;AAAA,IAChC;AAAA,IAEJ,QAAQ;AAAA,MACJ,UAAU,CAACD,MAAM;AACb,cAAMe,IAAUd,EAAE;AAClB,YAAIc,GAAS;AACT,gBAAMC,IAAM;AAAA,YACR,UAAAZ;AAAA,YACA,cAAAM;AAAA,YACA,QAAQF;AAAA,YACR,SAAAF;AAAA,UAAA;AAEJ,UAAAS,EAAQ,KAAKC,CAAG,GAChBhB,EAAE,OAAO,KAAK;AAAA,YACV,SAAS;AAAA,YACT,OAAO;AAAA,YACP,SAASgB;AAAA,UAAA,CACZ;AAAA,QACL;AAAA,MACJ;AAAA,IAAA;AAAA,IAEJ,MAAM,MACK;AAAA,EACX,GAGkBjB,CAAM,GAC5BE,IAAID,EAAE,OAKCA;AACX,GAGaiB,IAAgDC,EAAMpB,CAAa;"}
|
|
@@ -11,6 +11,6 @@ type Struct = ComponentStruct<BaseAppMsgStruct, {
|
|
|
11
11
|
}>;
|
|
12
12
|
export declare const useStorageService: (params: ComponentParams<Struct>) => Component<Struct>;
|
|
13
13
|
export type StorageServiceStruct = Struct;
|
|
14
|
-
export declare const StorageService: FC<ComponentParams<
|
|
14
|
+
export declare const StorageService: React.FC<ComponentParams<Struct>>;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=StorageService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageService.d.ts","sourceRoot":"","sources":["../../../src/services/react/StorageService.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,eAAe,EACf,SAAS,EAGZ,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,KAAK,MAAM,GAAG,eAAe,CACzB,gBAAgB,EAChB;IACI,KAAK,EAAE,iBAAiB,GAAG;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,QAAQ,EAAE;QACN,OAAO,EAAE,kBAAkB,CAAC,eAAe,GAAG,eAAe,GAAG,kBAAkB,CAAC,CAAC;KACvF,CAAC;CACL,CACJ,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,eAAe,CAAC,MAAM,CAAC,sBA+DhE,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAC1C,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"StorageService.d.ts","sourceRoot":"","sources":["../../../src/services/react/StorageService.tsx"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,eAAe,EACf,SAAS,EAGZ,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,KAAK,MAAM,GAAG,eAAe,CACzB,gBAAgB,EAChB;IACI,KAAK,EAAE,iBAAiB,GAAG;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,QAAQ,EAAE;QACN,OAAO,EAAE,kBAAkB,CAAC,eAAe,GAAG,eAAe,GAAG,kBAAkB,CAAC,CAAC;KACvF,CAAC;CACL,CACJ,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,eAAe,CAAC,MAAM,CAAC,sBA+DhE,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAC1C,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAA4B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageService.es.js","sources":["../../../src/services/react/StorageService.tsx"],"sourcesContent":["import {\r\n ComponentParams,\r\n ComponentStruct,\r\n Component,\r\n ComponentModel,\r\n ComponentDef,\r\n} from '@/componentModel/contracts';\r\nimport { getFC, useComponent } from '@/componentModel/react';\r\nimport { PersistentStore } from '@actdim/utico/store/persistentStore';\r\nimport { BaseAppMsgChannels, BaseAppMsgStruct } from '@/appDomain/appContracts';\r\nimport { PropsWithChildren } from 'react';\r\n\r\ntype Struct = ComponentStruct<\r\n BaseAppMsgStruct,\r\n {\r\n props: PropsWithChildren & {\r\n storeName?: string;\r\n };\r\n msgScope: {\r\n provide: BaseAppMsgChannels<'APP.STORE.GET' | 'APP.STORE.SET' | 'APP.STORE.REMOVE'>;\r\n };\r\n }\r\n>;\r\n\r\nexport const useStorageService = (params: ComponentParams<Struct>) => {\r\n let c: Component<Struct>;\r\n let m: ComponentModel<Struct>;\r\n\r\n async function _updateStoreAsync() {\r\n store = await PersistentStore.open(m.storeName);\r\n }\r\n\r\n let store: PersistentStore;\r\n let ready: () => void;\r\n const init = new Promise<void>((res) => {\r\n ready = res;\r\n });\r\n\r\n const def: ComponentDef<Struct> = {\r\n props: {\r\n storeName: '',\r\n },\r\n msgBroker: {\r\n provide: {\r\n 'APP.STORE.GET': {\r\n in: {\r\n callback: async (msg) => {\r\n await init;\r\n const item = await store.get(msg.payload.key);\r\n return item?.data.value;\r\n },\r\n },\r\n },\r\n 'APP.STORE.SET': {\r\n in: {\r\n callback: async (msg) => {\r\n await init;\r\n await store.set(\r\n {\r\n key: msg.payload.key,\r\n },\r\n msg.payload.value,\r\n );\r\n },\r\n },\r\n },\r\n 'APP.STORE.REMOVE': {\r\n in: {\r\n callback: async (msg) => {\r\n await init;\r\n await store.delete(msg.payload.key);\r\n },\r\n },\r\n },\r\n },\r\n },\r\n events: {\r\n onChangeStoreName: () => {\r\n _updateStoreAsync();\r\n },\r\n },\r\n };\r\n\r\n c = useComponent(def, params);\r\n m = c.model;\r\n _updateStoreAsync().then(() => ready());\r\n return c;\r\n};\r\n\r\nexport type StorageServiceStruct = Struct;\r\nexport const StorageService = getFC(useStorageService);\r\n"],"names":["useStorageService","params","c","m","_updateStoreAsync","store","PersistentStore","ready","init","res","useComponent","msg","StorageService","getFC"],"mappings":";;AAwBO,MAAMA,IAAoB,CAACC,MAAoC;AAClE,MAAIC,GACAC;AAEJ,iBAAeC,IAAoB;AAC/B,IAAAC,IAAQ,MAAMC,EAAgB,KAAKH,EAAE,SAAS;AAAA,EAClD;AAEA,MAAIE,GACAE;AACJ,QAAMC,IAAO,IAAI,QAAc,CAACC,MAAQ;AACpC,IAAAF,IAAQE;AAAA,EACZ,CAAC;AA+CD,SAAAP,IAAIQ,EA7C8B;AAAA,IAC9B,OAAO;AAAA,MACH,WAAW;AAAA,IAAA;AAAA,IAEf,WAAW;AAAA,MACP,SAAS;AAAA,QACL,iBAAiB;AAAA,UACb,IAAI;AAAA,YACA,UAAU,OAAOC,OACb,MAAMH,IACO,MAAMH,EAAM,IAAIM,EAAI,QAAQ,GAAG,IAC/B,KAAK;AAAA,UACtB;AAAA,QACJ;AAAA,QAEJ,iBAAiB;AAAA,UACb,IAAI;AAAA,YACA,UAAU,OAAOA,MAAQ;AACrB,oBAAMH,GACN,MAAMH,EAAM;AAAA,gBACR;AAAA,kBACI,KAAKM,EAAI,QAAQ;AAAA,gBAAA;AAAA,gBAErBA,EAAI,QAAQ;AAAA,cAAA;AAAA,YAEpB;AAAA,UAAA;AAAA,QACJ;AAAA,QAEJ,oBAAoB;AAAA,UAChB,IAAI;AAAA,YACA,UAAU,OAAOA,MAAQ;AACrB,oBAAMH,GACN,MAAMH,EAAM,OAAOM,EAAI,QAAQ,GAAG;AAAA,YACtC;AAAA,UAAA;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,IAEJ,QAAQ;AAAA,MACJ,mBAAmB,MAAM;AACrB,QAAAP,EAAA;AAAA,MACJ;AAAA,IAAA;AAAA,EACJ,GAGkBH,CAAM,GAC5BE,IAAID,EAAE,OACNE,IAAoB,KAAK,MAAMG,GAAO,GAC/BL;AACX,GAGaU,
|
|
1
|
+
{"version":3,"file":"StorageService.es.js","sources":["../../../src/services/react/StorageService.tsx"],"sourcesContent":["import {\r\n ComponentParams,\r\n ComponentStruct,\r\n Component,\r\n ComponentModel,\r\n ComponentDef,\r\n} from '@/componentModel/contracts';\r\nimport { getFC, useComponent } from '@/componentModel/react';\r\nimport { PersistentStore } from '@actdim/utico/store/persistentStore';\r\nimport { BaseAppMsgChannels, BaseAppMsgStruct } from '@/appDomain/appContracts';\r\nimport { PropsWithChildren } from 'react';\r\n\r\ntype Struct = ComponentStruct<\r\n BaseAppMsgStruct,\r\n {\r\n props: PropsWithChildren & {\r\n storeName?: string;\r\n };\r\n msgScope: {\r\n provide: BaseAppMsgChannels<'APP.STORE.GET' | 'APP.STORE.SET' | 'APP.STORE.REMOVE'>;\r\n };\r\n }\r\n>;\r\n\r\nexport const useStorageService = (params: ComponentParams<Struct>) => {\r\n let c: Component<Struct>;\r\n let m: ComponentModel<Struct>;\r\n\r\n async function _updateStoreAsync() {\r\n store = await PersistentStore.open(m.storeName);\r\n }\r\n\r\n let store: PersistentStore;\r\n let ready: () => void;\r\n const init = new Promise<void>((res) => {\r\n ready = res;\r\n });\r\n\r\n const def: ComponentDef<Struct> = {\r\n props: {\r\n storeName: '',\r\n },\r\n msgBroker: {\r\n provide: {\r\n 'APP.STORE.GET': {\r\n in: {\r\n callback: async (msg) => {\r\n await init;\r\n const item = await store.get(msg.payload.key);\r\n return item?.data.value;\r\n },\r\n },\r\n },\r\n 'APP.STORE.SET': {\r\n in: {\r\n callback: async (msg) => {\r\n await init;\r\n await store.set(\r\n {\r\n key: msg.payload.key,\r\n },\r\n msg.payload.value,\r\n );\r\n },\r\n },\r\n },\r\n 'APP.STORE.REMOVE': {\r\n in: {\r\n callback: async (msg) => {\r\n await init;\r\n await store.delete(msg.payload.key);\r\n },\r\n },\r\n },\r\n },\r\n },\r\n events: {\r\n onChangeStoreName: () => {\r\n _updateStoreAsync();\r\n },\r\n },\r\n };\r\n\r\n c = useComponent(def, params);\r\n m = c.model;\r\n _updateStoreAsync().then(() => ready());\r\n return c;\r\n};\r\n\r\nexport type StorageServiceStruct = Struct;\r\nexport const StorageService: React.FC<ComponentParams<Struct>> = getFC(useStorageService);\r\n"],"names":["useStorageService","params","c","m","_updateStoreAsync","store","PersistentStore","ready","init","res","useComponent","msg","StorageService","getFC"],"mappings":";;AAwBO,MAAMA,IAAoB,CAACC,MAAoC;AAClE,MAAIC,GACAC;AAEJ,iBAAeC,IAAoB;AAC/B,IAAAC,IAAQ,MAAMC,EAAgB,KAAKH,EAAE,SAAS;AAAA,EAClD;AAEA,MAAIE,GACAE;AACJ,QAAMC,IAAO,IAAI,QAAc,CAACC,MAAQ;AACpC,IAAAF,IAAQE;AAAA,EACZ,CAAC;AA+CD,SAAAP,IAAIQ,EA7C8B;AAAA,IAC9B,OAAO;AAAA,MACH,WAAW;AAAA,IAAA;AAAA,IAEf,WAAW;AAAA,MACP,SAAS;AAAA,QACL,iBAAiB;AAAA,UACb,IAAI;AAAA,YACA,UAAU,OAAOC,OACb,MAAMH,IACO,MAAMH,EAAM,IAAIM,EAAI,QAAQ,GAAG,IAC/B,KAAK;AAAA,UACtB;AAAA,QACJ;AAAA,QAEJ,iBAAiB;AAAA,UACb,IAAI;AAAA,YACA,UAAU,OAAOA,MAAQ;AACrB,oBAAMH,GACN,MAAMH,EAAM;AAAA,gBACR;AAAA,kBACI,KAAKM,EAAI,QAAQ;AAAA,gBAAA;AAAA,gBAErBA,EAAI,QAAQ;AAAA,cAAA;AAAA,YAEpB;AAAA,UAAA;AAAA,QACJ;AAAA,QAEJ,oBAAoB;AAAA,UAChB,IAAI;AAAA,YACA,UAAU,OAAOA,MAAQ;AACrB,oBAAMH,GACN,MAAMH,EAAM,OAAOM,EAAI,QAAQ,GAAG;AAAA,YACtC;AAAA,UAAA;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,IAEJ,QAAQ;AAAA,MACJ,mBAAmB,MAAM;AACrB,QAAAP,EAAA;AAAA,MACJ;AAAA,IAAA;AAAA,EACJ,GAGkBH,CAAM,GAC5BE,IAAID,EAAE,OACNE,IAAoB,KAAK,MAAMG,GAAO,GAC/BL;AACX,GAGaU,IAAoDC,EAAMb,CAAiB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actdim/dynstruct",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
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",
|