@synnaxlabs/x 0.26.0 → 0.27.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/.turbo/turbo-build.log +17 -15
- package/dist/deep.cjs +1 -1
- package/dist/deep.js +39 -39
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/kv.cjs +1 -1
- package/dist/kv.js +2 -4
- package/dist/observe.cjs +1 -1
- package/dist/observe.js +26 -16
- package/dist/path-DLggFlTl.cjs +1 -0
- package/dist/path-DsFnOSKR.js +71 -0
- package/dist/{series-CNcMldp_.cjs → series-BVB6n18P.cjs} +7 -7
- package/dist/{series-CaeAWaDJ.js → series-DMUGN3Sl.js} +64 -49
- package/dist/src/binary/encoder.d.ts +0 -1
- package/dist/src/change/change.d.ts +0 -1
- package/dist/src/clamp/clamp.d.ts +0 -1
- package/dist/src/compare/compare.d.ts +0 -1
- package/dist/src/control/control.d.ts +0 -1
- package/dist/src/control/index.d.ts.map +1 -1
- package/dist/src/deep/delete.d.ts +0 -1
- package/dist/src/deep/equal.d.ts +0 -1
- package/dist/src/deep/merge.d.ts +0 -1
- package/dist/src/deep/path.d.ts +76 -2
- package/dist/src/deep/path.d.ts.map +1 -1
- package/dist/src/errors/errors.d.ts.map +1 -1
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/id/id.d.ts +0 -1
- package/dist/src/identity.d.ts +0 -1
- package/dist/src/kv/types.d.ts +16 -0
- package/dist/src/kv/types.d.ts.map +1 -1
- package/dist/src/migrate/migrate.d.ts +0 -1
- package/dist/src/mock/MockGLBufferController.d.ts +5 -6
- package/dist/src/mock/MockGLBufferController.d.ts.map +1 -1
- package/dist/src/numeric/index.d.ts.map +1 -1
- package/dist/src/numeric/numeric.d.ts.map +1 -1
- package/dist/src/observe/observe.d.ts +24 -2
- package/dist/src/observe/observe.d.ts.map +1 -1
- package/dist/src/primitive.d.ts +1 -2
- package/dist/src/primitive.d.ts.map +1 -1
- package/dist/src/record.d.ts +0 -1
- package/dist/src/renderable.d.ts +0 -1
- package/dist/src/runtime/os.d.ts +0 -1
- package/dist/src/search.d.ts +0 -1
- package/dist/src/spatial/base.d.ts +0 -1
- package/dist/src/spatial/bounds/bounds.d.ts +0 -1
- package/dist/src/spatial/box/box.d.ts +0 -1
- package/dist/src/spatial/dimensions/dimensions.d.ts +0 -1
- package/dist/src/spatial/direction/direction.d.ts +0 -1
- package/dist/src/spatial/location/location.d.ts +0 -1
- package/dist/src/spatial/position/position.d.ts +0 -1
- package/dist/src/spatial/scale/scale.d.ts +0 -1
- package/dist/src/spatial/xy/xy.d.ts +0 -1
- package/dist/src/telem/generate.d.ts +0 -1
- package/dist/src/telem/series.d.ts +0 -1
- package/dist/src/telem/telem.d.ts +19 -1
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/src/zodutil/zodutil.d.ts +0 -1
- package/dist/telem.cjs +1 -1
- package/dist/telem.js +1 -1
- package/dist/types-BpAJW2TM.js +11 -0
- package/dist/types-zRwnQ1hc.cjs +1 -0
- package/dist/zodutil.cjs +1 -1
- package/dist/zodutil.js +1 -1
- package/package.json +1 -1
- package/src/caseconv/caseconv.spec.ts +9 -0
- package/src/control/index.ts +9 -0
- package/src/deep/path.spec.ts +29 -0
- package/src/deep/path.ts +94 -5
- package/src/errors/errors.ts +9 -0
- package/src/errors/index.ts +9 -0
- package/src/kv/types.ts +13 -0
- package/src/mock/MockGLBufferController.ts +7 -7
- package/src/numeric/index.ts +9 -0
- package/src/numeric/numeric.ts +9 -0
- package/src/observe/observe.ts +30 -1
- package/src/primitive.ts +1 -1
- package/src/telem/series.spec.ts +14 -0
- package/src/telem/series.ts +1 -1
- package/src/telem/telem.ts +26 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/path-Coj1BKMh.cjs +0 -1
- package/dist/path-DH9iaDDf.js +0 -58
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var K=Object.defineProperty;var j=(f,t,e)=>t in f?K(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e;var s=(f,t,e)=>j(f,typeof t!="symbol"?t+"":t,e);const L=require("./index-tYmAULd8.cjs"),H=require("./index-BGz7XJIe.cjs"),X=require("./index-CvHP07Bs.cjs"),z=require("./bounds-ZZc1c-_Z.cjs");require("./box-C6r0YnKB.cjs");require("./dimensions-zMcb9pMk.cjs");require("./base-B48bPNx5.cjs");require("./location-55G2uRZN.cjs");require("./scale-COuYv97b.cjs");require("./xy-cP-FXJtR.cjs");const c=require("zod");let Q=(f,t=21)=>(e=t)=>{let r="",u=e;for(;u--;)r+=f[Math.random()*f.length|0];return r};const _="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Z=Q(_,11),tt=Object.freeze(Object.defineProperty({__proto__:null,id:Z},Symbol.toStringTag,{value:"Module"})),k=(f,t)=>{const e=new y(t);if(![w.DAY,w.HOUR,w.MINUTE,w.SECOND,w.MILLISECOND,w.MICROSECOND,w.NANOSECOND].some(u=>u.equals(e)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=f.valueOf()%e.valueOf();return f instanceof y?new y(r):new w(r)},i=class i{constructor(t,e="UTC"){s(this,"value");s(this,"encodeValue",!0);if(t==null)this.value=i.now().valueOf();else if(t instanceof Date)this.value=BigInt(t.getTime())*i.MILLISECOND.valueOf();else if(typeof t=="string")this.value=i.parseDateTimeString(t,e).valueOf();else if(Array.isArray(t))this.value=i.parseDate(t);else{let r=BigInt(0);t instanceof Number&&(t=t.valueOf()),e==="local"&&(r=i.utcOffset.valueOf()),typeof t=="number"&&(isFinite(t)?t=Math.trunc(t):(isNaN(t)&&(t=0),t===1/0?t=i.MAX:t=i.MIN)),this.value=BigInt(t.valueOf())+r}}static parseDate([t=1970,e=1,r=1]){const u=new Date(t,e-1,r,0,0,0,0);return new i(BigInt(u.getTime())*i.MILLISECOND.valueOf()).truncate(i.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(t,e="UTC"){const[r,u,h]=t.split(":");let g="00",N="00";h!=null&&([g,N]=h.split("."));let O=i.hours(parseInt(r??"00",10)).add(i.minutes(parseInt(u??"00",10))).add(i.seconds(parseInt(g??"00",10))).add(i.milliseconds(parseInt(N??"00",10)));return e==="local"&&(O=O.add(i.utcOffset)),O.valueOf()}static parseDateTimeString(t,e="UTC"){if(!t.includes("/")&&!t.includes("-"))return i.parseTimeString(t,e);const r=new Date(t);return t.includes(":")||r.setUTCHours(0,0,0,0),new i(BigInt(r.getTime())*i.MILLISECOND.valueOf(),e).valueOf()}fString(t="ISO",e="UTC"){switch(t){case"ISODate":return this.toISOString(e).slice(0,10);case"ISOTime":return this.toISOString(e).slice(11,23);case"time":return this.timeString(!1,e);case"preciseTime":return this.timeString(!0,e);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,e)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,e)}`;default:return this.toISOString(e)}}toISOString(t="UTC"){return t==="UTC"?this.date().toISOString():this.sub(i.utcOffset).date().toISOString()}timeString(t=!1,e="UTC"){const r=this.toISOString(e);return t?r.slice(11,23):r.slice(11,19)}dateString(){const t=this.date(),e=t.toLocaleString("default",{month:"short"}),r=t.toLocaleString("default",{day:"numeric"});return`${e} ${r}`}static get utcOffset(){return new w(BigInt(new Date().getTimezoneOffset())*i.MINUTE.valueOf())}static since(t){return new i().span(t)}date(){return new Date(this.milliseconds())}equals(t){return this.valueOf()===new i(t).valueOf()}span(t){return this.range(t).span}range(t){return new M(this,t).makeValid()}spanRange(t){return this.range(this.add(t)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(t){return this.valueOf()>new i(t).valueOf()}afterEq(t){return this.valueOf()>=new i(t).valueOf()}before(t){return this.valueOf()<new i(t).valueOf()}beforeEq(t){return this.valueOf()<=new i(t).valueOf()}add(t){return new i(this.valueOf()+BigInt(t.valueOf()))}sub(t){return new i(this.valueOf()-BigInt(t.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(i.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(t){return k(this,t)}get isToday(){return this.truncate(w.DAY).equals(i.now().truncate(w.DAY))}truncate(t){return this.sub(this.remainder(t))}static now(){return new i(new Date)}static max(...t){let e=i.MIN;for(const r of t){const u=new i(r);u.after(e)&&(e=u)}return e}static min(...t){let e=i.MAX;for(const r of t){const u=new i(r);u.before(e)&&(e=u)}return e}static nanoseconds(t){return new i(t)}static microseconds(t){return i.nanoseconds(t*1e3)}static milliseconds(t){return i.microseconds(t*1e3)}static seconds(t){return i.milliseconds(t*1e3)}static minutes(t){return i.seconds(t*60)}static hours(t){return i.minutes(t*60)}static days(t){return i.hours(t*24)}};s(i,"NANOSECOND",i.nanoseconds(1)),s(i,"MICROSECOND",i.microseconds(1)),s(i,"MILLISECOND",i.milliseconds(1)),s(i,"SECOND",i.seconds(1)),s(i,"MINUTE",i.minutes(1)),s(i,"HOUR",i.hours(1)),s(i,"DAY",i.days(1)),s(i,"MAX",new i((1n<<63n)-1n)),s(i,"MIN",new i(0)),s(i,"ZERO",new i(0)),s(i,"z",c.z.union([c.z.object({value:c.z.bigint()}).transform(t=>new i(t.value)),c.z.string().transform(t=>new i(BigInt(t))),c.z.instanceof(Number).transform(t=>new i(t)),c.z.number().transform(t=>new i(t)),c.z.instanceof(i)]));let y=i;const a=class a{constructor(t){s(this,"value");s(this,"encodeValue",!0);typeof t=="number"&&(t=Math.trunc(t.valueOf())),this.value=BigInt(t.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(t){return this.valueOf()<new a(t).valueOf()}greaterThan(t){return this.valueOf()>new a(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new a(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new a(t).valueOf()}remainder(t){return k(this,t)}truncate(t){return new a(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(){const t=this.truncate(a.DAY),e=this.truncate(a.HOUR),r=this.truncate(a.MINUTE),u=this.truncate(a.SECOND),h=this.truncate(a.MILLISECOND),g=this.truncate(a.MICROSECOND),N=this.truncate(a.NANOSECOND),O=t,S=e.sub(t),p=r.sub(e),o=u.sub(r),B=h.sub(u),U=g.sub(h),q=N.sub(g);let A="";return O.isZero||(A+=`${O.days}d `),S.isZero||(A+=`${S.hours}h `),p.isZero||(A+=`${p.minutes}m `),o.isZero||(A+=`${o.seconds}s `),B.isZero||(A+=`${B.milliseconds}ms `),U.isZero||(A+=`${U.microseconds}µs `),q.isZero||(A+=`${q.nanoseconds}ns`),A.trim()}get days(){return Number(this.valueOf())/Number(a.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(a.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(a.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(a.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(a.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(a.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(t){return this.valueOf()===new a(t).valueOf()}add(t){return new a(this.valueOf()+new a(t).valueOf())}sub(t){return new a(this.valueOf()-new a(t).valueOf())}static nanoseconds(t=1){return new a(t)}static microseconds(t=1){return a.nanoseconds(t*1e3)}static milliseconds(t=1){return a.microseconds(t*1e3)}static seconds(t=1){return a.milliseconds(t*1e3)}static minutes(t){return a.seconds(t.valueOf()*60)}static hours(t){return a.minutes(t*60)}static days(t){return a.hours(t*24)}};s(a,"NANOSECOND",a.nanoseconds(1)),s(a,"MICROSECOND",a.microseconds(1)),s(a,"MILLISECOND",a.milliseconds(1)),s(a,"SECOND",a.seconds(1)),s(a,"MINUTE",a.minutes(1)),s(a,"HOUR",a.hours(1)),s(a,"DAY",a.days(1)),s(a,"MAX",new a((1n<<63n)-1n)),s(a,"MIN",new a(0)),s(a,"ZERO",new a(0)),s(a,"z",c.z.union([c.z.object({value:c.z.bigint()}).transform(t=>new a(t.value)),c.z.string().transform(t=>new a(BigInt(t))),c.z.instanceof(Number).transform(t=>new a(t)),c.z.number().transform(t=>new a(t)),c.z.instanceof(a)]));let w=a;const v=class v extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new v(t).valueOf()}get period(){return w.seconds(1/this.valueOf())}sampleCount(t){return new w(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new I(e).valueOf()}span(t){return w.seconds(t/this.valueOf())}byteSpan(t,e){return this.span(t.valueOf()/e.valueOf())}static hz(t){return new v(t)}static khz(t){return v.hz(t*1e3)}};s(v,"z",c.z.union([c.z.number().transform(t=>new v(t)),c.z.instanceof(Number).transform(t=>new v(t)),c.z.instanceof(v)]));let x=v;const m=class m extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}length(t){return t.valueOf()/this.valueOf()}size(t){return new C(t*this.valueOf())}};s(m,"UNKNOWN",new m(0)),s(m,"BIT128",new m(16)),s(m,"BIT64",new m(8)),s(m,"BIT32",new m(4)),s(m,"BIT16",new m(2)),s(m,"BIT8",new m(1)),s(m,"z",c.z.union([c.z.number().transform(t=>new m(t)),c.z.instanceof(Number).transform(t=>new m(t)),c.z.instanceof(m)]));let I=m;const T=class T{constructor(t,e){s(this,"start");s(this,"end");typeof t=="object"&&"start"in t?(this.start=new y(t.start),this.end=new y(t.end)):(this.start=new y(t),this.end=new y(e))}get span(){return new w(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new T(this.end,this.start)}equals(t){return this.start.equals(t.start)&&this.end.equals(t.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(t,e=w.ZERO){t=t.makeValid();const r=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(r.start)||r.end.equals(t.start))return!1;const u=y.max(r.start,t.start),h=y.min(r.end,t.end);return h.before(u)?!1:new w(h.sub(u)).greaterThanOrEqual(e)}roughlyEquals(t,e){let r=this.start.sub(t.start).valueOf(),u=this.end.sub(t.end).valueOf();return r<0&&(r=-r),u<0&&(u=-u),r<=e.valueOf()&&u<=e.valueOf()}contains(t){return t instanceof T?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new T(this.start,this.end);return t.start.after(this.start)&&(e.start=t.start),t.start.after(this.end)&&(e.end=t.start),t.end.before(this.end)&&(e.end=t.end),t.end.before(this.start)&&(e.start=t.end),e}};s(T,"MAX",new T(y.MIN,y.MAX)),s(T,"MIN",new T(y.MAX,y.MIN)),s(T,"ZERO",new T(y.ZERO,y.ZERO)),s(T,"z",c.z.union([c.z.object({start:y.z,end:y.z}).transform(t=>new T(t.start,t.end)),c.z.instanceof(T)]));let M=T;const n=class n extends String{constructor(t){if(t instanceof n||typeof t=="string"||typeof t.valueOf()=="string"){super(t.valueOf());return}else{const e=n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(e!=null){super(e.valueOf());return}}throw super(n.UNKNOWN.valueOf()),new Error(`unable to find data type for ${t.toString()}`)}get Array(){const t=n.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(t){return this.valueOf()===t.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(n.JSON)||this.equals(n.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(n.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=n.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}canSafelyCastTo(t){return this.equals(t)?!0:this.isVariable&&!t.isVariable||!this.isVariable&&t.isVariable?!1:this.isFloat&&t.isInteger||this.isInteger&&t.isFloat?this.density.valueOf()<t.density.valueOf():this.isFloat&&t.isFloat||this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf():!1}canCastTo(t){return this.isNumeric&&t.isNumeric?!0:this.equals(t)}checkArray(t){return t.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return n.BIG_INT_TYPES.some(t=>t.equals(this))}};s(n,"UNKNOWN",new n("unknown")),s(n,"FLOAT64",new n("float64")),s(n,"FLOAT32",new n("float32")),s(n,"INT64",new n("int64")),s(n,"INT32",new n("int32")),s(n,"INT16",new n("int16")),s(n,"INT8",new n("int8")),s(n,"UINT64",new n("uint64")),s(n,"UINT32",new n("uint32")),s(n,"UINT16",new n("uint16")),s(n,"UINT8",new n("uint8")),s(n,"BOOLEAN",n.UINT8),s(n,"TIMESTAMP",new n("timestamp")),s(n,"UUID",new n("uuid")),s(n,"STRING",new n("string")),s(n,"JSON",new n("json")),s(n,"ARRAY_CONSTRUCTORS",new Map([[n.UINT8.toString(),Uint8Array],[n.UINT16.toString(),Uint16Array],[n.UINT32.toString(),Uint32Array],[n.UINT64.toString(),BigUint64Array],[n.FLOAT32.toString(),Float32Array],[n.FLOAT64.toString(),Float64Array],[n.INT8.toString(),Int8Array],[n.INT16.toString(),Int16Array],[n.INT32.toString(),Int32Array],[n.INT64.toString(),BigInt64Array],[n.TIMESTAMP.toString(),BigInt64Array],[n.STRING.toString(),Uint8Array],[n.JSON.toString(),Uint8Array],[n.UUID.toString(),Uint8Array]])),s(n,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,n.UINT8],[Uint16Array.name,n.UINT16],[Uint32Array.name,n.UINT32],[BigUint64Array.name,n.UINT64],[Float32Array.name,n.FLOAT32],[Float64Array.name,n.FLOAT64],[Int8Array.name,n.INT8],[Int16Array.name,n.INT16],[Int32Array.name,n.INT32],[BigInt64Array.name,n.INT64]])),s(n,"DENSITIES",new Map([[n.UINT8.toString(),I.BIT8],[n.UINT16.toString(),I.BIT16],[n.UINT32.toString(),I.BIT32],[n.UINT64.toString(),I.BIT64],[n.FLOAT32.toString(),I.BIT32],[n.FLOAT64.toString(),I.BIT64],[n.INT8.toString(),I.BIT8],[n.INT16.toString(),I.BIT16],[n.INT32.toString(),I.BIT32],[n.INT64.toString(),I.BIT64],[n.TIMESTAMP.toString(),I.BIT64],[n.STRING.toString(),I.UNKNOWN],[n.JSON.toString(),I.UNKNOWN],[n.UUID.toString(),I.BIT128]])),s(n,"ALL",[n.UNKNOWN,n.FLOAT64,n.FLOAT32,n.INT64,n.INT32,n.INT16,n.INT8,n.UINT64,n.UINT32,n.UINT16,n.UINT8,n.TIMESTAMP,n.UUID,n.STRING,n.JSON]),s(n,"BIG_INT_TYPES",[n.INT64,n.UINT64,n.TIMESTAMP]),s(n,"z",c.z.union([c.z.string().transform(t=>new n(t)),c.z.instanceof(n)]));let d=n;const l=class l extends Number{constructor(t){super(t.valueOf())}largerThan(t){return this.valueOf()>t.valueOf()}smallerThan(t){return this.valueOf()<t.valueOf()}add(t){return l.bytes(this.valueOf()+t.valueOf())}sub(t){return l.bytes(this.valueOf()-t.valueOf())}truncate(t){return new l(Math.trunc(this.valueOf()/t.valueOf())*t.valueOf())}remainder(t){return l.bytes(this.valueOf()%t.valueOf())}get gigabytes(){return this.valueOf()/l.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/l.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/l.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/l.TERABYTE.valueOf()}toString(){const t=this.truncate(l.TERABYTE),e=this.truncate(l.GIGABYTE),r=this.truncate(l.MEGABYTE),u=this.truncate(l.KILOBYTE),h=this.truncate(l.BYTE),g=t,N=e.sub(t),O=r.sub(e),S=u.sub(r),p=h.sub(u);let o="";return g.isZero||(o+=`${g.terabytes}TB `),N.isZero||(o+=`${N.gigabytes}GB `),O.isZero||(o+=`${O.megabytes}MB `),S.isZero||(o+=`${S.kilobytes}KB `),(!p.isZero||o==="")&&(o+=`${p.valueOf()}B`),o.trim()}static bytes(t=1){return new l(t)}static kilobytes(t=1){return l.bytes(t.valueOf()*1e3)}static megabytes(t=1){return l.kilobytes(t.valueOf()*1e3)}static gigabytes(t=1){return l.megabytes(t.valueOf()*1e3)}static terabytes(t){return l.gigabytes(t.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};s(l,"BYTE",new l(1)),s(l,"KILOBYTE",l.kilobytes(1)),s(l,"MEGABYTE",l.megabytes(1)),s(l,"GIGABYTE",l.gigabytes(1)),s(l,"TERABYTE",l.terabytes(1)),s(l,"ZERO",new l(0)),s(l,"z",c.z.union([c.z.number().transform(t=>new l(t)),c.z.instanceof(l)]));let C=l;const et=c.z.union([c.z.instanceof(Uint8Array),c.z.instanceof(Uint16Array),c.z.instanceof(Uint32Array),c.z.instanceof(BigUint64Array),c.z.instanceof(Float32Array),c.z.instanceof(Float64Array),c.z.instanceof(Int8Array),c.z.instanceof(Int16Array),c.z.instanceof(Int32Array),c.z.instanceof(BigInt64Array)]),D=f=>{const t=typeof f;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||f instanceof y||f instanceof w||f instanceof Date},J=(f,t,e,r=0)=>f.usesBigInt&&!t.usesBigInt?Number(e)-Number(r):!f.usesBigInt&&t.usesBigInt?BigInt(e)-BigInt(r):R(e,-r),W=f=>f==null?!1:Array.isArray(f)||f instanceof ArrayBuffer||ArrayBuffer.isView(f)&&!(f instanceof DataView)||f instanceof b?!0:D(f),E=-1;class b{constructor(t){s(this,"key","");s(this,"isSynnaxSeries",!0);s(this,"dataType");s(this,"sampleOffset");s(this,"gl");s(this,"_data");s(this,"_timeRange");s(this,"alignment",0n);s(this,"_cachedMin");s(this,"_cachedMax");s(this,"writePos",E);s(this,"_refCount",0);s(this,"_cachedLength");W(t)&&(t={data:t});const{dataType:e,timeRange:r,sampleOffset:u=0,glBufferUsage:h="static",alignment:g=0n,key:N=Z()}=t,{data:O}=t;if(O instanceof b||typeof O=="object"&&"isSynnaxSeries"in O&&O.isSynnaxSeries===!0){const o=O;this.key=o.key,this.dataType=o.dataType,this.sampleOffset=o.sampleOffset,this.gl=o.gl,this._data=o._data,this._timeRange=o._timeRange,this.alignment=o.alignment,this._cachedMin=o._cachedMin,this._cachedMax=o._cachedMax,this.writePos=o.writePos,this._refCount=o._refCount,this._cachedLength=o._cachedLength;return}const S=D(O),p=Array.isArray(O);if(e!=null)this.dataType=new d(e);else{if(O instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(p||S){let o=O;if(!S){if(O.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");o=O[0]}if(typeof o=="string")this.dataType=d.STRING;else if(typeof o=="number")this.dataType=d.FLOAT64;else if(typeof o=="bigint")this.dataType=d.INT64;else if(typeof o=="boolean")this.dataType=d.BOOLEAN;else if(o instanceof y||o instanceof Date||o instanceof y)this.dataType=d.TIMESTAMP;else if(typeof o=="object")this.dataType=d.JSON;else throw new Error(`cannot infer data type of ${typeof o} when constructing a Series from a JS array`)}else this.dataType=new d(O)}if(!p&&!S)this._data=O;else{let o=S?[O]:O;const B=o[0];(B instanceof y||B instanceof Date||B instanceof w)&&(o=o.map(U=>new y(U).valueOf())),this.dataType.equals(d.STRING)?(this._cachedLength=o.length,this._data=new TextEncoder().encode(o.join(`
|
|
1
|
+
"use strict";var K=Object.defineProperty;var j=(f,t,e)=>t in f?K(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e;var s=(f,t,e)=>j(f,typeof t!="symbol"?t+"":t,e);const L=require("./index-tYmAULd8.cjs"),H=require("./index-BGz7XJIe.cjs"),X=require("./index-CvHP07Bs.cjs"),z=require("./bounds-ZZc1c-_Z.cjs");require("./box-C6r0YnKB.cjs");require("./dimensions-zMcb9pMk.cjs");require("./base-B48bPNx5.cjs");require("./location-55G2uRZN.cjs");require("./scale-COuYv97b.cjs");require("./xy-cP-FXJtR.cjs");const c=require("zod");let Q=(f,t=21)=>(e=t)=>{let r="",u=e;for(;u--;)r+=f[Math.random()*f.length|0];return r};const _="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Z=Q(_,11),tt=Object.freeze(Object.defineProperty({__proto__:null,id:Z},Symbol.toStringTag,{value:"Module"})),k=(f,t)=>{const e=new y(t);if(![m.DAY,m.HOUR,m.MINUTE,m.SECOND,m.MILLISECOND,m.MICROSECOND,m.NANOSECOND].some(u=>u.equals(e)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=f.valueOf()%e.valueOf();return f instanceof y?new y(r):new m(r)},i=class i{constructor(t,e="UTC"){s(this,"value");s(this,"encodeValue",!0);if(t==null)this.value=i.now().valueOf();else if(t instanceof Date)this.value=BigInt(t.getTime())*i.MILLISECOND.valueOf();else if(typeof t=="string")this.value=i.parseDateTimeString(t,e).valueOf();else if(Array.isArray(t))this.value=i.parseDate(t);else{let r=BigInt(0);t instanceof Number&&(t=t.valueOf()),e==="local"&&(r=i.utcOffset.valueOf()),typeof t=="number"&&(isFinite(t)?t=Math.trunc(t):(isNaN(t)&&(t=0),t===1/0?t=i.MAX:t=i.MIN)),this.value=BigInt(t.valueOf())+r}}static parseDate([t=1970,e=1,r=1]){const u=new Date(t,e-1,r,0,0,0,0);return new i(BigInt(u.getTime())*i.MILLISECOND.valueOf()).truncate(i.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(t,e="UTC"){const[r,u,d]=t.split(":");let g="00",S="00";d!=null&&([g,S]=d.split("."));let O=i.hours(parseInt(r??"00",10)).add(i.minutes(parseInt(u??"00",10))).add(i.seconds(parseInt(g??"00",10))).add(i.milliseconds(parseInt(S??"00",10)));return e==="local"&&(O=O.add(i.utcOffset)),O.valueOf()}static parseDateTimeString(t,e="UTC"){if(!t.includes("/")&&!t.includes("-"))return i.parseTimeString(t,e);const r=new Date(t);return t.includes(":")||r.setUTCHours(0,0,0,0),new i(BigInt(r.getTime())*i.MILLISECOND.valueOf(),e).valueOf()}fString(t="ISO",e="UTC"){switch(t){case"ISODate":return this.toISOString(e).slice(0,10);case"ISOTime":return this.toISOString(e).slice(11,23);case"time":return this.timeString(!1,e);case"preciseTime":return this.timeString(!0,e);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,e)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,e)}`;default:return this.toISOString(e)}}toISOString(t="UTC"){return t==="UTC"?this.date().toISOString():this.sub(i.utcOffset).date().toISOString()}timeString(t=!1,e="UTC"){const r=this.toISOString(e);return t?r.slice(11,23):r.slice(11,19)}dateString(){const t=this.date(),e=t.toLocaleString("default",{month:"short"}),r=t.toLocaleString("default",{day:"numeric"});return`${e} ${r}`}static get utcOffset(){return new m(BigInt(new Date().getTimezoneOffset())*i.MINUTE.valueOf())}static since(t){return new i().span(t)}date(){return new Date(this.milliseconds())}equals(t){return this.valueOf()===new i(t).valueOf()}span(t){return this.range(t).span}range(t){return new M(this,t).makeValid()}spanRange(t){return this.range(this.add(t)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(t){return this.valueOf()>new i(t).valueOf()}afterEq(t){return this.valueOf()>=new i(t).valueOf()}before(t){return this.valueOf()<new i(t).valueOf()}beforeEq(t){return this.valueOf()<=new i(t).valueOf()}add(t){return new i(this.valueOf()+BigInt(t.valueOf()))}sub(t){return new i(this.valueOf()-BigInt(t.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(i.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(t){return k(this,t)}get isToday(){return this.truncate(m.DAY).equals(i.now().truncate(m.DAY))}truncate(t){return this.sub(this.remainder(t))}static now(){return new i(new Date)}static max(...t){let e=i.MIN;for(const r of t){const u=new i(r);u.after(e)&&(e=u)}return e}static min(...t){let e=i.MAX;for(const r of t){const u=new i(r);u.before(e)&&(e=u)}return e}static nanoseconds(t){return new i(t)}static microseconds(t){return i.nanoseconds(t*1e3)}static milliseconds(t){return i.microseconds(t*1e3)}static seconds(t){return i.milliseconds(t*1e3)}static minutes(t){return i.seconds(t*60)}static hours(t){return i.minutes(t*60)}static days(t){return i.hours(t*24)}};s(i,"NANOSECOND",i.nanoseconds(1)),s(i,"MICROSECOND",i.microseconds(1)),s(i,"MILLISECOND",i.milliseconds(1)),s(i,"SECOND",i.seconds(1)),s(i,"MINUTE",i.minutes(1)),s(i,"HOUR",i.hours(1)),s(i,"DAY",i.days(1)),s(i,"MAX",new i((1n<<63n)-1n)),s(i,"MIN",new i(0)),s(i,"ZERO",new i(0)),s(i,"z",c.z.union([c.z.object({value:c.z.bigint()}).transform(t=>new i(t.value)),c.z.string().transform(t=>new i(BigInt(t))),c.z.instanceof(Number).transform(t=>new i(t)),c.z.number().transform(t=>new i(t)),c.z.instanceof(i)]));let y=i;const a=class a{constructor(t){s(this,"value");s(this,"encodeValue",!0);typeof t=="number"&&(t=Math.trunc(t.valueOf())),this.value=BigInt(t.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(t){return this.valueOf()<new a(t).valueOf()}greaterThan(t){return this.valueOf()>new a(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new a(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new a(t).valueOf()}remainder(t){return k(this,t)}truncate(t){return new a(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(){const t=this.truncate(a.DAY),e=this.truncate(a.HOUR),r=this.truncate(a.MINUTE),u=this.truncate(a.SECOND),d=this.truncate(a.MILLISECOND),g=this.truncate(a.MICROSECOND),S=this.truncate(a.NANOSECOND),O=t,N=e.sub(t),p=r.sub(e),o=u.sub(r),B=d.sub(u),U=g.sub(d),q=S.sub(g);let A="";return O.isZero||(A+=`${O.days}d `),N.isZero||(A+=`${N.hours}h `),p.isZero||(A+=`${p.minutes}m `),o.isZero||(A+=`${o.seconds}s `),B.isZero||(A+=`${B.milliseconds}ms `),U.isZero||(A+=`${U.microseconds}µs `),q.isZero||(A+=`${q.nanoseconds}ns`),A.trim()}get days(){return Number(this.valueOf())/Number(a.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(a.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(a.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(a.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(a.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(a.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(t){return this.valueOf()===new a(t).valueOf()}add(t){return new a(this.valueOf()+new a(t).valueOf())}sub(t){return new a(this.valueOf()-new a(t).valueOf())}static nanoseconds(t=1){return new a(t)}static microseconds(t=1){return a.nanoseconds(t*1e3)}static milliseconds(t=1){return a.microseconds(t*1e3)}static seconds(t=1){return a.milliseconds(t*1e3)}static minutes(t){return a.seconds(t.valueOf()*60)}static hours(t){return a.minutes(t*60)}static days(t){return a.hours(t*24)}};s(a,"NANOSECOND",a.nanoseconds(1)),s(a,"MICROSECOND",a.microseconds(1)),s(a,"MILLISECOND",a.milliseconds(1)),s(a,"SECOND",a.seconds(1)),s(a,"MINUTE",a.minutes(1)),s(a,"HOUR",a.hours(1)),s(a,"DAY",a.days(1)),s(a,"MAX",new a((1n<<63n)-1n)),s(a,"MIN",new a(0)),s(a,"ZERO",new a(0)),s(a,"z",c.z.union([c.z.object({value:c.z.bigint()}).transform(t=>new a(t.value)),c.z.string().transform(t=>new a(BigInt(t))),c.z.instanceof(Number).transform(t=>new a(t)),c.z.number().transform(t=>new a(t)),c.z.instanceof(a)]));let m=a;const v=class v extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new v(t).valueOf()}get period(){return m.seconds(1/this.valueOf())}sampleCount(t){return new m(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new I(e).valueOf()}span(t){return m.seconds(t/this.valueOf())}byteSpan(t,e){return this.span(t.valueOf()/e.valueOf())}static hz(t){return new v(t)}static khz(t){return v.hz(t*1e3)}};s(v,"z",c.z.union([c.z.number().transform(t=>new v(t)),c.z.instanceof(Number).transform(t=>new v(t)),c.z.instanceof(v)]));let x=v;const w=class w extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}length(t){return t.valueOf()/this.valueOf()}size(t){return new C(t*this.valueOf())}};s(w,"UNKNOWN",new w(0)),s(w,"BIT128",new w(16)),s(w,"BIT64",new w(8)),s(w,"BIT32",new w(4)),s(w,"BIT16",new w(2)),s(w,"BIT8",new w(1)),s(w,"z",c.z.union([c.z.number().transform(t=>new w(t)),c.z.instanceof(Number).transform(t=>new w(t)),c.z.instanceof(w)]));let I=w;const b=class b{constructor(t,e){s(this,"start");s(this,"end");typeof t=="object"&&"start"in t?(this.start=new y(t.start),this.end=new y(t.end)):(this.start=new y(t),this.end=new y(e))}get span(){return new m(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new b(this.end,this.start)}equals(t){return this.start.equals(t.start)&&this.end.equals(t.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(t,e=m.ZERO){t=t.makeValid();const r=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(r.start)||r.end.equals(t.start))return!1;const u=y.max(r.start,t.start),d=y.min(r.end,t.end);return d.before(u)?!1:new m(d.sub(u)).greaterThanOrEqual(e)}roughlyEquals(t,e){let r=this.start.sub(t.start).valueOf(),u=this.end.sub(t.end).valueOf();return r<0&&(r=-r),u<0&&(u=-u),r<=e.valueOf()&&u<=e.valueOf()}contains(t){return t instanceof b?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new b(this.start,this.end);return t.start.after(this.start)&&(e.start=t.start),t.start.after(this.end)&&(e.end=t.start),t.end.before(this.end)&&(e.end=t.end),t.end.before(this.start)&&(e.start=t.end),e}};s(b,"MAX",new b(y.MIN,y.MAX)),s(b,"MIN",new b(y.MAX,y.MIN)),s(b,"ZERO",new b(y.ZERO,y.ZERO)),s(b,"z",c.z.union([c.z.object({start:y.z,end:y.z}).transform(t=>new b(t.start,t.end)),c.z.instanceof(b)]));let M=b;const n=class n extends String{constructor(t){if(t instanceof n||typeof t=="string"||typeof t.valueOf()=="string"){super(t.valueOf());return}else{const e=n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(e!=null){super(e.valueOf());return}}throw super(n.UNKNOWN.valueOf()),new Error(`unable to find data type for ${t.toString()}`)}get Array(){const t=n.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(t){return this.valueOf()===t.valueOf()}matches(...t){return t.some(e=>this.equals(e))}toString(){return this.valueOf()}get isVariable(){return this.equals(n.JSON)||this.equals(n.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(n.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=n.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}canSafelyCastTo(t){return this.equals(t)?!0:this.isVariable&&!t.isVariable||!this.isVariable&&t.isVariable?!1:this.isFloat&&t.isInteger||this.isInteger&&t.isFloat?this.density.valueOf()<t.density.valueOf():this.isFloat&&t.isFloat||this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf():!1}canCastTo(t){return this.isNumeric&&t.isNumeric?!0:this.equals(t)}checkArray(t){return t.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return n.BIG_INT_TYPES.some(t=>t.equals(this))}};s(n,"UNKNOWN",new n("unknown")),s(n,"FLOAT64",new n("float64")),s(n,"FLOAT32",new n("float32")),s(n,"INT64",new n("int64")),s(n,"INT32",new n("int32")),s(n,"INT16",new n("int16")),s(n,"INT8",new n("int8")),s(n,"UINT64",new n("uint64")),s(n,"UINT32",new n("uint32")),s(n,"UINT16",new n("uint16")),s(n,"UINT8",new n("uint8")),s(n,"BOOLEAN",n.UINT8),s(n,"TIMESTAMP",new n("timestamp")),s(n,"UUID",new n("uuid")),s(n,"STRING",new n("string")),s(n,"JSON",new n("json")),s(n,"ARRAY_CONSTRUCTORS",new Map([[n.UINT8.toString(),Uint8Array],[n.UINT16.toString(),Uint16Array],[n.UINT32.toString(),Uint32Array],[n.UINT64.toString(),BigUint64Array],[n.FLOAT32.toString(),Float32Array],[n.FLOAT64.toString(),Float64Array],[n.INT8.toString(),Int8Array],[n.INT16.toString(),Int16Array],[n.INT32.toString(),Int32Array],[n.INT64.toString(),BigInt64Array],[n.TIMESTAMP.toString(),BigInt64Array],[n.STRING.toString(),Uint8Array],[n.JSON.toString(),Uint8Array],[n.UUID.toString(),Uint8Array]])),s(n,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,n.UINT8],[Uint16Array.name,n.UINT16],[Uint32Array.name,n.UINT32],[BigUint64Array.name,n.UINT64],[Float32Array.name,n.FLOAT32],[Float64Array.name,n.FLOAT64],[Int8Array.name,n.INT8],[Int16Array.name,n.INT16],[Int32Array.name,n.INT32],[BigInt64Array.name,n.INT64]])),s(n,"DENSITIES",new Map([[n.UINT8.toString(),I.BIT8],[n.UINT16.toString(),I.BIT16],[n.UINT32.toString(),I.BIT32],[n.UINT64.toString(),I.BIT64],[n.FLOAT32.toString(),I.BIT32],[n.FLOAT64.toString(),I.BIT64],[n.INT8.toString(),I.BIT8],[n.INT16.toString(),I.BIT16],[n.INT32.toString(),I.BIT32],[n.INT64.toString(),I.BIT64],[n.TIMESTAMP.toString(),I.BIT64],[n.STRING.toString(),I.UNKNOWN],[n.JSON.toString(),I.UNKNOWN],[n.UUID.toString(),I.BIT128]])),s(n,"ALL",[n.UNKNOWN,n.FLOAT64,n.FLOAT32,n.INT64,n.INT32,n.INT16,n.INT8,n.UINT64,n.UINT32,n.UINT16,n.UINT8,n.TIMESTAMP,n.UUID,n.STRING,n.JSON]),s(n,"BIG_INT_TYPES",[n.INT64,n.UINT64,n.TIMESTAMP]),s(n,"z",c.z.union([c.z.string().transform(t=>new n(t)),c.z.instanceof(n)]));let h=n;const l=class l extends Number{constructor(t){super(t.valueOf())}largerThan(t){return this.valueOf()>t.valueOf()}smallerThan(t){return this.valueOf()<t.valueOf()}add(t){return l.bytes(this.valueOf()+t.valueOf())}sub(t){return l.bytes(this.valueOf()-t.valueOf())}truncate(t){return new l(Math.trunc(this.valueOf()/t.valueOf())*t.valueOf())}remainder(t){return l.bytes(this.valueOf()%t.valueOf())}get gigabytes(){return this.valueOf()/l.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/l.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/l.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/l.TERABYTE.valueOf()}toString(){const t=this.truncate(l.TERABYTE),e=this.truncate(l.GIGABYTE),r=this.truncate(l.MEGABYTE),u=this.truncate(l.KILOBYTE),d=this.truncate(l.BYTE),g=t,S=e.sub(t),O=r.sub(e),N=u.sub(r),p=d.sub(u);let o="";return g.isZero||(o+=`${g.terabytes}TB `),S.isZero||(o+=`${S.gigabytes}GB `),O.isZero||(o+=`${O.megabytes}MB `),N.isZero||(o+=`${N.kilobytes}KB `),(!p.isZero||o==="")&&(o+=`${p.valueOf()}B`),o.trim()}static bytes(t=1){return new l(t)}static kilobytes(t=1){return l.bytes(t.valueOf()*1e3)}static megabytes(t=1){return l.kilobytes(t.valueOf()*1e3)}static gigabytes(t=1){return l.megabytes(t.valueOf()*1e3)}static terabytes(t){return l.gigabytes(t.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};s(l,"BYTE",new l(1)),s(l,"KILOBYTE",l.kilobytes(1)),s(l,"MEGABYTE",l.megabytes(1)),s(l,"GIGABYTE",l.gigabytes(1)),s(l,"TERABYTE",l.terabytes(1)),s(l,"ZERO",new l(0)),s(l,"z",c.z.union([c.z.number().transform(t=>new l(t)),c.z.instanceof(l)]));let C=l;const et=c.z.union([c.z.instanceof(Uint8Array),c.z.instanceof(Uint16Array),c.z.instanceof(Uint32Array),c.z.instanceof(BigUint64Array),c.z.instanceof(Float32Array),c.z.instanceof(Float64Array),c.z.instanceof(Int8Array),c.z.instanceof(Int16Array),c.z.instanceof(Int32Array),c.z.instanceof(BigInt64Array)]),D=f=>{const t=typeof f;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||f instanceof y||f instanceof m||f instanceof Date},J=(f,t,e,r=0)=>f.usesBigInt&&!t.usesBigInt?Number(e)-Number(r):!f.usesBigInt&&t.usesBigInt?BigInt(e)-BigInt(r):R(e,-r),W=f=>f==null?!1:Array.isArray(f)||f instanceof ArrayBuffer||ArrayBuffer.isView(f)&&!(f instanceof DataView)||f instanceof T?!0:D(f),E=-1;class T{constructor(t){s(this,"key","");s(this,"isSynnaxSeries",!0);s(this,"dataType");s(this,"sampleOffset");s(this,"gl");s(this,"_data");s(this,"_timeRange");s(this,"alignment",0n);s(this,"_cachedMin");s(this,"_cachedMax");s(this,"writePos",E);s(this,"_refCount",0);s(this,"_cachedLength");W(t)&&(t={data:t});const{dataType:e,timeRange:r,sampleOffset:u=0,glBufferUsage:d="static",alignment:g=0n,key:S=Z()}=t,{data:O}=t;if(O instanceof T||typeof O=="object"&&"isSynnaxSeries"in O&&O.isSynnaxSeries===!0){const o=O;this.key=o.key,this.dataType=o.dataType,this.sampleOffset=o.sampleOffset,this.gl=o.gl,this._data=o._data,this._timeRange=o._timeRange,this.alignment=o.alignment,this._cachedMin=o._cachedMin,this._cachedMax=o._cachedMax,this.writePos=o.writePos,this._refCount=o._refCount,this._cachedLength=o._cachedLength;return}const N=D(O),p=Array.isArray(O);if(e!=null)this.dataType=new h(e);else{if(O instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(p||N){let o=O;if(!N){if(O.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");o=O[0]}if(typeof o=="string")this.dataType=h.STRING;else if(typeof o=="number")this.dataType=h.FLOAT64;else if(typeof o=="bigint")this.dataType=h.INT64;else if(typeof o=="boolean")this.dataType=h.BOOLEAN;else if(o instanceof y||o instanceof Date||o instanceof y)this.dataType=h.TIMESTAMP;else if(typeof o=="object")this.dataType=h.JSON;else throw new Error(`cannot infer data type of ${typeof o} when constructing a Series from a JS array`)}else this.dataType=new h(O)}if(!p&&!N)this._data=O;else{let o=N?[O]:O;const B=o[0];(B instanceof y||B instanceof Date||B instanceof m)&&(o=o.map(U=>new y(U).valueOf())),this.dataType.equals(h.STRING)?(this._cachedLength=o.length,this._data=new TextEncoder().encode(o.join(`
|
|
2
2
|
`)+`
|
|
3
|
-
`)):this.dataType.equals(
|
|
3
|
+
`)):this.dataType.equals(h.JSON)?(this._cachedLength=o.length,this._data=new TextEncoder().encode(o.map(U=>L.JSON_CODEC.encodeString(U)).join(`
|
|
4
4
|
`)+`
|
|
5
|
-
`)):this._data=new this.dataType.Array(o).buffer}this.key=
|
|
5
|
+
`)):this._data=new this.dataType.Array(o).buffer}this.key=S,this.alignment=g,this.sampleOffset=u??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:d}}static alloc({capacity:t,dataType:e,...r}){if(t===0)throw new Error("[Series] - cannot allocate an array of length 0");const u=new new h(e).Array(t),d=new T({data:u.buffer,dataType:e,...r});return d.writePos=0,d}static generateTimestamps(t,e,r){const u=r.spanRange(e.span(t)),d=new BigInt64Array(t);for(let g=0;g<t;g++)d[g]=BigInt(r.add(e.span(g)).valueOf());return new T({data:d,dataType:h.TIMESTAMP,timeRange:u})}get refCount(){return this._refCount}static fromStrings(t,e){const r=new TextEncoder().encode(t.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`);return new
|
|
7
|
+
`);return new T({data:r,dataType:h.STRING,timeRange:e})}static fromJSON(t,e){const r=new TextEncoder().encode(t.map(u=>L.JSON_CODEC.encodeString(u)).join(`
|
|
8
8
|
`)+`
|
|
9
|
-
`);return new
|
|
10
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(
|
|
11
|
-
`).slice(0,-1).map(e=>t.parse(L.JSON_CODEC.decodeString(e)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new C(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===E?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===E?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let t=0;return this.data.forEach(e=>{e===10&&t++}),this._cachedLength=t,t}convert(t,e=0){if(this.dataType.equals(t))return this;const r=new t.Array(this.length);for(let u=0;u<this.length;u++)r[u]=J(this.dataType,t,this.data[u],e);return new
|
|
9
|
+
`);return new T({data:r,dataType:h.JSON,timeRange:e})}acquire(t){this._refCount++,t!=null&&this.updateGLBuffer(t)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(t){if(!t.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===E)return 0;const e=this.capacity-this.writePos,r=e<t.length?t.slice(0,e):t;return this.underlyingData.set(r.data,this.writePos),this.maybeRecomputeMinMax(r),this._cachedLength=void 0,this.writePos+=r.length,r.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===E?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(h.STRING,h.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
10
|
+
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(h.UUID))throw new Error("cannot convert non-uuid series to uuids");const t=h.UUID.density.valueOf(),e=Array(this.length);for(let r=0;r<this.length;r++){const u=this.buffer.slice(r*t,(r+1)*t),d=Array.from(new Uint8Array(u),g=>g.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");e[r]=d}return e}parseJSON(t){if(!this.dataType.equals(h.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
|
|
11
|
+
`).slice(0,-1).map(e=>t.parse(L.JSON_CODEC.decodeString(e)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new C(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===E?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===E?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let t=0;return this.data.forEach(e=>{e===10&&t++}),this._cachedLength=t,t}convert(t,e=0){if(this.dataType.equals(t))return this;const r=new t.Array(this.length);for(let u=0;u<this.length;u++)r[u]=J(this.dataType,t,this.data[u],e);return new T({data:r.buffer,dataType:t,timeRange:this._timeRange,sampleOffset:e,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(h.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMax=t.reduce((e,r)=>e>r?e:r)}else{const t=this.data;this._cachedMax=t.reduce((e,r)=>e>r?e:r)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),R(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(h.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMin=t.reduce((e,r)=>e<r?e:r)}else{const t=this.data;this._cachedMin=t.reduce((e,r)=>e<r?e:r)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),R(this._cachedMin,this.sampleOffset))}get bounds(){return z.construct(Number(this.min),Number(this.max))}maybeRecomputeMinMax(t){if(this._cachedMin!=null){const e=t._cachedMin??t.calcRawMin();e<this._cachedMin&&(this._cachedMin=e)}if(this._cachedMax!=null){const e=t._cachedMax??t.calcRawMax();e>this._cachedMax&&(this._cachedMax=e)}}enrich(){this.max,this.min}get range(){return R(this.max,-this.min)}at(t,e){if(this.dataType.isVariable)return this.atVariable(t,e??!1);t<0&&(t=this.length+t);const r=this.data[t];if(r==null){if(e===!0)throw new Error(`[series] - no value at index ${t}`);return}return R(r,this.sampleOffset)}atVariable(t,e){t<0&&(t=this.length+t);let r=0,u=0;for(let g=0;g<this.data.length;g++)if(this.data[g]===10){if(t===0){u=g;break}r=g+1,t--}if(u===0&&(u=this.data.length),r>=u||t>0){if(e)throw new Error(`[series] - no value at index ${t}`);return}const d=this.data.slice(r,u);return this.dataType.equals(h.STRING)?new TextDecoder().decode(d):H.snakeToCamel(JSON.parse(new TextDecoder().decode(d)))}binarySearch(t){let e=0,r=this.length-1;const u=X.newF(t);for(;e<=r;){const d=Math.floor((e+r)/2),g=u(this.at(d,!0),t);if(g===0)return d;g<0?e=d+1:r=d-1}return e}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(h.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:e,bufferUsage:r,prevBuffer:u}=this.gl;if(e==null&&(this.gl.buffer=t.createBuffer()),this.writePos!==u)if(t.bindBuffer(t.ARRAY_BUFFER,this.gl.buffer),this.writePos!==E){u===0&&t.bufferData(t.ARRAY_BUFFER,this.byteCapacity.valueOf(),t.STATIC_DRAW);const d=this.dataType.density.size(u).valueOf(),g=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,d,g.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.buffer,r==="static"?t.STATIC_DRAW:t.DYNAMIC_DRAW),this.gl.prevBuffer=E}as(t){if(t==="string"){if(!this.dataType.equals(h.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(t==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(t==="bigint"){if(!this.dataType.equals(h.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${t}`)}get digest(){var t;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(t=this._timeRange)==null?void 0:t.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return z.construct(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(t){this.gl.buffer!=null&&(t.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const t=new rt(this);return this.dataType.equals(h.JSON)?new nt(t):t}return new st(this)}slice(t,e){if(t<=0&&(e==null||e>=this.length))return this;const r=this.data.slice(t,e);return new T({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(t){return new T({data:this.buffer,dataType:this.dataType,timeRange:M.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:t})}}class rt{constructor(t){s(this,"series");s(this,"index");s(this,"decoder");if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==10;)this.index++;const r=this.index;return t===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,r))})}[Symbol.iterator](){return this}}var $,F;class nt{constructor(t){s(this,"wrapped");s(this,$,"JSONSeriesIterator");this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:L.JSON_CODEC.decodeString(t.value)}}[(F=Symbol.iterator,$=Symbol.toStringTag,F)](){return this}}var P,Y;class st{constructor(t){s(this,"series");s(this,"index");s(this,P,"SeriesIterator");this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(Y=Symbol.iterator,P=Symbol.toStringTag,Y)](){return this}}const R=(f,t)=>typeof f=="bigint"&&typeof t=="bigint"||typeof f=="number"&&typeof t=="number"?f+t:t===0?f:f===0?t:Number(f)+Number(t);class it{constructor(t){s(this,"series");if(t.length!==0){const e=t[0].dataType;for(let r=1;r<t.length;r++)if(!t[r].dataType.equals(e))throw new Error("[multi-series] - series must have the same data type")}this.series=t}as(t){if(!new h(t).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${t.toString()}`);return this}get dataType(){return this.series.length===0?h.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?M.ZERO:new M(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(t){this.series.push(t)}get length(){return this.series.reduce((t,e)=>t+e.length,0)}at(t,e=!1){t<0&&(t=this.length+t);for(const r of this.series){if(t<r.length)return r.at(t,e);t-=r.length}if(e)throw new Error(`[series] - no value at index ${t}`)}get byteLength(){return new C(this.series.reduce((t,e)=>t+e.byteLength.valueOf(),0))}get data(){const t=new this.dataType.Array(this.length);let e=0;for(const r of this.series)t.set(r.data,e),e+=r.length;return new this.dataType.Array(t)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new at(this.series)}}var G,V;class at{constructor(t){s(this,"series");s(this,"seriesIndex");s(this,"internal");s(this,G,"MultiSeriesIterator");this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();return t.done===!1?t:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(V=Symbol.iterator,G=Symbol.toStringTag,V)](){return this}}exports.DataType=h;exports.Density=I;exports.MultiSeries=it;exports.Rate=x;exports.Series=T;exports.Size=C;exports.TimeRange=M;exports.TimeSpan=m;exports.TimeStamp=y;exports.addSamples=R;exports.convertDataType=J;exports.id=tt;exports.isCrudeSeries=W;exports.isTelemValue=D;exports.typedArrayZ=et;
|
|
@@ -64,9 +64,9 @@ const z = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", Z =
|
|
|
64
64
|
}
|
|
65
65
|
static parseTimeString(t, e = "UTC") {
|
|
66
66
|
const [r, u, h] = t.split(":");
|
|
67
|
-
let
|
|
68
|
-
h != null && ([
|
|
69
|
-
let O = i.hours(parseInt(r ?? "00", 10)).add(i.minutes(parseInt(u ?? "00", 10))).add(i.seconds(parseInt(
|
|
67
|
+
let g = "00", S = "00";
|
|
68
|
+
h != null && ([g, S] = h.split("."));
|
|
69
|
+
let O = i.hours(parseInt(r ?? "00", 10)).add(i.minutes(parseInt(u ?? "00", 10))).add(i.seconds(parseInt(g ?? "00", 10))).add(i.milliseconds(parseInt(S ?? "00", 10)));
|
|
70
70
|
return e === "local" && (O = O.add(i.utcOffset)), O.valueOf();
|
|
71
71
|
}
|
|
72
72
|
static parseDateTimeString(t, e = "UTC") {
|
|
@@ -369,7 +369,7 @@ const a = class a {
|
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
371
|
toString() {
|
|
372
|
-
const t = this.truncate(a.DAY), e = this.truncate(a.HOUR), r = this.truncate(a.MINUTE), u = this.truncate(a.SECOND), h = this.truncate(a.MILLISECOND),
|
|
372
|
+
const t = this.truncate(a.DAY), e = this.truncate(a.HOUR), r = this.truncate(a.MINUTE), u = this.truncate(a.SECOND), h = this.truncate(a.MILLISECOND), g = this.truncate(a.MICROSECOND), S = this.truncate(a.NANOSECOND), O = t, T = e.sub(t), p = r.sub(e), o = u.sub(r), M = h.sub(u), B = g.sub(h), x = S.sub(g);
|
|
373
373
|
let A = "";
|
|
374
374
|
return O.isZero || (A += `${O.days}d `), T.isZero || (A += `${T.hours}h `), p.isZero || (A += `${p.minutes}m `), o.isZero || (A += `${o.seconds}s `), M.isZero || (A += `${M.milliseconds}ms `), B.isZero || (A += `${B.microseconds}µs `), x.isZero || (A += `${x.nanoseconds}ns`), A.trim();
|
|
375
375
|
}
|
|
@@ -685,6 +685,12 @@ const b = class b {
|
|
|
685
685
|
get isZero() {
|
|
686
686
|
return this.span.isZero;
|
|
687
687
|
}
|
|
688
|
+
/**
|
|
689
|
+
* @returns the TimeRange as a numeric object with start and end properties.
|
|
690
|
+
*/
|
|
691
|
+
get numeric() {
|
|
692
|
+
return { start: Number(this.start.valueOf()), end: Number(this.end.valueOf()) };
|
|
693
|
+
}
|
|
688
694
|
/**
|
|
689
695
|
* Creates a new TimeRange with the start and end swapped.
|
|
690
696
|
*
|
|
@@ -768,9 +774,18 @@ const n = class n extends String {
|
|
|
768
774
|
throw new Error(`unable to find array constructor for ${this.valueOf()}`);
|
|
769
775
|
return t;
|
|
770
776
|
}
|
|
777
|
+
/**
|
|
778
|
+
* @returns true if the DataType is equal to the given DataType.
|
|
779
|
+
*/
|
|
771
780
|
equals(t) {
|
|
772
781
|
return this.valueOf() === t.valueOf();
|
|
773
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* @returns true if the DataType is equal to any of the given DataTypes.
|
|
785
|
+
*/
|
|
786
|
+
matches(...t) {
|
|
787
|
+
return t.some((e) => this.equals(e));
|
|
788
|
+
}
|
|
774
789
|
/** @returns a string representation of the DataType. */
|
|
775
790
|
toString() {
|
|
776
791
|
return this.valueOf();
|
|
@@ -897,7 +912,7 @@ s(n, "z", c.union([
|
|
|
897
912
|
c.string().transform((t) => new n(t)),
|
|
898
913
|
c.instanceof(n)
|
|
899
914
|
]));
|
|
900
|
-
let
|
|
915
|
+
let d = n;
|
|
901
916
|
const l = class l extends Number {
|
|
902
917
|
constructor(t) {
|
|
903
918
|
super(t.valueOf());
|
|
@@ -935,9 +950,9 @@ const l = class l extends Number {
|
|
|
935
950
|
return this.valueOf() / l.TERABYTE.valueOf();
|
|
936
951
|
}
|
|
937
952
|
toString() {
|
|
938
|
-
const t = this.truncate(l.TERABYTE), e = this.truncate(l.GIGABYTE), r = this.truncate(l.MEGABYTE), u = this.truncate(l.KILOBYTE), h = this.truncate(l.BYTE),
|
|
953
|
+
const t = this.truncate(l.TERABYTE), e = this.truncate(l.GIGABYTE), r = this.truncate(l.MEGABYTE), u = this.truncate(l.KILOBYTE), h = this.truncate(l.BYTE), g = t, S = e.sub(t), O = r.sub(e), T = u.sub(r), p = h.sub(u);
|
|
939
954
|
let o = "";
|
|
940
|
-
return
|
|
955
|
+
return g.isZero || (o += `${g.terabytes}TB `), S.isZero || (o += `${S.gigabytes}GB `), O.isZero || (o += `${O.megabytes}MB `), T.isZero || (o += `${T.kilobytes}KB `), (!p.isZero || o === "") && (o += `${p.valueOf()}B`), o.trim();
|
|
941
956
|
}
|
|
942
957
|
/**
|
|
943
958
|
* Creates a Size from the given number of bytes.
|
|
@@ -1050,7 +1065,7 @@ class N {
|
|
|
1050
1065
|
timeRange: r,
|
|
1051
1066
|
sampleOffset: u = 0,
|
|
1052
1067
|
glBufferUsage: h = "static",
|
|
1053
|
-
alignment:
|
|
1068
|
+
alignment: g = 0n,
|
|
1054
1069
|
key: S = Z()
|
|
1055
1070
|
} = t, { data: O } = t;
|
|
1056
1071
|
if (O instanceof N || typeof O == "object" && "isSynnaxSeries" in O && O.isSynnaxSeries === !0) {
|
|
@@ -1059,7 +1074,7 @@ class N {
|
|
|
1059
1074
|
return;
|
|
1060
1075
|
}
|
|
1061
1076
|
const T = J(O), p = Array.isArray(O);
|
|
1062
|
-
if (e != null) this.dataType = new
|
|
1077
|
+
if (e != null) this.dataType = new d(e);
|
|
1063
1078
|
else {
|
|
1064
1079
|
if (O instanceof ArrayBuffer)
|
|
1065
1080
|
throw new Error(
|
|
@@ -1074,32 +1089,32 @@ class N {
|
|
|
1074
1089
|
);
|
|
1075
1090
|
o = O[0];
|
|
1076
1091
|
}
|
|
1077
|
-
if (typeof o == "string") this.dataType =
|
|
1078
|
-
else if (typeof o == "number") this.dataType =
|
|
1079
|
-
else if (typeof o == "bigint") this.dataType =
|
|
1080
|
-
else if (typeof o == "boolean") this.dataType =
|
|
1092
|
+
if (typeof o == "string") this.dataType = d.STRING;
|
|
1093
|
+
else if (typeof o == "number") this.dataType = d.FLOAT64;
|
|
1094
|
+
else if (typeof o == "bigint") this.dataType = d.INT64;
|
|
1095
|
+
else if (typeof o == "boolean") this.dataType = d.BOOLEAN;
|
|
1081
1096
|
else if (o instanceof m || o instanceof Date || o instanceof m)
|
|
1082
|
-
this.dataType =
|
|
1083
|
-
else if (typeof o == "object") this.dataType =
|
|
1097
|
+
this.dataType = d.TIMESTAMP;
|
|
1098
|
+
else if (typeof o == "object") this.dataType = d.JSON;
|
|
1084
1099
|
else
|
|
1085
1100
|
throw new Error(
|
|
1086
1101
|
`cannot infer data type of ${typeof o} when constructing a Series from a JS array`
|
|
1087
1102
|
);
|
|
1088
|
-
} else this.dataType = new
|
|
1103
|
+
} else this.dataType = new d(O);
|
|
1089
1104
|
}
|
|
1090
1105
|
if (!p && !T) this._data = O;
|
|
1091
1106
|
else {
|
|
1092
1107
|
let o = T ? [O] : O;
|
|
1093
1108
|
const M = o[0];
|
|
1094
|
-
(M instanceof m || M instanceof Date || M instanceof w) && (o = o.map((B) => new m(B).valueOf())), this.dataType.equals(
|
|
1109
|
+
(M instanceof m || M instanceof Date || M instanceof w) && (o = o.map((B) => new m(B).valueOf())), this.dataType.equals(d.STRING) ? (this._cachedLength = o.length, this._data = new TextEncoder().encode(o.join(`
|
|
1095
1110
|
`) + `
|
|
1096
|
-
`)) : this.dataType.equals(
|
|
1111
|
+
`)) : this.dataType.equals(d.JSON) ? (this._cachedLength = o.length, this._data = new TextEncoder().encode(
|
|
1097
1112
|
o.map((B) => L.encodeString(B)).join(`
|
|
1098
1113
|
`) + `
|
|
1099
1114
|
`
|
|
1100
1115
|
)) : this._data = new this.dataType.Array(o).buffer;
|
|
1101
1116
|
}
|
|
1102
|
-
this.key = S, this.alignment =
|
|
1117
|
+
this.key = S, this.alignment = g, this.sampleOffset = u ?? 0, this._timeRange = r, this.gl = {
|
|
1103
1118
|
control: null,
|
|
1104
1119
|
buffer: null,
|
|
1105
1120
|
prevBuffer: 0,
|
|
@@ -1109,7 +1124,7 @@ class N {
|
|
|
1109
1124
|
static alloc({ capacity: t, dataType: e, ...r }) {
|
|
1110
1125
|
if (t === 0)
|
|
1111
1126
|
throw new Error("[Series] - cannot allocate an array of length 0");
|
|
1112
|
-
const u = new new
|
|
1127
|
+
const u = new new d(e).Array(t), h = new N({
|
|
1113
1128
|
data: u.buffer,
|
|
1114
1129
|
dataType: e,
|
|
1115
1130
|
...r
|
|
@@ -1118,9 +1133,9 @@ class N {
|
|
|
1118
1133
|
}
|
|
1119
1134
|
static generateTimestamps(t, e, r) {
|
|
1120
1135
|
const u = r.spanRange(e.span(t)), h = new BigInt64Array(t);
|
|
1121
|
-
for (let
|
|
1122
|
-
h[
|
|
1123
|
-
return new N({ data: h, dataType:
|
|
1136
|
+
for (let g = 0; g < t; g++)
|
|
1137
|
+
h[g] = BigInt(r.add(e.span(g)).valueOf());
|
|
1138
|
+
return new N({ data: h, dataType: d.TIMESTAMP, timeRange: u });
|
|
1124
1139
|
}
|
|
1125
1140
|
get refCount() {
|
|
1126
1141
|
return this._refCount;
|
|
@@ -1129,7 +1144,7 @@ class N {
|
|
|
1129
1144
|
const r = new TextEncoder().encode(t.join(`
|
|
1130
1145
|
`) + `
|
|
1131
1146
|
`);
|
|
1132
|
-
return new N({ data: r, dataType:
|
|
1147
|
+
return new N({ data: r, dataType: d.STRING, timeRange: e });
|
|
1133
1148
|
}
|
|
1134
1149
|
static fromJSON(t, e) {
|
|
1135
1150
|
const r = new TextEncoder().encode(
|
|
@@ -1137,7 +1152,7 @@ class N {
|
|
|
1137
1152
|
`) + `
|
|
1138
1153
|
`
|
|
1139
1154
|
);
|
|
1140
|
-
return new N({ data: r, dataType:
|
|
1155
|
+
return new N({ data: r, dataType: d.JSON, timeRange: e });
|
|
1141
1156
|
}
|
|
1142
1157
|
acquire(t) {
|
|
1143
1158
|
this._refCount++, t != null && this.updateGLBuffer(t);
|
|
@@ -1178,23 +1193,23 @@ class N {
|
|
|
1178
1193
|
return this.writePos === E ? this.underlyingData : new this.dataType.Array(this._data, 0, this.writePos);
|
|
1179
1194
|
}
|
|
1180
1195
|
toStrings() {
|
|
1181
|
-
if (!this.dataType.
|
|
1196
|
+
if (!this.dataType.matches(d.STRING, d.UUID))
|
|
1182
1197
|
throw new Error("cannot convert non-string series to strings");
|
|
1183
1198
|
return new TextDecoder().decode(this.buffer).split(`
|
|
1184
1199
|
`).slice(0, -1);
|
|
1185
1200
|
}
|
|
1186
1201
|
toUUIDs() {
|
|
1187
|
-
if (!this.dataType.equals(
|
|
1202
|
+
if (!this.dataType.equals(d.UUID))
|
|
1188
1203
|
throw new Error("cannot convert non-uuid series to uuids");
|
|
1189
|
-
const t =
|
|
1204
|
+
const t = d.UUID.density.valueOf(), e = Array(this.length);
|
|
1190
1205
|
for (let r = 0; r < this.length; r++) {
|
|
1191
|
-
const u = this.buffer.slice(r * t, (r + 1) * t), h = Array.from(new Uint8Array(u), (
|
|
1206
|
+
const u = this.buffer.slice(r * t, (r + 1) * t), h = Array.from(new Uint8Array(u), (g) => g.toString(16).padStart(2, "0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, "$1-$2-$3-$4-$5");
|
|
1192
1207
|
e[r] = h;
|
|
1193
1208
|
}
|
|
1194
1209
|
return e;
|
|
1195
1210
|
}
|
|
1196
1211
|
parseJSON(t) {
|
|
1197
|
-
if (!this.dataType.equals(
|
|
1212
|
+
if (!this.dataType.equals(d.JSON))
|
|
1198
1213
|
throw new Error("cannot convert non-string series to strings");
|
|
1199
1214
|
return new TextDecoder().decode(this.buffer).split(`
|
|
1200
1215
|
`).slice(0, -1).map((e) => t.parse(L.decodeString(e)));
|
|
@@ -1253,7 +1268,7 @@ class N {
|
|
|
1253
1268
|
}
|
|
1254
1269
|
calcRawMax() {
|
|
1255
1270
|
if (this.length === 0) return -1 / 0;
|
|
1256
|
-
if (this.dataType.equals(
|
|
1271
|
+
if (this.dataType.equals(d.TIMESTAMP))
|
|
1257
1272
|
this._cachedMax = this.data[this.data.length - 1];
|
|
1258
1273
|
else if (this.dataType.usesBigInt) {
|
|
1259
1274
|
const t = this.data;
|
|
@@ -1272,7 +1287,7 @@ class N {
|
|
|
1272
1287
|
}
|
|
1273
1288
|
calcRawMin() {
|
|
1274
1289
|
if (this.length === 0) return 1 / 0;
|
|
1275
|
-
if (this.dataType.equals(
|
|
1290
|
+
if (this.dataType.equals(d.TIMESTAMP))
|
|
1276
1291
|
this._cachedMin = this.data[0];
|
|
1277
1292
|
else if (this.dataType.usesBigInt) {
|
|
1278
1293
|
const t = this.data;
|
|
@@ -1322,20 +1337,20 @@ class N {
|
|
|
1322
1337
|
atVariable(t, e) {
|
|
1323
1338
|
t < 0 && (t = this.length + t);
|
|
1324
1339
|
let r = 0, u = 0;
|
|
1325
|
-
for (let
|
|
1326
|
-
if (this.data[
|
|
1340
|
+
for (let g = 0; g < this.data.length; g++)
|
|
1341
|
+
if (this.data[g] === 10) {
|
|
1327
1342
|
if (t === 0) {
|
|
1328
|
-
u =
|
|
1343
|
+
u = g;
|
|
1329
1344
|
break;
|
|
1330
1345
|
}
|
|
1331
|
-
r =
|
|
1346
|
+
r = g + 1, t--;
|
|
1332
1347
|
}
|
|
1333
1348
|
if (u === 0 && (u = this.data.length), r >= u || t > 0) {
|
|
1334
1349
|
if (e) throw new Error(`[series] - no value at index ${t}`);
|
|
1335
1350
|
return;
|
|
1336
1351
|
}
|
|
1337
1352
|
const h = this.data.slice(r, u);
|
|
1338
|
-
return this.dataType.equals(
|
|
1353
|
+
return this.dataType.equals(d.STRING) ? new TextDecoder().decode(h) : j(
|
|
1339
1354
|
JSON.parse(new TextDecoder().decode(h))
|
|
1340
1355
|
);
|
|
1341
1356
|
}
|
|
@@ -1348,21 +1363,21 @@ class N {
|
|
|
1348
1363
|
let e = 0, r = this.length - 1;
|
|
1349
1364
|
const u = H(t);
|
|
1350
1365
|
for (; e <= r; ) {
|
|
1351
|
-
const h = Math.floor((e + r) / 2),
|
|
1352
|
-
if (
|
|
1353
|
-
|
|
1366
|
+
const h = Math.floor((e + r) / 2), g = u(this.at(h, !0), t);
|
|
1367
|
+
if (g === 0) return h;
|
|
1368
|
+
g < 0 ? e = h + 1 : r = h - 1;
|
|
1354
1369
|
}
|
|
1355
1370
|
return e;
|
|
1356
1371
|
}
|
|
1357
1372
|
updateGLBuffer(t) {
|
|
1358
|
-
if (this.gl.control = t, !this.dataType.equals(
|
|
1373
|
+
if (this.gl.control = t, !this.dataType.equals(d.FLOAT32))
|
|
1359
1374
|
throw new Error("Only FLOAT32 arrays can be used in WebGL");
|
|
1360
1375
|
const { buffer: e, bufferUsage: r, prevBuffer: u } = this.gl;
|
|
1361
1376
|
if (e == null && (this.gl.buffer = t.createBuffer()), this.writePos !== u)
|
|
1362
1377
|
if (t.bindBuffer(t.ARRAY_BUFFER, this.gl.buffer), this.writePos !== E) {
|
|
1363
1378
|
u === 0 && t.bufferData(t.ARRAY_BUFFER, this.byteCapacity.valueOf(), t.STATIC_DRAW);
|
|
1364
|
-
const h = this.dataType.density.size(u).valueOf(),
|
|
1365
|
-
t.bufferSubData(t.ARRAY_BUFFER, h,
|
|
1379
|
+
const h = this.dataType.density.size(u).valueOf(), g = this.underlyingData.slice(this.gl.prevBuffer, this.writePos);
|
|
1380
|
+
t.bufferSubData(t.ARRAY_BUFFER, h, g.buffer), this.gl.prevBuffer = this.writePos;
|
|
1366
1381
|
} else
|
|
1367
1382
|
t.bufferData(
|
|
1368
1383
|
t.ARRAY_BUFFER,
|
|
@@ -1372,7 +1387,7 @@ class N {
|
|
|
1372
1387
|
}
|
|
1373
1388
|
as(t) {
|
|
1374
1389
|
if (t === "string") {
|
|
1375
|
-
if (!this.dataType.equals(
|
|
1390
|
+
if (!this.dataType.equals(d.STRING))
|
|
1376
1391
|
throw new Error(
|
|
1377
1392
|
`cannot convert series of type ${this.dataType.toString()} to string`
|
|
1378
1393
|
);
|
|
@@ -1386,7 +1401,7 @@ class N {
|
|
|
1386
1401
|
return this;
|
|
1387
1402
|
}
|
|
1388
1403
|
if (t === "bigint") {
|
|
1389
|
-
if (!this.dataType.equals(
|
|
1404
|
+
if (!this.dataType.equals(d.INT64))
|
|
1390
1405
|
throw new Error(
|
|
1391
1406
|
`cannot convert series of type ${this.dataType.toString()} to bigint`
|
|
1392
1407
|
);
|
|
@@ -1427,7 +1442,7 @@ class N {
|
|
|
1427
1442
|
[Symbol.iterator]() {
|
|
1428
1443
|
if (this.dataType.isVariable) {
|
|
1429
1444
|
const t = new tt(this);
|
|
1430
|
-
return this.dataType.equals(
|
|
1445
|
+
return this.dataType.equals(d.JSON) ? new et(t) : t;
|
|
1431
1446
|
}
|
|
1432
1447
|
return new rt(this);
|
|
1433
1448
|
}
|
|
@@ -1524,14 +1539,14 @@ class yt {
|
|
|
1524
1539
|
this.series = t;
|
|
1525
1540
|
}
|
|
1526
1541
|
as(t) {
|
|
1527
|
-
if (!new
|
|
1542
|
+
if (!new d(t).equals(this.dataType))
|
|
1528
1543
|
throw new Error(
|
|
1529
1544
|
`cannot convert series of type ${this.dataType.toString()} to ${t.toString()}`
|
|
1530
1545
|
);
|
|
1531
1546
|
return this;
|
|
1532
1547
|
}
|
|
1533
1548
|
get dataType() {
|
|
1534
|
-
return this.series.length === 0 ?
|
|
1549
|
+
return this.series.length === 0 ? d.UNKNOWN : this.series[0].dataType;
|
|
1535
1550
|
}
|
|
1536
1551
|
get timeRange() {
|
|
1537
1552
|
return this.series.length === 0 ? U.ZERO : new U(
|
|
@@ -1597,7 +1612,7 @@ export {
|
|
|
1597
1612
|
R as a,
|
|
1598
1613
|
w as b,
|
|
1599
1614
|
U as c,
|
|
1600
|
-
|
|
1615
|
+
d,
|
|
1601
1616
|
C as e,
|
|
1602
1617
|
J as f,
|
|
1603
1618
|
Q as g,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC"}
|
package/dist/src/deep/equal.d.ts
CHANGED