@ckbox/i18n 2.3.1 → 2.4.0-dev.0

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/README.md CHANGED
@@ -13,7 +13,7 @@ Using a build served from the CDN is the simplest and fastest way of embedding C
13
13
  To start using CKBox on your website, embed the following `script` element in the HTML code of the page:
14
14
 
15
15
  ```html
16
- <script src="https://cdn.ckbox.io/ckbox/2.3.1/ckbox.js"></script>
16
+ <script src="https://cdn.ckbox.io/ckbox/2.4.0-dev.0/ckbox.js"></script>
17
17
  ```
18
18
 
19
19
  Quick implementation example:
@@ -23,7 +23,7 @@ Quick implementation example:
23
23
  <html>
24
24
  <head>
25
25
  <meta charset="UTF-8" />
26
- <script src="https://cdn.ckbox.io/ckbox/2.3.1/ckbox.js"></script>
26
+ <script src="https://cdn.ckbox.io/ckbox/2.4.0-dev.0/ckbox.js"></script>
27
27
  </head>
28
28
  <body>
29
29
  <div id="ckbox"></div>
@@ -49,7 +49,7 @@ The code snippet below presents the simplest scenario for integration of CKEdito
49
49
  <head>
50
50
  <meta charset="UTF-8" />
51
51
  <script src="https://cdn.ckeditor.com/ckeditor5/39.0.0/classic/ckeditor.js"></script>
52
- <script src="https://cdn.ckbox.io/ckbox/2.3.1/ckbox.js"></script>
52
+ <script src="https://cdn.ckbox.io/ckbox/2.4.0-dev.0/ckbox.js"></script>
53
53
  </head>
54
54
  <body>
55
55
  <div id="editor"></div>
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  */
4
- const _0x3b8c8a=_0x543e;(function(_0x4cd551,_0x567ebd){const _0x3af5f5=_0x543e,_0x12e638=_0x4cd551();while(!![]){try{const _0x2db588=parseInt(_0x3af5f5(0xd5))/0x1+-parseInt(_0x3af5f5(0xd6))/0x2+parseInt(_0x3af5f5(0xe0))/0x3*(parseInt(_0x3af5f5(0xdf))/0x4)+parseInt(_0x3af5f5(0xf4))/0x5+-parseInt(_0x3af5f5(0xf8))/0x6+-parseInt(_0x3af5f5(0xe9))/0x7+-parseInt(_0x3af5f5(0xf6))/0x8*(-parseInt(_0x3af5f5(0xe1))/0x9);if(_0x2db588===_0x567ebd)break;else _0x12e638['push'](_0x12e638['shift']());}catch(_0x2c783f){_0x12e638['push'](_0x12e638['shift']());}}}(_0x52f5,0x8fce7));import*as _0x4158f6 from'react';import{sprintf}from'sprintf-js';class Plural{constructor(_0x474505){const _0xc6daa4=_0x543e;this[_0xc6daa4(0xf1)]=_0x474505;try{this[_0xc6daa4(0xf9)]=new Intl[(_0xc6daa4(0xd4))](_0x474505);}catch(_0x57e473){console[_0xc6daa4(0xd1)](_0xc6daa4(0xe4));}}[_0x3b8c8a(0xeb)](_0x46474e,_0x29a187){const _0x223de9=_0x3b8c8a;if(!this['_rules'])return _0x46474e+_0x223de9(0xe8);const _0x5a31a2=this[_0x223de9(0xf9)][_0x223de9(0xde)](_0x29a187);return _0x46474e+'_'+_0x5a31a2;}}function _0x52f5(){const _0x26fc6c=['useEffect','_one','4422103yShcog','log','getKey','pluralUtils','exec','\x22\x20is\x20not\x20supported.','isSupported','supportedLocalesOf','lang','Fragment','slice','2043325LHGdwX','useContext','5383376hZJjlu','push','3467262tsKeLT','_rules','plural','warn','includes','indexOf','PluralRules','567208rhplJd','305536blptiD','strong','Provider','createContext','tag','filter','text','values','select','9240nYzapG','393RuqGIK','9ufYxRt','createElement','code','Plural\x20rules\x20could\x20not\x20be\x20created.\x20Perhaps\x20`Intl.PluralRules`\x20is\x20not\x20supported?','length','map'];_0x52f5=function(){return _0x26fc6c;};return _0x52f5();}Plural[_0x3b8c8a(0xef)]=_0x4a537c=>{const _0x2a7dff=_0x3b8c8a;try{return Intl[_0x2a7dff(0xd4)][_0x2a7dff(0xf0)]([_0x4a537c])[_0x2a7dff(0xe5)]>0x0;}catch(_0x347589){return![];}};const I18nContext=_0x4158f6[_0x3b8c8a(0xd9)]({'debug':![],'lang':'en','resources':{},'pluralUtils':new Plural('en')}),I18nProvider=({children:_0x628303,debug:debug=![],lang:lang='en',resources:resources={}})=>{const _0x4a5d24=_0x3b8c8a;return _0x4158f6[_0x4a5d24(0xe7)](()=>{const _0x139cdb=_0x4a5d24,_0x1b8e8c=Plural[_0x139cdb(0xef)](lang);!_0x1b8e8c&&console[_0x139cdb(0xd1)]('Plural\x20form\x20for\x20language\x20\x22'+lang+_0x139cdb(0xee));},[lang]),_0x4158f6[_0x4a5d24(0xe2)](I18nContext[_0x4a5d24(0xd8)],{'value':{'debug':debug,'lang':lang,'pluralUtils':new Plural(lang),'resources':resources}},_0x628303);},TAG_REGEX=/<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,ALLOWED_TAGS=['em',_0x3b8c8a(0xd7),_0x3b8c8a(0xe3)],getMsg=(_0x3a8db8,_0x7a4df2={},_0x16f387)=>{const _0x15c3f8=_0x3b8c8a,_0x3883c2=_0x16f387['plural'];if(_0x7a4df2[_0x3a8db8]&&_0x3883c2===undefined)return{'found':!![],'msg':_0x7a4df2[_0x3a8db8]};const _0x2db528=Object['keys'](_0x7a4df2)[_0x15c3f8(0xdb)](_0x3da32b=>_0x3da32b[_0x15c3f8(0xd3)](_0x3a8db8)===0x0);if(_0x2db528[_0x15c3f8(0xe5)]===0x0||_0x3883c2===undefined)return{'found':![],'msg':_0x3a8db8};const _0x10e077=_0x16f387[_0x15c3f8(0xec)][_0x15c3f8(0xeb)](_0x3a8db8,_0x3883c2);return{'found':!![],'msg':_0x7a4df2[_0x10e077]};},parseMsgTags=_0x2fe4ac=>{const _0x36059c=_0x3b8c8a,_0x54e44d=[];let _0x3340ef=0x0,_0xa24cf3;while((_0xa24cf3=TAG_REGEX[_0x36059c(0xed)](_0x2fe4ac))!==null){const _0x158723=_0xa24cf3[0x0],{index:_0x1a70e6}=_0xa24cf3,_0x15c2c6=_0x158723['charAt'](0x1)==='/',_0x13c6c8=_0x15c2c6?_0x158723[_0x36059c(0xf3)](0x2,-0x1):_0x158723[_0x36059c(0xf3)](0x1,-0x1),_0x162b2b=ALLOWED_TAGS[_0x36059c(0xd2)](_0x13c6c8);if(!_0x162b2b)continue;const _0x5bf958=_0x2fe4ac[_0x36059c(0xf3)](_0x3340ef,_0x1a70e6);if(!_0x5bf958){_0x3340ef=_0x1a70e6+_0x158723['length'];continue;}_0x15c2c6?_0x54e44d[_0x36059c(0xf7)]({'type':_0x36059c(0xda),'name':_0x158723['slice'](0x2,-0x1),'content':_0x5bf958}):_0x54e44d[_0x36059c(0xf7)]({'type':_0x36059c(0xdc),'content':_0x5bf958}),_0x3340ef=_0x1a70e6+_0x158723[_0x36059c(0xe5)];}return _0x3340ef<_0x2fe4ac['length']&&_0x54e44d[_0x36059c(0xf7)]({'type':_0x36059c(0xdc),'content':_0x2fe4ac[_0x36059c(0xf3)](_0x3340ef)}),_0x54e44d;};function formatMsgWithTags(_0x2b3b58){const _0xa9f7cc=_0x3b8c8a,_0x5baa9c=parseMsgTags(_0x2b3b58),_0x12e4b0=_0x5baa9c[_0xa9f7cc(0xe6)](({content:_0x190a31,type:_0x53a8f7,name:_0x317681},_0x5ae261)=>{const _0x2c944a=_0xa9f7cc,_0x27bf80=_0x53a8f7!==_0x2c944a(0xdc)&&_0x317681?_0x317681:_0x4158f6[_0x2c944a(0xf2)];return _0x4158f6['createElement'](_0x27bf80,{'key':''+_0x5ae261},_0x190a31);});return _0x12e4b0;}function formatMsg(_0x1947ce,_0x391319,_0x448502){const _0x266287=sprintf(_0x1947ce,..._0x391319!==null&&_0x391319!==void 0x0?_0x391319:[]);if(!_0x448502)return _0x266287;return formatMsgWithTags(_0x266287);}const useTranslation=()=>{const _0x596a68=_0x3b8c8a,{lang:_0x5698fb,debug:_0x10f273,pluralUtils:_0x846aa9,resources:_0x154ad2}=_0x4158f6[_0x596a68(0xf5)](I18nContext);function _0x3189ab(_0x1e10a3,_0x2c1c90){const _0x10cfa8=_0x596a68,{found:_0x417eb8,msg:_0xb71e55}=getMsg(_0x1e10a3,_0x154ad2[_0x5698fb],{'plural':_0x2c1c90===null||_0x2c1c90===void 0x0?void 0x0:_0x2c1c90[_0x10cfa8(0xd0)],'pluralUtils':_0x846aa9});_0x10f273&&!_0x417eb8&&console[_0x10cfa8(0xea)]('['+_0x5698fb+']:\x20Translation\x20for\x20key\x20\x27'+_0x1e10a3+'\x27\x20is\x20missing.');if(_0x2c1c90===null||_0x2c1c90===void 0x0?void 0x0:_0x2c1c90['processTags'])return formatMsg(_0xb71e55,_0x2c1c90===null||_0x2c1c90===void 0x0?void 0x0:_0x2c1c90[_0x10cfa8(0xdd)],!![]);return formatMsg(_0xb71e55,_0x2c1c90===null||_0x2c1c90===void 0x0?void 0x0:_0x2c1c90[_0x10cfa8(0xdd)],![]);}return{'t':_0x3189ab,'lang':_0x5698fb};};function _0x543e(_0x4613f4,_0x423895){const _0x52f5b3=_0x52f5();return _0x543e=function(_0x543ee3,_0x30ba50){_0x543ee3=_0x543ee3-0xd0;let _0x3c2e7f=_0x52f5b3[_0x543ee3];return _0x3c2e7f;},_0x543e(_0x4613f4,_0x423895);}export{I18nContext,I18nProvider,useTranslation};
4
+ const _0x58d9d7=_0x1fc4;(function(_0x45ec38,_0x185875){const _0xabc8aa=_0x1fc4,_0x80e7eb=_0x45ec38();while(!![]){try{const _0x2b4ac7=-parseInt(_0xabc8aa(0x14a))/0x1*(-parseInt(_0xabc8aa(0x154))/0x2)+-parseInt(_0xabc8aa(0x161))/0x3+-parseInt(_0xabc8aa(0x162))/0x4*(parseInt(_0xabc8aa(0x15d))/0x5)+-parseInt(_0xabc8aa(0x164))/0x6*(-parseInt(_0xabc8aa(0x148))/0x7)+parseInt(_0xabc8aa(0x13b))/0x8*(-parseInt(_0xabc8aa(0x159))/0x9)+parseInt(_0xabc8aa(0x138))/0xa+-parseInt(_0xabc8aa(0x145))/0xb*(parseInt(_0xabc8aa(0x163))/0xc);if(_0x2b4ac7===_0x185875)break;else _0x80e7eb['push'](_0x80e7eb['shift']());}catch(_0x2cbb1a){_0x80e7eb['push'](_0x80e7eb['shift']());}}}(_0x5a12,0x831c5));import*as _0x354b3a from'react';import{sprintf}from'sprintf-js';class Plural{constructor(_0x2bca19){const _0x3865e3=_0x1fc4;this[_0x3865e3(0x14b)]=_0x2bca19;try{this[_0x3865e3(0x13e)]=new Intl[(_0x3865e3(0x14e))](_0x2bca19);}catch(_0x42c4a6){console[_0x3865e3(0x143)]('Plural\x20rules\x20could\x20not\x20be\x20created.\x20Perhaps\x20`Intl.PluralRules`\x20is\x20not\x20supported?');}}[_0x58d9d7(0x142)](_0x5eb46d,_0x11505f){const _0x2927a0=_0x58d9d7;if(!this[_0x2927a0(0x13e)])return _0x5eb46d+_0x2927a0(0x14d);const _0x3650e7=this[_0x2927a0(0x13e)][_0x2927a0(0x141)](_0x11505f);return _0x5eb46d+'_'+_0x3650e7;}}Plural['isSupported']=_0x4508a7=>{const _0x4b8d69=_0x58d9d7;try{return Intl[_0x4b8d69(0x14e)][_0x4b8d69(0x15e)]([_0x4508a7])[_0x4b8d69(0x13a)]>0x0;}catch(_0x33c558){return![];}};function _0x1fc4(_0xa2494e,_0x5743b0){const _0x5a122d=_0x5a12();return _0x1fc4=function(_0x1fc4b9,_0x48fb31){_0x1fc4b9=_0x1fc4b9-0x138;let _0x510574=_0x5a122d[_0x1fc4b9];return _0x510574;},_0x1fc4(_0xa2494e,_0x5743b0);}const I18nContext=_0x354b3a[_0x58d9d7(0x13f)]({'debug':![],'lang':'en','resources':{},'pluralUtils':new Plural('en')}),I18nProvider=({children:_0x57d0e0,debug:debug=![],lang:lang='en',resources:resources={}})=>{const _0x21218a=_0x58d9d7;return _0x354b3a[_0x21218a(0x157)](()=>{const _0x35ec37=_0x21218a,_0x14af9b=Plural[_0x35ec37(0x155)](lang);!_0x14af9b&&console[_0x35ec37(0x143)]('Plural\x20form\x20for\x20language\x20\x22'+lang+_0x35ec37(0x144));},[lang]),_0x354b3a['createElement'](I18nContext[_0x21218a(0x158)],{'value':{'debug':debug,'lang':lang,'pluralUtils':new Plural(lang),'resources':resources}},_0x57d0e0);},TAG_REGEX=/<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,ALLOWED_TAGS=['em',_0x58d9d7(0x14c),_0x58d9d7(0x153)],getMsg=(_0xb26f24,_0x245561={},_0x10240f)=>{const _0x260cb5=_0x58d9d7,_0x4f27a4=_0x10240f[_0x260cb5(0x140)];if(_0x245561[_0xb26f24]&&_0x4f27a4===undefined)return{'found':!![],'msg':_0x245561[_0xb26f24]};const _0x4f417a=Object[_0x260cb5(0x160)](_0x245561)[_0x260cb5(0x15c)](_0x1ab3ed=>_0x1ab3ed[_0x260cb5(0x139)](_0xb26f24)===0x0);if(_0x4f417a[_0x260cb5(0x13a)]===0x0||_0x4f27a4===undefined)return{'found':![],'msg':_0xb26f24};const _0x57beaa=_0x10240f[_0x260cb5(0x146)][_0x260cb5(0x142)](_0xb26f24,_0x4f27a4);return{'found':!![],'msg':_0x245561[_0x57beaa]};},parseMsgTags=_0x47f0a1=>{const _0x3f642a=_0x58d9d7,_0x47c74c=[];let _0x4bc59b=0x0,_0x2b4336;while((_0x2b4336=TAG_REGEX[_0x3f642a(0x15b)](_0x47f0a1))!==null){const _0x561a4e=_0x2b4336[0x0],{index:_0x12fb2c}=_0x2b4336,_0x5cf200=_0x561a4e['charAt'](0x1)==='/',_0x3911ff=_0x5cf200?_0x561a4e['slice'](0x2,-0x1):_0x561a4e[_0x3f642a(0x13d)](0x1,-0x1),_0x26708e=ALLOWED_TAGS['includes'](_0x3911ff);if(!_0x26708e)continue;const _0x4153dd=_0x47f0a1['slice'](_0x4bc59b,_0x12fb2c);if(!_0x4153dd){_0x4bc59b=_0x12fb2c+_0x561a4e[_0x3f642a(0x13a)];continue;}_0x5cf200?_0x47c74c[_0x3f642a(0x15f)]({'type':'tag','name':_0x561a4e['slice'](0x2,-0x1),'content':_0x4153dd}):_0x47c74c[_0x3f642a(0x15f)]({'type':_0x3f642a(0x14f),'content':_0x4153dd}),_0x4bc59b=_0x12fb2c+_0x561a4e[_0x3f642a(0x13a)];}return _0x4bc59b<_0x47f0a1[_0x3f642a(0x13a)]&&_0x47c74c[_0x3f642a(0x15f)]({'type':_0x3f642a(0x14f),'content':_0x47f0a1['slice'](_0x4bc59b)}),_0x47c74c;};function formatMsgWithTags(_0xf9fa36){const _0x4f77cd=_0x58d9d7,_0x2dc1b7=parseMsgTags(_0xf9fa36),_0x442292=_0x2dc1b7[_0x4f77cd(0x151)](({content:_0x3c30af,type:_0x5097a3,name:_0x3dfa79},_0x4657f6)=>{const _0x53c597=_0x4f77cd,_0x3a8870=_0x5097a3!=='text'&&_0x3dfa79?_0x3dfa79:_0x354b3a['Fragment'];return _0x354b3a[_0x53c597(0x149)](_0x3a8870,{'key':''+_0x4657f6},_0x3c30af);});return _0x442292;}function _0x5a12(){const _0x59b53f=['createContext','plural','select','getKey','warn','\x22\x20is\x20not\x20supported.','4626017ZFqJKv','pluralUtils','log','1357279dQsAUo','createElement','1aLXmSy','lang','strong','_one','PluralRules','text','\x27\x20is\x20missing.','map',']:\x20Translation\x20for\x20key\x20\x27','code','2042870BDEsda','isSupported','processTags','useEffect','Provider','12105pQVxZG','values','exec','filter','106015tkqWZU','supportedLocalesOf','push','keys','307179yEOitz','44cHPAEx','12uVeFnM','30rXEkRq','1092820zZlhvJ','indexOf','length','4800NlkWmo','useContext','slice','_rules'];_0x5a12=function(){return _0x59b53f;};return _0x5a12();}function formatMsg(_0x460187,_0x4fc148,_0x50ae26){const _0x57cb45=sprintf(_0x460187,..._0x4fc148!==null&&_0x4fc148!==void 0x0?_0x4fc148:[]);if(!_0x50ae26)return _0x57cb45;return formatMsgWithTags(_0x57cb45);}const useTranslation=()=>{const _0x5b3ca4=_0x58d9d7,{lang:_0x5c6e4e,debug:_0xaf2b46,pluralUtils:_0x5831a3,resources:_0x1a14ea}=_0x354b3a[_0x5b3ca4(0x13c)](I18nContext);function _0x14b1ee(_0x2654f0,_0x22aede){const _0x124409=_0x5b3ca4,{found:_0x56e8b2,msg:_0x3a50da}=getMsg(_0x2654f0,_0x1a14ea[_0x5c6e4e],{'plural':_0x22aede===null||_0x22aede===void 0x0?void 0x0:_0x22aede['plural'],'pluralUtils':_0x5831a3});_0xaf2b46&&!_0x56e8b2&&console[_0x124409(0x147)]('['+_0x5c6e4e+_0x124409(0x152)+_0x2654f0+_0x124409(0x150));if(_0x22aede===null||_0x22aede===void 0x0?void 0x0:_0x22aede[_0x124409(0x156)])return formatMsg(_0x3a50da,_0x22aede===null||_0x22aede===void 0x0?void 0x0:_0x22aede[_0x124409(0x15a)],!![]);return formatMsg(_0x3a50da,_0x22aede===null||_0x22aede===void 0x0?void 0x0:_0x22aede['values'],![]);}return{'t':_0x14b1ee,'lang':_0x5c6e4e};};export{I18nContext,I18nProvider,useTranslation};
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "license": "SEE LICENSE IN LICENSE.md",
24
24
  "name": "@ckbox/i18n",
25
- "version": "2.3.1",
25
+ "version": "2.4.0-dev.0",
26
26
  "description": "I18n utils of CKBox",
27
27
  "main": "dist/index.js",
28
28
  "types": "dist/index.d.ts",
@@ -30,7 +30,9 @@
30
30
  "react": "^18"
31
31
  },
32
32
  "dependencies": {
33
+ "@vitest/coverage-v8": "^1.2.0",
33
34
  "sprintf-js": "^1.1.3",
34
- "tslib": "^2.6.2"
35
+ "tslib": "^2.6.2",
36
+ "vitest": "^1.2.0"
35
37
  }
36
38
  }