@obitosouls/tizenbrew-netmirror 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -2
- package/package.json +42 -4
- package/service/index.js +498 -0
- package/web/config.xml +21 -0
- package/web/css/app.css +552 -0
- package/web/icon.png +0 -0
- package/web/index.html +258 -0
- package/web/js/api.js +707 -0
- package/web/js/app.js +3058 -0
- package/web/js/boot.js +230 -0
- package/web/js/hls.min.js +2 -0
package/web/js/boot.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* boot.js — loaded before everything else. Plain ES5 only.
|
|
3
|
+
* 1. On-screen error console: any script error is shown on the TV itself,
|
|
4
|
+
* together with the browser engine version and viewport size.
|
|
5
|
+
* 2. Polyfills for older Samsung Tizen engines (2016–2018 TVs).
|
|
6
|
+
*/
|
|
7
|
+
(function () {
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
/* ---------------- 1. On-screen error console ---------------- */
|
|
11
|
+
var box = null, pending = [];
|
|
12
|
+
function attach() {
|
|
13
|
+
if (box || !document.body) return;
|
|
14
|
+
box = document.createElement('div');
|
|
15
|
+
box.id = 'boot-errors';
|
|
16
|
+
box.style.cssText = 'position:fixed;left:20px;right:20px;bottom:20px;z-index:99999;max-height:45%;overflow:hidden;' +
|
|
17
|
+
'background:rgba(120,0,0,0.94);color:#fff;font:20px/1.4 monospace;padding:16px 20px;border-radius:8px;white-space:pre-wrap;';
|
|
18
|
+
var head = document.createElement('div');
|
|
19
|
+
head.style.cssText = 'color:#ffd0d0;margin-bottom:8px;font-size:16px;';
|
|
20
|
+
head.textContent = 'App error (please photograph this) | ' + navigator.userAgent +
|
|
21
|
+
' | viewport ' + window.innerWidth + 'x' + window.innerHeight;
|
|
22
|
+
box.appendChild(head);
|
|
23
|
+
document.body.appendChild(box);
|
|
24
|
+
for (var i = 0; i < pending.length; i++) addLine(pending[i]);
|
|
25
|
+
pending = [];
|
|
26
|
+
}
|
|
27
|
+
function addLine(msg) {
|
|
28
|
+
var line = document.createElement('div');
|
|
29
|
+
line.textContent = msg;
|
|
30
|
+
box.appendChild(line);
|
|
31
|
+
}
|
|
32
|
+
function show(msg) {
|
|
33
|
+
try {
|
|
34
|
+
attach();
|
|
35
|
+
if (box) addLine(msg); else pending.push(msg);
|
|
36
|
+
} catch (e) { /* never let the reporter itself throw */ }
|
|
37
|
+
}
|
|
38
|
+
window.__showError = show;
|
|
39
|
+
window.onerror = function (msg, src, line, col) {
|
|
40
|
+
show(String(msg) + ' @ ' + String(src || '').split('/').pop() + ':' + line + ':' + (col || 0));
|
|
41
|
+
return false;
|
|
42
|
+
};
|
|
43
|
+
window.addEventListener('unhandledrejection', function (e) {
|
|
44
|
+
var r = e && e.reason;
|
|
45
|
+
show('Unhandled promise rejection: ' + (r && r.message ? r.message : r));
|
|
46
|
+
});
|
|
47
|
+
document.addEventListener('DOMContentLoaded', attachIfPending);
|
|
48
|
+
function attachIfPending() { if (pending.length) attach(); }
|
|
49
|
+
|
|
50
|
+
/* ---------------- 2. Polyfills ---------------- */
|
|
51
|
+
function define(obj, name, fn) {
|
|
52
|
+
if (!obj[name]) Object.defineProperty(obj, name, { value: fn, configurable: true, writable: true });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
define(Array.prototype, 'find', function (fn, thisArg) {
|
|
56
|
+
for (var i = 0; i < this.length; i++) if (fn.call(thisArg, this[i], i, this)) return this[i];
|
|
57
|
+
return undefined;
|
|
58
|
+
});
|
|
59
|
+
define(Array.prototype, 'findIndex', function (fn, thisArg) {
|
|
60
|
+
for (var i = 0; i < this.length; i++) if (fn.call(thisArg, this[i], i, this)) return i;
|
|
61
|
+
return -1;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (typeof Object.assign !== 'function') {
|
|
65
|
+
Object.assign = function (target) {
|
|
66
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
67
|
+
var s = arguments[i];
|
|
68
|
+
if (s != null) for (var k in s) if (Object.prototype.hasOwnProperty.call(s, k)) target[k] = s[k];
|
|
69
|
+
}
|
|
70
|
+
return target;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
define(String, 'fromCodePoint', function () {
|
|
75
|
+
var out = '';
|
|
76
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
77
|
+
var c = Number(arguments[i]);
|
|
78
|
+
if (!(c >= 0 && c <= 0x10FFFF) || Math.floor(c) !== c) throw new RangeError('Invalid code point ' + c);
|
|
79
|
+
if (c > 0xFFFF) { c -= 0x10000; out += String.fromCharCode(0xD800 + (c >> 10), 0xDC00 + (c & 0x3FF)); }
|
|
80
|
+
else out += String.fromCharCode(c);
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var EP = window.Element && Element.prototype;
|
|
86
|
+
if (EP) {
|
|
87
|
+
if (!EP.matches) EP.matches = EP.webkitMatchesSelector || EP.msMatchesSelector;
|
|
88
|
+
if (!EP.closest) {
|
|
89
|
+
EP.closest = function (sel) {
|
|
90
|
+
var el = this;
|
|
91
|
+
while (el && el.nodeType === 1) {
|
|
92
|
+
if (el.matches(sel)) return el;
|
|
93
|
+
el = el.parentElement || el.parentNode;
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!window.URL && window.webkitURL) window.URL = window.webkitURL;
|
|
101
|
+
|
|
102
|
+
/* Minimal Promise (only if the engine has none) */
|
|
103
|
+
if (typeof window.Promise !== 'function') {
|
|
104
|
+
var P = function (fn) {
|
|
105
|
+
var self = this, done = false;
|
|
106
|
+
self._s = 0; self._v = undefined; self._q = [];
|
|
107
|
+
function finish(state, value) {
|
|
108
|
+
self._s = state; self._v = value;
|
|
109
|
+
var q = self._q; self._q = null;
|
|
110
|
+
setTimeout(function () { for (var i = 0; i < q.length; i++) q[i](); }, 0);
|
|
111
|
+
}
|
|
112
|
+
function adopt(v) {
|
|
113
|
+
if (v === self) return finish(2, new TypeError('Promise cycle'));
|
|
114
|
+
if (v && (typeof v === 'object' || typeof v === 'function')) {
|
|
115
|
+
var then;
|
|
116
|
+
try { then = v.then; } catch (e) { return finish(2, e); }
|
|
117
|
+
if (typeof then === 'function') {
|
|
118
|
+
var called = false;
|
|
119
|
+
try {
|
|
120
|
+
then.call(v, function (x) { if (!called) { called = true; adopt(x); } },
|
|
121
|
+
function (e) { if (!called) { called = true; finish(2, e); } });
|
|
122
|
+
} catch (e) { if (!called) { called = true; finish(2, e); } }
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
finish(1, v);
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
fn(function (v) { if (!done) { done = true; adopt(v); } },
|
|
130
|
+
function (e) { if (!done) { done = true; finish(2, e); } });
|
|
131
|
+
} catch (e) { if (!done) { done = true; finish(2, e); } }
|
|
132
|
+
};
|
|
133
|
+
P.prototype.then = function (onFul, onRej) {
|
|
134
|
+
var self = this;
|
|
135
|
+
return new P(function (resolve, reject) {
|
|
136
|
+
function run() {
|
|
137
|
+
var cb = self._s === 1 ? onFul : onRej;
|
|
138
|
+
if (typeof cb !== 'function') { (self._s === 1 ? resolve : reject)(self._v); return; }
|
|
139
|
+
try { resolve(cb(self._v)); } catch (e) { reject(e); }
|
|
140
|
+
}
|
|
141
|
+
if (self._q) self._q.push(run); else setTimeout(run, 0);
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
P.prototype['catch'] = function (onRej) { return this.then(null, onRej); };
|
|
145
|
+
P.resolve = function (v) { return new P(function (r) { r(v); }); };
|
|
146
|
+
P.reject = function (e) { return new P(function (_, r) { r(e); }); };
|
|
147
|
+
P.all = function (list) {
|
|
148
|
+
return new P(function (resolve, reject) {
|
|
149
|
+
var out = [], left = list.length;
|
|
150
|
+
if (!left) return resolve(out);
|
|
151
|
+
list.forEach(function (p, i) {
|
|
152
|
+
P.resolve(p).then(function (v) { out[i] = v; if (--left === 0) resolve(out); }, reject);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
window.Promise = P;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* Minimal TextDecoder: utf-8 (with fatal), utf-16le/be, windows-1252 */
|
|
160
|
+
if (typeof window.TextDecoder === 'undefined') {
|
|
161
|
+
var CP1252 = [0x20AC, 0x81, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x8D, 0x017D, 0x8F,
|
|
162
|
+
0x90, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x9D, 0x017E, 0x0178];
|
|
163
|
+
var TD = function (label, opts) {
|
|
164
|
+
this.encoding = String(label || 'utf-8').toLowerCase().replace(/^utf8$/, 'utf-8');
|
|
165
|
+
this.fatal = !!(opts && opts.fatal);
|
|
166
|
+
};
|
|
167
|
+
TD.prototype.decode = function (input) {
|
|
168
|
+
var b = !input ? new Uint8Array(0) : (input instanceof Uint8Array ? input : new Uint8Array(input));
|
|
169
|
+
var enc = this.encoding, out = '', i;
|
|
170
|
+
if (enc === 'utf-16le' || enc === 'utf-16be') {
|
|
171
|
+
for (i = 0; i + 1 < b.length; i += 2) out += String.fromCharCode(enc === 'utf-16le' ? (b[i] | (b[i + 1] << 8)) : ((b[i] << 8) | b[i + 1]));
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
if (enc === 'windows-1252' || enc === 'latin1' || enc === 'iso-8859-1') {
|
|
175
|
+
for (i = 0; i < b.length; i++) out += String.fromCharCode(b[i] >= 0x80 && b[i] <= 0x9F ? CP1252[b[i] - 0x80] : b[i]);
|
|
176
|
+
return out;
|
|
177
|
+
}
|
|
178
|
+
for (i = 0; i < b.length;) {
|
|
179
|
+
var c = b[i++], cp, need = 0, ok = true;
|
|
180
|
+
if (c < 0x80) cp = c;
|
|
181
|
+
else if (c >= 0xC2 && c < 0xE0) { cp = c & 0x1F; need = 1; }
|
|
182
|
+
else if (c >= 0xE0 && c < 0xF0) { cp = c & 0x0F; need = 2; }
|
|
183
|
+
else if (c >= 0xF0 && c < 0xF5) { cp = c & 0x07; need = 3; }
|
|
184
|
+
else ok = false;
|
|
185
|
+
for (var k = 0; ok && k < need; k++) {
|
|
186
|
+
var d = b[i];
|
|
187
|
+
if (d === undefined || (d & 0xC0) !== 0x80) { ok = false; break; }
|
|
188
|
+
cp = (cp << 6) | (d & 0x3F); i++;
|
|
189
|
+
}
|
|
190
|
+
if (ok && ((need === 2 && cp < 0x800) || (need === 3 && (cp < 0x10000 || cp > 0x10FFFF)) || (cp >= 0xD800 && cp <= 0xDFFF))) ok = false;
|
|
191
|
+
if (!ok) {
|
|
192
|
+
if (this.fatal) throw new TypeError('The encoded data was not valid utf-8');
|
|
193
|
+
out += '�';
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
out += String.fromCodePoint(cp);
|
|
197
|
+
}
|
|
198
|
+
return out;
|
|
199
|
+
};
|
|
200
|
+
window.TextDecoder = TD;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* Minimal fetch over XMLHttpRequest (supports ok/status/json/text/arrayBuffer) */
|
|
204
|
+
if (typeof window.fetch !== 'function') {
|
|
205
|
+
window.fetch = function (url, opts) {
|
|
206
|
+
opts = opts || {};
|
|
207
|
+
return new Promise(function (resolve, reject) {
|
|
208
|
+
var x = new XMLHttpRequest();
|
|
209
|
+
x.open(opts.method || 'GET', url, true);
|
|
210
|
+
x.responseType = 'arraybuffer';
|
|
211
|
+
var hd = opts.headers || {};
|
|
212
|
+
for (var k in hd) if (Object.prototype.hasOwnProperty.call(hd, k)) x.setRequestHeader(k, hd[k]);
|
|
213
|
+
x.onload = function () {
|
|
214
|
+
var buf = x.response || new ArrayBuffer(0);
|
|
215
|
+
var res = {
|
|
216
|
+
ok: (x.status >= 200 && x.status < 300) || (x.status === 0 && buf.byteLength > 0),
|
|
217
|
+
status: x.status,
|
|
218
|
+
arrayBuffer: function () { return Promise.resolve(buf); },
|
|
219
|
+
text: function () { return Promise.resolve(new TextDecoder('utf-8').decode(new Uint8Array(buf))); },
|
|
220
|
+
json: function () { return res.text().then(JSON.parse); }
|
|
221
|
+
};
|
|
222
|
+
resolve(res);
|
|
223
|
+
};
|
|
224
|
+
x.onerror = x.ontimeout = function () { reject(new TypeError('Network request failed')); };
|
|
225
|
+
if (opts.signal && opts.signal.addEventListener) opts.signal.addEventListener('abort', function () { x.abort(); });
|
|
226
|
+
x.send(opts.body || null);
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
})();
|