@loaders.gl/json 4.0.0-beta.2 → 4.0.0-beta.4

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 (119) hide show
  1. package/dist/{dist.min.js → dist.dev.js} +1510 -1559
  2. package/dist/{esm/geojson-loader.js → geojson-loader.js} +2 -2
  3. package/dist/geojson-loader.js.map +1 -0
  4. package/dist/geojson-worker.js +345 -179
  5. package/dist/{esm/geojson-writer.js → geojson-writer.js} +1 -1
  6. package/dist/geojson-writer.js.map +1 -0
  7. package/dist/index.cjs +1259 -0
  8. package/dist/index.js +9 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/{esm/json-loader.js → json-loader.js} +3 -3
  11. package/dist/json-loader.js.map +1 -0
  12. package/dist/{esm/json-writer.js → json-writer.js} +1 -1
  13. package/dist/json-writer.js.map +1 -0
  14. package/dist/{esm/lib → lib}/clarinet/clarinet.js +33 -34
  15. package/dist/lib/clarinet/clarinet.js.map +1 -0
  16. package/dist/{esm/lib → lib}/encoder-utils/encode-table-row.js +1 -1
  17. package/dist/lib/encoder-utils/encode-table-row.js.map +1 -0
  18. package/dist/lib/encoder-utils/encode-utils.js.map +1 -0
  19. package/dist/{esm/lib → lib}/encoder-utils/utf8-encoder.js +4 -5
  20. package/dist/lib/encoder-utils/utf8-encoder.js.map +1 -0
  21. package/dist/{esm/lib → lib}/encoders/geojson-encoder.js +3 -3
  22. package/dist/lib/encoders/geojson-encoder.js.map +1 -0
  23. package/dist/{esm/lib → lib}/encoders/json-encoder.js +1 -1
  24. package/dist/lib/encoders/json-encoder.js.map +1 -0
  25. package/dist/{esm/lib → lib}/json-parser/json-parser.js +8 -9
  26. package/dist/lib/json-parser/json-parser.js.map +1 -0
  27. package/dist/{esm/lib → lib}/json-parser/streaming-json-parser.js +6 -7
  28. package/dist/lib/json-parser/streaming-json-parser.js.map +1 -0
  29. package/dist/{esm/lib → lib}/jsonpath/jsonpath.js +1 -2
  30. package/dist/lib/jsonpath/jsonpath.js.map +1 -0
  31. package/dist/{esm/lib → lib}/parsers/parse-json-in-batches.js +2 -2
  32. package/dist/lib/parsers/parse-json-in-batches.js.map +1 -0
  33. package/dist/lib/parsers/parse-json.js.map +1 -0
  34. package/dist/{esm/lib → lib}/parsers/parse-ndjson-in-batches.js +1 -1
  35. package/dist/lib/parsers/parse-ndjson-in-batches.js.map +1 -0
  36. package/dist/{esm/lib → lib}/parsers/parse-ndjson.js +1 -1
  37. package/dist/lib/parsers/parse-ndjson.js.map +1 -0
  38. package/dist/{esm/ndgeoson-loader.js → ndgeoson-loader.js} +3 -3
  39. package/dist/ndgeoson-loader.js.map +1 -0
  40. package/dist/{esm/ndjson-loader.js → ndjson-loader.js} +3 -3
  41. package/dist/ndjson-loader.js.map +1 -0
  42. package/dist/{esm/workers → workers}/geojson-worker.js +1 -1
  43. package/dist/workers/geojson-worker.js.map +1 -0
  44. package/package.json +17 -9
  45. package/dist/bundle.d.ts +0 -2
  46. package/dist/bundle.d.ts.map +0 -1
  47. package/dist/es5/bundle.js +0 -6
  48. package/dist/es5/bundle.js.map +0 -1
  49. package/dist/es5/geojson-loader.js +0 -166
  50. package/dist/es5/geojson-loader.js.map +0 -1
  51. package/dist/es5/geojson-writer.js +0 -27
  52. package/dist/es5/geojson-writer.js.map +0 -1
  53. package/dist/es5/index.js +0 -69
  54. package/dist/es5/index.js.map +0 -1
  55. package/dist/es5/json-loader.js +0 -67
  56. package/dist/es5/json-loader.js.map +0 -1
  57. package/dist/es5/json-writer.js +0 -42
  58. package/dist/es5/json-writer.js.map +0 -1
  59. package/dist/es5/lib/clarinet/clarinet.js +0 -446
  60. package/dist/es5/lib/clarinet/clarinet.js.map +0 -1
  61. package/dist/es5/lib/encoder-utils/encode-table-row.js +0 -54
  62. package/dist/es5/lib/encoder-utils/encode-table-row.js.map +0 -1
  63. package/dist/es5/lib/encoder-utils/encode-utils.js +0 -42
  64. package/dist/es5/lib/encoder-utils/encode-utils.js.map +0 -1
  65. package/dist/es5/lib/encoder-utils/utf8-encoder.js +0 -54
  66. package/dist/es5/lib/encoder-utils/utf8-encoder.js.map +0 -1
  67. package/dist/es5/lib/encoders/geojson-encoder.js +0 -141
  68. package/dist/es5/lib/encoders/geojson-encoder.js.map +0 -1
  69. package/dist/es5/lib/encoders/json-encoder.js +0 -30
  70. package/dist/es5/lib/encoders/json-encoder.js.map +0 -1
  71. package/dist/es5/lib/json-parser/json-parser.js +0 -140
  72. package/dist/es5/lib/json-parser/json-parser.js.map +0 -1
  73. package/dist/es5/lib/json-parser/streaming-json-parser.js +0 -123
  74. package/dist/es5/lib/json-parser/streaming-json-parser.js.map +0 -1
  75. package/dist/es5/lib/jsonpath/jsonpath.js +0 -119
  76. package/dist/es5/lib/jsonpath/jsonpath.js.map +0 -1
  77. package/dist/es5/lib/parsers/parse-json-in-batches.js +0 -206
  78. package/dist/es5/lib/parsers/parse-json-in-batches.js.map +0 -1
  79. package/dist/es5/lib/parsers/parse-json.js +0 -38
  80. package/dist/es5/lib/parsers/parse-json.js.map +0 -1
  81. package/dist/es5/lib/parsers/parse-ndjson-in-batches.js +0 -114
  82. package/dist/es5/lib/parsers/parse-ndjson-in-batches.js.map +0 -1
  83. package/dist/es5/lib/parsers/parse-ndjson.js +0 -19
  84. package/dist/es5/lib/parsers/parse-ndjson.js.map +0 -1
  85. package/dist/es5/ndgeoson-loader.js +0 -51
  86. package/dist/es5/ndgeoson-loader.js.map +0 -1
  87. package/dist/es5/ndjson-loader.js +0 -44
  88. package/dist/es5/ndjson-loader.js.map +0 -1
  89. package/dist/es5/workers/geojson-worker.js +0 -6
  90. package/dist/es5/workers/geojson-worker.js.map +0 -1
  91. package/dist/esm/bundle.js +0 -4
  92. package/dist/esm/bundle.js.map +0 -1
  93. package/dist/esm/geojson-loader.js.map +0 -1
  94. package/dist/esm/geojson-writer.js.map +0 -1
  95. package/dist/esm/index.js +0 -9
  96. package/dist/esm/index.js.map +0 -1
  97. package/dist/esm/json-loader.js.map +0 -1
  98. package/dist/esm/json-writer.js.map +0 -1
  99. package/dist/esm/lib/clarinet/LICENSE +0 -28
  100. package/dist/esm/lib/clarinet/clarinet.js.map +0 -1
  101. package/dist/esm/lib/encoder-utils/encode-table-row.js.map +0 -1
  102. package/dist/esm/lib/encoder-utils/encode-utils.js.map +0 -1
  103. package/dist/esm/lib/encoder-utils/utf8-encoder.js.map +0 -1
  104. package/dist/esm/lib/encoders/geojson-encoder.js.map +0 -1
  105. package/dist/esm/lib/encoders/json-encoder.js.map +0 -1
  106. package/dist/esm/lib/json-parser/json-parser.js.map +0 -1
  107. package/dist/esm/lib/json-parser/streaming-json-parser.js.map +0 -1
  108. package/dist/esm/lib/jsonpath/jsonpath.js.map +0 -1
  109. package/dist/esm/lib/parsers/parse-json-in-batches.js.map +0 -1
  110. package/dist/esm/lib/parsers/parse-json.js.map +0 -1
  111. package/dist/esm/lib/parsers/parse-ndjson-in-batches.js.map +0 -1
  112. package/dist/esm/lib/parsers/parse-ndjson.js.map +0 -1
  113. package/dist/esm/ndgeoson-loader.js.map +0 -1
  114. package/dist/esm/ndjson-loader.js.map +0 -1
  115. package/dist/esm/workers/geojson-worker.js.map +0 -1
  116. package/src/bundle.ts +0 -4
  117. /package/dist/{es5/lib → lib}/clarinet/LICENSE +0 -0
  118. /package/dist/{esm/lib → lib}/encoder-utils/encode-utils.js +0 -0
  119. /package/dist/{esm/lib → lib}/parsers/parse-json.js +0 -0
@@ -1,77 +1,97 @@
1
- (() => {
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if (typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if (typeof define === 'function' && define.amd) define([], factory);
5
+ else if (typeof exports === 'object') exports['loader'] = factory();
6
+ else root['loader'] = factory();})(globalThis, function () {
7
+ "use strict";
8
+ var __exports__ = (() => {
2
9
  var __defProp = Object.defineProperty;
3
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
4
- var __esm = (fn, res) => function __init() {
5
- return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
6
- };
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __getOwnPropNames = Object.getOwnPropertyNames;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
13
  var __export = (target, all) => {
11
- __markAsModule(target);
12
14
  for (var name in all)
13
15
  __defProp(target, name, { get: all[name], enumerable: true });
14
16
  };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+
27
+ // src/index.ts
28
+ var src_exports = {};
29
+ __export(src_exports, {
30
+ JSONLoader: () => JSONLoader,
31
+ JSONWriter: () => JSONWriter,
32
+ NDJSONLoader: () => NDJSONLoader,
33
+ _ClarinetParser: () => ClarinetParser,
34
+ _GeoJSONLoader: () => GeoJSONLoader,
35
+ _GeoJSONWorkerLoader: () => GeoJSONWorkerLoader,
36
+ _GeoJSONWriter: () => GeoJSONWriter,
37
+ _JSONPath: () => JSONPath,
38
+ _rebuildJsonObject: () => rebuildJsonObject
39
+ });
15
40
 
16
41
  // ../schema/src/lib/table/batches/base-table-batch-aggregator.ts
17
- var DEFAULT_ROW_COUNT, BaseTableBatchAggregator;
18
- var init_base_table_batch_aggregator = __esm({
19
- "../schema/src/lib/table/batches/base-table-batch-aggregator.ts"() {
20
- DEFAULT_ROW_COUNT = 100;
21
- BaseTableBatchAggregator = class {
22
- constructor(schema, options) {
23
- this.length = 0;
24
- this.rows = null;
25
- this.cursor = 0;
26
- this._headers = [];
27
- this.options = options;
28
- this.schema = schema;
29
- if (!Array.isArray(schema)) {
30
- this._headers = [];
31
- for (const key in schema) {
32
- this._headers[schema[key].index] = schema[key].name;
33
- }
34
- }
35
- }
36
- rowCount() {
37
- return this.length;
38
- }
39
- addArrayRow(row, cursor) {
40
- if (Number.isFinite(cursor)) {
41
- this.cursor = cursor;
42
- }
43
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
44
- this.rows[this.length] = row;
45
- this.length++;
46
- }
47
- addObjectRow(row, cursor) {
48
- if (Number.isFinite(cursor)) {
49
- this.cursor = cursor;
50
- }
51
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
52
- this.rows[this.length] = row;
53
- this.length++;
54
- }
55
- getBatch() {
56
- let rows = this.rows;
57
- if (!rows) {
58
- return null;
59
- }
60
- rows = rows.slice(0, this.length);
61
- this.rows = null;
62
- const batch = {
63
- shape: this.options.shape,
64
- batchType: "data",
65
- data: rows,
66
- length: this.length,
67
- schema: this.schema,
68
- cursor: this.cursor
69
- };
70
- return batch;
42
+ var DEFAULT_ROW_COUNT = 100;
43
+ var BaseTableBatchAggregator = class {
44
+ length = 0;
45
+ rows = null;
46
+ cursor = 0;
47
+ _headers = [];
48
+ constructor(schema, options) {
49
+ this.options = options;
50
+ this.schema = schema;
51
+ if (!Array.isArray(schema)) {
52
+ this._headers = [];
53
+ for (const key in schema) {
54
+ this._headers[schema[key].index] = schema[key].name;
71
55
  }
56
+ }
57
+ }
58
+ rowCount() {
59
+ return this.length;
60
+ }
61
+ addArrayRow(row, cursor) {
62
+ if (Number.isFinite(cursor)) {
63
+ this.cursor = cursor;
64
+ }
65
+ this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
66
+ this.rows[this.length] = row;
67
+ this.length++;
68
+ }
69
+ addObjectRow(row, cursor) {
70
+ if (Number.isFinite(cursor)) {
71
+ this.cursor = cursor;
72
+ }
73
+ this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
74
+ this.rows[this.length] = row;
75
+ this.length++;
76
+ }
77
+ getBatch() {
78
+ let rows = this.rows;
79
+ if (!rows) {
80
+ return null;
81
+ }
82
+ rows = rows.slice(0, this.length);
83
+ this.rows = null;
84
+ const batch = {
85
+ shape: this.options.shape,
86
+ batchType: "data",
87
+ data: rows,
88
+ length: this.length,
89
+ schema: this.schema,
90
+ cursor: this.cursor
72
91
  };
92
+ return batch;
73
93
  }
74
- });
94
+ };
75
95
 
76
96
  // ../schema/src/lib/table/simple-table/row-utils.ts
77
97
  function convertToObjectRow(arrayRow, headers) {
@@ -100,306 +120,286 @@
100
120
  }
101
121
  return arrayRow;
102
122
  }
103
- var init_row_utils = __esm({
104
- "../schema/src/lib/table/simple-table/row-utils.ts"() {
105
- }
106
- });
107
123
 
108
124
  // ../schema/src/lib/table/batches/row-table-batch-aggregator.ts
109
- var DEFAULT_ROW_COUNT2, RowTableBatchAggregator;
110
- var init_row_table_batch_aggregator = __esm({
111
- "../schema/src/lib/table/batches/row-table-batch-aggregator.ts"() {
112
- init_row_utils();
113
- DEFAULT_ROW_COUNT2 = 100;
114
- RowTableBatchAggregator = class {
115
- constructor(schema, options) {
116
- this.length = 0;
117
- this.objectRows = null;
118
- this.arrayRows = null;
119
- this.cursor = 0;
120
- this._headers = [];
121
- this.options = options;
122
- this.schema = schema;
123
- if (!Array.isArray(schema)) {
124
- this._headers = [];
125
- for (const key in schema) {
126
- this._headers[schema[key].index] = schema[key].name;
127
- }
128
- }
129
- }
130
- rowCount() {
131
- return this.length;
132
- }
133
- addArrayRow(row, cursor) {
134
- if (Number.isFinite(cursor)) {
135
- this.cursor = cursor;
136
- }
137
- switch (this.options.shape) {
138
- case "object-row-table":
139
- const rowObject = convertToObjectRow(row, this._headers);
140
- this.addObjectRow(rowObject, cursor);
141
- break;
142
- case "array-row-table":
143
- this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT2);
144
- this.arrayRows[this.length] = row;
145
- this.length++;
146
- break;
147
- }
148
- }
149
- addObjectRow(row, cursor) {
150
- if (Number.isFinite(cursor)) {
151
- this.cursor = cursor;
152
- }
153
- switch (this.options.shape) {
154
- case "array-row-table":
155
- const rowArray = convertToArrayRow(row, this._headers);
156
- this.addArrayRow(rowArray, cursor);
157
- break;
158
- case "object-row-table":
159
- this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT2);
160
- this.objectRows[this.length] = row;
161
- this.length++;
162
- break;
163
- }
164
- }
165
- getBatch() {
166
- let rows = this.arrayRows || this.objectRows;
167
- if (!rows) {
168
- return null;
169
- }
170
- rows = rows.slice(0, this.length);
171
- this.arrayRows = null;
172
- this.objectRows = null;
173
- return {
174
- shape: this.options.shape,
175
- batchType: "data",
176
- data: rows,
177
- length: this.length,
178
- schema: this.schema,
179
- cursor: this.cursor
180
- };
125
+ var DEFAULT_ROW_COUNT2 = 100;
126
+ var RowTableBatchAggregator = class {
127
+ length = 0;
128
+ objectRows = null;
129
+ arrayRows = null;
130
+ cursor = 0;
131
+ _headers = [];
132
+ constructor(schema, options) {
133
+ this.options = options;
134
+ this.schema = schema;
135
+ if (!Array.isArray(schema)) {
136
+ this._headers = [];
137
+ for (const key in schema) {
138
+ this._headers[schema[key].index] = schema[key].name;
181
139
  }
140
+ }
141
+ }
142
+ rowCount() {
143
+ return this.length;
144
+ }
145
+ addArrayRow(row, cursor) {
146
+ if (Number.isFinite(cursor)) {
147
+ this.cursor = cursor;
148
+ }
149
+ switch (this.options.shape) {
150
+ case "object-row-table":
151
+ const rowObject = convertToObjectRow(row, this._headers);
152
+ this.addObjectRow(rowObject, cursor);
153
+ break;
154
+ case "array-row-table":
155
+ this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT2);
156
+ this.arrayRows[this.length] = row;
157
+ this.length++;
158
+ break;
159
+ }
160
+ }
161
+ addObjectRow(row, cursor) {
162
+ if (Number.isFinite(cursor)) {
163
+ this.cursor = cursor;
164
+ }
165
+ switch (this.options.shape) {
166
+ case "array-row-table":
167
+ const rowArray = convertToArrayRow(row, this._headers);
168
+ this.addArrayRow(rowArray, cursor);
169
+ break;
170
+ case "object-row-table":
171
+ this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT2);
172
+ this.objectRows[this.length] = row;
173
+ this.length++;
174
+ break;
175
+ }
176
+ }
177
+ getBatch() {
178
+ let rows = this.arrayRows || this.objectRows;
179
+ if (!rows) {
180
+ return null;
181
+ }
182
+ rows = rows.slice(0, this.length);
183
+ this.arrayRows = null;
184
+ this.objectRows = null;
185
+ return {
186
+ shape: this.options.shape,
187
+ batchType: "data",
188
+ data: rows,
189
+ length: this.length,
190
+ schema: this.schema,
191
+ cursor: this.cursor
182
192
  };
183
193
  }
184
- });
194
+ };
185
195
 
186
196
  // ../schema/src/lib/table/batches/columnar-table-batch-aggregator.ts
187
- var DEFAULT_ROW_COUNT3, ColumnarTableBatchAggregator;
188
- var init_columnar_table_batch_aggregator = __esm({
189
- "../schema/src/lib/table/batches/columnar-table-batch-aggregator.ts"() {
190
- DEFAULT_ROW_COUNT3 = 100;
191
- ColumnarTableBatchAggregator = class {
192
- constructor(schema, options) {
193
- this.length = 0;
194
- this.allocated = 0;
195
- this.columns = {};
196
- this.schema = schema;
197
- this._reallocateColumns();
198
- }
199
- rowCount() {
200
- return this.length;
201
- }
202
- addArrayRow(row) {
203
- this._reallocateColumns();
204
- let i = 0;
205
- for (const fieldName in this.columns) {
206
- this.columns[fieldName][this.length] = row[i++];
207
- }
208
- this.length++;
209
- }
210
- addObjectRow(row) {
211
- this._reallocateColumns();
212
- for (const fieldName in row) {
213
- this.columns[fieldName][this.length] = row[fieldName];
214
- }
215
- this.length++;
216
- }
217
- getBatch() {
218
- this._pruneColumns();
219
- const columns = Array.isArray(this.schema) ? this.columns : {};
220
- if (!Array.isArray(this.schema)) {
221
- for (const fieldName in this.schema) {
222
- const field = this.schema[fieldName];
223
- columns[field.name] = this.columns[field.index];
224
- }
225
- }
226
- this.columns = {};
227
- const batch = {
228
- shape: "columnar-table",
229
- batchType: "data",
230
- data: columns,
231
- schema: this.schema,
232
- length: this.length
233
- };
234
- return batch;
235
- }
236
- _reallocateColumns() {
237
- if (this.length < this.allocated) {
238
- return;
239
- }
240
- this.allocated = this.allocated > 0 ? this.allocated *= 2 : DEFAULT_ROW_COUNT3;
241
- this.columns = {};
242
- for (const fieldName in this.schema) {
243
- const field = this.schema[fieldName];
244
- const ArrayType = field.type || Float32Array;
245
- const oldColumn = this.columns[field.index];
246
- if (oldColumn && ArrayBuffer.isView(oldColumn)) {
247
- const typedArray = new ArrayType(this.allocated);
248
- typedArray.set(oldColumn);
249
- this.columns[field.index] = typedArray;
250
- } else if (oldColumn) {
251
- oldColumn.length = this.allocated;
252
- this.columns[field.index] = oldColumn;
253
- } else {
254
- this.columns[field.index] = new ArrayType(this.allocated);
255
- }
256
- }
257
- }
258
- _pruneColumns() {
259
- for (const [columnName, column] of Object.entries(this.columns)) {
260
- this.columns[columnName] = column.slice(0, this.length);
261
- }
197
+ var DEFAULT_ROW_COUNT3 = 100;
198
+ var ColumnarTableBatchAggregator = class {
199
+ length = 0;
200
+ allocated = 0;
201
+ columns = {};
202
+ constructor(schema, options) {
203
+ this.schema = schema;
204
+ this._reallocateColumns();
205
+ }
206
+ rowCount() {
207
+ return this.length;
208
+ }
209
+ addArrayRow(row) {
210
+ this._reallocateColumns();
211
+ let i = 0;
212
+ for (const fieldName in this.columns) {
213
+ this.columns[fieldName][this.length] = row[i++];
214
+ }
215
+ this.length++;
216
+ }
217
+ addObjectRow(row) {
218
+ this._reallocateColumns();
219
+ for (const fieldName in row) {
220
+ this.columns[fieldName][this.length] = row[fieldName];
221
+ }
222
+ this.length++;
223
+ }
224
+ getBatch() {
225
+ this._pruneColumns();
226
+ const columns = Array.isArray(this.schema) ? this.columns : {};
227
+ if (!Array.isArray(this.schema)) {
228
+ for (const fieldName in this.schema) {
229
+ const field = this.schema[fieldName];
230
+ columns[field.name] = this.columns[field.index];
262
231
  }
232
+ }
233
+ this.columns = {};
234
+ const batch = {
235
+ shape: "columnar-table",
236
+ batchType: "data",
237
+ data: columns,
238
+ schema: this.schema,
239
+ length: this.length
263
240
  };
241
+ return batch;
264
242
  }
265
- });
243
+ _reallocateColumns() {
244
+ if (this.length < this.allocated) {
245
+ return;
246
+ }
247
+ this.allocated = this.allocated > 0 ? this.allocated *= 2 : DEFAULT_ROW_COUNT3;
248
+ this.columns = {};
249
+ for (const fieldName in this.schema) {
250
+ const field = this.schema[fieldName];
251
+ const ArrayType = field.type || Float32Array;
252
+ const oldColumn = this.columns[field.index];
253
+ if (oldColumn && ArrayBuffer.isView(oldColumn)) {
254
+ const typedArray = new ArrayType(this.allocated);
255
+ typedArray.set(oldColumn);
256
+ this.columns[field.index] = typedArray;
257
+ } else if (oldColumn) {
258
+ oldColumn.length = this.allocated;
259
+ this.columns[field.index] = oldColumn;
260
+ } else {
261
+ this.columns[field.index] = new ArrayType(this.allocated);
262
+ }
263
+ }
264
+ }
265
+ _pruneColumns() {
266
+ for (const [columnName, column] of Object.entries(this.columns)) {
267
+ this.columns[columnName] = column.slice(0, this.length);
268
+ }
269
+ }
270
+ };
266
271
 
267
272
  // ../schema/src/lib/table/batches/table-batch-builder.ts
268
- var DEFAULT_OPTIONS, ERR_MESSAGE, TableBatchBuilder;
269
- var init_table_batch_builder = __esm({
270
- "../schema/src/lib/table/batches/table-batch-builder.ts"() {
271
- init_base_table_batch_aggregator();
272
- init_row_table_batch_aggregator();
273
- init_columnar_table_batch_aggregator();
274
- DEFAULT_OPTIONS = {
275
- shape: "array-row-table",
276
- batchSize: "auto",
277
- batchDebounceMs: 0,
278
- limit: 0,
279
- _limitMB: 0
273
+ var DEFAULT_OPTIONS = {
274
+ shape: "array-row-table",
275
+ batchSize: "auto",
276
+ batchDebounceMs: 0,
277
+ limit: 0,
278
+ _limitMB: 0
279
+ };
280
+ var ERR_MESSAGE = "TableBatchBuilder";
281
+ var TableBatchBuilder = class {
282
+ aggregator = null;
283
+ batchCount = 0;
284
+ bytesUsed = 0;
285
+ isChunkComplete = false;
286
+ lastBatchEmittedMs = Date.now();
287
+ totalLength = 0;
288
+ totalBytes = 0;
289
+ rowBytes = 0;
290
+ constructor(schema, options) {
291
+ this.schema = schema;
292
+ this.options = {
293
+ ...DEFAULT_OPTIONS,
294
+ ...options
280
295
  };
281
- ERR_MESSAGE = "TableBatchBuilder";
282
- TableBatchBuilder = class {
283
- constructor(schema, options) {
284
- this.aggregator = null;
285
- this.batchCount = 0;
286
- this.bytesUsed = 0;
287
- this.isChunkComplete = false;
288
- this.lastBatchEmittedMs = Date.now();
289
- this.totalLength = 0;
290
- this.totalBytes = 0;
291
- this.rowBytes = 0;
292
- this.schema = schema;
293
- this.options = { ...DEFAULT_OPTIONS, ...options };
294
- }
295
- limitReached() {
296
- if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
297
- return true;
298
- }
299
- if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
300
- return true;
301
- }
296
+ }
297
+ limitReached() {
298
+ if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
299
+ return true;
300
+ }
301
+ if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
302
+ return true;
303
+ }
304
+ return false;
305
+ }
306
+ addRow(row) {
307
+ if (this.limitReached()) {
308
+ return;
309
+ }
310
+ this.totalLength++;
311
+ this.rowBytes = this.rowBytes || this._estimateRowMB(row);
312
+ this.totalBytes += this.rowBytes;
313
+ if (Array.isArray(row)) {
314
+ this.addArrayRow(row);
315
+ } else {
316
+ this.addObjectRow(row);
317
+ }
318
+ }
319
+ addArrayRow(row) {
320
+ if (!this.aggregator) {
321
+ const TableBatchType = this._getTableBatchType();
322
+ this.aggregator = new TableBatchType(this.schema, this.options);
323
+ }
324
+ this.aggregator.addArrayRow(row);
325
+ }
326
+ addObjectRow(row) {
327
+ if (!this.aggregator) {
328
+ const TableBatchType = this._getTableBatchType();
329
+ this.aggregator = new TableBatchType(this.schema, this.options);
330
+ }
331
+ this.aggregator.addObjectRow(row);
332
+ }
333
+ chunkComplete(chunk) {
334
+ if (chunk instanceof ArrayBuffer) {
335
+ this.bytesUsed += chunk.byteLength;
336
+ }
337
+ if (typeof chunk === "string") {
338
+ this.bytesUsed += chunk.length;
339
+ }
340
+ this.isChunkComplete = true;
341
+ }
342
+ getFullBatch(options) {
343
+ return this._isFull() ? this._getBatch(options) : null;
344
+ }
345
+ getFinalBatch(options) {
346
+ return this._getBatch(options);
347
+ }
348
+ _estimateRowMB(row) {
349
+ return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
350
+ }
351
+ _isFull() {
352
+ if (!this.aggregator || this.aggregator.rowCount() === 0) {
353
+ return false;
354
+ }
355
+ if (this.options.batchSize === "auto") {
356
+ if (!this.isChunkComplete) {
302
357
  return false;
303
358
  }
304
- addRow(row) {
305
- if (this.limitReached()) {
306
- return;
307
- }
308
- this.totalLength++;
309
- this.rowBytes = this.rowBytes || this._estimateRowMB(row);
310
- this.totalBytes += this.rowBytes;
311
- if (Array.isArray(row)) {
312
- this.addArrayRow(row);
313
- } else {
314
- this.addObjectRow(row);
315
- }
316
- }
317
- addArrayRow(row) {
318
- if (!this.aggregator) {
319
- const TableBatchType = this._getTableBatchType();
320
- this.aggregator = new TableBatchType(this.schema, this.options);
321
- }
322
- this.aggregator.addArrayRow(row);
323
- }
324
- addObjectRow(row) {
325
- if (!this.aggregator) {
326
- const TableBatchType = this._getTableBatchType();
327
- this.aggregator = new TableBatchType(this.schema, this.options);
328
- }
329
- this.aggregator.addObjectRow(row);
330
- }
331
- chunkComplete(chunk) {
332
- if (chunk instanceof ArrayBuffer) {
333
- this.bytesUsed += chunk.byteLength;
334
- }
335
- if (typeof chunk === "string") {
336
- this.bytesUsed += chunk.length;
337
- }
338
- this.isChunkComplete = true;
339
- }
340
- getFullBatch(options) {
341
- return this._isFull() ? this._getBatch(options) : null;
342
- }
343
- getFinalBatch(options) {
344
- return this._getBatch(options);
345
- }
346
- _estimateRowMB(row) {
347
- return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
348
- }
349
- _isFull() {
350
- if (!this.aggregator || this.aggregator.rowCount() === 0) {
351
- return false;
352
- }
353
- if (this.options.batchSize === "auto") {
354
- if (!this.isChunkComplete) {
355
- return false;
356
- }
357
- } else if (this.options.batchSize > this.aggregator.rowCount()) {
358
- return false;
359
- }
360
- if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
361
- return false;
362
- }
363
- this.isChunkComplete = false;
364
- this.lastBatchEmittedMs = Date.now();
365
- return true;
366
- }
367
- _getBatch(options) {
368
- if (!this.aggregator) {
369
- return null;
370
- }
371
- if (options?.bytesUsed) {
372
- this.bytesUsed = options.bytesUsed;
373
- }
374
- const normalizedBatch = this.aggregator.getBatch();
375
- normalizedBatch.count = this.batchCount;
376
- normalizedBatch.bytesUsed = this.bytesUsed;
377
- Object.assign(normalizedBatch, options);
378
- this.batchCount++;
379
- this.aggregator = null;
380
- return normalizedBatch;
381
- }
382
- _getTableBatchType() {
383
- switch (this.options.shape) {
384
- case "row-table":
385
- return BaseTableBatchAggregator;
386
- case "array-row-table":
387
- case "object-row-table":
388
- return RowTableBatchAggregator;
389
- case "columnar-table":
390
- return ColumnarTableBatchAggregator;
391
- case "arrow-table":
392
- if (!TableBatchBuilder.ArrowBatch) {
393
- throw new Error(ERR_MESSAGE);
394
- }
395
- return TableBatchBuilder.ArrowBatch;
396
- default:
397
- throw new Error(ERR_MESSAGE);
398
- }
399
- }
400
- };
359
+ } else if (this.options.batchSize > this.aggregator.rowCount()) {
360
+ return false;
361
+ }
362
+ if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
363
+ return false;
364
+ }
365
+ this.isChunkComplete = false;
366
+ this.lastBatchEmittedMs = Date.now();
367
+ return true;
401
368
  }
402
- });
369
+ _getBatch(options) {
370
+ if (!this.aggregator) {
371
+ return null;
372
+ }
373
+ if (options?.bytesUsed) {
374
+ this.bytesUsed = options.bytesUsed;
375
+ }
376
+ const normalizedBatch = this.aggregator.getBatch();
377
+ normalizedBatch.count = this.batchCount;
378
+ normalizedBatch.bytesUsed = this.bytesUsed;
379
+ Object.assign(normalizedBatch, options);
380
+ this.batchCount++;
381
+ this.aggregator = null;
382
+ return normalizedBatch;
383
+ }
384
+ _getTableBatchType() {
385
+ switch (this.options.shape) {
386
+ case "row-table":
387
+ return BaseTableBatchAggregator;
388
+ case "array-row-table":
389
+ case "object-row-table":
390
+ return RowTableBatchAggregator;
391
+ case "columnar-table":
392
+ return ColumnarTableBatchAggregator;
393
+ case "arrow-table":
394
+ if (!TableBatchBuilder.ArrowBatch) {
395
+ throw new Error(ERR_MESSAGE);
396
+ }
397
+ return TableBatchBuilder.ArrowBatch;
398
+ default:
399
+ throw new Error(ERR_MESSAGE);
400
+ }
401
+ }
402
+ };
403
403
 
404
404
  // ../schema/src/lib/table/simple-table/table-accessors.ts
405
405
  function getTableLength(table) {
@@ -568,10 +568,6 @@
568
568
  yield getTableRowAsObject(table, rowIndex, target);
569
569
  }
570
570
  }
571
- var init_table_accessors = __esm({
572
- "../schema/src/lib/table/simple-table/table-accessors.ts"() {
573
- }
574
- });
575
571
 
576
572
  // ../schema/src/lib/table/simple-table/data-type.ts
577
573
  function getDataTypeFromValue(value, defaultNumberType = "float32") {
@@ -592,13 +588,22 @@
592
588
  function getDataTypeFromArray(array) {
593
589
  let type = getDataTypeFromTypedArray(array);
594
590
  if (type !== "null") {
595
- return { type, nullable: false };
591
+ return {
592
+ type,
593
+ nullable: false
594
+ };
596
595
  }
597
596
  if (array.length > 0) {
598
597
  type = getDataTypeFromValue(array[0]);
599
- return { type, nullable: true };
598
+ return {
599
+ type,
600
+ nullable: true
601
+ };
600
602
  }
601
- return { type: "null", nullable: true };
603
+ return {
604
+ type: "null",
605
+ nullable: true
606
+ };
602
607
  }
603
608
  function getDataTypeFromTypedArray(array) {
604
609
  switch (array.constructor) {
@@ -623,10 +628,6 @@
623
628
  return "null";
624
629
  }
625
630
  }
626
- var init_data_type = __esm({
627
- "../schema/src/lib/table/simple-table/data-type.ts"() {
628
- }
629
- });
630
631
 
631
632
  // ../schema/src/lib/table/simple-table/table-schema.ts
632
633
  function deduceTableSchema(table) {
@@ -647,7 +648,10 @@
647
648
  const field = deduceFieldFromColumn(column, columnName);
648
649
  fields.push(field);
649
650
  }
650
- return { fields, metadata: {} };
651
+ return {
652
+ fields,
653
+ metadata: {}
654
+ };
651
655
  }
652
656
  function deduceSchemaFromRows(rowTable) {
653
657
  if (!rowTable.length) {
@@ -658,7 +662,10 @@
658
662
  for (const [columnName, value] of Object.entries(row0)) {
659
663
  fields.push(deduceFieldFromValue(value, columnName));
660
664
  }
661
- return { fields, metadata: {} };
665
+ return {
666
+ fields,
667
+ metadata: {}
668
+ };
662
669
  }
663
670
  function deduceFieldFromColumn(column, name) {
664
671
  if (ArrayBuffer.isView(column)) {
@@ -688,30 +695,37 @@
688
695
  nullable: true
689
696
  };
690
697
  }
691
- var init_table_schema = __esm({
692
- "../schema/src/lib/table/simple-table/table-schema.ts"() {
693
- init_data_type();
694
- }
695
- });
696
698
 
697
699
  // ../schema/src/lib/table/simple-table/make-table.ts
698
700
  function makeTableFromData(data) {
699
701
  let table;
700
702
  switch (getTableShapeFromData(data)) {
701
703
  case "array-row-table":
702
- table = { shape: "array-row-table", data };
704
+ table = {
705
+ shape: "array-row-table",
706
+ data
707
+ };
703
708
  break;
704
709
  case "object-row-table":
705
- table = { shape: "object-row-table", data };
710
+ table = {
711
+ shape: "object-row-table",
712
+ data
713
+ };
706
714
  break;
707
715
  case "columnar-table":
708
- table = { shape: "columnar-table", data };
716
+ table = {
717
+ shape: "columnar-table",
718
+ data
719
+ };
709
720
  break;
710
721
  default:
711
722
  throw new Error("table");
712
723
  }
713
724
  const schema = deduceTableSchema(table);
714
- return { ...table, schema };
725
+ return {
726
+ ...table,
727
+ schema
728
+ };
715
729
  }
716
730
  function getTableShapeFromData(data) {
717
731
  if (Array.isArray(data)) {
@@ -731,20 +745,6 @@
731
745
  }
732
746
  throw new Error("invalid table");
733
747
  }
734
- var init_make_table = __esm({
735
- "../schema/src/lib/table/simple-table/make-table.ts"() {
736
- init_table_schema();
737
- }
738
- });
739
-
740
- // ../schema/src/index.ts
741
- var init_src = __esm({
742
- "../schema/src/index.ts"() {
743
- init_table_batch_builder();
744
- init_table_accessors();
745
- init_make_table();
746
- }
747
- });
748
748
 
749
749
  // src/lib/parsers/parse-json.ts
750
750
  function parseJSONSync(jsonText, options) {
@@ -773,11 +773,6 @@
773
773
  }
774
774
  return null;
775
775
  }
776
- var init_parse_json = __esm({
777
- "src/lib/parsers/parse-json.ts"() {
778
- init_src();
779
- }
780
- });
781
776
 
782
777
  // ../loader-utils/src/lib/env-utils/assert.ts
783
778
  function assert(condition, message) {
@@ -785,16 +780,14 @@
785
780
  throw new Error(message || "loader assertion failed.");
786
781
  }
787
782
  }
788
- var init_assert = __esm({
789
- "../loader-utils/src/lib/env-utils/assert.ts"() {
790
- }
791
- });
792
783
 
793
784
  // ../loader-utils/src/lib/iterators/text-iterators.ts
794
785
  async function* makeTextDecoderIterator(arrayBufferIterator, options = {}) {
795
786
  const textDecoder = new TextDecoder(void 0, options);
796
787
  for await (const arrayBuffer of arrayBufferIterator) {
797
- yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, { stream: true });
788
+ yield typeof arrayBuffer === "string" ? arrayBuffer : textDecoder.decode(arrayBuffer, {
789
+ stream: true
790
+ });
798
791
  }
799
792
  }
800
793
  async function* makeLineIterator(textIterator) {
@@ -815,791 +808,801 @@
815
808
  async function* makeNumberedLineIterator(lineIterator) {
816
809
  let counter = 1;
817
810
  for await (const line of lineIterator) {
818
- yield { counter, line };
811
+ yield {
812
+ counter,
813
+ line
814
+ };
819
815
  counter++;
820
816
  }
821
817
  }
822
- var init_text_iterators = __esm({
823
- "../loader-utils/src/lib/iterators/text-iterators.ts"() {
824
- }
825
- });
826
818
 
827
819
  // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
828
- var init_typeof = __esm({
829
- "../../node_modules/@babel/runtime/helpers/esm/typeof.js"() {
830
- }
831
- });
820
+ function _typeof(obj) {
821
+ "@babel/helpers - typeof";
822
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
823
+ return typeof obj2;
824
+ } : function(obj2) {
825
+ return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
826
+ }, _typeof(obj);
827
+ }
832
828
 
833
829
  // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
834
- var init_toPrimitive = __esm({
835
- "../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js"() {
836
- init_typeof();
837
- }
838
- });
830
+ function _toPrimitive(input, hint) {
831
+ if (_typeof(input) !== "object" || input === null)
832
+ return input;
833
+ var prim = input[Symbol.toPrimitive];
834
+ if (prim !== void 0) {
835
+ var res = prim.call(input, hint || "default");
836
+ if (_typeof(res) !== "object")
837
+ return res;
838
+ throw new TypeError("@@toPrimitive must return a primitive value.");
839
+ }
840
+ return (hint === "string" ? String : Number)(input);
841
+ }
839
842
 
840
843
  // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
841
- var init_toPropertyKey = __esm({
842
- "../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js"() {
843
- init_typeof();
844
- init_toPrimitive();
845
- }
846
- });
844
+ function _toPropertyKey(arg) {
845
+ var key = _toPrimitive(arg, "string");
846
+ return _typeof(key) === "symbol" ? key : String(key);
847
+ }
847
848
 
848
849
  // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
849
- var init_defineProperty = __esm({
850
- "../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
851
- init_toPropertyKey();
852
- }
853
- });
854
-
855
- // ../loader-utils/src/index.ts
856
- var init_src2 = __esm({
857
- "../loader-utils/src/index.ts"() {
858
- init_assert();
859
- init_text_iterators();
850
+ function _defineProperty(obj, key, value) {
851
+ key = _toPropertyKey(key);
852
+ if (key in obj) {
853
+ Object.defineProperty(obj, key, {
854
+ value,
855
+ enumerable: true,
856
+ configurable: true,
857
+ writable: true
858
+ });
859
+ } else {
860
+ obj[key] = value;
860
861
  }
861
- });
862
+ return obj;
863
+ }
862
864
 
863
865
  // src/lib/clarinet/clarinet.ts
864
- function isWhitespace(c) {
865
- return c === Char.carriageReturn || c === Char.lineFeed || c === Char.space || c === Char.tab;
866
- }
867
- function checkBufferLength(parser) {
868
- const maxAllowed = Math.max(MAX_BUFFER_LENGTH, 10);
869
- let maxActual = 0;
870
- for (const buffer of ["textNode", "numberNode"]) {
871
- const len = parser[buffer] === void 0 ? 0 : parser[buffer].length;
872
- if (len > maxAllowed) {
873
- switch (buffer) {
874
- case "text":
875
- break;
876
- default:
877
- parser._error(`Max buffer length exceeded: ${buffer}`);
878
- }
879
- }
880
- maxActual = Math.max(maxActual, len);
866
+ var MAX_BUFFER_LENGTH = Number.MAX_SAFE_INTEGER;
867
+ var STATE = function(STATE2) {
868
+ STATE2[STATE2["BEGIN"] = 0] = "BEGIN";
869
+ STATE2[STATE2["VALUE"] = 1] = "VALUE";
870
+ STATE2[STATE2["OPEN_OBJECT"] = 2] = "OPEN_OBJECT";
871
+ STATE2[STATE2["CLOSE_OBJECT"] = 3] = "CLOSE_OBJECT";
872
+ STATE2[STATE2["OPEN_ARRAY"] = 4] = "OPEN_ARRAY";
873
+ STATE2[STATE2["CLOSE_ARRAY"] = 5] = "CLOSE_ARRAY";
874
+ STATE2[STATE2["TEXT_ESCAPE"] = 6] = "TEXT_ESCAPE";
875
+ STATE2[STATE2["STRING"] = 7] = "STRING";
876
+ STATE2[STATE2["BACKSLASH"] = 8] = "BACKSLASH";
877
+ STATE2[STATE2["END"] = 9] = "END";
878
+ STATE2[STATE2["OPEN_KEY"] = 10] = "OPEN_KEY";
879
+ STATE2[STATE2["CLOSE_KEY"] = 11] = "CLOSE_KEY";
880
+ STATE2[STATE2["TRUE"] = 12] = "TRUE";
881
+ STATE2[STATE2["TRUE2"] = 13] = "TRUE2";
882
+ STATE2[STATE2["TRUE3"] = 14] = "TRUE3";
883
+ STATE2[STATE2["FALSE"] = 15] = "FALSE";
884
+ STATE2[STATE2["FALSE2"] = 16] = "FALSE2";
885
+ STATE2[STATE2["FALSE3"] = 17] = "FALSE3";
886
+ STATE2[STATE2["FALSE4"] = 18] = "FALSE4";
887
+ STATE2[STATE2["NULL"] = 19] = "NULL";
888
+ STATE2[STATE2["NULL2"] = 20] = "NULL2";
889
+ STATE2[STATE2["NULL3"] = 21] = "NULL3";
890
+ STATE2[STATE2["NUMBER_DECIMAL_POINT"] = 22] = "NUMBER_DECIMAL_POINT";
891
+ STATE2[STATE2["NUMBER_DIGIT"] = 23] = "NUMBER_DIGIT";
892
+ return STATE2;
893
+ }(STATE || {});
894
+ var Char = {
895
+ tab: 9,
896
+ lineFeed: 10,
897
+ carriageReturn: 13,
898
+ space: 32,
899
+ doubleQuote: 34,
900
+ plus: 43,
901
+ comma: 44,
902
+ minus: 45,
903
+ period: 46,
904
+ _0: 48,
905
+ _9: 57,
906
+ colon: 58,
907
+ E: 69,
908
+ openBracket: 91,
909
+ backslash: 92,
910
+ closeBracket: 93,
911
+ a: 97,
912
+ b: 98,
913
+ e: 101,
914
+ f: 102,
915
+ l: 108,
916
+ n: 110,
917
+ r: 114,
918
+ s: 115,
919
+ t: 116,
920
+ u: 117,
921
+ openBrace: 123,
922
+ closeBrace: 125
923
+ };
924
+ var stringTokenPattern = /[\\"\n]/g;
925
+ var DEFAULT_OPTIONS2 = {
926
+ onready: () => {
927
+ },
928
+ onopenobject: () => {
929
+ },
930
+ onkey: () => {
931
+ },
932
+ oncloseobject: () => {
933
+ },
934
+ onopenarray: () => {
935
+ },
936
+ onclosearray: () => {
937
+ },
938
+ onvalue: () => {
939
+ },
940
+ onerror: () => {
941
+ },
942
+ onend: () => {
943
+ },
944
+ onchunkparsed: () => {
881
945
  }
882
- parser.bufferCheckPosition = MAX_BUFFER_LENGTH - maxActual + parser.position;
883
- }
884
- var MAX_BUFFER_LENGTH, STATE, Char, stringTokenPattern, DEFAULT_OPTIONS2, ClarinetParser;
885
- var init_clarinet = __esm({
886
- "src/lib/clarinet/clarinet.ts"() {
887
- MAX_BUFFER_LENGTH = Number.MAX_SAFE_INTEGER;
888
- (function(STATE2) {
889
- STATE2[STATE2["BEGIN"] = 0] = "BEGIN";
890
- STATE2[STATE2["VALUE"] = 1] = "VALUE";
891
- STATE2[STATE2["OPEN_OBJECT"] = 2] = "OPEN_OBJECT";
892
- STATE2[STATE2["CLOSE_OBJECT"] = 3] = "CLOSE_OBJECT";
893
- STATE2[STATE2["OPEN_ARRAY"] = 4] = "OPEN_ARRAY";
894
- STATE2[STATE2["CLOSE_ARRAY"] = 5] = "CLOSE_ARRAY";
895
- STATE2[STATE2["TEXT_ESCAPE"] = 6] = "TEXT_ESCAPE";
896
- STATE2[STATE2["STRING"] = 7] = "STRING";
897
- STATE2[STATE2["BACKSLASH"] = 8] = "BACKSLASH";
898
- STATE2[STATE2["END"] = 9] = "END";
899
- STATE2[STATE2["OPEN_KEY"] = 10] = "OPEN_KEY";
900
- STATE2[STATE2["CLOSE_KEY"] = 11] = "CLOSE_KEY";
901
- STATE2[STATE2["TRUE"] = 12] = "TRUE";
902
- STATE2[STATE2["TRUE2"] = 13] = "TRUE2";
903
- STATE2[STATE2["TRUE3"] = 14] = "TRUE3";
904
- STATE2[STATE2["FALSE"] = 15] = "FALSE";
905
- STATE2[STATE2["FALSE2"] = 16] = "FALSE2";
906
- STATE2[STATE2["FALSE3"] = 17] = "FALSE3";
907
- STATE2[STATE2["FALSE4"] = 18] = "FALSE4";
908
- STATE2[STATE2["NULL"] = 19] = "NULL";
909
- STATE2[STATE2["NULL2"] = 20] = "NULL2";
910
- STATE2[STATE2["NULL3"] = 21] = "NULL3";
911
- STATE2[STATE2["NUMBER_DECIMAL_POINT"] = 22] = "NUMBER_DECIMAL_POINT";
912
- STATE2[STATE2["NUMBER_DIGIT"] = 23] = "NUMBER_DIGIT";
913
- })(STATE || (STATE = {}));
914
- Char = {
915
- tab: 9,
916
- lineFeed: 10,
917
- carriageReturn: 13,
918
- space: 32,
919
- doubleQuote: 34,
920
- plus: 43,
921
- comma: 44,
922
- minus: 45,
923
- period: 46,
924
- _0: 48,
925
- _9: 57,
926
- colon: 58,
927
- E: 69,
928
- openBracket: 91,
929
- backslash: 92,
930
- closeBracket: 93,
931
- a: 97,
932
- b: 98,
933
- e: 101,
934
- f: 102,
935
- l: 108,
936
- n: 110,
937
- r: 114,
938
- s: 115,
939
- t: 116,
940
- u: 117,
941
- openBrace: 123,
942
- closeBrace: 125
946
+ };
947
+ var ClarinetParser = class {
948
+ options = DEFAULT_OPTIONS2;
949
+ bufferCheckPosition = MAX_BUFFER_LENGTH;
950
+ q = "";
951
+ c = "";
952
+ p = "";
953
+ closed = false;
954
+ closedRoot = false;
955
+ sawRoot = false;
956
+ error = null;
957
+ state = STATE.BEGIN;
958
+ stack = [];
959
+ position = 0;
960
+ column = 0;
961
+ line = 1;
962
+ slashed = false;
963
+ unicodeI = 0;
964
+ unicodeS = null;
965
+ depth = 0;
966
+ constructor(options = {}) {
967
+ this.options = {
968
+ ...DEFAULT_OPTIONS2,
969
+ ...options
943
970
  };
944
- stringTokenPattern = /[\\"\n]/g;
945
- DEFAULT_OPTIONS2 = {
946
- onready: () => {
947
- },
948
- onopenobject: () => {
949
- },
950
- onkey: () => {
951
- },
952
- oncloseobject: () => {
953
- },
954
- onopenarray: () => {
955
- },
956
- onclosearray: () => {
957
- },
958
- onvalue: () => {
959
- },
960
- onerror: () => {
961
- },
962
- onend: () => {
963
- },
964
- onchunkparsed: () => {
971
+ this.textNode = void 0;
972
+ this.numberNode = "";
973
+ this.emit("onready");
974
+ }
975
+ end() {
976
+ if (this.state !== STATE.VALUE || this.depth !== 0)
977
+ this._error("Unexpected end");
978
+ this._closeValue();
979
+ this.c = "";
980
+ this.closed = true;
981
+ this.emit("onend");
982
+ return this;
983
+ }
984
+ resume() {
985
+ this.error = null;
986
+ return this;
987
+ }
988
+ close() {
989
+ return this.write(null);
990
+ }
991
+ emit(event, data) {
992
+ this.options[event]?.(data, this);
993
+ }
994
+ emitNode(event, data) {
995
+ this._closeValue();
996
+ this.emit(event, data);
997
+ }
998
+ write(chunk) {
999
+ if (this.error) {
1000
+ throw this.error;
1001
+ }
1002
+ if (this.closed) {
1003
+ return this._error("Cannot write after close. Assign an onready handler.");
1004
+ }
1005
+ if (chunk === null) {
1006
+ return this.end();
1007
+ }
1008
+ let i = 0;
1009
+ let c = chunk.charCodeAt(0);
1010
+ let p = this.p;
1011
+ while (c) {
1012
+ p = c;
1013
+ this.c = c = chunk.charCodeAt(i++);
1014
+ if (p !== c) {
1015
+ this.p = p;
1016
+ } else {
1017
+ p = this.p;
965
1018
  }
966
- };
967
- ClarinetParser = class {
968
- constructor(options = {}) {
969
- this.options = DEFAULT_OPTIONS2;
970
- this.bufferCheckPosition = MAX_BUFFER_LENGTH;
971
- this.q = "";
972
- this.c = "";
973
- this.p = "";
974
- this.closed = false;
975
- this.closedRoot = false;
976
- this.sawRoot = false;
977
- this.error = null;
978
- this.state = 0;
979
- this.stack = [];
980
- this.position = 0;
1019
+ if (!c)
1020
+ break;
1021
+ this.position++;
1022
+ if (c === Char.lineFeed) {
1023
+ this.line++;
981
1024
  this.column = 0;
982
- this.line = 1;
983
- this.slashed = false;
984
- this.unicodeI = 0;
985
- this.unicodeS = null;
986
- this.depth = 0;
987
- this.options = { ...DEFAULT_OPTIONS2, ...options };
988
- this.textNode = void 0;
989
- this.numberNode = "";
990
- this.emit("onready");
991
- }
992
- end() {
993
- if (this.state !== 1 || this.depth !== 0)
994
- this._error("Unexpected end");
995
- this._closeValue();
996
- this.c = "";
997
- this.closed = true;
998
- this.emit("onend");
999
- return this;
1000
- }
1001
- resume() {
1002
- this.error = null;
1003
- return this;
1004
- }
1005
- close() {
1006
- return this.write(null);
1007
- }
1008
- emit(event, data) {
1009
- this.options[event]?.(data, this);
1010
- }
1011
- emitNode(event, data) {
1012
- this._closeValue();
1013
- this.emit(event, data);
1014
- }
1015
- write(chunk) {
1016
- if (this.error) {
1017
- throw this.error;
1018
- }
1019
- if (this.closed) {
1020
- return this._error("Cannot write after close. Assign an onready handler.");
1021
- }
1022
- if (chunk === null) {
1023
- return this.end();
1024
- }
1025
- let i = 0;
1026
- let c = chunk.charCodeAt(0);
1027
- let p = this.p;
1028
- while (c) {
1029
- p = c;
1030
- this.c = c = chunk.charCodeAt(i++);
1031
- if (p !== c) {
1032
- this.p = p;
1033
- } else {
1034
- p = this.p;
1025
+ } else
1026
+ this.column++;
1027
+ switch (this.state) {
1028
+ case STATE.BEGIN:
1029
+ if (c === Char.openBrace)
1030
+ this.state = STATE.OPEN_OBJECT;
1031
+ else if (c === Char.openBracket)
1032
+ this.state = STATE.OPEN_ARRAY;
1033
+ else if (!isWhitespace(c)) {
1034
+ this._error("Non-whitespace before {[.");
1035
1035
  }
1036
- if (!c)
1037
- break;
1038
- this.position++;
1039
- if (c === Char.lineFeed) {
1040
- this.line++;
1041
- this.column = 0;
1036
+ continue;
1037
+ case STATE.OPEN_KEY:
1038
+ case STATE.OPEN_OBJECT:
1039
+ if (isWhitespace(c))
1040
+ continue;
1041
+ if (this.state === STATE.OPEN_KEY)
1042
+ this.stack.push(STATE.CLOSE_KEY);
1043
+ else if (c === Char.closeBrace) {
1044
+ this.emit("onopenobject");
1045
+ this.depth++;
1046
+ this.emit("oncloseobject");
1047
+ this.depth--;
1048
+ this.state = this.stack.pop() || STATE.VALUE;
1049
+ continue;
1042
1050
  } else
1043
- this.column++;
1044
- switch (this.state) {
1045
- case 0:
1046
- if (c === Char.openBrace)
1047
- this.state = 2;
1048
- else if (c === Char.openBracket)
1049
- this.state = 4;
1050
- else if (!isWhitespace(c)) {
1051
- this._error("Non-whitespace before {[.");
1052
- }
1053
- continue;
1054
- case 10:
1055
- case 2:
1056
- if (isWhitespace(c))
1057
- continue;
1058
- if (this.state === 10)
1059
- this.stack.push(11);
1060
- else if (c === Char.closeBrace) {
1061
- this.emit("onopenobject");
1062
- this.depth++;
1063
- this.emit("oncloseobject");
1064
- this.depth--;
1065
- this.state = this.stack.pop() || 1;
1066
- continue;
1067
- } else
1068
- this.stack.push(3);
1069
- if (c === Char.doubleQuote)
1070
- this.state = 7;
1071
- else
1072
- this._error('Malformed object key should start with "');
1073
- continue;
1074
- case 11:
1075
- case 3:
1076
- if (isWhitespace(c))
1077
- continue;
1078
- if (c === Char.colon) {
1079
- if (this.state === 3) {
1080
- this.stack.push(3);
1081
- this._closeValue("onopenobject");
1082
- this.depth++;
1083
- } else
1084
- this._closeValue("onkey");
1085
- this.state = 1;
1086
- } else if (c === Char.closeBrace) {
1087
- this.emitNode("oncloseobject");
1088
- this.depth--;
1089
- this.state = this.stack.pop() || 1;
1090
- } else if (c === Char.comma) {
1091
- if (this.state === 3)
1092
- this.stack.push(3);
1093
- this._closeValue();
1094
- this.state = 10;
1095
- } else
1096
- this._error("Bad object");
1051
+ this.stack.push(STATE.CLOSE_OBJECT);
1052
+ if (c === Char.doubleQuote)
1053
+ this.state = STATE.STRING;
1054
+ else
1055
+ this._error('Malformed object key should start with "');
1056
+ continue;
1057
+ case STATE.CLOSE_KEY:
1058
+ case STATE.CLOSE_OBJECT:
1059
+ if (isWhitespace(c))
1060
+ continue;
1061
+ if (c === Char.colon) {
1062
+ if (this.state === STATE.CLOSE_OBJECT) {
1063
+ this.stack.push(STATE.CLOSE_OBJECT);
1064
+ this._closeValue("onopenobject");
1065
+ this.depth++;
1066
+ } else
1067
+ this._closeValue("onkey");
1068
+ this.state = STATE.VALUE;
1069
+ } else if (c === Char.closeBrace) {
1070
+ this.emitNode("oncloseobject");
1071
+ this.depth--;
1072
+ this.state = this.stack.pop() || STATE.VALUE;
1073
+ } else if (c === Char.comma) {
1074
+ if (this.state === STATE.CLOSE_OBJECT)
1075
+ this.stack.push(STATE.CLOSE_OBJECT);
1076
+ this._closeValue();
1077
+ this.state = STATE.OPEN_KEY;
1078
+ } else
1079
+ this._error("Bad object");
1080
+ continue;
1081
+ case STATE.OPEN_ARRAY:
1082
+ case STATE.VALUE:
1083
+ if (isWhitespace(c))
1084
+ continue;
1085
+ if (this.state === STATE.OPEN_ARRAY) {
1086
+ this.emit("onopenarray");
1087
+ this.depth++;
1088
+ this.state = STATE.VALUE;
1089
+ if (c === Char.closeBracket) {
1090
+ this.emit("onclosearray");
1091
+ this.depth--;
1092
+ this.state = this.stack.pop() || STATE.VALUE;
1097
1093
  continue;
1098
- case 4:
1099
- case 1:
1100
- if (isWhitespace(c))
1101
- continue;
1102
- if (this.state === 4) {
1103
- this.emit("onopenarray");
1104
- this.depth++;
1105
- this.state = 1;
1106
- if (c === Char.closeBracket) {
1107
- this.emit("onclosearray");
1108
- this.depth--;
1109
- this.state = this.stack.pop() || 1;
1110
- continue;
1094
+ } else {
1095
+ this.stack.push(STATE.CLOSE_ARRAY);
1096
+ }
1097
+ }
1098
+ if (c === Char.doubleQuote)
1099
+ this.state = STATE.STRING;
1100
+ else if (c === Char.openBrace)
1101
+ this.state = STATE.OPEN_OBJECT;
1102
+ else if (c === Char.openBracket)
1103
+ this.state = STATE.OPEN_ARRAY;
1104
+ else if (c === Char.t)
1105
+ this.state = STATE.TRUE;
1106
+ else if (c === Char.f)
1107
+ this.state = STATE.FALSE;
1108
+ else if (c === Char.n)
1109
+ this.state = STATE.NULL;
1110
+ else if (c === Char.minus) {
1111
+ this.numberNode += "-";
1112
+ } else if (Char._0 <= c && c <= Char._9) {
1113
+ this.numberNode += String.fromCharCode(c);
1114
+ this.state = STATE.NUMBER_DIGIT;
1115
+ } else
1116
+ this._error("Bad value");
1117
+ continue;
1118
+ case STATE.CLOSE_ARRAY:
1119
+ if (c === Char.comma) {
1120
+ this.stack.push(STATE.CLOSE_ARRAY);
1121
+ this._closeValue("onvalue");
1122
+ this.state = STATE.VALUE;
1123
+ } else if (c === Char.closeBracket) {
1124
+ this.emitNode("onclosearray");
1125
+ this.depth--;
1126
+ this.state = this.stack.pop() || STATE.VALUE;
1127
+ } else if (isWhitespace(c))
1128
+ continue;
1129
+ else
1130
+ this._error("Bad array");
1131
+ continue;
1132
+ case STATE.STRING:
1133
+ if (this.textNode === void 0) {
1134
+ this.textNode = "";
1135
+ }
1136
+ let starti = i - 1;
1137
+ let slashed = this.slashed;
1138
+ let unicodeI = this.unicodeI;
1139
+ STRING_BIGLOOP:
1140
+ while (true) {
1141
+ while (unicodeI > 0) {
1142
+ this.unicodeS += String.fromCharCode(c);
1143
+ c = chunk.charCodeAt(i++);
1144
+ this.position++;
1145
+ if (unicodeI === 4) {
1146
+ this.textNode += String.fromCharCode(parseInt(this.unicodeS, 16));
1147
+ unicodeI = 0;
1148
+ starti = i - 1;
1111
1149
  } else {
1112
- this.stack.push(5);
1150
+ unicodeI++;
1113
1151
  }
1152
+ if (!c)
1153
+ break STRING_BIGLOOP;
1114
1154
  }
1115
- if (c === Char.doubleQuote)
1116
- this.state = 7;
1117
- else if (c === Char.openBrace)
1118
- this.state = 2;
1119
- else if (c === Char.openBracket)
1120
- this.state = 4;
1121
- else if (c === Char.t)
1122
- this.state = 12;
1123
- else if (c === Char.f)
1124
- this.state = 15;
1125
- else if (c === Char.n)
1126
- this.state = 19;
1127
- else if (c === Char.minus) {
1128
- this.numberNode += "-";
1129
- } else if (Char._0 <= c && c <= Char._9) {
1130
- this.numberNode += String.fromCharCode(c);
1131
- this.state = 23;
1132
- } else
1133
- this._error("Bad value");
1134
- continue;
1135
- case 5:
1136
- if (c === Char.comma) {
1137
- this.stack.push(5);
1138
- this._closeValue("onvalue");
1139
- this.state = 1;
1140
- } else if (c === Char.closeBracket) {
1141
- this.emitNode("onclosearray");
1142
- this.depth--;
1143
- this.state = this.stack.pop() || 1;
1144
- } else if (isWhitespace(c))
1145
- continue;
1146
- else
1147
- this._error("Bad array");
1148
- continue;
1149
- case 7:
1150
- if (this.textNode === void 0) {
1151
- this.textNode = "";
1155
+ if (c === Char.doubleQuote && !slashed) {
1156
+ this.state = this.stack.pop() || STATE.VALUE;
1157
+ this.textNode += chunk.substring(starti, i - 1);
1158
+ this.position += i - 1 - starti;
1159
+ break;
1160
+ }
1161
+ if (c === Char.backslash && !slashed) {
1162
+ slashed = true;
1163
+ this.textNode += chunk.substring(starti, i - 1);
1164
+ this.position += i - 1 - starti;
1165
+ c = chunk.charCodeAt(i++);
1166
+ this.position++;
1167
+ if (!c)
1168
+ break;
1152
1169
  }
1153
- let starti = i - 1;
1154
- let slashed = this.slashed;
1155
- let unicodeI = this.unicodeI;
1156
- STRING_BIGLOOP:
1157
- while (true) {
1158
- while (unicodeI > 0) {
1159
- this.unicodeS += String.fromCharCode(c);
1160
- c = chunk.charCodeAt(i++);
1161
- this.position++;
1162
- if (unicodeI === 4) {
1163
- this.textNode += String.fromCharCode(parseInt(this.unicodeS, 16));
1164
- unicodeI = 0;
1165
- starti = i - 1;
1166
- } else {
1167
- unicodeI++;
1168
- }
1169
- if (!c)
1170
- break STRING_BIGLOOP;
1171
- }
1172
- if (c === Char.doubleQuote && !slashed) {
1173
- this.state = this.stack.pop() || 1;
1174
- this.textNode += chunk.substring(starti, i - 1);
1175
- this.position += i - 1 - starti;
1176
- break;
1177
- }
1178
- if (c === Char.backslash && !slashed) {
1179
- slashed = true;
1180
- this.textNode += chunk.substring(starti, i - 1);
1181
- this.position += i - 1 - starti;
1182
- c = chunk.charCodeAt(i++);
1183
- this.position++;
1184
- if (!c)
1185
- break;
1186
- }
1187
- if (slashed) {
1188
- slashed = false;
1189
- if (c === Char.n) {
1190
- this.textNode += "\n";
1191
- } else if (c === Char.r) {
1192
- this.textNode += "\r";
1193
- } else if (c === Char.t) {
1194
- this.textNode += " ";
1195
- } else if (c === Char.f) {
1196
- this.textNode += "\f";
1197
- } else if (c === Char.b) {
1198
- this.textNode += "\b";
1199
- } else if (c === Char.u) {
1200
- unicodeI = 1;
1201
- this.unicodeS = "";
1202
- } else {
1203
- this.textNode += String.fromCharCode(c);
1204
- }
1205
- c = chunk.charCodeAt(i++);
1206
- this.position++;
1207
- starti = i - 1;
1208
- if (!c)
1209
- break;
1210
- else
1211
- continue;
1212
- }
1213
- stringTokenPattern.lastIndex = i;
1214
- const reResult = stringTokenPattern.exec(chunk);
1215
- if (reResult === null) {
1216
- i = chunk.length + 1;
1217
- this.textNode += chunk.substring(starti, i - 1);
1218
- this.position += i - 1 - starti;
1219
- break;
1220
- }
1221
- i = reResult.index + 1;
1222
- c = chunk.charCodeAt(reResult.index);
1223
- if (!c) {
1224
- this.textNode += chunk.substring(starti, i - 1);
1225
- this.position += i - 1 - starti;
1226
- break;
1227
- }
1170
+ if (slashed) {
1171
+ slashed = false;
1172
+ if (c === Char.n) {
1173
+ this.textNode += "\n";
1174
+ } else if (c === Char.r) {
1175
+ this.textNode += "\r";
1176
+ } else if (c === Char.t) {
1177
+ this.textNode += " ";
1178
+ } else if (c === Char.f) {
1179
+ this.textNode += "\f";
1180
+ } else if (c === Char.b) {
1181
+ this.textNode += "\b";
1182
+ } else if (c === Char.u) {
1183
+ unicodeI = 1;
1184
+ this.unicodeS = "";
1185
+ } else {
1186
+ this.textNode += String.fromCharCode(c);
1228
1187
  }
1229
- this.slashed = slashed;
1230
- this.unicodeI = unicodeI;
1231
- continue;
1232
- case 12:
1233
- if (c === Char.r)
1234
- this.state = 13;
1235
- else
1236
- this._error(`Invalid true started with t${c}`);
1237
- continue;
1238
- case 13:
1239
- if (c === Char.u)
1240
- this.state = 14;
1241
- else
1242
- this._error(`Invalid true started with tr${c}`);
1243
- continue;
1244
- case 14:
1245
- if (c === Char.e) {
1246
- this.emit("onvalue", true);
1247
- this.state = this.stack.pop() || 1;
1248
- } else
1249
- this._error(`Invalid true started with tru${c}`);
1250
- continue;
1251
- case 15:
1252
- if (c === Char.a)
1253
- this.state = 16;
1254
- else
1255
- this._error(`Invalid false started with f${c}`);
1256
- continue;
1257
- case 16:
1258
- if (c === Char.l)
1259
- this.state = 17;
1260
- else
1261
- this._error(`Invalid false started with fa${c}`);
1262
- continue;
1263
- case 17:
1264
- if (c === Char.s)
1265
- this.state = 18;
1266
- else
1267
- this._error(`Invalid false started with fal${c}`);
1268
- continue;
1269
- case 18:
1270
- if (c === Char.e) {
1271
- this.emit("onvalue", false);
1272
- this.state = this.stack.pop() || 1;
1273
- } else
1274
- this._error(`Invalid false started with fals${c}`);
1275
- continue;
1276
- case 19:
1277
- if (c === Char.u)
1278
- this.state = 20;
1279
- else
1280
- this._error(`Invalid null started with n${c}`);
1281
- continue;
1282
- case 20:
1283
- if (c === Char.l)
1284
- this.state = 21;
1285
- else
1286
- this._error(`Invalid null started with nu${c}`);
1287
- continue;
1288
- case 21:
1289
- if (c === Char.l) {
1290
- this.emit("onvalue", null);
1291
- this.state = this.stack.pop() || 1;
1292
- } else
1293
- this._error(`Invalid null started with nul${c}`);
1294
- continue;
1295
- case 22:
1296
- if (c === Char.period) {
1297
- this.numberNode += ".";
1298
- this.state = 23;
1299
- } else
1300
- this._error("Leading zero not followed by .");
1301
- continue;
1302
- case 23:
1303
- if (Char._0 <= c && c <= Char._9)
1304
- this.numberNode += String.fromCharCode(c);
1305
- else if (c === Char.period) {
1306
- if (this.numberNode.indexOf(".") !== -1)
1307
- this._error("Invalid number has two dots");
1308
- this.numberNode += ".";
1309
- } else if (c === Char.e || c === Char.E) {
1310
- if (this.numberNode.indexOf("e") !== -1 || this.numberNode.indexOf("E") !== -1)
1311
- this._error("Invalid number has two exponential");
1312
- this.numberNode += "e";
1313
- } else if (c === Char.plus || c === Char.minus) {
1314
- if (!(p === Char.e || p === Char.E))
1315
- this._error("Invalid symbol in number");
1316
- this.numberNode += String.fromCharCode(c);
1317
- } else {
1318
- this._closeNumber();
1319
- i--;
1320
- this.state = this.stack.pop() || 1;
1188
+ c = chunk.charCodeAt(i++);
1189
+ this.position++;
1190
+ starti = i - 1;
1191
+ if (!c)
1192
+ break;
1193
+ else
1194
+ continue;
1321
1195
  }
1322
- continue;
1323
- default:
1324
- this._error(`Unknown state: ${this.state}`);
1196
+ stringTokenPattern.lastIndex = i;
1197
+ const reResult = stringTokenPattern.exec(chunk);
1198
+ if (reResult === null) {
1199
+ i = chunk.length + 1;
1200
+ this.textNode += chunk.substring(starti, i - 1);
1201
+ this.position += i - 1 - starti;
1202
+ break;
1203
+ }
1204
+ i = reResult.index + 1;
1205
+ c = chunk.charCodeAt(reResult.index);
1206
+ if (!c) {
1207
+ this.textNode += chunk.substring(starti, i - 1);
1208
+ this.position += i - 1 - starti;
1209
+ break;
1210
+ }
1211
+ }
1212
+ this.slashed = slashed;
1213
+ this.unicodeI = unicodeI;
1214
+ continue;
1215
+ case STATE.TRUE:
1216
+ if (c === Char.r)
1217
+ this.state = STATE.TRUE2;
1218
+ else
1219
+ this._error(`Invalid true started with t${c}`);
1220
+ continue;
1221
+ case STATE.TRUE2:
1222
+ if (c === Char.u)
1223
+ this.state = STATE.TRUE3;
1224
+ else
1225
+ this._error(`Invalid true started with tr${c}`);
1226
+ continue;
1227
+ case STATE.TRUE3:
1228
+ if (c === Char.e) {
1229
+ this.emit("onvalue", true);
1230
+ this.state = this.stack.pop() || STATE.VALUE;
1231
+ } else
1232
+ this._error(`Invalid true started with tru${c}`);
1233
+ continue;
1234
+ case STATE.FALSE:
1235
+ if (c === Char.a)
1236
+ this.state = STATE.FALSE2;
1237
+ else
1238
+ this._error(`Invalid false started with f${c}`);
1239
+ continue;
1240
+ case STATE.FALSE2:
1241
+ if (c === Char.l)
1242
+ this.state = STATE.FALSE3;
1243
+ else
1244
+ this._error(`Invalid false started with fa${c}`);
1245
+ continue;
1246
+ case STATE.FALSE3:
1247
+ if (c === Char.s)
1248
+ this.state = STATE.FALSE4;
1249
+ else
1250
+ this._error(`Invalid false started with fal${c}`);
1251
+ continue;
1252
+ case STATE.FALSE4:
1253
+ if (c === Char.e) {
1254
+ this.emit("onvalue", false);
1255
+ this.state = this.stack.pop() || STATE.VALUE;
1256
+ } else
1257
+ this._error(`Invalid false started with fals${c}`);
1258
+ continue;
1259
+ case STATE.NULL:
1260
+ if (c === Char.u)
1261
+ this.state = STATE.NULL2;
1262
+ else
1263
+ this._error(`Invalid null started with n${c}`);
1264
+ continue;
1265
+ case STATE.NULL2:
1266
+ if (c === Char.l)
1267
+ this.state = STATE.NULL3;
1268
+ else
1269
+ this._error(`Invalid null started with nu${c}`);
1270
+ continue;
1271
+ case STATE.NULL3:
1272
+ if (c === Char.l) {
1273
+ this.emit("onvalue", null);
1274
+ this.state = this.stack.pop() || STATE.VALUE;
1275
+ } else
1276
+ this._error(`Invalid null started with nul${c}`);
1277
+ continue;
1278
+ case STATE.NUMBER_DECIMAL_POINT:
1279
+ if (c === Char.period) {
1280
+ this.numberNode += ".";
1281
+ this.state = STATE.NUMBER_DIGIT;
1282
+ } else
1283
+ this._error("Leading zero not followed by .");
1284
+ continue;
1285
+ case STATE.NUMBER_DIGIT:
1286
+ if (Char._0 <= c && c <= Char._9)
1287
+ this.numberNode += String.fromCharCode(c);
1288
+ else if (c === Char.period) {
1289
+ if (this.numberNode.indexOf(".") !== -1)
1290
+ this._error("Invalid number has two dots");
1291
+ this.numberNode += ".";
1292
+ } else if (c === Char.e || c === Char.E) {
1293
+ if (this.numberNode.indexOf("e") !== -1 || this.numberNode.indexOf("E") !== -1)
1294
+ this._error("Invalid number has two exponential");
1295
+ this.numberNode += "e";
1296
+ } else if (c === Char.plus || c === Char.minus) {
1297
+ if (!(p === Char.e || p === Char.E))
1298
+ this._error("Invalid symbol in number");
1299
+ this.numberNode += String.fromCharCode(c);
1300
+ } else {
1301
+ this._closeNumber();
1302
+ i--;
1303
+ this.state = this.stack.pop() || STATE.VALUE;
1325
1304
  }
1326
- }
1327
- if (this.position >= this.bufferCheckPosition) {
1328
- checkBufferLength(this);
1329
- }
1330
- this.emit("onchunkparsed");
1331
- return this;
1332
- }
1333
- _closeValue(event = "onvalue") {
1334
- if (this.textNode !== void 0) {
1335
- this.emit(event, this.textNode);
1336
- }
1337
- this.textNode = void 0;
1338
- }
1339
- _closeNumber() {
1340
- if (this.numberNode)
1341
- this.emit("onvalue", parseFloat(this.numberNode));
1342
- this.numberNode = "";
1305
+ continue;
1306
+ default:
1307
+ this._error(`Unknown state: ${this.state}`);
1343
1308
  }
1344
- _error(message = "") {
1345
- this._closeValue();
1346
- message += `
1309
+ }
1310
+ if (this.position >= this.bufferCheckPosition) {
1311
+ checkBufferLength(this);
1312
+ }
1313
+ this.emit("onchunkparsed");
1314
+ return this;
1315
+ }
1316
+ _closeValue(event = "onvalue") {
1317
+ if (this.textNode !== void 0) {
1318
+ this.emit(event, this.textNode);
1319
+ }
1320
+ this.textNode = void 0;
1321
+ }
1322
+ _closeNumber() {
1323
+ if (this.numberNode)
1324
+ this.emit("onvalue", parseFloat(this.numberNode));
1325
+ this.numberNode = "";
1326
+ }
1327
+ _error(message = "") {
1328
+ this._closeValue();
1329
+ message += `
1347
1330
  Line: ${this.line}
1348
1331
  Column: ${this.column}
1349
1332
  Char: ${this.c}`;
1350
- const error = new Error(message);
1351
- this.error = error;
1352
- this.emit("onerror", error);
1333
+ const error = new Error(message);
1334
+ this.error = error;
1335
+ this.emit("onerror", error);
1336
+ }
1337
+ };
1338
+ function isWhitespace(c) {
1339
+ return c === Char.carriageReturn || c === Char.lineFeed || c === Char.space || c === Char.tab;
1340
+ }
1341
+ function checkBufferLength(parser) {
1342
+ const maxAllowed = Math.max(MAX_BUFFER_LENGTH, 10);
1343
+ let maxActual = 0;
1344
+ for (const buffer of ["textNode", "numberNode"]) {
1345
+ const len = parser[buffer] === void 0 ? 0 : parser[buffer].length;
1346
+ if (len > maxAllowed) {
1347
+ switch (buffer) {
1348
+ case "text":
1349
+ break;
1350
+ default:
1351
+ parser._error(`Max buffer length exceeded: ${buffer}`);
1353
1352
  }
1354
- };
1353
+ }
1354
+ maxActual = Math.max(maxActual, len);
1355
1355
  }
1356
- });
1356
+ parser.bufferCheckPosition = MAX_BUFFER_LENGTH - maxActual + parser.position;
1357
+ }
1357
1358
 
1358
1359
  // src/lib/jsonpath/jsonpath.ts
1359
- var JSONPath;
1360
- var init_jsonpath = __esm({
1361
- "src/lib/jsonpath/jsonpath.ts"() {
1362
- JSONPath = class {
1363
- constructor(path = null) {
1364
- this.path = ["$"];
1365
- if (path instanceof JSONPath) {
1366
- this.path = [...path.path];
1367
- return;
1368
- }
1369
- if (Array.isArray(path)) {
1370
- this.path.push(...path);
1371
- return;
1372
- }
1373
- if (typeof path === "string") {
1374
- this.path = path.split(".");
1375
- if (this.path[0] !== "$") {
1376
- throw new Error("JSONPaths must start with $");
1377
- }
1378
- }
1379
- }
1380
- clone() {
1381
- return new JSONPath(this);
1382
- }
1383
- toString() {
1384
- return this.path.join(".");
1385
- }
1386
- push(name) {
1387
- this.path.push(name);
1388
- }
1389
- pop() {
1390
- return this.path.pop();
1391
- }
1392
- set(name) {
1393
- this.path[this.path.length - 1] = name;
1394
- }
1395
- equals(other) {
1396
- if (!this || !other || this.path.length !== other.path.length) {
1397
- return false;
1398
- }
1399
- for (let i = 0; i < this.path.length; ++i) {
1400
- if (this.path[i] !== other.path[i]) {
1401
- return false;
1402
- }
1403
- }
1404
- return true;
1405
- }
1406
- setFieldAtPath(object, value) {
1407
- const path = [...this.path];
1408
- path.shift();
1409
- const field = path.pop();
1410
- for (const component of path) {
1411
- object = object[component];
1412
- }
1413
- object[field] = value;
1360
+ var JSONPath = class {
1361
+ constructor(path = null) {
1362
+ this.path = ["$"];
1363
+ if (path instanceof JSONPath) {
1364
+ this.path = [...path.path];
1365
+ return;
1366
+ }
1367
+ if (Array.isArray(path)) {
1368
+ this.path.push(...path);
1369
+ return;
1370
+ }
1371
+ if (typeof path === "string") {
1372
+ this.path = path.split(".");
1373
+ if (this.path[0] !== "$") {
1374
+ throw new Error("JSONPaths must start with $");
1414
1375
  }
1415
- getFieldAtPath(object) {
1416
- const path = [...this.path];
1417
- path.shift();
1418
- const field = path.pop();
1419
- for (const component of path) {
1420
- object = object[component];
1421
- }
1422
- return object[field];
1376
+ }
1377
+ }
1378
+ clone() {
1379
+ return new JSONPath(this);
1380
+ }
1381
+ toString() {
1382
+ return this.path.join(".");
1383
+ }
1384
+ push(name) {
1385
+ this.path.push(name);
1386
+ }
1387
+ pop() {
1388
+ return this.path.pop();
1389
+ }
1390
+ set(name) {
1391
+ this.path[this.path.length - 1] = name;
1392
+ }
1393
+ equals(other) {
1394
+ if (!this || !other || this.path.length !== other.path.length) {
1395
+ return false;
1396
+ }
1397
+ for (let i = 0; i < this.path.length; ++i) {
1398
+ if (this.path[i] !== other.path[i]) {
1399
+ return false;
1423
1400
  }
1424
- };
1401
+ }
1402
+ return true;
1425
1403
  }
1426
- });
1404
+ setFieldAtPath(object, value) {
1405
+ const path = [...this.path];
1406
+ path.shift();
1407
+ const field = path.pop();
1408
+ for (const component of path) {
1409
+ object = object[component];
1410
+ }
1411
+ object[field] = value;
1412
+ }
1413
+ getFieldAtPath(object) {
1414
+ const path = [...this.path];
1415
+ path.shift();
1416
+ const field = path.pop();
1417
+ for (const component of path) {
1418
+ object = object[component];
1419
+ }
1420
+ return object[field];
1421
+ }
1422
+ };
1427
1423
 
1428
1424
  // src/lib/json-parser/json-parser.ts
1429
- var JSONParser;
1430
- var init_json_parser = __esm({
1431
- "src/lib/json-parser/json-parser.ts"() {
1432
- init_clarinet();
1433
- init_jsonpath();
1434
- JSONParser = class {
1435
- constructor(options) {
1436
- this.result = void 0;
1437
- this.previousStates = [];
1438
- this.currentState = Object.freeze({ container: [], key: null });
1439
- this.jsonpath = new JSONPath();
1440
- this.reset();
1441
- this.parser = new ClarinetParser({
1442
- onready: () => {
1443
- this.jsonpath = new JSONPath();
1444
- this.previousStates.length = 0;
1445
- this.currentState.container.length = 0;
1446
- },
1447
- onopenobject: (name) => {
1448
- this._openObject({});
1449
- if (typeof name !== "undefined") {
1450
- this.parser.emit("onkey", name);
1451
- }
1452
- },
1453
- onkey: (name) => {
1454
- this.jsonpath.set(name);
1455
- this.currentState.key = name;
1456
- },
1457
- oncloseobject: () => {
1458
- this._closeObject();
1459
- },
1460
- onopenarray: () => {
1461
- this._openArray();
1462
- },
1463
- onclosearray: () => {
1464
- this._closeArray();
1465
- },
1466
- onvalue: (value) => {
1467
- this._pushOrSet(value);
1468
- },
1469
- onerror: (error) => {
1470
- throw error;
1471
- },
1472
- onend: () => {
1473
- this.result = this.currentState.container.pop();
1474
- },
1475
- ...options
1476
- });
1477
- }
1478
- reset() {
1479
- this.result = void 0;
1480
- this.previousStates = [];
1481
- this.currentState = Object.freeze({ container: [], key: null });
1425
+ var JSONParser = class {
1426
+ result = void 0;
1427
+ previousStates = [];
1428
+ currentState = Object.freeze({
1429
+ container: [],
1430
+ key: null
1431
+ });
1432
+ jsonpath = new JSONPath();
1433
+ constructor(options) {
1434
+ this.reset();
1435
+ this.parser = new ClarinetParser({
1436
+ onready: () => {
1482
1437
  this.jsonpath = new JSONPath();
1483
- }
1484
- write(chunk) {
1485
- this.parser.write(chunk);
1486
- }
1487
- close() {
1488
- this.parser.close();
1489
- }
1490
- _pushOrSet(value) {
1491
- const { container, key } = this.currentState;
1492
- if (key !== null) {
1493
- container[key] = value;
1494
- this.currentState.key = null;
1495
- } else {
1496
- container.push(value);
1438
+ this.previousStates.length = 0;
1439
+ this.currentState.container.length = 0;
1440
+ },
1441
+ onopenobject: (name) => {
1442
+ this._openObject({});
1443
+ if (typeof name !== "undefined") {
1444
+ this.parser.emit("onkey", name);
1497
1445
  }
1498
- }
1499
- _openArray(newContainer = []) {
1500
- this.jsonpath.push(null);
1501
- this._pushOrSet(newContainer);
1502
- this.previousStates.push(this.currentState);
1503
- this.currentState = { container: newContainer, isArray: true, key: null };
1504
- }
1505
- _closeArray() {
1506
- this.jsonpath.pop();
1507
- this.currentState = this.previousStates.pop();
1508
- }
1509
- _openObject(newContainer = {}) {
1510
- this.jsonpath.push(null);
1511
- this._pushOrSet(newContainer);
1512
- this.previousStates.push(this.currentState);
1513
- this.currentState = { container: newContainer, isArray: false, key: null };
1514
- }
1515
- _closeObject() {
1516
- this.jsonpath.pop();
1517
- this.currentState = this.previousStates.pop();
1518
- }
1446
+ },
1447
+ onkey: (name) => {
1448
+ this.jsonpath.set(name);
1449
+ this.currentState.key = name;
1450
+ },
1451
+ oncloseobject: () => {
1452
+ this._closeObject();
1453
+ },
1454
+ onopenarray: () => {
1455
+ this._openArray();
1456
+ },
1457
+ onclosearray: () => {
1458
+ this._closeArray();
1459
+ },
1460
+ onvalue: (value) => {
1461
+ this._pushOrSet(value);
1462
+ },
1463
+ onerror: (error) => {
1464
+ throw error;
1465
+ },
1466
+ onend: () => {
1467
+ this.result = this.currentState.container.pop();
1468
+ },
1469
+ ...options
1470
+ });
1471
+ }
1472
+ reset() {
1473
+ this.result = void 0;
1474
+ this.previousStates = [];
1475
+ this.currentState = Object.freeze({
1476
+ container: [],
1477
+ key: null
1478
+ });
1479
+ this.jsonpath = new JSONPath();
1480
+ }
1481
+ write(chunk) {
1482
+ this.parser.write(chunk);
1483
+ }
1484
+ close() {
1485
+ this.parser.close();
1486
+ }
1487
+ _pushOrSet(value) {
1488
+ const {
1489
+ container,
1490
+ key
1491
+ } = this.currentState;
1492
+ if (key !== null) {
1493
+ container[key] = value;
1494
+ this.currentState.key = null;
1495
+ } else {
1496
+ container.push(value);
1497
+ }
1498
+ }
1499
+ _openArray(newContainer = []) {
1500
+ this.jsonpath.push(null);
1501
+ this._pushOrSet(newContainer);
1502
+ this.previousStates.push(this.currentState);
1503
+ this.currentState = {
1504
+ container: newContainer,
1505
+ isArray: true,
1506
+ key: null
1519
1507
  };
1520
1508
  }
1521
- });
1509
+ _closeArray() {
1510
+ this.jsonpath.pop();
1511
+ this.currentState = this.previousStates.pop();
1512
+ }
1513
+ _openObject(newContainer = {}) {
1514
+ this.jsonpath.push(null);
1515
+ this._pushOrSet(newContainer);
1516
+ this.previousStates.push(this.currentState);
1517
+ this.currentState = {
1518
+ container: newContainer,
1519
+ isArray: false,
1520
+ key: null
1521
+ };
1522
+ }
1523
+ _closeObject() {
1524
+ this.jsonpath.pop();
1525
+ this.currentState = this.previousStates.pop();
1526
+ }
1527
+ };
1522
1528
 
1523
1529
  // src/lib/json-parser/streaming-json-parser.ts
1524
- var StreamingJSONParser;
1525
- var init_streaming_json_parser = __esm({
1526
- "src/lib/json-parser/streaming-json-parser.ts"() {
1527
- init_json_parser();
1528
- init_jsonpath();
1529
- StreamingJSONParser = class extends JSONParser {
1530
- constructor(options = {}) {
1531
- super({
1532
- onopenarray: () => {
1533
- if (!this.streamingArray) {
1534
- if (this._matchJSONPath()) {
1535
- this.streamingJsonPath = this.getJsonPath().clone();
1536
- this.streamingArray = [];
1537
- this._openArray(this.streamingArray);
1538
- return;
1539
- }
1540
- }
1541
- this._openArray();
1542
- },
1543
- onopenobject: (name) => {
1544
- if (!this.topLevelObject) {
1545
- this.topLevelObject = {};
1546
- this._openObject(this.topLevelObject);
1547
- } else {
1548
- this._openObject({});
1549
- }
1550
- if (typeof name !== "undefined") {
1551
- this.parser.emit("onkey", name);
1552
- }
1530
+ var StreamingJSONParser = class extends JSONParser {
1531
+ streamingJsonPath = null;
1532
+ streamingArray = null;
1533
+ topLevelObject = null;
1534
+ constructor(options = {}) {
1535
+ super({
1536
+ onopenarray: () => {
1537
+ if (!this.streamingArray) {
1538
+ if (this._matchJSONPath()) {
1539
+ this.streamingJsonPath = this.getJsonPath().clone();
1540
+ this.streamingArray = [];
1541
+ this._openArray(this.streamingArray);
1542
+ return;
1553
1543
  }
1554
- });
1555
- this.streamingJsonPath = null;
1556
- this.streamingArray = null;
1557
- this.topLevelObject = null;
1558
- const jsonpaths = options.jsonpaths || [];
1559
- this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));
1560
- }
1561
- write(chunk) {
1562
- super.write(chunk);
1563
- let array = [];
1564
- if (this.streamingArray) {
1565
- array = [...this.streamingArray];
1566
- this.streamingArray.length = 0;
1567
1544
  }
1568
- return array;
1569
- }
1570
- getPartialResult() {
1571
- return this.topLevelObject;
1572
- }
1573
- getStreamingJsonPath() {
1574
- return this.streamingJsonPath;
1575
- }
1576
- getStreamingJsonPathAsString() {
1577
- return this.streamingJsonPath && this.streamingJsonPath.toString();
1578
- }
1579
- getJsonPath() {
1580
- return this.jsonpath;
1581
- }
1582
- _matchJSONPath() {
1583
- const currentPath = this.getJsonPath();
1584
- if (this.jsonPaths.length === 0) {
1585
- return true;
1545
+ this._openArray();
1546
+ },
1547
+ onopenobject: (name) => {
1548
+ if (!this.topLevelObject) {
1549
+ this.topLevelObject = {};
1550
+ this._openObject(this.topLevelObject);
1551
+ } else {
1552
+ this._openObject({});
1586
1553
  }
1587
- for (const jsonPath of this.jsonPaths) {
1588
- if (jsonPath.equals(currentPath)) {
1589
- return true;
1590
- }
1554
+ if (typeof name !== "undefined") {
1555
+ this.parser.emit("onkey", name);
1591
1556
  }
1592
- return false;
1593
1557
  }
1594
- };
1558
+ });
1559
+ const jsonpaths = options.jsonpaths || [];
1560
+ this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));
1561
+ }
1562
+ write(chunk) {
1563
+ super.write(chunk);
1564
+ let array = [];
1565
+ if (this.streamingArray) {
1566
+ array = [...this.streamingArray];
1567
+ this.streamingArray.length = 0;
1568
+ }
1569
+ return array;
1595
1570
  }
1596
- });
1571
+ getPartialResult() {
1572
+ return this.topLevelObject;
1573
+ }
1574
+ getStreamingJsonPath() {
1575
+ return this.streamingJsonPath;
1576
+ }
1577
+ getStreamingJsonPathAsString() {
1578
+ return this.streamingJsonPath && this.streamingJsonPath.toString();
1579
+ }
1580
+ getJsonPath() {
1581
+ return this.jsonpath;
1582
+ }
1583
+ _matchJSONPath() {
1584
+ const currentPath = this.getJsonPath();
1585
+ if (this.jsonPaths.length === 0) {
1586
+ return true;
1587
+ }
1588
+ for (const jsonPath of this.jsonPaths) {
1589
+ if (jsonPath.equals(currentPath)) {
1590
+ return true;
1591
+ }
1592
+ }
1593
+ return false;
1594
+ }
1595
+ };
1597
1596
 
1598
1597
  // src/lib/parsers/parse-json-in-batches.ts
1599
1598
  async function* parseJSONInBatches(binaryAsyncIterator, options) {
1600
1599
  const asyncIterator = makeTextDecoderIterator(binaryAsyncIterator);
1601
- const { metadata } = options;
1602
- const { jsonpaths } = options.json || {};
1600
+ const {
1601
+ metadata
1602
+ } = options;
1603
+ const {
1604
+ jsonpaths
1605
+ } = options.json || {};
1603
1606
  let isFirstChunk = true;
1604
1607
  const schema = null;
1605
1608
  const shape = options?.json?.shape || "object-row-table";
@@ -1607,7 +1610,9 @@ Char: ${this.c}`;
1607
1610
  ...options,
1608
1611
  shape
1609
1612
  });
1610
- const parser = new StreamingJSONParser({ jsonpaths });
1613
+ const parser = new StreamingJSONParser({
1614
+ jsonpaths
1615
+ });
1611
1616
  for await (const chunk of asyncIterator) {
1612
1617
  const rows = parser.write(chunk);
1613
1618
  const jsonpath2 = rows.length > 0 && parser.getStreamingJsonPathAsString();
@@ -1628,19 +1633,25 @@ Char: ${this.c}`;
1628
1633
  }
1629
1634
  for (const row of rows) {
1630
1635
  tableBatchBuilder.addRow(row);
1631
- const batch3 = tableBatchBuilder.getFullBatch({ jsonpath: jsonpath2 });
1636
+ const batch3 = tableBatchBuilder.getFullBatch({
1637
+ jsonpath: jsonpath2
1638
+ });
1632
1639
  if (batch3) {
1633
1640
  yield batch3;
1634
1641
  }
1635
1642
  }
1636
1643
  tableBatchBuilder.chunkComplete(chunk);
1637
- const batch2 = tableBatchBuilder.getFullBatch({ jsonpath: jsonpath2 });
1644
+ const batch2 = tableBatchBuilder.getFullBatch({
1645
+ jsonpath: jsonpath2
1646
+ });
1638
1647
  if (batch2) {
1639
1648
  yield batch2;
1640
1649
  }
1641
1650
  }
1642
1651
  const jsonpath = parser.getStreamingJsonPathAsString();
1643
- const batch = tableBatchBuilder.getFinalBatch({ jsonpath });
1652
+ const batch = tableBatchBuilder.getFinalBatch({
1653
+ jsonpath
1654
+ });
1644
1655
  if (batch) {
1645
1656
  yield batch;
1646
1657
  }
@@ -1669,56 +1680,53 @@ Char: ${this.c}`;
1669
1680
  }
1670
1681
  return batch.container;
1671
1682
  }
1672
- var init_parse_json_in_batches = __esm({
1673
- "src/lib/parsers/parse-json-in-batches.ts"() {
1674
- init_src();
1675
- init_src2();
1676
- init_streaming_json_parser();
1677
- init_jsonpath();
1678
- }
1679
- });
1680
1683
 
1681
1684
  // src/json-loader.ts
1685
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1686
+ var DEFAULT_JSON_LOADER_OPTIONS = {
1687
+ json: {
1688
+ shape: "object-row-table",
1689
+ table: false,
1690
+ jsonpaths: []
1691
+ }
1692
+ };
1693
+ var JSONLoader = {
1694
+ name: "JSON",
1695
+ id: "json",
1696
+ module: "json",
1697
+ version: VERSION,
1698
+ extensions: ["json", "geojson"],
1699
+ mimeTypes: ["application/json"],
1700
+ category: "table",
1701
+ text: true,
1702
+ parse,
1703
+ parseTextSync,
1704
+ parseInBatches,
1705
+ options: DEFAULT_JSON_LOADER_OPTIONS
1706
+ };
1682
1707
  async function parse(arrayBuffer, options) {
1683
1708
  return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
1684
1709
  }
1685
1710
  function parseTextSync(text, options) {
1686
- const jsonOptions = { ...options, json: { ...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json } };
1711
+ const jsonOptions = {
1712
+ ...options,
1713
+ json: {
1714
+ ...DEFAULT_JSON_LOADER_OPTIONS.json,
1715
+ ...options?.json
1716
+ }
1717
+ };
1687
1718
  return parseJSONSync(text, jsonOptions);
1688
1719
  }
1689
1720
  function parseInBatches(asyncIterator, options) {
1690
- const jsonOptions = { ...options, json: { ...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json } };
1721
+ const jsonOptions = {
1722
+ ...options,
1723
+ json: {
1724
+ ...DEFAULT_JSON_LOADER_OPTIONS.json,
1725
+ ...options?.json
1726
+ }
1727
+ };
1691
1728
  return parseJSONInBatches(asyncIterator, jsonOptions);
1692
1729
  }
1693
- var VERSION, DEFAULT_JSON_LOADER_OPTIONS, JSONLoader;
1694
- var init_json_loader = __esm({
1695
- "src/json-loader.ts"() {
1696
- init_parse_json();
1697
- init_parse_json_in_batches();
1698
- VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1699
- DEFAULT_JSON_LOADER_OPTIONS = {
1700
- json: {
1701
- shape: "object-row-table",
1702
- table: false,
1703
- jsonpaths: []
1704
- }
1705
- };
1706
- JSONLoader = {
1707
- name: "JSON",
1708
- id: "json",
1709
- module: "json",
1710
- version: VERSION,
1711
- extensions: ["json", "geojson"],
1712
- mimeTypes: ["application/json"],
1713
- category: "table",
1714
- text: true,
1715
- parse,
1716
- parseTextSync,
1717
- parseInBatches,
1718
- options: DEFAULT_JSON_LOADER_OPTIONS
1719
- };
1720
- }
1721
- });
1722
1730
 
1723
1731
  // src/lib/parsers/parse-ndjson.ts
1724
1732
  function parseNDJSONSync(ndjsonText) {
@@ -1732,11 +1740,6 @@ Char: ${this.c}`;
1732
1740
  });
1733
1741
  return makeTableFromData(parsedLines);
1734
1742
  }
1735
- var init_parse_ndjson = __esm({
1736
- "src/lib/parsers/parse-ndjson.ts"() {
1737
- init_src();
1738
- }
1739
- });
1740
1743
 
1741
1744
  // src/lib/parsers/parse-ndjson-in-batches.ts
1742
1745
  async function* parseNDJSONInBatches(binaryAsyncIterator, options) {
@@ -1749,7 +1752,10 @@ Char: ${this.c}`;
1749
1752
  ...options,
1750
1753
  shape
1751
1754
  });
1752
- for await (const { counter, line } of numberedLineIterator) {
1755
+ for await (const {
1756
+ counter,
1757
+ line
1758
+ } of numberedLineIterator) {
1753
1759
  try {
1754
1760
  const row = JSON.parse(line);
1755
1761
  tableBatchBuilder.addRow(row);
@@ -1767,40 +1773,23 @@ Char: ${this.c}`;
1767
1773
  yield batch;
1768
1774
  }
1769
1775
  }
1770
- var init_parse_ndjson_in_batches = __esm({
1771
- "src/lib/parsers/parse-ndjson-in-batches.ts"() {
1772
- init_src();
1773
- init_src2();
1774
- }
1775
- });
1776
1776
 
1777
1777
  // src/ndjson-loader.ts
1778
- var VERSION2, NDJSONLoader;
1779
- var init_ndjson_loader = __esm({
1780
- "src/ndjson-loader.ts"() {
1781
- init_parse_ndjson();
1782
- init_parse_ndjson_in_batches();
1783
- VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1784
- NDJSONLoader = {
1785
- name: "NDJSON",
1786
- id: "ndjson",
1787
- module: "json",
1788
- version: VERSION2,
1789
- extensions: ["ndjson", "jsonl"],
1790
- mimeTypes: [
1791
- "application/x-ndjson",
1792
- "application/jsonlines",
1793
- "application/json-seq"
1794
- ],
1795
- category: "table",
1796
- text: true,
1797
- parse: async (arrayBuffer) => parseNDJSONSync(new TextDecoder().decode(arrayBuffer)),
1798
- parseTextSync: parseNDJSONSync,
1799
- parseInBatches: parseNDJSONInBatches,
1800
- options: {}
1801
- };
1802
- }
1803
- });
1778
+ var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1779
+ var NDJSONLoader = {
1780
+ name: "NDJSON",
1781
+ id: "ndjson",
1782
+ module: "json",
1783
+ version: VERSION2,
1784
+ extensions: ["ndjson", "jsonl"],
1785
+ mimeTypes: ["application/x-ndjson", "application/jsonlines", "application/json-seq"],
1786
+ category: "table",
1787
+ text: true,
1788
+ parse: async (arrayBuffer) => parseNDJSONSync(new TextDecoder().decode(arrayBuffer)),
1789
+ parseTextSync: parseNDJSONSync,
1790
+ parseInBatches: parseNDJSONInBatches,
1791
+ options: {}
1792
+ };
1804
1793
 
1805
1794
  // src/lib/encoders/json-encoder.ts
1806
1795
  function encodeTableAsJSON(table, options) {
@@ -1812,64 +1801,49 @@ Char: ${this.c}`;
1812
1801
  }
1813
1802
  return `[${strings.join(",")}]`;
1814
1803
  }
1815
- var init_json_encoder = __esm({
1816
- "src/lib/encoders/json-encoder.ts"() {
1817
- init_src();
1818
- }
1819
- });
1820
1804
 
1821
1805
  // src/json-writer.ts
1822
- var JSONWriter;
1823
- var init_json_writer = __esm({
1824
- "src/json-writer.ts"() {
1825
- init_json_encoder();
1826
- JSONWriter = {
1827
- id: "json",
1828
- version: "latest",
1829
- module: "json",
1830
- name: "JSON",
1831
- extensions: ["json"],
1832
- mimeTypes: ["application/json"],
1833
- options: {},
1834
- text: true,
1835
- encode: async (table, options) => new TextEncoder().encode(encodeTableAsJSON(table, options)).buffer,
1836
- encodeTextSync: (table, options) => encodeTableAsJSON(table, options)
1837
- };
1838
- }
1839
- });
1806
+ var JSONWriter = {
1807
+ id: "json",
1808
+ version: "latest",
1809
+ module: "json",
1810
+ name: "JSON",
1811
+ extensions: ["json"],
1812
+ mimeTypes: ["application/json"],
1813
+ options: {},
1814
+ text: true,
1815
+ encode: async (table, options) => new TextEncoder().encode(encodeTableAsJSON(table, options)).buffer,
1816
+ encodeTextSync: (table, options) => encodeTableAsJSON(table, options)
1817
+ };
1840
1818
 
1841
- // ../../node_modules/@math.gl/polygon/dist/esm/polygon-utils.js
1819
+ // ../../node_modules/@math.gl/polygon/dist/polygon-utils.js
1820
+ var DimIndex = {
1821
+ x: 0,
1822
+ y: 1,
1823
+ z: 2
1824
+ };
1842
1825
  function getPolygonSignedArea(points, options = {}) {
1843
1826
  const {
1844
1827
  start = 0,
1845
- end = points.length
1828
+ end = points.length,
1829
+ plane = "xy"
1846
1830
  } = options;
1847
1831
  const dim = options.size || 2;
1848
1832
  let area2 = 0;
1833
+ const i0 = DimIndex[plane[0]];
1834
+ const i1 = DimIndex[plane[1]];
1849
1835
  for (let i = start, j = end - dim; i < end; i += dim) {
1850
- area2 += (points[i] - points[j]) * (points[i + 1] + points[j + 1]);
1836
+ area2 += (points[i + i0] - points[j + i0]) * (points[i + i1] + points[j + i1]);
1851
1837
  j = i;
1852
1838
  }
1853
1839
  return area2 / 2;
1854
1840
  }
1855
- var init_polygon_utils = __esm({
1856
- "../../node_modules/@math.gl/polygon/dist/esm/polygon-utils.js"() {
1857
- }
1858
- });
1859
1841
 
1860
- // ../../node_modules/@math.gl/polygon/dist/esm/polygon.js
1861
- var init_polygon = __esm({
1862
- "../../node_modules/@math.gl/polygon/dist/esm/polygon.js"() {
1863
- init_defineProperty();
1864
- init_polygon_utils();
1865
- }
1866
- });
1867
-
1868
- // ../../node_modules/@math.gl/polygon/dist/esm/earcut.js
1869
- function earcut(positions, holeIndices, dim = 2, areas) {
1842
+ // ../../node_modules/@math.gl/polygon/dist/earcut.js
1843
+ function earcut(positions, holeIndices, dim = 2, areas, plane = "xy") {
1870
1844
  const hasHoles = holeIndices && holeIndices.length;
1871
1845
  const outerLen = hasHoles ? holeIndices[0] * dim : positions.length;
1872
- let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0]);
1846
+ let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0], plane);
1873
1847
  const triangles = [];
1874
1848
  if (!outerNode || outerNode.next === outerNode.prev)
1875
1849
  return triangles;
@@ -1881,7 +1855,7 @@ Char: ${this.c}`;
1881
1855
  let x;
1882
1856
  let y;
1883
1857
  if (hasHoles)
1884
- outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas);
1858
+ outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
1885
1859
  if (positions.length > 80 * dim) {
1886
1860
  minX = maxX = positions[0];
1887
1861
  minY = maxY = positions[1];
@@ -1898,27 +1872,30 @@ Char: ${this.c}`;
1898
1872
  maxY = y;
1899
1873
  }
1900
1874
  invSize = Math.max(maxX - minX, maxY - minY);
1901
- invSize = invSize !== 0 ? 1 / invSize : 0;
1875
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
1902
1876
  }
1903
- earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
1877
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
1904
1878
  return triangles;
1905
1879
  }
1906
- function linkedList(data, start, end, dim, clockwise, area2) {
1880
+ function linkedList(data, start, end, dim, clockwise, area2, plane) {
1907
1881
  let i;
1908
1882
  let last;
1909
1883
  if (area2 === void 0) {
1910
1884
  area2 = getPolygonSignedArea(data, {
1911
1885
  start,
1912
1886
  end,
1913
- size: dim
1887
+ size: dim,
1888
+ plane
1914
1889
  });
1915
1890
  }
1891
+ let i0 = DimIndex[plane[0]];
1892
+ let i1 = DimIndex[plane[1]];
1916
1893
  if (clockwise === area2 < 0) {
1917
1894
  for (i = start; i < end; i += dim)
1918
- last = insertNode(i, data[i], data[i + 1], last);
1895
+ last = insertNode(i, data[i + i0], data[i + i1], last);
1919
1896
  } else {
1920
1897
  for (i = end - dim; i >= start; i -= dim)
1921
- last = insertNode(i, data[i], data[i + 1], last);
1898
+ last = insertNode(i, data[i + i0], data[i + i1], last);
1922
1899
  }
1923
1900
  if (last && equals(last, last.next)) {
1924
1901
  removeNode(last);
@@ -1959,9 +1936,9 @@ Char: ${this.c}`;
1959
1936
  prev = ear.prev;
1960
1937
  next = ear.next;
1961
1938
  if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
1962
- triangles.push(prev.i / dim);
1963
- triangles.push(ear.i / dim);
1964
- triangles.push(next.i / dim);
1939
+ triangles.push(prev.i / dim | 0);
1940
+ triangles.push(ear.i / dim | 0);
1941
+ triangles.push(next.i / dim | 0);
1965
1942
  removeNode(ear);
1966
1943
  ear = next.next;
1967
1944
  stop = next.next;
@@ -1987,9 +1964,19 @@ Char: ${this.c}`;
1987
1964
  const c = ear.next;
1988
1965
  if (area(a, b, c) >= 0)
1989
1966
  return false;
1990
- let p = ear.next.next;
1991
- while (p !== ear.prev) {
1992
- if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
1967
+ const ax = a.x;
1968
+ const bx = b.x;
1969
+ const cx = c.x;
1970
+ const ay = a.y;
1971
+ const by = b.y;
1972
+ const cy = c.y;
1973
+ const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx;
1974
+ const y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy;
1975
+ const x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx;
1976
+ const y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
1977
+ let p = c.next;
1978
+ while (p !== a) {
1979
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
1993
1980
  return false;
1994
1981
  p = p.next;
1995
1982
  }
@@ -2001,29 +1988,35 @@ Char: ${this.c}`;
2001
1988
  const c = ear.next;
2002
1989
  if (area(a, b, c) >= 0)
2003
1990
  return false;
2004
- const minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x;
2005
- const minTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y;
2006
- const maxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x;
2007
- const maxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y;
2008
- const minZ = zOrder(minTX, minTY, minX, minY, invSize);
2009
- const maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
1991
+ const ax = a.x;
1992
+ const bx = b.x;
1993
+ const cx = c.x;
1994
+ const ay = a.y;
1995
+ const by = b.y;
1996
+ const cy = c.y;
1997
+ const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx;
1998
+ const y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy;
1999
+ const x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx;
2000
+ const y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
2001
+ const minZ = zOrder(x0, y0, minX, minY, invSize);
2002
+ const maxZ = zOrder(x1, y1, minX, minY, invSize);
2010
2003
  let p = ear.prevZ;
2011
2004
  let n = ear.nextZ;
2012
2005
  while (p && p.z >= minZ && n && n.z <= maxZ) {
2013
- if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
2006
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
2014
2007
  return false;
2015
2008
  p = p.prevZ;
2016
- if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0)
2009
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
2017
2010
  return false;
2018
2011
  n = n.nextZ;
2019
2012
  }
2020
2013
  while (p && p.z >= minZ) {
2021
- if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
2014
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
2022
2015
  return false;
2023
2016
  p = p.prevZ;
2024
2017
  }
2025
2018
  while (n && n.z <= maxZ) {
2026
- if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0)
2019
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
2027
2020
  return false;
2028
2021
  n = n.nextZ;
2029
2022
  }
@@ -2035,9 +2028,9 @@ Char: ${this.c}`;
2035
2028
  const a = p.prev;
2036
2029
  const b = p.next.next;
2037
2030
  if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
2038
- triangles.push(a.i / dim);
2039
- triangles.push(p.i / dim);
2040
- triangles.push(b.i / dim);
2031
+ triangles.push(a.i / dim | 0);
2032
+ triangles.push(p.i / dim | 0);
2033
+ triangles.push(b.i / dim | 0);
2041
2034
  removeNode(p);
2042
2035
  removeNode(p.next);
2043
2036
  p = start = b;
@@ -2055,8 +2048,8 @@ Char: ${this.c}`;
2055
2048
  let c = splitPolygon(a, b);
2056
2049
  a = filterPoints(a, a.next);
2057
2050
  c = filterPoints(c, c.next);
2058
- earcutLinked(a, triangles, dim, minX, minY, invSize);
2059
- earcutLinked(c, triangles, dim, minX, minY, invSize);
2051
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
2052
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
2060
2053
  return;
2061
2054
  }
2062
2055
  b = b.next;
@@ -2064,7 +2057,7 @@ Char: ${this.c}`;
2064
2057
  a = a.next;
2065
2058
  } while (a !== start);
2066
2059
  }
2067
- function eliminateHoles(data, holeIndices, outerNode, dim, areas) {
2060
+ function eliminateHoles(data, holeIndices, outerNode, dim, areas, plane) {
2068
2061
  const queue = [];
2069
2062
  let i;
2070
2063
  let len;
@@ -2074,15 +2067,14 @@ Char: ${this.c}`;
2074
2067
  for (i = 0, len = holeIndices.length; i < len; i++) {
2075
2068
  start = holeIndices[i] * dim;
2076
2069
  end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
2077
- list = linkedList(data, start, end, dim, false, areas && areas[i + 1]);
2070
+ list = linkedList(data, start, end, dim, false, areas && areas[i + 1], plane);
2078
2071
  if (list === list.next)
2079
2072
  list.steiner = true;
2080
2073
  queue.push(getLeftmost(list));
2081
2074
  }
2082
2075
  queue.sort(compareX);
2083
2076
  for (i = 0; i < queue.length; i++) {
2084
- eliminateHole(queue[i], outerNode);
2085
- outerNode = filterPoints(outerNode, outerNode.next);
2077
+ outerNode = eliminateHole(queue[i], outerNode);
2086
2078
  }
2087
2079
  return outerNode;
2088
2080
  }
@@ -2090,12 +2082,13 @@ Char: ${this.c}`;
2090
2082
  return a.x - b.x;
2091
2083
  }
2092
2084
  function eliminateHole(hole, outerNode) {
2093
- outerNode = findHoleBridge(hole, outerNode);
2094
- if (outerNode) {
2095
- const b = splitPolygon(outerNode, hole);
2096
- filterPoints(outerNode, outerNode.next);
2097
- filterPoints(b, b.next);
2085
+ const bridge = findHoleBridge(hole, outerNode);
2086
+ if (!bridge) {
2087
+ return outerNode;
2098
2088
  }
2089
+ const bridgeReverse = splitPolygon(bridge, hole);
2090
+ filterPoints(bridgeReverse, bridgeReverse.next);
2091
+ return filterPoints(bridge, bridge.next);
2099
2092
  }
2100
2093
  function findHoleBridge(hole, outerNode) {
2101
2094
  let p = outerNode;
@@ -2108,21 +2101,15 @@ Char: ${this.c}`;
2108
2101
  const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
2109
2102
  if (x <= hx && x > qx) {
2110
2103
  qx = x;
2111
- if (x === hx) {
2112
- if (hy === p.y)
2113
- return p;
2114
- if (hy === p.next.y)
2115
- return p.next;
2116
- }
2117
2104
  m = p.x < p.next.x ? p : p.next;
2105
+ if (x === hx)
2106
+ return m;
2118
2107
  }
2119
2108
  }
2120
2109
  p = p.next;
2121
2110
  } while (p !== outerNode);
2122
2111
  if (!m)
2123
2112
  return null;
2124
- if (hx === qx)
2125
- return m;
2126
2113
  const stop = m;
2127
2114
  const mx = m.x;
2128
2115
  const my = m.y;
@@ -2147,7 +2134,7 @@ Char: ${this.c}`;
2147
2134
  function indexCurve(start, minX, minY, invSize) {
2148
2135
  let p = start;
2149
2136
  do {
2150
- if (p.z === null)
2137
+ if (p.z === 0)
2151
2138
  p.z = zOrder(p.x, p.y, minX, minY, invSize);
2152
2139
  p.prevZ = p.prev;
2153
2140
  p.nextZ = p.next;
@@ -2208,8 +2195,8 @@ Char: ${this.c}`;
2208
2195
  return list;
2209
2196
  }
2210
2197
  function zOrder(x, y, minX, minY, invSize) {
2211
- x = 32767 * (x - minX) * invSize;
2212
- y = 32767 * (y - minY) * invSize;
2198
+ x = (x - minX) * invSize | 0;
2199
+ y = (y - minY) * invSize | 0;
2213
2200
  x = (x | x << 8) & 16711935;
2214
2201
  x = (x | x << 4) & 252645135;
2215
2202
  x = (x | x << 2) & 858993459;
@@ -2231,7 +2218,7 @@ Char: ${this.c}`;
2231
2218
  return leftmost;
2232
2219
  }
2233
2220
  function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
2234
- return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
2221
+ return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
2235
2222
  }
2236
2223
  function isValidDiagonal(a, b) {
2237
2224
  return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
@@ -2290,8 +2277,8 @@ Char: ${this.c}`;
2290
2277
  return inside;
2291
2278
  }
2292
2279
  function splitPolygon(a, b) {
2293
- const a2 = new Node(a.i, a.x, a.y);
2294
- const b2 = new Node(b.i, b.x, b.y);
2280
+ const a2 = new Vertex(a.i, a.x, a.y);
2281
+ const b2 = new Vertex(b.i, b.x, b.y);
2295
2282
  const an = a.next;
2296
2283
  const bp = b.prev;
2297
2284
  a.next = b;
@@ -2305,7 +2292,7 @@ Char: ${this.c}`;
2305
2292
  return b2;
2306
2293
  }
2307
2294
  function insertNode(i, x, y, last) {
2308
- const p = new Node(i, x, y);
2295
+ const p = new Vertex(i, x, y);
2309
2296
  if (!last) {
2310
2297
  p.prev = p;
2311
2298
  p.next = p;
@@ -2325,64 +2312,22 @@ Char: ${this.c}`;
2325
2312
  if (p.nextZ)
2326
2313
  p.nextZ.prevZ = p.prevZ;
2327
2314
  }
2328
- function Node(i, x, y) {
2329
- this.i = i;
2330
- this.x = x;
2331
- this.y = y;
2332
- this.prev = null;
2333
- this.next = null;
2334
- this.z = null;
2335
- this.prevZ = null;
2336
- this.nextZ = null;
2337
- this.steiner = false;
2338
- }
2339
- var init_earcut = __esm({
2340
- "../../node_modules/@math.gl/polygon/dist/esm/earcut.js"() {
2341
- init_polygon_utils();
2342
- }
2343
- });
2344
-
2345
- // ../../node_modules/@math.gl/polygon/dist/esm/utils.js
2346
- var init_utils = __esm({
2347
- "../../node_modules/@math.gl/polygon/dist/esm/utils.js"() {
2348
- }
2349
- });
2350
-
2351
- // ../../node_modules/@math.gl/polygon/dist/esm/lineclip.js
2352
- var init_lineclip = __esm({
2353
- "../../node_modules/@math.gl/polygon/dist/esm/lineclip.js"() {
2354
- init_utils();
2355
- }
2356
- });
2357
-
2358
- // ../../node_modules/@math.gl/polygon/dist/esm/cut-by-grid.js
2359
- var init_cut_by_grid = __esm({
2360
- "../../node_modules/@math.gl/polygon/dist/esm/cut-by-grid.js"() {
2361
- init_lineclip();
2362
- init_utils();
2363
- }
2364
- });
2365
-
2366
- // ../../node_modules/@math.gl/polygon/dist/esm/cut-by-mercator-bounds.js
2367
- var init_cut_by_mercator_bounds = __esm({
2368
- "../../node_modules/@math.gl/polygon/dist/esm/cut-by-mercator-bounds.js"() {
2369
- init_cut_by_grid();
2370
- init_utils();
2315
+ var Vertex = class {
2316
+ constructor(i, x, y) {
2317
+ _defineProperty(this, "i", void 0);
2318
+ _defineProperty(this, "x", void 0);
2319
+ _defineProperty(this, "y", void 0);
2320
+ _defineProperty(this, "prev", null);
2321
+ _defineProperty(this, "next", null);
2322
+ _defineProperty(this, "z", 0);
2323
+ _defineProperty(this, "prevZ", null);
2324
+ _defineProperty(this, "nextZ", null);
2325
+ _defineProperty(this, "steiner", false);
2326
+ this.i = i;
2327
+ this.x = x;
2328
+ this.y = y;
2371
2329
  }
2372
- });
2373
-
2374
- // ../../node_modules/@math.gl/polygon/dist/esm/index.js
2375
- var init_esm = __esm({
2376
- "../../node_modules/@math.gl/polygon/dist/esm/index.js"() {
2377
- init_polygon();
2378
- init_polygon_utils();
2379
- init_earcut();
2380
- init_lineclip();
2381
- init_cut_by_grid();
2382
- init_cut_by_mercator_bounds();
2383
- init_polygon();
2384
- }
2385
- });
2330
+ };
2386
2331
 
2387
2332
  // ../gis/src/lib/flat-geojson-to-binary.ts
2388
2333
  function flatGeojsonToBinary(features, geometryInfo, options) {
@@ -2423,7 +2368,11 @@ Char: ${this.c}`;
2423
2368
  propArrayTypes,
2424
2369
  coordLength
2425
2370
  } = geometryInfo;
2426
- const { numericPropKeys = [], PositionDataType = Float32Array, triangulate = true } = options;
2371
+ const {
2372
+ numericPropKeys = [],
2373
+ PositionDataType = Float32Array,
2374
+ triangulate = true
2375
+ } = options;
2427
2376
  const hasGlobalId = features[0] && "id" in features[0];
2428
2377
  const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
2429
2378
  const points = {
@@ -2488,7 +2437,9 @@ Char: ${this.c}`;
2488
2437
  handlePoint(geometry, points, indexMap, coordLength, properties);
2489
2438
  points.properties.push(keepStringProperties(properties, numericPropKeys));
2490
2439
  if (hasGlobalId) {
2491
- points.fields.push({ id: feature.id });
2440
+ points.fields.push({
2441
+ id: feature.id
2442
+ });
2492
2443
  }
2493
2444
  indexMap.pointFeature++;
2494
2445
  break;
@@ -2496,7 +2447,9 @@ Char: ${this.c}`;
2496
2447
  handleLineString(geometry, lines, indexMap, coordLength, properties);
2497
2448
  lines.properties.push(keepStringProperties(properties, numericPropKeys));
2498
2449
  if (hasGlobalId) {
2499
- lines.fields.push({ id: feature.id });
2450
+ lines.fields.push({
2451
+ id: feature.id
2452
+ });
2500
2453
  }
2501
2454
  indexMap.lineFeature++;
2502
2455
  break;
@@ -2504,7 +2457,9 @@ Char: ${this.c}`;
2504
2457
  handlePolygon(geometry, polygons, indexMap, coordLength, properties);
2505
2458
  polygons.properties.push(keepStringProperties(properties, numericPropKeys));
2506
2459
  if (hasGlobalId) {
2507
- polygons.fields.push({ id: feature.id });
2460
+ polygons.fields.push({
2461
+ id: feature.id
2462
+ });
2508
2463
  }
2509
2464
  indexMap.polygonFeature++;
2510
2465
  break;
@@ -2555,7 +2510,11 @@ Char: ${this.c}`;
2555
2510
  indexMap.polygonPosition += (end - start) / coordLength;
2556
2511
  }
2557
2512
  const endPosition = indexMap.polygonPosition;
2558
- triangulatePolygon(polygons, areas, indices, { startPosition, endPosition, coordLength });
2513
+ triangulatePolygon(polygons, areas, indices, {
2514
+ startPosition,
2515
+ endPosition,
2516
+ coordLength
2517
+ });
2559
2518
  }
2560
2519
  }
2561
2520
  function triangulatePolygon(polygons, areas, indices, {
@@ -2579,7 +2538,10 @@ Char: ${this.c}`;
2579
2538
  function wrapProps(obj, size) {
2580
2539
  const returnObj = {};
2581
2540
  for (const key in obj) {
2582
- returnObj[key] = { value: obj[key], size };
2541
+ returnObj[key] = {
2542
+ value: obj[key],
2543
+ size
2544
+ };
2583
2545
  }
2584
2546
  return returnObj;
2585
2547
  }
@@ -2587,31 +2549,70 @@ Char: ${this.c}`;
2587
2549
  const binaryFeatures = {
2588
2550
  points: {
2589
2551
  ...points,
2590
- positions: { value: points.positions, size: coordLength },
2591
- globalFeatureIds: { value: points.globalFeatureIds, size: 1 },
2592
- featureIds: { value: points.featureIds, size: 1 },
2552
+ positions: {
2553
+ value: points.positions,
2554
+ size: coordLength
2555
+ },
2556
+ globalFeatureIds: {
2557
+ value: points.globalFeatureIds,
2558
+ size: 1
2559
+ },
2560
+ featureIds: {
2561
+ value: points.featureIds,
2562
+ size: 1
2563
+ },
2593
2564
  numericProps: wrapProps(points.numericProps, 1)
2594
2565
  },
2595
2566
  lines: {
2596
2567
  ...lines,
2597
- positions: { value: lines.positions, size: coordLength },
2598
- pathIndices: { value: lines.pathIndices, size: 1 },
2599
- globalFeatureIds: { value: lines.globalFeatureIds, size: 1 },
2600
- featureIds: { value: lines.featureIds, size: 1 },
2568
+ positions: {
2569
+ value: lines.positions,
2570
+ size: coordLength
2571
+ },
2572
+ pathIndices: {
2573
+ value: lines.pathIndices,
2574
+ size: 1
2575
+ },
2576
+ globalFeatureIds: {
2577
+ value: lines.globalFeatureIds,
2578
+ size: 1
2579
+ },
2580
+ featureIds: {
2581
+ value: lines.featureIds,
2582
+ size: 1
2583
+ },
2601
2584
  numericProps: wrapProps(lines.numericProps, 1)
2602
2585
  },
2603
2586
  polygons: {
2604
2587
  ...polygons,
2605
- positions: { value: polygons.positions, size: coordLength },
2606
- polygonIndices: { value: polygons.polygonIndices, size: 1 },
2607
- primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 },
2608
- globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 },
2609
- featureIds: { value: polygons.featureIds, size: 1 },
2588
+ positions: {
2589
+ value: polygons.positions,
2590
+ size: coordLength
2591
+ },
2592
+ polygonIndices: {
2593
+ value: polygons.polygonIndices,
2594
+ size: 1
2595
+ },
2596
+ primitivePolygonIndices: {
2597
+ value: polygons.primitivePolygonIndices,
2598
+ size: 1
2599
+ },
2600
+ globalFeatureIds: {
2601
+ value: polygons.globalFeatureIds,
2602
+ size: 1
2603
+ },
2604
+ featureIds: {
2605
+ value: polygons.featureIds,
2606
+ size: 1
2607
+ },
2610
2608
  numericProps: wrapProps(polygons.numericProps, 1)
2611
2609
  }
2612
2610
  };
2613
2611
  if (binaryFeatures.polygons && polygons.triangles) {
2614
- binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
2612
+ binaryFeatures.polygons.triangles = {
2613
+ value: new Uint32Array(polygons.triangles),
2614
+ size: 1
2615
+ };
2615
2616
  }
2616
2617
  return binaryFeatures;
2617
2618
  }
@@ -2638,11 +2639,6 @@ Char: ${this.c}`;
2638
2639
  }
2639
2640
  return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;
2640
2641
  }
2641
- var init_flat_geojson_to_binary = __esm({
2642
- "../gis/src/lib/flat-geojson-to-binary.ts"() {
2643
- init_esm();
2644
- }
2645
- });
2646
2642
 
2647
2643
  // ../gis/src/lib/extract-geometry-info.ts
2648
2644
  function extractGeometryInfo(features) {
@@ -2655,7 +2651,7 @@ Char: ${this.c}`;
2655
2651
  let polygonObjectsCount = 0;
2656
2652
  let polygonRingsCount = 0;
2657
2653
  let polygonFeaturesCount = 0;
2658
- const coordLengths = new Set();
2654
+ const coordLengths = /* @__PURE__ */ new Set();
2659
2655
  for (const feature of features) {
2660
2656
  const geometry = feature.geometry;
2661
2657
  switch (geometry.type) {
@@ -2728,13 +2724,12 @@ Char: ${this.c}`;
2728
2724
  polygonFeaturesCount
2729
2725
  };
2730
2726
  }
2731
- var init_extract_geometry_info = __esm({
2732
- "../gis/src/lib/extract-geometry-info.ts"() {
2733
- }
2734
- });
2735
2727
 
2736
2728
  // ../gis/src/lib/geojson-to-flat-geojson.ts
2737
- function geojsonToFlatGeojson(features, options = { coordLength: 2, fixRingWinding: true }) {
2729
+ function geojsonToFlatGeojson(features, options = {
2730
+ coordLength: 2,
2731
+ fixRingWinding: true
2732
+ }) {
2738
2733
  return features.map((feature) => flattenFeature(feature, options));
2739
2734
  }
2740
2735
  function flattenPoint(coordinates, data, indices, options) {
@@ -2775,7 +2770,9 @@ Char: ${this.c}`;
2775
2770
  }
2776
2771
  }
2777
2772
  function flattenFeature(feature, options) {
2778
- const { geometry } = feature;
2773
+ const {
2774
+ geometry
2775
+ } = feature;
2779
2776
  if (geometry.type === "GeometryCollection") {
2780
2777
  throw new Error("GeometryCollection type not supported");
2781
2778
  }
@@ -2813,48 +2810,81 @@ Char: ${this.c}`;
2813
2810
  default:
2814
2811
  throw new Error(`Unknown type: ${type}`);
2815
2812
  }
2816
- return { ...feature, geometry: { type, indices, data, areas } };
2813
+ return {
2814
+ ...feature,
2815
+ geometry: {
2816
+ type,
2817
+ indices,
2818
+ data,
2819
+ areas
2820
+ }
2821
+ };
2817
2822
  }
2818
- var init_geojson_to_flat_geojson = __esm({
2819
- "../gis/src/lib/geojson-to-flat-geojson.ts"() {
2820
- init_esm();
2821
- }
2822
- });
2823
2823
 
2824
2824
  // ../gis/src/lib/geojson-to-binary.ts
2825
- function geojsonToBinary(features, options = { fixRingWinding: true, triangulate: true }) {
2825
+ function geojsonToBinary(features, options = {
2826
+ fixRingWinding: true,
2827
+ triangulate: true
2828
+ }) {
2826
2829
  const geometryInfo = extractGeometryInfo(features);
2827
2830
  const coordLength = geometryInfo.coordLength;
2828
- const { fixRingWinding } = options;
2829
- const flatFeatures = geojsonToFlatGeojson(features, { coordLength, fixRingWinding });
2831
+ const {
2832
+ fixRingWinding
2833
+ } = options;
2834
+ const flatFeatures = geojsonToFlatGeojson(features, {
2835
+ coordLength,
2836
+ fixRingWinding
2837
+ });
2830
2838
  return flatGeojsonToBinary(flatFeatures, geometryInfo, {
2831
2839
  numericPropKeys: options.numericPropKeys,
2832
2840
  PositionDataType: options.PositionDataType || Float32Array,
2833
2841
  triangulate: options.triangulate
2834
2842
  });
2835
2843
  }
2836
- var init_geojson_to_binary = __esm({
2837
- "../gis/src/lib/geojson-to-binary.ts"() {
2838
- init_extract_geometry_info();
2839
- init_geojson_to_flat_geojson();
2840
- init_flat_geojson_to_binary();
2841
- }
2842
- });
2843
-
2844
- // ../gis/src/index.ts
2845
- var init_src3 = __esm({
2846
- "../gis/src/index.ts"() {
2847
- init_geojson_to_binary();
2848
- }
2849
- });
2850
2844
 
2851
2845
  // src/geojson-loader.ts
2846
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2847
+ var GeoJSONWorkerLoader = {
2848
+ name: "GeoJSON",
2849
+ id: "geojson",
2850
+ module: "geojson",
2851
+ version: VERSION3,
2852
+ worker: true,
2853
+ extensions: ["geojson"],
2854
+ mimeTypes: ["application/geo+json"],
2855
+ category: "geometry",
2856
+ text: true,
2857
+ options: {
2858
+ geojson: {
2859
+ shape: "object-row-table"
2860
+ },
2861
+ json: {
2862
+ shape: "object-row-table",
2863
+ jsonpaths: ["$", "$.features"]
2864
+ },
2865
+ gis: {
2866
+ format: "geojson"
2867
+ }
2868
+ }
2869
+ };
2870
+ var GeoJSONLoader = {
2871
+ ...GeoJSONWorkerLoader,
2872
+ parse: parse2,
2873
+ parseTextSync: parseTextSync2,
2874
+ parseInBatches: parseInBatches2
2875
+ };
2852
2876
  async function parse2(arrayBuffer, options) {
2853
2877
  return parseTextSync2(new TextDecoder().decode(arrayBuffer), options);
2854
2878
  }
2855
2879
  function parseTextSync2(text, options) {
2856
- options = { ...GeoJSONLoader.options, ...options };
2857
- options.geojson = { ...GeoJSONLoader.options.geojson, ...options.geojson };
2880
+ options = {
2881
+ ...GeoJSONLoader.options,
2882
+ ...options
2883
+ };
2884
+ options.geojson = {
2885
+ ...GeoJSONLoader.options.geojson,
2886
+ ...options.geojson
2887
+ };
2858
2888
  options.gis = options.gis || {};
2859
2889
  let geojson;
2860
2890
  try {
@@ -2875,8 +2905,14 @@ Char: ${this.c}`;
2875
2905
  }
2876
2906
  }
2877
2907
  function parseInBatches2(asyncIterator, options) {
2878
- options = { ...GeoJSONLoader.options, ...options };
2879
- options.json = { ...GeoJSONLoader.options.geojson, ...options.geojson };
2908
+ options = {
2909
+ ...GeoJSONLoader.options,
2910
+ ...options
2911
+ };
2912
+ options.json = {
2913
+ ...GeoJSONLoader.options.geojson,
2914
+ ...options.geojson
2915
+ };
2880
2916
  const geojsonIterator = parseJSONInBatches(asyncIterator, options);
2881
2917
  switch (options.gis.format) {
2882
2918
  case "binary":
@@ -2891,43 +2927,6 @@ Char: ${this.c}`;
2891
2927
  yield batch;
2892
2928
  }
2893
2929
  }
2894
- var VERSION3, GeoJSONWorkerLoader, GeoJSONLoader;
2895
- var init_geojson_loader = __esm({
2896
- "src/geojson-loader.ts"() {
2897
- init_src3();
2898
- init_parse_json_in_batches();
2899
- VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2900
- GeoJSONWorkerLoader = {
2901
- name: "GeoJSON",
2902
- id: "geojson",
2903
- module: "geojson",
2904
- version: VERSION3,
2905
- worker: true,
2906
- extensions: ["geojson"],
2907
- mimeTypes: ["application/geo+json"],
2908
- category: "geometry",
2909
- text: true,
2910
- options: {
2911
- geojson: {
2912
- shape: "object-row-table"
2913
- },
2914
- json: {
2915
- shape: "object-row-table",
2916
- jsonpaths: ["$", "$.features"]
2917
- },
2918
- gis: {
2919
- format: "geojson"
2920
- }
2921
- }
2922
- };
2923
- GeoJSONLoader = {
2924
- ...GeoJSONWorkerLoader,
2925
- parse: parse2,
2926
- parseTextSync: parseTextSync2,
2927
- parseInBatches: parseInBatches2
2928
- };
2929
- }
2930
- });
2931
2930
 
2932
2931
  // src/lib/encoder-utils/encode-utils.ts
2933
2932
  function detectGeometryColumnIndex(table) {
@@ -2956,11 +2955,6 @@ Char: ${this.c}`;
2956
2955
  }
2957
2956
  return properties;
2958
2957
  }
2959
- var init_encode_utils = __esm({
2960
- "src/lib/encoder-utils/encode-utils.ts"() {
2961
- init_src();
2962
- }
2963
- });
2964
2958
 
2965
2959
  // src/lib/encoder-utils/encode-table-row.ts
2966
2960
  function encodeTableRow(table, rowIndex, geometryColumnIndex, utf8Encoder) {
@@ -2976,7 +2970,11 @@ Char: ${this.c}`;
2976
2970
  const columnName = table.schema?.fields[geometryColumnIndex].name;
2977
2971
  let featureOrGeometry = columnName && row[columnName];
2978
2972
  if (!featureOrGeometry) {
2979
- return { type: "Feature", geometry: null, properties };
2973
+ return {
2974
+ type: "Feature",
2975
+ geometry: null,
2976
+ properties
2977
+ };
2980
2978
  }
2981
2979
  if (typeof featureOrGeometry === "string") {
2982
2980
  try {
@@ -2989,53 +2987,53 @@ Char: ${this.c}`;
2989
2987
  throw new Error("invalid geometry column value");
2990
2988
  }
2991
2989
  if (featureOrGeometry?.type === "Feature") {
2992
- return { ...featureOrGeometry, properties };
2990
+ return {
2991
+ ...featureOrGeometry,
2992
+ properties
2993
+ };
2993
2994
  }
2994
- return { type: "Feature", geometry: featureOrGeometry, properties };
2995
+ return {
2996
+ type: "Feature",
2997
+ geometry: featureOrGeometry,
2998
+ properties
2999
+ };
2995
3000
  }
2996
- var init_encode_table_row = __esm({
2997
- "src/lib/encoder-utils/encode-table-row.ts"() {
2998
- init_src();
2999
- init_encode_utils();
3000
- }
3001
- });
3002
3001
 
3003
3002
  // src/lib/encoder-utils/utf8-encoder.ts
3004
- var Utf8ArrayBufferEncoder;
3005
- var init_utf8_encoder = __esm({
3006
- "src/lib/encoder-utils/utf8-encoder.ts"() {
3007
- Utf8ArrayBufferEncoder = class {
3008
- constructor(chunkSize) {
3009
- this.strings = [];
3010
- this.totalLength = 0;
3011
- this.textEncoder = new TextEncoder();
3012
- this.chunkSize = chunkSize;
3013
- }
3014
- push(...strings) {
3015
- for (const string of strings) {
3016
- this.strings.push(string);
3017
- this.totalLength += string.length;
3018
- }
3019
- }
3020
- isFull() {
3021
- return this.totalLength >= this.chunkSize;
3022
- }
3023
- getArrayBufferBatch() {
3024
- return this.textEncoder.encode(this.getStringBatch()).buffer;
3025
- }
3026
- getStringBatch() {
3027
- const stringChunk = this.strings.join("");
3028
- this.strings = [];
3029
- this.totalLength = 0;
3030
- return stringChunk;
3031
- }
3032
- };
3003
+ var Utf8ArrayBufferEncoder = class {
3004
+ strings = [];
3005
+ totalLength = 0;
3006
+ textEncoder = new TextEncoder();
3007
+ constructor(chunkSize) {
3008
+ this.chunkSize = chunkSize;
3009
+ }
3010
+ push(...strings) {
3011
+ for (const string of strings) {
3012
+ this.strings.push(string);
3013
+ this.totalLength += string.length;
3014
+ }
3033
3015
  }
3034
- });
3016
+ isFull() {
3017
+ return this.totalLength >= this.chunkSize;
3018
+ }
3019
+ getArrayBufferBatch() {
3020
+ return this.textEncoder.encode(this.getStringBatch()).buffer;
3021
+ }
3022
+ getStringBatch() {
3023
+ const stringChunk = this.strings.join("");
3024
+ this.strings = [];
3025
+ this.totalLength = 0;
3026
+ return stringChunk;
3027
+ }
3028
+ };
3035
3029
 
3036
3030
  // src/lib/encoders/geojson-encoder.ts
3037
3031
  async function* encodeTableAsGeojsonInBatches(batchIterator, inputOpts = {}) {
3038
- const options = { geojson: {}, chunkSize: 1e4, ...inputOpts };
3032
+ const options = {
3033
+ geojson: {},
3034
+ chunkSize: 1e4,
3035
+ ...inputOpts
3036
+ };
3039
3037
  const utf8Encoder = new Utf8ArrayBufferEncoder(options.chunkSize);
3040
3038
  if (!options.geojson.featureArray) {
3041
3039
  utf8Encoder.push("{\n", '"type": "FeatureCollection",\n', '"features":\n');
@@ -3073,72 +3071,25 @@ Char: ${this.c}`;
3073
3071
  }
3074
3072
  yield utf8Encoder.getArrayBufferBatch();
3075
3073
  }
3076
- var init_geojson_encoder = __esm({
3077
- "src/lib/encoders/geojson-encoder.ts"() {
3078
- init_src();
3079
- init_encode_utils();
3080
- init_encode_table_row();
3081
- init_utf8_encoder();
3082
- }
3083
- });
3084
3074
 
3085
3075
  // src/geojson-writer.ts
3086
- var GeoJSONWriter;
3087
- var init_geojson_writer = __esm({
3088
- "src/geojson-writer.ts"() {
3089
- init_geojson_encoder();
3090
- GeoJSONWriter = {
3091
- id: "geojson",
3092
- version: "latest",
3093
- module: "geojson",
3094
- name: "GeoJSON",
3095
- extensions: ["geojson"],
3096
- mimeTypes: ["application/geo+json"],
3097
- options: {
3098
- geojson: {
3099
- featureArray: false,
3100
- geometryColumn: null
3101
- }
3102
- },
3103
- text: true,
3104
- encodeInBatches: (tableIterator, options) => encodeTableAsGeojsonInBatches(tableIterator, options)
3105
- };
3106
- }
3107
- });
3108
-
3109
- // src/index.ts
3110
- var src_exports = {};
3111
- __export(src_exports, {
3112
- JSONLoader: () => JSONLoader,
3113
- JSONWriter: () => JSONWriter,
3114
- NDJSONLoader: () => NDJSONLoader,
3115
- _ClarinetParser: () => ClarinetParser,
3116
- _GeoJSONLoader: () => GeoJSONLoader,
3117
- _GeoJSONWorkerLoader: () => GeoJSONWorkerLoader,
3118
- _GeoJSONWriter: () => GeoJSONWriter,
3119
- _JSONPath: () => JSONPath,
3120
- _rebuildJsonObject: () => rebuildJsonObject
3121
- });
3122
- var init_src4 = __esm({
3123
- "src/index.ts"() {
3124
- init_json_loader();
3125
- init_ndjson_loader();
3126
- init_json_writer();
3127
- init_geojson_loader();
3128
- init_geojson_writer();
3129
- init_jsonpath();
3130
- init_clarinet();
3131
- init_parse_json_in_batches();
3132
- }
3133
- });
3134
-
3135
- // src/bundle.ts
3136
- var require_bundle = __commonJS({
3137
- "src/bundle.ts"(exports, module) {
3138
- var moduleExports = (init_src4(), src_exports);
3139
- globalThis.loaders = globalThis.loaders || {};
3140
- module.exports = Object.assign(globalThis.loaders, moduleExports);
3141
- }
3142
- });
3143
- require_bundle();
3076
+ var GeoJSONWriter = {
3077
+ id: "geojson",
3078
+ version: "latest",
3079
+ module: "geojson",
3080
+ name: "GeoJSON",
3081
+ extensions: ["geojson"],
3082
+ mimeTypes: ["application/geo+json"],
3083
+ options: {
3084
+ geojson: {
3085
+ featureArray: false,
3086
+ geometryColumn: null
3087
+ }
3088
+ },
3089
+ text: true,
3090
+ encodeInBatches: (tableIterator, options) => encodeTableAsGeojsonInBatches(tableIterator, options)
3091
+ };
3092
+ return __toCommonJS(src_exports);
3144
3093
  })();
3094
+ return __exports__;
3095
+ });