gedcom-ts 1.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+
3
+ All notable changes of gedcom-ts
4
+
5
+ ## [1.0.9] - 2023-06-16
6
+
7
+ ### Added
8
+
9
+ - support multiple FAMS
10
+
11
+ ## [1.0.8] - 2023-06-15
12
+
13
+ ### Added
14
+
15
+ - all right reserved - proprietary code explicit in licence package
16
+
17
+ ## [1.0.7] - 2023-06-15
18
+
19
+ ### Added
20
+
21
+ - FAMS and FAMC are exported
22
+
23
+ ## [1.0.6] - 2023-06-15
24
+
25
+ ### Added
26
+
27
+ - export birth and death date and place
28
+
29
+ ## [1.0.5] - 2023-06-10
30
+
31
+ ### Added
32
+
33
+ - act birth and death
34
+
35
+ ## [1.0.4] - 2020-03-10
36
+
37
+ ### Added
38
+
39
+ - read FAMS (code for two parents) and FAMC (code for childs). It's same code between them.
40
+ - read Sex with two possibilities: M or F
41
+ - group partnersMap, it's a map for all parents
42
+ - jest / test in People / runner
43
+ - createDirectAncestries
44
+
45
+
46
+ ## 1.0.3 - 2019-10-01
47
+
48
+ ### Added
49
+
50
+ - add import gedcom file and return a JSON data model of an array of People. It just extract names and firstnames
51
+
52
+ ## 1.0.2-alpha - 2019-09-01
53
+
54
+ ### Added
55
+
56
+ - export for birth and death in gedcom
57
+ - All identificators can be used for a developper. It's an enum of properties used for all gedcom
58
+ - City is removed and replaced by Place. Place gets more informations
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # gedcom-ts
2
+
3
+ A TypeScript library to manipulate genealogy tree data model in JSON and to export data in a GEDCOM file (.ged).
4
+
5
+ ## INFORMATIONS
6
+
7
+ Gedcom-ts is an amazing library that allows you to work with genealogical files in the GEDCOM format in a simple and convenient way. You can easily import your GEDCOM files and convert them into JSON format for easier manipulation.
8
+
9
+ With Gedcom-ts, you can intuitively visualize your family trees starting from a specific person. You can also discover Sosa numbers, which help you quickly identify your direct ancestors.
10
+
11
+ The library supports the management of family relationships, enabling you to represent family ties such as parents and children. You can also record the first names and surnames of your ancestors, as well as birth and death records.
12
+
13
+ While marriage records are not yet supported, you can still manage couples and their relationships. The library allows you to export your data in the GEDCOM format for easy sharing with others using compatible software.
14
+
15
+ We are actively working on clear and precise documentation that will soon be available to guide you step-by-step in using Gedcom-ts. Stay tuned for updates and new features to come!
16
+
17
+ With Gedcom-ts, genealogy becomes more accessible and exciting. Enjoy this library to explore your family history and share your discoveries with your loved ones.
18
+
19
+ To provide any advice or suggestions for improvement, please contact me at: bertrand.jaunet@gmail.com
20
+
21
+
22
+ ## Install the gedcom-ts library
23
+
24
+ __NPM__
25
+
26
+ ```
27
+ npm i --save gedcom-ts
28
+ ```
29
+
30
+ ## All instantiations JSON data model of Peoples
31
+
32
+ ```ts
33
+ import { Place, People, Act, DateAct, Identificator, GEDCOM, ReadGed } from 'gedcom-ts';
34
+ ```
35
+
36
+ Output in gedcom
37
+
38
+ ```ged
39
+ 0 HEAD
40
+ 1 SOUR generated by gedcom-ts
41
+ 1 DATE 13 07 2019
42
+ 2 TIME 19:10:22
43
+ 1 FILE monFichierGEDCOM
44
+ 1 GEDC
45
+ 2 VERS 5.5.1
46
+ 2 FORM LINEAGE-LINKED
47
+ 1 CHAR UTF-8
48
+ 0 @I1@ INDI
49
+ 1 NAME "Bruce" Thomas /WAYNE/
50
+ 1 SEX H
51
+ 1 BIRT
52
+ 2 DATE 01 Jan 1938
53
+ 2 PLAC Gotham City,USA
54
+ 1 DEAT
55
+ 2 DATE 01 Jan 2000
56
+ 2 PLAC Gotham City,USA
57
+ TRLR
58
+ ```
@@ -0,0 +1,8 @@
1
+ import { DateAct } from "./DateAct";
2
+ export declare class Act {
3
+ dateAct?: DateAct;
4
+ place: string;
5
+ act: string;
6
+ files: Array<Blob>;
7
+ constructor(dateAct?: DateAct, place?: string, act?: string, files?: Array<Blob>);
8
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Act {
4
+ constructor(dateAct, place, act, files) {
5
+ if (dateAct) {
6
+ this.dateAct = dateAct;
7
+ }
8
+ if (place) {
9
+ this.place = place;
10
+ }
11
+ if (act) {
12
+ this.act = act;
13
+ }
14
+ if (files) {
15
+ this.files = files;
16
+ }
17
+ }
18
+ }
19
+ exports.Act = Act;
@@ -0,0 +1,15 @@
1
+ export declare enum TypeDateAct {
2
+ BEF = "BEF",
3
+ ABT = "ABT",
4
+ NULL = "NULL"
5
+ }
6
+ export declare class DateAct {
7
+ typeDateAct?: TypeDateAct;
8
+ day?: string;
9
+ month?: string;
10
+ year?: string;
11
+ date?: Date | null;
12
+ constructor(dateLine: string);
13
+ private convertMonth;
14
+ private parseDate;
15
+ }
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var TypeDateAct;
4
+ (function (TypeDateAct) {
5
+ TypeDateAct["BEF"] = "BEF";
6
+ TypeDateAct["ABT"] = "ABT";
7
+ TypeDateAct["NULL"] = "NULL";
8
+ })(TypeDateAct = exports.TypeDateAct || (exports.TypeDateAct = {}));
9
+ class DateAct {
10
+ constructor(dateLine) {
11
+ if (dateLine && dateLine !== 'inconnue') {
12
+ const dateParts = dateLine.split(' ');
13
+ switch (dateParts.length) {
14
+ case 1:
15
+ if (dateParts[0].includes('/')) {
16
+ const [month, year] = dateParts[0].split('/');
17
+ this.month = this.convertMonth(month);
18
+ this.year = year;
19
+ }
20
+ else {
21
+ this.year = dateParts[0];
22
+ }
23
+ break;
24
+ case 2:
25
+ if (dateParts[0] === TypeDateAct.BEF || dateParts[0] === TypeDateAct.ABT) {
26
+ this.typeDateAct = dateParts[0];
27
+ if (dateParts[1].includes('/')) {
28
+ const [month, year] = dateParts[1].split('/');
29
+ this.month = this.convertMonth(month);
30
+ this.year = year;
31
+ }
32
+ else {
33
+ this.month = '';
34
+ this.year = dateParts[1];
35
+ }
36
+ }
37
+ else if (dateParts[0].includes('/')) {
38
+ const [month, year] = dateParts[0].split('/');
39
+ this.month = this.convertMonth(month);
40
+ this.year = year;
41
+ }
42
+ else {
43
+ this.month = dateParts[0];
44
+ this.year = dateParts[1];
45
+ }
46
+ break;
47
+ case 3:
48
+ if (dateParts[0] === TypeDateAct.BEF || dateParts[0] === TypeDateAct.ABT) {
49
+ this.typeDateAct = dateParts[0];
50
+ this.month = dateParts[1];
51
+ this.year = dateParts[2];
52
+ }
53
+ else if (dateParts[1].includes('/')) {
54
+ const [month, year] = dateParts[1].split('/');
55
+ this.month = this.convertMonth(month);
56
+ this.year = year;
57
+ }
58
+ else {
59
+ this.day = dateParts[0];
60
+ this.month = dateParts[1];
61
+ this.year = dateParts[2];
62
+ }
63
+ break;
64
+ }
65
+ this.date = this.parseDate();
66
+ }
67
+ }
68
+ convertMonth(month) {
69
+ const monthMap = {
70
+ '1': 'JAN',
71
+ '2': 'FEB',
72
+ '3': 'MAR',
73
+ '4': 'APR',
74
+ '5': 'MAY',
75
+ '6': 'JUN',
76
+ '7': 'JUL',
77
+ '8': 'AUG',
78
+ '9': 'SEP',
79
+ '10': 'OCT',
80
+ '11': 'NOV',
81
+ '12': 'DEC',
82
+ };
83
+ if (monthMap[month]) {
84
+ return monthMap[month];
85
+ }
86
+ return month.toUpperCase();
87
+ }
88
+ parseDate() {
89
+ const months = {
90
+ JAN: 0,
91
+ FEB: 1,
92
+ MAR: 2,
93
+ APR: 3,
94
+ MAY: 4,
95
+ JUN: 5,
96
+ JUL: 6,
97
+ AUG: 7,
98
+ SEP: 8,
99
+ OCT: 9,
100
+ NOV: 10,
101
+ DEC: 11,
102
+ };
103
+ if (!this.year) {
104
+ return null; // Année manquante, la date ne peut pas être analysée
105
+ }
106
+ let day = 1;
107
+ if (this.day) {
108
+ day = parseInt(this.day, 10);
109
+ if (isNaN(day)) {
110
+ return null; // Jour invalide
111
+ }
112
+ }
113
+ let month = 0;
114
+ if (this.month) {
115
+ const monthKey = this.month.toUpperCase();
116
+ month = months[monthKey];
117
+ if (month === undefined) {
118
+ return null; // Mois invalide
119
+ }
120
+ }
121
+ let year = parseInt(this.year, 10);
122
+ if (isNaN(year)) {
123
+ return null; // Année invalide
124
+ }
125
+ return new Date(year, month, day);
126
+ }
127
+ }
128
+ exports.DateAct = DateAct;
@@ -0,0 +1,131 @@
1
+ export declare enum Identificator {
2
+ ABBR = "ABBR",
3
+ ADDR = "ADDR",
4
+ ADR1 = "ADDR1",
5
+ ADR2 = "ADDR2",
6
+ ADOP = "ADOP",
7
+ AFN = "AFN",
8
+ AGE = "AGE",
9
+ AGNC = "AGNC",
10
+ ALIA = "ALIA",
11
+ ANCE = "ANCE",
12
+ ANCI = "ANCI",
13
+ ANUL = "ANUL",
14
+ ASSO = "ASSO",
15
+ AUTH = "AUTH",
16
+ BAPL = "BAPL",
17
+ BAPM = "BAPM",
18
+ BARM = "BARM",
19
+ BASM = "BASM",
20
+ BIRT = "BIRT",
21
+ BLES = "BLES",
22
+ BLOB = "BLOB",
23
+ BURI = "BURI",
24
+ CALN = "CALN",
25
+ CAST = "CAST",
26
+ CAUS = "CAUS",
27
+ CENS = "CENS",
28
+ CHAN = "CHAN",
29
+ CHAR = "CHAR",
30
+ CHIL = "CHIL",
31
+ CHR = "CHR",
32
+ CHRA = "CHRA",
33
+ CITY = "CITY",
34
+ CONC = "CONC",
35
+ CONF = "CONF",
36
+ CONL = "CONL",
37
+ CONT = "CONT",
38
+ COPR = "COPR",
39
+ CORP = "CORP",
40
+ CREM = "CREM",
41
+ CTRY = "CTRY",
42
+ DATA = "DATA",
43
+ DATE = "DATE",
44
+ DEAT = "DEAT",
45
+ DESC = "DESC",
46
+ DESI = "DESI",
47
+ DEST = "DEST",
48
+ DIV = "DIV",
49
+ DIVF = "DIVF",
50
+ DSCR = "DSCR",
51
+ EDUC = "EDUC",
52
+ EMIG = "EMIG",
53
+ ENDL = "ENDL",
54
+ ENGA = "ENGA",
55
+ EVEN = "EVEN",
56
+ FAM = "FAM",
57
+ FAMC = "FAMC",
58
+ FAMF = "FAMF",
59
+ FAMS = "FAMS",
60
+ FCOM = "FCOM",
61
+ FILE = "FILE",
62
+ FORM = "FORM",
63
+ GEDC = "GEDC",
64
+ GIVN = "GIVN",
65
+ GRAD = "GRAD",
66
+ HEAD = "HEAD",
67
+ HUSB = "HUSB",
68
+ IDNO = "IDNO",
69
+ IMMI = "IMMI",
70
+ INDI = "INDI",
71
+ LANG = "LANG",
72
+ LEGA = "LEGA",
73
+ MARB = "MARB",
74
+ MARC = "MARC",
75
+ MARL = "MARL",
76
+ MARR = "MARR",
77
+ MARS = "MARS",
78
+ MEDI = "MEDI",
79
+ NAME = "NAME",
80
+ NATI = "NATI",
81
+ NATU = "NATU",
82
+ NCHI = "NCHI",
83
+ NICK = "NICK",
84
+ NMR = "NMR",
85
+ NOTE = "NOTE",
86
+ NPFX = "NPFX",
87
+ NSFX = "NSFX",
88
+ OBJE = "OBJE",
89
+ OCCU = "OCCU",
90
+ ORDI = "ORDI",
91
+ ORDN = "ORDN",
92
+ PAGE = "PAGE",
93
+ PEDI = "PEDI",
94
+ PHON = "PHON",
95
+ PLAC = "PLAC",
96
+ POST = "POST",
97
+ PROB = "PROB",
98
+ PROP = "PROP",
99
+ PUBL = "PUBL",
100
+ QUAY = "QUAY",
101
+ REFN = "REFN",
102
+ RELA = "RELA",
103
+ RELI = "RELI",
104
+ REPO = "REPO",
105
+ RESI = "RESI",
106
+ RESN = "RESN",
107
+ RETI = "RETI",
108
+ RFN = "RFN",
109
+ RIN = "RIN",
110
+ ROLE = "ROLE",
111
+ SEX = "SEX",
112
+ SLGC = "SLGC",
113
+ SLGS = "SLGS",
114
+ SOUR = "SOUR",
115
+ SPFX = "SPFX",
116
+ SSN = "SSN",
117
+ STAE = "STAE",
118
+ STAT = "STAT",
119
+ SUBM = "SUBM",
120
+ SUBN = "SUBN",
121
+ SURN = "SURN",
122
+ TEMP = "TEMP",
123
+ TEXT = "TEXT",
124
+ TIME = "TIME",
125
+ TITL = "TITL",
126
+ TRLR = "TRLR",
127
+ TYPE = "TYPE",
128
+ VERS = "VERS",
129
+ WIFE = "WIFE",
130
+ WILL = "WILL"
131
+ }
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Identificator;
4
+ (function (Identificator) {
5
+ Identificator["ABBR"] = "ABBR";
6
+ Identificator["ADDR"] = "ADDR";
7
+ Identificator["ADR1"] = "ADDR1";
8
+ Identificator["ADR2"] = "ADDR2";
9
+ Identificator["ADOP"] = "ADOP";
10
+ Identificator["AFN"] = "AFN";
11
+ Identificator["AGE"] = "AGE";
12
+ Identificator["AGNC"] = "AGNC";
13
+ Identificator["ALIA"] = "ALIA";
14
+ Identificator["ANCE"] = "ANCE";
15
+ Identificator["ANCI"] = "ANCI";
16
+ Identificator["ANUL"] = "ANUL";
17
+ Identificator["ASSO"] = "ASSO";
18
+ Identificator["AUTH"] = "AUTH";
19
+ Identificator["BAPL"] = "BAPL";
20
+ Identificator["BAPM"] = "BAPM";
21
+ Identificator["BARM"] = "BARM";
22
+ Identificator["BASM"] = "BASM";
23
+ Identificator["BIRT"] = "BIRT";
24
+ Identificator["BLES"] = "BLES";
25
+ Identificator["BLOB"] = "BLOB";
26
+ Identificator["BURI"] = "BURI";
27
+ Identificator["CALN"] = "CALN";
28
+ Identificator["CAST"] = "CAST";
29
+ Identificator["CAUS"] = "CAUS";
30
+ Identificator["CENS"] = "CENS";
31
+ Identificator["CHAN"] = "CHAN";
32
+ Identificator["CHAR"] = "CHAR";
33
+ Identificator["CHIL"] = "CHIL";
34
+ Identificator["CHR"] = "CHR";
35
+ Identificator["CHRA"] = "CHRA";
36
+ Identificator["CITY"] = "CITY";
37
+ Identificator["CONC"] = "CONC";
38
+ Identificator["CONF"] = "CONF";
39
+ Identificator["CONL"] = "CONL";
40
+ Identificator["CONT"] = "CONT";
41
+ Identificator["COPR"] = "COPR";
42
+ Identificator["CORP"] = "CORP";
43
+ Identificator["CREM"] = "CREM";
44
+ Identificator["CTRY"] = "CTRY";
45
+ Identificator["DATA"] = "DATA";
46
+ Identificator["DATE"] = "DATE";
47
+ Identificator["DEAT"] = "DEAT";
48
+ Identificator["DESC"] = "DESC";
49
+ Identificator["DESI"] = "DESI";
50
+ Identificator["DEST"] = "DEST";
51
+ Identificator["DIV"] = "DIV";
52
+ Identificator["DIVF"] = "DIVF";
53
+ Identificator["DSCR"] = "DSCR";
54
+ Identificator["EDUC"] = "EDUC";
55
+ Identificator["EMIG"] = "EMIG";
56
+ Identificator["ENDL"] = "ENDL";
57
+ Identificator["ENGA"] = "ENGA";
58
+ Identificator["EVEN"] = "EVEN";
59
+ Identificator["FAM"] = "FAM";
60
+ Identificator["FAMC"] = "FAMC";
61
+ Identificator["FAMF"] = "FAMF";
62
+ Identificator["FAMS"] = "FAMS";
63
+ Identificator["FCOM"] = "FCOM";
64
+ Identificator["FILE"] = "FILE";
65
+ Identificator["FORM"] = "FORM";
66
+ Identificator["GEDC"] = "GEDC";
67
+ Identificator["GIVN"] = "GIVN";
68
+ Identificator["GRAD"] = "GRAD";
69
+ Identificator["HEAD"] = "HEAD";
70
+ Identificator["HUSB"] = "HUSB";
71
+ Identificator["IDNO"] = "IDNO";
72
+ Identificator["IMMI"] = "IMMI";
73
+ Identificator["INDI"] = "INDI";
74
+ Identificator["LANG"] = "LANG";
75
+ Identificator["LEGA"] = "LEGA";
76
+ Identificator["MARB"] = "MARB";
77
+ Identificator["MARC"] = "MARC";
78
+ Identificator["MARL"] = "MARL";
79
+ Identificator["MARR"] = "MARR";
80
+ Identificator["MARS"] = "MARS";
81
+ Identificator["MEDI"] = "MEDI";
82
+ Identificator["NAME"] = "NAME";
83
+ Identificator["NATI"] = "NATI";
84
+ Identificator["NATU"] = "NATU";
85
+ Identificator["NCHI"] = "NCHI";
86
+ Identificator["NICK"] = "NICK";
87
+ Identificator["NMR"] = "NMR";
88
+ Identificator["NOTE"] = "NOTE";
89
+ Identificator["NPFX"] = "NPFX";
90
+ Identificator["NSFX"] = "NSFX";
91
+ Identificator["OBJE"] = "OBJE";
92
+ Identificator["OCCU"] = "OCCU";
93
+ Identificator["ORDI"] = "ORDI";
94
+ Identificator["ORDN"] = "ORDN";
95
+ Identificator["PAGE"] = "PAGE";
96
+ Identificator["PEDI"] = "PEDI";
97
+ Identificator["PHON"] = "PHON";
98
+ Identificator["PLAC"] = "PLAC";
99
+ Identificator["POST"] = "POST";
100
+ Identificator["PROB"] = "PROB";
101
+ Identificator["PROP"] = "PROP";
102
+ Identificator["PUBL"] = "PUBL";
103
+ Identificator["QUAY"] = "QUAY";
104
+ Identificator["REFN"] = "REFN";
105
+ Identificator["RELA"] = "RELA";
106
+ Identificator["RELI"] = "RELI";
107
+ Identificator["REPO"] = "REPO";
108
+ Identificator["RESI"] = "RESI";
109
+ Identificator["RESN"] = "RESN";
110
+ Identificator["RETI"] = "RETI";
111
+ Identificator["RFN"] = "RFN";
112
+ Identificator["RIN"] = "RIN";
113
+ Identificator["ROLE"] = "ROLE";
114
+ Identificator["SEX"] = "SEX";
115
+ Identificator["SLGC"] = "SLGC";
116
+ Identificator["SLGS"] = "SLGS";
117
+ Identificator["SOUR"] = "SOUR";
118
+ Identificator["SPFX"] = "SPFX";
119
+ Identificator["SSN"] = "SSN";
120
+ Identificator["STAE"] = "STAE";
121
+ Identificator["STAT"] = "STAT";
122
+ Identificator["SUBM"] = "SUBM";
123
+ Identificator["SUBN"] = "SUBN";
124
+ Identificator["SURN"] = "SURN";
125
+ Identificator["TEMP"] = "TEMP";
126
+ Identificator["TEXT"] = "TEXT";
127
+ Identificator["TIME"] = "TIME";
128
+ Identificator["TITL"] = "TITL";
129
+ Identificator["TRLR"] = "TRLR";
130
+ Identificator["TYPE"] = "TYPE";
131
+ Identificator["VERS"] = "VERS";
132
+ Identificator["WIFE"] = "WIFE";
133
+ Identificator["WILL"] = "WILL";
134
+ })(Identificator = exports.Identificator || (exports.Identificator = {}));
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Act_1 = require("./Act");
4
+ const Identificator_enum_1 = require("./Identificator.enum");
5
+ const Utils_People_1 = require("./Utils-People");
6
+ const DateAct_1 = require("./DateAct");
7
+ var Sex;
8
+ (function (Sex) {
9
+ Sex["M"] = "M";
10
+ Sex["F"] = "F";
11
+ })(Sex = exports.Sex || (exports.Sex = {}));
12
+ class People {
13
+ constructor(sosa, sex, firstnames, lastname, birth, marriage, death, FAMC, FAMS, photo) {
14
+ this.sosa = sosa;
15
+ this.sex = sex;
16
+ this.firstnames = firstnames;
17
+ this.lastname = lastname;
18
+ this.photo = photo;
19
+ this.birth = birth;
20
+ this.marriage = marriage;
21
+ this.death = death;
22
+ this.FAMC = FAMC;
23
+ this.FAMS = FAMS;
24
+ }
25
+ createPeopleJson(peopleLines) {
26
+ const peoplesLinesWithoutCarriage = peopleLines.map(people => people.replace(/[\n\r]+/g, ''));
27
+ this.createFirstnamesAndLastnameJson(peoplesLinesWithoutCarriage);
28
+ this.createSex(peoplesLinesWithoutCarriage);
29
+ this.createFAM(peoplesLinesWithoutCarriage);
30
+ this.createPhoto(peoplesLinesWithoutCarriage);
31
+ this.birth = this.createBirthDeathAct(peoplesLinesWithoutCarriage, Identificator_enum_1.Identificator.BIRT);
32
+ this.death = this.createBirthDeathAct(peoplesLinesWithoutCarriage, Identificator_enum_1.Identificator.DEAT);
33
+ }
34
+ createFirstnamesAndLastnameJson(peopleLines) {
35
+ let lineName = peopleLines.find((information) => information ? information.startsWith('1 NAME') : false);
36
+ lineName = lineName ? lineName.replace('1 NAME', '').trim() : null;
37
+ const regex = /\/(.*?)\//;
38
+ const execLastName = regex.exec(lineName);
39
+ this.lastname = execLastName ? execLastName[1].trim().toUpperCase() : null;
40
+ lineName = execLastName && execLastName[0] ? lineName.replace(execLastName[0], '').trim() : lineName;
41
+ this.firstnames = lineName ? lineName.replace(new RegExp('"', 'g'), '').trim().split(' ') : null;
42
+ }
43
+ createSex(peopleLines) {
44
+ this.sex = Utils_People_1.findValueInLine(peopleLines, '1 SEX ') === Sex.M ? Sex.M : Sex.F;
45
+ }
46
+ // Enfant issu de la Famille (union de 2 parents)
47
+ createFAM(peopleLines) {
48
+ const numberPattern = /\d+/g;
49
+ const famc = Utils_People_1.findValueInLine(peopleLines, '1 FAMC ');
50
+ if (famc) {
51
+ this.FAMC = Number(famc.match(numberPattern));
52
+ }
53
+ const fams = Utils_People_1.findLinesConcernedByKeyword(peopleLines, '1 FAMS ').map(line => Number(line.match(numberPattern)));
54
+ if ((fams === null || fams === void 0 ? void 0 : fams.length) > 0) {
55
+ this.FAMS = (fams === null || fams === void 0 ? void 0 : fams.length) > 0 ? fams : [];
56
+ }
57
+ }
58
+ createPhoto(peopleLines) {
59
+ const photoUrl = Utils_People_1.findValueInLine(peopleLines, '2 FILE ');
60
+ if (photoUrl) {
61
+ this.photo = photoUrl;
62
+ }
63
+ }
64
+ createBirthDeathAct(peopleLines, identificator) {
65
+ const idxBegin = peopleLines.findIndex((lineInformation) => lineInformation.startsWith(`1 ${identificator}`));
66
+ const startArray = peopleLines.slice(idxBegin + 1);
67
+ const idxEnd = startArray.findIndex((lineInformation) => lineInformation.startsWith('1 '));
68
+ const finalArray = idxEnd >= 0 ? startArray.slice(0, idxEnd) : startArray;
69
+ return new Act_1.Act(new DateAct_1.DateAct(Utils_People_1.findValueInLine(finalArray, '2 DATE ')), Utils_People_1.findValueInLine(finalArray, '2 PLAC '));
70
+ }
71
+ }
72
+ exports.People = People;
73
+ class TreePeople extends People {
74
+ constructor(people, parents, childrens, currentSosa) {
75
+ super(currentSosa, people.sex, people.firstnames, people.lastname, people.birth, people.marriage, people.death, people.FAMC, people.FAMS);
76
+ this.parents = parents;
77
+ this.childrens = childrens;
78
+ }
79
+ }
80
+ exports.TreePeople = TreePeople;
@@ -0,0 +1,14 @@
1
+ export declare class Place {
2
+ city: string;
3
+ zip: number;
4
+ county: string;
5
+ region: string;
6
+ country: string;
7
+ coordinate: CoordinateGPS;
8
+ constructor(city?: string, zip?: number, county?: string, region?: string, country?: string, coordinate?: CoordinateGPS);
9
+ }
10
+ export declare class CoordinateGPS {
11
+ latitude: number;
12
+ longitude: number;
13
+ constructor(latitude: number, longitude: number);
14
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Place {
4
+ constructor(city, zip, county, region, country, coordinate) {
5
+ this.city = city;
6
+ this.zip = zip;
7
+ this.county = county;
8
+ this.region = region;
9
+ this.country = country.toUpperCase();
10
+ this.coordinate = coordinate;
11
+ }
12
+ }
13
+ exports.Place = Place;
14
+ class CoordinateGPS {
15
+ constructor(latitude, longitude) {
16
+ this.latitude = latitude;
17
+ this.longitude = longitude;
18
+ }
19
+ }
20
+ exports.CoordinateGPS = CoordinateGPS;
@@ -0,0 +1,3 @@
1
+ export declare enum Separators {
2
+ CARRIAGE_RETURN = "\n"
3
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var Separators;
4
+ (function (Separators) {
5
+ Separators["CARRIAGE_RETURN"] = "\n";
6
+ })(Separators = exports.Separators || (exports.Separators = {}));
@@ -0,0 +1,6 @@
1
+ export declare class ConvertStringToDate {
2
+ private monthMapping;
3
+ private dateString;
4
+ constructor(dateString: string);
5
+ get toDate(): Date | undefined;
6
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ConvertStringToDate {
4
+ constructor(dateString) {
5
+ this.monthMapping = {
6
+ JAN: 0,
7
+ FEB: 1,
8
+ MAR: 2,
9
+ APR: 3,
10
+ MAY: 4,
11
+ JUN: 5,
12
+ JUL: 6,
13
+ AUG: 7,
14
+ SEP: 8,
15
+ OCT: 9,
16
+ NOV: 10,
17
+ DEC: 11
18
+ };
19
+ this.dateString = dateString;
20
+ }
21
+ get toDate() {
22
+ const regex = /^(\w+\s)?(\d{1,2})?\s?([A-Za-z]+)?\s?(\d{4})?$/;
23
+ const match = this.dateString.match(regex);
24
+ if (match) {
25
+ const prefix = match[1];
26
+ const day = match[1];
27
+ const monthStr = match[3];
28
+ const year = match[4];
29
+ console.log(match);
30
+ if (year) {
31
+ if (monthStr) {
32
+ if (day) {
33
+ return new Date(parseInt(year), this.monthMapping[monthStr], parseInt(day));
34
+ }
35
+ return new Date(parseInt(year), this.monthMapping[monthStr], 1);
36
+ }
37
+ return new Date(parseInt(year), 0, 1);
38
+ }
39
+ }
40
+ return undefined;
41
+ }
42
+ }
43
+ exports.ConvertStringToDate = ConvertStringToDate;
@@ -0,0 +1,2 @@
1
+ export declare const findValueInLine: (lines: string[], keyword: any) => string;
2
+ export declare const findLinesConcernedByKeyword: (lines: string[], keyword: any) => string[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findValueInLine = (lines, keyword) => {
4
+ const line = lines.find((lineInformation) => lineInformation.startsWith(keyword));
5
+ return line ? line.replace(keyword, '') : null;
6
+ };
7
+ exports.findLinesConcernedByKeyword = (lines, keyword) => {
8
+ return [...lines]
9
+ .filter(line => line.startsWith(keyword))
10
+ .map(line => line.replace(keyword, ''));
11
+ };
@@ -0,0 +1,2 @@
1
+ export declare class Utils {
2
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class Utils {
4
+ }
5
+ exports.Utils = Utils;
@@ -0,0 +1,42 @@
1
+ import { Separators } from '../commons/Separators';
2
+ import { People } from '../commons/People';
3
+ import { Act } from '../commons/Act';
4
+ import { Identificator } from '../commons/Identificator.enum';
5
+ export declare class ExportFormatFile {
6
+ title: string;
7
+ extension: string;
8
+ constructor(title: string);
9
+ export(data: any): void;
10
+ }
11
+ export declare class GEDCOM extends ExportFormatFile {
12
+ peoples: Array<People>;
13
+ constructor(title: string, peoples: Array<People>);
14
+ get beginGedcom(): string;
15
+ get contentGedcom(): string;
16
+ download(): void;
17
+ }
18
+ export declare class LineGedcom {
19
+ cr: Separators;
20
+ }
21
+ export declare class PeopleLine extends LineGedcom {
22
+ sosa: number;
23
+ fams?: number[];
24
+ famc?: number;
25
+ firstnames: Array<string>;
26
+ lastnames: string;
27
+ constructor(sosa: number, firstnames: Array<string>, lastnames: string, fams: number[], famc: number);
28
+ get indi(): string;
29
+ get famsLine(): string;
30
+ get famcLine(): string | null;
31
+ get firstnamesAndNames(): string;
32
+ get sex(): string;
33
+ }
34
+ export declare class ActLine extends LineGedcom {
35
+ type: Identificator;
36
+ act: Act;
37
+ constructor(type: Identificator, act: Act);
38
+ get typeLine(): string;
39
+ get dateLine(): string;
40
+ get placeLine(): string;
41
+ private formatDate;
42
+ }
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Separators_1 = require("../commons/Separators");
4
+ const People_1 = require("../commons/People");
5
+ const Identificator_enum_1 = require("../commons/Identificator.enum");
6
+ class ExportFormatFile {
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
+ exports.ExportFormatFile = ExportFormatFile;
18
+ class GEDCOM extends ExportFormatFile {
19
+ constructor(title, peoples) {
20
+ super(title);
21
+ this.extension = '.ged';
22
+ this.peoples = peoples;
23
+ }
24
+ get beginGedcom() {
25
+ const cr = Separators_1.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_1.Separators.CARRIAGE_RETURN;
51
+ if (this.peoples && this.peoples.length > 0) {
52
+ this.peoples.forEach((people) => {
53
+ var _a, _b, _c, _d, _e;
54
+ const firstnames = (_a = people.firstnames) !== null && _a !== void 0 ? _a : [];
55
+ const peopleLine = new PeopleLine(people.sosa, [...firstnames], people.lastname, people.FAMS, people.FAMC);
56
+ // sosa
57
+ content += peopleLine.indi;
58
+ if (peopleLine.famsLine) {
59
+ content += peopleLine.famsLine;
60
+ }
61
+ if (peopleLine.famcLine) {
62
+ content += peopleLine.famcLine;
63
+ }
64
+ // prénom et nom
65
+ content += peopleLine.firstnamesAndNames;
66
+ // sex
67
+ content += peopleLine.sex;
68
+ // birth
69
+ if (people.birth && (((_b = people.birth.dateAct) === null || _b === void 0 ? void 0 : _b.date) || people.birth.place)) {
70
+ const actLine = new ActLine(Identificator_enum_1.Identificator.BIRT, people.birth);
71
+ content += actLine.typeLine;
72
+ if ((_c = people.birth.dateAct) === null || _c === void 0 ? void 0 : _c.date) {
73
+ content += actLine.dateLine;
74
+ }
75
+ if (people.birth.place) {
76
+ content += actLine.placeLine;
77
+ }
78
+ }
79
+ if (people.death && (((_d = people.death.dateAct) === null || _d === void 0 ? void 0 : _d.date) || people.death.place)) {
80
+ const actLine = new ActLine(Identificator_enum_1.Identificator.DEAT, people.death);
81
+ content += actLine.typeLine;
82
+ if ((_e = people.death.dateAct) === null || _e === void 0 ? void 0 : _e.date) {
83
+ content += actLine.dateLine;
84
+ }
85
+ if (people.death.place) {
86
+ content += actLine.placeLine;
87
+ }
88
+ }
89
+ });
90
+ // content += 'toto' + cr;
91
+ }
92
+ return content;
93
+ }
94
+ download() {
95
+ const ged = `data:text/ged;charset=utf-8,${this.beginGedcom}${this.contentGedcom}${Identificator_enum_1.Identificator.TRLR}`;
96
+ const data = encodeURI(ged);
97
+ this.export(data);
98
+ }
99
+ }
100
+ exports.GEDCOM = GEDCOM;
101
+ class LineGedcom {
102
+ constructor() {
103
+ this.cr = Separators_1.Separators.CARRIAGE_RETURN;
104
+ }
105
+ }
106
+ exports.LineGedcom = LineGedcom;
107
+ class PeopleLine extends LineGedcom {
108
+ constructor(sosa, firstnames, lastnames, fams, famc) {
109
+ super();
110
+ this.sosa = sosa;
111
+ this.firstnames = firstnames;
112
+ this.lastnames = lastnames !== null && lastnames !== void 0 ? lastnames : '';
113
+ this.fams = (fams === null || fams === void 0 ? void 0 : 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 ? People_1.Sex.F : People_1.Sex.M}${this.cr}`;
155
+ }
156
+ return '';
157
+ }
158
+ }
159
+ exports.PeopleLine = PeopleLine;
160
+ class ActLine extends LineGedcom {
161
+ constructor(type, act) {
162
+ super();
163
+ this.type = type;
164
+ this.act = act;
165
+ }
166
+ get typeLine() {
167
+ return `1 ${this.type}${this.cr}`;
168
+ }
169
+ get dateLine() {
170
+ var _a, _b;
171
+ if ((_b = (_a = this.act) === null || _a === void 0 ? void 0 : _a.dateAct) === null || _b === void 0 ? void 0 : _b.date) {
172
+ const options = { day: '2-digit', month: 'short', year: 'numeric' };
173
+ return `2 ${Identificator_enum_1.Identificator.DATE} ${this.formatDate(this.act.dateAct)}${this.cr}`;
174
+ }
175
+ return '';
176
+ }
177
+ get placeLine() {
178
+ var _a, _b;
179
+ if (((_b = (_a = this.act) === null || _a === void 0 ? void 0 : _a.place) === null || _b === void 0 ? void 0 : _b.length) > 0) {
180
+ return `2 ${Identificator_enum_1.Identificator.PLAC} ${this.act.place}${this.cr}`;
181
+ }
182
+ return '';
183
+ }
184
+ formatDate(dateAct) {
185
+ if (dateAct.date) {
186
+ return `${dateAct.day ? `${dateAct.day} ` : ''}${dateAct.month ? `${dateAct.month} ` : ''}${dateAct.year ? `${dateAct.year}` : ''}`;
187
+ }
188
+ return '';
189
+ }
190
+ }
191
+ exports.ActLine = ActLine;
@@ -0,0 +1,19 @@
1
+ import { People } from '../commons/People';
2
+ export declare class ReadGed {
3
+ gedcom: string;
4
+ peoples: People[];
5
+ partnersMap: Map<number, People[]>;
6
+ childsMap: Map<number, People[]>;
7
+ constructor(gedcom: string);
8
+ get informationHeadFile(): string;
9
+ get informationPeoplesFile(): string[];
10
+ get informationMarriagesFile(): string[];
11
+ private get separate();
12
+ import(): People[];
13
+ groupPartners(): void;
14
+ createDirectAncestries(people: People): People[];
15
+ private haveParentsOfPeople;
16
+ }
17
+ export declare class Create {
18
+ static json(peoplesFile: string[], marriagesFile: string[]): People[];
19
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const People_1 = require("../commons/People");
4
+ class ReadGed {
5
+ constructor(gedcom) {
6
+ this.gedcom = gedcom;
7
+ this.peoples = this.import();
8
+ this.partnersMap = new Map();
9
+ this.childsMap = new Map();
10
+ this.groupPartners();
11
+ }
12
+ get informationHeadFile() {
13
+ if (this.separate) {
14
+ return this.separate.find((information) => information.startsWith('0 HEAD'));
15
+ }
16
+ return null;
17
+ }
18
+ get informationPeoplesFile() {
19
+ if (this.separate) {
20
+ return this.separate.filter((information) => information.startsWith('0 @I'));
21
+ }
22
+ return null;
23
+ }
24
+ get informationMarriagesFile() {
25
+ if (this.separate) {
26
+ return this.separate.filter((information) => information.startsWith('0 @F'));
27
+ }
28
+ return null;
29
+ }
30
+ get separate() {
31
+ const splitGedcom = this.gedcom.split('\n0 ');
32
+ return splitGedcom.map((split) => split.startsWith('0') ? split : `0 ${split}`);
33
+ }
34
+ import() {
35
+ return Create.json(this.informationPeoplesFile, this.informationMarriagesFile);
36
+ }
37
+ groupPartners() {
38
+ [...this.peoples].forEach(people => {
39
+ var _a;
40
+ if (((_a = people.FAMS) === null || _a === void 0 ? void 0 : _a.length) > 0) {
41
+ people.FAMS.forEach(oneFams => {
42
+ let partners = [people];
43
+ if (this.partnersMap.has(oneFams)) {
44
+ partners = [...partners, ...this.partnersMap.get(oneFams)];
45
+ }
46
+ this.partnersMap.set(oneFams, partners);
47
+ });
48
+ }
49
+ if (people.FAMC) {
50
+ let allChilds = [people];
51
+ if (this.childsMap.has(people.FAMC)) {
52
+ allChilds = [...allChilds, ...this.childsMap.get(people.FAMC)];
53
+ }
54
+ this.childsMap.set(people.FAMC, allChilds);
55
+ }
56
+ });
57
+ }
58
+ createDirectAncestries(people) {
59
+ return this.haveParentsOfPeople(people, [])
60
+ .sort((a, b) => a.sosa - b.sosa);
61
+ }
62
+ haveParentsOfPeople(people, directAncestries, sosaChild) {
63
+ const copyPeople = Object.assign({}, people);
64
+ copyPeople.sosa = !sosaChild ? 1 : (sosaChild * 2) + (people.sex === People_1.Sex.F ? 1 : 0);
65
+ if (this.partnersMap.has(copyPeople.FAMC)) {
66
+ const parents = [...this.partnersMap.get(copyPeople.FAMC)];
67
+ if (parents && parents.length > 0) {
68
+ parents.forEach(parent => {
69
+ this.haveParentsOfPeople(parent, directAncestries, copyPeople.sosa);
70
+ });
71
+ }
72
+ }
73
+ directAncestries.push(copyPeople);
74
+ return directAncestries;
75
+ }
76
+ }
77
+ exports.ReadGed = ReadGed;
78
+ class Create {
79
+ static json(peoplesFile, marriagesFile) {
80
+ if (peoplesFile && peoplesFile.length > 0) {
81
+ return peoplesFile
82
+ .map((peopleFile) => {
83
+ const peopleLines = peopleFile.split('\n');
84
+ const newPeopleJson = new People_1.People();
85
+ newPeopleJson.createPeopleJson(peopleLines);
86
+ return newPeopleJson;
87
+ })
88
+ .sort((n1, n2) => n1.FAMC - n2.FAMC);
89
+ }
90
+ return null;
91
+ }
92
+ }
93
+ exports.Create = Create;
@@ -0,0 +1,6 @@
1
+ export { People } from "./commons/People";
2
+ export { Act } from "./commons/Act";
3
+ export { Place } from "./commons/Place";
4
+ export { Identificator } from "./commons/Identificator.enum";
5
+ export { GEDCOM } from "./export/GEDCOM";
6
+ export { ReadGed } from "./import/ReadGed";
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var People_1 = require("./commons/People");
4
+ exports.People = People_1.People;
5
+ var Act_1 = require("./commons/Act");
6
+ exports.Act = Act_1.Act;
7
+ var Place_1 = require("./commons/Place");
8
+ exports.Place = Place_1.Place;
9
+ var Identificator_enum_1 = require("./commons/Identificator.enum");
10
+ exports.Identificator = Identificator_enum_1.Identificator;
11
+ var GEDCOM_1 = require("./export/GEDCOM");
12
+ exports.GEDCOM = GEDCOM_1.GEDCOM;
13
+ var ReadGed_1 = require("./import/ReadGed");
14
+ exports.ReadGed = ReadGed_1.ReadGed;
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "gedcom-ts",
3
+ "version": "1.1.0",
4
+ "description": "A TypeScript library to create genealogy tree data model and to import/export data in a GEDCOM file (.ged).",
5
+ "author": "Bertrand Jaunet <bertrand.jaunet@gmail.com>",
6
+ "license": "proprietary",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "scripts": {
10
+ "pack": "tsc && npm pack",
11
+ "test": "jest"
12
+ },
13
+ "devDependencies": {
14
+ "@types/jest": "^25.1.3",
15
+ "@types/node": "^13.9.0",
16
+ "jest": "^25.1.0",
17
+ "ts-jest": "^25.2.1",
18
+ "typescript": "^3.8.3"
19
+ },
20
+ "keywords": [
21
+ "genealogy",
22
+ "gedcom",
23
+ ".ged",
24
+ "tree",
25
+ "typescript",
26
+ "front-end",
27
+ "web"
28
+ ]
29
+ }
@@ -0,0 +1,28 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ entry: './src/index.ts',
5
+ devtool: 'inline-source-map',
6
+ module: {
7
+ rules: [
8
+ {
9
+ test: /\.tsx?$/,
10
+ use: 'ts-loader',
11
+ exclude: /node_modules/,
12
+ },
13
+ ],
14
+ },
15
+ resolve: {
16
+ extensions: [ '.tsx', '.ts', '.js' ],
17
+ },
18
+ output: {
19
+ filename: 'bundle.js',
20
+ path: path.resolve(__dirname, 'dist'),
21
+ },
22
+ node: {
23
+ console: 'empty',
24
+ fs: 'empty',
25
+ net: 'empty',
26
+ tls: 'empty'
27
+ }
28
+ };