@loaders.gl/core 5.0.0-beta.7 → 5.0.0-beta.8

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 (233) hide show
  1. package/dist/arrow-geometry/geojson-table.cjs +26 -15
  2. package/dist/arrow-geometry/geojson-table.cjs.map +2 -2
  3. package/dist/arrow-geometry/geojson-table.d.ts +8 -1
  4. package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
  5. package/dist/arrow-geometry/geojson-table.js +18 -9
  6. package/dist/arrow-geometry/geojson-table.js.map +1 -1
  7. package/dist/cluster-source.cjs +78 -8
  8. package/dist/cluster-source.cjs.map +3 -3
  9. package/dist/dist.dev.js +354 -319
  10. package/dist/dist.min.js +3 -3
  11. package/dist/federated-table-scan-source.cjs +177 -176
  12. package/dist/federated-table-scan-source.cjs.map +2 -2
  13. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +4 -8
  14. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
  15. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.d.ts.map +1 -1
  16. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
  17. package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
  18. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
  19. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
  20. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
  21. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
  22. package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
  23. package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
  24. package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
  25. package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
  26. package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
  27. package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
  28. package/dist/index.cjs +351 -281
  29. package/dist/index.cjs.map +3 -3
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +1 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/api/create-data-source.d.ts +14 -9
  35. package/dist/lib/api/create-data-source.d.ts.map +1 -1
  36. package/dist/lib/api/create-data-source.js +55 -45
  37. package/dist/lib/api/create-data-source.js.map +1 -1
  38. package/dist/lib/api/encode.d.ts +1 -1
  39. package/dist/lib/api/encode.d.ts.map +1 -1
  40. package/dist/lib/api/encode.js +11 -2
  41. package/dist/lib/api/encode.js.map +1 -1
  42. package/dist/lib/api/load-in-batches.d.ts +3 -2
  43. package/dist/lib/api/load-in-batches.d.ts.map +1 -1
  44. package/dist/lib/api/load-in-batches.js.map +1 -1
  45. package/dist/lib/api/load-loader.d.ts +3 -3
  46. package/dist/lib/api/load-loader.d.ts.map +1 -1
  47. package/dist/lib/api/load-loader.js +14 -18
  48. package/dist/lib/api/load-loader.js.map +1 -1
  49. package/dist/lib/api/load.d.ts +7 -3
  50. package/dist/lib/api/load.d.ts.map +1 -1
  51. package/dist/lib/api/load.js +11 -64
  52. package/dist/lib/api/load.js.map +1 -1
  53. package/dist/lib/api/parse-file.d.ts +5 -3
  54. package/dist/lib/api/parse-file.d.ts.map +1 -1
  55. package/dist/lib/api/parse-file.js +12 -7
  56. package/dist/lib/api/parse-file.js.map +1 -1
  57. package/dist/lib/api/parse-in-batches.d.ts +5 -3
  58. package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
  59. package/dist/lib/api/parse-in-batches.js +14 -3
  60. package/dist/lib/api/parse-in-batches.js.map +1 -1
  61. package/dist/lib/api/parse-sync.d.ts +5 -3
  62. package/dist/lib/api/parse-sync.d.ts.map +1 -1
  63. package/dist/lib/api/parse-sync.js +8 -6
  64. package/dist/lib/api/parse-sync.js.map +1 -1
  65. package/dist/lib/api/parse.d.ts +5 -3
  66. package/dist/lib/api/parse.d.ts.map +1 -1
  67. package/dist/lib/api/parse.js +26 -15
  68. package/dist/lib/api/parse.js.map +1 -1
  69. package/dist/lib/api/select-loader.d.ts +4 -2
  70. package/dist/lib/api/select-loader.d.ts.map +1 -1
  71. package/dist/lib/api/select-loader.js +43 -40
  72. package/dist/lib/api/select-loader.js.map +1 -1
  73. package/dist/lib/api/select-source.d.ts.map +1 -1
  74. package/dist/lib/api/select-source.js +1 -1
  75. package/dist/lib/api/select-source.js.map +1 -1
  76. package/dist/lib/init.js +1 -1
  77. package/dist/lib/loader-utils/loggers.d.ts +2 -37
  78. package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
  79. package/dist/lib/loader-utils/loggers.js +2 -63
  80. package/dist/lib/loader-utils/loggers.js.map +1 -1
  81. package/dist/lib/loader-utils/native-arrow.d.ts +11 -0
  82. package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
  83. package/dist/lib/loader-utils/native-arrow.js +52 -0
  84. package/dist/lib/loader-utils/native-arrow.js.map +1 -0
  85. package/dist/lib/loader-utils/option-defaults.js +2 -2
  86. package/dist/lib/loader-utils/option-defaults.js.map +1 -1
  87. package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
  88. package/dist/lib/loader-utils/option-utils.js +21 -10
  89. package/dist/lib/loader-utils/option-utils.js.map +1 -1
  90. package/dist/loader-utils/index.cjs +143 -42
  91. package/dist/loader-utils/index.cjs.map +3 -3
  92. package/dist/loader-utils/index.d.ts +2 -2
  93. package/dist/loader-utils/index.d.ts.map +1 -1
  94. package/dist/loader-utils/index.js +1 -1
  95. package/dist/loader-utils/index.js.map +1 -1
  96. package/dist/loader-utils/json-loader.js +1 -1
  97. package/dist/loader-utils/lib/log-utils/log.d.ts +24 -1
  98. package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
  99. package/dist/loader-utils/lib/log-utils/log.js +32 -1
  100. package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
  101. package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +5 -0
  102. package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -1
  103. package/dist/loader-utils/lib/scan-utils/logical-table-query.js +13 -5
  104. package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -1
  105. package/dist/loader-utils/lib/scan-utils/table-query.d.ts +5 -1
  106. package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
  107. package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
  108. package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
  109. package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -1
  110. package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
  111. package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +27 -20
  112. package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
  113. package/dist/loader-utils/lib/sources/data-source.js +3 -3
  114. package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
  115. package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
  116. package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +15 -1
  117. package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
  118. package/dist/loader-utils/loader-types.d.ts +102 -27
  119. package/dist/loader-utils/loader-types.d.ts.map +1 -1
  120. package/dist/loader-utils/loader-types.js.map +1 -1
  121. package/dist/loader-utils/source-types.d.ts +5 -5
  122. package/dist/loader-utils/source-types.d.ts.map +1 -1
  123. package/dist/loader-utils/source-types.js +5 -1
  124. package/dist/loader-utils/source-types.js.map +1 -1
  125. package/dist/null-loader.js +1 -1
  126. package/dist/null-worker-node.js +1 -1
  127. package/dist/null-worker.js +1 -1
  128. package/dist/polyfills/index.cjs +3 -2
  129. package/dist/polyfills/index.d.ts.map +1 -1
  130. package/dist/polyfills/index.js +2 -2
  131. package/dist/polyfills/index.js.map +1 -1
  132. package/dist/scan/arrow-execution/expressions.cjs +9 -9
  133. package/dist/scan/arrow-execution/expressions.cjs.map +3 -3
  134. package/dist/scan/arrow-execution/expressions.d.ts +3 -3
  135. package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
  136. package/dist/scan/arrow-execution/expressions.js +4 -4
  137. package/dist/scan/arrow-execution/expressions.js.map +1 -1
  138. package/dist/scan/index.cjs +21 -6
  139. package/dist/scan/index.cjs.map +2 -2
  140. package/dist/scan/index.d.ts +2 -1
  141. package/dist/scan/index.d.ts.map +1 -1
  142. package/dist/scan/index.js +1 -1
  143. package/dist/scan/index.js.map +1 -1
  144. package/dist/scan/parse-sql-predicate.cjs +1 -1
  145. package/dist/scan/parse-sql-predicate.cjs.map +1 -1
  146. package/dist/scan/parse-sql-predicate.js +1 -1
  147. package/dist/scan/parse-sql-predicate.js.map +1 -1
  148. package/dist/scan/query-progressive.cjs +191 -0
  149. package/dist/scan/query-progressive.cjs.map +7 -0
  150. package/dist/scan/query-progressive.d.ts +39 -0
  151. package/dist/scan/query-progressive.d.ts.map +1 -0
  152. package/dist/scan/query-progressive.js +174 -0
  153. package/dist/scan/query-progressive.js.map +1 -0
  154. package/dist/scan/query.cjs +42 -8
  155. package/dist/scan/query.cjs.map +3 -3
  156. package/dist/scan/query.d.ts +26 -6
  157. package/dist/scan/query.d.ts.map +1 -1
  158. package/dist/scan/query.js +48 -7
  159. package/dist/scan/query.js.map +1 -1
  160. package/dist/schema-utils/index.cjs +262 -241
  161. package/dist/schema-utils/index.cjs.map +2 -2
  162. package/dist/schema-utils/index.d.ts +1 -0
  163. package/dist/schema-utils/index.d.ts.map +1 -1
  164. package/dist/schema-utils/index.js +1 -0
  165. package/dist/schema-utils/index.js.map +1 -1
  166. package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
  167. package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
  168. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +28 -0
  169. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
  170. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +26 -0
  171. package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
  172. package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
  173. package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
  174. package/dist/vector-table-scan-source.cjs +2 -1
  175. package/dist/vector-table-scan-source.cjs.map +1 -1
  176. package/dist/worker-utils/index.cjs +49 -9
  177. package/dist/worker-utils/index.cjs.map +3 -3
  178. package/dist/worker-utils/lib/env-utils/version.js +1 -1
  179. package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
  180. package/dist/worker-utils/lib/library-utils/library-utils.js +2 -1
  181. package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
  182. package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
  183. package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
  184. package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
  185. package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
  186. package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
  187. package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
  188. package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
  189. package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
  190. package/package.json +8 -7
  191. package/src/arrow-geometry/geojson-table.ts +27 -17
  192. package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
  193. package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
  194. package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
  195. package/src/index.ts +1 -1
  196. package/src/lib/api/create-data-source.ts +136 -58
  197. package/src/lib/api/encode.ts +14 -3
  198. package/src/lib/api/load-in-batches.ts +15 -7
  199. package/src/lib/api/load-loader.ts +21 -20
  200. package/src/lib/api/load.ts +49 -121
  201. package/src/lib/api/parse-file.ts +42 -23
  202. package/src/lib/api/parse-in-batches.ts +49 -12
  203. package/src/lib/api/parse-sync.ts +37 -19
  204. package/src/lib/api/parse.ts +51 -30
  205. package/src/lib/api/select-loader.ts +56 -53
  206. package/src/lib/api/select-source.ts +7 -1
  207. package/src/lib/loader-utils/loggers.ts +2 -70
  208. package/src/lib/loader-utils/native-arrow.ts +70 -0
  209. package/src/lib/loader-utils/option-defaults.ts +2 -2
  210. package/src/lib/loader-utils/option-utils.ts +21 -10
  211. package/src/loader-utils/index.ts +2 -1
  212. package/src/loader-utils/lib/log-utils/log.ts +39 -1
  213. package/src/loader-utils/lib/scan-utils/logical-table-query.ts +18 -8
  214. package/src/loader-utils/lib/scan-utils/table-query.ts +10 -1
  215. package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +36 -25
  216. package/src/loader-utils/lib/sources/data-source.ts +3 -3
  217. package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +16 -1
  218. package/src/loader-utils/loader-types.ts +168 -43
  219. package/src/loader-utils/source-types.ts +12 -6
  220. package/src/polyfills/index.ts +3 -3
  221. package/src/scan/arrow-execution/expressions.ts +5 -5
  222. package/src/scan/index.ts +7 -1
  223. package/src/scan/parse-sql-predicate.ts +1 -1
  224. package/src/scan/query-progressive.ts +231 -0
  225. package/src/scan/query.ts +92 -10
  226. package/src/schema-utils/index.ts +5 -0
  227. package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
  228. package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +58 -0
  229. package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
  230. package/src/worker-utils/lib/library-utils/library-utils.ts +2 -1
  231. package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
  232. package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
  233. package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
package/dist/dist.dev.js CHANGED
@@ -40,6 +40,7 @@ var __exports__ = (() => {
40
40
  concatenateArrayBuffersAsync: () => concatenateArrayBuffersAsync,
41
41
  coreApi: () => coreApi,
42
42
  createDataSource: () => createDataSource,
43
+ createDataSourceSync: () => createDataSourceSync,
43
44
  document: () => document_,
44
45
  encode: () => encode,
45
46
  encodeInBatches: () => encodeInBatches,
@@ -674,6 +675,35 @@ var __exports__ = (() => {
674
675
  return log3;
675
676
  }
676
677
  var log2 = createLog();
678
+ var NullLog = class {
679
+ /** Discards debug messages. */
680
+ log() {
681
+ return ignoreMessage;
682
+ }
683
+ /** Discards informational messages. */
684
+ info() {
685
+ return ignoreMessage;
686
+ }
687
+ /** Discards messages marked to be emitted once. */
688
+ once() {
689
+ return ignoreMessage;
690
+ }
691
+ /** Discards warnings. */
692
+ warn() {
693
+ return ignoreMessage;
694
+ }
695
+ /** Discards errors. */
696
+ error() {
697
+ return ignoreMessage;
698
+ }
699
+ };
700
+ function ignoreMessage() {
701
+ }
702
+ var nullLog = new NullLog();
703
+ function getLoaderLog(options) {
704
+ const logger = options?.core?.log !== void 0 ? options.core.log : options?.log;
705
+ return logger === null ? nullLog : logger || log2;
706
+ }
677
707
 
678
708
  // src/loader-utils/lib/javascript-utils/is-type.ts
679
709
  var isBoolean = (value) => typeof value === "boolean";
@@ -3713,9 +3743,9 @@ var __exports__ = (() => {
3713
3743
  return;
3714
3744
  }
3715
3745
  warnedWorkerVersionFallbacks2.add(workerId);
3716
- console.warn(
3746
+ log2.warn(
3717
3747
  `loaders.gl: ${worker.name} loader worker version is "latest" because __VERSION__ was not injected. Fetching ${url} from CDN.`
3718
- );
3748
+ )();
3719
3749
  }
3720
3750
 
3721
3751
  // src/worker-utils/lib/worker-api/task-runtime.ts
@@ -4157,7 +4187,14 @@ var __exports__ = (() => {
4157
4187
  ...portableOptions,
4158
4188
  signal: void 0,
4159
4189
  onProgress: void 0,
4160
- ...portableOptions.core ? { core: { ...portableOptions.core, authentications: void 0 } } : {}
4190
+ log: isDisabledLog(portableOptions.log) ? null : void 0,
4191
+ ...portableOptions.core ? {
4192
+ core: {
4193
+ ...portableOptions.core,
4194
+ authentications: void 0,
4195
+ log: isDisabledLog(portableOptions.core.log) ? null : void 0
4196
+ }
4197
+ } : {}
4161
4198
  };
4162
4199
  const serializedOptions = JSON.parse(
4163
4200
  JSON.stringify(optionsToSerialize, (_key, value) => {
@@ -4212,6 +4249,9 @@ var __exports__ = (() => {
4212
4249
  function isLoaderWithWorkerResultDeserializer(loader) {
4213
4250
  return typeof loader.deserializeWorkerResult === "function";
4214
4251
  }
4252
+ function isDisabledLog(logger) {
4253
+ return logger === null || logger instanceof NullLog;
4254
+ }
4215
4255
 
4216
4256
  // src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts
4217
4257
  function canEncodeWithWorker(writer, options) {
@@ -5313,7 +5353,9 @@ var __exports__ = (() => {
5313
5353
 
5314
5354
  // src/loader-utils/source-types.ts
5315
5355
  function isSourceLoader(loader) {
5316
- return Boolean(loader && typeof loader === "object" && "createDataSource" in loader);
5356
+ return Boolean(
5357
+ loader && typeof loader === "object" && "createDataSourceSync" in loader && "fromUrl" in loader && "testURL" in loader
5358
+ );
5317
5359
  }
5318
5360
 
5319
5361
  // src/lib/fetch/fetch-error.ts
@@ -5532,72 +5574,6 @@ var __exports__ = (() => {
5532
5574
  });
5533
5575
  }
5534
5576
 
5535
- // src/lib/loader-utils/loggers.ts
5536
- var probeLog = new ProbeLog({ id: "loaders.gl" });
5537
- var NullLog = class {
5538
- /** Drops a log message. */
5539
- log() {
5540
- return () => {
5541
- };
5542
- }
5543
- /** Drops an info message. */
5544
- info() {
5545
- return () => {
5546
- };
5547
- }
5548
- /** Logs one message once; no-op for the null logger. */
5549
- once() {
5550
- return () => {
5551
- };
5552
- }
5553
- /** Drops a warning message. */
5554
- warn() {
5555
- return () => {
5556
- };
5557
- }
5558
- /** Drops an error message. */
5559
- error() {
5560
- return () => {
5561
- };
5562
- }
5563
- };
5564
- var ConsoleLog2 = class {
5565
- /** Console-like object used for message output. */
5566
- console;
5567
- /** Messages already emitted through `once`. */
5568
- onceMessages = /* @__PURE__ */ new Set();
5569
- /** Creates a console-backed logger. */
5570
- constructor() {
5571
- this.console = console;
5572
- }
5573
- /** Logs a message to the console. */
5574
- log(...args) {
5575
- return this.console.log.bind(this.console, ...args);
5576
- }
5577
- /** Logs an informational message to the console. */
5578
- info(...args) {
5579
- return this.console.info.bind(this.console, ...args);
5580
- }
5581
- /** Logs one message once to the console. */
5582
- once(...args) {
5583
- const message = String(args[0]);
5584
- if (this.onceMessages.has(message)) {
5585
- return () => {
5586
- };
5587
- }
5588
- this.onceMessages.add(message);
5589
- return this.console.info.bind(this.console, ...args);
5590
- }
5591
- /** Logs a warning message to the console. */
5592
- warn(...args) {
5593
- return this.console.warn.bind(this.console, ...args);
5594
- }
5595
- /** Logs an error message to the console. */
5596
- error(...args) {
5597
- return this.console.error.bind(this.console, ...args);
5598
- }
5599
- };
5600
-
5601
5577
  // src/lib/loader-utils/option-defaults.ts
5602
5578
  var DEFAULT_LOADER_OPTIONS = {
5603
5579
  searchParams: void 0,
@@ -5610,8 +5586,7 @@ var __exports__ = (() => {
5610
5586
  ignoreRegisteredLoaders: void 0,
5611
5587
  nothrow: false,
5612
5588
  shape: void 0,
5613
- log: new ConsoleLog2(),
5614
- // A probe.gl compatible (`log.log()()` syntax) that just logs to console
5589
+ log: log2,
5615
5590
  useLocalLibraries: false,
5616
5591
  subloaders: void 0,
5617
5592
  CDN: "https://unpkg.com/@loaders.gl",
@@ -5682,6 +5657,48 @@ var __exports__ = (() => {
5682
5657
  signal: "core.fetch.signal"
5683
5658
  };
5684
5659
 
5660
+ // src/lib/loader-utils/native-arrow.ts
5661
+ function getShapeOptionKey(loader) {
5662
+ const keys = Object.keys(loader.options || {}).filter((key) => {
5663
+ const value = loader.options?.[key];
5664
+ return key !== "core" && value && typeof value === "object" && "shape" in value;
5665
+ });
5666
+ return keys.includes(loader.id) ? loader.id : keys.length === 1 ? keys[0] : void 0;
5667
+ }
5668
+ function getNativeArrowOptions(loader, options, inBatches = false) {
5669
+ const key = getShapeOptionKey(loader);
5670
+ const scopedOptions = key && options[key];
5671
+ if (!scopedOptions || typeof scopedOptions !== "object" || !("shape" in scopedOptions) || scopedOptions.shape !== "arrow") {
5672
+ return null;
5673
+ }
5674
+ if (inBatches && options.core?.metadata) {
5675
+ throw new Error(
5676
+ 'shape: "arrow" does not support core.metadata; use "arrow-table" for batch metadata'
5677
+ );
5678
+ }
5679
+ return {
5680
+ ...options,
5681
+ core: { ...options.core, ...options.core?.shape === "arrow" ? { shape: "arrow-table" } : {} },
5682
+ [key]: { ...scopedOptions, shape: "arrow-table" }
5683
+ };
5684
+ }
5685
+ function unwrapArrowTable(result) {
5686
+ const table = result;
5687
+ if (table?.shape !== "arrow-table" || !table.data || !Array.isArray(table.data.batches)) {
5688
+ throw new Error('shape: "arrow" requires a loader that supports "arrow-table" output');
5689
+ }
5690
+ return table.data;
5691
+ }
5692
+ async function* unwrapArrowBatches(batches) {
5693
+ for await (const batch of batches) {
5694
+ const batchType = batch?.batchType;
5695
+ if (batchType === "metadata" || batchType === "partial-result" || batchType === "final-result") {
5696
+ continue;
5697
+ }
5698
+ yield* unwrapArrowTable(batch).batches;
5699
+ }
5700
+ }
5701
+
5685
5702
  // src/lib/loader-utils/option-utils.ts
5686
5703
  var CORE_LOADER_OPTION_KEYS = [
5687
5704
  "baseUrl",
@@ -5798,15 +5815,15 @@ var __exports__ = (() => {
5798
5815
  const isWorkerUrlOption = key === "workerUrl" && id;
5799
5816
  if (!(key in defaultOptions) && !isBaseUriOption && !isWorkerUrlOption) {
5800
5817
  if (key in deprecatedOptions) {
5801
- if (probeLog.level > 0) {
5802
- probeLog.warn(
5818
+ if (log2.level > 0) {
5819
+ log2.warn(
5803
5820
  `${loaderName} loader option '${prefix}${key}' no longer supported, use '${deprecatedOptions[key]}'`
5804
5821
  )();
5805
5822
  }
5806
5823
  } else if (!isSubOptions) {
5807
- if (probeLog.level > 0) {
5824
+ if (log2.level > 0) {
5808
5825
  const suggestion = findSimilarOption(key, loaders);
5809
- probeLog.warn(
5826
+ log2.warn(
5810
5827
  `${loaderName} loader option '${prefix}${key}' not recognized. ${suggestion}`
5811
5828
  )();
5812
5829
  }
@@ -5838,13 +5855,20 @@ var __exports__ = (() => {
5838
5855
  mergedOptions.core = { ...loaderDefaultOptions.core };
5839
5856
  }
5840
5857
  moveDeprecatedTopLevelOptionsToCore(mergedOptions);
5841
- if (mergedOptions.core?.log === null) {
5842
- mergedOptions.core = { ...mergedOptions.core, log: new NullLog() };
5858
+ const shapeKey = loader.defaultShape && getShapeOptionKey(loader);
5859
+ if (shapeKey) {
5860
+ mergedOptions[shapeKey] = {
5861
+ ...loaderDefaultOptions[shapeKey],
5862
+ shape: loader.defaultShape
5863
+ };
5843
5864
  }
5844
5865
  mergeNestedFields(mergedOptions, normalizeLoaderOptions(getGlobalLoaderOptions()));
5845
5866
  const userOptions = normalizeLoaderOptions(options);
5846
5867
  mergeNestedFields(mergedOptions, userOptions);
5847
5868
  applyCoreShapeDefault(mergedOptions, userOptions, loader);
5869
+ if (mergedOptions.core?.log === null) {
5870
+ mergedOptions.core = { ...mergedOptions.core, log: getLoaderLog(mergedOptions) };
5871
+ }
5848
5872
  addUrlOptions(mergedOptions, url);
5849
5873
  addDeprecatedTopLevelOptions(mergedOptions);
5850
5874
  return mergedOptions;
@@ -5854,20 +5878,24 @@ var __exports__ = (() => {
5854
5878
  if (coreShape === void 0) {
5855
5879
  return;
5856
5880
  }
5857
- const loaderScopedDefaults = loader.options?.[loader.id];
5881
+ const shapeOptionKey = getShapeOptionKey(loader);
5882
+ if (!shapeOptionKey) {
5883
+ return;
5884
+ }
5885
+ const loaderScopedDefaults = loader.options?.[shapeOptionKey];
5858
5886
  if (!isPureObject(loaderScopedDefaults) || !("shape" in loaderScopedDefaults)) {
5859
5887
  return;
5860
5888
  }
5861
- const globalLoaderScopedOptions = getGlobalLoaderOptions()[loader.id];
5889
+ const globalLoaderScopedOptions = getGlobalLoaderOptions()[shapeOptionKey];
5862
5890
  if (isPureObject(globalLoaderScopedOptions) && "shape" in globalLoaderScopedOptions) {
5863
5891
  return;
5864
5892
  }
5865
- const userLoaderScopedOptions = userOptions[loader.id];
5893
+ const userLoaderScopedOptions = userOptions[shapeOptionKey];
5866
5894
  if (isPureObject(userLoaderScopedOptions) && "shape" in userLoaderScopedOptions) {
5867
5895
  return;
5868
5896
  }
5869
- const loaderScopedOptions = mergedOptions[loader.id];
5870
- mergedOptions[loader.id] = {
5897
+ const loaderScopedOptions = mergedOptions[shapeOptionKey];
5898
+ mergedOptions[shapeOptionKey] = {
5871
5899
  ...isPureObject(loaderScopedOptions) ? loaderScopedOptions : {},
5872
5900
  shape: coreShape
5873
5901
  };
@@ -5999,40 +6027,29 @@ var __exports__ = (() => {
5999
6027
 
6000
6028
  // src/lib/api/select-loader.ts
6001
6029
  var EXT_PATTERN = /\.([^.]+)$/;
6002
- async function selectLoader(data, loaders = [], options, context) {
6030
+ async function selectLoader(data, loaders = [], options, context, operation = "parse") {
6003
6031
  if (!validHTTPResponse(data)) {
6004
6032
  return null;
6005
6033
  }
6006
6034
  const normalizedOptions = normalizeLoaderOptions(options || {});
6007
6035
  normalizedOptions.core ||= {};
6008
- if (data instanceof Response && mayContainText(data)) {
6009
- const text = await data.clone().text();
6010
- const textLoader = selectLoaderSync(
6011
- text,
6012
- loaders,
6013
- { ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } },
6014
- context
6015
- );
6016
- if (textLoader) {
6017
- return textLoader;
6018
- }
6019
- }
6020
- let loader = selectLoaderSync(
6021
- data,
6022
- loaders,
6023
- { ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } },
6024
- context
6025
- );
6026
- if (loader) {
6027
- return loader;
6036
+ if (loaders && !Array.isArray(loaders)) {
6037
+ return normalizeLoader(loaders);
6028
6038
  }
6029
- if (isBlob(data)) {
6030
- data = await data.slice(0, 10).arrayBuffer();
6031
- loader = selectLoaderSync(data, loaders, normalizedOptions, context);
6039
+ const text = data instanceof Response && mayContainText(data) ? await data.clone().text() : null;
6040
+ let initialBytes;
6041
+ async function matchCandidates(candidates) {
6042
+ normalizeLoaders(candidates);
6043
+ const loader2 = text !== null && selectLoaderInternal(text, candidates, normalizedOptions, context, operation) || selectLoaderInternal(data, candidates, normalizedOptions, context, operation);
6044
+ if (!loader2 && isBlob(data) && candidates.length) {
6045
+ initialBytes ??= await data.slice(0, 10).arrayBuffer();
6046
+ return selectLoaderInternal(initialBytes, candidates, normalizedOptions, context, operation);
6047
+ }
6048
+ return loader2;
6032
6049
  }
6033
- if (!loader && data instanceof Response && mayContainText(data)) {
6034
- const text = await data.clone().text();
6035
- loader = selectLoaderSync(text, loaders, normalizedOptions, context);
6050
+ let loader = await matchCandidates(loaders || []);
6051
+ if (!loader && !normalizedOptions.core.ignoreRegisteredLoaders) {
6052
+ loader = await matchCandidates(getRegisteredLoaders());
6036
6053
  }
6037
6054
  if (!loader && !normalizedOptions.core.nothrow) {
6038
6055
  throw new Error(getNoValidLoaderMessage(data));
@@ -6045,7 +6062,7 @@ var __exports__ = (() => {
6045
6062
  mimeType && (mimeType.startsWith("text/") || mimeType === "application/json" || mimeType.endsWith("+json"))
6046
6063
  );
6047
6064
  }
6048
- function selectLoaderSync(data, loaders = [], options, context) {
6065
+ function selectLoaderSync(data, loaders = [], options, context, operation = "parse") {
6049
6066
  if (!validHTTPResponse(data)) {
6050
6067
  return null;
6051
6068
  }
@@ -6054,21 +6071,24 @@ var __exports__ = (() => {
6054
6071
  if (loaders && !Array.isArray(loaders)) {
6055
6072
  return normalizeLoader(loaders);
6056
6073
  }
6057
- let candidateLoaders = [];
6058
- if (loaders) {
6059
- candidateLoaders = candidateLoaders.concat(loaders);
6060
- }
6061
- if (!normalizedOptions.core.ignoreRegisteredLoaders) {
6062
- candidateLoaders.push(...getRegisteredLoaders());
6074
+ const candidates = loaders || [];
6075
+ normalizeLoaders(candidates);
6076
+ let loader = selectLoaderInternal(data, candidates, normalizedOptions, context, operation);
6077
+ if (!loader && !normalizedOptions.core.ignoreRegisteredLoaders) {
6078
+ loader = selectLoaderInternal(
6079
+ data,
6080
+ getRegisteredLoaders(),
6081
+ normalizedOptions,
6082
+ context,
6083
+ operation
6084
+ );
6063
6085
  }
6064
- normalizeLoaders(candidateLoaders);
6065
- const loader = selectLoaderInternal(data, candidateLoaders, normalizedOptions, context);
6066
6086
  if (!loader && !normalizedOptions.core.nothrow) {
6067
6087
  throw new Error(getNoValidLoaderMessage(data));
6068
6088
  }
6069
6089
  return loader;
6070
6090
  }
6071
- function selectLoaderInternal(data, loaders, options, context) {
6091
+ function selectLoaderInternal(data, loaders, options, context, operation = "parse") {
6072
6092
  const url = getResourceUrl(data);
6073
6093
  const type = getResourceMIMEType(data);
6074
6094
  const testUrl = stripQueryString(url) || context?.url;
@@ -6083,20 +6103,27 @@ var __exports__ = (() => {
6083
6103
  loader = findLoaderByMIMEType(loaders, options?.core?.mimeType);
6084
6104
  reason = `match forced by supplied MIME type ${options?.core?.mimeType}`;
6085
6105
  }
6086
- loader = loader || findSourceLoaderByTestURL(loaders, testUrl);
6087
- reason = reason || (loader ? `matched source url ${testUrl}` : "");
6088
- loader = loader || findLoaderByUrl(loaders, testUrl);
6106
+ if (!loader && operation === "source") {
6107
+ loader = findSourceLoaderByTestURL(loaders, testUrl);
6108
+ reason = loader ? `matched source url ${testUrl}` : "";
6109
+ }
6110
+ const fallbackLoaders = operation === "source" && testUrl ? loaders.filter((candidate) => !isSourceLoader(candidate)) : loaders;
6111
+ loader = loader || findLoaderByUrl(fallbackLoaders, testUrl);
6089
6112
  reason = reason || (loader ? `matched url ${testUrl}` : "");
6090
- loader = loader || findLoaderByMIMEType(loaders, type);
6113
+ if (!loader && operation === "parse") {
6114
+ loader = findSourceLoaderByTestURL(loaders, testUrl);
6115
+ reason = loader ? `matched source url ${testUrl}` : "";
6116
+ }
6117
+ loader = loader || findLoaderByMIMEType(fallbackLoaders, type);
6091
6118
  reason = reason || (loader ? `matched MIME type ${type}` : "");
6092
- loader = loader || findLoaderByInitialBytes(loaders, data);
6119
+ loader = loader || findLoaderByInitialBytes(fallbackLoaders, data);
6093
6120
  reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
6094
6121
  if (!loader && isBlob(data)) {
6095
6122
  loader = findSourceLoaderByTestData(loaders, data);
6096
6123
  reason = reason || (loader ? "matched source testData" : "");
6097
6124
  }
6098
6125
  if (options?.core?.fallbackMimeType) {
6099
- loader = loader || findLoaderByMIMEType(loaders, options?.core?.fallbackMimeType);
6126
+ loader = loader || findLoaderByMIMEType(fallbackLoaders, options?.core?.fallbackMimeType);
6100
6127
  reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
6101
6128
  }
6102
6129
  if (reason) {
@@ -6522,16 +6549,7 @@ var __exports__ = (() => {
6522
6549
  var loaderImplementationPromises = /* @__PURE__ */ new Map();
6523
6550
  var loaderImplementations = /* @__PURE__ */ new Map();
6524
6551
  async function getLoaderImplementation(loader, options, url) {
6525
- if (isSourceLoader(loader)) {
6526
- const source = loader.preload ? await loader.preload(url || "", options) : loader;
6527
- if (!isSourceLoader(source)) {
6528
- throw new Error(
6529
- `${loader.id} source loader preload() did not return a runtime source loader`
6530
- );
6531
- }
6532
- return source;
6533
- }
6534
- if (isLoaderWithParser(loader)) {
6552
+ if (isLoaderWithParser(loader) || !loader.preload && loader.createDataSourceSync) {
6535
6553
  return loader;
6536
6554
  }
6537
6555
  const implementationCacheKey = getLoaderImplementationCacheKey(loader, options);
@@ -6565,31 +6583,33 @@ var __exports__ = (() => {
6565
6583
  }
6566
6584
  return await loaderImplementationPromise;
6567
6585
  }
6568
- function getLoaderImplementationSync(loader) {
6586
+ function getLoaderImplementationSync(loader, options) {
6569
6587
  if (loader.subloaders && !preparedLoaders.has(loader)) {
6570
6588
  const prepared = preparedDefaults.get(loader);
6571
6589
  if (prepared) return prepared;
6572
6590
  if (!isLoaderWithParser(loader)) return null;
6573
6591
  }
6574
- if (isLoaderWithParser(loader)) {
6592
+ if (isLoaderWithParser(loader) || !loader.preload && loader.createDataSourceSync) {
6575
6593
  return loader;
6576
6594
  }
6577
- const implementationCacheKey = getLoaderImplementationCacheKey(loader);
6595
+ const implementationCacheKey = getLoaderImplementationCacheKey(loader, options);
6578
6596
  return loaderImplementations.get(loader)?.get(implementationCacheKey) || null;
6579
6597
  }
6580
6598
  function isLoaderWithParser(loader) {
6581
6599
  const candidate = loader;
6582
6600
  return Boolean(
6583
- candidate.parse || candidate.parseSync || candidate.parseInBatches || candidate.parseText || candidate.parseTextSync || candidate.parseFile || candidate.parseFileInBatches
6601
+ candidate.parse || candidate.parseBlob || candidate.parseUrl || candidate.parseSync || candidate.parseInBatches || candidate.parseText || candidate.parseTextSync || candidate.parseFile || candidate.parseFileInBatches
6584
6602
  );
6585
6603
  }
6586
6604
  async function resolveLoaderImplementation(loader, options, url) {
6587
6605
  if (loader.preload) {
6588
6606
  const preloadedLoader = await loader.preload(url || "", options);
6589
- if (isLoaderWithParser(preloadedLoader)) {
6607
+ if (preloadedLoader && (isLoaderWithParser(preloadedLoader) || preloadedLoader.createDataSourceSync)) {
6590
6608
  return preloadedLoader;
6591
6609
  }
6592
- throw new Error(`${loader.id} loader preload() did not return a parser-bearing loader`);
6610
+ throw new Error(
6611
+ `${loader.id} loader preload() did not return a parser-bearing loader or a source factory`
6612
+ );
6593
6613
  }
6594
6614
  const implementationSpecifier = getLoaderImplementationSpecifier(loader, options);
6595
6615
  return await importLoaderImplementation(implementationSpecifier, loader.id);
@@ -6694,7 +6714,7 @@ var __exports__ = (() => {
6694
6714
  prepared.worker = false;
6695
6715
  for (const method of [
6696
6716
  "parseBlob",
6697
- "createDataSource",
6717
+ "createDataSourceSync",
6698
6718
  "parse",
6699
6719
  "parseSync",
6700
6720
  "parseText",
@@ -6745,11 +6765,6 @@ var __exports__ = (() => {
6745
6765
  if (!loader) {
6746
6766
  return null;
6747
6767
  }
6748
- if (isSourceLoader(loader)) {
6749
- throw new Error(
6750
- `${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseFile().`
6751
- );
6752
- }
6753
6768
  const normalizedOptions = normalizeOptions(options, loader, candidateLoaders, url);
6754
6769
  const authenticationLoader = !loader.getAuthentications && normalizedOptions.core?.credentials?.length ? await getLoaderImplementation(loader, normalizedOptions, url || context?.url) : loader;
6755
6770
  const strictOptions = await resolveLoaderAuthenticationOptions(
@@ -6757,13 +6772,20 @@ var __exports__ = (() => {
6757
6772
  url,
6758
6773
  normalizedOptions
6759
6774
  );
6775
+ const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
6760
6776
  context = getLoaderContext(
6761
6777
  // @ts-expect-error candidateLoaders may be a single forced loader
6762
6778
  { url, _parse: parse, loaders: candidateLoaders },
6763
- strictOptions,
6779
+ nativeArrowOptions || strictOptions,
6764
6780
  context || null
6765
6781
  );
6766
- return await parseFileWithLoader(loader, file, strictOptions, context);
6782
+ const result = await parseFileWithLoader(
6783
+ loader,
6784
+ file,
6785
+ nativeArrowOptions || strictOptions,
6786
+ context
6787
+ );
6788
+ return nativeArrowOptions ? unwrapArrowTable(result) : result;
6767
6789
  }
6768
6790
  async function parseFileWithLoader(loader, file, options, context) {
6769
6791
  (options.signal || context.signal)?.throwIfAborted();
@@ -6771,7 +6793,9 @@ var __exports__ = (() => {
6771
6793
  options = mergeOptions(loader.options, options);
6772
6794
  const loaderWithParser = await getLoaderImplementation(loader, options, context.url);
6773
6795
  if (loaderWithParser.parseFile) {
6774
- return await loaderWithParser.parseFile(file, options, context);
6796
+ const output = loaderWithParser.prepareParseOutput?.(options);
6797
+ const result = await loaderWithParser.parseFile(file, output?.options ?? options, context);
6798
+ return output ? output.convert(result) : result;
6775
6799
  }
6776
6800
  const parseFunction = loaderWithParser.parse;
6777
6801
  if (parseFunction) {
@@ -6782,6 +6806,9 @@ var __exports__ = (() => {
6782
6806
  const data = await file.read(0n, length);
6783
6807
  return await parse(data, loaderWithParser, options, context);
6784
6808
  }
6809
+ if (loaderWithParser.createDataSourceSync) {
6810
+ throw new Error(`${loader.id} has no file parser. Use createDataSource() to open a source.`);
6811
+ }
6785
6812
  throw new Error(`${loader.id} loader - no file parser found`);
6786
6813
  }
6787
6814
 
@@ -6799,28 +6826,25 @@ var __exports__ = (() => {
6799
6826
  if (!loader) {
6800
6827
  return null;
6801
6828
  }
6802
- if (isSourceLoader(loader)) {
6803
- throw new Error(
6804
- `${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseSync().`
6805
- );
6806
- }
6807
6829
  const strictOptions = normalizeOptions(options, loader, candidateLoaders);
6808
6830
  const url = getResourceUrl(data);
6809
6831
  const parse2 = () => {
6810
6832
  throw new Error("parseSync called parse (which is async");
6811
6833
  };
6834
+ const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
6812
6835
  context = getLoaderContext(
6813
6836
  { url, _parseSync: parse2, _parse: parse2, loaders },
6814
- strictOptions,
6837
+ nativeArrowOptions || strictOptions,
6815
6838
  context || null
6816
6839
  );
6817
6840
  const loaderWithParser = getLoaderImplementationSync(loader);
6818
- return parseWithLoaderSync(
6841
+ const result = parseWithLoaderSync(
6819
6842
  loaderWithParser || loader,
6820
6843
  data,
6821
- strictOptions,
6844
+ nativeArrowOptions || strictOptions,
6822
6845
  context
6823
6846
  );
6847
+ return nativeArrowOptions ? unwrapArrowTable(result) : result;
6824
6848
  }
6825
6849
  function parseWithLoaderSync(loader, data, options, context) {
6826
6850
  data = getArrayBufferOrStringFromDataSync(data, loader, options);
@@ -6835,6 +6859,11 @@ var __exports__ = (() => {
6835
6859
  `${loader.name} loader: 'parseSync' requires a parser-bearing loader. Import the loader implementation directly, or call preload(loader) before parseSync(). ${context.url || ""}`
6836
6860
  );
6837
6861
  }
6862
+ if (loader.createDataSourceSync) {
6863
+ throw new Error(
6864
+ `${loader.id} has no synchronous parser. Use createDataSource() to open a source.`
6865
+ );
6866
+ }
6838
6867
  throw new Error(
6839
6868
  `${loader.name} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${context.url || ""}`
6840
6869
  );
@@ -6864,16 +6893,26 @@ var __exports__ = (() => {
6864
6893
  url || "",
6865
6894
  normalizedOptions
6866
6895
  );
6896
+ const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, true);
6867
6897
  context = getLoaderContext(
6868
6898
  { url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray },
6869
- strictOptions,
6899
+ nativeArrowOptions || strictOptions,
6870
6900
  context || null
6871
6901
  );
6872
6902
  const loaderWithParser = await getLoaderImplementation(loader, strictOptions, context.url);
6873
- return await parseWithLoaderInBatches(loader, loaderWithParser, data, strictOptions, context);
6903
+ const batches = await parseWithLoaderInBatches(
6904
+ loader,
6905
+ loaderWithParser,
6906
+ data,
6907
+ nativeArrowOptions || strictOptions,
6908
+ context
6909
+ );
6910
+ return nativeArrowOptions ? unwrapArrowBatches(batches) : batches;
6874
6911
  }
6875
6912
  async function parseWithLoaderInBatches(originalLoader, loader, data, options, context) {
6876
- const outputIterator = await parseToOutputIterator(loader, data, options, context);
6913
+ const output = loader.parseInBatches ? loader.prepareParseBatchOutput?.(options) : null;
6914
+ const decoded = await parseToOutputIterator(loader, data, output?.options ?? options, context);
6915
+ const outputIterator = output ? convertOutputBatches(decoded, output.convert) : decoded;
6877
6916
  if (!options?.core?.metadata) {
6878
6917
  return outputIterator;
6879
6918
  }
@@ -6894,6 +6933,11 @@ var __exports__ = (() => {
6894
6933
  }
6895
6934
  return makeMetadataBatchIterator(outputIterator);
6896
6935
  }
6936
+ async function* convertOutputBatches(batches, convert) {
6937
+ for await (const batch of batches) {
6938
+ yield convert(batch);
6939
+ }
6940
+ }
6897
6941
  async function parseToOutputIterator(loader, data, options, context) {
6898
6942
  const inputIterator = await getAsyncIterableFromData(data, options);
6899
6943
  const transformedIterator = await applyInputTransforms(
@@ -6973,38 +7017,6 @@ var __exports__ = (() => {
6973
7017
  return iteratorChain;
6974
7018
  }
6975
7019
 
6976
- // src/lib/api/load-in-batches.ts
6977
- function loadInBatches(files, loaders, options, context) {
6978
- let loadersArray;
6979
- if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
6980
- context = void 0;
6981
- options = loaders;
6982
- loadersArray = void 0;
6983
- } else {
6984
- loadersArray = loaders;
6985
- }
6986
- if (!Array.isArray(files)) {
6987
- return loadOneFileInBatches(files, loadersArray, options || {});
6988
- }
6989
- const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}));
6990
- return promises;
6991
- }
6992
- async function loadOneFileInBatches(file, loaders, options) {
6993
- if (typeof file === "string") {
6994
- const url = file;
6995
- const loader = await selectLoader(url, loaders, {
6996
- ...options,
6997
- core: { ...options.core, nothrow: true }
6998
- });
6999
- const authenticationLoader = loader && !loader.getAuthentications && options.core?.credentials?.length ? await getLoaderImplementation(loader, options, url) : loader;
7000
- options = await resolveLoaderAuthenticationOptions(authenticationLoader, url, options);
7001
- const fetch2 = getFetchFunction(options);
7002
- const response = await fetch2(applySearchParamsToUrl(url, options));
7003
- return Array.isArray(loaders) ? await parseInBatches(response, loaders, options) : await parseInBatches(response, loaders, options);
7004
- }
7005
- return Array.isArray(loaders) ? await parseInBatches(file, loaders, options) : await parseInBatches(file, loaders, options);
7006
- }
7007
-
7008
7020
  // src/lib/api/load.ts
7009
7021
  async function load(url, loaders, options, context) {
7010
7022
  let resolvedLoaders;
@@ -7018,91 +7030,40 @@ var __exports__ = (() => {
7018
7030
  resolvedOptions = options;
7019
7031
  }
7020
7032
  resolvedOptions ||= getGlobalLoaderOptions();
7021
- if (!Array.isArray(resolvedLoaders) && isSourceLoader(resolvedLoaders)) {
7022
- const sourceLoader = await resolveSourceLoader(resolvedLoaders, url, resolvedOptions);
7023
- resolvedOptions = await resolveLoaderAuthenticationOptions(
7024
- resolvedLoaders.getAuthentications ? resolvedLoaders : sourceLoader,
7025
- typeof url === "string" ? url : "",
7026
- resolvedOptions || {}
7027
- );
7028
- const runtimeCoreApi = {
7029
- fetchFile,
7030
- parse,
7031
- parseFile,
7032
- parseSync,
7033
- parseInBatches,
7034
- load,
7035
- loadInBatches
7036
- };
7037
- return sourceLoader.createDataSource(
7038
- url,
7039
- resolvedOptions || {},
7040
- runtimeCoreApi
7041
- );
7042
- }
7043
- if (Array.isArray(resolvedLoaders) && resolvedLoaders.length === 1 && isSourceLoader(resolvedLoaders[0])) {
7044
- const sourceLoader = await resolveSourceLoader(resolvedLoaders[0], url, resolvedOptions);
7045
- resolvedOptions = await resolveLoaderAuthenticationOptions(
7046
- resolvedLoaders[0].getAuthentications ? resolvedLoaders[0] : sourceLoader,
7047
- typeof url === "string" ? url : "",
7048
- resolvedOptions || {}
7049
- );
7050
- const runtimeCoreApi = {
7051
- fetchFile,
7052
- parse,
7053
- parseFile,
7054
- parseSync,
7055
- parseInBatches,
7056
- load,
7057
- loadInBatches
7058
- };
7059
- return sourceLoader.createDataSource(
7060
- url,
7061
- resolvedOptions || {},
7062
- runtimeCoreApi
7063
- );
7064
- }
7065
7033
  if (typeof url === "string" || isBlob(url)) {
7066
7034
  const selectedLoader = await selectLoader(url, resolvedLoaders, {
7067
7035
  ...resolvedOptions,
7068
7036
  core: { ...resolvedOptions?.core, nothrow: true }
7069
7037
  });
7070
- if (selectedLoader && isSourceLoader(selectedLoader)) {
7071
- const sourceLoader = await resolveSourceLoader(selectedLoader, url, resolvedOptions);
7072
- resolvedOptions = await resolveLoaderAuthenticationOptions(
7073
- selectedLoader.getAuthentications ? selectedLoader : sourceLoader,
7074
- typeof url === "string" ? url : "",
7075
- resolvedOptions || {}
7076
- );
7077
- return sourceLoader.createDataSource(
7078
- url,
7079
- resolvedOptions || {},
7080
- {
7081
- fetchFile,
7082
- parse,
7083
- parseFile,
7084
- parseSync,
7085
- parseInBatches,
7086
- load,
7087
- loadInBatches
7088
- }
7089
- );
7090
- }
7091
7038
  if (selectedLoader && typeof url === "string") {
7092
7039
  const loaderImplementation = await getLoaderImplementation(
7093
7040
  selectedLoader,
7094
7041
  resolvedOptions,
7095
7042
  url
7096
7043
  );
7044
+ if (loaderImplementation.createDataSourceSync && !isLoaderWithParser(loaderImplementation)) {
7045
+ throw new Error(
7046
+ `${selectedLoader.id} creates sources. Use createDataSource() instead of load().`
7047
+ );
7048
+ }
7097
7049
  resolvedOptions = await resolveLoaderAuthenticationOptions(
7098
7050
  selectedLoader.getAuthentications ? selectedLoader : loaderImplementation,
7099
7051
  url,
7100
7052
  resolvedOptions || {}
7101
7053
  );
7102
- const parseUrl = loaderImplementation.parseUrl;
7054
+ const { parseUrl } = loaderImplementation;
7103
7055
  if (parseUrl) {
7104
7056
  const requestUrl = applySearchParamsToUrl(url, resolvedOptions);
7105
- return await parseUrl(requestUrl, resolvedOptions, context);
7057
+ const nativeOptions = getNativeArrowOptions(
7058
+ selectedLoader,
7059
+ normalizeOptions(resolvedOptions, selectedLoader, [selectedLoader], url)
7060
+ );
7061
+ const result = await parseUrl(
7062
+ requestUrl,
7063
+ nativeOptions || resolvedOptions,
7064
+ context
7065
+ );
7066
+ return nativeOptions ? unwrapArrowTable(result) : result;
7106
7067
  }
7107
7068
  }
7108
7069
  }
@@ -7129,15 +7090,37 @@ var __exports__ = (() => {
7129
7090
  }
7130
7091
  return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions, context) : await parse(data, resolvedLoaders, resolvedOptions, context);
7131
7092
  }
7132
- async function resolveSourceLoader(loader, url, options) {
7133
- if (!loader.preload) {
7134
- return loader;
7093
+
7094
+ // src/lib/api/load-in-batches.ts
7095
+ function loadInBatches(files, loaders, options, context) {
7096
+ let loadersArray;
7097
+ if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
7098
+ context = void 0;
7099
+ options = loaders;
7100
+ loadersArray = void 0;
7101
+ } else {
7102
+ loadersArray = loaders;
7103
+ }
7104
+ if (!Array.isArray(files)) {
7105
+ return loadOneFileInBatches(files, loadersArray, options || {});
7135
7106
  }
7136
- const sourceLoader = await loader.preload(typeof url === "string" ? url : "", options);
7137
- if (!isSourceLoader(sourceLoader)) {
7138
- throw new Error(`${loader.id} source loader preload() did not return a runtime source loader`);
7107
+ const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}));
7108
+ return promises;
7109
+ }
7110
+ async function loadOneFileInBatches(file, loaders, options) {
7111
+ if (typeof file === "string") {
7112
+ const url = file;
7113
+ const loader = await selectLoader(url, loaders, {
7114
+ ...options,
7115
+ core: { ...options.core, nothrow: true }
7116
+ });
7117
+ const authenticationLoader = loader && !loader.getAuthentications && options.core?.credentials?.length ? await getLoaderImplementation(loader, options, url) : loader;
7118
+ options = await resolveLoaderAuthenticationOptions(authenticationLoader, url, options);
7119
+ const fetch2 = getFetchFunction(options);
7120
+ const response = await fetch2(applySearchParamsToUrl(url, options));
7121
+ return Array.isArray(loaders) ? await parseInBatches(response, loaders, options) : await parseInBatches(response, loaders, options);
7139
7122
  }
7140
- return sourceLoader;
7123
+ return Array.isArray(loaders) ? await parseInBatches(file, loaders, options) : await parseInBatches(file, loaders, options);
7141
7124
  }
7142
7125
 
7143
7126
  // src/lib/api/core-api.ts
@@ -7215,11 +7198,6 @@ var __exports__ = (() => {
7215
7198
  if (!loader) {
7216
7199
  return null;
7217
7200
  }
7218
- if (isSourceLoader(loader)) {
7219
- throw new Error(
7220
- `${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parse().`
7221
- );
7222
- }
7223
7201
  const normalizedOptions = normalizeOptions(options, loader, candidateLoaders, url);
7224
7202
  const authenticationLoader = !loader.getAuthentications && normalizedOptions.core?.credentials?.length ? await getLoaderImplementation(loader, normalizedOptions, url || context?.url) : loader;
7225
7203
  const strictOptions = await resolveLoaderAuthenticationOptions(
@@ -7227,13 +7205,15 @@ var __exports__ = (() => {
7227
7205
  url || "",
7228
7206
  normalizedOptions
7229
7207
  );
7208
+ const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
7230
7209
  context = getLoaderContext(
7231
7210
  // @ts-expect-error
7232
7211
  { url, _parse: parse, loaders: candidateLoaders },
7233
- strictOptions,
7212
+ nativeArrowOptions || strictOptions,
7234
7213
  context || null
7235
7214
  );
7236
- return await parseWithLoader(loader, data, strictOptions, context);
7215
+ const result = await parseWithLoader(loader, data, nativeArrowOptions || strictOptions, context);
7216
+ return nativeArrowOptions ? unwrapArrowTable(result) : result;
7237
7217
  }
7238
7218
  async function parseWithLoader(loader, data, options, context) {
7239
7219
  (options.signal || context.signal)?.throwIfAborted();
@@ -7245,15 +7225,22 @@ var __exports__ = (() => {
7245
7225
  context.response = { headers, ok, redirected, status, statusText, type, url };
7246
7226
  }
7247
7227
  const loaderWithParser = await getLoaderImplementation(loader, options, context.url);
7248
- if (shouldParseWithWorker(loaderWithParser, data, options, context, loader)) {
7249
- data = await getArrayBufferFromData(data, options);
7250
- return await parseWithWorker(loaderWithParser, data, options, context, parse);
7228
+ if (loaderWithParser.createDataSourceSync && !isLoaderWithParser(loaderWithParser)) {
7229
+ throw new Error(`${loader.id} creates sources. Use createDataSource() to open a source.`);
7251
7230
  }
7252
- if (isBlob(data) && loaderWithParser.parseBlob) {
7253
- return await loaderWithParser.parseBlob(data, options, context);
7231
+ const output = loaderWithParser.prepareParseOutput?.(options);
7232
+ const parseOptions = output?.options ?? options;
7233
+ let result;
7234
+ if (shouldParseWithWorker(loaderWithParser, data, parseOptions, context, loader)) {
7235
+ data = await getArrayBufferFromData(data, parseOptions);
7236
+ result = await parseWithWorker(loaderWithParser, data, parseOptions, context, parse);
7237
+ } else if (isBlob(data) && loaderWithParser.parseBlob) {
7238
+ result = await loaderWithParser.parseBlob(data, parseOptions, context);
7239
+ } else {
7240
+ data = await getArrayBufferOrStringFromData(data, loader, parseOptions);
7241
+ result = await parseWithLoaderImplementation(loaderWithParser, data, parseOptions, context);
7254
7242
  }
7255
- data = await getArrayBufferOrStringFromData(data, loader, options);
7256
- return await parseWithLoaderImplementation(loaderWithParser, data, options, context);
7243
+ return output ? output.convert(result) : result;
7257
7244
  }
7258
7245
  async function parseWithLoaderImplementation(loader, data, options, context) {
7259
7246
  if (loader.parseText && typeof data === "string") {
@@ -7270,6 +7257,9 @@ var __exports__ = (() => {
7270
7257
  `${loader.name} loader: 'parse' not available on parser-bearing sync loader. Add an async 'parse' function to this loader, or call preload(loader) before parseSync(). ${context.url || ""}`
7271
7258
  );
7272
7259
  }
7260
+ if (loader.createDataSourceSync) {
7261
+ throw new Error(`${loader.id} creates sources. Use createDataSource() to open a source.`);
7262
+ }
7273
7263
  throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
7274
7264
  }
7275
7265
 
@@ -7368,8 +7358,15 @@ var __exports__ = (() => {
7368
7358
  }
7369
7359
  function encodeInBatches(data, writer, options) {
7370
7360
  if (writer.encodeInBatches) {
7371
- const dataIterator = getIterator2(data);
7372
- return writer.encodeInBatches(dataIterator, options);
7361
+ let dataIterator;
7362
+ if (data && typeof data === "object") {
7363
+ if ("numRows" in data && "schema" in data) {
7364
+ dataIterator = [data];
7365
+ } else if (Symbol.iterator in data || Symbol.asyncIterator in data) {
7366
+ dataIterator = data;
7367
+ }
7368
+ }
7369
+ return writer.encodeInBatches(dataIterator ?? getIterator2(data), options);
7373
7370
  }
7374
7371
  throw new Error(`Writer ${writer.name} could not encode in batches`);
7375
7372
  }
@@ -7403,49 +7400,81 @@ var __exports__ = (() => {
7403
7400
  }
7404
7401
 
7405
7402
  // src/lib/api/create-data-source.ts
7406
- function createDataSource(data, sources, options = {}) {
7407
- const resolvedOptions = options || {};
7408
- const type = resolvedOptions?.core?.type || resolvedOptions.type || "auto";
7409
- const source = sources.length === 1 ? sources[0] : type === "auto" ? selectLoaderSync(data, sources, {
7410
- // `createDataSource` supports non-fetch inputs such as in-memory tables.
7411
- // Selection remains best-effort for those cases.
7412
- ...resolvedOptions,
7413
- core: { ...resolvedOptions?.core, type: "auto" }
7414
- }) : getSourceOfType(type, sources);
7415
- if (!source) {
7416
- throw new Error("Not a valid source type");
7417
- }
7418
- const contributions = resolvedOptions.core?.credentials?.length ? source.getAuthentications?.(typeof data === "string" ? data : "", resolvedOptions) : void 0;
7403
+ async function createDataSource(data, loaders, options = {}) {
7404
+ options.signal?.throwIfAborted();
7405
+ const candidates = getCandidates(loaders, options);
7406
+ const loader = candidates.length === 1 ? candidates[0] : await selectLoader(
7407
+ data,
7408
+ candidates,
7409
+ getSelectionOptions(options),
7410
+ void 0,
7411
+ "source"
7412
+ );
7413
+ if (!loader) {
7414
+ throw new Error("No explicit source loader matches the input");
7415
+ }
7416
+ const url = typeof data === "string" ? data : "";
7417
+ const implementation = await preload(loader, options, url);
7418
+ options.signal?.throwIfAborted();
7419
+ const authenticatedOptions = await resolveLoaderAuthenticationOptions(
7420
+ loader.getAuthentications ? loader : implementation,
7421
+ url,
7422
+ options
7423
+ );
7424
+ options.signal?.throwIfAborted();
7425
+ return constructSource(implementation, data, authenticatedOptions);
7426
+ }
7427
+ function createDataSourceSync(data, loaders, options = {}) {
7428
+ const candidates = getCandidates(loaders, options);
7429
+ const loader = candidates.length === 1 ? candidates[0] : selectLoaderSync(
7430
+ data,
7431
+ candidates,
7432
+ getSelectionOptions(options),
7433
+ void 0,
7434
+ "source"
7435
+ );
7436
+ if (!loader) {
7437
+ throw new Error("No explicit source loader matches the input");
7438
+ }
7439
+ const implementation = getLoaderImplementationSync(loader, options);
7440
+ if (!implementation) {
7441
+ throw new Error(
7442
+ `${loader.id} has no synchronous source factory available. Call preload() first.`
7443
+ );
7444
+ }
7445
+ const authenticationLoader = loader.getAuthentications ? loader : implementation;
7446
+ const contributions = options.core?.credentials?.length ? authenticationLoader.getAuthentications?.(typeof data === "string" ? data : "", options) : void 0;
7419
7447
  if (contributions && "then" in contributions) {
7420
7448
  void contributions.catch(() => {
7421
7449
  });
7422
- throw new Error("Use load() with an asynchronous getAuthentications() hook.");
7450
+ throw new Error("Use createDataSource() with an asynchronous getAuthentications() hook.");
7423
7451
  }
7424
7452
  const authenticatedOptions = resolveAuthenticationOptions(
7425
7453
  contributions?.length ? {
7426
- ...resolvedOptions,
7454
+ ...options,
7427
7455
  core: {
7428
- ...resolvedOptions.core,
7429
- authentications: [
7430
- ...resolvedOptions.core?.authentications || [],
7431
- ...contributions || []
7432
- ]
7456
+ ...options.core,
7457
+ authentications: [...options.core?.authentications || [], ...contributions]
7433
7458
  }
7434
- } : resolvedOptions
7435
- );
7436
- return source.createDataSource(
7437
- data,
7438
- authenticatedOptions,
7439
- coreApi
7459
+ } : options
7440
7460
  );
7461
+ return constructSource(implementation, data, authenticatedOptions);
7441
7462
  }
7442
- function getSourceOfType(type, sources) {
7443
- for (const service of sources) {
7444
- if (service.type === type) {
7445
- return service;
7446
- }
7463
+ function getCandidates(loaders, options) {
7464
+ const candidates = Array.isArray(loaders) ? [...loaders] : [loaders];
7465
+ const type = options.core?.type || options.type;
7466
+ return candidates.length > 1 && type && type !== "auto" ? candidates.filter((loader) => isSourceLoader(loader) && loader.type === type) : candidates;
7467
+ }
7468
+ function getSelectionOptions(options) {
7469
+ return { ...options, core: { ...options.core, ignoreRegisteredLoaders: true, nothrow: true } };
7470
+ }
7471
+ function constructSource(loader, data, options) {
7472
+ if (loader.createDataSourceSync) {
7473
+ return loader.createDataSourceSync(data, options, coreApi);
7447
7474
  }
7448
- return null;
7475
+ throw new Error(
7476
+ `${loader.id} has no synchronous source factory. Use createDataSource() to preload the loader.`
7477
+ );
7449
7478
  }
7450
7479
 
7451
7480
  // src/lib/api/select-source.ts
@@ -7453,16 +7482,22 @@ var __exports__ = (() => {
7453
7482
  const type = options?.type || "auto";
7454
7483
  let selectedSource = null;
7455
7484
  if (type === "auto") {
7456
- selectedSource = selectLoaderSync(url, sources, { core: { nothrow: true } });
7485
+ selectedSource = selectLoaderSync(
7486
+ url,
7487
+ sources,
7488
+ { core: { nothrow: true } },
7489
+ void 0,
7490
+ "source"
7491
+ );
7457
7492
  } else {
7458
- selectedSource = getSourceOfType2(type, sources);
7493
+ selectedSource = getSourceOfType(type, sources);
7459
7494
  }
7460
7495
  if (!selectedSource && !options?.nothrow) {
7461
7496
  throw new Error("Not a valid image source type");
7462
7497
  }
7463
7498
  return selectedSource;
7464
7499
  }
7465
- function getSourceOfType2(type, sources) {
7500
+ function getSourceOfType(type, sources) {
7466
7501
  for (const service of sources) {
7467
7502
  if (service.type === type) {
7468
7503
  return service;