diff --git a/client-showcase/.gitignore b/client-showcase/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/client-showcase/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/client-showcase/index.html b/client-showcase/index.html new file mode 100644 index 0000000..d7f9a44 --- /dev/null +++ b/client-showcase/index.html @@ -0,0 +1,15 @@ + + + + + + + epoxy-tls: TLS + HTTP + WebSockets in WASM + + + +
+ + + + diff --git a/client-showcase/package.json b/client-showcase/package.json new file mode 100644 index 0000000..92992c9 --- /dev/null +++ b/client-showcase/package.json @@ -0,0 +1,21 @@ +{ + "name": "client-showcase", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "devDependencies": { + "typescript": "~5.7.3", + "vite": "^6.0.11", + "vite-plugin-dreamland": "^1.2.1", + "vite-plugin-static-copy": "^2.2.0" + }, + "dependencies": { + "@mercuryworkshop/epoxy-tls": "file:../client", + "dreamland": "^0.0.25" + } +} diff --git a/client-showcase/src/demo.tsx b/client-showcase/src/demo.tsx new file mode 100644 index 0000000..5b5d4d8 --- /dev/null +++ b/client-showcase/src/demo.tsx @@ -0,0 +1,351 @@ +import { fetch as epoxyFetch } from "./epoxy"; +import { logger } from "./loggingws"; +import { settings } from "./store"; + +const REQUEST_METHODS = ["GET", "HEAD", "POST", "PUT", "DELETE", "CONNECT", "OPTIONS", "TRACE", "PATCH"]; +const REQUEST_BODY_METHODS = ["POST", "PUT", "CONNECT", "PATCH"]; + +type EpoxyRequest = { + method: string, + url: string, + headers: Record, + body: string, +}; +type EpoxyResponse = { + status: number, + statusText: string, + headers: Record, + body: string, +} + +async function fetchWithEpoxy(req: EpoxyRequest): Promise { + const extra: any = { method: req.method, headers: req.headers, }; + if (req.body) { + extra.body = req.body; + } + const res = await epoxyFetch(req.url, extra); + return { + status: res.status, + statusText: res.statusText, + /* @ts-ignore */ + headers: res.rawHeaders, + body: await res.text(), + }; +} + +const Option: Component<{ value: string }> = function() { + return +} + +const Textarea: Component<{ value: string, id: string, placeholder: string }> = function() { + return