Skip to content

Commit

Permalink
general update
Browse files Browse the repository at this point in the history
  • Loading branch information
icecream17 committed Oct 17, 2021
1 parent 3cf6c58 commit 5cfefe7
Show file tree
Hide file tree
Showing 27 changed files with 44 additions and 147,614 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ yarn-error.log*

# Dependency analytics report
/target/npmlist.json

# copy/paste storage
temp
147,406 changes: 0 additions & 147,406 deletions .yarn/releases/yarn-1.22.11.cjs

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-berry.cjs
yarnPath: .yarn/releases/yarn-3.0.2.cjs
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Note: Many earlier versions are not specified, that's too much work.

When a `@types` dependency updates, they almost always don't affect anything.

## v0.24.11

- (code) Use yarn 3.0.2
- (code / tests) Remove _expect
- (docs) Remove `@requiredProps` and `@optionalProps` in favor of TypeScript

## v0.24.10

- (tests) Allow more time for 1 specific test
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solver",
"version": "0.24.10",
"version": "0.24.11",
"private": true,
"homepage": "https://icecream17.github.io/solver",
"dependencies": {
Expand Down Expand Up @@ -45,5 +45,6 @@
},
"engines": {
"node": ">=15.0.0"
}
},
"packageManager": "[email protected]"
}
14 changes: 7 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type AppState = {
*/
class App extends React.Component<_UnusedProps, AppState> {
sudoku: SudokuData
constructor (props: _UnusedProps) {
constructor(props: _UnusedProps) {
super(props)

/**
Expand Down Expand Up @@ -73,17 +73,17 @@ class App extends React.Component<_UnusedProps, AppState> {
}
}

componentWillUnmount() {
componentWillUnmount () {
window._custom.alert = () => undefined;
window._custom.prompt = () => undefined;
}

componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
componentDidCatch (error: Error, errorInfo: React.ErrorInfo) {
console.error("App crashed", { error, errorInfo });
this.setState({ error: true })
}

render() {
render () {
const classNames = ["App"]
if (this.state.error) {
classNames.push("error")
Expand Down Expand Up @@ -127,7 +127,7 @@ class App extends React.Component<_UnusedProps, AppState> {
// 1. User isn't absolutely blocked
// 2. No more `not implemented` errors in tests

alert(message: string, alertType = AlertType.INFO) {
alert (message: string, alertType = AlertType.INFO) {
this.setState(state => {
const notices = state.notices.slice()
notices.push({
Expand All @@ -140,7 +140,7 @@ class App extends React.Component<_UnusedProps, AppState> {
})
}

prompt(message = "default message (shouldn't appear)", defaultResponse = "", callback?: PromptCallback) {
prompt (message = "default message (shouldn't appear)", defaultResponse = "", callback?: PromptCallback) {
this.setState(state => {
const notices = state.notices.slice()
notices.push({
Expand All @@ -154,7 +154,7 @@ class App extends React.Component<_UnusedProps, AppState> {
})
}

finishNotice() {
finishNotice () {
this.setState(state => {
const notices = state.notices.slice()
notices.shift()
Expand Down
9 changes: 1 addition & 8 deletions src/Elems/Aside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,16 @@ import './Aside.css'
import React from 'react'
import SolverPart from './AsideElems/SolverPart'
import SudokuData from '../Api/Spaces/Sudoku'
import { _expect } from '../utils'
import { _ReactProps } from '../Types'

type AsideProps = Readonly<{
sudoku: SudokuData
}> & _ReactProps

/**
* @requiredProps
* - sudoku
* Will be made of tabs later on
*/
export default class Aside extends React.Component<AsideProps> {
constructor(props: AsideProps) {
_expect(Aside, props).toHaveProperty("sudoku")
super(props)
}

render() {
return (
<section className="App-aside">
Expand Down
7 changes: 1 addition & 6 deletions src/Elems/AsideElems/SolverPart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react'
import Solver from '../../Api/Solver'
import Sudoku from '../../Api/Spaces/Sudoku'
import { StrategyResult } from '../../Api/Types'
import { _expect } from '../../utils'
import StrategyControls from './StrategyControls'
import StrategyList from './StrategyList'

Expand All @@ -13,9 +12,7 @@ type SolverPartProps = Readonly<{

/**
* The solver part of the sudoku solver
*
* @requiredProps
* - sudoku
* TODO: Change to tab system. Sudoku controls vs strategy controls
*/
export default class SolverPart extends React.Component<SolverPartProps> {
solver: Solver
Expand All @@ -25,8 +22,6 @@ export default class SolverPart extends React.Component<SolverPartProps> {
}
strategyItemStates: StrategyResult[]
constructor(props: SolverPartProps) {
_expect(SolverPart, props).toHaveProperties("sudoku")

super(props)

this.children = {
Expand Down
11 changes: 0 additions & 11 deletions src/Elems/AsideElems/StrategyControl.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { _expect } from '../../utils';
import { _ReactProps } from '../../Types';
import Control from '../Control';

Expand All @@ -12,18 +11,8 @@ type StrategyControlProps = Readonly<{
* Strategy control
* When a user clicks on the control... something happens,
* like a strategy being run against the sudoku.
*
* @requiredProps
* - onClick
* - name
*/
export default class StrategyControl extends React.Component<StrategyControlProps> {
constructor(props: StrategyControlProps) {
_expect(StrategyControl, props).toHaveProperties("onClick", "name")

super(props)
}

render() {
return (
<Control
Expand Down
6 changes: 0 additions & 6 deletions src/Elems/AsideElems/StrategyControls.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import Solver from '../../Api/Solver';
import { _expect } from '../../utils';
import { GuaranteedConstructCallback } from '../../Types';
import StrategyControl from './StrategyControl';

Expand All @@ -10,14 +9,9 @@ type StrategyControlsProps = Readonly<{

/**
* A bunch of strategy controls [TODO]
*
* @requiredProps
* - solver: Solver
*/
export default class StrategyControls extends React.Component<StrategyControlsProps> {
constructor(props: StrategyControlsProps) {
_expect(StrategyControls, props).toHaveProperties("solver")

super(props)
this.props.whenConstruct(this)
}
Expand Down
12 changes: 0 additions & 12 deletions src/Elems/AsideElems/StrategyItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import StrategyLabel, { StrategyLabelProps } from './StrategyLabel';
import StrategyToggler from './StrategyToggler';
import StrategyStatus, { StrategyStatusProps } from './StrategyStatus';
import Solver from '../../Api/Solver';
import { _expect } from '../../utils';
import StrategyTogglerLabel from './StrategyTogglerLabel';

export type StrategyItemProps = StrategyLabelProps & Readonly<{
Expand All @@ -24,23 +23,12 @@ export type StrategyItemState = StrategyStatusProps & Readonly<{
* The strategy element
*
* Passes props to StrategyLabel
*
* @requiredProps
* - name
* - solver
* - index
*
* @optionalProps
* - href
* - required
*/
export default class StrategyItem extends React.Component<StrategyItemProps, StrategyItemState> {
id: `strategy-${string}`;
labelId: `label-for-strategy-${string}`;
togglerId?: `strategy-toggler-${string}`;
constructor(props: StrategyItemProps) {
_expect(StrategyItem, props).toHaveProperties("name", "solver", "index")

super(props)

const name = this.props.name.replaceAll(' ', '-')
Expand Down
13 changes: 3 additions & 10 deletions src/Elems/AsideElems/StrategyLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import React from 'react';
import { _expect } from '../../utils';
import ExternalLink from '../ExternalLink';

export type StrategyLabelProps = Readonly<{
Expand All @@ -16,22 +15,16 @@ export type StrategyLabelProps = Readonly<{
* Really it's just the text inside the StrategyItem,
* besides StrategyResult
*/
export default class StrategyLabel extends React.Component<StrategyLabelProps> {
constructor(props: StrategyLabelProps) {
_expect(StrategyLabel, props).toHaveProperties("name")
super(props)
}

export default class StrategyLabel extends React.PureComponent<StrategyLabelProps> {
render() {
let content = <span className="StrategyLabel" id={this.props.id}>{this.props.name}</span>
if (this.props.href) {
content = (
return (
<ExternalLink className="StrategyLabel" id={this.props.id} href={this.props.href}>
{this.props.name}
</ExternalLink>
)
}

return content
return <span className="StrategyLabel" id={this.props.id}>{this.props.name}</span>
}
}
6 changes: 0 additions & 6 deletions src/Elems/AsideElems/StrategyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import './StrategyList.css'
import React from 'react';
import Solver from '../../Api/Solver';
import { _expect } from '../../utils';
import { GuaranteedConstructCallback } from '../../Types';
import StrategyItem from './StrategyItem';

Expand All @@ -12,14 +11,9 @@ type StrategyListProps = Readonly<{

/**
* A list of strategies
*
* @requiredProps
* - solver
*/
export default class StrategyList extends React.Component<StrategyListProps> {
constructor(props: StrategyListProps) {
_expect(StrategyList, props).toHaveProperties("solver")

super(props)
this.props.whenConstruct()
}
Expand Down
11 changes: 0 additions & 11 deletions src/Elems/AsideElems/StrategyStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import React from 'react';
import { SuccessError } from '../../Api/Types';
import { _expect } from '../../utils';

export type StrategyStatusProps = Readonly<{
success: null
Expand All @@ -14,18 +13,8 @@ export type StrategyStatusProps = Readonly<{

/**
* How did trying the strategy go?
*
* @requiredProps
* - success
* - successcount
*/
export default class StrategyStatus extends React.Component<StrategyStatusProps> {
constructor(props: StrategyStatusProps) {
_expect(StrategyStatus, props).toHaveProperties("success", "successcount")

super(props)
}

render() {
const resultText =
this.props.success === null
Expand Down
7 changes: 0 additions & 7 deletions src/Elems/AsideElems/StrategyToggler.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

import React from 'react';
import { _expect } from '../../utils';

type StrategyTogglerProps = Readonly<{
callback: React.ChangeEventHandler
Expand All @@ -13,15 +12,9 @@ type StrategyTogglerState = Readonly<{

/**
* Turns a strategy off or on
*
* @requiredProps
* - callback
* - id
*/
export default class StrategyToggler extends React.Component<StrategyTogglerProps, StrategyTogglerState> {
constructor(props: StrategyTogglerProps) {
_expect(StrategyToggler, props).toHaveProperties("callback", "id")

super(props)

this.state = {
Expand Down
14 changes: 6 additions & 8 deletions src/Elems/AsideElems/StrategyTogglerLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import React from 'react';
import { _expect } from '../../utils';

export type StrategyTogglerLabelProps = Readonly<{
name: string
Expand All @@ -14,13 +13,12 @@ export type StrategyTogglerLabelProps = Readonly<{
* Really it's just the text inside the StrategyItem,
* besides StrategyResult
*/
export default class StrategyTogglerLabel extends React.Component<StrategyTogglerLabelProps> {
constructor(props: StrategyTogglerLabelProps) {
_expect(StrategyTogglerLabel, props).toHaveProperties("name")
super(props)
}

export default class StrategyTogglerLabel extends React.PureComponent<StrategyTogglerLabelProps> {
render() {
return <span className="StrategyTogglerLabel" id={this.props.id}>{"Toggle " + this.props.name}</span>
return (
<span className="StrategyTogglerLabel" id={this.props.id}>
{`Toggle ${this.props.name}`}
</span>
)
}
}
6 changes: 0 additions & 6 deletions src/Elems/Control.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { _expect } from '../utils';

type ControlProps = Readonly<{
className?: string
Expand All @@ -10,11 +9,6 @@ type ControlProps = Readonly<{
* A general button control
*/
export default class Control extends React.PureComponent<ControlProps> {
constructor(props: ControlProps) {
_expect(Control, props).toHaveProperties("onClick")
super(props)
}

render() {
const className = this.props.className ?? 'Control'
return (
Expand Down
Loading

0 comments on commit 5cfefe7

Please sign in to comment.