miniprogram-ci 1.9.8 → 1.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +5 -0
- package/dist/@types/config.d.ts +1 -1
- package/dist/@types/core/js/workletCompile.d.ts +22 -0
- package/dist/@types/summer/plugins/worklet.d.ts +4 -0
- package/dist/@types/types/index.d.ts +1 -0
- package/dist/@types/utils/babel_plugin_worklet.d.ts +1 -0
- package/dist/config.js +1 -1
- package/dist/core/analyse/partial.js +1 -1
- package/dist/core/js/workletCompile.js +1 -0
- package/dist/core/worker_thread/task/compilejs.js +1 -1
- package/dist/manifest.json +2 -2
- package/dist/summer/ci.js +1 -1
- package/dist/summer/plugins/index.js +1 -1
- package/dist/summer/plugins/worklet.js +1 -0
- package/dist/utils/babel_plugin_worklet.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,6 +7,10 @@ miniprogram-ci 是从[微信开发者工具](https://developers.weixin.qq.com/mi
|
|
|
7
7
|
miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,调用方式与普通开发模式无异。[查看详情](#第三方平台开发)
|
|
8
8
|
|
|
9
9
|
## 最近变更
|
|
10
|
+
#### 1.9.10
|
|
11
|
+
- `new` 新增 支持 compileWorklet 编译选项。
|
|
12
|
+
#### 1.9.9
|
|
13
|
+
- `new` 更新 worklet 函数的编译逻辑。
|
|
10
14
|
#### 1.9.8
|
|
11
15
|
- `fix` 修复 TypeError: _regeneratorRuntime3 is not a function 报错问题
|
|
12
16
|
#### 1.9.7
|
|
@@ -813,6 +817,7 @@ miniprogram-ci \
|
|
|
813
817
|
| minify | boolean | 上传时压缩所有代码,对应于微信开发者工具的 "上传时压缩代码" |
|
|
814
818
|
| codeProtect | boolean | 对应于微信开发者工具的 "上传时进行代码保护" |
|
|
815
819
|
| autoPrefixWXSS | boolean | 对应于微信开发者工具的 "上传时样式自动补全" |
|
|
820
|
+
| compileWorklet | boolean | 对应于微信开发者工具的 编译 worklet 代码 |
|
|
816
821
|
|
|
817
822
|
## 第三方平台开发
|
|
818
823
|
|
package/dist/@types/config.d.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface IOptions {
|
|
2
|
+
babelRoot: string;
|
|
3
|
+
code: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
disableUseStrict?: boolean;
|
|
6
|
+
inputSourceMap?: import('source-map').RawSourceMap;
|
|
7
|
+
}
|
|
8
|
+
declare const workletCompile: (options: IOptions) => {
|
|
9
|
+
error: {
|
|
10
|
+
message: string;
|
|
11
|
+
code: number;
|
|
12
|
+
};
|
|
13
|
+
code?: undefined;
|
|
14
|
+
map?: undefined;
|
|
15
|
+
helpers?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
code: string;
|
|
18
|
+
map: import("source-map").RawSourceMap;
|
|
19
|
+
helpers: never[];
|
|
20
|
+
error?: undefined;
|
|
21
|
+
};
|
|
22
|
+
export = workletCompile;
|
|
@@ -4,6 +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 nodePath: any;
|
|
7
8
|
declare const buildBindFunc: (func: any) => any;
|
|
8
9
|
declare const buildWorkletFunc: (func: any) => any;
|
|
9
10
|
declare const globals: Set<string>;
|
package/dist/config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),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="1.9.
|
|
2
|
+
"use strict";var COMPILE_TYPE;Object.defineProperty(exports,"__esModule",{value:!0}),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="1.9.10",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(_){_.miniProgram="miniProgram",_.miniProgramPlugin="miniProgramPlugin",_.miniGame="miniGame",_.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,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"]}};
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";function findAllDescendant(e,t){let n;n=Array.isArray(e)?e:[e];const s=n.slice(0),
|
|
2
|
+
"use strict";function findAllDescendant(e,t){let n;n=Array.isArray(e)?e:[e];const s=n.slice(0),o=[],a=[];for(;s.length>0;){const e=s.pop();o.push(e),e.childModules.forEach(e=>{s.indexOf(e)<0&&o.indexOf(e)<0&&(s.push(e),e.type===t&&a.push(e))})}return a}function findModsByType(e,t){var n;return(null===(n=null==e?void 0:e.graph)||void 0===n?void 0:n.modules.filter(e=>e.type===t))||[]}function findModByTypeAndPath(e,t,n){var s;return null===(s=e.graph)||void 0===s?void 0:s.modules.find(e=>e.type===t&&e.path===n)}function findPageMods(e,t){return(findModsByType(e,"Page")||[]).filter(e=>t.includes(e.path.replace(/\.json$/,"")))}function findGlobalCompMods(e){const t=findModByTypeAndPath(e,"MainPackage","app.json");return(null==t?void 0:t.childModules.filter(e=>"Component"===e.type))||[]}function getAllSubpackagePath(e){return findModsByType(e,"SubPackage").map(e=>e.path)}function innerGetSortedJSFiles(e,t){const n=new Set,s=new Set,o=new Set,a=[];for(const t of e){const e=t.findChild("Js");e&&(t.config?o.add(e.path):s.add(e.path),n.add(e.path),a.push(e))}const i=findAllDescendant(e.concat(t),"Component");for(const e of i.concat(t)){const t=e.findChild("Js");t&&(o.add(t.path),n.add(t.path),a.push(t))}const l=findAllDescendant(a,"Js");for(const e of l){const t=e.path;n.add(t)}return{allFiles:Array.from(n),pageFiles:Array.from(s),componentFiles:Array.from(o)}}function groupBySubpackage(e,t){const n=[],s={};for(const o of e){const e=t.find(e=>o.startsWith(e));e?(s[e]||(s[e]=[]),s[e].push(o)):n.push(o)}return{main:n,subs:s}}function partialGetSubPkgSortedJSFiles(e,t,n){const s=findPageMods(e,t);let{allFiles:o,pageFiles:a,componentFiles:i}=innerGetSortedJSFiles(s,[]);const l=getAllSubpackagePath(e);return{allFiles:groupBySubpackage(o,l).subs[n]||[],pageFiles:groupBySubpackage(a,l).subs[n]||[],componentFiles:groupBySubpackage(i,l).subs[n]||[]}}function partialGetMainPkgSortedJSFiles(e,t){const n=findPageMods(e,t),s=findGlobalCompMods(e);let{allFiles:o,pageFiles:a,componentFiles:i}=innerGetSortedJSFiles(n,s),l=!1;const p=findModByTypeAndPath(e,"Js","app.js");if(p){l=!0,o.push(p.path);const e=findAllDescendant([p],"Js");for(const t of e){const e=t.path;o.indexOf(e)<0&&o.push(e)}}const r=getAllSubpackagePath(e);return{hasAppJS:l,allFiles:groupBySubpackage(o,r).main,pageFiles:groupBySubpackage(a,r).main,componentFiles:groupBySubpackage(i,r).main}}function partialWholePkgGetSortedJSFiles(e,t){const n=findPageMods(e,t),s=findGlobalCompMods(e);let{allFiles:o,pageFiles:a,componentFiles:i}=innerGetSortedJSFiles(n,s),l=!1;const p=findModByTypeAndPath(e,"Js","app.js");if(p){l=!0,o.push(p.path);const e=findAllDescendant([p],"Js");for(const t of e){const e=t.path;o.indexOf(e)<0&&o.push(e)}}return{hasAppJS:l,allFiles:o,pageFiles:a,componentFiles:i}}function innerGetResourceFiles(e,t){let n=[];for(const s of e){const e=findAllDescendant(s,t);n=n.concat(e.map(e=>e.path))}return n}function partialGetWxmlAndWxsFiles(e,t,n){const s=findPageMods(e,t),o=findGlobalCompMods(e),a=innerGetResourceFiles(s.concat(o),"Wxml"),i=innerGetResourceFiles(s.concat(o),"Wxs"),l=getAllSubpackagePath(e),p=groupBySubpackage(a,l),r=groupBySubpackage(i,l);return{wxmlFiles:n?p.main.concat(p.subs[n]||[]):p.main,wxsFiles:n?r.main.concat(r.subs[n]||[]):r.main}}function partialGetWxssFiles(e,t,n){const s=findPageMods(e,t),o=findGlobalCompMods(e),a=innerGetResourceFiles(s.concat(o),"Wxss"),i=findModByTypeAndPath(e,"Wxss","app.wxss");if(i&&!a.includes(i.path)){a.push(i.path);const e=findAllDescendant(i,"Wxss");for(const t of e)a.includes(t.path)||a.push(t.path)}const l=groupBySubpackage(a,getAllSubpackagePath(e));return n?l.main.concat(l.subs[n]||[]):l.main}function partialGetCodeFiles(e,t){const n=new Set,s=findModByTypeAndPath(e,"MainPackage","app.json");n.add("app.json");const o=new Set;function a(e){switch(o.add(e),e.type){case"Page":case"Component":case"Wxml":case"Wxss":case"Wxs":case"Js":case"Config":n.add(e.path)}for(const t of e.childModules)o.has(t)||a(t)}for(const e of null==s?void 0:s.childModules)if("Page"===e.type)t.includes(e.path.replace(/\.json$/,""))&&a(e);else if("SubPackage"===e.type)for(const n of e.childModules)t.includes(n.path.replace(/\.json$/,""))&&a(n);else a(e);return console.log("[partial-compile] compile",n),Array.from(n)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.partialGetCodeFiles=exports.partialGetWxssFiles=exports.partialGetWxmlAndWxsFiles=exports.partialWholePkgGetSortedJSFiles=exports.partialGetMainPkgSortedJSFiles=exports.partialGetSubPkgSortedJSFiles=exports.findAllDescendant=void 0,exports.findAllDescendant=findAllDescendant,exports.partialGetSubPkgSortedJSFiles=partialGetSubPkgSortedJSFiles,exports.partialGetMainPkgSortedJSFiles=partialGetMainPkgSortedJSFiles,exports.partialWholePkgGetSortedJSFiles=partialWholePkgGetSortedJSFiles,exports.partialGetWxmlAndWxsFiles=partialGetWxmlAndWxsFiles,exports.partialGetWxssFiles=partialGetWxssFiles,exports.partialGetCodeFiles=partialGetCodeFiles;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const config_1=require("../../config"),_pluginTransformWorklet=()=>require("../../utils/babel_plugin_worklet"),babel7=()=>require("@babel/core"),workletCompile=e=>{const{code:r,filePath:l,inputSourceMap:i}=e,o=e.disableUseStrict||/^\s*\/\/\s?use strict disable;/i.test(r);let t=null;try{t=require("@babel/core").transform(r,{babelrc:!1,plugins:[require("../../utils/babel_plugin_worklet")],sourceFileName:l,inputSourceMap:i,sourceMaps:!0,configFile:!1})}catch(e){return{error:{message:`file: ${l}\n ${e.message}`,code:config_1.BABEL_TRANS_JS_ERR}}}let s=(null==t?void 0:t.code)||r;const u=(null==t?void 0:t.map)||i;return o&&(s=s.replace(/^"use strict";/,"")),{code:s,map:u,helpers:[]}};module.exports=workletCompile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),tools_1=require("../../../utils/tools"),config_1=require("../../../config"),call_func_1=require("./call_func"),log_1=tslib_1.__importDefault(require("../../../utils/log")),babel_helper_1=require("../../../utils/babel_helper"),jsonParse_1=require("../../../utils/jsonParse"),sourcemap=()=>require("source-map"),enhanceCompile=()=>require("../../js/enhance"),
|
|
1
|
+
"use strict";const tslib_1=require("tslib"),fs_1=tslib_1.__importDefault(require("fs")),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),tools_1=require("../../../utils/tools"),config_1=require("../../../config"),call_func_1=require("./call_func"),log_1=tslib_1.__importDefault(require("../../../utils/log")),babel_helper_1=require("../../../utils/babel_helper"),jsonParse_1=require("../../../utils/jsonParse"),sourcemap=()=>require("source-map"),enhanceCompile=()=>require("../../js/enhance"),workletCompile=()=>require("../../js/workletCompile"),es6Compile=()=>require("../../js/es6_transform"),minifyJS=()=>require("../../js/minifyjs"),minifyJSAfterWrap=()=>require("../../js/minifyjs_after_wrap"),MAX_CODE_LENGTH=512e3;async function tryGetInputSourceMap(e,r){try{const t=/\/\/[#|@] sourceMappingURL=[\s]*(\S*)[\s]*$/m.exec(e),s=path_1.default.posix.dirname(r),o=path_1.default.posix.basename(r);let i;if(null==t?void 0:t[1])if(/\.js\.map$/.test(t[1]))i=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(s,t[1]),"utf-8");else{const e=t[1].split("base64,")[1];i=Buffer.from(e,"base64").toString()}else{const e=path_1.default.posix.join(s,o+".map");fs_1.default.existsSync(e)&&(i=await(0,call_func_1.call)("readFileAsync",e,"utf-8"))}if(i){const e=(0,jsonParse_1.jsonParse)(i);new(require("source-map").SourceMapConsumer)(e);return await insertSourcesContent(e,r),e}}catch(e){log_1.default.log(`try to get input sourcemap of ${r} catch error ${e}`)}}const insertSourcesContent=async(e,r)=>{if(Array.isArray(e.sources)&&!Array.isArray(e.sourcesContent)){const t=e.sourcesContent;try{const t=path_1.default.posix.dirname(r),s=[],o=e.sources;for(const e of o){const r=await(0,call_func_1.call)("readFileAsync",path_1.default.posix.join(t,e),"utf-8");s.push(r)}e.sourcesContent=s}catch(r){e.sourcesContent=t}}};async function compileJS(e){const{code:r,filePath:t,projectPath:s,setting:o,babelRoot:i="@babel/runtime",root:a="",babelIgnore:n=[]}=e,{es7:l,es6:c,disableUseStrict:u,compileWorklet:p}=o,f="string"==typeof r?r:(0,tools_1.bufferToUtf8String)(Buffer.from(r)),_=path_1.default.posix.join(a,t),m=o.minify||o.minifyJS;if(void 0===f)return{error:{code:config_1.FILE_NOT_UTF8,path:_,message:locales_1.default.config.FILE_NOT_UTF8.format(_)}};const b=f.length>=512e3;let d=!1;l&&(d=(0,babel_helper_1.isIgnore)(n,t));const h=await tryGetInputSourceMap(f,path_1.default.posix.join(s,a,t));if(b||d)return{error:null,isLargeFile:b,isBabelIgnore:d,map:"object"==typeof h?JSON.stringify(h):h,code:f,helpers:[]};let g=f,j=h,y=[];if(l){const e=await require("../../js/enhance")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:h});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}else if(c){const e=require("../../js/es6_transform")({code:f,filePath:t,inputSourceMap:h});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map}else if(p){if(f.includes('"worklet"')||f.includes("'worklet'")){const e=await require("../../js/workletCompile")({code:f,babelRoot:i,filePath:t,disableUseStrict:u,inputSourceMap:h});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code||"",j=e.map,y=e.helpers||[]}}if(m){if(!c&&!l){const e=require("../../js/minifyjs_after_wrap")({filePath:t,code:g,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}else{const e=require("../../js/minifyjs")({filePath:t,code:g,useTerser:!!l,inputSourceMap:j});if(e.error)return{error:Object.assign(Object.assign({},e.error),{path:_})};g=e.code,j=e.map}}if("string"!=typeof j)try{(null==j?void 0:j.sourcesContent)&&(j.sourcesContent=j.sourcesContent.map(e=>e.replace(/\r\n/g,"\n"))),j=JSON.stringify(j)}catch(e){j=""}else j=j.replace(/\\r\\n/g,"\\n");return{error:null,isLargeFile:b,isBabelIgnore:d,map:j,code:g.replace(/\r\n/g,"\n"),helpers:y||[]}}module.exports=compileJS;
|
package/dist/manifest.json
CHANGED
package/dist/summer/ci.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tools_1=require("../utils/tools"),common_1=require("../core/compile/common"),project_1=require("./project"),recorder_1=require("./recorder"),summer_1=require("./summer");function getSummerOptions(e,r){const i=new Set;return i.add("javascript"),e&&(i.add(["es6module",{disableUseStrict:e.disableUseStrict}]),
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compile=void 0;const tools_1=require("../utils/tools"),common_1=require("../core/compile/common"),project_1=require("./project"),recorder_1=require("./recorder"),summer_1=require("./summer");function getSummerOptions(e,r){const i=new Set;return i.add("javascript"),e&&(i.add(["es6module",{disableUseStrict:e.disableUseStrict}]),e.es7||e.es6?i.add(["enhance",{disableUseStrict:e.disableUseStrict}]):e.compileWorklet&&i.add("worklet"),(e.minifyWXSS||e.autoPrefixWXSS)&&i.add("wxss"),e.minifyWXML&&i.add("minifywxml"),e.minify&&(i.add("terser"),i.add("wxss"))),r&&r.forEach(e=>{if("string"==typeof e)i.add(e);else{if(!Array.isArray(e))throw new Error("invalid useSummerCompiler options: "+JSON.stringify(e));if("string"!=typeof e[0]||void 0===e[1])throw new Error("invalid useSummerCompiler options: "+JSON.stringify(e));i.add(e)}}),Array.from(i)}async function compile(e,r,i,o){var t;const s={appid:e.appid,attr:await e.attr(),compileType:e.type,miniprogramRoot:e.miniprogramRoot,pluginRoot:e.pluginRoot,summerPlugins:getSummerOptions(i.setting,o),babelSetting:null===(t=null==r?void 0:r.setting)||void 0===t?void 0:t.babelSetting},n=e.getFilesAndDirs();n.files=n.files.filter(common_1.isNotIgnoredByProjectConfig.bind(null,r,e.miniprogramRoot));const m=new project_1.Project((0,tools_1.normalizePath)(e.projectPath),n.files,n.dirs,s),l=new summer_1.SummerCompiler(m,"",s),a=new recorder_1.Recorder((e,r,o)=>{var t;null===(t=i.onProgressUpdate)||void 0===t||t.call(i,{id:e.toString(),message:o,status:r})});return await l.compile({},a)}exports.compile=compile;
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const typescript=()=>require("./typescript"),sass=()=>require("./sass"),less=()=>require("./less"),enhance=()=>require("./enhance"),terser=()=>require("./terser"),javascript=()=>require("./base/javascript"),wxss=()=>require("./base/wxss"),es6module=()=>require("./base/es6module"),minifywxml=()=>require("./minifywxml"),plugins={typescript:typescript,less:less,sass:sass,enhance:enhance,javascript:javascript,terser:terser,wxss:wxss,es6module:es6module,minifywxml:minifywxml};exports.default={load:e=>e in plugins?plugins[e]().default:null};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const typescript=()=>require("./typescript"),sass=()=>require("./sass"),less=()=>require("./less"),enhance=()=>require("./enhance"),terser=()=>require("./terser"),javascript=()=>require("./base/javascript"),wxss=()=>require("./base/wxss"),es6module=()=>require("./base/es6module"),minifywxml=()=>require("./minifywxml"),worklet=()=>require("./worklet"),plugins={typescript:typescript,less:less,sass:sass,enhance:enhance,javascript:javascript,terser:terser,wxss:wxss,es6module:es6module,minifywxml:minifywxml,worklet:worklet};exports.default={load:e=>e in plugins?plugins[e]().default:null};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const config_1=require("../../config"),types_1=require("../types"),_pluginTransformWorklet=()=>require("../../utils/babel_plugin_worklet"),babel7=()=>require("@babel/core"),worklet=(e,r)=>{const t=babel7();let o;try{const s={babelrc:!1,plugins:[require("../../utils/babel_plugin_worklet")],sourceFileName:r,inputSourceMap:!1,configFile:!1,code:!1,ast:!0,cloneInputAst:!1};if(e.astInfo){if(e.astInfo.type!==types_1.AstType.Babel)throw new Error("ast type is not babel");o=t.transformFromAstSync(e.astInfo.ast,e.sourceCode,s)}else{if(null===e.sourceCode)throw new Error("source.targetCode is null");o=babel7().transform(e.sourceCode,s)}}catch(e){const t=`file: ${r}\n ${e.message}`,o=new Error(t);throw o.code=config_1.BABEL_TRANS_JS_ERR,o}return{sourceCode:e.sourceCode,inputMap:e.inputMap,astInfo:{ast:o.ast,type:types_1.AstType.Babel}}};function default_1(e,r){return{name:"summer-worklet",workerMethods:{worklet:worklet},async transform(e,r,t,{isBabelIgnore:o}){if(r.endsWith(".js")&&!o){return e.sourceCode.includes('"worklet"')||e.sourceCode.includes("'worklet'")?await this.runWorkerMethod("worklet",e,t):e}return e}}}exports.default=default_1;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
!function(require, directRequire){
|
|
2
|
-
"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,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=e.functionExpression(e.identifier(n),t.program.body[0].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,t.program.body[0].expression.body));return generate(o,{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 makeWorklet(e,t,r){const n=makeWorkletName(e,t),o=new Map,i=new Set,s=new ClosureGenerator,a={};t.traverse({DirectiveLiteral(e){"worklet"===e.node.value&&e.getFunctionParent()===t&&e.parentPath.remove()}});const l="\n("+(e.isObjectMethod(t)?"function ":"")+t.toString()+"\n)",c=transformSync(l,{filename:r,ast:!0,babelrc:!1,configFile:!1});t.parent&&t.parent.callee&&"createAnimatedStyle"===t.parent.callee.name&&(a.optFlags=isPossibleOptimization(c.ast)),traverse(c.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 i=e.scope;for(;null!=i;){if(null!=i.bindings[r])return;i=i.parent}o.set(r,e.node),s.addPath(r,e)},AssignmentExpression(t){const r=t.node.left;e.isMemberExpression(r)&&e.isIdentifier(r.object)&&e.isIdentifier(r.property,{name:"value"})&&i.add(r.object.name)}});const p=Array.from(o.values()),u=e.identifier("_f"),d=e.cloneNode(t.node);let m;m="BlockStatement"===d.body.type?e.functionExpression(null,d.params,d.body):d;const f=buildWorkletString(e,c.ast,p,n),b=hash(f),h=t&&t.node&&t.node.loc&&t.node.loc.start;if(h){const{line:e,column:t}=h;"number"==typeof e&&"number"==typeof t&&(r=`${r} (${e}:${t})`)}const g=[e.variableDeclaration("const",[e.variableDeclarator(u,m)]),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("_closure"),!1),s.generate(e,p,o.keys()))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("asString"),!1),e.stringLiteral(f))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("__workletHash"),!1),e.numericLiteral(b))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("__location"),!1),e.stringLiteral(r))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("__worklet"),!1),e.booleanLiteral(!0)))];g.push(e.returnStatement(u));return e.functionExpression(t.id,[],e.blockStatement(g))}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=makeWorklet(e,t,r),o=e.callExpression(n,[]),i=e.isScopable(t.parent)||e.isExportNamedDeclaration(t.parent);t.replaceWith(t.node.id&&i?e.variableDeclaration("const",[e.variableDeclarator(t.node.id,o)]):o)}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":{exit(t,r){const n=r.file.opts.filename||r.file.opts.sourceFileName;processIfWorkletNode(e,t,n)}}}}},module.exports.version="0.0.
|
|
2
|
+
"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=e.functionExpression(e.identifier(n),t.program.body[0].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,t.program.body[0].expression.body));return generate(o,{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 makeWorklet(e,t,r){const n=makeWorkletName(e,t),o=new Map,i=new Set,s=new ClosureGenerator,a={};t.traverse({DirectiveLiteral(e){"worklet"===e.node.value&&e.getFunctionParent()===t&&e.parentPath.remove()}});const l="\n("+(e.isObjectMethod(t)?"function ":"")+t.toString()+"\n)",c=transformSync(l,{filename:r,ast:!0,babelrc:!1,configFile:!1});t.parent&&t.parent.callee&&"createAnimatedStyle"===t.parent.callee.name&&(a.optFlags=isPossibleOptimization(c.ast)),traverse(c.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 i=e.scope;for(;null!=i;){if(null!=i.bindings[r])return;i=i.parent}o.set(r,e.node),s.addPath(r,e)},AssignmentExpression(t){const r=t.node.left;e.isMemberExpression(r)&&e.isIdentifier(r.object)&&e.isIdentifier(r.property,{name:"value"})&&i.add(r.object.name)}});const p=Array.from(o.values()),u=e.identifier("_f"),d=e.cloneNode(t.node);let m;m="BlockStatement"===d.body.type?e.functionExpression(null,d.params,d.body):d;const f=buildWorkletString(e,c.ast,p,n),b=hash(f),h=t&&t.node&&t.node.loc&&t.node.loc.start;if(h){const{line:e,column:t}=h;"number"==typeof e&&"number"==typeof t&&(r=`${r} (${e}:${t})`)}const g=[e.variableDeclaration("const",[e.variableDeclarator(u,m)]),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("_closure"),!1),s.generate(e,p,o.keys()))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("asString"),!1),e.stringLiteral(f))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("__workletHash"),!1),e.numericLiteral(b))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("__location"),!1),e.stringLiteral(r))),e.expressionStatement(e.assignmentExpression("=",e.memberExpression(u,e.identifier("__worklet"),!1),e.booleanLiteral(!0)))];g.push(e.returnStatement(u));return e.functionExpression(t.id,[],e.blockStatement(g))}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=makeWorklet(e,t,r),o=e.callExpression(n,[]),i=e.isScopable(t.parent)||e.isExportNamedDeclaration(t.parent);t.replaceWith(t.node.id&&i?e.variableDeclaration("const",[e.variableDeclarator(t.node.id,o)]):o)}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":{exit(t,r){const n=r.file.opts.filename||r.file.opts.sourceFileName;processIfWorkletNode(e,t,n)}}}}},module.exports.version="0.0.7";
|
|
3
3
|
}(require("licia/lazyImport")(require), require)
|
package/package.json
CHANGED