@nocobase/plugin-localization 1.5.0-beta.1 → 1.6.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/517.index.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/server/plugin.d.ts +1 -0
- package/dist/server/plugin.js +28 -6
- package/package.json +2 -2
- package/dist/node_modules/deepmerge/.editorconfig +0 -7
- package/dist/node_modules/deepmerge/.eslintcache +0 -1
- package/dist/node_modules/deepmerge/dist/cjs.js +0 -1
- package/dist/node_modules/deepmerge/dist/umd.js +0 -139
- package/dist/node_modules/deepmerge/index.d.ts +0 -20
- package/dist/node_modules/deepmerge/index.js +0 -106
- package/dist/node_modules/deepmerge/license.txt +0 -21
- package/dist/node_modules/deepmerge/package.json +0 -1
- package/dist/node_modules/deepmerge/rollup.config.js +0 -22
|
@@ -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
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_localization=self.webpackChunk_nocobase_plugin_localization||[]).push([["517"],{668:function(e,t,n){n.r(t),n.d(t,{Localization:function(){return P}});var o=n("482"),r=n("563"),l=n("505"),a=n("772"),i=n("749"),c=n("721"),u=n("156"),s=n.n(u),p=n("573"),d={name:"localization",fields:[{interface:"input",type:"string",name:"text",uiSchema:{type:"string",title:'{{t("Text")}}',"x-component":"Input.TextArea",required:!0}},{interface:"input",type:"string",name:"translation",uiSchema:{type:"string",title:'{{t("Translation")}}',"x-component":"Input.TextArea"}},{interface:"select",type:"string",name:"moduleTitle",uiSchema:{type:"string",title:'{{t("Module")}}',"x-component":"Select",enum:[{value:"Menu",label:'{{t("Menu")}}'},{value:"Collections & Fields",label:'{{t("Collections & Fields", {ns:"localization"})}}'}]}}]},m={type:"void",name:"localization","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:d,resourceName:"localizationTexts",request:{resource:"localizationTexts",action:"list",params:{pageSize:50}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:d},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{currentLang:{type:"void","x-align":"left","x-component":"CurrentLang"},filter:{type:"void",title:'{{t("Filter")}}',"x-align":"left","x-component":"Filter"},deleteTranslation:{type:"void",title:'{{t("Delete translation")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ useBulkDestroyTranslationAction }}",confirm:{title:"{{t('Delete translation')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},sync:{type:"void",title:'{{t("Sync")}}',"x-component":"Sync"},publish:{type:"void",title:'{{t("Publish")}}',"x-component":"Action","x-component-props":{icon:"UploadOutlined",type:"primary",useAction:"{{ usePublishAction }}"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"translationId",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{text:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{text:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},translation:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{translation:{type:"string","x-component":"CollectionField","x-component-props":{component:"TranslationField"},"x-read-pretty":!0}}},moduleTitle:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{moduleTitle:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Edit")}}',properties:{moduleTitle:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},text:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},translation:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateTranslationAction }}"}}}}}}}},deleteTranslation:{type:"void",title:'{{ t("Delete translation") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete translation')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{useDestroyTranslationAction}}"},"x-visible":"{{useHasTranslation()}}"}}}}}}}}};function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function f(e,t,n,o,r,l,a){try{var i=e[l](a),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(o,r)}function x(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var l=e.apply(t,n);function a(e){f(l,o,r,a,i,"next",e)}function i(e){f(l,o,r,a,i,"throw",e)}a(void 0)})}}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o,r,l;o=e,r=t,l=n[t],r in o?Object.defineProperty(o,r,{value:l,enumerable:!0,configurable:!0,writable:!0}):o[r]=l})}return e}function v(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 o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var l=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,o=e}finally{try{!a&&null!=r.return&&r.return()}finally{if(i)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return y(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 y(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 g(e,t){var n,o,r,l,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){return function(l){if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&l[0]?o.return:l[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,l[1])).done)return r;switch(o=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,o=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===l[0]||2===l[0])){a=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){a.label=l[1];break}if(6===l[0]&&a.label<r[1]){a.label=r[1],r=l;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(l);break}r[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],o=0}finally{n=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,i])}}}var C=c.Typography.Text,A=function(){var e=(0,l.useField)(),t=(0,l.useForm)(),n=(0,a.useActionContext)(),o=(0,a.useResourceActionContext)().refresh,r=(0,a.useResourceContext)().targetKey,i=(0,a.useRecord)()[r],c=(0,a.useAPIClient)(),u=c.auth.getLocale();return{run:function(){return x(function(){return g(this,function(r){switch(r.label){case 0:return[4,t.submit()];case 1:r.sent(),e.data=e.data||{},e.data.loading=!0,r.label=2;case 2:return r.trys.push([2,5,6,7]),[4,c.resource("localizationTranslations").updateOrCreate({filterKeys:["textId","locale"],values:{textId:i,locale:u,translation:t.values.translation}})];case 3:return r.sent(),n.setVisible(!1),[4,t.reset()];case 4:return r.sent(),o(),[3,7];case 5:return console.log(r.sent()),[3,7];case 6:return e.data.loading=!1,[7];case 7:return[2]}})})()}}},w=function(){var e=(0,a.useResourceActionContext)().refresh,t=(0,a.useAPIClient)(),n=(0,a.useRecord)().translationId;return{run:function(){return x(function(){return g(this,function(o){switch(o.label){case 0:return[4,t.resource("localizationTranslations").destroy({filterByTk:n})];case 1:return o.sent(),e(),[2]}})})()}}},T=function(){var e=(0,a.useResourceActionContext)(),t=e.state,n=e.setState,o=e.refresh,r=(0,a.useAPIClient)(),l=(0,p.F)().t;return{run:function(){return x(function(){var e;return g(this,function(a){switch(a.label){case 0:if(!(null==t?void 0:null===(e=t.selectedRowKeys)||void 0===e?void 0:e.length))return[2,c.message.error(l("Please select the records you want to delete"))];return[4,r.resource("localizationTranslations").destroy({filterByTk:null==t?void 0:t.selectedRowKeys})];case 1:return a.sent(),null==n||n({selectedRowKeys:[]}),o(),[2]}})})()}}},S=function(){var e=(0,a.useAPIClient)();return{run:function(){return x(function(){return g(this,function(t){switch(t.label){case 0:return[4,e.resource("localization").publish()];case 1:return t.sent(),window.location.reload(),[2]}})})()}}},F=function(){var e=(0,p.F)().t,t=(0,a.useResourceActionContext)().refresh,n=(0,a.useAPIClient)(),r=h((0,u.useState)(!1),2),l=r[0],i=r[1],d=["local","menu","db"],m=h((0,u.useState)(d),2),y=m[0],f=m[1],b=h((0,u.useState)(!1),2),v=b[0],C=b[1],A=h((0,u.useState)(!0),2),w=A[0],T=A[1];return s().createElement(a.StablePopover,{placement:"bottomRight",content:s().createElement(s().Fragment,null,s().createElement(c.Checkbox,{indeterminate:v,onChange:function(e){f(e.target.checked?d:[]),C(!1),T(e.target.checked)},checked:w},e("All")),s().createElement(c.Divider,{style:{margin:"5px 0"}}),s().createElement(c.Checkbox.Group,{onChange:function(e){f(e),C(!!e.length&&e.length<d.length),T(e.length===d.length)},value:y},s().createElement(c.Col,null,s().createElement(c.Row,null,s().createElement(c.Checkbox,{value:"local"},e("System & Plugins"))),s().createElement(c.Row,null,s().createElement(c.Checkbox,{value:"db"},e("Collections & Fields"))),s().createElement(c.Row,null,s().createElement(c.Checkbox,{value:"menu"},e("Menu"))))))},s().createElement(c.Button,{icon:s().createElement(o.SyncOutlined,null),loading:l,onClick:x(function(){return g(this,function(o){switch(o.label){case 0:if(!y.length)return[2,c.message.error(e("Please select the resources you want to synchronize"))];return i(!0),[4,n.resource("localization").sync({values:{types:y}})];case 1:return o.sent(),i(!1),t(),[2]}})})},e("Sync")))},E=function(){var e,t=(0,p.F)().t,n=(0,i.useMemoizedFn)(t),o=(0,a.useResourceActionContext)().data;return(0,u.useMemo)(function(){var e,t;return(null==o?void 0:null===(t=o.meta)||void 0===t?void 0:null===(e=t.modules)||void 0===e?void 0:e.map(function(e){return{value:e.value,label:n(e.label)}}))||[]},[null==o?void 0:null===(e=o.meta)||void 0===e?void 0:e.modules,n])},k=function(){var e=(0,p.F)().t,t=(0,a.useResourceActionContext)().run,n=E(),o=(0,u.useMemo)(function(){return(0,r.createForm)({initialValues:{hasTranslation:!0}})},[]),i=function(e){t(b({},e||o.values))};return(0,u.useEffect)(function(){o.query("module").take().dataSource=n},[o,n]),s().createElement(a.FormProvider,{form:o},s().createElement("div",{style:{display:"flex"}},s().createElement(l.Field,{name:"module",dataSource:n,component:[a.Select,{allowClear:!0,placeholder:e("Module"),onChange:function(e){return i(v(b({},o.values),{module:e}))}}]}),s().createElement(l.Field,{name:"keyword",component:[c.Input.Search,{placeholder:e("Keyword"),allowClear:!0,style:{marginLeft:"8px",width:"fit-content"},onSearch:function(e){return i(v(b({},o.values),{keyword:e}))}}]}),s().createElement(l.Field,{name:"hasTranslation",dataSource:[{label:e("All"),value:!0},{label:e("No translation"),value:!1}],component:[a.Radio.Group,{defaultValue:!0,style:{marginLeft:"8px",width:"fit-content"},optionType:"button",onChange:function(){return i()}}]})))},P=function(){var e,t=(0,p.F)().t,n=(0,a.useAPIClient)().auth.getLocale(),o=(null===(e=a.locale[n])||void 0===e?void 0:e.label)||n;return s().createElement(c.Card,{bordered:!1},s().createElement(a.SchemaComponent,{schema:m,components:{TranslationField:function(e){return void 0!==e.value?s().createElement(a.Input.TextArea,e):s().createElement("div",null)},CurrentLang:function(){return s().createElement(c.Typography,null,s().createElement(C,{strong:!0},t("Current language")),s().createElement(c.Tag,{style:{marginLeft:"10px"}},o))},Sync:F,Filter:k},scope:{t:t,useDestroyTranslationAction:w,useBulkDestroyTranslationAction:T,useUpdateTranslationAction:A,usePublishAction:S,useModules:E}}))}}}]);
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@formily/core"),require("@nocobase/client"),require("ahooks"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-localization",["react-i18next","@formily/core","@nocobase/client","ahooks","antd","@ant-design/icons","@formily/react","react"],t):"object"==typeof exports?exports["@nocobase/plugin-localization"]=t(require("react-i18next"),require("@formily/core"),require("@nocobase/client"),require("ahooks"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("react")):e["@nocobase/plugin-localization"]=t(e["react-i18next"],e["@formily/core"],e["@nocobase/client"],e.ahooks,e.antd,e["@ant-design/icons"],e["@formily/react"],e.react)}(self,function(e,t,n,r,o,i,u,c){return function(){var a,l,f,s,p,d={573:function(e,t,n){"use strict";n.d(t,{A:function(){return o},F:function(){return i}});var r=n(238),o="localization",i=function(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=i},563:function(e){"use strict";e.exports=t},505:function(e){"use strict";e.exports=u},772:function(e){"use strict";e.exports=n},749:function(e){"use strict";e.exports=r},721:function(e){"use strict";e.exports=o},156:function(e){"use strict";e.exports=c},238:function(t){"use strict";t.exports=e}},b={};function y(e){var t=b[e];if(void 0!==t)return t.exports;var n=b[e]={exports:{}};return d[e](n,n.exports,y),n.exports}y.m=d,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return""+e+".index.js"},y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a={},l="@nocobase/plugin-localization:",y.l=function(e,t,n,r){if(a[e]){a[e].push(t);return}if(void 0!==n){for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var f=u[c];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==l+n){o=f;break}}}!o&&(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-webpack",l+n),o.src=e),a[e]=[t];var s=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=a[e];if(delete a[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(s.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=s.bind(null,o.onerror),o.onload=s.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.p="/static/plugins/@nocobase/plugin-localization/dist/client/",f={909:0},y.f.j=function(e,t){var n=y.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=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.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)}}},s=function(e,t){var n=t[0],r=t[1],o=t[2],i,u,c=0;if(n.some(function(e){return 0!==f[e]})){for(i in r)y.o(r,i)&&(y.m[i]=r[i]);o&&o(y)}for(e&&e(t);c<n.length;c++)u=n[c],y.o(f,u)&&f[u]&&f[u][0](),f[u]=0},(p=self.webpackChunk_nocobase_plugin_localization=self.webpackChunk_nocobase_plugin_localization||[]).forEach(s.bind(null,0)),p.push=s.bind(null,p.push.bind(p));var h={};return!function(){"use strict";y.r(h),y.d(h,{PluginLocalizationClient:function(){return s}});var e=y(772),t=y(573),n=y(581);function r(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function o(e,t,n){return(o=l()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function i(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 u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e){var t="function"==typeof Map?new Map:void 0;return(a=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 o(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),c(r,e)})(e)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}var f=(0,e.lazy)(function(){return n("imported_-237jod_component",y.e("517").then(y.bind(y,668)))},"Localization").Localization,s=function(e){var n,o,a;function s(){var e,t,n;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,s),e=this,t=s,n=arguments,t=u(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,l()?Reflect.construct(t,n||[],u(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&&c(e,t)}(s,e),n=s,o=[{key:"load",value:function(){var e,n=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}}(this,function(e){return n.app.pluginSettingsManager.add(t.A,{title:'{{t("Localization", { ns: "'.concat(t.A,'" })}}'),icon:"GlobalOutlined",Component:f,aclSnippet:"pm.localization.localization"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,i){var u=e.apply(t,n);function c(e){r(u,o,i,c,a,"next",e)}function a(e){r(u,o,i,c,a,"throw",e)}c(void 0)})})()}}],i(n.prototype,o),s}(a(e.Plugin));h.default=s}(),h}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -11,14 +11,14 @@ module.exports = {
|
|
|
11
11
|
"@ant-design/icons": "5.2.6",
|
|
12
12
|
"@formily/core": "2.3.0",
|
|
13
13
|
"@formily/react": "2.3.0",
|
|
14
|
-
"@nocobase/client": "1.
|
|
14
|
+
"@nocobase/client": "1.6.0-alpha.2",
|
|
15
15
|
"ahooks": "3.7.8",
|
|
16
16
|
"antd": "5.12.8",
|
|
17
17
|
"react": "18.2.0",
|
|
18
|
-
"@nocobase/database": "1.
|
|
19
|
-
"@nocobase/plugin-ui-schema-storage": "1.
|
|
20
|
-
"@nocobase/server": "1.
|
|
21
|
-
"@nocobase/cache": "1.
|
|
18
|
+
"@nocobase/database": "1.6.0-alpha.2",
|
|
19
|
+
"@nocobase/plugin-ui-schema-storage": "1.6.0-alpha.2",
|
|
20
|
+
"@nocobase/server": "1.6.0-alpha.2",
|
|
21
|
+
"@nocobase/cache": "1.6.0-alpha.2",
|
|
22
22
|
"react-i18next": "11.18.6",
|
|
23
|
-
"@nocobase/actions": "1.
|
|
23
|
+
"@nocobase/actions": "1.6.0-alpha.2"
|
|
24
24
|
};
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare class PluginLocalizationServer extends Plugin {
|
|
|
15
15
|
afterAdd(): void;
|
|
16
16
|
beforeLoad(): void;
|
|
17
17
|
load(): Promise<void>;
|
|
18
|
+
handleSyncMessage(message: any): Promise<void>;
|
|
18
19
|
install(options?: InstallOptions): Promise<void>;
|
|
19
20
|
afterEnable(): Promise<void>;
|
|
20
21
|
afterDisable(): Promise<void>;
|
package/dist/server/plugin.js
CHANGED
|
@@ -41,7 +41,6 @@ __export(plugin_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(plugin_exports);
|
|
43
43
|
var import_server = require("@nocobase/server");
|
|
44
|
-
var import_path = require("path");
|
|
45
44
|
var import_localization = __toESM(require("./actions/localization"));
|
|
46
45
|
var import_localizationTexts = __toESM(require("./actions/localizationTexts"));
|
|
47
46
|
var import_resources = __toESM(require("./resources"));
|
|
@@ -71,7 +70,14 @@ class PluginLocalizationServer extends import_server.Plugin {
|
|
|
71
70
|
module: module2,
|
|
72
71
|
text: title
|
|
73
72
|
}
|
|
74
|
-
}).then((res) =>
|
|
73
|
+
}).then((res) => {
|
|
74
|
+
this.resources.updateCacheTexts([res]);
|
|
75
|
+
this.sendSyncMessage({
|
|
76
|
+
type: "updateCacheTexts",
|
|
77
|
+
texts: [res]
|
|
78
|
+
});
|
|
79
|
+
}).catch((err) => {
|
|
80
|
+
this.log.error(err);
|
|
75
81
|
});
|
|
76
82
|
});
|
|
77
83
|
}
|
|
@@ -80,12 +86,11 @@ class PluginLocalizationServer extends import_server.Plugin {
|
|
|
80
86
|
beforeLoad() {
|
|
81
87
|
}
|
|
82
88
|
async load() {
|
|
83
|
-
|
|
84
|
-
this.app.resource({
|
|
89
|
+
this.app.resourceManager.define({
|
|
85
90
|
name: "localizationTexts",
|
|
86
91
|
actions: import_localizationTexts.default
|
|
87
92
|
});
|
|
88
|
-
this.app.
|
|
93
|
+
this.app.resourceManager.define({
|
|
89
94
|
name: "localization",
|
|
90
95
|
actions: import_localization.default
|
|
91
96
|
});
|
|
@@ -121,7 +126,17 @@ class PluginLocalizationServer extends import_server.Plugin {
|
|
|
121
126
|
{
|
|
122
127
|
transaction: options == null ? void 0 : options.transaction
|
|
123
128
|
}
|
|
124
|
-
).then((newTexts) =>
|
|
129
|
+
).then((newTexts) => {
|
|
130
|
+
this.resources.updateCacheTexts(newTexts, options == null ? void 0 : options.transaction);
|
|
131
|
+
this.sendSyncMessage(
|
|
132
|
+
{
|
|
133
|
+
type: "updateCacheTexts",
|
|
134
|
+
texts: newTexts
|
|
135
|
+
},
|
|
136
|
+
{ transaction: options == null ? void 0 : options.transaction }
|
|
137
|
+
);
|
|
138
|
+
}).catch((err) => {
|
|
139
|
+
this.log.error(err);
|
|
125
140
|
});
|
|
126
141
|
});
|
|
127
142
|
const cache = await this.app.cacheManager.createCache({
|
|
@@ -136,6 +151,13 @@ class PluginLocalizationServer extends import_server.Plugin {
|
|
|
136
151
|
reset: () => this.resources.reset()
|
|
137
152
|
});
|
|
138
153
|
}
|
|
154
|
+
async handleSyncMessage(message) {
|
|
155
|
+
switch (message.type) {
|
|
156
|
+
case "updateCacheTexts":
|
|
157
|
+
await this.resources.updateCacheTexts(message.texts);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
139
161
|
async install(options) {
|
|
140
162
|
}
|
|
141
163
|
async afterEnable() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-localization",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-alpha.2",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"homepage": "https://docs.nocobase.com/handbook/localization-management",
|
|
6
6
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/localization-management",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"displayName.zh-CN": "本地化",
|
|
25
25
|
"description": "Allows to manage localization resources of the application.",
|
|
26
26
|
"description.zh-CN": "支持管理应用程序的本地化资源。",
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "08bbc34c21727fc0ad0880f397a42bf7741091ee"
|
|
28
28
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"/Users/joshduff/code/deepmerge/test/custom-is-mergeable-object.js":"1"},{"size":1990,"mtime":1679007485753,"results":"2","hashOfConfig":"3"},{"filePath":"4","messages":"5","suppressedMessages":"6","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"ktjd5k","/Users/joshduff/code/deepmerge/test/custom-is-mergeable-object.js",[],[]]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";var e={323:function(e){var r=function isMergeableObject(e){return isNonNullObject(e)&&!isSpecial(e)};function isNonNullObject(e){return!!e&&typeof e==="object"}function isSpecial(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||isReactElement(e)}var t=typeof Symbol==="function"&&Symbol.for;var n=t?Symbol.for("react.element"):60103;function isReactElement(e){return e.$$typeof===n}function emptyTarget(e){return Array.isArray(e)?[]:{}}function cloneUnlessOtherwiseSpecified(e,r){return r.clone!==false&&r.isMergeableObject(e)?deepmerge(emptyTarget(e),e,r):e}function defaultArrayMerge(e,r,t){return e.concat(r).map((function(e){return cloneUnlessOtherwiseSpecified(e,t)}))}function getMergeFunction(e,r){if(!r.customMerge){return deepmerge}var t=r.customMerge(e);return typeof t==="function"?t:deepmerge}function getEnumerableOwnPropertySymbols(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(r){return Object.propertyIsEnumerable.call(e,r)})):[]}function getKeys(e){return Object.keys(e).concat(getEnumerableOwnPropertySymbols(e))}function propertyIsOnObject(e,r){try{return r in e}catch(e){return false}}function propertyIsUnsafe(e,r){return propertyIsOnObject(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function mergeObject(e,r,t){var n={};if(t.isMergeableObject(e)){getKeys(e).forEach((function(r){n[r]=cloneUnlessOtherwiseSpecified(e[r],t)}))}getKeys(r).forEach((function(c){if(propertyIsUnsafe(e,c)){return}if(propertyIsOnObject(e,c)&&t.isMergeableObject(r[c])){n[c]=getMergeFunction(c,t)(e[c],r[c],t)}else{n[c]=cloneUnlessOtherwiseSpecified(r[c],t)}}));return n}function deepmerge(e,t,n){n=n||{};n.arrayMerge=n.arrayMerge||defaultArrayMerge;n.isMergeableObject=n.isMergeableObject||r;n.cloneUnlessOtherwiseSpecified=cloneUnlessOtherwiseSpecified;var c=Array.isArray(t);var i=Array.isArray(e);var o=c===i;if(!o){return cloneUnlessOtherwiseSpecified(t,n)}else if(c){return n.arrayMerge(e,t,n)}else{return mergeObject(e,t,n)}}deepmerge.all=function deepmergeAll(e,r){if(!Array.isArray(e)){throw new Error("first argument should be an array")}return e.reduce((function(e,t){return deepmerge(e,t,r)}),{})};var c=deepmerge;e.exports=c}};var r={};function __nccwpck_require__(t){var n=r[t];if(n!==undefined){return n.exports}var c=r[t]={exports:{}};var i=true;try{e[t](c,c.exports,__nccwpck_require__);i=false}finally{if(i)delete r[t]}return c.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(323);module.exports=t})();
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
-
(global = global || self, global.deepmerge = factory());
|
|
5
|
-
}(this, function () { 'use strict';
|
|
6
|
-
|
|
7
|
-
var isMergeableObject = function isMergeableObject(value) {
|
|
8
|
-
return isNonNullObject(value)
|
|
9
|
-
&& !isSpecial(value)
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function isNonNullObject(value) {
|
|
13
|
-
return !!value && typeof value === 'object'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function isSpecial(value) {
|
|
17
|
-
var stringValue = Object.prototype.toString.call(value);
|
|
18
|
-
|
|
19
|
-
return stringValue === '[object RegExp]'
|
|
20
|
-
|| stringValue === '[object Date]'
|
|
21
|
-
|| isReactElement(value)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
25
|
-
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
26
|
-
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
27
|
-
|
|
28
|
-
function isReactElement(value) {
|
|
29
|
-
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function emptyTarget(val) {
|
|
33
|
-
return Array.isArray(val) ? [] : {}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
37
|
-
return (options.clone !== false && options.isMergeableObject(value))
|
|
38
|
-
? deepmerge(emptyTarget(value), value, options)
|
|
39
|
-
: value
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function defaultArrayMerge(target, source, options) {
|
|
43
|
-
return target.concat(source).map(function(element) {
|
|
44
|
-
return cloneUnlessOtherwiseSpecified(element, options)
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getMergeFunction(key, options) {
|
|
49
|
-
if (!options.customMerge) {
|
|
50
|
-
return deepmerge
|
|
51
|
-
}
|
|
52
|
-
var customMerge = options.customMerge(key);
|
|
53
|
-
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function getEnumerableOwnPropertySymbols(target) {
|
|
57
|
-
return Object.getOwnPropertySymbols
|
|
58
|
-
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
59
|
-
return Object.propertyIsEnumerable.call(target, symbol)
|
|
60
|
-
})
|
|
61
|
-
: []
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function getKeys(target) {
|
|
65
|
-
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function propertyIsOnObject(object, property) {
|
|
69
|
-
try {
|
|
70
|
-
return property in object
|
|
71
|
-
} catch(_) {
|
|
72
|
-
return false
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
77
|
-
function propertyIsUnsafe(target, key) {
|
|
78
|
-
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
79
|
-
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
80
|
-
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function mergeObject(target, source, options) {
|
|
84
|
-
var destination = {};
|
|
85
|
-
if (options.isMergeableObject(target)) {
|
|
86
|
-
getKeys(target).forEach(function(key) {
|
|
87
|
-
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
getKeys(source).forEach(function(key) {
|
|
91
|
-
if (propertyIsUnsafe(target, key)) {
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
96
|
-
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
97
|
-
} else {
|
|
98
|
-
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return destination
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function deepmerge(target, source, options) {
|
|
105
|
-
options = options || {};
|
|
106
|
-
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
107
|
-
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
108
|
-
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
109
|
-
// implementations can use it. The caller may not replace it.
|
|
110
|
-
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
111
|
-
|
|
112
|
-
var sourceIsArray = Array.isArray(source);
|
|
113
|
-
var targetIsArray = Array.isArray(target);
|
|
114
|
-
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
115
|
-
|
|
116
|
-
if (!sourceAndTargetTypesMatch) {
|
|
117
|
-
return cloneUnlessOtherwiseSpecified(source, options)
|
|
118
|
-
} else if (sourceIsArray) {
|
|
119
|
-
return options.arrayMerge(target, source, options)
|
|
120
|
-
} else {
|
|
121
|
-
return mergeObject(target, source, options)
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
deepmerge.all = function deepmergeAll(array, options) {
|
|
126
|
-
if (!Array.isArray(array)) {
|
|
127
|
-
throw new Error('first argument should be an array')
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return array.reduce(function(prev, next) {
|
|
131
|
-
return deepmerge(prev, next, options)
|
|
132
|
-
}, {})
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
var deepmerge_1 = deepmerge;
|
|
136
|
-
|
|
137
|
-
return deepmerge_1;
|
|
138
|
-
|
|
139
|
-
}));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
declare function deepmerge<T>(x: Partial<T>, y: Partial<T>, options?: deepmerge.Options): T;
|
|
2
|
-
declare function deepmerge<T1, T2>(x: Partial<T1>, y: Partial<T2>, options?: deepmerge.Options): T1 & T2;
|
|
3
|
-
|
|
4
|
-
declare namespace deepmerge {
|
|
5
|
-
export interface Options {
|
|
6
|
-
arrayMerge?(target: any[], source: any[], options?: ArrayMergeOptions): any[];
|
|
7
|
-
clone?: boolean;
|
|
8
|
-
customMerge?: (key: string, options?: Options) => ((x: any, y: any) => any) | undefined;
|
|
9
|
-
isMergeableObject?(value: object): boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface ArrayMergeOptions {
|
|
12
|
-
isMergeableObject(value: object): boolean;
|
|
13
|
-
cloneUnlessOtherwiseSpecified(value: object, options?: Options): object;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function all (objects: object[], options?: Options): object;
|
|
17
|
-
export function all<T> (objects: Partial<T>[], options?: Options): T;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export = deepmerge;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
var defaultIsMergeableObject = require('is-mergeable-object')
|
|
2
|
-
|
|
3
|
-
function emptyTarget(val) {
|
|
4
|
-
return Array.isArray(val) ? [] : {}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
8
|
-
return (options.clone !== false && options.isMergeableObject(value))
|
|
9
|
-
? deepmerge(emptyTarget(value), value, options)
|
|
10
|
-
: value
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function defaultArrayMerge(target, source, options) {
|
|
14
|
-
return target.concat(source).map(function(element) {
|
|
15
|
-
return cloneUnlessOtherwiseSpecified(element, options)
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getMergeFunction(key, options) {
|
|
20
|
-
if (!options.customMerge) {
|
|
21
|
-
return deepmerge
|
|
22
|
-
}
|
|
23
|
-
var customMerge = options.customMerge(key)
|
|
24
|
-
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function getEnumerableOwnPropertySymbols(target) {
|
|
28
|
-
return Object.getOwnPropertySymbols
|
|
29
|
-
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
30
|
-
return Object.propertyIsEnumerable.call(target, symbol)
|
|
31
|
-
})
|
|
32
|
-
: []
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getKeys(target) {
|
|
36
|
-
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function propertyIsOnObject(object, property) {
|
|
40
|
-
try {
|
|
41
|
-
return property in object
|
|
42
|
-
} catch(_) {
|
|
43
|
-
return false
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
48
|
-
function propertyIsUnsafe(target, key) {
|
|
49
|
-
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
50
|
-
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
51
|
-
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function mergeObject(target, source, options) {
|
|
55
|
-
var destination = {}
|
|
56
|
-
if (options.isMergeableObject(target)) {
|
|
57
|
-
getKeys(target).forEach(function(key) {
|
|
58
|
-
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options)
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
getKeys(source).forEach(function(key) {
|
|
62
|
-
if (propertyIsUnsafe(target, key)) {
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
67
|
-
destination[key] = getMergeFunction(key, options)(target[key], source[key], options)
|
|
68
|
-
} else {
|
|
69
|
-
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options)
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
return destination
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function deepmerge(target, source, options) {
|
|
76
|
-
options = options || {}
|
|
77
|
-
options.arrayMerge = options.arrayMerge || defaultArrayMerge
|
|
78
|
-
options.isMergeableObject = options.isMergeableObject || defaultIsMergeableObject
|
|
79
|
-
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
80
|
-
// implementations can use it. The caller may not replace it.
|
|
81
|
-
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified
|
|
82
|
-
|
|
83
|
-
var sourceIsArray = Array.isArray(source)
|
|
84
|
-
var targetIsArray = Array.isArray(target)
|
|
85
|
-
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray
|
|
86
|
-
|
|
87
|
-
if (!sourceAndTargetTypesMatch) {
|
|
88
|
-
return cloneUnlessOtherwiseSpecified(source, options)
|
|
89
|
-
} else if (sourceIsArray) {
|
|
90
|
-
return options.arrayMerge(target, source, options)
|
|
91
|
-
} else {
|
|
92
|
-
return mergeObject(target, source, options)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
deepmerge.all = function deepmergeAll(array, options) {
|
|
97
|
-
if (!Array.isArray(array)) {
|
|
98
|
-
throw new Error('first argument should be an array')
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return array.reduce(function(prev, next) {
|
|
102
|
-
return deepmerge(prev, next, options)
|
|
103
|
-
}, {})
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
module.exports = deepmerge
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"deepmerge","description":"A library for deep (recursive) merging of Javascript objects","keywords":["merge","deep","extend","copy","clone","recursive"],"version":"4.3.1","homepage":"https://github.com/TehShrike/deepmerge","repository":{"type":"git","url":"git://github.com/TehShrike/deepmerge.git"},"main":"dist/cjs.js","engines":{"node":">=0.10.0"},"scripts":{"build":"rollup -c","test":"npm run build && tape test/*.js && jsmd readme.md && npm run test:typescript","test:typescript":"tsc --noEmit test/typescript.ts && ts-node test/typescript.ts","size":"npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"},"devDependencies":{"@types/node":"^8.10.54","is-mergeable-object":"1.1.0","is-plain-object":"^5.0.0","jsmd":"^1.0.2","rollup":"^1.23.1","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","tape":"^4.11.0","ts-node":"7.0.1","typescript":"=2.2.2","uglify-js":"^3.6.1"},"license":"MIT","_lastModified":"2024-12-03T15:11:40.832Z"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import resolve from 'rollup-plugin-node-resolve'
|
|
2
|
-
import commonjs from 'rollup-plugin-commonjs'
|
|
3
|
-
import pkg from './package.json'
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
input: `index.js`,
|
|
7
|
-
plugins: [
|
|
8
|
-
commonjs(),
|
|
9
|
-
resolve(),
|
|
10
|
-
],
|
|
11
|
-
output: [
|
|
12
|
-
{
|
|
13
|
-
file: pkg.main,
|
|
14
|
-
format: `cjs`
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
name: 'deepmerge',
|
|
18
|
-
file: 'dist/umd.js',
|
|
19
|
-
format: `umd`
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
}
|