dytools-capture-engine 1.3.0 → 1.3.2

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
@@ -148,11 +148,6 @@ var CaptureZoneBase = class {
148
148
  this.needsAnchorReposition = false;
149
149
  // This is true when the zone needs to be repositioned to the parent's anchor point when the anchor is moved.
150
150
  this.primaryCanvasRectangleId = null;
151
- this.defaultOptions = {
152
- zoneColor: "blue",
153
- ocrMatchColor: "rgba(0, 255, 0, 0.25)",
154
- anchorPointColor: ""
155
- };
156
151
  // a queue for pending internal events
157
152
  this.pendingInternalEvents = [];
158
153
  this.options = this.createOptions(opts);
@@ -168,6 +163,13 @@ var CaptureZoneBase = class {
168
163
  this._excludeFromOutput = excludeFromOutput;
169
164
  this._defaultValueIfEmpty = defaultValueIfEmpty;
170
165
  }
166
+ get defaultOptions() {
167
+ return {
168
+ zoneColor: "blue",
169
+ ocrMatchColor: "rgba(0, 255, 0, 0.25)",
170
+ anchorPointColor: ""
171
+ };
172
+ }
171
173
  /** INTERNAL SETUP **/
172
174
  createOptions(opts) {
173
175
  return { ...this.defaultOptions, ...opts };
@@ -484,6 +486,11 @@ var SimpleZone = class extends CaptureZoneBase {
484
486
  this.ocrOverlayIds = [];
485
487
  this.lastMatchHash = "";
486
488
  }
489
+ get defaultOptions() {
490
+ return {
491
+ ...super.defaultOptions
492
+ };
493
+ }
487
494
  handleInternalZoneEvent(type, payload) {
488
495
  super.handleInternalZoneEvent(type, payload);
489
496
  if (this.canvasManager === null) {
@@ -562,10 +569,10 @@ var AnchorChildZone = class extends SimpleZone {
562
569
  constructor() {
563
570
  super(...arguments);
564
571
  this.type = "anchor-child";
565
- this.defaultOptions = {
566
- zoneColor: "lightblue",
567
- ocrMatchColor: "lightgreen",
568
- anchorPointColor: "red"
572
+ }
573
+ get defaultOptions() {
574
+ return {
575
+ ...super.defaultOptions
569
576
  };
570
577
  }
571
578
  toExternalChild(docWidth, docHeight, parentAnchor) {
@@ -592,19 +599,6 @@ var AnchorZone = class extends CaptureZoneBase {
592
599
  this.ocrOverlayIds = [];
593
600
  this.lastMatchHash = "";
594
601
  this.currentAnchorPoint = null;
595
- this.defaultOptions = {
596
- zoneColor: "green",
597
- ocrMatchColor: "rgba(0, 255, 255, 0.25)",
598
- anchorPointColor: "rgba(0, 0, 255, 0.25)",
599
- zoneAdditionalChildrenColor: (index) => {
600
- let maxOpacity = 0.5;
601
- let minOpacity = 0.25;
602
- let percentThroughArray = (index + 1) / this.children.length;
603
- let opacity = maxOpacity - (maxOpacity - minOpacity) * percentThroughArray;
604
- let color = `rgba(50, 128, 255, ${opacity.toFixed(2)})`;
605
- return color;
606
- }
607
- };
608
602
  const internalArray = [];
609
603
  const snapshotChildren = (arr) => {
610
604
  const map = /* @__PURE__ */ new Map();
@@ -658,6 +652,22 @@ var AnchorZone = class extends CaptureZoneBase {
658
652
  configurable: false
659
653
  });
660
654
  }
655
+ get defaultOptions() {
656
+ return {
657
+ ...super.defaultOptions,
658
+ zoneColor: "green",
659
+ ocrMatchColor: "rgba(0, 255, 255, 0.25)",
660
+ anchorPointColor: "rgba(0, 0, 255, 0.25)",
661
+ zoneAdditionalChildrenColor: (index) => {
662
+ let maxOpacity = 0.5;
663
+ let minOpacity = 0.25;
664
+ let percentThroughArray = (index + 1) / this.children.length;
665
+ let opacity = maxOpacity - (maxOpacity - minOpacity) * percentThroughArray;
666
+ let color = `rgba(50, 128, 255, ${opacity.toFixed(2)})`;
667
+ return color;
668
+ }
669
+ };
670
+ }
661
671
  resolveValue(value, index, total, defaultValue = "black") {
662
672
  if (value === void 0 || value === null) {
663
673
  return defaultValue;
@@ -1404,7 +1414,10 @@ var CaptureEngine = class {
1404
1414
  * @param bounds Rectangle
1405
1415
  */
1406
1416
  addSimpleZone(bounds, makeCurrentSelected = false) {
1407
- let newZone = new SimpleZone("Test1", bounds, false, null, null, null);
1417
+ let newZone = new SimpleZone("Test1", bounds, false, null, null, null, false, null, false, null, {
1418
+ zoneColor: this.options.simpleZoneColor,
1419
+ ocrMatchColor: this.options.simpleZoneOcrMatchColor
1420
+ });
1408
1421
  this.zones.push(newZone);
1409
1422
  if (makeCurrentSelected) {
1410
1423
  this.setSelectedZones([newZone]);
@@ -1416,7 +1429,12 @@ var CaptureEngine = class {
1416
1429
  * @param bounds Rectangle
1417
1430
  */
1418
1431
  addAnchorZone(bounds, makeCurrentSelected = false) {
1419
- let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, null, null);
1432
+ let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1433
+ zoneColor: this.options.anchorZoneColor,
1434
+ ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1435
+ anchorPointColor: this.options.anchorZoneAnchorPointColor,
1436
+ zoneAdditionalChildrenColor: this.options.anchorZoneAdditionalChildrenColor
1437
+ });
1420
1438
  this.zones.push(newZone);
1421
1439
  if (makeCurrentSelected) {
1422
1440
  this.setSelectedZones([newZone]);
@@ -1433,7 +1451,10 @@ var CaptureEngine = class {
1433
1451
  if (!anchorZone) {
1434
1452
  throw new Error(`Anchor zone with id ${anchorId} not found`);
1435
1453
  }
1436
- let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, null, null);
1454
+ let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1455
+ zoneColor: this.options.anchorChildZoneColor,
1456
+ ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1457
+ });
1437
1458
  if (!anchorZone.children) anchorZone.children = [];
1438
1459
  anchorZone.children.push(newZone);
1439
1460
  if (makeCurrentSelected) {
package/dist/index.js CHANGED
@@ -132,11 +132,6 @@ var CaptureZoneBase = class {
132
132
  this.needsAnchorReposition = false;
133
133
  // This is true when the zone needs to be repositioned to the parent's anchor point when the anchor is moved.
134
134
  this.primaryCanvasRectangleId = null;
135
- this.defaultOptions = {
136
- zoneColor: "blue",
137
- ocrMatchColor: "rgba(0, 255, 0, 0.25)",
138
- anchorPointColor: ""
139
- };
140
135
  // a queue for pending internal events
141
136
  this.pendingInternalEvents = [];
142
137
  this.options = this.createOptions(opts);
@@ -152,6 +147,13 @@ var CaptureZoneBase = class {
152
147
  this._excludeFromOutput = excludeFromOutput;
153
148
  this._defaultValueIfEmpty = defaultValueIfEmpty;
154
149
  }
150
+ get defaultOptions() {
151
+ return {
152
+ zoneColor: "blue",
153
+ ocrMatchColor: "rgba(0, 255, 0, 0.25)",
154
+ anchorPointColor: ""
155
+ };
156
+ }
155
157
  /** INTERNAL SETUP **/
156
158
  createOptions(opts) {
157
159
  return { ...this.defaultOptions, ...opts };
@@ -468,6 +470,11 @@ var SimpleZone = class extends CaptureZoneBase {
468
470
  this.ocrOverlayIds = [];
469
471
  this.lastMatchHash = "";
470
472
  }
473
+ get defaultOptions() {
474
+ return {
475
+ ...super.defaultOptions
476
+ };
477
+ }
471
478
  handleInternalZoneEvent(type, payload) {
472
479
  super.handleInternalZoneEvent(type, payload);
473
480
  if (this.canvasManager === null) {
@@ -546,10 +553,10 @@ var AnchorChildZone = class extends SimpleZone {
546
553
  constructor() {
547
554
  super(...arguments);
548
555
  this.type = "anchor-child";
549
- this.defaultOptions = {
550
- zoneColor: "lightblue",
551
- ocrMatchColor: "lightgreen",
552
- anchorPointColor: "red"
556
+ }
557
+ get defaultOptions() {
558
+ return {
559
+ ...super.defaultOptions
553
560
  };
554
561
  }
555
562
  toExternalChild(docWidth, docHeight, parentAnchor) {
@@ -576,19 +583,6 @@ var AnchorZone = class extends CaptureZoneBase {
576
583
  this.ocrOverlayIds = [];
577
584
  this.lastMatchHash = "";
578
585
  this.currentAnchorPoint = null;
579
- this.defaultOptions = {
580
- zoneColor: "green",
581
- ocrMatchColor: "rgba(0, 255, 255, 0.25)",
582
- anchorPointColor: "rgba(0, 0, 255, 0.25)",
583
- zoneAdditionalChildrenColor: (index) => {
584
- let maxOpacity = 0.5;
585
- let minOpacity = 0.25;
586
- let percentThroughArray = (index + 1) / this.children.length;
587
- let opacity = maxOpacity - (maxOpacity - minOpacity) * percentThroughArray;
588
- let color = `rgba(50, 128, 255, ${opacity.toFixed(2)})`;
589
- return color;
590
- }
591
- };
592
586
  const internalArray = [];
593
587
  const snapshotChildren = (arr) => {
594
588
  const map = /* @__PURE__ */ new Map();
@@ -642,6 +636,22 @@ var AnchorZone = class extends CaptureZoneBase {
642
636
  configurable: false
643
637
  });
644
638
  }
639
+ get defaultOptions() {
640
+ return {
641
+ ...super.defaultOptions,
642
+ zoneColor: "green",
643
+ ocrMatchColor: "rgba(0, 255, 255, 0.25)",
644
+ anchorPointColor: "rgba(0, 0, 255, 0.25)",
645
+ zoneAdditionalChildrenColor: (index) => {
646
+ let maxOpacity = 0.5;
647
+ let minOpacity = 0.25;
648
+ let percentThroughArray = (index + 1) / this.children.length;
649
+ let opacity = maxOpacity - (maxOpacity - minOpacity) * percentThroughArray;
650
+ let color = `rgba(50, 128, 255, ${opacity.toFixed(2)})`;
651
+ return color;
652
+ }
653
+ };
654
+ }
645
655
  resolveValue(value, index, total, defaultValue = "black") {
646
656
  if (value === void 0 || value === null) {
647
657
  return defaultValue;
@@ -1388,7 +1398,10 @@ var CaptureEngine = class {
1388
1398
  * @param bounds Rectangle
1389
1399
  */
1390
1400
  addSimpleZone(bounds, makeCurrentSelected = false) {
1391
- let newZone = new SimpleZone("Test1", bounds, false, null, null, null);
1401
+ let newZone = new SimpleZone("Test1", bounds, false, null, null, null, false, null, false, null, {
1402
+ zoneColor: this.options.simpleZoneColor,
1403
+ ocrMatchColor: this.options.simpleZoneOcrMatchColor
1404
+ });
1392
1405
  this.zones.push(newZone);
1393
1406
  if (makeCurrentSelected) {
1394
1407
  this.setSelectedZones([newZone]);
@@ -1400,7 +1413,12 @@ var CaptureEngine = class {
1400
1413
  * @param bounds Rectangle
1401
1414
  */
1402
1415
  addAnchorZone(bounds, makeCurrentSelected = false) {
1403
- let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, null, null);
1416
+ let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1417
+ zoneColor: this.options.anchorZoneColor,
1418
+ ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1419
+ anchorPointColor: this.options.anchorZoneAnchorPointColor,
1420
+ zoneAdditionalChildrenColor: this.options.anchorZoneAdditionalChildrenColor
1421
+ });
1404
1422
  this.zones.push(newZone);
1405
1423
  if (makeCurrentSelected) {
1406
1424
  this.setSelectedZones([newZone]);
@@ -1417,7 +1435,10 @@ var CaptureEngine = class {
1417
1435
  if (!anchorZone) {
1418
1436
  throw new Error(`Anchor zone with id ${anchorId} not found`);
1419
1437
  }
1420
- let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, null, null);
1438
+ let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1439
+ zoneColor: this.options.anchorChildZoneColor,
1440
+ ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1441
+ });
1421
1442
  if (!anchorZone.children) anchorZone.children = [];
1422
1443
  anchorZone.children.push(newZone);
1423
1444
  if (makeCurrentSelected) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dytools-capture-engine",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "An editor allowing the creation of templates for ocr capture.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",