@treeviz/gedcom-parser 1.0.23 → 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/README.md +45 -0
- package/dist/classes/index.d.ts +1 -1
- package/dist/classes/index.js +425 -59
- package/dist/cli/index.js +1613 -385
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +424 -58
- package/dist/factories/index.d.ts +2 -2
- package/dist/factories/index.js +424 -58
- package/dist/{index-CSjQRlxq.d.ts → index-CzYZg44D.d.ts} +30 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +462 -63
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/kinship-translator/index.d.ts +2 -2
- package/dist/kinship-translator/index.js +424 -58
- package/dist/place-parser-CJ3EbFmb.d.ts +40 -0
- package/dist/{place-translator-BYX8180A.d.ts → place-translator-Ci5rEY6p.d.ts} +3 -1
- 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 +460 -61
- package/package.json +1 -1
- package/dist/place-parser-Dl5iva3h.d.ts +0 -37
package/dist/classes/index.js
CHANGED
|
@@ -850,11 +850,30 @@ var Common = class _Common {
|
|
|
850
850
|
const sour = get(head, "SOUR.value");
|
|
851
851
|
return !!sour?.toLowerCase()?.startsWith("myheritage");
|
|
852
852
|
}
|
|
853
|
+
/**
|
|
854
|
+
* Get the source type as a string (for prefixing tree IDs and names)
|
|
855
|
+
* Returns the detected source type or undefined if unknown
|
|
856
|
+
*/
|
|
857
|
+
getSourceType() {
|
|
858
|
+
if (this.isAncestry()) return "Ancestry";
|
|
859
|
+
if (this.isMyHeritage()) return "MyHeritage";
|
|
860
|
+
if (this.isFamilySearch()) return "FamilySearch";
|
|
861
|
+
if (this.isGNO2GED()) return "GNO2GED";
|
|
862
|
+
if (this.isGenoPro()) return "GenoPro";
|
|
863
|
+
if (this.isAhnenblatt()) return "Ahnenblatt";
|
|
864
|
+
if (this.isGeni()) return "Geni";
|
|
865
|
+
return void 0;
|
|
866
|
+
}
|
|
853
867
|
isFamilySearch() {
|
|
854
868
|
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
855
869
|
const sourName = get(head, "SOUR.NAME.value");
|
|
856
870
|
return sourName === "FamilySearch API";
|
|
857
871
|
}
|
|
872
|
+
isGNO2GED() {
|
|
873
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
874
|
+
const sour = get(head, "SOUR.value");
|
|
875
|
+
return sour === "GNO2GED";
|
|
876
|
+
}
|
|
858
877
|
getAncestryTreeId() {
|
|
859
878
|
const path = "HEAD.SOUR._TREE.RIN.value";
|
|
860
879
|
return get(this, path) || get(this.getGedcom(), path);
|
|
@@ -865,11 +884,34 @@ var Common = class _Common {
|
|
|
865
884
|
}
|
|
866
885
|
getTreeId() {
|
|
867
886
|
if (this?.isAncestry()) {
|
|
868
|
-
|
|
887
|
+
const id = this.getAncestryTreeId();
|
|
888
|
+
if (id !== void 0) return id;
|
|
869
889
|
}
|
|
870
890
|
if (this?.isMyHeritage()) {
|
|
871
|
-
|
|
891
|
+
const id = this.getMyHeritageTreeId();
|
|
892
|
+
if (id !== void 0) return id;
|
|
893
|
+
}
|
|
894
|
+
if (this?.isFamilySearch()) {
|
|
895
|
+
const id = this.getFamilySearchTreeId();
|
|
896
|
+
if (id !== void 0) return id;
|
|
872
897
|
}
|
|
898
|
+
if (this?.isGNO2GED()) {
|
|
899
|
+
const id = this.getGNO2GEDTreeId();
|
|
900
|
+
if (id !== void 0) return id;
|
|
901
|
+
}
|
|
902
|
+
if (this?.isAhnenblatt()) {
|
|
903
|
+
const id = this.getAhnenblattTreeId();
|
|
904
|
+
if (id !== void 0) return id;
|
|
905
|
+
}
|
|
906
|
+
if (this?.isGeni()) {
|
|
907
|
+
const id = this.getGeniTreeId();
|
|
908
|
+
if (id !== void 0) return id;
|
|
909
|
+
}
|
|
910
|
+
if (this?.isGenoPro()) {
|
|
911
|
+
const id = this.getGenoProTreeId();
|
|
912
|
+
if (id !== void 0) return id;
|
|
913
|
+
}
|
|
914
|
+
return this.getUniversalTreeId();
|
|
873
915
|
}
|
|
874
916
|
getAncestryTreeName() {
|
|
875
917
|
const path = "HEAD.SOUR._TREE.value";
|
|
@@ -882,13 +924,146 @@ var Common = class _Common {
|
|
|
882
924
|
/Exported by MyHeritage.com from (?<tree>.+) in.+$/
|
|
883
925
|
)?.groups?.tree;
|
|
884
926
|
}
|
|
927
|
+
getFamilySearchTreeId() {
|
|
928
|
+
const rin = get(this, "HEAD.SOUR._TREE.RIN.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.RIN.value");
|
|
929
|
+
if (rin) {
|
|
930
|
+
return rin;
|
|
931
|
+
}
|
|
932
|
+
return "familysearch";
|
|
933
|
+
}
|
|
934
|
+
getFamilySearchTreeName() {
|
|
935
|
+
const treeName = get(this, "HEAD.SOUR._TREE.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.value");
|
|
936
|
+
if (treeName) {
|
|
937
|
+
return treeName;
|
|
938
|
+
}
|
|
939
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
940
|
+
return fileName || "FamilySearch Import";
|
|
941
|
+
}
|
|
942
|
+
getAhnenblattTreeId() {
|
|
943
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
944
|
+
if (fileName) {
|
|
945
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
946
|
+
if (idMatch) {
|
|
947
|
+
return idMatch[1];
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return void 0;
|
|
951
|
+
}
|
|
952
|
+
getAhnenblattTreeName() {
|
|
953
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
954
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
955
|
+
}
|
|
956
|
+
getGeniTreeId() {
|
|
957
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
958
|
+
if (fileName) {
|
|
959
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
960
|
+
if (idMatch) {
|
|
961
|
+
return idMatch[1];
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return void 0;
|
|
965
|
+
}
|
|
966
|
+
getGeniTreeName() {
|
|
967
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
968
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
969
|
+
}
|
|
970
|
+
getGenoProTreeId() {
|
|
971
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
972
|
+
if (fileName) {
|
|
973
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
974
|
+
if (idMatch) {
|
|
975
|
+
return idMatch[1];
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return void 0;
|
|
979
|
+
}
|
|
980
|
+
getGenoProTreeName() {
|
|
981
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
982
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
983
|
+
}
|
|
984
|
+
getGNO2GEDTreeId() {
|
|
985
|
+
const rin = get(this, "HEAD._TREE.RIN.value") || get(this.getGedcom(), "HEAD._TREE.RIN.value");
|
|
986
|
+
if (rin) {
|
|
987
|
+
return rin;
|
|
988
|
+
}
|
|
989
|
+
return `gno_${this._gedcom?.refcount || "unknown"}`;
|
|
990
|
+
}
|
|
991
|
+
getGNO2GEDTreeName() {
|
|
992
|
+
const treeName = get(this, "HEAD._TREE.value") || get(this.getGedcom(), "HEAD._TREE.value");
|
|
993
|
+
if (treeName) {
|
|
994
|
+
return treeName;
|
|
995
|
+
}
|
|
996
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
997
|
+
return fileName || "GNO2GED Export";
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Universal tree ID getter for unknown/unrecognized GEDCOM sources
|
|
1001
|
+
* Tries to extract an ID from various common locations
|
|
1002
|
+
*/
|
|
1003
|
+
getUniversalTreeId() {
|
|
1004
|
+
const sourceType = this.getSourceType();
|
|
1005
|
+
const prefix = sourceType ? sourceType.toLowerCase() : "tree";
|
|
1006
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
1007
|
+
if (fileName) {
|
|
1008
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
1009
|
+
if (idMatch) {
|
|
1010
|
+
return `${prefix}_${idMatch[1]}`;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return `${prefix}_${this._gedcom?.refcount || "unknown"}`;
|
|
1014
|
+
}
|
|
1015
|
+
/**
|
|
1016
|
+
* Universal tree name getter for unknown/unrecognized GEDCOM sources
|
|
1017
|
+
* Tries to extract a name from various common locations
|
|
1018
|
+
*/
|
|
1019
|
+
getUniversalTreeName() {
|
|
1020
|
+
const sourceType = this.getSourceType();
|
|
1021
|
+
const prefix = sourceType ? `${sourceType}-` : "";
|
|
1022
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
1023
|
+
if (fileName) {
|
|
1024
|
+
const cleanName = fileName.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
1025
|
+
return `${prefix}${cleanName}`;
|
|
1026
|
+
}
|
|
1027
|
+
const sourName = get(this, "HEAD.SOUR.NAME.value") || get(this.getGedcom(), "HEAD.SOUR.NAME.value");
|
|
1028
|
+
if (sourName) {
|
|
1029
|
+
return `${prefix}${sourName}`;
|
|
1030
|
+
}
|
|
1031
|
+
const sourValue = get(this, "HEAD.SOUR.value") || get(this.getGedcom(), "HEAD.SOUR.value");
|
|
1032
|
+
if (sourValue) {
|
|
1033
|
+
return `${prefix}${sourValue}`;
|
|
1034
|
+
}
|
|
1035
|
+
return `${prefix}Unknown Tree`;
|
|
1036
|
+
}
|
|
885
1037
|
getTreeName() {
|
|
886
1038
|
if (this?.isAncestry()) {
|
|
887
|
-
|
|
1039
|
+
const name = this.getAncestryTreeName();
|
|
1040
|
+
if (name) return name;
|
|
888
1041
|
}
|
|
889
1042
|
if (this?.isMyHeritage()) {
|
|
890
|
-
|
|
1043
|
+
const name = this.getMyHeritageTreeName();
|
|
1044
|
+
if (name) return name;
|
|
1045
|
+
}
|
|
1046
|
+
if (this?.isFamilySearch()) {
|
|
1047
|
+
const name = this.getFamilySearchTreeName();
|
|
1048
|
+
if (name) return name;
|
|
1049
|
+
}
|
|
1050
|
+
if (this?.isGNO2GED()) {
|
|
1051
|
+
const name = this.getGNO2GEDTreeName();
|
|
1052
|
+
if (name) return name;
|
|
1053
|
+
}
|
|
1054
|
+
if (this?.isAhnenblatt()) {
|
|
1055
|
+
const name = this.getAhnenblattTreeName();
|
|
1056
|
+
if (name) return name;
|
|
891
1057
|
}
|
|
1058
|
+
if (this?.isGeni()) {
|
|
1059
|
+
const name = this.getGeniTreeName();
|
|
1060
|
+
if (name) return name;
|
|
1061
|
+
}
|
|
1062
|
+
if (this?.isGenoPro()) {
|
|
1063
|
+
const name = this.getGenoProTreeName();
|
|
1064
|
+
if (name) return name;
|
|
1065
|
+
}
|
|
1066
|
+
return this.getUniversalTreeName();
|
|
892
1067
|
}
|
|
893
1068
|
};
|
|
894
1069
|
var createProxy = (target) => {
|
|
@@ -3030,66 +3205,125 @@ var getMarriageAscAndChildBirth = (person) => (itemA, keyA, itemB, keyB) => {
|
|
|
3030
3205
|
const childB = familyB?.getChildren().orderBy(BIRTH_ASC).index(0);
|
|
3031
3206
|
return getBirthAsc(childA, keyA, childB);
|
|
3032
3207
|
};
|
|
3208
|
+
var getGedcomId = (gedcom) => {
|
|
3209
|
+
if (!gedcom) {
|
|
3210
|
+
return "unknown";
|
|
3211
|
+
}
|
|
3212
|
+
const treeId = gedcom.getTreeId?.() || "";
|
|
3213
|
+
const treeName = gedcom.getTreeName?.() || "";
|
|
3214
|
+
const sanitizedName = treeName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
3215
|
+
if (treeId && sanitizedName) {
|
|
3216
|
+
return `${treeId}_${sanitizedName}`;
|
|
3217
|
+
} else if (treeId) {
|
|
3218
|
+
return treeId;
|
|
3219
|
+
} else if (sanitizedName) {
|
|
3220
|
+
return sanitizedName;
|
|
3221
|
+
}
|
|
3222
|
+
return `gedcom_${gedcom.refcount}`;
|
|
3223
|
+
};
|
|
3033
3224
|
var caches = {
|
|
3034
3225
|
pathCache: {},
|
|
3035
3226
|
relativesOnDegreeCache: {},
|
|
3036
|
-
relativesOnLevelCache: {}
|
|
3227
|
+
relativesOnLevelCache: {},
|
|
3228
|
+
profilePictureCache: {}
|
|
3037
3229
|
};
|
|
3038
|
-
var
|
|
3039
|
-
var
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3230
|
+
var cacheDbs;
|
|
3231
|
+
var getCacheDbs = () => {
|
|
3232
|
+
if (!cacheDbs) {
|
|
3233
|
+
const getInstance = getCacheManagerFactory();
|
|
3234
|
+
cacheDbs = {
|
|
3235
|
+
pathCache: getInstance(
|
|
3236
|
+
"ftv",
|
|
3237
|
+
"Main",
|
|
3238
|
+
"path",
|
|
3239
|
+
true
|
|
3240
|
+
),
|
|
3241
|
+
relativesOnDegreeCache: getInstance("ftv", "Main", "path", true),
|
|
3242
|
+
relativesOnLevelCache: getInstance(
|
|
3243
|
+
"ftv",
|
|
3244
|
+
"Main",
|
|
3245
|
+
"path",
|
|
3246
|
+
true
|
|
3247
|
+
),
|
|
3248
|
+
profilePictureCache: getInstance(
|
|
3249
|
+
"ftv",
|
|
3250
|
+
"Main",
|
|
3251
|
+
"images",
|
|
3252
|
+
false
|
|
3253
|
+
)
|
|
3254
|
+
};
|
|
3255
|
+
}
|
|
3256
|
+
return cacheDbs;
|
|
3053
3257
|
};
|
|
3054
|
-
|
|
3258
|
+
var storeCache = {
|
|
3259
|
+
// NOTE: pathCache, relativesOnLevelCache, and relativesOnDegreeCache are intentionally
|
|
3260
|
+
// kept in memory only. These debounced functions exist to satisfy the type system
|
|
3261
|
+
// but are never called.
|
|
3055
3262
|
pathCache: debounce((value) => {
|
|
3056
3263
|
if (value) {
|
|
3057
|
-
|
|
3264
|
+
getCacheDbs().pathCache.setItem(value);
|
|
3058
3265
|
}
|
|
3059
3266
|
}, 50),
|
|
3060
3267
|
relativesOnLevelCache: debounce((value) => {
|
|
3061
3268
|
if (value) {
|
|
3062
|
-
|
|
3269
|
+
getCacheDbs().relativesOnLevelCache.setItem(value);
|
|
3063
3270
|
}
|
|
3064
3271
|
}, 50),
|
|
3065
3272
|
relativesOnDegreeCache: debounce((value) => {
|
|
3066
3273
|
if (value) {
|
|
3067
|
-
|
|
3274
|
+
getCacheDbs().relativesOnDegreeCache.setItem(value);
|
|
3068
3275
|
}
|
|
3069
|
-
}, 50)
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3276
|
+
}, 50),
|
|
3277
|
+
// profilePictureCache IS persisted to IndexedDB
|
|
3278
|
+
profilePictureCache: debounce((value) => {
|
|
3279
|
+
if (value) {
|
|
3280
|
+
getCacheDbs().profilePictureCache.setItem(value);
|
|
3281
|
+
}
|
|
3282
|
+
}, 100)
|
|
3283
|
+
};
|
|
3284
|
+
var relativesCache = (cacheKey) => (gedcom, key, subKey, value) => {
|
|
3285
|
+
const gedcomId = getGedcomId(gedcom);
|
|
3286
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
3287
|
+
const cache = caches[cacheKey];
|
|
3288
|
+
if (!cache) {
|
|
3073
3289
|
caches[cacheKey] = {};
|
|
3074
3290
|
}
|
|
3075
|
-
if (value
|
|
3076
|
-
|
|
3077
|
-
|
|
3291
|
+
if (value) {
|
|
3292
|
+
const typedCache2 = caches[cacheKey];
|
|
3293
|
+
if (!typedCache2[fullKey]) {
|
|
3294
|
+
typedCache2[fullKey] = {};
|
|
3078
3295
|
}
|
|
3079
|
-
|
|
3080
|
-
return
|
|
3296
|
+
typedCache2[fullKey][subKey] = value;
|
|
3297
|
+
return typedCache2[fullKey][subKey];
|
|
3081
3298
|
}
|
|
3082
|
-
|
|
3299
|
+
const typedCache = caches[cacheKey];
|
|
3300
|
+
return typedCache?.[fullKey]?.[subKey];
|
|
3083
3301
|
};
|
|
3084
|
-
var pathCache = (key, value) => {
|
|
3302
|
+
var pathCache = (gedcom, key, value) => {
|
|
3303
|
+
const gedcomId = getGedcomId(gedcom);
|
|
3304
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
3085
3305
|
if (!caches.pathCache) {
|
|
3086
3306
|
caches.pathCache = {};
|
|
3087
3307
|
}
|
|
3088
3308
|
if (value && caches.pathCache) {
|
|
3089
|
-
caches.pathCache[
|
|
3090
|
-
return caches.pathCache[
|
|
3309
|
+
caches.pathCache[fullKey] = value;
|
|
3310
|
+
return caches.pathCache[fullKey];
|
|
3091
3311
|
}
|
|
3092
|
-
return caches.pathCache?.[
|
|
3312
|
+
return caches.pathCache?.[fullKey];
|
|
3313
|
+
};
|
|
3314
|
+
var profilePictureCache = (gedcom, key, value) => {
|
|
3315
|
+
const gedcomId = getGedcomId(gedcom);
|
|
3316
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
3317
|
+
if (!caches.profilePictureCache) {
|
|
3318
|
+
caches.profilePictureCache = {};
|
|
3319
|
+
}
|
|
3320
|
+
if (value && caches.profilePictureCache) {
|
|
3321
|
+
caches.profilePictureCache[fullKey] = value;
|
|
3322
|
+
storeCache.profilePictureCache(caches.profilePictureCache);
|
|
3323
|
+
return caches.profilePictureCache[fullKey];
|
|
3324
|
+
}
|
|
3325
|
+
const cached = caches.profilePictureCache?.[fullKey];
|
|
3326
|
+
return cached;
|
|
3093
3327
|
};
|
|
3094
3328
|
|
|
3095
3329
|
// src/utils/get-places.ts
|
|
@@ -4361,7 +4595,7 @@ var Indi = class extends Common {
|
|
|
4361
4595
|
}
|
|
4362
4596
|
async ancestryMedia(namespace) {
|
|
4363
4597
|
const list = {};
|
|
4364
|
-
const objeList = this.get("OBJE")?.toList();
|
|
4598
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4365
4599
|
const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
|
|
4366
4600
|
const tree = this.getAncestryTreeId();
|
|
4367
4601
|
if (objeList) {
|
|
@@ -4435,11 +4669,12 @@ var Indi = class extends Common {
|
|
|
4435
4669
|
if (!tree) {
|
|
4436
4670
|
return;
|
|
4437
4671
|
}
|
|
4438
|
-
const objeList = this.get("OBJE")?.toList();
|
|
4439
|
-
const birthObj = this.get("BIRT.OBJE")?.toList();
|
|
4440
|
-
const deathObj = this.get("DEAT.OBJE")?.toList();
|
|
4672
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4673
|
+
const birthObj = this.get("BIRT.OBJE")?.toList().copy();
|
|
4674
|
+
const deathObj = this.get("DEAT.OBJE")?.toList().copy();
|
|
4675
|
+
objeList?.merge(birthObj).merge(deathObj);
|
|
4441
4676
|
(this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).forEach((fam) => {
|
|
4442
|
-
objeList
|
|
4677
|
+
objeList.merge(fam?.get("MARR.OBJE"));
|
|
4443
4678
|
});
|
|
4444
4679
|
objeList?.forEach((o, index) => {
|
|
4445
4680
|
if (!o) {
|
|
@@ -4557,6 +4792,88 @@ var Indi = class extends Common {
|
|
|
4557
4792
|
};
|
|
4558
4793
|
});
|
|
4559
4794
|
}
|
|
4795
|
+
geniMedia() {
|
|
4796
|
+
const list = {};
|
|
4797
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4798
|
+
const sourList = this.get("SOUR")?.toList().copy();
|
|
4799
|
+
sourList?.forEach((sour) => {
|
|
4800
|
+
const sourObje = sour?.get("OBJE")?.toList();
|
|
4801
|
+
objeList.merge(sourObje);
|
|
4802
|
+
});
|
|
4803
|
+
if (!objeList || objeList.length === 0) {
|
|
4804
|
+
return void 0;
|
|
4805
|
+
}
|
|
4806
|
+
const rfn = this.get("RFN")?.toValue();
|
|
4807
|
+
const geniId = rfn?.replace(/^geni:/, "") || "unknown";
|
|
4808
|
+
objeList.forEach((obje, index) => {
|
|
4809
|
+
if (!obje) {
|
|
4810
|
+
return;
|
|
4811
|
+
}
|
|
4812
|
+
const key = `@O${index}@`;
|
|
4813
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
4814
|
+
const url = obje?.get("FILE")?.toValue();
|
|
4815
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
4816
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
4817
|
+
if (url) {
|
|
4818
|
+
const urlMatch = url.match(/\/([^/]+)\?hash=/);
|
|
4819
|
+
const imgId = urlMatch?.[1] || `img-${index}-${Date.now().toString(36)}`;
|
|
4820
|
+
const id = `geni-${geniId}-${imgId}`;
|
|
4821
|
+
list[id] = {
|
|
4822
|
+
isPrimary,
|
|
4823
|
+
key,
|
|
4824
|
+
id,
|
|
4825
|
+
tree: geniId,
|
|
4826
|
+
imgId,
|
|
4827
|
+
person: this.id,
|
|
4828
|
+
title,
|
|
4829
|
+
url,
|
|
4830
|
+
contentType: type,
|
|
4831
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
4832
|
+
};
|
|
4833
|
+
}
|
|
4834
|
+
});
|
|
4835
|
+
return list;
|
|
4836
|
+
}
|
|
4837
|
+
universalMedia() {
|
|
4838
|
+
const list = {};
|
|
4839
|
+
if (!this.id) {
|
|
4840
|
+
return list;
|
|
4841
|
+
}
|
|
4842
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4843
|
+
if (!objeList || objeList.length === 0) {
|
|
4844
|
+
return list;
|
|
4845
|
+
}
|
|
4846
|
+
const rfn = this.get("RFN")?.toValue();
|
|
4847
|
+
const treeId = rfn || "universal";
|
|
4848
|
+
objeList.forEach((obje, index) => {
|
|
4849
|
+
if (!obje) {
|
|
4850
|
+
return;
|
|
4851
|
+
}
|
|
4852
|
+
const key = `@O${index}@`;
|
|
4853
|
+
obje.standardizeMedia();
|
|
4854
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
4855
|
+
const url = obje?.get("FILE")?.toValue();
|
|
4856
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
4857
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
4858
|
+
if (url) {
|
|
4859
|
+
const imgId = `media-${index}-${url.split("/").pop()?.split("?")[0]?.substring(0, 20) || Date.now().toString(36)}`;
|
|
4860
|
+
const id = `${treeId}-${this.id}-${imgId}`;
|
|
4861
|
+
list[id] = {
|
|
4862
|
+
isPrimary,
|
|
4863
|
+
key,
|
|
4864
|
+
id,
|
|
4865
|
+
tree: treeId,
|
|
4866
|
+
imgId,
|
|
4867
|
+
person: this.id,
|
|
4868
|
+
title,
|
|
4869
|
+
url,
|
|
4870
|
+
contentType: type,
|
|
4871
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
4872
|
+
};
|
|
4873
|
+
}
|
|
4874
|
+
});
|
|
4875
|
+
return list;
|
|
4876
|
+
}
|
|
4560
4877
|
async multimedia(namespace) {
|
|
4561
4878
|
if (this?.isAncestry()) {
|
|
4562
4879
|
return await this.ancestryMedia(namespace);
|
|
@@ -4564,11 +4881,30 @@ var Indi = class extends Common {
|
|
|
4564
4881
|
if (this?.isMyHeritage()) {
|
|
4565
4882
|
return this.myheritageMedia();
|
|
4566
4883
|
}
|
|
4567
|
-
|
|
4884
|
+
if (this?.isGeni()) {
|
|
4885
|
+
return this.geniMedia();
|
|
4886
|
+
}
|
|
4887
|
+
return this.universalMedia();
|
|
4568
4888
|
}
|
|
4569
4889
|
async getProfilePicture(namespace, onlyPrimary = true) {
|
|
4890
|
+
if (!this.id) {
|
|
4891
|
+
return void 0;
|
|
4892
|
+
}
|
|
4893
|
+
const cacheKey = this.id;
|
|
4894
|
+
const cached = profilePictureCache(
|
|
4895
|
+
this._gedcom,
|
|
4896
|
+
cacheKey
|
|
4897
|
+
);
|
|
4898
|
+
if (cached !== void 0) {
|
|
4899
|
+
return cached;
|
|
4900
|
+
}
|
|
4570
4901
|
const mediaList = await this.multimedia(namespace);
|
|
4571
4902
|
if (!mediaList) {
|
|
4903
|
+
profilePictureCache(
|
|
4904
|
+
this._gedcom,
|
|
4905
|
+
cacheKey,
|
|
4906
|
+
void 0
|
|
4907
|
+
);
|
|
4572
4908
|
return void 0;
|
|
4573
4909
|
}
|
|
4574
4910
|
const mediaArray = Object.values(mediaList);
|
|
@@ -4576,27 +4912,41 @@ var Indi = class extends Common {
|
|
|
4576
4912
|
(media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
|
|
4577
4913
|
);
|
|
4578
4914
|
if (primaryMedia) {
|
|
4579
|
-
|
|
4915
|
+
const result = {
|
|
4580
4916
|
file: primaryMedia.url,
|
|
4581
4917
|
form: primaryMedia.contentType,
|
|
4582
4918
|
title: primaryMedia.title,
|
|
4583
4919
|
isPrimary: true
|
|
4584
4920
|
};
|
|
4585
|
-
|
|
4586
|
-
|
|
4921
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
4922
|
+
return result;
|
|
4923
|
+
}
|
|
4924
|
+
if (onlyPrimary) {
|
|
4925
|
+
profilePictureCache(
|
|
4926
|
+
this._gedcom,
|
|
4927
|
+
cacheKey,
|
|
4928
|
+
void 0
|
|
4929
|
+
);
|
|
4587
4930
|
return void 0;
|
|
4588
4931
|
}
|
|
4589
4932
|
const secondaryMedia = mediaArray.find(
|
|
4590
4933
|
(media) => isImageFormat(media.contentType || getFileExtension(media.url))
|
|
4591
4934
|
);
|
|
4592
4935
|
if (secondaryMedia) {
|
|
4593
|
-
|
|
4936
|
+
const result = {
|
|
4594
4937
|
file: secondaryMedia.url,
|
|
4595
4938
|
form: secondaryMedia.contentType,
|
|
4596
4939
|
title: secondaryMedia.title,
|
|
4597
4940
|
isPrimary: false
|
|
4598
4941
|
};
|
|
4942
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
4943
|
+
return result;
|
|
4599
4944
|
}
|
|
4945
|
+
profilePictureCache(
|
|
4946
|
+
this._gedcom,
|
|
4947
|
+
cacheKey,
|
|
4948
|
+
void 0
|
|
4949
|
+
);
|
|
4600
4950
|
return void 0;
|
|
4601
4951
|
}
|
|
4602
4952
|
link(poolId) {
|
|
@@ -4964,7 +5314,7 @@ var Indi = class extends Common {
|
|
|
4964
5314
|
return;
|
|
4965
5315
|
}
|
|
4966
5316
|
const cacheKey = `${this.id}|${usedIndi.id}`;
|
|
4967
|
-
const cache = pathCache(cacheKey);
|
|
5317
|
+
const cache = pathCache(this._gedcom, cacheKey);
|
|
4968
5318
|
if (cache) {
|
|
4969
5319
|
return cache;
|
|
4970
5320
|
}
|
|
@@ -5009,7 +5359,7 @@ var Indi = class extends Common {
|
|
|
5009
5359
|
if (breakOnNext) {
|
|
5010
5360
|
return void 0;
|
|
5011
5361
|
}
|
|
5012
|
-
pathCache(cacheKey, path2);
|
|
5362
|
+
pathCache(this._gedcom, cacheKey, path2);
|
|
5013
5363
|
return path2;
|
|
5014
5364
|
}
|
|
5015
5365
|
visited.append(indi);
|
|
@@ -5179,7 +5529,7 @@ var Indi = class extends Common {
|
|
|
5179
5529
|
}
|
|
5180
5530
|
getRelativesOnDegree(degree = 0) {
|
|
5181
5531
|
this.id = this.id || `@I${Math.random()}@`;
|
|
5182
|
-
const cache = relativesOnDegreeCache(this.id, degree);
|
|
5532
|
+
const cache = relativesOnDegreeCache(this._gedcom, this.id, degree);
|
|
5183
5533
|
if (cache) {
|
|
5184
5534
|
return cache;
|
|
5185
5535
|
}
|
|
@@ -5187,6 +5537,7 @@ var Indi = class extends Common {
|
|
|
5187
5537
|
const excludes = persons;
|
|
5188
5538
|
if (!Math.abs(degree)) {
|
|
5189
5539
|
return relativesOnDegreeCache(
|
|
5540
|
+
this._gedcom,
|
|
5190
5541
|
this.id,
|
|
5191
5542
|
degree,
|
|
5192
5543
|
persons.except(this)
|
|
@@ -5197,11 +5548,11 @@ var Indi = class extends Common {
|
|
|
5197
5548
|
excludes.merge(persons);
|
|
5198
5549
|
persons = this.getRelativesOnLevel(validDegree).getRelativesOnDegree(-validDegree).copy().exclude(excludes);
|
|
5199
5550
|
}
|
|
5200
|
-
return relativesOnDegreeCache(this.id, degree, persons);
|
|
5551
|
+
return relativesOnDegreeCache(this._gedcom, this.id, degree, persons);
|
|
5201
5552
|
}
|
|
5202
5553
|
getRelativesOnLevel(level = 0, filter) {
|
|
5203
5554
|
this.id = this.id || `@I${Math.random()}@`;
|
|
5204
|
-
const cache = relativesOnLevelCache(this.id, level);
|
|
5555
|
+
const cache = relativesOnLevelCache(this._gedcom, this.id, level);
|
|
5205
5556
|
if (cache) {
|
|
5206
5557
|
return cache;
|
|
5207
5558
|
}
|
|
@@ -5212,7 +5563,7 @@ var Indi = class extends Common {
|
|
|
5212
5563
|
};
|
|
5213
5564
|
let families = this.get(config.key)?.toValueList();
|
|
5214
5565
|
if (!families) {
|
|
5215
|
-
return relativesOnLevelCache(this.id, level, persons);
|
|
5566
|
+
return relativesOnLevelCache(this._gedcom, this.id, level, persons);
|
|
5216
5567
|
}
|
|
5217
5568
|
if (filter) {
|
|
5218
5569
|
families = families.filter(filter);
|
|
@@ -5223,7 +5574,12 @@ var Indi = class extends Common {
|
|
|
5223
5574
|
persons = this.toFamilies(families).getParents();
|
|
5224
5575
|
}
|
|
5225
5576
|
if (level >= -1 && level <= 1) {
|
|
5226
|
-
return relativesOnLevelCache(
|
|
5577
|
+
return relativesOnLevelCache(
|
|
5578
|
+
this._gedcom,
|
|
5579
|
+
this.id,
|
|
5580
|
+
level,
|
|
5581
|
+
persons.except(this)
|
|
5582
|
+
);
|
|
5227
5583
|
}
|
|
5228
5584
|
for (let i = 1; i < Math.abs(level); i++) {
|
|
5229
5585
|
if (config.isAscendant) {
|
|
@@ -5232,7 +5588,12 @@ var Indi = class extends Common {
|
|
|
5232
5588
|
persons = persons.getParents();
|
|
5233
5589
|
}
|
|
5234
5590
|
}
|
|
5235
|
-
return relativesOnLevelCache(
|
|
5591
|
+
return relativesOnLevelCache(
|
|
5592
|
+
this._gedcom,
|
|
5593
|
+
this.id,
|
|
5594
|
+
level,
|
|
5595
|
+
persons.except(this)
|
|
5596
|
+
);
|
|
5236
5597
|
}
|
|
5237
5598
|
getAscendants(level = 0, filter) {
|
|
5238
5599
|
if (!level) {
|
|
@@ -5271,7 +5632,12 @@ var Indi = class extends Common {
|
|
|
5271
5632
|
}
|
|
5272
5633
|
currentGen++;
|
|
5273
5634
|
generations[currentGen] = descentants;
|
|
5274
|
-
relativesOnLevelCache(
|
|
5635
|
+
relativesOnLevelCache(
|
|
5636
|
+
this._gedcom,
|
|
5637
|
+
this.id,
|
|
5638
|
+
-currentGen,
|
|
5639
|
+
descentants
|
|
5640
|
+
);
|
|
5275
5641
|
descentants && relatives.merge(descentants);
|
|
5276
5642
|
}
|
|
5277
5643
|
return { relatives, generations };
|
|
@@ -5304,7 +5670,7 @@ var Indi = class extends Common {
|
|
|
5304
5670
|
}
|
|
5305
5671
|
currentGen++;
|
|
5306
5672
|
generations[currentGen] = parents;
|
|
5307
|
-
relativesOnLevelCache(this.id, currentGen, parents);
|
|
5673
|
+
relativesOnLevelCache(this._gedcom, this.id, currentGen, parents);
|
|
5308
5674
|
parents && relatives.merge(parents);
|
|
5309
5675
|
}
|
|
5310
5676
|
return { relatives, generations };
|
|
@@ -5888,7 +6254,7 @@ var createIndi = (gedcom, id, main, parent) => {
|
|
|
5888
6254
|
|
|
5889
6255
|
// package.json
|
|
5890
6256
|
var package_default = {
|
|
5891
|
-
version: "
|
|
6257
|
+
version: "2.0.0"};
|
|
5892
6258
|
|
|
5893
6259
|
// src/utils/get-product-details.ts
|
|
5894
6260
|
var getVersion = () => package_default.version;
|