Merge pull request #571 from dkanada/select-server

Fix select server redirect and remove more dependencies
This commit is contained in:
dkanada 2019-11-20 12:08:19 +09:00 committed by GitHub
commit c1b866d9c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 50 additions and 3438 deletions

View File

@ -18,16 +18,21 @@
},
"dependencies": {
"alameda": "^1.3.0",
"document-register-element": "^0.5.4",
"flv.js": "^1.5.0",
"hls.js": "^0.12.4",
"howler": "^2.1.2",
"jquery": "^3.4.1",
"jstree": "^3.3.7",
"libjass": "^0.11.0",
"native-promise-only": "^0.8.0-a",
"requirejs": "^2.3.5",
"resize-observer-polyfill": "^1.5.1",
"shaka-player": "^2.5.5",
"sortablejs": "^1.9.0",
"swiper": "^3.4.2"
"swiper": "^3.4.2",
"webcomponents.js-2": "^0.7.24",
"whatwg-fetch": "^1.1.1"
},
"scripts": {
"serve": "webpack-dev-server --config webpack.dev.js --open",

View File

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>testing my-element</title>
<script src="build/document-register-element.js"></script>
<script src="test/my-element.js"></script>
</head>
<body>
<my-element>
some content
</my-element>
</body>

View File

@ -1,246 +0,0 @@
/*! (C) WebReflection Mit Style License */
(function(e, t, n, r) {
"use strict";
function rt(e, t) {
for (var n = 0, r = e.length; n < r; n++) vt(e[n], t)
}
function it(e) {
for (var t = 0, n = e.length, r; t < n; t++) r = e[t], nt(r, b[ot(r)])
}
function st(e) {
return function(t) {
j(t) && (vt(t, e), rt(t.querySelectorAll(w), e))
}
}
function ot(e) {
var t = e.getAttribute("is"),
n = e.nodeName.toUpperCase(),
r = S.call(y, t ? v + t.toUpperCase() : d + n);
return t && -1 < r && !ut(n, t) ? -1 : r
}
function ut(e, t) {
return -1 < w.indexOf(e + '[is="' + t + '"]')
}
function at(e) {
var t = e.currentTarget,
n = e.attrChange,
r = e.attrName,
i = e.target;
Q && (!i || i === t) && t.attributeChangedCallback && r !== "style" && e.prevValue !== e.newValue && t.attributeChangedCallback(r, n === e[a] ? null : e.prevValue, n === e[l] ? null : e.newValue)
}
function ft(e) {
var t = st(e);
return function(e) {
X.push(t, e.target)
}
}
function lt(e) {
K && (K = !1, e.currentTarget.removeEventListener(h, lt)), rt((e.target || t).querySelectorAll(w), e.detail === o ? o : s), B && pt()
}
function ct(e, t) {
var n = this;
q.call(n, e, t), G.call(n, {
target: n
})
}
function ht(e, t) {
D(e, t), et ? et.observe(e, z) : (J && (e.setAttribute = ct, e[i] = Z(e), e.addEventListener(p, G)), e.addEventListener(c, at)), e.createdCallback && Q && (e.created = !0, e.createdCallback(), e.created = !1)
}
function pt() {
for (var e, t = 0, n = F.length; t < n; t++) e = F[t], E.contains(e) || (n--, F.splice(t--, 1), vt(e, o))
}
function dt(e) {
throw new Error("A " + e + " type is already registered")
}
function vt(e, t) {
var n, r = ot(e); - 1 < r && (tt(e, b[r]), r = 0, t === s && !e[s] ? (e[o] = !1, e[s] = !0, r = 1, B && S.call(F, e) < 0 && F.push(e)) : t === o && !e[o] && (e[s] = !1, e[o] = !0, r = 1), r && (n = e[t + "Callback"]) && n.call(e))
}
if (r in t) return;
var i = "__" + r + (Math.random() * 1e5 >> 0),
s = "attached",
o = "detached",
u = "extends",
a = "ADDITION",
f = "MODIFICATION",
l = "REMOVAL",
c = "DOMAttrModified",
h = "DOMContentLoaded",
p = "DOMSubtreeModified",
d = "<",
v = "=",
m = /^[A-Z][A-Z0-9]*(?:-[A-Z0-9]+)+$/,
g = ["ANNOTATION-XML", "COLOR-PROFILE", "FONT-FACE", "FONT-FACE-SRC", "FONT-FACE-URI", "FONT-FACE-FORMAT", "FONT-FACE-NAME", "MISSING-GLYPH"],
y = [],
b = [],
w = "",
E = t.documentElement,
S = y.indexOf || function(e) {
for (var t = this.length; t-- && this[t] !== e;);
return t
},
x = n.prototype,
T = x.hasOwnProperty,
N = x.isPrototypeOf,
C = n.defineProperty,
k = n.getOwnPropertyDescriptor,
L = n.getOwnPropertyNames,
A = n.getPrototypeOf,
O = n.setPrototypeOf,
M = !!n.__proto__,
_ = n.create || function mt(e) {
return e ? (mt.prototype = e, new mt) : this
},
D = O || (M ? function(e, t) {
return e.__proto__ = t, e
} : L && k ? function() {
function e(e, t) {
for (var n, r = L(t), i = 0, s = r.length; i < s; i++) n = r[i], T.call(e, n) || C(e, n, k(t, n))
}
return function(t, n) {
do e(t, n); while ((n = A(n)) && !N.call(n, t));
return t
}
}() : function(e, t) {
for (var n in t) e[n] = t[n];
return e
}),
P = e.MutationObserver || e.WebKitMutationObserver,
H = (e.HTMLElement || e.Element || e.Node).prototype,
B = !N.call(H, E),
j = B ? function(e) {
return e.nodeType === 1
} : function(e) {
return N.call(H, e)
},
F = B && [],
I = H.cloneNode,
q = H.setAttribute,
R = H.removeAttribute,
U = t.createElement,
z = P && {
attributes: !0,
characterData: !0,
attributeOldValue: !0
},
W = P || function(e) {
J = !1, E.removeEventListener(c, W)
},
X, V = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.msRequestAnimationFrame || function(e) {
setTimeout(e, 10)
},
$ = !1,
J = !0,
K = !0,
Q = !0,
G, Y, Z, et, tt, nt;
O || M ? (tt = function(e, t) {
N.call(t, e) || ht(e, t)
}, nt = ht) : (tt = function(e, t) {
e[i] || (e[i] = n(!0), ht(e, t))
}, nt = tt), B ? (J = !1, function() {
var e = k(H, "addEventListener"),
t = e.value,
n = function(e) {
var t = new CustomEvent(c, {
bubbles: !0
});
t.attrName = e, t.prevValue = this.getAttribute(e), t.newValue = null, t[l] = t.attrChange = 2, R.call(this, e), this.dispatchEvent(t)
},
r = function(e, t) {
var n = this.hasAttribute(e),
r = n && this.getAttribute(e),
i = new CustomEvent(c, {
bubbles: !0
});
q.call(this, e, t), i.attrName = e, i.prevValue = n ? r : null, i.newValue = t, n ? i[f] = i.attrChange = 1 : i[a] = i.attrChange = 0, this.dispatchEvent(i)
},
s = function(e) {
var t = e.currentTarget,
n = t[i],
r = e.propertyName,
s;
n.hasOwnProperty(r) && (n = n[r], s = new CustomEvent(c, {
bubbles: !0
}), s.attrName = n.name, s.prevValue = n.value || null, s.newValue = n.value = t[r] || null, s.prevValue == null ? s[a] = s.attrChange = 0 : s[f] = s.attrChange = 1, t.dispatchEvent(s))
};
e.value = function(e, o, u) {
e === c && this.attributeChangedCallback && this.setAttribute !== r && (this[i] = {
className: {
name: "class",
value: this.className
}
}, this.setAttribute = r, this.removeAttribute = n, t.call(this, "propertychange", s)), t.call(this, e, o, u)
}, C(H, "addEventListener", e)
}()) : P || (E.addEventListener(c, W), E.setAttribute(i, 1), E.removeAttribute(i), J && (G = function(e) {
var t = this,
n, r, s;
if (t === e.target) {
n = t[i], t[i] = r = Z(t);
for (s in r) {
if (!(s in n)) return Y(0, t, s, n[s], r[s], a);
if (r[s] !== n[s]) return Y(1, t, s, n[s], r[s], f)
}
for (s in n)
if (!(s in r)) return Y(2, t, s, n[s], r[s], l)
}
}, Y = function(e, t, n, r, i, s) {
var o = {
attrChange: e,
currentTarget: t,
attrName: n,
prevValue: r,
newValue: i
};
o[s] = e, at(o)
}, Z = function(e) {
for (var t, n, r = {}, i = e.attributes, s = 0, o = i.length; s < o; s++) t = i[s], n = t.name, n !== "setAttribute" && (r[n] = t.value);
return r
})), t[r] = function(n, r) {
c = n.toUpperCase(), $ || ($ = !0, P ? (et = function(e, t) {
function n(e, t) {
for (var n = 0, r = e.length; n < r; t(e[n++]));
}
return new P(function(r) {
for (var i, s, o, u = 0, a = r.length; u < a; u++) i = r[u], i.type === "childList" ? (n(i.addedNodes, e), n(i.removedNodes, t)) : (s = i.target, Q && s.attributeChangedCallback && i.attributeName !== "style" && (o = s.getAttribute(i.attributeName), o !== i.oldValue && s.attributeChangedCallback(i.attributeName, i.oldValue, o)))
})
}(st(s), st(o)), et.observe(t, {
childList: !0,
subtree: !0
})) : (X = [], V(function E() {
while (X.length) X.shift().call(null, X.shift());
V(E)
}), t.addEventListener("DOMNodeInserted", ft(s)), t.addEventListener("DOMNodeRemoved", ft(o))), t.addEventListener(h, lt), t.addEventListener("readystatechange", lt), t.createElement = function(e, n) {
var r = U.apply(t, arguments),
i = "" + e,
s = S.call(y, (n ? v : d) + (n || i).toUpperCase()),
o = -1 < s;
return n && (r.setAttribute("is", n = n.toLowerCase()), o && (o = ut(i.toUpperCase(), n))), Q = !t.createElement.innerHTMLHelper, o && nt(r, b[s]), r
}, H.cloneNode = function(e) {
var t = I.call(this, !!e),
n = ot(t);
return -1 < n && nt(t, b[n]), e && it(t.querySelectorAll(w)), t
}), -2 < S.call(y, v + c) + S.call(y, d + c) && dt(n);
if (!m.test(c) || -1 < S.call(g, c)) throw new Error("The type " + n + " is invalid");
var i = function() {
return f ? t.createElement(l, c) : t.createElement(l)
},
a = r || x,
f = T.call(a, u),
l = f ? r[u].toUpperCase() : c,
c, p;
return f && -1 < S.call(y, d + l) && dt(l), p = y.push((f ? v : d) + c) - 1, w = w.concat(w.length ? "," : "", f ? l + '[is="' + n.toLowerCase() + '"]' : l), i.prototype = b[p] = T.call(a, "prototype") ? a.prototype : _(H), rt(t.querySelectorAll(w), s), i
}
})(window, document, Object, "registerElement");

View File

@ -1,263 +0,0 @@
! function(self) {
"use strict";
function normalizeName(name) {
if ("string" != typeof name && (name = String(name)), /[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) throw new TypeError("Invalid character in header field name");
return name.toLowerCase()
}
function normalizeValue(value) {
return "string" != typeof value && (value = String(value)), value
}
function iteratorFor(items) {
var iterator = {
next: function() {
var value = items.shift();
return {
done: void 0 === value,
value: value
}
}
};
return support.iterable && (iterator[Symbol.iterator] = function() {
return iterator
}), iterator
}
function Headers(headers) {
this.map = {}, headers instanceof Headers ? headers.forEach(function(value, name) {
this.append(name, value)
}, this) : headers && Object.getOwnPropertyNames(headers).forEach(function(name) {
this.append(name, headers[name])
}, this)
}
function consumed(body) {
if (body.bodyUsed) return Promise.reject(new TypeError("Already read"));
body.bodyUsed = !0
}
function fileReaderReady(reader) {
return new Promise(function(resolve, reject) {
reader.onload = function() {
resolve(reader.result)
}, reader.onerror = function() {
reject(reader.error)
}
})
}
function readBlobAsArrayBuffer(blob) {
var reader = new FileReader,
promise = fileReaderReady(reader);
return reader.readAsArrayBuffer(blob), promise
}
function readBlobAsText(blob) {
var reader = new FileReader,
promise = fileReaderReady(reader);
return reader.readAsText(blob), promise
}
function readArrayBufferAsText(buf) {
for (var view = new Uint8Array(buf), chars = new Array(view.length), i = 0; i < view.length; i++) chars[i] = String.fromCharCode(view[i]);
return chars.join("")
}
function bufferClone(buf) {
if (buf.slice) return buf.slice(0);
var view = new Uint8Array(buf.byteLength);
return view.set(new Uint8Array(buf)), view.buffer
}
function Body() {
return this.bodyUsed = !1, this._initBody = function(body) {
if (this._bodyInit = body, body)
if ("string" == typeof body) this._bodyText = body;
else if (support.blob && Blob.prototype.isPrototypeOf(body)) this._bodyBlob = body;
else if (support.formData && FormData.prototype.isPrototypeOf(body)) this._bodyFormData = body;
else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) this._bodyText = body.toString();
else if (support.arrayBuffer && support.blob && isDataView(body)) this._bodyArrayBuffer = bufferClone(body.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer]);
else {
if (!support.arrayBuffer || !ArrayBuffer.prototype.isPrototypeOf(body) && !isArrayBufferView(body)) throw new Error("unsupported BodyInit type");
this._bodyArrayBuffer = bufferClone(body)
} else this._bodyText = "";
this.headers.get("content-type") || ("string" == typeof body ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : support.searchParams && URLSearchParams.prototype.isPrototypeOf(body) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"))
}, support.blob && (this.blob = function() {
var rejected = consumed(this);
if (rejected) return rejected;
if (this._bodyBlob) return Promise.resolve(this._bodyBlob);
if (this._bodyArrayBuffer) return Promise.resolve(new Blob([this._bodyArrayBuffer]));
if (this._bodyFormData) throw new Error("could not read FormData body as blob");
return Promise.resolve(new Blob([this._bodyText]))
}, this.arrayBuffer = function() {
return this._bodyArrayBuffer ? consumed(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(readBlobAsArrayBuffer)
}), this.text = function() {
var rejected = consumed(this);
if (rejected) return rejected;
if (this._bodyBlob) return readBlobAsText(this._bodyBlob);
if (this._bodyArrayBuffer) return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
if (this._bodyFormData) throw new Error("could not read FormData body as text");
return Promise.resolve(this._bodyText)
}, support.formData && (this.formData = function() {
return this.text().then(decode)
}), this.json = function() {
return this.text().then(JSON.parse)
}, this
}
function normalizeMethod(method) {
var upcased = method.toUpperCase();
return methods.indexOf(upcased) > -1 ? upcased : method
}
function Request(input, options) {
options = options || {};
var body = options.body;
if ("string" == typeof input) this.url = input;
else {
if (input.bodyUsed) throw new TypeError("Already read");
this.url = input.url, this.credentials = input.credentials, options.headers || (this.headers = new Headers(input.headers)), this.method = input.method, this.mode = input.mode, body || null == input._bodyInit || (body = input._bodyInit, input.bodyUsed = !0)
}
if (this.credentials = options.credentials || this.credentials || "omit", !options.headers && this.headers || (this.headers = new Headers(options.headers)), this.method = normalizeMethod(options.method || this.method || "GET"), this.mode = options.mode || this.mode || null, this.referrer = null, ("GET" === this.method || "HEAD" === this.method) && body) throw new TypeError("Body not allowed for GET or HEAD requests");
this._initBody(body)
}
function decode(body) {
var form = new FormData;
return body.trim().split("&").forEach(function(bytes) {
if (bytes) {
var split = bytes.split("="),
name = split.shift().replace(/\+/g, " "),
value = split.join("=").replace(/\+/g, " ");
form.append(decodeURIComponent(name), decodeURIComponent(value))
}
}), form
}
function parseHeaders(rawHeaders) {
var headers = new Headers;
return rawHeaders.split("\r\n").forEach(function(line) {
var parts = line.split(":"),
key = parts.shift().trim();
if (key) {
var value = parts.join(":").trim();
headers.append(key, value)
}
}), headers
}
function Response(bodyInit, options) {
options || (options = {}), this.type = "default", this.status = "status" in options ? options.status : 200, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in options ? options.statusText : "OK", this.headers = new Headers(options.headers), this.url = options.url || "", this._initBody(bodyInit)
}
if (!self.fetch) {
var support = {
searchParams: "URLSearchParams" in self,
iterable: "Symbol" in self && "iterator" in Symbol,
blob: "FileReader" in self && "Blob" in self && function() {
try {
return new Blob, !0
} catch (e) {
return !1
}
}(),
formData: "FormData" in self,
arrayBuffer: "ArrayBuffer" in self
};
if (support.arrayBuffer) var viewClasses = ["[object Int8Array]", "[object Uint8Array]", "[object Uint8ClampedArray]", "[object Int16Array]", "[object Uint16Array]", "[object Int32Array]", "[object Uint32Array]", "[object Float32Array]", "[object Float64Array]"],
isDataView = function(obj) {
return obj && DataView.prototype.isPrototypeOf(obj)
},
isArrayBufferView = ArrayBuffer.isView || function(obj) {
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
};
Headers.prototype.append = function(name, value) {
name = normalizeName(name), value = normalizeValue(value);
var list = this.map[name];
list || (list = [], this.map[name] = list), list.push(value)
}, Headers.prototype.delete = function(name) {
delete this.map[normalizeName(name)]
}, Headers.prototype.get = function(name) {
var values = this.map[normalizeName(name)];
return values ? values[0] : null
}, Headers.prototype.getAll = function(name) {
return this.map[normalizeName(name)] || []
}, Headers.prototype.has = function(name) {
return this.map.hasOwnProperty(normalizeName(name))
}, Headers.prototype.set = function(name, value) {
this.map[normalizeName(name)] = [normalizeValue(value)]
}, Headers.prototype.forEach = function(callback, thisArg) {
Object.getOwnPropertyNames(this.map).forEach(function(name) {
this.map[name].forEach(function(value) {
callback.call(thisArg, value, name, this)
}, this)
}, this)
}, Headers.prototype.keys = function() {
var items = [];
return this.forEach(function(value, name) {
items.push(name)
}), iteratorFor(items)
}, Headers.prototype.values = function() {
var items = [];
return this.forEach(function(value) {
items.push(value)
}), iteratorFor(items)
}, Headers.prototype.entries = function() {
var items = [];
return this.forEach(function(value, name) {
items.push([name, value])
}), iteratorFor(items)
}, support.iterable && (Headers.prototype[Symbol.iterator] = Headers.prototype.entries);
var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
Request.prototype.clone = function() {
return new Request(this, {
body: this._bodyInit
})
}, Body.call(Request.prototype), Body.call(Response.prototype), Response.prototype.clone = function() {
return new Response(this._bodyInit, {
status: this.status,
statusText: this.statusText,
headers: new Headers(this.headers),
url: this.url
})
}, Response.error = function() {
var response = new Response(null, {
status: 0,
statusText: ""
});
return response.type = "error", response
};
var redirectStatuses = [301, 302, 303, 307, 308];
Response.redirect = function(url, status) {
if (-1 === redirectStatuses.indexOf(status)) throw new RangeError("Invalid status code");
return new Response(null, {
status: status,
headers: {
location: url
}
})
}, self.Headers = Headers, self.Request = Request, self.Response = Response, self.fetch = function(input, init) {
return new Promise(function(resolve, reject) {
var request = new Request(input, init),
xhr = new XMLHttpRequest;
xhr.onload = function() {
var options = {
status: xhr.status,
statusText: xhr.statusText,
headers: parseHeaders(xhr.getAllResponseHeaders() || "")
};
options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
var body = "response" in xhr ? xhr.response : xhr.responseText;
resolve(new Response(body, options))
}, xhr.onerror = function() {
reject(new TypeError("Network request failed"))
}, xhr.ontimeout = function() {
reject(new TypeError("Network request failed"))
}, xhr.open(request.method, request.url, !0), "include" === request.credentials && (xhr.withCredentials = !0), "responseType" in xhr && support.blob && (xhr.responseType = "blob"), request.headers.forEach(function(value, name) {
xhr.setRequestHeader(name, value)
}), xhr.send(void 0 === request._bodyInit ? null : request._bodyInit)
})
}, self.fetch.polyfill = !0
}
}("undefined" != typeof self ? self : this);

View File

@ -1,373 +0,0 @@
/*! Native Promise Only
v0.8.0-a (c) Kyle Simpson
MIT License: http://getify.mit-license.org
*/
(function UMD(name,context,definition){
// special form of UMD for polyfilling across evironments
context[name] = definition();
if (typeof module != "undefined" && module.exports) { module.exports = context[name]; }
else if (typeof define == "function" && define.amd) { define(function $AMD$(){ return context[name]; }); }
})("Promise",typeof global != "undefined" ? global : this,function DEF(){
/*jshint validthis:true */
"use strict";
var builtInProp, cycle, scheduling_queue,
ToString = Object.prototype.toString,
timer = (typeof setImmediate != "undefined") ?
function timer(fn) { return setImmediate(fn); } :
setTimeout
;
// dammit, IE8.
try {
Object.defineProperty({},"x",{});
builtInProp = function builtInProp(obj,name,val,config) {
return Object.defineProperty(obj,name,{
value: val,
writable: true,
configurable: config !== false
});
};
}
catch (err) {
builtInProp = function builtInProp(obj,name,val) {
obj[name] = val;
return obj;
};
}
// Note: using a queue instead of array for efficiency
scheduling_queue = (function Queue() {
var first, last, item;
function Item(fn,self) {
this.fn = fn;
this.self = self;
this.next = void 0;
}
return {
add: function add(fn,self) {
item = new Item(fn,self);
if (last) {
last.next = item;
}
else {
first = item;
}
last = item;
item = void 0;
},
drain: function drain() {
var f = first;
first = last = cycle = void 0;
while (f) {
f.fn.call(f.self);
f = f.next;
}
}
};
})();
function schedule(fn,self) {
scheduling_queue.add(fn,self);
if (!cycle) {
cycle = timer(scheduling_queue.drain);
}
}
// promise duck typing
function isThenable(o) {
var _then, o_type = typeof o;
if (o != null &&
(
o_type == "object" || o_type == "function"
)
) {
_then = o.then;
}
return typeof _then == "function" ? _then : false;
}
function notify() {
for (var i=0; i<this.chain.length; i++) {
notifyIsolated(
this,
(this.state === 1) ? this.chain[i].success : this.chain[i].failure,
this.chain[i]
);
}
this.chain.length = 0;
}
// NOTE: This is a separate function to isolate
// the `try..catch` so that other code can be
// optimized better
function notifyIsolated(self,cb,chain) {
var ret, _then;
try {
if (cb === false) {
chain.reject(self.msg);
}
else {
if (cb === true) {
ret = self.msg;
}
else {
ret = cb.call(void 0,self.msg);
}
if (ret === chain.promise) {
chain.reject(TypeError("Promise-chain cycle"));
}
else if (_then = isThenable(ret)) {
_then.call(ret,chain.resolve,chain.reject);
}
else {
chain.resolve(ret);
}
}
}
catch (err) {
chain.reject(err);
}
}
function resolve(msg) {
var _then, self = this;
// already triggered?
if (self.triggered) { return; }
self.triggered = true;
// unwrap
if (self.def) {
self = self.def;
}
try {
if (_then = isThenable(msg)) {
schedule(function(){
var def_wrapper = new MakeDefWrapper(self);
try {
_then.call(msg,
function $resolve$(){ resolve.apply(def_wrapper,arguments); },
function $reject$(){ reject.apply(def_wrapper,arguments); }
);
}
catch (err) {
reject.call(def_wrapper,err);
}
})
}
else {
self.msg = msg;
self.state = 1;
if (self.chain.length > 0) {
schedule(notify,self);
}
}
}
catch (err) {
reject.call(new MakeDefWrapper(self),err);
}
}
function reject(msg) {
var self = this;
// already triggered?
if (self.triggered) { return; }
self.triggered = true;
// unwrap
if (self.def) {
self = self.def;
}
self.msg = msg;
self.state = 2;
if (self.chain.length > 0) {
schedule(notify,self);
}
}
function iteratePromises(Constructor,arr,resolver,rejecter) {
for (var idx=0; idx<arr.length; idx++) {
(function IIFE(idx){
Constructor.resolve(arr[idx])
.then(
function $resolver$(msg){
resolver(idx,msg);
},
rejecter
);
})(idx);
}
}
function MakeDefWrapper(self) {
this.def = self;
this.triggered = false;
}
function MakeDef(self) {
this.promise = self;
this.state = 0;
this.triggered = false;
this.chain = [];
this.msg = void 0;
}
function Promise(executor) {
if (typeof executor != "function") {
throw TypeError("Not a function");
}
if (this.__NPO__ !== 0) {
throw TypeError("Not a promise");
}
// instance shadowing the inherited "brand"
// to signal an already "initialized" promise
this.__NPO__ = 1;
var def = new MakeDef(this);
this["then"] = function then(success,failure) {
var o = {
success: typeof success == "function" ? success : true,
failure: typeof failure == "function" ? failure : false
};
// Note: `then(..)` itself can be borrowed to be used against
// a different promise constructor for making the chained promise,
// by substituting a different `this` binding.
o.promise = new this.constructor(function extractChain(resolve,reject) {
if (typeof resolve != "function" || typeof reject != "function") {
throw TypeError("Not a function");
}
o.resolve = resolve;
o.reject = reject;
});
def.chain.push(o);
if (def.state !== 0) {
schedule(notify,def);
}
return o.promise;
};
this["catch"] = function $catch$(failure) {
return this.then(void 0,failure);
};
try {
executor.call(
void 0,
function publicResolve(msg){
resolve.call(def,msg);
},
function publicReject(msg) {
reject.call(def,msg);
}
);
}
catch (err) {
reject.call(def,err);
}
}
var PromisePrototype = builtInProp({},"constructor",Promise,
/*configurable=*/false
);
// Note: Android 4 cannot use `Object.defineProperty(..)` here
Promise.prototype = PromisePrototype;
// built-in "brand" to signal an "uninitialized" promise
builtInProp(PromisePrototype,"__NPO__",0,
/*configurable=*/false
);
builtInProp(Promise,"resolve",function Promise$resolve(msg) {
var Constructor = this;
// spec mandated checks
// note: best "isPromise" check that's practical for now
if (msg && typeof msg == "object" && msg.__NPO__ === 1) {
return msg;
}
return new Constructor(function executor(resolve,reject){
if (typeof resolve != "function" || typeof reject != "function") {
throw TypeError("Not a function");
}
resolve(msg);
});
});
builtInProp(Promise,"reject",function Promise$reject(msg) {
return new this(function executor(resolve,reject){
if (typeof resolve != "function" || typeof reject != "function") {
throw TypeError("Not a function");
}
reject(msg);
});
});
builtInProp(Promise,"all",function Promise$all(arr) {
var Constructor = this;
// spec mandated checks
if (ToString.call(arr) != "[object Array]") {
return Constructor.reject(TypeError("Not an array"));
}
if (arr.length === 0) {
return Constructor.resolve([]);
}
return new Constructor(function executor(resolve,reject){
if (typeof resolve != "function" || typeof reject != "function") {
throw TypeError("Not a function");
}
var len = arr.length, msgs = Array(len), count = 0;
iteratePromises(Constructor,arr,function resolver(idx,msg) {
msgs[idx] = msg;
if (++count === len) {
resolve(msgs);
}
},reject);
});
});
builtInProp(Promise,"race",function Promise$race(arr) {
var Constructor = this;
// spec mandated checks
if (ToString.call(arr) != "[object Array]") {
return Constructor.reject(TypeError("Not an array"));
}
return new Constructor(function executor(resolve,reject){
if (typeof resolve != "function" || typeof reject != "function") {
throw TypeError("Not a function");
}
iteratePromises(Constructor,arr,function resolver(idx,msg){
resolve(msg);
},reject);
});
});
return Promise;
});

View File

@ -1,21 +0,0 @@
// Adapter for "promises-aplus-tests" test runner
var path = require("path");
var Promise = require(path.join(__dirname,"lib","npo.src.js"));
module.exports.deferred = function __deferred__() {
var o = {};
o.promise = new Promise(function __Promise__(resolve,reject){
o.resolve = resolve;
o.reject = reject;
});
return o;
};
module.exports.resolved = function __resolved__(val) {
return Promise.resolve(val);
};
module.exports.rejected = function __rejected__(reason) {
return Promise.reject(reason);
};

View File

@ -1,939 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.ResizeObserver = factory());
}(this, (function () { 'use strict';
/**
* A collection of shims that provide minimal functionality of the ES6 collections.
*
* These implementations are not meant to be used outside of the ResizeObserver
* modules as they cover only a limited range of use cases.
*/
/* eslint-disable require-jsdoc, valid-jsdoc */
var MapShim = (function () {
if (typeof Map !== 'undefined') {
return Map;
}
/**
* Returns index in provided array that matches the specified key.
*
* @param {Array<Array>} arr
* @param {*} key
* @returns {number}
*/
function getIndex(arr, key) {
var result = -1;
arr.some(function (entry, index) {
if (entry[0] === key) {
result = index;
return true;
}
return false;
});
return result;
}
return (function () {
function anonymous() {
this.__entries__ = [];
}
var prototypeAccessors = { size: { configurable: true } };
/**
* @returns {boolean}
*/
prototypeAccessors.size.get = function () {
return this.__entries__.length;
};
/**
* @param {*} key
* @returns {*}
*/
anonymous.prototype.get = function (key) {
var index = getIndex(this.__entries__, key);
var entry = this.__entries__[index];
return entry && entry[1];
};
/**
* @param {*} key
* @param {*} value
* @returns {void}
*/
anonymous.prototype.set = function (key, value) {
var index = getIndex(this.__entries__, key);
if (~index) {
this.__entries__[index][1] = value;
} else {
this.__entries__.push([key, value]);
}
};
/**
* @param {*} key
* @returns {void}
*/
anonymous.prototype.delete = function (key) {
var entries = this.__entries__;
var index = getIndex(entries, key);
if (~index) {
entries.splice(index, 1);
}
};
/**
* @param {*} key
* @returns {void}
*/
anonymous.prototype.has = function (key) {
return !!~getIndex(this.__entries__, key);
};
/**
* @returns {void}
*/
anonymous.prototype.clear = function () {
this.__entries__.splice(0);
};
/**
* @param {Function} callback
* @param {*} [ctx=null]
* @returns {void}
*/
anonymous.prototype.forEach = function (callback, ctx) {
var this$1 = this;
if ( ctx === void 0 ) ctx = null;
for (var i = 0, list = this$1.__entries__; i < list.length; i += 1) {
var entry = list[i];
callback.call(ctx, entry[1], entry[0]);
}
};
Object.defineProperties( anonymous.prototype, prototypeAccessors );
return anonymous;
}());
})();
/**
* Detects whether window and document objects are available in current environment.
*/
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
// Returns global object of a current environment.
var global$1 = (function () {
if (typeof global !== 'undefined' && global.Math === Math) {
return global;
}
if (typeof self !== 'undefined' && self.Math === Math) {
return self;
}
if (typeof window !== 'undefined' && window.Math === Math) {
return window;
}
// eslint-disable-next-line no-new-func
return Function('return this')();
})();
/**
* A shim for the requestAnimationFrame which falls back to the setTimeout if
* first one is not supported.
*
* @returns {number} Requests' identifier.
*/
var requestAnimationFrame$1 = (function () {
if (typeof requestAnimationFrame === 'function') {
// It's required to use a bounded function because IE sometimes throws
// an "Invalid calling object" error if rAF is invoked without the global
// object on the left hand side.
return requestAnimationFrame.bind(global$1);
}
return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
})();
// Defines minimum timeout before adding a trailing call.
var trailingTimeout = 2;
/**
* Creates a wrapper function which ensures that provided callback will be
* invoked only once during the specified delay period.
*
* @param {Function} callback - Function to be invoked after the delay period.
* @param {number} delay - Delay after which to invoke callback.
* @returns {Function}
*/
var throttle = function (callback, delay) {
var leadingCall = false,
trailingCall = false,
lastCallTime = 0;
/**
* Invokes the original callback function and schedules new invocation if
* the "proxy" was called during current request.
*
* @returns {void}
*/
function resolvePending() {
if (leadingCall) {
leadingCall = false;
callback();
}
if (trailingCall) {
proxy();
}
}
/**
* Callback invoked after the specified delay. It will further postpone
* invocation of the original function delegating it to the
* requestAnimationFrame.
*
* @returns {void}
*/
function timeoutCallback() {
requestAnimationFrame$1(resolvePending);
}
/**
* Schedules invocation of the original function.
*
* @returns {void}
*/
function proxy() {
var timeStamp = Date.now();
if (leadingCall) {
// Reject immediately following calls.
if (timeStamp - lastCallTime < trailingTimeout) {
return;
}
// Schedule new call to be in invoked when the pending one is resolved.
// This is important for "transitions" which never actually start
// immediately so there is a chance that we might miss one if change
// happens amids the pending invocation.
trailingCall = true;
} else {
leadingCall = true;
trailingCall = false;
setTimeout(timeoutCallback, delay);
}
lastCallTime = timeStamp;
}
return proxy;
};
// Minimum delay before invoking the update of observers.
var REFRESH_DELAY = 20;
// A list of substrings of CSS properties used to find transition events that
// might affect dimensions of observed elements.
var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
// Check if MutationObserver is available.
var mutationObserverSupported = typeof MutationObserver !== 'undefined';
/**
* Singleton controller class which handles updates of ResizeObserver instances.
*/
var ResizeObserverController = function() {
this.connected_ = false;
this.mutationEventsAdded_ = false;
this.mutationsObserver_ = null;
this.observers_ = [];
this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
};
/**
* Adds observer to observers list.
*
* @param {ResizeObserverSPI} observer - Observer to be added.
* @returns {void}
*/
/**
* Holds reference to the controller's instance.
*
* @private {ResizeObserverController}
*/
/**
* Keeps reference to the instance of MutationObserver.
*
* @private {MutationObserver}
*/
/**
* Indicates whether DOM listeners have been added.
*
* @private {boolean}
*/
ResizeObserverController.prototype.addObserver = function (observer) {
if (!~this.observers_.indexOf(observer)) {
this.observers_.push(observer);
}
// Add listeners if they haven't been added yet.
if (!this.connected_) {
this.connect_();
}
};
/**
* Removes observer from observers list.
*
* @param {ResizeObserverSPI} observer - Observer to be removed.
* @returns {void}
*/
ResizeObserverController.prototype.removeObserver = function (observer) {
var observers = this.observers_;
var index = observers.indexOf(observer);
// Remove observer if it's present in registry.
if (~index) {
observers.splice(index, 1);
}
// Remove listeners if controller has no connected observers.
if (!observers.length && this.connected_) {
this.disconnect_();
}
};
/**
* Invokes the update of observers. It will continue running updates insofar
* it detects changes.
*
* @returns {void}
*/
ResizeObserverController.prototype.refresh = function () {
var changesDetected = this.updateObservers_();
// Continue running updates if changes have been detected as there might
// be future ones caused by CSS transitions.
if (changesDetected) {
this.refresh();
}
};
/**
* Updates every observer from observers list and notifies them of queued
* entries.
*
* @private
* @returns {boolean} Returns "true" if any observer has detected changes in
* dimensions of it's elements.
*/
ResizeObserverController.prototype.updateObservers_ = function () {
// Collect observers that have active observations.
var activeObservers = this.observers_.filter(function (observer) {
return observer.gatherActive(), observer.hasActive();
});
// Deliver notifications in a separate cycle in order to avoid any
// collisions between observers, e.g. when multiple instances of
// ResizeObserver are tracking the same element and the callback of one
// of them changes content dimensions of the observed target. Sometimes
// this may result in notifications being blocked for the rest of observers.
activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
return activeObservers.length > 0;
};
/**
* Initializes DOM listeners.
*
* @private
* @returns {void}
*/
ResizeObserverController.prototype.connect_ = function () {
// Do nothing if running in a non-browser environment or if listeners
// have been already added.
if (!isBrowser || this.connected_) {
return;
}
// Subscription to the "Transitionend" event is used as a workaround for
// delayed transitions. This way it's possible to capture at least the
// final state of an element.
document.addEventListener('transitionend', this.onTransitionEnd_);
window.addEventListener('resize', this.refresh);
window.addEventListener('orientationchange', this.refresh);
if (mutationObserverSupported) {
this.mutationsObserver_ = new MutationObserver(this.refresh);
this.mutationsObserver_.observe(document, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
} else {
document.addEventListener('DOMSubtreeModified', this.refresh);
this.mutationEventsAdded_ = true;
}
this.connected_ = true;
};
/**
* Removes DOM listeners.
*
* @private
* @returns {void}
*/
ResizeObserverController.prototype.disconnect_ = function () {
// Do nothing if running in a non-browser environment or if listeners
// have been already removed.
if (!isBrowser || !this.connected_) {
return;
}
document.removeEventListener('transitionend', this.onTransitionEnd_);
window.removeEventListener('resize', this.refresh);
window.removeEventListener('orientationchange', this.refresh);
if (this.mutationsObserver_) {
this.mutationsObserver_.disconnect();
}
if (this.mutationEventsAdded_) {
document.removeEventListener('DOMSubtreeModified', this.refresh);
}
this.mutationsObserver_ = null;
this.mutationEventsAdded_ = false;
this.connected_ = false;
};
/**
* "Transitionend" event handler.
*
* @private
* @param {TransitionEvent} event
* @returns {void}
*/
ResizeObserverController.prototype.onTransitionEnd_ = function (ref) {
var propertyName = ref.propertyName; if ( propertyName === void 0 ) propertyName = '';
// Detect whether transition may affect dimensions of an element.
var isReflowProperty = transitionKeys.some(function (key) {
return !!~propertyName.indexOf(key);
});
if (isReflowProperty) {
this.refresh();
}
};
/**
* Returns instance of the ResizeObserverController.
*
* @returns {ResizeObserverController}
*/
ResizeObserverController.getInstance = function () {
if (!this.instance_) {
this.instance_ = new ResizeObserverController();
}
return this.instance_;
};
ResizeObserverController.instance_ = null;
/**
* Defines non-writable/enumerable properties of the provided target object.
*
* @param {Object} target - Object for which to define properties.
* @param {Object} props - Properties to be defined.
* @returns {Object} Target object.
*/
var defineConfigurable = (function (target, props) {
for (var i = 0, list = Object.keys(props); i < list.length; i += 1) {
var key = list[i];
Object.defineProperty(target, key, {
value: props[key],
enumerable: false,
writable: false,
configurable: true
});
}
return target;
});
/**
* Returns the global object associated with provided element.
*
* @param {Object} target
* @returns {Object}
*/
var getWindowOf = (function (target) {
// Assume that the element is an instance of Node, which means that it
// has the "ownerDocument" property from which we can retrieve a
// corresponding global object.
var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
// Return the local global object if it's not possible extract one from
// provided element.
return ownerGlobal || global$1;
});
// Placeholder of an empty content rectangle.
var emptyRect = createRectInit(0, 0, 0, 0);
/**
* Converts provided string to a number.
*
* @param {number|string} value
* @returns {number}
*/
function toFloat(value) {
return parseFloat(value) || 0;
}
/**
* Extracts borders size from provided styles.
*
* @param {CSSStyleDeclaration} styles
* @param {...string} positions - Borders positions (top, right, ...)
* @returns {number}
*/
function getBordersSize(styles) {
var positions = [], len = arguments.length - 1;
while ( len-- > 0 ) positions[ len ] = arguments[ len + 1 ];
return positions.reduce(function (size, position) {
var value = styles['border-' + position + '-width'];
return size + toFloat(value);
}, 0);
}
/**
* Extracts paddings sizes from provided styles.
*
* @param {CSSStyleDeclaration} styles
* @returns {Object} Paddings box.
*/
function getPaddings(styles) {
var positions = ['top', 'right', 'bottom', 'left'];
var paddings = {};
for (var i = 0, list = positions; i < list.length; i += 1) {
var position = list[i];
var value = styles['padding-' + position];
paddings[position] = toFloat(value);
}
return paddings;
}
/**
* Calculates content rectangle of provided SVG element.
*
* @param {SVGGraphicsElement} target - Element content rectangle of which needs
* to be calculated.
* @returns {DOMRectInit}
*/
function getSVGContentRect(target) {
var bbox = target.getBBox();
return createRectInit(0, 0, bbox.width, bbox.height);
}
/**
* Calculates content rectangle of provided HTMLElement.
*
* @param {HTMLElement} target - Element for which to calculate the content rectangle.
* @returns {DOMRectInit}
*/
function getHTMLElementContentRect(target) {
var rect = target.getBoundingClientRect();
return createRectInit(rect.left, rect.top, rect.width, rect.height);
}
/**
* Checks whether provided element is a document element (<html>).
*
* @param {Element} target - Element to be checked.
* @returns {boolean}
*/
function isDocumentElement(target) {
return target === getWindowOf(target).document.documentElement;
}
/**
* Calculates an appropriate content rectangle for provided html or svg element.
*
* @param {Element} target - Element content rectangle of which needs to be calculated.
* @returns {DOMRectInit}
*/
function getContentRect(target) {
if (!isBrowser) {
return emptyRect;
}
return getHTMLElementContentRect(target);
}
/**
* Creates rectangle with an interface of the DOMRectReadOnly.
* Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
*
* @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
* @returns {DOMRectReadOnly}
*/
function createReadOnlyRect(ref) {
var x = ref.x;
var y = ref.y;
var width = ref.width;
var height = ref.height;
// If DOMRectReadOnly is available use it as a prototype for the rectangle.
var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
var rect = Object.create(Constr.prototype);
// Rectangle's properties are not writable and non-enumerable.
defineConfigurable(rect, {
x: x, y: y, width: width, height: height,
top: y,
right: x + width,
bottom: height + y,
left: x
});
return rect;
}
/**
* Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
* Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
*
* @param {number} x - X coordinate.
* @param {number} y - Y coordinate.
* @param {number} width - Rectangle's width.
* @param {number} height - Rectangle's height.
* @returns {DOMRectInit}
*/
function createRectInit(x, y, width, height) {
return { x: x, y: y, width: width, height: height };
}
/**
* Class that is responsible for computations of the content rectangle of
* provided DOM element and for keeping track of it's changes.
*/
var ResizeObservation = function(target) {
this.broadcastWidth = 0;
this.broadcastHeight = 0;
this.contentRect_ = createRectInit(0, 0, 0, 0);
this.target = target;
};
/**
* Updates content rectangle and tells whether it's width or height properties
* have changed since the last broadcast.
*
* @returns {boolean}
*/
/**
* Reference to the last observed content rectangle.
*
* @private {DOMRectInit}
*/
/**
* Broadcasted width of content rectangle.
*
* @type {number}
*/
ResizeObservation.prototype.isActive = function () {
var rect = getContentRect(this.target);
this.contentRect_ = rect;
return rect.width !== this.broadcastWidth || rect.height !== this.broadcastHeight;
};
/**
* Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
* from the corresponding properties of the last observed content rectangle.
*
* @returns {DOMRectInit} Last observed content rectangle.
*/
ResizeObservation.prototype.broadcastRect = function () {
var rect = this.contentRect_;
this.broadcastWidth = rect.width;
this.broadcastHeight = rect.height;
return rect;
};
var ResizeObserverEntry = function(target, rectInit) {
var contentRect = createReadOnlyRect(rectInit);
// According to the specification following properties are not writable
// and are also not enumerable in the native implementation.
//
// Property accessors are not being used as they'd require to define a
// private WeakMap storage which may cause memory leaks in browsers that
// don't support this type of collections.
defineConfigurable(this, { target: target, contentRect: contentRect });
};
var ResizeObserverSPI = function(callback, controller, callbackCtx) {
this.activeObservations_ = [];
this.observations_ = new MapShim();
if (typeof callback !== 'function') {
throw new TypeError('The callback provided as parameter 1 is not a function.');
}
this.callback_ = callback;
this.controller_ = controller;
this.callbackCtx_ = callbackCtx;
};
/**
* Starts observing provided element.
*
* @param {Element} target - Element to be observed.
* @returns {void}
*/
/**
* Registry of the ResizeObservation instances.
*
* @private {Map<Element, ResizeObservation>}
*/
/**
* Public ResizeObserver instance which will be passed to the callback
* function and used as a value of it's "this" binding.
*
* @private {ResizeObserver}
*/
/**
* Collection of resize observations that have detected changes in dimensions
* of elements.
*
* @private {Array<ResizeObservation>}
*/
ResizeObserverSPI.prototype.observe = function (target) {
if (!arguments.length) {
throw new TypeError('1 argument required, but only 0 present.');
}
// Do nothing if current environment doesn't have the Element interface.
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
return;
}
if (!(target instanceof getWindowOf(target).Element)) {
throw new TypeError('parameter 1 is not of type "Element".');
}
var observations = this.observations_;
// Do nothing if element is already being observed.
if (observations.has(target)) {
return;
}
observations.set(target, new ResizeObservation(target));
this.controller_.addObserver(this);
// Force the update of observations.
this.controller_.refresh();
};
/**
* Stops observing provided element.
*
* @param {Element} target - Element to stop observing.
* @returns {void}
*/
ResizeObserverSPI.prototype.unobserve = function (target) {
if (!arguments.length) {
throw new TypeError('1 argument required, but only 0 present.');
}
// Do nothing if current environment doesn't have the Element interface.
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
return;
}
if (!(target instanceof getWindowOf(target).Element)) {
throw new TypeError('parameter 1 is not of type "Element".');
}
var observations = this.observations_;
// Do nothing if element is not being observed.
if (!observations.has(target)) {
return;
}
observations.delete(target);
if (!observations.size) {
this.controller_.removeObserver(this);
}
};
/**
* Stops observing all elements.
*
* @returns {void}
*/
ResizeObserverSPI.prototype.disconnect = function () {
this.clearActive();
this.observations_.clear();
this.controller_.removeObserver(this);
};
/**
* Collects observation instances the associated element of which has changed
* it's content rectangle.
*
* @returns {void}
*/
ResizeObserverSPI.prototype.gatherActive = function () {
var this$1 = this;
this.clearActive();
this.observations_.forEach(function (observation) {
if (observation.isActive()) {
this$1.activeObservations_.push(observation);
}
});
};
/**
* Invokes initial callback function with a list of ResizeObserverEntry
* instances collected from active resize observations.
*
* @returns {void}
*/
ResizeObserverSPI.prototype.broadcastActive = function () {
// Do nothing if observer doesn't have active observations.
if (!this.hasActive()) {
return;
}
var ctx = this.callbackCtx_;
// Create ResizeObserverEntry instance for every active observation.
var entries = this.activeObservations_.map(function (observation) {
return new ResizeObserverEntry(observation.target, observation.broadcastRect());
});
this.callback_.call(ctx, entries, ctx);
this.clearActive();
};
/**
* Clears the collection of active observations.
*
* @returns {void}
*/
ResizeObserverSPI.prototype.clearActive = function () {
this.activeObservations_.splice(0);
};
/**
* Tells whether observer has active observations.
*
* @returns {boolean}
*/
ResizeObserverSPI.prototype.hasActive = function () {
return this.activeObservations_.length > 0;
};
// Registry of internal observers. If WeakMap is not available use current shim
// for the Map collection as it has all required methods and because WeakMap
// can't be fully polyfilled anyway.
var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
/**
* ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
* exposing only those methods and properties that are defined in the spec.
*/
var ResizeObserver = function(callback) {
if (!(this instanceof ResizeObserver)) {
throw new TypeError('Cannot call a class as a function.');
}
if (!arguments.length) {
throw new TypeError('1 argument required, but only 0 present.');
}
var controller = ResizeObserverController.getInstance();
var observer = new ResizeObserverSPI(callback, controller, this);
observers.set(this, observer);
};
// Expose public methods of ResizeObserver.
['observe', 'unobserve', 'disconnect'].forEach(function (method) {
ResizeObserver.prototype[method] = function () {
return (ref = observers.get(this))[method].apply(ref, arguments);
var ref;
};
});
var index = (function () {
// Export existing implementation if available.
if (typeof global$1.ResizeObserver !== 'undefined') {
return global$1.ResizeObserver;
}
return ResizeObserver;
})();
return index;
})));

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,14 @@
// Use define from require.js not webpack's define
var _define = window.define;
// document-register-element
var docRegister = require("document-register-element");
_define("document-register-element", function() { return docRegister; });
// fetch
var fetch = require("whatwg-fetch");
_define("fetch", function() { return fetch });
// flvjs
var flvjs = require("flv.js");
_define("flvjs", function() { return flvjs; });
@ -25,6 +33,14 @@ _define("hlsjs", function() { return hlsjs; });
var howler = require("howler");
_define("howler", function() { return howler; });
// native-promise-only
var nativePromise = require("native-promise-only");
_define("native-promise-only", function() { return nativePromise; });
// resize-observer-polyfill
var resize = require("resize-observer-polyfill");
_define("resize-observer-polyfill", function() { return resize; });
// shaka
var shaka = require("shaka-player");
_define("shaka", function() { return shaka; });
@ -38,6 +54,10 @@ _define("swiper", function() { return swiper; });
var sortable = require("sortablejs");
_define("sortable", function() { return sortable; });
// webcomponents
var webcomponents = require("webcomponents.js-2");
_define("webcomponents", function() { return webcomponents });
// libjass
var libjass = require("libjass");
require("libjass/libjass.css");

View File

@ -1,5 +1,5 @@
//TODO: (vitorsemeano) modify this lines for webpack
define(["bower_components/apiclient/apiclientcore", "localassetmanager"], function(ApiClient, localassetmanager) {
define(["libraries/apiclient/apiclientcore", "localassetmanager"], function(ApiClient, localassetmanager) {
"use strict";
if ("cordova" !== window.appMode && "android" !== window.appMode) {

View File

@ -659,6 +659,11 @@ define(["events", "apiclient", "appStorage"], function (events, apiClientFactory
return result;
});
}
return Promise.resolve({
Servers: servers,
State: "ServerSelection"
});
};
self.connectToServer = function (server, options) {

View File

@ -308,7 +308,7 @@ var AppInfo = {};
}
function getBowerPath() {
return "bower_components";
return "libraries";
}
function getComponentsPath() {
@ -387,7 +387,7 @@ var AppInfo = {};
return self.ResizeObserver;
});
} else {
define("ResizeObserver", [getBowerPath() + "/resize-observer-polyfill/ResizeObserver"], returnFirstDependency);
define("ResizeObserver", ["resize-observer-polyfill"], returnFirstDependency);
}
}
@ -410,9 +410,9 @@ var AppInfo = {};
if ("registerElement" in document) {
define("registerElement", []);
} else if (browser.msie) {
define("registerElement", [bowerPath + "/webcomponentsjs/webcomponents-lite.min.js"], returnFirstDependency);
define("registerElement", ["webcomponents"], returnFirstDependency);
} else {
define("registerElement", [bowerPath + "/document-register-element/build/document-register-element"], returnFirstDependency);
define("registerElement", ["document-register-element"], returnFirstDependency);
}
define("imageFetcher", [componentsPath + "/images/imageFetcher"], returnFirstDependency);
@ -632,7 +632,7 @@ var AppInfo = {};
}
if (!window.Promise || browser.web0s) {
require([getBowerPath() + "/native-promise-only/lib/npo.src"], init);
require(["native-promise-only"], init);
} else {
init();
}
@ -681,15 +681,20 @@ var AppInfo = {};
},
bundles: {
bundle: [
"document-register-element",
"fetch",
"flvjs",
"jstree",
"jQuery",
"hlsjs",
"howler",
"native-promise-only",
"resize-observer-polyfill",
"shaka",
"swiper",
"sortable",
"libjass"
"libjass",
"webcomponents"
]
},
urlArgs: urlArgs,
@ -741,9 +746,10 @@ var AppInfo = {};
define("itemrepository", [bowerPath + "/apiclient/sync/itemrepository"], returnFirstDependency);
define("useractionrepository", [bowerPath + "/apiclient/sync/useractionrepository"], returnFirstDependency);
// also pull out these libs
define("page", [bowerPath + "/page"], returnFirstDependency);
define("fetch", [bowerPath + "/fetch/fetch"], returnFirstDependency);
// TODO remove these libraries
// all three have been modified so we need to fix that first
define("page", [bowerPath + "/pagejs/page"], returnFirstDependency);
define("scroller", [componentsPath + "/scroller"], returnFirstDependency);
define("queryString", [bowerPath + "/query-string/index"], function () {
return queryString;
});
@ -843,7 +849,6 @@ var AppInfo = {};
define("sortMenu", [componentsPath + "/sortmenu/sortmenu"], returnFirstDependency);
define("idb", [componentsPath + "/idb"], returnFirstDependency);
define("sanitizefilename", [componentsPath + "/sanitizefilename"], returnFirstDependency);
define("scroller", [componentsPath + "/scroller"], returnFirstDependency);
define("toast", [componentsPath + "/toast/toast"], returnFirstDependency);
define("scrollHelper", [componentsPath + "/scrollhelper"], returnFirstDependency);
define("touchHelper", [componentsPath + "/touchhelper"], returnFirstDependency);

View File

@ -1,6 +1,8 @@
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const Assets = [
"alameda/alameda.js",
"requirejs/require.js"