@nocobase/plugin-license 2.1.0-beta.15 → 2.1.0-beta.16

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.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("ahooks"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-license",["react","ahooks","@formily/react","@nocobase/client","@ant-design/icons","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-license"]=t(require("react"),require("ahooks"),require("@formily/react"),require("@nocobase/client"),require("@ant-design/icons"),require("antd")):e["@nocobase/plugin-license"]=t(e.react,e.ahooks,e["@formily/react"],e["@nocobase/client"],e["@ant-design/icons"],e.antd)}(self,function(e,t,n,r,o,i){return function(){"use strict";var a={482:function(e){e.exports=o},505:function(e){e.exports=n},772:function(e){e.exports=r},749:function(e){e.exports=t},721:function(e){e.exports=i},156:function(t){t.exports=e}},u={};function l(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return a[e](n,n.exports,l),n.exports}l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return!function(){l.r(c),l.d(c,{PluginLicenseClient:function(){return N},default:function(){return _}});var e=l(772),t=l(156),n=l.n(t),r=l(721),o=l(749),i=JSON.parse('{"u2":"@nocobase/plugin-license"}');function a(){var t=(0,e.useApp)();return function(e,n){return String(t.i18n.t(e,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:[i.u2,"client"]},n||{})))}}var u=l(482);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var f=function(o){var i,u=o.refreshToken,l=(0,e.useAPIClient)(),c=(i=(0,t.useState)(null),function(e){if(Array.isArray(e))return e}(i)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(i,2)||function(e,t){if(e){if("string"==typeof e)return s(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}}(i,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=c[0],p=c[1],y=a();return((0,t.useEffect)(function(){p(null),l.request({url:"/license:license-validate",method:"get"}).then(function(e){var t;p(null==e||null==(t=e.data)?void 0:t.data)}).catch(function(e){console.log(e)})},[u]),(null==f?void 0:f.licenseStatus)&&(null==f?void 0:f.licenseStatus)==="active")?(null==f?void 0:f.isServiceConnection)===!1&&(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary."),n().createElement("br",null),y("Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isServiceConnection)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):null:null},p=l(505),y=n().createContext(null);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){h(i,r,o,a,u,"next",e)}function u(e){h(i,r,o,a,u,"throw",e)}a(void 0)})}}function b(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var v=function(){var o,i,u=(0,e.useAPIClient)(),l=(o=(0,t.useState)(!1),function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(o,2)||function(e,t){if(e){if("string"==typeof e)return d(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}}(o,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=l[0],s=l[1],f=(0,p.useForm)(),h=a(),v=n().useContext(y).onSaveSuccess,g=(i=m(function(e){var t,o,i;return b(this,function(a){switch(a.label){case 0:s(!0),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,u.request({url:"/license:license-key",method:"POST",data:{licenseKey:e}})];case 2:if(o=a.sent(),s(!1),"invalid"===(i=(null==o||null==(t=o.data)?void 0:t.data)||{}).keyStatus)return r.Modal.error({title:h("Invalid license key."),content:h("The license key is invalid. Please visit the NocoBase Service to obtain a new license key.")}),[2];if("invalid"===i.licenseStatus)return r.Modal.error({title:h("Invalid license key."),content:h("The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.")}),[2];if(!1===i.envMatch)return r.Modal.error({title:h("Environment mismatch."),content:n().createElement(n().Fragment,null,!1===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,h("The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.")),!0===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,h("The current system does not match the licensed system. Please use the new InstanceID to request a new license key.")),!1===i.dbMatch&&!0===i.sysMatch&&n().createElement(n().Fragment,null,h("The current database does not match the licensed database. Please use the new InstanceID to request a new license key.")))}),[2];if(!1===i.domainMatch)return r.Modal.error({title:h("Domain mismatch."),content:h("The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.",{domain:i.current.domain,interpolation:{escapeValue:!1}})}),[2];if(null==v||v(),!0===i.isExpired)return r.message.success(h("The license key was saved successfully"),5),r.Modal.warning({title:h("The license has exceeded the upgrade validity period."),content:h("Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.")}),[2];if(!1===i.isPkgLogin)return r.message.success(h("The license key was saved successfully"),5),r.Modal.warning({title:h("Network error."),content:h("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")}),[2];return r.message.success(h("License key saved successfully. Please retry the plugin installation.")),[3,4];case 3:return a.sent(),s(!1),r.message.error(h("Network error. Please try again.")),[3,4];case 4:return[2]}})}),function(e){return i.apply(this,arguments)});return{loading:c,onClick:m(function(){var e;return b(this,function(t){switch(t.label){case 0:return[4,null==f?void 0:f.validate()];case 1:return t.sent(),[4,g(null==(e=f.values)?void 0:e.licenseKey)];case 2:return t.sent(),[2]}})})}};function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function k(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){w(i,r,o,a,u,"next",e)}function u(e){w(i,r,o,a,u,"throw",e)}a(void 0)})}}function S(){return(S=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,u=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(u)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var E=function(e){var t=e.text,n=e.onSuccess,r=e.onError;if(!navigator.clipboard){var o=document.createElement("textarea");o.value=t,o.style.top="0",o.style.left="0",o.style.position="fixed",document.body.appendChild(o),o.focus(),o.select();try{document.execCommand("copy"),null==n||n()}catch(e){null==r||r()}document.body.removeChild(o);return}navigator.clipboard.writeText(t).then(function(){null==n||n()}).catch(function(e){console.error(e),null==r||r()})};function O(){var o,i=(0,e.useAPIClient)(),l=x((0,t.useState)(!1),2),c=l[0],s=l[1],f=x((0,t.useState)(""),2);f[0],f[1];var p=a(),y=(o=k(function(){return P(this,function(e){return s(!0),[2,i.request({url:"/license:instance-id",method:"GET"}).then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data}).finally(function(){s(!1)})]})}),function(){return o.apply(this,arguments)});return n().createElement(r.Button,{onClick:k(function(){return P(this,function(e){switch(e.label){case 0:return[4,y()];case 1:return E({text:e.sent(),onSuccess:function(){r.message.success(p("Copied"))},onError:function(){r.message.error(p("Failed to copy, please open ./storage/.license/instance-id and copy it"))}}),[2]}})}),loading:c,icon:n().createElement(u.CopyOutlined,null),type:"link"},p("Copy"))}var j=function(e){var i=S({},function(e){if(null==e)throw TypeError("Cannot destructure "+e);return e}(e)),u=x((0,t.useState)(!1),2),l=u[0],c=u[1],s=(0,p.useForm)(),f=a(),d=n().useContext(y).keyExist;return((0,o.useAsyncEffect)(k(function(){return P(this,function(e){return!1===d&&(c(!0),null==s||s.setFieldState("footer",function(e){e.visible=!0})),[2]})}),[d]),l)?n().createElement(r.Input.TextArea,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({rows:4},i)):d?n().createElement(n().Fragment,null,f("License key has been set"),"\xa0",n().createElement(r.Button,{onClick:function(){c(!0),null==s||s.setFieldState("footer",function(e){e.visible=!0})}},f("Change key"))):null},T=function(){var t=n().useContext(y),r=t.keyExist,o=t.refreshToken;return r?n().createElement(e.SchemaComponent,{key:o,schema:{type:"void",properties:{card:{type:"void","x-component":"LicenseCard"}}}}):null};function A(){var i=a(),u=x((0,t.useState)(0),2),l=u[0],c=u[1],s=x((0,t.useState)(null),2),p=s[0],d=s[1],h=(0,e.useAPIClient)();(0,o.useAsyncEffect)(k(function(){var e,t;return P(this,function(n){switch(n.label){case 0:return[4,h.request({url:"/license:is-exists",method:"GET"})];case 1:return d(null==(t=n.sent())||null==(e=t.data)?void 0:e.data),[2]}})}),[]);var m={type:"void","x-decorator":"Form",properties:{form:{type:"void",properties:{label:{type:"string",title:i("Instance ID"),"x-component":"InstanceId","x-decorator":"FormItem"},licenseKey:{type:"string",title:i("License key"),required:!0,"x-component":"TextArea","x-decorator":"FormItem","x-component-props":{placeholder:i("Enter license key")}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitProps","x-component-props":{type:"primary",style:{marginBottom:16}}}},"x-visible":!1},licenseInfo:{type:"void","x-component":"LicenseCardWarp"}}}}};return n().createElement(r.Card,{bordered:!1},n().createElement(y.Provider,{value:{onSaveSuccess:function(){c(function(e){return e+1}),d(!0)},keyExist:p,refreshToken:l}},n().createElement(f,{refreshToken:l}),n().createElement(e.SchemaComponent,{scope:{useSubmitProps:v},components:{InstanceId:O,TextArea:j,LicenseCardWarp:T},schema:{type:"void",properties:{form:m}}})))}function C(e,t,n,r,o,i,a){try{var u=e[i](a),l=u.value}catch(e){n(e);return}u.done?t(l):Promise.resolve(l).then(r,o)}function I(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){C(i,r,o,a,u,"next",e)}function u(e){C(i,r,o,a,u,"throw",e)}a(void 0)})}}function M(e,t,n){return(M=D()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&F(o,n.prototype),o}).apply(null,arguments)}function q(e){return(q=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function F(e,t){return(F=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function B(e){var t="function"==typeof Map?new Map:void 0;return(B=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return M(e,arguments,q(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),F(n,e)})(e)}function D(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(D=function(){return!!e})()}function L(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){var l=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var N=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=q(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,D()?Reflect.construct(e,t||[],q(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&F(n,e),t=[{key:"afterAdd",value:function(){return I(function(){return L(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return I(function(){return L(this,function(e){return[2]})})()}},{key:"load",value:function(){var e=this;return I(function(){return L(this,function(t){return e.app.pluginSettingsManager.add("license-settings",{title:"{{t(".concat(JSON.stringify("License settings"),", { ns: ['").concat(i.u2,"', 'client'], nsMode: 'fallback' })}}"),icon:"SolutionOutlined",Component:A,aclSnippet:"pm.license-settings"}),[2]})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(B(e.Plugin)),_=N}(),c}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-license",["ahooks","react","antd","@nocobase/client","@ant-design/icons","@formily/react"],t):"object"==typeof exports?exports["@nocobase/plugin-license"]=t(require("ahooks"),require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons"),require("@formily/react")):e["@nocobase/plugin-license"]=t(e.ahooks,e.react,e.antd,e["@nocobase/client"],e["@ant-design/icons"],e["@formily/react"])}(self,function(e,t,n,r,o,a){return function(){"use strict";var i={375:function(e){e.exports=o},230:function(e){e.exports=a},342:function(e){e.exports=r},625:function(t){t.exports=e},59:function(e){e.exports=n},155:function(e){e.exports=t}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return i[e](n,n.exports,c),n.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(l=c.g.location+"");var l,s=c.g.document;if(!l&&s&&(s.currentScript&&"SCRIPT"===s.currentScript.tagName.toUpperCase()&&(l=s.currentScript.src),!l)){var f=s.getElementsByTagName("script");if(f.length)for(var p=f.length-1;p>-1&&(!l||!/^http(s?):/.test(l));)l=f[p--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");c.p=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var y={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-license/dist/client/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var r=window.location.pathname||"/",o=r.indexOf("/v2/");e=o>=0?r.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-license/dist/client/"}c.p=e}(),!function(){c.r(y),c.d(y,{default:function(){return L},PluginLicenseClient:function(){return D}});var e=c(342),t=c(155),n=c.n(t),r=c(59),o=c(625),a=JSON.parse('{"UU":"@nocobase/plugin-license"}');function i(){var t=(0,e.useApp)();return function(e,n){return String(t.i18n.t(e,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:[a.UU,"client"]},n||{})))}}var u=c(375);function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var s=function(o){var a,u=o.refreshToken,c=(0,e.useAPIClient)(),s=function(e){if(Array.isArray(e))return e}(a=(0,t.useState)(null))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw n}}return o}}(a)||function(e){if(e){if("string"==typeof e)return l(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return l(e,2)}}(a)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),f=s[0],p=s[1],y=i();return((0,t.useEffect)(function(){p(null),c.request({url:"/license:license-validate",method:"get"}).then(function(e){var t;p(null==e||null==(t=e.data)?void 0:t.data)}).catch(function(e){console.log(e)})},[u]),(null==f?void 0:f.licenseStatus)&&(null==f?void 0:f.licenseStatus)==="active")?(null==f?void 0:f.isServiceConnection)===!1&&(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary."),n().createElement("br",null),y("Plugins also cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isServiceConnection)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, the license key cannot be updated automatically. Please update it manually if necessary.")),type:"warning",style:{marginBottom:12}}):(null==f?void 0:f.isPkgLogin)===!1?n().createElement(r.Alert,{message:y("Network error."),description:n().createElement(n().Fragment,null,y("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")),type:"warning",style:{marginBottom:12}}):null:null},f=c(230),p=n().createContext(null);function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function b(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){h(a,r,o,i,u,"next",e)}function u(e){h(a,r,o,i,u,"throw",e)}i(void 0)})}}function m(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var v=function(){var o,a=(0,e.useAPIClient)(),u=function(e){if(Array.isArray(e))return e}(o=(0,t.useState)(!1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(o.push(t.value),2!==o.length);a=!0);}catch(e){i=!0,n=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw n}}return o}}(o)||function(e){if(e){if("string"==typeof e)return d(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return d(e,2)}}(o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),c=u[0],l=u[1],s=(0,f.useForm)(),y=i(),h=n().useContext(p).onSaveSuccess;return{loading:c,onClick:function(){return b(function(){var e;return m(this,function(t){switch(t.label){case 0:return[4,null==s?void 0:s.validate()];case 1:var o;return t.sent(),[4,(o=null==(e=s.values)?void 0:e.licenseKey,b(function(){var e,t,i;return m(this,function(u){switch(u.label){case 0:l(!0),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,a.request({url:"/license:license-key",method:"POST",data:{licenseKey:o}})];case 2:if(t=u.sent(),l(!1),"invalid"===(i=(null==t||null==(e=t.data)?void 0:e.data)||{}).keyStatus)return r.Modal.error({title:y("Invalid license key."),content:y("The license key is invalid. Please visit the NocoBase Service to obtain a new license key.")}),[2];if("invalid"===i.licenseStatus)return r.Modal.error({title:y("Invalid license key."),content:y("The current license key has been deprecated. Please visit the NocoBase Service to obtain a new license key.")}),[2];if(!1===i.envMatch)return r.Modal.error({title:y("Environment mismatch."),content:n().createElement(n().Fragment,null,!1===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,y("The current system and database do not match the licensed environment. Please use the new InstanceID to request a new license key.")),!0===i.dbMatch&&!1===i.sysMatch&&n().createElement(n().Fragment,null,y("The current system does not match the licensed system. Please use the new InstanceID to request a new license key.")),!1===i.dbMatch&&!0===i.sysMatch&&n().createElement(n().Fragment,null,y("The current database does not match the licensed database. Please use the new InstanceID to request a new license key.")))}),[2];if(!1===i.domainMatch)return r.Modal.error({title:y("Domain mismatch."),content:y("The current domain ({{domain}}) does not match the licensed domain. Please use the current domain to request a new license key.",{domain:i.current.domain,interpolation:{escapeValue:!1}})}),[2];if(null==h||h(),!0===i.isExpired)return r.message.success(y("The license key was saved successfully"),5),r.Modal.warning({title:y("The license has exceeded the upgrade validity period."),content:y("Plugins bound to this license can still be used but cannot be upgraded. To upgrade, please renew or repurchase the license.")}),[2];if(!1===i.isPkgLogin)return r.message.success(y("The license key was saved successfully"),5),r.Modal.warning({title:y("Network error."),content:y("Due to network issues, plugins cannot be updated automatically (they are still usable). To update plugins, please check your network connection or refer to the NocoBase Service documentation to upload plugins manually.")}),[2];return r.message.success(y("License key saved successfully. Please retry the plugin installation.")),[3,4];case 3:return u.sent(),l(!1),r.message.error(y("Network error. Please try again.")),[3,4];case 4:return[2]}})})())];case 2:return t.sent(),[2]}})})()}}};function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function S(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){w(a,r,o,i,u,"next",e)}function u(e){w(a,r,o,i,u,"throw",e)}i(void 0)})}}function k(){return(k=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,u=!1;try{for(o=o.call(e);!(i=(n=o.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var P=function(e){var t=e.text,n=e.onSuccess,r=e.onError;if(!navigator.clipboard){var o=document.createElement("textarea");o.value=t,o.style.top="0",o.style.left="0",o.style.position="fixed",document.body.appendChild(o),o.focus(),o.select();try{document.execCommand("copy"),null==n||n()}catch(e){null==r||r()}document.body.removeChild(o);return}navigator.clipboard.writeText(t).then(function(){null==n||n()}).catch(function(e){console.error(e),null==r||r()})};function E(){var o=(0,e.useAPIClient)(),a=x((0,t.useState)(!1),2),c=a[0],l=a[1],s=x((0,t.useState)(""),2);s[0],s[1];var f=i();return n().createElement(r.Button,{onClick:function(){return S(function(){return O(this,function(e){switch(e.label){case 0:return[4,S(function(){return O(this,function(e){return l(!0),[2,o.request({url:"/license:instance-id",method:"GET"}).then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data}).finally(function(){l(!1)})]})})()];case 1:return P({text:e.sent(),onSuccess:function(){r.message.success(f("Copied"))},onError:function(){r.message.error(f("Failed to copy, please open ./storage/.license/instance-id and copy it"))}}),[2]}})})()},loading:c,icon:n().createElement(u.CopyOutlined,null),type:"link"},f("Copy"))}var j=function(e){var a=e;if(null==a)throw TypeError("Cannot destructure "+a);var u=k({},e),c=x((0,t.useState)(!1),2),l=c[0],s=c[1],y=(0,f.useForm)(),d=i(),h=n().useContext(p).keyExist;return((0,o.useAsyncEffect)(function(){return S(function(){return O(this,function(e){return!1===h&&(s(!0),null==y||y.setFieldState("footer",function(e){e.visible=!0})),[2]})})()},[h]),l)?n().createElement(r.Input.TextArea,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({rows:4},u)):h?n().createElement(n().Fragment,null,d("License key has been set"),"\xa0",n().createElement(r.Button,{onClick:function(){s(!0),null==y||y.setFieldState("footer",function(e){e.visible=!0})}},d("Change key"))):null},T=function(){var t=n().useContext(p),r=t.keyExist,o=t.refreshToken;return r?n().createElement(e.SchemaComponent,{key:o,schema:{type:"void",properties:{card:{type:"void","x-component":"LicenseCard"}}}}):null};function I(){var a=i(),u=x((0,t.useState)(0),2),c=u[0],l=u[1],f=x((0,t.useState)(null),2),y=f[0],d=f[1],h=(0,e.useAPIClient)();(0,o.useAsyncEffect)(function(){return S(function(){var e,t;return O(this,function(n){switch(n.label){case 0:return[4,h.request({url:"/license:is-exists",method:"GET"})];case 1:return d(null==(t=n.sent())||null==(e=t.data)?void 0:e.data),[2]}})})()},[]);var b={type:"void","x-decorator":"Form",properties:{form:{type:"void",properties:{label:{type:"string",title:a("Instance ID"),"x-component":"InstanceId","x-decorator":"FormItem"},licenseKey:{type:"string",title:a("License key"),required:!0,"x-component":"TextArea","x-decorator":"FormItem","x-component-props":{placeholder:a("Enter license key")}},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitProps","x-component-props":{type:"primary",style:{marginBottom:16}}}},"x-visible":!1},licenseInfo:{type:"void","x-component":"LicenseCardWarp"}}}}};return n().createElement(r.Card,{bordered:!1},n().createElement(p.Provider,{value:{onSaveSuccess:function(){l(function(e){return e+1}),d(!0)},keyExist:y,refreshToken:c}},n().createElement(s,{refreshToken:c}),n().createElement(e.SchemaComponent,{scope:{useSubmitProps:v},components:{InstanceId:E,TextArea:j,LicenseCardWarp:T},schema:{type:"void",properties:{form:b}}})))}function A(e,t,n,r,o,a,i){try{var u=e[a](i),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function C(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function i(e){A(a,r,o,i,u,"next",e)}function u(e){A(a,r,o,i,u,"throw",e)}i(void 0)})}}function _(e,t,n){return(_=B()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&q(o,n.prototype),o}).apply(null,arguments)}function M(e){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t){return(q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function F(e){var t="function"==typeof Map?new Map:void 0;return(F=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return _(e,arguments,M(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),q(n,e)})(e)}function B(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(B=function(){return!!e})()}function N(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(i,"next",{value:c(0)}),u(i,"throw",{value:c(1)}),u(i,"return",{value:c(2)}),"function"==typeof Symbol&&u(i,Symbol.iterator,{value:function(){return this}}),i;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}var D=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=M(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,B()?Reflect.construct(e,t||[],M(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&q(n,e),t=[{key:"afterAdd",value:function(){return C(function(){return N(this,function(e){return[2]})})()}},{key:"beforeLoad",value:function(){return C(function(){return N(this,function(e){return[2]})})()}},{key:"load",value:function(){return C(function(){return N(this,function(e){return this.app.pluginSettingsManager.add("license-settings",{title:"{{t(".concat(JSON.stringify("License settings"),", { ns: ['").concat(a.UU,"', 'client'], nsMode: 'fallback' })}}"),icon:"SolutionOutlined",Component:I,aclSnippet:"pm.license-settings"}),[2]})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(F(e.Plugin)),L=D}(),y}()});
@@ -9,16 +9,17 @@
9
9
 
10
10
  module.exports = {
11
11
  "react": "18.2.0",
12
- "@nocobase/client": "2.1.0-beta.15",
12
+ "@nocobase/client": "2.1.0-beta.16",
13
13
  "antd": "5.24.2",
14
14
  "ahooks": "3.7.8",
15
15
  "@ant-design/icons": "5.6.1",
16
16
  "@formily/react": "2.3.7",
17
17
  "@nocobase/license-kit": "0.3.8",
18
18
  "react-i18next": "11.18.6",
19
- "@nocobase/server": "2.1.0-beta.15",
19
+ "@nocobase/server": "2.1.0-beta.16",
20
20
  "lodash": "4.18.1",
21
- "koa": "2.16.0",
21
+ "@nocobase/utils": "2.1.0-beta.16",
22
+ "koa": "3.2.0",
22
23
  "axios": "1.7.7",
23
- "@nocobase/logger": "2.1.0-beta.15"
24
+ "@nocobase/logger": "2.1.0-beta.16"
24
25
  };
@@ -43,9 +43,10 @@ __export(instance_exports, {
43
43
  module.exports = __toCommonJS(instance_exports);
44
44
  var import_fs = __toESM(require("fs"));
45
45
  var import_path = __toESM(require("path"));
46
+ var import_utils = require("@nocobase/utils");
46
47
  var import_child_process = require("child_process");
47
48
  async function getInstanceId() {
48
- const dir = import_path.default.resolve(process.cwd(), "storage/.license");
49
+ const dir = (0, import_utils.storagePathJoin)(".license");
49
50
  const filePath = import_path.default.resolve(dir, "instance-id");
50
51
  await createInstanceId(true);
51
52
  const id = import_fs.default.readFileSync(filePath, "utf-8");
@@ -63,7 +64,7 @@ async function createInstanceId(force = false) {
63
64
  });
64
65
  }
65
66
  async function isLicenseKeyExists() {
66
- const dir = import_path.default.resolve(process.cwd(), "storage/.license");
67
+ const dir = (0, import_utils.storagePathJoin)(".license");
67
68
  const filePath = import_path.default.resolve(dir, "license-key");
68
69
  return import_fs.default.existsSync(filePath);
69
70
  }
@@ -48,6 +48,7 @@ __export(key_exports, {
48
48
  module.exports = __toCommonJS(key_exports);
49
49
  var import_license_kit = require("@nocobase/license-kit");
50
50
  var import_path = __toESM(require("path"));
51
+ var import_utils = require("@nocobase/utils");
51
52
  var import_fs = __toESM(require("fs"));
52
53
  var import_interface2 = require("./interface");
53
54
  var import_axios = __toESM(require("axios"));
@@ -88,7 +89,7 @@ async function request({
88
89
  }
89
90
  }
90
91
  async function saveLicenseKey(licenseKey, ctx) {
91
- const dir = import_path.default.resolve(process.cwd(), "storage/.license");
92
+ const dir = (0, import_utils.storagePathJoin)(".license");
92
93
  const filePath = import_path.default.resolve(dir, "license-key");
93
94
  await import_fs.default.promises.writeFile(filePath, licenseKey);
94
95
  if (ctx && ctx.cache) {
@@ -97,7 +98,7 @@ async function saveLicenseKey(licenseKey, ctx) {
97
98
  }
98
99
  }
99
100
  async function getLocalKeyData() {
100
- const keyFile = import_path.default.resolve(process.cwd(), "storage/.license/license-key");
101
+ const keyFile = (0, import_utils.storagePathJoin)(".license", "license-key");
101
102
  try {
102
103
  const key = (await import_fs.default.promises.readFile(keyFile, "utf8")).trim();
103
104
  return JSON.parse((0, import_license_kit.keyDecrypt)(key));
@@ -108,7 +109,7 @@ async function getLocalKeyData() {
108
109
  async function getKey(ctx) {
109
110
  var _a, _b;
110
111
  let key;
111
- const keyFile = import_path.default.resolve(process.cwd(), "storage/.license/license-key");
112
+ const keyFile = (0, import_utils.storagePathJoin)(".license", "license-key");
112
113
  if (ctx == null ? void 0 : ctx.cache) {
113
114
  try {
114
115
  key = await ctx.cache.get(import_interface2.CACHE_KEY);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-license",
3
- "version": "2.1.0-beta.15",
3
+ "version": "2.1.0-beta.16",
4
4
  "main": "dist/server/index.js",
5
5
  "displayName": "License settings",
6
6
  "displayName.ru-RU": "Настройки лицензии",
@@ -17,5 +17,5 @@
17
17
  "ts:env": "tsc -p tsconfig.env.json"
18
18
  },
19
19
  "license": "Apache-2.0",
20
- "gitHead": "dc1aceea6357e6ab149976c2a236fc4b6bee1370"
20
+ "gitHead": "b9a191705a440a336c85d82fd877fdf152bec70f"
21
21
  }