From 27bceafeb67dfba5ad82375fb1b865dc247eaaf5 Mon Sep 17 00:00:00 2001 From: Google GitHub Actions Bot <72759630+google-github-actions-bot@users.noreply.github.com> Date: Tue, 8 Nov 2022 12:57:40 -0600 Subject: [PATCH] chore: build dist (#659) chore: build dist release-please-action --- dist/index.js | 605 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 503 insertions(+), 102 deletions(-) diff --git a/dist/index.js b/dist/index.js index 42e2199..c65bb34 100644 --- a/dist/index.js +++ b/dist/index.js @@ -16700,6 +16700,38 @@ exports.default = once; "use strict"; +/** + * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes. + * + * Works with anything that has a `length` property and index access properties, including NodeList. + * + * @template {unknown} T + * @param {Array | ({length:number, [number]: T})} list + * @param {function (item: T, index: number, list:Array | ({length:number, [number]: T})):boolean} predicate + * @param {Partial>?} ac `Array.prototype` by default, + * allows injecting a custom implementation in tests + * @returns {T | undefined} + * + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find + * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find + */ +function find(list, predicate, ac) { + if (ac === undefined) { + ac = Array.prototype; + } + if (list && typeof ac.find === 'function') { + return ac.find.call(list, predicate); + } + for (var i = 0; i < list.length; i++) { + if (Object.prototype.hasOwnProperty.call(list, i)) { + var item = list[i]; + if (predicate.call(undefined, item, i, list)) { + return item; + } + } + } +} + /** * "Shallow freezes" an object to render it immutable. * Uses `Object.freeze` if available, @@ -16865,6 +16897,7 @@ var NAMESPACE = freeze({ }) exports.assign = assign; +exports.find = find; exports.freeze = freeze; exports.MIME_TYPE = MIME_TYPE; exports.NAMESPACE = NAMESPACE; @@ -17207,6 +17240,7 @@ exports.DOMParser = DOMParser; var conventions = __nccwpck_require__(49756); +var find = conventions.find; var NAMESPACE = conventions.NAMESPACE; /** @@ -17269,7 +17303,9 @@ function arrayIncludes (list) { function copy(src,dest){ for(var p in src){ - dest[p] = src[p]; + if (Object.prototype.hasOwnProperty.call(src, p)) { + dest[p] = src[p]; + } } } @@ -17363,14 +17399,14 @@ NodeList.prototype = { * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. * @standard level1 */ - length:0, + length:0, /** * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null. * @standard level1 - * @param index unsigned long + * @param index unsigned long * Index into the collection. * @return Node - * The node at the indexth position in the NodeList, or null if that is not a valid index. + * The node at the indexth position in the NodeList, or null if that is not a valid index. */ item: function(index) { return this[index] || null; @@ -17380,7 +17416,23 @@ NodeList.prototype = { serializeToString(this[i],buf,isHTML,nodeFilter); } return buf.join(''); - } + }, + /** + * @private + * @param {function (Node):boolean} predicate + * @returns {Node[]} + */ + filter: function (predicate) { + return Array.prototype.filter.call(this, predicate); + }, + /** + * @private + * @param {Node} item + * @returns {number} + */ + indexOf: function (item) { + return Array.prototype.indexOf.call(this, item); + }, }; function LiveNodeList(node,refresh){ @@ -17414,7 +17466,7 @@ _extends(LiveNodeList,NodeList); * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, * and does not imply that the DOM specifies an order to these Nodes. * NamedNodeMap objects in the DOM are live. - * used for attributes or DocumentType entities + * used for attributes or DocumentType entities */ function NamedNodeMap() { }; @@ -17458,7 +17510,7 @@ function _removeNamedNode(el,list,attr){ } } }else{ - throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr)) + throw new DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr)) } } NamedNodeMap.prototype = { @@ -17503,10 +17555,10 @@ NamedNodeMap.prototype = { var attr = this.getNamedItem(key); _removeNamedNode(this._ownerElement,this,attr); return attr; - - + + },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR - + //for level2 removeNamedItemNS:function(namespaceURI,localName){ var attr = this.getNamedItemNS(namespaceURI,localName); @@ -17652,11 +17704,11 @@ Node.prototype = { prefix : null, localName : null, // Modified in DOM Level 2: - insertBefore:function(newChild, refChild){//raises + insertBefore:function(newChild, refChild){//raises return _insertBefore(this,newChild,refChild); }, - replaceChild:function(newChild, oldChild){//raises - this.insertBefore(newChild,oldChild); + replaceChild:function(newChild, oldChild){//raises + _insertBefore(this, newChild,oldChild, assertPreReplacementValidityInDocument); if(oldChild){ this.removeChild(oldChild); } @@ -17716,9 +17768,9 @@ Node.prototype = { //console.dir(map) if(map){ for(var n in map){ - if(map[n] == namespaceURI){ - return n; - } + if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) { + return n; + } } } el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode; @@ -17732,7 +17784,7 @@ Node.prototype = { var map = el._nsMap; //console.dir(map) if(map){ - if(prefix in map){ + if(Object.prototype.hasOwnProperty.call(map, prefix)){ return map[prefix] ; } } @@ -17778,6 +17830,7 @@ function _visitNode(node,callback){ function Document(){ + this.ownerDocument = this; } function _onAddAttribute(doc,el,newAttr){ @@ -17861,48 +17914,313 @@ function _removeChild (parentNode, child) { _onUpdateChild(parentNode.ownerDocument, parentNode); return child; } + +/** + * Returns `true` if `node` can be a parent for insertion. + * @param {Node} node + * @returns {boolean} + */ +function hasValidParentNodeType(node) { + return ( + node && + (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE) + ); +} + +/** + * Returns `true` if `node` can be inserted according to it's `nodeType`. + * @param {Node} node + * @returns {boolean} + */ +function hasInsertableNodeType(node) { + return ( + node && + (isElementNode(node) || + isTextNode(node) || + isDocTypeNode(node) || + node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || + node.nodeType === Node.COMMENT_NODE || + node.nodeType === Node.PROCESSING_INSTRUCTION_NODE) + ); +} + +/** + * Returns true if `node` is a DOCTYPE node + * @param {Node} node + * @returns {boolean} + */ +function isDocTypeNode(node) { + return node && node.nodeType === Node.DOCUMENT_TYPE_NODE; +} + +/** + * Returns true if the node is an element + * @param {Node} node + * @returns {boolean} + */ +function isElementNode(node) { + return node && node.nodeType === Node.ELEMENT_NODE; +} /** - * preformance key(refChild == null) + * Returns true if `node` is a text node + * @param {Node} node + * @returns {boolean} */ -function _insertBefore(parentNode,newChild,nextChild){ - var cp = newChild.parentNode; +function isTextNode(node) { + return node && node.nodeType === Node.TEXT_NODE; +} + +/** + * Check if en element node can be inserted before `child`, or at the end if child is falsy, + * according to the presence and position of a doctype node on the same level. + * + * @param {Document} doc The document node + * @param {Node} child the node that would become the nextSibling if the element would be inserted + * @returns {boolean} `true` if an element can be inserted before child + * @private + * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity + */ +function isElementInsertionPossible(doc, child) { + var parentChildNodes = doc.childNodes || []; + if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) { + return false; + } + var docTypeNode = find(parentChildNodes, isDocTypeNode); + return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child)); +} + +/** + * Check if en element node can be inserted before `child`, or at the end if child is falsy, + * according to the presence and position of a doctype node on the same level. + * + * @param {Node} doc The document node + * @param {Node} child the node that would become the nextSibling if the element would be inserted + * @returns {boolean} `true` if an element can be inserted before child + * @private + * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity + */ +function isElementReplacementPossible(doc, child) { + var parentChildNodes = doc.childNodes || []; + + function hasElementChildThatIsNotChild(node) { + return isElementNode(node) && node !== child; + } + + if (find(parentChildNodes, hasElementChildThatIsNotChild)) { + return false; + } + var docTypeNode = find(parentChildNodes, isDocTypeNode); + return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child)); +} + +/** + * @private + * Steps 1-5 of the checks before inserting and before replacing a child are the same. + * + * @param {Node} parent the parent node to insert `node` into + * @param {Node} node the node to insert + * @param {Node=} child the node that should become the `nextSibling` of `node` + * @returns {Node} + * @throws DOMException for several node combinations that would create a DOM that is not well-formed. + * @throws DOMException if `child` is provided but is not a child of `parent`. + * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity + * @see https://dom.spec.whatwg.org/#concept-node-replace + */ +function assertPreInsertionValidity1to5(parent, node, child) { + // 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException. + if (!hasValidParentNodeType(parent)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType); + } + // 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a "HierarchyRequestError" DOMException. + // not implemented! + // 3. If `child` is non-null and its parent is not `parent`, then throw a "NotFoundError" DOMException. + if (child && child.parentNode !== parent) { + throw new DOMException(NOT_FOUND_ERR, 'child not in parent'); + } + if ( + // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException. + !hasInsertableNodeType(node) || + // 5. If either `node` is a Text node and `parent` is a document, + // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0 + // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE) + // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException. + (isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE) + ) { + throw new DOMException( + HIERARCHY_REQUEST_ERR, + 'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType + ); + } +} + +/** + * @private + * Step 6 of the checks before inserting and before replacing a child are different. + * + * @param {Document} parent the parent node to insert `node` into + * @param {Node} node the node to insert + * @param {Node | undefined} child the node that should become the `nextSibling` of `node` + * @returns {Node} + * @throws DOMException for several node combinations that would create a DOM that is not well-formed. + * @throws DOMException if `child` is provided but is not a child of `parent`. + * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity + * @see https://dom.spec.whatwg.org/#concept-node-replace + */ +function assertPreInsertionValidityInDocument(parent, node, child) { + var parentChildNodes = parent.childNodes || []; + var nodeChildNodes = node.childNodes || []; + + // DocumentFragment + if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { + var nodeChildElements = nodeChildNodes.filter(isElementNode); + // If node has more than one element child or has a Text node child. + if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment'); + } + // Otherwise, if `node` has one element child and either `parent` has an element child, + // `child` is a doctype, or `child` is non-null and a doctype is following `child`. + if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype'); + } + } + // Element + if (isElementNode(node)) { + // `parent` has an element child, `child` is a doctype, + // or `child` is non-null and a doctype is following `child`. + if (!isElementInsertionPossible(parent, child)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype'); + } + } + // DocumentType + if (isDocTypeNode(node)) { + // `parent` has a doctype child, + if (find(parentChildNodes, isDocTypeNode)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed'); + } + var parentElementChild = find(parentChildNodes, isElementNode); + // `child` is non-null and an element is preceding `child`, + if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element'); + } + // or `child` is null and `parent` has an element child. + if (!child && parentElementChild) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present'); + } + } +} + +/** + * @private + * Step 6 of the checks before inserting and before replacing a child are different. + * + * @param {Document} parent the parent node to insert `node` into + * @param {Node} node the node to insert + * @param {Node | undefined} child the node that should become the `nextSibling` of `node` + * @returns {Node} + * @throws DOMException for several node combinations that would create a DOM that is not well-formed. + * @throws DOMException if `child` is provided but is not a child of `parent`. + * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity + * @see https://dom.spec.whatwg.org/#concept-node-replace + */ +function assertPreReplacementValidityInDocument(parent, node, child) { + var parentChildNodes = parent.childNodes || []; + var nodeChildNodes = node.childNodes || []; + + // DocumentFragment + if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { + var nodeChildElements = nodeChildNodes.filter(isElementNode); + // If `node` has more than one element child or has a Text node child. + if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment'); + } + // Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`. + if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype'); + } + } + // Element + if (isElementNode(node)) { + // `parent` has an element child that is not `child` or a doctype is following `child`. + if (!isElementReplacementPossible(parent, child)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype'); + } + } + // DocumentType + if (isDocTypeNode(node)) { + function hasDoctypeChildThatIsNotChild(node) { + return isDocTypeNode(node) && node !== child; + } + + // `parent` has a doctype child that is not `child`, + if (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed'); + } + var parentElementChild = find(parentChildNodes, isElementNode); + // or an element is preceding `child`. + if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) { + throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element'); + } + } +} + +/** + * @private + * @param {Node} parent the parent node to insert `node` into + * @param {Node} node the node to insert + * @param {Node=} child the node that should become the `nextSibling` of `node` + * @returns {Node} + * @throws DOMException for several node combinations that would create a DOM that is not well-formed. + * @throws DOMException if `child` is provided but is not a child of `parent`. + * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity + */ +function _insertBefore(parent, node, child, _inDocumentAssertion) { + // To ensure pre-insertion validity of a node into a parent before a child, run these steps: + assertPreInsertionValidity1to5(parent, node, child); + + // If parent is a document, and any of the statements below, switched on the interface node implements, + // are true, then throw a "HierarchyRequestError" DOMException. + if (parent.nodeType === Node.DOCUMENT_NODE) { + (_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child); + } + + var cp = node.parentNode; if(cp){ - cp.removeChild(newChild);//remove and update + cp.removeChild(node);//remove and update } - if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ - var newFirst = newChild.firstChild; + if(node.nodeType === DOCUMENT_FRAGMENT_NODE){ + var newFirst = node.firstChild; if (newFirst == null) { - return newChild; + return node; } - var newLast = newChild.lastChild; + var newLast = node.lastChild; }else{ - newFirst = newLast = newChild; + newFirst = newLast = node; } - var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild; + var pre = child ? child.previousSibling : parent.lastChild; newFirst.previousSibling = pre; - newLast.nextSibling = nextChild; - - + newLast.nextSibling = child; + + if(pre){ pre.nextSibling = newFirst; }else{ - parentNode.firstChild = newFirst; + parent.firstChild = newFirst; } - if(nextChild == null){ - parentNode.lastChild = newLast; + if(child == null){ + parent.lastChild = newLast; }else{ - nextChild.previousSibling = newLast; + child.previousSibling = newLast; } do{ - newFirst.parentNode = parentNode; + newFirst.parentNode = parent; }while(newFirst !== newLast && (newFirst= newFirst.nextSibling)) - _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode); - //console.log(parentNode.lastChild.nextSibling == null) - if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) { - newChild.firstChild = newChild.lastChild = null; + _onUpdateChild(parent.ownerDocument||parent, parent); + //console.log(parent.lastChild.nextSibling == null) + if (node.nodeType == DOCUMENT_FRAGMENT_NODE) { + node.firstChild = node.lastChild = null; } - return newChild; + return node; } /** @@ -17957,11 +18275,13 @@ Document.prototype = { } return newChild; } - if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){ + _insertBefore(this, newChild, refChild); + newChild.ownerDocument = this; + if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) { this.documentElement = newChild; } - return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild; + return newChild; }, removeChild : function(oldChild){ if(this.documentElement == oldChild){ @@ -17969,6 +18289,17 @@ Document.prototype = { } return _removeChild(this,oldChild); }, + replaceChild: function (newChild, oldChild) { + //raises + _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument); + newChild.ownerDocument = this; + if (oldChild) { + this.removeChild(oldChild); + } + if (isElementNode(newChild)) { + this.documentElement = newChild; + } + }, // Introduced in DOM Level 2: importNode : function(importedNode,deep){ return importNode(this,importedNode,deep); @@ -18155,7 +18486,7 @@ Element.prototype = { var attr = this.getAttributeNode(name) attr && this.removeAttributeNode(attr); }, - + //four real opeartion method appendChild:function(newChild){ if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){ @@ -18179,7 +18510,7 @@ Element.prototype = { var old = this.getAttributeNodeNS(namespaceURI, localName); old && this.removeAttributeNode(old); }, - + hasAttributeNS : function(namespaceURI, localName){ return this.getAttributeNodeNS(namespaceURI, localName)!=null; }, @@ -18195,7 +18526,7 @@ Element.prototype = { getAttributeNodeNS : function(namespaceURI, localName){ return this.attributes.getNamedItemNS(namespaceURI, localName); }, - + getElementsByTagName : function(tagName){ return new LiveNodeList(this,function(base){ var ls = []; @@ -18216,7 +18547,7 @@ Element.prototype = { } }); return ls; - + }); } }; @@ -18245,7 +18576,7 @@ CharacterData.prototype = { }, insertData: function(offset,text) { this.replaceData(offset,0,text); - + }, appendChild:function(newChild){ throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]) @@ -18339,7 +18670,7 @@ function nodeSerializeToString(isHtml,nodeFilter){ var refNode = this.nodeType == 9 && this.documentElement || this; var prefix = refNode.prefix; var uri = refNode.namespaceURI; - + if(uri && prefix == null){ //console.log(prefix) var prefix = refNode.lookupPrefix(uri); @@ -18372,8 +18703,8 @@ function needNamespaceDefine(node, isHTML, visibleNamespaces) { if (prefix === "xml" && uri === NAMESPACE.XML || uri === NAMESPACE.XMLNS) { return false; } - - var i = visibleNamespaces.length + + var i = visibleNamespaces.length while (i--) { var ns = visibleNamespaces[i]; // get namespace prefix @@ -18424,7 +18755,7 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){ var len = attrs.length; var child = node.firstChild; var nodeName = node.tagName; - + isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML var prefixedNodeName = nodeName @@ -18483,14 +18814,14 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){ serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces); } - // add namespace for current node + // add namespace for current node if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) { var prefix = node.prefix||''; var uri = node.namespaceURI; addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : "xmlns", uri); visibleNamespaces.push({ prefix: prefix, namespace:uri }); } - + if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){ buf.push('>'); //if is cdata child node @@ -18631,11 +18962,13 @@ function importNode(doc,node,deep){ // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,}; function cloneNode(doc,node,deep){ var node2 = new node.constructor(); - for(var n in node){ - var v = node[n]; - if(typeof v != 'object' ){ - if(v != node2[n]){ - node2[n] = v; + for (var n in node) { + if (Object.prototype.hasOwnProperty.call(node, n)) { + var v = node[n]; + if (typeof v != "object") { + if (v != node2[n]) { + node2[n] = v; + } } } } @@ -18703,7 +19036,7 @@ try{ } } }) - + function getTextContent(node){ switch(node.nodeType){ case ELEMENT_NODE: @@ -19174,8 +19507,10 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){ if(endIgnoreCaseMach){ domBuilder.endElement(config.uri,config.localName,tagName); if(localNSMap){ - for(var prefix in localNSMap){ - domBuilder.endPrefixMapping(prefix) ; + for (var prefix in localNSMap) { + if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) { + domBuilder.endPrefixMapping(prefix); + } } } if(!endMatch){ @@ -19517,8 +19852,10 @@ function appendElement(el,domBuilder,currentNSMap){ if(el.closed){ domBuilder.endElement(ns,localName,tagName); if(localNSMap){ - for(prefix in localNSMap){ - domBuilder.endPrefixMapping(prefix) + for (prefix in localNSMap) { + if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) { + domBuilder.endPrefixMapping(prefix); + } } } }else{ @@ -19564,9 +19901,15 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){ return pos crateInfo.name)); const graph = new Map(); for (const crateInfo of allPackages) { @@ -87512,6 +87855,17 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin { ...((_b = crateInfo.manifest['dev-dependencies']) !== null && _b !== void 0 ? _b : {}), ...((_c = crateInfo.manifest['build-dependencies']) !== null && _c !== void 0 ? _c : {}), }); + const targets = crateInfo.manifest.target; + if (targets) { + for (const targetName in targets) { + const target = targets[targetName]; + allDeps.push(...Object.keys({ + ...((_d = target.dependencies) !== null && _d !== void 0 ? _d : {}), + ...((_e = target['dev-dependencies']) !== null && _e !== void 0 ? _e : {}), + ...((_f = target['build-dependencies']) !== null && _f !== void 0 ? _f : {}), + })); + } + } const workspaceDeps = allDeps.filter(dep => workspaceCrateNames.has(dep)); graph.set(crateInfo.name, { deps: workspaceDeps, @@ -87532,7 +87886,6 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin { } exports.CargoWorkspace = CargoWorkspace; function getChangelogDepsNotes(originalManifest, updatedManifest) { - var _a; let depUpdateNotes = ''; const depTypes = [ 'dependencies', @@ -87560,21 +87913,32 @@ function getChangelogDepsNotes(originalManifest, updatedManifest) { } return result; }; - const updates = new Map(); - for (const depType of depTypes) { - const depUpdates = []; - const pkgDepTypes = updatedManifest[depType]; - if (pkgDepTypes === undefined) { - continue; - } - for (const [depName, currentDepVer] of Object.entries(getDepMap(pkgDepTypes))) { - const origDepVer = depVer((_a = originalManifest[depType]) === null || _a === void 0 ? void 0 : _a[depName]); - if (currentDepVer !== origDepVer) { - depUpdates.push(`\n * ${depName} bumped from ${origDepVer} to ${currentDepVer}`); + const populateUpdates = (originalScope, updatedScope, updates) => { + var _a; + for (const depType of depTypes) { + const depUpdates = []; + const pkgDepTypes = updatedScope[depType]; + if (pkgDepTypes === undefined) { + continue; + } + for (const [depName, currentDepVer] of Object.entries(getDepMap(pkgDepTypes))) { + const origDepVer = depVer((_a = originalScope[depType]) === null || _a === void 0 ? void 0 : _a[depName]); + if (currentDepVer !== origDepVer) { + depUpdates.push(`\n * ${depName} bumped from ${origDepVer} to ${currentDepVer}`); + } + } + if (depUpdates.length > 0) { + const updatesForType = updates.get(depType) || new Set(); + depUpdates.forEach(update => updatesForType.add(update)); + updates.set(depType, updatesForType); } } - if (depUpdates.length > 0) { - updates.set(depType, depUpdates); + }; + const updates = new Map(); + populateUpdates(originalManifest, updatedManifest, updates); + if (updatedManifest.target && originalManifest.target) { + for (const targetName in updatedManifest.target) { + populateUpdates(originalManifest.target[targetName], updatedManifest.target[targetName], updates); } } for (const [dt, notes] of updates) { @@ -87978,7 +88342,8 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin { this.logger.warn(`${pomUpdate.path} does not have cached contents`); } } - if (candidate.pullRequest.version) { + if (candidate.pullRequest.version && + this.isReleaseVersion(candidate.pullRequest.version)) { updatedPathVersions.set(candidate.path, candidate.pullRequest.version); } } @@ -87999,7 +88364,9 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin { else { this.logger.debug(`version: ${version} forced bump`); updatedVersions.set(packageName, version); - updatedPathVersions.set(this.pathFromPackage(pkg), version); + if (this.isReleaseVersion(version)) { + updatedPathVersions.set(this.pathFromPackage(pkg), version); + } } } } @@ -88030,6 +88397,16 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin { } return graph; } + /** + * Given a release version, determine if we should bump the manifest + * version as well. For maven artifacts, SNAPSHOT versions are not + * considered releases. + * @param {Version} version The release version + */ + isReleaseVersion(version) { + var _a; + return !((_a = version.preRelease) === null || _a === void 0 ? void 0 : _a.includes('SNAPSHOT')); + } bumpVersion(artifact) { const strategy = new java_snapshot_1.JavaSnapshot(new always_bump_patch_1.AlwaysBumpPatch()); return strategy.bump(version_1.Version.parse(artifact.version), [FAKE_COMMIT]); @@ -88435,7 +88812,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { return new versioning_strategy_1.PatchVersionUpdate().bump(version); } updateCandidate(existingCandidate, pkg, updatedVersions) { - var _a; + var _a, _b; const graphPackage = (_a = this.packageGraph) === null || _a === void 0 ? void 0 : _a.get(pkg.name); if (!graphPackage) { throw new Error(`Could not find graph package for ${pkg.name}`); @@ -88451,8 +88828,12 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { for (const [depName, resolved] of graphPackage.localDependencies) { const depVersion = updatedVersions.get(depName); if (depVersion && resolved.type !== 'directory') { - updatedPackage.updateLocalDependency(resolved, depVersion.toString(), '^'); - this.logger.info(`${pkg.name}.${depName} updated to ^${depVersion.toString()}`); + const currentVersion = (_b = this.combineDeps(pkg)) === null || _b === void 0 ? void 0 : _b[depName]; + const prefix = currentVersion + ? this.detectRangePrefix(currentVersion) + : ''; + updatedPackage.updateLocalDependency(resolved, depVersion.toString(), prefix); + this.logger.info(`${pkg.name}.${depName} updated to ${prefix}${depVersion.toString()}`); } } const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage); @@ -88550,15 +88931,10 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { return candidates; } async buildGraph(allPackages) { - var _a, _b, _c; const graph = new Map(); const workspacePackageNames = new Set(allPackages.map(packageJson => packageJson.name)); for (const packageJson of allPackages) { - const allDeps = Object.keys({ - ...((_a = packageJson.dependencies) !== null && _a !== void 0 ? _a : {}), - ...((_b = packageJson.devDependencies) !== null && _b !== void 0 ? _b : {}), - ...((_c = packageJson.optionalDependencies) !== null && _c !== void 0 ? _c : {}), - }); + const allDeps = Object.keys(this.combineDeps(packageJson)); const workspaceDeps = allDeps.filter(dep => workspacePackageNames.has(dep)); graph.set(packageJson.name, { deps: workspaceDeps, @@ -88576,8 +88952,28 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { pathFromPackage(pkg) { return pkg.location; } + detectRangePrefix(version) { + return (Object.values(SUPPORTED_RANGE_PREFIXES).find(supportedRangePrefix => version.startsWith(supportedRangePrefix)) || ''); + } + combineDeps(packageJson) { + var _a, _b, _c; + return { + ...((_a = packageJson.dependencies) !== null && _a !== void 0 ? _a : {}), + ...((_b = packageJson.devDependencies) !== null && _b !== void 0 ? _b : {}), + ...((_c = packageJson.optionalDependencies) !== null && _c !== void 0 ? _c : {}), + }; + } } exports.NodeWorkspace = NodeWorkspace; +var SUPPORTED_RANGE_PREFIXES; +(function (SUPPORTED_RANGE_PREFIXES) { + SUPPORTED_RANGE_PREFIXES["CARET"] = "^"; + SUPPORTED_RANGE_PREFIXES["TILDE"] = "~"; + SUPPORTED_RANGE_PREFIXES["GREATER_THAN"] = ">"; + SUPPORTED_RANGE_PREFIXES["LESS_THAN"] = "<"; + SUPPORTED_RANGE_PREFIXES["EQUAL_OR_GREATER_THAN"] = ">="; + SUPPORTED_RANGE_PREFIXES["EQUAL_OR_LESS_THAN"] = "<="; +})(SUPPORTED_RANGE_PREFIXES || (SUPPORTED_RANGE_PREFIXES = {})); function getChangelogDepsNotes(original, updated) { var _a; let depUpdateNotes = ''; @@ -88882,7 +89278,9 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin { const version = this.bumpVersion(pkg); this.logger.debug(`version: ${version} forced bump`); updatedVersions.set(packageName, version); - updatedPathVersions.set(this.pathFromPackage(pkg), version); + if (this.isReleaseVersion(version)) { + updatedPathVersions.set(this.pathFromPackage(pkg), version); + } } } return { @@ -88890,6 +89288,14 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin { updatedPathVersions, }; } + /** + * Given a release version, determine if we should bump the manifest + * version as well. + * @param {Version} _version The release version + */ + isReleaseVersion(_version) { + return true; + } /** * Helper to invert the graph from package => packages that it depends on * to package => packages that depend on it. @@ -90753,7 +91159,8 @@ const CHANGELOG_SECTIONS = [ { type: 'perf', section: 'Performance Improvements' }, { type: 'revert', section: 'Reverts' }, { type: 'docs', section: 'Documentation' }, - { type: 'chore', section: 'Miscellaneous Chores' }, + { type: 'misc', section: 'Miscellaneous' }, + { type: 'chore', section: 'Chores', hidden: true }, { type: 'style', section: 'Styles', hidden: true }, { type: 'refactor', section: 'Code Refactoring', hidden: true }, { type: 'test', section: 'Tests', hidden: true }, @@ -94169,19 +94576,13 @@ class CommitSplit { newPath = newPath.replace(/^\//, ''); newPath = newPath.replace(/$/, '/'); newPath = newPath.replace(/^/, '/'); - for (let exPath of paths) { - exPath = exPath.replace(/$/, '/'); - exPath = exPath.replace(/^/, '/'); - if (newPath.startsWith(exPath) || exPath.startsWith(newPath)) { - throw new Error(`Path prefixes must be unique: ${newPath}, ${exPath}`); - } - } // store them with leading and trailing slashes removed. newPath = newPath.replace(/\/$/, ''); newPath = newPath.replace(/^\//, ''); paths.push(newPath); } - this.packagePaths = paths; + // sort by longest paths first + this.packagePaths = paths.sort((a, b) => b.length - a.length); } } /** @@ -120241,7 +120642,7 @@ module.exports = {}; /***/ ((module) => { "use strict"; -module.exports = {"i8":"14.14.0"}; +module.exports = {"i8":"14.16.0"}; /***/ }),