From 8e08b9b69e7feae2050a4b1c9b939fea67200fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=9B=B9=E5=AE=87?= Date: Mon, 18 Aug 2025 11:50:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B9=E6=B3=95=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王曹宇 --- build-tools/delete_systemapi_plugin.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-tools/delete_systemapi_plugin.js b/build-tools/delete_systemapi_plugin.js index a482757f44..a2465b2826 100644 --- a/build-tools/delete_systemapi_plugin.js +++ b/build-tools/delete_systemapi_plugin.js @@ -48,8 +48,10 @@ const METHOD_KIND = [ ts.SyntaxKind.Constructor ]; +//正则匹配api节点的开头注释 const regJSDOCStr = `\\s*\\/\\*\\*(?:(?!\\/\\*\\*)[\\s\\S])*?`; +//.static.d.ets需要特殊处理的文件,及内部systemapi匹配正则表达式 const STATIC_API_DELETE_RULES = new Map([[ 'arkui/component/common.static.d.ets', [ `${regJSDOCStr}declare enum TransitionHierarchyStrategy.*ADAPTIVE = 1.*?\\n\\}.*?\\n`, @@ -70,6 +72,7 @@ const STATIC_API_DELETE_RULES = new Map([[ 'arkui/component/uiExtensionComponent.static.d.ets', []], [ 'arkui/component/xcomponent.static.d.ets', []]]); +// .static.d.ets需要特殊处理的文件,及内部特殊处理内容,包括整个文件删除和删除systemapi的import const STATIC_IMPORT_DELETE_RULES = new Map([[ 'arkui/component/common.static.d.ets', [{ reg: /(import\s*\{.*)IlluminatedType(,\s)?(.*from.*enums)/g, replaceValue: '$1$3' @@ -407,6 +410,7 @@ function tsTransform(utFiles, callback) { } /** + * 正则处理.static.d.ets文件 * * @param {string} url * @returns @@ -414,7 +418,7 @@ function tsTransform(utFiles, callback) { function processStaticFile(url) { const relativePath = path.relative(inputDir, url).replace(/\\/g, '/'); let content = fs.readFileSync(url, 'utf-8'); // 文件内容 - const regNodeList = STATIC_API_DELETE_RULES.get(relativePath); + const regNodeList = STATIC_API_DELETE_RULES.get(relativePath) || []; regNodeList.forEach(regRule => { const regSystemApi = new RegExp(regRule, 'sg'); content = content.replace(regSystemApi, '\n'); -- Gitee