From d785cb3b6b906e1c3e991dd8c3516e87db870db6 Mon Sep 17 00:00:00 2001 From: orveth Date: Wed, 10 Jun 2026 06:55:16 -0700 Subject: [PATCH] chore: remove the React surface from the SDK (core-only, module settings unchanged) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Delete the React provider/hooks/contexts and the React dev-playground so the default (and only) package entry is react-free. Master's existing single-entry build now naturally yields a core-only package — no module-settings change. Deleted (React library surface): - src/lib/main.tsx (OpenSecretProvider/OpenSecretContext) - src/lib/developer.tsx (OpenSecretDeveloper/OpenSecretDeveloperContext) - src/lib/context.ts (useOpenSecret) - src/lib/developerContext.ts (useOpenSecretDeveloper) - src/lib/util.ts (orphan useOnMount/sleep — nothing imported ./util) Deleted (React dev-playground): - index.html, src/main.tsx, src/App.tsx, src/AI.tsx, src/App.css, src/index.css Edited: - src/lib/index.ts — drop the React re-exports; keep all core exports (api, ai, config, apiConfig, attestation/attestationForView, pcr, crypto) - package.json — drop react/react-dom peers + 5 React devDeps; 0.1.0 -> 0.2.0; main/module/exports/type UNCHANGED (single-entry preserved) - vite.config.ts — drop @vitejs/plugin-react import + react() plugin only - eslint.config.js — drop the removed react-hooks/react-refresh plugin imports Breaking (0.2.0): removes the React provider/hooks. agicash needs no change — it imports only core symbols. Do NOT publish (gudnuf-gated). Co-Authored-By: Claude Opus 4.8 (1M context) --- eslint.config.js | 13 - index.html | 13 - package.json | 11 +- src/AI.tsx | 110 --- src/App.css | 103 --- src/App.tsx | 697 ------------------ src/index.css | 24 - src/lib/context.ts | 28 - src/lib/developer.tsx | 670 ------------------ src/lib/developerContext.ts | 8 - src/lib/index.ts | 18 - src/lib/main.tsx | 1324 ----------------------------------- src/lib/util.ts | 19 - src/main.tsx | 16 - vite.config.ts | 2 - 15 files changed, 1 insertion(+), 3055 deletions(-) delete mode 100644 index.html delete mode 100644 src/AI.tsx delete mode 100644 src/App.css delete mode 100644 src/App.tsx delete mode 100644 src/index.css delete mode 100644 src/lib/context.ts delete mode 100644 src/lib/developer.tsx delete mode 100644 src/lib/developerContext.ts delete mode 100644 src/lib/main.tsx delete mode 100644 src/lib/util.ts delete mode 100644 src/main.tsx diff --git a/eslint.config.js b/eslint.config.js index b783bb4..4bb5395 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,7 +1,5 @@ import js from '@eslint/js' import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' import tseslint from 'typescript-eslint' export default tseslint.config( @@ -13,17 +11,6 @@ export default tseslint.config( ecmaVersion: 2020, globals: globals.browser, }, - plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - rules: { - ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], - }, }, { // Special rules for test files diff --git a/index.html b/index.html deleted file mode 100644 index e4b78ea..0000000 --- a/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Vite + React + TS - - -
- - - diff --git a/package.json b/package.json index f6c2520..c722dbe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@agicash/opensecret-sdk", - "version": "0.1.0", + "version": "0.2.0", "publishConfig": { "access": "public" }, @@ -35,10 +35,6 @@ "docs:clear": "cd website && bun run clear", "docs:deploy": "cd website && bun run deploy" }, - "peerDependencies": { - "react": "^18.0.0 || ^19.0.0", - "react-dom": "^18.0.0 || ^19.0.0" - }, "dependencies": { "@peculiar/x509": "^1.12.2", "@stablelib/base64": "^2.0.0", @@ -53,12 +49,7 @@ "@noble/curves": "^1.6.0", "@noble/hashes": "^1.5.0", "@types/bun": "latest", - "@types/react": "^19.0.0", - "@types/react-dom": "^19.0.0", - "@vitejs/plugin-react": "^4.3.3", "eslint": "^9.13.0", - "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.14", "globals": "^15.11.0", "openai": "^5.20.0", "prettier": "^3.3.3", diff --git a/src/AI.tsx b/src/AI.tsx deleted file mode 100644 index f28e552..0000000 --- a/src/AI.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import { useOpenSecret } from "./lib"; -import { useState, FormEvent } from "react"; -import OpenAI from "openai"; - -type ChatMessage = { - role: "user" | "assistant"; - content: string; -}; - -export function AI() { - const os = useOpenSecret(); - const [query, setQuery] = useState(""); - const [response, setResponse] = useState(""); - const [loading, setLoading] = useState(false); - - const handleSubmit = async (e: FormEvent) => { - e.preventDefault(); - - setLoading(true); - setResponse(""); - - if (!os.auth.user) { - alert("Please log in to use the AI chat."); - return; - } - - const customFetch = os.aiCustomFetch; - - if (!query.trim() || loading || !customFetch) return; - - try { - console.log("Starting chat request to URL:", `${os.apiUrl}/v1/`); - - const openai = new OpenAI({ - baseURL: `${os.apiUrl}/v1/`, - dangerouslyAllowBrowser: true, - apiKey: "api-key-doesnt-matter", - defaultHeaders: { - "Accept-Encoding": "identity", - "Content-Type": "application/json" - }, - fetch: customFetch - }); - - console.log("Created OpenAI client"); - - const model = "hugging-quants/Meta-Llama-3.1-70B-Instruct-AWQ-INT4"; - const messages = [{ role: "user", content: query } as ChatMessage]; - - console.log("Starting stream request"); - const stream = await openai.chat.completions.create({ - model, - messages, - stream: true - }); - - console.log("Stream created successfully"); - - let fullResponse = ""; - for await (const chunk of stream) { - console.log("Received chunk:", chunk); - const content = chunk.choices[0]?.delta?.content || ""; - fullResponse += content; - setResponse(fullResponse); - } - } catch (error) { - console.error("Chat error:", error); - if (error instanceof Error) { - console.error("Error details:", { - message: error.message, - stack: error.stack, - name: error.name - }); - } - setResponse("Error: Failed to get response. " + (error as Error).message); - } finally { - setLoading(false); - } - }; - - if (!os.auth.user) { - return
Please log in to use the AI chat.
; - } - - return ( -
-
- setQuery(e.target.value)} - placeholder="Enter your question..." - className="w-full p-2 border rounded" - disabled={loading} - /> - -
- - {response && ( -
{response}
- )} -
- ); -} diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 4930879..0000000 --- a/src/App.css +++ /dev/null @@ -1,103 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; -} - -.docs-container { - text-align: left; - max-width: 800px; - margin: 0 auto; -} - -section { - margin-bottom: 2rem; -} - -h2 { - margin-top: 0; -} - -p { - margin-bottom: 1.5rem; -} - -.auth-form { - display: flex; - flex-direction: column; - gap: 0.5rem; - max-width: 300px; -} - -.auth-form input { - padding: 0.5rem; - color: inherit; - background: rgba(127, 127, 127, 0.1); - border: 1px solid rgba(127, 127, 127, 0.2); - border-radius: 4px; -} - -button { - padding: 0.5rem; -} - -.data-display { - background: rgba(127, 127, 127, 0.1); - padding: 1rem; - border-radius: 4px; - overflow-x: auto; -} - -.data-display pre { - margin: 0; - white-space: pre-wrap; - word-wrap: break-word; -} - -.json-input { - padding: 0.5rem; - color: inherit; - background: rgba(127, 127, 127, 0.1); - border: 1px solid rgba(127, 127, 127, 0.2); - border-radius: 4px; - font-family: monospace; - resize: vertical; -} - -.api-message { - margin-top: 0.5rem; - padding: 0.5rem; - border-radius: 4px; - background: rgba(127, 127, 127, 0.1); -} - -.grid-container { - display: grid; - grid-template-columns: minmax(min-content, 150px) 1fr minmax(min-content, 120px) minmax( - min-content, - 120px - ); - gap: 1rem; -} - -.grid-header { - font-weight: bold; - border-bottom: 1px solid rgba(127, 127, 127, 0.2); - padding-bottom: 0.5rem; -} - -.grid-item { - padding: 0.5rem 0; - border-bottom: 1px solid rgba(127, 127, 127, 0.1); -} - -.grid-item.value { - max-height: 4.5rem; /* Approx. 4 lines of text */ - overflow-y: auto; - font-family: monospace; -} - -.grid-item.timestamp { - font-size: 0.8rem; - color: rgba(127, 127, 127, 0.7); -} diff --git a/src/App.tsx b/src/App.tsx deleted file mode 100644 index e110afd..0000000 --- a/src/App.tsx +++ /dev/null @@ -1,697 +0,0 @@ -import "./App.css"; -import { useState } from "react"; -import React from "react"; -import { useOpenSecret } from "./lib"; -import type { KVListItem } from "./lib"; -import { schnorr, secp256k1 } from "@noble/curves/secp256k1"; -import { AI } from "./AI"; - -function TokenGenerator() { - const [audience, setAudience] = useState("http://localhost:3001"); - const [token, setToken] = useState(""); - const [error, setError] = useState(""); - const os = useOpenSecret(); - - const generateToken = async () => { - try { - setError(""); - const response = await os.generateThirdPartyToken(audience); - setToken(response.token); - } catch (err) { - setError(err instanceof Error ? err.message : "Failed to generate token"); - } - }; - - return ( -
-
- setAudience(e.target.value)} - placeholder="Enter audience URL" - /> - -
- {error && ( -
- {error} -
- )} - {token && ( -
-

Generated Token:

-