gedcom-ts 1.1.1 → 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/LICENSE +22 -0
- package/README.md +228 -35
- package/dist/commons/Act.d.ts +38 -5
- package/dist/commons/ActsByYears.d.ts +10 -0
- package/dist/commons/DateAct.d.ts +24 -5
- package/dist/commons/MultimediaFile.d.ts +14 -0
- package/dist/commons/Note.d.ts +18 -0
- package/dist/commons/Person.d.ts +44 -0
- package/dist/commons/Place.d.ts +7 -9
- package/dist/export/GEDCOM.d.ts +46 -37
- package/dist/import/LoadFile.d.ts +2 -0
- package/dist/import/ReadGed.d.ts +17 -17
- package/dist/import/SplitedInformations.d.ts +13 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +12 -4
- package/dist/index.mjs +1 -0
- package/dist/services/CitySearch.d.ts +2 -0
- package/dist/utils/acts-helper/acts-helper.d.ts +2 -0
- package/dist/utils/gedcom/formatNoteForExport.d.ts +12 -0
- package/dist/utils/gedcom/parseGedcomLine.d.ts +13 -0
- package/dist/utils/indi/indi.d.ts +2 -0
- package/dist/utils/multimedia/nextAvailableRelativeMediaPath.d.ts +9 -0
- package/dist/utils/sosa/calculate-sosa.d.ts +2 -0
- package/package.json +50 -13
- package/CHANGELOG.md +0 -58
- package/dist/commons/Act.js +0 -20
- package/dist/commons/DateAct.js +0 -130
- package/dist/commons/Identificator.enum.js +0 -132
- package/dist/commons/People.d.ts +0 -29
- package/dist/commons/People.js +0 -88
- package/dist/commons/Place.js +0 -24
- package/dist/commons/Separators.js +0 -4
- package/dist/commons/Utils-People.d.ts +0 -2
- package/dist/commons/Utils-People.js +0 -9
- package/dist/export/GEDCOM.js +0 -189
- package/dist/import/ReadGed.js +0 -92
- package/dist/index.js +0 -6
- package/webpack.config.ts +0 -28
package/dist/commons/DateAct.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
export var TypeDateAct;
|
|
2
|
-
(function (TypeDateAct) {
|
|
3
|
-
TypeDateAct["BEF"] = "BEF";
|
|
4
|
-
TypeDateAct["ABT"] = "ABT";
|
|
5
|
-
TypeDateAct["NULL"] = "NULL";
|
|
6
|
-
})(TypeDateAct || (TypeDateAct = {}));
|
|
7
|
-
export class DateAct {
|
|
8
|
-
typeDateAct;
|
|
9
|
-
day;
|
|
10
|
-
month;
|
|
11
|
-
year;
|
|
12
|
-
date;
|
|
13
|
-
constructor(dateLine) {
|
|
14
|
-
if (dateLine && dateLine !== 'inconnue') {
|
|
15
|
-
const dateParts = dateLine.split(' ');
|
|
16
|
-
switch (dateParts.length) {
|
|
17
|
-
case 1:
|
|
18
|
-
if (dateParts[0].includes('/')) {
|
|
19
|
-
const [month, year] = dateParts[0].split('/');
|
|
20
|
-
this.month = this.convertMonth(month);
|
|
21
|
-
this.year = year;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
this.year = dateParts[0];
|
|
25
|
-
}
|
|
26
|
-
break;
|
|
27
|
-
case 2:
|
|
28
|
-
if (dateParts[0] === TypeDateAct.BEF || dateParts[0] === TypeDateAct.ABT) {
|
|
29
|
-
this.typeDateAct = dateParts[0];
|
|
30
|
-
if (dateParts[1].includes('/')) {
|
|
31
|
-
const [month, year] = dateParts[1].split('/');
|
|
32
|
-
this.month = this.convertMonth(month);
|
|
33
|
-
this.year = year;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
this.month = '';
|
|
37
|
-
this.year = dateParts[1];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else if (dateParts[0].includes('/')) {
|
|
41
|
-
const [month, year] = dateParts[0].split('/');
|
|
42
|
-
this.month = this.convertMonth(month);
|
|
43
|
-
this.year = year;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this.month = dateParts[0];
|
|
47
|
-
this.year = dateParts[1];
|
|
48
|
-
}
|
|
49
|
-
break;
|
|
50
|
-
case 3:
|
|
51
|
-
if (dateParts[0] === TypeDateAct.BEF || dateParts[0] === TypeDateAct.ABT) {
|
|
52
|
-
this.typeDateAct = dateParts[0];
|
|
53
|
-
this.month = dateParts[1];
|
|
54
|
-
this.year = dateParts[2];
|
|
55
|
-
}
|
|
56
|
-
else if (dateParts[1].includes('/')) {
|
|
57
|
-
const [month, year] = dateParts[1].split('/');
|
|
58
|
-
this.month = this.convertMonth(month);
|
|
59
|
-
this.year = year;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.day = dateParts[0];
|
|
63
|
-
this.month = dateParts[1];
|
|
64
|
-
this.year = dateParts[2];
|
|
65
|
-
}
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
this.date = this.parseDate();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
convertMonth(month) {
|
|
72
|
-
const monthMap = {
|
|
73
|
-
'1': 'JAN',
|
|
74
|
-
'2': 'FEB',
|
|
75
|
-
'3': 'MAR',
|
|
76
|
-
'4': 'APR',
|
|
77
|
-
'5': 'MAY',
|
|
78
|
-
'6': 'JUN',
|
|
79
|
-
'7': 'JUL',
|
|
80
|
-
'8': 'AUG',
|
|
81
|
-
'9': 'SEP',
|
|
82
|
-
'10': 'OCT',
|
|
83
|
-
'11': 'NOV',
|
|
84
|
-
'12': 'DEC',
|
|
85
|
-
};
|
|
86
|
-
if (monthMap[month]) {
|
|
87
|
-
return monthMap[month];
|
|
88
|
-
}
|
|
89
|
-
return month.toUpperCase();
|
|
90
|
-
}
|
|
91
|
-
parseDate() {
|
|
92
|
-
const months = {
|
|
93
|
-
JAN: 0,
|
|
94
|
-
FEB: 1,
|
|
95
|
-
MAR: 2,
|
|
96
|
-
APR: 3,
|
|
97
|
-
MAY: 4,
|
|
98
|
-
JUN: 5,
|
|
99
|
-
JUL: 6,
|
|
100
|
-
AUG: 7,
|
|
101
|
-
SEP: 8,
|
|
102
|
-
OCT: 9,
|
|
103
|
-
NOV: 10,
|
|
104
|
-
DEC: 11,
|
|
105
|
-
};
|
|
106
|
-
if (!this.year) {
|
|
107
|
-
return null; // Année manquante, la date ne peut pas être analysée
|
|
108
|
-
}
|
|
109
|
-
let day = 1;
|
|
110
|
-
if (this.day) {
|
|
111
|
-
day = parseInt(this.day, 10);
|
|
112
|
-
if (isNaN(day)) {
|
|
113
|
-
return null; // Jour invalide
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
let month = 0;
|
|
117
|
-
if (this.month) {
|
|
118
|
-
const monthKey = this.month.toUpperCase();
|
|
119
|
-
month = months[monthKey];
|
|
120
|
-
if (month === undefined) {
|
|
121
|
-
return null; // Mois invalide
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
let year = parseInt(this.year, 10);
|
|
125
|
-
if (isNaN(year)) {
|
|
126
|
-
return null; // Année invalide
|
|
127
|
-
}
|
|
128
|
-
return new Date(year, month, day);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
export var Identificator;
|
|
2
|
-
(function (Identificator) {
|
|
3
|
-
Identificator["ABBR"] = "ABBR";
|
|
4
|
-
Identificator["ADDR"] = "ADDR";
|
|
5
|
-
Identificator["ADR1"] = "ADDR1";
|
|
6
|
-
Identificator["ADR2"] = "ADDR2";
|
|
7
|
-
Identificator["ADOP"] = "ADOP";
|
|
8
|
-
Identificator["AFN"] = "AFN";
|
|
9
|
-
Identificator["AGE"] = "AGE";
|
|
10
|
-
Identificator["AGNC"] = "AGNC";
|
|
11
|
-
Identificator["ALIA"] = "ALIA";
|
|
12
|
-
Identificator["ANCE"] = "ANCE";
|
|
13
|
-
Identificator["ANCI"] = "ANCI";
|
|
14
|
-
Identificator["ANUL"] = "ANUL";
|
|
15
|
-
Identificator["ASSO"] = "ASSO";
|
|
16
|
-
Identificator["AUTH"] = "AUTH";
|
|
17
|
-
Identificator["BAPL"] = "BAPL";
|
|
18
|
-
Identificator["BAPM"] = "BAPM";
|
|
19
|
-
Identificator["BARM"] = "BARM";
|
|
20
|
-
Identificator["BASM"] = "BASM";
|
|
21
|
-
Identificator["BIRT"] = "BIRT";
|
|
22
|
-
Identificator["BLES"] = "BLES";
|
|
23
|
-
Identificator["BLOB"] = "BLOB";
|
|
24
|
-
Identificator["BURI"] = "BURI";
|
|
25
|
-
Identificator["CALN"] = "CALN";
|
|
26
|
-
Identificator["CAST"] = "CAST";
|
|
27
|
-
Identificator["CAUS"] = "CAUS";
|
|
28
|
-
Identificator["CENS"] = "CENS";
|
|
29
|
-
Identificator["CHAN"] = "CHAN";
|
|
30
|
-
Identificator["CHAR"] = "CHAR";
|
|
31
|
-
Identificator["CHIL"] = "CHIL";
|
|
32
|
-
Identificator["CHR"] = "CHR";
|
|
33
|
-
Identificator["CHRA"] = "CHRA";
|
|
34
|
-
Identificator["CITY"] = "CITY";
|
|
35
|
-
Identificator["CONC"] = "CONC";
|
|
36
|
-
Identificator["CONF"] = "CONF";
|
|
37
|
-
Identificator["CONL"] = "CONL";
|
|
38
|
-
Identificator["CONT"] = "CONT";
|
|
39
|
-
Identificator["COPR"] = "COPR";
|
|
40
|
-
Identificator["CORP"] = "CORP";
|
|
41
|
-
Identificator["CREM"] = "CREM";
|
|
42
|
-
Identificator["CTRY"] = "CTRY";
|
|
43
|
-
Identificator["DATA"] = "DATA";
|
|
44
|
-
Identificator["DATE"] = "DATE";
|
|
45
|
-
Identificator["DEAT"] = "DEAT";
|
|
46
|
-
Identificator["DESC"] = "DESC";
|
|
47
|
-
Identificator["DESI"] = "DESI";
|
|
48
|
-
Identificator["DEST"] = "DEST";
|
|
49
|
-
Identificator["DIV"] = "DIV";
|
|
50
|
-
Identificator["DIVF"] = "DIVF";
|
|
51
|
-
Identificator["DSCR"] = "DSCR";
|
|
52
|
-
Identificator["EDUC"] = "EDUC";
|
|
53
|
-
Identificator["EMIG"] = "EMIG";
|
|
54
|
-
Identificator["ENDL"] = "ENDL";
|
|
55
|
-
Identificator["ENGA"] = "ENGA";
|
|
56
|
-
Identificator["EVEN"] = "EVEN";
|
|
57
|
-
Identificator["FAM"] = "FAM";
|
|
58
|
-
Identificator["FAMC"] = "FAMC";
|
|
59
|
-
Identificator["FAMF"] = "FAMF";
|
|
60
|
-
Identificator["FAMS"] = "FAMS";
|
|
61
|
-
Identificator["FCOM"] = "FCOM";
|
|
62
|
-
Identificator["FILE"] = "FILE";
|
|
63
|
-
Identificator["FORM"] = "FORM";
|
|
64
|
-
Identificator["GEDC"] = "GEDC";
|
|
65
|
-
Identificator["GIVN"] = "GIVN";
|
|
66
|
-
Identificator["GRAD"] = "GRAD";
|
|
67
|
-
Identificator["HEAD"] = "HEAD";
|
|
68
|
-
Identificator["HUSB"] = "HUSB";
|
|
69
|
-
Identificator["IDNO"] = "IDNO";
|
|
70
|
-
Identificator["IMMI"] = "IMMI";
|
|
71
|
-
Identificator["INDI"] = "INDI";
|
|
72
|
-
Identificator["LANG"] = "LANG";
|
|
73
|
-
Identificator["LEGA"] = "LEGA";
|
|
74
|
-
Identificator["MARB"] = "MARB";
|
|
75
|
-
Identificator["MARC"] = "MARC";
|
|
76
|
-
Identificator["MARL"] = "MARL";
|
|
77
|
-
Identificator["MARR"] = "MARR";
|
|
78
|
-
Identificator["MARS"] = "MARS";
|
|
79
|
-
Identificator["MEDI"] = "MEDI";
|
|
80
|
-
Identificator["NAME"] = "NAME";
|
|
81
|
-
Identificator["NATI"] = "NATI";
|
|
82
|
-
Identificator["NATU"] = "NATU";
|
|
83
|
-
Identificator["NCHI"] = "NCHI";
|
|
84
|
-
Identificator["NICK"] = "NICK";
|
|
85
|
-
Identificator["NMR"] = "NMR";
|
|
86
|
-
Identificator["NOTE"] = "NOTE";
|
|
87
|
-
Identificator["NPFX"] = "NPFX";
|
|
88
|
-
Identificator["NSFX"] = "NSFX";
|
|
89
|
-
Identificator["OBJE"] = "OBJE";
|
|
90
|
-
Identificator["OCCU"] = "OCCU";
|
|
91
|
-
Identificator["ORDI"] = "ORDI";
|
|
92
|
-
Identificator["ORDN"] = "ORDN";
|
|
93
|
-
Identificator["PAGE"] = "PAGE";
|
|
94
|
-
Identificator["PEDI"] = "PEDI";
|
|
95
|
-
Identificator["PHON"] = "PHON";
|
|
96
|
-
Identificator["PLAC"] = "PLAC";
|
|
97
|
-
Identificator["POST"] = "POST";
|
|
98
|
-
Identificator["PROB"] = "PROB";
|
|
99
|
-
Identificator["PROP"] = "PROP";
|
|
100
|
-
Identificator["PUBL"] = "PUBL";
|
|
101
|
-
Identificator["QUAY"] = "QUAY";
|
|
102
|
-
Identificator["REFN"] = "REFN";
|
|
103
|
-
Identificator["RELA"] = "RELA";
|
|
104
|
-
Identificator["RELI"] = "RELI";
|
|
105
|
-
Identificator["REPO"] = "REPO";
|
|
106
|
-
Identificator["RESI"] = "RESI";
|
|
107
|
-
Identificator["RESN"] = "RESN";
|
|
108
|
-
Identificator["RETI"] = "RETI";
|
|
109
|
-
Identificator["RFN"] = "RFN";
|
|
110
|
-
Identificator["RIN"] = "RIN";
|
|
111
|
-
Identificator["ROLE"] = "ROLE";
|
|
112
|
-
Identificator["SEX"] = "SEX";
|
|
113
|
-
Identificator["SLGC"] = "SLGC";
|
|
114
|
-
Identificator["SLGS"] = "SLGS";
|
|
115
|
-
Identificator["SOUR"] = "SOUR";
|
|
116
|
-
Identificator["SPFX"] = "SPFX";
|
|
117
|
-
Identificator["SSN"] = "SSN";
|
|
118
|
-
Identificator["STAE"] = "STAE";
|
|
119
|
-
Identificator["STAT"] = "STAT";
|
|
120
|
-
Identificator["SUBM"] = "SUBM";
|
|
121
|
-
Identificator["SUBN"] = "SUBN";
|
|
122
|
-
Identificator["SURN"] = "SURN";
|
|
123
|
-
Identificator["TEMP"] = "TEMP";
|
|
124
|
-
Identificator["TEXT"] = "TEXT";
|
|
125
|
-
Identificator["TIME"] = "TIME";
|
|
126
|
-
Identificator["TITL"] = "TITL";
|
|
127
|
-
Identificator["TRLR"] = "TRLR";
|
|
128
|
-
Identificator["TYPE"] = "TYPE";
|
|
129
|
-
Identificator["VERS"] = "VERS";
|
|
130
|
-
Identificator["WIFE"] = "WIFE";
|
|
131
|
-
Identificator["WILL"] = "WILL";
|
|
132
|
-
})(Identificator || (Identificator = {}));
|
package/dist/commons/People.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Act } from './Act';
|
|
2
|
-
export declare enum Sex {
|
|
3
|
-
M = "M",
|
|
4
|
-
F = "F"
|
|
5
|
-
}
|
|
6
|
-
export declare class People {
|
|
7
|
-
sosa: number;
|
|
8
|
-
sex: Sex;
|
|
9
|
-
firstnames: Array<string>;
|
|
10
|
-
lastname: string;
|
|
11
|
-
birth: Act;
|
|
12
|
-
marriage: Act;
|
|
13
|
-
death: Act;
|
|
14
|
-
FAMC: number;
|
|
15
|
-
FAMS: number[];
|
|
16
|
-
photo: string;
|
|
17
|
-
constructor(sosa?: number, sex?: Sex, firstnames?: Array<string>, lastname?: string, birth?: Act, marriage?: Act, death?: Act, FAMC?: number, FAMS?: number[], photo?: string);
|
|
18
|
-
createPeopleJson(peopleLines: string[]): void;
|
|
19
|
-
private createFirstnamesAndLastnameJson;
|
|
20
|
-
private createSex;
|
|
21
|
-
private createFAM;
|
|
22
|
-
private createPhoto;
|
|
23
|
-
private createBirthDeathAct;
|
|
24
|
-
}
|
|
25
|
-
export declare class TreePeople extends People {
|
|
26
|
-
parents: People[];
|
|
27
|
-
childrens: People[];
|
|
28
|
-
constructor(people: People, parents: People[], childrens: People[], currentSosa: number);
|
|
29
|
-
}
|
package/dist/commons/People.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Act } from './Act';
|
|
2
|
-
import { Identificator } from "./Identificator.enum";
|
|
3
|
-
import { findLinesConcernedByKeyword, findValueInLine } from "./Utils-People";
|
|
4
|
-
import { DateAct } from "./DateAct";
|
|
5
|
-
export var Sex;
|
|
6
|
-
(function (Sex) {
|
|
7
|
-
Sex["M"] = "M";
|
|
8
|
-
Sex["F"] = "F";
|
|
9
|
-
})(Sex || (Sex = {}));
|
|
10
|
-
export class People {
|
|
11
|
-
sosa;
|
|
12
|
-
sex;
|
|
13
|
-
firstnames;
|
|
14
|
-
lastname;
|
|
15
|
-
birth;
|
|
16
|
-
marriage;
|
|
17
|
-
death;
|
|
18
|
-
FAMC;
|
|
19
|
-
FAMS;
|
|
20
|
-
photo;
|
|
21
|
-
constructor(sosa, sex, firstnames, lastname, birth, marriage, death, FAMC, FAMS, photo) {
|
|
22
|
-
this.sosa = sosa;
|
|
23
|
-
this.sex = sex;
|
|
24
|
-
this.firstnames = firstnames;
|
|
25
|
-
this.lastname = lastname;
|
|
26
|
-
this.photo = photo;
|
|
27
|
-
this.birth = birth;
|
|
28
|
-
this.marriage = marriage;
|
|
29
|
-
this.death = death;
|
|
30
|
-
this.FAMC = FAMC;
|
|
31
|
-
this.FAMS = FAMS;
|
|
32
|
-
}
|
|
33
|
-
createPeopleJson(peopleLines) {
|
|
34
|
-
const peoplesLinesWithoutCarriage = peopleLines.map(people => people.replace(/[\n\r]+/g, ''));
|
|
35
|
-
this.createFirstnamesAndLastnameJson(peoplesLinesWithoutCarriage);
|
|
36
|
-
this.createSex(peoplesLinesWithoutCarriage);
|
|
37
|
-
this.createFAM(peoplesLinesWithoutCarriage);
|
|
38
|
-
this.createPhoto(peoplesLinesWithoutCarriage);
|
|
39
|
-
this.birth = this.createBirthDeathAct(peoplesLinesWithoutCarriage, Identificator.BIRT);
|
|
40
|
-
this.death = this.createBirthDeathAct(peoplesLinesWithoutCarriage, Identificator.DEAT);
|
|
41
|
-
}
|
|
42
|
-
createFirstnamesAndLastnameJson(peopleLines) {
|
|
43
|
-
let lineName = peopleLines.find((information) => information ? information.startsWith('1 NAME') : false);
|
|
44
|
-
lineName = lineName ? lineName.replace('1 NAME', '').trim() : null;
|
|
45
|
-
const regex = /\/(.*?)\//;
|
|
46
|
-
const execLastName = regex.exec(lineName);
|
|
47
|
-
this.lastname = execLastName ? execLastName[1].trim().toUpperCase() : null;
|
|
48
|
-
lineName = execLastName && execLastName[0] ? lineName.replace(execLastName[0], '').trim() : lineName;
|
|
49
|
-
this.firstnames = lineName ? lineName.replace(new RegExp('"', 'g'), '').trim().split(' ') : null;
|
|
50
|
-
}
|
|
51
|
-
createSex(peopleLines) {
|
|
52
|
-
this.sex = findValueInLine(peopleLines, '1 SEX ') === Sex.M ? Sex.M : Sex.F;
|
|
53
|
-
}
|
|
54
|
-
// Enfant issu de la Famille (union de 2 parents)
|
|
55
|
-
createFAM(peopleLines) {
|
|
56
|
-
const numberPattern = /\d+/g;
|
|
57
|
-
const famc = findValueInLine(peopleLines, '1 FAMC ');
|
|
58
|
-
if (famc) {
|
|
59
|
-
this.FAMC = Number(famc.match(numberPattern));
|
|
60
|
-
}
|
|
61
|
-
const fams = findLinesConcernedByKeyword(peopleLines, '1 FAMS ').map(line => Number(line.match(numberPattern)));
|
|
62
|
-
if (fams?.length > 0) {
|
|
63
|
-
this.FAMS = fams?.length > 0 ? fams : [];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
createPhoto(peopleLines) {
|
|
67
|
-
const photoUrl = findValueInLine(peopleLines, '2 FILE ');
|
|
68
|
-
if (photoUrl) {
|
|
69
|
-
this.photo = photoUrl;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
createBirthDeathAct(peopleLines, identificator) {
|
|
73
|
-
const idxBegin = peopleLines.findIndex((lineInformation) => lineInformation.startsWith(`1 ${identificator}`));
|
|
74
|
-
const startArray = peopleLines.slice(idxBegin + 1);
|
|
75
|
-
const idxEnd = startArray.findIndex((lineInformation) => lineInformation.startsWith('1 '));
|
|
76
|
-
const finalArray = idxEnd >= 0 ? startArray.slice(0, idxEnd) : startArray;
|
|
77
|
-
return new Act(new DateAct(findValueInLine(finalArray, '2 DATE ')), findValueInLine(finalArray, '2 PLAC '));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
export class TreePeople extends People {
|
|
81
|
-
parents;
|
|
82
|
-
childrens;
|
|
83
|
-
constructor(people, parents, childrens, currentSosa) {
|
|
84
|
-
super(currentSosa, people.sex, people.firstnames, people.lastname, people.birth, people.marriage, people.death, people.FAMC, people.FAMS);
|
|
85
|
-
this.parents = parents;
|
|
86
|
-
this.childrens = childrens;
|
|
87
|
-
}
|
|
88
|
-
}
|
package/dist/commons/Place.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export class Place {
|
|
2
|
-
city;
|
|
3
|
-
zip;
|
|
4
|
-
county;
|
|
5
|
-
region;
|
|
6
|
-
country;
|
|
7
|
-
coordinate;
|
|
8
|
-
constructor(city, zip, county, region, country, coordinate) {
|
|
9
|
-
this.city = city;
|
|
10
|
-
this.zip = zip;
|
|
11
|
-
this.county = county;
|
|
12
|
-
this.region = region;
|
|
13
|
-
this.country = country.toUpperCase();
|
|
14
|
-
this.coordinate = coordinate;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export class CoordinateGPS {
|
|
18
|
-
latitude;
|
|
19
|
-
longitude;
|
|
20
|
-
constructor(latitude, longitude) {
|
|
21
|
-
this.latitude = latitude;
|
|
22
|
-
this.longitude = longitude;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const findValueInLine = (lines, keyword) => {
|
|
2
|
-
const line = lines.find((lineInformation) => lineInformation.startsWith(keyword));
|
|
3
|
-
return line ? line.replace(keyword, '') : null;
|
|
4
|
-
};
|
|
5
|
-
export const findLinesConcernedByKeyword = (lines, keyword) => {
|
|
6
|
-
return [...lines]
|
|
7
|
-
.filter(line => line.startsWith(keyword))
|
|
8
|
-
.map(line => line.replace(keyword, ''));
|
|
9
|
-
};
|
package/dist/export/GEDCOM.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { Separators } from '../commons/Separators';
|
|
2
|
-
import { Sex } from '../commons/People';
|
|
3
|
-
import { Identificator } from '../commons/Identificator.enum';
|
|
4
|
-
export class ExportFormatFile {
|
|
5
|
-
title;
|
|
6
|
-
extension;
|
|
7
|
-
constructor(title) {
|
|
8
|
-
this.title = title;
|
|
9
|
-
}
|
|
10
|
-
export(data) {
|
|
11
|
-
const link = document.createElement('a');
|
|
12
|
-
link.setAttribute('href', data);
|
|
13
|
-
link.setAttribute('download', `${this.title}${this.extension}`);
|
|
14
|
-
link.click();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export class GEDCOM extends ExportFormatFile {
|
|
18
|
-
peoples;
|
|
19
|
-
constructor(title, peoples) {
|
|
20
|
-
super(title);
|
|
21
|
-
this.extension = '.ged';
|
|
22
|
-
this.peoples = peoples;
|
|
23
|
-
}
|
|
24
|
-
get beginGedcom() {
|
|
25
|
-
const cr = Separators.CARRIAGE_RETURN;
|
|
26
|
-
const date = new Date();
|
|
27
|
-
const options = { day: '2-digit', month: '2-digit', year: 'numeric' };
|
|
28
|
-
const formattedTime = date.toLocaleTimeString('fr-FR');
|
|
29
|
-
return ('0 HEAD' +
|
|
30
|
-
cr +
|
|
31
|
-
'1 SOUR generated by gedcom-ts' +
|
|
32
|
-
cr +
|
|
33
|
-
`1 DATE ${date.toLocaleDateString('fr-FR', options)}` +
|
|
34
|
-
cr +
|
|
35
|
-
`2 TIME ${date.toLocaleTimeString('fr-FR')}` +
|
|
36
|
-
cr +
|
|
37
|
-
`1 FILE ${this.title}` +
|
|
38
|
-
cr +
|
|
39
|
-
'1 GEDC' +
|
|
40
|
-
cr +
|
|
41
|
-
'2 VERS 5.5.1' +
|
|
42
|
-
cr +
|
|
43
|
-
'2 FORM LINEAGE-LINKED' +
|
|
44
|
-
cr +
|
|
45
|
-
'1 CHAR UTF-8' +
|
|
46
|
-
cr);
|
|
47
|
-
}
|
|
48
|
-
get contentGedcom() {
|
|
49
|
-
let content = '';
|
|
50
|
-
const cr = Separators.CARRIAGE_RETURN;
|
|
51
|
-
if (this.peoples && this.peoples.length > 0) {
|
|
52
|
-
this.peoples.forEach((people) => {
|
|
53
|
-
const firstnames = people.firstnames ?? [];
|
|
54
|
-
const peopleLine = new PeopleLine(people.sosa, [...firstnames], people.lastname, people.FAMS, people.FAMC);
|
|
55
|
-
// sosa
|
|
56
|
-
content += peopleLine.indi;
|
|
57
|
-
if (peopleLine.famsLine) {
|
|
58
|
-
content += peopleLine.famsLine;
|
|
59
|
-
}
|
|
60
|
-
if (peopleLine.famcLine) {
|
|
61
|
-
content += peopleLine.famcLine;
|
|
62
|
-
}
|
|
63
|
-
// prénom et nom
|
|
64
|
-
content += peopleLine.firstnamesAndNames;
|
|
65
|
-
// sex
|
|
66
|
-
content += peopleLine.sex;
|
|
67
|
-
// birth
|
|
68
|
-
if (people.birth && (people.birth.dateAct?.date || people.birth.place)) {
|
|
69
|
-
const actLine = new ActLine(Identificator.BIRT, people.birth);
|
|
70
|
-
content += actLine.typeLine;
|
|
71
|
-
if (people.birth.dateAct?.date) {
|
|
72
|
-
content += actLine.dateLine;
|
|
73
|
-
}
|
|
74
|
-
if (people.birth.place) {
|
|
75
|
-
content += actLine.placeLine;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (people.death && (people.death.dateAct?.date || people.death.place)) {
|
|
79
|
-
const actLine = new ActLine(Identificator.DEAT, people.death);
|
|
80
|
-
content += actLine.typeLine;
|
|
81
|
-
if (people.death.dateAct?.date) {
|
|
82
|
-
content += actLine.dateLine;
|
|
83
|
-
}
|
|
84
|
-
if (people.death.place) {
|
|
85
|
-
content += actLine.placeLine;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
// content += 'toto' + cr;
|
|
90
|
-
}
|
|
91
|
-
return content;
|
|
92
|
-
}
|
|
93
|
-
download() {
|
|
94
|
-
const ged = `data:text/ged;charset=utf-8,${this.beginGedcom}${this.contentGedcom}${Identificator.TRLR}`;
|
|
95
|
-
const data = encodeURI(ged);
|
|
96
|
-
this.export(data);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
export class LineGedcom {
|
|
100
|
-
cr = Separators.CARRIAGE_RETURN;
|
|
101
|
-
}
|
|
102
|
-
export class PeopleLine extends LineGedcom {
|
|
103
|
-
sosa;
|
|
104
|
-
fams;
|
|
105
|
-
famc;
|
|
106
|
-
firstnames;
|
|
107
|
-
lastnames;
|
|
108
|
-
constructor(sosa, firstnames, lastnames, fams, famc) {
|
|
109
|
-
super();
|
|
110
|
-
this.sosa = sosa;
|
|
111
|
-
this.firstnames = firstnames;
|
|
112
|
-
this.lastnames = lastnames ?? '';
|
|
113
|
-
this.fams = fams?.length > 0 ? fams : [];
|
|
114
|
-
if (famc) {
|
|
115
|
-
this.famc = famc;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
get indi() {
|
|
119
|
-
if (this.sosa) {
|
|
120
|
-
return `0 @I${this.sosa}@ INDI${this.cr}`;
|
|
121
|
-
}
|
|
122
|
-
return '';
|
|
123
|
-
}
|
|
124
|
-
get famsLine() {
|
|
125
|
-
return this.fams.reduce((pre, curr) => {
|
|
126
|
-
if (curr >= 0) {
|
|
127
|
-
pre += `1 FAMS @${curr}@${this.cr}`;
|
|
128
|
-
}
|
|
129
|
-
return pre;
|
|
130
|
-
}, '');
|
|
131
|
-
}
|
|
132
|
-
get famcLine() {
|
|
133
|
-
if (this.famc) {
|
|
134
|
-
return `1 FAMC @${this.famc}@${this.cr}`;
|
|
135
|
-
}
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
get firstnamesAndNames() {
|
|
139
|
-
if (this.firstnames || this.lastnames) {
|
|
140
|
-
let content = '1 NAME';
|
|
141
|
-
if (this.firstnames && this.firstnames.length > 0) {
|
|
142
|
-
this.firstnames[0] = `"${this.firstnames[0]}"`;
|
|
143
|
-
content += ` ${this.firstnames.join(' ')}`;
|
|
144
|
-
}
|
|
145
|
-
if (this.lastnames && this.lastnames.length > 0) {
|
|
146
|
-
content += ` /${this.lastnames}/`;
|
|
147
|
-
}
|
|
148
|
-
return content + this.cr;
|
|
149
|
-
}
|
|
150
|
-
return '';
|
|
151
|
-
}
|
|
152
|
-
get sex() {
|
|
153
|
-
if (this.sosa) {
|
|
154
|
-
return `1 SEX ${this.sosa === 1 || this.sosa % 2 ? Sex.F : Sex.M}${this.cr}`;
|
|
155
|
-
}
|
|
156
|
-
return '';
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
export class ActLine extends LineGedcom {
|
|
160
|
-
type;
|
|
161
|
-
act;
|
|
162
|
-
constructor(type, act) {
|
|
163
|
-
super();
|
|
164
|
-
this.type = type;
|
|
165
|
-
this.act = act;
|
|
166
|
-
}
|
|
167
|
-
get typeLine() {
|
|
168
|
-
return `1 ${this.type}${this.cr}`;
|
|
169
|
-
}
|
|
170
|
-
get dateLine() {
|
|
171
|
-
if (this.act?.dateAct?.date) {
|
|
172
|
-
const options = { day: '2-digit', month: 'short', year: 'numeric' };
|
|
173
|
-
return `2 ${Identificator.DATE} ${this.formatDate(this.act.dateAct)}${this.cr}`;
|
|
174
|
-
}
|
|
175
|
-
return '';
|
|
176
|
-
}
|
|
177
|
-
get placeLine() {
|
|
178
|
-
if (this.act?.place?.length > 0) {
|
|
179
|
-
return `2 ${Identificator.PLAC} ${this.act.place}${this.cr}`;
|
|
180
|
-
}
|
|
181
|
-
return '';
|
|
182
|
-
}
|
|
183
|
-
formatDate(dateAct) {
|
|
184
|
-
if (dateAct.date) {
|
|
185
|
-
return `${dateAct.day ? `${dateAct.day} ` : ''}${dateAct.month ? `${dateAct.month} ` : ''}${dateAct.year ? `${dateAct.year}` : ''}`;
|
|
186
|
-
}
|
|
187
|
-
return '';
|
|
188
|
-
}
|
|
189
|
-
}
|