@chamn/render 0.0.7 → 0.0.9
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/CHANGELOG.md +12 -0
- package/{build.config.js → build.config.ts} +1 -1
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +242 -222
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/package.json +8 -6
- package/src/index.ts +1 -0
- package/src/util/assetsLoader.ts +6 -5
- package/src/util/index.ts +35 -0
- package/stats.html +6177 -0
- package/dist/commonComponent/index.d.ts +0 -12
- package/dist/const/index.d.ts +0 -2
- package/dist/core/ReactErrorBoundary.d.ts +0 -26
- package/dist/core/adapter.d.ts +0 -64
- package/dist/core/adapterReact.d.ts +0 -108
- package/dist/core/designReactRender.d.ts +0 -47
- package/dist/core/refManager.d.ts +0 -7
- package/dist/core/render.d.ts +0 -32
- package/dist/core/storeManager.d.ts +0 -11
- package/dist/core/type.d.ts +0 -9
- package/dist/index.d.ts +0 -5
- package/dist/util/assetsLoader.d.ts +0 -15
- package/dist/util/index.d.ts +0 -17
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.9",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"start": "build-script",
|
|
13
13
|
"build": "build-script --build",
|
|
14
|
+
"build:analyze": "build-script --build --analyze",
|
|
14
15
|
"build:w": "build-script --build --watch",
|
|
15
16
|
"lint": "eslint --ext .tsx,.ts src/",
|
|
16
17
|
"prettier": "prettier --write ./src",
|
|
17
18
|
"test": "jest"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@chamn/model": "0.0.
|
|
21
|
+
"@chamn/model": "0.0.9",
|
|
22
|
+
"cross-env": "^7.0.3",
|
|
21
23
|
"html-tag-names": "^2.0.1",
|
|
22
24
|
"loadjs": "4.3.0-rc1",
|
|
23
25
|
"lodash-es": "^4.17.21",
|
|
@@ -27,9 +29,9 @@
|
|
|
27
29
|
"zustand": "^4.1.5"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
|
-
"@chamn/build-script": "0.0.
|
|
31
|
-
"@chamn/demo-page": "0.0.
|
|
32
|
-
"@chamn/material": "0.0.
|
|
32
|
+
"@chamn/build-script": "0.0.9",
|
|
33
|
+
"@chamn/demo-page": "0.0.9",
|
|
34
|
+
"@chamn/material": "0.0.9",
|
|
33
35
|
"@types/loadjs": "^4.0.1",
|
|
34
36
|
"@types/lodash-es": "^4.17.6",
|
|
35
37
|
"@types/react": "^18.0.15",
|
|
@@ -38,5 +40,5 @@
|
|
|
38
40
|
"react-router-dom": "^6.6.1"
|
|
39
41
|
},
|
|
40
42
|
"config": {},
|
|
41
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "f073439ea704830a6f62146c916c2f0348c2e531"
|
|
42
44
|
}
|
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
|
+
};
|