Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@journeyapps/core-xml

Package Overview
Dependencies
Maintainers
2
Versions
244
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@journeyapps/core-xml - npm Package Compare versions

Comparing version 0.0.0-dev.916fc5f.5f75e8a to 0.0.0-dev.95e34a5

dist/@types/tests/OrderedIncrementalUpdater.test.d.ts

2

dist/@types/src/ElementBuilder.d.ts

@@ -16,2 +16,2 @@ import { XMLElement } from '@journeyapps/domparser/types';

}
export declare type UpdateFunction = (element: XMLElement) => void;
export type UpdateFunction = (element: XMLElement) => void;
import { XMLNode, XMLSerializer } from '@journeyapps/domparser/types';
import { XMLNodeLike } from '@journeyapps/domparser/lib/XMLNode';
declare type NodeFilter = (node: XMLNodeLike) => XMLNode | string;
type NodeFilter = (node: XMLNodeLike) => XMLNode | string;
export declare const serializer: XMLSerializer;
export declare function serialize(node: XMLNodeLike, nodeFilter?: NodeFilter): string;
export {};

@@ -1,3 +0,3 @@

import { XMLElement, XMLPosition, XMLDocument } from '@journeyapps/domparser/types';
import { XMLDOMParser, XMLSerializer, DOMImplementation } from '@journeyapps/domparser/types';
import { XMLSerializer } from '@journeyapps/domparser';
import { DOMImplementation, XMLDocument, XMLDOMParser, XMLElement, XMLPosition } from '@journeyapps/domparser/types';
import { AttributeNode } from './utils';

@@ -30,3 +30,3 @@ export interface ConfiguredParser {

export declare function getAttribute(elem: XMLElement, key: string): string | null;
export declare type XMLPositional = XMLElement | AttributeNode | [XMLElement | AttributeNode, number, number] | XMLRange;
export type XMLPositional = XMLElement | AttributeNode | [XMLElement | AttributeNode, number, number] | XMLRange;
export declare function getPosition(input: XMLPositional): XMLRange;

@@ -36,3 +36,3 @@ export declare function attributeValuePosition(element: XMLElement, attributeName: string, start: number, end: number): XMLRange;

export declare function attributeNode(element: XMLElement, attributeName: string): AttributeNode;
export declare type ErrorType = 'warning' | 'error';
export type ErrorType = 'warning' | 'error';
export declare function error(element: XMLPositional, message: string, type?: ErrorType): ValidationError;

@@ -39,0 +39,0 @@ export declare function warning(element: XMLPositional, message: string): ValidationError;

@@ -10,6 +10,7 @@ "use strict";

// and @journeyapps/domparser for parsing.
//@ts-ignore
const implementation = document.implementation;
const parser = new domparser_1.DOMParser({ implementation });
const serializer = new XMLSerializer();
xml_1.configureParser({
(0, xml_1.configureParser)({
implementation,

@@ -28,3 +29,3 @@ parser,

const serializer = new xmldom.XMLSerializer();
xml_1.configureParser({
(0, xml_1.configureParser)({
implementation,

@@ -31,0 +32,0 @@ parser,

"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
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 });
__export(require("./xml"));
__export(require("./utils"));
__export(require("./OrderedIncrementalUpdater"));
__export(require("./UnorderedIncrementalUpdater"));
__export(require("./pretty"));
__exportStar(require("./xml"), exports);
__exportStar(require("./utils"), exports);
__exportStar(require("./OrderedIncrementalUpdater"), exports);
__exportStar(require("./UnorderedIncrementalUpdater"), exports);
__exportStar(require("./pretty"), exports);
__exportStar(require("./ElementBuilder"), exports);
//# sourceMappingURL=index.js.map
"use strict";
// This is the default import for NodeJS.
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
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 });
// Export the same values as for browsers.
__export(require("./index"));
__exportStar(require("./index"), exports);
// Auto-configure the parser
require("./domparser");
//# sourceMappingURL=node.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrderedIncrementalUpdater = void 0;
const index_1 = require("./index");

@@ -77,7 +78,7 @@ /**

}
else if (index_1.isElement(child) && this.tagMap[child.tagName]) {
else if ((0, index_1.isElement)(child) && this.tagMap[child.tagName]) {
// A known element that isn't inserted already.
// Skip it.
}
else if (index_1.isText(child) && this.textContent !== undefined) {
else if ((0, index_1.isText)(child) && this.textContent !== undefined) {
// Skip any nodes after the first one.

@@ -84,0 +85,0 @@ if (!seenSourceText) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stripWhitespace = exports.serializeToString = exports.prettyText = exports.pretty = void 0;
const types_1 = require("@journeyapps/domparser/types");

@@ -16,3 +17,3 @@ const utils_1 = require("./utils");

const child = document.childNodes.item(i);
if (utils_1.isText(child)) {
if ((0, utils_1.isText)(child)) {
// workaround for xmldom that has text nodes in the document

@@ -60,3 +61,3 @@ continue;

const child = children[i];
if (utils_1.isText(child)) {
if ((0, utils_1.isText)(child)) {
// Workaround for xmldom inserting extra newlines

@@ -106,3 +107,3 @@ continue;

let newNode = node.cloneNode(false);
if (utils_1.isText(node)) {
if ((0, utils_1.isText)(node)) {
const trimmedText = node.nodeValue.trim();

@@ -125,3 +126,3 @@ const newLines = node.nodeValue.split('\n').length - 1;

}
else if (utils_1.isElement(node)) {
else if ((0, utils_1.isElement)(node)) {
let filteredChildren = [];

@@ -133,3 +134,3 @@ for (let i = 0; i < node.childNodes.length; i++) {

filteredChildren = filteredChildren.filter((node) => node != null);
if (filteredChildren.length == 1 && utils_1.isText(filteredChildren[0])) {
if (filteredChildren.length == 1 && (0, utils_1.isText)(filteredChildren[0])) {
// Text on its own. Preserve whitespace.

@@ -160,3 +161,3 @@ newNode.appendChild(filteredChildren[0]);

else {
if (utils_1.isText(child)) {
if ((0, utils_1.isText)(child)) {
// Text in mixed-mode.

@@ -163,0 +164,0 @@ // We currently preserve whitespace _before_ the text element, but not _after_.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serialize = exports.serializer = void 0;
const types_1 = require("@journeyapps/domparser/types");

@@ -58,3 +59,3 @@ const utils_1 = require("./utils");

}
if (utils_1.isElement(node)) {
if ((0, utils_1.isElement)(node)) {
if (!visibleNamespaces) {

@@ -120,12 +121,12 @@ visibleNamespaces = [];

}
else if (utils_1.isAttribute(node)) {
else if ((0, utils_1.isAttribute)(node)) {
buf.push(' ', node.name, '="', node.value.replace(/[<&"]/g, _xmlEncoder), '"');
}
else if (utils_1.isText(node)) {
else if ((0, utils_1.isText)(node)) {
buf.push(node.data.replace(/[<&]/g, _xmlEncoder));
}
else if (utils_1.isCdataNode(node)) {
else if ((0, utils_1.isCdataNode)(node)) {
buf.push('<![CDATA[', node.data, ']]>');
}
else if (utils_1.isCommentNode(node)) {
else if ((0, utils_1.isCommentNode)(node)) {
buf.push('<!--', node.data, '-->');

@@ -132,0 +133,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnorderedIncrementalUpdater = void 0;
const index_1 = require("./index");

@@ -61,4 +62,4 @@ /**

// Copy existing children
for (let child of index_1.iter(this.sourceElement.childNodes)) {
if (index_1.isElement(child) && child.tagName in this.sourceElements) {
for (let child of (0, index_1.iter)(this.sourceElement.childNodes)) {
if ((0, index_1.isElement)(child) && child.tagName in this.sourceElements) {
if (this.sourceElements[child.tagName].has(child)) {

@@ -65,0 +66,0 @@ // Present - update!

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.iter = exports.setAttributes = exports.isCommentNode = exports.isCdataNode = exports.isText = exports.isElement = exports.isAttribute = exports.DOCUMENT_NODE = exports.TEXT_NODE = exports.ATTRIBUTE_NODE = exports.ELEMENT_NODE = void 0;
const types_1 = require("@journeyapps/domparser/types");

@@ -4,0 +5,0 @@ // From: http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.childContent = exports.childNode = exports.documentToText = exports.createDocument = exports.parse = exports.configureParser = exports.getParser = exports.validateChildren = exports.children = exports.attribute = exports.parseElement = exports.warning = exports.error = exports.attributeNode = exports.elementTextPosition = exports.attributeValuePosition = exports.getPosition = exports.getAttribute = void 0;
const domparser_1 = require("@journeyapps/domparser");
const utils_1 = require("./utils");

@@ -48,3 +50,3 @@ let configuredParser = null;

var owner;
if (utils_1.isAttribute(node)) {
if ((0, utils_1.isAttribute)(node)) {
owner = node.ownerElement.ownerDocument;

@@ -61,3 +63,3 @@ }

}
else if (utils_1.isElement(node) && node.openStart != null && node.nameEnd != null) {
else if ((0, utils_1.isElement)(node) && node.openStart != null && node.nameEnd != null) {
// This is an element

@@ -67,3 +69,3 @@ position.start = locator.position(node.openStart + 1);

}
else if (utils_1.isAttribute(node)) {
else if ((0, utils_1.isAttribute)(node)) {
// This is an attribute

@@ -199,3 +201,4 @@ var attrPosition = node.ownerElement.attributePositions == null ? null : node.ownerElement.attributePositions[node.name];

};
if (type == null) {
// The specific tag exclusions if for the specs
if (type == null && tag != 'context-menu' && tag != 'button') {
result.type = null;

@@ -289,19 +292,31 @@ result.errors.push(warning(element, "Invalid element '" + tag + "'"));

return function (valuesString, element) {
var values = valuesString.split(',');
var invalidValues = [];
Array.prototype.forEach.call(values, function (value) {
if (options.indexOf(value) == -1) {
invalidValues.push(value);
}
});
if (invalidValues.length === 0) {
return validateMultiOptions(valuesString, element, options, customMessage);
};
};
exports.attribute.multiOptionListWithFunctions = function multiOptionList(options, functionPrefix, customMessage) {
return function (valuesString, element) {
if (valuesString.indexOf(functionPrefix) === 0) {
// function token expression, therefore allow
return valuesString;
}
else {
var message = 'Invalid values: ' + invalidValues + '. ';
var extraMessage = customMessage == null ? element.name + ' values must be from ' + options : customMessage;
throw new Error(message + extraMessage);
}
return validateMultiOptions(valuesString, element, options, customMessage);
};
};
function validateMultiOptions(valuesString, element, options, customMessage) {
var values = valuesString.split(',');
var invalidValues = [];
values.forEach((value) => {
if (options.indexOf(value) == -1) {
invalidValues.push(value);
}
});
if (invalidValues.length === 0) {
return valuesString;
}
else {
var message = 'Invalid values: ' + invalidValues + '. ';
var extraMessage = customMessage == null ? element.name + ' values must be from ' + options : customMessage;
throw new Error(message + extraMessage);
}
}
// filter can be an array of strings, or a comma-separated list

@@ -326,3 +341,3 @@ function children(element, filter) {

var child = all[i];
if (utils_1.isElement(child) &&
if ((0, utils_1.isElement)(child) &&
child.tagName != null &&

@@ -340,3 +355,3 @@ (allowedNames == null || allowedNames.indexOf(child.tagName) != -1)) {

Array.prototype.forEach.call(element.childNodes, function (child) {
if (utils_1.isElement(child)) {
if ((0, utils_1.isElement)(child)) {
var tag = child.tagName;

@@ -374,5 +389,7 @@ var order = tagNames[tag];

configureParser({
//@ts-ignore
implementation: document.implementation,
//@ts-ignore
parser: new DOMParser(),
serializer: new XMLSerializer()
serializer: new domparser_1.XMLSerializer()
});

@@ -409,3 +426,3 @@ }

var child = element.childNodes[i];
if (utils_1.isElement(child) && child.tagName == childName) {
if ((0, utils_1.isElement)(child) && child.tagName == childName) {
return child;

@@ -412,0 +429,0 @@ }

{
"name": "@journeyapps/core-xml",
"version": "0.0.0-dev.916fc5f.5f75e8a",
"description": "Journey JS library",
"version": "0.0.0-dev.95e34a5",
"description": "Journey XML library",
"main": "./dist/src/node.js",
"browser": "./dist/src/index.js",
"typings": "./dist/@types/src/index",
"scripts": {
"build": "../node_modules/.bin/tsc --build",
"test": "yarn build && yarn test:node && yarn test:browser",
"test:browser": "karma start karma.conf.js --single-run",
"test:node": "jasmine dist/test/unit/all.js"
},
"dependencies": {
"@journeyapps/domparser": "^0.3.0"
},
"devDependencies": {
"@journeyapps/core-test-helpers": "0.0.0-dev.916fc5f.5f75e8a"
},
"files": [

@@ -25,3 +13,17 @@ "dist/src",

],
"gitHead": "7efac88e5b97e0b1eeb78090f697f17dfbea0b66"
}
"dependencies": {
"@journeyapps/domparser": "^0.4.1",
"xmldom": "^0.6.0"
},
"devDependencies": {
"jsdom": "^24.0.0",
"stream-browserify": "^3.0.0"
},
"scripts": {
"build": "../node_modules/.bin/tsc --build",
"clean": "tsc -b --clean && rm -rf ./dist",
"test": "pnpm build && pnpm test:node && pnpm test:browser",
"test:browser": "vitest --run --config vitest.config.browser.ts ",
"test:node": "vitest --run --config vitest.config.unit.ts"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc