rx-player 4.0.0-dev.202402213 → 4.0.0-dev.2024022300
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/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/commonjs/core/main/worker/worker_main.js +8 -9
- package/dist/commonjs/features/features_object.js +1 -1
- package/dist/commonjs/features/list/dash.js +2 -2
- package/dist/commonjs/features/types.d.ts +8 -3
- package/dist/commonjs/main_thread/api/public_api.js +2 -7
- package/dist/commonjs/multithread_types.d.ts +1 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.d.ts +4 -3
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +11 -4
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.d.ts +2 -1
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.js +12 -3
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.d.ts +3 -2
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.js +22 -11
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/parse_s_element.d.ts +11 -2
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/parse_s_element.js +74 -3
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +2 -1
- package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +3 -1
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/index.d.ts +17 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/index.js +19 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.js +400 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.js +33 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.js +70 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.js +118 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.js +154 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.js +70 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.js +221 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Period.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Period.js +179 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +256 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.d.ts +23 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.js +152 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.js +60 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.js +125 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.d.ts +22 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.js +36 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.js +82 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts +176 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.js +382 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.d.ts +24 -0
- package/dist/commonjs/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.js +142 -0
- package/dist/commonjs/parsers/manifest/dash/node_parser_types.d.ts +5 -3
- package/dist/commonjs/public_types.d.ts +1 -1
- package/dist/commonjs/transports/dash/manifest_parser.js +33 -4
- package/dist/commonjs/utils/xml-parser.d.ts +70 -0
- package/dist/commonjs/utils/xml-parser.js +357 -0
- package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/es2017/core/main/worker/worker_main.js +8 -9
- package/dist/es2017/features/features_object.js +1 -1
- package/dist/es2017/features/list/dash.js +2 -2
- package/dist/es2017/features/types.d.ts +8 -3
- package/dist/es2017/main_thread/api/public_api.js +2 -7
- package/dist/es2017/multithread_types.d.ts +1 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.d.ts +4 -3
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +12 -5
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.d.ts +2 -1
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.js +13 -4
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.d.ts +3 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.js +22 -11
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/parse_s_element.d.ts +11 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/parse_s_element.js +49 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +2 -1
- package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +3 -1
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/index.d.ts +17 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/index.js +17 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.js +358 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.js +30 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.js +45 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.js +77 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.js +101 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.js +45 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.js +179 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Period.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Period.js +137 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +214 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.d.ts +23 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.js +111 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.js +41 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.js +84 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.d.ts +22 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.js +33 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.js +57 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts +176 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.js +310 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.d.ts +24 -0
- package/dist/es2017/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.js +114 -0
- package/dist/es2017/parsers/manifest/dash/node_parser_types.d.ts +5 -3
- package/dist/es2017/public_types.d.ts +1 -1
- package/dist/es2017/transports/dash/manifest_parser.js +33 -4
- package/dist/es2017/utils/xml-parser.d.ts +70 -0
- package/dist/es2017/utils/xml-parser.js +322 -0
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +141 -65
- package/dist/rx-player.min.js +1 -1
- package/dist/worker.js +8 -3
- package/package.json +1 -1
- package/.vscode/settings.json +0 -9
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/index.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/index.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/AdaptationSet.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/AdaptationSet.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/BaseURL.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/BaseURL.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/EventStream.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/EventStream.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Initialization.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Initialization.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/MPD.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/MPD.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Period.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Period.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Representation.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Representation.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentBase.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentBase.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTemplate.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTemplate.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentURL.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentURL.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/utils.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/utils.js +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/parse_from_document.d.ts +0 -0
- /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/parse_from_document.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/index.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/index.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/AdaptationSet.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/AdaptationSet.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/BaseURL.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/BaseURL.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/EventStream.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/EventStream.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Initialization.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Initialization.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/MPD.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/MPD.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Period.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Period.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Representation.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/Representation.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentBase.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentBase.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTemplate.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTemplate.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentURL.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentURL.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/utils.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/utils.js +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/parse_from_document.d.ts +0 -0
- /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/parse_from_document.js +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code is mainly a modified version of the tXml library.
|
|
3
|
+
*
|
|
4
|
+
* @author: Tobias Nickel
|
|
5
|
+
* created: 06.04.2015
|
|
6
|
+
* https://github.com/TobiasNickel/tXml
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The MIT License (MIT)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2015 Tobias Nickel
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
export interface ITNode {
|
|
32
|
+
tagName: string;
|
|
33
|
+
attributes: Partial<Record<string, string | null>>;
|
|
34
|
+
children: Array<ITNode | string>;
|
|
35
|
+
posStart: number;
|
|
36
|
+
posEnd: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ITParseOptions {
|
|
39
|
+
pos?: number;
|
|
40
|
+
noChildNodes?: string[];
|
|
41
|
+
keepComments?: boolean;
|
|
42
|
+
keepWhitespace?: boolean;
|
|
43
|
+
simplify?: boolean;
|
|
44
|
+
filter?: (a: ITNode, i: number) => boolean;
|
|
45
|
+
attrName?: string;
|
|
46
|
+
attrValue?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* parseXML / html into a DOM Object. with no validation and some failur tolerance
|
|
50
|
+
* @param {string} src - Your XML to parse
|
|
51
|
+
* @param {Object} [options = {}] - all other options:
|
|
52
|
+
* @return {Array.<Object | string>}
|
|
53
|
+
*/
|
|
54
|
+
declare function parseXml(src: string, options?: ITParseOptions): Array<ITNode | string>;
|
|
55
|
+
/**
|
|
56
|
+
* behaves the same way as Array.filter, if the filter method return true, the element is in the resultList
|
|
57
|
+
* @params {Array} children - the children of a node
|
|
58
|
+
* @param {function} f - the filter method
|
|
59
|
+
*/
|
|
60
|
+
declare function filter(children: Array<ITNode | string>, f: (a: ITNode, i: number, dept: number, path: string) => boolean, dept?: number, path?: string): Array<ITNode | string>;
|
|
61
|
+
/**
|
|
62
|
+
* use this method to read the text content, of some node.
|
|
63
|
+
* It is great if you have mixed content like:
|
|
64
|
+
* this text has some <b>big</b> text and a <a href=''>link</a>
|
|
65
|
+
* @return {string}
|
|
66
|
+
*/
|
|
67
|
+
declare function toContentString(tDom: ITNode | string | Array<ITNode | string>): string;
|
|
68
|
+
declare function getElementById(src: string, id: string): ITNode | string | undefined;
|
|
69
|
+
declare function getElementsByClassName(src: string, classname: string): Array<ITNode | string>;
|
|
70
|
+
export { filter, getElementById, getElementsByClassName, parseXml, toContentString };
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This code is mainly a modified version of the tXml library.
|
|
4
|
+
*
|
|
5
|
+
* @author: Tobias Nickel
|
|
6
|
+
* created: 06.04.2015
|
|
7
|
+
* https://github.com/TobiasNickel/tXml
|
|
8
|
+
*/
|
|
9
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
10
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
11
|
+
if (!m) return o;
|
|
12
|
+
var i = m.call(o), r, ar = [], e;
|
|
13
|
+
try {
|
|
14
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
15
|
+
}
|
|
16
|
+
catch (error) { e = { error: error }; }
|
|
17
|
+
finally {
|
|
18
|
+
try {
|
|
19
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
20
|
+
}
|
|
21
|
+
finally { if (e) throw e.error; }
|
|
22
|
+
}
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
+
if (ar || !(i in from)) {
|
|
28
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
+
ar[i] = from[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.toContentString = exports.parseXml = exports.getElementsByClassName = exports.getElementById = exports.filter = void 0;
|
|
36
|
+
var openBracket = "<";
|
|
37
|
+
var openBracketCC = "<".charCodeAt(0);
|
|
38
|
+
var closeBracket = ">";
|
|
39
|
+
var closeBracketCC = ">".charCodeAt(0);
|
|
40
|
+
var minusCC = "-".charCodeAt(0);
|
|
41
|
+
var slashCC = "/".charCodeAt(0);
|
|
42
|
+
var exclamationCC = "!".charCodeAt(0);
|
|
43
|
+
var singleQuoteCC = "'".charCodeAt(0);
|
|
44
|
+
var doubleQuoteCC = '"'.charCodeAt(0);
|
|
45
|
+
var openCornerBracketCC = "[".charCodeAt(0);
|
|
46
|
+
var closeCornerBracketCC = "]".charCodeAt(0);
|
|
47
|
+
/** Character marking end of attribute and node name. */
|
|
48
|
+
var nameSpacer = "\r\n\t>/= ";
|
|
49
|
+
/**
|
|
50
|
+
* parseXML / html into a DOM Object. with no validation and some failur tolerance
|
|
51
|
+
* @param {string} src - Your XML to parse
|
|
52
|
+
* @param {Object} [options = {}] - all other options:
|
|
53
|
+
* @return {Array.<Object | string>}
|
|
54
|
+
*/
|
|
55
|
+
function parseXml(src, options) {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
if (options === void 0) { options = {}; }
|
|
58
|
+
var pos = (_a = options.pos) !== null && _a !== void 0 ? _a : 0;
|
|
59
|
+
var keepComments = options.keepComments === true;
|
|
60
|
+
var keepWhitespace = options.keepWhitespace === true;
|
|
61
|
+
var out;
|
|
62
|
+
if (options.attrValue !== undefined) {
|
|
63
|
+
options.attrName = (_b = options.attrName) !== null && _b !== void 0 ? _b : "id";
|
|
64
|
+
out = [];
|
|
65
|
+
while ((pos = findElements()) !== -1) {
|
|
66
|
+
pos = src.lastIndexOf("<", pos);
|
|
67
|
+
if (pos !== -1) {
|
|
68
|
+
out.push(parseNode());
|
|
69
|
+
}
|
|
70
|
+
// eslint-disable-next-line no-param-reassign
|
|
71
|
+
src = src.substring(pos);
|
|
72
|
+
pos = 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
out = parseChildren("");
|
|
77
|
+
}
|
|
78
|
+
if (options.filter) {
|
|
79
|
+
out = filter(out, options.filter);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
/**
|
|
83
|
+
* parsing a list of entries
|
|
84
|
+
* @param {string} tagName
|
|
85
|
+
* @returns {Array.<ITNode | string>}
|
|
86
|
+
*/
|
|
87
|
+
function parseChildren(tagName) {
|
|
88
|
+
var children = [];
|
|
89
|
+
while (src[pos]) {
|
|
90
|
+
if (src.charCodeAt(pos) === openBracketCC) {
|
|
91
|
+
if (src.charCodeAt(pos + 1) === slashCC) {
|
|
92
|
+
var closeStart = pos + 2;
|
|
93
|
+
pos = src.indexOf(closeBracket, pos);
|
|
94
|
+
var closeTag = src.substring(closeStart, pos);
|
|
95
|
+
if (closeTag.indexOf(tagName) === -1) {
|
|
96
|
+
var parsedText = src.substring(0, pos).split("\n");
|
|
97
|
+
throw new Error("Unexpected close tag\nLine: " +
|
|
98
|
+
(parsedText.length - 1) +
|
|
99
|
+
"\nColumn: " +
|
|
100
|
+
(parsedText[parsedText.length - 1].length + 1) +
|
|
101
|
+
"\nChar: " +
|
|
102
|
+
src[pos]);
|
|
103
|
+
}
|
|
104
|
+
if (pos !== -1) {
|
|
105
|
+
pos += 1;
|
|
106
|
+
}
|
|
107
|
+
return children;
|
|
108
|
+
}
|
|
109
|
+
else if (src.charCodeAt(pos + 1) === exclamationCC) {
|
|
110
|
+
if (src.charCodeAt(pos + 2) === minusCC) {
|
|
111
|
+
// comment support
|
|
112
|
+
var startCommentPos = pos;
|
|
113
|
+
while (pos !== -1 &&
|
|
114
|
+
!(src.charCodeAt(pos) === closeBracketCC &&
|
|
115
|
+
src.charCodeAt(pos - 1) === minusCC &&
|
|
116
|
+
src.charCodeAt(pos - 2) === minusCC)) {
|
|
117
|
+
pos = src.indexOf(closeBracket, pos + 1);
|
|
118
|
+
}
|
|
119
|
+
if (pos === -1) {
|
|
120
|
+
pos = src.length;
|
|
121
|
+
}
|
|
122
|
+
if (keepComments) {
|
|
123
|
+
children.push(src.substring(startCommentPos, pos + 1));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (src.charCodeAt(pos + 2) === openCornerBracketCC &&
|
|
127
|
+
src.charCodeAt(pos + 8) === openCornerBracketCC &&
|
|
128
|
+
src.substring(pos + 3, pos + 8).toLowerCase() === "cdata") {
|
|
129
|
+
// cdata
|
|
130
|
+
var cdataEndIndex = src.indexOf("]]>", pos);
|
|
131
|
+
if (cdataEndIndex === -1) {
|
|
132
|
+
children.push(src.substring(pos + 9));
|
|
133
|
+
pos = src.length;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
children.push(src.substring(pos + 9, cdataEndIndex));
|
|
137
|
+
pos = cdataEndIndex + 3;
|
|
138
|
+
}
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// doctypesupport
|
|
143
|
+
var startDoctype = pos + 1;
|
|
144
|
+
pos += 2;
|
|
145
|
+
var encapsuled = false;
|
|
146
|
+
while ((src.charCodeAt(pos) !== closeBracketCC || encapsuled) && src[pos]) {
|
|
147
|
+
if (src.charCodeAt(pos) === openCornerBracketCC) {
|
|
148
|
+
encapsuled = true;
|
|
149
|
+
}
|
|
150
|
+
else if (encapsuled && src.charCodeAt(pos) === closeCornerBracketCC) {
|
|
151
|
+
encapsuled = false;
|
|
152
|
+
}
|
|
153
|
+
pos++;
|
|
154
|
+
}
|
|
155
|
+
children.push(src.substring(startDoctype, pos));
|
|
156
|
+
}
|
|
157
|
+
pos++;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
var node = parseNode();
|
|
161
|
+
children.push(node);
|
|
162
|
+
if (node.tagName[0] === "?") {
|
|
163
|
+
children.push.apply(children, __spreadArray([], __read(node.children), false));
|
|
164
|
+
node.children = [];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
var text = parseText();
|
|
169
|
+
if (keepWhitespace) {
|
|
170
|
+
if (text.length > 0) {
|
|
171
|
+
children.push(text);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
var trimmed = text.trim();
|
|
176
|
+
if (trimmed.length > 0) {
|
|
177
|
+
children.push(trimmed);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
pos++;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return children;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* returns the text outside of texts until the first '<'
|
|
187
|
+
*/
|
|
188
|
+
function parseText() {
|
|
189
|
+
var start = pos;
|
|
190
|
+
pos = src.indexOf(openBracket, pos) - 1;
|
|
191
|
+
if (pos === -2) {
|
|
192
|
+
pos = src.length;
|
|
193
|
+
}
|
|
194
|
+
return src.slice(start, pos + 1);
|
|
195
|
+
}
|
|
196
|
+
function parseName() {
|
|
197
|
+
var start = pos;
|
|
198
|
+
while (nameSpacer.indexOf(src[pos]) === -1 && src[pos]) {
|
|
199
|
+
pos++;
|
|
200
|
+
}
|
|
201
|
+
return src.slice(start, pos);
|
|
202
|
+
}
|
|
203
|
+
function parseNode() {
|
|
204
|
+
var posStart = pos;
|
|
205
|
+
pos++;
|
|
206
|
+
var tagName = parseName();
|
|
207
|
+
var attributes = {};
|
|
208
|
+
var children = [];
|
|
209
|
+
// parsing attributes
|
|
210
|
+
while (src.charCodeAt(pos) !== closeBracketCC && src[pos]) {
|
|
211
|
+
var c = src.charCodeAt(pos);
|
|
212
|
+
if ((c > 64 && c < 91) || (c > 96 && c < 123)) {
|
|
213
|
+
// if('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(src[pos])!==-1 ){
|
|
214
|
+
var name_1 = parseName();
|
|
215
|
+
// search beginning of the string
|
|
216
|
+
var code = src.charCodeAt(pos);
|
|
217
|
+
while (code &&
|
|
218
|
+
code !== singleQuoteCC &&
|
|
219
|
+
code !== doubleQuoteCC &&
|
|
220
|
+
!((code > 64 && code < 91) || (code > 96 && code < 123)) &&
|
|
221
|
+
code !== closeBracketCC) {
|
|
222
|
+
pos++;
|
|
223
|
+
code = src.charCodeAt(pos);
|
|
224
|
+
}
|
|
225
|
+
var value = void 0;
|
|
226
|
+
if (code === singleQuoteCC || code === doubleQuoteCC) {
|
|
227
|
+
value = parseString();
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
value = null;
|
|
231
|
+
pos--;
|
|
232
|
+
}
|
|
233
|
+
attributes[name_1] = value === null ? null : translateEntities(value);
|
|
234
|
+
}
|
|
235
|
+
pos++;
|
|
236
|
+
}
|
|
237
|
+
// optional parsing of children
|
|
238
|
+
if (src.charCodeAt(pos - 1) !== slashCC) {
|
|
239
|
+
pos++;
|
|
240
|
+
children = parseChildren(tagName);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
pos++;
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
tagName: tagName,
|
|
247
|
+
attributes: attributes,
|
|
248
|
+
children: children,
|
|
249
|
+
posStart: posStart,
|
|
250
|
+
posEnd: pos,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Parses a string, that starts with a char and with the same usually ' or "
|
|
255
|
+
* character starting at `pos`.
|
|
256
|
+
* @returns {string}
|
|
257
|
+
*/
|
|
258
|
+
function parseString() {
|
|
259
|
+
var startChar = src[pos];
|
|
260
|
+
var startpos = pos + 1;
|
|
261
|
+
pos = src.indexOf(startChar, startpos);
|
|
262
|
+
return src.slice(startpos, pos);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
*
|
|
266
|
+
*/
|
|
267
|
+
function findElements() {
|
|
268
|
+
var r = new RegExp("\\s" + options.attrName + "\\s*=['\"]" + options.attrValue + "['\"]").exec(src);
|
|
269
|
+
if (r) {
|
|
270
|
+
return r.index;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
return -1;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
exports.parseXml = parseXml;
|
|
278
|
+
/**
|
|
279
|
+
* behaves the same way as Array.filter, if the filter method return true, the element is in the resultList
|
|
280
|
+
* @params {Array} children - the children of a node
|
|
281
|
+
* @param {function} f - the filter method
|
|
282
|
+
*/
|
|
283
|
+
function filter(children, f, dept, path) {
|
|
284
|
+
if (dept === void 0) { dept = 0; }
|
|
285
|
+
if (path === void 0) { path = ""; }
|
|
286
|
+
var out = [];
|
|
287
|
+
children.forEach(function (child, i) {
|
|
288
|
+
if (typeof child === "object") {
|
|
289
|
+
if (f(child, i, dept, path)) {
|
|
290
|
+
out.push(child);
|
|
291
|
+
}
|
|
292
|
+
if (child.children.length > 0) {
|
|
293
|
+
var kids = filter(child.children, f, dept + 1, (path ? path + "." : "") + i + "." + child.tagName);
|
|
294
|
+
out = out.concat(kids);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
exports.filter = filter;
|
|
301
|
+
/**
|
|
302
|
+
* use this method to read the text content, of some node.
|
|
303
|
+
* It is great if you have mixed content like:
|
|
304
|
+
* this text has some <b>big</b> text and a <a href=''>link</a>
|
|
305
|
+
* @return {string}
|
|
306
|
+
*/
|
|
307
|
+
function toContentString(tDom) {
|
|
308
|
+
if (Array.isArray(tDom)) {
|
|
309
|
+
var out_1 = "";
|
|
310
|
+
tDom.forEach(function (e) {
|
|
311
|
+
out_1 += " " + toContentString(e);
|
|
312
|
+
out_1 = out_1.trim();
|
|
313
|
+
});
|
|
314
|
+
return out_1;
|
|
315
|
+
}
|
|
316
|
+
else if (typeof tDom === "object") {
|
|
317
|
+
return toContentString(tDom.children);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
return " " + translateEntities(tDom);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
exports.toContentString = toContentString;
|
|
324
|
+
/**
|
|
325
|
+
* @param {string} str
|
|
326
|
+
* @returns {string}
|
|
327
|
+
*/
|
|
328
|
+
function translateEntities(str) {
|
|
329
|
+
if (str.indexOf("&") < 0) {
|
|
330
|
+
// Fast path for when there's no entity
|
|
331
|
+
return str;
|
|
332
|
+
}
|
|
333
|
+
return str
|
|
334
|
+
.replace(/</g, "<")
|
|
335
|
+
.replace(/>/g, ">")
|
|
336
|
+
.replace(/"/g, '"')
|
|
337
|
+
.replace(/'/g, "'")
|
|
338
|
+
.replace(/&#x([A-Fa-f0-9]+);/g, function (_, code) {
|
|
339
|
+
return String.fromCharCode(parseInt(code, 16));
|
|
340
|
+
})
|
|
341
|
+
.replace(/&/g, "&");
|
|
342
|
+
}
|
|
343
|
+
function getElementById(src, id) {
|
|
344
|
+
var out = parseXml(src, {
|
|
345
|
+
attrValue: id,
|
|
346
|
+
});
|
|
347
|
+
return out[0];
|
|
348
|
+
}
|
|
349
|
+
exports.getElementById = getElementById;
|
|
350
|
+
function getElementsByClassName(src, classname) {
|
|
351
|
+
var out = parseXml(src, {
|
|
352
|
+
attrName: "class",
|
|
353
|
+
attrValue: "[a-zA-Z0-9- ]*" + classname + "[a-zA-Z0-9- ]*",
|
|
354
|
+
});
|
|
355
|
+
return out;
|
|
356
|
+
}
|
|
357
|
+
exports.getElementsByClassName = getElementsByClassName;
|