@lunora/wire 1.0.0-alpha.2 → 1.0.0-alpha.3

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.mjs CHANGED
@@ -1 +1 @@
1
- import{default as o}from"./packem_shared/stableStringify-rlPCO-eR.mjs";import{WIRE_TAG as d,decodeDocument as i,decodeWire as n,encodeArgsOrThrow as a,encodeWire as c,needsWireEncoding as f}from"./packem_shared/WIRE_TAG-DIesFsHE.mjs";import{default as l}from"./packem_shared/stableWireKey-CHXf9QAT.mjs";import{isPlainObject as W}from"./packem_shared/isPlainObject-UM7p1XXO.mjs";export{d as WIRE_TAG,i as decodeDocument,n as decodeWire,a as encodeArgsOrThrow,c as encodeWire,W as isPlainObject,f as needsWireEncoding,o as stableStringify,l as stableWireKey};
1
+ import{default as o}from"./packem_shared/stableStringify-rlPCO-eR.mjs";import{WIRE_TAG as d,decodeDocument as i,decodeWire as n,encodeArgsOrThrow as a,encodeWire as c,needsWireEncoding as f}from"./packem_shared/WIRE_TAG-D1pg4t5o.mjs";import{default as l}from"./packem_shared/stableWireKey-D10F2WCL.mjs";import{isPlainObject as W}from"./packem_shared/isPlainObject-UM7p1XXO.mjs";export{d as WIRE_TAG,i as decodeDocument,n as decodeWire,a as encodeArgsOrThrow,c as encodeWire,W as isPlainObject,f as needsWireEncoding,o as stableStringify,l as stableWireKey};
@@ -0,0 +1 @@
1
+ import{isPlainObject as u}from"./isPlainObject-UM7p1XXO.mjs";const f=r=>{let e="";for(let n=0;n<r.length;n+=32768)e+=String.fromCharCode(...r.subarray(n,n+32768));return btoa(e)},E=r=>{const e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=1)t[n]=e.codePointAt(n)??0;return t},i="$lunora.wire$",s=64,d=1024,w="__proto__",O=/^-?\d+$/,b={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},g={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},y=(r,e,t)=>{e===w?Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t},T=(r,e)=>{for(let t=0;t<r.length;t+=1){const n=Object.getOwnPropertyDescriptor(r,t);if(n!==void 0&&(!("value"in n)||n.value===void 0||e(n.value)))return!0}return!1},p=(r,e=0)=>{if(e>s)return!0;const t=typeof r;return r===null||t==="string"||t==="boolean"?!1:t==="number"?!Number.isFinite(r):t!=="object"||"toJSON"in r?!0:Array.isArray(r)?r.length>0&&r[0]===i?!0:T(r,n=>p(n,e+1)):!u(r)||Object.hasOwn(r,w)?!0:Object.keys(r).some(n=>{const o=Object.getOwnPropertyDescriptor(r,n);return o===void 0||!("value"in o)||o.value!==void 0&&p(o.value,e+1)})},j=r=>{const e=r.toString();if(e.length>d)throw new RangeError(`wire-codec: over-long bigint (max ${String(d)} digits)`);return[i,"bigint",e]},R=r=>Number.isNaN(r)?[i,"nan"]:r===1/0?[i,"inf"]:r===-1/0?[i,"-inf"]:r,S=(r,e)=>{const t=e(Object.fromEntries(Object.keys(r).map(c=>[c,r[c]]))),n=r,o=[i,"error",String(n.name),String(n.message),t];return r.cause!==void 0&&o.push(e(r.cause)),o},U=r=>{const e=r.constructor.name,t=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return e==="Uint8Array"?[i,"bytes",f(t)]:[i,"bytes",f(t),e]},I=(r,e)=>r instanceof Date?[i,"date",e(r.getTime())]:r instanceof Error?S(r,e):r instanceof URL?[i,"url",r.href]:r instanceof Map?[i,"map",[...r.entries()].map(([t,n])=>[e(t),e(n)])]:r instanceof Set?[i,"set",[...r].map(t=>e(t))]:r instanceof ArrayBuffer?[i,"bytes",f(new Uint8Array(r)),"ArrayBuffer"]:ArrayBuffer.isView(r)?U(r):void 0,N=(r,e)=>{const t=r.map(n=>e(n));return t.length>0&&t[0]===i?[i,"arr",t]:t},B=(r,e)=>{const t={};for(const n of Object.keys(r)){const o=r[n];o!==void 0&&y(t,n,e(o))}return t},m=(r,e=0)=>{if(e>s)throw new RangeError(`wire-codec: value nesting exceeds the ${String(s)}-level limit`);if(r===void 0)return[i,"undefined"];if(r===null)return r;if(typeof r=="bigint")return j(r);if(typeof r=="number")return R(r);if(typeof r!="object")return r;const t=o=>m(o,e+1),n=I(r,t);if(n!==void 0)return n;if(Array.isArray(r))return N(r,t);if(!u(r)){const o=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${o} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}return B(r,t)},_=r=>{const e=r[2];if(typeof e!="string"||e.length>d||!O.test(e))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${String(d)} digits)`);return BigInt(e)},P=(r,e)=>{const t=e(r[2]);if(typeof t!="number")throw new TypeError("wire-codec: malformed date — epoch must be a number");return new Date(t)},$=(r,e)=>{const t=r[2];return new Map(t.map(n=>{if(!Array.isArray(n)||n.length!==2)throw new TypeError("wire-codec: malformed map entry — expected a [key, value] pair");return[e(n[0]),e(n[1])]}))},D=r=>{const e=r[2];if(typeof e!="string")throw new TypeError("wire-codec: malformed url — href must be a string");return new URL(e)},k=(r,e)=>{const t=r[2],n=r[3];if(typeof t!="string"||typeof n!="string")throw new TypeError("wire-codec: malformed error — name and message must be strings");const o=(Object.hasOwn(g,t)?g[t]:void 0)??Error,c=new o(n);c.name!==t&&Object.defineProperty(c,"name",{configurable:!0,value:t,writable:!0});const a=e(r[4]);if(a===null||typeof a!="object"||Array.isArray(a))throw new TypeError("wire-codec: malformed error — props must be an object");for(const[h,l]of Object.entries(a))y(c,h,l);return r.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:e(r[5]),writable:!0}),c},C=r=>{const e=r[2];if(typeof e!="string")throw new TypeError("wire-codec: malformed bytes — payload must be a base64 string");const t=E(e);if(f(t)!==e)throw new TypeError("wire-codec: malformed bytes — payload must be canonical padded base64");const n=r[3]??"Uint8Array";if(n==="ArrayBuffer")return t.buffer.byteLength===t.byteLength?t.buffer:new Uint8Array(t).buffer;const o=Object.hasOwn(b,n)?b[n]:void 0;return o?new o(new Uint8Array(t).buffer):t},L=(r,e)=>{switch(r[1]){case"-inf":return-1/0;case"arr":return r[2].map(n=>e(n));case"bigint":return _(r);case"bytes":return C(r);case"date":return P(r,e);case"error":return k(r,e);case"inf":return 1/0;case"map":return $(r,e);case"nan":return Number.NaN;case"set":return new Set(r[2].map(n=>e(n)));case"undefined":return;case"url":return D(r);default:return r.map(n=>e(n))}},M=(r,e)=>{const t={};for(const n of Object.keys(r))y(t,n,e(r[n]));return t},A=(r,e=0)=>{if(e>s)throw new RangeError(`wire-codec: value nesting exceeds the ${String(s)}-level limit`);if(r===null||typeof r!="object")return r;const t=n=>A(n,e+1);if(Array.isArray(r)){const n=r;return n[0]===i?L(n,t):n.map(o=>t(o))}return M(r,t)},G=r=>{try{const e=A(JSON.parse(r));return u(e)?e:void 0}catch{return}},W=(r,e,t)=>{try{return m(t)}catch(n){throw new TypeError(`${r}: cannot encode args for '${e}' — ${n instanceof Error?n.message:String(n)}`,n instanceof Error?{cause:n}:void 0)}};export{i as WIRE_TAG,G as decodeDocument,A as decodeWire,W as encodeArgsOrThrow,m as encodeWire,u as isPlainObject,p as needsWireEncoding};
@@ -1 +1 @@
1
- import r from"./stableStringify-rlPCO-eR.mjs";import{encodeWire as t}from"./WIRE_TAG-DIesFsHE.mjs";import"./isPlainObject-UM7p1XXO.mjs";const a=e=>r(t(e));export{a as default};
1
+ import r from"./stableStringify-rlPCO-eR.mjs";import{encodeWire as t}from"./WIRE_TAG-D1pg4t5o.mjs";import"./isPlainObject-UM7p1XXO.mjs";const a=e=>r(t(e));export{a as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/wire",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "Wire codec and stable keys shared by every Lunora tier",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -1 +0,0 @@
1
- import{isPlainObject as u}from"./isPlainObject-UM7p1XXO.mjs";const f=r=>{let e="";for(let n=0;n<r.length;n+=32768)e+=String.fromCharCode(...r.subarray(n,n+32768));return btoa(e)},l=r=>{const e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n+=1)t[n]=e.codePointAt(n)??0;return t},i="$lunora.wire$",s=64,d=1024,w="__proto__",O=/^-?\d+$/,b={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},g={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},y=(r,e,t)=>{e===w?Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):r[e]=t},p=(r,e=0)=>{if(e>s)return!0;if(r===null)return!1;const t=typeof r;if(t==="string"||t==="boolean")return!1;if(t==="number")return!Number.isFinite(r);if(t!=="object")return!0;if(Array.isArray(r))return r.length>0&&r[0]===i?!0:r.some(n=>n===void 0||p(n,e+1));if(!u(r)||Object.hasOwn(r,w))return!0;for(const n of Object.keys(r)){const o=r[n];if(o!==void 0&&p(o,e+1))return!0}return!1},T=r=>{const e=r.toString();if(e.length>d)throw new RangeError(`wire-codec: over-long bigint (max ${String(d)} digits)`);return[i,"bigint",e]},j=r=>Number.isNaN(r)?[i,"nan"]:r===1/0?[i,"inf"]:r===-1/0?[i,"-inf"]:r,R=(r,e)=>{const t=e(Object.fromEntries(Object.keys(r).map(c=>[c,r[c]]))),n=r,o=[i,"error",String(n.name),String(n.message),t];return r.cause!==void 0&&o.push(e(r.cause)),o},S=r=>{const e=r.constructor.name,t=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return e==="Uint8Array"?[i,"bytes",f(t)]:[i,"bytes",f(t),e]},U=(r,e)=>r instanceof Date?[i,"date",e(r.getTime())]:r instanceof Error?R(r,e):r instanceof URL?[i,"url",r.href]:r instanceof Map?[i,"map",[...r.entries()].map(([t,n])=>[e(t),e(n)])]:r instanceof Set?[i,"set",[...r].map(t=>e(t))]:r instanceof ArrayBuffer?[i,"bytes",f(new Uint8Array(r)),"ArrayBuffer"]:ArrayBuffer.isView(r)?S(r):void 0,I=(r,e)=>{const t=r.map(n=>e(n));return t.length>0&&t[0]===i?[i,"arr",t]:t},B=(r,e)=>{const t={};for(const n of Object.keys(r)){const o=r[n];o!==void 0&&y(t,n,e(o))}return t},m=(r,e=0)=>{if(e>s)throw new RangeError(`wire-codec: value nesting exceeds the ${String(s)}-level limit`);if(r===void 0)return[i,"undefined"];if(r===null)return r;if(typeof r=="bigint")return T(r);if(typeof r=="number")return j(r);if(typeof r!="object")return r;const t=o=>m(o,e+1),n=U(r,t);if(n!==void 0)return n;if(Array.isArray(r))return I(r,t);if(!u(r)){const o=r.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${o} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}return B(r,t)},N=r=>{const e=r[2];if(typeof e!="string"||e.length>d||!O.test(e))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${String(d)} digits)`);return BigInt(e)},_=(r,e)=>{const t=e(r[2]);if(typeof t!="number")throw new TypeError("wire-codec: malformed date — epoch must be a number");return new Date(t)},$=(r,e)=>{const t=r[2];return new Map(t.map(n=>{if(!Array.isArray(n)||n.length!==2)throw new TypeError("wire-codec: malformed map entry — expected a [key, value] pair");return[e(n[0]),e(n[1])]}))},k=r=>{const e=r[2];if(typeof e!="string")throw new TypeError("wire-codec: malformed url — href must be a string");return new URL(e)},P=(r,e)=>{const t=r[2],n=r[3];if(typeof t!="string"||typeof n!="string")throw new TypeError("wire-codec: malformed error — name and message must be strings");const o=(Object.hasOwn(g,t)?g[t]:void 0)??Error,c=new o(n);c.name!==t&&Object.defineProperty(c,"name",{configurable:!0,value:t,writable:!0});const a=e(r[4]);if(a===null||typeof a!="object"||Array.isArray(a))throw new TypeError("wire-codec: malformed error — props must be an object");for(const[h,E]of Object.entries(a))y(c,h,E);return r.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:e(r[5]),writable:!0}),c},D=r=>{const e=r[2];if(typeof e!="string")throw new TypeError("wire-codec: malformed bytes — payload must be a base64 string");const t=l(e);if(f(t)!==e)throw new TypeError("wire-codec: malformed bytes — payload must be canonical padded base64");const n=r[3]??"Uint8Array";if(n==="ArrayBuffer")return t.buffer.byteLength===t.byteLength?t.buffer:new Uint8Array(t).buffer;const o=Object.hasOwn(b,n)?b[n]:void 0;return o?new o(new Uint8Array(t).buffer):t},C=(r,e)=>{switch(r[1]){case"-inf":return-1/0;case"arr":return r[2].map(n=>e(n));case"bigint":return N(r);case"bytes":return D(r);case"date":return _(r,e);case"error":return P(r,e);case"inf":return 1/0;case"map":return $(r,e);case"nan":return Number.NaN;case"set":return new Set(r[2].map(n=>e(n)));case"undefined":return;case"url":return k(r);default:return r.map(n=>e(n))}},L=(r,e)=>{const t={};for(const n of Object.keys(r))y(t,n,e(r[n]));return t},A=(r,e=0)=>{if(e>s)throw new RangeError(`wire-codec: value nesting exceeds the ${String(s)}-level limit`);if(r===null||typeof r!="object")return r;const t=n=>A(n,e+1);if(Array.isArray(r)){const n=r;return n[0]===i?C(n,t):n.map(o=>t(o))}return L(r,t)},F=r=>{try{const e=A(JSON.parse(r));return u(e)?e:void 0}catch{return}},G=(r,e,t)=>{try{return m(t)}catch(n){throw new TypeError(`${r}: cannot encode args for '${e}' — ${n instanceof Error?n.message:String(n)}`,n instanceof Error?{cause:n}:void 0)}};export{i as WIRE_TAG,F as decodeDocument,A as decodeWire,G as encodeArgsOrThrow,m as encodeWire,u as isPlainObject,p as needsWireEncoding};