Comparing version 2.0.2 to 2.0.3
@@ -1,77 +0,14 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLocale = exports.setLocale = exports.formatMessage = void 0; | ||
const react_1 = __importDefault(require("react")); | ||
/** | ||
* 获取链接字符串 | ||
*/ | ||
const getIntlStr = (str, varObj = {}) => { | ||
const commStrs = str.split(/\{[^\{\}]*?\}/); // 将不是变量的部分抽离出来 | ||
const varStrs = []; | ||
str.replace(/\{[^\{\}]*?\}/g, (s) => { | ||
let newS = s.substring(1, s.length - 1); | ||
if (newS) { | ||
if (varObj[newS] == null) { | ||
newS = `{${newS}}`; | ||
} | ||
else { | ||
newS = varObj[newS] || ''; | ||
} | ||
} | ||
varStrs.push(newS); | ||
return ''; | ||
}); | ||
const strs = []; | ||
for (let i = 0; i < commStrs.length; i += 1) { | ||
strs[i * 2] = commStrs[i] || ''; | ||
strs[(i * 2) + 1] = varStrs[i] || ''; | ||
} | ||
return strs; | ||
}; | ||
/** | ||
* 国际化渲染函数 | ||
* @param infoObj | ||
* @param varObj | ||
* @returns | ||
*/ | ||
const formatMessage = (infoObj, varObj) => { | ||
const { id } = infoObj; | ||
const { intl } = window; | ||
if (!intl) { | ||
console.error('本地词汇库为空,请检查!'); | ||
return id; | ||
} | ||
if (!intl[id]) { | ||
console.error(`词汇${id}不存在,请检查!`); | ||
return id; | ||
} | ||
const value = intl ? intl[id] : id; | ||
const strs = getIntlStr(value, varObj); | ||
if (Object.values(varObj || {}).find(item => typeof item === 'object')) { // 对象的属性值为对象时就认为是react对象 | ||
return react_1.default.createElement(react_1.default.Fragment, null, strs); | ||
} | ||
return strs.join(''); | ||
}; | ||
exports.formatMessage = formatMessage; | ||
/** | ||
* 修改语言类型 | ||
* @param lan | ||
*/ | ||
const setLocale = (lan) => { | ||
if (!lan) { | ||
return; | ||
} | ||
window.localStorage.setItem('umi_locale', lan); | ||
window.location.reload(); | ||
}; | ||
exports.setLocale = setLocale; | ||
/** | ||
* 获取语言类型 | ||
*/ | ||
const getLocale = () => { | ||
return window.localStorage.getItem('umi_locale') || 'zh-CN'; | ||
}; | ||
exports.getLocale = getLocale; | ||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=59)}({59:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getLocale=t.setLocale=t.formatMessage=void 0;const o=n(r(60));t.formatMessage=(e,t)=>{const{id:r}=e,{intl:n}=window;if(!n)return console.error("本地词汇库为空,请检查!"),r;if(!n[r])return console.error(`词汇${r}不存在,请检查!`),r;const u=((e,t={})=>{const r=e.split(/\{[^\{\}]*?\}/),n=[];e.replace(/\{[^\{\}]*?\}/g,e=>{let r=e.substring(1,e.length-1);return r&&(r=null==t[r]?`{${r}}`:t[r]||""),n.push(r),""});const o=[];for(let e=0;e<r.length;e+=1)o[2*e]=r[e]||"",o[2*e+1]=n[e]||"";return o})(n?n[r]:r,t);return Object.values(t||{}).find(e=>"object"==typeof e)?o.default.createElement(o.default.Fragment,null,u):u.join("")};t.setLocale=e=>{e&&(window.localStorage.setItem("umi_locale",e),window.location.reload())};t.getLocale=()=>window.localStorage.getItem("umi_locale")||"zh-CN"},60:function(e,t,r){"use strict";e.exports=r(61)},61:function(e,t,r){"use strict"; | ||
/** @license React v17.0.2 | ||
* react.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/var n=r(62),o=60103,u=60106;t.Fragment=60107,t.StrictMode=60108,t.Profiler=60114;var i=60109,c=60110,a=60112;t.Suspense=60113;var f=60115,l=60116;if("function"==typeof Symbol&&Symbol.for){var s=Symbol.for;o=s("react.element"),u=s("react.portal"),t.Fragment=s("react.fragment"),t.StrictMode=s("react.strict_mode"),t.Profiler=s("react.profiler"),i=s("react.provider"),c=s("react.context"),a=s("react.forward_ref"),t.Suspense=s("react.suspense"),f=s("react.memo"),l=s("react.lazy")}var p="function"==typeof Symbol&&Symbol.iterator;function y(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var d={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v={};function h(e,t,r){this.props=e,this.context=t,this.refs=v,this.updater=r||d}function m(){}function _(e,t,r){this.props=e,this.context=t,this.refs=v,this.updater=r||d}h.prototype.isReactComponent={},h.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error(y(85));this.updater.enqueueSetState(this,e,t,"setState")},h.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},m.prototype=h.prototype;var b=_.prototype=new m;b.constructor=_,n(b,h.prototype),b.isPureReactComponent=!0;var g={current:null},j=Object.prototype.hasOwnProperty,w={key:!0,ref:!0,__self:!0,__source:!0};function O(e,t,r){var n,u={},i=null,c=null;if(null!=t)for(n in void 0!==t.ref&&(c=t.ref),void 0!==t.key&&(i=""+t.key),t)j.call(t,n)&&!w.hasOwnProperty(n)&&(u[n]=t[n]);var a=arguments.length-2;if(1===a)u.children=r;else if(1<a){for(var f=Array(a),l=0;l<a;l++)f[l]=arguments[l+2];u.children=f}if(e&&e.defaultProps)for(n in a=e.defaultProps)void 0===u[n]&&(u[n]=a[n]);return{$$typeof:o,type:e,key:i,ref:c,props:u,_owner:g.current}}function S(e){return"object"==typeof e&&null!==e&&e.$$typeof===o}var $=/\/+/g;function k(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function C(e,t,r,n,i){var c=typeof e;"undefined"!==c&&"boolean"!==c||(e=null);var a=!1;if(null===e)a=!0;else switch(c){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case o:case u:a=!0}}if(a)return i=i(a=e),e=""===n?"."+k(a,0):n,Array.isArray(i)?(r="",null!=e&&(r=e.replace($,"$&/")+"/"),C(i,t,r,"",(function(e){return e}))):null!=i&&(S(i)&&(i=function(e,t){return{$$typeof:o,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(i,r+(!i.key||a&&a.key===i.key?"":(""+i.key).replace($,"$&/")+"/")+e)),t.push(i)),1;if(a=0,n=""===n?".":n+":",Array.isArray(e))for(var f=0;f<e.length;f++){var l=n+k(c=e[f],f);a+=C(c,t,r,l,i)}else if("function"==typeof(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(e)))for(e=l.call(e),f=0;!(c=e.next()).done;)a+=C(c=c.value,t,r,l=n+k(c,f++),i);else if("object"===c)throw t=""+e,Error(y(31,"[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t));return a}function E(e,t,r){if(null==e)return e;var n=[],o=0;return C(e,n,"","",(function(e){return t.call(r,e,o++)})),n}function P(e){if(-1===e._status){var t=e._result;t=t(),e._status=0,e._result=t,t.then((function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)}),(function(t){0===e._status&&(e._status=2,e._result=t)}))}if(1===e._status)return e._result;throw e._result}var R={current:null};function x(){var e=R.current;if(null===e)throw Error(y(321));return e}var M={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:g,IsSomeRendererActing:{current:!1},assign:n};t.Children={map:E,forEach:function(e,t,r){E(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return E(e,(function(){t++})),t},toArray:function(e){return E(e,(function(e){return e}))||[]},only:function(e){if(!S(e))throw Error(y(143));return e}},t.Component=h,t.PureComponent=_,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=M,t.cloneElement=function(e,t,r){if(null==e)throw Error(y(267,e));var u=n({},e.props),i=e.key,c=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(c=t.ref,a=g.current),void 0!==t.key&&(i=""+t.key),e.type&&e.type.defaultProps)var f=e.type.defaultProps;for(l in t)j.call(t,l)&&!w.hasOwnProperty(l)&&(u[l]=void 0===t[l]&&void 0!==f?f[l]:t[l])}var l=arguments.length-2;if(1===l)u.children=r;else if(1<l){f=Array(l);for(var s=0;s<l;s++)f[s]=arguments[s+2];u.children=f}return{$$typeof:o,type:e.type,key:i,ref:c,props:u,_owner:a}},t.createContext=function(e,t){return void 0===t&&(t=null),(e={$$typeof:c,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:i,_context:e},e.Consumer=e},t.createElement=O,t.createFactory=function(e){var t=O.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:a,render:e}},t.isValidElement=S,t.lazy=function(e){return{$$typeof:l,_payload:{_status:-1,_result:e},_init:P}},t.memo=function(e,t){return{$$typeof:f,type:e,compare:void 0===t?null:t}},t.useCallback=function(e,t){return x().useCallback(e,t)},t.useContext=function(e,t){return x().useContext(e,t)},t.useDebugValue=function(){},t.useEffect=function(e,t){return x().useEffect(e,t)},t.useImperativeHandle=function(e,t,r){return x().useImperativeHandle(e,t,r)},t.useLayoutEffect=function(e,t){return x().useLayoutEffect(e,t)},t.useMemo=function(e,t){return x().useMemo(e,t)},t.useReducer=function(e,t,r){return x().useReducer(e,t,r)},t.useRef=function(e){return x().useRef(e)},t.useState=function(e){return x().useState(e)},t.version="17.0.2"},62:function(e,t,r){"use strict"; | ||
/* | ||
object-assign | ||
(c) Sindre Sorhus | ||
@license MIT | ||
*/var n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;function i(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,c,a=i(e),f=1;f<arguments.length;f++){for(var l in r=Object(arguments[f]))o.call(r,l)&&(a[l]=r[l]);if(n){c=n(r);for(var s=0;s<c.length;s++)u.call(r,c[s])&&(a[c[s]]=r[c[s]])}}return a}}}); |
{ | ||
"name": "tant-intl", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "依托于飞书表格做文案管理的多语言组件", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"start": "tsc -w", | ||
"start2": "npx webpack --mode=development --watch", | ||
"test": "node dist/cli", | ||
"build": "tsc", | ||
"build2": "npx webpack --mode=production" | ||
"start": "tsc --target es5 --outDir lib -watch", | ||
"build": "tsc --target ESNext --outDir es && tsc --target es5 --outDir lib && npx webpack --mode=production", | ||
"build-es": "tsc --target ESNext --outDir es", | ||
"build-lib": "tsc --target es5 --outDir lib", | ||
"build-dist": "npx webpack --mode=production" | ||
}, | ||
@@ -20,11 +20,14 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/cli": "^7.17.6", | ||
"@babel/parser": "^7.17.0", | ||
"@babel/preset-env": "^7.16.11", | ||
"@babel/preset-typescript": "^7.16.7", | ||
"@babel/traverse": "^7.17.0", | ||
"@types/node": "^17.0.21", | ||
"dayjs": "^1.10.7", | ||
"feishu-excel": "^1.0.0", | ||
"request": "^2.88.2", | ||
"feishu-excel": "^1.0.4", | ||
"ts-loader": "^8.3.0", | ||
"typescript": "^4.5.5", | ||
"webpack-cli": "^4.9.2" | ||
"webpack-cli": "^4.9.2", | ||
"babel-core": "^6.26.3" | ||
}, | ||
@@ -36,3 +39,4 @@ "bin": { | ||
"dist", | ||
"src" | ||
"lib", | ||
"es" | ||
], | ||
@@ -39,0 +43,0 @@ "dependencies": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 5 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 6 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
383397
8
924
12
2
16
8