@al8b/screen 0.1.13 → 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.
@@ -26,15 +26,6 @@ __export(core_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(core_exports);
28
28
 
29
- // src/drawing/sprite-screen.ts
30
- var import_diagnostics3 = require("@al8b/diagnostics");
31
-
32
- // src/drawing/primitives-screen.ts
33
- var import_diagnostics2 = require("@al8b/diagnostics");
34
-
35
- // src/core/base-screen.ts
36
- var import_diagnostics = require("@al8b/diagnostics");
37
-
38
29
  // src/tri/ttri.ts
39
30
  var ZBuffer = class {
40
31
  static {
@@ -339,10 +330,13 @@ var BaseScreen = class {
339
330
  alpha: false
340
331
  });
341
332
  if (!ctx) {
342
- const diagnostic = (0, import_diagnostics.createDiagnostic)(import_diagnostics.APIErrorCode.E7001);
343
- const formatted = (0, import_diagnostics.formatForBrowser)(diagnostic);
344
- (0, import_diagnostics.reportRuntimeError)(this.runtime?.listener, import_diagnostics.APIErrorCode.E7001, {});
345
- throw new Error(formatted);
333
+ const message = "Failed to get 2D rendering context";
334
+ this.runtime?.listener?.reportError?.({
335
+ code: "E7001",
336
+ message,
337
+ data: {}
338
+ });
339
+ throw new Error(message);
346
340
  }
347
341
  if (ctx !== this.context) {
348
342
  this.context = ctx;
@@ -395,8 +389,12 @@ var BaseScreen = class {
395
389
  } else if (typeof color === "string") {
396
390
  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);
397
391
  if (!isValidColor) {
398
- (0, import_diagnostics.reportRuntimeError)(this.runtime?.listener, import_diagnostics.APIErrorCode.E7003, {
399
- color
392
+ this.runtime?.listener?.reportError?.({
393
+ code: "E7003",
394
+ message: "Invalid color",
395
+ data: {
396
+ color
397
+ }
400
398
  });
401
399
  return;
402
400
  }
@@ -413,8 +411,12 @@ var BaseScreen = class {
413
411
  setBlending(blending) {
414
412
  const blend = this.blending[blending || "normal"];
415
413
  if (!blend) {
416
- (0, import_diagnostics.reportRuntimeError)(this.runtime?.listener, import_diagnostics.APIErrorCode.E7007, {
417
- blendMode: blending
414
+ this.runtime?.listener?.reportError?.({
415
+ code: "E7007",
416
+ message: "Invalid blend mode",
417
+ data: {
418
+ blendMode: blending
419
+ }
418
420
  });
419
421
  this.context.globalCompositeOperation = "source-over";
420
422
  return;
@@ -456,13 +458,21 @@ var BaseScreen = class {
456
458
  this.font_load_requested[font] = true;
457
459
  try {
458
460
  document.fonts?.load?.(`16pt ${font}`).catch(() => {
459
- (0, import_diagnostics.reportRuntimeError)(this.runtime?.listener, import_diagnostics.APIErrorCode.E7006, {
460
- font
461
+ this.runtime?.listener?.reportError?.({
462
+ code: "E7006",
463
+ message: "Font loading failed",
464
+ data: {
465
+ font
466
+ }
461
467
  });
462
468
  });
463
469
  } catch {
464
- (0, import_diagnostics.reportRuntimeError)(this.runtime?.listener, import_diagnostics.APIErrorCode.E7006, {
465
- font
470
+ this.runtime?.listener?.reportError?.({
471
+ code: "E7006",
472
+ message: "Font loading failed",
473
+ data: {
474
+ font
475
+ }
466
476
  });
467
477
  }
468
478
  }
@@ -570,9 +580,13 @@ var BaseScreen = class {
570
580
  resize(width, height) {
571
581
  if (width && height) {
572
582
  if (width <= 0 || height <= 0 || !isFinite(width) || !isFinite(height)) {
573
- (0, import_diagnostics.reportRuntimeError)(this.runtime?.listener, import_diagnostics.APIErrorCode.E7002, {
574
- width,
575
- height
583
+ this.runtime?.listener?.reportError?.({
584
+ code: "E7002",
585
+ message: "Invalid resize dimensions",
586
+ data: {
587
+ width,
588
+ height
589
+ }
576
590
  });
577
591
  return;
578
592
  }
@@ -592,12 +606,20 @@ var PrimitiveScreen = class extends BaseScreen {
592
606
  }
593
607
  fillRect(x, y, w, h, color) {
594
608
  if (!this.context) {
595
- (0, import_diagnostics2.reportRuntimeError)(this.runtime?.listener, import_diagnostics2.APIErrorCode.E7092, {});
609
+ this.runtime?.listener?.reportError?.({
610
+ code: "E7092",
611
+ message: "Drawing context not available",
612
+ data: {}
613
+ });
596
614
  return;
597
615
  }
598
616
  if (!isFinite(x) || !isFinite(y) || !isFinite(w) || !isFinite(h) || w <= 0 || h <= 0) {
599
- (0, import_diagnostics2.reportRuntimeError)(this.runtime?.listener, import_diagnostics2.APIErrorCode.E7093, {
600
- error: `Invalid parameters: x=${x}, y=${y}, w=${w}, h=${h}`
617
+ this.runtime?.listener?.reportError?.({
618
+ code: "E7093",
619
+ message: "Invalid draw parameters",
620
+ data: {
621
+ error: `Invalid parameters: x=${x}, y=${y}, w=${w}, h=${h}`
622
+ }
601
623
  });
602
624
  return;
603
625
  }
@@ -893,8 +915,12 @@ var SpriteScreen = class extends PrimitiveScreen {
893
915
  }
894
916
  }
895
917
  if (!spriteObj2) {
896
- (0, import_diagnostics3.reportRuntimeError)(this.runtime?.listener, import_diagnostics3.APIErrorCode.E7004, {
897
- spriteName
918
+ this.runtime?.listener?.reportError?.({
919
+ code: "E7004",
920
+ message: "Sprite not found",
921
+ data: {
922
+ spriteName
923
+ }
898
924
  });
899
925
  return null;
900
926
  }
@@ -904,8 +930,12 @@ var SpriteScreen = class extends PrimitiveScreen {
904
930
  }
905
931
  if (!sprite || !sprite.ready) {
906
932
  const spriteName = typeof sprite === "string" ? sprite : "unknown";
907
- (0, import_diagnostics3.reportRuntimeError)(this.runtime?.listener, import_diagnostics3.APIErrorCode.E7005, {
908
- spriteName
933
+ this.runtime?.listener?.reportError?.({
934
+ code: "E7005",
935
+ message: "Sprite not ready",
936
+ data: {
937
+ spriteName
938
+ }
909
939
  });
910
940
  return null;
911
941
  }