@ygracs/xepg-lib-js 0.0.22 → 0.0.23

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.
@@ -1,12 +1,12 @@
1
- // [v0.2.098-20250306]
1
+ // [v0.2.106-20250428]
2
2
 
3
3
  // === module init block ===
4
4
 
5
5
  const xmlParser = require('@ygracs/xml-js6');
6
6
 
7
7
  const {
8
- valueToIndex,
9
- readAsString, readAsNumberEx,
8
+ valueToIndex, valueToIDString,
9
+ readAsString, readAsNumber,
10
10
  isNotEmptyString,
11
11
  isArray, isObject, isPlainObject,
12
12
  } = require('@ygracs/bsfoc-lib-js');
@@ -22,16 +22,18 @@ const {
22
22
  } = require('./dts-helper.js');
23
23
 
24
24
  const {
25
- loadFileSync, loadFile,
25
+ loadFromFileSync, loadFromFile,
26
26
  saveToFileSync, saveToFile,
27
- } = require('./file-helper.js');
27
+ } = require('@cntwg/file-helper');
28
28
 
29
29
  const xObj = require('@ygracs/xobj-lib-js');
30
30
 
31
- const TXmlContentParseOptions = xObj.TXmlContentParseOptions;
32
31
  const {
32
+ TXmlContentParseOptions,
33
33
  getXObjElement,
34
34
  insertXObjElement,
35
+ writeXObjParam,
36
+ writeXObjAttr,
35
37
  } = xObj;
36
38
 
37
39
  // === module extra block (helper functions) ===
@@ -44,33 +46,23 @@ function readXObjParam(obj){
44
46
  return xObj.readXObjParam(obj, defParseOptions.settings.textKey);
45
47
  };
46
48
 
47
- function writeXObjParam(obj, value){
48
- return xObj.writeXObjParam(obj, value, defParseOptions.settings.textKey);
49
- };
50
-
51
- function writeXObjAttr(obj, name, value) {
52
- return xObj.writeXObjAttr(
53
- obj, name, value, defParseOptions.settings.attributesKey
54
- );
55
- };
56
-
57
49
  /*
58
50
  * === xObj-function wrappers (end) ===
59
51
  */
60
52
 
61
53
  /**
62
- * @param {object} obj
63
- * @param {string} elem
54
+ * @param {object} obj - element
55
+ * @param {string} name - child element name
64
56
  * @returns {string}
65
57
  * @inner
66
58
  */
67
- function _getXmlChildElementParam(obj, elem) {
68
- const child = obj ? getXObjElement(obj, elem) : null;
59
+ function _getXmlChildElementParam(obj, name) {
60
+ const child = obj ? getXObjElement(obj, name) : null;
69
61
  return child ? readXObjParam(child) : '';
70
62
  };
71
63
 
72
64
  /**
73
- * @param {object} obj
65
+ * @param {object} obj - element
74
66
  * @returns {number}
75
67
  * @inner
76
68
  */
@@ -81,18 +73,25 @@ function _getDTSTypeValueForXObj(obj) {
81
73
  return chkDTSysID(result) ? result : 0; //-1; // // TODO: [?]
82
74
  };
83
75
 
84
- function writeXEpgDocDeclSection(obj, opt) {
76
+ /**
77
+ * @param {object} obj - element
78
+ * @param {*} data - data
79
+ * @returns {void}
80
+ * @inner
81
+ */
82
+ function writeXEpgDocDeclSection(obj, data) {
83
+ const key_name = defParseOptions.settings.declarationKey;
85
84
  let xml_ver = XEPG_XML_DOC_VERSION;
86
85
  let doc_def_enc = XEPG_DEF_ENCODING_VALUE;
87
- let key_name = defParseOptions.settings.declarationKey;
88
- if (isPlainObject(opt)) {
89
- xml_ver = readAsString(opt.version, { defValue: xml_ver });
90
- doc_def_enc = readAsString(opt.encoding, { defValue: doc_def_enc });
86
+ if (isPlainObject(data)) {
87
+ xml_ver = readAsString(data.version, { defValue: xml_ver });
88
+ doc_def_enc = readAsString(data.encoding, { defValue: doc_def_enc });
91
89
  };
92
90
  if (isPlainObject(obj) && isNotEmptyString(key_name)) {
93
91
  obj[key_name] = {};
94
- writeXObjAttr(obj[key_name], 'version', xml_ver);
95
- writeXObjAttr(obj[key_name], 'encoding', doc_def_enc);
92
+ const attr_key = defParseOptions.settings.attributesKey;
93
+ writeXObjAttr(obj[key_name], 'version', xml_ver, attr_key);
94
+ writeXObjAttr(obj[key_name], 'encoding', doc_def_enc, attr_key);
96
95
  };
97
96
  };
98
97
 
@@ -161,6 +160,75 @@ const defParseOptions = new TXmlContentParseOptions();
161
160
  * (* function definitions *)
162
161
  */
163
162
 
163
+ /**
164
+ * @since v0.0.23
165
+ * @function readAsTagName
166
+ * @param {any} value - some value
167
+ * @returns {string}
168
+ * @description Tries to convert a given value to a valid tag name
169
+ * of an XML-element.
170
+ */
171
+ function readAsTagName(value) {
172
+ let tagName = valueToIDString(value, { ignoreNumbers: true });
173
+ if (tagName === null) return '';
174
+ if (tagName !== '') {
175
+ // // TODO: do extra checks
176
+ const template = /[\s\/\\\"\'<>=]/;
177
+ const trigger = tagName.match(template);
178
+ if (trigger) {
179
+ //console.log(trigger);
180
+ tagName = '';
181
+ };
182
+ };
183
+ return tagName;
184
+ };
185
+
186
+ /**
187
+ * @since v0.0.23
188
+ * @function readAsAttrName
189
+ * @param {any} value - some value
190
+ * @returns {string}
191
+ * @description Tries to convert a given value to a valid name
192
+ * of an XML-attribute.
193
+ */
194
+ function readAsAttrName(value) {
195
+ let attrName = valueToIDString(value, { ignoreNumbers: true });
196
+ if (attrName === null) return '';
197
+ if (attrName !== '') {
198
+ // // TODO: do extra checks
199
+ const template = /[\s\/\\\"\'<>=]/;
200
+ const trigger = attrName.match(template);
201
+ if (trigger) {
202
+ //console.log(trigger);
203
+ attrName = '';
204
+ };
205
+ };
206
+ return attrName;
207
+ };
208
+
209
+ /**
210
+ * @since v0.0.23
211
+ * @function valueToElementID
212
+ * @param {any} value - some value
213
+ * @returns {string}
214
+ * @description Tries to convert a given value to a valid identifier
215
+ * suitable as a value for an "ID-attribute" of an XML-element.
216
+ */
217
+ function valueToElementID(value) {
218
+ let id = valueToIDString(value);
219
+ if (id === null) return '';
220
+ if (id !== '') {
221
+ // // TODO: do extra checks
222
+ const template = /[\s\/\\\"\'<>=]/;
223
+ const trigger = id.match(template);
224
+ if (trigger) {
225
+ //console.log(trigger);
226
+ id = '';
227
+ };
228
+ };
229
+ return id;
230
+ };
231
+
164
232
  /***
165
233
  * (* class definitions *)
166
234
  */
@@ -176,32 +244,45 @@ const defParseOptions = new TXmlContentParseOptions();
176
244
  */
177
245
 
178
246
  /**
247
+ * @typedef {Object} OPT_epgelsett_bs
248
+ * @property {TXmlContentParseOptions} [parseOptions] - parser options
249
+ * @description An XEPG-element options set (base)
250
+ */
251
+
252
+ /**
253
+ * @typedef {Object} OPT_epgelsett_ex
254
+ * @property {TXmlContentParseOptions} [parseOptions] - parser options
255
+ * @property {object} [opt.dts_src]
256
+ * @property {object} [opt.tz_src]
257
+ * @description An XEPG-element options set (extend)
258
+ */
259
+
260
+ /**
261
+ * @since 0.0.22
179
262
  * @classdesc This class implements an interface of a EPG-schedule element
180
263
  */
181
264
  class TXEpgScheduleItem {
182
- /** @property {object} */
265
+ /** @type {object} */
183
266
  #_host;// = null;
184
- /** @property {object} */
267
+ /** @type {OPT_epgelsett_ex} */
185
268
  #_options;// = null;
186
- /** @property {TXmlContentParseOptions} */
269
+ /** @type {TXmlContentParseOptions} */
187
270
  #_parseOptions;// = null;
188
- /** @property {?object} */
271
+ /** @type {?object} */
189
272
  #_dts_src = null;
190
- /** @property {?object} */
273
+ /** @type {?object} */
191
274
  #_tz_src = null;
192
275
 
193
276
  /**
194
277
  * @param {object} obj - host object
195
- * @param {object} [opt] - options
196
- * @param {object} [opt.parseOptions]
197
- * @param {?object} [opt.dts_src]
198
- * @param {?object} [opt.tz_src]
278
+ * @param {OPT_epgelsett_ex} [opt] - options
199
279
  * @description Creates an instance of the EPG-schedule element
200
280
  */
201
281
  constructor(obj, opt) {
202
282
  // load content
203
283
  const _host = isPlainObject(obj) ? obj : {};
204
284
  // load options
285
+ /** @type {OPT_epgelsett_ex} */
205
286
  const _options = isPlainObject(opt) ? opt : {};
206
287
  let {
207
288
  parseOptions,
@@ -226,7 +307,7 @@ class TXEpgScheduleItem {
226
307
 
227
308
  /**
228
309
  * Contains a dtstype ID
229
- * @property {number}
310
+ * @type {number}
230
311
  * @readonly
231
312
  */
232
313
  get dtstype() {
@@ -235,7 +316,7 @@ class TXEpgScheduleItem {
235
316
 
236
317
  /**
237
318
  * Contains a TZ-offset
238
- * @property {number}
319
+ * @type {number}
239
320
  * @readonly
240
321
  */
241
322
  get curDocTZ() {
@@ -248,7 +329,7 @@ class TXEpgScheduleItem {
248
329
 
249
330
  /**
250
331
  * Contains a schedule start time as a timestamp
251
- * @property {number}
332
+ * @type {number}
252
333
  * @readonly
253
334
  */
254
335
  get time() {
@@ -260,7 +341,7 @@ class TXEpgScheduleItem {
260
341
 
261
342
  /**
262
343
  * Contains a schedule title
263
- * @property {string}
344
+ * @type {string}
264
345
  * @readonly
265
346
  */
266
347
  get title() {
@@ -269,7 +350,7 @@ class TXEpgScheduleItem {
269
350
 
270
351
  /**
271
352
  * Contains a schedule category
272
- * @property {string}
353
+ * @type {string}
273
354
  * @readonly
274
355
  */
275
356
  get category() {
@@ -278,18 +359,18 @@ class TXEpgScheduleItem {
278
359
 
279
360
  /**
280
361
  * Contains a schedule rating value (aka pcmark)
281
- * @property {number}
362
+ * @type {number}
282
363
  * @readonly
283
364
  */
284
365
  get rating() {
285
- return readAsNumberEx(
366
+ return readAsNumber(
286
367
  _getXmlChildElementParam(this.#_host, XEPG_SCHEDPMARK_ETAG_NAME), 0
287
368
  );
288
369
  }
289
370
 
290
371
  /**
291
372
  * Contains a schedule description
292
- * @property {string}
373
+ * @type {string}
293
374
  * @readonly
294
375
  */
295
376
  get descr() {
@@ -330,7 +411,9 @@ class TXEpgScheduleItem {
330
411
  if (dtValue !== '') {
331
412
  const opt = { force: true };
332
413
  const item = insertXObjElement(this.#_host, XEPG_SCHEDTIME_ETAG_NAME, opt);
333
- if (item) result = writeXObjParam(item, dtValue);
414
+ if (item) {
415
+ result = writeXObjParam(item, dtValue, defParseOptions.settings.textKey);
416
+ };
334
417
  };
335
418
  };
336
419
  return result;
@@ -346,7 +429,9 @@ class TXEpgScheduleItem {
346
429
  if (typeof value === 'string') {
347
430
  const opt = { force: true };
348
431
  const item = insertXObjElement(this.#_host, XEPG_SCHEDTITL_ETAG_NAME, opt);
349
- if (item) result = writeXObjParam(item, value.trim());
432
+ if (item) {
433
+ result = writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
434
+ };
350
435
  };
351
436
  return result;
352
437
  }
@@ -361,7 +446,9 @@ class TXEpgScheduleItem {
361
446
  if (typeof value === 'string') {
362
447
  const opt = { force: true };
363
448
  const item = insertXObjElement(this.#_host, XEPG_SCHEDCAT_ETAG_NAME, opt);
364
- if (item) result = writeXObjParam(item, value.trim());
449
+ if (item) {
450
+ result = writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
451
+ };
365
452
  };
366
453
  return result;
367
454
  }
@@ -377,7 +464,9 @@ class TXEpgScheduleItem {
377
464
  if (_value !== -1) {
378
465
  const opt = { force: true };
379
466
  const item = insertXObjElement(this.#_host, XEPG_SCHEDPMARK_ETAG_NAME, opt);
380
- if (item) result = writeXObjParam(item, _value);
467
+ if (item) {
468
+ result = writeXObjParam(item, _value, defParseOptions.settings.textKey);
469
+ };
381
470
  };
382
471
  return result;
383
472
  }
@@ -392,7 +481,9 @@ class TXEpgScheduleItem {
392
481
  if (typeof value === 'string') {
393
482
  const opt = { force: true };
394
483
  const item = insertXObjElement(this.#_host, XEPG_SCHEDDESC_ETAG_NAME, opt);
395
- if (item) result = writeXObjParam(item, value.trim());
484
+ if (item) {
485
+ result = writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
486
+ };
396
487
  };
397
488
  return result;
398
489
  }
@@ -423,24 +514,23 @@ class TXEpgScheduleItem {
423
514
  * @classdesc This class implements an interface of a EPG-schedules list
424
515
  */
425
516
  class TXEpgSchedulesList {
426
- /** @property {object[]} */
517
+ /** @type {object[]} */
427
518
  #_content;// = null;
428
- /** @property {object} */
519
+ /** @type {OPT_epgelsett_ex} */
429
520
  #_options;// = null;
430
- /** @property {?object} */
521
+ /** @type {?object} */
431
522
  #_dts_src = null;
432
- /** @property {?object} */
523
+ /** @type {?object} */
433
524
  #_tz_src = null;
434
525
 
435
526
  /**
436
527
  * @param {any[]} obj - list of an elements
437
- * @param {object} [opt] - options
438
- * @param {?object} [opt.dts_src]
439
- * @param {?object} [opt.tz_src]
528
+ * @param {OPT_epgelsett_ex} [opt] - options
440
529
  * @description Creates an instance of the schedules list
441
530
  */
442
531
  constructor(obj, opt) {
443
532
  const _content = isArray(obj) ? obj : [];
533
+ /** @type {OPT_epgelsett_ex} */
444
534
  const _options = isPlainObject(opt) ? opt : {};
445
535
  let { dts_src, tz_src } = _options;
446
536
  if (!isPlainObject(dts_src)) dts_src = null;
@@ -468,7 +558,7 @@ class TXEpgSchedulesList {
468
558
 
469
559
  /**
470
560
  * Contains a quantity of a schedules
471
- * @property {number}
561
+ * @type {number}
472
562
  * @readonly
473
563
  */
474
564
  get schedQty() {
@@ -477,7 +567,7 @@ class TXEpgSchedulesList {
477
567
 
478
568
  /**
479
569
  * Contains a dtstype ID
480
- * @property {number}
570
+ * @type {number}
481
571
  * @readonly
482
572
  */
483
573
  get dtstype() {
@@ -486,7 +576,7 @@ class TXEpgSchedulesList {
486
576
 
487
577
  /**
488
578
  * Contains a TZ-offset
489
- * @property {number}
579
+ * @type {number}
490
580
  * @readonly
491
581
  */
492
582
  get curDocTZ() {
@@ -527,9 +617,9 @@ class TXEpgSchedulesList {
527
617
  }
528
618
 
529
619
  /**
620
+ * @since 0.0.20
530
621
  * @param {(number|string)} value - index of some element
531
622
  * @returns {boolean}
532
- * @since 0.0.20
533
623
  * @description Checks whether a given value is a valid index
534
624
  * and it fits the index range of an instance
535
625
  */
@@ -539,9 +629,9 @@ class TXEpgSchedulesList {
539
629
  }
540
630
 
541
631
  /**
632
+ * @since 0.0.22
542
633
  * @param {(number|string)} index - index of some element
543
634
  * @returns {?TXEpgScheduleItem}
544
- * @since 0.0.22
545
635
  * @description Returns a schedule element addressed by a given index
546
636
  */
547
637
  schedule(index) {
@@ -602,24 +692,24 @@ class TXEpgSchedulesList {
602
692
  * @classdesc This class implements an interface of a EPG-provider element
603
693
  */
604
694
  class TXEpgProviderContainer {
605
- /** @property {Object} */
695
+ /** @type {Object} */
606
696
  #_host;// = null;
607
- /** @property {Object} */
697
+ /** @type {OPT_epgelsett_bs} */
608
698
  #_options;// = null;
609
- /** @property {TXmlContentParseOptions} */
699
+ /** @type {TXmlContentParseOptions} */
610
700
  #_parseOptions;// = null;
611
- /** @property {?TXEpgDTSProvider} */
701
+ /** @type {?TXEpgDTSProvider} */
612
702
 
613
703
  /**
614
704
  * @param {object} obj - host object
615
- * @param {object} [opt] - options
616
- * @param {object} [opt.parseOptions]
705
+ * @param {OPT_epgelsett_bs} [opt] - options
617
706
  * @description Creates an instance of the EPG-provider element
618
707
  */
619
708
  constructor(obj, opt) {
620
709
  // load content
621
710
  const _host = isPlainObject(obj) ? obj : {};
622
711
  // load options
712
+ /** @type {OPT_epgelsett_bs} */
623
713
  const _options = isPlainObject(opt) ? opt : {};
624
714
  let {
625
715
  parseOptions,
@@ -652,7 +742,7 @@ class TXEpgProviderContainer {
652
742
 
653
743
  /**
654
744
  * Contains a provider name
655
- * @property {string}
745
+ * @type {string}
656
746
  */
657
747
  get name() {
658
748
  return _getXmlChildElementParam(this.#_host, 'name').trim();
@@ -664,7 +754,7 @@ class TXEpgProviderContainer {
664
754
 
665
755
  /**
666
756
  * Contains a version of a provider
667
- * @property {string}
757
+ * @type {string}
668
758
  */
669
759
  get version() {
670
760
  return _getXmlChildElementParam(this.#_host, 'version').trim();
@@ -674,13 +764,15 @@ class TXEpgProviderContainer {
674
764
  if (typeof value === 'string' && this.name !== '') {
675
765
  const opt = { force: true };
676
766
  const item = insertXObjElement(this.#_host, 'version', opt);
677
- if (item) writeXObjParam(item, value.trim());
767
+ if (item) {
768
+ writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
769
+ };
678
770
  };
679
771
  }
680
772
 
681
773
  /**
682
774
  * Contains a version of a document schema
683
- * @property {string}
775
+ * @type {string}
684
776
  */
685
777
  get schema() {
686
778
  return _getXmlChildElementParam(this.#_host, XEPG_DOCSCH_ETAG_NAME).trim();
@@ -690,13 +782,15 @@ class TXEpgProviderContainer {
690
782
  if (typeof value === 'string') {
691
783
  const opt = { force: true };
692
784
  const item = insertXObjElement(this.#_host, XEPG_DOCSCH_ETAG_NAME, opt);
693
- if (item) writeXObjParam(item, value.trim());
785
+ if (item) {
786
+ writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
787
+ };
694
788
  };
695
789
  }
696
790
 
697
791
  /**
698
792
  * Contains a document type
699
- * @property {string}
793
+ * @type {string}
700
794
  */
701
795
  get doctype() {
702
796
  return _getXmlChildElementParam(this.#_host, XEPG_DOCTYP_ETAG_NAME).trim();
@@ -706,7 +800,9 @@ class TXEpgProviderContainer {
706
800
  if (typeof value === 'string') {
707
801
  const opt = { force: true };
708
802
  const item = insertXObjElement(this.#_host, XEPG_DOCTYP_ETAG_NAME, opt);
709
- if (item) writeXObjParam(item, value.trim());
803
+ if (item) {
804
+ writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
805
+ };
710
806
  };
711
807
  }
712
808
 
@@ -720,7 +816,9 @@ class TXEpgProviderContainer {
720
816
  if (typeof value === 'string') {
721
817
  const name = value.trim();
722
818
  const item = insertXObjElement(this.#_host, 'name', { force: true });
723
- if (item) isSucceed = writeXObjParam(item, name);
819
+ if (item) {
820
+ isSucceed = writeXObjParam(item, name, defParseOptions.settings.textKey);
821
+ };
724
822
  };
725
823
  return isSucceed;
726
824
  }
@@ -803,8 +901,8 @@ class TXEpgProviderContainer {
803
901
  }
804
902
 
805
903
  /**
806
- * @returns {string}
807
904
  * @since v0.0.20
905
+ * @returns {string}
808
906
  * @description Returns an instance content as a string in an XML-format.
809
907
  */
810
908
  saveToXMLString() {
@@ -835,28 +933,29 @@ class TXEpgProviderContainer {
835
933
  */
836
934
 
837
935
  /**
936
+ * @since 0.0.22
838
937
  * @classdesc This class implements an interface of a channel element
839
938
  */
840
939
  class TXEpgChannelContainer {
841
- /** @property {object} */
940
+ /** @type {object} */
842
941
  #_host;// = null;
843
- /** @property {object} */
942
+ /** @type {OPT_epgelsett_bs} */
844
943
  #_options;// = null;
845
- /** @property {TXmlContentParseOptions} */
944
+ /** @type {TXmlContentParseOptions} */
846
945
  #_parseOptions;// = null;
847
- /** @property {string} */
946
+ /** @type {string} */
848
947
  #_xepgSchema;// = null;
849
948
 
850
949
  /**
851
950
  * @param {object} obj - host object
852
- * @param {object} [opt] - options
853
- * @param {object} [opt.parseOptions]
951
+ * @param {OPT_epgelsett_bs} [opt] - options
854
952
  * @description Creates an instance of the channel element
855
953
  */
856
954
  constructor(obj, opt) {
857
955
  // load content
858
956
  const _host = isPlainObject(obj) ? obj : {};
859
957
  // load options
958
+ /** @type {OPT_epgelsett_bs} */
860
959
  const _options = isPlainObject(opt) ? opt : {};
861
960
  let {
862
961
  parseOptions,
@@ -877,7 +976,7 @@ class TXEpgChannelContainer {
877
976
 
878
977
  /**
879
978
  * Contains a channel ID
880
- * @returns {string}
979
+ * @type {string}
881
980
  * @readonly
882
981
  */
883
982
  get id() {
@@ -886,7 +985,7 @@ class TXEpgChannelContainer {
886
985
 
887
986
  /**
888
987
  * Contains a channel name
889
- * @returns {string}
988
+ * @type {string}
890
989
  */
891
990
  get name() {
892
991
  return _getXmlChildElementParam(this.#_host, XEPG_CHNNAME_ETAG_NAME).trim();
@@ -899,13 +998,15 @@ class TXEpgChannelContainer {
899
998
  XEPG_CHNNAME_ETAG_NAME,
900
999
  { force: true },
901
1000
  );
902
- if (item) writeXObjParam(item, value.trim());
1001
+ if (item) {
1002
+ writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
1003
+ };
903
1004
  };
904
1005
  }
905
1006
 
906
1007
  /**
907
1008
  * Contains a channel Group ID
908
- * @returns {string}
1009
+ * @type {string}
909
1010
  */
910
1011
  get gid() {
911
1012
  return _getXmlChildElementParam(this.#_host, XEPG_CHNGID_ETAG_NAME).trim();
@@ -918,13 +1019,15 @@ class TXEpgChannelContainer {
918
1019
  XEPG_CHNGID_ETAG_NAME,
919
1020
  { force: true },
920
1021
  );
921
- if (item) writeXObjParam(item, value.trim());
1022
+ if (item) {
1023
+ writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
1024
+ };
922
1025
  };
923
1026
  }
924
1027
 
925
1028
  /**
926
1029
  * Contains a channel source URL
927
- * @returns {string}
1030
+ * @type {string}
928
1031
  */
929
1032
  get url() {
930
1033
  return _getXmlChildElementParam(this.#_host, XEPG_CHNURL_ETAG_NAME).trim();
@@ -937,7 +1040,9 @@ class TXEpgChannelContainer {
937
1040
  XEPG_CHNURL_ETAG_NAME,
938
1041
  { force: true },
939
1042
  );
940
- if (item) writeXObjParam(item, value.trim());
1043
+ if (item) {
1044
+ writeXObjParam(item, value.trim(), defParseOptions.settings.textKey);
1045
+ };
941
1046
  };
942
1047
  }
943
1048
 
@@ -956,7 +1061,7 @@ class TXEpgChannelContainer {
956
1061
  { force: true },
957
1062
  );
958
1063
  if (item) {
959
- isSucceed = writeXObjParam(item, chnid);
1064
+ isSucceed = writeXObjParam(item, chnid, defParseOptions.settings.textKey);
960
1065
  };
961
1066
  };
962
1067
  return isSucceed;
@@ -1020,14 +1125,15 @@ class TXEpgChannelContainer {
1020
1125
  };
1021
1126
  let item = null;
1022
1127
  const _host = this.#_host;
1128
+ const text_key = defParseOptions.settings.textKey;
1023
1129
  item = insertXObjElement(_host, XEPG_CHNID_ETAG_NAME, { force: true });
1024
- if (item) writeXObjParam(item, chnid);
1130
+ if (item) writeXObjParam(item, chnid, text_key);
1025
1131
  item = insertXObjElement(_host, XEPG_CHNNAME_ETAG_NAME, { force: true });
1026
- if (item) writeXObjParam(item, chname);
1132
+ if (item) writeXObjParam(item, chname, text_key);
1027
1133
  item = insertXObjElement(_host, XEPG_CHNGID_ETAG_NAME, { force: true });
1028
- if (item) writeXObjParam(item, chngid);
1134
+ if (item) writeXObjParam(item, chngid, text_key);
1029
1135
  item = insertXObjElement(_host, XEPG_CHNURL_ETAG_NAME, { force: true });
1030
- if (item) writeXObjParam(item, srcurl);
1136
+ if (item) writeXObjParam(item, srcurl, text_key);
1031
1137
  }
1032
1138
 
1033
1139
  }
@@ -1036,21 +1142,21 @@ class TXEpgChannelContainer {
1036
1142
  * @classdesc This class implements an interface of a DTS-provider element
1037
1143
  */
1038
1144
  class TXEpgDTSProvider {
1039
- /** @property {object} */
1145
+ /** @type {object} */
1040
1146
  #_content;// = null;
1041
- /** @property {object} */
1147
+ /** @type {OPT_epgelsett_bs} */
1042
1148
  #_options;// = null;
1043
1149
 
1044
1150
  /**
1045
1151
  * @param {object} obj - host object
1046
- * @param {object} [opt] - options
1047
- * @param {object} [opt.parseOptions]
1152
+ * @param {OPT_epgelsett_bs} [opt] - options
1048
1153
  * @description Creates an instance of the DTS-provider element
1049
1154
  */
1050
1155
  constructor(obj, opt) {
1051
1156
  // load content
1052
1157
  const _content = isPlainObject(obj) ? obj : {};
1053
1158
  // load options
1159
+ /** @type {OPT_epgelsett_bs} */
1054
1160
  let _options = isPlainObject(opt) ? opt : {};
1055
1161
  let {
1056
1162
  parseOptions,
@@ -1077,7 +1183,7 @@ class TXEpgDTSProvider {
1077
1183
 
1078
1184
  /**
1079
1185
  * Contains a dtstype ID
1080
- * @property {number}
1186
+ * @type {number}
1081
1187
  */
1082
1188
  get dtstype() {
1083
1189
  const item = getXObjElement(this.#_content, XEPG_DTSINFO_ETAG_NAME);
@@ -1092,7 +1198,7 @@ class TXEpgDTSProvider {
1092
1198
 
1093
1199
  /**
1094
1200
  * Contains a TZ-offset
1095
- * @property {number}
1201
+ * @type {number}
1096
1202
  */
1097
1203
  get curDocTZ() {
1098
1204
  const tz = convTZStringToValue(
@@ -1109,7 +1215,9 @@ class TXEpgDTSProvider {
1109
1215
  XEPG_DOCTZ_ETAG_NAME,
1110
1216
  { force: true },
1111
1217
  );
1112
- if (item) writeXObjParam(item, _value);
1218
+ if (item) {
1219
+ writeXObjParam(item, _value, defParseOptions.settings.textKey);
1220
+ };
1113
1221
  };
1114
1222
  }
1115
1223
 
@@ -1132,10 +1240,10 @@ class TXEpgDTSProvider {
1132
1240
  let curItem = insertXObjElement(item, 'value', { force: true });
1133
1241
  if (
1134
1242
  curItem
1135
- && writeXObjParam(curItem, index)
1243
+ && writeXObjParam(curItem, index, defParseOptions.settings.textKey)
1136
1244
  && (curItem = insertXObjElement(item, 'name', { force: true }))
1137
1245
  ) {
1138
- isSucceed = writeXObjParam(curItem, name);
1246
+ isSucceed = writeXObjParam(curItem, name, defParseOptions.settings.textKey);
1139
1247
  };
1140
1248
  };
1141
1249
  };
@@ -1148,25 +1256,25 @@ class TXEpgDTSProvider {
1148
1256
  * @classdesc This class implements an interface of a EPG-header element
1149
1257
  */
1150
1258
  class TXEpgHeaderContainer {
1151
- /** @property {Object} */
1259
+ /** @type {Object} */
1152
1260
  #_host;// = null;
1153
- /** @property {Object} */
1261
+ /** @type {OPT_epgelsett_bs} */
1154
1262
  #_options;// = null;
1155
- /** @property {TXmlContentParseOptions} */
1263
+ /** @type {TXmlContentParseOptions} */
1156
1264
  #_parseOptions;// = null;
1157
- /** @property {TXEpgDTSProvider} */
1265
+ /** @type {TXEpgDTSProvider} */
1158
1266
  #_dtsProv;// = null;
1159
1267
 
1160
1268
  /**
1161
- * @param {object} obj
1162
- * @param {object} [opt] - options
1163
- * @param {object} [opt.parseOptions]
1269
+ * @param {object} obj - host element
1270
+ * @param {OPT_epgelsett_bs} [opt] - options
1164
1271
  * @description Creates an instance of the EPG-header element
1165
1272
  */
1166
1273
  constructor(obj, opt) {
1167
1274
  // load content
1168
1275
  const _host = isPlainObject(obj) ? obj : {};
1169
1276
  // load options
1277
+ /** @type {OPT_epgelsett_bs} */
1170
1278
  const _options = isPlainObject(opt) ? opt : {};
1171
1279
  let {
1172
1280
  parseOptions,
@@ -1187,7 +1295,7 @@ class TXEpgHeaderContainer {
1187
1295
 
1188
1296
  /**
1189
1297
  * Returns a `TXEpgDTSProvider` instance
1190
- * @property {TXEpgDTSProvider}
1298
+ * @type {TXEpgDTSProvider}
1191
1299
  * @readonly
1192
1300
  */
1193
1301
  get dts() {
@@ -1196,7 +1304,7 @@ class TXEpgHeaderContainer {
1196
1304
 
1197
1305
  /**
1198
1306
  * Contains a dtstype ID
1199
- * @property {number}
1307
+ * @type {number}
1200
1308
  * @todo [since v0.0.22] becomes readonly
1201
1309
  */
1202
1310
  get dtstype() {
@@ -1209,7 +1317,7 @@ class TXEpgHeaderContainer {
1209
1317
 
1210
1318
  /**
1211
1319
  * Contains a TZ-offset
1212
- * @property {number}
1320
+ * @type {number}
1213
1321
  * @todo [since v0.0.22] becomes readonly
1214
1322
  */
1215
1323
  get curDocTZ() {
@@ -1244,7 +1352,7 @@ class TXEpgHeaderContainer {
1244
1352
 
1245
1353
  /**
1246
1354
  * Returns a `TXEpgProviderContainer` instance
1247
- * @property {?TXEpgProviderContainer}
1355
+ * @type {?TXEpgProviderContainer}
1248
1356
  * @readonly
1249
1357
  * @deprecated
1250
1358
  */
@@ -1255,7 +1363,7 @@ class TXEpgHeaderContainer {
1255
1363
  /**
1256
1364
  * Returns a `TXEpgProviderContainer` instance
1257
1365
  * @since 0.0.22
1258
- * @property {?TXEpgProviderContainer}
1366
+ * @type {?TXEpgProviderContainer}
1259
1367
  * @readonly
1260
1368
  */
1261
1369
  get provider() {
@@ -1270,7 +1378,7 @@ class TXEpgHeaderContainer {
1270
1378
  /**
1271
1379
  * Returns a `TXEpgChannelContainer` instance
1272
1380
  * @since 0.0.22
1273
- * @property {?TXEpgChannelContainer}
1381
+ * @type {?TXEpgChannelContainer}
1274
1382
  * @readonly
1275
1383
  */
1276
1384
  get channel() {
@@ -1301,7 +1409,9 @@ class TXEpgHeaderContainer {
1301
1409
  XEPG_DOCDTO_ETAG_NAME,
1302
1410
  { force: true },
1303
1411
  );
1304
- if (item) writeXObjParam(item, dt_str);
1412
+ if (item) {
1413
+ writeXObjParam(item, dt_str, defParseOptions.settings.textKey);
1414
+ };
1305
1415
  }
1306
1416
 
1307
1417
  /**
@@ -1330,7 +1440,9 @@ class TXEpgHeaderContainer {
1330
1440
  XEPG_DOCDTE_ETAG_NAME,
1331
1441
  { force: true },
1332
1442
  );
1333
- if (item) writeXObjParam(item, dt_str);
1443
+ if (item) {
1444
+ writeXObjParam(item, dt_str, defParseOptions.settings.textKey);
1445
+ };
1334
1446
  }
1335
1447
 
1336
1448
  /**
@@ -1385,8 +1497,8 @@ class TXEpgHeaderContainer {
1385
1497
  }
1386
1498
 
1387
1499
  /**
1388
- * @returns {string}
1389
1500
  * @since v0.0.20
1501
+ * @returns {string}
1390
1502
  * @description Returns an instance content as a string in an XML-format.
1391
1503
  */
1392
1504
  saveToXMLString() {
@@ -1412,32 +1524,37 @@ class TXEpgHeaderContainer {
1412
1524
  * @property {boolean} isERR - flag
1413
1525
  * @property {number} [errCode] - error code
1414
1526
  * @property {string} errEvent - event ID
1415
- * @property {string} errMsg - event message
1416
- * @property {string} source - path to file
1417
- * @property {any} content - file content
1527
+ * @property {string} [errMsg] - event message
1528
+ * @property {string} [source] - path to file
1529
+ * @property {any} [content] - file content
1418
1530
  * @description A fs ops description.
1419
1531
  */
1420
1532
 
1533
+ /**
1534
+ * @typedef {Object} OPT_epgcpsett
1535
+ * @property {TXmlContentParseOptions} [parseOptions] - parser options
1536
+ * @property {boolean} [autoBindRoot] - <*deprecated*>
1537
+ * @description An options set for `TXEpgContentProvider`-class
1538
+
1421
1539
  /**
1422
1540
  * @classdesc This class implements an interface of the container
1423
1541
  * that manages a content of a XEPG-document
1424
1542
  */
1425
1543
  class TXEpgContentProvider {
1426
- /** @property {Object} */
1544
+ /** @type {Object} */
1427
1545
  #_content;// = null;
1428
- /** @property {Object} */
1546
+ /** @type {OPT_epgcpsett} */
1429
1547
  #_options;// = null;
1430
- /** @property {?TXmlContentParseOptions} */
1548
+ /** @type {TXmlContentParseOptions} */
1431
1549
  #_parseOptions;// = null;
1432
1550
 
1433
1551
  /**
1434
- * @param {object} [opt] - options
1435
- * @param {object} [opt.parseOptions]
1436
- * @param {boolean} [opt.autoBindRoot] - <*reserved*> ([?] - deprecate)
1552
+ * @param {OPT_epgcpsett} [opt] - options
1437
1553
  * @description Creates an instance of the XEPG-content provider
1438
1554
  */
1439
1555
  constructor(opt) {
1440
1556
  // load options
1557
+ /** @type {OPT_epgcpsett} */
1441
1558
  const _options = isPlainObject(opt) ? opt : {};
1442
1559
  let {
1443
1560
  parseOptions,
@@ -1477,7 +1594,12 @@ class TXEpgContentProvider {
1477
1594
  if (!docRoot) {
1478
1595
  docRoot = insertXObjElement(_content, XEPG_ROOT_ETAG_NAME);
1479
1596
  if (docRoot) {
1480
- writeXObjAttr(docRoot, `xmlns:${XEPG_DEF_NS_NAME}`, XEPG_DEF_NS_PATH);
1597
+ writeXObjAttr(
1598
+ docRoot,
1599
+ `xmlns:${XEPG_DEF_NS_NAME}`,
1600
+ XEPG_DEF_NS_PATH,
1601
+ defParseOptions.settings.attributesKey,
1602
+ );
1481
1603
  };
1482
1604
  };
1483
1605
  return isPlainObject(docRoot) ? docRoot : null;
@@ -1543,7 +1665,7 @@ class TXEpgContentProvider {
1543
1665
 
1544
1666
  /**
1545
1667
  * Returns a `TXEpgHeaderContainer` instance
1546
- * @property {?TXEpgHeaderContainer}
1668
+ * @type {?TXEpgHeaderContainer}
1547
1669
  * @readonly
1548
1670
  * @deprecated
1549
1671
  */
@@ -1559,7 +1681,7 @@ class TXEpgContentProvider {
1559
1681
  /**
1560
1682
  * Returns a `TXEpgHeaderContainer` instance
1561
1683
  * @since 0.0.22
1562
- * @property {?TXEpgHeaderContainer}
1684
+ * @type {?TXEpgHeaderContainer}
1563
1685
  * @readonly
1564
1686
  */
1565
1687
  get header() {
@@ -1573,7 +1695,7 @@ class TXEpgContentProvider {
1573
1695
 
1574
1696
  /**
1575
1697
  * Returns a `TXEpgProviderContainer` instance
1576
- * @property {?TXEpgProviderContainer}
1698
+ * @type {?TXEpgProviderContainer}
1577
1699
  * @readonly
1578
1700
  * @deprecated
1579
1701
  */
@@ -1585,7 +1707,7 @@ class TXEpgContentProvider {
1585
1707
  /**
1586
1708
  * Returns a `TXEpgProviderContainer` instance
1587
1709
  * @since 0.0.22
1588
- * @property {?TXEpgProviderContainer}
1710
+ * @type {?TXEpgProviderContainer}
1589
1711
  * @readonly
1590
1712
  */
1591
1713
  get provider() {
@@ -1595,7 +1717,7 @@ class TXEpgContentProvider {
1595
1717
 
1596
1718
  /**
1597
1719
  * Returns a `TXEpgDTSProvider` instance
1598
- * @property {?TXEpgDTSProvider}
1720
+ * @type {?TXEpgDTSProvider}
1599
1721
  * @readonly
1600
1722
  */
1601
1723
  get dts() {
@@ -1611,7 +1733,7 @@ class TXEpgContentProvider {
1611
1733
 
1612
1734
  /**
1613
1735
  * Returns a `TXEpgSchedulesList` instance
1614
- * @property {TXEpgSchedulesList}
1736
+ * @type {TXEpgSchedulesList}
1615
1737
  * @readonly
1616
1738
  */
1617
1739
  get SchedulesList() {
@@ -1754,10 +1876,10 @@ class TXEpgContentProvider {
1754
1876
  }
1755
1877
 
1756
1878
  /**
1879
+ * @since 0.0.18
1757
1880
  * @param {string} xmlString - a document content in XML-format
1758
1881
  * @returns {boolean}
1759
1882
  * @throws {Error}
1760
- * @since 0.0.18
1761
1883
  * @description Loads a document content from a string.
1762
1884
  */
1763
1885
  loadFromXMLString(xmlString) {
@@ -1807,7 +1929,7 @@ class TXEpgContentProvider {
1807
1929
  loadFromFile(source) {
1808
1930
  /**/// main part that return promise as a result
1809
1931
  return new Promise((resolve, reject) => {
1810
- loadFile(source).then(data => {
1932
+ loadFromFile(source).then(data => {
1811
1933
  if (!data.isERR) {
1812
1934
  if (data.content !== '') {
1813
1935
  if (this.loadFromXMLString(data.content)) {
@@ -1838,7 +1960,7 @@ class TXEpgContentProvider {
1838
1960
  * @description Loads a document content from a file.
1839
1961
  */
1840
1962
  loadFromFileSync(source) {
1841
- const data = loadFileSync(source);
1963
+ const data = loadFromFileSync(source);
1842
1964
  if (!data.isERR) {
1843
1965
  if (data.content !== '') {
1844
1966
  if (this.loadFromXMLString(data.content)) {
@@ -1868,6 +1990,15 @@ class TXEpgContentProvider {
1868
1990
 
1869
1991
  // === module exports block ===
1870
1992
 
1993
+ module.exports.XEPG_DEF_PROVIDER_NAME = XEPG_DEF_PROVIDER_NAME;
1994
+ module.exports.XEPG_DEF_PROVIDER_VER = XEPG_DEF_PROVIDER_VER;
1995
+ module.exports.XEPG_DEF_DOCUMENT_TYPE = XEPG_DEF_DOCUMENT_TYPE;
1996
+ module.exports.XEPG_DEF_DOCUMENT_SCHEMA = XEPG_DEF_DOCUMENT_SCHEMA;
1997
+
1998
+ module.exports.readAsTagName = readAsTagName;
1999
+ module.exports.readAsAttrName = readAsAttrName;
2000
+ module.exports.valueToElementID = valueToElementID;
2001
+
1871
2002
  module.exports.TXEpgDTSProvider = TXEpgDTSProvider;
1872
2003
  module.exports.TXEpgScheduleItem = TXEpgScheduleItem;
1873
2004
  module.exports.TXEpgSchedulesList = TXEpgSchedulesList;
@@ -1876,10 +2007,5 @@ module.exports.TXEpgChannelContainer = TXEpgChannelContainer;
1876
2007
  module.exports.TXEpgHeaderContainer = TXEpgHeaderContainer;
1877
2008
  module.exports.TXEpgContentProvider = TXEpgContentProvider;
1878
2009
 
1879
- module.exports.XEPG_DEF_PROVIDER_NAME = XEPG_DEF_PROVIDER_NAME;
1880
- module.exports.XEPG_DEF_PROVIDER_VER = XEPG_DEF_PROVIDER_VER;
1881
- module.exports.XEPG_DEF_DOCUMENT_TYPE = XEPG_DEF_DOCUMENT_TYPE;
1882
- module.exports.XEPG_DEF_DOCUMENT_SCHEMA = XEPG_DEF_DOCUMENT_SCHEMA;
1883
-
1884
2010
  /** @deprecated */
1885
2011
  module.exports.TXepgDTSProvider = TXEpgDTSProvider;