dytools-capture-engine 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -492,6 +492,8 @@ var SimpleZone = class extends CaptureZoneBase {
492
492
  this.primaryCanvasRectangleId = this.canvasManager.addRectangle(this.rect, this.name, "blue", true, true);
493
493
  }
494
494
  if (type === CaptureZoneEventType.ZoneHiddenChanged) {
495
+ const zoneHiddenChangedPayload = payload;
496
+ this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
495
497
  }
496
498
  if (type === CaptureZoneEventType.ZoneOcrMatchesChanged) {
497
499
  const zoneOcrMatchesChangedPayload = payload;
@@ -532,35 +534,6 @@ var SimpleZone = class extends CaptureZoneBase {
532
534
  }
533
535
  }
534
536
  }
535
- update(ocrRead, ocrMatches, canvas, flags) {
536
- if (!this.primaryCanvasRectangleId) {
537
- this.primaryCanvasRectangleId = canvas.addRectangle(this.rect, this.name, "blue", true, true);
538
- } else {
539
- canvas.setName(this.primaryCanvasRectangleId, this.name);
540
- canvas.setColor(this.primaryCanvasRectangleId, "blue");
541
- canvas.setVisibility(this.primaryCanvasRectangleId, !this.hidden);
542
- canvas.setSelectable(this.primaryCanvasRectangleId, true);
543
- canvas.setResizable(this.primaryCanvasRectangleId, true);
544
- canvas.setRectangleSize(this.primaryCanvasRectangleId, this.rect);
545
- }
546
- if (!ocrMatches || ocrMatches.length == 0) {
547
- return;
548
- }
549
- let thisOcrMatches = ocrMatches?.filter((e) => e.templateZoneId == this.id) ?? [];
550
- let matchHash = this.hidden + "|" + thisOcrMatches.map((e) => `${e.ocrTextResultIds.sort().join(",")}`).join(",");
551
- if (matchHash === this.lastMatchHash) {
552
- return;
553
- }
554
- this.ocrOverlayIds.forEach((id) => canvas.removeObject(id));
555
- this.lastMatchHash = matchHash;
556
- let isFirstMatch = true;
557
- for (const match of thisOcrMatches) {
558
- if (!this.hidden) {
559
- this.ocrOverlayIds.push(canvas.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 0, 0.25)", false));
560
- }
561
- break;
562
- }
563
- }
564
537
  toExternal(docWidth, docHeight) {
565
538
  return {
566
539
  TemplateZoneId: this.id,
@@ -606,7 +579,7 @@ var AnchorZone = class extends CaptureZoneBase {
606
579
  super(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required, dataType, excludeFromOutput, defaultValueIfEmpty);
607
580
  this.type = "anchor";
608
581
  //private primaryCanvasRectangleId: string | null = null;
609
- this._anchorLocation = "TopLeft";
582
+ this._anchorLocation = "MiddleLeft";
610
583
  this._groupChildren = true;
611
584
  this.children = [];
612
585
  //canvasEngineIds: string[] = [];
@@ -716,6 +689,10 @@ var AnchorZone = class extends CaptureZoneBase {
716
689
  });
717
690
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["groupChildren"] });
718
691
  }
692
+ if (type === CaptureZoneEventType.ZoneHiddenChanged) {
693
+ const zoneHiddenChangedPayload = payload;
694
+ this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
695
+ }
719
696
  if (type === CaptureZoneEventType.ZoneOcrMatchesChanged) {
720
697
  const zoneOcrMatchesChangedPayload = payload;
721
698
  let ocrMatches = zoneOcrMatchesChangedPayload.matches;
package/dist/index.d.cts CHANGED
@@ -394,7 +394,7 @@ interface CaptureToEngineEventPayloads {
394
394
  };
395
395
  }
396
396
  type ZoneKind = "simple" | "anchor" | "anchor-child";
397
- type AnchorLocation = "TopLeft" | "TopRight" | "BottomLeft" | "BottomRight" | "Center";
397
+ type AnchorLocation = "TopLeft" | "TopRight" | "BottomLeft" | "BottomRight" | "CenterMiddle" | "CenterTop" | "CenterBottom" | "MiddleLeft" | "MiddleRight";
398
398
  interface TemplateZoneBase {
399
399
  id: string;
400
400
  name: string;
package/dist/index.d.ts CHANGED
@@ -394,7 +394,7 @@ interface CaptureToEngineEventPayloads {
394
394
  };
395
395
  }
396
396
  type ZoneKind = "simple" | "anchor" | "anchor-child";
397
- type AnchorLocation = "TopLeft" | "TopRight" | "BottomLeft" | "BottomRight" | "Center";
397
+ type AnchorLocation = "TopLeft" | "TopRight" | "BottomLeft" | "BottomRight" | "CenterMiddle" | "CenterTop" | "CenterBottom" | "MiddleLeft" | "MiddleRight";
398
398
  interface TemplateZoneBase {
399
399
  id: string;
400
400
  name: string;
package/dist/index.js CHANGED
@@ -476,6 +476,8 @@ var SimpleZone = class extends CaptureZoneBase {
476
476
  this.primaryCanvasRectangleId = this.canvasManager.addRectangle(this.rect, this.name, "blue", true, true);
477
477
  }
478
478
  if (type === CaptureZoneEventType.ZoneHiddenChanged) {
479
+ const zoneHiddenChangedPayload = payload;
480
+ this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
479
481
  }
480
482
  if (type === CaptureZoneEventType.ZoneOcrMatchesChanged) {
481
483
  const zoneOcrMatchesChangedPayload = payload;
@@ -516,35 +518,6 @@ var SimpleZone = class extends CaptureZoneBase {
516
518
  }
517
519
  }
518
520
  }
519
- update(ocrRead, ocrMatches, canvas, flags) {
520
- if (!this.primaryCanvasRectangleId) {
521
- this.primaryCanvasRectangleId = canvas.addRectangle(this.rect, this.name, "blue", true, true);
522
- } else {
523
- canvas.setName(this.primaryCanvasRectangleId, this.name);
524
- canvas.setColor(this.primaryCanvasRectangleId, "blue");
525
- canvas.setVisibility(this.primaryCanvasRectangleId, !this.hidden);
526
- canvas.setSelectable(this.primaryCanvasRectangleId, true);
527
- canvas.setResizable(this.primaryCanvasRectangleId, true);
528
- canvas.setRectangleSize(this.primaryCanvasRectangleId, this.rect);
529
- }
530
- if (!ocrMatches || ocrMatches.length == 0) {
531
- return;
532
- }
533
- let thisOcrMatches = ocrMatches?.filter((e) => e.templateZoneId == this.id) ?? [];
534
- let matchHash = this.hidden + "|" + thisOcrMatches.map((e) => `${e.ocrTextResultIds.sort().join(",")}`).join(",");
535
- if (matchHash === this.lastMatchHash) {
536
- return;
537
- }
538
- this.ocrOverlayIds.forEach((id) => canvas.removeObject(id));
539
- this.lastMatchHash = matchHash;
540
- let isFirstMatch = true;
541
- for (const match of thisOcrMatches) {
542
- if (!this.hidden) {
543
- this.ocrOverlayIds.push(canvas.addPolygon(match.polygonAbsolute.points, "rgba(0, 255, 0, 0.25)", false));
544
- }
545
- break;
546
- }
547
- }
548
521
  toExternal(docWidth, docHeight) {
549
522
  return {
550
523
  TemplateZoneId: this.id,
@@ -590,7 +563,7 @@ var AnchorZone = class extends CaptureZoneBase {
590
563
  super(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required, dataType, excludeFromOutput, defaultValueIfEmpty);
591
564
  this.type = "anchor";
592
565
  //private primaryCanvasRectangleId: string | null = null;
593
- this._anchorLocation = "TopLeft";
566
+ this._anchorLocation = "MiddleLeft";
594
567
  this._groupChildren = true;
595
568
  this.children = [];
596
569
  //canvasEngineIds: string[] = [];
@@ -700,6 +673,10 @@ var AnchorZone = class extends CaptureZoneBase {
700
673
  });
701
674
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["groupChildren"] });
702
675
  }
676
+ if (type === CaptureZoneEventType.ZoneHiddenChanged) {
677
+ const zoneHiddenChangedPayload = payload;
678
+ this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
679
+ }
703
680
  if (type === CaptureZoneEventType.ZoneOcrMatchesChanged) {
704
681
  const zoneOcrMatchesChangedPayload = payload;
705
682
  let ocrMatches = zoneOcrMatchesChangedPayload.matches;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dytools-capture-engine",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "An editor allowing the creation of templates for ocr capture.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",