@nocobase/plugin-theme-editor 1.5.0-beta.9 → 1.5.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/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Updated Date: October 15, 2024
1
+ Updated Date: February 6, 2025
2
2
 
3
3
  NocoBase License Agreement
4
4
 
@@ -78,7 +78,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
78
78
 
79
79
  6.1 Obtain a permanent commercial license of the Software.
80
80
 
81
- 6.2 Get 12 months of upgrade and exclusive technical support.
81
+ 6.2 Get software upgrades and exclusive technical support during the upgrade validity period.
82
82
 
83
83
  6.3 The licensed Software can be used for commercial purposes with no restrictions on the number of applications and users.
84
84
 
@@ -95,7 +95,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
95
95
  6.9 If there are other agreements in the contract for the above rights, the contract agreement shall prevail.
96
96
 
97
97
  ====================================
98
- 7. Obligations of Commercial License
98
+ 1. Obligations of Commercial License
99
99
  ====================================
100
100
 
101
101
  7.1 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
@@ -108,11 +108,13 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
108
108
 
109
109
  7.5 It is not allowed for the User with a Standard Edition license to sell Upper Layer Application to clients without a Commercial license.
110
110
 
111
- 7.6 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
111
+ 7.6 It is not allowed for the User with a Professional or Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license with access to further development and configuration.
112
112
 
113
- 7.7 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
113
+ 7.7 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
114
114
 
115
- 7.8 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
115
+ 7.8 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
116
+
117
+ 7.9 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
116
118
 
117
119
  ======================================
118
120
  8. Rights of Commercial Plugin License
@@ -120,7 +122,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
120
122
 
121
123
  8.1 Obtain a permanent Commercial Plugin License for the Commercial Plugin.
122
124
 
123
- 8.2 Receive 12 months of upgrades and exclusive technical support.
125
+ 8.2 Get plugins upgrades and exclusive technical support during the upgrade validity period.
124
126
 
125
127
  8.3 Can be used for commercial purposes without restrictions on the number of applications or users.
126
128
 
@@ -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-i18next"),require("@nocobase/utils/client"),require("@nocobase/client"),require("lodash"),require("antd"),require("@ant-design/icons"),require("@ant-design/cssinjs"),require("react"),require("@emotion/css")):"function"==typeof define&&define.amd?define("@nocobase/plugin-theme-editor",["react-i18next","@nocobase/utils/client","@nocobase/client","lodash","antd","@ant-design/icons","@ant-design/cssinjs","react","@emotion/css"],t):"object"==typeof exports?exports["@nocobase/plugin-theme-editor"]=t(require("react-i18next"),require("@nocobase/utils/client"),require("@nocobase/client"),require("lodash"),require("antd"),require("@ant-design/icons"),require("@ant-design/cssinjs"),require("react"),require("@emotion/css")):e["@nocobase/plugin-theme-editor"]=t(e["react-i18next"],e["@nocobase/utils/client"],e["@nocobase/client"],e.lodash,e.antd,e["@ant-design/icons"],e["@ant-design/cssinjs"],e.react,e["@emotion/css"])}(self,function(e,t,n,r,o,i,u,a,c){return function(){var l,s,f,d,p,m={7012:function(e,t,n){"use strict";n.r(t),n.d(t,{useThemeId:function(){return f}});var r=n(3772),o=n(7584),i=n(8156),u=n.n(i),a=n(8144),c=n(5725),l=n(3036),s=u().createContext({}),f=function(){return u().useContext(s)},d=function(e){var t,n,f,d=e.children,p=(0,r.useCurrentUserContext)(),m=(0,r.useGlobalTheme)().setTheme,h=(0,l.useThemeListContext)(),b=h.run,v=h.data,y=h.loading,g=(0,i.useMemo)(function(){return null==v?void 0:v.find(function(e){return e.default})},[v]),O=(0,i.useRef)(null),w=(0,r.useAPIClient)();(0,i.useEffect)(function(){var e=w.auth.getOption("theme");if(e)try{m((0,c.w)(JSON.parse(e)).config)}catch(e){(0,o.error)(e)}},[]),(0,i.useEffect)(function(){if(!v)return b();var e,t,n,o,i=null==p?void 0:null===(n=p.data)||void 0===n?void 0:null===(t=n.data)||void 0===t?void 0:null===(e=t.systemSettings)||void 0===e?void 0:e.themeId;null!=i&&(o=v.find(function(e){return e.id===i})),!o&&(o=g),o?(O.current=o.id,m(o.config),w.auth.setOption("theme",JSON.stringify(Object.assign(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,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},o),{config:(0,a.i)(o.config)})))):(m(r.defaultTheme),w.auth.setOption("theme",null))},[w.auth,null==p?void 0:null===(f=p.data)||void 0===f?void 0:null===(n=f.data)||void 0===n?void 0:null===(t=n.systemSettings)||void 0===t?void 0:t.themeId,v,b,m,g]);var P=y&&!v||p.loading?{}:{currentThemeId:O.current,defaultThemeId:null==g?void 0:g.id};return u().createElement(s.Provider,{value:P},d)};d.displayName="InitializeTheme",t.default=d},3036:function(e,t,n){"use strict";n.r(t),n.d(t,{ThemeListProvider:function(){return s},useThemeListContext:function(){return l}});var r=n(3772),o=n(7584),i=n(8156),u=n.n(i),a=n(5725),c=(0,i.createContext)(null);c.displayName="ThemeListContext";var l=function(){return u().useContext(c)},s=function(e){var t=e.children,n=(0,r.useRequest)({url:"themeConfig:list",params:{sort:"id",paginate:!1}},{manual:!0}),l=n.data,s=n.error,f=n.run,d=n.refresh,p=n.loading,m=(0,i.useMemo)(function(){var e;return null==l?void 0:null===(e=l.data)||void 0===e?void 0:e.map(function(e){return(0,a.w)(e)})},[l]);return s&&(0,o.error)(s),u().createElement(c.Provider,{value:{data:m,error:s,run:f,refresh:d,loading:p}},t)};s.displayName="ThemeListProvider"},15:function(e,t,n){"use strict";n.d(t,{Y:function(){return l}});var r=n(3772),o=n(7584),i=n(8156);function u(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function a(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,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function l(){var e,t,n=(0,r.useAPIClient)(),l=(0,r.useCurrentUserContext)();return{updateUserThemeSettings:(0,i.useCallback)((t=(e=function(e){var t,r;return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(i){switch(i.label){case 0:if(e===(null===(t=l.data.data.systemSettings)||void 0===t?void 0:t.themeId))return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n.resource("users").updateProfile({values:{systemSettings:c(a({},l.data.data.systemSettings||{}),{themeId:e})}})];case 2:return i.sent(),l.mutate({data:c(a({},l.data.data),{systemSettings:c(a({},l.data.data.systemSettings||{}),{themeId:e})})}),[3,4];case 3:return r=i.sent(),(0,o.error)(r),[3,4];case 4:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){u(i,r,o,a,c,"next",e)}function c(e){u(i,r,o,a,c,"throw",e)}a(void 0)})}),function(e){return t.apply(this,arguments)}),[n,l])}}},8144:function(e,t,n){"use strict";n.d(t,{i:function(){return u}});var r=n(2721),o=n(467),i=n.n(o);function u(e){return(e=i().cloneDeep(e)).algorithm?(Array.isArray(e.algorithm)?e.algorithm=e.algorithm.map(function(e){return a(e)}).filter(Boolean):e.algorithm=a(e.algorithm),i().isEmpty(e.algorithm)&&delete e.algorithm,e):e}function a(e){return"string"==typeof e?e:e.toString()===r.theme.darkAlgorithm.toString()?"darkAlgorithm":e.toString()===r.theme.compactAlgorithm.toString()?"compactAlgorithm":void 0}},5725:function(e,t,n){"use strict";n.d(t,{w:function(){return u}});var r=n(2721),o=n(467),i=n.n(o);function u(e){var t;return e=i().cloneDeep(e),i().isString(e.config.algorithm)&&(e.config.algorithm=r.theme[e.config.algorithm]),Array.isArray(null===(t=e.config)||void 0===t?void 0:t.algorithm)&&(e.config.algorithm=e.config.algorithm.map(function(e){return i().isString(e)?r.theme[e]:e})),e}},573:function(e,t,n){"use strict";n.d(t,{$:function(){return i},A:function(){return o}});var r=n(3238),o="theme-editor";function i(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},3581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},1143:function(e){"use strict";e.exports=u},482:function(e){"use strict";e.exports=i},4964:function(e){"use strict";e.exports=c},3772:function(e){"use strict";e.exports=n},7584:function(e){"use strict";e.exports=t},2721:function(e){"use strict";e.exports=o},467:function(e){"use strict";e.exports=r},8156:function(e){"use strict";e.exports=a},3238:function(t){"use strict";t.exports=e}},h={};function b(e){var t=h[e];if(void 0!==t)return t.exports;var n=h[e]={exports:{}};return m[e](n,n.exports,b),n.exports}b.m=m,b.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return b.d(t,{a:t}),t},b.d=function(e,t){for(var n in t)b.o(t,n)&&!b.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},b.f={},b.e=function(e){return Promise.all(Object.keys(b.f).reduce(function(t,n){return b.f[n](e,t),t},[]))},b.u=function(e){return""+({171:"49db08b28208ffa6",506:"7c36603b4fb35f3c",916:"f0f46c0d5e9d3ae0",933:"d7a691fdba42ac3b",964:"862ac7919b43871b"})[e]+".js"},b.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l={},s="@nocobase/plugin-theme-editor:",b.l=function(e,t,n,r){if(l[e]){l[e].push(t);return}if(void 0!==n){for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")==s+n){o=c;break}}}!o&&(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,b.nc&&o.setAttribute("nonce",b.nc),o.setAttribute("data-webpack",s+n),o.src=e),l[e]=[t];var f=function(t,n){o.onerror=o.onload=null,clearTimeout(d);var r=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=f.bind(null,o.onerror),o.onload=f.bind(null,o.onload),i&&document.head.appendChild(o)},b.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},b.nc=void 0,b.p="/static/plugins/@nocobase/plugin-theme-editor/dist/client/",f={909:0},b.f.j=function(e,t){var n=b.o(f,e)?f[e]:void 0;if(0!==n){if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=f[e]=[t,r]});t.push(n[2]=r);var o=b.p+b.u(e),i=Error();b.l(o,function(t){if(b.o(f,e)&&(0!==(n=f[e])&&(f[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}}},d=function(e,t){var n=t[0],r=t[1],o=t[2],i,u,a=0;if(n.some(function(e){return 0!==f[e]})){for(i in r)b.o(r,i)&&(b.m[i]=r[i]);o&&o(b)}for(e&&e(t);a<n.length;a++)u=n[a],b.o(f,u)&&f[u]&&f[u][0](),f[u]=0},(p=self.webpackChunk_nocobase_plugin_theme_editor=self.webpackChunk_nocobase_plugin_theme_editor||[]).forEach(d.bind(null,0)),p.push=d.bind(null,p.push.bind(p));var v={};return!function(){"use strict";b.r(v),b.d(v,{PluginThemeEditorClient:function(){return A},default:function(){return q}});var e=b("3772"),t=b("2721"),n=b("467"),r=b.n(n),o=b("8156"),i=b.n(o),u=b("7584"),a=b("7012"),c=b("3036"),l=b("573"),s=b("15");function f(){var t=(0,l.$)().t,n=(0,c.useThemeListContext)(),r=n.run,f=n.error,d=n.data,p=(0,s.Y)().updateUserThemeSettings,m=(0,a.useThemeId)().currentThemeId,h=(0,o.useMemo)(function(){return null==d?void 0:d.filter(function(e){return e.optional}).map(function(e){return{label:t(e.config.name),value:e.id}})},[d,t]);return((0,o.useEffect)(function(){!d&&r()},[]),f)?((0,u.error)(f),null):i().createElement(e.SelectWithTitle,{title:t("Theme"),options:h,defaultValue:m,onChange:function(e){p(e)}})}var d=b(3581);function p(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 m(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function h(e,t,n){return(h=P()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&O(o,n.prototype),o}).apply(null,arguments)}function y(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)}}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function O(e,t){return(O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t="function"==typeof Map?new Map:void 0;return(w=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).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,r)}function r(){return h(e,arguments,g(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),O(r,e)})(e)}function P(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(P=function(){return!!e})()}function S(){var e,t,n=(e=["\n overflow: hidden;\n border-left: 1px solid ",";\n animation: 0.1s ease-out 0s 1 slideInFromRight;\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(100%);\n }\n 100% {\n transform: translateX(0);\n }\n }\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return S=function(){return n},n}var j=(0,e.lazy)(function(){return d("imported_-1bkn1ue_component",Promise.resolve().then(b.bind(b,7012)))}),x=(0,e.lazy)(function(){return d("imported_-16ae68t_component",b.e("964").then(b.bind(b,4950)))},"ThemeEditorProvider").ThemeEditorProvider,T=(0,e.lazy)(function(){return d("imported_-19lv318_component",Promise.all([b.e("933"),b.e("916"),b.e("506")]).then(b.bind(b,8390)))}),_=(0,e.lazy)(function(){return d("imported_-ofsaik_component",Promise.resolve().then(b.bind(b,3036)))},"ThemeListProvider").ThemeListProvider,E=(0,e.lazy)(function(){return d("imported_-1mfft73_component",Promise.all([b.e("933"),b.e("916"),b.e("171")]).then(b.bind(b,7362)))}),k=(0,e.createStyles)(function(e){var t=e.css,n=e.token;return{editor:t(S(),n.colorBorderSecondary)}}),C=i().memo(function(n){var u,a,c,l=(0,e.useCurrentUserSettingsMenu)().addMenuItem,s=(0,o.useMemo)(function(){return{key:"theme",eventKey:"theme",label:i().createElement(f,null)}},[]);var d=(u=i().useState(!1),a=2,function(e){if(Array.isArray(e))return e}(u)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],u=!0,a=!1;try{for(o=o.call(e);!(u=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);u=!0);}catch(e){a=!0,r=e}finally{try{!u&&null!=o.return&&o.return()}finally{if(a)throw r}}return i}}(u,2)||function(e,t){if(e){if("string"==typeof e)return p(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 p(e,t)}}(u,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.")}()),m=d[0],h=d[1],b=(0,e.useGlobalTheme)(),v=b.theme,y=b.setTheme,g=k().styles;(0,o.useEffect)(function(){l(s,{before:"divider_3"})},[l,s]);var O=(0,o.useMemo)(function(){return m?{transform:"rotate(0)",flexGrow:1,width:0,height:"100%"}:{flexGrow:1,width:0,height:"100%"}},[m]),w=i().createElement("div",{style:{display:"flex",overflow:"hidden",height:"100%"}},i().createElement("div",{style:O},n.children),m?i().createElement("div",{className:g.editor},i().createElement(E,{onThemeChange:y})):null);return!(null==v?void 0:null===(c=v.token)||void 0===c?void 0:c.motionUnit)&&r().set(v,"token.motionUnit",e.defaultTheme.token.motionUnit),i().createElement(t.ConfigProvider,{theme:v},i().createElement(_,null,i().createElement(j,null,i().createElement(x,{open:m,setOpen:h},w))))});C.displayName="CustomThemeProvider";var A=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=g(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,P()?Reflect.construct(t,n||[],g(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&O(e,t)}(o,e),t=o,n=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(e){return t.app.use(C),t.app.pluginSettingsManager.add(l.A,{title:'{{t("Theme editor", {ns:"'.concat(l.A,'"})}}'),icon:"BgColorsOutlined",Component:T,aclSnippet:"pm.theme-editor.themes"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){m(i,r,o,u,a,"next",e)}function a(e){m(i,r,o,u,a,"throw",e)}u(void 0)})})()}}],y(t.prototype,n),o}(w(e.Plugin)),q=A}(),v}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@nocobase/utils/client"),require("@nocobase/client"),require("lodash"),require("antd"),require("@ant-design/icons"),require("@ant-design/cssinjs"),require("react"),require("@emotion/css")):"function"==typeof define&&define.amd?define("@nocobase/plugin-theme-editor",["react-i18next","@nocobase/utils/client","@nocobase/client","lodash","antd","@ant-design/icons","@ant-design/cssinjs","react","@emotion/css"],t):"object"==typeof exports?exports["@nocobase/plugin-theme-editor"]=t(require("react-i18next"),require("@nocobase/utils/client"),require("@nocobase/client"),require("lodash"),require("antd"),require("@ant-design/icons"),require("@ant-design/cssinjs"),require("react"),require("@emotion/css")):e["@nocobase/plugin-theme-editor"]=t(e["react-i18next"],e["@nocobase/utils/client"],e["@nocobase/client"],e.lodash,e.antd,e["@ant-design/icons"],e["@ant-design/cssinjs"],e.react,e["@emotion/css"])}(self,function(e,t,n,r,o,i,u,a,c){return function(){var l,s,f,d,p,m,h={7012:function(e,t,n){"use strict";n.r(t),n.d(t,{useThemeId:function(){return f}});var r=n(3772),o=n(7584),i=n(8156),u=n.n(i),a=n(8144),c=n(5725),l=n(3036),s=u().createContext({}),f=function(){return u().useContext(s)},d=function(e){var t,n,f,d=e.children,p=(0,r.useCurrentUserContext)(),m=(0,r.useGlobalTheme)().setTheme,h=(0,l.useThemeListContext)(),b=h.run,v=h.data,y=h.loading,g=(0,i.useMemo)(function(){return null==v?void 0:v.find(function(e){return e.default})},[v]),w=(0,i.useRef)(null),O=(0,r.useAPIClient)();(0,i.useEffect)(function(){var e=O.auth.getOption("theme");if(e)try{m((0,c.w)(JSON.parse(e)).config)}catch(e){(0,o.error)(e)}},[]),(0,i.useEffect)(function(){if(!v)return b();var e,t,n,o,i=null==p?void 0:null===(n=p.data)||void 0===n?void 0:null===(t=n.data)||void 0===t?void 0:null===(e=t.systemSettings)||void 0===e?void 0:e.themeId;null!=i&&(o=v.find(function(e){return e.id===i})),!o&&(o=g),o?(w.current=o.id,m(o.config),O.auth.setOption("theme",JSON.stringify(Object.assign(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,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}({},o),{config:(0,a.i)(o.config)})))):(m(r.defaultTheme),O.auth.setOption("theme",null))},[O.auth,null==p?void 0:null===(f=p.data)||void 0===f?void 0:null===(n=f.data)||void 0===n?void 0:null===(t=n.systemSettings)||void 0===t?void 0:t.themeId,v,b,m,g]);var j=y&&!v||p.loading?{}:{currentThemeId:w.current,defaultThemeId:null==g?void 0:g.id};return u().createElement(s.Provider,{value:j},d)};d.displayName="InitializeTheme",t.default=d},3036:function(e,t,n){"use strict";n.r(t),n.d(t,{ThemeListProvider:function(){return s},useThemeListContext:function(){return l}});var r=n(3772),o=n(7584),i=n(8156),u=n.n(i),a=n(5725),c=(0,i.createContext)(null);c.displayName="ThemeListContext";var l=function(){return u().useContext(c)},s=function(e){var t=e.children,n=(0,r.useRequest)({url:"themeConfig:list",params:{sort:"id",paginate:!1}},{manual:!0}),l=n.data,s=n.error,f=n.run,d=n.refresh,p=n.loading,m=(0,i.useMemo)(function(){var e;return null==l?void 0:null===(e=l.data)||void 0===e?void 0:e.map(function(e){return(0,a.w)(e)})},[l]);return s&&(0,o.error)(s),u().createElement(c.Provider,{value:{data:m,error:s,run:f,refresh:d,loading:p}},t)};s.displayName="ThemeListProvider"},15:function(e,t,n){"use strict";n.d(t,{Y:function(){return l}});var r=n(3772),o=n(7584),i=n(8156);function u(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function a(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,o,i;r=e,o=t,i=n[t],o in r?Object.defineProperty(r,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[o]=i})}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function l(){var e,t,n=(0,r.useAPIClient)(),l=(0,r.useCurrentUserContext)();return{updateUserThemeSettings:(0,i.useCallback)((t=(e=function(e){var t,r;return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(i){switch(i.label){case 0:if(e===(null===(t=l.data.data.systemSettings)||void 0===t?void 0:t.themeId))return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n.resource("users").updateTheme({values:{themeId:e}})];case 2:return i.sent(),l.mutate({data:c(a({},l.data.data),{systemSettings:c(a({},l.data.data.systemSettings||{}),{themeId:e})})}),[3,4];case 3:return r=i.sent(),(0,o.error)(r),[3,4];case 4:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){u(i,r,o,a,c,"next",e)}function c(e){u(i,r,o,a,c,"throw",e)}a(void 0)})}),function(e){return t.apply(this,arguments)}),[n,l])}}},8144:function(e,t,n){"use strict";n.d(t,{i:function(){return u}});var r=n(2721),o=n(467),i=n.n(o);function u(e){return(e=i().cloneDeep(e)).algorithm?(Array.isArray(e.algorithm)?e.algorithm=e.algorithm.map(function(e){return a(e)}).filter(Boolean):e.algorithm=a(e.algorithm),i().isEmpty(e.algorithm)&&delete e.algorithm,e):e}function a(e){return"string"==typeof e?e:e.toString()===r.theme.darkAlgorithm.toString()?"darkAlgorithm":e.toString()===r.theme.compactAlgorithm.toString()?"compactAlgorithm":void 0}},5725:function(e,t,n){"use strict";n.d(t,{w:function(){return u}});var r=n(2721),o=n(467),i=n.n(o);function u(e){var t;return e=i().cloneDeep(e),i().isString(e.config.algorithm)&&(e.config.algorithm=r.theme[e.config.algorithm]),Array.isArray(null===(t=e.config)||void 0===t?void 0:t.algorithm)&&(e.config.algorithm=e.config.algorithm.map(function(e){return i().isString(e)?r.theme[e]:e})),e}},573:function(e,t,n){"use strict";n.d(t,{$:function(){return i},A:function(){return o}});var r=n(3238),o="theme-editor";function i(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},3581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},1143:function(e){"use strict";e.exports=u},482:function(e){"use strict";e.exports=i},4964:function(e){"use strict";e.exports=c},3772:function(e){"use strict";e.exports=n},7584:function(e){"use strict";e.exports=t},2721:function(e){"use strict";e.exports=o},467:function(e){"use strict";e.exports=r},8156:function(e){"use strict";e.exports=a},3238:function(t){"use strict";t.exports=e}},b={};function v(e){var t=b[e];if(void 0!==t)return t.exports;var n=b[e]={exports:{}};return h[e](n,n.exports,v),n.exports}v.m=h,v.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return v.d(t,{a:t}),t},v.d=function(e,t){for(var n in t)v.o(t,n)&&!v.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},v.f={},v.e=function(e){return Promise.all(Object.keys(v.f).reduce(function(t,n){return v.f[n](e,t),t},[]))},v.u=function(e){return""+({171:"49db08b28208ffa6",506:"7c36603b4fb35f3c",916:"f0f46c0d5e9d3ae0",933:"d7a691fdba42ac3b",964:"862ac7919b43871b"})[e]+".js"},v.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),v.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l={},s="@nocobase/plugin-theme-editor:",v.l=function(e,t,n,r){if(l[e]){l[e].push(t);return}if(void 0!==n){for(var o,i,u=document.getElementsByTagName("script"),a=0;a<u.length;a++){var c=u[a];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")==s+n){o=c;break}}}!o&&(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,v.nc&&o.setAttribute("nonce",v.nc),o.setAttribute("data-webpack",s+n),o.src=e),l[e]=[t];var f=function(t,n){o.onerror=o.onload=null,clearTimeout(d);var r=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=f.bind(null,o.onerror),o.onload=f.bind(null,o.onload),i&&document.head.appendChild(o)},v.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},v.nc=void 0,v.p=(!(f=window.__nocobase_public_path__||"/").endsWith("/")&&(f+="/"),f+"static/plugins/@nocobase/plugin-theme-editor/dist/client/"),d={909:0},v.f.j=function(e,t){var n=v.o(d,e)?d[e]:void 0;if(0!==n){if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=d[e]=[t,r]});t.push(n[2]=r);var o=v.p+v.u(e),i=Error();v.l(o,function(t){if(v.o(d,e)&&(0!==(n=d[e])&&(d[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}}},p=function(e,t){var n=t[0],r=t[1],o=t[2],i,u,a=0;if(n.some(function(e){return 0!==d[e]})){for(i in r)v.o(r,i)&&(v.m[i]=r[i]);o&&o(v)}for(e&&e(t);a<n.length;a++)u=n[a],v.o(d,u)&&d[u]&&d[u][0](),d[u]=0},(m=self.webpackChunk_nocobase_plugin_theme_editor=self.webpackChunk_nocobase_plugin_theme_editor||[]).forEach(p.bind(null,0)),m.push=p.bind(null,m.push.bind(m));var y={};return!function(){"use strict";v.r(y),v.d(y,{PluginThemeEditorClient:function(){return A},default:function(){return q}});var e=v("3772"),t=v("2721"),n=v("467"),r=v.n(n),o=v("8156"),i=v.n(o),u=v("7584"),a=v("7012"),c=v("3036"),l=v("573"),s=v("15");function f(){var t=(0,l.$)().t,n=(0,c.useThemeListContext)(),r=n.run,f=n.error,d=n.data,p=(0,s.Y)().updateUserThemeSettings,m=(0,a.useThemeId)().currentThemeId,h=(0,o.useMemo)(function(){return null==d?void 0:d.filter(function(e){return e.optional}).map(function(e){return{label:t(e.config.name),value:e.id}})},[d,t]);return((0,o.useEffect)(function(){!d&&r()},[]),f)?((0,u.error)(f),null):i().createElement(e.SelectWithTitle,{title:t("Theme"),options:h,defaultValue:m,onChange:function(e){p(e)}})}var d=v(3581);function p(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 m(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function h(e,t,n){return(h=j()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&w(o,n.prototype),o}).apply(null,arguments)}function b(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)}}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){var t="function"==typeof Map?new Map:void 0;return(O=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).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,r)}function r(){return h(e,arguments,g(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),w(r,e)})(e)}function j(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(j=function(){return!!e})()}function P(){var e,t,n=(e=["\n overflow: hidden;\n border-left: 1px solid ",";\n animation: 0.1s ease-out 0s 1 slideInFromRight;\n @keyframes slideInFromRight {\n 0% {\n transform: translateX(100%);\n }\n 100% {\n transform: translateX(0);\n }\n }\n "],!t&&(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return P=function(){return n},n}var x=(0,e.lazy)(function(){return d("imported_-1bkn1ue_component",Promise.resolve().then(v.bind(v,7012)))}),S=(0,e.lazy)(function(){return d("imported_-16ae68t_component",v.e("964").then(v.bind(v,4950)))},"ThemeEditorProvider").ThemeEditorProvider,_=(0,e.lazy)(function(){return d("imported_-19lv318_component",Promise.all([v.e("933"),v.e("916"),v.e("506")]).then(v.bind(v,8390)))}),T=(0,e.lazy)(function(){return d("imported_-ofsaik_component",Promise.resolve().then(v.bind(v,3036)))},"ThemeListProvider").ThemeListProvider,E=(0,e.lazy)(function(){return d("imported_-1mfft73_component",Promise.all([v.e("933"),v.e("916"),v.e("171")]).then(v.bind(v,7362)))}),k=(0,e.createStyles)(function(e){var t=e.css,n=e.token;return{editor:t(P(),n.colorBorderSecondary)}}),C=i().memo(function(n){var u,a,c,l=(0,e.useCurrentUserSettingsMenu)().addMenuItem,s=(0,o.useMemo)(function(){return{key:"theme",eventKey:"theme",label:i().createElement(f,null)}},[]);var d=(u=i().useState(!1),a=2,function(e){if(Array.isArray(e))return e}(u)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],u=!0,a=!1;try{for(o=o.call(e);!(u=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);u=!0);}catch(e){a=!0,r=e}finally{try{!u&&null!=o.return&&o.return()}finally{if(a)throw r}}return i}}(u,2)||function(e,t){if(e){if("string"==typeof e)return p(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 p(e,t)}}(u,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.")}()),m=d[0],h=d[1],b=(0,e.useGlobalTheme)(),v=b.theme,y=b.setTheme,g=k().styles;(0,o.useEffect)(function(){l(s,{before:"divider_3"})},[l,s]);var w=(0,o.useMemo)(function(){return m?{transform:"rotate(0)",flexGrow:1,width:0,height:"100%"}:{flexGrow:1,width:0,height:"100%"}},[m]),O=i().createElement("div",{style:{display:"flex",overflow:"hidden",height:"100%"}},i().createElement("div",{style:w},n.children),m?i().createElement("div",{className:g.editor},i().createElement(E,{onThemeChange:y})):null);return!(null==v?void 0:null===(c=v.token)||void 0===c?void 0:c.motionUnit)&&r().set(v,"token.motionUnit",e.defaultTheme.token.motionUnit),i().createElement(t.ConfigProvider,{theme:v},i().createElement(T,null,i().createElement(x,null,i().createElement(S,{open:m,setOpen:h},O))))});C.displayName="CustomThemeProvider";var A=function(e){var t,n,r;function o(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,o),e=this,t=o,n=arguments,t=g(t),function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,j()?Reflect.construct(t,n||[],g(e).constructor):t.apply(e,n))}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&w(e,t)}(o,e),t=o,n=[{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}(this,function(e){return t.app.use(C),t.app.pluginSettingsManager.add(l.A,{title:'{{t("Theme editor", {ns:"'.concat(l.A,'"})}}'),icon:"BgColorsOutlined",Component:_,aclSnippet:"pm.theme-editor.themes"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){m(i,r,o,u,a,"next",e)}function a(e){m(i,r,o,u,a,"throw",e)}u(void 0)})})()}}],b(t.prototype,n),o}(O(e.Plugin)),q=A}(),y}()});
@@ -8,15 +8,16 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.5.0-beta.9",
11
+ "@nocobase/client": "1.5.1",
12
12
  "react": "18.2.0",
13
13
  "antd": "5.12.8",
14
14
  "lodash": "4.17.21",
15
- "@nocobase/server": "1.5.0-beta.9",
15
+ "@nocobase/server": "1.5.1",
16
16
  "@ant-design/cssinjs": "1.21.1",
17
17
  "@ant-design/icons": "5.2.6",
18
- "@nocobase/utils": "1.5.0-beta.9",
18
+ "@nocobase/utils": "1.5.1",
19
19
  "react-i18next": "11.18.6",
20
- "@nocobase/database": "1.5.0-beta.9",
20
+ "@nocobase/actions": "1.5.1",
21
+ "@nocobase/database": "1.5.1",
21
22
  "@emotion/css": "11.13.0"
22
23
  };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Context, Next } from '@nocobase/actions';
10
+ export declare function updateTheme(ctx: Context, next: Next): Promise<void>;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var update_user_theme_exports = {};
28
+ __export(update_user_theme_exports, {
29
+ updateTheme: () => updateTheme
30
+ });
31
+ module.exports = __toCommonJS(update_user_theme_exports);
32
+ async function updateTheme(ctx, next) {
33
+ const { themeId } = ctx.action.params.values || {};
34
+ const { currentUser } = ctx.state;
35
+ if (!currentUser) {
36
+ ctx.throw(401);
37
+ }
38
+ const userRepo = ctx.db.getRepository("users");
39
+ const user = await userRepo.findOne({ filter: { id: currentUser.id } });
40
+ await userRepo.update({
41
+ filterByTk: currentUser.id,
42
+ values: {
43
+ systemSettings: {
44
+ ...user.systemSettings,
45
+ themeId
46
+ }
47
+ }
48
+ });
49
+ await next();
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ updateTheme
54
+ });
@@ -7,11 +7,9 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- var __create = Object.create;
11
10
  var __defProp = Object.defineProperty;
12
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
13
  var __hasOwnProp = Object.prototype.hasOwnProperty;
16
14
  var __export = (target, all) => {
17
15
  for (var name in all)
@@ -25,14 +23,6 @@ var __copyProps = (to, from, except, desc) => {
25
23
  }
26
24
  return to;
27
25
  };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
27
  var plugin_exports = {};
38
28
  __export(plugin_exports, {
@@ -41,8 +31,8 @@ __export(plugin_exports, {
41
31
  });
42
32
  module.exports = __toCommonJS(plugin_exports);
43
33
  var import_server = require("@nocobase/server");
44
- var import_path = __toESM(require("path"));
45
34
  var import_builtinThemes = require("./builtinThemes");
35
+ var import_update_user_theme = require("./actions/update-user-theme");
46
36
  class PluginThemeEditorServer extends import_server.Plugin {
47
37
  theme;
48
38
  afterAdd() {
@@ -50,14 +40,8 @@ class PluginThemeEditorServer extends import_server.Plugin {
50
40
  async beforeLoad() {
51
41
  }
52
42
  async load() {
53
- await this.importCollections(import_path.default.resolve(__dirname, "./collections"));
54
- this.db.addMigrations({
55
- namespace: "theme-editor",
56
- directory: (0, import_path.resolve)(__dirname, "./migrations"),
57
- context: {
58
- plugin: this
59
- }
60
- });
43
+ this.app.resourceManager.registerActionHandler("users:updateTheme", import_update_user_theme.updateTheme);
44
+ this.app.acl.allow("users", "updateTheme", "loggedIn");
61
45
  this.app.acl.allow("themeConfig", "list", "public");
62
46
  this.app.acl.registerSnippet({
63
47
  name: `pm.${this.name}.themeConfig`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-theme-editor",
3
- "version": "1.5.0-beta.9",
3
+ "version": "1.5.1",
4
4
  "main": "dist/server/index.js",
5
5
  "homepage": "https://docs.nocobase.com/handbook/theme-editor",
6
6
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/theme-editor",
@@ -32,7 +32,7 @@
32
32
  "@nocobase/test": "1.x",
33
33
  "@nocobase/utils": "1.x"
34
34
  },
35
- "gitHead": "fef0bcb5f95705cd83607f03a6c911550016281b",
35
+ "gitHead": "b16a0ff226482d0de847656ea26fd621b1d685cf",
36
36
  "keywords": [
37
37
  "System management"
38
38
  ]