@ygracs/xepg-lib-js 0.0.24 → 0.0.26-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 +21 -0
- package/LICENSE +1 -1
- package/README.md +3 -2
- package/doc/xepgdoc-lib.md +13 -17
- package/index.d.ts +21 -0
- package/index.js +7 -4
- package/lib/dts-helper.d.ts +37 -0
- package/lib/dts-helper.js +3 -3
- package/lib/xepgdoc-lib.d.ts +596 -0
- package/lib/xepgdoc-lib.js +35 -136
- package/lib/xml-base.d.ts +21 -0
- package/lib/xml-base.js +133 -0
- package/package.json +18 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
#### *v0.0.xx*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.3;
|
|
6
|
+
> - update dependency on `@ygracs/dtf-lib-js` module to v0.0.33;
|
|
7
|
+
> - update dependency on `@cntwg/file-helper` module to v0.0.3;
|
|
8
|
+
|
|
9
|
+
#### *v0.0.25*
|
|
10
|
+
|
|
11
|
+
Pre-release version.
|
|
12
|
+
|
|
13
|
+
> - update `xepgdoc-lib.md`;
|
|
14
|
+
> - update dependency on `@ygracs/bsfoc-lib-js` module to v0.3.0;
|
|
15
|
+
> - update dependency on `@ygracs/dtf-lib-js` module to v0.0.30;
|
|
16
|
+
> - update dependency on `@ygracs/xobj-lib-js` module to v0.2.4;
|
|
17
|
+
> - move some functions from `$lib/xepgdoc-lib.js` into new `$lib/xml-base.js` module;
|
|
18
|
+
> - add function: `readAsAttrValue`;
|
|
19
|
+
> - (`TXEpgHeaderContainer`) remove deprecated property: `Provider`;
|
|
20
|
+
> - (`TXEpgContentProvider`) remove deprecated properties: `Header`, `Provider`.
|
|
21
|
+
|
|
1
22
|
#### *v0.0.24*
|
|
2
23
|
|
|
3
24
|
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-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
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|***rev.*:**|0.0.
|
|
1
|
+
|***rev.*:**|0.0.11|
|
|
2
2
|
|:---|---:|
|
|
3
|
-
|***date***:|2025-
|
|
3
|
+
|***date***:|2025-08-25|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -20,6 +20,7 @@ This module contains the following components:
|
|
|
20
20
|
|
|
21
21
|
+ `readAsTagName`;
|
|
22
22
|
+ `readAsAttrName`;
|
|
23
|
+
+ `readAsAttrValue`;
|
|
23
24
|
+ `valueToElementID`;
|
|
24
25
|
|
|
25
26
|
- classes:
|
package/doc/xepgdoc-lib.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|***rev.*:**|0.1.
|
|
1
|
+
|***rev.*:**|0.1.43|
|
|
2
2
|
|:---|---:|
|
|
3
|
-
|***date***:|2025-
|
|
3
|
+
|***date***:|2025-08-25|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
@@ -91,6 +91,17 @@ This function tries to convert a given `value` to the value of type which is sui
|
|
|
91
91
|
|:---|---|---:|:---|
|
|
92
92
|
| `value` | `any` | --- | some value to read |
|
|
93
93
|
|
|
94
|
+
<a name="readAsAttrValue"></a>
|
|
95
|
+
#### **readAsAttrValue(value)** => `string`
|
|
96
|
+
|
|
97
|
+
> since: \[`v0.0.25`]
|
|
98
|
+
|
|
99
|
+
This function tries to convert a given `value` to the value of type which is suitable for an XML-element's attribute. If failed a `null` is returned.
|
|
100
|
+
|
|
101
|
+
| parameter name | value type | default value | description |
|
|
102
|
+
|:---|---|---:|:---|
|
|
103
|
+
| `value` | `any` | --- | some value |
|
|
104
|
+
|
|
94
105
|
<a name="valueToElementID"></a>
|
|
95
106
|
#### **valueToElementID(value)**
|
|
96
107
|
|
|
@@ -670,11 +681,6 @@ The `options` structure is listed below:
|
|
|
670
681
|
|---|---|:---|
|
|
671
682
|
| `number` | no | defines a current TimeZone |
|
|
672
683
|
|
|
673
|
-
<a name="TXEpgHeaderContainer+Provider"></a>
|
|
674
|
-
##### **Provider**
|
|
675
|
-
|
|
676
|
-
> \[!] NOTE: `[since v0.0.22]` deprecated. Use [`provider` property](#TXEpgHeaderContainer+provider) instead.
|
|
677
|
-
|
|
678
684
|
<a name="TXEpgHeaderContainer+provider"></a>
|
|
679
685
|
##### **provider**
|
|
680
686
|
|
|
@@ -822,11 +828,6 @@ The `options` structure is listed below:
|
|
|
822
828
|
|
|
823
829
|
#### class properties
|
|
824
830
|
|
|
825
|
-
<a name="TXEpgContentProvider+Header"></a>
|
|
826
|
-
##### **Header**
|
|
827
|
-
|
|
828
|
-
> \[!] NOTE: `[since v0.0.22]` deprecated. Use [`header` property](#TXEpgContentProvider+header) instead.
|
|
829
|
-
|
|
830
831
|
<a name="TXEpgContentProvider+header"></a>
|
|
831
832
|
##### **header**
|
|
832
833
|
|
|
@@ -836,11 +837,6 @@ The `options` structure is listed below:
|
|
|
836
837
|
|---|---|:---|
|
|
837
838
|
| `TXEpgHeaderContainer` | yes | returns a `TXEpgHeaderContainer` instance |
|
|
838
839
|
|
|
839
|
-
<a name="TXEpgContentProvider+Provider"></a>
|
|
840
|
-
##### **Provider**
|
|
841
|
-
|
|
842
|
-
> \[!] NOTE: `[since v0.0.22]` deprecated. Use [`provider` property](#TXEpgContentProvider+provider) instead.
|
|
843
|
-
|
|
844
840
|
<a name="TXEpgContentProvider+provider"></a>
|
|
845
841
|
##### **provider**
|
|
846
842
|
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TXmlContentParseOptions,
|
|
3
|
+
} from "@ygracs/xobj-lib-js";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
TXEpgContentProvider,
|
|
7
|
+
TXEpgScheduleItem, TXEpgSchedulesList,
|
|
8
|
+
TXEpgDTSProvider, TXEpgProviderContainer, TXEpgHeaderContainer,
|
|
9
|
+
} from "./lib/xepgdoc-lib";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
readAsTagName, readAsAttrName, readAsAttrValue, valueToElementID,
|
|
13
|
+
} from "./lib/xml-base";
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
TXEpgContentProvider,
|
|
17
|
+
TXEpgScheduleItem, TXEpgSchedulesList,
|
|
18
|
+
TXEpgDTSProvider, TXEpgProviderContainer, TXEpgHeaderContainer,
|
|
19
|
+
readAsTagName, readAsAttrName, readAsAttrValue, valueToElementID,
|
|
20
|
+
TXmlContentParseOptions,
|
|
21
|
+
};
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.1.
|
|
1
|
+
// [v0.1.014-20250825]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -6,6 +6,8 @@ const xepgdoc = require('./lib/xepgdoc-lib.js');
|
|
|
6
6
|
|
|
7
7
|
const xObj = require('@ygracs/xobj-lib-js');
|
|
8
8
|
|
|
9
|
+
const xmlBase = require('./lib/xml-base');
|
|
10
|
+
|
|
9
11
|
// === module inner block ===
|
|
10
12
|
|
|
11
13
|
// === module main block ===
|
|
@@ -20,9 +22,10 @@ module.exports.TXEpgDTSProvider = xepgdoc.TXEpgDTSProvider;
|
|
|
20
22
|
module.exports.TXEpgProviderContainer = xepgdoc.TXEpgProviderContainer;
|
|
21
23
|
module.exports.TXEpgHeaderContainer = xepgdoc.TXEpgHeaderContainer;
|
|
22
24
|
|
|
23
|
-
module.exports.readAsTagName =
|
|
24
|
-
module.exports.readAsAttrName =
|
|
25
|
-
module.exports.
|
|
25
|
+
module.exports.readAsTagName = xmlBase.readAsTagName;
|
|
26
|
+
module.exports.readAsAttrName = xmlBase.readAsAttrName;
|
|
27
|
+
module.exports.readAsAttrValue = xmlBase.readAsAttrValue;
|
|
28
|
+
module.exports.valueToElementID = xmlBase.valueToElementID;
|
|
26
29
|
|
|
27
30
|
// re-export stuff from `@ygracs/xobj-lib-js` module
|
|
28
31
|
module.exports.TXmlContentParseOptions = xObj.TXmlContentParseOptions;
|
|
@@ -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.
|
|
1
|
+
// [v0.1.049-20260101]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -128,7 +128,7 @@ function convStringToDTValue(value, dts_id = 0, tz) {
|
|
|
128
128
|
// TODO: check TZ
|
|
129
129
|
//console.log('convStringToDTValue => dtstype:[timestamp]');
|
|
130
130
|
const { isSucceed, value: dtValue } = tryDTValue(value);
|
|
131
|
-
if (isSucceed) result = dtValue.getTime();
|
|
131
|
+
if (isSucceed && dtValue != null) result = dtValue.getTime();
|
|
132
132
|
//console.log('convStringToDTValue => value:['+value+']');
|
|
133
133
|
//console.log('convStringToDTValue => result:['+result+']');
|
|
134
134
|
break;
|
|
@@ -160,7 +160,7 @@ function convStringToDTValue(value, dts_id = 0, tz) {
|
|
|
160
160
|
*/
|
|
161
161
|
function convDTValueToString(value, dts_id, tz) {
|
|
162
162
|
let { isSucceed, value: dtValue } = tryDTValue(value);
|
|
163
|
-
let dt_val = isSucceed ? dtValue.getTime() : new Date(0);
|
|
163
|
+
let dt_val = isSucceed && dtValue != null ? dtValue.getTime() : new Date(0);
|
|
164
164
|
let result = '';
|
|
165
165
|
let dtstype = valueToIndex(dts_id);
|
|
166
166
|
if (!chkDTSysID(dtstype)) dtstype = 0;
|
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An XEPG-element options set (base)
|
|
3
|
+
*/
|
|
4
|
+
export type OPT_epgelsett_bs = {
|
|
5
|
+
/**
|
|
6
|
+
* - parser options
|
|
7
|
+
*/
|
|
8
|
+
parseOptions?: InstanceType<typeof TXmlContentParseOptions>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* An XEPG-element options set (base)
|
|
12
|
+
*/
|
|
13
|
+
export type XEpgElementConfigBase = {
|
|
14
|
+
/**
|
|
15
|
+
* - parser options
|
|
16
|
+
*/
|
|
17
|
+
parseOptions: InstanceType<typeof TXmlContentParseOptions>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A schedule info descriptor
|
|
21
|
+
*/
|
|
22
|
+
export type xepgShedInfoDesc = {
|
|
23
|
+
/**
|
|
24
|
+
* - a schedule start time
|
|
25
|
+
*/
|
|
26
|
+
time: number;
|
|
27
|
+
/**
|
|
28
|
+
* - schedule title
|
|
29
|
+
*/
|
|
30
|
+
title: string;
|
|
31
|
+
/**
|
|
32
|
+
* - schedule category
|
|
33
|
+
*/
|
|
34
|
+
cat?: string;
|
|
35
|
+
/**
|
|
36
|
+
* - schedule rating
|
|
37
|
+
*/
|
|
38
|
+
pcmark?: number;
|
|
39
|
+
/**
|
|
40
|
+
* - schedule description
|
|
41
|
+
*/
|
|
42
|
+
descr?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* An extra options set
|
|
46
|
+
*/
|
|
47
|
+
export type OPT_extra = {
|
|
48
|
+
/**
|
|
49
|
+
* - 'DTS'-settings
|
|
50
|
+
*/
|
|
51
|
+
dts_src?: object;
|
|
52
|
+
/**
|
|
53
|
+
* - 'TZ'-settings
|
|
54
|
+
*/
|
|
55
|
+
tz_src?: object;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* An XEPG-element options set (extend)
|
|
59
|
+
*/
|
|
60
|
+
export type OPT_epgelsett_ex = {
|
|
61
|
+
/**
|
|
62
|
+
* - parser options
|
|
63
|
+
*/
|
|
64
|
+
parseOptions?: InstanceType<typeof TXmlContentParseOptions>;
|
|
65
|
+
dts_src?: object;
|
|
66
|
+
tz_src?: object;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A provider info descriptor
|
|
70
|
+
*/
|
|
71
|
+
export type xepgProvInfoDesc = {
|
|
72
|
+
/**
|
|
73
|
+
* - provider name
|
|
74
|
+
*/
|
|
75
|
+
name?: string;
|
|
76
|
+
/**
|
|
77
|
+
* - provider version
|
|
78
|
+
*/
|
|
79
|
+
version?: string;
|
|
80
|
+
/**
|
|
81
|
+
* - document schema
|
|
82
|
+
*/
|
|
83
|
+
schema: string;
|
|
84
|
+
/**
|
|
85
|
+
* - document type
|
|
86
|
+
*/
|
|
87
|
+
doctype: string;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* A channel info descriptor
|
|
91
|
+
*/
|
|
92
|
+
export type xepgChnInfoDesc = {
|
|
93
|
+
/**
|
|
94
|
+
* - channel ID
|
|
95
|
+
*/
|
|
96
|
+
chnid: string;
|
|
97
|
+
/**
|
|
98
|
+
* - channel name
|
|
99
|
+
*/
|
|
100
|
+
chname: string;
|
|
101
|
+
/**
|
|
102
|
+
* - channel 'Group ID'
|
|
103
|
+
*/
|
|
104
|
+
chngid?: string;
|
|
105
|
+
/**
|
|
106
|
+
* - EPG-source URL
|
|
107
|
+
*/
|
|
108
|
+
srcurl?: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* An options set for `TXEpgContentProvider`-class
|
|
113
|
+
*/
|
|
114
|
+
export type OPT_epgcpsett = {
|
|
115
|
+
/**
|
|
116
|
+
* - parser options
|
|
117
|
+
*/
|
|
118
|
+
parseOptions?: InstanceType<typeof TXmlContentParseOptions>;
|
|
119
|
+
/**
|
|
120
|
+
* - <*deprecated*>
|
|
121
|
+
*/
|
|
122
|
+
autoBindRoot?: boolean;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* An options set for `TXEpgContentProvider`-class
|
|
126
|
+
*/
|
|
127
|
+
export type XEpgContainerSettings = {
|
|
128
|
+
/**
|
|
129
|
+
* - parser options
|
|
130
|
+
*/
|
|
131
|
+
parseOptions: InstanceType<typeof TXmlContentParseOptions>;
|
|
132
|
+
/**
|
|
133
|
+
* - <*deprecated*>
|
|
134
|
+
*/
|
|
135
|
+
autoBindRoot?: boolean | undefined;
|
|
136
|
+
};
|
|
137
|
+
export const XEPG_DEF_PROVIDER_NAME: "xepg-lib-js";
|
|
138
|
+
export const XEPG_DEF_PROVIDER_VER: "0.0.21";
|
|
139
|
+
export const XEPG_DEF_DOCUMENT_TYPE: "xepg";
|
|
140
|
+
export const XEPG_DEF_DOCUMENT_SCHEMA: string;
|
|
141
|
+
/**
|
|
142
|
+
* @classdesc This class implements an interface of a DTS-provider element
|
|
143
|
+
*/
|
|
144
|
+
export class TXEpgDTSProvider {
|
|
145
|
+
/**
|
|
146
|
+
* Creates an instance of the DTS-provider element
|
|
147
|
+
*/
|
|
148
|
+
constructor(obj: object, opt?: OPT_epgelsett_bs);
|
|
149
|
+
/**
|
|
150
|
+
* Contains a dtstype ID
|
|
151
|
+
*/
|
|
152
|
+
get dtstype(): number;
|
|
153
|
+
set dtstype(value: number);
|
|
154
|
+
/**
|
|
155
|
+
* Contains a TZ-offset
|
|
156
|
+
*/
|
|
157
|
+
get curDocTZ(): number;
|
|
158
|
+
set curDocTZ(value: number);
|
|
159
|
+
/**
|
|
160
|
+
* Tries to set a `DTS`-type
|
|
161
|
+
* @since 0.0.22
|
|
162
|
+
*/
|
|
163
|
+
setType(value: any): boolean;
|
|
164
|
+
#private;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @since 0.0.22
|
|
169
|
+
* @classdesc This class implements an interface of a EPG-schedule element
|
|
170
|
+
*/
|
|
171
|
+
export class TXEpgScheduleItem {
|
|
172
|
+
/**
|
|
173
|
+
* Creates an instance of the EPG-schedule element
|
|
174
|
+
*/
|
|
175
|
+
constructor(obj: object, opt?: OPT_epgelsett_ex, extra?: OPT_extra);
|
|
176
|
+
/**
|
|
177
|
+
* Contains a dtstype ID
|
|
178
|
+
*/
|
|
179
|
+
get dtstype(): number;
|
|
180
|
+
/**
|
|
181
|
+
* Contains a TZ-offset
|
|
182
|
+
*/
|
|
183
|
+
get curDocTZ(): number;
|
|
184
|
+
/**
|
|
185
|
+
* Contains a schedule start time as a timestamp
|
|
186
|
+
*/
|
|
187
|
+
get time(): number;
|
|
188
|
+
/**
|
|
189
|
+
* Contains a schedule title
|
|
190
|
+
*/
|
|
191
|
+
get title(): string;
|
|
192
|
+
/**
|
|
193
|
+
* Contains a schedule category
|
|
194
|
+
*/
|
|
195
|
+
get category(): string;
|
|
196
|
+
/**
|
|
197
|
+
* Contains a schedule rating value (aka pcmark)
|
|
198
|
+
*/
|
|
199
|
+
get rating(): number;
|
|
200
|
+
/**
|
|
201
|
+
* Contains a schedule description
|
|
202
|
+
*/
|
|
203
|
+
get descr(): string;
|
|
204
|
+
/**
|
|
205
|
+
* Returns a schedule info item descriptor
|
|
206
|
+
*/
|
|
207
|
+
getInfo(): xepgShedInfoDesc;
|
|
208
|
+
/**
|
|
209
|
+
* Sets a schedule start time.
|
|
210
|
+
*/
|
|
211
|
+
setTime(value: number | string | Date): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Sets a schedule title.
|
|
214
|
+
*/
|
|
215
|
+
setTitle(value: string): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Sets a schedule title.
|
|
218
|
+
*/
|
|
219
|
+
setCategory(value: string): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Sets a schedule rating value.
|
|
222
|
+
*/
|
|
223
|
+
setRating(value: number | string): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Sets a schedule description.
|
|
226
|
+
*/
|
|
227
|
+
setDescr(value: string): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Returns an instance content as a string in an XML-format.
|
|
230
|
+
*/
|
|
231
|
+
saveToXMLString(): string;
|
|
232
|
+
/**
|
|
233
|
+
* Loads an element content from a string.
|
|
234
|
+
* @since v0.0.24
|
|
235
|
+
* @throws {Error}
|
|
236
|
+
* @experimental
|
|
237
|
+
*/
|
|
238
|
+
loadFromXMLString(xmlString: string): boolean;
|
|
239
|
+
#private;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @classdesc This class implements an interface of a EPG-schedules list
|
|
244
|
+
*/
|
|
245
|
+
export class TXEpgSchedulesList {
|
|
246
|
+
/**
|
|
247
|
+
* Creates an instance of the schedules list
|
|
248
|
+
*/
|
|
249
|
+
constructor(obj: any[], opt?: OPT_epgelsett_ex, extra?: OPT_extra);
|
|
250
|
+
/**
|
|
251
|
+
* Contains a quantity of a schedules
|
|
252
|
+
* @deprecated
|
|
253
|
+
* @todo \[since `v0.0.24`] deprecated. Use `TXEpgSchedulesList.count`
|
|
254
|
+
*/
|
|
255
|
+
get schedQty(): number;
|
|
256
|
+
/**
|
|
257
|
+
* Contains a quantity of a schedules
|
|
258
|
+
* @since v0.0.24
|
|
259
|
+
*/
|
|
260
|
+
get count(): number;
|
|
261
|
+
/**
|
|
262
|
+
* Contains a dtstype ID
|
|
263
|
+
*/
|
|
264
|
+
get dtstype(): number;
|
|
265
|
+
/**
|
|
266
|
+
* Contains a TZ-offset
|
|
267
|
+
*/
|
|
268
|
+
get curDocTZ(): number;
|
|
269
|
+
/**
|
|
270
|
+
* Indicates whether an instance has none member
|
|
271
|
+
* @deprecated
|
|
272
|
+
* @todo \[since `v0.0.24`] deprecated. Use `TXEpgSchedulesList.isEmpty`
|
|
273
|
+
*/
|
|
274
|
+
hasNoSchedules(): boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Indicates whether an instance has none member
|
|
277
|
+
* @since v0.0.24
|
|
278
|
+
*/
|
|
279
|
+
isEmpty(): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Indicates whether an instance has any member
|
|
282
|
+
* @deprecated
|
|
283
|
+
* @todo \[since `v0.0.24`] deprecated. Use `TXEpgSchedulesList.isNotEmpty`
|
|
284
|
+
*/
|
|
285
|
+
hasSchedules(): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Indicates whether an instance has any member
|
|
288
|
+
* @since v0.0.24
|
|
289
|
+
*/
|
|
290
|
+
isNotEmpty(): boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Checks whether a given value is a valid index and it fits the index range
|
|
293
|
+
* of an instance
|
|
294
|
+
* @since 0.0.20
|
|
295
|
+
*/
|
|
296
|
+
chkIndex(value: number | string): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Returns a schedule element addressed by a given index
|
|
299
|
+
* @since 0.0.22
|
|
300
|
+
*/
|
|
301
|
+
schedule(index: number | string): TXEpgScheduleItem | null;
|
|
302
|
+
/**
|
|
303
|
+
* Returns a schedule info item for instance element addressed
|
|
304
|
+
* by a given index
|
|
305
|
+
*/
|
|
306
|
+
getScheduleInfo(index: number | string): xepgShedInfoDesc | null;
|
|
307
|
+
/**
|
|
308
|
+
* Returns a schedule info for instance members
|
|
309
|
+
*/
|
|
310
|
+
getAllSchedulesInfo(): xepgShedInfoDesc[];
|
|
311
|
+
/**
|
|
312
|
+
* @protected
|
|
313
|
+
*/
|
|
314
|
+
protected asJSON(): string;
|
|
315
|
+
[Symbol.iterator](): {
|
|
316
|
+
next: () => {
|
|
317
|
+
done: boolean;
|
|
318
|
+
value: TXEpgScheduleItem | null;
|
|
319
|
+
} | {
|
|
320
|
+
done: boolean;
|
|
321
|
+
value: undefined;
|
|
322
|
+
};
|
|
323
|
+
return(): {
|
|
324
|
+
done: boolean;
|
|
325
|
+
value: undefined;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
#private;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* @classdesc This class implements an interface of a EPG-provider element
|
|
333
|
+
*/
|
|
334
|
+
export class TXEpgProviderContainer {
|
|
335
|
+
/**
|
|
336
|
+
* Creates an instance of the EPG-provider element
|
|
337
|
+
*/
|
|
338
|
+
constructor(obj: object, opt?: OPT_epgelsett_bs);
|
|
339
|
+
/**
|
|
340
|
+
* Contains a provider name
|
|
341
|
+
*/
|
|
342
|
+
get name(): string;
|
|
343
|
+
set name(value: string);
|
|
344
|
+
/**
|
|
345
|
+
* Contains a version of a provider
|
|
346
|
+
*/
|
|
347
|
+
get version(): string;
|
|
348
|
+
set version(value: string);
|
|
349
|
+
/**
|
|
350
|
+
* Contains a version of a document schema
|
|
351
|
+
*/
|
|
352
|
+
get schema(): string;
|
|
353
|
+
set schema(value: string);
|
|
354
|
+
/**
|
|
355
|
+
* Contains a document type
|
|
356
|
+
*/
|
|
357
|
+
get doctype(): string;
|
|
358
|
+
set doctype(value: string);
|
|
359
|
+
/**
|
|
360
|
+
* Sets a provider name
|
|
361
|
+
*/
|
|
362
|
+
setName(value: string): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Returns a provider info item
|
|
365
|
+
*/
|
|
366
|
+
getInfo(): xepgProvInfoDesc;
|
|
367
|
+
/**
|
|
368
|
+
* Sets a provider info
|
|
369
|
+
* @todo [since v0.0.21] deprecate use of `obj`-param as array
|
|
370
|
+
*/
|
|
371
|
+
setInfo(obj: string[] | xepgProvInfoDesc): void;
|
|
372
|
+
/**
|
|
373
|
+
* Sets an initial instance state
|
|
374
|
+
*/
|
|
375
|
+
init(opt?: xepgProvInfoDesc | string[]): void;
|
|
376
|
+
/**
|
|
377
|
+
* Returns an instance content as a string in an XML-format.
|
|
378
|
+
* @since v0.0.20
|
|
379
|
+
*/
|
|
380
|
+
saveToXMLString(): string;
|
|
381
|
+
/**
|
|
382
|
+
* Loads a element content from a string.
|
|
383
|
+
* @since v0.0.24
|
|
384
|
+
* @throws {Error}
|
|
385
|
+
* @experimental
|
|
386
|
+
*/
|
|
387
|
+
loadFromXMLString(xmlString: string): boolean;
|
|
388
|
+
#private;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* @since 0.0.22
|
|
393
|
+
* @classdesc This class implements an interface of a channel element
|
|
394
|
+
*/
|
|
395
|
+
export class TXEpgChannelContainer {
|
|
396
|
+
/**
|
|
397
|
+
* Creates an instance of the channel element
|
|
398
|
+
*/
|
|
399
|
+
constructor(obj: object, opt?: OPT_epgelsett_bs);
|
|
400
|
+
/**
|
|
401
|
+
* Contains a channel ID
|
|
402
|
+
*/
|
|
403
|
+
get id(): string;
|
|
404
|
+
/**
|
|
405
|
+
* Contains a channel name
|
|
406
|
+
*/
|
|
407
|
+
get name(): string;
|
|
408
|
+
set name(value: string);
|
|
409
|
+
/**
|
|
410
|
+
* Contains a channel Group ID
|
|
411
|
+
*/
|
|
412
|
+
get gid(): string;
|
|
413
|
+
set gid(value: string);
|
|
414
|
+
/**
|
|
415
|
+
* Contains a channel source URL
|
|
416
|
+
*/
|
|
417
|
+
get url(): string;
|
|
418
|
+
set url(value: string);
|
|
419
|
+
/**
|
|
420
|
+
* Tries to set a channel ID
|
|
421
|
+
*/
|
|
422
|
+
setID(value: string): boolean;
|
|
423
|
+
/**
|
|
424
|
+
* Returns a channel info
|
|
425
|
+
*/
|
|
426
|
+
getInfo(): xepgChnInfoDesc;
|
|
427
|
+
/**
|
|
428
|
+
* Sets a channel info
|
|
429
|
+
*/
|
|
430
|
+
setInfo(obj: string | xepgChnInfoDesc): void;
|
|
431
|
+
#private;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @classdesc This class implements an interface of a EPG-header element
|
|
436
|
+
*/
|
|
437
|
+
export class TXEpgHeaderContainer {
|
|
438
|
+
/**
|
|
439
|
+
* Creates an instance of the EPG-header element
|
|
440
|
+
*/
|
|
441
|
+
constructor(obj: object, opt?: OPT_epgelsett_bs);
|
|
442
|
+
/**
|
|
443
|
+
* Returns a `TXEpgDTSProvider` instance
|
|
444
|
+
*/
|
|
445
|
+
get dts(): TXEpgDTSProvider;
|
|
446
|
+
/**
|
|
447
|
+
* Contains a dtstype ID
|
|
448
|
+
* @todo [since v0.0.22] becomes readonly
|
|
449
|
+
*/
|
|
450
|
+
get dtstype(): number;
|
|
451
|
+
set dtstype(value: number);
|
|
452
|
+
/**
|
|
453
|
+
* Contains a TZ-offset
|
|
454
|
+
* @todo [since v0.0.22] becomes readonly
|
|
455
|
+
*/
|
|
456
|
+
get curDocTZ(): number;
|
|
457
|
+
set curDocTZ(value: number);
|
|
458
|
+
/**
|
|
459
|
+
* Returns a `TXEpgProviderContainer` instance
|
|
460
|
+
* @since 0.0.22
|
|
461
|
+
*/
|
|
462
|
+
get provider(): TXEpgProviderContainer | null;
|
|
463
|
+
/**
|
|
464
|
+
* Returns a `TXEpgChannelContainer` instance
|
|
465
|
+
* @since 0.0.22
|
|
466
|
+
*/
|
|
467
|
+
get channel(): TXEpgChannelContainer | null;
|
|
468
|
+
/**
|
|
469
|
+
* Returns a document creation date as a timestamp
|
|
470
|
+
*/
|
|
471
|
+
getDocumentDT(): number;
|
|
472
|
+
/**
|
|
473
|
+
* Sets a document creation date to a current system time
|
|
474
|
+
*/
|
|
475
|
+
setDocumentDT(): void;
|
|
476
|
+
/**
|
|
477
|
+
* Returns a document expire date as a timestamp
|
|
478
|
+
*/
|
|
479
|
+
getDocumentEDT(): number;
|
|
480
|
+
/**
|
|
481
|
+
* Sets a document expire date to a given time
|
|
482
|
+
*/
|
|
483
|
+
setDocumentEDT(value: any): void;
|
|
484
|
+
/**
|
|
485
|
+
* Returns a channel info
|
|
486
|
+
*/
|
|
487
|
+
getChannelInfo(): xepgChnInfoDesc;
|
|
488
|
+
/**
|
|
489
|
+
* Sets a channel info
|
|
490
|
+
* @deprecated
|
|
491
|
+
* @todo [since v0.0.22] deprecated. Use `TXEpgChannelContainer.setInfo`
|
|
492
|
+
*/
|
|
493
|
+
setChannelInfo(obj: xepgChnInfoDesc): void;
|
|
494
|
+
/**
|
|
495
|
+
* Returns a provider info
|
|
496
|
+
*/
|
|
497
|
+
getProviderInfo(): xepgProvInfoDesc | null;
|
|
498
|
+
/**
|
|
499
|
+
* Sets a provider info
|
|
500
|
+
* @deprecated
|
|
501
|
+
* @todo \[since `v0.0.24`] deprecated. Use `TXEpgProviderContainer.setInfo`
|
|
502
|
+
*/
|
|
503
|
+
setProviderInfo(obj: xepgProvInfoDesc): void;
|
|
504
|
+
/**
|
|
505
|
+
* Returns an instance content as a string in an XML-format.
|
|
506
|
+
* @since v0.0.20
|
|
507
|
+
*/
|
|
508
|
+
saveToXMLString(): string;
|
|
509
|
+
/**
|
|
510
|
+
* Loads an element content from a string.
|
|
511
|
+
* @since v0.0.24
|
|
512
|
+
* @throws {Error}
|
|
513
|
+
* @experimental
|
|
514
|
+
*/
|
|
515
|
+
loadFromXMLString(xmlString: string): boolean;
|
|
516
|
+
#private;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* @classdesc This class implements an interface of the container
|
|
521
|
+
* that manages a content of a XEPG-document
|
|
522
|
+
*/
|
|
523
|
+
export class TXEpgContentProvider {
|
|
524
|
+
/**
|
|
525
|
+
* Creates an instance of the XEPG-content provider
|
|
526
|
+
*/
|
|
527
|
+
constructor(opt?: OPT_epgcpsett);
|
|
528
|
+
/**
|
|
529
|
+
* Returns a `TXEpgHeaderContainer` instance
|
|
530
|
+
* @since 0.0.22
|
|
531
|
+
*/
|
|
532
|
+
get header(): TXEpgHeaderContainer | null;
|
|
533
|
+
/**
|
|
534
|
+
* Returns a `TXEpgProviderContainer` instance
|
|
535
|
+
* @since 0.0.22
|
|
536
|
+
*/
|
|
537
|
+
get provider(): TXEpgProviderContainer | null;
|
|
538
|
+
/**
|
|
539
|
+
* Returns a `TXEpgDTSProvider` instance
|
|
540
|
+
*/
|
|
541
|
+
get dts(): TXEpgDTSProvider | null;
|
|
542
|
+
/**
|
|
543
|
+
* @deprecated
|
|
544
|
+
*/
|
|
545
|
+
get Content(): this;
|
|
546
|
+
/**
|
|
547
|
+
* Returns a `TXEpgSchedulesList` instance
|
|
548
|
+
* @deprecated
|
|
549
|
+
* @todo \[since `v0.0.24`] deprecated. Use `TXEpgContentProvider.schedules`
|
|
550
|
+
*/
|
|
551
|
+
get SchedulesList(): TXEpgSchedulesList;
|
|
552
|
+
/**
|
|
553
|
+
* Returns a `TXEpgSchedulesList` instance
|
|
554
|
+
* @since 0.0.24
|
|
555
|
+
*/
|
|
556
|
+
get schedules(): TXEpgSchedulesList;
|
|
557
|
+
|
|
558
|
+
init(): void;
|
|
559
|
+
/**
|
|
560
|
+
* Returns a document content as a string in an XML-format.
|
|
561
|
+
*/
|
|
562
|
+
saveToXMLString(): string;
|
|
563
|
+
/**
|
|
564
|
+
* Saves a document content to a file.
|
|
565
|
+
* @throws {Error}
|
|
566
|
+
* @async
|
|
567
|
+
*/
|
|
568
|
+
saveToFile(source: string): Promise<fsoDescr>;
|
|
569
|
+
/**
|
|
570
|
+
* Saves a document content to a file.
|
|
571
|
+
*/
|
|
572
|
+
saveToFileSync(source: string): fsoDescr;
|
|
573
|
+
/**
|
|
574
|
+
* Loads a document content from a string.
|
|
575
|
+
* @since 0.0.18
|
|
576
|
+
* @throws {Error}
|
|
577
|
+
*/
|
|
578
|
+
loadFromXMLString(xmlString: string): boolean;
|
|
579
|
+
/**
|
|
580
|
+
* Loads a document content from a file.
|
|
581
|
+
* @throws {Error}
|
|
582
|
+
* @async
|
|
583
|
+
*/
|
|
584
|
+
loadFromFile(source: string): Promise<fsoDescr>;
|
|
585
|
+
/**
|
|
586
|
+
* Loads a document content from a file.
|
|
587
|
+
*/
|
|
588
|
+
loadFromFileSync(source: string): fsoDescr;
|
|
589
|
+
/**
|
|
590
|
+
* @protected
|
|
591
|
+
*/
|
|
592
|
+
protected asJSON(): string;
|
|
593
|
+
#private;
|
|
594
|
+
}
|
|
595
|
+
import { TXmlContentParseOptions } from "@ygracs/xobj-lib-js";
|
|
596
|
+
import { fsoDescr } from "@cntwg/file-helper";
|
package/lib/xepgdoc-lib.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// [v0.2.
|
|
1
|
+
// [v0.2.132-20260122]
|
|
2
2
|
|
|
3
3
|
// === module init block ===
|
|
4
4
|
|
|
@@ -24,17 +24,27 @@ const {
|
|
|
24
24
|
const {
|
|
25
25
|
loadFromFileSync, loadFromFile,
|
|
26
26
|
saveToFileSync, saveToFile,
|
|
27
|
+
// * import types definitions *
|
|
28
|
+
/** @see fsoDescr from `@cntwg/file-helper` */
|
|
29
|
+
fsoDescr,
|
|
27
30
|
} = require('@cntwg/file-helper');
|
|
28
31
|
|
|
29
32
|
const xObj = require('@ygracs/xobj-lib-js');
|
|
30
|
-
|
|
31
33
|
const {
|
|
32
|
-
TXmlContentParseOptions,
|
|
33
34
|
getXObjElement,
|
|
34
35
|
insertXObjElement,
|
|
35
36
|
writeXObjParam,
|
|
36
37
|
writeXObjAttr,
|
|
38
|
+
//TXmlContentParseOptions,
|
|
37
39
|
} = xObj;
|
|
40
|
+
// keep the next line for a type checking work properly :(
|
|
41
|
+
const { TXmlContentParseOptions } = require('@ygracs/xobj-lib-js/lib/xObj-defs');
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
readAsTagName,
|
|
45
|
+
readAsAttrName,
|
|
46
|
+
valueToElementID,
|
|
47
|
+
} = require('./xml-base');
|
|
38
48
|
|
|
39
49
|
// === module inner block ===
|
|
40
50
|
|
|
@@ -167,11 +177,17 @@ function deserializeXObjFromXMLString(node, opt, text, tagName) {
|
|
|
167
177
|
* @property {TXmlContentParseOptions} [parseOptions] - parser options
|
|
168
178
|
*/
|
|
169
179
|
|
|
180
|
+
/**
|
|
181
|
+
* An XEPG-element options set (base)
|
|
182
|
+
* @typedef {Object} XEpgElementConfigBase
|
|
183
|
+
* @property {TXmlContentParseOptions} parseOptions - parser options
|
|
184
|
+
*/
|
|
185
|
+
|
|
170
186
|
/**
|
|
171
187
|
* Evaluates an XML-node base settings
|
|
172
188
|
* @function __evalXMLBaseNodeSettings
|
|
173
189
|
* @param {any} value - element settings to evaluate
|
|
174
|
-
* @returns {
|
|
190
|
+
* @returns {XEpgElementConfigBase}
|
|
175
191
|
* @inner
|
|
176
192
|
*/
|
|
177
193
|
function __evalXMLBaseNodeSettings(value) {
|
|
@@ -184,6 +200,7 @@ function __evalXMLBaseNodeSettings(value) {
|
|
|
184
200
|
if (!(parseOptions instanceof TXmlContentParseOptions)) {
|
|
185
201
|
settings.parseOptions = new TXmlContentParseOptions(parseOptions);
|
|
186
202
|
};
|
|
203
|
+
// @ts-expect-error
|
|
187
204
|
return settings;
|
|
188
205
|
};
|
|
189
206
|
|
|
@@ -252,73 +269,6 @@ const defParseOptions = new TXmlContentParseOptions();
|
|
|
252
269
|
* (* function definitions *)
|
|
253
270
|
*/
|
|
254
271
|
|
|
255
|
-
/**
|
|
256
|
-
* Tries to convert a given value to a valid tag name of an XML-element.
|
|
257
|
-
* @since v0.0.23
|
|
258
|
-
* @function readAsTagName
|
|
259
|
-
* @param {any} value - some value
|
|
260
|
-
* @returns {string}
|
|
261
|
-
*/
|
|
262
|
-
function readAsTagName(value) {
|
|
263
|
-
let tagName = valueToIDString(value, { ignoreNumbers: true });
|
|
264
|
-
if (tagName === null) return '';
|
|
265
|
-
if (tagName !== '') {
|
|
266
|
-
// // TODO: do extra checks
|
|
267
|
-
const template = /[\s\/\\\"\'<>=]/;
|
|
268
|
-
const trigger = tagName.match(template);
|
|
269
|
-
if (trigger) {
|
|
270
|
-
//console.log(trigger);
|
|
271
|
-
tagName = '';
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
|
-
return tagName;
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Tries to convert a given value to a valid name of an XML-attribute.
|
|
279
|
-
* @since v0.0.23
|
|
280
|
-
* @function readAsAttrName
|
|
281
|
-
* @param {any} value - some value
|
|
282
|
-
* @returns {string}
|
|
283
|
-
*/
|
|
284
|
-
function readAsAttrName(value) {
|
|
285
|
-
let attrName = valueToIDString(value, { ignoreNumbers: true });
|
|
286
|
-
if (attrName === null) return '';
|
|
287
|
-
if (attrName !== '') {
|
|
288
|
-
// // TODO: do extra checks
|
|
289
|
-
const template = /[\s\/\\\"\'<>=]/;
|
|
290
|
-
const trigger = attrName.match(template);
|
|
291
|
-
if (trigger) {
|
|
292
|
-
//console.log(trigger);
|
|
293
|
-
attrName = '';
|
|
294
|
-
};
|
|
295
|
-
};
|
|
296
|
-
return attrName;
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Tries to convert a given value to a valid identifier suitable as a value
|
|
301
|
-
* for an "ID-attribute" of an XML-element.
|
|
302
|
-
* @since v0.0.23
|
|
303
|
-
* @function valueToElementID
|
|
304
|
-
* @param {any} value - some value
|
|
305
|
-
* @returns {string}
|
|
306
|
-
*/
|
|
307
|
-
function valueToElementID(value) {
|
|
308
|
-
let id = valueToIDString(value);
|
|
309
|
-
if (id === null) return '';
|
|
310
|
-
if (id !== '') {
|
|
311
|
-
// // TODO: do extra checks
|
|
312
|
-
const template = /[\s\/\\\"\'<>=]/;
|
|
313
|
-
const trigger = id.match(template);
|
|
314
|
-
if (trigger) {
|
|
315
|
-
//console.log(trigger);
|
|
316
|
-
id = '';
|
|
317
|
-
};
|
|
318
|
-
};
|
|
319
|
-
return id;
|
|
320
|
-
};
|
|
321
|
-
|
|
322
272
|
/***
|
|
323
273
|
* (* class definitions *)
|
|
324
274
|
*/
|
|
@@ -501,13 +451,13 @@ class TXEpgScheduleItem {
|
|
|
501
451
|
setTime(value) {
|
|
502
452
|
let { isSucceed, value: dtValue } = tryDTValue(value);
|
|
503
453
|
let result = false;
|
|
504
|
-
if (isSucceed) {
|
|
505
|
-
|
|
506
|
-
if (
|
|
454
|
+
if (isSucceed && dtValue != null) {
|
|
455
|
+
const text = convDTValueToString(dtValue, this.dtstype, this.curDocTZ);
|
|
456
|
+
if (text !== '') {
|
|
507
457
|
const opt = { force: true };
|
|
508
458
|
const item = insertXObjElement(this.#_host, XEPG_SCHEDTIME_ETAG_NAME, opt);
|
|
509
459
|
if (item) {
|
|
510
|
-
result = writeXObjParam(item,
|
|
460
|
+
result = writeXObjParam(item, text, defParseOptions.settings.textKey);
|
|
511
461
|
};
|
|
512
462
|
};
|
|
513
463
|
};
|
|
@@ -678,7 +628,6 @@ class TXEpgSchedulesList {
|
|
|
678
628
|
* Returns a raw schedule element
|
|
679
629
|
* @param {(number|string)} value - element index
|
|
680
630
|
* @returns {any}
|
|
681
|
-
* @private
|
|
682
631
|
*/
|
|
683
632
|
#_getItem = function(value) {
|
|
684
633
|
if (this.chkIndex(value)) {
|
|
@@ -1020,7 +969,7 @@ class TXEpgProviderContainer {
|
|
|
1020
969
|
|
|
1021
970
|
/**
|
|
1022
971
|
* Sets an initial instance state
|
|
1023
|
-
* @param {(xepgProvInfoDesc|string[])} opt - options
|
|
972
|
+
* @param {(xepgProvInfoDesc|string[])} [opt] - options
|
|
1024
973
|
* @returns {void}
|
|
1025
974
|
*/
|
|
1026
975
|
init(opt) {
|
|
@@ -1325,7 +1274,6 @@ class TXEpgDTSProvider {
|
|
|
1325
1274
|
|
|
1326
1275
|
/**
|
|
1327
1276
|
* @returns {void}
|
|
1328
|
-
* @private
|
|
1329
1277
|
*/
|
|
1330
1278
|
#_init() {
|
|
1331
1279
|
insertXObjElement(this.#_content, XEPG_DTSINFO_ETAG_NAME);
|
|
@@ -1343,7 +1291,7 @@ class TXEpgDTSProvider {
|
|
|
1343
1291
|
}
|
|
1344
1292
|
|
|
1345
1293
|
set dtstype(value) {
|
|
1346
|
-
|
|
1294
|
+
this.setType(value);
|
|
1347
1295
|
}
|
|
1348
1296
|
|
|
1349
1297
|
/**
|
|
@@ -1475,7 +1423,6 @@ class TXEpgHeaderContainer {
|
|
|
1475
1423
|
|
|
1476
1424
|
/**
|
|
1477
1425
|
* @returns {?object}
|
|
1478
|
-
* @private
|
|
1479
1426
|
*/
|
|
1480
1427
|
#_getProv() {
|
|
1481
1428
|
const docProv = getXObjElement(this.#_host, XEPG_PRVINFO_ETAG_NAME);
|
|
@@ -1484,7 +1431,6 @@ class TXEpgHeaderContainer {
|
|
|
1484
1431
|
|
|
1485
1432
|
/**
|
|
1486
1433
|
* @returns {?object}
|
|
1487
|
-
* @private
|
|
1488
1434
|
*/
|
|
1489
1435
|
#_initProv() {
|
|
1490
1436
|
const _host = this.#_host;
|
|
@@ -1495,17 +1441,6 @@ class TXEpgHeaderContainer {
|
|
|
1495
1441
|
return isPlainObject(docProv) ? docProv : null;
|
|
1496
1442
|
}
|
|
1497
1443
|
|
|
1498
|
-
/**
|
|
1499
|
-
* Returns a `TXEpgProviderContainer` instance
|
|
1500
|
-
* @type {?TXEpgProviderContainer}
|
|
1501
|
-
* @readonly
|
|
1502
|
-
* @deprecated
|
|
1503
|
-
* @todo \[since `v0.0.22`] deprecated. Use `TXEpgHeaderContainer.provider`
|
|
1504
|
-
*/
|
|
1505
|
-
get Provider() {
|
|
1506
|
-
return this.provider;
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
1444
|
/**
|
|
1510
1445
|
* Returns a `TXEpgProviderContainer` instance
|
|
1511
1446
|
* @since 0.0.22
|
|
@@ -1683,20 +1618,16 @@ class TXEpgHeaderContainer {
|
|
|
1683
1618
|
};
|
|
1684
1619
|
|
|
1685
1620
|
/**
|
|
1686
|
-
*
|
|
1687
|
-
* @typedef {Object}
|
|
1688
|
-
* @property {
|
|
1689
|
-
* @property {
|
|
1690
|
-
* @property {string} errEvent - event ID
|
|
1691
|
-
* @property {string} [errMsg] - event message
|
|
1692
|
-
* @property {string} [source] - path to file
|
|
1693
|
-
* @property {any} [content] - file content
|
|
1621
|
+
* An options set for `TXEpgContentProvider`-class
|
|
1622
|
+
* @typedef {Object} OPT_epgcpsett
|
|
1623
|
+
* @property {TXmlContentParseOptions} [parseOptions] - parser options
|
|
1624
|
+
* @property {boolean} [autoBindRoot] - <*deprecated*>
|
|
1694
1625
|
*/
|
|
1695
1626
|
|
|
1696
1627
|
/**
|
|
1697
1628
|
* An options set for `TXEpgContentProvider`-class
|
|
1698
|
-
* @typedef {Object}
|
|
1699
|
-
* @property {TXmlContentParseOptions}
|
|
1629
|
+
* @typedef {Object} XEpgContainerSettings
|
|
1630
|
+
* @property {TXmlContentParseOptions} parseOptions - parser options
|
|
1700
1631
|
* @property {boolean} [autoBindRoot] - <*deprecated*>
|
|
1701
1632
|
*/
|
|
1702
1633
|
|
|
@@ -1707,7 +1638,7 @@ class TXEpgHeaderContainer {
|
|
|
1707
1638
|
class TXEpgContentProvider {
|
|
1708
1639
|
/** @type {Object} */
|
|
1709
1640
|
#_content;
|
|
1710
|
-
/** @type {
|
|
1641
|
+
/** @type {XEpgContainerSettings} */
|
|
1711
1642
|
#_options;
|
|
1712
1643
|
/** @type {TXmlContentParseOptions} */
|
|
1713
1644
|
#_parseOptions;
|
|
@@ -1719,7 +1650,7 @@ class TXEpgContentProvider {
|
|
|
1719
1650
|
constructor(opt) {
|
|
1720
1651
|
// load options
|
|
1721
1652
|
const _options = __evalXMLBaseNodeSettings(opt);
|
|
1722
|
-
/** @type {
|
|
1653
|
+
/** @type {XEpgContainerSettings} */
|
|
1723
1654
|
let {
|
|
1724
1655
|
parseOptions,
|
|
1725
1656
|
autoBindRoot, // <*reserved*> ([?] - deprecate)
|
|
@@ -1737,7 +1668,6 @@ class TXEpgContentProvider {
|
|
|
1737
1668
|
|
|
1738
1669
|
/**
|
|
1739
1670
|
* @returns {?Object}
|
|
1740
|
-
* @private
|
|
1741
1671
|
*/
|
|
1742
1672
|
#_getRoot() {
|
|
1743
1673
|
const docRoot = getXObjElement(this.#_content, XEPG_ROOT_ETAG_NAME);
|
|
@@ -1746,7 +1676,6 @@ class TXEpgContentProvider {
|
|
|
1746
1676
|
|
|
1747
1677
|
/**
|
|
1748
1678
|
* @returns {?object}
|
|
1749
|
-
* @private
|
|
1750
1679
|
*/
|
|
1751
1680
|
#_initRoot() {
|
|
1752
1681
|
const _content = this.#_content;
|
|
@@ -1767,7 +1696,6 @@ class TXEpgContentProvider {
|
|
|
1767
1696
|
|
|
1768
1697
|
/**
|
|
1769
1698
|
* @returns {?Object}
|
|
1770
|
-
* @private
|
|
1771
1699
|
*/
|
|
1772
1700
|
#_getHdr() {
|
|
1773
1701
|
const docRoot = this.#_getRoot();
|
|
@@ -1780,7 +1708,6 @@ class TXEpgContentProvider {
|
|
|
1780
1708
|
|
|
1781
1709
|
/**
|
|
1782
1710
|
* @returns {?object}
|
|
1783
|
-
* @private
|
|
1784
1711
|
*/
|
|
1785
1712
|
#_initHdr() {
|
|
1786
1713
|
let docHdr = this.#_getHdr();
|
|
@@ -1796,7 +1723,6 @@ class TXEpgContentProvider {
|
|
|
1796
1723
|
|
|
1797
1724
|
/**
|
|
1798
1725
|
* @returns {?Object}
|
|
1799
|
-
* @private
|
|
1800
1726
|
*/
|
|
1801
1727
|
#_getBody() {
|
|
1802
1728
|
const docRoot = this.#_getRoot();
|
|
@@ -1809,7 +1735,6 @@ class TXEpgContentProvider {
|
|
|
1809
1735
|
|
|
1810
1736
|
/**
|
|
1811
1737
|
* @returns {?object}
|
|
1812
|
-
* @private
|
|
1813
1738
|
*/
|
|
1814
1739
|
#_initBody() {
|
|
1815
1740
|
let docBody = this.#_getBody();
|
|
@@ -1823,17 +1748,6 @@ class TXEpgContentProvider {
|
|
|
1823
1748
|
return isPlainObject(docBody) ? docBody : null;
|
|
1824
1749
|
}
|
|
1825
1750
|
|
|
1826
|
-
/**
|
|
1827
|
-
* Returns a `TXEpgHeaderContainer` instance
|
|
1828
|
-
* @type {?TXEpgHeaderContainer}
|
|
1829
|
-
* @readonly
|
|
1830
|
-
* @deprecated
|
|
1831
|
-
* @todo \[since `v0.0.22`] deprecated. Use `TXEpgContentProvider.header`
|
|
1832
|
-
*/
|
|
1833
|
-
get Header() {
|
|
1834
|
-
return this.header;
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
1751
|
/**
|
|
1838
1752
|
* Returns a `TXEpgHeaderContainer` instance
|
|
1839
1753
|
* @since 0.0.22
|
|
@@ -1849,17 +1763,6 @@ class TXEpgContentProvider {
|
|
|
1849
1763
|
);
|
|
1850
1764
|
}
|
|
1851
1765
|
|
|
1852
|
-
/**
|
|
1853
|
-
* Returns a `TXEpgProviderContainer` instance
|
|
1854
|
-
* @type {?TXEpgProviderContainer}
|
|
1855
|
-
* @readonly
|
|
1856
|
-
* @deprecated
|
|
1857
|
-
* @todo \[since `v0.0.22`] deprecated. Use `TXEpgContentProvider.provider`
|
|
1858
|
-
*/
|
|
1859
|
-
get Provider() {
|
|
1860
|
-
return this.provider;
|
|
1861
|
-
}
|
|
1862
|
-
|
|
1863
1766
|
/**
|
|
1864
1767
|
* Returns a `TXEpgProviderContainer` instance
|
|
1865
1768
|
* @since 0.0.22
|
|
@@ -2156,10 +2059,6 @@ module.exports.XEPG_DEF_PROVIDER_VER = XEPG_DEF_PROVIDER_VER;
|
|
|
2156
2059
|
module.exports.XEPG_DEF_DOCUMENT_TYPE = XEPG_DEF_DOCUMENT_TYPE;
|
|
2157
2060
|
module.exports.XEPG_DEF_DOCUMENT_SCHEMA = XEPG_DEF_DOCUMENT_SCHEMA;
|
|
2158
2061
|
|
|
2159
|
-
module.exports.readAsTagName = readAsTagName;
|
|
2160
|
-
module.exports.readAsAttrName = readAsAttrName;
|
|
2161
|
-
module.exports.valueToElementID = valueToElementID;
|
|
2162
|
-
|
|
2163
2062
|
module.exports.TXEpgDTSProvider = TXEpgDTSProvider;
|
|
2164
2063
|
module.exports.TXEpgScheduleItem = TXEpgScheduleItem;
|
|
2165
2064
|
module.exports.TXEpgSchedulesList = TXEpgSchedulesList;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tries to convert a given value to a valid tag name of an XML-element.
|
|
3
|
+
* @since v0.0.23
|
|
4
|
+
*/
|
|
5
|
+
export function readAsTagName(value: any): string;
|
|
6
|
+
/**
|
|
7
|
+
* Tries to convert a given value to a valid name of an XML-attribute.
|
|
8
|
+
* @since v0.0.23
|
|
9
|
+
*/
|
|
10
|
+
export function readAsAttrName(value: any): string;
|
|
11
|
+
/**
|
|
12
|
+
* Tries to convert a given value to a valid "attribute value".
|
|
13
|
+
* @since v0.0.25
|
|
14
|
+
*/
|
|
15
|
+
export function readAsAttrValue(value: any): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Tries to convert a given value to a valid identifier suitable as a value
|
|
18
|
+
* for an "ID-attribute" of an XML-element.
|
|
19
|
+
* @since v0.0.23
|
|
20
|
+
*/
|
|
21
|
+
export function valueToElementID(value: any): string;
|
package/lib/xml-base.js
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// [v0.1.002-20250825]
|
|
2
|
+
|
|
3
|
+
// === module init block ===
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
//valueToIndex,
|
|
7
|
+
valueToIDString,
|
|
8
|
+
//readAsString, readAsNumber,
|
|
9
|
+
//isNotEmptyString,
|
|
10
|
+
//isArray, isObject, isPlainObject,
|
|
11
|
+
} = require('@ygracs/bsfoc-lib-js');
|
|
12
|
+
|
|
13
|
+
// === module inner block ===
|
|
14
|
+
|
|
15
|
+
/***
|
|
16
|
+
* (* helper function definitions *)
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// === module main block ===
|
|
20
|
+
|
|
21
|
+
/***
|
|
22
|
+
* (* constant definitions *)
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/***
|
|
26
|
+
* (* function definitions *)
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Tries to convert a given value to a valid tag name of an XML-element.
|
|
31
|
+
* @since v0.0.23
|
|
32
|
+
* @function readAsTagName
|
|
33
|
+
* @param {any} value - some value
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
function readAsTagName(value) {
|
|
37
|
+
let tagName = valueToIDString(value, { ignoreNumbers: true });
|
|
38
|
+
if (tagName === null) return '';
|
|
39
|
+
if (tagName !== '') {
|
|
40
|
+
// // TODO: do extra checks
|
|
41
|
+
const template = /[\s\/\\\"\'<>=]/;
|
|
42
|
+
const trigger = tagName.match(template);
|
|
43
|
+
if (trigger) {
|
|
44
|
+
//console.log(trigger);
|
|
45
|
+
tagName = '';
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
return tagName;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Tries to convert a given value to a valid name of an XML-attribute.
|
|
53
|
+
* @since v0.0.23
|
|
54
|
+
* @function readAsAttrName
|
|
55
|
+
* @param {any} value - some value
|
|
56
|
+
* @returns {string}
|
|
57
|
+
*/
|
|
58
|
+
function readAsAttrName(value) {
|
|
59
|
+
let attrName = valueToIDString(value, { ignoreNumbers: true });
|
|
60
|
+
if (attrName === null) return '';
|
|
61
|
+
if (attrName !== '') {
|
|
62
|
+
// // TODO: do extra checks
|
|
63
|
+
const template = /[\s\/\\\"\'<>=]/;
|
|
64
|
+
const trigger = attrName.match(template);
|
|
65
|
+
if (trigger) {
|
|
66
|
+
//console.log(trigger);
|
|
67
|
+
attrName = '';
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
return attrName;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Tries to convert a given value to a valid "attribute value".
|
|
75
|
+
* @since v0.0.25
|
|
76
|
+
* @function readAsAttrValue
|
|
77
|
+
* @param {any} value - some value
|
|
78
|
+
* @return {?string}
|
|
79
|
+
*/
|
|
80
|
+
function readAsAttrValue(value) {
|
|
81
|
+
let result = null;
|
|
82
|
+
switch (typeof value) {
|
|
83
|
+
case 'boolean': {
|
|
84
|
+
result = value.toString();
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'number': {
|
|
88
|
+
if (Number.isNaN(value)) break;
|
|
89
|
+
result = value.toString();
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case 'string': {
|
|
93
|
+
result = value.trim();
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default: {}
|
|
97
|
+
};
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Tries to convert a given value to a valid identifier suitable as a value
|
|
103
|
+
* for an "ID-attribute" of an XML-element.
|
|
104
|
+
* @since v0.0.23
|
|
105
|
+
* @function valueToElementID
|
|
106
|
+
* @param {any} value - some value
|
|
107
|
+
* @returns {string}
|
|
108
|
+
*/
|
|
109
|
+
function valueToElementID(value) {
|
|
110
|
+
let id = valueToIDString(value);
|
|
111
|
+
if (id === null) return '';
|
|
112
|
+
if (id !== '') {
|
|
113
|
+
// // TODO: do extra checks
|
|
114
|
+
const template = /[\s\/\\\"\'<>=]/;
|
|
115
|
+
const trigger = id.match(template);
|
|
116
|
+
if (trigger) {
|
|
117
|
+
//console.log(trigger);
|
|
118
|
+
id = '';
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
return id;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/***
|
|
125
|
+
* (* class definitions *)
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
// === module exports block ===
|
|
129
|
+
|
|
130
|
+
module.exports.readAsTagName = readAsTagName;
|
|
131
|
+
module.exports.readAsAttrName = readAsAttrName;
|
|
132
|
+
module.exports.readAsAttrValue = readAsAttrValue;
|
|
133
|
+
module.exports.valueToElementID = valueToElementID;
|
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.26-b",
|
|
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",
|
|
@@ -13,35 +13,42 @@
|
|
|
13
13
|
"EPG"
|
|
14
14
|
],
|
|
15
15
|
"main": "./index.js",
|
|
16
|
+
"types": "./index.d.ts",
|
|
16
17
|
"files": [
|
|
17
18
|
"doc/xepgdoc-spec-draft.dtd",
|
|
18
19
|
"doc/*.xepg",
|
|
19
20
|
"doc/*.md",
|
|
20
21
|
"lib/xepgdoc-lib.js",
|
|
21
22
|
"lib/dts-helper.js",
|
|
23
|
+
"lib/xml-base.js",
|
|
24
|
+
"lib/*.d.ts",
|
|
22
25
|
"index.js",
|
|
26
|
+
"index.d.ts",
|
|
23
27
|
"CHANGELOG.md"
|
|
24
28
|
],
|
|
25
29
|
"scripts": {
|
|
26
30
|
"test": "cross-env TZ='Etc/UTC' jest",
|
|
27
31
|
"build-doc-md": "jsdoc2md",
|
|
28
|
-
"build-doc-html": "jsdoc"
|
|
32
|
+
"build-doc-html": "jsdoc",
|
|
33
|
+
"gen-dts": "npx -p typescript tsc"
|
|
29
34
|
},
|
|
30
35
|
"imports": {
|
|
31
36
|
"#lib/*": "./lib/*",
|
|
32
37
|
"#test-dir/*": "./__test__/*"
|
|
33
38
|
},
|
|
34
39
|
"dependencies": {
|
|
35
|
-
"@cntwg/file-helper": "^0.0.
|
|
36
|
-
"@ygracs/bsfoc-lib-js": "
|
|
37
|
-
"@ygracs/dtf-lib-js": "^0.0.
|
|
38
|
-
"@ygracs/xml-js6": "^0.0.
|
|
39
|
-
"@ygracs/xobj-lib-js": "^0.2.
|
|
40
|
+
"@cntwg/file-helper": "^0.0.3",
|
|
41
|
+
"@ygracs/bsfoc-lib-js": "~0.3.3",
|
|
42
|
+
"@ygracs/dtf-lib-js": "^0.0.33",
|
|
43
|
+
"@ygracs/xml-js6": "^0.0.6-b",
|
|
44
|
+
"@ygracs/xobj-lib-js": "^0.2.8-b"
|
|
40
45
|
},
|
|
41
46
|
"devDependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
47
|
+
"@ygracs/test-helper": "~0.0.1-b",
|
|
48
|
+
"cross-env": "^10.1.0",
|
|
49
|
+
"jest": "^30.2.0",
|
|
50
|
+
"jsdoc-to-markdown": "^9.1.3",
|
|
51
|
+
"minimist": "^1.2.8",
|
|
52
|
+
"typescript": "~5.9.3"
|
|
46
53
|
}
|
|
47
54
|
}
|