@loaders.gl/loader-utils 4.3.0-alpha.2 → 4.3.0-alpha.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 (57) hide show
  1. package/dist/index.cjs +121 -3
  2. package/dist/index.cjs.map +3 -3
  3. package/dist/index.d.ts +7 -3
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +3 -1
  6. package/dist/json-loader.js +1 -1
  7. package/dist/lib/file-provider/data-view-file.d.ts +2 -2
  8. package/dist/lib/file-provider/data-view-file.d.ts.map +1 -1
  9. package/dist/lib/file-provider/file-handle-file.d.ts +2 -2
  10. package/dist/lib/file-provider/file-handle-file.d.ts.map +1 -1
  11. package/dist/lib/file-provider/file-provider-interface.d.ts +45 -0
  12. package/dist/lib/file-provider/file-provider-interface.d.ts.map +1 -0
  13. package/dist/lib/file-provider/file-provider-interface.js +9 -0
  14. package/dist/lib/file-provider/file-provider.d.ts +28 -17
  15. package/dist/lib/file-provider/file-provider.d.ts.map +1 -1
  16. package/dist/lib/file-provider/file-provider.js +111 -7
  17. package/dist/lib/log-utils/log.js +1 -1
  18. package/dist/lib/sources/data-source.d.ts +1 -0
  19. package/dist/lib/sources/data-source.d.ts.map +1 -1
  20. package/dist/lib/sources/image-source.d.ts +11 -13
  21. package/dist/lib/sources/image-source.d.ts.map +1 -1
  22. package/dist/lib/sources/image-source.js +1 -3
  23. package/dist/lib/sources/image-tile-source.d.ts +4 -2
  24. package/dist/lib/sources/image-tile-source.d.ts.map +1 -1
  25. package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -1
  26. package/dist/lib/sources/tile-source-adapter.js +1 -0
  27. package/dist/lib/sources/tile-source.d.ts +18 -14
  28. package/dist/lib/sources/tile-source.d.ts.map +1 -1
  29. package/dist/lib/sources/utils/utils.d.ts +1 -1
  30. package/dist/lib/sources/utils/utils.d.ts.map +1 -1
  31. package/dist/lib/sources/utils/utils.js +1 -1
  32. package/dist/lib/sources/vector-source.d.ts +61 -0
  33. package/dist/lib/sources/vector-source.d.ts.map +1 -0
  34. package/dist/lib/sources/vector-source.js +13 -0
  35. package/dist/lib/sources/vector-tile-source.d.ts +1 -1
  36. package/dist/lib/sources/vector-tile-source.d.ts.map +1 -1
  37. package/dist/source-types.d.ts +39 -0
  38. package/dist/source-types.d.ts.map +1 -0
  39. package/package.json +5 -4
  40. package/src/index.ts +8 -3
  41. package/src/lib/file-provider/data-view-file.ts +2 -2
  42. package/src/lib/file-provider/file-handle-file.ts +2 -2
  43. package/src/lib/file-provider/file-provider-interface.ts +56 -0
  44. package/src/lib/file-provider/file-provider.ts +98 -25
  45. package/src/lib/sources/data-source.ts +1 -0
  46. package/src/lib/sources/image-source.ts +19 -18
  47. package/src/lib/sources/image-tile-source.ts +8 -3
  48. package/src/lib/sources/tile-source-adapter.ts +1 -0
  49. package/src/lib/sources/tile-source.ts +26 -19
  50. package/src/lib/sources/utils/utils.ts +1 -1
  51. package/src/lib/sources/vector-source.ts +74 -0
  52. package/src/lib/sources/vector-tile-source.ts +4 -2
  53. package/src/source-types.ts +49 -0
  54. package/dist/service-types.d.ts +0 -10
  55. package/dist/service-types.d.ts.map +0 -1
  56. package/src/service-types.ts +0 -14
  57. /package/dist/{service-types.js → source-types.js} +0 -0
package/dist/index.cjs CHANGED
@@ -29,12 +29,14 @@ __export(dist_exports, {
29
29
  DataSource: () => DataSource,
30
30
  DataViewFile: () => DataViewFile,
31
31
  FileHandleFile: () => FileHandleFile,
32
+ FileProvider: () => FileProvider,
32
33
  HttpFile: () => HttpFile,
33
34
  ImageSource: () => ImageSource,
34
35
  JSONLoader: () => JSONLoader,
35
36
  NodeFile: () => NodeFileFacade,
36
37
  NodeFilesystem: () => NodeFileSystemFacade,
37
38
  RequestScheduler: () => RequestScheduler,
39
+ VectorSource: () => VectorSource,
38
40
  _addAliases: () => addAliases,
39
41
  assert: () => assert,
40
42
  canEncodeWithWorker: () => canEncodeWithWorker,
@@ -138,7 +140,7 @@ var nodeVersion = matches && parseFloat(matches[1]) || 0;
138
140
 
139
141
  // dist/lib/log-utils/log.js
140
142
  var import_log = require("@probe.gl/log");
141
- var VERSION = true ? "4.3.0-alpha.1" : "latest";
143
+ var VERSION = true ? "4.3.0-alpha.3" : "latest";
142
144
  var version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
143
145
  function createLog() {
144
146
  const log2 = new import_log.Log({ id: "loaders.gl" });
@@ -717,7 +719,7 @@ function resolvePath(filename2) {
717
719
  }
718
720
 
719
721
  // dist/json-loader.js
720
- var VERSION2 = true ? "4.3.0-alpha.1" : "latest";
722
+ var VERSION2 = true ? "4.3.0-alpha.3" : "latest";
721
723
  var JSONLoader = {
722
724
  dataType: null,
723
725
  batchType: null,
@@ -1128,11 +1130,121 @@ var NodeFileSystemFacade = class {
1128
1130
  }
1129
1131
  };
1130
1132
 
1131
- // dist/lib/file-provider/file-provider.js
1133
+ // dist/lib/file-provider/file-provider-interface.js
1132
1134
  var isFileProvider = (fileProvider) => {
1133
1135
  return (fileProvider == null ? void 0 : fileProvider.getUint8) && (fileProvider == null ? void 0 : fileProvider.slice) && (fileProvider == null ? void 0 : fileProvider.length);
1134
1136
  };
1135
1137
 
1138
+ // dist/lib/file-provider/file-provider.js
1139
+ var FileProvider = class {
1140
+ /** The File object from which data is provided */
1141
+ file;
1142
+ size;
1143
+ /** Create a new BrowserFile */
1144
+ constructor(file, size) {
1145
+ this.file = file;
1146
+ this.size = BigInt(size);
1147
+ }
1148
+ static async create(file) {
1149
+ var _a;
1150
+ let size = 0n;
1151
+ if (file.bigsize > 0n) {
1152
+ size = file.bigsize;
1153
+ } else if (file.size > 0) {
1154
+ size = file.size;
1155
+ } else {
1156
+ const stats = await ((_a = file.stat) == null ? void 0 : _a.call(file));
1157
+ size = (stats == null ? void 0 : stats.bigsize) ?? 0n;
1158
+ }
1159
+ return new FileProvider(file, size);
1160
+ }
1161
+ /**
1162
+ * Truncates the file descriptor.
1163
+ * @param length desired file lenght
1164
+ */
1165
+ async truncate(length) {
1166
+ throw new Error("file loaded via range requests cannot be changed");
1167
+ }
1168
+ /**
1169
+ * Append data to a file.
1170
+ * @param buffer data to append
1171
+ */
1172
+ async append(buffer) {
1173
+ throw new Error("file loaded via range requests cannot be changed");
1174
+ }
1175
+ /** Close file */
1176
+ async destroy() {
1177
+ throw new Error("file loaded via range requests cannot be changed");
1178
+ }
1179
+ /**
1180
+ * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
1181
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
1182
+ */
1183
+ async getUint8(offset) {
1184
+ const arrayBuffer = await this.file.read(offset, 1);
1185
+ const val = new Uint8Array(arrayBuffer).at(0);
1186
+ if (val === void 0) {
1187
+ throw new Error("something went wrong");
1188
+ }
1189
+ return val;
1190
+ }
1191
+ /**
1192
+ * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
1193
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
1194
+ */
1195
+ async getUint16(offset) {
1196
+ const arrayBuffer = await this.file.read(offset, 2);
1197
+ const val = new Uint16Array(arrayBuffer).at(0);
1198
+ if (val === void 0) {
1199
+ throw new Error("something went wrong");
1200
+ }
1201
+ return val;
1202
+ }
1203
+ /**
1204
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1205
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
1206
+ */
1207
+ async getUint32(offset) {
1208
+ const arrayBuffer = await this.file.read(offset, 4);
1209
+ const val = new Uint32Array(arrayBuffer).at(0);
1210
+ if (val === void 0) {
1211
+ throw new Error("something went wrong");
1212
+ }
1213
+ return val;
1214
+ }
1215
+ /**
1216
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1217
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
1218
+ */
1219
+ async getBigUint64(offset) {
1220
+ const arrayBuffer = await this.file.read(offset, 8);
1221
+ const val = new BigInt64Array(arrayBuffer).at(0);
1222
+ if (val === void 0) {
1223
+ throw new Error("something went wrong");
1224
+ }
1225
+ return val;
1226
+ }
1227
+ /**
1228
+ * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
1229
+ * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
1230
+ * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
1231
+ */
1232
+ async slice(startOffset, endOffset) {
1233
+ const bigLength = BigInt(endOffset) - BigInt(startOffset);
1234
+ if (bigLength > Number.MAX_SAFE_INTEGER) {
1235
+ throw new Error("too big slice");
1236
+ }
1237
+ const length = Number(bigLength);
1238
+ return await this.file.read(startOffset, length);
1239
+ }
1240
+ /**
1241
+ * the length (in bytes) of the data.
1242
+ */
1243
+ get length() {
1244
+ return this.size;
1245
+ }
1246
+ };
1247
+
1136
1248
  // dist/lib/file-provider/file-handle-file.js
1137
1249
  var FileHandleFile = class {
1138
1250
  /** The FileHandle from which data is provided */
@@ -1335,4 +1447,10 @@ var ImageSource = class extends DataSource {
1335
1447
  };
1336
1448
  __publicField(ImageSource, "type", "template");
1337
1449
  __publicField(ImageSource, "testURL", (url) => false);
1450
+
1451
+ // dist/lib/sources/vector-source.js
1452
+ var VectorSource = class extends DataSource {
1453
+ };
1454
+ __publicField(VectorSource, "type", "template");
1455
+ __publicField(VectorSource, "testURL", (url) => false);
1338
1456
  //# sourceMappingURL=index.cjs.map