@chamn/render 0.2.4 → 0.3.0

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.
@@ -6,7 +6,16 @@ export declare function shouldConstruct(Component: any): boolean;
6
6
  export declare function canAcceptsRef(Comp: any): any;
7
7
  export declare function compWrapper(Comp: any): any;
8
8
  export declare const runExpression: (expStr: string, context: any) => any;
9
- export declare const convertCodeStringToFunction: (functionStr: string, $$context: ContextType, storeManager: StoreManager) => (...args: any[]) => void;
9
+ /** 后续考虑是否需要做沙箱 */
10
+ export declare const convertCodeStringToFunction: (params: {
11
+ funcBody: string;
12
+ funcName: string;
13
+ nodeContext: ContextType;
14
+ storeManager: StoreManager;
15
+ /** 最近一个 API 的返回响应 */
16
+ $$response?: any;
17
+ actionVariableSpace?: Record<any, any>;
18
+ }) => (...args: any[]) => any;
10
19
  /**
11
20
  *
12
21
  * @param args 对象的值
@@ -23,3 +32,12 @@ export declare const getComponentsLibs: (libs: Record<string, any>, list: Compon
23
32
  export declare const getThirdLibs: (libs: Record<string, any>, list: LibMetaType[]) => Record<string, any>;
24
33
  export declare const getNodeCssClassName: (node: CNode | CRootNode) => string;
25
34
  export declare const findComponentByChainRefer: (componentReferPath: string, components: Record<string, any>) => () => string;
35
+ /**
36
+ * 优先访问 sourceObj 上的方法,找不到时访问 targetObj 上的方法
37
+ * @param sourceObj
38
+ * @param targetObj
39
+ * @returns
40
+ */
41
+ export declare const getInheritObj: (sourceObj: Record<any, any>, targetObj: Record<any, any>) => {
42
+ [x: string]: any;
43
+ };
@@ -0,0 +1,3 @@
1
+ import { Component } from 'react';
2
+ export declare function getInstance(key: any): any;
3
+ export declare function findDOMNode(componentOrElement: Component<any, any>): null | Element | Text;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "dist"
6
6
  ],
7
7
  "type": "module",
8
- "version": "0.2.4",
8
+ "version": "0.3.0",
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
@@ -26,21 +26,22 @@
26
26
  "react-dom": ">=16.9.0"
27
27
  },
28
28
  "dependencies": {
29
- "@chamn/model": "0.2.4",
29
+ "@chamn/model": "0.3.0",
30
30
  "html-tag-names": "^2.0.1",
31
31
  "loadjs": "4.3.0-rc1",
32
32
  "lodash-es": "^4.17.21",
33
+ "react-reconciler": "^0.31.0",
33
34
  "zustand": "^4.3.8"
34
35
  },
35
36
  "devDependencies": {
36
- "@chamn/build-script": "0.2.4",
37
- "@chamn/demo-page": "0.2.4",
37
+ "@chamn/build-script": "0.3.0",
38
+ "@chamn/demo-page": "0.3.0",
38
39
  "@types/loadjs": "^4.0.1",
39
40
  "@types/lodash-es": "^4.17.6",
40
41
  "@types/node": "~18.15.9",
41
42
  "@types/react": "^18.2.0",
42
43
  "@types/react-dom": "^18.0.6",
43
- "antd": "^5.0.0",
44
+ "antd": "^5.23.2",
44
45
  "cross-env": "^7.0.3",
45
46
  "react": "^18.2.0",
46
47
  "react-dom": "^18.2.0",
@@ -49,5 +50,5 @@
49
50
  "vite-plugin-dts": "^2.1.0"
50
51
  },
51
52
  "config": {},
52
- "gitHead": "8697b4a11fe1d0dc6f2d3c4226860d91a1740412"
53
+ "gitHead": "b8e6e48950cd7f8c67c1617cb277228748af5bd8"
53
54
  }
@@ -1,121 +0,0 @@
1
- import React from 'react';
2
- import { CNode, CPage, CRootNode } from '@chamn/model';
3
- import { AdapterOptionType, ContextType } from './adapter';
4
- import { StoreApi } from 'zustand/vanilla';
5
- import { StoreManager } from './storeManager';
6
- import { VariableManager } from './variableManager';
7
- export declare class DefineReactAdapter {
8
- renderMode: AdapterOptionType['renderMode'];
9
- components: AdapterOptionType['components'];
10
- storeManager: StoreManager;
11
- variableManager: VariableManager;
12
- runtimeComponentCache: Map<string, {
13
- component: any;
14
- }>;
15
- onGetRef?: AdapterOptionType['onGetRef'];
16
- onGetComponent: AdapterOptionType['onGetComponent'];
17
- onComponentMount: AdapterOptionType['onComponentMount'];
18
- onComponentDestroy: AdapterOptionType['onComponentDestroy'];
19
- /**
20
- * 处理 props 钩子, 可以统一拦截 node 的处理,并修改其值
21
- */
22
- processNodeConfigHook?: AdapterOptionType['processNodeConfigHook'];
23
- getComponent(currentNode: CNode | CRootNode): any;
24
- getContext(data?: ContextType, ctx?: ContextType | null): ContextType;
25
- pageRender(pageModel: CPage, { components, onGetRef, $$context, onGetComponent, onComponentMount, onComponentDestroy, renderMode, processNodeConfigHook, }: AdapterOptionType): string | React.ReactElement<any, string | React.JSXElementConstructor<any>>;
26
- transformProps(originalProps: Record<string, any> | undefined, { $$context: parentContext, }: {
27
- $$context: ContextType;
28
- }): Record<string, any>;
29
- collectSpecialProps(originalProps: Record<string, unknown> | undefined, isValidate: (val: unknown) => boolean): {
30
- keyPath: string[];
31
- val: any;
32
- }[];
33
- convertModelToComponent(originalComponent: any, nodeModel: CNode | CRootNode): {
34
- new (props: {
35
- $$context: ContextType;
36
- $$nodeModel: CNode | CRootNode;
37
- }): {
38
- _CONDITION: boolean;
39
- _DESIGN_BOX: boolean;
40
- _NODE_MODEL: CNode | CRootNode;
41
- _NODE_ID: string;
42
- UNIQUE_ID: string;
43
- targetComponentRef: React.MutableRefObject<any>;
44
- listenerHandle: (() => void)[];
45
- storeState: StoreApi<any>;
46
- storeListenDisposeList: (() => void)[];
47
- /** save dom and media css */
48
- domHeader: HTMLHeadElement | undefined;
49
- mediaStyleDomMap: Record<string, HTMLStyleElement>;
50
- /** 存储当前节点的一些变量和方法,不具有响应性 */
51
- variableSpace: {
52
- staticVar: Record<any, any>;
53
- methods: Record<any, (...args: any) => any>;
54
- };
55
- nodeName: any;
56
- updateState: (newState: any) => void;
57
- connectStore(): void;
58
- getStyleDomById: (id: string) => HTMLStyleElement;
59
- addMediaCSS: () => void;
60
- removeMediaCSS: () => void;
61
- componentDidMount(): void;
62
- rebuildNode: () => void;
63
- componentWillUnmount(): void;
64
- render(): React.ReactNode;
65
- context: unknown;
66
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{
67
- $$context: ContextType;
68
- $$nodeModel: CNode | CRootNode;
69
- }>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
70
- forceUpdate(callback?: (() => void) | undefined): void;
71
- readonly props: Readonly<{
72
- $$context: ContextType;
73
- $$nodeModel: CNode | CRootNode;
74
- }>;
75
- state: Readonly<{}>;
76
- refs: {
77
- [key: string]: React.ReactInstance;
78
- };
79
- shouldComponentUpdate?(nextProps: Readonly<{
80
- $$context: ContextType;
81
- $$nodeModel: CNode | CRootNode;
82
- }>, nextState: Readonly<{}>, nextContext: any): boolean;
83
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
84
- getSnapshotBeforeUpdate?(prevProps: Readonly<{
85
- $$context: ContextType;
86
- $$nodeModel: CNode | CRootNode;
87
- }>, prevState: Readonly<{}>): any;
88
- componentDidUpdate?(prevProps: Readonly<{
89
- $$context: ContextType;
90
- $$nodeModel: CNode | CRootNode;
91
- }>, prevState: Readonly<{}>, snapshot?: any): void;
92
- componentWillMount?(): void;
93
- UNSAFE_componentWillMount?(): void;
94
- componentWillReceiveProps?(nextProps: Readonly<{
95
- $$context: ContextType;
96
- $$nodeModel: CNode | CRootNode;
97
- }>, nextContext: any): void;
98
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{
99
- $$context: ContextType;
100
- $$nodeModel: CNode | CRootNode;
101
- }>, nextContext: any): void;
102
- componentWillUpdate?(nextProps: Readonly<{
103
- $$context: ContextType;
104
- $$nodeModel: CNode | CRootNode;
105
- }>, nextState: Readonly<{}>, nextContext: any): void;
106
- UNSAFE_componentWillUpdate?(nextProps: Readonly<{
107
- $$context: ContextType;
108
- $$nodeModel: CNode | CRootNode;
109
- }>, nextState: Readonly<{}>, nextContext: any): void;
110
- };
111
- __CP_TYPE__: string;
112
- contextType?: React.Context<any> | undefined;
113
- };
114
- buildComponent(node: CNode | CRootNode | string, { $$context, }: {
115
- $$context: ContextType;
116
- idx?: number;
117
- }): string | React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
118
- render(originalComponent: React.ComponentClass<any> | React.FunctionComponent | string, props?: Record<any, any>, ...children: React.ReactNode[]): string | React.ReactElement<any, string | React.JSXElementConstructor<any>>;
119
- clear(): void;
120
- }
121
- export declare const ReactAdapter: import("./adapter").AdapterType;