@loaders.gl/3d-tiles 4.4.0-alpha.2 → 4.4.0

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 (122) hide show
  1. package/README.md +1 -1
  2. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts +3 -3
  3. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -1
  4. package/dist/3d-tiles-archive/3d-tiles-archive-archive.js +5 -4
  5. package/dist/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  6. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +3 -3
  7. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -1
  8. package/dist/3d-tiles-archive/3d-tiles-archive-parser.js +4 -3
  9. package/dist/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  10. package/dist/3d-tiles-archive-loader.d.ts.map +1 -1
  11. package/dist/3d-tiles-archive-loader.js +4 -3
  12. package/dist/3d-tiles-archive-loader.js.map +1 -0
  13. package/dist/cesium-ion-loader.d.ts +2 -2
  14. package/dist/cesium-ion-loader.d.ts.map +1 -1
  15. package/dist/cesium-ion-loader.js +1 -0
  16. package/dist/cesium-ion-loader.js.map +1 -0
  17. package/dist/dist.dev.js +1386 -898
  18. package/dist/dist.min.js +1 -1
  19. package/dist/index.cjs +37 -27
  20. package/dist/index.cjs.map +4 -4
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +1 -0
  24. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -0
  25. package/dist/lib/classes/tile-3d-batch-table-hierarchy.d.ts +1 -1
  26. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +1 -0
  27. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -0
  28. package/dist/lib/classes/tile-3d-batch-table.js +1 -0
  29. package/dist/lib/classes/tile-3d-batch-table.js.map +1 -0
  30. package/dist/lib/classes/tile-3d-feature-table.d.ts.map +1 -1
  31. package/dist/lib/classes/tile-3d-feature-table.js +14 -1
  32. package/dist/lib/classes/tile-3d-feature-table.js.map +1 -0
  33. package/dist/lib/constants.js +1 -0
  34. package/dist/lib/constants.js.map +1 -0
  35. package/dist/lib/encoders/encode-3d-tile-batched-model.js +1 -0
  36. package/dist/lib/encoders/encode-3d-tile-batched-model.js.map +1 -0
  37. package/dist/lib/encoders/encode-3d-tile-composite.js +1 -0
  38. package/dist/lib/encoders/encode-3d-tile-composite.js.map +1 -0
  39. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +1 -0
  40. package/dist/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -0
  41. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +1 -0
  42. package/dist/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -0
  43. package/dist/lib/encoders/encode-3d-tile.js +1 -0
  44. package/dist/lib/encoders/encode-3d-tile.js.map +1 -0
  45. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +1 -0
  46. package/dist/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -0
  47. package/dist/lib/ion/ion.js +1 -0
  48. package/dist/lib/ion/ion.js.map +1 -0
  49. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +1 -0
  50. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -0
  51. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +1 -0
  52. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -0
  53. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +1 -0
  54. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -0
  55. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +1 -0
  56. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
  57. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  58. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -1
  59. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -0
  60. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +1 -0
  61. package/dist/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -0
  62. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +1 -0
  63. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
  64. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +1 -0
  65. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -0
  66. package/dist/lib/parsers/helpers/parse-utils.js +1 -0
  67. package/dist/lib/parsers/helpers/parse-utils.js.map +1 -0
  68. package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -0
  69. package/dist/lib/parsers/parse-3d-tile-batched-model.js.map +1 -0
  70. package/dist/lib/parsers/parse-3d-tile-composite.js +1 -0
  71. package/dist/lib/parsers/parse-3d-tile-composite.js.map +1 -0
  72. package/dist/lib/parsers/parse-3d-tile-gltf.js +1 -0
  73. package/dist/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
  74. package/dist/lib/parsers/parse-3d-tile-header.d.ts +2 -2
  75. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  76. package/dist/lib/parsers/parse-3d-tile-header.js +1 -0
  77. package/dist/lib/parsers/parse-3d-tile-header.js.map +1 -0
  78. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +1 -0
  79. package/dist/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -0
  80. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +1 -0
  81. package/dist/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -0
  82. package/dist/lib/parsers/parse-3d-tile.js +1 -0
  83. package/dist/lib/parsers/parse-3d-tile.js.map +1 -0
  84. package/dist/lib/utils/obb/s2-corners-to-obb.js +1 -0
  85. package/dist/lib/utils/obb/s2-corners-to-obb.js.map +1 -0
  86. package/dist/lib/utils/s2/converters/s2-to-boundary.js +1 -0
  87. package/dist/lib/utils/s2/converters/s2-to-boundary.js.map +1 -0
  88. package/dist/lib/utils/s2/converters/s2-to-obb-points.js +1 -0
  89. package/dist/lib/utils/s2/converters/s2-to-obb-points.js.map +1 -0
  90. package/dist/lib/utils/s2/converters/s2-to-region.js +1 -0
  91. package/dist/lib/utils/s2/converters/s2-to-region.js.map +1 -0
  92. package/dist/lib/utils/s2/index.js +1 -0
  93. package/dist/lib/utils/s2/index.js.map +1 -0
  94. package/dist/lib/utils/s2/s2-geometry-functions.js +1 -0
  95. package/dist/lib/utils/s2/s2-geometry-functions.js.map +1 -0
  96. package/dist/lib/utils/s2/s2-token-functions.js +1 -0
  97. package/dist/lib/utils/s2/s2-token-functions.js.map +1 -0
  98. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +1 -0
  99. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js.map +1 -0
  100. package/dist/lib/utils/s2/s2geometry/s2-geometry.js +1 -0
  101. package/dist/lib/utils/s2/s2geometry/s2-geometry.js.map +1 -0
  102. package/dist/lib/utils/version.js +2 -1
  103. package/dist/lib/utils/version.js.map +1 -0
  104. package/dist/tile-3d-subtree-loader.js +1 -0
  105. package/dist/tile-3d-subtree-loader.js.map +1 -0
  106. package/dist/tile-3d-writer.js +1 -0
  107. package/dist/tile-3d-writer.js.map +1 -0
  108. package/dist/tiles-3d-loader.d.ts +2 -2
  109. package/dist/tiles-3d-loader.d.ts.map +1 -1
  110. package/dist/tiles-3d-loader.js +1 -0
  111. package/dist/tiles-3d-loader.js.map +1 -0
  112. package/dist/types.js +1 -0
  113. package/dist/types.js.map +1 -0
  114. package/package.json +12 -12
  115. package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +7 -10
  116. package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +7 -5
  117. package/src/3d-tiles-archive-loader.ts +4 -2
  118. package/src/cesium-ion-loader.ts +2 -2
  119. package/src/lib/classes/tile-3d-feature-table.ts +11 -1
  120. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +2 -1
  121. package/src/lib/parsers/parse-3d-tile-header.ts +2 -2
  122. package/src/tiles-3d-loader.ts +2 -2
package/dist/dist.dev.js CHANGED
@@ -4329,7 +4329,139 @@ var __exports__ = (() => {
4329
4329
  }
4330
4330
 
4331
4331
  // ../../node_modules/@probe.gl/env/dist/index.js
4332
- var VERSION = true ? "4.0.7" : "untranspiled source";
4332
+ var VERSION = true ? "4.1.1" : "untranspiled source";
4333
+
4334
+ // ../../node_modules/@probe.gl/log/dist/utils/assert.js
4335
+ function assert3(condition, message) {
4336
+ if (!condition) {
4337
+ throw new Error(message || "Assertion failed");
4338
+ }
4339
+ }
4340
+
4341
+ // ../../node_modules/@probe.gl/log/dist/loggers/log-utils.js
4342
+ function normalizeLogLevel(logLevel) {
4343
+ if (!logLevel) {
4344
+ return 0;
4345
+ }
4346
+ let resolvedLevel;
4347
+ switch (typeof logLevel) {
4348
+ case "number":
4349
+ resolvedLevel = logLevel;
4350
+ break;
4351
+ case "object":
4352
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
4353
+ break;
4354
+ default:
4355
+ return 0;
4356
+ }
4357
+ assert3(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
4358
+ return resolvedLevel;
4359
+ }
4360
+ function normalizeArguments(opts) {
4361
+ const { logLevel, message } = opts;
4362
+ opts.logLevel = normalizeLogLevel(logLevel);
4363
+ const args = opts.args ? Array.from(opts.args) : [];
4364
+ while (args.length && args.shift() !== message) {
4365
+ }
4366
+ switch (typeof logLevel) {
4367
+ case "string":
4368
+ case "function":
4369
+ if (message !== void 0) {
4370
+ args.unshift(message);
4371
+ }
4372
+ opts.message = logLevel;
4373
+ break;
4374
+ case "object":
4375
+ Object.assign(opts, logLevel);
4376
+ break;
4377
+ default:
4378
+ }
4379
+ if (typeof opts.message === "function") {
4380
+ opts.message = opts.message();
4381
+ }
4382
+ const messageType = typeof opts.message;
4383
+ assert3(messageType === "string" || messageType === "object");
4384
+ return Object.assign(opts, { args }, opts.opts);
4385
+ }
4386
+
4387
+ // ../../node_modules/@probe.gl/log/dist/loggers/base-log.js
4388
+ var noop = () => {
4389
+ };
4390
+ var BaseLog = class {
4391
+ constructor({ level = 0 } = {}) {
4392
+ this.userData = {};
4393
+ this._onceCache = /* @__PURE__ */ new Set();
4394
+ this._level = level;
4395
+ }
4396
+ set level(newLevel) {
4397
+ this.setLevel(newLevel);
4398
+ }
4399
+ get level() {
4400
+ return this.getLevel();
4401
+ }
4402
+ setLevel(level) {
4403
+ this._level = level;
4404
+ return this;
4405
+ }
4406
+ getLevel() {
4407
+ return this._level;
4408
+ }
4409
+ // Unconditional logging
4410
+ warn(message, ...args) {
4411
+ return this._log("warn", 0, message, args, { once: true });
4412
+ }
4413
+ error(message, ...args) {
4414
+ return this._log("error", 0, message, args);
4415
+ }
4416
+ // Conditional logging
4417
+ log(logLevel, message, ...args) {
4418
+ return this._log("log", logLevel, message, args);
4419
+ }
4420
+ info(logLevel, message, ...args) {
4421
+ return this._log("info", logLevel, message, args);
4422
+ }
4423
+ once(logLevel, message, ...args) {
4424
+ return this._log("once", logLevel, message, args, { once: true });
4425
+ }
4426
+ _log(type, logLevel, message, args, options = {}) {
4427
+ const normalized = normalizeArguments({
4428
+ logLevel,
4429
+ message,
4430
+ args: this._buildArgs(logLevel, message, args),
4431
+ opts: options
4432
+ });
4433
+ return this._createLogFunction(type, normalized, options);
4434
+ }
4435
+ _buildArgs(logLevel, message, args) {
4436
+ return [logLevel, message, ...args];
4437
+ }
4438
+ _createLogFunction(type, normalized, options) {
4439
+ if (!this._shouldLog(normalized.logLevel)) {
4440
+ return noop;
4441
+ }
4442
+ const tag = this._getOnceTag(options.tag ?? normalized.tag ?? normalized.message);
4443
+ if ((options.once || normalized.once) && tag !== void 0) {
4444
+ if (this._onceCache.has(tag)) {
4445
+ return noop;
4446
+ }
4447
+ this._onceCache.add(tag);
4448
+ }
4449
+ return this._emit(type, normalized);
4450
+ }
4451
+ _shouldLog(logLevel) {
4452
+ return this.getLevel() >= normalizeLogLevel(logLevel);
4453
+ }
4454
+ _getOnceTag(tag) {
4455
+ if (tag === void 0) {
4456
+ return void 0;
4457
+ }
4458
+ try {
4459
+ return typeof tag === "string" ? tag : String(tag);
4460
+ } catch {
4461
+ return void 0;
4462
+ }
4463
+ }
4464
+ };
4333
4465
 
4334
4466
  // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
4335
4467
  function getStorage(type) {
@@ -4448,13 +4580,6 @@ var __exports__ = (() => {
4448
4580
  }
4449
4581
  }
4450
4582
 
4451
- // ../../node_modules/@probe.gl/log/dist/utils/assert.js
4452
- function assert3(condition, message) {
4453
- if (!condition) {
4454
- throw new Error(message || "Assertion failed");
4455
- }
4456
- }
4457
-
4458
4583
  // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
4459
4584
  function getHiResTimestamp() {
4460
4585
  let timestamp;
@@ -4469,7 +4594,7 @@ var __exports__ = (() => {
4469
4594
  return timestamp;
4470
4595
  }
4471
4596
 
4472
- // ../../node_modules/@probe.gl/log/dist/log.js
4597
+ // ../../node_modules/@probe.gl/log/dist/loggers/probe-log.js
4473
4598
  var originalConsole = {
4474
4599
  debug: isBrowser2() ? console.debug || console.log : console.log,
4475
4600
  log: console.log,
@@ -4481,12 +4606,9 @@ var __exports__ = (() => {
4481
4606
  enabled: true,
4482
4607
  level: 0
4483
4608
  };
4484
- function noop() {
4485
- }
4486
- var cache = {};
4487
- var ONCE = { once: true };
4488
- var Log = class {
4609
+ var ProbeLog = class extends BaseLog {
4489
4610
  constructor({ id } = { id: "" }) {
4611
+ super({ level: 0 });
4490
4612
  this.VERSION = VERSION;
4491
4613
  this._startTs = getHiResTimestamp();
4492
4614
  this._deltaTs = getHiResTimestamp();
@@ -4494,22 +4616,16 @@ var __exports__ = (() => {
4494
4616
  this.LOG_THROTTLE_TIMEOUT = 0;
4495
4617
  this.id = id;
4496
4618
  this.userData = {};
4497
- this._storage = new LocalStorage(`__probe-${this.id}__`, DEFAULT_LOG_CONFIGURATION);
4619
+ this._storage = new LocalStorage(`__probe-${this.id}__`, { [this.id]: DEFAULT_LOG_CONFIGURATION });
4498
4620
  this.timeStamp(`${this.id} started`);
4499
4621
  autobind(this);
4500
4622
  Object.seal(this);
4501
4623
  }
4502
- set level(newLevel) {
4503
- this.setLevel(newLevel);
4504
- }
4505
- get level() {
4506
- return this.getLevel();
4507
- }
4508
4624
  isEnabled() {
4509
- return this._storage.config.enabled;
4625
+ return this._getConfiguration().enabled;
4510
4626
  }
4511
4627
  getLevel() {
4512
- return this._storage.config.level;
4628
+ return this._getConfiguration().level;
4513
4629
  }
4514
4630
  /** @return milliseconds, with fractions */
4515
4631
  getTotal() {
@@ -4533,20 +4649,20 @@ var __exports__ = (() => {
4533
4649
  }
4534
4650
  // Configure
4535
4651
  enable(enabled = true) {
4536
- this._storage.setConfiguration({ enabled });
4652
+ this._updateConfiguration({ enabled });
4537
4653
  return this;
4538
4654
  }
4539
4655
  setLevel(level) {
4540
- this._storage.setConfiguration({ level });
4656
+ this._updateConfiguration({ level });
4541
4657
  return this;
4542
4658
  }
4543
4659
  /** return the current status of the setting */
4544
4660
  get(setting) {
4545
- return this._storage.config[setting];
4661
+ return this._getConfiguration()[setting];
4546
4662
  }
4547
4663
  // update the status of the setting
4548
4664
  set(setting, value) {
4549
- this._storage.setConfiguration({ [setting]: value });
4665
+ this._updateConfiguration({ [setting]: value });
4550
4666
  }
4551
4667
  /** Logs the current settings as a table */
4552
4668
  settings() {
@@ -4562,11 +4678,16 @@ var __exports__ = (() => {
4562
4678
  throw new Error(message || "Assertion failed");
4563
4679
  }
4564
4680
  }
4565
- warn(message) {
4566
- return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
4681
+ warn(message, ...args) {
4682
+ return this._log("warn", 0, message, args, {
4683
+ method: originalConsole.warn,
4684
+ once: true
4685
+ });
4567
4686
  }
4568
- error(message) {
4569
- return this._getLogFunction(0, message, originalConsole.error, arguments);
4687
+ error(message, ...args) {
4688
+ return this._log("error", 0, message, args, {
4689
+ method: originalConsole.error
4690
+ });
4570
4691
  }
4571
4692
  /** Print a deprecation warning */
4572
4693
  deprecated(oldUsage, newUsage) {
@@ -4576,50 +4697,63 @@ var __exports__ = (() => {
4576
4697
  removed(oldUsage, newUsage) {
4577
4698
  return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`);
4578
4699
  }
4579
- probe(logLevel, message) {
4580
- return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
4700
+ probe(logLevel, message, ...args) {
4701
+ return this._log("log", logLevel, message, args, {
4702
+ method: originalConsole.log,
4581
4703
  time: true,
4582
4704
  once: true
4583
4705
  });
4584
4706
  }
4585
- log(logLevel, message) {
4586
- return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
4707
+ log(logLevel, message, ...args) {
4708
+ return this._log("log", logLevel, message, args, {
4709
+ method: originalConsole.debug
4710
+ });
4587
4711
  }
4588
- info(logLevel, message) {
4589
- return this._getLogFunction(logLevel, message, console.info, arguments);
4712
+ info(logLevel, message, ...args) {
4713
+ return this._log("info", logLevel, message, args, { method: console.info });
4590
4714
  }
4591
- once(logLevel, message) {
4592
- return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
4715
+ once(logLevel, message, ...args) {
4716
+ return this._log("once", logLevel, message, args, {
4717
+ method: originalConsole.debug || originalConsole.info,
4718
+ once: true
4719
+ });
4593
4720
  }
4594
4721
  /** Logs an object as a table */
4595
4722
  table(logLevel, table, columns) {
4596
4723
  if (table) {
4597
- return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
4724
+ return this._log("table", logLevel, table, columns && [columns] || [], {
4725
+ method: console.table || noop,
4598
4726
  tag: getTableHeader(table)
4599
4727
  });
4600
4728
  }
4601
4729
  return noop;
4602
4730
  }
4603
4731
  time(logLevel, message) {
4604
- return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
4732
+ return this._log("time", logLevel, message, [], {
4733
+ method: console.time ? console.time : console.info
4734
+ });
4605
4735
  }
4606
4736
  timeEnd(logLevel, message) {
4607
- return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
4737
+ return this._log("time", logLevel, message, [], {
4738
+ method: console.timeEnd ? console.timeEnd : console.info
4739
+ });
4608
4740
  }
4609
4741
  timeStamp(logLevel, message) {
4610
- return this._getLogFunction(logLevel, message, console.timeStamp || noop);
4742
+ return this._log("time", logLevel, message, [], {
4743
+ method: console.timeStamp || noop
4744
+ });
4611
4745
  }
4612
4746
  group(logLevel, message, opts = { collapsed: false }) {
4613
- const options = normalizeArguments({ logLevel, message, opts });
4614
- const { collapsed } = opts;
4615
- options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
4616
- return this._getLogFunction(options);
4747
+ const method = (opts.collapsed ? console.groupCollapsed : console.group) || console.info;
4748
+ return this._log("group", logLevel, message, [], { method });
4617
4749
  }
4618
4750
  groupCollapsed(logLevel, message, opts = {}) {
4619
4751
  return this.group(logLevel, message, Object.assign({}, opts, { collapsed: true }));
4620
4752
  }
4621
4753
  groupEnd(logLevel) {
4622
- return this._getLogFunction(logLevel, "", console.groupEnd || noop);
4754
+ return this._log("groupEnd", logLevel, "", [], {
4755
+ method: console.groupEnd || noop
4756
+ });
4623
4757
  }
4624
4758
  // EXPERIMENTAL
4625
4759
  withGroup(logLevel, message, func) {
@@ -4635,78 +4769,34 @@ var __exports__ = (() => {
4635
4769
  console.trace();
4636
4770
  }
4637
4771
  }
4638
- // PRIVATE METHODS
4639
- /** Deduces log level from a variety of arguments */
4640
4772
  _shouldLog(logLevel) {
4641
- return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
4642
- }
4643
- _getLogFunction(logLevel, message, method, args, opts) {
4644
- if (this._shouldLog(logLevel)) {
4645
- opts = normalizeArguments({ logLevel, message, args, opts });
4646
- method = method || opts.method;
4647
- assert3(method);
4648
- opts.total = this.getTotal();
4649
- opts.delta = this.getDelta();
4650
- this._deltaTs = getHiResTimestamp();
4651
- const tag = opts.tag || opts.message;
4652
- if (opts.once && tag) {
4653
- if (!cache[tag]) {
4654
- cache[tag] = getHiResTimestamp();
4655
- } else {
4656
- return noop;
4657
- }
4658
- }
4659
- message = decorateMessage(this.id, opts.message, opts);
4660
- return method.bind(console, message, ...opts.args);
4661
- }
4662
- return noop;
4663
- }
4664
- };
4665
- Log.VERSION = VERSION;
4666
- function normalizeLogLevel(logLevel) {
4667
- if (!logLevel) {
4668
- return 0;
4773
+ return this.isEnabled() && super._shouldLog(logLevel);
4669
4774
  }
4670
- let resolvedLevel;
4671
- switch (typeof logLevel) {
4672
- case "number":
4673
- resolvedLevel = logLevel;
4674
- break;
4675
- case "object":
4676
- resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
4677
- break;
4678
- default:
4679
- return 0;
4680
- }
4681
- assert3(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
4682
- return resolvedLevel;
4683
- }
4684
- function normalizeArguments(opts) {
4685
- const { logLevel, message } = opts;
4686
- opts.logLevel = normalizeLogLevel(logLevel);
4687
- const args = opts.args ? Array.from(opts.args) : [];
4688
- while (args.length && args.shift() !== message) {
4775
+ _emit(_type, normalized) {
4776
+ const method = normalized.method;
4777
+ assert3(method);
4778
+ normalized.total = this.getTotal();
4779
+ normalized.delta = this.getDelta();
4780
+ this._deltaTs = getHiResTimestamp();
4781
+ const message = decorateMessage(this.id, normalized.message, normalized);
4782
+ return method.bind(console, message, ...normalized.args);
4689
4783
  }
4690
- switch (typeof logLevel) {
4691
- case "string":
4692
- case "function":
4693
- if (message !== void 0) {
4694
- args.unshift(message);
4695
- }
4696
- opts.message = logLevel;
4697
- break;
4698
- case "object":
4699
- Object.assign(opts, logLevel);
4700
- break;
4701
- default:
4784
+ _getConfiguration() {
4785
+ if (!this._storage.config[this.id]) {
4786
+ this._updateConfiguration(DEFAULT_LOG_CONFIGURATION);
4787
+ }
4788
+ return this._storage.config[this.id];
4702
4789
  }
4703
- if (typeof opts.message === "function") {
4704
- opts.message = opts.message();
4790
+ _updateConfiguration(configuration) {
4791
+ const currentConfiguration = this._storage.config[this.id] || {
4792
+ ...DEFAULT_LOG_CONFIGURATION
4793
+ };
4794
+ this._storage.setConfiguration({
4795
+ [this.id]: { ...currentConfiguration, ...configuration }
4796
+ });
4705
4797
  }
4706
- const messageType = typeof opts.message;
4707
- assert3(messageType === "string" || messageType === "object");
4708
- return Object.assign(opts, { args }, opts.opts);
4709
- }
4798
+ };
4799
+ ProbeLog.VERSION = VERSION;
4710
4800
  function decorateMessage(id, message, opts) {
4711
4801
  if (typeof message === "string") {
4712
4802
  const time = opts.time ? leftPad(formatTime(opts.total)) : "";
@@ -4728,7 +4818,10 @@ var __exports__ = (() => {
4728
4818
  globalThis.probe = {};
4729
4819
 
4730
4820
  // ../../node_modules/@probe.gl/log/dist/index.js
4731
- var dist_default = new Log({ id: "@probe.gl/log" });
4821
+ var dist_default = new ProbeLog({ id: "@probe.gl/log" });
4822
+
4823
+ // ../loader-utils/src/lib/javascript-utils/is-type.ts
4824
+ var isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
4732
4825
 
4733
4826
  // ../loader-utils/src/lib/module-utils/js-module-utils.ts
4734
4827
  function registerJSModules(modules) {
@@ -4745,14 +4838,16 @@ var __exports__ = (() => {
4745
4838
  var NPM_TAG = "beta";
4746
4839
 
4747
4840
  // ../worker-utils/src/lib/env-utils/version.ts
4841
+ var warningIssued = false;
4748
4842
  function getVersion() {
4749
4843
  if (!globalThis._loadersgl_?.version) {
4750
4844
  globalThis._loadersgl_ = globalThis._loadersgl_ || {};
4751
- if (typeof __VERSION__ === "undefined") {
4845
+ if (typeof __VERSION__ === "undefined" && !warningIssued) {
4752
4846
  console.warn(
4753
4847
  "loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
4754
4848
  );
4755
4849
  globalThis._loadersgl_.version = NPM_TAG;
4850
+ warningIssued = true;
4756
4851
  } else {
4757
4852
  globalThis._loadersgl_.version = __VERSION__;
4758
4853
  }
@@ -4790,6 +4885,16 @@ var __exports__ = (() => {
4790
4885
 
4791
4886
  // ../worker-utils/src/lib/library-utils/library-utils.ts
4792
4887
  var loadLibraryPromises = {};
4888
+ function extractLoadLibraryOptions(options = {}) {
4889
+ const useLocalLibraries = options.useLocalLibraries ?? options.core?.useLocalLibraries;
4890
+ const CDN = options.CDN ?? options.core?.CDN;
4891
+ const modules = options.modules;
4892
+ return {
4893
+ ...useLocalLibraries !== void 0 ? { useLocalLibraries } : {},
4894
+ ...CDN !== void 0 ? { CDN } : {},
4895
+ ...modules !== void 0 ? { modules } : {}
4896
+ };
4897
+ }
4793
4898
  async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
4794
4899
  if (moduleName) {
4795
4900
  libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
@@ -4799,6 +4904,9 @@ var __exports__ = (() => {
4799
4904
  return await loadLibraryPromises[libraryUrl];
4800
4905
  }
4801
4906
  function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
4907
+ if (options?.core) {
4908
+ throw new Error("loadLibrary: options.core must be pre-normalized");
4909
+ }
4802
4910
  if (!options.useLocalLibraries && library.startsWith("http")) {
4803
4911
  return library;
4804
4912
  }
@@ -4824,10 +4932,20 @@ var __exports__ = (() => {
4824
4932
  return await loadAsArrayBuffer(libraryUrl);
4825
4933
  }
4826
4934
  if (!isBrowser3) {
4935
+ const { requireFromFile } = globalThis.loaders || {};
4827
4936
  try {
4828
- const { requireFromFile } = globalThis.loaders || {};
4829
- return await requireFromFile?.(libraryUrl);
4937
+ const result = await requireFromFile?.(libraryUrl);
4938
+ if (result || !libraryUrl.includes("/dist/libs/")) {
4939
+ return result;
4940
+ }
4941
+ return await requireFromFile?.(libraryUrl.replace("/dist/libs/", "/src/libs/"));
4830
4942
  } catch (error) {
4943
+ if (libraryUrl.includes("/dist/libs/")) {
4944
+ try {
4945
+ return await requireFromFile?.(libraryUrl.replace("/dist/libs/", "/src/libs/"));
4946
+ } catch {
4947
+ }
4948
+ }
4831
4949
  console.error(error);
4832
4950
  return null;
4833
4951
  }
@@ -4863,7 +4981,14 @@ var __exports__ = (() => {
4863
4981
  const response = await fetch(url);
4864
4982
  return await response.arrayBuffer();
4865
4983
  }
4866
- return await readFileAsArrayBuffer(url);
4984
+ try {
4985
+ return await readFileAsArrayBuffer(url);
4986
+ } catch {
4987
+ if (url.includes("/dist/libs/")) {
4988
+ return await readFileAsArrayBuffer(url.replace("/dist/libs/", "/src/libs/"));
4989
+ }
4990
+ throw new Error(`Failed to load ArrayBuffer from ${url}`);
4991
+ }
4867
4992
  }
4868
4993
  async function loadAsText(url) {
4869
4994
  const { readFileAsText } = globalThis.loaders || {};
@@ -4871,7 +4996,14 @@ var __exports__ = (() => {
4871
4996
  const response = await fetch(url);
4872
4997
  return await response.text();
4873
4998
  }
4874
- return await readFileAsText(url);
4999
+ try {
5000
+ return await readFileAsText(url);
5001
+ } catch {
5002
+ if (url.includes("/dist/libs/")) {
5003
+ return await readFileAsText(url.replace("/dist/libs/", "/src/libs/"));
5004
+ }
5005
+ throw new Error(`Failed to load text from ${url}`);
5006
+ }
4875
5007
  }
4876
5008
 
4877
5009
  // ../loader-utils/src/lib/binary-utils/get-first-characters.ts
@@ -5019,10 +5151,26 @@ var __exports__ = (() => {
5019
5151
  async function concatenateArrayBuffersAsync(asyncIterator) {
5020
5152
  const arrayBuffers = [];
5021
5153
  for await (const chunk of asyncIterator) {
5022
- arrayBuffers.push(chunk);
5154
+ arrayBuffers.push(copyToArrayBuffer(chunk));
5023
5155
  }
5024
5156
  return concatenateArrayBuffers(...arrayBuffers);
5025
5157
  }
5158
+ function copyToArrayBuffer(chunk) {
5159
+ if (chunk instanceof ArrayBuffer) {
5160
+ return chunk;
5161
+ }
5162
+ if (ArrayBuffer.isView(chunk)) {
5163
+ const { buffer, byteOffset, byteLength } = chunk;
5164
+ return copyFromBuffer(buffer, byteOffset, byteLength);
5165
+ }
5166
+ return copyFromBuffer(chunk);
5167
+ }
5168
+ function copyFromBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
5169
+ const view = new Uint8Array(buffer, byteOffset, byteLength);
5170
+ const copy4 = new Uint8Array(view.length);
5171
+ copy4.set(view);
5172
+ return copy4.buffer;
5173
+ }
5026
5174
 
5027
5175
  // ../loader-utils/src/lib/node/buffer.browser.ts
5028
5176
  function toArrayBuffer(buffer) {
@@ -5040,11 +5188,15 @@ var __exports__ = (() => {
5040
5188
  if (data instanceof ArrayBuffer) {
5041
5189
  return data;
5042
5190
  }
5191
+ if (isSharedArrayBuffer(data)) {
5192
+ return copyToArrayBuffer2(data);
5193
+ }
5043
5194
  if (ArrayBuffer.isView(data)) {
5195
+ const buffer = data.buffer;
5044
5196
  if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
5045
- return data.buffer;
5197
+ return buffer;
5046
5198
  }
5047
- return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
5199
+ return buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
5048
5200
  }
5049
5201
  if (typeof data === "string") {
5050
5202
  const text = data;
@@ -5056,6 +5208,25 @@ var __exports__ = (() => {
5056
5208
  }
5057
5209
  throw new Error("toArrayBuffer");
5058
5210
  }
5211
+ function ensureArrayBuffer(bufferSource) {
5212
+ if (bufferSource instanceof ArrayBuffer) {
5213
+ return bufferSource;
5214
+ }
5215
+ if (isSharedArrayBuffer(bufferSource)) {
5216
+ return copyToArrayBuffer2(bufferSource);
5217
+ }
5218
+ const { buffer, byteOffset, byteLength } = bufferSource;
5219
+ if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
5220
+ return buffer;
5221
+ }
5222
+ return copyToArrayBuffer2(buffer, byteOffset, byteLength);
5223
+ }
5224
+ function copyToArrayBuffer2(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
5225
+ const view = new Uint8Array(buffer, byteOffset, byteLength);
5226
+ const copy4 = new Uint8Array(view.length);
5227
+ copy4.set(view);
5228
+ return copy4.buffer;
5229
+ }
5059
5230
 
5060
5231
  // ../loader-utils/src/lib/node/promisify.ts
5061
5232
  function promisify1(fn) {
@@ -5085,7 +5256,7 @@ var __exports__ = (() => {
5085
5256
  // ../loader-utils/src/lib/path-utils/path.ts
5086
5257
  function filename(url) {
5087
5258
  const slashIndex = url ? url.lastIndexOf("/") : -1;
5088
- return slashIndex >= 0 ? url.substr(slashIndex + 1) : "";
5259
+ return slashIndex >= 0 ? url.substr(slashIndex + 1) : url;
5089
5260
  }
5090
5261
  function dirname(url) {
5091
5262
  const slashIndex = url ? url.lastIndexOf("/") : -1;
@@ -5207,6 +5378,33 @@ var __exports__ = (() => {
5207
5378
  return res;
5208
5379
  }
5209
5380
 
5381
+ // ../loader-utils/src/lib/files/blob-file.ts
5382
+ var BlobFile = class {
5383
+ handle;
5384
+ size;
5385
+ bigsize;
5386
+ url;
5387
+ constructor(blob) {
5388
+ this.handle = blob instanceof ArrayBuffer ? new Blob([blob]) : blob;
5389
+ this.size = blob instanceof ArrayBuffer ? blob.byteLength : blob.size;
5390
+ this.bigsize = BigInt(this.size);
5391
+ this.url = blob instanceof File ? blob.name : "";
5392
+ }
5393
+ async close() {
5394
+ }
5395
+ async stat() {
5396
+ return {
5397
+ size: this.handle.size,
5398
+ bigsize: BigInt(this.handle.size),
5399
+ isDirectory: false
5400
+ };
5401
+ }
5402
+ async read(start, length4) {
5403
+ const arrayBuffer = await this.handle.slice(Number(start), Number(start) + Number(length4)).arrayBuffer();
5404
+ return arrayBuffer;
5405
+ }
5406
+ };
5407
+
5210
5408
  // ../loader-utils/src/lib/files/node-file-facade.ts
5211
5409
  var NOT_IMPLEMENTED = new Error("Not implemented");
5212
5410
  var NodeFileFacade = class {
@@ -5235,173 +5433,16 @@ var __exports__ = (() => {
5235
5433
  async stat() {
5236
5434
  throw NOT_IMPLEMENTED;
5237
5435
  }
5238
- /** Truncates the file descriptor. Only available on NodeFile. */
5239
- async truncate(length4) {
5240
- throw NOT_IMPLEMENTED;
5241
- }
5242
- /** Append data to a file. Only available on NodeFile. */
5243
- async append(data) {
5244
- throw NOT_IMPLEMENTED;
5245
- }
5246
- /** Close the file */
5247
- async close() {
5248
- }
5249
- };
5250
-
5251
- // ../loader-utils/src/lib/file-provider/file-provider-interface.ts
5252
- var isFileProvider = (fileProvider) => {
5253
- return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
5254
- };
5255
-
5256
- // ../loader-utils/src/lib/file-provider/file-handle-file.ts
5257
- var FileHandleFile = class {
5258
- /** The FileHandle from which data is provided */
5259
- file;
5260
- /** Create a new FileHandleFile */
5261
- constructor(path, append = false) {
5262
- this.file = new NodeFileFacade(path, append ? "a+" : "r");
5263
- }
5264
- /**
5265
- * Truncates the file descriptor.
5266
- * @param length desired file lenght
5267
- */
5268
- async truncate(length4) {
5269
- await this.file.truncate(length4);
5270
- }
5271
- /**
5272
- * Append data to a file.
5273
- * @param buffer data to append
5274
- */
5275
- async append(buffer) {
5276
- await this.file.append(buffer);
5277
- }
5278
- /** Close file */
5279
- async destroy() {
5280
- await this.file.close();
5281
- }
5282
- /**
5283
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
5284
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5285
- */
5286
- async getUint8(offset) {
5287
- const arrayBuffer = await this.file.read(offset, 1);
5288
- const val = new Uint8Array(arrayBuffer).at(0);
5289
- if (val === void 0) {
5290
- throw new Error("something went wrong");
5291
- }
5292
- return val;
5293
- }
5294
- /**
5295
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
5296
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5297
- */
5298
- async getUint16(offset) {
5299
- const arrayBuffer = await this.file.read(offset, 2);
5300
- const val = new Uint16Array(arrayBuffer).at(0);
5301
- if (val === void 0) {
5302
- throw new Error("something went wrong");
5303
- }
5304
- return val;
5305
- }
5306
- /**
5307
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
5308
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5309
- */
5310
- async getUint32(offset) {
5311
- const arrayBuffer = await this.file.read(offset, 4);
5312
- const val = new Uint32Array(arrayBuffer).at(0);
5313
- if (val === void 0) {
5314
- throw new Error("something went wrong");
5315
- }
5316
- return val;
5317
- }
5318
- /**
5319
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
5320
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5321
- */
5322
- async getBigUint64(offset) {
5323
- const arrayBuffer = await this.file.read(offset, 8);
5324
- const val = new BigInt64Array(arrayBuffer).at(0);
5325
- if (val === void 0) {
5326
- throw new Error("something went wrong");
5327
- }
5328
- return val;
5329
- }
5330
- /**
5331
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
5332
- * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
5333
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
5334
- */
5335
- async slice(startOffset, endOffset) {
5336
- const bigLength = endOffset - startOffset;
5337
- if (bigLength > Number.MAX_SAFE_INTEGER) {
5338
- throw new Error("too big slice");
5339
- }
5340
- const length4 = Number(bigLength);
5341
- return await this.file.read(startOffset, length4);
5342
- }
5343
- /**
5344
- * the length (in bytes) of the data.
5345
- */
5346
- get length() {
5347
- return this.file.bigsize;
5348
- }
5349
- };
5350
-
5351
- // ../loader-utils/src/lib/file-provider/data-view-file.ts
5352
- var toNumber = (bigint) => {
5353
- if (bigint > Number.MAX_SAFE_INTEGER) {
5354
- throw new Error("Offset is out of bounds");
5355
- }
5356
- return Number(bigint);
5357
- };
5358
- var DataViewFile = class {
5359
- /** The DataView from which data is provided */
5360
- file;
5361
- constructor(file) {
5362
- this.file = file;
5363
- }
5364
- async destroy() {
5365
- }
5366
- /**
5367
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
5368
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5369
- */
5370
- async getUint8(offset) {
5371
- return this.file.getUint8(toNumber(offset));
5372
- }
5373
- /**
5374
- * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
5375
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5376
- */
5377
- async getUint16(offset) {
5378
- return this.file.getUint16(toNumber(offset), true);
5379
- }
5380
- /**
5381
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
5382
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5383
- */
5384
- async getUint32(offset) {
5385
- return this.file.getUint32(toNumber(offset), true);
5386
- }
5387
- /**
5388
- * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
5389
- * @param offset The offset, in bytes, from the start of the file where to read the data.
5390
- */
5391
- async getBigUint64(offset) {
5392
- return this.file.getBigUint64(toNumber(offset), true);
5436
+ /** Truncates the file descriptor. Only available on NodeFile. */
5437
+ async truncate(length4) {
5438
+ throw NOT_IMPLEMENTED;
5393
5439
  }
5394
- /**
5395
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
5396
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
5397
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
5398
- */
5399
- async slice(startOffset, endOffset) {
5400
- return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
5440
+ /** Append data to a file. Only available on NodeFile. */
5441
+ async append(data) {
5442
+ throw NOT_IMPLEMENTED;
5401
5443
  }
5402
- /** the length (in bytes) of the data. */
5403
- get length() {
5404
- return BigInt(this.file.byteLength);
5444
+ /** Close the file */
5445
+ async close() {
5405
5446
  }
5406
5447
  };
5407
5448
 
@@ -10936,21 +10977,32 @@ var __exports__ = (() => {
10936
10977
  [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`
10937
10978
  };
10938
10979
  var loadDecoderPromise;
10939
- async function loadDracoDecoderModule(options) {
10980
+ async function loadDracoDecoderModule(options = {}, type) {
10940
10981
  const modules = options.modules || {};
10941
10982
  if (modules.draco3d) {
10942
10983
  loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
10943
10984
  return { draco };
10944
10985
  });
10945
10986
  } else {
10946
- loadDecoderPromise ||= loadDracoDecoder(options);
10987
+ loadDecoderPromise ||= loadDracoDecoder(options, type);
10947
10988
  }
10948
10989
  return await loadDecoderPromise;
10949
10990
  }
10950
- async function loadDracoDecoder(options) {
10991
+ function getLibraryExport(library, exportName) {
10992
+ if (library && typeof library === "object") {
10993
+ if (library.default) {
10994
+ return library.default;
10995
+ }
10996
+ if (library[exportName]) {
10997
+ return library[exportName];
10998
+ }
10999
+ }
11000
+ return library;
11001
+ }
11002
+ async function loadDracoDecoder(options, type) {
10951
11003
  let DracoDecoderModule;
10952
11004
  let wasmBinary;
10953
- switch (options.draco && options.draco.decoderType) {
11005
+ switch (type) {
10954
11006
  case "js":
10955
11007
  DracoDecoderModule = await loadLibrary(
10956
11008
  DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
@@ -10961,25 +11013,52 @@ var __exports__ = (() => {
10961
11013
  break;
10962
11014
  case "wasm":
10963
11015
  default:
10964
- [DracoDecoderModule, wasmBinary] = await Promise.all([
10965
- await loadLibrary(
10966
- DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
10967
- "draco",
10968
- options,
10969
- DRACO_EXTERNAL_LIBRARIES.DECODER
10970
- ),
10971
- await loadLibrary(
10972
- DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
10973
- "draco",
10974
- options,
10975
- DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
10976
- )
10977
- ]);
10978
- }
11016
+ try {
11017
+ [DracoDecoderModule, wasmBinary] = await Promise.all([
11018
+ await loadLibrary(
11019
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
11020
+ "draco",
11021
+ options,
11022
+ DRACO_EXTERNAL_LIBRARIES.DECODER
11023
+ ),
11024
+ await loadLibrary(
11025
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
11026
+ "draco",
11027
+ options,
11028
+ DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
11029
+ )
11030
+ ]);
11031
+ } catch {
11032
+ DracoDecoderModule = null;
11033
+ wasmBinary = null;
11034
+ }
11035
+ }
11036
+ DracoDecoderModule = getLibraryExport(DracoDecoderModule, "DracoDecoderModule");
10979
11037
  DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
11038
+ if (!DracoDecoderModule && !isBrowser3) {
11039
+ [DracoDecoderModule, wasmBinary] = await Promise.all([
11040
+ await loadLibrary(
11041
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
11042
+ "draco",
11043
+ { ...options, useLocalLibraries: true },
11044
+ DRACO_EXTERNAL_LIBRARIES.DECODER
11045
+ ),
11046
+ await loadLibrary(
11047
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
11048
+ "draco",
11049
+ { ...options, useLocalLibraries: true },
11050
+ DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
11051
+ )
11052
+ ]);
11053
+ DracoDecoderModule = getLibraryExport(DracoDecoderModule, "DracoDecoderModule");
11054
+ DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
11055
+ }
10980
11056
  return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
10981
11057
  }
10982
11058
  function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
11059
+ if (typeof DracoDecoderModule !== "function") {
11060
+ throw new Error("DracoDecoderModule could not be loaded");
11061
+ }
10983
11062
  const options = {};
10984
11063
  if (wasmBinary) {
10985
11064
  options.wasmBinary = wasmBinary;
@@ -11588,7 +11667,6 @@ var __exports__ = (() => {
11588
11667
  draco: {
11589
11668
  decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
11590
11669
  // 'js' for IE11
11591
- libraryPath: "libs/",
11592
11670
  extraAttributes: {},
11593
11671
  attributeNameEntry: void 0
11594
11672
  }
@@ -11599,7 +11677,10 @@ var __exports__ = (() => {
11599
11677
  parse
11600
11678
  };
11601
11679
  async function parse(arrayBuffer, options) {
11602
- const { draco } = await loadDracoDecoderModule(options);
11680
+ const { draco } = await loadDracoDecoderModule(
11681
+ extractLoadLibraryOptions(options),
11682
+ options?.draco?.decoderType || "wasm"
11683
+ );
11603
11684
  const dracoParser = new DracoParser(draco);
11604
11685
  try {
11605
11686
  return dracoParser.parseSync(arrayBuffer, options?.draco);
@@ -11738,8 +11819,9 @@ var __exports__ = (() => {
11738
11819
  if (length4 === void 0) {
11739
11820
  length4 = (buffer.byteLength - byteOffset) / GLType.getByteSize(glType);
11740
11821
  }
11822
+ const arrayBuffer = ArrayBuffer.isView(buffer) ? buffer.buffer : buffer;
11741
11823
  const ArrayType = GLType.getArrayType(glType);
11742
- return new ArrayType(buffer, byteOffset, length4);
11824
+ return new ArrayType(arrayBuffer, byteOffset, length4);
11743
11825
  }
11744
11826
  };
11745
11827
 
@@ -11871,7 +11953,17 @@ var __exports__ = (() => {
11871
11953
  const cachedTypedArrays = this._cachedTypedArrays;
11872
11954
  let typedArray = cachedTypedArrays[propertyName];
11873
11955
  if (!typedArray) {
11874
- typedArray = GLType.createTypedArray(componentType, array);
11956
+ if (ArrayBuffer.isView(array)) {
11957
+ const byteOffset = array.byteOffset;
11958
+ const byteLength = array.byteLength;
11959
+ const elementCount = byteLength / GLType.getByteSize(componentType);
11960
+ typedArray = GLType.createTypedArray(componentType, array.buffer, byteOffset, elementCount);
11961
+ } else if (array instanceof ArrayBuffer) {
11962
+ typedArray = GLType.createTypedArray(componentType, array);
11963
+ } else {
11964
+ const ArrayType = GLType.getArrayType(componentType);
11965
+ typedArray = new ArrayType(array);
11966
+ }
11875
11967
  cachedTypedArrays[propertyName] = typedArray;
11876
11968
  }
11877
11969
  return typedArray;
@@ -13003,7 +13095,6 @@ var __exports__ = (() => {
13003
13095
  }
13004
13096
 
13005
13097
  // ../images/src/lib/parsers/parse-to-image-bitmap.ts
13006
- var EMPTY_OBJECT = {};
13007
13098
  var imagebitmapOptionsSupported = true;
13008
13099
  async function parseToImageBitmap(arrayBuffer, options, url) {
13009
13100
  let blob;
@@ -13031,8 +13122,13 @@ var __exports__ = (() => {
13031
13122
  return await createImageBitmap(blob);
13032
13123
  }
13033
13124
  function isEmptyObject(object) {
13034
- for (const key in object || EMPTY_OBJECT) {
13035
- return false;
13125
+ if (!object) {
13126
+ return true;
13127
+ }
13128
+ for (const key in object) {
13129
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
13130
+ return false;
13131
+ }
13036
13132
  }
13037
13133
  return true;
13038
13134
  }
@@ -14053,7 +14149,7 @@ var __exports__ = (() => {
14053
14149
  buffer = bufferArray.slice(offset, offset + byteLength).buffer;
14054
14150
  offset = 0;
14055
14151
  }
14056
- return new ArrayType(buffer, offset, length4);
14152
+ return new ArrayType(ensureArrayBuffer(buffer), offset, length4);
14057
14153
  }
14058
14154
  function getPrimitiveTextureData(scenegraph, textureInfo, primitive) {
14059
14155
  const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`;
@@ -14811,7 +14907,7 @@ var __exports__ = (() => {
14811
14907
  }
14812
14908
  function createBufferView(typedArray, scenegraph) {
14813
14909
  scenegraph.gltf.buffers.push({
14814
- arrayBuffer: typedArray.buffer,
14910
+ arrayBuffer: ensureArrayBuffer(typedArray.buffer),
14815
14911
  byteOffset: typedArray.byteOffset,
14816
14912
  byteLength: typedArray.byteLength
14817
14913
  });
@@ -15149,104 +15245,117 @@ var __exports__ = (() => {
15149
15245
  }
15150
15246
 
15151
15247
  // ../textures/src/lib/gl-extensions.ts
15152
- var GL_EXTENSIONS_CONSTANTS = {
15153
- // WEBGL_compressed_texture_s3tc
15154
- COMPRESSED_RGB_S3TC_DXT1_EXT: 33776,
15155
- COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777,
15156
- COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778,
15157
- COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779,
15158
- // WEBGL_compressed_texture_es3
15159
- COMPRESSED_R11_EAC: 37488,
15160
- COMPRESSED_SIGNED_R11_EAC: 37489,
15161
- COMPRESSED_RG11_EAC: 37490,
15162
- COMPRESSED_SIGNED_RG11_EAC: 37491,
15163
- COMPRESSED_RGB8_ETC2: 37492,
15164
- COMPRESSED_RGBA8_ETC2_EAC: 37493,
15165
- COMPRESSED_SRGB8_ETC2: 37494,
15166
- COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495,
15167
- COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496,
15168
- COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497,
15169
- // WEBGL_compressed_texture_pvrtc
15170
- COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840,
15171
- COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842,
15172
- COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841,
15173
- COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843,
15174
- // WEBGL_compressed_texture_etc1
15175
- COMPRESSED_RGB_ETC1_WEBGL: 36196,
15176
- // WEBGL_compressed_texture_atc
15177
- COMPRESSED_RGB_ATC_WEBGL: 35986,
15178
- COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987,
15179
- COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798,
15180
- // WEBGL_compressed_texture_astc
15181
- COMPRESSED_RGBA_ASTC_4X4_KHR: 37808,
15182
- COMPRESSED_RGBA_ASTC_5X4_KHR: 37809,
15183
- COMPRESSED_RGBA_ASTC_5X5_KHR: 37810,
15184
- COMPRESSED_RGBA_ASTC_6X5_KHR: 37811,
15185
- COMPRESSED_RGBA_ASTC_6X6_KHR: 37812,
15186
- COMPRESSED_RGBA_ASTC_8X5_KHR: 37813,
15187
- COMPRESSED_RGBA_ASTC_8X6_KHR: 37814,
15188
- COMPRESSED_RGBA_ASTC_8X8_KHR: 37815,
15189
- COMPRESSED_RGBA_ASTC_10X5_KHR: 37816,
15190
- COMPRESSED_RGBA_ASTC_10X6_KHR: 37817,
15191
- COMPRESSED_RGBA_ASTC_10X8_KHR: 37818,
15192
- COMPRESSED_RGBA_ASTC_10X10_KHR: 37819,
15193
- COMPRESSED_RGBA_ASTC_12X10_KHR: 37820,
15194
- COMPRESSED_RGBA_ASTC_12X12_KHR: 37821,
15195
- COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840,
15196
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841,
15197
- COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842,
15198
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843,
15199
- COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844,
15200
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845,
15201
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846,
15202
- COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847,
15203
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848,
15204
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849,
15205
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850,
15206
- COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851,
15207
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852,
15208
- COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853,
15209
- // EXT_texture_compression_rgtc
15210
- COMPRESSED_RED_RGTC1_EXT: 36283,
15211
- COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284,
15212
- COMPRESSED_RED_GREEN_RGTC2_EXT: 36285,
15213
- COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286,
15214
- // WEBGL_compressed_texture_s3tc_srgb
15215
- COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916,
15216
- COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917,
15217
- COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918,
15218
- COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919
15219
- };
15248
+ var GL_RGBA4 = 32854;
15249
+ var GL_RGBA8 = 32856;
15250
+ var GL_RGB565 = 36194;
15251
+ var GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 33776;
15252
+ var GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779;
15253
+ var GL_COMPRESSED_RGBA8_ETC2_EAC = 37493;
15254
+ var GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840;
15255
+ var GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842;
15256
+ var GL_COMPRESSED_RGB_ETC1_WEBGL = 36196;
15257
+ var GL_COMPRESSED_RGB_ATC_WEBGL = 35986;
15258
+ var GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798;
15259
+ var GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 37808;
15260
+ var GL_COMPRESSED_RED_RGTC1_EXT = 36283;
15261
+ var GL_COMPRESSED_RED_GREEN_RGTC2_EXT = 36285;
15262
+ var GL_COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492;
15220
15263
 
15221
- // ../textures/src/lib/utils/texture-formats.ts
15264
+ // ../textures/src/lib/utils/detect-supported-texture-formats.ts
15222
15265
  var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"];
15223
- var WEBGL_EXTENSIONS = {
15266
+ var WEBGL_TEXTURE_FORMATS = {
15224
15267
  /* eslint-disable camelcase */
15225
- WEBGL_compressed_texture_s3tc: "dxt",
15226
- WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb",
15227
- WEBGL_compressed_texture_etc1: "etc1",
15228
- WEBGL_compressed_texture_etc: "etc2",
15229
- WEBGL_compressed_texture_pvrtc: "pvrtc",
15230
- WEBGL_compressed_texture_atc: "atc",
15231
- WEBGL_compressed_texture_astc: "astc",
15232
- EXT_texture_compression_rgtc: "rgtc"
15268
+ WEBGL_compressed_texture_s3tc: [
15269
+ "bc1-rgb-unorm-webgl",
15270
+ "bc1-rgba-unorm",
15271
+ "bc2-rgba-unorm",
15272
+ "bc3-rgba-unorm"
15273
+ ],
15274
+ WEBGL_compressed_texture_s3tc_srgb: [
15275
+ "bc1-rgb-unorm-srgb-webgl",
15276
+ "bc1-rgba-unorm-srgb",
15277
+ "bc2-rgba-unorm-srgb",
15278
+ "bc3-rgba-unorm-srgb"
15279
+ ],
15280
+ EXT_texture_compression_rgtc: ["bc4-r-unorm", "bc4-r-snorm", "bc5-rg-unorm", "bc5-rg-snorm"],
15281
+ EXT_texture_compression_bptc: [
15282
+ "bc6h-rgb-ufloat",
15283
+ "bc6h-rgb-float",
15284
+ "bc7-rgba-unorm",
15285
+ "bc7-rgba-unorm-srgb"
15286
+ ],
15287
+ WEBGL_compressed_texture_etc1: ["etc1-rgb-unorm-webgl"],
15288
+ WEBGL_compressed_texture_etc: [
15289
+ "etc2-rgb8unorm",
15290
+ "etc2-rgb8unorm-srgb",
15291
+ "etc2-rgb8a1unorm",
15292
+ "etc2-rgb8a1unorm-srgb",
15293
+ "etc2-rgba8unorm",
15294
+ "etc2-rgba8unorm-srgb",
15295
+ "eac-r11unorm",
15296
+ "eac-r11snorm",
15297
+ "eac-rg11unorm",
15298
+ "eac-rg11snorm"
15299
+ ],
15300
+ WEBGL_compressed_texture_pvrtc: [
15301
+ "pvrtc-rgb4unorm-webgl",
15302
+ "pvrtc-rgba4unorm-webgl",
15303
+ "pvrtc-rgb2unorm-webgl",
15304
+ "pvrtc-rgba2unorm-webgl"
15305
+ ],
15306
+ WEBGL_compressed_texture_atc: [
15307
+ "atc-rgb-unorm-webgl",
15308
+ "atc-rgba-unorm-webgl",
15309
+ "atc-rgbai-unorm-webgl"
15310
+ ],
15311
+ WEBGL_compressed_texture_astc: [
15312
+ "astc-4x4-unorm",
15313
+ "astc-4x4-unorm-srgb",
15314
+ "astc-5x4-unorm",
15315
+ "astc-5x4-unorm-srgb",
15316
+ "astc-5x5-unorm",
15317
+ "astc-5x5-unorm-srgb",
15318
+ "astc-6x5-unorm",
15319
+ "astc-6x5-unorm-srgb",
15320
+ "astc-6x6-unorm",
15321
+ "astc-6x6-unorm-srgb",
15322
+ "astc-8x5-unorm",
15323
+ "astc-8x5-unorm-srgb",
15324
+ "astc-8x6-unorm",
15325
+ "astc-8x6-unorm-srgb",
15326
+ "astc-8x8-unorm",
15327
+ "astc-8x8-unorm-srgb",
15328
+ "astc-10x5-unorm",
15329
+ "astc-10x5-unorm-srgb",
15330
+ "astc-10x6-unorm",
15331
+ "astc-10x6-unorm-srgb",
15332
+ "astc-10x8-unorm",
15333
+ "astc-10x8-unorm-srgb",
15334
+ "astc-10x10-unorm",
15335
+ "astc-10x10-unorm-srgb",
15336
+ "astc-12x10-unorm",
15337
+ "astc-12x10-unorm-srgb",
15338
+ "astc-12x12-unorm",
15339
+ "astc-12x12-unorm-srgb"
15340
+ ]
15233
15341
  /* eslint-enable camelcase */
15234
15342
  };
15235
- var formats = null;
15236
- function getSupportedGPUTextureFormats(gl) {
15237
- if (!formats) {
15343
+ var textureFormats = null;
15344
+ function detectSupportedTextureFormats(gl) {
15345
+ if (!textureFormats) {
15238
15346
  gl = gl || getWebGLContext() || void 0;
15239
- formats = /* @__PURE__ */ new Set();
15347
+ textureFormats = /* @__PURE__ */ new Set();
15240
15348
  for (const prefix of BROWSER_PREFIXES) {
15241
- for (const extension in WEBGL_EXTENSIONS) {
15349
+ for (const extension in WEBGL_TEXTURE_FORMATS) {
15242
15350
  if (gl && gl.getExtension(`${prefix}${extension}`)) {
15243
- const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
15244
- formats.add(gpuTextureFormat);
15351
+ for (const textureFormat of WEBGL_TEXTURE_FORMATS[extension]) {
15352
+ textureFormats.add(textureFormat);
15353
+ }
15245
15354
  }
15246
15355
  }
15247
15356
  }
15248
15357
  }
15249
- return formats;
15358
+ return textureFormats;
15250
15359
  }
15251
15360
  function getWebGLContext() {
15252
15361
  try {
@@ -15291,73 +15400,154 @@ var __exports__ = (() => {
15291
15400
  }
15292
15401
 
15293
15402
  // ../textures/src/lib/parsers/parse-basis.ts
15294
- var OutputFormat = {
15403
+ var basisTranscodingLock = Promise.resolve();
15404
+ var BASIS_FORMAT_TO_OUTPUT_OPTIONS = {
15295
15405
  etc1: {
15296
15406
  basisFormat: 0,
15297
15407
  compressed: true,
15298
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
15408
+ format: GL_COMPRESSED_RGB_ETC1_WEBGL,
15409
+ textureFormat: "etc1-rgb-unorm-webgl"
15410
+ },
15411
+ etc2: {
15412
+ basisFormat: 1,
15413
+ compressed: true,
15414
+ format: GL_COMPRESSED_RGBA8_ETC2_EAC,
15415
+ textureFormat: "etc2-rgba8unorm"
15299
15416
  },
15300
- etc2: { basisFormat: 1, compressed: true },
15301
15417
  bc1: {
15302
15418
  basisFormat: 2,
15303
15419
  compressed: true,
15304
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
15420
+ format: GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
15421
+ textureFormat: "bc1-rgb-unorm-webgl"
15305
15422
  },
15306
15423
  bc3: {
15307
15424
  basisFormat: 3,
15308
15425
  compressed: true,
15309
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
15426
+ format: GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
15427
+ textureFormat: "bc3-rgba-unorm"
15428
+ },
15429
+ bc4: {
15430
+ basisFormat: 4,
15431
+ compressed: true,
15432
+ format: GL_COMPRESSED_RED_RGTC1_EXT,
15433
+ textureFormat: "bc4-r-unorm"
15434
+ },
15435
+ bc5: {
15436
+ basisFormat: 5,
15437
+ compressed: true,
15438
+ format: GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
15439
+ textureFormat: "bc5-rg-unorm"
15440
+ },
15441
+ "bc7-m6-opaque-only": {
15442
+ basisFormat: 6,
15443
+ compressed: true,
15444
+ format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
15445
+ textureFormat: "bc7-rgba-unorm"
15446
+ },
15447
+ "bc7-m5": {
15448
+ basisFormat: 7,
15449
+ compressed: true,
15450
+ format: GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
15451
+ textureFormat: "bc7-rgba-unorm"
15310
15452
  },
15311
- bc4: { basisFormat: 4, compressed: true },
15312
- bc5: { basisFormat: 5, compressed: true },
15313
- "bc7-m6-opaque-only": { basisFormat: 6, compressed: true },
15314
- "bc7-m5": { basisFormat: 7, compressed: true },
15315
15453
  "pvrtc1-4-rgb": {
15316
15454
  basisFormat: 8,
15317
15455
  compressed: true,
15318
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
15456
+ format: GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
15457
+ textureFormat: "pvrtc-rgb4unorm-webgl"
15319
15458
  },
15320
15459
  "pvrtc1-4-rgba": {
15321
15460
  basisFormat: 9,
15322
15461
  compressed: true,
15323
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
15462
+ format: GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
15463
+ textureFormat: "pvrtc-rgba4unorm-webgl"
15324
15464
  },
15325
15465
  "astc-4x4": {
15326
15466
  basisFormat: 10,
15327
15467
  compressed: true,
15328
- format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
15468
+ format: GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
15469
+ textureFormat: "astc-4x4-unorm"
15470
+ },
15471
+ "atc-rgb": {
15472
+ basisFormat: 11,
15473
+ compressed: true,
15474
+ format: GL_COMPRESSED_RGB_ATC_WEBGL,
15475
+ textureFormat: "atc-rgb-unorm-webgl"
15476
+ },
15477
+ "atc-rgba-interpolated-alpha": {
15478
+ basisFormat: 12,
15479
+ compressed: true,
15480
+ format: GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
15481
+ textureFormat: "atc-rgbai-unorm-webgl"
15482
+ },
15483
+ rgba32: {
15484
+ basisFormat: 13,
15485
+ compressed: false,
15486
+ format: GL_RGBA8,
15487
+ textureFormat: "rgba8unorm"
15488
+ },
15489
+ rgb565: {
15490
+ basisFormat: 14,
15491
+ compressed: false,
15492
+ format: GL_RGB565,
15493
+ textureFormat: "rgb565unorm-webgl"
15329
15494
  },
15330
- "atc-rgb": { basisFormat: 11, compressed: true },
15331
- "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true },
15332
- rgba32: { basisFormat: 13, compressed: false },
15333
- rgb565: { basisFormat: 14, compressed: false },
15334
- bgr565: { basisFormat: 15, compressed: false },
15335
- rgba4444: { basisFormat: 16, compressed: false }
15495
+ bgr565: {
15496
+ basisFormat: 15,
15497
+ compressed: false,
15498
+ format: GL_RGB565,
15499
+ textureFormat: "rgb565unorm-webgl"
15500
+ },
15501
+ rgba4444: {
15502
+ basisFormat: 16,
15503
+ compressed: false,
15504
+ format: GL_RGBA4,
15505
+ textureFormat: "rgba4unorm-webgl"
15506
+ }
15336
15507
  };
15337
- async function parseBasis(data, options) {
15338
- if (options.basis.containerFormat === "auto") {
15339
- if (isKTX(data)) {
15340
- const fileConstructors = await loadBasisEncoderModule(options);
15341
- return parseKTX2File(fileConstructors.KTX2File, data, options);
15342
- }
15343
- const { BasisFile } = await loadBasisTranscoderModule(options);
15344
- return parseBasisFile(BasisFile, data, options);
15345
- }
15346
- switch (options.basis.module) {
15347
- case "encoder":
15348
- const fileConstructors = await loadBasisEncoderModule(options);
15349
- switch (options.basis.containerFormat) {
15350
- case "ktx2":
15351
- return parseKTX2File(fileConstructors.KTX2File, data, options);
15352
- case "basis":
15353
- default:
15354
- return parseBasisFile(fileConstructors.BasisFile, data, options);
15508
+ var BASIS_FORMATS = Object.freeze(
15509
+ Object.keys(BASIS_FORMAT_TO_OUTPUT_OPTIONS)
15510
+ );
15511
+ async function withBasisTranscodingLock(transcode) {
15512
+ const previousLock = basisTranscodingLock;
15513
+ let releaseLock;
15514
+ basisTranscodingLock = new Promise((resolve2) => {
15515
+ releaseLock = resolve2;
15516
+ });
15517
+ await previousLock;
15518
+ try {
15519
+ return await transcode();
15520
+ } finally {
15521
+ releaseLock();
15522
+ }
15523
+ }
15524
+ async function parseBasis(data, options = {}) {
15525
+ const loadLibraryOptions = extractLoadLibraryOptions(options);
15526
+ return await withBasisTranscodingLock(async () => {
15527
+ if (!options.basis?.containerFormat || options.basis.containerFormat === "auto") {
15528
+ if (isKTX(data)) {
15529
+ const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
15530
+ return parseKTX2File(fileConstructors.KTX2File, data, options);
15355
15531
  }
15356
- case "transcoder":
15357
- default:
15358
- const { BasisFile } = await loadBasisTranscoderModule(options);
15532
+ const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
15359
15533
  return parseBasisFile(BasisFile, data, options);
15360
- }
15534
+ }
15535
+ switch (options.basis.module) {
15536
+ case "encoder":
15537
+ const fileConstructors = await loadBasisEncoderModule(loadLibraryOptions);
15538
+ switch (options.basis.containerFormat) {
15539
+ case "ktx2":
15540
+ return parseKTX2File(fileConstructors.KTX2File, data, options);
15541
+ case "basis":
15542
+ default:
15543
+ return parseBasisFile(fileConstructors.BasisFile, data, options);
15544
+ }
15545
+ case "transcoder":
15546
+ default:
15547
+ const { BasisFile } = await loadBasisTranscoderModule(loadLibraryOptions);
15548
+ return parseBasisFile(BasisFile, data, options);
15549
+ }
15550
+ });
15361
15551
  }
15362
15552
  function parseBasisFile(BasisFile, data, options) {
15363
15553
  const basisFile = new BasisFile(new Uint8Array(data));
@@ -15387,7 +15577,7 @@ var __exports__ = (() => {
15387
15577
  const hasAlpha = basisFile.getHasAlpha(
15388
15578
  /* imageIndex, levelIndex */
15389
15579
  );
15390
- const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
15580
+ const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, hasAlpha);
15391
15581
  const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
15392
15582
  const decodedData = new Uint8Array(decodedSize);
15393
15583
  if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
@@ -15395,11 +15585,13 @@ var __exports__ = (() => {
15395
15585
  }
15396
15586
  return {
15397
15587
  // standard loaders.gl image category payload
15588
+ shape: "texture-level",
15398
15589
  width,
15399
15590
  height,
15400
15591
  data: decodedData,
15401
15592
  compressed,
15402
- format,
15593
+ ...format !== void 0 ? { format } : {},
15594
+ ...textureFormat !== void 0 ? { textureFormat } : {},
15403
15595
  // Additional fields
15404
15596
  // Add levelSize field.
15405
15597
  hasAlpha
@@ -15424,7 +15616,7 @@ var __exports__ = (() => {
15424
15616
  }
15425
15617
  function transcodeKTX2Image(ktx2File, levelIndex, options) {
15426
15618
  const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
15427
- const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
15619
+ const { compressed, format, basisFormat, textureFormat } = getBasisOptions(options, alphaFlag);
15428
15620
  const decodedSize = ktx2File.getImageTranscodedSizeInBytes(
15429
15621
  levelIndex,
15430
15622
  0,
@@ -15447,48 +15639,98 @@ var __exports__ = (() => {
15447
15639
  }
15448
15640
  return {
15449
15641
  // standard loaders.gl image category payload
15642
+ shape: "texture-level",
15450
15643
  width,
15451
15644
  height,
15452
15645
  data: decodedData,
15453
15646
  compressed,
15647
+ ...format !== void 0 ? { format } : {},
15648
+ ...textureFormat !== void 0 ? { textureFormat } : {},
15454
15649
  // Additional fields
15455
15650
  levelSize: decodedSize,
15456
- hasAlpha: alphaFlag,
15457
- format
15651
+ hasAlpha: alphaFlag
15458
15652
  };
15459
15653
  }
15460
15654
  function getBasisOptions(options, hasAlpha) {
15461
- let format = options && options.basis && options.basis.format;
15655
+ let format = options.basis?.format || "auto";
15462
15656
  if (format === "auto") {
15463
- format = selectSupportedBasisFormat();
15657
+ format = options.basis?.supportedTextureFormats ? selectSupportedBasisFormat(options.basis.supportedTextureFormats) : selectSupportedBasisFormat();
15464
15658
  }
15465
15659
  if (typeof format === "object") {
15466
15660
  format = hasAlpha ? format.alpha : format.noAlpha;
15467
15661
  }
15468
- format = format.toLowerCase();
15469
- return OutputFormat[format];
15662
+ const normalizedFormat = format.toLowerCase();
15663
+ const basisOutputOptions = BASIS_FORMAT_TO_OUTPUT_OPTIONS[normalizedFormat];
15664
+ if (!basisOutputOptions) {
15665
+ throw new Error(`Unknown Basis format ${format}`);
15666
+ }
15667
+ return basisOutputOptions;
15470
15668
  }
15471
- function selectSupportedBasisFormat() {
15472
- const supportedFormats = getSupportedGPUTextureFormats();
15473
- if (supportedFormats.has("astc")) {
15669
+ function selectSupportedBasisFormat(supportedTextureFormats = detectSupportedTextureFormats()) {
15670
+ const textureFormats2 = new Set(supportedTextureFormats);
15671
+ if (hasSupportedTextureFormat(textureFormats2, ["astc-4x4-unorm", "astc-4x4-unorm-srgb"])) {
15474
15672
  return "astc-4x4";
15475
- } else if (supportedFormats.has("dxt")) {
15673
+ } else if (hasSupportedTextureFormat(textureFormats2, ["bc7-rgba-unorm", "bc7-rgba-unorm-srgb"])) {
15674
+ return {
15675
+ alpha: "bc7-m5",
15676
+ noAlpha: "bc7-m6-opaque-only"
15677
+ };
15678
+ } else if (hasSupportedTextureFormat(textureFormats2, [
15679
+ "bc1-rgb-unorm-webgl",
15680
+ "bc1-rgb-unorm-srgb-webgl",
15681
+ "bc1-rgba-unorm",
15682
+ "bc1-rgba-unorm-srgb",
15683
+ "bc2-rgba-unorm",
15684
+ "bc2-rgba-unorm-srgb",
15685
+ "bc3-rgba-unorm",
15686
+ "bc3-rgba-unorm-srgb"
15687
+ ])) {
15476
15688
  return {
15477
15689
  alpha: "bc3",
15478
15690
  noAlpha: "bc1"
15479
15691
  };
15480
- } else if (supportedFormats.has("pvrtc")) {
15692
+ } else if (hasSupportedTextureFormat(textureFormats2, [
15693
+ "pvrtc-rgb4unorm-webgl",
15694
+ "pvrtc-rgba4unorm-webgl",
15695
+ "pvrtc-rgb2unorm-webgl",
15696
+ "pvrtc-rgba2unorm-webgl"
15697
+ ])) {
15481
15698
  return {
15482
15699
  alpha: "pvrtc1-4-rgba",
15483
15700
  noAlpha: "pvrtc1-4-rgb"
15484
15701
  };
15485
- } else if (supportedFormats.has("etc1")) {
15486
- return "etc1";
15487
- } else if (supportedFormats.has("etc2")) {
15702
+ } else if (hasSupportedTextureFormat(textureFormats2, [
15703
+ "etc2-rgb8unorm",
15704
+ "etc2-rgb8unorm-srgb",
15705
+ "etc2-rgb8a1unorm",
15706
+ "etc2-rgb8a1unorm-srgb",
15707
+ "etc2-rgba8unorm",
15708
+ "etc2-rgba8unorm-srgb",
15709
+ "eac-r11unorm",
15710
+ "eac-r11snorm",
15711
+ "eac-rg11unorm",
15712
+ "eac-rg11snorm"
15713
+ ])) {
15488
15714
  return "etc2";
15715
+ } else if (textureFormats2.has("etc1-rgb-unorm-webgl")) {
15716
+ return "etc1";
15717
+ } else if (hasSupportedTextureFormat(textureFormats2, [
15718
+ "atc-rgb-unorm-webgl",
15719
+ "atc-rgba-unorm-webgl",
15720
+ "atc-rgbai-unorm-webgl"
15721
+ ])) {
15722
+ return {
15723
+ alpha: "atc-rgba-interpolated-alpha",
15724
+ noAlpha: "atc-rgb"
15725
+ };
15489
15726
  }
15490
15727
  return "rgb565";
15491
15728
  }
15729
+ function hasSupportedTextureFormat(supportedTextureFormats, candidateTextureFormats) {
15730
+ return candidateTextureFormats.some(
15731
+ (textureFormat) => supportedTextureFormats.has(textureFormat)
15732
+ );
15733
+ }
15492
15734
 
15493
15735
  // ../textures/src/basis-loader.ts
15494
15736
  var BasisWorkerLoader = {
@@ -15506,7 +15748,6 @@ var __exports__ = (() => {
15506
15748
  options: {
15507
15749
  basis: {
15508
15750
  format: "auto",
15509
- libraryPath: "libs/",
15510
15751
  containerFormat: "auto",
15511
15752
  module: "transcoder"
15512
15753
  }
@@ -15628,16 +15869,26 @@ var __exports__ = (() => {
15628
15869
  }
15629
15870
 
15630
15871
  // ../gltf/src/lib/gltf-utils/resolve-url.ts
15631
- function resolveUrl(url, options) {
15872
+ function resolveUrl(url, options, context) {
15632
15873
  const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:");
15633
15874
  if (absolute) {
15634
15875
  return url;
15635
15876
  }
15636
- const baseUrl = options.baseUri || options.uri;
15877
+ const baseUrl = context?.baseUrl || getResolveBaseUrl(options?.core?.baseUrl);
15878
+ if (!baseUrl) {
15879
+ throw new Error(`'baseUrl' must be provided to resolve relative url ${url}`);
15880
+ }
15881
+ return baseUrl.endsWith("/") ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
15882
+ }
15883
+ function getResolveBaseUrl(baseUrl) {
15637
15884
  if (!baseUrl) {
15638
- throw new Error(`'baseUri' must be provided to resolve relative url ${url}`);
15885
+ return void 0;
15886
+ }
15887
+ if (baseUrl.endsWith("/")) {
15888
+ return baseUrl;
15639
15889
  }
15640
- return baseUrl.substr(0, baseUrl.lastIndexOf("/") + 1) + url;
15890
+ const slashIndex = baseUrl.lastIndexOf("/");
15891
+ return slashIndex >= 0 ? baseUrl.slice(0, slashIndex + 1) : "";
15641
15892
  }
15642
15893
 
15643
15894
  // ../gltf/src/lib/extensions/EXT_meshopt_compression.ts
@@ -16187,7 +16438,7 @@ var __exports__ = (() => {
16187
16438
  const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`];
16188
16439
  if (Number.isFinite(texCoordAccessor)) {
16189
16440
  const accessor = gltfData.json.accessors?.[texCoordAccessor];
16190
- if (accessor && accessor.bufferView) {
16441
+ if (accessor && accessor.bufferView !== void 0) {
16191
16442
  const bufferView = gltfData.json.bufferViews?.[accessor.bufferView];
16192
16443
  if (bufferView) {
16193
16444
  const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer];
@@ -16204,7 +16455,7 @@ var __exports__ = (() => {
16204
16455
  result.set([scratchVector8[0], scratchVector8[1]], i * components);
16205
16456
  }
16206
16457
  if (originalTexCoord === texCoord) {
16207
- updateGltf(accessor, bufferView, gltfData.buffers, result);
16458
+ updateGltf(accessor, gltfData, result, accessor.bufferView);
16208
16459
  } else {
16209
16460
  createAttribute(texCoord, accessor, primitive, gltfData, result);
16210
16461
  }
@@ -16212,28 +16463,49 @@ var __exports__ = (() => {
16212
16463
  }
16213
16464
  }
16214
16465
  }
16215
- function updateGltf(accessor, bufferView, buffers, newTexCoordArray) {
16466
+ function updateGltf(accessor, gltfData, newTexCoordArray, originalBufferViewIndex) {
16216
16467
  accessor.componentType = 5126;
16217
- buffers.push({
16218
- arrayBuffer: newTexCoordArray.buffer,
16468
+ accessor.byteOffset = 0;
16469
+ const accessors = gltfData.json.accessors || [];
16470
+ const bufferViewReferenceCount = accessors.reduce((count, currentAccessor) => {
16471
+ return currentAccessor.bufferView === originalBufferViewIndex ? count + 1 : count;
16472
+ }, 0);
16473
+ const shouldCreateNewBufferView = bufferViewReferenceCount > 1;
16474
+ gltfData.buffers.push({
16475
+ arrayBuffer: ensureArrayBuffer(newTexCoordArray.buffer),
16219
16476
  byteOffset: 0,
16220
16477
  byteLength: newTexCoordArray.buffer.byteLength
16221
16478
  });
16222
- bufferView.buffer = buffers.length - 1;
16223
- bufferView.byteLength = newTexCoordArray.buffer.byteLength;
16479
+ const newBufferIndex = gltfData.buffers.length - 1;
16480
+ gltfData.json.bufferViews = gltfData.json.bufferViews || [];
16481
+ if (shouldCreateNewBufferView) {
16482
+ gltfData.json.bufferViews.push({
16483
+ buffer: newBufferIndex,
16484
+ byteLength: newTexCoordArray.buffer.byteLength,
16485
+ byteOffset: 0
16486
+ });
16487
+ accessor.bufferView = gltfData.json.bufferViews.length - 1;
16488
+ return;
16489
+ }
16490
+ const bufferView = gltfData.json.bufferViews[originalBufferViewIndex];
16491
+ if (!bufferView) {
16492
+ return;
16493
+ }
16494
+ bufferView.buffer = newBufferIndex;
16224
16495
  bufferView.byteOffset = 0;
16225
- delete bufferView.byteStride;
16496
+ bufferView.byteLength = newTexCoordArray.buffer.byteLength;
16497
+ if (bufferView.byteStride !== void 0) {
16498
+ delete bufferView.byteStride;
16499
+ }
16226
16500
  }
16227
16501
  function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, newTexCoordArray) {
16228
16502
  gltfData.buffers.push({
16229
- arrayBuffer: newTexCoordArray.buffer,
16503
+ arrayBuffer: ensureArrayBuffer(newTexCoordArray.buffer),
16230
16504
  byteOffset: 0,
16231
16505
  byteLength: newTexCoordArray.buffer.byteLength
16232
16506
  });
16507
+ gltfData.json.bufferViews = gltfData.json.bufferViews || [];
16233
16508
  const bufferViews = gltfData.json.bufferViews;
16234
- if (!bufferViews) {
16235
- return;
16236
- }
16237
16509
  bufferViews.push({
16238
16510
  buffer: gltfData.buffers.length - 1,
16239
16511
  byteLength: newTexCoordArray.buffer.byteLength,
@@ -16702,10 +16974,10 @@ var __exports__ = (() => {
16702
16974
  return gltf;
16703
16975
  }
16704
16976
  function parseGLTFContainerSync(gltf, data, byteOffset, options) {
16705
- if (options.uri) {
16706
- gltf.baseUri = options.uri;
16977
+ if (options.core?.baseUrl) {
16978
+ gltf.baseUri = options.core?.baseUrl;
16707
16979
  }
16708
- if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) {
16980
+ if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options.glb)) {
16709
16981
  const textDecoder = new TextDecoder();
16710
16982
  data = textDecoder.decode(data);
16711
16983
  }
@@ -16740,7 +17012,7 @@ var __exports__ = (() => {
16740
17012
  if (buffer.uri) {
16741
17013
  const { fetch: fetch2 } = context;
16742
17014
  assert7(fetch2);
16743
- const uri = resolveUrl(buffer.uri, options);
17015
+ const uri = resolveUrl(buffer.uri, options, context);
16744
17016
  const response = await context?.fetch?.(uri);
16745
17017
  const arrayBuffer = await response?.arrayBuffer?.();
16746
17018
  gltf.buffers[i] = {
@@ -16780,7 +17052,7 @@ var __exports__ = (() => {
16780
17052
  async function loadImage(gltf, image, index, options, context) {
16781
17053
  let arrayBuffer;
16782
17054
  if (image.uri && !image.hasOwnProperty("bufferView")) {
16783
- const uri = resolveUrl(image.uri, options);
17055
+ const uri = resolveUrl(image.uri, options, context);
16784
17056
  const { fetch: fetch2 } = context;
16785
17057
  const response = await fetch2(uri);
16786
17058
  arrayBuffer = await response.arrayBuffer();
@@ -16793,14 +17065,15 @@ var __exports__ = (() => {
16793
17065
  arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength);
16794
17066
  }
16795
17067
  assert7(arrayBuffer, "glTF image has no data");
17068
+ const strictOptions = options;
17069
+ const gltfOptions = {
17070
+ ...strictOptions,
17071
+ core: { ...strictOptions?.core, mimeType: image.mimeType }
17072
+ };
16796
17073
  let parsedImage = await parseFromContext(
16797
17074
  arrayBuffer,
16798
17075
  [ImageLoader, BasisLoader],
16799
- {
16800
- ...options,
16801
- mimeType: image.mimeType,
16802
- basis: options.basis || { format: selectSupportedBasisFormat() }
16803
- },
17076
+ gltfOptions,
16804
17077
  context
16805
17078
  );
16806
17079
  if (parsedImage && parsedImage[0]) {
@@ -16841,18 +17114,15 @@ var __exports__ = (() => {
16841
17114
  // Create image objects
16842
17115
  decompressMeshes: true
16843
17116
  // Decompress Draco encoded meshes
16844
- },
16845
- // common?
16846
- log: console
16847
- // eslint-disable-line
17117
+ }
16848
17118
  }
16849
17119
  };
16850
17120
  async function parse2(arrayBuffer, options = {}, context) {
16851
- options = { ...GLTFLoader.options, ...options };
16852
- options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf };
16853
- const { byteOffset = 0 } = options;
17121
+ const mergedOptions = { ...GLTFLoader.options, ...options };
17122
+ mergedOptions.gltf = { ...GLTFLoader.options.gltf, ...mergedOptions.gltf };
17123
+ const byteOffset = options?.glb?.byteOffset || 0;
16854
17124
  const gltf = {};
16855
- return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
17125
+ return await parseGLTF(gltf, arrayBuffer, byteOffset, mergedOptions, context);
16856
17126
  }
16857
17127
 
16858
17128
  // ../gltf/src/lib/api/post-process-gltf.ts
@@ -17158,7 +17428,7 @@ var __exports__ = (() => {
17158
17428
  const buffer = accessor.bufferView.buffer;
17159
17429
  const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView);
17160
17430
  const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset;
17161
- let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength);
17431
+ let cutBuffer = copyToArrayBuffer2(buffer.arrayBuffer, byteOffset, byteLength);
17162
17432
  if (accessor.bufferView.byteStride) {
17163
17433
  cutBuffer = this._getValueFromInterleavedBuffer(
17164
17434
  buffer,
@@ -17298,7 +17568,7 @@ var __exports__ = (() => {
17298
17568
  }
17299
17569
  if (tile.gltfUrl) {
17300
17570
  const { fetch: fetch2 } = context;
17301
- const response = await fetch2(tile.gltfUrl, options);
17571
+ const response = await fetch2(tile.gltfUrl, options?.core);
17302
17572
  tile.gltfArrayBuffer = await response.arrayBuffer();
17303
17573
  tile.gltfByteOffset = 0;
17304
17574
  }
@@ -17687,295 +17957,328 @@ var __exports__ = (() => {
17687
17957
  // ../../node_modules/long/index.js
17688
17958
  var wasm = null;
17689
17959
  try {
17690
- wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
17691
- 0,
17692
- 97,
17693
- 115,
17694
- 109,
17695
- 1,
17696
- 0,
17697
- 0,
17698
- 0,
17699
- 1,
17700
- 13,
17701
- 2,
17702
- 96,
17703
- 0,
17704
- 1,
17705
- 127,
17706
- 96,
17707
- 4,
17708
- 127,
17709
- 127,
17710
- 127,
17711
- 127,
17712
- 1,
17713
- 127,
17714
- 3,
17715
- 7,
17716
- 6,
17717
- 0,
17718
- 1,
17719
- 1,
17720
- 1,
17721
- 1,
17722
- 1,
17723
- 6,
17724
- 6,
17725
- 1,
17726
- 127,
17727
- 1,
17728
- 65,
17729
- 0,
17730
- 11,
17731
- 7,
17732
- 50,
17733
- 6,
17734
- 3,
17735
- 109,
17736
- 117,
17737
- 108,
17738
- 0,
17739
- 1,
17740
- 5,
17741
- 100,
17742
- 105,
17743
- 118,
17744
- 95,
17745
- 115,
17746
- 0,
17747
- 2,
17748
- 5,
17749
- 100,
17750
- 105,
17751
- 118,
17752
- 95,
17753
- 117,
17754
- 0,
17755
- 3,
17756
- 5,
17757
- 114,
17758
- 101,
17759
- 109,
17760
- 95,
17761
- 115,
17762
- 0,
17763
- 4,
17764
- 5,
17765
- 114,
17766
- 101,
17767
- 109,
17768
- 95,
17769
- 117,
17770
- 0,
17771
- 5,
17772
- 8,
17773
- 103,
17774
- 101,
17775
- 116,
17776
- 95,
17777
- 104,
17778
- 105,
17779
- 103,
17780
- 104,
17781
- 0,
17782
- 0,
17783
- 10,
17784
- 191,
17785
- 1,
17786
- 6,
17787
- 4,
17788
- 0,
17789
- 35,
17790
- 0,
17791
- 11,
17792
- 36,
17793
- 1,
17794
- 1,
17795
- 126,
17796
- 32,
17797
- 0,
17798
- 173,
17799
- 32,
17800
- 1,
17801
- 173,
17802
- 66,
17803
- 32,
17804
- 134,
17805
- 132,
17806
- 32,
17807
- 2,
17808
- 173,
17809
- 32,
17810
- 3,
17811
- 173,
17812
- 66,
17813
- 32,
17814
- 134,
17815
- 132,
17816
- 126,
17817
- 34,
17818
- 4,
17819
- 66,
17820
- 32,
17821
- 135,
17822
- 167,
17823
- 36,
17824
- 0,
17825
- 32,
17826
- 4,
17827
- 167,
17828
- 11,
17829
- 36,
17830
- 1,
17831
- 1,
17832
- 126,
17833
- 32,
17834
- 0,
17835
- 173,
17836
- 32,
17837
- 1,
17838
- 173,
17839
- 66,
17840
- 32,
17841
- 134,
17842
- 132,
17843
- 32,
17844
- 2,
17845
- 173,
17846
- 32,
17847
- 3,
17848
- 173,
17849
- 66,
17850
- 32,
17851
- 134,
17852
- 132,
17853
- 127,
17854
- 34,
17855
- 4,
17856
- 66,
17857
- 32,
17858
- 135,
17859
- 167,
17860
- 36,
17861
- 0,
17862
- 32,
17863
- 4,
17864
- 167,
17865
- 11,
17866
- 36,
17867
- 1,
17868
- 1,
17869
- 126,
17870
- 32,
17871
- 0,
17872
- 173,
17873
- 32,
17874
- 1,
17875
- 173,
17876
- 66,
17877
- 32,
17878
- 134,
17879
- 132,
17880
- 32,
17881
- 2,
17882
- 173,
17883
- 32,
17884
- 3,
17885
- 173,
17886
- 66,
17887
- 32,
17888
- 134,
17889
- 132,
17890
- 128,
17891
- 34,
17892
- 4,
17893
- 66,
17894
- 32,
17895
- 135,
17896
- 167,
17897
- 36,
17898
- 0,
17899
- 32,
17900
- 4,
17901
- 167,
17902
- 11,
17903
- 36,
17904
- 1,
17905
- 1,
17906
- 126,
17907
- 32,
17908
- 0,
17909
- 173,
17910
- 32,
17911
- 1,
17912
- 173,
17913
- 66,
17914
- 32,
17915
- 134,
17916
- 132,
17917
- 32,
17918
- 2,
17919
- 173,
17920
- 32,
17921
- 3,
17922
- 173,
17923
- 66,
17924
- 32,
17925
- 134,
17926
- 132,
17927
- 129,
17928
- 34,
17929
- 4,
17930
- 66,
17931
- 32,
17932
- 135,
17933
- 167,
17934
- 36,
17935
- 0,
17936
- 32,
17937
- 4,
17938
- 167,
17939
- 11,
17940
- 36,
17941
- 1,
17942
- 1,
17943
- 126,
17944
- 32,
17945
- 0,
17946
- 173,
17947
- 32,
17948
- 1,
17949
- 173,
17950
- 66,
17951
- 32,
17952
- 134,
17953
- 132,
17954
- 32,
17955
- 2,
17956
- 173,
17957
- 32,
17958
- 3,
17959
- 173,
17960
- 66,
17961
- 32,
17962
- 134,
17963
- 132,
17964
- 130,
17965
- 34,
17966
- 4,
17967
- 66,
17968
- 32,
17969
- 135,
17970
- 167,
17971
- 36,
17972
- 0,
17973
- 32,
17974
- 4,
17975
- 167,
17976
- 11
17977
- ])), {}).exports;
17978
- } catch (e) {
17960
+ wasm = new WebAssembly.Instance(
17961
+ new WebAssembly.Module(
17962
+ new Uint8Array([
17963
+ // \0asm
17964
+ 0,
17965
+ 97,
17966
+ 115,
17967
+ 109,
17968
+ // version 1
17969
+ 1,
17970
+ 0,
17971
+ 0,
17972
+ 0,
17973
+ // section "type"
17974
+ 1,
17975
+ 13,
17976
+ 2,
17977
+ // 0, () => i32
17978
+ 96,
17979
+ 0,
17980
+ 1,
17981
+ 127,
17982
+ // 1, (i32, i32, i32, i32) => i32
17983
+ 96,
17984
+ 4,
17985
+ 127,
17986
+ 127,
17987
+ 127,
17988
+ 127,
17989
+ 1,
17990
+ 127,
17991
+ // section "function"
17992
+ 3,
17993
+ 7,
17994
+ 6,
17995
+ // 0, type 0
17996
+ 0,
17997
+ // 1, type 1
17998
+ 1,
17999
+ // 2, type 1
18000
+ 1,
18001
+ // 3, type 1
18002
+ 1,
18003
+ // 4, type 1
18004
+ 1,
18005
+ // 5, type 1
18006
+ 1,
18007
+ // section "global"
18008
+ 6,
18009
+ 6,
18010
+ 1,
18011
+ // 0, "high", mutable i32
18012
+ 127,
18013
+ 1,
18014
+ 65,
18015
+ 0,
18016
+ 11,
18017
+ // section "export"
18018
+ 7,
18019
+ 50,
18020
+ 6,
18021
+ // 0, "mul"
18022
+ 3,
18023
+ 109,
18024
+ 117,
18025
+ 108,
18026
+ 0,
18027
+ 1,
18028
+ // 1, "div_s"
18029
+ 5,
18030
+ 100,
18031
+ 105,
18032
+ 118,
18033
+ 95,
18034
+ 115,
18035
+ 0,
18036
+ 2,
18037
+ // 2, "div_u"
18038
+ 5,
18039
+ 100,
18040
+ 105,
18041
+ 118,
18042
+ 95,
18043
+ 117,
18044
+ 0,
18045
+ 3,
18046
+ // 3, "rem_s"
18047
+ 5,
18048
+ 114,
18049
+ 101,
18050
+ 109,
18051
+ 95,
18052
+ 115,
18053
+ 0,
18054
+ 4,
18055
+ // 4, "rem_u"
18056
+ 5,
18057
+ 114,
18058
+ 101,
18059
+ 109,
18060
+ 95,
18061
+ 117,
18062
+ 0,
18063
+ 5,
18064
+ // 5, "get_high"
18065
+ 8,
18066
+ 103,
18067
+ 101,
18068
+ 116,
18069
+ 95,
18070
+ 104,
18071
+ 105,
18072
+ 103,
18073
+ 104,
18074
+ 0,
18075
+ 0,
18076
+ // section "code"
18077
+ 10,
18078
+ 191,
18079
+ 1,
18080
+ 6,
18081
+ // 0, "get_high"
18082
+ 4,
18083
+ 0,
18084
+ 35,
18085
+ 0,
18086
+ 11,
18087
+ // 1, "mul"
18088
+ 36,
18089
+ 1,
18090
+ 1,
18091
+ 126,
18092
+ 32,
18093
+ 0,
18094
+ 173,
18095
+ 32,
18096
+ 1,
18097
+ 173,
18098
+ 66,
18099
+ 32,
18100
+ 134,
18101
+ 132,
18102
+ 32,
18103
+ 2,
18104
+ 173,
18105
+ 32,
18106
+ 3,
18107
+ 173,
18108
+ 66,
18109
+ 32,
18110
+ 134,
18111
+ 132,
18112
+ 126,
18113
+ 34,
18114
+ 4,
18115
+ 66,
18116
+ 32,
18117
+ 135,
18118
+ 167,
18119
+ 36,
18120
+ 0,
18121
+ 32,
18122
+ 4,
18123
+ 167,
18124
+ 11,
18125
+ // 2, "div_s"
18126
+ 36,
18127
+ 1,
18128
+ 1,
18129
+ 126,
18130
+ 32,
18131
+ 0,
18132
+ 173,
18133
+ 32,
18134
+ 1,
18135
+ 173,
18136
+ 66,
18137
+ 32,
18138
+ 134,
18139
+ 132,
18140
+ 32,
18141
+ 2,
18142
+ 173,
18143
+ 32,
18144
+ 3,
18145
+ 173,
18146
+ 66,
18147
+ 32,
18148
+ 134,
18149
+ 132,
18150
+ 127,
18151
+ 34,
18152
+ 4,
18153
+ 66,
18154
+ 32,
18155
+ 135,
18156
+ 167,
18157
+ 36,
18158
+ 0,
18159
+ 32,
18160
+ 4,
18161
+ 167,
18162
+ 11,
18163
+ // 3, "div_u"
18164
+ 36,
18165
+ 1,
18166
+ 1,
18167
+ 126,
18168
+ 32,
18169
+ 0,
18170
+ 173,
18171
+ 32,
18172
+ 1,
18173
+ 173,
18174
+ 66,
18175
+ 32,
18176
+ 134,
18177
+ 132,
18178
+ 32,
18179
+ 2,
18180
+ 173,
18181
+ 32,
18182
+ 3,
18183
+ 173,
18184
+ 66,
18185
+ 32,
18186
+ 134,
18187
+ 132,
18188
+ 128,
18189
+ 34,
18190
+ 4,
18191
+ 66,
18192
+ 32,
18193
+ 135,
18194
+ 167,
18195
+ 36,
18196
+ 0,
18197
+ 32,
18198
+ 4,
18199
+ 167,
18200
+ 11,
18201
+ // 4, "rem_s"
18202
+ 36,
18203
+ 1,
18204
+ 1,
18205
+ 126,
18206
+ 32,
18207
+ 0,
18208
+ 173,
18209
+ 32,
18210
+ 1,
18211
+ 173,
18212
+ 66,
18213
+ 32,
18214
+ 134,
18215
+ 132,
18216
+ 32,
18217
+ 2,
18218
+ 173,
18219
+ 32,
18220
+ 3,
18221
+ 173,
18222
+ 66,
18223
+ 32,
18224
+ 134,
18225
+ 132,
18226
+ 129,
18227
+ 34,
18228
+ 4,
18229
+ 66,
18230
+ 32,
18231
+ 135,
18232
+ 167,
18233
+ 36,
18234
+ 0,
18235
+ 32,
18236
+ 4,
18237
+ 167,
18238
+ 11,
18239
+ // 5, "rem_u"
18240
+ 36,
18241
+ 1,
18242
+ 1,
18243
+ 126,
18244
+ 32,
18245
+ 0,
18246
+ 173,
18247
+ 32,
18248
+ 1,
18249
+ 173,
18250
+ 66,
18251
+ 32,
18252
+ 134,
18253
+ 132,
18254
+ 32,
18255
+ 2,
18256
+ 173,
18257
+ 32,
18258
+ 3,
18259
+ 173,
18260
+ 66,
18261
+ 32,
18262
+ 134,
18263
+ 132,
18264
+ 130,
18265
+ 34,
18266
+ 4,
18267
+ 66,
18268
+ 32,
18269
+ 135,
18270
+ 167,
18271
+ 36,
18272
+ 0,
18273
+ 32,
18274
+ 4,
18275
+ 167,
18276
+ 11
18277
+ ])
18278
+ ),
18279
+ {}
18280
+ ).exports;
18281
+ } catch {
17979
18282
  }
17980
18283
  function Long(low, high, unsigned) {
17981
18284
  this.low = low | 0;
@@ -17995,27 +18298,27 @@ var __exports__ = (() => {
17995
18298
  var INT_CACHE = {};
17996
18299
  var UINT_CACHE = {};
17997
18300
  function fromInt(value, unsigned) {
17998
- var obj, cachedObj, cache2;
18301
+ var obj, cachedObj, cache;
17999
18302
  if (unsigned) {
18000
18303
  value >>>= 0;
18001
- if (cache2 = 0 <= value && value < 256) {
18304
+ if (cache = 0 <= value && value < 256) {
18002
18305
  cachedObj = UINT_CACHE[value];
18003
18306
  if (cachedObj)
18004
18307
  return cachedObj;
18005
18308
  }
18006
18309
  obj = fromBits(value, 0, true);
18007
- if (cache2)
18310
+ if (cache)
18008
18311
  UINT_CACHE[value] = obj;
18009
18312
  return obj;
18010
18313
  } else {
18011
18314
  value |= 0;
18012
- if (cache2 = -128 <= value && value < 128) {
18315
+ if (cache = -128 <= value && value < 128) {
18013
18316
  cachedObj = INT_CACHE[value];
18014
18317
  if (cachedObj)
18015
18318
  return cachedObj;
18016
18319
  }
18017
18320
  obj = fromBits(value, value < 0 ? -1 : 0, false);
18018
- if (cache2)
18321
+ if (cache)
18019
18322
  INT_CACHE[value] = obj;
18020
18323
  return obj;
18021
18324
  }
@@ -18037,7 +18340,11 @@ var __exports__ = (() => {
18037
18340
  }
18038
18341
  if (value < 0)
18039
18342
  return fromNumber(-value, unsigned).neg();
18040
- return fromBits(value % TWO_PWR_32_DBL | 0, value / TWO_PWR_32_DBL | 0, unsigned);
18343
+ return fromBits(
18344
+ value % TWO_PWR_32_DBL | 0,
18345
+ value / TWO_PWR_32_DBL | 0,
18346
+ unsigned
18347
+ );
18041
18348
  }
18042
18349
  Long.fromNumber = fromNumber;
18043
18350
  function fromBits(lowBits, highBits, unsigned) {
@@ -18086,7 +18393,11 @@ var __exports__ = (() => {
18086
18393
  return fromNumber(val, unsigned);
18087
18394
  if (typeof val === "string")
18088
18395
  return fromString(val, unsigned);
18089
- return fromBits(val.low, val.high, typeof unsigned === "boolean" ? unsigned : val.unsigned);
18396
+ return fromBits(
18397
+ val.low,
18398
+ val.high,
18399
+ typeof unsigned === "boolean" ? unsigned : val.unsigned
18400
+ );
18090
18401
  }
18091
18402
  Long.fromValue = fromValue;
18092
18403
  var TWO_PWR_16_DBL = 1 << 16;
@@ -18115,7 +18426,7 @@ var __exports__ = (() => {
18115
18426
  LongPrototype.toInt = function toInt() {
18116
18427
  return this.unsigned ? this.low >>> 0 : this.low;
18117
18428
  };
18118
- LongPrototype.toNumber = function toNumber2() {
18429
+ LongPrototype.toNumber = function toNumber() {
18119
18430
  if (this.unsigned)
18120
18431
  return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
18121
18432
  return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
@@ -18168,6 +18479,14 @@ var __exports__ = (() => {
18168
18479
  break;
18169
18480
  return this.high != 0 ? bit + 33 : bit + 1;
18170
18481
  };
18482
+ LongPrototype.isSafeInteger = function isSafeInteger() {
18483
+ var top11Bits = this.high >> 21;
18484
+ if (!top11Bits)
18485
+ return true;
18486
+ if (this.unsigned)
18487
+ return false;
18488
+ return top11Bits === -1 && !(this.low === 0 && this.high === -2097152);
18489
+ };
18171
18490
  LongPrototype.isZero = function isZero() {
18172
18491
  return this.high === 0 && this.low === 0;
18173
18492
  };
@@ -18288,12 +18607,7 @@ var __exports__ = (() => {
18288
18607
  if (!isLong(multiplier))
18289
18608
  multiplier = fromValue(multiplier);
18290
18609
  if (wasm) {
18291
- var low = wasm["mul"](
18292
- this.low,
18293
- this.high,
18294
- multiplier.low,
18295
- multiplier.high
18296
- );
18610
+ var low = wasm["mul"](this.low, this.high, multiplier.low, multiplier.high);
18297
18611
  return fromBits(low, wasm["get_high"](), this.unsigned);
18298
18612
  }
18299
18613
  if (multiplier.isZero())
@@ -18463,7 +18777,11 @@ var __exports__ = (() => {
18463
18777
  if ((numBits &= 63) === 0)
18464
18778
  return this;
18465
18779
  else if (numBits < 32)
18466
- return fromBits(this.low << numBits, this.high << numBits | this.low >>> 32 - numBits, this.unsigned);
18780
+ return fromBits(
18781
+ this.low << numBits,
18782
+ this.high << numBits | this.low >>> 32 - numBits,
18783
+ this.unsigned
18784
+ );
18467
18785
  else
18468
18786
  return fromBits(0, this.low << numBits - 32, this.unsigned);
18469
18787
  };
@@ -18474,9 +18792,17 @@ var __exports__ = (() => {
18474
18792
  if ((numBits &= 63) === 0)
18475
18793
  return this;
18476
18794
  else if (numBits < 32)
18477
- return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >> numBits, this.unsigned);
18795
+ return fromBits(
18796
+ this.low >>> numBits | this.high << 32 - numBits,
18797
+ this.high >> numBits,
18798
+ this.unsigned
18799
+ );
18478
18800
  else
18479
- return fromBits(this.high >> numBits - 32, this.high >= 0 ? 0 : -1, this.unsigned);
18801
+ return fromBits(
18802
+ this.high >> numBits - 32,
18803
+ this.high >= 0 ? 0 : -1,
18804
+ this.unsigned
18805
+ );
18480
18806
  };
18481
18807
  LongPrototype.shr = LongPrototype.shiftRight;
18482
18808
  LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
@@ -18485,7 +18811,11 @@ var __exports__ = (() => {
18485
18811
  if ((numBits &= 63) === 0)
18486
18812
  return this;
18487
18813
  if (numBits < 32)
18488
- return fromBits(this.low >>> numBits | this.high << 32 - numBits, this.high >>> numBits, this.unsigned);
18814
+ return fromBits(
18815
+ this.low >>> numBits | this.high << 32 - numBits,
18816
+ this.high >>> numBits,
18817
+ this.unsigned
18818
+ );
18489
18819
  if (numBits === 32)
18490
18820
  return fromBits(this.high, 0, this.unsigned);
18491
18821
  return fromBits(this.high >>> numBits - 32, 0, this.unsigned);
@@ -18502,11 +18832,19 @@ var __exports__ = (() => {
18502
18832
  return fromBits(this.high, this.low, this.unsigned);
18503
18833
  if (numBits < 32) {
18504
18834
  b = 32 - numBits;
18505
- return fromBits(this.low << numBits | this.high >>> b, this.high << numBits | this.low >>> b, this.unsigned);
18835
+ return fromBits(
18836
+ this.low << numBits | this.high >>> b,
18837
+ this.high << numBits | this.low >>> b,
18838
+ this.unsigned
18839
+ );
18506
18840
  }
18507
18841
  numBits -= 32;
18508
18842
  b = 32 - numBits;
18509
- return fromBits(this.high << numBits | this.low >>> b, this.low << numBits | this.high >>> b, this.unsigned);
18843
+ return fromBits(
18844
+ this.high << numBits | this.low >>> b,
18845
+ this.low << numBits | this.high >>> b,
18846
+ this.unsigned
18847
+ );
18510
18848
  };
18511
18849
  LongPrototype.rotl = LongPrototype.rotateLeft;
18512
18850
  LongPrototype.rotateRight = function rotateRight(numBits) {
@@ -18519,11 +18857,19 @@ var __exports__ = (() => {
18519
18857
  return fromBits(this.high, this.low, this.unsigned);
18520
18858
  if (numBits < 32) {
18521
18859
  b = 32 - numBits;
18522
- return fromBits(this.high << b | this.low >>> numBits, this.low << b | this.high >>> numBits, this.unsigned);
18860
+ return fromBits(
18861
+ this.high << b | this.low >>> numBits,
18862
+ this.low << b | this.high >>> numBits,
18863
+ this.unsigned
18864
+ );
18523
18865
  }
18524
18866
  numBits -= 32;
18525
18867
  b = 32 - numBits;
18526
- return fromBits(this.low << b | this.high >>> numBits, this.high << b | this.low >>> numBits, this.unsigned);
18868
+ return fromBits(
18869
+ this.low << b | this.high >>> numBits,
18870
+ this.high << b | this.low >>> numBits,
18871
+ this.unsigned
18872
+ );
18527
18873
  };
18528
18874
  LongPrototype.rotr = LongPrototype.rotateRight;
18529
18875
  LongPrototype.toSigned = function toSigned() {
@@ -18582,6 +18928,23 @@ var __exports__ = (() => {
18582
18928
  unsigned
18583
18929
  );
18584
18930
  };
18931
+ if (typeof BigInt === "function") {
18932
+ Long.fromBigInt = function fromBigInt(value, unsigned) {
18933
+ var lowBits = Number(BigInt.asIntN(32, value));
18934
+ var highBits = Number(BigInt.asIntN(32, value >> BigInt(32)));
18935
+ return fromBits(lowBits, highBits, unsigned);
18936
+ };
18937
+ Long.fromValue = function fromValueWithBigInt(value, unsigned) {
18938
+ if (typeof value === "bigint")
18939
+ return Long.fromBigInt(value, unsigned);
18940
+ return fromValue(value, unsigned);
18941
+ };
18942
+ LongPrototype.toBigInt = function toBigInt2() {
18943
+ var lowBigInt = BigInt(this.low >>> 0);
18944
+ var highBigInt = BigInt(this.unsigned ? this.high >>> 0 : this.high);
18945
+ return highBigInt << BigInt(32) | lowBigInt;
18946
+ };
18947
+ }
18585
18948
  var long_default = Long;
18586
18949
 
18587
18950
  // src/lib/utils/s2/s2-token-functions.ts
@@ -19456,22 +19819,109 @@ var __exports__ = (() => {
19456
19819
  }
19457
19820
  };
19458
19821
 
19822
+ // ../zip/src/parse-zip/readable-file-utils.ts
19823
+ function toBigInt(value) {
19824
+ return typeof value === "bigint" ? value : BigInt(value);
19825
+ }
19826
+ function toNumber2(value) {
19827
+ const numberValue = Number(value);
19828
+ if (!Number.isFinite(numberValue)) {
19829
+ throw new Error("Offset is out of bounds");
19830
+ }
19831
+ return numberValue;
19832
+ }
19833
+ function normalizeOffset(offset, size) {
19834
+ if (offset < 0) {
19835
+ return Math.max(size + offset, 0);
19836
+ }
19837
+ return Math.min(offset, size);
19838
+ }
19839
+ async function readRange(file, start, end) {
19840
+ const startOffset = toBigInt(start);
19841
+ const endOffset = toBigInt(end);
19842
+ const length4 = endOffset - startOffset;
19843
+ if (length4 < 0) {
19844
+ throw new Error("Invalid range requested");
19845
+ }
19846
+ return await file.read(startOffset, toNumber2(length4));
19847
+ }
19848
+ async function readDataView(file, start, end) {
19849
+ const arrayBuffer = await readRange(file, start, end);
19850
+ return new DataView(arrayBuffer);
19851
+ }
19852
+ async function readUint16(file, offset) {
19853
+ const dataView = await readDataView(file, offset, toBigInt(offset) + 2n);
19854
+ return dataView.getUint16(0, true);
19855
+ }
19856
+ async function readUint32(file, offset) {
19857
+ const dataView = await readDataView(file, offset, toBigInt(offset) + 4n);
19858
+ return dataView.getUint32(0, true);
19859
+ }
19860
+ async function readBigUint64(file, offset) {
19861
+ const dataView = await readDataView(file, offset, toBigInt(offset) + 8n);
19862
+ return dataView.getBigUint64(0, true);
19863
+ }
19864
+ async function getReadableFileSize(file) {
19865
+ if (file.bigsize > 0n) {
19866
+ return file.bigsize;
19867
+ }
19868
+ if (file.size > 0) {
19869
+ return BigInt(file.size);
19870
+ }
19871
+ if (file.stat) {
19872
+ const stats = await file.stat();
19873
+ if (stats?.bigsize !== void 0) {
19874
+ return stats.bigsize;
19875
+ }
19876
+ if (stats?.size !== void 0) {
19877
+ return BigInt(stats.size);
19878
+ }
19879
+ }
19880
+ return 0n;
19881
+ }
19882
+ var DataViewReadableFile = class {
19883
+ handle;
19884
+ size;
19885
+ bigsize;
19886
+ url;
19887
+ constructor(dataView, url = "") {
19888
+ this.handle = dataView;
19889
+ this.size = dataView.byteLength;
19890
+ this.bigsize = BigInt(dataView.byteLength);
19891
+ this.url = url;
19892
+ }
19893
+ async close() {
19894
+ }
19895
+ async stat() {
19896
+ return { size: this.size, bigsize: this.bigsize, isDirectory: false };
19897
+ }
19898
+ async read(start = 0, length4) {
19899
+ const offset = toNumber2(start);
19900
+ const end = length4 ? offset + length4 : this.size;
19901
+ const normalizedStart = normalizeOffset(offset, this.size);
19902
+ const normalizedEnd = normalizeOffset(end, this.size);
19903
+ const clampedEnd = Math.max(normalizedEnd, normalizedStart);
19904
+ const lengthToRead = clampedEnd - normalizedStart;
19905
+ if (lengthToRead <= 0) {
19906
+ return new ArrayBuffer(0);
19907
+ }
19908
+ return copyToArrayBuffer2(this.handle.buffer, normalizedStart, lengthToRead);
19909
+ }
19910
+ };
19911
+
19459
19912
  // ../zip/src/parse-zip/search-from-the-end.ts
19460
19913
  var buffLength = 1024;
19461
19914
  var searchFromTheEnd = async (file, target) => {
19462
- const searchWindow = [
19463
- await file.getUint8(file.length - 1n),
19464
- await file.getUint8(file.length - 2n),
19465
- await file.getUint8(file.length - 3n),
19466
- void 0
19467
- ];
19915
+ const fileLength = await getReadableFileSize(file);
19916
+ const lastBytes = new Uint8Array(await readRange(file, fileLength - 3n, fileLength + 1n));
19917
+ const searchWindow = [lastBytes[3], lastBytes[2], lastBytes[1], void 0];
19468
19918
  let targetOffset = -1;
19469
- let point = file.length - 4n;
19919
+ let point = fileLength - 4n;
19470
19920
  do {
19471
19921
  const prevPoint = point;
19472
19922
  point -= BigInt(buffLength);
19473
19923
  point = point >= 0n ? point : 0n;
19474
- const buff = new Uint8Array(await file.slice(point, prevPoint));
19924
+ const buff = new Uint8Array(await readRange(file, point, prevPoint));
19475
19925
  for (let i = buff.length - 1; i > -1; i--) {
19476
19926
  searchWindow[3] = searchWindow[2];
19477
19927
  searchWindow[2] = searchWindow[1];
@@ -19499,23 +19949,24 @@ var __exports__ = (() => {
19499
19949
  var ZIP64_CD_START_OFFSET_OFFSET = 48n;
19500
19950
  var parseEoCDRecord = async (file) => {
19501
19951
  const zipEoCDOffset = await searchFromTheEnd(file, eoCDSignature);
19502
- let cdRecordsNumber = BigInt(await file.getUint16(zipEoCDOffset + CD_RECORDS_NUMBER_OFFSET));
19503
- let cdByteSize = BigInt(await file.getUint32(zipEoCDOffset + CD_CD_BYTE_SIZE_OFFSET));
19504
- let cdStartOffset = BigInt(await file.getUint32(zipEoCDOffset + CD_START_OFFSET_OFFSET));
19952
+ let cdRecordsNumber = BigInt(await readUint16(file, zipEoCDOffset + CD_RECORDS_NUMBER_OFFSET));
19953
+ let cdByteSize = BigInt(await readUint32(file, zipEoCDOffset + CD_CD_BYTE_SIZE_OFFSET));
19954
+ let cdStartOffset = BigInt(await readUint32(file, zipEoCDOffset + CD_START_OFFSET_OFFSET));
19505
19955
  let zip64EoCDLocatorOffset = zipEoCDOffset - 20n;
19506
19956
  let zip64EoCDOffset = 0n;
19507
- const magicBytes = await file.slice(zip64EoCDLocatorOffset, zip64EoCDLocatorOffset + 4n);
19508
- if (compareArrayBuffers(magicBytes, zip64EoCDLocatorSignature)) {
19509
- zip64EoCDOffset = await file.getBigUint64(
19957
+ const magicBytes = await readRange(file, zip64EoCDLocatorOffset, zip64EoCDLocatorOffset + 4n);
19958
+ if (compareArrayBuffers(magicBytes, zip64EoCDLocatorSignature.buffer)) {
19959
+ zip64EoCDOffset = await readBigUint64(
19960
+ file,
19510
19961
  zip64EoCDLocatorOffset + ZIP64_EOCD_START_OFFSET_OFFSET
19511
19962
  );
19512
- const endOfCDMagicBytes = await file.slice(zip64EoCDOffset, zip64EoCDOffset + 4n);
19963
+ const endOfCDMagicBytes = await readRange(file, zip64EoCDOffset, zip64EoCDOffset + 4n);
19513
19964
  if (!compareArrayBuffers(endOfCDMagicBytes, zip64EoCDSignature.buffer)) {
19514
19965
  throw new Error("zip64 EoCD not found");
19515
19966
  }
19516
- cdRecordsNumber = await file.getBigUint64(zip64EoCDOffset + ZIP64_CD_RECORDS_NUMBER_OFFSET);
19517
- cdByteSize = await file.getBigUint64(zip64EoCDOffset + ZIP64_CD_CD_BYTE_SIZE_OFFSET);
19518
- cdStartOffset = await file.getBigUint64(zip64EoCDOffset + ZIP64_CD_START_OFFSET_OFFSET);
19967
+ cdRecordsNumber = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_RECORDS_NUMBER_OFFSET);
19968
+ cdByteSize = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_CD_BYTE_SIZE_OFFSET);
19969
+ cdStartOffset = await readBigUint64(file, zip64EoCDOffset + ZIP64_CD_START_OFFSET_OFFSET);
19519
19970
  } else {
19520
19971
  zip64EoCDLocatorOffset = 0n;
19521
19972
  }
@@ -19679,12 +20130,11 @@ var __exports__ = (() => {
19679
20130
  var CD_FILE_NAME_OFFSET = 46n;
19680
20131
  var signature = new Uint8Array([80, 75, 1, 2]);
19681
20132
  var parseZipCDFileHeader = async (headerOffset, file) => {
19682
- if (headerOffset >= file.length) {
20133
+ const fileLength = await getReadableFileSize(file);
20134
+ if (headerOffset >= fileLength) {
19683
20135
  return null;
19684
20136
  }
19685
- const mainHeader = new DataView(
19686
- await file.slice(headerOffset, headerOffset + CD_FILE_NAME_OFFSET)
19687
- );
20137
+ const mainHeader = await readDataView(file, headerOffset, headerOffset + CD_FILE_NAME_OFFSET);
19688
20138
  const magicBytes = mainHeader.buffer.slice(0, 4);
19689
20139
  if (!compareArrayBuffers(magicBytes, signature.buffer)) {
19690
20140
  return null;
@@ -19694,7 +20144,8 @@ var __exports__ = (() => {
19694
20144
  const extraFieldLength = mainHeader.getUint16(CD_EXTRA_FIELD_LENGTH_OFFSET, true);
19695
20145
  const startDisk = BigInt(mainHeader.getUint16(CD_START_DISK_OFFSET, true));
19696
20146
  const fileNameLength = mainHeader.getUint16(CD_FILE_NAME_LENGTH_OFFSET, true);
19697
- const additionalHeader = await file.slice(
20147
+ const additionalHeader = await readRange(
20148
+ file,
19698
20149
  headerOffset + CD_FILE_NAME_OFFSET,
19699
20150
  headerOffset + CD_FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength)
19700
20151
  );
@@ -19724,8 +20175,8 @@ var __exports__ = (() => {
19724
20175
  };
19725
20176
  async function* makeZipCDHeaderIterator(fileProvider) {
19726
20177
  const { cdStartOffset, cdByteSize } = await parseEoCDRecord(fileProvider);
19727
- const centralDirectory = new DataViewFile(
19728
- new DataView(await fileProvider.slice(cdStartOffset, cdStartOffset + cdByteSize))
20178
+ const centralDirectory = new DataViewReadableFile(
20179
+ new DataView(await readRange(fileProvider, cdStartOffset, cdStartOffset + cdByteSize))
19729
20180
  );
19730
20181
  let cdHeader = await parseZipCDFileHeader(0n, centralDirectory);
19731
20182
  while (cdHeader) {
@@ -19887,14 +20338,15 @@ var __exports__ = (() => {
19887
20338
  var FILE_NAME_OFFSET = 30n;
19888
20339
  var signature2 = new Uint8Array([80, 75, 3, 4]);
19889
20340
  var parseZipLocalFileHeader = async (headerOffset, file) => {
19890
- const mainHeader = new DataView(await file.slice(headerOffset, headerOffset + FILE_NAME_OFFSET));
20341
+ const mainHeader = await readDataView(file, headerOffset, headerOffset + FILE_NAME_OFFSET);
19891
20342
  const magicBytes = mainHeader.buffer.slice(0, 4);
19892
- if (!compareArrayBuffers(magicBytes, signature2)) {
20343
+ if (!compareArrayBuffers(magicBytes, signature2.buffer)) {
19893
20344
  return null;
19894
20345
  }
19895
20346
  const fileNameLength = mainHeader.getUint16(FILE_NAME_LENGTH_OFFSET, true);
19896
20347
  const extraFieldLength = mainHeader.getUint16(EXTRA_FIELD_LENGTH_OFFSET, true);
19897
- const additionalHeader = await file.slice(
20348
+ const additionalHeader = await readRange(
20349
+ file,
19898
20350
  headerOffset + FILE_NAME_OFFSET,
19899
20351
  headerOffset + FILE_NAME_OFFSET + BigInt(fileNameLength + extraFieldLength)
19900
20352
  );
@@ -20093,16 +20545,16 @@ var __exports__ = (() => {
20093
20545
  }
20094
20546
 
20095
20547
  // ../crypto/src/lib/algorithms/md5-wasm.ts
20096
- var atb = typeof atob === "function" ? atob : typeof Buffer === "function" ? nodeATOB : identity4;
20097
- var wasmB64 = atb(
20548
+ var BASE64_LOOKUP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
20549
+ var wasmB64Bytes = decodeBase64Safely(
20098
20550
  "AGFzbQEAAAABDANgAX8AYAAAYAABfwIeAgdpbXBvcnRzA2xvZwAAB2ltcG9ydHMDbWVtAgABAzIxAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEAAAAAAAAAAAAAAAAAAAAAAgICAgIAAAAAAAaYARt/AUGBxpS6Bgt/AUGJ17b+fgt/AUH+uevFeQt/AUH2qMmBAQt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALB7oCJQhvbmVGdWxsQQAYCG9uZUZ1bGxCABkIb25lRnVsbEMAGghvbmVGdWxsRAAbBWxvb3BzAAEEbG9vcAACBXByaW1lAAMFbG9vcEEABAZsb29wQTEABQZsb29wQTIABgZsb29wQTMABwZsb29wQTQACAVsb29wQgAJBmxvb3BCMQAKBmxvb3BCMgALBmxvb3BCMwAMBmxvb3BCNAANBWxvb3BDAA4GbG9vcEMxAA8GbG9vcEMyABAGbG9vcEMzABEGbG9vcEM0ABIFbG9vcEQAEwZsb29wRDEAFAZsb29wRDIAFQZsb29wRDMAFgZsb29wRDQAFwRnZXRBACgEZ2V0QgApBGdldEMAKgRnZXREACsEZ2V0WAAsBHNldEEALQRzZXRCAC4Ec2V0QwAvBHNldEQAMARzZXRYADEKzA0xWwEBf0EAJAggAEEGdCEBAkADQCMIIAFGDQEjACQEIwEkBSMCJAYjAyQHEAIjBCMAaiQAIwUjAWokASMGIwJqJAIjByMDaiQDIwhBwABqJAgMAAsLIwgjGmokGgsTACMIIxpqJAkQAxAEEAkQDhATC6IBAEEAIwlqKAIAJApBBCMJaigCACQLQQgjCWooAgAkDEEMIwlqKAIAJA1BECMJaigCACQOQRQjCWooAgAkD0EYIwlqKAIAJBBBHCMJaigCACQRQSAjCWooAgAkEkEkIwlqKAIAJBNBKCMJaigCACQUQSwjCWooAgAkFUEwIwlqKAIAJBZBNCMJaigCACQXQTgjCWooAgAkGEE8IwlqKAIAJBkLCgAQBRAGEAcQCAsuAEH4yKq7fSMKahAYQdbunsZ+IwtqEBtB2+GBoQIjDGoQGkHunfeNfCMNahAZCy0AQa+f8Kt/Iw5qEBhBqoyfvAQjD2oQG0GTjMHBeiMQahAaQYGqmmojEWoQGQssAEHYsYLMBiMSahAYQa/vk9p4IxNqEBtBsbd9IxRqEBpBvq/zyngjFWoQGQstAEGiosDcBiMWahAYQZPj4WwjF2oQG0GOh+WzeiMYahAaQaGQ0M0EIxlqEBkLCgAQChALEAwQDQsuAEHiyviwfyMLahAcQcDmgoJ8IxBqEB9B0bT5sgIjFWoQHkGqj9vNfiMKahAdCy0AQd2gvLF9Iw9qEBxB06iQEiMUahAfQYHNh8V9IxlqEB5ByPfPvn4jDmoQHQsuAEHmm4ePAiMTahAcQdaP3Jl8IxhqEB9Bh5vUpn8jDWoQHkHtqeiqBCMSahAdCy0AQYXSj896IxdqEBxB+Me+ZyMMahAfQdmFvLsGIxFqEB5Bipmp6XgjFmoQHQsKABAPEBAQERASCysAQcLyaCMPahAgQYHtx7t4IxJqECNBosL17AYjFWoQIkGM8JRvIxhqECELLgBBxNT7pXojC2oQIEGpn/veBCMOahAjQeCW7bV/IxFqECJB8Pj+9XsjFGoQIQstAEHG/e3EAiMXahAgQfrPhNV+IwpqECNBheG8p30jDWoQIkGFuqAkIxBqECELLgBBuaDTzn0jE2oQIEHls+62fiMWahAjQfj5if0BIxlqECJB5ayxpXwjDGoQIQsKABAUEBUQFhAXCy0AQcTEpKF/IwpqECRBl/+rmQQjEWoQJ0Gnx9DceiMYahAmQbnAzmQjD2oQJQstAEHDs+2qBiMWahAkQZKZs/h4Iw1qECdB/ei/fyMUahAmQdG7kax4IwtqECULLQBBz/yh/QYjEmoQJEHgzbNxIxlqECdBlIaFmHojEGoQJkGho6DwBCMXahAlCy4AQYL9zbp/Iw5qECRBteTr6XsjFWoQJ0G7pd/WAiMMahAmQZGnm9x+IxNqECULKAEBf0F/IwFzIwNxIwEjAnFyIwBqIABqIgFBB3QgAUEZdnIjAWokAAsoAQF/QX8jAnMjAHEjAiMDcXIjAWogAGoiAUEWdCABQQp2ciMCaiQBCygBAX9BfyMDcyMBcSMDIwBxciMCaiAAaiIBQRF0IAFBD3ZyIwNqJAILKAEBf0F/IwBzIwJxIwAjAXFyIwNqIABqIgFBDHQgAUEUdnIjAGokAwsoAQF/IwJBfyMDc3EjASMDcXIjAGogAGoiAUEFdCABQRt2ciMBaiQACygBAX8jA0F/IwBzcSMCIwBxciMBaiAAaiIBQRR0IAFBDHZyIwJqJAELKAEBfyMAQX8jAXNxIwMjAXFyIwJqIABqIgFBDnQgAUESdnIjA2okAgsoAQF/IwFBfyMCc3EjACMCcXIjA2ogAGoiAUEJdCABQRd2ciMAaiQDCyIBAX8jASMCcyMDcyMAaiAAaiIBQQR0IAFBHHZyIwFqJAALIgEBfyMCIwNzIwBzIwFqIABqIgFBF3QgAUEJdnIjAmokAQsiAQF/IwMjAHMjAXMjAmogAGoiAUEQdCABQRB2ciMDaiQCCyIBAX8jACMBcyMCcyMDaiAAaiIBQQt0IAFBFXZyIwBqJAMLJQEBf0F/IwNzIwFyIwJzIwBqIABqIgFBBnQgAUEadnIjAWokAAslAQF/QX8jAHMjAnIjA3MjAWogAGoiAUEVdCABQQt2ciMCaiQBCyUBAX9BfyMBcyMDciMAcyMCaiAAaiIBQQ90IAFBEXZyIwNqJAILJQEBf0F/IwJzIwByIwFzIwNqIABqIgFBCnQgAUEWdnIjAGokAwsEACMACwQAIwELBAAjAgsEACMDCwQAIxoLBgAgACQACwYAIAAkAQsGACAAJAILBgAgACQDCwYAIAAkGgsA6gQEbmFtZQGSAzIAA2xvZwEFbG9vcHMCBGxvb3ADBXByaW1lBAVsb29wQQUGbG9vcEExBgZsb29wQTIHBmxvb3BBMwgGbG9vcEE0CQVsb29wQgoGbG9vcEIxCwZsb29wQjIMBmxvb3BCMw0GbG9vcEI0DgVsb29wQw8GbG9vcEMxEAZsb29wQzIRBmxvb3BDMxIGbG9vcEM0EwVsb29wRBQGbG9vcEQxFQZsb29wRDIWBmxvb3BEMxcGbG9vcEQ0GAhvbmVGdWxsQRkIb25lRnVsbEIaCG9uZUZ1bGxDGwhvbmVGdWxsRBwIdHdvRnVsbEEdCHR3b0Z1bGxCHgh0d29GdWxsQx8IdHdvRnVsbEQgCHRyZUZ1bGxBIQh0cmVGdWxsQiIIdHJlRnVsbEMjCHRyZUZ1bGxEJAhxdWFGdWxsQSUIcXVhRnVsbEImCHF1YUZ1bGxDJwhxdWFGdWxsRCgEZ2V0QSkEZ2V0QioEZ2V0QysEZ2V0RCwEZ2V0WC0Ec2V0QS4Ec2V0Qi8Ec2V0QzAEc2V0RDEEc2V0WALNATIAAQAAAQIAAAEIbnVtbG9vcHMCAAMABAAFAAYABwAIAAkACgALAAwADQAOAA8AEAARABIAEwAUABUAFgAXABgCAAABAW4ZAgAAAQFuGgIAAAEBbhsCAAABAW4cAgAAAQFuHQIAAAEBbh4CAAABAW4fAgAAAQFuIAIAAAEBbiECAAABAW4iAgAAAQFuIwIAAAEBbiQCAAABAW4lAgAAAQFuJgIAAAEBbicCAAABAW4oACkAKgArACwALQEAAC4BAAAvAQAAMAEAADEBAAA="
20099
20551
  );
20100
- var wasm2 = WebAssembly && atb !== identity4 ? str2AB(wasmB64).buffer : false;
20552
+ var wasm2 = typeof WebAssembly !== "undefined" && wasmB64Bytes ? wasmB64Bytes.buffer : false;
20101
20553
  var crypt = makeCrypt();
20102
20554
  var biteSize = 240 * 16 * 16;
20103
20555
  var bounder = Math.floor(biteSize * 16 * 1.066666667);
20104
20556
  var upperLimit = 268435456 - 65536;
20105
- var parmTypeErrStr = "Parameter must be Buffer, ArrayBuffer or Uint8Array";
20557
+ var parmTypeErrStr = "Parameter must be ArrayBuffer, ArrayBufferView or string";
20106
20558
  var tooBigErrStr = "Parameter exceeds max size of 255.9 Mbytes";
20107
20559
  if (!wasm2) {
20108
20560
  console.log(
@@ -20121,20 +20573,9 @@ var __exports__ = (() => {
20121
20573
  catchFun = fun;
20122
20574
  return returnObj;
20123
20575
  };
20124
- if (true) {
20125
- if (data && typeof data === "object") {
20126
- if (typeof Buffer === "function" && data.constructor === Buffer) {
20127
- buff = data;
20128
- } else {
20129
- if (data.constructor === Uint8Array || data.constructor === ArrayBuffer) {
20130
- buff = data.constructor === ArrayBuffer ? new Uint8Array(data) : data;
20131
- } else {
20132
- getCatch(new TypeError(parmTypeErrStr));
20133
- }
20134
- }
20135
- } else {
20136
- getCatch(new TypeError(parmTypeErrStr));
20137
- }
20576
+ buff = normalizeInput(data);
20577
+ if (!buff) {
20578
+ getCatch(new TypeError(parmTypeErrStr));
20138
20579
  }
20139
20580
  if (buff) {
20140
20581
  len2 = buff.length;
@@ -20450,21 +20891,62 @@ var __exports__ = (() => {
20450
20891
  return result;
20451
20892
  };
20452
20893
  }
20453
- function str2AB(str3) {
20454
- var l, buff, buffView, i = -1;
20455
- l = str3.length - 1;
20456
- buff = new ArrayBuffer(str3.length);
20457
- buffView = new Uint8Array(buff);
20458
- while (l > i++) {
20459
- buffView[i] = str3.charCodeAt(i);
20894
+ function decodeBase64Safely(str3) {
20895
+ try {
20896
+ return decodeBase64ToUint8Array(str3);
20897
+ } catch (error) {
20898
+ return null;
20460
20899
  }
20461
- return buffView;
20462
20900
  }
20463
- function nodeATOB(str3) {
20464
- return Buffer.from(str3, "base64").toString("binary");
20901
+ function decodeBase64ToUint8Array(base64) {
20902
+ var sanitized = base64.replace(/-/g, "+").replace(/_/g, "/");
20903
+ if (typeof atob === "function") {
20904
+ return binaryStringToUint8Array(atob(sanitized));
20905
+ }
20906
+ return decodeBase64WithoutAtob(sanitized);
20465
20907
  }
20466
- function identity4(x) {
20467
- return x;
20908
+ function decodeBase64WithoutAtob(base64) {
20909
+ var paddingLength = base64.endsWith("==") ? 2 : base64.endsWith("=") ? 1 : 0, byteLength = base64.length * 3 / 4 - paddingLength, bytes = new Uint8Array(byteLength), byteIndex = 0, i = 0, enc1, enc2, enc3, enc4;
20910
+ while (i < base64.length) {
20911
+ enc1 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
20912
+ enc2 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
20913
+ enc3 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
20914
+ enc4 = BASE64_LOOKUP.indexOf(base64.charAt(i++));
20915
+ if (enc1 < 0 || enc2 < 0 || enc3 < 0 || enc4 < 0) {
20916
+ throw new TypeError("Invalid base64 input");
20917
+ }
20918
+ bytes[byteIndex++] = enc1 << 2 | enc2 >> 4;
20919
+ if (enc3 < 64 && byteIndex < byteLength) {
20920
+ bytes[byteIndex++] = (enc2 & 15) << 4 | enc3 >> 2;
20921
+ }
20922
+ if (enc4 < 64 && byteIndex < byteLength) {
20923
+ bytes[byteIndex++] = (enc3 & 3) << 6 | enc4;
20924
+ }
20925
+ }
20926
+ return bytes;
20927
+ }
20928
+ function binaryStringToUint8Array(str3) {
20929
+ var length4 = str3.length, view = new Uint8Array(length4), i = 0;
20930
+ while (i < length4) {
20931
+ view[i] = str3.charCodeAt(i);
20932
+ i++;
20933
+ }
20934
+ return view;
20935
+ }
20936
+ function normalizeInput(data) {
20937
+ if (data instanceof Uint8Array) {
20938
+ return data;
20939
+ }
20940
+ if (typeof ArrayBuffer !== "undefined" && data instanceof ArrayBuffer) {
20941
+ return new Uint8Array(data);
20942
+ }
20943
+ if (data && typeof data === "object" && ArrayBuffer.isView(data)) {
20944
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
20945
+ }
20946
+ if (typeof data === "string") {
20947
+ return new TextEncoder().encode(data);
20948
+ }
20949
+ return null;
20468
20950
  }
20469
20951
  function makeCrypt() {
20470
20952
  var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -20636,7 +21118,7 @@ var __exports__ = (() => {
20636
21118
  const pakoOptions = this.options?.deflate || {};
20637
21119
  const inputArray = new Uint8Array(input);
20638
21120
  const deflate = this.options?.raw ? import_pako.default.deflateRaw : import_pako.default.deflate;
20639
- return deflate(inputArray, pakoOptions).buffer;
21121
+ return toArrayBuffer2(deflate(inputArray, pakoOptions).buffer);
20640
21122
  }
20641
21123
  decompressSync(input) {
20642
21124
  if (!isBrowser && this.options.deflate?.useZlib) {
@@ -20646,7 +21128,7 @@ var __exports__ = (() => {
20646
21128
  const pakoOptions = this.options?.deflate || {};
20647
21129
  const inputArray = new Uint8Array(input);
20648
21130
  const inflate = this.options?.raw ? import_pako.default.inflateRaw : import_pako.default.inflate;
20649
- return inflate(inputArray, pakoOptions).buffer;
21131
+ return toArrayBuffer2(inflate(inputArray, pakoOptions).buffer);
20650
21132
  }
20651
21133
  async *compressBatches(asyncIterator) {
20652
21134
  const pakoOptions = this.options?.deflate || {};
@@ -20728,34 +21210,35 @@ var __exports__ = (() => {
20728
21210
  }
20729
21211
  };
20730
21212
  var ZipFileSystem = class {
20731
- /** FileProvider instance promise */
20732
- fileProvider = null;
21213
+ /** File instance */
21214
+ file = null;
20733
21215
  fileName;
20734
21216
  archive = null;
20735
21217
  /**
20736
21218
  * Constructor
20737
- * @param file - instance of FileProvider or file path string
21219
+ * @param file - instance of ReadableFile or file path string
20738
21220
  */
20739
21221
  constructor(file) {
20740
21222
  if (typeof file === "string") {
20741
21223
  this.fileName = file;
20742
- if (!isBrowser) {
20743
- this.fileProvider = new FileHandleFile(file);
20744
- } else {
20745
- throw new Error("Cannot open file for random access in a WEB browser");
21224
+ if (isBrowser) {
21225
+ throw new Error("ZipFileSystem cannot open file paths in browser environments");
20746
21226
  }
21227
+ this.file = new NodeFileFacade(file);
21228
+ } else if (file instanceof Blob || file instanceof ArrayBuffer) {
21229
+ this.file = new BlobFile(file);
20747
21230
  } else if (file instanceof IndexedArchive) {
20748
- this.fileProvider = file.fileProvider;
21231
+ this.file = file.file;
20749
21232
  this.archive = file;
20750
21233
  this.fileName = file.fileName;
20751
- } else if (isFileProvider(file)) {
20752
- this.fileProvider = file;
21234
+ } else {
21235
+ this.file = file;
20753
21236
  }
20754
21237
  }
20755
21238
  /** Clean up resources */
20756
21239
  async destroy() {
20757
- if (this.fileProvider) {
20758
- await this.fileProvider.destroy();
21240
+ if (this.file) {
21241
+ await this.file.close();
20759
21242
  }
20760
21243
  }
20761
21244
  /**
@@ -20763,11 +21246,11 @@ var __exports__ = (() => {
20763
21246
  * @returns array of file names
20764
21247
  */
20765
21248
  async readdir() {
20766
- if (!this.fileProvider) {
21249
+ if (!this.file) {
20767
21250
  throw new Error("No data detected in the zip archive");
20768
21251
  }
20769
21252
  const fileNames = [];
20770
- const zipCDIterator = makeZipCDHeaderIterator(this.fileProvider);
21253
+ const zipCDIterator = makeZipCDHeaderIterator(this.file);
20771
21254
  for await (const cdHeader of zipCDIterator) {
20772
21255
  fileNames.push(cdHeader.fileName);
20773
21256
  }
@@ -20795,13 +21278,13 @@ var __exports__ = (() => {
20795
21278
  if (this.archive) {
20796
21279
  uncompressedFile = await this.archive.getFile(filename2, "http");
20797
21280
  } else {
20798
- if (!this.fileProvider) {
21281
+ if (!this.file) {
20799
21282
  throw new Error("No data detected in the zip archive");
20800
21283
  }
20801
21284
  const cdFileHeader = await this.getCDFileHeader(filename2);
20802
21285
  const localFileHeader = await parseZipLocalFileHeader(
20803
21286
  cdFileHeader.localHeaderOffset,
20804
- this.fileProvider
21287
+ this.file
20805
21288
  );
20806
21289
  if (!localFileHeader) {
20807
21290
  throw new Error("Local file header has not been found in the zip archive`");
@@ -20810,7 +21293,8 @@ var __exports__ = (() => {
20810
21293
  if (!compressionHandler) {
20811
21294
  throw Error("Only Deflation compression is supported");
20812
21295
  }
20813
- const compressedFile = await this.fileProvider.slice(
21296
+ const compressedFile = await readRange(
21297
+ this.file,
20814
21298
  localFileHeader.fileDataOffset,
20815
21299
  localFileHeader.fileDataOffset + localFileHeader.compressedSize
20816
21300
  );
@@ -20828,10 +21312,10 @@ var __exports__ = (() => {
20828
21312
  * @returns central directory file header
20829
21313
  */
20830
21314
  async getCDFileHeader(filename2) {
20831
- if (!this.fileProvider) {
21315
+ if (!this.file) {
20832
21316
  throw new Error("No data detected in the zip archive");
20833
21317
  }
20834
- const zipCDIterator = makeZipCDHeaderIterator(this.fileProvider);
21318
+ const zipCDIterator = makeZipCDHeaderIterator(this.file);
20835
21319
  let result = null;
20836
21320
  for await (const cdHeader of zipCDIterator) {
20837
21321
  if (cdHeader.fileName === filename2) {
@@ -20848,16 +21332,16 @@ var __exports__ = (() => {
20848
21332
 
20849
21333
  // ../zip/src/filesystems/IndexedArchive.ts
20850
21334
  var IndexedArchive = class {
20851
- fileProvider;
21335
+ file;
20852
21336
  fileName;
20853
21337
  /**
20854
21338
  * Constructor
20855
- * @param fileProvider - instance of a binary data reader
21339
+ * @param fileProvider - readable file instance for random access
20856
21340
  * @param hashTable - pre-loaded hashTable. If presented, getFile will skip reading the hash file
20857
21341
  * @param fileName - name of the archive. It is used to add to an URL of a loader context
20858
21342
  */
20859
- constructor(fileProvider, hashTable, fileName) {
20860
- this.fileProvider = fileProvider;
21343
+ constructor(file, hashTable, fileName) {
21344
+ this.file = file;
20861
21345
  this.fileName = fileName;
20862
21346
  }
20863
21347
  /**
@@ -20866,7 +21350,7 @@ var __exports__ = (() => {
20866
21350
  * @returns
20867
21351
  */
20868
21352
  async getFileWithoutHash(filename2) {
20869
- const zipFS = new ZipFileSystem(this.fileProvider);
21353
+ const zipFS = new ZipFileSystem(this.file);
20870
21354
  const response = await zipFS.fetch(filename2);
20871
21355
  return await response.arrayBuffer();
20872
21356
  }
@@ -20915,7 +21399,7 @@ var __exports__ = (() => {
20915
21399
  hashTable;
20916
21400
  /**
20917
21401
  * creates Tiles3DArchive handler
20918
- * @param fileProvider - FileProvider with the whole file
21402
+ * @param fileProvider - readable file handle with the whole archive
20919
21403
  * @param hashTable - hash info
20920
21404
  */
20921
21405
  constructor(fileProvider, hashTable, fileName) {
@@ -20951,11 +21435,12 @@ var __exports__ = (() => {
20951
21435
  if (byteOffset === void 0) {
20952
21436
  return null;
20953
21437
  }
20954
- const localFileHeader = await parseZipLocalFileHeader(byteOffset, this.fileProvider);
21438
+ const localFileHeader = await parseZipLocalFileHeader(byteOffset, this.file);
20955
21439
  if (!localFileHeader) {
20956
21440
  return null;
20957
21441
  }
20958
- const compressedFile = await this.fileProvider.slice(
21442
+ const compressedFile = await readRange(
21443
+ this.file,
20959
21444
  localFileHeader.fileDataOffset,
20960
21445
  localFileHeader.fileDataOffset + localFileHeader.compressedSize
20961
21446
  );
@@ -20990,7 +21475,8 @@ var __exports__ = (() => {
20990
21475
  throw new Error("corrupted 3tz zip archive");
20991
21476
  }
20992
21477
  const fileDataOffset = localFileHeader.fileDataOffset;
20993
- const hashFile = await fileProvider.slice(
21478
+ const hashFile = await readRange(
21479
+ fileProvider,
20994
21480
  fileDataOffset,
20995
21481
  fileDataOffset + localFileHeader.compressedSize
20996
21482
  );
@@ -21014,7 +21500,9 @@ var __exports__ = (() => {
21014
21500
  options: {}
21015
21501
  };
21016
21502
  async function parse3DTilesArchive2(data, options = {}) {
21017
- const archive = await parse3DTilesArchive(new DataViewFile(new DataView(data)));
21503
+ const archive = await parse3DTilesArchive(
21504
+ new DataViewReadableFile(new DataView(data))
21505
+ );
21018
21506
  return archive.getFile(options["3d-tiles-archive"]?.path ?? "");
21019
21507
  }
21020
21508