@chamn/render 0.0.8 → 0.0.10
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/.eslintrc.js +1 -0
- package/CHANGELOG.md +10 -0
- package/{build.config.js → build.config.ts} +11 -2
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +172 -141
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/util/assetsLoader.d.ts +1 -1
- package/dist/util/index.d.ts +3 -0
- package/package.json +9 -7
- package/src/index.ts +1 -0
- package/src/util/assetsLoader.ts +6 -5
- package/src/util/index.ts +35 -0
package/dist/util/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContextType } from '../core/adapter';
|
|
2
2
|
import { StoreManager } from '../core/storeManager';
|
|
3
|
+
import { AssetPackage } from '@chamn/model';
|
|
3
4
|
export declare const isClass: (val: any) => boolean;
|
|
4
5
|
export declare function shouldConstruct(Component: Function): boolean;
|
|
5
6
|
export declare function canAcceptsRef(Comp: any): any;
|
|
@@ -15,3 +16,5 @@ export declare const convertCodeStringToFunction: (functionStr: string, $$contex
|
|
|
15
16
|
export declare const getObjFromArrayMap: (args: any[], argsName: string[]) => Record<any, any>;
|
|
16
17
|
export declare const formatSourceStylePropertyName: (style: Record<string, string>) => Record<string, string>;
|
|
17
18
|
export declare const getCSSTextValue: (cssObj: Record<string, string>) => string;
|
|
19
|
+
export declare const collectVariable: (assetPackages: AssetPackage[], win: Window) => Record<string, any>;
|
|
20
|
+
export declare const flatObject: (obj: Record<string, any>, level?: number) => {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chamn/render",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test": "jest"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@chamn/model": "0.0.
|
|
21
|
+
"@chamn/model": "0.0.10",
|
|
22
22
|
"cross-env": "^7.0.3",
|
|
23
23
|
"html-tag-names": "^2.0.1",
|
|
24
24
|
"loadjs": "4.3.0-rc1",
|
|
@@ -29,16 +29,18 @@
|
|
|
29
29
|
"zustand": "^4.1.5"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@chamn/build-script": "0.0.
|
|
33
|
-
"@chamn/demo-page": "0.0.
|
|
34
|
-
"@chamn/material": "0.0.
|
|
32
|
+
"@chamn/build-script": "0.0.10",
|
|
33
|
+
"@chamn/demo-page": "0.0.10",
|
|
34
|
+
"@chamn/material": "0.0.10",
|
|
35
35
|
"@types/loadjs": "^4.0.1",
|
|
36
36
|
"@types/lodash-es": "^4.17.6",
|
|
37
|
+
"@types/node": "^18.15.9",
|
|
37
38
|
"@types/react": "^18.0.15",
|
|
38
39
|
"@types/react-dom": "^18.0.6",
|
|
39
40
|
"antd": "^5.0.0",
|
|
40
|
-
"react-router-dom": "^6.6.1"
|
|
41
|
+
"react-router-dom": "^6.6.1",
|
|
42
|
+
"vite-plugin-dts": "^2.1.0"
|
|
41
43
|
},
|
|
42
44
|
"config": {},
|
|
43
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "89c4cfa2d5a7a8e60970e7317616e564ddd626e1"
|
|
44
46
|
}
|
package/src/index.ts
CHANGED
package/src/util/assetsLoader.ts
CHANGED
|
@@ -45,19 +45,20 @@ export class AssetLoader {
|
|
|
45
45
|
this._onSuccessList.forEach((el) => el());
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
// 在下一个事件循环执行,确保 onSuccess 和 onError 被注册
|
|
50
51
|
loadjs.ready(ids, {
|
|
51
52
|
success: () => {
|
|
52
53
|
this._onSuccessList.forEach((el) => el());
|
|
54
|
+
resolve('');
|
|
53
55
|
},
|
|
54
56
|
error: (depsNotFound) => {
|
|
55
57
|
this._onErrorList.forEach((el) => el(depsNotFound));
|
|
58
|
+
reject(depsNotFound);
|
|
56
59
|
},
|
|
57
60
|
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return this;
|
|
61
|
+
});
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
onSuccess(cb: () => void) {
|
package/src/util/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { capitalize } from 'lodash-es';
|
|
|
2
2
|
import { Component, createElement } from 'react';
|
|
3
3
|
import { ContextType } from '../core/adapter';
|
|
4
4
|
import { StoreManager } from '../core/storeManager';
|
|
5
|
+
import { AssetPackage } from '@chamn/model';
|
|
5
6
|
|
|
6
7
|
export const isClass = function (val: any) {
|
|
7
8
|
if (!val) {
|
|
@@ -127,3 +128,37 @@ export const getCSSTextValue = (cssObj: Record<string, string>) => {
|
|
|
127
128
|
});
|
|
128
129
|
return res;
|
|
129
130
|
};
|
|
131
|
+
|
|
132
|
+
export const collectVariable = (assetPackages: AssetPackage[], win: Window) => {
|
|
133
|
+
const res: Record<string, any> = {};
|
|
134
|
+
assetPackages.forEach((el) => {
|
|
135
|
+
if (el.globalName) {
|
|
136
|
+
const target = (win as any)[el.globalName];
|
|
137
|
+
if (target) {
|
|
138
|
+
res[el.globalName] = target;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return res;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export const flatObject = (obj: Record<string, any>, level = 1) => {
|
|
146
|
+
let count = 0;
|
|
147
|
+
let currentObj = obj;
|
|
148
|
+
let newObj: Record<string, any> = {};
|
|
149
|
+
let res = {};
|
|
150
|
+
while (count < level) {
|
|
151
|
+
Object.keys(currentObj).forEach((key) => {
|
|
152
|
+
newObj = {
|
|
153
|
+
...newObj,
|
|
154
|
+
...currentObj[key],
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
res = newObj;
|
|
158
|
+
currentObj = newObj;
|
|
159
|
+
newObj = {};
|
|
160
|
+
count += 1;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return res;
|
|
164
|
+
};
|