@treeviz/gedcom-parser 1.0.23 → 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/README.md +45 -0
- package/dist/classes/index.d.ts +1 -1
- package/dist/classes/index.js +424 -61
- package/dist/cli/index.js +1825 -449
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +423 -60
- package/dist/factories/index.d.ts +2 -2
- package/dist/factories/index.js +423 -60
- package/dist/{index-CSjQRlxq.d.ts → index-B3Po1Kaw.d.ts} +145 -107
- package/dist/index.d.ts +3 -3
- package/dist/index.js +461 -65
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/kinship-translator/index.d.ts +19 -19
- package/dist/kinship-translator/index.js +423 -60
- package/dist/place-parser-BLwBjtXS.d.ts +40 -0
- package/dist/{place-translator-BYX8180A.d.ts → place-translator-DPMyrsnu.d.ts} +24 -19
- package/dist/structures/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +459 -63
- package/package.json +1 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/place-parser-Dl5iva3h.d.ts +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aT as RequiredFilter, aO as RelationType, n as Filter, aA as PartnerType, ax as Order, az as OrderIterator, af as IndiType, ac as IndiKey, ap as NameOrder } from '../index-
|
|
1
|
+
import { aT as RequiredFilter, aO as RelationType, n as Filter, aA as PartnerType, ax as Order, az as OrderIterator, af as IndiType, ac as IndiKey, ap as NameOrder } from '../index-B3Po1Kaw.js';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/constants/index.js
CHANGED
|
@@ -97,66 +97,125 @@ __export(translators_exports, {
|
|
|
97
97
|
fr: () => KinshipTranslatorFr,
|
|
98
98
|
hu: () => KinshipTranslatorHU
|
|
99
99
|
});
|
|
100
|
+
var getGedcomId = (gedcom) => {
|
|
101
|
+
if (!gedcom) {
|
|
102
|
+
return "unknown";
|
|
103
|
+
}
|
|
104
|
+
const treeId = gedcom.getTreeId?.() || "";
|
|
105
|
+
const treeName = gedcom.getTreeName?.() || "";
|
|
106
|
+
const sanitizedName = treeName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
107
|
+
if (treeId && sanitizedName) {
|
|
108
|
+
return `${treeId}_${sanitizedName}`;
|
|
109
|
+
} else if (treeId) {
|
|
110
|
+
return treeId;
|
|
111
|
+
} else if (sanitizedName) {
|
|
112
|
+
return sanitizedName;
|
|
113
|
+
}
|
|
114
|
+
return `gedcom_${gedcom.refcount}`;
|
|
115
|
+
};
|
|
100
116
|
var caches = {
|
|
101
117
|
pathCache: {},
|
|
102
118
|
relativesOnDegreeCache: {},
|
|
103
|
-
relativesOnLevelCache: {}
|
|
119
|
+
relativesOnLevelCache: {},
|
|
120
|
+
profilePictureCache: {}
|
|
104
121
|
};
|
|
105
|
-
var
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
var cacheDbs;
|
|
123
|
+
var getCacheDbs = () => {
|
|
124
|
+
if (!cacheDbs) {
|
|
125
|
+
const getInstance = getCacheManagerFactory();
|
|
126
|
+
cacheDbs = {
|
|
127
|
+
pathCache: getInstance(
|
|
128
|
+
"ftv",
|
|
129
|
+
"Main",
|
|
130
|
+
"path",
|
|
131
|
+
true
|
|
132
|
+
),
|
|
133
|
+
relativesOnDegreeCache: getInstance("ftv", "Main", "path", true),
|
|
134
|
+
relativesOnLevelCache: getInstance(
|
|
135
|
+
"ftv",
|
|
136
|
+
"Main",
|
|
137
|
+
"path",
|
|
138
|
+
true
|
|
139
|
+
),
|
|
140
|
+
profilePictureCache: getInstance(
|
|
141
|
+
"ftv",
|
|
142
|
+
"Main",
|
|
143
|
+
"images",
|
|
144
|
+
false
|
|
145
|
+
)
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return cacheDbs;
|
|
120
149
|
};
|
|
121
|
-
|
|
150
|
+
var storeCache = {
|
|
151
|
+
// NOTE: pathCache, relativesOnLevelCache, and relativesOnDegreeCache are intentionally
|
|
152
|
+
// kept in memory only. These debounced functions exist to satisfy the type system
|
|
153
|
+
// but are never called.
|
|
122
154
|
pathCache: debounce((value) => {
|
|
123
155
|
if (value) {
|
|
124
|
-
|
|
156
|
+
getCacheDbs().pathCache.setItem(value);
|
|
125
157
|
}
|
|
126
158
|
}, 50),
|
|
127
159
|
relativesOnLevelCache: debounce((value) => {
|
|
128
160
|
if (value) {
|
|
129
|
-
|
|
161
|
+
getCacheDbs().relativesOnLevelCache.setItem(value);
|
|
130
162
|
}
|
|
131
163
|
}, 50),
|
|
132
164
|
relativesOnDegreeCache: debounce((value) => {
|
|
133
165
|
if (value) {
|
|
134
|
-
|
|
166
|
+
getCacheDbs().relativesOnDegreeCache.setItem(value);
|
|
135
167
|
}
|
|
136
|
-
}, 50)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
168
|
+
}, 50),
|
|
169
|
+
// profilePictureCache IS persisted to IndexedDB
|
|
170
|
+
profilePictureCache: debounce((value) => {
|
|
171
|
+
if (value) {
|
|
172
|
+
getCacheDbs().profilePictureCache.setItem(value);
|
|
173
|
+
}
|
|
174
|
+
}, 100)
|
|
175
|
+
};
|
|
176
|
+
var relativesCache = (cacheKey) => (gedcom, key, subKey, value) => {
|
|
177
|
+
const gedcomId = getGedcomId(gedcom);
|
|
178
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
179
|
+
const cache = caches[cacheKey];
|
|
180
|
+
if (!cache) {
|
|
140
181
|
caches[cacheKey] = {};
|
|
141
182
|
}
|
|
142
|
-
if (value
|
|
143
|
-
|
|
144
|
-
|
|
183
|
+
if (value) {
|
|
184
|
+
const typedCache2 = caches[cacheKey];
|
|
185
|
+
if (!typedCache2[fullKey]) {
|
|
186
|
+
typedCache2[fullKey] = {};
|
|
145
187
|
}
|
|
146
|
-
|
|
147
|
-
return
|
|
188
|
+
typedCache2[fullKey][subKey] = value;
|
|
189
|
+
return typedCache2[fullKey][subKey];
|
|
148
190
|
}
|
|
149
|
-
|
|
191
|
+
const typedCache = caches[cacheKey];
|
|
192
|
+
return typedCache?.[fullKey]?.[subKey];
|
|
150
193
|
};
|
|
151
|
-
var pathCache = (key, value) => {
|
|
194
|
+
var pathCache = (gedcom, key, value) => {
|
|
195
|
+
const gedcomId = getGedcomId(gedcom);
|
|
196
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
152
197
|
if (!caches.pathCache) {
|
|
153
198
|
caches.pathCache = {};
|
|
154
199
|
}
|
|
155
200
|
if (value && caches.pathCache) {
|
|
156
|
-
caches.pathCache[
|
|
157
|
-
return caches.pathCache[
|
|
201
|
+
caches.pathCache[fullKey] = value;
|
|
202
|
+
return caches.pathCache[fullKey];
|
|
158
203
|
}
|
|
159
|
-
return caches.pathCache?.[
|
|
204
|
+
return caches.pathCache?.[fullKey];
|
|
205
|
+
};
|
|
206
|
+
var profilePictureCache = (gedcom, key, value) => {
|
|
207
|
+
const gedcomId = getGedcomId(gedcom);
|
|
208
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
209
|
+
if (!caches.profilePictureCache) {
|
|
210
|
+
caches.profilePictureCache = {};
|
|
211
|
+
}
|
|
212
|
+
if (value && caches.profilePictureCache) {
|
|
213
|
+
caches.profilePictureCache[fullKey] = value;
|
|
214
|
+
storeCache.profilePictureCache(caches.profilePictureCache);
|
|
215
|
+
return caches.profilePictureCache[fullKey];
|
|
216
|
+
}
|
|
217
|
+
const cached = caches.profilePictureCache?.[fullKey];
|
|
218
|
+
return cached;
|
|
160
219
|
};
|
|
161
220
|
|
|
162
221
|
// src/utils/get-all-prop.ts
|
|
@@ -707,11 +766,30 @@ var Common = class _Common {
|
|
|
707
766
|
const sour = get(head, "SOUR.value");
|
|
708
767
|
return !!sour?.toLowerCase()?.startsWith("myheritage");
|
|
709
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* Get the source type as a string (for prefixing tree IDs and names)
|
|
771
|
+
* Returns the detected source type or undefined if unknown
|
|
772
|
+
*/
|
|
773
|
+
getSourceType() {
|
|
774
|
+
if (this.isAncestry()) return "Ancestry";
|
|
775
|
+
if (this.isMyHeritage()) return "MyHeritage";
|
|
776
|
+
if (this.isFamilySearch()) return "FamilySearch";
|
|
777
|
+
if (this.isGNO2GED()) return "GNO2GED";
|
|
778
|
+
if (this.isGenoPro()) return "GenoPro";
|
|
779
|
+
if (this.isAhnenblatt()) return "Ahnenblatt";
|
|
780
|
+
if (this.isGeni()) return "Geni";
|
|
781
|
+
return void 0;
|
|
782
|
+
}
|
|
710
783
|
isFamilySearch() {
|
|
711
784
|
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
712
785
|
const sourName = get(head, "SOUR.NAME.value");
|
|
713
786
|
return sourName === "FamilySearch API";
|
|
714
787
|
}
|
|
788
|
+
isGNO2GED() {
|
|
789
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
790
|
+
const sour = get(head, "SOUR.value");
|
|
791
|
+
return sour === "GNO2GED";
|
|
792
|
+
}
|
|
715
793
|
getAncestryTreeId() {
|
|
716
794
|
const path = "HEAD.SOUR._TREE.RIN.value";
|
|
717
795
|
return get(this, path) || get(this.getGedcom(), path);
|
|
@@ -722,11 +800,34 @@ var Common = class _Common {
|
|
|
722
800
|
}
|
|
723
801
|
getTreeId() {
|
|
724
802
|
if (this?.isAncestry()) {
|
|
725
|
-
|
|
803
|
+
const id = this.getAncestryTreeId();
|
|
804
|
+
if (id !== void 0) return id;
|
|
726
805
|
}
|
|
727
806
|
if (this?.isMyHeritage()) {
|
|
728
|
-
|
|
807
|
+
const id = this.getMyHeritageTreeId();
|
|
808
|
+
if (id !== void 0) return id;
|
|
729
809
|
}
|
|
810
|
+
if (this?.isFamilySearch()) {
|
|
811
|
+
const id = this.getFamilySearchTreeId();
|
|
812
|
+
if (id !== void 0) return id;
|
|
813
|
+
}
|
|
814
|
+
if (this?.isGNO2GED()) {
|
|
815
|
+
const id = this.getGNO2GEDTreeId();
|
|
816
|
+
if (id !== void 0) return id;
|
|
817
|
+
}
|
|
818
|
+
if (this?.isAhnenblatt()) {
|
|
819
|
+
const id = this.getAhnenblattTreeId();
|
|
820
|
+
if (id !== void 0) return id;
|
|
821
|
+
}
|
|
822
|
+
if (this?.isGeni()) {
|
|
823
|
+
const id = this.getGeniTreeId();
|
|
824
|
+
if (id !== void 0) return id;
|
|
825
|
+
}
|
|
826
|
+
if (this?.isGenoPro()) {
|
|
827
|
+
const id = this.getGenoProTreeId();
|
|
828
|
+
if (id !== void 0) return id;
|
|
829
|
+
}
|
|
830
|
+
return this.getUniversalTreeId();
|
|
730
831
|
}
|
|
731
832
|
getAncestryTreeName() {
|
|
732
833
|
const path = "HEAD.SOUR._TREE.value";
|
|
@@ -739,13 +840,146 @@ var Common = class _Common {
|
|
|
739
840
|
/Exported by MyHeritage.com from (?<tree>.+) in.+$/
|
|
740
841
|
)?.groups?.tree;
|
|
741
842
|
}
|
|
843
|
+
getFamilySearchTreeId() {
|
|
844
|
+
const rin = get(this, "HEAD.SOUR._TREE.RIN.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.RIN.value");
|
|
845
|
+
if (rin) {
|
|
846
|
+
return rin;
|
|
847
|
+
}
|
|
848
|
+
return "familysearch";
|
|
849
|
+
}
|
|
850
|
+
getFamilySearchTreeName() {
|
|
851
|
+
const treeName = get(this, "HEAD.SOUR._TREE.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.value");
|
|
852
|
+
if (treeName) {
|
|
853
|
+
return treeName;
|
|
854
|
+
}
|
|
855
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
856
|
+
return fileName || "FamilySearch Import";
|
|
857
|
+
}
|
|
858
|
+
getAhnenblattTreeId() {
|
|
859
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
860
|
+
if (fileName) {
|
|
861
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
862
|
+
if (idMatch) {
|
|
863
|
+
return idMatch[1];
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return void 0;
|
|
867
|
+
}
|
|
868
|
+
getAhnenblattTreeName() {
|
|
869
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
870
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
871
|
+
}
|
|
872
|
+
getGeniTreeId() {
|
|
873
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
874
|
+
if (fileName) {
|
|
875
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
876
|
+
if (idMatch) {
|
|
877
|
+
return idMatch[1];
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return void 0;
|
|
881
|
+
}
|
|
882
|
+
getGeniTreeName() {
|
|
883
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
884
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
885
|
+
}
|
|
886
|
+
getGenoProTreeId() {
|
|
887
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
888
|
+
if (fileName) {
|
|
889
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
890
|
+
if (idMatch) {
|
|
891
|
+
return idMatch[1];
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return void 0;
|
|
895
|
+
}
|
|
896
|
+
getGenoProTreeName() {
|
|
897
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
898
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
899
|
+
}
|
|
900
|
+
getGNO2GEDTreeId() {
|
|
901
|
+
const rin = get(this, "HEAD._TREE.RIN.value") || get(this.getGedcom(), "HEAD._TREE.RIN.value");
|
|
902
|
+
if (rin) {
|
|
903
|
+
return rin;
|
|
904
|
+
}
|
|
905
|
+
return `gno_${this._gedcom?.refcount || "unknown"}`;
|
|
906
|
+
}
|
|
907
|
+
getGNO2GEDTreeName() {
|
|
908
|
+
const treeName = get(this, "HEAD._TREE.value") || get(this.getGedcom(), "HEAD._TREE.value");
|
|
909
|
+
if (treeName) {
|
|
910
|
+
return treeName;
|
|
911
|
+
}
|
|
912
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
913
|
+
return fileName || "GNO2GED Export";
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Universal tree ID getter for unknown/unrecognized GEDCOM sources
|
|
917
|
+
* Tries to extract an ID from various common locations
|
|
918
|
+
*/
|
|
919
|
+
getUniversalTreeId() {
|
|
920
|
+
const sourceType = this.getSourceType();
|
|
921
|
+
const prefix = sourceType ? sourceType.toLowerCase() : "tree";
|
|
922
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
923
|
+
if (fileName) {
|
|
924
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
925
|
+
if (idMatch) {
|
|
926
|
+
return `${prefix}_${idMatch[1]}`;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return `${prefix}_${this._gedcom?.refcount || "unknown"}`;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Universal tree name getter for unknown/unrecognized GEDCOM sources
|
|
933
|
+
* Tries to extract a name from various common locations
|
|
934
|
+
*/
|
|
935
|
+
getUniversalTreeName() {
|
|
936
|
+
const sourceType = this.getSourceType();
|
|
937
|
+
const prefix = sourceType ? `${sourceType}-` : "";
|
|
938
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
939
|
+
if (fileName) {
|
|
940
|
+
const cleanName = fileName.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
941
|
+
return `${prefix}${cleanName}`;
|
|
942
|
+
}
|
|
943
|
+
const sourName = get(this, "HEAD.SOUR.NAME.value") || get(this.getGedcom(), "HEAD.SOUR.NAME.value");
|
|
944
|
+
if (sourName) {
|
|
945
|
+
return `${prefix}${sourName}`;
|
|
946
|
+
}
|
|
947
|
+
const sourValue = get(this, "HEAD.SOUR.value") || get(this.getGedcom(), "HEAD.SOUR.value");
|
|
948
|
+
if (sourValue) {
|
|
949
|
+
return `${prefix}${sourValue}`;
|
|
950
|
+
}
|
|
951
|
+
return `${prefix}Unknown Tree`;
|
|
952
|
+
}
|
|
742
953
|
getTreeName() {
|
|
743
954
|
if (this?.isAncestry()) {
|
|
744
|
-
|
|
955
|
+
const name = this.getAncestryTreeName();
|
|
956
|
+
if (name) return name;
|
|
745
957
|
}
|
|
746
958
|
if (this?.isMyHeritage()) {
|
|
747
|
-
|
|
959
|
+
const name = this.getMyHeritageTreeName();
|
|
960
|
+
if (name) return name;
|
|
961
|
+
}
|
|
962
|
+
if (this?.isFamilySearch()) {
|
|
963
|
+
const name = this.getFamilySearchTreeName();
|
|
964
|
+
if (name) return name;
|
|
748
965
|
}
|
|
966
|
+
if (this?.isGNO2GED()) {
|
|
967
|
+
const name = this.getGNO2GEDTreeName();
|
|
968
|
+
if (name) return name;
|
|
969
|
+
}
|
|
970
|
+
if (this?.isAhnenblatt()) {
|
|
971
|
+
const name = this.getAhnenblattTreeName();
|
|
972
|
+
if (name) return name;
|
|
973
|
+
}
|
|
974
|
+
if (this?.isGeni()) {
|
|
975
|
+
const name = this.getGeniTreeName();
|
|
976
|
+
if (name) return name;
|
|
977
|
+
}
|
|
978
|
+
if (this?.isGenoPro()) {
|
|
979
|
+
const name = this.getGenoProTreeName();
|
|
980
|
+
if (name) return name;
|
|
981
|
+
}
|
|
982
|
+
return this.getUniversalTreeName();
|
|
749
983
|
}
|
|
750
984
|
};
|
|
751
985
|
var createProxy = (target) => {
|
|
@@ -2522,7 +2756,7 @@ var Indi = class extends Common {
|
|
|
2522
2756
|
}
|
|
2523
2757
|
async ancestryMedia(namespace) {
|
|
2524
2758
|
const list = {};
|
|
2525
|
-
const objeList = this.get("OBJE")?.toList();
|
|
2759
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
2526
2760
|
const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
|
|
2527
2761
|
const tree = this.getAncestryTreeId();
|
|
2528
2762
|
if (objeList) {
|
|
@@ -2572,7 +2806,7 @@ var Indi = class extends Common {
|
|
|
2572
2806
|
title,
|
|
2573
2807
|
url,
|
|
2574
2808
|
contentType: type,
|
|
2575
|
-
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()
|
|
2809
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
2576
2810
|
};
|
|
2577
2811
|
}
|
|
2578
2812
|
})
|
|
@@ -2596,11 +2830,12 @@ var Indi = class extends Common {
|
|
|
2596
2830
|
if (!tree) {
|
|
2597
2831
|
return;
|
|
2598
2832
|
}
|
|
2599
|
-
const objeList = this.get("OBJE")?.toList();
|
|
2600
|
-
const birthObj = this.get("BIRT.OBJE")?.toList();
|
|
2601
|
-
const deathObj = this.get("DEAT.OBJE")?.toList();
|
|
2833
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
2834
|
+
const birthObj = this.get("BIRT.OBJE")?.toList().copy();
|
|
2835
|
+
const deathObj = this.get("DEAT.OBJE")?.toList().copy();
|
|
2836
|
+
objeList?.merge(birthObj).merge(deathObj);
|
|
2602
2837
|
(this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).forEach((fam) => {
|
|
2603
|
-
objeList?.merge(
|
|
2838
|
+
objeList?.merge(fam?.get("MARR.OBJE"));
|
|
2604
2839
|
});
|
|
2605
2840
|
objeList?.forEach((o, index) => {
|
|
2606
2841
|
if (!o) {
|
|
@@ -2626,7 +2861,7 @@ var Indi = class extends Common {
|
|
|
2626
2861
|
title,
|
|
2627
2862
|
url,
|
|
2628
2863
|
contentType: type,
|
|
2629
|
-
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()
|
|
2864
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
2630
2865
|
};
|
|
2631
2866
|
}
|
|
2632
2867
|
});
|
|
@@ -2718,6 +2953,85 @@ var Indi = class extends Common {
|
|
|
2718
2953
|
};
|
|
2719
2954
|
});
|
|
2720
2955
|
}
|
|
2956
|
+
geniMedia() {
|
|
2957
|
+
const list = {};
|
|
2958
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
2959
|
+
const sourList = this.get("SOUR")?.toList().copy();
|
|
2960
|
+
sourList?.forEach((sour) => {
|
|
2961
|
+
const sourObje = sour?.get("OBJE")?.toList();
|
|
2962
|
+
objeList?.merge(sourObje);
|
|
2963
|
+
});
|
|
2964
|
+
const rfn = this.get("RFN")?.toValue();
|
|
2965
|
+
const geniId = rfn?.replace(/^geni:/, "") || "unknown";
|
|
2966
|
+
objeList?.forEach((obje, index) => {
|
|
2967
|
+
if (!obje) {
|
|
2968
|
+
return;
|
|
2969
|
+
}
|
|
2970
|
+
const key = `@O${index}@`;
|
|
2971
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
2972
|
+
const url = obje?.get("FILE")?.toValue();
|
|
2973
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
2974
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
2975
|
+
if (url) {
|
|
2976
|
+
const urlMatch = url.match(/\/([^/]+)\?hash=/);
|
|
2977
|
+
const imgId = urlMatch?.[1] || `img-${index}-${Date.now().toString(36)}`;
|
|
2978
|
+
const id = `geni-${geniId}-${imgId}`;
|
|
2979
|
+
list[id] = {
|
|
2980
|
+
isPrimary,
|
|
2981
|
+
key,
|
|
2982
|
+
id,
|
|
2983
|
+
tree: geniId,
|
|
2984
|
+
imgId,
|
|
2985
|
+
person: this.id,
|
|
2986
|
+
title,
|
|
2987
|
+
url,
|
|
2988
|
+
contentType: type,
|
|
2989
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
2990
|
+
};
|
|
2991
|
+
}
|
|
2992
|
+
});
|
|
2993
|
+
return list;
|
|
2994
|
+
}
|
|
2995
|
+
universalMedia() {
|
|
2996
|
+
const list = {};
|
|
2997
|
+
if (!this.id) {
|
|
2998
|
+
return list;
|
|
2999
|
+
}
|
|
3000
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
3001
|
+
if (!objeList || objeList.length === 0) {
|
|
3002
|
+
return list;
|
|
3003
|
+
}
|
|
3004
|
+
const rfn = this.get("RFN")?.toValue();
|
|
3005
|
+
const treeId = this.getUniversalTreeId() || rfn || "universal";
|
|
3006
|
+
objeList.forEach((obje, index) => {
|
|
3007
|
+
if (!obje) {
|
|
3008
|
+
return;
|
|
3009
|
+
}
|
|
3010
|
+
const key = `@O${index}@`;
|
|
3011
|
+
obje.standardizeMedia();
|
|
3012
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
3013
|
+
const url = obje?.get("FILE")?.toValue();
|
|
3014
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
3015
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
3016
|
+
if (url) {
|
|
3017
|
+
const imgId = `media-${index}-${url.split("/").pop()?.split("?")[0]?.substring(0, 20) || Date.now().toString(36)}`;
|
|
3018
|
+
const id = `${treeId}-${this.id}-${imgId}`;
|
|
3019
|
+
list[id] = {
|
|
3020
|
+
isPrimary,
|
|
3021
|
+
key,
|
|
3022
|
+
id,
|
|
3023
|
+
tree: treeId,
|
|
3024
|
+
imgId,
|
|
3025
|
+
person: this.id,
|
|
3026
|
+
title,
|
|
3027
|
+
url,
|
|
3028
|
+
contentType: type,
|
|
3029
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
3030
|
+
};
|
|
3031
|
+
}
|
|
3032
|
+
});
|
|
3033
|
+
return list;
|
|
3034
|
+
}
|
|
2721
3035
|
async multimedia(namespace) {
|
|
2722
3036
|
if (this?.isAncestry()) {
|
|
2723
3037
|
return await this.ancestryMedia(namespace);
|
|
@@ -2725,11 +3039,30 @@ var Indi = class extends Common {
|
|
|
2725
3039
|
if (this?.isMyHeritage()) {
|
|
2726
3040
|
return this.myheritageMedia();
|
|
2727
3041
|
}
|
|
2728
|
-
|
|
3042
|
+
if (this?.isGeni()) {
|
|
3043
|
+
return this.geniMedia();
|
|
3044
|
+
}
|
|
3045
|
+
return this.universalMedia();
|
|
2729
3046
|
}
|
|
2730
3047
|
async getProfilePicture(namespace, onlyPrimary = true) {
|
|
3048
|
+
if (!this.id) {
|
|
3049
|
+
return void 0;
|
|
3050
|
+
}
|
|
3051
|
+
const cacheKey = this.id;
|
|
3052
|
+
const cached = profilePictureCache(
|
|
3053
|
+
this._gedcom,
|
|
3054
|
+
cacheKey
|
|
3055
|
+
);
|
|
3056
|
+
if (cached !== void 0) {
|
|
3057
|
+
return cached;
|
|
3058
|
+
}
|
|
2731
3059
|
const mediaList = await this.multimedia(namespace);
|
|
2732
3060
|
if (!mediaList) {
|
|
3061
|
+
profilePictureCache(
|
|
3062
|
+
this._gedcom,
|
|
3063
|
+
cacheKey,
|
|
3064
|
+
void 0
|
|
3065
|
+
);
|
|
2733
3066
|
return void 0;
|
|
2734
3067
|
}
|
|
2735
3068
|
const mediaArray = Object.values(mediaList);
|
|
@@ -2737,27 +3070,41 @@ var Indi = class extends Common {
|
|
|
2737
3070
|
(media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
|
|
2738
3071
|
);
|
|
2739
3072
|
if (primaryMedia) {
|
|
2740
|
-
|
|
3073
|
+
const result = {
|
|
2741
3074
|
file: primaryMedia.url,
|
|
2742
3075
|
form: primaryMedia.contentType,
|
|
2743
3076
|
title: primaryMedia.title,
|
|
2744
3077
|
isPrimary: true
|
|
2745
3078
|
};
|
|
2746
|
-
|
|
2747
|
-
|
|
3079
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
3080
|
+
return result;
|
|
3081
|
+
}
|
|
3082
|
+
if (onlyPrimary) {
|
|
3083
|
+
profilePictureCache(
|
|
3084
|
+
this._gedcom,
|
|
3085
|
+
cacheKey,
|
|
3086
|
+
void 0
|
|
3087
|
+
);
|
|
2748
3088
|
return void 0;
|
|
2749
3089
|
}
|
|
2750
3090
|
const secondaryMedia = mediaArray.find(
|
|
2751
3091
|
(media) => isImageFormat(media.contentType || getFileExtension(media.url))
|
|
2752
3092
|
);
|
|
2753
3093
|
if (secondaryMedia) {
|
|
2754
|
-
|
|
3094
|
+
const result = {
|
|
2755
3095
|
file: secondaryMedia.url,
|
|
2756
3096
|
form: secondaryMedia.contentType,
|
|
2757
3097
|
title: secondaryMedia.title,
|
|
2758
3098
|
isPrimary: false
|
|
2759
3099
|
};
|
|
3100
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
3101
|
+
return result;
|
|
2760
3102
|
}
|
|
3103
|
+
profilePictureCache(
|
|
3104
|
+
this._gedcom,
|
|
3105
|
+
cacheKey,
|
|
3106
|
+
void 0
|
|
3107
|
+
);
|
|
2761
3108
|
return void 0;
|
|
2762
3109
|
}
|
|
2763
3110
|
link(poolId) {
|
|
@@ -3125,7 +3472,7 @@ var Indi = class extends Common {
|
|
|
3125
3472
|
return;
|
|
3126
3473
|
}
|
|
3127
3474
|
const cacheKey = `${this.id}|${usedIndi.id}`;
|
|
3128
|
-
const cache = pathCache(cacheKey);
|
|
3475
|
+
const cache = pathCache(this._gedcom, cacheKey);
|
|
3129
3476
|
if (cache) {
|
|
3130
3477
|
return cache;
|
|
3131
3478
|
}
|
|
@@ -3170,7 +3517,7 @@ var Indi = class extends Common {
|
|
|
3170
3517
|
if (breakOnNext) {
|
|
3171
3518
|
return void 0;
|
|
3172
3519
|
}
|
|
3173
|
-
pathCache(cacheKey, path2);
|
|
3520
|
+
pathCache(this._gedcom, cacheKey, path2);
|
|
3174
3521
|
return path2;
|
|
3175
3522
|
}
|
|
3176
3523
|
visited.append(indi);
|
|
@@ -3340,7 +3687,7 @@ var Indi = class extends Common {
|
|
|
3340
3687
|
}
|
|
3341
3688
|
getRelativesOnDegree(degree = 0) {
|
|
3342
3689
|
this.id = this.id || `@I${Math.random()}@`;
|
|
3343
|
-
const cache = relativesOnDegreeCache(this.id, degree);
|
|
3690
|
+
const cache = relativesOnDegreeCache(this._gedcom, this.id, degree);
|
|
3344
3691
|
if (cache) {
|
|
3345
3692
|
return cache;
|
|
3346
3693
|
}
|
|
@@ -3348,6 +3695,7 @@ var Indi = class extends Common {
|
|
|
3348
3695
|
const excludes = persons;
|
|
3349
3696
|
if (!Math.abs(degree)) {
|
|
3350
3697
|
return relativesOnDegreeCache(
|
|
3698
|
+
this._gedcom,
|
|
3351
3699
|
this.id,
|
|
3352
3700
|
degree,
|
|
3353
3701
|
persons.except(this)
|
|
@@ -3358,11 +3706,11 @@ var Indi = class extends Common {
|
|
|
3358
3706
|
excludes.merge(persons);
|
|
3359
3707
|
persons = this.getRelativesOnLevel(validDegree).getRelativesOnDegree(-validDegree).copy().exclude(excludes);
|
|
3360
3708
|
}
|
|
3361
|
-
return relativesOnDegreeCache(this.id, degree, persons);
|
|
3709
|
+
return relativesOnDegreeCache(this._gedcom, this.id, degree, persons);
|
|
3362
3710
|
}
|
|
3363
3711
|
getRelativesOnLevel(level = 0, filter) {
|
|
3364
3712
|
this.id = this.id || `@I${Math.random()}@`;
|
|
3365
|
-
const cache = relativesOnLevelCache(this.id, level);
|
|
3713
|
+
const cache = relativesOnLevelCache(this._gedcom, this.id, level);
|
|
3366
3714
|
if (cache) {
|
|
3367
3715
|
return cache;
|
|
3368
3716
|
}
|
|
@@ -3373,7 +3721,7 @@ var Indi = class extends Common {
|
|
|
3373
3721
|
};
|
|
3374
3722
|
let families = this.get(config.key)?.toValueList();
|
|
3375
3723
|
if (!families) {
|
|
3376
|
-
return relativesOnLevelCache(this.id, level, persons);
|
|
3724
|
+
return relativesOnLevelCache(this._gedcom, this.id, level, persons);
|
|
3377
3725
|
}
|
|
3378
3726
|
if (filter) {
|
|
3379
3727
|
families = families.filter(filter);
|
|
@@ -3384,7 +3732,12 @@ var Indi = class extends Common {
|
|
|
3384
3732
|
persons = this.toFamilies(families).getParents();
|
|
3385
3733
|
}
|
|
3386
3734
|
if (level >= -1 && level <= 1) {
|
|
3387
|
-
return relativesOnLevelCache(
|
|
3735
|
+
return relativesOnLevelCache(
|
|
3736
|
+
this._gedcom,
|
|
3737
|
+
this.id,
|
|
3738
|
+
level,
|
|
3739
|
+
persons.except(this)
|
|
3740
|
+
);
|
|
3388
3741
|
}
|
|
3389
3742
|
for (let i = 1; i < Math.abs(level); i++) {
|
|
3390
3743
|
if (config.isAscendant) {
|
|
@@ -3393,7 +3746,12 @@ var Indi = class extends Common {
|
|
|
3393
3746
|
persons = persons.getParents();
|
|
3394
3747
|
}
|
|
3395
3748
|
}
|
|
3396
|
-
return relativesOnLevelCache(
|
|
3749
|
+
return relativesOnLevelCache(
|
|
3750
|
+
this._gedcom,
|
|
3751
|
+
this.id,
|
|
3752
|
+
level,
|
|
3753
|
+
persons.except(this)
|
|
3754
|
+
);
|
|
3397
3755
|
}
|
|
3398
3756
|
getAscendants(level = 0, filter) {
|
|
3399
3757
|
if (!level) {
|
|
@@ -3432,7 +3790,12 @@ var Indi = class extends Common {
|
|
|
3432
3790
|
}
|
|
3433
3791
|
currentGen++;
|
|
3434
3792
|
generations[currentGen] = descentants;
|
|
3435
|
-
relativesOnLevelCache(
|
|
3793
|
+
relativesOnLevelCache(
|
|
3794
|
+
this._gedcom,
|
|
3795
|
+
this.id,
|
|
3796
|
+
-currentGen,
|
|
3797
|
+
descentants
|
|
3798
|
+
);
|
|
3436
3799
|
descentants && relatives.merge(descentants);
|
|
3437
3800
|
}
|
|
3438
3801
|
return { relatives, generations };
|
|
@@ -3465,7 +3828,7 @@ var Indi = class extends Common {
|
|
|
3465
3828
|
}
|
|
3466
3829
|
currentGen++;
|
|
3467
3830
|
generations[currentGen] = parents;
|
|
3468
|
-
relativesOnLevelCache(this.id, currentGen, parents);
|
|
3831
|
+
relativesOnLevelCache(this._gedcom, this.id, currentGen, parents);
|
|
3469
3832
|
parents && relatives.merge(parents);
|
|
3470
3833
|
}
|
|
3471
3834
|
return { relatives, generations };
|