MinsoftK

10

Showing 1000 changed files with 0 additions and 4791 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

// Standard YAML's Core schema.
// http://www.yaml.org/spec/1.2/spec.html#id2804923
//
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
// So, Core schema has no distinctions from JSON schema is JS-YAML.
'use strict';
var Schema = require('../schema');
module.exports = new Schema({
include: [
require('./json')
]
});
// JS-YAML's default schema for `load` function.
// It is not described in the YAML specification.
//
// This schema is based on JS-YAML's default safe schema and includes
// JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
//
// Also this schema is used as default base schema at `Schema.create` function.
'use strict';
var Schema = require('../schema');
module.exports = Schema.DEFAULT = new Schema({
include: [
require('./default_safe')
],
explicit: [
require('../type/js/undefined'),
require('../type/js/regexp'),
require('../type/js/function')
]
});
// JS-YAML's default schema for `safeLoad` function.
// It is not described in the YAML specification.
//
// This schema is based on standard YAML's Core schema and includes most of
// extra types described at YAML tag repository. (http://yaml.org/type/)
'use strict';
var Schema = require('../schema');
module.exports = new Schema({
include: [
require('./core')
],
implicit: [
require('../type/timestamp'),
require('../type/merge')
],
explicit: [
require('../type/binary'),
require('../type/omap'),
require('../type/pairs'),
require('../type/set')
]
});
// Standard YAML's Failsafe schema.
// http://www.yaml.org/spec/1.2/spec.html#id2802346
'use strict';
var Schema = require('../schema');
module.exports = new Schema({
explicit: [
require('../type/str'),
require('../type/seq'),
require('../type/map')
]
});
// Standard YAML's JSON schema.
// http://www.yaml.org/spec/1.2/spec.html#id2803231
//
// NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
// So, this schema is not such strict as defined in the YAML specification.
// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
'use strict';
var Schema = require('../schema');
module.exports = new Schema({
include: [
require('./failsafe')
],
implicit: [
require('../type/null'),
require('../type/bool'),
require('../type/int'),
require('../type/float')
]
});
'use strict';
var YAMLException = require('./exception');
var TYPE_CONSTRUCTOR_OPTIONS = [
'kind',
'resolve',
'construct',
'instanceOf',
'predicate',
'represent',
'defaultStyle',
'styleAliases'
];
var YAML_NODE_KINDS = [
'scalar',
'sequence',
'mapping'
];
function compileStyleAliases(map) {
var result = {};
if (map !== null) {
Object.keys(map).forEach(function (style) {
map[style].forEach(function (alias) {
result[String(alias)] = style;
});
});
}
return result;
}
function Type(tag, options) {
options = options || {};
Object.keys(options).forEach(function (name) {
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
}
});
// TODO: Add tag format check.
this.tag = tag;
this.kind = options['kind'] || null;
this.resolve = options['resolve'] || function () { return true; };
this.construct = options['construct'] || function (data) { return data; };
this.instanceOf = options['instanceOf'] || null;
this.predicate = options['predicate'] || null;
this.represent = options['represent'] || null;
this.defaultStyle = options['defaultStyle'] || null;
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
}
}
module.exports = Type;
'use strict';
/*eslint-disable no-bitwise*/
var NodeBuffer;
try {
// A trick for browserified version, to not include `Buffer` shim
var _require = require;
NodeBuffer = _require('buffer').Buffer;
} catch (__) {}
var Type = require('../type');
// [ 64, 65, 66 ] -> [ padding, CR, LF ]
var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
function resolveYamlBinary(data) {
if (data === null) return false;
var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
// Convert one by one.
for (idx = 0; idx < max; idx++) {
code = map.indexOf(data.charAt(idx));
// Skip CR/LF
if (code > 64) continue;
// Fail on illegal characters
if (code < 0) return false;
bitlen += 6;
}
// If there are any bits left, source was corrupted
return (bitlen % 8) === 0;
}
function constructYamlBinary(data) {
var idx, tailbits,
input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
max = input.length,
map = BASE64_MAP,
bits = 0,
result = [];
// Collect by 6*4 bits (3 bytes)
for (idx = 0; idx < max; idx++) {
if ((idx % 4 === 0) && idx) {
result.push((bits >> 16) & 0xFF);
result.push((bits >> 8) & 0xFF);
result.push(bits & 0xFF);
}
bits = (bits << 6) | map.indexOf(input.charAt(idx));
}
// Dump tail
tailbits = (max % 4) * 6;
if (tailbits === 0) {
result.push((bits >> 16) & 0xFF);
result.push((bits >> 8) & 0xFF);
result.push(bits & 0xFF);
} else if (tailbits === 18) {
result.push((bits >> 10) & 0xFF);
result.push((bits >> 2) & 0xFF);
} else if (tailbits === 12) {
result.push((bits >> 4) & 0xFF);
}
// Wrap into Buffer for NodeJS and leave Array for browser
if (NodeBuffer) {
// Support node 6.+ Buffer API when available
return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
}
return result;
}
function representYamlBinary(object /*, style*/) {
var result = '', bits = 0, idx, tail,
max = object.length,
map = BASE64_MAP;
// Convert every three bytes to 4 ASCII characters.
for (idx = 0; idx < max; idx++) {
if ((idx % 3 === 0) && idx) {
result += map[(bits >> 18) & 0x3F];
result += map[(bits >> 12) & 0x3F];
result += map[(bits >> 6) & 0x3F];
result += map[bits & 0x3F];
}
bits = (bits << 8) + object[idx];
}
// Dump tail
tail = max % 3;
if (tail === 0) {
result += map[(bits >> 18) & 0x3F];
result += map[(bits >> 12) & 0x3F];
result += map[(bits >> 6) & 0x3F];
result += map[bits & 0x3F];
} else if (tail === 2) {
result += map[(bits >> 10) & 0x3F];
result += map[(bits >> 4) & 0x3F];
result += map[(bits << 2) & 0x3F];
result += map[64];
} else if (tail === 1) {
result += map[(bits >> 2) & 0x3F];
result += map[(bits << 4) & 0x3F];
result += map[64];
result += map[64];
}
return result;
}
function isBinary(object) {
return NodeBuffer && NodeBuffer.isBuffer(object);
}
module.exports = new Type('tag:yaml.org,2002:binary', {
kind: 'scalar',
resolve: resolveYamlBinary,
construct: constructYamlBinary,
predicate: isBinary,
represent: representYamlBinary
});
'use strict';
var Type = require('../type');
function resolveYamlBoolean(data) {
if (data === null) return false;
var max = data.length;
return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
(max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
}
function constructYamlBoolean(data) {
return data === 'true' ||
data === 'True' ||
data === 'TRUE';
}
function isBoolean(object) {
return Object.prototype.toString.call(object) === '[object Boolean]';
}
module.exports = new Type('tag:yaml.org,2002:bool', {
kind: 'scalar',
resolve: resolveYamlBoolean,
construct: constructYamlBoolean,
predicate: isBoolean,
represent: {
lowercase: function (object) { return object ? 'true' : 'false'; },
uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
camelcase: function (object) { return object ? 'True' : 'False'; }
},
defaultStyle: 'lowercase'
});
'use strict';
var common = require('../common');
var Type = require('../type');
var YAML_FLOAT_PATTERN = new RegExp(
// 2.5e4, 2.5 and integers
'^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
// .2e4, .2
// special case, seems not from spec
'|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
// 20:59
'|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
// .inf
'|[-+]?\\.(?:inf|Inf|INF)' +
// .nan
'|\\.(?:nan|NaN|NAN))$');
function resolveYamlFloat(data) {
if (data === null) return false;
if (!YAML_FLOAT_PATTERN.test(data) ||
// Quick hack to not allow integers end with `_`
// Probably should update regexp & check speed
data[data.length - 1] === '_') {
return false;
}
return true;
}
function constructYamlFloat(data) {
var value, sign, base, digits;
value = data.replace(/_/g, '').toLowerCase();
sign = value[0] === '-' ? -1 : 1;
digits = [];
if ('+-'.indexOf(value[0]) >= 0) {
value = value.slice(1);
}
if (value === '.inf') {
return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
} else if (value === '.nan') {
return NaN;
} else if (value.indexOf(':') >= 0) {
value.split(':').forEach(function (v) {
digits.unshift(parseFloat(v, 10));
});
value = 0.0;
base = 1;
digits.forEach(function (d) {
value += d * base;
base *= 60;
});
return sign * value;
}
return sign * parseFloat(value, 10);
}
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
function representYamlFloat(object, style) {
var res;
if (isNaN(object)) {
switch (style) {
case 'lowercase': return '.nan';
case 'uppercase': return '.NAN';
case 'camelcase': return '.NaN';
}
} else if (Number.POSITIVE_INFINITY === object) {
switch (style) {
case 'lowercase': return '.inf';
case 'uppercase': return '.INF';
case 'camelcase': return '.Inf';
}
} else if (Number.NEGATIVE_INFINITY === object) {
switch (style) {
case 'lowercase': return '-.inf';
case 'uppercase': return '-.INF';
case 'camelcase': return '-.Inf';
}
} else if (common.isNegativeZero(object)) {
return '-0.0';
}
res = object.toString(10);
// JS stringifier can build scientific format without dots: 5e-100,
// while YAML requres dot: 5.e-100. Fix it with simple hack
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
}
function isFloat(object) {
return (Object.prototype.toString.call(object) === '[object Number]') &&
(object % 1 !== 0 || common.isNegativeZero(object));
}
module.exports = new Type('tag:yaml.org,2002:float', {
kind: 'scalar',
resolve: resolveYamlFloat,
construct: constructYamlFloat,
predicate: isFloat,
represent: representYamlFloat,
defaultStyle: 'lowercase'
});
'use strict';
var common = require('../common');
var Type = require('../type');
function isHexCode(c) {
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
((0x61/* a */ <= c) && (c <= 0x66/* f */));
}
function isOctCode(c) {
return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
}
function isDecCode(c) {
return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
}
function resolveYamlInteger(data) {
if (data === null) return false;
var max = data.length,
index = 0,
hasDigits = false,
ch;
if (!max) return false;
ch = data[index];
// sign
if (ch === '-' || ch === '+') {
ch = data[++index];
}
if (ch === '0') {
// 0
if (index + 1 === max) return true;
ch = data[++index];
// base 2, base 8, base 16
if (ch === 'b') {
// base 2
index++;
for (; index < max; index++) {
ch = data[index];
if (ch === '_') continue;
if (ch !== '0' && ch !== '1') return false;
hasDigits = true;
}
return hasDigits && ch !== '_';
}
if (ch === 'x') {
// base 16
index++;
for (; index < max; index++) {
ch = data[index];
if (ch === '_') continue;
if (!isHexCode(data.charCodeAt(index))) return false;
hasDigits = true;
}
return hasDigits && ch !== '_';
}
// base 8
for (; index < max; index++) {
ch = data[index];
if (ch === '_') continue;
if (!isOctCode(data.charCodeAt(index))) return false;
hasDigits = true;
}
return hasDigits && ch !== '_';
}
// base 10 (except 0) or base 60
// value should not start with `_`;
if (ch === '_') return false;
for (; index < max; index++) {
ch = data[index];
if (ch === '_') continue;
if (ch === ':') break;
if (!isDecCode(data.charCodeAt(index))) {
return false;
}
hasDigits = true;
}
// Should have digits and should not end with `_`
if (!hasDigits || ch === '_') return false;
// if !base60 - done;
if (ch !== ':') return true;
// base60 almost not used, no needs to optimize
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
}
function constructYamlInteger(data) {
var value = data, sign = 1, ch, base, digits = [];
if (value.indexOf('_') !== -1) {
value = value.replace(/_/g, '');
}
ch = value[0];
if (ch === '-' || ch === '+') {
if (ch === '-') sign = -1;
value = value.slice(1);
ch = value[0];
}
if (value === '0') return 0;
if (ch === '0') {
if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
if (value[1] === 'x') return sign * parseInt(value, 16);
return sign * parseInt(value, 8);
}
if (value.indexOf(':') !== -1) {
value.split(':').forEach(function (v) {
digits.unshift(parseInt(v, 10));
});
value = 0;
base = 1;
digits.forEach(function (d) {
value += (d * base);
base *= 60;
});
return sign * value;
}
return sign * parseInt(value, 10);
}
function isInteger(object) {
return (Object.prototype.toString.call(object)) === '[object Number]' &&
(object % 1 === 0 && !common.isNegativeZero(object));
}
module.exports = new Type('tag:yaml.org,2002:int', {
kind: 'scalar',
resolve: resolveYamlInteger,
construct: constructYamlInteger,
predicate: isInteger,
represent: {
binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
decimal: function (obj) { return obj.toString(10); },
/* eslint-disable max-len */
hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
},
defaultStyle: 'decimal',
styleAliases: {
binary: [ 2, 'bin' ],
octal: [ 8, 'oct' ],
decimal: [ 10, 'dec' ],
hexadecimal: [ 16, 'hex' ]
}
});
'use strict';
var esprima;
// Browserified version does not have esprima
//
// 1. For node.js just require module as deps
// 2. For browser try to require mudule via external AMD system.
// If not found - try to fallback to window.esprima. If not
// found too - then fail to parse.
//
try {
// workaround to exclude package from browserify list.
var _require = require;
esprima = _require('esprima');
} catch (_) {
/* eslint-disable no-redeclare */
/* global window */
if (typeof window !== 'undefined') esprima = window.esprima;
}
var Type = require('../../type');
function resolveJavascriptFunction(data) {
if (data === null) return false;
try {
var source = '(' + data + ')',
ast = esprima.parse(source, { range: true });
if (ast.type !== 'Program' ||
ast.body.length !== 1 ||
ast.body[0].type !== 'ExpressionStatement' ||
(ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
ast.body[0].expression.type !== 'FunctionExpression')) {
return false;
}
return true;
} catch (err) {
return false;
}
}
function constructJavascriptFunction(data) {
/*jslint evil:true*/
var source = '(' + data + ')',
ast = esprima.parse(source, { range: true }),
params = [],
body;
if (ast.type !== 'Program' ||
ast.body.length !== 1 ||
ast.body[0].type !== 'ExpressionStatement' ||
(ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
ast.body[0].expression.type !== 'FunctionExpression')) {
throw new Error('Failed to resolve function');
}
ast.body[0].expression.params.forEach(function (param) {
params.push(param.name);
});
body = ast.body[0].expression.body.range;
// Esprima's ranges include the first '{' and the last '}' characters on
// function expressions. So cut them out.
if (ast.body[0].expression.body.type === 'BlockStatement') {
/*eslint-disable no-new-func*/
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
}
// ES6 arrow functions can omit the BlockStatement. In that case, just return
// the body.
/*eslint-disable no-new-func*/
return new Function(params, 'return ' + source.slice(body[0], body[1]));
}
function representJavascriptFunction(object /*, style*/) {
return object.toString();
}
function isFunction(object) {
return Object.prototype.toString.call(object) === '[object Function]';
}
module.exports = new Type('tag:yaml.org,2002:js/function', {
kind: 'scalar',
resolve: resolveJavascriptFunction,
construct: constructJavascriptFunction,
predicate: isFunction,
represent: representJavascriptFunction
});
'use strict';
var Type = require('../../type');
function resolveJavascriptRegExp(data) {
if (data === null) return false;
if (data.length === 0) return false;
var regexp = data,
tail = /\/([gim]*)$/.exec(data),
modifiers = '';
// if regexp starts with '/' it can have modifiers and must be properly closed
// `/foo/gim` - modifiers tail can be maximum 3 chars
if (regexp[0] === '/') {
if (tail) modifiers = tail[1];
if (modifiers.length > 3) return false;
// if expression starts with /, is should be properly terminated
if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
}
return true;
}
function constructJavascriptRegExp(data) {
var regexp = data,
tail = /\/([gim]*)$/.exec(data),
modifiers = '';
// `/foo/gim` - tail can be maximum 4 chars
if (regexp[0] === '/') {
if (tail) modifiers = tail[1];
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
}
return new RegExp(regexp, modifiers);
}
function representJavascriptRegExp(object /*, style*/) {
var result = '/' + object.source + '/';
if (object.global) result += 'g';
if (object.multiline) result += 'm';
if (object.ignoreCase) result += 'i';
return result;
}
function isRegExp(object) {
return Object.prototype.toString.call(object) === '[object RegExp]';
}
module.exports = new Type('tag:yaml.org,2002:js/regexp', {
kind: 'scalar',
resolve: resolveJavascriptRegExp,
construct: constructJavascriptRegExp,
predicate: isRegExp,
represent: representJavascriptRegExp
});
'use strict';
var Type = require('../../type');
function resolveJavascriptUndefined() {
return true;
}
function constructJavascriptUndefined() {
/*eslint-disable no-undefined*/
return undefined;
}
function representJavascriptUndefined() {
return '';
}
function isUndefined(object) {
return typeof object === 'undefined';
}
module.exports = new Type('tag:yaml.org,2002:js/undefined', {
kind: 'scalar',
resolve: resolveJavascriptUndefined,
construct: constructJavascriptUndefined,
predicate: isUndefined,
represent: representJavascriptUndefined
});
'use strict';
var Type = require('../type');
module.exports = new Type('tag:yaml.org,2002:map', {
kind: 'mapping',
construct: function (data) { return data !== null ? data : {}; }
});
'use strict';
var Type = require('../type');
function resolveYamlMerge(data) {
return data === '<<' || data === null;
}
module.exports = new Type('tag:yaml.org,2002:merge', {
kind: 'scalar',
resolve: resolveYamlMerge
});
'use strict';
var Type = require('../type');
function resolveYamlNull(data) {
if (data === null) return true;
var max = data.length;
return (max === 1 && data === '~') ||
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
}
function constructYamlNull() {
return null;
}
function isNull(object) {
return object === null;
}
module.exports = new Type('tag:yaml.org,2002:null', {
kind: 'scalar',
resolve: resolveYamlNull,
construct: constructYamlNull,
predicate: isNull,
represent: {
canonical: function () { return '~'; },
lowercase: function () { return 'null'; },
uppercase: function () { return 'NULL'; },
camelcase: function () { return 'Null'; }
},
defaultStyle: 'lowercase'
});
'use strict';
var Type = require('../type');
var _hasOwnProperty = Object.prototype.hasOwnProperty;
var _toString = Object.prototype.toString;
function resolveYamlOmap(data) {
if (data === null) return true;
var objectKeys = [], index, length, pair, pairKey, pairHasKey,
object = data;
for (index = 0, length = object.length; index < length; index += 1) {
pair = object[index];
pairHasKey = false;
if (_toString.call(pair) !== '[object Object]') return false;
for (pairKey in pair) {
if (_hasOwnProperty.call(pair, pairKey)) {
if (!pairHasKey) pairHasKey = true;
else return false;
}
}
if (!pairHasKey) return false;
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
else return false;
}
return true;
}
function constructYamlOmap(data) {
return data !== null ? data : [];
}
module.exports = new Type('tag:yaml.org,2002:omap', {
kind: 'sequence',
resolve: resolveYamlOmap,
construct: constructYamlOmap
});
'use strict';
var Type = require('../type');
var _toString = Object.prototype.toString;
function resolveYamlPairs(data) {
if (data === null) return true;
var index, length, pair, keys, result,
object = data;
result = new Array(object.length);
for (index = 0, length = object.length; index < length; index += 1) {
pair = object[index];
if (_toString.call(pair) !== '[object Object]') return false;
keys = Object.keys(pair);
if (keys.length !== 1) return false;
result[index] = [ keys[0], pair[keys[0]] ];
}
return true;
}
function constructYamlPairs(data) {
if (data === null) return [];
var index, length, pair, keys, result,
object = data;
result = new Array(object.length);
for (index = 0, length = object.length; index < length; index += 1) {
pair = object[index];
keys = Object.keys(pair);
result[index] = [ keys[0], pair[keys[0]] ];
}
return result;
}
module.exports = new Type('tag:yaml.org,2002:pairs', {
kind: 'sequence',
resolve: resolveYamlPairs,
construct: constructYamlPairs
});
'use strict';
var Type = require('../type');
module.exports = new Type('tag:yaml.org,2002:seq', {
kind: 'sequence',
construct: function (data) { return data !== null ? data : []; }
});
'use strict';
var Type = require('../type');
var _hasOwnProperty = Object.prototype.hasOwnProperty;
function resolveYamlSet(data) {
if (data === null) return true;
var key, object = data;
for (key in object) {
if (_hasOwnProperty.call(object, key)) {
if (object[key] !== null) return false;
}
}
return true;
}
function constructYamlSet(data) {
return data !== null ? data : {};
}
module.exports = new Type('tag:yaml.org,2002:set', {
kind: 'mapping',
resolve: resolveYamlSet,
construct: constructYamlSet
});
'use strict';
var Type = require('../type');
module.exports = new Type('tag:yaml.org,2002:str', {
kind: 'scalar',
construct: function (data) { return data !== null ? data : ''; }
});
'use strict';
var Type = require('../type');
var YAML_DATE_REGEXP = new RegExp(
'^([0-9][0-9][0-9][0-9])' + // [1] year
'-([0-9][0-9])' + // [2] month
'-([0-9][0-9])$'); // [3] day
var YAML_TIMESTAMP_REGEXP = new RegExp(
'^([0-9][0-9][0-9][0-9])' + // [1] year
'-([0-9][0-9]?)' + // [2] month
'-([0-9][0-9]?)' + // [3] day
'(?:[Tt]|[ \\t]+)' + // ...
'([0-9][0-9]?)' + // [4] hour
':([0-9][0-9])' + // [5] minute
':([0-9][0-9])' + // [6] second
'(?:\\.([0-9]*))?' + // [7] fraction
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
'(?::([0-9][0-9]))?))?$'); // [11] tz_minute
function resolveYamlTimestamp(data) {
if (data === null) return false;
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
return false;
}
function constructYamlTimestamp(data) {
var match, year, month, day, hour, minute, second, fraction = 0,
delta = null, tz_hour, tz_minute, date;
match = YAML_DATE_REGEXP.exec(data);
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
if (match === null) throw new Error('Date resolve error');
// match: [1] year [2] month [3] day
year = +(match[1]);
month = +(match[2]) - 1; // JS month starts with 0
day = +(match[3]);
if (!match[4]) { // no hour
return new Date(Date.UTC(year, month, day));
}
// match: [4] hour [5] minute [6] second [7] fraction
hour = +(match[4]);
minute = +(match[5]);
second = +(match[6]);
if (match[7]) {
fraction = match[7].slice(0, 3);
while (fraction.length < 3) { // milli-seconds
fraction += '0';
}
fraction = +fraction;
}
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
if (match[9]) {
tz_hour = +(match[10]);
tz_minute = +(match[11] || 0);
delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
if (match[9] === '-') delta = -delta;
}
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
if (delta) date.setTime(date.getTime() - delta);
return date;
}
function representYamlTimestamp(object /*, style*/) {
return object.toISOString();
}
module.exports = new Type('tag:yaml.org,2002:timestamp', {
kind: 'scalar',
resolve: resolveYamlTimestamp,
construct: constructYamlTimestamp,
instanceOf: Date,
represent: representYamlTimestamp
});
{
"_from": "js-yaml@^3.13.1",
"_id": "js-yaml@3.14.1",
"_inBundle": false,
"_integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
"_location": "/js-yaml",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "js-yaml@^3.13.1",
"name": "js-yaml",
"escapedName": "js-yaml",
"rawSpec": "^3.13.1",
"saveSpec": null,
"fetchSpec": "^3.13.1"
},
"_requiredBy": [
"/@eslint/eslintrc",
"/@istanbuljs/load-nyc-config",
"/cssnano/cosmiconfig",
"/eslint",
"/postcss-load-config/cosmiconfig",
"/svgo"
],
"_resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
"_shasum": "dae812fdb3825fa306609a8717383c50c36a0537",
"_spec": "js-yaml@^3.13.1",
"_where": "C:\\Users\\kkwan_000\\Desktop\\git\\2017110269\\minsung\\node_modules\\svgo",
"author": {
"name": "Vladimir Zapparov",
"email": "dervus.grim@gmail.com"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
},
"bugs": {
"url": "https://github.com/nodeca/js-yaml/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Aleksey V Zapparov",
"email": "ixti@member.fsf.org",
"url": "http://www.ixti.net/"
},
{
"name": "Vitaly Puzrin",
"email": "vitaly@rcdesign.ru",
"url": "https://github.com/puzrin"
},
{
"name": "Martin Grenfell",
"email": "martin.grenfell@gmail.com",
"url": "http://got-ravings.blogspot.com"
}
],
"dependencies": {
"argparse": "^1.0.7",
"esprima": "^4.0.0"
},
"deprecated": false,
"description": "YAML 1.2 parser and serializer",
"devDependencies": {
"ansi": "^0.3.1",
"benchmark": "^2.1.4",
"browserify": "^16.2.2",
"codemirror": "^5.13.4",
"eslint": "^7.0.0",
"fast-check": "^1.24.2",
"istanbul": "^0.4.5",
"mocha": "^7.1.2",
"uglify-js": "^3.0.1"
},
"files": [
"index.js",
"lib/",
"bin/",
"dist/"
],
"homepage": "https://github.com/nodeca/js-yaml",
"jsdelivr": "dist/js-yaml.min.js",
"keywords": [
"yaml",
"parser",
"serializer",
"pyyaml"
],
"license": "MIT",
"name": "js-yaml",
"repository": {
"type": "git",
"url": "git+https://github.com/nodeca/js-yaml.git"
},
"scripts": {
"test": "make test"
},
"unpkg": "dist/js-yaml.min.js",
"version": "3.14.1"
}
node_modules
.DS_Store
\ No newline at end of file
Licensing
---------
This software is covered under the following copyright:
/*
* Copyright (c) 2003-2005 Tom Wu
* 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" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF
* THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* In addition, the following condition applies:
*
* All redistributions must retain an intact copy of this copyright notice
* and disclaimer.
*/
Address all questions regarding this license to:
Tom Wu
tjw@cs.Stanford.EDU
\ No newline at end of file
# jsbn: javascript big number
[Tom Wu's Original Website](http://www-cs-students.stanford.edu/~tjw/jsbn/)
I felt compelled to put this on github and publish to npm. I haven't tested every other big integer library out there, but the few that I have tested in comparison to this one have not even come close in performance. I am aware of the `bi` module on npm, however it has been modified and I wanted to publish the original without modifications. This is jsbn and jsbn2 from Tom Wu's original website above, with the modular pattern applied to prevent global leaks and to allow for use with node.js on the server side.
## usage
var BigInteger = require('jsbn');
var a = new BigInteger('91823918239182398123');
alert(a.bitLength()); // 67
## API
### bi.toString()
returns the base-10 number as a string
### bi.negate()
returns a new BigInteger equal to the negation of `bi`
### bi.abs
returns new BI of absolute value
### bi.compareTo
### bi.bitLength
### bi.mod
### bi.modPowInt
### bi.clone
### bi.intValue
### bi.byteValue
### bi.shortValue
### bi.signum
### bi.toByteArray
### bi.equals
### bi.min
### bi.max
### bi.and
### bi.or
### bi.xor
### bi.andNot
### bi.not
### bi.shiftLeft
### bi.shiftRight
### bi.getLowestSetBit
### bi.bitCount
### bi.testBit
### bi.setBit
### bi.clearBit
### bi.flipBit
### bi.add
### bi.subtract
### bi.multiply
### bi.divide
### bi.remainder
### bi.divideAndRemainder
### bi.modPow
### bi.modInverse
### bi.pow
### bi.gcd
### bi.isProbablePrime
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="index.js"></script>
</body>
</html>
\ No newline at end of file
var BigInteger = require('./');
var a = new BigInteger('91823918239182398123');
console.log(a.bitLength());
\ No newline at end of file
This diff is collapsed. Click to expand it.
{
"_from": "jsbn@~0.1.0",
"_id": "jsbn@0.1.1",
"_inBundle": false,
"_integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
"_location": "/jsbn",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "jsbn@~0.1.0",
"name": "jsbn",
"escapedName": "jsbn",
"rawSpec": "~0.1.0",
"saveSpec": null,
"fetchSpec": "~0.1.0"
},
"_requiredBy": [
"/ecc-jsbn",
"/sshpk"
],
"_resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"_shasum": "a5e654c2e5a2deb5f201d96cefbca80c0ef2f513",
"_spec": "jsbn@~0.1.0",
"_where": "C:\\Users\\kkwan_000\\Desktop\\git\\2017110269\\minsung\\node_modules\\sshpk",
"author": {
"name": "Tom Wu"
},
"bugs": {
"url": "https://github.com/andyperlitch/jsbn/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "The jsbn library is a fast, portable implementation of large-number math in pure JavaScript, enabling public-key crypto and other applications on desktop and mobile browsers.",
"homepage": "https://github.com/andyperlitch/jsbn#readme",
"keywords": [
"biginteger",
"bignumber",
"big",
"integer"
],
"license": "MIT",
"main": "index.js",
"name": "jsbn",
"repository": {
"type": "git",
"url": "git+https://github.com/andyperlitch/jsbn.git"
},
"scripts": {
"test": "mocha test.js"
},
"version": "0.1.1"
}
This diff could not be displayed because it is too large.
Copyright (c) 2010 Elijah Insua
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.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
{
"Object": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Function": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Number": {
"writable": true,
"enumerable": false,
"configurable": true
},
"parseFloat": {
"writable": true,
"enumerable": false,
"configurable": true
},
"parseInt": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Infinity": {
"writable": false,
"enumerable": false,
"configurable": false
},
"NaN": {
"writable": false,
"enumerable": false,
"configurable": false
},
"undefined": {
"writable": false,
"enumerable": false,
"configurable": false
},
"Boolean": {
"writable": true,
"enumerable": false,
"configurable": true
},
"String": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Symbol": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Date": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Promise": {
"writable": true,
"enumerable": false,
"configurable": true
},
"RegExp": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Error": {
"writable": true,
"enumerable": false,
"configurable": true
},
"EvalError": {
"writable": true,
"enumerable": false,
"configurable": true
},
"RangeError": {
"writable": true,
"enumerable": false,
"configurable": true
},
"ReferenceError": {
"writable": true,
"enumerable": false,
"configurable": true
},
"SyntaxError": {
"writable": true,
"enumerable": false,
"configurable": true
},
"TypeError": {
"writable": true,
"enumerable": false,
"configurable": true
},
"URIError": {
"writable": true,
"enumerable": false,
"configurable": true
},
"globalThis": {
"writable": true,
"enumerable": false,
"configurable": true
},
"JSON": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Math": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Intl": {
"writable": true,
"enumerable": false,
"configurable": true
},
"ArrayBuffer": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Uint8Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Int8Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Uint16Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Int16Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Uint32Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Int32Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Float32Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Float64Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Uint8ClampedArray": {
"writable": true,
"enumerable": false,
"configurable": true
},
"BigUint64Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"BigInt64Array": {
"writable": true,
"enumerable": false,
"configurable": true
},
"DataView": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Map": {
"writable": true,
"enumerable": false,
"configurable": true
},
"BigInt": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Set": {
"writable": true,
"enumerable": false,
"configurable": true
},
"WeakMap": {
"writable": true,
"enumerable": false,
"configurable": true
},
"WeakSet": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Proxy": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Reflect": {
"writable": true,
"enumerable": false,
"configurable": true
},
"decodeURI": {
"writable": true,
"enumerable": false,
"configurable": true
},
"decodeURIComponent": {
"writable": true,
"enumerable": false,
"configurable": true
},
"encodeURI": {
"writable": true,
"enumerable": false,
"configurable": true
},
"encodeURIComponent": {
"writable": true,
"enumerable": false,
"configurable": true
},
"escape": {
"writable": true,
"enumerable": false,
"configurable": true
},
"unescape": {
"writable": true,
"enumerable": false,
"configurable": true
},
"eval": {
"writable": true,
"enumerable": false,
"configurable": true
},
"isFinite": {
"writable": true,
"enumerable": false,
"configurable": true
},
"isNaN": {
"writable": true,
"enumerable": false,
"configurable": true
},
"SharedArrayBuffer": {
"writable": true,
"enumerable": false,
"configurable": true
},
"Atomics": {
"writable": true,
"enumerable": false,
"configurable": true
},
"WebAssembly": {
"writable": true,
"enumerable": false,
"configurable": true
}
}
"use strict";
module.exports = function (nameForErrorMessage, window) {
if (!window) {
// Do nothing for window-less documents.
return;
}
const error = new Error(`Not implemented: ${nameForErrorMessage}`);
error.type = "not implemented";
window._virtualConsole.emit("jsdomError", error);
};
"use strict";
const parse5 = require("parse5");
const { createElement } = require("../../living/helpers/create-element");
const DocumentType = require("../../living/generated/DocumentType");
const DocumentFragment = require("../../living/generated/DocumentFragment");
const Text = require("../../living/generated/Text");
const Comment = require("../../living/generated/Comment");
const attributes = require("../../living/attributes");
const nodeTypes = require("../../living/node-type");
const serializationAdapter = require("../../living/domparsing/parse5-adapter-serialization");
const {
customElementReactionsStack, invokeCEReactions, lookupCEDefinition
} = require("../../living/helpers/custom-elements");
// Horrible monkey-patch to implement https://github.com/inikulin/parse5/issues/237 and
// https://github.com/inikulin/parse5/issues/285.
const OpenElementStack = require("parse5/lib/parser/open-element-stack");
const openElementStackOriginalPush = OpenElementStack.prototype.push;
OpenElementStack.prototype.push = function (...args) {
openElementStackOriginalPush.apply(this, args);
this.treeAdapter._currentElement = this.current;
const after = this.items[this.stackTop];
if (after._pushedOnStackOfOpenElements) {
after._pushedOnStackOfOpenElements();
}
};
const openElementStackOriginalPop = OpenElementStack.prototype.pop;
OpenElementStack.prototype.pop = function (...args) {
const before = this.items[this.stackTop];
openElementStackOriginalPop.apply(this, args);
this.treeAdapter._currentElement = this.current;
if (before._poppedOffStackOfOpenElements) {
before._poppedOffStackOfOpenElements();
}
};
class JSDOMParse5Adapter {
constructor(documentImpl, options = {}) {
this._documentImpl = documentImpl;
this._globalObject = documentImpl._globalObject;
this._fragment = options.fragment || false;
// Since the createElement hook doesn't provide the parent element, we keep track of this using _currentElement:
// https://github.com/inikulin/parse5/issues/285. See above horrible monkey-patch for how this is maintained.
this._currentElement = undefined;
}
_ownerDocument() {
const { _currentElement } = this;
// The _currentElement is undefined when parsing elements at the root of the document.
if (_currentElement) {
return _currentElement.localName === "template" ?
_currentElement.content._ownerDocument :
_currentElement._ownerDocument;
}
return this._documentImpl;
}
createDocument() {
// parse5's model assumes that parse(html) will call into here to create the new Document, then return it. However,
// jsdom's model assumes we can create a Window (and through that create an empty Document), do some other setup
// stuff, and then parse, stuffing nodes into that Document as we go. So to adapt between these two models, we just
// return the already-created Document when asked by parse5 to "create" a Document.
return this._documentImpl;
}
createDocumentFragment() {
const ownerDocument = this._ownerDocument();
return DocumentFragment.createImpl(this._globalObject, [], { ownerDocument });
}
// https://html.spec.whatwg.org/#create-an-element-for-the-token
createElement(localName, namespace, attrs) {
const ownerDocument = this._ownerDocument();
const isAttribute = attrs.find(attr => attr.name === "is");
const isValue = isAttribute ? isAttribute.value : null;
const definition = lookupCEDefinition(ownerDocument, namespace, localName);
let willExecuteScript = false;
if (definition !== null && !this._fragment) {
willExecuteScript = true;
}
if (willExecuteScript) {
ownerDocument._throwOnDynamicMarkupInsertionCounter++;
customElementReactionsStack.push([]);
}
const element = createElement(ownerDocument, localName, namespace, null, isValue, willExecuteScript);
this.adoptAttributes(element, attrs);
if (willExecuteScript) {
const queue = customElementReactionsStack.pop();
invokeCEReactions(queue);
ownerDocument._throwOnDynamicMarkupInsertionCounter--;
}
if ("_parserInserted" in element) {
element._parserInserted = true;
}
return element;
}
createCommentNode(data) {
const ownerDocument = this._ownerDocument();
return Comment.createImpl(this._globalObject, [], { data, ownerDocument });
}
appendChild(parentNode, newNode) {
parentNode._append(newNode);
}
insertBefore(parentNode, newNode, referenceNode) {
parentNode._insert(newNode, referenceNode);
}
setTemplateContent(templateElement, contentFragment) {
// This code makes the glue between jsdom and parse5 HTMLTemplateElement parsing:
//
// * jsdom during the construction of the HTMLTemplateElement (for example when create via
// `document.createElement("template")`), creates a DocumentFragment and set it into _templateContents.
// * parse5 when parsing a <template> tag creates an HTMLTemplateElement (`createElement` adapter hook) and also
// create a DocumentFragment (`createDocumentFragment` adapter hook).
//
// At this point we now have to replace the one created in jsdom with one created by parse5.
const { _ownerDocument, _host } = templateElement._templateContents;
contentFragment._ownerDocument = _ownerDocument;
contentFragment._host = _host;
templateElement._templateContents = contentFragment;
}
setDocumentType(document, name, publicId, systemId) {
const ownerDocument = this._ownerDocument();
const documentType = DocumentType.createImpl(this._globalObject, [], { name, publicId, systemId, ownerDocument });
document._append(documentType);
}
setDocumentMode(document, mode) {
// TODO: the rest of jsdom ignores this
document._mode = mode;
}
detachNode(node) {
node.remove();
}
insertText(parentNode, text) {
const { lastChild } = parentNode;
if (lastChild && lastChild.nodeType === nodeTypes.TEXT_NODE) {
lastChild.data += text;
} else {
const ownerDocument = this._ownerDocument();
const textNode = Text.createImpl(this._globalObject, [], { data: text, ownerDocument });
parentNode._append(textNode);
}
}
insertTextBefore(parentNode, text, referenceNode) {
const { previousSibling } = referenceNode;
if (previousSibling && previousSibling.nodeType === nodeTypes.TEXT_NODE) {
previousSibling.data += text;
} else {
const ownerDocument = this._ownerDocument();
const textNode = Text.createImpl(this._globalObject, [], { data: text, ownerDocument });
parentNode._append(textNode, referenceNode);
}
}
adoptAttributes(element, attrs) {
for (const attr of attrs) {
const prefix = attr.prefix === "" ? null : attr.prefix;
attributes.setAttributeValue(element, attr.name, attr.value, prefix, attr.namespace);
}
}
}
// Assign shared adapters with serializer.
Object.assign(JSDOMParse5Adapter.prototype, serializationAdapter);
function parseFragment(markup, contextElement) {
const ownerDocument = contextElement.localName === "template" ?
contextElement.content._ownerDocument :
contextElement._ownerDocument;
const config = Object.assign({}, ownerDocument._parseOptions, {
treeAdapter: new JSDOMParse5Adapter(ownerDocument, {
fragment: true
})
});
return parse5.parseFragment(contextElement, markup, config);
}
function parseIntoDocument(markup, ownerDocument) {
const config = Object.assign({}, ownerDocument._parseOptions, {
treeAdapter: new JSDOMParse5Adapter(ownerDocument)
});
return parse5.parse(markup, config);
}
module.exports = {
parseFragment,
parseIntoDocument
};
"use strict";
const xmlParser = require("./xml");
const htmlParser = require("./html");
// https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm
function parseFragment(markup, contextElement) {
const { _parsingMode } = contextElement._ownerDocument;
let parseAlgorithm;
if (_parsingMode === "html") {
parseAlgorithm = htmlParser.parseFragment;
} else if (_parsingMode === "xml") {
parseAlgorithm = xmlParser.parseFragment;
}
// Note: HTML and XML fragment parsing algorithm already return a document fragments; no need to do steps 3 and 4
return parseAlgorithm(markup, contextElement);
}
function parseIntoDocument(markup, ownerDocument) {
const { _parsingMode } = ownerDocument;
let parseAlgorithm;
if (_parsingMode === "html") {
parseAlgorithm = htmlParser.parseIntoDocument;
} else if (_parsingMode === "xml") {
parseAlgorithm = xmlParser.parseIntoDocument;
}
return parseAlgorithm(markup, ownerDocument);
}
module.exports = {
parseFragment,
parseIntoDocument
};
"use strict";
const { SaxesParser } = require("saxes");
const DOMException = require("domexception/webidl2js-wrapper");
const { createElement } = require("../../living/helpers/create-element");
const DocumentFragment = require("../../living/generated/DocumentFragment");
const DocumentType = require("../../living/generated/DocumentType");
const CDATASection = require("../../living/generated/CDATASection");
const Comment = require("../../living/generated/Comment");
const ProcessingInstruction = require("../../living/generated/ProcessingInstruction");
const Text = require("../../living/generated/Text");
const attributes = require("../../living/attributes");
const { HTML_NS } = require("../../living/helpers/namespaces");
const HTML5_DOCTYPE = /<!doctype html>/i;
const PUBLIC_DOCTYPE = /<!doctype\s+([^\s]+)\s+public\s+"([^"]+)"\s+"([^"]+)"/i;
const SYSTEM_DOCTYPE = /<!doctype\s+([^\s]+)\s+system\s+"([^"]+)"/i;
const CUSTOM_NAME_DOCTYPE = /<!doctype\s+([^\s>]+)/i;
function parseDocType(globalObject, ownerDocument, html) {
if (HTML5_DOCTYPE.test(html)) {
return createDocumentType(globalObject, ownerDocument, "html", "", "");
}
const publicPieces = PUBLIC_DOCTYPE.exec(html);
if (publicPieces) {
return createDocumentType(globalObject, ownerDocument, publicPieces[1], publicPieces[2], publicPieces[3]);
}
const systemPieces = SYSTEM_DOCTYPE.exec(html);
if (systemPieces) {
return createDocumentType(globalObject, ownerDocument, systemPieces[1], "", systemPieces[2]);
}
const namePiece = CUSTOM_NAME_DOCTYPE.exec(html)[1] || "html";
return createDocumentType(globalObject, ownerDocument, namePiece, "", "");
}
function createDocumentType(globalObject, ownerDocument, name, publicId, systemId) {
return DocumentType.createImpl(globalObject, [], { ownerDocument, name, publicId, systemId });
}
function isHTMLTemplateElement(element) {
return element.tagName === "template" && element.namespaceURI === HTML_NS;
}
function createParser(rootNode, globalObject, saxesOptions) {
const parser = new SaxesParser({
...saxesOptions,
// Browsers always have namespace support.
xmlns: true,
// We force the parser to treat all documents (even documents declaring themselves to be XML 1.1 documents) as XML
// 1.0 documents. See https://github.com/jsdom/jsdom/issues/2677 for a discussion of the stakes.
defaultXMLVersion: "1.0",
forceXMLVersion: true
});
const openStack = [rootNode];
function getOwnerDocument() {
const currentElement = openStack[openStack.length - 1];
return isHTMLTemplateElement(currentElement) ?
currentElement._templateContents._ownerDocument :
currentElement._ownerDocument;
}
function appendChild(child) {
const parentElement = openStack[openStack.length - 1];
if (isHTMLTemplateElement(parentElement)) {
parentElement._templateContents._insert(child, null);
} else {
parentElement._insert(child, null);
}
}
parser.on("text", saxesOptions.fragment ?
// In a fragment, all text events produced by saxes must result in a text
// node.
data => {
const ownerDocument = getOwnerDocument();
appendChild(Text.createImpl(globalObject, [], { data, ownerDocument }));
} :
// When parsing a whole document, we must ignore those text nodes that are
// produced outside the root element. Saxes produces events for them,
// but DOM trees do not record text outside the root element.
data => {
if (openStack.length > 1) {
const ownerDocument = getOwnerDocument();
appendChild(Text.createImpl(globalObject, [], { data, ownerDocument }));
}
});
parser.on("cdata", data => {
const ownerDocument = getOwnerDocument();
appendChild(CDATASection.createImpl(globalObject, [], { data, ownerDocument }));
});
parser.on("opentag", tag => {
const { local: tagLocal, attributes: tagAttributes } = tag;
const ownerDocument = getOwnerDocument();
const tagNamespace = tag.uri === "" ? null : tag.uri;
const tagPrefix = tag.prefix === "" ? null : tag.prefix;
const isValue = tagAttributes.is === undefined ? null : tagAttributes.is.value;
const elem = createElement(ownerDocument, tagLocal, tagNamespace, tagPrefix, isValue, true);
// We mark a script element as "parser-inserted", which prevents it from
// being immediately executed.
if (tagLocal === "script" && tagNamespace === HTML_NS) {
elem._parserInserted = true;
}
for (const key of Object.keys(tagAttributes)) {
const { prefix, local, uri, value } = tagAttributes[key];
attributes.setAttributeValue(
elem, local, value, prefix === "" ? null : prefix,
uri === "" ? null : uri
);
}
appendChild(elem);
openStack.push(elem);
});
parser.on("closetag", () => {
const elem = openStack.pop();
// Once a script is populated, we can execute it.
if (elem.localName === "script" && elem.namespaceURI === HTML_NS) {
elem._eval();
}
});
parser.on("comment", data => {
const ownerDocument = getOwnerDocument();
appendChild(Comment.createImpl(globalObject, [], { data, ownerDocument }));
});
parser.on("processinginstruction", ({ target, body }) => {
const ownerDocument = getOwnerDocument();
appendChild(ProcessingInstruction.createImpl(globalObject, [], { target, data: body, ownerDocument }));
});
parser.on("doctype", dt => {
const ownerDocument = getOwnerDocument();
appendChild(parseDocType(globalObject, ownerDocument, `<!doctype ${dt}>`));
const entityMatcher = /<!ENTITY ([^ ]+) "([^"]+)">/g;
let result;
while ((result = entityMatcher.exec(dt))) {
const [, name, value] = result;
if (!(name in parser.ENTITIES)) {
parser.ENTITIES[name] = value;
}
}
});
parser.on("error", err => {
throw DOMException.create(globalObject, [err.message, "SyntaxError"]);
});
return parser;
}
function parseFragment(markup, contextElement) {
const { _globalObject, _ownerDocument } = contextElement;
const fragment = DocumentFragment.createImpl(_globalObject, [], { ownerDocument: _ownerDocument });
// Only parseFragment needs resolvePrefix per the saxes documentation:
// https://github.com/lddubeau/saxes#parsing-xml-fragments
const parser = createParser(fragment, _globalObject, {
fragment: true,
resolvePrefix(prefix) {
// saxes wants undefined as the return value if the prefix is not defined, not null.
return contextElement.lookupNamespaceURI(prefix) || undefined;
}
});
parser.write(markup).close();
return fragment;
}
function parseIntoDocument(markup, ownerDocument) {
const { _globalObject } = ownerDocument;
const parser = createParser(ownerDocument, _globalObject, {
fileName: ownerDocument.location && ownerDocument.location.href
});
parser.write(markup).close();
return ownerDocument;
}
module.exports = {
parseFragment,
parseIntoDocument
};
"use strict";
class QueueItem {
constructor(onLoad, onError, dependentItem) {
this.onLoad = onLoad;
this.onError = onError;
this.data = null;
this.error = null;
this.dependentItem = dependentItem;
}
}
/**
* AsyncResourceQueue is the queue in charge of run the async scripts
* and notify when they finish.
*/
module.exports = class AsyncResourceQueue {
constructor() {
this.items = new Set();
this.dependentItems = new Set();
}
count() {
return this.items.size + this.dependentItems.size;
}
_notify() {
if (this._listener) {
this._listener();
}
}
_check(item) {
let promise;
if (item.onError && item.error) {
promise = item.onError(item.error);
} else if (item.onLoad && item.data) {
promise = item.onLoad(item.data);
}
promise
.then(() => {
this.items.delete(item);
this.dependentItems.delete(item);
if (this.count() === 0) {
this._notify();
}
});
}
setListener(listener) {
this._listener = listener;
}
push(request, onLoad, onError, dependentItem) {
const q = this;
const item = new QueueItem(onLoad, onError, dependentItem);
q.items.add(item);
return request
.then(data => {
item.data = data;
if (dependentItem && !dependentItem.finished) {
q.dependentItems.add(item);
return q.items.delete(item);
}
if (onLoad) {
return q._check(item);
}
q.items.delete(item);
if (q.count() === 0) {
q._notify();
}
return null;
})
.catch(err => {
item.error = err;
if (dependentItem && !dependentItem.finished) {
q.dependentItems.add(item);
return q.items.delete(item);
}
if (onError) {
return q._check(item);
}
q.items.delete(item);
if (q.count() === 0) {
q._notify();
}
return null;
});
}
notifyItem(syncItem) {
for (const item of this.dependentItems) {
if (item.dependentItem === syncItem) {
this._check(item);
}
}
}
};
"use strict";
const ResourceLoader = require("./resource-loader.js");
module.exports = class NoOpResourceLoader extends ResourceLoader {
fetch() {
return null;
}
};
"use strict";
const idlUtils = require("../../living/generated/utils");
const { fireAnEvent } = require("../../living/helpers/events");
module.exports = class PerDocumentResourceLoader {
constructor(document) {
this._document = document;
this._defaultEncoding = document._encoding;
this._resourceLoader = document._defaultView ? document._defaultView._resourceLoader : null;
this._requestManager = document._requestManager;
this._queue = document._queue;
this._deferQueue = document._deferQueue;
this._asyncQueue = document._asyncQueue;
}
fetch(url, { element, onLoad, onError }) {
const request = this._resourceLoader.fetch(url, {
cookieJar: this._document._cookieJar,
element: idlUtils.wrapperForImpl(element),
referrer: this._document.URL
});
if (request === null) {
return null;
}
this._requestManager.add(request);
const onErrorWrapped = error => {
this._requestManager.remove(request);
if (onError) {
onError(error);
}
fireAnEvent("error", element);
const err = new Error(`Could not load ${element.localName}: "${url}"`);
err.type = "resource loading";
err.detail = error;
this._document._defaultView._virtualConsole.emit("jsdomError", err);
return Promise.resolve();
};
const onLoadWrapped = data => {
this._requestManager.remove(request);
this._addCookies(url, request.response ? request.response.headers : {});
try {
const result = onLoad ? onLoad(data) : undefined;
return Promise.resolve(result)
.then(() => {
fireAnEvent("load", element);
return Promise.resolve();
})
.catch(err => {
return onErrorWrapped(err);
});
} catch (err) {
return onErrorWrapped(err);
}
};
if (element.localName === "script" && element.hasAttributeNS(null, "async")) {
this._asyncQueue.push(request, onLoadWrapped, onErrorWrapped, this._queue.getLastScript());
} else if (element.localName === "script" && element.hasAttributeNS(null, "defer")) {
this._deferQueue.push(request, onLoadWrapped, onErrorWrapped, false, element);
} else {
this._queue.push(request, onLoadWrapped, onErrorWrapped, false, element);
}
return request;
}
_addCookies(url, headers) {
let cookies = headers["set-cookie"];
if (!cookies) {
return;
}
if (!Array.isArray(cookies)) {
cookies = [cookies];
}
cookies.forEach(cookie => {
this._document._cookieJar.setCookieSync(cookie, url, { http: true, ignoreError: true });
});
}
};
"use strict";
/**
* Manage all the request and it is able to abort
* all pending request.
*/
module.exports = class RequestManager {
constructor() {
this.openedRequests = [];
}
add(req) {
this.openedRequests.push(req);
}
remove(req) {
const idx = this.openedRequests.indexOf(req);
if (idx !== -1) {
this.openedRequests.splice(idx, 1);
}
}
close() {
for (const openedRequest of this.openedRequests) {
openedRequest.abort();
}
this.openedRequests = [];
}
size() {
return this.openedRequests.length;
}
};
"use strict";
const fs = require("fs");
const { parseURL } = require("whatwg-url");
const dataURLFromRecord = require("data-urls").fromURLRecord;
const request = require("request-promise-native");
const wrapCookieJarForRequest = require("../../living/helpers/wrap-cookie-jar-for-request");
const packageVersion = require("../../../../package.json").version;
const IS_BROWSER = Object.prototype.toString.call(process) !== "[object process]";
module.exports = class ResourceLoader {
constructor({
strictSSL = true,
proxy = undefined,
userAgent = `Mozilla/5.0 (${process.platform || "unknown OS"}) AppleWebKit/537.36 ` +
`(KHTML, like Gecko) jsdom/${packageVersion}`
} = {}) {
this._strictSSL = strictSSL;
this._proxy = proxy;
this._userAgent = userAgent;
}
_readDataURL(urlRecord) {
const dataURL = dataURLFromRecord(urlRecord);
let timeoutId;
const promise = new Promise(resolve => {
timeoutId = setTimeout(resolve, 0, dataURL.body);
});
promise.abort = () => {
if (timeoutId !== undefined) {
clearTimeout(timeoutId);
}
};
return promise;
}
_readFile(filePath) {
let readableStream;
let abort; // Native Promises doesn't have an "abort" method.
/*
* Creating a promise for two reason:
* 1. fetch always return a promise.
* 2. We need to add an abort handler.
*/
const promise = new Promise((resolve, reject) => {
readableStream = fs.createReadStream(filePath);
let data = Buffer.alloc(0);
abort = reject;
readableStream.on("error", reject);
readableStream.on("data", chunk => {
data = Buffer.concat([data, chunk]);
});
readableStream.on("end", () => {
resolve(data);
});
});
promise.abort = () => {
readableStream.destroy();
const error = new Error("request canceled by user");
error.isAbortError = true;
abort(error);
};
return promise;
}
_getRequestOptions({ cookieJar, referrer, accept = "*/*" }) {
const requestOptions = {
encoding: null,
gzip: true,
jar: wrapCookieJarForRequest(cookieJar),
strictSSL: this._strictSSL,
proxy: this._proxy,
forever: true,
headers: {
"User-Agent": this._userAgent,
"Accept-Language": "en",
Accept: accept
}
};
if (referrer && !IS_BROWSER) {
requestOptions.headers.referer = referrer;
}
return requestOptions;
}
fetch(urlString, options = {}) {
const url = parseURL(urlString);
if (!url) {
return Promise.reject(new Error(`Tried to fetch invalid URL ${urlString}`));
}
switch (url.scheme) {
case "data": {
return this._readDataURL(url);
}
case "http":
case "https": {
const requestOptions = this._getRequestOptions(options);
return request(urlString, requestOptions);
}
case "file": {
// TODO: Improve the URL => file algorithm. See https://github.com/jsdom/jsdom/pull/2279#discussion_r199977987
const filePath = urlString
.replace(/^file:\/\//, "")
.replace(/^\/([a-z]):\//i, "$1:/")
.replace(/%20/g, " ");
return this._readFile(filePath);
}
default: {
return Promise.reject(new Error(`Tried to fetch URL ${urlString} with invalid scheme ${url.scheme}`));
}
}
}
};
"use strict";
/**
* Queue for all the resources to be download except async scripts.
* Async scripts have their own queue AsyncResourceQueue.
*/
module.exports = class ResourceQueue {
constructor({ paused, asyncQueue } = {}) {
this.paused = Boolean(paused);
this._asyncQueue = asyncQueue;
}
getLastScript() {
let head = this.tail;
while (head) {
if (head.isScript) {
return head;
}
head = head.prev;
}
return null;
}
_moreScripts() {
let found = false;
let head = this.tail;
while (head && !found) {
found = head.isScript;
head = head.prev;
}
return found;
}
_notify() {
if (this._listener) {
this._listener();
}
}
setListener(listener) {
this._listener = listener;
}
push(request, onLoad, onError, keepLast, element) {
const isScript = element ? element.localName === "script" : false;
if (!request) {
if (isScript && !this._moreScripts()) {
return onLoad();
}
request = new Promise(resolve => resolve());
}
const q = this;
const item = {
isScript,
err: null,
element,
fired: false,
data: null,
keepLast,
prev: q.tail,
check() {
if (!q.paused && !this.prev && this.fired) {
let promise;
if (this.err && onError) {
promise = onError(this.err);
}
if (!this.err && onLoad) {
promise = onLoad(this.data);
}
Promise.resolve(promise)
.then(() => {
if (this.next) {
this.next.prev = null;
this.next.check();
} else { // q.tail===this
q.tail = null;
q._notify();
}
this.finished = true;
if (q._asyncQueue) {
q._asyncQueue.notifyItem(this);
}
});
}
}
};
if (q.tail) {
if (q.tail.keepLast) {
// if the tail is the load event in document and we receive a new element to load
// we should add this new request before the load event.
if (q.tail.prev) {
q.tail.prev.next = item;
}
item.prev = q.tail.prev;
q.tail.prev = item;
item.next = q.tail;
} else {
q.tail.next = item;
q.tail = item;
}
} else {
q.tail = item;
}
return request
.then(data => {
item.fired = 1;
item.data = data;
item.check();
})
.catch(err => {
item.fired = true;
item.err = err;
item.check();
});
}
resume() {
if (!this.paused) {
return;
}
this.paused = false;
let head = this.tail;
while (head && head.prev) {
head = head.prev;
}
if (head) {
head.check();
}
}
};
"use strict";
const cssom = require("cssom");
const cssstyle = require("cssstyle");
exports.addToCore = core => {
// What works now:
// - Accessing the rules defined in individual stylesheets
// - Modifications to style content attribute are reflected in style property
// - Modifications to style property are reflected in style content attribute
// TODO
// - Modifications to style element's textContent are reflected in sheet property.
// - Modifications to style element's sheet property are reflected in textContent.
// - Modifications to link.href property are reflected in sheet property.
// - Less-used features of link: disabled
// - Less-used features of style: disabled, scoped, title
// - CSSOM-View
// - getComputedStyle(): requires default stylesheet, cascading, inheritance,
// filtering by @media (screen? print?), layout for widths/heights
// - Load events are not in the specs, but apparently some browsers
// implement something. Should onload only fire after all @imports have been
// loaded, or only the primary sheet?
core.StyleSheet = cssom.StyleSheet;
core.MediaList = cssom.MediaList;
core.CSSStyleSheet = cssom.CSSStyleSheet;
core.CSSRule = cssom.CSSRule;
core.CSSStyleRule = cssom.CSSStyleRule;
core.CSSMediaRule = cssom.CSSMediaRule;
core.CSSImportRule = cssom.CSSImportRule;
core.CSSStyleDeclaration = cssstyle.CSSStyleDeclaration;
// Relavant specs
// http://www.w3.org/TR/DOM-Level-2-Style (2000)
// http://www.w3.org/TR/cssom-view/ (2008)
// http://dev.w3.org/csswg/cssom/ (2010) Meant to replace DOM Level 2 Style
// http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML5, of course
// http://dev.w3.org/csswg/css-style-attr/ not sure what's new here
// Objects that aren't in cssom library but should be:
// CSSRuleList (cssom just uses array)
// CSSFontFaceRule
// CSSPageRule
// These rules don't really make sense to implement, so CSSOM draft makes them
// obsolete.
// CSSCharsetRule
// CSSUnknownRule
// These objects are considered obsolete by CSSOM draft, although modern
// browsers implement them.
// CSSValue
// CSSPrimitiveValue
// CSSValueList
// RGBColor
// Rect
// Counter
};
This diff is collapsed. Click to expand it.
"use strict";
const AbortSignal = require("../generated/AbortSignal");
class AbortControllerImpl {
constructor(globalObject) {
this.signal = AbortSignal.createImpl(globalObject, []);
}
abort() {
this.signal._signalAbort();
}
}
module.exports = {
implementation: AbortControllerImpl
};
"use strict";
const { setupForSimpleEventAccessors } = require("../helpers/create-event-accessor");
const { fireAnEvent } = require("../helpers/events");
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
class AbortSignalImpl extends EventTargetImpl {
constructor(globalObject, args, privateData) {
super(globalObject, args, privateData);
// make event firing possible
this._ownerDocument = globalObject.document;
this.aborted = false;
this.abortAlgorithms = new Set();
}
_signalAbort() {
if (this.aborted) {
return;
}
this.aborted = true;
for (const algorithm of this.abortAlgorithms) {
algorithm();
}
this.abortAlgorithms.clear();
fireAnEvent("abort", this);
}
_addAlgorithm(algorithm) {
if (this.aborted) {
return;
}
this.abortAlgorithms.add(algorithm);
}
_removeAlgorithm(algorithm) {
this.abortAlgorithms.delete(algorithm);
}
}
setupForSimpleEventAccessors(AbortSignalImpl.prototype, ["abort"]);
module.exports = {
implementation: AbortSignalImpl
};
"use strict";
const DOMException = require("domexception/webidl2js-wrapper");
const { HTML_NS } = require("./helpers/namespaces");
const { asciiLowercase } = require("./helpers/strings");
const { queueAttributeMutationRecord } = require("./helpers/mutation-observers");
const { enqueueCECallbackReaction } = require("./helpers/custom-elements");
// The following three are for https://dom.spec.whatwg.org/#concept-element-attribute-has. We don't just have a
// predicate tester since removing that kind of flexibility gives us the potential for better future optimizations.
/* eslint-disable no-restricted-properties */
exports.hasAttribute = function (element, A) {
return element._attributeList.includes(A);
};
exports.hasAttributeByName = function (element, name) {
return element._attributesByNameMap.has(name);
};
exports.hasAttributeByNameNS = function (element, namespace, localName) {
return element._attributeList.some(attribute => {
return attribute._localName === localName && attribute._namespace === namespace;
});
};
// https://dom.spec.whatwg.org/#concept-element-attributes-change
exports.changeAttribute = (element, attribute, value) => {
const { _localName, _namespace, _value } = attribute;
queueAttributeMutationRecord(element, _localName, _namespace, _value);
if (element._ceState === "custom") {
enqueueCECallbackReaction(element, "attributeChangedCallback", [
_localName,
_value,
value,
_namespace
]);
}
attribute._value = value;
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
element._attrModified(attribute._qualifiedName, value, _value);
};
// https://dom.spec.whatwg.org/#concept-element-attributes-append
exports.appendAttribute = function (element, attribute) {
const { _localName, _namespace, _value } = attribute;
queueAttributeMutationRecord(element, _localName, _namespace, null);
if (element._ceState === "custom") {
enqueueCECallbackReaction(element, "attributeChangedCallback", [
_localName,
null,
_value,
_namespace
]);
}
const attributeList = element._attributeList;
attributeList.push(attribute);
attribute._element = element;
// Sync name cache
const name = attribute._qualifiedName;
const cache = element._attributesByNameMap;
let entry = cache.get(name);
if (!entry) {
entry = [];
cache.set(name, entry);
}
entry.push(attribute);
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is added."
element._attrModified(name, _value, null);
};
exports.removeAttribute = function (element, attribute) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove
const { _localName, _namespace, _value } = attribute;
queueAttributeMutationRecord(element, _localName, _namespace, _value);
if (element._ceState === "custom") {
enqueueCECallbackReaction(element, "attributeChangedCallback", [
_localName,
_value,
null,
_namespace
]);
}
const attributeList = element._attributeList;
for (let i = 0; i < attributeList.length; ++i) {
if (attributeList[i] === attribute) {
attributeList.splice(i, 1);
attribute._element = null;
// Sync name cache
const name = attribute._qualifiedName;
const cache = element._attributesByNameMap;
const entry = cache.get(name);
entry.splice(entry.indexOf(attribute), 1);
if (entry.length === 0) {
cache.delete(name);
}
// Run jsdom hooks; roughly correspond to spec's "An attribute is removed."
element._attrModified(name, null, attribute._value);
return;
}
}
};
exports.replaceAttribute = function (element, oldAttr, newAttr) {
// https://dom.spec.whatwg.org/#concept-element-attributes-replace
const { _localName, _namespace, _value } = oldAttr;
queueAttributeMutationRecord(element, _localName, _namespace, _value);
if (element._ceState === "custom") {
enqueueCECallbackReaction(element, "attributeChangedCallback", [
_localName,
_value,
newAttr._value,
_namespace
]);
}
const attributeList = element._attributeList;
for (let i = 0; i < attributeList.length; ++i) {
if (attributeList[i] === oldAttr) {
attributeList.splice(i, 1, newAttr);
oldAttr._element = null;
newAttr._element = element;
// Sync name cache
const name = newAttr._qualifiedName;
const cache = element._attributesByNameMap;
let entry = cache.get(name);
if (!entry) {
entry = [];
cache.set(name, entry);
}
entry.splice(entry.indexOf(oldAttr), 1, newAttr);
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
element._attrModified(name, newAttr._value, oldAttr._value);
return;
}
}
};
exports.getAttributeByName = function (element, name) {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
if (element._namespaceURI === HTML_NS &&
element._ownerDocument._parsingMode === "html") {
name = asciiLowercase(name);
}
const cache = element._attributesByNameMap;
const entry = cache.get(name);
if (!entry) {
return null;
}
return entry[0];
};
exports.getAttributeByNameNS = function (element, namespace, localName) {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
if (namespace === "") {
namespace = null;
}
const attributeList = element._attributeList;
for (let i = 0; i < attributeList.length; ++i) {
const attr = attributeList[i];
if (attr._namespace === namespace && attr._localName === localName) {
return attr;
}
}
return null;
};
// Both of the following functions implement https://dom.spec.whatwg.org/#concept-element-attributes-get-value.
// Separated them into two to keep symmetry with other functions.
exports.getAttributeValue = function (element, localName) {
const attr = exports.getAttributeByNameNS(element, null, localName);
if (!attr) {
return "";
}
return attr._value;
};
exports.getAttributeValueNS = function (element, namespace, localName) {
const attr = exports.getAttributeByNameNS(element, namespace, localName);
if (!attr) {
return "";
}
return attr._value;
};
exports.setAttribute = function (element, attr) {
// https://dom.spec.whatwg.org/#concept-element-attributes-set
if (attr._element !== null && attr._element !== element) {
throw DOMException.create(element._globalObject, ["The attribute is in use.", "InUseAttributeError"]);
}
const oldAttr = exports.getAttributeByNameNS(element, attr._namespace, attr._localName);
if (oldAttr === attr) {
return attr;
}
if (oldAttr !== null) {
exports.replaceAttribute(element, oldAttr, attr);
} else {
exports.appendAttribute(element, attr);
}
return oldAttr;
};
exports.setAttributeValue = function (element, localName, value, prefix, namespace) {
// https://dom.spec.whatwg.org/#concept-element-attributes-set-value
if (prefix === undefined) {
prefix = null;
}
if (namespace === undefined) {
namespace = null;
}
const attribute = exports.getAttributeByNameNS(element, namespace, localName);
if (attribute === null) {
const newAttribute = element._ownerDocument._createAttribute({
namespace,
namespacePrefix: prefix,
localName,
value
});
exports.appendAttribute(element, newAttribute);
return;
}
exports.changeAttribute(element, attribute, value);
};
// https://dom.spec.whatwg.org/#set-an-existing-attribute-value
exports.setAnExistingAttributeValue = (attribute, value) => {
const element = attribute._element;
if (element === null) {
attribute._value = value;
} else {
exports.changeAttribute(element, attribute, value);
}
};
exports.removeAttributeByName = function (element, name) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
const attr = exports.getAttributeByName(element, name);
if (attr !== null) {
exports.removeAttribute(element, attr);
}
return attr;
};
exports.removeAttributeByNameNS = function (element, namespace, localName) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
const attr = exports.getAttributeByNameNS(element, namespace, localName);
if (attr !== null) {
exports.removeAttribute(element, attr);
}
return attr;
};
exports.attributeNames = function (element) {
// Needed by https://dom.spec.whatwg.org/#dom-element-getattributenames
return element._attributeList.map(a => a._qualifiedName);
};
exports.hasAttributes = function (element) {
// Needed by https://dom.spec.whatwg.org/#dom-element-hasattributes
return element._attributeList.length > 0;
};
"use strict";
const { setAnExistingAttributeValue } = require("../attributes.js");
const NodeImpl = require("../nodes/Node-impl.js").implementation;
const { ATTRIBUTE_NODE } = require("../node-type.js");
exports.implementation = class AttrImpl extends NodeImpl {
constructor(globalObject, args, privateData) {
super(globalObject, args, privateData);
this._namespace = privateData.namespace !== undefined ? privateData.namespace : null;
this._namespacePrefix = privateData.namespacePrefix !== undefined ? privateData.namespacePrefix : null;
this._localName = privateData.localName;
this._value = privateData.value !== undefined ? privateData.value : "";
this._element = privateData.element !== undefined ? privateData.element : null;
this.nodeType = ATTRIBUTE_NODE;
this.specified = true;
}
get namespaceURI() {
return this._namespace;
}
get prefix() {
return this._namespacePrefix;
}
get localName() {
return this._localName;
}
get name() {
return this._qualifiedName;
}
get nodeName() {
return this._qualifiedName;
}
get value() {
return this._value;
}
set value(value) {
setAnExistingAttributeValue(this, value);
}
get ownerElement() {
return this._element;
}
get _qualifiedName() {
// https://dom.spec.whatwg.org/#concept-attribute-qualified-name
if (this._namespacePrefix === null) {
return this._localName;
}
return this._namespacePrefix + ":" + this._localName;
}
};
"use strict";
const DOMException = require("domexception/webidl2js-wrapper");
const idlUtils = require("../generated/utils.js");
const attributes = require("../attributes.js");
const { HTML_NS } = require("../helpers/namespaces");
exports.implementation = class NamedNodeMapImpl {
constructor(globalObject, args, privateData) {
this._element = privateData.element;
this._globalObject = globalObject;
}
get _attributeList() {
return this._element._attributeList;
}
get [idlUtils.supportedPropertyIndices]() {
return this._attributeList.keys();
}
get length() {
return this._attributeList.length;
}
item(index) {
if (index >= this._attributeList.length) {
return null;
}
return this._attributeList[index];
}
get [idlUtils.supportedPropertyNames]() {
const names = new Set(this._attributeList.map(a => a._qualifiedName));
const el = this._element;
if (el._namespaceURI === HTML_NS && el._ownerDocument._parsingMode === "html") {
for (const name of names) {
const lowercaseName = name.toLowerCase();
if (lowercaseName !== name) {
names.delete(name);
}
}
}
return names;
}
getNamedItem(qualifiedName) {
return attributes.getAttributeByName(this._element, qualifiedName);
}
getNamedItemNS(namespace, localName) {
return attributes.getAttributeByNameNS(this._element, namespace, localName);
}
setNamedItem(attr) {
// eslint-disable-next-line no-restricted-properties
return attributes.setAttribute(this._element, attr);
}
setNamedItemNS(attr) {
// eslint-disable-next-line no-restricted-properties
return attributes.setAttribute(this._element, attr);
}
removeNamedItem(qualifiedName) {
const attr = attributes.removeAttributeByName(this._element, qualifiedName);
if (attr === null) {
throw DOMException.create(this._globalObject, [
"Tried to remove an attribute that was not present",
"NotFoundError"
]);
}
return attr;
}
removeNamedItemNS(namespace, localName) {
const attr = attributes.removeAttributeByNameNS(this._element, namespace, localName);
if (attr === null) {
throw DOMException.create(this._globalObject, [
"Tried to remove an attribute that was not present",
"NotFoundError"
]);
}
return attr;
}
};
"use strict";
const ValidityState = require("../generated/ValidityState");
const { isDisabled } = require("../helpers/form-controls");
const { closest } = require("../helpers/traversal");
const { fireAnEvent } = require("../helpers/events");
exports.implementation = class DefaultConstraintValidationImpl {
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-willvalidate
get willValidate() {
return this._isCandidateForConstraintValidation();
}
get validity() {
if (!this._validity) {
this._validity = ValidityState.createImpl(this._globalObject, [], {
element: this
});
}
return this._validity;
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-checkvalidity
checkValidity() {
if (!this._isCandidateForConstraintValidation()) {
return true;
}
if (this._satisfiesConstraints()) {
return true;
}
fireAnEvent("invalid", this, undefined, { cancelable: true });
return false;
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-setcustomvalidity
setCustomValidity(message) {
this._customValidityErrorMessage = message;
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity
// Since jsdom has no user interaction, it's the same as #checkValidity
reportValidity() {
return this.checkValidity();
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-validationmessage
get validationMessage() {
const { validity } = this;
if (!this._isCandidateForConstraintValidation() || this._satisfiesConstraints()) {
return "";
}
const isSufferingFromCustomError = validity.customError;
if (isSufferingFromCustomError) {
return this._customValidityErrorMessage;
}
return "Constraints not satisfied";
}
_isCandidateForConstraintValidation() {
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-disabled
return !isDisabled(this) &&
// If an element has a datalist element ancestor,
// it is barred from constraint validation.
closest(this, "datalist") === null &&
!this._barredFromConstraintValidationSpecialization();
}
_isBarredFromConstraintValidation() {
return !this._isCandidateForConstraintValidation();
}
_satisfiesConstraints() {
return this.validity.valid;
}
};
"use strict";
exports.implementation = class ValidityStateImpl {
constructor(globalObject, args, privateData) {
const { element, state = {} } = privateData;
this._element = element;
this._state = state;
}
get badInput() {
return this._failsConstraint("badInput");
}
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-custom-error
get customError() {
return this._element._customValidityErrorMessage !== "";
}
get patternMismatch() {
return this._failsConstraint("patternMismatch");
}
get rangeOverflow() {
return this._failsConstraint("rangeOverflow");
}
get rangeUnderflow() {
return this._failsConstraint("rangeUnderflow");
}
get stepMismatch() {
return this._failsConstraint("stepMismatch");
}
get tooLong() {
return this._failsConstraint("tooLong");
}
get tooShort() {
return this._failsConstraint("tooShort");
}
get typeMismatch() {
return this._failsConstraint("typeMismatch");
}
get valueMissing() {
return this._failsConstraint("valueMissing");
}
_failsConstraint(method) {
const validationMethod = this._state[method];
if (validationMethod) {
return validationMethod();
}
return false;
}
get valid() {
return !(this.badInput || this.valueMissing || this.customError ||
this.patternMismatch || this.rangeOverflow || this.rangeUnderflow ||
this.stepMismatch || this.tooLong || this.tooShort || this.typeMismatch);
}
};
"use strict";
const idlUtils = require("../generated/utils.js");
exports.implementation = class StyleSheetList {
constructor() {
this._list = [];
}
get length() {
return this._list.length;
}
item(index) {
const result = this._list[index];
return result !== undefined ? result : null;
}
get [idlUtils.supportedPropertyIndices]() {
return this._list.keys();
}
_add(sheet) {
const { _list } = this;
if (!_list.includes(sheet)) {
_list.push(sheet);
}
}
_remove(sheet) {
const { _list } = this;
const index = _list.indexOf(sheet);
if (index >= 0) {
_list.splice(index, 1);
}
}
};
"use strict";
const webIDLConversions = require("webidl-conversions");
const DOMException = require("domexception/webidl2js-wrapper");
const NODE_TYPE = require("../node-type");
const { HTML_NS } = require("../helpers/namespaces");
const { getHTMLElementInterface } = require("../helpers/create-element");
const { shadowIncludingInclusiveDescendantsIterator } = require("../helpers/shadow-dom");
const { isValidCustomElementName, tryUpgradeElement, enqueueCEUpgradeReaction } = require("../helpers/custom-elements");
const idlUtils = require("../generated/utils");
const HTMLUnknownElement = require("../generated/HTMLUnknownElement");
const LIFECYCLE_CALLBACKS = [
"connectedCallback",
"disconnectedCallback",
"adoptedCallback",
"attributeChangedCallback"
];
function convertToSequenceDOMString(obj) {
if (!obj || !obj[Symbol.iterator]) {
throw new TypeError("Invalid Sequence");
}
return Array.from(obj).map(webIDLConversions.DOMString);
}
// Returns true is the passed value is a valid constructor.
// Borrowed from: https://stackoverflow.com/a/39336206/3832710
function isConstructor(value) {
if (typeof value !== "function") {
return false;
}
try {
const P = new Proxy(value, {
construct() {
return {};
}
});
// eslint-disable-next-line no-new
new P();
return true;
} catch {
return false;
}
}
// https://html.spec.whatwg.org/#customelementregistry
class CustomElementRegistryImpl {
constructor(globalObject) {
this._customElementDefinitions = [];
this._elementDefinitionIsRunning = false;
this._whenDefinedPromiseMap = Object.create(null);
this._globalObject = globalObject;
}
// https://html.spec.whatwg.org/#dom-customelementregistry-define
define(name, ctor, options) {
const { _globalObject } = this;
if (!isConstructor(ctor)) {
throw new TypeError("Constructor argument is not a constructor.");
}
if (!isValidCustomElementName(name)) {
throw DOMException.create(_globalObject, ["Name argument is not a valid custom element name.", "SyntaxError"]);
}
const nameAlreadyRegistered = this._customElementDefinitions.some(entry => entry.name === name);
if (nameAlreadyRegistered) {
throw DOMException.create(_globalObject, [
"This name has already been registered in the registry.",
"NotSupportedError"
]);
}
const ctorAlreadyRegistered = this._customElementDefinitions.some(entry => entry.ctor === ctor);
if (ctorAlreadyRegistered) {
throw DOMException.create(_globalObject, [
"This constructor has already been registered in the registry.",
"NotSupportedError"
]);
}
let localName = name;
let extendsOption = null;
if (options !== undefined && options.extends) {
extendsOption = options.extends;
}
if (extendsOption !== null) {
if (isValidCustomElementName(extendsOption)) {
throw DOMException.create(_globalObject, [
"Option extends value can't be a valid custom element name.",
"NotSupportedError"
]);
}
const extendsInterface = getHTMLElementInterface(extendsOption);
if (extendsInterface === HTMLUnknownElement) {
throw DOMException.create(_globalObject, [
`${extendsOption} is an HTMLUnknownElement.`,
"NotSupportedError"
]);
}
localName = extendsOption;
}
if (this._elementDefinitionIsRunning) {
throw DOMException.create(_globalObject, [
"Invalid nested custom element definition.",
"NotSupportedError"
]);
}
this._elementDefinitionIsRunning = true;
let disableShadow = false;
let observedAttributes = [];
const lifecycleCallbacks = {
connectedCallback: null,
disconnectedCallback: null,
adoptedCallback: null,
attributeChangedCallback: null
};
let caughtError;
try {
const { prototype } = ctor;
if (typeof prototype !== "object") {
throw new TypeError("Invalid constructor prototype.");
}
for (const callbackName of LIFECYCLE_CALLBACKS) {
const callbackValue = prototype[callbackName];
if (callbackValue !== undefined) {
lifecycleCallbacks[callbackName] = webIDLConversions.Function(callbackValue);
}
}
if (lifecycleCallbacks.attributeChangedCallback !== null) {
const observedAttributesIterable = ctor.observedAttributes;
if (observedAttributesIterable !== undefined) {
observedAttributes = convertToSequenceDOMString(observedAttributesIterable);
}
}
let disabledFeatures = [];
const disabledFeaturesIterable = ctor.disabledFeatures;
if (disabledFeaturesIterable) {
disabledFeatures = convertToSequenceDOMString(disabledFeaturesIterable);
}
disableShadow = disabledFeatures.includes("shadow");
} catch (err) {
caughtError = err;
} finally {
this._elementDefinitionIsRunning = false;
}
if (caughtError !== undefined) {
throw caughtError;
}
const definition = {
name,
localName,
ctor,
observedAttributes,
lifecycleCallbacks,
disableShadow,
constructionStack: []
};
this._customElementDefinitions.push(definition);
const document = idlUtils.implForWrapper(this._globalObject._document);
const upgradeCandidates = [];
for (const candidate of shadowIncludingInclusiveDescendantsIterator(document)) {
if (
(candidate._namespaceURI === HTML_NS && candidate._localName === localName) &&
(extendsOption === null || candidate._isValue === name)
) {
upgradeCandidates.push(candidate);
}
}
for (const upgradeCandidate of upgradeCandidates) {
enqueueCEUpgradeReaction(upgradeCandidate, definition);
}
if (this._whenDefinedPromiseMap[name] !== undefined) {
this._whenDefinedPromiseMap[name].resolve(undefined);
delete this._whenDefinedPromiseMap[name];
}
}
// https://html.spec.whatwg.org/#dom-customelementregistry-get
get(name) {
const definition = this._customElementDefinitions.find(entry => entry.name === name);
return definition && definition.ctor;
}
// https://html.spec.whatwg.org/#dom-customelementregistry-whendefined
whenDefined(name) {
if (!isValidCustomElementName(name)) {
return Promise.reject(DOMException.create(
this._globalObject,
["Name argument is not a valid custom element name.", "SyntaxError"]
));
}
const alreadyRegistered = this._customElementDefinitions.some(entry => entry.name === name);
if (alreadyRegistered) {
return Promise.resolve();
}
if (this._whenDefinedPromiseMap[name] === undefined) {
let resolve;
const promise = new Promise(r => {
resolve = r;
});
// Store the pending Promise along with the extracted resolve callback to actually resolve the returned Promise,
// once the custom element is registered.
this._whenDefinedPromiseMap[name] = {
promise,
resolve
};
}
return this._whenDefinedPromiseMap[name].promise;
}
// https://html.spec.whatwg.org/#dom-customelementregistry-upgrade
upgrade(root) {
for (const candidate of shadowIncludingInclusiveDescendantsIterator(root)) {
if (candidate.nodeType === NODE_TYPE.ELEMENT_NODE) {
tryUpgradeElement(candidate);
}
}
}
}
module.exports = {
implementation: CustomElementRegistryImpl
};
"use strict";
const XMLDocument = require("../living/generated/XMLDocument.js");
const Document = require("../living/generated/Document.js");
const { wrapperForImpl } = require("./generated/utils.js");
exports.createImpl = (globalObject, options, { alwaysUseDocumentClass = false } = {}) => {
if (options.parsingMode === "xml" && !alwaysUseDocumentClass) {
return XMLDocument.createImpl(globalObject, [], { options });
}
return Document.createImpl(globalObject, [], { options });
};
exports.createWrapper = (...args) => {
return wrapperForImpl(exports.createImpl(...args));
};
"use strict";
const { parseIntoDocument } = require("../../browser/parser");
const Document = require("../generated/Document");
exports.implementation = class DOMParserImpl {
constructor(globalObject) {
this._globalObject = globalObject;
}
parseFromString(string, contentType) {
switch (String(contentType)) {
case "text/html": {
return this.createScriptingDisabledDocument("html", contentType, string);
}
case "text/xml":
case "application/xml":
case "application/xhtml+xml":
case "image/svg+xml": {
try {
return this.createScriptingDisabledDocument("xml", contentType, string);
} catch (error) {
const document = this.createScriptingDisabledDocument("xml", contentType);
const element = document.createElementNS("http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror");
element.textContent = error.message;
document.appendChild(element);
return document;
}
}
default:
throw new TypeError("Invalid contentType");
}
}
createScriptingDisabledDocument(parsingMode, contentType, string) {
const document = Document.createImpl(this._globalObject, [], {
options: {
parsingMode,
encoding: "UTF-8",
contentType,
readyState: "complete",
scriptingDisabled: true
// TODO: somehow set URL to active document's URL
}
});
if (string !== undefined) {
parseIntoDocument(string, document);
}
return document;
}
};
"use strict";
const serialize = require("w3c-xmlserializer");
const DOMException = require("domexception/webidl2js-wrapper");
const utils = require("../generated/utils");
exports.implementation = class XMLSerializerImpl {
constructor(globalObject) {
this._globalObject = globalObject;
}
serializeToString(root) {
try {
return serialize(utils.wrapperForImpl(root), { requireWellFormed: false });
} catch (e) {
throw DOMException.create(this._globalObject, [e.message, "InvalidStateError"]);
}
}
};
"use strict";
const nodeTypes = require("../node-type");
const { domSymbolTree } = require("../helpers/internal-constants");
// Serialization only requires a subset of the tree adapter interface.
// Tree traversing
exports.getFirstChild = node => node.firstChild;
exports.getChildNodes = node => node.childNodesForSerializing || domSymbolTree.childrenToArray(node);
exports.getParentNode = node => node.parentNode;
exports.getAttrList = element => {
const attributeList = [...element._attributeList];
if (element._isValue && attributeList.every(attr => attr.name !== "is")) {
attributeList.unshift({
name: "is",
namespace: null,
prefix: null,
value: element._isValue
});
}
return attributeList;
};
// Node data
exports.getTagName = element => element._qualifiedName; // https://github.com/inikulin/parse5/issues/231
exports.getNamespaceURI = element => element.namespaceURI;
exports.getTextNodeContent = exports.getCommentNodeContent = node => node.data;
exports.getDocumentTypeNodeName = node => node.name;
exports.getDocumentTypeNodePublicId = node => node.publicId;
exports.getDocumentTypeNodeSystemId = node => node.systemId;
exports.getTemplateContent = templateElement => templateElement._templateContents;
exports.getDocumentMode = document => document._mode;
// Node types
exports.isTextNode = node => node.nodeType === nodeTypes.TEXT_NODE;
exports.isCommentNode = node => node.nodeType === nodeTypes.COMMENT_NODE;
exports.isDocumentTypeNode = node => node.nodeType === nodeTypes.DOCUMENT_TYPE_NODE;
exports.isElementNode = node => node.nodeType === nodeTypes.ELEMENT_NODE;
// Source code location
exports.setNodeSourceCodeLocation = (node, location) => {
node.sourceCodeLocation = location;
};
exports.getNodeSourceCodeLocation = node => node.sourceCodeLocation;
"use strict";
const produceXMLSerialization = require("w3c-xmlserializer");
const parse5 = require("parse5");
const DOMException = require("domexception/webidl2js-wrapper");
const utils = require("../generated/utils");
const treeAdapter = require("./parse5-adapter-serialization");
const NODE_TYPE = require("../node-type");
const NAMESPACES = require("../helpers/namespaces");
function htmlSerialization(node) {
if (
node.nodeType === NODE_TYPE.ELEMENT_NODE &&
node.namespaceURI === NAMESPACES.HTML_NS &&
node.tagName === "TEMPLATE"
) {
node = node.content;
}
return parse5.serialize(node, { treeAdapter });
}
module.exports.fragmentSerialization = (node, { requireWellFormed, globalObject }) => {
const contextDocument =
node.nodeType === NODE_TYPE.DOCUMENT_NODE ? node : node._ownerDocument;
if (contextDocument._parsingMode === "html") {
return htmlSerialization(node);
}
const childNodes = node.childNodesForSerializing || node.childNodes;
try {
let serialized = "";
for (let i = 0; i < childNodes.length; ++i) {
serialized += produceXMLSerialization(
utils.wrapperForImpl(childNodes[i] || childNodes.item(i)),
{ requireWellFormed }
);
}
return serialized;
} catch (e) {
throw DOMException.create(globalObject, [e.message, "InvalidStateError"]);
}
};
"use strict";
const EventImpl = require("./Event-impl").implementation;
const CloseEventInit = require("../generated/CloseEventInit");
class CloseEventImpl extends EventImpl {}
CloseEventImpl.defaultInit = CloseEventInit.convert(undefined);
exports.implementation = CloseEventImpl;
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
const CompositionEventInit = require("../generated/CompositionEventInit");
class CompositionEventImpl extends UIEventImpl {
initCompositionEvent(type, bubbles, cancelable, view, data) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, 0);
this.data = data;
}
}
CompositionEventImpl.defaultInit = CompositionEventInit.convert(undefined);
module.exports = {
implementation: CompositionEventImpl
};
"use strict";
const EventImpl = require("./Event-impl").implementation;
const CustomEventInit = require("../generated/CustomEventInit");
class CustomEventImpl extends EventImpl {
initCustomEvent(type, bubbles, cancelable, detail) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.detail = detail;
}
}
CustomEventImpl.defaultInit = CustomEventInit.convert(undefined);
module.exports = {
implementation: CustomEventImpl
};
"use strict";
const EventImpl = require("./Event-impl").implementation;
const ErrorEventInit = require("../generated/ErrorEventInit");
class ErrorEventImpl extends EventImpl {
}
ErrorEventImpl.defaultInit = ErrorEventInit.convert(undefined);
module.exports = {
implementation: ErrorEventImpl
};
"use strict";
const idlUtils = require("../generated/utils");
const EventInit = require("../generated/EventInit");
class EventImpl {
constructor(globalObject, args, privateData) {
const [type, eventInitDict = this.constructor.defaultInit] = args;
this.type = type;
this.bubbles = false;
this.cancelable = false;
for (const key in eventInitDict) {
if (key in this.constructor.defaultInit) {
this[key] = eventInitDict[key];
}
}
for (const key in this.constructor.defaultInit) {
if (!(key in this)) {
this[key] = this.constructor.defaultInit[key];
}
}
this.target = null;
this.currentTarget = null;
this.eventPhase = 0;
this._globalObject = globalObject;
this._initializedFlag = true;
this._stopPropagationFlag = false;
this._stopImmediatePropagationFlag = false;
this._canceledFlag = false;
this._inPassiveListenerFlag = false;
this._dispatchFlag = false;
this._path = [];
this.isTrusted = privateData.isTrusted || false;
this.timeStamp = Date.now();
}
// https://dom.spec.whatwg.org/#set-the-canceled-flag
_setTheCanceledFlag() {
if (this.cancelable && !this._inPassiveListenerFlag) {
this._canceledFlag = true;
}
}
get srcElement() {
return this.target;
}
get returnValue() {
return !this._canceledFlag;
}
set returnValue(v) {
if (v === false) {
this._setTheCanceledFlag();
}
}
get defaultPrevented() {
return this._canceledFlag;
}
stopPropagation() {
this._stopPropagationFlag = true;
}
get cancelBubble() {
return this._stopPropagationFlag;
}
set cancelBubble(v) {
if (v) {
this._stopPropagationFlag = true;
}
}
stopImmediatePropagation() {
this._stopPropagationFlag = true;
this._stopImmediatePropagationFlag = true;
}
preventDefault() {
this._setTheCanceledFlag();
}
// https://dom.spec.whatwg.org/#dom-event-composedpath
// Current implementation is based of https://whatpr.org/dom/699.html#dom-event-composedpath
// due to a bug in composed path implementation https://github.com/whatwg/dom/issues/684
composedPath() {
const composedPath = [];
const { currentTarget, _path: path } = this;
if (path.length === 0) {
return composedPath;
}
composedPath.push(currentTarget);
let currentTargetIndex = 0;
let currentTargetHiddenSubtreeLevel = 0;
for (let index = path.length - 1; index >= 0; index--) {
const { item, rootOfClosedTree, slotInClosedTree } = path[index];
if (rootOfClosedTree) {
currentTargetHiddenSubtreeLevel++;
}
if (item === idlUtils.implForWrapper(currentTarget)) {
currentTargetIndex = index;
break;
}
if (slotInClosedTree) {
currentTargetHiddenSubtreeLevel--;
}
}
let currentHiddenLevel = currentTargetHiddenSubtreeLevel;
let maxHiddenLevel = currentTargetHiddenSubtreeLevel;
for (let i = currentTargetIndex - 1; i >= 0; i--) {
const { item, rootOfClosedTree, slotInClosedTree } = path[i];
if (rootOfClosedTree) {
currentHiddenLevel++;
}
if (currentHiddenLevel <= maxHiddenLevel) {
composedPath.unshift(idlUtils.wrapperForImpl(item));
}
if (slotInClosedTree) {
currentHiddenLevel--;
if (currentHiddenLevel < maxHiddenLevel) {
maxHiddenLevel = currentHiddenLevel;
}
}
}
currentHiddenLevel = currentTargetHiddenSubtreeLevel;
maxHiddenLevel = currentTargetHiddenSubtreeLevel;
for (let index = currentTargetIndex + 1; index < path.length; index++) {
const { item, rootOfClosedTree, slotInClosedTree } = path[index];
if (slotInClosedTree) {
currentHiddenLevel++;
}
if (currentHiddenLevel <= maxHiddenLevel) {
composedPath.push(idlUtils.wrapperForImpl(item));
}
if (rootOfClosedTree) {
currentHiddenLevel--;
if (currentHiddenLevel < maxHiddenLevel) {
maxHiddenLevel = currentHiddenLevel;
}
}
}
return composedPath;
}
_initialize(type, bubbles, cancelable) {
this.type = type;
this._initializedFlag = true;
this._stopPropagationFlag = false;
this._stopImmediatePropagationFlag = false;
this._canceledFlag = false;
this.isTrusted = false;
this.target = null;
this.bubbles = bubbles;
this.cancelable = cancelable;
}
initEvent(type, bubbles, cancelable) {
if (this._dispatchFlag) {
return;
}
this._initialize(type, bubbles, cancelable);
}
}
EventImpl.defaultInit = EventInit.convert(undefined);
module.exports = {
implementation: EventImpl
};
"use strict";
// This mixin doesn't have an IDL equivalent, but since MouseEvent and KeyboardEvent implement getModifierState() the
// same way, its implementation is shared here.
class EventModifierMixinImpl {
// Event's constructor assumes all options correspond to IDL attributes with the same names, and sets them on `this`.
// That is not the case for these modifier boolean options, but since the options are set on `this` anyway we'll
// access them that way. The spec doesn't say much about the case where keyArg is not one of the valid ones
// (https://w3c.github.io/uievents-key/#keys-modifier), but at least Chrome returns false for invalid modifiers. Since
// these invalid modifiers will be undefined on `this` (thus `false` after casting it to boolean), we don't need to do
// extra checking for validity.
getModifierState(keyArg) {
return Boolean(this[`modifier${keyArg}`]);
}
}
exports.implementation = EventModifierMixinImpl;
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
const FocusEventInit = require("../generated/FocusEventInit");
class FocusEventImpl extends UIEventImpl {}
FocusEventImpl.defaultInit = FocusEventInit.convert(undefined);
exports.implementation = FocusEventImpl;
"use strict";
const EventImpl = require("./Event-impl").implementation;
const HashChangeEventInit = require("../generated/HashChangeEventInit");
class HashChangeEventImpl extends EventImpl {
}
HashChangeEventImpl.defaultInit = HashChangeEventInit.convert(undefined);
module.exports = {
implementation: HashChangeEventImpl
};
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
const InputEventInit = require("../generated/InputEventInit");
// https://w3c.github.io/uievents/#interface-inputevent
class InputEventImpl extends UIEventImpl {
initInputEvent(type, bubbles, cancelable, data, isComposing) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable);
this.data = data;
this.isComposing = isComposing;
}
}
InputEventImpl.defaultInit = InputEventInit.convert(undefined);
module.exports = {
implementation: InputEventImpl
};
"use strict";
const { mixin } = require("../../utils");
const EventModifierMixinImpl = require("./EventModifierMixin-impl").implementation;
const UIEventImpl = require("./UIEvent-impl").implementation;
const KeyboardEventInit = require("../generated/KeyboardEventInit");
class KeyboardEventImpl extends UIEventImpl {
initKeyboardEvent(type, bubbles, cancelable, view, key, location, ctrlKey, altKey, shiftKey, metaKey) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, 0);
this.key = key;
this.location = location;
this.ctrlKey = ctrlKey;
this.altKey = altKey;
this.shiftKey = shiftKey;
this.metaKey = metaKey;
}
}
mixin(KeyboardEventImpl.prototype, EventModifierMixinImpl.prototype);
KeyboardEventImpl.defaultInit = KeyboardEventInit.convert(undefined);
module.exports = {
implementation: KeyboardEventImpl
};
"use strict";
const EventImpl = require("./Event-impl").implementation;
const MessageEventInit = require("../generated/MessageEventInit");
class MessageEventImpl extends EventImpl {
initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.data = data;
this.origin = origin;
this.lastEventId = lastEventId;
this.source = source;
this.ports = ports;
}
}
MessageEventImpl.defaultInit = MessageEventInit.convert(undefined);
module.exports = {
implementation: MessageEventImpl
};
"use strict";
const { mixin } = require("../../utils");
const EventModifierMixinImpl = require("./EventModifierMixin-impl").implementation;
const UIEventImpl = require("./UIEvent-impl").implementation;
const MouseEventInit = require("../generated/MouseEventInit");
class MouseEventImpl extends UIEventImpl {
initMouseEvent(
type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget
) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, detail);
this.screenX = screenX;
this.screenY = screenY;
this.clientX = clientX;
this.clientY = clientY;
this.ctrlKey = ctrlKey;
this.altKey = altKey;
this.shiftKey = shiftKey;
this.metaKey = metaKey;
this.button = button;
this.relatedTarget = relatedTarget;
}
}
mixin(MouseEventImpl.prototype, EventModifierMixinImpl.prototype);
MouseEventImpl.defaultInit = MouseEventInit.convert(undefined);
module.exports = {
implementation: MouseEventImpl
};
"use strict";
const EventImpl = require("./Event-impl").implementation;
const PageTransitionEventInit = require("../generated/PageTransitionEventInit");
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#pagetransitionevent
class PageTransitionEventImpl extends EventImpl {
initPageTransitionEvent(type, bubbles, cancelable, persisted) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.persisted = persisted;
}
}
PageTransitionEventImpl.defaultInit = PageTransitionEventInit.convert(undefined);
exports.implementation = PageTransitionEventImpl;
"use strict";
const EventImpl = require("./Event-impl.js").implementation;
const PopStateEventInit = require("../generated/PopStateEventInit");
class PopStateEventImpl extends EventImpl {}
PopStateEventImpl.defaultInit = PopStateEventInit.convert(undefined);
exports.implementation = PopStateEventImpl;
"use strict";
const EventImpl = require("./Event-impl").implementation;
const ProgressEventInit = require("../generated/ProgressEventInit");
class ProgressEventImpl extends EventImpl {
}
ProgressEventImpl.defaultInit = ProgressEventInit.convert(undefined);
module.exports = {
implementation: ProgressEventImpl
};
"use strict";
const EventImpl = require("./Event-impl").implementation;
const StorageEventInit = require("../generated/StorageEventInit");
// https://html.spec.whatwg.org/multipage/webstorage.html#the-storageevent-interface
class StorageEventImpl extends EventImpl {
initStorageEvent(type, bubbles, cancelable, key, oldValue, newValue, url, storageArea) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.key = key;
this.oldValue = oldValue;
this.newValue = newValue;
this.url = url;
this.storageArea = storageArea;
}
}
StorageEventImpl.defaultInit = StorageEventInit.convert(undefined);
module.exports = {
implementation: StorageEventImpl
};
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
const TouchEventInit = require("../generated/TouchEventInit");
class TouchEventImpl extends UIEventImpl {
}
TouchEventImpl.defaultInit = TouchEventInit.convert(undefined);
module.exports = {
implementation: TouchEventImpl
};
"use strict";
const idlUtils = require("../generated/utils");
const UIEventInit = require("../generated/UIEventInit");
const EventImpl = require("./Event-impl").implementation;
// Until webidl2js gains support for checking for Window, this would have to do.
function isWindow(val) {
if (typeof val !== "object") {
return false;
}
const wrapper = idlUtils.wrapperForImpl(val);
if (typeof wrapper === "object") {
return wrapper === wrapper._globalProxy;
}
// `val` may be either impl or wrapper currently, because webidl2js currently unwraps Window objects (and their global
// proxies) to their underlying EventTargetImpl during conversion, which is not what we want. But at the same time,
// some internal usage call this constructor with the actual global proxy.
return isWindow(idlUtils.implForWrapper(val));
}
class UIEventImpl extends EventImpl {
constructor(globalObject, args, privateData) {
const eventInitDict = args[1];
// undefined check included so that we can omit the property in internal usage.
if (eventInitDict && eventInitDict.view !== null && eventInitDict.view !== undefined) {
if (!isWindow(eventInitDict.view)) {
throw new TypeError(`Failed to construct '${new.target.name.replace(/Impl$/, "")}': member view is not of ` +
"type Window.");
}
}
super(globalObject, args, privateData);
}
initUIEvent(type, bubbles, cancelable, view, detail) {
if (view !== null) {
if (!isWindow(view)) {
throw new TypeError(`Failed to execute 'initUIEvent' on '${this.constructor.name.replace(/Impl$/, "")}': ` +
"parameter 4 is not of type 'Window'.");
}
}
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.view = view;
this.detail = detail;
}
}
UIEventImpl.defaultInit = UIEventInit.convert(undefined);
module.exports = {
implementation: UIEventImpl
};
"use strict";
const MouseEventImpl = require("./MouseEvent-impl").implementation;
const WheelEventInit = require("../generated/WheelEventInit");
class WheelEventImpl extends MouseEventImpl {}
WheelEventImpl.defaultInit = WheelEventInit.convert(undefined);
module.exports = {
implementation: WheelEventImpl
};
"use strict";
const {
isForbidden,
isForbiddenResponse,
isPrivilegedNoCORSRequest,
isNoCORSSafelistedRequest,
isCORSWhitelisted
} = require("./header-types");
const HeaderList = require("./header-list");
function assertName(name) {
if (!name.match(/^[!#$%&'*+\-.^`|~\w]+$/)) {
throw new TypeError("name is invalid");
}
}
function assertValue(value) {
if (value.match(/[\0\r\n]/)) {
throw new TypeError("value is invalid");
}
}
class HeadersImpl {
constructor(globalObject, args) {
this.guard = "none";
this.headersList = new HeaderList();
if (args[0]) {
this._fill(args[0]);
}
}
_fill(init) {
if (Array.isArray(init)) {
for (const header of init) {
if (header.length !== 2) {
throw new TypeError("init is invalid");
}
this.append(header[0], header[1]);
}
} else {
for (const key of Object.keys(init)) {
this.append(key, init[key]);
}
}
}
has(name) {
assertName(name);
return this.headersList.contains(name);
}
get(name) {
assertName(name);
return this.headersList.get(name);
}
_removePrivilegedNoCORSHeaders() {
this.headersList.delete("range");
}
append(name, value) {
value = value.trim();
assertName(name);
assertValue(value);
switch (this.guard) {
case "immutable":
throw new TypeError("Headers is immutable");
case "request":
if (isForbidden(name)) {
return;
}
break;
case "request-no-cors": {
let temporaryValue = this.get(name);
if (temporaryValue === null) {
temporaryValue = value;
} else {
temporaryValue += `, ${value}`;
}
if (!isCORSWhitelisted(name, value)) {
return;
}
break;
}
case "response":
if (isForbiddenResponse(name)) {
return;
}
break;
}
this.headersList.append(name, value);
this._removePrivilegedNoCORSHeaders();
}
set(name, value) {
value = value.trim();
assertName(name);
assertValue(value);
switch (this.guard) {
case "immutable":
throw new TypeError("Headers is immutable");
case "request":
if (isForbidden(name)) {
return;
}
break;
case "request-no-cors": {
if (!isCORSWhitelisted(name, value)) {
return;
}
break;
}
case "response":
if (isForbiddenResponse(name)) {
return;
}
break;
}
this.headersList.set(name, value);
this._removePrivilegedNoCORSHeaders();
}
delete(name) {
assertName(name);
switch (this.guard) {
case "immutable":
throw new TypeError("Headers is immutable");
case "request":
if (isForbidden(name)) {
return;
}
break;
case "request-no-cors": {
if (
!isNoCORSSafelistedRequest(name) &&
!isPrivilegedNoCORSRequest(name)
) {
return;
}
break;
}
case "response":
if (isForbiddenResponse(name)) {
return;
}
break;
}
this.headersList.delete(name);
this._removePrivilegedNoCORSHeaders();
}
* [Symbol.iterator]() {
for (const header of this.headersList.sortAndCombine()) {
yield header;
}
}
}
exports.implementation = HeadersImpl;
"use strict";
/**
* Provides some utility functions for somewhat efficiently modifying a
* collection of headers.
*
* Note that this class only operates on ByteStrings (which is also why we use
* toLowerCase internally).
*/
class HeaderList {
constructor() {
this.headers = new Map();
}
append(name, value) {
const existing = this.headers.get(name.toLowerCase());
if (existing) {
name = existing[0].name;
existing.push({ name, value });
} else {
this.headers.set(name.toLowerCase(), [{ name, value }]);
}
}
contains(name) {
return this.headers.has(name.toLowerCase());
}
get(name) {
name = name.toLowerCase();
const values = this.headers.get(name);
if (!values) {
return null;
}
return values.map(h => h.value).join(", ");
}
delete(name) {
this.headers.delete(name.toLowerCase());
}
set(name, value) {
const lowerName = name.toLowerCase();
this.headers.delete(lowerName);
this.headers.set(lowerName, [{ name, value }]);
}
sortAndCombine() {
const names = [...this.headers.keys()].sort();
return names.map(n => [n, this.get(n)]);
}
}
module.exports = HeaderList;
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.