Revert "Typescript (#92)"

This reverts commit 71c65efa206c6d6f896f4dbcc7a0bfaf74534667.
This commit is contained in:
Roland Osborne 2024-05-02 15:21:20 -07:00
parent 8e6f1087e4
commit 3b7de54be8
244 changed files with 7124 additions and 2123 deletions

3
.gitignore vendored
View File

@ -14,6 +14,3 @@
# Dependency directories (remove the comment below to include it)
# vendor/
node_modules
.DS_Store
dist

6
net/web/babel.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
presets: [
'@babel/preset-env',
['@babel/preset-react', {runtime: 'automatic'}],
],
};

View File

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="theme-color" content="#000000" />
<meta
name="Databag"
content="Communication for the Decentralized Web"
/>
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
<title>Databag</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>

View File

@ -1,12 +0,0 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
preset: 'ts-jest',
testEnvironment: 'jsdom',
modulePaths: ['<rootDir>/src/'],
testMatch: ['**/test/**'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/mock/fileMock.js',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
// "(.*)": "<rootDir>/src/$1",
},
};

6
net/web/jsconfig.json Normal file
View File

@ -0,0 +1,6 @@
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}

View File

@ -2,7 +2,19 @@
"name": "databag",
"version": "0.1.0",
"private": true,
"type": "module",
"jest": {
"testEnvironment": "jsdom",
"modulePaths": [
"<rootDir>/src/"
],
"testMatch": [
"**/test/**"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/mock/fileMock.js",
"\\.(css|less|scss|sass)$": "identity-obj-proxy"
}
},
"dependencies": {
"@charliewilco/gluejar": "^1.0.0",
"@testing-library/jest-dom": "^5.14.1",
@ -21,13 +33,15 @@
"react-image-file-resizer": "^0.4.8",
"react-resize-detector": "^7.0.0",
"react-router-dom": "^6.2.2",
"react-scripts": "5.0.0",
"styled-components": "^5.3.3",
"web-vitals": "^2.1.0"
},
"scripts": {
"start": "vite",
"build": "vite build",
"test": "jest"
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
@ -48,25 +62,14 @@
]
},
"devDependencies": {
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@testing-library/dom": "^8.19.1",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.5.12",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"babel-jest": "^29.3.1",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"react-test-renderer": "^18.2.0",
"ts-jest": "^29.1.2",
"typescript": "^5.4.5",
"vite": "^5.2.0",
"vite-tsconfig-paths": "^4.3.2"
"react-test-renderer": "^18.2.0"
}
}

43
net/web/public/index.html Normal file
View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="theme-color" content="#000000" />
<meta
name="Databag"
content="Communication for the Decentralized Web"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Databag</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

View File

@ -13,7 +13,7 @@ export function useAdmin() {
placeholder: '',
unclaimed: null,
busy: false,
strings: {} as Record<string, string>,
strings: {},
menuStyle: {},
});

View File

@ -14,7 +14,7 @@ export function useCreateAccount() {
busy: false,
validatetatus: 'success',
help: '',
strings: {} as Record<string,string>,
strings: {},
menuStyle: {},
});

View File

@ -13,7 +13,7 @@ export function useLogin() {
availableSet: false,
disabled: true,
busy: false,
strings: {} as Record<string,string>,
strings: {},
menuStyle: {},
});

View File

@ -13,7 +13,7 @@ export function useAccess() {
themes: [],
language: null,
languages: [],
strings: {} as Record<string,string>,
strings: {},
});
const navigate = useNavigate();
@ -32,7 +32,7 @@ export function useAccess() {
}, [app.state, navigate]);
useEffect(() => {
let params = new URLSearchParams(location+"");
let params = new URLSearchParams(location);
let token = params.get("access");
if (token) {
const access = async () => {

View File

@ -12,17 +12,17 @@ export function checkResponse(response) {
}
}
export async function fetchWithTimeout(url, options):Promise<Response> {
export async function fetchWithTimeout(url, options) {
return Promise.race([
fetch(url, options).catch(err => { throw new Error(url + ' failed'); }),
new Promise<Response>((_, reject) => setTimeout(() => reject(new Error(url + ' timeout')), TIMEOUT))
new Promise((_, reject) => setTimeout(() => reject(new Error(url + ' timeout')), TIMEOUT))
]);
}
export async function fetchWithCustomTimeout(url, options, timeout):Promise<Response> {
export async function fetchWithCustomTimeout(url, options, timeout) {
return Promise.race([
fetch(url, options).catch(err => { throw new Error(url + ' failed'); }),
new Promise<Response>((_, reject) => setTimeout(() => reject(new Error(url + ' timeout')), timeout))
new Promise((_, reject) => setTimeout(() => reject(new Error(url + ' timeout')), timeout))
]);
}

View File

@ -1,6 +1,6 @@
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannels(server, token, viewRevision?, channelRevision?) {
export async function getContactChannels(server, token, viewRevision, channelRevision) {
let host = "";
if (server) {
host = `https://${server}`;

View File

@ -2,21 +2,15 @@ import React, { useState, useEffect, useRef } from 'react';
import { CarouselWrapper } from './Carousel.styled';
import { CloseOutlined } from '@ant-design/icons';
import ReactResizeDetector from 'react-resize-detector';
interface Props {
pad?:any
items?:any
itemRenderer?:any
itemRemove?:any
}
export function Carousel({ pad, items, itemRenderer, itemRemove }:Props) {
export function Carousel({ pad, items, itemRenderer, itemRemove }) {
const [slots, setSlots] = useState([]);
let carousel = useRef<any>();
let carousel = useRef();
const RemoveItem = ({ index }) => {
if (itemRemove) {
return <div className="delitem" onClick={() => itemRemove(index)}><CloseOutlined /></div>
return <div class="delitem" onClick={() => itemRemove(index)}><CloseOutlined /></div>
}
return <></>
}
@ -28,8 +22,8 @@ export function Carousel({ pad, items, itemRenderer, itemRemove }:Props) {
<ReactResizeDetector handleWidth={true} handleHeight={false}>
{({ width, height }) => {
return (
<div className="item noselect">
<div className="asset">{ itemRenderer(items[i], i) }</div>
<div class="item noselect">
<div class="asset">{ itemRenderer(items[i], i) }</div>
<RemoveItem index={i} />
</div>
);
@ -38,14 +32,14 @@ export function Carousel({ pad, items, itemRenderer, itemRemove }:Props) {
));
}
if (items.length > 0) {
assets.push(<div className="space"></div>)
assets.push(<div class="space"></div>)
}
setSlots(assets);
}, [items, itemRenderer]);
return (
<CarouselWrapper>
<div className="carousel" style={{ paddingLeft: pad + 32 }} ref={carousel}>
<div class="carousel" style={{ paddingLeft: pad + 32 }} ref={carousel}>
{slots}
</div>
</CarouselWrapper>

Some files were not shown because too many files have changed in this diff Show More