@bgscore/react-i18n 0.0.1 → 1.0.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/dist/plugin.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"t",{value:!0});var n=require("fs"),e=require("path");const t=e.resolve(process.cwd(),"src");function r(t,o){for(const c of n.readdirSync(t,{withFileTypes:!0})){const n=e.join(t,c.name);c.isDirectory()&&(o(n),r(n,o))}}function o(n,e="",t=new Set){for(const[r,c]of Object.entries(n)){const n=e?`${e}.${r}`:r;null===c||"object"!=typeof c||Array.isArray(c)?t.add(n):o(c,n,t)}return t}function c(c,s,f){r(t,r=>{e.basename(r)===c&&function(r,c,s,f){const i=n.readdirSync(r).filter(n=>n.endsWith(".json"));if(!i.length)return;const u=new Set;for(const t of i){const c=e.join(r,t),s=JSON.parse(n.readFileSync(c,"utf-8"));"object"!=typeof s||Array.isArray(s)||o(s).forEach(n=>u.add(n))}if(!u.size)return;const a=function(n,r){return e.relative(t,n).replace(/\\/g,"/").replace(`/${r}`,"").replace(/\//g,".")}(r,c),l=`\ndeclare global {\n interface ${f} {\n "${a}": ${Array.from(u).sort().map(n=>`"${n}"`).join(" | ")};\n }\n}\n\nexport {};\n`,p=e.join(r,s);n.existsSync(p)&&n.readFileSync(p,"utf-8").trim()===l.trim()||n.writeFileSync(p,l,"utf-8")}(r,c,s,f)})}exports.default=(n={})=>{const e=n.i18nDirName??"i18n",t=n.outputFileName??"i18n.types.ts",r=n.namespaceInterfaceName??"I18nNamespaceMap",o=()=>{c(e,t,r)};return{name:"bgs-react-i18n",enforce:"pre",configResolved(){o()},buildStart(){o()},configureServer(n){o(),n.watcher.on("add",o).on("change",o).on("unlink",o).on("addDir",o).on("unlinkDir",o)}}};
1
+ "use strict";Object.defineProperty(exports,"t",{value:!0});var n=require("fs"),e=require("path");const t=e.resolve(process.cwd(),"src");function r(t,o){for(const c of n.readdirSync(t,{withFileTypes:!0})){const n=e.join(t,c.name);c.isDirectory()&&(o(n),r(n,o))}}function o(n,e="",t=new Set){for(const[r,c]of Object.entries(n)){const n=e?`${e}.${r}`:r;null===c||"object"!=typeof c||Array.isArray(c)?t.add(n):o(c,n,t)}return t}function c(c,s,i){r(t,r=>{e.basename(r)===c&&function(r,c,s,i){const u=n.readdirSync(r).filter(n=>n.endsWith(".json"));if(!u.length)return;const f=new Set;for(const t of u){const c=e.join(r,t),s=JSON.parse(n.readFileSync(c,"utf-8"));"object"!=typeof s||Array.isArray(s)||o(s).forEach(n=>f.add(n))}if(!f.size)return;const a=function(n,r){return e.relative(t,n).replace(/\\/g,"/").replace(`/${r}`,"").replace(/\//g,".")}(r,c),l=`\ndeclare global {\n interface ${i} {\n "${a}": ${Array.from(f).sort().map(n=>`"${n}"`).join(" | ")};\n }\n}\n\nexport {};\n`,p=e.join(r,s);n.existsSync(p)&&n.readFileSync(p,"utf-8").trim()===l.trim()||n.writeFileSync(p,l,"utf-8")}(r,c,s,i)})}exports.default=(n={})=>{const e=n.i18nDirName??"i18n",t=n.outputFileName??"i18n.types.ts",r=n.namespaceInterfaceName??"I18nNamespaceMap",o=()=>{c(e,t,r)};return{name:"bgs-react-i18n",enforce:"pre",apply:"build",configResolved(){o()},buildStart(){o()},configureServer(n){o(),n.watcher.on("add",o).on("change",o).on("unlink",o).on("addDir",o).on("unlinkDir",o)}}};
package/dist/plugin.mjs CHANGED
@@ -1 +1 @@
1
- import n from"fs";import t from"path";const o=t.resolve(process.cwd(),"src");function e(o,r){for(const c of n.readdirSync(o,{withFileTypes:!0})){const n=t.join(o,c.name);c.isDirectory()&&(r(n),e(n,r))}}function r(n,t="",o=new Set){for(const[e,c]of Object.entries(n)){const n=t?`${t}.${e}`:e;null===c||"object"!=typeof c||Array.isArray(c)?o.add(n):r(c,n,o)}return o}function c(c,f,s){e(o,e=>{t.basename(e)===c&&function(e,c,f,s){const i=n.readdirSync(e).filter(n=>n.endsWith(".json"));if(!i.length)return;const u=new Set;for(const o of i){const c=t.join(e,o),f=JSON.parse(n.readFileSync(c,"utf-8"));"object"!=typeof f||Array.isArray(f)||r(f).forEach(n=>u.add(n))}if(!u.size)return;const a=function(n,e){return t.relative(o,n).replace(/\\/g,"/").replace(`/${e}`,"").replace(/\//g,".")}(e,c),p=`\ndeclare global {\n interface ${s} {\n "${a}": ${Array.from(u).sort().map(n=>`"${n}"`).join(" | ")};\n }\n}\n\nexport {};\n`,l=t.join(e,f);n.existsSync(l)&&n.readFileSync(l,"utf-8").trim()===p.trim()||n.writeFileSync(l,p,"utf-8")}(e,c,f,s)})}const f=(n={})=>{const t=n.i18nDirName??"i18n",o=n.outputFileName??"i18n.types.ts",e=n.namespaceInterfaceName??"I18nNamespaceMap",r=()=>{c(t,o,e)};return{name:"bgs-react-i18n",enforce:"pre",configResolved(){r()},buildStart(){r()},configureServer(n){r(),n.watcher.on("add",r).on("change",r).on("unlink",r).on("addDir",r).on("unlinkDir",r)}}};export{f as default};
1
+ import n from"fs";import t from"path";const o=t.resolve(process.cwd(),"src");function e(o,r){for(const c of n.readdirSync(o,{withFileTypes:!0})){const n=t.join(o,c.name);c.isDirectory()&&(r(n),e(n,r))}}function r(n,t="",o=new Set){for(const[e,c]of Object.entries(n)){const n=t?`${t}.${e}`:e;null===c||"object"!=typeof c||Array.isArray(c)?o.add(n):r(c,n,o)}return o}function c(c,f,s){e(o,e=>{t.basename(e)===c&&function(e,c,f,s){const i=n.readdirSync(e).filter(n=>n.endsWith(".json"));if(!i.length)return;const u=new Set;for(const o of i){const c=t.join(e,o),f=JSON.parse(n.readFileSync(c,"utf-8"));"object"!=typeof f||Array.isArray(f)||r(f).forEach(n=>u.add(n))}if(!u.size)return;const a=function(n,e){return t.relative(o,n).replace(/\\/g,"/").replace(`/${e}`,"").replace(/\//g,".")}(e,c),p=`\ndeclare global {\n interface ${s} {\n "${a}": ${Array.from(u).sort().map(n=>`"${n}"`).join(" | ")};\n }\n}\n\nexport {};\n`,l=t.join(e,f);n.existsSync(l)&&n.readFileSync(l,"utf-8").trim()===p.trim()||n.writeFileSync(l,p,"utf-8")}(e,c,f,s)})}const f=(n={})=>{const t=n.i18nDirName??"i18n",o=n.outputFileName??"i18n.types.ts",e=n.namespaceInterfaceName??"I18nNamespaceMap",r=()=>{c(t,o,e)};return{name:"bgs-react-i18n",enforce:"pre",apply:"build",configResolved(){r()},buildStart(){r()},configureServer(n){r(),n.watcher.on("add",r).on("change",r).on("unlink",r).on("addDir",r).on("unlinkDir",r)}}};export{f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgscore/react-i18n",
3
- "version": "0.0.1",
3
+ "version": "1.0.1",
4
4
  "description": "Vite plugin for React that automatically generates TypeScript-safe i18n namespaces and translation keys from JSON files",
5
5
  "author": "Andry Bagus Dharmawan",
6
6
  "license": "MIT",