@weconjs/core 1.2.3 → 1.2.10
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 +460 -259
- package/dist/config.d.ts +7 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +21 -43
- package/dist/config.js.map +1 -1
- package/dist/devtools/controllers/i18n.controller.d.ts +1 -1
- package/dist/devtools/controllers/i18n.controller.d.ts.map +1 -1
- package/dist/devtools/controllers/i18n.controller.js +19 -10
- package/dist/devtools/controllers/i18n.controller.js.map +1 -1
- package/dist/devtools/index.d.ts.map +1 -1
- package/dist/devtools/index.js +2 -0
- package/dist/devtools/index.js.map +1 -1
- package/dist/i18n/index.d.ts +13 -30
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +15 -91
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/loader.d.ts +58 -0
- package/dist/i18n/loader.d.ts.map +1 -0
- package/dist/i18n/loader.js +97 -0
- package/dist/i18n/loader.js.map +1 -0
- package/dist/i18n/middleware.d.ts +39 -0
- package/dist/i18n/middleware.d.ts.map +1 -0
- package/dist/i18n/middleware.js +75 -0
- package/dist/i18n/middleware.js.map +1 -0
- package/dist/i18n/utils.d.ts +31 -0
- package/dist/i18n/utils.d.ts.map +1 -0
- package/dist/i18n/utils.js +46 -0
- package/dist/i18n/utils.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts +10 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +25 -0
- package/dist/module.js.map +1 -1
- package/dist/server/banner.d.ts +1 -0
- package/dist/server/banner.d.ts.map +1 -1
- package/dist/server/banner.js +13 -2
- package/dist/server/banner.js.map +1 -1
- package/dist/server/index.d.ts +7 -3
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +20 -12
- package/dist/server/index.js.map +1 -1
- package/dist/types.d.ts +15 -13
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -4
- package/dist/devtools/client/assets/CopyButton-DIdtJD4_.js +0 -6
- package/dist/devtools/client/assets/ModuleDetail-Dx6eU87l.js +0 -1
- package/dist/devtools/client/assets/TranslationEditor-Bj654a_E.js +0 -11
- package/dist/devtools/client/assets/chevron-right-E9DzkOHY.js +0 -6
- package/dist/devtools/client/assets/copy-BvbhBv2y.js +0 -6
- package/dist/devtools/client/assets/index-B42p6IVr.js +0 -6
- package/dist/devtools/client/assets/index-CSkGspzD.js +0 -1
- package/dist/devtools/client/assets/index-CnAObNgT.js +0 -16
- package/dist/devtools/client/assets/index-CwJHaaYT.css +0 -1
- package/dist/devtools/client/assets/index-Dfe66IW7.js +0 -1
- package/dist/devtools/client/assets/index-DoHRi03N.js +0 -201
- package/dist/devtools/client/assets/index-DvvGoEUv.js +0 -1
- package/dist/devtools/client/assets/loader-circle-DoOjJ8vr.js +0 -6
- package/dist/devtools/client/assets/plus-Ca-xq8y8.js +0 -6
- package/dist/devtools/client/assets/save-CV1xmSXO.js +0 -11
- package/dist/devtools/client/assets/search-CpTZ4fXm.js +0 -6
- package/dist/devtools/client/index.html +0 -15
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as n,u as P,d as W,j as e,m as u,G as D,X as E,a as h}from"./index-DoHRi03N.js";import{L as N}from"./loader-circle-DoOjJ8vr.js";import{C as A}from"./chevron-right-E9DzkOHY.js";import{C as B}from"./copy-BvbhBv2y.js";import{P as G}from"./plus-Ca-xq8y8.js";function q(){const[o,S]=n.useState([]),[F,U]=n.useState(!0),[T,c]=n.useState(null),[g,l]=n.useState(""),[v,C]=n.useState(!1),[r,x]=n.useState(null),[f,y]=n.useState(""),[$,w]=n.useState(!1),b=P(),{addToast:d}=W(),j=()=>{h.get("/i18n").then(a=>S(a.data??[])).catch(console.error).finally(()=>U(!1))};n.useEffect(()=>{j()},[]);const z=async a=>{const s=g.trim().toLowerCase();if(s){C(!0);try{await h.put(`/i18n/${a}/${s}`,{}),d({type:"success",message:`Created ${a}/${s}`}),c(null),l(""),j(),b(`/i18n/${a}/${s}`)}catch{d({type:"error",message:"Failed to create language"})}finally{C(!1)}}},L=async(a,s)=>{var m;const t=f.trim().toLowerCase();if(!t)return;const p=o.find(i=>i.namespace===a);if(p!=null&&p.languages.includes(t)){d({type:"error",message:`Language "${t}" already exists in ${a}`});return}w(!0);try{const i=await h.get(`/i18n/${a}/${s}`),K=((m=i.data)==null?void 0:m.translations)??i.data??{};await h.put(`/i18n/${a}/${t}`,K),d({type:"success",message:`Duplicated ${s.toUpperCase()} → ${t.toUpperCase()} in ${a}`}),x(null),y(""),j(),b(`/i18n/${a}/${t}`)}catch{d({type:"error",message:"Failed to duplicate language"})}finally{w(!1)}},k=()=>{x(null),y("")};return F?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(N,{className:"size-8 animate-spin text-primary"})}):o.length===0?e.jsxs(u.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.3},className:"flex size-full flex-col items-center justify-center gap-4 p-6",children:[e.jsx("div",{className:"flex size-16 items-center justify-center rounded-full bg-secondary",children:e.jsx(D,{className:"size-8 text-secondary"})}),e.jsx("p",{className:"text-lg font-semibold text-primary",children:"No translations found"}),e.jsx("p",{className:"max-w-md text-center text-sm text-secondary",children:"Enable i18n in your Wecon config and add translation files to your module directories to manage translations here."})]}):e.jsxs(u.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.3},className:"flex size-full flex-col gap-6 overflow-y-auto p-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-primary",children:"Translations"}),e.jsxs("p",{className:"mt-1 text-sm text-secondary",children:[o.length," namespace",o.length!==1?"s":""," · Manage translations for each module"]})]}),e.jsx("div",{className:"flex flex-col gap-4",children:o.map(a=>{var s;return e.jsxs("div",{className:"rounded-primary border border-primary bg-secondary p-5",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-3",children:[e.jsx("div",{className:"flex size-8 items-center justify-center rounded-secondary bg-primary",children:e.jsx(D,{className:"size-4 text-secondary"})}),e.jsx("span",{className:"text-base font-semibold text-primary",children:a.namespace})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.languages.map(t=>{var m;const p=`${a.namespace}:${t}`;return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(u.button,{whileHover:{scale:1.03},whileTap:{scale:.97},onClick:()=>b(`/i18n/${a.namespace}/${t}`),className:"flex items-center gap-2 rounded-secondary border border-primary bg-primary px-3 py-2 text-xs transition-shadow hover:shadow-small",children:[e.jsx("span",{className:"font-bold text-primary",children:t.toUpperCase()}),e.jsxs("span",{className:"text-secondary",children:[((m=a.keyCounts)==null?void 0:m[t])??0," keys"]}),e.jsx(A,{className:"size-3 text-secondary"})]}),e.jsx("button",{onClick:i=>{i.stopPropagation(),x(p),y(""),c(null)},title:`Duplicate ${t.toUpperCase()} to new language`,className:"flex size-7 items-center justify-center rounded-secondary text-secondary transition-colors hover:bg-primary hover:text-primary",children:e.jsx(B,{className:"size-3"})})]},t)}),(r==null?void 0:r.startsWith(`${a.namespace}:`))&&e.jsxs(u.div,{initial:{opacity:0,width:0},animate:{opacity:1,width:"auto"},className:"flex items-center gap-1.5 rounded-secondary border border-blue-300 bg-primary px-2 py-1",children:[e.jsxs("span",{className:"text-[10px] text-secondary",children:["Copy ",(s=r.split(":")[1])==null?void 0:s.toUpperCase()," →"]}),e.jsx("input",{type:"text",value:f,onChange:t=>y(t.target.value),onKeyDown:t=>{t.key==="Enter"&&L(a.namespace,r.split(":")[1]),t.key==="Escape"&&k()},placeholder:"e.g. ar",autoFocus:!0,maxLength:5,className:"w-14 rounded-tertiary border border-blue-400 bg-secondary px-2 py-1 text-xs text-primary outline-none"}),e.jsx("button",{onClick:()=>L(a.namespace,r.split(":")[1]),disabled:$||!f.trim(),className:"rounded-secondary bg-btn-primary px-2 py-1 text-xs font-medium text-btn-primary transition-opacity hover:opacity-90 disabled:opacity-50",children:$?e.jsx(N,{className:"size-3 animate-spin"}):"Duplicate"}),e.jsx("button",{onClick:k,className:"rounded-secondary p-0.5 transition-colors hover:bg-secondary",children:e.jsx(E,{className:"size-3.5 text-secondary"})})]}),T===a.namespace?e.jsxs(u.div,{initial:{opacity:0,width:0},animate:{opacity:1,width:"auto"},className:"flex items-center gap-1.5",children:[e.jsx("input",{type:"text",value:g,onChange:t=>l(t.target.value),onKeyDown:t=>{t.key==="Enter"&&z(a.namespace),t.key==="Escape"&&(c(null),l(""))},placeholder:"e.g. fr",autoFocus:!0,maxLength:5,className:"w-16 rounded-tertiary border border-blue-400 bg-primary px-2 py-1.5 text-xs text-primary outline-none"}),e.jsx("button",{onClick:()=>z(a.namespace),disabled:v||!g.trim(),className:"rounded-secondary bg-btn-primary px-2.5 py-1.5 text-xs font-medium text-btn-primary transition-opacity hover:opacity-90 disabled:opacity-50",children:v?e.jsx(N,{className:"size-3 animate-spin"}):"Create"}),e.jsx("button",{onClick:()=>{c(null),l("")},className:"rounded-secondary p-1 transition-colors hover:bg-primary",children:e.jsx(E,{className:"size-3.5 text-secondary"})})]}):!(r!=null&&r.startsWith(`${a.namespace}:`))&&e.jsxs("button",{onClick:()=>{c(a.namespace),l(""),x(null)},className:"flex items-center gap-1 rounded-secondary border border-dashed border-primary px-3 py-2 text-xs text-secondary transition-colors hover:bg-primary hover:text-primary",children:[e.jsx(G,{className:"size-3"}),"Add language"]})]})]},a.namespace)})})]})}export{q as default};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./index-DoHRi03N.js";/**
|
|
2
|
-
* @license lucide-react v0.460.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const r=e("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);export{r as L};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c as e}from"./index-DoHRi03N.js";/**
|
|
2
|
-
* @license lucide-react v0.460.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const a=e("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);export{a as P};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{c as a}from"./index-DoHRi03N.js";/**
|
|
2
|
-
* @license lucide-react v0.460.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const e=a("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
7
|
-
* @license lucide-react v0.460.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const o=a("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);export{e as A,o as S};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c}from"./index-DoHRi03N.js";/**
|
|
2
|
-
* @license lucide-react v0.460.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const r=c("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);export{r as S};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🔧</text></svg>" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Wecon DevTools</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-DoHRi03N.js"></script>
|
|
9
|
-
<link rel="stylesheet" crossorigin href="./assets/index-CwJHaaYT.css">
|
|
10
|
-
</head>
|
|
11
|
-
|
|
12
|
-
<body>
|
|
13
|
-
<div id="root"></div>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|