lottie-helper 1.1.0 → 1.1.2
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/bin/lottie.help.js +21 -3
- package/dist/bundle.min.js +1 -1
- package/package.json +32 -32
- package/pnpm-lock.yaml +2 -2
- package/readme.md +21 -3
- package/index.html +0 -20
package/bin/lottie.help.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/env node
|
1
|
+
#!/usr/bin/env node
|
2
2
|
|
3
3
|
const childProcess = require("child_process");
|
4
4
|
const { program } = require("commander");
|
@@ -9,7 +9,9 @@ const versionPath = join(versionDir, "package.json");
|
|
9
9
|
var packageJson = require(`${versionPath}`);
|
10
10
|
|
11
11
|
// * commander命令行参数处理
|
12
|
-
var jsonURL;
|
12
|
+
var jsonURL, ctrlRemove, envDEV;
|
13
|
+
|
14
|
+
// 命令行逻辑
|
13
15
|
program
|
14
16
|
.version(packageJson.version, "-v, -V , --version")
|
15
17
|
// 自定义lottie jsonURL
|
@@ -24,6 +26,18 @@ program
|
|
24
26
|
}
|
25
27
|
}
|
26
28
|
)
|
29
|
+
// 删除lohelp插入HTML的所有内容
|
30
|
+
.option(
|
31
|
+
"-r,--remove",
|
32
|
+
"remove: can reset all changes for lottie-helper",
|
33
|
+
() => {
|
34
|
+
ctrlRemove = true;
|
35
|
+
}
|
36
|
+
)
|
37
|
+
// 开发模式
|
38
|
+
.option("-D,--dev", "DEV: debug model", () => {
|
39
|
+
envDEV = true;
|
40
|
+
})
|
27
41
|
.parse(process.argv);
|
28
42
|
|
29
43
|
const nodeRunShell = (shell) => {
|
@@ -48,4 +62,8 @@ const nodeRunShell = (shell) => {
|
|
48
62
|
// 这里引用执行全局插件路径下的主文件
|
49
63
|
const mainPath = resolve(__dirname, "..");
|
50
64
|
// * 这里若是调试模式,则引入/dist/bundle.js未编译文件即可
|
51
|
-
nodeRunShell(
|
65
|
+
nodeRunShell(
|
66
|
+
`node ${mainPath}/dist/bundle${
|
67
|
+
envDEV ? "" : ".min"
|
68
|
+
}.js --userJsonURL ${jsonURL} ${ctrlRemove ? "--removeFlagFile" : ""}`
|
69
|
+
);
|
package/dist/bundle.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";function t(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t=function(){return e};var e={},r=Object.prototype,o=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof h?e:h,i=Object.create(o.prototype),a=new E(n||[]);return i._invoke=function(t,e,r){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 S()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=L(a,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p={};function h(){}function d(){}function v(){}var y={};s(y,a,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(P([])));g&&g!==r&&o.call(g,a)&&(y=g);var w=v.prototype=h.prototype=Object.create(y);function x(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(i,a,c,u){var s=f(t[i],t,a);if("throw"!==s.type){var l=s.arg,p=l.value;return p&&"object"==n(p)&&o.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):e.resolve(p).then((function(t){l.value=t,c(l)}),(function(t){return r("throw",t,c,u)}))}u(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}}function L(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,L(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function P(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(o.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:S}}function S(){return{value:void 0,done:!0}}return d.prototype=v,s(w,"constructor",v),s(v,"constructor",d),d.displayName=s(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,u,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(b.prototype),s(b.prototype,c,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new b(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),s(w,u,"Generator"),s(w,a,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=P,E.prototype={constructor:E,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(k),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=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 e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.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 r("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 r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){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&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function e(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,c,u,"throw",t)}c(void 0)}))}}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var o=require("minimist"),i=require("cheerio"),a=require("fs"),c=require("path"),u=require("axios");function s(t){return t&&"object"===n(t)&&"default"in t?t:{default:t}}var l=s(o),f=s(i),p=s(a),h=s(c),d=s(u),v=function(){var e=r(t().mark((function e(){var r,n=arguments;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n.length>0&&void 0!==n[0]?n[0]:"index.html",t.prev=1,console.log("loadHTML running..."),t.abrupt("return",new Promise((function(t,e){var n=h.default.join(process.cwd(),r);p.default.readFile(n,"utf-8",(function(r,n){if(r)return e(r);t(n)}))})));case 6:t.prev=6,t.t0=t.catch(1),Promise.reject(t.t0);case 9:case"end":return t.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=r(t().mark((function e(r,n){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,console.log("writeHTML running..."),t.abrupt("return",new Promise((function(t,e){var o=h.default.join(process.cwd(),r);p.default.writeFile(o,n,"utf-8",(function(r){if(r)return e(r);t("write done")}))})));case 5:t.prev=5,t.t0=t.catch(0),Promise.reject(t.t0);case 8:case"end":return t.stop()}}),e,null,[[0,5]])})));return function(t,r){return e.apply(this,arguments)}}(),m=function(){var e=r(t().mark((function e(r){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,console.log("loadJs running..."),t.abrupt("return",new Promise((function(t,e){var n=h.default.join(__dirname,r);p.default.readFile("".concat(n),"utf-8",(function(r,n){if(r)return e(r);t(n)}))})));case 5:t.prev=5,t.t0=t.catch(0),Promise.reject(t.t0);case 8:case"end":return t.stop()}}),e,null,[[0,5]])})));return function(t){return e.apply(this,arguments)}}(),g=d.default.create({timeout:3e5,headers:{Authorization:""}});g.interceptors.response.use((function(t){return t}),(function(t){return t.response,Promise.reject(t)}));var w={domain:"https://callbackhell.xyz"};function x(t){!function(t){g.defaults.headers.Authorization="Bearer ".concat(t)}(t)}console.log("%c 🍬 config","color:#465975",w);var b=l.default(process.argv.slice(2)).userJsonURL;console.log("userJsonURL:",b);var L="undefined"!==b&&b;r(t().mark((function e(){var n,o,i,a,c,u,s,l,p,h,d,b,j,k,E;return t().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,new Promise(function(){var e=r(t().mark((function e(r,n){var o,i,a,c,u,s,l,f,p,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,o="".concat(w.domain,"/lottie-json/token?name=sxh&&password=123456"),t.next=5,g(o);case 5:i=t.sent,a=i.status,c=i.data,u=c.data,s=c.code,l=c.msg,200===a&&200===s?(f=(null==u?void 0:u.token)||"",r(f)):n(l),t.next=16;break;case 12:t.prev=12,t.t0=t.catch(0),p=t.t0.response,h=p.status,d=p.statusText,n({status:h,statusText:d});case 16:case"end":return t.stop()}}),e,null,[[0,12]])})));return function(t,r){return e.apply(this,arguments)}}());case 3:x(e.sent),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.log("getTokenErr: ".concat(e.t0));case 10:return n="it fuckin empty jsonResult.",o=L||"/lottie-json/lottie-2.json",i="".concat(w.domain).concat(o),e.prev=14,e.next=17,g(i);case 17:if(a=e.sent,c=a.status,u=a.data,200!==c){e.next=24;break}n=JSON.stringify(u),e.next=25;break;case 24:return e.abrupt("return",new Error(" [ERROR] URL RESPONSE STATUS: ".concat(c)));case 25:e.next=33;break;case 27:e.prev=27,e.t1=e.catch(14),s=e.t1.response,l=s.status,p=s.statusText,console.log("status:".concat(l)),console.log("statusText:".concat(p)),console.log("get jsonURL error, please check you jsonURL.");case 33:return e.prev=33,h="index.html",e.next=37,v(h);case 37:return d=e.sent,b=f.default.load(d),e.next=41,m("controller.min.js");case 41:return j=e.sent,b("body").prepend('<script type="text/javascript">'.concat(j,"<\/script>")),b("body").prepend('<script type="text/javascript">window.animateJson='.concat(n,"<\/script>")),b("body").prepend('<div id="lottie-wrapper"><div id="lottie"></div></div>'),b("head").append("<style>#lottie-wrapper {position: absolute;left: 0;top: 0;width: 100%;height: 100%;background: #fff;background-size: cover;z-index: 999999 !important;transition: all 1s;overflow: hidden;}#lottie {position: absolute;left: 50%;top: 50%;width: 50%;transform: translate(-50%, -50%);}</style>"),b("head").append('<script src="https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.9.6/lottie.min.js"><\/script>'),k=b.html(),e.next=50,y(h,k);case 50:E=e.sent,console.log(E),e.next=57;break;case 54:e.prev=54,e.t2=e.catch(33),console.log(e.t2);case 57:case"end":return e.stop()}}),e,null,[[0,7],[14,27],[33,54]])})))();
|
1
|
+
"use strict";function t(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t=function(){return e};var e={},r=Object.prototype,o=r.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof h?e:h,a=Object.create(o.prototype),i=new E(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return S()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=L(i,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p={};function h(){}function d(){}function v(){}var y={};s(y,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(P([])));g&&g!==r&&o.call(g,i)&&(y=g);var w=v.prototype=h.prototype=Object.create(y);function x(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){function r(a,i,c,u){var s=f(t[a],t,i);if("throw"!==s.type){var l=s.arg,p=l.value;return p&&"object"==n(p)&&o.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):e.resolve(p).then((function(t){l.value=t,c(l)}),(function(t){return r("throw",t,c,u)}))}u(s.arg)}var a;this._invoke=function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}}function L(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,L(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=f(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function P(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,n=function e(){for(;++r<t.length;)if(o.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return n.next=n}}return{next:S}}function S(){return{value:void 0,done:!0}}return d.prototype=v,s(w,"constructor",v),s(v,"constructor",d),d.displayName=s(v,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,u,"GeneratorFunction")),t.prototype=Object.create(w),t},e.awrap=function(t){return{__await:t}},x(b.prototype),s(b.prototype,c,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new b(l(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},x(w),s(w,u,"Generator"),s(w,i,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=P,E.prototype={constructor:E,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(k),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=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 e=this;function r(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=o.call(a,"catchLoc"),u=o.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,p):this.complete(i)},complete:function(t,e){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&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}function e(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function c(t){e(i,o,a,c,u,"next",t)}function u(t){e(i,o,a,c,u,"throw",t)}c(void 0)}))}}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var o=require("minimist"),a=require("cheerio"),i=require("fs"),c=require("path"),u=require("axios");function s(t){return t&&"object"===n(t)&&"default"in t?t:{default:t}}var l=s(o),f=s(a),p=s(i),h=s(c),d=s(u),v=function(){var e=r(t().mark((function e(){var r,n=arguments;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n.length>0&&void 0!==n[0]?n[0]:"index.html",t.prev=1,console.log("loadHTML running..."),t.abrupt("return",new Promise((function(t,e){var n=h.default.join(process.cwd(),r);p.default.readFile(n,"utf-8",(function(r,n){if(r)return e(r);t(n)}))})));case 6:t.prev=6,t.t0=t.catch(1),Promise.reject(t.t0);case 9:case"end":return t.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=r(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,console.log("loadHTMLDir running..."),t.abrupt("return",new Promise((function(t,e){var r=h.default.join(process.cwd());p.default.readdir(r,"utf-8",(function(r,n){if(r)return e(r);t(n)}))})));case 5:t.prev=5,t.t0=t.catch(0),Promise.reject(t.t0);case 8:case"end":return t.stop()}}),e,null,[[0,5]])})));return function(){return e.apply(this,arguments)}}(),m=function(){var e=r(t().mark((function e(r,n){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,console.log("writeHTML running..."),t.abrupt("return",new Promise((function(t,e){var o=h.default.join(process.cwd(),r);p.default.writeFile(o,n,"utf-8",(function(r){if(r)return e(r);t("write done")}))})));case 5:t.prev=5,t.t0=t.catch(0),Promise.reject(t.t0);case 8:case"end":return t.stop()}}),e,null,[[0,5]])})));return function(t,r){return e.apply(this,arguments)}}(),g=function(){var e=r(t().mark((function e(r){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,console.log("loadJs running..."),t.abrupt("return",new Promise((function(t,e){var n=h.default.join(__dirname,r);p.default.readFile("".concat(n),"utf-8",(function(r,n){if(r)return e(r);t(n)}))})));case 5:t.prev=5,t.t0=t.catch(0),Promise.reject(t.t0);case 8:case"end":return t.stop()}}),e,null,[[0,5]])})));return function(t){return e.apply(this,arguments)}}(),w=d.default.create({timeout:3e5,headers:{Authorization:""}});w.interceptors.response.use((function(t){return t}),(function(t){return t.response,Promise.reject(t)}));var x="https://callbackhell.xyz",b="index.html",L="lohelp--doge-420",j=function(){return new Promise(function(){var e=r(t().mark((function e(r,n){var o,a,i,c,u,s,l,f,p,h,d;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,o="".concat(x,"/lottie-json/token?name=sxh&&password=123456"),t.next=5,w(o);case 5:a=t.sent,i=a.status,c=a.data,u=c.data,s=c.code,l=c.msg,200===i&&200===s?(f=(null==u?void 0:u.token)||"",r(f)):n(l),t.next=16;break;case 12:t.prev=12,t.t0=t.catch(0),p=t.t0.response,h=p.status,d=p.statusText,n({status:h,statusText:d});case 16:case"end":return t.stop()}}),e,null,[[0,12]])})));return function(t,r){return e.apply(this,arguments)}}())};function k(t){!function(t){w.defaults.headers.Authorization="Bearer ".concat(t)}(t)}function E(){return P.apply(this,arguments)}function P(){return(P=r(t().mark((function e(){var r,n,o,a,i;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,y();case 3:if(r=t.sent,o=r.find((function(t){return t===b})),n=o||r.find((function(t){if("html"===t.split(".").pop().toLowerCase())return t}))){t.next=8;break}return t.abrupt("return",Promise.reject("lottie-helper ERR: 同级目录下未找到.html文件"));case 8:return console.log("target resource: ".concat(n)),global.targetFileName=n,t.next=12,v(n);case 12:return a=t.sent,i=f.default.load(a),t.abrupt("return",i);case 17:t.prev=17,t.t0=t.catch(0),console.log(t.t0),Promise.reject(t.t0);case 21:case"end":return t.stop()}}),e,null,[[0,17]])})))).apply(this,arguments)}function S(t){return _.apply(this,arguments)}function _(){return(_=r(t().mark((function e(r){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r("div[class=".concat(L,"]")).remove(),r("style[class=".concat(L,"]")).remove(),r("script[class=".concat(L,"]")).remove();case 3:case"end":return t.stop()}}),e)})))).apply(this,arguments)}function O(t,e){return T.apply(this,arguments)}function T(){return(T=r(t().mark((function e(r,n){var o;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,g("controller.min.js");case 2:o=t.sent,r("body").prepend('<script type="text/javascript" class="'.concat(L,'">').concat(o,"<\/script>")),r("body").prepend('<script type="text/javascript" class="'.concat(L,'">window.animateJson=').concat(n,"<\/script>")),r("body").prepend('<div id="lottie-wrapper" class="'.concat(L,'"><div id="lottie"></div></div>')),r("head").append('<style class="'.concat(L,'">#lottie-wrapper {position: absolute;left: 0;top: 0;width: 100%;height: 100%;background: #fff;background-size: cover;z-index: 999999 !important;transition: all 1s;overflow: hidden;}#lottie {position: absolute;left: 50%;top: 50%;width: 50%;transform: translate(-50%, -50%);}</style>')),r("head").append('<script src="https://cdnjs.cloudflare.com/ajax/libs/lottie-web/5.9.6/lottie.min.js" class="'.concat(L,'"><\/script>'));case 8:case"end":return t.stop()}}),e)})))).apply(this,arguments)}function R(t){return F.apply(this,arguments)}function F(){return F=r(t().mark((function e(r){var n,o,a,i,c,u,s,l,f;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n="it fuckin empty jsonResult.",o=r||"/lottie-json/lottie-2.json",a="".concat(x).concat(o),t.prev=4,t.next=7,w(a);case 7:if(i=t.sent,c=i.status,u=i.data,200!==c){t.next=14;break}n=JSON.stringify(u),t.next=15;break;case 14:return t.abrupt("return",new Error(" [ERROR] URL RESPONSE STATUS: ".concat(c)));case 15:t.next=23;break;case 17:t.prev=17,t.t0=t.catch(4),s=t.t0.response,l=s.status,f=s.statusText,console.log("status:".concat(l)),console.log("statusText:".concat(f)),console.log("get jsonURL error, please check you jsonURL.");case 23:return t.abrupt("return",n);case 24:case"end":return t.stop()}}),e,null,[[4,17]])}))),F.apply(this,arguments)}function N(t){return G.apply(this,arguments)}function G(){return(G=r(t().mark((function e(r){var n,o,a;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=r.html(),o=global.targetFileName,t.next=4,m(o,n);case 4:a=t.sent,console.log(a);case 6:case"end":return t.stop()}}),e)})))).apply(this,arguments)}function A(){return U.apply(this,arguments)}function U(){return(U=r(t().mark((function e(){return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,j();case 3:k(t.sent),t.next=10;break;case 7:t.prev=7,t.t0=t.catch(0),console.log("coreAuthErr: ".concat(t.t0));case 10:case"end":return t.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}var q=l.default(process.argv.slice(2)),z=q.userJsonURL;q.removeFlagFile;console.log(q),console.log("userJsonURL:",z);var J="undefined"!==z&&z;console.log("Release-Time:".concat(new Date)),r(t().mark((function e(){var r,n;return t().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,A();case 3:return t.next=5,E();case 5:return S(r=t.sent),t.next=9,R(J);case 9:return n=t.sent,t.next=12,O(r,n);case 12:return t.next=14,N(r);case 14:t.next=19;break;case 16:t.prev=16,t.t0=t.catch(0),console.log(t.t0);case 19:case"end":return t.stop()}}),e,null,[[0,16]])})))();
|
package/package.json
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
{
|
2
|
-
"name": "lottie-helper",
|
3
|
-
"version": "1.1.
|
4
|
-
"description": "lottie-helper",
|
5
|
-
"main": "./src/index.js",
|
6
|
-
"bin": {
|
7
|
-
"lohelp": "bin/lottie.help.js"
|
8
|
-
},
|
9
|
-
"scripts": {
|
10
|
-
"start": "node run build",
|
11
|
-
"action": "node dist/bundle.min.js",
|
12
|
-
"build": "pnpm i && npm run build-controller && npm run build-main",
|
13
|
-
"build-main": "npx rollup -c ./rollup.config.js",
|
14
|
-
"build-controller": "npx rollup -c ./rollup.config.controller.js",
|
15
|
-
"test": "echo \"Error: no test specified\""
|
16
|
-
},
|
17
|
-
"author": "jf",
|
18
|
-
"license": "MIT",
|
19
|
-
"devDependencies": {
|
20
|
-
"@babel/core": "^7.0.0",
|
21
|
-
"@babel/preset-env": "^7.18.10",
|
22
|
-
"@rollup/plugin-babel": "^5.3.1",
|
23
|
-
"@rollup/plugin-json": "^4.1.0",
|
24
|
-
"rollup-plugin-terser": "^7.0.2"
|
25
|
-
},
|
26
|
-
"dependencies": {
|
27
|
-
"axios": "^0.27.2",
|
28
|
-
"cheerio": "
|
29
|
-
"commander": "^9.4.0",
|
30
|
-
"minimist": "
|
31
|
-
}
|
32
|
-
}
|
1
|
+
{
|
2
|
+
"name": "lottie-helper",
|
3
|
+
"version": "1.1.2",
|
4
|
+
"description": "lottie-helper",
|
5
|
+
"main": "./src/index.js",
|
6
|
+
"bin": {
|
7
|
+
"lohelp": "bin/lottie.help.js"
|
8
|
+
},
|
9
|
+
"scripts": {
|
10
|
+
"start": "node run build",
|
11
|
+
"action": "node dist/bundle.min.js",
|
12
|
+
"build": "pnpm i && npm run build-controller && npm run build-main",
|
13
|
+
"build-main": "npx rollup -c ./rollup.config.js",
|
14
|
+
"build-controller": "npx rollup -c ./rollup.config.controller.js",
|
15
|
+
"test": "echo \"Error: no test specified\""
|
16
|
+
},
|
17
|
+
"author": "jf",
|
18
|
+
"license": "MIT",
|
19
|
+
"devDependencies": {
|
20
|
+
"@babel/core": "^7.0.0",
|
21
|
+
"@babel/preset-env": "^7.18.10",
|
22
|
+
"@rollup/plugin-babel": "^5.3.1",
|
23
|
+
"@rollup/plugin-json": "^4.1.0",
|
24
|
+
"rollup-plugin-terser": "^7.0.2"
|
25
|
+
},
|
26
|
+
"dependencies": {
|
27
|
+
"axios": "^0.27.2",
|
28
|
+
"cheerio": "1.0.0-rc.12",
|
29
|
+
"commander": "^9.4.0",
|
30
|
+
"minimist": "1.2.6"
|
31
|
+
}
|
32
|
+
}
|
package/pnpm-lock.yaml
CHANGED
package/readme.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
## 教程
|
8
8
|
|
9
|
-
只需在你的 HTML 同级目录,执行如下命令:
|
9
|
+
只需在你的 `.HTML` 同级目录,执行如下命令:
|
10
10
|
|
11
11
|
```shell
|
12
12
|
npx lottie-helper lohelp
|
@@ -44,7 +44,7 @@ npx lottie-helper lohelp -j /lottie-json/118336-please-wait.json
|
|
44
44
|
|
45
45
|
一键自定义想要的 Lottie 动画内容!
|
46
46
|
|
47
|
-
>
|
47
|
+
> 自定义的动画资源可在[【资源】](#资源)标题中查找。
|
48
48
|
|
49
49
|
- `-j`
|
50
50
|
|
@@ -58,8 +58,26 @@ npx lottie-helper lohelp -j /lottie-json/118336-please-wait.json
|
|
58
58
|
|
59
59
|
|
60
60
|
|
61
|
+
## feature
|
62
|
+
|
63
|
+
- 可随意重复执行`npx lottie-helper lohelp`,插件会自动帮你初始化改动!
|
64
|
+
|
65
|
+
- 技术栈无关,只关心你最终的HTML资源变动!
|
66
|
+
|
67
|
+
- 将`npx lottie-helper lohelp`加在你的编译脚本之后,即可自动化添加首屏动画!
|
68
|
+
|
69
|
+
```shell
|
70
|
+
vue-cli-service build && npx lottie-helper lohelp
|
71
|
+
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
61
79
|
|
62
80
|
## TODO
|
63
81
|
|
64
|
-
- inquirer
|
82
|
+
- inquirer,控制台箭头操作,常用交互式命令行用户界面的集合
|
65
83
|
|
package/index.html
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head>
|
2
|
-
<meta charset="utf-8">
|
3
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
4
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
5
|
-
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
6
|
-
<title><%= htmlWebpackPlugin.options.title %></title>
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<noscript>
|
10
|
-
<strong
|
11
|
-
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
|
12
|
-
properly without JavaScript enabled. Please enable it to
|
13
|
-
continue.</strong
|
14
|
-
>
|
15
|
-
</noscript>
|
16
|
-
<div id="app" class="app-wrapper"></div>
|
17
|
-
<!-- built files will be auto injected -->
|
18
|
-
|
19
|
-
|
20
|
-
</body></html>
|