@luma.gl/core 9.0.0 → 9.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -97,39 +97,37 @@ var __exports__ = (() => {
97
97
  uid: () => uid
98
98
  });
99
99
 
100
+ // ../../node_modules/@probe.gl/env/dist/lib/globals.js
101
+ var window_ = globalThis;
102
+ var document_ = globalThis.document || {};
103
+ var process_ = globalThis.process || {};
104
+ var console_ = globalThis.console;
105
+ var navigator_ = globalThis.navigator || {};
106
+
100
107
  // ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
101
108
  function isElectron(mockUserAgent) {
102
- if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
109
+ if (typeof window !== "undefined" && window.process?.type === "renderer") {
103
110
  return true;
104
111
  }
105
- if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
112
+ if (typeof process !== "undefined" && Boolean(process.versions?.["electron"])) {
106
113
  return true;
107
114
  }
108
- const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
115
+ const realUserAgent = typeof navigator !== "undefined" && navigator.userAgent;
109
116
  const userAgent = mockUserAgent || realUserAgent;
110
- if (userAgent && userAgent.indexOf("Electron") >= 0) {
111
- return true;
112
- }
113
- return false;
117
+ return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
114
118
  }
115
119
 
116
120
  // ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
117
121
  function isBrowser() {
118
- const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
122
+ const isNode = (
123
+ // @ts-expect-error
124
+ typeof process === "object" && String(process) === "[object process]" && !process?.browser
125
+ );
119
126
  return !isNode || isElectron();
120
127
  }
121
128
 
122
- // ../../node_modules/@probe.gl/env/dist/lib/globals.js
123
- var self_ = globalThis.self || globalThis.window || globalThis.global;
124
- var window_ = globalThis.window || globalThis.self || globalThis.global;
125
- var document_ = globalThis.document || {};
126
- var process_ = globalThis.process || {};
127
- var console_ = globalThis.console;
128
- var navigator_ = globalThis.navigator || {};
129
-
130
- // ../../node_modules/@probe.gl/env/dist/utils/globals.js
131
- var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
132
- var isBrowser2 = isBrowser();
129
+ // ../../node_modules/@probe.gl/env/dist/index.js
130
+ var VERSION = true ? "4.0.7" : "untranspiled source";
133
131
 
134
132
  // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
135
133
  function getStorage(type) {
@@ -144,11 +142,7 @@ var __exports__ = (() => {
144
142
  }
145
143
  }
146
144
  var LocalStorage = class {
147
- constructor(id, defaultConfig) {
148
- let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
149
- this.storage = void 0;
150
- this.id = void 0;
151
- this.config = void 0;
145
+ constructor(id, defaultConfig, type = "sessionStorage") {
152
146
  this.storage = getStorage(type);
153
147
  this.id = id;
154
148
  this.config = defaultConfig;
@@ -164,6 +158,7 @@ var __exports__ = (() => {
164
158
  this.storage.setItem(this.id, serialized);
165
159
  }
166
160
  }
161
+ // Get config from persistent store, if available
167
162
  _loadConfiguration() {
168
163
  let configuration = {};
169
164
  if (this.storage) {
@@ -189,22 +184,10 @@ var __exports__ = (() => {
189
184
  }
190
185
  return formatted;
191
186
  }
192
- function leftPad(string) {
193
- let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
187
+ function leftPad(string, length = 8) {
194
188
  const padLength = Math.max(length - string.length, 0);
195
189
  return `${" ".repeat(padLength)}${string}`;
196
190
  }
197
- function formatImage(image, message, scale) {
198
- let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
199
- const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
200
- if (image.width > maxWidth) {
201
- scale = Math.min(scale, maxWidth / image.width);
202
- }
203
- const width = image.width * scale;
204
- const height = image.height * scale;
205
- const style = ["font-size:1px;", `padding:${Math.floor(height / 2)}px ${Math.floor(width / 2)}px;`, `line-height:${height}px;`, `background:url(${imageUrl});`, `background-size:${width}px ${height}px;`, "color:transparent;"].join("");
206
- return [`${message} %c+`, style];
207
- }
208
191
 
209
192
  // ../../node_modules/@probe.gl/log/dist/utils/color.js
210
193
  var COLOR;
@@ -249,8 +232,7 @@ var __exports__ = (() => {
249
232
  }
250
233
 
251
234
  // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
252
- function autobind(obj) {
253
- let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
235
+ function autobind(obj, predefined = ["constructor"]) {
254
236
  const proto = Object.getPrototypeOf(obj);
255
237
  const propNames = Object.getOwnPropertyNames(proto);
256
238
  const object = obj;
@@ -275,11 +257,9 @@ var __exports__ = (() => {
275
257
  function getHiResTimestamp() {
276
258
  let timestamp;
277
259
  if (isBrowser() && window_.performance) {
278
- var _window$performance, _window$performance$n;
279
- timestamp = window_ === null || window_ === void 0 ? void 0 : (_window$performance = window_.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
260
+ timestamp = window_?.performance?.now?.();
280
261
  } else if ("hrtime" in process_) {
281
- var _process$hrtime;
282
- const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
262
+ const timeParts = process_?.hrtime?.();
283
263
  timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
284
264
  } else {
285
265
  timestamp = Date.now();
@@ -302,21 +282,12 @@ var __exports__ = (() => {
302
282
  function noop() {
303
283
  }
304
284
  var cache = {};
305
- var ONCE = {
306
- once: true
307
- };
285
+ var ONCE = { once: true };
308
286
  var Log = class {
309
- constructor() {
310
- let {
311
- id
312
- } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
313
- id: ""
314
- };
315
- this.id = void 0;
287
+ constructor({ id } = { id: "" }) {
316
288
  this.VERSION = VERSION;
317
289
  this._startTs = getHiResTimestamp();
318
290
  this._deltaTs = getHiResTimestamp();
319
- this._storage = void 0;
320
291
  this.userData = {};
321
292
  this.LOG_THROTTLE_TIMEOUT = 0;
322
293
  this.id = id;
@@ -338,42 +309,44 @@ var __exports__ = (() => {
338
309
  getLevel() {
339
310
  return this._storage.config.level;
340
311
  }
312
+ /** @return milliseconds, with fractions */
341
313
  getTotal() {
342
314
  return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
343
315
  }
316
+ /** @return milliseconds, with fractions */
344
317
  getDelta() {
345
318
  return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
346
319
  }
320
+ /** @deprecated use logLevel */
347
321
  set priority(newPriority) {
348
322
  this.level = newPriority;
349
323
  }
324
+ /** @deprecated use logLevel */
350
325
  get priority() {
351
326
  return this.level;
352
327
  }
328
+ /** @deprecated use logLevel */
353
329
  getPriority() {
354
330
  return this.level;
355
331
  }
356
- enable() {
357
- let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
358
- this._storage.setConfiguration({
359
- enabled
360
- });
332
+ // Configure
333
+ enable(enabled = true) {
334
+ this._storage.setConfiguration({ enabled });
361
335
  return this;
362
336
  }
363
337
  setLevel(level) {
364
- this._storage.setConfiguration({
365
- level
366
- });
338
+ this._storage.setConfiguration({ level });
367
339
  return this;
368
340
  }
341
+ /** return the current status of the setting */
369
342
  get(setting) {
370
343
  return this._storage.config[setting];
371
344
  }
345
+ // update the status of the setting
372
346
  set(setting, value) {
373
- this._storage.setConfiguration({
374
- [setting]: value
375
- });
347
+ this._storage.setConfiguration({ [setting]: value });
376
348
  }
349
+ /** Logs the current settings as a table */
377
350
  settings() {
378
351
  if (console.table) {
379
352
  console.table(this._storage.config);
@@ -381,8 +354,11 @@ var __exports__ = (() => {
381
354
  console.log(this._storage.config);
382
355
  }
383
356
  }
357
+ // Unconditional logging
384
358
  assert(condition, message) {
385
- assert(condition, message);
359
+ if (!condition) {
360
+ throw new Error(message || "Assertion failed");
361
+ }
386
362
  }
387
363
  warn(message) {
388
364
  return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
@@ -390,9 +366,11 @@ var __exports__ = (() => {
390
366
  error(message) {
391
367
  return this._getLogFunction(0, message, originalConsole.error, arguments);
392
368
  }
369
+ /** Print a deprecation warning */
393
370
  deprecated(oldUsage, newUsage) {
394
371
  return this.warn(`\`${oldUsage}\` is deprecated and will be removed in a later version. Use \`${newUsage}\` instead`);
395
372
  }
373
+ /** Print a removal warning */
396
374
  removed(oldUsage, newUsage) {
397
375
  return this.error(`\`${oldUsage}\` has been removed. Use \`${newUsage}\` instead`);
398
376
  }
@@ -411,6 +389,7 @@ var __exports__ = (() => {
411
389
  once(logLevel, message) {
412
390
  return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
413
391
  }
392
+ /** Logs an object as a table */
414
393
  table(logLevel, table, columns) {
415
394
  if (table) {
416
395
  return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
@@ -419,27 +398,6 @@ var __exports__ = (() => {
419
398
  }
420
399
  return noop;
421
400
  }
422
- image(_ref) {
423
- let {
424
- logLevel,
425
- priority,
426
- image,
427
- message = "",
428
- scale = 1
429
- } = _ref;
430
- if (!this._shouldLog(logLevel || priority)) {
431
- return noop;
432
- }
433
- return isBrowser() ? logImageInBrowser({
434
- image,
435
- message,
436
- scale
437
- }) : logImageInNode({
438
- image,
439
- message,
440
- scale
441
- });
442
- }
443
401
  time(logLevel, message) {
444
402
  return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
445
403
  }
@@ -449,30 +407,19 @@ var __exports__ = (() => {
449
407
  timeStamp(logLevel, message) {
450
408
  return this._getLogFunction(logLevel, message, console.timeStamp || noop);
451
409
  }
452
- group(logLevel, message) {
453
- let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
454
- collapsed: false
455
- };
456
- const options = normalizeArguments({
457
- logLevel,
458
- message,
459
- opts
460
- });
461
- const {
462
- collapsed
463
- } = opts;
410
+ group(logLevel, message, opts = { collapsed: false }) {
411
+ const options = normalizeArguments({ logLevel, message, opts });
412
+ const { collapsed } = opts;
464
413
  options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
465
414
  return this._getLogFunction(options);
466
415
  }
467
- groupCollapsed(logLevel, message) {
468
- let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
469
- return this.group(logLevel, message, Object.assign({}, opts, {
470
- collapsed: true
471
- }));
416
+ groupCollapsed(logLevel, message, opts = {}) {
417
+ return this.group(logLevel, message, Object.assign({}, opts, { collapsed: true }));
472
418
  }
473
419
  groupEnd(logLevel) {
474
420
  return this._getLogFunction(logLevel, "", console.groupEnd || noop);
475
421
  }
422
+ // EXPERIMENTAL
476
423
  withGroup(logLevel, message, func) {
477
424
  this.group(logLevel, message)();
478
425
  try {
@@ -486,17 +433,14 @@ var __exports__ = (() => {
486
433
  console.trace();
487
434
  }
488
435
  }
436
+ // PRIVATE METHODS
437
+ /** Deduces log level from a variety of arguments */
489
438
  _shouldLog(logLevel) {
490
439
  return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
491
440
  }
492
441
  _getLogFunction(logLevel, message, method, args, opts) {
493
442
  if (this._shouldLog(logLevel)) {
494
- opts = normalizeArguments({
495
- logLevel,
496
- message,
497
- args,
498
- opts
499
- });
443
+ opts = normalizeArguments({ logLevel, message, args, opts });
500
444
  method = method || opts.method;
501
445
  assert(method);
502
446
  opts.total = this.getTotal();
@@ -536,10 +480,7 @@ var __exports__ = (() => {
536
480
  return resolvedLevel;
537
481
  }
538
482
  function normalizeArguments(opts) {
539
- const {
540
- logLevel,
541
- message
542
- } = opts;
483
+ const { logLevel, message } = opts;
543
484
  opts.logLevel = normalizeLogLevel(logLevel);
544
485
  const args = opts.args ? Array.from(opts.args) : [];
545
486
  while (args.length && args.shift() !== message) {
@@ -562,9 +503,7 @@ var __exports__ = (() => {
562
503
  }
563
504
  const messageType = typeof opts.message;
564
505
  assert(messageType === "string" || messageType === "object");
565
- return Object.assign(opts, {
566
- args
567
- }, opts.opts);
506
+ return Object.assign(opts, { args }, opts.opts);
568
507
  }
569
508
  function decorateMessage(id, message, opts) {
570
509
  if (typeof message === "string") {
@@ -574,43 +513,6 @@ var __exports__ = (() => {
574
513
  }
575
514
  return message;
576
515
  }
577
- function logImageInNode(_ref2) {
578
- let {
579
- image,
580
- message = "",
581
- scale = 1
582
- } = _ref2;
583
- console.warn("removed");
584
- return noop;
585
- }
586
- function logImageInBrowser(_ref3) {
587
- let {
588
- image,
589
- message = "",
590
- scale = 1
591
- } = _ref3;
592
- if (typeof image === "string") {
593
- const img = new Image();
594
- img.onload = () => {
595
- const args = formatImage(img, message, scale);
596
- console.log(...args);
597
- };
598
- img.src = image;
599
- return noop;
600
- }
601
- const element = image.nodeName || "";
602
- if (element.toLowerCase() === "img") {
603
- console.log(...formatImage(image, message, scale));
604
- return noop;
605
- }
606
- if (element.toLowerCase() === "canvas") {
607
- const img = new Image();
608
- img.onload = () => console.log(...formatImage(img, message, scale));
609
- img.src = image.toDataURL();
610
- return noop;
611
- }
612
- return noop;
613
- }
614
516
  function getTableHeader(table) {
615
517
  for (const key in table) {
616
518
  for (const title in table[key]) {
@@ -620,10 +522,11 @@ var __exports__ = (() => {
620
522
  return "empty";
621
523
  }
622
524
 
525
+ // ../../node_modules/@probe.gl/log/dist/init.js
526
+ globalThis.probe = {};
527
+
623
528
  // ../../node_modules/@probe.gl/log/dist/index.js
624
- var dist_default = new Log({
625
- id: "@probe.gl/log"
626
- });
529
+ var dist_default = new Log({ id: "@probe.gl/log" });
627
530
 
628
531
  // src/utils/log.ts
629
532
  var log = new Log({ id: "luma.gl" });
@@ -645,8 +548,6 @@ var __exports__ = (() => {
645
548
  // ../../node_modules/@probe.gl/stats/dist/lib/stat.js
646
549
  var Stat = class {
647
550
  constructor(name2, type) {
648
- this.name = void 0;
649
- this.type = void 0;
650
551
  this.sampleSize = 1;
651
552
  this.time = 0;
652
553
  this.count = 0;
@@ -681,26 +582,31 @@ var __exports__ = (() => {
681
582
  this.sampleSize = samples;
682
583
  return this;
683
584
  }
585
+ /** Call to increment count (+1) */
684
586
  incrementCount() {
685
587
  this.addCount(1);
686
588
  return this;
687
589
  }
590
+ /** Call to decrement count (-1) */
688
591
  decrementCount() {
689
592
  this.subtractCount(1);
690
593
  return this;
691
594
  }
595
+ /** Increase count */
692
596
  addCount(value) {
693
597
  this._count += value;
694
598
  this._samples++;
695
599
  this._checkSampling();
696
600
  return this;
697
601
  }
602
+ /** Decrease count */
698
603
  subtractCount(value) {
699
604
  this._count -= value;
700
605
  this._samples++;
701
606
  this._checkSampling();
702
607
  return this;
703
608
  }
609
+ /** Add an arbitrary timing and bump the count */
704
610
  addTime(time) {
705
611
  this._time += time;
706
612
  this.lastTiming = time;
@@ -708,11 +614,13 @@ var __exports__ = (() => {
708
614
  this._checkSampling();
709
615
  return this;
710
616
  }
617
+ /** Start a timer */
711
618
  timeStart() {
712
619
  this._startTime = getHiResTimestamp2();
713
620
  this._timerPending = true;
714
621
  return this;
715
622
  }
623
+ /** End a timer. Adds to time and bumps the timing count. */
716
624
  timeEnd() {
717
625
  if (!this._timerPending) {
718
626
  return this;
@@ -725,18 +633,22 @@ var __exports__ = (() => {
725
633
  getSampleAverageCount() {
726
634
  return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0;
727
635
  }
636
+ /** Calculate average time / count for the previous window */
728
637
  getSampleAverageTime() {
729
638
  return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0;
730
639
  }
640
+ /** Calculate counts per second for the previous window */
731
641
  getSampleHz() {
732
642
  return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1e3) : 0;
733
643
  }
734
644
  getAverageCount() {
735
645
  return this.samples > 0 ? this.count / this.samples : 0;
736
646
  }
647
+ /** Calculate average time / count */
737
648
  getAverageTime() {
738
649
  return this.samples > 0 ? this.time / this.samples : 0;
739
650
  }
651
+ /** Calculate counts per second */
740
652
  getHz() {
741
653
  return this.time > 0 ? this.samples / (this.time / 1e3) : 0;
742
654
  }
@@ -757,23 +669,20 @@ var __exports__ = (() => {
757
669
  // ../../node_modules/@probe.gl/stats/dist/lib/stats.js
758
670
  var Stats = class {
759
671
  constructor(options) {
760
- this.id = void 0;
761
672
  this.stats = {};
762
673
  this.id = options.id;
763
674
  this.stats = {};
764
675
  this._initializeStats(options.stats);
765
676
  Object.seal(this);
766
677
  }
767
- get(name2) {
768
- let type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "count";
769
- return this._getOrCreate({
770
- name: name2,
771
- type
772
- });
678
+ /** Acquire a stat. Create if it doesn't exist. */
679
+ get(name2, type = "count") {
680
+ return this._getOrCreate({ name: name2, type });
773
681
  }
774
682
  get size() {
775
683
  return Object.keys(this.stats).length;
776
684
  }
685
+ /** Reset all stats */
777
686
  reset() {
778
687
  for (const stat of Object.values(this.stats)) {
779
688
  stat.reset();
@@ -797,15 +706,11 @@ var __exports__ = (() => {
797
706
  });
798
707
  return table;
799
708
  }
800
- _initializeStats() {
801
- let stats = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
709
+ _initializeStats(stats = []) {
802
710
  stats.forEach((stat) => this._getOrCreate(stat));
803
711
  }
804
712
  _getOrCreate(stat) {
805
- const {
806
- name: name2,
807
- type
808
- } = stat;
713
+ const { name: name2, type } = stat;
809
714
  let result = this.stats[name2];
810
715
  if (!result) {
811
716
  if (stat instanceof Stat) {
@@ -1371,51 +1276,76 @@ var __exports__ = (() => {
1371
1276
  }
1372
1277
 
1373
1278
  // src/lib/luma.ts
1374
- var deviceList = /* @__PURE__ */ new Map();
1279
+ var deviceMap = /* @__PURE__ */ new Map();
1375
1280
  var luma = class {
1376
1281
  static registerDevices(deviceClasses) {
1377
1282
  for (const deviceClass of deviceClasses) {
1378
1283
  assert2(deviceClass.type && deviceClass.isSupported && deviceClass.create);
1379
- deviceList.set(deviceClass.type, deviceClass);
1284
+ deviceMap.set(deviceClass.type, deviceClass);
1380
1285
  }
1381
1286
  }
1382
1287
  static getAvailableDevices() {
1383
- return Array.from(deviceList).map((Device2) => Device2.type);
1288
+ return Array.from(deviceMap).map((Device2) => Device2.type);
1384
1289
  }
1385
1290
  static getSupportedDevices() {
1386
- return Array.from(deviceList).filter((Device2) => Device2.isSupported()).map((Device2) => Device2.type);
1291
+ return Array.from(deviceMap).filter((Device2) => Device2.isSupported()).map((Device2) => Device2.type);
1387
1292
  }
1388
1293
  static setDefaultDeviceProps(props) {
1389
1294
  Object.assign(Device.defaultProps, props);
1390
1295
  }
1296
+ /** Attach to an existing GPU API handle (WebGL2RenderingContext or GPUDevice). */
1297
+ static async attachDevice(props) {
1298
+ const devices = getDeviceMap(props.devices) || deviceMap;
1299
+ if (props.handle instanceof WebGL2RenderingContext) {
1300
+ const WebGLDevice = devices.get("webgl");
1301
+ if (WebGLDevice) {
1302
+ return await WebGLDevice.attach(props.handle);
1303
+ }
1304
+ }
1305
+ if (props.handle === null) {
1306
+ const UnknownDevice = devices.get("unknown");
1307
+ if (UnknownDevice) {
1308
+ return await UnknownDevice.attach(null);
1309
+ }
1310
+ }
1311
+ throw new Error(
1312
+ "Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported."
1313
+ );
1314
+ }
1391
1315
  /** Creates a device. Asynchronously. */
1392
1316
  static async createDevice(props = {}) {
1393
1317
  props = { ...Device.defaultProps, ...props };
1394
1318
  if (props.gl) {
1395
1319
  props.type = "webgl";
1396
1320
  }
1397
- let DeviceClass;
1321
+ const devices = getDeviceMap(props.devices) || deviceMap;
1398
1322
  switch (props.type) {
1399
1323
  case "webgpu":
1400
- DeviceClass = deviceList.get("webgpu");
1401
- if (DeviceClass) {
1402
- return await DeviceClass.create(props);
1324
+ let WebGPUDevice = devices.get("webgpu");
1325
+ if (WebGPUDevice) {
1326
+ return await WebGPUDevice.create(props);
1403
1327
  }
1404
1328
  break;
1405
1329
  case "webgl":
1406
- DeviceClass = deviceList.get("webgl");
1407
- if (DeviceClass) {
1408
- return await DeviceClass.create(props);
1330
+ let WebGLDevice = devices.get("webgl");
1331
+ if (WebGLDevice) {
1332
+ return await WebGLDevice.create(props);
1333
+ }
1334
+ break;
1335
+ case "unknown":
1336
+ const UnknownDevice = devices.get("unknown");
1337
+ if (UnknownDevice) {
1338
+ return await UnknownDevice.create(props);
1409
1339
  }
1410
1340
  break;
1411
1341
  case "best-available":
1412
- DeviceClass = deviceList.get("webgpu");
1413
- if (DeviceClass && DeviceClass.isSupported()) {
1414
- return await DeviceClass.create(props);
1342
+ WebGPUDevice = devices.get("webgpu");
1343
+ if (WebGPUDevice?.isSupported?.()) {
1344
+ return await WebGPUDevice.create(props);
1415
1345
  }
1416
- DeviceClass = deviceList.get("webgl");
1417
- if (DeviceClass && DeviceClass.isSupported()) {
1418
- return await DeviceClass.create(props);
1346
+ WebGLDevice = devices.get("webgl");
1347
+ if (WebGLDevice?.isSupported?.()) {
1348
+ return await WebGLDevice.create(props);
1419
1349
  }
1420
1350
  break;
1421
1351
  }
@@ -1424,10 +1354,25 @@ var __exports__ = (() => {
1424
1354
  );
1425
1355
  }
1426
1356
  };
1357
+ __publicField(luma, "defaultProps", {
1358
+ ...Device.defaultProps,
1359
+ type: "best-available",
1360
+ devices: void 0
1361
+ });
1427
1362
  /** Global stats for all devices */
1428
1363
  __publicField(luma, "stats", lumaStats);
1429
1364
  /** Global log */
1430
1365
  __publicField(luma, "log", log);
1366
+ function getDeviceMap(deviceClasses) {
1367
+ if (!deviceClasses || deviceClasses?.length === 0) {
1368
+ return null;
1369
+ }
1370
+ const map = /* @__PURE__ */ new Map();
1371
+ for (const deviceClass of deviceClasses) {
1372
+ map.set(deviceClass.type, deviceClass);
1373
+ }
1374
+ return map;
1375
+ }
1431
1376
 
1432
1377
  // src/adapter/canvas-context.ts
1433
1378
  var isPage = isBrowser() && typeof document !== "undefined";