New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@inlang/plugin-message-format

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@inlang/plugin-message-format - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

10

dist/index.js

@@ -1,5 +0,5 @@

var g={en:"inlang message format"},_={en:"The simplest storage plugin for inlang."};var R=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}},Z=Symbol("brand");function d(e){return{issues:e}}function p(e){return{output:e}}function M(e,t){return{reason:e?.reason,validation:t.validation,origin:e?.origin||"value",message:t.message,input:t.input,path:t.path,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function J(e,t){return{reason:t,origin:e?.origin,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function I(e,t,r,s){if(!t||!t.length||r?.skipPipe)return p(e);let n,a,u=e;for(let i of t){let o=i(u);if(o.issues){n=n||J(r,s);for(let l of o.issues){let c=M(n,l);a?a.push(c):a=[c]}if(n.abortEarly||n.abortPipeEarly)break}else u=o.output}return a?d(a):p(u)}function A(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function E(e){return typeof e=="function"?e():e}function k(e,t,r){return d([{validation:e,message:E(t),input:r}])}function w(e,t,r,s,n,a){return{issues:[{reason:t,validation:r,origin:e?.origin||"value",message:E(s),input:n,issues:a,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}]}}function P(e,t,r){let[s,n]=A(t,r),a;return{schema:"object",object:e,async:!1,_parse(u,i){if(!u||typeof u!="object")return w(i,"type","object",s||"Invalid type",u);a=a||Object.entries(e);let o,l={};for(let[c,D]of a){let h=u[c],f=D._parse(h,i);if(f.issues){let b={schema:"object",input:u,key:c,value:h};for(let y of f.issues)y.path?y.path.unshift(b):y.path=[b],o?.push(y);if(o||(o=f.issues),i?.abortEarly)break}else l[c]=f.output}return o?d(o):I(l,n,i,"object")}}}function j(e,t){let[r,s]=A(e,t);return{schema:"string",async:!1,_parse(n,a){return typeof n!="string"?w(a,"type","string",r||"Invalid type",n):I(n,s,a,"string")}}}function F(e,t,r){let s=e._parse(t,r);if(s.issues)throw new R(s.issues);return s.output}function x(e,t){return r=>r.endsWith(e)?p(r):k("ends_with",t||"Invalid end",r)}function O(e,t){return r=>e.test(r)?p(r):k("regex",t||"Invalid regex",r)}var N=P({filePath:j([O(/^(\.)|(\/)/),x(".json")])});var W=e=>{let t=S(e,0);if(t===void 0||!C(e[t]))return;let r=S(e,t+1);if(r!==void 0)return U(e,t,r)},T=W,S=(e,t)=>{for(let r=t;r<e.length;r+=1){let s=e[r];if(!L(s))return r}},L=e=>e===" "||e===" "||e===`
`||e==="\r",C=e=>e==="{"||e==="[",U=(e,t,r)=>{let s;for(let n=r-1;n>t;n-=1){let a=e[n];if(a==="\r")return;if(a===`
`)return B(s);if(s===void 0)s=a;else if(s[0]===a)s+=a;else return}},B=e=>e===void 0?0:e[0]===" "?e.length:e;var m=e=>{let t=e.endsWith(`
`),r=T(e);return(s,n)=>JSON.stringify(s,n,r)+(t?`
`:"")};var V="plugin.inlang.messageFormat",$,z={id:V,displayName:g,description:_,loadMessages:async({settings:e,nodeishFs:t})=>{F(N,e["plugin.inlang.messageFormat"]);try{let r=await t.readFile(e["plugin.inlang.messageFormat"].filePath,{encoding:"utf-8"});return $=m(r),JSON.parse(r).data}catch(r){if(r?.code==="ENOENT")return await t.writeFile(e["plugin.inlang.messageFormat"].filePath,JSON.stringify({$schema:"https://inlang.com/schema/inlang-message-format",data:[]},void 0," ")),[];throw r}},saveMessages:async({settings:e,nodeishFs:t,messages:r})=>t.writeFile(e["plugin.inlang.messageFormat"].filePath,$({$schema:"https://inlang.com/schema/inlang-message-format",data:r.sort((s,n)=>s.id.localeCompare(n.id))}))};var ce=z;export{ce as default};
var U=Object.create;var I=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var H=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of V(t))!K.call(e,s)&&s!==r&&I(e,s,{get:()=>t[s],enumerable:!(n=B(t,s))||n.enumerable});return e};var Q=(e,t,r)=>(r=e!=null?U(Z(e)):{},H(t||!e||!e.__esModule?I(r,"default",{value:e,enumerable:!0}):r,e));var M=q((we,l)=>{"use strict";var ae=process.platform==="win32",ue=/^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/,b={};function ie(e){return ue.exec(e).slice(1)}b.parse=function(e){if(typeof e!="string")throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=ie(e);if(!t||t.length!==5)throw new TypeError("Invalid path '"+e+"'");return{root:t[1],dir:t[0]===t[1]?t[0]:t[0].slice(0,-1),base:t[2],ext:t[4],name:t[3]}};var oe=/^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/,v={};function ce(e){return oe.exec(e).slice(1)}v.parse=function(e){if(typeof e!="string")throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=ce(e);if(!t||t.length!==5)throw new TypeError("Invalid path '"+e+"'");return{root:t[1],dir:t[0].slice(0,-1),base:t[2],ext:t[4],name:t[3]}};ae?l.exports=b.parse:l.exports=v.parse;l.exports.posix=v.parse;l.exports.win32=b.parse});var E={en:"inlang message format"},w={en:"The simplest storage plugin for inlang."};var Y=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}},de=Symbol("brand");function h(e){return{issues:e}}function d(e){return{output:e}}function G(e,t){return{reason:e?.reason,validation:t.validation,origin:e?.origin||"value",message:t.message,input:t.input,path:t.path,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function X(e,t){return{reason:t,origin:e?.origin,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function P(e,t,r,n){if(!t||!t.length||r?.skipPipe)return d(e);let s,a,u=e;for(let o of t){let i=o(u);if(i.issues){s=s||X(r,n);for(let f of i.issues){let c=G(s,f);a?a.push(c):a=[c]}if(s.abortEarly||s.abortPipeEarly)break}else u=i.output}return a?h(a):d(u)}function k(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function j(e){return typeof e=="function"?e():e}function F(e,t,r){return h([{validation:e,message:j(t),input:r}])}function x(e,t,r,n,s,a){return{issues:[{reason:t,validation:r,origin:e?.origin||"value",message:j(n),input:s,issues:a,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}]}}function O(e,t,r){let[n,s]=k(t,r),a;return{schema:"object",object:e,async:!1,_parse(u,o){if(!u||typeof u!="object")return x(o,"type","object",n||"Invalid type",u);a=a||Object.entries(e);let i,f={};for(let[c,C]of a){let g=u[c],y=C._parse(g,o);if(y.issues){let _={schema:"object",input:u,key:c,value:g};for(let p of y.issues)p.path?p.path.unshift(_):p.path=[_],i?.push(p);if(i||(i=y.issues),o?.abortEarly)break}else f[c]=y.output}return i?h(i):P(f,s,o,"object")}}}function N(e,t){let[r,n]=k(e,t);return{schema:"string",async:!1,_parse(s,a){return typeof s!="string"?x(a,"type","string",r||"Invalid type",s):P(s,n,a,"string")}}}function T(e,t,r){let n=e._parse(t,r);if(n.issues)throw new Y(n.issues);return n.output}function S(e,t){return r=>r.endsWith(e)?d(r):F("ends_with",t||"Invalid end",r)}function $(e,t){return r=>e.test(r)?d(r):F("regex",t||"Invalid regex",r)}var z=O({filePath:N([$(/^(\.)|(\/)/),S(".json")])});var ee=e=>{let t=R(e,0);if(t===void 0||!re(e[t]))return;let r=R(e,t+1);if(r!==void 0)return se(e,t,r)},D=ee,R=(e,t)=>{for(let r=t;r<e.length;r+=1){let n=e[r];if(!te(n))return r}},te=e=>e===" "||e===" "||e===`
`||e==="\r",re=e=>e==="{"||e==="[",se=(e,t,r)=>{let n;for(let s=r-1;s>t;s-=1){let a=e[s];if(a==="\r")return;if(a===`
`)return ne(n);if(n===void 0)n=a;else if(n[0]===a)n+=a;else return}},ne=e=>e===void 0?0:e[0]===" "?e.length:e;var m=e=>{let t=e.endsWith(`
`),r=D(e);return(n,s)=>JSON.stringify(n,s,r)+(t?`
`:"")};var J=Q(M(),1),le="plugin.inlang.messageFormat",W,L={id:le,displayName:E,description:w,loadMessages:async({settings:e,nodeishFs:t})=>{T(z,e["plugin.inlang.messageFormat"]);try{let r=await t.readFile(e["plugin.inlang.messageFormat"].filePath,{encoding:"utf-8"});return W=m(r),JSON.parse(r).data}catch(r){if(r?.code==="ENOENT")return await fe({path:e["plugin.inlang.messageFormat"].filePath,nodeishFs:t}),[];throw r}},saveMessages:async({settings:e,nodeishFs:t,messages:r})=>t.writeFile(e["plugin.inlang.messageFormat"].filePath,W({$schema:"https://inlang.com/schema/inlang-message-format",data:r.sort((n,s)=>n.id.localeCompare(s.id))}))},fe=async e=>{let t=(0,J.default)(e.path);await e.nodeishFs.mkdir(t.dir,{recursive:!0}),await e.nodeishFs.writeFile(e.path,JSON.stringify({$schema:"https://inlang.com/schema/inlang-message-format",data:[]},void 0," "))};var Ne=L;export{Ne as default};
{
"name": "@inlang/plugin-message-format",
"version": "1.0.0",
"version": "1.1.0",
"type": "module",

@@ -27,3 +27,5 @@ "exports": {

"@sinclair/typebox": "^0.31.17",
"@types/path-parse": "1.0.21",
"@vitest/coverage-v8": "^0.33.0",
"path-parse": "1.0.7",
"typescript": "^5.1.3",

@@ -30,0 +32,0 @@ "valibot": "0.18.0",

@@ -45,2 +45,2 @@ # Plugin inlang message format

_Is something unclear or do you have questions? Reach out to us in our [Discord channel](https://discord.gg/9vUg7Rr), open a [Discussion](https://github.com/inlang/monorepo/discussions), or file an [Issue](https:github.com/inlang/monorepong/issues) on [Github](httpgithub.com/inlang/monorepolang)._
_Is something unclear or do you have questions? Reach out to us in our [Discord channel](https://discord.gg/9vUg7Rr), open a [Discussion](https://github.com/inlang/monorepo/discussions), or file an [Issue](https://github.com/inlang/monorepo/issues) on [Github](https://github.com/inlang/monorepo)._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc