mirror of
https://gitee.com/openharmony/developtools_ace_js2bundle
synced 2024-11-23 07:20:22 +00:00
Signed-off-by: chengongping <chengongping@huawei.com> Change-Id: I22e687cb2dbdf09fd2914240344b49eb1e5b219f
This commit is contained in:
parent
1e780f0aa8
commit
cd2928c44c
74
BUILD.gn
74
BUILD.gn
@ -1,4 +1,15 @@
|
|||||||
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
|
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# 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/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,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
import("//build/ohos.gni")
|
import("//build/ohos.gni")
|
||||||
import("//build/ohos/ace/ace.gni")
|
import("//build/ohos/ace/ace.gni")
|
||||||
@ -73,19 +84,21 @@ action("build_ace_loader_library") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ace_loader_sources = [
|
||||||
|
"ace-loader/.npmignore",
|
||||||
|
"ace-loader/babel.config.js",
|
||||||
|
"ace-loader/index.js",
|
||||||
|
"ace-loader/main.product.js",
|
||||||
|
"ace-loader/npm-install.js",
|
||||||
|
"ace-loader/package-lock.json",
|
||||||
|
"ace-loader/package.json",
|
||||||
|
"ace-loader/sample",
|
||||||
|
"ace-loader/webpack.lite.config.js",
|
||||||
|
"ace-loader/webpack.rich.config.js",
|
||||||
|
]
|
||||||
|
|
||||||
ohos_copy("ace_loader") {
|
ohos_copy("ace_loader") {
|
||||||
sources = [
|
sources = ace_loader_sources
|
||||||
"ace-loader/.npmignore",
|
|
||||||
"ace-loader/babel.config.js",
|
|
||||||
"ace-loader/index.js",
|
|
||||||
"ace-loader/main.product.js",
|
|
||||||
"ace-loader/npm-install.js",
|
|
||||||
"ace-loader/package-lock.json",
|
|
||||||
"ace-loader/package.json",
|
|
||||||
"ace-loader/sample",
|
|
||||||
"ace-loader/webpack.lite.config.js",
|
|
||||||
"ace-loader/webpack.rich.config.js",
|
|
||||||
]
|
|
||||||
outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
|
outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
|
||||||
module_source_dir = target_out_dir + "/$target_name/"
|
module_source_dir = target_out_dir + "/$target_name/"
|
||||||
module_install_name = ""
|
module_install_name = ""
|
||||||
@ -101,14 +114,29 @@ ohos_copy("ace_loader_library") {
|
|||||||
license_file = "//third_party/weex-loader/NOTICE"
|
license_file = "//third_party/weex-loader/NOTICE"
|
||||||
}
|
}
|
||||||
|
|
||||||
# copy previewer
|
ace_loader_dir =
|
||||||
ohos_copy("previewer_copy") {
|
get_label_info(":ace_loader", "target_out_dir") + "/ace_loader_ark"
|
||||||
if (host_os == "mac") {
|
|
||||||
sources = [ "//prebuilts/previewer/darwin/previewer" ]
|
ohos_copy("ace_loader_ark") {
|
||||||
} else {
|
sources = ace_loader_sources
|
||||||
sources = [ "//prebuilts/previewer/windows/previewer" ]
|
outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ]
|
||||||
}
|
license_file = "//third_party/parse5/LICENSE"
|
||||||
outputs = [ target_out_dir + "/{{source_file_part}}" ]
|
}
|
||||||
module_source_dir = target_out_dir + "/previewer/"
|
|
||||||
module_install_name = ""
|
ohos_copy("ace_loader_ark_hap") {
|
||||||
|
deps = [
|
||||||
|
":ace_loader",
|
||||||
|
":ace_loader_ark",
|
||||||
|
":build_ace_loader_library",
|
||||||
|
]
|
||||||
|
sources = [ ace_loader_lib_dir ]
|
||||||
|
outputs = [ ace_loader_dir + "/lib" ]
|
||||||
|
license_file = "//third_party/parse5/LICENSE"
|
||||||
|
}
|
||||||
|
|
||||||
|
ohos_copy("ace_loader_node_modules") {
|
||||||
|
deps = [ ":ace_loader_ark_hap" ]
|
||||||
|
sources = [ "//developtools/ace-js2bundle/ace-loader/node_modules" ]
|
||||||
|
outputs = [ ace_loader_dir + "/node_modules" ]
|
||||||
|
license_file = "//third_party/parse5/LICENSE"
|
||||||
}
|
}
|
||||||
|
1
LICENSE
1
LICENSE
@ -175,4 +175,3 @@
|
|||||||
of your accepting any such warranty or additional liability.
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
32
OAT.xml
Normal file
32
OAT.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
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/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,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<oatconfig>
|
||||||
|
<licensefile></licensefile>
|
||||||
|
<filefilterlist>
|
||||||
|
<filefilter name="defaultFilter" desc="Files not to check">
|
||||||
|
<filteritem type="filepath" name="ace-loader/node_modules/.*" desc="dependencies of ace-loader"/>
|
||||||
|
<filteritem type="filepath" name="ace-loader/third_party/.*" desc="third party software"/>
|
||||||
|
<filteritem type="filepath" name="ace-loader/lib/.*" desc="files generated by ace-loader"/>
|
||||||
|
<filteritem type="filepath" name="ace-loader/plugin/codegen/index.js" desc="files generated by another department"/>
|
||||||
|
</filefilter>
|
||||||
|
</filefilterlist>
|
||||||
|
</oatconfig>
|
||||||
|
</configuration>
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
@ -12,7 +12,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
src
|
src
|
||||||
test
|
test
|
||||||
|
@ -38,16 +38,71 @@ function deleteFolderRecursive(url) {
|
|||||||
function readManifest(manifestFilePath) {
|
function readManifest(manifestFilePath) {
|
||||||
let manifest = {};
|
let manifest = {};
|
||||||
try {
|
try {
|
||||||
const jsonString = fs.readFileSync(manifestFilePath).toString()
|
if (fs.existsSync(manifestFilePath)) {
|
||||||
manifest = JSON.parse(jsonString)
|
const jsonString = fs.readFileSync(manifestFilePath).toString();
|
||||||
|
manifest = JSON.parse(jsonString);
|
||||||
|
} else if (process.env.aceConfigPath && fs.existsSync(process.env.aceConfigPath)) {
|
||||||
|
buildManifest(manifest, process.env.aceConfigPath);
|
||||||
|
} else {
|
||||||
|
throw Error('\u001b[31m' + 'ERROR: the manifest.json or config.json is lost.' + '\u001b[39m')
|
||||||
|
.message;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Error('\u001b[31m' + 'ERROR: the manifest file is lost or format is invalid.' + '\u001b[39m').message
|
throw Error('\u001b[31m' + 'ERROR: the manifest.json or config.json file format is invalid.' +
|
||||||
|
'\u001b[39m').message;
|
||||||
}
|
}
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function buildManifest(manifest, aceConfigPath) {
|
||||||
|
try {
|
||||||
|
const configJson = JSON.parse(fs.readFileSync(aceConfigPath).toString());
|
||||||
|
const srcPath = process.env.srcPath;
|
||||||
|
manifest.type = process.env.abilityType;
|
||||||
|
manifest.pages = []
|
||||||
|
if (manifest.type === 'form') {
|
||||||
|
if (configJson.module && configJson.module.abilities) {
|
||||||
|
manifest.pages = getForms(configJson, srcPath);
|
||||||
|
} else {
|
||||||
|
throw Error('\u001b[31m'+
|
||||||
|
'EERROR: the config.json file miss keyword module || module[abilities].' +
|
||||||
|
'\u001b[39m').message;
|
||||||
|
}
|
||||||
|
manifest.minPlatformVersion = configJson.app.apiVersion.compatible;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw Error('\u001b[31m' + 'ERROR: the config.json file is lost or format is invalid.' +
|
||||||
|
'\u001b[39m').message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getForms(configJson, srcPath) {
|
||||||
|
const pages = [];
|
||||||
|
for (const ability of configJson.module.abilities){
|
||||||
|
if (ability.srcPath === srcPath) {
|
||||||
|
readForms(ability, pages);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readForms(ability, pages) {
|
||||||
|
if (ability.forms) {
|
||||||
|
for (const form of ability.forms){
|
||||||
|
if (form.src) {
|
||||||
|
pages.push(form.src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw Error('\u001b[31m' +`ERROR: the ${ability} in config.json file miss forms.' +
|
||||||
|
'\u001b[39m`).message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadEntryObj(projectPath, device_level, abilityType, manifestFilePath) {
|
function loadEntryObj(projectPath, device_level, abilityType, manifestFilePath) {
|
||||||
let entryObj = {}
|
let entryObj = {};
|
||||||
switch (abilityType) {
|
switch (abilityType) {
|
||||||
case 'page':
|
case 'page':
|
||||||
const appJSPath = path.resolve(projectPath, 'app.js');
|
const appJSPath = path.resolve(projectPath, 'app.js');
|
||||||
@ -60,9 +115,13 @@ function loadEntryObj(projectPath, device_level, abilityType, manifestFilePath)
|
|||||||
entryObj['./app'] = path.resolve(projectPath, './app.js?entry');
|
entryObj['./app'] = path.resolve(projectPath, './app.js?entry');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'form':
|
||||||
|
entryObj = addPageEntryObj(readManifest(manifestFilePath), projectPath);
|
||||||
|
entryObj[`./${abilityType}`] = path.resolve(projectPath, `./${abilityType}.js?entry`);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
entryObj[`./${abilityType}`] = path.resolve(projectPath + `./${abilityType}.js?entry`);
|
entryObj[`./${abilityType}`] = path.resolve(projectPath, `./${abilityType}.js?entry`);
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
return entryObj;
|
return entryObj;
|
||||||
}
|
}
|
||||||
@ -85,7 +144,8 @@ function addPageEntryObj(manifest, projectPath) {
|
|||||||
} else if (isHml) {
|
} else if (isHml) {
|
||||||
entryObj['./' + element] = path.resolve(projectPath, './' + sourcePath + '.hml?entry');
|
entryObj['./' + element] = path.resolve(projectPath, './' + sourcePath + '.hml?entry');
|
||||||
} else if (isVisual) {
|
} else if (isVisual) {
|
||||||
entryObj['./' + element] = path.resolve(aceSuperVisualPath, './' + sourcePath + '.visual?entry');
|
entryObj['./' + element] = path.resolve(aceSuperVisualPath, './' + sourcePath +
|
||||||
|
'.visual?entry');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return entryObj;
|
return entryObj;
|
||||||
@ -95,4 +155,4 @@ module.exports = {
|
|||||||
deleteFolderRecursive: deleteFolderRecursive,
|
deleteFolderRecursive: deleteFolderRecursive,
|
||||||
readManifest: readManifest,
|
readManifest: readManifest,
|
||||||
loadEntryObj: loadEntryObj
|
loadEntryObj: loadEntryObj
|
||||||
};
|
};
|
6
ace-loader/package-lock.json
generated
6
ace-loader/package-lock.json
generated
@ -2563,9 +2563,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"deccjsunit": {
|
"deccjsunit": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.nlark.com/deccjsunit/download/deccjsunit-1.0.3.tgz",
|
"resolved": "https://registry.nlark.com/deccjsunit/download/deccjsunit-1.0.4.tgz",
|
||||||
"integrity": "sha1-AcMxIKje4SsaoQiZGE14pszfiKI="
|
"integrity": "sha512-fkOzBz9uNKElrm6VGrisXLbAmLshcqBoqYAyo2+v9uceAkv75xh9dWAUmnZoWE/v4ujqYHylaudON1nj+LPuPA=="
|
||||||
},
|
},
|
||||||
"decode-uri-component": {
|
"decode-uri-component": {
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
"copy-webpack-plugin": "^8.1.0",
|
"copy-webpack-plugin": "^8.1.0",
|
||||||
"css": "^3.0.0",
|
"css": "^3.0.0",
|
||||||
"css-loader": "^3.4.2",
|
"css-loader": "^3.4.2",
|
||||||
"deccjsunit": "1.0.3",
|
"deccjsunit": "1.0.4",
|
||||||
"escodegen": "^2.0.0",
|
"escodegen": "^2.0.0",
|
||||||
"esprima": "^4.0.1",
|
"esprima": "^4.0.1",
|
||||||
"hash-sum": "^1.0.2",
|
"hash-sum": "^1.0.2",
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -324,6 +324,8 @@ var cardCommonTag = {
|
|||||||
accessibilityimportance: {
|
accessibilityimportance: {
|
||||||
enum: ['auto', 'yes', 'no', 'no-hide-descendants'],
|
enum: ['auto', 'yes', 'no', 'no-hide-descendants'],
|
||||||
},
|
},
|
||||||
|
for: {},
|
||||||
|
tid: {}
|
||||||
},
|
},
|
||||||
'children': ['block', 'slot'],
|
'children': ['block', 'slot'],
|
||||||
'parents': ['block']
|
'parents': ['block']
|
||||||
|
@ -177,7 +177,7 @@ function validateTagName(domNode, out, relativePath) {
|
|||||||
const depends = out.deps
|
const depends = out.deps
|
||||||
const jsonTemplate = out.jsonTemplate
|
const jsonTemplate = out.jsonTemplate
|
||||||
const log = out.log
|
const log = out.log
|
||||||
const oneChildNode = ['dialog', 'popup', 'badge']
|
const oneChildNode = ['dialog', 'popup', 'badge', 'list-item']
|
||||||
const logType = process.env.DEVICE_LEVEL === DEVICE_LEVEL.LITE ? 'ERROR' : 'WARNING'
|
const logType = process.env.DEVICE_LEVEL === DEVICE_LEVEL.LITE ? 'ERROR' : 'WARNING'
|
||||||
let pos = domNode.__location || {}
|
let pos = domNode.__location || {}
|
||||||
const elementNamesInFile = elementNames[relativePath] || []
|
const elementNamesInFile = elementNames[relativePath] || []
|
||||||
@ -765,6 +765,14 @@ function validateStyle(css, out, nodeLoc, relativePath) {
|
|||||||
if (styleContent.length === 2) {
|
if (styleContent.length === 2) {
|
||||||
const key = styleContent[0].trim().replace(/-([a-z])/g, function(s, m) { return m.toUpperCase() })
|
const key = styleContent[0].trim().replace(/-([a-z])/g, function(s, m) { return m.toUpperCase() })
|
||||||
let value = bind(styleContent[1].trim(), undefined, true, out, nodeLoc)
|
let value = bind(styleContent[1].trim(), undefined, true, out, nodeLoc)
|
||||||
|
const contentValue = styleContent[1].trim().toString();
|
||||||
|
if (contentValue.match(/^linear-gradient/) && contentValue.match(/\(.*\{\{.*\}\}.*\)/)) {
|
||||||
|
log.push({
|
||||||
|
line: nodeLoc.line || 1,
|
||||||
|
column: nodeLoc.col || 1,
|
||||||
|
reason: `ERROR: can not bind data for linear-gradient in inline style at ${css}`
|
||||||
|
})
|
||||||
|
}
|
||||||
if (key === 'flex' && typeof value === 'string') {
|
if (key === 'flex' && typeof value === 'string') {
|
||||||
expandFlex(key, value, cssStyle, nodeLoc, log)
|
expandFlex(key, value, cssStyle, nodeLoc, log)
|
||||||
} else {
|
} else {
|
||||||
@ -1073,8 +1081,8 @@ function validateEvent(eventName, val, out, pos, relativePath) {
|
|||||||
let paramList = content[2]
|
let paramList = content[2]
|
||||||
if (paramList) {
|
if (paramList) {
|
||||||
paramList = transContent.parseExpression(paramList, true)
|
paramList = transContent.parseExpression(paramList, true)
|
||||||
val = eval('(function (evt) {' + bind('{{' + functionName + '(' + paramList + ',evt)}}',
|
val = eval('(function (evt) {' + bind('{{' + functionName + '(' + paramList + ',evt)}}',
|
||||||
false, true, out, pos) + '})')
|
false, true, out, pos) + '})')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1102,17 +1110,17 @@ function distributeEvent(out, eventName, name, val) {
|
|||||||
out.jsonTemplate.onBubbleEvents[name] = val
|
out.jsonTemplate.onBubbleEvents[name] = val
|
||||||
}
|
}
|
||||||
} else if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && CLICK_EVENT_REGEXP.test(name) &&
|
} else if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && CLICK_EVENT_REGEXP.test(name) &&
|
||||||
!eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) {
|
!eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) {
|
||||||
if (eventName.match(START_CATCH_REGEXP)) {
|
if (eventName.match(START_CATCH_REGEXP)) {
|
||||||
out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {}
|
out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {}
|
||||||
out.jsonTemplate.catchBubbleEvents[name] = val
|
out.jsonTemplate.catchBubbleEvents[name] = val
|
||||||
} else {
|
|
||||||
out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {}
|
|
||||||
out.jsonTemplate.onBubbleEvents[name] = val
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
out.jsonTemplate.events = out.jsonTemplate.events || {}
|
out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {}
|
||||||
out.jsonTemplate.events[name] = val
|
out.jsonTemplate.onBubbleEvents[name] = val
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.jsonTemplate.events = out.jsonTemplate.events || {}
|
||||||
|
out.jsonTemplate.events[name] = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1244,8 +1252,8 @@ function validateAttrElse(preNode, out, nodeLoc, relativePath) {
|
|||||||
function parseDataAttr(name, value, out) {
|
function parseDataAttr(name, value, out) {
|
||||||
const childName = name.replace('data-', '')
|
const childName = name.replace('data-', '')
|
||||||
out.jsonTemplate.attr = out.jsonTemplate.attr || {}
|
out.jsonTemplate.attr = out.jsonTemplate.attr || {}
|
||||||
out.jsonTemplate.attr.data = out.jsonTemplate.attr.data || {}
|
out.jsonTemplate.attr.$data = out.jsonTemplate.attr.$data || {}
|
||||||
out.jsonTemplate.attr.data[childName] = bind(value, undefined, true, out)
|
out.jsonTemplate.attr.$data[childName] = bind(value, undefined, true, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSupportedSelfClosing(tagName) {
|
function isSupportedSelfClosing(tagName) {
|
||||||
|
@ -30,7 +30,9 @@ class AfterEmitPlugin {
|
|||||||
(assets, back) => {
|
(assets, back) => {
|
||||||
const keys = Object.keys(assets)
|
const keys = Object.keys(assets)
|
||||||
keys.forEach(key => {
|
keys.forEach(key => {
|
||||||
sourceChange(key, assets, compilation);
|
if ('./' + process.env.abilityType + '.js' !== key) {
|
||||||
|
sourceChange(key, assets, compilation);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
back && back();
|
back && back();
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Stats = require('webpack/lib/Stats');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { DEVICE_LEVEL } = require('./lite/lite-enum');
|
import Compilation from 'webpack/lib/Compilation';
|
||||||
|
import JavascriptModulesPlugin from 'webpack/lib/javascript/JavascriptModulesPlugin';
|
||||||
|
import CachedSource from 'webpack-sources/lib/CachedSource';
|
||||||
|
import ConcatSource from 'webpack-sources/lib/ConcatSource';
|
||||||
|
|
||||||
|
import { circularFile } from './util';
|
||||||
|
|
||||||
const REG = /\([^\)]+\)/;
|
|
||||||
let mStats;
|
let mStats;
|
||||||
let mErrorCount = 0;
|
let mErrorCount = 0;
|
||||||
let mWarningCount = 0;
|
let mWarningCount = 0;
|
||||||
@ -29,6 +32,14 @@ let warningCount = 0;
|
|||||||
let noteCount = 0;
|
let noteCount = 0;
|
||||||
let errorCount = 0;
|
let errorCount = 0;
|
||||||
|
|
||||||
|
const GLOBAL_COMMON_MODULE_CACHE = `
|
||||||
|
globalThis["__common_module_cache__"] = globalThis["__common_module_cache__"] || {};
|
||||||
|
globalThis["webpackChunkace_loader"].forEach((item)=> {
|
||||||
|
Object.keys(item[1]).forEach((element) => {
|
||||||
|
globalThis["__common_module_cache__"][element] = null;
|
||||||
|
})
|
||||||
|
});`;
|
||||||
|
|
||||||
class ResultStates {
|
class ResultStates {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
@ -36,6 +47,30 @@ class ResultStates {
|
|||||||
|
|
||||||
apply(compiler) {
|
apply(compiler) {
|
||||||
const buildPath = this.options.build;
|
const buildPath = this.options.build;
|
||||||
|
const modulePaths = new Set();
|
||||||
|
|
||||||
|
compiler.hooks.compilation.tap('toFindModule', (compilation) => {
|
||||||
|
compilation.hooks.buildModule.tap("findModule", (module) => {
|
||||||
|
if (/node_modules/.test(module.context)) {
|
||||||
|
const beforNodeModules = module.context.substr(0, module.context.indexOf('node_modules'));
|
||||||
|
const afterNodeModules =
|
||||||
|
module.context.replace(beforNodeModules, '').replace('node_modules' + path.sep, '');
|
||||||
|
const src = afterNodeModules.substr(0, afterNodeModules.indexOf(path.sep));
|
||||||
|
const modulePath =
|
||||||
|
path.resolve(beforNodeModules, 'node_modules', src, 'src', 'js', 'share');
|
||||||
|
if (fs.existsSync(modulePath)) {
|
||||||
|
modulePaths.add(modulePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
compiler.hooks.afterCompile.tap('copyFindModule', () => {
|
||||||
|
for (let modulePath of modulePaths) {
|
||||||
|
circularFile(modulePath, path.resolve(buildPath, '../share'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
compiler.hooks.done.tap('Result States', (stats) => {
|
compiler.hooks.done.tap('Result States', (stats) => {
|
||||||
mStats = stats;
|
mStats = stats;
|
||||||
warningCount = 0;
|
warningCount = 0;
|
||||||
@ -58,6 +93,38 @@ class ResultStates {
|
|||||||
}
|
}
|
||||||
printResult(buildPath);
|
printResult(buildPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
compiler.hooks.compilation.tap('CommonAsset', compilation => {
|
||||||
|
compilation.hooks.processAssets.tap(
|
||||||
|
{
|
||||||
|
name: 'GLOBAL_COMMON_MODULE_CACHE',
|
||||||
|
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
||||||
|
},
|
||||||
|
(assets) => {
|
||||||
|
if (assets['commons.js']) {
|
||||||
|
assets['commons.js'] = new CachedSource(
|
||||||
|
new ConcatSource(assets['commons.js'], GLOBAL_COMMON_MODULE_CACHE));
|
||||||
|
} else if (assets['vendors.js']) {
|
||||||
|
assets['vendors.js'] = new CachedSource(
|
||||||
|
new ConcatSource(assets['vendors.js'], GLOBAL_COMMON_MODULE_CACHE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
compiler.hooks.compilation.tap('Require', compilation => {
|
||||||
|
JavascriptModulesPlugin.getCompilationHooks(compilation).renderRequire.tap('renderRequire',
|
||||||
|
(source) => {
|
||||||
|
return `var commonCachedModule = globalThis["__common_module_cache__"] ? ` +
|
||||||
|
`globalThis["__common_module_cache__"][moduleId]: null;\n` +
|
||||||
|
`if (commonCachedModule) { return commonCachedModule.exports; }\n` +
|
||||||
|
source.replace('// Execute the module function',
|
||||||
|
`if (globalThis["__common_module_cache__"] && moduleId.indexOf("?name=") < 0 && ` +
|
||||||
|
`Object.keys(globalThis["__common_module_cache__"]).indexOf(moduleId) >= 0) {\n` +
|
||||||
|
` globalThis["__common_module_cache__"][moduleId] = module;\n}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* distributed with this work for additional information
|
* you may not use this file except in compliance with the License.
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* You may obtain a copy of the License at
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); 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/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import loaderUtils from 'loader-utils';
|
import loaderUtils from 'loader-utils';
|
||||||
@ -24,7 +20,7 @@ const codegen = require("./codegen/index.js");
|
|||||||
module.exports = function (source, map) {
|
module.exports = function (source, map) {
|
||||||
this.cacheable && this.cacheable();
|
this.cacheable && this.cacheable();
|
||||||
const callback = this.async();
|
const callback = this.async();
|
||||||
|
|
||||||
const parsed = codegen.genHmlAndCss(source);
|
const parsed = codegen.genHmlAndCss(source);
|
||||||
const loaderQuery = loaderUtils.getOptions(this) || {};
|
const loaderQuery = loaderUtils.getOptions(this) || {};
|
||||||
if (parsed.errorType && parsed.errorType !== '') {
|
if (parsed.errorType && parsed.errorType !== '') {
|
||||||
|
@ -17,7 +17,6 @@ const fs = require('fs')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const process = require('child_process')
|
const process = require('child_process')
|
||||||
|
|
||||||
const arkDir = path.join(__dirname, '..', 'bin', 'ark');
|
|
||||||
const forward = '(global.___mainEntry___ = function (globalObjects) {' + '\n' +
|
const forward = '(global.___mainEntry___ = function (globalObjects) {' + '\n' +
|
||||||
' var define = globalObjects.define;' + '\n' +
|
' var define = globalObjects.define;' + '\n' +
|
||||||
' var require = globalObjects.require;' + '\n' +
|
' var require = globalObjects.require;' + '\n' +
|
||||||
@ -35,25 +34,25 @@ const forward = '(global.___mainEntry___ = function (globalObjects) {' + '\n' +
|
|||||||
const last = '\n' + '})(this.__appProto__);' + '\n' + '})'
|
const last = '\n' + '})(this.__appProto__);' + '\n' + '})'
|
||||||
const firstFileEXT = '_.js'
|
const firstFileEXT = '_.js'
|
||||||
let output
|
let output
|
||||||
let webpackPath
|
|
||||||
let isWin = false
|
let isWin = false
|
||||||
let isMac = false
|
let isMac = false
|
||||||
let isDebug = false
|
let isDebug = false
|
||||||
|
let arkDir
|
||||||
|
|
||||||
class GenAbcPlugin {
|
class GenAbcPlugin {
|
||||||
constructor(output_, webpackPath_, isDebug_) {
|
constructor(output_, arkDir_, isDebug_) {
|
||||||
output = output_
|
output = output_
|
||||||
webpackPath = webpackPath_
|
arkDir = arkDir_
|
||||||
isDebug = isDebug_
|
isDebug = isDebug_
|
||||||
}
|
}
|
||||||
apply(compiler) {
|
apply(compiler) {
|
||||||
if (fs.existsSync(path.resolve(webpackPath, 'ark/build-win'))) {
|
if (fs.existsSync(path.resolve(arkDir, 'build-win'))) {
|
||||||
isWin = true
|
isWin = true
|
||||||
} else {
|
} else {
|
||||||
if (fs.existsSync(path.resolve(webpackPath, 'ark/build-mac'))) {
|
if (fs.existsSync(path.resolve(arkDir, 'build-mac'))) {
|
||||||
isMac = true
|
isMac = true
|
||||||
} else {
|
} else {
|
||||||
if (!fs.existsSync(path.resolve(webpackPath, 'ark/build'))) {
|
if (!fs.existsSync(path.resolve(arkDir, 'build'))) {
|
||||||
console.error('\u001b[31m', `find build fail`, '\u001b[39m')
|
console.error('\u001b[31m', `find build fail`, '\u001b[39m')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -65,11 +64,14 @@ class GenAbcPlugin {
|
|||||||
const keys = Object.keys(assets)
|
const keys = Object.keys(assets)
|
||||||
keys.forEach(key => {
|
keys.forEach(key => {
|
||||||
// choice *.js
|
// choice *.js
|
||||||
if (output && webpackPath && path.extname(key) === '.js') {
|
if (output && path.extname(key) === '.js') {
|
||||||
let newContent = assets[key].source()
|
let newContent = assets[key].source()
|
||||||
if (key.search('./workers/') !== 0) {
|
if (key.search('./workers/') !== 0 && key !== 'commons.js' && key !== 'vendors.js') {
|
||||||
newContent = forward + newContent + last
|
newContent = forward + newContent + last
|
||||||
}
|
}
|
||||||
|
if (key === 'commons.js' || key === 'vendors.js') {
|
||||||
|
newContent = `\n\n\n\n\n\n\n\n\n\n\n\n\n\n` + newContent
|
||||||
|
}
|
||||||
const keyPath = key.replace(/\.js$/, firstFileEXT)
|
const keyPath = key.replace(/\.js$/, firstFileEXT)
|
||||||
writeFileSync(newContent, path.resolve(output, keyPath), key)
|
writeFileSync(newContent, path.resolve(output, keyPath), key)
|
||||||
}
|
}
|
||||||
|
@ -192,11 +192,11 @@ function codegenHmlAndCss() {
|
|||||||
|
|
||||||
if (process.env.DEVICE_LEVEL === 'card') {
|
if (process.env.DEVICE_LEVEL === 'card') {
|
||||||
output = '//card_start\n'
|
output = '//card_start\n'
|
||||||
output += `var card_template =` + getRequireString(this,
|
output += `var card_template =` + getRequireString(this,
|
||||||
jsonLoaders('template', undefined, true, 'template'), this.resourcePath)
|
jsonLoaders('template', undefined, true, 'template'), this.resourcePath)
|
||||||
output += `var card_style =` + getRequireString(this,
|
output += `var card_style =` + getRequireString(this,
|
||||||
jsonLoaders('style', undefined, true, 'style'), this.resourcePath)
|
jsonLoaders('style', undefined, true, 'style'), this.resourcePath)
|
||||||
output += `var card_json =` + getRequireString(this,
|
output += `var card_json =` + getRequireString(this,
|
||||||
jsonLoaders('json', undefined, true, 'json'), this.resourcePath)
|
jsonLoaders('json', undefined, true, 'json'), this.resourcePath)
|
||||||
output += '\n//card_end'
|
output += '\n//card_end'
|
||||||
} else {
|
} else {
|
||||||
@ -207,7 +207,7 @@ function codegenHmlAndCss() {
|
|||||||
elementName: undefined,
|
elementName: undefined,
|
||||||
source: jsFileName
|
source: jsFileName
|
||||||
}), jsFileName)
|
}), jsFileName)
|
||||||
|
|
||||||
output += 'var $app_template$ = ' + getRequireString(this, getLoaderString('template', {
|
output += 'var $app_template$ = ' + getRequireString(this, getLoaderString('template', {
|
||||||
customLang,
|
customLang,
|
||||||
lang: undefined,
|
lang: undefined,
|
||||||
@ -215,7 +215,7 @@ function codegenHmlAndCss() {
|
|||||||
elementName: undefined,
|
elementName: undefined,
|
||||||
source: this.resourcePath
|
source: this.resourcePath
|
||||||
}), this.resourcePath)
|
}), this.resourcePath)
|
||||||
|
|
||||||
output += 'var $app_style$ = ' + getRequireString(this, getLoaderString('style', {
|
output += 'var $app_style$ = ' + getRequireString(this, getLoaderString('style', {
|
||||||
customLang,
|
customLang,
|
||||||
lang: undefined,
|
lang: undefined,
|
||||||
@ -223,9 +223,9 @@ function codegenHmlAndCss() {
|
|||||||
elementName: undefined,
|
elementName: undefined,
|
||||||
source: this.resourcePath
|
source: this.resourcePath
|
||||||
}), this.resourcePath)
|
}), this.resourcePath)
|
||||||
|
|
||||||
output += `
|
output += `
|
||||||
$app_define$('@app-component/${getNameByPath(this.resourcePath)}', [],
|
$app_define$('@app-component/${getNameByPath(this.resourcePath)}', [],
|
||||||
function($app_require$, $app_exports$, $app_module$) {
|
function($app_require$, $app_exports$, $app_module$) {
|
||||||
` + `
|
` + `
|
||||||
$app_script$($app_module$, $app_exports$, $app_require$)
|
$app_script$($app_module$, $app_exports$, $app_require$)
|
||||||
@ -240,8 +240,8 @@ function codegenHmlAndCss() {
|
|||||||
})
|
})
|
||||||
`
|
`
|
||||||
if (isEntry) {
|
if (isEntry) {
|
||||||
output += `$app_bootstrap$('@app-component/
|
output += `$app_bootstrap$('@app-component/${getNameByPath(this.resourcePath)}'`
|
||||||
${getNameByPath(this.resourcePath)}'` + ',undefined' + ',undefined' + `)`
|
+ ',undefined' + ',undefined' + `)`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output
|
return output
|
||||||
|
@ -19,6 +19,7 @@ const SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
|
|||||||
|
|
||||||
const CUSTOM_THEME_PROP_GROUPS = require('./theme/customThemeStyles');
|
const CUSTOM_THEME_PROP_GROUPS = require('./theme/customThemeStyles');
|
||||||
const OHOS_THEME_PROP_GROUPS = require('./theme/ohosStyles');
|
const OHOS_THEME_PROP_GROUPS = require('./theme/ohosStyles');
|
||||||
|
import { mkDir } from './util';
|
||||||
|
|
||||||
const FILE_EXT_NAME = ['.js', '.css', '.jsx', '.less', '.sass', '.scss', '.md', '.DS_Store', '.hml'];
|
const FILE_EXT_NAME = ['.js', '.css', '.jsx', '.less', '.sass', '.scss', '.md', '.DS_Store', '.hml'];
|
||||||
const red = '\u001b[31m';
|
const red = '\u001b[31m';
|
||||||
@ -63,14 +64,6 @@ function copyFile(input, output) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkDir(path_) {
|
|
||||||
const parent = path.join(path_, '..');
|
|
||||||
if (!(fs.existsSync(parent) && !fs.statSync(parent).isFile())) {
|
|
||||||
mkDir(parent);
|
|
||||||
}
|
|
||||||
fs.mkdirSync(path_);
|
|
||||||
}
|
|
||||||
|
|
||||||
function circularFile(inputPath, outputPath, ext) {
|
function circularFile(inputPath, outputPath, ext) {
|
||||||
const realPath = path.join(inputPath, ext);
|
const realPath = path.join(inputPath, ext);
|
||||||
const localI18n = path.join(input, 'i18n');
|
const localI18n = path.join(input, 'i18n');
|
||||||
@ -146,12 +139,8 @@ let entryObj = {};
|
|||||||
function addPageEntryObj() {
|
function addPageEntryObj() {
|
||||||
entryObj = {};
|
entryObj = {};
|
||||||
if (process.env.abilityType === 'page') {
|
if (process.env.abilityType === 'page') {
|
||||||
if (!fs.existsSync(manifestFilePath)) {
|
const jsonString = readManifest(manifestFilePath);
|
||||||
throw Error('ERROR: missing manifest').message;
|
const pages = jsonString.pages;
|
||||||
}
|
|
||||||
const jsonString = fs.readFileSync(manifestFilePath).toString();
|
|
||||||
const obj = JSON.parse(jsonString);
|
|
||||||
const pages = obj.pages;
|
|
||||||
if (pages === undefined) {
|
if (pages === undefined) {
|
||||||
throw Error('ERROR: missing pages').message;
|
throw Error('ERROR: missing pages').message;
|
||||||
}
|
}
|
||||||
@ -164,13 +153,12 @@ function addPageEntryObj() {
|
|||||||
const isVisual = fs.existsSync(visualPath);
|
const isVisual = fs.existsSync(visualPath);
|
||||||
const projectPath = process.env.projectPath;
|
const projectPath = process.env.projectPath;
|
||||||
if (isHml && isVisual) {
|
if (isHml && isVisual) {
|
||||||
logWarn(this, [{
|
console.error('ERROR: ' + sourcePath + ' cannot both have hml && visual');
|
||||||
reason: 'ERROR: ' + sourcePath + ' cannot both have hml && visual',
|
|
||||||
}]);
|
|
||||||
} else if (isHml) {
|
} else if (isHml) {
|
||||||
entryObj['./' + element] = path.resolve(projectPath, './' + sourcePath + '.hml?entry');
|
entryObj['./' + element] = path.resolve(projectPath, './' + sourcePath + '.hml?entry');
|
||||||
} else if (isVisual) {
|
} else if (isVisual) {
|
||||||
entryObj['./' + element] = path.resolve(aceSuperVisualPath, './' + sourcePath + '.visual?entry');
|
entryObj['./' + element] = path.resolve(aceSuperVisualPath, './' + sourcePath +
|
||||||
|
'.visual?entry');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -180,6 +168,66 @@ function addPageEntryObj() {
|
|||||||
return entryObj;
|
return entryObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readManifest(manifestFilePath) {
|
||||||
|
let manifest = {};
|
||||||
|
try {
|
||||||
|
if (fs.existsSync(manifestFilePath)) {
|
||||||
|
const jsonString = fs.readFileSync(manifestFilePath).toString();
|
||||||
|
manifest = JSON.parse(jsonString);
|
||||||
|
} else if (process.env.aceConfigPath && fs.existsSync(process.env.aceConfigPath)) {
|
||||||
|
buildManifest(manifest, process.env.aceConfigPath);
|
||||||
|
} else {
|
||||||
|
throw Error('\u001b[31m' + 'ERROR: the manifest.json or config.json is lost.' +
|
||||||
|
'\u001b[39m').message;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw Error('\u001b[31m' + 'ERROR: the manifest.json or config.json file format is invalid.' +
|
||||||
|
'\u001b[39m').message;
|
||||||
|
}
|
||||||
|
return manifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildManifest(manifest, aceConfigPath) {
|
||||||
|
try {
|
||||||
|
const configJson = JSON.parse(fs.readFileSync(aceConfigPath).toString());
|
||||||
|
const srcPath = process.env.srcPath;
|
||||||
|
manifest.type = process.env.abilityType;
|
||||||
|
if (configJson.module && configJson.module.abilities) {
|
||||||
|
manifest.pages = getPages(configJson, srcPath);
|
||||||
|
} else {
|
||||||
|
throw Error('\u001b[31m'+
|
||||||
|
'EERROR: the config.json file miss keyword module || module[abilities].' +
|
||||||
|
'\u001b[39m').message;
|
||||||
|
}
|
||||||
|
manifest.minPlatformVersion = configJson.app.apiVersion.compatible;
|
||||||
|
} catch (e) {
|
||||||
|
throw Error("\x1B[31m" + 'ERROR: the config.json file is lost or format is invalid.' +
|
||||||
|
"\x1B[39m").message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPages(configJson, srcPath) {
|
||||||
|
let pages = []
|
||||||
|
for (const ability of configJson.module.abilities){
|
||||||
|
if (ability.srcPath === srcPath) {
|
||||||
|
readPages(ability, pages, configJson)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
function readPages(ability, pages, configJson) {
|
||||||
|
for (const js of configJson.module.js){
|
||||||
|
if (ability.name === js.name) {
|
||||||
|
js.pages.forEach(page => {
|
||||||
|
pages.push(page)
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadWorker(entryObj) {
|
function loadWorker(entryObj) {
|
||||||
const workerPath = path.resolve(input, 'workers');
|
const workerPath = path.resolve(input, 'workers');
|
||||||
if (fs.existsSync(workerPath)) {
|
if (fs.existsSync(workerPath)) {
|
||||||
@ -236,4 +284,4 @@ function themeFileBuild(customThemePath, customThemeBuild) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ResourcePlugin;
|
module.exports = ResourcePlugin;
|
@ -1,20 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* distributed with this work for additional information
|
* you may not use this file except in compliance with the License.
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* You may obtain a copy of the License at
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); 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/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const OHOS_THEME_PROP_GROUPS = require('./theme/ohosStyles')
|
const OHOS_THEME_PROP_GROUPS = require('./theme/ohosStyles')
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* distributed with this work for additional information
|
* you may not use this file except in compliance with the License.
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* You may obtain a copy of the License at
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); 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/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@colorBackground: #000000;
|
@colorBackground: #000000;
|
||||||
.container {
|
.container {
|
||||||
background-color: @colorBackground;
|
background-color: @colorBackground;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
|
@ -13,4 +13,4 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_c('slider', {'attrs' : {'max' : 100}} ),_c('image'),_c('div', {'attrs' : {'key' : \"day\",'value' : \"hello\"}} ),_c('text', {'attrs' : {'value' : \"hello\"}} ),_c('text', {'attrs' : {'value' : function () {return _vm.num}}} )] ) }"}
|
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_c('slider', {'attrs' : {'max' : 100}} ),_c('image'),_c('div', {'attrs' : {'key' : \"day\",'value' : \"hello\"}} ),_c('text', {'attrs' : {'value' : \"hello\"}} ),_c('text', {'attrs' : {'value' : function () {return _vm.num}}} )] ) }"}
|
@ -13,4 +13,4 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{"render": "function (vm) { var _vm = vm || this; return _c('div', {'staticClass' : [\"container\"]} , [_c('div', {'onBubbleEvents' : {'click' : _vm.test1}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test2}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test3}} ),_c('div', {'catchBubbleEvents' : {'click' : _vm.test4}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test5}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test6}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test7}} ),_c('div', {'catchBubbleEvents' : {'click' : _vm.test8}} ),_c('div', {'onCaptureEvents' : {'click' : _vm.test9}} ),_c('div', {'onCaptureEvents' : {'click' : _vm.test10}} ),_c('div', {'onCaptureEvents' : {'click' : _vm.test11}} ),_c('div', {'catchCaptureEvents' : {'click' : _vm.test12}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe1},'catchCaptureEvents' : {'longpress' : _vm.longpress1}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe2},'onCaptureEvents' : {'longpress' : _vm.longpress2}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe3},'onCaptureEvents' : {'longpress' : _vm.longpress3}} ),_c('div', {'catchBubbleEvents' : {'swipe' : _vm.swipe4},'onCaptureEvents' : {'longpress' : _vm.longpress4}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe5},'catchBubbleEvents' : {'longpress' : _vm.longpress5}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe6,'longpress' : _vm.longpress6}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe7,'longpress' : _vm.longpress7}} ),_c('div', {'catchBubbleEvents' : {'swipe' : _vm.swipe8},'onBubbleEvents' : {'longpress' : _vm.longpress8}} ),_c('div', {'onCaptureEvents' : {'swipe' : _vm.swipe9},'catchBubbleEvents' : {'longpress' : _vm.longpress9}} ),_c('div', {'onCaptureEvents' : {'swipe' : _vm.swipe10},'onBubbleEvents' : {'longpress' : _vm.longpress10}} ),_c('div', {'onCaptureEvents' : {'swipe' : _vm.swipe11},'onBubbleEvents' : {'longpress' : _vm.longpress11}} ),_c('div', {'catchCaptureEvents' : {'swipe' : _vm.swipe12},'onBubbleEvents' : {'longpress' : _vm.longpress12}} )] ) }"}
|
{"render": "function (vm) { var _vm = vm || this; return _c('div', {'staticClass' : [\"container\"]} , [_c('div', {'onBubbleEvents' : {'click' : _vm.test1}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test2}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test3}} ),_c('div', {'catchBubbleEvents' : {'click' : _vm.test4}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test5}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test6}} ),_c('div', {'onBubbleEvents' : {'click' : _vm.test7}} ),_c('div', {'catchBubbleEvents' : {'click' : _vm.test8}} ),_c('div', {'onCaptureEvents' : {'click' : _vm.test9}} ),_c('div', {'onCaptureEvents' : {'click' : _vm.test10}} ),_c('div', {'onCaptureEvents' : {'click' : _vm.test11}} ),_c('div', {'catchCaptureEvents' : {'click' : _vm.test12}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe1},'catchCaptureEvents' : {'longpress' : _vm.longpress1}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe2},'onCaptureEvents' : {'longpress' : _vm.longpress2}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe3},'onCaptureEvents' : {'longpress' : _vm.longpress3}} ),_c('div', {'catchBubbleEvents' : {'swipe' : _vm.swipe4},'onCaptureEvents' : {'longpress' : _vm.longpress4}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe5},'catchBubbleEvents' : {'longpress' : _vm.longpress5}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe6,'longpress' : _vm.longpress6}} ),_c('div', {'onBubbleEvents' : {'swipe' : _vm.swipe7,'longpress' : _vm.longpress7}} ),_c('div', {'catchBubbleEvents' : {'swipe' : _vm.swipe8},'onBubbleEvents' : {'longpress' : _vm.longpress8}} ),_c('div', {'onCaptureEvents' : {'swipe' : _vm.swipe9},'catchBubbleEvents' : {'longpress' : _vm.longpress9}} ),_c('div', {'onCaptureEvents' : {'swipe' : _vm.swipe10},'onBubbleEvents' : {'longpress' : _vm.longpress10}} ),_c('div', {'onCaptureEvents' : {'swipe' : _vm.swipe11},'onBubbleEvents' : {'longpress' : _vm.longpress11}} ),_c('div', {'catchCaptureEvents' : {'swipe' : _vm.swipe12},'onBubbleEvents' : {'longpress' : _vm.longpress12}} )] ) }"}
|
@ -13,4 +13,4 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_c('div', {'staticClass' : [\"container\"]} ),_c('div', {'staticClass' : [\"container\",\"table\"]} )] ) }"}
|
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_c('div', {'staticClass' : [\"container\"]} ),_c('div', {'staticClass' : [\"container\",\"table\"]} )] ) }"}
|
@ -13,4 +13,4 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_c('text', {'attrs' : {'value' : function () {return _vm.ti||_vm.subTitle}}} ),_c('text', {'attrs' : {'value' : function () {return _vm.ti&&_vm.subTitle}}} ),_c('div', {'attrs' : {'value' : function () {return _vm.isArrived==='arrived'&&_vm.isTravel===false}}} ),_c('div', {'attrs' : {'value' : function () {return _vm.isArrived==='arrived'||_vm.isTravel===false}}} ),_c('div', {'attrs' : {'value' : function () {return !_vm.flag}}} ),_c('div', {'attrs' : {'value' : function () {return !!_vm.flag}}} )] ) }"}
|
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_c('text', {'attrs' : {'value' : function () {return _vm.ti||_vm.subTitle}}} ),_c('text', {'attrs' : {'value' : function () {return _vm.ti&&_vm.subTitle}}} ),_c('div', {'attrs' : {'value' : function () {return _vm.isArrived==='arrived'&&_vm.isTravel===false}}} ),_c('div', {'attrs' : {'value' : function () {return _vm.isArrived==='arrived'||_vm.isTravel===false}}} ),_c('div', {'attrs' : {'value' : function () {return !_vm.flag}}} ),_c('div', {'attrs' : {'value' : function () {return !!_vm.flag}}} )] ) }"}
|
@ -13,4 +13,4 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_l((function () {return _vm.list}),function($item,$idx){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test($item,evt)}}} , [_c('text', {'attrs' : {'value' : function () {return ($idx) + decodeURI('.') + ($item.name)}}} )] )}),_c('div', [_l((function () {return _vm.list}),function(personItem,$idx){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test($idx,evt)}}} , [_c('text', {'attrs' : {'value' : function () {return ($idx) + decodeURI('-') + (personItem.name) + decodeURI('--') + (personItem.age)}}} )] )}),_c('image', {'attrs' : {'src' : function () {return _vm.personItem}}} )] ),_c('div', [_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(personItem,evt)}}} , [_c('text', {'attrs' : {'value' : function () {return (personIndex) + decodeURI('.') + (personItem.name)}}} )] )}),_c('swiper', {'attrs' : {'index' : function () {return _vm.personIndex},'loop' : function () {return _vm.personItem}}} )] ),_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(personItem,evt)}}} , [_l((function () {return _vm.menu}),function(item,index){return _c('div', [_c('text', {'attrs' : {'value' : function () {return (personItem.id) + decodeURI('--') + (item.name)}}} )] )})] )}),_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(personItem,evt)}}} , [_l((function () {return personItem}),function(item,index){return _c('div', [_c('text', {'attrs' : {'value' : function () {return (index) + decodeURI('--') + (item.name)}}} )] )})] )}),_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(personItem,evt)}}} , [_c('div', {'attrs' : {'value' : function () {return (personIndex) + decodeURI('.') + (personItem.name)}},'onBubbleEvents' : {'click' : personItem.click}} )] )}),_l((function () {return value.list}),function(index,value){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(value,evt)}}} , [_c('div', {'attrs' : {'value' : function () {return value.info}},'onBubbleEvents' : {'click' : value.click}} )] )})] ) }"}
|
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_l((function () {return _vm.list}),function($item,$idx){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test($item,evt)}}} , [_c('text', {'attrs' : {'value' : function () {return ($idx) + decodeURI('.') + ($item.name)}}} )] )}),_c('div', [_l((function () {return _vm.list}),function(personItem,$idx){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test($idx,evt)}}} , [_c('text', {'attrs' : {'value' : function () {return ($idx) + decodeURI('-') + (personItem.name) + decodeURI('--') + (personItem.age)}}} )] )}),_c('image', {'attrs' : {'src' : function () {return _vm.personItem}}} )] ),_c('div', [_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(personItem,evt)}}} , [_c('text', {'attrs' : {'value' : function () {return (personIndex) + decodeURI('.') + (personItem.name)}}} )] )}),_c('swiper', {'attrs' : {'index' : function () {return _vm.personIndex},'loop' : function () {return _vm.personItem}}} )] ),_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(personItem,evt)}}} , [_l((function () {return _vm.menu}),function(item,index){return _c('div', [_c('text', {'attrs' : {'value' : function () {return (personItem.id) + decodeURI('--') + (item.name)}}} )] )})] )}),_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(personItem,evt)}}} , [_l((function () {return personItem}),function(item,index){return _c('div', [_c('text', {'attrs' : {'value' : function () {return (index) + decodeURI('--') + (item.name)}}} )] )})] )}),_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(personItem,evt)}}} , [_c('div', {'attrs' : {'value' : function () {return (personIndex) + decodeURI('.') + (personItem.name)}},'onBubbleEvents' : {'click' : personItem.click}} )] )}),_l((function () {return value.list}),function(index,value){return _c('div', {'onBubbleEvents' : {'click' : function (evt) {_vm.test(value,evt)}}} , [_c('div', {'attrs' : {'value' : function () {return value.info}},'onBubbleEvents' : {'click' : value.click}} )] )})] ) }"}
|
@ -13,4 +13,4 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_i((function () {return _vm.conditionVar===1}),function(){return _c('text', {'attrs' : {'value' : function () {return _vm.componentData.if}}} )}),_c('div', {'staticClass' : [\"item-content\"]} , [_i((function () {return _vm.conditionVar===1}),function(){return _c('text', {'attrs' : {'value' : function () {return _vm.componentData.if}}} )}),_i((function () {return _vm.conditionVar===2&&!(_vm.conditionVar===1)}),function(){return _c('text', {'attrs' : {'value' : function () {return _vm.componentData.elif}}} )}),_i((function () {return !(_vm.conditionVar===2)&&!(_vm.conditionVar===1)}),function(){return _c('text', {'attrs' : {'value' : function () {return _vm.componentData.else}}} )})] ),_i((function () {return _vm.showTest}),function(){return _c('div', [_l((function () {return _vm.list}),function($item,$idx){return _c('div', [_c('text', {'attrs' : {'value' : function () {return ($idx) + decodeURI('.') + ($item.name)}}} )] )})] )}),_l((function () {return _vm.list}),function($item,$idx){return _c('div', [_i((function () {return _vm.showTest}),function(){return _c('div', [_c('text', {'attrs' : {'value' : function () {return ($idx) + decodeURI('.') + ($item.name)}}} )] )})] )}),_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', [_i((function () {return personIndex==1}),function(){return _c('div', [_c('text', {'attrs' : {'value' : function () {return personItem.name}}} )] )})] )})] ) }"}
|
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_i((function () {return _vm.conditionVar===1}),function(){return _c('text', {'attrs' : {'value' : function () {return _vm.componentData.if}}} )}),_c('div', {'staticClass' : [\"item-content\"]} , [_i((function () {return _vm.conditionVar===1}),function(){return _c('text', {'attrs' : {'value' : function () {return _vm.componentData.if}}} )}),_i((function () {return _vm.conditionVar===2&&!(_vm.conditionVar===1)}),function(){return _c('text', {'attrs' : {'value' : function () {return _vm.componentData.elif}}} )}),_i((function () {return !(_vm.conditionVar===2)&&!(_vm.conditionVar===1)}),function(){return _c('text', {'attrs' : {'value' : function () {return _vm.componentData.else}}} )})] ),_i((function () {return _vm.showTest}),function(){return _c('div', [_l((function () {return _vm.list}),function($item,$idx){return _c('div', [_c('text', {'attrs' : {'value' : function () {return ($idx) + decodeURI('.') + ($item.name)}}} )] )})] )}),_l((function () {return _vm.list}),function($item,$idx){return _c('div', [_i((function () {return _vm.showTest}),function(){return _c('div', [_c('text', {'attrs' : {'value' : function () {return ($idx) + decodeURI('.') + ($item.name)}}} )] )})] )}),_l((function () {return _vm.list}),function(personItem,personIndex){return _c('div', [_i((function () {return personIndex==1}),function(){return _c('div', [_c('text', {'attrs' : {'value' : function () {return personItem.name}}} )] )})] )})] ) }"}
|
@ -13,4 +13,4 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_c('div', {'staticStyle' : {'width' : 10}, } ),_c('div', {'dynamicStyle' :{'height' : function () {return _vm.num}}} ),_c('text', {'staticStyle' : {'color' : 13047173}, } ),_c('div', {'staticStyle' : {'color' : 14745599}, } ),_c('div', {'staticStyle' : {'animationDelay' : \"900ms\"}, } ),_c('div', {'staticStyle' : {'animationDuration' : \"200ms\"}, } ),_c('div', {'staticStyle' : {'animationIterationCount' : \"infinite\"}, } ),_c('div', {'staticStyle' : {'animationIterationCount' : 1000}, } ),_c('div', {'staticStyle' : {'backgroundImage' : \"url(/common/img/xmad.jpg)\"}, } ),_c('div', {'staticStyle' : {'backgroundImage' : \"url(/common/img/map.jpg)\"}, } )] ) }"}
|
{"render": "function (vm) { var _vm = vm || this; return _c('div', [_c('div', {'staticStyle' : {'width' : 10}, } ),_c('div', {'dynamicStyle' :{'height' : function () {return _vm.num}}} ),_c('text', {'staticStyle' : {'color' : 13047173}, } ),_c('div', {'staticStyle' : {'color' : 14745599}, } ),_c('div', {'staticStyle' : {'animationDelay' : \"900ms\"}, } ),_c('div', {'staticStyle' : {'animationDuration' : \"200ms\"}, } ),_c('div', {'staticStyle' : {'animationIterationCount' : \"infinite\"}, } ),_c('div', {'staticStyle' : {'animationIterationCount' : 1000}, } ),_c('div', {'staticStyle' : {'backgroundImage' : \"url(/common/img/xmad.jpg)\"}, } ),_c('div', {'staticStyle' : {'backgroundImage' : \"url(/common/img/map.jpg)\"}, } )] ) }"}
|
@ -1,20 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* distributed with this work for additional information
|
* you may not use this file except in compliance with the License.
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* You may obtain a copy of the License at
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); 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/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -12,3 +12,4 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* 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/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,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
@ -40,7 +40,7 @@ const richModule = {
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /(\.hml|app\.js|data\.js|service\.js)(\?[^?]+)?$/,
|
test: /(\.hml)(\?[^?]+)?$/,
|
||||||
use: [{
|
use: [{
|
||||||
loader: path.resolve(__dirname, './index.js')
|
loader: path.resolve(__dirname, './index.js')
|
||||||
}]
|
}]
|
||||||
@ -137,9 +137,32 @@ let config = {
|
|||||||
poll: false,
|
poll: false,
|
||||||
ignored: /node_modules/
|
ignored: /node_modules/
|
||||||
},
|
},
|
||||||
|
optimization: {
|
||||||
|
splitChunks: {
|
||||||
|
chunks: "all",
|
||||||
|
minSize: 0,
|
||||||
|
cacheGroups: {
|
||||||
|
vendors: {
|
||||||
|
test: /[\\/]node_modules[\\/]/,
|
||||||
|
priority: -10,
|
||||||
|
name: "vendors",
|
||||||
|
chunks: 'initial'
|
||||||
|
},
|
||||||
|
commons: {
|
||||||
|
test: /\.js|css|hml$/,
|
||||||
|
name: 'commons',
|
||||||
|
priority: -20,
|
||||||
|
minChunks: 2,
|
||||||
|
chunks: 'initial',
|
||||||
|
reuseExistingChunk: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]'
|
devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]',
|
||||||
|
globalObject: 'globalThis'
|
||||||
},
|
},
|
||||||
devtool: 'nosources-source-map',
|
devtool: 'nosources-source-map',
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
@ -164,7 +187,7 @@ function setConfigs(env) {
|
|||||||
process.env.aceManifestPath = process.env.aceManifestPath || path.resolve(process.env.projectPath, 'manifest.json');
|
process.env.aceManifestPath = process.env.aceManifestPath || path.resolve(process.env.projectPath, 'manifest.json');
|
||||||
process.env.abilityType = process.env.abilityType || 'page'
|
process.env.abilityType = process.env.abilityType || 'page'
|
||||||
process.env.DEVICE_LEVEL = process.env.DEVICE_LEVEL || 'rich'
|
process.env.DEVICE_LEVEL = process.env.DEVICE_LEVEL || 'rich'
|
||||||
if (process.env.abilityType === 'page') {
|
if (process.env.abilityType === 'page' || process.env.abilityType === 'form') {
|
||||||
const manifest = readManifest(process.env.aceManifestPath)
|
const manifest = readManifest(process.env.aceManifestPath)
|
||||||
process.env.DEVICE_LEVEL = manifest.type === 'form' ? 'card' : 'rich'
|
process.env.DEVICE_LEVEL = manifest.type === 'form' ? 'card' : 'rich'
|
||||||
process.env.PLATFORM_VERSION = PLATFORM.VERSION6;
|
process.env.PLATFORM_VERSION = PLATFORM.VERSION6;
|
||||||
@ -183,13 +206,6 @@ module.exports = (env) => {
|
|||||||
setConfigs(env)
|
setConfigs(env)
|
||||||
deleteFolderRecursive(process.env.buildPath);
|
deleteFolderRecursive(process.env.buildPath);
|
||||||
config.cache.cacheDirectory = path.resolve(process.env.cachePath, '.rich_cache');
|
config.cache.cacheDirectory = path.resolve(process.env.cachePath, '.rich_cache');
|
||||||
config.module.rules.push({
|
|
||||||
test: new RegExp("(" + (process.env.abilityType === 'page' ?
|
|
||||||
'app' : process.env.abilityType) + "\.js)(\\?[^?]+)?$"),
|
|
||||||
use: [{
|
|
||||||
loader: path.resolve(__dirname, './index.js')
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
config.entry = loadEntryObj(process.env.projectPath, process.env.DEVICE_LEVEL,
|
config.entry = loadEntryObj(process.env.projectPath, process.env.DEVICE_LEVEL,
|
||||||
process.env.abilityType, process.env.aceManifestPath)
|
process.env.abilityType, process.env.aceManifestPath)
|
||||||
config.output.path = path.resolve(__dirname, process.env.buildPath)
|
config.output.path = path.resolve(__dirname, process.env.buildPath)
|
||||||
@ -218,6 +234,17 @@ module.exports = (env) => {
|
|||||||
]
|
]
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
if (process.env.aceConfigPath && fs.existsSync(process.env.aceConfigPath)) {
|
||||||
|
config.plugins.push(new CopyPlugin({
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
from: path.resolve(process.env.aceConfigPath),
|
||||||
|
to: path.resolve(process.env.buildPath, 'config.json'),
|
||||||
|
noErrorOnMissing: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
}
|
||||||
if (process.env.DEVICE_LEVEL === 'card') {
|
if (process.env.DEVICE_LEVEL === 'card') {
|
||||||
config.module = cardModule
|
config.module = cardModule
|
||||||
config.plugins.push(new AfterEmitPlugin())
|
config.plugins.push(new AfterEmitPlugin())
|
||||||
@ -225,7 +252,11 @@ module.exports = (env) => {
|
|||||||
if (env.isPreview !== "true") {
|
if (env.isPreview !== "true") {
|
||||||
config.plugins.push(new ModuleCollectionPlugin())
|
config.plugins.push(new ModuleCollectionPlugin())
|
||||||
if (env.compilerType && env.compilerType === 'ark') {
|
if (env.compilerType && env.compilerType === 'ark') {
|
||||||
config.plugins.push(new GenAbcPlugin(process.env.buildPath, path.join(__dirname, 'bin'),
|
let arkDir = path.join(__dirname, 'bin', 'ark');
|
||||||
|
if (env.arkFrontendDir) {
|
||||||
|
arkDir = env.arkFrontendDir;
|
||||||
|
}
|
||||||
|
config.plugins.push(new GenAbcPlugin(process.env.buildPath, arkDir,
|
||||||
env.buildMode === 'debug'))
|
env.buildMode === 'debug'))
|
||||||
} else {
|
} else {
|
||||||
if (env.deviceType) {
|
if (env.deviceType) {
|
||||||
@ -267,5 +298,12 @@ module.exports = (env) => {
|
|||||||
config.output.sourceMapFilename = '_releaseMap/[name].js.map'
|
config.output.sourceMapFilename = '_releaseMap/[name].js.map'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
config.module.rules.push({
|
||||||
|
test: new RegExp("(" + (process.env.abilityType === 'page' ?
|
||||||
|
'app' : process.env.abilityType) + "\.js)(\\?[^?]+)?$"),
|
||||||
|
use: [{
|
||||||
|
loader: path.resolve(__dirname, './index.js')
|
||||||
|
}]
|
||||||
|
})
|
||||||
return config
|
return config
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user