dytools-capture-engine 1.5.2 → 2.0.0

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,51 @@ 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), true, 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
+ super.handleInternalZoneEvent(type, payload);
591
+ if (this.canvasManager === null) {
592
+ this.emitToEngine(CaptureToEngineEventType.ZoneError, { zone: this, message: "Missing CanvasManager" });
593
+ return;
594
+ }
595
+ if (type === CaptureZoneEventType.ZoneCanvasManagerSet) {
596
+ this.primaryCanvasRectangleId = this.canvasManager.addRectangle(this.rect, this.name, this.options.zoneColor ?? "black", true, true);
597
+ }
598
+ }
599
+ handleEvent(id, type, payload) {
600
+ if (this.id !== id) {
601
+ return;
602
+ }
603
+ }
604
+ toExternal(docWidth, docHeight) {
605
+ return {
606
+ TemplateZoneId: this.id,
607
+ Name: this.name,
608
+ Type: "TemplateStaticZone",
609
+ DataType: this.dataType,
610
+ Value: this.defaultValueIfEmpty,
611
+ FeatureFlags: this.featureFlags ?? void 0
612
+ };
613
+ }
614
+ get value() {
615
+ return this.defaultValueIfEmpty;
616
+ }
617
+ set value(value) {
618
+ this.defaultValueIfEmpty = value;
619
+ }
620
+ };
466
621
  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);
622
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
623
+ super(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required, dataType, excludeFromOutput, defaultValueIfEmpty, featureFlags, opts);
469
624
  this.type = "simple";
470
625
  this.ocrOverlayIds = [];
471
626
  this.lastMatchHash = "";
@@ -540,12 +695,16 @@ var SimpleZone = class extends CaptureZoneBase {
540
695
  WidthAbsolute: this.rect.size.width,
541
696
  HeightAbsolute: this.rect.size.height,
542
697
  RegExFilter: this.filterRegex,
698
+ ApplyRegExFilterToWholeLines: this.applyFilterRegexToWholeLines,
699
+ IsRegExFilterNegated: this.isFilterRegexNegated,
543
700
  RegExOutput: this.outputRegex,
544
701
  RegExReplacement: this.outputReplacement,
702
+ OutputFunction: this.outputFunction,
545
703
  Required: this.required,
546
704
  DataType: this.dataType,
547
705
  ExcludeFromOutput: this.excludeFromOutput,
548
- DefaultValueIfEmpty: this.defaultValueIfEmpty
706
+ DefaultValueIfEmpty: this.defaultValueIfEmpty,
707
+ FeatureFlags: this.featureFlags ?? void 0
549
708
  };
550
709
  }
551
710
  };
@@ -572,14 +731,15 @@ var AnchorChildZone = class extends SimpleZone {
572
731
  }
573
732
  };
574
733
  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);
734
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
735
+ super(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required, dataType, excludeFromOutput, defaultValueIfEmpty, featureFlags, opts);
577
736
  this.type = "anchor";
578
- //private primaryCanvasRectangleId: string | null = null;
579
737
  this._anchorLocation = "MiddleLeft";
580
738
  this._groupChildren = true;
739
+ this._hasColumnHeaders = false;
740
+ this._excludeColumnHeaders = false;
741
+ this._isAnchorPerLine = false;
581
742
  this.children = [];
582
- //canvasEngineIds: string[] = [];
583
743
  this.ocrOverlayIds = [];
584
744
  this.lastMatchHash = "";
585
745
  this.currentAnchorPoint = null;
@@ -676,6 +836,33 @@ var AnchorZone = class extends CaptureZoneBase {
676
836
  this._groupChildren = value;
677
837
  this.emitZoneEvent(CaptureZoneEventType.ZoneGroupChildrenChanged, { oldGroupChildren, newGroupChildren: value });
678
838
  }
839
+ get hasColumnHeaders() {
840
+ return this._hasColumnHeaders;
841
+ }
842
+ set hasColumnHeaders(value) {
843
+ if (value === this._hasColumnHeaders) return;
844
+ const oldHasColumnHeaders = this._hasColumnHeaders;
845
+ this._hasColumnHeaders = value;
846
+ this.emitZoneEvent(CaptureZoneEventType.ZoneHasColumnHeadersChanged, { oldHasColumnHeaders, newHasColumnHeaders: value });
847
+ }
848
+ get excludeColumnHeaders() {
849
+ return this._excludeColumnHeaders;
850
+ }
851
+ set excludeColumnHeaders(value) {
852
+ if (value === this._excludeColumnHeaders) return;
853
+ const oldExcludeColumnHeaders = this._excludeColumnHeaders;
854
+ this._excludeColumnHeaders = value;
855
+ this.emitZoneEvent(CaptureZoneEventType.ZoneExcludeColumnHeadersChanged, { oldExcludeColumnHeaders, newExcludeColumnHeaders: value });
856
+ }
857
+ get isAnchorPerLine() {
858
+ return this._isAnchorPerLine;
859
+ }
860
+ set isAnchorPerLine(value) {
861
+ if (value === this._isAnchorPerLine) return;
862
+ const oldIsAnchorPerLine = this._isAnchorPerLine;
863
+ this._isAnchorPerLine = value;
864
+ this.emitZoneEvent(CaptureZoneEventType.ZoneIsAnchorPerLineChanged, { oldIsAnchorPerLine, newIsAnchorPerLine: value });
865
+ }
679
866
  handleInternalZoneEvent(type, payload) {
680
867
  super.handleInternalZoneEvent(type, payload);
681
868
  if (this.canvasManager === null) {
@@ -707,6 +894,39 @@ var AnchorZone = class extends CaptureZoneBase {
707
894
  });
708
895
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["groupChildren"] });
709
896
  }
897
+ if (type === CaptureZoneEventType.ZoneHasColumnHeadersChanged) {
898
+ const zoneHasColumnHeadersChangedPayload = payload;
899
+ const oldHasColumnHeaders = zoneHasColumnHeadersChangedPayload.oldHasColumnHeaders;
900
+ const newHasColumnHeaders = zoneHasColumnHeadersChangedPayload.newHasColumnHeaders;
901
+ this.emitToEngine(CaptureToEngineEventType.ZoneHasColumnHeadersChanged, {
902
+ zone: this,
903
+ oldHasColumnHeaders,
904
+ newHasColumnHeaders
905
+ });
906
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["hasColumnHeaders"] });
907
+ }
908
+ if (type === CaptureZoneEventType.ZoneExcludeColumnHeadersChanged) {
909
+ const zoneExcludeColumnHeadersChangedPayload = payload;
910
+ const oldExcludeColumnHeaders = zoneExcludeColumnHeadersChangedPayload.oldExcludeColumnHeaders;
911
+ const newExcludeColumnHeaders = zoneExcludeColumnHeadersChangedPayload.newExcludeColumnHeaders;
912
+ this.emitToEngine(CaptureToEngineEventType.ZoneExcludeColumnHeadersChanged, {
913
+ zone: this,
914
+ oldExcludeColumnHeaders,
915
+ newExcludeColumnHeaders
916
+ });
917
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["excludeColumnHeaders"] });
918
+ }
919
+ if (type === CaptureZoneEventType.ZoneIsAnchorPerLineChanged) {
920
+ const zoneIsAnchorPerLineChangedPayload = payload;
921
+ const oldIsAnchorPerLine = zoneIsAnchorPerLineChangedPayload.oldIsAnchorPerLine;
922
+ const newIsAnchorPerLine = zoneIsAnchorPerLineChangedPayload.newIsAnchorPerLine;
923
+ this.emitToEngine(CaptureToEngineEventType.ZoneIsAnchorPerLineChanged, {
924
+ zone: this,
925
+ oldIsAnchorPerLine,
926
+ newIsAnchorPerLine
927
+ });
928
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["isAnchorPerLine"] });
929
+ }
710
930
  if (type === CaptureZoneEventType.ZoneHiddenChanged) {
711
931
  const zoneHiddenChangedPayload = payload;
712
932
  this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
@@ -802,8 +1022,11 @@ var AnchorZone = class extends CaptureZoneBase {
802
1022
  WidthAbsolute: this.rect.size.width,
803
1023
  HeightAbsolute: this.rect.size.height,
804
1024
  RegExFilter: this.filterRegex,
1025
+ ApplyRegExFilterToWholeLines: this.applyFilterRegexToWholeLines,
1026
+ IsRegExFilterNegated: this.isFilterRegexNegated,
805
1027
  RegExOutput: this.outputRegex,
806
1028
  RegExReplacement: this.outputReplacement,
1029
+ OutputFunction: this.outputFunction,
807
1030
  Required: this.required,
808
1031
  DataType: this.dataType,
809
1032
  ExcludeFromOutput: this.excludeFromOutput,
@@ -812,6 +1035,10 @@ var AnchorZone = class extends CaptureZoneBase {
812
1035
  AnchorLocationXAbsoluteHint: this.currentAnchorPoint?.x,
813
1036
  AnchorLocationYAbsoluteHint: this.currentAnchorPoint?.y,
814
1037
  GroupChildrenInSubRecord: this.groupChildren,
1038
+ HasColumnHeaders: this.hasColumnHeaders,
1039
+ ExcludeColumnHeaders: this.excludeColumnHeaders,
1040
+ IsAnchorPerLine: this.isAnchorPerLine,
1041
+ FeatureFlags: this.featureFlags ?? void 0,
815
1042
  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
1043
  };
817
1044
  }
@@ -1078,7 +1305,6 @@ var CaptureEngine = class {
1078
1305
  });
1079
1306
  this.engine.on(EngineEventType.EngineRenderStarted, () => {
1080
1307
  this.emitExternal(CapturePublicEventType.CaptureRenderStarted, {});
1081
- this.doRender();
1082
1308
  });
1083
1309
  this.engine.on(EngineEventType.EngineRenderCompleted, () => {
1084
1310
  this.emitExternal(CapturePublicEventType.CaptureRenderCompleted, {});
@@ -1163,6 +1389,18 @@ var CaptureEngine = class {
1163
1389
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1164
1390
  this.refreshMatches();
1165
1391
  }
1392
+ if (type === CaptureToEngineEventType.ZoneApplyFilterRegexToWholeLinesChanged) {
1393
+ const zoneApplyFilterRegexToWholeLinesChangedPayload = payload;
1394
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneApplyFilterRegexToWholeLinesChangedPayload.zone, propertiesChanged: ["applyFilterRegexToWholeLines"] });
1395
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1396
+ this.refreshMatches();
1397
+ }
1398
+ if (type === CaptureToEngineEventType.ZoneIsFilterRegexNegatedChanged) {
1399
+ const zoneIsFilterRegexNegatedChangedPayload = payload;
1400
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneIsFilterRegexNegatedChangedPayload.zone, propertiesChanged: ["isFilterRegexNegated"] });
1401
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1402
+ this.refreshMatches();
1403
+ }
1166
1404
  if (type === CaptureToEngineEventType.ZoneOutputRegexChanged) {
1167
1405
  const zoneOutputRegexChangedPayload = payload;
1168
1406
  this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneOutputRegexChangedPayload.zone, propertiesChanged: ["outputRegex"] });
@@ -1175,6 +1413,12 @@ var CaptureEngine = class {
1175
1413
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1176
1414
  this.refreshMatches();
1177
1415
  }
1416
+ if (type === CaptureToEngineEventType.ZoneOutputFunctionChanged) {
1417
+ const zoneOutputFunctionChangedPayload = payload;
1418
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneOutputFunctionChangedPayload.zone, propertiesChanged: ["outputFunction"] });
1419
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1420
+ this.refreshMatches();
1421
+ }
1178
1422
  if (type === CaptureToEngineEventType.ZoneRequiredChanged) {
1179
1423
  const zoneRequiredChangedPayload = payload;
1180
1424
  this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneRequiredChangedPayload.zone, propertiesChanged: ["required"] });
@@ -1207,6 +1451,30 @@ var CaptureEngine = class {
1207
1451
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1208
1452
  this.refreshMatches();
1209
1453
  }
1454
+ if (type === CaptureToEngineEventType.ZoneFeatureFlagsChanged) {
1455
+ const zoneFeatureFlagsChangedPayload = payload;
1456
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneFeatureFlagsChangedPayload.zone, propertiesChanged: ["featureFlags"] });
1457
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1458
+ this.refreshMatches();
1459
+ }
1460
+ if (type === CaptureToEngineEventType.ZoneHasColumnHeadersChanged) {
1461
+ const zoneHasColumnHeadersChangedPayload = payload;
1462
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneHasColumnHeadersChangedPayload.zone, propertiesChanged: ["hasColumnHeaders"] });
1463
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1464
+ this.refreshMatches();
1465
+ }
1466
+ if (type === CaptureToEngineEventType.ZoneExcludeColumnHeadersChanged) {
1467
+ const zoneExcludeColumnHeadersChangedPayload = payload;
1468
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneExcludeColumnHeadersChangedPayload.zone, propertiesChanged: ["excludeColumnHeaders"] });
1469
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1470
+ this.refreshMatches();
1471
+ }
1472
+ if (type === CaptureToEngineEventType.ZoneIsAnchorPerLineChanged) {
1473
+ const zoneIsAnchorPerLineChangedPayload = payload;
1474
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneIsAnchorPerLineChangedPayload.zone, propertiesChanged: ["isAnchorPerLine"] });
1475
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1476
+ this.refreshMatches();
1477
+ }
1210
1478
  }
1211
1479
  onZoneAdded(zone, parentZone, excludeOcrMatches = false) {
1212
1480
  zone.setEngineEventSink?.(
@@ -1238,10 +1506,6 @@ var CaptureEngine = class {
1238
1506
  const zoneId = parts[0];
1239
1507
  return this.allZonesFlattened.find((z) => z.id === zoneId);
1240
1508
  }
1241
- doRender() {
1242
- for (const zone of this.allZonesFlattened) {
1243
- }
1244
- }
1245
1509
  // ---- metered wrapper ----
1246
1510
  createMeteredFn(fn, minIntervalMs = 1e3) {
1247
1511
  let lastExec = 0;
@@ -1314,10 +1578,10 @@ var CaptureEngine = class {
1314
1578
  // --- in CaptureEngine.ts (or a new file) ---
1315
1579
  rectFromExternal(z, docW, docH) {
1316
1580
  return new Rectangle(
1317
- z.X * docW,
1318
- z.Y * docH,
1319
- z.Width * docW,
1320
- z.Height * docH
1581
+ (z.X ?? 0) * docW,
1582
+ (z.Y ?? 0) * docH,
1583
+ (z.Width ?? 10) * docW,
1584
+ (z.Height ?? 10) * docH
1321
1585
  );
1322
1586
  }
1323
1587
  zoneFromExternal(z, docW, docH, parentAnchorAbs) {
@@ -1327,12 +1591,16 @@ var CaptureEngine = class {
1327
1591
  this.rectFromExternal(z, docW, docH),
1328
1592
  false,
1329
1593
  z.RegExFilter ?? null,
1594
+ z.ApplyRegExFilterToWholeLines ?? true,
1595
+ z.IsRegExFilterNegated ?? false,
1330
1596
  z.RegExOutput ?? null,
1331
1597
  z.RegExReplacement ?? null,
1598
+ z.OutputFunction ?? null,
1332
1599
  z.Required ?? false,
1333
1600
  z.DataType ?? null,
1334
1601
  z.ExcludeFromOutput ?? false,
1335
1602
  z.DefaultValueIfEmpty ?? null,
1603
+ z.FeatureFlags ?? null,
1336
1604
  {
1337
1605
  zoneColor: this.options.anchorZoneColor,
1338
1606
  ocrMatchColor: this.options.anchorZoneOcrMatchColor,
@@ -1342,6 +1610,9 @@ var CaptureEngine = class {
1342
1610
  );
1343
1611
  if (z.AnchorLocation) anchor.anchorLocation = z.AnchorLocation;
1344
1612
  if (z.GroupChildrenInSubRecord !== void 0) anchor.groupChildren = z.GroupChildrenInSubRecord;
1613
+ if (z.HasColumnHeaders) anchor.hasColumnHeaders = z.HasColumnHeaders;
1614
+ if (z.ExcludeColumnHeaders) anchor.excludeColumnHeaders = z.ExcludeColumnHeaders;
1615
+ if (z.IsAnchorPerLine) anchor.isAnchorPerLine = z.IsAnchorPerLine;
1345
1616
  const anchorPoint = anchor.rect.origin;
1346
1617
  for (const childDto of z.ChildZones ?? []) {
1347
1618
  const child = this.zoneFromExternal(childDto, docW, docH, anchorPoint);
@@ -1351,42 +1622,65 @@ var CaptureEngine = class {
1351
1622
  return anchor;
1352
1623
  }
1353
1624
  if (parentAnchorAbs) {
1354
- const absX = parentAnchorAbs.x / docW + z.X;
1355
- const absY = parentAnchorAbs.y / docH + z.Y;
1625
+ const absX = parentAnchorAbs.x / docW + (z.X ?? 0);
1626
+ const absY = parentAnchorAbs.y / docH + (z.Y ?? 0);
1356
1627
  const childRect = new Rectangle(
1357
1628
  absX * docW,
1358
1629
  absY * docH,
1359
- z.Width * docW,
1360
- z.Height * docH
1630
+ (z.Width ?? 10) * docW,
1631
+ (z.Height ?? 10) * docH
1361
1632
  );
1362
1633
  return new AnchorChildZone(
1363
1634
  z.Name,
1364
1635
  childRect,
1365
1636
  false,
1366
1637
  z.RegExFilter ?? null,
1638
+ z.ApplyRegExFilterToWholeLines ?? true,
1639
+ z.IsRegExFilterNegated ?? false,
1367
1640
  z.RegExOutput ?? null,
1368
1641
  z.RegExReplacement ?? null,
1642
+ z.OutputFunction ?? null,
1369
1643
  z.Required ?? false,
1370
1644
  z.DataType ?? null,
1371
1645
  z.ExcludeFromOutput ?? false,
1372
1646
  z.DefaultValueIfEmpty ?? null,
1647
+ z.FeatureFlags ?? null,
1373
1648
  {
1374
1649
  zoneColor: this.options.anchorChildZoneColor,
1375
1650
  ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1376
1651
  }
1377
1652
  );
1378
1653
  }
1654
+ if (z.Type === "TemplateStaticZone") {
1655
+ const staticZone = new StaticZone(
1656
+ z.Name,
1657
+ z.DataType ?? null,
1658
+ z.Value ?? null,
1659
+ z.FeatureFlags ?? null,
1660
+ {
1661
+ zoneColor: this.options.anchorZoneColor,
1662
+ ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1663
+ anchorPointColor: this.options.anchorZoneAnchorPointColor,
1664
+ zoneAdditionalChildrenColor: this.options.anchorZoneAdditionalChildrenColor
1665
+ }
1666
+ );
1667
+ return staticZone;
1668
+ }
1379
1669
  return new SimpleZone(
1380
1670
  z.Name,
1381
1671
  this.rectFromExternal(z, docW, docH),
1382
1672
  false,
1383
1673
  z.RegExFilter ?? null,
1674
+ z.ApplyRegExFilterToWholeLines ?? false,
1675
+ z.IsRegExFilterNegated ?? false,
1384
1676
  z.RegExOutput ?? null,
1385
1677
  z.RegExReplacement ?? null,
1678
+ z.OutputFunction ?? null,
1386
1679
  z.Required ?? false,
1387
1680
  z.DataType ?? null,
1388
1681
  z.ExcludeFromOutput ?? false,
1389
1682
  z.DefaultValueIfEmpty ?? null,
1683
+ z.FeatureFlags ?? null,
1390
1684
  {
1391
1685
  zoneColor: this.options.simpleZoneColor,
1392
1686
  ocrMatchColor: this.options.simpleZoneOcrMatchColor
@@ -1408,12 +1702,26 @@ var CaptureEngine = class {
1408
1702
  getZoneById(id) {
1409
1703
  return this.allZonesFlattened.find((z) => z.id === id);
1410
1704
  }
1705
+ /**
1706
+ * Add a new static zone
1707
+ */
1708
+ addStaticZone(makeCurrentSelected = false) {
1709
+ let newZone = new StaticZone(`Static ${this.zoneCounter++}`, null, null, null, {
1710
+ zoneColor: this.options.simpleZoneColor,
1711
+ ocrMatchColor: this.options.simpleZoneOcrMatchColor
1712
+ });
1713
+ this.zones.push(newZone);
1714
+ if (makeCurrentSelected) {
1715
+ this.setSelectedZones([newZone]);
1716
+ }
1717
+ return newZone;
1718
+ }
1411
1719
  /**
1412
1720
  * Add a new simple zone
1413
1721
  * @param bounds Rectangle
1414
1722
  */
1415
1723
  addSimpleZone(bounds, makeCurrentSelected = false) {
1416
- let newZone = new SimpleZone("Test1", bounds, false, null, null, null, false, null, false, null, {
1724
+ let newZone = new SimpleZone(`Simple ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1417
1725
  zoneColor: this.options.simpleZoneColor,
1418
1726
  ocrMatchColor: this.options.simpleZoneOcrMatchColor
1419
1727
  });
@@ -1428,7 +1736,7 @@ var CaptureEngine = class {
1428
1736
  * @param bounds Rectangle
1429
1737
  */
1430
1738
  addAnchorZone(bounds, makeCurrentSelected = false) {
1431
- let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1739
+ let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1432
1740
  zoneColor: this.options.anchorZoneColor,
1433
1741
  ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1434
1742
  anchorPointColor: this.options.anchorZoneAnchorPointColor,
@@ -1450,7 +1758,7 @@ var CaptureEngine = class {
1450
1758
  if (!anchorZone) {
1451
1759
  throw new Error(`Anchor zone with id ${anchorId} not found`);
1452
1760
  }
1453
- let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1761
+ let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1454
1762
  zoneColor: this.options.anchorChildZoneColor,
1455
1763
  ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1456
1764
  });
@@ -1519,18 +1827,39 @@ var CaptureEngine = class {
1519
1827
  if (patch.filterRegex !== void 0) {
1520
1828
  zone.filterRegex = patch.filterRegex;
1521
1829
  }
1830
+ if (patch.applyFilterRegexToWholeLines !== void 0) {
1831
+ zone.applyFilterRegexToWholeLines = patch.applyFilterRegexToWholeLines;
1832
+ }
1833
+ if (patch.isFilterRegexNegated !== void 0) {
1834
+ zone.isFilterRegexNegated = patch.isFilterRegexNegated;
1835
+ }
1522
1836
  if (patch.outputRegex !== void 0) {
1523
1837
  zone.outputRegex = patch.outputRegex;
1524
1838
  }
1525
1839
  if (patch.outputReplacement !== void 0) {
1526
1840
  zone.outputReplacement = patch.outputReplacement;
1527
1841
  }
1842
+ if (patch.outputFunction !== void 0) {
1843
+ zone.outputFunction = patch.outputFunction;
1844
+ }
1528
1845
  if (patch.anchorLocation !== void 0) {
1529
1846
  zone.anchorLocation = patch.anchorLocation;
1530
1847
  }
1531
1848
  if (patch.groupChildren !== void 0) {
1532
1849
  zone.groupChildren = patch.groupChildren;
1533
1850
  }
1851
+ if (patch.featureFlags !== void 0) {
1852
+ zone.featureFlags = patch.featureFlags;
1853
+ }
1854
+ if (patch.hasColumnHeaders !== void 0) {
1855
+ zone.hasColumnHeaders = patch.hasColumnHeaders;
1856
+ }
1857
+ if (patch.excludeColumnHeaders !== void 0) {
1858
+ zone.excludeColumnHeaders = patch.excludeColumnHeaders;
1859
+ }
1860
+ if (patch.isAnchorPerLine !== void 0) {
1861
+ zone.isAnchorPerLine = patch.isAnchorPerLine;
1862
+ }
1534
1863
  if (patch.rect) {
1535
1864
  const b = patch.rect;
1536
1865
  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.0",
4
4
  "description": "An editor allowing the creation of templates for ocr capture.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",