dytools-capture-engine 1.5.2 → 2.0.1

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.js CHANGED
@@ -18,6 +18,8 @@ var CapturePublicEventType = {
18
18
  // This is a call that happens when either resize or moved.
19
19
  ZoneNameChanged: "zone:name_changed",
20
20
  ZoneFilterRegexChanged: "zone:filter_regex_changed",
21
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone:apply_filter_regex_to_whole_lines_changed",
22
+ ZoneIsFilterRegexNegatedChanged: "zone:is_filter_regex_negated_changed",
21
23
  ZoneExampleChanged: "zone:example_changed",
22
24
  ZoneHiddenChanged: "zone:hidden_changed",
23
25
  ZoneChanged: "zone:changed",
@@ -61,15 +63,22 @@ var CaptureZoneEventType = {
61
63
  ZoneExampleChanged: "zone_internal:example_changed",
62
64
  ZoneHiddenChanged: "zone_internal:hidden_changed",
63
65
  ZoneFilterRegexChanged: "zone_internal:filter_regex_changed",
66
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone_internal:apply_filter_regex_to_whole_lines_changed",
67
+ ZoneIsFilterRegexNegatedChanged: "zone_internal:is_filter_regex_negated_changed",
64
68
  ZoneOutputRegexChanged: "zone_internal:output_regex_changed",
65
69
  ZoneOutputReplacementChanged: "zone_internal:output_replacement_changed",
70
+ ZoneOutputFunctionChanged: "zone_internal:output_function_changed",
66
71
  ZoneRequiredChanged: "zone_internal:required_changed",
67
72
  ZoneDataTypeChanged: "zone_internal:data_type_changed",
68
73
  ZoneExcludeFromOutputChanged: "zone_internal:exclude_from_output_changed",
69
74
  ZoneDefaultValueIfEmptyChanged: "zone_internal:default_value_if_empty_changed",
75
+ ZoneFeatureFlagsChanged: "zone_internal:feature_flags_changed",
70
76
  ZoneOcrMatchesChanged: "zone_internal:ocr_matches_changed",
71
77
  ZoneGroupChildrenChanged: "zone_internal:group_children_changed",
72
- ZoneAnchorLocationChanged: "zone_internal:anchor_location_changed"
78
+ ZoneAnchorLocationChanged: "zone_internal:anchor_location_changed",
79
+ ZoneHasColumnHeadersChanged: "zone_internal:has_column_headers_changed",
80
+ ZoneExcludeColumnHeadersChanged: "zone_internal:exclude_column_headers_changed",
81
+ ZoneIsAnchorPerLineChanged: "zone_internal:is_anchor_per_line_changed"
73
82
  // These are events based on the state of the zone that is handled by the engine.
74
83
  // ZoneSelected: "zone:selected",
75
84
  // ZoneDeselected: "zone:deselected",
@@ -102,8 +111,11 @@ var CaptureToEngineEventType = {
102
111
  // This is a call that happens when either resize or moved.
103
112
  ZoneNameChanged: "zone:name_changed",
104
113
  ZoneFilterRegexChanged: "zone:filter_regex_changed",
114
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone:apply_filter_regex_to_whole_lines_changed",
115
+ ZoneIsFilterRegexNegatedChanged: "zone:is_filter_regex_negated_changed",
105
116
  ZoneOutputRegexChanged: "zone:output_regex_changed",
106
117
  ZoneOutputReplacementChanged: "zone:output_replacement_changed",
118
+ ZoneOutputFunctionChanged: "zone:output_function_changed",
107
119
  ZoneRequiredChanged: "zone:required_changed",
108
120
  ZoneDataTypeChanged: "zone:data_type_changed",
109
121
  ZoneExcludeFromOutputChanged: "zone:exclude_from_output_changed",
@@ -114,6 +126,10 @@ var CaptureToEngineEventType = {
114
126
  // This happens on all the above events.
115
127
  ZoneAnchorLocationChanged: "zone:anchor_location_changed",
116
128
  ZoneGroupChildrenChanged: "zone:group_children_changed",
129
+ ZoneHasColumnHeadersChanged: "zone:has_column_headers_changed",
130
+ ZoneExcludeColumnHeadersChanged: "zone:exclude_column_headers_changed",
131
+ ZoneIsAnchorPerLineChanged: "zone:is_anchor_per_line_changed",
132
+ ZoneFeatureFlagsChanged: "zone:feature_flags_changed",
117
133
  ZoneChildZoneAdded: "zone:child_zone_added",
118
134
  ZoneChildZoneRemoved: "zone:child_zone_removed",
119
135
  ZoneChildZonesChanged: "zone:child_zone_changed",
@@ -127,7 +143,7 @@ var CaptureToEngineEventType = {
127
143
  // ObjectDeselected: "object:deselected",
128
144
  };
129
145
  var CaptureZoneBase = class {
130
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
146
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
131
147
  this._example = null;
132
148
  this.needsAnchorReposition = false;
133
149
  // This is true when the zone needs to be repositioned to the parent's anchor point when the anchor is moved.
@@ -140,12 +156,16 @@ var CaptureZoneBase = class {
140
156
  this._rect = rect;
141
157
  this._hidden = hidden;
142
158
  this._filterRegex = filterRegex;
159
+ this._applyFilterRegexToWholeLines = applyFilterRegexToWholeLines;
160
+ this._isFilterRegexNegated = isFilterRegexNegated;
143
161
  this._outputRegex = outputRegex;
144
162
  this._outputReplacement = outputReplacement;
163
+ this._outputFunction = outputFunction;
145
164
  this._required = required;
146
165
  this._dataType = dataType;
147
166
  this._excludeFromOutput = excludeFromOutput;
148
167
  this._defaultValueIfEmpty = defaultValueIfEmpty;
168
+ this._featureFlags = featureFlags;
149
169
  }
150
170
  get defaultOptions() {
151
171
  return {
@@ -221,6 +241,28 @@ var CaptureZoneBase = class {
221
241
  });
222
242
  propertiesChanged.push("filterRegex");
223
243
  }
244
+ if (type === CaptureZoneEventType.ZoneApplyFilterRegexToWholeLinesChanged) {
245
+ const zoneApplyFilterRegexToWholeLinesChangedPayload = payload;
246
+ const oldApplyFilterRegexToWholeLines = zoneApplyFilterRegexToWholeLinesChangedPayload.oldApplyFilterRegexToWholeLines;
247
+ const newApplyFilterRegexToWholeLines = zoneApplyFilterRegexToWholeLinesChangedPayload.newApplyFilterRegexToWholeLines;
248
+ this.emitToEngine(CaptureToEngineEventType.ZoneApplyFilterRegexToWholeLinesChanged, {
249
+ zone: this,
250
+ oldApplyFilterRegexToWholeLines,
251
+ newApplyFilterRegexToWholeLines
252
+ });
253
+ propertiesChanged.push("applyFilterRegexToWholeLines");
254
+ }
255
+ if (type === CaptureZoneEventType.ZoneIsFilterRegexNegatedChanged) {
256
+ const zoneIsFilterRegexNegatedChangedPayload = payload;
257
+ const oldIsFilterRegexNegated = zoneIsFilterRegexNegatedChangedPayload.oldIsFilterRegexNegated;
258
+ const newIsFilterRegexNegated = zoneIsFilterRegexNegatedChangedPayload.newIsFilterRegexNegated;
259
+ this.emitToEngine(CaptureToEngineEventType.ZoneIsFilterRegexNegatedChanged, {
260
+ zone: this,
261
+ oldIsFilterRegexNegated,
262
+ newIsFilterRegexNegated
263
+ });
264
+ propertiesChanged.push("isFilterRegexNegated");
265
+ }
224
266
  if (type === CaptureZoneEventType.ZoneOutputRegexChanged) {
225
267
  const zoneOutputRegexChangedPayload = payload;
226
268
  const oldOutputRegex = zoneOutputRegexChangedPayload.oldOutputRegex;
@@ -243,6 +285,17 @@ var CaptureZoneBase = class {
243
285
  });
244
286
  propertiesChanged.push("outputReplacement");
245
287
  }
288
+ if (type === CaptureZoneEventType.ZoneOutputFunctionChanged) {
289
+ const zoneOutputFunctionChangedPayload = payload;
290
+ const oldOutputFunction = zoneOutputFunctionChangedPayload.oldOutputFunction;
291
+ const newOutputFunction = zoneOutputFunctionChangedPayload.newOutputFunction;
292
+ this.emitToEngine(CaptureToEngineEventType.ZoneOutputFunctionChanged, {
293
+ zone: this,
294
+ oldOutputFunction,
295
+ newOutputFunction
296
+ });
297
+ propertiesChanged.push("outputFunction");
298
+ }
246
299
  if (type === CaptureZoneEventType.ZoneRequiredChanged) {
247
300
  const zoneRequiredChangedPayload = payload;
248
301
  const oldRequired = zoneRequiredChangedPayload.oldRequired;
@@ -287,6 +340,17 @@ var CaptureZoneBase = class {
287
340
  });
288
341
  propertiesChanged.push("defaultValueIfEmpty");
289
342
  }
343
+ if (type === CaptureZoneEventType.ZoneFeatureFlagsChanged) {
344
+ const zoneFeatureFlagsChangedPayload = payload;
345
+ const oldFeatureFlags = zoneFeatureFlagsChangedPayload.oldFeatureFlags;
346
+ const newFeatureFlags = zoneFeatureFlagsChangedPayload.newFeatureFlags;
347
+ this.emitToEngine(CaptureToEngineEventType.ZoneFeatureFlagsChanged, {
348
+ zone: this,
349
+ oldFeatureFlags,
350
+ newFeatureFlags
351
+ });
352
+ propertiesChanged.push("featureFlags");
353
+ }
290
354
  if (propertiesChanged.length > 0) {
291
355
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged });
292
356
  }
@@ -356,6 +420,24 @@ var CaptureZoneBase = class {
356
420
  this._filterRegex = value;
357
421
  this.emitZoneEvent(CaptureZoneEventType.ZoneFilterRegexChanged, { oldFilterRegex, newFilterRegex: value });
358
422
  }
423
+ get applyFilterRegexToWholeLines() {
424
+ return this._applyFilterRegexToWholeLines;
425
+ }
426
+ set applyFilterRegexToWholeLines(value) {
427
+ if (value === this._applyFilterRegexToWholeLines) return;
428
+ const oldApplyFilterRegexToWholeLines = this._applyFilterRegexToWholeLines;
429
+ this._applyFilterRegexToWholeLines = value;
430
+ this.emitZoneEvent(CaptureZoneEventType.ZoneApplyFilterRegexToWholeLinesChanged, { oldApplyFilterRegexToWholeLines, newApplyFilterRegexToWholeLines: value });
431
+ }
432
+ get isFilterRegexNegated() {
433
+ return this._isFilterRegexNegated;
434
+ }
435
+ set isFilterRegexNegated(value) {
436
+ if (value === this._isFilterRegexNegated) return;
437
+ const oldIsFilterRegexNegated = this._isFilterRegexNegated;
438
+ this._isFilterRegexNegated = value;
439
+ this.emitZoneEvent(CaptureZoneEventType.ZoneIsFilterRegexNegatedChanged, { oldIsFilterRegexNegated, newIsFilterRegexNegated: value });
440
+ }
359
441
  get outputRegex() {
360
442
  return this._outputRegex ?? null;
361
443
  }
@@ -376,6 +458,15 @@ var CaptureZoneBase = class {
376
458
  this._outputReplacement = value;
377
459
  this.emitZoneEvent(CaptureZoneEventType.ZoneOutputReplacementChanged, { oldOutputReplacement, newOutputReplacement: value });
378
460
  }
461
+ get outputFunction() {
462
+ return this._outputFunction ?? null;
463
+ }
464
+ set outputFunction(value) {
465
+ if (value === this._outputFunction) return;
466
+ const oldOutputFunction = this._outputFunction;
467
+ this._outputFunction = value;
468
+ this.emitZoneEvent(CaptureZoneEventType.ZoneOutputFunctionChanged, { oldOutputFunction, newOutputFunction: value });
469
+ }
379
470
  get required() {
380
471
  return this._required;
381
472
  }
@@ -414,6 +505,28 @@ var CaptureZoneBase = class {
414
505
  this._defaultValueIfEmpty = value;
415
506
  this.emitZoneEvent(CaptureZoneEventType.ZoneDefaultValueIfEmptyChanged, { oldDefaultValueIfEmpty, newDefaultValueIfEmpty: value });
416
507
  }
508
+ get featureFlags() {
509
+ return this._featureFlags ?? null;
510
+ }
511
+ set featureFlags(value) {
512
+ if (value === this._featureFlags) return;
513
+ if ((value === void 0 || value === null || value.length == 0) && (this._featureFlags === void 0 || this._featureFlags === null || this._featureFlags.length == 0)) return;
514
+ if (value && this._featureFlags && this.sameStrings(value, this._featureFlags)) return;
515
+ const oldFeatureFlags = this._featureFlags;
516
+ this._featureFlags = value;
517
+ this.emitZoneEvent(CaptureZoneEventType.ZoneFeatureFlagsChanged, { oldFeatureFlags, newFeatureFlags: value });
518
+ }
519
+ sameStrings(a, b) {
520
+ if (a.length !== b.length) return false;
521
+ const map = /* @__PURE__ */ new Map();
522
+ for (const s of a) map.set(s, (map.get(s) ?? 0) + 1);
523
+ for (const s of b) {
524
+ const count = map.get(s);
525
+ if (!count) return false;
526
+ count === 1 ? map.delete(s) : map.set(s, count - 1);
527
+ }
528
+ return map.size === 0;
529
+ }
417
530
  /* EVENT HANDLING METHODS */
418
531
  setEngineEventSink(callback) {
419
532
  this.engineEventSink = callback;
@@ -463,9 +576,53 @@ var CaptureZoneBase = class {
463
576
  }
464
577
  }
465
578
  };
579
+ var StaticZone = class extends CaptureZoneBase {
580
+ constructor(name, dataType = null, value = null, featureFlags, opts = {}) {
581
+ super(name, new Rectangle(0, 0, 10, 10), false, null, false, false, null, null, null, false, dataType, false, value, featureFlags, opts);
582
+ this.type = "static";
583
+ }
584
+ get defaultOptions() {
585
+ return {
586
+ ...super.defaultOptions
587
+ };
588
+ }
589
+ handleInternalZoneEvent(type, payload) {
590
+ if (type === CaptureZoneEventType.ZoneNameChanged || type === CaptureZoneEventType.ZoneDataTypeChanged || type === CaptureZoneEventType.ZoneDefaultValueIfEmptyChanged || type === CaptureZoneEventType.ZoneFeatureFlagsChanged) {
591
+ super.handleInternalZoneEvent(type, payload);
592
+ }
593
+ if (this.canvasManager === null) {
594
+ this.emitToEngine(CaptureToEngineEventType.ZoneError, { zone: this, message: "Missing CanvasManager" });
595
+ return;
596
+ }
597
+ if (type === CaptureZoneEventType.ZoneCanvasManagerSet) {
598
+ this.primaryCanvasRectangleId = this.canvasManager.addRectangle(this.rect, this.name, this.options.zoneColor ?? "black", true, true);
599
+ }
600
+ }
601
+ handleEvent(id, type, payload) {
602
+ if (this.id !== id) {
603
+ return;
604
+ }
605
+ }
606
+ toExternal(docWidth, docHeight) {
607
+ return {
608
+ TemplateZoneId: this.id,
609
+ Name: this.name,
610
+ Type: "TemplateStaticZone",
611
+ DataType: this.dataType,
612
+ Value: this.defaultValueIfEmpty,
613
+ FeatureFlags: this.featureFlags ?? void 0
614
+ };
615
+ }
616
+ get value() {
617
+ return this.defaultValueIfEmpty;
618
+ }
619
+ set value(value) {
620
+ this.defaultValueIfEmpty = value;
621
+ }
622
+ };
466
623
  var SimpleZone = class extends CaptureZoneBase {
467
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
468
- super(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required, dataType, excludeFromOutput, defaultValueIfEmpty, opts);
624
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
625
+ super(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required, dataType, excludeFromOutput, defaultValueIfEmpty, featureFlags, opts);
469
626
  this.type = "simple";
470
627
  this.ocrOverlayIds = [];
471
628
  this.lastMatchHash = "";
@@ -540,12 +697,16 @@ var SimpleZone = class extends CaptureZoneBase {
540
697
  WidthAbsolute: this.rect.size.width,
541
698
  HeightAbsolute: this.rect.size.height,
542
699
  RegExFilter: this.filterRegex,
700
+ ApplyRegExFilterToWholeLines: this.applyFilterRegexToWholeLines,
701
+ IsRegExFilterNegated: this.isFilterRegexNegated,
543
702
  RegExOutput: this.outputRegex,
544
703
  RegExReplacement: this.outputReplacement,
704
+ OutputFunction: this.outputFunction,
545
705
  Required: this.required,
546
706
  DataType: this.dataType,
547
707
  ExcludeFromOutput: this.excludeFromOutput,
548
- DefaultValueIfEmpty: this.defaultValueIfEmpty
708
+ DefaultValueIfEmpty: this.defaultValueIfEmpty,
709
+ FeatureFlags: this.featureFlags ?? void 0
549
710
  };
550
711
  }
551
712
  };
@@ -572,14 +733,15 @@ var AnchorChildZone = class extends SimpleZone {
572
733
  }
573
734
  };
574
735
  var AnchorZone = class extends CaptureZoneBase {
575
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
576
- super(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required, dataType, excludeFromOutput, defaultValueIfEmpty, opts);
736
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
737
+ super(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required, dataType, excludeFromOutput, defaultValueIfEmpty, featureFlags, opts);
577
738
  this.type = "anchor";
578
- //private primaryCanvasRectangleId: string | null = null;
579
739
  this._anchorLocation = "MiddleLeft";
580
740
  this._groupChildren = true;
741
+ this._hasColumnHeaders = false;
742
+ this._excludeColumnHeaders = false;
743
+ this._isAnchorPerLine = false;
581
744
  this.children = [];
582
- //canvasEngineIds: string[] = [];
583
745
  this.ocrOverlayIds = [];
584
746
  this.lastMatchHash = "";
585
747
  this.currentAnchorPoint = null;
@@ -676,6 +838,33 @@ var AnchorZone = class extends CaptureZoneBase {
676
838
  this._groupChildren = value;
677
839
  this.emitZoneEvent(CaptureZoneEventType.ZoneGroupChildrenChanged, { oldGroupChildren, newGroupChildren: value });
678
840
  }
841
+ get hasColumnHeaders() {
842
+ return this._hasColumnHeaders;
843
+ }
844
+ set hasColumnHeaders(value) {
845
+ if (value === this._hasColumnHeaders) return;
846
+ const oldHasColumnHeaders = this._hasColumnHeaders;
847
+ this._hasColumnHeaders = value;
848
+ this.emitZoneEvent(CaptureZoneEventType.ZoneHasColumnHeadersChanged, { oldHasColumnHeaders, newHasColumnHeaders: value });
849
+ }
850
+ get excludeColumnHeaders() {
851
+ return this._excludeColumnHeaders;
852
+ }
853
+ set excludeColumnHeaders(value) {
854
+ if (value === this._excludeColumnHeaders) return;
855
+ const oldExcludeColumnHeaders = this._excludeColumnHeaders;
856
+ this._excludeColumnHeaders = value;
857
+ this.emitZoneEvent(CaptureZoneEventType.ZoneExcludeColumnHeadersChanged, { oldExcludeColumnHeaders, newExcludeColumnHeaders: value });
858
+ }
859
+ get isAnchorPerLine() {
860
+ return this._isAnchorPerLine;
861
+ }
862
+ set isAnchorPerLine(value) {
863
+ if (value === this._isAnchorPerLine) return;
864
+ const oldIsAnchorPerLine = this._isAnchorPerLine;
865
+ this._isAnchorPerLine = value;
866
+ this.emitZoneEvent(CaptureZoneEventType.ZoneIsAnchorPerLineChanged, { oldIsAnchorPerLine, newIsAnchorPerLine: value });
867
+ }
679
868
  handleInternalZoneEvent(type, payload) {
680
869
  super.handleInternalZoneEvent(type, payload);
681
870
  if (this.canvasManager === null) {
@@ -707,6 +896,39 @@ var AnchorZone = class extends CaptureZoneBase {
707
896
  });
708
897
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["groupChildren"] });
709
898
  }
899
+ if (type === CaptureZoneEventType.ZoneHasColumnHeadersChanged) {
900
+ const zoneHasColumnHeadersChangedPayload = payload;
901
+ const oldHasColumnHeaders = zoneHasColumnHeadersChangedPayload.oldHasColumnHeaders;
902
+ const newHasColumnHeaders = zoneHasColumnHeadersChangedPayload.newHasColumnHeaders;
903
+ this.emitToEngine(CaptureToEngineEventType.ZoneHasColumnHeadersChanged, {
904
+ zone: this,
905
+ oldHasColumnHeaders,
906
+ newHasColumnHeaders
907
+ });
908
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["hasColumnHeaders"] });
909
+ }
910
+ if (type === CaptureZoneEventType.ZoneExcludeColumnHeadersChanged) {
911
+ const zoneExcludeColumnHeadersChangedPayload = payload;
912
+ const oldExcludeColumnHeaders = zoneExcludeColumnHeadersChangedPayload.oldExcludeColumnHeaders;
913
+ const newExcludeColumnHeaders = zoneExcludeColumnHeadersChangedPayload.newExcludeColumnHeaders;
914
+ this.emitToEngine(CaptureToEngineEventType.ZoneExcludeColumnHeadersChanged, {
915
+ zone: this,
916
+ oldExcludeColumnHeaders,
917
+ newExcludeColumnHeaders
918
+ });
919
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["excludeColumnHeaders"] });
920
+ }
921
+ if (type === CaptureZoneEventType.ZoneIsAnchorPerLineChanged) {
922
+ const zoneIsAnchorPerLineChangedPayload = payload;
923
+ const oldIsAnchorPerLine = zoneIsAnchorPerLineChangedPayload.oldIsAnchorPerLine;
924
+ const newIsAnchorPerLine = zoneIsAnchorPerLineChangedPayload.newIsAnchorPerLine;
925
+ this.emitToEngine(CaptureToEngineEventType.ZoneIsAnchorPerLineChanged, {
926
+ zone: this,
927
+ oldIsAnchorPerLine,
928
+ newIsAnchorPerLine
929
+ });
930
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["isAnchorPerLine"] });
931
+ }
710
932
  if (type === CaptureZoneEventType.ZoneHiddenChanged) {
711
933
  const zoneHiddenChangedPayload = payload;
712
934
  this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
@@ -802,8 +1024,11 @@ var AnchorZone = class extends CaptureZoneBase {
802
1024
  WidthAbsolute: this.rect.size.width,
803
1025
  HeightAbsolute: this.rect.size.height,
804
1026
  RegExFilter: this.filterRegex,
1027
+ ApplyRegExFilterToWholeLines: this.applyFilterRegexToWholeLines,
1028
+ IsRegExFilterNegated: this.isFilterRegexNegated,
805
1029
  RegExOutput: this.outputRegex,
806
1030
  RegExReplacement: this.outputReplacement,
1031
+ OutputFunction: this.outputFunction,
807
1032
  Required: this.required,
808
1033
  DataType: this.dataType,
809
1034
  ExcludeFromOutput: this.excludeFromOutput,
@@ -812,6 +1037,10 @@ var AnchorZone = class extends CaptureZoneBase {
812
1037
  AnchorLocationXAbsoluteHint: this.currentAnchorPoint?.x,
813
1038
  AnchorLocationYAbsoluteHint: this.currentAnchorPoint?.y,
814
1039
  GroupChildrenInSubRecord: this.groupChildren,
1040
+ HasColumnHeaders: this.hasColumnHeaders,
1041
+ ExcludeColumnHeaders: this.excludeColumnHeaders,
1042
+ IsAnchorPerLine: this.isAnchorPerLine,
1043
+ FeatureFlags: this.featureFlags ?? void 0,
815
1044
  ChildZones: this.children.map((e) => e instanceof AnchorChildZone ? e.toExternalChild(docWidth, docHeight, this.currentAnchorPoint || this.rect.origin) ?? null : e.toExternal(docWidth, docHeight) ?? null).filter((e) => e !== null)
816
1045
  };
817
1046
  }
@@ -1078,7 +1307,6 @@ var CaptureEngine = class {
1078
1307
  });
1079
1308
  this.engine.on(EngineEventType.EngineRenderStarted, () => {
1080
1309
  this.emitExternal(CapturePublicEventType.CaptureRenderStarted, {});
1081
- this.doRender();
1082
1310
  });
1083
1311
  this.engine.on(EngineEventType.EngineRenderCompleted, () => {
1084
1312
  this.emitExternal(CapturePublicEventType.CaptureRenderCompleted, {});
@@ -1163,6 +1391,18 @@ var CaptureEngine = class {
1163
1391
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1164
1392
  this.refreshMatches();
1165
1393
  }
1394
+ if (type === CaptureToEngineEventType.ZoneApplyFilterRegexToWholeLinesChanged) {
1395
+ const zoneApplyFilterRegexToWholeLinesChangedPayload = payload;
1396
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneApplyFilterRegexToWholeLinesChangedPayload.zone, propertiesChanged: ["applyFilterRegexToWholeLines"] });
1397
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1398
+ this.refreshMatches();
1399
+ }
1400
+ if (type === CaptureToEngineEventType.ZoneIsFilterRegexNegatedChanged) {
1401
+ const zoneIsFilterRegexNegatedChangedPayload = payload;
1402
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneIsFilterRegexNegatedChangedPayload.zone, propertiesChanged: ["isFilterRegexNegated"] });
1403
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1404
+ this.refreshMatches();
1405
+ }
1166
1406
  if (type === CaptureToEngineEventType.ZoneOutputRegexChanged) {
1167
1407
  const zoneOutputRegexChangedPayload = payload;
1168
1408
  this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneOutputRegexChangedPayload.zone, propertiesChanged: ["outputRegex"] });
@@ -1175,6 +1415,12 @@ var CaptureEngine = class {
1175
1415
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1176
1416
  this.refreshMatches();
1177
1417
  }
1418
+ if (type === CaptureToEngineEventType.ZoneOutputFunctionChanged) {
1419
+ const zoneOutputFunctionChangedPayload = payload;
1420
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneOutputFunctionChangedPayload.zone, propertiesChanged: ["outputFunction"] });
1421
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1422
+ this.refreshMatches();
1423
+ }
1178
1424
  if (type === CaptureToEngineEventType.ZoneRequiredChanged) {
1179
1425
  const zoneRequiredChangedPayload = payload;
1180
1426
  this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneRequiredChangedPayload.zone, propertiesChanged: ["required"] });
@@ -1207,6 +1453,30 @@ var CaptureEngine = class {
1207
1453
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1208
1454
  this.refreshMatches();
1209
1455
  }
1456
+ if (type === CaptureToEngineEventType.ZoneFeatureFlagsChanged) {
1457
+ const zoneFeatureFlagsChangedPayload = payload;
1458
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneFeatureFlagsChangedPayload.zone, propertiesChanged: ["featureFlags"] });
1459
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1460
+ this.refreshMatches();
1461
+ }
1462
+ if (type === CaptureToEngineEventType.ZoneHasColumnHeadersChanged) {
1463
+ const zoneHasColumnHeadersChangedPayload = payload;
1464
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneHasColumnHeadersChangedPayload.zone, propertiesChanged: ["hasColumnHeaders"] });
1465
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1466
+ this.refreshMatches();
1467
+ }
1468
+ if (type === CaptureToEngineEventType.ZoneExcludeColumnHeadersChanged) {
1469
+ const zoneExcludeColumnHeadersChangedPayload = payload;
1470
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneExcludeColumnHeadersChangedPayload.zone, propertiesChanged: ["excludeColumnHeaders"] });
1471
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1472
+ this.refreshMatches();
1473
+ }
1474
+ if (type === CaptureToEngineEventType.ZoneIsAnchorPerLineChanged) {
1475
+ const zoneIsAnchorPerLineChangedPayload = payload;
1476
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneIsAnchorPerLineChangedPayload.zone, propertiesChanged: ["isAnchorPerLine"] });
1477
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1478
+ this.refreshMatches();
1479
+ }
1210
1480
  }
1211
1481
  onZoneAdded(zone, parentZone, excludeOcrMatches = false) {
1212
1482
  zone.setEngineEventSink?.(
@@ -1238,10 +1508,6 @@ var CaptureEngine = class {
1238
1508
  const zoneId = parts[0];
1239
1509
  return this.allZonesFlattened.find((z) => z.id === zoneId);
1240
1510
  }
1241
- doRender() {
1242
- for (const zone of this.allZonesFlattened) {
1243
- }
1244
- }
1245
1511
  // ---- metered wrapper ----
1246
1512
  createMeteredFn(fn, minIntervalMs = 1e3) {
1247
1513
  let lastExec = 0;
@@ -1314,10 +1580,10 @@ var CaptureEngine = class {
1314
1580
  // --- in CaptureEngine.ts (or a new file) ---
1315
1581
  rectFromExternal(z, docW, docH) {
1316
1582
  return new Rectangle(
1317
- z.X * docW,
1318
- z.Y * docH,
1319
- z.Width * docW,
1320
- z.Height * docH
1583
+ (z.X ?? 0) * docW,
1584
+ (z.Y ?? 0) * docH,
1585
+ (z.Width ?? 10) * docW,
1586
+ (z.Height ?? 10) * docH
1321
1587
  );
1322
1588
  }
1323
1589
  zoneFromExternal(z, docW, docH, parentAnchorAbs) {
@@ -1327,12 +1593,16 @@ var CaptureEngine = class {
1327
1593
  this.rectFromExternal(z, docW, docH),
1328
1594
  false,
1329
1595
  z.RegExFilter ?? null,
1596
+ z.ApplyRegExFilterToWholeLines ?? true,
1597
+ z.IsRegExFilterNegated ?? false,
1330
1598
  z.RegExOutput ?? null,
1331
1599
  z.RegExReplacement ?? null,
1600
+ z.OutputFunction ?? null,
1332
1601
  z.Required ?? false,
1333
1602
  z.DataType ?? null,
1334
1603
  z.ExcludeFromOutput ?? false,
1335
1604
  z.DefaultValueIfEmpty ?? null,
1605
+ z.FeatureFlags ?? null,
1336
1606
  {
1337
1607
  zoneColor: this.options.anchorZoneColor,
1338
1608
  ocrMatchColor: this.options.anchorZoneOcrMatchColor,
@@ -1342,6 +1612,9 @@ var CaptureEngine = class {
1342
1612
  );
1343
1613
  if (z.AnchorLocation) anchor.anchorLocation = z.AnchorLocation;
1344
1614
  if (z.GroupChildrenInSubRecord !== void 0) anchor.groupChildren = z.GroupChildrenInSubRecord;
1615
+ if (z.HasColumnHeaders) anchor.hasColumnHeaders = z.HasColumnHeaders;
1616
+ if (z.ExcludeColumnHeaders) anchor.excludeColumnHeaders = z.ExcludeColumnHeaders;
1617
+ anchor.isAnchorPerLine = z.IsAnchorPerLine ?? true;
1345
1618
  const anchorPoint = anchor.rect.origin;
1346
1619
  for (const childDto of z.ChildZones ?? []) {
1347
1620
  const child = this.zoneFromExternal(childDto, docW, docH, anchorPoint);
@@ -1351,42 +1624,65 @@ var CaptureEngine = class {
1351
1624
  return anchor;
1352
1625
  }
1353
1626
  if (parentAnchorAbs) {
1354
- const absX = parentAnchorAbs.x / docW + z.X;
1355
- const absY = parentAnchorAbs.y / docH + z.Y;
1627
+ const absX = parentAnchorAbs.x / docW + (z.X ?? 0);
1628
+ const absY = parentAnchorAbs.y / docH + (z.Y ?? 0);
1356
1629
  const childRect = new Rectangle(
1357
1630
  absX * docW,
1358
1631
  absY * docH,
1359
- z.Width * docW,
1360
- z.Height * docH
1632
+ (z.Width ?? 10) * docW,
1633
+ (z.Height ?? 10) * docH
1361
1634
  );
1362
1635
  return new AnchorChildZone(
1363
1636
  z.Name,
1364
1637
  childRect,
1365
1638
  false,
1366
1639
  z.RegExFilter ?? null,
1640
+ z.ApplyRegExFilterToWholeLines ?? true,
1641
+ z.IsRegExFilterNegated ?? false,
1367
1642
  z.RegExOutput ?? null,
1368
1643
  z.RegExReplacement ?? null,
1644
+ z.OutputFunction ?? null,
1369
1645
  z.Required ?? false,
1370
1646
  z.DataType ?? null,
1371
1647
  z.ExcludeFromOutput ?? false,
1372
1648
  z.DefaultValueIfEmpty ?? null,
1649
+ z.FeatureFlags ?? null,
1373
1650
  {
1374
1651
  zoneColor: this.options.anchorChildZoneColor,
1375
1652
  ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1376
1653
  }
1377
1654
  );
1378
1655
  }
1656
+ if (z.Type === "TemplateStaticZone") {
1657
+ const staticZone = new StaticZone(
1658
+ z.Name,
1659
+ z.DataType ?? null,
1660
+ z.Value ?? null,
1661
+ z.FeatureFlags ?? null,
1662
+ {
1663
+ zoneColor: this.options.anchorZoneColor,
1664
+ ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1665
+ anchorPointColor: this.options.anchorZoneAnchorPointColor,
1666
+ zoneAdditionalChildrenColor: this.options.anchorZoneAdditionalChildrenColor
1667
+ }
1668
+ );
1669
+ return staticZone;
1670
+ }
1379
1671
  return new SimpleZone(
1380
1672
  z.Name,
1381
1673
  this.rectFromExternal(z, docW, docH),
1382
1674
  false,
1383
1675
  z.RegExFilter ?? null,
1676
+ z.ApplyRegExFilterToWholeLines ?? false,
1677
+ z.IsRegExFilterNegated ?? false,
1384
1678
  z.RegExOutput ?? null,
1385
1679
  z.RegExReplacement ?? null,
1680
+ z.OutputFunction ?? null,
1386
1681
  z.Required ?? false,
1387
1682
  z.DataType ?? null,
1388
1683
  z.ExcludeFromOutput ?? false,
1389
1684
  z.DefaultValueIfEmpty ?? null,
1685
+ z.FeatureFlags ?? null,
1390
1686
  {
1391
1687
  zoneColor: this.options.simpleZoneColor,
1392
1688
  ocrMatchColor: this.options.simpleZoneOcrMatchColor
@@ -1408,12 +1704,26 @@ var CaptureEngine = class {
1408
1704
  getZoneById(id) {
1409
1705
  return this.allZonesFlattened.find((z) => z.id === id);
1410
1706
  }
1707
+ /**
1708
+ * Add a new static zone
1709
+ */
1710
+ addStaticZone(makeCurrentSelected = false) {
1711
+ let newZone = new StaticZone(`Static ${this.zoneCounter++}`, null, null, null, {
1712
+ zoneColor: this.options.simpleZoneColor,
1713
+ ocrMatchColor: this.options.simpleZoneOcrMatchColor
1714
+ });
1715
+ this.zones.push(newZone);
1716
+ if (makeCurrentSelected) {
1717
+ this.setSelectedZones([newZone]);
1718
+ }
1719
+ return newZone;
1720
+ }
1411
1721
  /**
1412
1722
  * Add a new simple zone
1413
1723
  * @param bounds Rectangle
1414
1724
  */
1415
1725
  addSimpleZone(bounds, makeCurrentSelected = false) {
1416
- let newZone = new SimpleZone("Test1", bounds, false, null, null, null, false, null, false, null, {
1726
+ let newZone = new SimpleZone(`Simple ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1417
1727
  zoneColor: this.options.simpleZoneColor,
1418
1728
  ocrMatchColor: this.options.simpleZoneOcrMatchColor
1419
1729
  });
@@ -1428,7 +1738,7 @@ var CaptureEngine = class {
1428
1738
  * @param bounds Rectangle
1429
1739
  */
1430
1740
  addAnchorZone(bounds, makeCurrentSelected = false) {
1431
- let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1741
+ let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1432
1742
  zoneColor: this.options.anchorZoneColor,
1433
1743
  ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1434
1744
  anchorPointColor: this.options.anchorZoneAnchorPointColor,
@@ -1450,7 +1760,7 @@ var CaptureEngine = class {
1450
1760
  if (!anchorZone) {
1451
1761
  throw new Error(`Anchor zone with id ${anchorId} not found`);
1452
1762
  }
1453
- let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1763
+ let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1454
1764
  zoneColor: this.options.anchorChildZoneColor,
1455
1765
  ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1456
1766
  });
@@ -1519,18 +1829,39 @@ var CaptureEngine = class {
1519
1829
  if (patch.filterRegex !== void 0) {
1520
1830
  zone.filterRegex = patch.filterRegex;
1521
1831
  }
1832
+ if (patch.applyFilterRegexToWholeLines !== void 0) {
1833
+ zone.applyFilterRegexToWholeLines = patch.applyFilterRegexToWholeLines;
1834
+ }
1835
+ if (patch.isFilterRegexNegated !== void 0) {
1836
+ zone.isFilterRegexNegated = patch.isFilterRegexNegated;
1837
+ }
1522
1838
  if (patch.outputRegex !== void 0) {
1523
1839
  zone.outputRegex = patch.outputRegex;
1524
1840
  }
1525
1841
  if (patch.outputReplacement !== void 0) {
1526
1842
  zone.outputReplacement = patch.outputReplacement;
1527
1843
  }
1844
+ if (patch.outputFunction !== void 0) {
1845
+ zone.outputFunction = patch.outputFunction;
1846
+ }
1528
1847
  if (patch.anchorLocation !== void 0) {
1529
1848
  zone.anchorLocation = patch.anchorLocation;
1530
1849
  }
1531
1850
  if (patch.groupChildren !== void 0) {
1532
1851
  zone.groupChildren = patch.groupChildren;
1533
1852
  }
1853
+ if (patch.featureFlags !== void 0) {
1854
+ zone.featureFlags = patch.featureFlags;
1855
+ }
1856
+ if (patch.hasColumnHeaders !== void 0) {
1857
+ zone.hasColumnHeaders = patch.hasColumnHeaders;
1858
+ }
1859
+ if (patch.excludeColumnHeaders !== void 0) {
1860
+ zone.excludeColumnHeaders = patch.excludeColumnHeaders;
1861
+ }
1862
+ if (patch.isAnchorPerLine !== void 0) {
1863
+ zone.isAnchorPerLine = patch.isAnchorPerLine;
1864
+ }
1534
1865
  if (patch.rect) {
1535
1866
  const b = patch.rect;
1536
1867
  if (b instanceof Rectangle) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dytools-capture-engine",
3
- "version": "1.5.2",
3
+ "version": "2.0.1",
4
4
  "description": "An editor allowing the creation of templates for ocr capture.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",