jeawin-astro 1.0.1
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/.babelrc +10 -0
- package/README.md +1 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js +1 -0
- package/dist/cms.js +1 -0
- package/dist/index.js +1 -0
- package/dist/util.js +1 -0
- package/es/_virtual/_rollupPluginBabelHelpers.js +1 -0
- package/es/cms.js +1 -0
- package/es/index.js +1 -0
- package/es/util.js +1 -0
- package/example/index.test.js +1 -0
- package/package.json +43 -0
- package/rollup.config.js +56 -0
- package/src/cms.js +1079 -0
- package/src/index.ts +3 -0
- package/src/util.js +135 -0
- package/tsconfig.json +31 -0
package/.babelrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# jeawin astro tools
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function t(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function r(){r=function(){return e};var t,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",h=a.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function l(t,r,e,n){var o=r&&r.prototype instanceof m?r:m,a=Object.create(o.prototype),c=new T(n||[]);return i(a,"_invoke",{value:G(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=l;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",g={};function m(){}function w(){}function L(){}var x={};f(x,c,(function(){return this}));var b=Object.getPrototypeOf,E=b&&b(b(S([])));E&&E!==n&&o.call(E,c)&&(x=E);var _=L.prototype=m.prototype=Object.create(x);function O(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function j(t,r){function e(n,i,a,c){var u=s(t[n],t,i);if("throw"!==u.type){var h=u.arg,f=h.value;return f&&"object"==typeof f&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(f).then((function(t){h.value=t,a(h)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function G(r,e,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var h=s(r,e,n);if("normal"===h.type){if(o=n.done?d:y,h.arg===g)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(o=d,n.method="throw",n.arg=h.arg)}}}function P(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,P(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=s(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function k(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 N(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(o.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return w.prototype=L,i(_,"constructor",{value:L,configurable:!0}),i(L,"constructor",{value:w,configurable:!0}),w.displayName=f(L,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,L):(t.__proto__=L,f(t,h,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},O(j.prototype),f(j.prototype,u,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new j(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(_),f(_,h,"Generator"),f(_,c,(function(){return this})),f(_,"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=S,T.prototype={constructor:T,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),h=o.call(a,"finallyLoc");if(u&&h){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!h)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.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,g):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),g},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),N(e),g}},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;N(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:S(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}exports.asyncToGenerator=function(r){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=r.apply(e,n);function c(r){t(a,o,i,c,u,"next",r)}function u(r){t(a,o,i,c,u,"throw",r)}c(void 0)}))}},exports.regeneratorRuntime=r;
|
package/dist/cms.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),r=require("lodash");require("dayjs");var n=require("node:crypto"),t=require("keyv"),a=require("@keyv/compress-brotli"),o=require("keyv-lru"),u=require("./util.js"),s="1d",c=!0;(void 0).PROD&&(s="1d",c=!1);var i=new t({store:new o.KeyvLru({max:5e3,notify:!1,ttl:0,expire:0}),namespace:"site_".concat((void 0).JEAWIN_SITE_ID),compression:new a});function p(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"0s",n=r.substring(r.length,1);return"s"===n?e=1:"m"===n?e=60:"h"===n?e=3600:"d"===n?e=86400:"w"===n?e=604800:"y"===n&&(e=31536e3),parseInt(r.substring(0,r.length-1),10)*e*1e3}function d(e,r){return l.apply(this,arguments)}function l(){return(l=e.asyncToGenerator(e.regeneratorRuntime().mark((function t(a,o){var u,s,c,d,l,h,_,f,m,g,y;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(u="json",s="0s",r.has(o,"type")&&(u=o.type),r.has(o,"verbose")&&o.verbose,r.has(o,"duration")&&(s=o.duration),c=p(s),d={},r.has(o,"fetchOptions")&&(d=o.fetchOptions),l="",l=r.has(d,"method")&&"POST"===r.toUpper(d.method)?n.createHash("md5").update(a+d.body.toString()).digest("hex"):n.createHash("md5").update(a).digest("hex"),!(c>0)){e.next=21;break}return e.next=14,i.has(l);case 14:if(!e.sent){e.next=21;break}return e.next=18,i.get(l);case 18:return h=e.sent,_=JSON.parse(h),e.abrupt("return",Promise.resolve(_));case 21:return e.prev=21,e.next=25,fetch(a,d);case 25:if((f=e.sent).ok){e.next=29;break}return m=new Error("Fetch error! status: ".concat(f.status)),e.abrupt("return",Promise.reject(m));case 29:g=null,y="",e.t0=u,e.next="text"===e.t0?34:39;break;case 34:return e.next=36,f.text();case 36:return g=e.sent,y=g,e.abrupt("break",44);case 39:return e.next=41,f.json();case 41:return g=e.sent,y=JSON.stringify(g),e.abrupt("break",44);case 44:return c>0&&i.set(l,y,c),e.abrupt("return",Promise.resolve(g));case 48:return e.prev=48,e.t1=e.catch(21),e.abrupt("return",Promise.reject(e.t1));case 52:case"end":return e.stop()}}),t,null,[[21,48]])})))).apply(this,arguments)}var h="".concat((void 0).JEAWIN_API_DOMAIN).concat((void 0).JEAWIN_API_PATH,"&site_id=").concat((void 0).JEAWIN_SITE_ID);function _(){return(_=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.clear();case 2:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function f(){return(f=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var n;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,d("".concat(h,"&m=index"));case 3:if(n=e.sent,0!==Number(n.code)){e.next=7;break}return e.abrupt("return",n.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function m(){return(m=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),r.has(t,"seo_title")&&a.append("seo_title",t.seo_title||""),r.has(t,"seo_description")&&a.append("seo_description",t.seo_description||""),e.next=7,d("".concat(h,"&m=share_button&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 7:if(o=e.sent,0!==Number(o.code)){e.next=11;break}return e.abrupt("return",o.data);case 11:return e.abrupt("return",null);case 12:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function g(){return(g=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"node_id")&&a.append("node_id",t.node_id),e.next=8,d("".concat(h,"&m=comment_form&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 8:if(o=e.sent,0!==Number(o.code)){e.next=12;break}return e.abrupt("return",o.data);case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function y(){return(y=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),e.next=5,d("".concat(h,"&m=stats&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function b(){return(b=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"node_id")&&a.append("node_id",t.node_id||""),e.next=5,d("".concat(h,"&m=author_info&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function x(){return(x=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var n;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,d("".concat(h,"&m=country"),{verbose:c,duration:s,type:"json"});case 3:if(n=e.sent,0!==Number(n.code)){e.next=7;break}return e.abrupt("return",n.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function v(){return(v=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var n;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,d("".concat(h,"&m=glossary"),{verbose:c,duration:s,type:"json"});case 3:if(n=e.sent,0!==Number(n.code)){e.next=7;break}return e.abrupt("return",n.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function w(){return(w=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"form_id")&&a.append("form_id",t.form_id||""),e.next=5,d("".concat(h,"&m=form&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function R(){return(R=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var n;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,d("".concat(h,"&m=all_langs"),{verbose:c,duration:s,type:"json"});case 3:if(n=e.sent,0!==Number(n.code)){e.next=7;break}return e.abrupt("return",n.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function k(){return(k=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"key")&&a.append("key",t.key||""),e.next=5,d("".concat(h,"&m=get_lang&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function S(){return(S=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var n;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,d("".concat(h,"&m=all_uri"),{verbose:c,duration:s,type:"json"});case 3:if(n=e.sent,0!==Number(n.code)){e.next=7;break}return e.abrupt("return",n.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function j(){return(j=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var n;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,d("".concat(h,"&m=site_options"),{verbose:c,duration:s,type:"json"});case 3:if(n=e.sent,0!==Number(n.code)){e.next=7;break}return e.abrupt("return",{data:n.data,siteinfo:n.siteinfo});case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function N(){return(N=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"option_name")&&a.append("option_name",t.option_name||""),e.next=5,d("".concat(h,"&m=site_option&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function T(){return(T=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"menu_id")&&a.append("menu_id",t.menu_id||""),r.has(t,"parent_id")&&a.append("parent_id",t.parent_id||""),e.next=6,d("".concat(h,"&m=menus&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 6:if(o=e.sent,0!==Number(o.code)){e.next=10;break}return e.abrupt("return",o.data);case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function P(){return(P=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"menu_id")&&a.append("menu_id",t.menu_id||""),e.next=5,d("".concat(h,"&m=menu_tree&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function G(){return(G=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function L(){return(L=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"block_id")&&a.append("block_id",t.block_id||""),e.next=5,d("".concat(h,"&m=block&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function U(){return(U=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"show_hreflang")&&a.append("show_hreflang",t.show_hreflang||""),r.has(t,"show_ldjson")&&a.append("show_ldjson",t.show_ldjson||""),r.has(t,"field_array")&&a.append("field_array",JSON.stringify(t.field_array||"")),e.next=8,d("".concat(h,"&m=channel&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 8:if(o=e.sent,0!==Number(o.code)){e.next=12;break}return e.abrupt("return",o.data);case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function O(){return(O=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(n){var t,a;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new URLSearchParams,e.next=4,d("".concat(h,"&m=all_categories&").concat(t.toString()),{verbose:c,duration:s,type:"json"});case 4:if(a=e.sent,0!==Number(a.code)){e.next=8;break}return e.abrupt("return",a.data);case 8:return e.abrupt("return",null);case 9:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function J(){return(J=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"parent_id")&&a.append("parent_id",t.parent_id||""),e.next=6,d("".concat(h,"&m=categories&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 6:if(o=e.sent,0!==Number(o.code)){e.next=10;break}return e.abrupt("return",o.data);case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function I(){return(I=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),e.next=5,d("".concat(h,"&m=category_tree&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function q(){return(q=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"show_hreflang")&&a.append("show_hreflang",t.show_hreflang||""),r.has(t,"show_ldjson")&&a.append("show_ldjson",t.show_ldjson||""),r.has(t,"field_array")&&a.append("field_array",JSON.stringify(t.field_array||"")),e.next=8,d("".concat(h,"&m=category&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 8:if(o=e.sent,0!==Number(o.code)){e.next=12;break}return e.abrupt("return",o.data);case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function A(){return(A=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,u.render_value(t,"channel_id")&&a.append("channel_id",t.channel_id||""),u.render_value(t,"category_id")&&a.append("category_id",t.category_id||""),u.render_value(t,"limit_type")&&a.append("limit_type",t.limit_type||""),u.render_value(t,"sort")&&a.append("sort",t.sort||""),u.render_value(t,"sortorder")&&a.append("sortorder",t.sortorder||""),u.render_value(t,"per_page")&&a.append("page_size",t.per_page||""),u.render_value(t,"page")&&a.append("page",t.page||1),u.render_value(t,"include_children_category_nodes")&&a.append("include_children_category_nodes",t.include_children_category_nodes||""),r.has(t,"no_fields")&&a.append("no_fields",t.no_fields||""),r.has(t,"no_images_html")&&a.append("no_images_html",t.no_images_html||""),r.has(t,"field_array")&&a.append("field_array",JSON.stringify(t.field_array||"")),e.next=15,d("".concat(h,"&m=nodes&").concat(a.toString()),{verbose:c,duration:s,type:"json",directory:".cache/nodes/".concat(t.channel_id?t.channel_id+"/":"")});case 15:if(o=e.sent,0!==Number(o.code)){e.next=19;break}return e.abrupt("return",o.data);case 19:return e.abrupt("return",null);case 20:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function E(){return(E=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"field_id")&&a.append("field_id",t.field_id||""),r.has(t,"rel_id")&&a.append("rel_id",t.rel_id||""),r.has(t,"page")&&a.append("page",t.page||""),r.has(t,"page_size")&&a.append("page_size",t.page_size||""),r.has(t,"no_fields")&&a.append("no_fields",t.no_fields||""),r.has(t,"no_images_html")&&a.append("no_images_html",t.no_images_html||""),e.next=10,d("".concat(h,"&m=rel_nodes&").concat(a.toString()),{verbose:c,duration:"0s",type:"json"});case 10:if(o=e.sent,0!==Number(o.code)){e.next=14;break}return e.abrupt("return",o.data);case 14:return e.abrupt("return",null);case 15:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function z(){return(z=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"node_id")&&a.append("node_id",t.node_id||""),r.has(t,"show_hreflang")&&a.append("show_hreflang",t.show_hreflang||""),r.has(t,"show_ldjson")&&a.append("show_ldjson",t.show_ldjson||""),r.has(t,"get_prevnext")&&a.append("get_prevnext",t.get_prevnext||""),e.next=10,d("".concat(h,"&m=node&").concat(a.toString()),{verbose:c,duration:s,type:"json",directory:".cache/node/".concat(t.channel_id?t.channel_id+"/":"")});case 10:if(o=e.sent,0!==Number(o.code)){e.next=14;break}return e.abrupt("return",o.data);case 14:return e.abrupt("return",null);case 15:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function D(){return(D=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"node_id")&&a.append("node_id",t.node_id||""),r.has(t,"direction")&&a.append("direction",t.direction||""),r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"no_fields")&&a.append("no_fields",t.no_fields||""),e.next=9,d("".concat(h,"&m=node&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 9:if(o=e.sent,0!==Number(o.code)){e.next=13;break}return e.abrupt("return",o.data);case 13:return e.abrupt("return",null);case 14:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function H(){return(H=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),e.next=5,d("".concat(h,"&m=channeluriarr&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function W(){return(W=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"category_id")&&a.append("category_id",t.category_id||""),e.next=5,d("".concat(h,"&m=categoryuriarr&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function B(){return(B=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"node_id")&&a.append("node_id",t.node_id||""),e.next=5,d("".concat(h,"&m=nodeuriarr&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 5:if(o=e.sent,0!==Number(o.code)){e.next=9;break}return e.abrupt("return",o.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function F(){return(F=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),r.has(t,"is_home")&&a.append("is_home",t.is_home||""),r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),e.next=8,d("".concat(h,"&m=friendlinks&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 8:if(o=e.sent,0!==Number(o.code)){e.next=12;break}return e.abrupt("return",[o.data,o.channeluriarr,o.categoryuriarr]);case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function K(){return(K=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),r.has(t,"render_type")&&a.append("render_type",t.render_type||""),e.next=6,d("".concat(h,"&m=choose_language&").concat(a.toString()),{verbose:c,duration:s,type:"json"});case 6:if(o=e.sent,0!==Number(o.code)){e.next=10;break}return e.abrupt("return",o.data);case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function M(){return(M=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"image_url")&&a.append("image_url",t.image_url||""),r.has(t,"alt")&&a.append("alt",t.alt||""),r.has(t,"layout")&&a.append("layout",t.layout||""),r.has(t,"attributes_json")&&a.append("attributes_json",JSON.stringify(t.attributes_json||"")),r.has(t,"show_link")&&a.append("show_link",t.show_link||""),e.next=9,d("".concat(h,"&m=theme_render_image"),{verbose:c,duration:s,type:"json",fetchOptions:{method:"POST",body:a}});case 9:if(o=e.sent,0!==Number(o.code)){e.next=13;break}return e.abrupt("return",o.data);case 13:return e.abrupt("return",null);case 14:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function C(){return(C=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"image_url")&&a.append("image_url",t.image_url||""),r.has(t,"params_json")&&a.append("params_json",JSON.stringify(t.params_json||"")),e.next=6,d("".concat(h,"&m=theme_image_url"),{verbose:c,duration:s,type:"json",fetchOptions:{method:"POST",body:a}});case 6:if(o=e.sent,0!==Number(o.code)){e.next=10;break}return e.abrupt("return",o.data);case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),n)})))).apply(this,arguments)}function Q(){return(Q=e.asyncToGenerator(e.regeneratorRuntime().mark((function r(){var n;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,d("".concat(h,"&m=sitemap"),{verbose:c,duration:s,type:"json"});case 3:if(n=e.sent,0!==Number(n.code)){e.next=7;break}return e.abrupt("return",n.data);case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),r)})))).apply(this,arguments)}function V(){return(V=e.asyncToGenerator(e.regeneratorRuntime().mark((function n(t){var a,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"page_type")&&a.append("page_type",t.page_type||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"node_id")&&a.append("node_id",t.node_id||""),r.has(t,"field_array")&&a.append("field_array",JSON.stringify(t.field_array||"")),r.has(t,"style_config")&&a.append("style_config",JSON.stringify(t.style_config||"")),e.next=10,d("".concat(h,"&m=render_filter_links_simple"),{verbose:c,duration:s,type:"json",fetchOptions:{method:"POST",body:a}});case 10:if(o=e.sent,0!==Number(o.code)){e.next=14;break}return e.abrupt("return",o.data);case 14:return e.abrupt("return",o);case 15:case"end":return e.stop()}}),n)})))).apply(this,arguments)}exports.consolelog=function(){},exports.delete_cache=function(){return _.apply(this,arguments)},exports.get_all_categories=function(e){return O.apply(this,arguments)},exports.get_all_langs=function(){return R.apply(this,arguments)},exports.get_all_uri=function(){return S.apply(this,arguments)},exports.get_author_info=function(e){return b.apply(this,arguments)},exports.get_block=function(e){return L.apply(this,arguments)},exports.get_blocks=function(){return G.apply(this,arguments)},exports.get_categories=function(e){return J.apply(this,arguments)},exports.get_category=function(e){return q.apply(this,arguments)},exports.get_category_tree=function(e){return I.apply(this,arguments)},exports.get_category_url=function(e){return W.apply(this,arguments)},exports.get_channel=function(e){return U.apply(this,arguments)},exports.get_channel_url=function(e){return H.apply(this,arguments)},exports.get_choose_language=function(e){return K.apply(this,arguments)},exports.get_comment_form=function(e){return g.apply(this,arguments)},exports.get_country=function(){return x.apply(this,arguments)},exports.get_filter_links=function(e){return V.apply(this,arguments)},exports.get_form=function(e){return w.apply(this,arguments)},exports.get_friendlinks=function(e){return F.apply(this,arguments)},exports.get_glossary=function(){return v.apply(this,arguments)},exports.get_index=function(){return f.apply(this,arguments)},exports.get_lang=function(e){return k.apply(this,arguments)},exports.get_menu_tree=function(e){return P.apply(this,arguments)},exports.get_menus=function(e){return T.apply(this,arguments)},exports.get_node=function(e){return z.apply(this,arguments)},exports.get_node_url=function(e){return B.apply(this,arguments)},exports.get_nodes=function(e){return A.apply(this,arguments)},exports.get_prevnext_node=function(e){return D.apply(this,arguments)},exports.get_rel_nodes=function(e){return E.apply(this,arguments)},exports.get_share_button=function(e){return m.apply(this,arguments)},exports.get_site_option=function(e){return N.apply(this,arguments)},exports.get_site_options=function(){return j.apply(this,arguments)},exports.get_sitemap=function(){return Q.apply(this,arguments)},exports.get_stats=function(e){return y.apply(this,arguments)},exports.get_theme_image_url=function(e){return C.apply(this,arguments)},exports.get_theme_render_image=function(e){return M.apply(this,arguments)};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./cms.js"),t=require("./util.js");exports.consolelog=e.consolelog,exports.delete_cache=e.delete_cache,exports.get_all_categories=e.get_all_categories,exports.get_all_langs=e.get_all_langs,exports.get_all_uri=e.get_all_uri,exports.get_author_info=e.get_author_info,exports.get_block=e.get_block,exports.get_blocks=e.get_blocks,exports.get_categories=e.get_categories,exports.get_category=e.get_category,exports.get_category_tree=e.get_category_tree,exports.get_category_url=e.get_category_url,exports.get_channel=e.get_channel,exports.get_channel_url=e.get_channel_url,exports.get_choose_language=e.get_choose_language,exports.get_comment_form=e.get_comment_form,exports.get_country=e.get_country,exports.get_filter_links=e.get_filter_links,exports.get_form=e.get_form,exports.get_friendlinks=e.get_friendlinks,exports.get_glossary=e.get_glossary,exports.get_index=e.get_index,exports.get_lang=e.get_lang,exports.get_menu_tree=e.get_menu_tree,exports.get_menus=e.get_menus,exports.get_node=e.get_node,exports.get_node_url=e.get_node_url,exports.get_nodes=e.get_nodes,exports.get_prevnext_node=e.get_prevnext_node,exports.get_rel_nodes=e.get_rel_nodes,exports.get_share_button=e.get_share_button,exports.get_site_option=e.get_site_option,exports.get_site_options=e.get_site_options,exports.get_sitemap=e.get_sitemap,exports.get_stats=e.get_stats,exports.get_theme_image_url=e.get_theme_image_url,exports.get_theme_render_image=e.get_theme_render_image,exports.get_children_categories=t.get_children_categories,exports.get_url=t.get_url,exports.img_add_link=t.img_add_link,exports.img_change_attrs=t.img_change_attrs,exports.is_default_image=t.is_default_image,exports.render_date=t.render_date,exports.render_url=t.render_url,exports.render_value=t.render_value,exports.default={};
|
package/dist/util.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./_virtual/_rollupPluginBabelHelpers.js"),r=require("lodash"),t=require("dayjs"),n=require("cheerio"),a=require("./cms.js");function u(e){var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var i=u(n);function c(){return(c=e.asyncToGenerator(e.regeneratorRuntime().mark((function t(n,u){var i,c,o;return e.regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.get_all_uri();case 2:i=e.sent,c="",o=null,e.t0=n,e.next="channel"===e.t0?8:"category"===e.t0?11:"node"===e.t0?14:17;break;case 8:return o=r.find(i,(function(e){return"channel"==e.page_type&&e.channel_id==u})),c=o.url,e.abrupt("break",18);case 11:return o=r.find(i,(function(e){return"category"==e.page_type&&e.category_id==u})),c=o.url,e.abrupt("break",18);case 14:return o=r.find(i,(function(e){return"node"==e.page_type&&e.node_id==u})),c=o.url,e.abrupt("break",18);case 17:return e.abrupt("break",18);case 18:return e.abrupt("return",c);case 19:case"end":return e.stop()}}),t)})))).apply(this,arguments)}exports.get_children_categories=function(e,t,n){return r.filter(e,(function(e){return Number(e.channel_id)===Number(t)&&Number(e.parent_id)===Number(n)}))},exports.get_url=function(e,r){return c.apply(this,arguments)},exports.img_add_link=function(e){if(!e)return e;var r=i.load(e),t=r("img"),n=t.attr("width"),a=t.attr("height"),u=t.attr("title"),c=t.attr("src");return t.wrap('<a href="'.concat(c,'" title="').concat(u,'" target="_blank" data-pswp-width="').concat(n,'" data-pswp-height="').concat(a,'"></a>')),r.html("a")},exports.img_change_attrs=function(e,r,t){if(!e)return e;var n=i.load(e),a=n("img");for(var u in r)a.attr(u,r[u]);for(var c in t)a.removeAttr(c);return n.html("img")},exports.is_default_image=function(e){return!(!e||-1===e.indexOf("placeholder-lg")&&-1===e.indexOf("resource/images/default.png")&&-1===e.indexOf("resource/images/default.jpg"))},exports.render_date=function(e){return t.unix(e).format("MMM DD, YYYY")},exports.render_url=function(e){return e?-1!==e.indexOf("http://")||-1!==e.indexOf("https://")?e:"/"==e?"/":"/".concat(r.trimStart(e.replaceAll(".html",""),"/"),".html"):"/"},exports.render_value=function(e,n){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",u=r.get(e,n,a);return r.isString(u)?r.replace(u,"{{YEAR}}",t().format("YYYY")):u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function r(r){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=r.apply(e,n);function c(r){t(a,o,i,c,u,"next",r)}function u(r){t(a,o,i,c,u,"throw",r)}c(void 0)}))}}function e(){e=function(){return r};var t,r={},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",h=a.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function l(t,r,e,n){var o=r&&r.prototype instanceof m?r:m,a=Object.create(o.prototype),c=new T(n||[]);return i(a,"_invoke",{value:G(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}}}r.wrap=l;var p="suspendedStart",y="suspendedYield",v="executing",d="completed",g={};function m(){}function w(){}function L(){}var b={};f(b,c,(function(){return this}));var x=Object.getPrototypeOf,E=x&&x(x(S([])));E&&E!==n&&o.call(E,c)&&(b=E);var _=L.prototype=m.prototype=Object.create(b);function O(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function j(t,r){function e(n,i,a,c){var u=s(t[n],t,i);if("throw"!==u.type){var h=u.arg,f=h.value;return f&&"object"==typeof f&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(f).then((function(t){h.value=t,a(h)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new r((function(r,n){e(t,o,r,n)}))}return n=n?n.then(i,i):i()}})}function G(r,e,n){var o=p;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var h=s(r,e,n);if("normal"===h.type){if(o=n.done?d:y,h.arg===g)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(o=d,n.method="throw",n.arg=h.arg)}}}function P(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,P(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=s(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function k(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 N(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(r){if(r||""===r){var e=r[c];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var n=-1,i=function e(){for(;++n<r.length;)if(o.call(r,n))return e.value=r[n],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return w.prototype=L,i(_,"constructor",{value:L,configurable:!0}),i(L,"constructor",{value:w,configurable:!0}),w.displayName=f(L,h,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,L):(t.__proto__=L,f(t,h,"GeneratorFunction")),t.prototype=Object.create(_),t},r.awrap=function(t){return{__await:t}},O(j.prototype),f(j.prototype,u,(function(){return this})),r.AsyncIterator=j,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new j(l(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},O(_),f(_,h,"Generator"),f(_,c,(function(){return this})),f(_,"toString",(function(){return"[object Generator]"})),r.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}},r.values=S,T.prototype={constructor:T,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!r)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function n(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),h=o.call(a,"finallyLoc");if(u&&h){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!h)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.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,g):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),g},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),N(e),g}},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;N(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:S(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),g}},r}export{r as asyncToGenerator,e as regeneratorRuntime};
|
package/es/cms.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{asyncToGenerator as e,regeneratorRuntime as n}from"./_virtual/_rollupPluginBabelHelpers.js";import r from"lodash";import"dayjs";import t from"node:crypto";import a from"keyv";import c from"@keyv/compress-brotli";import{KeyvLru as s}from"keyv-lru";import{render_value as u}from"./util.js";var o="1d",i=!0;function p(){}import.meta.env.PROD&&(o="1d",i=!1);var d=new a({store:new s({max:5e3,notify:!1,ttl:0,expire:0}),namespace:"site_".concat(import.meta.env.JEAWIN_SITE_ID),compression:new c});function h(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"0s",r=n.substring(n.length,1);return"s"===r?e=1:"m"===r?e=60:"h"===r?e=3600:"d"===r?e=86400:"w"===r?e=604800:"y"===r&&(e=31536e3),parseInt(n.substring(0,n.length-1),10)*e*1e3}function l(e,n){return f.apply(this,arguments)}function f(){return(f=e(n().mark((function e(a,c){var s,u,o,i,p,l,f,_,m,b,y;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s="json",u="0s",r.has(c,"type")&&(s=c.type),r.has(c,"verbose")&&c.verbose,r.has(c,"duration")&&(u=c.duration),o=h(u),i={},r.has(c,"fetchOptions")&&(i=c.fetchOptions),p="",p=r.has(i,"method")&&"POST"===r.toUpper(i.method)?t.createHash("md5").update(a+i.body.toString()).digest("hex"):t.createHash("md5").update(a).digest("hex"),!(o>0)){e.next=21;break}return e.next=14,d.has(p);case 14:if(!e.sent){e.next=21;break}return e.next=18,d.get(p);case 18:return l=e.sent,f=JSON.parse(l),e.abrupt("return",Promise.resolve(f));case 21:return e.prev=21,e.next=25,fetch(a,i);case 25:if((_=e.sent).ok){e.next=29;break}return m=new Error("Fetch error! status: ".concat(_.status)),e.abrupt("return",Promise.reject(m));case 29:b=null,y="",e.t0=s,e.next="text"===e.t0?34:39;break;case 34:return e.next=36,_.text();case 36:return b=e.sent,y=b,e.abrupt("break",44);case 39:return e.next=41,_.json();case 41:return b=e.sent,y=JSON.stringify(b),e.abrupt("break",44);case 44:return o>0&&d.set(p,y,o),e.abrupt("return",Promise.resolve(b));case 48:return e.prev=48,e.t1=e.catch(21),e.abrupt("return",Promise.reject(e.t1));case 52:case"end":return e.stop()}}),e,null,[[21,48]])})))).apply(this,arguments)}var _="".concat(import.meta.env.JEAWIN_API_DOMAIN).concat(import.meta.env.JEAWIN_API_PATH,"&site_id=").concat(import.meta.env.JEAWIN_SITE_ID);function m(){return b.apply(this,arguments)}function b(){return(b=e(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d.clear();case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(){return v.apply(this,arguments)}function v(){return(v=e(n().mark((function e(){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,l("".concat(_,"&m=index"));case 3:if(r=e.sent,0!==Number(r.code)){e.next=7;break}return e.abrupt("return",r.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(e){return g.apply(this,arguments)}function g(){return(g=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),r.has(t,"seo_title")&&a.append("seo_title",t.seo_title||""),r.has(t,"seo_description")&&a.append("seo_description",t.seo_description||""),e.next=7,l("".concat(_,"&m=share_button&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 7:if(c=e.sent,0!==Number(c.code)){e.next=11;break}return e.abrupt("return",c.data);case 11:return e.abrupt("return",null);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function x(e){return k.apply(this,arguments)}function k(){return(k=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"node_id")&&a.append("node_id",t.node_id),e.next=8,l("".concat(_,"&m=comment_form&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 8:if(c=e.sent,0!==Number(c.code)){e.next=12;break}return e.abrupt("return",c.data);case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function S(e){return j.apply(this,arguments)}function j(){return(j=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),e.next=5,l("".concat(_,"&m=stats&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function N(e){return P.apply(this,arguments)}function P(){return(P=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"node_id")&&a.append("node_id",t.node_id||""),e.next=5,l("".concat(_,"&m=author_info&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function R(){return U.apply(this,arguments)}function U(){return(U=e(n().mark((function e(){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,l("".concat(_,"&m=country"),{verbose:i,duration:o,type:"json"});case 3:if(r=e.sent,0!==Number(r.code)){e.next=7;break}return e.abrupt("return",r.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function L(){return O.apply(this,arguments)}function O(){return(O=e(n().mark((function e(){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,l("".concat(_,"&m=glossary"),{verbose:i,duration:o,type:"json"});case 3:if(r=e.sent,0!==Number(r.code)){e.next=7;break}return e.abrupt("return",r.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function J(e){return I.apply(this,arguments)}function I(){return(I=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"form_id")&&a.append("form_id",t.form_id||""),e.next=5,l("".concat(_,"&m=form&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function A(){return T.apply(this,arguments)}function T(){return(T=e(n().mark((function e(){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,l("".concat(_,"&m=all_langs"),{verbose:i,duration:o,type:"json"});case 3:if(r=e.sent,0!==Number(r.code)){e.next=7;break}return e.abrupt("return",r.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function E(e){return z.apply(this,arguments)}function z(){return(z=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"key")&&a.append("key",t.key||""),e.next=5,l("".concat(_,"&m=get_lang&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function D(){return H.apply(this,arguments)}function H(){return(H=e(n().mark((function e(){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,l("".concat(_,"&m=all_uri"),{verbose:i,duration:o,type:"json"});case 3:if(r=e.sent,0!==Number(r.code)){e.next=7;break}return e.abrupt("return",r.data);case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function W(){return B.apply(this,arguments)}function B(){return(B=e(n().mark((function e(){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,l("".concat(_,"&m=site_options"),{verbose:i,duration:o,type:"json"});case 3:if(r=e.sent,0!==Number(r.code)){e.next=7;break}return e.abrupt("return",{data:r.data,siteinfo:r.siteinfo});case 7:return e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function F(e){return G.apply(this,arguments)}function G(){return(G=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"option_name")&&a.append("option_name",t.option_name||""),e.next=5,l("".concat(_,"&m=site_option&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function M(e){return q.apply(this,arguments)}function q(){return(q=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"menu_id")&&a.append("menu_id",t.menu_id||""),r.has(t,"parent_id")&&a.append("parent_id",t.parent_id||""),e.next=6,l("".concat(_,"&m=menus&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 6:if(c=e.sent,0!==Number(c.code)){e.next=10;break}return e.abrupt("return",c.data);case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(e){return K.apply(this,arguments)}function K(){return(K=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"menu_id")&&a.append("menu_id",t.menu_id||""),e.next=5,l("".concat(_,"&m=menu_tree&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Q(){return V.apply(this,arguments)}function V(){return(V=e(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function X(e){return Y.apply(this,arguments)}function Y(){return(Y=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"block_id")&&a.append("block_id",t.block_id||""),e.next=5,l("".concat(_,"&m=block&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Z(e){return $.apply(this,arguments)}function $(){return($=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"show_hreflang")&&a.append("show_hreflang",t.show_hreflang||""),r.has(t,"show_ldjson")&&a.append("show_ldjson",t.show_ldjson||""),r.has(t,"field_array")&&a.append("field_array",JSON.stringify(t.field_array||"")),e.next=8,l("".concat(_,"&m=channel&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 8:if(c=e.sent,0!==Number(c.code)){e.next=12;break}return e.abrupt("return",c.data);case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ee(e){return ne.apply(this,arguments)}function ne(){return(ne=e(n().mark((function e(r){var t,a;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new URLSearchParams,e.next=4,l("".concat(_,"&m=all_categories&").concat(t.toString()),{verbose:i,duration:o,type:"json"});case 4:if(a=e.sent,0!==Number(a.code)){e.next=8;break}return e.abrupt("return",a.data);case 8:return e.abrupt("return",null);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function re(e){return te.apply(this,arguments)}function te(){return(te=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"parent_id")&&a.append("parent_id",t.parent_id||""),e.next=6,l("".concat(_,"&m=categories&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 6:if(c=e.sent,0!==Number(c.code)){e.next=10;break}return e.abrupt("return",c.data);case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ae(e){return ce.apply(this,arguments)}function ce(){return(ce=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),e.next=5,l("".concat(_,"&m=category_tree&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function se(e){return ue.apply(this,arguments)}function ue(){return(ue=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"show_hreflang")&&a.append("show_hreflang",t.show_hreflang||""),r.has(t,"show_ldjson")&&a.append("show_ldjson",t.show_ldjson||""),r.has(t,"field_array")&&a.append("field_array",JSON.stringify(t.field_array||"")),e.next=8,l("".concat(_,"&m=category&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 8:if(c=e.sent,0!==Number(c.code)){e.next=12;break}return e.abrupt("return",c.data);case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oe(e){return ie.apply(this,arguments)}function ie(){return(ie=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,u(t,"channel_id")&&a.append("channel_id",t.channel_id||""),u(t,"category_id")&&a.append("category_id",t.category_id||""),u(t,"limit_type")&&a.append("limit_type",t.limit_type||""),u(t,"sort")&&a.append("sort",t.sort||""),u(t,"sortorder")&&a.append("sortorder",t.sortorder||""),u(t,"per_page")&&a.append("page_size",t.per_page||""),u(t,"page")&&a.append("page",t.page||1),u(t,"include_children_category_nodes")&&a.append("include_children_category_nodes",t.include_children_category_nodes||""),r.has(t,"no_fields")&&a.append("no_fields",t.no_fields||""),r.has(t,"no_images_html")&&a.append("no_images_html",t.no_images_html||""),r.has(t,"field_array")&&a.append("field_array",JSON.stringify(t.field_array||"")),e.next=15,l("".concat(_,"&m=nodes&").concat(a.toString()),{verbose:i,duration:o,type:"json",directory:".cache/nodes/".concat(t.channel_id?t.channel_id+"/":"")});case 15:if(c=e.sent,0!==Number(c.code)){e.next=19;break}return e.abrupt("return",c.data);case 19:return e.abrupt("return",null);case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function pe(e){return de.apply(this,arguments)}function de(){return(de=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"field_id")&&a.append("field_id",t.field_id||""),r.has(t,"rel_id")&&a.append("rel_id",t.rel_id||""),r.has(t,"page")&&a.append("page",t.page||""),r.has(t,"page_size")&&a.append("page_size",t.page_size||""),r.has(t,"no_fields")&&a.append("no_fields",t.no_fields||""),r.has(t,"no_images_html")&&a.append("no_images_html",t.no_images_html||""),e.next=10,l("".concat(_,"&m=rel_nodes&").concat(a.toString()),{verbose:i,duration:"0s",type:"json"});case 10:if(c=e.sent,0!==Number(c.code)){e.next=14;break}return e.abrupt("return",c.data);case 14:return e.abrupt("return",null);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e){return le.apply(this,arguments)}function le(){return(le=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"node_id")&&a.append("node_id",t.node_id||""),r.has(t,"show_hreflang")&&a.append("show_hreflang",t.show_hreflang||""),r.has(t,"show_ldjson")&&a.append("show_ldjson",t.show_ldjson||""),r.has(t,"get_prevnext")&&a.append("get_prevnext",t.get_prevnext||""),e.next=10,l("".concat(_,"&m=node&").concat(a.toString()),{verbose:i,duration:o,type:"json",directory:".cache/node/".concat(t.channel_id?t.channel_id+"/":"")});case 10:if(c=e.sent,0!==Number(c.code)){e.next=14;break}return e.abrupt("return",c.data);case 14:return e.abrupt("return",null);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fe(e){return _e.apply(this,arguments)}function _e(){return(_e=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"node_id")&&a.append("node_id",t.node_id||""),r.has(t,"direction")&&a.append("direction",t.direction||""),r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"no_fields")&&a.append("no_fields",t.no_fields||""),e.next=9,l("".concat(_,"&m=node&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 9:if(c=e.sent,0!==Number(c.code)){e.next=13;break}return e.abrupt("return",c.data);case 13:return e.abrupt("return",null);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function me(e){return be.apply(this,arguments)}function be(){return(be=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),e.next=5,l("".concat(_,"&m=channeluriarr&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(e){return ve.apply(this,arguments)}function ve(){return(ve=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"category_id")&&a.append("category_id",t.category_id||""),e.next=5,l("".concat(_,"&m=categoryuriarr&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function we(e){return ge.apply(this,arguments)}function ge(){return(ge=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"node_id")&&a.append("node_id",t.node_id||""),e.next=5,l("".concat(_,"&m=nodeuriarr&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 5:if(c=e.sent,0!==Number(c.code)){e.next=9;break}return e.abrupt("return",c.data);case 9:return e.abrupt("return",null);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(e){return ke.apply(this,arguments)}function ke(){return(ke=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),r.has(t,"is_home")&&a.append("is_home",t.is_home||""),r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),e.next=8,l("".concat(_,"&m=friendlinks&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 8:if(c=e.sent,0!==Number(c.code)){e.next=12;break}return e.abrupt("return",[c.data,c.channeluriarr,c.categoryuriarr]);case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Se(e){return je.apply(this,arguments)}function je(){return(je=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"canonical")&&a.append("canonical",t.canonical||""),r.has(t,"render_type")&&a.append("render_type",t.render_type||""),e.next=6,l("".concat(_,"&m=choose_language&").concat(a.toString()),{verbose:i,duration:o,type:"json"});case 6:if(c=e.sent,0!==Number(c.code)){e.next=10;break}return e.abrupt("return",c.data);case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ne(e){return Pe.apply(this,arguments)}function Pe(){return(Pe=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"image_url")&&a.append("image_url",t.image_url||""),r.has(t,"alt")&&a.append("alt",t.alt||""),r.has(t,"layout")&&a.append("layout",t.layout||""),r.has(t,"attributes_json")&&a.append("attributes_json",JSON.stringify(t.attributes_json||"")),r.has(t,"show_link")&&a.append("show_link",t.show_link||""),e.next=9,l("".concat(_,"&m=theme_render_image"),{verbose:i,duration:o,type:"json",fetchOptions:{method:"POST",body:a}});case 9:if(c=e.sent,0!==Number(c.code)){e.next=13;break}return e.abrupt("return",c.data);case 13:return e.abrupt("return",null);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Re(e){return Ue.apply(this,arguments)}function Ue(){return(Ue=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"image_url")&&a.append("image_url",t.image_url||""),r.has(t,"params_json")&&a.append("params_json",JSON.stringify(t.params_json||"")),e.next=6,l("".concat(_,"&m=theme_image_url"),{verbose:i,duration:o,type:"json",fetchOptions:{method:"POST",body:a}});case 6:if(c=e.sent,0!==Number(c.code)){e.next=10;break}return e.abrupt("return",c.data);case 10:return e.abrupt("return",null);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Le(){return Oe.apply(this,arguments)}function Oe(){return(Oe=e(n().mark((function e(){var r;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,l("".concat(_,"&m=sitemap"),{verbose:i,duration:o,type:"json"});case 3:if(r=e.sent,0!==Number(r.code)){e.next=7;break}return e.abrupt("return",r.data);case 7:return e.abrupt("return",r);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Je(e){return Ie.apply(this,arguments)}function Ie(){return(Ie=e(n().mark((function e(t){var a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new URLSearchParams,r.has(t,"channel_id")&&a.append("channel_id",t.channel_id||""),r.has(t,"page_type")&&a.append("page_type",t.page_type||""),r.has(t,"category_id")&&a.append("category_id",t.category_id||""),r.has(t,"node_id")&&a.append("node_id",t.node_id||""),r.has(t,"field_array")&&a.append("field_array",JSON.stringify(t.field_array||"")),r.has(t,"style_config")&&a.append("style_config",JSON.stringify(t.style_config||"")),e.next=10,l("".concat(_,"&m=render_filter_links_simple"),{verbose:i,duration:o,type:"json",fetchOptions:{method:"POST",body:a}});case 10:if(c=e.sent,0!==Number(c.code)){e.next=14;break}return e.abrupt("return",c.data);case 14:return e.abrupt("return",c);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}export{p as consolelog,m as delete_cache,ee as get_all_categories,A as get_all_langs,D as get_all_uri,N as get_author_info,X as get_block,Q as get_blocks,re as get_categories,se as get_category,ae as get_category_tree,ye as get_category_url,Z as get_channel,me as get_channel_url,Se as get_choose_language,x as get_comment_form,R as get_country,Je as get_filter_links,J as get_form,xe as get_friendlinks,L as get_glossary,y as get_index,E as get_lang,C as get_menu_tree,M as get_menus,he as get_node,we as get_node_url,oe as get_nodes,fe as get_prevnext_node,pe as get_rel_nodes,w as get_share_button,F as get_site_option,W as get_site_options,Le as get_sitemap,S as get_stats,Re as get_theme_image_url,Ne as get_theme_render_image};
|
package/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{consolelog,delete_cache,get_all_categories,get_all_langs,get_all_uri,get_author_info,get_block,get_blocks,get_categories,get_category,get_category_tree,get_category_url,get_channel,get_channel_url,get_choose_language,get_comment_form,get_country,get_filter_links,get_form,get_friendlinks,get_glossary,get_index,get_lang,get_menu_tree,get_menus,get_node,get_node_url,get_nodes,get_prevnext_node,get_rel_nodes,get_share_button,get_site_option,get_site_options,get_sitemap,get_stats,get_theme_image_url,get_theme_render_image}from"./cms.js";export{get_children_categories,get_url,img_add_link,img_change_attrs,is_default_image,render_date,render_url,render_value}from"./util.js";var e={};export{e as default};
|
package/es/util.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{asyncToGenerator as r,regeneratorRuntime as t}from"./_virtual/_rollupPluginBabelHelpers.js";import e from"lodash";import n from"dayjs";import*as a from"cheerio";import{get_all_uri as i}from"./cms.js";function u(r){return!(!r||-1===r.indexOf("placeholder-lg")&&-1===r.indexOf("resource/images/default.png")&&-1===r.indexOf("resource/images/default.jpg"))}function o(r){return n.unix(r).format("MMM DD, YYYY")}function c(r,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=e.get(r,t,a);return e.isString(i)?e.replace(i,"{{YEAR}}",n().format("YYYY")):i}function f(r){return r?-1!==r.indexOf("http://")||-1!==r.indexOf("https://")?r:"/"==r?"/":"/".concat(e.trimStart(r.replaceAll(".html",""),"/"),".html"):"/"}function p(r,t){return l.apply(this,arguments)}function l(){return(l=r(t().mark((function r(n,a){var u,o,c;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,i();case 2:u=r.sent,o="",c=null,r.t0=n,r.next="channel"===r.t0?8:"category"===r.t0?11:"node"===r.t0?14:17;break;case 8:return c=e.find(u,(function(r){return"channel"==r.page_type&&r.channel_id==a})),o=c.url,r.abrupt("break",18);case 11:return c=e.find(u,(function(r){return"category"==r.page_type&&r.category_id==a})),o=c.url,r.abrupt("break",18);case 14:return c=e.find(u,(function(r){return"node"==r.page_type&&r.node_id==a})),o=c.url,r.abrupt("break",18);case 17:return r.abrupt("break",18);case 18:return r.abrupt("return",o);case 19:case"end":return r.stop()}}),r)})))).apply(this,arguments)}function s(r){if(!r)return r;var t=a.load(r),e=t("img"),n=e.attr("width"),i=e.attr("height"),u=e.attr("title"),o=e.attr("src");return e.wrap('<a href="'.concat(o,'" title="').concat(u,'" target="_blank" data-pswp-width="').concat(n,'" data-pswp-height="').concat(i,'"></a>')),t.html("a")}function m(r,t,e){if(!r)return r;var n=a.load(r),i=n("img");for(var u in t)i.attr(u,t[u]);for(var o in e)i.removeAttr(o);return n.html("img")}function d(r,t,n){return e.filter(r,(function(r){return Number(r.channel_id)===Number(t)&&Number(r.parent_id)===Number(n)}))}export{d as get_children_categories,p as get_url,s as img_add_link,m as img_change_attrs,u as is_default_image,o as render_date,f as render_url,c as render_value};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { get_index } from '../dist/index';
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jeawin-astro",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"author": "chaegumi <chaegumi@qq.com>",
|
|
5
|
+
"description": "",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://www.jeawin.com/",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node example",
|
|
11
|
+
"build": "rollup -c"
|
|
12
|
+
},
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"module": "es/index.js",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@babel/core": "^7.25.2",
|
|
17
|
+
"@babel/preset-env": "^7.25.4",
|
|
18
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
19
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
20
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
21
|
+
"@rollup/plugin-multi-entry": "^6.0.1",
|
|
22
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
23
|
+
"@rollup/plugin-strip": "^3.0.4",
|
|
24
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
25
|
+
"@rollup/plugin-typescript": "^12.1.0",
|
|
26
|
+
"autoprefixer": "^10.4.20",
|
|
27
|
+
"postcss": "^8.4.47",
|
|
28
|
+
"rollup": "^4.22.4",
|
|
29
|
+
"rollup-plugin-node-externals": "^7.1.3",
|
|
30
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
31
|
+
"typescript": "^5.6.2"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@keyv/compress-brotli": "^2.0.2",
|
|
35
|
+
"cheerio": "^1.0.0",
|
|
36
|
+
"dayjs": "^1.11.13",
|
|
37
|
+
"glob": "^11.0.0",
|
|
38
|
+
"keyv": "^5.0.3",
|
|
39
|
+
"keyv-lru": "^3.0.4",
|
|
40
|
+
"lodash": "^4.17.21",
|
|
41
|
+
"tslib": "^2.7.0"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import strip from '@rollup/plugin-strip';
|
|
4
|
+
import typescript from '@rollup/plugin-typescript';
|
|
5
|
+
import autoprefixer from 'autoprefixer';
|
|
6
|
+
import externals from 'rollup-plugin-node-externals';
|
|
7
|
+
import postcss from 'rollup-plugin-postcss';
|
|
8
|
+
import babel from '@rollup/plugin-babel';
|
|
9
|
+
import json from '@rollup/plugin-json';
|
|
10
|
+
import terser from '@rollup/plugin-terser';
|
|
11
|
+
import { globSync } from 'glob';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { fileURLToPath } from 'node:url';
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
input: Object.fromEntries(
|
|
17
|
+
globSync('src/**/*.{ts,js}').map(file => [
|
|
18
|
+
path.relative(
|
|
19
|
+
'src',
|
|
20
|
+
file.slice(0, file.length - path.extname(file).length)
|
|
21
|
+
),
|
|
22
|
+
fileURLToPath(new URL(file, import.meta.url))
|
|
23
|
+
])
|
|
24
|
+
),
|
|
25
|
+
output: [{
|
|
26
|
+
dir: 'es',
|
|
27
|
+
format: "es",
|
|
28
|
+
exports: 'named',
|
|
29
|
+
preserveModules: true,
|
|
30
|
+
preserveModulesRoot: 'es'
|
|
31
|
+
}, {
|
|
32
|
+
dir: 'dist',
|
|
33
|
+
format: 'cjs',
|
|
34
|
+
exports: 'named',
|
|
35
|
+
preserveModules: true,
|
|
36
|
+
preserveModulesRoot: 'dist'
|
|
37
|
+
}],
|
|
38
|
+
plugins: [
|
|
39
|
+
externals({
|
|
40
|
+
devDeps: false
|
|
41
|
+
}),
|
|
42
|
+
json(),
|
|
43
|
+
resolve(),
|
|
44
|
+
commonjs(),
|
|
45
|
+
typescript(),
|
|
46
|
+
postcss({
|
|
47
|
+
plugins: [autoprefixer()]
|
|
48
|
+
}),
|
|
49
|
+
babel({
|
|
50
|
+
exclude: 'node_modules/**',
|
|
51
|
+
babelHelpers: 'bundled',
|
|
52
|
+
}),
|
|
53
|
+
strip(),
|
|
54
|
+
terser()
|
|
55
|
+
]
|
|
56
|
+
}
|