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

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,3 +1,19 @@
1
+ #### *v0.0.xx*
2
+
3
+ Pre-release version.
4
+
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;
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;
11
+ > - add new class: `TXmlContentDeclaration`;
12
+ > - (`TXEpgContentProvider`) change behavior for methods: `loadFromFile`, `loadFromFileSync`;
13
+ > - (`TXEpgContentProvider`) remove deprecated properties: `SchedulesList`;
14
+ > - (`TXEpgHeaderContainer`) remove deprecated methods: `setProviderInfo`, `setChannelInfo`;
15
+ > - (`TXEpgSchedulesList`) remove deprecated methods: `hasSchedules`, `hasNoSchedules`;
16
+
1
17
  #### *v0.0.25*
2
18
 
3
19
  Pre-release version.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019-2025 Yuri Grachev
3
+ Copyright (c) 2019-2026 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
 
@@ -1,6 +1,6 @@
1
- |***rev.*:**|0.1.43|
1
+ |***rev.*:**|0.1.45|
2
2
  |:---|---:|
3
- |***date***:|2025-08-25|
3
+ |***date***:|2026-03-05|
4
4
 
5
5
  ## Introduction
6
6
 
@@ -322,11 +322,6 @@ The class constructor receives arguments listed below:
322
322
 
323
323
  #### class methods
324
324
 
325
- <a name="TXEpgSchedulesList+hasNoSchedules"></a>
326
- ##### **hasNoSchedules()** => `boolean`
327
-
328
- > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`isEmpty` method](#TXEpgSchedulesList+isEmpty) instead.
329
-
330
325
  <a name="TXEpgSchedulesList+isEmpty"></a>
331
326
  ##### **isEmpty()** => `boolean`
332
327
 
@@ -334,11 +329,6 @@ The class constructor receives arguments listed below:
334
329
 
335
330
  This method returns `true` if a document contains no schedules.
336
331
 
337
- <a name="TXEpgSchedulesList+hasSchedules"></a>
338
- ##### **hasSchedules()** => `boolean`
339
-
340
- > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`isNotEmpty` method](#TXEpgSchedulesList+isNotEmpty) instead.
341
-
342
332
  <a name="TXEpgSchedulesList+isNotEmpty"></a>
343
333
  ##### **isNotEmpty()** => `boolean`
344
334
 
@@ -739,45 +729,11 @@ An object contains the following fields:
739
729
  |`chname`|`string`|a name of the channel|
740
730
  |`srcurl`|`string`|a link to source|
741
731
 
742
- <a name="TXEpgHeaderContainer+setChannelInfo"></a>
743
- ##### **setChannelInfo(obj)** => `void`
744
-
745
- > \[!] WARNING: `[since v0.0.22]` deprecated. Use [`TXEpgChannelContainer.setInfo()`](#TXEpgChannelContainer+setInfo) instead.
746
-
747
- This method fills a channel information with a given data.
748
-
749
- | parameter name | value type | default value | description |
750
- |:---|---|---:|:---|
751
- | `obj` | `xepgChnInfoDesc` | --- | channel info descriptor |
752
-
753
- > \[!] NOTE: `[since v0.0.21]` a use of a `string` or `array` types a as values of an `obj` are deprecated and will be dropped soon.
754
-
755
- The `obj` parameter can be a string or an array or an object.
756
-
757
- If a string is given it mean to contains the `chnid` value.
758
-
759
- If an array is given it contains the following fields:
760
-
761
- `[ <chnid>, <chname>, <chngid>, <srcurl> ]`
762
-
763
- If an object is given it contains the following fields:
764
-
765
- |field name|field type|description|
766
- |:---|---|:---|
767
- |`chnid`|`string`|a channel ID|
768
- |`chname`|`string`|a name of the channel|
769
- |`chngid`|`string`|a channel group|
770
- |`srcurl`|`string`|a link to source|
771
-
772
732
  <a name="TXEpgHeaderContainer+getProviderInfo"></a>
773
733
  ##### **getProviderInfo()** => `xepgProvInfoDesc`
774
734
 
775
735
  This method returns an object which contains an information about document provider.
776
736
 
777
- ##### **setProviderInfo(obj)**
778
-
779
- > \[!] WARNING: `[since v0.0.24]` deprecated. Use [`TXEpgProviderContainer.setInfo()`](#TXEpgProviderContainer+setInfo) instead.
780
-
781
737
  <a name="TXEpgHeaderContainer+saveToXMLString"></a>
782
738
  ##### **saveToXMLString()** => `string`
783
739
 
@@ -804,6 +760,60 @@ This method loads an element content from a string given by a `str` parameter.
804
760
 
805
761
  This methods throws `Error` if something goes wrong through a parsing process of a string.
806
762
 
763
+ <a name="TXmlContentDeclaration"></a>
764
+ ### **TXmlContentDeclaration**
765
+
766
+ > since: `v0.0.2x`
767
+
768
+ This class implements a proxy interface for a document declaration element.
769
+
770
+ #### class constructor
771
+
772
+ The class constructor creates a new instance of the class.
773
+
774
+ ##### constructor parameters
775
+
776
+ The class constructor receives an arguments listed below:
777
+
778
+ | parameter name | value type | default value | description |
779
+ |:---|---|---:|:---|
780
+ | `object` | `object` | --- | a host object for the document content |
781
+ | `options` | `object` | --- | an options settings |
782
+
783
+ ###### `options` parameter
784
+
785
+ The `options` structure is listed below:
786
+
787
+ | option name | value type | default value | description |
788
+ |:---|---|---:|:---|
789
+ | `parseOptions` | `object` | `EMPTY_OBJECT` | contains a XML-parse options (see description for `XML_DEF_PARSE_OPTIONS`) |
790
+
791
+ ##### exceptions
792
+
793
+ If `object` parameter is not a type of `object` or not given a `TypeError` thrown.
794
+
795
+ #### class properties
796
+
797
+ <a name="TXmlContentDeclaration+version"></a>
798
+ ##### **version**
799
+
800
+ | property type | read only | description |
801
+ |---|---|:---|
802
+ | `string` | no | returns a version of an XML |
803
+
804
+ <a name="TXmlContentDeclaration+encoding"></a>
805
+ ##### **encoding**
806
+
807
+ | property type | read only | description |
808
+ |---|---|:---|
809
+ | `string` | no | returns a name of the character set used by the document |
810
+
811
+ #### class methods (*special*)
812
+
813
+ ##### **init()** => `void`
814
+
815
+ This method initializes an element with a default values.
816
+
807
817
  <a name="TXEpgContentProvider"></a>
808
818
  ### **TXEpgContentProvider**
809
819
 
@@ -853,11 +863,6 @@ The `options` structure is listed below:
853
863
  |---|---|:---|
854
864
  | `TXEpgDTSProvider` | yes | returns a `TXEpgDTSProvider` instance |
855
865
 
856
- <a name="TXEpgContentProvider+SchedulesList"></a>
857
- ##### **SchedulesList**
858
-
859
- > \[!] NOTE: `[since v0.0.24]` deprecated. Use [`schedules` property](#TXEpgContentProvider+schedules) instead.
860
-
861
866
  <a name="TXEpgContentProvider+schedules"></a>
862
867
  ##### **schedules**
863
868
 
package/index.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import {
2
+ TXmlContentParseOptions,
3
+ } from "@ygracs/xobj-lib-js";
4
+
5
+ import {
6
+ TXEpgContentProvider,
7
+ TXEpgScheduleItem, TXEpgSchedulesList,
8
+ TXEpgDTSProvider, TXEpgProviderContainer, TXEpgHeaderContainer,
9
+ TXmlContentDeclaration,
10
+ } from "./lib/xepgdoc-lib";
11
+
12
+ import {
13
+ readAsTagName, readAsAttrName, readAsAttrValue, valueToElementID,
14
+ } from "./lib/xml-base";
15
+
16
+ export {
17
+ TXEpgContentProvider,
18
+ TXEpgScheduleItem, TXEpgSchedulesList,
19
+ TXEpgDTSProvider, TXEpgProviderContainer, TXEpgHeaderContainer,
20
+ TXmlContentDeclaration,
21
+ readAsTagName, readAsAttrName, readAsAttrValue, valueToElementID,
22
+ TXmlContentParseOptions,
23
+ };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // [v0.1.014-20250825]
1
+ // [v0.1.015-20260304]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -21,6 +21,7 @@ module.exports.TXEpgSchedulesList = xepgdoc.TXEpgSchedulesList;
21
21
  module.exports.TXEpgDTSProvider = xepgdoc.TXEpgDTSProvider;
22
22
  module.exports.TXEpgProviderContainer = xepgdoc.TXEpgProviderContainer;
23
23
  module.exports.TXEpgHeaderContainer = xepgdoc.TXEpgHeaderContainer;
24
+ module.exports.TXmlContentDeclaration = xepgdoc.TXmlContentDeclaration;
24
25
 
25
26
  module.exports.readAsTagName = xmlBase.readAsTagName;
26
27
  module.exports.readAsAttrName = xmlBase.readAsAttrName;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A 'DTS'-type descriptor
3
+ */
4
+ export type DTSysDescr = {
5
+ /**
6
+ * - dtstype ID
7
+ */
8
+ index: number;
9
+ /**
10
+ * - dtstype name
11
+ */
12
+ name: string;
13
+ };
14
+
15
+ /**
16
+ * Checks if a given value is a valid dtstype ID
17
+ */
18
+ export function chkDTSysID(value: number | string): boolean;
19
+ /**
20
+ * Returns a dtstype name by a given dtstype ID
21
+ */
22
+ export function getDTSysName(value: number | string): string;
23
+ /**
24
+ * Returns a dtstype description for a given dtstype ID
25
+ */
26
+ export function getDTSysDescr(value: number | string): DTSysDescr;
27
+ /**
28
+ * Tries to convert a given string to timestamp
29
+ * @todo check TZ
30
+ */
31
+ export function convStringToDTValue(value: string, dts_id?: number | string, tz?: number | string): number;
32
+ /**
33
+ * Tries to convert a given value to its string representation
34
+ * @todo check TZ
35
+ */
36
+ 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,4 +1,4 @@
1
- // [v0.1.048-20250727]
1
+ // [v0.1.050-20260201]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -7,13 +7,14 @@ const {
7
7
  } = require('@ygracs/bsfoc-lib-js');
8
8
 
9
9
  const {
10
+ isDateObject,
10
11
  convDTValueToISO8601,
11
12
  convDTValueToXMLTV, convXMLTVToDTValue,
12
13
  convDTValueToDateString,
13
14
  tryDTValue,
14
15
  } = require('@ygracs/dtf-lib-js');
15
16
 
16
- // === module extra block (helper functions) ===
17
+ // === module inner block ===
17
18
 
18
19
  // === module main block ===
19
20
 
@@ -118,8 +119,8 @@ function convStringToDTValue(value, dts_id = 0, tz) {
118
119
  case 'xmltv': {
119
120
  // TODO: check TZ
120
121
  //console.log('convStringToDTValue => dtstype:[xmltv]');
121
- const dtValue = convXMLTVToDTValue(value, true);
122
- if (dtValue !== null) result = dtValue;
122
+ const dt = convXMLTVToDTValue(value, true);
123
+ if (dt !== null) result = isDateObject(dt) ? dt.getTime() : dt;
123
124
  //console.log('convStringToDTValue => value:['+value+']');
124
125
  //console.log('convStringToDTValue => result:['+result+']');
125
126
  break;
@@ -128,7 +129,7 @@ function convStringToDTValue(value, dts_id = 0, tz) {
128
129
  // TODO: check TZ
129
130
  //console.log('convStringToDTValue => dtstype:[timestamp]');
130
131
  const { isSucceed, value: dtValue } = tryDTValue(value);
131
- if (isSucceed) result = dtValue.getTime();
132
+ if (isSucceed && dtValue != null) result = dtValue.getTime();
132
133
  //console.log('convStringToDTValue => value:['+value+']');
133
134
  //console.log('convStringToDTValue => result:['+result+']');
134
135
  break;
@@ -160,7 +161,7 @@ function convStringToDTValue(value, dts_id = 0, tz) {
160
161
  */
161
162
  function convDTValueToString(value, dts_id, tz) {
162
163
  let { isSucceed, value: dtValue } = tryDTValue(value);
163
- let dt_val = isSucceed ? dtValue.getTime() : new Date(0);
164
+ let dt_val = isSucceed && dtValue != null ? dtValue.getTime() : new Date(0);
164
165
  let result = '';
165
166
  let dtstype = valueToIndex(dts_id);
166
167
  if (!chkDTSysID(dtstype)) dtstype = 0;