Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@loaders.gl/schema

Package Overview
Dependencies
Maintainers
0
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/schema - npm Package Compare versions

Comparing version 4.3.0-alpha.3 to 4.3.0-alpha.4

153

dist/dist.dev.js

@@ -103,2 +103,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

deduceTableSchema: () => deduceTableSchema,
getArrayTypeFromDataType: () => getArrayTypeFromDataType,
getDataTypeFromArray: () => getDataTypeFromArray,

@@ -127,2 +128,78 @@ getMeshBoundingBox: () => getMeshBoundingBox,

// src/lib/table/simple-table/data-type.ts
function getDataTypeFromValue(value, defaultNumberType = "float32") {
if (value instanceof Date) {
return "date-millisecond";
}
if (value instanceof Number) {
return defaultNumberType;
}
if (typeof value === "string") {
return "utf8";
}
if (value === null || value === "undefined") {
return "null";
}
return "null";
}
function getDataTypeFromArray(array) {
let type = getDataTypeFromTypedArray(array);
if (type !== "null") {
return { type, nullable: false };
}
if (array.length > 0) {
type = getDataTypeFromValue(array[0]);
return { type, nullable: true };
}
return { type: "null", nullable: true };
}
function getDataTypeFromTypedArray(array) {
switch (array.constructor) {
case Int8Array:
return "int8";
case Uint8Array:
case Uint8ClampedArray:
return "uint8";
case Int16Array:
return "int16";
case Uint16Array:
return "uint16";
case Int32Array:
return "int32";
case Uint32Array:
return "uint32";
case Float32Array:
return "float32";
case Float64Array:
return "float64";
default:
return "null";
}
}
function getArrayTypeFromDataType(type, nullable) {
if (!nullable) {
switch (type) {
case "int8":
return Int8Array;
case "uint8":
return Uint8Array;
case "int16":
return Int16Array;
case "uint16":
return Uint16Array;
case "int32":
return Int32Array;
case "uint32":
return Uint32Array;
case "float32":
return Float32Array;
case "float64":
return Float64Array;
default:
break;
}
}
return Array;
}
// src/lib/table/batches/base-table-batch-aggregator.ts

@@ -845,78 +922,2 @@ var DEFAULT_ROW_COUNT = 100;

// src/lib/table/simple-table/data-type.ts
function getDataTypeFromValue(value, defaultNumberType = "float32") {
if (value instanceof Date) {
return "date-millisecond";
}
if (value instanceof Number) {
return defaultNumberType;
}
if (typeof value === "string") {
return "utf8";
}
if (value === null || value === "undefined") {
return "null";
}
return "null";
}
function getDataTypeFromArray(array) {
let type = getDataTypeFromTypedArray(array);
if (type !== "null") {
return { type, nullable: false };
}
if (array.length > 0) {
type = getDataTypeFromValue(array[0]);
return { type, nullable: true };
}
return { type: "null", nullable: true };
}
function getDataTypeFromTypedArray(array) {
switch (array.constructor) {
case Int8Array:
return "int8";
case Uint8Array:
case Uint8ClampedArray:
return "uint8";
case Int16Array:
return "int16";
case Uint16Array:
return "uint16";
case Int32Array:
return "int32";
case Uint32Array:
return "uint32";
case Float32Array:
return "float32";
case Float64Array:
return "float64";
default:
return "null";
}
}
function getArrayTypeFromDataType(type, nullable) {
if (!nullable) {
switch (type) {
case "int8":
return Int8Array;
case "uint8":
return Uint8Array;
case "int16":
return Int16Array;
case "uint16":
return Uint16Array;
case "int32":
return Int32Array;
case "uint32":
return Uint32Array;
case "float32":
return Float32Array;
case "float64":
return Float64Array;
default:
break;
}
}
return Array;
}
// src/lib/table/simple-table/table-schema.ts

@@ -923,0 +924,0 @@ function deduceTableSchema(table) {

@@ -7,4 +7,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

else root['loaders'] = factory();})(globalThis, function () {
"use strict";var __exports__=(()=>{var Kt=Object.create;var F=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(t,e,r)=>e in t?F(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ae=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),oe=(t,e)=>{for(var r in e)F(t,r,{get:e[r],enumerable:!0})},M=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of te(e))!re.call(t,a)&&a!==r&&F(t,a,{get:()=>e[a],enumerable:!(s=Qt(e,a))||s.enumerable});return t},U=(t,e,r)=>(M(t,e,"default"),r&&M(r,e,"default")),ne=(t,e,r)=>(r=t!=null?Kt(ee(t)):{},M(e||!t||!t.__esModule?F(r,"default",{value:t,enumerable:!0}):r,t)),ie=t=>M(F({},"__esModule",{value:!0}),t);var Et=(t,e,r)=>(se(t,typeof e!="symbol"?e+"":e,r),r);var Ct=ae((Se,Bt)=>{Bt.exports=globalThis.loaders});var C={};oe(C,{ArrowLikeDataType:()=>m,ArrowLikeField:()=>p,ArrowLikeSchema:()=>d,ArrowLikeTable:()=>P,AsyncQueue:()=>B,Binary:()=>at,Bool:()=>H,ColumnarTableBatchAggregator:()=>S,Date:()=>I,DateDay:()=>nt,DateMillisecond:()=>it,FixedSizeList:()=>gt,Float:()=>x,Float16:()=>et,Float32:()=>rt,Float64:()=>st,Int:()=>f,Int16:()=>V,Int32:()=>G,Int64:()=>X,Int8:()=>J,Interval:()=>O,IntervalDayTime:()=>ft,IntervalYearMonth:()=>pt,Null:()=>q,RowTableBatchAggregator:()=>A,Struct:()=>wt,TableBatchBuilder:()=>R,Time:()=>T,TimeMillisecond:()=>lt,TimeSecond:()=>ct,Timestamp:()=>b,TimestampMicrosecond:()=>mt,TimestampMillisecond:()=>ht,TimestampNanosecond:()=>dt,TimestampSecond:()=>ut,Uint16:()=>K,Uint32:()=>Q,Uint64:()=>tt,Uint8:()=>Z,Utf8:()=>ot,convertTable:()=>Jt,convertToArrayRow:()=>L,convertToObjectRow:()=>v,deduceMeshField:()=>Tt,deduceMeshSchema:()=>Xt,deduceTableSchema:()=>w,getDataTypeFromArray:()=>Y,getMeshBoundingBox:()=>Gt,getMeshSize:()=>Vt,getTableCell:()=>j,getTableColumnIndex:()=>xt,getTableColumnName:()=>vt,getTableLength:()=>h,getTableNumCols:()=>$,getTableRowAsArray:()=>E,getTableRowAsObject:()=>N,getTableRowShape:()=>kt,getTypeInfo:()=>Zt,isTable:()=>Ut,makeArrayRowIterator:()=>At,makeBatchFromTable:()=>Pt,makeMeshAttributeMetadata:()=>Ot,makeObjectRowIterator:()=>St,makeRowIterator:()=>Lt,makeTableFromBatches:()=>qt,makeTableFromData:()=>Yt});U(C,ne(Ct(),1));var k=class{schema;options;shape;length=0;rows=null;cursor=0;_headers=[];constructor(e,r){if(this.options=r,this.schema=e,!Array.isArray(e)){this._headers=[];for(let s in e)this._headers[e[s].index]=e[s].name}}rowCount(){return this.length}addArrayRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}addObjectRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}getBatch(){let e=this.rows;return e?(e=e.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function v(t,e){if(!t)throw new Error("null row");let r={};if(e)for(let s=0;s<e.length;s++)r[e[s]]=t[s];else for(let s=0;s<t.length;s++){let a=`column-${s}`;r[a]=t[s]}return r}function L(t,e){if(!t)throw new Error("null row");if(e){let r=new Array(e.length);for(let s=0;s<e.length;s++)r[s]=t[e[s]];return r}return Object.values(t)}function Dt(t){let e=[];for(let r=0;r<t.length;r++){let s=`column-${r}`;e.push(s)}return e}function _t(t){return Object.keys(t)}var Mt=100,A=class{schema;options;length=0;objectRows=null;arrayRows=null;cursor=0;_headers=null;constructor(e,r){if(this.options=r,this.schema=e,e){this._headers=[];for(let s in e)this._headers[e[s].index]=e[s].name}}rowCount(){return this.length}addArrayRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=Dt(e),this.options.shape){case"object-row-table":let s=v(e,this._headers);this.addObjectRow(s,r);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Mt),this.arrayRows[this.length]=e,this.length++;break}}addObjectRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=_t(e),this.options.shape){case"array-row-table":let s=L(e,this._headers);this.addArrayRow(s,r);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Mt),this.objectRows[this.length]=e,this.length++;break}}getBatch(){let e=this.arrayRows||this.objectRows;return e?(e=e.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var S=class{schema;length=0;allocated=0;columns={};constructor(e,r){this.schema=e,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(e){this._reallocateColumns();let r=0;for(let s in this.columns)this.columns[s][this.length]=e[r++];this.length++}addObjectRow(e){this._reallocateColumns();for(let r in e)this.columns[r][this.length]=e[r];this.length++}getBatch(){this._pruneColumns();let e=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(let s in this.schema){let a=this.schema[s];e[a.name]=this.columns[a.index]}return this.columns={},{shape:"columnar-table",batchType:"data",data:e,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:100,this.columns={};for(let e in this.schema){let r=this.schema[e],s=r.type||Float32Array,a=this.columns[r.index];if(a&&ArrayBuffer.isView(a)){let u=new s(this.allocated);u.set(a),this.columns[r.index]=u}else a?(a.length=this.allocated,this.columns[r.index]=a):this.columns[r.index]=new s(this.allocated)}}}_pruneColumns(){for(let[e,r]of Object.entries(this.columns))this.columns[e]=r.slice(0,this.length)}};var ce={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},le="TableBatchBuilder",z=class{schema;options;aggregator=null;batchCount=0;bytesUsed=0;isChunkComplete=!1;lastBatchEmittedMs=Date.now();totalLength=0;totalBytes=0;rowBytes=0;constructor(e,r){this.schema=e,this.options={...ce,...r}}limitReached(){return!!(Boolean(this.options?.limit)&&this.totalLength>=this.options.limit||Boolean(this.options?._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(e){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(e),this.totalBytes+=this.rowBytes,Array.isArray(e)?this.addArrayRow(e):this.addObjectRow(e))}addArrayRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addArrayRow(e)}addObjectRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addObjectRow(e)}chunkComplete(e){e instanceof ArrayBuffer&&(this.bytesUsed+=e.byteLength),typeof e=="string"&&(this.bytesUsed+=e.length),this.isChunkComplete=!0}getFullBatch(e){return this._isFull()?this._getBatch(e):null}getFinalBatch(e){return this._getBatch(e)}_estimateRowMB(e){return Array.isArray(e)?e.length*8:Object.keys(e).length*8}_isFull(){if(!this.aggregator||this.aggregator.rowCount()===0)return!1;if(this.options.batchSize==="auto"){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs?!1:(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(e){if(!this.aggregator)return null;e?.bytesUsed&&(this.bytesUsed=e.bytesUsed);let r=this.aggregator.getBatch();return r.count=this.batchCount,r.bytesUsed=this.bytesUsed,Object.assign(r,e),this.batchCount++,this.aggregator=null,r}_getTableBatchType(){switch(this.options.shape){case"array-row-table":case"object-row-table":return A;case"columnar-table":return S;case"arrow-table":if(!z.ArrowBatch)throw new Error(le);return z.ArrowBatch;default:return k}}},R=z;Et(R,"ArrowBatch");function Ut(t){switch(typeof t=="object"&&t?.shape){case"array-row-table":case"object-row-table":return Array.isArray(t.data);case"geojson-table":return Array.isArray(t.features);case"columnar-table":return t.data&&typeof t.data=="object";case"arrow-table":return Boolean(t?.data?.numRows!==void 0);default:return!1}}function h(t){switch(t.shape){case"array-row-table":case"object-row-table":return t.data.length;case"geojson-table":return t.features.length;case"arrow-table":return t.data.numRows;case"columnar-table":for(let r of Object.values(t.data))return r.length||0;return 0;default:throw new Error("table")}}function $(t){if(t.schema)return t.schema.fields.length;if(h(t)===0)throw new Error("empty table");switch(t.shape){case"array-row-table":return t.data[0].length;case"object-row-table":return Object.keys(t.data[0]).length;case"geojson-table":return Object.keys(t.features[0]).length;case"columnar-table":return Object.keys(t.data).length;case"arrow-table":return t.data.numCols;default:throw new Error("table")}}function j(t,e,r){switch(t.shape){case"array-row-table":let s=xt(t,r);return t.data[e][s];case"object-row-table":return t.data[e][r];case"geojson-table":return t.features[e][r];case"columnar-table":return t.data[r][e];case"arrow-table":let u=t.data,c=u.schema.fields.findIndex(l=>l.name===r);return u.getChildAt(c)?.get(e);default:throw new Error("todo")}}function kt(t){switch(t.shape){case"array-row-table":case"object-row-table":return t.shape;case"geojson-table":return"object-row-table";case"columnar-table":default:throw new Error("Not a row table")}}function xt(t,e){let r=t.schema?.fields.findIndex(s=>s.name===e);if(r===void 0)throw new Error(e);return r}function vt(t,e){let r=t.schema?.fields[e]?.name;if(!r)throw new Error(`${e}`);return r}function N(t,e,r,s){switch(t.shape){case"object-row-table":return s?Object.fromEntries(Object.entries(t.data[e])):t.data[e];case"array-row-table":if(t.schema){let o=r||{};for(let n=0;n<t.schema.fields.length;n++)o[t.schema.fields[n].name]=t.data[e][n];return o}throw new Error("no schema");case"geojson-table":if(t.schema){let o=r||{};for(let n=0;n<t.schema.fields.length;n++)o[t.schema.fields[n].name]=t.features[e][n];return o}throw new Error("no schema");case"columnar-table":if(t.schema){let o=r||{};for(let n=0;n<t.schema.fields.length;n++)o[t.schema.fields[n].name]=t.data[t.schema.fields[n].name][e];return o}else{let o=r||{};for(let[n,g]of Object.entries(t.data))o[n]=g[e];return o}case"arrow-table":let a=t.data,u=r||{},c=a.get(e),l=a.schema;for(let o=0;o<l.fields.length;o++)u[l.fields[o].name]=c?.[l.fields[o].name];return u;default:throw new Error("shape")}}function E(t,e,r,s){switch(t.shape){case"array-row-table":return s?Array.from(t.data[e]):t.data[e];case"object-row-table":if(t.schema){let o=r||[];for(let n=0;n<t.schema.fields.length;n++)o[n]=t.data[e][t.schema.fields[n].name];return o}return Object.values(t.data[e]);case"geojson-table":if(t.schema){let o=r||[];for(let n=0;n<t.schema.fields.length;n++)o[n]=t.features[e][t.schema.fields[n].name];return o}return Object.values(t.features[e]);case"columnar-table":if(t.schema){let o=r||[];for(let n=0;n<t.schema.fields.length;n++)o[n]=t.data[t.schema.fields[n].name][e];return o}else{let o=r||[],n=0;for(let g of Object.values(t.data))o[n]=g[e],n++;return o}case"arrow-table":let a=t.data,u=r||[],c=a.get(e),l=a.schema;for(let o=0;o<l.fields.length;o++)u[o]=c?.[l.fields[o].name];return u;default:throw new Error("shape")}}function*Lt(t,e){switch(e){case"array-row-table":yield*At(t);break;case"object-row-table":yield*St(t);break;default:throw new Error(`Unknown row type ${e}`)}}function*At(t,e=[]){let r=h(t);for(let s=0;s<r;s++)yield E(t,s,e)}function*St(t,e={}){let r=h(t);for(let s=0;s<r;s++)yield N(t,s,e)}var p=class{name;type;nullable;metadata;constructor(e,r,s=!1,a=new Map){this.name=e,this.type=r,this.nullable=s,this.metadata=a}get typeId(){return this.type&&this.type.typeId}clone(){return new p(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return`${JSON.stringify(this.type)}${this.nullable?", nullable":""}${this.metadata?`, metadata: ${JSON.stringify(this.metadata)}`:""}`}};var d=class{fields;metadata;constructor(e,r=new Map){this.fields=e.map(s=>new p(s.name,s.type,s.nullable,s.metadata)),this.metadata=r instanceof Map?r:new Map(Object.entries(r))}compareTo(e){if(this.metadata!==e.metadata||this.fields.length!==e.fields.length)return!1;for(let r=0;r<this.fields.length;++r)if(!this.fields[r].compareTo(e.fields[r]))return!1;return!0}select(...e){let r=Object.create(null);for(let a of e)r[a]=!0;let s=this.fields.filter(a=>r[a.name]);return new d(s,this.metadata)}selectAt(...e){let r=e.map(s=>this.fields[s]).filter(Boolean);return new d(r,this.metadata)}assign(e){let r,s=this.metadata;if(e instanceof d){let c=e;r=c.fields,s=zt(zt(new Map,this.metadata),c.metadata)}else r=e;let a=Object.create(null);for(let c of this.fields)a[c.name]=c;for(let c of r)a[c.name]=c;let u=Object.values(a);return new d(u,s)}};function zt(t,e){return new Map([...t||new Map,...e||new Map])}function W(t,e="float32"){return t instanceof Date?"date-millisecond":t instanceof Number?e:typeof t=="string"?"utf8":(t===null||t==="undefined","null")}function Y(t){let e=jt(t);return e!=="null"?{type:e,nullable:!1}:t.length>0?(e=W(t[0]),{type:e,nullable:!0}):{type:"null",nullable:!0}}function jt(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function $t(t,e){if(!e)switch(t){case"int8":return Int8Array;case"uint8":return Uint8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;default:break}return Array}function w(t){switch(t.shape){case"array-row-table":case"object-row-table":return he(t.data);case"geojson-table":return me(t.features);case"columnar-table":return ue(t.data);case"arrow-table":default:throw new Error("Deduce schema")}}function ue(t){let e=[];for(let[r,s]of Object.entries(t)){let a=de(s,r);e.push(a)}return{fields:e,metadata:{}}}function he(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0];for(let[s,a]of Object.entries(r))e.push(Wt(a,s));return{fields:e,metadata:{}}}function me(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0].properties||{};for(let[s,a]of Object.entries(r))e.push(Wt(a,s));return{fields:e,metadata:{}}}function de(t,e){if(ArrayBuffer.isView(t)){let r=Y(t);return{name:e,type:r.type||"null",nullable:r.nullable}}if(Array.isArray(t)&&t.length>0){let r=t[0],s=W(r);return{name:e,type:s,nullable:!0}}throw new Error("empty table")}function Wt(t,e){let r=W(t);return{name:e,type:r,nullable:!0}}var It=class{table;columnName;constructor(e,r){this.table=e,this.columnName=r}get(e){return j(this.table,e,this.columnName)}toArray(){switch(this.table.shape){case"arrow-table":return this.table.data.getChild(this.columnName)?.toArray();case"columnar-table":return this.table.data[this.columnName];default:throw new Error(this.table.shape)}}},P=class{schema;table;constructor(e){let r=e.schema||w(e);this.schema=new d(r.fields,r.metadata),this.table={...e,schema:r}}get data(){return this.table.shape==="geojson-table"?this.table.features:this.table.data}get numCols(){return $(this.table)}get length(){return h(this.table)}getChild(e){return new It(this.table,e)}};function Yt(t){let e;switch(fe(t)){case"array-row-table":e={shape:"array-row-table",data:t};break;case"object-row-table":e={shape:"object-row-table",data:t};break;case"columnar-table":e={shape:"columnar-table",data:t};break;default:throw new Error("table")}let r=w(e);return{...e,schema:r}}function fe(t){if(Array.isArray(t)){if(t.length===0)throw new Error("cannot deduce type of empty table");let e=t[0];if(Array.isArray(e))return"array-row-table";if(e&&typeof e=="object")return"object-row-table"}if(t&&typeof t=="object")return"columnar-table";throw new Error("invalid table")}function Pt(t){return{...t,length:h(t),batchType:"data"}}async function qt(t){let e,r,s,a=null,u;for await(let c of t)switch(a=a||c.shape,u=u||c.schema,c.shape){case"array-row-table":e=e||[];for(let l=0;l<h(c);l++){let o=c.data[l];e.push(o)}break;case"object-row-table":r=r||[];for(let l=0;l<h(c);l++){let o=c.data[l];r.push(o)}break;case"geojson-table":s=s||[];for(let l=0;l<h(c);l++){let o=c.features[l];s.push(o)}break;case"columnar-table":case"arrow-table":default:throw new Error("shape")}if(!a)return null;switch(a){case"array-row-table":return{shape:"array-row-table",data:e,schema:u};case"object-row-table":return{shape:"object-row-table",data:r,schema:u};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:s,schema:u};default:return null}}function Ht(t,e){let r=$t(t.type,t.nullable);return new r(e)}function Jt(t,e){switch(e){case"object-row-table":return be(t);case"array-row-table":return we(t);case"columnar-table":return ge(t);case"arrow-table":return pe(t);default:throw new Error(e)}}function pe(t){let e=globalThis.__loaders?._makeArrowTable;if(!e)throw new Error("");return e(t)}function ge(t){let e=t.schema||w(t),r=t.schema?.fields||[];if(t.shape==="columnar-table")return{...t,schema:e};let s=h(t),a={};for(let u of r){let c=Ht(u,s);a[u.name]=c;for(let l=0;l<s;l++)c[l]=j(t,l,u.name)}return{shape:"columnar-table",schema:e,data:a}}function we(t){if(t.shape==="array-row-table")return t;let e=h(t),r=new Array(e);for(let s=0;s<e;s++)r[s]=E(t,s);return{shape:"array-row-table",schema:t.schema,data:r}}function be(t){if(t.shape==="object-row-table")return t;let e=h(t),r=new Array(e);for(let s=0;s<e;s++)r[s]=N(t,s);return{shape:"object-row-table",schema:t.schema,data:r}}function Vt(t){let e=0;for(let r in t){let s=t[r];ArrayBuffer.isView(s)&&(e+=s.byteLength*s.BYTES_PER_ELEMENT)}return e}function Gt(t){let e=1/0,r=1/0,s=1/0,a=-1/0,u=-1/0,c=-1/0,l=t.POSITION?t.POSITION.value:[],o=l&&l.length;for(let n=0;n<o;n+=3){let g=l[n],D=l[n+1],_=l[n+2];e=g<e?g:e,r=D<r?D:r,s=_<s?_:s,a=g>a?g:a,u=D>u?D:u,c=_>c?_:c}return[[e,r,s],[a,u,c]]}function Xt(t,e={}){return{fields:ye(t),metadata:e}}function Tt(t,e,r){let s=jt(e.value),a=r||Ot(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:s}]},nullable:!1,metadata:a}}function ye(t){let e=[];for(let r in t){let s=t[r];e.push(Tt(r,s))}return e}function Ot(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}var i;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"})(i||(i={}));var m=class{static isNull(e){return e&&e.typeId===i.Null}static isInt(e){return e&&e.typeId===i.Int}static isFloat(e){return e&&e.typeId===i.Float}static isBinary(e){return e&&e.typeId===i.Binary}static isUtf8(e){return e&&e.typeId===i.Utf8}static isBool(e){return e&&e.typeId===i.Bool}static isDecimal(e){return e&&e.typeId===i.Decimal}static isDate(e){return e&&e.typeId===i.Date}static isTime(e){return e&&e.typeId===i.Time}static isTimestamp(e){return e&&e.typeId===i.Timestamp}static isInterval(e){return e&&e.typeId===i.Interval}static isList(e){return e&&e.typeId===i.List}static isStruct(e){return e&&e.typeId===i.Struct}static isUnion(e){return e&&e.typeId===i.Union}static isFixedSizeBinary(e){return e&&e.typeId===i.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===i.FixedSizeList}static isMap(e){return e&&e.typeId===i.Map}static isDictionary(e){return e&&e.typeId===i.Dictionary}get typeId(){return i.NONE}compareTo(e){return this===e}},q=class extends m{get typeId(){return i.Null}get[Symbol.toStringTag](){return"Null"}toString(){return"Null"}},H=class extends m{get typeId(){return i.Bool}get[Symbol.toStringTag](){return"Bool"}toString(){return"Bool"}},f=class extends m{isSigned;bitWidth;constructor(e,r){super(),this.isSigned=e,this.bitWidth=r}get typeId(){return i.Int}get[Symbol.toStringTag](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}},J=class extends f{constructor(){super(!0,8)}},V=class extends f{constructor(){super(!0,16)}},G=class extends f{constructor(){super(!0,32)}},X=class extends f{constructor(){super(!0,64)}},Z=class extends f{constructor(){super(!1,8)}},K=class extends f{constructor(){super(!1,16)}},Q=class extends f{constructor(){super(!1,32)}},tt=class extends f{constructor(){super(!1,64)}},Ft={HALF:16,SINGLE:32,DOUBLE:64},x=class extends m{precision;constructor(e){super(),this.precision=e}get typeId(){return i.Float}get[Symbol.toStringTag](){return"Float"}toString(){return`Float${this.precision}`}},et=class extends x{constructor(){super(Ft.HALF)}},rt=class extends x{constructor(){super(Ft.SINGLE)}},st=class extends x{constructor(){super(Ft.DOUBLE)}},at=class extends m{constructor(){super()}get typeId(){return i.Binary}toString(){return"Binary"}get[Symbol.toStringTag](){return"Binary"}},ot=class extends m{get typeId(){return i.Utf8}get[Symbol.toStringTag](){return"Utf8"}toString(){return"Utf8"}},Rt={DAY:0,MILLISECOND:1},I=class extends m{unit;constructor(e){super(),this.unit=e}get typeId(){return i.Date}get[Symbol.toStringTag](){return"Date"}toString(){return`Date${(this.unit+1)*32}<${Rt[this.unit]}>`}},nt=class extends I{constructor(){super(Rt.DAY)}},it=class extends I{constructor(){super(Rt.MILLISECOND)}},y={SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},T=class extends m{unit;bitWidth;constructor(e,r){super(),this.unit=e,this.bitWidth=r}get typeId(){return i.Time}toString(){return`Time${this.bitWidth}<${y[this.unit]}>`}get[Symbol.toStringTag](){return"Time"}},ct=class extends T{constructor(){super(y.SECOND,32)}},lt=class extends T{constructor(){super(y.MILLISECOND,32)}},b=class extends m{unit;timezone;constructor(e,r=null){super(),this.unit=e,this.timezone=r}get typeId(){return i.Timestamp}get[Symbol.toStringTag](){return"Timestamp"}toString(){return`Timestamp<${y[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}},ut=class extends b{constructor(e=null){super(y.SECOND,e)}},ht=class extends b{constructor(e=null){super(y.MILLISECOND,e)}},mt=class extends b{constructor(e=null){super(y.MICROSECOND,e)}},dt=class extends b{constructor(e=null){super(y.NANOSECOND,e)}},Nt={DAY_TIME:0,YEAR_MONTH:1},O=class extends m{unit;constructor(e){super(),this.unit=e}get typeId(){return i.Interval}get[Symbol.toStringTag](){return"Interval"}toString(){return`Interval<${Nt[this.unit]}>`}},ft=class extends O{constructor(){super(Nt.DAY_TIME)}},pt=class extends O{constructor(){super(Nt.YEAR_MONTH)}},gt=class extends m{listSize;children;constructor(e,r){super(),this.listSize=e,this.children=[r]}get typeId(){return i.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[Symbol.toStringTag](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${JSON.stringify(this.valueType)}>`}},wt=class extends m{children;constructor(e){super(),this.children=e}get typeId(){return i.Struct}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${JSON.stringify(e.type)}`).join(", ")}}>`}get[Symbol.toStringTag](){return"Struct"}};function Zt(t){return{typeId:t.typeId,ArrayType:t.ArrayType,typeName:t.toString(),typeEnumName:xe(t.typeId),precision:t.precision}}var bt=null;function xe(t){if(!bt){bt={};for(let e in i)bt[i[e]]=e}return bt[t]}var yt=class extends Array{enqueue(e){return this.push(e)}dequeue(){return this.shift()}},B=class{_values;_settlers;_closed;constructor(){this._values=new yt,this._settlers=new yt,this._closed=!1}close(){for(;this._settlers.length>0;)this._settlers.dequeue().resolve({done:!0});this._closed=!0}[Symbol.asyncIterator](){return this}enqueue(e){if(this._closed)throw new Error("Closed");if(this._settlers.length>0){if(this._values.length>0)throw new Error("Illegal internal state");let r=this._settlers.dequeue();e instanceof Error?r.reject(e):r.resolve({value:e})}else this._values.enqueue(e)}next(){if(this._values.length>0){let e=this._values.dequeue();return e instanceof Error?Promise.reject(e):Promise.resolve({value:e})}if(this._closed){if(this._settlers.length>0)throw new Error("Illegal internal state");return Promise.resolve({done:!0})}return new Promise((e,r)=>{this._settlers.enqueue({resolve:e,reject:r})})}};return ie(C);})();
"use strict";var __exports__=(()=>{var Kt=Object.create;var F=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=(t,e,r)=>e in t?F(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ae=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),oe=(t,e)=>{for(var r in e)F(t,r,{get:e[r],enumerable:!0})},M=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of te(e))!re.call(t,a)&&a!==r&&F(t,a,{get:()=>e[a],enumerable:!(s=Qt(e,a))||s.enumerable});return t},U=(t,e,r)=>(M(t,e,"default"),r&&M(r,e,"default")),ne=(t,e,r)=>(r=t!=null?Kt(ee(t)):{},M(e||!t||!t.__esModule?F(r,"default",{value:t,enumerable:!0}):r,t)),ie=t=>M(F({},"__esModule",{value:!0}),t);var Bt=(t,e,r)=>(se(t,typeof e!="symbol"?e+"":e,r),r);var Dt=ae((Se,Ct)=>{Ct.exports=globalThis.loaders});var C={};oe(C,{ArrowLikeDataType:()=>m,ArrowLikeField:()=>p,ArrowLikeSchema:()=>d,ArrowLikeTable:()=>q,AsyncQueue:()=>B,Binary:()=>ot,Bool:()=>J,ColumnarTableBatchAggregator:()=>S,Date:()=>I,DateDay:()=>it,DateMillisecond:()=>ct,FixedSizeList:()=>wt,Float:()=>x,Float16:()=>rt,Float32:()=>st,Float64:()=>at,Int:()=>f,Int16:()=>G,Int32:()=>X,Int64:()=>Z,Int8:()=>V,Interval:()=>O,IntervalDayTime:()=>pt,IntervalYearMonth:()=>gt,Null:()=>H,RowTableBatchAggregator:()=>A,Struct:()=>bt,TableBatchBuilder:()=>R,Time:()=>T,TimeMillisecond:()=>ut,TimeSecond:()=>lt,Timestamp:()=>b,TimestampMicrosecond:()=>dt,TimestampMillisecond:()=>mt,TimestampNanosecond:()=>ft,TimestampSecond:()=>ht,Uint16:()=>Q,Uint32:()=>tt,Uint64:()=>et,Uint8:()=>K,Utf8:()=>nt,convertTable:()=>Jt,convertToArrayRow:()=>W,convertToObjectRow:()=>$,deduceMeshField:()=>Ot,deduceMeshSchema:()=>Xt,deduceTableSchema:()=>w,getArrayTypeFromDataType:()=>L,getDataTypeFromArray:()=>v,getMeshBoundingBox:()=>Gt,getMeshSize:()=>Vt,getTableCell:()=>j,getTableColumnIndex:()=>St,getTableColumnName:()=>Lt,getTableLength:()=>h,getTableNumCols:()=>P,getTableRowAsArray:()=>E,getTableRowAsObject:()=>N,getTableRowShape:()=>vt,getTypeInfo:()=>Zt,isTable:()=>kt,makeArrayRowIterator:()=>jt,makeBatchFromTable:()=>Pt,makeMeshAttributeMetadata:()=>Ft,makeObjectRowIterator:()=>It,makeRowIterator:()=>zt,makeTableFromBatches:()=>qt,makeTableFromData:()=>Yt});U(C,ne(Dt(),1));function k(t,e="float32"){return t instanceof Date?"date-millisecond":t instanceof Number?e:typeof t=="string"?"utf8":(t===null||t==="undefined","null")}function v(t){let e=At(t);return e!=="null"?{type:e,nullable:!1}:t.length>0?(e=k(t[0]),{type:e,nullable:!0}):{type:"null",nullable:!0}}function At(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function L(t,e){if(!e)switch(t){case"int8":return Int8Array;case"uint8":return Uint8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;default:break}return Array}var z=class{schema;options;shape;length=0;rows=null;cursor=0;_headers=[];constructor(e,r){if(this.options=r,this.schema=e,!Array.isArray(e)){this._headers=[];for(let s in e)this._headers[e[s].index]=e[s].name}}rowCount(){return this.length}addArrayRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}addObjectRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}getBatch(){let e=this.rows;return e?(e=e.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function $(t,e){if(!t)throw new Error("null row");let r={};if(e)for(let s=0;s<e.length;s++)r[e[s]]=t[s];else for(let s=0;s<t.length;s++){let a=`column-${s}`;r[a]=t[s]}return r}function W(t,e){if(!t)throw new Error("null row");if(e){let r=new Array(e.length);for(let s=0;s<e.length;s++)r[s]=t[e[s]];return r}return Object.values(t)}function _t(t){let e=[];for(let r=0;r<t.length;r++){let s=`column-${r}`;e.push(s)}return e}function Mt(t){return Object.keys(t)}var Ut=100,A=class{schema;options;length=0;objectRows=null;arrayRows=null;cursor=0;_headers=null;constructor(e,r){if(this.options=r,this.schema=e,e){this._headers=[];for(let s in e)this._headers[e[s].index]=e[s].name}}rowCount(){return this.length}addArrayRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=_t(e),this.options.shape){case"object-row-table":let s=$(e,this._headers);this.addObjectRow(s,r);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Ut),this.arrayRows[this.length]=e,this.length++;break}}addObjectRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=Mt(e),this.options.shape){case"array-row-table":let s=W(e,this._headers);this.addArrayRow(s,r);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Ut),this.objectRows[this.length]=e,this.length++;break}}getBatch(){let e=this.arrayRows||this.objectRows;return e?(e=e.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var S=class{schema;length=0;allocated=0;columns={};constructor(e,r){this.schema=e,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(e){this._reallocateColumns();let r=0;for(let s in this.columns)this.columns[s][this.length]=e[r++];this.length++}addObjectRow(e){this._reallocateColumns();for(let r in e)this.columns[r][this.length]=e[r];this.length++}getBatch(){this._pruneColumns();let e=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(let s in this.schema){let a=this.schema[s];e[a.name]=this.columns[a.index]}return this.columns={},{shape:"columnar-table",batchType:"data",data:e,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:100,this.columns={};for(let e in this.schema){let r=this.schema[e],s=r.type||Float32Array,a=this.columns[r.index];if(a&&ArrayBuffer.isView(a)){let u=new s(this.allocated);u.set(a),this.columns[r.index]=u}else a?(a.length=this.allocated,this.columns[r.index]=a):this.columns[r.index]=new s(this.allocated)}}}_pruneColumns(){for(let[e,r]of Object.entries(this.columns))this.columns[e]=r.slice(0,this.length)}};var ce={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},le="TableBatchBuilder",Y=class{schema;options;aggregator=null;batchCount=0;bytesUsed=0;isChunkComplete=!1;lastBatchEmittedMs=Date.now();totalLength=0;totalBytes=0;rowBytes=0;constructor(e,r){this.schema=e,this.options={...ce,...r}}limitReached(){return!!(Boolean(this.options?.limit)&&this.totalLength>=this.options.limit||Boolean(this.options?._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(e){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(e),this.totalBytes+=this.rowBytes,Array.isArray(e)?this.addArrayRow(e):this.addObjectRow(e))}addArrayRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addArrayRow(e)}addObjectRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addObjectRow(e)}chunkComplete(e){e instanceof ArrayBuffer&&(this.bytesUsed+=e.byteLength),typeof e=="string"&&(this.bytesUsed+=e.length),this.isChunkComplete=!0}getFullBatch(e){return this._isFull()?this._getBatch(e):null}getFinalBatch(e){return this._getBatch(e)}_estimateRowMB(e){return Array.isArray(e)?e.length*8:Object.keys(e).length*8}_isFull(){if(!this.aggregator||this.aggregator.rowCount()===0)return!1;if(this.options.batchSize==="auto"){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs?!1:(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(e){if(!this.aggregator)return null;e?.bytesUsed&&(this.bytesUsed=e.bytesUsed);let r=this.aggregator.getBatch();return r.count=this.batchCount,r.bytesUsed=this.bytesUsed,Object.assign(r,e),this.batchCount++,this.aggregator=null,r}_getTableBatchType(){switch(this.options.shape){case"array-row-table":case"object-row-table":return A;case"columnar-table":return S;case"arrow-table":if(!Y.ArrowBatch)throw new Error(le);return Y.ArrowBatch;default:return z}}},R=Y;Bt(R,"ArrowBatch");function kt(t){switch(typeof t=="object"&&t?.shape){case"array-row-table":case"object-row-table":return Array.isArray(t.data);case"geojson-table":return Array.isArray(t.features);case"columnar-table":return t.data&&typeof t.data=="object";case"arrow-table":return Boolean(t?.data?.numRows!==void 0);default:return!1}}function h(t){switch(t.shape){case"array-row-table":case"object-row-table":return t.data.length;case"geojson-table":return t.features.length;case"arrow-table":return t.data.numRows;case"columnar-table":for(let r of Object.values(t.data))return r.length||0;return 0;default:throw new Error("table")}}function P(t){if(t.schema)return t.schema.fields.length;if(h(t)===0)throw new Error("empty table");switch(t.shape){case"array-row-table":return t.data[0].length;case"object-row-table":return Object.keys(t.data[0]).length;case"geojson-table":return Object.keys(t.features[0]).length;case"columnar-table":return Object.keys(t.data).length;case"arrow-table":return t.data.numCols;default:throw new Error("table")}}function j(t,e,r){switch(t.shape){case"array-row-table":let s=St(t,r);return t.data[e][s];case"object-row-table":return t.data[e][r];case"geojson-table":return t.features[e][r];case"columnar-table":return t.data[r][e];case"arrow-table":let u=t.data,c=u.schema.fields.findIndex(l=>l.name===r);return u.getChildAt(c)?.get(e);default:throw new Error("todo")}}function vt(t){switch(t.shape){case"array-row-table":case"object-row-table":return t.shape;case"geojson-table":return"object-row-table";case"columnar-table":default:throw new Error("Not a row table")}}function St(t,e){let r=t.schema?.fields.findIndex(s=>s.name===e);if(r===void 0)throw new Error(e);return r}function Lt(t,e){let r=t.schema?.fields[e]?.name;if(!r)throw new Error(`${e}`);return r}function N(t,e,r,s){switch(t.shape){case"object-row-table":return s?Object.fromEntries(Object.entries(t.data[e])):t.data[e];case"array-row-table":if(t.schema){let o=r||{};for(let n=0;n<t.schema.fields.length;n++)o[t.schema.fields[n].name]=t.data[e][n];return o}throw new Error("no schema");case"geojson-table":if(t.schema){let o=r||{};for(let n=0;n<t.schema.fields.length;n++)o[t.schema.fields[n].name]=t.features[e][n];return o}throw new Error("no schema");case"columnar-table":if(t.schema){let o=r||{};for(let n=0;n<t.schema.fields.length;n++)o[t.schema.fields[n].name]=t.data[t.schema.fields[n].name][e];return o}else{let o=r||{};for(let[n,g]of Object.entries(t.data))o[n]=g[e];return o}case"arrow-table":let a=t.data,u=r||{},c=a.get(e),l=a.schema;for(let o=0;o<l.fields.length;o++)u[l.fields[o].name]=c?.[l.fields[o].name];return u;default:throw new Error("shape")}}function E(t,e,r,s){switch(t.shape){case"array-row-table":return s?Array.from(t.data[e]):t.data[e];case"object-row-table":if(t.schema){let o=r||[];for(let n=0;n<t.schema.fields.length;n++)o[n]=t.data[e][t.schema.fields[n].name];return o}return Object.values(t.data[e]);case"geojson-table":if(t.schema){let o=r||[];for(let n=0;n<t.schema.fields.length;n++)o[n]=t.features[e][t.schema.fields[n].name];return o}return Object.values(t.features[e]);case"columnar-table":if(t.schema){let o=r||[];for(let n=0;n<t.schema.fields.length;n++)o[n]=t.data[t.schema.fields[n].name][e];return o}else{let o=r||[],n=0;for(let g of Object.values(t.data))o[n]=g[e],n++;return o}case"arrow-table":let a=t.data,u=r||[],c=a.get(e),l=a.schema;for(let o=0;o<l.fields.length;o++)u[o]=c?.[l.fields[o].name];return u;default:throw new Error("shape")}}function*zt(t,e){switch(e){case"array-row-table":yield*jt(t);break;case"object-row-table":yield*It(t);break;default:throw new Error(`Unknown row type ${e}`)}}function*jt(t,e=[]){let r=h(t);for(let s=0;s<r;s++)yield E(t,s,e)}function*It(t,e={}){let r=h(t);for(let s=0;s<r;s++)yield N(t,s,e)}var p=class{name;type;nullable;metadata;constructor(e,r,s=!1,a=new Map){this.name=e,this.type=r,this.nullable=s,this.metadata=a}get typeId(){return this.type&&this.type.typeId}clone(){return new p(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return`${JSON.stringify(this.type)}${this.nullable?", nullable":""}${this.metadata?`, metadata: ${JSON.stringify(this.metadata)}`:""}`}};var d=class{fields;metadata;constructor(e,r=new Map){this.fields=e.map(s=>new p(s.name,s.type,s.nullable,s.metadata)),this.metadata=r instanceof Map?r:new Map(Object.entries(r))}compareTo(e){if(this.metadata!==e.metadata||this.fields.length!==e.fields.length)return!1;for(let r=0;r<this.fields.length;++r)if(!this.fields[r].compareTo(e.fields[r]))return!1;return!0}select(...e){let r=Object.create(null);for(let a of e)r[a]=!0;let s=this.fields.filter(a=>r[a.name]);return new d(s,this.metadata)}selectAt(...e){let r=e.map(s=>this.fields[s]).filter(Boolean);return new d(r,this.metadata)}assign(e){let r,s=this.metadata;if(e instanceof d){let c=e;r=c.fields,s=$t($t(new Map,this.metadata),c.metadata)}else r=e;let a=Object.create(null);for(let c of this.fields)a[c.name]=c;for(let c of r)a[c.name]=c;let u=Object.values(a);return new d(u,s)}};function $t(t,e){return new Map([...t||new Map,...e||new Map])}function w(t){switch(t.shape){case"array-row-table":case"object-row-table":return he(t.data);case"geojson-table":return me(t.features);case"columnar-table":return ue(t.data);case"arrow-table":default:throw new Error("Deduce schema")}}function ue(t){let e=[];for(let[r,s]of Object.entries(t)){let a=de(s,r);e.push(a)}return{fields:e,metadata:{}}}function he(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0];for(let[s,a]of Object.entries(r))e.push(Wt(a,s));return{fields:e,metadata:{}}}function me(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0].properties||{};for(let[s,a]of Object.entries(r))e.push(Wt(a,s));return{fields:e,metadata:{}}}function de(t,e){if(ArrayBuffer.isView(t)){let r=v(t);return{name:e,type:r.type||"null",nullable:r.nullable}}if(Array.isArray(t)&&t.length>0){let r=t[0],s=k(r);return{name:e,type:s,nullable:!0}}throw new Error("empty table")}function Wt(t,e){let r=k(t);return{name:e,type:r,nullable:!0}}var Tt=class{table;columnName;constructor(e,r){this.table=e,this.columnName=r}get(e){return j(this.table,e,this.columnName)}toArray(){switch(this.table.shape){case"arrow-table":return this.table.data.getChild(this.columnName)?.toArray();case"columnar-table":return this.table.data[this.columnName];default:throw new Error(this.table.shape)}}},q=class{schema;table;constructor(e){let r=e.schema||w(e);this.schema=new d(r.fields,r.metadata),this.table={...e,schema:r}}get data(){return this.table.shape==="geojson-table"?this.table.features:this.table.data}get numCols(){return P(this.table)}get length(){return h(this.table)}getChild(e){return new Tt(this.table,e)}};function Yt(t){let e;switch(fe(t)){case"array-row-table":e={shape:"array-row-table",data:t};break;case"object-row-table":e={shape:"object-row-table",data:t};break;case"columnar-table":e={shape:"columnar-table",data:t};break;default:throw new Error("table")}let r=w(e);return{...e,schema:r}}function fe(t){if(Array.isArray(t)){if(t.length===0)throw new Error("cannot deduce type of empty table");let e=t[0];if(Array.isArray(e))return"array-row-table";if(e&&typeof e=="object")return"object-row-table"}if(t&&typeof t=="object")return"columnar-table";throw new Error("invalid table")}function Pt(t){return{...t,length:h(t),batchType:"data"}}async function qt(t){let e,r,s,a=null,u;for await(let c of t)switch(a=a||c.shape,u=u||c.schema,c.shape){case"array-row-table":e=e||[];for(let l=0;l<h(c);l++){let o=c.data[l];e.push(o)}break;case"object-row-table":r=r||[];for(let l=0;l<h(c);l++){let o=c.data[l];r.push(o)}break;case"geojson-table":s=s||[];for(let l=0;l<h(c);l++){let o=c.features[l];s.push(o)}break;case"columnar-table":case"arrow-table":default:throw new Error("shape")}if(!a)return null;switch(a){case"array-row-table":return{shape:"array-row-table",data:e,schema:u};case"object-row-table":return{shape:"object-row-table",data:r,schema:u};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:s,schema:u};default:return null}}function Ht(t,e){let r=L(t.type,t.nullable);return new r(e)}function Jt(t,e){switch(e){case"object-row-table":return be(t);case"array-row-table":return we(t);case"columnar-table":return ge(t);case"arrow-table":return pe(t);default:throw new Error(e)}}function pe(t){let e=globalThis.__loaders?._makeArrowTable;if(!e)throw new Error("");return e(t)}function ge(t){let e=t.schema||w(t),r=t.schema?.fields||[];if(t.shape==="columnar-table")return{...t,schema:e};let s=h(t),a={};for(let u of r){let c=Ht(u,s);a[u.name]=c;for(let l=0;l<s;l++)c[l]=j(t,l,u.name)}return{shape:"columnar-table",schema:e,data:a}}function we(t){if(t.shape==="array-row-table")return t;let e=h(t),r=new Array(e);for(let s=0;s<e;s++)r[s]=E(t,s);return{shape:"array-row-table",schema:t.schema,data:r}}function be(t){if(t.shape==="object-row-table")return t;let e=h(t),r=new Array(e);for(let s=0;s<e;s++)r[s]=N(t,s);return{shape:"object-row-table",schema:t.schema,data:r}}function Vt(t){let e=0;for(let r in t){let s=t[r];ArrayBuffer.isView(s)&&(e+=s.byteLength*s.BYTES_PER_ELEMENT)}return e}function Gt(t){let e=1/0,r=1/0,s=1/0,a=-1/0,u=-1/0,c=-1/0,l=t.POSITION?t.POSITION.value:[],o=l&&l.length;for(let n=0;n<o;n+=3){let g=l[n],D=l[n+1],_=l[n+2];e=g<e?g:e,r=D<r?D:r,s=_<s?_:s,a=g>a?g:a,u=D>u?D:u,c=_>c?_:c}return[[e,r,s],[a,u,c]]}function Xt(t,e={}){return{fields:ye(t),metadata:e}}function Ot(t,e,r){let s=At(e.value),a=r||Ft(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:s}]},nullable:!1,metadata:a}}function ye(t){let e=[];for(let r in t){let s=t[r];e.push(Ot(r,s))}return e}function Ft(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}var i;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"})(i||(i={}));var m=class{static isNull(e){return e&&e.typeId===i.Null}static isInt(e){return e&&e.typeId===i.Int}static isFloat(e){return e&&e.typeId===i.Float}static isBinary(e){return e&&e.typeId===i.Binary}static isUtf8(e){return e&&e.typeId===i.Utf8}static isBool(e){return e&&e.typeId===i.Bool}static isDecimal(e){return e&&e.typeId===i.Decimal}static isDate(e){return e&&e.typeId===i.Date}static isTime(e){return e&&e.typeId===i.Time}static isTimestamp(e){return e&&e.typeId===i.Timestamp}static isInterval(e){return e&&e.typeId===i.Interval}static isList(e){return e&&e.typeId===i.List}static isStruct(e){return e&&e.typeId===i.Struct}static isUnion(e){return e&&e.typeId===i.Union}static isFixedSizeBinary(e){return e&&e.typeId===i.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===i.FixedSizeList}static isMap(e){return e&&e.typeId===i.Map}static isDictionary(e){return e&&e.typeId===i.Dictionary}get typeId(){return i.NONE}compareTo(e){return this===e}},H=class extends m{get typeId(){return i.Null}get[Symbol.toStringTag](){return"Null"}toString(){return"Null"}},J=class extends m{get typeId(){return i.Bool}get[Symbol.toStringTag](){return"Bool"}toString(){return"Bool"}},f=class extends m{isSigned;bitWidth;constructor(e,r){super(),this.isSigned=e,this.bitWidth=r}get typeId(){return i.Int}get[Symbol.toStringTag](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}},V=class extends f{constructor(){super(!0,8)}},G=class extends f{constructor(){super(!0,16)}},X=class extends f{constructor(){super(!0,32)}},Z=class extends f{constructor(){super(!0,64)}},K=class extends f{constructor(){super(!1,8)}},Q=class extends f{constructor(){super(!1,16)}},tt=class extends f{constructor(){super(!1,32)}},et=class extends f{constructor(){super(!1,64)}},Rt={HALF:16,SINGLE:32,DOUBLE:64},x=class extends m{precision;constructor(e){super(),this.precision=e}get typeId(){return i.Float}get[Symbol.toStringTag](){return"Float"}toString(){return`Float${this.precision}`}},rt=class extends x{constructor(){super(Rt.HALF)}},st=class extends x{constructor(){super(Rt.SINGLE)}},at=class extends x{constructor(){super(Rt.DOUBLE)}},ot=class extends m{constructor(){super()}get typeId(){return i.Binary}toString(){return"Binary"}get[Symbol.toStringTag](){return"Binary"}},nt=class extends m{get typeId(){return i.Utf8}get[Symbol.toStringTag](){return"Utf8"}toString(){return"Utf8"}},Nt={DAY:0,MILLISECOND:1},I=class extends m{unit;constructor(e){super(),this.unit=e}get typeId(){return i.Date}get[Symbol.toStringTag](){return"Date"}toString(){return`Date${(this.unit+1)*32}<${Nt[this.unit]}>`}},it=class extends I{constructor(){super(Nt.DAY)}},ct=class extends I{constructor(){super(Nt.MILLISECOND)}},y={SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},T=class extends m{unit;bitWidth;constructor(e,r){super(),this.unit=e,this.bitWidth=r}get typeId(){return i.Time}toString(){return`Time${this.bitWidth}<${y[this.unit]}>`}get[Symbol.toStringTag](){return"Time"}},lt=class extends T{constructor(){super(y.SECOND,32)}},ut=class extends T{constructor(){super(y.MILLISECOND,32)}},b=class extends m{unit;timezone;constructor(e,r=null){super(),this.unit=e,this.timezone=r}get typeId(){return i.Timestamp}get[Symbol.toStringTag](){return"Timestamp"}toString(){return`Timestamp<${y[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}},ht=class extends b{constructor(e=null){super(y.SECOND,e)}},mt=class extends b{constructor(e=null){super(y.MILLISECOND,e)}},dt=class extends b{constructor(e=null){super(y.MICROSECOND,e)}},ft=class extends b{constructor(e=null){super(y.NANOSECOND,e)}},Et={DAY_TIME:0,YEAR_MONTH:1},O=class extends m{unit;constructor(e){super(),this.unit=e}get typeId(){return i.Interval}get[Symbol.toStringTag](){return"Interval"}toString(){return`Interval<${Et[this.unit]}>`}},pt=class extends O{constructor(){super(Et.DAY_TIME)}},gt=class extends O{constructor(){super(Et.YEAR_MONTH)}},wt=class extends m{listSize;children;constructor(e,r){super(),this.listSize=e,this.children=[r]}get typeId(){return i.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[Symbol.toStringTag](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${JSON.stringify(this.valueType)}>`}},bt=class extends m{children;constructor(e){super(),this.children=e}get typeId(){return i.Struct}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${JSON.stringify(e.type)}`).join(", ")}}>`}get[Symbol.toStringTag](){return"Struct"}};function Zt(t){return{typeId:t.typeId,ArrayType:t.ArrayType,typeName:t.toString(),typeEnumName:xe(t.typeId),precision:t.precision}}var yt=null;function xe(t){if(!yt){yt={};for(let e in i)yt[i[e]]=e}return yt[t]}var xt=class extends Array{enqueue(e){return this.push(e)}dequeue(){return this.shift()}},B=class{_values;_settlers;_closed;constructor(){this._values=new xt,this._settlers=new xt,this._closed=!1}close(){for(;this._settlers.length>0;)this._settlers.dequeue().resolve({done:!0});this._closed=!0}[Symbol.asyncIterator](){return this}enqueue(e){if(this._closed)throw new Error("Closed");if(this._settlers.length>0){if(this._values.length>0)throw new Error("Illegal internal state");let r=this._settlers.dequeue();e instanceof Error?r.reject(e):r.resolve({value:e})}else this._values.enqueue(e)}next(){if(this._values.length>0){let e=this._values.dequeue();return e instanceof Error?Promise.reject(e):Promise.resolve({value:e})}if(this._closed){if(this._settlers.length>0)throw new Error("Illegal internal state");return Promise.resolve({done:!0})}return new Promise((e,r)=>{this._settlers.enqueue({resolve:e,reject:r})})}};return ie(C);})();
return __exports__;
});
export type { TypedArray, BigTypedArray, TypedArrayConstructor, BigTypedArrayConstructor, NumberArray, ArrayType, AnyArray } from "./types/types.js";
export type { Schema, Field, DataType, SchemaMetadata, FieldMetadata } from "./types/schema.js";
export type { Batch } from "./types/batch.js";
export { getArrayTypeFromDataType } from "./lib/table/simple-table/data-type.js";
export type { Table, RowTable, ArrayRowTable, ObjectRowTable, GeoJSONTable, ColumnarTable, ArrowTable, Tables } from "./types/category-table.js";

@@ -5,0 +6,0 @@ export type { TableBatch, ArrayRowTableBatch, ObjectRowTableBatch, GeoJSONTableBatch, ColumnarTableBatch, ArrowTableBatch } from "./types/category-table.js";

// loaders.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
export { getArrayTypeFromDataType } from "./lib/table/simple-table/data-type.js";
// TABLE CATEGORY UTILS

@@ -5,0 +6,0 @@ export { TableBatchBuilder } from "./lib/table/batches/table-batch-builder.js";

{
"name": "@loaders.gl/schema",
"version": "4.3.0-alpha.3",
"version": "4.3.0-alpha.4",
"description": "Table format APIs for JSON, CSV, etc...",

@@ -49,3 +49,3 @@ "license": "MIT",

},
"gitHead": "3213679d79e6ff2814d48fd3337acfa446c74099"
"gitHead": "4900ac4c4de20366c050b80cef04dc5b52d167af"
}

@@ -16,6 +16,9 @@ // loaders.gl

// SCHEMAS AND DATA TYPES
export type {Schema, Field, DataType, SchemaMetadata, FieldMetadata} from './types/schema';
export type {Batch} from './types/batch';
export {getArrayTypeFromDataType} from './lib/table/simple-table/data-type';
// TABLE CATEGORY TYPES

@@ -22,0 +25,0 @@ export type {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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