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

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,23 @@
1
- #### *v0.0.xx*
1
+ #### *v0.0.30*
2
2
 
3
3
  Pre-release version.
4
4
 
5
5
  > - 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;
6
+ > - update dependency on `@ygracs/xml-js6` module to v0.0.9-b;
7
+ > - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.4;
8
8
  > - 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;
9
+ > - update dependency on `@ygracs/xobj-lib-js` module to v0.3.3;
10
+ > - update dependency on `@cntwg/file-helper` module to v0.0.4;
11
11
  > - add new class: `TXmlContentDeclaration`;
12
12
  > - (`TXEpgContentProvider`) change behavior for methods: `loadFromFile`, `loadFromFileSync`;
13
13
  > - (`TXEpgContentProvider`) remove deprecated properties: `SchedulesList`;
14
14
  > - (`TXEpgHeaderContainer`) remove deprecated methods: `setProviderInfo`, `setChannelInfo`;
15
+ > - (`TXEpgProviderContainer`) change behavior for methods: `init`;
16
+ > - (`TXEpgChannelContainer`) change behavior for methods: `setInfo`;
17
+ > - (`TXEpgSchedulesList`) add new methods: `checkIndex`;
18
+ > - (`TXEpgSchedulesList`) deprecate methods: `chkIndex`;
15
19
  > - (`TXEpgSchedulesList`) remove deprecated methods: `hasSchedules`, `hasNoSchedules`;
20
+ > - other fixes.
16
21
 
17
22
  #### *v0.0.25*
18
23
 
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,9 +1,10 @@
1
- // [v0.1.050-20260201]
1
+ // [v0.1.053-20260531]
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 {
@@ -14,59 +15,102 @@ const {
14
15
  tryDTValue,
15
16
  } = require('@ygracs/dtf-lib-js');
16
17
 
18
+ const {
19
+ _getXmlChildElementParam,
20
+ } = require('./xml-base');
21
+
17
22
  // === module inner block ===
18
23
 
19
- // === module main block ===
24
+ /**
25
+ * @param {?object} obj - element
26
+ * @param {object} [parseOptions] - parser options
27
+ * @returns {number}
28
+ * @inner
29
+ */
30
+ function _getDTSTypeValueForXObj(obj, parseOptions) {
31
+ const result = valueToIndex(
32
+ _getXmlChildElementParam(obj, 'value', parseOptions)
33
+ );
34
+ return checkDTSysID(result) ? result : 0; //-1; // // TODO: [?]
35
+ };
36
+ module.exports._getDTSTypeValueForXObj = _getDTSTypeValueForXObj;
20
37
 
21
- /***
22
- * (* constant definitions *)
38
+ /**
39
+ *
40
+ * @param {?object} obj - element
41
+ * @param {object} [parseOptions] - parser options
42
+ * @returns {number}
43
+ * @inner
23
44
  */
45
+ function _getTZSrcValueFromXObj(obj, parseOptions) {
46
+ return readAsNumber(_getXmlChildElementParam(obj, 'value', parseOptions));
47
+ };
48
+ module.exports._getTZSrcValueFromXObj = _getTZSrcValueFromXObj;
49
+
50
+ // === module main block ===
24
51
 
25
52
  const def_dts_param = [
26
53
  'default', 'iso8601', 'xmltv', 'timestamp', 'utc',
27
54
  ];
28
55
 
29
- /***
30
- * (* function definitions *)
31
- */
32
-
33
56
  /**
34
57
  * Checks if a given value is a valid dtstype ID
35
58
  * @function chkDTSysID
36
- * @param {(number|string)} value - value to verify
59
+ * @param {number|string} value - value to verify
37
60
  * @returns {boolean}
61
+ * @deprecated
62
+ * @todo \[since `v0.0.25`] deprecated. Use {@link checkDTSysID} instead
38
63
  */
39
64
  function chkDTSysID(value) {
40
65
  const _value = valueToIndex(value);
41
66
  return _value !== -1 && def_dts_param[_value] ? true : false;
42
67
  };
68
+ module.exports.chkDTSysID = chkDTSysID;
69
+
70
+ /**
71
+ * Checks if a given value is a valid dtstype ID
72
+ * @function checkDTSysID
73
+ * @param {number|string} value - value to verify
74
+ * @returns {boolean}
75
+ */
76
+ function checkDTSysID(value) {
77
+ const _value = valueToIndex(value);
78
+ return _value !== -1 && def_dts_param[_value] ? true : false;
79
+ };
80
+ module.exports.checkDTSysID = checkDTSysID;
43
81
 
44
82
  /**
45
83
  * Returns a dtstype name by a given dtstype ID
46
84
  * @function getDTSysName
47
- * @param {(number|string)} value - DTS-type identifier
85
+ * @param {number|string} value - DTS-type identifier
48
86
  * @returns {string}
49
87
  */
50
88
  function getDTSysName(value) {
51
89
  let result = 'undefined';
52
- if (chkDTSysID(value)) {
90
+ if (checkDTSysID(value)) {
53
91
  result = def_dts_param[Number(value)];
54
92
  };
55
93
  return result;
56
94
  };
95
+ module.exports.getDTSysName = getDTSysName;
57
96
 
58
97
  /**
59
98
  * A 'DTS'-type descriptor
60
- * @typedef {Object} DTSysDescr
99
+ * @typedef {Object} IDTSysDescr
61
100
  * @property {number} index - dtstype ID
62
101
  * @property {string} name - dtstype name
63
102
  */
103
+ /**
104
+ * A virtual constant meant for support jsdoc notation:
105
+ * @type {IDTSysDescr}
106
+ */
107
+ module.exports.IDTSysDescr = { index: 0, name: '' };
64
108
 
65
109
  /**
66
110
  * Returns a dtstype description for a given dtstype ID
67
111
  * @function getDTSysDescr
68
- * @param {(number|string)} value - DTS-type identifier
69
- * @returns {DTSysDescr}
112
+ * @param {number|string} value - DTS-type identifier
113
+ * @returns {IDTSysDescr}
70
114
  */
71
115
  function getDTSysDescr(value) {
72
116
  let index = valueToIndex(value);
@@ -83,13 +127,14 @@ function getDTSysDescr(value) {
83
127
  };
84
128
  return { index, name };
85
129
  };
130
+ module.exports.getDTSysDescr = getDTSysDescr;
86
131
 
87
132
  /**
88
133
  * Tries to convert a given string to timestamp
89
134
  * @function convStringToDTValue
90
135
  * @param {string} value - some value
91
- * @param {(number|string)} [dts_id=0] - DTS-type identifier
92
- * @param {(number|string)} [tz] - <*reserved*>
136
+ * @param {number|string} [dts_id=0] - DTS-type identifier
137
+ * @param {number|string} [tz] - <*reserved*>
93
138
  * @returns {number}
94
139
  * @todo check TZ
95
140
  */
@@ -149,13 +194,14 @@ function convStringToDTValue(value, dts_id = 0, tz) {
149
194
  };
150
195
  return result;
151
196
  };
197
+ module.exports.convStringToDTValue = convStringToDTValue;
152
198
 
153
199
  /**
154
200
  * Tries to convert a given value to its string representation
155
201
  * @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*>
202
+ * @param {number|string|Date} value - some value
203
+ * @param {number|string} [dts_id=0] - DTS-type identifier
204
+ * @param {number|string} [tz] - <*reserved*>
159
205
  * @returns {string}
160
206
  * @todo check TZ
161
207
  */
@@ -164,13 +210,13 @@ function convDTValueToString(value, dts_id, tz) {
164
210
  let dt_val = isSucceed && dtValue != null ? dtValue.getTime() : new Date(0);
165
211
  let result = '';
166
212
  let dtstype = valueToIndex(dts_id);
167
- if (!chkDTSysID(dtstype)) dtstype = 0;
213
+ if (!checkDTSysID(dtstype)) dtstype = 0;
168
214
  switch (getDTSysName(dtstype)) {
169
215
  case 'default': {
170
216
  // TODO: check TZ
171
217
  //console.log('convDTValueToString => dtstype:[default]');
172
218
  result = convDTValueToDateString(dt_val, {
173
- src_in_utc: false,
219
+ //src_in_utc: false,
174
220
  });
175
221
  //console.log('convDTValueToString => value:['+value+']');
176
222
  //console.log('convDTValueToString => result:['+result+']');
@@ -180,9 +226,7 @@ function convDTValueToString(value, dts_id, tz) {
180
226
  // TODO: check TZ
181
227
  //console.log('convDTValueToString => dtstype:[iso8601]');
182
228
  result = convDTValueToISO8601(dt_val, {
183
- //use_bs_format: false,
184
229
  useBaseFormat: false,
185
- src_in_utc: false,
186
230
  });
187
231
  //console.log('convDTValueToString => value:['+value+']');
188
232
  //console.log('convDTValueToString => result:['+result+']');
@@ -191,9 +235,7 @@ function convDTValueToString(value, dts_id, tz) {
191
235
  case 'xmltv': {
192
236
  // TODO: check TZ
193
237
  //console.log('convDTValueToString => dtstype:[xmltv]');
194
- result = convDTValueToXMLTV(dt_val, {
195
- src_in_utc: false,
196
- });
238
+ result = convDTValueToXMLTV(dt_val, {});
197
239
  //console.log('convDTValueToString => value:['+value+']');
198
240
  //console.log('convDTValueToString => result:['+result+']');
199
241
  break;
@@ -210,16 +252,4 @@ function convDTValueToString(value, dts_id, tz) {
210
252
  };
211
253
  return result;
212
254
  };
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;
255
+ 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";