Skip to content

Commit

Permalink
Upgrade things
Browse files Browse the repository at this point in the history
- Upgrade React
- Upgrade javacpp
- Support macos-arm64: bytedeco/javacpp-presets#1069
  • Loading branch information
kevinychen committed Nov 5, 2023
1 parent 9633eb2 commit ceec4f7
Show file tree
Hide file tree
Showing 9 changed files with 5,619 additions and 7,621 deletions.
11 changes: 7 additions & 4 deletions snap-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
"private": true,
"dependencies": {
"classnames": "^2.3.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-github-corner": "^2.5.0",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.3"
"react-router-dom": "^6.18.0",
"react-scripts": "^5.0.1"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11"
},
"scripts": {
"start": "REACT_APP_LOCAL=true react-scripts start",
Expand Down
62 changes: 19 additions & 43 deletions snap-app/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import classNames from "classnames";
import React from 'react';
import ReactDOM from 'react-dom';
import ReactDOM from "react-dom/client";
import GithubCorner from 'react-github-corner';
import {
BrowserRouter as Router,
Redirect,
Switch,
Navigate,
Routes,
Route,
Link
Link,
} from 'react-router-dom';
import FindWords from './findwords';
import Parser from './parser';
Expand Down Expand Up @@ -57,48 +57,24 @@ function Header({ mode }) {
function App() {
return <Router>
<GithubCorner href="https://github.com/kevinychen/snap2" />
<Switch>
<Route path="/parser">
<Header mode="parser" />
<Parser />
</Route>
<Route path="/wordsearch">
<Header mode="wordsearch" />
<Wordsearch />
</Route>
<Route path="/solver">
<Header mode="solver" />
<Solver />
</Route>
<Route path="/findwords">
<Header mode="findwords" />
<FindWords />
</Route>
<Route path="/index.html">
<Redirect to="/" />
</Route>
<Route path="/document.html">
<Redirect to="/parser" />
</Route>
<Route path="/wordsearch.html">
<Redirect to="/wordsearch" />
</Route>
<Route path="/solver.html">
<Redirect to="/solver" />
</Route>
<Route path="/findwords.html">
<Redirect to="/findwords" />
</Route>
<Route path="/">
<Index />
</Route>
</Switch>
<Routes>
<Route path="/parser" element={<><Header mode="parser" /><Parser /></>} />
<Route path="/wordsearch" element={<><Header mode="wordsearch" /><Wordsearch /></>} i/>
<Route path="/solver" element={<><Header mode="solver" /><Solver /></>}/>
<Route path="/findwords" element={<><Header mode="findwords" /><FindWords /></>} />
<Route path="/index.html" element={<Navigate to="/" />} />
<Route path="/document.html" element={<Navigate to="/parser" />} />
<Route path="/wordsearch.html" element={<Navigate to="/wordsearch" />} />
<Route path="/solver.html" element={<Navigate to="/solver" />} />
<Route path="/findwords.html" element={<Navigate to="/findwords" />} />
<Route path="/" element={<Index />} />
</Routes>
</Router>;
}

ReactDOM.render(
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
</React.StrictMode>
);
12 changes: 10 additions & 2 deletions snap-app/src/solver/solver.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import React from "react";
import { withRouter } from "react-router-dom";
import { useNavigate } from "react-router";
import { postJson } from "../fetch";
import "./solver.css";

export const withRouter = Component => {
const Wrapper = props => {
const history = useNavigate();
return <Component history={history} {...props} />;
};
return Wrapper;
};

class Solver extends React.Component {

constructor(props) {
Expand All @@ -18,7 +26,7 @@ class Solver extends React.Component {

componentDidMount() {
window.addEventListener("keyup", this.handleKey);
const searchParams = new URLSearchParams(this.props.location.search);
const searchParams = new URLSearchParams(this.props.location?.search);
if (searchParams.get("r") === '1') {
this.setState({
canRearrange: true
Expand Down
4 changes: 2 additions & 2 deletions snap-app/src/wordsearch/wordsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class Wordsearch extends React.Component {
componentDidMount() {
const hash = window.location.hash.substr(1);
if (hash !== '') {
this.setState({ ...JSON.parse(Buffer.from(hash, 'base64')) }, this.solve);
this.setState({ ...JSON.parse(atob(hash)) }, this.solve);
}
}

Expand Down Expand Up @@ -183,7 +183,7 @@ export default class Wordsearch extends React.Component {

hashLocation() {
const { grid, wordbank, boggle, highlightingAllWordbank, highlightingDifferentColors } = this.state;
window.location.hash = Buffer.from(JSON.stringify({ grid, wordbank, boggle, highlightingAllWordbank, highlightingDifferentColors })).toString('base64');
window.location.hash = btoa(JSON.stringify({ grid, wordbank, boggle, highlightingAllWordbank, highlightingDifferentColors }));
}

hashStringToColor(str) {
Expand Down
Loading

0 comments on commit ceec4f7

Please sign in to comment.