| 
						
						
							
								
							
						
						
					 | 
					@ -7,7 +7,7 @@ import type { DatabaseService, QueryExecResult } from "../interfaces/database"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { logger } from "@/utils/logger"; | 
					 | 
					 | 
					import { logger } from "@/utils/logger"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					interface QueuedOperation { | 
					 | 
					 | 
					interface QueuedOperation { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					  type: "run" | "query" | "getOneRow" | "getAll"; | 
					 | 
					 | 
					  type: "run" | "query"; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					  sql: string; | 
					 | 
					 | 
					  sql: string; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  params: unknown[]; | 
					 | 
					 | 
					  params: unknown[]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  resolve: (value: unknown) => void; | 
					 | 
					 | 
					  resolve: (value: unknown) => void; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -84,7 +84,7 @@ class AbsurdSqlDatabaseService implements DatabaseService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    SQL.FS.mkdir("/sql"); | 
					 | 
					 | 
					    SQL.FS.mkdir("/sql"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    SQL.FS.mount(sqlFS, {}, "/sql"); | 
					 | 
					 | 
					    SQL.FS.mount(sqlFS, {}, "/sql"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    const path = "/sql/timesafari.sqlite"; | 
					 | 
					 | 
					    const path = "/sql/timesafari.absurd-sql"; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    if (typeof SharedArrayBuffer === "undefined") { | 
					 | 
					 | 
					    if (typeof SharedArrayBuffer === "undefined") { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      const stream = SQL.FS.open(path, "a+"); | 
					 | 
					 | 
					      const stream = SQL.FS.open(path, "a+"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      await stream.node.contents.readIfFallback(); | 
					 | 
					 | 
					      await stream.node.contents.readIfFallback(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -133,7 +133,6 @@ class AbsurdSqlDatabaseService implements DatabaseService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      if (!operation) continue; | 
					 | 
					 | 
					      if (!operation) continue; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      try { | 
					 | 
					 | 
					      try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        let queryResult: QueryExecResult[] = []; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        let result: unknown; | 
					 | 
					 | 
					        let result: unknown; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        switch (operation.type) { | 
					 | 
					 | 
					        switch (operation.type) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          case "run": | 
					 | 
					 | 
					          case "run": | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -142,14 +141,6 @@ class AbsurdSqlDatabaseService implements DatabaseService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          case "query": | 
					 | 
					 | 
					          case "query": | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            result = await this.db.exec(operation.sql, operation.params); | 
					 | 
					 | 
					            result = await this.db.exec(operation.sql, operation.params); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            break; | 
					 | 
					 | 
					            break; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          case "getOneRow": | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            queryResult = await this.db.exec(operation.sql, operation.params); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            result = queryResult[0]?.values[0]; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            break; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          case "getAll": | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            queryResult = await this.db.exec(operation.sql, operation.params); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            result = queryResult[0]?.values || []; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            break; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        operation.resolve(result); | 
					 | 
					 | 
					        operation.resolve(result); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      } catch (error) { | 
					 | 
					 | 
					      } catch (error) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -232,19 +223,6 @@ class AbsurdSqlDatabaseService implements DatabaseService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    await this.waitForInitialization(); | 
					 | 
					 | 
					    await this.waitForInitialization(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    return this.queueOperation<QueryExecResult[]>("query", sql, params); | 
					 | 
					 | 
					    return this.queueOperation<QueryExecResult[]>("query", sql, params); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  async getOneRow( | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    sql: string, | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    params: unknown[] = [], | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  ): Promise<unknown[] | undefined> { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    await this.waitForInitialization(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    return this.queueOperation<unknown[] | undefined>("getOneRow", sql, params); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  async getAll(sql: string, params: unknown[] = []): Promise<unknown[][]> { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    await this.waitForInitialization(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    return this.queueOperation<unknown[][]>("getAll", sql, params); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					// Create a singleton instance
 | 
					 | 
					 | 
					// Create a singleton instance
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |