diff --git a/cozo-lib-wasm/wasm-react-demo/.gitignore b/cozo-lib-wasm/wasm-react-demo/.gitignore deleted file mode 100644 index 4d29575d..00000000 --- a/cozo-lib-wasm/wasm-react-demo/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/cozo-lib-wasm/wasm-react-demo/README-zh.md b/cozo-lib-wasm/wasm-react-demo/README-zh.md deleted file mode 100644 index 568b9737..00000000 --- a/cozo-lib-wasm/wasm-react-demo/README-zh.md +++ /dev/null @@ -1,3 +0,0 @@ -# Cozo WASM 示例 - -此示例的展示在 https://www.cozodb.org/wasm-demo/ 。源码供参考。 \ No newline at end of file diff --git a/cozo-lib-wasm/wasm-react-demo/README.md b/cozo-lib-wasm/wasm-react-demo/README.md deleted file mode 100644 index 1b9ce04c..00000000 --- a/cozo-lib-wasm/wasm-react-demo/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Cozo in WASM demo - -This is the source code for the demo at https://www.cozodb.org/wasm-demo/. -It might be helpful if you want to integrate Cozo WASM in your own project. \ No newline at end of file diff --git a/cozo-lib-wasm/wasm-react-demo/deploy.sh b/cozo-lib-wasm/wasm-react-demo/deploy.sh deleted file mode 100755 index 312d66b0..00000000 --- a/cozo-lib-wasm/wasm-react-demo/deploy.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -rm -fr node_modules -rm -fr build -yarn -yarn build -rm -fr ~/cozodb_site/wasm-demo/ -mv build ~/cozodb_site/wasm-demo \ No newline at end of file diff --git a/cozo-lib-wasm/wasm-react-demo/package.json b/cozo-lib-wasm/wasm-react-demo/package.json deleted file mode 100644 index 92d13652..00000000 --- a/cozo-lib-wasm/wasm-react-demo/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "cozo-web", - "version": "0.1.0", - "private": true, - "dependencies": { - "@blueprintjs/core": "^4.12.0", - "@blueprintjs/table": "^4.7.9", - "@testing-library/jest-dom": "^5.16.5", - "@testing-library/react": "^13.4.0", - "@testing-library/user-event": "^13.5.0", - "ansicolor": "^1.1.100", - "cozo-lib-wasm": "file:../pkg", - "file-saver": "^2.0.5", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-scripts": "5.0.1", - "web-vitals": "^2.1.4" - }, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" - }, - "eslintConfig": { - "extends": [ - "react-app", - "react-app/jest" - ] - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - }, - "homepage": "." -} diff --git a/cozo-lib-wasm/wasm-react-demo/public/index.html b/cozo-lib-wasm/wasm-react-demo/public/index.html deleted file mode 100644 index 183c0dea..00000000 --- a/cozo-lib-wasm/wasm-react-demo/public/index.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - Cozo in WASM - - - - - - -
- - - diff --git a/cozo-lib-wasm/wasm-react-demo/src/App.css b/cozo-lib-wasm/wasm-react-demo/src/App.css deleted file mode 100644 index 4093f56b..00000000 --- a/cozo-lib-wasm/wasm-react-demo/src/App.css +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2022, The Cozo Project Authors. - * - * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. - * If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. - */ - - -@import "~normalize.css"; -@import "~@blueprintjs/core/lib/css/blueprint.css"; -@import "~@blueprintjs/icons/lib/css/blueprint-icons.css"; -@import "~@blueprintjs/table/lib/css/table.css"; -#error-message, #other-results { - padding: 10px; - overflow: scroll; - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - font-size: 90%; -} -#query-box, #params-box { - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - font-size: 100%; - min-height: 200px; - max-height: 40vh; - min-width: 200px; -} -#welcome { - padding: 15px; -} \ No newline at end of file diff --git a/cozo-lib-wasm/wasm-react-demo/src/App.js b/cozo-lib-wasm/wasm-react-demo/src/App.js deleted file mode 100644 index 9b7a9158..00000000 --- a/cozo-lib-wasm/wasm-react-demo/src/App.js +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Copyright 2022, The Cozo Project Authors. - * - * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. - * If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -import { - Button, - Checkbox, - Classes, - Colors, - Dialog, - FileInput, - InputGroup, - Intent, - Tag, - TextArea, - Toaster -} from "@blueprintjs/core"; -import { Cell, Column, Table2 } from "@blueprintjs/table"; -import { parse } from "ansicolor"; -import init, { CozoDb } from "cozo-lib-wasm"; -import { saveAs } from 'file-saver'; -import React, { useEffect, useState } from "react"; -import './App.css'; -import { useBlueprintThemeClassName, usePreferredColorScheme } from './hooks/use-color-scheme'; - - -function App() { - const [db, setDb] = useState(null); - const [params, setParams] = useState('{}'); - const [showParams, setShowParams] = useState(false); - const [queryText, setQueryText] = useState(''); - const [inProgress, setInProgress] = useState(false); - const [statusMessage, setStatusMessage] = useState(''); - const [errorMessage, setErrorMessage] = useState([]); - const [queryResults, setQueryResults] = useState(null); - const [queryId, setQueryId] = useState(0); - - useEffect(() => { - init().then(() => { - let db = CozoDb.new(); - setDb(db); - }) - }, []); - - const colorScheme = usePreferredColorScheme(); - useBlueprintThemeClassName(colorScheme); - - const renderCell = (colIdx) => (rowIdx) => - {displayValue(queryResults.rows[rowIdx][colIdx])} - - - function handleKeyDown(e) { - if (e.key === 'Enter' && e.shiftKey) { - e.preventDefault(); - e.stopPropagation(); - handleQuery(); - } - if (e.key === 'Tab' && !e.shiftKey) { - e.preventDefault(); - e.stopPropagation(); - typeInTextarea(' '); - } - } - - function typeInTextarea(newText, el = document.activeElement) { - const [start, end] = [el.selectionStart, el.selectionEnd]; - el.setRangeText(newText, start, end, 'end'); - } - - function displayValue(v) { - if (typeof v === 'string') { - return v - } else { - return {JSON.stringify(v)} - } - } - - function handleQuery() { - if (!db || inProgress) { - setInProgress(false); - setErrorMessage([]); - setStatusMessage(['database not ready']); - setQueryResults(null); - return; - } - setQueryId(queryId + 1); - const query = queryText.trim(); - if (query) { - setInProgress(true); - setErrorMessage([]); - setStatusMessage(''); - setQueryResults(null); - requestAnimationFrame(() => { - setTimeout(() => { - try { - const t0 = performance.now(); - const res_str = db.run(query, params); - const t1 = performance.now(); - const res = JSON.parse(res_str); - if (res.ok) { - setStatusMessage(`finished with ${res.rows.length} rows in ${(t1 - t0).toFixed(1)}ms`); - if (!res.headers) { - res.headers = []; - if (res.rows.length) { - for (let i = 0; i < res.rows[0].length; i++) { - res.headers.push('' + i); - } - } - } - } else { - console.error('Query failed', res); - setStatusMessage(`finished with errors`); - if (res.display) { - const messages = parse(res.display); - setErrorMessage(messages.spans); - } else { - setErrorMessage([res.message]); - } - } - setQueryResults(res); - } catch (e) { - setStatusMessage(`query failed`); - setErrorMessage(['' + e]); - } finally { - setInProgress(false); - } - }, 0) - }) - } - } - - return ( -
-
-
-