@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
|
@@ -2301,11 +2301,30 @@ var Common = class _Common {
|
|
|
2301
2301
|
const sour = get(head, "SOUR.value");
|
|
2302
2302
|
return !!sour?.toLowerCase()?.startsWith("myheritage");
|
|
2303
2303
|
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Get the source type as a string (for prefixing tree IDs and names)
|
|
2306
|
+
* Returns the detected source type or undefined if unknown
|
|
2307
|
+
*/
|
|
2308
|
+
getSourceType() {
|
|
2309
|
+
if (this.isAncestry()) return "Ancestry";
|
|
2310
|
+
if (this.isMyHeritage()) return "MyHeritage";
|
|
2311
|
+
if (this.isFamilySearch()) return "FamilySearch";
|
|
2312
|
+
if (this.isGNO2GED()) return "GNO2GED";
|
|
2313
|
+
if (this.isGenoPro()) return "GenoPro";
|
|
2314
|
+
if (this.isAhnenblatt()) return "Ahnenblatt";
|
|
2315
|
+
if (this.isGeni()) return "Geni";
|
|
2316
|
+
return void 0;
|
|
2317
|
+
}
|
|
2304
2318
|
isFamilySearch() {
|
|
2305
2319
|
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
2306
2320
|
const sourName = get(head, "SOUR.NAME.value");
|
|
2307
2321
|
return sourName === "FamilySearch API";
|
|
2308
2322
|
}
|
|
2323
|
+
isGNO2GED() {
|
|
2324
|
+
const head = get(this, "HEAD") || get(this.getGedcom(), "HEAD");
|
|
2325
|
+
const sour = get(head, "SOUR.value");
|
|
2326
|
+
return sour === "GNO2GED";
|
|
2327
|
+
}
|
|
2309
2328
|
getAncestryTreeId() {
|
|
2310
2329
|
const path = "HEAD.SOUR._TREE.RIN.value";
|
|
2311
2330
|
return get(this, path) || get(this.getGedcom(), path);
|
|
@@ -2316,11 +2335,34 @@ var Common = class _Common {
|
|
|
2316
2335
|
}
|
|
2317
2336
|
getTreeId() {
|
|
2318
2337
|
if (this?.isAncestry()) {
|
|
2319
|
-
|
|
2338
|
+
const id = this.getAncestryTreeId();
|
|
2339
|
+
if (id !== void 0) return id;
|
|
2320
2340
|
}
|
|
2321
2341
|
if (this?.isMyHeritage()) {
|
|
2322
|
-
|
|
2342
|
+
const id = this.getMyHeritageTreeId();
|
|
2343
|
+
if (id !== void 0) return id;
|
|
2344
|
+
}
|
|
2345
|
+
if (this?.isFamilySearch()) {
|
|
2346
|
+
const id = this.getFamilySearchTreeId();
|
|
2347
|
+
if (id !== void 0) return id;
|
|
2323
2348
|
}
|
|
2349
|
+
if (this?.isGNO2GED()) {
|
|
2350
|
+
const id = this.getGNO2GEDTreeId();
|
|
2351
|
+
if (id !== void 0) return id;
|
|
2352
|
+
}
|
|
2353
|
+
if (this?.isAhnenblatt()) {
|
|
2354
|
+
const id = this.getAhnenblattTreeId();
|
|
2355
|
+
if (id !== void 0) return id;
|
|
2356
|
+
}
|
|
2357
|
+
if (this?.isGeni()) {
|
|
2358
|
+
const id = this.getGeniTreeId();
|
|
2359
|
+
if (id !== void 0) return id;
|
|
2360
|
+
}
|
|
2361
|
+
if (this?.isGenoPro()) {
|
|
2362
|
+
const id = this.getGenoProTreeId();
|
|
2363
|
+
if (id !== void 0) return id;
|
|
2364
|
+
}
|
|
2365
|
+
return this.getUniversalTreeId();
|
|
2324
2366
|
}
|
|
2325
2367
|
getAncestryTreeName() {
|
|
2326
2368
|
const path = "HEAD.SOUR._TREE.value";
|
|
@@ -2333,13 +2375,146 @@ var Common = class _Common {
|
|
|
2333
2375
|
/Exported by MyHeritage.com from (?<tree>.+) in.+$/
|
|
2334
2376
|
)?.groups?.tree;
|
|
2335
2377
|
}
|
|
2378
|
+
getFamilySearchTreeId() {
|
|
2379
|
+
const rin = get(this, "HEAD.SOUR._TREE.RIN.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.RIN.value");
|
|
2380
|
+
if (rin) {
|
|
2381
|
+
return rin;
|
|
2382
|
+
}
|
|
2383
|
+
return "familysearch";
|
|
2384
|
+
}
|
|
2385
|
+
getFamilySearchTreeName() {
|
|
2386
|
+
const treeName = get(this, "HEAD.SOUR._TREE.value") || get(this.getGedcom(), "HEAD.SOUR._TREE.value");
|
|
2387
|
+
if (treeName) {
|
|
2388
|
+
return treeName;
|
|
2389
|
+
}
|
|
2390
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2391
|
+
return fileName || "FamilySearch Import";
|
|
2392
|
+
}
|
|
2393
|
+
getAhnenblattTreeId() {
|
|
2394
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2395
|
+
if (fileName) {
|
|
2396
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
2397
|
+
if (idMatch) {
|
|
2398
|
+
return idMatch[1];
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
return void 0;
|
|
2402
|
+
}
|
|
2403
|
+
getAhnenblattTreeName() {
|
|
2404
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2405
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
2406
|
+
}
|
|
2407
|
+
getGeniTreeId() {
|
|
2408
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2409
|
+
if (fileName) {
|
|
2410
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
2411
|
+
if (idMatch) {
|
|
2412
|
+
return idMatch[1];
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
return void 0;
|
|
2416
|
+
}
|
|
2417
|
+
getGeniTreeName() {
|
|
2418
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2419
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
2420
|
+
}
|
|
2421
|
+
getGenoProTreeId() {
|
|
2422
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2423
|
+
if (fileName) {
|
|
2424
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
2425
|
+
if (idMatch) {
|
|
2426
|
+
return idMatch[1];
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
return void 0;
|
|
2430
|
+
}
|
|
2431
|
+
getGenoProTreeName() {
|
|
2432
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2433
|
+
return fileName?.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
2434
|
+
}
|
|
2435
|
+
getGNO2GEDTreeId() {
|
|
2436
|
+
const rin = get(this, "HEAD._TREE.RIN.value") || get(this.getGedcom(), "HEAD._TREE.RIN.value");
|
|
2437
|
+
if (rin) {
|
|
2438
|
+
return rin;
|
|
2439
|
+
}
|
|
2440
|
+
return `gno_${this._gedcom?.refcount || "unknown"}`;
|
|
2441
|
+
}
|
|
2442
|
+
getGNO2GEDTreeName() {
|
|
2443
|
+
const treeName = get(this, "HEAD._TREE.value") || get(this.getGedcom(), "HEAD._TREE.value");
|
|
2444
|
+
if (treeName) {
|
|
2445
|
+
return treeName;
|
|
2446
|
+
}
|
|
2447
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2448
|
+
return fileName || "GNO2GED Export";
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Universal tree ID getter for unknown/unrecognized GEDCOM sources
|
|
2452
|
+
* Tries to extract an ID from various common locations
|
|
2453
|
+
*/
|
|
2454
|
+
getUniversalTreeId() {
|
|
2455
|
+
const sourceType = this.getSourceType();
|
|
2456
|
+
const prefix = sourceType ? sourceType.toLowerCase() : "tree";
|
|
2457
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2458
|
+
if (fileName) {
|
|
2459
|
+
const idMatch = fileName.match(/_(\d+)/);
|
|
2460
|
+
if (idMatch) {
|
|
2461
|
+
return `${prefix}_${idMatch[1]}`;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
return `${prefix}_${this._gedcom?.refcount || "unknown"}`;
|
|
2465
|
+
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Universal tree name getter for unknown/unrecognized GEDCOM sources
|
|
2468
|
+
* Tries to extract a name from various common locations
|
|
2469
|
+
*/
|
|
2470
|
+
getUniversalTreeName() {
|
|
2471
|
+
const sourceType = this.getSourceType();
|
|
2472
|
+
const prefix = sourceType ? `${sourceType}-` : "";
|
|
2473
|
+
const fileName = get(this, "HEAD.FILE.value") || get(this.getGedcom(), "HEAD.FILE.value");
|
|
2474
|
+
if (fileName) {
|
|
2475
|
+
const cleanName = fileName.replace(/\.ged$/i, "").replace(/_/g, " ");
|
|
2476
|
+
return `${prefix}${cleanName}`;
|
|
2477
|
+
}
|
|
2478
|
+
const sourName = get(this, "HEAD.SOUR.NAME.value") || get(this.getGedcom(), "HEAD.SOUR.NAME.value");
|
|
2479
|
+
if (sourName) {
|
|
2480
|
+
return `${prefix}${sourName}`;
|
|
2481
|
+
}
|
|
2482
|
+
const sourValue = get(this, "HEAD.SOUR.value") || get(this.getGedcom(), "HEAD.SOUR.value");
|
|
2483
|
+
if (sourValue) {
|
|
2484
|
+
return `${prefix}${sourValue}`;
|
|
2485
|
+
}
|
|
2486
|
+
return `${prefix}Unknown Tree`;
|
|
2487
|
+
}
|
|
2336
2488
|
getTreeName() {
|
|
2337
2489
|
if (this?.isAncestry()) {
|
|
2338
|
-
|
|
2490
|
+
const name = this.getAncestryTreeName();
|
|
2491
|
+
if (name) return name;
|
|
2339
2492
|
}
|
|
2340
2493
|
if (this?.isMyHeritage()) {
|
|
2341
|
-
|
|
2494
|
+
const name = this.getMyHeritageTreeName();
|
|
2495
|
+
if (name) return name;
|
|
2496
|
+
}
|
|
2497
|
+
if (this?.isFamilySearch()) {
|
|
2498
|
+
const name = this.getFamilySearchTreeName();
|
|
2499
|
+
if (name) return name;
|
|
2500
|
+
}
|
|
2501
|
+
if (this?.isGNO2GED()) {
|
|
2502
|
+
const name = this.getGNO2GEDTreeName();
|
|
2503
|
+
if (name) return name;
|
|
2504
|
+
}
|
|
2505
|
+
if (this?.isAhnenblatt()) {
|
|
2506
|
+
const name = this.getAhnenblattTreeName();
|
|
2507
|
+
if (name) return name;
|
|
2342
2508
|
}
|
|
2509
|
+
if (this?.isGeni()) {
|
|
2510
|
+
const name = this.getGeniTreeName();
|
|
2511
|
+
if (name) return name;
|
|
2512
|
+
}
|
|
2513
|
+
if (this?.isGenoPro()) {
|
|
2514
|
+
const name = this.getGenoProTreeName();
|
|
2515
|
+
if (name) return name;
|
|
2516
|
+
}
|
|
2517
|
+
return this.getUniversalTreeName();
|
|
2343
2518
|
}
|
|
2344
2519
|
};
|
|
2345
2520
|
var createProxy = (target) => {
|
|
@@ -2754,66 +2929,125 @@ var getMarriageAscAndChildBirth = (person) => (itemA, keyA, itemB, keyB) => {
|
|
|
2754
2929
|
const childB = familyB?.getChildren().orderBy(BIRTH_ASC).index(0);
|
|
2755
2930
|
return getBirthAsc(childA, keyA, childB);
|
|
2756
2931
|
};
|
|
2932
|
+
var getGedcomId = (gedcom) => {
|
|
2933
|
+
if (!gedcom) {
|
|
2934
|
+
return "unknown";
|
|
2935
|
+
}
|
|
2936
|
+
const treeId = gedcom.getTreeId?.() || "";
|
|
2937
|
+
const treeName = gedcom.getTreeName?.() || "";
|
|
2938
|
+
const sanitizedName = treeName.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
2939
|
+
if (treeId && sanitizedName) {
|
|
2940
|
+
return `${treeId}_${sanitizedName}`;
|
|
2941
|
+
} else if (treeId) {
|
|
2942
|
+
return treeId;
|
|
2943
|
+
} else if (sanitizedName) {
|
|
2944
|
+
return sanitizedName;
|
|
2945
|
+
}
|
|
2946
|
+
return `gedcom_${gedcom.refcount}`;
|
|
2947
|
+
};
|
|
2757
2948
|
var caches = {
|
|
2758
2949
|
pathCache: {},
|
|
2759
2950
|
relativesOnDegreeCache: {},
|
|
2760
|
-
relativesOnLevelCache: {}
|
|
2951
|
+
relativesOnLevelCache: {},
|
|
2952
|
+
profilePictureCache: {}
|
|
2761
2953
|
};
|
|
2762
|
-
var
|
|
2763
|
-
var
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2954
|
+
var cacheDbs;
|
|
2955
|
+
var getCacheDbs = () => {
|
|
2956
|
+
if (!cacheDbs) {
|
|
2957
|
+
const getInstance = getCacheManagerFactory();
|
|
2958
|
+
cacheDbs = {
|
|
2959
|
+
pathCache: getInstance(
|
|
2960
|
+
"ftv",
|
|
2961
|
+
"Main",
|
|
2962
|
+
"path",
|
|
2963
|
+
true
|
|
2964
|
+
),
|
|
2965
|
+
relativesOnDegreeCache: getInstance("ftv", "Main", "path", true),
|
|
2966
|
+
relativesOnLevelCache: getInstance(
|
|
2967
|
+
"ftv",
|
|
2968
|
+
"Main",
|
|
2969
|
+
"path",
|
|
2970
|
+
true
|
|
2971
|
+
),
|
|
2972
|
+
profilePictureCache: getInstance(
|
|
2973
|
+
"ftv",
|
|
2974
|
+
"Main",
|
|
2975
|
+
"images",
|
|
2976
|
+
false
|
|
2977
|
+
)
|
|
2978
|
+
};
|
|
2979
|
+
}
|
|
2980
|
+
return cacheDbs;
|
|
2777
2981
|
};
|
|
2778
|
-
|
|
2982
|
+
var storeCache = {
|
|
2983
|
+
// NOTE: pathCache, relativesOnLevelCache, and relativesOnDegreeCache are intentionally
|
|
2984
|
+
// kept in memory only. These debounced functions exist to satisfy the type system
|
|
2985
|
+
// but are never called.
|
|
2779
2986
|
pathCache: debounce((value) => {
|
|
2780
2987
|
if (value) {
|
|
2781
|
-
|
|
2988
|
+
getCacheDbs().pathCache.setItem(value);
|
|
2782
2989
|
}
|
|
2783
2990
|
}, 50),
|
|
2784
2991
|
relativesOnLevelCache: debounce((value) => {
|
|
2785
2992
|
if (value) {
|
|
2786
|
-
|
|
2993
|
+
getCacheDbs().relativesOnLevelCache.setItem(value);
|
|
2787
2994
|
}
|
|
2788
2995
|
}, 50),
|
|
2789
2996
|
relativesOnDegreeCache: debounce((value) => {
|
|
2790
2997
|
if (value) {
|
|
2791
|
-
|
|
2998
|
+
getCacheDbs().relativesOnDegreeCache.setItem(value);
|
|
2792
2999
|
}
|
|
2793
|
-
}, 50)
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
3000
|
+
}, 50),
|
|
3001
|
+
// profilePictureCache IS persisted to IndexedDB
|
|
3002
|
+
profilePictureCache: debounce((value) => {
|
|
3003
|
+
if (value) {
|
|
3004
|
+
getCacheDbs().profilePictureCache.setItem(value);
|
|
3005
|
+
}
|
|
3006
|
+
}, 100)
|
|
3007
|
+
};
|
|
3008
|
+
var relativesCache = (cacheKey) => (gedcom, key, subKey, value) => {
|
|
3009
|
+
const gedcomId = getGedcomId(gedcom);
|
|
3010
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
3011
|
+
const cache = caches[cacheKey];
|
|
3012
|
+
if (!cache) {
|
|
2797
3013
|
caches[cacheKey] = {};
|
|
2798
3014
|
}
|
|
2799
|
-
if (value
|
|
2800
|
-
|
|
2801
|
-
|
|
3015
|
+
if (value) {
|
|
3016
|
+
const typedCache2 = caches[cacheKey];
|
|
3017
|
+
if (!typedCache2[fullKey]) {
|
|
3018
|
+
typedCache2[fullKey] = {};
|
|
2802
3019
|
}
|
|
2803
|
-
|
|
2804
|
-
return
|
|
3020
|
+
typedCache2[fullKey][subKey] = value;
|
|
3021
|
+
return typedCache2[fullKey][subKey];
|
|
2805
3022
|
}
|
|
2806
|
-
|
|
3023
|
+
const typedCache = caches[cacheKey];
|
|
3024
|
+
return typedCache?.[fullKey]?.[subKey];
|
|
2807
3025
|
};
|
|
2808
|
-
var pathCache = (key, value) => {
|
|
3026
|
+
var pathCache = (gedcom, key, value) => {
|
|
3027
|
+
const gedcomId = getGedcomId(gedcom);
|
|
3028
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
2809
3029
|
if (!caches.pathCache) {
|
|
2810
3030
|
caches.pathCache = {};
|
|
2811
3031
|
}
|
|
2812
3032
|
if (value && caches.pathCache) {
|
|
2813
|
-
caches.pathCache[
|
|
2814
|
-
return caches.pathCache[
|
|
3033
|
+
caches.pathCache[fullKey] = value;
|
|
3034
|
+
return caches.pathCache[fullKey];
|
|
2815
3035
|
}
|
|
2816
|
-
return caches.pathCache?.[
|
|
3036
|
+
return caches.pathCache?.[fullKey];
|
|
3037
|
+
};
|
|
3038
|
+
var profilePictureCache = (gedcom, key, value) => {
|
|
3039
|
+
const gedcomId = getGedcomId(gedcom);
|
|
3040
|
+
const fullKey = `${gedcomId}:${key}`;
|
|
3041
|
+
if (!caches.profilePictureCache) {
|
|
3042
|
+
caches.profilePictureCache = {};
|
|
3043
|
+
}
|
|
3044
|
+
if (value && caches.profilePictureCache) {
|
|
3045
|
+
caches.profilePictureCache[fullKey] = value;
|
|
3046
|
+
storeCache.profilePictureCache(caches.profilePictureCache);
|
|
3047
|
+
return caches.profilePictureCache[fullKey];
|
|
3048
|
+
}
|
|
3049
|
+
const cached = caches.profilePictureCache?.[fullKey];
|
|
3050
|
+
return cached;
|
|
2817
3051
|
};
|
|
2818
3052
|
|
|
2819
3053
|
// src/utils/get-places.ts
|
|
@@ -4113,7 +4347,7 @@ var Indi = class extends Common {
|
|
|
4113
4347
|
}
|
|
4114
4348
|
async ancestryMedia(namespace) {
|
|
4115
4349
|
const list = {};
|
|
4116
|
-
const objeList = this.get("OBJE")?.toList();
|
|
4350
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4117
4351
|
const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
|
|
4118
4352
|
const tree = this.getAncestryTreeId();
|
|
4119
4353
|
if (objeList) {
|
|
@@ -4163,7 +4397,7 @@ var Indi = class extends Common {
|
|
|
4163
4397
|
title,
|
|
4164
4398
|
url,
|
|
4165
4399
|
contentType: type,
|
|
4166
|
-
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()
|
|
4400
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
4167
4401
|
};
|
|
4168
4402
|
}
|
|
4169
4403
|
})
|
|
@@ -4187,11 +4421,12 @@ var Indi = class extends Common {
|
|
|
4187
4421
|
if (!tree) {
|
|
4188
4422
|
return;
|
|
4189
4423
|
}
|
|
4190
|
-
const objeList = this.get("OBJE")?.toList();
|
|
4191
|
-
const birthObj = this.get("BIRT.OBJE")?.toList();
|
|
4192
|
-
const deathObj = this.get("DEAT.OBJE")?.toList();
|
|
4424
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4425
|
+
const birthObj = this.get("BIRT.OBJE")?.toList().copy();
|
|
4426
|
+
const deathObj = this.get("DEAT.OBJE")?.toList().copy();
|
|
4427
|
+
objeList?.merge(birthObj).merge(deathObj);
|
|
4193
4428
|
(this.get("FAMS")?.toValueList().values() ?? []).concat(this.get("FAMC")?.toValueList().values() ?? []).forEach((fam) => {
|
|
4194
|
-
objeList?.merge(
|
|
4429
|
+
objeList?.merge(fam?.get("MARR.OBJE"));
|
|
4195
4430
|
});
|
|
4196
4431
|
objeList?.forEach((o, index) => {
|
|
4197
4432
|
if (!o) {
|
|
@@ -4217,7 +4452,7 @@ var Indi = class extends Common {
|
|
|
4217
4452
|
title,
|
|
4218
4453
|
url,
|
|
4219
4454
|
contentType: type,
|
|
4220
|
-
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()
|
|
4455
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
4221
4456
|
};
|
|
4222
4457
|
}
|
|
4223
4458
|
});
|
|
@@ -4309,6 +4544,85 @@ var Indi = class extends Common {
|
|
|
4309
4544
|
};
|
|
4310
4545
|
});
|
|
4311
4546
|
}
|
|
4547
|
+
geniMedia() {
|
|
4548
|
+
const list = {};
|
|
4549
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4550
|
+
const sourList = this.get("SOUR")?.toList().copy();
|
|
4551
|
+
sourList?.forEach((sour) => {
|
|
4552
|
+
const sourObje = sour?.get("OBJE")?.toList();
|
|
4553
|
+
objeList?.merge(sourObje);
|
|
4554
|
+
});
|
|
4555
|
+
const rfn = this.get("RFN")?.toValue();
|
|
4556
|
+
const geniId = rfn?.replace(/^geni:/, "") || "unknown";
|
|
4557
|
+
objeList?.forEach((obje, index) => {
|
|
4558
|
+
if (!obje) {
|
|
4559
|
+
return;
|
|
4560
|
+
}
|
|
4561
|
+
const key = `@O${index}@`;
|
|
4562
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
4563
|
+
const url = obje?.get("FILE")?.toValue();
|
|
4564
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
4565
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
4566
|
+
if (url) {
|
|
4567
|
+
const urlMatch = url.match(/\/([^/]+)\?hash=/);
|
|
4568
|
+
const imgId = urlMatch?.[1] || `img-${index}-${Date.now().toString(36)}`;
|
|
4569
|
+
const id = `geni-${geniId}-${imgId}`;
|
|
4570
|
+
list[id] = {
|
|
4571
|
+
isPrimary,
|
|
4572
|
+
key,
|
|
4573
|
+
id,
|
|
4574
|
+
tree: geniId,
|
|
4575
|
+
imgId,
|
|
4576
|
+
person: this.id,
|
|
4577
|
+
title,
|
|
4578
|
+
url,
|
|
4579
|
+
contentType: type,
|
|
4580
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
4581
|
+
};
|
|
4582
|
+
}
|
|
4583
|
+
});
|
|
4584
|
+
return list;
|
|
4585
|
+
}
|
|
4586
|
+
universalMedia() {
|
|
4587
|
+
const list = {};
|
|
4588
|
+
if (!this.id) {
|
|
4589
|
+
return list;
|
|
4590
|
+
}
|
|
4591
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4592
|
+
if (!objeList || objeList.length === 0) {
|
|
4593
|
+
return list;
|
|
4594
|
+
}
|
|
4595
|
+
const rfn = this.get("RFN")?.toValue();
|
|
4596
|
+
const treeId = this.getUniversalTreeId() || rfn || "universal";
|
|
4597
|
+
objeList.forEach((obje, index) => {
|
|
4598
|
+
if (!obje) {
|
|
4599
|
+
return;
|
|
4600
|
+
}
|
|
4601
|
+
const key = `@O${index}@`;
|
|
4602
|
+
obje.standardizeMedia();
|
|
4603
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
4604
|
+
const url = obje?.get("FILE")?.toValue();
|
|
4605
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
4606
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
4607
|
+
if (url) {
|
|
4608
|
+
const imgId = `media-${index}-${url.split("/").pop()?.split("?")[0]?.substring(0, 20) || Date.now().toString(36)}`;
|
|
4609
|
+
const id = `${treeId}-${this.id}-${imgId}`;
|
|
4610
|
+
list[id] = {
|
|
4611
|
+
isPrimary,
|
|
4612
|
+
key,
|
|
4613
|
+
id,
|
|
4614
|
+
tree: treeId,
|
|
4615
|
+
imgId,
|
|
4616
|
+
person: this.id,
|
|
4617
|
+
title,
|
|
4618
|
+
url,
|
|
4619
|
+
contentType: type,
|
|
4620
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
4621
|
+
};
|
|
4622
|
+
}
|
|
4623
|
+
});
|
|
4624
|
+
return list;
|
|
4625
|
+
}
|
|
4312
4626
|
async multimedia(namespace) {
|
|
4313
4627
|
if (this?.isAncestry()) {
|
|
4314
4628
|
return await this.ancestryMedia(namespace);
|
|
@@ -4316,11 +4630,30 @@ var Indi = class extends Common {
|
|
|
4316
4630
|
if (this?.isMyHeritage()) {
|
|
4317
4631
|
return this.myheritageMedia();
|
|
4318
4632
|
}
|
|
4319
|
-
|
|
4633
|
+
if (this?.isGeni()) {
|
|
4634
|
+
return this.geniMedia();
|
|
4635
|
+
}
|
|
4636
|
+
return this.universalMedia();
|
|
4320
4637
|
}
|
|
4321
4638
|
async getProfilePicture(namespace, onlyPrimary = true) {
|
|
4639
|
+
if (!this.id) {
|
|
4640
|
+
return void 0;
|
|
4641
|
+
}
|
|
4642
|
+
const cacheKey = this.id;
|
|
4643
|
+
const cached = profilePictureCache(
|
|
4644
|
+
this._gedcom,
|
|
4645
|
+
cacheKey
|
|
4646
|
+
);
|
|
4647
|
+
if (cached !== void 0) {
|
|
4648
|
+
return cached;
|
|
4649
|
+
}
|
|
4322
4650
|
const mediaList = await this.multimedia(namespace);
|
|
4323
4651
|
if (!mediaList) {
|
|
4652
|
+
profilePictureCache(
|
|
4653
|
+
this._gedcom,
|
|
4654
|
+
cacheKey,
|
|
4655
|
+
void 0
|
|
4656
|
+
);
|
|
4324
4657
|
return void 0;
|
|
4325
4658
|
}
|
|
4326
4659
|
const mediaArray = Object.values(mediaList);
|
|
@@ -4328,27 +4661,41 @@ var Indi = class extends Common {
|
|
|
4328
4661
|
(media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
|
|
4329
4662
|
);
|
|
4330
4663
|
if (primaryMedia) {
|
|
4331
|
-
|
|
4664
|
+
const result = {
|
|
4332
4665
|
file: primaryMedia.url,
|
|
4333
4666
|
form: primaryMedia.contentType,
|
|
4334
4667
|
title: primaryMedia.title,
|
|
4335
4668
|
isPrimary: true
|
|
4336
4669
|
};
|
|
4337
|
-
|
|
4338
|
-
|
|
4670
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
4671
|
+
return result;
|
|
4672
|
+
}
|
|
4673
|
+
if (onlyPrimary) {
|
|
4674
|
+
profilePictureCache(
|
|
4675
|
+
this._gedcom,
|
|
4676
|
+
cacheKey,
|
|
4677
|
+
void 0
|
|
4678
|
+
);
|
|
4339
4679
|
return void 0;
|
|
4340
4680
|
}
|
|
4341
4681
|
const secondaryMedia = mediaArray.find(
|
|
4342
4682
|
(media) => isImageFormat(media.contentType || getFileExtension(media.url))
|
|
4343
4683
|
);
|
|
4344
4684
|
if (secondaryMedia) {
|
|
4345
|
-
|
|
4685
|
+
const result = {
|
|
4346
4686
|
file: secondaryMedia.url,
|
|
4347
4687
|
form: secondaryMedia.contentType,
|
|
4348
4688
|
title: secondaryMedia.title,
|
|
4349
4689
|
isPrimary: false
|
|
4350
4690
|
};
|
|
4691
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
4692
|
+
return result;
|
|
4351
4693
|
}
|
|
4694
|
+
profilePictureCache(
|
|
4695
|
+
this._gedcom,
|
|
4696
|
+
cacheKey,
|
|
4697
|
+
void 0
|
|
4698
|
+
);
|
|
4352
4699
|
return void 0;
|
|
4353
4700
|
}
|
|
4354
4701
|
link(poolId) {
|
|
@@ -4716,7 +5063,7 @@ var Indi = class extends Common {
|
|
|
4716
5063
|
return;
|
|
4717
5064
|
}
|
|
4718
5065
|
const cacheKey = `${this.id}|${usedIndi.id}`;
|
|
4719
|
-
const cache = pathCache(cacheKey);
|
|
5066
|
+
const cache = pathCache(this._gedcom, cacheKey);
|
|
4720
5067
|
if (cache) {
|
|
4721
5068
|
return cache;
|
|
4722
5069
|
}
|
|
@@ -4761,7 +5108,7 @@ var Indi = class extends Common {
|
|
|
4761
5108
|
if (breakOnNext) {
|
|
4762
5109
|
return void 0;
|
|
4763
5110
|
}
|
|
4764
|
-
pathCache(cacheKey, path2);
|
|
5111
|
+
pathCache(this._gedcom, cacheKey, path2);
|
|
4765
5112
|
return path2;
|
|
4766
5113
|
}
|
|
4767
5114
|
visited.append(indi);
|
|
@@ -4931,7 +5278,7 @@ var Indi = class extends Common {
|
|
|
4931
5278
|
}
|
|
4932
5279
|
getRelativesOnDegree(degree = 0) {
|
|
4933
5280
|
this.id = this.id || `@I${Math.random()}@`;
|
|
4934
|
-
const cache = relativesOnDegreeCache(this.id, degree);
|
|
5281
|
+
const cache = relativesOnDegreeCache(this._gedcom, this.id, degree);
|
|
4935
5282
|
if (cache) {
|
|
4936
5283
|
return cache;
|
|
4937
5284
|
}
|
|
@@ -4939,6 +5286,7 @@ var Indi = class extends Common {
|
|
|
4939
5286
|
const excludes = persons;
|
|
4940
5287
|
if (!Math.abs(degree)) {
|
|
4941
5288
|
return relativesOnDegreeCache(
|
|
5289
|
+
this._gedcom,
|
|
4942
5290
|
this.id,
|
|
4943
5291
|
degree,
|
|
4944
5292
|
persons.except(this)
|
|
@@ -4949,11 +5297,11 @@ var Indi = class extends Common {
|
|
|
4949
5297
|
excludes.merge(persons);
|
|
4950
5298
|
persons = this.getRelativesOnLevel(validDegree).getRelativesOnDegree(-validDegree).copy().exclude(excludes);
|
|
4951
5299
|
}
|
|
4952
|
-
return relativesOnDegreeCache(this.id, degree, persons);
|
|
5300
|
+
return relativesOnDegreeCache(this._gedcom, this.id, degree, persons);
|
|
4953
5301
|
}
|
|
4954
5302
|
getRelativesOnLevel(level = 0, filter) {
|
|
4955
5303
|
this.id = this.id || `@I${Math.random()}@`;
|
|
4956
|
-
const cache = relativesOnLevelCache(this.id, level);
|
|
5304
|
+
const cache = relativesOnLevelCache(this._gedcom, this.id, level);
|
|
4957
5305
|
if (cache) {
|
|
4958
5306
|
return cache;
|
|
4959
5307
|
}
|
|
@@ -4964,7 +5312,7 @@ var Indi = class extends Common {
|
|
|
4964
5312
|
};
|
|
4965
5313
|
let families = this.get(config.key)?.toValueList();
|
|
4966
5314
|
if (!families) {
|
|
4967
|
-
return relativesOnLevelCache(this.id, level, persons);
|
|
5315
|
+
return relativesOnLevelCache(this._gedcom, this.id, level, persons);
|
|
4968
5316
|
}
|
|
4969
5317
|
if (filter) {
|
|
4970
5318
|
families = families.filter(filter);
|
|
@@ -4975,7 +5323,12 @@ var Indi = class extends Common {
|
|
|
4975
5323
|
persons = this.toFamilies(families).getParents();
|
|
4976
5324
|
}
|
|
4977
5325
|
if (level >= -1 && level <= 1) {
|
|
4978
|
-
return relativesOnLevelCache(
|
|
5326
|
+
return relativesOnLevelCache(
|
|
5327
|
+
this._gedcom,
|
|
5328
|
+
this.id,
|
|
5329
|
+
level,
|
|
5330
|
+
persons.except(this)
|
|
5331
|
+
);
|
|
4979
5332
|
}
|
|
4980
5333
|
for (let i = 1; i < Math.abs(level); i++) {
|
|
4981
5334
|
if (config.isAscendant) {
|
|
@@ -4984,7 +5337,12 @@ var Indi = class extends Common {
|
|
|
4984
5337
|
persons = persons.getParents();
|
|
4985
5338
|
}
|
|
4986
5339
|
}
|
|
4987
|
-
return relativesOnLevelCache(
|
|
5340
|
+
return relativesOnLevelCache(
|
|
5341
|
+
this._gedcom,
|
|
5342
|
+
this.id,
|
|
5343
|
+
level,
|
|
5344
|
+
persons.except(this)
|
|
5345
|
+
);
|
|
4988
5346
|
}
|
|
4989
5347
|
getAscendants(level = 0, filter) {
|
|
4990
5348
|
if (!level) {
|
|
@@ -5023,7 +5381,12 @@ var Indi = class extends Common {
|
|
|
5023
5381
|
}
|
|
5024
5382
|
currentGen++;
|
|
5025
5383
|
generations[currentGen] = descentants;
|
|
5026
|
-
relativesOnLevelCache(
|
|
5384
|
+
relativesOnLevelCache(
|
|
5385
|
+
this._gedcom,
|
|
5386
|
+
this.id,
|
|
5387
|
+
-currentGen,
|
|
5388
|
+
descentants
|
|
5389
|
+
);
|
|
5027
5390
|
descentants && relatives.merge(descentants);
|
|
5028
5391
|
}
|
|
5029
5392
|
return { relatives, generations };
|
|
@@ -5056,7 +5419,7 @@ var Indi = class extends Common {
|
|
|
5056
5419
|
}
|
|
5057
5420
|
currentGen++;
|
|
5058
5421
|
generations[currentGen] = parents;
|
|
5059
|
-
relativesOnLevelCache(this.id, currentGen, parents);
|
|
5422
|
+
relativesOnLevelCache(this._gedcom, this.id, currentGen, parents);
|
|
5060
5423
|
parents && relatives.merge(parents);
|
|
5061
5424
|
}
|
|
5062
5425
|
return { relatives, generations };
|