@ygracs/xepg-lib-js 0.0.25 → 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 CHANGED
@@ -1,3 +1,11 @@
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
+
1
9
  #### *v0.0.25*
2
10
 
3
11
  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
 
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
+ };
@@ -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.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";
@@ -1,4 +1,4 @@
1
- // [v0.2.128-20250825]
1
+ // [v0.2.132-20260122]
2
2
 
3
3
  // === module init block ===
4
4
 
@@ -24,17 +24,21 @@ 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');
38
42
 
39
43
  const {
40
44
  readAsTagName,
@@ -173,11 +177,17 @@ function deserializeXObjFromXMLString(node, opt, text, tagName) {
173
177
  * @property {TXmlContentParseOptions} [parseOptions] - parser options
174
178
  */
175
179
 
180
+ /**
181
+ * An XEPG-element options set (base)
182
+ * @typedef {Object} XEpgElementConfigBase
183
+ * @property {TXmlContentParseOptions} parseOptions - parser options
184
+ */
185
+
176
186
  /**
177
187
  * Evaluates an XML-node base settings
178
188
  * @function __evalXMLBaseNodeSettings
179
189
  * @param {any} value - element settings to evaluate
180
- * @returns {OPT_epgelsett_bs}
190
+ * @returns {XEpgElementConfigBase}
181
191
  * @inner
182
192
  */
183
193
  function __evalXMLBaseNodeSettings(value) {
@@ -190,6 +200,7 @@ function __evalXMLBaseNodeSettings(value) {
190
200
  if (!(parseOptions instanceof TXmlContentParseOptions)) {
191
201
  settings.parseOptions = new TXmlContentParseOptions(parseOptions);
192
202
  };
203
+ // @ts-expect-error
193
204
  return settings;
194
205
  };
195
206
 
@@ -440,13 +451,13 @@ class TXEpgScheduleItem {
440
451
  setTime(value) {
441
452
  let { isSucceed, value: dtValue } = tryDTValue(value);
442
453
  let result = false;
443
- if (isSucceed) {
444
- dtValue = convDTValueToString(dtValue, this.dtstype, this.curDocTZ);
445
- if (dtValue !== '') {
454
+ if (isSucceed && dtValue != null) {
455
+ const text = convDTValueToString(dtValue, this.dtstype, this.curDocTZ);
456
+ if (text !== '') {
446
457
  const opt = { force: true };
447
458
  const item = insertXObjElement(this.#_host, XEPG_SCHEDTIME_ETAG_NAME, opt);
448
459
  if (item) {
449
- result = writeXObjParam(item, dtValue, defParseOptions.settings.textKey);
460
+ result = writeXObjParam(item, text, defParseOptions.settings.textKey);
450
461
  };
451
462
  };
452
463
  };
@@ -617,7 +628,6 @@ class TXEpgSchedulesList {
617
628
  * Returns a raw schedule element
618
629
  * @param {(number|string)} value - element index
619
630
  * @returns {any}
620
- * @private
621
631
  */
622
632
  #_getItem = function(value) {
623
633
  if (this.chkIndex(value)) {
@@ -959,7 +969,7 @@ class TXEpgProviderContainer {
959
969
 
960
970
  /**
961
971
  * Sets an initial instance state
962
- * @param {(xepgProvInfoDesc|string[])} opt - options
972
+ * @param {(xepgProvInfoDesc|string[])} [opt] - options
963
973
  * @returns {void}
964
974
  */
965
975
  init(opt) {
@@ -1264,7 +1274,6 @@ class TXEpgDTSProvider {
1264
1274
 
1265
1275
  /**
1266
1276
  * @returns {void}
1267
- * @private
1268
1277
  */
1269
1278
  #_init() {
1270
1279
  insertXObjElement(this.#_content, XEPG_DTSINFO_ETAG_NAME);
@@ -1282,7 +1291,7 @@ class TXEpgDTSProvider {
1282
1291
  }
1283
1292
 
1284
1293
  set dtstype(value) {
1285
- return this.setType(value);
1294
+ this.setType(value);
1286
1295
  }
1287
1296
 
1288
1297
  /**
@@ -1414,7 +1423,6 @@ class TXEpgHeaderContainer {
1414
1423
 
1415
1424
  /**
1416
1425
  * @returns {?object}
1417
- * @private
1418
1426
  */
1419
1427
  #_getProv() {
1420
1428
  const docProv = getXObjElement(this.#_host, XEPG_PRVINFO_ETAG_NAME);
@@ -1423,7 +1431,6 @@ class TXEpgHeaderContainer {
1423
1431
 
1424
1432
  /**
1425
1433
  * @returns {?object}
1426
- * @private
1427
1434
  */
1428
1435
  #_initProv() {
1429
1436
  const _host = this.#_host;
@@ -1611,20 +1618,16 @@ class TXEpgHeaderContainer {
1611
1618
  };
1612
1619
 
1613
1620
  /**
1614
- * A fs ops description.
1615
- * @typedef {Object} fsoDescr
1616
- * @property {boolean} isERR - flag
1617
- * @property {number} [errCode] - error code
1618
- * @property {string} errEvent - event ID
1619
- * @property {string} [errMsg] - event message
1620
- * @property {string} [source] - path to file
1621
- * @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*>
1622
1625
  */
1623
1626
 
1624
1627
  /**
1625
1628
  * An options set for `TXEpgContentProvider`-class
1626
- * @typedef {Object} OPT_epgcpsett
1627
- * @property {TXmlContentParseOptions} [parseOptions] - parser options
1629
+ * @typedef {Object} XEpgContainerSettings
1630
+ * @property {TXmlContentParseOptions} parseOptions - parser options
1628
1631
  * @property {boolean} [autoBindRoot] - <*deprecated*>
1629
1632
  */
1630
1633
 
@@ -1635,7 +1638,7 @@ class TXEpgHeaderContainer {
1635
1638
  class TXEpgContentProvider {
1636
1639
  /** @type {Object} */
1637
1640
  #_content;
1638
- /** @type {OPT_epgcpsett} */
1641
+ /** @type {XEpgContainerSettings} */
1639
1642
  #_options;
1640
1643
  /** @type {TXmlContentParseOptions} */
1641
1644
  #_parseOptions;
@@ -1647,7 +1650,7 @@ class TXEpgContentProvider {
1647
1650
  constructor(opt) {
1648
1651
  // load options
1649
1652
  const _options = __evalXMLBaseNodeSettings(opt);
1650
- /** @type {OPT_epgcpsett} */
1653
+ /** @type {XEpgContainerSettings} */
1651
1654
  let {
1652
1655
  parseOptions,
1653
1656
  autoBindRoot, // <*reserved*> ([?] - deprecate)
@@ -1665,7 +1668,6 @@ class TXEpgContentProvider {
1665
1668
 
1666
1669
  /**
1667
1670
  * @returns {?Object}
1668
- * @private
1669
1671
  */
1670
1672
  #_getRoot() {
1671
1673
  const docRoot = getXObjElement(this.#_content, XEPG_ROOT_ETAG_NAME);
@@ -1674,7 +1676,6 @@ class TXEpgContentProvider {
1674
1676
 
1675
1677
  /**
1676
1678
  * @returns {?object}
1677
- * @private
1678
1679
  */
1679
1680
  #_initRoot() {
1680
1681
  const _content = this.#_content;
@@ -1695,7 +1696,6 @@ class TXEpgContentProvider {
1695
1696
 
1696
1697
  /**
1697
1698
  * @returns {?Object}
1698
- * @private
1699
1699
  */
1700
1700
  #_getHdr() {
1701
1701
  const docRoot = this.#_getRoot();
@@ -1708,7 +1708,6 @@ class TXEpgContentProvider {
1708
1708
 
1709
1709
  /**
1710
1710
  * @returns {?object}
1711
- * @private
1712
1711
  */
1713
1712
  #_initHdr() {
1714
1713
  let docHdr = this.#_getHdr();
@@ -1724,7 +1723,6 @@ class TXEpgContentProvider {
1724
1723
 
1725
1724
  /**
1726
1725
  * @returns {?Object}
1727
- * @private
1728
1726
  */
1729
1727
  #_getBody() {
1730
1728
  const docRoot = this.#_getRoot();
@@ -1737,7 +1735,6 @@ class TXEpgContentProvider {
1737
1735
 
1738
1736
  /**
1739
1737
  * @returns {?object}
1740
- * @private
1741
1738
  */
1742
1739
  #_initBody() {
1743
1740
  let docBody = this.#_getBody();
@@ -2069,8 +2066,3 @@ module.exports.TXEpgProviderContainer = TXEpgProviderContainer;
2069
2066
  module.exports.TXEpgChannelContainer = TXEpgChannelContainer;
2070
2067
  module.exports.TXEpgHeaderContainer = TXEpgHeaderContainer;
2071
2068
  module.exports.TXEpgContentProvider = TXEpgContentProvider;
2072
-
2073
- // * re-exported *
2074
- module.exports.readAsTagName = readAsTagName;
2075
- module.exports.readAsAttrName = readAsAttrName;
2076
- module.exports.valueToElementID = valueToElementID;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ygracs/xepg-lib-js",
3
- "version": "0.0.25",
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,6 +13,7 @@
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",
@@ -20,29 +21,34 @@
20
21
  "lib/xepgdoc-lib.js",
21
22
  "lib/dts-helper.js",
22
23
  "lib/xml-base.js",
24
+ "lib/*.d.ts",
23
25
  "index.js",
26
+ "index.d.ts",
24
27
  "CHANGELOG.md"
25
28
  ],
26
29
  "scripts": {
27
30
  "test": "cross-env TZ='Etc/UTC' jest",
28
31
  "build-doc-md": "jsdoc2md",
29
- "build-doc-html": "jsdoc"
32
+ "build-doc-html": "jsdoc",
33
+ "gen-dts": "npx -p typescript tsc"
30
34
  },
31
35
  "imports": {
32
36
  "#lib/*": "./lib/*",
33
37
  "#test-dir/*": "./__test__/*"
34
38
  },
35
39
  "dependencies": {
36
- "@cntwg/file-helper": "^0.0.1",
37
- "@ygracs/bsfoc-lib-js": "^0.3.0",
38
- "@ygracs/dtf-lib-js": "^0.0.30",
39
- "@ygracs/xml-js6": "^0.0.5-b",
40
- "@ygracs/xobj-lib-js": "^0.2.4"
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"
41
45
  },
42
46
  "devDependencies": {
43
- "cross-env": "^10.0.0",
44
- "jest": "^30.0.5",
45
- "jsdoc-to-markdown": "^9.1.2",
46
- "minimist": "^1.2.8"
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"
47
53
  }
48
54
  }