1 | "use strict";
|
---|
2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
---|
3 | if (k2 === undefined) k2 = k;
|
---|
4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
---|
5 | }) : (function(o, m, k, k2) {
|
---|
6 | if (k2 === undefined) k2 = k;
|
---|
7 | o[k2] = m[k];
|
---|
8 | }));
|
---|
9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
---|
10 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
---|
11 | }) : function(o, v) {
|
---|
12 | o["default"] = v;
|
---|
13 | });
|
---|
14 | var __importStar = (this && this.__importStar) || function (mod) {
|
---|
15 | if (mod && mod.__esModule) return mod;
|
---|
16 | var result = {};
|
---|
17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
---|
18 | __setModuleDefault(result, mod);
|
---|
19 | return result;
|
---|
20 | };
|
---|
21 | var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
---|
22 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
---|
23 | };
|
---|
24 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
---|
25 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
---|
26 | };
|
---|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
28 | exports.RssHandler = exports.DefaultHandler = exports.DomUtils = exports.ElementType = exports.Tokenizer = exports.createDomStream = exports.parseDOM = exports.parseDocument = exports.DomHandler = exports.Parser = void 0;
|
---|
29 | var Parser_1 = require("./Parser");
|
---|
30 | Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return Parser_1.Parser; } });
|
---|
31 | var domhandler_1 = require("domhandler");
|
---|
32 | Object.defineProperty(exports, "DomHandler", { enumerable: true, get: function () { return domhandler_1.DomHandler; } });
|
---|
33 | Object.defineProperty(exports, "DefaultHandler", { enumerable: true, get: function () { return domhandler_1.DomHandler; } });
|
---|
34 | // Helper methods
|
---|
35 | /**
|
---|
36 | * Parses the data, returns the resulting document.
|
---|
37 | *
|
---|
38 | * @param data The data that should be parsed.
|
---|
39 | * @param options Optional options for the parser and DOM builder.
|
---|
40 | */
|
---|
41 | function parseDocument(data, options) {
|
---|
42 | var handler = new domhandler_1.DomHandler(undefined, options);
|
---|
43 | new Parser_1.Parser(handler, options).end(data);
|
---|
44 | return handler.root;
|
---|
45 | }
|
---|
46 | exports.parseDocument = parseDocument;
|
---|
47 | /**
|
---|
48 | * Parses data, returns an array of the root nodes.
|
---|
49 | *
|
---|
50 | * Note that the root nodes still have a `Document` node as their parent.
|
---|
51 | * Use `parseDocument` to get the `Document` node instead.
|
---|
52 | *
|
---|
53 | * @param data The data that should be parsed.
|
---|
54 | * @param options Optional options for the parser and DOM builder.
|
---|
55 | * @deprecated Use `parseDocument` instead.
|
---|
56 | */
|
---|
57 | function parseDOM(data, options) {
|
---|
58 | return parseDocument(data, options).children;
|
---|
59 | }
|
---|
60 | exports.parseDOM = parseDOM;
|
---|
61 | /**
|
---|
62 | * Creates a parser instance, with an attached DOM handler.
|
---|
63 | *
|
---|
64 | * @param cb A callback that will be called once parsing has been completed.
|
---|
65 | * @param options Optional options for the parser and DOM builder.
|
---|
66 | * @param elementCb An optional callback that will be called every time a tag has been completed inside of the DOM.
|
---|
67 | */
|
---|
68 | function createDomStream(cb, options, elementCb) {
|
---|
69 | var handler = new domhandler_1.DomHandler(cb, options, elementCb);
|
---|
70 | return new Parser_1.Parser(handler, options);
|
---|
71 | }
|
---|
72 | exports.createDomStream = createDomStream;
|
---|
73 | var Tokenizer_1 = require("./Tokenizer");
|
---|
74 | Object.defineProperty(exports, "Tokenizer", { enumerable: true, get: function () { return __importDefault(Tokenizer_1).default; } });
|
---|
75 | var ElementType = __importStar(require("domelementtype"));
|
---|
76 | exports.ElementType = ElementType;
|
---|
77 | /*
|
---|
78 | * All of the following exports exist for backwards-compatibility.
|
---|
79 | * They should probably be removed eventually.
|
---|
80 | */
|
---|
81 | __exportStar(require("./FeedHandler"), exports);
|
---|
82 | exports.DomUtils = __importStar(require("domutils"));
|
---|
83 | var FeedHandler_1 = require("./FeedHandler");
|
---|
84 | Object.defineProperty(exports, "RssHandler", { enumerable: true, get: function () { return FeedHandler_1.FeedHandler; } });
|
---|