mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-16 01:13:08 +09:00
683 lines
48 KiB
JavaScript
683 lines
48 KiB
JavaScript
|
|
function run_test() {
|
||
|
|
for (var k in SOURCE_MAP_TEST_MODULE) {
|
||
|
|
if (/^test/.test(k)) {
|
||
|
|
SOURCE_MAP_TEST_MODULE[k](assert);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
var SOURCE_MAP_TEST_MODULE =
|
||
|
|
/******/ (function(modules) { // webpackBootstrap
|
||
|
|
/******/ // The module cache
|
||
|
|
/******/ var installedModules = {};
|
||
|
|
/******/
|
||
|
|
/******/ // The require function
|
||
|
|
/******/ function __webpack_require__(moduleId) {
|
||
|
|
/******/
|
||
|
|
/******/ // Check if module is in cache
|
||
|
|
/******/ if(installedModules[moduleId])
|
||
|
|
/******/ return installedModules[moduleId].exports;
|
||
|
|
/******/
|
||
|
|
/******/ // Create a new module (and put it into the cache)
|
||
|
|
/******/ var module = installedModules[moduleId] = {
|
||
|
|
/******/ exports: {},
|
||
|
|
/******/ id: moduleId,
|
||
|
|
/******/ loaded: false
|
||
|
|
/******/ };
|
||
|
|
/******/
|
||
|
|
/******/ // Execute the module function
|
||
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||
|
|
/******/
|
||
|
|
/******/ // Flag the module as loaded
|
||
|
|
/******/ module.loaded = true;
|
||
|
|
/******/
|
||
|
|
/******/ // Return the exports of the module
|
||
|
|
/******/ return module.exports;
|
||
|
|
/******/ }
|
||
|
|
/******/
|
||
|
|
/******/
|
||
|
|
/******/ // expose the modules object (__webpack_modules__)
|
||
|
|
/******/ __webpack_require__.m = modules;
|
||
|
|
/******/
|
||
|
|
/******/ // expose the module cache
|
||
|
|
/******/ __webpack_require__.c = installedModules;
|
||
|
|
/******/
|
||
|
|
/******/ // __webpack_public_path__
|
||
|
|
/******/ __webpack_require__.p = "";
|
||
|
|
/******/
|
||
|
|
/******/ // Load entry module and return exports
|
||
|
|
/******/ return __webpack_require__(0);
|
||
|
|
/******/ })
|
||
|
|
/************************************************************************/
|
||
|
|
/******/ ([
|
||
|
|
/* 0 */
|
||
|
|
/***/ function(module, exports, __webpack_require__) {
|
||
|
|
|
||
|
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||
|
|
/*
|
||
|
|
* Copyright 2011 Mozilla Foundation and contributors
|
||
|
|
* Licensed under the New BSD license. See LICENSE or:
|
||
|
|
* http://opensource.org/licenses/BSD-3-Clause
|
||
|
|
*/
|
||
|
|
{
|
||
|
|
var ArraySet = __webpack_require__(1).ArraySet;
|
||
|
|
|
||
|
|
function makeTestSet() {
|
||
|
|
var set = new ArraySet();
|
||
|
|
for (var i = 0; i < 100; i++) {
|
||
|
|
set.add(String(i));
|
||
|
|
}
|
||
|
|
return set;
|
||
|
|
}
|
||
|
|
|
||
|
|
exports['test .has() membership'] = function (assert) {
|
||
|
|
var set = makeTestSet();
|
||
|
|
for (var i = 0; i < 100; i++) {
|
||
|
|
assert.ok(set.has(String(i)));
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test .indexOf() elements'] = function (assert) {
|
||
|
|
var set = makeTestSet();
|
||
|
|
for (var i = 0; i < 100; i++) {
|
||
|
|
assert.strictEqual(set.indexOf(String(i)), i);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test .at() indexing'] = function (assert) {
|
||
|
|
var set = makeTestSet();
|
||
|
|
for (var i = 0; i < 100; i++) {
|
||
|
|
assert.strictEqual(set.at(i), String(i));
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test creating from an array'] = function (assert) {
|
||
|
|
var set = ArraySet.fromArray(['foo', 'bar', 'baz', 'quux', 'hasOwnProperty']);
|
||
|
|
|
||
|
|
assert.ok(set.has('foo'));
|
||
|
|
assert.ok(set.has('bar'));
|
||
|
|
assert.ok(set.has('baz'));
|
||
|
|
assert.ok(set.has('quux'));
|
||
|
|
assert.ok(set.has('hasOwnProperty'));
|
||
|
|
|
||
|
|
assert.strictEqual(set.indexOf('foo'), 0);
|
||
|
|
assert.strictEqual(set.indexOf('bar'), 1);
|
||
|
|
assert.strictEqual(set.indexOf('baz'), 2);
|
||
|
|
assert.strictEqual(set.indexOf('quux'), 3);
|
||
|
|
|
||
|
|
assert.strictEqual(set.at(0), 'foo');
|
||
|
|
assert.strictEqual(set.at(1), 'bar');
|
||
|
|
assert.strictEqual(set.at(2), 'baz');
|
||
|
|
assert.strictEqual(set.at(3), 'quux');
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test that you can add __proto__; see github issue #30'] = function (assert) {
|
||
|
|
var set = new ArraySet();
|
||
|
|
set.add('__proto__');
|
||
|
|
assert.ok(set.has('__proto__'));
|
||
|
|
assert.strictEqual(set.at(0), '__proto__');
|
||
|
|
assert.strictEqual(set.indexOf('__proto__'), 0);
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test .fromArray() with duplicates'] = function (assert) {
|
||
|
|
var set = ArraySet.fromArray(['foo', 'foo']);
|
||
|
|
assert.ok(set.has('foo'));
|
||
|
|
assert.strictEqual(set.at(0), 'foo');
|
||
|
|
assert.strictEqual(set.indexOf('foo'), 0);
|
||
|
|
assert.strictEqual(set.toArray().length, 1);
|
||
|
|
|
||
|
|
set = ArraySet.fromArray(['foo', 'foo'], true);
|
||
|
|
assert.ok(set.has('foo'));
|
||
|
|
assert.strictEqual(set.at(0), 'foo');
|
||
|
|
assert.strictEqual(set.at(1), 'foo');
|
||
|
|
assert.strictEqual(set.indexOf('foo'), 0);
|
||
|
|
assert.strictEqual(set.toArray().length, 2);
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test .add() with duplicates'] = function (assert) {
|
||
|
|
var set = new ArraySet();
|
||
|
|
set.add('foo');
|
||
|
|
|
||
|
|
set.add('foo');
|
||
|
|
assert.ok(set.has('foo'));
|
||
|
|
assert.strictEqual(set.at(0), 'foo');
|
||
|
|
assert.strictEqual(set.indexOf('foo'), 0);
|
||
|
|
assert.strictEqual(set.toArray().length, 1);
|
||
|
|
|
||
|
|
set.add('foo', true);
|
||
|
|
assert.ok(set.has('foo'));
|
||
|
|
assert.strictEqual(set.at(0), 'foo');
|
||
|
|
assert.strictEqual(set.at(1), 'foo');
|
||
|
|
assert.strictEqual(set.indexOf('foo'), 0);
|
||
|
|
assert.strictEqual(set.toArray().length, 2);
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test .size()'] = function (assert) {
|
||
|
|
var set = new ArraySet();
|
||
|
|
set.add('foo');
|
||
|
|
set.add('bar');
|
||
|
|
set.add('baz');
|
||
|
|
assert.strictEqual(set.size(), 3);
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test .size() with disallowed duplicates'] = function (assert) {
|
||
|
|
var set = new ArraySet();
|
||
|
|
|
||
|
|
set.add('foo');
|
||
|
|
set.add('foo');
|
||
|
|
|
||
|
|
set.add('bar');
|
||
|
|
set.add('bar');
|
||
|
|
|
||
|
|
set.add('baz');
|
||
|
|
set.add('baz');
|
||
|
|
|
||
|
|
assert.strictEqual(set.size(), 3);
|
||
|
|
};
|
||
|
|
|
||
|
|
exports['test .size() with allowed duplicates'] = function (assert) {
|
||
|
|
var set = new ArraySet();
|
||
|
|
|
||
|
|
set.add('foo');
|
||
|
|
set.add('foo', true);
|
||
|
|
|
||
|
|
set.add('bar');
|
||
|
|
set.add('bar', true);
|
||
|
|
|
||
|
|
set.add('baz');
|
||
|
|
set.add('baz', true);
|
||
|
|
|
||
|
|
assert.strictEqual(set.size(), 3);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/***/ },
|
||
|
|
/* 1 */
|
||
|
|
/***/ function(module, exports, __webpack_require__) {
|
||
|
|
|
||
|
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||
|
|
/*
|
||
|
|
* Copyright 2011 Mozilla Foundation and contributors
|
||
|
|
* Licensed under the New BSD license. See LICENSE or:
|
||
|
|
* http://opensource.org/licenses/BSD-3-Clause
|
||
|
|
*/
|
||
|
|
{
|
||
|
|
var util = __webpack_require__(2);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A data structure which is a combination of an array and a set. Adding a new
|
||
|
|
* member is O(1), testing for membership is O(1), and finding the index of an
|
||
|
|
* element is O(1). Removing elements from the set is not supported. Only
|
||
|
|
* strings are supported for membership.
|
||
|
|
*/
|
||
|
|
function ArraySet() {
|
||
|
|
this._array = [];
|
||
|
|
this._set = {};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Static method for creating ArraySet instances from an existing array.
|
||
|
|
*/
|
||
|
|
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
||
|
|
var set = new ArraySet();
|
||
|
|
for (var i = 0, len = aArray.length; i < len; i++) {
|
||
|
|
set.add(aArray[i], aAllowDuplicates);
|
||
|
|
}
|
||
|
|
return set;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Return how many unique items are in this ArraySet. If duplicates have been
|
||
|
|
* added, than those do not count towards the size.
|
||
|
|
*
|
||
|
|
* @returns Number
|
||
|
|
*/
|
||
|
|
ArraySet.prototype.size = function ArraySet_size() {
|
||
|
|
return Object.getOwnPropertyNames(this._set).length;
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Add the given string to this set.
|
||
|
|
*
|
||
|
|
* @param String aStr
|
||
|
|
*/
|
||
|
|
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
||
|
|
var sStr = util.toSetString(aStr);
|
||
|
|
var isDuplicate = this._set.hasOwnProperty(sStr);
|
||
|
|
var idx = this._array.length;
|
||
|
|
if (!isDuplicate || aAllowDuplicates) {
|
||
|
|
this._array.push(aStr);
|
||
|
|
}
|
||
|
|
if (!isDuplicate) {
|
||
|
|
this._set[sStr] = idx;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Is the given string a member of this set?
|
||
|
|
*
|
||
|
|
* @param String aStr
|
||
|
|
*/
|
||
|
|
ArraySet.prototype.has = function ArraySet_has(aStr) {
|
||
|
|
var sStr = util.toSetString(aStr);
|
||
|
|
return this._set.hasOwnProperty(sStr);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* What is the index of the given string in the array?
|
||
|
|
*
|
||
|
|
* @param String aStr
|
||
|
|
*/
|
||
|
|
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
||
|
|
var sStr = util.toSetString(aStr);
|
||
|
|
if (this._set.hasOwnProperty(sStr)) {
|
||
|
|
return this._set[sStr];
|
||
|
|
}
|
||
|
|
throw new Error('"' + aStr + '" is not in the set.');
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* What is the element at the given index?
|
||
|
|
*
|
||
|
|
* @param Number aIdx
|
||
|
|
*/
|
||
|
|
ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
||
|
|
if (aIdx >= 0 && aIdx < this._array.length) {
|
||
|
|
return this._array[aIdx];
|
||
|
|
}
|
||
|
|
throw new Error('No element indexed by ' + aIdx);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns the array representation of this set (which has the proper indices
|
||
|
|
* indicated by indexOf). Note that this is a copy of the internal array used
|
||
|
|
* for storing the members so that no one can mess with internal state.
|
||
|
|
*/
|
||
|
|
ArraySet.prototype.toArray = function ArraySet_toArray() {
|
||
|
|
return this._array.slice();
|
||
|
|
};
|
||
|
|
|
||
|
|
exports.ArraySet = ArraySet;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/***/ },
|
||
|
|
/* 2 */
|
||
|
|
/***/ function(module, exports) {
|
||
|
|
|
||
|
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
||
|
|
/*
|
||
|
|
* Copyright 2011 Mozilla Foundation and contributors
|
||
|
|
* Licensed under the New BSD license. See LICENSE or:
|
||
|
|
* http://opensource.org/licenses/BSD-3-Clause
|
||
|
|
*/
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* This is a helper function for getting values from parameter/options
|
||
|
|
* objects.
|
||
|
|
*
|
||
|
|
* @param args The object we are extracting values from
|
||
|
|
* @param name The name of the property we are getting.
|
||
|
|
* @param defaultValue An optional value to return if the property is missing
|
||
|
|
* from the object. If this is not specified and the property is missing, an
|
||
|
|
* error will be thrown.
|
||
|
|
*/
|
||
|
|
function getArg(aArgs, aName, aDefaultValue) {
|
||
|
|
if (aName in aArgs) {
|
||
|
|
return aArgs[aName];
|
||
|
|
} else if (arguments.length === 3) {
|
||
|
|
return aDefaultValue;
|
||
|
|
} else {
|
||
|
|
throw new Error('"' + aName + '" is a required argument.');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
exports.getArg = getArg;
|
||
|
|
|
||
|
|
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
|
||
|
|
var dataUrlRegexp = /^data:.+\,.+$/;
|
||
|
|
|
||
|
|
function urlParse(aUrl) {
|
||
|
|
var match = aUrl.match(urlRegexp);
|
||
|
|
if (!match) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return {
|
||
|
|
scheme: match[1],
|
||
|
|
auth: match[2],
|
||
|
|
host: match[3],
|
||
|
|
port: match[4],
|
||
|
|
path: match[5]
|
||
|
|
};
|
||
|
|
}
|
||
|
|
exports.urlParse = urlParse;
|
||
|
|
|
||
|
|
function urlGenerate(aParsedUrl) {
|
||
|
|
var url = '';
|
||
|
|
if (aParsedUrl.scheme) {
|
||
|
|
url += aParsedUrl.scheme + ':';
|
||
|
|
}
|
||
|
|
url += '//';
|
||
|
|
if (aParsedUrl.auth) {
|
||
|
|
url += aParsedUrl.auth + '@';
|
||
|
|
}
|
||
|
|
if (aParsedUrl.host) {
|
||
|
|
url += aParsedUrl.host;
|
||
|
|
}
|
||
|
|
if (aParsedUrl.port) {
|
||
|
|
url += ":" + aParsedUrl.port
|
||
|
|
}
|
||
|
|
if (aParsedUrl.path) {
|
||
|
|
url += aParsedUrl.path;
|
||
|
|
}
|
||
|
|
return url;
|
||
|
|
}
|
||
|
|
exports.urlGenerate = urlGenerate;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Normalizes a path, or the path portion of a URL:
|
||
|
|
*
|
||
|
|
* - Replaces consequtive slashes with one slash.
|
||
|
|
* - Removes unnecessary '.' parts.
|
||
|
|
* - Removes unnecessary '<dir>/..' parts.
|
||
|
|
*
|
||
|
|
* Based on code in the Node.js 'path' core module.
|
||
|
|
*
|
||
|
|
* @param aPath The path or url to normalize.
|
||
|
|
*/
|
||
|
|
function normalize(aPath) {
|
||
|
|
var path = aPath;
|
||
|
|
var url = urlParse(aPath);
|
||
|
|
if (url) {
|
||
|
|
if (!url.path) {
|
||
|
|
return aPath;
|
||
|
|
}
|
||
|
|
path = url.path;
|
||
|
|
}
|
||
|
|
var isAbsolute = exports.isAbsolute(path);
|
||
|
|
|
||
|
|
var parts = path.split(/\/+/);
|
||
|
|
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
||
|
|
part = parts[i];
|
||
|
|
if (part === '.') {
|
||
|
|
parts.splice(i, 1);
|
||
|
|
} else if (part === '..') {
|
||
|
|
up++;
|
||
|
|
} else if (up > 0) {
|
||
|
|
if (part === '') {
|
||
|
|
// The first part is blank if the path is absolute. Trying to go
|
||
|
|
// above the root is a no-op. Therefore we can remove all '..' parts
|
||
|
|
// directly after the root.
|
||
|
|
parts.splice(i + 1, up);
|
||
|
|
up = 0;
|
||
|
|
} else {
|
||
|
|
parts.splice(i, 2);
|
||
|
|
up--;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
path = parts.join('/');
|
||
|
|
|
||
|
|
if (path === '') {
|
||
|
|
path = isAbsolute ? '/' : '.';
|
||
|
|
}
|
||
|
|
|
||
|
|
if (url) {
|
||
|
|
url.path = path;
|
||
|
|
return urlGenerate(url);
|
||
|
|
}
|
||
|
|
return path;
|
||
|
|
}
|
||
|
|
exports.normalize = normalize;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Joins two paths/URLs.
|
||
|
|
*
|
||
|
|
* @param aRoot The root path or URL.
|
||
|
|
* @param aPath The path or URL to be joined with the root.
|
||
|
|
*
|
||
|
|
* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
|
||
|
|
* scheme-relative URL: Then the scheme of aRoot, if any, is prepended
|
||
|
|
* first.
|
||
|
|
* - Otherwise aPath is a path. If aRoot is a URL, then its path portion
|
||
|
|
* is updated with the result and aRoot is returned. Otherwise the result
|
||
|
|
* is returned.
|
||
|
|
* - If aPath is absolute, the result is aPath.
|
||
|
|
* - Otherwise the two paths are joined with a slash.
|
||
|
|
* - Joining for example 'http://' and 'www.example.com' is also supported.
|
||
|
|
*/
|
||
|
|
function join(aRoot, aPath) {
|
||
|
|
if (aRoot === "") {
|
||
|
|
aRoot = ".";
|
||
|
|
}
|
||
|
|
if (aPath === "") {
|
||
|
|
aPath = ".";
|
||
|
|
}
|
||
|
|
var aPathUrl = urlParse(aPath);
|
||
|
|
var aRootUrl = urlParse(aRoot);
|
||
|
|
if (aRootUrl) {
|
||
|
|
aRoot = aRootUrl.path || '/';
|
||
|
|
}
|
||
|
|
|
||
|
|
// `join(foo, '//www.example.org')`
|
||
|
|
if (aPathUrl && !aPathUrl.scheme) {
|
||
|
|
if (aRootUrl) {
|
||
|
|
aPathUrl.scheme = aRootUrl.scheme;
|
||
|
|
}
|
||
|
|
return urlGenerate(aPathUrl);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (aPathUrl || aPath.match(dataUrlRegexp)) {
|
||
|
|
return aPath;
|
||
|
|
}
|
||
|
|
|
||
|
|
// `join('http://', 'www.example.com')`
|
||
|
|
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
|
||
|
|
aRootUrl.host = aPath;
|
||
|
|
return urlGenerate(aRootUrl);
|
||
|
|
}
|
||
|
|
|
||
|
|
var joined = aPath.charAt(0) === '/'
|
||
|
|
? aPath
|
||
|
|
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
|
||
|
|
|
||
|
|
if (aRootUrl) {
|
||
|
|
aRootUrl.path = joined;
|
||
|
|
return urlGenerate(aRootUrl);
|
||
|
|
}
|
||
|
|
return joined;
|
||
|
|
}
|
||
|
|
exports.join = join;
|
||
|
|
|
||
|
|
exports.isAbsolute = function (aPath) {
|
||
|
|
return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);
|
||
|
|
};
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Make a path relative to a URL or another path.
|
||
|
|
*
|
||
|
|
* @param aRoot The root path or URL.
|
||
|
|
* @param aPath The path or URL to be made relative to aRoot.
|
||
|
|
*/
|
||
|
|
function relative(aRoot, aPath) {
|
||
|
|
if (aRoot === "") {
|
||
|
|
aRoot = ".";
|
||
|
|
}
|
||
|
|
|
||
|
|
aRoot = aRoot.replace(/\/$/, '');
|
||
|
|
|
||
|
|
// It is possible for the path to be above the root. In this case, simply
|
||
|
|
// checking whether the root is a prefix of the path won't work. Instead, we
|
||
|
|
// need to remove components from the root one by one, until either we find
|
||
|
|
// a prefix that fits, or we run out of components to remove.
|
||
|
|
var level = 0;
|
||
|
|
while (aPath.indexOf(aRoot + '/') !== 0) {
|
||
|
|
var index = aRoot.lastIndexOf("/");
|
||
|
|
if (index < 0) {
|
||
|
|
return aPath;
|
||
|
|
}
|
||
|
|
|
||
|
|
// If the only part of the root that is left is the scheme (i.e. http://,
|
||
|
|
// file:///, etc.), one or more slashes (/), or simply nothing at all, we
|
||
|
|
// have exhausted all components, so the path is not relative to the root.
|
||
|
|
aRoot = aRoot.slice(0, index);
|
||
|
|
if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
|
||
|
|
return aPath;
|
||
|
|
}
|
||
|
|
|
||
|
|
++level;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Make sure we add a "../" for each component we removed from the root.
|
||
|
|
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
||
|
|
}
|
||
|
|
exports.relative = relative;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Because behavior goes wacky when you set `__proto__` on objects, we
|
||
|
|
* have to prefix all the strings in our set with an arbitrary character.
|
||
|
|
*
|
||
|
|
* See https://github.com/mozilla/source-map/pull/31 and
|
||
|
|
* https://github.com/mozilla/source-map/issues/30
|
||
|
|
*
|
||
|
|
* @param String aStr
|
||
|
|
*/
|
||
|
|
function toSetString(aStr) {
|
||
|
|
return '$' + aStr;
|
||
|
|
}
|
||
|
|
exports.toSetString = toSetString;
|
||
|
|
|
||
|
|
function fromSetString(aStr) {
|
||
|
|
return aStr.substr(1);
|
||
|
|
}
|
||
|
|
exports.fromSetString = fromSetString;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Comparator between two mappings where the original positions are compared.
|
||
|
|
*
|
||
|
|
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
||
|
|
* mappings with the same original source/line/column, but different generated
|
||
|
|
* line and column the same. Useful when searching for a mapping with a
|
||
|
|
* stubbed out mapping.
|
||
|
|
*/
|
||
|
|
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
||
|
|
var cmp = mappingA.source - mappingB.source;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.originalLine - mappingB.originalLine;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||
|
|
if (cmp !== 0 || onlyCompareOriginal) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
return mappingA.name - mappingB.name;
|
||
|
|
}
|
||
|
|
exports.compareByOriginalPositions = compareByOriginalPositions;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Comparator between two mappings with deflated source and name indices where
|
||
|
|
* the generated positions are compared.
|
||
|
|
*
|
||
|
|
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
||
|
|
* mappings with the same generated line and column, but different
|
||
|
|
* source/name/original line and column the same. Useful when searching for a
|
||
|
|
* mapping with a stubbed out mapping.
|
||
|
|
*/
|
||
|
|
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
|
||
|
|
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||
|
|
if (cmp !== 0 || onlyCompareGenerated) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.source - mappingB.source;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.originalLine - mappingB.originalLine;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
return mappingA.name - mappingB.name;
|
||
|
|
}
|
||
|
|
exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
|
||
|
|
|
||
|
|
function strcmp(aStr1, aStr2) {
|
||
|
|
if (aStr1 === aStr2) {
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (aStr1 > aStr2) {
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
return -1;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Comparator between two mappings with inflated source and name strings where
|
||
|
|
* the generated positions are compared.
|
||
|
|
*/
|
||
|
|
function compareByGeneratedPositionsInflated(mappingA, mappingB) {
|
||
|
|
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = strcmp(mappingA.source, mappingB.source);
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.originalLine - mappingB.originalLine;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
||
|
|
if (cmp !== 0) {
|
||
|
|
return cmp;
|
||
|
|
}
|
||
|
|
|
||
|
|
return strcmp(mappingA.name, mappingB.name);
|
||
|
|
}
|
||
|
|
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/***/ }
|
||
|
|
/******/ ]);
|
||
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay9ib290c3RyYXAgZjFlMTE4YWJkNTdmZDlhZDAzNTIiLCJ3ZWJwYWNrOi8vLy4vdGVzdC90ZXN0LWFycmF5LXNldC5qcyIsIndlYnBhY2s6Ly8vLi9saWIvYXJyYXktc2V0LmpzIiwid2VicGFjazovLy8uL2xpYi91dGlsLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O0FBQUE7QUFDQTs7QUFFQTtBQUNBOztBQUV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