@ygracs/xepg-lib-js 0.0.15 → 0.0.16
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 +135 -0
- package/LICENSE +1 -1
- package/index.js +1 -1
- package/lib/dts-helper.js +25 -3
- package/lib/xepgdoc-lib.js +57 -23
- package/package.json +13 -9
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#### *v0.0.16*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - updated dependency on `@ygracs/xobj-lib-js` module to v0.0.14-rc3;
|
|
6
|
+
> - updated dependency on `@ygracs/dtf-lib-js` module to v0.0.21.
|
|
7
|
+
> - added `getDTSysDescr` function into `dts-helper.js` lib-module;
|
|
8
|
+
> - some fixes in `dts-helper.js` lib-module;
|
|
9
|
+
> - some fixes in `xepgdoc-lib.js` module.
|
|
10
|
+
|
|
11
|
+
#### *v0.0.15*
|
|
12
|
+
|
|
13
|
+
Pre-release version.
|
|
14
|
+
|
|
15
|
+
> - `xepgdoc-spec.md` updated;
|
|
16
|
+
> - `xepgdoc-lib.md` updated;
|
|
17
|
+
> - removed property `SchedulesQty` for `TXEpgSchedulesList` class;
|
|
18
|
+
> - some changes upon a class constructor options (deprecated settings which sets the rules of an element tag naming).
|
|
19
|
+
|
|
20
|
+
#### *v0.0.14*
|
|
21
|
+
|
|
22
|
+
Pre-release version.
|
|
23
|
+
|
|
24
|
+
> - added dependency on `@ygracs/dtf-lib-js` module;
|
|
25
|
+
> - `$module/lib/dts-helper.js` updated;
|
|
26
|
+
> - `$module/lib/xepgdoc-lib.js` updated;
|
|
27
|
+
> - `$module/lib/dtFunc.js` removed.
|
|
28
|
+
|
|
29
|
+
#### *v0.0.13*
|
|
30
|
+
|
|
31
|
+
Pre-release version.
|
|
32
|
+
|
|
33
|
+
> - updated `dtFunc.js` lib-module to v0.1.019-20220903;
|
|
34
|
+
> - updated dependency on `@ygracs/xobj-lib-js` module to v0.0.13;
|
|
35
|
+
> - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.1.2.
|
|
36
|
+
|
|
37
|
+
#### *v0.0.12*
|
|
38
|
+
|
|
39
|
+
Pre-release version.
|
|
40
|
+
|
|
41
|
+
> - switch dependency from `@cntwg/xml-lib-js` module to `@ygracs/xobj-lib-js` module;
|
|
42
|
+
> - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.1.1.
|
|
43
|
+
|
|
44
|
+
#### *v0.0.11*
|
|
45
|
+
|
|
46
|
+
Pre-release version.
|
|
47
|
+
|
|
48
|
+
> - `xepgdoc-lib.md` updated;
|
|
49
|
+
> - some fixes in `dts-helper.js` lib-module;
|
|
50
|
+
> - some fixes in `dtFunc.js` lib-module;
|
|
51
|
+
> - some fixes in `xepgdoc-lib.js` module;
|
|
52
|
+
> - add property `schedQty` to `TXEpgSchedulesList` class;
|
|
53
|
+
> - add property `dts` to `TXEpgHeaderContainer` class;
|
|
54
|
+
> - add property `dts` to `TXEpgContentContainer` class;
|
|
55
|
+
> - add `TXepgDTSProvider` class;
|
|
56
|
+
> - deprecate property `SchedulesQty` of `TXEpgSchedulesList` class.
|
|
57
|
+
|
|
58
|
+
#### *v0.0.10*
|
|
59
|
+
|
|
60
|
+
Pre-release version.
|
|
61
|
+
|
|
62
|
+
> - some fixes in `xepgdoc-lib.js` module.
|
|
63
|
+
|
|
64
|
+
#### *v0.0.9*
|
|
65
|
+
|
|
66
|
+
Pre-release version.
|
|
67
|
+
|
|
68
|
+
> - `xepgdoc-lib.md` updated;
|
|
69
|
+
> - `xepgdoc-spec.md` updated;
|
|
70
|
+
> - some fixes in `xepgdoc-lib.js` module;
|
|
71
|
+
> - some fixes in `dtFunc.js` module;
|
|
72
|
+
> - `$module/lib/dts-helper.js` added;
|
|
73
|
+
> - move module `xepgdoc-lib-v2.js` to its own project;
|
|
74
|
+
> - updated dependency on `@cntwg/xml-lib-js` module to v0.0.13;
|
|
75
|
+
> - updated dependency on `@ygracs/xml-js6` module to v0.0.3b.
|
|
76
|
+
|
|
77
|
+
#### *v0.0.8*
|
|
78
|
+
|
|
79
|
+
Pre-release version.
|
|
80
|
+
|
|
81
|
+
> - updated dependency on `@cntwg/xml-lib-js` module to v0.0.10;
|
|
82
|
+
> - switch dependency from `@cntwg/bsfoc-lib-js` module to `@ygracs/bsfoc-lib-js` module.
|
|
83
|
+
|
|
84
|
+
#### *v0.0.7*
|
|
85
|
+
|
|
86
|
+
Pre-release version.
|
|
87
|
+
|
|
88
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.11;
|
|
89
|
+
> - updated dependency on `@cntwg/xml-lib-js` module to v0.0.9.
|
|
90
|
+
|
|
91
|
+
#### *v0.0.6*
|
|
92
|
+
|
|
93
|
+
Pre-release version.
|
|
94
|
+
|
|
95
|
+
> - some fixes in `xepgdoc-lib.js` module.
|
|
96
|
+
|
|
97
|
+
#### *v0.0.5*
|
|
98
|
+
|
|
99
|
+
Pre-release version.
|
|
100
|
+
|
|
101
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.8;
|
|
102
|
+
> - updated dependency on `@cntwg/xml-lib-js` module to v0.0.8;
|
|
103
|
+
> - add method `loadFromFileSync` to `TXEpgContentProvider` (v1);
|
|
104
|
+
> - add method `saveToFileSync` to `TXEpgContentProvider` (v1);
|
|
105
|
+
> - some fixes in `xepgdoc-lib.js` module;
|
|
106
|
+
> - `$module/lib/xepgdoc-lib-v2.js` added;
|
|
107
|
+
> - `xepgdoc-lib-v2.md` added;
|
|
108
|
+
> - `xepgdoc-spec.md` added.
|
|
109
|
+
|
|
110
|
+
#### *v0.0.4*
|
|
111
|
+
|
|
112
|
+
Pre-release version.
|
|
113
|
+
|
|
114
|
+
> - removed class `TXEpgContentBodyContainer` from `xepgdoc-lib.js` module;
|
|
115
|
+
> - merdged class `TXEpgContentContainer` into `TXEpgContentProvider`;
|
|
116
|
+
> - `xepgdoc-lib.md` added.
|
|
117
|
+
|
|
118
|
+
#### *v0.0.3*
|
|
119
|
+
|
|
120
|
+
Pre-release version.
|
|
121
|
+
|
|
122
|
+
> - updated dependency on `@cntwg/xml-lib-js` module to v0.0.7;
|
|
123
|
+
> - renamed class `TXEpgScheduleContainer` to `TXEpgSchedulesList`;
|
|
124
|
+
> - `xepgdoc-lib.md` added;
|
|
125
|
+
> - MIT-license applied.
|
|
126
|
+
|
|
127
|
+
#### *v0.0.2*
|
|
128
|
+
|
|
129
|
+
Pre-release version.
|
|
130
|
+
|
|
131
|
+
> - fixed some errors in `xepgdoc-lib.js` module.
|
|
132
|
+
|
|
133
|
+
#### *v0.0.1*
|
|
134
|
+
|
|
135
|
+
Pre-release version.
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2019-
|
|
3
|
+
Copyright (c) 2019-2023 Yuri Grachev
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/index.js
CHANGED
package/lib/dts-helper.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.042-20230326]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
valueToIndex, readAsString, readAsNumberEx,
|
|
7
|
+
isDateObject,
|
|
7
8
|
} = require('@ygracs/bsfoc-lib-js');
|
|
8
9
|
|
|
9
10
|
const {
|
|
@@ -33,6 +34,22 @@ function getDTSysName(value){
|
|
|
33
34
|
return result;
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
function getDTSysDescr(value){
|
|
38
|
+
let index = valueToIndex(value);
|
|
39
|
+
let name = 'undefined';
|
|
40
|
+
if (index !== -1) {
|
|
41
|
+
let result = def_dts_param[index];
|
|
42
|
+
if (result) name = result;
|
|
43
|
+
} else if (typeof value === 'string') {
|
|
44
|
+
let result = value.trim();
|
|
45
|
+
if (result !== '') {
|
|
46
|
+
index = def_dts_param.indexOf(result);
|
|
47
|
+
if (index !== -1) name = result;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
return { index, name };
|
|
51
|
+
};
|
|
52
|
+
|
|
36
53
|
function convStringToDTValue(value, dts_id, tz){
|
|
37
54
|
let result = 0;
|
|
38
55
|
let dtstype = valueToIndex(dts_id);
|
|
@@ -84,9 +101,13 @@ function convStringToDTValue(value, dts_id, tz){
|
|
|
84
101
|
|
|
85
102
|
function convDTValueToString(value, dts_id, tz){
|
|
86
103
|
let result = '';
|
|
87
|
-
let
|
|
88
|
-
|
|
104
|
+
let dt_val = (
|
|
105
|
+
isDateObject(value)
|
|
106
|
+
? value
|
|
107
|
+
: (new Date(readAsNumberEx(value, 0)))
|
|
108
|
+
).getTime();
|
|
89
109
|
if (Number.isNaN(dt_val)) dt_val = new Date(0);
|
|
110
|
+
let dtstype = valueToIndex(dts_id);
|
|
90
111
|
if (!chkDTSysID(dtstype)) dtstype = 0;
|
|
91
112
|
switch (getDTSysName(dtstype)) {
|
|
92
113
|
case 'default':
|
|
@@ -137,5 +158,6 @@ function convDTValueToString(value, dts_id, tz){
|
|
|
137
158
|
exports.chkDTSysID = chkDTSysID;
|
|
138
159
|
exports.checkDTSysID = chkDTSysID;
|
|
139
160
|
exports.getDTSysName = getDTSysName;
|
|
161
|
+
exports.getDTSysDescr = getDTSysDescr;
|
|
140
162
|
exports.convStringToDTValue = convStringToDTValue;
|
|
141
163
|
exports.convDTValueToString = convDTValueToString;
|
package/lib/xepgdoc-lib.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.054-20230326]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@ const {
|
|
|
18
18
|
} = require('@ygracs/dtf-lib-js');
|
|
19
19
|
|
|
20
20
|
const {
|
|
21
|
-
chkDTSysID, getDTSysName,
|
|
21
|
+
chkDTSysID, getDTSysName, getDTSysDescr,
|
|
22
22
|
convStringToDTValue, convDTValueToString,
|
|
23
23
|
} = require('./dts-helper.js');
|
|
24
24
|
|
|
@@ -277,7 +277,11 @@ class TXEpgProviderContainer {
|
|
|
277
277
|
set version(value){
|
|
278
278
|
if (this.name !== '') {
|
|
279
279
|
const _value = typeof value === 'string' ? value.trim() : '';
|
|
280
|
-
const item = insertXObjElement(
|
|
280
|
+
const item = insertXObjElement(
|
|
281
|
+
this.#_content,
|
|
282
|
+
'version',
|
|
283
|
+
{ force: true },
|
|
284
|
+
);
|
|
281
285
|
if (item) writeXObjParam(item, _value);
|
|
282
286
|
};
|
|
283
287
|
}
|
|
@@ -288,7 +292,11 @@ class TXEpgProviderContainer {
|
|
|
288
292
|
|
|
289
293
|
set schema(value){
|
|
290
294
|
const _value = typeof value === 'string' ? value.trim() : '';
|
|
291
|
-
const item = insertXObjElement(
|
|
295
|
+
const item = insertXObjElement(
|
|
296
|
+
this.#_content,
|
|
297
|
+
XEPG_DOCSCH_ETAG_NAME,
|
|
298
|
+
{ force: true },
|
|
299
|
+
);
|
|
292
300
|
if (item) writeXObjParam(item, _value);
|
|
293
301
|
}
|
|
294
302
|
|
|
@@ -298,13 +306,17 @@ class TXEpgProviderContainer {
|
|
|
298
306
|
|
|
299
307
|
set doctype(value){
|
|
300
308
|
const _value = typeof value === 'string' ? value.trim() : '';
|
|
301
|
-
const item = insertXObjElement(
|
|
309
|
+
const item = insertXObjElement(
|
|
310
|
+
this.#_content,
|
|
311
|
+
XEPG_DOCTYP_ETAG_NAME,
|
|
312
|
+
{ force: true },
|
|
313
|
+
);
|
|
302
314
|
if (item) writeXObjParam(item, _value);
|
|
303
315
|
}
|
|
304
316
|
|
|
305
317
|
setName(value){
|
|
306
318
|
let isSUCCEED = false;
|
|
307
|
-
let item = insertXObjElement(this.#_content, 'name', true);
|
|
319
|
+
let item = insertXObjElement(this.#_content, 'name', { force: true });
|
|
308
320
|
if (item) {
|
|
309
321
|
const name = typeof value === 'string' ? value.trim() : '';
|
|
310
322
|
isSUCCEED = writeXObjParam(item, name);
|
|
@@ -413,14 +425,22 @@ class TXepgDTSProvider {
|
|
|
413
425
|
}
|
|
414
426
|
|
|
415
427
|
set dtstype(value){
|
|
416
|
-
|
|
417
|
-
|
|
428
|
+
let { index, name } = getDTSysDescr(value);
|
|
429
|
+
if (index !== -1) {
|
|
430
|
+
const item = insertXObjElement(
|
|
431
|
+
this.#_content,
|
|
432
|
+
XEPG_DTSINFO_ETAG_NAME,
|
|
433
|
+
{ force: true },
|
|
434
|
+
);
|
|
418
435
|
if (item) {
|
|
419
|
-
let
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
436
|
+
let curItem = insertXObjElement(item, 'value', { force: true });
|
|
437
|
+
if (
|
|
438
|
+
curItem
|
|
439
|
+
&& writeXObjParam(curItem, index)
|
|
440
|
+
&& (curItem = insertXObjElement(item, 'name', { force: true }))
|
|
441
|
+
) {
|
|
442
|
+
writeXObjParam(curItem, name);
|
|
443
|
+
};
|
|
424
444
|
};
|
|
425
445
|
};
|
|
426
446
|
}
|
|
@@ -432,8 +452,15 @@ class TXepgDTSProvider {
|
|
|
432
452
|
}
|
|
433
453
|
|
|
434
454
|
set curDocTZ(value){
|
|
435
|
-
let
|
|
436
|
-
if (
|
|
455
|
+
let _value = convValueToTZString(value);
|
|
456
|
+
if (_value !== '') {
|
|
457
|
+
let item = insertXObjElement(
|
|
458
|
+
this.#_content,
|
|
459
|
+
XEPG_DOCTZ_ETAG_NAME,
|
|
460
|
+
{ force: true },
|
|
461
|
+
);
|
|
462
|
+
if (item) writeXObjParam(item, _value);
|
|
463
|
+
};
|
|
437
464
|
}
|
|
438
465
|
|
|
439
466
|
};
|
|
@@ -516,9 +543,12 @@ class TXEpgHeaderContainer {
|
|
|
516
543
|
}
|
|
517
544
|
|
|
518
545
|
setDocumentDT(){
|
|
519
|
-
let
|
|
520
|
-
let
|
|
521
|
-
|
|
546
|
+
let dt_str = convDTValueToString(Date.now(), this.dtstype, this.curDocTZ);
|
|
547
|
+
let item = insertXObjElement(
|
|
548
|
+
this.#_content,
|
|
549
|
+
XEPG_DOCDTO_ETAG_NAME,
|
|
550
|
+
{ force: true },
|
|
551
|
+
);
|
|
522
552
|
if (item) writeXObjParam(item, dt_str);
|
|
523
553
|
}
|
|
524
554
|
|
|
@@ -534,7 +564,11 @@ class TXEpgHeaderContainer {
|
|
|
534
564
|
setDocumentEDT(value){
|
|
535
565
|
// TODO: check if value is a DateTime-string
|
|
536
566
|
let dt_str = convDTValueToString(value, this.dtstype, this.curDocTZ);
|
|
537
|
-
let item = insertXObjElement(
|
|
567
|
+
let item = insertXObjElement(
|
|
568
|
+
this.#_content,
|
|
569
|
+
XEPG_DOCDTE_ETAG_NAME,
|
|
570
|
+
{ force: true },
|
|
571
|
+
);
|
|
538
572
|
if (item) writeXObjParam(item, dt_str);
|
|
539
573
|
}
|
|
540
574
|
|
|
@@ -583,13 +617,13 @@ class TXEpgHeaderContainer {
|
|
|
583
617
|
};
|
|
584
618
|
let item = null;
|
|
585
619
|
const _content = this.#_content;
|
|
586
|
-
item = insertXObjElement(_content, XEPG_CHNID_ETAG_NAME, true);
|
|
620
|
+
item = insertXObjElement(_content, XEPG_CHNID_ETAG_NAME, { force: true });
|
|
587
621
|
if (item) writeXObjParam(item, chnid);
|
|
588
|
-
item = insertXObjElement(_content, XEPG_CHNNAME_ETAG_NAME, true);
|
|
622
|
+
item = insertXObjElement(_content, XEPG_CHNNAME_ETAG_NAME, { force: true });
|
|
589
623
|
if (item) writeXObjParam(item, chname);
|
|
590
|
-
item = insertXObjElement(_content, XEPG_CHNGID_ETAG_NAME, true);
|
|
624
|
+
item = insertXObjElement(_content, XEPG_CHNGID_ETAG_NAME, { force: true });
|
|
591
625
|
if (item) writeXObjParam(item, chngid);
|
|
592
|
-
item = insertXObjElement(_content, XEPG_CHNURL_ETAG_NAME, true);
|
|
626
|
+
item = insertXObjElement(_content, XEPG_CHNURL_ETAG_NAME, { force: true });
|
|
593
627
|
if (item) writeXObjParam(item, srcurl);
|
|
594
628
|
}
|
|
595
629
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ygracs/xepg-lib-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "A library for handling an EPG-sources based on an XEPG-format",
|
|
5
5
|
"author": "ygracs <cs70th-om@rambler.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,22 +15,26 @@
|
|
|
15
15
|
"doc/xepgdoc-example.xepg",
|
|
16
16
|
"lib/xepgdoc-lib.js",
|
|
17
17
|
"lib/dts-helper.js",
|
|
18
|
-
"index.js"
|
|
18
|
+
"index.js",
|
|
19
|
+
"CHANGELOG.md"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
|
-
"test": "jest",
|
|
22
|
-
"test-xepg": "jest ./test",
|
|
22
|
+
"test": "TZ='Etc/UTC' jest",
|
|
23
|
+
"test-xepg": "TZ='Etc/UTC' jest ./test",
|
|
23
24
|
"test-xepg:sl": "jest TXEpgSchedulesList",
|
|
24
|
-
"test-xepg:hc": "jest TXEpgHeader",
|
|
25
|
+
"test-xepg:hc": "TZ='Etc/UTC' jest TXEpgHeader",
|
|
25
26
|
"test-xepg:pc": "jest TXEpgProvider",
|
|
26
27
|
"test-xepg:dts": "jest TXEpgDTS",
|
|
27
|
-
"test-xepg:cp": "jest TXEpgContentProvider"
|
|
28
|
-
|
|
28
|
+
"test-xepg:cp": "jest TXEpgContentProvider",
|
|
29
|
+
"win:test": "set TZ='Etc/UTC' && jest",
|
|
30
|
+
"win:test-xepg": "set TZ='Etc/UTC' && jest ./test",
|
|
31
|
+
"win:test-xepg:hc": "set TZ='Etc/UTC' && jest TXEpgHeader"
|
|
32
|
+
},
|
|
29
33
|
"dependencies": {
|
|
30
34
|
"@ygracs/bsfoc-lib-js": "^0.1.2",
|
|
31
|
-
"@ygracs/dtf-lib-js": "^0.0.
|
|
35
|
+
"@ygracs/dtf-lib-js": "^0.0.21",
|
|
32
36
|
"@ygracs/xml-js6": "^0.0.3-b",
|
|
33
|
-
"@ygracs/xobj-lib-js": "^0.0.
|
|
37
|
+
"@ygracs/xobj-lib-js": "^0.0.14-rc3"
|
|
34
38
|
},
|
|
35
39
|
"devDependencies": {
|
|
36
40
|
"jest": "^29.3.1"
|