@aiot-toolkit/aiotpack 2.0.5-beta.1 → 2.0.5-beta.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.
@@ -45,8 +45,6 @@ class WrapPlugin {
45
45
  var $app_require$ = global.$app_require$ || org_app_require
46
46
 
47
47
  ${enableE2e ? `globalThis = undefined; \n global = typeof window === "undefined" ? global.__proto__ : window;` : ''}
48
- // 转换动态 style 的函数
49
- ${isApp ? this.translateStyleFunc() : ''}
50
48
  var ${createFuncnName} = function() {
51
49
  return `, source, `
52
50
  }
@@ -6,6 +6,6 @@ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavas
6
6
  declare class JsLoader implements ILoader {
7
7
  context: IFileLaneContext;
8
8
  compilerOption: IJavascriptCompileOption;
9
- parser(files: IFileParam<any>[]): IFileParam<any>[] | Promise<IFileParam<any>[]>;
9
+ parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
10
10
  }
11
11
  export default JsLoader;
@@ -10,29 +10,32 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
10
10
  * JsLoader
11
11
  */
12
12
  class JsLoader {
13
- parser(files) {
13
+ async parser(files) {
14
14
  const onLog = () => {};
15
- return files.map(item => {
15
+ const result = [];
16
+ for (const item of files) {
16
17
  if (!item.content) {
17
- return {
18
+ result.push({
18
19
  path: item.path,
19
20
  content: item.content
21
+ });
22
+ } else {
23
+ const options = {
24
+ filePath: item.path,
25
+ projectPath: this.context.projectPath,
26
+ content: item.content.toString(),
27
+ projectType: _sharedUtils.ProjectType.getProjectType(this.context.projectPath),
28
+ onLog
20
29
  };
30
+ result.push({
31
+ path: item.path,
32
+ content: (await new _parser.ScriptToTypescript(options, this.compilerOption, this.context).translate({
33
+ content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
34
+ }, [])).targetTree.getFullText()
35
+ });
21
36
  }
22
- const options = {
23
- filePath: item.path,
24
- projectPath: this.context.projectPath,
25
- content: item.content.toString(),
26
- projectType: _sharedUtils.ProjectType.getProjectType(this.context.projectPath),
27
- onLog
28
- };
29
- return {
30
- path: item.path,
31
- content: new _parser.ScriptToTypescript(options, this.compilerOption, this.context).translate({
32
- content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
33
- }, []).targetTree.getFullText()
34
- };
35
- });
37
+ }
38
+ return result;
36
39
  }
37
40
  }
38
41
  var _default = exports.default = JsLoader;
@@ -115,11 +115,38 @@ class UxLoaderUtils {
115
115
  // 区分app.ux和一般ux
116
116
  // app.ux解析结果中加上manifest.json的内容
117
117
  const manifestJson = `require('./manifest.json')`;
118
+ function translateStyleFunc() {
119
+ return `
120
+ var $translateStyle$ = function (value) {
121
+ if (typeof value === 'string') {
122
+ return Object.fromEntries(
123
+ value
124
+ .split(';')
125
+ .filter((item) => Boolean(item && item.trim()))
126
+ .map((item) => {
127
+ const matchs = item.match(/([^:]+):(.*)/);
128
+ if (matchs && matchs.length > 2) {
129
+ return [
130
+ matchs[1]
131
+ .trim()
132
+ .replace(/-([a-z])/g, (_, match) => match.toUpperCase()),
133
+ matchs[2].trim(),
134
+ ];
135
+ }
136
+ return [];
137
+ })
138
+ );
139
+ }
140
+ return value;
141
+ };
142
+ global.$translateStyle$ = $translateStyle$
143
+ `;
144
+ }
118
145
  const integrateFunction = (appImport, appStyleTree, appTemplateTree, appScriptTree) => {
119
146
  const scriptCode = appScriptTree.getText();
120
147
  const hasScript = Boolean(scriptCode) && scriptCode !== '""';
121
148
  // script代码放在第三个位置不能变化,影响更新source map
122
- return isAppUx ? [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? `var $app_script$ = ${UxLoaderUtils.wrapScript(false, appScriptTree)}` : '', hasScript ? `$app_script$({}, $app_exports$, $app_require$);` : `$app_exports$.default = {}`, `$app_exports$.default.style = $app_style$;`, `$app_exports$.default.manifest = ${manifestJson}`] : [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? `var $app_script$ = ${UxLoaderUtils.wrapScript(isPageUx, appScriptTree)}` : '', `var $app_template$ = ${UxLoaderUtils.wrapTempalte(appTemplateTree, file, compilerOption)}`, `${UxLoaderUtils.getReturnType(isPageUx)} function ($app_exports$) {`, hasScript ? `$app_script$({}, $app_exports$, $app_require$);` : `$app_exports$.default = {}`, `$app_exports$.default.template = $app_template$;`, `$app_exports$.default.style = $app_style$;`, `}`];
149
+ return isAppUx ? [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? `var $app_script$ = ${UxLoaderUtils.wrapScript(false, appScriptTree)}` : '', hasScript ? `$app_script$({}, $app_exports$, $app_require$);` : `$app_exports$.default = {}`, `$app_exports$.default.style = $app_style$;`, `$app_exports$.default.manifest = ${manifestJson}`, translateStyleFunc()] : [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? `var $app_script$ = ${UxLoaderUtils.wrapScript(isPageUx, appScriptTree)}` : '', `var $app_template$ = ${UxLoaderUtils.wrapTempalte(appTemplateTree, file, compilerOption)}`, `${UxLoaderUtils.getReturnType(isPageUx)} function ($app_exports$) {`, hasScript ? `$app_script$({}, $app_exports$, $app_require$);` : `$app_exports$.default = {}`, `$app_exports$.default.template = $app_template$;`, `$app_exports$.default.style = $app_style$;`, `}`];
123
150
  };
124
151
  const {
125
152
  targetTree,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/aiotpack",
3
- "version": "2.0.5-beta.1",
3
+ "version": "2.0.5-beta.10",
4
4
  "description": "The process tool for packaging aiot projects.",
5
5
  "keywords": [
6
6
  "aiotpack"
@@ -19,16 +19,16 @@
19
19
  "test": "node ./__tests__/aiotpack.test.js"
20
20
  },
21
21
  "dependencies": {
22
- "@aiot-toolkit/generator": "2.0.5-beta.1",
23
- "@aiot-toolkit/parser": "2.0.5-beta.1",
24
- "@aiot-toolkit/shared-utils": "2.0.5-beta.1",
22
+ "@aiot-toolkit/generator": "2.0.5-beta.10",
23
+ "@aiot-toolkit/parser": "2.0.5-beta.10",
24
+ "@aiot-toolkit/shared-utils": "2.0.5-beta.10",
25
25
  "@hap-toolkit/aaptjs": "^2.0.0",
26
26
  "@rspack/core": "^1.1.8",
27
- "aiot-parse5": "^1.0.0",
27
+ "aiot-parse5": "^1.0.2",
28
28
  "archiver": "^7.0.1",
29
29
  "babel-loader": "^9.1.3",
30
30
  "fast-glob": "^3.3.2",
31
- "file-lane": "2.0.5-beta.1",
31
+ "file-lane": "2.0.5-beta.10",
32
32
  "file-loader": "^6.2.0",
33
33
  "fs-extra": "^11.2.0",
34
34
  "jsrsasign": "^11.1.0",
@@ -46,5 +46,5 @@
46
46
  "@types/jsrsasign": "^10.5.12",
47
47
  "@types/webpack-sources": "^3.2.3"
48
48
  },
49
- "gitHead": "44f8c6ee763bc01bd53c655b93e09c698057fc3e"
49
+ "gitHead": "b2403dbd071d5a6ae33b27f49c6f47ba95861477"
50
50
  }