@loaders.gl/loader-utils 4.3.0-alpha.1 → 4.3.0-alpha.3

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 (61) hide show
  1. package/dist/index.cjs +122 -4
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/index.d.ts +8 -4
  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 +104 -7
  17. package/dist/lib/log-utils/log.d.ts +0 -1
  18. package/dist/lib/log-utils/log.d.ts.map +1 -1
  19. package/dist/lib/log-utils/log.js +12 -3
  20. package/dist/lib/sources/data-source.d.ts +1 -0
  21. package/dist/lib/sources/data-source.d.ts.map +1 -1
  22. package/dist/lib/sources/image-source.d.ts +11 -13
  23. package/dist/lib/sources/image-source.d.ts.map +1 -1
  24. package/dist/lib/sources/image-source.js +1 -3
  25. package/dist/lib/sources/image-tile-source.d.ts +4 -3
  26. package/dist/lib/sources/image-tile-source.d.ts.map +1 -1
  27. package/dist/lib/sources/tile-source-adapter.d.ts +2 -1
  28. package/dist/lib/sources/tile-source-adapter.d.ts.map +1 -1
  29. package/dist/lib/sources/tile-source-adapter.js +4 -3
  30. package/dist/lib/sources/tile-source.d.ts +30 -25
  31. package/dist/lib/sources/tile-source.d.ts.map +1 -1
  32. package/dist/lib/sources/utils/utils.d.ts +1 -1
  33. package/dist/lib/sources/utils/utils.d.ts.map +1 -1
  34. package/dist/lib/sources/utils/utils.js +1 -1
  35. package/dist/lib/sources/vector-source.d.ts +61 -0
  36. package/dist/lib/sources/vector-source.d.ts.map +1 -0
  37. package/dist/lib/sources/vector-source.js +13 -0
  38. package/dist/lib/sources/vector-tile-source.d.ts +6 -3
  39. package/dist/lib/sources/vector-tile-source.d.ts.map +1 -1
  40. package/dist/source-types.d.ts +39 -0
  41. package/dist/source-types.d.ts.map +1 -0
  42. package/package.json +5 -4
  43. package/src/index.ts +9 -4
  44. package/src/lib/file-provider/data-view-file.ts +2 -2
  45. package/src/lib/file-provider/file-handle-file.ts +2 -2
  46. package/src/lib/file-provider/file-provider-interface.ts +56 -0
  47. package/src/lib/file-provider/file-provider.ts +95 -25
  48. package/src/lib/log-utils/log.ts +15 -2
  49. package/src/lib/sources/data-source.ts +1 -0
  50. package/src/lib/sources/image-source.ts +19 -18
  51. package/src/lib/sources/image-tile-source.ts +8 -4
  52. package/src/lib/sources/tile-source-adapter.ts +5 -4
  53. package/src/lib/sources/tile-source.ts +38 -30
  54. package/src/lib/sources/utils/utils.ts +1 -1
  55. package/src/lib/sources/vector-source.ts +74 -0
  56. package/src/lib/sources/vector-tile-source.ts +11 -4
  57. package/src/source-types.ts +49 -0
  58. package/dist/service-types.d.ts +0 -10
  59. package/dist/service-types.d.ts.map +0 -1
  60. package/src/service-types.ts +0 -14
  61. /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,9 +140,18 @@ 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.2.0" : "latest";
143
+ var VERSION = true ? "4.3.0-alpha.2" : "latest";
142
144
  var version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
143
- var log = new import_log.Log({ id: `loaders.gl ${version}` });
145
+ function createLog() {
146
+ const log2 = new import_log.Log({ id: "loaders.gl" });
147
+ globalThis.loaders = globalThis.loaders || {};
148
+ globalThis.loaders.log = log2;
149
+ globalThis.loaders.version = version;
150
+ globalThis.probe = globalThis.probe || {};
151
+ globalThis.probe.loaders = log2;
152
+ return log2;
153
+ }
154
+ var log = createLog();
144
155
 
145
156
  // dist/lib/option-utils/merge-loader-options.js
146
157
  function mergeLoaderOptions(baseOptions, newOptions) {
@@ -708,7 +719,7 @@ function resolvePath(filename2) {
708
719
  }
709
720
 
710
721
  // dist/json-loader.js
711
- var VERSION2 = true ? "4.2.0" : "latest";
722
+ var VERSION2 = true ? "4.3.0-alpha.2" : "latest";
712
723
  var JSONLoader = {
713
724
  dataType: null,
714
725
  batchType: null,
@@ -1119,11 +1130,112 @@ var NodeFileSystemFacade = class {
1119
1130
  }
1120
1131
  };
1121
1132
 
1122
- // dist/lib/file-provider/file-provider.js
1133
+ // dist/lib/file-provider/file-provider-interface.js
1123
1134
  var isFileProvider = (fileProvider) => {
1124
1135
  return (fileProvider == null ? void 0 : fileProvider.getUint8) && (fileProvider == null ? void 0 : fileProvider.slice) && (fileProvider == null ? void 0 : fileProvider.length);
1125
1136
  };
1126
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, _b;
1150
+ return new FileProvider(file, file.bigsize > 0n ? file.bigsize : file.size > 0n ? file.size : ((_b = await ((_a = file.stat) == null ? void 0 : _a.call(file))) == null ? void 0 : _b.bigsize) ?? 0n);
1151
+ }
1152
+ /**
1153
+ * Truncates the file descriptor.
1154
+ * @param length desired file lenght
1155
+ */
1156
+ async truncate(length) {
1157
+ throw new Error("file loaded via range requests cannot be changed");
1158
+ }
1159
+ /**
1160
+ * Append data to a file.
1161
+ * @param buffer data to append
1162
+ */
1163
+ async append(buffer) {
1164
+ throw new Error("file loaded via range requests cannot be changed");
1165
+ }
1166
+ /** Close file */
1167
+ async destroy() {
1168
+ throw new Error("file loaded via range requests cannot be changed");
1169
+ }
1170
+ /**
1171
+ * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
1172
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
1173
+ */
1174
+ async getUint8(offset) {
1175
+ const arrayBuffer = await this.file.read(offset, 1);
1176
+ const val = new Uint8Array(arrayBuffer).at(0);
1177
+ if (val === void 0) {
1178
+ throw new Error("something went wrong");
1179
+ }
1180
+ return val;
1181
+ }
1182
+ /**
1183
+ * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
1184
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
1185
+ */
1186
+ async getUint16(offset) {
1187
+ const arrayBuffer = await this.file.read(offset, 2);
1188
+ const val = new Uint16Array(arrayBuffer).at(0);
1189
+ if (val === void 0) {
1190
+ throw new Error("something went wrong");
1191
+ }
1192
+ return val;
1193
+ }
1194
+ /**
1195
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1196
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
1197
+ */
1198
+ async getUint32(offset) {
1199
+ const arrayBuffer = await this.file.read(offset, 4);
1200
+ const val = new Uint32Array(arrayBuffer).at(0);
1201
+ if (val === void 0) {
1202
+ throw new Error("something went wrong");
1203
+ }
1204
+ return val;
1205
+ }
1206
+ /**
1207
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
1208
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
1209
+ */
1210
+ async getBigUint64(offset) {
1211
+ const arrayBuffer = await this.file.read(offset, 8);
1212
+ const val = new BigInt64Array(arrayBuffer).at(0);
1213
+ if (val === void 0) {
1214
+ throw new Error("something went wrong");
1215
+ }
1216
+ return val;
1217
+ }
1218
+ /**
1219
+ * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
1220
+ * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
1221
+ * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
1222
+ */
1223
+ async slice(startOffset, endOffset) {
1224
+ const bigLength = BigInt(endOffset) - BigInt(startOffset);
1225
+ if (bigLength > Number.MAX_SAFE_INTEGER) {
1226
+ throw new Error("too big slice");
1227
+ }
1228
+ const length = Number(bigLength);
1229
+ return await this.file.read(startOffset, length);
1230
+ }
1231
+ /**
1232
+ * the length (in bytes) of the data.
1233
+ */
1234
+ get length() {
1235
+ return this.size;
1236
+ }
1237
+ };
1238
+
1127
1239
  // dist/lib/file-provider/file-handle-file.js
1128
1240
  var FileHandleFile = class {
1129
1241
  /** The FileHandle from which data is provided */
@@ -1326,4 +1438,10 @@ var ImageSource = class extends DataSource {
1326
1438
  };
1327
1439
  __publicField(ImageSource, "type", "template");
1328
1440
  __publicField(ImageSource, "testURL", (url) => false);
1441
+
1442
+ // dist/lib/sources/vector-source.js
1443
+ var VectorSource = class extends DataSource {
1444
+ };
1445
+ __publicField(VectorSource, "type", "template");
1446
+ __publicField(VectorSource, "testURL", (url) => false);
1329
1447
  //# sourceMappingURL=index.cjs.map