miniprogram-ci 2.1.30 → 2.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/README.md +3 -0
- package/dist/@types/config/config.d.ts +1 -1
- package/dist/@types/modules/nativecompiler/processHandler.d.ts +5 -0
- package/dist/@types/utils/babel_plugin_worklet.d.ts +10 -1
- package/dist/@types/utils/subprocess/processManager.d.ts +1 -0
- package/dist/config/config.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/index.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/task/minifywxml.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
- package/dist/modules/nativecompiler/nativeEntryProcess.js +1 -1
- package/dist/modules/nativecompiler/processHandler.js +1 -0
- package/dist/utils/babel_plugin_worklet.js +1 -1
- package/dist/utils/debug.js +1 -1
- package/dist/utils/subprocess/processManager.js +1 -1
- package/package.json +5 -54
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,6 +7,9 @@ miniprogram-ci 是从[微信开发者工具](https://developers.weixin.qq.com/mi
|
|
|
7
7
|
miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,调用方式与普通开发模式无异。[查看详情](#第三方平台开发)
|
|
8
8
|
|
|
9
9
|
## 最近变更
|
|
10
|
+
#### 2.1.31
|
|
11
|
+
- `fix` 修复 去除 package.json devDependencies
|
|
12
|
+
- `fix` 修复 锁定 less 版本为 4.5.1
|
|
10
13
|
#### 2.1.30
|
|
11
14
|
- `new` 新增 允许 CI 构建多端 APK 时使用 beta 版本 SDK
|
|
12
15
|
#### 2.1.29
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MiniProgramDevtools } from '../../types';
|
|
2
|
+
export declare function initHandler(message: MiniProgramDevtools.InitMsg): Promise<void>;
|
|
3
|
+
export declare function destroy(): Promise<void>;
|
|
4
|
+
export declare const onMessage: (fn: (...args: any[]) => any) => void;
|
|
5
|
+
export declare function messageHandler(message: MiniProgramDevtools.SummerProcessMessage): Promise<void>;
|
|
@@ -4,7 +4,7 @@ declare const hash: any;
|
|
|
4
4
|
declare const transformSync: any;
|
|
5
5
|
declare const traverse: any;
|
|
6
6
|
declare const parse: any;
|
|
7
|
-
declare const
|
|
7
|
+
declare const nodePath: any;
|
|
8
8
|
declare const buildBindFunc: (func: any) => any;
|
|
9
9
|
declare const buildWorkletFunc: (func: any) => any;
|
|
10
10
|
declare const globals: Set<string>;
|
|
@@ -23,7 +23,16 @@ declare function buildWorkletString(t: any, fun: any, closureVariables: any, nam
|
|
|
23
23
|
declare function generateWorkletFactory(t: any, fun: any): any;
|
|
24
24
|
declare function removeWorkletDirective(fun: any): undefined;
|
|
25
25
|
declare function makeWorkletName(t: any, fun: any): any;
|
|
26
|
+
declare function extractWorkletData(t: any, fun: any, fileName: any): {
|
|
27
|
+
variables: any[];
|
|
28
|
+
closure: Map<any, any>;
|
|
29
|
+
closureGenerator: ClosureGenerator;
|
|
30
|
+
funString: any;
|
|
31
|
+
workletHash: any;
|
|
32
|
+
locationFileName: any;
|
|
33
|
+
};
|
|
26
34
|
declare function makeWorklet(t: any, fun: any, fileName: any): any;
|
|
35
|
+
declare function buildWorkletProperties(t: any, fun: any, fileName: any): any;
|
|
27
36
|
declare function processWorkletFunction(t: any, fun: any, fileName: any): void;
|
|
28
37
|
declare function processIfWorkletNode(t: any, fun: any, fileName: any): void;
|
|
29
38
|
declare const FUNCTIONLESS_FLAG = 1;
|
package/dist/config/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.1.
|
|
1
|
+
"use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.1.31",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.getDefaultIgnores=getDefaultIgnores,exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={})),function(e){e[e.Include=0]="Include",e[e.PackOptionsIgnore=1]="PackOptionsIgnore",e[e.AnalyseNoUse=2]="AnalyseNoUse",e[e.PartialCompileNoUse=3]="PartialCompileNoUse"}(EFilterCode=exports.EFilterCode||(exports.EFilterCode={})),exports.MAX_CODE_LENGTH=2048e3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.abortTask=exports.runTask=void 0;const tslib_1=require("tslib"),logger_1=require("../utils/logger"),workerManager_1=require("./workerManager"),childprocessManager_1=require("./childprocessManager"),index_1=tslib_1.__importDefault(require("./task/index")),env_1=require("../../../../utils/env");tslib_1.__exportStar(require("./config"),exports);const isDevtools=void 0!==(null===process||void 0===process?void 0:process.env.__nwjs);async function runTask(r,e,o=(()=>{})){var s;if(logger_1.logger.info("runTask",r,e.filePath),global.__MINIPROGRAM_CI_TEST__||"true"===(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.__MINIPROGRAM_CI_TEST__))return(0,index_1.default)(r,e);try{if((null===process||void 0===process?void 0:process.__nwjs)&&"wechatwebdevtools"===nw.App.manifest.appname)return await childprocessManager_1.childProcessManager.runTask(r,e,o);const s=(0,workerManager_1.getWorkerManager)(isDevtools);return await s.runTask(r,e,o)}catch(o){if(env_1.isWebIDE)throw o;if(o===workerManager_1.AbortEvent)throw o;if(logger_1.logger.error(`runTask ${r}, ${e.filePath} catch error ${o}`),o instanceof childprocessManager_1.ChildProcessCrashedError)throw new Error(`runTask ${r}, ${e.filePath} catch error ${o}`);return(0,index_1.default)(r,e)}}function abortTask(r){(0,workerManager_1.getWorkerManager)(isDevtools).abort(r)}exports.runTask=runTask,exports.abortTask=abortTask;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.abortTask=exports.runTask=void 0;const tslib_1=require("tslib"),logger_1=require("../utils/logger"),workerManager_1=require("./workerManager"),childprocessManager_1=require("./childprocessManager"),index_1=tslib_1.__importDefault(require("./task/index")),env_1=require("../../../../utils/env");tslib_1.__exportStar(require("./config"),exports);const isDevtools=void 0!==(null===process||void 0===process?void 0:process.env.__nwjs);async function runTask(r,e,o=(()=>{})){var s,a;if(logger_1.logger.info("runTask",r,e.filePath),global.__MINIPROGRAM_CI_TEST__||"true"===(null===(s=null===process||void 0===process?void 0:process.env)||void 0===s?void 0:s.__MINIPROGRAM_CI_TEST__))return(0,index_1.default)(r,e);try{if((null===process||void 0===process?void 0:process.__nwjs)&&"wechatwebdevtools"===nw.App.manifest.appname||(null===(a=null===process||void 0===process?void 0:process.versions)||void 0===a?void 0:a.electron))return await childprocessManager_1.childProcessManager.runTask(r,e,o);const s=(0,workerManager_1.getWorkerManager)(isDevtools);return await s.runTask(r,e,o)}catch(o){if(env_1.isWebIDE)throw o;if(o===workerManager_1.AbortEvent)throw o;if(logger_1.logger.error(`runTask ${r}, ${e.filePath} catch error ${o}`),o instanceof childprocessManager_1.ChildProcessCrashedError)throw new Error(`runTask ${r}, ${e.filePath} catch error ${o}`);return(0,index_1.default)(r,e)}}function abortTask(r){(0,workerManager_1.getWorkerManager)(isDevtools).abort(r)}exports.runTask=runTask,exports.abortTask=abortTask;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.minifyWXML=exports.StyleAttrValueTokenizer=exports.TemplateTokenizer=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),log=tslib_1.__importStar(require("../../../../../utils/log")),config_1=require("../../../../../config/config");function getCharCode(T){return T.charCodeAt(0)>=256?BASE_STATE.OTHERS:T.charCodeAt(0)}function trimStringLeft(T,E=!0){return E?T.trimLeft():T.split("\n").map(T=>T.replace(/^[ \t]*/g,"")).join("\n")}function trimStringRight(T,E=!0){return E?T.trimRight():T.split("\n").map(T=>T.replace(/[ \t]*$/,"")).join("\n")}var TokenType,BASE_STATE,STATE,TEMPLATE_STATE,STYLE_ATTR_VALUE_STATE,ACTION;!function(T){T[T.ATTR=0]="ATTR",T[T.TAG=1]="TAG",T[T.LEFT_ANGLE_BRACKET=2]="LEFT_ANGLE_BRACKET",T[T.RIGHT_ANGLE_BRACKET=3]="RIGHT_ANGLE_BRACKET",T[T.END_LEFT_ANGLE_BRACKET=4]="END_LEFT_ANGLE_BRACKET",T[T.STRING1=5]="STRING1",T[T.STRING2=6]="STRING2",T[T.ATTR_VALUE=7]="ATTR_VALUE",T[T.TEXT_VALUE=8]="TEXT_VALUE",T[T.TAG_TEXT_VALUE=9]="TAG_TEXT_VALUE",T[T.TEMPLATE_START=10]="TEMPLATE_START",T[T.TEMPLATE_END=11]="TEMPLATE_END",T[T.TEMPLATE_ITEM=12]="TEMPLATE_ITEM",T[T.TEMPLATE_STRING=13]="TEMPLATE_STRING",T[T.SELF_CLOSE=14]="SELF_CLOSE",T[T.WXS_VALUE=15]="WXS_VALUE",T[T.STYLE_KEY=16]="STYLE_KEY",T[T.TAG_EQ=17]="TAG_EQ",T[T.STYLE_VALUE=18]="STYLE_VALUE",T[T.STYLE_ATTR_VALUE=19]="STYLE_ATTR_VALUE",T[T.CLASS_ATTR_VALUE=20]="CLASS_ATTR_VALUE",T[T.OTHERS=21]="OTHERS"}(TokenType||(TokenType={})),function(T){T[T.ERROR=-1]="ERROR",T[T.NOT_SET=0]="NOT_SET",T[T.START=1]="START",T[T.OTHERS=2]="OTHERS",T[T.END=3]="END",T[T.MAX_STATE=4]="MAX_STATE"}(BASE_STATE||(BASE_STATE={})),function(T){T[T.IN_TAG_TEXT=5]="IN_TAG_TEXT",T[T.TAG_START=6]="TAG_START",T[T.IN_TAG_WORD=7]="IN_TAG_WORD",T[T.TAG_EQ=8]="TAG_EQ",T[T.IN_TAG_ATTR_WORD=9]="IN_TAG_ATTR_WORD",T[T.IN_TAG_ATTR_VALUE_STRING=10]="IN_TAG_ATTR_VALUE_STRING",T[T.IN_TAG_ATTR_VALUE_STRING_ESCAPE=11]="IN_TAG_ATTR_VALUE_STRING_ESCAPE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE=12]="IN_TAG_ATTR_VALUE_STRING_SINGLE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE=13]="IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE",T[T.WAIT_TEMPLATE_START=14]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=15]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=16]="WAIT_TEMPLATE_END",T[T.TEMPLATE_END_CHECK=17]="TEMPLATE_END_CHECK",T[T.IN_TEMPLATE_STRING=18]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=19]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=20]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=21]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_RIGHT_BRACKET=22]="WAIT_FOR_RIGHT_BRACKET",T[T.IN_WXS=23]="IN_WXS",T[T.IN_WXS_STRING=24]="IN_WXS_STRING",T[T.IN_WXS_STRING_ESCAPE=25]="IN_WXS_STRING_ESCAPE",T[T.IN_WXS_STRING_SINGLE=26]="IN_WXS_STRING_SINGLE",T[T.IN_WXS_STRING_SINGLE_ESCAPE=27]="IN_WXS_STRING_SINGLE_ESCAPE",T[T.WXS_END_STEP=28]="WXS_END_STEP",T[T.IN_COMMENT_BEGIN1=29]="IN_COMMENT_BEGIN1",T[T.IN_COMMENT_BEGIN2=30]="IN_COMMENT_BEGIN2",T[T.IN_COMMENT=31]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END1=32]="WAIT_FOR_COMMENT_END1",T[T.WAIT_FOR_COMMENT_END2=33]="WAIT_FOR_COMMENT_END2",T[T.IN_TEXT=34]="IN_TEXT",T[T.IN_END_TAG=35]="IN_END_TAG",T[T.IN_END_TAG_WORD=36]="IN_END_TAG_WORD",T[T.MAX_STATE=37]="MAX_STATE"}(STATE||(STATE={})),function(T){T[T.WAIT_TEMPLATE_START=5]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE_ITEM=6]="IN_TEMPLATE_ITEM",T[T.WAIT_TEMPLATE_END=7]="WAIT_TEMPLATE_END",T[T.SPACE_AFTER_WAIT_TEMPLATE_END=8]="SPACE_AFTER_WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=9]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=10]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=11]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=12]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=13]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=14]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=15]="WAIT_FOR_COMMENT_END",T[T.IN_TEMPLATE_SPACE=16]="IN_TEMPLATE_SPACE",T[T.MAX_STATE=17]="MAX_STATE"}(TEMPLATE_STATE||(TEMPLATE_STATE={})),function(T){T[T.WAIT_KEY=5]="WAIT_KEY",T[T.IN_KEY=6]="IN_KEY",T[T.WAIT_KEY_VALUE_SAPERATE=7]="WAIT_KEY_VALUE_SAPERATE",T[T.IN_KEY_VALUE_SAPERATE=8]="IN_KEY_VALUE_SAPERATE",T[T.WAIT_VALUE=9]="WAIT_VALUE",T[T.IN_VALUE=10]="IN_VALUE",T[T.WAIT_ITEM_SAPERATE=11]="WAIT_ITEM_SAPERATE",T[T.IN_ITEM_SAPERATE=12]="IN_ITEM_SAPERATE",T[T.IN_STRING=13]="IN_STRING",T[T.IN_STRING_ESCAPE=14]="IN_STRING_ESCAPE",T[T.IN_STRING2=15]="IN_STRING2",T[T.IN_STRING2_ESCAPE=16]="IN_STRING2_ESCAPE",T[T.WAIT_TEMPLATE_START=17]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=18]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=19]="WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=20]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=21]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=22]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=23]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=24]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=25]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=26]="WAIT_FOR_COMMENT_END",T[T.MAX_STATE=27]="MAX_STATE"}(STYLE_ATTR_VALUE_STATE||(STYLE_ATTR_VALUE_STATE={})),function(T){T[T.NOTHING=0]="NOTHING",T[T.DO_ACTION=65536]="DO_ACTION",T[T.STORE_TOKEN_EXCLUDE=131072]="STORE_TOKEN_EXCLUDE",T[T.STORE_TOKEN_INCLUDE=262144]="STORE_TOKEN_INCLUDE",T[T.IGNORE=524288]="IGNORE",T[T.REFEED=1048576]="REFEED",T[T.STORE_TOKEN_FIRST=2097152]="STORE_TOKEN_FIRST",T[T.STORE_ONE_SPACE=4194304]="STORE_ONE_SPACE",T[T.STORE_ONE_LINE_BREAK=8388608]="STORE_ONE_LINE_BREAK",T[T.GET_STATE_BEFORE=16777216]="GET_STATE_BEFORE",T[T.STORE_STATE_BEFORE=33554432]="STORE_STATE_BEFORE",T[T.SET_WXS_STATE=67108864]="SET_WXS_STATE",T[T.RECORD_IN_TEMPLATE_OBJECT=134217728]="RECORD_IN_TEMPLATE_OBJECT",T[T.CHECK_IN_TEMPLATE_OBJECT=268435456]="CHECK_IN_TEMPLATE_OBJECT"}(ACTION||(ACTION={}));class Token{constructor(T,E){this.type=T,this.value=E}}class MachineState{constructor(){this.cur_pos=0,this.last_pos=0,this.line=1,this.col=1,this.mark_pos=0,this.mark_col=0,this.last_line=this.line,this.last_col=1,this.state=BASE_STATE.START,this.in_template_object_count=0}}const ALPHA="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-:",DIGIT="0123456789.",WHITECHARS=" \n\t\r";class BaseMachine{constructor(T,E){this.mState=new MachineState,this.storedStates=[],this.oldState=BASE_STATE.START,this.tokens=[],this.mPath=T,this.mSrc=E}FillTT(T,E,_,A){for(const S of A)this.TT[T][getCharCode(S)]=E|_}Reset(){return this.mState.cur_pos=0,this.mState.last_pos=0,this.mState.mark_pos=0,this.mState.line=1,this.mState.col=1,this.mState.last_col=1,this.mState.mark_col=1,this.mState.last_line=this.mState.line,this.mState.state=BASE_STATE.START,0}refeed(T){let E=this.TT[this.mState.state][getCharCode(T)];if(E===BASE_STATE.NOT_SET&&(E=this.TT[this.mState.state][BASE_STATE.OTHERS]),E===BASE_STATE.NOT_SET)throw{col:this.mState.col,line:this.mState.line,message:"BAD STATE MACHINE!"};if(E<0){if("\0"!==T)throw{col:this.mState.col,line:this.mState.line,message:`unexpected character \`${T.replace(/\n/g,"\\n")}\``};throw{col:this.mState.col,line:this.mState.line,message:"unexpected end"}}const _=E,A=65535&E,S=this.mState.state;_&ACTION.STORE_STATE_BEFORE&&(this.storedStates.push(S),this.mState.mark_pos=this.mState.cur_pos,this.mState.mark_col=this.mState.mark_col),this.mState.state=A,this.doAction(T,S,_)}Feed(T){"\n"===T&&(this.mState.line++,this.mState.col=0),this.refeed(T)}FillTT_template_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[T][getCharCode(_)]=E,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}updatePosition(){this.mState.last_pos=this.mState.cur_pos,this.mState.last_col=this.mState.col,this.mState.last_line=this.mState.line}processPosition(){this.mState.cur_pos++,this.mState.col++}doAction(T,E,_){if(_&ACTION.STORE_TOKEN_FIRST&&this.mState.mark_pos>this.mState.last_pos){const T=this.mSrc.substring(this.mState.last_pos,this.mState.mark_pos);this.doExcludeAction(this.storedStates[this.storedStates.length-1],T),this.mState.last_pos=this.mState.mark_pos,this.mState.last_col=this.mState.mark_col}if(_&ACTION.STORE_ONE_LINE_BREAK&&(this.appendToken(TokenType.OTHERS,"\n"),this.updatePosition()),_&ACTION.STORE_ONE_SPACE&&(this.appendToken(TokenType.OTHERS," "),this.updatePosition()),_&ACTION.STORE_TOKEN_EXCLUDE){const T=this.mState.cur_pos,_=this.mState.last_pos;if(T>=_){const A=this.mSrc.substring(_,T);this.doExcludeAction(E,A),this.updatePosition()}}if(_&ACTION.RECORD_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count++,_&ACTION.CHECK_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count>0&&(this.mState.in_template_object_count--,this.mState.state=STATE.IN_TEMPLATE),_&ACTION.REFEED){if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}this.refeed(T)}else{if(this.processPosition(),_&ACTION.STORE_TOKEN_INCLUDE){const _=this.mSrc.substring(this.mState.last_pos,this.mState.cur_pos);this.doIncludeAction(T,E,_),this.updatePosition()}if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}}}}class StyleAttrValueMachine extends BaseMachine{get TT(){return StyleAttrValueMachine._TT||this.InitTransitTable(),StyleAttrValueMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){T===TokenType.STYLE_VALUE&&(E=E.replace(/[ \t]+/g," ")),this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STYLE_ATTR_VALUE_STATE.IN_KEY:_=TokenType.STYLE_KEY;break;case STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE:_=TokenType.OTHERS;break;case STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE:_=TokenType.OTHERS,E=";";break;case STYLE_ATTR_VALUE_STATE.IN_VALUE:_=TokenType.STYLE_VALUE}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case STYLE_ATTR_VALUE_STATE.IN_STRING:A=TokenType.STRING1;break;case STYLE_ATTR_VALUE_STATE.IN_STRING2:A=TokenType.STRING2;break;case STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_ITEM,_=new TemplateTokenizer(_,this.mPath).toString();break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START:this.doExcludeAction(this.storedStates[this.storedStates.length-1],_.replace(/\/\*$/,"")),A=TokenType.OTHERS,_="/*";break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END:A=TokenType.OTHERS,_="*/"}this.appendToken(A,_)}FillTT_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[T][getCharCode("\n")]=BASE_STATE.ERROR,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){StyleAttrValueMachine._TT=new Array(STYLE_ATTR_VALUE_STATE.MAX_STATE);for(let T=0;T<STYLE_ATTR_VALUE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode(":")]=BASE_STATE.ERROR,this.TT[BASE_STATE.START][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[BASE_STATE.START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.WAIT_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_VALUE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("\0")]=BASE_STATE.END,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("}")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.IGNORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.NOTHING,this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING,ACTION.GET_STATE_BEFORE,'"'),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING2,ACTION.GET_STATE_BEFORE,"'")}}class TemplateMachine extends BaseMachine{get TT(){return TemplateMachine._TT||this.InitTransitTable(),TemplateMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case TEMPLATE_STATE.IN_TEMPLATE_ITEM:case TEMPLATE_STATE.WAIT_TEMPLATE_END:_=TokenType.TEMPLATE_ITEM}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case TEMPLATE_STATE.WAIT_TEMPLATE_START:A=TokenType.TEMPLATE_START;break;case TEMPLATE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_END}this.appendToken(A,_)}InitTransitTable(){TemplateMachine._TT=new Array(TEMPLATE_STATE.MAX_STATE);for(let T=0;T<TEMPLATE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode("{")]=TEMPLATE_STATE.WAIT_TEMPLATE_START,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_SPACE,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("/")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_START,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_ITEM,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("\\")]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][0]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=TEMPLATE_STATE.IN_COMMENT,this.FillTT(TEMPLATE_STATE.WAIT_FOR_COMMENT_START,TEMPLATE_STATE.IN_TEMPLATE_ITEM,ACTION.REFEED," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_COMMENT][getCharCode("*")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_END,this.TT[TEMPLATE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_COMMENT,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=TEMPLATE_STATE.IN_TEMPLATE_SPACE|ACTION.IGNORE,this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,'"'),this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING2,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,"'"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=BASE_STATE.END|ACTION.STORE_TOKEN_INCLUDE,this.FillTT(TEMPLATE_STATE.WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.STORE_TOKEN_EXCLUDE," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.REFEED,this.FillTT(TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END|ACTION.STORE_ONE_SPACE,this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.IGNORE|ACTION.REFEED,this.FillTT(BASE_STATE.END,BASE_STATE.END,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.END][getCharCode("\0")]=BASE_STATE.END,this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.ERROR}}class TemplateTokenizer{constructor(T,E){this.machine=new TemplateMachine(E,T),this.m_pSrc=T,this.path=E}toString(){this.tokens||(this.tokens=this.generateTokens());return this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.TemplateTokenizer=TemplateTokenizer;class StyleAttrValueTokenizer{constructor(T,E){this.machine=new StyleAttrValueMachine(E,T),this.m_pSrc=T,this.path=E}toString(){return this.tokens||(this.tokens=this.generateTokens()),this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.StyleAttrValueTokenizer=StyleAttrValueTokenizer;class Machine extends BaseMachine{get TT(){return Machine._TT||this.InitTransitTable(),Machine._TT}constructor(T,E){super(T,E),this.tagStack=[],this.InitTransitTable(),this.mPath=T,this.mSrc=E}get wxsState(){return"wxs"===this.tagStack[this.tagStack.length-1]}get textState(){return"text"===this.tagStack[this.tagStack.length-1]}getTokens(){return[...this.tokens]}checkLastTokenIfTypeMatch(T){var E;return(null===(E=this.tokens[this.tokens.length-1])||void 0===E?void 0:E.type)===T?this.tokens[this.tokens.length-1]:void 0}getLastTokenIfTypeMatch(T){if(0!==this.tokens.length)for(let E=this.tokens.length-1;E>=0;E--){const _=this.tokens[E];if(_.type===T)return _}}canBeOmittedTokenType(T){return T===TokenType.WXS_VALUE}appendToken(T,E){if(this.canBeOmittedTokenType(T)&&(E=this.transTagTextTokenValue(E)),T===TokenType.ATTR_VALUE){const T=this.getLastTokenIfTypeMatch(TokenType.ATTR);"style"===(null==T?void 0:T.value)&&(E=this.trySlimStyleAttrValue(E))}E&&this.tokens.push(new Token(T,E))}transTagTextTokenValue(T){return this.wxsState?T=T.split("\n").map(T=>T.trim()).join("\n"):T}trySlimStyleAttrValue(T){const E=[];try{if(T.length<=1)return T;for(let T=this.tokens.length-1;T>=0;T--){if(this.tokens[T].type===TokenType.TAG_EQ)break;E.unshift(this.tokens.pop())}const _=`${E.map(T=>null==T?void 0:T.value).join("")}${T}`,A=_.startsWith('"')||_.startsWith("'"),S=_.endsWith('"')||_.endsWith("'"),t=new StyleAttrValueTokenizer(_.replace(/^['"]/,"").replace(/['"]$/,""),this.mPath).toString();return`${A?_.substr(0,1):""}${t}${S?_.substr(_.length-1,1):""}`}catch(T){this.tokens.push(...E)}return T}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STATE.IN_TAG_ATTR_VALUE_STRING:case STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE:_=TokenType.ATTR_VALUE;break;case STATE.IN_TAG_WORD:_=TokenType.TAG,this.tagStack.push(E);break;case STATE.IN_END_TAG_WORD:_=TokenType.TAG;if(this.tagStack.pop()!==E)throw{col:this.mState.col-E.length,line:this.mState.line,message:"unexpected end tag: "+E};break;case STATE.IN_WXS:_=TokenType.WXS_VALUE;break;case STATE.IN_TEXT:_=TokenType.TEXT_VALUE;break;case STATE.IN_TAG_TEXT:_=TokenType.TAG_TEXT_VALUE;break;case STATE.IN_TAG_ATTR_WORD:_=TokenType.ATTR;break;case STATE.TAG_START:_=TokenType.LEFT_ANGLE_BRACKET;break;case STATE.IN_TEMPLATE:_=TokenType.TEMPLATE_ITEM;break;case STATE.TAG_EQ:_=TokenType.TAG_EQ;break;case STATE.TEMPLATE_END_CHECK:{const T=this.mState.cur_pos;if("}"===this.mSrc.substring(T-3,T-2))throw{col:this.mState.col-3,line:this.mState.line,message:"unexpected end tag: }. } should not be followed by }} direactly, add a space and change it to } }}"};this.appendToken(TokenType.TEMPLATE_ITEM,""+new TemplateTokenizer(E,this.mPath)),_=TokenType.TEMPLATE_END,E=""}}this.appendToken(_,E)}doIncludeAction(T,E,_){const A=this.mState.state;let S;E===STATE.WXS_END_STEP?(this.appendToken(TokenType.WXS_VALUE,_.substr(0,_.length-2)),S=TokenType.END_LEFT_ANGLE_BRACKET,_="</"):E===STATE.IN_WXS_STRING||E===STATE.IN_WXS_STRING_SINGLE?S=TokenType.WXS_VALUE:E===STATE.IN_TAG_ATTR_VALUE_STRING||E===STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE?S=TokenType.ATTR_VALUE:E===STATE.TAG_START&&A===STATE.IN_END_TAG?S=TokenType.END_LEFT_ANGLE_BRACKET:E===STATE.WAIT_FOR_RIGHT_BRACKET?(S=TokenType.SELF_CLOSE,this.tagStack.pop()):S=TokenType.OTHERS,">"!==T||E!==STATE.IN_TAG_WORD&&E!==STATE.IN_TAG_ATTR_WORD&&E!==STATE.IN_TAG_ATTR_VALUE_STRING&&E!==STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE&&E!==STATE.IN_END_TAG_WORD||(S=TokenType.RIGHT_ANGLE_BRACKET),this.appendToken(S,_)}Feed(T){super.Feed(T),this.wxsState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_WXS),this.textState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_TEXT)}FillTT_attr_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[T][getCharCode("\n")]=BASE_STATE.ERROR,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){Machine._TT=new Array(STATE.MAX_STATE);for(let T=0;T<STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.TT[BASE_STATE.START][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[BASE_STATE.START][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[STATE.IN_TAG_TEXT][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT,this.TT[STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.GET_STATE_BEFORE,this.TT[STATE.IN_TEMPLATE][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.RECORD_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("}")]=STATE.WAIT_TEMPLATE_END|ACTION.CHECK_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TEMPLATE,STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE,this.TT[STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STATE.WAIT_TEMPLATE_END][getCharCode("}")]=STATE.TEMPLATE_END_CHECK,this.TT[STATE.TEMPLATE_END_CHECK][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STATE.IN_TEMPLATE][getCharCode('"')]=STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STATE.IN_TEMPLATE][getCharCode("'")]=STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.FillTT_template_string(STATE.IN_TEMPLATE_STRING,STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STATE.IN_TEMPLATE_STRING2,STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT(STATE.TAG_START,STATE.TAG_START,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_START,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_START][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.TAG_START][getCharCode("!")]=STATE.IN_COMMENT_BEGIN1,this.TT[STATE.TAG_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN1][getCharCode("-")]=STATE.IN_COMMENT_BEGIN2,this.TT[STATE.IN_COMMENT_BEGIN1][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN2][getCharCode("-")]=STATE.IN_COMMENT,this.TT[STATE.IN_COMMENT_BEGIN2][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END1,this.TT[STATE.IN_COMMENT][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END1][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END1][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.IGNORE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END2][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("=")]=STATE.TAG_EQ|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.TAG_EQ,STATE.TAG_EQ,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_EQ,STATE.IN_TAG_ATTR_VALUE_STRING,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_EQ][getCharCode('"')]=STATE.IN_TAG_ATTR_VALUE_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][getCharCode("'")]=STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][0]=BASE_STATE.ERROR,this.TT[STATE.TAG_EQ][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG,ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG,BASE_STATE.ERROR,ACTION.NOTHING,DIGIT),this.TT[STATE.IN_END_TAG][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_END_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_END_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.WAIT_FOR_RIGHT_BRACKET,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING,STATE.IN_TAG_ATTR_WORD,'"'),this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE,STATE.IN_TAG_ATTR_WORD,"'"),this.TT[STATE.IN_WXS][getCharCode("<")]=STATE.WXS_END_STEP,this.TT[STATE.IN_WXS][getCharCode('"')]=STATE.IN_WXS_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_WXS][getCharCode("'")]=STATE.IN_WXS_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT_attr_string(STATE.IN_WXS_STRING,STATE.IN_WXS,'"'),this.FillTT_attr_string(STATE.IN_WXS_STRING_SINGLE,STATE.IN_WXS,"'"),this.TT[STATE.IN_WXS][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.WXS_END_STEP][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WXS_END_STEP][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.IN_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TEXT][BASE_STATE.OTHERS]=STATE.IN_TEXT,this.TT[STATE.IN_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE}}class Tokenizer{constructor(T,E){this.machine=new Machine(E,T),this.m_pSrc=T,this.path=E}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];try{for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}this.machine.Feed("\0")}catch(T){throw new Error(`${T.line}:${T.col}:${T.message}`)}return this.machine.getTokens()}}function generateWXMLFromTokens(T,E={collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1}){const{collapseWhitespace:_,conservativeCollapse:A,preserveLineBreaks:S}=E,t=[];for(let E=0;E<T.length;E++){const e=T[E];let N=e.value;const R=e.type;if(R===TokenType.ATTR&&(N=" "+N),R===TokenType.TAG_TEXT_VALUE){S||(N=N.replace(/\n/g," ")),_&&(N=N.replace(/([ \t])+/g," "));const t=T[E-1];t&&t.type!==TokenType.RIGHT_ANGLE_BRACKET&&t.type!==TokenType.SELF_CLOSE||_&&!A&&(N=trimStringLeft(N,!1)),(null==t?void 0:t.type)===TokenType.TAG_TEXT_VALUE&&((null==t?void 0:t.value.endsWith(" "))||(null==t?void 0:t.value.endsWith("\n")))&&_&&(N=trimStringLeft(N,!1))}if(R===TokenType.LEFT_ANGLE_BRACKET||R===TokenType.END_LEFT_ANGLE_BRACKET){const S=T[E-1];if((null==S?void 0:S.type)===TokenType.TAG_TEXT_VALUE&&_&&!A){const T=t.pop()||"";t.push(trimStringRight(T,!1))}}t.push(N)}return t.join("")}async function minifyWXML(T){const{filePath:E,root:_=""}=T,A=T.code instanceof Buffer?T.code.toString():T.code,S=Object.assign({collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1},T.setting),t=path_1.default.posix.join(_,E);if(A.length>0)try{const T=new Tokenizer(A.replace(/\r\n/g,"\n"),t);return{error:null,code:generateWXMLFromTokens(T.generateTokens(),S)}}catch(T){return log.error("minifywxml error @ "+t),log.error(T.message),{error:{code:config_1.MINIFY_WXML_ERR,path:t,message:T.message}}}return{error:null,code:A.replace(/\r\n/g,"\n")}}exports.minifyWXML=minifyWXML;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.minifyWXML=exports.StyleAttrValueTokenizer=exports.TemplateTokenizer=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),log=tslib_1.__importStar(require("../../../../../utils/log")),config_1=require("../../../../../config/config");function getCharCode(T){return T.charCodeAt(0)>=256?BASE_STATE.OTHERS:T.charCodeAt(0)}function trimStringLeft(T,E=!0){return E?T.trimLeft():T.split("\n").map(T=>T.replace(/^[ \t]*/g,"")).join("\n")}function trimStringRight(T,E=!0){return E?T.trimRight():T.split("\n").map(T=>T.replace(/[ \t]*$/,"")).join("\n")}var TokenType,BASE_STATE,STATE,TEMPLATE_STATE,STYLE_ATTR_VALUE_STATE,ACTION;!function(T){T[T.ATTR=0]="ATTR",T[T.TAG=1]="TAG",T[T.LEFT_ANGLE_BRACKET=2]="LEFT_ANGLE_BRACKET",T[T.RIGHT_ANGLE_BRACKET=3]="RIGHT_ANGLE_BRACKET",T[T.END_LEFT_ANGLE_BRACKET=4]="END_LEFT_ANGLE_BRACKET",T[T.STRING1=5]="STRING1",T[T.STRING2=6]="STRING2",T[T.ATTR_VALUE=7]="ATTR_VALUE",T[T.TEXT_VALUE=8]="TEXT_VALUE",T[T.TAG_TEXT_VALUE=9]="TAG_TEXT_VALUE",T[T.TEMPLATE_START=10]="TEMPLATE_START",T[T.TEMPLATE_END=11]="TEMPLATE_END",T[T.TEMPLATE_ITEM=12]="TEMPLATE_ITEM",T[T.TEMPLATE_STRING=13]="TEMPLATE_STRING",T[T.SELF_CLOSE=14]="SELF_CLOSE",T[T.WXS_VALUE=15]="WXS_VALUE",T[T.STYLE_KEY=16]="STYLE_KEY",T[T.TAG_EQ=17]="TAG_EQ",T[T.STYLE_VALUE=18]="STYLE_VALUE",T[T.STYLE_ATTR_VALUE=19]="STYLE_ATTR_VALUE",T[T.CLASS_ATTR_VALUE=20]="CLASS_ATTR_VALUE",T[T.OTHERS=21]="OTHERS"}(TokenType||(TokenType={})),function(T){T[T.ERROR=-1]="ERROR",T[T.NOT_SET=0]="NOT_SET",T[T.START=1]="START",T[T.OTHERS=2]="OTHERS",T[T.END=3]="END",T[T.MAX_STATE=4]="MAX_STATE"}(BASE_STATE||(BASE_STATE={})),function(T){T[T.IN_TAG_TEXT=5]="IN_TAG_TEXT",T[T.TAG_START=6]="TAG_START",T[T.IN_TAG_WORD=7]="IN_TAG_WORD",T[T.TAG_EQ=8]="TAG_EQ",T[T.IN_TAG_ATTR_WORD=9]="IN_TAG_ATTR_WORD",T[T.IN_TAG_ATTR_VALUE_STRING=10]="IN_TAG_ATTR_VALUE_STRING",T[T.IN_TAG_ATTR_VALUE_STRING_ESCAPE=11]="IN_TAG_ATTR_VALUE_STRING_ESCAPE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE=12]="IN_TAG_ATTR_VALUE_STRING_SINGLE",T[T.IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE=13]="IN_TAG_ATTR_VALUE_STRING_SINGLE_ESCAPE",T[T.WAIT_TEMPLATE_START=14]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=15]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=16]="WAIT_TEMPLATE_END",T[T.TEMPLATE_END_CHECK=17]="TEMPLATE_END_CHECK",T[T.IN_TEMPLATE_STRING=18]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=19]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=20]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=21]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_RIGHT_BRACKET=22]="WAIT_FOR_RIGHT_BRACKET",T[T.IN_WXS=23]="IN_WXS",T[T.IN_WXS_STRING=24]="IN_WXS_STRING",T[T.IN_WXS_STRING_ESCAPE=25]="IN_WXS_STRING_ESCAPE",T[T.IN_WXS_STRING_SINGLE=26]="IN_WXS_STRING_SINGLE",T[T.IN_WXS_STRING_SINGLE_ESCAPE=27]="IN_WXS_STRING_SINGLE_ESCAPE",T[T.WXS_END_STEP=28]="WXS_END_STEP",T[T.IN_COMMENT_BEGIN1=29]="IN_COMMENT_BEGIN1",T[T.IN_COMMENT_BEGIN2=30]="IN_COMMENT_BEGIN2",T[T.IN_COMMENT=31]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END1=32]="WAIT_FOR_COMMENT_END1",T[T.WAIT_FOR_COMMENT_END2=33]="WAIT_FOR_COMMENT_END2",T[T.IN_TEXT=34]="IN_TEXT",T[T.IN_END_TAG=35]="IN_END_TAG",T[T.IN_END_TAG_WORD=36]="IN_END_TAG_WORD",T[T.MAX_STATE=37]="MAX_STATE"}(STATE||(STATE={})),function(T){T[T.WAIT_TEMPLATE_START=5]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE_ITEM=6]="IN_TEMPLATE_ITEM",T[T.WAIT_TEMPLATE_END=7]="WAIT_TEMPLATE_END",T[T.SPACE_AFTER_WAIT_TEMPLATE_END=8]="SPACE_AFTER_WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=9]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=10]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=11]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=12]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=13]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=14]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=15]="WAIT_FOR_COMMENT_END",T[T.IN_TEMPLATE_SPACE=16]="IN_TEMPLATE_SPACE",T[T.MAX_STATE=17]="MAX_STATE"}(TEMPLATE_STATE||(TEMPLATE_STATE={})),function(T){T[T.WAIT_KEY=5]="WAIT_KEY",T[T.IN_KEY=6]="IN_KEY",T[T.WAIT_KEY_VALUE_SAPERATE=7]="WAIT_KEY_VALUE_SAPERATE",T[T.IN_KEY_VALUE_SAPERATE=8]="IN_KEY_VALUE_SAPERATE",T[T.WAIT_VALUE=9]="WAIT_VALUE",T[T.IN_VALUE=10]="IN_VALUE",T[T.WAIT_ITEM_SAPERATE=11]="WAIT_ITEM_SAPERATE",T[T.IN_ITEM_SAPERATE=12]="IN_ITEM_SAPERATE",T[T.IN_STRING=13]="IN_STRING",T[T.IN_STRING_ESCAPE=14]="IN_STRING_ESCAPE",T[T.IN_STRING2=15]="IN_STRING2",T[T.IN_STRING2_ESCAPE=16]="IN_STRING2_ESCAPE",T[T.WAIT_TEMPLATE_START=17]="WAIT_TEMPLATE_START",T[T.IN_TEMPLATE=18]="IN_TEMPLATE",T[T.WAIT_TEMPLATE_END=19]="WAIT_TEMPLATE_END",T[T.IN_TEMPLATE_STRING=20]="IN_TEMPLATE_STRING",T[T.IN_TEMPLATE_STRING_ESCAPE=21]="IN_TEMPLATE_STRING_ESCAPE",T[T.IN_TEMPLATE_STRING2=22]="IN_TEMPLATE_STRING2",T[T.IN_TEMPLATE_STRING2_ESCAPE=23]="IN_TEMPLATE_STRING2_ESCAPE",T[T.WAIT_FOR_COMMENT_START=24]="WAIT_FOR_COMMENT_START",T[T.IN_COMMENT=25]="IN_COMMENT",T[T.WAIT_FOR_COMMENT_END=26]="WAIT_FOR_COMMENT_END",T[T.MAX_STATE=27]="MAX_STATE"}(STYLE_ATTR_VALUE_STATE||(STYLE_ATTR_VALUE_STATE={})),function(T){T[T.NOTHING=0]="NOTHING",T[T.DO_ACTION=65536]="DO_ACTION",T[T.STORE_TOKEN_EXCLUDE=131072]="STORE_TOKEN_EXCLUDE",T[T.STORE_TOKEN_INCLUDE=262144]="STORE_TOKEN_INCLUDE",T[T.IGNORE=524288]="IGNORE",T[T.REFEED=1048576]="REFEED",T[T.STORE_TOKEN_FIRST=2097152]="STORE_TOKEN_FIRST",T[T.STORE_ONE_SPACE=4194304]="STORE_ONE_SPACE",T[T.STORE_ONE_LINE_BREAK=8388608]="STORE_ONE_LINE_BREAK",T[T.GET_STATE_BEFORE=16777216]="GET_STATE_BEFORE",T[T.STORE_STATE_BEFORE=33554432]="STORE_STATE_BEFORE",T[T.SET_WXS_STATE=67108864]="SET_WXS_STATE",T[T.RECORD_IN_TEMPLATE_OBJECT=134217728]="RECORD_IN_TEMPLATE_OBJECT",T[T.CHECK_IN_TEMPLATE_OBJECT=268435456]="CHECK_IN_TEMPLATE_OBJECT"}(ACTION||(ACTION={}));class Token{constructor(T,E){this.type=T,this.value=E}}class MachineState{constructor(){this.cur_pos=0,this.last_pos=0,this.line=1,this.col=1,this.mark_pos=0,this.mark_col=0,this.last_line=this.line,this.last_col=1,this.state=BASE_STATE.START,this.in_template_object_count=0}}const ALPHA="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-:",DIGIT="0123456789.",WHITECHARS=" \n\t\r";class BaseMachine{constructor(T,E){this.mState=new MachineState,this.storedStates=[],this.oldState=BASE_STATE.START,this.tokens=[],this.mPath=T,this.mSrc=E}FillTT(T,E,_,A){for(const S of A)this.TT[T][getCharCode(S)]=E|_}Reset(){return this.mState.cur_pos=0,this.mState.last_pos=0,this.mState.mark_pos=0,this.mState.line=1,this.mState.col=1,this.mState.last_col=1,this.mState.mark_col=1,this.mState.last_line=this.mState.line,this.mState.state=BASE_STATE.START,0}refeed(T){let E=this.TT[this.mState.state][getCharCode(T)];if(E===BASE_STATE.NOT_SET&&(E=this.TT[this.mState.state][BASE_STATE.OTHERS]),E===BASE_STATE.NOT_SET)throw{col:this.mState.col,line:this.mState.line,message:"BAD STATE MACHINE!"};if(E<0){if("\0"!==T)throw{col:this.mState.col,line:this.mState.line,message:`unexpected character \`${T.replace(/\n/g,"\\n")}\``};throw{col:this.mState.col,line:this.mState.line,message:"unexpected end"}}const _=E,A=65535&E,S=this.mState.state;_&ACTION.STORE_STATE_BEFORE&&(this.storedStates.push(S),this.mState.mark_pos=this.mState.cur_pos,this.mState.mark_col=this.mState.mark_col),this.mState.state=A,this.doAction(T,S,_)}Feed(T){"\n"===T&&(this.mState.line++,this.mState.col=0),this.refeed(T)}FillTT_template_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[T][getCharCode(_)]=E,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}updatePosition(){this.mState.last_pos=this.mState.cur_pos,this.mState.last_col=this.mState.col,this.mState.last_line=this.mState.line}processPosition(){this.mState.cur_pos++,this.mState.col++}doAction(T,E,_){if(_&ACTION.STORE_TOKEN_FIRST&&this.mState.mark_pos>this.mState.last_pos){const T=this.mSrc.substring(this.mState.last_pos,this.mState.mark_pos);this.doExcludeAction(this.storedStates[this.storedStates.length-1],T),this.mState.last_pos=this.mState.mark_pos,this.mState.last_col=this.mState.mark_col}if(_&ACTION.STORE_ONE_LINE_BREAK&&(this.appendToken(TokenType.OTHERS,"\n"),this.updatePosition()),_&ACTION.STORE_ONE_SPACE&&(this.appendToken(TokenType.OTHERS," "),this.updatePosition()),_&ACTION.STORE_TOKEN_EXCLUDE){const T=this.mState.cur_pos,_=this.mState.last_pos;if(T>=_){const A=this.mSrc.substring(_,T);this.doExcludeAction(E,A),this.updatePosition()}}if(_&ACTION.RECORD_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count++,_&ACTION.CHECK_IN_TEMPLATE_OBJECT&&this.mState.in_template_object_count>0&&(this.mState.in_template_object_count--,this.mState.state=STATE.IN_TEMPLATE),_&ACTION.REFEED){if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}this.refeed(T)}else{if(this.processPosition(),_&ACTION.STORE_TOKEN_INCLUDE){const _=this.mSrc.substring(this.mState.last_pos,this.mState.cur_pos);this.doIncludeAction(T,E,_),this.updatePosition()}if(_&ACTION.IGNORE&&this.updatePosition(),_&ACTION.GET_STATE_BEFORE){const T=this.storedStates.pop();T&&(this.mState.state=T)}}}}class StyleAttrValueMachine extends BaseMachine{get TT(){return StyleAttrValueMachine._TT||this.InitTransitTable(),StyleAttrValueMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){T===TokenType.STYLE_VALUE&&(E=E.replace(/[ \t]+/g," ")),this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STYLE_ATTR_VALUE_STATE.IN_KEY:_=TokenType.STYLE_KEY;break;case STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE:_=TokenType.OTHERS;break;case STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE:_=TokenType.OTHERS,E=";";break;case STYLE_ATTR_VALUE_STATE.IN_VALUE:_=TokenType.STYLE_VALUE}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case STYLE_ATTR_VALUE_STATE.IN_STRING:A=TokenType.STRING1;break;case STYLE_ATTR_VALUE_STATE.IN_STRING2:A=TokenType.STRING2;break;case STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_ITEM,_=new TemplateTokenizer(_,this.mPath).toString();break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START:this.doExcludeAction(this.storedStates[this.storedStates.length-1],_.replace(/\/\*$/,"")),A=TokenType.OTHERS,_="/*";break;case STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END:A=TokenType.OTHERS,_="*/"}this.appendToken(A,_)}FillTT_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[T][getCharCode("\n")]=BASE_STATE.ERROR,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){StyleAttrValueMachine._TT=new Array(STYLE_ATTR_VALUE_STATE.MAX_STATE);for(let T=0;T<STYLE_ATTR_VALUE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode(":")]=BASE_STATE.ERROR,this.TT[BASE_STATE.START][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[BASE_STATE.START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.WAIT_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(":")]=STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.IN_KEY_VALUE_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT(STYLE_ATTR_VALUE_STATE.WAIT_VALUE,STYLE_ATTR_VALUE_STATE.WAIT_VALUE,ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(":")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_VALUE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("\0")]=BASE_STATE.END,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_VALUE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_VALUE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE,STYLE_ATTR_VALUE_STATE.WAIT_KEY,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode(";")]=STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("'")]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("\0")]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.IN_ITEM_SAPERATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.IN_KEY|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_START][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("}")]=STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_TEMPLATE_END][getCharCode("/")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START|ACTION.STORE_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode('"')]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.IN_TEMPLATE][getCharCode("'")]=STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=ACTION.GET_STATE_BEFORE,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][getCharCode("*")]=STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END,this.TT[STYLE_ATTR_VALUE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.IGNORE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=ACTION.GET_STATE_BEFORE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STYLE_ATTR_VALUE_STATE.WAIT_FOR_COMMENT_END][BASE_STATE.OTHERS]=STYLE_ATTR_VALUE_STATE.IN_COMMENT|ACTION.NOTHING,this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STYLE_ATTR_VALUE_STATE.IN_TEMPLATE_STRING2,STYLE_ATTR_VALUE_STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING,ACTION.GET_STATE_BEFORE,'"'),this.FillTT_string(STYLE_ATTR_VALUE_STATE.IN_STRING2,ACTION.GET_STATE_BEFORE,"'")}}class TemplateMachine extends BaseMachine{get TT(){return TemplateMachine._TT||this.InitTransitTable(),TemplateMachine._TT}constructor(T,E){super(T,E),this.mState.state=BASE_STATE.START}getTokens(){return[...this.tokens]}appendToken(T,E){this.tokens.push(new Token(T,E))}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case TEMPLATE_STATE.IN_TEMPLATE_ITEM:case TEMPLATE_STATE.WAIT_TEMPLATE_END:_=TokenType.TEMPLATE_ITEM}this.appendToken(_,E)}doIncludeAction(T,E,_){let A=TokenType.OTHERS;switch(E){case TEMPLATE_STATE.WAIT_TEMPLATE_START:A=TokenType.TEMPLATE_START;break;case TEMPLATE_STATE.WAIT_TEMPLATE_END:A=TokenType.TEMPLATE_END}this.appendToken(A,_)}InitTransitTable(){TemplateMachine._TT=new Array(TEMPLATE_STATE.MAX_STATE);for(let T=0;T<TEMPLATE_STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.FillTT(BASE_STATE.START,BASE_STATE.START,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.START][getCharCode("{")]=TEMPLATE_STATE.WAIT_TEMPLATE_START,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][getCharCode("{")]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE,this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_SPACE,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][getCharCode("/")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_START,this.TT[TEMPLATE_STATE.IN_TEMPLATE_SPACE][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.FillTT(TEMPLATE_STATE.IN_TEMPLATE_ITEM,TEMPLATE_STATE.IN_TEMPLATE_SPACE,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("\\")]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode('"')]=TEMPLATE_STATE.IN_TEMPLATE_STRING|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][getCharCode("'")]=TEMPLATE_STATE.IN_TEMPLATE_STRING2|ACTION.STORE_STATE_BEFORE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_TEMPLATE_ITEM][0]=BASE_STATE.ERROR,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][getCharCode("*")]=TEMPLATE_STATE.IN_COMMENT,this.FillTT(TEMPLATE_STATE.WAIT_FOR_COMMENT_START,TEMPLATE_STATE.IN_TEMPLATE_ITEM,ACTION.REFEED," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_START][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM,this.TT[TEMPLATE_STATE.IN_COMMENT][getCharCode("*")]=TEMPLATE_STATE.WAIT_FOR_COMMENT_END,this.TT[TEMPLATE_STATE.IN_COMMENT][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_COMMENT,this.TT[TEMPLATE_STATE.WAIT_FOR_COMMENT_END][getCharCode("/")]=TEMPLATE_STATE.IN_TEMPLATE_SPACE|ACTION.IGNORE,this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,'"'),this.FillTT_template_string(TEMPLATE_STATE.IN_TEMPLATE_STRING2,TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.STORE_TOKEN_INCLUDE|ACTION.GET_STATE_BEFORE,"'"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][getCharCode("}")]=BASE_STATE.END|ACTION.STORE_TOKEN_INCLUDE,this.FillTT(TEMPLATE_STATE.WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.STORE_TOKEN_EXCLUDE," \n\t\r"),this.TT[TEMPLATE_STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.REFEED,this.FillTT(TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END,ACTION.IGNORE," \n\t\r"),this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][getCharCode("}")]=TEMPLATE_STATE.WAIT_TEMPLATE_END|ACTION.STORE_ONE_SPACE,this.TT[TEMPLATE_STATE.SPACE_AFTER_WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=TEMPLATE_STATE.IN_TEMPLATE_ITEM|ACTION.IGNORE|ACTION.REFEED,this.FillTT(BASE_STATE.END,BASE_STATE.END,ACTION.IGNORE," \n\t\r"),this.TT[BASE_STATE.END][getCharCode("\0")]=BASE_STATE.END,this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.ERROR}}class TemplateTokenizer{constructor(T,E){this.machine=new TemplateMachine(E,T),this.m_pSrc=T,this.path=E}toString(){this.tokens||(this.tokens=this.generateTokens());return this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.TemplateTokenizer=TemplateTokenizer;class StyleAttrValueTokenizer{constructor(T,E){this.machine=new StyleAttrValueMachine(E,T),this.m_pSrc=T,this.path=E}toString(){return this.tokens||(this.tokens=this.generateTokens()),this.tokens.map(T=>T.value).join("")}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}return this.machine.Feed("\0"),this.machine.getTokens()}}exports.StyleAttrValueTokenizer=StyleAttrValueTokenizer;class Machine extends BaseMachine{get TT(){return Machine._TT||this.InitTransitTable(),Machine._TT}constructor(T,E){super(T,E),this.tagStack=[],this.InitTransitTable(),this.mPath=T,this.mSrc=E}get wxsState(){return"wxs"===this.tagStack[this.tagStack.length-1]}get textState(){return"text"===this.tagStack[this.tagStack.length-1]}getTokens(){return[...this.tokens]}checkLastTokenIfTypeMatch(T){var E;return(null===(E=this.tokens[this.tokens.length-1])||void 0===E?void 0:E.type)===T?this.tokens[this.tokens.length-1]:void 0}getLastTokenIfTypeMatch(T){if(0!==this.tokens.length)for(let E=this.tokens.length-1;E>=0;E--){const _=this.tokens[E];if(_.type===T)return _}}canBeOmittedTokenType(T){return T===TokenType.WXS_VALUE}appendToken(T,E){if(this.canBeOmittedTokenType(T)&&(E=this.transTagTextTokenValue(E)),T===TokenType.ATTR_VALUE){const T=this.getLastTokenIfTypeMatch(TokenType.ATTR);"style"===(null==T?void 0:T.value)&&(E=this.trySlimStyleAttrValue(E))}E&&this.tokens.push(new Token(T,E))}transTagTextTokenValue(T){return this.wxsState?T=T.split("\n").map(T=>T.trim()).join("\n"):T}trySlimStyleAttrValue(T){const E=[];try{if(T.length<=1)return T;for(let T=this.tokens.length-1;T>=0;T--){if(this.tokens[T].type===TokenType.TAG_EQ)break;E.unshift(this.tokens.pop())}const _=`${E.map(T=>null==T?void 0:T.value).join("")}${T}`,A=_.startsWith('"')||_.startsWith("'"),S=_.endsWith('"')||_.endsWith("'"),t=new StyleAttrValueTokenizer(_.replace(/^['"]/,"").replace(/['"]$/,""),this.mPath).toString();return`${A?_.substr(0,1):""}${t}${S?_.substr(_.length-1,1):""}`}catch(T){this.tokens.push(...E)}return T}doExcludeAction(T,E){let _=TokenType.OTHERS;switch(T){case STATE.IN_TAG_ATTR_VALUE_STRING:case STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE:_=TokenType.ATTR_VALUE;break;case STATE.IN_TAG_WORD:_=TokenType.TAG,this.tagStack.push(E);break;case STATE.IN_END_TAG_WORD:_=TokenType.TAG;if(this.tagStack.pop()!==E)throw{col:this.mState.col-E.length,line:this.mState.line,message:"unexpected end tag: "+E};break;case STATE.IN_WXS:_=TokenType.WXS_VALUE;break;case STATE.IN_TEXT:_=TokenType.TEXT_VALUE;break;case STATE.IN_TAG_TEXT:_=TokenType.TAG_TEXT_VALUE;break;case STATE.IN_TAG_ATTR_WORD:_=TokenType.ATTR;break;case STATE.TAG_START:_=TokenType.LEFT_ANGLE_BRACKET;break;case STATE.IN_TEMPLATE:_=TokenType.TEMPLATE_ITEM;break;case STATE.TAG_EQ:_=TokenType.TAG_EQ;break;case STATE.TEMPLATE_END_CHECK:{const T=this.mState.cur_pos;if("}"===this.mSrc.substring(T-3,T-2))throw{col:this.mState.col-3,line:this.mState.line,message:"unexpected end tag: }. } should not be followed by }} direactly, add a space and change it to } }}"};this.appendToken(TokenType.TEMPLATE_ITEM,""+new TemplateTokenizer(E,this.mPath)),_=TokenType.TEMPLATE_END,E=""}}this.appendToken(_,E)}doIncludeAction(T,E,_){const A=this.mState.state;let S;E===STATE.WXS_END_STEP?(this.appendToken(TokenType.WXS_VALUE,_.substr(0,_.length-2)),S=TokenType.END_LEFT_ANGLE_BRACKET,_="</"):E===STATE.IN_WXS_STRING||E===STATE.IN_WXS_STRING_SINGLE?S=TokenType.WXS_VALUE:E===STATE.IN_TAG_ATTR_VALUE_STRING||E===STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE?S=TokenType.ATTR_VALUE:E===STATE.TAG_START&&A===STATE.IN_END_TAG?S=TokenType.END_LEFT_ANGLE_BRACKET:E===STATE.WAIT_FOR_RIGHT_BRACKET?(S=TokenType.SELF_CLOSE,this.tagStack.pop()):S=TokenType.OTHERS,">"!==T||E!==STATE.IN_TAG_WORD&&E!==STATE.IN_TAG_ATTR_WORD&&E!==STATE.IN_TAG_ATTR_VALUE_STRING&&E!==STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE&&E!==STATE.IN_END_TAG_WORD||(S=TokenType.RIGHT_ANGLE_BRACKET),this.appendToken(S,_)}Feed(T){super.Feed(T),this.wxsState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_WXS),this.textState&&this.mState.state===STATE.IN_TAG_TEXT&&(this.mState.state=STATE.IN_TEXT)}FillTT_attr_string(T,E,_){const A=T+1;this.TT[T][getCharCode("\\")]=A,this.TT[A][BASE_STATE.OTHERS]=T,this.TT[A][getCharCode("\n")]=E|ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE,this.TT[T][getCharCode(_)]=E|ACTION.STORE_TOKEN_INCLUDE,this.TT[T][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[T][0]=BASE_STATE.ERROR,this.TT[T][BASE_STATE.OTHERS]=T}InitTransitTable(){Machine._TT=new Array(STATE.MAX_STATE);for(let T=0;T<STATE.MAX_STATE;T++){const E=new Array(257);E.fill(0),this.TT[T]=E}this.TT[BASE_STATE.END][BASE_STATE.OTHERS]=BASE_STATE.END,this.TT[BASE_STATE.START][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[BASE_STATE.START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[BASE_STATE.START][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.NOTHING,this.TT[STATE.IN_TAG_TEXT][0]=BASE_STATE.END|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_TEXT][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT,this.TT[STATE.WAIT_TEMPLATE_START][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.STORE_TOKEN_FIRST,this.TT[STATE.WAIT_TEMPLATE_START][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.GET_STATE_BEFORE,this.TT[STATE.IN_TEMPLATE][getCharCode("{")]=STATE.IN_TEMPLATE|ACTION.RECORD_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("}")]=STATE.WAIT_TEMPLATE_END|ACTION.CHECK_IN_TEMPLATE_OBJECT,this.TT[STATE.IN_TEMPLATE][getCharCode("\\")]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TEMPLATE,STATE.IN_TEMPLATE,ACTION.NOTHING," \n\t\r"),this.TT[STATE.IN_TEMPLATE][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE,this.TT[STATE.IN_TEMPLATE][0]=BASE_STATE.ERROR,this.TT[STATE.WAIT_TEMPLATE_END][getCharCode("}")]=STATE.TEMPLATE_END_CHECK,this.TT[STATE.TEMPLATE_END_CHECK][BASE_STATE.OTHERS]=STATE.IN_TAG_TEXT|ACTION.REFEED|ACTION.STORE_TOKEN_EXCLUDE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_TEMPLATE_END][BASE_STATE.OTHERS]=STATE.IN_TEMPLATE|ACTION.REFEED,this.TT[STATE.IN_TEMPLATE][getCharCode('"')]=STATE.IN_TEMPLATE_STRING|ACTION.NOTHING,this.TT[STATE.IN_TEMPLATE][getCharCode("'")]=STATE.IN_TEMPLATE_STRING2|ACTION.NOTHING,this.FillTT_template_string(STATE.IN_TEMPLATE_STRING,STATE.IN_TEMPLATE|ACTION.NOTHING,'"'),this.FillTT_template_string(STATE.IN_TEMPLATE_STRING2,STATE.IN_TEMPLATE|ACTION.NOTHING,"'"),this.FillTT(STATE.TAG_START,STATE.TAG_START,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_START,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_START][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.TAG_START][getCharCode("!")]=STATE.IN_COMMENT_BEGIN1,this.TT[STATE.TAG_START][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN1][getCharCode("-")]=STATE.IN_COMMENT_BEGIN2,this.TT[STATE.IN_COMMENT_BEGIN1][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT_BEGIN2][getCharCode("-")]=STATE.IN_COMMENT,this.TT[STATE.IN_COMMENT_BEGIN2][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_COMMENT][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END1,this.TT[STATE.IN_COMMENT][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END1][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END1][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.IGNORE|ACTION.GET_STATE_BEFORE,this.TT[STATE.WAIT_FOR_COMMENT_END2][getCharCode("-")]=STATE.WAIT_FOR_COMMENT_END2,this.TT[STATE.WAIT_FOR_COMMENT_END2][BASE_STATE.OTHERS]=STATE.IN_COMMENT,this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_TAG_ATTR_WORD,STATE.IN_TAG_ATTR_WORD,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("=")]=STATE.TAG_EQ|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode('"')]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TAG_ATTR_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.TT[STATE.IN_TAG_ATTR_WORD][0]=BASE_STATE.ERROR,this.FillTT(STATE.TAG_EQ,STATE.TAG_EQ,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.TAG_EQ,STATE.IN_TAG_ATTR_VALUE_STRING,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.TAG_EQ][getCharCode('"')]=STATE.IN_TAG_ATTR_VALUE_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][getCharCode("'")]=STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.TAG_EQ][0]=BASE_STATE.ERROR,this.TT[STATE.TAG_EQ][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG,ACTION.IGNORE," \n\t\r"),this.FillTT(STATE.IN_END_TAG,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG,BASE_STATE.ERROR,ACTION.NOTHING,DIGIT),this.TT[STATE.IN_END_TAG][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,ALPHA),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG_WORD,ACTION.NOTHING,DIGIT),this.FillTT(STATE.IN_END_TAG_WORD,STATE.IN_END_TAG,ACTION.STORE_TOKEN_EXCLUDE|ACTION.IGNORE," \n\t\r"),this.TT[STATE.IN_END_TAG_WORD][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_EXCLUDE|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.IN_END_TAG_WORD][getCharCode("/")]=STATE.WAIT_FOR_RIGHT_BRACKET|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_END_TAG_WORD][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT(STATE.WAIT_FOR_RIGHT_BRACKET,STATE.IN_TAG_WORD,ACTION.STORE_TOKEN_EXCLUDE,ALPHA),this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][getCharCode(">")]=STATE.IN_TAG_TEXT|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WAIT_FOR_RIGHT_BRACKET][BASE_STATE.OTHERS]=BASE_STATE.ERROR,this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING,STATE.IN_TAG_ATTR_WORD,'"'),this.FillTT_attr_string(STATE.IN_TAG_ATTR_VALUE_STRING_SINGLE,STATE.IN_TAG_ATTR_WORD,"'"),this.TT[STATE.IN_WXS][getCharCode("<")]=STATE.WXS_END_STEP,this.TT[STATE.IN_WXS][getCharCode('"')]=STATE.IN_WXS_STRING|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_WXS][getCharCode("'")]=STATE.IN_WXS_STRING_SINGLE|ACTION.STORE_TOKEN_EXCLUDE,this.FillTT_attr_string(STATE.IN_WXS_STRING,STATE.IN_WXS,'"'),this.FillTT_attr_string(STATE.IN_WXS_STRING_SINGLE,STATE.IN_WXS,"'"),this.TT[STATE.IN_WXS][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.WXS_END_STEP][getCharCode("/")]=STATE.IN_END_TAG|ACTION.STORE_TOKEN_INCLUDE,this.TT[STATE.WXS_END_STEP][BASE_STATE.OTHERS]=STATE.IN_WXS,this.TT[STATE.IN_TEXT][getCharCode("<")]=STATE.TAG_START|ACTION.STORE_TOKEN_EXCLUDE,this.TT[STATE.IN_TEXT][BASE_STATE.OTHERS]=STATE.IN_TEXT,this.TT[STATE.IN_TEXT][getCharCode("{")]=STATE.WAIT_TEMPLATE_START|ACTION.STORE_STATE_BEFORE}}class Tokenizer{constructor(T,E){this.machine=new Machine(E,T),this.m_pSrc=T,this.path=E}generateTokens(){if(this.machine.Reset(),0===this.m_pSrc.length)return[];try{for(let T=0;T<this.m_pSrc.length;T++){const E=this.m_pSrc[T];this.machine.Feed(E)}this.machine.Feed("\0")}catch(T){throw new Error(`${T.line}:${T.col}:${T.message}`)}return this.machine.getTokens()}}function generateWXMLFromTokens(T,E={collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1}){const{collapseWhitespace:_,conservativeCollapse:A,preserveLineBreaks:S}=E,t=[];for(let E=0;E<T.length;E++){const e=T[E];let N=e.value;const R=e.type;if(R===TokenType.ATTR&&(N=" "+N),R===TokenType.TAG_TEXT_VALUE){S||(N=N.replace(/\n/g," ")),_&&(N=N.replace(/([ \t])+/g," "));const t=T[E-1];t&&t.type!==TokenType.RIGHT_ANGLE_BRACKET&&t.type!==TokenType.SELF_CLOSE||_&&!A&&(N=trimStringLeft(N,!1)),(null==t?void 0:t.type)===TokenType.TAG_TEXT_VALUE&&((null==t?void 0:t.value.endsWith(" "))||(null==t?void 0:t.value.endsWith("\n")))&&_&&(N=trimStringLeft(N,!1))}if(R===TokenType.LEFT_ANGLE_BRACKET||R===TokenType.END_LEFT_ANGLE_BRACKET){const S=T[E-1];if((null==S?void 0:S.type)===TokenType.TAG_TEXT_VALUE&&_&&!A){const T=t.pop()||"";t.push(trimStringRight(T,!1))}}t.push(N)}return t.join("")}async function minifyWXML(T){const{filePath:E,root:_=""}=T,A=T.code instanceof Buffer?T.code.toString():T.code,S=Object.assign({collapseWhitespace:!0,conservativeCollapse:!1,preserveLineBreaks:!1},T.setting),t=path_1.default.posix.join(_,E);if(A.length>0)try{const T=new Tokenizer(A.replace(/\r\n/g,"\n"),t);return{error:null,code:generateWXMLFromTokens(T.generateTokens(),S)}}catch(T){return log.error("minifywxml error @ "+t),log.error(T.message),{error:{code:config_1.MINIFY_WXML_ERR,path:t,message:T.message}}}return{error:null,code:A.replace(/\r\n/g,"\n")}}exports.minifyWXML=minifyWXML;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.random=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),customError_1=require("../../../../utils/customError"),debug_1=require("../../../../utils/debug");let runInMainProcess=void 0;const sass=async()=>{if(void 0===runInMainProcess&&(runInMainProcess=await(0,debug_1.shouldRunInMainProcess)()),runInMainProcess){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.random=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),customError_1=require("../../../../utils/customError"),debug_1=require("../../../../utils/debug");let runInMainProcess=void 0;const sass=async()=>{if(void 0===runInMainProcess&&(runInMainProcess=await(0,debug_1.shouldRunInMainProcess)()),runInMainProcess){return require("sass")}return require("sass")};function random(){return(0,tools_1.generateMD5)(`${Math.random()}${Date.now()}`)}exports.random=random;const importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,importCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.css)\1(?:\s*);/g;async function sassRender(s,t){if("undefined"!=typeof WEBIDE_WEBPECK_DEFINE_PLUGIN);else{(await sass()).render(s,t)}}function default_1(s){return{name:"summer-sass",resolveExt:{wxss:["sass","scss"]},async load(t,e){var o,r,a,i;if(e.endsWith(".scss")||e.endsWith(".sass")){const n=(0,tools_1.pathRelative)(s.projectPath,e);let l=s.getFile("",n).toString();const u=s.getTargetPath(s.miniprogramRoot,"global");if(n!==u+".scss"&&n!==u+".sass"){const t=path_1.default.extname(n),e=(null===(r=null===(o=s.setting)||void 0===o?void 0:o.sassSetting)||void 0===r?void 0:r.sassCommonUseFilePath)||"global.sass",u=(null===(i=null===(a=s.setting)||void 0===a?void 0:a.sassSetting)||void 0===i?void 0:i.scssCommonUseFilePath)||"global.scss";let c=".sass"===t?e:u;const d=(0,tools_1.pathRelative)(s.miniprogramRoot,path_1.default.dirname(n))||".";s.exists(s.miniprogramRoot,c)||(c=".sass"===t?u:e),s.exists(s.miniprogramRoot,c)&&(l=".sass"===t?`@use '${"."===d?".":(0,tools_1.pathRelative)(d,"./")}/${c}'\n${l}`:`@use '${"."===d?".":(0,tools_1.pathRelative)(d,"./")}/${c}';\n${l}`)}const c=[];l=l.replace(importWxssReg,(s,t,e)=>(c.push(e),s.replace(e,e.slice(0,-4)+"css")));const d=path_1.default.posix.dirname((0,tools_1.pathRelative)(s.projectPath,e));return new Promise((s,o)=>{const r=Date.now();sassRender({file:e,data:l,sourceMap:!0,sourceMapContents:!0,omitSourceMapUrl:!0,outFile:e.slice(0,-5)+".wxss",includePaths:this.rootPath?[this.rootPath]:[]},(a,i)=>{if(a){const s=(0,customError_1.makeCustomError)(a,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR);return void o(s)}if(!i)return void o(new Error("no result"));const n=i.css.toString("utf-8").replace(importCssReg,(s,t,e)=>{const o=e.slice(0,-3)+"wxss";return c.includes(o)?s.replace(e,o):s});if(i.stats.includedFiles.length>0)for(const s of i.stats.includedFiles)s!==e&&this.addWatchFile(s);const l=i.map?JSON.parse(i.map.toString("utf-8")):void 0;l&&(l.sourceRoot=d),s({targetPath:t,source:{sourceCode:n,inputMap:l},process:[{cost:Date.now()-r,pluginName:"summer-sass",action:"load"}]})})})}}}}exports.default=default_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _a,_b;process.env&&process.env.isDevtools&&require("../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0}),(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../../utils/hackrequire/index");const entryProcess_1=require("../../utils/subprocess/entryProcess"),
|
|
1
|
+
var _a,_b;process.env&&process.env.isDevtools&&require("../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0}),(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../../utils/hackrequire/index");const entryProcess_1=require("../../utils/subprocess/entryProcess"),processHandler_1=require("./processHandler");(0,entryProcess_1.runSubProcess)({initHandler:processHandler_1.initHandler,messageHandler:processHandler_1.messageHandler,timeout:(null===(_b=process.env)||void 0===_b?void 0:_b.timeout)||3e5});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=exports.onMessage=exports.destroy=exports.initHandler=void 0;const progressRecorder_1=require("../../utils/progressRecorder"),nativeCompiler_1=require("./nativeCompiler");let nativeCompiler,inited=!1;function processSend(e){emiter.emit("message",e)}async function initHandler(e){const{projectInfo:t,passData:i}=e.data;if(inited)return;const{miniappDirPath:n,devtoolsVersion:s}=i;nativeCompiler=new nativeCompiler_1.NativeCompiler({projectInfo:t,miniappDirPath:n,devtoolsVersion:s}),inited=!0}async function destroy(){nativeCompiler=void 0,inited=!1}exports.initHandler=initHandler,exports.destroy=destroy;const emiter=function(){const e={};return{on:(t,i)=>{e.hasOwnProperty(t)||(e[t]=[]),e[t].push(i)},emit:(t,...i)=>{const n=e[t];if((null==n?void 0:n.length)>0)for(const e of n)try{e(...i)}catch(e){}}}}(),onMessage=e=>{emiter.on("message",e)};async function messageHandler(e){if("event"!==e.type&&"request"===e.type){const{id:t,name:i,data:n}=e,s=t,a=new progressRecorder_1.Recorder((e,t,i)=>{processSend({type:"progress",id:e,taskId:s,status:t,message:i})});n.fullEnv&&(global.fullEnv=n.fullEnv);try{let e;const r=`${i}-${s}`;if("buildNative"===i)e=await a.run(r,async()=>await nativeCompiler.build(n,a));else if("runNative"===i)e=await a.run(r,async()=>await nativeCompiler.run(n,a));else if("buildNativePlugin"===i)e=await a.run(r,async()=>await nativeCompiler.buildPlugin(n,a));else if("packIOSCloudBuildMaterial"===i)e=await a.run(r,async()=>await nativeCompiler.packIOSCloudBuildMaterial(n,a));else if("initUSBConnectionProcess"===i)e=await a.run(r,async()=>await nativeCompiler.initUSBConnectionProcess(n,a));else{if("codesignIOSApp"!==i)throw new Error("unknown command "+i);e=await a.run(r,async()=>await nativeCompiler.codesignIOSApp(n,a))}processSend({type:"response",id:t,data:e})}catch(e){processSend({type:"response",id:t,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.onMessage=onMessage,exports.messageHandler=messageHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const template=require("@babel/template").default,generate=require("@babel/generator").default,hash=require("string-hash-64"),{transformSync:transformSync}=require("@babel/core"),traverse=require("@babel/traverse").default,parse=require("@babel/parser").parse,
|
|
1
|
+
"use strict";const template=require("@babel/template").default,generate=require("@babel/generator").default,hash=require("string-hash-64"),{transformSync:transformSync}=require("@babel/core"),traverse=require("@babel/traverse").default,parse=require("@babel/parser").parse,nodePath=require("path"),buildBindFunc=e=>template.ast(`\n var _${e}_ = this.${e}.bind(this);\n`),buildWorkletFunc=e=>template.ast(`\n var ${e} = this._${e}_worklet_factory_();\n`),globals=new Set(["this","console","_setGlobalConsole","Date","Array","ArrayBuffer","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","Float32Array","Float64Array","Date","HermesInternal","JSON","Math","Number","Object","String","Symbol","undefined","null","UIManager","requestAnimationFrame","_WORKLET","arguments","Boolean","parseInt","parseFloat","Map","Set","_log","_updateProps","RegExp","Error","global","_measure","_scrollTo","_setGestureState","_getCurrentTime","_eventTimestamp","_frameTimestamp","isNaN","LayoutAnimationRepository","_stopObservingProgress","_startObservingProgress","setTimeout","globalThis","workletUIModule"]),blacklistedFunctions=new Set(["stopCapturing","toString","map","filter","forEach","valueOf","toPrecision","toExponential","constructor","toFixed","toLocaleString","toSource","charAt","charCodeAt","concat","indexOf","lastIndexOf","localeCompare","length","match","replace","search","slice","split","substr","substring","toLocaleLowerCase","toLocaleUpperCase","toLowerCase","toUpperCase","every","join","pop","push","reduce","reduceRight","reverse","shift","slice","some","sort","splice","unshift","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","bind","apply","call","__callAsync","includes"]),possibleOptFunction=new Set(["interpolate"]);class ClosureGenerator{constructor(){this.trie=[{},!1]}mergeAns(e,t){const[r,n]=e,[o,i]=t;return 0!==o.length?[r.concat(o),i]:[r,n]}findPrefixRec(e){const t=[[],null];if(!e||"MemberExpression"!==e.node.type)return t;const r=e.node;if("Identifier"!==r.property.type)return t;if(r.computed||"value"===r.property.name||blacklistedFunctions.has(r.property.name))return t;if(e.parent&&"AssignmentExpression"===e.parent.type&&e.parent.left===e.node)return t;const n=[r.property.name],o=r,i=this.findPrefixRec(e.parentPath);return this.mergeAns([n,o],i)}findPrefix(e,t){const r=[e],n=t.node,o=this.findPrefixRec(t.parentPath);return this.mergeAns([r,n],o)}addPath(e,t){const[r,n]=this.findPrefix(e,t);let o=this.trie,i=-1;for(const e of r)i++,o[1]||(o[0][e]||(o[0][e]=[{},!1]),i===r.length-1&&(o[0][e]=[n,!0]),o=o[0][e])}generateNodeForBase(e,t,r){const n=r[0][t];return n[1]?n[0]:e.objectExpression(Object.keys(n[0]).map(t=>e.objectProperty(e.identifier(t),this.generateNodeForBase(e,t,n),!1,!0)))}generate(e,t,r){const n=[...r];return e.objectExpression(t.map((t,r)=>e.objectProperty(e.identifier(t.name),this.generateNodeForBase(e,n[r],this.trie),!1,!0)))}}function buildWorkletString(e,t,r,n){traverse(t,{enter(t){e.removeComments(t.node)}});const o=t.program.body.find(e=>"ExpressionStatement"===e.type),i=e.functionExpression(e.identifier(n),o.expression.params,function(t,r){return 0===t.length?r:e.blockStatement([e.variableDeclaration("const",[e.variableDeclarator(e.objectPattern(t.map(t=>e.objectProperty(e.identifier(t.name),e.identifier(t.name),!1,!0))),e.memberExpression(e.identifier("jsThis"),e.identifier("_closure")))]),r])}(r,o.expression.body));return generate(i,{compact:!0}).code}function generateWorkletFactory(e,t){const r=new Map;t.traverse({CallExpression:{enter(t){if(!e.isMemberExpression(t.node.callee))return;const n=[];let o=t.node.callee;for(;e.isMemberExpression(o);){const e=o.property.name;n.unshift(e),o=o.object}if(!e.isThisExpression(o))return;let i=n[n.length-1];if("bind"===i)return i=n[n.length-2],r.set(i,"bind"),void t.replaceWith(e.identifier(`_${i}_`));t.get("callee").replaceWith(e.identifier(i)),r.set(i,"worklet")}}});const n=[];r.forEach((e,t)=>{const r="bind"===e?(o=t,template.ast(`\n var _${o}_ = this.${o}.bind(this);\n`)):buildWorkletFunc(t);var o;n.push(r)});const o=e.arrowFunctionExpression(t.node.params,t.node.body),i=e.identifier("f");return e.functionExpression(null,[],e.blockStatement([...n,e.variableDeclaration("var",[e.variableDeclarator(i,o)]),e.returnStatement(i)]))}function removeWorkletDirective(e){let t;const r=parse("\n("+e.toString()+"\n)");return traverse(r,{DirectiveLiteral(e){"worklet"===e.node.value&&e.parentPath.remove()},Program:{exit(e){t=e.get("body.0.expression").node}}}),t}function makeWorkletName(e,t){return e.isObjectMethod(t)?t.node.key.name:e.isFunctionDeclaration(t)||e.isFunctionExpression(t)&&e.isIdentifier(t.node.id)?t.node.id.name:"_f"}function extractWorkletData(e,t,r){const n=makeWorkletName(e,t),o=new Map,i=new ClosureGenerator;t.traverse({DirectiveLiteral(e){"worklet"===e.node.value&&e.getFunctionParent()===t&&e.parentPath.remove()}});const a="\n("+(e.isObjectMethod(t)?"function ":"")+t.toString()+"\n)",s=transformSync(a,{filename:r,presets:["@babel/preset-typescript"],plugins:["@babel/plugin-transform-shorthand-properties","@babel/plugin-transform-arrow-functions","@babel/plugin-proposal-optional-chaining","@babel/plugin-proposal-nullish-coalescing-operator",["@babel/plugin-transform-template-literals",{loose:!0}]],ast:!0,babelrc:!1,configFile:!1});traverse(s.ast,{ReferencedIdentifier(e){const r=e.node.name;if(globals.has(r)||t.node.id&&t.node.id.name===r)return;const n=e.parent;if("MemberExpression"===n.type&&n.property===e.node&&!n.computed)return;if("ObjectProperty"===n.type&&"ObjectExpression"===e.parentPath.parent.type&&e.node!==n.value)return;let a=e.scope;for(;null!=a;){if(null!=a.bindings[r])return;a=a.parent}o.set(r,e.node),i.addPath(r,e)}});const l=Array.from(o.values()),c=buildWorkletString(e,s.ast,l,n),p=hash(c);let u=r;const d=t&&t.node&&t.node.loc&&t.node.loc.start;if(d){const{line:e,column:t}=d;"number"==typeof e&&"number"==typeof t&&(u=`${r} (${e}:${t})`)}return{variables:l,closure:o,closureGenerator:i,funString:c,workletHash:p,locationFileName:u}}function makeWorklet(e,t,r){const{variables:n,closure:o,closureGenerator:i,funString:a,workletHash:s,locationFileName:l}=extractWorkletData(e,t,r),c=e.identifier("_f"),p=e.cloneNode(t.node);let u;u="BlockStatement"===p.body.type?e.functionExpression(null,p.params,p.body):p;const d=[e.variableDeclaration("const",[e.variableDeclarator(c,u)]),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(c,e.identifier("_closure"),!1),i.generate(e,n,o.keys()))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(c,e.identifier("asString"),!1),e.stringLiteral(a))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(c,e.identifier("__workletHash"),!1),e.numericLiteral(s))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(c,e.identifier("__location"),!1),e.stringLiteral(l))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(c,e.identifier("__worklet"),!1),e.booleanLiteral(!0)))];d.push(e.returnStatement(c));return e.functionExpression(t.id,[],e.blockStatement(d))}function buildWorkletProperties(e,t,r){const{variables:n,closure:o,closureGenerator:i,funString:a,workletHash:s,locationFileName:l}=extractWorkletData(e,t,r);return e.objectExpression([e.objectProperty(e.identifier("_closure"),i.generate(e,n,o.keys())),e.objectProperty(e.identifier("asString"),e.stringLiteral(a)),e.objectProperty(e.identifier("__workletHash"),e.numericLiteral(s)),e.objectProperty(e.identifier("__location"),e.stringLiteral(l)),e.objectProperty(e.identifier("__worklet"),e.booleanLiteral(!0))])}function processWorkletFunction(e,t,r){if(!e.isFunctionParent(t))return;if(t.parentPath.isObjectProperty()){const r=t.parent.key.name,n=removeWorkletDirective(t),o=generateWorkletFactory(e,t),i=`_${r}_worklet_factory_`;return void t.parentPath.replaceWithMultiple([e.objectProperty(e.identifier(r),n,!1,!1),e.objectProperty(e.identifier(i),o,!1,!1)])}const n=e.isScopable(t.parent)||e.isExportNamedDeclaration(t.parent);if(e.isFunctionDeclaration(t.node)&&t.node.id&&n){const n=t.node.id,o=buildWorkletProperties(e,t,r),i=e.expressionStatement(e.callExpression(e.memberExpression(e.identifier("Object"),e.identifier("assign")),[e.identifier(n.name),o]));t.insertAfter(i)}else{const o=makeWorklet(e,t,r),i=e.callExpression(o,[]);t.replaceWith(t.node.id&&n?e.variableDeclaration("const",[e.variableDeclarator(t.node.id,i)]):i)}}function processIfWorkletNode(e,t,r){t.traverse({DirectiveLiteral(n){if("worklet"===n.node.value&&n.getFunctionParent()===t){const n=t.node.body.directives;n&&n.length>0&&n.some(t=>e.isDirectiveLiteral(t.value)&&"worklet"===t.value.value)&&processWorkletFunction(e,t,r)}}})}const FUNCTIONLESS_FLAG=1,STATEMENTLESS_FLAG=2;function isPossibleOptimization(e){let t=!1,r=!1;traverse(e,{CallExpression(e){possibleOptFunction.has(e.node.callee.name)||(t=!0)},IfStatement(){r=!0}});let n=0;return t||(n|=1),r||(n|=2),n}module.exports=function({types:e}){return{pre(){null!=this.opts&&Array.isArray(this.opts.globals)&&this.opts.globals.forEach(e=>{globals.add(e)})},visitor:{"FunctionDeclaration|FunctionExpression|ArrowFunctionExpression":{enter(t,r){let n=r.file.opts.filename;n=nodePath.relative(__dirname,n),processIfWorkletNode(e,t,n)}}}}};
|
package/dist/utils/debug.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";async function shouldInspectCompiler(){var o,l,e,
|
|
1
|
+
"use strict";async function shouldInspectCompiler(){var o,l,e,r;if(global.__MINIPROGRAM_CI_TEST__)return!0;if(null===(o=global.localStorage)||void 0===o?void 0:o.getItemAsync){if(await(null===(e=null===(l=global.localStorage)||void 0===l?void 0:l.getItemAsync)||void 0===e?void 0:e.call(l,"inspectCompiler")))return!0}else if(null===(r=global.localStorage)||void 0===r?void 0:r.getItem("inspectCompiler"))return!0;return!1}async function shouldRunInMainProcess(){var o,l,e,r,n;if(null===(o=global.localStorage)||void 0===o?void 0:o.getItemAsync){if(await(null===(e=null===(l=global.localStorage)||void 0===l?void 0:l.getItemAsync)||void 0===e?void 0:e.call(l,"compilerInMainProcess")))return!0}else if(null===(r=global.localStorage)||void 0===r?void 0:r.getItem("compilerInMainProcess"))return!0;return!!(null===(n=null===process||void 0===process?void 0:process.versions)||void 0===n?void 0:n.electron)}async function shouldNotRunInWorker(){var o,l,e,r;if(null===(o=global.localStorage)||void 0===o?void 0:o.getItemAsync){if(await(null===(e=null===(l=global.localStorage)||void 0===l?void 0:l.getItemAsync)||void 0===e?void 0:e.call(l,"compilerNotInWorker")))return!0}else if(null===(r=global.localStorage)||void 0===r?void 0:r.getItem("compilerNotInWorker"))return!0;return!1}Object.defineProperty(exports,"__esModule",{value:!0}),exports.shouldNotRunInWorker=exports.shouldRunInMainProcess=exports.shouldInspectCompiler=void 0,exports.shouldInspectCompiler=shouldInspectCompiler,exports.shouldRunInMainProcess=shouldRunInMainProcess,exports.shouldNotRunInWorker=shouldNotRunInWorker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SubProcessProxy=void 0;const processService_1=require("./processService"),customError_1=require("../customError"),singletontask_1=require("../singletontask"),debug_1=require("../debug"),progressRecorder_1=require("../../utils/progressRecorder");class SubProcessProxy{constructor(s,e,r,t,o=8891,i){this.project=s,this.entryPath=e,this.passData=r,this.initOptions=t,this.inspectPort=o,this.progressUpdate=i,this.taskMap=new Map,this.taskId=0,this.init=async()=>{this.process=await this.forkProcess()},this.onMessage=s=>{var e,r;if(this._cpPromise&&("ready"===s.type&&(clearTimeout(this._cpPromise.timer),null===(e=this._cpPromise)||void 0===e||e.resolve()),"noReady"===s.type&&this._cpPromise.reject(new Error(s.error.message))),"progress"===s.type){const e=this.taskMap.get(s.taskId);(null==e?void 0:e.progressUpdate)&&e.progressUpdate(s.id,s.status,s.message)}if("log"===s.type&&(null===(r=this.progressUpdate)||void 0===r||r.call(this,s.id||"",s.status,s.text)),"response"===s.type){const{id:e,data:r,error:t}=s;t?this.onResponse(e,void 0,t):this.onResponse(e,r,void 0)}}}async ready(){var s;return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init)),await(null===(s=this._checkReadyTask)||void 0===s?void 0:s.getResult(!0))}async sendProcessMessage(s){await this.ready(),this.process.send(s)}destroy(){var s;null===(s=this.process)||void 0===s||s.kill("SIGTERM"),this.process=void 0,this._checkReadyTask=void 0}async forkProcess(){console.warn(`[summer-compiler] forkProcess [${(0,progressRecorder_1.getPrintTime)()}]`);const s=await this.project.serialize();console.warn(`[summer-compiler] forkProcess serialize [${(0,progressRecorder_1.getPrintTime)()}]`);const e={type:"init",data:{passData:this.passData,projectInfo:s,options:this.initOptions}},r=await(0,debug_1.shouldRunInMainProcess)();if(r){const s=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SubProcessProxy=void 0;const tslib_1=require("tslib"),processService_1=require("./processService"),path_1=tslib_1.__importDefault(require("path")),customError_1=require("../customError"),singletontask_1=require("../singletontask"),debug_1=require("../debug"),progressRecorder_1=require("../../utils/progressRecorder"),IN_PROCESS_HANDLER_MODULE_MAP={summerEntryProcess:"../../modules/corecompiler/processHandler",summerentryprocess:"../../modules/corecompiler/processHandler",nativeEntryProcess:"../../modules/nativecompiler/processHandler"};class SubProcessProxy{constructor(s,e,r,t,o=8891,i){this.project=s,this.entryPath=e,this.passData=r,this.initOptions=t,this.inspectPort=o,this.progressUpdate=i,this.taskMap=new Map,this.taskId=0,this.init=async()=>{this.process=await this.forkProcess()},this.onMessage=s=>{var e,r;if(this._cpPromise&&("ready"===s.type&&(clearTimeout(this._cpPromise.timer),null===(e=this._cpPromise)||void 0===e||e.resolve()),"noReady"===s.type&&this._cpPromise.reject(new Error(s.error.message))),"progress"===s.type){const e=this.taskMap.get(s.taskId);(null==e?void 0:e.progressUpdate)&&e.progressUpdate(s.id,s.status,s.message)}if("log"===s.type&&(null===(r=this.progressUpdate)||void 0===r||r.call(this,s.id||"",s.status,s.text)),"response"===s.type){const{id:e,data:r,error:t}=s;t?this.onResponse(e,void 0,t):this.onResponse(e,r,void 0)}}}async ready(){var s;return this._checkReadyTask||(this._checkReadyTask=new singletontask_1.SingletonTask(this.init)),await(null===(s=this._checkReadyTask)||void 0===s?void 0:s.getResult(!0))}async sendProcessMessage(s){await this.ready(),this.process.send(s)}destroy(){var s;null===(s=this.process)||void 0===s||s.kill("SIGTERM"),this.process=void 0,this._checkReadyTask=void 0}getInProcessHandler(){const s=path_1.default.parse(this.entryPath).name,e=IN_PROCESS_HANDLER_MODULE_MAP[s];if(!e)throw new Error("unsupported in-process entry handler: "+this.entryPath);return require(e)}async forkProcess(){console.warn(`[summer-compiler] forkProcess [${(0,progressRecorder_1.getPrintTime)()}]`);const s=await this.project.serialize();console.warn(`[summer-compiler] forkProcess serialize [${(0,progressRecorder_1.getPrintTime)()}]`);const e={type:"init",data:{passData:this.passData,projectInfo:s,options:this.initOptions}},r=await(0,debug_1.shouldRunInMainProcess)();if(r){const s=this.getInProcessHandler();return await s.initHandler(e),s.onMessage(this.onMessage),{send:e=>{r&&s.messageHandler(e)},kill:e=>(s.destroy(),!0)}}console.warn(`[summer-compiler] forkProcess start [${(0,progressRecorder_1.getPrintTime)()}]`);const t=await(0,processService_1.forkProcess)(this,this.entryPath,this.project.projectPath,e,this.inspectPort);return console.warn(`[summer-compiler] forkProcess done [${(0,progressRecorder_1.getPrintTime)()}]`),t}onResponse(s,e,r){const t=this.taskMap.get(s);this.taskMap.delete(s),t?r?(r=new customError_1.CustomError(r),t.reject(r)):t.resolve(e):console.error(`child process task: ${s} not found`)}async sendEvent(s,e){this.sendProcessMessage({type:"event",name:s,data:e})}async runTask(s,e,r){return new Promise((t,o)=>{const i={name:s,data:e,resolve:t,reject:o,progressUpdate:r};this.taskId+=1,this.taskMap.set(this.taskId,i);this.sendProcessMessage({type:"request",id:this.taskId,name:s,data:e}).catch(s=>{o(s)})})}}exports.SubProcessProxy=SubProcessProxy;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miniprogram-ci",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.31",
|
|
4
4
|
"description": "Module that build miniprogram project for web or app extracted from WeChatDevtools.",
|
|
5
5
|
"homepage": "https://developers.weixin.qq.com/community/homepage",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"beta": "npm run init && rm -rf dist && tsc && gulp copy && node ./task/afterbuild.js && npm run test",
|
|
16
16
|
"build": "rm -rf dist && npm run eslint -- --fix && npm run bb",
|
|
17
17
|
"prebuild-ci": "npm run buildandroidtoolkit",
|
|
18
|
-
"build-ci": "rm -rf dist && rm -rf ci-src && npm run build && gulp pre-build-ci && rm -rf dist && gulp removeForCi && npm run ci-tsc && gulp build-ci",
|
|
18
|
+
"build-ci": "rm -rf dist && rm -rf ci-src && npm run build && gulp pre-build-ci && rm -rf dist && gulp removeForCi && npm run ci-tsc && gulp build-ci && npm run genCiDist",
|
|
19
|
+
"genCiDist": "node ./task/genCiDist.js",
|
|
19
20
|
"ci-tsc": "gulp ci-tsc",
|
|
20
21
|
"ci-tsc-dev": "gulp ci-tsc-dev",
|
|
21
22
|
"bb": "npm run init && gulp inc-version && gulp tsc && gulp build && node ./task/afterbuild.js ",
|
|
@@ -53,56 +54,6 @@
|
|
|
53
54
|
"overrides": {
|
|
54
55
|
"graceful-fs": "4.2.11"
|
|
55
56
|
},
|
|
56
|
-
"devDependencies": {
|
|
57
|
-
"@swc/helpers": "0.5.9",
|
|
58
|
-
"@tencent/eslint-config-extends": "git+https://git.woa.com/devtools/eslint-config-extends.git",
|
|
59
|
-
"@tencent/eslint-config-tencent": "^1.0.4",
|
|
60
|
-
"@tencent/wxa-runtime-browser": "^0.2.0",
|
|
61
|
-
"@types/babel__core": "^7.1.17",
|
|
62
|
-
"@types/babel-code-frame": "^6.20.2",
|
|
63
|
-
"@types/babel-core": "^6.25.6",
|
|
64
|
-
"@types/cssnano": "^4.0.1",
|
|
65
|
-
"@types/estree": "0.0.47",
|
|
66
|
-
"@types/fs-extra": "^8.0.0",
|
|
67
|
-
"@types/glob": "^7.2.0",
|
|
68
|
-
"@types/html-minifier": "^3.5.3",
|
|
69
|
-
"@types/jest": "^26.0.20",
|
|
70
|
-
"@types/less": "^3.0.3",
|
|
71
|
-
"@types/lodash": "^4.14.178",
|
|
72
|
-
"@types/node": "^13.13.52",
|
|
73
|
-
"@types/read-package-tree": "^5.2.0",
|
|
74
|
-
"@types/request": "^2.48.3",
|
|
75
|
-
"@types/rimraf": "^3.0.0",
|
|
76
|
-
"@types/sass": "^1.43.1",
|
|
77
|
-
"@types/terminal-kit": "^1.34.0",
|
|
78
|
-
"@types/uglify-js": "^3.0.4",
|
|
79
|
-
"@types/uuid": "^3.1.0",
|
|
80
|
-
"@types/yargs": "^13.0.3",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
82
|
-
"@typescript-eslint/parser": "^4.33.0",
|
|
83
|
-
"chai": "^4.2.0",
|
|
84
|
-
"chai-as-promised": "^7.1.1",
|
|
85
|
-
"dependency-tree": "^10.0.9",
|
|
86
|
-
"eslint": "^7.16.0",
|
|
87
|
-
"eslint-plugin-import": "2.22.1",
|
|
88
|
-
"eslint-plugin-react": "7.22.0",
|
|
89
|
-
"eslint-plugin-unused-imports": "^1.1.1",
|
|
90
|
-
"eslint-plugin-weixin-devtools": "git+https://git.woa.com/devtools/eslint-plugin-weixin-devtools.git#master",
|
|
91
|
-
"gulp": "^4.0.2",
|
|
92
|
-
"gulp-clean": "^0.4.0",
|
|
93
|
-
"gulp-if": "^3.0.0",
|
|
94
|
-
"gulp-preprocess": "^5.0.0",
|
|
95
|
-
"gulp-terser": "^1.2.0",
|
|
96
|
-
"gulp-tsc": "^1.3.2",
|
|
97
|
-
"gulp-typescript": "5.0.1",
|
|
98
|
-
"jest": "^26.6.3",
|
|
99
|
-
"mocha": "^6.2.2",
|
|
100
|
-
"mochawesome": "^4.1.0",
|
|
101
|
-
"nyc": "^14.1.1",
|
|
102
|
-
"ts-jest": "^26.5.2",
|
|
103
|
-
"typescript": "^4.9.5",
|
|
104
|
-
"typescript-json-schema": "^0.41.0"
|
|
105
|
-
},
|
|
106
57
|
"dependencies": {
|
|
107
58
|
"@babel/code-frame": "7.22.10",
|
|
108
59
|
"@babel/compat-data": "7.22.9",
|
|
@@ -257,7 +208,7 @@
|
|
|
257
208
|
"js-base64": "^3.7.2",
|
|
258
209
|
"jsonschema": "^1.2.5",
|
|
259
210
|
"jszip": "^3.4.0",
|
|
260
|
-
"less": "
|
|
211
|
+
"less": "4.5.1",
|
|
261
212
|
"licia": "^1.31.1",
|
|
262
213
|
"lodash": "^4.17.15",
|
|
263
214
|
"memory-fs": "^0.5.0",
|
|
@@ -290,4 +241,4 @@
|
|
|
290
241
|
"engines": {
|
|
291
242
|
"node": ">=16.1.0"
|
|
292
243
|
}
|
|
293
|
-
}
|
|
244
|
+
}
|