Skip to content

Commit

Permalink
Complete transition from TypeScript to typed JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
glacials committed Apr 19, 2024
1 parent a4e94f8 commit 5d0183a
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 593 deletions.
6 changes: 2 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

_What's in Standard?_ has three code bases.
_What's in Standard?_ has three code bases, all in this repository.

- API and website (see below)
- Mobile apps (see [`./mobile`](./mobile))
Expand All @@ -27,9 +27,7 @@ npm install
npm start
```

Then open [localhost:8080][localhost] in your browser!

[localhost]: http://localhost:8080
Then open the printed local URL in your browser.

### Common tasks

Expand Down
2 changes: 1 addition & 1 deletion web/.node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.10.0
21.7.3
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<body data-spy="scroll" data-target="#nav" id="sets">
<div id="app" class="container"></div>
<script type="module" src="/src/main.ts"></script>
<script type="module" src="/src/main.js"></script>

<script>
(function (i, s, o, g, r, a, m) {
Expand Down
749 changes: 236 additions & 513 deletions web/package-lock.json

Large diffs are not rendered by default.

14 changes: 2 additions & 12 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,16 @@
"requirejs": "^2.3.6",
"sass": "^1.69.7",
"supervisor": "^0.12.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
"vite": "^4.3.9",
"vue-loader": "^17.2.2",
"vue-template-compiler": "^2.7.14",
"webpack-cli": "^5.1.4"
},
"engines": {
"node": "^20"
"node": "^21"
},
"license": "MIT",
"homepage": "https://github.com/glacials/whatsinstandard",
"mocha": {
"extensions": [
"ts"
],
"node-option": [
"loader=ts-node/esm"
]
},
"name": "whatsinstandard",
"people": {
"author": {
Expand All @@ -61,7 +51,7 @@
"prepare": "./node_modules/node/bin/node api/generate.js",
"preview": "vite preview",
"start": "vite",
"test": "mocha test/api.ts"
"test": "mocha test/api.js"
},
"type": "module",
"version": "1.0.1"
Expand Down
8 changes: 5 additions & 3 deletions web/src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const apiURL = "/api/v6/standard.json";
* @param bans The bans to filter.
* @returns The bans that apply to the given sets.
*/
function bansFor(sets: card.Set[], bans: card.Ban[]) {
function bansFor(sets: card.CardSet[], bans: card.Ban[]) {
return bans.filter((ban: card.Ban) =>
sets.map((set: card.Set) => set.code).includes(ban.setCode)
sets.map((set: card.CardSet) => set.code).includes(ban.setCode)
);
}
Expand All @@ -42,7 +42,9 @@ const hideAlert20230507 = ref(
watchEffect(async () => {
const body = await (await fetch(apiURL)).json();
rounds.value = card.Round.ify(body.sets.map((set: any) => new card.Set(set)));
rounds.value = card.Round.ify(
body.sets.map((set: any) => new card.CardSet(set))
);
bans.value = body.bans.map((ban: any) => new card.Ban(ban));
});
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion web/src/types/card/Ban.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* A {@link Ban} is a card that is or was banned in Standard.
*/
export class Ban {
export default class Ban {
/**
* Create a new {@link Ban} from the given JSON.
*/
Expand Down
6 changes: 3 additions & 3 deletions web/src/types/card/CardSet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BiDate } from "../BiDate.js";
import { Symbol } from "./Symbol.js";
import Symbol from "./Symbol.js";

/**
* A Magic: The Gathering set.
Expand Down Expand Up @@ -152,14 +152,14 @@ export default class CardSet {
* @returns {string} The card set as a JSON object.
*/
toJSON() {
return JSON.stringify({
return JSON.stringify({
name: this.name,
codename: this.codename,
code: this.code,
symbol: Object.assign({}, this.symbol),
enterDate: Object.assign({}, this.enterDate),
exitDate: Object.assign({}, this.exitDate),
internalId: this.internalId,
})
});
}
}
4 changes: 2 additions & 2 deletions web/src/types/card/Round.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CardSet } from "./CardSet";
import CardSet from "./CardSet";

/**
* A group of {@link CardSet CardSets} that share an exit date.
*/
export class Round {
export default class Round {
/**
* Return the {@link Round Rounds} in the given array that have dropped from Standard,
* according to local time. Order is preserved.
Expand Down
2 changes: 1 addition & 1 deletion web/src/types/card/Symbol.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* A set symbol icon.
*/
export class Symbol {
export default class Symbol {
/**
* Create a new Symbol.
*
Expand Down
8 changes: 5 additions & 3 deletions web/src/types/card/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export { Ban } from "./Ban.js";
export { Round } from "./Round.js";
export { Set } from "./Set.js";
import Ban from "./Ban.js";
import Round from "./Round.js";
import CardSet from "./CardSet.js";

export { Ban, Round, CardSet };
File renamed without changes.
37 changes: 0 additions & 37 deletions web/tsconfig.json

This file was deleted.

12 changes: 0 additions & 12 deletions web/tsconfig.node.json

This file was deleted.

0 comments on commit 5d0183a

Please sign in to comment.