ps99-api 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@
16
16
  "ps99-api": "file:../..",
17
17
  "react": "^18.3.1",
18
18
  "react-dom": "^18.3.1",
19
- "react-router-dom": "^6.23.1"
19
+ "react-router-dom": "^6.24.1"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/react": "^18.3.3",
@@ -26,8 +26,8 @@
26
26
  "css-loader": "^7.1.2",
27
27
  "html-webpack-plugin": "^5.6.0",
28
28
  "ts-loader": "^9.5.1",
29
- "typescript": "^5.5.2",
30
- "webpack": "^5.92.0",
29
+ "typescript": "^5.5.3",
30
+ "webpack": "^5.92.1",
31
31
  "webpack-cli": "^5.1.4",
32
32
  "webpack-dev-server": "^5.0.4",
33
33
  "workbox-webpack-plugin": "^7.1.0"
@@ -14,8 +14,14 @@ const App: React.FC = () => {
14
14
  <Routes>
15
15
  <Route path="/" element={<HomePage />} />
16
16
  <Route path="/collections" element={<CollectionsIndex />} />
17
- <Route path="/collections/:collectionName" element={<CollectionConfigIndex />} />
18
- <Route path="/collections/:collectionName/:configName" element={<DynamicCollectionConfigData />} />
17
+ <Route
18
+ path="/collections/:collectionName"
19
+ element={<CollectionConfigIndex />}
20
+ />
21
+ <Route
22
+ path="/collections/:collectionName/:configName"
23
+ element={<DynamicCollectionConfigData />}
24
+ />
19
25
  </Routes>
20
26
  <Footer />
21
27
  </Router>
@@ -3,7 +3,10 @@ import { useParams } from "react-router-dom";
3
3
  import { CollectionName } from "ps99-api";
4
4
 
5
5
  const DynamicCollectionConfigData: React.FC = () => {
6
- const { collectionName, configName } = useParams<{ collectionName: CollectionName; configName: string }>();
6
+ const { collectionName, configName } = useParams<{
7
+ collectionName: CollectionName;
8
+ configName: string;
9
+ }>();
7
10
 
8
11
  if (!collectionName || !configName) {
9
12
  return <div>Invalid collection or config name</div>;
@@ -9,10 +9,10 @@ interface GenericFetchComponentProps<T> {
9
9
  }
10
10
 
11
11
  export const GenericFetchComponent = <T,>({
12
- collectionName,
13
- render,
14
- configData,
15
- }: GenericFetchComponentProps<T>) => {
12
+ collectionName,
13
+ render,
14
+ configData,
15
+ }: GenericFetchComponentProps<T>) => {
16
16
  const { configName } = useParams<{ configName: string }>();
17
17
  const [data, setData] = useState<T | null>(configData || null);
18
18
  const [error, setError] = useState<string | null>(null);
@@ -23,9 +23,12 @@ export const GenericFetchComponent = <T,>({
23
23
  const fetchData = async () => {
24
24
  if (!configName) return;
25
25
  const api = new PetSimulator99API();
26
- const response: ApiResponseBody<any[]> = await api.getCollection(collectionName);
26
+ const response: ApiResponseBody<any[]> =
27
+ await api.getCollection(collectionName);
27
28
  if (response.status === "ok") {
28
- const item = response.data.find((item) => item.configName === configName);
29
+ const item = response.data.find(
30
+ (item) => item.configName === configName,
31
+ );
29
32
  if (item) {
30
33
  setData(item.configData);
31
34
  } else {
@@ -28,7 +28,9 @@ const ImageComponent: React.FC<ImageProps> = ({ src, alt }) => {
28
28
  const api = new PetSimulator99API();
29
29
  try {
30
30
  const imageBlob = await api.getImage(src);
31
- const url = URL.createObjectURL(new Blob([imageBlob], { type: "image/png" }));
31
+ const url = URL.createObjectURL(
32
+ new Blob([imageBlob], { type: "image/png" }),
33
+ );
32
34
  setImageUrl(url);
33
35
  } catch (error) {
34
36
  console.error("Error fetching image:", error);
@@ -53,9 +55,7 @@ const ImageComponent: React.FC<ImageProps> = ({ src, alt }) => {
53
55
  }, [src]);
54
56
 
55
57
  return (
56
- <div>
57
- {imageUrl ? <img src={imageUrl} alt={alt} /> : <p>Loading...</p>}
58
- </div>
58
+ <div>{imageUrl ? <img src={imageUrl} alt={alt} /> : <p>Loading...</p>}</div>
59
59
  );
60
60
  };
61
61
 
@@ -1,4 +1,5 @@
1
1
  const path = require("path");
2
+ const CopyWebpackPlugin = require("copy-webpack-plugin");
2
3
 
3
4
  module.exports = {
4
5
  entry: "./src/index.tsx",
@@ -27,6 +28,11 @@ module.exports = {
27
28
  path: path.resolve(__dirname, "dist"),
28
29
  publicPath: "/",
29
30
  },
31
+ plugins: [
32
+ new CopyWebpackPlugin({
33
+ patterns: [{ from: path.resolve(__dirname, "public") }],
34
+ }),
35
+ ],
30
36
  devServer: {
31
37
  static: {
32
38
  directory: path.join(__dirname, "public"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ps99-api",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Pet Simulator Public API wrapper written in Typescript.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -25,15 +25,15 @@
25
25
  "@semantic-release/git": "^10.0.1",
26
26
  "@tsconfig/node20": "^20.1.4",
27
27
  "@types/jest": "^29.5.12",
28
- "@types/node": "^20.14.2",
28
+ "@types/node": "^20.14.10",
29
29
  "cz-conventional-changelog": "^3.3.0",
30
30
  "dets": "^0.16.0",
31
31
  "esbuild": "0.21.5",
32
32
  "jest": "^29.7.0",
33
33
  "prettier": "^3.3.2",
34
34
  "semantic-release": "^24.0.0",
35
- "ts-jest": "^29.1.2",
36
- "typescript": "^5.4.5"
35
+ "ts-jest": "^29.1.5",
36
+ "typescript": "^5.5.3"
37
37
  },
38
38
  "dependencies": {
39
39
  "axios": "^1.7.2"