@ygracs/xepg-lib-js 0.0.27-b → 0.0.31

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 CHANGED
@@ -1,18 +1,33 @@
1
- #### *v0.0.xx*
1
+ #### *v0.0.31*
2
+
3
+ Pre-release version.
4
+
5
+ > - update dependency on `@ygracs/xml-js6` module to v0.0.10;
6
+ > - update dependency on `@ygracs/bsfoc-lib-js` module to v0.4.0;
7
+ > - update dependency on `@ygracs/dtf-lib-js` module to v0.1.0;
8
+ > - update dependency on `@ygracs/xobj-lib-js` module to v0.4.1;
9
+ > - some fixes.
10
+
11
+ #### *v0.0.30*
2
12
 
3
13
  Pre-release version.
4
14
 
5
15
  > - update `xepgdoc-lib.md`;
6
- > - update dependency on `@ygracs/xml-js6` module to v0.0.8-b;
7
- > - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.3;
16
+ > - update dependency on `@ygracs/xml-js6` module to v0.0.9-b;
17
+ > - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.4;
8
18
  > - update dependency on `@ygracs/dtf-lib-js` module to v0.0.33;
9
- > - update dependency on `@ygracs/xobj-lib-js` module to v0.3.0;
10
- > - update dependency on `@cntwg/file-helper` module to v0.0.3;
19
+ > - update dependency on `@ygracs/xobj-lib-js` module to v0.3.3;
20
+ > - update dependency on `@cntwg/file-helper` module to v0.0.4;
11
21
  > - add new class: `TXmlContentDeclaration`;
12
22
  > - (`TXEpgContentProvider`) change behavior for methods: `loadFromFile`, `loadFromFileSync`;
13
23
  > - (`TXEpgContentProvider`) remove deprecated properties: `SchedulesList`;
14
24
  > - (`TXEpgHeaderContainer`) remove deprecated methods: `setProviderInfo`, `setChannelInfo`;
25
+ > - (`TXEpgProviderContainer`) change behavior for methods: `init`;
26
+ > - (`TXEpgChannelContainer`) change behavior for methods: `setInfo`;
27
+ > - (`TXEpgSchedulesList`) add new methods: `checkIndex`;
28
+ > - (`TXEpgSchedulesList`) deprecate methods: `chkIndex`;
15
29
  > - (`TXEpgSchedulesList`) remove deprecated methods: `hasSchedules`, `hasNoSchedules`;
30
+ > - other fixes.
16
31
 
17
32
  #### *v0.0.25*
18
33
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- |***rev.*:**|0.0.11|
1
+ |***rev.*:**|0.0.12|
2
2
  |:---|---:|
3
- |***date***:|2025-08-25|
3
+ |***date***:|2026-06-12|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -48,3 +48,5 @@ For more read the `xepgdoc-lib.md` in the project `doc` directory.
48
48
  ### Installation
49
49
 
50
50
  `npm install @ygracs/xepg-lib-js`
51
+
52
+ > Note: It's recommended to "pin" a package versions range to its minor releases after installation. To do so use `~` range specifier (*e.g. `~0.0.30`*) in `package.json`.
@@ -1,6 +1,6 @@
1
- |***rev.*:**|0.1.45|
1
+ |***rev.*:**|0.1.46|
2
2
  |:---|---:|
3
- |***date***:|2026-03-05|
3
+ |***date***:|2026-06-12|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -341,11 +341,18 @@ This method returns `true` if a document contains at least one schedule.
341
341
 
342
342
  > since: `v0.0.20`
343
343
 
344
- This method checks if a given `value` represents a valid schedule index and if so returns `true`.
344
+ > WARNING: \[since `v0.0.30`] this method deprecated (*use [`checkIndex`](#TXEpgSchedulesList+checkIndex) method instead*).
345
+
346
+ <a name="TXEpgSchedulesList+checkIndex"></a>
347
+ ##### **checkIndex(value)** => `boolean`
348
+
349
+ > since: \[`v0.0.30`]
350
+
351
+ This method checks if the given `value` represents a valid index value and fits the range of all possible indexes belonging to the list instance. If so `true` is returned.
345
352
 
346
353
  | parameter name | value type | default value | description |
347
354
  |:---|---|---:|:---|
348
- | `value` | `number`, `string` | --- | a value to be verified |
355
+ | `value` | `number` or `string` | --- | a value to be verified |
349
356
 
350
357
  <a name="TXEpgSchedulesList+schedule"></a>
351
358
  ##### **schedule(index)** => `TXEpgScheduleItem`
@@ -513,8 +520,8 @@ The class constructor receives arguments listed below:
513
520
 
514
521
  | parameter name | value type | default value | description |
515
522
  |:---|---|---:|:---|
516
- |`object`|`object`|---|a host object|
517
- |`options`|`object`|---|an options settings|
523
+ | `object` | `object` | --- | a host object |
524
+ | `options` | `object` | --- | an options settings |
518
525
 
519
526
  #### class properties
520
527
 
@@ -763,7 +770,7 @@ This methods throws `Error` if something goes wrong through a parsing process of
763
770
  <a name="TXmlContentDeclaration"></a>
764
771
  ### **TXmlContentDeclaration**
765
772
 
766
- > since: `v0.0.2x`
773
+ > since: `v0.0.30`
767
774
 
768
775
  This class implements a proxy interface for a document declaration element.
769
776
 
package/index.d.ts CHANGED
@@ -1,10 +1,13 @@
1
+ import { TXEpgScheduleItem } from "./lib/xepg-sched";
2
+ import { TXEpgSchedulesList } from "./lib/xepg-sched";
3
+ import { TXEpgChannelContainer } from "./lib/xepg-channel";
4
+
1
5
  import {
2
6
  TXmlContentParseOptions,
3
7
  } from "@ygracs/xobj-lib-js";
4
8
 
5
9
  import {
6
10
  TXEpgContentProvider,
7
- TXEpgScheduleItem, TXEpgSchedulesList,
8
11
  TXEpgDTSProvider, TXEpgProviderContainer, TXEpgHeaderContainer,
9
12
  TXmlContentDeclaration,
10
13
  } from "./lib/xepgdoc-lib";
@@ -17,6 +20,7 @@ export {
17
20
  TXEpgContentProvider,
18
21
  TXEpgScheduleItem, TXEpgSchedulesList,
19
22
  TXEpgDTSProvider, TXEpgProviderContainer, TXEpgHeaderContainer,
23
+ TXEpgChannelContainer,
20
24
  TXmlContentDeclaration,
21
25
  readAsTagName, readAsAttrName, readAsAttrValue, valueToElementID,
22
26
  TXmlContentParseOptions,
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.1.015-20260304]
1
+ // [v0.1.017-20260531]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -8,6 +8,14 @@ const xObj = require('@ygracs/xobj-lib-js');
8
8
 
9
9
  const xmlBase = require('./lib/xml-base');
10
10
 
11
+ const {
12
+ TXEpgScheduleItem, TXEpgSchedulesList,
13
+ } = require('./lib/xepg-sched');
14
+
15
+ const {
16
+ TXEpgChannelContainer,
17
+ } = require('./lib/xepg-channel');
18
+
11
19
  // === module inner block ===
12
20
 
13
21
  // === module main block ===
@@ -15,9 +23,10 @@ const xmlBase = require('./lib/xml-base');
15
23
  // === module exports block ===
16
24
 
17
25
  /**/// v1 branch
26
+ module.exports.TXEpgScheduleItem = TXEpgScheduleItem;
27
+ module.exports.TXEpgSchedulesList = TXEpgSchedulesList;
28
+ module.exports.TXEpgChannelContainer = TXEpgChannelContainer;
18
29
  module.exports.TXEpgContentProvider = xepgdoc.TXEpgContentProvider;
19
- module.exports.TXEpgScheduleItem = xepgdoc.TXEpgScheduleItem;
20
- module.exports.TXEpgSchedulesList = xepgdoc.TXEpgSchedulesList;
21
30
  module.exports.TXEpgDTSProvider = xepgdoc.TXEpgDTSProvider;
22
31
  module.exports.TXEpgProviderContainer = xepgdoc.TXEpgProviderContainer;
23
32
  module.exports.TXEpgHeaderContainer = xepgdoc.TXEpgHeaderContainer;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A 'DTS'-type descriptor
3
3
  */
4
- export type DTSysDescr = {
4
+ export type IDTSysDescr = {
5
5
  /**
6
6
  * - dtstype ID
7
7
  */
@@ -11,11 +11,28 @@ export type DTSysDescr = {
11
11
  */
12
12
  name: string;
13
13
  };
14
+ export const IDTSysDescr: IDTSysDescr;
14
15
 
16
+ /**
17
+ *
18
+ * @inner
19
+ */
20
+ export function _getDTSTypeValueForXObj(obj: object | null, parseOptions?: object): number;
21
+ /**
22
+ *
23
+ * @inner
24
+ */
25
+ export function _getTZSrcValueFromXObj(obj: object | null, parseOptions?: object): number;
15
26
  /**
16
27
  * Checks if a given value is a valid dtstype ID
28
+ * @deprecated
29
+ * @todo \[since `v0.0.25`] deprecated. Use {@link checkDTSysID} instead
17
30
  */
18
31
  export function chkDTSysID(value: number | string): boolean;
32
+ /**
33
+ * Checks if a given value is a valid dtstype ID
34
+ */
35
+ export function checkDTSysID(value: number | string): boolean;
19
36
  /**
20
37
  * Returns a dtstype name by a given dtstype ID
21
38
  */
@@ -23,7 +40,7 @@ export function getDTSysName(value: number | string): string;
23
40
  /**
24
41
  * Returns a dtstype description for a given dtstype ID
25
42
  */
26
- export function getDTSysDescr(value: number | string): DTSysDescr;
43
+ export function getDTSysDescr(value: number | string): IDTSysDescr;
27
44
  /**
28
45
  * Tries to convert a given string to timestamp
29
46
  * @todo check TZ
@@ -34,4 +51,3 @@ export function convStringToDTValue(value: string, dts_id?: number | string, tz?
34
51
  * @todo check TZ
35
52
  */
36
53
  export function convDTValueToString(value: number | string | Date, dts_id?: number | string, tz?: number | string): string;
37
- export { chkDTSysID as checkDTSysID };
package/lib/dts-helper.js CHANGED
@@ -1,72 +1,118 @@
1
- // [v0.1.050-20260201]
1
+ // [v0.1.054-20260913]
2
2
 
3
3
  // === module init block ===
4
4
 
5
5
  const {
6
6
  valueToIndex,
7
+ readAsNumber,
7
8
  } = require('@ygracs/bsfoc-lib-js');
8
9
 
9
10
  const {
10
11
  isDateObject,
11
12
  convDTValueToISO8601,
12
- convDTValueToXMLTV, convXMLTVToDTValue,
13
+ convDTValueToXMLTV,
14
+ convXMLTVToDTValue,
15
+ convXMLTVToTimestamp,
13
16
  convDTValueToDateString,
14
17
  tryDTValue,
15
18
  } = require('@ygracs/dtf-lib-js');
16
19
 
20
+ const {
21
+ _getXmlChildElementParam,
22
+ } = require('./xml-base');
23
+
17
24
  // === module inner block ===
18
25
 
19
- // === module main block ===
26
+ /**
27
+ * @param {?object} obj - element
28
+ * @param {object} [parseOptions] - parser options
29
+ * @returns {number}
30
+ * @inner
31
+ */
32
+ function _getDTSTypeValueForXObj(obj, parseOptions) {
33
+ const result = valueToIndex(
34
+ _getXmlChildElementParam(obj, 'value', parseOptions)
35
+ );
36
+ return checkDTSysID(result) ? result : 0; //-1; // // TODO: [?]
37
+ };
38
+ module.exports._getDTSTypeValueForXObj = _getDTSTypeValueForXObj;
20
39
 
21
- /***
22
- * (* constant definitions *)
40
+ /**
41
+ *
42
+ * @param {?object} obj - element
43
+ * @param {object} [parseOptions] - parser options
44
+ * @returns {number}
45
+ * @inner
23
46
  */
47
+ function _getTZSrcValueFromXObj(obj, parseOptions) {
48
+ return readAsNumber(_getXmlChildElementParam(obj, 'value', parseOptions));
49
+ };
50
+ module.exports._getTZSrcValueFromXObj = _getTZSrcValueFromXObj;
51
+
52
+ // === module main block ===
24
53
 
25
54
  const def_dts_param = [
26
55
  'default', 'iso8601', 'xmltv', 'timestamp', 'utc',
27
56
  ];
28
57
 
29
- /***
30
- * (* function definitions *)
31
- */
32
-
33
58
  /**
34
59
  * Checks if a given value is a valid dtstype ID
35
60
  * @function chkDTSysID
36
- * @param {(number|string)} value - value to verify
61
+ * @param {number|string} value - value to verify
37
62
  * @returns {boolean}
63
+ * @deprecated
64
+ * @todo \[since `v0.0.25`] deprecated. Use {@link checkDTSysID} instead
38
65
  */
39
66
  function chkDTSysID(value) {
40
67
  const _value = valueToIndex(value);
41
68
  return _value !== -1 && def_dts_param[_value] ? true : false;
42
69
  };
70
+ module.exports.chkDTSysID = chkDTSysID;
71
+
72
+ /**
73
+ * Checks if a given value is a valid dtstype ID
74
+ * @function checkDTSysID
75
+ * @param {number|string} value - value to verify
76
+ * @returns {boolean}
77
+ */
78
+ function checkDTSysID(value) {
79
+ const _value = valueToIndex(value);
80
+ return _value !== -1 && def_dts_param[_value] ? true : false;
81
+ };
82
+ module.exports.checkDTSysID = checkDTSysID;
43
83
 
44
84
  /**
45
85
  * Returns a dtstype name by a given dtstype ID
46
86
  * @function getDTSysName
47
- * @param {(number|string)} value - DTS-type identifier
87
+ * @param {number|string} value - DTS-type identifier
48
88
  * @returns {string}
49
89
  */
50
90
  function getDTSysName(value) {
51
91
  let result = 'undefined';
52
- if (chkDTSysID(value)) {
92
+ if (checkDTSysID(value)) {
53
93
  result = def_dts_param[Number(value)];
54
94
  };
55
95
  return result;
56
96
  };
97
+ module.exports.getDTSysName = getDTSysName;
57
98
 
58
99
  /**
59
100
  * A 'DTS'-type descriptor
60
- * @typedef {Object} DTSysDescr
101
+ * @typedef {Object} IDTSysDescr
61
102
  * @property {number} index - dtstype ID
62
103
  * @property {string} name - dtstype name
63
104
  */
105
+ /**
106
+ * A virtual constant meant for support jsdoc notation:
107
+ * @type {IDTSysDescr}
108
+ */
109
+ module.exports.IDTSysDescr = { index: 0, name: '' };
64
110
 
65
111
  /**
66
112
  * Returns a dtstype description for a given dtstype ID
67
113
  * @function getDTSysDescr
68
- * @param {(number|string)} value - DTS-type identifier
69
- * @returns {DTSysDescr}
114
+ * @param {number|string} value - DTS-type identifier
115
+ * @returns {IDTSysDescr}
70
116
  */
71
117
  function getDTSysDescr(value) {
72
118
  let index = valueToIndex(value);
@@ -83,13 +129,14 @@ function getDTSysDescr(value) {
83
129
  };
84
130
  return { index, name };
85
131
  };
132
+ module.exports.getDTSysDescr = getDTSysDescr;
86
133
 
87
134
  /**
88
135
  * Tries to convert a given string to timestamp
89
136
  * @function convStringToDTValue
90
137
  * @param {string} value - some value
91
- * @param {(number|string)} [dts_id=0] - DTS-type identifier
92
- * @param {(number|string)} [tz] - <*reserved*>
138
+ * @param {number|string} [dts_id=0] - DTS-type identifier
139
+ * @param {number|string} [tz] - <*reserved*>
93
140
  * @returns {number}
94
141
  * @todo check TZ
95
142
  */
@@ -119,8 +166,8 @@ function convStringToDTValue(value, dts_id = 0, tz) {
119
166
  case 'xmltv': {
120
167
  // TODO: check TZ
121
168
  //console.log('convStringToDTValue => dtstype:[xmltv]');
122
- const dt = convXMLTVToDTValue(value, true);
123
- if (dt !== null) result = isDateObject(dt) ? dt.getTime() : dt;
169
+ const dt = convXMLTVToTimestamp(value);
170
+ if (dt !== null) result = dt;
124
171
  //console.log('convStringToDTValue => value:['+value+']');
125
172
  //console.log('convStringToDTValue => result:['+result+']');
126
173
  break;
@@ -149,13 +196,14 @@ function convStringToDTValue(value, dts_id = 0, tz) {
149
196
  };
150
197
  return result;
151
198
  };
199
+ module.exports.convStringToDTValue = convStringToDTValue;
152
200
 
153
201
  /**
154
202
  * Tries to convert a given value to its string representation
155
203
  * @function convDTValueToString
156
- * @param {(number|string|Date)} value - some value
157
- * @param {(number|string)} [dts_id=0] - DTS-type identifier
158
- * @param {(number|string)} [tz] - <*reserved*>
204
+ * @param {number|string|Date} value - some value
205
+ * @param {number|string} [dts_id=0] - DTS-type identifier
206
+ * @param {number|string} [tz] - <*reserved*>
159
207
  * @returns {string}
160
208
  * @todo check TZ
161
209
  */
@@ -164,13 +212,13 @@ function convDTValueToString(value, dts_id, tz) {
164
212
  let dt_val = isSucceed && dtValue != null ? dtValue.getTime() : new Date(0);
165
213
  let result = '';
166
214
  let dtstype = valueToIndex(dts_id);
167
- if (!chkDTSysID(dtstype)) dtstype = 0;
215
+ if (!checkDTSysID(dtstype)) dtstype = 0;
168
216
  switch (getDTSysName(dtstype)) {
169
217
  case 'default': {
170
218
  // TODO: check TZ
171
219
  //console.log('convDTValueToString => dtstype:[default]');
172
220
  result = convDTValueToDateString(dt_val, {
173
- src_in_utc: false,
221
+ //src_in_utc: false,
174
222
  });
175
223
  //console.log('convDTValueToString => value:['+value+']');
176
224
  //console.log('convDTValueToString => result:['+result+']');
@@ -180,9 +228,7 @@ function convDTValueToString(value, dts_id, tz) {
180
228
  // TODO: check TZ
181
229
  //console.log('convDTValueToString => dtstype:[iso8601]');
182
230
  result = convDTValueToISO8601(dt_val, {
183
- //use_bs_format: false,
184
231
  useBaseFormat: false,
185
- src_in_utc: false,
186
232
  });
187
233
  //console.log('convDTValueToString => value:['+value+']');
188
234
  //console.log('convDTValueToString => result:['+result+']');
@@ -191,9 +237,7 @@ function convDTValueToString(value, dts_id, tz) {
191
237
  case 'xmltv': {
192
238
  // TODO: check TZ
193
239
  //console.log('convDTValueToString => dtstype:[xmltv]');
194
- result = convDTValueToXMLTV(dt_val, {
195
- src_in_utc: false,
196
- });
240
+ result = convDTValueToXMLTV(dt_val, {});
197
241
  //console.log('convDTValueToString => value:['+value+']');
198
242
  //console.log('convDTValueToString => result:['+result+']');
199
243
  break;
@@ -210,16 +254,4 @@ function convDTValueToString(value, dts_id, tz) {
210
254
  };
211
255
  return result;
212
256
  };
213
-
214
- /***
215
- * (* class definitions *)
216
- */
217
-
218
- // === module exports block ===
219
-
220
- exports.chkDTSysID = chkDTSysID;
221
- exports.checkDTSysID = chkDTSysID;
222
- exports.getDTSysName = getDTSysName;
223
- exports.getDTSysDescr = getDTSysDescr;
224
- exports.convStringToDTValue = convStringToDTValue;
225
- exports.convDTValueToString = convDTValueToString;
257
+ module.exports.convDTValueToString = convDTValueToString;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @deprecated
3
+ */
4
+ export type setInfoParam = string;
5
+ export const setInfoParam: setInfoParam;
6
+ /**
7
+ * A channel info descriptor
8
+ */
9
+ export type IXEpgChnInfoDesc = {
10
+ /**
11
+ * - channel ID
12
+ */
13
+ chnid: string;
14
+ /**
15
+ * - channel name
16
+ */
17
+ chname: string;
18
+ /**
19
+ * - channel 'Group ID'
20
+ */
21
+ chngid?: string;
22
+ /**
23
+ * - EPG-source URL
24
+ */
25
+ srcurl?: string;
26
+ };
27
+ export const IXEpgChnInfoDesc: IXEpgChnInfoDesc;
28
+ /**
29
+ * An XEPG-element options set (base)
30
+ */
31
+ export type OPT_epgelsett_bs = {
32
+ /**
33
+ * - parser options
34
+ */
35
+ parseOptions?: InstanceType<typeof TXmlContentParseOptions>;
36
+ };
37
+ /**
38
+ * An XEPG-element options set (base)
39
+ */
40
+ export type XEpgElementConfigBase = {
41
+ /**
42
+ * - parser options
43
+ */
44
+ parseOptions: InstanceType<typeof TXmlContentParseOptions>;
45
+ };
46
+
47
+ /**
48
+ * This class implements an interface of a channel element
49
+ * @since 0.0.22
50
+ */
51
+ export class TXEpgChannelContainer {
52
+ /**
53
+ * Creates an instance of the channel element
54
+ */
55
+ constructor(obj: INode, opt?: OPT_epgelsett_bs);
56
+ /**
57
+ * Contains a channel ID
58
+ */
59
+ get id(): string;
60
+ /**
61
+ * Contains a channel name
62
+ */
63
+ get name(): string;
64
+ set name(value: string);
65
+ /**
66
+ * Contains a channel Group ID
67
+ */
68
+ get gid(): string;
69
+ set gid(value: string);
70
+ /**
71
+ * Contains a channel source URL
72
+ */
73
+ get url(): string;
74
+ set url(value: string);
75
+ /**
76
+ * Tries to set a channel ID
77
+ */
78
+ setID(value: string): boolean;
79
+ /**
80
+ * Returns a channel info
81
+ */
82
+ getInfo(): IXEpgChnInfoDesc;
83
+ /**
84
+ * Sets a channel info
85
+ */
86
+ setInfo(obj: setInfoParam | IXEpgChnInfoDesc): void;
87
+ #private;
88
+ }
89
+
90
+ import { TXmlContentParseOptions } from "@ygracs/xobj-lib-js";
91
+ import type { INode } from "@ygracs/xobj-lib-js";