Mobile app PoC (#281)

Initial checkin of mobile "native" app
This commit is contained in:
Zef Hemel
2023-01-08 12:24:12 +01:00
committed by GitHub
parent dc7de9d8f9
commit 0365673c41
61 changed files with 5190 additions and 155 deletions
+38
View File
@@ -0,0 +1,38 @@
import type {
SandboxFetchRequest,
SandboxFetchResponse,
} from "../../plug-api/plugos-syscall/fetch.ts";
import { base64Encode } from "../asset_bundle/base64.ts";
import { SysCallMapping } from "../system.ts";
export async function sandboxFetch(
url: string,
req?: SandboxFetchRequest,
): Promise<SandboxFetchResponse> {
const result = await fetch(
url,
req && {
method: req.method,
headers: req.headers,
},
);
const body = await (await result.blob()).arrayBuffer();
return {
ok: result.ok,
status: result.status,
headers: Object.fromEntries(result.headers.entries()),
base64Body: base64Encode(new Uint8Array(body)),
};
}
export function sandboxFetchSyscalls(): SysCallMapping {
return {
"sandboxFetch.fetch": (
_ctx,
url: string,
options?: SandboxFetchRequest,
): Promise<SandboxFetchResponse> => {
return sandboxFetch(url, options);
},
};
}
+3 -3
View File
@@ -1,9 +1,9 @@
import { FullTextSearchOptions } from "../../plug-api/plugos-syscall/fulltext.ts";
import { AsyncSQLite } from "../../plugos/sqlite/async_sqlite.ts";
import { ISQLite } from "../sqlite/sqlite_interface.ts";
import { SysCallMapping } from "../system.ts";
export async function ensureFTSTable(
db: AsyncSQLite,
db: ISQLite,
tableName: string,
) {
const result = await db.query(
@@ -20,7 +20,7 @@ export async function ensureFTSTable(
}
export function fullTextSearchSyscalls(
db: AsyncSQLite,
db: ISQLite,
tableName: string,
): SysCallMapping {
return {
+1 -1
View File
@@ -1,7 +1,7 @@
import { assertEquals } from "../../test_deps.ts";
import { createSandbox } from "../environments/deno_sandbox.ts";
import { System } from "../system.ts";
import { ensureTable, storeSyscalls } from "./store.deno.ts";
import { ensureTable, storeSyscalls } from "./store.sqlite.ts";
import { AsyncSQLite } from "../sqlite/async_sqlite.ts";
Deno.test("Test store", async () => {
@@ -1,4 +1,4 @@
import { AsyncSQLite } from "../sqlite/async_sqlite.ts";
import { ISQLite } from "../sqlite/sqlite_interface.ts";
import { SysCallMapping } from "../system.ts";
export type Item = {
@@ -12,7 +12,7 @@ export type KV = {
value: any;
};
export async function ensureTable(db: AsyncSQLite, tableName: string) {
export async function ensureTable(db: ISQLite, tableName: string) {
const result = await db.query(
`SELECT name FROM sqlite_master WHERE type='table' AND name=?`,
tableName,
@@ -72,7 +72,7 @@ export function queryToSql(
}
export function storeSyscalls(
db: AsyncSQLite,
db: ISQLite,
tableName: string,
): SysCallMapping {
const apiObj: SysCallMapping = {