miniprogram-ci 1.9.7 → 1.9.9
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 +2 -0
- package/README.md +7 -0
- package/dist/@types/config.d.ts +1 -1
- package/dist/@types/utils/babel_plugin_worklet.d.ts +1 -0
- package/dist/@types/vendor/code-analyse/index.d.ts +4 -1
- package/dist/config.js +1 -1
- package/dist/core/analyse/partial.js +1 -1
- package/dist/manifest.json +2 -2
- package/dist/utils/babel_plugin_worklet.js +1 -1
- package/dist/vendor/babel_runtime/helpers/regeneratorRuntime.js +1 -1
- package/dist/vendor/code-analyse/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -6,6 +6,13 @@ miniprogram-ci 是从[微信开发者工具](https://developers.weixin.qq.com/mi
|
|
|
6
6
|
|
|
7
7
|
miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,调用方式与普通开发模式无异。[查看详情](#第三方平台开发)
|
|
8
8
|
|
|
9
|
+
## 最近变更
|
|
10
|
+
#### 1.9.8
|
|
11
|
+
- `fix` 修复 TypeError: _regeneratorRuntime3 is not a function 报错问题
|
|
12
|
+
#### 1.9.7
|
|
13
|
+
- `new` 更新 babel 版本到 7.21.4
|
|
14
|
+
|
|
15
|
+
>完整变更记录请查看 CHANGELOG.md 文件
|
|
9
16
|
## 注意事项
|
|
10
17
|
|
|
11
18
|
1. 代码上传密钥拥有预览、上传代码的权限
|
package/dist/@types/config.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -181,7 +181,10 @@ export declare interface IAnalyseResult {
|
|
|
181
181
|
|
|
182
182
|
declare interface IAppJSON {
|
|
183
183
|
pages?: string[];
|
|
184
|
-
workers?: string
|
|
184
|
+
workers?: string | {
|
|
185
|
+
path: string;
|
|
186
|
+
isSubpackage: boolean;
|
|
187
|
+
};
|
|
185
188
|
subPackages?: ISubpackageItem[];
|
|
186
189
|
subpackages?: ISubpackageItem[];
|
|
187
190
|
usingComponents?: IStringKeyMap;
|
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.9",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)
|
package/dist/manifest.json
CHANGED
|
@@ -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)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var t=require("./typeof");function r(){module.exports=r=function(){return e},module.exports.__esModule=!0,module.exports.default=module.exports;var e={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(t,r,e){t[r]=e.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{h({},"")}catch(t){h=function(t,r,e){return t[r]=e}}function f(t,r,e,n){var o=r&&r.prototype instanceof d?r:d,a=Object.create(o.prototype),c=new k(n||[]);return i(a,"_invoke",{value:E(t,e,c)}),a}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p={};function d(){}function v(){}function y(){}var g={};h(g,c,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(G([])));w&&w!==n&&o.call(w,c)&&(g=w);var x=y.prototype=d.prototype=Object.create(g);function L(t){["next","throw","return"].forEach((function(r){h(t,r,(function(t){return this._invoke(r,t)}))}))}function b(r,e){function n(i,a,c,u){var l=s(r[i],r,a);if("throw"!==l.type){var h=l.arg,f=h.value;return f&&"object"==t(f)&&o.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):e.resolve(f).then((function(t){h.value=t,c(h)}),(function(t){return n("throw",t,c,u)}))}u(l.arg)}var a;i(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return a=a?a.then(o,o):o()}})}function E(t,r,e){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return N()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var c=_(a,e);if(c){if(c===p)continue;return c}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var u=s(t,r,e);if("normal"===u.type){if(n=e.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(n="completed",e.method="throw",e.arg=u.arg)}}}function _(t,r){var e=r.method,n=t.iterator[e];if(void 0===n)return r.delegate=null,"throw"===e&&t.iterator.return&&(r.method="return",r.arg=void 0,_(t,r),"throw"===r.method)||"return"!==e&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+e+"' method")),p;var o=s(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,p;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,p):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,p)}function O(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function j(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function G(t){if(t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,n=function r(){for(;++e<t.length;)if(o.call(t,e))return r.value=t[e],r.done=!1,r;return r.value=void 0,r.done=!0,r};return n.next=n}}return{next:N}}function N(){return{value:void 0,done:!0}}return v.prototype=y,i(x,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:v,configurable:!0}),v.displayName=h(y,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===v||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,h(t,l,"GeneratorFunction")),t.prototype=Object.create(x),t},e.awrap=function(t){return{__await:t}},L(b.prototype),h(b.prototype,u,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new b(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},L(x),h(x,l,"Generator"),h(x,c,(function(){return this})),h(x,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=G,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function e(e,n){return a.type="throw",a.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var c=o.call(i,"catchLoc"),u=o.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),p},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),j(e),p}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;j(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:G(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),p}},e}module.exports=r,module.exports.__esModule=!0,module.exports.default=module.exports;
|