@treeviz/gedcom-parser 1.0.5 → 1.0.6
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/classes/gedcom.js +15 -14
- package/package.json +1 -1
package/dist/classes/gedcom.js
CHANGED
|
@@ -729,17 +729,16 @@ export const mergeGedcoms = (targetGedcom, sourceGedcom, strategy = "id") => {
|
|
|
729
729
|
...targetChildIds,
|
|
730
730
|
]).size;
|
|
731
731
|
// Match if:
|
|
732
|
-
// 1.
|
|
732
|
+
// 1. At least one spouse is present (to avoid matching empty families), OR
|
|
733
733
|
// 2. At least 50% of children overlap
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
}
|
|
734
|
+
const hasSpouses = finalHusbId ||
|
|
735
|
+
finalWifeId ||
|
|
736
|
+
targetHusbId ||
|
|
737
|
+
targetWifeId;
|
|
738
|
+
const hasMatchingChildren = totalUniqueChildren > 0 &&
|
|
739
|
+
childOverlap / totalUniqueChildren >= 0.5;
|
|
740
|
+
if (hasSpouses || hasMatchingChildren) {
|
|
741
|
+
matchedTargetFam = targetFam;
|
|
743
742
|
}
|
|
744
743
|
}
|
|
745
744
|
});
|
|
@@ -799,7 +798,7 @@ export const mergeGedcoms = (targetGedcom, sourceGedcom, strategy = "id") => {
|
|
|
799
798
|
if (!sourceIndi)
|
|
800
799
|
return;
|
|
801
800
|
// Clear and rebuild FAMS references with remapped IDs
|
|
802
|
-
|
|
801
|
+
clonedIndi.remove("FAMS");
|
|
803
802
|
const sourceFAMS = sourceIndi.FAMS?.toList();
|
|
804
803
|
sourceFAMS?.forEach((famRef) => {
|
|
805
804
|
const oldFamId = famRef.value;
|
|
@@ -813,7 +812,7 @@ export const mergeGedcoms = (targetGedcom, sourceGedcom, strategy = "id") => {
|
|
|
813
812
|
}
|
|
814
813
|
});
|
|
815
814
|
// Clear and rebuild FAMC references with remapped IDs
|
|
816
|
-
|
|
815
|
+
clonedIndi.remove("FAMC");
|
|
817
816
|
const sourceFAMC = sourceIndi.FAMC?.toList();
|
|
818
817
|
sourceFAMC?.forEach((famRef) => {
|
|
819
818
|
const oldFamId = famRef.value;
|
|
@@ -853,7 +852,7 @@ export const mergeGedcoms = (targetGedcom, sourceGedcom, strategy = "id") => {
|
|
|
853
852
|
}
|
|
854
853
|
}
|
|
855
854
|
// Update CHIL references
|
|
856
|
-
|
|
855
|
+
clonedFam.remove("CHIL");
|
|
857
856
|
const sourceChildren = sourceFam.CHIL?.toList();
|
|
858
857
|
sourceChildren?.forEach((childRef) => {
|
|
859
858
|
const oldChildId = childRef.value;
|
|
@@ -875,7 +874,9 @@ export const mergeGedcoms = (targetGedcom, sourceGedcom, strategy = "id") => {
|
|
|
875
874
|
const targetIndi = mergedGedcom.indis()?.item(matchedTargetId);
|
|
876
875
|
if (targetIndi) {
|
|
877
876
|
// Merge without overriding existing data
|
|
878
|
-
|
|
877
|
+
// If using a strategy field (not "id"), avoid merging that field since it's already the same
|
|
878
|
+
const avoidKeys = strategy !== "id" ? [strategy] : [];
|
|
879
|
+
targetIndi.merge(clonedIndi, false, avoidKeys);
|
|
879
880
|
}
|
|
880
881
|
}
|
|
881
882
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeviz/gedcom-parser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Lightweight, pluggable GEDCOM parser for JavaScript/TypeScript with optional caching and place matching. Zero browser dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|