Compare commits

..

3 Commits

Author SHA1 Message Date
Abdussamed 087263d3f0 yerel event 2024-03-27 09:08:10 +03:00
saqut ce37dc6fc1 Sıkıştırılmış JS dosyaları 2024-02-08 22:12:49 +03:00
saqut de61abe4f6 Merge pull request 'Stability Update' (#1) from stability-update into MASTER
Reviewed-on: #1
2024-02-08 21:59:52 +03:00
7 changed files with 7067 additions and 25 deletions

View File

@ -26,7 +26,7 @@ class EventTarget
{ {
if(this._events.has(event)) if(this._events.has(event))
{ {
this._events.get(event).push(callback) this._events.get(event)?.push(callback)
}else{ }else{
this._events.set(event,[callback]) this._events.set(event,[callback])
} }
@ -48,7 +48,7 @@ class EventTarget
/** /**
* *
* @param {string} type gerçekleşen olay türü * @param {string} type gerçekleşen olay türü
* @param {...any[]} args olay gerçekleştiğinde çalışacak işlevler gönderilecek argümanlar * @param {...any[]} args olay gerexçekleştiğinde çalışacak işlevler gönderilecek argümanlar
*/ */
public emitEvent(type:string, ...args) public emitEvent(type:string, ...args)
{ {
@ -106,7 +106,7 @@ export class IndexedDB extends EventTarget
this.IsReady = false; this.IsReady = false;
this.DBRequest = IndexedDB.Engine.open(this.Model.name, this.Model.version || 0); this.DBRequest = IndexedDB.Engine.open(this.Model.name, this.Model.version || 0);
this.DBRequest.addEventListener("upgradeneeded", this.executeMigrate.bind(this)); this.DBRequest.addEventListener("upgradeneeded", this.executeMigrate.bind(this));
new IEventLocate<IDBDatabase>(this.DBRequest).sync().then(async db => { new IEventLocate<IDBDatabase,IDBRequest>(this.DBRequest).sync().then(async db => {
this.DB = db; this.DB = db;
this.IsReady = true; this.IsReady = true;
this.dispatchEvent(new Event("load")); this.dispatchEvent(new Event("load"));
@ -125,7 +125,7 @@ export class IndexedDB extends EventTarget
{ {
objectStore = db.createObjectStore(e.name, {keyPath:e.key}); objectStore = db.createObjectStore(e.name, {keyPath:e.key});
}else{ }else{
objectStore = this.DBRequest.transaction.objectStore(e.name); objectStore = (this.DBRequest.transaction as IDBTransaction).objectStore(e.name);
} }
e.columns.forEach(name => { e.columns.forEach(name => {
@ -172,7 +172,7 @@ export class IndexedDB extends EventTarget
{ {
if(!this.IsReady) return; if(!this.IsReady) return;
let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).add(data); let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).add(data);
return await (new IEventLocate<IDBValidKey>(store)).sync(); return await (new IEventLocate<IDBValidKey,IDBRequest>(store)).sync();
} }
/** /**
* Tablodaki tüm verileri temizler * Tablodaki tüm verileri temizler
@ -181,7 +181,7 @@ export class IndexedDB extends EventTarget
{ {
if(!this.IsReady) return; if(!this.IsReady) return;
let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).clear(); let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).clear();
return await (new IEventLocate<undefined>(store)).sync(); return await (new IEventLocate<undefined,IDBRequest>(store)).sync();
} }
/** /**
* Tablodaki verilerin sayısını döner * Tablodaki verilerin sayısını döner
@ -190,7 +190,7 @@ export class IndexedDB extends EventTarget
{ {
if(!this.IsReady) return; if(!this.IsReady) return;
let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).count(); let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).count();
return await (new IEventLocate<number>(store)).sync(); return await (new IEventLocate<number,IDBRequest>(store)).sync();
} }
/** /**
* Tablo bir kayıt siler * Tablo bir kayıt siler
@ -199,25 +199,25 @@ export class IndexedDB extends EventTarget
{ {
if(!this.IsReady) return; if(!this.IsReady) return;
let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).delete(name); let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).delete(name);
return await (new IEventLocate <undefined> (store)).sync(); return await (new IEventLocate <undefined,IDBRequest> (store)).sync();
} }
/** /**
* Tablodaki bir kaydı okur * Tablodaki bir kaydı okur (primary key ile)
*/ */
public async get(tablename:string, index:string) public async get(tablename:string, index:string)
{ {
if(!this.IsReady) return; if(!this.IsReady) return;
let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).get(index); let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).get(index);
return await (new IEventLocate <{[key:string]:any}> (store)).sync(); return await (new IEventLocate <any,IDBRequest> (store)).sync();
} }
/** /**
* Tablodaki bir kaydı okur * Tablodaki bir kaydı okur (belirtilen index kolonuyla arar)
*/ */
public async getFrom(tablename:string, column:string, index:string) public async getFrom(tablename:string, column:string, index:string)
{ {
if(!this.IsReady) return; if(!this.IsReady) return;
let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).index(column).get(index); let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).index(column).get(index);
return await (new IEventLocate <{[key:string]:any}> (store)).sync(); return await (new IEventLocate <any,IDBRequest> (store)).sync();
} }
/** /**
* Tablodaki tüm kayıtları alır * Tablodaki tüm kayıtları alır
@ -226,7 +226,7 @@ export class IndexedDB extends EventTarget
{ {
if(!this.IsReady) return; if(!this.IsReady) return;
let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).getAll(); let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).getAll();
return await (new IEventLocate <{[key:string]:any}[]> (store)).sync(); return await (new IEventLocate <any[], IDBRequest> (store)).sync();
} }
/** /**
* Tabloda veri yoksa oluşturur varsa günceller * Tabloda veri yoksa oluşturur varsa günceller
@ -249,7 +249,7 @@ export class IndexedDB extends EventTarget
{ {
if(!this.IsReady) return; if(!this.IsReady) return;
let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).put(data); let store = this.DB.transaction([tablename], "readwrite").objectStore(tablename).put(data);
return await (new IEventLocate <IDBValidKey> (store)).sync(); return await (new IEventLocate <IDBValidKey,IDBRequest> (store)).sync();
} }
/** /**
* Tablodaki tüm verileri tek tek verir * Tablodaki tüm verileri tek tek verir
@ -268,7 +268,7 @@ export class IndexedDB extends EventTarget
try{ try{
callback( callback(
data, data,
() => cursor.result.continue(), () => cursor.result?.continue(),
() => ok(void 0), () => ok(void 0),
cursor.result.primaryKey cursor.result.primaryKey
) )
@ -372,27 +372,27 @@ export class IndexedDB extends EventTarget
} }
if('mozIndexedDB' in window) if('mozIndexedDB' in window)
{ {
IndexedDB.Engine = window['mozIndexedDB'] IndexedDB.Engine = window['mozIndexedDB'] as IDBFactory
} }
if('webkitIndexedDB' in window) if('webkitIndexedDB' in window)
{ {
IndexedDB.Engine = window['webkitIndexedDB'] IndexedDB.Engine = window['webkitIndexedDB'] as IDBFactory
} }
if('msIndexedDB' in window) if('msIndexedDB' in window)
{ {
IndexedDB.Engine = window['msIndexedDB'] IndexedDB.Engine = window['msIndexedDB'] as IDBFactory
} }
} }
} }
interface ISheel{ interface ISheel<Type>{
onsuccess : (e:any) => any; onsuccess : ((this: Type, ev: Event) => any) | null;
onerror : (e:any) => any; onerror : ((this: Type, ev: Event) => any) | null;
} }
/** /**
* Başarılı olduğunda onsuccess başarısız olduğunda onerror döndüren yapıları * Başarılı olduğunda onsuccess başarısız olduğunda onerror döndüren yapıları
* javascript ES6 tarafında async/await yapısına dönüştürür böylece try-catch kullanılarak yakalanabilir * javascript ES6 tarafında async/await yapısına dönüştürür böylece try-catch kullanılarak yakalanabilir
*/ */
class IEventLocate<Type> class IEventLocate<Type,Shell>
{ {
private result : { private result : {
then:any[], then:any[],
@ -408,9 +408,9 @@ class IEventLocate<Type>
catch: [], catch: [],
finally: [] finally: []
}; };
public constructor(sheel:ISheel) public constructor(sheel:ISheel<Shell>)
{ {
sheel.onerror = (event) => { sheel.onerror = (event:any) => {
this.result.catch = [event.target, event]; this.result.catch = [event.target, event];
this.events.catch.forEach(e => { this.events.catch.forEach(e => {
e.call(event.target, event.target?.result); e.call(event.target, event.target?.result);
@ -419,7 +419,7 @@ class IEventLocate<Type>
e.call(event.target, event.target?.result); e.call(event.target, event.target?.result);
}) })
} }
sheel.onsuccess = (event) => { sheel.onsuccess = (event:any) => {
this.result.then = [event.target, event]; this.result.then = [event.target, event];
this.events.then.forEach(e => { this.events.then.forEach(e => {
e.call(event.target, event.target?.result); e.call(event.target, event.target?.result);

27
index.html Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<header></header>
<main></main>
<footer></footer>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<video controls style="width:50%;aspect-ratio: 2/1;">
<track src="video.tr.vtt" kind="subtitles" srclang="tr" label="Türkçe" default>
<track src="video.en.vtt" kind="subtitles" srclang="en" label="Engilişçe">
<source src="video.webm" type="video/webm">
</video>
</body>
</html>

2
jscompiled/IndexedDB.js Normal file
View File

@ -0,0 +1,2 @@
(()=>{class t{on(t,e){this._events.has(t)?this._events.get(t).push(e):this._events.set(t,[e])}addEventListener(t,e){this.on(t,e)}dispatchEvent(t){this.emitEvent(t.type,t)}emitEvent(t,...e){let s=this._events.get(t);if(s)for(let t of s)t(...e)}constructor(){this._events=new Map}}class e extends t{constructor(){super(),this.IsReady=!1,e.Engine||e.PolyfillCompalibity()}scope(t){if(this.IsReady)return t();this.addEventListener("load",()=>t())}async connect(){this.IsReady=!1,this.DBRequest=e.Engine.open(this.Model.name,this.Model.version||0),this.DBRequest.addEventListener("upgradeneeded",this.executeMigrate.bind(this)),new s(this.DBRequest).sync().then(async t=>{this.DB=t,this.IsReady=!0,this.dispatchEvent(new Event("load"))})}executeMigrate(){let t=this.DBRequest.result;for(let e of this.Model.tables){let s;for(let n of(s=t.objectStoreNames.contains(e.name)?this.DBRequest.transaction.objectStore(e.name):t.createObjectStore(e.name,{keyPath:e.key}),e.columns.forEach(t=>{s.indexNames.contains(t)||s.createIndex(t,t)}),Array.from(s.indexNames)))e.columns.includes(n)||s.deleteIndex(n)}for(let e of Array.from(t.objectStoreNames))0!=this.Model.tables.filter(t=>t.name==e).length||t.deleteObjectStore(e);this.dispatchEvent(new Event("migrate"))}migrate(t){this.Model=t}async add(t,e){if(!this.IsReady)return;let n=this.DB.transaction([t],"readwrite").objectStore(t).add(e);return await new s(n).sync()}async clear(t){if(!this.IsReady)return;let e=this.DB.transaction([t],"readwrite").objectStore(t).clear();return await new s(e).sync()}async count(t){if(!this.IsReady)return;let e=this.DB.transaction([t],"readwrite").objectStore(t).count();return await new s(e).sync()}async delete(t,e){if(!this.IsReady)return;let n=this.DB.transaction([t],"readwrite").objectStore(t).delete(e);return await new s(n).sync()}async get(t,e){if(!this.IsReady)return;let n=this.DB.transaction([t],"readwrite").objectStore(t).get(e);return await new s(n).sync()}async getFrom(t,e,n){if(!this.IsReady)return;let i=this.DB.transaction([t],"readwrite").objectStore(t).index(e).get(n);return await new s(i).sync()}async getAll(t){if(!this.IsReady)return;let e=this.DB.transaction([t],"readwrite").objectStore(t).getAll();return await new s(e).sync()}async save(t,e,s){this.IsReady&&(await this.get(t,e)?await this.put(t,s):await this.add(t,s))}async put(t,e){if(!this.IsReady)return;let n=this.DB.transaction([t],"readwrite").objectStore(t).put(e);return await new s(n).sync()}async each(t,e){let s=this.DB.transaction([t],"readonly").objectStore(t).openCursor();await new Promise(t=>{s.onsuccess=function(){if(null!==s.result){let n=s.result.value;try{e(n,()=>s.result.continue(),()=>t(void 0),s.result.primaryKey)}catch{t(void 0)}}else t(void 0)}})}async subfilter(t,e,s,n){let i=[],a=[];for(let n of(await this.each(t,async(t,s,n,a)=>{await e(t,n)&&i.push(a),s()}),i)){let e=this.get(t,n);a.push(await s(e))}return"function"==typeof n&&n(a),a}async countFilter(t,e,s=!1){let n=0;return await this.each(t,async(t,i,a)=>{await e(t,a)&&(n++,s&&a()),i()}),n}close(){this.IsReady&&(this.dispatchEvent(new Event("close")),this.DB.close(),this.IsReady=!1)}static PolyfillCompalibity(){"indexedDB"in window&&(e.Engine=window.indexedDB),"mozIndexedDB"in window&&(e.Engine=window.mozIndexedDB),"webkitIndexedDB"in window&&(e.Engine=window.webkitIndexedDB),"msIndexedDB"in window&&(e.Engine=window.msIndexedDB)}}class s{constructor(t){this.result={then:[],catch:[],finally:[]},this.events={then:[],catch:[],finally:[]},t.onerror=t=>{this.result.catch=[t.target,t],this.events.catch.forEach(e=>{e.call(t.target,t.target?.result)}),this.events.finally.forEach(e=>{e.call(t.target,t.target?.result)})},t.onsuccess=t=>{this.result.then=[t.target,t],this.events.then.forEach(e=>{e.call(t.target,t.target?.result)})}}sync(){return new Promise((t,e)=>{this.then(t),this.catch(e)})}then(t){this.result.then.length?t.call(this.result.then[0],this.result.then[1]):this.events.then.push(t)}catch(t){this.result.catch.length?t.call(this.result.catch[0],this.result.catch[1]):this.events.catch.push(t)}finally(t){this.result.finally.length?t.call(this.result.finally[0],this.result.finally[1]):this.events.finally.push(t)}}window.IndexedDB=e})();
//# sourceMappingURL=IndexedDB.js.map

File diff suppressed because one or more lines are too long

6994
video.en.vtt Normal file

File diff suppressed because it is too large Load Diff

18
video.tr.vtt Normal file
View File

@ -0,0 +1,18 @@
WEBVTT
Kind: captions
Language: tr
00:00:00.000 --> 00:00:04.240 position:100% align:center size:35%
Abdussamed ULUTAŞ sunar
00:00:04.000 --> 00:00:05.000 position:100% align:center size:35%
Alt yazı 1
00:00:05.000 --> 00:00:06.000 position:100% align:center size:35%
Alt yazı 2
00:00:06.000 --> 00:00:07.000 position:100% align:center size:35%
Alt yazı 3
00:00:07.000 --> 00:00:08.000 position:100% align:center size:35%
Alt yazı 4

BIN
video.webm Normal file

Binary file not shown.