@builder.io/sdk
Advanced tools
Comparing version 3.0.1 to 3.0.2-0
{ | ||
"name": "@builder.io/sdk", | ||
"version": "3.0.1", | ||
"version": "3.0.2-0", | ||
"unpkg": "./dist/index.browser.js", | ||
@@ -75,3 +75,4 @@ "main": "./dist/index.cjs.js", | ||
"hoistingLimits": "workspaces" | ||
} | ||
}, | ||
"stableVersion": "3.0.1" | ||
} |
@@ -480,2 +480,3 @@ /// <reference types="node" /> | ||
meta?: Record<string, any>; | ||
behavior?: string; | ||
} | ||
@@ -482,0 +483,0 @@ /** |
@@ -1,170 +0,166 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.TinyPromise = void 0; | ||
var next_tick_function_1 = require("../functions/next-tick.function"); | ||
var next_tick_function_1 = require('../functions/next-tick.function'); | ||
var State = { | ||
Pending: 'Pending', | ||
Fulfilled: 'Fulfilled', | ||
Rejected: 'Rejected', | ||
Pending: 'Pending', | ||
Fulfilled: 'Fulfilled', | ||
Rejected: 'Rejected', | ||
}; | ||
function isFunction(val) { | ||
return val && typeof val === 'function'; | ||
return val && typeof val === 'function'; | ||
} | ||
function isObject(val) { | ||
return val && typeof val === 'object'; | ||
return val && typeof val === 'object'; | ||
} | ||
var TinyPromise = /** @class */ (function () { | ||
function TinyPromise(executor) { | ||
this._state = State.Pending; | ||
this._handlers = []; | ||
this._value = null; | ||
executor(this._resolve.bind(this), this._reject.bind(this)); | ||
function TinyPromise(executor) { | ||
this._state = State.Pending; | ||
this._handlers = []; | ||
this._value = null; | ||
executor(this._resolve.bind(this), this._reject.bind(this)); | ||
} | ||
TinyPromise.prototype._resolve = function (x) { | ||
var _this = this; | ||
if (x instanceof TinyPromise) { | ||
x.then(this._resolve.bind(this), this._reject.bind(this)); | ||
} else if (isObject(x) || isFunction(x)) { | ||
var called_1 = false; | ||
try { | ||
var thenable = x.then; | ||
if (isFunction(thenable)) { | ||
thenable.call( | ||
x, | ||
function (result) { | ||
if (!called_1) _this._resolve(result); | ||
called_1 = true; | ||
return undefined; | ||
}, | ||
function (error) { | ||
if (!called_1) _this._reject(error); | ||
called_1 = true; | ||
return undefined; | ||
} | ||
); | ||
} else { | ||
this._fulfill(x); | ||
} | ||
} catch (ex) { | ||
if (!called_1) { | ||
this._reject(ex); | ||
} | ||
} | ||
} else { | ||
this._fulfill(x); | ||
} | ||
TinyPromise.prototype._resolve = function (x) { | ||
var _this = this; | ||
if (x instanceof TinyPromise) { | ||
x.then(this._resolve.bind(this), this._reject.bind(this)); | ||
} | ||
else if (isObject(x) || isFunction(x)) { | ||
var called_1 = false; | ||
try { | ||
var thenable = x.then; | ||
if (isFunction(thenable)) { | ||
thenable.call(x, function (result) { | ||
if (!called_1) | ||
_this._resolve(result); | ||
called_1 = true; | ||
return undefined; | ||
}, function (error) { | ||
if (!called_1) | ||
_this._reject(error); | ||
called_1 = true; | ||
return undefined; | ||
}); | ||
}; | ||
TinyPromise.prototype._fulfill = function (result) { | ||
var _this = this; | ||
this._state = State.Fulfilled; | ||
this._value = result; | ||
this._handlers.forEach(function (handler) { | ||
return _this._callHandler(handler); | ||
}); | ||
}; | ||
TinyPromise.prototype._reject = function (error) { | ||
var _this = this; | ||
this._state = State.Rejected; | ||
this._value = error; | ||
this._handlers.forEach(function (handler) { | ||
return _this._callHandler(handler); | ||
}); | ||
}; | ||
TinyPromise.prototype._isPending = function () { | ||
return this._state === State.Pending; | ||
}; | ||
TinyPromise.prototype._isFulfilled = function () { | ||
return this._state === State.Fulfilled; | ||
}; | ||
TinyPromise.prototype._isRejected = function () { | ||
return this._state === State.Rejected; | ||
}; | ||
TinyPromise.prototype._addHandler = function (onFulfilled, onRejected) { | ||
this._handlers.push({ | ||
onFulfilled: onFulfilled, | ||
onRejected: onRejected, | ||
}); | ||
}; | ||
TinyPromise.prototype._callHandler = function (handler) { | ||
if (this._isFulfilled() && isFunction(handler.onFulfilled)) { | ||
handler.onFulfilled(this._value); | ||
} else if (this._isRejected() && isFunction(handler.onRejected)) { | ||
handler.onRejected(this._value); | ||
} | ||
}; | ||
TinyPromise.prototype.then = function (onFulfilled, onRejected) { | ||
var _this = this; | ||
switch (this._state) { | ||
case State.Pending: { | ||
return new TinyPromise(function (resolve, reject) { | ||
_this._addHandler( | ||
function (value) { | ||
(0, next_tick_function_1.nextTick)(function () { | ||
try { | ||
if (isFunction(onFulfilled)) { | ||
resolve(onFulfilled(value)); | ||
} else { | ||
resolve(value); | ||
} | ||
} catch (ex) { | ||
reject(ex); | ||
} | ||
else { | ||
this._fulfill(x); | ||
}); | ||
}, | ||
function (error) { | ||
(0, next_tick_function_1.nextTick)(function () { | ||
try { | ||
if (isFunction(onRejected)) { | ||
resolve(onRejected(error)); | ||
} else { | ||
reject(error); | ||
} | ||
} catch (ex) { | ||
reject(ex); | ||
} | ||
}); | ||
} | ||
catch (ex) { | ||
if (!called_1) { | ||
this._reject(ex); | ||
} | ||
); | ||
}); | ||
} | ||
case State.Fulfilled: { | ||
return new TinyPromise(function (resolve, reject) { | ||
(0, next_tick_function_1.nextTick)(function () { | ||
try { | ||
if (isFunction(onFulfilled)) { | ||
resolve(onFulfilled(_this._value)); | ||
} else { | ||
resolve(_this._value); | ||
} | ||
} catch (ex) { | ||
reject(ex); | ||
} | ||
} | ||
else { | ||
this._fulfill(x); | ||
} | ||
}; | ||
TinyPromise.prototype._fulfill = function (result) { | ||
var _this = this; | ||
this._state = State.Fulfilled; | ||
this._value = result; | ||
this._handlers.forEach(function (handler) { return _this._callHandler(handler); }); | ||
}; | ||
TinyPromise.prototype._reject = function (error) { | ||
var _this = this; | ||
this._state = State.Rejected; | ||
this._value = error; | ||
this._handlers.forEach(function (handler) { return _this._callHandler(handler); }); | ||
}; | ||
TinyPromise.prototype._isPending = function () { | ||
return this._state === State.Pending; | ||
}; | ||
TinyPromise.prototype._isFulfilled = function () { | ||
return this._state === State.Fulfilled; | ||
}; | ||
TinyPromise.prototype._isRejected = function () { | ||
return this._state === State.Rejected; | ||
}; | ||
TinyPromise.prototype._addHandler = function (onFulfilled, onRejected) { | ||
this._handlers.push({ | ||
onFulfilled: onFulfilled, | ||
onRejected: onRejected, | ||
}); | ||
}); | ||
}; | ||
TinyPromise.prototype._callHandler = function (handler) { | ||
if (this._isFulfilled() && isFunction(handler.onFulfilled)) { | ||
handler.onFulfilled(this._value); | ||
} | ||
else if (this._isRejected() && isFunction(handler.onRejected)) { | ||
handler.onRejected(this._value); | ||
} | ||
}; | ||
TinyPromise.prototype.then = function (onFulfilled, onRejected) { | ||
var _this = this; | ||
switch (this._state) { | ||
case State.Pending: { | ||
return new TinyPromise(function (resolve, reject) { | ||
_this._addHandler(function (value) { | ||
(0, next_tick_function_1.nextTick)(function () { | ||
try { | ||
if (isFunction(onFulfilled)) { | ||
resolve(onFulfilled(value)); | ||
} | ||
else { | ||
resolve(value); | ||
} | ||
} | ||
catch (ex) { | ||
reject(ex); | ||
} | ||
}); | ||
}, function (error) { | ||
(0, next_tick_function_1.nextTick)(function () { | ||
try { | ||
if (isFunction(onRejected)) { | ||
resolve(onRejected(error)); | ||
} | ||
else { | ||
reject(error); | ||
} | ||
} | ||
catch (ex) { | ||
reject(ex); | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
case State.Rejected: { | ||
return new TinyPromise(function (resolve, reject) { | ||
(0, next_tick_function_1.nextTick)(function () { | ||
try { | ||
if (isFunction(onRejected)) { | ||
resolve(onRejected(_this._value)); | ||
} else { | ||
reject(_this._value); | ||
} | ||
} catch (ex) { | ||
reject(ex); | ||
} | ||
case State.Fulfilled: { | ||
return new TinyPromise(function (resolve, reject) { | ||
(0, next_tick_function_1.nextTick)(function () { | ||
try { | ||
if (isFunction(onFulfilled)) { | ||
resolve(onFulfilled(_this._value)); | ||
} | ||
else { | ||
resolve(_this._value); | ||
} | ||
} | ||
catch (ex) { | ||
reject(ex); | ||
} | ||
}); | ||
}); | ||
} | ||
case State.Rejected: { | ||
return new TinyPromise(function (resolve, reject) { | ||
(0, next_tick_function_1.nextTick)(function () { | ||
try { | ||
if (isFunction(onRejected)) { | ||
resolve(onRejected(_this._value)); | ||
} | ||
else { | ||
reject(_this._value); | ||
} | ||
} | ||
catch (ex) { | ||
reject(ex); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
}; | ||
return TinyPromise; | ||
}()); | ||
}); | ||
}); | ||
} | ||
} | ||
}; | ||
return TinyPromise; | ||
})(); | ||
exports.TinyPromise = TinyPromise; | ||
exports.default = (typeof Promise !== 'undefined' ? Promise : TinyPromise); | ||
//# sourceMappingURL=promise.class.js.map | ||
exports.default = typeof Promise !== 'undefined' ? Promise : TinyPromise; | ||
//# sourceMappingURL=promise.class.js.map |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.QueryString = void 0; | ||
@@ -7,78 +7,77 @@ var PROPERTY_NAME_DENY_LIST = Object.freeze(['__proto__', 'prototype', 'constructor']); | ||
var QueryString = /** @class */ (function () { | ||
function QueryString() { | ||
function QueryString() {} | ||
QueryString.parseDeep = function (queryString) { | ||
var obj = this.parse(queryString); | ||
return this.deepen(obj); | ||
}; | ||
QueryString.stringifyDeep = function (obj) { | ||
var map = this.flatten(obj); | ||
return this.stringify(map); | ||
}; | ||
QueryString.parse = function (queryString) { | ||
var query = {}; | ||
var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&'); | ||
for (var i = 0; i < pairs.length; i++) { | ||
var pair = pairs[i].split('='); | ||
// TODO: node support? | ||
try { | ||
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || ''); | ||
} catch (error) { | ||
// Ignore malformed URI components | ||
} | ||
} | ||
QueryString.parseDeep = function (queryString) { | ||
var obj = this.parse(queryString); | ||
return this.deepen(obj); | ||
}; | ||
QueryString.stringifyDeep = function (obj) { | ||
var map = this.flatten(obj); | ||
return this.stringify(map); | ||
}; | ||
QueryString.parse = function (queryString) { | ||
var query = {}; | ||
var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&'); | ||
for (var i = 0; i < pairs.length; i++) { | ||
var pair = pairs[i].split('='); | ||
// TODO: node support? | ||
try { | ||
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || ''); | ||
} | ||
catch (error) { | ||
// Ignore malformed URI components | ||
} | ||
return query; | ||
}; | ||
QueryString.stringify = function (map) { | ||
var str = ''; | ||
for (var key in map) { | ||
if (map.hasOwnProperty(key)) { | ||
var value = map[key]; | ||
if (str) { | ||
str += '&'; | ||
} | ||
return query; | ||
}; | ||
QueryString.stringify = function (map) { | ||
var str = ''; | ||
for (var key in map) { | ||
if (map.hasOwnProperty(key)) { | ||
var value = map[key]; | ||
if (str) { | ||
str += '&'; | ||
} | ||
str += encodeURIComponent(key) + '=' + encodeURIComponent(value); | ||
} | ||
} | ||
return str; | ||
}; | ||
QueryString.deepen = function (map) { | ||
// FIXME; Should be type Tree = Record<string, string | Tree> | ||
// requires a typescript upgrade. | ||
var output = {}; | ||
for (var k in map) { | ||
var t = output; | ||
var parts = k.split('.'); | ||
var key = parts.pop(); | ||
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
var part = parts_1[_i]; | ||
assertAllowedPropertyName(part); | ||
t = t[part] = t[part] || {}; | ||
} | ||
t[key] = map[k]; | ||
} | ||
return output; | ||
}; | ||
QueryString.flatten = function (obj, _current, _res) { | ||
if (_res === void 0) { _res = {}; } | ||
for (var key in obj) { | ||
var value = obj[key]; | ||
var newKey = _current ? _current + '.' + key : key; | ||
if (value && typeof value === 'object') { | ||
this.flatten(value, newKey, _res); | ||
} | ||
else { | ||
_res[newKey] = value; | ||
} | ||
} | ||
return _res; | ||
}; | ||
return QueryString; | ||
}()); | ||
str += encodeURIComponent(key) + '=' + encodeURIComponent(value); | ||
} | ||
} | ||
return str; | ||
}; | ||
QueryString.deepen = function (map) { | ||
// FIXME; Should be type Tree = Record<string, string | Tree> | ||
// requires a typescript upgrade. | ||
var output = {}; | ||
for (var k in map) { | ||
var t = output; | ||
var parts = k.split('.'); | ||
var key = parts.pop(); | ||
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
var part = parts_1[_i]; | ||
assertAllowedPropertyName(part); | ||
t = t[part] = t[part] || {}; | ||
} | ||
t[key] = map[k]; | ||
} | ||
return output; | ||
}; | ||
QueryString.flatten = function (obj, _current, _res) { | ||
if (_res === void 0) { | ||
_res = {}; | ||
} | ||
for (var key in obj) { | ||
var value = obj[key]; | ||
var newKey = _current ? _current + '.' + key : key; | ||
if (value && typeof value === 'object') { | ||
this.flatten(value, newKey, _res); | ||
} else { | ||
_res[newKey] = value; | ||
} | ||
} | ||
return _res; | ||
}; | ||
return QueryString; | ||
})(); | ||
exports.QueryString = QueryString; | ||
function assertAllowedPropertyName(name) { | ||
if (PROPERTY_NAME_DENY_LIST.indexOf(name) >= 0) | ||
throw new Error("Property name \"".concat(name, "\" is not allowed")); | ||
if (PROPERTY_NAME_DENY_LIST.indexOf(name) >= 0) | ||
throw new Error('Property name "'.concat(name, '" is not allowed')); | ||
} | ||
//# sourceMappingURL=query-string.class.js.map | ||
//# sourceMappingURL=query-string.class.js.map |
@@ -1,25 +0,25 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var query_string_class_1 = require("./query-string.class"); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var query_string_class_1 = require('./query-string.class'); | ||
test.each([ | ||
// prettier-ignore | ||
['__proto__.foo.baz=1'], | ||
['prototype.foo=1'], | ||
// prettier-ignore | ||
['__proto__.foo.baz=1'], | ||
['prototype.foo=1'], | ||
])('(regression) prototype pollution %#', function (input) { | ||
expect(function () { | ||
query_string_class_1.QueryString.parseDeep(input); | ||
}).toThrowError(/Property name \".*\" is not allowed/); | ||
var pollutedObject = {}; | ||
expect(pollutedObject.foo).toBeUndefined(); | ||
expect(function () { | ||
query_string_class_1.QueryString.parseDeep(input); | ||
}).toThrowError(/Property name \".*\" is not allowed/); | ||
var pollutedObject = {}; | ||
expect(pollutedObject.foo).toBeUndefined(); | ||
}); | ||
describe('.parseDeep', function () { | ||
test('input string may be prefixed with a question mark', function () { | ||
var result = query_string_class_1.QueryString.parseDeep('?foo=1'); | ||
expect(result).toEqual({ foo: '1' }); | ||
}); | ||
test('converts the paths to a single object', function () { | ||
var result = query_string_class_1.QueryString.parseDeep('foo.bar.baz=1&foo.boo=2'); | ||
expect(result).toEqual({ foo: { bar: { baz: '1' }, boo: '2' } }); | ||
}); | ||
test('input string may be prefixed with a question mark', function () { | ||
var result = query_string_class_1.QueryString.parseDeep('?foo=1'); | ||
expect(result).toEqual({ foo: '1' }); | ||
}); | ||
test('converts the paths to a single object', function () { | ||
var result = query_string_class_1.QueryString.parseDeep('foo.bar.baz=1&foo.boo=2'); | ||
expect(result).toEqual({ foo: { bar: { baz: '1' }, boo: '2' } }); | ||
}); | ||
}); | ||
//# sourceMappingURL=query-string.class.test.js.map | ||
//# sourceMappingURL=query-string.class.test.js.map |
@@ -1,25 +0,25 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.assign = void 0; | ||
function assign(target) { | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
} | ||
var to = Object(target); | ||
for (var index = 1; index < arguments.length; index++) { | ||
var nextSource = arguments[index]; | ||
if (nextSource != null) { | ||
// Skip over if undefined or null | ||
for (var nextKey in nextSource) { | ||
// Avoid bugs when hasOwnProperty is shadowed | ||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
} | ||
var to = Object(target); | ||
for (var index = 1; index < arguments.length; index++) { | ||
var nextSource = arguments[index]; | ||
if (nextSource != null) { | ||
// Skip over if undefined or null | ||
for (var nextKey in nextSource) { | ||
// Avoid bugs when hasOwnProperty is shadowed | ||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { | ||
to[nextKey] = nextSource[nextKey]; | ||
} | ||
} | ||
} | ||
return to; | ||
} | ||
return to; | ||
} | ||
exports.assign = assign; | ||
//# sourceMappingURL=assign.function.js.map | ||
//# sourceMappingURL=assign.function.js.map |
@@ -1,85 +0,107 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
var __importDefault = | ||
(this && this.__importDefault) || | ||
function (mod) { | ||
return mod && mod.__esModule ? mod : { default: mod }; | ||
}; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.getFetch = void 0; | ||
var promise_class_1 = __importDefault(require("../classes/promise.class")); | ||
var server_only_require_function_1 = __importDefault(require("./server-only-require.function")); | ||
var promise_class_1 = __importDefault(require('../classes/promise.class')); | ||
var server_only_require_function_1 = __importDefault(require('./server-only-require.function')); | ||
function promiseResolve(value) { | ||
return new promise_class_1.default(function (resolve) { return resolve(value); }); | ||
return new promise_class_1.default(function (resolve) { | ||
return resolve(value); | ||
}); | ||
} | ||
// Adapted from https://raw.githubusercontent.com/developit/unfetch/master/src/index.mjs | ||
function tinyFetch(url, options) { | ||
if (options === void 0) { options = {}; } | ||
return new promise_class_1.default(function (resolve, reject) { | ||
var request = new XMLHttpRequest(); | ||
request.open(options.method || 'get', url, true); | ||
if (options.headers) { | ||
for (var i in options.headers) { | ||
request.setRequestHeader(i, options.headers[i]); | ||
} | ||
} | ||
request.withCredentials = options.credentials === 'include'; | ||
request.onload = function () { | ||
resolve(response()); | ||
}; | ||
request.onerror = reject; | ||
request.send(options.body); | ||
function response() { | ||
var keys = []; | ||
var all = []; | ||
var headers = {}; | ||
var header = undefined; | ||
request | ||
.getAllResponseHeaders() | ||
.replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function (_match, _key, value) { | ||
var key = _key; | ||
keys.push((key = key.toLowerCase())); | ||
all.push([key, value]); | ||
header = headers[key]; | ||
headers[key] = header ? "".concat(header, ",").concat(value) : value; | ||
return ''; | ||
}); | ||
return { | ||
ok: ((request.status / 100) | 0) === 2, | ||
status: request.status, | ||
statusText: request.statusText, | ||
url: request.responseURL, | ||
clone: response, | ||
text: function () { return promiseResolve(request.responseText); }, | ||
json: function () { return promiseResolve(request.responseText).then(JSON.parse); }, | ||
blob: function () { return promiseResolve(new Blob([request.response])); }, | ||
headers: { | ||
keys: function () { return keys; }, | ||
entries: function () { return all; }, | ||
get: function (n) { return headers[n.toLowerCase()]; }, | ||
has: function (n) { return n.toLowerCase() in headers; }, | ||
}, | ||
}; | ||
} | ||
}); | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
return new promise_class_1.default(function (resolve, reject) { | ||
var request = new XMLHttpRequest(); | ||
request.open(options.method || 'get', url, true); | ||
if (options.headers) { | ||
for (var i in options.headers) { | ||
request.setRequestHeader(i, options.headers[i]); | ||
} | ||
} | ||
request.withCredentials = options.credentials === 'include'; | ||
request.onload = function () { | ||
resolve(response()); | ||
}; | ||
request.onerror = reject; | ||
request.send(options.body); | ||
function response() { | ||
var keys = []; | ||
var all = []; | ||
var headers = {}; | ||
var header = undefined; | ||
request | ||
.getAllResponseHeaders() | ||
.replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, function (_match, _key, value) { | ||
var key = _key; | ||
keys.push((key = key.toLowerCase())); | ||
all.push([key, value]); | ||
header = headers[key]; | ||
headers[key] = header ? ''.concat(header, ',').concat(value) : value; | ||
return ''; | ||
}); | ||
return { | ||
ok: ((request.status / 100) | 0) === 2, | ||
status: request.status, | ||
statusText: request.statusText, | ||
url: request.responseURL, | ||
clone: response, | ||
text: function () { | ||
return promiseResolve(request.responseText); | ||
}, | ||
json: function () { | ||
return promiseResolve(request.responseText).then(JSON.parse); | ||
}, | ||
blob: function () { | ||
return promiseResolve(new Blob([request.response])); | ||
}, | ||
headers: { | ||
keys: function () { | ||
return keys; | ||
}, | ||
entries: function () { | ||
return all; | ||
}, | ||
get: function (n) { | ||
return headers[n.toLowerCase()]; | ||
}, | ||
has: function (n) { | ||
return n.toLowerCase() in headers; | ||
}, | ||
}, | ||
}; | ||
} | ||
}); | ||
} | ||
function getFetch() { | ||
// If fetch is defined, in the browser, via polyfill, or in a Cloudflare worker, use it. | ||
var _fetch = undefined; | ||
if (globalThis.fetch) { | ||
_fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = globalThis.fetch); | ||
// If fetch is defined, in the browser, via polyfill, or in a Cloudflare worker, use it. | ||
var _fetch = undefined; | ||
if (globalThis.fetch) { | ||
_fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = globalThis.fetch); | ||
} else if (typeof window === 'undefined') { | ||
// If fetch is not defined, in a Node.js environment, use node-fetch. | ||
try { | ||
// node-fetch@^3 is ESM only, and will throw error on require. | ||
_fetch !== null && _fetch !== void 0 | ||
? _fetch | ||
: (_fetch = (0, server_only_require_function_1.default)('node-fetch')); | ||
} catch (e) { | ||
// If node-fetch is not installed, use tiny-fetch. | ||
console.warn( | ||
'node-fetch is not installed. consider polyfilling fetch or installing node-fetch.' | ||
); | ||
console.warn(e); | ||
} | ||
else if (typeof window === 'undefined') { | ||
// If fetch is not defined, in a Node.js environment, use node-fetch. | ||
try { | ||
// node-fetch@^3 is ESM only, and will throw error on require. | ||
_fetch !== null && _fetch !== void 0 ? _fetch : (_fetch = (0, server_only_require_function_1.default)('node-fetch')); | ||
} | ||
catch (e) { | ||
// If node-fetch is not installed, use tiny-fetch. | ||
console.warn('node-fetch is not installed. consider polyfilling fetch or installing node-fetch.'); | ||
console.warn(e); | ||
} | ||
} | ||
// Otherwise, use tiny-fetch. | ||
return _fetch !== null && _fetch !== void 0 ? _fetch : tinyFetch; | ||
} | ||
// Otherwise, use tiny-fetch. | ||
return _fetch !== null && _fetch !== void 0 ? _fetch : tinyFetch; | ||
} | ||
exports.getFetch = getFetch; | ||
//# sourceMappingURL=fetch.function.js.map | ||
//# sourceMappingURL=fetch.function.js.map |
@@ -1,66 +0,150 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
'use strict'; | ||
var __assign = | ||
(this && this.__assign) || | ||
function () { | ||
__assign = | ||
Object.assign || | ||
function (t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
}; | ||
var __generator = | ||
(this && this.__generator) || | ||
function (thisArg, body) { | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [], | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
return ( | ||
(g = { next: verb(0), throw: verb(1), return: verb(2) }), | ||
typeof Symbol === 'function' && | ||
(g[Symbol.iterator] = function () { | ||
return this; | ||
}), | ||
g | ||
); | ||
function verb(n) { | ||
return function (v) { | ||
return step([n, v]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
if (f) throw new TypeError('Generator is already executing.'); | ||
while ((g && ((g = 0), op[0] && (_ = 0)), _)) | ||
try { | ||
if ( | ||
((f = 1), | ||
y && | ||
(t = | ||
op[0] & 2 | ||
? y['return'] | ||
: op[0] | ||
? y['throw'] || ((t = y['return']) && t.call(y), 0) | ||
: y.next) && | ||
!(t = t.call(y, op[1])).done) | ||
) | ||
return t; | ||
if (((y = 0), t)) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { value: op[1], done: false }; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [0]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if ( | ||
!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && | ||
(op[0] === 6 || op[0] === 2) | ||
) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [6, e]; | ||
y = 0; | ||
} finally { | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
}; | ||
var __spreadArray = | ||
(this && this.__spreadArray) || | ||
function (to, from, pack) { | ||
if (pack || arguments.length === 2) | ||
for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
}; | ||
var __values = | ||
(this && this.__values) || | ||
function (o) { | ||
var s = typeof Symbol === 'function' && Symbol.iterator, | ||
m = s && o[s], | ||
i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
if (o && typeof o.length === 'number') | ||
return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
}, | ||
}; | ||
throw new TypeError(s ? 'Object is not iterable.' : 'Symbol.iterator is not defined.'); | ||
}; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var Limit; | ||
(function (Limit) { | ||
Limit[Limit["All"] = 0] = "All"; | ||
Limit[Limit["Two"] = 1] = "Two"; | ||
Limit[Limit["One"] = 2] = "One"; | ||
Limit[(Limit['All'] = 0)] = 'All'; | ||
Limit[(Limit['Two'] = 1)] = 'Two'; | ||
Limit[(Limit['One'] = 2)] = 'One'; | ||
})(Limit || (Limit = {})); | ||
@@ -70,272 +154,303 @@ var config; | ||
function default_1(input, options) { | ||
if (input.nodeType !== Node.ELEMENT_NODE) { | ||
throw new Error("Can't generate CSS selector for non-element node type."); | ||
} | ||
if ('html' === input.tagName.toLowerCase()) { | ||
return input.tagName.toLowerCase(); | ||
} | ||
var defaults = { | ||
root: document.body, | ||
idName: function (name) { return true; }, | ||
className: function (name) { return true; }, | ||
tagName: function (name) { return true; }, | ||
seedMinLength: 1, | ||
optimizedMinLength: 2, | ||
threshold: 1000, | ||
}; | ||
config = __assign(__assign({}, defaults), options); | ||
rootDocument = findRootDocument(config.root, defaults); | ||
var path = bottomUpSearch(input, Limit.All, function () { | ||
return bottomUpSearch(input, Limit.Two, function () { return bottomUpSearch(input, Limit.One); }); | ||
if (input.nodeType !== Node.ELEMENT_NODE) { | ||
throw new Error("Can't generate CSS selector for non-element node type."); | ||
} | ||
if ('html' === input.tagName.toLowerCase()) { | ||
return input.tagName.toLowerCase(); | ||
} | ||
var defaults = { | ||
root: document.body, | ||
idName: function (name) { | ||
return true; | ||
}, | ||
className: function (name) { | ||
return true; | ||
}, | ||
tagName: function (name) { | ||
return true; | ||
}, | ||
seedMinLength: 1, | ||
optimizedMinLength: 2, | ||
threshold: 1000, | ||
}; | ||
config = __assign(__assign({}, defaults), options); | ||
rootDocument = findRootDocument(config.root, defaults); | ||
var path = bottomUpSearch(input, Limit.All, function () { | ||
return bottomUpSearch(input, Limit.Two, function () { | ||
return bottomUpSearch(input, Limit.One); | ||
}); | ||
if (path) { | ||
var optimized = sort(optimize(path, input)); | ||
if (optimized.length > 0) { | ||
path = optimized[0]; | ||
} | ||
return selector(path); | ||
}); | ||
if (path) { | ||
var optimized = sort(optimize(path, input)); | ||
if (optimized.length > 0) { | ||
path = optimized[0]; | ||
} | ||
else { | ||
throw new Error("Selector was not found."); | ||
} | ||
return selector(path); | ||
} else { | ||
throw new Error('Selector was not found.'); | ||
} | ||
} | ||
exports.default = default_1; | ||
function findRootDocument(rootNode, defaults) { | ||
if (rootNode.nodeType === Node.DOCUMENT_NODE) { | ||
return rootNode; | ||
} | ||
if (rootNode === defaults.root) { | ||
return rootNode.ownerDocument; | ||
} | ||
if (rootNode.nodeType === Node.DOCUMENT_NODE) { | ||
return rootNode; | ||
} | ||
if (rootNode === defaults.root) { | ||
return rootNode.ownerDocument; | ||
} | ||
return rootNode; | ||
} | ||
function bottomUpSearch(input, limit, fallback) { | ||
var path = null; | ||
var stack = []; | ||
var current = input; | ||
var i = 0; | ||
var _loop_1 = function () { | ||
var level = maybe(id(current)) || maybe.apply(void 0, classNames(current)) || | ||
maybe(tagName(current)) || [any()]; | ||
var nth = index(current); | ||
if (limit === Limit.All) { | ||
if (nth) { | ||
level = level.concat(level.filter(dispensableNth).map(function (node) { return nthChild(node, nth); })); | ||
} | ||
} | ||
else if (limit === Limit.Two) { | ||
level = level.slice(0, 1); | ||
if (nth) { | ||
level = level.concat(level.filter(dispensableNth).map(function (node) { return nthChild(node, nth); })); | ||
} | ||
} | ||
else if (limit === Limit.One) { | ||
var node = (level = level.slice(0, 1))[0]; | ||
if (nth && dispensableNth(node)) { | ||
level = [nthChild(node, nth)]; | ||
} | ||
} | ||
for (var _i = 0, level_1 = level; _i < level_1.length; _i++) { | ||
var node = level_1[_i]; | ||
node.level = i; | ||
} | ||
stack.push(level); | ||
if (stack.length >= config.seedMinLength) { | ||
path = findUniquePath(stack, fallback); | ||
if (path) { | ||
return "break"; | ||
} | ||
} | ||
current = current.parentElement; | ||
i++; | ||
}; | ||
while (current && current !== config.root.parentElement) { | ||
var state_1 = _loop_1(); | ||
if (state_1 === "break") | ||
break; | ||
var path = null; | ||
var stack = []; | ||
var current = input; | ||
var i = 0; | ||
var _loop_1 = function () { | ||
var level = maybe(id(current)) || | ||
maybe.apply(void 0, classNames(current)) || | ||
maybe(tagName(current)) || [any()]; | ||
var nth = index(current); | ||
if (limit === Limit.All) { | ||
if (nth) { | ||
level = level.concat( | ||
level.filter(dispensableNth).map(function (node) { | ||
return nthChild(node, nth); | ||
}) | ||
); | ||
} | ||
} else if (limit === Limit.Two) { | ||
level = level.slice(0, 1); | ||
if (nth) { | ||
level = level.concat( | ||
level.filter(dispensableNth).map(function (node) { | ||
return nthChild(node, nth); | ||
}) | ||
); | ||
} | ||
} else if (limit === Limit.One) { | ||
var node = (level = level.slice(0, 1))[0]; | ||
if (nth && dispensableNth(node)) { | ||
level = [nthChild(node, nth)]; | ||
} | ||
} | ||
if (!path) { | ||
path = findUniquePath(stack, fallback); | ||
for (var _i = 0, level_1 = level; _i < level_1.length; _i++) { | ||
var node = level_1[_i]; | ||
node.level = i; | ||
} | ||
return path; | ||
stack.push(level); | ||
if (stack.length >= config.seedMinLength) { | ||
path = findUniquePath(stack, fallback); | ||
if (path) { | ||
return 'break'; | ||
} | ||
} | ||
current = current.parentElement; | ||
i++; | ||
}; | ||
while (current && current !== config.root.parentElement) { | ||
var state_1 = _loop_1(); | ||
if (state_1 === 'break') break; | ||
} | ||
if (!path) { | ||
path = findUniquePath(stack, fallback); | ||
} | ||
return path; | ||
} | ||
function findUniquePath(stack, fallback) { | ||
var paths = sort(combinations(stack)); | ||
if (paths.length > config.threshold) { | ||
return fallback ? fallback() : null; | ||
var paths = sort(combinations(stack)); | ||
if (paths.length > config.threshold) { | ||
return fallback ? fallback() : null; | ||
} | ||
for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) { | ||
var candidate = paths_1[_i]; | ||
if (unique(candidate)) { | ||
return candidate; | ||
} | ||
for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) { | ||
var candidate = paths_1[_i]; | ||
if (unique(candidate)) { | ||
return candidate; | ||
} | ||
} | ||
return null; | ||
} | ||
return null; | ||
} | ||
function selector(path) { | ||
var node = path[0]; | ||
var query = node.name; | ||
for (var i = 1; i < path.length; i++) { | ||
var level = path[i].level || 0; | ||
if (node.level === level - 1) { | ||
query = "".concat(path[i].name, " > ").concat(query); | ||
} | ||
else { | ||
query = "".concat(path[i].name, " ").concat(query); | ||
} | ||
node = path[i]; | ||
var node = path[0]; | ||
var query = node.name; | ||
for (var i = 1; i < path.length; i++) { | ||
var level = path[i].level || 0; | ||
if (node.level === level - 1) { | ||
query = ''.concat(path[i].name, ' > ').concat(query); | ||
} else { | ||
query = ''.concat(path[i].name, ' ').concat(query); | ||
} | ||
return query; | ||
node = path[i]; | ||
} | ||
return query; | ||
} | ||
function penalty(path) { | ||
return path.map(function (node) { return node.penalty; }).reduce(function (acc, i) { return acc + i; }, 0); | ||
return path | ||
.map(function (node) { | ||
return node.penalty; | ||
}) | ||
.reduce(function (acc, i) { | ||
return acc + i; | ||
}, 0); | ||
} | ||
function unique(path) { | ||
switch (rootDocument.querySelectorAll(selector(path)).length) { | ||
case 0: | ||
throw new Error("Can't select any node with this selector: ".concat(selector(path))); | ||
case 1: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
switch (rootDocument.querySelectorAll(selector(path)).length) { | ||
case 0: | ||
throw new Error("Can't select any node with this selector: ".concat(selector(path))); | ||
case 1: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
function id(input) { | ||
var elementId = input.getAttribute('id'); | ||
if (elementId && config.idName(elementId)) { | ||
return { | ||
name: '#' + elementId, | ||
penalty: 0, | ||
}; | ||
} | ||
return null; | ||
var elementId = input.getAttribute('id'); | ||
if (elementId && config.idName(elementId)) { | ||
return { | ||
name: '#' + elementId, | ||
penalty: 0, | ||
}; | ||
} | ||
return null; | ||
} | ||
function classNames(input) { | ||
var names = [].slice.call(input.classList).filter(config.className); | ||
return names.map(function (name) { return ({ | ||
name: '.' + name, | ||
penalty: 1, | ||
}); }); | ||
var names = [].slice.call(input.classList).filter(config.className); | ||
return names.map(function (name) { | ||
return { | ||
name: '.' + name, | ||
penalty: 1, | ||
}; | ||
}); | ||
} | ||
function tagName(input) { | ||
var name = input.tagName.toLowerCase(); | ||
if (config.tagName(name)) { | ||
return { | ||
name: name, | ||
penalty: 2, | ||
}; | ||
} | ||
return null; | ||
} | ||
function any() { | ||
var name = input.tagName.toLowerCase(); | ||
if (config.tagName(name)) { | ||
return { | ||
name: '*', | ||
penalty: 3, | ||
name: name, | ||
penalty: 2, | ||
}; | ||
} | ||
return null; | ||
} | ||
function any() { | ||
return { | ||
name: '*', | ||
penalty: 3, | ||
}; | ||
} | ||
function index(input) { | ||
var parent = input.parentNode; | ||
if (!parent) { | ||
return null; | ||
var parent = input.parentNode; | ||
if (!parent) { | ||
return null; | ||
} | ||
var child = parent.firstChild; | ||
if (!child) { | ||
return null; | ||
} | ||
var i = 0; | ||
while (child) { | ||
if (child.nodeType === Node.ELEMENT_NODE) { | ||
i++; | ||
} | ||
var child = parent.firstChild; | ||
if (!child) { | ||
return null; | ||
if (child === input) { | ||
break; | ||
} | ||
var i = 0; | ||
while (child) { | ||
if (child.nodeType === Node.ELEMENT_NODE) { | ||
i++; | ||
} | ||
if (child === input) { | ||
break; | ||
} | ||
child = child.nextSibling; | ||
} | ||
return i; | ||
child = child.nextSibling; | ||
} | ||
return i; | ||
} | ||
function nthChild(node, i) { | ||
return { | ||
name: node.name + ":nth-child(".concat(i, ")"), | ||
penalty: node.penalty + 1, | ||
}; | ||
return { | ||
name: node.name + ':nth-child('.concat(i, ')'), | ||
penalty: node.penalty + 1, | ||
}; | ||
} | ||
function dispensableNth(node) { | ||
return node.name !== 'html' && !(node.name[0] === '#'); | ||
return node.name !== 'html' && !(node.name[0] === '#'); | ||
} | ||
function maybe() { | ||
var level = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
level[_i] = arguments[_i]; | ||
} | ||
var list = level.filter(notEmpty); | ||
if (list.length > 0) { | ||
return list; | ||
} | ||
return null; | ||
var level = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
level[_i] = arguments[_i]; | ||
} | ||
var list = level.filter(notEmpty); | ||
if (list.length > 0) { | ||
return list; | ||
} | ||
return null; | ||
} | ||
function notEmpty(value) { | ||
return value !== null && value !== undefined; | ||
return value !== null && value !== undefined; | ||
} | ||
function combinations(stack, path) { | ||
var _i, _a, node; | ||
if (path === void 0) { path = []; } | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(stack.length > 0)) return [3 /*break*/, 5]; | ||
_i = 0, _a = stack[0]; | ||
_b.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 4]; | ||
node = _a[_i]; | ||
return [5 /*yield**/, __values(combinations(stack.slice(1, stack.length), path.concat(node)))]; | ||
case 2: | ||
_b.sent(); | ||
_b.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: return [3 /*break*/, 7]; | ||
case 5: return [4 /*yield*/, path]; | ||
case 6: | ||
_b.sent(); | ||
_b.label = 7; | ||
case 7: return [2 /*return*/]; | ||
} | ||
}); | ||
var _i, _a, node; | ||
if (path === void 0) { | ||
path = []; | ||
} | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!(stack.length > 0)) return [3 /*break*/, 5]; | ||
(_i = 0), (_a = stack[0]); | ||
_b.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 4]; | ||
node = _a[_i]; | ||
return [ | ||
5 /*yield**/, | ||
__values(combinations(stack.slice(1, stack.length), path.concat(node))), | ||
]; | ||
case 2: | ||
_b.sent(); | ||
_b.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: | ||
return [3 /*break*/, 7]; | ||
case 5: | ||
return [4 /*yield*/, path]; | ||
case 6: | ||
_b.sent(); | ||
_b.label = 7; | ||
case 7: | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
function sort(paths) { | ||
return [].slice.call(paths).sort(function (a, b) { return penalty(a) - penalty(b); }); | ||
return [].slice.call(paths).sort(function (a, b) { | ||
return penalty(a) - penalty(b); | ||
}); | ||
} | ||
function optimize(path, input) { | ||
var i, newPath; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!(path.length > 2 && path.length > config.optimizedMinLength)) return [3 /*break*/, 5]; | ||
i = 1; | ||
_a.label = 1; | ||
case 1: | ||
if (!(i < path.length - 1)) return [3 /*break*/, 5]; | ||
newPath = __spreadArray([], path, true); | ||
newPath.splice(i, 1); | ||
if (!(unique(newPath) && same(newPath, input))) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, newPath]; | ||
case 2: | ||
_a.sent(); | ||
return [5 /*yield**/, __values(optimize(newPath, input))]; | ||
case 3: | ||
_a.sent(); | ||
_a.label = 4; | ||
case 4: | ||
i++; | ||
return [3 /*break*/, 1]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
}); | ||
var i, newPath; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!(path.length > 2 && path.length > config.optimizedMinLength)) return [3 /*break*/, 5]; | ||
i = 1; | ||
_a.label = 1; | ||
case 1: | ||
if (!(i < path.length - 1)) return [3 /*break*/, 5]; | ||
newPath = __spreadArray([], path, true); | ||
newPath.splice(i, 1); | ||
if (!(unique(newPath) && same(newPath, input))) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, newPath]; | ||
case 2: | ||
_a.sent(); | ||
return [5 /*yield**/, __values(optimize(newPath, input))]; | ||
case 3: | ||
_a.sent(); | ||
_a.label = 4; | ||
case 4: | ||
i++; | ||
return [3 /*break*/, 1]; | ||
case 5: | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
function same(path, input) { | ||
return rootDocument.querySelector(selector(path)) === input; | ||
return rootDocument.querySelector(selector(path)) === input; | ||
} | ||
//# sourceMappingURL=finder.function.js.map | ||
//# sourceMappingURL=finder.function.js.map |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.getTopLevelDomain = void 0; | ||
@@ -10,9 +10,9 @@ /** | ||
function getTopLevelDomain(host) { | ||
var parts = host.split('.'); | ||
if (parts.length > 2) { | ||
return parts.slice(1).join('.'); | ||
} | ||
return host; | ||
var parts = host.split('.'); | ||
if (parts.length > 2) { | ||
return parts.slice(1).join('.'); | ||
} | ||
return host; | ||
} | ||
exports.getTopLevelDomain = getTopLevelDomain; | ||
//# sourceMappingURL=get-top-level-domain.js.map | ||
//# sourceMappingURL=get-top-level-domain.js.map |
@@ -1,29 +0,32 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.nextTick = void 0; | ||
var isSafari = typeof window !== 'undefined' && | ||
/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent); | ||
var isSafari = | ||
typeof window !== 'undefined' && | ||
/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent); | ||
var isClient = typeof window !== 'undefined'; | ||
// TODO: queue all of these in a debounceNextTick | ||
function nextTick(fn) { | ||
// if (typeof process !== 'undefined' && process.nextTick) { | ||
// console.log('process.nextTick?'); | ||
// process.nextTick(fn); | ||
// return; | ||
// } | ||
// FIXME: fix the real safari issue of this randomly not working | ||
if (!isClient || isSafari || typeof MutationObserver === 'undefined') { | ||
setTimeout(fn); | ||
return; | ||
} | ||
var called = 0; | ||
var observer = new MutationObserver(function () { return fn(); }); | ||
var element = document.createTextNode(''); | ||
observer.observe(element, { | ||
characterData: true, | ||
}); | ||
// tslint:disable-next-line | ||
element.data = String((called = ++called)); | ||
// if (typeof process !== 'undefined' && process.nextTick) { | ||
// console.log('process.nextTick?'); | ||
// process.nextTick(fn); | ||
// return; | ||
// } | ||
// FIXME: fix the real safari issue of this randomly not working | ||
if (!isClient || isSafari || typeof MutationObserver === 'undefined') { | ||
setTimeout(fn); | ||
return; | ||
} | ||
var called = 0; | ||
var observer = new MutationObserver(function () { | ||
return fn(); | ||
}); | ||
var element = document.createTextNode(''); | ||
observer.observe(element, { | ||
characterData: true, | ||
}); | ||
// tslint:disable-next-line | ||
element.data = String((called = ++called)); | ||
} | ||
exports.nextTick = nextTick; | ||
//# sourceMappingURL=next-tick.function.js.map | ||
//# sourceMappingURL=next-tick.function.js.map |
@@ -1,17 +0,17 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.omit = void 0; | ||
function omit(obj) { | ||
var values = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
values[_i - 1] = arguments[_i]; | ||
} | ||
var newObject = Object.assign({}, obj); | ||
for (var _a = 0, values_1 = values; _a < values_1.length; _a++) { | ||
var key = values_1[_a]; | ||
delete newObject[key]; | ||
} | ||
return newObject; | ||
var values = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
values[_i - 1] = arguments[_i]; | ||
} | ||
var newObject = Object.assign({}, obj); | ||
for (var _a = 0, values_1 = values; _a < values_1.length; _a++) { | ||
var key = values_1[_a]; | ||
delete newObject[key]; | ||
} | ||
return newObject; | ||
} | ||
exports.omit = omit; | ||
//# sourceMappingURL=omit.function.js.map | ||
//# sourceMappingURL=omit.function.js.map |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
// Webpack workaround to conditionally require certain external modules | ||
@@ -7,10 +7,11 @@ // only on the server and not bundle them on the client | ||
try { | ||
// tslint:disable-next-line:no-eval | ||
serverOnlyRequire = eval('require'); | ||
// tslint:disable-next-line:no-eval | ||
serverOnlyRequire = eval('require'); | ||
} catch (err) { | ||
// all good | ||
serverOnlyRequire = function () { | ||
return null; | ||
}; | ||
} | ||
catch (err) { | ||
// all good | ||
serverOnlyRequire = (function () { return null; }); | ||
} | ||
exports.default = serverOnlyRequire; | ||
//# sourceMappingURL=server-only-require.function.js.map | ||
//# sourceMappingURL=server-only-require.function.js.map |
@@ -1,42 +0,40 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.throttle = void 0; | ||
function throttle(func, wait, options) { | ||
if (options === void 0) { options = {}; } | ||
var context; | ||
var args; | ||
var result; | ||
var timeout = null; | ||
var previous = 0; | ||
var later = function () { | ||
previous = options.leading === false ? 0 : Date.now(); | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var context; | ||
var args; | ||
var result; | ||
var timeout = null; | ||
var previous = 0; | ||
var later = function () { | ||
previous = options.leading === false ? 0 : Date.now(); | ||
timeout = null; | ||
result = func.apply(context, args); | ||
if (!timeout) context = args = null; | ||
}; | ||
return function () { | ||
var now = Date.now(); | ||
if (!previous && options.leading === false) previous = now; | ||
var remaining = wait - (now - previous); | ||
context = this; | ||
args = arguments; | ||
if (remaining <= 0 || remaining > wait) { | ||
if (timeout) { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
result = func.apply(context, args); | ||
if (!timeout) | ||
context = args = null; | ||
}; | ||
return function () { | ||
var now = Date.now(); | ||
if (!previous && options.leading === false) | ||
previous = now; | ||
var remaining = wait - (now - previous); | ||
context = this; | ||
args = arguments; | ||
if (remaining <= 0 || remaining > wait) { | ||
if (timeout) { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
} | ||
previous = now; | ||
result = func.apply(context, args); | ||
if (!timeout) | ||
context = args = null; | ||
} | ||
else if (!timeout && options.trailing !== false) { | ||
timeout = setTimeout(later, remaining); | ||
} | ||
return result; | ||
}; | ||
} | ||
previous = now; | ||
result = func.apply(context, args); | ||
if (!timeout) context = args = null; | ||
} else if (!timeout && options.trailing !== false) { | ||
timeout = setTimeout(later, remaining); | ||
} | ||
return result; | ||
}; | ||
} | ||
exports.throttle = throttle; | ||
//# sourceMappingURL=throttle.function.js.map | ||
//# sourceMappingURL=throttle.function.js.map |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.toError = void 0; | ||
@@ -17,7 +17,6 @@ /** | ||
function toError(err) { | ||
if (err instanceof Error) | ||
return err; | ||
return new Error(String(err)); | ||
if (err instanceof Error) return err; | ||
return new Error(String(err)); | ||
} | ||
exports.toError = toError; | ||
//# sourceMappingURL=to-error.js.map | ||
//# sourceMappingURL=to-error.js.map |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.uuid = exports.uuidv4 = void 0; | ||
@@ -8,6 +8,7 @@ /** | ||
function uuidv4() { | ||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | ||
var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8; | ||
return v.toString(16); | ||
}); | ||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | ||
var r = (Math.random() * 16) | 0, | ||
v = c == 'x' ? r : (r & 0x3) | 0x8; | ||
return v.toString(16); | ||
}); | ||
} | ||
@@ -19,5 +20,5 @@ exports.uuidv4 = uuidv4; | ||
function uuid() { | ||
return uuidv4().replace(/-/g, ''); | ||
return uuidv4().replace(/-/g, ''); | ||
} | ||
exports.uuid = uuid; | ||
//# sourceMappingURL=uuid.js.map | ||
//# sourceMappingURL=uuid.js.map |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.DEFAULT_API_VERSION = void 0; | ||
exports.DEFAULT_API_VERSION = 'v3'; | ||
//# sourceMappingURL=api-version.js.map | ||
//# sourceMappingURL=api-version.js.map |
@@ -1,3 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=element.js.map | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
//# sourceMappingURL=element.js.map |
@@ -1,129 +0,233 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
'use strict'; | ||
var __awaiter = | ||
(this && this.__awaiter) || | ||
function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { | ||
return value instanceof P | ||
? value | ||
: new P(function (resolve) { | ||
resolve(value); | ||
}); | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function rejected(value) { | ||
try { | ||
step(generator['throw'](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
}; | ||
var __generator = | ||
(this && this.__generator) || | ||
function (thisArg, body) { | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [], | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
return ( | ||
(g = { next: verb(0), throw: verb(1), return: verb(2) }), | ||
typeof Symbol === 'function' && | ||
(g[Symbol.iterator] = function () { | ||
return this; | ||
}), | ||
g | ||
); | ||
function verb(n) { | ||
return function (v) { | ||
return step([n, v]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
if (f) throw new TypeError('Generator is already executing.'); | ||
while ((g && ((g = 0), op[0] && (_ = 0)), _)) | ||
try { | ||
if ( | ||
((f = 1), | ||
y && | ||
(t = | ||
op[0] & 2 | ||
? y['return'] | ||
: op[0] | ||
? y['throw'] || ((t = y['return']) && t.call(y), 0) | ||
: y.next) && | ||
!(t = t.call(y, op[1])).done) | ||
) | ||
return t; | ||
if (((y = 0), t)) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { value: op[1], done: false }; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [0]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if ( | ||
!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && | ||
(op[0] === 6 || op[0] === 2) | ||
) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [6, e]; | ||
y = 0; | ||
} finally { | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var url_1 = require("./url"); | ||
var url_2 = require("url"); | ||
}; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var url_1 = require('./url'); | ||
var url_2 = require('url'); | ||
describe('.parse', function () { | ||
test('can parse a full url', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
expect((0, url_1.parse)('http://example.com/foo/bar?q=1')).toEqual({ | ||
auth: null, | ||
hash: null, | ||
host: 'example.com', | ||
hostname: 'example.com', | ||
href: 'http://example.com/foo/bar?q=1', | ||
path: '/foo/bar?q=1', | ||
pathname: '/foo/bar', | ||
port: null, | ||
protocol: 'http:', | ||
query: 'q=1', | ||
search: '?q=1', | ||
slashes: true, | ||
}); | ||
return [2 /*return*/]; | ||
test('can parse a full url', function () { | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
expect((0, url_1.parse)('http://example.com/foo/bar?q=1')).toEqual({ | ||
auth: null, | ||
hash: null, | ||
host: 'example.com', | ||
hostname: 'example.com', | ||
href: 'http://example.com/foo/bar?q=1', | ||
path: '/foo/bar?q=1', | ||
pathname: '/foo/bar', | ||
port: null, | ||
protocol: 'http:', | ||
query: 'q=1', | ||
search: '?q=1', | ||
slashes: true, | ||
}); | ||
}); }); | ||
test('can parse a path', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
expect((0, url_1.parse)('/foo/bar?q=1')).toEqual({ | ||
auth: null, | ||
hash: null, | ||
host: null, | ||
hostname: null, | ||
href: '/foo/bar?q=1', | ||
path: '/foo/bar?q=1', | ||
pathname: '/foo/bar', | ||
port: null, | ||
protocol: null, | ||
query: 'q=1', | ||
search: '?q=1', | ||
slashes: null, | ||
}); | ||
return [2 /*return*/]; | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
}); | ||
test('can parse a path', function () { | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
expect((0, url_1.parse)('/foo/bar?q=1')).toEqual({ | ||
auth: null, | ||
hash: null, | ||
host: null, | ||
hostname: null, | ||
href: '/foo/bar?q=1', | ||
path: '/foo/bar?q=1', | ||
pathname: '/foo/bar', | ||
port: null, | ||
protocol: null, | ||
query: 'q=1', | ||
search: '?q=1', | ||
slashes: null, | ||
}); | ||
}); }); | ||
test('can parse a url that is missing slashes', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
expect((0, url_1.parse)('http:example.com/foo/bar?q=1')).toEqual({ | ||
auth: null, | ||
hash: null, | ||
host: 'example.com', | ||
hostname: 'example.com', | ||
href: 'http://example.com/foo/bar?q=1', | ||
path: '/foo/bar?q=1', | ||
pathname: '/foo/bar', | ||
port: null, | ||
protocol: 'http:', | ||
query: 'q=1', | ||
search: '?q=1', | ||
slashes: false, | ||
}); | ||
return [2 /*return*/]; | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
}); | ||
test('can parse a url that is missing slashes', function () { | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
expect((0, url_1.parse)('http:example.com/foo/bar?q=1')).toEqual({ | ||
auth: null, | ||
hash: null, | ||
host: 'example.com', | ||
hostname: 'example.com', | ||
href: 'http://example.com/foo/bar?q=1', | ||
path: '/foo/bar?q=1', | ||
pathname: '/foo/bar', | ||
port: null, | ||
protocol: 'http:', | ||
query: 'q=1', | ||
search: '?q=1', | ||
slashes: false, | ||
}); | ||
}); }); | ||
describe('behaves the same as the old query function', function () { | ||
describe.each([{ url: '/foo/bar?a=1&b=2' }, { url: 'http://example.com/foo/bar?a=1&b=2' }])('with url `$url`', function (_a) { | ||
var url = _a.url; | ||
var expected = Object.assign({}, (0, url_2.parse)(url)); | ||
var actual = (0, url_1.parse)(url); | ||
test.each([ | ||
{ prop: 'query' }, | ||
{ prop: 'port' }, | ||
{ prop: 'auth' }, | ||
{ prop: 'hash' }, | ||
{ prop: 'host' }, | ||
{ prop: 'hostname' }, | ||
{ prop: 'href' }, | ||
{ prop: 'path' }, | ||
{ prop: 'pathname' }, | ||
{ prop: 'protocol' }, | ||
{ prop: 'search' }, | ||
{ prop: 'slashes' }, | ||
])('`$prop` is the same', function (_a) { | ||
var prop = _a.prop; | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_b) { | ||
expect(actual[prop]).toEqual(expected[prop]); | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
}); | ||
describe('behaves the same as the old query function', function () { | ||
describe.each([{ url: '/foo/bar?a=1&b=2' }, { url: 'http://example.com/foo/bar?a=1&b=2' }])( | ||
'with url `$url`', | ||
function (_a) { | ||
var url = _a.url; | ||
var expected = Object.assign({}, (0, url_2.parse)(url)); | ||
var actual = (0, url_1.parse)(url); | ||
test.each([ | ||
{ prop: 'query' }, | ||
{ prop: 'port' }, | ||
{ prop: 'auth' }, | ||
{ prop: 'hash' }, | ||
{ prop: 'host' }, | ||
{ prop: 'hostname' }, | ||
{ prop: 'href' }, | ||
{ prop: 'path' }, | ||
{ prop: 'pathname' }, | ||
{ prop: 'protocol' }, | ||
{ prop: 'search' }, | ||
{ prop: 'slashes' }, | ||
])('`$prop` is the same', function (_a) { | ||
var prop = _a.prop; | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_b) { | ||
expect(actual[prop]).toEqual(expected[prop]); | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
); | ||
}); | ||
}); | ||
//# sourceMappingURL=url.test.js.map | ||
//# sourceMappingURL=url.test.js.map |
{ | ||
"name": "@builder.io/sdk", | ||
"version": "3.0.1", | ||
"version": "3.0.2-0", | ||
"unpkg": "./dist/index.browser.js", | ||
@@ -75,3 +75,4 @@ "main": "./dist/index.cjs.js", | ||
"hoistingLimits": "workspaces" | ||
} | ||
} | ||
}, | ||
"stableVersion": "3.0.1" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15785
1651956
104
2