update node modules

This commit is contained in:
s2
2020-07-20 16:20:39 +02:00
parent dcb748f037
commit f9fb05e4db
906 changed files with 124011 additions and 93468 deletions

25
node_modules/w3c-xmlserializer/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,25 @@
The MIT License (MIT)
=====================
Copyright © 2016 Sebastian Mayr
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.

View File

@@ -2,19 +2,40 @@
An XML serializer that follows the [W3C specification](https://w3c.github.io/DOM-Parsing/).
This module is mostly used as an internal part of [jsdom](https://github.com/jsdom/jsdom). However, you can use it independently with some care. That isn't very well-documented yet, but hopefully the below sample can give you an idea.
This package can be used in Node.js, as long as you feed it a DOM node, e.g. one produced by [jsdom](https://github.com/jsdom/jsdom).
## Basic usage
Assume you have a DOM tree rooted at a node `node`. In Node.js, you could create this using [jsdom](https://github.com/jsdom/jsdom) as follows:
```js
const { XMLSerializer } = require("w3c-xmlserializer");
const { JSDOM } = require("jsdom");
const { document } = new JSDOM().window;
const XMLSerializer = XMLSerializer.interface;
const serializer = new XMLSerializer();
const doc = document.createElement("akomaNtoso");
const node = document.createElement("akomaNtoso");
```
console.log(serializer.serializeToString(doc));
Then, you use this package as follows:
```js
const serialize = require("w3c-xmlserializer");
console.log(serialize(node));
// => '<akomantoso xmlns="http://www.w3.org/1999/xhtml"></akomantoso>'
```
## `requireWellFormed` option
By default the input DOM tree is not required to be "well-formed"; any given input will serialize to some output string. You can instead require well-formedness via
```js
serialize(node, { requireWellFormed: true });
```
which will cause `Error`s to be thrown when non-well-formed constructs are encountered. [Per the spec](https://w3c.github.io/DOM-Parsing/#dfn-require-well-formed), this largely is about imposing constraints on the names of elements, attributes, etc.
As a point of reference, on the web platform:
* The [`innerHTML` getter](https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml) uses the require-well-formed mode, i.e. trying to get the `innerHTML` of non-well-formed subtrees will throw.
* The [`xhr.send()` method](https://xhr.spec.whatwg.org/#the-send()-method) does not require well-formedness, i.e. sending non-well-formed `Document`s will serialize and send them anyway.

View File

@@ -1,9 +0,0 @@
"use strict";
const { produceXMLSerialization } = require("./serialization");
exports.implementation = class XMLSerializerImpl {
serializeToString(root) {
return produceXMLSerialization(root, false);
}
};

View File

@@ -1,113 +0,0 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
class XMLSerializer {
constructor() {
return iface.setup(Object.create(new.target.prototype));
}
serializeToString(root) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError(
"Failed to execute 'serializeToString' on 'XMLSerializer': 1 argument required, but only " +
arguments.length +
" present."
);
}
const args = [];
{
let curArg = arguments[0];
curArg = utils.tryImplForWrapper(curArg);
args.push(curArg);
}
return this[impl].serializeToString(...args);
}
}
Object.defineProperties(XMLSerializer.prototype, {
serializeToString: { enumerable: true },
[Symbol.toStringTag]: { value: "XMLSerializer", configurable: true }
});
const iface = {
// When an interface-module that implements this interface as a mixin is loaded, it will append its own `.is()`
// method into this array. It allows objects that directly implements *those* interfaces to be recognized as
// implementing this mixin interface.
_mixedIntoPredicates: [],
is(obj) {
if (obj) {
if (utils.hasOwn(obj, impl) && obj[impl] instanceof Impl.implementation) {
return true;
}
for (const isMixedInto of module.exports._mixedIntoPredicates) {
if (isMixedInto(obj)) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (const isMixedInto of module.exports._mixedIntoPredicates) {
if (isMixedInto(wrapper)) {
return true;
}
}
}
return false;
},
convert(obj, { context = "The provided value" } = {}) {
if (module.exports.is(obj)) {
return utils.implForWrapper(obj);
}
throw new TypeError(`${context} is not of type 'XMLSerializer'.`);
},
create(constructorArgs, privateData) {
let obj = Object.create(XMLSerializer.prototype);
obj = this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(XMLSerializer.prototype);
obj = this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
Object.defineProperty(obj, impl, {
value: new Impl.implementation(constructorArgs, privateData),
configurable: true
});
obj[impl][utils.wrapperSymbol] = obj;
if (Impl.init) {
Impl.init(obj[impl], privateData);
}
return obj;
},
interface: XMLSerializer,
expose: {
Window: { XMLSerializer }
}
}; // iface
module.exports = iface;
const Impl = require("./XMLSerializer-impl.js");

View File

@@ -1,9 +0,0 @@
"use strict";
const { produceXMLSerialization } = require("./serialization");
const XMLSerializer = require("./XMLSerializer");
module.exports = {
XMLSerializer,
produceXMLSerialization
};

View File

@@ -1,6 +1,5 @@
"use strict";
const DOMException = require("domexception");
const xnv = require("xml-name-validator");
const attributeUtils = require("./attributes");
@@ -61,7 +60,7 @@ function recordNamespaceInformation(element, map, prefixMap) {
function serializeDocumentType(node, namespace, prefixMap, requireWellFormed) {
if (requireWellFormed && !PUBID_CHAR.test(node.publicId)) {
throw new Error("Node publicId is not well formed");
throw new Error("Failed to serialize XML: document type node publicId is not well-formed.");
}
if (
@@ -69,7 +68,7 @@ function serializeDocumentType(node, namespace, prefixMap, requireWellFormed) {
(!XML_CHAR.test(node.systemId) ||
(node.systemId.includes('"') && node.systemId.includes("'")))
) {
throw new Error("Node systemId is not well formed");
throw new Error("Failed to serialize XML: document type node systemId is not well-formed.");
}
let markup = `<!DOCTYPE ${node.name}`;
@@ -94,13 +93,13 @@ function serializeProcessingInstruction(
requireWellFormed &&
(node.target.includes(":") || asciiCaseInsensitiveMatch(node.target, "xml"))
) {
throw new Error("Node target is not well formed");
throw new Error("Failed to serialize XML: processing instruction node target is not well-formed.");
}
if (
requireWellFormed &&
(!XML_CHAR.test(node.data) || node.data.includes("?>"))
) {
throw new Error("Node data is not well formed");
throw new Error("Failed to serialize XML: processing instruction node data is not well-formed.");
}
return `<?${node.target} ${node.data}?>`;
}
@@ -113,7 +112,7 @@ function serializeDocument(
refs
) {
if (requireWellFormed && node.documentElement === null) {
throw new Error("Document does not have a document element");
throw new Error("Failed to serialize XML: document does not have a document element.");
}
let serializedDocument = "";
for (const child of node.childNodes) {
@@ -150,7 +149,7 @@ function serializeDocumentFragment(
function serializeText(node, namespace, prefixMap, requireWellFormed) {
if (requireWellFormed && !XML_CHAR.test(node.data)) {
throw new Error("Node data is not well formed");
throw new Error("Failed to serialize XML: text node data is not well-formed.");
}
return node.data
@@ -161,14 +160,14 @@ function serializeText(node, namespace, prefixMap, requireWellFormed) {
function serializeComment(node, namespace, prefixMap, requireWellFormed) {
if (requireWellFormed && !XML_CHAR.test(node.data)) {
throw new Error("Node data is not well formed");
throw new Error("Failed to serialize XML: comment node data is not well-formed.");
}
if (
requireWellFormed &&
(node.data.includes("--") || node.data.endsWith("-"))
) {
throw new Error("Found hyphens in illegal places");
throw new Error("Failed to serialize XML: found hyphens in illegal places in comment node data.");
}
return `<!--${node.data}-->`;
}
@@ -178,7 +177,7 @@ function serializeElement(node, namespace, prefixMap, requireWellFormed, refs) {
requireWellFormed &&
(node.localName.includes(":") || !xnv.name(node.localName))
) {
throw new Error("localName is not a valid XML name");
throw new Error("Failed to serialize XML: element node localName is not a valid XML name.");
}
let markup = "<";
let qualifiedName = "";
@@ -208,7 +207,7 @@ function serializeElement(node, namespace, prefixMap, requireWellFormed, refs) {
let candidatePrefix = attributeUtils.preferredPrefixString(map, ns, prefix);
if (prefix === "xmlns") {
if (requireWellFormed) {
throw new Error("Elements can't have xmlns prefix");
throw new Error("Failed to serialize XML: element nodes can't have a prefix of \"xmlns\".");
}
candidatePrefix = "xmlns";
}
@@ -359,21 +358,14 @@ function xmlSerialization(node, namespace, prefixMap, requireWellFormed, refs) {
case NODE_TYPES.CDATA_SECTION_NODE:
return serializeCDATASection(node);
default:
throw new TypeError("Only Nodes and Attr objects can be serialized");
throw new TypeError("Failed to serialize XML: only Nodes can be serialized.");
}
}
module.exports.produceXMLSerialization = (root, requireWellFormed) => {
module.exports = (root, { requireWellFormed = false } = {}) => {
const namespacePrefixMap = Object.create(null);
namespacePrefixMap["http://www.w3.org/XML/1998/namespace"] = ["xml"];
try {
return xmlSerialization(root, null, namespacePrefixMap, requireWellFormed, {
prefixIndex: 1
});
} catch (e) {
throw new DOMException(
"Failed to serialize XML: " + e.message,
"InvalidStateError"
);
}
return xmlSerialization(root, null, namespacePrefixMap, requireWellFormed, {
prefixIndex: 1
});
};

View File

@@ -1,127 +0,0 @@
"use strict";
// Returns "Type(value) is Object" in ES terminology.
function isObject(value) {
return typeof value === "object" && value !== null || typeof value === "function";
}
function hasOwn(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
const getOwnPropertyDescriptors = typeof Object.getOwnPropertyDescriptors === "function" ?
Object.getOwnPropertyDescriptors :
// Polyfill exists until we require Node.js v8.x
// https://tc39.github.io/ecma262/#sec-object.getownpropertydescriptors
obj => {
if (obj === undefined || obj === null) {
throw new TypeError("Cannot convert undefined or null to object");
}
obj = Object(obj);
const ownKeys = Reflect.ownKeys(obj);
const descriptors = {};
for (const key of ownKeys) {
const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
if (descriptor !== undefined) {
Reflect.defineProperty(descriptors, key, {
value: descriptor,
writable: true,
enumerable: true,
configurable: true
});
}
}
return descriptors;
};
const wrapperSymbol = Symbol("wrapper");
const implSymbol = Symbol("impl");
const sameObjectCaches = Symbol("SameObject caches");
function getSameObject(wrapper, prop, creator) {
if (!wrapper[sameObjectCaches]) {
wrapper[sameObjectCaches] = Object.create(null);
}
if (prop in wrapper[sameObjectCaches]) {
return wrapper[sameObjectCaches][prop];
}
wrapper[sameObjectCaches][prop] = creator();
return wrapper[sameObjectCaches][prop];
}
function wrapperForImpl(impl) {
return impl ? impl[wrapperSymbol] : null;
}
function implForWrapper(wrapper) {
return wrapper ? wrapper[implSymbol] : null;
}
function tryWrapperForImpl(impl) {
const wrapper = wrapperForImpl(impl);
return wrapper ? wrapper : impl;
}
function tryImplForWrapper(wrapper) {
const impl = implForWrapper(wrapper);
return impl ? impl : wrapper;
}
const iterInternalSymbol = Symbol("internal");
const IteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()));
function isArrayIndexPropName(P) {
if (typeof P !== "string") {
return false;
}
const i = P >>> 0;
if (i === Math.pow(2, 32) - 1) {
return false;
}
const s = `${i}`;
if (P !== s) {
return false;
}
return true;
}
const supportsPropertyIndex = Symbol("supports property index");
const supportedPropertyIndices = Symbol("supported property indices");
const supportsPropertyName = Symbol("supports property name");
const supportedPropertyNames = Symbol("supported property names");
const indexedGet = Symbol("indexed property get");
const indexedSetNew = Symbol("indexed property set new");
const indexedSetExisting = Symbol("indexed property set existing");
const namedGet = Symbol("named property get");
const namedSetNew = Symbol("named property set new");
const namedSetExisting = Symbol("named property set existing");
const namedDelete = Symbol("named property delete");
module.exports = exports = {
isObject,
hasOwn,
getOwnPropertyDescriptors,
wrapperSymbol,
implSymbol,
getSameObject,
wrapperForImpl,
implForWrapper,
tryWrapperForImpl,
tryImplForWrapper,
iterInternalSymbol,
IteratorPrototype,
isArrayIndexPropName,
supportsPropertyIndex,
supportedPropertyIndices,
supportsPropertyName,
supportedPropertyNames,
indexedGet,
indexedSetNew,
indexedSetExisting,
namedGet,
namedSetNew,
namedSetExisting,
namedDelete
};

View File

@@ -1,47 +1,43 @@
{
"_args": [
[
"w3c-xmlserializer@1.1.2",
"D:\\Projects\\vanillajs-seed"
]
],
"_development": true,
"_from": "w3c-xmlserializer@1.1.2",
"_id": "w3c-xmlserializer@1.1.2",
"_from": "w3c-xmlserializer@^2.0.0",
"_id": "w3c-xmlserializer@2.0.0",
"_inBundle": false,
"_integrity": "sha512-p10l/ayESzrBMYWRID6xbuCKh2Fp77+sA0doRuGn4tTIMrrZVeqfpKjXHY+oDh3K4nLdPgNwMTVP6Vp4pvqbNg==",
"_integrity": "sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==",
"_location": "/w3c-xmlserializer",
"_phantomChildren": {},
"_requested": {
"type": "version",
"type": "range",
"registry": true,
"raw": "w3c-xmlserializer@1.1.2",
"raw": "w3c-xmlserializer@^2.0.0",
"name": "w3c-xmlserializer",
"escapedName": "w3c-xmlserializer",
"rawSpec": "1.1.2",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "1.1.2"
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/jsdom"
],
"_resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-1.1.2.tgz",
"_spec": "1.1.2",
"_where": "D:\\Projects\\vanillajs-seed",
"_resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz",
"_shasum": "3e7104a05b75146cc60f564380b7f683acf1020a",
"_spec": "w3c-xmlserializer@^2.0.0",
"_where": "D:\\Projects\\vanillajs-seed\\node_modules\\jsdom",
"bugs": {
"url": "https://github.com/jsdom/w3c-xmlserializer/issues"
},
"bundleDependencies": false,
"dependencies": {
"domexception": "^1.0.1",
"webidl-conversions": "^4.0.2",
"xml-name-validator": "^3.0.0"
},
"deprecated": false,
"description": "A per-spec XML serializer implementation",
"devDependencies": {
"eslint": "^5.15.2",
"jest": "^24.5.0",
"jsdom": "^14.0.0",
"webidl2js": "^9.2.0"
"eslint": "^6.8.0",
"jest": "^24.9.0",
"jsdom": "^15.2.1"
},
"engines": {
"node": ">=10"
},
"files": [
"lib/"
@@ -54,7 +50,7 @@
"xmlserializer"
],
"license": "MIT",
"main": "lib/index.js",
"main": "lib/serialize.js",
"name": "w3c-xmlserializer",
"repository": {
"type": "git",
@@ -62,9 +58,7 @@
},
"scripts": {
"lint": "eslint .",
"prepare": "node scripts/convert-idl.js",
"pretest": "node scripts/convert-idl.js",
"test": "jest"
},
"version": "1.1.2"
"version": "2.0.0"
}