fix
This commit is contained in:
80
book/node_modules/web-resource-inliner/README.md
generated
vendored
Normal file
80
book/node_modules/web-resource-inliner/README.md
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
# web-resource-inliner [](http://travis-ci.org/jrit/web-resource-inliner)
|
||||
|
||||
Brings externally referenced resources, such as js, css and images, into a single file.
|
||||
|
||||
For example:
|
||||
|
||||
```html
|
||||
<link href="css/style.css" rel="stylesheet" data-inline >
|
||||
```
|
||||
is replaced with
|
||||
```html
|
||||
<style>
|
||||
/* contents of css/style.css */
|
||||
</style>
|
||||
```
|
||||
|
||||
Javascript references are brought inline, and images in the html and css blocks are converted to base-64 data: urls.
|
||||
|
||||
By default, all links and scripts are inlined, plus any images under 8KB, however this behavior can be overrided via several options.
|
||||
|
||||
|
||||
## Getting Started
|
||||
```
|
||||
npm install web-resource-inliner
|
||||
```
|
||||
|
||||
|
||||
## Usage Examples
|
||||
|
||||
For a number of usage examples, see ./test/spec.js and the associated test.* and test_out.* files in ./test/cases/
|
||||
|
||||
## Methods
|
||||
|
||||
#### html( options, callback )
|
||||
Expects options.fileContent to be HTML and creates a new HTML document. `callback` will be called on completion or error with arguments `( error, result )`.
|
||||
|
||||
#### css( options, callback )
|
||||
Expects options.fileContent to be CSS and creates a new CSS document. `callback` will be called on completion or error with arguments `( error, result )`.
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
#### `fileContent`, required
|
||||
This is the HTML or CSS content to be inlined, you should provide HTML to the `html()` method and CSS to the `css()` method or you will get errors or garbage output.
|
||||
|
||||
#### `inlineAttribute`, string, default `data-inline`
|
||||
Sets the attribute that is used to include/exclude specific resources based on the default behavior for the resource type. For example, if `scripts` is set to `false`, an individual script can be inlined by adding the attribute to the `script` tag like `<script src="myscript.js" data-inline ></script>`. On the other hand, if `images` are set to be inlined by default, a specific image can be excluded by adding `-ignore` to the end of the `inlineAttribute` like `<img src="myimg.png" data-inline-ignore >`. In CSS, a comment is required at the end of the line to perform the same thing, such as `/*data-inline*/` or `/*data-inline-ignore*/`.
|
||||
|
||||
#### `images`, Boolean or Number, default `8`
|
||||
When true, inline images unless they have an exclusion attribute (see inlineAttribute option). When false, exclude images unless they have an inclusion attribute (see inlineAttribute option). When a number, inline images only when the base64 content size is less than the number of KBs. For example, the default is to only inline images less than 8KB.
|
||||
|
||||
#### `svgs`, Boolean or Number, default `8`
|
||||
When true, inline SVG `<use>` unless they have an exclusion attribute (see inlineAttribute option). When false, exclude SVG `<use>` unless they have an inclusion attribute (see inlineAttribute option). When a number, inline SVG `<use>` only when the content size is less than the number of KBs. For example, the default is to only inline SVGs less than 8KB.
|
||||
|
||||
#### `scripts`, Boolean or Number, default `true`
|
||||
When true, inline scripts unless they have an exclusion attribute (see inlineAttribute option). When false, exclude scripts unless they have an inclusion attribute (see inlineAttribute option). When a number, inline scripts only when the base64 content size is less than the number of KBs.
|
||||
|
||||
#### `links`, Boolean or Number, default `true`
|
||||
When true, inline stylesheet links unless they have an exclusion attribute (see inlineAttribute option). When false, exclude stylesheet links unless they have an inclusion attribute (see inlineAttribute option). When a number, inline stylesheet links only when the base64 content size is less than the number of KBs.
|
||||
|
||||
#### `relativeTo`, string, default empty string
|
||||
Describes the path relationship between where web-resource-inliner is running and what the relative paths in `fileContent` or href/src urls refer to. For example, the tests cases in this package are in `test/cases/` so their relative paths start by referring to that folder, but the root of this project and where `npm test` runs from is 2 folders up, so `relativeTo` is set to `test/cases/` in `test/spec.js`. Likewise, with `href="content.css"` and a `relativeTo` of `http://github.com/` the resource retrieved would be `http://github.com/content.css`.
|
||||
|
||||
#### `rebaseRelativeTo`, string, default empty string
|
||||
Describes the path relationship between CSS content and the context it will be loaded in. For example, when a CSS file contains `url(some-file.png)` and the file is moved from a location in a folder like `/css` to `/` then the path to the image needs to be changed to `url(css/some-file.png)`. In this case, `rebaseRelativeTo` would be `css`. You probably don't want to set this when you are using `html()`.
|
||||
|
||||
#### `strict`, Boolean, default `false`
|
||||
When strict is `true`, a missing resource will cause the inliner to halt and return an error in the callback. The default behavior is to log a warning to the console and continue inlining with the available resources, which is more similar to how a web page behaves.
|
||||
|
||||
#### `requestResource`, Function, default `undefined`
|
||||
Allows to adjust issued requests. E.g., add authentication tokens to requested URLs. The function is called with `{ uri, encoding, gzip }` object as its parameter. It can replace builtin [node-fetch](https://github.com/node-fetch/node-fetch) with your own solution.
|
||||
|
||||
#### `scriptTransform`, Function( content, callback ), default `undefined`
|
||||
Allows to make changes to scripts before they are inlined, such as minifying. Callback is standard node error first, second argument is transformed value.
|
||||
|
||||
#### `linkTransform`, Function( content, callback ), default `undefined`
|
||||
Allows to make changes to links before they are inlined, such as CSS pre-and-post-processors. Callback is standard node error first, second argument is transformed value.
|
||||
|
||||
## Contributing
|
||||
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Run tests with `npm test`.
|
1
book/node_modules/web-resource-inliner/node_modules/.bin/mime
generated
vendored
Symbolic link
1
book/node_modules/web-resource-inliner/node_modules/.bin/mime
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../mime/cli.js
|
11
book/node_modules/web-resource-inliner/node_modules/dom-serializer/LICENSE
generated
vendored
Normal file
11
book/node_modules/web-resource-inliner/node_modules/dom-serializer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 The cheeriojs contributors
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
97
book/node_modules/web-resource-inliner/node_modules/dom-serializer/README.md
generated
vendored
Normal file
97
book/node_modules/web-resource-inliner/node_modules/dom-serializer/README.md
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
# dom-serializer [](https://travis-ci.com/cheeriojs/dom-serializer)
|
||||
|
||||
Renders a [domhandler](https://github.com/fb55/domhandler) DOM node or an array of domhandler DOM nodes to a string.
|
||||
|
||||
```js
|
||||
import render from "dom-serializer";
|
||||
|
||||
// OR
|
||||
|
||||
const render = require("dom-serializer").default;
|
||||
```
|
||||
|
||||
# API
|
||||
|
||||
## `render`
|
||||
|
||||
▸ **render**(`node`: Node \| Node[], `options?`: [_Options_](#Options)): _string_
|
||||
|
||||
Renders a DOM node or an array of DOM nodes to a string.
|
||||
|
||||
Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
|
||||
|
||||
#### Parameters:
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :-------- | :--------------------------------- | :------------ | :----------------------------- |
|
||||
| `node` | Node \| Node[] | - | Node to be rendered. |
|
||||
| `options` | [_DomSerializerOptions_](#Options) | {} | Changes serialization behavior |
|
||||
|
||||
**Returns:** _string_
|
||||
|
||||
## Options
|
||||
|
||||
### `decodeEntities`
|
||||
|
||||
• `Optional` **decodeEntities**: _boolean_
|
||||
|
||||
Encode characters that are either reserved in HTML or XML, or are outside of the ASCII range.
|
||||
|
||||
**`default`** true
|
||||
|
||||
---
|
||||
|
||||
### `emptyAttrs`
|
||||
|
||||
• `Optional` **emptyAttrs**: _boolean_
|
||||
|
||||
Print an empty attribute's value.
|
||||
|
||||
**`default`** xmlMode
|
||||
|
||||
**`example`** With <code>emptyAttrs: false</code>: <code><input checked></code>
|
||||
|
||||
**`example`** With <code>emptyAttrs: true</code>: <code><input checked=""></code>
|
||||
|
||||
---
|
||||
|
||||
### `selfClosingTags`
|
||||
|
||||
• `Optional` **selfClosingTags**: _boolean_
|
||||
|
||||
Print self-closing tags for tags without contents.
|
||||
|
||||
**`default`** xmlMode
|
||||
|
||||
**`example`** With <code>selfClosingTags: false</code>: <code><foo></foo></code>
|
||||
|
||||
**`example`** With <code>selfClosingTags: true</code>: <code><foo /></code>
|
||||
|
||||
---
|
||||
|
||||
### `xmlMode`
|
||||
|
||||
• `Optional` **xmlMode**: _boolean_ \| _"foreign"_
|
||||
|
||||
Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options.
|
||||
|
||||
If the value is `"foreign"`, it will try to correct mixed-case attribute names.
|
||||
|
||||
**`default`** false
|
||||
|
||||
---
|
||||
|
||||
## Ecosystem
|
||||
|
||||
| Name | Description |
|
||||
| ------------------------------------------------------------- | ------------------------------------------------------- |
|
||||
| [htmlparser2](https://github.com/fb55/htmlparser2) | Fast & forgiving HTML/XML parser |
|
||||
| [domhandler](https://github.com/fb55/domhandler) | Handler for htmlparser2 that turns documents into a DOM |
|
||||
| [domutils](https://github.com/fb55/domutils) | Utilities for working with domhandler's DOM |
|
||||
| [css-select](https://github.com/fb55/css-select) | CSS selector engine, compatible with domhandler's DOM |
|
||||
| [cheerio](https://github.com/cheeriojs/cheerio) | The jQuery API for domhandler's DOM |
|
||||
| [dom-serializer](https://github.com/cheeriojs/dom-serializer) | Serializer for domhandler's DOM |
|
||||
|
||||
---
|
||||
|
||||
LICENSE: MIT
|
3
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/foreignNames.d.ts
generated
vendored
Normal file
3
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/foreignNames.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const elementNames: Map<string, string>;
|
||||
export declare const attributeNames: Map<string, string>;
|
||||
//# sourceMappingURL=foreignNames.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/foreignNames.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/foreignNames.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"foreignNames.d.ts","sourceRoot":"","sources":["../../src/foreignNames.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,qBAwCxB,CAAC;AACF,eAAO,MAAM,cAAc,qBA8D1B,CAAC"}
|
100
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/foreignNames.js
generated
vendored
Normal file
100
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/foreignNames.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
export const elementNames = new Map([
|
||||
"altGlyph",
|
||||
"altGlyphDef",
|
||||
"altGlyphItem",
|
||||
"animateColor",
|
||||
"animateMotion",
|
||||
"animateTransform",
|
||||
"clipPath",
|
||||
"feBlend",
|
||||
"feColorMatrix",
|
||||
"feComponentTransfer",
|
||||
"feComposite",
|
||||
"feConvolveMatrix",
|
||||
"feDiffuseLighting",
|
||||
"feDisplacementMap",
|
||||
"feDistantLight",
|
||||
"feDropShadow",
|
||||
"feFlood",
|
||||
"feFuncA",
|
||||
"feFuncB",
|
||||
"feFuncG",
|
||||
"feFuncR",
|
||||
"feGaussianBlur",
|
||||
"feImage",
|
||||
"feMerge",
|
||||
"feMergeNode",
|
||||
"feMorphology",
|
||||
"feOffset",
|
||||
"fePointLight",
|
||||
"feSpecularLighting",
|
||||
"feSpotLight",
|
||||
"feTile",
|
||||
"feTurbulence",
|
||||
"foreignObject",
|
||||
"glyphRef",
|
||||
"linearGradient",
|
||||
"radialGradient",
|
||||
"textPath",
|
||||
].map((val) => [val.toLowerCase(), val]));
|
||||
export const attributeNames = new Map([
|
||||
"definitionURL",
|
||||
"attributeName",
|
||||
"attributeType",
|
||||
"baseFrequency",
|
||||
"baseProfile",
|
||||
"calcMode",
|
||||
"clipPathUnits",
|
||||
"diffuseConstant",
|
||||
"edgeMode",
|
||||
"filterUnits",
|
||||
"glyphRef",
|
||||
"gradientTransform",
|
||||
"gradientUnits",
|
||||
"kernelMatrix",
|
||||
"kernelUnitLength",
|
||||
"keyPoints",
|
||||
"keySplines",
|
||||
"keyTimes",
|
||||
"lengthAdjust",
|
||||
"limitingConeAngle",
|
||||
"markerHeight",
|
||||
"markerUnits",
|
||||
"markerWidth",
|
||||
"maskContentUnits",
|
||||
"maskUnits",
|
||||
"numOctaves",
|
||||
"pathLength",
|
||||
"patternContentUnits",
|
||||
"patternTransform",
|
||||
"patternUnits",
|
||||
"pointsAtX",
|
||||
"pointsAtY",
|
||||
"pointsAtZ",
|
||||
"preserveAlpha",
|
||||
"preserveAspectRatio",
|
||||
"primitiveUnits",
|
||||
"refX",
|
||||
"refY",
|
||||
"repeatCount",
|
||||
"repeatDur",
|
||||
"requiredExtensions",
|
||||
"requiredFeatures",
|
||||
"specularConstant",
|
||||
"specularExponent",
|
||||
"spreadMethod",
|
||||
"startOffset",
|
||||
"stdDeviation",
|
||||
"stitchTiles",
|
||||
"surfaceScale",
|
||||
"systemLanguage",
|
||||
"tableValues",
|
||||
"targetX",
|
||||
"targetY",
|
||||
"textLength",
|
||||
"viewBox",
|
||||
"viewTarget",
|
||||
"xChannelSelector",
|
||||
"yChannelSelector",
|
||||
"zoomAndPan",
|
||||
].map((val) => [val.toLowerCase(), val]));
|
52
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/index.d.ts
generated
vendored
Normal file
52
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import type { AnyNode } from "domhandler";
|
||||
export interface DomSerializerOptions {
|
||||
/**
|
||||
* Print an empty attribute's value.
|
||||
*
|
||||
* @default xmlMode
|
||||
* @example With <code>emptyAttrs: false</code>: <code><input checked></code>
|
||||
* @example With <code>emptyAttrs: true</code>: <code><input checked=""></code>
|
||||
*/
|
||||
emptyAttrs?: boolean;
|
||||
/**
|
||||
* Print self-closing tags for tags without contents.
|
||||
*
|
||||
* @default xmlMode
|
||||
* @example With <code>selfClosingTags: false</code>: <code><foo></foo></code>
|
||||
* @example With <code>selfClosingTags: true</code>: <code><foo /></code>
|
||||
*/
|
||||
selfClosingTags?: boolean;
|
||||
/**
|
||||
* Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options.
|
||||
*
|
||||
* If the value is `"foreign"`, it will try to correct mixed-case attribute names.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean | "foreign";
|
||||
/**
|
||||
* Encode characters that are either reserved in HTML or XML.
|
||||
*
|
||||
* If `xmlMode` is `true` or the value not `'utf8'`, characters outside of the utf8 range will be encoded as well.
|
||||
*
|
||||
* @default `decodeEntities`
|
||||
*/
|
||||
encodeEntities?: boolean | "utf8";
|
||||
/**
|
||||
* Option inherited from parsing; will be used as the default value for `encodeEntities`.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
decodeEntities?: boolean;
|
||||
}
|
||||
/**
|
||||
* Renders a DOM node or an array of DOM nodes to a string.
|
||||
*
|
||||
* Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
|
||||
*
|
||||
* @param node Node to be rendered.
|
||||
* @param options Changes serialization behavior
|
||||
*/
|
||||
export declare function render(node: AnyNode | ArrayLike<AnyNode>, options?: DomSerializerOptions): string;
|
||||
export default render;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/index.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,OAAO,EAMR,MAAM,YAAY,CAAC;AAWpB,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAClC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA4ED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,EAClC,OAAO,GAAE,oBAAyB,GACjC,MAAM,CAUR;AAED,eAAe,MAAM,CAAC"}
|
190
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/index.js
generated
vendored
Normal file
190
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Module dependencies
|
||||
*/
|
||||
import * as ElementType from "domelementtype";
|
||||
import { encodeXML, escapeAttribute, escapeText } from "entities";
|
||||
/**
|
||||
* Mixed-case SVG and MathML tags & attributes
|
||||
* recognized by the HTML parser.
|
||||
*
|
||||
* @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
|
||||
*/
|
||||
import { elementNames, attributeNames } from "./foreignNames.js";
|
||||
const unencodedElements = new Set([
|
||||
"style",
|
||||
"script",
|
||||
"xmp",
|
||||
"iframe",
|
||||
"noembed",
|
||||
"noframes",
|
||||
"plaintext",
|
||||
"noscript",
|
||||
]);
|
||||
function replaceQuotes(value) {
|
||||
return value.replace(/"/g, """);
|
||||
}
|
||||
/**
|
||||
* Format attributes
|
||||
*/
|
||||
function formatAttributes(attributes, opts) {
|
||||
var _a;
|
||||
if (!attributes)
|
||||
return;
|
||||
const encode = ((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) === false
|
||||
? replaceQuotes
|
||||
: opts.xmlMode || opts.encodeEntities !== "utf8"
|
||||
? encodeXML
|
||||
: escapeAttribute;
|
||||
return Object.keys(attributes)
|
||||
.map((key) => {
|
||||
var _a, _b;
|
||||
const value = (_a = attributes[key]) !== null && _a !== void 0 ? _a : "";
|
||||
if (opts.xmlMode === "foreign") {
|
||||
/* Fix up mixed-case attribute names */
|
||||
key = (_b = attributeNames.get(key)) !== null && _b !== void 0 ? _b : key;
|
||||
}
|
||||
if (!opts.emptyAttrs && !opts.xmlMode && value === "") {
|
||||
return key;
|
||||
}
|
||||
return `${key}="${encode(value)}"`;
|
||||
})
|
||||
.join(" ");
|
||||
}
|
||||
/**
|
||||
* Self-enclosing tags
|
||||
*/
|
||||
const singleTag = new Set([
|
||||
"area",
|
||||
"base",
|
||||
"basefont",
|
||||
"br",
|
||||
"col",
|
||||
"command",
|
||||
"embed",
|
||||
"frame",
|
||||
"hr",
|
||||
"img",
|
||||
"input",
|
||||
"isindex",
|
||||
"keygen",
|
||||
"link",
|
||||
"meta",
|
||||
"param",
|
||||
"source",
|
||||
"track",
|
||||
"wbr",
|
||||
]);
|
||||
/**
|
||||
* Renders a DOM node or an array of DOM nodes to a string.
|
||||
*
|
||||
* Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
|
||||
*
|
||||
* @param node Node to be rendered.
|
||||
* @param options Changes serialization behavior
|
||||
*/
|
||||
export function render(node, options = {}) {
|
||||
const nodes = "length" in node ? node : [node];
|
||||
let output = "";
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
output += renderNode(nodes[i], options);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
export default render;
|
||||
function renderNode(node, options) {
|
||||
switch (node.type) {
|
||||
case ElementType.Root:
|
||||
return render(node.children, options);
|
||||
// @ts-expect-error We don't use `Doctype` yet
|
||||
case ElementType.Doctype:
|
||||
case ElementType.Directive:
|
||||
return renderDirective(node);
|
||||
case ElementType.Comment:
|
||||
return renderComment(node);
|
||||
case ElementType.CDATA:
|
||||
return renderCdata(node);
|
||||
case ElementType.Script:
|
||||
case ElementType.Style:
|
||||
case ElementType.Tag:
|
||||
return renderTag(node, options);
|
||||
case ElementType.Text:
|
||||
return renderText(node, options);
|
||||
}
|
||||
}
|
||||
const foreignModeIntegrationPoints = new Set([
|
||||
"mi",
|
||||
"mo",
|
||||
"mn",
|
||||
"ms",
|
||||
"mtext",
|
||||
"annotation-xml",
|
||||
"foreignObject",
|
||||
"desc",
|
||||
"title",
|
||||
]);
|
||||
const foreignElements = new Set(["svg", "math"]);
|
||||
function renderTag(elem, opts) {
|
||||
var _a;
|
||||
// Handle SVG / MathML in HTML
|
||||
if (opts.xmlMode === "foreign") {
|
||||
/* Fix up mixed-case element names */
|
||||
elem.name = (_a = elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name;
|
||||
/* Exit foreign mode at integration points */
|
||||
if (elem.parent &&
|
||||
foreignModeIntegrationPoints.has(elem.parent.name)) {
|
||||
opts = { ...opts, xmlMode: false };
|
||||
}
|
||||
}
|
||||
if (!opts.xmlMode && foreignElements.has(elem.name)) {
|
||||
opts = { ...opts, xmlMode: "foreign" };
|
||||
}
|
||||
let tag = `<${elem.name}`;
|
||||
const attribs = formatAttributes(elem.attribs, opts);
|
||||
if (attribs) {
|
||||
tag += ` ${attribs}`;
|
||||
}
|
||||
if (elem.children.length === 0 &&
|
||||
(opts.xmlMode
|
||||
? // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags
|
||||
opts.selfClosingTags !== false
|
||||
: // User explicitly asked for self-closing tags, even in HTML mode
|
||||
opts.selfClosingTags && singleTag.has(elem.name))) {
|
||||
if (!opts.xmlMode)
|
||||
tag += " ";
|
||||
tag += "/>";
|
||||
}
|
||||
else {
|
||||
tag += ">";
|
||||
if (elem.children.length > 0) {
|
||||
tag += render(elem.children, opts);
|
||||
}
|
||||
if (opts.xmlMode || !singleTag.has(elem.name)) {
|
||||
tag += `</${elem.name}>`;
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
function renderDirective(elem) {
|
||||
return `<${elem.data}>`;
|
||||
}
|
||||
function renderText(elem, opts) {
|
||||
var _a;
|
||||
let data = elem.data || "";
|
||||
// If entities weren't decoded, no need to encode them back
|
||||
if (((_a = opts.encodeEntities) !== null && _a !== void 0 ? _a : opts.decodeEntities) !== false &&
|
||||
!(!opts.xmlMode &&
|
||||
elem.parent &&
|
||||
unencodedElements.has(elem.parent.name))) {
|
||||
data =
|
||||
opts.xmlMode || opts.encodeEntities !== "utf8"
|
||||
? encodeXML(data)
|
||||
: escapeText(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
function renderCdata(elem) {
|
||||
return `<![CDATA[${elem.children[0].data}]]>`;
|
||||
}
|
||||
function renderComment(elem) {
|
||||
return `<!--${elem.data}-->`;
|
||||
}
|
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/package.json
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
3
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/foreignNames.d.ts
generated
vendored
Normal file
3
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/foreignNames.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare const elementNames: Map<string, string>;
|
||||
export declare const attributeNames: Map<string, string>;
|
||||
//# sourceMappingURL=foreignNames.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/foreignNames.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/foreignNames.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"foreignNames.d.ts","sourceRoot":"","sources":["../src/foreignNames.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,qBAsCvB,CAAC;AACH,eAAO,MAAM,cAAc,qBA4DzB,CAAC"}
|
103
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/foreignNames.js
generated
vendored
Normal file
103
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/foreignNames.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.attributeNames = exports.elementNames = void 0;
|
||||
exports.elementNames = new Map([
|
||||
["altglyph", "altGlyph"],
|
||||
["altglyphdef", "altGlyphDef"],
|
||||
["altglyphitem", "altGlyphItem"],
|
||||
["animatecolor", "animateColor"],
|
||||
["animatemotion", "animateMotion"],
|
||||
["animatetransform", "animateTransform"],
|
||||
["clippath", "clipPath"],
|
||||
["feblend", "feBlend"],
|
||||
["fecolormatrix", "feColorMatrix"],
|
||||
["fecomponenttransfer", "feComponentTransfer"],
|
||||
["fecomposite", "feComposite"],
|
||||
["feconvolvematrix", "feConvolveMatrix"],
|
||||
["fediffuselighting", "feDiffuseLighting"],
|
||||
["fedisplacementmap", "feDisplacementMap"],
|
||||
["fedistantlight", "feDistantLight"],
|
||||
["fedropshadow", "feDropShadow"],
|
||||
["feflood", "feFlood"],
|
||||
["fefunca", "feFuncA"],
|
||||
["fefuncb", "feFuncB"],
|
||||
["fefuncg", "feFuncG"],
|
||||
["fefuncr", "feFuncR"],
|
||||
["fegaussianblur", "feGaussianBlur"],
|
||||
["feimage", "feImage"],
|
||||
["femerge", "feMerge"],
|
||||
["femergenode", "feMergeNode"],
|
||||
["femorphology", "feMorphology"],
|
||||
["feoffset", "feOffset"],
|
||||
["fepointlight", "fePointLight"],
|
||||
["fespecularlighting", "feSpecularLighting"],
|
||||
["fespotlight", "feSpotLight"],
|
||||
["fetile", "feTile"],
|
||||
["feturbulence", "feTurbulence"],
|
||||
["foreignobject", "foreignObject"],
|
||||
["glyphref", "glyphRef"],
|
||||
["lineargradient", "linearGradient"],
|
||||
["radialgradient", "radialGradient"],
|
||||
["textpath", "textPath"],
|
||||
]);
|
||||
exports.attributeNames = new Map([
|
||||
["definitionurl", "definitionURL"],
|
||||
["attributename", "attributeName"],
|
||||
["attributetype", "attributeType"],
|
||||
["basefrequency", "baseFrequency"],
|
||||
["baseprofile", "baseProfile"],
|
||||
["calcmode", "calcMode"],
|
||||
["clippathunits", "clipPathUnits"],
|
||||
["diffuseconstant", "diffuseConstant"],
|
||||
["edgemode", "edgeMode"],
|
||||
["filterunits", "filterUnits"],
|
||||
["glyphref", "glyphRef"],
|
||||
["gradienttransform", "gradientTransform"],
|
||||
["gradientunits", "gradientUnits"],
|
||||
["kernelmatrix", "kernelMatrix"],
|
||||
["kernelunitlength", "kernelUnitLength"],
|
||||
["keypoints", "keyPoints"],
|
||||
["keysplines", "keySplines"],
|
||||
["keytimes", "keyTimes"],
|
||||
["lengthadjust", "lengthAdjust"],
|
||||
["limitingconeangle", "limitingConeAngle"],
|
||||
["markerheight", "markerHeight"],
|
||||
["markerunits", "markerUnits"],
|
||||
["markerwidth", "markerWidth"],
|
||||
["maskcontentunits", "maskContentUnits"],
|
||||
["maskunits", "maskUnits"],
|
||||
["numoctaves", "numOctaves"],
|
||||
["pathlength", "pathLength"],
|
||||
["patterncontentunits", "patternContentUnits"],
|
||||
["patterntransform", "patternTransform"],
|
||||
["patternunits", "patternUnits"],
|
||||
["pointsatx", "pointsAtX"],
|
||||
["pointsaty", "pointsAtY"],
|
||||
["pointsatz", "pointsAtZ"],
|
||||
["preservealpha", "preserveAlpha"],
|
||||
["preserveaspectratio", "preserveAspectRatio"],
|
||||
["primitiveunits", "primitiveUnits"],
|
||||
["refx", "refX"],
|
||||
["refy", "refY"],
|
||||
["repeatcount", "repeatCount"],
|
||||
["repeatdur", "repeatDur"],
|
||||
["requiredextensions", "requiredExtensions"],
|
||||
["requiredfeatures", "requiredFeatures"],
|
||||
["specularconstant", "specularConstant"],
|
||||
["specularexponent", "specularExponent"],
|
||||
["spreadmethod", "spreadMethod"],
|
||||
["startoffset", "startOffset"],
|
||||
["stddeviation", "stdDeviation"],
|
||||
["stitchtiles", "stitchTiles"],
|
||||
["surfacescale", "surfaceScale"],
|
||||
["systemlanguage", "systemLanguage"],
|
||||
["tablevalues", "tableValues"],
|
||||
["targetx", "targetX"],
|
||||
["targety", "targetY"],
|
||||
["textlength", "textLength"],
|
||||
["viewbox", "viewBox"],
|
||||
["viewtarget", "viewTarget"],
|
||||
["xchannelselector", "xChannelSelector"],
|
||||
["ychannelselector", "yChannelSelector"],
|
||||
["zoomandpan", "zoomAndPan"],
|
||||
]);
|
43
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/index.d.ts
generated
vendored
Normal file
43
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { Node } from "domhandler";
|
||||
export interface DomSerializerOptions {
|
||||
/**
|
||||
* Print an empty attribute's value.
|
||||
*
|
||||
* @default xmlMode
|
||||
* @example With <code>emptyAttrs: false</code>: <code><input checked></code>
|
||||
* @example With <code>emptyAttrs: true</code>: <code><input checked=""></code>
|
||||
*/
|
||||
emptyAttrs?: boolean;
|
||||
/**
|
||||
* Print self-closing tags for tags without contents.
|
||||
*
|
||||
* @default xmlMode
|
||||
* @example With <code>selfClosingTags: false</code>: <code><foo></foo></code>
|
||||
* @example With <code>selfClosingTags: true</code>: <code><foo /></code>
|
||||
*/
|
||||
selfClosingTags?: boolean;
|
||||
/**
|
||||
* Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options.
|
||||
*
|
||||
* If the value is `"foreign"`, it will try to correct mixed-case attribute names.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean | "foreign";
|
||||
/**
|
||||
* Encode characters that are either reserved in HTML or XML, or are outside of the ASCII range.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
decodeEntities?: boolean;
|
||||
}
|
||||
/**
|
||||
* Renders a DOM node or an array of DOM nodes to a string.
|
||||
*
|
||||
* Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
|
||||
*
|
||||
* @param node Node to be rendered.
|
||||
* @param options Changes serialization behavior
|
||||
*/
|
||||
export default function render(node: Node | ArrayLike<Node>, options?: DomSerializerOptions): string;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/index.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAuC,MAAM,YAAY,CAAC;AAW5E,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAqED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,EAC5B,OAAO,GAAE,oBAAyB,GACjC,MAAM,CAUR"}
|
211
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/index.js
generated
vendored
Normal file
211
book/node_modules/web-resource-inliner/node_modules/dom-serializer/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,211 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/*
|
||||
* Module dependencies
|
||||
*/
|
||||
var ElementType = __importStar(require("domelementtype"));
|
||||
var entities_1 = require("entities");
|
||||
/**
|
||||
* Mixed-case SVG and MathML tags & attributes
|
||||
* recognized by the HTML parser.
|
||||
*
|
||||
* @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
|
||||
*/
|
||||
var foreignNames_1 = require("./foreignNames");
|
||||
var unencodedElements = new Set([
|
||||
"style",
|
||||
"script",
|
||||
"xmp",
|
||||
"iframe",
|
||||
"noembed",
|
||||
"noframes",
|
||||
"plaintext",
|
||||
"noscript",
|
||||
]);
|
||||
/**
|
||||
* Format attributes
|
||||
*/
|
||||
function formatAttributes(attributes, opts) {
|
||||
if (!attributes)
|
||||
return;
|
||||
return Object.keys(attributes)
|
||||
.map(function (key) {
|
||||
var _a, _b;
|
||||
var value = (_a = attributes[key]) !== null && _a !== void 0 ? _a : "";
|
||||
if (opts.xmlMode === "foreign") {
|
||||
/* Fix up mixed-case attribute names */
|
||||
key = (_b = foreignNames_1.attributeNames.get(key)) !== null && _b !== void 0 ? _b : key;
|
||||
}
|
||||
if (!opts.emptyAttrs && !opts.xmlMode && value === "") {
|
||||
return key;
|
||||
}
|
||||
return key + "=\"" + (opts.decodeEntities !== false
|
||||
? entities_1.encodeXML(value)
|
||||
: value.replace(/"/g, """)) + "\"";
|
||||
})
|
||||
.join(" ");
|
||||
}
|
||||
/**
|
||||
* Self-enclosing tags
|
||||
*/
|
||||
var singleTag = new Set([
|
||||
"area",
|
||||
"base",
|
||||
"basefont",
|
||||
"br",
|
||||
"col",
|
||||
"command",
|
||||
"embed",
|
||||
"frame",
|
||||
"hr",
|
||||
"img",
|
||||
"input",
|
||||
"isindex",
|
||||
"keygen",
|
||||
"link",
|
||||
"meta",
|
||||
"param",
|
||||
"source",
|
||||
"track",
|
||||
"wbr",
|
||||
]);
|
||||
/**
|
||||
* Renders a DOM node or an array of DOM nodes to a string.
|
||||
*
|
||||
* Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
|
||||
*
|
||||
* @param node Node to be rendered.
|
||||
* @param options Changes serialization behavior
|
||||
*/
|
||||
function render(node, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
var nodes = "length" in node ? node : [node];
|
||||
var output = "";
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
output += renderNode(nodes[i], options);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
exports.default = render;
|
||||
function renderNode(node, options) {
|
||||
switch (node.type) {
|
||||
case ElementType.Root:
|
||||
return render(node.children, options);
|
||||
case ElementType.Directive:
|
||||
case ElementType.Doctype:
|
||||
return renderDirective(node);
|
||||
case ElementType.Comment:
|
||||
return renderComment(node);
|
||||
case ElementType.CDATA:
|
||||
return renderCdata(node);
|
||||
case ElementType.Script:
|
||||
case ElementType.Style:
|
||||
case ElementType.Tag:
|
||||
return renderTag(node, options);
|
||||
case ElementType.Text:
|
||||
return renderText(node, options);
|
||||
}
|
||||
}
|
||||
var foreignModeIntegrationPoints = new Set([
|
||||
"mi",
|
||||
"mo",
|
||||
"mn",
|
||||
"ms",
|
||||
"mtext",
|
||||
"annotation-xml",
|
||||
"foreignObject",
|
||||
"desc",
|
||||
"title",
|
||||
]);
|
||||
var foreignElements = new Set(["svg", "math"]);
|
||||
function renderTag(elem, opts) {
|
||||
var _a;
|
||||
// Handle SVG / MathML in HTML
|
||||
if (opts.xmlMode === "foreign") {
|
||||
/* Fix up mixed-case element names */
|
||||
elem.name = (_a = foreignNames_1.elementNames.get(elem.name)) !== null && _a !== void 0 ? _a : elem.name;
|
||||
/* Exit foreign mode at integration points */
|
||||
if (elem.parent &&
|
||||
foreignModeIntegrationPoints.has(elem.parent.name)) {
|
||||
opts = __assign(__assign({}, opts), { xmlMode: false });
|
||||
}
|
||||
}
|
||||
if (!opts.xmlMode && foreignElements.has(elem.name)) {
|
||||
opts = __assign(__assign({}, opts), { xmlMode: "foreign" });
|
||||
}
|
||||
var tag = "<" + elem.name;
|
||||
var attribs = formatAttributes(elem.attribs, opts);
|
||||
if (attribs) {
|
||||
tag += " " + attribs;
|
||||
}
|
||||
if (elem.children.length === 0 &&
|
||||
(opts.xmlMode
|
||||
? // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags
|
||||
opts.selfClosingTags !== false
|
||||
: // User explicitly asked for self-closing tags, even in HTML mode
|
||||
opts.selfClosingTags && singleTag.has(elem.name))) {
|
||||
if (!opts.xmlMode)
|
||||
tag += " ";
|
||||
tag += "/>";
|
||||
}
|
||||
else {
|
||||
tag += ">";
|
||||
if (elem.children.length > 0) {
|
||||
tag += render(elem.children, opts);
|
||||
}
|
||||
if (opts.xmlMode || !singleTag.has(elem.name)) {
|
||||
tag += "</" + elem.name + ">";
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
function renderDirective(elem) {
|
||||
return "<" + elem.data + ">";
|
||||
}
|
||||
function renderText(elem, opts) {
|
||||
var data = elem.data || "";
|
||||
// If entities weren't decoded, no need to encode them back
|
||||
if (opts.decodeEntities !== false &&
|
||||
!(!opts.xmlMode &&
|
||||
elem.parent &&
|
||||
unencodedElements.has(elem.parent.name))) {
|
||||
data = entities_1.encodeXML(data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
function renderCdata(elem) {
|
||||
return "<![CDATA[" + elem.children[0].data + "]]>";
|
||||
}
|
||||
function renderComment(elem) {
|
||||
return "<!--" + elem.data + "-->";
|
||||
}
|
11
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/LICENSE
generated
vendored
Normal file
11
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
Copyright (c) Felix Böhm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
85
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/index.d.ts
generated
vendored
Normal file
85
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { Node, Element, DataNode, NodeWithChildren, Document } from "./node";
|
||||
export * from "./node";
|
||||
export interface DomHandlerOptions {
|
||||
/**
|
||||
* Add a `startIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
||||
* indicating the position of the start of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withStartIndices?: boolean;
|
||||
/**
|
||||
* Add an `endIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
||||
* indicating the position of the end of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withEndIndices?: boolean;
|
||||
/**
|
||||
* Replace all whitespace with single spaces.
|
||||
*
|
||||
* **Note:** Enabling this might break your markup.
|
||||
*
|
||||
* @default false
|
||||
* @deprecated
|
||||
*/
|
||||
normalizeWhitespace?: boolean;
|
||||
/**
|
||||
* Treat the markup as XML.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean;
|
||||
}
|
||||
interface ParserInterface {
|
||||
startIndex: number | null;
|
||||
endIndex: number | null;
|
||||
}
|
||||
declare type Callback = (error: Error | null, dom: Node[]) => void;
|
||||
declare type ElementCallback = (element: Element) => void;
|
||||
export declare class DomHandler {
|
||||
/** The elements of the DOM */
|
||||
dom: Node[];
|
||||
/** The root element for the DOM */
|
||||
root: Document;
|
||||
/** Called once parsing has completed. */
|
||||
private readonly callback;
|
||||
/** Settings for the handler. */
|
||||
private readonly options;
|
||||
/** Callback whenever a tag is closed. */
|
||||
private readonly elementCB;
|
||||
/** Indicated whether parsing has been completed. */
|
||||
private done;
|
||||
/** Stack of open tags. */
|
||||
protected tagStack: NodeWithChildren[];
|
||||
/** A data node that is still being written to. */
|
||||
protected lastNode: DataNode | null;
|
||||
/** Reference to the parser instance. Used for location information. */
|
||||
private parser;
|
||||
/**
|
||||
* @param callback Called once parsing has completed.
|
||||
* @param options Settings for the handler.
|
||||
* @param elementCB Callback whenever a tag is closed.
|
||||
*/
|
||||
constructor(callback?: Callback | null, options?: DomHandlerOptions | null, elementCB?: ElementCallback);
|
||||
onparserinit(parser: ParserInterface): void;
|
||||
onreset(): void;
|
||||
onend(): void;
|
||||
onerror(error: Error): void;
|
||||
onclosetag(): void;
|
||||
onopentag(name: string, attribs: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
ontext(data: string): void;
|
||||
oncomment(data: string): void;
|
||||
oncommentend(): void;
|
||||
oncdatastart(): void;
|
||||
oncdataend(): void;
|
||||
onprocessinginstruction(name: string, data: string): void;
|
||||
protected handleCallback(error: Error | null): void;
|
||||
protected addNode(node: Node): void;
|
||||
}
|
||||
export default DomHandler;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/index.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,IAAI,EACJ,OAAO,EACP,QAAQ,EAGR,gBAAgB,EAChB,QAAQ,EAEX,MAAM,QAAQ,CAAC;AAEhB,cAAc,QAAQ,CAAC;AAIvB,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAUD,UAAU,eAAe;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,aAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;AAC3D,aAAK,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAElD,qBAAa,UAAU;IACnB,8BAA8B;IACvB,GAAG,EAAE,IAAI,EAAE,CAAM;IAExB,mCAAmC;IAC5B,IAAI,WAA0B;IAErC,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAE3C,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAE5C,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IAEnD,oDAAoD;IACpD,OAAO,CAAC,IAAI,CAAS;IAErB,0BAA0B;IAC1B,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,CAAe;IAErD,kDAAkD;IAClD,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAQ;IAE3C,uEAAuE;IACvE,OAAO,CAAC,MAAM,CAAgC;IAE9C;;;;OAIG;gBAEC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,EAC1B,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAClC,SAAS,CAAC,EAAE,eAAe;IAiBxB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAK3C,OAAO,IAAI,IAAI;IAUf,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAI3B,UAAU,IAAI,IAAI;IAYlB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI;IAOjE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA2B1B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAW7B,YAAY,IAAI,IAAI;IAIpB,YAAY,IAAI,IAAI;IAUpB,UAAU,IAAI,IAAI;IAIlB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAKhE,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAQnD,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAwBtC;AAED,eAAe,UAAU,CAAC"}
|
176
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/index.js
generated
vendored
Normal file
176
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DomHandler = void 0;
|
||||
var domelementtype_1 = require("domelementtype");
|
||||
var node_1 = require("./node");
|
||||
__exportStar(require("./node"), exports);
|
||||
var reWhitespace = /\s+/g;
|
||||
// Default options
|
||||
var defaultOpts = {
|
||||
normalizeWhitespace: false,
|
||||
withStartIndices: false,
|
||||
withEndIndices: false,
|
||||
xmlMode: false,
|
||||
};
|
||||
var DomHandler = /** @class */ (function () {
|
||||
/**
|
||||
* @param callback Called once parsing has completed.
|
||||
* @param options Settings for the handler.
|
||||
* @param elementCB Callback whenever a tag is closed.
|
||||
*/
|
||||
function DomHandler(callback, options, elementCB) {
|
||||
/** The elements of the DOM */
|
||||
this.dom = [];
|
||||
/** The root element for the DOM */
|
||||
this.root = new node_1.Document(this.dom);
|
||||
/** Indicated whether parsing has been completed. */
|
||||
this.done = false;
|
||||
/** Stack of open tags. */
|
||||
this.tagStack = [this.root];
|
||||
/** A data node that is still being written to. */
|
||||
this.lastNode = null;
|
||||
/** Reference to the parser instance. Used for location information. */
|
||||
this.parser = null;
|
||||
// Make it possible to skip arguments, for backwards-compatibility
|
||||
if (typeof options === "function") {
|
||||
elementCB = options;
|
||||
options = defaultOpts;
|
||||
}
|
||||
if (typeof callback === "object") {
|
||||
options = callback;
|
||||
callback = undefined;
|
||||
}
|
||||
this.callback = callback !== null && callback !== void 0 ? callback : null;
|
||||
this.options = options !== null && options !== void 0 ? options : defaultOpts;
|
||||
this.elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
|
||||
}
|
||||
DomHandler.prototype.onparserinit = function (parser) {
|
||||
this.parser = parser;
|
||||
};
|
||||
// Resets the handler back to starting state
|
||||
DomHandler.prototype.onreset = function () {
|
||||
this.dom = [];
|
||||
this.root = new node_1.Document(this.dom);
|
||||
this.done = false;
|
||||
this.tagStack = [this.root];
|
||||
this.lastNode = null;
|
||||
this.parser = null;
|
||||
};
|
||||
// Signals the handler that parsing is done
|
||||
DomHandler.prototype.onend = function () {
|
||||
if (this.done)
|
||||
return;
|
||||
this.done = true;
|
||||
this.parser = null;
|
||||
this.handleCallback(null);
|
||||
};
|
||||
DomHandler.prototype.onerror = function (error) {
|
||||
this.handleCallback(error);
|
||||
};
|
||||
DomHandler.prototype.onclosetag = function () {
|
||||
this.lastNode = null;
|
||||
var elem = this.tagStack.pop();
|
||||
if (this.options.withEndIndices) {
|
||||
elem.endIndex = this.parser.endIndex;
|
||||
}
|
||||
if (this.elementCB)
|
||||
this.elementCB(elem);
|
||||
};
|
||||
DomHandler.prototype.onopentag = function (name, attribs) {
|
||||
var type = this.options.xmlMode ? domelementtype_1.ElementType.Tag : undefined;
|
||||
var element = new node_1.Element(name, attribs, undefined, type);
|
||||
this.addNode(element);
|
||||
this.tagStack.push(element);
|
||||
};
|
||||
DomHandler.prototype.ontext = function (data) {
|
||||
var normalizeWhitespace = this.options.normalizeWhitespace;
|
||||
var lastNode = this.lastNode;
|
||||
if (lastNode && lastNode.type === domelementtype_1.ElementType.Text) {
|
||||
if (normalizeWhitespace) {
|
||||
lastNode.data = (lastNode.data + data).replace(reWhitespace, " ");
|
||||
}
|
||||
else {
|
||||
lastNode.data += data;
|
||||
}
|
||||
if (this.options.withEndIndices) {
|
||||
lastNode.endIndex = this.parser.endIndex;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (normalizeWhitespace) {
|
||||
data = data.replace(reWhitespace, " ");
|
||||
}
|
||||
var node = new node_1.Text(data);
|
||||
this.addNode(node);
|
||||
this.lastNode = node;
|
||||
}
|
||||
};
|
||||
DomHandler.prototype.oncomment = function (data) {
|
||||
if (this.lastNode && this.lastNode.type === domelementtype_1.ElementType.Comment) {
|
||||
this.lastNode.data += data;
|
||||
return;
|
||||
}
|
||||
var node = new node_1.Comment(data);
|
||||
this.addNode(node);
|
||||
this.lastNode = node;
|
||||
};
|
||||
DomHandler.prototype.oncommentend = function () {
|
||||
this.lastNode = null;
|
||||
};
|
||||
DomHandler.prototype.oncdatastart = function () {
|
||||
var text = new node_1.Text("");
|
||||
var node = new node_1.NodeWithChildren(domelementtype_1.ElementType.CDATA, [text]);
|
||||
this.addNode(node);
|
||||
text.parent = node;
|
||||
this.lastNode = text;
|
||||
};
|
||||
DomHandler.prototype.oncdataend = function () {
|
||||
this.lastNode = null;
|
||||
};
|
||||
DomHandler.prototype.onprocessinginstruction = function (name, data) {
|
||||
var node = new node_1.ProcessingInstruction(name, data);
|
||||
this.addNode(node);
|
||||
};
|
||||
DomHandler.prototype.handleCallback = function (error) {
|
||||
if (typeof this.callback === "function") {
|
||||
this.callback(error, this.dom);
|
||||
}
|
||||
else if (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
DomHandler.prototype.addNode = function (node) {
|
||||
var parent = this.tagStack[this.tagStack.length - 1];
|
||||
var previousSibling = parent.children[parent.children.length - 1];
|
||||
if (this.options.withStartIndices) {
|
||||
node.startIndex = this.parser.startIndex;
|
||||
}
|
||||
if (this.options.withEndIndices) {
|
||||
node.endIndex = this.parser.endIndex;
|
||||
}
|
||||
parent.children.push(node);
|
||||
if (previousSibling) {
|
||||
node.prev = previousSibling;
|
||||
previousSibling.next = node;
|
||||
}
|
||||
node.parent = parent;
|
||||
this.lastNode = null;
|
||||
};
|
||||
return DomHandler;
|
||||
}());
|
||||
exports.DomHandler = DomHandler;
|
||||
exports.default = DomHandler;
|
237
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/node.d.ts
generated
vendored
Normal file
237
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
import { ElementType } from "domelementtype";
|
||||
interface SourceCodeLocation {
|
||||
/** One-based line index of the first character. */
|
||||
startLine: number;
|
||||
/** One-based column index of the first character. */
|
||||
startCol: number;
|
||||
/** Zero-based first character index. */
|
||||
startOffset: number;
|
||||
/** One-based line index of the last character. */
|
||||
endLine: number;
|
||||
/** One-based column index of the last character. Points directly *after* the last character. */
|
||||
endCol: number;
|
||||
/** Zero-based last character index. Points directly *after* the last character. */
|
||||
endOffset: number;
|
||||
}
|
||||
interface TagSourceCodeLocation extends SourceCodeLocation {
|
||||
startTag?: SourceCodeLocation;
|
||||
endTag?: SourceCodeLocation;
|
||||
}
|
||||
/**
|
||||
* This object will be used as the prototype for Nodes when creating a
|
||||
* DOM-Level-1-compliant structure.
|
||||
*/
|
||||
export declare class Node {
|
||||
type: ElementType;
|
||||
/** Parent of the node */
|
||||
parent: NodeWithChildren | null;
|
||||
/** Previous sibling */
|
||||
prev: Node | null;
|
||||
/** Next sibling */
|
||||
next: Node | null;
|
||||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
||||
startIndex: number | null;
|
||||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
||||
endIndex: number | null;
|
||||
/**
|
||||
* `parse5` source code location info.
|
||||
*
|
||||
* Available if parsing with parse5 and location info is enabled.
|
||||
*/
|
||||
sourceCodeLocation?: SourceCodeLocation | null;
|
||||
/**
|
||||
*
|
||||
* @param type The type of the node.
|
||||
*/
|
||||
constructor(type: ElementType);
|
||||
/**
|
||||
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
||||
* node {@link type}.
|
||||
*/
|
||||
get nodeType(): number;
|
||||
/**
|
||||
* Same as {@link parent}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get parentNode(): NodeWithChildren | null;
|
||||
set parentNode(parent: NodeWithChildren | null);
|
||||
/**
|
||||
* Same as {@link prev}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get previousSibling(): Node | null;
|
||||
set previousSibling(prev: Node | null);
|
||||
/**
|
||||
* Same as {@link next}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get nextSibling(): Node | null;
|
||||
set nextSibling(next: Node | null);
|
||||
/**
|
||||
* Clone this node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
||||
}
|
||||
/**
|
||||
* A node that contains some data.
|
||||
*/
|
||||
export declare class DataNode extends Node {
|
||||
data: string;
|
||||
/**
|
||||
* @param type The type of the node
|
||||
* @param data The content of the data node
|
||||
*/
|
||||
constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
|
||||
/**
|
||||
* Same as {@link data}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get nodeValue(): string;
|
||||
set nodeValue(data: string);
|
||||
}
|
||||
/**
|
||||
* Text within the document.
|
||||
*/
|
||||
export declare class Text extends DataNode {
|
||||
constructor(data: string);
|
||||
}
|
||||
/**
|
||||
* Comments within the document.
|
||||
*/
|
||||
export declare class Comment extends DataNode {
|
||||
constructor(data: string);
|
||||
}
|
||||
/**
|
||||
* Processing instructions, including doc types.
|
||||
*/
|
||||
export declare class ProcessingInstruction extends DataNode {
|
||||
name: string;
|
||||
constructor(name: string, data: string);
|
||||
/** If this is a doctype, the document type name (parse5 only). */
|
||||
"x-name"?: string;
|
||||
/** If this is a doctype, the document type public identifier (parse5 only). */
|
||||
"x-publicId"?: string;
|
||||
/** If this is a doctype, the document type system identifier (parse5 only). */
|
||||
"x-systemId"?: string;
|
||||
}
|
||||
/**
|
||||
* A `Node` that can have children.
|
||||
*/
|
||||
export declare class NodeWithChildren extends Node {
|
||||
children: Node[];
|
||||
/**
|
||||
* @param type Type of the node.
|
||||
* @param children Children of the node. Only certain node types can have children.
|
||||
*/
|
||||
constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
|
||||
/** First child of the node. */
|
||||
get firstChild(): Node | null;
|
||||
/** Last child of the node. */
|
||||
get lastChild(): Node | null;
|
||||
/**
|
||||
* Same as {@link children}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get childNodes(): Node[];
|
||||
set childNodes(children: Node[]);
|
||||
}
|
||||
/**
|
||||
* The root node of the document.
|
||||
*/
|
||||
export declare class Document extends NodeWithChildren {
|
||||
constructor(children: Node[]);
|
||||
/** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
|
||||
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
||||
}
|
||||
/**
|
||||
* The description of an individual attribute.
|
||||
*/
|
||||
interface Attribute {
|
||||
name: string;
|
||||
value: string;
|
||||
namespace?: string;
|
||||
prefix?: string;
|
||||
}
|
||||
/**
|
||||
* An element within the DOM.
|
||||
*/
|
||||
export declare class Element extends NodeWithChildren {
|
||||
name: string;
|
||||
attribs: {
|
||||
[name: string]: string;
|
||||
};
|
||||
/**
|
||||
* @param name Name of the tag, eg. `div`, `span`.
|
||||
* @param attribs Object mapping attribute names to attribute values.
|
||||
* @param children Children of the node.
|
||||
*/
|
||||
constructor(name: string, attribs: {
|
||||
[name: string]: string;
|
||||
}, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
||||
/**
|
||||
* `parse5` source code location info, with start & end tags.
|
||||
*
|
||||
* Available if parsing with parse5 and location info is enabled.
|
||||
*/
|
||||
sourceCodeLocation?: TagSourceCodeLocation | null;
|
||||
/**
|
||||
* Same as {@link name}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get tagName(): string;
|
||||
set tagName(name: string);
|
||||
get attributes(): Attribute[];
|
||||
/** Element namespace (parse5 only). */
|
||||
namespace?: string;
|
||||
/** Element attribute namespaces (parse5 only). */
|
||||
"x-attribsNamespace"?: Record<string, string>;
|
||||
/** Element attribute namespace-related prefixes (parse5 only). */
|
||||
"x-attribsPrefix"?: Record<string, string>;
|
||||
}
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `Element`, `false` otherwise.
|
||||
*/
|
||||
export declare function isTag(node: Node): node is Element;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
||||
*/
|
||||
export declare function isCDATA(node: Node): node is NodeWithChildren;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
||||
*/
|
||||
export declare function isText(node: Node): node is Text;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
||||
*/
|
||||
export declare function isComment(node: Node): node is DataNode;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
export declare function isDirective(node: Node): node is ProcessingInstruction;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
export declare function isDocument(node: Node): node is Document;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
|
||||
*/
|
||||
export declare function hasChildren(node: Node): node is NodeWithChildren;
|
||||
/**
|
||||
* Clone a node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
|
||||
export {};
|
||||
//# sourceMappingURL=node.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/node.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/node.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,gBAAgB,CAAC;AAahE,UAAU,kBAAkB;IACxB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,qBAAsB,SAAQ,kBAAkB;IACtD,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED;;;GAGG;AACH,qBAAa,IAAI;IA2BM,IAAI,EAAE,WAAW;IA1BpC,yBAAyB;IACzB,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IAEvC,uBAAuB;IACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEzB,mBAAmB;IACnB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEzB,2FAA2F;IAC3F,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEjC,uFAAuF;IACvF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAE/C;;;OAGG;gBACgB,IAAI,EAAE,WAAW;IAIpC;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAID;;;OAGG;IACH,IAAI,UAAU,IAAI,gBAAgB,GAAG,IAAI,CAExC;IAED,IAAI,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,EAE7C;IAED;;;OAGG;IACH,IAAI,eAAe,IAAI,IAAI,GAAG,IAAI,CAEjC;IAED,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAEpC;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,IAAI,GAAG,IAAI,CAE7B;IAED,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAEhC;IAED;;;;;OAKG;IACH,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,UAAQ,GAAG,CAAC;CAG3D;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,IAAI;IAOnB,IAAI,EAAE,MAAM;IANvB;;;OAGG;gBAEC,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,EAC7D,IAAI,EAAE,MAAM;IAKvB;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,SAAS,CAAC,IAAI,EAAE,MAAM,EAEzB;CACJ;AAED;;GAEG;AACH,qBAAa,IAAK,SAAQ,QAAQ;gBAClB,IAAI,EAAE,MAAM;CAG3B;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,QAAQ;gBACrB,IAAI,EAAE,MAAM;CAG3B;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,QAAQ;IAC5B,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAI7C,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,IAAI;IAY3B,QAAQ,EAAE,IAAI,EAAE;IAX3B;;;OAGG;gBAEC,IAAI,EACE,WAAW,CAAC,IAAI,GAChB,WAAW,CAAC,KAAK,GACjB,WAAW,CAAC,MAAM,GAClB,WAAW,CAAC,KAAK,GACjB,WAAW,CAAC,GAAG,EACd,QAAQ,EAAE,IAAI,EAAE;IAM3B,+BAA+B;IAC/B,IAAI,UAAU,IAAI,IAAI,GAAG,IAAI,CAE5B;IAED,8BAA8B;IAC9B,IAAI,SAAS,IAAI,IAAI,GAAG,IAAI,CAI3B;IAED;;;OAGG;IACH,IAAI,UAAU,IAAI,IAAI,EAAE,CAEvB;IAED,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,EAE9B;CACJ;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,gBAAgB;gBAC9B,QAAQ,EAAE,IAAI,EAAE;IAI5B,mGAAmG;IACnG,QAAQ,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,gBAAgB,CAAC;CACxD;AAED;;GAEG;AACH,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,gBAAgB;IAO9B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAP9C;;;;OAIG;gBAEQ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAC1C,QAAQ,GAAE,IAAI,EAAO,EACrB,IAAI,GACE,WAAW,CAAC,GAAG,GACf,WAAW,CAAC,MAAM,GAClB,WAAW,CAAC,KAIG;IAKzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAIlD;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,EAEvB;IAED,IAAI,UAAU,IAAI,SAAS,EAAE,CAO5B;IAED,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,OAAO,CAEjD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,gBAAgB,CAE5D;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,CAE/C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,QAAQ,CAEtD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,qBAAqB,CAErE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,QAAQ,CAEvD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,gBAAgB,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,UAAQ,GAAG,CAAC,CA4DvE"}
|
444
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/node.js
generated
vendored
Normal file
444
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/lib/node.js
generated
vendored
Normal file
@@ -0,0 +1,444 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cloneNode = exports.hasChildren = exports.isDocument = exports.isDirective = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = exports.Element = exports.Document = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;
|
||||
var domelementtype_1 = require("domelementtype");
|
||||
var nodeTypes = new Map([
|
||||
[domelementtype_1.ElementType.Tag, 1],
|
||||
[domelementtype_1.ElementType.Script, 1],
|
||||
[domelementtype_1.ElementType.Style, 1],
|
||||
[domelementtype_1.ElementType.Directive, 1],
|
||||
[domelementtype_1.ElementType.Text, 3],
|
||||
[domelementtype_1.ElementType.CDATA, 4],
|
||||
[domelementtype_1.ElementType.Comment, 8],
|
||||
[domelementtype_1.ElementType.Root, 9],
|
||||
]);
|
||||
/**
|
||||
* This object will be used as the prototype for Nodes when creating a
|
||||
* DOM-Level-1-compliant structure.
|
||||
*/
|
||||
var Node = /** @class */ (function () {
|
||||
/**
|
||||
*
|
||||
* @param type The type of the node.
|
||||
*/
|
||||
function Node(type) {
|
||||
this.type = type;
|
||||
/** Parent of the node */
|
||||
this.parent = null;
|
||||
/** Previous sibling */
|
||||
this.prev = null;
|
||||
/** Next sibling */
|
||||
this.next = null;
|
||||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
||||
this.startIndex = null;
|
||||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
||||
this.endIndex = null;
|
||||
}
|
||||
Object.defineProperty(Node.prototype, "nodeType", {
|
||||
// Read-only aliases
|
||||
/**
|
||||
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
||||
* node {@link type}.
|
||||
*/
|
||||
get: function () {
|
||||
var _a;
|
||||
return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "parentNode", {
|
||||
// Read-write aliases for properties
|
||||
/**
|
||||
* Same as {@link parent}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.parent;
|
||||
},
|
||||
set: function (parent) {
|
||||
this.parent = parent;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "previousSibling", {
|
||||
/**
|
||||
* Same as {@link prev}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.prev;
|
||||
},
|
||||
set: function (prev) {
|
||||
this.prev = prev;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "nextSibling", {
|
||||
/**
|
||||
* Same as {@link next}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.next;
|
||||
},
|
||||
set: function (next) {
|
||||
this.next = next;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/**
|
||||
* Clone this node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
Node.prototype.cloneNode = function (recursive) {
|
||||
if (recursive === void 0) { recursive = false; }
|
||||
return cloneNode(this, recursive);
|
||||
};
|
||||
return Node;
|
||||
}());
|
||||
exports.Node = Node;
|
||||
/**
|
||||
* A node that contains some data.
|
||||
*/
|
||||
var DataNode = /** @class */ (function (_super) {
|
||||
__extends(DataNode, _super);
|
||||
/**
|
||||
* @param type The type of the node
|
||||
* @param data The content of the data node
|
||||
*/
|
||||
function DataNode(type, data) {
|
||||
var _this = _super.call(this, type) || this;
|
||||
_this.data = data;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(DataNode.prototype, "nodeValue", {
|
||||
/**
|
||||
* Same as {@link data}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.data;
|
||||
},
|
||||
set: function (data) {
|
||||
this.data = data;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return DataNode;
|
||||
}(Node));
|
||||
exports.DataNode = DataNode;
|
||||
/**
|
||||
* Text within the document.
|
||||
*/
|
||||
var Text = /** @class */ (function (_super) {
|
||||
__extends(Text, _super);
|
||||
function Text(data) {
|
||||
return _super.call(this, domelementtype_1.ElementType.Text, data) || this;
|
||||
}
|
||||
return Text;
|
||||
}(DataNode));
|
||||
exports.Text = Text;
|
||||
/**
|
||||
* Comments within the document.
|
||||
*/
|
||||
var Comment = /** @class */ (function (_super) {
|
||||
__extends(Comment, _super);
|
||||
function Comment(data) {
|
||||
return _super.call(this, domelementtype_1.ElementType.Comment, data) || this;
|
||||
}
|
||||
return Comment;
|
||||
}(DataNode));
|
||||
exports.Comment = Comment;
|
||||
/**
|
||||
* Processing instructions, including doc types.
|
||||
*/
|
||||
var ProcessingInstruction = /** @class */ (function (_super) {
|
||||
__extends(ProcessingInstruction, _super);
|
||||
function ProcessingInstruction(name, data) {
|
||||
var _this = _super.call(this, domelementtype_1.ElementType.Directive, data) || this;
|
||||
_this.name = name;
|
||||
return _this;
|
||||
}
|
||||
return ProcessingInstruction;
|
||||
}(DataNode));
|
||||
exports.ProcessingInstruction = ProcessingInstruction;
|
||||
/**
|
||||
* A `Node` that can have children.
|
||||
*/
|
||||
var NodeWithChildren = /** @class */ (function (_super) {
|
||||
__extends(NodeWithChildren, _super);
|
||||
/**
|
||||
* @param type Type of the node.
|
||||
* @param children Children of the node. Only certain node types can have children.
|
||||
*/
|
||||
function NodeWithChildren(type, children) {
|
||||
var _this = _super.call(this, type) || this;
|
||||
_this.children = children;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
|
||||
// Aliases
|
||||
/** First child of the node. */
|
||||
get: function () {
|
||||
var _a;
|
||||
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
|
||||
/** Last child of the node. */
|
||||
get: function () {
|
||||
return this.children.length > 0
|
||||
? this.children[this.children.length - 1]
|
||||
: null;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
|
||||
/**
|
||||
* Same as {@link children}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.children;
|
||||
},
|
||||
set: function (children) {
|
||||
this.children = children;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return NodeWithChildren;
|
||||
}(Node));
|
||||
exports.NodeWithChildren = NodeWithChildren;
|
||||
/**
|
||||
* The root node of the document.
|
||||
*/
|
||||
var Document = /** @class */ (function (_super) {
|
||||
__extends(Document, _super);
|
||||
function Document(children) {
|
||||
return _super.call(this, domelementtype_1.ElementType.Root, children) || this;
|
||||
}
|
||||
return Document;
|
||||
}(NodeWithChildren));
|
||||
exports.Document = Document;
|
||||
/**
|
||||
* An element within the DOM.
|
||||
*/
|
||||
var Element = /** @class */ (function (_super) {
|
||||
__extends(Element, _super);
|
||||
/**
|
||||
* @param name Name of the tag, eg. `div`, `span`.
|
||||
* @param attribs Object mapping attribute names to attribute values.
|
||||
* @param children Children of the node.
|
||||
*/
|
||||
function Element(name, attribs, children, type) {
|
||||
if (children === void 0) { children = []; }
|
||||
if (type === void 0) { type = name === "script"
|
||||
? domelementtype_1.ElementType.Script
|
||||
: name === "style"
|
||||
? domelementtype_1.ElementType.Style
|
||||
: domelementtype_1.ElementType.Tag; }
|
||||
var _this = _super.call(this, type, children) || this;
|
||||
_this.name = name;
|
||||
_this.attribs = attribs;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(Element.prototype, "tagName", {
|
||||
// DOM Level 1 aliases
|
||||
/**
|
||||
* Same as {@link name}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.name;
|
||||
},
|
||||
set: function (name) {
|
||||
this.name = name;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Element.prototype, "attributes", {
|
||||
get: function () {
|
||||
var _this = this;
|
||||
return Object.keys(this.attribs).map(function (name) {
|
||||
var _a, _b;
|
||||
return ({
|
||||
name: name,
|
||||
value: _this.attribs[name],
|
||||
namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
|
||||
prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
|
||||
});
|
||||
});
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return Element;
|
||||
}(NodeWithChildren));
|
||||
exports.Element = Element;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `Element`, `false` otherwise.
|
||||
*/
|
||||
function isTag(node) {
|
||||
return (0, domelementtype_1.isTag)(node);
|
||||
}
|
||||
exports.isTag = isTag;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
||||
*/
|
||||
function isCDATA(node) {
|
||||
return node.type === domelementtype_1.ElementType.CDATA;
|
||||
}
|
||||
exports.isCDATA = isCDATA;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
||||
*/
|
||||
function isText(node) {
|
||||
return node.type === domelementtype_1.ElementType.Text;
|
||||
}
|
||||
exports.isText = isText;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
||||
*/
|
||||
function isComment(node) {
|
||||
return node.type === domelementtype_1.ElementType.Comment;
|
||||
}
|
||||
exports.isComment = isComment;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
function isDirective(node) {
|
||||
return node.type === domelementtype_1.ElementType.Directive;
|
||||
}
|
||||
exports.isDirective = isDirective;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
function isDocument(node) {
|
||||
return node.type === domelementtype_1.ElementType.Root;
|
||||
}
|
||||
exports.isDocument = isDocument;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
|
||||
*/
|
||||
function hasChildren(node) {
|
||||
return Object.prototype.hasOwnProperty.call(node, "children");
|
||||
}
|
||||
exports.hasChildren = hasChildren;
|
||||
/**
|
||||
* Clone a node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
function cloneNode(node, recursive) {
|
||||
if (recursive === void 0) { recursive = false; }
|
||||
var result;
|
||||
if (isText(node)) {
|
||||
result = new Text(node.data);
|
||||
}
|
||||
else if (isComment(node)) {
|
||||
result = new Comment(node.data);
|
||||
}
|
||||
else if (isTag(node)) {
|
||||
var children = recursive ? cloneChildren(node.children) : [];
|
||||
var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
|
||||
children.forEach(function (child) { return (child.parent = clone_1); });
|
||||
if (node.namespace != null) {
|
||||
clone_1.namespace = node.namespace;
|
||||
}
|
||||
if (node["x-attribsNamespace"]) {
|
||||
clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
|
||||
}
|
||||
if (node["x-attribsPrefix"]) {
|
||||
clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
|
||||
}
|
||||
result = clone_1;
|
||||
}
|
||||
else if (isCDATA(node)) {
|
||||
var children = recursive ? cloneChildren(node.children) : [];
|
||||
var clone_2 = new NodeWithChildren(domelementtype_1.ElementType.CDATA, children);
|
||||
children.forEach(function (child) { return (child.parent = clone_2); });
|
||||
result = clone_2;
|
||||
}
|
||||
else if (isDocument(node)) {
|
||||
var children = recursive ? cloneChildren(node.children) : [];
|
||||
var clone_3 = new Document(children);
|
||||
children.forEach(function (child) { return (child.parent = clone_3); });
|
||||
if (node["x-mode"]) {
|
||||
clone_3["x-mode"] = node["x-mode"];
|
||||
}
|
||||
result = clone_3;
|
||||
}
|
||||
else if (isDirective(node)) {
|
||||
var instruction = new ProcessingInstruction(node.name, node.data);
|
||||
if (node["x-name"] != null) {
|
||||
instruction["x-name"] = node["x-name"];
|
||||
instruction["x-publicId"] = node["x-publicId"];
|
||||
instruction["x-systemId"] = node["x-systemId"];
|
||||
}
|
||||
result = instruction;
|
||||
}
|
||||
else {
|
||||
throw new Error("Not implemented yet: ".concat(node.type));
|
||||
}
|
||||
result.startIndex = node.startIndex;
|
||||
result.endIndex = node.endIndex;
|
||||
if (node.sourceCodeLocation != null) {
|
||||
result.sourceCodeLocation = node.sourceCodeLocation;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.cloneNode = cloneNode;
|
||||
function cloneChildren(childs) {
|
||||
var children = childs.map(function (child) { return cloneNode(child, true); });
|
||||
for (var i = 1; i < children.length; i++) {
|
||||
children[i].prev = children[i - 1];
|
||||
children[i - 1].next = children[i];
|
||||
}
|
||||
return children;
|
||||
}
|
58
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/package.json
generated
vendored
Normal file
58
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "domhandler",
|
||||
"version": "4.3.1",
|
||||
"description": "Handler for htmlparser2 that turns pages into a dom",
|
||||
"author": "Felix Boehm <me@feedic.com>",
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domhandler?sponsor=1"
|
||||
},
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run test:jest && npm run lint",
|
||||
"test:jest": "jest",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write '**/*.{ts,md,json}'",
|
||||
"build": "tsc",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/fb55/domhandler.git"
|
||||
},
|
||||
"keywords": [
|
||||
"dom",
|
||||
"htmlparser2"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/node": "^17.0.21",
|
||||
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
||||
"@typescript-eslint/parser": "^5.15.0",
|
||||
"eslint": "^8.11.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"htmlparser2": "^7.2.0",
|
||||
"jest": "^27.5.1",
|
||||
"prettier": "^2.6.0",
|
||||
"ts-jest": "^27.1.3",
|
||||
"typescript": "^4.6.2"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 4
|
||||
}
|
||||
}
|
163
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/readme.md
generated
vendored
Normal file
163
book/node_modules/web-resource-inliner/node_modules/dom-serializer/node_modules/domhandler/readme.md
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
# domhandler [](https://travis-ci.com/fb55/domhandler)
|
||||
|
||||
The DOM handler creates a tree containing all nodes of a page.
|
||||
The tree can be manipulated using the [domutils](https://github.com/fb55/domutils)
|
||||
or [cheerio](https://github.com/cheeriojs/cheerio) libraries and
|
||||
rendered using [dom-serializer](https://github.com/cheeriojs/dom-serializer) .
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
const handler = new DomHandler([ <func> callback(err, dom), ] [ <obj> options ]);
|
||||
// const parser = new Parser(handler[, options]);
|
||||
```
|
||||
|
||||
Available options are described below.
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
const { Parser } = require("htmlparser2");
|
||||
const { DomHandler } = require("domhandler");
|
||||
const rawHtml =
|
||||
"Xyz <script language= javascript>var foo = '<<bar>>';</script><!--<!-- Waah! -- -->";
|
||||
const handler = new DomHandler((error, dom) => {
|
||||
if (error) {
|
||||
// Handle error
|
||||
} else {
|
||||
// Parsing completed, do something
|
||||
console.log(dom);
|
||||
}
|
||||
});
|
||||
const parser = new Parser(handler);
|
||||
parser.write(rawHtml);
|
||||
parser.end();
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
data: "Xyz ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "script",
|
||||
name: "script",
|
||||
attribs: {
|
||||
language: "javascript",
|
||||
},
|
||||
children: [
|
||||
{
|
||||
data: "var foo = '<bar>';<",
|
||||
type: "text",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
data: "<!-- Waah! -- ",
|
||||
type: "comment",
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
## Option: `withStartIndices`
|
||||
|
||||
Add a `startIndex` property to nodes.
|
||||
When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
||||
indicating the position of the start of the node in the document.
|
||||
The default value is `false`.
|
||||
|
||||
## Option: `withEndIndices`
|
||||
|
||||
Add an `endIndex` property to nodes.
|
||||
When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
||||
indicating the position of the end of the node in the document.
|
||||
The default value is `false`.
|
||||
|
||||
## Option: `normalizeWhitespace` _(deprecated)_
|
||||
|
||||
Replace all whitespace with single spaces.
|
||||
The default value is `false`.
|
||||
|
||||
**Note:** Enabling this might break your markup.
|
||||
|
||||
For the following examples, this HTML will be used:
|
||||
|
||||
```html
|
||||
<font> <br />this is the text <font></font></font>
|
||||
```
|
||||
|
||||
### Example: `normalizeWhitespace: true`
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
children: [
|
||||
{
|
||||
data: " ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "br",
|
||||
},
|
||||
{
|
||||
data: "this is the text ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### Example: `normalizeWhitespace: false`
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
children: [
|
||||
{
|
||||
data: "\n\t",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "br",
|
||||
},
|
||||
{
|
||||
data: "this is the text\n",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
License: BSD-2-Clause
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
## `domhandler` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of `domhandler` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-domhandler?utm_source=npm-domhandler&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
55
book/node_modules/web-resource-inliner/node_modules/dom-serializer/package.json
generated
vendored
Normal file
55
book/node_modules/web-resource-inliner/node_modules/dom-serializer/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "dom-serializer",
|
||||
"version": "1.4.1",
|
||||
"description": "render domhandler DOM nodes to a string",
|
||||
"author": "Felix Boehm <me@feedic.com>",
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"html",
|
||||
"xml",
|
||||
"render"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/cheeriojs/dom-renderer.git"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib/**/*"
|
||||
],
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.0.1",
|
||||
"domhandler": "^4.2.0",
|
||||
"entities": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/node": "^15.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.23.0",
|
||||
"@typescript-eslint/parser": "^4.23.0",
|
||||
"cheerio": "^1.0.0-rc.9",
|
||||
"coveralls": "^3.0.5",
|
||||
"eslint": "^7.26.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"htmlparser2": "^6.1.0",
|
||||
"jest": "^26.0.1",
|
||||
"prettier": "^2.3.0",
|
||||
"ts-jest": "^26.5.6",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest --coverage && npm run lint",
|
||||
"coverage": "cat coverage/lcov.info | coveralls",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write '**/*.{ts,md,json}'",
|
||||
"build": "tsc",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"funding": "https://github.com/cheeriojs/dom-serializer?sponsor=1",
|
||||
"license": "MIT"
|
||||
}
|
11
book/node_modules/web-resource-inliner/node_modules/domhandler/LICENSE
generated
vendored
Normal file
11
book/node_modules/web-resource-inliner/node_modules/domhandler/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
Copyright (c) Felix Böhm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
78
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/index.d.ts
generated
vendored
Normal file
78
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
import { Node, Element, DataNode } from "./node";
|
||||
export * from "./node";
|
||||
export interface DomHandlerOptions {
|
||||
/**
|
||||
* Add a `startIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
||||
* indicating the position of the start of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withStartIndices?: boolean;
|
||||
/**
|
||||
* Add an `endIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
||||
* indicating the position of the end of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withEndIndices?: boolean;
|
||||
/**
|
||||
* Replace all whitespace with single spaces.
|
||||
*
|
||||
* **Note:** Enabling this might break your markup.
|
||||
*
|
||||
* @default false
|
||||
* @deprecated
|
||||
*/
|
||||
normalizeWhitespace?: boolean;
|
||||
}
|
||||
interface ParserInterface {
|
||||
startIndex: number | null;
|
||||
endIndex: number | null;
|
||||
}
|
||||
declare type Callback = (error: Error | null, dom: Node[]) => void;
|
||||
declare type ElementCallback = (element: Element) => void;
|
||||
export declare class DomHandler {
|
||||
/** The constructed DOM */
|
||||
dom: Node[];
|
||||
/** Called once parsing has completed. */
|
||||
private readonly _callback;
|
||||
/** Settings for the handler. */
|
||||
private readonly _options;
|
||||
/** Callback whenever a tag is closed. */
|
||||
private readonly _elementCB;
|
||||
/** Indicated whether parsing has been completed. */
|
||||
private _done;
|
||||
/** Stack of open tags. */
|
||||
private _tagStack;
|
||||
/** A data node that is still being written to. */
|
||||
private _lastNode;
|
||||
/** Reference to the parser instance. Used for location information. */
|
||||
private _parser;
|
||||
/**
|
||||
* @param callback Called once parsing has completed.
|
||||
* @param options Settings for the handler.
|
||||
* @param elementCB Callback whenever a tag is closed.
|
||||
*/
|
||||
constructor(callback?: Callback | null, options?: DomHandlerOptions | null, elementCB?: ElementCallback);
|
||||
onparserinit(parser: ParserInterface): void;
|
||||
onreset(): void;
|
||||
onend(): void;
|
||||
onerror(error: Error): void;
|
||||
onclosetag(): void;
|
||||
onopentag(name: string, attribs: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
ontext(data: string): void;
|
||||
oncomment(data: string): void;
|
||||
oncommentend(): void;
|
||||
oncdatastart(): void;
|
||||
oncdataend(): void;
|
||||
onprocessinginstruction(name: string, data: string): void;
|
||||
protected handleCallback(error: Error | null): void;
|
||||
protected addNode(node: Node): void;
|
||||
protected addDataNode(node: DataNode): void;
|
||||
}
|
||||
export default DomHandler;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/index.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,IAAI,EACJ,OAAO,EACP,QAAQ,EAKX,MAAM,QAAQ,CAAC;AAEhB,cAAc,QAAQ,CAAC;AAIvB,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AASD,UAAU,eAAe;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,aAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;AAC3D,aAAK,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAElD,qBAAa,UAAU;IACnB,0BAA0B;IACnB,GAAG,EAAE,IAAI,EAAE,CAAM;IAExB,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAE5C,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAE7C,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IAEpD,oDAAoD;IACpD,OAAO,CAAC,KAAK,CAAS;IAEtB,0BAA0B;IAC1B,OAAO,CAAC,SAAS,CAAiB;IAElC,kDAAkD;IAClD,OAAO,CAAC,SAAS,CAAyB;IAE1C,uEAAuE;IACvE,OAAO,CAAC,OAAO,CAAgC;IAE/C;;;;OAIG;gBAEC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,EAC1B,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAClC,SAAS,CAAC,EAAE,eAAe;IAiBxB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAK3C,OAAO,IAAI,IAAI;IASf,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAI3B,UAAU,IAAI,IAAI;IAgBlB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI;IAMjE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAyB1B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAW7B,YAAY,IAAI,IAAI;IAIpB,YAAY,IAAI,IAAI;IAUpB,UAAU,IAAI,IAAI;IAIlB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAKhE,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAQnD,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAiCnC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;CAI9C;AAED,eAAe,UAAU,CAAC"}
|
176
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/index.js
generated
vendored
Normal file
176
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DomHandler = void 0;
|
||||
var node_1 = require("./node");
|
||||
__exportStar(require("./node"), exports);
|
||||
var reWhitespace = /\s+/g;
|
||||
// Default options
|
||||
var defaultOpts = {
|
||||
normalizeWhitespace: false,
|
||||
withStartIndices: false,
|
||||
withEndIndices: false,
|
||||
};
|
||||
var DomHandler = /** @class */ (function () {
|
||||
/**
|
||||
* @param callback Called once parsing has completed.
|
||||
* @param options Settings for the handler.
|
||||
* @param elementCB Callback whenever a tag is closed.
|
||||
*/
|
||||
function DomHandler(callback, options, elementCB) {
|
||||
/** The constructed DOM */
|
||||
this.dom = [];
|
||||
/** Indicated whether parsing has been completed. */
|
||||
this._done = false;
|
||||
/** Stack of open tags. */
|
||||
this._tagStack = [];
|
||||
/** A data node that is still being written to. */
|
||||
this._lastNode = null;
|
||||
/** Reference to the parser instance. Used for location information. */
|
||||
this._parser = null;
|
||||
// Make it possible to skip arguments, for backwards-compatibility
|
||||
if (typeof options === "function") {
|
||||
elementCB = options;
|
||||
options = defaultOpts;
|
||||
}
|
||||
if (typeof callback === "object") {
|
||||
options = callback;
|
||||
callback = undefined;
|
||||
}
|
||||
this._callback = callback !== null && callback !== void 0 ? callback : null;
|
||||
this._options = options !== null && options !== void 0 ? options : defaultOpts;
|
||||
this._elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
|
||||
}
|
||||
DomHandler.prototype.onparserinit = function (parser) {
|
||||
this._parser = parser;
|
||||
};
|
||||
// Resets the handler back to starting state
|
||||
DomHandler.prototype.onreset = function () {
|
||||
var _a;
|
||||
this.dom = [];
|
||||
this._done = false;
|
||||
this._tagStack = [];
|
||||
this._lastNode = null;
|
||||
this._parser = (_a = this._parser) !== null && _a !== void 0 ? _a : null;
|
||||
};
|
||||
// Signals the handler that parsing is done
|
||||
DomHandler.prototype.onend = function () {
|
||||
if (this._done)
|
||||
return;
|
||||
this._done = true;
|
||||
this._parser = null;
|
||||
this.handleCallback(null);
|
||||
};
|
||||
DomHandler.prototype.onerror = function (error) {
|
||||
this.handleCallback(error);
|
||||
};
|
||||
DomHandler.prototype.onclosetag = function () {
|
||||
this._lastNode = null;
|
||||
var elem = this._tagStack.pop();
|
||||
if (!elem || !this._parser) {
|
||||
return;
|
||||
}
|
||||
if (this._options.withEndIndices) {
|
||||
elem.endIndex = this._parser.endIndex;
|
||||
}
|
||||
if (this._elementCB)
|
||||
this._elementCB(elem);
|
||||
};
|
||||
DomHandler.prototype.onopentag = function (name, attribs) {
|
||||
var element = new node_1.Element(name, attribs);
|
||||
this.addNode(element);
|
||||
this._tagStack.push(element);
|
||||
};
|
||||
DomHandler.prototype.ontext = function (data) {
|
||||
var normalize = this._options.normalizeWhitespace;
|
||||
var _lastNode = this._lastNode;
|
||||
if (_lastNode && _lastNode.type === "text" /* Text */) {
|
||||
if (normalize) {
|
||||
_lastNode.data = (_lastNode.data + data).replace(reWhitespace, " ");
|
||||
}
|
||||
else {
|
||||
_lastNode.data += data;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (normalize) {
|
||||
data = data.replace(reWhitespace, " ");
|
||||
}
|
||||
var node = new node_1.Text(data);
|
||||
this.addNode(node);
|
||||
this._lastNode = node;
|
||||
}
|
||||
};
|
||||
DomHandler.prototype.oncomment = function (data) {
|
||||
if (this._lastNode && this._lastNode.type === "comment" /* Comment */) {
|
||||
this._lastNode.data += data;
|
||||
return;
|
||||
}
|
||||
var node = new node_1.Comment(data);
|
||||
this.addNode(node);
|
||||
this._lastNode = node;
|
||||
};
|
||||
DomHandler.prototype.oncommentend = function () {
|
||||
this._lastNode = null;
|
||||
};
|
||||
DomHandler.prototype.oncdatastart = function () {
|
||||
var text = new node_1.Text("");
|
||||
var node = new node_1.NodeWithChildren("cdata" /* CDATA */, [text]);
|
||||
this.addNode(node);
|
||||
text.parent = node;
|
||||
this._lastNode = text;
|
||||
};
|
||||
DomHandler.prototype.oncdataend = function () {
|
||||
this._lastNode = null;
|
||||
};
|
||||
DomHandler.prototype.onprocessinginstruction = function (name, data) {
|
||||
var node = new node_1.ProcessingInstruction(name, data);
|
||||
this.addNode(node);
|
||||
};
|
||||
DomHandler.prototype.handleCallback = function (error) {
|
||||
if (typeof this._callback === "function") {
|
||||
this._callback(error, this.dom);
|
||||
}
|
||||
else if (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
DomHandler.prototype.addNode = function (node) {
|
||||
var parent = this._tagStack[this._tagStack.length - 1];
|
||||
var siblings = parent ? parent.children : this.dom;
|
||||
var previousSibling = siblings[siblings.length - 1];
|
||||
if (this._parser) {
|
||||
if (this._options.withStartIndices) {
|
||||
node.startIndex = this._parser.startIndex;
|
||||
}
|
||||
if (this._options.withEndIndices) {
|
||||
node.endIndex = this._parser.endIndex;
|
||||
}
|
||||
}
|
||||
siblings.push(node);
|
||||
if (previousSibling) {
|
||||
node.prev = previousSibling;
|
||||
previousSibling.next = node;
|
||||
}
|
||||
if (parent) {
|
||||
node.parent = parent;
|
||||
}
|
||||
this._lastNode = null;
|
||||
};
|
||||
DomHandler.prototype.addDataNode = function (node) {
|
||||
this.addNode(node);
|
||||
this._lastNode = node;
|
||||
};
|
||||
return DomHandler;
|
||||
}());
|
||||
exports.DomHandler = DomHandler;
|
||||
exports.default = DomHandler;
|
98
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/node.d.ts
generated
vendored
Normal file
98
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
import { ElementType } from "domelementtype";
|
||||
/**
|
||||
* This object will be used as the prototype for Nodes when creating a
|
||||
* DOM-Level-1-compliant structure.
|
||||
*/
|
||||
export declare class Node {
|
||||
type: ElementType;
|
||||
/** Parent of the node */
|
||||
parent: NodeWithChildren | null;
|
||||
/** Previous sibling */
|
||||
prev: Node | null;
|
||||
/** Next sibling */
|
||||
next: Node | null;
|
||||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
||||
startIndex: number | null;
|
||||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
||||
endIndex: number | null;
|
||||
/**
|
||||
*
|
||||
* @param type The type of the node.
|
||||
*/
|
||||
constructor(type: ElementType);
|
||||
get nodeType(): number;
|
||||
get parentNode(): NodeWithChildren | null;
|
||||
set parentNode(parent: NodeWithChildren | null);
|
||||
get previousSibling(): Node | null;
|
||||
set previousSibling(prev: Node | null);
|
||||
get nextSibling(): Node | null;
|
||||
set nextSibling(next: Node | null);
|
||||
/**
|
||||
* Clone this node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
cloneNode(recursive?: boolean): Node;
|
||||
}
|
||||
export declare class DataNode extends Node {
|
||||
data: string;
|
||||
/**
|
||||
* @param type The type of the node
|
||||
* @param data The content of the data node
|
||||
*/
|
||||
constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
|
||||
get nodeValue(): string;
|
||||
set nodeValue(data: string);
|
||||
}
|
||||
export declare class Text extends DataNode {
|
||||
constructor(data: string);
|
||||
}
|
||||
export declare class Comment extends DataNode {
|
||||
constructor(data: string);
|
||||
}
|
||||
export declare class ProcessingInstruction extends DataNode {
|
||||
name: string;
|
||||
constructor(name: string, data: string);
|
||||
}
|
||||
export declare class NodeWithChildren extends Node {
|
||||
children: Node[];
|
||||
/**
|
||||
*
|
||||
* @param type Type of the node.
|
||||
* @param children Children of the node. Only certain node types can have children.
|
||||
*/
|
||||
constructor(type: ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
|
||||
get firstChild(): Node | null;
|
||||
get lastChild(): Node | null;
|
||||
get childNodes(): Node[];
|
||||
set childNodes(children: Node[]);
|
||||
}
|
||||
export declare class Element extends NodeWithChildren {
|
||||
name: string;
|
||||
attribs: {
|
||||
[name: string]: string;
|
||||
};
|
||||
/**
|
||||
* @param name Name of the tag, eg. `div`, `span`.
|
||||
* @param attribs Object mapping attribute names to attribute values.
|
||||
* @param children Children of the node.
|
||||
*/
|
||||
constructor(name: string, attribs: {
|
||||
[name: string]: string;
|
||||
}, children?: Node[]);
|
||||
get tagName(): string;
|
||||
set tagName(name: string);
|
||||
get attributes(): {
|
||||
name: string;
|
||||
value: string;
|
||||
}[];
|
||||
}
|
||||
/**
|
||||
* Clone a node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
export declare function cloneNode(node: Node, recursive?: boolean): Node;
|
||||
//# sourceMappingURL=node.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/node.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/node.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAY7C;;;GAGG;AACH,qBAAa,IAAI;IAoBM,IAAI,EAAE,WAAW;IAnBpC,yBAAyB;IACzB,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IAEvC,uBAAuB;IACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEzB,mBAAmB;IACnB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEzB,2FAA2F;IAC3F,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEjC,uFAAuF;IACvF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;OAGG;gBACgB,IAAI,EAAE,WAAW;IAGpC,IAAI,QAAQ,IAAI,MAAM,CAErB;IAGD,IAAI,UAAU,IAAI,gBAAgB,GAAG,IAAI,CAExC;IAED,IAAI,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,EAE7C;IAED,IAAI,eAAe,IAAI,IAAI,GAAG,IAAI,CAEjC;IAED,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAEpC;IAED,IAAI,WAAW,IAAI,IAAI,GAAG,IAAI,CAE7B;IAED,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAEhC;IAED;;;;;OAKG;IACH,SAAS,CAAC,SAAS,UAAQ,GAAG,IAAI;CAGrC;AAED,qBAAa,QAAS,SAAQ,IAAI;IAOnB,IAAI,EAAE,MAAM;IANvB;;;OAGG;gBAEC,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,EAC7D,IAAI,EAAE,MAAM;IAKvB,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,SAAS,CAAC,IAAI,EAAE,MAAM,EAEzB;CACJ;AAED,qBAAa,IAAK,SAAQ,QAAQ;gBAClB,IAAI,EAAE,MAAM;CAG3B;AAED,qBAAa,OAAQ,SAAQ,QAAQ;gBACrB,IAAI,EAAE,MAAM;CAG3B;AAED,qBAAa,qBAAsB,SAAQ,QAAQ;IAC5B,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAGhD;AAED,qBAAa,gBAAiB,SAAQ,IAAI;IAY3B,QAAQ,EAAE,IAAI,EAAE;IAX3B;;;;OAIG;gBAEC,IAAI,EACE,WAAW,CAAC,KAAK,GACjB,WAAW,CAAC,MAAM,GAClB,WAAW,CAAC,KAAK,GACjB,WAAW,CAAC,GAAG,EACd,QAAQ,EAAE,IAAI,EAAE;IAM3B,IAAI,UAAU,IAAI,IAAI,GAAG,IAAI,CAE5B;IAED,IAAI,SAAS,IAAI,IAAI,GAAG,IAAI,CAI3B;IAED,IAAI,UAAU,IAAI,IAAI,EAAE,CAEvB;IAED,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,EAE9B;CACJ;AAED,qBAAa,OAAQ,SAAQ,gBAAgB;IAO9B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAP9C;;;;OAIG;gBAEQ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAC1C,QAAQ,GAAE,IAAI,EAAO;IAczB,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,EAEvB;IAED,IAAI,UAAU,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAKlD;CACJ;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,UAAQ,GAAG,IAAI,CA+B7D"}
|
296
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/node.js
generated
vendored
Normal file
296
book/node_modules/web-resource-inliner/node_modules/domhandler/lib/node.js
generated
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cloneNode = exports.Element = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;
|
||||
var nodeTypes = new Map([
|
||||
["tag" /* Tag */, 1],
|
||||
["script" /* Script */, 1],
|
||||
["style" /* Style */, 1],
|
||||
["directive" /* Directive */, 1],
|
||||
["text" /* Text */, 3],
|
||||
["cdata" /* CDATA */, 4],
|
||||
["comment" /* Comment */, 8],
|
||||
]);
|
||||
/**
|
||||
* This object will be used as the prototype for Nodes when creating a
|
||||
* DOM-Level-1-compliant structure.
|
||||
*/
|
||||
var Node = /** @class */ (function () {
|
||||
/**
|
||||
*
|
||||
* @param type The type of the node.
|
||||
*/
|
||||
function Node(type) {
|
||||
this.type = type;
|
||||
/** Parent of the node */
|
||||
this.parent = null;
|
||||
/** Previous sibling */
|
||||
this.prev = null;
|
||||
/** Next sibling */
|
||||
this.next = null;
|
||||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
||||
this.startIndex = null;
|
||||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
||||
this.endIndex = null;
|
||||
}
|
||||
Object.defineProperty(Node.prototype, "nodeType", {
|
||||
// Read-only aliases
|
||||
get: function () {
|
||||
var _a;
|
||||
return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "parentNode", {
|
||||
// Read-write aliases for properties
|
||||
get: function () {
|
||||
return this.parent;
|
||||
},
|
||||
set: function (parent) {
|
||||
this.parent = parent;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "previousSibling", {
|
||||
get: function () {
|
||||
return this.prev;
|
||||
},
|
||||
set: function (prev) {
|
||||
this.prev = prev;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "nextSibling", {
|
||||
get: function () {
|
||||
return this.next;
|
||||
},
|
||||
set: function (next) {
|
||||
this.next = next;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/**
|
||||
* Clone this node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
Node.prototype.cloneNode = function (recursive) {
|
||||
if (recursive === void 0) { recursive = false; }
|
||||
return cloneNode(this, recursive);
|
||||
};
|
||||
return Node;
|
||||
}());
|
||||
exports.Node = Node;
|
||||
var DataNode = /** @class */ (function (_super) {
|
||||
__extends(DataNode, _super);
|
||||
/**
|
||||
* @param type The type of the node
|
||||
* @param data The content of the data node
|
||||
*/
|
||||
function DataNode(type, data) {
|
||||
var _this = _super.call(this, type) || this;
|
||||
_this.data = data;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(DataNode.prototype, "nodeValue", {
|
||||
get: function () {
|
||||
return this.data;
|
||||
},
|
||||
set: function (data) {
|
||||
this.data = data;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return DataNode;
|
||||
}(Node));
|
||||
exports.DataNode = DataNode;
|
||||
var Text = /** @class */ (function (_super) {
|
||||
__extends(Text, _super);
|
||||
function Text(data) {
|
||||
return _super.call(this, "text" /* Text */, data) || this;
|
||||
}
|
||||
return Text;
|
||||
}(DataNode));
|
||||
exports.Text = Text;
|
||||
var Comment = /** @class */ (function (_super) {
|
||||
__extends(Comment, _super);
|
||||
function Comment(data) {
|
||||
return _super.call(this, "comment" /* Comment */, data) || this;
|
||||
}
|
||||
return Comment;
|
||||
}(DataNode));
|
||||
exports.Comment = Comment;
|
||||
var ProcessingInstruction = /** @class */ (function (_super) {
|
||||
__extends(ProcessingInstruction, _super);
|
||||
function ProcessingInstruction(name, data) {
|
||||
var _this = _super.call(this, "directive" /* Directive */, data) || this;
|
||||
_this.name = name;
|
||||
return _this;
|
||||
}
|
||||
return ProcessingInstruction;
|
||||
}(DataNode));
|
||||
exports.ProcessingInstruction = ProcessingInstruction;
|
||||
var NodeWithChildren = /** @class */ (function (_super) {
|
||||
__extends(NodeWithChildren, _super);
|
||||
/**
|
||||
*
|
||||
* @param type Type of the node.
|
||||
* @param children Children of the node. Only certain node types can have children.
|
||||
*/
|
||||
function NodeWithChildren(type, children) {
|
||||
var _this = _super.call(this, type) || this;
|
||||
_this.children = children;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
|
||||
// Aliases
|
||||
get: function () {
|
||||
var _a;
|
||||
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
|
||||
get: function () {
|
||||
return this.children.length > 0
|
||||
? this.children[this.children.length - 1]
|
||||
: null;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
|
||||
get: function () {
|
||||
return this.children;
|
||||
},
|
||||
set: function (children) {
|
||||
this.children = children;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return NodeWithChildren;
|
||||
}(Node));
|
||||
exports.NodeWithChildren = NodeWithChildren;
|
||||
var Element = /** @class */ (function (_super) {
|
||||
__extends(Element, _super);
|
||||
/**
|
||||
* @param name Name of the tag, eg. `div`, `span`.
|
||||
* @param attribs Object mapping attribute names to attribute values.
|
||||
* @param children Children of the node.
|
||||
*/
|
||||
function Element(name, attribs, children) {
|
||||
if (children === void 0) { children = []; }
|
||||
var _this = _super.call(this, name === "script"
|
||||
? "script" /* Script */
|
||||
: name === "style"
|
||||
? "style" /* Style */
|
||||
: "tag" /* Tag */, children) || this;
|
||||
_this.name = name;
|
||||
_this.attribs = attribs;
|
||||
_this.attribs = attribs;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(Element.prototype, "tagName", {
|
||||
// DOM Level 1 aliases
|
||||
get: function () {
|
||||
return this.name;
|
||||
},
|
||||
set: function (name) {
|
||||
this.name = name;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Element.prototype, "attributes", {
|
||||
get: function () {
|
||||
var _this = this;
|
||||
return Object.keys(this.attribs).map(function (name) { return ({
|
||||
name: name,
|
||||
value: _this.attribs[name],
|
||||
}); });
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return Element;
|
||||
}(NodeWithChildren));
|
||||
exports.Element = Element;
|
||||
/**
|
||||
* Clone a node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
function cloneNode(node, recursive) {
|
||||
if (recursive === void 0) { recursive = false; }
|
||||
switch (node.type) {
|
||||
case "text" /* Text */:
|
||||
return new Text(node.data);
|
||||
case "directive" /* Directive */: {
|
||||
var instr = node;
|
||||
return new ProcessingInstruction(instr.name, instr.data);
|
||||
}
|
||||
case "comment" /* Comment */:
|
||||
return new Comment(node.data);
|
||||
case "tag" /* Tag */:
|
||||
case "script" /* Script */:
|
||||
case "style" /* Style */: {
|
||||
var elem = node;
|
||||
var children = recursive ? cloneChildren(elem.children) : [];
|
||||
var clone_1 = new Element(elem.name, __assign({}, elem.attribs), children);
|
||||
children.forEach(function (child) { return (child.parent = clone_1); });
|
||||
return clone_1;
|
||||
}
|
||||
case "cdata" /* CDATA */: {
|
||||
var cdata = node;
|
||||
var children = recursive ? cloneChildren(cdata.children) : [];
|
||||
var clone_2 = new NodeWithChildren("cdata" /* CDATA */, children);
|
||||
children.forEach(function (child) { return (child.parent = clone_2); });
|
||||
return clone_2;
|
||||
}
|
||||
case "doctype" /* Doctype */: {
|
||||
// This type isn't used yet.
|
||||
throw new Error("Not implemented yet: ElementType.Doctype case");
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.cloneNode = cloneNode;
|
||||
function cloneChildren(childs) {
|
||||
var children = childs.map(function (child) { return cloneNode(child, true); });
|
||||
for (var i = 1; i < children.length; i++) {
|
||||
children[i].prev = children[i - 1];
|
||||
children[i - 1].next = children[i];
|
||||
}
|
||||
return children;
|
||||
}
|
57
book/node_modules/web-resource-inliner/node_modules/domhandler/package.json
generated
vendored
Normal file
57
book/node_modules/web-resource-inliner/node_modules/domhandler/package.json
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "domhandler",
|
||||
"version": "3.3.0",
|
||||
"description": "Handler for htmlparser2 that turns pages into a dom",
|
||||
"author": "Felix Boehm <me@feedic.com>",
|
||||
"funding": "https://github.com/fb55/domhandler?sponsor=1",
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest --coverage && npm run lint",
|
||||
"coverage": "cat coverage/lcov.info | coveralls",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write '**/*.{ts,md,json}'",
|
||||
"build": "tsc",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/fb55/domhandler.git"
|
||||
},
|
||||
"keywords": [
|
||||
"dom",
|
||||
"htmlparser2"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/node": "^14.0.9",
|
||||
"@typescript-eslint/eslint-plugin": "^4.1.0",
|
||||
"@typescript-eslint/parser": "^4.1.0",
|
||||
"coveralls": "^3.0.5",
|
||||
"eslint": "^7.9.0",
|
||||
"eslint-config-prettier": "^6.0.0",
|
||||
"htmlparser2": "^4.1.0",
|
||||
"jest": "^26.0.1",
|
||||
"prettier": "^2.0.5",
|
||||
"ts-jest": "^26.1.0",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 4
|
||||
}
|
||||
}
|
163
book/node_modules/web-resource-inliner/node_modules/domhandler/readme.md
generated
vendored
Normal file
163
book/node_modules/web-resource-inliner/node_modules/domhandler/readme.md
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
# domhandler [](https://travis-ci.org/fb55/domhandler)
|
||||
|
||||
The DOM handler creates a tree containing all nodes of a page.
|
||||
The tree can be manipulated using the [domutils](https://github.com/fb55/domutils)
|
||||
or [cheerio](https://github.com/cheeriojs/cheerio) libraries and
|
||||
rendered using [dom-serializer](https://github.com/cheeriojs/dom-serializer) .
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
const handler = new DomHandler([ <func> callback(err, dom), ] [ <obj> options ]);
|
||||
// const parser = new Parser(handler[, options]);
|
||||
```
|
||||
|
||||
Available options are described below.
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
const { Parser } = require("htmlparser2");
|
||||
const { DomHandler } = require("domhandler");
|
||||
const rawHtml =
|
||||
"Xyz <script language= javascript>var foo = '<<bar>>';< / script><!--<!-- Waah! -- -->";
|
||||
const handler = new DomHandler(function (error, dom) {
|
||||
if (error) {
|
||||
// Handle error
|
||||
} else {
|
||||
// Parsing completed, do something
|
||||
console.log(dom);
|
||||
}
|
||||
});
|
||||
const parser = new Parser(handler);
|
||||
parser.write(rawHtml);
|
||||
parser.end();
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
data: "Xyz ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "script",
|
||||
name: "script",
|
||||
attribs: {
|
||||
language: "javascript",
|
||||
},
|
||||
children: [
|
||||
{
|
||||
data: "var foo = '<bar>';<",
|
||||
type: "text",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
data: "<!-- Waah! -- ",
|
||||
type: "comment",
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
## Option: `withStartIndices`
|
||||
|
||||
Add a `startIndex` property to nodes.
|
||||
When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
||||
indicating the position of the start of the node in the document.
|
||||
The default value is `false`.
|
||||
|
||||
## Option: `withEndIndices`
|
||||
|
||||
Add an `endIndex` property to nodes.
|
||||
When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
||||
indicating the position of the end of the node in the document.
|
||||
The default value is `false`.
|
||||
|
||||
## Option: `normalizeWhitespace` _(deprecated)_
|
||||
|
||||
Replace all whitespace with single spaces.
|
||||
The default value is `false`.
|
||||
|
||||
**Note:** Enabling this might break your markup.
|
||||
|
||||
For the following examples, this HTML will be used:
|
||||
|
||||
```html
|
||||
<font> <br />this is the text <font></font></font>
|
||||
```
|
||||
|
||||
### Example: `normalizeWhitespace: true`
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
children: [
|
||||
{
|
||||
data: " ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "br",
|
||||
},
|
||||
{
|
||||
data: "this is the text ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### Example: `normalizeWhitespace: false`
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
children: [
|
||||
{
|
||||
data: "\n\t",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "br",
|
||||
},
|
||||
{
|
||||
data: "this is the text\n",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
License: BSD-2-Clause
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
## `domhandler` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of `domhandler` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-domhandler?utm_source=npm-domhandler&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
11
book/node_modules/web-resource-inliner/node_modules/domutils/LICENSE
generated
vendored
Normal file
11
book/node_modules/web-resource-inliner/node_modules/domutils/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
Copyright (c) Felix Böhm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
45
book/node_modules/web-resource-inliner/node_modules/domutils/lib/feeds.d.ts
generated
vendored
Normal file
45
book/node_modules/web-resource-inliner/node_modules/domutils/lib/feeds.d.ts
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { Node } from "domhandler";
|
||||
export declare type FeedItemMediaMedium = "image" | "audio" | "video" | "document" | "executable";
|
||||
export declare type FeedItemMediaExpression = "sample" | "full" | "nonstop";
|
||||
export interface FeedItemMedia {
|
||||
medium: FeedItemMediaMedium | undefined;
|
||||
isDefault: boolean;
|
||||
url?: string;
|
||||
fileSize?: number;
|
||||
type?: string;
|
||||
expression?: FeedItemMediaExpression;
|
||||
bitrate?: number;
|
||||
framerate?: number;
|
||||
samplingrate?: number;
|
||||
channels?: number;
|
||||
duration?: number;
|
||||
height?: number;
|
||||
width?: number;
|
||||
lang?: string;
|
||||
}
|
||||
export interface FeedItem {
|
||||
id?: string;
|
||||
title?: string;
|
||||
link?: string;
|
||||
description?: string;
|
||||
pubDate?: Date;
|
||||
media: FeedItemMedia[];
|
||||
}
|
||||
export interface Feed {
|
||||
type: string;
|
||||
id?: string;
|
||||
title?: string;
|
||||
link?: string;
|
||||
description?: string;
|
||||
updated?: Date;
|
||||
author?: string;
|
||||
items: FeedItem[];
|
||||
}
|
||||
/**
|
||||
* Get the feed object from the root of a DOM tree.
|
||||
*
|
||||
* @param doc - The DOM to to extract the feed from.
|
||||
* @returns The feed.
|
||||
*/
|
||||
export declare function getFeed(doc: Node[]): Feed | null;
|
||||
//# sourceMappingURL=feeds.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/feeds.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/feeds.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"feeds.d.ts","sourceRoot":"","sources":["../src/feeds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,YAAY,CAAC;AAIhD,oBAAY,mBAAmB,GACzB,OAAO,GACP,OAAO,GACP,OAAO,GACP,UAAU,GACV,YAAY,CAAC;AAEnB,oBAAY,uBAAuB,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAEpE,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACxC,SAAS,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,KAAK,EAAE,aAAa,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,IAAI;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,CAQhD"}
|
190
book/node_modules/web-resource-inliner/node_modules/domutils/lib/feeds.js
generated
vendored
Normal file
190
book/node_modules/web-resource-inliner/node_modules/domutils/lib/feeds.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getFeed = void 0;
|
||||
var stringify_1 = require("./stringify");
|
||||
var legacy_1 = require("./legacy");
|
||||
/**
|
||||
* Get the feed object from the root of a DOM tree.
|
||||
*
|
||||
* @param doc - The DOM to to extract the feed from.
|
||||
* @returns The feed.
|
||||
*/
|
||||
function getFeed(doc) {
|
||||
var feedRoot = getOneElement(isValidFeed, doc);
|
||||
return !feedRoot
|
||||
? null
|
||||
: feedRoot.name === "feed"
|
||||
? getAtomFeed(feedRoot)
|
||||
: getRssFeed(feedRoot);
|
||||
}
|
||||
exports.getFeed = getFeed;
|
||||
/**
|
||||
* Parse an Atom feed.
|
||||
*
|
||||
* @param feedRoot The root of the feed.
|
||||
* @returns The parsed feed.
|
||||
*/
|
||||
function getAtomFeed(feedRoot) {
|
||||
var _a;
|
||||
var childs = feedRoot.children;
|
||||
var feed = {
|
||||
type: "atom",
|
||||
items: (0, legacy_1.getElementsByTagName)("entry", childs).map(function (item) {
|
||||
var _a;
|
||||
var children = item.children;
|
||||
var entry = { media: getMediaElements(children) };
|
||||
addConditionally(entry, "id", "id", children);
|
||||
addConditionally(entry, "title", "title", children);
|
||||
var href = (_a = getOneElement("link", children)) === null || _a === void 0 ? void 0 : _a.attribs.href;
|
||||
if (href) {
|
||||
entry.link = href;
|
||||
}
|
||||
var description = fetch("summary", children) || fetch("content", children);
|
||||
if (description) {
|
||||
entry.description = description;
|
||||
}
|
||||
var pubDate = fetch("updated", children);
|
||||
if (pubDate) {
|
||||
entry.pubDate = new Date(pubDate);
|
||||
}
|
||||
return entry;
|
||||
}),
|
||||
};
|
||||
addConditionally(feed, "id", "id", childs);
|
||||
addConditionally(feed, "title", "title", childs);
|
||||
var href = (_a = getOneElement("link", childs)) === null || _a === void 0 ? void 0 : _a.attribs.href;
|
||||
if (href) {
|
||||
feed.link = href;
|
||||
}
|
||||
addConditionally(feed, "description", "subtitle", childs);
|
||||
var updated = fetch("updated", childs);
|
||||
if (updated) {
|
||||
feed.updated = new Date(updated);
|
||||
}
|
||||
addConditionally(feed, "author", "email", childs, true);
|
||||
return feed;
|
||||
}
|
||||
/**
|
||||
* Parse a RSS feed.
|
||||
*
|
||||
* @param feedRoot The root of the feed.
|
||||
* @returns The parsed feed.
|
||||
*/
|
||||
function getRssFeed(feedRoot) {
|
||||
var _a, _b;
|
||||
var childs = (_b = (_a = getOneElement("channel", feedRoot.children)) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [];
|
||||
var feed = {
|
||||
type: feedRoot.name.substr(0, 3),
|
||||
id: "",
|
||||
items: (0, legacy_1.getElementsByTagName)("item", feedRoot.children).map(function (item) {
|
||||
var children = item.children;
|
||||
var entry = { media: getMediaElements(children) };
|
||||
addConditionally(entry, "id", "guid", children);
|
||||
addConditionally(entry, "title", "title", children);
|
||||
addConditionally(entry, "link", "link", children);
|
||||
addConditionally(entry, "description", "description", children);
|
||||
var pubDate = fetch("pubDate", children);
|
||||
if (pubDate)
|
||||
entry.pubDate = new Date(pubDate);
|
||||
return entry;
|
||||
}),
|
||||
};
|
||||
addConditionally(feed, "title", "title", childs);
|
||||
addConditionally(feed, "link", "link", childs);
|
||||
addConditionally(feed, "description", "description", childs);
|
||||
var updated = fetch("lastBuildDate", childs);
|
||||
if (updated) {
|
||||
feed.updated = new Date(updated);
|
||||
}
|
||||
addConditionally(feed, "author", "managingEditor", childs, true);
|
||||
return feed;
|
||||
}
|
||||
var MEDIA_KEYS_STRING = ["url", "type", "lang"];
|
||||
var MEDIA_KEYS_INT = [
|
||||
"fileSize",
|
||||
"bitrate",
|
||||
"framerate",
|
||||
"samplingrate",
|
||||
"channels",
|
||||
"duration",
|
||||
"height",
|
||||
"width",
|
||||
];
|
||||
/**
|
||||
* Get all media elements of a feed item.
|
||||
*
|
||||
* @param where Nodes to search in.
|
||||
* @returns Media elements.
|
||||
*/
|
||||
function getMediaElements(where) {
|
||||
return (0, legacy_1.getElementsByTagName)("media:content", where).map(function (elem) {
|
||||
var attribs = elem.attribs;
|
||||
var media = {
|
||||
medium: attribs.medium,
|
||||
isDefault: !!attribs.isDefault,
|
||||
};
|
||||
for (var _i = 0, MEDIA_KEYS_STRING_1 = MEDIA_KEYS_STRING; _i < MEDIA_KEYS_STRING_1.length; _i++) {
|
||||
var attrib = MEDIA_KEYS_STRING_1[_i];
|
||||
if (attribs[attrib]) {
|
||||
media[attrib] = attribs[attrib];
|
||||
}
|
||||
}
|
||||
for (var _a = 0, MEDIA_KEYS_INT_1 = MEDIA_KEYS_INT; _a < MEDIA_KEYS_INT_1.length; _a++) {
|
||||
var attrib = MEDIA_KEYS_INT_1[_a];
|
||||
if (attribs[attrib]) {
|
||||
media[attrib] = parseInt(attribs[attrib], 10);
|
||||
}
|
||||
}
|
||||
if (attribs.expression) {
|
||||
media.expression =
|
||||
attribs.expression;
|
||||
}
|
||||
return media;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get one element by tag name.
|
||||
*
|
||||
* @param tagName Tag name to look for
|
||||
* @param node Node to search in
|
||||
* @returns The element or null
|
||||
*/
|
||||
function getOneElement(tagName, node) {
|
||||
return (0, legacy_1.getElementsByTagName)(tagName, node, true, 1)[0];
|
||||
}
|
||||
/**
|
||||
* Get the text content of an element with a certain tag name.
|
||||
*
|
||||
* @param tagName Tag name to look for.
|
||||
* @param where Node to search in.
|
||||
* @param recurse Whether to recurse into child nodes.
|
||||
* @returns The text content of the element.
|
||||
*/
|
||||
function fetch(tagName, where, recurse) {
|
||||
if (recurse === void 0) { recurse = false; }
|
||||
return (0, stringify_1.textContent)((0, legacy_1.getElementsByTagName)(tagName, where, recurse, 1)).trim();
|
||||
}
|
||||
/**
|
||||
* Adds a property to an object if it has a value.
|
||||
*
|
||||
* @param obj Object to be extended
|
||||
* @param prop Property name
|
||||
* @param tagName Tag name that contains the conditionally added property
|
||||
* @param where Element to search for the property
|
||||
* @param recurse Whether to recurse into child nodes.
|
||||
*/
|
||||
function addConditionally(obj, prop, tagName, where, recurse) {
|
||||
if (recurse === void 0) { recurse = false; }
|
||||
var val = fetch(tagName, where, recurse);
|
||||
if (val)
|
||||
obj[prop] = val;
|
||||
}
|
||||
/**
|
||||
* Checks if an element is a feed root node.
|
||||
*
|
||||
* @param value The name of the element to check.
|
||||
* @returns Whether an element is a feed root node.
|
||||
*/
|
||||
function isValidFeed(value) {
|
||||
return value === "rss" || value === "feed" || value === "rdf:RDF";
|
||||
}
|
51
book/node_modules/web-resource-inliner/node_modules/domutils/lib/helpers.d.ts
generated
vendored
Normal file
51
book/node_modules/web-resource-inliner/node_modules/domutils/lib/helpers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Node } from "domhandler";
|
||||
/**
|
||||
* Given an array of nodes, remove any member that is contained by another.
|
||||
*
|
||||
* @param nodes Nodes to filter.
|
||||
* @returns Remaining nodes that aren't subtrees of each other.
|
||||
*/
|
||||
export declare function removeSubsets(nodes: Node[]): Node[];
|
||||
export declare const enum DocumentPosition {
|
||||
DISCONNECTED = 1,
|
||||
PRECEDING = 2,
|
||||
FOLLOWING = 4,
|
||||
CONTAINS = 8,
|
||||
CONTAINED_BY = 16
|
||||
}
|
||||
/**
|
||||
* Compare the position of one node against another node in any other document.
|
||||
* The return value is a bitmask with the following values:
|
||||
*
|
||||
* Document order:
|
||||
* > There is an ordering, document order, defined on all the nodes in the
|
||||
* > document corresponding to the order in which the first character of the
|
||||
* > XML representation of each node occurs in the XML representation of the
|
||||
* > document after expansion of general entities. Thus, the document element
|
||||
* > node will be the first node. Element nodes occur before their children.
|
||||
* > Thus, document order orders element nodes in order of the occurrence of
|
||||
* > their start-tag in the XML (after expansion of entities). The attribute
|
||||
* > nodes of an element occur after the element and before its children. The
|
||||
* > relative order of attribute nodes is implementation-dependent./
|
||||
*
|
||||
* Source:
|
||||
* http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
|
||||
*
|
||||
* @param nodeA The first node to use in the comparison
|
||||
* @param nodeB The second node to use in the comparison
|
||||
* @returns A bitmask describing the input nodes' relative position.
|
||||
*
|
||||
* See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
|
||||
* a description of these values.
|
||||
*/
|
||||
export declare function compareDocumentPosition(nodeA: Node, nodeB: Node): number;
|
||||
/**
|
||||
* Sort an array of nodes based on their relative position in the document and
|
||||
* remove any duplicate nodes. If the array contains nodes that do not belong
|
||||
* to the same document, sort order is unspecified.
|
||||
*
|
||||
* @param nodes Array of DOM nodes.
|
||||
* @returns Collection of unique nodes, sorted in document order.
|
||||
*/
|
||||
export declare function uniqueSort<T extends Node>(nodes: T[]): T[];
|
||||
//# sourceMappingURL=helpers.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/helpers.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/helpers.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CA6BnD;AAGD,0BAAkB,gBAAgB;IAC9B,YAAY,IAAI;IAChB,SAAS,IAAI;IACb,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,YAAY,KAAK;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,CA4CxE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAc1D"}
|
125
book/node_modules/web-resource-inliner/node_modules/domutils/lib/helpers.js
generated
vendored
Normal file
125
book/node_modules/web-resource-inliner/node_modules/domutils/lib/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.uniqueSort = exports.compareDocumentPosition = exports.removeSubsets = void 0;
|
||||
var domhandler_1 = require("domhandler");
|
||||
/**
|
||||
* Given an array of nodes, remove any member that is contained by another.
|
||||
*
|
||||
* @param nodes Nodes to filter.
|
||||
* @returns Remaining nodes that aren't subtrees of each other.
|
||||
*/
|
||||
function removeSubsets(nodes) {
|
||||
var idx = nodes.length;
|
||||
/*
|
||||
* Check if each node (or one of its ancestors) is already contained in the
|
||||
* array.
|
||||
*/
|
||||
while (--idx >= 0) {
|
||||
var node = nodes[idx];
|
||||
/*
|
||||
* Remove the node if it is not unique.
|
||||
* We are going through the array from the end, so we only
|
||||
* have to check nodes that preceed the node under consideration in the array.
|
||||
*/
|
||||
if (idx > 0 && nodes.lastIndexOf(node, idx - 1) >= 0) {
|
||||
nodes.splice(idx, 1);
|
||||
continue;
|
||||
}
|
||||
for (var ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
|
||||
if (nodes.includes(ancestor)) {
|
||||
nodes.splice(idx, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
exports.removeSubsets = removeSubsets;
|
||||
/**
|
||||
* Compare the position of one node against another node in any other document.
|
||||
* The return value is a bitmask with the following values:
|
||||
*
|
||||
* Document order:
|
||||
* > There is an ordering, document order, defined on all the nodes in the
|
||||
* > document corresponding to the order in which the first character of the
|
||||
* > XML representation of each node occurs in the XML representation of the
|
||||
* > document after expansion of general entities. Thus, the document element
|
||||
* > node will be the first node. Element nodes occur before their children.
|
||||
* > Thus, document order orders element nodes in order of the occurrence of
|
||||
* > their start-tag in the XML (after expansion of entities). The attribute
|
||||
* > nodes of an element occur after the element and before its children. The
|
||||
* > relative order of attribute nodes is implementation-dependent./
|
||||
*
|
||||
* Source:
|
||||
* http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
|
||||
*
|
||||
* @param nodeA The first node to use in the comparison
|
||||
* @param nodeB The second node to use in the comparison
|
||||
* @returns A bitmask describing the input nodes' relative position.
|
||||
*
|
||||
* See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
|
||||
* a description of these values.
|
||||
*/
|
||||
function compareDocumentPosition(nodeA, nodeB) {
|
||||
var aParents = [];
|
||||
var bParents = [];
|
||||
if (nodeA === nodeB) {
|
||||
return 0;
|
||||
}
|
||||
var current = (0, domhandler_1.hasChildren)(nodeA) ? nodeA : nodeA.parent;
|
||||
while (current) {
|
||||
aParents.unshift(current);
|
||||
current = current.parent;
|
||||
}
|
||||
current = (0, domhandler_1.hasChildren)(nodeB) ? nodeB : nodeB.parent;
|
||||
while (current) {
|
||||
bParents.unshift(current);
|
||||
current = current.parent;
|
||||
}
|
||||
var maxIdx = Math.min(aParents.length, bParents.length);
|
||||
var idx = 0;
|
||||
while (idx < maxIdx && aParents[idx] === bParents[idx]) {
|
||||
idx++;
|
||||
}
|
||||
if (idx === 0) {
|
||||
return 1 /* DISCONNECTED */;
|
||||
}
|
||||
var sharedParent = aParents[idx - 1];
|
||||
var siblings = sharedParent.children;
|
||||
var aSibling = aParents[idx];
|
||||
var bSibling = bParents[idx];
|
||||
if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) {
|
||||
if (sharedParent === nodeB) {
|
||||
return 4 /* FOLLOWING */ | 16 /* CONTAINED_BY */;
|
||||
}
|
||||
return 4 /* FOLLOWING */;
|
||||
}
|
||||
if (sharedParent === nodeA) {
|
||||
return 2 /* PRECEDING */ | 8 /* CONTAINS */;
|
||||
}
|
||||
return 2 /* PRECEDING */;
|
||||
}
|
||||
exports.compareDocumentPosition = compareDocumentPosition;
|
||||
/**
|
||||
* Sort an array of nodes based on their relative position in the document and
|
||||
* remove any duplicate nodes. If the array contains nodes that do not belong
|
||||
* to the same document, sort order is unspecified.
|
||||
*
|
||||
* @param nodes Array of DOM nodes.
|
||||
* @returns Collection of unique nodes, sorted in document order.
|
||||
*/
|
||||
function uniqueSort(nodes) {
|
||||
nodes = nodes.filter(function (node, i, arr) { return !arr.includes(node, i + 1); });
|
||||
nodes.sort(function (a, b) {
|
||||
var relative = compareDocumentPosition(a, b);
|
||||
if (relative & 2 /* PRECEDING */) {
|
||||
return -1;
|
||||
}
|
||||
else if (relative & 4 /* FOLLOWING */) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
exports.uniqueSort = uniqueSort;
|
10
book/node_modules/web-resource-inliner/node_modules/domutils/lib/index.d.ts
generated
vendored
Normal file
10
book/node_modules/web-resource-inliner/node_modules/domutils/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export * from "./stringify";
|
||||
export * from "./traversal";
|
||||
export * from "./manipulation";
|
||||
export * from "./querying";
|
||||
export * from "./legacy";
|
||||
export * from "./helpers";
|
||||
export * from "./feeds";
|
||||
/** @deprecated Use these methods from `domhandler` directly. */
|
||||
export { isTag, isCDATA, isText, isComment, isDocument, hasChildren, } from "domhandler";
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/index.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,gEAAgE;AAChE,OAAO,EACH,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAS,EACT,UAAU,EACV,WAAW,GACd,MAAM,YAAY,CAAC"}
|
28
book/node_modules/web-resource-inliner/node_modules/domutils/lib/index.js
generated
vendored
Normal file
28
book/node_modules/web-resource-inliner/node_modules/domutils/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hasChildren = exports.isDocument = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = void 0;
|
||||
__exportStar(require("./stringify"), exports);
|
||||
__exportStar(require("./traversal"), exports);
|
||||
__exportStar(require("./manipulation"), exports);
|
||||
__exportStar(require("./querying"), exports);
|
||||
__exportStar(require("./legacy"), exports);
|
||||
__exportStar(require("./helpers"), exports);
|
||||
__exportStar(require("./feeds"), exports);
|
||||
/** @deprecated Use these methods from `domhandler` directly. */
|
||||
var domhandler_1 = require("domhandler");
|
||||
Object.defineProperty(exports, "isTag", { enumerable: true, get: function () { return domhandler_1.isTag; } });
|
||||
Object.defineProperty(exports, "isCDATA", { enumerable: true, get: function () { return domhandler_1.isCDATA; } });
|
||||
Object.defineProperty(exports, "isText", { enumerable: true, get: function () { return domhandler_1.isText; } });
|
||||
Object.defineProperty(exports, "isComment", { enumerable: true, get: function () { return domhandler_1.isComment; } });
|
||||
Object.defineProperty(exports, "isDocument", { enumerable: true, get: function () { return domhandler_1.isDocument; } });
|
||||
Object.defineProperty(exports, "hasChildren", { enumerable: true, get: function () { return domhandler_1.hasChildren; } });
|
47
book/node_modules/web-resource-inliner/node_modules/domutils/lib/legacy.d.ts
generated
vendored
Normal file
47
book/node_modules/web-resource-inliner/node_modules/domutils/lib/legacy.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Node, Element } from "domhandler";
|
||||
import { ElementType } from "domelementtype";
|
||||
interface TestElementOpts {
|
||||
tag_name?: string | ((name: string) => boolean);
|
||||
tag_type?: string | ((name: string) => boolean);
|
||||
tag_contains?: string | ((data?: string) => boolean);
|
||||
[attributeName: string]: undefined | string | ((attributeValue: string) => boolean);
|
||||
}
|
||||
/**
|
||||
* @param options An object describing nodes to look for.
|
||||
* @param node The element to test.
|
||||
* @returns Whether the element matches the description in `options`.
|
||||
*/
|
||||
export declare function testElement(options: TestElementOpts, node: Node): boolean;
|
||||
/**
|
||||
* @param options An object describing nodes to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes that match `options`.
|
||||
*/
|
||||
export declare function getElements(options: TestElementOpts, nodes: Node | Node[], recurse: boolean, limit?: number): Node[];
|
||||
/**
|
||||
* @param id The unique ID attribute value to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @returns The node with the supplied ID.
|
||||
*/
|
||||
export declare function getElementById(id: string | ((id: string) => boolean), nodes: Node | Node[], recurse?: boolean): Element | null;
|
||||
/**
|
||||
* @param tagName Tag name to search for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `tagName`.
|
||||
*/
|
||||
export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Element[];
|
||||
/**
|
||||
* @param type Element type to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `type`.
|
||||
*/
|
||||
export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Node[];
|
||||
export {};
|
||||
//# sourceMappingURL=legacy.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/legacy.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/legacy.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../src/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK7C,UAAU,eAAe;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;IACrD,CAAC,aAAa,EAAE,MAAM,GAChB,SAAS,GACT,MAAM,GACN,CAAC,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC;CAC/C;AAqED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAGzE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACvB,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,EAAE,OAAO,EAChB,KAAK,SAAW,GACjB,IAAI,EAAE,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC1B,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,EACtC,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,UAAO,GACf,OAAO,GAAG,IAAI,CAGhB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,EAC7C,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,UAAO,EACd,KAAK,SAAW,GACjB,OAAO,EAAE,CAEX;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,WAAW,GAAG,CAAC,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,EACpD,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,EACpB,OAAO,UAAO,EACd,KAAK,SAAW,GACjB,IAAI,EAAE,CAER"}
|
124
book/node_modules/web-resource-inliner/node_modules/domutils/lib/legacy.js
generated
vendored
Normal file
124
book/node_modules/web-resource-inliner/node_modules/domutils/lib/legacy.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getElementsByTagType = exports.getElementsByTagName = exports.getElementById = exports.getElements = exports.testElement = void 0;
|
||||
var domhandler_1 = require("domhandler");
|
||||
var querying_1 = require("./querying");
|
||||
var Checks = {
|
||||
tag_name: function (name) {
|
||||
if (typeof name === "function") {
|
||||
return function (elem) { return (0, domhandler_1.isTag)(elem) && name(elem.name); };
|
||||
}
|
||||
else if (name === "*") {
|
||||
return domhandler_1.isTag;
|
||||
}
|
||||
return function (elem) { return (0, domhandler_1.isTag)(elem) && elem.name === name; };
|
||||
},
|
||||
tag_type: function (type) {
|
||||
if (typeof type === "function") {
|
||||
return function (elem) { return type(elem.type); };
|
||||
}
|
||||
return function (elem) { return elem.type === type; };
|
||||
},
|
||||
tag_contains: function (data) {
|
||||
if (typeof data === "function") {
|
||||
return function (elem) { return (0, domhandler_1.isText)(elem) && data(elem.data); };
|
||||
}
|
||||
return function (elem) { return (0, domhandler_1.isText)(elem) && elem.data === data; };
|
||||
},
|
||||
};
|
||||
/**
|
||||
* @param attrib Attribute to check.
|
||||
* @param value Attribute value to look for.
|
||||
* @returns A function to check whether the a node has an attribute with a particular value.
|
||||
*/
|
||||
function getAttribCheck(attrib, value) {
|
||||
if (typeof value === "function") {
|
||||
return function (elem) { return (0, domhandler_1.isTag)(elem) && value(elem.attribs[attrib]); };
|
||||
}
|
||||
return function (elem) { return (0, domhandler_1.isTag)(elem) && elem.attribs[attrib] === value; };
|
||||
}
|
||||
/**
|
||||
* @param a First function to combine.
|
||||
* @param b Second function to combine.
|
||||
* @returns A function taking a node and returning `true` if either
|
||||
* of the input functions returns `true` for the node.
|
||||
*/
|
||||
function combineFuncs(a, b) {
|
||||
return function (elem) { return a(elem) || b(elem); };
|
||||
}
|
||||
/**
|
||||
* @param options An object describing nodes to look for.
|
||||
* @returns A function executing all checks in `options` and returning `true`
|
||||
* if any of them match a node.
|
||||
*/
|
||||
function compileTest(options) {
|
||||
var funcs = Object.keys(options).map(function (key) {
|
||||
var value = options[key];
|
||||
return Object.prototype.hasOwnProperty.call(Checks, key)
|
||||
? Checks[key](value)
|
||||
: getAttribCheck(key, value);
|
||||
});
|
||||
return funcs.length === 0 ? null : funcs.reduce(combineFuncs);
|
||||
}
|
||||
/**
|
||||
* @param options An object describing nodes to look for.
|
||||
* @param node The element to test.
|
||||
* @returns Whether the element matches the description in `options`.
|
||||
*/
|
||||
function testElement(options, node) {
|
||||
var test = compileTest(options);
|
||||
return test ? test(node) : true;
|
||||
}
|
||||
exports.testElement = testElement;
|
||||
/**
|
||||
* @param options An object describing nodes to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes that match `options`.
|
||||
*/
|
||||
function getElements(options, nodes, recurse, limit) {
|
||||
if (limit === void 0) { limit = Infinity; }
|
||||
var test = compileTest(options);
|
||||
return test ? (0, querying_1.filter)(test, nodes, recurse, limit) : [];
|
||||
}
|
||||
exports.getElements = getElements;
|
||||
/**
|
||||
* @param id The unique ID attribute value to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @returns The node with the supplied ID.
|
||||
*/
|
||||
function getElementById(id, nodes, recurse) {
|
||||
if (recurse === void 0) { recurse = true; }
|
||||
if (!Array.isArray(nodes))
|
||||
nodes = [nodes];
|
||||
return (0, querying_1.findOne)(getAttribCheck("id", id), nodes, recurse);
|
||||
}
|
||||
exports.getElementById = getElementById;
|
||||
/**
|
||||
* @param tagName Tag name to search for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `tagName`.
|
||||
*/
|
||||
function getElementsByTagName(tagName, nodes, recurse, limit) {
|
||||
if (recurse === void 0) { recurse = true; }
|
||||
if (limit === void 0) { limit = Infinity; }
|
||||
return (0, querying_1.filter)(Checks.tag_name(tagName), nodes, recurse, limit);
|
||||
}
|
||||
exports.getElementsByTagName = getElementsByTagName;
|
||||
/**
|
||||
* @param type Element type to look for.
|
||||
* @param nodes Nodes to search through.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes with the supplied `type`.
|
||||
*/
|
||||
function getElementsByTagType(type, nodes, recurse, limit) {
|
||||
if (recurse === void 0) { recurse = true; }
|
||||
if (limit === void 0) { limit = Infinity; }
|
||||
return (0, querying_1.filter)(Checks.tag_type(type), nodes, recurse, limit);
|
||||
}
|
||||
exports.getElementsByTagType = getElementsByTagType;
|
43
book/node_modules/web-resource-inliner/node_modules/domutils/lib/manipulation.d.ts
generated
vendored
Normal file
43
book/node_modules/web-resource-inliner/node_modules/domutils/lib/manipulation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { Node, Element } from "domhandler";
|
||||
/**
|
||||
* Remove an element from the dom
|
||||
*
|
||||
* @param elem The element to be removed
|
||||
*/
|
||||
export declare function removeElement(elem: Node): void;
|
||||
/**
|
||||
* Replace an element in the dom
|
||||
*
|
||||
* @param elem The element to be replaced
|
||||
* @param replacement The element to be added
|
||||
*/
|
||||
export declare function replaceElement(elem: Node, replacement: Node): void;
|
||||
/**
|
||||
* Append a child to an element.
|
||||
*
|
||||
* @param elem The element to append to.
|
||||
* @param child The element to be added as a child.
|
||||
*/
|
||||
export declare function appendChild(elem: Element, child: Node): void;
|
||||
/**
|
||||
* Append an element after another.
|
||||
*
|
||||
* @param elem The element to append after.
|
||||
* @param next The element be added.
|
||||
*/
|
||||
export declare function append(elem: Node, next: Node): void;
|
||||
/**
|
||||
* Prepend a child to an element.
|
||||
*
|
||||
* @param elem The element to prepend before.
|
||||
* @param child The element to be added as a child.
|
||||
*/
|
||||
export declare function prependChild(elem: Element, child: Node): void;
|
||||
/**
|
||||
* Prepend an element before another.
|
||||
*
|
||||
* @param elem The element to prepend before.
|
||||
* @param prev The element be added.
|
||||
*/
|
||||
export declare function prepend(elem: Node, prev: Node): void;
|
||||
//# sourceMappingURL=manipulation.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/manipulation.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/manipulation.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"manipulation.d.ts","sourceRoot":"","sources":["../src/manipulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAQ9C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,GAAG,IAAI,CAgBlE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAa5D;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAoBnD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAa7D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAiBpD"}
|
129
book/node_modules/web-resource-inliner/node_modules/domutils/lib/manipulation.js
generated
vendored
Normal file
129
book/node_modules/web-resource-inliner/node_modules/domutils/lib/manipulation.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.prepend = exports.prependChild = exports.append = exports.appendChild = exports.replaceElement = exports.removeElement = void 0;
|
||||
/**
|
||||
* Remove an element from the dom
|
||||
*
|
||||
* @param elem The element to be removed
|
||||
*/
|
||||
function removeElement(elem) {
|
||||
if (elem.prev)
|
||||
elem.prev.next = elem.next;
|
||||
if (elem.next)
|
||||
elem.next.prev = elem.prev;
|
||||
if (elem.parent) {
|
||||
var childs = elem.parent.children;
|
||||
childs.splice(childs.lastIndexOf(elem), 1);
|
||||
}
|
||||
}
|
||||
exports.removeElement = removeElement;
|
||||
/**
|
||||
* Replace an element in the dom
|
||||
*
|
||||
* @param elem The element to be replaced
|
||||
* @param replacement The element to be added
|
||||
*/
|
||||
function replaceElement(elem, replacement) {
|
||||
var prev = (replacement.prev = elem.prev);
|
||||
if (prev) {
|
||||
prev.next = replacement;
|
||||
}
|
||||
var next = (replacement.next = elem.next);
|
||||
if (next) {
|
||||
next.prev = replacement;
|
||||
}
|
||||
var parent = (replacement.parent = elem.parent);
|
||||
if (parent) {
|
||||
var childs = parent.children;
|
||||
childs[childs.lastIndexOf(elem)] = replacement;
|
||||
}
|
||||
}
|
||||
exports.replaceElement = replaceElement;
|
||||
/**
|
||||
* Append a child to an element.
|
||||
*
|
||||
* @param elem The element to append to.
|
||||
* @param child The element to be added as a child.
|
||||
*/
|
||||
function appendChild(elem, child) {
|
||||
removeElement(child);
|
||||
child.next = null;
|
||||
child.parent = elem;
|
||||
if (elem.children.push(child) > 1) {
|
||||
var sibling = elem.children[elem.children.length - 2];
|
||||
sibling.next = child;
|
||||
child.prev = sibling;
|
||||
}
|
||||
else {
|
||||
child.prev = null;
|
||||
}
|
||||
}
|
||||
exports.appendChild = appendChild;
|
||||
/**
|
||||
* Append an element after another.
|
||||
*
|
||||
* @param elem The element to append after.
|
||||
* @param next The element be added.
|
||||
*/
|
||||
function append(elem, next) {
|
||||
removeElement(next);
|
||||
var parent = elem.parent;
|
||||
var currNext = elem.next;
|
||||
next.next = currNext;
|
||||
next.prev = elem;
|
||||
elem.next = next;
|
||||
next.parent = parent;
|
||||
if (currNext) {
|
||||
currNext.prev = next;
|
||||
if (parent) {
|
||||
var childs = parent.children;
|
||||
childs.splice(childs.lastIndexOf(currNext), 0, next);
|
||||
}
|
||||
}
|
||||
else if (parent) {
|
||||
parent.children.push(next);
|
||||
}
|
||||
}
|
||||
exports.append = append;
|
||||
/**
|
||||
* Prepend a child to an element.
|
||||
*
|
||||
* @param elem The element to prepend before.
|
||||
* @param child The element to be added as a child.
|
||||
*/
|
||||
function prependChild(elem, child) {
|
||||
removeElement(child);
|
||||
child.parent = elem;
|
||||
child.prev = null;
|
||||
if (elem.children.unshift(child) !== 1) {
|
||||
var sibling = elem.children[1];
|
||||
sibling.prev = child;
|
||||
child.next = sibling;
|
||||
}
|
||||
else {
|
||||
child.next = null;
|
||||
}
|
||||
}
|
||||
exports.prependChild = prependChild;
|
||||
/**
|
||||
* Prepend an element before another.
|
||||
*
|
||||
* @param elem The element to prepend before.
|
||||
* @param prev The element be added.
|
||||
*/
|
||||
function prepend(elem, prev) {
|
||||
removeElement(prev);
|
||||
var parent = elem.parent;
|
||||
if (parent) {
|
||||
var childs = parent.children;
|
||||
childs.splice(childs.indexOf(elem), 0, prev);
|
||||
}
|
||||
if (elem.prev) {
|
||||
elem.prev.next = prev;
|
||||
}
|
||||
prev.parent = parent;
|
||||
prev.prev = elem.prev;
|
||||
prev.next = elem;
|
||||
elem.prev = prev;
|
||||
}
|
||||
exports.prepend = prepend;
|
55
book/node_modules/web-resource-inliner/node_modules/domutils/lib/querying.d.ts
generated
vendored
Normal file
55
book/node_modules/web-resource-inliner/node_modules/domutils/lib/querying.d.ts
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
import { Node, Element } from "domhandler";
|
||||
/**
|
||||
* Search a node and its children for nodes passing a test function.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param node Node to search. Will be included in the result set if it matches.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function filter(test: (elem: Node) => boolean, node: Node | Node[], recurse?: boolean, limit?: number): Node[];
|
||||
/**
|
||||
* Search an array of node and its children for nodes passing a test function.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function find(test: (elem: Node) => boolean, nodes: Node[], recurse: boolean, limit: number): Node[];
|
||||
/**
|
||||
* Finds the first element inside of an array that matches a test function.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns The first node in the array that passes `test`.
|
||||
*/
|
||||
export declare function findOneChild(test: (elem: Node) => boolean, nodes: Node[]): Node | undefined;
|
||||
/**
|
||||
* Finds one element in a tree that passes a test.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @returns The first child node that passes `test`.
|
||||
*/
|
||||
export declare function findOne(test: (elem: Element) => boolean, nodes: Node[], recurse?: boolean): Element | null;
|
||||
/**
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns Whether a tree of nodes contains at least one node passing a test.
|
||||
*/
|
||||
export declare function existsOne(test: (elem: Element) => boolean, nodes: Node[]): boolean;
|
||||
/**
|
||||
* Search and array of nodes and its children for nodes passing a test function.
|
||||
*
|
||||
* Same as `find`, only with less options, leading to reduced complexity.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
export declare function findAll(test: (elem: Element) => boolean, nodes: Node[]): Element[];
|
||||
//# sourceMappingURL=querying.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/querying.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/querying.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"querying.d.ts","sourceRoot":"","sources":["../src/querying.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAClB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,EAC7B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,EACnB,OAAO,UAAO,EACd,KAAK,SAAW,GACjB,IAAI,EAAE,CAGR;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAChB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,EAC7B,KAAK,EAAE,IAAI,EAAE,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,GACd,IAAI,EAAE,CAkBR;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,EAC7B,KAAK,EAAE,IAAI,EAAE,GACd,IAAI,GAAG,SAAS,CAElB;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACnB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,IAAI,EAAE,EACb,OAAO,UAAO,GACf,OAAO,GAAG,IAAI,CAehB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACrB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,IAAI,EAAE,GACd,OAAO,CAQT;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CACnB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,IAAI,EAAE,GACd,OAAO,EAAE,CAYX"}
|
126
book/node_modules/web-resource-inliner/node_modules/domutils/lib/querying.js
generated
vendored
Normal file
126
book/node_modules/web-resource-inliner/node_modules/domutils/lib/querying.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.findAll = exports.existsOne = exports.findOne = exports.findOneChild = exports.find = exports.filter = void 0;
|
||||
var domhandler_1 = require("domhandler");
|
||||
/**
|
||||
* Search a node and its children for nodes passing a test function.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param node Node to search. Will be included in the result set if it matches.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
function filter(test, node, recurse, limit) {
|
||||
if (recurse === void 0) { recurse = true; }
|
||||
if (limit === void 0) { limit = Infinity; }
|
||||
if (!Array.isArray(node))
|
||||
node = [node];
|
||||
return find(test, node, recurse, limit);
|
||||
}
|
||||
exports.filter = filter;
|
||||
/**
|
||||
* Search an array of node and its children for nodes passing a test function.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @param limit Maximum number of nodes to return.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
function find(test, nodes, recurse, limit) {
|
||||
var result = [];
|
||||
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
||||
var elem = nodes_1[_i];
|
||||
if (test(elem)) {
|
||||
result.push(elem);
|
||||
if (--limit <= 0)
|
||||
break;
|
||||
}
|
||||
if (recurse && (0, domhandler_1.hasChildren)(elem) && elem.children.length > 0) {
|
||||
var children = find(test, elem.children, recurse, limit);
|
||||
result.push.apply(result, children);
|
||||
limit -= children.length;
|
||||
if (limit <= 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.find = find;
|
||||
/**
|
||||
* Finds the first element inside of an array that matches a test function.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns The first node in the array that passes `test`.
|
||||
*/
|
||||
function findOneChild(test, nodes) {
|
||||
return nodes.find(test);
|
||||
}
|
||||
exports.findOneChild = findOneChild;
|
||||
/**
|
||||
* Finds one element in a tree that passes a test.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @param recurse Also consider child nodes.
|
||||
* @returns The first child node that passes `test`.
|
||||
*/
|
||||
function findOne(test, nodes, recurse) {
|
||||
if (recurse === void 0) { recurse = true; }
|
||||
var elem = null;
|
||||
for (var i = 0; i < nodes.length && !elem; i++) {
|
||||
var checked = nodes[i];
|
||||
if (!(0, domhandler_1.isTag)(checked)) {
|
||||
continue;
|
||||
}
|
||||
else if (test(checked)) {
|
||||
elem = checked;
|
||||
}
|
||||
else if (recurse && checked.children.length > 0) {
|
||||
elem = findOne(test, checked.children);
|
||||
}
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
exports.findOne = findOne;
|
||||
/**
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns Whether a tree of nodes contains at least one node passing a test.
|
||||
*/
|
||||
function existsOne(test, nodes) {
|
||||
return nodes.some(function (checked) {
|
||||
return (0, domhandler_1.isTag)(checked) &&
|
||||
(test(checked) ||
|
||||
(checked.children.length > 0 &&
|
||||
existsOne(test, checked.children)));
|
||||
});
|
||||
}
|
||||
exports.existsOne = existsOne;
|
||||
/**
|
||||
* Search and array of nodes and its children for nodes passing a test function.
|
||||
*
|
||||
* Same as `find`, only with less options, leading to reduced complexity.
|
||||
*
|
||||
* @param test Function to test nodes on.
|
||||
* @param nodes Array of nodes to search.
|
||||
* @returns All nodes passing `test`.
|
||||
*/
|
||||
function findAll(test, nodes) {
|
||||
var _a;
|
||||
var result = [];
|
||||
var stack = nodes.filter(domhandler_1.isTag);
|
||||
var elem;
|
||||
while ((elem = stack.shift())) {
|
||||
var children = (_a = elem.children) === null || _a === void 0 ? void 0 : _a.filter(domhandler_1.isTag);
|
||||
if (children && children.length > 0) {
|
||||
stack.unshift.apply(stack, children);
|
||||
}
|
||||
if (test(elem))
|
||||
result.push(elem);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.findAll = findAll;
|
41
book/node_modules/web-resource-inliner/node_modules/domutils/lib/stringify.d.ts
generated
vendored
Normal file
41
book/node_modules/web-resource-inliner/node_modules/domutils/lib/stringify.d.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Node } from "domhandler";
|
||||
import { DomSerializerOptions } from "dom-serializer";
|
||||
/**
|
||||
* @param node Node to get the outer HTML of.
|
||||
* @param options Options for serialization.
|
||||
* @deprecated Use the `dom-serializer` module directly.
|
||||
* @returns `node`'s outer HTML.
|
||||
*/
|
||||
export declare function getOuterHTML(node: Node | Node[], options?: DomSerializerOptions): string;
|
||||
/**
|
||||
* @param node Node to get the inner HTML of.
|
||||
* @param options Options for serialization.
|
||||
* @deprecated Use the `dom-serializer` module directly.
|
||||
* @returns `node`'s inner HTML.
|
||||
*/
|
||||
export declare function getInnerHTML(node: Node, options?: DomSerializerOptions): string;
|
||||
/**
|
||||
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags.
|
||||
*
|
||||
* @deprecated Use `textContent` instead.
|
||||
* @param node Node to get the inner text of.
|
||||
* @returns `node`'s inner text.
|
||||
*/
|
||||
export declare function getText(node: Node | Node[]): string;
|
||||
/**
|
||||
* Get a node's text content.
|
||||
*
|
||||
* @param node Node to get the text content of.
|
||||
* @returns `node`'s text content.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
|
||||
*/
|
||||
export declare function textContent(node: Node | Node[]): string;
|
||||
/**
|
||||
* Get a node's inner text.
|
||||
*
|
||||
* @param node Node to get the inner text of.
|
||||
* @returns `node`'s inner text.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText}
|
||||
*/
|
||||
export declare function innerText(node: Node | Node[]): string;
|
||||
//# sourceMappingURL=stringify.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/stringify.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/stringify.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stringify.d.ts","sourceRoot":"","sources":["../src/stringify.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,IAAI,EAEP,MAAM,YAAY,CAAC;AACpB,OAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGlE;;;;;GAKG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,EACnB,OAAO,CAAC,EAAE,oBAAoB,GAC/B,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,oBAAoB,GAC/B,MAAM,CAIR;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,CAMnD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,CAOvD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,MAAM,CAOrD"}
|
86
book/node_modules/web-resource-inliner/node_modules/domutils/lib/stringify.js
generated
vendored
Normal file
86
book/node_modules/web-resource-inliner/node_modules/domutils/lib/stringify.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.innerText = exports.textContent = exports.getText = exports.getInnerHTML = exports.getOuterHTML = void 0;
|
||||
var domhandler_1 = require("domhandler");
|
||||
var dom_serializer_1 = __importDefault(require("dom-serializer"));
|
||||
var domelementtype_1 = require("domelementtype");
|
||||
/**
|
||||
* @param node Node to get the outer HTML of.
|
||||
* @param options Options for serialization.
|
||||
* @deprecated Use the `dom-serializer` module directly.
|
||||
* @returns `node`'s outer HTML.
|
||||
*/
|
||||
function getOuterHTML(node, options) {
|
||||
return (0, dom_serializer_1.default)(node, options);
|
||||
}
|
||||
exports.getOuterHTML = getOuterHTML;
|
||||
/**
|
||||
* @param node Node to get the inner HTML of.
|
||||
* @param options Options for serialization.
|
||||
* @deprecated Use the `dom-serializer` module directly.
|
||||
* @returns `node`'s inner HTML.
|
||||
*/
|
||||
function getInnerHTML(node, options) {
|
||||
return (0, domhandler_1.hasChildren)(node)
|
||||
? node.children.map(function (node) { return getOuterHTML(node, options); }).join("")
|
||||
: "";
|
||||
}
|
||||
exports.getInnerHTML = getInnerHTML;
|
||||
/**
|
||||
* Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags.
|
||||
*
|
||||
* @deprecated Use `textContent` instead.
|
||||
* @param node Node to get the inner text of.
|
||||
* @returns `node`'s inner text.
|
||||
*/
|
||||
function getText(node) {
|
||||
if (Array.isArray(node))
|
||||
return node.map(getText).join("");
|
||||
if ((0, domhandler_1.isTag)(node))
|
||||
return node.name === "br" ? "\n" : getText(node.children);
|
||||
if ((0, domhandler_1.isCDATA)(node))
|
||||
return getText(node.children);
|
||||
if ((0, domhandler_1.isText)(node))
|
||||
return node.data;
|
||||
return "";
|
||||
}
|
||||
exports.getText = getText;
|
||||
/**
|
||||
* Get a node's text content.
|
||||
*
|
||||
* @param node Node to get the text content of.
|
||||
* @returns `node`'s text content.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
|
||||
*/
|
||||
function textContent(node) {
|
||||
if (Array.isArray(node))
|
||||
return node.map(textContent).join("");
|
||||
if ((0, domhandler_1.hasChildren)(node) && !(0, domhandler_1.isComment)(node)) {
|
||||
return textContent(node.children);
|
||||
}
|
||||
if ((0, domhandler_1.isText)(node))
|
||||
return node.data;
|
||||
return "";
|
||||
}
|
||||
exports.textContent = textContent;
|
||||
/**
|
||||
* Get a node's inner text.
|
||||
*
|
||||
* @param node Node to get the inner text of.
|
||||
* @returns `node`'s inner text.
|
||||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText}
|
||||
*/
|
||||
function innerText(node) {
|
||||
if (Array.isArray(node))
|
||||
return node.map(innerText).join("");
|
||||
if ((0, domhandler_1.hasChildren)(node) && (node.type === domelementtype_1.ElementType.Tag || (0, domhandler_1.isCDATA)(node))) {
|
||||
return innerText(node.children);
|
||||
}
|
||||
if ((0, domhandler_1.isText)(node))
|
||||
return node.data;
|
||||
return "";
|
||||
}
|
||||
exports.innerText = innerText;
|
59
book/node_modules/web-resource-inliner/node_modules/domutils/lib/traversal.d.ts
generated
vendored
Normal file
59
book/node_modules/web-resource-inliner/node_modules/domutils/lib/traversal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import { Node, Element, NodeWithChildren } from "domhandler";
|
||||
/**
|
||||
* Get a node's children.
|
||||
*
|
||||
* @param elem Node to get the children of.
|
||||
* @returns `elem`'s children, or an empty array.
|
||||
*/
|
||||
export declare function getChildren(elem: Node): Node[];
|
||||
export declare function getParent(elem: Element): Element | null;
|
||||
export declare function getParent(elem: Node): NodeWithChildren | null;
|
||||
/**
|
||||
* Gets an elements siblings, including the element itself.
|
||||
*
|
||||
* Attempts to get the children through the element's parent first.
|
||||
* If we don't have a parent (the element is a root node),
|
||||
* we walk the element's `prev` & `next` to get all remaining nodes.
|
||||
*
|
||||
* @param elem Element to get the siblings of.
|
||||
* @returns `elem`'s siblings.
|
||||
*/
|
||||
export declare function getSiblings(elem: Node): Node[];
|
||||
/**
|
||||
* Gets an attribute from an element.
|
||||
*
|
||||
* @param elem Element to check.
|
||||
* @param name Attribute name to retrieve.
|
||||
* @returns The element's attribute value, or `undefined`.
|
||||
*/
|
||||
export declare function getAttributeValue(elem: Element, name: string): string | undefined;
|
||||
/**
|
||||
* Checks whether an element has an attribute.
|
||||
*
|
||||
* @param elem Element to check.
|
||||
* @param name Attribute name to look for.
|
||||
* @returns Returns whether `elem` has the attribute `name`.
|
||||
*/
|
||||
export declare function hasAttrib(elem: Element, name: string): boolean;
|
||||
/**
|
||||
* Get the tag name of an element.
|
||||
*
|
||||
* @param elem The element to get the name for.
|
||||
* @returns The tag name of `elem`.
|
||||
*/
|
||||
export declare function getName(elem: Element): string;
|
||||
/**
|
||||
* Returns the next element sibling of a node.
|
||||
*
|
||||
* @param elem The element to get the next sibling of.
|
||||
* @returns `elem`'s next sibling that is a tag.
|
||||
*/
|
||||
export declare function nextElementSibling(elem: Node): Element | null;
|
||||
/**
|
||||
* Returns the previous element sibling of a node.
|
||||
*
|
||||
* @param elem The element to get the previous sibling of.
|
||||
* @returns `elem`'s previous sibling that is a tag.
|
||||
*/
|
||||
export declare function prevElementSibling(elem: Node): Element | null;
|
||||
//# sourceMappingURL=traversal.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/traversal.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/lib/traversal.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../src/traversal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGpE;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAE9C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;AACzD,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAAC;AAW/D;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAe9C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,GACb,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAM9D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,GAAG,IAAI,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,GAAG,IAAI,CAI7D"}
|
117
book/node_modules/web-resource-inliner/node_modules/domutils/lib/traversal.js
generated
vendored
Normal file
117
book/node_modules/web-resource-inliner/node_modules/domutils/lib/traversal.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.prevElementSibling = exports.nextElementSibling = exports.getName = exports.hasAttrib = exports.getAttributeValue = exports.getSiblings = exports.getParent = exports.getChildren = void 0;
|
||||
var domhandler_1 = require("domhandler");
|
||||
var emptyArray = [];
|
||||
/**
|
||||
* Get a node's children.
|
||||
*
|
||||
* @param elem Node to get the children of.
|
||||
* @returns `elem`'s children, or an empty array.
|
||||
*/
|
||||
function getChildren(elem) {
|
||||
var _a;
|
||||
return (_a = elem.children) !== null && _a !== void 0 ? _a : emptyArray;
|
||||
}
|
||||
exports.getChildren = getChildren;
|
||||
/**
|
||||
* Get a node's parent.
|
||||
*
|
||||
* @param elem Node to get the parent of.
|
||||
* @returns `elem`'s parent node.
|
||||
*/
|
||||
function getParent(elem) {
|
||||
return elem.parent || null;
|
||||
}
|
||||
exports.getParent = getParent;
|
||||
/**
|
||||
* Gets an elements siblings, including the element itself.
|
||||
*
|
||||
* Attempts to get the children through the element's parent first.
|
||||
* If we don't have a parent (the element is a root node),
|
||||
* we walk the element's `prev` & `next` to get all remaining nodes.
|
||||
*
|
||||
* @param elem Element to get the siblings of.
|
||||
* @returns `elem`'s siblings.
|
||||
*/
|
||||
function getSiblings(elem) {
|
||||
var _a, _b;
|
||||
var parent = getParent(elem);
|
||||
if (parent != null)
|
||||
return getChildren(parent);
|
||||
var siblings = [elem];
|
||||
var prev = elem.prev, next = elem.next;
|
||||
while (prev != null) {
|
||||
siblings.unshift(prev);
|
||||
(_a = prev, prev = _a.prev);
|
||||
}
|
||||
while (next != null) {
|
||||
siblings.push(next);
|
||||
(_b = next, next = _b.next);
|
||||
}
|
||||
return siblings;
|
||||
}
|
||||
exports.getSiblings = getSiblings;
|
||||
/**
|
||||
* Gets an attribute from an element.
|
||||
*
|
||||
* @param elem Element to check.
|
||||
* @param name Attribute name to retrieve.
|
||||
* @returns The element's attribute value, or `undefined`.
|
||||
*/
|
||||
function getAttributeValue(elem, name) {
|
||||
var _a;
|
||||
return (_a = elem.attribs) === null || _a === void 0 ? void 0 : _a[name];
|
||||
}
|
||||
exports.getAttributeValue = getAttributeValue;
|
||||
/**
|
||||
* Checks whether an element has an attribute.
|
||||
*
|
||||
* @param elem Element to check.
|
||||
* @param name Attribute name to look for.
|
||||
* @returns Returns whether `elem` has the attribute `name`.
|
||||
*/
|
||||
function hasAttrib(elem, name) {
|
||||
return (elem.attribs != null &&
|
||||
Object.prototype.hasOwnProperty.call(elem.attribs, name) &&
|
||||
elem.attribs[name] != null);
|
||||
}
|
||||
exports.hasAttrib = hasAttrib;
|
||||
/**
|
||||
* Get the tag name of an element.
|
||||
*
|
||||
* @param elem The element to get the name for.
|
||||
* @returns The tag name of `elem`.
|
||||
*/
|
||||
function getName(elem) {
|
||||
return elem.name;
|
||||
}
|
||||
exports.getName = getName;
|
||||
/**
|
||||
* Returns the next element sibling of a node.
|
||||
*
|
||||
* @param elem The element to get the next sibling of.
|
||||
* @returns `elem`'s next sibling that is a tag.
|
||||
*/
|
||||
function nextElementSibling(elem) {
|
||||
var _a;
|
||||
var next = elem.next;
|
||||
while (next !== null && !(0, domhandler_1.isTag)(next))
|
||||
(_a = next, next = _a.next);
|
||||
return next;
|
||||
}
|
||||
exports.nextElementSibling = nextElementSibling;
|
||||
/**
|
||||
* Returns the previous element sibling of a node.
|
||||
*
|
||||
* @param elem The element to get the previous sibling of.
|
||||
* @returns `elem`'s previous sibling that is a tag.
|
||||
*/
|
||||
function prevElementSibling(elem) {
|
||||
var _a;
|
||||
var prev = elem.prev;
|
||||
while (prev !== null && !(0, domhandler_1.isTag)(prev))
|
||||
(_a = prev, prev = _a.prev);
|
||||
return prev;
|
||||
}
|
||||
exports.prevElementSibling = prevElementSibling;
|
11
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/LICENSE
generated
vendored
Normal file
11
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
Copyright (c) Felix Böhm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
85
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/index.d.ts
generated
vendored
Normal file
85
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { Node, Element, DataNode, NodeWithChildren, Document } from "./node";
|
||||
export * from "./node";
|
||||
export interface DomHandlerOptions {
|
||||
/**
|
||||
* Add a `startIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
||||
* indicating the position of the start of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withStartIndices?: boolean;
|
||||
/**
|
||||
* Add an `endIndex` property to nodes.
|
||||
* When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
||||
* indicating the position of the end of the node in the document.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
withEndIndices?: boolean;
|
||||
/**
|
||||
* Replace all whitespace with single spaces.
|
||||
*
|
||||
* **Note:** Enabling this might break your markup.
|
||||
*
|
||||
* @default false
|
||||
* @deprecated
|
||||
*/
|
||||
normalizeWhitespace?: boolean;
|
||||
/**
|
||||
* Treat the markup as XML.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
xmlMode?: boolean;
|
||||
}
|
||||
interface ParserInterface {
|
||||
startIndex: number | null;
|
||||
endIndex: number | null;
|
||||
}
|
||||
declare type Callback = (error: Error | null, dom: Node[]) => void;
|
||||
declare type ElementCallback = (element: Element) => void;
|
||||
export declare class DomHandler {
|
||||
/** The elements of the DOM */
|
||||
dom: Node[];
|
||||
/** The root element for the DOM */
|
||||
root: Document;
|
||||
/** Called once parsing has completed. */
|
||||
private readonly callback;
|
||||
/** Settings for the handler. */
|
||||
private readonly options;
|
||||
/** Callback whenever a tag is closed. */
|
||||
private readonly elementCB;
|
||||
/** Indicated whether parsing has been completed. */
|
||||
private done;
|
||||
/** Stack of open tags. */
|
||||
protected tagStack: NodeWithChildren[];
|
||||
/** A data node that is still being written to. */
|
||||
protected lastNode: DataNode | null;
|
||||
/** Reference to the parser instance. Used for location information. */
|
||||
private parser;
|
||||
/**
|
||||
* @param callback Called once parsing has completed.
|
||||
* @param options Settings for the handler.
|
||||
* @param elementCB Callback whenever a tag is closed.
|
||||
*/
|
||||
constructor(callback?: Callback | null, options?: DomHandlerOptions | null, elementCB?: ElementCallback);
|
||||
onparserinit(parser: ParserInterface): void;
|
||||
onreset(): void;
|
||||
onend(): void;
|
||||
onerror(error: Error): void;
|
||||
onclosetag(): void;
|
||||
onopentag(name: string, attribs: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
ontext(data: string): void;
|
||||
oncomment(data: string): void;
|
||||
oncommentend(): void;
|
||||
oncdatastart(): void;
|
||||
oncdataend(): void;
|
||||
onprocessinginstruction(name: string, data: string): void;
|
||||
protected handleCallback(error: Error | null): void;
|
||||
protected addNode(node: Node): void;
|
||||
}
|
||||
export default DomHandler;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/index.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,IAAI,EACJ,OAAO,EACP,QAAQ,EAGR,gBAAgB,EAChB,QAAQ,EAEX,MAAM,QAAQ,CAAC;AAEhB,cAAc,QAAQ,CAAC;AAIvB,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAUD,UAAU,eAAe;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,aAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;AAC3D,aAAK,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAElD,qBAAa,UAAU;IACnB,8BAA8B;IACvB,GAAG,EAAE,IAAI,EAAE,CAAM;IAExB,mCAAmC;IAC5B,IAAI,WAA0B;IAErC,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAE3C,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAE5C,yCAAyC;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IAEnD,oDAAoD;IACpD,OAAO,CAAC,IAAI,CAAS;IAErB,0BAA0B;IAC1B,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,CAAe;IAErD,kDAAkD;IAClD,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAQ;IAE3C,uEAAuE;IACvE,OAAO,CAAC,MAAM,CAAgC;IAE9C;;;;OAIG;gBAEC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,EAC1B,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAClC,SAAS,CAAC,EAAE,eAAe;IAiBxB,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAK3C,OAAO,IAAI,IAAI;IAUf,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAI3B,UAAU,IAAI,IAAI;IAYlB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI;IAOjE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA2B1B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAW7B,YAAY,IAAI,IAAI;IAIpB,YAAY,IAAI,IAAI;IAUpB,UAAU,IAAI,IAAI;IAIlB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAKhE,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAQnD,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAwBtC;AAED,eAAe,UAAU,CAAC"}
|
176
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/index.js
generated
vendored
Normal file
176
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DomHandler = void 0;
|
||||
var domelementtype_1 = require("domelementtype");
|
||||
var node_1 = require("./node");
|
||||
__exportStar(require("./node"), exports);
|
||||
var reWhitespace = /\s+/g;
|
||||
// Default options
|
||||
var defaultOpts = {
|
||||
normalizeWhitespace: false,
|
||||
withStartIndices: false,
|
||||
withEndIndices: false,
|
||||
xmlMode: false,
|
||||
};
|
||||
var DomHandler = /** @class */ (function () {
|
||||
/**
|
||||
* @param callback Called once parsing has completed.
|
||||
* @param options Settings for the handler.
|
||||
* @param elementCB Callback whenever a tag is closed.
|
||||
*/
|
||||
function DomHandler(callback, options, elementCB) {
|
||||
/** The elements of the DOM */
|
||||
this.dom = [];
|
||||
/** The root element for the DOM */
|
||||
this.root = new node_1.Document(this.dom);
|
||||
/** Indicated whether parsing has been completed. */
|
||||
this.done = false;
|
||||
/** Stack of open tags. */
|
||||
this.tagStack = [this.root];
|
||||
/** A data node that is still being written to. */
|
||||
this.lastNode = null;
|
||||
/** Reference to the parser instance. Used for location information. */
|
||||
this.parser = null;
|
||||
// Make it possible to skip arguments, for backwards-compatibility
|
||||
if (typeof options === "function") {
|
||||
elementCB = options;
|
||||
options = defaultOpts;
|
||||
}
|
||||
if (typeof callback === "object") {
|
||||
options = callback;
|
||||
callback = undefined;
|
||||
}
|
||||
this.callback = callback !== null && callback !== void 0 ? callback : null;
|
||||
this.options = options !== null && options !== void 0 ? options : defaultOpts;
|
||||
this.elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
|
||||
}
|
||||
DomHandler.prototype.onparserinit = function (parser) {
|
||||
this.parser = parser;
|
||||
};
|
||||
// Resets the handler back to starting state
|
||||
DomHandler.prototype.onreset = function () {
|
||||
this.dom = [];
|
||||
this.root = new node_1.Document(this.dom);
|
||||
this.done = false;
|
||||
this.tagStack = [this.root];
|
||||
this.lastNode = null;
|
||||
this.parser = null;
|
||||
};
|
||||
// Signals the handler that parsing is done
|
||||
DomHandler.prototype.onend = function () {
|
||||
if (this.done)
|
||||
return;
|
||||
this.done = true;
|
||||
this.parser = null;
|
||||
this.handleCallback(null);
|
||||
};
|
||||
DomHandler.prototype.onerror = function (error) {
|
||||
this.handleCallback(error);
|
||||
};
|
||||
DomHandler.prototype.onclosetag = function () {
|
||||
this.lastNode = null;
|
||||
var elem = this.tagStack.pop();
|
||||
if (this.options.withEndIndices) {
|
||||
elem.endIndex = this.parser.endIndex;
|
||||
}
|
||||
if (this.elementCB)
|
||||
this.elementCB(elem);
|
||||
};
|
||||
DomHandler.prototype.onopentag = function (name, attribs) {
|
||||
var type = this.options.xmlMode ? domelementtype_1.ElementType.Tag : undefined;
|
||||
var element = new node_1.Element(name, attribs, undefined, type);
|
||||
this.addNode(element);
|
||||
this.tagStack.push(element);
|
||||
};
|
||||
DomHandler.prototype.ontext = function (data) {
|
||||
var normalizeWhitespace = this.options.normalizeWhitespace;
|
||||
var lastNode = this.lastNode;
|
||||
if (lastNode && lastNode.type === domelementtype_1.ElementType.Text) {
|
||||
if (normalizeWhitespace) {
|
||||
lastNode.data = (lastNode.data + data).replace(reWhitespace, " ");
|
||||
}
|
||||
else {
|
||||
lastNode.data += data;
|
||||
}
|
||||
if (this.options.withEndIndices) {
|
||||
lastNode.endIndex = this.parser.endIndex;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (normalizeWhitespace) {
|
||||
data = data.replace(reWhitespace, " ");
|
||||
}
|
||||
var node = new node_1.Text(data);
|
||||
this.addNode(node);
|
||||
this.lastNode = node;
|
||||
}
|
||||
};
|
||||
DomHandler.prototype.oncomment = function (data) {
|
||||
if (this.lastNode && this.lastNode.type === domelementtype_1.ElementType.Comment) {
|
||||
this.lastNode.data += data;
|
||||
return;
|
||||
}
|
||||
var node = new node_1.Comment(data);
|
||||
this.addNode(node);
|
||||
this.lastNode = node;
|
||||
};
|
||||
DomHandler.prototype.oncommentend = function () {
|
||||
this.lastNode = null;
|
||||
};
|
||||
DomHandler.prototype.oncdatastart = function () {
|
||||
var text = new node_1.Text("");
|
||||
var node = new node_1.NodeWithChildren(domelementtype_1.ElementType.CDATA, [text]);
|
||||
this.addNode(node);
|
||||
text.parent = node;
|
||||
this.lastNode = text;
|
||||
};
|
||||
DomHandler.prototype.oncdataend = function () {
|
||||
this.lastNode = null;
|
||||
};
|
||||
DomHandler.prototype.onprocessinginstruction = function (name, data) {
|
||||
var node = new node_1.ProcessingInstruction(name, data);
|
||||
this.addNode(node);
|
||||
};
|
||||
DomHandler.prototype.handleCallback = function (error) {
|
||||
if (typeof this.callback === "function") {
|
||||
this.callback(error, this.dom);
|
||||
}
|
||||
else if (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
DomHandler.prototype.addNode = function (node) {
|
||||
var parent = this.tagStack[this.tagStack.length - 1];
|
||||
var previousSibling = parent.children[parent.children.length - 1];
|
||||
if (this.options.withStartIndices) {
|
||||
node.startIndex = this.parser.startIndex;
|
||||
}
|
||||
if (this.options.withEndIndices) {
|
||||
node.endIndex = this.parser.endIndex;
|
||||
}
|
||||
parent.children.push(node);
|
||||
if (previousSibling) {
|
||||
node.prev = previousSibling;
|
||||
previousSibling.next = node;
|
||||
}
|
||||
node.parent = parent;
|
||||
this.lastNode = null;
|
||||
};
|
||||
return DomHandler;
|
||||
}());
|
||||
exports.DomHandler = DomHandler;
|
||||
exports.default = DomHandler;
|
237
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/node.d.ts
generated
vendored
Normal file
237
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/node.d.ts
generated
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
import { ElementType } from "domelementtype";
|
||||
interface SourceCodeLocation {
|
||||
/** One-based line index of the first character. */
|
||||
startLine: number;
|
||||
/** One-based column index of the first character. */
|
||||
startCol: number;
|
||||
/** Zero-based first character index. */
|
||||
startOffset: number;
|
||||
/** One-based line index of the last character. */
|
||||
endLine: number;
|
||||
/** One-based column index of the last character. Points directly *after* the last character. */
|
||||
endCol: number;
|
||||
/** Zero-based last character index. Points directly *after* the last character. */
|
||||
endOffset: number;
|
||||
}
|
||||
interface TagSourceCodeLocation extends SourceCodeLocation {
|
||||
startTag?: SourceCodeLocation;
|
||||
endTag?: SourceCodeLocation;
|
||||
}
|
||||
/**
|
||||
* This object will be used as the prototype for Nodes when creating a
|
||||
* DOM-Level-1-compliant structure.
|
||||
*/
|
||||
export declare class Node {
|
||||
type: ElementType;
|
||||
/** Parent of the node */
|
||||
parent: NodeWithChildren | null;
|
||||
/** Previous sibling */
|
||||
prev: Node | null;
|
||||
/** Next sibling */
|
||||
next: Node | null;
|
||||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
||||
startIndex: number | null;
|
||||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
||||
endIndex: number | null;
|
||||
/**
|
||||
* `parse5` source code location info.
|
||||
*
|
||||
* Available if parsing with parse5 and location info is enabled.
|
||||
*/
|
||||
sourceCodeLocation?: SourceCodeLocation | null;
|
||||
/**
|
||||
*
|
||||
* @param type The type of the node.
|
||||
*/
|
||||
constructor(type: ElementType);
|
||||
/**
|
||||
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
||||
* node {@link type}.
|
||||
*/
|
||||
get nodeType(): number;
|
||||
/**
|
||||
* Same as {@link parent}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get parentNode(): NodeWithChildren | null;
|
||||
set parentNode(parent: NodeWithChildren | null);
|
||||
/**
|
||||
* Same as {@link prev}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get previousSibling(): Node | null;
|
||||
set previousSibling(prev: Node | null);
|
||||
/**
|
||||
* Same as {@link next}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get nextSibling(): Node | null;
|
||||
set nextSibling(next: Node | null);
|
||||
/**
|
||||
* Clone this node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
||||
}
|
||||
/**
|
||||
* A node that contains some data.
|
||||
*/
|
||||
export declare class DataNode extends Node {
|
||||
data: string;
|
||||
/**
|
||||
* @param type The type of the node
|
||||
* @param data The content of the data node
|
||||
*/
|
||||
constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
|
||||
/**
|
||||
* Same as {@link data}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get nodeValue(): string;
|
||||
set nodeValue(data: string);
|
||||
}
|
||||
/**
|
||||
* Text within the document.
|
||||
*/
|
||||
export declare class Text extends DataNode {
|
||||
constructor(data: string);
|
||||
}
|
||||
/**
|
||||
* Comments within the document.
|
||||
*/
|
||||
export declare class Comment extends DataNode {
|
||||
constructor(data: string);
|
||||
}
|
||||
/**
|
||||
* Processing instructions, including doc types.
|
||||
*/
|
||||
export declare class ProcessingInstruction extends DataNode {
|
||||
name: string;
|
||||
constructor(name: string, data: string);
|
||||
/** If this is a doctype, the document type name (parse5 only). */
|
||||
"x-name"?: string;
|
||||
/** If this is a doctype, the document type public identifier (parse5 only). */
|
||||
"x-publicId"?: string;
|
||||
/** If this is a doctype, the document type system identifier (parse5 only). */
|
||||
"x-systemId"?: string;
|
||||
}
|
||||
/**
|
||||
* A `Node` that can have children.
|
||||
*/
|
||||
export declare class NodeWithChildren extends Node {
|
||||
children: Node[];
|
||||
/**
|
||||
* @param type Type of the node.
|
||||
* @param children Children of the node. Only certain node types can have children.
|
||||
*/
|
||||
constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
|
||||
/** First child of the node. */
|
||||
get firstChild(): Node | null;
|
||||
/** Last child of the node. */
|
||||
get lastChild(): Node | null;
|
||||
/**
|
||||
* Same as {@link children}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get childNodes(): Node[];
|
||||
set childNodes(children: Node[]);
|
||||
}
|
||||
/**
|
||||
* The root node of the document.
|
||||
*/
|
||||
export declare class Document extends NodeWithChildren {
|
||||
constructor(children: Node[]);
|
||||
/** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
|
||||
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
||||
}
|
||||
/**
|
||||
* The description of an individual attribute.
|
||||
*/
|
||||
interface Attribute {
|
||||
name: string;
|
||||
value: string;
|
||||
namespace?: string;
|
||||
prefix?: string;
|
||||
}
|
||||
/**
|
||||
* An element within the DOM.
|
||||
*/
|
||||
export declare class Element extends NodeWithChildren {
|
||||
name: string;
|
||||
attribs: {
|
||||
[name: string]: string;
|
||||
};
|
||||
/**
|
||||
* @param name Name of the tag, eg. `div`, `span`.
|
||||
* @param attribs Object mapping attribute names to attribute values.
|
||||
* @param children Children of the node.
|
||||
*/
|
||||
constructor(name: string, attribs: {
|
||||
[name: string]: string;
|
||||
}, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
||||
/**
|
||||
* `parse5` source code location info, with start & end tags.
|
||||
*
|
||||
* Available if parsing with parse5 and location info is enabled.
|
||||
*/
|
||||
sourceCodeLocation?: TagSourceCodeLocation | null;
|
||||
/**
|
||||
* Same as {@link name}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get tagName(): string;
|
||||
set tagName(name: string);
|
||||
get attributes(): Attribute[];
|
||||
/** Element namespace (parse5 only). */
|
||||
namespace?: string;
|
||||
/** Element attribute namespaces (parse5 only). */
|
||||
"x-attribsNamespace"?: Record<string, string>;
|
||||
/** Element attribute namespace-related prefixes (parse5 only). */
|
||||
"x-attribsPrefix"?: Record<string, string>;
|
||||
}
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `Element`, `false` otherwise.
|
||||
*/
|
||||
export declare function isTag(node: Node): node is Element;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
||||
*/
|
||||
export declare function isCDATA(node: Node): node is NodeWithChildren;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
||||
*/
|
||||
export declare function isText(node: Node): node is Text;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
||||
*/
|
||||
export declare function isComment(node: Node): node is DataNode;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
export declare function isDirective(node: Node): node is ProcessingInstruction;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
export declare function isDocument(node: Node): node is Document;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
|
||||
*/
|
||||
export declare function hasChildren(node: Node): node is NodeWithChildren;
|
||||
/**
|
||||
* Clone a node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
|
||||
export {};
|
||||
//# sourceMappingURL=node.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/node.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/node.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,gBAAgB,CAAC;AAahE,UAAU,kBAAkB;IACxB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,MAAM,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,qBAAsB,SAAQ,kBAAkB;IACtD,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED;;;GAGG;AACH,qBAAa,IAAI;IA2BM,IAAI,EAAE,WAAW;IA1BpC,yBAAyB;IACzB,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IAEvC,uBAAuB;IACvB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEzB,mBAAmB;IACnB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEzB,2FAA2F;IAC3F,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEjC,uFAAuF;IACvF,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAE/C;;;OAGG;gBACgB,IAAI,EAAE,WAAW;IAIpC;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAID;;;OAGG;IACH,IAAI,UAAU,IAAI,gBAAgB,GAAG,IAAI,CAExC;IAED,IAAI,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,EAE7C;IAED;;;OAGG;IACH,IAAI,eAAe,IAAI,IAAI,GAAG,IAAI,CAEjC;IAED,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAEpC;IAED;;;OAGG;IACH,IAAI,WAAW,IAAI,IAAI,GAAG,IAAI,CAE7B;IAED,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAEhC;IAED;;;;;OAKG;IACH,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,UAAQ,GAAG,CAAC;CAG3D;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,IAAI;IAOnB,IAAI,EAAE,MAAM;IANvB;;;OAGG;gBAEC,IAAI,EAAE,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,EAC7D,IAAI,EAAE,MAAM;IAKvB;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,SAAS,CAAC,IAAI,EAAE,MAAM,EAEzB;CACJ;AAED;;GAEG;AACH,qBAAa,IAAK,SAAQ,QAAQ;gBAClB,IAAI,EAAE,MAAM;CAG3B;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,QAAQ;gBACrB,IAAI,EAAE,MAAM;CAG3B;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,QAAQ;IAC5B,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAI7C,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,IAAI;IAY3B,QAAQ,EAAE,IAAI,EAAE;IAX3B;;;OAGG;gBAEC,IAAI,EACE,WAAW,CAAC,IAAI,GAChB,WAAW,CAAC,KAAK,GACjB,WAAW,CAAC,MAAM,GAClB,WAAW,CAAC,KAAK,GACjB,WAAW,CAAC,GAAG,EACd,QAAQ,EAAE,IAAI,EAAE;IAM3B,+BAA+B;IAC/B,IAAI,UAAU,IAAI,IAAI,GAAG,IAAI,CAE5B;IAED,8BAA8B;IAC9B,IAAI,SAAS,IAAI,IAAI,GAAG,IAAI,CAI3B;IAED;;;OAGG;IACH,IAAI,UAAU,IAAI,IAAI,EAAE,CAEvB;IAED,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,EAE9B;CACJ;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,gBAAgB;gBAC9B,QAAQ,EAAE,IAAI,EAAE;IAI5B,mGAAmG;IACnG,QAAQ,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,gBAAgB,CAAC;CACxD;AAED;;GAEG;AACH,UAAU,SAAS;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,gBAAgB;IAO9B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAP9C;;;;OAIG;gBAEQ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAC1C,QAAQ,GAAE,IAAI,EAAO,EACrB,IAAI,GACE,WAAW,CAAC,GAAG,GACf,WAAW,CAAC,MAAM,GAClB,WAAW,CAAC,KAIG;IAKzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAIlD;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,EAEvB;IAED,IAAI,UAAU,IAAI,SAAS,EAAE,CAO5B;IAED,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,OAAO,CAEjD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,gBAAgB,CAE5D;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,CAE/C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,QAAQ,CAEtD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,qBAAqB,CAErE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,QAAQ,CAEvD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,gBAAgB,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,UAAQ,GAAG,CAAC,CA4DvE"}
|
444
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/node.js
generated
vendored
Normal file
444
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/lib/node.js
generated
vendored
Normal file
@@ -0,0 +1,444 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cloneNode = exports.hasChildren = exports.isDocument = exports.isDirective = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = exports.Element = exports.Document = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;
|
||||
var domelementtype_1 = require("domelementtype");
|
||||
var nodeTypes = new Map([
|
||||
[domelementtype_1.ElementType.Tag, 1],
|
||||
[domelementtype_1.ElementType.Script, 1],
|
||||
[domelementtype_1.ElementType.Style, 1],
|
||||
[domelementtype_1.ElementType.Directive, 1],
|
||||
[domelementtype_1.ElementType.Text, 3],
|
||||
[domelementtype_1.ElementType.CDATA, 4],
|
||||
[domelementtype_1.ElementType.Comment, 8],
|
||||
[domelementtype_1.ElementType.Root, 9],
|
||||
]);
|
||||
/**
|
||||
* This object will be used as the prototype for Nodes when creating a
|
||||
* DOM-Level-1-compliant structure.
|
||||
*/
|
||||
var Node = /** @class */ (function () {
|
||||
/**
|
||||
*
|
||||
* @param type The type of the node.
|
||||
*/
|
||||
function Node(type) {
|
||||
this.type = type;
|
||||
/** Parent of the node */
|
||||
this.parent = null;
|
||||
/** Previous sibling */
|
||||
this.prev = null;
|
||||
/** Next sibling */
|
||||
this.next = null;
|
||||
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
||||
this.startIndex = null;
|
||||
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
||||
this.endIndex = null;
|
||||
}
|
||||
Object.defineProperty(Node.prototype, "nodeType", {
|
||||
// Read-only aliases
|
||||
/**
|
||||
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
||||
* node {@link type}.
|
||||
*/
|
||||
get: function () {
|
||||
var _a;
|
||||
return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "parentNode", {
|
||||
// Read-write aliases for properties
|
||||
/**
|
||||
* Same as {@link parent}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.parent;
|
||||
},
|
||||
set: function (parent) {
|
||||
this.parent = parent;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "previousSibling", {
|
||||
/**
|
||||
* Same as {@link prev}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.prev;
|
||||
},
|
||||
set: function (prev) {
|
||||
this.prev = prev;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Node.prototype, "nextSibling", {
|
||||
/**
|
||||
* Same as {@link next}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.next;
|
||||
},
|
||||
set: function (next) {
|
||||
this.next = next;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/**
|
||||
* Clone this node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
Node.prototype.cloneNode = function (recursive) {
|
||||
if (recursive === void 0) { recursive = false; }
|
||||
return cloneNode(this, recursive);
|
||||
};
|
||||
return Node;
|
||||
}());
|
||||
exports.Node = Node;
|
||||
/**
|
||||
* A node that contains some data.
|
||||
*/
|
||||
var DataNode = /** @class */ (function (_super) {
|
||||
__extends(DataNode, _super);
|
||||
/**
|
||||
* @param type The type of the node
|
||||
* @param data The content of the data node
|
||||
*/
|
||||
function DataNode(type, data) {
|
||||
var _this = _super.call(this, type) || this;
|
||||
_this.data = data;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(DataNode.prototype, "nodeValue", {
|
||||
/**
|
||||
* Same as {@link data}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.data;
|
||||
},
|
||||
set: function (data) {
|
||||
this.data = data;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return DataNode;
|
||||
}(Node));
|
||||
exports.DataNode = DataNode;
|
||||
/**
|
||||
* Text within the document.
|
||||
*/
|
||||
var Text = /** @class */ (function (_super) {
|
||||
__extends(Text, _super);
|
||||
function Text(data) {
|
||||
return _super.call(this, domelementtype_1.ElementType.Text, data) || this;
|
||||
}
|
||||
return Text;
|
||||
}(DataNode));
|
||||
exports.Text = Text;
|
||||
/**
|
||||
* Comments within the document.
|
||||
*/
|
||||
var Comment = /** @class */ (function (_super) {
|
||||
__extends(Comment, _super);
|
||||
function Comment(data) {
|
||||
return _super.call(this, domelementtype_1.ElementType.Comment, data) || this;
|
||||
}
|
||||
return Comment;
|
||||
}(DataNode));
|
||||
exports.Comment = Comment;
|
||||
/**
|
||||
* Processing instructions, including doc types.
|
||||
*/
|
||||
var ProcessingInstruction = /** @class */ (function (_super) {
|
||||
__extends(ProcessingInstruction, _super);
|
||||
function ProcessingInstruction(name, data) {
|
||||
var _this = _super.call(this, domelementtype_1.ElementType.Directive, data) || this;
|
||||
_this.name = name;
|
||||
return _this;
|
||||
}
|
||||
return ProcessingInstruction;
|
||||
}(DataNode));
|
||||
exports.ProcessingInstruction = ProcessingInstruction;
|
||||
/**
|
||||
* A `Node` that can have children.
|
||||
*/
|
||||
var NodeWithChildren = /** @class */ (function (_super) {
|
||||
__extends(NodeWithChildren, _super);
|
||||
/**
|
||||
* @param type Type of the node.
|
||||
* @param children Children of the node. Only certain node types can have children.
|
||||
*/
|
||||
function NodeWithChildren(type, children) {
|
||||
var _this = _super.call(this, type) || this;
|
||||
_this.children = children;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
|
||||
// Aliases
|
||||
/** First child of the node. */
|
||||
get: function () {
|
||||
var _a;
|
||||
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
|
||||
/** Last child of the node. */
|
||||
get: function () {
|
||||
return this.children.length > 0
|
||||
? this.children[this.children.length - 1]
|
||||
: null;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
|
||||
/**
|
||||
* Same as {@link children}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.children;
|
||||
},
|
||||
set: function (children) {
|
||||
this.children = children;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return NodeWithChildren;
|
||||
}(Node));
|
||||
exports.NodeWithChildren = NodeWithChildren;
|
||||
/**
|
||||
* The root node of the document.
|
||||
*/
|
||||
var Document = /** @class */ (function (_super) {
|
||||
__extends(Document, _super);
|
||||
function Document(children) {
|
||||
return _super.call(this, domelementtype_1.ElementType.Root, children) || this;
|
||||
}
|
||||
return Document;
|
||||
}(NodeWithChildren));
|
||||
exports.Document = Document;
|
||||
/**
|
||||
* An element within the DOM.
|
||||
*/
|
||||
var Element = /** @class */ (function (_super) {
|
||||
__extends(Element, _super);
|
||||
/**
|
||||
* @param name Name of the tag, eg. `div`, `span`.
|
||||
* @param attribs Object mapping attribute names to attribute values.
|
||||
* @param children Children of the node.
|
||||
*/
|
||||
function Element(name, attribs, children, type) {
|
||||
if (children === void 0) { children = []; }
|
||||
if (type === void 0) { type = name === "script"
|
||||
? domelementtype_1.ElementType.Script
|
||||
: name === "style"
|
||||
? domelementtype_1.ElementType.Style
|
||||
: domelementtype_1.ElementType.Tag; }
|
||||
var _this = _super.call(this, type, children) || this;
|
||||
_this.name = name;
|
||||
_this.attribs = attribs;
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(Element.prototype, "tagName", {
|
||||
// DOM Level 1 aliases
|
||||
/**
|
||||
* Same as {@link name}.
|
||||
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
||||
*/
|
||||
get: function () {
|
||||
return this.name;
|
||||
},
|
||||
set: function (name) {
|
||||
this.name = name;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Element.prototype, "attributes", {
|
||||
get: function () {
|
||||
var _this = this;
|
||||
return Object.keys(this.attribs).map(function (name) {
|
||||
var _a, _b;
|
||||
return ({
|
||||
name: name,
|
||||
value: _this.attribs[name],
|
||||
namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
|
||||
prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
|
||||
});
|
||||
});
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return Element;
|
||||
}(NodeWithChildren));
|
||||
exports.Element = Element;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `Element`, `false` otherwise.
|
||||
*/
|
||||
function isTag(node) {
|
||||
return (0, domelementtype_1.isTag)(node);
|
||||
}
|
||||
exports.isTag = isTag;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
||||
*/
|
||||
function isCDATA(node) {
|
||||
return node.type === domelementtype_1.ElementType.CDATA;
|
||||
}
|
||||
exports.isCDATA = isCDATA;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
||||
*/
|
||||
function isText(node) {
|
||||
return node.type === domelementtype_1.ElementType.Text;
|
||||
}
|
||||
exports.isText = isText;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
||||
*/
|
||||
function isComment(node) {
|
||||
return node.type === domelementtype_1.ElementType.Comment;
|
||||
}
|
||||
exports.isComment = isComment;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
function isDirective(node) {
|
||||
return node.type === domelementtype_1.ElementType.Directive;
|
||||
}
|
||||
exports.isDirective = isDirective;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
||||
*/
|
||||
function isDocument(node) {
|
||||
return node.type === domelementtype_1.ElementType.Root;
|
||||
}
|
||||
exports.isDocument = isDocument;
|
||||
/**
|
||||
* @param node Node to check.
|
||||
* @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
|
||||
*/
|
||||
function hasChildren(node) {
|
||||
return Object.prototype.hasOwnProperty.call(node, "children");
|
||||
}
|
||||
exports.hasChildren = hasChildren;
|
||||
/**
|
||||
* Clone a node, and optionally its children.
|
||||
*
|
||||
* @param recursive Clone child nodes as well.
|
||||
* @returns A clone of the node.
|
||||
*/
|
||||
function cloneNode(node, recursive) {
|
||||
if (recursive === void 0) { recursive = false; }
|
||||
var result;
|
||||
if (isText(node)) {
|
||||
result = new Text(node.data);
|
||||
}
|
||||
else if (isComment(node)) {
|
||||
result = new Comment(node.data);
|
||||
}
|
||||
else if (isTag(node)) {
|
||||
var children = recursive ? cloneChildren(node.children) : [];
|
||||
var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
|
||||
children.forEach(function (child) { return (child.parent = clone_1); });
|
||||
if (node.namespace != null) {
|
||||
clone_1.namespace = node.namespace;
|
||||
}
|
||||
if (node["x-attribsNamespace"]) {
|
||||
clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
|
||||
}
|
||||
if (node["x-attribsPrefix"]) {
|
||||
clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
|
||||
}
|
||||
result = clone_1;
|
||||
}
|
||||
else if (isCDATA(node)) {
|
||||
var children = recursive ? cloneChildren(node.children) : [];
|
||||
var clone_2 = new NodeWithChildren(domelementtype_1.ElementType.CDATA, children);
|
||||
children.forEach(function (child) { return (child.parent = clone_2); });
|
||||
result = clone_2;
|
||||
}
|
||||
else if (isDocument(node)) {
|
||||
var children = recursive ? cloneChildren(node.children) : [];
|
||||
var clone_3 = new Document(children);
|
||||
children.forEach(function (child) { return (child.parent = clone_3); });
|
||||
if (node["x-mode"]) {
|
||||
clone_3["x-mode"] = node["x-mode"];
|
||||
}
|
||||
result = clone_3;
|
||||
}
|
||||
else if (isDirective(node)) {
|
||||
var instruction = new ProcessingInstruction(node.name, node.data);
|
||||
if (node["x-name"] != null) {
|
||||
instruction["x-name"] = node["x-name"];
|
||||
instruction["x-publicId"] = node["x-publicId"];
|
||||
instruction["x-systemId"] = node["x-systemId"];
|
||||
}
|
||||
result = instruction;
|
||||
}
|
||||
else {
|
||||
throw new Error("Not implemented yet: ".concat(node.type));
|
||||
}
|
||||
result.startIndex = node.startIndex;
|
||||
result.endIndex = node.endIndex;
|
||||
if (node.sourceCodeLocation != null) {
|
||||
result.sourceCodeLocation = node.sourceCodeLocation;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.cloneNode = cloneNode;
|
||||
function cloneChildren(childs) {
|
||||
var children = childs.map(function (child) { return cloneNode(child, true); });
|
||||
for (var i = 1; i < children.length; i++) {
|
||||
children[i].prev = children[i - 1];
|
||||
children[i - 1].next = children[i];
|
||||
}
|
||||
return children;
|
||||
}
|
58
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/package.json
generated
vendored
Normal file
58
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "domhandler",
|
||||
"version": "4.3.1",
|
||||
"description": "Handler for htmlparser2 that turns pages into a dom",
|
||||
"author": "Felix Boehm <me@feedic.com>",
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domhandler?sponsor=1"
|
||||
},
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run test:jest && npm run lint",
|
||||
"test:jest": "jest",
|
||||
"lint": "eslint src",
|
||||
"format": "prettier --write '**/*.{ts,md,json}'",
|
||||
"build": "tsc",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/fb55/domhandler.git"
|
||||
},
|
||||
"keywords": [
|
||||
"dom",
|
||||
"htmlparser2"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
},
|
||||
"dependencies": {
|
||||
"domelementtype": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.4.1",
|
||||
"@types/node": "^17.0.21",
|
||||
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
||||
"@typescript-eslint/parser": "^5.15.0",
|
||||
"eslint": "^8.11.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"htmlparser2": "^7.2.0",
|
||||
"jest": "^27.5.1",
|
||||
"prettier": "^2.6.0",
|
||||
"ts-jest": "^27.1.3",
|
||||
"typescript": "^4.6.2"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 4
|
||||
}
|
||||
}
|
163
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/readme.md
generated
vendored
Normal file
163
book/node_modules/web-resource-inliner/node_modules/domutils/node_modules/domhandler/readme.md
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
# domhandler [](https://travis-ci.com/fb55/domhandler)
|
||||
|
||||
The DOM handler creates a tree containing all nodes of a page.
|
||||
The tree can be manipulated using the [domutils](https://github.com/fb55/domutils)
|
||||
or [cheerio](https://github.com/cheeriojs/cheerio) libraries and
|
||||
rendered using [dom-serializer](https://github.com/cheeriojs/dom-serializer) .
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
const handler = new DomHandler([ <func> callback(err, dom), ] [ <obj> options ]);
|
||||
// const parser = new Parser(handler[, options]);
|
||||
```
|
||||
|
||||
Available options are described below.
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
const { Parser } = require("htmlparser2");
|
||||
const { DomHandler } = require("domhandler");
|
||||
const rawHtml =
|
||||
"Xyz <script language= javascript>var foo = '<<bar>>';</script><!--<!-- Waah! -- -->";
|
||||
const handler = new DomHandler((error, dom) => {
|
||||
if (error) {
|
||||
// Handle error
|
||||
} else {
|
||||
// Parsing completed, do something
|
||||
console.log(dom);
|
||||
}
|
||||
});
|
||||
const parser = new Parser(handler);
|
||||
parser.write(rawHtml);
|
||||
parser.end();
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
data: "Xyz ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "script",
|
||||
name: "script",
|
||||
attribs: {
|
||||
language: "javascript",
|
||||
},
|
||||
children: [
|
||||
{
|
||||
data: "var foo = '<bar>';<",
|
||||
type: "text",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
data: "<!-- Waah! -- ",
|
||||
type: "comment",
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
## Option: `withStartIndices`
|
||||
|
||||
Add a `startIndex` property to nodes.
|
||||
When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
||||
indicating the position of the start of the node in the document.
|
||||
The default value is `false`.
|
||||
|
||||
## Option: `withEndIndices`
|
||||
|
||||
Add an `endIndex` property to nodes.
|
||||
When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
||||
indicating the position of the end of the node in the document.
|
||||
The default value is `false`.
|
||||
|
||||
## Option: `normalizeWhitespace` _(deprecated)_
|
||||
|
||||
Replace all whitespace with single spaces.
|
||||
The default value is `false`.
|
||||
|
||||
**Note:** Enabling this might break your markup.
|
||||
|
||||
For the following examples, this HTML will be used:
|
||||
|
||||
```html
|
||||
<font> <br />this is the text <font></font></font>
|
||||
```
|
||||
|
||||
### Example: `normalizeWhitespace: true`
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
children: [
|
||||
{
|
||||
data: " ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "br",
|
||||
},
|
||||
{
|
||||
data: "this is the text ",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### Example: `normalizeWhitespace: false`
|
||||
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
children: [
|
||||
{
|
||||
data: "\n\t",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "br",
|
||||
},
|
||||
{
|
||||
data: "this is the text\n",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "tag",
|
||||
name: "font",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
License: BSD-2-Clause
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
## `domhandler` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of `domhandler` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-domhandler?utm_source=npm-domhandler&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
65
book/node_modules/web-resource-inliner/node_modules/domutils/package.json
generated
vendored
Normal file
65
book/node_modules/web-resource-inliner/node_modules/domutils/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"name": "domutils",
|
||||
"version": "2.8.0",
|
||||
"description": "Utilities for working with htmlparser2's dom",
|
||||
"author": "Felix Boehm <me@feedic.com>",
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/domutils?sponsor=1"
|
||||
},
|
||||
"license": "BSD-2-Clause",
|
||||
"sideEffects": false,
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib/**/*"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run test:jest && npm run lint",
|
||||
"test:jest": "jest",
|
||||
"lint": "npm run lint:es && npm run lint:prettier",
|
||||
"lint:es": "eslint --ignore-path .gitignore .",
|
||||
"lint:prettier": "npm run prettier -- --check",
|
||||
"format": "npm run format:es && npm run format:prettier",
|
||||
"format:es": "npm run lint:es -- --fix",
|
||||
"format:prettier": "npm run prettier -- --write",
|
||||
"prettier": "prettier \"**/*.{ts,md,json,yml}\" --ignore-path .gitignore",
|
||||
"build": "tsc",
|
||||
"build:docs": "typedoc --hideGenerator --exclude \"**/*+(index|.spec).ts\" src",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/fb55/domutils.git"
|
||||
},
|
||||
"keywords": [
|
||||
"dom",
|
||||
"htmlparser2"
|
||||
],
|
||||
"dependencies": {
|
||||
"dom-serializer": "^1.0.1",
|
||||
"domelementtype": "^2.2.0",
|
||||
"domhandler": "^4.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/node": "^16.7.2",
|
||||
"@typescript-eslint/eslint-plugin": "^4.29.3",
|
||||
"@typescript-eslint/parser": "^4.29.3",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-jsdoc": "^36.0.8",
|
||||
"htmlparser2": "~7.0.0",
|
||||
"jest": "^27.1.0",
|
||||
"prettier": "^2.0.5",
|
||||
"ts-jest": "^27.0.5",
|
||||
"typedoc": "^0.21.6",
|
||||
"typescript": "^4.4.2"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 4
|
||||
}
|
||||
}
|
31
book/node_modules/web-resource-inliner/node_modules/domutils/readme.md
generated
vendored
Normal file
31
book/node_modules/web-resource-inliner/node_modules/domutils/readme.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# domutils [](https://travis-ci.com/fb55/domutils)
|
||||
|
||||
Utilities for working with [htmlparser2](https://github.com/fb55/htmlparser2)'s DOM.
|
||||
|
||||
All functions are exported as a single module. Look [through the docs](https://domutils.js.org/modules.html) to see what is available.
|
||||
|
||||
## Ecosystem
|
||||
|
||||
| Name | Description |
|
||||
| ------------------------------------------------------------- | ------------------------------------------------------- |
|
||||
| [htmlparser2](https://github.com/fb55/htmlparser2) | Fast & forgiving HTML/XML parser |
|
||||
| [domhandler](https://github.com/fb55/domhandler) | Handler for htmlparser2 that turns documents into a DOM |
|
||||
| [domutils](https://github.com/fb55/domutils) | Utilities for working with domhandler's DOM |
|
||||
| [css-select](https://github.com/fb55/css-select) | CSS selector engine, compatible with domhandler's DOM |
|
||||
| [cheerio](https://github.com/cheeriojs/cheerio) | The jQuery API for domhandler's DOM |
|
||||
| [dom-serializer](https://github.com/cheeriojs/dom-serializer) | Serializer for domhandler's DOM |
|
||||
|
||||
---
|
||||
|
||||
License: BSD-2-Clause
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
## `domutils` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of `domutils` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-domutils?utm_source=npm-domutils&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
11
book/node_modules/web-resource-inliner/node_modules/entities/LICENSE
generated
vendored
Normal file
11
book/node_modules/web-resource-inliner/node_modules/entities/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
Copyright (c) Felix Böhm
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
5
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode.d.ts
generated
vendored
Normal file
5
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare const decodeXML: (str: string) => string;
|
||||
export declare const decodeHTMLStrict: (str: string) => string;
|
||||
export declare type MapType = Record<string, string>;
|
||||
export declare const decodeHTML: (str: string) => string;
|
||||
//# sourceMappingURL=decode.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS,QAOL,MAAM,WAP0B,CAAC;AAClD,eAAO,MAAM,gBAAgB,QAMZ,MAAM,WANoC,CAAC;AAE5D,oBAAY,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAS7C,eAAO,MAAM,UAAU,QAyBN,MAAM,WACnB,CAAC"}
|
53
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode.js
generated
vendored
Normal file
53
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.decodeHTML = exports.decodeHTMLStrict = exports.decodeXML = void 0;
|
||||
var entities_json_1 = __importDefault(require("./maps/entities.json"));
|
||||
var legacy_json_1 = __importDefault(require("./maps/legacy.json"));
|
||||
var xml_json_1 = __importDefault(require("./maps/xml.json"));
|
||||
var decode_codepoint_1 = __importDefault(require("./decode_codepoint"));
|
||||
var strictEntityRe = /&(?:[a-zA-Z0-9]+|#[xX][\da-fA-F]+|#\d+);/g;
|
||||
exports.decodeXML = getStrictDecoder(xml_json_1.default);
|
||||
exports.decodeHTMLStrict = getStrictDecoder(entities_json_1.default);
|
||||
function getStrictDecoder(map) {
|
||||
var replace = getReplacer(map);
|
||||
return function (str) { return String(str).replace(strictEntityRe, replace); };
|
||||
}
|
||||
var sorter = function (a, b) { return (a < b ? 1 : -1); };
|
||||
exports.decodeHTML = (function () {
|
||||
var legacy = Object.keys(legacy_json_1.default).sort(sorter);
|
||||
var keys = Object.keys(entities_json_1.default).sort(sorter);
|
||||
for (var i = 0, j = 0; i < keys.length; i++) {
|
||||
if (legacy[j] === keys[i]) {
|
||||
keys[i] += ";?";
|
||||
j++;
|
||||
}
|
||||
else {
|
||||
keys[i] += ";";
|
||||
}
|
||||
}
|
||||
var re = new RegExp("&(?:" + keys.join("|") + "|#[xX][\\da-fA-F]+;?|#\\d+;?)", "g");
|
||||
var replace = getReplacer(entities_json_1.default);
|
||||
function replacer(str) {
|
||||
if (str.substr(-1) !== ";")
|
||||
str += ";";
|
||||
return replace(str);
|
||||
}
|
||||
// TODO consider creating a merged map
|
||||
return function (str) { return String(str).replace(re, replacer); };
|
||||
})();
|
||||
function getReplacer(map) {
|
||||
return function replace(str) {
|
||||
if (str.charAt(1) === "#") {
|
||||
var secondChar = str.charAt(2);
|
||||
if (secondChar === "X" || secondChar === "x") {
|
||||
return decode_codepoint_1.default(parseInt(str.substr(3), 16));
|
||||
}
|
||||
return decode_codepoint_1.default(parseInt(str.substr(2), 10));
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
return map[str.slice(1, -1)] || str;
|
||||
};
|
||||
}
|
2
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode_codepoint.d.ts
generated
vendored
Normal file
2
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode_codepoint.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export default function decodeCodePoint(codePoint: number): string;
|
||||
//# sourceMappingURL=decode_codepoint.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode_codepoint.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode_codepoint.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"decode_codepoint.d.ts","sourceRoot":"","sources":["../src/decode_codepoint.ts"],"names":[],"mappings":"AAsBA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAUjE"}
|
30
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode_codepoint.js
generated
vendored
Normal file
30
book/node_modules/web-resource-inliner/node_modules/entities/lib/decode_codepoint.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var decode_json_1 = __importDefault(require("./maps/decode.json"));
|
||||
// Adapted from https://github.com/mathiasbynens/he/blob/master/src/he.js#L94-L119
|
||||
var fromCodePoint =
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
String.fromCodePoint ||
|
||||
function (codePoint) {
|
||||
var output = "";
|
||||
if (codePoint > 0xffff) {
|
||||
codePoint -= 0x10000;
|
||||
output += String.fromCharCode(((codePoint >>> 10) & 0x3ff) | 0xd800);
|
||||
codePoint = 0xdc00 | (codePoint & 0x3ff);
|
||||
}
|
||||
output += String.fromCharCode(codePoint);
|
||||
return output;
|
||||
};
|
||||
function decodeCodePoint(codePoint) {
|
||||
if ((codePoint >= 0xd800 && codePoint <= 0xdfff) || codePoint > 0x10ffff) {
|
||||
return "\uFFFD";
|
||||
}
|
||||
if (codePoint in decode_json_1.default) {
|
||||
codePoint = decode_json_1.default[codePoint];
|
||||
}
|
||||
return fromCodePoint(codePoint);
|
||||
}
|
||||
exports.default = decodeCodePoint;
|
47
book/node_modules/web-resource-inliner/node_modules/entities/lib/encode.d.ts
generated
vendored
Normal file
47
book/node_modules/web-resource-inliner/node_modules/entities/lib/encode.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
||||
* documents using XML entities.
|
||||
*
|
||||
* If a character has no equivalent entity, a
|
||||
* numeric hexadecimal reference (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare const encodeXML: (data: string) => string;
|
||||
/**
|
||||
* Encodes all entities and non-ASCII characters in the input.
|
||||
*
|
||||
* This includes characters that are valid ASCII characters in HTML documents.
|
||||
* For example `#` will be encoded as `#`. To get a more compact output,
|
||||
* consider using the `encodeNonAsciiHTML` function.
|
||||
*
|
||||
* If a character has no equivalent entity, a
|
||||
* numeric hexadecimal reference (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare const encodeHTML: (data: string) => string;
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in HTML
|
||||
* documents using HTML entities.
|
||||
*
|
||||
* If a character has no equivalent entity, a
|
||||
* numeric hexadecimal reference (eg. `ü`) will be used.
|
||||
*/
|
||||
export declare const encodeNonAsciiHTML: (data: string) => string;
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
||||
* documents using numeric hexadecimal reference (eg. `ü`).
|
||||
*
|
||||
* Have a look at `escapeUTF8` if you want a more concise output at the expense
|
||||
* of reduced transportability.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare function escape(data: string): string;
|
||||
/**
|
||||
* Encodes all characters not valid in XML documents using numeric hexadecimal
|
||||
* reference (eg. `ü`).
|
||||
*
|
||||
* Note that the output will be character-set dependent.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
export declare function escapeUTF8(data: string): string;
|
||||
//# sourceMappingURL=encode.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/encode.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/encode.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,SAwIJ,MAAM,WAxI4B,CAAC;AAOrD;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,SAkFL,MAAM,WAlFuC,CAAC;AAChE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,SA+Gb,MAAM,WA/GsC,CAAC;AAqF/D;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
136
book/node_modules/web-resource-inliner/node_modules/entities/lib/encode.js
generated
vendored
Normal file
136
book/node_modules/web-resource-inliner/node_modules/entities/lib/encode.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.escapeUTF8 = exports.escape = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.encodeXML = void 0;
|
||||
var xml_json_1 = __importDefault(require("./maps/xml.json"));
|
||||
var inverseXML = getInverseObj(xml_json_1.default);
|
||||
var xmlReplacer = getInverseReplacer(inverseXML);
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
||||
* documents using XML entities.
|
||||
*
|
||||
* If a character has no equivalent entity, a
|
||||
* numeric hexadecimal reference (eg. `ü`) will be used.
|
||||
*/
|
||||
exports.encodeXML = getASCIIEncoder(inverseXML);
|
||||
var entities_json_1 = __importDefault(require("./maps/entities.json"));
|
||||
var inverseHTML = getInverseObj(entities_json_1.default);
|
||||
var htmlReplacer = getInverseReplacer(inverseHTML);
|
||||
/**
|
||||
* Encodes all entities and non-ASCII characters in the input.
|
||||
*
|
||||
* This includes characters that are valid ASCII characters in HTML documents.
|
||||
* For example `#` will be encoded as `#`. To get a more compact output,
|
||||
* consider using the `encodeNonAsciiHTML` function.
|
||||
*
|
||||
* If a character has no equivalent entity, a
|
||||
* numeric hexadecimal reference (eg. `ü`) will be used.
|
||||
*/
|
||||
exports.encodeHTML = getInverse(inverseHTML, htmlReplacer);
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in HTML
|
||||
* documents using HTML entities.
|
||||
*
|
||||
* If a character has no equivalent entity, a
|
||||
* numeric hexadecimal reference (eg. `ü`) will be used.
|
||||
*/
|
||||
exports.encodeNonAsciiHTML = getASCIIEncoder(inverseHTML);
|
||||
function getInverseObj(obj) {
|
||||
return Object.keys(obj)
|
||||
.sort()
|
||||
.reduce(function (inverse, name) {
|
||||
inverse[obj[name]] = "&" + name + ";";
|
||||
return inverse;
|
||||
}, {});
|
||||
}
|
||||
function getInverseReplacer(inverse) {
|
||||
var single = [];
|
||||
var multiple = [];
|
||||
for (var _i = 0, _a = Object.keys(inverse); _i < _a.length; _i++) {
|
||||
var k = _a[_i];
|
||||
if (k.length === 1) {
|
||||
// Add value to single array
|
||||
single.push("\\" + k);
|
||||
}
|
||||
else {
|
||||
// Add value to multiple array
|
||||
multiple.push(k);
|
||||
}
|
||||
}
|
||||
// Add ranges to single characters.
|
||||
single.sort();
|
||||
for (var start = 0; start < single.length - 1; start++) {
|
||||
// Find the end of a run of characters
|
||||
var end = start;
|
||||
while (end < single.length - 1 &&
|
||||
single[end].charCodeAt(1) + 1 === single[end + 1].charCodeAt(1)) {
|
||||
end += 1;
|
||||
}
|
||||
var count = 1 + end - start;
|
||||
// We want to replace at least three characters
|
||||
if (count < 3)
|
||||
continue;
|
||||
single.splice(start, count, single[start] + "-" + single[end]);
|
||||
}
|
||||
multiple.unshift("[" + single.join("") + "]");
|
||||
return new RegExp(multiple.join("|"), "g");
|
||||
}
|
||||
// /[^\0-\x7F]/gu
|
||||
var reNonASCII = /(?:[\x80-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g;
|
||||
var getCodePoint =
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
String.prototype.codePointAt != null
|
||||
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
function (str) { return str.codePointAt(0); }
|
||||
: // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
||||
function (c) {
|
||||
return (c.charCodeAt(0) - 0xd800) * 0x400 +
|
||||
c.charCodeAt(1) -
|
||||
0xdc00 +
|
||||
0x10000;
|
||||
};
|
||||
function singleCharReplacer(c) {
|
||||
return "&#x" + (c.length > 1 ? getCodePoint(c) : c.charCodeAt(0))
|
||||
.toString(16)
|
||||
.toUpperCase() + ";";
|
||||
}
|
||||
function getInverse(inverse, re) {
|
||||
return function (data) {
|
||||
return data
|
||||
.replace(re, function (name) { return inverse[name]; })
|
||||
.replace(reNonASCII, singleCharReplacer);
|
||||
};
|
||||
}
|
||||
var reEscapeChars = new RegExp(xmlReplacer.source + "|" + reNonASCII.source, "g");
|
||||
/**
|
||||
* Encodes all non-ASCII characters, as well as characters not valid in XML
|
||||
* documents using numeric hexadecimal reference (eg. `ü`).
|
||||
*
|
||||
* Have a look at `escapeUTF8` if you want a more concise output at the expense
|
||||
* of reduced transportability.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
function escape(data) {
|
||||
return data.replace(reEscapeChars, singleCharReplacer);
|
||||
}
|
||||
exports.escape = escape;
|
||||
/**
|
||||
* Encodes all characters not valid in XML documents using numeric hexadecimal
|
||||
* reference (eg. `ü`).
|
||||
*
|
||||
* Note that the output will be character-set dependent.
|
||||
*
|
||||
* @param data String to escape.
|
||||
*/
|
||||
function escapeUTF8(data) {
|
||||
return data.replace(xmlReplacer, singleCharReplacer);
|
||||
}
|
||||
exports.escapeUTF8 = escapeUTF8;
|
||||
function getASCIIEncoder(obj) {
|
||||
return function (data) {
|
||||
return data.replace(reEscapeChars, function (c) { return obj[c] || singleCharReplacer(c); });
|
||||
};
|
||||
}
|
27
book/node_modules/web-resource-inliner/node_modules/entities/lib/index.d.ts
generated
vendored
Normal file
27
book/node_modules/web-resource-inliner/node_modules/entities/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Decodes a string with entities.
|
||||
*
|
||||
* @param data String to decode.
|
||||
* @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0.
|
||||
* @deprecated Use `decodeXML` or `decodeHTML` directly.
|
||||
*/
|
||||
export declare function decode(data: string, level?: number): string;
|
||||
/**
|
||||
* Decodes a string with entities. Does not allow missing trailing semicolons for entities.
|
||||
*
|
||||
* @param data String to decode.
|
||||
* @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0.
|
||||
* @deprecated Use `decodeHTMLStrict` or `decodeXML` directly.
|
||||
*/
|
||||
export declare function decodeStrict(data: string, level?: number): string;
|
||||
/**
|
||||
* Encodes a string with entities.
|
||||
*
|
||||
* @param data String to encode.
|
||||
* @param level Optional level to encode at. 0 = XML, 1 = HTML. Default is 0.
|
||||
* @deprecated Use `encodeHTML`, `encodeXML` or `encodeNonAsciiHTML` directly.
|
||||
*/
|
||||
export declare function encode(data: string, level?: number): string;
|
||||
export { encodeXML, encodeHTML, encodeNonAsciiHTML, escape, escapeUTF8, encodeHTML as encodeHTML4, encodeHTML as encodeHTML5, } from "./encode";
|
||||
export { decodeXML, decodeHTML, decodeHTMLStrict, decodeHTML as decodeHTML4, decodeHTML as decodeHTML5, decodeHTMLStrict as decodeHTML4Strict, decodeHTMLStrict as decodeHTML5Strict, decodeXML as decodeXMLStrict, } from "./decode";
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/index.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/index.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,OAAO,EACH,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,MAAM,EACN,UAAU,EAEV,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,GAC5B,MAAM,UAAU,CAAC;AAElB,OAAO,EACH,SAAS,EACT,UAAU,EACV,gBAAgB,EAEhB,UAAU,IAAI,WAAW,EACzB,UAAU,IAAI,WAAW,EACzB,gBAAgB,IAAI,iBAAiB,EACrC,gBAAgB,IAAI,iBAAiB,EACrC,SAAS,IAAI,eAAe,GAC/B,MAAM,UAAU,CAAC"}
|
57
book/node_modules/web-resource-inliner/node_modules/entities/lib/index.js
generated
vendored
Normal file
57
book/node_modules/web-resource-inliner/node_modules/entities/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.decodeXMLStrict = exports.decodeHTML5Strict = exports.decodeHTML4Strict = exports.decodeHTML5 = exports.decodeHTML4 = exports.decodeHTMLStrict = exports.decodeHTML = exports.decodeXML = exports.encodeHTML5 = exports.encodeHTML4 = exports.escapeUTF8 = exports.escape = exports.encodeNonAsciiHTML = exports.encodeHTML = exports.encodeXML = exports.encode = exports.decodeStrict = exports.decode = void 0;
|
||||
var decode_1 = require("./decode");
|
||||
var encode_1 = require("./encode");
|
||||
/**
|
||||
* Decodes a string with entities.
|
||||
*
|
||||
* @param data String to decode.
|
||||
* @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0.
|
||||
* @deprecated Use `decodeXML` or `decodeHTML` directly.
|
||||
*/
|
||||
function decode(data, level) {
|
||||
return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTML)(data);
|
||||
}
|
||||
exports.decode = decode;
|
||||
/**
|
||||
* Decodes a string with entities. Does not allow missing trailing semicolons for entities.
|
||||
*
|
||||
* @param data String to decode.
|
||||
* @param level Optional level to decode at. 0 = XML, 1 = HTML. Default is 0.
|
||||
* @deprecated Use `decodeHTMLStrict` or `decodeXML` directly.
|
||||
*/
|
||||
function decodeStrict(data, level) {
|
||||
return (!level || level <= 0 ? decode_1.decodeXML : decode_1.decodeHTMLStrict)(data);
|
||||
}
|
||||
exports.decodeStrict = decodeStrict;
|
||||
/**
|
||||
* Encodes a string with entities.
|
||||
*
|
||||
* @param data String to encode.
|
||||
* @param level Optional level to encode at. 0 = XML, 1 = HTML. Default is 0.
|
||||
* @deprecated Use `encodeHTML`, `encodeXML` or `encodeNonAsciiHTML` directly.
|
||||
*/
|
||||
function encode(data, level) {
|
||||
return (!level || level <= 0 ? encode_1.encodeXML : encode_1.encodeHTML)(data);
|
||||
}
|
||||
exports.encode = encode;
|
||||
var encode_2 = require("./encode");
|
||||
Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function () { return encode_2.encodeXML; } });
|
||||
Object.defineProperty(exports, "encodeHTML", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
|
||||
Object.defineProperty(exports, "encodeNonAsciiHTML", { enumerable: true, get: function () { return encode_2.encodeNonAsciiHTML; } });
|
||||
Object.defineProperty(exports, "escape", { enumerable: true, get: function () { return encode_2.escape; } });
|
||||
Object.defineProperty(exports, "escapeUTF8", { enumerable: true, get: function () { return encode_2.escapeUTF8; } });
|
||||
// Legacy aliases (deprecated)
|
||||
Object.defineProperty(exports, "encodeHTML4", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
|
||||
Object.defineProperty(exports, "encodeHTML5", { enumerable: true, get: function () { return encode_2.encodeHTML; } });
|
||||
var decode_2 = require("./decode");
|
||||
Object.defineProperty(exports, "decodeXML", { enumerable: true, get: function () { return decode_2.decodeXML; } });
|
||||
Object.defineProperty(exports, "decodeHTML", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
|
||||
Object.defineProperty(exports, "decodeHTMLStrict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
|
||||
// Legacy aliases (deprecated)
|
||||
Object.defineProperty(exports, "decodeHTML4", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
|
||||
Object.defineProperty(exports, "decodeHTML5", { enumerable: true, get: function () { return decode_2.decodeHTML; } });
|
||||
Object.defineProperty(exports, "decodeHTML4Strict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
|
||||
Object.defineProperty(exports, "decodeHTML5Strict", { enumerable: true, get: function () { return decode_2.decodeHTMLStrict; } });
|
||||
Object.defineProperty(exports, "decodeXMLStrict", { enumerable: true, get: function () { return decode_2.decodeXML; } });
|
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/maps/decode.json
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/maps/decode.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"0":65533,"128":8364,"130":8218,"131":402,"132":8222,"133":8230,"134":8224,"135":8225,"136":710,"137":8240,"138":352,"139":8249,"140":338,"142":381,"145":8216,"146":8217,"147":8220,"148":8221,"149":8226,"150":8211,"151":8212,"152":732,"153":8482,"154":353,"155":8250,"156":339,"158":382,"159":376}
|
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/maps/entities.json
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/maps/entities.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/maps/legacy.json
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/maps/legacy.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"Aacute":"Á","aacute":"á","Acirc":"Â","acirc":"â","acute":"´","AElig":"Æ","aelig":"æ","Agrave":"À","agrave":"à","amp":"&","AMP":"&","Aring":"Å","aring":"å","Atilde":"Ã","atilde":"ã","Auml":"Ä","auml":"ä","brvbar":"¦","Ccedil":"Ç","ccedil":"ç","cedil":"¸","cent":"¢","copy":"©","COPY":"©","curren":"¤","deg":"°","divide":"÷","Eacute":"É","eacute":"é","Ecirc":"Ê","ecirc":"ê","Egrave":"È","egrave":"è","ETH":"Ð","eth":"ð","Euml":"Ë","euml":"ë","frac12":"½","frac14":"¼","frac34":"¾","gt":">","GT":">","Iacute":"Í","iacute":"í","Icirc":"Î","icirc":"î","iexcl":"¡","Igrave":"Ì","igrave":"ì","iquest":"¿","Iuml":"Ï","iuml":"ï","laquo":"«","lt":"<","LT":"<","macr":"¯","micro":"µ","middot":"·","nbsp":" ","not":"¬","Ntilde":"Ñ","ntilde":"ñ","Oacute":"Ó","oacute":"ó","Ocirc":"Ô","ocirc":"ô","Ograve":"Ò","ograve":"ò","ordf":"ª","ordm":"º","Oslash":"Ø","oslash":"ø","Otilde":"Õ","otilde":"õ","Ouml":"Ö","ouml":"ö","para":"¶","plusmn":"±","pound":"£","quot":"\"","QUOT":"\"","raquo":"»","reg":"®","REG":"®","sect":"§","shy":"","sup1":"¹","sup2":"²","sup3":"³","szlig":"ß","THORN":"Þ","thorn":"þ","times":"×","Uacute":"Ú","uacute":"ú","Ucirc":"Û","ucirc":"û","Ugrave":"Ù","ugrave":"ù","uml":"¨","Uuml":"Ü","uuml":"ü","Yacute":"Ý","yacute":"ý","yen":"¥","yuml":"ÿ"}
|
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/maps/xml.json
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/entities/lib/maps/xml.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"amp":"&","apos":"'","gt":">","lt":"<","quot":"\""}
|
64
book/node_modules/web-resource-inliner/node_modules/entities/package.json
generated
vendored
Normal file
64
book/node_modules/web-resource-inliner/node_modules/entities/package.json
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "entities",
|
||||
"version": "2.2.0",
|
||||
"description": "Encode & decode XML and HTML entities with ease",
|
||||
"author": "Felix Boehm <me@feedic.com>",
|
||||
"funding": "https://github.com/fb55/entities?sponsor=1",
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"entity",
|
||||
"decoding",
|
||||
"encoding",
|
||||
"html",
|
||||
"xml",
|
||||
"html entities"
|
||||
],
|
||||
"directories": {
|
||||
"lib": "lib/"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib/**/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/node": "^14.11.8",
|
||||
"@typescript-eslint/eslint-plugin": "^4.4.1",
|
||||
"@typescript-eslint/parser": "^4.4.1",
|
||||
"coveralls": "*",
|
||||
"eslint": "^7.11.0",
|
||||
"eslint-config-prettier": "^7.0.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"jest": "^26.5.3",
|
||||
"prettier": "^2.0.5",
|
||||
"ts-jest": "^26.1.0",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest --coverage && npm run lint",
|
||||
"coverage": "cat coverage/lcov.info | coveralls",
|
||||
"lint": "npm run lint:es && npm run lint:prettier",
|
||||
"lint:es": "eslint .",
|
||||
"lint:prettier": "npm run prettier -- --check",
|
||||
"format": "npm run format:es && npm run format:prettier",
|
||||
"format:es": "npm run lint:es -- --fix",
|
||||
"format:prettier": "npm run prettier -- --write",
|
||||
"prettier": "prettier '**/*.{ts,md,json,yml}'",
|
||||
"build": "tsc && cp -r src/maps lib",
|
||||
"prepare": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/fb55/entities.git"
|
||||
},
|
||||
"license": "BSD-2-Clause",
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 4,
|
||||
"proseWrap": "always"
|
||||
}
|
||||
}
|
57
book/node_modules/web-resource-inliner/node_modules/entities/readme.md
generated
vendored
Normal file
57
book/node_modules/web-resource-inliner/node_modules/entities/readme.md
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
# entities [](https://npmjs.org/package/entities) [](https://npmjs.org/package/entities) [](http://travis-ci.org/fb55/entities) [](https://coveralls.io/r/fb55/entities)
|
||||
|
||||
Encode & decode HTML & XML entities with ease & speed.
|
||||
|
||||
## How to…
|
||||
|
||||
### …install `entities`
|
||||
|
||||
npm install entities
|
||||
|
||||
### …use `entities`
|
||||
|
||||
```javascript
|
||||
const entities = require("entities");
|
||||
|
||||
//encoding
|
||||
entities.escape("&"); // "&#38;"
|
||||
entities.encodeXML("&"); // "&#38;"
|
||||
entities.encodeHTML("&"); // "&#38;"
|
||||
|
||||
//decoding
|
||||
entities.decodeXML("asdf & ÿ ü '"); // "asdf & ÿ ü '"
|
||||
entities.decodeHTML("asdf & ÿ ü '"); // "asdf & ÿ ü '"
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
This is how `entities` compares to other libraries on a very basic benchmark
|
||||
(see `scripts/benchmark.ts`, for 10,000,000 iterations):
|
||||
|
||||
| Library | `decode` performance | `encode` performance | Bundle size |
|
||||
| -------------- | -------------------- | -------------------- | -------------------------------------------------------------------------- |
|
||||
| entities | 10.809s | 17.683s |  |
|
||||
| html-entities | 14.029s | 22.670s |  |
|
||||
| he | 16.163s | 44.010s |  |
|
||||
| parse-entities | 28.507s | N/A |  |
|
||||
|
||||
---
|
||||
|
||||
License: BSD-2-Clause
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security). Tidelift will
|
||||
coordinate the fix and disclosure.
|
||||
|
||||
## `entities` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of `entities` and thousands of other packages are working with
|
||||
Tidelift to deliver commercial support and maintenance for the open source
|
||||
dependencies you use to build your applications. Save time, reduce risk, and
|
||||
improve code health, while paying the maintainers of the exact dependencies you
|
||||
use.
|
||||
[Learn more.](https://tidelift.com/subscription/pkg/npm-entities?utm_source=npm-entities&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
18
book/node_modules/web-resource-inliner/node_modules/htmlparser2/LICENSE
generated
vendored
Normal file
18
book/node_modules/web-resource-inliner/node_modules/htmlparser2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
Copyright 2010, 2011, Chris Winberry <chris@winberry.net>. All rights reserved.
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
127
book/node_modules/web-resource-inliner/node_modules/htmlparser2/README.md
generated
vendored
Normal file
127
book/node_modules/web-resource-inliner/node_modules/htmlparser2/README.md
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
# htmlparser2
|
||||
|
||||
[](https://npmjs.org/package/htmlparser2)
|
||||
[](https://npmjs.org/package/htmlparser2)
|
||||
[](https://github.com/fb55/htmlparser2/actions?query=workflow%3A%22Node.js+Test%22)
|
||||
[](https://coveralls.io/r/fb55/htmlparser2)
|
||||
|
||||
A forgiving HTML/XML/RSS parser.
|
||||
The parser can handle streams and provides a callback interface.
|
||||
|
||||
## Installation
|
||||
|
||||
npm install --save htmlparser2
|
||||
|
||||
A live demo of htmlparser2 is available [here](https://astexplorer.net/#/2AmVrGuGVJ).
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
const htmlparser2 = require("htmlparser2");
|
||||
const parser = new htmlparser2.Parser({
|
||||
onopentag(name, attribs) {
|
||||
if (name === "script" && attribs.type === "text/javascript") {
|
||||
console.log("JS! Hooray!");
|
||||
}
|
||||
},
|
||||
ontext(text) {
|
||||
console.log("-->", text);
|
||||
},
|
||||
onclosetag(tagname) {
|
||||
if (tagname === "script") {
|
||||
console.log("That's it?!");
|
||||
}
|
||||
},
|
||||
});
|
||||
parser.write(
|
||||
"Xyz <script type='text/javascript'>var foo = '<<bar>>';</ script>"
|
||||
);
|
||||
parser.end();
|
||||
```
|
||||
|
||||
Output (simplified):
|
||||
|
||||
```
|
||||
--> Xyz
|
||||
JS! Hooray!
|
||||
--> var foo = '<<bar>>';
|
||||
That's it?!
|
||||
```
|
||||
|
||||
### Usage with streams
|
||||
|
||||
While the `Parser` interface closely resembles Node.js streams, it's not a 100% match.
|
||||
Use the `WritableStream` interface to process a streaming input:
|
||||
|
||||
```javascript
|
||||
const { WritableStream } = require("htmlparser2/lib/WritableStream");
|
||||
const parserStream = new WritableStream({
|
||||
ontext(text) {
|
||||
console.log("Streaming:", text);
|
||||
},
|
||||
});
|
||||
|
||||
const htmlStream = fs.createReadStream("./my-file.html");
|
||||
htmlStream.pipe(parserStream).on("finish", () => console.log("done"));
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
Read more about the parser and its options in the [wiki](https://github.com/fb55/htmlparser2/wiki/Parser-options).
|
||||
|
||||
## Get a DOM
|
||||
|
||||
The `DomHandler` produces a DOM (document object model) that can be manipulated using the [`DomUtils`](https://github.com/fb55/DomUtils) helper.
|
||||
|
||||
The `DomHandler`, while still bundled with this module, was moved to its [own module](https://github.com/fb55/domhandler).
|
||||
Have a look at that for further information.
|
||||
|
||||
## Parsing RSS/RDF/Atom Feeds
|
||||
|
||||
```javascript
|
||||
const feed = htmlparser2.parseFeed(content, options);
|
||||
```
|
||||
|
||||
Note: While the provided feed handler works for most feeds,
|
||||
you might want to use [danmactough/node-feedparser](https://github.com/danmactough/node-feedparser), which is much better tested and actively maintained.
|
||||
|
||||
## Performance
|
||||
|
||||
After having some artificial benchmarks for some time, **@AndreasMadsen** published his [`htmlparser-benchmark`](https://github.com/AndreasMadsen/htmlparser-benchmark), which benchmarks HTML parses based on real-world websites.
|
||||
|
||||
At the time of writing, the latest versions of all supported parsers show the following performance characteristics on [Travis CI](https://travis-ci.org/AndreasMadsen/htmlparser-benchmark/builds/10805007) (please note that Travis doesn't guarantee equal conditions for all tests):
|
||||
|
||||
```
|
||||
gumbo-parser : 34.9208 ms/file ± 21.4238
|
||||
html-parser : 24.8224 ms/file ± 15.8703
|
||||
html5 : 419.597 ms/file ± 264.265
|
||||
htmlparser : 60.0722 ms/file ± 384.844
|
||||
htmlparser2-dom: 12.0749 ms/file ± 6.49474
|
||||
htmlparser2 : 7.49130 ms/file ± 5.74368
|
||||
hubbub : 30.4980 ms/file ± 16.4682
|
||||
libxmljs : 14.1338 ms/file ± 18.6541
|
||||
parse5 : 22.0439 ms/file ± 15.3743
|
||||
sax : 49.6513 ms/file ± 26.6032
|
||||
```
|
||||
|
||||
## How does this module differ from [node-htmlparser](https://github.com/tautologistics/node-htmlparser)?
|
||||
|
||||
This module started as a fork of the `htmlparser` module.
|
||||
The main difference is that `htmlparser2` is intended to be used only with node (it runs on other platforms using [browserify](https://github.com/substack/node-browserify)).
|
||||
`htmlparser2` was rewritten multiple times and, while it maintains an API that's compatible with `htmlparser` in most cases, the projects don't share any code anymore.
|
||||
|
||||
The parser now provides a callback interface inspired by [sax.js](https://github.com/isaacs/sax-js) (originally targeted at [readabilitySAX](https://github.com/fb55/readabilitysax)).
|
||||
As a result, old handlers won't work anymore.
|
||||
|
||||
The `DefaultHandler` and the `RssHandler` were renamed to clarify their purpose (to `DomHandler` and `FeedHandler`). The old names are still available when requiring `htmlparser2`, your code should work as expected.
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
## `htmlparser2` for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of `htmlparser2` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-htmlparser2?utm_source=npm-htmlparser2&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
10
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/CollectingHandler.d.ts
generated
vendored
Normal file
10
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/CollectingHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import MultiplexHandler from "./MultiplexHandler";
|
||||
import { Handler } from "./Parser";
|
||||
export declare class CollectingHandler extends MultiplexHandler {
|
||||
_cbs: Partial<Handler>;
|
||||
events: [keyof Handler, ...unknown[]][];
|
||||
constructor(cbs?: Partial<Handler>);
|
||||
onreset(): void;
|
||||
restart(): void;
|
||||
}
|
||||
//# sourceMappingURL=CollectingHandler.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/CollectingHandler.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/CollectingHandler.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CollectingHandler.d.ts","sourceRoot":"","sources":["../src/CollectingHandler.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,qBAAa,iBAAkB,SAAQ,gBAAgB;IACnD,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,MAAM,EAAE,CAAC,MAAM,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,EAAE,CAAC;gBAE5B,GAAG,GAAE,OAAO,CAAC,OAAO,CAAM;IAUtC,OAAO,IAAI,IAAI;IAKf,OAAO,IAAI,IAAI;CAOlB"}
|
60
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/CollectingHandler.js
generated
vendored
Normal file
60
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/CollectingHandler.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||||
r[k] = a[j];
|
||||
return r;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CollectingHandler = void 0;
|
||||
var MultiplexHandler_1 = __importDefault(require("./MultiplexHandler"));
|
||||
var CollectingHandler = /** @class */ (function (_super) {
|
||||
__extends(CollectingHandler, _super);
|
||||
function CollectingHandler(cbs) {
|
||||
if (cbs === void 0) { cbs = {}; }
|
||||
var _this = _super.call(this, function (name) {
|
||||
var _a;
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
_this.events.push(__spreadArrays([name], args));
|
||||
(_a = _this._cbs[name]) === null || _a === void 0 ? void 0 : _a.apply(void 0, args);
|
||||
}) || this;
|
||||
_this._cbs = cbs;
|
||||
_this.events = [];
|
||||
return _this;
|
||||
}
|
||||
CollectingHandler.prototype.onreset = function () {
|
||||
var _a, _b;
|
||||
this.events = [];
|
||||
(_b = (_a = this._cbs).onreset) === null || _b === void 0 ? void 0 : _b.call(_a);
|
||||
};
|
||||
CollectingHandler.prototype.restart = function () {
|
||||
var _a, _b, _c;
|
||||
(_b = (_a = this._cbs).onreset) === null || _b === void 0 ? void 0 : _b.call(_a);
|
||||
for (var _i = 0, _d = this.events; _i < _d.length; _i++) {
|
||||
var _e = _d[_i], name_1 = _e[0], args = _e.slice(1);
|
||||
(_c = this._cbs[name_1]) === null || _c === void 0 ? void 0 : _c.apply(void 0, args);
|
||||
}
|
||||
};
|
||||
return CollectingHandler;
|
||||
}(MultiplexHandler_1.default));
|
||||
exports.CollectingHandler = CollectingHandler;
|
67
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/FeedHandler.d.ts
generated
vendored
Normal file
67
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/FeedHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import DomHandler, { DomHandlerOptions } from "domhandler";
|
||||
import { ParserOptions } from "./Parser";
|
||||
declare enum FeedItemMediaMedium {
|
||||
image = 0,
|
||||
audio = 1,
|
||||
video = 2,
|
||||
document = 3,
|
||||
executable = 4
|
||||
}
|
||||
declare enum FeedItemMediaExpression {
|
||||
sample = 0,
|
||||
full = 1,
|
||||
nonstop = 2
|
||||
}
|
||||
interface FeedItemMedia {
|
||||
url?: string;
|
||||
fileSize?: number;
|
||||
type?: string;
|
||||
medium: FeedItemMediaMedium | undefined;
|
||||
isDefault: boolean;
|
||||
expression?: FeedItemMediaExpression;
|
||||
bitrate?: number;
|
||||
framerate?: number;
|
||||
samplingrate?: number;
|
||||
channels?: number;
|
||||
duration?: number;
|
||||
height?: number;
|
||||
width?: number;
|
||||
lang?: string;
|
||||
}
|
||||
interface FeedItem {
|
||||
id?: string;
|
||||
title?: string;
|
||||
link?: string;
|
||||
description?: string;
|
||||
pubDate?: Date;
|
||||
media?: FeedItemMedia[];
|
||||
}
|
||||
interface Feed {
|
||||
type?: string;
|
||||
id?: string;
|
||||
title?: string;
|
||||
link?: string;
|
||||
description?: string;
|
||||
updated?: Date;
|
||||
author?: string;
|
||||
items?: FeedItem[];
|
||||
}
|
||||
export declare class FeedHandler extends DomHandler {
|
||||
feed?: Feed;
|
||||
/**
|
||||
*
|
||||
* @param callback
|
||||
* @param options
|
||||
*/
|
||||
constructor(callback?: ((error: Error | null) => void) | DomHandlerOptions, options?: DomHandlerOptions);
|
||||
onend(): void;
|
||||
}
|
||||
/**
|
||||
* Parse a feed.
|
||||
*
|
||||
* @param feed The feed that should be parsed, as a string.
|
||||
* @param options Optionally, options for parsing. When using this option, you probably want to set `xmlMode` to `true`.
|
||||
*/
|
||||
export declare function parseFeed(feed: string, options?: ParserOptions & DomHandlerOptions): Feed | undefined;
|
||||
export {};
|
||||
//# sourceMappingURL=FeedHandler.d.ts.map
|
1
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/FeedHandler.d.ts.map
generated
vendored
Normal file
1
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/FeedHandler.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"FeedHandler.d.ts","sourceRoot":"","sources":["../src/FeedHandler.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAE,iBAAiB,EAAiB,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAU,aAAa,EAAE,MAAM,UAAU,CAAC;AAEjD,aAAK,mBAAmB;IACpB,KAAK,IAAA;IACL,KAAK,IAAA;IACL,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,UAAU,IAAA;CACb;AAED,aAAK,uBAAuB;IACxB,MAAM,IAAA;IACN,IAAI,IAAA;IACJ,OAAO,IAAA;CACV;AAED,UAAU,aAAa;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACxC,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,QAAQ;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED,UAAU,IAAI;IACV,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;CACtB;AAGD,qBAAa,WAAY,SAAQ,UAAU;IACvC,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;;OAIG;gBAEC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,iBAAiB,EAC9D,OAAO,CAAC,EAAE,iBAAiB;IAS/B,KAAK,IAAI,IAAI;CA2GhB;AA8FD;;;;;GAKG;AACH,wBAAgB,SAAS,CACrB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,aAAa,GAAG,iBAAkC,GAC5D,IAAI,GAAG,SAAS,CAIlB"}
|
233
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/FeedHandler.js
generated
vendored
Normal file
233
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/FeedHandler.js
generated
vendored
Normal file
@@ -0,0 +1,233 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseFeed = exports.FeedHandler = void 0;
|
||||
var domhandler_1 = __importDefault(require("domhandler"));
|
||||
var DomUtils = __importStar(require("domutils"));
|
||||
var Parser_1 = require("./Parser");
|
||||
var FeedItemMediaMedium;
|
||||
(function (FeedItemMediaMedium) {
|
||||
FeedItemMediaMedium[FeedItemMediaMedium["image"] = 0] = "image";
|
||||
FeedItemMediaMedium[FeedItemMediaMedium["audio"] = 1] = "audio";
|
||||
FeedItemMediaMedium[FeedItemMediaMedium["video"] = 2] = "video";
|
||||
FeedItemMediaMedium[FeedItemMediaMedium["document"] = 3] = "document";
|
||||
FeedItemMediaMedium[FeedItemMediaMedium["executable"] = 4] = "executable";
|
||||
})(FeedItemMediaMedium || (FeedItemMediaMedium = {}));
|
||||
var FeedItemMediaExpression;
|
||||
(function (FeedItemMediaExpression) {
|
||||
FeedItemMediaExpression[FeedItemMediaExpression["sample"] = 0] = "sample";
|
||||
FeedItemMediaExpression[FeedItemMediaExpression["full"] = 1] = "full";
|
||||
FeedItemMediaExpression[FeedItemMediaExpression["nonstop"] = 2] = "nonstop";
|
||||
})(FeedItemMediaExpression || (FeedItemMediaExpression = {}));
|
||||
// TODO: Consume data as it is coming in
|
||||
var FeedHandler = /** @class */ (function (_super) {
|
||||
__extends(FeedHandler, _super);
|
||||
/**
|
||||
*
|
||||
* @param callback
|
||||
* @param options
|
||||
*/
|
||||
function FeedHandler(callback, options) {
|
||||
var _this = this;
|
||||
if (typeof callback === "object") {
|
||||
callback = undefined;
|
||||
options = callback;
|
||||
}
|
||||
_this = _super.call(this, callback, options) || this;
|
||||
return _this;
|
||||
}
|
||||
FeedHandler.prototype.onend = function () {
|
||||
var _a, _b;
|
||||
var feed = {};
|
||||
var feedRoot = getOneElement(isValidFeed, this.dom);
|
||||
if (feedRoot) {
|
||||
if (feedRoot.name === "feed") {
|
||||
var childs = feedRoot.children;
|
||||
feed.type = "atom";
|
||||
addConditionally(feed, "id", "id", childs);
|
||||
addConditionally(feed, "title", "title", childs);
|
||||
var href = getAttribute("href", getOneElement("link", childs));
|
||||
if (href) {
|
||||
feed.link = href;
|
||||
}
|
||||
addConditionally(feed, "description", "subtitle", childs);
|
||||
var updated = fetch("updated", childs);
|
||||
if (updated) {
|
||||
feed.updated = new Date(updated);
|
||||
}
|
||||
addConditionally(feed, "author", "email", childs, true);
|
||||
feed.items = getElements("entry", childs).map(function (item) {
|
||||
var entry = {};
|
||||
var children = item.children;
|
||||
addConditionally(entry, "id", "id", children);
|
||||
addConditionally(entry, "title", "title", children);
|
||||
var href = getAttribute("href", getOneElement("link", children));
|
||||
if (href) {
|
||||
entry.link = href;
|
||||
}
|
||||
var description = fetch("summary", children) ||
|
||||
fetch("content", children);
|
||||
if (description) {
|
||||
entry.description = description;
|
||||
}
|
||||
var pubDate = fetch("updated", children);
|
||||
if (pubDate) {
|
||||
entry.pubDate = new Date(pubDate);
|
||||
}
|
||||
entry.media = getMediaElements(children);
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
else {
|
||||
var childs = (_b = (_a = getOneElement("channel", feedRoot.children)) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [];
|
||||
feed.type = feedRoot.name.substr(0, 3);
|
||||
feed.id = "";
|
||||
addConditionally(feed, "title", "title", childs);
|
||||
addConditionally(feed, "link", "link", childs);
|
||||
addConditionally(feed, "description", "description", childs);
|
||||
var updated = fetch("lastBuildDate", childs);
|
||||
if (updated) {
|
||||
feed.updated = new Date(updated);
|
||||
}
|
||||
addConditionally(feed, "author", "managingEditor", childs, true);
|
||||
feed.items = getElements("item", feedRoot.children).map(function (item) {
|
||||
var entry = {};
|
||||
var children = item.children;
|
||||
addConditionally(entry, "id", "guid", children);
|
||||
addConditionally(entry, "title", "title", children);
|
||||
addConditionally(entry, "link", "link", children);
|
||||
addConditionally(entry, "description", "description", children);
|
||||
var pubDate = fetch("pubDate", children);
|
||||
if (pubDate)
|
||||
entry.pubDate = new Date(pubDate);
|
||||
entry.media = getMediaElements(children);
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
}
|
||||
this.feed = feed;
|
||||
this.handleCallback(feedRoot ? null : Error("couldn't find root of feed"));
|
||||
};
|
||||
return FeedHandler;
|
||||
}(domhandler_1.default));
|
||||
exports.FeedHandler = FeedHandler;
|
||||
function getMediaElements(where) {
|
||||
return getElements("media:content", where).map(function (elem) {
|
||||
var media = {
|
||||
medium: elem.attribs.medium,
|
||||
isDefault: !!elem.attribs.isDefault,
|
||||
};
|
||||
if (elem.attribs.url) {
|
||||
media.url = elem.attribs.url;
|
||||
}
|
||||
if (elem.attribs.fileSize) {
|
||||
media.fileSize = parseInt(elem.attribs.fileSize, 10);
|
||||
}
|
||||
if (elem.attribs.type) {
|
||||
media.type = elem.attribs.type;
|
||||
}
|
||||
if (elem.attribs.expression) {
|
||||
media.expression = elem.attribs
|
||||
.expression;
|
||||
}
|
||||
if (elem.attribs.bitrate) {
|
||||
media.bitrate = parseInt(elem.attribs.bitrate, 10);
|
||||
}
|
||||
if (elem.attribs.framerate) {
|
||||
media.framerate = parseInt(elem.attribs.framerate, 10);
|
||||
}
|
||||
if (elem.attribs.samplingrate) {
|
||||
media.samplingrate = parseInt(elem.attribs.samplingrate, 10);
|
||||
}
|
||||
if (elem.attribs.channels) {
|
||||
media.channels = parseInt(elem.attribs.channels, 10);
|
||||
}
|
||||
if (elem.attribs.duration) {
|
||||
media.duration = parseInt(elem.attribs.duration, 10);
|
||||
}
|
||||
if (elem.attribs.height) {
|
||||
media.height = parseInt(elem.attribs.height, 10);
|
||||
}
|
||||
if (elem.attribs.width) {
|
||||
media.width = parseInt(elem.attribs.width, 10);
|
||||
}
|
||||
if (elem.attribs.lang) {
|
||||
media.lang = elem.attribs.lang;
|
||||
}
|
||||
return media;
|
||||
});
|
||||
}
|
||||
function getElements(tagName, where) {
|
||||
return DomUtils.getElementsByTagName(tagName, where, true);
|
||||
}
|
||||
function getOneElement(tagName, node) {
|
||||
return DomUtils.getElementsByTagName(tagName, node, true, 1)[0];
|
||||
}
|
||||
function fetch(tagName, where, recurse) {
|
||||
if (recurse === void 0) { recurse = false; }
|
||||
return DomUtils.getText(DomUtils.getElementsByTagName(tagName, where, recurse, 1)).trim();
|
||||
}
|
||||
function getAttribute(name, elem) {
|
||||
if (!elem) {
|
||||
return null;
|
||||
}
|
||||
var attribs = elem.attribs;
|
||||
return attribs[name];
|
||||
}
|
||||
function addConditionally(obj, prop, what, where, recurse) {
|
||||
if (recurse === void 0) { recurse = false; }
|
||||
var tmp = fetch(what, where, recurse);
|
||||
if (tmp)
|
||||
obj[prop] = tmp;
|
||||
}
|
||||
function isValidFeed(value) {
|
||||
return value === "rss" || value === "feed" || value === "rdf:RDF";
|
||||
}
|
||||
var defaultOptions = { xmlMode: true };
|
||||
/**
|
||||
* Parse a feed.
|
||||
*
|
||||
* @param feed The feed that should be parsed, as a string.
|
||||
* @param options Optionally, options for parsing. When using this option, you probably want to set `xmlMode` to `true`.
|
||||
*/
|
||||
function parseFeed(feed, options) {
|
||||
if (options === void 0) { options = defaultOptions; }
|
||||
var handler = new FeedHandler(options);
|
||||
new Parser_1.Parser(handler, options).end(feed);
|
||||
return handler.feed;
|
||||
}
|
||||
exports.parseFeed = parseFeed;
|
27
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/MultiplexHandler.d.ts
generated
vendored
Normal file
27
book/node_modules/web-resource-inliner/node_modules/htmlparser2/lib/MultiplexHandler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { Parser, Handler } from "./Parser";
|
||||
/**
|
||||
* Calls a specific handler function for all events that are encountered.
|
||||
*
|
||||
* @param func — The function to multiplex all events to.
|
||||
*/
|
||||
export default class MultiplexHandler implements Handler {
|
||||
_func: (event: keyof Handler, ...args: unknown[]) => void;
|
||||
constructor(func: (event: keyof Handler, ...args: unknown[]) => void);
|
||||
onattribute(name: string, value: string, quote: string | null | undefined): void;
|
||||
oncdatastart(): void;
|
||||
oncdataend(): void;
|
||||
ontext(text: string): void;
|
||||
onprocessinginstruction(name: string, value: string): void;
|
||||
oncomment(comment: string): void;
|
||||
oncommentend(): void;
|
||||
onclosetag(name: string): void;
|
||||
onopentag(name: string, attribs: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
onopentagname(name: string): void;
|
||||
onerror(error: Error): void;
|
||||
onend(): void;
|
||||
onparserinit(parser: Parser): void;
|
||||
onreset(): void;
|
||||
}
|
||||
//# sourceMappingURL=MultiplexHandler.d.ts.map
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user