@treeviz/gedcom-parser 1.0.22 → 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 +427 -58
- package/dist/cli/index.js +1615 -384
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +426 -57
- package/dist/factories/index.d.ts +2 -2
- package/dist/factories/index.js +426 -57
- package/dist/{index-BPEVN_DY.d.ts → index-CzYZg44D.d.ts} +32 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +464 -62
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/kinship-translator/index.d.ts +2 -2
- package/dist/kinship-translator/index.js +426 -57
- package/dist/place-parser-CJ3EbFmb.d.ts +40 -0
- package/dist/{place-translator-CRiaOO9v.d.ts → place-translator-Ci5rEY6p.d.ts} +4 -2
- 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 +462 -60
- package/package.json +1 -1
- package/dist/place-parser-CM0TJFj8.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
|
-
async getProfilePicture(namespace) {
|
|
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,24 +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
|
};
|
|
4921
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
4922
|
+
return result;
|
|
4923
|
+
}
|
|
4924
|
+
if (onlyPrimary) {
|
|
4925
|
+
profilePictureCache(
|
|
4926
|
+
this._gedcom,
|
|
4927
|
+
cacheKey,
|
|
4928
|
+
void 0
|
|
4929
|
+
);
|
|
4930
|
+
return void 0;
|
|
4585
4931
|
}
|
|
4586
4932
|
const secondaryMedia = mediaArray.find(
|
|
4587
4933
|
(media) => isImageFormat(media.contentType || getFileExtension(media.url))
|
|
4588
4934
|
);
|
|
4589
4935
|
if (secondaryMedia) {
|
|
4590
|
-
|
|
4936
|
+
const result = {
|
|
4591
4937
|
file: secondaryMedia.url,
|
|
4592
4938
|
form: secondaryMedia.contentType,
|
|
4593
4939
|
title: secondaryMedia.title,
|
|
4594
4940
|
isPrimary: false
|
|
4595
4941
|
};
|
|
4942
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
4943
|
+
return result;
|
|
4596
4944
|
}
|
|
4945
|
+
profilePictureCache(
|
|
4946
|
+
this._gedcom,
|
|
4947
|
+
cacheKey,
|
|
4948
|
+
void 0
|
|
4949
|
+
);
|
|
4597
4950
|
return void 0;
|
|
4598
4951
|
}
|
|
4599
4952
|
link(poolId) {
|
|
@@ -4961,7 +5314,7 @@ var Indi = class extends Common {
|
|
|
4961
5314
|
return;
|
|
4962
5315
|
}
|
|
4963
5316
|
const cacheKey = `${this.id}|${usedIndi.id}`;
|
|
4964
|
-
const cache = pathCache(cacheKey);
|
|
5317
|
+
const cache = pathCache(this._gedcom, cacheKey);
|
|
4965
5318
|
if (cache) {
|
|
4966
5319
|
return cache;
|
|
4967
5320
|
}
|
|
@@ -5006,7 +5359,7 @@ var Indi = class extends Common {
|
|
|
5006
5359
|
if (breakOnNext) {
|
|
5007
5360
|
return void 0;
|
|
5008
5361
|
}
|
|
5009
|
-
pathCache(cacheKey, path2);
|
|
5362
|
+
pathCache(this._gedcom, cacheKey, path2);
|
|
5010
5363
|
return path2;
|
|
5011
5364
|
}
|
|
5012
5365
|
visited.append(indi);
|
|
@@ -5176,7 +5529,7 @@ var Indi = class extends Common {
|
|
|
5176
5529
|
}
|
|
5177
5530
|
getRelativesOnDegree(degree = 0) {
|
|
5178
5531
|
this.id = this.id || `@I${Math.random()}@`;
|
|
5179
|
-
const cache = relativesOnDegreeCache(this.id, degree);
|
|
5532
|
+
const cache = relativesOnDegreeCache(this._gedcom, this.id, degree);
|
|
5180
5533
|
if (cache) {
|
|
5181
5534
|
return cache;
|
|
5182
5535
|
}
|
|
@@ -5184,6 +5537,7 @@ var Indi = class extends Common {
|
|
|
5184
5537
|
const excludes = persons;
|
|
5185
5538
|
if (!Math.abs(degree)) {
|
|
5186
5539
|
return relativesOnDegreeCache(
|
|
5540
|
+
this._gedcom,
|
|
5187
5541
|
this.id,
|
|
5188
5542
|
degree,
|
|
5189
5543
|
persons.except(this)
|
|
@@ -5194,11 +5548,11 @@ var Indi = class extends Common {
|
|
|
5194
5548
|
excludes.merge(persons);
|
|
5195
5549
|
persons = this.getRelativesOnLevel(validDegree).getRelativesOnDegree(-validDegree).copy().exclude(excludes);
|
|
5196
5550
|
}
|
|
5197
|
-
return relativesOnDegreeCache(this.id, degree, persons);
|
|
5551
|
+
return relativesOnDegreeCache(this._gedcom, this.id, degree, persons);
|
|
5198
5552
|
}
|
|
5199
5553
|
getRelativesOnLevel(level = 0, filter) {
|
|
5200
5554
|
this.id = this.id || `@I${Math.random()}@`;
|
|
5201
|
-
const cache = relativesOnLevelCache(this.id, level);
|
|
5555
|
+
const cache = relativesOnLevelCache(this._gedcom, this.id, level);
|
|
5202
5556
|
if (cache) {
|
|
5203
5557
|
return cache;
|
|
5204
5558
|
}
|
|
@@ -5209,7 +5563,7 @@ var Indi = class extends Common {
|
|
|
5209
5563
|
};
|
|
5210
5564
|
let families = this.get(config.key)?.toValueList();
|
|
5211
5565
|
if (!families) {
|
|
5212
|
-
return relativesOnLevelCache(this.id, level, persons);
|
|
5566
|
+
return relativesOnLevelCache(this._gedcom, this.id, level, persons);
|
|
5213
5567
|
}
|
|
5214
5568
|
if (filter) {
|
|
5215
5569
|
families = families.filter(filter);
|
|
@@ -5220,7 +5574,12 @@ var Indi = class extends Common {
|
|
|
5220
5574
|
persons = this.toFamilies(families).getParents();
|
|
5221
5575
|
}
|
|
5222
5576
|
if (level >= -1 && level <= 1) {
|
|
5223
|
-
return relativesOnLevelCache(
|
|
5577
|
+
return relativesOnLevelCache(
|
|
5578
|
+
this._gedcom,
|
|
5579
|
+
this.id,
|
|
5580
|
+
level,
|
|
5581
|
+
persons.except(this)
|
|
5582
|
+
);
|
|
5224
5583
|
}
|
|
5225
5584
|
for (let i = 1; i < Math.abs(level); i++) {
|
|
5226
5585
|
if (config.isAscendant) {
|
|
@@ -5229,7 +5588,12 @@ var Indi = class extends Common {
|
|
|
5229
5588
|
persons = persons.getParents();
|
|
5230
5589
|
}
|
|
5231
5590
|
}
|
|
5232
|
-
return relativesOnLevelCache(
|
|
5591
|
+
return relativesOnLevelCache(
|
|
5592
|
+
this._gedcom,
|
|
5593
|
+
this.id,
|
|
5594
|
+
level,
|
|
5595
|
+
persons.except(this)
|
|
5596
|
+
);
|
|
5233
5597
|
}
|
|
5234
5598
|
getAscendants(level = 0, filter) {
|
|
5235
5599
|
if (!level) {
|
|
@@ -5268,7 +5632,12 @@ var Indi = class extends Common {
|
|
|
5268
5632
|
}
|
|
5269
5633
|
currentGen++;
|
|
5270
5634
|
generations[currentGen] = descentants;
|
|
5271
|
-
relativesOnLevelCache(
|
|
5635
|
+
relativesOnLevelCache(
|
|
5636
|
+
this._gedcom,
|
|
5637
|
+
this.id,
|
|
5638
|
+
-currentGen,
|
|
5639
|
+
descentants
|
|
5640
|
+
);
|
|
5272
5641
|
descentants && relatives.merge(descentants);
|
|
5273
5642
|
}
|
|
5274
5643
|
return { relatives, generations };
|
|
@@ -5301,7 +5670,7 @@ var Indi = class extends Common {
|
|
|
5301
5670
|
}
|
|
5302
5671
|
currentGen++;
|
|
5303
5672
|
generations[currentGen] = parents;
|
|
5304
|
-
relativesOnLevelCache(this.id, currentGen, parents);
|
|
5673
|
+
relativesOnLevelCache(this._gedcom, this.id, currentGen, parents);
|
|
5305
5674
|
parents && relatives.merge(parents);
|
|
5306
5675
|
}
|
|
5307
5676
|
return { relatives, generations };
|
|
@@ -5885,7 +6254,7 @@ var createIndi = (gedcom, id, main, parent) => {
|
|
|
5885
6254
|
|
|
5886
6255
|
// package.json
|
|
5887
6256
|
var package_default = {
|
|
5888
|
-
version: "
|
|
6257
|
+
version: "2.0.0"};
|
|
5889
6258
|
|
|
5890
6259
|
// src/utils/get-product-details.ts
|
|
5891
6260
|
var getVersion = () => package_default.version;
|