stremiok 2.2.6 → 2.2.8

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/js/stvod.js ADDED
@@ -0,0 +1,289 @@
1
+ /* Stalker films and series. Global namespace: StVod
2
+ A Stalker portal's (your IPTV playlists') films and series, as a local addon like Xtream's
3
+ (js/xtvod.js): a Movies and a Series catalog per portal (its categories as genres; none: the
4
+ newest; search), their pages and sources, and, on titles from your addons, the portal's copies
5
+ (found by a search of it when a title's sources are asked). All of it through StremioK's
6
+ service, which asks as a MAG box does (see service/index.js, /stalker/vod; YTPlay.stalkerVod).
7
+ A source is the service's link that asks the portal for the title's own when it's played
8
+ (/stalker/play): nothing is asked of the portal before, and the link saved to resume stays good.
9
+ Ids: svm.<portal>.<id> (a film), svs.<portal>.<id> (a series; svs.<portal>.v.<id>: a film the
10
+ portal marks as a series; its episodes svs.<portal>.<id>:<season>:<episode>, as other addons'
11
+ tt…:1:2). */
12
+ var StVod = (function () {
13
+ 'use strict';
14
+
15
+ var CATS_KEY = 'stremiok.stvod.cats', SEEN_KEY = 'stremiok.stvod.seen', CATS_FRESH_MS = 86400000, CATS_RETRY_MS = 6 * 3600000, SEEN_MAX = 200;
16
+ function enc(v) { return encodeURIComponent('' + v); }
17
+
18
+ // The Stalker portals among your playlists (switched on): { id, label, url, mac }.
19
+ function accounts() {
20
+ if (typeof IPTV === 'undefined' || !IPTV.isStalker) { return []; }
21
+ return IPTV.getPlaylists().filter(function (p) { return !p.off && IPTV.isStalker(p); }).map(function (p) {
22
+ return { id: p.id, label: IPTV.label(p.id), url: p.url, mac: p.mac };
23
+ });
24
+ }
25
+ function account(id) {
26
+ var l = accounts();
27
+ for (var i = 0; i < l.length; i++) { if (l[i].id === id) { return l[i]; } }
28
+ return null;
29
+ }
30
+ // The service's answer ({ why }: an error).
31
+ function ask(acc, more) {
32
+ if (typeof YTPlay === 'undefined' || !YTPlay.stalkerVod) { return Promise.reject(new Error('Stalker portals are read by StremioK’s service (not in a desktop browser)')); }
33
+ return YTPlay.stalkerVod(acc.url, acc.mac, more).then(function (r) {
34
+ if (!r || r.why) { throw new Error((r && r.why) || 'no answer'); }
35
+ return r;
36
+ });
37
+ }
38
+
39
+ // ---- Categories: Discover's genres, kept a day (U.store), read again in the background ----
40
+ // What's kept follows the portal's address and MAC: either edited, the old one's aren't its own.
41
+ var _cats = null, _catsAsked = {}, _changeFns = [], _reloaded = {};
42
+ function onChange(fn) { _changeFns.push(fn); } // (catalogs added or gone once its categories came)
43
+ function changed() { _changeFns.forEach(function (fn) { try { fn(); } catch (e) {} }); }
44
+ function sigOf(acc) { return acc.id + '|' + acc.url + '|' + acc.mac; }
45
+ function catsAll() {
46
+ if (!_cats) { var c = U.store.get(CATS_KEY, {}); _cats = c && typeof c === 'object' && !Array.isArray(c) ? c : {}; }
47
+ return _cats;
48
+ }
49
+ function known(acc) { var c = catsAll()[acc.id]; return c && c.sig === sigOf(acc) ? c : null; }
50
+ function catsOf(acc, type) { var c = known(acc); return c && Array.isArray(c[type]) ? c[type] : []; }
51
+ // A portal with films or series of that type (either, without one), or whose categories
52
+ // haven't come yet. One that lists none adds nothing: no catalogs, no copies.
53
+ function hasVod(acc, type) {
54
+ var c = known(acc);
55
+ if (!c) { return !type; }
56
+ return type ? catsOf(acc, type).length > 0 : !c.none;
57
+ }
58
+ function isEnabled() { return accounts().some(function (acc) { return hasVod(acc); }); }
59
+ function catList(r) {
60
+ return (r && Array.isArray(r.cats) ? r.cats : []).filter(function (c) { return c && c.id && c.title; }).slice(0, 1000).map(function (c) { return [('' + c.id).slice(0, 40), ('' + c.title).slice(0, 80)]; });
61
+ }
62
+ function refreshCats() {
63
+ accounts().forEach(function (acc) {
64
+ var c = known(acc), sk = sigOf(acc);
65
+ if ((c && Date.now() - c.at < (c.none ? CATS_RETRY_MS : CATS_FRESH_MS)) || _catsAsked[sk]) { return; }
66
+ _catsAsked[sk] = true; // (once a launch: a portal that didn't answer is asked again at the next)
67
+ function either(p) { return p.then(null, function (e) { return { failed: e }; }); }
68
+ var fresh = _reloaded[acc.id] ? '&fresh=1' : ''; // (Reload: the service's kept lists let go too)
69
+ Promise.all([either(ask(acc, '&type=movie&do=cats' + fresh)), either(ask(acc, '&type=series&do=cats' + fresh))]).then(function (r) {
70
+ if (r[0].failed && r[1].failed) { U.log('iptv', 'Stalker “' + acc.label + '”: its films and series couldn’t be read (' + U.problem(r[0].failed) + ')'); return; }
71
+ var all = catsAll(), keep = {}, o = { sig: sk, movie: catList(r[0]), series: catList(r[1]), at: Date.now() };
72
+ if (!o.movie.length && !o.series.length) { o.none = true; U.log('iptv', 'Stalker “' + acc.label + '”: no films or series'); }
73
+ accounts().forEach(function (a) { if (all[a.id]) { keep[a.id] = all[a.id]; } }); // (portals gone: dropped)
74
+ keep[acc.id] = o;
75
+ _cats = keep;
76
+ U.store.set(CATS_KEY, keep);
77
+ var before = _addon ? _addon.manifest.catalogs.length : 0;
78
+ fillCatalogs();
79
+ if (_addon && (_addon.manifest.catalogs.length !== before || _reloaded[acc.id])) { changed(); } // (its rows: Home reads them now)
80
+ delete _reloaded[acc.id];
81
+ });
82
+ });
83
+ }
84
+ // Reload on a portal (Settings › Content › IPTV): its categories asked again now, and the
85
+ // service's kept lists of it let go (fresh=1).
86
+ function reload(id) {
87
+ var acc = account(id), all = catsAll();
88
+ if (!acc) { return; }
89
+ delete all[id];
90
+ U.store.set(CATS_KEY, all);
91
+ _catsAsked[sigOf(acc)] = false;
92
+ _seasons.clear();
93
+ _reloaded[id] = true;
94
+ refreshCats();
95
+ }
96
+
97
+ // ---- The addon ----
98
+ var _addon = null;
99
+ function catalogsNow() {
100
+ var out = [];
101
+ accounts().forEach(function (acc) {
102
+ ['movie', 'series'].forEach(function (type) {
103
+ if (!hasVod(acc, type)) { return; }
104
+ out.push({ type: type, id: 'sv.' + acc.id + '.' + type, name: acc.label,
105
+ extra: [{ name: 'genre', options: catsOf(acc, type).map(function (c) { return c[1]; }) }, { name: 'search' }, { name: 'skip' }] });
106
+ });
107
+ });
108
+ return out;
109
+ }
110
+ var RESOURCES = ['catalog', { name: 'stream', types: ['movie', 'series'], idPrefixes: ['tt', 'tmdb:'] }];
111
+ function fillCatalogs() { // (changed in place: the loaded addon holds the same list)
112
+ if (!_addon) { return; }
113
+ var l = _addon.manifest.catalogs;
114
+ l.splice.apply(l, [0, l.length].concat(catalogsNow()));
115
+ _addon.manifest.resources = accounts().some(function (acc) { return hasVod(acc, 'movie') || hasVod(acc, 'series'); }) ? RESOURCES : ['catalog'];
116
+ }
117
+ function synthAddon() {
118
+ if (!_addon) {
119
+ _addon = { __local: true, __impl: StVod, __sources: true, url: 'local:stvod', base: 'local:stvod',
120
+ manifest: { id: 'org.stremiok.stvod', name: 'Stalker', version: '1.0.0', types: ['movie', 'series'], resources: RESOURCES, catalogs: [] } };
121
+ }
122
+ fillCatalogs();
123
+ refreshCats();
124
+ return _addon;
125
+ }
126
+
127
+ // ---- Titles: a card, and what the portal said of it (its cmd: what plays it) ----
128
+ // Kept while StremioK runs; a title whose page was opened, also for the next launches (SEEN_MAX
129
+ // of them: Continue Watching's open their pages again).
130
+ var _items = U.lru(600);
131
+ function slim(it) { var o = { name: it.name }; ['year', 'pic', 'cmd', 'rating', 'series'].forEach(function (k) { if (it[k]) { o[k] = it[k]; } }); return o; }
132
+ function seenAll() { var a = U.store.get(SEEN_KEY, []); return Array.isArray(a) ? a : []; }
133
+ function remember(id, it) {
134
+ var all = seenAll().filter(function (x) { return x && x[0] !== id; });
135
+ all.push([id, slim(it)]);
136
+ U.store.set(SEEN_KEY, all.slice(-SEEN_MAX));
137
+ }
138
+ function recall(id) {
139
+ var it = _items.get(id);
140
+ if (it) { return it; }
141
+ var all = seenAll();
142
+ for (var i = all.length - 1; i >= 0; i--) { if (all[i] && all[i][0] === id && all[i][1] && all[i][1].name) { return all[i][1]; } }
143
+ return null;
144
+ }
145
+ function idOf(acc, type, it) {
146
+ var series = type === 'series' || !!it.series;
147
+ return (series ? 'svs.' : 'svm.') + acc.id + '.' + (type === 'movie' && it.series ? 'v.' : '') + it.id;
148
+ }
149
+ function cardOf(acc, type, it) {
150
+ if (!it || !it.id || !it.name) { return null; }
151
+ var id = idOf(acc, type, it), m = { id: id, type: /^svs\./.test(id) ? 'series' : 'movie', name: it.name, posterShape: 'poster' };
152
+ if (it.pic) { m.poster = it.pic; }
153
+ if (it.rating > 0) { m.imdbRating = (+it.rating).toFixed(1); }
154
+ if (it.year) { m.releaseInfo = '' + it.year; }
155
+ if (it.desc) { m.description = it.desc; }
156
+ _items.set(id, it);
157
+ return m;
158
+ }
159
+ function catalog(catId, extra) {
160
+ var m = /^sv\.([^.]+)\.(movie|series)$/.exec(catId || ''), acc = m && account(m[1]);
161
+ if (!acc) { return Promise.resolve([]); }
162
+ var type = m[2], skip = extra && extra.skip ? (parseInt(extra.skip, 10) || 0) : 0, cat = '*';
163
+ if (extra && extra.genre) {
164
+ var c = catsOf(acc, type).filter(function (x) { return x[1] === extra.genre; })[0];
165
+ if (!c) { return Promise.resolve([]); }
166
+ cat = c[0];
167
+ }
168
+ var more = '&type=' + type + '&do=list&cat=' + enc(cat) + (extra && extra.search ? '&q=' + enc(('' + extra.search).slice(0, 120)) : '') + (skip ? '&skip=' + skip : '');
169
+ return ask(acc, more).then(function (r) {
170
+ return (Array.isArray(r.items) ? r.items : []).map(function (it) { return cardOf(acc, type, it); }).filter(Boolean);
171
+ }, function (e) {
172
+ U.log('iptv', 'Stalker “' + acc.label + '”: its ' + (type === 'movie' ? 'films' : 'series') + ' couldn’t be read (' + U.problem(e) + ')');
173
+ return [];
174
+ });
175
+ }
176
+
177
+ // ---- A title's page ----
178
+ function parseId(id) {
179
+ var m = /^sv([ms])\.([^.]+)\.(v\.)?([\w-]+)(?::(\d+):(\d+))?$/.exec('' + id);
180
+ if (!m) { return null; }
181
+ var x = { kind: m[1], acc: account(m[2]), vod: !!m[3], num: m[4], season: m[5] != null ? +m[5] : null, episode: m[6] != null ? +m[6] : null };
182
+ x.base = 'sv' + x.kind + '.' + m[2] + '.' + (x.vod ? 'v.' : '') + x.num;
183
+ return x;
184
+ }
185
+ // A series' seasons, as the service lists them ({ season, name, cmd, eps: [{ n, cmd?, name? }] }).
186
+ var _seasons = U.lru(20);
187
+ function seasons(acc, x) {
188
+ var k = sigOf(acc) + '|' + x.base, kept = _seasons.get(k);
189
+ if (kept) { return kept; }
190
+ var p = ask(acc, '&type=series&do=seasons&id=' + enc(x.num) + (x.vod ? '&via=vod' : '')).then(function (r) { return Array.isArray(r.seasons) ? r.seasons : []; });
191
+ _seasons.set(k, p);
192
+ p.then(null, function () { if (_seasons.get(k) === p) { _seasons.set(k, null); } });
193
+ return p;
194
+ }
195
+ function list(v) { return ('' + (v || '')).split(/\s*,\s*/).map(function (s) { return s.trim(); }).filter(Boolean).slice(0, 12); }
196
+ function details(m, it) {
197
+ if (it.pic) { m.poster = it.pic; }
198
+ if (it.desc) { m.description = it.desc; }
199
+ if (list(it.genres).length) { m.genres = list(it.genres); }
200
+ if (list(it.cast).length) { m.cast = list(it.cast); }
201
+ if (list(it.director).length) { m.director = list(it.director); }
202
+ if (it.rating > 0) { m.imdbRating = (+it.rating).toFixed(1); }
203
+ if (it.mins > 0) { m.runtime = it.mins + ' min'; }
204
+ if (it.year) { m.releaseInfo = '' + it.year; m.year = '' + it.year; }
205
+ return m;
206
+ }
207
+ function meta(type, id) {
208
+ var x = parseId(id);
209
+ if (!x || !x.acc) { return Promise.resolve(null); }
210
+ var it = recall(x.base);
211
+ if (x.kind === 'm') {
212
+ if (!it) { return Promise.resolve(null); }
213
+ remember(x.base, it);
214
+ return Promise.resolve(details({ id: x.base, type: 'movie', name: it.name, _from: x.acc.label }, it));
215
+ }
216
+ return seasons(x.acc, x).then(function (l) {
217
+ if (!it && !l.length) { return null; }
218
+ if (it) { remember(x.base, it); }
219
+ var m = details({ id: x.base, type: 'series', name: it ? it.name : 'Series', _from: x.acc.label }, it || {});
220
+ m.videos = [];
221
+ l.forEach(function (se) {
222
+ (se.eps || []).forEach(function (ep) { m.videos.push({ id: x.base + ':' + se.season + ':' + ep.n, season: se.season, episode: ep.n, title: ep.name || 'Episode ' + ep.n }); });
223
+ });
224
+ return m;
225
+ });
226
+ }
227
+
228
+ // ---- Sources ----
229
+ function source(acc, url, name) {
230
+ var st = { url: url, name: 'Stalker', title: ('' + name).trim() + '\n' + acc.label, _stvod: true }, h = U.sanitizeHeaders({ ua: IPTV.stbUa });
231
+ if (h) { st._headers = h; }
232
+ return st;
233
+ }
234
+ function playUrl(acc, cmd, ep) {
235
+ if (typeof YTPlay === 'undefined' || !YTPlay.stalkerPlayUrl) { return Promise.reject(new Error('no service')); }
236
+ return YTPlay.stalkerPlayUrl(acc.url, acc.mac, cmd, ep);
237
+ }
238
+ function filmSource(acc, it) {
239
+ if (!it || !it.cmd) { return Promise.resolve(null); }
240
+ return playUrl(acc, it.cmd, -1).then(function (u) { return source(acc, u, it.name); }, function () { return null; });
241
+ }
242
+ function two(n) { return (n < 10 ? '0' : '') + n; }
243
+ function episodeSource(acc, x, season, episode, name) {
244
+ return seasons(acc, x).then(function (l) {
245
+ var se = l.filter(function (s) { return s.season === season; })[0], ep = se && (se.eps || []).filter(function (e) { return e.n === episode; })[0];
246
+ if (!ep || !(ep.cmd || se.cmd)) { return null; }
247
+ return playUrl(acc, ep.cmd || se.cmd, ep.cmd ? -1 : episode).then(function (u) { return source(acc, u, (name || '') + ' S' + two(season) + 'E' + two(episode)); });
248
+ }).then(null, function () { return null; });
249
+ }
250
+ // A title's sources: its own (svm / svs ids), or, for a title from your addons, each portal's
251
+ // copies (m: its details, for its name and year), found by a search of the portal.
252
+ function streams(type, id, m) {
253
+ var x = parseId(id);
254
+ if (x) {
255
+ if (!x.acc) { return Promise.resolve([]); }
256
+ var it = recall(x.base);
257
+ var p = x.kind === 'm' ? filmSource(x.acc, it) : x.season != null ? episodeSource(x.acc, x, x.season, x.episode, it ? it.name : '') : Promise.resolve(null);
258
+ return p.then(function (s) { return s ? [s] : []; });
259
+ }
260
+ return matches(type, id, m);
261
+ }
262
+ // A name to match: no accents, brackets, year at the end, quality words or punctuation.
263
+ var WORDS = /\b(4k|uhd|fhd|hd|sd|hdr|hevc|x265|h265|1080p|720p|2160p|multi|sub|subs|dub|dubbed|latino|castellano)\b/g;
264
+ function keyOf(name) {
265
+ var s = ('' + (name || '')).toLowerCase();
266
+ if (s.normalize) { s = s.normalize('NFD').replace(/[̀-ͯ]/g, ''); }
267
+ return s.replace(/\([^()]*\)|\[[^\[\]]*\]/g, ' ').replace(WORDS, ' ').trim().replace(/\b(19|20)\d{2}$/, ' ').replace(/&/g, ' and ').replace(/[^a-z0-9]+/g, ' ').trim();
268
+ }
269
+ function yearOf(v) { var y = parseInt(('' + (v || '')).slice(0, 4), 10); return y > 1880 && y < 2100 ? y : 0; }
270
+ function matches(type, id, m) {
271
+ var parts = ('' + id).split(':'), season = type === 'series' ? parseInt(parts[parts.length - 2], 10) : null, episode = type === 'series' ? parseInt(parts[parts.length - 1], 10) : null;
272
+ if (type === 'series' && !(season >= 0 && episode >= 0)) { return Promise.resolve([]); }
273
+ var name = m && m.name ? '' + m.name : '', year = m ? yearOf(m.year || m.releaseInfo || m.released) : 0, k = keyOf(name);
274
+ if (!k) { return Promise.resolve([]); }
275
+ return Promise.all(accounts().filter(function (acc) { return hasVod(acc, type); }).map(function (acc) {
276
+ return ask(acc, '&type=' + type + '&do=list&q=' + enc(name.slice(0, 120))).then(function (r) {
277
+ var hits = (Array.isArray(r.items) ? r.items : []).filter(function (it) {
278
+ return it && keyOf(it.name) === k && (type === 'series' || !it.series) && (!year || !it.year || Math.abs(it.year - year) <= (type === 'series' ? 0 : 1));
279
+ }).slice(0, 2);
280
+ return Promise.all(hits.map(function (it) {
281
+ var card = cardOf(acc, type, it); // (kept: what plays it)
282
+ return type === 'movie' ? filmSource(acc, it) : episodeSource(acc, parseId(card.id), season, episode, it.name);
283
+ }));
284
+ }, function () { return []; });
285
+ })).then(function (all) { return [].concat.apply([], all).filter(Boolean); });
286
+ }
287
+
288
+ return { accounts: accounts, isEnabled: isEnabled, onChange: onChange, reload: reload, synthAddon: synthAddon, catalog: catalog, meta: meta, streams: streams, refreshCats: refreshCats };
289
+ })();
package/js/util.js CHANGED
@@ -382,12 +382,12 @@ var U = (function () {
382
382
  return cut ? out.replace(/[ \t]{2,}/g, ' ').replace(/^[ \t]+|[ \t]+$/gm, '') : out;
383
383
  }
384
384
 
385
- /* Request headers a stream needs (IPTV's http-user-agent / http-referrer): only these
386
- two (the only ones the TV's player takes), as { ua, ref }. Each is kept to printable
387
- ASCII on one line (a line break would add a header of its own) and a sane length; a
388
- Referer must be an http(s) link. The names Stremio uses ("User-Agent", "Referer") are
389
- read too. Returns null when nothing usable is left. */
390
- var HEADER_MAX = { ua: 512, ref: 2048 };
385
+ /* Request headers a stream needs (IPTV's http-user-agent / http-referrer, a cookie): only
386
+ these three (the ones the TV's player takes), as { ua, ref, cookie }. Each is kept to
387
+ printable ASCII on one line (a line break would add a header of its own) and a sane length;
388
+ a Referer must be an http(s) link. The names Stremio uses ("User-Agent", "Referer",
389
+ "Cookie") are read too. Returns null when nothing usable is left. */
390
+ var HEADER_MAX = { ua: 512, ref: 2048, cookie: 3000 }; // (a cookie: within what a newer TV's service reads of a request, 8 KB)
391
391
  function headerValue(v, max) {
392
392
  if (typeof v !== 'string') { return ''; }
393
393
  v = v.trim();
@@ -397,11 +397,13 @@ var U = (function () {
397
397
  if (!h || typeof h !== 'object') { return null; }
398
398
  var ua = headerValue(h.ua != null ? h.ua : (h['User-Agent'] || h['user-agent']), HEADER_MAX.ua);
399
399
  var ref = headerValue(h.ref != null ? h.ref : (h.Referer || h.referer), HEADER_MAX.ref);
400
+ var cookie = headerValue(h.cookie != null ? h.cookie : (h.Cookie || h.COOKIE), HEADER_MAX.cookie);
400
401
  if (ref && !/^https?:\/\/[^\s]+$/i.test(ref)) { ref = ''; }
401
- if (!ua && !ref) { return null; }
402
+ if (!ua && !ref && !cookie) { return null; }
402
403
  var out = {};
403
404
  if (ua) { out.ua = ua; }
404
405
  if (ref) { out.ref = ref; }
406
+ if (cookie) { out.cookie = cookie; }
405
407
  return out;
406
408
  }
407
409
 
@@ -0,0 +1,281 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ -----
205
+
206
+ Contains code from https://github.com/mozilla/language-mapping-list
207
+
208
+ The MIT License (MIT)
209
+
210
+ Copyright (c) 2013 Ali Al Dallal
211
+
212
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
213
+ this software and associated documentation files (the "Software"), to deal in
214
+ the Software without restriction, including without limitation the rights to
215
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
216
+ the Software, and to permit persons to whom the Software is furnished to do so,
217
+ subject to the following conditions:
218
+
219
+ The above copyright notice and this permission notice shall be included in all
220
+ copies or substantial portions of the Software.
221
+
222
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
223
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
224
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
225
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
226
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
227
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
228
+
229
+ -----
230
+
231
+ Contains code from https://github.com/TobiasNickel/tXml
232
+ (See lib/util/tXml.js)
233
+
234
+ tXml MIT License Agreement
235
+
236
+ Copyright 2015 Tobias Nickel
237
+
238
+ Permission is hereby granted, free of charge, to any person obtaining a copy
239
+ of this software and associated documentation files (the "Software"), to deal
240
+ in the Software without restriction, including without limitation the rights
241
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
242
+ copies of the Software, and to permit persons to whom the Software is
243
+ furnished to do so, subject to the following conditions:
244
+
245
+ The above copyright notice and this permission notice shall be included in
246
+ all copies or substantial portions of the Software.
247
+
248
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
249
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
250
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
251
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
252
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
253
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
254
+ SOFTWARE.
255
+
256
+ -----
257
+
258
+ Contains code from https://github.com/toji/gl-matrix
259
+ (See ui/gl_matrix/matrix_4x4.js and ui/gl_matrix/matrix_quaternion.js)
260
+
261
+ The MIT License (MIT)
262
+
263
+ Copyright (c) 2015-2021, Brandon Jones, Colin MacKenzie IV.
264
+
265
+ Permission is hereby granted, free of charge, to any person obtaining a copy
266
+ of this software and associated documentation files (the "Software"), to deal
267
+ in the Software without restriction, including without limitation the rights
268
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
269
+ copies of the Software, and to permit persons to whom the Software is
270
+ furnished to do so, subject to the following conditions:
271
+
272
+ The above copyright notice and this permission notice shall be included in
273
+ all copies or substantial portions of the Software.
274
+
275
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
276
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
277
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
278
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
279
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
280
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
281
+ SOFTWARE.