@al8b/screen 0.1.12 → 0.1.14

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.
@@ -1,15 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/drawing/sprite-screen.ts
5
- import { APIErrorCode as APIErrorCode3, reportRuntimeError as reportRuntimeError3 } from "@al8b/diagnostics";
6
-
7
- // src/drawing/primitives-screen.ts
8
- import { APIErrorCode as APIErrorCode2, reportRuntimeError as reportRuntimeError2 } from "@al8b/diagnostics";
9
-
10
- // src/core/base-screen.ts
11
- import { APIErrorCode, createDiagnostic, formatForBrowser, reportRuntimeError } from "@al8b/diagnostics";
12
-
13
4
  // src/tri/ttri.ts
14
5
  var ZBuffer = class {
15
6
  static {
@@ -314,10 +305,13 @@ var BaseScreen = class {
314
305
  alpha: false
315
306
  });
316
307
  if (!ctx) {
317
- const diagnostic = createDiagnostic(APIErrorCode.E7001);
318
- const formatted = formatForBrowser(diagnostic);
319
- reportRuntimeError(this.runtime?.listener, APIErrorCode.E7001, {});
320
- throw new Error(formatted);
308
+ const message = "Failed to get 2D rendering context";
309
+ this.runtime?.listener?.reportError?.({
310
+ code: "E7001",
311
+ message,
312
+ data: {}
313
+ });
314
+ throw new Error(message);
321
315
  }
322
316
  if (ctx !== this.context) {
323
317
  this.context = ctx;
@@ -370,8 +364,12 @@ var BaseScreen = class {
370
364
  } else if (typeof color === "string") {
371
365
  const isValidColor = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(color) || /^rgb\(|^rgba\(|^hsl\(|^hsla\(/.test(color) || /^(red|green|blue|yellow|cyan|magenta|black|white|gray|grey|orange|pink|purple|brown|transparent)$/i.test(color);
372
366
  if (!isValidColor) {
373
- reportRuntimeError(this.runtime?.listener, APIErrorCode.E7003, {
374
- color
367
+ this.runtime?.listener?.reportError?.({
368
+ code: "E7003",
369
+ message: "Invalid color",
370
+ data: {
371
+ color
372
+ }
375
373
  });
376
374
  return;
377
375
  }
@@ -388,8 +386,12 @@ var BaseScreen = class {
388
386
  setBlending(blending) {
389
387
  const blend = this.blending[blending || "normal"];
390
388
  if (!blend) {
391
- reportRuntimeError(this.runtime?.listener, APIErrorCode.E7007, {
392
- blendMode: blending
389
+ this.runtime?.listener?.reportError?.({
390
+ code: "E7007",
391
+ message: "Invalid blend mode",
392
+ data: {
393
+ blendMode: blending
394
+ }
393
395
  });
394
396
  this.context.globalCompositeOperation = "source-over";
395
397
  return;
@@ -431,13 +433,21 @@ var BaseScreen = class {
431
433
  this.font_load_requested[font] = true;
432
434
  try {
433
435
  document.fonts?.load?.(`16pt ${font}`).catch(() => {
434
- reportRuntimeError(this.runtime?.listener, APIErrorCode.E7006, {
435
- font
436
+ this.runtime?.listener?.reportError?.({
437
+ code: "E7006",
438
+ message: "Font loading failed",
439
+ data: {
440
+ font
441
+ }
436
442
  });
437
443
  });
438
444
  } catch {
439
- reportRuntimeError(this.runtime?.listener, APIErrorCode.E7006, {
440
- font
445
+ this.runtime?.listener?.reportError?.({
446
+ code: "E7006",
447
+ message: "Font loading failed",
448
+ data: {
449
+ font
450
+ }
441
451
  });
442
452
  }
443
453
  }
@@ -545,9 +555,13 @@ var BaseScreen = class {
545
555
  resize(width, height) {
546
556
  if (width && height) {
547
557
  if (width <= 0 || height <= 0 || !isFinite(width) || !isFinite(height)) {
548
- reportRuntimeError(this.runtime?.listener, APIErrorCode.E7002, {
549
- width,
550
- height
558
+ this.runtime?.listener?.reportError?.({
559
+ code: "E7002",
560
+ message: "Invalid resize dimensions",
561
+ data: {
562
+ width,
563
+ height
564
+ }
551
565
  });
552
566
  return;
553
567
  }
@@ -567,12 +581,20 @@ var PrimitiveScreen = class extends BaseScreen {
567
581
  }
568
582
  fillRect(x, y, w, h, color) {
569
583
  if (!this.context) {
570
- reportRuntimeError2(this.runtime?.listener, APIErrorCode2.E7092, {});
584
+ this.runtime?.listener?.reportError?.({
585
+ code: "E7092",
586
+ message: "Drawing context not available",
587
+ data: {}
588
+ });
571
589
  return;
572
590
  }
573
591
  if (!isFinite(x) || !isFinite(y) || !isFinite(w) || !isFinite(h) || w <= 0 || h <= 0) {
574
- reportRuntimeError2(this.runtime?.listener, APIErrorCode2.E7093, {
575
- error: `Invalid parameters: x=${x}, y=${y}, w=${w}, h=${h}`
592
+ this.runtime?.listener?.reportError?.({
593
+ code: "E7093",
594
+ message: "Invalid draw parameters",
595
+ data: {
596
+ error: `Invalid parameters: x=${x}, y=${y}, w=${w}, h=${h}`
597
+ }
576
598
  });
577
599
  return;
578
600
  }
@@ -868,8 +890,12 @@ var SpriteScreen = class extends PrimitiveScreen {
868
890
  }
869
891
  }
870
892
  if (!spriteObj2) {
871
- reportRuntimeError3(this.runtime?.listener, APIErrorCode3.E7004, {
872
- spriteName
893
+ this.runtime?.listener?.reportError?.({
894
+ code: "E7004",
895
+ message: "Sprite not found",
896
+ data: {
897
+ spriteName
898
+ }
873
899
  });
874
900
  return null;
875
901
  }
@@ -879,8 +905,12 @@ var SpriteScreen = class extends PrimitiveScreen {
879
905
  }
880
906
  if (!sprite || !sprite.ready) {
881
907
  const spriteName = typeof sprite === "string" ? sprite : "unknown";
882
- reportRuntimeError3(this.runtime?.listener, APIErrorCode3.E7005, {
883
- spriteName
908
+ this.runtime?.listener?.reportError?.({
909
+ code: "E7005",
910
+ message: "Sprite not ready",
911
+ data: {
912
+ spriteName
913
+ }
884
914
  });
885
915
  return null;
886
916
  }