qr codes are ... STILL ... working

cordova
Valerie 2022-07-25 21:23:40 -04:00
parent 00f6ecae52
commit 0be5d1b3dd
21 changed files with 683 additions and 103 deletions

View File

@ -21,7 +21,8 @@
"ignorePatterns": [
"node_modules/**",
"**/dist/**",
"cordova/**"
"cordova/**",
"scripts/**"
],
"rules": {
"@typescript-eslint/no-unused-vars": "error",

View File

@ -1,21 +0,0 @@
import {resolve, sep} from 'path';
export default {
'*.{js,ts,tsx}': 'eslint --cache --fix',
/**
* Run typechecking if any type-sensitive files was staged
* @param {string[]} filenames
* @return {string[]}
*/
'packages/**/{*.ts,*.vue,tsconfig.json}': ({filenames}) => {
const pathToPackages = resolve(process.cwd(), 'packages') + sep;
return Array.from(
filenames.reduce((set, filename) => {
const pack = filename.replace(pathToPackages, '').split(sep)[0];
set.add(`npm run typecheck:${pack} --if-present`);
return set;
}, new Set),
);
},
};

View File

@ -9,7 +9,8 @@
"version": "1.0.0",
"license": "Apache-2.0",
"dependencies": {
"cordova": "^11.0.0"
"cordova": "^11.0.0",
"cordova-plugin-qrscanner-mm": "^4.0.3"
},
"devDependencies": {
"cordova-android": "^10.1.2"
@ -1232,6 +1233,15 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/cordova-plugin-qrscanner-mm": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/cordova-plugin-qrscanner-mm/-/cordova-plugin-qrscanner-mm-4.0.3.tgz",
"integrity": "sha512-C3RoycI66tzx3X3TQlH08x5k2VMbBzK77+e7HpeYTR+93rAZuDsnkWoEl09MHnZhHLKpRuR6hEf77obkNAzk4A==",
"dependencies": {
"qrcode-reader": "^1.0.4",
"webrtc-adapter": "^3.1.4"
}
},
"node_modules/cordova-serve": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/cordova-serve/-/cordova-serve-4.0.0.tgz",
@ -3719,6 +3729,11 @@
"teleport": ">=0.2.0"
}
},
"node_modules/qrcode-reader": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/qrcode-reader/-/qrcode-reader-1.0.4.tgz",
"integrity": "sha512-rRjALGNh9zVqvweg1j5OKIQKNsw3bLC+7qwlnead5K/9cb1cEIAGkwikt/09U0K+2IDWGD9CC6SP7tHAjUeqvQ=="
},
"node_modules/qs": {
"version": "6.10.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
@ -4104,6 +4119,11 @@
"resolved": "https://registry.npmjs.org/sax/-/sax-1.1.4.tgz",
"integrity": "sha512-5f3k2PbGGp+YtKJjOItpg3P99IMD84E4HOvcfleTb5joCHNXYLsR9yWFPOYGgaeMPDubQILTCMdsFb2OMeOjtg=="
},
"node_modules/sdp": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/sdp/-/sdp-1.5.4.tgz",
"integrity": "sha512-9x0+fpJHW2bbqtIktmL+H9m+BswgurPVPhWrur4cCZPDWDSsdGYvRBaKhDXlnNCD1b/Xi8cOTG2u703CTQuwgg=="
},
"node_modules/semver": {
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
@ -4812,6 +4832,18 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ=="
},
"node_modules/webrtc-adapter": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-3.4.3.tgz",
"integrity": "sha512-rz+SxzIEuHDbyTKhYffLmzSGX6+D/pOwoXKzS1pbR2PmMhBQTXCd7aYVhSoCcTHRcmcAR3OsFE8pbYFdy1qjbQ==",
"dependencies": {
"sdp": "^1.5.0"
},
"engines": {
"node": ">=6.0.0",
"npm": ">=3.10.0"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -5979,6 +6011,15 @@
}
}
},
"cordova-plugin-qrscanner-mm": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/cordova-plugin-qrscanner-mm/-/cordova-plugin-qrscanner-mm-4.0.3.tgz",
"integrity": "sha512-C3RoycI66tzx3X3TQlH08x5k2VMbBzK77+e7HpeYTR+93rAZuDsnkWoEl09MHnZhHLKpRuR6hEf77obkNAzk4A==",
"requires": {
"qrcode-reader": "^1.0.4",
"webrtc-adapter": "^3.1.4"
}
},
"cordova-serve": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/cordova-serve/-/cordova-serve-4.0.0.tgz",
@ -7850,6 +7891,11 @@
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
"integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw=="
},
"qrcode-reader": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/qrcode-reader/-/qrcode-reader-1.0.4.tgz",
"integrity": "sha512-rRjALGNh9zVqvweg1j5OKIQKNsw3bLC+7qwlnead5K/9cb1cEIAGkwikt/09U0K+2IDWGD9CC6SP7tHAjUeqvQ=="
},
"qs": {
"version": "6.10.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
@ -8125,6 +8171,11 @@
"resolved": "https://registry.npmjs.org/sax/-/sax-1.1.4.tgz",
"integrity": "sha512-5f3k2PbGGp+YtKJjOItpg3P99IMD84E4HOvcfleTb5joCHNXYLsR9yWFPOYGgaeMPDubQILTCMdsFb2OMeOjtg=="
},
"sdp": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/sdp/-/sdp-1.5.4.tgz",
"integrity": "sha512-9x0+fpJHW2bbqtIktmL+H9m+BswgurPVPhWrur4cCZPDWDSsdGYvRBaKhDXlnNCD1b/Xi8cOTG2u703CTQuwgg=="
},
"semver": {
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
@ -8662,6 +8713,14 @@
}
}
},
"webrtc-adapter": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-3.4.3.tgz",
"integrity": "sha512-rz+SxzIEuHDbyTKhYffLmzSGX6+D/pOwoXKzS1pbR2PmMhBQTXCd7aYVhSoCcTHRcmcAR3OsFE8pbYFdy1qjbQ==",
"requires": {
"sdp": "^1.5.0"
}
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",

View File

@ -16,10 +16,14 @@
"cordova": {
"platforms": [
"android"
]
],
"plugins": {
"cordova-plugin-qrscanner": {}
}
},
"dependencies": {
"cordova": "^11.0.0"
"cordova": "^11.0.0",
"cordova-plugin-qrscanner-mm": "^4.0.3"
},
"devDependencies": {
"cordova-android": "^10.1.2"

27
cordova/www/app.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,8 +26,8 @@
}
</style>
</head>
<body style="margin: 0px; overflow: hidden; color: #f8f8f2; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif">
<div id="app" style="width: 100vw; height: 100vh; background: #282a36"></div>
<body style="margin: 0px; overflow: hidden;">
<div id="app" style="width: 100vw; height: 100vh;"></div>
<script src="cordova.js"></script>
<script src="index.js"></script>

335
package-lock.json generated
View File

@ -8,6 +8,7 @@
"hasInstallScript": true,
"dependencies": {
"@types/mysql": "^2.15.21",
"@types/qrcode": "^1.4.2",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/react-timeago": "^4.1.3",
@ -20,8 +21,10 @@
"express": "^4.18.1",
"get-port": "^6.1.2",
"mysql": "^2.18.1",
"qrcode": "^1.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0",
"react-time-ago": "^7.2.1",
"react-timeago": "^7.1.0",
"uuid": "^8.3.2",
@ -1053,6 +1056,14 @@
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
},
"node_modules/@types/qrcode": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.4.2.tgz",
"integrity": "sha512-7uNT9L4WQTNJejHTSTdaJhfBSCN73xtXaHFyBJ8TSwiLhe4PRuTue7Iph0s2nG9R/ifUaSnGhLUOZavlBEqDWQ==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
@ -3521,6 +3532,14 @@
}
}
},
"node_modules/decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/decompress-response": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz",
@ -3654,6 +3673,11 @@
"dev": true,
"optional": true
},
"node_modules/dijkstrajs": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.2.tgz",
"integrity": "sha512-QV6PMaHTCNmKSeP6QoXhVTw9snc9VD8MulTT0Bd99Pacp4SS1cjcrYPgBPmibqKVtMJJfqC6XvOXgPMEEPH/fg=="
},
"node_modules/dir-compare": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-2.4.0.tgz",
@ -4123,6 +4147,11 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
},
"node_modules/encode-utf8": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz",
"integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw=="
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@ -5455,7 +5484,6 @@
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
@ -8154,6 +8182,14 @@
"node": ">=4.0"
}
},
"node_modules/pngjs": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
"integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@ -8316,6 +8352,134 @@
"teleport": ">=0.2.0"
}
},
"node_modules/qrcode": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.1.tgz",
"integrity": "sha512-nS8NJ1Z3md8uTjKtP+SGGhfqmTCs5flU/xR623oI0JX+Wepz9R8UrRVCTBTJm3qGw3rH6jJ6MUHjkDx15cxSSg==",
"dependencies": {
"dijkstrajs": "^1.0.1",
"encode-utf8": "^1.0.3",
"pngjs": "^5.0.0",
"yargs": "^15.3.1"
},
"bin": {
"qrcode": "bin/qrcode"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/qrcode/node_modules/camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
"engines": {
"node": ">=6"
}
},
"node_modules/qrcode/node_modules/cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"node_modules/qrcode/node_modules/find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"dependencies": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"dependencies": {
"p-locate": "^4.1.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"dependencies": {
"p-limit": "^2.2.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="
},
"node_modules/qrcode/node_modules/yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"dependencies": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
},
"engines": {
"node": ">=8"
}
},
"node_modules/qrcode/node_modules/yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"dependencies": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/qs": {
"version": "6.10.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
@ -8435,6 +8599,14 @@
"react": "^18.2.0"
}
},
"node_modules/react-icons": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.4.0.tgz",
"integrity": "sha512-fSbvHeVYo/B5/L4VhB7sBA1i2tS8MkT0Hb9t2H1AVPkwGfVHLJCqyr2Py9dKMxsyM63Eng1GkdZfbWj+Fmv8Rg==",
"peerDependencies": {
"react": "*"
}
},
"node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
@ -8702,7 +8874,6 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=",
"dev": true,
"engines": {
"node": ">=0.10.0"
}
@ -8715,6 +8886,11 @@
"node": ">=0.10.0"
}
},
"node_modules/require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"node_modules/resolve": {
"version": "1.22.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
@ -10439,6 +10615,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q=="
},
"node_modules/wide-align": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",
@ -11463,6 +11644,14 @@
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
},
"@types/qrcode": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.4.2.tgz",
"integrity": "sha512-7uNT9L4WQTNJejHTSTdaJhfBSCN73xtXaHFyBJ8TSwiLhe4PRuTue7Iph0s2nG9R/ifUaSnGhLUOZavlBEqDWQ==",
"requires": {
"@types/node": "*"
}
},
"@types/qs": {
"version": "6.9.7",
"resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz",
@ -13323,6 +13512,11 @@
"ms": "2.1.2"
}
},
"decamelize": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
"integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA=="
},
"decompress-response": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz",
@ -13421,6 +13615,11 @@
"dev": true,
"optional": true
},
"dijkstrajs": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.2.tgz",
"integrity": "sha512-QV6PMaHTCNmKSeP6QoXhVTw9snc9VD8MulTT0Bd99Pacp4SS1cjcrYPgBPmibqKVtMJJfqC6XvOXgPMEEPH/fg=="
},
"dir-compare": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-2.4.0.tgz",
@ -13806,6 +14005,11 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
},
"encode-utf8": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz",
"integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw=="
},
"encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@ -14741,8 +14945,7 @@
"get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="
},
"get-func-name": {
"version": "2.0.0",
@ -16737,6 +16940,11 @@
}
}
},
"pngjs": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",
"integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw=="
},
"postcss": {
"version": "8.4.14",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz",
@ -16858,6 +17066,106 @@
"resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz",
"integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw=="
},
"qrcode": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.1.tgz",
"integrity": "sha512-nS8NJ1Z3md8uTjKtP+SGGhfqmTCs5flU/xR623oI0JX+Wepz9R8UrRVCTBTJm3qGw3rH6jJ6MUHjkDx15cxSSg==",
"requires": {
"dijkstrajs": "^1.0.1",
"encode-utf8": "^1.0.3",
"pngjs": "^5.0.0",
"yargs": "^15.3.1"
},
"dependencies": {
"camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
"integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="
},
"cliui": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",
"integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",
"requires": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^6.2.0"
}
},
"find-up": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
"integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
"requires": {
"locate-path": "^5.0.0",
"path-exists": "^4.0.0"
}
},
"locate-path": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
"integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
"requires": {
"p-locate": "^4.1.0"
}
},
"p-locate": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
"integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
"requires": {
"p-limit": "^2.2.0"
}
},
"path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="
},
"wrap-ansi": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",
"integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",
"requires": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
}
},
"y18n": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="
},
"yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"requires": {
"cliui": "^6.0.0",
"decamelize": "^1.2.0",
"find-up": "^4.1.0",
"get-caller-file": "^2.0.1",
"require-directory": "^2.1.1",
"require-main-filename": "^2.0.0",
"set-blocking": "^2.0.0",
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
}
},
"yargs-parser": {
"version": "18.1.3",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",
"integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",
"requires": {
"camelcase": "^5.0.0",
"decamelize": "^1.2.0"
}
}
}
},
"qs": {
"version": "6.10.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
@ -16940,6 +17248,12 @@
"scheduler": "^0.23.0"
}
},
"react-icons": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.4.0.tgz",
"integrity": "sha512-fSbvHeVYo/B5/L4VhB7sBA1i2tS8MkT0Hb9t2H1AVPkwGfVHLJCqyr2Py9dKMxsyM63Eng1GkdZfbWj+Fmv8Rg==",
"requires": {}
},
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
@ -17144,14 +17458,18 @@
"require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=",
"dev": true
"integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I="
},
"require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw=="
},
"require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
"integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg=="
},
"resolve": {
"version": "1.22.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz",
@ -18409,6 +18727,11 @@
"is-symbol": "^1.0.3"
}
},
"which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q=="
},
"wide-align": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",

View File

@ -57,6 +57,7 @@
},
"dependencies": {
"@types/mysql": "^2.15.21",
"@types/qrcode": "^1.4.2",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/react-timeago": "^4.1.3",
@ -69,8 +70,10 @@
"express": "^4.18.1",
"get-port": "^6.1.2",
"mysql": "^2.18.1",
"qrcode": "^1.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0",
"react-time-ago": "^7.2.1",
"react-timeago": "^7.1.0",
"uuid": "^8.3.2",

View File

@ -5,6 +5,7 @@ import {
mkdirSync,
existsSync,
} from 'fs';
import { URL } from 'url';
const appdataPath = process.env.APPDATA || // windows
(process.platform == 'darwin' ?
@ -13,6 +14,7 @@ const appdataPath = process.env.APPDATA || // windows
const cornerDataPath = resolve(appdataPath, 'corner');
const clientIdPath = resolve(cornerDataPath, 'clientId');
const homeServerPath = resolve(cornerDataPath, 'homeServer');
// --- setup ---
@ -40,3 +42,21 @@ export function setClientId(id: string) {
writeFileSync(clientIdPath, id);
return true;
}
export function getHomeServer() {
const url = readFileSync(homeServerPath).toString()
try {
new URL(url);
return url;
} catch(e) {
return null;
}
}
export function setHomeServer(url: string) {
if(url === null) {
writeFileSync(homeServerPath, '');
return null
}
writeFileSync(homeServerPath, url);
}

View File

@ -6,8 +6,8 @@
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Vite App</title>
</head>
<body style="font-size: 1em; margin: 0px; overflow: hidden; color: #f8f8f2; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif">
<div id="app" style="width: 100vw; height: 100vh; background: #282a36"></div>
<body style=" margin: 0px; overflow: hidden;">
<div id="app" style="width: 100vw; height: 100vh;"></div>
<script src="./src/index.tsx" type="module"></script>
</body>
</html>

View File

@ -1,5 +1,7 @@
import * as preload from '#preload';
console.log('#preload', preload);
const functions: any = (function() {
const electron = !!preload.getClientId;
const cordova = 'cordova' in globalThis;
@ -11,7 +13,8 @@ const functions: any = (function() {
if(electron) {
return preload;
} else {
let cid: any = null;
let cid: string | null = null;
let homeServer: string | null = null;
return {
getClientId() {
return cid;
@ -19,10 +22,20 @@ const functions: any = (function() {
setClientId(id: any) {
cid = id;
},
getHomeServer() {
return homeServer;
},
setHomeServer(str: string) {
homeServer = str;
}
};
}
})();
console.log('native functions loaded', functions);
export const getClientId = functions.getClientId;
export const setClientId = functions.setClientId;
export const getHomeServer = functions.getHomeServer;
export const setHomeServer = functions.setHomeServer;

View File

@ -1,24 +1,59 @@
import { createContext, useEffect, useState } from 'react';
import { createContext, useCallback, useEffect, useState, useMemo } from 'react';
import Channels from './Channels';
import Chat from './Chat';
import { getClientId, setClientId } from '../lib/native';
import {
getClientId,
setClientId,
getHomeServer,
setHomeServer
} from '../lib/native';
import { useApi } from '../lib/useApi';
import Sidebar from '../components/Sidebar';
import NewAccount from './NewAccount';
export const channelContext = createContext<{
export const ChannelContext = createContext<{
channel: string | null,
setChannel: (uid: string) => void
}>({
channel: null,
setChannel: () => {},
});
export const clientIdContext = createContext<string | null>(null);
export const ClientIdContext = createContext<{
clientId: string | null,
setClientId: (id: string | null) => void
}>({
clientId: null,
setClientId: () => {}
});
export const HomeServerContext = createContext<{
homeServer: string | null,
setHomeServer: (uid: string | null) => void
}>({
homeServer: null,
setHomeServer: () => {}
});
export const TransparencyContext = createContext<(transparent: boolean) => void>(() => {});
export default function App() {
const [channel, setChannel] = useState<string | null>(null);
const [clientId, setCachedClientId] = useState(getClientId());
const channelContextValue = { channel, setChannel };
const [homeServer, setCachedHomeServer] = useState<string | null>(getHomeServer());
const channelContextValue = { channel, setChannel }
const [transparent, setTransparent] = useState(false);
const setHomeServerCallback = useCallback((url: string | null) => {
console.log('SETTING HOME SERVER', url)
setHomeServer(url);
setCachedHomeServer(getHomeServer());
}, [homeServer]);
const homeServerContextValue = useMemo(() => {
return {
homeServer,
setHomeServer: setHomeServerCallback
};
}, [homeServer, setHomeServerCallback])
// persist given clientId to disk
useEffect(() => {
@ -37,9 +72,36 @@ export default function App() {
send('client:new');
}, [clientId]);
const clientIdContextValue = { clientId, setClientId: setCachedClientId };
// font-size: 16px;
// font-family: 'Lato', sans-serif;
// font-family: 'Red Hat Text', sans-serif;
// font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
// color: #f8f8f2;
// background: #282a36;
return (
<clientIdContext.Provider value={clientId}>
<channelContext.Provider value={channelContextValue}>
<ClientIdContext.Provider value={clientIdContextValue}>
<ChannelContext.Provider value={channelContextValue}>
<HomeServerContext.Provider value={homeServerContextValue}>
<TransparencyContext.Provider value={setTransparent}>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin='' />
<link href={"https://fonts.googleapis.com/css2?family=Fira+Sans&family=Josefin+Sans&family=Lato&family=Radio+Canada&family=Readex+Pro&family=Red+Hat+Text&family=Rubik&family=Signika&family=Telex&display=swap"} rel="stylesheet" />
<div style={{
background: transparent ? 'rgba(0, 0, 0, 0)' : '#282a36',
color: transparent ? 'black' : '#f8f8f2',
fontSize: '16px',
fontFamily: "'Red Hat Text', sans-serif",
width: '100%',
height: '100%'
}}>
{homeServer === null && (
<NewAccount></NewAccount>
) || (
<Sidebar
threshold={800}
sidebar={300}
@ -47,21 +109,11 @@ export default function App() {
<Channels></Channels>
<Chat></Chat>
</Sidebar>
{/* <div style={{
display: 'grid',
gridTemplateColumns: '200px 1fr',
gridTemplateRows: '1fr',
height: '100%',
}}>
<div style={{
background: '#21222c',
borderRight: '1px solid #bd93f9',
}}>
)}
</div>
<div>
</div>
</div> */}
</channelContext.Provider>
</clientIdContext.Provider>
</TransparencyContext.Provider>
</HomeServerContext.Provider>
</ChannelContext.Provider>
</ClientIdContext.Provider>
);
}

View File

@ -1,8 +1,9 @@
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
import { channelContext, clientIdContext } from './App';
import { ChannelContext, ClientIdContext, HomeServerContext } from './App';
import { useApi } from '../lib/useApi';
import type { IMessage } from './Message';
import NameTextbox from './NameTextbox';
import LoginQR from './LoginQR';
interface IChannel {
uid: string;
@ -26,8 +27,10 @@ export default function Channels() {
const [channels, setChannels] = useState<IChannel[]>([]);
const [unreads, setUnreads] = useState<IUnreads>({});
const {channel, setChannel} = useContext(channelContext);
const clientId = useContext(clientIdContext);
const { channel, setChannel } = useContext(ChannelContext);
const { clientId } = useContext(ClientIdContext);
const { setHomeServer } = useContext(HomeServerContext);
const { send } = useApi({
'channels:list'(data: IChannel[]) {
@ -56,8 +59,10 @@ export default function Channels() {
}, [channels]);
useEffect(() => {
console.log(channel, channels);
if(channels.length === 0) return;
if(channel !== null) return;
console.log('this is what setChannel is', setChannel);
setChannel(channels[0].uid);
}, [channel, channels]);
@ -135,7 +140,9 @@ export default function Channels() {
borderRadius: '8px',
// lineHeight: '20px'
}}>ADD</button>
<NameTextbox></NameTextbox>
<NameTextbox></NameTextbox><br></br>
<button onClick={() => setHomeServer(null)}>leave</button><br></br>
<LoginQR></LoginQR>
</div>
);
}

View File

@ -1,9 +1,10 @@
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
import { v4 } from 'uuid';
import { useApi } from '../lib/useApi';
import { channelContext, clientIdContext } from './App';
import { ChannelContext, ClientIdContext } from './App';
import type { IMessage} from './Message';
import { Message } from './Message';
import { MdSend } from 'react-icons/md'
function createMessage(from: string, text: string,
channel: string, t = 0): IMessage {
@ -20,10 +21,13 @@ export default () => {
const [messages, setMessages] = useState<IMessage[]>([]);
const [hist, setHist] = useState(false);
const CHATBOX_SIZE = 64;
const PADDING = 8;
const textBoxRef = useRef<HTMLDivElement>(null);
const { channel, setChannel } = useContext(channelContext);
const clientId = useContext(clientIdContext);
const { channel, setChannel } = useContext(ChannelContext);
const { clientId } = useContext(ClientIdContext);
const { send } = useApi({
'message:message'(data: IMessage) {
@ -68,8 +72,8 @@ export default () => {
height: '100%',
width: '100%',
display: 'grid',
gridTemplateColumns: '1fr 64px',
gridTemplateRows: '1fr 64px',
gridTemplateColumns: `1fr ${CHATBOX_SIZE}px`,
gridTemplateRows: `1fr ${CHATBOX_SIZE}px`,
gridTemplateAreas: '"content content" "message send"',
}}
>
@ -77,6 +81,7 @@ export default () => {
// borderBottom: '1px solid #bd93f9',
gridArea: 'content',
position: 'relative',
// borderBottom: '1px solid white'
}}>
<div style={{
position: 'absolute',
@ -91,9 +96,9 @@ export default () => {
<div onClick={() => {
textBoxRef.current?.focus();
}}style={{
margin: '8px',
marginRight: '3px',
borderRadius: '8px',
margin: PADDING + 'px',
marginRight: '0px',
borderRadius: ((CHATBOX_SIZE - PADDING*2) / 2) + 'px',
background: '#343746',
gridArea: 'message',
display: 'grid',
@ -112,9 +117,11 @@ export default () => {
background: 'inherit',
outline: 'none',
boxSizing: 'border-box',
borderRadius: '8px',
// borderRadius: '8px',
// borderRadius: '50%',
width: '100%',
resize: 'none',
// border: '1px solid white',
}}
></div>
</div>
@ -128,14 +135,14 @@ export default () => {
background: '#bd93f9',
width: '100%',
height: '100%',
// borderRadius: '50%',
borderRadius: '8px',
borderRadius: '50%',
// borderRadius: '8px',
cursor: 'pointer',
display: 'grid',
placeItems: 'center center',
fontSize: '32px',
}}>
<MdSend></MdSend>
</div>
</div>
</div>

View File

@ -0,0 +1,19 @@
import { useContext, useEffect, useState } from "react";
import { ClientIdContext, HomeServerContext } from "./App";
import QR from 'qrcode';
export default function() {
const { homeServer } = useContext(HomeServerContext);
const { clientId } = useContext(ClientIdContext);
const [qr, setQr] = useState<string | null>(null);
useEffect(() => {
(async () => {
setQr(await QR.toDataURL(
'loginv1|' + homeServer + '|' + clientId
));
})()
}, [clientId, homeServer])
return <img src={qr ?? undefined} />
}

View File

@ -37,7 +37,7 @@ export function Message({
}}>
<TimeAgo
date={message.timestamp}
formatter={(t, u) => u === 'second' ? 'Just Now' : ('' + t + u[0])}
formatter={(t, u) => u === 'second' ? 'Now' : ('' + t + u[0])}
></TimeAgo>
</span>
<span style={{

View File

@ -5,12 +5,12 @@ import {
useRef,
useState,
} from 'react';
import { clientIdContext } from './App';
import { ClientIdContext } from './App';
import { useApi } from '../lib/useApi';
export default function NameTextbox() {
const clientId = useContext(clientIdContext);
const { clientId } = useContext(ClientIdContext);
const [name, setName] = useState<string | null>(null);
const [inputElement, setInputElement] = useState<HTMLInputElement | null>(null);

View File

@ -0,0 +1,78 @@
import { useEffect, useState } from "react";
import { useCallback, useContext, useRef } from "react"
import { ClientIdContext, HomeServerContext, TransparencyContext } from "./App"
export default function NewAccount() {
const [data, setData] = useState('');
const [scanning, setScanning] = useState(false);
const inputRef = useRef<HTMLInputElement>(null);
const { setHomeServer } = useContext(HomeServerContext);
const { setClientId } = useContext(ClientIdContext);
const setTransparent = useContext(TransparencyContext);
useEffect(() => {
setTransparent(scanning);
}, [scanning, setTransparent]);
const go = useCallback(() => {
if(inputRef.current === null) return;
setHomeServer(inputRef.current.value)
}, [HomeServerContext]);
const scanQr = useCallback(() => {
//@ts-ignore
window.QRScanner.prepare((err: any, status: any) => {
if(!err && status.authorized) {
setScanning(true);
//@ts-ignore
window.QRScanner.hide();
//@ts-ignore
window.QRScanner.scan((err, text) => {
if (err) return alert(err);
// alert(text);
setData(text);
setScanning(false);
//@ts-ignore
window.QRScanner.show();
});
}
});
}, [data]);
useEffect(() => {
// this avoids a timing issue whereby the component
// gets removed before it has a chance to clean up
// its setting of transparency...
if(scanning) return;
if(!data) return;
const [action, homeServer, clientId] = data.split('|');
switch(action) {
case 'loginv1': {
setHomeServer(homeServer);
setClientId(clientId);
break;
}
}
}, [data, scanning])
return <div style={{
display: 'grid',
placeContent: 'center center',
height: '100%',
}}>
Create New Account!! <br />
Enter Home Server URL <br />
<input defaultValue="wss://dev.valnet.xyz" ref={inputRef}></input> <br />
<button onClick={go}> GO </button> <br />
<br />
or scan a QR! <br />
<button onClick={scanQr}>SCAN</button><br></br>
<pre>
{data}
{scanning ? 'SCANNING' : 'NOT SCANNING'}
</pre>
</div>
}

View File

@ -40,7 +40,9 @@ const config = {
environment: 'happy-dom',
},
plugins: [
react(),
react({
fastRefresh: false
}),
renderer.vite({
preloadEntry: join(PACKAGE_ROOT, '../preload/src/index.ts'),
}),

View File

@ -16,6 +16,12 @@ files.forEach(file => {
copyFileSync(resolve('./packages/renderer/dist/', file), './cordova/www/app.js');
});
execSync('npm run cordova run', {
try {
const proc = execSync('npm run cordova run', {
cwd: resolve('./cordova'),
});
} catch(e) {
console.log(e.output.toString());
}
// console.log(proc.toString());