@aiot-toolkit/aiotpack 2.1.0-prender.1 → 2.1.0-prender.11
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/lib/afterCompile/ux/UxAfterCompile.d.ts +0 -4
- package/lib/afterCompile/ux/UxAfterCompile.js +10 -70
- package/lib/compiler/javascript/TemplateCompiler.d.ts +0 -10
- package/lib/compiler/javascript/TemplateCompiler.js +402 -81
- package/lib/compiler/javascript/ViteCompiler.d.ts +4 -0
- package/lib/compiler/javascript/ViteCompiler.js +398 -68
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +0 -17
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +3 -3
- package/lib/compiler/javascript/vela/utils/Jsc.js +87 -4
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +4 -1
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +23 -5
- package/lib/config/UxConfig.js +0 -3
- package/package.json +6 -6
- package/lib/prerender/PrerenderVM.d.ts +0 -86
- package/lib/prerender/PrerenderVM.js +0 -677
- package/lib/prerender/StyleSerializer.d.ts +0 -18
- package/lib/prerender/StyleSerializer.js +0 -92
- package/lib/prerender/TemplateSerializer.d.ts +0 -26
- package/lib/prerender/TemplateSerializer.js +0 -122
- package/lib/prerender/index.d.ts +0 -20
- package/lib/prerender/index.js +0 -519
- package/lib/prerender/interface/IPrerenderOption.d.ts +0 -15
- package/lib/prerender/interface/IPrerenderOption.js +0 -1
|
@@ -6,10 +6,6 @@ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavas
|
|
|
6
6
|
declare class UxAfterCompile {
|
|
7
7
|
static compileJavascript: FollowWork<IJavascriptCompileOption>;
|
|
8
8
|
static protobuf: FollowWork<IJavascriptCompileOption>;
|
|
9
|
-
/**
|
|
10
|
-
* 预渲染:在 VM 沙箱中执行编译后的模板函数,生成 .template.json + .css.json
|
|
11
|
-
*/
|
|
12
|
-
static prerender: FollowWork<IJavascriptCompileOption>;
|
|
13
9
|
static jsc: FollowWork<IJavascriptCompileOption>;
|
|
14
10
|
static toRpk: FollowWork<IJavascriptCompileOption>;
|
|
15
11
|
/**
|
|
@@ -19,7 +19,6 @@ var _ZipFileUtil = _interopRequireDefault(require("@aiot-toolkit/shared-utils/li
|
|
|
19
19
|
var _ImageIcu = _interopRequireDefault(require("../../compiler/tools/icu/ImageIcu"));
|
|
20
20
|
var _LiteCard = _interopRequireDefault(require("../../compiler/javascript/vela/utils/LiteCard"));
|
|
21
21
|
var _UxUtil = _interopRequireDefault(require("@aiot-toolkit/parser/lib/ux/utils/UxUtil"));
|
|
22
|
-
var _prerender = require("../../prerender");
|
|
23
22
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
23
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
25
24
|
|
|
@@ -45,11 +44,16 @@ class UxAfterCompile {
|
|
|
45
44
|
level: _sharedUtils.Loglevel.SUCCESS,
|
|
46
45
|
message: ['javascript compile success']
|
|
47
46
|
}]);
|
|
48
|
-
}).catch(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
}).catch(err => {
|
|
48
|
+
const errors = err?.errors;
|
|
49
|
+
const warnings = err?.warnings;
|
|
50
|
+
if (!errors?.length && !warnings?.length) {
|
|
51
|
+
onLog?.([{
|
|
52
|
+
level: _sharedUtils.Loglevel.THROW,
|
|
53
|
+
message: [`javascript compile failed: ${err?.message ?? err}`]
|
|
54
|
+
}]);
|
|
55
|
+
throw err instanceof Error ? err : new Error(String(err));
|
|
56
|
+
}
|
|
53
57
|
const errorLength = errors?.length || 0;
|
|
54
58
|
const messages = [`webpack error:\r\n`];
|
|
55
59
|
if (errors?.length) {
|
|
@@ -90,70 +94,6 @@ class UxAfterCompile {
|
|
|
90
94
|
BinaryPlugin.createBinFiles();
|
|
91
95
|
}
|
|
92
96
|
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 预渲染:在 VM 沙箱中执行编译后的模板函数,生成 .template.json + .css.json
|
|
96
|
-
*/
|
|
97
|
-
static prerender = async params => {
|
|
98
|
-
const {
|
|
99
|
-
compilerOption,
|
|
100
|
-
onLog,
|
|
101
|
-
compilation
|
|
102
|
-
} = params;
|
|
103
|
-
if (!compilerOption || compilerOption.enablePrerender === false) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// In watch mode, clear prerender caches for changed pages
|
|
108
|
-
if (compilation && compilation.trigger !== _FileLaneTriggerType.default.START) {
|
|
109
|
-
const {
|
|
110
|
-
sourceRoot
|
|
111
|
-
} = compilerOption;
|
|
112
|
-
const srcPath = _path.default.join(compilerOption.projectPath, sourceRoot);
|
|
113
|
-
const changedPages = (compilation.changedFiles || []).filter(f => compilation.entries?.includes(f)).map(f => {
|
|
114
|
-
const rel = _path.default.relative(srcPath, f).replace(/\\/g, '/');
|
|
115
|
-
return rel.replace(/\.[^.]+$/, '');
|
|
116
|
-
});
|
|
117
|
-
(0, _prerender.watchChange)(changedPages.length > 0 ? changedPages : undefined);
|
|
118
|
-
}
|
|
119
|
-
const {
|
|
120
|
-
projectPath,
|
|
121
|
-
outputPath,
|
|
122
|
-
sourceRoot
|
|
123
|
-
} = compilerOption;
|
|
124
|
-
const buildPath = _path.default.join(projectPath, outputPath);
|
|
125
|
-
const manifestPath = _path.default.join(projectPath, sourceRoot, 'manifest.json');
|
|
126
|
-
if (!_fsExtra.default.existsSync(manifestPath)) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const excludeList = compilerOption.prerenderExclude || [];
|
|
130
|
-
const manifest = _fsExtra.default.readJSONSync(manifestPath);
|
|
131
|
-
const pages = Object.keys(manifest.router?.pages || {}).filter(pageName => {
|
|
132
|
-
if (excludeList.some(pattern => pageName.startsWith(pattern))) {
|
|
133
|
-
onLog?.([{
|
|
134
|
-
level: _sharedUtils.Loglevel.INFO,
|
|
135
|
-
message: [`prerender: skip excluded ${pageName}`]
|
|
136
|
-
}]);
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
}).map(pageName => {
|
|
141
|
-
const pageConf = manifest.router.pages[pageName];
|
|
142
|
-
const component = pageConf.component || 'index';
|
|
143
|
-
return `${pageName}/${component}`;
|
|
144
|
-
});
|
|
145
|
-
if (!pages.length) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const deviceTypes = manifest.deviceTypeList?.length ? manifest.deviceTypeList : ['default'];
|
|
149
|
-
await (0, _prerender.prerender)({
|
|
150
|
-
buildPath,
|
|
151
|
-
sourcePath: _path.default.join(projectPath, sourceRoot),
|
|
152
|
-
pages,
|
|
153
|
-
prerenderSubComp: compilerOption.prerenderSubComp !== false,
|
|
154
|
-
deviceTypes
|
|
155
|
-
}, onLog);
|
|
156
|
-
};
|
|
157
97
|
static jsc = async params => {
|
|
158
98
|
const {
|
|
159
99
|
context,
|
|
@@ -12,16 +12,6 @@ declare function uxToTemplateJson(templateNode: any, styleObjectId?: number, sty
|
|
|
12
12
|
* `screen and ` is preserved; `not` / `only` are preserved as-is.
|
|
13
13
|
*/
|
|
14
14
|
declare function normalizeMediaQuery(condition: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Parse compiled $app_style$ array. Each rule is either:
|
|
17
|
-
* [selectors, props] — base rule
|
|
18
|
-
* [{condition: "<media-query>"}, selectors, props] — conditional rule (@media or @import with query)
|
|
19
|
-
*
|
|
20
|
-
* Returns a flat map: selectors → props for base rules, plus
|
|
21
|
-
* `"@media <normalizedConditionText>"` keys whose values are the per-condition
|
|
22
|
-
* `{selector: props}` map. The condition text is normalized to Level 3 so
|
|
23
|
-
* runtime only needs a Level-3 matcher.
|
|
24
|
-
*/
|
|
25
15
|
declare function parseStyleArray(code: string): Record<string, any>;
|
|
26
16
|
/** Convert CSS text to css.json format */
|
|
27
17
|
export { uxToTemplateJson, parseStyleArray, normalizeMediaQuery };
|