@loaders.gl/shapefile 4.0.0-alpha.5 → 4.0.0-alpha.6

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.
Files changed (124) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/dbf-loader.js +29 -20
  3. package/dist/dbf-worker.js +73 -447
  4. package/dist/dist.min.js +130 -489
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/dbf-loader.js +53 -0
  8. package/dist/es5/dbf-loader.js.map +1 -0
  9. package/dist/es5/index.js +39 -0
  10. package/dist/es5/index.js.map +1 -0
  11. package/dist/es5/lib/parsers/parse-dbf.js +394 -0
  12. package/dist/es5/lib/parsers/parse-dbf.js.map +1 -0
  13. package/dist/es5/lib/parsers/parse-shapefile.js +373 -0
  14. package/dist/es5/lib/parsers/parse-shapefile.js.map +1 -0
  15. package/dist/es5/lib/parsers/parse-shp-geometry.js +220 -0
  16. package/dist/es5/lib/parsers/parse-shp-geometry.js.map +1 -0
  17. package/dist/es5/lib/parsers/parse-shp-header.js +35 -0
  18. package/dist/es5/lib/parsers/parse-shp-header.js.map +1 -0
  19. package/dist/es5/lib/parsers/parse-shp.js +227 -0
  20. package/dist/es5/lib/parsers/parse-shp.js.map +1 -0
  21. package/dist/es5/lib/parsers/parse-shx.js +26 -0
  22. package/dist/es5/lib/parsers/parse-shx.js.map +1 -0
  23. package/dist/es5/lib/parsers/types.js +2 -0
  24. package/dist/es5/lib/parsers/types.js.map +1 -0
  25. package/dist/es5/lib/streaming/binary-chunk-reader.js +178 -0
  26. package/dist/es5/lib/streaming/binary-chunk-reader.js.map +1 -0
  27. package/dist/es5/lib/streaming/binary-reader.js +48 -0
  28. package/dist/es5/lib/streaming/binary-reader.js.map +1 -0
  29. package/dist/es5/lib/streaming/zip-batch-iterators.js +91 -0
  30. package/dist/es5/lib/streaming/zip-batch-iterators.js.map +1 -0
  31. package/dist/es5/shapefile-loader.js +31 -0
  32. package/dist/es5/shapefile-loader.js.map +1 -0
  33. package/dist/es5/shp-loader.js +56 -0
  34. package/dist/es5/shp-loader.js.map +1 -0
  35. package/dist/es5/workers/dbf-worker.js +6 -0
  36. package/dist/es5/workers/dbf-worker.js.map +1 -0
  37. package/dist/es5/workers/shp-worker.js +6 -0
  38. package/dist/es5/workers/shp-worker.js.map +1 -0
  39. package/dist/esm/bundle.js +4 -0
  40. package/dist/esm/bundle.js.map +1 -0
  41. package/dist/esm/dbf-loader.js +24 -0
  42. package/dist/esm/dbf-loader.js.map +1 -0
  43. package/dist/esm/index.js +4 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/lib/parsers/parse-dbf.js +296 -0
  46. package/dist/esm/lib/parsers/parse-dbf.js.map +1 -0
  47. package/dist/esm/lib/parsers/parse-shapefile.js +187 -0
  48. package/dist/esm/lib/parsers/parse-shapefile.js.map +1 -0
  49. package/dist/esm/lib/parsers/parse-shp-geometry.js +191 -0
  50. package/dist/esm/lib/parsers/parse-shp-geometry.js.map +1 -0
  51. package/dist/esm/lib/parsers/parse-shp-header.js +29 -0
  52. package/dist/esm/lib/parsers/parse-shp-header.js.map +1 -0
  53. package/dist/esm/lib/parsers/parse-shp.js +134 -0
  54. package/dist/esm/lib/parsers/parse-shp.js.map +1 -0
  55. package/dist/esm/lib/parsers/parse-shx.js +20 -0
  56. package/dist/esm/lib/parsers/parse-shx.js.map +1 -0
  57. package/dist/esm/lib/parsers/types.js +2 -0
  58. package/dist/esm/lib/parsers/types.js.map +1 -0
  59. package/dist/esm/lib/streaming/binary-chunk-reader.js +106 -0
  60. package/dist/esm/lib/streaming/binary-chunk-reader.js.map +1 -0
  61. package/dist/esm/lib/streaming/binary-reader.js +27 -0
  62. package/dist/esm/lib/streaming/binary-reader.js.map +1 -0
  63. package/dist/esm/lib/streaming/zip-batch-iterators.js +44 -0
  64. package/dist/esm/lib/streaming/zip-batch-iterators.js.map +1 -0
  65. package/dist/esm/shapefile-loader.js +23 -0
  66. package/dist/esm/shapefile-loader.js.map +1 -0
  67. package/dist/esm/shp-loader.js +26 -0
  68. package/dist/esm/shp-loader.js.map +1 -0
  69. package/dist/esm/workers/dbf-worker.js +4 -0
  70. package/dist/esm/workers/dbf-worker.js.map +1 -0
  71. package/dist/esm/workers/shp-worker.js +4 -0
  72. package/dist/esm/workers/shp-worker.js.map +1 -0
  73. package/dist/index.js +11 -4
  74. package/dist/lib/parsers/parse-dbf.d.ts +4 -18
  75. package/dist/lib/parsers/parse-dbf.d.ts.map +1 -1
  76. package/dist/lib/parsers/parse-dbf.js +309 -264
  77. package/dist/lib/parsers/parse-shapefile.d.ts +3 -8
  78. package/dist/lib/parsers/parse-shapefile.d.ts.map +1 -1
  79. package/dist/lib/parsers/parse-shapefile.js +227 -209
  80. package/dist/lib/parsers/parse-shp-geometry.d.ts +2 -3
  81. package/dist/lib/parsers/parse-shp-geometry.d.ts.map +1 -1
  82. package/dist/lib/parsers/parse-shp-geometry.js +265 -212
  83. package/dist/lib/parsers/parse-shp-header.js +38 -27
  84. package/dist/lib/parsers/parse-shp.d.ts +3 -2
  85. package/dist/lib/parsers/parse-shp.d.ts.map +1 -1
  86. package/dist/lib/parsers/parse-shp.js +160 -136
  87. package/dist/lib/parsers/parse-shx.js +25 -19
  88. package/dist/lib/parsers/types.d.ts +68 -0
  89. package/dist/lib/parsers/types.d.ts.map +1 -0
  90. package/dist/lib/parsers/types.js +2 -0
  91. package/dist/lib/streaming/binary-chunk-reader.d.ts +5 -3
  92. package/dist/lib/streaming/binary-chunk-reader.d.ts.map +1 -1
  93. package/dist/lib/streaming/binary-chunk-reader.js +152 -128
  94. package/dist/lib/streaming/binary-reader.js +50 -33
  95. package/dist/lib/streaming/zip-batch-iterators.js +57 -48
  96. package/dist/shapefile-loader.js +30 -22
  97. package/dist/shp-loader.js +32 -22
  98. package/dist/shp-worker.js +57 -19
  99. package/dist/workers/dbf-worker.js +5 -4
  100. package/dist/workers/shp-worker.js +5 -4
  101. package/package.json +7 -7
  102. package/src/lib/parsers/parse-dbf.ts +41 -67
  103. package/src/lib/parsers/parse-shapefile.ts +3 -6
  104. package/src/lib/parsers/parse-shp-geometry.ts +3 -2
  105. package/src/lib/parsers/parse-shp.ts +26 -12
  106. package/src/lib/parsers/types.ts +79 -0
  107. package/src/lib/streaming/binary-chunk-reader.ts +5 -1
  108. package/src/lib/streaming/zip-batch-iterators.ts +2 -2
  109. package/dist/bundle.js.map +0 -1
  110. package/dist/dbf-loader.js.map +0 -1
  111. package/dist/index.js.map +0 -1
  112. package/dist/lib/parsers/parse-dbf.js.map +0 -1
  113. package/dist/lib/parsers/parse-shapefile.js.map +0 -1
  114. package/dist/lib/parsers/parse-shp-geometry.js.map +0 -1
  115. package/dist/lib/parsers/parse-shp-header.js.map +0 -1
  116. package/dist/lib/parsers/parse-shp.js.map +0 -1
  117. package/dist/lib/parsers/parse-shx.js.map +0 -1
  118. package/dist/lib/streaming/binary-chunk-reader.js.map +0 -1
  119. package/dist/lib/streaming/binary-reader.js.map +0 -1
  120. package/dist/lib/streaming/zip-batch-iterators.js.map +0 -1
  121. package/dist/shapefile-loader.js.map +0 -1
  122. package/dist/shp-loader.js.map +0 -1
  123. package/dist/workers/dbf-worker.js.map +0 -1
  124. package/dist/workers/shp-worker.js.map +0 -1
package/dist/bundle.js CHANGED
@@ -1,5 +1,5 @@
1
+ "use strict";
2
+ // @ts-nocheck
1
3
  const moduleExports = require('./index');
2
-
3
4
  globalThis.loaders = globalThis.loaders || {};
4
5
  module.exports = Object.assign(globalThis.loaders, moduleExports);
5
- //# sourceMappingURL=bundle.js.map
@@ -1,23 +1,32 @@
1
- import { parseDBF, parseDBFInBatches } from './lib/parsers/parse-dbf';
2
- const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
3
- export const DBFWorkerLoader = {
4
- name: 'DBF',
5
- id: 'dbf',
6
- module: 'shapefile',
7
- version: VERSION,
8
- worker: true,
9
- category: 'table',
10
- extensions: ['dbf'],
11
- mimeTypes: ['application/x-dbf'],
12
- options: {
13
- dbf: {
14
- encoding: 'latin1'
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DBFLoader = exports.DBFWorkerLoader = void 0;
4
+ const parse_dbf_1 = require("./lib/parsers/parse-dbf");
5
+ // __VERSION__ is injected by babel-plugin-version-inline
6
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
8
+ /**
9
+ * DBFLoader - DBF files are used to contain non-geometry columns in Shapefiles
10
+ */
11
+ exports.DBFWorkerLoader = {
12
+ name: 'DBF',
13
+ id: 'dbf',
14
+ module: 'shapefile',
15
+ version: VERSION,
16
+ worker: true,
17
+ category: 'table',
18
+ extensions: ['dbf'],
19
+ mimeTypes: ['application/x-dbf'],
20
+ options: {
21
+ dbf: {
22
+ encoding: 'latin1'
23
+ }
15
24
  }
16
- }
17
25
  };
18
- export const DBFLoader = { ...DBFWorkerLoader,
19
- parse: async (arrayBuffer, options) => parseDBF(arrayBuffer, options),
20
- parseSync: parseDBF,
21
- parseInBatches: parseDBFInBatches
26
+ /** DBF file loader */
27
+ exports.DBFLoader = {
28
+ ...exports.DBFWorkerLoader,
29
+ parse: async (arrayBuffer, options) => (0, parse_dbf_1.parseDBF)(arrayBuffer, options),
30
+ parseSync: parse_dbf_1.parseDBF,
31
+ parseInBatches: parse_dbf_1.parseDBFInBatches
22
32
  };
23
- //# sourceMappingURL=dbf-loader.js.map
@@ -1,420 +1,4 @@
1
1
  (() => {
2
- // ../schema/src/lib/utils/assert.ts
3
- function assert(condition, message) {
4
- if (!condition) {
5
- throw new Error(message || "loader assertion failed.");
6
- }
7
- }
8
-
9
- // ../schema/src/lib/schema/impl/schema.ts
10
- var Schema = class {
11
- constructor(fields, metadata) {
12
- assert(Array.isArray(fields));
13
- checkNames(fields);
14
- this.fields = fields;
15
- this.metadata = metadata || new Map();
16
- }
17
- compareTo(other) {
18
- if (this.metadata !== other.metadata) {
19
- return false;
20
- }
21
- if (this.fields.length !== other.fields.length) {
22
- return false;
23
- }
24
- for (let i = 0; i < this.fields.length; ++i) {
25
- if (!this.fields[i].compareTo(other.fields[i])) {
26
- return false;
27
- }
28
- }
29
- return true;
30
- }
31
- select(...columnNames) {
32
- const nameMap = Object.create(null);
33
- for (const name of columnNames) {
34
- nameMap[name] = true;
35
- }
36
- const selectedFields = this.fields.filter((field) => nameMap[field.name]);
37
- return new Schema(selectedFields, this.metadata);
38
- }
39
- selectAt(...columnIndices) {
40
- const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
41
- return new Schema(selectedFields, this.metadata);
42
- }
43
- assign(schemaOrFields) {
44
- let fields;
45
- let metadata = this.metadata;
46
- if (schemaOrFields instanceof Schema) {
47
- const otherSchema = schemaOrFields;
48
- fields = otherSchema.fields;
49
- metadata = mergeMaps(mergeMaps(new Map(), this.metadata), otherSchema.metadata);
50
- } else {
51
- fields = schemaOrFields;
52
- }
53
- const fieldMap = Object.create(null);
54
- for (const field of this.fields) {
55
- fieldMap[field.name] = field;
56
- }
57
- for (const field of fields) {
58
- fieldMap[field.name] = field;
59
- }
60
- const mergedFields = Object.values(fieldMap);
61
- return new Schema(mergedFields, metadata);
62
- }
63
- };
64
- function checkNames(fields) {
65
- const usedNames = {};
66
- for (const field of fields) {
67
- if (usedNames[field.name]) {
68
- console.warn("Schema: duplicated field name", field.name, field);
69
- }
70
- usedNames[field.name] = true;
71
- }
72
- }
73
- function mergeMaps(m1, m2) {
74
- return new Map([...m1 || new Map(), ...m2 || new Map()]);
75
- }
76
-
77
- // ../schema/src/lib/schema/impl/field.ts
78
- var Field = class {
79
- constructor(name, type, nullable = false, metadata = new Map()) {
80
- this.name = name;
81
- this.type = type;
82
- this.nullable = nullable;
83
- this.metadata = metadata;
84
- }
85
- get typeId() {
86
- return this.type && this.type.typeId;
87
- }
88
- clone() {
89
- return new Field(this.name, this.type, this.nullable, this.metadata);
90
- }
91
- compareTo(other) {
92
- return this.name === other.name && this.type === other.type && this.nullable === other.nullable && this.metadata === other.metadata;
93
- }
94
- toString() {
95
- return `${this.type}${this.nullable ? ", nullable" : ""}${this.metadata ? `, metadata: ${this.metadata}` : ""}`;
96
- }
97
- };
98
-
99
- // ../schema/src/lib/schema/impl/enum.ts
100
- var Type;
101
- (function(Type2) {
102
- Type2[Type2["NONE"] = 0] = "NONE";
103
- Type2[Type2["Null"] = 1] = "Null";
104
- Type2[Type2["Int"] = 2] = "Int";
105
- Type2[Type2["Float"] = 3] = "Float";
106
- Type2[Type2["Binary"] = 4] = "Binary";
107
- Type2[Type2["Utf8"] = 5] = "Utf8";
108
- Type2[Type2["Bool"] = 6] = "Bool";
109
- Type2[Type2["Decimal"] = 7] = "Decimal";
110
- Type2[Type2["Date"] = 8] = "Date";
111
- Type2[Type2["Time"] = 9] = "Time";
112
- Type2[Type2["Timestamp"] = 10] = "Timestamp";
113
- Type2[Type2["Interval"] = 11] = "Interval";
114
- Type2[Type2["List"] = 12] = "List";
115
- Type2[Type2["Struct"] = 13] = "Struct";
116
- Type2[Type2["Union"] = 14] = "Union";
117
- Type2[Type2["FixedSizeBinary"] = 15] = "FixedSizeBinary";
118
- Type2[Type2["FixedSizeList"] = 16] = "FixedSizeList";
119
- Type2[Type2["Map"] = 17] = "Map";
120
- Type2[Type2["Dictionary"] = -1] = "Dictionary";
121
- Type2[Type2["Int8"] = -2] = "Int8";
122
- Type2[Type2["Int16"] = -3] = "Int16";
123
- Type2[Type2["Int32"] = -4] = "Int32";
124
- Type2[Type2["Int64"] = -5] = "Int64";
125
- Type2[Type2["Uint8"] = -6] = "Uint8";
126
- Type2[Type2["Uint16"] = -7] = "Uint16";
127
- Type2[Type2["Uint32"] = -8] = "Uint32";
128
- Type2[Type2["Uint64"] = -9] = "Uint64";
129
- Type2[Type2["Float16"] = -10] = "Float16";
130
- Type2[Type2["Float32"] = -11] = "Float32";
131
- Type2[Type2["Float64"] = -12] = "Float64";
132
- Type2[Type2["DateDay"] = -13] = "DateDay";
133
- Type2[Type2["DateMillisecond"] = -14] = "DateMillisecond";
134
- Type2[Type2["TimestampSecond"] = -15] = "TimestampSecond";
135
- Type2[Type2["TimestampMillisecond"] = -16] = "TimestampMillisecond";
136
- Type2[Type2["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
137
- Type2[Type2["TimestampNanosecond"] = -18] = "TimestampNanosecond";
138
- Type2[Type2["TimeSecond"] = -19] = "TimeSecond";
139
- Type2[Type2["TimeMillisecond"] = -20] = "TimeMillisecond";
140
- Type2[Type2["TimeMicrosecond"] = -21] = "TimeMicrosecond";
141
- Type2[Type2["TimeNanosecond"] = -22] = "TimeNanosecond";
142
- Type2[Type2["DenseUnion"] = -23] = "DenseUnion";
143
- Type2[Type2["SparseUnion"] = -24] = "SparseUnion";
144
- Type2[Type2["IntervalDayTime"] = -25] = "IntervalDayTime";
145
- Type2[Type2["IntervalYearMonth"] = -26] = "IntervalYearMonth";
146
- })(Type || (Type = {}));
147
-
148
- // ../schema/src/lib/schema/impl/type.ts
149
- var DataType = class {
150
- static isNull(x) {
151
- return x && x.typeId === Type.Null;
152
- }
153
- static isInt(x) {
154
- return x && x.typeId === Type.Int;
155
- }
156
- static isFloat(x) {
157
- return x && x.typeId === Type.Float;
158
- }
159
- static isBinary(x) {
160
- return x && x.typeId === Type.Binary;
161
- }
162
- static isUtf8(x) {
163
- return x && x.typeId === Type.Utf8;
164
- }
165
- static isBool(x) {
166
- return x && x.typeId === Type.Bool;
167
- }
168
- static isDecimal(x) {
169
- return x && x.typeId === Type.Decimal;
170
- }
171
- static isDate(x) {
172
- return x && x.typeId === Type.Date;
173
- }
174
- static isTime(x) {
175
- return x && x.typeId === Type.Time;
176
- }
177
- static isTimestamp(x) {
178
- return x && x.typeId === Type.Timestamp;
179
- }
180
- static isInterval(x) {
181
- return x && x.typeId === Type.Interval;
182
- }
183
- static isList(x) {
184
- return x && x.typeId === Type.List;
185
- }
186
- static isStruct(x) {
187
- return x && x.typeId === Type.Struct;
188
- }
189
- static isUnion(x) {
190
- return x && x.typeId === Type.Union;
191
- }
192
- static isFixedSizeBinary(x) {
193
- return x && x.typeId === Type.FixedSizeBinary;
194
- }
195
- static isFixedSizeList(x) {
196
- return x && x.typeId === Type.FixedSizeList;
197
- }
198
- static isMap(x) {
199
- return x && x.typeId === Type.Map;
200
- }
201
- static isDictionary(x) {
202
- return x && x.typeId === Type.Dictionary;
203
- }
204
- get typeId() {
205
- return Type.NONE;
206
- }
207
- compareTo(other) {
208
- return this === other;
209
- }
210
- };
211
- var Null = class extends DataType {
212
- get typeId() {
213
- return Type.Null;
214
- }
215
- get [Symbol.toStringTag]() {
216
- return "Null";
217
- }
218
- toString() {
219
- return "Null";
220
- }
221
- };
222
- var Bool = class extends DataType {
223
- get typeId() {
224
- return Type.Bool;
225
- }
226
- get [Symbol.toStringTag]() {
227
- return "Bool";
228
- }
229
- toString() {
230
- return "Bool";
231
- }
232
- };
233
- var Int = class extends DataType {
234
- constructor(isSigned, bitWidth) {
235
- super();
236
- this.isSigned = isSigned;
237
- this.bitWidth = bitWidth;
238
- }
239
- get typeId() {
240
- return Type.Int;
241
- }
242
- get [Symbol.toStringTag]() {
243
- return "Int";
244
- }
245
- toString() {
246
- return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
247
- }
248
- };
249
- var Precision = {
250
- HALF: 16,
251
- SINGLE: 32,
252
- DOUBLE: 64
253
- };
254
- var Float = class extends DataType {
255
- constructor(precision) {
256
- super();
257
- this.precision = precision;
258
- }
259
- get typeId() {
260
- return Type.Float;
261
- }
262
- get [Symbol.toStringTag]() {
263
- return "Float";
264
- }
265
- toString() {
266
- return `Float${this.precision}`;
267
- }
268
- };
269
- var Float64 = class extends Float {
270
- constructor() {
271
- super(Precision.DOUBLE);
272
- }
273
- };
274
- var Binary = class extends DataType {
275
- constructor() {
276
- super();
277
- }
278
- get typeId() {
279
- return Type.Binary;
280
- }
281
- toString() {
282
- return "Binary";
283
- }
284
- get [Symbol.toStringTag]() {
285
- return "Binary";
286
- }
287
- };
288
- var Utf8 = class extends DataType {
289
- get typeId() {
290
- return Type.Utf8;
291
- }
292
- get [Symbol.toStringTag]() {
293
- return "Utf8";
294
- }
295
- toString() {
296
- return "Utf8";
297
- }
298
- };
299
- var DateUnit = {
300
- DAY: 0,
301
- MILLISECOND: 1
302
- };
303
- var Date2 = class extends DataType {
304
- constructor(unit) {
305
- super();
306
- this.unit = unit;
307
- }
308
- get typeId() {
309
- return Type.Date;
310
- }
311
- get [Symbol.toStringTag]() {
312
- return "Date";
313
- }
314
- toString() {
315
- return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`;
316
- }
317
- };
318
- var TimeUnit = {
319
- SECOND: 1,
320
- MILLISECOND: 1e3,
321
- MICROSECOND: 1e6,
322
- NANOSECOND: 1e9
323
- };
324
- var Time = class extends DataType {
325
- constructor(unit, bitWidth) {
326
- super();
327
- this.unit = unit;
328
- this.bitWidth = bitWidth;
329
- }
330
- get typeId() {
331
- return Type.Time;
332
- }
333
- toString() {
334
- return `Time${this.bitWidth}<${TimeUnit[this.unit]}>`;
335
- }
336
- get [Symbol.toStringTag]() {
337
- return "Time";
338
- }
339
- };
340
- var Timestamp = class extends DataType {
341
- constructor(unit, timezone = null) {
342
- super();
343
- this.unit = unit;
344
- this.timezone = timezone;
345
- }
346
- get typeId() {
347
- return Type.Timestamp;
348
- }
349
- get [Symbol.toStringTag]() {
350
- return "Timestamp";
351
- }
352
- toString() {
353
- return `Timestamp<${TimeUnit[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
354
- }
355
- };
356
- var TimestampMillisecond = class extends Timestamp {
357
- constructor(timezone = null) {
358
- super(TimeUnit.MILLISECOND, timezone);
359
- }
360
- };
361
- var IntervalUnit = {
362
- DAY_TIME: 0,
363
- YEAR_MONTH: 1
364
- };
365
- var Interval = class extends DataType {
366
- constructor(unit) {
367
- super();
368
- this.unit = unit;
369
- }
370
- get typeId() {
371
- return Type.Interval;
372
- }
373
- get [Symbol.toStringTag]() {
374
- return "Interval";
375
- }
376
- toString() {
377
- return `Interval<${IntervalUnit[this.unit]}>`;
378
- }
379
- };
380
- var FixedSizeList = class extends DataType {
381
- constructor(listSize, child) {
382
- super();
383
- this.listSize = listSize;
384
- this.children = [child];
385
- }
386
- get typeId() {
387
- return Type.FixedSizeList;
388
- }
389
- get valueType() {
390
- return this.children[0].type;
391
- }
392
- get valueField() {
393
- return this.children[0];
394
- }
395
- get [Symbol.toStringTag]() {
396
- return "FixedSizeList";
397
- }
398
- toString() {
399
- return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
400
- }
401
- };
402
- var Struct = class extends DataType {
403
- constructor(children) {
404
- super();
405
- this.children = children;
406
- }
407
- get typeId() {
408
- return Type.Struct;
409
- }
410
- toString() {
411
- return `Struct<{${this.children.map((f) => `${f.name}:${f.type}`).join(", ")}}>`;
412
- }
413
- get [Symbol.toStringTag]() {
414
- return "Struct";
415
- }
416
- };
417
-
418
2
  // src/lib/streaming/binary-chunk-reader.ts
419
3
  var BinaryChunkReader = class {
420
4
  constructor(options) {
@@ -549,13 +133,21 @@
549
133
  }
550
134
  };
551
135
  function parseDBF(arrayBuffer, options = {}) {
552
- const loaderOptions = options.dbf || {};
553
- const { encoding } = loaderOptions;
136
+ const { encoding = "latin1" } = options.dbf || {};
554
137
  const dbfParser = new DBFParser({ encoding });
555
138
  dbfParser.write(arrayBuffer);
556
139
  dbfParser.end();
557
140
  const { data, schema } = dbfParser.result;
558
- switch (options.tables && options.tables.format) {
141
+ const shape = options?.tables?.format || options?.dbf?.shape;
142
+ switch (shape) {
143
+ case "object-row-table": {
144
+ const table = {
145
+ shape: "object-row-table",
146
+ schema,
147
+ data
148
+ };
149
+ return table;
150
+ }
559
151
  case "table":
560
152
  return { schema, rows: data };
561
153
  case "rows":
@@ -564,8 +156,7 @@
564
156
  }
565
157
  }
566
158
  async function* parseDBFInBatches(asyncIterator, options = {}) {
567
- const loaderOptions = options.dbf || {};
568
- const { encoding } = loaderOptions;
159
+ const { encoding = "latin1" } = options.dbf || {};
569
160
  const parser = new DBFParser({ encoding });
570
161
  let headerReturned = false;
571
162
  for await (const arrayBuffer of asyncIterator) {
@@ -592,7 +183,7 @@
592
183
  case 3:
593
184
  return state;
594
185
  case 0:
595
- const dataView = binaryReader.getDataView(DBF_HEADER_SIZE, "DBF header");
186
+ const dataView = binaryReader.getDataView(DBF_HEADER_SIZE);
596
187
  if (!dataView) {
597
188
  return state;
598
189
  }
@@ -605,12 +196,15 @@
605
196
  state = 1;
606
197
  break;
607
198
  case 1:
608
- const fieldDescriptorView = binaryReader.getDataView(result.dbfHeader.headerLength - DBF_HEADER_SIZE, "DBF field descriptors");
199
+ const fieldDescriptorView = binaryReader.getDataView(result.dbfHeader.headerLength - DBF_HEADER_SIZE);
609
200
  if (!fieldDescriptorView) {
610
201
  return state;
611
202
  }
612
203
  result.dbfFields = parseFieldDescriptors(fieldDescriptorView, textDecoder);
613
- result.schema = new Schema(result.dbfFields.map((dbfField) => makeField(dbfField)));
204
+ result.schema = {
205
+ fields: result.dbfFields.map((dbfField) => makeField(dbfField)),
206
+ metadata: {}
207
+ };
614
208
  state = 2;
615
209
  binaryReader.skip(1);
616
210
  break;
@@ -713,26 +307,26 @@
713
307
  function makeField({ name, dataType, fieldLength, decimal }) {
714
308
  switch (dataType) {
715
309
  case "B":
716
- return new Field(name, new Float64(), true);
310
+ return { name, type: "float64", nullable: true, metadata: {} };
717
311
  case "C":
718
- return new Field(name, new Utf8(), true);
312
+ return { name, type: "utf8", nullable: true, metadata: {} };
719
313
  case "F":
720
- return new Field(name, new Float64(), true);
314
+ return { name, type: "float64", nullable: true, metadata: {} };
721
315
  case "N":
722
- return new Field(name, new Float64(), true);
316
+ return { name, type: "float64", nullable: true, metadata: {} };
723
317
  case "O":
724
- return new Field(name, new Float64(), true);
318
+ return { name, type: "float64", nullable: true, metadata: {} };
725
319
  case "D":
726
- return new Field(name, new TimestampMillisecond(), true);
320
+ return { name, type: "timestamp-millisecond", nullable: true, metadata: {} };
727
321
  case "L":
728
- return new Field(name, new Bool(), true);
322
+ return { name, type: "bool", nullable: true, metadata: {} };
729
323
  default:
730
324
  throw new Error("Unsupported data type");
731
325
  }
732
326
  }
733
327
 
734
328
  // src/dbf-loader.ts
735
- var VERSION = true ? "4.0.0-alpha.5" : "latest";
329
+ var VERSION = true ? "4.0.0-alpha.6" : "latest";
736
330
  var DBFWorkerLoader = {
737
331
  name: "DBF",
738
332
  id: "dbf",
@@ -791,16 +385,33 @@
791
385
  }
792
386
 
793
387
  // ../worker-utils/src/lib/worker-farm/worker-body.ts
388
+ function getParentPort() {
389
+ let parentPort;
390
+ try {
391
+ eval("globalThis.parentPort = require('worker_threads').parentPort");
392
+ parentPort = globalThis.parentPort;
393
+ } catch {
394
+ }
395
+ return parentPort;
396
+ }
794
397
  var onMessageWrapperMap = new Map();
795
398
  var WorkerBody = class {
399
+ static inWorkerThread() {
400
+ return typeof self !== "undefined" || Boolean(getParentPort());
401
+ }
796
402
  static set onmessage(onMessage) {
797
- self.onmessage = (message) => {
798
- if (!isKnownMessage(message)) {
799
- return;
800
- }
801
- const { type, payload } = message.data;
403
+ function handleMessage(message) {
404
+ const parentPort3 = getParentPort();
405
+ const { type, payload } = parentPort3 ? message : message.data;
802
406
  onMessage(type, payload);
803
- };
407
+ }
408
+ const parentPort2 = getParentPort();
409
+ if (parentPort2) {
410
+ parentPort2.on("message", handleMessage);
411
+ parentPort2.on("exit", () => console.debug("Node worker closing"));
412
+ } else {
413
+ globalThis.onmessage = handleMessage;
414
+ }
804
415
  }
805
416
  static addEventListener(onMessage) {
806
417
  let onMessageWrapper = onMessageWrapperMap.get(onMessage);
@@ -809,22 +420,36 @@
809
420
  if (!isKnownMessage(message)) {
810
421
  return;
811
422
  }
812
- const { type, payload } = message.data;
423
+ const parentPort3 = getParentPort();
424
+ const { type, payload } = parentPort3 ? message : message.data;
813
425
  onMessage(type, payload);
814
426
  };
815
427
  }
816
- self.addEventListener("message", onMessageWrapper);
428
+ const parentPort2 = getParentPort();
429
+ if (parentPort2) {
430
+ console.error("not implemented");
431
+ } else {
432
+ globalThis.addEventListener("message", onMessageWrapper);
433
+ }
817
434
  }
818
435
  static removeEventListener(onMessage) {
819
436
  const onMessageWrapper = onMessageWrapperMap.get(onMessage);
820
437
  onMessageWrapperMap.delete(onMessage);
821
- self.removeEventListener("message", onMessageWrapper);
438
+ const parentPort2 = getParentPort();
439
+ if (parentPort2) {
440
+ console.error("not implemented");
441
+ } else {
442
+ globalThis.removeEventListener("message", onMessageWrapper);
443
+ }
822
444
  }
823
445
  static postMessage(type, payload) {
824
- if (self) {
825
- const data = { source: "loaders.gl", type, payload };
826
- const transferList = getTransferList(payload);
827
- self.postMessage(data, transferList);
446
+ const data = { source: "loaders.gl", type, payload };
447
+ const transferList = getTransferList(payload);
448
+ const parentPort2 = getParentPort();
449
+ if (parentPort2) {
450
+ parentPort2.postMessage(data, transferList);
451
+ } else {
452
+ globalThis.postMessage(data, transferList);
828
453
  }
829
454
  }
830
455
  };
@@ -836,19 +461,20 @@
836
461
  // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
837
462
  var requestId = 0;
838
463
  function createLoaderWorker(loader) {
839
- if (typeof self === "undefined") {
464
+ if (!WorkerBody.inWorkerThread()) {
840
465
  return;
841
466
  }
842
467
  WorkerBody.onmessage = async (type, payload) => {
843
468
  switch (type) {
844
469
  case "process":
845
470
  try {
846
- const { input, options = {} } = payload;
471
+ const { input, options = {}, context = {} } = payload;
847
472
  const result = await parseData({
848
473
  loader,
849
474
  arrayBuffer: input,
850
475
  options,
851
476
  context: {
477
+ ...context,
852
478
  parse: parseOnMainThread
853
479
  }
854
480
  });