diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 1b45979..0000000 --- a/README.en.md +++ /dev/null @@ -1,82 +0,0 @@ -# developtools_ace-ets2bundle - -#### Description -Provide declarative paradigm syntax compilation conversion, syntax verification, rich and friendly syntax error prompting capabilities. - -#### Software Architecture - -* compiler/src: source code -* test: unit test file -* .eslintrc: eslint configure -* babel.config.js: babel configure -* main.js: source code -* package.json: define what libraries will be installed into node_modules when you run `npm install` -* tsconfig.json: the compiler options required to compile the project -* webpack.config.js: webpack configuration information - -#### Prerequisites - -``` -> npm -v - 6.14.8 -> node -v - v12.18.3 -``` -Your `npm` and `node` should be of a later version. You can upgrade them to the **latest stable version**. - -#### Installing - -Enter the root directory of the compiler: -``` -npm config set registry http://registry.npm.taobao.org -npm config set strict-ssl false -npm cache clean -f -npm install -``` - -#### Quick Start - -Enter the root directory of the compiler: -``` -npm run build -npm run compile -``` -The `sample` project will be compiled. The output is in the `sample/build` directory. - -#### Create a new project - -Enter the root directory of the compiler: -``` -npm run create [projectName] -``` - -**Note**: If `projectName` is empty, create the `HelloAce` project by default. -For example, use the following line to create a project named `foo`: -``` -$ npm run create foo -``` -The directory structure of project `foo`: -- foo - - pages - - index.ets - - app.ets - - manifest.json - -#### Create a new page - -For example, create a file `bar.ets` in the `pages` directory. And then add the following lines to `"pages"` field in `manifest.json`: -``` - "pages": [ - "pages/index", - "pages/bar" - ] -``` - -#### Compile a project - -Enter the root directory of the compiler: -``` -$ npm run build -$ npm run compile [projectName] -``` -**Note**: If `projectName` is empty, compile the `sample` project by default. In the project root directory, the compilation result is in the `build` directory. diff --git a/README.md b/README.md index f7b74ee..c78c37b 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,20 @@ # developtools_ace-ets2bundle -#### 介绍 +#### Description +Provide declarative paradigm syntax compilation conversion, syntax verification, rich and friendly syntax error prompting capabilities. -提供声明式范式的语法编译转换,语法验证,丰富友好的语法报错提示能力。 +#### Software Architecture -#### 软件架构 +* compiler/src: source code +* test: unit test file +* .eslintrc: eslint configure +* babel.config.js: babel configure +* main.js: source code +* package.json: define what libraries will be installed into node_modules when you run `npm install` +* tsconfig.json: the compiler options required to compile the project +* webpack.config.js: webpack configuration information -* compiler/src: 编译转换工具源码 -* test: 单元测试用例 -* .eslintrc: eslint配置规则 -* babel.config.js: babel配置信息 -* main.js: 编译转换工具源码 -* package.json: 安装依赖软件版本信息 -* tsconfig.json: 编译工程配置信息 -* webpack.config.js: 打包工具脚本配置信息 - -#### 环境准备 +#### Prerequisites ``` > npm -v @@ -23,11 +22,11 @@ > node -v v12.18.3 ``` -请安装最新稳定的node版本。 +Please install the **latest stable version**. -#### 安装 +#### Installing -进入到compiler目录 +Enter the root directory of the compiler: ``` npm config set registry http://registry.npm.taobao.org npm config set strict-ssl false @@ -35,37 +34,37 @@ npm cache clean -f npm install ``` -#### 快速开始 +#### Quick Start -进入到compiler目录 +Enter the root directory of the compiler: ``` npm run build npm run compile ``` -上述命令编译了compiler目录下的`sample`工程,编译结果在`sample\build`目录。 +The `sample` project will be compiled. The output is in the `sample/build` directory. -#### 创建一个新工程 +#### Creating a Project -进入到compiler目录 +Enter the root directory of the compiler: ``` npm run create [projectName] ``` -**Note**: 如果`projectName`未指定,`HelloAce`为默认的工程名。 -例如创建一个`foo`工程: +**Note**: If `projectName` is not specified, the `HelloAce` project will be compiled. +For example, use the following line to create a project named `foo`: ``` $ npm run create foo ``` -工程`foo`的目录结构: +The directory structure of project `foo`: - foo - pages - index.ets - app.ets - manifest.json -#### 创建一个新的页面 +#### Creating a Page -例如在`pages`目录创建一个`bar.ets`页面,需要在manifest.json文件的`pages`新增一行,如下所示: +For example, create a file `bar.ets` in the `pages` directory. And then add the following lines to `"pages"` field in `manifest.json`: ``` "pages": [ "pages/index", @@ -73,11 +72,11 @@ $ npm run create foo ] ``` -#### 编译工程 +#### Compiling a Project -进入到compiler目录 +Enter the root directory of the compiler: ``` $ npm run build $ npm run compile [projectName] ``` -**Note**: 如果`projectName`未指定,默认编译`sample`工程,编译结果在`sample\build`目录。 +**Note**: If `projectName` is not specified, the `sample` project will be compiled. In the project root directory, the compilation result is in the `build` directory. diff --git a/README_zh.md b/README_zh.md new file mode 100644 index 0000000..f7b74ee --- /dev/null +++ b/README_zh.md @@ -0,0 +1,83 @@ +# developtools_ace-ets2bundle + +#### 介绍 + +提供声明式范式的语法编译转换,语法验证,丰富友好的语法报错提示能力。 + +#### 软件架构 + +* compiler/src: 编译转换工具源码 +* test: 单元测试用例 +* .eslintrc: eslint配置规则 +* babel.config.js: babel配置信息 +* main.js: 编译转换工具源码 +* package.json: 安装依赖软件版本信息 +* tsconfig.json: 编译工程配置信息 +* webpack.config.js: 打包工具脚本配置信息 + +#### 环境准备 + +``` +> npm -v + 6.14.8 +> node -v + v12.18.3 +``` +请安装最新稳定的node版本。 + +#### 安装 + +进入到compiler目录 +``` +npm config set registry http://registry.npm.taobao.org +npm config set strict-ssl false +npm cache clean -f +npm install +``` + +#### 快速开始 + +进入到compiler目录 +``` +npm run build +npm run compile +``` +上述命令编译了compiler目录下的`sample`工程,编译结果在`sample\build`目录。 + +#### 创建一个新工程 + +进入到compiler目录 +``` +npm run create [projectName] +``` + +**Note**: 如果`projectName`未指定,`HelloAce`为默认的工程名。 +例如创建一个`foo`工程: +``` +$ npm run create foo +``` +工程`foo`的目录结构: +- foo + - pages + - index.ets + - app.ets + - manifest.json + +#### 创建一个新的页面 + +例如在`pages`目录创建一个`bar.ets`页面,需要在manifest.json文件的`pages`新增一行,如下所示: +``` + "pages": [ + "pages/index", + "pages/bar" + ] +``` + +#### 编译工程 + +进入到compiler目录 +``` +$ npm run build +$ npm run compile [projectName] +``` +**Note**: 如果`projectName`未指定,默认编译`sample`工程,编译结果在`sample\build`目录。 diff --git a/compiler/sample/manifest.json b/compiler/sample/manifest.json index 8895c32..ac9b672 100644 --- a/compiler/sample/manifest.json +++ b/compiler/sample/manifest.json @@ -5,7 +5,7 @@ "versionCode": 1, "minPlatformVersion": "1.0.1", "pages": [ - "pages/todo", + "pages/willdo", "pages/index", "pages/home", "pages/home_preview", diff --git a/compiler/sample/pages/testcases/showcaseCovid19.ets b/compiler/sample/pages/testcases/showcaseCovid19.ets index f5568df..529e5ba 100644 --- a/compiler/sample/pages/testcases/showcaseCovid19.ets +++ b/compiler/sample/pages/testcases/showcaseCovid19.ets @@ -729,7 +729,7 @@ struct FiltersView { let newValue: boolean = (data.length > 0) ? !data[0].show : false; data.forEach((c: CountryVM) => c.show = newValue); - // FIXME: hack to make this vew render and take chnaged 'show' CountryVM instances into account + // hack to make this vew render and take chnaged 'show' CountryVM instances into account // this need @Observed CountryVM / createdObservableObject to work efficiently. this.countryHasChanged = !this.countryHasChanged } diff --git a/compiler/sample/pages/testcases/stateArrayReverse.ets b/compiler/sample/pages/testcases/stateArrayReverse.ets index e63d893..8824e48 100644 --- a/compiler/sample/pages/testcases/stateArrayReverse.ets +++ b/compiler/sample/pages/testcases/stateArrayReverse.ets @@ -26,7 +26,7 @@ (in SwiftUI). Therefore, the app needs to provide a unique id for each array item. We do so by making each array item an object with a unique id. - TODO this id should be used as the 'key' argument when creating a Text. + this id should be used as the 'key' argument when creating a Text. */ diff --git a/compiler/sample/pages/todo.ets b/compiler/sample/pages/willdo.ets similarity index 95% rename from compiler/sample/pages/todo.ets rename to compiler/sample/pages/willdo.ets index 448a8e1..40e8c9a 100644 --- a/compiler/sample/pages/todo.ets +++ b/compiler/sample/pages/willdo.ets @@ -16,12 +16,12 @@ /** * ACE @ Web Helsinki * - * eDSL version of TODO application + * eDSL version of this application * * ( unverified due to lack of working eDSL transpiler ) * * For comparison, the plain JS version of this app that works with ACE-Diff can be found here - * https://rnd-gitlab-eu-c.huawei.com/zidanehbs/ace/ace/-/blob/fin-hmf-dev-ace-diff-clean/samples/common/res/hi_topapp/assets/js/default/acediff/todoListForEach.js + * * This is the ouput the eDSL transpiler should generate. */ let tasks: Array = [ @@ -159,7 +159,7 @@ struct RootView { Text((item.id + 1) + " : " + item.label) }, - /* second parameter is a arrow function that takes an item as input + /* second parameter is an arrow function that takes an item as input and returns a persistent nique id (or key ) */ item => item.id ) // ForEach diff --git a/compiler/src/process_component_member.ts b/compiler/src/process_component_member.ts index 2b69384..6abc3a1 100644 --- a/compiler/src/process_component_member.ts +++ b/compiler/src/process_component_member.ts @@ -856,7 +856,7 @@ function validateForbiddenUseStateType(propertyName: ts.Identifier, decorator: s function validateDuplicateDecorator(decorator: ts.Decorator, log: LogInfo[]): void { log.push({ type: LogType.ERROR, - message: `The decorator '${decorator.getText()}' cannot have the same name as the build-in ` + + message: `The decorator '${decorator.getText()}' cannot have the same name as the built-in ` + `style attribute '${decorator.getText().replace('@', '')}'.`, pos: decorator.getStart() }); diff --git a/compiler/src/process_import.ts b/compiler/src/process_import.ts index 6327b5c..eecade8 100644 --- a/compiler/src/process_import.ts +++ b/compiler/src/process_import.ts @@ -162,13 +162,13 @@ function addDependencies(node: ts.ClassDeclaration, defaultNameFromParent: strin if (defaultNameFromParent && node.modifiers && node.modifiers.length >= 2 && node.modifiers[0] && node.modifiers[1] && node.modifiers[0].kind === ts.SyntaxKind.ExportKeyword && node.modifiers[1].kind === ts.SyntaxKind.DefaultKeyword) { - setDependencies(defaultNameFromParent, ComponentSet.links, ComponentSet.propertys, + setDependencies(defaultNameFromParent, ComponentSet.links, ComponentSet.properties, ComponentSet.props); } else if (asNameFromParent.has(componentName)) { - setDependencies(asNameFromParent.get(componentName), ComponentSet.links, ComponentSet.propertys, + setDependencies(asNameFromParent.get(componentName), ComponentSet.links, ComponentSet.properties, ComponentSet.props); } else { - setDependencies(componentName, ComponentSet.links, ComponentSet.propertys, ComponentSet.props); + setDependencies(componentName, ComponentSet.links, ComponentSet.properties, ComponentSet.props); } } diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 7af185c..9ce9a10 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -85,13 +85,13 @@ export function addLog(type: LogType, message: string, pos: number, log: LogInfo } export function getMessage(fileName: string, info: LogInfo): string { - let messsage: string; + let message: string; if (info.line && info.column) { - messsage = `BUILD${info.type} File: ${fileName}:${info.line}:${info.column}\n ${info.message}`; + message = `BUILD${info.type} File: ${fileName}:${info.line}:${info.column}\n ${info.message}`; } else { - messsage = `BUILD${info.type} File: ${fileName}\n ${info.message}`; + message = `BUILD${info.type} File: ${fileName}\n ${info.message}`; } - return messsage; + return message; } class ComponentInfo { @@ -222,4 +222,4 @@ export function toHashData(path: string) { const hash = createHash('sha256'); hash.update(content); return hash.digest('hex'); -} +} diff --git a/compiler/src/validate_ui_syntax.ts b/compiler/src/validate_ui_syntax.ts index 47bff67..949d88c 100644 --- a/compiler/src/validate_ui_syntax.ts +++ b/compiler/src/validate_ui_syntax.ts @@ -73,7 +73,7 @@ export interface ComponentCollection { } export interface IComponentSet { - propertys: Set; + properties: Set; regulars: Set; states: Set; links: Set; @@ -609,7 +609,7 @@ function isNonspecificChildIfStatement(node: ts.Node, specificChildSet: Set = new Set(); + const properties: Set = new Set(); const states: Set = new Set(); const links: Set = new Set(); const props: Set = new Set(); @@ -632,15 +632,15 @@ export function getComponentSet(node: ts.StructDeclaration): IComponentSet { const provides: Set = new Set(); const consumes: Set = new Set(); const objectLinks: Set = new Set(); - traversalComponentProps(node, propertys, regulars, states, links, props, storageProps, + traversalComponentProps(node, properties, regulars, states, links, props, storageProps, storageLinks, provides, consumes, objectLinks); return { - propertys, regulars, states, links, props, storageProps, storageLinks, provides, + properties, regulars, states, links, props, storageProps, storageLinks, provides, consumes, objectLinks }; } -function traversalComponentProps(node: ts.StructDeclaration, propertys: Set, +function traversalComponentProps(node: ts.StructDeclaration, properties: Set, regulars: Set, states: Set, links: Set, props: Set, storageProps: Set, storageLinks: Set, provides: Set, consumes: Set, objectLinks: Set): void { @@ -650,7 +650,7 @@ function traversalComponentProps(node: ts.StructDeclaration, propertys: Set { if (ts.isPropertyDeclaration(item) && ts.isIdentifier(item.name)) { const propertyName: string = item.name.getText(); - propertys.add(propertyName); + properties.add(propertyName); if (!item.decorators || !item.decorators.length) { regulars.add(propertyName); } else { @@ -735,10 +735,10 @@ export function preprocessExtend(content: string, extendCollection?: Set }); } -export function processSystemApi(content: string, isProcessWhiteList: boolean = false, +export function processSystemApi(content: string, isProcessAllowList: boolean = false, sourcePath: string = null, isSystemModule: boolean = false): string { let REG_SYSTEM: RegExp; - if (isProcessWhiteList) { + if (isProcessAllowList) { REG_SYSTEM = /(import|const)\s+(.+)\s*=\s*(\_\_importDefault\()?require\(\s*['"]@(system|ohos)\.(\S+)['"]\s*\)(\))?/g; } else { @@ -762,9 +762,9 @@ export function processSystemApi(content: string, isProcessWhiteList: boolean = if (!VALIDATE_MODULE.includes(systemValue)){ importModuleCollection.add(systemValue); } - if (!isProcessWhiteList && !isSystemModule) { + if (!isProcessAllowList && !isSystemModule) { return item; - } else if (isProcessWhiteList) { + } else if (isProcessAllowList) { systemValue = item2; moduleType = item4; systemKey = item5; @@ -798,7 +798,7 @@ function processInnerModule(content: string, systemValueCollection: Set) } const VALIDATE_MODULE_REG: RegExp = new RegExp('^(' + VALIDATE_MODULE.join('|') + ')'); -function validateWhiteListModule(moduleType: string, systemKey: string): boolean { +function validateAllowListModule(moduleType: string, systemKey: string): boolean { return moduleType === 'ohos' && VALIDATE_MODULE_REG.test(systemKey); } diff --git a/compiler/test/ut/gesture/panGestrue.ts b/compiler/test/ut/gesture/panGestrue.ts index 36fad83..07be107 100644 --- a/compiler/test/ut/gesture/panGestrue.ts +++ b/compiler/test/ut/gesture/panGestrue.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/compiler/test/ut/gesture/pinchGesture.ts b/compiler/test/ut/gesture/pinchGesture.ts index 751f3d0..6745ee0 100644 --- a/compiler/test/ut/gesture/pinchGesture.ts +++ b/compiler/test/ut/gesture/pinchGesture.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/compiler/test/ut/gesture/rotationGesture.ts b/compiler/test/ut/gesture/rotationGesture.ts index 60cd852..6a5cc04 100644 --- a/compiler/test/ut/gesture/rotationGesture.ts +++ b/compiler/test/ut/gesture/rotationGesture.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS,