@vercel/stega 1.0.0 → 1.1.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/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var p={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},l={0:8203,1:8204,2:8205,3:65279},d={0:String.fromCodePoint(l[0]),1:String.fromCodePoint(l[1]),2:String.fromCodePoint(l[2]),3:String.fromCodePoint(l[3])},u=new Array(4).fill(String.fromCodePoint(l[0])).join(""),g=String.fromCharCode(0);function A(e){let r=JSON.stringify(e),t=new TextEncoder().encode(r),i="";for(let c=0;c<t.length;c++){let n=t[c];i+=d[n>>6&3]+d[n>>4&3]+d[n>>2&3]+d[n&3]}return u+i}function C(e){let r=JSON.stringify(e);return Array.from(r).map(t=>{let i=t.charCodeAt(0);if(i>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${r} on character ${t} (${i})`);return Array.from(i.toString(16).padStart(2,"0")).map(c=>String.fromCodePoint(p[c])).join("")}).join("")}function I(e){return!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(e)?!1:!!Date.parse(e)}function S(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch (e2){return!1}return!0}function y(e,r,t="auto"){return t===!0||t==="auto"&&(I(e)||S(e))?e:`${e}${A(r)}`}var m=Object.fromEntries(Object.entries(d).map(e=>[e[1],+e[0]])),T=Object.fromEntries(Object.entries(p).map(e=>e.reverse())),h=`${Object.values(p).map(e=>`\\u{${e.toString(16)}}`).join("")}`,x= exports.VERCEL_STEGA_REGEX =new RegExp(`[${h}]{4,}`,"gu");function X(e){let r=e.match(x);if(r)return E(r[0],!0)[0]}function M(e){let r=e.match(x);if(r)return r.map(t=>E(t)).flat()}function E(e,r=!1){let t=Array.from(e),i=1/0,c=-1;for(let n=0;n<t.length;++n)t[n]===u[0]&&t[n+1]===u[1]&&t[n+2]===u[2]&&t[n+3]===u[3]&&(i=Math.min(i,n),c=Math.max(c,n));if(c===-1)return _(t,r);for(let n=i;n<=c;++n)if(!((t.length-n)%4))try{let f=t.slice(n+4),s=new Uint8Array(f.length/4);for(let o=0;o<s.length;o++)s[o]=m[f[o*4]]<<6|m[f[o*4+1]]<<4|m[f[o*4+2]]<<2|m[f[o*4+3]];let a=new TextDecoder().decode(s);if(r){let o=a.indexOf(g);return o===-1&&(o=a.length),[JSON.parse(a.slice(0,o))]}return a.split(g).filter(Boolean).map(o=>JSON.parse(o))}catch (e3){}return[]}function _(e,r){var f;let t=[];for(let s=e.length*.5;s--;){let a=`${T[e[s*2].codePointAt(0)]}${T[e[s*2+1].codePointAt(0)]}`;t.unshift(String.fromCharCode(parseInt(a,16)))}let i=[],c=[t.join("")],n=10;for(;c.length;){let s=c.shift();try{if(i.push(JSON.parse(s)),r)return i}catch(a){if(!n--)throw a;let o=+((f=a.message.match(/\sposition\s(\d+)$/))==null?void 0:f[1]);if(!o)throw a;c.unshift(s.substring(0,o),s.substring(o))}}return i}function P(e){var r;return{cleaned:e.replace(x,""),encoded:((r=e.match(x))==null?void 0:r[0])||""}}function w(e){return e&&JSON.parse(P(JSON.stringify(e)).cleaned)}exports.VERCEL_STEGA_REGEX = x; exports.legacyStegaEncode = C; exports.vercelStegaClean = w; exports.vercelStegaCombine = y; exports.vercelStegaDecode = X; exports.vercelStegaDecodeAll = M; exports.vercelStegaEncode = A; exports.vercelStegaSplit = P;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},l={0:8203,1:8204,2:8205,3:65279},d={0:String.fromCodePoint(l[0]),1:String.fromCodePoint(l[1]),2:String.fromCodePoint(l[2]),3:String.fromCodePoint(l[3])},u=new Array(4).fill(String.fromCodePoint(l[0])).join(""),g=String.fromCharCode(0);function A(e){let r=JSON.stringify(e),t=new TextEncoder().encode(r),i="";for(let c=0;c<t.length;c++){let n=t[c];i+=d[n>>6&3]+d[n>>4&3]+d[n>>2&3]+d[n&3]}return u+i}function C(e){let r=JSON.stringify(e);return Array.from(r).map(t=>{let i=t.charCodeAt(0);if(i>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${r} on character ${t} (${i})`);return Array.from(i.toString(16).padStart(2,"0")).map(c=>String.fromCodePoint(p[c])).join("")}).join("")}function I(e){return!Number.isNaN(Number(e))||/[a-z]/i.test(e)&&!/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(e)?!1:!!Date.parse(e)}function S(e){try{new URL(e,e.startsWith("/")?"https://acme.com":void 0)}catch{return!1}return!0}function y(e,r,t="auto"){return t===!0||t==="auto"&&(I(e)||S(e))?e:`${e}${A(r)}`}var m=Object.fromEntries(Object.entries(d).map(e=>[e[1],+e[0]])),T=Object.fromEntries(Object.entries(p).map(e=>e.reverse())),h=`${Object.values(p).map(e=>`\\u{${e.toString(16)}}`).join("")}`,x=new RegExp(`[${h}]{4,}`,"gu");function X(e){let r=e.match(x);if(r)return E(r[0],!0)[0]}function M(e){let r=e.match(x);if(r)return r.map(t=>E(t)).flat()}function E(e,r=!1){let t=Array.from(e),i=1/0,c=-1;for(let n=0;n<t.length;++n)t[n]===u[0]&&t[n+1]===u[1]&&t[n+2]===u[2]&&t[n+3]===u[3]&&(i=Math.min(i,n),c=Math.max(c,n));if(c===-1)return _(t,r);for(let n=i;n<=c;++n)if(!((t.length-n)%4))try{let f=t.slice(n+4),s=new Uint8Array(f.length/4);for(let o=0;o<s.length;o++)s[o]=m[f[o*4]]<<6|m[f[o*4+1]]<<4|m[f[o*4+2]]<<2|m[f[o*4+3]];let a=new TextDecoder().decode(s);if(r){let o=a.indexOf(g);return o===-1&&(o=a.length),[JSON.parse(a.slice(0,o))]}return a.split(g).filter(Boolean).map(o=>JSON.parse(o))}catch{}return[]}function _(e,r){var f;let t=[];for(let s=e.length*.5;s--;){let a=`${T[e[s*2].codePointAt(0)]}${T[e[s*2+1].codePointAt(0)]}`;t.unshift(String.fromCharCode(parseInt(a,16)))}let i=[],c=[t.join("")],n=10;for(;c.length;){let s=c.shift();try{if(i.push(JSON.parse(s)),r)return i}catch(a){if(!n--)throw a;let o=+((f=a.message.match(/\sposition\s(\d+)$/))==null?void 0:f[1]);if(!o)throw a;c.unshift(s.substring(0,o),s.substring(o))}}return i}function P(e){var r;return{cleaned:e.replace(x,""),encoded:((r=e.match(x))==null?void 0:r[0])||""}}function w(e){return e&&JSON.parse(P(JSON.stringify(e)).cleaned)}export{x as VERCEL_STEGA_REGEX,C as legacyStegaEncode,w as vercelStegaClean,y as vercelStegaCombine,X as vercelStegaDecode,M as vercelStegaDecodeAll,A as vercelStegaEncode,P as vercelStegaSplit};
|