@treeviz/gedcom-parser 1.0.19 → 1.0.21
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/dist/classes/index.d.ts +1 -1
- package/dist/classes/index.js +151 -45
- package/dist/cli/index.js +151 -45
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +150 -44
- package/dist/factories/index.d.ts +2 -2
- package/dist/factories/index.js +150 -44
- package/dist/{index-BnFjCzJz.d.ts → index-BPEVN_DY.d.ts} +19 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +151 -45
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/kinship-translator/index.d.ts +2 -2
- package/dist/kinship-translator/index.js +150 -44
- package/dist/{place-parser-ChkPI4pQ.d.ts → place-parser-CM0TJFj8.d.ts} +1 -1
- package/dist/place-translator-CRiaOO9v.d.ts +88 -0
- package/dist/structures/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.d.ts +14 -86
- package/dist/utils/index.js +152 -46
- package/package.json +1 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,91 +1,19 @@
|
|
|
1
|
-
export { C as CacheRelatives, I as ICacheManager, P as PlaceParts, g as getPlaceParts, p as pathCache, a as relativesCache, r as resetRelativesCache } from '../place-parser-
|
|
2
|
-
|
|
3
|
-
export {
|
|
1
|
+
export { C as CacheRelatives, I as ICacheManager, P as PlaceParts, g as getPlaceParts, p as pathCache, a as relativesCache, r as resetRelativesCache } from '../place-parser-CM0TJFj8.js';
|
|
2
|
+
export { A as ACCEPTED_DATE_FORMATS, a as ACCEPTED_DATE_FORMATS_REGEX, G as GedcomTree, b as commonDateFormatter, c as create, d as dateFormatter, e as getAllProp, f as getFamilyWith, j as getName, g as getRawSize, h as getVersion, q as hungarianOrdinalize, k as implemented, i as isDevelopment, m as marriageDateFormatter, o as nameFormatter, l as notImplemented, n as noteDateFormatter, p as ordinalize, r as placeTranslator, s as setNestedGroup } from '../place-translator-CRiaOO9v.js';
|
|
3
|
+
export { bD as Place, bE as PlaceType, P as PrimitiveRange, R as Range, S as SplitResult, h as extractSeparationYears, e as extractSplitPoints, d as findMatchingRangeForSplitRange, f as fromTuple, g as generateSplitRanges, bF as getPlaces, i as inRange, a as isIntersectedRange, b as isRangeContained, p as parseRangeBounds, c as splitOverlappingRanges, s as splitRange } from '../index-BPEVN_DY.js';
|
|
4
4
|
import 'date-fns';
|
|
5
5
|
|
|
6
|
-
declare const GedcomTree: {
|
|
7
|
-
parse: (content: string, options?: {
|
|
8
|
-
settings?: Settings;
|
|
9
|
-
}) => any;
|
|
10
|
-
parseHierarchy: (content: string, options?: {
|
|
11
|
-
settings?: Settings;
|
|
12
|
-
}) => {
|
|
13
|
-
gedcom: GedComType;
|
|
14
|
-
raw: string;
|
|
15
|
-
};
|
|
16
|
-
addToList: (id: string, type: MultiTag, common: Common, prev: Common) => void;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
declare const create: (gedcom: GedComType, type: MultiTag, id?: string, nodes?: {
|
|
20
|
-
mainNode?: Common;
|
|
21
|
-
curNode?: Common;
|
|
22
|
-
prevNode?: Common;
|
|
23
|
-
}) => {
|
|
24
|
-
prevNode: Common<string, IdType>;
|
|
25
|
-
curNode: Common<string, IdType>;
|
|
26
|
-
mainNode: Common<string, IdType>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
declare const ACCEPTED_DATE_FORMATS: string[];
|
|
30
|
-
declare const ACCEPTED_DATE_FORMATS_REGEX: RegExp;
|
|
31
|
-
declare const commonDateFormatter: (date?: IDateStructure["DATE"], format?: string, prefix?: string) => string;
|
|
32
|
-
declare const noteDateFormatter: (date?: IDateStructure["DATE"], format?: string, prefix?: string, shortNote?: boolean, showNote?: boolean) => string;
|
|
33
|
-
declare const marriageDateFormatter: (fam?: FamType, showDays?: boolean, showPlaces?: boolean, shortNote?: boolean, showNote?: boolean, showDisplayTextIfNoDate?: boolean, showAllEvents?: boolean, dateFormatPattern?: string) => {
|
|
34
|
-
marriages?: string[];
|
|
35
|
-
marriagePlaces?: string[];
|
|
36
|
-
rawArray: CommonDate[];
|
|
37
|
-
inArray: string[];
|
|
38
|
-
inOrder: string;
|
|
39
|
-
places: string[];
|
|
40
|
-
marriage: string[];
|
|
41
|
-
};
|
|
42
|
-
declare const dateFormatter: (indi?: IndiType, showMarriages?: boolean, showDays?: boolean, showPlaces?: boolean, shortNote?: boolean, showNote?: boolean, isOnStage?: (key: IndiKey) => boolean, showAllEvents?: boolean, dateFormatPattern?: string) => {
|
|
43
|
-
births?: string[];
|
|
44
|
-
birthPlaces?: string[];
|
|
45
|
-
deaths?: string[];
|
|
46
|
-
deathPlaces?: string[];
|
|
47
|
-
marriages?: string[];
|
|
48
|
-
marriagePlaces?: string[];
|
|
49
|
-
birthPlace?: string;
|
|
50
|
-
deathPlace?: string;
|
|
51
|
-
inArray: string[];
|
|
52
|
-
inOrder: string;
|
|
53
|
-
places: string[];
|
|
54
|
-
birth: string;
|
|
55
|
-
marriage: string[];
|
|
56
|
-
death: string;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
declare const getAllProp: <T>(indi?: IndiType, prop?: MultiTag) => T[];
|
|
60
|
-
|
|
61
|
-
declare const getFamilyWith: (person1: IndiType, person2?: IndiKey, famType?: "FAMS" | "FAMC") => FamType | undefined;
|
|
62
|
-
|
|
63
|
-
declare const isDevelopment: () => boolean;
|
|
64
|
-
declare const getVersion: () => string;
|
|
65
|
-
declare const getName: () => string;
|
|
66
|
-
|
|
67
|
-
declare const getRawSize: (raw?: string) => number;
|
|
68
|
-
|
|
69
|
-
declare const implemented: (type: string, ...args: any[]) => void;
|
|
70
|
-
declare const notImplemented: (type: string, ...args: any[]) => void;
|
|
71
|
-
|
|
72
|
-
declare const nameFormatter: (indiName?: IndiType | string, settings?: Partial<Settings>, letterOnAll?: boolean, indi?: IndiType, debug?: 3) => {
|
|
73
|
-
suffix: string;
|
|
74
|
-
givenname: string;
|
|
75
|
-
surname: string;
|
|
76
|
-
inOrder: [string, string, string];
|
|
77
|
-
letter: string;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
declare const setNestedGroup: (obj: NestedGroup, key: string | string[], value: Individuals, uniqueCounting?: boolean) => void;
|
|
81
|
-
|
|
82
|
-
declare const ordinalize: (n: number) => string;
|
|
83
|
-
declare const hungarianOrdinalize: (n: number) => string;
|
|
84
|
-
|
|
85
6
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
7
|
+
* Get file extension from filename
|
|
8
|
+
* @param filename - The filename to extract extension from
|
|
9
|
+
* @returns File extension without the dot, or empty string if no extension
|
|
10
|
+
*/
|
|
11
|
+
declare const getFileExtension: (filename: string) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a file format is an image format
|
|
14
|
+
* @param format - The file format/extension to check
|
|
15
|
+
* @returns true if the format is a supported image format
|
|
88
16
|
*/
|
|
89
|
-
declare const
|
|
17
|
+
declare const isImageFormat: (format: string) => boolean;
|
|
90
18
|
|
|
91
|
-
export {
|
|
19
|
+
export { getFileExtension, isImageFormat };
|
package/dist/utils/index.js
CHANGED
|
@@ -1503,6 +1503,27 @@ var implemented = (type, ...args) => {
|
|
|
1503
1503
|
var notImplemented = (type, ...args) => {
|
|
1504
1504
|
console.error(`[Not Implemented] ${type}`, ...args);
|
|
1505
1505
|
};
|
|
1506
|
+
|
|
1507
|
+
// src/utils/media-utils.ts
|
|
1508
|
+
var getFileExtension = (filename) => {
|
|
1509
|
+
const match = filename.match(/\.([^.]+)$/);
|
|
1510
|
+
return match ? match[1] : "";
|
|
1511
|
+
};
|
|
1512
|
+
var isImageFormat = (format2) => {
|
|
1513
|
+
if (!format2) return false;
|
|
1514
|
+
const imageFormats = [
|
|
1515
|
+
"jpg",
|
|
1516
|
+
"jpeg",
|
|
1517
|
+
"png",
|
|
1518
|
+
"gif",
|
|
1519
|
+
"bmp",
|
|
1520
|
+
"webp",
|
|
1521
|
+
"svg",
|
|
1522
|
+
"tiff",
|
|
1523
|
+
"tif"
|
|
1524
|
+
];
|
|
1525
|
+
return imageFormats.includes(format2.toLowerCase());
|
|
1526
|
+
};
|
|
1506
1527
|
var uniqueItemsCache = /* @__PURE__ */ new WeakMap();
|
|
1507
1528
|
var setNestedGroup = (obj, key, value, uniqueCounting = true) => {
|
|
1508
1529
|
const parts = Array.isArray(key) ? key : key.split(/,\s*/);
|
|
@@ -2718,54 +2739,62 @@ var Indi = class extends Common {
|
|
|
2718
2739
|
}
|
|
2719
2740
|
async ancestryMedia(namespace) {
|
|
2720
2741
|
const list = {};
|
|
2721
|
-
const
|
|
2742
|
+
const objeList = this.get("OBJE")?.toList();
|
|
2722
2743
|
const www = this._gedcom?.HEAD?.SOUR?.CORP?.WWW?.value;
|
|
2723
2744
|
const tree = this.getAncestryTreeId();
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
let url = obje?.get("FILE")?.toValue();
|
|
2734
|
-
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
2735
|
-
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
2736
|
-
const imgId = clone || mser;
|
|
2737
|
-
if (!www || !tree || !this.id) {
|
|
2738
|
-
return;
|
|
2739
|
-
}
|
|
2740
|
-
if (!namespace && !url) {
|
|
2741
|
-
try {
|
|
2742
|
-
const mediaDetailsResponse = await fetch(
|
|
2743
|
-
`https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
|
|
2744
|
-
);
|
|
2745
|
-
const mediaDetails = await mediaDetailsResponse.json();
|
|
2746
|
-
if (mediaDetails.url) {
|
|
2747
|
-
url = `${mediaDetails.url}&imageQuality=hq`;
|
|
2745
|
+
if (objeList) {
|
|
2746
|
+
await Promise.all(
|
|
2747
|
+
objeList.map(async (objeRef) => {
|
|
2748
|
+
const key = objeRef?.id;
|
|
2749
|
+
const obje = objeRef?.standardizeMedia(
|
|
2750
|
+
namespace,
|
|
2751
|
+
true,
|
|
2752
|
+
(ns, iId) => {
|
|
2753
|
+
return ns && iId ? `https://mediasvc.ancestry.com/v2/image/namespaces/${ns}/media/${iId}?client=trees-mediaservice&imageQuality=hq` : void 0;
|
|
2748
2754
|
}
|
|
2749
|
-
|
|
2755
|
+
);
|
|
2756
|
+
const isPrimary = obje?.get("_PRIM")?.toValue() === "Y";
|
|
2757
|
+
const media = obje?.RIN?.value;
|
|
2758
|
+
const clone = obje?.get("_CLON._OID")?.toValue();
|
|
2759
|
+
const mser = obje?.get("_MSER._LKID")?.toValue();
|
|
2760
|
+
let url = obje?.get("FILE")?.toValue();
|
|
2761
|
+
const title = obje?.get("TITL")?.toValue() ?? "";
|
|
2762
|
+
const type = obje?.get("FORM")?.toValue() ?? "raw";
|
|
2763
|
+
const imgId = clone || mser;
|
|
2764
|
+
if (!www || !tree || !this.id) {
|
|
2765
|
+
return;
|
|
2750
2766
|
}
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
url
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2767
|
+
if (!namespace && !url) {
|
|
2768
|
+
try {
|
|
2769
|
+
const mediaDetailsResponse = await fetch(
|
|
2770
|
+
`https://www.ancestry.com/api/media/viewer/v2/trees/${tree}/media?id=${media}`
|
|
2771
|
+
);
|
|
2772
|
+
const mediaDetails = await mediaDetailsResponse.json();
|
|
2773
|
+
if (mediaDetails.url) {
|
|
2774
|
+
url = `${mediaDetails.url}&imageQuality=hq`;
|
|
2775
|
+
}
|
|
2776
|
+
} catch (_e) {
|
|
2777
|
+
}
|
|
2778
|
+
url = url || `https://${www}/mediaui-viewer/tree/${tree}/media/${media}`;
|
|
2779
|
+
}
|
|
2780
|
+
if (url && imgId) {
|
|
2781
|
+
const id = `${tree}-${this.id}-${imgId}`;
|
|
2782
|
+
list[id] = {
|
|
2783
|
+
key,
|
|
2784
|
+
isPrimary,
|
|
2785
|
+
id,
|
|
2786
|
+
tree,
|
|
2787
|
+
imgId,
|
|
2788
|
+
person: this.id,
|
|
2789
|
+
title,
|
|
2790
|
+
url,
|
|
2791
|
+
contentType: type,
|
|
2792
|
+
downloadName: `${this.id.replaceAll("@", "")}_${this.toNaturalName().replaceAll(" ", "-") || ""}_${(title || key.replaceAll("@", "").toString()).replaceAll(" ", "-")}`
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2795
|
+
})
|
|
2796
|
+
);
|
|
2797
|
+
}
|
|
2769
2798
|
return list;
|
|
2770
2799
|
}
|
|
2771
2800
|
myheritageLink(poolId = 0) {
|
|
@@ -2803,6 +2832,7 @@ var Indi = class extends Common {
|
|
|
2803
2832
|
if (url && imgId) {
|
|
2804
2833
|
const id = `${tree}-${this.id}-${imgId}`;
|
|
2805
2834
|
list[id] = {
|
|
2835
|
+
isPrimary: false,
|
|
2806
2836
|
key,
|
|
2807
2837
|
id,
|
|
2808
2838
|
tree,
|
|
@@ -2912,6 +2942,36 @@ var Indi = class extends Common {
|
|
|
2912
2942
|
}
|
|
2913
2943
|
return void 0;
|
|
2914
2944
|
}
|
|
2945
|
+
async getProfilePicture(namespace) {
|
|
2946
|
+
const mediaList = await this.multimedia(namespace);
|
|
2947
|
+
if (!mediaList) {
|
|
2948
|
+
return void 0;
|
|
2949
|
+
}
|
|
2950
|
+
const mediaArray = Object.values(mediaList);
|
|
2951
|
+
const primaryMedia = mediaArray.find(
|
|
2952
|
+
(media) => media.isPrimary && isImageFormat(media.contentType || getFileExtension(media.url))
|
|
2953
|
+
);
|
|
2954
|
+
if (primaryMedia) {
|
|
2955
|
+
return {
|
|
2956
|
+
file: primaryMedia.url,
|
|
2957
|
+
form: primaryMedia.contentType,
|
|
2958
|
+
title: primaryMedia.title,
|
|
2959
|
+
isPrimary: true
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
const secondaryMedia = mediaArray.find(
|
|
2963
|
+
(media) => isImageFormat(media.contentType || getFileExtension(media.url))
|
|
2964
|
+
);
|
|
2965
|
+
if (secondaryMedia) {
|
|
2966
|
+
return {
|
|
2967
|
+
file: secondaryMedia.url,
|
|
2968
|
+
form: secondaryMedia.contentType,
|
|
2969
|
+
title: secondaryMedia.title,
|
|
2970
|
+
isPrimary: false
|
|
2971
|
+
};
|
|
2972
|
+
}
|
|
2973
|
+
return void 0;
|
|
2974
|
+
}
|
|
2915
2975
|
link(poolId) {
|
|
2916
2976
|
if (this?.isAncestry()) {
|
|
2917
2977
|
return this.ancestryLink();
|
|
@@ -3004,6 +3064,52 @@ var Indi = class extends Common {
|
|
|
3004
3064
|
const deathEvent = this.get("DEAT")?.index(0);
|
|
3005
3065
|
return deathEvent?.PLAC?.value;
|
|
3006
3066
|
}
|
|
3067
|
+
/**
|
|
3068
|
+
* Get all marriage places for this individual
|
|
3069
|
+
* @returns Array of marriage place strings (may include undefined for marriages without place)
|
|
3070
|
+
*/
|
|
3071
|
+
getMarriagePlaces() {
|
|
3072
|
+
const marriagePlaces = [];
|
|
3073
|
+
const families = this.getFamilies("FAMS");
|
|
3074
|
+
families.forEach((family) => {
|
|
3075
|
+
const marrEvents = (family?.MARR?.toList().values() ?? []).filter(
|
|
3076
|
+
Boolean
|
|
3077
|
+
);
|
|
3078
|
+
if (marrEvents.length === 0) {
|
|
3079
|
+
marriagePlaces.push(void 0);
|
|
3080
|
+
} else {
|
|
3081
|
+
marrEvents.forEach((marrEvent) => {
|
|
3082
|
+
const marriageEventDetail = marrEvent;
|
|
3083
|
+
const marriagePlace = marriageEventDetail?.PLAC?.value;
|
|
3084
|
+
marriagePlaces.push(marriagePlace);
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
});
|
|
3088
|
+
return marriagePlaces;
|
|
3089
|
+
}
|
|
3090
|
+
/**
|
|
3091
|
+
* Get all marriage dates for this individual
|
|
3092
|
+
* @returns Array of marriage date strings (may include undefined for marriages without date)
|
|
3093
|
+
*/
|
|
3094
|
+
getMarriageDates() {
|
|
3095
|
+
const marriageDates = [];
|
|
3096
|
+
const families = this.getFamilies("FAMS");
|
|
3097
|
+
families.forEach((family) => {
|
|
3098
|
+
const marrEvents = (family?.MARR?.toList().values() ?? []).filter(
|
|
3099
|
+
Boolean
|
|
3100
|
+
);
|
|
3101
|
+
if (marrEvents.length === 0) {
|
|
3102
|
+
marriageDates.push(void 0);
|
|
3103
|
+
} else {
|
|
3104
|
+
marrEvents.forEach((marrEvent) => {
|
|
3105
|
+
const marriageEventDetail = marrEvent;
|
|
3106
|
+
const marriageDate = marriageEventDetail?.DATE?.value;
|
|
3107
|
+
marriageDates.push(marriageDate);
|
|
3108
|
+
});
|
|
3109
|
+
}
|
|
3110
|
+
});
|
|
3111
|
+
return marriageDates;
|
|
3112
|
+
}
|
|
3007
3113
|
isDead() {
|
|
3008
3114
|
return this.get("DEAT.DATE")?.toValue() !== void 0 || this.get("DEAT.PLAC")?.toValue() !== void 0;
|
|
3009
3115
|
}
|
|
@@ -5999,7 +6105,7 @@ var isCommonDate = (value) => {
|
|
|
5999
6105
|
// package.json
|
|
6000
6106
|
var package_default = {
|
|
6001
6107
|
name: "@treeviz/gedcom-parser",
|
|
6002
|
-
version: "1.0.
|
|
6108
|
+
version: "1.0.21"};
|
|
6003
6109
|
|
|
6004
6110
|
// src/utils/get-product-details.ts
|
|
6005
6111
|
var isDevelopment = () => {
|
|
@@ -6980,4 +7086,4 @@ if (isDev) {
|
|
|
6980
7086
|
}
|
|
6981
7087
|
var parser_default = GedcomTree;
|
|
6982
7088
|
|
|
6983
|
-
export { ACCEPTED_DATE_FORMATS, ACCEPTED_DATE_FORMATS_REGEX, parser_default as GedcomTree, PlaceType, commonDateFormatter, create, dateFormatter, extractSeparationYears, extractSplitPoints, findMatchingRangeForSplitRange, fromTuple, generateSplitRanges, getAllProp, getFamilyWith, getName, getPlaceParts, getPlaces, getRawSize, getVersion, hungarianOrdinalize, implemented, inRange, isDevelopment, isIntersectedRange, isRangeContained, marriageDateFormatter, nameFormatter, notImplemented, noteDateFormatter, ordinalize, parseRangeBounds, pathCache, placeTranslator, relativesCache, resetRelativesCache, setNestedGroup, splitOverlappingRanges, splitRange };
|
|
7089
|
+
export { ACCEPTED_DATE_FORMATS, ACCEPTED_DATE_FORMATS_REGEX, parser_default as GedcomTree, PlaceType, commonDateFormatter, create, dateFormatter, extractSeparationYears, extractSplitPoints, findMatchingRangeForSplitRange, fromTuple, generateSplitRanges, getAllProp, getFamilyWith, getFileExtension, getName, getPlaceParts, getPlaces, getRawSize, getVersion, hungarianOrdinalize, implemented, inRange, isDevelopment, isImageFormat, isIntersectedRange, isRangeContained, marriageDateFormatter, nameFormatter, notImplemented, noteDateFormatter, ordinalize, parseRangeBounds, pathCache, placeTranslator, relativesCache, resetRelativesCache, setNestedGroup, splitOverlappingRanges, splitRange };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeviz/gedcom-parser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "Lightweight, pluggable GEDCOM parser for JavaScript/TypeScript with optional caching and place matching. Zero browser dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|