@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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { r as GeneratedIndiMethods, A as ICommon, J as IFam, K as IFamilies, M as IGedCom, O as IIndi, S as IIndividuals, V as IList, _ as IObje, a0 as IRepo, a2 as ISour, a6 as ISubm } from '../index-CzYZg44D.js';
|
|
2
2
|
import 'date-fns';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as Cases,
|
|
1
|
+
import { ah as IKinshipTranslator, aB as Path, aC as PathItem, af as IndiType, ac as IndiKey, ai as Language } from '../index-CzYZg44D.js';
|
|
2
|
+
export { C as Cases, f as CrossCase, g as CrossCases } from '../index-CzYZg44D.js';
|
|
3
3
|
import 'date-fns';
|
|
4
4
|
|
|
5
5
|
declare class KinshipTranslatorBasic implements IKinshipTranslator {
|
|
@@ -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) {
|
|
@@ -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
|
|
4429
|
+
objeList.merge(fam?.get("MARR.OBJE"));
|
|
4195
4430
|
});
|
|
4196
4431
|
objeList?.forEach((o, index) => {
|
|
4197
4432
|
if (!o) {
|
|
@@ -4309,6 +4544,88 @@ 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
|
+
if (!objeList || objeList.length === 0) {
|
|
4556
|
+
return void 0;
|
|
4557
|
+
}
|
|
4558
|
+
const rfn = this.get("RFN")?.toValue();
|
|
4559
|
+
const geniId = rfn?.replace(/^geni:/, "") || "unknown";
|
|
4560
|
+
objeList.forEach((obje, index) => {
|
|
4561
|
+
if (!obje) {
|
|
4562
|
+
return;
|
|
4563
|
+
}
|
|
4564
|
+
const key = `@O${index}@`;
|
|
4565
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
4566
|
+
const url = obje?.get("FILE")?.toValue();
|
|
4567
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
4568
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
4569
|
+
if (url) {
|
|
4570
|
+
const urlMatch = url.match(/\/([^/]+)\?hash=/);
|
|
4571
|
+
const imgId = urlMatch?.[1] || `img-${index}-${Date.now().toString(36)}`;
|
|
4572
|
+
const id = `geni-${geniId}-${imgId}`;
|
|
4573
|
+
list[id] = {
|
|
4574
|
+
isPrimary,
|
|
4575
|
+
key,
|
|
4576
|
+
id,
|
|
4577
|
+
tree: geniId,
|
|
4578
|
+
imgId,
|
|
4579
|
+
person: this.id,
|
|
4580
|
+
title,
|
|
4581
|
+
url,
|
|
4582
|
+
contentType: type,
|
|
4583
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
4584
|
+
};
|
|
4585
|
+
}
|
|
4586
|
+
});
|
|
4587
|
+
return list;
|
|
4588
|
+
}
|
|
4589
|
+
universalMedia() {
|
|
4590
|
+
const list = {};
|
|
4591
|
+
if (!this.id) {
|
|
4592
|
+
return list;
|
|
4593
|
+
}
|
|
4594
|
+
const objeList = this.get("OBJE")?.toList().copy();
|
|
4595
|
+
if (!objeList || objeList.length === 0) {
|
|
4596
|
+
return list;
|
|
4597
|
+
}
|
|
4598
|
+
const rfn = this.get("RFN")?.toValue();
|
|
4599
|
+
const treeId = rfn || "universal";
|
|
4600
|
+
objeList.forEach((obje, index) => {
|
|
4601
|
+
if (!obje) {
|
|
4602
|
+
return;
|
|
4603
|
+
}
|
|
4604
|
+
const key = `@O${index}@`;
|
|
4605
|
+
obje.standardizeMedia();
|
|
4606
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
4607
|
+
const url = obje?.get("FILE")?.toValue();
|
|
4608
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
4609
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
4610
|
+
if (url) {
|
|
4611
|
+
const imgId = `media-${index}-${url.split("/").pop()?.split("?")[0]?.substring(0, 20) || Date.now().toString(36)}`;
|
|
4612
|
+
const id = `${treeId}-${this.id}-${imgId}`;
|
|
4613
|
+
list[id] = {
|
|
4614
|
+
isPrimary,
|
|
4615
|
+
key,
|
|
4616
|
+
id,
|
|
4617
|
+
tree: treeId,
|
|
4618
|
+
imgId,
|
|
4619
|
+
person: this.id,
|
|
4620
|
+
title,
|
|
4621
|
+
url,
|
|
4622
|
+
contentType: type,
|
|
4623
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName()?.replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
4624
|
+
};
|
|
4625
|
+
}
|
|
4626
|
+
});
|
|
4627
|
+
return list;
|
|
4628
|
+
}
|
|
4312
4629
|
async multimedia(namespace) {
|
|
4313
4630
|
if (this?.isAncestry()) {
|
|
4314
4631
|
return await this.ancestryMedia(namespace);
|
|
@@ -4316,11 +4633,30 @@ var Indi = class extends Common {
|
|
|
4316
4633
|
if (this?.isMyHeritage()) {
|
|
4317
4634
|
return this.myheritageMedia();
|
|
4318
4635
|
}
|
|
4319
|
-
|
|
4636
|
+
if (this?.isGeni()) {
|
|
4637
|
+
return this.geniMedia();
|
|
4638
|
+
}
|
|
4639
|
+
return this.universalMedia();
|
|
4320
4640
|
}
|
|
4321
|
-
async getProfilePicture(namespace) {
|
|
4641
|
+
async getProfilePicture(namespace, onlyPrimary = true) {
|
|
4642
|
+
if (!this.id) {
|
|
4643
|
+
return void 0;
|
|
4644
|
+
}
|
|
4645
|
+
const cacheKey = this.id;
|
|
4646
|
+
const cached = profilePictureCache(
|
|
4647
|
+
this._gedcom,
|
|
4648
|
+
cacheKey
|
|
4649
|
+
);
|
|
4650
|
+
if (cached !== void 0) {
|
|
4651
|
+
return cached;
|
|
4652
|
+
}
|
|
4322
4653
|
const mediaList = await this.multimedia(namespace);
|
|
4323
4654
|
if (!mediaList) {
|
|
4655
|
+
profilePictureCache(
|
|
4656
|
+
this._gedcom,
|
|
4657
|
+
cacheKey,
|
|
4658
|
+
void 0
|
|
4659
|
+
);
|
|
4324
4660
|
return void 0;
|
|
4325
4661
|
}
|
|
4326
4662
|
const mediaArray = Object.values(mediaList);
|
|
@@ -4328,24 +4664,41 @@ var Indi = class extends Common {
|
|
|
4328
4664
|
(media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
|
|
4329
4665
|
);
|
|
4330
4666
|
if (primaryMedia) {
|
|
4331
|
-
|
|
4667
|
+
const result = {
|
|
4332
4668
|
file: primaryMedia.url,
|
|
4333
4669
|
form: primaryMedia.contentType,
|
|
4334
4670
|
title: primaryMedia.title,
|
|
4335
4671
|
isPrimary: true
|
|
4336
4672
|
};
|
|
4673
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
4674
|
+
return result;
|
|
4675
|
+
}
|
|
4676
|
+
if (onlyPrimary) {
|
|
4677
|
+
profilePictureCache(
|
|
4678
|
+
this._gedcom,
|
|
4679
|
+
cacheKey,
|
|
4680
|
+
void 0
|
|
4681
|
+
);
|
|
4682
|
+
return void 0;
|
|
4337
4683
|
}
|
|
4338
4684
|
const secondaryMedia = mediaArray.find(
|
|
4339
4685
|
(media) => isImageFormat(media.contentType || getFileExtension(media.url))
|
|
4340
4686
|
);
|
|
4341
4687
|
if (secondaryMedia) {
|
|
4342
|
-
|
|
4688
|
+
const result = {
|
|
4343
4689
|
file: secondaryMedia.url,
|
|
4344
4690
|
form: secondaryMedia.contentType,
|
|
4345
4691
|
title: secondaryMedia.title,
|
|
4346
4692
|
isPrimary: false
|
|
4347
4693
|
};
|
|
4694
|
+
profilePictureCache(this._gedcom, cacheKey, result);
|
|
4695
|
+
return result;
|
|
4348
4696
|
}
|
|
4697
|
+
profilePictureCache(
|
|
4698
|
+
this._gedcom,
|
|
4699
|
+
cacheKey,
|
|
4700
|
+
void 0
|
|
4701
|
+
);
|
|
4349
4702
|
return void 0;
|
|
4350
4703
|
}
|
|
4351
4704
|
link(poolId) {
|
|
@@ -4713,7 +5066,7 @@ var Indi = class extends Common {
|
|
|
4713
5066
|
return;
|
|
4714
5067
|
}
|
|
4715
5068
|
const cacheKey = `${this.id}|${usedIndi.id}`;
|
|
4716
|
-
const cache = pathCache(cacheKey);
|
|
5069
|
+
const cache = pathCache(this._gedcom, cacheKey);
|
|
4717
5070
|
if (cache) {
|
|
4718
5071
|
return cache;
|
|
4719
5072
|
}
|
|
@@ -4758,7 +5111,7 @@ var Indi = class extends Common {
|
|
|
4758
5111
|
if (breakOnNext) {
|
|
4759
5112
|
return void 0;
|
|
4760
5113
|
}
|
|
4761
|
-
pathCache(cacheKey, path2);
|
|
5114
|
+
pathCache(this._gedcom, cacheKey, path2);
|
|
4762
5115
|
return path2;
|
|
4763
5116
|
}
|
|
4764
5117
|
visited.append(indi);
|
|
@@ -4928,7 +5281,7 @@ var Indi = class extends Common {
|
|
|
4928
5281
|
}
|
|
4929
5282
|
getRelativesOnDegree(degree = 0) {
|
|
4930
5283
|
this.id = this.id || `@I${Math.random()}@`;
|
|
4931
|
-
const cache = relativesOnDegreeCache(this.id, degree);
|
|
5284
|
+
const cache = relativesOnDegreeCache(this._gedcom, this.id, degree);
|
|
4932
5285
|
if (cache) {
|
|
4933
5286
|
return cache;
|
|
4934
5287
|
}
|
|
@@ -4936,6 +5289,7 @@ var Indi = class extends Common {
|
|
|
4936
5289
|
const excludes = persons;
|
|
4937
5290
|
if (!Math.abs(degree)) {
|
|
4938
5291
|
return relativesOnDegreeCache(
|
|
5292
|
+
this._gedcom,
|
|
4939
5293
|
this.id,
|
|
4940
5294
|
degree,
|
|
4941
5295
|
persons.except(this)
|
|
@@ -4946,11 +5300,11 @@ var Indi = class extends Common {
|
|
|
4946
5300
|
excludes.merge(persons);
|
|
4947
5301
|
persons = this.getRelativesOnLevel(validDegree).getRelativesOnDegree(-validDegree).copy().exclude(excludes);
|
|
4948
5302
|
}
|
|
4949
|
-
return relativesOnDegreeCache(this.id, degree, persons);
|
|
5303
|
+
return relativesOnDegreeCache(this._gedcom, this.id, degree, persons);
|
|
4950
5304
|
}
|
|
4951
5305
|
getRelativesOnLevel(level = 0, filter) {
|
|
4952
5306
|
this.id = this.id || `@I${Math.random()}@`;
|
|
4953
|
-
const cache = relativesOnLevelCache(this.id, level);
|
|
5307
|
+
const cache = relativesOnLevelCache(this._gedcom, this.id, level);
|
|
4954
5308
|
if (cache) {
|
|
4955
5309
|
return cache;
|
|
4956
5310
|
}
|
|
@@ -4961,7 +5315,7 @@ var Indi = class extends Common {
|
|
|
4961
5315
|
};
|
|
4962
5316
|
let families = this.get(config.key)?.toValueList();
|
|
4963
5317
|
if (!families) {
|
|
4964
|
-
return relativesOnLevelCache(this.id, level, persons);
|
|
5318
|
+
return relativesOnLevelCache(this._gedcom, this.id, level, persons);
|
|
4965
5319
|
}
|
|
4966
5320
|
if (filter) {
|
|
4967
5321
|
families = families.filter(filter);
|
|
@@ -4972,7 +5326,12 @@ var Indi = class extends Common {
|
|
|
4972
5326
|
persons = this.toFamilies(families).getParents();
|
|
4973
5327
|
}
|
|
4974
5328
|
if (level >= -1 && level <= 1) {
|
|
4975
|
-
return relativesOnLevelCache(
|
|
5329
|
+
return relativesOnLevelCache(
|
|
5330
|
+
this._gedcom,
|
|
5331
|
+
this.id,
|
|
5332
|
+
level,
|
|
5333
|
+
persons.except(this)
|
|
5334
|
+
);
|
|
4976
5335
|
}
|
|
4977
5336
|
for (let i = 1; i < Math.abs(level); i++) {
|
|
4978
5337
|
if (config.isAscendant) {
|
|
@@ -4981,7 +5340,12 @@ var Indi = class extends Common {
|
|
|
4981
5340
|
persons = persons.getParents();
|
|
4982
5341
|
}
|
|
4983
5342
|
}
|
|
4984
|
-
return relativesOnLevelCache(
|
|
5343
|
+
return relativesOnLevelCache(
|
|
5344
|
+
this._gedcom,
|
|
5345
|
+
this.id,
|
|
5346
|
+
level,
|
|
5347
|
+
persons.except(this)
|
|
5348
|
+
);
|
|
4985
5349
|
}
|
|
4986
5350
|
getAscendants(level = 0, filter) {
|
|
4987
5351
|
if (!level) {
|
|
@@ -5020,7 +5384,12 @@ var Indi = class extends Common {
|
|
|
5020
5384
|
}
|
|
5021
5385
|
currentGen++;
|
|
5022
5386
|
generations[currentGen] = descentants;
|
|
5023
|
-
relativesOnLevelCache(
|
|
5387
|
+
relativesOnLevelCache(
|
|
5388
|
+
this._gedcom,
|
|
5389
|
+
this.id,
|
|
5390
|
+
-currentGen,
|
|
5391
|
+
descentants
|
|
5392
|
+
);
|
|
5024
5393
|
descentants && relatives.merge(descentants);
|
|
5025
5394
|
}
|
|
5026
5395
|
return { relatives, generations };
|
|
@@ -5053,7 +5422,7 @@ var Indi = class extends Common {
|
|
|
5053
5422
|
}
|
|
5054
5423
|
currentGen++;
|
|
5055
5424
|
generations[currentGen] = parents;
|
|
5056
|
-
relativesOnLevelCache(this.id, currentGen, parents);
|
|
5425
|
+
relativesOnLevelCache(this._gedcom, this.id, currentGen, parents);
|
|
5057
5426
|
parents && relatives.merge(parents);
|
|
5058
5427
|
}
|
|
5059
5428
|
return { relatives, generations };
|